@preply/ds-web-lib 3.5.0 → 3.5.2-beta.8e09f17aa4de23f74af5a6d4df8099acd8f3d3af.0
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.
- package/dist/ChipsPrimitive-DN5NA2yH.js +1242 -0
- package/dist/assets/Accordion.css +2 -2
- package/dist/assets/AlertDialog.css +2 -2
- package/dist/assets/Avatar.css +3 -3
- package/dist/assets/AvatarWithStatus.css +2 -2
- package/dist/assets/Badge.css +3 -3
- package/dist/assets/Box.css +3 -3
- package/dist/assets/Button.css +4 -4
- package/dist/assets/ButtonBase.css +4 -4
- package/dist/assets/Checkbox.css +2 -2
- package/dist/assets/Chips.css +16 -16
- package/dist/assets/ChipsPrimitive.css +118 -0
- package/dist/assets/CountryFlag.css +1 -1
- package/dist/assets/Dialog.css +5 -4
- package/dist/assets/Divider.css +14 -0
- package/dist/assets/FieldButton.css +3 -3
- package/dist/assets/FormControl.css +2 -2
- package/dist/assets/Heading.css +3 -3
- package/dist/assets/Icon.css +3 -3
- package/dist/assets/InputContainer.css +2 -2
- package/dist/assets/LayoutFlex.css +1 -1
- package/dist/assets/LayoutFlexItem.css +1 -1
- package/dist/assets/Link.css +3 -3
- package/dist/assets/Loader.css +1 -1
- package/dist/assets/OnboardingTooltip.css +1 -1
- package/dist/assets/OnboardingTour.css +1 -1
- package/dist/assets/PreplyLogo.css +1 -1
- package/dist/assets/ProgressBar.css +1 -1
- package/dist/assets/ProgressSteps.css +1 -1
- package/dist/assets/Rating.css +136 -0
- package/dist/assets/Slider.css +1 -1
- package/dist/assets/Spinner.css +3 -3
- package/dist/assets/Steps.css +1 -1
- package/dist/assets/Switch.css +57 -0
- package/dist/assets/Text.css +3 -3
- package/dist/assets/TextHighlighted.css +3 -3
- package/dist/assets/TextInline.css +3 -3
- package/dist/assets/Toast.css +2 -2
- package/dist/assets/Tooltip.css +1 -1
- package/dist/assets/VisuallyHidden.css +9 -0
- package/dist/assets/align-self.css +1 -1
- package/dist/assets/color.css +2 -2
- package/dist/assets/exp-color.css +2 -2
- package/dist/assets/layout-gap.css +3 -3
- package/dist/assets/layout-grid.css +3 -3
- package/dist/assets/layout-hide.css +1 -1
- package/dist/assets/layout-padding.css +3 -3
- package/dist/assets/layout-relative.css +1 -1
- package/dist/assets/text-accent.css +2 -2
- package/dist/assets/text-centered.css +1 -1
- package/dist/assets/text-weight.css +2 -2
- package/dist/components/Accordion/Accordion.js +1 -1
- package/dist/components/Chips/Chips.types.d.ts +38 -0
- package/dist/components/Chips/Chips.types.d.ts.map +1 -0
- package/dist/components/Chips/DismissibleChips.d.ts +48 -0
- package/dist/components/Chips/DismissibleChips.d.ts.map +1 -0
- package/dist/components/Chips/DismissibleChips.js +92 -0
- package/dist/components/Chips/MultiSelectChips.d.ts +45 -0
- package/dist/components/Chips/MultiSelectChips.d.ts.map +1 -0
- package/dist/components/Chips/MultiSelectChips.js +70 -0
- package/dist/components/Chips/SingleSelectChips.d.ts +45 -0
- package/dist/components/Chips/SingleSelectChips.d.ts.map +1 -0
- package/dist/components/Chips/SingleSelectChips.js +63 -0
- package/dist/components/Chips/private/ChipsPrimitive.d.ts +58 -0
- package/dist/components/Chips/private/ChipsPrimitive.d.ts.map +1 -0
- package/dist/components/Chips/private/ChipsPrimitive.js +17 -0
- package/dist/components/CountryFlag/CountryFlag.d.ts +3 -4
- package/dist/components/CountryFlag/CountryFlag.d.ts.map +1 -1
- package/dist/components/CountryFlag/CountryFlag.js +6 -6
- package/dist/components/Divider/Divider.d.ts +9 -0
- package/dist/components/Divider/Divider.d.ts.map +1 -0
- package/dist/components/Divider/Divider.js +14 -0
- package/dist/components/FormControl/FormControl.d.ts +2 -1
- package/dist/components/FormControl/FormControl.d.ts.map +1 -1
- package/dist/components/FormControl/FormControl.js +6 -2
- package/dist/components/Rating/Rating.d.ts +90 -0
- package/dist/components/Rating/Rating.d.ts.map +1 -0
- package/dist/components/Rating/Rating.js +126 -0
- package/dist/components/Switch/Switch.d.ts +62 -0
- package/dist/components/Switch/Switch.d.ts.map +1 -0
- package/dist/components/Switch/Switch.js +51 -0
- package/dist/components/{Chips → deprecated/Chips}/Chips.d.ts +9 -1
- package/dist/components/deprecated/Chips/Chips.d.ts.map +1 -0
- package/dist/components/{Chips → deprecated/Chips}/Chips.js +7 -7
- package/dist/components/deprecated/index.d.ts +2 -0
- package/dist/components/deprecated/index.d.ts.map +1 -0
- package/dist/components/deprecated/index.js +4 -0
- package/dist/components/index.d.ts +5 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +13 -2
- package/dist/components/private/VisuallyHidden/VisuallyHidden.d.ts +23 -0
- package/dist/components/private/VisuallyHidden/VisuallyHidden.d.ts.map +1 -0
- package/dist/components/private/VisuallyHidden/VisuallyHidden.js +15 -0
- package/dist/index.js +13 -2
- package/dist/utils/Orientation/OrientationProvider.d.ts +45 -0
- package/dist/utils/Orientation/OrientationProvider.d.ts.map +1 -0
- package/dist/utils/Orientation/OrientationProvider.js +27 -0
- package/dist/utils/Orientation/index.d.ts +2 -0
- package/dist/utils/Orientation/index.d.ts.map +1 -0
- package/dist/utils/Orientation/index.js +5 -0
- package/dist/utils/RovingTabIndex/RovingTabIndexProvider.d.ts +45 -0
- package/dist/utils/RovingTabIndex/RovingTabIndexProvider.d.ts.map +1 -0
- package/dist/utils/RovingTabIndex/RovingTabIndexProvider.js +48 -0
- package/dist/utils/RovingTabIndex/index.d.ts +2 -0
- package/dist/utils/RovingTabIndex/index.d.ts.map +1 -0
- package/dist/utils/RovingTabIndex/index.js +5 -0
- package/dist/utils/createRequiredContext.d.ts +15 -0
- package/dist/utils/createRequiredContext.d.ts.map +1 -0
- package/dist/utils/createRequiredContext.js +16 -0
- package/dist/utils/useControllableState/useControllableState.d.ts +19 -0
- package/dist/utils/useControllableState/useControllableState.d.ts.map +1 -0
- package/dist/utils/useControllableState/useControllableState.js +27 -0
- package/dist/utils/useStableCallback/useStableCallback.d.ts +18 -0
- package/dist/utils/useStableCallback/useStableCallback.d.ts.map +1 -0
- package/dist/utils/useStableCallback/useStableCallback.js +15 -0
- package/package.json +14 -13
- package/dist/components/Chips/Chips.d.ts.map +0 -1
- package/dist/components/CountryFlag/types.d.ts +0 -3
- package/dist/components/CountryFlag/types.d.ts.map +0 -1
- package/dist/components/CountryFlag/utils/countries.d.ts +0 -276
- package/dist/components/CountryFlag/utils/countries.d.ts.map +0 -1
- package/dist/components/CountryFlag/utils/countries.js +0 -275
- package/dist/components/CountryFlag/utils/getCountryFlagUrl.d.ts +0 -7
- package/dist/components/CountryFlag/utils/getCountryFlagUrl.d.ts.map +0 -1
- package/dist/components/CountryFlag/utils/getCountryFlagUrl.js +0 -14
- /package/dist/components/{CountryFlag/types.js → Chips/Chips.types.js} +0 -0
@@ -0,0 +1,1242 @@
|
|
1
|
+
"use client";
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
3
|
+
import o__default, { useRef, useContext, useMemo, useEffect, forwardRef } from "react";
|
4
|
+
import { useRovingTabIndex, RovingTabIndexProvider } from "./utils/RovingTabIndex/RovingTabIndexProvider.js";
|
5
|
+
import { Icon } from "./components/Icon/Icon.js";
|
6
|
+
import { useOrientation, OrientationProvider } from "./utils/Orientation/OrientationProvider.js";
|
7
|
+
import { CountryFlag } from "./components/CountryFlag/CountryFlag.js";
|
8
|
+
import { useMergeRefs } from "@preply/ds-core";
|
9
|
+
import './assets/ChipsPrimitive.css';const $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c = typeof document !== "undefined" ? o__default.useLayoutEffect : () => {
|
10
|
+
};
|
11
|
+
const $431fbd86ca7dc216$export$b204af158042fbac = (el) => {
|
12
|
+
var _el_ownerDocument;
|
13
|
+
return (_el_ownerDocument = el === null || el === void 0 ? void 0 : el.ownerDocument) !== null && _el_ownerDocument !== void 0 ? _el_ownerDocument : document;
|
14
|
+
};
|
15
|
+
const $431fbd86ca7dc216$export$f21a1ffae260145a = (el) => {
|
16
|
+
if (el && "window" in el && el.window === el) return el;
|
17
|
+
const doc = $431fbd86ca7dc216$export$b204af158042fbac(el);
|
18
|
+
return doc.defaultView || window;
|
19
|
+
};
|
20
|
+
function $431fbd86ca7dc216$var$isNode(value) {
|
21
|
+
return value !== null && typeof value === "object" && "nodeType" in value && typeof value.nodeType === "number";
|
22
|
+
}
|
23
|
+
function $431fbd86ca7dc216$export$af51f0f06c0f328a(node) {
|
24
|
+
return $431fbd86ca7dc216$var$isNode(node) && node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && "host" in node;
|
25
|
+
}
|
26
|
+
let $f4e2df6bd15f8569$var$_shadowDOM = false;
|
27
|
+
function $f4e2df6bd15f8569$export$98658e8c59125e6a() {
|
28
|
+
return $f4e2df6bd15f8569$var$_shadowDOM;
|
29
|
+
}
|
30
|
+
function $d4ee10de306f2510$export$4282f70798064fe0(node, otherNode) {
|
31
|
+
if (!$f4e2df6bd15f8569$export$98658e8c59125e6a()) return otherNode && node ? node.contains(otherNode) : false;
|
32
|
+
if (!node || !otherNode) return false;
|
33
|
+
let currentNode = otherNode;
|
34
|
+
while (currentNode !== null) {
|
35
|
+
if (currentNode === node) return true;
|
36
|
+
if (currentNode.tagName === "SLOT" && currentNode.assignedSlot)
|
37
|
+
currentNode = currentNode.assignedSlot.parentNode;
|
38
|
+
else if ($431fbd86ca7dc216$export$af51f0f06c0f328a(currentNode))
|
39
|
+
currentNode = currentNode.host;
|
40
|
+
else currentNode = currentNode.parentNode;
|
41
|
+
}
|
42
|
+
return false;
|
43
|
+
}
|
44
|
+
const $d4ee10de306f2510$export$cd4e5573fbe2b576 = (doc = document) => {
|
45
|
+
var _activeElement_shadowRoot;
|
46
|
+
if (!$f4e2df6bd15f8569$export$98658e8c59125e6a()) return doc.activeElement;
|
47
|
+
let activeElement = doc.activeElement;
|
48
|
+
while (activeElement && "shadowRoot" in activeElement && ((_activeElement_shadowRoot = activeElement.shadowRoot) === null || _activeElement_shadowRoot === void 0 ? void 0 : _activeElement_shadowRoot.activeElement)) activeElement = activeElement.shadowRoot.activeElement;
|
49
|
+
return activeElement;
|
50
|
+
};
|
51
|
+
function $d4ee10de306f2510$export$e58f029f0fbfdb29(event) {
|
52
|
+
if ($f4e2df6bd15f8569$export$98658e8c59125e6a() && event.target.shadowRoot) {
|
53
|
+
if (event.composedPath) return event.composedPath()[0];
|
54
|
+
}
|
55
|
+
return event.target;
|
56
|
+
}
|
57
|
+
class $dfc540311bf7f109$export$63eb3ababa9c55c4 {
|
58
|
+
get currentNode() {
|
59
|
+
return this._currentNode;
|
60
|
+
}
|
61
|
+
set currentNode(node) {
|
62
|
+
if (!$d4ee10de306f2510$export$4282f70798064fe0(this.root, node)) throw new Error("Cannot set currentNode to a node that is not contained by the root node.");
|
63
|
+
const walkers = [];
|
64
|
+
let curNode = node;
|
65
|
+
let currentWalkerCurrentNode = node;
|
66
|
+
this._currentNode = node;
|
67
|
+
while (curNode && curNode !== this.root) if (curNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
68
|
+
const shadowRoot = curNode;
|
69
|
+
const walker2 = this._doc.createTreeWalker(shadowRoot, this.whatToShow, {
|
70
|
+
acceptNode: this._acceptNode
|
71
|
+
});
|
72
|
+
walkers.push(walker2);
|
73
|
+
walker2.currentNode = currentWalkerCurrentNode;
|
74
|
+
this._currentSetFor.add(walker2);
|
75
|
+
curNode = currentWalkerCurrentNode = shadowRoot.host;
|
76
|
+
} else curNode = curNode.parentNode;
|
77
|
+
const walker = this._doc.createTreeWalker(this.root, this.whatToShow, {
|
78
|
+
acceptNode: this._acceptNode
|
79
|
+
});
|
80
|
+
walkers.push(walker);
|
81
|
+
walker.currentNode = currentWalkerCurrentNode;
|
82
|
+
this._currentSetFor.add(walker);
|
83
|
+
this._walkerStack = walkers;
|
84
|
+
}
|
85
|
+
get doc() {
|
86
|
+
return this._doc;
|
87
|
+
}
|
88
|
+
firstChild() {
|
89
|
+
let currentNode = this.currentNode;
|
90
|
+
let newNode = this.nextNode();
|
91
|
+
if (!$d4ee10de306f2510$export$4282f70798064fe0(currentNode, newNode)) {
|
92
|
+
this.currentNode = currentNode;
|
93
|
+
return null;
|
94
|
+
}
|
95
|
+
if (newNode) this.currentNode = newNode;
|
96
|
+
return newNode;
|
97
|
+
}
|
98
|
+
lastChild() {
|
99
|
+
let walker = this._walkerStack[0];
|
100
|
+
let newNode = walker.lastChild();
|
101
|
+
if (newNode) this.currentNode = newNode;
|
102
|
+
return newNode;
|
103
|
+
}
|
104
|
+
nextNode() {
|
105
|
+
const nextNode = this._walkerStack[0].nextNode();
|
106
|
+
if (nextNode) {
|
107
|
+
const shadowRoot = nextNode.shadowRoot;
|
108
|
+
if (shadowRoot) {
|
109
|
+
var _this_filter;
|
110
|
+
let nodeResult;
|
111
|
+
if (typeof this.filter === "function") nodeResult = this.filter(nextNode);
|
112
|
+
else if ((_this_filter = this.filter) === null || _this_filter === void 0 ? void 0 : _this_filter.acceptNode) nodeResult = this.filter.acceptNode(nextNode);
|
113
|
+
if (nodeResult === NodeFilter.FILTER_ACCEPT) {
|
114
|
+
this.currentNode = nextNode;
|
115
|
+
return nextNode;
|
116
|
+
}
|
117
|
+
let newNode = this.nextNode();
|
118
|
+
if (newNode) this.currentNode = newNode;
|
119
|
+
return newNode;
|
120
|
+
}
|
121
|
+
if (nextNode) this.currentNode = nextNode;
|
122
|
+
return nextNode;
|
123
|
+
} else {
|
124
|
+
if (this._walkerStack.length > 1) {
|
125
|
+
this._walkerStack.shift();
|
126
|
+
let newNode = this.nextNode();
|
127
|
+
if (newNode) this.currentNode = newNode;
|
128
|
+
return newNode;
|
129
|
+
} else return null;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
previousNode() {
|
133
|
+
const currentWalker = this._walkerStack[0];
|
134
|
+
if (currentWalker.currentNode === currentWalker.root) {
|
135
|
+
if (this._currentSetFor.has(currentWalker)) {
|
136
|
+
this._currentSetFor.delete(currentWalker);
|
137
|
+
if (this._walkerStack.length > 1) {
|
138
|
+
this._walkerStack.shift();
|
139
|
+
let newNode = this.previousNode();
|
140
|
+
if (newNode) this.currentNode = newNode;
|
141
|
+
return newNode;
|
142
|
+
} else return null;
|
143
|
+
}
|
144
|
+
return null;
|
145
|
+
}
|
146
|
+
const previousNode = currentWalker.previousNode();
|
147
|
+
if (previousNode) {
|
148
|
+
const shadowRoot = previousNode.shadowRoot;
|
149
|
+
if (shadowRoot) {
|
150
|
+
var _this_filter;
|
151
|
+
let nodeResult;
|
152
|
+
if (typeof this.filter === "function") nodeResult = this.filter(previousNode);
|
153
|
+
else if ((_this_filter = this.filter) === null || _this_filter === void 0 ? void 0 : _this_filter.acceptNode) nodeResult = this.filter.acceptNode(previousNode);
|
154
|
+
if (nodeResult === NodeFilter.FILTER_ACCEPT) {
|
155
|
+
if (previousNode) this.currentNode = previousNode;
|
156
|
+
return previousNode;
|
157
|
+
}
|
158
|
+
let newNode = this.lastChild();
|
159
|
+
if (newNode) this.currentNode = newNode;
|
160
|
+
return newNode;
|
161
|
+
}
|
162
|
+
if (previousNode) this.currentNode = previousNode;
|
163
|
+
return previousNode;
|
164
|
+
} else {
|
165
|
+
if (this._walkerStack.length > 1) {
|
166
|
+
this._walkerStack.shift();
|
167
|
+
let newNode = this.previousNode();
|
168
|
+
if (newNode) this.currentNode = newNode;
|
169
|
+
return newNode;
|
170
|
+
} else return null;
|
171
|
+
}
|
172
|
+
}
|
173
|
+
/**
|
174
|
+
* @deprecated
|
175
|
+
*/
|
176
|
+
nextSibling() {
|
177
|
+
return null;
|
178
|
+
}
|
179
|
+
/**
|
180
|
+
* @deprecated
|
181
|
+
*/
|
182
|
+
previousSibling() {
|
183
|
+
return null;
|
184
|
+
}
|
185
|
+
/**
|
186
|
+
* @deprecated
|
187
|
+
*/
|
188
|
+
parentNode() {
|
189
|
+
return null;
|
190
|
+
}
|
191
|
+
constructor(doc, root, whatToShow, filter) {
|
192
|
+
this._walkerStack = [];
|
193
|
+
this._currentSetFor = /* @__PURE__ */ new Set();
|
194
|
+
this._acceptNode = (node) => {
|
195
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
196
|
+
const shadowRoot2 = node.shadowRoot;
|
197
|
+
if (shadowRoot2) {
|
198
|
+
const walker = this._doc.createTreeWalker(shadowRoot2, this.whatToShow, {
|
199
|
+
acceptNode: this._acceptNode
|
200
|
+
});
|
201
|
+
this._walkerStack.unshift(walker);
|
202
|
+
return NodeFilter.FILTER_ACCEPT;
|
203
|
+
} else {
|
204
|
+
var _this_filter;
|
205
|
+
if (typeof this.filter === "function") return this.filter(node);
|
206
|
+
else if ((_this_filter = this.filter) === null || _this_filter === void 0 ? void 0 : _this_filter.acceptNode) return this.filter.acceptNode(node);
|
207
|
+
else if (this.filter === null) return NodeFilter.FILTER_ACCEPT;
|
208
|
+
}
|
209
|
+
}
|
210
|
+
return NodeFilter.FILTER_SKIP;
|
211
|
+
};
|
212
|
+
this._doc = doc;
|
213
|
+
this.root = root;
|
214
|
+
this.filter = filter !== null && filter !== void 0 ? filter : null;
|
215
|
+
this.whatToShow = whatToShow !== null && whatToShow !== void 0 ? whatToShow : NodeFilter.SHOW_ALL;
|
216
|
+
this._currentNode = root;
|
217
|
+
this._walkerStack.unshift(doc.createTreeWalker(root, whatToShow, this._acceptNode));
|
218
|
+
const shadowRoot = root.shadowRoot;
|
219
|
+
if (shadowRoot) {
|
220
|
+
const walker = this._doc.createTreeWalker(shadowRoot, this.whatToShow, {
|
221
|
+
acceptNode: this._acceptNode
|
222
|
+
});
|
223
|
+
this._walkerStack.unshift(walker);
|
224
|
+
}
|
225
|
+
}
|
226
|
+
}
|
227
|
+
function $dfc540311bf7f109$export$4d0f8be8b12a7ef6(doc, root, whatToShow, filter) {
|
228
|
+
if ($f4e2df6bd15f8569$export$98658e8c59125e6a()) return new $dfc540311bf7f109$export$63eb3ababa9c55c4(doc, root, whatToShow, filter);
|
229
|
+
return doc.createTreeWalker(root, whatToShow, filter);
|
230
|
+
}
|
231
|
+
function $7215afc6de606d6b$export$de79e2c695e052f3(element) {
|
232
|
+
if ($7215afc6de606d6b$var$supportsPreventScroll()) element.focus({
|
233
|
+
preventScroll: true
|
234
|
+
});
|
235
|
+
else {
|
236
|
+
let scrollableElements = $7215afc6de606d6b$var$getScrollableElements(element);
|
237
|
+
element.focus();
|
238
|
+
$7215afc6de606d6b$var$restoreScrollPosition(scrollableElements);
|
239
|
+
}
|
240
|
+
}
|
241
|
+
let $7215afc6de606d6b$var$supportsPreventScrollCached = null;
|
242
|
+
function $7215afc6de606d6b$var$supportsPreventScroll() {
|
243
|
+
if ($7215afc6de606d6b$var$supportsPreventScrollCached == null) {
|
244
|
+
$7215afc6de606d6b$var$supportsPreventScrollCached = false;
|
245
|
+
try {
|
246
|
+
let focusElem = document.createElement("div");
|
247
|
+
focusElem.focus({
|
248
|
+
get preventScroll() {
|
249
|
+
$7215afc6de606d6b$var$supportsPreventScrollCached = true;
|
250
|
+
return true;
|
251
|
+
}
|
252
|
+
});
|
253
|
+
} catch {
|
254
|
+
}
|
255
|
+
}
|
256
|
+
return $7215afc6de606d6b$var$supportsPreventScrollCached;
|
257
|
+
}
|
258
|
+
function $7215afc6de606d6b$var$getScrollableElements(element) {
|
259
|
+
let parent = element.parentNode;
|
260
|
+
let scrollableElements = [];
|
261
|
+
let rootScrollingElement = document.scrollingElement || document.documentElement;
|
262
|
+
while (parent instanceof HTMLElement && parent !== rootScrollingElement) {
|
263
|
+
if (parent.offsetHeight < parent.scrollHeight || parent.offsetWidth < parent.scrollWidth) scrollableElements.push({
|
264
|
+
element: parent,
|
265
|
+
scrollTop: parent.scrollTop,
|
266
|
+
scrollLeft: parent.scrollLeft
|
267
|
+
});
|
268
|
+
parent = parent.parentNode;
|
269
|
+
}
|
270
|
+
if (rootScrollingElement instanceof HTMLElement) scrollableElements.push({
|
271
|
+
element: rootScrollingElement,
|
272
|
+
scrollTop: rootScrollingElement.scrollTop,
|
273
|
+
scrollLeft: rootScrollingElement.scrollLeft
|
274
|
+
});
|
275
|
+
return scrollableElements;
|
276
|
+
}
|
277
|
+
function $7215afc6de606d6b$var$restoreScrollPosition(scrollableElements) {
|
278
|
+
for (let { element, scrollTop, scrollLeft } of scrollableElements) {
|
279
|
+
element.scrollTop = scrollTop;
|
280
|
+
element.scrollLeft = scrollLeft;
|
281
|
+
}
|
282
|
+
}
|
283
|
+
function $c87311424ea30a05$var$testUserAgent(re) {
|
284
|
+
var _window_navigator_userAgentData;
|
285
|
+
if (typeof window === "undefined" || window.navigator == null) return false;
|
286
|
+
let brands = (_window_navigator_userAgentData = window.navigator["userAgentData"]) === null || _window_navigator_userAgentData === void 0 ? void 0 : _window_navigator_userAgentData.brands;
|
287
|
+
return Array.isArray(brands) && brands.some((brand) => re.test(brand.brand)) || re.test(window.navigator.userAgent);
|
288
|
+
}
|
289
|
+
function $c87311424ea30a05$var$testPlatform(re) {
|
290
|
+
var _window_navigator_userAgentData;
|
291
|
+
return typeof window !== "undefined" && window.navigator != null ? re.test(((_window_navigator_userAgentData = window.navigator["userAgentData"]) === null || _window_navigator_userAgentData === void 0 ? void 0 : _window_navigator_userAgentData.platform) || window.navigator.platform) : false;
|
292
|
+
}
|
293
|
+
function $c87311424ea30a05$var$cached(fn) {
|
294
|
+
if (process.env.NODE_ENV === "test") return fn;
|
295
|
+
let res = null;
|
296
|
+
return () => {
|
297
|
+
if (res == null) res = fn();
|
298
|
+
return res;
|
299
|
+
};
|
300
|
+
}
|
301
|
+
const $c87311424ea30a05$export$9ac100e40613ea10 = $c87311424ea30a05$var$cached(function() {
|
302
|
+
return $c87311424ea30a05$var$testPlatform(/^Mac/i);
|
303
|
+
});
|
304
|
+
const $c87311424ea30a05$export$186c6964ca17d99 = $c87311424ea30a05$var$cached(function() {
|
305
|
+
return $c87311424ea30a05$var$testPlatform(/^iPhone/i);
|
306
|
+
});
|
307
|
+
const $c87311424ea30a05$export$7bef049ce92e4224 = $c87311424ea30a05$var$cached(function() {
|
308
|
+
return $c87311424ea30a05$var$testPlatform(/^iPad/i) || // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
|
309
|
+
$c87311424ea30a05$export$9ac100e40613ea10() && navigator.maxTouchPoints > 1;
|
310
|
+
});
|
311
|
+
const $c87311424ea30a05$export$fedb369cb70207f1 = $c87311424ea30a05$var$cached(function() {
|
312
|
+
return $c87311424ea30a05$export$186c6964ca17d99() || $c87311424ea30a05$export$7bef049ce92e4224();
|
313
|
+
});
|
314
|
+
$c87311424ea30a05$var$cached(function() {
|
315
|
+
return $c87311424ea30a05$export$9ac100e40613ea10() || $c87311424ea30a05$export$fedb369cb70207f1();
|
316
|
+
});
|
317
|
+
$c87311424ea30a05$var$cached(function() {
|
318
|
+
return $c87311424ea30a05$var$testUserAgent(/AppleWebKit/i) && !$c87311424ea30a05$export$6446a186d09e379e();
|
319
|
+
});
|
320
|
+
const $c87311424ea30a05$export$6446a186d09e379e = $c87311424ea30a05$var$cached(function() {
|
321
|
+
return $c87311424ea30a05$var$testUserAgent(/Chrome/i);
|
322
|
+
});
|
323
|
+
const $c87311424ea30a05$export$a11b0059900ceec8 = $c87311424ea30a05$var$cached(function() {
|
324
|
+
return $c87311424ea30a05$var$testUserAgent(/Android/i);
|
325
|
+
});
|
326
|
+
$c87311424ea30a05$var$cached(function() {
|
327
|
+
return $c87311424ea30a05$var$testUserAgent(/Firefox/i);
|
328
|
+
});
|
329
|
+
let $bbed8b41f857bcc0$var$transitionsByElement = /* @__PURE__ */ new Map();
|
330
|
+
let $bbed8b41f857bcc0$var$transitionCallbacks = /* @__PURE__ */ new Set();
|
331
|
+
function $bbed8b41f857bcc0$var$setupGlobalEvents() {
|
332
|
+
if (typeof window === "undefined") return;
|
333
|
+
function isTransitionEvent(event) {
|
334
|
+
return "propertyName" in event;
|
335
|
+
}
|
336
|
+
let onTransitionStart = (e) => {
|
337
|
+
if (!isTransitionEvent(e) || !e.target) return;
|
338
|
+
let transitions = $bbed8b41f857bcc0$var$transitionsByElement.get(e.target);
|
339
|
+
if (!transitions) {
|
340
|
+
transitions = /* @__PURE__ */ new Set();
|
341
|
+
$bbed8b41f857bcc0$var$transitionsByElement.set(e.target, transitions);
|
342
|
+
e.target.addEventListener("transitioncancel", onTransitionEnd, {
|
343
|
+
once: true
|
344
|
+
});
|
345
|
+
}
|
346
|
+
transitions.add(e.propertyName);
|
347
|
+
};
|
348
|
+
let onTransitionEnd = (e) => {
|
349
|
+
if (!isTransitionEvent(e) || !e.target) return;
|
350
|
+
let properties = $bbed8b41f857bcc0$var$transitionsByElement.get(e.target);
|
351
|
+
if (!properties) return;
|
352
|
+
properties.delete(e.propertyName);
|
353
|
+
if (properties.size === 0) {
|
354
|
+
e.target.removeEventListener("transitioncancel", onTransitionEnd);
|
355
|
+
$bbed8b41f857bcc0$var$transitionsByElement.delete(e.target);
|
356
|
+
}
|
357
|
+
if ($bbed8b41f857bcc0$var$transitionsByElement.size === 0) {
|
358
|
+
for (let cb of $bbed8b41f857bcc0$var$transitionCallbacks) cb();
|
359
|
+
$bbed8b41f857bcc0$var$transitionCallbacks.clear();
|
360
|
+
}
|
361
|
+
};
|
362
|
+
document.body.addEventListener("transitionrun", onTransitionStart);
|
363
|
+
document.body.addEventListener("transitionend", onTransitionEnd);
|
364
|
+
}
|
365
|
+
if (typeof document !== "undefined") {
|
366
|
+
if (document.readyState !== "loading") $bbed8b41f857bcc0$var$setupGlobalEvents();
|
367
|
+
else document.addEventListener("DOMContentLoaded", $bbed8b41f857bcc0$var$setupGlobalEvents);
|
368
|
+
}
|
369
|
+
function $bbed8b41f857bcc0$var$cleanupDetachedElements() {
|
370
|
+
for (const [eventTarget] of $bbed8b41f857bcc0$var$transitionsByElement)
|
371
|
+
if ("isConnected" in eventTarget && !eventTarget.isConnected) $bbed8b41f857bcc0$var$transitionsByElement.delete(eventTarget);
|
372
|
+
}
|
373
|
+
function $bbed8b41f857bcc0$export$24490316f764c430(fn) {
|
374
|
+
requestAnimationFrame(() => {
|
375
|
+
$bbed8b41f857bcc0$var$cleanupDetachedElements();
|
376
|
+
if ($bbed8b41f857bcc0$var$transitionsByElement.size === 0) fn();
|
377
|
+
else $bbed8b41f857bcc0$var$transitionCallbacks.add(fn);
|
378
|
+
});
|
379
|
+
}
|
380
|
+
function $6a7db85432448f7f$export$60278871457622de(event) {
|
381
|
+
if (event.mozInputSource === 0 && event.isTrusted) return true;
|
382
|
+
if ($c87311424ea30a05$export$a11b0059900ceec8() && event.pointerType) return event.type === "click" && event.buttons === 1;
|
383
|
+
return event.detail === 0 && !event.pointerType;
|
384
|
+
}
|
385
|
+
const $7d2416ea0959daaa$var$supportsCheckVisibility = typeof Element !== "undefined" && "checkVisibility" in Element.prototype;
|
386
|
+
function $7d2416ea0959daaa$var$isStyleVisible(element) {
|
387
|
+
const windowObject = $431fbd86ca7dc216$export$f21a1ffae260145a(element);
|
388
|
+
if (!(element instanceof windowObject.HTMLElement) && !(element instanceof windowObject.SVGElement)) return false;
|
389
|
+
let { display, visibility } = element.style;
|
390
|
+
let isVisible = display !== "none" && visibility !== "hidden" && visibility !== "collapse";
|
391
|
+
if (isVisible) {
|
392
|
+
const { getComputedStyle } = element.ownerDocument.defaultView;
|
393
|
+
let { display: computedDisplay, visibility: computedVisibility } = getComputedStyle(element);
|
394
|
+
isVisible = computedDisplay !== "none" && computedVisibility !== "hidden" && computedVisibility !== "collapse";
|
395
|
+
}
|
396
|
+
return isVisible;
|
397
|
+
}
|
398
|
+
function $7d2416ea0959daaa$var$isAttributeVisible(element, childElement) {
|
399
|
+
return !element.hasAttribute("hidden") && // Ignore HiddenSelect when tree walking.
|
400
|
+
!element.hasAttribute("data-react-aria-prevent-focus") && (element.nodeName === "DETAILS" && childElement && childElement.nodeName !== "SUMMARY" ? element.hasAttribute("open") : true);
|
401
|
+
}
|
402
|
+
function $7d2416ea0959daaa$export$e989c0fffaa6b27a(element, childElement) {
|
403
|
+
if ($7d2416ea0959daaa$var$supportsCheckVisibility) return element.checkVisibility();
|
404
|
+
return element.nodeName !== "#comment" && $7d2416ea0959daaa$var$isStyleVisible(element) && $7d2416ea0959daaa$var$isAttributeVisible(element, childElement) && (!element.parentElement || $7d2416ea0959daaa$export$e989c0fffaa6b27a(element.parentElement, element));
|
405
|
+
}
|
406
|
+
const $b4b717babfbb907b$var$focusableElements = [
|
407
|
+
"input:not([disabled]):not([type=hidden])",
|
408
|
+
"select:not([disabled])",
|
409
|
+
"textarea:not([disabled])",
|
410
|
+
"button:not([disabled])",
|
411
|
+
"a[href]",
|
412
|
+
"area[href]",
|
413
|
+
"summary",
|
414
|
+
"iframe",
|
415
|
+
"object",
|
416
|
+
"embed",
|
417
|
+
"audio[controls]",
|
418
|
+
"video[controls]",
|
419
|
+
'[contenteditable]:not([contenteditable^="false"])',
|
420
|
+
"permission"
|
421
|
+
];
|
422
|
+
const $b4b717babfbb907b$var$FOCUSABLE_ELEMENT_SELECTOR = $b4b717babfbb907b$var$focusableElements.join(":not([hidden]),") + ",[tabindex]:not([disabled]):not([hidden])";
|
423
|
+
$b4b717babfbb907b$var$focusableElements.push('[tabindex]:not([tabindex="-1"]):not([disabled])');
|
424
|
+
const $b4b717babfbb907b$var$TABBABLE_ELEMENT_SELECTOR = $b4b717babfbb907b$var$focusableElements.join(':not([hidden]):not([tabindex="-1"]),');
|
425
|
+
function $b4b717babfbb907b$export$4c063cf1350e6fed(element) {
|
426
|
+
return element.matches($b4b717babfbb907b$var$FOCUSABLE_ELEMENT_SELECTOR) && $7d2416ea0959daaa$export$e989c0fffaa6b27a(element) && !$b4b717babfbb907b$var$isInert(element);
|
427
|
+
}
|
428
|
+
function $b4b717babfbb907b$export$bebd5a1431fec25d(element) {
|
429
|
+
return element.matches($b4b717babfbb907b$var$TABBABLE_ELEMENT_SELECTOR) && $7d2416ea0959daaa$export$e989c0fffaa6b27a(element) && !$b4b717babfbb907b$var$isInert(element);
|
430
|
+
}
|
431
|
+
function $b4b717babfbb907b$var$isInert(element) {
|
432
|
+
let node = element;
|
433
|
+
while (node != null) {
|
434
|
+
if (node instanceof node.ownerDocument.defaultView.HTMLElement && node.inert) return true;
|
435
|
+
node = node.parentElement;
|
436
|
+
}
|
437
|
+
return false;
|
438
|
+
}
|
439
|
+
let $8a9cb279dc87e130$export$fda7da73ab5d4c48 = false;
|
440
|
+
let $507fabe10e71c6fb$var$currentModality = null;
|
441
|
+
let $507fabe10e71c6fb$var$changeHandlers = /* @__PURE__ */ new Set();
|
442
|
+
let $507fabe10e71c6fb$export$d90243b58daecda7 = /* @__PURE__ */ new Map();
|
443
|
+
let $507fabe10e71c6fb$var$hasEventBeforeFocus = false;
|
444
|
+
let $507fabe10e71c6fb$var$hasBlurredWindowRecently = false;
|
445
|
+
function $507fabe10e71c6fb$var$triggerChangeHandlers(modality, e) {
|
446
|
+
for (let handler of $507fabe10e71c6fb$var$changeHandlers) handler(modality, e);
|
447
|
+
}
|
448
|
+
function $507fabe10e71c6fb$var$isValidKey(e) {
|
449
|
+
return !(e.metaKey || !$c87311424ea30a05$export$9ac100e40613ea10() && e.altKey || e.ctrlKey || e.key === "Control" || e.key === "Shift" || e.key === "Meta");
|
450
|
+
}
|
451
|
+
function $507fabe10e71c6fb$var$handleKeyboardEvent(e) {
|
452
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
453
|
+
if ($507fabe10e71c6fb$var$isValidKey(e)) {
|
454
|
+
$507fabe10e71c6fb$var$currentModality = "keyboard";
|
455
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers("keyboard", e);
|
456
|
+
}
|
457
|
+
}
|
458
|
+
function $507fabe10e71c6fb$var$handlePointerEvent(e) {
|
459
|
+
$507fabe10e71c6fb$var$currentModality = "pointer";
|
460
|
+
if (e.type === "mousedown" || e.type === "pointerdown") {
|
461
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
462
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers("pointer", e);
|
463
|
+
}
|
464
|
+
}
|
465
|
+
function $507fabe10e71c6fb$var$handleClickEvent(e) {
|
466
|
+
if ($6a7db85432448f7f$export$60278871457622de(e)) {
|
467
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
468
|
+
$507fabe10e71c6fb$var$currentModality = "virtual";
|
469
|
+
}
|
470
|
+
}
|
471
|
+
function $507fabe10e71c6fb$var$handleFocusEvent(e) {
|
472
|
+
if (e.target === window || e.target === document || $8a9cb279dc87e130$export$fda7da73ab5d4c48 || !e.isTrusted) return;
|
473
|
+
if (!$507fabe10e71c6fb$var$hasEventBeforeFocus && !$507fabe10e71c6fb$var$hasBlurredWindowRecently) {
|
474
|
+
$507fabe10e71c6fb$var$currentModality = "virtual";
|
475
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers("virtual", e);
|
476
|
+
}
|
477
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = false;
|
478
|
+
$507fabe10e71c6fb$var$hasBlurredWindowRecently = false;
|
479
|
+
}
|
480
|
+
function $507fabe10e71c6fb$var$handleWindowBlur() {
|
481
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = false;
|
482
|
+
$507fabe10e71c6fb$var$hasBlurredWindowRecently = true;
|
483
|
+
}
|
484
|
+
function $507fabe10e71c6fb$var$setupGlobalFocusEvents(element) {
|
485
|
+
if (typeof window === "undefined" || typeof document === "undefined" || $507fabe10e71c6fb$export$d90243b58daecda7.get($431fbd86ca7dc216$export$f21a1ffae260145a(element))) return;
|
486
|
+
const windowObject = $431fbd86ca7dc216$export$f21a1ffae260145a(element);
|
487
|
+
const documentObject = $431fbd86ca7dc216$export$b204af158042fbac(element);
|
488
|
+
let focus = windowObject.HTMLElement.prototype.focus;
|
489
|
+
windowObject.HTMLElement.prototype.focus = function() {
|
490
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
491
|
+
focus.apply(this, arguments);
|
492
|
+
};
|
493
|
+
documentObject.addEventListener("keydown", $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
494
|
+
documentObject.addEventListener("keyup", $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
495
|
+
documentObject.addEventListener("click", $507fabe10e71c6fb$var$handleClickEvent, true);
|
496
|
+
windowObject.addEventListener("focus", $507fabe10e71c6fb$var$handleFocusEvent, true);
|
497
|
+
windowObject.addEventListener("blur", $507fabe10e71c6fb$var$handleWindowBlur, false);
|
498
|
+
if (typeof PointerEvent !== "undefined") {
|
499
|
+
documentObject.addEventListener("pointerdown", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
500
|
+
documentObject.addEventListener("pointermove", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
501
|
+
documentObject.addEventListener("pointerup", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
502
|
+
} else if (process.env.NODE_ENV === "test") {
|
503
|
+
documentObject.addEventListener("mousedown", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
504
|
+
documentObject.addEventListener("mousemove", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
505
|
+
documentObject.addEventListener("mouseup", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
506
|
+
}
|
507
|
+
windowObject.addEventListener("beforeunload", () => {
|
508
|
+
$507fabe10e71c6fb$var$tearDownWindowFocusTracking(element);
|
509
|
+
}, {
|
510
|
+
once: true
|
511
|
+
});
|
512
|
+
$507fabe10e71c6fb$export$d90243b58daecda7.set(windowObject, {
|
513
|
+
focus
|
514
|
+
});
|
515
|
+
}
|
516
|
+
const $507fabe10e71c6fb$var$tearDownWindowFocusTracking = (element, loadListener) => {
|
517
|
+
const windowObject = $431fbd86ca7dc216$export$f21a1ffae260145a(element);
|
518
|
+
const documentObject = $431fbd86ca7dc216$export$b204af158042fbac(element);
|
519
|
+
if (loadListener) documentObject.removeEventListener("DOMContentLoaded", loadListener);
|
520
|
+
if (!$507fabe10e71c6fb$export$d90243b58daecda7.has(windowObject)) return;
|
521
|
+
windowObject.HTMLElement.prototype.focus = $507fabe10e71c6fb$export$d90243b58daecda7.get(windowObject).focus;
|
522
|
+
documentObject.removeEventListener("keydown", $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
523
|
+
documentObject.removeEventListener("keyup", $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
524
|
+
documentObject.removeEventListener("click", $507fabe10e71c6fb$var$handleClickEvent, true);
|
525
|
+
windowObject.removeEventListener("focus", $507fabe10e71c6fb$var$handleFocusEvent, true);
|
526
|
+
windowObject.removeEventListener("blur", $507fabe10e71c6fb$var$handleWindowBlur, false);
|
527
|
+
if (typeof PointerEvent !== "undefined") {
|
528
|
+
documentObject.removeEventListener("pointerdown", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
529
|
+
documentObject.removeEventListener("pointermove", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
530
|
+
documentObject.removeEventListener("pointerup", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
531
|
+
} else if (process.env.NODE_ENV === "test") {
|
532
|
+
documentObject.removeEventListener("mousedown", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
533
|
+
documentObject.removeEventListener("mousemove", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
534
|
+
documentObject.removeEventListener("mouseup", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
535
|
+
}
|
536
|
+
$507fabe10e71c6fb$export$d90243b58daecda7.delete(windowObject);
|
537
|
+
};
|
538
|
+
function $507fabe10e71c6fb$export$2f1888112f558a7d(element) {
|
539
|
+
const documentObject = $431fbd86ca7dc216$export$b204af158042fbac(element);
|
540
|
+
let loadListener;
|
541
|
+
if (documentObject.readyState !== "loading") $507fabe10e71c6fb$var$setupGlobalFocusEvents(element);
|
542
|
+
else {
|
543
|
+
loadListener = () => {
|
544
|
+
$507fabe10e71c6fb$var$setupGlobalFocusEvents(element);
|
545
|
+
};
|
546
|
+
documentObject.addEventListener("DOMContentLoaded", loadListener);
|
547
|
+
}
|
548
|
+
return () => $507fabe10e71c6fb$var$tearDownWindowFocusTracking(element, loadListener);
|
549
|
+
}
|
550
|
+
if (typeof document !== "undefined") $507fabe10e71c6fb$export$2f1888112f558a7d();
|
551
|
+
function $507fabe10e71c6fb$export$630ff653c5ada6a9() {
|
552
|
+
return $507fabe10e71c6fb$var$currentModality;
|
553
|
+
}
|
554
|
+
function $3ad3f6e1647bc98d$export$80f3e147d781571c(element) {
|
555
|
+
const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(element);
|
556
|
+
const activeElement = $d4ee10de306f2510$export$cd4e5573fbe2b576(ownerDocument);
|
557
|
+
if ($507fabe10e71c6fb$export$630ff653c5ada6a9() === "virtual") {
|
558
|
+
let lastFocusedElement = activeElement;
|
559
|
+
$bbed8b41f857bcc0$export$24490316f764c430(() => {
|
560
|
+
if ($d4ee10de306f2510$export$cd4e5573fbe2b576(ownerDocument) === lastFocusedElement && element.isConnected) $7215afc6de606d6b$export$de79e2c695e052f3(element);
|
561
|
+
});
|
562
|
+
} else $7215afc6de606d6b$export$de79e2c695e052f3(element);
|
563
|
+
}
|
564
|
+
const $9bf71ea28793e738$var$FocusContext = /* @__PURE__ */ o__default.createContext(null);
|
565
|
+
const $9bf71ea28793e738$var$RESTORE_FOCUS_EVENT = "react-aria-focus-scope-restore";
|
566
|
+
let $9bf71ea28793e738$var$activeScope = null;
|
567
|
+
function $9bf71ea28793e738$export$20e40289641fbbb6(props) {
|
568
|
+
let { children, contain, restoreFocus, autoFocus } = props;
|
569
|
+
let startRef = useRef(null);
|
570
|
+
let endRef = useRef(null);
|
571
|
+
let scopeRef = useRef([]);
|
572
|
+
let { parentNode } = useContext($9bf71ea28793e738$var$FocusContext) || {};
|
573
|
+
let node = useMemo(() => new $9bf71ea28793e738$var$TreeNode({
|
574
|
+
scopeRef
|
575
|
+
}), [
|
576
|
+
scopeRef
|
577
|
+
]);
|
578
|
+
$f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
|
579
|
+
let parent = parentNode || $9bf71ea28793e738$export$d06fae2ee68b101e.root;
|
580
|
+
if ($9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(parent.scopeRef) && $9bf71ea28793e738$var$activeScope && !$9bf71ea28793e738$var$isAncestorScope($9bf71ea28793e738$var$activeScope, parent.scopeRef)) {
|
581
|
+
let activeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode($9bf71ea28793e738$var$activeScope);
|
582
|
+
if (activeNode) parent = activeNode;
|
583
|
+
}
|
584
|
+
parent.addChild(node);
|
585
|
+
$9bf71ea28793e738$export$d06fae2ee68b101e.addNode(node);
|
586
|
+
}, [
|
587
|
+
node,
|
588
|
+
parentNode
|
589
|
+
]);
|
590
|
+
$f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
|
591
|
+
let node2 = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef);
|
592
|
+
if (node2) node2.contain = !!contain;
|
593
|
+
}, [
|
594
|
+
contain
|
595
|
+
]);
|
596
|
+
$f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
|
597
|
+
var _startRef_current;
|
598
|
+
let node2 = (_startRef_current = startRef.current) === null || _startRef_current === void 0 ? void 0 : _startRef_current.nextSibling;
|
599
|
+
let nodes = [];
|
600
|
+
let stopPropagation = (e) => e.stopPropagation();
|
601
|
+
while (node2 && node2 !== endRef.current) {
|
602
|
+
nodes.push(node2);
|
603
|
+
node2.addEventListener($9bf71ea28793e738$var$RESTORE_FOCUS_EVENT, stopPropagation);
|
604
|
+
node2 = node2.nextSibling;
|
605
|
+
}
|
606
|
+
scopeRef.current = nodes;
|
607
|
+
return () => {
|
608
|
+
for (let node3 of nodes) node3.removeEventListener($9bf71ea28793e738$var$RESTORE_FOCUS_EVENT, stopPropagation);
|
609
|
+
};
|
610
|
+
}, [
|
611
|
+
children
|
612
|
+
]);
|
613
|
+
$9bf71ea28793e738$var$useActiveScopeTracker(scopeRef, restoreFocus, contain);
|
614
|
+
$9bf71ea28793e738$var$useFocusContainment(scopeRef, contain);
|
615
|
+
$9bf71ea28793e738$var$useRestoreFocus(scopeRef, restoreFocus, contain);
|
616
|
+
$9bf71ea28793e738$var$useAutoFocus(scopeRef, autoFocus);
|
617
|
+
useEffect(() => {
|
618
|
+
const activeElement = $d4ee10de306f2510$export$cd4e5573fbe2b576($431fbd86ca7dc216$export$b204af158042fbac(scopeRef.current ? scopeRef.current[0] : void 0));
|
619
|
+
let scope = null;
|
620
|
+
if ($9bf71ea28793e738$var$isElementInScope(activeElement, scopeRef.current)) {
|
621
|
+
for (let node2 of $9bf71ea28793e738$export$d06fae2ee68b101e.traverse()) if (node2.scopeRef && $9bf71ea28793e738$var$isElementInScope(activeElement, node2.scopeRef.current)) scope = node2;
|
622
|
+
if (scope === $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef)) $9bf71ea28793e738$var$activeScope = scope.scopeRef;
|
623
|
+
}
|
624
|
+
}, [
|
625
|
+
scopeRef
|
626
|
+
]);
|
627
|
+
$f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
|
628
|
+
return () => {
|
629
|
+
var _focusScopeTree_getTreeNode_parent, _focusScopeTree_getTreeNode;
|
630
|
+
var _focusScopeTree_getTreeNode_parent_scopeRef;
|
631
|
+
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;
|
632
|
+
if ((scopeRef === $9bf71ea28793e738$var$activeScope || $9bf71ea28793e738$var$isAncestorScope(scopeRef, $9bf71ea28793e738$var$activeScope)) && (!parentScope || $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(parentScope))) $9bf71ea28793e738$var$activeScope = parentScope;
|
633
|
+
$9bf71ea28793e738$export$d06fae2ee68b101e.removeTreeNode(scopeRef);
|
634
|
+
};
|
635
|
+
}, [
|
636
|
+
scopeRef
|
637
|
+
]);
|
638
|
+
let focusManager = useMemo(() => $9bf71ea28793e738$var$createFocusManagerForScope(scopeRef), []);
|
639
|
+
let value = useMemo(() => ({
|
640
|
+
focusManager,
|
641
|
+
parentNode: node
|
642
|
+
}), [
|
643
|
+
node,
|
644
|
+
focusManager
|
645
|
+
]);
|
646
|
+
return /* @__PURE__ */ o__default.createElement($9bf71ea28793e738$var$FocusContext.Provider, {
|
647
|
+
value
|
648
|
+
}, /* @__PURE__ */ o__default.createElement("span", {
|
649
|
+
"data-focus-scope-start": true,
|
650
|
+
hidden: true,
|
651
|
+
ref: startRef
|
652
|
+
}), children, /* @__PURE__ */ o__default.createElement("span", {
|
653
|
+
"data-focus-scope-end": true,
|
654
|
+
hidden: true,
|
655
|
+
ref: endRef
|
656
|
+
}));
|
657
|
+
}
|
658
|
+
function $9bf71ea28793e738$export$10c5169755ce7bd7() {
|
659
|
+
var _useContext;
|
660
|
+
return (_useContext = useContext($9bf71ea28793e738$var$FocusContext)) === null || _useContext === void 0 ? void 0 : _useContext.focusManager;
|
661
|
+
}
|
662
|
+
function $9bf71ea28793e738$var$createFocusManagerForScope(scopeRef) {
|
663
|
+
return {
|
664
|
+
focusNext(opts = {}) {
|
665
|
+
let scope = scopeRef.current;
|
666
|
+
let { from, tabbable, wrap, accept } = opts;
|
667
|
+
var _scope_;
|
668
|
+
let node = from || $d4ee10de306f2510$export$cd4e5573fbe2b576($431fbd86ca7dc216$export$b204af158042fbac((_scope_ = scope[0]) !== null && _scope_ !== void 0 ? _scope_ : void 0));
|
669
|
+
let sentinel = scope[0].previousElementSibling;
|
670
|
+
let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
|
671
|
+
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
|
672
|
+
tabbable,
|
673
|
+
accept
|
674
|
+
}, scope);
|
675
|
+
walker.currentNode = $9bf71ea28793e738$var$isElementInScope(node, scope) ? node : sentinel;
|
676
|
+
let nextNode = walker.nextNode();
|
677
|
+
if (!nextNode && wrap) {
|
678
|
+
walker.currentNode = sentinel;
|
679
|
+
nextNode = walker.nextNode();
|
680
|
+
}
|
681
|
+
if (nextNode) $9bf71ea28793e738$var$focusElement(nextNode, true);
|
682
|
+
return nextNode;
|
683
|
+
},
|
684
|
+
focusPrevious(opts = {}) {
|
685
|
+
let scope = scopeRef.current;
|
686
|
+
let { from, tabbable, wrap, accept } = opts;
|
687
|
+
var _scope_;
|
688
|
+
let node = from || $d4ee10de306f2510$export$cd4e5573fbe2b576($431fbd86ca7dc216$export$b204af158042fbac((_scope_ = scope[0]) !== null && _scope_ !== void 0 ? _scope_ : void 0));
|
689
|
+
let sentinel = scope[scope.length - 1].nextElementSibling;
|
690
|
+
let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
|
691
|
+
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
|
692
|
+
tabbable,
|
693
|
+
accept
|
694
|
+
}, scope);
|
695
|
+
walker.currentNode = $9bf71ea28793e738$var$isElementInScope(node, scope) ? node : sentinel;
|
696
|
+
let previousNode = walker.previousNode();
|
697
|
+
if (!previousNode && wrap) {
|
698
|
+
walker.currentNode = sentinel;
|
699
|
+
previousNode = walker.previousNode();
|
700
|
+
}
|
701
|
+
if (previousNode) $9bf71ea28793e738$var$focusElement(previousNode, true);
|
702
|
+
return previousNode;
|
703
|
+
},
|
704
|
+
focusFirst(opts = {}) {
|
705
|
+
let scope = scopeRef.current;
|
706
|
+
let { tabbable, accept } = opts;
|
707
|
+
let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
|
708
|
+
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
|
709
|
+
tabbable,
|
710
|
+
accept
|
711
|
+
}, scope);
|
712
|
+
walker.currentNode = scope[0].previousElementSibling;
|
713
|
+
let nextNode = walker.nextNode();
|
714
|
+
if (nextNode) $9bf71ea28793e738$var$focusElement(nextNode, true);
|
715
|
+
return nextNode;
|
716
|
+
},
|
717
|
+
focusLast(opts = {}) {
|
718
|
+
let scope = scopeRef.current;
|
719
|
+
let { tabbable, accept } = opts;
|
720
|
+
let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
|
721
|
+
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
|
722
|
+
tabbable,
|
723
|
+
accept
|
724
|
+
}, scope);
|
725
|
+
walker.currentNode = scope[scope.length - 1].nextElementSibling;
|
726
|
+
let previousNode = walker.previousNode();
|
727
|
+
if (previousNode) $9bf71ea28793e738$var$focusElement(previousNode, true);
|
728
|
+
return previousNode;
|
729
|
+
}
|
730
|
+
};
|
731
|
+
}
|
732
|
+
function $9bf71ea28793e738$var$getScopeRoot(scope) {
|
733
|
+
return scope[0].parentElement;
|
734
|
+
}
|
735
|
+
function $9bf71ea28793e738$var$shouldContainFocus(scopeRef) {
|
736
|
+
let scope = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode($9bf71ea28793e738$var$activeScope);
|
737
|
+
while (scope && scope.scopeRef !== scopeRef) {
|
738
|
+
if (scope.contain) return false;
|
739
|
+
scope = scope.parent;
|
740
|
+
}
|
741
|
+
return true;
|
742
|
+
}
|
743
|
+
function $9bf71ea28793e738$var$isTabbableRadio(element) {
|
744
|
+
if (element.checked) return true;
|
745
|
+
let radios = [];
|
746
|
+
if (!element.form) radios = [
|
747
|
+
...$431fbd86ca7dc216$export$b204af158042fbac(element).querySelectorAll(`input[type="radio"][name="${CSS.escape(element.name)}"]`)
|
748
|
+
].filter((radio) => !radio.form);
|
749
|
+
else {
|
750
|
+
var _element_form_elements, _element_form;
|
751
|
+
let radioList = (_element_form = element.form) === null || _element_form === void 0 ? void 0 : (_element_form_elements = _element_form.elements) === null || _element_form_elements === void 0 ? void 0 : _element_form_elements.namedItem(element.name);
|
752
|
+
radios = [
|
753
|
+
...radioList !== null && radioList !== void 0 ? radioList : []
|
754
|
+
];
|
755
|
+
}
|
756
|
+
if (!radios) return false;
|
757
|
+
let anyChecked = radios.some((radio) => radio.checked);
|
758
|
+
return !anyChecked;
|
759
|
+
}
|
760
|
+
function $9bf71ea28793e738$var$useFocusContainment(scopeRef, contain) {
|
761
|
+
let focusedNode = useRef(void 0);
|
762
|
+
let raf = useRef(void 0);
|
763
|
+
$f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
|
764
|
+
let scope = scopeRef.current;
|
765
|
+
if (!contain) {
|
766
|
+
if (raf.current) {
|
767
|
+
cancelAnimationFrame(raf.current);
|
768
|
+
raf.current = void 0;
|
769
|
+
}
|
770
|
+
return;
|
771
|
+
}
|
772
|
+
const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(scope ? scope[0] : void 0);
|
773
|
+
let onKeyDown = (e) => {
|
774
|
+
if (e.key !== "Tab" || e.altKey || e.ctrlKey || e.metaKey || !$9bf71ea28793e738$var$shouldContainFocus(scopeRef) || e.isComposing) return;
|
775
|
+
let focusedElement = $d4ee10de306f2510$export$cd4e5573fbe2b576(ownerDocument);
|
776
|
+
let scope2 = scopeRef.current;
|
777
|
+
if (!scope2 || !$9bf71ea28793e738$var$isElementInScope(focusedElement, scope2)) return;
|
778
|
+
let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope2);
|
779
|
+
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
|
780
|
+
tabbable: true
|
781
|
+
}, scope2);
|
782
|
+
if (!focusedElement) return;
|
783
|
+
walker.currentNode = focusedElement;
|
784
|
+
let nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
|
785
|
+
if (!nextElement) {
|
786
|
+
walker.currentNode = e.shiftKey ? scope2[scope2.length - 1].nextElementSibling : scope2[0].previousElementSibling;
|
787
|
+
nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
|
788
|
+
}
|
789
|
+
e.preventDefault();
|
790
|
+
if (nextElement) $9bf71ea28793e738$var$focusElement(nextElement, true);
|
791
|
+
};
|
792
|
+
let onFocus = (e) => {
|
793
|
+
if ((!$9bf71ea28793e738$var$activeScope || $9bf71ea28793e738$var$isAncestorScope($9bf71ea28793e738$var$activeScope, scopeRef)) && $9bf71ea28793e738$var$isElementInScope($d4ee10de306f2510$export$e58f029f0fbfdb29(e), scopeRef.current)) {
|
794
|
+
$9bf71ea28793e738$var$activeScope = scopeRef;
|
795
|
+
focusedNode.current = $d4ee10de306f2510$export$e58f029f0fbfdb29(e);
|
796
|
+
} else if ($9bf71ea28793e738$var$shouldContainFocus(scopeRef) && !$9bf71ea28793e738$var$isElementInChildScope($d4ee10de306f2510$export$e58f029f0fbfdb29(e), scopeRef)) {
|
797
|
+
if (focusedNode.current) focusedNode.current.focus();
|
798
|
+
else if ($9bf71ea28793e738$var$activeScope && $9bf71ea28793e738$var$activeScope.current) $9bf71ea28793e738$var$focusFirstInScope($9bf71ea28793e738$var$activeScope.current);
|
799
|
+
} else if ($9bf71ea28793e738$var$shouldContainFocus(scopeRef)) focusedNode.current = $d4ee10de306f2510$export$e58f029f0fbfdb29(e);
|
800
|
+
};
|
801
|
+
let onBlur = (e) => {
|
802
|
+
if (raf.current) cancelAnimationFrame(raf.current);
|
803
|
+
raf.current = requestAnimationFrame(() => {
|
804
|
+
let modality = $507fabe10e71c6fb$export$630ff653c5ada6a9();
|
805
|
+
let shouldSkipFocusRestore = (modality === "virtual" || modality === null) && $c87311424ea30a05$export$a11b0059900ceec8() && $c87311424ea30a05$export$6446a186d09e379e();
|
806
|
+
let activeElement = $d4ee10de306f2510$export$cd4e5573fbe2b576(ownerDocument);
|
807
|
+
if (!shouldSkipFocusRestore && activeElement && $9bf71ea28793e738$var$shouldContainFocus(scopeRef) && !$9bf71ea28793e738$var$isElementInChildScope(activeElement, scopeRef)) {
|
808
|
+
$9bf71ea28793e738$var$activeScope = scopeRef;
|
809
|
+
let target = $d4ee10de306f2510$export$e58f029f0fbfdb29(e);
|
810
|
+
if (target && target.isConnected) {
|
811
|
+
var _focusedNode_current;
|
812
|
+
focusedNode.current = target;
|
813
|
+
(_focusedNode_current = focusedNode.current) === null || _focusedNode_current === void 0 ? void 0 : _focusedNode_current.focus();
|
814
|
+
} else if ($9bf71ea28793e738$var$activeScope.current) $9bf71ea28793e738$var$focusFirstInScope($9bf71ea28793e738$var$activeScope.current);
|
815
|
+
}
|
816
|
+
});
|
817
|
+
};
|
818
|
+
ownerDocument.addEventListener("keydown", onKeyDown, false);
|
819
|
+
ownerDocument.addEventListener("focusin", onFocus, false);
|
820
|
+
scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.addEventListener("focusin", onFocus, false));
|
821
|
+
scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.addEventListener("focusout", onBlur, false));
|
822
|
+
return () => {
|
823
|
+
ownerDocument.removeEventListener("keydown", onKeyDown, false);
|
824
|
+
ownerDocument.removeEventListener("focusin", onFocus, false);
|
825
|
+
scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.removeEventListener("focusin", onFocus, false));
|
826
|
+
scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.removeEventListener("focusout", onBlur, false));
|
827
|
+
};
|
828
|
+
}, [
|
829
|
+
scopeRef,
|
830
|
+
contain
|
831
|
+
]);
|
832
|
+
$f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
|
833
|
+
return () => {
|
834
|
+
if (raf.current) cancelAnimationFrame(raf.current);
|
835
|
+
};
|
836
|
+
}, [
|
837
|
+
raf
|
838
|
+
]);
|
839
|
+
}
|
840
|
+
function $9bf71ea28793e738$var$isElementInAnyScope(element) {
|
841
|
+
return $9bf71ea28793e738$var$isElementInChildScope(element);
|
842
|
+
}
|
843
|
+
function $9bf71ea28793e738$var$isElementInScope(element, scope) {
|
844
|
+
if (!element) return false;
|
845
|
+
if (!scope) return false;
|
846
|
+
return scope.some((node) => node.contains(element));
|
847
|
+
}
|
848
|
+
function $9bf71ea28793e738$var$isElementInChildScope(element, scope = null) {
|
849
|
+
if (element instanceof Element && element.closest("[data-react-aria-top-layer]")) return true;
|
850
|
+
for (let { scopeRef: s } of $9bf71ea28793e738$export$d06fae2ee68b101e.traverse($9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scope))) {
|
851
|
+
if (s && $9bf71ea28793e738$var$isElementInScope(element, s.current)) return true;
|
852
|
+
}
|
853
|
+
return false;
|
854
|
+
}
|
855
|
+
function $9bf71ea28793e738$var$isAncestorScope(ancestor, scope) {
|
856
|
+
var _focusScopeTree_getTreeNode;
|
857
|
+
let parent = (_focusScopeTree_getTreeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scope)) === null || _focusScopeTree_getTreeNode === void 0 ? void 0 : _focusScopeTree_getTreeNode.parent;
|
858
|
+
while (parent) {
|
859
|
+
if (parent.scopeRef === ancestor) return true;
|
860
|
+
parent = parent.parent;
|
861
|
+
}
|
862
|
+
return false;
|
863
|
+
}
|
864
|
+
function $9bf71ea28793e738$var$focusElement(element, scroll = false) {
|
865
|
+
if (element != null && !scroll) try {
|
866
|
+
(0, $3ad3f6e1647bc98d$export$80f3e147d781571c)(element);
|
867
|
+
} catch {
|
868
|
+
}
|
869
|
+
else if (element != null) try {
|
870
|
+
element.focus();
|
871
|
+
} catch {
|
872
|
+
}
|
873
|
+
}
|
874
|
+
function $9bf71ea28793e738$var$getFirstInScope(scope, tabbable = true) {
|
875
|
+
let sentinel = scope[0].previousElementSibling;
|
876
|
+
let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
|
877
|
+
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
|
878
|
+
tabbable
|
879
|
+
}, scope);
|
880
|
+
walker.currentNode = sentinel;
|
881
|
+
let nextNode = walker.nextNode();
|
882
|
+
if (tabbable && !nextNode) {
|
883
|
+
scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
|
884
|
+
walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
|
885
|
+
tabbable: false
|
886
|
+
}, scope);
|
887
|
+
walker.currentNode = sentinel;
|
888
|
+
nextNode = walker.nextNode();
|
889
|
+
}
|
890
|
+
return nextNode;
|
891
|
+
}
|
892
|
+
function $9bf71ea28793e738$var$focusFirstInScope(scope, tabbable = true) {
|
893
|
+
$9bf71ea28793e738$var$focusElement($9bf71ea28793e738$var$getFirstInScope(scope, tabbable));
|
894
|
+
}
|
895
|
+
function $9bf71ea28793e738$var$useAutoFocus(scopeRef, autoFocus) {
|
896
|
+
const autoFocusRef = o__default.useRef(autoFocus);
|
897
|
+
useEffect(() => {
|
898
|
+
if (autoFocusRef.current) {
|
899
|
+
$9bf71ea28793e738$var$activeScope = scopeRef;
|
900
|
+
const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(scopeRef.current ? scopeRef.current[0] : void 0);
|
901
|
+
if (!$9bf71ea28793e738$var$isElementInScope($d4ee10de306f2510$export$cd4e5573fbe2b576(ownerDocument), $9bf71ea28793e738$var$activeScope.current) && scopeRef.current) $9bf71ea28793e738$var$focusFirstInScope(scopeRef.current);
|
902
|
+
}
|
903
|
+
autoFocusRef.current = false;
|
904
|
+
}, [
|
905
|
+
scopeRef
|
906
|
+
]);
|
907
|
+
}
|
908
|
+
function $9bf71ea28793e738$var$useActiveScopeTracker(scopeRef, restore, contain) {
|
909
|
+
$f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
|
910
|
+
if (restore || contain) return;
|
911
|
+
let scope = scopeRef.current;
|
912
|
+
const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(scope ? scope[0] : void 0);
|
913
|
+
let onFocus = (e) => {
|
914
|
+
let target = $d4ee10de306f2510$export$e58f029f0fbfdb29(e);
|
915
|
+
if ($9bf71ea28793e738$var$isElementInScope(target, scopeRef.current)) $9bf71ea28793e738$var$activeScope = scopeRef;
|
916
|
+
else if (!$9bf71ea28793e738$var$isElementInAnyScope(target)) $9bf71ea28793e738$var$activeScope = null;
|
917
|
+
};
|
918
|
+
ownerDocument.addEventListener("focusin", onFocus, false);
|
919
|
+
scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.addEventListener("focusin", onFocus, false));
|
920
|
+
return () => {
|
921
|
+
ownerDocument.removeEventListener("focusin", onFocus, false);
|
922
|
+
scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.removeEventListener("focusin", onFocus, false));
|
923
|
+
};
|
924
|
+
}, [
|
925
|
+
scopeRef,
|
926
|
+
restore,
|
927
|
+
contain
|
928
|
+
]);
|
929
|
+
}
|
930
|
+
function $9bf71ea28793e738$var$shouldRestoreFocus(scopeRef) {
|
931
|
+
let scope = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode($9bf71ea28793e738$var$activeScope);
|
932
|
+
while (scope && scope.scopeRef !== scopeRef) {
|
933
|
+
if (scope.nodeToRestore) return false;
|
934
|
+
scope = scope.parent;
|
935
|
+
}
|
936
|
+
return (scope === null || scope === void 0 ? void 0 : scope.scopeRef) === scopeRef;
|
937
|
+
}
|
938
|
+
function $9bf71ea28793e738$var$useRestoreFocus(scopeRef, restoreFocus, contain) {
|
939
|
+
const nodeToRestoreRef = useRef(typeof document !== "undefined" ? $d4ee10de306f2510$export$cd4e5573fbe2b576($431fbd86ca7dc216$export$b204af158042fbac(scopeRef.current ? scopeRef.current[0] : void 0)) : null);
|
940
|
+
$f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
|
941
|
+
let scope = scopeRef.current;
|
942
|
+
const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(scope ? scope[0] : void 0);
|
943
|
+
if (!restoreFocus || contain) return;
|
944
|
+
let onFocus = () => {
|
945
|
+
if ((!$9bf71ea28793e738$var$activeScope || $9bf71ea28793e738$var$isAncestorScope($9bf71ea28793e738$var$activeScope, scopeRef)) && $9bf71ea28793e738$var$isElementInScope($d4ee10de306f2510$export$cd4e5573fbe2b576(ownerDocument), scopeRef.current)) $9bf71ea28793e738$var$activeScope = scopeRef;
|
946
|
+
};
|
947
|
+
ownerDocument.addEventListener("focusin", onFocus, false);
|
948
|
+
scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.addEventListener("focusin", onFocus, false));
|
949
|
+
return () => {
|
950
|
+
ownerDocument.removeEventListener("focusin", onFocus, false);
|
951
|
+
scope === null || scope === void 0 ? void 0 : scope.forEach((element) => element.removeEventListener("focusin", onFocus, false));
|
952
|
+
};
|
953
|
+
}, [
|
954
|
+
scopeRef,
|
955
|
+
contain
|
956
|
+
]);
|
957
|
+
$f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
|
958
|
+
const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(scopeRef.current ? scopeRef.current[0] : void 0);
|
959
|
+
if (!restoreFocus) return;
|
960
|
+
let onKeyDown = (e) => {
|
961
|
+
if (e.key !== "Tab" || e.altKey || e.ctrlKey || e.metaKey || !$9bf71ea28793e738$var$shouldContainFocus(scopeRef) || e.isComposing) return;
|
962
|
+
let focusedElement = ownerDocument.activeElement;
|
963
|
+
if (!$9bf71ea28793e738$var$isElementInChildScope(focusedElement, scopeRef) || !$9bf71ea28793e738$var$shouldRestoreFocus(scopeRef)) return;
|
964
|
+
let treeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef);
|
965
|
+
if (!treeNode) return;
|
966
|
+
let nodeToRestore = treeNode.nodeToRestore;
|
967
|
+
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(ownerDocument.body, {
|
968
|
+
tabbable: true
|
969
|
+
});
|
970
|
+
walker.currentNode = focusedElement;
|
971
|
+
let nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
|
972
|
+
if (!nodeToRestore || !nodeToRestore.isConnected || nodeToRestore === ownerDocument.body) {
|
973
|
+
nodeToRestore = void 0;
|
974
|
+
treeNode.nodeToRestore = void 0;
|
975
|
+
}
|
976
|
+
if ((!nextElement || !$9bf71ea28793e738$var$isElementInChildScope(nextElement, scopeRef)) && nodeToRestore) {
|
977
|
+
walker.currentNode = nodeToRestore;
|
978
|
+
do
|
979
|
+
nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
|
980
|
+
while ($9bf71ea28793e738$var$isElementInChildScope(nextElement, scopeRef));
|
981
|
+
e.preventDefault();
|
982
|
+
e.stopPropagation();
|
983
|
+
if (nextElement) $9bf71ea28793e738$var$focusElement(nextElement, true);
|
984
|
+
else if (!$9bf71ea28793e738$var$isElementInAnyScope(nodeToRestore)) focusedElement.blur();
|
985
|
+
else $9bf71ea28793e738$var$focusElement(nodeToRestore, true);
|
986
|
+
}
|
987
|
+
};
|
988
|
+
if (!contain) ownerDocument.addEventListener("keydown", onKeyDown, true);
|
989
|
+
return () => {
|
990
|
+
if (!contain) ownerDocument.removeEventListener("keydown", onKeyDown, true);
|
991
|
+
};
|
992
|
+
}, [
|
993
|
+
scopeRef,
|
994
|
+
restoreFocus,
|
995
|
+
contain
|
996
|
+
]);
|
997
|
+
$f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
|
998
|
+
const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(scopeRef.current ? scopeRef.current[0] : void 0);
|
999
|
+
if (!restoreFocus) return;
|
1000
|
+
let treeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef);
|
1001
|
+
if (!treeNode) return;
|
1002
|
+
var _nodeToRestoreRef_current;
|
1003
|
+
treeNode.nodeToRestore = (_nodeToRestoreRef_current = nodeToRestoreRef.current) !== null && _nodeToRestoreRef_current !== void 0 ? _nodeToRestoreRef_current : void 0;
|
1004
|
+
return () => {
|
1005
|
+
let treeNode2 = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef);
|
1006
|
+
if (!treeNode2) return;
|
1007
|
+
let nodeToRestore = treeNode2.nodeToRestore;
|
1008
|
+
let activeElement = $d4ee10de306f2510$export$cd4e5573fbe2b576(ownerDocument);
|
1009
|
+
if (restoreFocus && nodeToRestore && (activeElement && $9bf71ea28793e738$var$isElementInChildScope(activeElement, scopeRef) || activeElement === ownerDocument.body && $9bf71ea28793e738$var$shouldRestoreFocus(scopeRef))) {
|
1010
|
+
let clonedTree = $9bf71ea28793e738$export$d06fae2ee68b101e.clone();
|
1011
|
+
requestAnimationFrame(() => {
|
1012
|
+
if (ownerDocument.activeElement === ownerDocument.body) {
|
1013
|
+
let treeNode3 = clonedTree.getTreeNode(scopeRef);
|
1014
|
+
while (treeNode3) {
|
1015
|
+
if (treeNode3.nodeToRestore && treeNode3.nodeToRestore.isConnected) {
|
1016
|
+
$9bf71ea28793e738$var$restoreFocusToElement(treeNode3.nodeToRestore);
|
1017
|
+
return;
|
1018
|
+
}
|
1019
|
+
treeNode3 = treeNode3.parent;
|
1020
|
+
}
|
1021
|
+
treeNode3 = clonedTree.getTreeNode(scopeRef);
|
1022
|
+
while (treeNode3) {
|
1023
|
+
if (treeNode3.scopeRef && treeNode3.scopeRef.current && $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(treeNode3.scopeRef)) {
|
1024
|
+
let node = $9bf71ea28793e738$var$getFirstInScope(treeNode3.scopeRef.current, true);
|
1025
|
+
$9bf71ea28793e738$var$restoreFocusToElement(node);
|
1026
|
+
return;
|
1027
|
+
}
|
1028
|
+
treeNode3 = treeNode3.parent;
|
1029
|
+
}
|
1030
|
+
}
|
1031
|
+
});
|
1032
|
+
}
|
1033
|
+
};
|
1034
|
+
}, [
|
1035
|
+
scopeRef,
|
1036
|
+
restoreFocus
|
1037
|
+
]);
|
1038
|
+
}
|
1039
|
+
function $9bf71ea28793e738$var$restoreFocusToElement(node) {
|
1040
|
+
if (node.dispatchEvent(new CustomEvent($9bf71ea28793e738$var$RESTORE_FOCUS_EVENT, {
|
1041
|
+
bubbles: true,
|
1042
|
+
cancelable: true
|
1043
|
+
}))) $9bf71ea28793e738$var$focusElement(node);
|
1044
|
+
}
|
1045
|
+
function $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, opts, scope) {
|
1046
|
+
let filter = (opts === null || opts === void 0 ? void 0 : opts.tabbable) ? $b4b717babfbb907b$export$bebd5a1431fec25d : $b4b717babfbb907b$export$4c063cf1350e6fed;
|
1047
|
+
let rootElement = (root === null || root === void 0 ? void 0 : root.nodeType) === Node.ELEMENT_NODE ? root : null;
|
1048
|
+
let doc = $431fbd86ca7dc216$export$b204af158042fbac(rootElement);
|
1049
|
+
let walker = $dfc540311bf7f109$export$4d0f8be8b12a7ef6(doc, root || doc, NodeFilter.SHOW_ELEMENT, {
|
1050
|
+
acceptNode(node) {
|
1051
|
+
var _opts_from;
|
1052
|
+
if (opts === null || opts === void 0 ? void 0 : (_opts_from = opts.from) === null || _opts_from === void 0 ? void 0 : _opts_from.contains(node)) return NodeFilter.FILTER_REJECT;
|
1053
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.tabbable) && node.tagName === "INPUT" && node.getAttribute("type") === "radio") {
|
1054
|
+
if (!$9bf71ea28793e738$var$isTabbableRadio(node)) return NodeFilter.FILTER_REJECT;
|
1055
|
+
if (walker.currentNode.tagName === "INPUT" && walker.currentNode.type === "radio" && walker.currentNode.name === node.name) return NodeFilter.FILTER_REJECT;
|
1056
|
+
}
|
1057
|
+
if (filter(node) && (!scope || $9bf71ea28793e738$var$isElementInScope(node, scope)) && (!(opts === null || opts === void 0 ? void 0 : opts.accept) || opts.accept(node))) return NodeFilter.FILTER_ACCEPT;
|
1058
|
+
return NodeFilter.FILTER_SKIP;
|
1059
|
+
}
|
1060
|
+
});
|
1061
|
+
if (opts === null || opts === void 0 ? void 0 : opts.from) walker.currentNode = opts.from;
|
1062
|
+
return walker;
|
1063
|
+
}
|
1064
|
+
class $9bf71ea28793e738$var$Tree {
|
1065
|
+
get size() {
|
1066
|
+
return this.fastMap.size;
|
1067
|
+
}
|
1068
|
+
getTreeNode(data) {
|
1069
|
+
return this.fastMap.get(data);
|
1070
|
+
}
|
1071
|
+
addTreeNode(scopeRef, parent, nodeToRestore) {
|
1072
|
+
let parentNode = this.fastMap.get(parent !== null && parent !== void 0 ? parent : null);
|
1073
|
+
if (!parentNode) return;
|
1074
|
+
let node = new $9bf71ea28793e738$var$TreeNode({
|
1075
|
+
scopeRef
|
1076
|
+
});
|
1077
|
+
parentNode.addChild(node);
|
1078
|
+
node.parent = parentNode;
|
1079
|
+
this.fastMap.set(scopeRef, node);
|
1080
|
+
if (nodeToRestore) node.nodeToRestore = nodeToRestore;
|
1081
|
+
}
|
1082
|
+
addNode(node) {
|
1083
|
+
this.fastMap.set(node.scopeRef, node);
|
1084
|
+
}
|
1085
|
+
removeTreeNode(scopeRef) {
|
1086
|
+
if (scopeRef === null) return;
|
1087
|
+
let node = this.fastMap.get(scopeRef);
|
1088
|
+
if (!node) return;
|
1089
|
+
let parentNode = node.parent;
|
1090
|
+
for (let current of this.traverse()) if (current !== node && node.nodeToRestore && current.nodeToRestore && node.scopeRef && node.scopeRef.current && $9bf71ea28793e738$var$isElementInScope(current.nodeToRestore, node.scopeRef.current)) current.nodeToRestore = node.nodeToRestore;
|
1091
|
+
let children = node.children;
|
1092
|
+
if (parentNode) {
|
1093
|
+
parentNode.removeChild(node);
|
1094
|
+
if (children.size > 0) children.forEach((child) => parentNode && parentNode.addChild(child));
|
1095
|
+
}
|
1096
|
+
this.fastMap.delete(node.scopeRef);
|
1097
|
+
}
|
1098
|
+
// Pre Order Depth First
|
1099
|
+
*traverse(node = this.root) {
|
1100
|
+
if (node.scopeRef != null) yield node;
|
1101
|
+
if (node.children.size > 0) for (let child of node.children) yield* this.traverse(child);
|
1102
|
+
}
|
1103
|
+
clone() {
|
1104
|
+
var _node_parent;
|
1105
|
+
let newTree = new $9bf71ea28793e738$var$Tree();
|
1106
|
+
var _node_parent_scopeRef;
|
1107
|
+
for (let node of this.traverse()) 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);
|
1108
|
+
return newTree;
|
1109
|
+
}
|
1110
|
+
constructor() {
|
1111
|
+
this.fastMap = /* @__PURE__ */ new Map();
|
1112
|
+
this.root = new $9bf71ea28793e738$var$TreeNode({
|
1113
|
+
scopeRef: null
|
1114
|
+
});
|
1115
|
+
this.fastMap.set(null, this.root);
|
1116
|
+
}
|
1117
|
+
}
|
1118
|
+
class $9bf71ea28793e738$var$TreeNode {
|
1119
|
+
addChild(node) {
|
1120
|
+
this.children.add(node);
|
1121
|
+
node.parent = this;
|
1122
|
+
}
|
1123
|
+
removeChild(node) {
|
1124
|
+
this.children.delete(node);
|
1125
|
+
node.parent = void 0;
|
1126
|
+
}
|
1127
|
+
constructor(props) {
|
1128
|
+
this.children = /* @__PURE__ */ new Set();
|
1129
|
+
this.contain = false;
|
1130
|
+
this.scopeRef = props.scopeRef;
|
1131
|
+
}
|
1132
|
+
}
|
1133
|
+
let $9bf71ea28793e738$export$d06fae2ee68b101e = new $9bf71ea28793e738$var$Tree();
|
1134
|
+
const list = "list__U846B";
|
1135
|
+
const listItem = "listItem__bAYUj";
|
1136
|
+
const button = "button__-48ze";
|
1137
|
+
const label = "label__qyi8r";
|
1138
|
+
const counter = "counter__nHcF5";
|
1139
|
+
const styles = {
|
1140
|
+
list,
|
1141
|
+
listItem,
|
1142
|
+
button,
|
1143
|
+
label,
|
1144
|
+
counter
|
1145
|
+
};
|
1146
|
+
const DEFAULT_ORIENTATION = "horizontal";
|
1147
|
+
function ChipsRoot({
|
1148
|
+
children,
|
1149
|
+
orientation = DEFAULT_ORIENTATION
|
1150
|
+
}) {
|
1151
|
+
return /* @__PURE__ */ jsx(OrientationProvider, { orientation, children: /* @__PURE__ */ jsx(RovingTabIndexProvider, { children }) });
|
1152
|
+
}
|
1153
|
+
const ChipsList = forwardRef(function ChipsList2({
|
1154
|
+
children,
|
1155
|
+
orientation = DEFAULT_ORIENTATION,
|
1156
|
+
...props
|
1157
|
+
}, ref) {
|
1158
|
+
return /* @__PURE__ */ jsx("ul", { ...props, ref, className: styles.list, "data-orientation": orientation, children: /* @__PURE__ */ jsx($9bf71ea28793e738$export$20e40289641fbbb6, { children }) });
|
1159
|
+
});
|
1160
|
+
function ChipListItem({
|
1161
|
+
children,
|
1162
|
+
...props
|
1163
|
+
}) {
|
1164
|
+
return /* @__PURE__ */ jsx("li", { ...props, className: styles.listItem, children });
|
1165
|
+
}
|
1166
|
+
const ChipButton = forwardRef(function ChipButton2({
|
1167
|
+
children,
|
1168
|
+
onKeyDown,
|
1169
|
+
variant,
|
1170
|
+
icon,
|
1171
|
+
countryFlagCode,
|
1172
|
+
dsInternalSimulation,
|
1173
|
+
...props
|
1174
|
+
}, incomingRef) {
|
1175
|
+
const {
|
1176
|
+
ref: rovingTabIndexRef,
|
1177
|
+
...rovingTabIndexProps
|
1178
|
+
} = useRovingTabIndex(props);
|
1179
|
+
const focusManager = $9bf71ea28793e738$export$10c5169755ce7bd7();
|
1180
|
+
const {
|
1181
|
+
nextKey,
|
1182
|
+
previousKey
|
1183
|
+
} = useOrientation();
|
1184
|
+
const handleKeyDown = (e) => {
|
1185
|
+
onKeyDown == null ? void 0 : onKeyDown(e);
|
1186
|
+
if (e.defaultPrevented) return;
|
1187
|
+
switch (e.key) {
|
1188
|
+
case nextKey:
|
1189
|
+
focusManager == null ? void 0 : focusManager.focusNext({
|
1190
|
+
wrap: true
|
1191
|
+
});
|
1192
|
+
break;
|
1193
|
+
case previousKey:
|
1194
|
+
focusManager == null ? void 0 : focusManager.focusPrevious({
|
1195
|
+
wrap: true
|
1196
|
+
});
|
1197
|
+
break;
|
1198
|
+
case "Home":
|
1199
|
+
focusManager == null ? void 0 : focusManager.focusFirst();
|
1200
|
+
break;
|
1201
|
+
case "End":
|
1202
|
+
focusManager == null ? void 0 : focusManager.focusLast();
|
1203
|
+
break;
|
1204
|
+
}
|
1205
|
+
};
|
1206
|
+
const ref = useMergeRefs(incomingRef, rovingTabIndexRef);
|
1207
|
+
return /* @__PURE__ */ jsxs("button", { ...props, ...rovingTabIndexProps, type: "button", onKeyDown: handleKeyDown, ref, className: styles.button, "data-variant": variant, "data-ds-internal-simulation": dsInternalSimulation, children: [
|
1208
|
+
icon && /* @__PURE__ */ jsx(Icon, { dataset: {
|
1209
|
+
testid: "chip-icon"
|
1210
|
+
}, svg: icon }),
|
1211
|
+
countryFlagCode && !icon && /* @__PURE__ */ jsx(CountryFlag, { code: countryFlagCode, size: "medium", dataset: {
|
1212
|
+
testid: "chip-country-flag"
|
1213
|
+
}, alt: "" }),
|
1214
|
+
children
|
1215
|
+
] });
|
1216
|
+
});
|
1217
|
+
function ChipLabel({
|
1218
|
+
children,
|
1219
|
+
counter: counter2,
|
1220
|
+
...props
|
1221
|
+
}) {
|
1222
|
+
return /* @__PURE__ */ jsxs("span", { ...props, className: styles.label, children: [
|
1223
|
+
children,
|
1224
|
+
counter2 !== void 0 && /* @__PURE__ */ jsx(ChipCounter, { children: counter2 })
|
1225
|
+
] });
|
1226
|
+
}
|
1227
|
+
function ChipCounter({
|
1228
|
+
children,
|
1229
|
+
...props
|
1230
|
+
}) {
|
1231
|
+
return /* @__PURE__ */ jsx("span", { "data-testid": "chip-counter", ...props, className: styles.counter, children });
|
1232
|
+
}
|
1233
|
+
export {
|
1234
|
+
$9bf71ea28793e738$export$10c5169755ce7bd7 as $,
|
1235
|
+
ChipsRoot as C,
|
1236
|
+
DEFAULT_ORIENTATION as D,
|
1237
|
+
ChipsList as a,
|
1238
|
+
ChipListItem as b,
|
1239
|
+
ChipButton as c,
|
1240
|
+
ChipLabel as d,
|
1241
|
+
ChipCounter as e
|
1242
|
+
};
|