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 | export interface RegisteredMessage {
|
---|
14 | /** The element containing the message. */
|
---|
15 | messageElement: Element;
|
---|
16 | /** The number of elements that reference this message element via `aria-describedby`. */
|
---|
17 | referenceCount: number;
|
---|
18 | }
|
---|
19 | /** ID used for the body container where all messages are appended. */
|
---|
20 | export declare const MESSAGES_CONTAINER_ID = "cdk-describedby-message-container";
|
---|
21 | /** ID prefix used for each created message element. */
|
---|
22 | export declare const CDK_DESCRIBEDBY_ID_PREFIX = "cdk-describedby-message";
|
---|
23 | /** Attribute given to each host element that is described by a message element. */
|
---|
24 | export declare const CDK_DESCRIBEDBY_HOST_ATTRIBUTE = "cdk-describedby-host";
|
---|
25 | /**
|
---|
26 | * Utility that creates visually hidden elements with a message content. Useful for elements that
|
---|
27 | * want to use aria-describedby to further describe themselves without adding additional visual
|
---|
28 | * content.
|
---|
29 | */
|
---|
30 | export declare class AriaDescriber implements OnDestroy {
|
---|
31 | private _document;
|
---|
32 | constructor(_document: any);
|
---|
33 | /**
|
---|
34 | * Adds to the host element an aria-describedby reference to a hidden element that contains
|
---|
35 | * the message. If the same message has already been registered, then it will reuse the created
|
---|
36 | * message element.
|
---|
37 | */
|
---|
38 | describe(hostElement: Element, message: string, role?: string): void;
|
---|
39 | /**
|
---|
40 | * Adds to the host element an aria-describedby reference to an already-existing message element.
|
---|
41 | */
|
---|
42 | describe(hostElement: Element, message: HTMLElement): void;
|
---|
43 | /** Removes the host element's aria-describedby reference to the message. */
|
---|
44 | removeDescription(hostElement: Element, message: string, role?: string): void;
|
---|
45 | /** Removes the host element's aria-describedby reference to the message element. */
|
---|
46 | removeDescription(hostElement: Element, message: HTMLElement): void;
|
---|
47 | /** Unregisters all created message elements and removes the message container. */
|
---|
48 | ngOnDestroy(): void;
|
---|
49 | /**
|
---|
50 | * Creates a new element in the visually hidden message container element with the message
|
---|
51 | * as its content and adds it to the message registry.
|
---|
52 | */
|
---|
53 | private _createMessageElement;
|
---|
54 | /** Deletes the message element from the global messages container. */
|
---|
55 | private _deleteMessageElement;
|
---|
56 | /** Creates the global container for all aria-describedby messages. */
|
---|
57 | private _createMessagesContainer;
|
---|
58 | /** Deletes the global messages container. */
|
---|
59 | private _deleteMessagesContainer;
|
---|
60 | /** Removes all cdk-describedby messages that are hosted through the element. */
|
---|
61 | private _removeCdkDescribedByReferenceIds;
|
---|
62 | /**
|
---|
63 | * Adds a message reference to the element using aria-describedby and increments the registered
|
---|
64 | * message's reference count.
|
---|
65 | */
|
---|
66 | private _addMessageReference;
|
---|
67 | /**
|
---|
68 | * Removes a message reference from the element using aria-describedby
|
---|
69 | * and decrements the registered message's reference count.
|
---|
70 | */
|
---|
71 | private _removeMessageReference;
|
---|
72 | /** Returns true if the element has been described by the provided message ID. */
|
---|
73 | private _isElementDescribedByMessage;
|
---|
74 | /** Determines whether a message can be described on a particular element. */
|
---|
75 | private _canBeDescribed;
|
---|
76 | /** Checks whether a node is an Element node. */
|
---|
77 | private _isElementNode;
|
---|
78 | }
|
---|