@angular/cdk 19.2.1 → 19.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/a11y/index.d.ts +926 -999
  2. package/accordion/index.d.ts +8 -27
  3. package/bidi/index.d.ts +38 -48
  4. package/clipboard/index.d.ts +61 -75
  5. package/coercion/index.d.ts +22 -32
  6. package/coercion/private/index.d.ts +2 -2
  7. package/collections/index.d.ts +139 -158
  8. package/dialog/index.d.ts +210 -246
  9. package/drag-drop/index.d.ts +1084 -1160
  10. package/fesm2022/a11y.mjs +62 -54
  11. package/fesm2022/a11y.mjs.map +1 -1
  12. package/fesm2022/accordion.mjs +10 -14
  13. package/fesm2022/accordion.mjs.map +1 -1
  14. package/fesm2022/bidi.mjs +15 -15
  15. package/fesm2022/bidi.mjs.map +1 -1
  16. package/fesm2022/cdk.mjs +1 -1
  17. package/fesm2022/cdk.mjs.map +1 -1
  18. package/fesm2022/clipboard.mjs +10 -14
  19. package/fesm2022/clipboard.mjs.map +1 -1
  20. package/fesm2022/coercion/private.mjs +0 -4
  21. package/fesm2022/coercion/private.mjs.map +1 -1
  22. package/fesm2022/coercion.mjs.map +1 -1
  23. package/fesm2022/collections.mjs +4 -8
  24. package/fesm2022/collections.mjs.map +1 -1
  25. package/fesm2022/dialog.mjs +10 -14
  26. package/fesm2022/dialog.mjs.map +1 -1
  27. package/fesm2022/drag-drop.mjs +31 -35
  28. package/fesm2022/drag-drop.mjs.map +1 -1
  29. package/fesm2022/keycodes.mjs +0 -4
  30. package/fesm2022/keycodes.mjs.map +1 -1
  31. package/fesm2022/layout.mjs +10 -14
  32. package/fesm2022/layout.mjs.map +1 -1
  33. package/fesm2022/listbox.mjs +10 -14
  34. package/fesm2022/listbox.mjs.map +1 -1
  35. package/fesm2022/menu.mjs +49 -53
  36. package/fesm2022/menu.mjs.map +1 -1
  37. package/fesm2022/observers/private.mjs +3 -7
  38. package/fesm2022/observers/private.mjs.map +1 -1
  39. package/fesm2022/observers.mjs +13 -17
  40. package/fesm2022/observers.mjs.map +1 -1
  41. package/fesm2022/overlay.mjs +54 -50
  42. package/fesm2022/overlay.mjs.map +1 -1
  43. package/fesm2022/platform.mjs +7 -11
  44. package/fesm2022/platform.mjs.map +1 -1
  45. package/fesm2022/portal.mjs +25 -26
  46. package/fesm2022/portal.mjs.map +1 -1
  47. package/fesm2022/private.mjs +6 -10
  48. package/fesm2022/private.mjs.map +1 -1
  49. package/fesm2022/scrolling.mjs +36 -40
  50. package/fesm2022/scrolling.mjs.map +1 -1
  51. package/fesm2022/stepper.mjs +29 -32
  52. package/fesm2022/stepper.mjs.map +1 -1
  53. package/fesm2022/table.mjs +78 -88
  54. package/fesm2022/table.mjs.map +1 -1
  55. package/fesm2022/testing/selenium-webdriver.mjs.map +1 -1
  56. package/fesm2022/testing/testbed.mjs +1 -41
  57. package/fesm2022/testing/testbed.mjs.map +1 -1
  58. package/fesm2022/testing.mjs.map +1 -1
  59. package/fesm2022/text-field.mjs +16 -20
  60. package/fesm2022/text-field.mjs.map +1 -1
  61. package/fesm2022/tree.mjs +25 -29
  62. package/fesm2022/tree.mjs.map +1 -1
  63. package/index.d.ts +2 -2
  64. package/keycodes/index.d.ts +123 -244
  65. package/layout/index.d.ts +23 -25
  66. package/listbox/index.d.ts +90 -107
  67. package/menu/index.d.ts +593 -687
  68. package/observers/index.d.ts +38 -44
  69. package/observers/private/index.d.ts +3 -3
  70. package/overlay/index.d.ts +921 -986
  71. package/package.json +1 -1
  72. package/platform/index.d.ts +50 -62
  73. package/portal/index.d.ts +172 -195
  74. package/private/index.d.ts +3 -3
  75. package/schematics/ng-add/index.js +1 -1
  76. package/schematics/ng-add/index.mjs +1 -1
  77. package/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template +1 -1
  78. package/scrolling/index.d.ts +268 -351
  79. package/stepper/index.d.ts +72 -124
  80. package/table/index.d.ts +336 -449
  81. package/testing/index.d.ts +490 -517
  82. package/testing/selenium-webdriver/index.d.ts +30 -20
  83. package/testing/testbed/index.d.ts +9 -19
  84. package/text-field/index.d.ts +9 -30
  85. package/tree/index.d.ts +204 -271
package/a11y/index.d.ts CHANGED
@@ -1,59 +1,42 @@
1
- import { AfterContentInit } from '@angular/core';
2
- import { AfterViewInit } from '@angular/core';
3
- import { DoCheck } from '@angular/core';
4
- import { ElementRef } from '@angular/core';
5
- import { EventEmitter } from '@angular/core';
6
1
  import * as i0 from '@angular/core';
2
+ import { OnDestroy, QueryList, Signal, Injector, InjectionToken, ElementRef, AfterViewInit, EventEmitter, Provider, NgZone, AfterContentInit, OnChanges, DoCheck, SimpleChanges } from '@angular/core';
3
+ import { Subject, Observable } from 'rxjs';
7
4
  import * as i1 from '@angular/cdk/observers';
8
- import { InjectionToken } from '@angular/core';
9
- import { Injector } from '@angular/core';
10
- import { NgZone } from '@angular/core';
11
- import { Observable } from 'rxjs';
12
- import { OnChanges } from '@angular/core';
13
- import { OnDestroy } from '@angular/core';
14
- import { Provider } from '@angular/core';
15
- import { QueryList } from '@angular/core';
16
- import { Signal } from '@angular/core';
17
- import { SimpleChanges } from '@angular/core';
18
- import { Subject } from 'rxjs';
19
5
 
20
- export declare class A11yModule {
21
- constructor();
22
- static ɵfac: i0.ɵɵFactoryDeclaration<A11yModule, never>;
23
- static ɵmod: i0.ɵɵNgModuleDeclaration<A11yModule, never, [typeof i1.ObserversModule, typeof i2.CdkAriaLive, typeof i3.CdkTrapFocus, typeof i4.CdkMonitorFocus], [typeof i2.CdkAriaLive, typeof i3.CdkTrapFocus, typeof i4.CdkMonitorFocus]>;
24
- static ɵinj: i0.ɵɵInjectorDeclaration<A11yModule>;
25
- }
26
-
27
- export 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;
6
+ /**
7
+ * Interface used to register message elements and keep a count of how many registrations have
8
+ * the same message and the reference to the message element used for the `aria-describedby`.
9
+ */
10
+ interface RegisteredMessage {
11
+ /** The element containing the message. */
12
+ messageElement: Element;
13
+ /** The number of elements that reference this message element via `aria-describedby`. */
14
+ referenceCount: number;
42
15
  }
43
-
44
-
45
16
  /**
46
- * Adds the given ID to the specified ARIA attribute on an element.
47
- * Used for attributes such as aria-labelledby, aria-owns, etc.
17
+ * ID used for the body container where all messages are appended.
18
+ * @deprecated No longer being used. To be removed.
19
+ * @breaking-change 14.0.0
48
20
  */
49
- export declare function addAriaReferencedId(el: Element, attr: `aria-${string}`, id: string): void;
50
-
21
+ declare const MESSAGES_CONTAINER_ID = "cdk-describedby-message-container";
22
+ /**
23
+ * ID prefix used for each created message element.
24
+ * @deprecated To be turned into a private variable.
25
+ * @breaking-change 14.0.0
26
+ */
27
+ declare const CDK_DESCRIBEDBY_ID_PREFIX = "cdk-describedby-message";
28
+ /**
29
+ * Attribute given to each host element that is described by a message element.
30
+ * @deprecated To be turned into a private variable.
31
+ * @breaking-change 14.0.0
32
+ */
33
+ declare const CDK_DESCRIBEDBY_HOST_ATTRIBUTE = "cdk-describedby-host";
51
34
  /**
52
35
  * Utility that creates visually hidden elements with a message content. Useful for elements that
53
36
  * want to use aria-describedby to further describe themselves without adding additional visual
54
37
  * content.
55
38
  */
56
- export declare class AriaDescriber implements OnDestroy {
39
+ declare class AriaDescriber implements OnDestroy {
57
40
  private _platform;
58
41
  private _document;
59
42
  /** Map of all registered message elements that have been placed into the document. */
@@ -110,213 +93,241 @@ export declare class AriaDescriber implements OnDestroy {
110
93
  static ɵprov: i0.ɵɵInjectableDeclaration<AriaDescriber>;
111
94
  }
112
95
 
113
- /** Possible politeness levels. */
114
- export declare type AriaLivePoliteness = 'off' | 'polite' | 'assertive';
115
-
116
96
  /**
117
- * Attribute given to each host element that is described by a message element.
118
- * @deprecated To be turned into a private variable.
119
- * @breaking-change 14.0.0
97
+ * Adds the given ID to the specified ARIA attribute on an element.
98
+ * Used for attributes such as aria-labelledby, aria-owns, etc.
120
99
  */
121
- export declare const CDK_DESCRIBEDBY_HOST_ATTRIBUTE = "cdk-describedby-host";
122
-
100
+ declare function addAriaReferencedId(el: Element, attr: `aria-${string}`, id: string): void;
123
101
  /**
124
- * ID prefix used for each created message element.
125
- * @deprecated To be turned into a private variable.
126
- * @breaking-change 14.0.0
102
+ * Removes the given ID from the specified ARIA attribute on an element.
103
+ * Used for attributes such as aria-labelledby, aria-owns, etc.
127
104
  */
128
- export declare const CDK_DESCRIBEDBY_ID_PREFIX = "cdk-describedby-message";
129
-
105
+ declare function removeAriaReferencedId(el: Element, attr: `aria-${string}`, id: string): void;
130
106
  /**
131
- * A directive that works similarly to aria-live, but uses the LiveAnnouncer to ensure compatibility
132
- * with a wider range of browsers and screen readers.
107
+ * Gets the list of IDs referenced by the given ARIA attribute on an element.
108
+ * Used for attributes such as aria-labelledby, aria-owns, etc.
133
109
  */
134
- export declare class CdkAriaLive implements OnDestroy {
135
- private _elementRef;
136
- private _liveAnnouncer;
137
- private _contentObserver;
138
- private _ngZone;
139
- /** The aria-live politeness level to use when announcing messages. */
140
- get politeness(): AriaLivePoliteness;
141
- set politeness(value: AriaLivePoliteness);
142
- private _politeness;
143
- /** Time in milliseconds after which to clear out the announcer element. */
144
- duration: number;
145
- private _previousAnnouncedText?;
146
- private _subscription;
147
- constructor(...args: unknown[]);
148
- ngOnDestroy(): void;
149
- static ɵfac: i0.ɵɵFactoryDeclaration<CdkAriaLive, never>;
150
- static ɵdir: i0.ɵɵDirectiveDeclaration<CdkAriaLive, "[cdkAriaLive]", ["cdkAriaLive"], { "politeness": { "alias": "cdkAriaLive"; "required": false; }; "duration": { "alias": "cdkAriaLiveDuration"; "required": false; }; }, {}, never, never, true, never>;
151
- }
110
+ declare function getAriaReferenceIds(el: Element, attr: string): string[];
152
111
 
112
+ /** This interface is for items that can be passed to a ListKeyManager. */
113
+ interface ListKeyManagerOption {
114
+ /** Whether the option is disabled. */
115
+ disabled?: boolean;
116
+ /** Gets the label for this option. */
117
+ getLabel?(): string;
118
+ }
119
+ /** Modifier keys handled by the ListKeyManager. */
120
+ type ListKeyManagerModifierKey = 'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey';
153
121
  /**
154
- * Directive that determines how a particular element was focused (via keyboard, mouse, touch, or
155
- * programmatically) and adds corresponding classes to the element.
156
- *
157
- * There are two variants of this directive:
158
- * 1) cdkMonitorElementFocus: does not consider an element to be focused if one of its children is
159
- * focused.
160
- * 2) cdkMonitorSubtreeFocus: considers an element focused if it or any of its children are focused.
122
+ * This class manages keyboard events for selectable lists. If you pass it a query list
123
+ * of items, it will set the active item correctly when arrow events occur.
161
124
  */
162
- export declare class CdkMonitorFocus implements AfterViewInit, OnDestroy {
163
- private _elementRef;
164
- private _focusMonitor;
165
- private _monitorSubscription;
166
- private _focusOrigin;
167
- readonly cdkFocusChange: EventEmitter<FocusOrigin>;
168
- constructor(...args: unknown[]);
169
- get focusOrigin(): FocusOrigin;
170
- ngAfterViewInit(): void;
171
- ngOnDestroy(): void;
172
- static ɵfac: i0.ɵɵFactoryDeclaration<CdkMonitorFocus, never>;
173
- static ɵdir: i0.ɵɵDirectiveDeclaration<CdkMonitorFocus, "[cdkMonitorElementFocus], [cdkMonitorSubtreeFocus]", ["cdkMonitorFocus"], {}, { "cdkFocusChange": "cdkFocusChange"; }, never, never, true, never>;
174
- }
175
-
176
- /** Directive for trapping focus within a region. */
177
- export declare class CdkTrapFocus implements OnDestroy, AfterContentInit, OnChanges, DoCheck {
178
- private _elementRef;
179
- private _focusTrapFactory;
180
- /** Underlying FocusTrap instance. */
181
- focusTrap: FocusTrap;
182
- /** Previously focused element to restore focus to upon destroy when using autoCapture. */
183
- private _previouslyFocusedElement;
184
- /** Whether the focus trap is active. */
185
- get enabled(): boolean;
186
- set enabled(value: boolean);
125
+ declare class ListKeyManager<T extends ListKeyManagerOption> {
126
+ private _items;
127
+ private _activeItemIndex;
128
+ private _activeItem;
129
+ private _wrap;
130
+ private _typeaheadSubscription;
131
+ private _itemChangesSubscription?;
132
+ private _vertical;
133
+ private _horizontal;
134
+ private _allowedModifierKeys;
135
+ private _homeAndEnd;
136
+ private _pageUpAndDown;
137
+ private _effectRef;
138
+ private _typeahead?;
187
139
  /**
188
- * Whether the directive should automatically move focus into the trapped region upon
189
- * initialization and return focus to the previous activeElement upon destruction.
140
+ * Predicate function that can be used to check whether an item should be skipped
141
+ * by the key manager. By default, disabled items are skipped.
190
142
  */
191
- autoCapture: boolean;
192
- constructor(...args: unknown[]);
193
- ngOnDestroy(): void;
194
- ngAfterContentInit(): void;
195
- ngDoCheck(): void;
196
- ngOnChanges(changes: SimpleChanges): void;
197
- private _captureFocus;
198
- static ɵfac: i0.ɵɵFactoryDeclaration<CdkTrapFocus, never>;
199
- static ɵdir: i0.ɵɵDirectiveDeclaration<CdkTrapFocus, "[cdkTrapFocus]", ["cdkTrapFocus"], { "enabled": { "alias": "cdkTrapFocus"; "required": false; }; "autoCapture": { "alias": "cdkTrapFocusAutoCapture"; "required": false; }; }, {}, never, never, true, never>;
200
- static ngAcceptInputType_enabled: unknown;
201
- static ngAcceptInputType_autoCapture: unknown;
202
- }
203
-
204
- /**
205
- * Class that allows for trapping focus within a DOM element.
206
- *
207
- * This class uses a strategy pattern that determines how it traps focus.
208
- * See FocusTrapInertStrategy.
209
- */
210
- export declare class ConfigurableFocusTrap extends FocusTrap implements ManagedFocusTrap {
211
- private _focusTrapManager;
212
- private _inertStrategy;
213
- /** Whether the FocusTrap is enabled. */
214
- get enabled(): boolean;
215
- set enabled(value: boolean);
216
- constructor(_element: HTMLElement, _checker: InteractivityChecker, _ngZone: NgZone, _document: Document, _focusTrapManager: FocusTrapManager, _inertStrategy: FocusTrapInertStrategy, config: ConfigurableFocusTrapConfig, injector?: Injector);
217
- /** Notifies the FocusTrapManager that this FocusTrap will be destroyed. */
218
- destroy(): void;
219
- /** @docs-private Implemented as part of ManagedFocusTrap. */
220
- _enable(): void;
221
- /** @docs-private Implemented as part of ManagedFocusTrap. */
222
- _disable(): void;
223
- }
224
-
225
-
226
- /**
227
- * Options for creating a ConfigurableFocusTrap.
228
- */
229
- export declare interface ConfigurableFocusTrapConfig {
143
+ private _skipPredicateFn;
144
+ constructor(items: QueryList<T> | T[] | readonly T[]);
145
+ constructor(items: Signal<T[]> | Signal<readonly T[]>, injector: Injector);
230
146
  /**
231
- * Whether to defer the creation of FocusTrap elements to be done manually by the user.
147
+ * Stream that emits any time the TAB key is pressed, so components can react
148
+ * when focus is shifted off of the list.
232
149
  */
233
- defer: boolean;
234
- }
235
-
236
- /** Factory that allows easy instantiation of configurable focus traps. */
237
- export declare class ConfigurableFocusTrapFactory {
238
- private _checker;
239
- private _ngZone;
240
- private _focusTrapManager;
241
- private _document;
242
- private _inertStrategy;
243
- private readonly _injector;
244
- constructor(...args: unknown[]);
150
+ readonly tabOut: Subject<void>;
151
+ /** Stream that emits whenever the active item of the list manager changes. */
152
+ readonly change: Subject<number>;
245
153
  /**
246
- * Creates a focus-trapped region around the given element.
247
- * @param element The element around which focus will be trapped.
248
- * @param config The focus trap configuration.
249
- * @returns The created focus trap instance.
154
+ * Sets the predicate function that determines which items should be skipped by the
155
+ * list key manager.
156
+ * @param predicate Function that determines whether the given item should be skipped.
250
157
  */
251
- create(element: HTMLElement, config?: ConfigurableFocusTrapConfig): ConfigurableFocusTrap;
158
+ skipPredicate(predicate: (item: T) => boolean): this;
252
159
  /**
253
- * @deprecated Pass a config object instead of the `deferCaptureElements` flag.
254
- * @breaking-change 11.0.0
160
+ * Configures wrapping mode, which determines whether the active item will wrap to
161
+ * the other end of list when there are no more items in the given direction.
162
+ * @param shouldWrap Whether the list should wrap when reaching the end.
255
163
  */
256
- create(element: HTMLElement, deferCaptureElements: boolean): ConfigurableFocusTrap;
257
- static ɵfac: i0.ɵɵFactoryDeclaration<ConfigurableFocusTrapFactory, never>;
258
- static ɵprov: i0.ɵɵInjectableDeclaration<ConfigurableFocusTrapFactory>;
259
- }
260
-
261
- /**
262
- * Lightweight FocusTrapInertStrategy that adds a document focus event
263
- * listener to redirect focus back inside the FocusTrap.
264
- */
265
- export declare class EventListenerFocusTrapInertStrategy implements FocusTrapInertStrategy {
266
- /** Focus event handler. */
267
- private _listener;
268
- /** Adds a document event listener that keeps focus inside the FocusTrap. */
269
- preventFocus(focusTrap: ConfigurableFocusTrap): void;
270
- /** Removes the event listener added in preventFocus. */
271
- allowFocus(focusTrap: ConfigurableFocusTrap): void;
164
+ withWrap(shouldWrap?: boolean): this;
272
165
  /**
273
- * Refocuses the first element in the FocusTrap if the focus event target was outside
274
- * the FocusTrap.
275
- *
276
- * This is an event listener callback. The event listener is added in runOutsideAngular,
277
- * so all this code runs outside Angular as well.
166
+ * Configures whether the key manager should be able to move the selection vertically.
167
+ * @param enabled Whether vertical selection should be enabled.
278
168
  */
279
- private _trapFocus;
280
- }
281
-
282
- /** InjectionToken for FocusMonitorOptions. */
283
- export declare const FOCUS_MONITOR_DEFAULT_OPTIONS: InjectionToken<FocusMonitorOptions>;
284
-
285
- /** The injection token used to specify the inert strategy. */
286
- export declare const FOCUS_TRAP_INERT_STRATEGY: InjectionToken<FocusTrapInertStrategy>;
287
-
288
- /**
289
- * This is the interface for focusable items (used by the FocusKeyManager).
290
- * Each item must know how to focus itself, whether or not it is currently disabled
291
- * and be able to supply its label.
292
- */
293
- export declare interface FocusableOption extends ListKeyManagerOption {
294
- /** Focuses the `FocusableOption`. */
295
- focus(origin?: FocusOrigin): void;
296
- }
297
-
298
- export declare class FocusKeyManager<T> extends ListKeyManager<FocusableOption & T> {
299
- private _origin;
169
+ withVerticalOrientation(enabled?: boolean): this;
300
170
  /**
301
- * Sets the focus origin that will be passed in to the items for any subsequent `focus` calls.
302
- * @param origin Focus origin to be used when focusing items.
171
+ * Configures the key manager to move the selection horizontally.
172
+ * Passing in `null` will disable horizontal movement.
173
+ * @param direction Direction in which the selection can be moved.
303
174
  */
304
- setFocusOrigin(origin: FocusOrigin): this;
175
+ withHorizontalOrientation(direction: 'ltr' | 'rtl' | null): this;
305
176
  /**
306
- * Sets the active item to the item at the specified
307
- * index and focuses the newly active item.
177
+ * Modifier keys which are allowed to be held down and whose default actions will be prevented
178
+ * as the user is pressing the arrow keys. Defaults to not allowing any modifier keys.
179
+ */
180
+ withAllowedModifierKeys(keys: ListKeyManagerModifierKey[]): this;
181
+ /**
182
+ * Turns on typeahead mode which allows users to set the active item by typing.
183
+ * @param debounceInterval Time to wait after the last keystroke before setting the active item.
184
+ */
185
+ withTypeAhead(debounceInterval?: number): this;
186
+ /** Cancels the current typeahead sequence. */
187
+ cancelTypeahead(): this;
188
+ /**
189
+ * Configures the key manager to activate the first and last items
190
+ * respectively when the Home or End key is pressed.
191
+ * @param enabled Whether pressing the Home or End key activates the first/last item.
192
+ */
193
+ withHomeAndEnd(enabled?: boolean): this;
194
+ /**
195
+ * Configures the key manager to activate every 10th, configured or first/last element in up/down direction
196
+ * respectively when the Page-Up or Page-Down key is pressed.
197
+ * @param enabled Whether pressing the Page-Up or Page-Down key activates the first/last item.
198
+ * @param delta Whether pressing the Home or End key activates the first/last item.
199
+ */
200
+ withPageUpDown(enabled?: boolean, delta?: number): this;
201
+ /**
202
+ * Sets the active item to the item at the index specified.
203
+ * @param index The index of the item to be set as active.
204
+ */
205
+ setActiveItem(index: number): void;
206
+ /**
207
+ * Sets the active item to the specified item.
208
+ * @param item The item to be set as active.
209
+ */
210
+ setActiveItem(item: T): void;
211
+ /**
212
+ * Sets the active item depending on the key event passed in.
213
+ * @param event Keyboard event to be used for determining which element should be active.
214
+ */
215
+ onKeydown(event: KeyboardEvent): void;
216
+ /** Index of the currently active item. */
217
+ get activeItemIndex(): number | null;
218
+ /** The active item. */
219
+ get activeItem(): T | null;
220
+ /** Gets whether the user is currently typing into the manager using the typeahead feature. */
221
+ isTyping(): boolean;
222
+ /** Sets the active item to the first enabled item in the list. */
223
+ setFirstItemActive(): void;
224
+ /** Sets the active item to the last enabled item in the list. */
225
+ setLastItemActive(): void;
226
+ /** Sets the active item to the next enabled item in the list. */
227
+ setNextItemActive(): void;
228
+ /** Sets the active item to a previous enabled item in the list. */
229
+ setPreviousItemActive(): void;
230
+ /**
231
+ * Allows setting the active without any other effects.
232
+ * @param index Index of the item to be set as active.
233
+ */
234
+ updateActiveItem(index: number): void;
235
+ /**
236
+ * Allows setting the active item without any other effects.
237
+ * @param item Item to be set as active.
238
+ */
239
+ updateActiveItem(item: T): void;
240
+ /** Cleans up the key manager. */
241
+ destroy(): void;
242
+ /**
243
+ * This method sets the active item, given a list of items and the delta between the
244
+ * currently active item and the new active item. It will calculate differently
245
+ * depending on whether wrap mode is turned on.
246
+ */
247
+ private _setActiveItemByDelta;
248
+ /**
249
+ * Sets the active item properly given "wrap" mode. In other words, it will continue to move
250
+ * down the list until it finds an item that is not disabled, and it will wrap if it
251
+ * encounters either end of the list.
252
+ */
253
+ private _setActiveInWrapMode;
254
+ /**
255
+ * Sets the active item properly given the default mode. In other words, it will
256
+ * continue to move down the list until it finds an item that is not disabled. If
257
+ * it encounters either end of the list, it will stop and not wrap.
258
+ */
259
+ private _setActiveInDefaultMode;
260
+ /**
261
+ * Sets the active item to the first enabled item starting at the index specified. If the
262
+ * item is disabled, it will move in the fallbackDelta direction until it either
263
+ * finds an enabled item or encounters the end of the list.
264
+ */
265
+ private _setActiveItemByIndex;
266
+ /** Returns the items as an array. */
267
+ private _getItemsArray;
268
+ /** Callback for when the items have changed. */
269
+ private _itemsChanged;
270
+ }
271
+
272
+ /**
273
+ * This is the interface for highlightable items (used by the ActiveDescendantKeyManager).
274
+ * Each item must know how to style itself as active or inactive and whether or not it is
275
+ * currently disabled.
276
+ */
277
+ interface Highlightable extends ListKeyManagerOption {
278
+ /** Applies the styles for an active item to this item. */
279
+ setActiveStyles(): void;
280
+ /** Applies the styles for an inactive item to this item. */
281
+ setInactiveStyles(): void;
282
+ }
283
+ declare class ActiveDescendantKeyManager<T> extends ListKeyManager<Highlightable & T> {
284
+ /**
285
+ * Sets the active item to the item at the specified index and adds the
286
+ * active styles to the newly active item. Also removes active styles
287
+ * from the previously active item.
308
288
  * @param index Index of the item to be set as active.
309
289
  */
310
290
  setActiveItem(index: number): void;
311
291
  /**
312
- * Sets the active item to the item that is specified and focuses it.
292
+ * Sets the active item to the item to the specified one and adds the
293
+ * active styles to the it. Also removes active styles from the
294
+ * previously active item.
313
295
  * @param item Item to be set as active.
314
296
  */
315
297
  setActiveItem(item: T): void;
316
298
  }
317
299
 
300
+ type FocusOrigin = 'touch' | 'mouse' | 'keyboard' | 'program' | null;
301
+ /**
302
+ * Corresponds to the options that can be passed to the native `focus` event.
303
+ * via https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus
304
+ */
305
+ interface FocusOptions$1 {
306
+ /** Whether the browser should scroll to the element when it is focused. */
307
+ preventScroll?: boolean;
308
+ }
309
+ /** Detection mode used for attributing the origin of a focus event. */
310
+ declare enum FocusMonitorDetectionMode {
311
+ /**
312
+ * Any mousedown, keydown, or touchstart event that happened in the previous
313
+ * tick or the current tick will be used to assign a focus event's origin (to
314
+ * either mouse, keyboard, or touch). This is the default option.
315
+ */
316
+ IMMEDIATE = 0,
317
+ /**
318
+ * A focus event's origin is always attributed to the last corresponding
319
+ * mousedown, keydown, or touchstart event, no matter how long ago it occurred.
320
+ */
321
+ EVENTUAL = 1
322
+ }
323
+ /** Injectable service-level options for FocusMonitor. */
324
+ interface FocusMonitorOptions {
325
+ detectionMode?: FocusMonitorDetectionMode;
326
+ }
327
+ /** InjectionToken for FocusMonitorOptions. */
328
+ declare const FOCUS_MONITOR_DEFAULT_OPTIONS: InjectionToken<FocusMonitorOptions>;
318
329
  /** Monitors mouse and keyboard events to determine the cause of focus events. */
319
- export declare class FocusMonitor implements OnDestroy {
330
+ declare class FocusMonitor implements OnDestroy {
320
331
  private _ngZone;
321
332
  private _platform;
322
333
  private readonly _inputModalityDetector;
@@ -398,14 +409,14 @@ export declare class FocusMonitor implements OnDestroy {
398
409
  * @param origin Focus origin.
399
410
  * @param options Options that can be used to configure the focus behavior.
400
411
  */
401
- focusVia(element: HTMLElement, origin: FocusOrigin, options?: FocusOptions_2): void;
412
+ focusVia(element: HTMLElement, origin: FocusOrigin, options?: FocusOptions$1): void;
402
413
  /**
403
414
  * Focuses the element via the specified focus origin.
404
415
  * @param element Element to focus.
405
416
  * @param origin Focus origin.
406
417
  * @param options Options that can be used to configure the focus behavior.
407
418
  */
408
- focusVia(element: ElementRef<HTMLElement>, origin: FocusOrigin, options?: FocusOptions_2): void;
419
+ focusVia(element: ElementRef<HTMLElement>, origin: FocusOrigin, options?: FocusOptions$1): void;
409
420
  ngOnDestroy(): void;
410
421
  /** Access injected document if available or fallback to global document reference */
411
422
  private _getDocument;
@@ -467,381 +478,355 @@ export declare class FocusMonitor implements OnDestroy {
467
478
  static ɵfac: i0.ɵɵFactoryDeclaration<FocusMonitor, never>;
468
479
  static ɵprov: i0.ɵɵInjectableDeclaration<FocusMonitor>;
469
480
  }
470
-
471
- /** Detection mode used for attributing the origin of a focus event. */
472
- export declare enum FocusMonitorDetectionMode {
473
- /**
474
- * Any mousedown, keydown, or touchstart event that happened in the previous
475
- * tick or the current tick will be used to assign a focus event's origin (to
476
- * either mouse, keyboard, or touch). This is the default option.
477
- */
478
- IMMEDIATE = 0,
479
- /**
480
- * A focus event's origin is always attributed to the last corresponding
481
- * mousedown, keydown, or touchstart event, no matter how long ago it occurred.
482
- */
483
- EVENTUAL = 1
484
- }
485
-
486
- /** Injectable service-level options for FocusMonitor. */
487
- export declare interface FocusMonitorOptions {
488
- detectionMode?: FocusMonitorDetectionMode;
489
- }
490
-
491
481
  /**
492
- * Corresponds to the options that can be passed to the native `focus` event.
493
- * via https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus
482
+ * Directive that determines how a particular element was focused (via keyboard, mouse, touch, or
483
+ * programmatically) and adds corresponding classes to the element.
484
+ *
485
+ * There are two variants of this directive:
486
+ * 1) cdkMonitorElementFocus: does not consider an element to be focused if one of its children is
487
+ * focused.
488
+ * 2) cdkMonitorSubtreeFocus: considers an element focused if it or any of its children are focused.
494
489
  */
495
- declare interface FocusOptions_2 {
496
- /** Whether the browser should scroll to the element when it is focused. */
497
- preventScroll?: boolean;
490
+ declare class CdkMonitorFocus implements AfterViewInit, OnDestroy {
491
+ private _elementRef;
492
+ private _focusMonitor;
493
+ private _monitorSubscription;
494
+ private _focusOrigin;
495
+ readonly cdkFocusChange: EventEmitter<FocusOrigin>;
496
+ constructor(...args: unknown[]);
497
+ get focusOrigin(): FocusOrigin;
498
+ ngAfterViewInit(): void;
499
+ ngOnDestroy(): void;
500
+ static ɵfac: i0.ɵɵFactoryDeclaration<CdkMonitorFocus, never>;
501
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CdkMonitorFocus, "[cdkMonitorElementFocus], [cdkMonitorSubtreeFocus]", ["cdkMonitorFocus"], {}, { "cdkFocusChange": "cdkFocusChange"; }, never, never, true, never>;
498
502
  }
499
- export { FocusOptions_2 as FocusOptions }
500
-
501
- export declare type FocusOrigin = 'touch' | 'mouse' | 'keyboard' | 'program' | null;
502
503
 
503
504
  /**
504
- * Class that allows for trapping focus within a DOM element.
505
- *
506
- * This class currently uses a relatively simple approach to focus trapping.
507
- * It assumes that the tab order is the same as DOM order, which is not necessarily true.
508
- * Things like `tabIndex > 0`, flex `order`, and shadow roots can cause the two to be misaligned.
505
+ * This is the interface for focusable items (used by the FocusKeyManager).
506
+ * Each item must know how to focus itself, whether or not it is currently disabled
507
+ * and be able to supply its label.
509
508
  */
510
- export declare class FocusTrap {
511
- readonly _element: HTMLElement;
512
- private _checker;
513
- readonly _ngZone: NgZone;
514
- readonly _document: Document;
515
- /** @breaking-change 20.0.0 param to become required */
516
- readonly _injector?: Injector | undefined;
517
- private _startAnchor;
518
- private _endAnchor;
519
- private _hasAttached;
520
- protected startAnchorListener: () => boolean;
521
- protected endAnchorListener: () => boolean;
522
- /** Whether the focus trap is active. */
523
- get enabled(): boolean;
524
- set enabled(value: boolean);
525
- protected _enabled: boolean;
526
- constructor(_element: HTMLElement, _checker: InteractivityChecker, _ngZone: NgZone, _document: Document, deferAnchors?: boolean,
527
- /** @breaking-change 20.0.0 param to become required */
528
- _injector?: Injector | undefined);
529
- /** Destroys the focus trap by cleaning up the anchors. */
530
- destroy(): void;
509
+ interface FocusableOption extends ListKeyManagerOption {
510
+ /** Focuses the `FocusableOption`. */
511
+ focus(origin?: FocusOrigin): void;
512
+ }
513
+ declare class FocusKeyManager<T> extends ListKeyManager<FocusableOption & T> {
514
+ private _origin;
531
515
  /**
532
- * Inserts the anchors into the DOM. This is usually done automatically
533
- * in the constructor, but can be deferred for cases like directives with `*ngIf`.
534
- * @returns Whether the focus trap managed to attach successfully. This may not be the case
535
- * if the target element isn't currently in the DOM.
516
+ * Sets the focus origin that will be passed in to the items for any subsequent `focus` calls.
517
+ * @param origin Focus origin to be used when focusing items.
536
518
  */
537
- attachAnchors(): boolean;
519
+ setFocusOrigin(origin: FocusOrigin): this;
538
520
  /**
539
- * Waits for the zone to stabilize, then focuses the first tabbable element.
540
- * @returns Returns a promise that resolves with a boolean, depending
541
- * on whether focus was moved successfully.
521
+ * Sets the active item to the item at the specified
522
+ * index and focuses the newly active item.
523
+ * @param index Index of the item to be set as active.
542
524
  */
543
- focusInitialElementWhenReady(options?: FocusOptions): Promise<boolean>;
525
+ setActiveItem(index: number): void;
544
526
  /**
545
- * Waits for the zone to stabilize, then focuses
546
- * the first tabbable element within the focus trap region.
547
- * @returns Returns a promise that resolves with a boolean, depending
548
- * on whether focus was moved successfully.
527
+ * Sets the active item to the item that is specified and focuses it.
528
+ * @param item Item to be set as active.
549
529
  */
550
- focusFirstTabbableElementWhenReady(options?: FocusOptions): Promise<boolean>;
530
+ setActiveItem(item: T): void;
531
+ }
532
+
533
+ /** Represents an item within a tree that can be passed to a TreeKeyManager. */
534
+ interface TreeKeyManagerItem {
535
+ /** Whether the item is disabled. */
536
+ isDisabled?: (() => boolean) | boolean;
537
+ /** The user-facing label for this item. */
538
+ getLabel?(): string;
539
+ /** Perform the main action (i.e. selection) for this item. */
540
+ activate(): void;
541
+ /** Retrieves the parent for this item. This is `null` if there is no parent. */
542
+ getParent(): TreeKeyManagerItem | null;
543
+ /** Retrieves the children for this item. */
544
+ getChildren(): TreeKeyManagerItem[] | Observable<TreeKeyManagerItem[]>;
545
+ /** Determines if the item is currently expanded. */
546
+ isExpanded: (() => boolean) | boolean;
547
+ /** Collapses the item, hiding its children. */
548
+ collapse(): void;
549
+ /** Expands the item, showing its children. */
550
+ expand(): void;
551
551
  /**
552
- * Waits for the zone to stabilize, then focuses
553
- * the last 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.
552
+ * Focuses the item. This should provide some indication to the user that this item is focused.
556
553
  */
557
- focusLastTabbableElementWhenReady(options?: FocusOptions): Promise<boolean>;
554
+ focus(): void;
558
555
  /**
559
- * Get the specified boundary element of the trapped region.
560
- * @param bound The boundary to get (start or end of trapped region).
561
- * @returns The boundary element.
556
+ * Unfocus the item. This should remove the focus state.
562
557
  */
563
- private _getRegionBoundary;
558
+ unfocus(): void;
564
559
  /**
565
- * Focuses the element that should be focused when the focus trap is initialized.
566
- * @returns Whether focus was moved successfully.
560
+ * Sets the item to be focusable without actually focusing it.
567
561
  */
568
- focusInitialElement(options?: FocusOptions): boolean;
562
+ makeFocusable?(): void;
563
+ }
564
+ /**
565
+ * Configuration for the TreeKeyManager.
566
+ */
567
+ interface TreeKeyManagerOptions<T extends TreeKeyManagerItem> {
569
568
  /**
570
- * Focuses the first tabbable element within the focus trap region.
571
- * @returns Whether focus was moved successfully.
569
+ * If true, then the key manager will call `activate` in addition to calling `focus` when a
570
+ * particular item is focused.
572
571
  */
573
- focusFirstTabbableElement(options?: FocusOptions): boolean;
572
+ shouldActivationFollowFocus?: boolean;
574
573
  /**
575
- * Focuses the last tabbable element within the focus trap region.
576
- * @returns Whether focus was moved successfully.
574
+ * The direction in which the tree items are laid out horizontally. This influences which key
575
+ * will be interpreted as expand or collapse.
577
576
  */
578
- focusLastTabbableElement(options?: FocusOptions): boolean;
577
+ horizontalOrientation?: 'rtl' | 'ltr';
579
578
  /**
580
- * Checks whether the focus trap has successfully been attached.
579
+ * If provided, navigation "skips" over items that pass the given predicate.
580
+ *
581
+ * If the item is to be skipped, predicate function should return false.
581
582
  */
582
- hasAttached(): boolean;
583
- /** Get the first tabbable element from a DOM subtree (inclusive). */
584
- private _getFirstTabbableElement;
585
- /** Get the last tabbable element from a DOM subtree (inclusive). */
586
- private _getLastTabbableElement;
587
- /** Creates an anchor element. */
588
- private _createAnchor;
583
+ skipPredicate?: (item: T) => boolean;
589
584
  /**
590
- * Toggles the `tabindex` of an anchor, based on the enabled state of the focus trap.
591
- * @param isEnabled Whether the focus trap is enabled.
592
- * @param anchor Anchor on which to toggle the tabindex.
585
+ * If provided, determines how the key manager determines if two items are equivalent.
586
+ *
587
+ * It should provide a unique key for each unique tree item. If two tree items are equivalent,
588
+ * then this function should return the same value.
593
589
  */
594
- private _toggleAnchorTabIndex;
590
+ trackBy?: (treeItem: T) => unknown;
595
591
  /**
596
- * Toggles the`tabindex` of both anchors to either trap Tab focus or allow it to escape.
597
- * @param enabled: Whether the anchors should trap Tab.
592
+ * If a value is provided, enables typeahead mode, which allows users to set the active item
593
+ * by typing the visible label of the item.
594
+ *
595
+ * If a number is provided, this will be the time to wait after the last keystroke before
596
+ * setting the active item. If `true` is provided, the default interval of 200ms will be used.
598
597
  */
599
- protected toggleAnchors(enabled: boolean): void;
600
- /** Executes a function when the zone is stable. */
601
- private _executeOnStable;
598
+ typeAheadDebounceInterval?: true | number;
602
599
  }
603
-
604
- /**
605
- * Factory that allows easy instantiation of focus traps.
606
- */
607
- export declare class FocusTrapFactory {
608
- private _checker;
609
- private _ngZone;
610
- private _document;
611
- private _injector;
612
- constructor(...args: unknown[]);
600
+ interface TreeKeyManagerStrategy<T extends TreeKeyManagerItem> {
601
+ /** Stream that emits any time the focused item changes. */
602
+ readonly change: Subject<T | null>;
613
603
  /**
614
- * Creates a focus-trapped region around the given element.
615
- * @param element The element around which focus will be trapped.
616
- * @param deferCaptureElements Defers the creation of focus-capturing elements to be done
617
- * manually by the user.
618
- * @returns The created focus trap instance.
604
+ * Cleans up the key manager.
619
605
  */
620
- create(element: HTMLElement, deferCaptureElements?: boolean): FocusTrap;
621
- static ɵfac: i0.ɵɵFactoryDeclaration<FocusTrapFactory, never>;
622
- static ɵprov: i0.ɵɵInjectableDeclaration<FocusTrapFactory>;
623
- }
624
-
625
- /**
626
- * A strategy that dictates how FocusTrap should prevent elements
627
- * outside of the FocusTrap from being focused.
628
- */
629
- export declare interface FocusTrapInertStrategy {
630
- /** Makes all elements outside focusTrap unfocusable. */
631
- preventFocus(focusTrap: FocusTrap): void;
632
- /** Reverts elements made unfocusable by preventFocus to their previous state. */
633
- allowFocus(focusTrap: FocusTrap): void;
634
- }
635
-
636
- /** Injectable that ensures only the most recently enabled FocusTrap is active. */
637
- declare class FocusTrapManager {
638
- private _focusTrapStack;
606
+ destroy(): void;
639
607
  /**
640
- * Disables the FocusTrap at the top of the stack, and then pushes
641
- * the new FocusTrap onto the stack.
608
+ * Handles a keyboard event on the tree.
609
+ *
610
+ * @param event Keyboard event that represents the user interaction with the tree.
642
611
  */
643
- register(focusTrap: ManagedFocusTrap): void;
612
+ onKeydown(event: KeyboardEvent): void;
613
+ /** Index of the currently active item. */
614
+ getActiveItemIndex(): number | null;
615
+ /** The currently active item. */
616
+ getActiveItem(): T | null;
644
617
  /**
645
- * Removes the FocusTrap from the stack, and activates the
646
- * FocusTrap that is the new top of the stack.
618
+ * Focus the provided item by index.
619
+ *
620
+ * Updates the state of the currently active item. Emits to `change` stream if active item
621
+ * Changes.
622
+ * @param index The index of the item to focus.
623
+ * @param options Additional focusing options.
647
624
  */
648
- deregister(focusTrap: ManagedFocusTrap): void;
649
- static ɵfac: i0.ɵɵFactoryDeclaration<FocusTrapManager, never>;
650
- static ɵprov: i0.ɵɵInjectableDeclaration<FocusTrapManager>;
651
- }
652
-
653
- /**
654
- * Gets the list of IDs referenced by the given ARIA attribute on an element.
655
- * Used for attributes such as aria-labelledby, aria-owns, etc.
656
- */
657
- export declare function getAriaReferenceIds(el: Element, attr: string): string[];
658
-
659
- /** Set of possible high-contrast mode backgrounds. */
660
- export declare enum HighContrastMode {
661
- NONE = 0,
662
- BLACK_ON_WHITE = 1,
663
- WHITE_ON_BLACK = 2
625
+ focusItem(index: number, options?: {
626
+ emitChangeEvent?: boolean;
627
+ }): void;
628
+ /**
629
+ * Focus the provided item.
630
+ *
631
+ * Updates the state of the currently active item. Emits to `change` stream if active item
632
+ * Changes.
633
+ * @param item The item to focus. Equality is determined via the trackBy function.
634
+ * @param options Additional focusing options.
635
+ */
636
+ focusItem(item: T, options?: {
637
+ emitChangeEvent?: boolean;
638
+ }): void;
639
+ focusItem(itemOrIndex: number | T, options?: {
640
+ emitChangeEvent?: boolean;
641
+ }): void;
664
642
  }
643
+ type TreeKeyManagerFactory<T extends TreeKeyManagerItem> = (items: Observable<T[]> | QueryList<T> | T[], options: TreeKeyManagerOptions<T>) => TreeKeyManagerStrategy<T>;
665
644
 
666
645
  /**
667
- * Service to determine whether the browser is currently in a high-contrast-mode environment.
646
+ * @docs-private
668
647
  *
669
- * Microsoft Windows supports an accessibility feature called "High Contrast Mode". This mode
670
- * changes the appearance of all applications, including web applications, to dramatically increase
671
- * contrast.
648
+ * Opt-out of Tree of key manager behavior.
672
649
  *
673
- * IE, Edge, and Firefox currently support this mode. Chrome does not support Windows High Contrast
674
- * Mode. This service does not detect high-contrast mode as added by the Chrome "High Contrast"
675
- * browser extension.
650
+ * When provided, Tree has same focus management behavior as before TreeKeyManager was introduced.
651
+ * - Tree does not respond to keyboard interaction
652
+ * - Tree node allows tabindex to be set by Input binding
653
+ * - Tree node allows tabindex to be set by attribute binding
654
+ *
655
+ * @deprecated NoopTreeKeyManager deprecated. Use TreeKeyManager or inject a
656
+ * TreeKeyManagerStrategy instead. To be removed in a future version.
657
+ *
658
+ * @breaking-change 21.0.0
676
659
  */
677
- export declare class HighContrastModeDetector implements OnDestroy {
678
- private _platform;
679
- /**
680
- * Figuring out the high contrast mode and adding the body classes can cause
681
- * some expensive layouts. This flag is used to ensure that we only do it once.
682
- */
683
- private _hasCheckedHighContrastMode;
684
- private _document;
685
- private _breakpointSubscription;
686
- constructor(...args: unknown[]);
687
- /** Gets the current high-contrast-mode for the page. */
688
- getHighContrastMode(): HighContrastMode;
689
- ngOnDestroy(): void;
690
- /** Applies CSS classes indicating high-contrast mode to document body (browser-only). */
691
- _applyBodyHighContrastModeCssClasses(): void;
692
- static ɵfac: i0.ɵɵFactoryDeclaration<HighContrastModeDetector, never>;
693
- static ɵprov: i0.ɵɵInjectableDeclaration<HighContrastModeDetector>;
660
+ declare class NoopTreeKeyManager<T extends TreeKeyManagerItem> implements TreeKeyManagerStrategy<T> {
661
+ readonly _isNoopTreeKeyManager = true;
662
+ readonly change: Subject<T | null>;
663
+ destroy(): void;
664
+ onKeydown(): void;
665
+ getActiveItemIndex(): null;
666
+ getActiveItem(): null;
667
+ focusItem(): void;
694
668
  }
695
-
696
669
  /**
697
- * This is the interface for highlightable items (used by the ActiveDescendantKeyManager).
698
- * Each item must know how to style itself as active or inactive and whether or not it is
699
- * currently disabled.
670
+ * @docs-private
671
+ *
672
+ * Opt-out of Tree of key manager behavior.
673
+ *
674
+ * When provided, Tree has same focus management behavior as before TreeKeyManager was introduced.
675
+ * - Tree does not respond to keyboard interaction
676
+ * - Tree node allows tabindex to be set by Input binding
677
+ * - Tree node allows tabindex to be set by attribute binding
678
+ *
679
+ * @deprecated NoopTreeKeyManager deprecated. Use TreeKeyManager or inject a
680
+ * TreeKeyManagerStrategy instead. To be removed in a future version.
681
+ *
682
+ * @breaking-change 21.0.0
700
683
  */
701
- export declare interface Highlightable extends ListKeyManagerOption {
702
- /** Applies the styles for an active item to this item. */
703
- setActiveStyles(): void;
704
- /** Applies the styles for an inactive item to this item. */
705
- setInactiveStyles(): void;
706
- }
707
-
708
- declare namespace i2 {
709
- export {
710
- LiveAnnouncer,
711
- CdkAriaLive
712
- }
713
- }
714
-
715
- declare namespace i3 {
716
- export {
717
- FocusTrap,
718
- FocusTrapFactory,
719
- CdkTrapFocus
720
- }
721
- }
722
-
723
- declare namespace i4 {
724
- export {
725
- FocusOrigin,
726
- FocusOptions_2 as FocusOptions,
727
- FocusMonitorDetectionMode,
728
- FocusMonitorOptions,
729
- FOCUS_MONITOR_DEFAULT_OPTIONS,
730
- FocusMonitor,
731
- CdkMonitorFocus
732
- }
733
- }
734
-
735
- /** Service that generates unique IDs for DOM nodes. */
736
- export declare class _IdGenerator {
737
- private _appId;
738
- /**
739
- * Generates a unique ID with a specific prefix.
740
- * @param prefix Prefix to add to the ID.
741
- */
742
- getId(prefix: string): string;
743
- static ɵfac: i0.ɵɵFactoryDeclaration<_IdGenerator, never>;
744
- static ɵprov: i0.ɵɵInjectableDeclaration<_IdGenerator>;
745
- }
746
-
684
+ declare function NOOP_TREE_KEY_MANAGER_FACTORY<T extends TreeKeyManagerItem>(): TreeKeyManagerFactory<T>;
747
685
  /**
748
- * Default options for the InputModalityDetector.
686
+ * @docs-private
749
687
  *
750
- * Modifier keys are ignored by default (i.e. when pressed won't cause the service to detect
751
- * keyboard input modality) for two reasons:
688
+ * Opt-out of Tree of key manager behavior.
752
689
  *
753
- * 1. Modifier keys are commonly used with mouse to perform actions such as 'right click' or 'open
754
- * in new tab', and are thus less representative of actual keyboard interaction.
755
- * 2. VoiceOver triggers some keyboard events when linearly navigating with Control + Option (but
756
- * confusingly not with Caps Lock). Thus, to have parity with other screen readers, we ignore
757
- * these keys so as to not update the input modality.
690
+ * When provided, Tree has same focus management behavior as before TreeKeyManager was introduced.
691
+ * - Tree does not respond to keyboard interaction
692
+ * - Tree node allows tabindex to be set by Input binding
693
+ * - Tree node allows tabindex to be set by attribute binding
758
694
  *
759
- * Note that we do not by default ignore the right Meta key on Safari because it has the same key
760
- * code as the ContextMenu key on other browsers. When we switch to using event.key, we can
761
- * distinguish between the two.
695
+ * @deprecated NoopTreeKeyManager deprecated. Use TreeKeyManager or inject a
696
+ * TreeKeyManagerStrategy instead. To be removed in a future version.
697
+ *
698
+ * @breaking-change 21.0.0
762
699
  */
763
- export declare const INPUT_MODALITY_DETECTOR_DEFAULT_OPTIONS: InputModalityDetectorOptions;
700
+ declare const NOOP_TREE_KEY_MANAGER_FACTORY_PROVIDER: Provider;
764
701
 
765
702
  /**
766
- * Injectable options for the InputModalityDetector. These are shallowly merged with the default
767
- * options.
768
- */
769
- export declare const INPUT_MODALITY_DETECTOR_OPTIONS: InjectionToken<InputModalityDetectorOptions>;
770
-
771
- /**
772
- * The input modalities detected by this service. Null is used if the input modality is unknown.
773
- */
774
- export declare type InputModality = 'keyboard' | 'mouse' | 'touch' | null;
775
-
776
- /**
777
- * Service that detects the user's input modality.
778
- *
779
- * This service does not update the input modality when a user navigates with a screen reader
780
- * (e.g. linear navigation with VoiceOver, object navigation / browse mode with NVDA, virtual PC
781
- * cursor mode with JAWS). This is in part due to technical limitations (i.e. keyboard events do not
782
- * fire as expected in these modes) but is also arguably the correct behavior. Navigating with a
783
- * screen reader is akin to visually scanning a page, and should not be interpreted as actual user
784
- * input interaction.
785
- *
786
- * When a user is not navigating but *interacting* with a screen reader, this service attempts to
787
- * update the input modality to keyboard, but in general this service's behavior is largely
788
- * undefined.
703
+ * This class manages keyboard events for trees. If you pass it a QueryList or other list of tree
704
+ * items, it will set the active item, focus, handle expansion and typeahead correctly when
705
+ * keyboard events occur.
789
706
  */
790
- export declare class InputModalityDetector implements OnDestroy {
791
- private readonly _platform;
792
- private readonly _listenerCleanups;
793
- /** Emits whenever an input modality is detected. */
794
- readonly modalityDetected: Observable<InputModality>;
795
- /** Emits when the input modality changes. */
796
- readonly modalityChanged: Observable<InputModality>;
797
- /** The most recently detected input modality. */
798
- get mostRecentModality(): InputModality;
707
+ declare class TreeKeyManager<T extends TreeKeyManagerItem> implements TreeKeyManagerStrategy<T> {
708
+ /** The index of the currently active (focused) item. */
709
+ private _activeItemIndex;
710
+ /** The currently active (focused) item. */
711
+ private _activeItem;
712
+ /** Whether or not we activate the item when it's focused. */
713
+ private _shouldActivationFollowFocus;
799
714
  /**
800
- * The most recently detected input modality event target. Is null if no input modality has been
801
- * detected or if the associated event target is null for some unknown reason.
715
+ * The orientation that the tree is laid out in. In `rtl` mode, the behavior of Left and
716
+ * Right arrow are switched.
802
717
  */
803
- _mostRecentTarget: HTMLElement | null;
804
- /** The underlying BehaviorSubject that emits whenever an input modality is detected. */
805
- private readonly _modality;
806
- /** Options for this InputModalityDetector. */
807
- private readonly _options;
718
+ private _horizontalOrientation;
808
719
  /**
809
- * The timestamp of the last touch input modality. Used to determine whether mousedown events
810
- * should be attributed to mouse or touch.
720
+ * Predicate function that can be used to check whether an item should be skipped
721
+ * by the key manager.
722
+ *
723
+ * The default value for this doesn't skip any elements in order to keep tree items focusable
724
+ * when disabled. This aligns with ARIA guidelines:
725
+ * https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#focusabilityofdisabledcontrols.
811
726
  */
812
- private _lastTouchMs;
727
+ private _skipPredicateFn;
728
+ /** Function to determine equivalent items. */
729
+ private _trackByFn;
730
+ /** Synchronous cache of the items to manage. */
731
+ private _items;
732
+ private _typeahead?;
733
+ private _typeaheadSubscription;
734
+ private _hasInitialFocused;
735
+ private _initializeFocus;
813
736
  /**
814
- * Handles keydown events. Must be an arrow function in order to preserve the context when it gets
815
- * bound.
737
+ *
738
+ * @param items List of TreeKeyManager options. Can be synchronous or asynchronous.
739
+ * @param config Optional configuration options. By default, use 'ltr' horizontal orientation. By
740
+ * default, do not skip any nodes. By default, key manager only calls `focus` method when items
741
+ * are focused and does not call `activate`. If `typeaheadDefaultInterval` is `true`, use a
742
+ * default interval of 200ms.
816
743
  */
817
- private _onKeydown;
744
+ constructor(items: Observable<T[]> | QueryList<T> | T[], config: TreeKeyManagerOptions<T>);
745
+ /** Stream that emits any time the focused item changes. */
746
+ readonly change: Subject<T | null>;
747
+ /** Cleans up the key manager. */
748
+ destroy(): void;
818
749
  /**
819
- * Handles mousedown events. Must be an arrow function in order to preserve the context when it
820
- * gets bound.
750
+ * Handles a keyboard event on the tree.
751
+ * @param event Keyboard event that represents the user interaction with the tree.
821
752
  */
822
- private _onMousedown;
753
+ onKeydown(event: KeyboardEvent): void;
754
+ /** Index of the currently active item. */
755
+ getActiveItemIndex(): number | null;
756
+ /** The currently active item. */
757
+ getActiveItem(): T | null;
758
+ /** Focus the first available item. */
759
+ private _focusFirstItem;
760
+ /** Focus the last available item. */
761
+ private _focusLastItem;
762
+ /** Focus the next available item. */
763
+ private _focusNextItem;
764
+ /** Focus the previous available item. */
765
+ private _focusPreviousItem;
823
766
  /**
824
- * Handles touchstart events. Must be an arrow function in order to preserve the context when it
825
- * gets bound.
767
+ * Focus the provided item by index.
768
+ * @param index The index of the item to focus.
769
+ * @param options Additional focusing options.
826
770
  */
827
- private _onTouchstart;
828
- constructor(...args: unknown[]);
829
- ngOnDestroy(): void;
830
- static ɵfac: i0.ɵɵFactoryDeclaration<InputModalityDetector, never>;
831
- static ɵprov: i0.ɵɵInjectableDeclaration<InputModalityDetector>;
771
+ focusItem(index: number, options?: {
772
+ emitChangeEvent?: boolean;
773
+ }): void;
774
+ focusItem(item: T, options?: {
775
+ emitChangeEvent?: boolean;
776
+ }): void;
777
+ focusItem(itemOrIndex: number | T, options?: {
778
+ emitChangeEvent?: boolean;
779
+ }): void;
780
+ private _updateActiveItemIndex;
781
+ private _setTypeAhead;
782
+ private _findNextAvailableItemIndex;
783
+ private _findPreviousAvailableItemIndex;
784
+ /**
785
+ * If the item is already expanded, we collapse the item. Otherwise, we will focus the parent.
786
+ */
787
+ private _collapseCurrentItem;
788
+ /**
789
+ * If the item is already collapsed, we expand the item. Otherwise, we will focus the first child.
790
+ */
791
+ private _expandCurrentItem;
792
+ private _isCurrentItemExpanded;
793
+ private _isItemDisabled;
794
+ /** For all items that are the same level as the current item, we expand those items. */
795
+ private _expandAllItemsAtCurrentItemLevel;
796
+ private _activateCurrentItem;
832
797
  }
798
+ /**
799
+ * @docs-private
800
+ * @deprecated No longer used, will be removed.
801
+ * @breaking-change 21.0.0
802
+ */
803
+ declare function TREE_KEY_MANAGER_FACTORY<T extends TreeKeyManagerItem>(): TreeKeyManagerFactory<T>;
804
+ /** Injection token that determines the key manager to use. */
805
+ declare const TREE_KEY_MANAGER: InjectionToken<TreeKeyManagerFactory<any>>;
806
+ /**
807
+ * @docs-private
808
+ * @deprecated No longer used, will be removed.
809
+ * @breaking-change 21.0.0
810
+ */
811
+ declare const TREE_KEY_MANAGER_FACTORY_PROVIDER: {
812
+ provide: InjectionToken<TreeKeyManagerFactory<any>>;
813
+ useFactory: typeof TREE_KEY_MANAGER_FACTORY;
814
+ };
833
815
 
834
- /** Options to configure the behavior of the InputModalityDetector. */
835
- export declare interface InputModalityDetectorOptions {
836
- /** Keys to ignore when detecting keyboard input modality. */
837
- ignoreKeys?: number[];
816
+ /**
817
+ * Configuration for the isFocusable method.
818
+ */
819
+ declare class IsFocusableConfig {
820
+ /**
821
+ * Whether to count an element as focusable even if it is not currently visible.
822
+ */
823
+ ignoreVisibility: boolean;
838
824
  }
839
-
840
825
  /**
841
826
  * Utility for checking the interactivity of an element, such as whether it is focusable or
842
827
  * tabbable.
843
828
  */
844
- export declare class InteractivityChecker {
829
+ declare class InteractivityChecker {
845
830
  private _platform;
846
831
  constructor(...args: unknown[]);
847
832
  /**
@@ -880,575 +865,517 @@ export declare class InteractivityChecker {
880
865
  static ɵprov: i0.ɵɵInjectableDeclaration<InteractivityChecker>;
881
866
  }
882
867
 
883
-
884
- /** Gets whether an event could be a faked `mousedown` event dispatched by a screen reader. */
885
- export declare function isFakeMousedownFromScreenReader(event: MouseEvent): boolean;
886
-
887
- /** Gets whether an event could be a faked `touchstart` event dispatched by a screen reader. */
888
- export declare function isFakeTouchstartFromScreenReader(event: TouchEvent): boolean;
889
-
890
868
  /**
891
- * Configuration for the isFocusable method.
869
+ * Options for creating a ConfigurableFocusTrap.
892
870
  */
893
- export declare class IsFocusableConfig {
871
+ interface ConfigurableFocusTrapConfig {
894
872
  /**
895
- * Whether to count an element as focusable even if it is not currently visible.
873
+ * Whether to defer the creation of FocusTrap elements to be done manually by the user.
896
874
  */
897
- ignoreVisibility: boolean;
875
+ defer: boolean;
898
876
  }
899
877
 
900
878
  /**
901
- * This class manages keyboard events for selectable lists. If you pass it a query list
902
- * of items, it will set the active item correctly when arrow events occur.
879
+ * Class that allows for trapping focus within a DOM element.
880
+ *
881
+ * This class currently uses a relatively simple approach to focus trapping.
882
+ * It assumes that the tab order is the same as DOM order, which is not necessarily true.
883
+ * Things like `tabIndex > 0`, flex `order`, and shadow roots can cause the two to be misaligned.
903
884
  */
904
- export declare class ListKeyManager<T extends ListKeyManagerOption> {
905
- private _items;
906
- private _activeItemIndex;
907
- private _activeItem;
908
- private _wrap;
909
- private _typeaheadSubscription;
910
- private _itemChangesSubscription?;
911
- private _vertical;
912
- private _horizontal;
913
- private _allowedModifierKeys;
914
- private _homeAndEnd;
915
- private _pageUpAndDown;
916
- private _effectRef;
917
- private _typeahead?;
885
+ declare class FocusTrap {
886
+ readonly _element: HTMLElement;
887
+ private _checker;
888
+ readonly _ngZone: NgZone;
889
+ readonly _document: Document;
890
+ /** @breaking-change 20.0.0 param to become required */
891
+ readonly _injector?: Injector | undefined;
892
+ private _startAnchor;
893
+ private _endAnchor;
894
+ private _hasAttached;
895
+ protected startAnchorListener: () => boolean;
896
+ protected endAnchorListener: () => boolean;
897
+ /** Whether the focus trap is active. */
898
+ get enabled(): boolean;
899
+ set enabled(value: boolean);
900
+ protected _enabled: boolean;
901
+ constructor(_element: HTMLElement, _checker: InteractivityChecker, _ngZone: NgZone, _document: Document, deferAnchors?: boolean,
902
+ /** @breaking-change 20.0.0 param to become required */
903
+ _injector?: Injector | undefined);
904
+ /** Destroys the focus trap by cleaning up the anchors. */
905
+ destroy(): void;
918
906
  /**
919
- * Predicate function that can be used to check whether an item should be skipped
920
- * by the key manager. By default, disabled items are skipped.
907
+ * Inserts the anchors into the DOM. This is usually done automatically
908
+ * in the constructor, but can be deferred for cases like directives with `*ngIf`.
909
+ * @returns Whether the focus trap managed to attach successfully. This may not be the case
910
+ * if the target element isn't currently in the DOM.
921
911
  */
922
- private _skipPredicateFn;
923
- constructor(items: QueryList<T> | T[] | readonly T[]);
924
- constructor(items: Signal<T[]> | Signal<readonly T[]>, injector: Injector);
912
+ attachAnchors(): boolean;
925
913
  /**
926
- * Stream that emits any time the TAB key is pressed, so components can react
927
- * when focus is shifted off of the list.
914
+ * Waits for the zone to stabilize, then focuses the first tabbable element.
915
+ * @returns Returns a promise that resolves with a boolean, depending
916
+ * on whether focus was moved successfully.
928
917
  */
929
- readonly tabOut: Subject<void>;
930
- /** Stream that emits whenever the active item of the list manager changes. */
931
- readonly change: Subject<number>;
918
+ focusInitialElementWhenReady(options?: FocusOptions): Promise<boolean>;
932
919
  /**
933
- * Sets the predicate function that determines which items should be skipped by the
934
- * list key manager.
935
- * @param predicate Function that determines whether the given item should be skipped.
920
+ * Waits for the zone to stabilize, then focuses
921
+ * the first tabbable element within the focus trap region.
922
+ * @returns Returns a promise that resolves with a boolean, depending
923
+ * on whether focus was moved successfully.
936
924
  */
937
- skipPredicate(predicate: (item: T) => boolean): this;
925
+ focusFirstTabbableElementWhenReady(options?: FocusOptions): Promise<boolean>;
938
926
  /**
939
- * Configures wrapping mode, which determines whether the active item will wrap to
940
- * the other end of list when there are no more items in the given direction.
941
- * @param shouldWrap Whether the list should wrap when reaching the end.
927
+ * Waits for the zone to stabilize, then focuses
928
+ * the last tabbable element within the focus trap region.
929
+ * @returns Returns a promise that resolves with a boolean, depending
930
+ * on whether focus was moved successfully.
942
931
  */
943
- withWrap(shouldWrap?: boolean): this;
932
+ focusLastTabbableElementWhenReady(options?: FocusOptions): Promise<boolean>;
944
933
  /**
945
- * Configures whether the key manager should be able to move the selection vertically.
946
- * @param enabled Whether vertical selection should be enabled.
934
+ * Get the specified boundary element of the trapped region.
935
+ * @param bound The boundary to get (start or end of trapped region).
936
+ * @returns The boundary element.
947
937
  */
948
- withVerticalOrientation(enabled?: boolean): this;
938
+ private _getRegionBoundary;
949
939
  /**
950
- * Configures the key manager to move the selection horizontally.
951
- * Passing in `null` will disable horizontal movement.
952
- * @param direction Direction in which the selection can be moved.
940
+ * Focuses the element that should be focused when the focus trap is initialized.
941
+ * @returns Whether focus was moved successfully.
953
942
  */
954
- withHorizontalOrientation(direction: 'ltr' | 'rtl' | null): this;
943
+ focusInitialElement(options?: FocusOptions): boolean;
955
944
  /**
956
- * Modifier keys which are allowed to be held down and whose default actions will be prevented
957
- * as the user is pressing the arrow keys. Defaults to not allowing any modifier keys.
958
- */
959
- withAllowedModifierKeys(keys: ListKeyManagerModifierKey[]): this;
960
- /**
961
- * Turns on typeahead mode which allows users to set the active item by typing.
962
- * @param debounceInterval Time to wait after the last keystroke before setting the active item.
963
- */
964
- withTypeAhead(debounceInterval?: number): this;
965
- /** Cancels the current typeahead sequence. */
966
- cancelTypeahead(): this;
967
- /**
968
- * Configures the key manager to activate the first and last items
969
- * respectively when the Home or End key is pressed.
970
- * @param enabled Whether pressing the Home or End key activates the first/last item.
971
- */
972
- withHomeAndEnd(enabled?: boolean): this;
973
- /**
974
- * Configures the key manager to activate every 10th, configured or first/last element in up/down direction
975
- * respectively when the Page-Up or Page-Down key is pressed.
976
- * @param enabled Whether pressing the Page-Up or Page-Down key activates the first/last item.
977
- * @param delta Whether pressing the Home or End key activates the first/last item.
978
- */
979
- withPageUpDown(enabled?: boolean, delta?: number): this;
980
- /**
981
- * Sets the active item to the item at the index specified.
982
- * @param index The index of the item to be set as active.
983
- */
984
- setActiveItem(index: number): void;
985
- /**
986
- * Sets the active item to the specified item.
987
- * @param item The item to be set as active.
988
- */
989
- setActiveItem(item: T): void;
990
- /**
991
- * Sets the active item depending on the key event passed in.
992
- * @param event Keyboard event to be used for determining which element should be active.
993
- */
994
- onKeydown(event: KeyboardEvent): void;
995
- /** Index of the currently active item. */
996
- get activeItemIndex(): number | null;
997
- /** The active item. */
998
- get activeItem(): T | null;
999
- /** Gets whether the user is currently typing into the manager using the typeahead feature. */
1000
- isTyping(): boolean;
1001
- /** Sets the active item to the first enabled item in the list. */
1002
- setFirstItemActive(): void;
1003
- /** Sets the active item to the last enabled item in the list. */
1004
- setLastItemActive(): void;
1005
- /** Sets the active item to the next enabled item in the list. */
1006
- setNextItemActive(): void;
1007
- /** Sets the active item to a previous enabled item in the list. */
1008
- setPreviousItemActive(): void;
1009
- /**
1010
- * Allows setting the active without any other effects.
1011
- * @param index Index of the item to be set as active.
1012
- */
1013
- updateActiveItem(index: number): void;
1014
- /**
1015
- * Allows setting the active item without any other effects.
1016
- * @param item Item to be set as active.
945
+ * Focuses the first tabbable element within the focus trap region.
946
+ * @returns Whether focus was moved successfully.
1017
947
  */
1018
- updateActiveItem(item: T): void;
1019
- /** Cleans up the key manager. */
1020
- destroy(): void;
948
+ focusFirstTabbableElement(options?: FocusOptions): boolean;
1021
949
  /**
1022
- * This method sets the active item, given a list of items and the delta between the
1023
- * currently active item and the new active item. It will calculate differently
1024
- * depending on whether wrap mode is turned on.
950
+ * Focuses the last tabbable element within the focus trap region.
951
+ * @returns Whether focus was moved successfully.
1025
952
  */
1026
- private _setActiveItemByDelta;
953
+ focusLastTabbableElement(options?: FocusOptions): boolean;
1027
954
  /**
1028
- * Sets the active item properly given "wrap" mode. In other words, it will continue to move
1029
- * down the list until it finds an item that is not disabled, and it will wrap if it
1030
- * encounters either end of the list.
955
+ * Checks whether the focus trap has successfully been attached.
1031
956
  */
1032
- private _setActiveInWrapMode;
957
+ hasAttached(): boolean;
958
+ /** Get the first tabbable element from a DOM subtree (inclusive). */
959
+ private _getFirstTabbableElement;
960
+ /** Get the last tabbable element from a DOM subtree (inclusive). */
961
+ private _getLastTabbableElement;
962
+ /** Creates an anchor element. */
963
+ private _createAnchor;
1033
964
  /**
1034
- * Sets the active item properly given the default mode. In other words, it will
1035
- * continue to move down the list until it finds an item that is not disabled. If
1036
- * it encounters either end of the list, it will stop and not wrap.
965
+ * Toggles the `tabindex` of an anchor, based on the enabled state of the focus trap.
966
+ * @param isEnabled Whether the focus trap is enabled.
967
+ * @param anchor Anchor on which to toggle the tabindex.
1037
968
  */
1038
- private _setActiveInDefaultMode;
969
+ private _toggleAnchorTabIndex;
1039
970
  /**
1040
- * Sets the active item to the first enabled item starting at the index specified. If the
1041
- * item is disabled, it will move in the fallbackDelta direction until it either
1042
- * finds an enabled item or encounters the end of the list.
971
+ * Toggles the`tabindex` of both anchors to either trap Tab focus or allow it to escape.
972
+ * @param enabled: Whether the anchors should trap Tab.
1043
973
  */
1044
- private _setActiveItemByIndex;
1045
- /** Returns the items as an array. */
1046
- private _getItemsArray;
1047
- /** Callback for when the items have changed. */
1048
- private _itemsChanged;
1049
- }
1050
-
1051
- /** Modifier keys handled by the ListKeyManager. */
1052
- export declare type ListKeyManagerModifierKey = 'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey';
1053
-
1054
- /** This interface is for items that can be passed to a ListKeyManager. */
1055
- export declare interface ListKeyManagerOption {
1056
- /** Whether the option is disabled. */
1057
- disabled?: boolean;
1058
- /** Gets the label for this option. */
1059
- getLabel?(): string;
974
+ protected toggleAnchors(enabled: boolean): void;
975
+ /** Executes a function when the zone is stable. */
976
+ private _executeOnStable;
1060
977
  }
1061
-
1062
- /** Injection token that can be used to configure the default options for the LiveAnnouncer. */
1063
- export declare const LIVE_ANNOUNCER_DEFAULT_OPTIONS: InjectionToken<LiveAnnouncerDefaultOptions>;
1064
-
1065
- export declare const LIVE_ANNOUNCER_ELEMENT_TOKEN: InjectionToken<HTMLElement | null>;
1066
-
1067
- /** @docs-private */
1068
- export declare function LIVE_ANNOUNCER_ELEMENT_TOKEN_FACTORY(): null;
1069
-
1070
- export declare class LiveAnnouncer implements OnDestroy {
978
+ /**
979
+ * Factory that allows easy instantiation of focus traps.
980
+ */
981
+ declare class FocusTrapFactory {
982
+ private _checker;
1071
983
  private _ngZone;
1072
- private _defaultOptions;
1073
- private _liveElement;
1074
984
  private _document;
1075
- private _previousTimeout;
1076
- private _currentPromise;
1077
- private _currentResolve;
985
+ private _injector;
1078
986
  constructor(...args: unknown[]);
1079
987
  /**
1080
- * Announces a message to screen readers.
1081
- * @param message Message to be announced to the screen reader.
1082
- * @returns Promise that will be resolved when the message is added to the DOM.
1083
- */
1084
- announce(message: string): Promise<void>;
1085
- /**
1086
- * Announces a message to screen readers.
1087
- * @param message Message to be announced to the screen reader.
1088
- * @param politeness The politeness of the announcer element.
1089
- * @returns Promise that will be resolved when the message is added to the DOM.
1090
- */
1091
- announce(message: string, politeness?: AriaLivePoliteness): Promise<void>;
1092
- /**
1093
- * Announces a message to screen readers.
1094
- * @param message Message to be announced to the screen reader.
1095
- * @param duration Time in milliseconds after which to clear out the announcer element. Note
1096
- * that this takes effect after the message has been added to the DOM, which can be up to
1097
- * 100ms after `announce` has been called.
1098
- * @returns Promise that will be resolved when the message is added to the DOM.
1099
- */
1100
- announce(message: string, duration?: number): Promise<void>;
1101
- /**
1102
- * Announces a message to screen readers.
1103
- * @param message Message to be announced to the screen reader.
1104
- * @param politeness The politeness of the announcer element.
1105
- * @param duration Time in milliseconds after which to clear out the announcer element. Note
1106
- * that this takes effect after the message has been added to the DOM, which can be up to
1107
- * 100ms after `announce` has been called.
1108
- * @returns Promise that will be resolved when the message is added to the DOM.
988
+ * Creates a focus-trapped region around the given element.
989
+ * @param element The element around which focus will be trapped.
990
+ * @param deferCaptureElements Defers the creation of focus-capturing elements to be done
991
+ * manually by the user.
992
+ * @returns The created focus trap instance.
1109
993
  */
1110
- announce(message: string, politeness?: AriaLivePoliteness, duration?: number): Promise<void>;
994
+ create(element: HTMLElement, deferCaptureElements?: boolean): FocusTrap;
995
+ static ɵfac: i0.ɵɵFactoryDeclaration<FocusTrapFactory, never>;
996
+ static ɵprov: i0.ɵɵInjectableDeclaration<FocusTrapFactory>;
997
+ }
998
+ /** Directive for trapping focus within a region. */
999
+ declare class CdkTrapFocus implements OnDestroy, AfterContentInit, OnChanges, DoCheck {
1000
+ private _elementRef;
1001
+ private _focusTrapFactory;
1002
+ /** Underlying FocusTrap instance. */
1003
+ focusTrap: FocusTrap;
1004
+ /** Previously focused element to restore focus to upon destroy when using autoCapture. */
1005
+ private _previouslyFocusedElement;
1006
+ /** Whether the focus trap is active. */
1007
+ get enabled(): boolean;
1008
+ set enabled(value: boolean);
1111
1009
  /**
1112
- * Clears the current text from the announcer element. Can be used to prevent
1113
- * screen readers from reading the text out again while the user is going
1114
- * through the page landmarks.
1010
+ * Whether the directive should automatically move focus into the trapped region upon
1011
+ * initialization and return focus to the previous activeElement upon destruction.
1115
1012
  */
1116
- clear(): void;
1013
+ autoCapture: boolean;
1014
+ constructor(...args: unknown[]);
1117
1015
  ngOnDestroy(): void;
1118
- private _createLiveElement;
1119
- /**
1120
- * Some browsers won't expose the accessibility node of the live announcer element if there is an
1121
- * `aria-modal` and the live announcer is outside of it. This method works around the issue by
1122
- * pointing the `aria-owns` of all modals to the live announcer element.
1123
- */
1124
- private _exposeAnnouncerToModals;
1125
- static ɵfac: i0.ɵɵFactoryDeclaration<LiveAnnouncer, never>;
1126
- static ɵprov: i0.ɵɵInjectableDeclaration<LiveAnnouncer>;
1016
+ ngAfterContentInit(): void;
1017
+ ngDoCheck(): void;
1018
+ ngOnChanges(changes: SimpleChanges): void;
1019
+ private _captureFocus;
1020
+ static ɵfac: i0.ɵɵFactoryDeclaration<CdkTrapFocus, never>;
1021
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CdkTrapFocus, "[cdkTrapFocus]", ["cdkTrapFocus"], { "enabled": { "alias": "cdkTrapFocus"; "required": false; }; "autoCapture": { "alias": "cdkTrapFocusAutoCapture"; "required": false; }; }, {}, never, never, true, never>;
1022
+ static ngAcceptInputType_enabled: unknown;
1023
+ static ngAcceptInputType_autoCapture: unknown;
1127
1024
  }
1128
1025
 
1129
- /** Object that can be used to configure the default options for the LiveAnnouncer. */
1130
- export declare interface LiveAnnouncerDefaultOptions {
1131
- /** Default politeness for the announcements. */
1132
- politeness?: AriaLivePoliteness;
1133
- /** Default duration for the announcement messages. */
1134
- duration?: number;
1026
+ /** The injection token used to specify the inert strategy. */
1027
+ declare const FOCUS_TRAP_INERT_STRATEGY: InjectionToken<FocusTrapInertStrategy>;
1028
+ /**
1029
+ * A strategy that dictates how FocusTrap should prevent elements
1030
+ * outside of the FocusTrap from being focused.
1031
+ */
1032
+ interface FocusTrapInertStrategy {
1033
+ /** Makes all elements outside focusTrap unfocusable. */
1034
+ preventFocus(focusTrap: FocusTrap): void;
1035
+ /** Reverts elements made unfocusable by preventFocus to their previous state. */
1036
+ allowFocus(focusTrap: FocusTrap): void;
1135
1037
  }
1136
1038
 
1137
1039
  /**
1138
1040
  * A FocusTrap managed by FocusTrapManager.
1139
1041
  * Implemented by ConfigurableFocusTrap to avoid circular dependency.
1140
1042
  */
1141
- declare interface ManagedFocusTrap {
1043
+ interface ManagedFocusTrap {
1142
1044
  _enable(): void;
1143
1045
  _disable(): void;
1144
1046
  focusInitialElementWhenReady(): Promise<boolean>;
1145
1047
  }
1048
+ /** Injectable that ensures only the most recently enabled FocusTrap is active. */
1049
+ declare class FocusTrapManager {
1050
+ private _focusTrapStack;
1051
+ /**
1052
+ * Disables the FocusTrap at the top of the stack, and then pushes
1053
+ * the new FocusTrap onto the stack.
1054
+ */
1055
+ register(focusTrap: ManagedFocusTrap): void;
1056
+ /**
1057
+ * Removes the FocusTrap from the stack, and activates the
1058
+ * FocusTrap that is the new top of the stack.
1059
+ */
1060
+ deregister(focusTrap: ManagedFocusTrap): void;
1061
+ static ɵfac: i0.ɵɵFactoryDeclaration<FocusTrapManager, never>;
1062
+ static ɵprov: i0.ɵɵInjectableDeclaration<FocusTrapManager>;
1063
+ }
1146
1064
 
1147
1065
  /**
1148
- * ID used for the body container where all messages are appended.
1149
- * @deprecated No longer being used. To be removed.
1150
- * @breaking-change 14.0.0
1151
- */
1152
- export declare const MESSAGES_CONTAINER_ID = "cdk-describedby-message-container";
1153
-
1154
- /**
1155
- * @docs-private
1156
- *
1157
- * Opt-out of Tree of key manager behavior.
1158
- *
1159
- * When provided, Tree has same focus management behavior as before TreeKeyManager was introduced.
1160
- * - Tree does not respond to keyboard interaction
1161
- * - Tree node allows tabindex to be set by Input binding
1162
- * - Tree node allows tabindex to be set by attribute binding
1163
- *
1164
- * @deprecated NoopTreeKeyManager deprecated. Use TreeKeyManager or inject a
1165
- * TreeKeyManagerStrategy instead. To be removed in a future version.
1066
+ * Class that allows for trapping focus within a DOM element.
1166
1067
  *
1167
- * @breaking-change 21.0.0
1068
+ * This class uses a strategy pattern that determines how it traps focus.
1069
+ * See FocusTrapInertStrategy.
1168
1070
  */
1169
- export declare function NOOP_TREE_KEY_MANAGER_FACTORY<T extends TreeKeyManagerItem>(): TreeKeyManagerFactory<T>;
1071
+ declare class ConfigurableFocusTrap extends FocusTrap implements ManagedFocusTrap {
1072
+ private _focusTrapManager;
1073
+ private _inertStrategy;
1074
+ /** Whether the FocusTrap is enabled. */
1075
+ get enabled(): boolean;
1076
+ set enabled(value: boolean);
1077
+ constructor(_element: HTMLElement, _checker: InteractivityChecker, _ngZone: NgZone, _document: Document, _focusTrapManager: FocusTrapManager, _inertStrategy: FocusTrapInertStrategy, config: ConfigurableFocusTrapConfig, injector?: Injector);
1078
+ /** Notifies the FocusTrapManager that this FocusTrap will be destroyed. */
1079
+ destroy(): void;
1080
+ /** @docs-private Implemented as part of ManagedFocusTrap. */
1081
+ _enable(): void;
1082
+ /** @docs-private Implemented as part of ManagedFocusTrap. */
1083
+ _disable(): void;
1084
+ }
1170
1085
 
1171
- /**
1172
- * @docs-private
1173
- *
1174
- * Opt-out of Tree of key manager behavior.
1175
- *
1176
- * When provided, Tree has same focus management behavior as before TreeKeyManager was introduced.
1177
- * - Tree does not respond to keyboard interaction
1178
- * - Tree node allows tabindex to be set by Input binding
1179
- * - Tree node allows tabindex to be set by attribute binding
1180
- *
1181
- * @deprecated NoopTreeKeyManager deprecated. Use TreeKeyManager or inject a
1182
- * TreeKeyManagerStrategy instead. To be removed in a future version.
1183
- *
1184
- * @breaking-change 21.0.0
1185
- */
1186
- export declare const NOOP_TREE_KEY_MANAGER_FACTORY_PROVIDER: Provider;
1086
+ /** Factory that allows easy instantiation of configurable focus traps. */
1087
+ declare class ConfigurableFocusTrapFactory {
1088
+ private _checker;
1089
+ private _ngZone;
1090
+ private _focusTrapManager;
1091
+ private _document;
1092
+ private _inertStrategy;
1093
+ private readonly _injector;
1094
+ constructor(...args: unknown[]);
1095
+ /**
1096
+ * Creates a focus-trapped region around the given element.
1097
+ * @param element The element around which focus will be trapped.
1098
+ * @param config The focus trap configuration.
1099
+ * @returns The created focus trap instance.
1100
+ */
1101
+ create(element: HTMLElement, config?: ConfigurableFocusTrapConfig): ConfigurableFocusTrap;
1102
+ /**
1103
+ * @deprecated Pass a config object instead of the `deferCaptureElements` flag.
1104
+ * @breaking-change 11.0.0
1105
+ */
1106
+ create(element: HTMLElement, deferCaptureElements: boolean): ConfigurableFocusTrap;
1107
+ static ɵfac: i0.ɵɵFactoryDeclaration<ConfigurableFocusTrapFactory, never>;
1108
+ static ɵprov: i0.ɵɵInjectableDeclaration<ConfigurableFocusTrapFactory>;
1109
+ }
1187
1110
 
1188
1111
  /**
1189
- * @docs-private
1190
- *
1191
- * Opt-out of Tree of key manager behavior.
1192
- *
1193
- * When provided, Tree has same focus management behavior as before TreeKeyManager was introduced.
1194
- * - Tree does not respond to keyboard interaction
1195
- * - Tree node allows tabindex to be set by Input binding
1196
- * - Tree node allows tabindex to be set by attribute binding
1197
- *
1198
- * @deprecated NoopTreeKeyManager deprecated. Use TreeKeyManager or inject a
1199
- * TreeKeyManagerStrategy instead. To be removed in a future version.
1200
- *
1201
- * @breaking-change 21.0.0
1112
+ * Lightweight FocusTrapInertStrategy that adds a document focus event
1113
+ * listener to redirect focus back inside the FocusTrap.
1202
1114
  */
1203
- export declare class NoopTreeKeyManager<T extends TreeKeyManagerItem> implements TreeKeyManagerStrategy<T> {
1204
- readonly _isNoopTreeKeyManager = true;
1205
- readonly change: Subject<T | null>;
1206
- destroy(): void;
1207
- onKeydown(): void;
1208
- getActiveItemIndex(): null;
1209
- getActiveItem(): null;
1210
- focusItem(): void;
1115
+ declare class EventListenerFocusTrapInertStrategy implements FocusTrapInertStrategy {
1116
+ /** Focus event handler. */
1117
+ private _listener;
1118
+ /** Adds a document event listener that keeps focus inside the FocusTrap. */
1119
+ preventFocus(focusTrap: ConfigurableFocusTrap): void;
1120
+ /** Removes the event listener added in preventFocus. */
1121
+ allowFocus(focusTrap: ConfigurableFocusTrap): void;
1122
+ /**
1123
+ * Refocuses the first element in the FocusTrap if the focus event target was outside
1124
+ * the FocusTrap.
1125
+ *
1126
+ * This is an event listener callback. The event listener is added in runOutsideAngular,
1127
+ * so all this code runs outside Angular as well.
1128
+ */
1129
+ private _trapFocus;
1211
1130
  }
1212
1131
 
1213
1132
  /**
1214
- * Interface used to register message elements and keep a count of how many registrations have
1215
- * the same message and the reference to the message element used for the `aria-describedby`.
1133
+ * The input modalities detected by this service. Null is used if the input modality is unknown.
1216
1134
  */
1217
- export declare interface RegisteredMessage {
1218
- /** The element containing the message. */
1219
- messageElement: Element;
1220
- /** The number of elements that reference this message element via `aria-describedby`. */
1221
- referenceCount: number;
1135
+ type InputModality = 'keyboard' | 'mouse' | 'touch' | null;
1136
+ /** Options to configure the behavior of the InputModalityDetector. */
1137
+ interface InputModalityDetectorOptions {
1138
+ /** Keys to ignore when detecting keyboard input modality. */
1139
+ ignoreKeys?: number[];
1222
1140
  }
1223
-
1224
1141
  /**
1225
- * Removes the given ID from the specified ARIA attribute on an element.
1226
- * Used for attributes such as aria-labelledby, aria-owns, etc.
1142
+ * Injectable options for the InputModalityDetector. These are shallowly merged with the default
1143
+ * options.
1227
1144
  */
1228
- export declare function removeAriaReferencedId(el: Element, attr: `aria-${string}`, id: string): void;
1229
-
1230
- /** Injection token that determines the key manager to use. */
1231
- export declare const TREE_KEY_MANAGER: InjectionToken<TreeKeyManagerFactory<any>>;
1232
-
1233
- /** @docs-private */
1234
- export declare function TREE_KEY_MANAGER_FACTORY<T extends TreeKeyManagerItem>(): TreeKeyManagerFactory<T>;
1235
-
1236
- /** @docs-private */
1237
- export declare const TREE_KEY_MANAGER_FACTORY_PROVIDER: {
1238
- provide: InjectionToken<TreeKeyManagerFactory<any>>;
1239
- useFactory: typeof TREE_KEY_MANAGER_FACTORY;
1240
- };
1241
-
1145
+ declare const INPUT_MODALITY_DETECTOR_OPTIONS: InjectionToken<InputModalityDetectorOptions>;
1242
1146
  /**
1243
- * This class manages keyboard events for trees. If you pass it a QueryList or other list of tree
1244
- * items, it will set the active item, focus, handle expansion and typeahead correctly when
1245
- * keyboard events occur.
1147
+ * Default options for the InputModalityDetector.
1148
+ *
1149
+ * Modifier keys are ignored by default (i.e. when pressed won't cause the service to detect
1150
+ * keyboard input modality) for two reasons:
1151
+ *
1152
+ * 1. Modifier keys are commonly used with mouse to perform actions such as 'right click' or 'open
1153
+ * in new tab', and are thus less representative of actual keyboard interaction.
1154
+ * 2. VoiceOver triggers some keyboard events when linearly navigating with Control + Option (but
1155
+ * confusingly not with Caps Lock). Thus, to have parity with other screen readers, we ignore
1156
+ * these keys so as to not update the input modality.
1157
+ *
1158
+ * Note that we do not by default ignore the right Meta key on Safari because it has the same key
1159
+ * code as the ContextMenu key on other browsers. When we switch to using event.key, we can
1160
+ * distinguish between the two.
1246
1161
  */
1247
- export declare class TreeKeyManager<T extends TreeKeyManagerItem> implements TreeKeyManagerStrategy<T> {
1248
- /** The index of the currently active (focused) item. */
1249
- private _activeItemIndex;
1250
- /** The currently active (focused) item. */
1251
- private _activeItem;
1252
- /** Whether or not we activate the item when it's focused. */
1253
- private _shouldActivationFollowFocus;
1254
- /**
1255
- * The orientation that the tree is laid out in. In `rtl` mode, the behavior of Left and
1256
- * Right arrow are switched.
1257
- */
1258
- private _horizontalOrientation;
1259
- /**
1260
- * Predicate function that can be used to check whether an item should be skipped
1261
- * by the key manager.
1262
- *
1263
- * The default value for this doesn't skip any elements in order to keep tree items focusable
1264
- * when disabled. This aligns with ARIA guidelines:
1265
- * https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#focusabilityofdisabledcontrols.
1266
- */
1267
- private _skipPredicateFn;
1268
- /** Function to determine equivalent items. */
1269
- private _trackByFn;
1270
- /** Synchronous cache of the items to manage. */
1271
- private _items;
1272
- private _typeahead?;
1273
- private _typeaheadSubscription;
1274
- private _hasInitialFocused;
1275
- private _initializeFocus;
1162
+ declare const INPUT_MODALITY_DETECTOR_DEFAULT_OPTIONS: InputModalityDetectorOptions;
1163
+ /**
1164
+ * Service that detects the user's input modality.
1165
+ *
1166
+ * This service does not update the input modality when a user navigates with a screen reader
1167
+ * (e.g. linear navigation with VoiceOver, object navigation / browse mode with NVDA, virtual PC
1168
+ * cursor mode with JAWS). This is in part due to technical limitations (i.e. keyboard events do not
1169
+ * fire as expected in these modes) but is also arguably the correct behavior. Navigating with a
1170
+ * screen reader is akin to visually scanning a page, and should not be interpreted as actual user
1171
+ * input interaction.
1172
+ *
1173
+ * When a user is not navigating but *interacting* with a screen reader, this service attempts to
1174
+ * update the input modality to keyboard, but in general this service's behavior is largely
1175
+ * undefined.
1176
+ */
1177
+ declare class InputModalityDetector implements OnDestroy {
1178
+ private readonly _platform;
1179
+ private readonly _listenerCleanups;
1180
+ /** Emits whenever an input modality is detected. */
1181
+ readonly modalityDetected: Observable<InputModality>;
1182
+ /** Emits when the input modality changes. */
1183
+ readonly modalityChanged: Observable<InputModality>;
1184
+ /** The most recently detected input modality. */
1185
+ get mostRecentModality(): InputModality;
1276
1186
  /**
1277
- *
1278
- * @param items List of TreeKeyManager options. Can be synchronous or asynchronous.
1279
- * @param config Optional configuration options. By default, use 'ltr' horizontal orientation. By
1280
- * default, do not skip any nodes. By default, key manager only calls `focus` method when items
1281
- * are focused and does not call `activate`. If `typeaheadDefaultInterval` is `true`, use a
1282
- * default interval of 200ms.
1187
+ * The most recently detected input modality event target. Is null if no input modality has been
1188
+ * detected or if the associated event target is null for some unknown reason.
1283
1189
  */
1284
- constructor(items: Observable<T[]> | QueryList<T> | T[], config: TreeKeyManagerOptions<T>);
1285
- /** Stream that emits any time the focused item changes. */
1286
- readonly change: Subject<T | null>;
1287
- /** Cleans up the key manager. */
1288
- destroy(): void;
1190
+ _mostRecentTarget: HTMLElement | null;
1191
+ /** The underlying BehaviorSubject that emits whenever an input modality is detected. */
1192
+ private readonly _modality;
1193
+ /** Options for this InputModalityDetector. */
1194
+ private readonly _options;
1289
1195
  /**
1290
- * Handles a keyboard event on the tree.
1291
- * @param event Keyboard event that represents the user interaction with the tree.
1196
+ * The timestamp of the last touch input modality. Used to determine whether mousedown events
1197
+ * should be attributed to mouse or touch.
1292
1198
  */
1293
- onKeydown(event: KeyboardEvent): void;
1294
- /** Index of the currently active item. */
1295
- getActiveItemIndex(): number | null;
1296
- /** The currently active item. */
1297
- getActiveItem(): T | null;
1298
- /** Focus the first available item. */
1299
- private _focusFirstItem;
1300
- /** Focus the last available item. */
1301
- private _focusLastItem;
1302
- /** Focus the next available item. */
1303
- private _focusNextItem;
1304
- /** Focus the previous available item. */
1305
- private _focusPreviousItem;
1199
+ private _lastTouchMs;
1306
1200
  /**
1307
- * Focus the provided item by index.
1308
- * @param index The index of the item to focus.
1309
- * @param options Additional focusing options.
1201
+ * Handles keydown events. Must be an arrow function in order to preserve the context when it gets
1202
+ * bound.
1310
1203
  */
1311
- focusItem(index: number, options?: {
1312
- emitChangeEvent?: boolean;
1313
- }): void;
1314
- focusItem(item: T, options?: {
1315
- emitChangeEvent?: boolean;
1316
- }): void;
1317
- focusItem(itemOrIndex: number | T, options?: {
1318
- emitChangeEvent?: boolean;
1319
- }): void;
1320
- private _updateActiveItemIndex;
1321
- private _setTypeAhead;
1322
- private _findNextAvailableItemIndex;
1323
- private _findPreviousAvailableItemIndex;
1204
+ private _onKeydown;
1324
1205
  /**
1325
- * If the item is already expanded, we collapse the item. Otherwise, we will focus the parent.
1206
+ * Handles mousedown events. Must be an arrow function in order to preserve the context when it
1207
+ * gets bound.
1326
1208
  */
1327
- private _collapseCurrentItem;
1209
+ private _onMousedown;
1328
1210
  /**
1329
- * If the item is already collapsed, we expand the item. Otherwise, we will focus the first child.
1211
+ * Handles touchstart events. Must be an arrow function in order to preserve the context when it
1212
+ * gets bound.
1330
1213
  */
1331
- private _expandCurrentItem;
1332
- private _isCurrentItemExpanded;
1333
- private _isItemDisabled;
1334
- /** For all items that are the same level as the current item, we expand those items. */
1335
- private _expandAllItemsAtCurrentItemLevel;
1336
- private _activateCurrentItem;
1214
+ private _onTouchstart;
1215
+ constructor(...args: unknown[]);
1216
+ ngOnDestroy(): void;
1217
+ static ɵfac: i0.ɵɵFactoryDeclaration<InputModalityDetector, never>;
1218
+ static ɵprov: i0.ɵɵInjectableDeclaration<InputModalityDetector>;
1337
1219
  }
1338
1220
 
1339
- export declare type TreeKeyManagerFactory<T extends TreeKeyManagerItem> = (items: Observable<T[]> | QueryList<T> | T[], options: TreeKeyManagerOptions<T>) => TreeKeyManagerStrategy<T>;
1221
+ /** Possible politeness levels. */
1222
+ type AriaLivePoliteness = 'off' | 'polite' | 'assertive';
1223
+ declare const LIVE_ANNOUNCER_ELEMENT_TOKEN: InjectionToken<HTMLElement | null>;
1224
+ /**
1225
+ * @docs-private
1226
+ * @deprecated No longer used, will be removed.
1227
+ * @breaking-change 21.0.0
1228
+ */
1229
+ declare function LIVE_ANNOUNCER_ELEMENT_TOKEN_FACTORY(): null;
1230
+ /** Object that can be used to configure the default options for the LiveAnnouncer. */
1231
+ interface LiveAnnouncerDefaultOptions {
1232
+ /** Default politeness for the announcements. */
1233
+ politeness?: AriaLivePoliteness;
1234
+ /** Default duration for the announcement messages. */
1235
+ duration?: number;
1236
+ }
1237
+ /** Injection token that can be used to configure the default options for the LiveAnnouncer. */
1238
+ declare const LIVE_ANNOUNCER_DEFAULT_OPTIONS: InjectionToken<LiveAnnouncerDefaultOptions>;
1340
1239
 
1341
- /** Represents an item within a tree that can be passed to a TreeKeyManager. */
1342
- export declare interface TreeKeyManagerItem {
1343
- /** Whether the item is disabled. */
1344
- isDisabled?: (() => boolean) | boolean;
1345
- /** The user-facing label for this item. */
1346
- getLabel?(): string;
1347
- /** Perform the main action (i.e. selection) for this item. */
1348
- activate(): void;
1349
- /** Retrieves the parent for this item. This is `null` if there is no parent. */
1350
- getParent(): TreeKeyManagerItem | null;
1351
- /** Retrieves the children for this item. */
1352
- getChildren(): TreeKeyManagerItem[] | Observable<TreeKeyManagerItem[]>;
1353
- /** Determines if the item is currently expanded. */
1354
- isExpanded: (() => boolean) | boolean;
1355
- /** Collapses the item, hiding its children. */
1356
- collapse(): void;
1357
- /** Expands the item, showing its children. */
1358
- expand(): void;
1359
- /**
1360
- * Focuses the item. This should provide some indication to the user that this item is focused.
1361
- */
1362
- focus(): void;
1363
- /**
1364
- * Unfocus the item. This should remove the focus state.
1365
- */
1366
- unfocus(): void;
1240
+ declare class LiveAnnouncer implements OnDestroy {
1241
+ private _ngZone;
1242
+ private _defaultOptions;
1243
+ private _liveElement;
1244
+ private _document;
1245
+ private _previousTimeout;
1246
+ private _currentPromise;
1247
+ private _currentResolve;
1248
+ constructor(...args: unknown[]);
1367
1249
  /**
1368
- * Sets the item to be focusable without actually focusing it.
1250
+ * Announces a message to screen readers.
1251
+ * @param message Message to be announced to the screen reader.
1252
+ * @returns Promise that will be resolved when the message is added to the DOM.
1369
1253
  */
1370
- makeFocusable?(): void;
1371
- }
1372
-
1373
- /**
1374
- * Configuration for the TreeKeyManager.
1375
- */
1376
- export declare interface TreeKeyManagerOptions<T extends TreeKeyManagerItem> {
1254
+ announce(message: string): Promise<void>;
1377
1255
  /**
1378
- * If true, then the key manager will call `activate` in addition to calling `focus` when a
1379
- * particular item is focused.
1256
+ * Announces a message to screen readers.
1257
+ * @param message Message to be announced to the screen reader.
1258
+ * @param politeness The politeness of the announcer element.
1259
+ * @returns Promise that will be resolved when the message is added to the DOM.
1380
1260
  */
1381
- shouldActivationFollowFocus?: boolean;
1261
+ announce(message: string, politeness?: AriaLivePoliteness): Promise<void>;
1382
1262
  /**
1383
- * The direction in which the tree items are laid out horizontally. This influences which key
1384
- * will be interpreted as expand or collapse.
1263
+ * Announces a message to screen readers.
1264
+ * @param message Message to be announced to the screen reader.
1265
+ * @param duration Time in milliseconds after which to clear out the announcer element. Note
1266
+ * that this takes effect after the message has been added to the DOM, which can be up to
1267
+ * 100ms after `announce` has been called.
1268
+ * @returns Promise that will be resolved when the message is added to the DOM.
1385
1269
  */
1386
- horizontalOrientation?: 'rtl' | 'ltr';
1270
+ announce(message: string, duration?: number): Promise<void>;
1387
1271
  /**
1388
- * If provided, navigation "skips" over items that pass the given predicate.
1389
- *
1390
- * If the item is to be skipped, predicate function should return false.
1272
+ * Announces a message to screen readers.
1273
+ * @param message Message to be announced to the screen reader.
1274
+ * @param politeness The politeness of the announcer element.
1275
+ * @param duration Time in milliseconds after which to clear out the announcer element. Note
1276
+ * that this takes effect after the message has been added to the DOM, which can be up to
1277
+ * 100ms after `announce` has been called.
1278
+ * @returns Promise that will be resolved when the message is added to the DOM.
1391
1279
  */
1392
- skipPredicate?: (item: T) => boolean;
1280
+ announce(message: string, politeness?: AriaLivePoliteness, duration?: number): Promise<void>;
1393
1281
  /**
1394
- * If provided, determines how the key manager determines if two items are equivalent.
1395
- *
1396
- * It should provide a unique key for each unique tree item. If two tree items are equivalent,
1397
- * then this function should return the same value.
1282
+ * Clears the current text from the announcer element. Can be used to prevent
1283
+ * screen readers from reading the text out again while the user is going
1284
+ * through the page landmarks.
1398
1285
  */
1399
- trackBy?: (treeItem: T) => unknown;
1286
+ clear(): void;
1287
+ ngOnDestroy(): void;
1288
+ private _createLiveElement;
1400
1289
  /**
1401
- * If a value is provided, enables typeahead mode, which allows users to set the active item
1402
- * by typing the visible label of the item.
1403
- *
1404
- * If a number is provided, this will be the time to wait after the last keystroke before
1405
- * setting the active item. If `true` is provided, the default interval of 200ms will be used.
1290
+ * Some browsers won't expose the accessibility node of the live announcer element if there is an
1291
+ * `aria-modal` and the live announcer is outside of it. This method works around the issue by
1292
+ * pointing the `aria-owns` of all modals to the live announcer element.
1406
1293
  */
1407
- typeAheadDebounceInterval?: true | number;
1294
+ private _exposeAnnouncerToModals;
1295
+ static ɵfac: i0.ɵɵFactoryDeclaration<LiveAnnouncer, never>;
1296
+ static ɵprov: i0.ɵɵInjectableDeclaration<LiveAnnouncer>;
1297
+ }
1298
+ /**
1299
+ * A directive that works similarly to aria-live, but uses the LiveAnnouncer to ensure compatibility
1300
+ * with a wider range of browsers and screen readers.
1301
+ */
1302
+ declare class CdkAriaLive implements OnDestroy {
1303
+ private _elementRef;
1304
+ private _liveAnnouncer;
1305
+ private _contentObserver;
1306
+ private _ngZone;
1307
+ /** The aria-live politeness level to use when announcing messages. */
1308
+ get politeness(): AriaLivePoliteness;
1309
+ set politeness(value: AriaLivePoliteness);
1310
+ private _politeness;
1311
+ /** Time in milliseconds after which to clear out the announcer element. */
1312
+ duration: number;
1313
+ private _previousAnnouncedText?;
1314
+ private _subscription;
1315
+ constructor(...args: unknown[]);
1316
+ ngOnDestroy(): void;
1317
+ static ɵfac: i0.ɵɵFactoryDeclaration<CdkAriaLive, never>;
1318
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CdkAriaLive, "[cdkAriaLive]", ["cdkAriaLive"], { "politeness": { "alias": "cdkAriaLive"; "required": false; }; "duration": { "alias": "cdkAriaLiveDuration"; "required": false; }; }, {}, never, never, true, never>;
1408
1319
  }
1409
1320
 
1410
- export declare interface TreeKeyManagerStrategy<T extends TreeKeyManagerItem> {
1411
- /** Stream that emits any time the focused item changes. */
1412
- readonly change: Subject<T | null>;
1413
- /**
1414
- * Cleans up the key manager.
1415
- */
1416
- destroy(): void;
1417
- /**
1418
- * Handles a keyboard event on the tree.
1419
- *
1420
- * @param event Keyboard event that represents the user interaction with the tree.
1421
- */
1422
- onKeydown(event: KeyboardEvent): void;
1423
- /** Index of the currently active item. */
1424
- getActiveItemIndex(): number | null;
1425
- /** The currently active item. */
1426
- getActiveItem(): T | null;
1321
+ /** Gets whether an event could be a faked `mousedown` event dispatched by a screen reader. */
1322
+ declare function isFakeMousedownFromScreenReader(event: MouseEvent): boolean;
1323
+ /** Gets whether an event could be a faked `touchstart` event dispatched by a screen reader. */
1324
+ declare function isFakeTouchstartFromScreenReader(event: TouchEvent): boolean;
1325
+
1326
+ declare class A11yModule {
1327
+ constructor();
1328
+ static ɵfac: i0.ɵɵFactoryDeclaration<A11yModule, never>;
1329
+ static ɵmod: i0.ɵɵNgModuleDeclaration<A11yModule, never, [typeof i1.ObserversModule, typeof CdkAriaLive, typeof CdkTrapFocus, typeof CdkMonitorFocus], [typeof CdkAriaLive, typeof CdkTrapFocus, typeof CdkMonitorFocus]>;
1330
+ static ɵinj: i0.ɵɵInjectorDeclaration<A11yModule>;
1331
+ }
1332
+
1333
+ /** Set of possible high-contrast mode backgrounds. */
1334
+ declare enum HighContrastMode {
1335
+ NONE = 0,
1336
+ BLACK_ON_WHITE = 1,
1337
+ WHITE_ON_BLACK = 2
1338
+ }
1339
+ /**
1340
+ * Service to determine whether the browser is currently in a high-contrast-mode environment.
1341
+ *
1342
+ * Microsoft Windows supports an accessibility feature called "High Contrast Mode". This mode
1343
+ * changes the appearance of all applications, including web applications, to dramatically increase
1344
+ * contrast.
1345
+ *
1346
+ * IE, Edge, and Firefox currently support this mode. Chrome does not support Windows High Contrast
1347
+ * Mode. This service does not detect high-contrast mode as added by the Chrome "High Contrast"
1348
+ * browser extension.
1349
+ */
1350
+ declare class HighContrastModeDetector implements OnDestroy {
1351
+ private _platform;
1427
1352
  /**
1428
- * Focus the provided item by index.
1429
- *
1430
- * Updates the state of the currently active item. Emits to `change` stream if active item
1431
- * Changes.
1432
- * @param index The index of the item to focus.
1433
- * @param options Additional focusing options.
1353
+ * Figuring out the high contrast mode and adding the body classes can cause
1354
+ * some expensive layouts. This flag is used to ensure that we only do it once.
1434
1355
  */
1435
- focusItem(index: number, options?: {
1436
- emitChangeEvent?: boolean;
1437
- }): void;
1356
+ private _hasCheckedHighContrastMode;
1357
+ private _document;
1358
+ private _breakpointSubscription;
1359
+ constructor(...args: unknown[]);
1360
+ /** Gets the current high-contrast-mode for the page. */
1361
+ getHighContrastMode(): HighContrastMode;
1362
+ ngOnDestroy(): void;
1363
+ /** Applies CSS classes indicating high-contrast mode to document body (browser-only). */
1364
+ _applyBodyHighContrastModeCssClasses(): void;
1365
+ static ɵfac: i0.ɵɵFactoryDeclaration<HighContrastModeDetector, never>;
1366
+ static ɵprov: i0.ɵɵInjectableDeclaration<HighContrastModeDetector>;
1367
+ }
1368
+
1369
+ /** Service that generates unique IDs for DOM nodes. */
1370
+ declare class _IdGenerator {
1371
+ private _appId;
1438
1372
  /**
1439
- * Focus the provided item.
1440
- *
1441
- * Updates the state of the currently active item. Emits to `change` stream if active item
1442
- * Changes.
1443
- * @param item The item to focus. Equality is determined via the trackBy function.
1444
- * @param options Additional focusing options.
1373
+ * Generates a unique ID with a specific prefix.
1374
+ * @param prefix Prefix to add to the ID.
1445
1375
  */
1446
- focusItem(item: T, options?: {
1447
- emitChangeEvent?: boolean;
1448
- }): void;
1449
- focusItem(itemOrIndex: number | T, options?: {
1450
- emitChangeEvent?: boolean;
1451
- }): void;
1376
+ getId(prefix: string): string;
1377
+ static ɵfac: i0.ɵɵFactoryDeclaration<_IdGenerator, never>;
1378
+ static ɵprov: i0.ɵɵInjectableDeclaration<_IdGenerator>;
1452
1379
  }
1453
1380
 
1454
- export { }
1381
+ export { A11yModule, ActiveDescendantKeyManager, AriaDescriber, type AriaLivePoliteness, CDK_DESCRIBEDBY_HOST_ATTRIBUTE, CDK_DESCRIBEDBY_ID_PREFIX, CdkAriaLive, CdkMonitorFocus, CdkTrapFocus, ConfigurableFocusTrap, type ConfigurableFocusTrapConfig, ConfigurableFocusTrapFactory, EventListenerFocusTrapInertStrategy, FOCUS_MONITOR_DEFAULT_OPTIONS, FOCUS_TRAP_INERT_STRATEGY, FocusKeyManager, FocusMonitor, FocusMonitorDetectionMode, type FocusMonitorOptions, type FocusOptions$1 as FocusOptions, type FocusOrigin, FocusTrap, FocusTrapFactory, type FocusTrapInertStrategy, type FocusableOption, HighContrastMode, HighContrastModeDetector, type Highlightable, INPUT_MODALITY_DETECTOR_DEFAULT_OPTIONS, INPUT_MODALITY_DETECTOR_OPTIONS, type InputModality, InputModalityDetector, type InputModalityDetectorOptions, InteractivityChecker, IsFocusableConfig, LIVE_ANNOUNCER_DEFAULT_OPTIONS, LIVE_ANNOUNCER_ELEMENT_TOKEN, LIVE_ANNOUNCER_ELEMENT_TOKEN_FACTORY, ListKeyManager, type ListKeyManagerModifierKey, type ListKeyManagerOption, LiveAnnouncer, type LiveAnnouncerDefaultOptions, MESSAGES_CONTAINER_ID, NOOP_TREE_KEY_MANAGER_FACTORY, NOOP_TREE_KEY_MANAGER_FACTORY_PROVIDER, NoopTreeKeyManager, type RegisteredMessage, TREE_KEY_MANAGER, TREE_KEY_MANAGER_FACTORY, TREE_KEY_MANAGER_FACTORY_PROVIDER, TreeKeyManager, type TreeKeyManagerFactory, type TreeKeyManagerItem, type TreeKeyManagerOptions, type TreeKeyManagerStrategy, _IdGenerator, addAriaReferencedId, getAriaReferenceIds, isFakeMousedownFromScreenReader, isFakeTouchstartFromScreenReader, removeAriaReferencedId };