1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { OnDestroy } from '@angular/core';
|
---|
9 | /**
|
---|
10 | * Interface used to register message elements and keep a count of how many registrations have
|
---|
11 | * the same message and the reference to the message element used for the `aria-describedby`.
|
---|
12 | */
|
---|
13 | import * as ɵngcc0 from '@angular/core';
|
---|
14 | export interface RegisteredMessage {
|
---|
15 | /** The element containing the message. */
|
---|
16 | messageElement: Element;
|
---|
17 | /** The number of elements that reference this message element via `aria-describedby`. */
|
---|
18 | referenceCount: number;
|
---|
19 | }
|
---|
20 | /** ID used for the body container where all messages are appended. */
|
---|
21 | export declare const MESSAGES_CONTAINER_ID = "cdk-describedby-message-container";
|
---|
22 | /** ID prefix used for each created message element. */
|
---|
23 | export declare const CDK_DESCRIBEDBY_ID_PREFIX = "cdk-describedby-message";
|
---|
24 | /** Attribute given to each host element that is described by a message element. */
|
---|
25 | export declare const CDK_DESCRIBEDBY_HOST_ATTRIBUTE = "cdk-describedby-host";
|
---|
26 | /**
|
---|
27 | * Utility that creates visually hidden elements with a message content. Useful for elements that
|
---|
28 | * want to use aria-describedby to further describe themselves without adding additional visual
|
---|
29 | * content.
|
---|
30 | */
|
---|
31 | export declare class AriaDescriber implements OnDestroy {
|
---|
32 | private _document;
|
---|
33 | constructor(_document: any);
|
---|
34 | /**
|
---|
35 | * Adds to the host element an aria-describedby reference to a hidden element that contains
|
---|
36 | * the message. If the same message has already been registered, then it will reuse the created
|
---|
37 | * message element.
|
---|
38 | */
|
---|
39 | describe(hostElement: Element, message: string, role?: string): void;
|
---|
40 | /**
|
---|
41 | * Adds to the host element an aria-describedby reference to an already-existing message element.
|
---|
42 | */
|
---|
43 | describe(hostElement: Element, message: HTMLElement): void;
|
---|
44 | /** Removes the host element's aria-describedby reference to the message. */
|
---|
45 | removeDescription(hostElement: Element, message: string, role?: string): void;
|
---|
46 | /** Removes the host element's aria-describedby reference to the message element. */
|
---|
47 | removeDescription(hostElement: Element, message: HTMLElement): void;
|
---|
48 | /** Unregisters all created message elements and removes the message container. */
|
---|
49 | ngOnDestroy(): void;
|
---|
50 | /**
|
---|
51 | * Creates a new element in the visually hidden message container element with the message
|
---|
52 | * as its content and adds it to the message registry.
|
---|
53 | */
|
---|
54 | private _createMessageElement;
|
---|
55 | /** Deletes the message element from the global messages container. */
|
---|
56 | private _deleteMessageElement;
|
---|
57 | /** Creates the global container for all aria-describedby messages. */
|
---|
58 | private _createMessagesContainer;
|
---|
59 | /** Deletes the global messages container. */
|
---|
60 | private _deleteMessagesContainer;
|
---|
61 | /** Removes all cdk-describedby messages that are hosted through the element. */
|
---|
62 | private _removeCdkDescribedByReferenceIds;
|
---|
63 | /**
|
---|
64 | * Adds a message reference to the element using aria-describedby and increments the registered
|
---|
65 | * message's reference count.
|
---|
66 | */
|
---|
67 | private _addMessageReference;
|
---|
68 | /**
|
---|
69 | * Removes a message reference from the element using aria-describedby
|
---|
70 | * and decrements the registered message's reference count.
|
---|
71 | */
|
---|
72 | private _removeMessageReference;
|
---|
73 | /** Returns true if the element has been described by the provided message ID. */
|
---|
74 | private _isElementDescribedByMessage;
|
---|
75 | /** Determines whether a message can be described on a particular element. */
|
---|
76 | private _canBeDescribed;
|
---|
77 | /** Checks whether a node is an Element node. */
|
---|
78 | private _isElementNode;
|
---|
79 | static ɵfac: ɵngcc0.ɵɵFactoryDeclaration<AriaDescriber, never>;
|
---|
80 | }
|
---|
81 |
|
---|
82 | //# sourceMappingURL=aria-describer.d.ts.map |
---|