UNPKG

49.1 kBTypeScriptView Raw
1import { AfterContentInit } from '@angular/core';
2import { AfterViewInit } from '@angular/core';
3import { BooleanInput } from '@angular/cdk/coercion';
4import { ContentObserver } from '@angular/cdk/observers';
5import { DoCheck } from '@angular/core';
6import { ElementRef } from '@angular/core';
7import { EventEmitter } from '@angular/core';
8import * as i0 from '@angular/core';
9import * as i4 from '@angular/cdk/observers';
10import { InjectionToken } from '@angular/core';
11import { NgZone } from '@angular/core';
12import { Observable } from 'rxjs';
13import { OnChanges } from '@angular/core';
14import { OnDestroy } from '@angular/core';
15import { Platform } from '@angular/cdk/platform';
16import { QueryList } from '@angular/core';
17import { SimpleChanges } from '@angular/core';
18import { Subject } from 'rxjs';
19
20export declare class A11yModule {
21 constructor(highContrastModeDetector: HighContrastModeDetector);
22 static ɵfac: i0.ɵɵFactoryDeclaration<A11yModule, never>;
23 static ɵmod: i0.ɵɵNgModuleDeclaration<A11yModule, [typeof i1.CdkAriaLive, typeof i2.CdkTrapFocus, typeof i3.CdkMonitorFocus], [typeof i4.ObserversModule], [typeof i1.CdkAriaLive, typeof i2.CdkTrapFocus, typeof i3.CdkMonitorFocus]>;
24 static ɵinj: i0.ɵɵInjectorDeclaration<A11yModule>;
25}
26
27export declare class ActiveDescendantKeyManager<T> extends ListKeyManager<Highlightable & T> {
28 /**
29 * Sets the active item to the item at the specified index and adds the
30 * active styles to the newly active item. Also removes active styles
31 * from the previously active item.
32 * @param index Index of the item to be set as active.
33 */
34 setActiveItem(index: number): void;
35 /**
36 * Sets the active item to the item to the specified one and adds the
37 * active styles to the it. Also removes active styles from the
38 * previously active item.
39 * @param item Item to be set as active.
40 */
41 setActiveItem(item: T): void;
42}
43
44/**
45 * Utility that creates visually hidden elements with a message content. Useful for elements that
46 * want to use aria-describedby to further describe themselves without adding additional visual
47 * content.
48 */
49export declare class AriaDescriber implements OnDestroy {
50 /**
51 * @deprecated To be turned into a required parameter.
52 * @breaking-change 14.0.0
53 */
54 private _platform?;
55 private _document;
56 /** Map of all registered message elements that have been placed into the document. */
57 private _messageRegistry;
58 /** Container for all registered messages. */
59 private _messagesContainer;
60 /** Unique ID for the service. */
61 private readonly _id;
62 constructor(_document: any,
63 /**
64 * @deprecated To be turned into a required parameter.
65 * @breaking-change 14.0.0
66 */
67 _platform?: Platform | undefined);
68 /**
69 * Adds to the host element an aria-describedby reference to a hidden element that contains
70 * the message. If the same message has already been registered, then it will reuse the created
71 * message element.
72 */
73 describe(hostElement: Element, message: string, role?: string): void;
74 /**
75 * Adds to the host element an aria-describedby reference to an already-existing message element.
76 */
77 describe(hostElement: Element, message: HTMLElement): void;
78 /** Removes the host element's aria-describedby reference to the message. */
79 removeDescription(hostElement: Element, message: string, role?: string): void;
80 /** Removes the host element's aria-describedby reference to the message element. */
81 removeDescription(hostElement: Element, message: HTMLElement): void;
82 /** Unregisters all created message elements and removes the message container. */
83 ngOnDestroy(): void;
84 /**
85 * Creates a new element in the visually hidden message container element with the message
86 * as its content and adds it to the message registry.
87 */
88 private _createMessageElement;
89 /** Deletes the message element from the global messages container. */
90 private _deleteMessageElement;
91 /** Creates the global container for all aria-describedby messages. */
92 private _createMessagesContainer;
93 /** Removes all cdk-describedby messages that are hosted through the element. */
94 private _removeCdkDescribedByReferenceIds;
95 /**
96 * Adds a message reference to the element using aria-describedby and increments the registered
97 * message's reference count.
98 */
99 private _addMessageReference;
100 /**
101 * Removes a message reference from the element using aria-describedby
102 * and decrements the registered message's reference count.
103 */
104 private _removeMessageReference;
105 /** Returns true if the element has been described by the provided message ID. */
106 private _isElementDescribedByMessage;
107 /** Determines whether a message can be described on a particular element. */
108 private _canBeDescribed;
109 /** Checks whether a node is an Element node. */
110 private _isElementNode;
111 static ɵfac: i0.ɵɵFactoryDeclaration<AriaDescriber, never>;
112 static ɵprov: i0.ɵɵInjectableDeclaration<AriaDescriber>;
113}
114
115/** Possible politeness levels. */
116export declare type AriaLivePoliteness = 'off' | 'polite' | 'assertive';
117
118/**
119 * Attribute given to each host element that is described by a message element.
120 * @deprecated To be turned into a private variable.
121 * @breaking-change 14.0.0
122 */
123export declare const CDK_DESCRIBEDBY_HOST_ATTRIBUTE = "cdk-describedby-host";
124
125/**
126 * ID prefix used for each created message element.
127 * @deprecated To be turned into a private variable.
128 * @breaking-change 14.0.0
129 */
130export declare const CDK_DESCRIBEDBY_ID_PREFIX = "cdk-describedby-message";
131
132/**
133 * A directive that works similarly to aria-live, but uses the LiveAnnouncer to ensure compatibility
134 * with a wider range of browsers and screen readers.
135 */
136export declare class CdkAriaLive implements OnDestroy {
137 private _elementRef;
138 private _liveAnnouncer;
139 private _contentObserver;
140 private _ngZone;
141 /** The aria-live politeness level to use when announcing messages. */
142 get politeness(): AriaLivePoliteness;
143 set politeness(value: AriaLivePoliteness);
144 private _politeness;
145 /** Time in milliseconds after which to clear out the announcer element. */
146 duration: number;
147 private _previousAnnouncedText?;
148 private _subscription;
149 constructor(_elementRef: ElementRef, _liveAnnouncer: LiveAnnouncer, _contentObserver: ContentObserver, _ngZone: NgZone);
150 ngOnDestroy(): void;
151 static ɵfac: i0.ɵɵFactoryDeclaration<CdkAriaLive, never>;
152 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkAriaLive, "[cdkAriaLive]", ["cdkAriaLive"], { "politeness": { "alias": "cdkAriaLive"; "required": false; }; "duration": { "alias": "cdkAriaLiveDuration"; "required": false; }; }, {}, never, never, false, never>;
153}
154
155/**
156 * Directive that determines how a particular element was focused (via keyboard, mouse, touch, or
157 * programmatically) and adds corresponding classes to the element.
158 *
159 * There are two variants of this directive:
160 * 1) cdkMonitorElementFocus: does not consider an element to be focused if one of its children is
161 * focused.
162 * 2) cdkMonitorSubtreeFocus: considers an element focused if it or any of its children are focused.
163 */
164export declare class CdkMonitorFocus implements AfterViewInit, OnDestroy {
165 private _elementRef;
166 private _focusMonitor;
167 private _monitorSubscription;
168 private _focusOrigin;
169 readonly cdkFocusChange: EventEmitter<FocusOrigin>;
170 constructor(_elementRef: ElementRef<HTMLElement>, _focusMonitor: FocusMonitor);
171 get focusOrigin(): FocusOrigin;
172 ngAfterViewInit(): void;
173 ngOnDestroy(): void;
174 static ɵfac: i0.ɵɵFactoryDeclaration<CdkMonitorFocus, never>;
175 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkMonitorFocus, "[cdkMonitorElementFocus], [cdkMonitorSubtreeFocus]", ["cdkMonitorFocus"], {}, { "cdkFocusChange": "cdkFocusChange"; }, never, never, false, never>;
176}
177
178/** Directive for trapping focus within a region. */
179export declare class CdkTrapFocus implements OnDestroy, AfterContentInit, OnChanges, DoCheck {
180 private _elementRef;
181 private _focusTrapFactory;
182 /** Underlying FocusTrap instance. */
183 focusTrap: FocusTrap;
184 /** Previously focused element to restore focus to upon destroy when using autoCapture. */
185 private _previouslyFocusedElement;
186 /** Whether the focus trap is active. */
187 get enabled(): boolean;
188 set enabled(value: BooleanInput);
189 /**
190 * Whether the directive should automatically move focus into the trapped region upon
191 * initialization and return focus to the previous activeElement upon destruction.
192 */
193 get autoCapture(): boolean;
194 set autoCapture(value: BooleanInput);
195 private _autoCapture;
196 constructor(_elementRef: ElementRef<HTMLElement>, _focusTrapFactory: FocusTrapFactory,
197 /**
198 * @deprecated No longer being used. To be removed.
199 * @breaking-change 13.0.0
200 */
201 _document: any);
202 ngOnDestroy(): void;
203 ngAfterContentInit(): void;
204 ngDoCheck(): void;
205 ngOnChanges(changes: SimpleChanges): void;
206 private _captureFocus;
207 static ɵfac: i0.ɵɵFactoryDeclaration<CdkTrapFocus, never>;
208 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkTrapFocus, "[cdkTrapFocus]", ["cdkTrapFocus"], { "enabled": { "alias": "cdkTrapFocus"; "required": false; }; "autoCapture": { "alias": "cdkTrapFocusAutoCapture"; "required": false; }; }, {}, never, never, false, never>;
209}
210
211/**
212 * Class that allows for trapping focus within a DOM element.
213 *
214 * This class uses a strategy pattern that determines how it traps focus.
215 * See FocusTrapInertStrategy.
216 */
217export declare class ConfigurableFocusTrap extends FocusTrap implements ManagedFocusTrap {
218 private _focusTrapManager;
219 private _inertStrategy;
220 /** Whether the FocusTrap is enabled. */
221 get enabled(): boolean;
222 set enabled(value: boolean);
223 constructor(_element: HTMLElement, _checker: InteractivityChecker, _ngZone: NgZone, _document: Document, _focusTrapManager: FocusTrapManager, _inertStrategy: FocusTrapInertStrategy, config: ConfigurableFocusTrapConfig);
224 /** Notifies the FocusTrapManager that this FocusTrap will be destroyed. */
225 destroy(): void;
226 /** @docs-private Implemented as part of ManagedFocusTrap. */
227 _enable(): void;
228 /** @docs-private Implemented as part of ManagedFocusTrap. */
229 _disable(): void;
230}
231
232
233/**
234 * Options for creating a ConfigurableFocusTrap.
235 */
236export declare interface ConfigurableFocusTrapConfig {
237 /**
238 * Whether to defer the creation of FocusTrap elements to be done manually by the user.
239 */
240 defer: boolean;
241}
242
243/** Factory that allows easy instantiation of configurable focus traps. */
244export declare class ConfigurableFocusTrapFactory {
245 private _checker;
246 private _ngZone;
247 private _focusTrapManager;
248 private _document;
249 private _inertStrategy;
250 constructor(_checker: InteractivityChecker, _ngZone: NgZone, _focusTrapManager: FocusTrapManager, _document: any, _inertStrategy?: FocusTrapInertStrategy);
251 /**
252 * Creates a focus-trapped region around the given element.
253 * @param element The element around which focus will be trapped.
254 * @param config The focus trap configuration.
255 * @returns The created focus trap instance.
256 */
257 create(element: HTMLElement, config?: ConfigurableFocusTrapConfig): ConfigurableFocusTrap;
258 /**
259 * @deprecated Pass a config object instead of the `deferCaptureElements` flag.
260 * @breaking-change 11.0.0
261 */
262 create(element: HTMLElement, deferCaptureElements: boolean): ConfigurableFocusTrap;
263 static ɵfac: i0.ɵɵFactoryDeclaration<ConfigurableFocusTrapFactory, [null, null, null, null, { optional: true; }]>;
264 static ɵprov: i0.ɵɵInjectableDeclaration<ConfigurableFocusTrapFactory>;
265}
266
267/**
268 * Lightweight FocusTrapInertStrategy that adds a document focus event
269 * listener to redirect focus back inside the FocusTrap.
270 */
271export declare class EventListenerFocusTrapInertStrategy implements FocusTrapInertStrategy {
272 /** Focus event handler. */
273 private _listener;
274 /** Adds a document event listener that keeps focus inside the FocusTrap. */
275 preventFocus(focusTrap: ConfigurableFocusTrap): void;
276 /** Removes the event listener added in preventFocus. */
277 allowFocus(focusTrap: ConfigurableFocusTrap): void;
278 /**
279 * Refocuses the first element in the FocusTrap if the focus event target was outside
280 * the FocusTrap.
281 *
282 * This is an event listener callback. The event listener is added in runOutsideAngular,
283 * so all this code runs outside Angular as well.
284 */
285 private _trapFocus;
286}
287
288/** InjectionToken for FocusMonitorOptions. */
289export declare const FOCUS_MONITOR_DEFAULT_OPTIONS: InjectionToken<FocusMonitorOptions>;
290
291/** The injection token used to specify the inert strategy. */
292export declare const FOCUS_TRAP_INERT_STRATEGY: InjectionToken<FocusTrapInertStrategy>;
293
294/**
295 * This is the interface for focusable items (used by the FocusKeyManager).
296 * Each item must know how to focus itself, whether or not it is currently disabled
297 * and be able to supply its label.
298 */
299export declare interface FocusableOption extends ListKeyManagerOption {
300 /** Focuses the `FocusableOption`. */
301 focus(origin?: FocusOrigin): void;
302}
303
304export declare class FocusKeyManager<T> extends ListKeyManager<FocusableOption & T> {
305 private _origin;
306 /**
307 * Sets the focus origin that will be passed in to the items for any subsequent `focus` calls.
308 * @param origin Focus origin to be used when focusing items.
309 */
310 setFocusOrigin(origin: FocusOrigin): this;
311 /**
312 * Sets the active item to the item at the specified
313 * index and focuses the newly active item.
314 * @param index Index of the item to be set as active.
315 */
316 setActiveItem(index: number): void;
317 /**
318 * Sets the active item to the item that is specified and focuses it.
319 * @param item Item to be set as active.
320 */
321 setActiveItem(item: T): void;
322}
323
324/** Monitors mouse and keyboard events to determine the cause of focus events. */
325export declare class FocusMonitor implements OnDestroy {
326 private _ngZone;
327 private _platform;
328 private readonly _inputModalityDetector;
329 /** The focus origin that the next focus event is a result of. */
330 private _origin;
331 /** The FocusOrigin of the last focus event tracked by the FocusMonitor. */
332 private _lastFocusOrigin;
333 /** Whether the window has just been focused. */
334 private _windowFocused;
335 /** The timeout id of the window focus timeout. */
336 private _windowFocusTimeoutId;
337 /** The timeout id of the origin clearing timeout. */
338 private _originTimeoutId;
339 /**
340 * Whether the origin was determined via a touch interaction. Necessary as properly attributing
341 * focus events to touch interactions requires special logic.
342 */
343 private _originFromTouchInteraction;
344 /** Map of elements being monitored to their info. */
345 private _elementInfo;
346 /** The number of elements currently being monitored. */
347 private _monitoredElementCount;
348 /**
349 * Keeps track of the root nodes to which we've currently bound a focus/blur handler,
350 * as well as the number of monitored elements that they contain. We have to treat focus/blur
351 * handlers differently from the rest of the events, because the browser won't emit events
352 * to the document when focus moves inside of a shadow root.
353 */
354 private _rootNodeFocusListenerCount;
355 /**
356 * The specified detection mode, used for attributing the origin of a focus
357 * event.
358 */
359 private readonly _detectionMode;
360 /**
361 * Event listener for `focus` events on the window.
362 * Needs to be an arrow function in order to preserve the context when it gets bound.
363 */
364 private _windowFocusListener;
365 /** Used to reference correct document/window */
366 protected _document?: Document;
367 /** Subject for stopping our InputModalityDetector subscription. */
368 private readonly _stopInputModalityDetector;
369 constructor(_ngZone: NgZone, _platform: Platform, _inputModalityDetector: InputModalityDetector,
370 /** @breaking-change 11.0.0 make document required */
371 document: any | null, options: FocusMonitorOptions | null);
372 /**
373 * Event listener for `focus` and 'blur' events on the document.
374 * Needs to be an arrow function in order to preserve the context when it gets bound.
375 */
376 private _rootNodeFocusAndBlurListener;
377 /**
378 * Monitors focus on an element and applies appropriate CSS classes.
379 * @param element The element to monitor
380 * @param checkChildren Whether to count the element as focused when its children are focused.
381 * @returns An observable that emits when the focus state of the element changes.
382 * When the element is blurred, null will be emitted.
383 */
384 monitor(element: HTMLElement, checkChildren?: boolean): Observable<FocusOrigin>;
385 /**
386 * Monitors focus on an element and applies appropriate CSS classes.
387 * @param element The element to monitor
388 * @param checkChildren Whether to count the element as focused when its children are focused.
389 * @returns An observable that emits when the focus state of the element changes.
390 * When the element is blurred, null will be emitted.
391 */
392 monitor(element: ElementRef<HTMLElement>, checkChildren?: boolean): Observable<FocusOrigin>;
393 /**
394 * Stops monitoring an element and removes all focus classes.
395 * @param element The element to stop monitoring.
396 */
397 stopMonitoring(element: HTMLElement): void;
398 /**
399 * Stops monitoring an element and removes all focus classes.
400 * @param element The element to stop monitoring.
401 */
402 stopMonitoring(element: ElementRef<HTMLElement>): void;
403 /**
404 * Focuses the element via the specified focus origin.
405 * @param element Element to focus.
406 * @param origin Focus origin.
407 * @param options Options that can be used to configure the focus behavior.
408 */
409 focusVia(element: HTMLElement, origin: FocusOrigin, options?: FocusOptions_2): void;
410 /**
411 * Focuses the element via the specified focus origin.
412 * @param element Element to focus.
413 * @param origin Focus origin.
414 * @param options Options that can be used to configure the focus behavior.
415 */
416 focusVia(element: ElementRef<HTMLElement>, origin: FocusOrigin, options?: FocusOptions_2): void;
417 ngOnDestroy(): void;
418 /** Access injected document if available or fallback to global document reference */
419 private _getDocument;
420 /** Use defaultView of injected document if available or fallback to global window reference */
421 private _getWindow;
422 private _getFocusOrigin;
423 /**
424 * Returns whether the focus event should be attributed to touch. Recall that in IMMEDIATE mode, a
425 * touch origin isn't immediately reset at the next tick (see _setOrigin). This means that when we
426 * handle a focus event following a touch interaction, we need to determine whether (1) the focus
427 * event was directly caused by the touch interaction or (2) the focus event was caused by a
428 * subsequent programmatic focus call triggered by the touch interaction.
429 * @param focusEventTarget The target of the focus event under examination.
430 */
431 private _shouldBeAttributedToTouch;
432 /**
433 * Sets the focus classes on the element based on the given focus origin.
434 * @param element The element to update the classes on.
435 * @param origin The focus origin.
436 */
437 private _setClasses;
438 /**
439 * Updates the focus origin. If we're using immediate detection mode, we schedule an async
440 * function to clear the origin at the end of a timeout. The duration of the timeout depends on
441 * the origin being set.
442 * @param origin The origin to set.
443 * @param isFromInteraction Whether we are setting the origin from an interaction event.
444 */
445 private _setOrigin;
446 /**
447 * Handles focus events on a registered element.
448 * @param event The focus event.
449 * @param element The monitored element.
450 */
451 private _onFocus;
452 /**
453 * Handles blur events on a registered element.
454 * @param event The blur event.
455 * @param element The monitored element.
456 */
457 _onBlur(event: FocusEvent, element: HTMLElement): void;
458 private _emitOrigin;
459 private _registerGlobalListeners;
460 private _removeGlobalListeners;
461 /** Updates all the state on an element once its focus origin has changed. */
462 private _originChanged;
463 /**
464 * Collects the `MonitoredElementInfo` of a particular element and
465 * all of its ancestors that have enabled `checkChildren`.
466 * @param element Element from which to start the search.
467 */
468 private _getClosestElementsInfo;
469 /**
470 * Returns whether an interaction is likely to have come from the user clicking the `label` of
471 * an `input` or `textarea` in order to focus it.
472 * @param focusEventTarget Target currently receiving focus.
473 */
474 private _isLastInteractionFromInputLabel;
475 static ɵfac: i0.ɵɵFactoryDeclaration<FocusMonitor, [null, null, null, { optional: true; }, { optional: true; }]>;
476 static ɵprov: i0.ɵɵInjectableDeclaration<FocusMonitor>;
477}
478
479/** Detection mode used for attributing the origin of a focus event. */
480export declare const enum FocusMonitorDetectionMode {
481 /**
482 * Any mousedown, keydown, or touchstart event that happened in the previous
483 * tick or the current tick will be used to assign a focus event's origin (to
484 * either mouse, keyboard, or touch). This is the default option.
485 */
486 IMMEDIATE = 0,
487 /**
488 * A focus event's origin is always attributed to the last corresponding
489 * mousedown, keydown, or touchstart event, no matter how long ago it occurred.
490 */
491 EVENTUAL = 1
492}
493
494/** Injectable service-level options for FocusMonitor. */
495export declare interface FocusMonitorOptions {
496 detectionMode?: FocusMonitorDetectionMode;
497}
498
499/**
500 * Corresponds to the options that can be passed to the native `focus` event.
501 * via https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus
502 */
503declare interface FocusOptions_2 {
504 /** Whether the browser should scroll to the element when it is focused. */
505 preventScroll?: boolean;
506}
507export { FocusOptions_2 as FocusOptions }
508
509export declare type FocusOrigin = 'touch' | 'mouse' | 'keyboard' | 'program' | null;
510
511/**
512 * Class that allows for trapping focus within a DOM element.
513 *
514 * This class currently uses a relatively simple approach to focus trapping.
515 * It assumes that the tab order is the same as DOM order, which is not necessarily true.
516 * Things like `tabIndex > 0`, flex `order`, and shadow roots can cause the two to be misaligned.
517 *
518 * @deprecated Use `ConfigurableFocusTrap` instead.
519 * @breaking-change 11.0.0
520 */
521export declare class FocusTrap {
522 readonly _element: HTMLElement;
523 private _checker;
524 readonly _ngZone: NgZone;
525 readonly _document: Document;
526 private _startAnchor;
527 private _endAnchor;
528 private _hasAttached;
529 protected startAnchorListener: () => boolean;
530 protected endAnchorListener: () => boolean;
531 /** Whether the focus trap is active. */
532 get enabled(): boolean;
533 set enabled(value: boolean);
534 protected _enabled: boolean;
535 constructor(_element: HTMLElement, _checker: InteractivityChecker, _ngZone: NgZone, _document: Document, deferAnchors?: boolean);
536 /** Destroys the focus trap by cleaning up the anchors. */
537 destroy(): void;
538 /**
539 * Inserts the anchors into the DOM. This is usually done automatically
540 * in the constructor, but can be deferred for cases like directives with `*ngIf`.
541 * @returns Whether the focus trap managed to attach successfully. This may not be the case
542 * if the target element isn't currently in the DOM.
543 */
544 attachAnchors(): boolean;
545 /**
546 * Waits for the zone to stabilize, then focuses the first tabbable element.
547 * @returns Returns a promise that resolves with a boolean, depending
548 * on whether focus was moved successfully.
549 */
550 focusInitialElementWhenReady(options?: FocusOptions): Promise<boolean>;
551 /**
552 * Waits for the zone to stabilize, then focuses
553 * the first tabbable element within the focus trap region.
554 * @returns Returns a promise that resolves with a boolean, depending
555 * on whether focus was moved successfully.
556 */
557 focusFirstTabbableElementWhenReady(options?: FocusOptions): Promise<boolean>;
558 /**
559 * Waits for the zone to stabilize, then focuses
560 * the last tabbable element within the focus trap region.
561 * @returns Returns a promise that resolves with a boolean, depending
562 * on whether focus was moved successfully.
563 */
564 focusLastTabbableElementWhenReady(options?: FocusOptions): Promise<boolean>;
565 /**
566 * Get the specified boundary element of the trapped region.
567 * @param bound The boundary to get (start or end of trapped region).
568 * @returns The boundary element.
569 */
570 private _getRegionBoundary;
571 /**
572 * Focuses the element that should be focused when the focus trap is initialized.
573 * @returns Whether focus was moved successfully.
574 */
575 focusInitialElement(options?: FocusOptions): boolean;
576 /**
577 * Focuses the first tabbable element within the focus trap region.
578 * @returns Whether focus was moved successfully.
579 */
580 focusFirstTabbableElement(options?: FocusOptions): boolean;
581 /**
582 * Focuses the last tabbable element within the focus trap region.
583 * @returns Whether focus was moved successfully.
584 */
585 focusLastTabbableElement(options?: FocusOptions): boolean;
586 /**
587 * Checks whether the focus trap has successfully been attached.
588 */
589 hasAttached(): boolean;
590 /** Get the first tabbable element from a DOM subtree (inclusive). */
591 private _getFirstTabbableElement;
592 /** Get the last tabbable element from a DOM subtree (inclusive). */
593 private _getLastTabbableElement;
594 /** Creates an anchor element. */
595 private _createAnchor;
596 /**
597 * Toggles the `tabindex` of an anchor, based on the enabled state of the focus trap.
598 * @param isEnabled Whether the focus trap is enabled.
599 * @param anchor Anchor on which to toggle the tabindex.
600 */
601 private _toggleAnchorTabIndex;
602 /**
603 * Toggles the`tabindex` of both anchors to either trap Tab focus or allow it to escape.
604 * @param enabled: Whether the anchors should trap Tab.
605 */
606 protected toggleAnchors(enabled: boolean): void;
607 /** Executes a function when the zone is stable. */
608 private _executeOnStable;
609}
610
611/**
612 * Factory that allows easy instantiation of focus traps.
613 * @deprecated Use `ConfigurableFocusTrapFactory` instead.
614 * @breaking-change 11.0.0
615 */
616export declare class FocusTrapFactory {
617 private _checker;
618 private _ngZone;
619 private _document;
620 constructor(_checker: InteractivityChecker, _ngZone: NgZone, _document: any);
621 /**
622 * Creates a focus-trapped region around the given element.
623 * @param element The element around which focus will be trapped.
624 * @param deferCaptureElements Defers the creation of focus-capturing elements to be done
625 * manually by the user.
626 * @returns The created focus trap instance.
627 */
628 create(element: HTMLElement, deferCaptureElements?: boolean): FocusTrap;
629 static ɵfac: i0.ɵɵFactoryDeclaration<FocusTrapFactory, never>;
630 static ɵprov: i0.ɵɵInjectableDeclaration<FocusTrapFactory>;
631}
632
633/**
634 * A strategy that dictates how FocusTrap should prevent elements
635 * outside of the FocusTrap from being focused.
636 */
637export declare interface FocusTrapInertStrategy {
638 /** Makes all elements outside focusTrap unfocusable. */
639 preventFocus(focusTrap: FocusTrap): void;
640 /** Reverts elements made unfocusable by preventFocus to their previous state. */
641 allowFocus(focusTrap: FocusTrap): void;
642}
643
644/** Injectable that ensures only the most recently enabled FocusTrap is active. */
645declare class FocusTrapManager {
646 private _focusTrapStack;
647 /**
648 * Disables the FocusTrap at the top of the stack, and then pushes
649 * the new FocusTrap onto the stack.
650 */
651 register(focusTrap: ManagedFocusTrap): void;
652 /**
653 * Removes the FocusTrap from the stack, and activates the
654 * FocusTrap that is the new top of the stack.
655 */
656 deregister(focusTrap: ManagedFocusTrap): void;
657 static ɵfac: i0.ɵɵFactoryDeclaration<FocusTrapManager, never>;
658 static ɵprov: i0.ɵɵInjectableDeclaration<FocusTrapManager>;
659}
660
661/** Set of possible high-contrast mode backgrounds. */
662export declare const enum HighContrastMode {
663 NONE = 0,
664 BLACK_ON_WHITE = 1,
665 WHITE_ON_BLACK = 2
666}
667
668/**
669 * Service to determine whether the browser is currently in a high-contrast-mode environment.
670 *
671 * Microsoft Windows supports an accessibility feature called "High Contrast Mode". This mode
672 * changes the appearance of all applications, including web applications, to dramatically increase
673 * contrast.
674 *
675 * IE, Edge, and Firefox currently support this mode. Chrome does not support Windows High Contrast
676 * Mode. This service does not detect high-contrast mode as added by the Chrome "High Contrast"
677 * browser extension.
678 */
679export declare class HighContrastModeDetector implements OnDestroy {
680 private _platform;
681 /**
682 * Figuring out the high contrast mode and adding the body classes can cause
683 * some expensive layouts. This flag is used to ensure that we only do it once.
684 */
685 private _hasCheckedHighContrastMode;
686 private _document;
687 private _breakpointSubscription;
688 constructor(_platform: Platform, document: any);
689 /** Gets the current high-contrast-mode for the page. */
690 getHighContrastMode(): HighContrastMode;
691 ngOnDestroy(): void;
692 /** Applies CSS classes indicating high-contrast mode to document body (browser-only). */
693 _applyBodyHighContrastModeCssClasses(): void;
694 static ɵfac: i0.ɵɵFactoryDeclaration<HighContrastModeDetector, never>;
695 static ɵprov: i0.ɵɵInjectableDeclaration<HighContrastModeDetector>;
696}
697
698/**
699 * This is the interface for highlightable items (used by the ActiveDescendantKeyManager).
700 * Each item must know how to style itself as active or inactive and whether or not it is
701 * currently disabled.
702 */
703export declare interface Highlightable extends ListKeyManagerOption {
704 /** Applies the styles for an active item to this item. */
705 setActiveStyles(): void;
706 /** Applies the styles for an inactive item to this item. */
707 setInactiveStyles(): void;
708}
709
710declare namespace i1 {
711 export {
712 LiveAnnouncer,
713 CdkAriaLive
714 }
715}
716
717declare namespace i2 {
718 export {
719 FocusTrap,
720 FocusTrapFactory,
721 CdkTrapFocus
722 }
723}
724
725declare namespace i3 {
726 export {
727 FocusOrigin,
728 FocusOptions_2 as FocusOptions,
729 FocusMonitorDetectionMode,
730 FocusMonitorOptions,
731 FOCUS_MONITOR_DEFAULT_OPTIONS,
732 FocusMonitor,
733 CdkMonitorFocus
734 }
735}
736
737/**
738 * Default options for the InputModalityDetector.
739 *
740 * Modifier keys are ignored by default (i.e. when pressed won't cause the service to detect
741 * keyboard input modality) for two reasons:
742 *
743 * 1. Modifier keys are commonly used with mouse to perform actions such as 'right click' or 'open
744 * in new tab', and are thus less representative of actual keyboard interaction.
745 * 2. VoiceOver triggers some keyboard events when linearly navigating with Control + Option (but
746 * confusingly not with Caps Lock). Thus, to have parity with other screen readers, we ignore
747 * these keys so as to not update the input modality.
748 *
749 * Note that we do not by default ignore the right Meta key on Safari because it has the same key
750 * code as the ContextMenu key on other browsers. When we switch to using event.key, we can
751 * distinguish between the two.
752 */
753export declare const INPUT_MODALITY_DETECTOR_DEFAULT_OPTIONS: InputModalityDetectorOptions;
754
755/**
756 * Injectable options for the InputModalityDetector. These are shallowly merged with the default
757 * options.
758 */
759export declare const INPUT_MODALITY_DETECTOR_OPTIONS: InjectionToken<InputModalityDetectorOptions>;
760
761/**
762 * The input modalities detected by this service. Null is used if the input modality is unknown.
763 */
764export declare type InputModality = 'keyboard' | 'mouse' | 'touch' | null;
765
766/**
767 * Service that detects the user's input modality.
768 *
769 * This service does not update the input modality when a user navigates with a screen reader
770 * (e.g. linear navigation with VoiceOver, object navigation / browse mode with NVDA, virtual PC
771 * cursor mode with JAWS). This is in part due to technical limitations (i.e. keyboard events do not
772 * fire as expected in these modes) but is also arguably the correct behavior. Navigating with a
773 * screen reader is akin to visually scanning a page, and should not be interpreted as actual user
774 * input interaction.
775 *
776 * When a user is not navigating but *interacting* with a screen reader, this service attempts to
777 * update the input modality to keyboard, but in general this service's behavior is largely
778 * undefined.
779 */
780export declare class InputModalityDetector implements OnDestroy {
781 private readonly _platform;
782 /** Emits whenever an input modality is detected. */
783 readonly modalityDetected: Observable<InputModality>;
784 /** Emits when the input modality changes. */
785 readonly modalityChanged: Observable<InputModality>;
786 /** The most recently detected input modality. */
787 get mostRecentModality(): InputModality;
788 /**
789 * The most recently detected input modality event target. Is null if no input modality has been
790 * detected or if the associated event target is null for some unknown reason.
791 */
792 _mostRecentTarget: HTMLElement | null;
793 /** The underlying BehaviorSubject that emits whenever an input modality is detected. */
794 private readonly _modality;
795 /** Options for this InputModalityDetector. */
796 private readonly _options;
797 /**
798 * The timestamp of the last touch input modality. Used to determine whether mousedown events
799 * should be attributed to mouse or touch.
800 */
801 private _lastTouchMs;
802 /**
803 * Handles keydown events. Must be an arrow function in order to preserve the context when it gets
804 * bound.
805 */
806 private _onKeydown;
807 /**
808 * Handles mousedown events. Must be an arrow function in order to preserve the context when it
809 * gets bound.
810 */
811 private _onMousedown;
812 /**
813 * Handles touchstart events. Must be an arrow function in order to preserve the context when it
814 * gets bound.
815 */
816 private _onTouchstart;
817 constructor(_platform: Platform, ngZone: NgZone, document: Document, options?: InputModalityDetectorOptions);
818 ngOnDestroy(): void;
819 static ɵfac: i0.ɵɵFactoryDeclaration<InputModalityDetector, [null, null, null, { optional: true; }]>;
820 static ɵprov: i0.ɵɵInjectableDeclaration<InputModalityDetector>;
821}
822
823/** Options to configure the behavior of the InputModalityDetector. */
824export declare interface InputModalityDetectorOptions {
825 /** Keys to ignore when detecting keyboard input modality. */
826 ignoreKeys?: number[];
827}
828
829/**
830 * Utility for checking the interactivity of an element, such as whether is is focusable or
831 * tabbable.
832 */
833export declare class InteractivityChecker {
834 private _platform;
835 constructor(_platform: Platform);
836 /**
837 * Gets whether an element is disabled.
838 *
839 * @param element Element to be checked.
840 * @returns Whether the element is disabled.
841 */
842 isDisabled(element: HTMLElement): boolean;
843 /**
844 * Gets whether an element is visible for the purposes of interactivity.
845 *
846 * This will capture states like `display: none` and `visibility: hidden`, but not things like
847 * being clipped by an `overflow: hidden` parent or being outside the viewport.
848 *
849 * @returns Whether the element is visible.
850 */
851 isVisible(element: HTMLElement): boolean;
852 /**
853 * Gets whether an element can be reached via Tab key.
854 * Assumes that the element has already been checked with isFocusable.
855 *
856 * @param element Element to be checked.
857 * @returns Whether the element is tabbable.
858 */
859 isTabbable(element: HTMLElement): boolean;
860 /**
861 * Gets whether an element can be focused by the user.
862 *
863 * @param element Element to be checked.
864 * @param config The config object with options to customize this method's behavior
865 * @returns Whether the element is focusable.
866 */
867 isFocusable(element: HTMLElement, config?: IsFocusableConfig): boolean;
868 static ɵfac: i0.ɵɵFactoryDeclaration<InteractivityChecker, never>;
869 static ɵprov: i0.ɵɵInjectableDeclaration<InteractivityChecker>;
870}
871
872
873/** Gets whether an event could be a faked `mousedown` event dispatched by a screen reader. */
874export declare function isFakeMousedownFromScreenReader(event: MouseEvent): boolean;
875
876/** Gets whether an event could be a faked `touchstart` event dispatched by a screen reader. */
877export declare function isFakeTouchstartFromScreenReader(event: TouchEvent): boolean;
878
879/**
880 * Configuration for the isFocusable method.
881 */
882export declare class IsFocusableConfig {
883 /**
884 * Whether to count an element as focusable even if it is not currently visible.
885 */
886 ignoreVisibility: boolean;
887}
888
889/**
890 * This class manages keyboard events for selectable lists. If you pass it a query list
891 * of items, it will set the active item correctly when arrow events occur.
892 */
893export declare class ListKeyManager<T extends ListKeyManagerOption> {
894 private _items;
895 private _activeItemIndex;
896 private _activeItem;
897 private _wrap;
898 private readonly _letterKeyStream;
899 private _typeaheadSubscription;
900 private _itemChangesSubscription?;
901 private _vertical;
902 private _horizontal;
903 private _allowedModifierKeys;
904 private _homeAndEnd;
905 private _pageUpAndDown;
906 /**
907 * Predicate function that can be used to check whether an item should be skipped
908 * by the key manager. By default, disabled items are skipped.
909 */
910 private _skipPredicateFn;
911 private _pressedLetters;
912 constructor(_items: QueryList<T> | T[]);
913 /**
914 * Stream that emits any time the TAB key is pressed, so components can react
915 * when focus is shifted off of the list.
916 */
917 readonly tabOut: Subject<void>;
918 /** Stream that emits whenever the active item of the list manager changes. */
919 readonly change: Subject<number>;
920 /**
921 * Sets the predicate function that determines which items should be skipped by the
922 * list key manager.
923 * @param predicate Function that determines whether the given item should be skipped.
924 */
925 skipPredicate(predicate: (item: T) => boolean): this;
926 /**
927 * Configures wrapping mode, which determines whether the active item will wrap to
928 * the other end of list when there are no more items in the given direction.
929 * @param shouldWrap Whether the list should wrap when reaching the end.
930 */
931 withWrap(shouldWrap?: boolean): this;
932 /**
933 * Configures whether the key manager should be able to move the selection vertically.
934 * @param enabled Whether vertical selection should be enabled.
935 */
936 withVerticalOrientation(enabled?: boolean): this;
937 /**
938 * Configures the key manager to move the selection horizontally.
939 * Passing in `null` will disable horizontal movement.
940 * @param direction Direction in which the selection can be moved.
941 */
942 withHorizontalOrientation(direction: 'ltr' | 'rtl' | null): this;
943 /**
944 * Modifier keys which are allowed to be held down and whose default actions will be prevented
945 * as the user is pressing the arrow keys. Defaults to not allowing any modifier keys.
946 */
947 withAllowedModifierKeys(keys: ListKeyManagerModifierKey[]): this;
948 /**
949 * Turns on typeahead mode which allows users to set the active item by typing.
950 * @param debounceInterval Time to wait after the last keystroke before setting the active item.
951 */
952 withTypeAhead(debounceInterval?: number): this;
953 /** Cancels the current typeahead sequence. */
954 cancelTypeahead(): this;
955 /**
956 * Configures the key manager to activate the first and last items
957 * respectively when the Home or End key is pressed.
958 * @param enabled Whether pressing the Home or End key activates the first/last item.
959 */
960 withHomeAndEnd(enabled?: boolean): this;
961 /**
962 * Configures the key manager to activate every 10th, configured or first/last element in up/down direction
963 * respectively when the Page-Up or Page-Down key is pressed.
964 * @param enabled Whether pressing the Page-Up or Page-Down key activates the first/last item.
965 * @param delta Whether pressing the Home or End key activates the first/last item.
966 */
967 withPageUpDown(enabled?: boolean, delta?: number): this;
968 /**
969 * Sets the active item to the item at the index specified.
970 * @param index The index of the item to be set as active.
971 */
972 setActiveItem(index: number): void;
973 /**
974 * Sets the active item to the specified item.
975 * @param item The item to be set as active.
976 */
977 setActiveItem(item: T): void;
978 /**
979 * Sets the active item depending on the key event passed in.
980 * @param event Keyboard event to be used for determining which element should be active.
981 */
982 onKeydown(event: KeyboardEvent): void;
983 /** Index of the currently active item. */
984 get activeItemIndex(): number | null;
985 /** The active item. */
986 get activeItem(): T | null;
987 /** Gets whether the user is currently typing into the manager using the typeahead feature. */
988 isTyping(): boolean;
989 /** Sets the active item to the first enabled item in the list. */
990 setFirstItemActive(): void;
991 /** Sets the active item to the last enabled item in the list. */
992 setLastItemActive(): void;
993 /** Sets the active item to the next enabled item in the list. */
994 setNextItemActive(): void;
995 /** Sets the active item to a previous enabled item in the list. */
996 setPreviousItemActive(): void;
997 /**
998 * Allows setting the active without any other effects.
999 * @param index Index of the item to be set as active.
1000 */
1001 updateActiveItem(index: number): void;
1002 /**
1003 * Allows setting the active item without any other effects.
1004 * @param item Item to be set as active.
1005 */
1006 updateActiveItem(item: T): void;
1007 /** Cleans up the key manager. */
1008 destroy(): void;
1009 /**
1010 * This method sets the active item, given a list of items and the delta between the
1011 * currently active item and the new active item. It will calculate differently
1012 * depending on whether wrap mode is turned on.
1013 */
1014 private _setActiveItemByDelta;
1015 /**
1016 * Sets the active item properly given "wrap" mode. In other words, it will continue to move
1017 * down the list until it finds an item that is not disabled, and it will wrap if it
1018 * encounters either end of the list.
1019 */
1020 private _setActiveInWrapMode;
1021 /**
1022 * Sets the active item properly given the default mode. In other words, it will
1023 * continue to move down the list until it finds an item that is not disabled. If
1024 * it encounters either end of the list, it will stop and not wrap.
1025 */
1026 private _setActiveInDefaultMode;
1027 /**
1028 * Sets the active item to the first enabled item starting at the index specified. If the
1029 * item is disabled, it will move in the fallbackDelta direction until it either
1030 * finds an enabled item or encounters the end of the list.
1031 */
1032 private _setActiveItemByIndex;
1033 /** Returns the items as an array. */
1034 private _getItemsArray;
1035}
1036
1037/** Modifier keys handled by the ListKeyManager. */
1038export declare type ListKeyManagerModifierKey = 'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey';
1039
1040/** This interface is for items that can be passed to a ListKeyManager. */
1041export declare interface ListKeyManagerOption {
1042 /** Whether the option is disabled. */
1043 disabled?: boolean;
1044 /** Gets the label for this option. */
1045 getLabel?(): string;
1046}
1047
1048/** Injection token that can be used to configure the default options for the LiveAnnouncer. */
1049export declare const LIVE_ANNOUNCER_DEFAULT_OPTIONS: InjectionToken<LiveAnnouncerDefaultOptions>;
1050
1051export declare const LIVE_ANNOUNCER_ELEMENT_TOKEN: InjectionToken<HTMLElement | null>;
1052
1053/** @docs-private */
1054export declare function LIVE_ANNOUNCER_ELEMENT_TOKEN_FACTORY(): null;
1055
1056export declare class LiveAnnouncer implements OnDestroy {
1057 private _ngZone;
1058 private _defaultOptions?;
1059 private _liveElement;
1060 private _document;
1061 private _previousTimeout;
1062 private _currentPromise;
1063 private _currentResolve;
1064 constructor(elementToken: any, _ngZone: NgZone, _document: any, _defaultOptions?: LiveAnnouncerDefaultOptions | undefined);
1065 /**
1066 * Announces a message to screen readers.
1067 * @param message Message to be announced to the screen reader.
1068 * @returns Promise that will be resolved when the message is added to the DOM.
1069 */
1070 announce(message: string): Promise<void>;
1071 /**
1072 * Announces a message to screen readers.
1073 * @param message Message to be announced to the screen reader.
1074 * @param politeness The politeness of the announcer element.
1075 * @returns Promise that will be resolved when the message is added to the DOM.
1076 */
1077 announce(message: string, politeness?: AriaLivePoliteness): Promise<void>;
1078 /**
1079 * Announces a message to screen readers.
1080 * @param message Message to be announced to the screen reader.
1081 * @param duration Time in milliseconds after which to clear out the announcer element. Note
1082 * that this takes effect after the message has been added to the DOM, which can be up to
1083 * 100ms after `announce` has been called.
1084 * @returns Promise that will be resolved when the message is added to the DOM.
1085 */
1086 announce(message: string, duration?: number): Promise<void>;
1087 /**
1088 * Announces a message to screen readers.
1089 * @param message Message to be announced to the screen reader.
1090 * @param politeness The politeness of the announcer element.
1091 * @param duration Time in milliseconds after which to clear out the announcer element. Note
1092 * that this takes effect after the message has been added to the DOM, which can be up to
1093 * 100ms after `announce` has been called.
1094 * @returns Promise that will be resolved when the message is added to the DOM.
1095 */
1096 announce(message: string, politeness?: AriaLivePoliteness, duration?: number): Promise<void>;
1097 /**
1098 * Clears the current text from the announcer element. Can be used to prevent
1099 * screen readers from reading the text out again while the user is going
1100 * through the page landmarks.
1101 */
1102 clear(): void;
1103 ngOnDestroy(): void;
1104 private _createLiveElement;
1105 /**
1106 * Some browsers won't expose the accessibility node of the live announcer element if there is an
1107 * `aria-modal` and the live announcer is outside of it. This method works around the issue by
1108 * pointing the `aria-owns` of all modals to the live announcer element.
1109 */
1110 private _exposeAnnouncerToModals;
1111 static ɵfac: i0.ɵɵFactoryDeclaration<LiveAnnouncer, [{ optional: true; }, null, null, { optional: true; }]>;
1112 static ɵprov: i0.ɵɵInjectableDeclaration<LiveAnnouncer>;
1113}
1114
1115/** Object that can be used to configure the default options for the LiveAnnouncer. */
1116export declare interface LiveAnnouncerDefaultOptions {
1117 /** Default politeness for the announcements. */
1118 politeness?: AriaLivePoliteness;
1119 /** Default duration for the announcement messages. */
1120 duration?: number;
1121}
1122
1123/**
1124 * A FocusTrap managed by FocusTrapManager.
1125 * Implemented by ConfigurableFocusTrap to avoid circular dependency.
1126 */
1127declare interface ManagedFocusTrap {
1128 _enable(): void;
1129 _disable(): void;
1130 focusInitialElementWhenReady(): Promise<boolean>;
1131}
1132
1133/**
1134 * ID used for the body container where all messages are appended.
1135 * @deprecated No longer being used. To be removed.
1136 * @breaking-change 14.0.0
1137 */
1138export declare const MESSAGES_CONTAINER_ID = "cdk-describedby-message-container";
1139
1140/**
1141 * Interface used to register message elements and keep a count of how many registrations have
1142 * the same message and the reference to the message element used for the `aria-describedby`.
1143 */
1144export declare interface RegisteredMessage {
1145 /** The element containing the message. */
1146 messageElement: Element;
1147 /** The number of elements that reference this message element via `aria-describedby`. */
1148 referenceCount: number;
1149}
1150
1151export { }