1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | import { BooleanInput } from './boolean-property';
|
9 | import { AfterContentInit, ElementRef, NgZone, OnDestroy, DoCheck, SimpleChanges, OnChanges } from '@angular/core';
|
10 | import { InteractivityChecker } from './interactivity-checker';
|
11 | import * as i0 from "@angular/core";
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | export declare class FocusTrap {
|
23 | readonly _element: HTMLElement;
|
24 | private _checker;
|
25 | readonly _ngZone: NgZone;
|
26 | readonly _document: Document;
|
27 | private _startAnchor?;
|
28 | private _endAnchor?;
|
29 | private _hasAttached;
|
30 | protected startAnchorListener: () => boolean;
|
31 | protected endAnchorListener: () => boolean;
|
32 |
|
33 | get enabled(): boolean;
|
34 | set enabled(value: boolean);
|
35 | protected _enabled: boolean;
|
36 | constructor(_element: HTMLElement, _checker: InteractivityChecker, _ngZone: NgZone, _document: Document, deferAnchors?: boolean);
|
37 | /** Destroys the focus trap by cleaning up the anchors. */
|
38 | destroy(): void;
|
39 | /**
|
40 | * Inserts the anchors into the DOM. This is usually done automatically
|
41 | * in the constructor, but can be deferred for cases like directives with `*ngIf`.
|
42 | * @returns Whether the focus trap managed to attach successfuly. This may not be the case
|
43 | * if the target element isn't currently in the DOM.
|
44 | */
|
45 | attachAnchors(): boolean;
|
46 | /**
|
47 | * Waits for the zone to stabilize, then either focuses the first element that the
|
48 | * user specified, or the first tabbable element.
|
49 | * @returns Returns a promise that resolves with a boolean, depending
|
50 | * on whether focus was moved successfully.
|
51 | */
|
52 | focusInitialElementWhenReady(): Promise<boolean>;
|
53 | /**
|
54 | * Waits for the zone to stabilize, then focuses
|
55 | * the first tabbable element within the focus trap region.
|
56 | * @returns Returns a promise that resolves with a boolean, depending
|
57 | * on whether focus was moved successfully.
|
58 | */
|
59 | focusFirstTabbableElementWhenReady(): Promise<boolean>;
|
60 | /**
|
61 | * Waits for the zone to stabilize, then focuses
|
62 | * the last tabbable element within the focus trap region.
|
63 | * @returns Returns a promise that resolves with a boolean, depending
|
64 | * on whether focus was moved successfully.
|
65 | */
|
66 | focusLastTabbableElementWhenReady(): Promise<boolean>;
|
67 | /**
|
68 | * Get the specified boundary element of the trapped region.
|
69 | * @param bound The boundary to get (start or end of trapped region).
|
70 | * @returns The boundary element.
|
71 | */
|
72 | private _getRegionBoundary;
|
73 | /**
|
74 | * Focuses the element that should be focused when the focus trap is initialized.
|
75 | * @returns Whether focus was moved successfully.
|
76 | */
|
77 | focusInitialElement(): boolean;
|
78 | /**
|
79 | * Focuses the first tabbable element within the focus trap region.
|
80 | * @returns Whether focus was moved successfully.
|
81 | */
|
82 | focusFirstTabbableElement(): boolean;
|
83 | /**
|
84 | * Focuses the last tabbable element within the focus trap region.
|
85 | * @returns Whether focus was moved successfully.
|
86 | */
|
87 | focusLastTabbableElement(): boolean;
|
88 | /**
|
89 | * Checks whether the focus trap has successfully been attached.
|
90 | */
|
91 | hasAttached(): boolean;
|
92 | /** Get the first tabbable element from a DOM subtree (inclusive). */
|
93 | private _getFirstTabbableElement;
|
94 | /** Get the last tabbable element from a DOM subtree (inclusive). */
|
95 | private _getLastTabbableElement;
|
96 | /** Creates an anchor element. */
|
97 | private _createAnchor;
|
98 | /**
|
99 | * Toggles the `tabindex` of an anchor, based on the enabled state of the focus trap.
|
100 | * @param isEnabled Whether the focus trap is enabled.
|
101 | * @param anchor Anchor on which to toggle the tabindex.
|
102 | */
|
103 | private _toggleAnchorTabIndex;
|
104 | /**
|
105 | * Toggles the`tabindex` of both anchors to either trap Tab focus or allow it to escape.
|
106 | * @param enabled: Whether the anchors should trap Tab.
|
107 | */
|
108 | protected toggleAnchors(enabled: boolean): void;
|
109 | /** Executes a function when the zone is stable. */
|
110 | private _executeOnStable;
|
111 | }
|
112 | /**
|
113 | * Factory that allows easy instantiation of focus traps.
|
114 | * @deprecated Use `ConfigurableFocusTrapFactory` instead.
|
115 | * @breaking-change for 11.0.0 Remove this class.
|
116 | */
|
117 | export declare class FocusTrapFactory {
|
118 | private _checker;
|
119 | private _ngZone;
|
120 | private _document;
|
121 | constructor(_checker: InteractivityChecker, _ngZone: NgZone, _document: any);
|
122 | /**
|
123 | * Creates a focus-trapped region around the given element.
|
124 | * @param element The element around which focus will be trapped.
|
125 | * @param deferCaptureElements Defers the creation of focus-capturing elements to be done
|
126 | * manually by the user.
|
127 | * @returns The created focus trap instance.
|
128 | */
|
129 | create(element: HTMLElement, deferCaptureElements?: boolean): FocusTrap;
|
130 | static ɵfac: i0.ɵɵFactoryDeclaration<FocusTrapFactory, never>;
|
131 | static ɵprov: i0.ɵɵInjectableDeclaration<FocusTrapFactory>;
|
132 | }
|
133 | /** Directive for trapping focus within a region. */
|
134 | export declare class FocusTrapDirective implements OnDestroy, AfterContentInit, OnChanges, DoCheck {
|
135 | private _elementRef;
|
136 | private _focusTrapFactory;
|
137 | private _document;
|
138 | /** Underlying FocusTrap instance. */
|
139 | focusTrap: FocusTrap;
|
140 | /** Previously focused element to restore focus to upon destroy when using autoCapture. */
|
141 | private _previouslyFocusedElement;
|
142 | /** Whether the focus trap is active. */
|
143 | get enabled(): boolean;
|
144 | set enabled(value: boolean);
|
145 | /**
|
146 | * Whether the directive should automatically move focus into the trapped region upon
|
147 | * initialization and return focus to the previous activeElement upon destruction.
|
148 | */
|
149 | get autoCapture(): boolean;
|
150 | set autoCapture(value: boolean);
|
151 | private _autoCapture;
|
152 | constructor(_elementRef: ElementRef<HTMLElement>, _focusTrapFactory: FocusTrapFactory, _document: any);
|
153 | ngOnDestroy(): void;
|
154 | ngAfterContentInit(): void;
|
155 | ngDoCheck(): void;
|
156 | ngOnChanges(changes: SimpleChanges): void;
|
157 | private _captureFocus;
|
158 | static ngAcceptInputType_enabled: BooleanInput;
|
159 | static ngAcceptInputType_autoCapture: BooleanInput;
|
160 | static ɵfac: i0.ɵɵFactoryDeclaration<FocusTrapDirective, never>;
|
161 | static ɵdir: i0.ɵɵDirectiveDeclaration<FocusTrapDirective, "[focusTrap]", ["focusTrap"], { "enabled": { "alias": "cdkTrapFocus"; "required": false; }; "autoCapture": { "alias": "cdkTrapFocusAutoCapture"; "required": false; }; }, {}, never, never, false, never>;
|
162 | }
|