@primer/components 0.0.0-202111616587 → 0.0.0-2021116181214

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 (175) hide show
  1. package/dist/browser.esm.js +2 -2
  2. package/dist/browser.esm.js.map +1 -1
  3. package/dist/browser.umd.js +2 -2
  4. package/dist/browser.umd.js.map +1 -1
  5. package/lib/ActionList/Item.js +3 -3
  6. package/lib/ActionList/List.js +2 -2
  7. package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +1 -1
  8. package/lib/Autocomplete/AutocompleteMenu.js +11 -23
  9. package/lib/CheckboxInputField.d.ts +11 -0
  10. package/lib/CheckboxInputField.js +73 -0
  11. package/lib/ChoiceFieldset/ChoiceFieldCaption.d.ts +3 -0
  12. package/lib/ChoiceFieldset/ChoiceFieldCaption.js +35 -0
  13. package/lib/ChoiceFieldset/ChoiceFieldLabel.d.ts +3 -0
  14. package/lib/ChoiceFieldset/ChoiceFieldLabel.js +35 -0
  15. package/lib/ChoiceFieldset/ChoiceFieldset.d.ts +65 -0
  16. package/lib/ChoiceFieldset/ChoiceFieldset.js +95 -0
  17. package/lib/ChoiceFieldset/ChoiceFieldsetDescription.d.ts +3 -0
  18. package/lib/ChoiceFieldset/ChoiceFieldsetDescription.js +29 -0
  19. package/lib/ChoiceFieldset/ChoiceFieldsetLegend.d.ts +9 -0
  20. package/lib/ChoiceFieldset/ChoiceFieldsetLegend.js +44 -0
  21. package/lib/ChoiceFieldset/ChoiceFieldsetList.d.ts +9 -0
  22. package/lib/ChoiceFieldset/ChoiceFieldsetList.js +69 -0
  23. package/lib/ChoiceFieldset/ChoiceFieldsetListContext.d.ts +19 -0
  24. package/lib/ChoiceFieldset/ChoiceFieldsetListContext.js +15 -0
  25. package/lib/ChoiceFieldset/ChoiceFieldsetListItem.d.ts +25 -0
  26. package/lib/ChoiceFieldset/ChoiceFieldsetListItem.js +75 -0
  27. package/lib/ChoiceFieldset/ChoiceFieldsetValidation.d.ts +6 -0
  28. package/lib/ChoiceFieldset/ChoiceFieldsetValidation.js +17 -0
  29. package/lib/ChoiceFieldset/index.d.ts +3 -0
  30. package/lib/ChoiceFieldset/index.js +23 -0
  31. package/lib/Dialog/ConfirmationDialog.js +2 -2
  32. package/lib/Dialog/Dialog.js +2 -2
  33. package/lib/FilteredActionList/FilteredActionList.js +3 -10
  34. package/lib/Overlay.d.ts +1 -1
  35. package/lib/RadioInputField.d.ts +10 -0
  36. package/lib/RadioInputField.js +74 -0
  37. package/lib/TextInputField.d.ts +583 -0
  38. package/lib/TextInputField.js +66 -0
  39. package/lib/TextInputWithTokens.js +4 -4
  40. package/lib/_InputCaption.d.ts +13 -0
  41. package/lib/_InputCaption.js +27 -0
  42. package/lib/_InputField/InputField.d.ts +39 -0
  43. package/lib/_InputField/InputField.js +90 -0
  44. package/lib/_InputField/InputFieldCaption.d.ts +3 -0
  45. package/lib/_InputField/InputFieldCaption.js +30 -0
  46. package/lib/_InputField/InputFieldLabel.d.ts +9 -0
  47. package/lib/_InputField/InputFieldLabel.js +34 -0
  48. package/lib/_InputField/InputFieldValidation.d.ts +6 -0
  49. package/lib/_InputField/InputFieldValidation.js +17 -0
  50. package/lib/_InputField/ToggleInputField.d.ts +13 -0
  51. package/lib/_InputField/ToggleInputField.js +71 -0
  52. package/lib/_InputField/ToggleInputLeadingVisual.d.ts +3 -0
  53. package/lib/_InputField/ToggleInputLeadingVisual.js +22 -0
  54. package/lib/_InputField/ValidationAnimationContainer.d.ts +6 -0
  55. package/lib/_InputField/ValidationAnimationContainer.js +48 -0
  56. package/lib/_InputField/index.d.ts +1 -0
  57. package/lib/_InputField/index.js +15 -0
  58. package/lib/_InputField/slots.d.ts +13 -0
  59. package/lib/_InputField/slots.js +17 -0
  60. package/lib/_InputLabel.d.ts +8 -0
  61. package/lib/_InputLabel.js +44 -0
  62. package/lib/_InputValidation.d.ts +8 -0
  63. package/lib/_InputValidation.js +56 -0
  64. package/lib/_VisuallyHidden.d.ts +6 -0
  65. package/lib/_VisuallyHidden.js +39 -0
  66. package/lib/behaviors/anchoredPosition.d.ts +89 -0
  67. package/lib/behaviors/anchoredPosition.js +316 -0
  68. package/lib/behaviors/focusTrap.d.ts +12 -0
  69. package/lib/behaviors/focusTrap.js +179 -0
  70. package/lib/behaviors/focusZone.d.ts +137 -0
  71. package/lib/behaviors/focusZone.js +578 -0
  72. package/lib/behaviors/scrollIntoViewingArea.d.ts +1 -0
  73. package/lib/behaviors/scrollIntoViewingArea.js +39 -0
  74. package/lib/hooks/useAnchoredPosition.d.ts +1 -1
  75. package/lib/hooks/useAnchoredPosition.js +2 -2
  76. package/lib/hooks/useFocusTrap.js +2 -2
  77. package/lib/hooks/useFocusZone.d.ts +1 -1
  78. package/lib/hooks/useFocusZone.js +2 -2
  79. package/lib/hooks/useOpenAndCloseFocus.js +2 -2
  80. package/lib/index.d.ts +4 -0
  81. package/lib/index.js +38 -0
  82. package/lib/utils/iterateFocusableElements.d.ts +42 -0
  83. package/lib/utils/iterateFocusableElements.js +113 -0
  84. package/lib/utils/types/FormValidationStatus.d.ts +1 -0
  85. package/lib/utils/types/FormValidationStatus.js +1 -0
  86. package/lib/utils/uniqueId.d.ts +1 -0
  87. package/lib/utils/uniqueId.js +12 -0
  88. package/lib/utils/userAgent.d.ts +1 -0
  89. package/lib/utils/userAgent.js +15 -0
  90. package/lib-esm/ActionList/Item.js +1 -1
  91. package/lib-esm/ActionList/List.js +1 -1
  92. package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +1 -1
  93. package/lib-esm/Autocomplete/AutocompleteMenu.js +7 -22
  94. package/lib-esm/CheckboxInputField.d.ts +11 -0
  95. package/lib-esm/CheckboxInputField.js +56 -0
  96. package/lib-esm/ChoiceFieldset/ChoiceFieldCaption.d.ts +3 -0
  97. package/lib-esm/ChoiceFieldset/ChoiceFieldCaption.js +20 -0
  98. package/lib-esm/ChoiceFieldset/ChoiceFieldLabel.d.ts +3 -0
  99. package/lib-esm/ChoiceFieldset/ChoiceFieldLabel.js +20 -0
  100. package/lib-esm/ChoiceFieldset/ChoiceFieldset.d.ts +65 -0
  101. package/lib-esm/ChoiceFieldset/ChoiceFieldset.js +72 -0
  102. package/lib-esm/ChoiceFieldset/ChoiceFieldsetDescription.d.ts +3 -0
  103. package/lib-esm/ChoiceFieldset/ChoiceFieldsetDescription.js +17 -0
  104. package/lib-esm/ChoiceFieldset/ChoiceFieldsetLegend.d.ts +9 -0
  105. package/lib-esm/ChoiceFieldset/ChoiceFieldsetLegend.js +31 -0
  106. package/lib-esm/ChoiceFieldset/ChoiceFieldsetList.d.ts +9 -0
  107. package/lib-esm/ChoiceFieldset/ChoiceFieldsetList.js +52 -0
  108. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListContext.d.ts +19 -0
  109. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListContext.js +5 -0
  110. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListItem.d.ts +25 -0
  111. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListItem.js +51 -0
  112. package/lib-esm/ChoiceFieldset/ChoiceFieldsetValidation.d.ts +6 -0
  113. package/lib-esm/ChoiceFieldset/ChoiceFieldsetValidation.js +7 -0
  114. package/lib-esm/ChoiceFieldset/index.d.ts +3 -0
  115. package/lib-esm/ChoiceFieldset/index.js +2 -0
  116. package/lib-esm/Dialog/ConfirmationDialog.js +1 -1
  117. package/lib-esm/Dialog/Dialog.js +1 -1
  118. package/lib-esm/FilteredActionList/FilteredActionList.js +3 -9
  119. package/lib-esm/Overlay.d.ts +1 -1
  120. package/lib-esm/RadioInputField.d.ts +10 -0
  121. package/lib-esm/RadioInputField.js +56 -0
  122. package/lib-esm/TextInputField.d.ts +583 -0
  123. package/lib-esm/TextInputField.js +50 -0
  124. package/lib-esm/TextInputWithTokens.js +2 -2
  125. package/lib-esm/_InputCaption.d.ts +13 -0
  126. package/lib-esm/_InputCaption.js +16 -0
  127. package/lib-esm/_InputField/InputField.d.ts +39 -0
  128. package/lib-esm/_InputField/InputField.js +70 -0
  129. package/lib-esm/_InputField/InputFieldCaption.d.ts +3 -0
  130. package/lib-esm/_InputField/InputFieldCaption.js +18 -0
  131. package/lib-esm/_InputField/InputFieldLabel.d.ts +9 -0
  132. package/lib-esm/_InputField/InputFieldLabel.js +22 -0
  133. package/lib-esm/_InputField/InputFieldValidation.d.ts +6 -0
  134. package/lib-esm/_InputField/InputFieldValidation.js +7 -0
  135. package/lib-esm/_InputField/ToggleInputField.d.ts +13 -0
  136. package/lib-esm/_InputField/ToggleInputField.js +54 -0
  137. package/lib-esm/_InputField/ToggleInputLeadingVisual.d.ts +3 -0
  138. package/lib-esm/_InputField/ToggleInputLeadingVisual.js +11 -0
  139. package/lib-esm/_InputField/ValidationAnimationContainer.d.ts +6 -0
  140. package/lib-esm/_InputField/ValidationAnimationContainer.js +33 -0
  141. package/lib-esm/_InputField/index.d.ts +1 -0
  142. package/lib-esm/_InputField/index.js +1 -0
  143. package/lib-esm/_InputField/slots.d.ts +13 -0
  144. package/lib-esm/_InputField/slots.js +5 -0
  145. package/lib-esm/_InputLabel.d.ts +8 -0
  146. package/lib-esm/_InputLabel.js +32 -0
  147. package/lib-esm/_InputValidation.d.ts +8 -0
  148. package/lib-esm/_InputValidation.js +43 -0
  149. package/lib-esm/_VisuallyHidden.d.ts +6 -0
  150. package/lib-esm/_VisuallyHidden.js +26 -0
  151. package/lib-esm/behaviors/anchoredPosition.d.ts +89 -0
  152. package/lib-esm/behaviors/anchoredPosition.js +309 -0
  153. package/lib-esm/behaviors/focusTrap.d.ts +12 -0
  154. package/lib-esm/behaviors/focusTrap.js +170 -0
  155. package/lib-esm/behaviors/focusZone.d.ts +137 -0
  156. package/lib-esm/behaviors/focusZone.js +560 -0
  157. package/lib-esm/behaviors/scrollIntoViewingArea.d.ts +1 -0
  158. package/lib-esm/behaviors/scrollIntoViewingArea.js +30 -0
  159. package/lib-esm/hooks/useAnchoredPosition.d.ts +1 -1
  160. package/lib-esm/hooks/useAnchoredPosition.js +1 -1
  161. package/lib-esm/hooks/useFocusTrap.js +1 -1
  162. package/lib-esm/hooks/useFocusZone.d.ts +1 -1
  163. package/lib-esm/hooks/useFocusZone.js +1 -1
  164. package/lib-esm/hooks/useOpenAndCloseFocus.js +1 -1
  165. package/lib-esm/index.d.ts +4 -0
  166. package/lib-esm/index.js +4 -0
  167. package/lib-esm/utils/iterateFocusableElements.d.ts +42 -0
  168. package/lib-esm/utils/iterateFocusableElements.js +102 -0
  169. package/lib-esm/utils/types/FormValidationStatus.d.ts +1 -0
  170. package/lib-esm/utils/types/FormValidationStatus.js +1 -0
  171. package/lib-esm/utils/uniqueId.d.ts +1 -0
  172. package/lib-esm/utils/uniqueId.js +5 -0
  173. package/lib-esm/utils/userAgent.d.ts +1 -0
  174. package/lib-esm/utils/userAgent.js +8 -0
  175. package/package.json +6 -3
@@ -0,0 +1,179 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.focusTrap = focusTrap;
7
+
8
+ var _iterateFocusableElements = require("../utils/iterateFocusableElements");
9
+
10
+ var _eventListenerSignal = require("../polyfills/eventListenerSignal");
11
+
12
+ (0, _eventListenerSignal.polyfill)();
13
+ const suspendedTrapStack = [];
14
+ let activeTrap = undefined;
15
+
16
+ function tryReactivate() {
17
+ const trapToReactivate = suspendedTrapStack.pop();
18
+
19
+ if (trapToReactivate) {
20
+ focusTrap(trapToReactivate.container, trapToReactivate.initialFocus, trapToReactivate.originalSignal);
21
+ }
22
+ } // @todo If AbortController.prototype.follow is ever implemented, that
23
+ // could replace this function. @see https://github.com/whatwg/dom/issues/920
24
+
25
+
26
+ function followSignal(signal) {
27
+ const controller = new AbortController();
28
+ signal.addEventListener('abort', () => {
29
+ controller.abort();
30
+ });
31
+ return controller;
32
+ }
33
+ /**
34
+ * Returns the first focusable child of `container`. If `lastChild` is true,
35
+ * returns the last focusable child of `container`.
36
+ * @param container
37
+ * @param lastChild
38
+ */
39
+
40
+
41
+ function getFocusableChild(container, lastChild = false) {
42
+ return (0, _iterateFocusableElements.iterateFocusableElements)(container, {
43
+ reverse: lastChild,
44
+ strict: true,
45
+ onlyTabbable: true
46
+ }).next().value;
47
+ }
48
+ /**
49
+ * Traps focus within the given container.
50
+ * @param container The container in which to trap focus
51
+ * @returns AbortController - call `.abort()` to disable the focus trap
52
+ */
53
+
54
+
55
+ function focusTrap(container, initialFocus, abortSignal) {
56
+ // Set up an abort controller if a signal was not passed in
57
+ const controller = new AbortController();
58
+ const signal = abortSignal !== null && abortSignal !== void 0 ? abortSignal : controller.signal;
59
+ container.setAttribute('data-focus-trap', 'active');
60
+ let lastFocusedChild = undefined; // Ensure focus remains in the trap zone by checking that a given recently-focused
61
+ // element is inside the trap zone. If it isn't, redirect focus to a suitable
62
+ // element within the trap zone. If need to redirect focus and a suitable element
63
+ // is not found, focus the container.
64
+
65
+ function ensureTrapZoneHasFocus(focusedElement) {
66
+ if (focusedElement instanceof HTMLElement && document.contains(container)) {
67
+ if (container.contains(focusedElement)) {
68
+ // If a child of the trap zone was focused, remember it
69
+ lastFocusedChild = focusedElement;
70
+ return;
71
+ } else {
72
+ if (lastFocusedChild && (0, _iterateFocusableElements.isTabbable)(lastFocusedChild) && container.contains(lastFocusedChild)) {
73
+ lastFocusedChild.focus();
74
+ return;
75
+ } else if (initialFocus && container.contains(initialFocus)) {
76
+ initialFocus.focus();
77
+ return;
78
+ } else {
79
+ // Ensure the container is focusable:
80
+ // - Either the container already has a `tabIndex`
81
+ // - Or provide a temporary `tabIndex`
82
+ const containerNeedsTemporaryTabIndex = container.getAttribute('tabindex') === null;
83
+
84
+ if (containerNeedsTemporaryTabIndex) {
85
+ container.setAttribute('tabindex', '-1');
86
+ } // Focus the container.
87
+
88
+
89
+ container.focus(); // If a temporary `tabIndex` was provided, remove it.
90
+
91
+ if (containerNeedsTemporaryTabIndex) {
92
+ // Once focus has moved from the container to a child within the FocusTrap,
93
+ // the container can be made un-refocusable by removing `tabIndex`.
94
+ container.addEventListener('blur', () => container.removeAttribute('tabindex'), {
95
+ once: true
96
+ }); // NB: If `tabIndex` was removed *before* `blur`, then certain browsers (e.g. Chrome)
97
+ // would consider `body` the `activeElement`, and as a result, keyboard navigation
98
+ // between children would break, since `body` is outside the `FocusTrap`.
99
+ }
100
+
101
+ return;
102
+ }
103
+ }
104
+ }
105
+ }
106
+
107
+ const wrappingController = followSignal(signal);
108
+ container.addEventListener('keydown', event => {
109
+ if (event.key !== 'Tab' || event.defaultPrevented) {
110
+ return;
111
+ }
112
+
113
+ const {
114
+ target
115
+ } = event;
116
+ const firstFocusableChild = getFocusableChild(container);
117
+ const lastFocusableChild = getFocusableChild(container, true);
118
+
119
+ if (target === firstFocusableChild && event.shiftKey) {
120
+ event.preventDefault();
121
+ lastFocusableChild === null || lastFocusableChild === void 0 ? void 0 : lastFocusableChild.focus();
122
+ } else if (target === lastFocusableChild && !event.shiftKey) {
123
+ event.preventDefault();
124
+ firstFocusableChild === null || firstFocusableChild === void 0 ? void 0 : firstFocusableChild.focus();
125
+ }
126
+ }, {
127
+ signal: wrappingController.signal
128
+ });
129
+
130
+ if (activeTrap) {
131
+ const suspendedTrap = activeTrap;
132
+ activeTrap.container.setAttribute('data-focus-trap', 'suspended');
133
+ activeTrap.controller.abort();
134
+ suspendedTrapStack.push(suspendedTrap);
135
+ } // When this trap is canceled, either by the user or by us for suspension
136
+
137
+
138
+ wrappingController.signal.addEventListener('abort', () => {
139
+ activeTrap = undefined;
140
+ }); // Only when user-canceled
141
+
142
+ signal.addEventListener('abort', () => {
143
+ container.removeAttribute('data-focus-trap');
144
+ const suspendedTrapIndex = suspendedTrapStack.findIndex(t => t.container === container);
145
+
146
+ if (suspendedTrapIndex >= 0) {
147
+ suspendedTrapStack.splice(suspendedTrapIndex, 1);
148
+ }
149
+
150
+ tryReactivate();
151
+ }); // Prevent focus leaving the trap container
152
+
153
+ document.addEventListener('focus', event => {
154
+ ensureTrapZoneHasFocus(event.target);
155
+ }, // use capture to ensure we get all events. focus events do not bubble
156
+ {
157
+ signal: wrappingController.signal,
158
+ capture: true
159
+ }); // focus the first element
160
+
161
+ ensureTrapZoneHasFocus(document.activeElement);
162
+ activeTrap = {
163
+ container,
164
+ controller: wrappingController,
165
+ initialFocus,
166
+ originalSignal: signal
167
+ }; // If we are activating a focus trap for a container that was previously
168
+ // suspended, just remove it from the suspended list.
169
+
170
+ const suspendedTrapIndex = suspendedTrapStack.findIndex(t => t.container === container);
171
+
172
+ if (suspendedTrapIndex >= 0) {
173
+ suspendedTrapStack.splice(suspendedTrapIndex, 1);
174
+ }
175
+
176
+ if (!abortSignal) {
177
+ return controller;
178
+ }
179
+ }
@@ -0,0 +1,137 @@
1
+ export declare type Direction = 'previous' | 'next' | 'start' | 'end';
2
+ export declare type FocusMovementKeys = 'ArrowLeft' | 'ArrowDown' | 'ArrowUp' | 'ArrowRight' | 'h' | 'j' | 'k' | 'l' | 'a' | 's' | 'w' | 'd' | 'Tab' | 'Home' | 'End' | 'PageUp' | 'PageDown';
3
+ export declare enum FocusKeys {
4
+ ArrowHorizontal = 1,
5
+ ArrowVertical = 2,
6
+ JK = 4,
7
+ HL = 8,
8
+ HomeAndEnd = 16,
9
+ PageUpDown = 256,
10
+ WS = 32,
11
+ AD = 64,
12
+ Tab = 128,
13
+ ArrowAll = 3,
14
+ HJKL = 12,
15
+ WASD = 96,
16
+ All = 511
17
+ }
18
+ /**
19
+ * Options that control the behavior of the arrow focus behavior.
20
+ */
21
+ export interface FocusZoneSettings {
22
+ /**
23
+ * Choose the behavior applied in cases where focus is currently at either the first or
24
+ * last element of the container.
25
+ *
26
+ * "stop" - do nothing and keep focus where it was
27
+ * "wrap" - wrap focus around to the first element from the last, or the last element from the first
28
+ *
29
+ * Default: "stop"
30
+ */
31
+ focusOutBehavior?: 'stop' | 'wrap';
32
+ /**
33
+ * If set, this will be called to get the next focusable element. If this function
34
+ * returns null, we will try to determine the next direction ourselves. Use the
35
+ * `bindKeys` option to customize which keys are listened to.
36
+ *
37
+ * The function can accept a Direction, indicating the direction focus should move,
38
+ * the HTMLElement that was previously focused, and lastly the `KeyboardEvent` object
39
+ * created by the original `"keydown"` event.
40
+ */
41
+ getNextFocusable?: (direction: Direction, from: Element | undefined, event: KeyboardEvent) => HTMLElement | undefined;
42
+ /**
43
+ * Called to decide if a focusable element is allowed to participate in the arrow
44
+ * key focus behavior.
45
+ *
46
+ * By default, all focusable elements within the given container will participate
47
+ * in the arrow key focus behavior. If you need to withhold some elements from
48
+ * participation, implement this callback to return false for those elements.
49
+ */
50
+ focusableElementFilter?: (element: HTMLElement) => boolean;
51
+ /**
52
+ * Bit flags that identify keys that will be bound to. Each available key either
53
+ * moves focus to the "next" element or the "previous" element, so it is best
54
+ * to only bind the keys that make sense to move focus in your UI. Use the `FocusKeys`
55
+ * object to discover supported keys.
56
+ *
57
+ * Use the bitwise "OR" operator (`|`) to combine key types. For example,
58
+ * `FocusKeys.WASD | FocusKeys.HJKL` represents all of W, A, S, D, H, J, K, and L.
59
+ *
60
+ * A note on FocusKeys.PageUpDown: This behavior does not support paging, so by default
61
+ * using these keys will result in the same behavior as Home and End. To override this
62
+ * behavior, implement `getNextFocusable`.
63
+ *
64
+ * The default for this setting is `FocusKeys.ArrowVertical | FocusKeys.HomeAndEnd`, unless
65
+ * `getNextFocusable` is provided, in which case `FocusKeys.ArrowAll | FocusKeys.HomeAndEnd`
66
+ * is used as the default.
67
+ */
68
+ bindKeys?: FocusKeys;
69
+ /**
70
+ * If provided, this signal can be used to disable the behavior and remove any
71
+ * event listeners.
72
+ */
73
+ abortSignal?: AbortSignal;
74
+ /**
75
+ * If `activeDescendantControl` is supplied, do not move focus or alter `tabindex` on
76
+ * any element. Instead, manage `aria-activedescendant` according to the ARIA best
77
+ * practices guidelines.
78
+ * @see https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_focus_activedescendant
79
+ *
80
+ * The given `activeDescendantControl` will be given an `aria-controls` attribute that
81
+ * references the ID of the `container`. Additionally, it will be given an
82
+ * `aria-activedescendant` attribute that references the ID of the currently-active
83
+ * descendant.
84
+ *
85
+ * This element will retain DOM focus as arrow keys are pressed.
86
+ */
87
+ activeDescendantControl?: HTMLElement;
88
+ /**
89
+ * Called each time the active descendant changes. Note that either of the parameters
90
+ * may be undefined, e.g. when an element in the container first becomes active, or
91
+ * when the controlling element becomes unfocused.
92
+ */
93
+ onActiveDescendantChanged?: (newActiveDescendant: HTMLElement | undefined, previousActiveDescendant: HTMLElement | undefined, directlyActivated: boolean) => void;
94
+ /**
95
+ * This option allows customization of the behavior that determines which of the
96
+ * focusable elements should be focused when focus enters the container via the Tab key.
97
+ *
98
+ * When set to "first", whenever focus enters the container via Tab, we will focus the
99
+ * first focusable element. When set to "previous", the most recently focused element
100
+ * will be focused (fallback to first if there was no previous).
101
+ *
102
+ * The "closest" strategy works like "first", except either the first or the last element
103
+ * of the container will be focused, depending on the direction from which focus comes.
104
+ *
105
+ * If a function is provided, this function should return the HTMLElement intended
106
+ * to receive focus. This is useful if you want to focus the currently "selected"
107
+ * item or element.
108
+ *
109
+ * Default: "previous"
110
+ *
111
+ * For more information, @see https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_general_within
112
+ */
113
+ focusInStrategy?: 'first' | 'closest' | 'previous' | ((previousFocusedElement: Element) => HTMLElement | undefined);
114
+ }
115
+ export declare const isActiveDescendantAttribute = "data-is-active-descendant";
116
+ /**
117
+ * A value of activated-directly for data-is-active-descendant indicates the descendant was activated
118
+ * by a manual user interaction with intent to move active descendant. This usually translates to the
119
+ * user pressing one of the bound keys (up/down arrow, etc) to move through the focus zone. This is
120
+ * intended to be roughly equivalent to the :focus-visible pseudo-class
121
+ **/
122
+ export declare const activeDescendantActivatedDirectly = "activated-directly";
123
+ /**
124
+ * A value of activated-indirectly for data-is-active-descendant indicates the descendant was activated
125
+ * implicitly, and not by a direct key press. This includes focus zone being created from scratch, focusable
126
+ * elements being added/removed, and mouseover events. This is intended to be roughly equivalent
127
+ * to :focus:not(:focus-visible)
128
+ **/
129
+ export declare const activeDescendantActivatedIndirectly = "activated-indirectly";
130
+ export declare const hasActiveDescendantAttribute = "data-has-active-descendant";
131
+ /**
132
+ * Sets up the arrow key focus behavior for all focusable elements in the given `container`.
133
+ * @param container
134
+ * @param settings
135
+ * @returns
136
+ */
137
+ export declare function focusZone(container: HTMLElement, settings?: FocusZoneSettings): AbortController;