@eightshift/ui-components 0.0.1

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 (112) hide show
  1. package/README.md +27 -0
  2. package/dist/Checkbox-BLcVbhiO.js +178 -0
  3. package/dist/ColorSwatch-Cmlex_kT.js +66 -0
  4. package/dist/FieldError-wtMA4667.js +42 -0
  5. package/dist/FocusScope-1u9yyfIN.js +725 -0
  6. package/dist/Form-Cq3fu75_.js +5 -0
  7. package/dist/GridList-BZPXp3_O.js +1256 -0
  8. package/dist/Group-DyqpTRPe.js +49 -0
  9. package/dist/Input-jsbb4ugq.js +130 -0
  10. package/dist/Label-BPzS-sR7.js +17 -0
  11. package/dist/ListBox-w9gDaJkV.js +4423 -0
  12. package/dist/LiveAnnouncer-IsokfWQ5.js +73 -0
  13. package/dist/NumberFormatter-LzoKy975.js +160 -0
  14. package/dist/RSPContexts-CrNYmadY.js +14 -0
  15. package/dist/Select-49a62830.esm-C-RFtLiD.js +2541 -0
  16. package/dist/SelectionManager-mefd0ThJ.js +2155 -0
  17. package/dist/Separator-DHn0CwdK.js +325 -0
  18. package/dist/Slider-Pyh2V4bY.js +885 -0
  19. package/dist/Text-BM136LvS.js +17 -0
  20. package/dist/VisuallyHidden-BYRI1Lfo.js +51 -0
  21. package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
  22. package/dist/ariaHideOutside-ByKBPHmX.js +113 -0
  23. package/dist/assets/style.css +1 -0
  24. package/dist/button-BkkdyHfJ.js +307 -0
  25. package/dist/components/animated-visibility/animated-visibility.js +7165 -0
  26. package/dist/components/base-control/base-control.js +97 -0
  27. package/dist/components/breakpoint-preview/breakpoint-preview.js +218 -0
  28. package/dist/components/button/button.js +10 -0
  29. package/dist/components/checkbox/checkbox.js +119 -0
  30. package/dist/components/color-pickers/color-picker.js +242 -0
  31. package/dist/components/color-pickers/color-swatch.js +62 -0
  32. package/dist/components/color-pickers/gradient-editor.js +516 -0
  33. package/dist/components/color-pickers/solid-color-picker.js +1633 -0
  34. package/dist/components/component-toggle/component-toggle.js +71 -0
  35. package/dist/components/container-panel/container-panel.js +39 -0
  36. package/dist/components/expandable/expandable.js +144 -0
  37. package/dist/components/input-field/input-field.js +224 -0
  38. package/dist/components/link-input/link-input.js +937 -0
  39. package/dist/components/list-box/list-box.js +152 -0
  40. package/dist/components/matrix-align/matrix-align.js +185 -0
  41. package/dist/components/menu/menu.js +1608 -0
  42. package/dist/components/notice/notice.js +119 -0
  43. package/dist/components/number-picker/number-picker.js +277 -0
  44. package/dist/components/popover/popover.js +9 -0
  45. package/dist/components/radio/radio.js +552 -0
  46. package/dist/components/repeater/repeater-item.js +127 -0
  47. package/dist/components/repeater/repeater.js +248 -0
  48. package/dist/components/responsive/responsive-legacy.js +326 -0
  49. package/dist/components/responsive/responsive.js +499 -0
  50. package/dist/components/responsive-preview/responsive-preview.js +119 -0
  51. package/dist/components/rich-label/rich-label.js +56 -0
  52. package/dist/components/select/async-multi-select.js +144 -0
  53. package/dist/components/select/async-single-select.js +126 -0
  54. package/dist/components/select/custom-select-default-components.js +38 -0
  55. package/dist/components/select/multi-select-components.js +8 -0
  56. package/dist/components/select/multi-select.js +134 -0
  57. package/dist/components/select/react-select-component-wrappers.js +90 -0
  58. package/dist/components/select/shared.js +45 -0
  59. package/dist/components/select/single-select.js +116 -0
  60. package/dist/components/select/styles.js +55 -0
  61. package/dist/components/slider/column-config-slider.js +225 -0
  62. package/dist/components/slider/slider.js +362 -0
  63. package/dist/components/slider/utils.js +45 -0
  64. package/dist/components/spacer/spacer.js +93 -0
  65. package/dist/components/tabs/tabs.js +626 -0
  66. package/dist/components/toggle/switch.js +140 -0
  67. package/dist/components/toggle/toggle.js +58 -0
  68. package/dist/components/toggle-button/toggle-button.js +206 -0
  69. package/dist/components/tooltip/tooltip.js +10 -0
  70. package/dist/context-jMy6xdVq.js +98 -0
  71. package/dist/default-i18n-BhE-OUmt.js +873 -0
  72. package/dist/filterDOMProps-DG2RfOUr.js +30 -0
  73. package/dist/focusSafely-C3K8zAKj.js +743 -0
  74. package/dist/hooks/use-cell-edit-mode.js +35 -0
  75. package/dist/icons/block-icon.js +42 -0
  76. package/dist/icons/generic-color-swatch.js +21 -0
  77. package/dist/icons/icons.js +3636 -0
  78. package/dist/index-Bfb9bWcb.js +28844 -0
  79. package/dist/index-a301f526.esm-Bioi4cGX.js +3576 -0
  80. package/dist/index.js +109 -0
  81. package/dist/intlStrings-CUhoK9EN.js +2484 -0
  82. package/dist/isScrollable-PcyglExV.js +10 -0
  83. package/dist/modifiers.esm-BuJQPI1X.js +31 -0
  84. package/dist/multi-select-components-CjVpCNko.js +3677 -0
  85. package/dist/number-rWqELA8W.js +39 -0
  86. package/dist/popover-Dx3vKXUX.js +1061 -0
  87. package/dist/react-select-async.esm-TFb_ZX6C.js +111 -0
  88. package/dist/react-select.esm-BjRWqf0E.js +15 -0
  89. package/dist/style.js +1 -0
  90. package/dist/textSelection-BosCCRVE.js +89 -0
  91. package/dist/tooltip-CkCndvTI.js +1094 -0
  92. package/dist/useButton-CuG5UzUw.js +74 -0
  93. package/dist/useEvent-DHv-yhOH.js +24 -0
  94. package/dist/useFocusRing-Cc-4eouh.js +41 -0
  95. package/dist/useFocusable-5q1Gek1J.js +81 -0
  96. package/dist/useFormReset-Buc9YJcv.js +23 -0
  97. package/dist/useFormValidationState-BAPPNXic.js +238 -0
  98. package/dist/useHasTabbableChild-D3uUNhJ0.js +37 -0
  99. package/dist/useLabel-CGlkoFG0.js +28 -0
  100. package/dist/useLabels-Dg62M_3P.js +25 -0
  101. package/dist/useListData-BelKu4kx.js +211 -0
  102. package/dist/useListState-Domq0blV.js +137 -0
  103. package/dist/useLocalizedStringFormatter-Prmz0h0A.js +130 -0
  104. package/dist/useNumberFieldState-BLU3uhSR.js +1253 -0
  105. package/dist/useNumberFormatter-BLc2xjZn.js +13 -0
  106. package/dist/usePress-BQgVor4T.js +698 -0
  107. package/dist/useToggle-C9ETOBaZ.js +58 -0
  108. package/dist/useToggleState-DJ_z5E2S.js +21 -0
  109. package/dist/utilities/classnames.js +16 -0
  110. package/dist/utilities/text-helpers.js +79 -0
  111. package/dist/utils-BsiH7-5Y.js +488 -0
  112. package/package.json +71 -0
@@ -0,0 +1,725 @@
1
+ import { f as $431fbd86ca7dc216$export$f21a1ffae260145a, g as $431fbd86ca7dc216$export$b204af158042fbac, h as $6a99195332edec8b$export$80f3e147d781571c } from "./focusSafely-C3K8zAKj.js";
2
+ import { g as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c } from "./utils-BsiH7-5Y.js";
3
+ import React__default, { useRef, useContext, useMemo, useEffect } from "react";
4
+ function $645f2e67b85a24c9$var$isStyleVisible(element) {
5
+ const windowObject = $431fbd86ca7dc216$export$f21a1ffae260145a(element);
6
+ if (!(element instanceof windowObject.HTMLElement) && !(element instanceof windowObject.SVGElement))
7
+ return false;
8
+ let { display, visibility } = element.style;
9
+ let isVisible = display !== "none" && visibility !== "hidden" && visibility !== "collapse";
10
+ if (isVisible) {
11
+ const { getComputedStyle } = element.ownerDocument.defaultView;
12
+ let { display: computedDisplay, visibility: computedVisibility } = getComputedStyle(element);
13
+ isVisible = computedDisplay !== "none" && computedVisibility !== "hidden" && computedVisibility !== "collapse";
14
+ }
15
+ return isVisible;
16
+ }
17
+ function $645f2e67b85a24c9$var$isAttributeVisible(element, childElement) {
18
+ return !element.hasAttribute("hidden") && // Ignore HiddenSelect when tree walking.
19
+ !element.hasAttribute("data-react-aria-prevent-focus") && (element.nodeName === "DETAILS" && childElement && childElement.nodeName !== "SUMMARY" ? element.hasAttribute("open") : true);
20
+ }
21
+ function $645f2e67b85a24c9$export$e989c0fffaa6b27a(element, childElement) {
22
+ return element.nodeName !== "#comment" && $645f2e67b85a24c9$var$isStyleVisible(element) && $645f2e67b85a24c9$var$isAttributeVisible(element, childElement) && (!element.parentElement || $645f2e67b85a24c9$export$e989c0fffaa6b27a(element.parentElement, element));
23
+ }
24
+ const $9bf71ea28793e738$var$FocusContext = /* @__PURE__ */ React__default.createContext(null);
25
+ let $9bf71ea28793e738$var$activeScope = null;
26
+ function $9bf71ea28793e738$export$20e40289641fbbb6(props) {
27
+ let { children, contain, restoreFocus, autoFocus } = props;
28
+ let startRef = useRef(null);
29
+ let endRef = useRef(null);
30
+ let scopeRef = useRef([]);
31
+ let { parentNode } = useContext($9bf71ea28793e738$var$FocusContext) || {};
32
+ let node = useMemo(() => new $9bf71ea28793e738$var$TreeNode({
33
+ scopeRef
34
+ }), [
35
+ scopeRef
36
+ ]);
37
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
38
+ let parent = parentNode || $9bf71ea28793e738$export$d06fae2ee68b101e.root;
39
+ if ($9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(parent.scopeRef) && $9bf71ea28793e738$var$activeScope && !$9bf71ea28793e738$var$isAncestorScope($9bf71ea28793e738$var$activeScope, parent.scopeRef)) {
40
+ let activeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode($9bf71ea28793e738$var$activeScope);
41
+ if (activeNode)
42
+ parent = activeNode;
43
+ }
44
+ parent.addChild(node);
45
+ $9bf71ea28793e738$export$d06fae2ee68b101e.addNode(node);
46
+ }, [
47
+ node,
48
+ parentNode
49
+ ]);
50
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
51
+ let node2 = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef);
52
+ if (node2)
53
+ node2.contain = !!contain;
54
+ }, [
55
+ contain
56
+ ]);
57
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
58
+ var _startRef_current;
59
+ let node2 = (_startRef_current = startRef.current) === null || _startRef_current === void 0 ? void 0 : _startRef_current.nextSibling;
60
+ let nodes = [];
61
+ while (node2 && node2 !== endRef.current) {
62
+ nodes.push(node2);
63
+ node2 = node2.nextSibling;
64
+ }
65
+ scopeRef.current = nodes;
66
+ }, [
67
+ children
68
+ ]);
69
+ $9bf71ea28793e738$var$useActiveScopeTracker(scopeRef, restoreFocus, contain);
70
+ $9bf71ea28793e738$var$useFocusContainment(scopeRef, contain);
71
+ $9bf71ea28793e738$var$useRestoreFocus(scopeRef, restoreFocus, contain);
72
+ $9bf71ea28793e738$var$useAutoFocus(scopeRef, autoFocus);
73
+ useEffect(() => {
74
+ const activeElement = $431fbd86ca7dc216$export$b204af158042fbac(scopeRef.current ? scopeRef.current[0] : void 0).activeElement;
75
+ let scope = null;
76
+ if ($9bf71ea28793e738$var$isElementInScope(activeElement, scopeRef.current)) {
77
+ for (let node2 of $9bf71ea28793e738$export$d06fae2ee68b101e.traverse())
78
+ if (node2.scopeRef && $9bf71ea28793e738$var$isElementInScope(activeElement, node2.scopeRef.current))
79
+ scope = node2;
80
+ if (scope === $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef))
81
+ $9bf71ea28793e738$var$activeScope = scope.scopeRef;
82
+ }
83
+ }, [
84
+ scopeRef
85
+ ]);
86
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
87
+ return () => {
88
+ var _focusScopeTree_getTreeNode_parent, _focusScopeTree_getTreeNode;
89
+ var _focusScopeTree_getTreeNode_parent_scopeRef;
90
+ let parentScope = (_focusScopeTree_getTreeNode_parent_scopeRef = (_focusScopeTree_getTreeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef)) === null || _focusScopeTree_getTreeNode === void 0 ? void 0 : (_focusScopeTree_getTreeNode_parent = _focusScopeTree_getTreeNode.parent) === null || _focusScopeTree_getTreeNode_parent === void 0 ? void 0 : _focusScopeTree_getTreeNode_parent.scopeRef) !== null && _focusScopeTree_getTreeNode_parent_scopeRef !== void 0 ? _focusScopeTree_getTreeNode_parent_scopeRef : null;
91
+ if ((scopeRef === $9bf71ea28793e738$var$activeScope || $9bf71ea28793e738$var$isAncestorScope(scopeRef, $9bf71ea28793e738$var$activeScope)) && (!parentScope || $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(parentScope)))
92
+ $9bf71ea28793e738$var$activeScope = parentScope;
93
+ $9bf71ea28793e738$export$d06fae2ee68b101e.removeTreeNode(scopeRef);
94
+ };
95
+ }, [
96
+ scopeRef
97
+ ]);
98
+ let focusManager = useMemo(() => $9bf71ea28793e738$var$createFocusManagerForScope(scopeRef), []);
99
+ let value = useMemo(() => ({
100
+ focusManager,
101
+ parentNode: node
102
+ }), [
103
+ node,
104
+ focusManager
105
+ ]);
106
+ return /* @__PURE__ */ React__default.createElement($9bf71ea28793e738$var$FocusContext.Provider, {
107
+ value
108
+ }, /* @__PURE__ */ React__default.createElement("span", {
109
+ "data-focus-scope-start": true,
110
+ hidden: true,
111
+ ref: startRef
112
+ }), children, /* @__PURE__ */ React__default.createElement("span", {
113
+ "data-focus-scope-end": true,
114
+ hidden: true,
115
+ ref: endRef
116
+ }));
117
+ }
118
+ function $9bf71ea28793e738$var$createFocusManagerForScope(scopeRef) {
119
+ return {
120
+ focusNext(opts = {}) {
121
+ let scope = scopeRef.current;
122
+ let { from, tabbable, wrap, accept } = opts;
123
+ let node = from || $431fbd86ca7dc216$export$b204af158042fbac(scope[0]).activeElement;
124
+ let sentinel = scope[0].previousElementSibling;
125
+ let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
126
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
127
+ tabbable,
128
+ accept
129
+ }, scope);
130
+ walker.currentNode = $9bf71ea28793e738$var$isElementInScope(node, scope) ? node : sentinel;
131
+ let nextNode = walker.nextNode();
132
+ if (!nextNode && wrap) {
133
+ walker.currentNode = sentinel;
134
+ nextNode = walker.nextNode();
135
+ }
136
+ if (nextNode)
137
+ $9bf71ea28793e738$var$focusElement(nextNode, true);
138
+ return nextNode;
139
+ },
140
+ focusPrevious(opts = {}) {
141
+ let scope = scopeRef.current;
142
+ let { from, tabbable, wrap, accept } = opts;
143
+ let node = from || $431fbd86ca7dc216$export$b204af158042fbac(scope[0]).activeElement;
144
+ let sentinel = scope[scope.length - 1].nextElementSibling;
145
+ let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
146
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
147
+ tabbable,
148
+ accept
149
+ }, scope);
150
+ walker.currentNode = $9bf71ea28793e738$var$isElementInScope(node, scope) ? node : sentinel;
151
+ let previousNode = walker.previousNode();
152
+ if (!previousNode && wrap) {
153
+ walker.currentNode = sentinel;
154
+ previousNode = walker.previousNode();
155
+ }
156
+ if (previousNode)
157
+ $9bf71ea28793e738$var$focusElement(previousNode, true);
158
+ return previousNode;
159
+ },
160
+ focusFirst(opts = {}) {
161
+ let scope = scopeRef.current;
162
+ let { tabbable, accept } = opts;
163
+ let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
164
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
165
+ tabbable,
166
+ accept
167
+ }, scope);
168
+ walker.currentNode = scope[0].previousElementSibling;
169
+ let nextNode = walker.nextNode();
170
+ if (nextNode)
171
+ $9bf71ea28793e738$var$focusElement(nextNode, true);
172
+ return nextNode;
173
+ },
174
+ focusLast(opts = {}) {
175
+ let scope = scopeRef.current;
176
+ let { tabbable, accept } = opts;
177
+ let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
178
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
179
+ tabbable,
180
+ accept
181
+ }, scope);
182
+ walker.currentNode = scope[scope.length - 1].nextElementSibling;
183
+ let previousNode = walker.previousNode();
184
+ if (previousNode)
185
+ $9bf71ea28793e738$var$focusElement(previousNode, true);
186
+ return previousNode;
187
+ }
188
+ };
189
+ }
190
+ const $9bf71ea28793e738$var$focusableElements = [
191
+ "input:not([disabled]):not([type=hidden])",
192
+ "select:not([disabled])",
193
+ "textarea:not([disabled])",
194
+ "button:not([disabled])",
195
+ "a[href]",
196
+ "area[href]",
197
+ "summary",
198
+ "iframe",
199
+ "object",
200
+ "embed",
201
+ "audio[controls]",
202
+ "video[controls]",
203
+ "[contenteditable]"
204
+ ];
205
+ const $9bf71ea28793e738$var$FOCUSABLE_ELEMENT_SELECTOR = $9bf71ea28793e738$var$focusableElements.join(":not([hidden]),") + ",[tabindex]:not([disabled]):not([hidden])";
206
+ $9bf71ea28793e738$var$focusableElements.push('[tabindex]:not([tabindex="-1"]):not([disabled])');
207
+ const $9bf71ea28793e738$var$TABBABLE_ELEMENT_SELECTOR = $9bf71ea28793e738$var$focusableElements.join(':not([hidden]):not([tabindex="-1"]),');
208
+ function $9bf71ea28793e738$var$getScopeRoot(scope) {
209
+ return scope[0].parentElement;
210
+ }
211
+ function $9bf71ea28793e738$var$shouldContainFocus(scopeRef) {
212
+ let scope = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode($9bf71ea28793e738$var$activeScope);
213
+ while (scope && scope.scopeRef !== scopeRef) {
214
+ if (scope.contain)
215
+ return false;
216
+ scope = scope.parent;
217
+ }
218
+ return true;
219
+ }
220
+ function $9bf71ea28793e738$var$useFocusContainment(scopeRef, contain) {
221
+ let focusedNode = useRef();
222
+ let raf = useRef();
223
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
224
+ let scope = scopeRef.current;
225
+ if (!contain) {
226
+ if (raf.current) {
227
+ cancelAnimationFrame(raf.current);
228
+ raf.current = void 0;
229
+ }
230
+ return;
231
+ }
232
+ const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(scope ? scope[0] : void 0);
233
+ let onKeyDown = (e) => {
234
+ if (e.key !== "Tab" || e.altKey || e.ctrlKey || e.metaKey || !$9bf71ea28793e738$var$shouldContainFocus(scopeRef) || e.isComposing)
235
+ return;
236
+ let focusedElement = ownerDocument.activeElement;
237
+ let scope2 = scopeRef.current;
238
+ if (!scope2 || !$9bf71ea28793e738$var$isElementInScope(focusedElement, scope2))
239
+ return;
240
+ let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope2);
241
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
242
+ tabbable: true
243
+ }, scope2);
244
+ if (!focusedElement)
245
+ return;
246
+ walker.currentNode = focusedElement;
247
+ let nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
248
+ if (!nextElement) {
249
+ walker.currentNode = e.shiftKey ? scope2[scope2.length - 1].nextElementSibling : scope2[0].previousElementSibling;
250
+ nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
251
+ }
252
+ e.preventDefault();
253
+ if (nextElement)
254
+ $9bf71ea28793e738$var$focusElement(nextElement, true);
255
+ };
256
+ let onFocus = (e) => {
257
+ if ((!$9bf71ea28793e738$var$activeScope || $9bf71ea28793e738$var$isAncestorScope($9bf71ea28793e738$var$activeScope, scopeRef)) && $9bf71ea28793e738$var$isElementInScope(e.target, scopeRef.current)) {
258
+ $9bf71ea28793e738$var$activeScope = scopeRef;
259
+ focusedNode.current = e.target;
260
+ } else if ($9bf71ea28793e738$var$shouldContainFocus(scopeRef) && !$9bf71ea28793e738$var$isElementInChildScope(e.target, scopeRef)) {
261
+ if (focusedNode.current)
262
+ focusedNode.current.focus();
263
+ else if ($9bf71ea28793e738$var$activeScope && $9bf71ea28793e738$var$activeScope.current)
264
+ $9bf71ea28793e738$var$focusFirstInScope($9bf71ea28793e738$var$activeScope.current);
265
+ } else if ($9bf71ea28793e738$var$shouldContainFocus(scopeRef))
266
+ focusedNode.current = e.target;
267
+ };
268
+ let onBlur = (e) => {
269
+ if (raf.current)
270
+ cancelAnimationFrame(raf.current);
271
+ raf.current = requestAnimationFrame(() => {
272
+ if (ownerDocument.activeElement && $9bf71ea28793e738$var$shouldContainFocus(scopeRef) && !$9bf71ea28793e738$var$isElementInChildScope(ownerDocument.activeElement, scopeRef)) {
273
+ $9bf71ea28793e738$var$activeScope = scopeRef;
274
+ if (ownerDocument.body.contains(e.target)) {
275
+ var _focusedNode_current;
276
+ focusedNode.current = e.target;
277
+ (_focusedNode_current = focusedNode.current) === null || _focusedNode_current === void 0 ? void 0 : _focusedNode_current.focus();
278
+ } else if ($9bf71ea28793e738$var$activeScope.current)
279
+ $9bf71ea28793e738$var$focusFirstInScope($9bf71ea28793e738$var$activeScope.current);
280
+ }
281
+ });
282
+ };
283
+ ownerDocument.addEventListener("keydown", onKeyDown, false);
284
+ ownerDocument.addEventListener("focusin", onFocus, false);
285
+ scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.addEventListener("focusin", onFocus, false));
286
+ scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.addEventListener("focusout", onBlur, false));
287
+ return () => {
288
+ ownerDocument.removeEventListener("keydown", onKeyDown, false);
289
+ ownerDocument.removeEventListener("focusin", onFocus, false);
290
+ scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.removeEventListener("focusin", onFocus, false));
291
+ scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.removeEventListener("focusout", onBlur, false));
292
+ };
293
+ }, [
294
+ scopeRef,
295
+ contain
296
+ ]);
297
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
298
+ return () => {
299
+ if (raf.current)
300
+ cancelAnimationFrame(raf.current);
301
+ };
302
+ }, [
303
+ raf
304
+ ]);
305
+ }
306
+ function $9bf71ea28793e738$var$isElementInAnyScope(element) {
307
+ return $9bf71ea28793e738$var$isElementInChildScope(element);
308
+ }
309
+ function $9bf71ea28793e738$var$isElementInScope(element, scope) {
310
+ if (!element)
311
+ return false;
312
+ if (!scope)
313
+ return false;
314
+ return scope.some((node) => node.contains(element));
315
+ }
316
+ function $9bf71ea28793e738$var$isElementInChildScope(element, scope = null) {
317
+ if (element instanceof Element && element.closest("[data-react-aria-top-layer]"))
318
+ return true;
319
+ for (let { scopeRef: s } of $9bf71ea28793e738$export$d06fae2ee68b101e.traverse($9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scope))) {
320
+ if (s && $9bf71ea28793e738$var$isElementInScope(element, s.current))
321
+ return true;
322
+ }
323
+ return false;
324
+ }
325
+ function $9bf71ea28793e738$export$1258395f99bf9cbf(element) {
326
+ return $9bf71ea28793e738$var$isElementInChildScope(element, $9bf71ea28793e738$var$activeScope);
327
+ }
328
+ function $9bf71ea28793e738$var$isAncestorScope(ancestor, scope) {
329
+ var _focusScopeTree_getTreeNode;
330
+ let parent = (_focusScopeTree_getTreeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scope)) === null || _focusScopeTree_getTreeNode === void 0 ? void 0 : _focusScopeTree_getTreeNode.parent;
331
+ while (parent) {
332
+ if (parent.scopeRef === ancestor)
333
+ return true;
334
+ parent = parent.parent;
335
+ }
336
+ return false;
337
+ }
338
+ function $9bf71ea28793e738$var$focusElement(element, scroll = false) {
339
+ if (element != null && !scroll)
340
+ try {
341
+ (0, $6a99195332edec8b$export$80f3e147d781571c)(element);
342
+ } catch (err) {
343
+ }
344
+ else if (element != null)
345
+ try {
346
+ element.focus();
347
+ } catch (err) {
348
+ }
349
+ }
350
+ function $9bf71ea28793e738$var$focusFirstInScope(scope, tabbable = true) {
351
+ let sentinel = scope[0].previousElementSibling;
352
+ let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
353
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
354
+ tabbable
355
+ }, scope);
356
+ walker.currentNode = sentinel;
357
+ let nextNode = walker.nextNode();
358
+ if (tabbable && !nextNode) {
359
+ scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
360
+ walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
361
+ tabbable: false
362
+ }, scope);
363
+ walker.currentNode = sentinel;
364
+ nextNode = walker.nextNode();
365
+ }
366
+ $9bf71ea28793e738$var$focusElement(nextNode);
367
+ }
368
+ function $9bf71ea28793e738$var$useAutoFocus(scopeRef, autoFocus) {
369
+ const autoFocusRef = React__default.useRef(autoFocus);
370
+ useEffect(() => {
371
+ if (autoFocusRef.current) {
372
+ $9bf71ea28793e738$var$activeScope = scopeRef;
373
+ const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(scopeRef.current ? scopeRef.current[0] : void 0);
374
+ if (!$9bf71ea28793e738$var$isElementInScope(ownerDocument.activeElement, $9bf71ea28793e738$var$activeScope.current) && scopeRef.current)
375
+ $9bf71ea28793e738$var$focusFirstInScope(scopeRef.current);
376
+ }
377
+ autoFocusRef.current = false;
378
+ }, [
379
+ scopeRef
380
+ ]);
381
+ }
382
+ function $9bf71ea28793e738$var$useActiveScopeTracker(scopeRef, restore, contain) {
383
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
384
+ if (restore || contain)
385
+ return;
386
+ let scope = scopeRef.current;
387
+ const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(scope ? scope[0] : void 0);
388
+ let onFocus = (e) => {
389
+ let target = e.target;
390
+ if ($9bf71ea28793e738$var$isElementInScope(target, scopeRef.current))
391
+ $9bf71ea28793e738$var$activeScope = scopeRef;
392
+ else if (!$9bf71ea28793e738$var$isElementInAnyScope(target))
393
+ $9bf71ea28793e738$var$activeScope = null;
394
+ };
395
+ ownerDocument.addEventListener("focusin", onFocus, false);
396
+ scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.addEventListener("focusin", onFocus, false));
397
+ return () => {
398
+ ownerDocument.removeEventListener("focusin", onFocus, false);
399
+ scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.removeEventListener("focusin", onFocus, false));
400
+ };
401
+ }, [
402
+ scopeRef,
403
+ restore,
404
+ contain
405
+ ]);
406
+ }
407
+ function $9bf71ea28793e738$var$shouldRestoreFocus(scopeRef) {
408
+ let scope = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode($9bf71ea28793e738$var$activeScope);
409
+ while (scope && scope.scopeRef !== scopeRef) {
410
+ if (scope.nodeToRestore)
411
+ return false;
412
+ scope = scope.parent;
413
+ }
414
+ return (scope === null || scope === void 0 ? void 0 : scope.scopeRef) === scopeRef;
415
+ }
416
+ function $9bf71ea28793e738$var$useRestoreFocus(scopeRef, restoreFocus, contain) {
417
+ const nodeToRestoreRef = useRef(typeof document !== "undefined" ? $431fbd86ca7dc216$export$b204af158042fbac(scopeRef.current ? scopeRef.current[0] : void 0).activeElement : null);
418
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
419
+ let scope = scopeRef.current;
420
+ const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(scope ? scope[0] : void 0);
421
+ if (!restoreFocus || contain)
422
+ return;
423
+ let onFocus = () => {
424
+ if ((!$9bf71ea28793e738$var$activeScope || $9bf71ea28793e738$var$isAncestorScope($9bf71ea28793e738$var$activeScope, scopeRef)) && $9bf71ea28793e738$var$isElementInScope(ownerDocument.activeElement, scopeRef.current))
425
+ $9bf71ea28793e738$var$activeScope = scopeRef;
426
+ };
427
+ ownerDocument.addEventListener("focusin", onFocus, false);
428
+ scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.addEventListener("focusin", onFocus, false));
429
+ return () => {
430
+ ownerDocument.removeEventListener("focusin", onFocus, false);
431
+ scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.removeEventListener("focusin", onFocus, false));
432
+ };
433
+ }, [
434
+ scopeRef,
435
+ contain
436
+ ]);
437
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
438
+ const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(scopeRef.current ? scopeRef.current[0] : void 0);
439
+ if (!restoreFocus)
440
+ return;
441
+ let onKeyDown = (e) => {
442
+ if (e.key !== "Tab" || e.altKey || e.ctrlKey || e.metaKey || !$9bf71ea28793e738$var$shouldContainFocus(scopeRef) || e.isComposing)
443
+ return;
444
+ let focusedElement = ownerDocument.activeElement;
445
+ if (!$9bf71ea28793e738$var$isElementInScope(focusedElement, scopeRef.current))
446
+ return;
447
+ let treeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef);
448
+ if (!treeNode)
449
+ return;
450
+ let nodeToRestore = treeNode.nodeToRestore;
451
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(ownerDocument.body, {
452
+ tabbable: true
453
+ });
454
+ walker.currentNode = focusedElement;
455
+ let nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
456
+ if (!nodeToRestore || !ownerDocument.body.contains(nodeToRestore) || nodeToRestore === ownerDocument.body) {
457
+ nodeToRestore = void 0;
458
+ treeNode.nodeToRestore = void 0;
459
+ }
460
+ if ((!nextElement || !$9bf71ea28793e738$var$isElementInScope(nextElement, scopeRef.current)) && nodeToRestore) {
461
+ walker.currentNode = nodeToRestore;
462
+ do
463
+ nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
464
+ while ($9bf71ea28793e738$var$isElementInScope(nextElement, scopeRef.current));
465
+ e.preventDefault();
466
+ e.stopPropagation();
467
+ if (nextElement)
468
+ $9bf71ea28793e738$var$focusElement(nextElement, true);
469
+ else if (!$9bf71ea28793e738$var$isElementInAnyScope(nodeToRestore))
470
+ focusedElement.blur();
471
+ else
472
+ $9bf71ea28793e738$var$focusElement(nodeToRestore, true);
473
+ }
474
+ };
475
+ if (!contain)
476
+ ownerDocument.addEventListener("keydown", onKeyDown, true);
477
+ return () => {
478
+ if (!contain)
479
+ ownerDocument.removeEventListener("keydown", onKeyDown, true);
480
+ };
481
+ }, [
482
+ scopeRef,
483
+ restoreFocus,
484
+ contain
485
+ ]);
486
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
487
+ const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(scopeRef.current ? scopeRef.current[0] : void 0);
488
+ if (!restoreFocus)
489
+ return;
490
+ let treeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef);
491
+ if (!treeNode)
492
+ return;
493
+ var _nodeToRestoreRef_current;
494
+ treeNode.nodeToRestore = (_nodeToRestoreRef_current = nodeToRestoreRef.current) !== null && _nodeToRestoreRef_current !== void 0 ? _nodeToRestoreRef_current : void 0;
495
+ return () => {
496
+ let treeNode2 = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef);
497
+ if (!treeNode2)
498
+ return;
499
+ let nodeToRestore = treeNode2.nodeToRestore;
500
+ if (restoreFocus && nodeToRestore && // eslint-disable-next-line react-hooks/exhaustive-deps
501
+ ($9bf71ea28793e738$var$isElementInScope(ownerDocument.activeElement, scopeRef.current) || ownerDocument.activeElement === ownerDocument.body && $9bf71ea28793e738$var$shouldRestoreFocus(scopeRef))) {
502
+ let clonedTree = $9bf71ea28793e738$export$d06fae2ee68b101e.clone();
503
+ requestAnimationFrame(() => {
504
+ if (ownerDocument.activeElement === ownerDocument.body) {
505
+ let treeNode3 = clonedTree.getTreeNode(scopeRef);
506
+ while (treeNode3) {
507
+ if (treeNode3.nodeToRestore && treeNode3.nodeToRestore.isConnected) {
508
+ $9bf71ea28793e738$var$focusElement(treeNode3.nodeToRestore);
509
+ return;
510
+ }
511
+ treeNode3 = treeNode3.parent;
512
+ }
513
+ treeNode3 = clonedTree.getTreeNode(scopeRef);
514
+ while (treeNode3) {
515
+ if (treeNode3.scopeRef && treeNode3.scopeRef.current && $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(treeNode3.scopeRef)) {
516
+ $9bf71ea28793e738$var$focusFirstInScope(treeNode3.scopeRef.current, true);
517
+ return;
518
+ }
519
+ treeNode3 = treeNode3.parent;
520
+ }
521
+ }
522
+ });
523
+ }
524
+ };
525
+ }, [
526
+ scopeRef,
527
+ restoreFocus
528
+ ]);
529
+ }
530
+ function $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, opts, scope) {
531
+ let selector = (opts === null || opts === void 0 ? void 0 : opts.tabbable) ? $9bf71ea28793e738$var$TABBABLE_ELEMENT_SELECTOR : $9bf71ea28793e738$var$FOCUSABLE_ELEMENT_SELECTOR;
532
+ let walker = $431fbd86ca7dc216$export$b204af158042fbac(root).createTreeWalker(root, NodeFilter.SHOW_ELEMENT, {
533
+ acceptNode(node) {
534
+ var _opts_from;
535
+ if (opts === null || opts === void 0 ? void 0 : (_opts_from = opts.from) === null || _opts_from === void 0 ? void 0 : _opts_from.contains(node))
536
+ return NodeFilter.FILTER_REJECT;
537
+ if (node.matches(selector) && $645f2e67b85a24c9$export$e989c0fffaa6b27a(node) && (!scope || $9bf71ea28793e738$var$isElementInScope(node, scope)) && (!(opts === null || opts === void 0 ? void 0 : opts.accept) || opts.accept(node)))
538
+ return NodeFilter.FILTER_ACCEPT;
539
+ return NodeFilter.FILTER_SKIP;
540
+ }
541
+ });
542
+ if (opts === null || opts === void 0 ? void 0 : opts.from)
543
+ walker.currentNode = opts.from;
544
+ return walker;
545
+ }
546
+ function $9bf71ea28793e738$export$c5251b9e124bf29(ref, defaultOptions = {}) {
547
+ return {
548
+ focusNext(opts = {}) {
549
+ let root = ref.current;
550
+ if (!root)
551
+ return null;
552
+ let { from, tabbable = defaultOptions.tabbable, wrap = defaultOptions.wrap, accept = defaultOptions.accept } = opts;
553
+ let node = from || $431fbd86ca7dc216$export$b204af158042fbac(root).activeElement;
554
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
555
+ tabbable,
556
+ accept
557
+ });
558
+ if (root.contains(node))
559
+ walker.currentNode = node;
560
+ let nextNode = walker.nextNode();
561
+ if (!nextNode && wrap) {
562
+ walker.currentNode = root;
563
+ nextNode = walker.nextNode();
564
+ }
565
+ if (nextNode)
566
+ $9bf71ea28793e738$var$focusElement(nextNode, true);
567
+ return nextNode;
568
+ },
569
+ focusPrevious(opts = defaultOptions) {
570
+ let root = ref.current;
571
+ if (!root)
572
+ return null;
573
+ let { from, tabbable = defaultOptions.tabbable, wrap = defaultOptions.wrap, accept = defaultOptions.accept } = opts;
574
+ let node = from || $431fbd86ca7dc216$export$b204af158042fbac(root).activeElement;
575
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
576
+ tabbable,
577
+ accept
578
+ });
579
+ if (root.contains(node))
580
+ walker.currentNode = node;
581
+ else {
582
+ let next = $9bf71ea28793e738$var$last(walker);
583
+ if (next)
584
+ $9bf71ea28793e738$var$focusElement(next, true);
585
+ return next !== null && next !== void 0 ? next : null;
586
+ }
587
+ let previousNode = walker.previousNode();
588
+ if (!previousNode && wrap) {
589
+ walker.currentNode = root;
590
+ let lastNode = $9bf71ea28793e738$var$last(walker);
591
+ if (!lastNode)
592
+ return null;
593
+ previousNode = lastNode;
594
+ }
595
+ if (previousNode)
596
+ $9bf71ea28793e738$var$focusElement(previousNode, true);
597
+ return previousNode !== null && previousNode !== void 0 ? previousNode : null;
598
+ },
599
+ focusFirst(opts = defaultOptions) {
600
+ let root = ref.current;
601
+ if (!root)
602
+ return null;
603
+ let { tabbable = defaultOptions.tabbable, accept = defaultOptions.accept } = opts;
604
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
605
+ tabbable,
606
+ accept
607
+ });
608
+ let nextNode = walker.nextNode();
609
+ if (nextNode)
610
+ $9bf71ea28793e738$var$focusElement(nextNode, true);
611
+ return nextNode;
612
+ },
613
+ focusLast(opts = defaultOptions) {
614
+ let root = ref.current;
615
+ if (!root)
616
+ return null;
617
+ let { tabbable = defaultOptions.tabbable, accept = defaultOptions.accept } = opts;
618
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
619
+ tabbable,
620
+ accept
621
+ });
622
+ let next = $9bf71ea28793e738$var$last(walker);
623
+ if (next)
624
+ $9bf71ea28793e738$var$focusElement(next, true);
625
+ return next !== null && next !== void 0 ? next : null;
626
+ }
627
+ };
628
+ }
629
+ function $9bf71ea28793e738$var$last(walker) {
630
+ let next = void 0;
631
+ let last;
632
+ do {
633
+ last = walker.lastChild();
634
+ if (last)
635
+ next = last;
636
+ } while (last);
637
+ return next;
638
+ }
639
+ class $9bf71ea28793e738$var$Tree {
640
+ get size() {
641
+ return this.fastMap.size;
642
+ }
643
+ getTreeNode(data) {
644
+ return this.fastMap.get(data);
645
+ }
646
+ addTreeNode(scopeRef, parent, nodeToRestore) {
647
+ let parentNode = this.fastMap.get(parent !== null && parent !== void 0 ? parent : null);
648
+ if (!parentNode)
649
+ return;
650
+ let node = new $9bf71ea28793e738$var$TreeNode({
651
+ scopeRef
652
+ });
653
+ parentNode.addChild(node);
654
+ node.parent = parentNode;
655
+ this.fastMap.set(scopeRef, node);
656
+ if (nodeToRestore)
657
+ node.nodeToRestore = nodeToRestore;
658
+ }
659
+ addNode(node) {
660
+ this.fastMap.set(node.scopeRef, node);
661
+ }
662
+ removeTreeNode(scopeRef) {
663
+ if (scopeRef === null)
664
+ return;
665
+ let node = this.fastMap.get(scopeRef);
666
+ if (!node)
667
+ return;
668
+ let parentNode = node.parent;
669
+ for (let current of this.traverse())
670
+ if (current !== node && node.nodeToRestore && current.nodeToRestore && node.scopeRef && node.scopeRef.current && $9bf71ea28793e738$var$isElementInScope(current.nodeToRestore, node.scopeRef.current))
671
+ current.nodeToRestore = node.nodeToRestore;
672
+ let children = node.children;
673
+ if (parentNode) {
674
+ parentNode.removeChild(node);
675
+ if (children.size > 0)
676
+ children.forEach((child) => parentNode && parentNode.addChild(child));
677
+ }
678
+ this.fastMap.delete(node.scopeRef);
679
+ }
680
+ // Pre Order Depth First
681
+ *traverse(node = this.root) {
682
+ if (node.scopeRef != null)
683
+ yield node;
684
+ if (node.children.size > 0)
685
+ for (let child of node.children)
686
+ yield* this.traverse(child);
687
+ }
688
+ clone() {
689
+ var _node_parent;
690
+ let newTree = new $9bf71ea28793e738$var$Tree();
691
+ var _node_parent_scopeRef;
692
+ for (let node of this.traverse())
693
+ newTree.addTreeNode(node.scopeRef, (_node_parent_scopeRef = (_node_parent = node.parent) === null || _node_parent === void 0 ? void 0 : _node_parent.scopeRef) !== null && _node_parent_scopeRef !== void 0 ? _node_parent_scopeRef : null, node.nodeToRestore);
694
+ return newTree;
695
+ }
696
+ constructor() {
697
+ this.fastMap = /* @__PURE__ */ new Map();
698
+ this.root = new $9bf71ea28793e738$var$TreeNode({
699
+ scopeRef: null
700
+ });
701
+ this.fastMap.set(null, this.root);
702
+ }
703
+ }
704
+ class $9bf71ea28793e738$var$TreeNode {
705
+ addChild(node) {
706
+ this.children.add(node);
707
+ node.parent = this;
708
+ }
709
+ removeChild(node) {
710
+ this.children.delete(node);
711
+ node.parent = void 0;
712
+ }
713
+ constructor(props) {
714
+ this.children = /* @__PURE__ */ new Set();
715
+ this.contain = false;
716
+ this.scopeRef = props.scopeRef;
717
+ }
718
+ }
719
+ let $9bf71ea28793e738$export$d06fae2ee68b101e = new $9bf71ea28793e738$var$Tree();
720
+ export {
721
+ $9bf71ea28793e738$export$20e40289641fbbb6 as $,
722
+ $9bf71ea28793e738$export$2d6ec8fc375ceafa as a,
723
+ $9bf71ea28793e738$export$c5251b9e124bf29 as b,
724
+ $9bf71ea28793e738$export$1258395f99bf9cbf as c
725
+ };