@altinn/altinn-components 0.56.31 → 0.56.33
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/assets/MenuItem.css +1 -1
- package/dist/components/DsComponents/index.js +1 -1
- package/dist/components/GlobalHeader/AccountSelector.js +37 -38
- package/dist/components/Menu/MenuItem.js +63 -62
- package/dist/components/Toolbar/example.data.js +16 -7
- package/dist/components/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/textfield-CRXtg-r5.js +3487 -0
- package/dist/types/lib/components/Toolbar/example.hooks.d.ts +12 -2
- package/package.json +2 -2
- package/dist/textfield-DP1SL4Wr.js +0 -3406
|
@@ -1,3406 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import * as p from "react";
|
|
3
|
-
import Tt, { forwardRef as L, useState as Ce, useRef as ge, useEffect as de, createContext as Pe, useContext as oe, useMemo as Le, useLayoutEffect as zn, useReducer as _r, useId as ze, isValidElement as Vn, memo as Lr, useCallback as zr, Children as dn, version as Vr } from "react";
|
|
4
|
-
import { jsx as v, jsxs as se, Fragment as Ht } from "react/jsx-runtime";
|
|
5
|
-
import { c as X } from "./lite-1fxw3LjI.js";
|
|
6
|
-
import { S as ie, a as Br } from "./index-D7FJjvrv.js";
|
|
7
|
-
import * as Bn from "react-dom";
|
|
8
|
-
import { flushSync as $n } from "react-dom";
|
|
9
|
-
import { S as $r, B as Ge, u as Kr } from "./button-BB5sYVKY.js";
|
|
10
|
-
import { V as Ut, u as Xt, F as ht, a as jr, b as Wr, c as fn } from "./index-z82sbSVU.js";
|
|
11
|
-
import { P as Bt } from "./paragraph-BRiIBpbY.js";
|
|
12
|
-
import { I as rt } from "./input-wBv_FkEV.js";
|
|
13
|
-
import { S as qr } from "./XMark-tKk6aExO.js";
|
|
14
|
-
import { S as Hr, a as Ur } from "./ChevronUp-_BBfEirx.js";
|
|
15
|
-
import { L as Oe } from "./label-xTmTyPhk.js";
|
|
16
|
-
import { u as Xr } from "./useId-BVFxCjkq.js";
|
|
17
|
-
import { S as Gr } from "./Checkmark-Byz_C9x4.js";
|
|
18
|
-
import { f as Kn, b as Yr, o as jn, c as Wn, g as kt, a as qn, s as Zr } from "./floating-ui.dom-bEgaHJCq.js";
|
|
19
|
-
import { u as Ve } from "./use-merge-refs-Cj4kTYVj.js";
|
|
20
|
-
import { T as Jr } from "./textarea-BBstVlPT.js";
|
|
21
|
-
var Qr = function(e, n) {
|
|
22
|
-
var t = {};
|
|
23
|
-
for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && n.indexOf(r) < 0 && (t[r] = e[r]);
|
|
24
|
-
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
25
|
-
for (var o = 0, r = Object.getOwnPropertySymbols(e); o < r.length; o++)
|
|
26
|
-
n.indexOf(r[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[o]) && (t[r[o]] = e[r[o]]);
|
|
27
|
-
return t;
|
|
28
|
-
};
|
|
29
|
-
const eo = L((e, n) => {
|
|
30
|
-
var { title: t, titleId: r } = e, o = Qr(e, ["title", "titleId"]);
|
|
31
|
-
let s = Xr();
|
|
32
|
-
return s = t ? r || "title-" + s : void 0, Tt.createElement(
|
|
33
|
-
"svg",
|
|
34
|
-
Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24", focusable: !1, role: "img", ref: n, "aria-labelledby": s }, o),
|
|
35
|
-
t ? Tt.createElement("title", { id: s }, t) : null,
|
|
36
|
-
Tt.createElement("path", { fill: "currentColor", fillRule: "evenodd", d: "M12 2.25A4.75 4.75 0 0 0 7.25 7v2.25H7A1.75 1.75 0 0 0 5.25 11v9c0 .414.336.75.75.75h12a.75.75 0 0 0 .75-.75v-9A1.75 1.75 0 0 0 17 9.25h-.25V7A4.75 4.75 0 0 0 12 2.25m3.25 7V7a3.25 3.25 0 0 0-6.5 0v2.25zM12 13a1.5 1.5 0 0 0-.75 2.8V17a.75.75 0 0 0 1.5 0v-1.2A1.5 1.5 0 0 0 12 13", clipRule: "evenodd" })
|
|
37
|
-
);
|
|
38
|
-
}), We = (e, n) => {
|
|
39
|
-
const t = {}, r = {};
|
|
40
|
-
let o = 0;
|
|
41
|
-
const s = e.length;
|
|
42
|
-
for (; o < s; )
|
|
43
|
-
r[e[o]] = 1, o += 1;
|
|
44
|
-
for (const i in n)
|
|
45
|
-
Object.hasOwn(r, i) || (t[i] = n[i]);
|
|
46
|
-
return t;
|
|
47
|
-
}, Hn = Pe({
|
|
48
|
-
elements: { current: /* @__PURE__ */ new Map() },
|
|
49
|
-
getOrderedItems: () => [],
|
|
50
|
-
setFocusableValue: () => {
|
|
51
|
-
},
|
|
52
|
-
onShiftTab: () => {
|
|
53
|
-
},
|
|
54
|
-
focusableValue: null,
|
|
55
|
-
orientation: "horizontal"
|
|
56
|
-
}), to = L(({ activeValue: e, asChild: n, orientation: t = "horizontal", onBlur: r, onFocus: o, ...s }, i) => {
|
|
57
|
-
const a = n ? ie : "div", l = e ?? null, [c, f] = Ce(l), [d, h] = Ce(!1), u = ge(/* @__PURE__ */ new Map()), m = ge(null), g = Ve([i, m]), w = () => {
|
|
58
|
-
if (!m.current)
|
|
59
|
-
return [];
|
|
60
|
-
const x = Array.from(m.current.querySelectorAll("[data-roving-tabindex-item]"));
|
|
61
|
-
return Array.from(u.current).sort((y, b) => x.indexOf(y[1]) - x.indexOf(b[1])).map(([y, b]) => ({ value: y, element: b }));
|
|
62
|
-
};
|
|
63
|
-
return de(() => {
|
|
64
|
-
f(l);
|
|
65
|
-
}, [l]), v(Hn.Provider, { value: {
|
|
66
|
-
elements: u,
|
|
67
|
-
getOrderedItems: w,
|
|
68
|
-
focusableValue: c,
|
|
69
|
-
setFocusableValue: f,
|
|
70
|
-
onShiftTab: () => {
|
|
71
|
-
h(!0);
|
|
72
|
-
},
|
|
73
|
-
orientation: t
|
|
74
|
-
}, children: v(a, { ...s, tabIndex: d ? -1 : 0, onBlur: (x) => {
|
|
75
|
-
r?.(x), h(!1), f(e ?? null);
|
|
76
|
-
}, onFocus: (x) => {
|
|
77
|
-
if (o?.(x), x.target !== x.currentTarget)
|
|
78
|
-
return;
|
|
79
|
-
const y = w();
|
|
80
|
-
y.length !== 0 && (c != null ? u.current.get(c)?.focus() : e != null ? u.current.get(e)?.focus() : y.at(0)?.element.focus());
|
|
81
|
-
}, ref: g }) });
|
|
82
|
-
}), no = (e) => {
|
|
83
|
-
const { elements: n, getOrderedItems: t, setFocusableValue: r, focusableValue: o, onShiftTab: s, orientation: i } = oe(Hn);
|
|
84
|
-
return {
|
|
85
|
-
getOrderedItems: t,
|
|
86
|
-
isFocusable: o === e,
|
|
87
|
-
orientation: i,
|
|
88
|
-
getRovingProps: (a) => ({
|
|
89
|
-
...a,
|
|
90
|
-
ref: (l) => {
|
|
91
|
-
l ? n.current.set(e, l) : n.current.delete(e);
|
|
92
|
-
},
|
|
93
|
-
onKeyDown: (l) => {
|
|
94
|
-
if (a?.onKeyDown?.(l), l.shiftKey && l.key === "Tab") {
|
|
95
|
-
s();
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
onFocus: (l) => {
|
|
100
|
-
a?.onFocus?.(l), r(e);
|
|
101
|
-
},
|
|
102
|
-
"data-roving-tabindex-item": !0,
|
|
103
|
-
tabIndex: o === e ? 0 : -1
|
|
104
|
-
})
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
function Mt(e, n) {
|
|
108
|
-
const t = e.findIndex((r) => r.value === n);
|
|
109
|
-
return e.at(t === e.length - 1 ? 0 : t + 1);
|
|
110
|
-
}
|
|
111
|
-
function Nt(e, n) {
|
|
112
|
-
const t = e.findIndex((r) => r.value === n);
|
|
113
|
-
return e.at(t === 0 ? -1 : t - 1);
|
|
114
|
-
}
|
|
115
|
-
const ro = L(({ value: e, asChild: n, ...t }, r) => {
|
|
116
|
-
const o = n ? ie : "div", s = e ?? (typeof t.children == "string" ? t.children : ""), { getOrderedItems: i, getRovingProps: a, orientation: l } = no(s), c = a({
|
|
117
|
-
onKeyDown: (d) => {
|
|
118
|
-
t?.onKeyDown?.(d);
|
|
119
|
-
const h = i();
|
|
120
|
-
let u;
|
|
121
|
-
switch (l) {
|
|
122
|
-
case "horizontal":
|
|
123
|
-
d.key === "ArrowRight" && (u = Mt(h, s)), d.key === "ArrowLeft" && (u = Nt(h, s));
|
|
124
|
-
break;
|
|
125
|
-
case "vertical":
|
|
126
|
-
d.key === "ArrowDown" && (u = Mt(h, s)), d.key === "ArrowUp" && (u = Nt(h, s));
|
|
127
|
-
break;
|
|
128
|
-
case "ambiguous":
|
|
129
|
-
["ArrowRight", "ArrowDown"].includes(d.key) && (u = Mt(h, s)), ["ArrowLeft", "ArrowUp"].includes(d.key) && (u = Nt(h, s));
|
|
130
|
-
}
|
|
131
|
-
d.key === "Home" && (u = h[0]), d.key === "End" && (u = h[h.length - 1]), u && (d.preventDefault(), u.element.focus());
|
|
132
|
-
}
|
|
133
|
-
}), f = Ve([r, c.ref]);
|
|
134
|
-
return v(o, { ...t, ...c, ref: f, children: t.children });
|
|
135
|
-
}), oo = (e, n, t) => {
|
|
136
|
-
const r = (t - 1) / 2, o = Math.max(1, Math.min(Math.max(e - Math.floor(r), 1), n - t + 1)), s = Math.min(Math.max(e + Math.ceil(r), t), n), i = Array.from({ length: s + 1 - o }, (a, l) => l + o);
|
|
137
|
-
return t > 4 && o > 1 && i.splice(0, 2, 1, 0), t > 3 && s < n && i.splice(-2, 2, 0, n), i;
|
|
138
|
-
}, Mi = ({ currentPage: e = 1, setCurrentPage: n, onChange: t, totalPages: r = 1, showPages: o = 7 }) => Le(() => {
|
|
139
|
-
const s = e < r, i = e !== 1, a = (l) => (c) => {
|
|
140
|
-
if (l < 1 || l > r)
|
|
141
|
-
return c.preventDefault();
|
|
142
|
-
t?.(c, l), c.defaultPrevented || n?.(l);
|
|
143
|
-
};
|
|
144
|
-
return {
|
|
145
|
-
/** Number of steps */
|
|
146
|
-
pages: oo(e, r, o).map((l, c) => ({
|
|
147
|
-
/**
|
|
148
|
-
* Page number or "ellipsis" for the ellipsis item
|
|
149
|
-
*/
|
|
150
|
-
page: l || "ellipsis",
|
|
151
|
-
/**
|
|
152
|
-
* Unique key for the item
|
|
153
|
-
*/
|
|
154
|
-
itemKey: l ? `page-${l}` : `ellipsis-${c}`,
|
|
155
|
-
// React key utility
|
|
156
|
-
/**
|
|
157
|
-
* Properties to spread on Pagination.Button
|
|
158
|
-
*/
|
|
159
|
-
buttonProps: l ? {
|
|
160
|
-
"aria-current": l === e ? "page" : void 0,
|
|
161
|
-
onClick: a(l),
|
|
162
|
-
variant: l === e ? "primary" : "tertiary"
|
|
163
|
-
} : null
|
|
164
|
-
})),
|
|
165
|
-
/** Properties to spread on Pagination.Button used for previous naviagation */
|
|
166
|
-
prevButtonProps: {
|
|
167
|
-
"aria-hidden": !i,
|
|
168
|
-
// Using aria-hidden to support all HTML elements because of potential asChild
|
|
169
|
-
onClick: a(e - 1),
|
|
170
|
-
variant: "tertiary"
|
|
171
|
-
},
|
|
172
|
-
/** Properties to spread on Pagination.Button used for next naviagation */
|
|
173
|
-
nextButtonProps: {
|
|
174
|
-
"aria-hidden": !s,
|
|
175
|
-
// Using aria-hidden to support all HTML elements because of potential asChild
|
|
176
|
-
onClick: a(e + 1),
|
|
177
|
-
variant: "tertiary"
|
|
178
|
-
},
|
|
179
|
-
/** Indication if previous page action should be shown or not */
|
|
180
|
-
hasPrev: i,
|
|
181
|
-
/** Indication if next page action should be shown or not */
|
|
182
|
-
hasNext: s
|
|
183
|
-
};
|
|
184
|
-
}, [e, r, o]), so = L(function({ className: n, count: t, maxCount: r, variant: o = "base", ...s }, i) {
|
|
185
|
-
return v("span", { className: X("ds-badge", n), "data-count": t && r && t > r ? `${r}+` : t, "data-variant": o, ref: i, ...s });
|
|
186
|
-
}), io = L(function({ className: n, overlap: t = "rectangle", placement: r = "top-right", ...o }, s) {
|
|
187
|
-
return v("span", { className: X("ds-badge--position", n), "data-overlap": t, "data-placement": r, ref: s, ...o });
|
|
188
|
-
}), ao = Object.assign(so, { Position: io });
|
|
189
|
-
ao.Position.displayName = "Badge.Position";
|
|
190
|
-
const lo = L(({ asChild: e, className: n, ...t }, r) => v(e ? ie : "a", { className: X("ds-link", n), ref: r, ...t }));
|
|
191
|
-
lo.displayName = "Link";
|
|
192
|
-
function xt() {
|
|
193
|
-
return typeof window < "u";
|
|
194
|
-
}
|
|
195
|
-
function Ct(e) {
|
|
196
|
-
return Un(e) ? (e.nodeName || "").toLowerCase() : "#document";
|
|
197
|
-
}
|
|
198
|
-
function ot(e) {
|
|
199
|
-
var n;
|
|
200
|
-
return (e == null || (n = e.ownerDocument) == null ? void 0 : n.defaultView) || window;
|
|
201
|
-
}
|
|
202
|
-
function co(e) {
|
|
203
|
-
var n;
|
|
204
|
-
return (n = (Un(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : n.documentElement;
|
|
205
|
-
}
|
|
206
|
-
function Un(e) {
|
|
207
|
-
return xt() ? e instanceof Node || e instanceof ot(e).Node : !1;
|
|
208
|
-
}
|
|
209
|
-
function be(e) {
|
|
210
|
-
return xt() ? e instanceof Element || e instanceof ot(e).Element : !1;
|
|
211
|
-
}
|
|
212
|
-
function Re(e) {
|
|
213
|
-
return xt() ? e instanceof HTMLElement || e instanceof ot(e).HTMLElement : !1;
|
|
214
|
-
}
|
|
215
|
-
function $t(e) {
|
|
216
|
-
return !xt() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof ot(e).ShadowRoot;
|
|
217
|
-
}
|
|
218
|
-
function hn(e) {
|
|
219
|
-
return ["html", "body", "#document"].includes(Ct(e));
|
|
220
|
-
}
|
|
221
|
-
function uo(e) {
|
|
222
|
-
return ot(e).getComputedStyle(e);
|
|
223
|
-
}
|
|
224
|
-
function fo(e) {
|
|
225
|
-
if (Ct(e) === "html")
|
|
226
|
-
return e;
|
|
227
|
-
const n = (
|
|
228
|
-
// Step into the shadow DOM of the parent of a slotted node.
|
|
229
|
-
e.assignedSlot || // DOM Element detected.
|
|
230
|
-
e.parentNode || // ShadowRoot detected.
|
|
231
|
-
$t(e) && e.host || // Fallback.
|
|
232
|
-
co(e)
|
|
233
|
-
);
|
|
234
|
-
return $t(n) ? n.host : n;
|
|
235
|
-
}
|
|
236
|
-
function Se(e) {
|
|
237
|
-
let n = e.activeElement;
|
|
238
|
-
for (; ((t = n) == null || (t = t.shadowRoot) == null ? void 0 : t.activeElement) != null; ) {
|
|
239
|
-
var t;
|
|
240
|
-
n = n.shadowRoot.activeElement;
|
|
241
|
-
}
|
|
242
|
-
return n;
|
|
243
|
-
}
|
|
244
|
-
function ce(e, n) {
|
|
245
|
-
if (!e || !n)
|
|
246
|
-
return !1;
|
|
247
|
-
const t = n.getRootNode == null ? void 0 : n.getRootNode();
|
|
248
|
-
if (e.contains(n))
|
|
249
|
-
return !0;
|
|
250
|
-
if (t && $t(t)) {
|
|
251
|
-
let r = n;
|
|
252
|
-
for (; r; ) {
|
|
253
|
-
if (e === r)
|
|
254
|
-
return !0;
|
|
255
|
-
r = r.parentNode || r.host;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
return !1;
|
|
259
|
-
}
|
|
260
|
-
function Xn() {
|
|
261
|
-
const e = navigator.userAgentData;
|
|
262
|
-
return e != null && e.platform ? e.platform : navigator.platform;
|
|
263
|
-
}
|
|
264
|
-
function Gn() {
|
|
265
|
-
const e = navigator.userAgentData;
|
|
266
|
-
return e && Array.isArray(e.brands) ? e.brands.map((n) => {
|
|
267
|
-
let {
|
|
268
|
-
brand: t,
|
|
269
|
-
version: r
|
|
270
|
-
} = n;
|
|
271
|
-
return t + "/" + r;
|
|
272
|
-
}).join(" ") : navigator.userAgent;
|
|
273
|
-
}
|
|
274
|
-
function Yn(e) {
|
|
275
|
-
return e.mozInputSource === 0 && e.isTrusted ? !0 : Kt() && e.pointerType ? e.type === "click" && e.buttons === 1 : e.detail === 0 && !e.pointerType;
|
|
276
|
-
}
|
|
277
|
-
function Zn(e) {
|
|
278
|
-
return mo() ? !1 : !Kt() && e.width === 0 && e.height === 0 || Kt() && e.width === 1 && e.height === 1 && e.pressure === 0 && e.detail === 0 && e.pointerType === "mouse" || // iOS VoiceOver returns 0.333• for width/height.
|
|
279
|
-
e.width < 1 && e.height < 1 && e.pressure === 0 && e.detail === 0 && e.pointerType === "touch";
|
|
280
|
-
}
|
|
281
|
-
function Jn() {
|
|
282
|
-
return /apple/i.test(navigator.vendor);
|
|
283
|
-
}
|
|
284
|
-
function Kt() {
|
|
285
|
-
const e = /android/i;
|
|
286
|
-
return e.test(Xn()) || e.test(Gn());
|
|
287
|
-
}
|
|
288
|
-
function ho() {
|
|
289
|
-
return Xn().toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
|
|
290
|
-
}
|
|
291
|
-
function mo() {
|
|
292
|
-
return Gn().includes("jsdom/");
|
|
293
|
-
}
|
|
294
|
-
function po(e) {
|
|
295
|
-
return "nativeEvent" in e;
|
|
296
|
-
}
|
|
297
|
-
function bo(e) {
|
|
298
|
-
return e.matches("html,body");
|
|
299
|
-
}
|
|
300
|
-
function pe(e) {
|
|
301
|
-
return e?.ownerDocument || document;
|
|
302
|
-
}
|
|
303
|
-
function Pt(e, n) {
|
|
304
|
-
if (n == null)
|
|
305
|
-
return !1;
|
|
306
|
-
if ("composedPath" in e)
|
|
307
|
-
return e.composedPath().includes(n);
|
|
308
|
-
const t = e;
|
|
309
|
-
return t.target != null && n.contains(t.target);
|
|
310
|
-
}
|
|
311
|
-
function _e(e) {
|
|
312
|
-
return "composedPath" in e ? e.composedPath()[0] : e.target;
|
|
313
|
-
}
|
|
314
|
-
const go = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
|
|
315
|
-
function vo(e) {
|
|
316
|
-
return Re(e) && e.matches(go);
|
|
317
|
-
}
|
|
318
|
-
function ue(e) {
|
|
319
|
-
e.preventDefault(), e.stopPropagation();
|
|
320
|
-
}
|
|
321
|
-
function Qn(e) {
|
|
322
|
-
return e ? e.getAttribute("role") === "combobox" && vo(e) : !1;
|
|
323
|
-
}
|
|
324
|
-
const mn = Math.floor;
|
|
325
|
-
var yo = ["input:not([inert])", "select:not([inert])", "textarea:not([inert])", "a[href]:not([inert])", "button:not([inert])", "[tabindex]:not(slot):not([inert])", "audio[controls]:not([inert])", "video[controls]:not([inert])", '[contenteditable]:not([contenteditable="false"]):not([inert])', "details>summary:first-of-type:not([inert])", "details:not([inert])"], mt = /* @__PURE__ */ yo.join(","), er = typeof Element > "u", qe = er ? function() {
|
|
326
|
-
} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, pt = !er && Element.prototype.getRootNode ? function(e) {
|
|
327
|
-
var n;
|
|
328
|
-
return e == null || (n = e.getRootNode) === null || n === void 0 ? void 0 : n.call(e);
|
|
329
|
-
} : function(e) {
|
|
330
|
-
return e?.ownerDocument;
|
|
331
|
-
}, bt = function e(n, t) {
|
|
332
|
-
var r;
|
|
333
|
-
t === void 0 && (t = !0);
|
|
334
|
-
var o = n == null || (r = n.getAttribute) === null || r === void 0 ? void 0 : r.call(n, "inert"), s = o === "" || o === "true", i = s || t && n && e(n.parentNode);
|
|
335
|
-
return i;
|
|
336
|
-
}, xo = function(n) {
|
|
337
|
-
var t, r = n == null || (t = n.getAttribute) === null || t === void 0 ? void 0 : t.call(n, "contenteditable");
|
|
338
|
-
return r === "" || r === "true";
|
|
339
|
-
}, Co = function(n, t, r) {
|
|
340
|
-
if (bt(n))
|
|
341
|
-
return [];
|
|
342
|
-
var o = Array.prototype.slice.apply(n.querySelectorAll(mt));
|
|
343
|
-
return t && qe.call(n, mt) && o.unshift(n), o = o.filter(r), o;
|
|
344
|
-
}, wo = function e(n, t, r) {
|
|
345
|
-
for (var o = [], s = Array.from(n); s.length; ) {
|
|
346
|
-
var i = s.shift();
|
|
347
|
-
if (!bt(i, !1))
|
|
348
|
-
if (i.tagName === "SLOT") {
|
|
349
|
-
var a = i.assignedElements(), l = a.length ? a : i.children, c = e(l, !0, r);
|
|
350
|
-
r.flatten ? o.push.apply(o, c) : o.push({
|
|
351
|
-
scopeParent: i,
|
|
352
|
-
candidates: c
|
|
353
|
-
});
|
|
354
|
-
} else {
|
|
355
|
-
var f = qe.call(i, mt);
|
|
356
|
-
f && r.filter(i) && (t || !n.includes(i)) && o.push(i);
|
|
357
|
-
var d = i.shadowRoot || // check for an undisclosed shadow
|
|
358
|
-
typeof r.getShadowRoot == "function" && r.getShadowRoot(i), h = !bt(d, !1) && (!r.shadowRootFilter || r.shadowRootFilter(i));
|
|
359
|
-
if (d && h) {
|
|
360
|
-
var u = e(d === !0 ? i.children : d.children, !0, r);
|
|
361
|
-
r.flatten ? o.push.apply(o, u) : o.push({
|
|
362
|
-
scopeParent: i,
|
|
363
|
-
candidates: u
|
|
364
|
-
});
|
|
365
|
-
} else
|
|
366
|
-
s.unshift.apply(s, i.children);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
return o;
|
|
370
|
-
}, tr = function(n) {
|
|
371
|
-
return !isNaN(parseInt(n.getAttribute("tabindex"), 10));
|
|
372
|
-
}, nr = function(n) {
|
|
373
|
-
if (!n)
|
|
374
|
-
throw new Error("No node provided");
|
|
375
|
-
return n.tabIndex < 0 && (/^(AUDIO|VIDEO|DETAILS)$/.test(n.tagName) || xo(n)) && !tr(n) ? 0 : n.tabIndex;
|
|
376
|
-
}, Eo = function(n, t) {
|
|
377
|
-
var r = nr(n);
|
|
378
|
-
return r < 0 && t && !tr(n) ? 0 : r;
|
|
379
|
-
}, Io = function(n, t) {
|
|
380
|
-
return n.tabIndex === t.tabIndex ? n.documentOrder - t.documentOrder : n.tabIndex - t.tabIndex;
|
|
381
|
-
}, rr = function(n) {
|
|
382
|
-
return n.tagName === "INPUT";
|
|
383
|
-
}, Ro = function(n) {
|
|
384
|
-
return rr(n) && n.type === "hidden";
|
|
385
|
-
}, So = function(n) {
|
|
386
|
-
var t = n.tagName === "DETAILS" && Array.prototype.slice.apply(n.children).some(function(r) {
|
|
387
|
-
return r.tagName === "SUMMARY";
|
|
388
|
-
});
|
|
389
|
-
return t;
|
|
390
|
-
}, Oo = function(n, t) {
|
|
391
|
-
for (var r = 0; r < n.length; r++)
|
|
392
|
-
if (n[r].checked && n[r].form === t)
|
|
393
|
-
return n[r];
|
|
394
|
-
}, To = function(n) {
|
|
395
|
-
if (!n.name)
|
|
396
|
-
return !0;
|
|
397
|
-
var t = n.form || pt(n), r = function(a) {
|
|
398
|
-
return t.querySelectorAll('input[type="radio"][name="' + a + '"]');
|
|
399
|
-
}, o;
|
|
400
|
-
if (typeof window < "u" && typeof window.CSS < "u" && typeof window.CSS.escape == "function")
|
|
401
|
-
o = r(window.CSS.escape(n.name));
|
|
402
|
-
else
|
|
403
|
-
try {
|
|
404
|
-
o = r(n.name);
|
|
405
|
-
} catch (i) {
|
|
406
|
-
return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", i.message), !1;
|
|
407
|
-
}
|
|
408
|
-
var s = Oo(o, n.form);
|
|
409
|
-
return !s || s === n;
|
|
410
|
-
}, ko = function(n) {
|
|
411
|
-
return rr(n) && n.type === "radio";
|
|
412
|
-
}, Mo = function(n) {
|
|
413
|
-
return ko(n) && !To(n);
|
|
414
|
-
}, No = function(n) {
|
|
415
|
-
var t, r = n && pt(n), o = (t = r) === null || t === void 0 ? void 0 : t.host, s = !1;
|
|
416
|
-
if (r && r !== n) {
|
|
417
|
-
var i, a, l;
|
|
418
|
-
for (s = !!((i = o) !== null && i !== void 0 && (a = i.ownerDocument) !== null && a !== void 0 && a.contains(o) || n != null && (l = n.ownerDocument) !== null && l !== void 0 && l.contains(n)); !s && o; ) {
|
|
419
|
-
var c, f, d;
|
|
420
|
-
r = pt(o), o = (c = r) === null || c === void 0 ? void 0 : c.host, s = !!((f = o) !== null && f !== void 0 && (d = f.ownerDocument) !== null && d !== void 0 && d.contains(o));
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
return s;
|
|
424
|
-
}, pn = function(n) {
|
|
425
|
-
var t = n.getBoundingClientRect(), r = t.width, o = t.height;
|
|
426
|
-
return r === 0 && o === 0;
|
|
427
|
-
}, Po = function(n, t) {
|
|
428
|
-
var r = t.displayCheck, o = t.getShadowRoot;
|
|
429
|
-
if (getComputedStyle(n).visibility === "hidden")
|
|
430
|
-
return !0;
|
|
431
|
-
var s = qe.call(n, "details>summary:first-of-type"), i = s ? n.parentElement : n;
|
|
432
|
-
if (qe.call(i, "details:not([open]) *"))
|
|
433
|
-
return !0;
|
|
434
|
-
if (!r || r === "full" || r === "legacy-full") {
|
|
435
|
-
if (typeof o == "function") {
|
|
436
|
-
for (var a = n; n; ) {
|
|
437
|
-
var l = n.parentElement, c = pt(n);
|
|
438
|
-
if (l && !l.shadowRoot && o(l) === !0)
|
|
439
|
-
return pn(n);
|
|
440
|
-
n.assignedSlot ? n = n.assignedSlot : !l && c !== n.ownerDocument ? n = c.host : n = l;
|
|
441
|
-
}
|
|
442
|
-
n = a;
|
|
443
|
-
}
|
|
444
|
-
if (No(n))
|
|
445
|
-
return !n.getClientRects().length;
|
|
446
|
-
if (r !== "legacy-full")
|
|
447
|
-
return !0;
|
|
448
|
-
} else if (r === "non-zero-area")
|
|
449
|
-
return pn(n);
|
|
450
|
-
return !1;
|
|
451
|
-
}, Do = function(n) {
|
|
452
|
-
if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(n.tagName))
|
|
453
|
-
for (var t = n.parentElement; t; ) {
|
|
454
|
-
if (t.tagName === "FIELDSET" && t.disabled) {
|
|
455
|
-
for (var r = 0; r < t.children.length; r++) {
|
|
456
|
-
var o = t.children.item(r);
|
|
457
|
-
if (o.tagName === "LEGEND")
|
|
458
|
-
return qe.call(t, "fieldset[disabled] *") ? !0 : !o.contains(n);
|
|
459
|
-
}
|
|
460
|
-
return !0;
|
|
461
|
-
}
|
|
462
|
-
t = t.parentElement;
|
|
463
|
-
}
|
|
464
|
-
return !1;
|
|
465
|
-
}, Ao = function(n, t) {
|
|
466
|
-
return !(t.disabled || // we must do an inert look up to filter out any elements inside an inert ancestor
|
|
467
|
-
// because we're limited in the type of selectors we can use in JSDom (see related
|
|
468
|
-
// note related to `candidateSelectors`)
|
|
469
|
-
bt(t) || Ro(t) || Po(t, n) || // For a details element with a summary, the summary element gets the focus
|
|
470
|
-
So(t) || Do(t));
|
|
471
|
-
}, jt = function(n, t) {
|
|
472
|
-
return !(Mo(t) || nr(t) < 0 || !Ao(n, t));
|
|
473
|
-
}, Fo = function(n) {
|
|
474
|
-
var t = parseInt(n.getAttribute("tabindex"), 10);
|
|
475
|
-
return !!(isNaN(t) || t >= 0);
|
|
476
|
-
}, _o = function e(n) {
|
|
477
|
-
var t = [], r = [];
|
|
478
|
-
return n.forEach(function(o, s) {
|
|
479
|
-
var i = !!o.scopeParent, a = i ? o.scopeParent : o, l = Eo(a, i), c = i ? e(o.candidates) : a;
|
|
480
|
-
l === 0 ? i ? t.push.apply(t, c) : t.push(a) : r.push({
|
|
481
|
-
documentOrder: s,
|
|
482
|
-
tabIndex: l,
|
|
483
|
-
item: o,
|
|
484
|
-
isScope: i,
|
|
485
|
-
content: c
|
|
486
|
-
});
|
|
487
|
-
}), r.sort(Io).reduce(function(o, s) {
|
|
488
|
-
return s.isScope ? o.push.apply(o, s.content) : o.push(s.content), o;
|
|
489
|
-
}, []).concat(t);
|
|
490
|
-
}, tt = function(n, t) {
|
|
491
|
-
t = t || {};
|
|
492
|
-
var r;
|
|
493
|
-
return t.getShadowRoot ? r = wo([n], t.includeContainer, {
|
|
494
|
-
filter: jt.bind(null, t),
|
|
495
|
-
flatten: !1,
|
|
496
|
-
getShadowRoot: t.getShadowRoot,
|
|
497
|
-
shadowRootFilter: Fo
|
|
498
|
-
}) : r = Co(n, t.includeContainer, jt.bind(null, t)), _o(r);
|
|
499
|
-
}, Lo = function(n, t) {
|
|
500
|
-
if (t = t || {}, !n)
|
|
501
|
-
throw new Error("No node provided");
|
|
502
|
-
return qe.call(n, mt) === !1 ? !1 : jt(t, n);
|
|
503
|
-
}, dt = typeof document < "u" ? zn : de;
|
|
504
|
-
function gt(e, n) {
|
|
505
|
-
if (e === n)
|
|
506
|
-
return !0;
|
|
507
|
-
if (typeof e != typeof n)
|
|
508
|
-
return !1;
|
|
509
|
-
if (typeof e == "function" && e.toString() === n.toString())
|
|
510
|
-
return !0;
|
|
511
|
-
let t, r, o;
|
|
512
|
-
if (e && n && typeof e == "object") {
|
|
513
|
-
if (Array.isArray(e)) {
|
|
514
|
-
if (t = e.length, t !== n.length) return !1;
|
|
515
|
-
for (r = t; r-- !== 0; )
|
|
516
|
-
if (!gt(e[r], n[r]))
|
|
517
|
-
return !1;
|
|
518
|
-
return !0;
|
|
519
|
-
}
|
|
520
|
-
if (o = Object.keys(e), t = o.length, t !== Object.keys(n).length)
|
|
521
|
-
return !1;
|
|
522
|
-
for (r = t; r-- !== 0; )
|
|
523
|
-
if (!{}.hasOwnProperty.call(n, o[r]))
|
|
524
|
-
return !1;
|
|
525
|
-
for (r = t; r-- !== 0; ) {
|
|
526
|
-
const s = o[r];
|
|
527
|
-
if (!(s === "_owner" && e.$$typeof) && !gt(e[s], n[s]))
|
|
528
|
-
return !1;
|
|
529
|
-
}
|
|
530
|
-
return !0;
|
|
531
|
-
}
|
|
532
|
-
return e !== e && n !== n;
|
|
533
|
-
}
|
|
534
|
-
function or(e) {
|
|
535
|
-
return typeof window > "u" ? 1 : (e.ownerDocument.defaultView || window).devicePixelRatio || 1;
|
|
536
|
-
}
|
|
537
|
-
function bn(e, n) {
|
|
538
|
-
const t = or(e);
|
|
539
|
-
return Math.round(n * t) / t;
|
|
540
|
-
}
|
|
541
|
-
function Dt(e) {
|
|
542
|
-
const n = p.useRef(e);
|
|
543
|
-
return dt(() => {
|
|
544
|
-
n.current = e;
|
|
545
|
-
}), n;
|
|
546
|
-
}
|
|
547
|
-
function zo(e) {
|
|
548
|
-
e === void 0 && (e = {});
|
|
549
|
-
const {
|
|
550
|
-
placement: n = "bottom",
|
|
551
|
-
strategy: t = "absolute",
|
|
552
|
-
middleware: r = [],
|
|
553
|
-
platform: o,
|
|
554
|
-
elements: {
|
|
555
|
-
reference: s,
|
|
556
|
-
floating: i
|
|
557
|
-
} = {},
|
|
558
|
-
transform: a = !0,
|
|
559
|
-
whileElementsMounted: l,
|
|
560
|
-
open: c
|
|
561
|
-
} = e, [f, d] = p.useState({
|
|
562
|
-
x: 0,
|
|
563
|
-
y: 0,
|
|
564
|
-
strategy: t,
|
|
565
|
-
placement: n,
|
|
566
|
-
middlewareData: {},
|
|
567
|
-
isPositioned: !1
|
|
568
|
-
}), [h, u] = p.useState(r);
|
|
569
|
-
gt(h, r) || u(r);
|
|
570
|
-
const [m, g] = p.useState(null), [w, x] = p.useState(null), y = p.useCallback((k) => {
|
|
571
|
-
k !== M.current && (M.current = k, g(k));
|
|
572
|
-
}, []), b = p.useCallback((k) => {
|
|
573
|
-
k !== $.current && ($.current = k, x(k));
|
|
574
|
-
}, []), C = s || m, A = i || w, M = p.useRef(null), $ = p.useRef(null), K = p.useRef(f), Z = l != null, G = Dt(l), q = Dt(o), O = Dt(c), N = p.useCallback(() => {
|
|
575
|
-
if (!M.current || !$.current)
|
|
576
|
-
return;
|
|
577
|
-
const k = {
|
|
578
|
-
placement: n,
|
|
579
|
-
strategy: t,
|
|
580
|
-
middleware: h
|
|
581
|
-
};
|
|
582
|
-
q.current && (k.platform = q.current), Wn(M.current, $.current, k).then((R) => {
|
|
583
|
-
const U = {
|
|
584
|
-
...R,
|
|
585
|
-
// The floating element's position may be recomputed while it's closed
|
|
586
|
-
// but still mounted (such as when transitioning out). To ensure
|
|
587
|
-
// `isPositioned` will be `false` initially on the next open, avoid
|
|
588
|
-
// setting it to `true` when `open === false` (must be specified).
|
|
589
|
-
isPositioned: O.current !== !1
|
|
590
|
-
};
|
|
591
|
-
P.current && !gt(K.current, U) && (K.current = U, Bn.flushSync(() => {
|
|
592
|
-
d(U);
|
|
593
|
-
}));
|
|
594
|
-
});
|
|
595
|
-
}, [h, n, t, q, O]);
|
|
596
|
-
dt(() => {
|
|
597
|
-
c === !1 && K.current.isPositioned && (K.current.isPositioned = !1, d((k) => ({
|
|
598
|
-
...k,
|
|
599
|
-
isPositioned: !1
|
|
600
|
-
})));
|
|
601
|
-
}, [c]);
|
|
602
|
-
const P = p.useRef(!1);
|
|
603
|
-
dt(() => (P.current = !0, () => {
|
|
604
|
-
P.current = !1;
|
|
605
|
-
}), []), dt(() => {
|
|
606
|
-
if (C && (M.current = C), A && ($.current = A), C && A) {
|
|
607
|
-
if (G.current)
|
|
608
|
-
return G.current(C, A, N);
|
|
609
|
-
N();
|
|
610
|
-
}
|
|
611
|
-
}, [C, A, N, G, Z]);
|
|
612
|
-
const E = p.useMemo(() => ({
|
|
613
|
-
reference: M,
|
|
614
|
-
floating: $,
|
|
615
|
-
setReference: y,
|
|
616
|
-
setFloating: b
|
|
617
|
-
}), [y, b]), D = p.useMemo(() => ({
|
|
618
|
-
reference: C,
|
|
619
|
-
floating: A
|
|
620
|
-
}), [C, A]), B = p.useMemo(() => {
|
|
621
|
-
const k = {
|
|
622
|
-
position: t,
|
|
623
|
-
left: 0,
|
|
624
|
-
top: 0
|
|
625
|
-
};
|
|
626
|
-
if (!D.floating)
|
|
627
|
-
return k;
|
|
628
|
-
const R = bn(D.floating, f.x), U = bn(D.floating, f.y);
|
|
629
|
-
return a ? {
|
|
630
|
-
...k,
|
|
631
|
-
transform: "translate(" + R + "px, " + U + "px)",
|
|
632
|
-
...or(D.floating) >= 1.5 && {
|
|
633
|
-
willChange: "transform"
|
|
634
|
-
}
|
|
635
|
-
} : {
|
|
636
|
-
position: t,
|
|
637
|
-
left: R,
|
|
638
|
-
top: U
|
|
639
|
-
};
|
|
640
|
-
}, [t, a, D.floating, f.x, f.y]);
|
|
641
|
-
return p.useMemo(() => ({
|
|
642
|
-
...f,
|
|
643
|
-
update: N,
|
|
644
|
-
refs: E,
|
|
645
|
-
elements: D,
|
|
646
|
-
floatingStyles: B
|
|
647
|
-
}), [f, N, E, D, B]);
|
|
648
|
-
}
|
|
649
|
-
const Vo = (e, n) => ({
|
|
650
|
-
...jn(e),
|
|
651
|
-
options: [e, n]
|
|
652
|
-
}), Bo = (e, n) => ({
|
|
653
|
-
...Kn(e),
|
|
654
|
-
options: [e, n]
|
|
655
|
-
}), $o = (e, n) => ({
|
|
656
|
-
...Yr(e),
|
|
657
|
-
options: [e, n]
|
|
658
|
-
});
|
|
659
|
-
function Gt(e) {
|
|
660
|
-
return p.useMemo(() => e.every((n) => n == null) ? null : (n) => {
|
|
661
|
-
e.forEach((t) => {
|
|
662
|
-
typeof t == "function" ? t(n) : t != null && (t.current = n);
|
|
663
|
-
});
|
|
664
|
-
}, e);
|
|
665
|
-
}
|
|
666
|
-
const sr = {
|
|
667
|
-
...p
|
|
668
|
-
}, Ko = sr.useInsertionEffect, jo = Ko || ((e) => e());
|
|
669
|
-
function xe(e) {
|
|
670
|
-
const n = p.useRef(() => {
|
|
671
|
-
if (process.env.NODE_ENV !== "production")
|
|
672
|
-
throw new Error("Cannot call an event handler while rendering.");
|
|
673
|
-
});
|
|
674
|
-
return jo(() => {
|
|
675
|
-
n.current = e;
|
|
676
|
-
}), p.useCallback(function() {
|
|
677
|
-
for (var t = arguments.length, r = new Array(t), o = 0; o < t; o++)
|
|
678
|
-
r[o] = arguments[o];
|
|
679
|
-
return n.current == null ? void 0 : n.current(...r);
|
|
680
|
-
}, []);
|
|
681
|
-
}
|
|
682
|
-
const Yt = "ArrowUp", st = "ArrowDown", He = "ArrowLeft", Ye = "ArrowRight";
|
|
683
|
-
function lt(e, n, t) {
|
|
684
|
-
return Math.floor(e / n) !== t;
|
|
685
|
-
}
|
|
686
|
-
function Qe(e, n) {
|
|
687
|
-
return n < 0 || n >= e.current.length;
|
|
688
|
-
}
|
|
689
|
-
function At(e, n) {
|
|
690
|
-
return le(e, {
|
|
691
|
-
disabledIndices: n
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
function gn(e, n) {
|
|
695
|
-
return le(e, {
|
|
696
|
-
decrement: !0,
|
|
697
|
-
startingIndex: e.current.length,
|
|
698
|
-
disabledIndices: n
|
|
699
|
-
});
|
|
700
|
-
}
|
|
701
|
-
function le(e, n) {
|
|
702
|
-
let {
|
|
703
|
-
startingIndex: t = -1,
|
|
704
|
-
decrement: r = !1,
|
|
705
|
-
disabledIndices: o,
|
|
706
|
-
amount: s = 1
|
|
707
|
-
} = n === void 0 ? {} : n;
|
|
708
|
-
const i = e.current;
|
|
709
|
-
let a = t;
|
|
710
|
-
do
|
|
711
|
-
a += r ? -s : s;
|
|
712
|
-
while (a >= 0 && a <= i.length - 1 && ft(i, a, o));
|
|
713
|
-
return a;
|
|
714
|
-
}
|
|
715
|
-
function Wo(e, n) {
|
|
716
|
-
let {
|
|
717
|
-
event: t,
|
|
718
|
-
orientation: r,
|
|
719
|
-
loop: o,
|
|
720
|
-
cols: s,
|
|
721
|
-
disabledIndices: i,
|
|
722
|
-
minIndex: a,
|
|
723
|
-
maxIndex: l,
|
|
724
|
-
prevIndex: c,
|
|
725
|
-
stopEvent: f = !1
|
|
726
|
-
} = n, d = c;
|
|
727
|
-
if (t.key === Yt) {
|
|
728
|
-
if (f && ue(t), c === -1)
|
|
729
|
-
d = l;
|
|
730
|
-
else if (d = le(e, {
|
|
731
|
-
startingIndex: d,
|
|
732
|
-
amount: s,
|
|
733
|
-
decrement: !0,
|
|
734
|
-
disabledIndices: i
|
|
735
|
-
}), o && (c - s < a || d < 0)) {
|
|
736
|
-
const h = c % s, u = l % s, m = l - (u - h);
|
|
737
|
-
u === h ? d = l : d = u > h ? m : m - s;
|
|
738
|
-
}
|
|
739
|
-
Qe(e, d) && (d = c);
|
|
740
|
-
}
|
|
741
|
-
if (t.key === st && (f && ue(t), c === -1 ? d = a : (d = le(e, {
|
|
742
|
-
startingIndex: c,
|
|
743
|
-
amount: s,
|
|
744
|
-
disabledIndices: i
|
|
745
|
-
}), o && c + s > l && (d = le(e, {
|
|
746
|
-
startingIndex: c % s - s,
|
|
747
|
-
amount: s,
|
|
748
|
-
disabledIndices: i
|
|
749
|
-
}))), Qe(e, d) && (d = c)), r === "both") {
|
|
750
|
-
const h = mn(c / s);
|
|
751
|
-
t.key === Ye && (f && ue(t), c % s !== s - 1 ? (d = le(e, {
|
|
752
|
-
startingIndex: c,
|
|
753
|
-
disabledIndices: i
|
|
754
|
-
}), o && lt(d, s, h) && (d = le(e, {
|
|
755
|
-
startingIndex: c - c % s - 1,
|
|
756
|
-
disabledIndices: i
|
|
757
|
-
}))) : o && (d = le(e, {
|
|
758
|
-
startingIndex: c - c % s - 1,
|
|
759
|
-
disabledIndices: i
|
|
760
|
-
})), lt(d, s, h) && (d = c)), t.key === He && (f && ue(t), c % s !== 0 ? (d = le(e, {
|
|
761
|
-
startingIndex: c,
|
|
762
|
-
decrement: !0,
|
|
763
|
-
disabledIndices: i
|
|
764
|
-
}), o && lt(d, s, h) && (d = le(e, {
|
|
765
|
-
startingIndex: c + (s - c % s),
|
|
766
|
-
decrement: !0,
|
|
767
|
-
disabledIndices: i
|
|
768
|
-
}))) : o && (d = le(e, {
|
|
769
|
-
startingIndex: c + (s - c % s),
|
|
770
|
-
decrement: !0,
|
|
771
|
-
disabledIndices: i
|
|
772
|
-
})), lt(d, s, h) && (d = c));
|
|
773
|
-
const u = mn(l / s) === h;
|
|
774
|
-
Qe(e, d) && (o && u ? d = t.key === He ? l : le(e, {
|
|
775
|
-
startingIndex: c - c % s - 1,
|
|
776
|
-
disabledIndices: i
|
|
777
|
-
}) : d = c);
|
|
778
|
-
}
|
|
779
|
-
return d;
|
|
780
|
-
}
|
|
781
|
-
function qo(e, n, t) {
|
|
782
|
-
const r = [];
|
|
783
|
-
let o = 0;
|
|
784
|
-
return e.forEach((s, i) => {
|
|
785
|
-
let {
|
|
786
|
-
width: a,
|
|
787
|
-
height: l
|
|
788
|
-
} = s;
|
|
789
|
-
if (a > n && process.env.NODE_ENV !== "production")
|
|
790
|
-
throw new Error("[Floating UI]: Invalid grid - item width at index " + i + " is greater than grid columns");
|
|
791
|
-
let c = !1;
|
|
792
|
-
for (t && (o = 0); !c; ) {
|
|
793
|
-
const f = [];
|
|
794
|
-
for (let d = 0; d < a; d++)
|
|
795
|
-
for (let h = 0; h < l; h++)
|
|
796
|
-
f.push(o + d + h * n);
|
|
797
|
-
o % n + a <= n && f.every((d) => r[d] == null) ? (f.forEach((d) => {
|
|
798
|
-
r[d] = i;
|
|
799
|
-
}), c = !0) : o++;
|
|
800
|
-
}
|
|
801
|
-
}), [...r];
|
|
802
|
-
}
|
|
803
|
-
function Ho(e, n, t, r, o) {
|
|
804
|
-
if (e === -1) return -1;
|
|
805
|
-
const s = t.indexOf(e), i = n[e];
|
|
806
|
-
switch (o) {
|
|
807
|
-
case "tl":
|
|
808
|
-
return s;
|
|
809
|
-
case "tr":
|
|
810
|
-
return i ? s + i.width - 1 : s;
|
|
811
|
-
case "bl":
|
|
812
|
-
return i ? s + (i.height - 1) * r : s;
|
|
813
|
-
case "br":
|
|
814
|
-
return t.lastIndexOf(e);
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
function Uo(e, n) {
|
|
818
|
-
return n.flatMap((t, r) => e.includes(t) ? [r] : []);
|
|
819
|
-
}
|
|
820
|
-
function ft(e, n, t) {
|
|
821
|
-
if (t)
|
|
822
|
-
return t.includes(n);
|
|
823
|
-
const r = e[n];
|
|
824
|
-
return r == null || r.hasAttribute("disabled") || r.getAttribute("aria-disabled") === "true";
|
|
825
|
-
}
|
|
826
|
-
let vn = 0;
|
|
827
|
-
function Me(e, n) {
|
|
828
|
-
n === void 0 && (n = {});
|
|
829
|
-
const {
|
|
830
|
-
preventScroll: t = !1,
|
|
831
|
-
cancelPrevious: r = !0,
|
|
832
|
-
sync: o = !1
|
|
833
|
-
} = n;
|
|
834
|
-
r && cancelAnimationFrame(vn);
|
|
835
|
-
const s = () => e?.focus({
|
|
836
|
-
preventScroll: t
|
|
837
|
-
});
|
|
838
|
-
o ? s() : vn = requestAnimationFrame(s);
|
|
839
|
-
}
|
|
840
|
-
var Q = typeof document < "u" ? zn : de;
|
|
841
|
-
function vt() {
|
|
842
|
-
return vt = Object.assign ? Object.assign.bind() : function(e) {
|
|
843
|
-
for (var n = 1; n < arguments.length; n++) {
|
|
844
|
-
var t = arguments[n];
|
|
845
|
-
for (var r in t)
|
|
846
|
-
Object.prototype.hasOwnProperty.call(t, r) && (e[r] = t[r]);
|
|
847
|
-
}
|
|
848
|
-
return e;
|
|
849
|
-
}, vt.apply(this, arguments);
|
|
850
|
-
}
|
|
851
|
-
let yn = !1, Xo = 0;
|
|
852
|
-
const xn = () => (
|
|
853
|
-
// Ensure the id is unique with multiple independent versions of Floating UI
|
|
854
|
-
// on <React 18
|
|
855
|
-
"floating-ui-" + Math.random().toString(36).slice(2, 6) + Xo++
|
|
856
|
-
);
|
|
857
|
-
function Go() {
|
|
858
|
-
const [e, n] = p.useState(() => yn ? xn() : void 0);
|
|
859
|
-
return Q(() => {
|
|
860
|
-
e == null && n(xn());
|
|
861
|
-
}, []), p.useEffect(() => {
|
|
862
|
-
yn = !0;
|
|
863
|
-
}, []), e;
|
|
864
|
-
}
|
|
865
|
-
const Yo = sr.useId, Zt = Yo || Go;
|
|
866
|
-
let nt;
|
|
867
|
-
process.env.NODE_ENV !== "production" && (nt = /* @__PURE__ */ new Set());
|
|
868
|
-
function Ft() {
|
|
869
|
-
for (var e, n = arguments.length, t = new Array(n), r = 0; r < n; r++)
|
|
870
|
-
t[r] = arguments[r];
|
|
871
|
-
const o = "Floating UI: " + t.join(" ");
|
|
872
|
-
if (!((e = nt) != null && e.has(o))) {
|
|
873
|
-
var s;
|
|
874
|
-
(s = nt) == null || s.add(o), console.warn(o);
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
function Zo() {
|
|
878
|
-
for (var e, n = arguments.length, t = new Array(n), r = 0; r < n; r++)
|
|
879
|
-
t[r] = arguments[r];
|
|
880
|
-
const o = "Floating UI: " + t.join(" ");
|
|
881
|
-
if (!((e = nt) != null && e.has(o))) {
|
|
882
|
-
var s;
|
|
883
|
-
(s = nt) == null || s.add(o), console.error(o);
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
function Jo() {
|
|
887
|
-
const e = /* @__PURE__ */ new Map();
|
|
888
|
-
return {
|
|
889
|
-
emit(n, t) {
|
|
890
|
-
var r;
|
|
891
|
-
(r = e.get(n)) == null || r.forEach((o) => o(t));
|
|
892
|
-
},
|
|
893
|
-
on(n, t) {
|
|
894
|
-
e.set(n, [...e.get(n) || [], t]);
|
|
895
|
-
},
|
|
896
|
-
off(n, t) {
|
|
897
|
-
var r;
|
|
898
|
-
e.set(n, ((r = e.get(n)) == null ? void 0 : r.filter((o) => o !== t)) || []);
|
|
899
|
-
}
|
|
900
|
-
};
|
|
901
|
-
}
|
|
902
|
-
const Qo = /* @__PURE__ */ p.createContext(null), es = /* @__PURE__ */ p.createContext(null), Jt = () => {
|
|
903
|
-
var e;
|
|
904
|
-
return ((e = p.useContext(Qo)) == null ? void 0 : e.id) || null;
|
|
905
|
-
}, wt = () => p.useContext(es);
|
|
906
|
-
function Ue(e) {
|
|
907
|
-
return "data-floating-ui-" + e;
|
|
908
|
-
}
|
|
909
|
-
function Ne(e) {
|
|
910
|
-
const n = ge(e);
|
|
911
|
-
return Q(() => {
|
|
912
|
-
n.current = e;
|
|
913
|
-
}), n;
|
|
914
|
-
}
|
|
915
|
-
function ts(e, n) {
|
|
916
|
-
var t;
|
|
917
|
-
let r = [], o = (t = e.find((s) => s.id === n)) == null ? void 0 : t.parentId;
|
|
918
|
-
for (; o; ) {
|
|
919
|
-
const s = e.find((i) => i.id === o);
|
|
920
|
-
o = s?.parentId, s && (r = r.concat(s));
|
|
921
|
-
}
|
|
922
|
-
return r;
|
|
923
|
-
}
|
|
924
|
-
function je(e, n) {
|
|
925
|
-
let t = e.filter((o) => {
|
|
926
|
-
var s;
|
|
927
|
-
return o.parentId === n && ((s = o.context) == null ? void 0 : s.open);
|
|
928
|
-
}), r = t;
|
|
929
|
-
for (; r.length; )
|
|
930
|
-
r = e.filter((o) => {
|
|
931
|
-
var s;
|
|
932
|
-
return (s = r) == null ? void 0 : s.some((i) => {
|
|
933
|
-
var a;
|
|
934
|
-
return o.parentId === i.id && ((a = o.context) == null ? void 0 : a.open);
|
|
935
|
-
});
|
|
936
|
-
}), t = t.concat(r);
|
|
937
|
-
return t;
|
|
938
|
-
}
|
|
939
|
-
function ns(e, n) {
|
|
940
|
-
let t, r = -1;
|
|
941
|
-
function o(s, i) {
|
|
942
|
-
i > r && (t = s, r = i), je(e, s).forEach((l) => {
|
|
943
|
-
o(l.id, i + 1);
|
|
944
|
-
});
|
|
945
|
-
}
|
|
946
|
-
return o(n, 0), e.find((s) => s.id === t);
|
|
947
|
-
}
|
|
948
|
-
let $e = /* @__PURE__ */ new WeakMap(), ct = /* @__PURE__ */ new WeakSet(), ut = {}, _t = 0;
|
|
949
|
-
const rs = () => typeof HTMLElement < "u" && "inert" in HTMLElement.prototype, ir = (e) => e && (e.host || ir(e.parentNode)), os = (e, n) => n.map((t) => {
|
|
950
|
-
if (e.contains(t))
|
|
951
|
-
return t;
|
|
952
|
-
const r = ir(t);
|
|
953
|
-
return e.contains(r) ? r : null;
|
|
954
|
-
}).filter((t) => t != null);
|
|
955
|
-
function ss(e, n, t, r) {
|
|
956
|
-
const o = "data-floating-ui-inert", s = r ? "inert" : t ? "aria-hidden" : null, i = os(n, e), a = /* @__PURE__ */ new Set(), l = new Set(i), c = [];
|
|
957
|
-
ut[o] || (ut[o] = /* @__PURE__ */ new WeakMap());
|
|
958
|
-
const f = ut[o];
|
|
959
|
-
i.forEach(d), h(n), a.clear();
|
|
960
|
-
function d(u) {
|
|
961
|
-
!u || a.has(u) || (a.add(u), u.parentNode && d(u.parentNode));
|
|
962
|
-
}
|
|
963
|
-
function h(u) {
|
|
964
|
-
!u || l.has(u) || [].forEach.call(u.children, (m) => {
|
|
965
|
-
if (Ct(m) !== "script")
|
|
966
|
-
if (a.has(m))
|
|
967
|
-
h(m);
|
|
968
|
-
else {
|
|
969
|
-
const g = s ? m.getAttribute(s) : null, w = g !== null && g !== "false", x = ($e.get(m) || 0) + 1, y = (f.get(m) || 0) + 1;
|
|
970
|
-
$e.set(m, x), f.set(m, y), c.push(m), x === 1 && w && ct.add(m), y === 1 && m.setAttribute(o, ""), !w && s && m.setAttribute(s, "true");
|
|
971
|
-
}
|
|
972
|
-
});
|
|
973
|
-
}
|
|
974
|
-
return _t++, () => {
|
|
975
|
-
c.forEach((u) => {
|
|
976
|
-
const m = ($e.get(u) || 0) - 1, g = (f.get(u) || 0) - 1;
|
|
977
|
-
$e.set(u, m), f.set(u, g), m || (!ct.has(u) && s && u.removeAttribute(s), ct.delete(u)), g || u.removeAttribute(o);
|
|
978
|
-
}), _t--, _t || ($e = /* @__PURE__ */ new WeakMap(), $e = /* @__PURE__ */ new WeakMap(), ct = /* @__PURE__ */ new WeakSet(), ut = {});
|
|
979
|
-
};
|
|
980
|
-
}
|
|
981
|
-
function Cn(e, n, t) {
|
|
982
|
-
n === void 0 && (n = !1), t === void 0 && (t = !1);
|
|
983
|
-
const r = pe(e[0]).body;
|
|
984
|
-
return ss(e.concat(Array.from(r.querySelectorAll("[aria-live]"))), r, n, t);
|
|
985
|
-
}
|
|
986
|
-
const Xe = () => ({
|
|
987
|
-
getShadowRoot: !0,
|
|
988
|
-
displayCheck: (
|
|
989
|
-
// JSDOM does not support the `tabbable` library. To solve this we can
|
|
990
|
-
// check if `ResizeObserver` is a real function (not polyfilled), which
|
|
991
|
-
// determines if the current environment is JSDOM-like.
|
|
992
|
-
typeof ResizeObserver == "function" && ResizeObserver.toString().includes("[native code]") ? "full" : "none"
|
|
993
|
-
)
|
|
994
|
-
});
|
|
995
|
-
function ar(e, n) {
|
|
996
|
-
const t = tt(e, Xe());
|
|
997
|
-
n === "prev" && t.reverse();
|
|
998
|
-
const r = t.indexOf(Se(pe(e)));
|
|
999
|
-
return t.slice(r + 1)[0];
|
|
1000
|
-
}
|
|
1001
|
-
function lr() {
|
|
1002
|
-
return ar(document.body, "next");
|
|
1003
|
-
}
|
|
1004
|
-
function cr() {
|
|
1005
|
-
return ar(document.body, "prev");
|
|
1006
|
-
}
|
|
1007
|
-
function et(e, n) {
|
|
1008
|
-
const t = n || e.currentTarget, r = e.relatedTarget;
|
|
1009
|
-
return !r || !ce(t, r);
|
|
1010
|
-
}
|
|
1011
|
-
function is(e) {
|
|
1012
|
-
tt(e, Xe()).forEach((t) => {
|
|
1013
|
-
t.dataset.tabindex = t.getAttribute("tabindex") || "", t.setAttribute("tabindex", "-1");
|
|
1014
|
-
});
|
|
1015
|
-
}
|
|
1016
|
-
function wn(e) {
|
|
1017
|
-
e.querySelectorAll("[data-tabindex]").forEach((t) => {
|
|
1018
|
-
const r = t.dataset.tabindex;
|
|
1019
|
-
delete t.dataset.tabindex, r ? t.setAttribute("tabindex", r) : t.removeAttribute("tabindex");
|
|
1020
|
-
});
|
|
1021
|
-
}
|
|
1022
|
-
function as(e, n, t) {
|
|
1023
|
-
const r = e.indexOf(n);
|
|
1024
|
-
function o(i) {
|
|
1025
|
-
const a = Ue("focus-guard");
|
|
1026
|
-
let l = r + (i ? 1 : 0), c = e[l];
|
|
1027
|
-
for (; c && (!c.isConnected || c.hasAttribute(a) || ce(t, c)); )
|
|
1028
|
-
i ? l++ : l--, c = e[l];
|
|
1029
|
-
return c;
|
|
1030
|
-
}
|
|
1031
|
-
const s = o(!0);
|
|
1032
|
-
return s || o(!1);
|
|
1033
|
-
}
|
|
1034
|
-
const Qt = {
|
|
1035
|
-
border: 0,
|
|
1036
|
-
clip: "rect(0 0 0 0)",
|
|
1037
|
-
height: "1px",
|
|
1038
|
-
margin: "-1px",
|
|
1039
|
-
overflow: "hidden",
|
|
1040
|
-
padding: 0,
|
|
1041
|
-
position: "fixed",
|
|
1042
|
-
whiteSpace: "nowrap",
|
|
1043
|
-
width: "1px",
|
|
1044
|
-
top: 0,
|
|
1045
|
-
left: 0
|
|
1046
|
-
};
|
|
1047
|
-
let ls;
|
|
1048
|
-
function En(e) {
|
|
1049
|
-
e.key === "Tab" && (e.target, clearTimeout(ls));
|
|
1050
|
-
}
|
|
1051
|
-
const yt = /* @__PURE__ */ p.forwardRef(function(n, t) {
|
|
1052
|
-
const [r, o] = p.useState();
|
|
1053
|
-
Q(() => (Jn() && o("button"), document.addEventListener("keydown", En), () => {
|
|
1054
|
-
document.removeEventListener("keydown", En);
|
|
1055
|
-
}), []);
|
|
1056
|
-
const s = {
|
|
1057
|
-
ref: t,
|
|
1058
|
-
tabIndex: 0,
|
|
1059
|
-
// Role is only for VoiceOver
|
|
1060
|
-
role: r,
|
|
1061
|
-
"aria-hidden": r ? void 0 : !0,
|
|
1062
|
-
[Ue("focus-guard")]: "",
|
|
1063
|
-
style: Qt
|
|
1064
|
-
};
|
|
1065
|
-
return /* @__PURE__ */ p.createElement("span", vt({}, n, s));
|
|
1066
|
-
}), ur = /* @__PURE__ */ p.createContext(null), In = /* @__PURE__ */ Ue("portal");
|
|
1067
|
-
function cs(e) {
|
|
1068
|
-
e === void 0 && (e = {});
|
|
1069
|
-
const {
|
|
1070
|
-
id: n,
|
|
1071
|
-
root: t
|
|
1072
|
-
} = e, r = Zt(), o = dr(), [s, i] = p.useState(null), a = p.useRef(null);
|
|
1073
|
-
return Q(() => () => {
|
|
1074
|
-
s?.remove(), queueMicrotask(() => {
|
|
1075
|
-
a.current = null;
|
|
1076
|
-
});
|
|
1077
|
-
}, [s]), Q(() => {
|
|
1078
|
-
if (!r || a.current) return;
|
|
1079
|
-
const l = n ? document.getElementById(n) : null;
|
|
1080
|
-
if (!l) return;
|
|
1081
|
-
const c = document.createElement("div");
|
|
1082
|
-
c.id = r, c.setAttribute(In, ""), l.appendChild(c), a.current = c, i(c);
|
|
1083
|
-
}, [n, r]), Q(() => {
|
|
1084
|
-
if (!r || a.current) return;
|
|
1085
|
-
let l = t || o?.portalNode;
|
|
1086
|
-
l && !be(l) && (l = l.current), l = l || document.body;
|
|
1087
|
-
let c = null;
|
|
1088
|
-
n && (c = document.createElement("div"), c.id = n, l.appendChild(c));
|
|
1089
|
-
const f = document.createElement("div");
|
|
1090
|
-
f.id = r, f.setAttribute(In, ""), l = c || l, l.appendChild(f), a.current = f, i(f);
|
|
1091
|
-
}, [n, t, r, o]), s;
|
|
1092
|
-
}
|
|
1093
|
-
function us(e) {
|
|
1094
|
-
const {
|
|
1095
|
-
children: n,
|
|
1096
|
-
id: t,
|
|
1097
|
-
root: r = null,
|
|
1098
|
-
preserveTabOrder: o = !0
|
|
1099
|
-
} = e, s = cs({
|
|
1100
|
-
id: t,
|
|
1101
|
-
root: r
|
|
1102
|
-
}), [i, a] = p.useState(null), l = p.useRef(null), c = p.useRef(null), f = p.useRef(null), d = p.useRef(null), h = i?.modal, u = i?.open, m = (
|
|
1103
|
-
// The FocusManager and therefore floating element are currently open/
|
|
1104
|
-
// rendered.
|
|
1105
|
-
!!i && // Guards are only for non-modal focus management.
|
|
1106
|
-
!i.modal && // Don't render if unmount is transitioning.
|
|
1107
|
-
i.open && o && !!(r || s)
|
|
1108
|
-
);
|
|
1109
|
-
return p.useEffect(() => {
|
|
1110
|
-
if (!s || !o || h)
|
|
1111
|
-
return;
|
|
1112
|
-
function g(w) {
|
|
1113
|
-
s && et(w) && (w.type === "focusin" ? wn : is)(s);
|
|
1114
|
-
}
|
|
1115
|
-
return s.addEventListener("focusin", g, !0), s.addEventListener("focusout", g, !0), () => {
|
|
1116
|
-
s.removeEventListener("focusin", g, !0), s.removeEventListener("focusout", g, !0);
|
|
1117
|
-
};
|
|
1118
|
-
}, [s, o, h]), p.useEffect(() => {
|
|
1119
|
-
s && (u || wn(s));
|
|
1120
|
-
}, [u, s]), /* @__PURE__ */ p.createElement(ur.Provider, {
|
|
1121
|
-
value: p.useMemo(() => ({
|
|
1122
|
-
preserveTabOrder: o,
|
|
1123
|
-
beforeOutsideRef: l,
|
|
1124
|
-
afterOutsideRef: c,
|
|
1125
|
-
beforeInsideRef: f,
|
|
1126
|
-
afterInsideRef: d,
|
|
1127
|
-
portalNode: s,
|
|
1128
|
-
setFocusManagerState: a
|
|
1129
|
-
}), [o, s])
|
|
1130
|
-
}, m && s && /* @__PURE__ */ p.createElement(yt, {
|
|
1131
|
-
"data-type": "outside",
|
|
1132
|
-
ref: l,
|
|
1133
|
-
onFocus: (g) => {
|
|
1134
|
-
if (et(g, s)) {
|
|
1135
|
-
var w;
|
|
1136
|
-
(w = f.current) == null || w.focus();
|
|
1137
|
-
} else {
|
|
1138
|
-
const x = cr() || i?.refs.domReference.current;
|
|
1139
|
-
x?.focus();
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
}), m && s && /* @__PURE__ */ p.createElement("span", {
|
|
1143
|
-
"aria-owns": s.id,
|
|
1144
|
-
style: Qt
|
|
1145
|
-
}), s && /* @__PURE__ */ Bn.createPortal(n, s), m && s && /* @__PURE__ */ p.createElement(yt, {
|
|
1146
|
-
"data-type": "outside",
|
|
1147
|
-
ref: c,
|
|
1148
|
-
onFocus: (g) => {
|
|
1149
|
-
if (et(g, s)) {
|
|
1150
|
-
var w;
|
|
1151
|
-
(w = d.current) == null || w.focus();
|
|
1152
|
-
} else {
|
|
1153
|
-
const x = lr() || i?.refs.domReference.current;
|
|
1154
|
-
x?.focus(), i?.closeOnFocusOut && i?.onOpenChange(!1, g.nativeEvent, "focus-out");
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
}));
|
|
1158
|
-
}
|
|
1159
|
-
const dr = () => p.useContext(ur), Wt = "data-floating-ui-focusable";
|
|
1160
|
-
function fr(e) {
|
|
1161
|
-
return e ? e.hasAttribute(Wt) ? e : e.querySelector("[" + Wt + "]") || e : null;
|
|
1162
|
-
}
|
|
1163
|
-
const Rn = 20;
|
|
1164
|
-
let Fe = [];
|
|
1165
|
-
function Lt(e) {
|
|
1166
|
-
Fe = Fe.filter((t) => t.isConnected);
|
|
1167
|
-
let n = e;
|
|
1168
|
-
if (!(!n || Ct(n) === "body")) {
|
|
1169
|
-
if (!Lo(n, Xe())) {
|
|
1170
|
-
const t = tt(n, Xe())[0];
|
|
1171
|
-
t && (n = t);
|
|
1172
|
-
}
|
|
1173
|
-
Fe.push(n), Fe.length > Rn && (Fe = Fe.slice(-Rn));
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
function Sn() {
|
|
1177
|
-
return Fe.slice().reverse().find((e) => e.isConnected);
|
|
1178
|
-
}
|
|
1179
|
-
const ds = /* @__PURE__ */ p.forwardRef(function(n, t) {
|
|
1180
|
-
return /* @__PURE__ */ p.createElement("button", vt({}, n, {
|
|
1181
|
-
type: "button",
|
|
1182
|
-
ref: t,
|
|
1183
|
-
tabIndex: -1,
|
|
1184
|
-
style: Qt
|
|
1185
|
-
}));
|
|
1186
|
-
});
|
|
1187
|
-
function fs(e) {
|
|
1188
|
-
const {
|
|
1189
|
-
context: n,
|
|
1190
|
-
children: t,
|
|
1191
|
-
disabled: r = !1,
|
|
1192
|
-
order: o = ["content"],
|
|
1193
|
-
guards: s = !0,
|
|
1194
|
-
initialFocus: i = 0,
|
|
1195
|
-
returnFocus: a = !0,
|
|
1196
|
-
restoreFocus: l = !1,
|
|
1197
|
-
modal: c = !0,
|
|
1198
|
-
visuallyHiddenDismiss: f = !1,
|
|
1199
|
-
closeOnFocusOut: d = !0
|
|
1200
|
-
} = e, {
|
|
1201
|
-
open: h,
|
|
1202
|
-
refs: u,
|
|
1203
|
-
nodeId: m,
|
|
1204
|
-
onOpenChange: g,
|
|
1205
|
-
events: w,
|
|
1206
|
-
dataRef: x,
|
|
1207
|
-
floatingId: y,
|
|
1208
|
-
elements: {
|
|
1209
|
-
domReference: b,
|
|
1210
|
-
floating: C
|
|
1211
|
-
}
|
|
1212
|
-
} = n, A = typeof i == "number" && i < 0, M = Qn(b) && A, $ = rs() ? s : !0, K = Ne(o), Z = Ne(i), G = Ne(a), q = wt(), O = dr(), N = p.useRef(null), P = p.useRef(null), E = p.useRef(!1), D = p.useRef(!1), B = p.useRef(-1), k = O != null, R = fr(C), U = xe(function(z) {
|
|
1213
|
-
return z === void 0 && (z = R), z ? tt(z, Xe()) : [];
|
|
1214
|
-
}), te = xe((z) => {
|
|
1215
|
-
const T = U(z);
|
|
1216
|
-
return K.current.map((S) => b && S === "reference" ? b : R && S === "floating" ? R : T).filter(Boolean).flat();
|
|
1217
|
-
});
|
|
1218
|
-
p.useEffect(() => {
|
|
1219
|
-
E.current = !1;
|
|
1220
|
-
}, [r]), p.useEffect(() => {
|
|
1221
|
-
if (r || !c) return;
|
|
1222
|
-
function z(S) {
|
|
1223
|
-
if (S.key === "Tab") {
|
|
1224
|
-
ce(R, Se(pe(R))) && U().length === 0 && !M && ue(S);
|
|
1225
|
-
const F = te(), H = _e(S);
|
|
1226
|
-
K.current[0] === "reference" && H === b && (ue(S), S.shiftKey ? Me(F[F.length - 1]) : Me(F[1])), K.current[1] === "floating" && H === R && S.shiftKey && (ue(S), Me(F[0]));
|
|
1227
|
-
}
|
|
1228
|
-
}
|
|
1229
|
-
const T = pe(R);
|
|
1230
|
-
return T.addEventListener("keydown", z), () => {
|
|
1231
|
-
T.removeEventListener("keydown", z);
|
|
1232
|
-
};
|
|
1233
|
-
}, [r, b, R, c, K, M, U, te]), p.useEffect(() => {
|
|
1234
|
-
if (r || !C) return;
|
|
1235
|
-
function z(T) {
|
|
1236
|
-
const S = _e(T), H = U().indexOf(S);
|
|
1237
|
-
H !== -1 && (B.current = H);
|
|
1238
|
-
}
|
|
1239
|
-
return C.addEventListener("focusin", z), () => {
|
|
1240
|
-
C.removeEventListener("focusin", z);
|
|
1241
|
-
};
|
|
1242
|
-
}, [r, C, U]), p.useEffect(() => {
|
|
1243
|
-
if (r || !d) return;
|
|
1244
|
-
function z() {
|
|
1245
|
-
D.current = !0, setTimeout(() => {
|
|
1246
|
-
D.current = !1;
|
|
1247
|
-
});
|
|
1248
|
-
}
|
|
1249
|
-
function T(S) {
|
|
1250
|
-
const F = S.relatedTarget;
|
|
1251
|
-
queueMicrotask(() => {
|
|
1252
|
-
const H = !(ce(b, F) || ce(C, F) || ce(F, C) || ce(O?.portalNode, F) || F != null && F.hasAttribute(Ue("focus-guard")) || q && (je(q.nodesRef.current, m).find((ee) => {
|
|
1253
|
-
var ne, Y;
|
|
1254
|
-
return ce((ne = ee.context) == null ? void 0 : ne.elements.floating, F) || ce((Y = ee.context) == null ? void 0 : Y.elements.domReference, F);
|
|
1255
|
-
}) || ts(q.nodesRef.current, m).find((ee) => {
|
|
1256
|
-
var ne, Y;
|
|
1257
|
-
return ((ne = ee.context) == null ? void 0 : ne.elements.floating) === F || ((Y = ee.context) == null ? void 0 : Y.elements.domReference) === F;
|
|
1258
|
-
})));
|
|
1259
|
-
if (l && H && Se(pe(R)) === pe(R).body) {
|
|
1260
|
-
Re(R) && R.focus();
|
|
1261
|
-
const ee = B.current, ne = U(), Y = ne[ee] || ne[ne.length - 1] || R;
|
|
1262
|
-
Re(Y) && Y.focus();
|
|
1263
|
-
}
|
|
1264
|
-
(M || !c) && F && H && !D.current && // Fix React 18 Strict Mode returnFocus due to double rendering.
|
|
1265
|
-
F !== Sn() && (E.current = !0, g(!1, S, "focus-out"));
|
|
1266
|
-
});
|
|
1267
|
-
}
|
|
1268
|
-
if (C && Re(b))
|
|
1269
|
-
return b.addEventListener("focusout", T), b.addEventListener("pointerdown", z), C.addEventListener("focusout", T), () => {
|
|
1270
|
-
b.removeEventListener("focusout", T), b.removeEventListener("pointerdown", z), C.removeEventListener("focusout", T);
|
|
1271
|
-
};
|
|
1272
|
-
}, [r, b, C, R, c, m, q, O, g, d, l, U, M]), p.useEffect(() => {
|
|
1273
|
-
var z;
|
|
1274
|
-
if (r) return;
|
|
1275
|
-
const T = Array.from((O == null || (z = O.portalNode) == null ? void 0 : z.querySelectorAll("[" + Ue("portal") + "]")) || []);
|
|
1276
|
-
if (C) {
|
|
1277
|
-
const S = [C, ...T, N.current, P.current, K.current.includes("reference") || M ? b : null].filter((H) => H != null), F = c || M ? Cn(S, $, !$) : Cn(S);
|
|
1278
|
-
return () => {
|
|
1279
|
-
F();
|
|
1280
|
-
};
|
|
1281
|
-
}
|
|
1282
|
-
}, [r, b, C, c, K, O, M, $]), Q(() => {
|
|
1283
|
-
if (r || !Re(R)) return;
|
|
1284
|
-
const z = pe(R), T = Se(z);
|
|
1285
|
-
queueMicrotask(() => {
|
|
1286
|
-
const S = te(R), F = Z.current, H = (typeof F == "number" ? S[F] : F.current) || R, ee = ce(R, T);
|
|
1287
|
-
!A && !ee && h && Me(H, {
|
|
1288
|
-
preventScroll: H === R
|
|
1289
|
-
});
|
|
1290
|
-
});
|
|
1291
|
-
}, [r, h, R, A, te, Z]), Q(() => {
|
|
1292
|
-
if (r || !R) return;
|
|
1293
|
-
let z = !1;
|
|
1294
|
-
const T = pe(R), S = Se(T);
|
|
1295
|
-
let H = x.current.openEvent;
|
|
1296
|
-
const ee = u.domReference.current;
|
|
1297
|
-
Lt(S);
|
|
1298
|
-
function ne(Y) {
|
|
1299
|
-
let {
|
|
1300
|
-
open: Ee,
|
|
1301
|
-
reason: we,
|
|
1302
|
-
event: J,
|
|
1303
|
-
nested: Ie
|
|
1304
|
-
} = Y;
|
|
1305
|
-
Ee && (H = J), we === "escape-key" && u.domReference.current && Lt(u.domReference.current), we === "hover" && J.type === "mouseleave" && (E.current = !0), we === "outside-press" && (Ie ? (E.current = !1, z = !0) : E.current = !(Yn(J) || Zn(J)));
|
|
1306
|
-
}
|
|
1307
|
-
return w.on("openchange", ne), () => {
|
|
1308
|
-
w.off("openchange", ne);
|
|
1309
|
-
const Y = Se(T), Ee = ce(C, Y) || q && je(q.nodesRef.current, m).some((he) => {
|
|
1310
|
-
var Ae;
|
|
1311
|
-
return ce((Ae = he.context) == null ? void 0 : Ae.elements.floating, Y);
|
|
1312
|
-
});
|
|
1313
|
-
(Ee || H && ["click", "mousedown"].includes(H.type)) && u.domReference.current && Lt(u.domReference.current);
|
|
1314
|
-
const J = ee || S, Ie = tt(pe(J).body, Xe());
|
|
1315
|
-
queueMicrotask(() => {
|
|
1316
|
-
let he = Sn();
|
|
1317
|
-
!he && Re(J) && C && (he = as(Ie, J, C)), // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1318
|
-
G.current && !E.current && Re(he) && // If the focus moved somewhere else after mount, avoid returning focus
|
|
1319
|
-
// since it likely entered a different element which should be
|
|
1320
|
-
// respected: https://github.com/floating-ui/floating-ui/issues/2607
|
|
1321
|
-
(!(he !== Y && Y !== T.body) || Ee) && he.focus({
|
|
1322
|
-
preventScroll: z
|
|
1323
|
-
});
|
|
1324
|
-
});
|
|
1325
|
-
};
|
|
1326
|
-
}, [r, C, R, G, x, u, w, q, m]), Q(() => {
|
|
1327
|
-
if (!r && O)
|
|
1328
|
-
return O.setFocusManagerState({
|
|
1329
|
-
modal: c,
|
|
1330
|
-
closeOnFocusOut: d,
|
|
1331
|
-
open: h,
|
|
1332
|
-
onOpenChange: g,
|
|
1333
|
-
refs: u
|
|
1334
|
-
}), () => {
|
|
1335
|
-
O.setFocusManagerState(null);
|
|
1336
|
-
};
|
|
1337
|
-
}, [r, O, c, h, g, u, d]), Q(() => {
|
|
1338
|
-
if (r || !R || typeof MutationObserver != "function" || A) return;
|
|
1339
|
-
const z = () => {
|
|
1340
|
-
const S = R.getAttribute("tabindex"), F = U(), H = Se(pe(C)), ee = F.indexOf(H);
|
|
1341
|
-
ee !== -1 && (B.current = ee), K.current.includes("floating") || H !== u.domReference.current && F.length === 0 ? S !== "0" && R.setAttribute("tabindex", "0") : S !== "-1" && R.setAttribute("tabindex", "-1");
|
|
1342
|
-
};
|
|
1343
|
-
z();
|
|
1344
|
-
const T = new MutationObserver(z);
|
|
1345
|
-
return T.observe(R, {
|
|
1346
|
-
childList: !0,
|
|
1347
|
-
subtree: !0,
|
|
1348
|
-
attributes: !0
|
|
1349
|
-
}), () => {
|
|
1350
|
-
T.disconnect();
|
|
1351
|
-
};
|
|
1352
|
-
}, [r, C, R, u, K, U, A]);
|
|
1353
|
-
function ve(z) {
|
|
1354
|
-
return r || !f || !c ? null : /* @__PURE__ */ p.createElement(ds, {
|
|
1355
|
-
ref: z === "start" ? N : P,
|
|
1356
|
-
onClick: (T) => g(!1, T.nativeEvent)
|
|
1357
|
-
}, typeof f == "string" ? f : "Dismiss");
|
|
1358
|
-
}
|
|
1359
|
-
const fe = !r && $ && (c ? !M : !0) && (k || c);
|
|
1360
|
-
return /* @__PURE__ */ p.createElement(p.Fragment, null, fe && /* @__PURE__ */ p.createElement(yt, {
|
|
1361
|
-
"data-type": "inside",
|
|
1362
|
-
ref: O?.beforeInsideRef,
|
|
1363
|
-
onFocus: (z) => {
|
|
1364
|
-
if (c) {
|
|
1365
|
-
const S = te();
|
|
1366
|
-
Me(o[0] === "reference" ? S[0] : S[S.length - 1]);
|
|
1367
|
-
} else if (O != null && O.preserveTabOrder && O.portalNode)
|
|
1368
|
-
if (E.current = !1, et(z, O.portalNode)) {
|
|
1369
|
-
const S = lr() || b;
|
|
1370
|
-
S?.focus();
|
|
1371
|
-
} else {
|
|
1372
|
-
var T;
|
|
1373
|
-
(T = O.beforeOutsideRef.current) == null || T.focus();
|
|
1374
|
-
}
|
|
1375
|
-
}
|
|
1376
|
-
}), !M && ve("start"), t, ve("end"), fe && /* @__PURE__ */ p.createElement(yt, {
|
|
1377
|
-
"data-type": "inside",
|
|
1378
|
-
ref: O?.afterInsideRef,
|
|
1379
|
-
onFocus: (z) => {
|
|
1380
|
-
if (c)
|
|
1381
|
-
Me(te()[0]);
|
|
1382
|
-
else if (O != null && O.preserveTabOrder && O.portalNode)
|
|
1383
|
-
if (d && (E.current = !0), et(z, O.portalNode)) {
|
|
1384
|
-
const S = cr() || b;
|
|
1385
|
-
S?.focus();
|
|
1386
|
-
} else {
|
|
1387
|
-
var T;
|
|
1388
|
-
(T = O.afterOutsideRef.current) == null || T.focus();
|
|
1389
|
-
}
|
|
1390
|
-
}
|
|
1391
|
-
}));
|
|
1392
|
-
}
|
|
1393
|
-
const hs = {
|
|
1394
|
-
pointerdown: "onPointerDown",
|
|
1395
|
-
mousedown: "onMouseDown",
|
|
1396
|
-
click: "onClick"
|
|
1397
|
-
}, ms = {
|
|
1398
|
-
pointerdown: "onPointerDownCapture",
|
|
1399
|
-
mousedown: "onMouseDownCapture",
|
|
1400
|
-
click: "onClickCapture"
|
|
1401
|
-
}, On = (e) => {
|
|
1402
|
-
var n, t;
|
|
1403
|
-
return {
|
|
1404
|
-
escapeKey: typeof e == "boolean" ? e : (n = e?.escapeKey) != null ? n : !1,
|
|
1405
|
-
outsidePress: typeof e == "boolean" ? e : (t = e?.outsidePress) != null ? t : !0
|
|
1406
|
-
};
|
|
1407
|
-
};
|
|
1408
|
-
function ps(e, n) {
|
|
1409
|
-
n === void 0 && (n = {});
|
|
1410
|
-
const {
|
|
1411
|
-
open: t,
|
|
1412
|
-
onOpenChange: r,
|
|
1413
|
-
elements: o,
|
|
1414
|
-
dataRef: s
|
|
1415
|
-
} = e, {
|
|
1416
|
-
enabled: i = !0,
|
|
1417
|
-
escapeKey: a = !0,
|
|
1418
|
-
outsidePress: l = !0,
|
|
1419
|
-
outsidePressEvent: c = "pointerdown",
|
|
1420
|
-
referencePress: f = !1,
|
|
1421
|
-
referencePressEvent: d = "pointerdown",
|
|
1422
|
-
ancestorScroll: h = !1,
|
|
1423
|
-
bubbles: u,
|
|
1424
|
-
capture: m
|
|
1425
|
-
} = n, g = wt(), w = xe(typeof l == "function" ? l : () => !1), x = typeof l == "function" ? w : l, y = p.useRef(!1), b = p.useRef(!1), {
|
|
1426
|
-
escapeKey: C,
|
|
1427
|
-
outsidePress: A
|
|
1428
|
-
} = On(u), {
|
|
1429
|
-
escapeKey: M,
|
|
1430
|
-
outsidePress: $
|
|
1431
|
-
} = On(m), K = xe((P) => {
|
|
1432
|
-
var E;
|
|
1433
|
-
if (!t || !i || !a || P.key !== "Escape")
|
|
1434
|
-
return;
|
|
1435
|
-
const D = (E = s.current.floatingContext) == null ? void 0 : E.nodeId, B = g ? je(g.nodesRef.current, D) : [];
|
|
1436
|
-
if (!C && (P.stopPropagation(), B.length > 0)) {
|
|
1437
|
-
let k = !0;
|
|
1438
|
-
if (B.forEach((R) => {
|
|
1439
|
-
var U;
|
|
1440
|
-
if ((U = R.context) != null && U.open && !R.context.dataRef.current.__escapeKeyBubbles) {
|
|
1441
|
-
k = !1;
|
|
1442
|
-
return;
|
|
1443
|
-
}
|
|
1444
|
-
}), !k)
|
|
1445
|
-
return;
|
|
1446
|
-
}
|
|
1447
|
-
r(!1, po(P) ? P.nativeEvent : P, "escape-key");
|
|
1448
|
-
}), Z = xe((P) => {
|
|
1449
|
-
var E;
|
|
1450
|
-
const D = () => {
|
|
1451
|
-
var B;
|
|
1452
|
-
K(P), (B = _e(P)) == null || B.removeEventListener("keydown", D);
|
|
1453
|
-
};
|
|
1454
|
-
(E = _e(P)) == null || E.addEventListener("keydown", D);
|
|
1455
|
-
}), G = xe((P) => {
|
|
1456
|
-
var E;
|
|
1457
|
-
const D = y.current;
|
|
1458
|
-
y.current = !1;
|
|
1459
|
-
const B = b.current;
|
|
1460
|
-
if (b.current = !1, c === "click" && B || D || typeof x == "function" && !x(P))
|
|
1461
|
-
return;
|
|
1462
|
-
const k = _e(P), R = "[" + Ue("inert") + "]", U = pe(o.floating).querySelectorAll(R);
|
|
1463
|
-
let te = be(k) ? k : null;
|
|
1464
|
-
for (; te && !hn(te); ) {
|
|
1465
|
-
const T = fo(te);
|
|
1466
|
-
if (hn(T) || !be(T))
|
|
1467
|
-
break;
|
|
1468
|
-
te = T;
|
|
1469
|
-
}
|
|
1470
|
-
if (U.length && be(k) && !bo(k) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
|
|
1471
|
-
!ce(k, o.floating) && // If the target root element contains none of the markers, then the
|
|
1472
|
-
// element was injected after the floating element rendered.
|
|
1473
|
-
Array.from(U).every((T) => !ce(te, T)))
|
|
1474
|
-
return;
|
|
1475
|
-
if (Re(k) && N) {
|
|
1476
|
-
const T = k.clientWidth > 0 && k.scrollWidth > k.clientWidth, S = k.clientHeight > 0 && k.scrollHeight > k.clientHeight;
|
|
1477
|
-
let F = S && P.offsetX > k.clientWidth;
|
|
1478
|
-
if (S && uo(k).direction === "rtl" && (F = P.offsetX <= k.offsetWidth - k.clientWidth), F || T && P.offsetY > k.clientHeight)
|
|
1479
|
-
return;
|
|
1480
|
-
}
|
|
1481
|
-
const ve = (E = s.current.floatingContext) == null ? void 0 : E.nodeId, fe = g && je(g.nodesRef.current, ve).some((T) => {
|
|
1482
|
-
var S;
|
|
1483
|
-
return Pt(P, (S = T.context) == null ? void 0 : S.elements.floating);
|
|
1484
|
-
});
|
|
1485
|
-
if (Pt(P, o.floating) || Pt(P, o.domReference) || fe)
|
|
1486
|
-
return;
|
|
1487
|
-
const z = g ? je(g.nodesRef.current, ve) : [];
|
|
1488
|
-
if (z.length > 0) {
|
|
1489
|
-
let T = !0;
|
|
1490
|
-
if (z.forEach((S) => {
|
|
1491
|
-
var F;
|
|
1492
|
-
if ((F = S.context) != null && F.open && !S.context.dataRef.current.__outsidePressBubbles) {
|
|
1493
|
-
T = !1;
|
|
1494
|
-
return;
|
|
1495
|
-
}
|
|
1496
|
-
}), !T)
|
|
1497
|
-
return;
|
|
1498
|
-
}
|
|
1499
|
-
r(!1, P, "outside-press");
|
|
1500
|
-
}), q = xe((P) => {
|
|
1501
|
-
var E;
|
|
1502
|
-
const D = () => {
|
|
1503
|
-
var B;
|
|
1504
|
-
G(P), (B = _e(P)) == null || B.removeEventListener(c, D);
|
|
1505
|
-
};
|
|
1506
|
-
(E = _e(P)) == null || E.addEventListener(c, D);
|
|
1507
|
-
});
|
|
1508
|
-
p.useEffect(() => {
|
|
1509
|
-
if (!t || !i)
|
|
1510
|
-
return;
|
|
1511
|
-
s.current.__escapeKeyBubbles = C, s.current.__outsidePressBubbles = A;
|
|
1512
|
-
function P(B) {
|
|
1513
|
-
r(!1, B, "ancestor-scroll");
|
|
1514
|
-
}
|
|
1515
|
-
const E = pe(o.floating);
|
|
1516
|
-
a && E.addEventListener("keydown", M ? Z : K, M), x && E.addEventListener(c, $ ? q : G, $);
|
|
1517
|
-
let D = [];
|
|
1518
|
-
return h && (be(o.domReference) && (D = kt(o.domReference)), be(o.floating) && (D = D.concat(kt(o.floating))), !be(o.reference) && o.reference && o.reference.contextElement && (D = D.concat(kt(o.reference.contextElement)))), D = D.filter((B) => {
|
|
1519
|
-
var k;
|
|
1520
|
-
return B !== ((k = E.defaultView) == null ? void 0 : k.visualViewport);
|
|
1521
|
-
}), D.forEach((B) => {
|
|
1522
|
-
B.addEventListener("scroll", P, {
|
|
1523
|
-
passive: !0
|
|
1524
|
-
});
|
|
1525
|
-
}), () => {
|
|
1526
|
-
a && E.removeEventListener("keydown", M ? Z : K, M), x && E.removeEventListener(c, $ ? q : G, $), D.forEach((B) => {
|
|
1527
|
-
B.removeEventListener("scroll", P);
|
|
1528
|
-
});
|
|
1529
|
-
};
|
|
1530
|
-
}, [s, o, a, x, c, t, r, h, i, C, A, K, M, Z, G, $, q]), p.useEffect(() => {
|
|
1531
|
-
y.current = !1;
|
|
1532
|
-
}, [x, c]);
|
|
1533
|
-
const O = p.useMemo(() => ({
|
|
1534
|
-
onKeyDown: K,
|
|
1535
|
-
[hs[d]]: (P) => {
|
|
1536
|
-
f && r(!1, P.nativeEvent, "reference-press");
|
|
1537
|
-
}
|
|
1538
|
-
}), [K, r, f, d]), N = p.useMemo(() => ({
|
|
1539
|
-
onKeyDown: K,
|
|
1540
|
-
onMouseDown() {
|
|
1541
|
-
b.current = !0;
|
|
1542
|
-
},
|
|
1543
|
-
onMouseUp() {
|
|
1544
|
-
b.current = !0;
|
|
1545
|
-
},
|
|
1546
|
-
[ms[c]]: () => {
|
|
1547
|
-
y.current = !0;
|
|
1548
|
-
}
|
|
1549
|
-
}), [K, c]);
|
|
1550
|
-
return p.useMemo(() => i ? {
|
|
1551
|
-
reference: O,
|
|
1552
|
-
floating: N
|
|
1553
|
-
} : {}, [i, O, N]);
|
|
1554
|
-
}
|
|
1555
|
-
function bs(e) {
|
|
1556
|
-
const {
|
|
1557
|
-
open: n = !1,
|
|
1558
|
-
onOpenChange: t,
|
|
1559
|
-
elements: r
|
|
1560
|
-
} = e, o = Zt(), s = p.useRef({}), [i] = p.useState(() => Jo()), a = Jt() != null;
|
|
1561
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1562
|
-
const u = r.reference;
|
|
1563
|
-
u && !be(u) && Zo("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
|
|
1564
|
-
}
|
|
1565
|
-
const [l, c] = p.useState(r.reference), f = xe((u, m, g) => {
|
|
1566
|
-
s.current.openEvent = u ? m : void 0, i.emit("openchange", {
|
|
1567
|
-
open: u,
|
|
1568
|
-
event: m,
|
|
1569
|
-
reason: g,
|
|
1570
|
-
nested: a
|
|
1571
|
-
}), t?.(u, m, g);
|
|
1572
|
-
}), d = p.useMemo(() => ({
|
|
1573
|
-
setPositionReference: c
|
|
1574
|
-
}), []), h = p.useMemo(() => ({
|
|
1575
|
-
reference: l || r.reference || null,
|
|
1576
|
-
floating: r.floating || null,
|
|
1577
|
-
domReference: r.reference
|
|
1578
|
-
}), [l, r.reference, r.floating]);
|
|
1579
|
-
return p.useMemo(() => ({
|
|
1580
|
-
dataRef: s,
|
|
1581
|
-
open: n,
|
|
1582
|
-
onOpenChange: f,
|
|
1583
|
-
elements: h,
|
|
1584
|
-
events: i,
|
|
1585
|
-
floatingId: o,
|
|
1586
|
-
refs: d
|
|
1587
|
-
}), [n, f, h, i, o, d]);
|
|
1588
|
-
}
|
|
1589
|
-
function gs(e) {
|
|
1590
|
-
e === void 0 && (e = {});
|
|
1591
|
-
const {
|
|
1592
|
-
nodeId: n
|
|
1593
|
-
} = e, t = bs({
|
|
1594
|
-
...e,
|
|
1595
|
-
elements: {
|
|
1596
|
-
reference: null,
|
|
1597
|
-
floating: null,
|
|
1598
|
-
...e.elements
|
|
1599
|
-
}
|
|
1600
|
-
}), r = e.rootContext || t, o = r.elements, [s, i] = p.useState(null), [a, l] = p.useState(null), f = o?.reference || s, d = p.useRef(null), h = wt();
|
|
1601
|
-
Q(() => {
|
|
1602
|
-
f && (d.current = f);
|
|
1603
|
-
}, [f]);
|
|
1604
|
-
const u = zo({
|
|
1605
|
-
...e,
|
|
1606
|
-
elements: {
|
|
1607
|
-
...o,
|
|
1608
|
-
...a && {
|
|
1609
|
-
reference: a
|
|
1610
|
-
}
|
|
1611
|
-
}
|
|
1612
|
-
}), m = p.useCallback((b) => {
|
|
1613
|
-
const C = be(b) ? {
|
|
1614
|
-
getBoundingClientRect: () => b.getBoundingClientRect(),
|
|
1615
|
-
contextElement: b
|
|
1616
|
-
} : b;
|
|
1617
|
-
l(C), u.refs.setReference(C);
|
|
1618
|
-
}, [u.refs]), g = p.useCallback((b) => {
|
|
1619
|
-
(be(b) || b === null) && (d.current = b, i(b)), (be(u.refs.reference.current) || u.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
|
|
1620
|
-
// `null` to support `positionReference` + an unstable `reference`
|
|
1621
|
-
// callback ref.
|
|
1622
|
-
b !== null && !be(b)) && u.refs.setReference(b);
|
|
1623
|
-
}, [u.refs]), w = p.useMemo(() => ({
|
|
1624
|
-
...u.refs,
|
|
1625
|
-
setReference: g,
|
|
1626
|
-
setPositionReference: m,
|
|
1627
|
-
domReference: d
|
|
1628
|
-
}), [u.refs, g, m]), x = p.useMemo(() => ({
|
|
1629
|
-
...u.elements,
|
|
1630
|
-
domReference: f
|
|
1631
|
-
}), [u.elements, f]), y = p.useMemo(() => ({
|
|
1632
|
-
...u,
|
|
1633
|
-
...r,
|
|
1634
|
-
refs: w,
|
|
1635
|
-
elements: x,
|
|
1636
|
-
nodeId: n
|
|
1637
|
-
}), [u, w, x, n, r]);
|
|
1638
|
-
return Q(() => {
|
|
1639
|
-
r.dataRef.current.floatingContext = y;
|
|
1640
|
-
const b = h?.nodesRef.current.find((C) => C.id === n);
|
|
1641
|
-
b && (b.context = y);
|
|
1642
|
-
}), p.useMemo(() => ({
|
|
1643
|
-
...u,
|
|
1644
|
-
context: y,
|
|
1645
|
-
refs: w,
|
|
1646
|
-
elements: x
|
|
1647
|
-
}), [u, w, x, y]);
|
|
1648
|
-
}
|
|
1649
|
-
const Tn = "active", kn = "selected";
|
|
1650
|
-
function zt(e, n, t) {
|
|
1651
|
-
const r = /* @__PURE__ */ new Map(), o = t === "item";
|
|
1652
|
-
let s = e;
|
|
1653
|
-
if (o && e) {
|
|
1654
|
-
const {
|
|
1655
|
-
[Tn]: i,
|
|
1656
|
-
[kn]: a,
|
|
1657
|
-
...l
|
|
1658
|
-
} = e;
|
|
1659
|
-
s = l;
|
|
1660
|
-
}
|
|
1661
|
-
return {
|
|
1662
|
-
...t === "floating" && {
|
|
1663
|
-
tabIndex: -1,
|
|
1664
|
-
[Wt]: ""
|
|
1665
|
-
},
|
|
1666
|
-
...s,
|
|
1667
|
-
...n.map((i) => {
|
|
1668
|
-
const a = i ? i[t] : null;
|
|
1669
|
-
return typeof a == "function" ? e ? a(e) : null : a;
|
|
1670
|
-
}).concat(e).reduce((i, a) => (a && Object.entries(a).forEach((l) => {
|
|
1671
|
-
let [c, f] = l;
|
|
1672
|
-
if (!(o && [Tn, kn].includes(c)))
|
|
1673
|
-
if (c.indexOf("on") === 0) {
|
|
1674
|
-
if (r.has(c) || r.set(c, []), typeof f == "function") {
|
|
1675
|
-
var d;
|
|
1676
|
-
(d = r.get(c)) == null || d.push(f), i[c] = function() {
|
|
1677
|
-
for (var h, u = arguments.length, m = new Array(u), g = 0; g < u; g++)
|
|
1678
|
-
m[g] = arguments[g];
|
|
1679
|
-
return (h = r.get(c)) == null ? void 0 : h.map((w) => w(...m)).find((w) => w !== void 0);
|
|
1680
|
-
};
|
|
1681
|
-
}
|
|
1682
|
-
} else
|
|
1683
|
-
i[c] = f;
|
|
1684
|
-
}), i), {})
|
|
1685
|
-
};
|
|
1686
|
-
}
|
|
1687
|
-
function vs(e) {
|
|
1688
|
-
e === void 0 && (e = []);
|
|
1689
|
-
const n = e.map((a) => a?.reference), t = e.map((a) => a?.floating), r = e.map((a) => a?.item), o = p.useCallback(
|
|
1690
|
-
(a) => zt(a, e, "reference"),
|
|
1691
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1692
|
-
n
|
|
1693
|
-
), s = p.useCallback(
|
|
1694
|
-
(a) => zt(a, e, "floating"),
|
|
1695
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1696
|
-
t
|
|
1697
|
-
), i = p.useCallback(
|
|
1698
|
-
(a) => zt(a, e, "item"),
|
|
1699
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1700
|
-
r
|
|
1701
|
-
);
|
|
1702
|
-
return p.useMemo(() => ({
|
|
1703
|
-
getReferenceProps: o,
|
|
1704
|
-
getFloatingProps: s,
|
|
1705
|
-
getItemProps: i
|
|
1706
|
-
}), [o, s, i]);
|
|
1707
|
-
}
|
|
1708
|
-
let Mn = !1;
|
|
1709
|
-
function Et(e, n, t) {
|
|
1710
|
-
switch (e) {
|
|
1711
|
-
case "vertical":
|
|
1712
|
-
return n;
|
|
1713
|
-
case "horizontal":
|
|
1714
|
-
return t;
|
|
1715
|
-
default:
|
|
1716
|
-
return n || t;
|
|
1717
|
-
}
|
|
1718
|
-
}
|
|
1719
|
-
function Nn(e, n) {
|
|
1720
|
-
return Et(n, e === Yt || e === st, e === He || e === Ye);
|
|
1721
|
-
}
|
|
1722
|
-
function Vt(e, n, t) {
|
|
1723
|
-
return Et(n, e === st, t ? e === He : e === Ye) || e === "Enter" || e === " " || e === "";
|
|
1724
|
-
}
|
|
1725
|
-
function ys(e, n, t) {
|
|
1726
|
-
return Et(n, t ? e === He : e === Ye, e === st);
|
|
1727
|
-
}
|
|
1728
|
-
function Pn(e, n, t) {
|
|
1729
|
-
return Et(n, t ? e === Ye : e === He, e === Yt);
|
|
1730
|
-
}
|
|
1731
|
-
function xs(e, n) {
|
|
1732
|
-
const {
|
|
1733
|
-
open: t,
|
|
1734
|
-
onOpenChange: r,
|
|
1735
|
-
elements: o
|
|
1736
|
-
} = e, {
|
|
1737
|
-
listRef: s,
|
|
1738
|
-
activeIndex: i,
|
|
1739
|
-
onNavigate: a = () => {
|
|
1740
|
-
},
|
|
1741
|
-
enabled: l = !0,
|
|
1742
|
-
selectedIndex: c = null,
|
|
1743
|
-
allowEscape: f = !1,
|
|
1744
|
-
loop: d = !1,
|
|
1745
|
-
nested: h = !1,
|
|
1746
|
-
rtl: u = !1,
|
|
1747
|
-
virtual: m = !1,
|
|
1748
|
-
focusItemOnOpen: g = "auto",
|
|
1749
|
-
focusItemOnHover: w = !0,
|
|
1750
|
-
openOnArrowKeyDown: x = !0,
|
|
1751
|
-
disabledIndices: y = void 0,
|
|
1752
|
-
orientation: b = "vertical",
|
|
1753
|
-
cols: C = 1,
|
|
1754
|
-
scrollItemIntoView: A = !0,
|
|
1755
|
-
virtualItemRef: M,
|
|
1756
|
-
itemSizes: $,
|
|
1757
|
-
dense: K = !1
|
|
1758
|
-
} = n;
|
|
1759
|
-
process.env.NODE_ENV !== "production" && (f && (d || Ft("`useListNavigation` looping must be enabled to allow escaping."), m || Ft("`useListNavigation` must be virtual to allow escaping.")), b === "vertical" && C > 1 && Ft("In grid list navigation mode (`cols` > 1), the `orientation` should", 'be either "horizontal" or "both".'));
|
|
1760
|
-
const Z = fr(o.floating), G = Ne(Z), q = Jt(), O = wt(), N = xe(a), P = p.useRef(g), E = p.useRef(c ?? -1), D = p.useRef(null), B = p.useRef(!0), k = p.useRef(N), R = p.useRef(!!o.floating), U = p.useRef(t), te = p.useRef(!1), ve = p.useRef(!1), fe = Ne(y), z = Ne(t), T = Ne(A), S = Ne(c), [F, H] = p.useState(), [ee, ne] = p.useState(), Y = xe(function(_, V, I) {
|
|
1761
|
-
I === void 0 && (I = !1);
|
|
1762
|
-
function W(j) {
|
|
1763
|
-
m ? (H(j.id), O?.events.emit("virtualfocus", j), M && (M.current = j)) : Me(j, {
|
|
1764
|
-
preventScroll: !0,
|
|
1765
|
-
// Mac Safari does not move the virtual cursor unless the focus call
|
|
1766
|
-
// is sync. However, for the very first focus call, we need to wait
|
|
1767
|
-
// for the position to be ready in order to prevent unwanted
|
|
1768
|
-
// scrolling. This means the virtual cursor will not move to the first
|
|
1769
|
-
// item when first opening the floating element, but will on
|
|
1770
|
-
// subsequent calls. `preventScroll` is supported in modern Safari,
|
|
1771
|
-
// so we can use that instead.
|
|
1772
|
-
// iOS Safari must be async or the first item will not be focused.
|
|
1773
|
-
sync: ho() && Jn() ? Mn || te.current : !1
|
|
1774
|
-
});
|
|
1775
|
-
}
|
|
1776
|
-
const ae = _.current[V.current];
|
|
1777
|
-
ae && W(ae), requestAnimationFrame(() => {
|
|
1778
|
-
const j = _.current[V.current] || ae;
|
|
1779
|
-
if (!j) return;
|
|
1780
|
-
ae || W(j);
|
|
1781
|
-
const re = T.current;
|
|
1782
|
-
re && we && (I || !B.current) && (j.scrollIntoView == null || j.scrollIntoView(typeof re == "boolean" ? {
|
|
1783
|
-
block: "nearest",
|
|
1784
|
-
inline: "nearest"
|
|
1785
|
-
} : re));
|
|
1786
|
-
});
|
|
1787
|
-
});
|
|
1788
|
-
Q(() => {
|
|
1789
|
-
document.createElement("div").focus({
|
|
1790
|
-
get preventScroll() {
|
|
1791
|
-
return Mn = !0, !1;
|
|
1792
|
-
}
|
|
1793
|
-
});
|
|
1794
|
-
}, []), Q(() => {
|
|
1795
|
-
l && (t && o.floating ? P.current && c != null && (ve.current = !0, E.current = c, N(c)) : R.current && (E.current = -1, k.current(null)));
|
|
1796
|
-
}, [l, t, o.floating, c, N]), Q(() => {
|
|
1797
|
-
if (l && t && o.floating)
|
|
1798
|
-
if (i == null) {
|
|
1799
|
-
if (te.current = !1, S.current != null)
|
|
1800
|
-
return;
|
|
1801
|
-
if (R.current && (E.current = -1, Y(s, E)), (!U.current || !R.current) && P.current && (D.current != null || P.current === !0 && D.current == null)) {
|
|
1802
|
-
let _ = 0;
|
|
1803
|
-
const V = () => {
|
|
1804
|
-
s.current[0] == null ? (_ < 2 && (_ ? requestAnimationFrame : queueMicrotask)(V), _++) : (E.current = D.current == null || Vt(D.current, b, u) || h ? At(s, fe.current) : gn(s, fe.current), D.current = null, N(E.current));
|
|
1805
|
-
};
|
|
1806
|
-
V();
|
|
1807
|
-
}
|
|
1808
|
-
} else Qe(s, i) || (E.current = i, Y(s, E, ve.current), ve.current = !1);
|
|
1809
|
-
}, [l, t, o.floating, i, S, h, s, b, u, N, Y, fe]), Q(() => {
|
|
1810
|
-
var _;
|
|
1811
|
-
if (!l || o.floating || !O || m || !R.current)
|
|
1812
|
-
return;
|
|
1813
|
-
const V = O.nodesRef.current, I = (_ = V.find((j) => j.id === q)) == null || (_ = _.context) == null ? void 0 : _.elements.floating, W = Se(pe(o.floating)), ae = V.some((j) => j.context && ce(j.context.elements.floating, W));
|
|
1814
|
-
I && !ae && B.current && I.focus({
|
|
1815
|
-
preventScroll: !0
|
|
1816
|
-
});
|
|
1817
|
-
}, [l, o.floating, O, q, m]), Q(() => {
|
|
1818
|
-
if (!l || !O || !m || q) return;
|
|
1819
|
-
function _(V) {
|
|
1820
|
-
ne(V.id), M && (M.current = V);
|
|
1821
|
-
}
|
|
1822
|
-
return O.events.on("virtualfocus", _), () => {
|
|
1823
|
-
O.events.off("virtualfocus", _);
|
|
1824
|
-
};
|
|
1825
|
-
}, [l, O, m, q, M]), Q(() => {
|
|
1826
|
-
k.current = N, R.current = !!o.floating;
|
|
1827
|
-
}), Q(() => {
|
|
1828
|
-
t || (D.current = null);
|
|
1829
|
-
}, [t]), Q(() => {
|
|
1830
|
-
U.current = t;
|
|
1831
|
-
}, [t]);
|
|
1832
|
-
const Ee = i != null, we = p.useMemo(() => {
|
|
1833
|
-
function _(I) {
|
|
1834
|
-
if (!t) return;
|
|
1835
|
-
const W = s.current.indexOf(I);
|
|
1836
|
-
W !== -1 && N(W);
|
|
1837
|
-
}
|
|
1838
|
-
return {
|
|
1839
|
-
onFocus(I) {
|
|
1840
|
-
let {
|
|
1841
|
-
currentTarget: W
|
|
1842
|
-
} = I;
|
|
1843
|
-
_(W);
|
|
1844
|
-
},
|
|
1845
|
-
onClick: (I) => {
|
|
1846
|
-
let {
|
|
1847
|
-
currentTarget: W
|
|
1848
|
-
} = I;
|
|
1849
|
-
return W.focus({
|
|
1850
|
-
preventScroll: !0
|
|
1851
|
-
});
|
|
1852
|
-
},
|
|
1853
|
-
// Safari
|
|
1854
|
-
...w && {
|
|
1855
|
-
onMouseMove(I) {
|
|
1856
|
-
let {
|
|
1857
|
-
currentTarget: W
|
|
1858
|
-
} = I;
|
|
1859
|
-
_(W);
|
|
1860
|
-
},
|
|
1861
|
-
onPointerLeave(I) {
|
|
1862
|
-
let {
|
|
1863
|
-
pointerType: W
|
|
1864
|
-
} = I;
|
|
1865
|
-
!B.current || W === "touch" || (E.current = -1, Y(s, E), N(null), m || Me(G.current, {
|
|
1866
|
-
preventScroll: !0
|
|
1867
|
-
}));
|
|
1868
|
-
}
|
|
1869
|
-
}
|
|
1870
|
-
};
|
|
1871
|
-
}, [t, G, Y, w, s, N, m]), J = xe((_) => {
|
|
1872
|
-
if (B.current = !1, te.current = !0, !z.current && _.currentTarget === G.current)
|
|
1873
|
-
return;
|
|
1874
|
-
if (h && Pn(_.key, b, u)) {
|
|
1875
|
-
ue(_), r(!1, _.nativeEvent, "list-navigation"), Re(o.domReference) && !m && o.domReference.focus();
|
|
1876
|
-
return;
|
|
1877
|
-
}
|
|
1878
|
-
const V = E.current, I = At(s, y), W = gn(s, y);
|
|
1879
|
-
if (_.key === "Home" && (ue(_), E.current = I, N(E.current)), _.key === "End" && (ue(_), E.current = W, N(E.current)), C > 1) {
|
|
1880
|
-
const ae = $ || Array.from({
|
|
1881
|
-
length: s.current.length
|
|
1882
|
-
}, () => ({
|
|
1883
|
-
width: 1,
|
|
1884
|
-
height: 1
|
|
1885
|
-
})), j = qo(ae, C, K), re = j.findIndex((ye) => ye != null && !ft(s.current, ye, y)), Be = j.reduce((ye, Te, it) => Te != null && !ft(s.current, Te, y) ? it : ye, -1), Ze = j[Wo({
|
|
1886
|
-
current: j.map((ye) => ye != null ? s.current[ye] : null)
|
|
1887
|
-
}, {
|
|
1888
|
-
event: _,
|
|
1889
|
-
orientation: b,
|
|
1890
|
-
loop: d,
|
|
1891
|
-
cols: C,
|
|
1892
|
-
// treat undefined (empty grid spaces) as disabled indices so we
|
|
1893
|
-
// don't end up in them
|
|
1894
|
-
disabledIndices: Uo([...y || s.current.map((ye, Te) => ft(s.current, Te) ? Te : void 0), void 0], j),
|
|
1895
|
-
minIndex: re,
|
|
1896
|
-
maxIndex: Be,
|
|
1897
|
-
prevIndex: Ho(
|
|
1898
|
-
E.current > W ? I : E.current,
|
|
1899
|
-
ae,
|
|
1900
|
-
j,
|
|
1901
|
-
C,
|
|
1902
|
-
// use a corner matching the edge closest to the direction
|
|
1903
|
-
// we're moving in so we don't end up in the same item. Prefer
|
|
1904
|
-
// top/left over bottom/right.
|
|
1905
|
-
_.key === st ? "bl" : _.key === Ye ? "tr" : "tl"
|
|
1906
|
-
),
|
|
1907
|
-
stopEvent: !0
|
|
1908
|
-
})];
|
|
1909
|
-
if (Ze != null && (E.current = Ze, N(E.current)), b === "both")
|
|
1910
|
-
return;
|
|
1911
|
-
}
|
|
1912
|
-
if (Nn(_.key, b)) {
|
|
1913
|
-
if (ue(_), t && !m && Se(_.currentTarget.ownerDocument) === _.currentTarget) {
|
|
1914
|
-
E.current = Vt(_.key, b, u) ? I : W, N(E.current);
|
|
1915
|
-
return;
|
|
1916
|
-
}
|
|
1917
|
-
Vt(_.key, b, u) ? d ? E.current = V >= W ? f && V !== s.current.length ? -1 : I : le(s, {
|
|
1918
|
-
startingIndex: V,
|
|
1919
|
-
disabledIndices: y
|
|
1920
|
-
}) : E.current = Math.min(W, le(s, {
|
|
1921
|
-
startingIndex: V,
|
|
1922
|
-
disabledIndices: y
|
|
1923
|
-
})) : d ? E.current = V <= I ? f && V !== -1 ? s.current.length : W : le(s, {
|
|
1924
|
-
startingIndex: V,
|
|
1925
|
-
decrement: !0,
|
|
1926
|
-
disabledIndices: y
|
|
1927
|
-
}) : E.current = Math.max(I, le(s, {
|
|
1928
|
-
startingIndex: V,
|
|
1929
|
-
decrement: !0,
|
|
1930
|
-
disabledIndices: y
|
|
1931
|
-
})), Qe(s, E.current) ? N(null) : N(E.current);
|
|
1932
|
-
}
|
|
1933
|
-
}), Ie = p.useMemo(() => m && t && Ee && {
|
|
1934
|
-
"aria-activedescendant": ee || F
|
|
1935
|
-
}, [m, t, Ee, ee, F]), he = p.useMemo(() => ({
|
|
1936
|
-
"aria-orientation": b === "both" ? void 0 : b,
|
|
1937
|
-
...!Qn(o.domReference) && Ie,
|
|
1938
|
-
onKeyDown: J,
|
|
1939
|
-
onPointerMove() {
|
|
1940
|
-
B.current = !0;
|
|
1941
|
-
}
|
|
1942
|
-
}), [Ie, J, o.domReference, b]), Ae = p.useMemo(() => {
|
|
1943
|
-
function _(I) {
|
|
1944
|
-
g === "auto" && Yn(I.nativeEvent) && (P.current = !0);
|
|
1945
|
-
}
|
|
1946
|
-
function V(I) {
|
|
1947
|
-
P.current = g, g === "auto" && Zn(I.nativeEvent) && (P.current = !0);
|
|
1948
|
-
}
|
|
1949
|
-
return {
|
|
1950
|
-
...Ie,
|
|
1951
|
-
onKeyDown(I) {
|
|
1952
|
-
B.current = !1;
|
|
1953
|
-
const W = I.key.indexOf("Arrow") === 0, ae = ys(I.key, b, u), j = Pn(I.key, b, u), re = Nn(I.key, b), Be = (h ? ae : re) || I.key === "Enter" || I.key.trim() === "";
|
|
1954
|
-
if (m && t) {
|
|
1955
|
-
const it = O?.nodesRef.current.find((at) => at.parentId == null), ke = O && it ? ns(O.nodesRef.current, it.id) : null;
|
|
1956
|
-
if (W && ke && M) {
|
|
1957
|
-
const at = new KeyboardEvent("keydown", {
|
|
1958
|
-
key: I.key,
|
|
1959
|
-
bubbles: !0
|
|
1960
|
-
});
|
|
1961
|
-
if (ae || j) {
|
|
1962
|
-
var Ze, ye;
|
|
1963
|
-
const Fr = ((Ze = ke.context) == null ? void 0 : Ze.elements.domReference) === I.currentTarget, cn = j && !Fr ? (ye = ke.context) == null ? void 0 : ye.elements.domReference : ae ? s.current.find((un) => un?.id === F) : null;
|
|
1964
|
-
cn && (ue(I), cn.dispatchEvent(at), ne(void 0));
|
|
1965
|
-
}
|
|
1966
|
-
if (re && ke.context && ke.context.open && ke.parentId && I.currentTarget !== ke.context.elements.domReference) {
|
|
1967
|
-
var Te;
|
|
1968
|
-
ue(I), (Te = ke.context.elements.domReference) == null || Te.dispatchEvent(at);
|
|
1969
|
-
return;
|
|
1970
|
-
}
|
|
1971
|
-
}
|
|
1972
|
-
return J(I);
|
|
1973
|
-
}
|
|
1974
|
-
if (!(!t && !x && W)) {
|
|
1975
|
-
if (Be && (D.current = h && re ? null : I.key), h) {
|
|
1976
|
-
ae && (ue(I), t ? (E.current = At(s, fe.current), N(E.current)) : r(!0, I.nativeEvent, "list-navigation"));
|
|
1977
|
-
return;
|
|
1978
|
-
}
|
|
1979
|
-
re && (c != null && (E.current = c), ue(I), !t && x ? r(!0, I.nativeEvent, "list-navigation") : J(I), t && N(E.current));
|
|
1980
|
-
}
|
|
1981
|
-
},
|
|
1982
|
-
onFocus() {
|
|
1983
|
-
t && !m && N(null);
|
|
1984
|
-
},
|
|
1985
|
-
onPointerDown: V,
|
|
1986
|
-
onMouseDown: _,
|
|
1987
|
-
onClick: _
|
|
1988
|
-
};
|
|
1989
|
-
}, [F, Ie, J, fe, g, s, h, N, r, t, x, b, u, c, O, m, M]);
|
|
1990
|
-
return p.useMemo(() => l ? {
|
|
1991
|
-
reference: Ae,
|
|
1992
|
-
floating: he,
|
|
1993
|
-
item: we
|
|
1994
|
-
} : {}, [l, Ae, he, we]);
|
|
1995
|
-
}
|
|
1996
|
-
const Cs = /* @__PURE__ */ new Map([["select", "listbox"], ["combobox", "listbox"], ["label", !1]]);
|
|
1997
|
-
function ws(e, n) {
|
|
1998
|
-
var t;
|
|
1999
|
-
n === void 0 && (n = {});
|
|
2000
|
-
const {
|
|
2001
|
-
open: r,
|
|
2002
|
-
floatingId: o
|
|
2003
|
-
} = e, {
|
|
2004
|
-
enabled: s = !0,
|
|
2005
|
-
role: i = "dialog"
|
|
2006
|
-
} = n, a = (t = Cs.get(i)) != null ? t : i, l = Zt(), f = Jt() != null, d = p.useMemo(() => a === "tooltip" || i === "label" ? {
|
|
2007
|
-
["aria-" + (i === "label" ? "labelledby" : "describedby")]: r ? o : void 0
|
|
2008
|
-
} : {
|
|
2009
|
-
"aria-expanded": r ? "true" : "false",
|
|
2010
|
-
"aria-haspopup": a === "alertdialog" ? "dialog" : a,
|
|
2011
|
-
"aria-controls": r ? o : void 0,
|
|
2012
|
-
...a === "listbox" && {
|
|
2013
|
-
role: "combobox"
|
|
2014
|
-
},
|
|
2015
|
-
...a === "menu" && {
|
|
2016
|
-
id: l
|
|
2017
|
-
},
|
|
2018
|
-
...a === "menu" && f && {
|
|
2019
|
-
role: "menuitem"
|
|
2020
|
-
},
|
|
2021
|
-
...i === "select" && {
|
|
2022
|
-
"aria-autocomplete": "none"
|
|
2023
|
-
},
|
|
2024
|
-
...i === "combobox" && {
|
|
2025
|
-
"aria-autocomplete": "list"
|
|
2026
|
-
}
|
|
2027
|
-
}, [a, o, f, r, l, i]), h = p.useMemo(() => {
|
|
2028
|
-
const m = {
|
|
2029
|
-
id: o,
|
|
2030
|
-
...a && {
|
|
2031
|
-
role: a
|
|
2032
|
-
}
|
|
2033
|
-
};
|
|
2034
|
-
return a === "tooltip" || i === "label" ? m : {
|
|
2035
|
-
...m,
|
|
2036
|
-
...a === "menu" && {
|
|
2037
|
-
"aria-labelledby": l
|
|
2038
|
-
}
|
|
2039
|
-
};
|
|
2040
|
-
}, [a, o, l, i]), u = p.useCallback((m) => {
|
|
2041
|
-
let {
|
|
2042
|
-
active: g,
|
|
2043
|
-
selected: w
|
|
2044
|
-
} = m;
|
|
2045
|
-
const x = {
|
|
2046
|
-
role: "option",
|
|
2047
|
-
...g && {
|
|
2048
|
-
id: o + "-option"
|
|
2049
|
-
}
|
|
2050
|
-
};
|
|
2051
|
-
switch (i) {
|
|
2052
|
-
case "select":
|
|
2053
|
-
return {
|
|
2054
|
-
...x,
|
|
2055
|
-
"aria-selected": g && w
|
|
2056
|
-
};
|
|
2057
|
-
case "combobox":
|
|
2058
|
-
return {
|
|
2059
|
-
...x,
|
|
2060
|
-
...g && {
|
|
2061
|
-
"aria-selected": !0
|
|
2062
|
-
}
|
|
2063
|
-
};
|
|
2064
|
-
}
|
|
2065
|
-
return {};
|
|
2066
|
-
}, [o, i]);
|
|
2067
|
-
return p.useMemo(() => s ? {
|
|
2068
|
-
reference: d,
|
|
2069
|
-
floating: h,
|
|
2070
|
-
item: u
|
|
2071
|
-
} : {}, [s, d, h, u]);
|
|
2072
|
-
}
|
|
2073
|
-
function Ke(e, n, t) {
|
|
2074
|
-
let r = t.initialDeps ?? [], o, s = !0;
|
|
2075
|
-
function i() {
|
|
2076
|
-
var a, l, c;
|
|
2077
|
-
let f;
|
|
2078
|
-
t.key && ((a = t.debug) != null && a.call(t)) && (f = Date.now());
|
|
2079
|
-
const d = e();
|
|
2080
|
-
if (!(d.length !== r.length || d.some((m, g) => r[g] !== m)))
|
|
2081
|
-
return o;
|
|
2082
|
-
r = d;
|
|
2083
|
-
let u;
|
|
2084
|
-
if (t.key && ((l = t.debug) != null && l.call(t)) && (u = Date.now()), o = n(...d), t.key && ((c = t.debug) != null && c.call(t))) {
|
|
2085
|
-
const m = Math.round((Date.now() - f) * 100) / 100, g = Math.round((Date.now() - u) * 100) / 100, w = g / 16, x = (y, b) => {
|
|
2086
|
-
for (y = String(y); y.length < b; )
|
|
2087
|
-
y = " " + y;
|
|
2088
|
-
return y;
|
|
2089
|
-
};
|
|
2090
|
-
console.info(
|
|
2091
|
-
`%c⏱ ${x(g, 5)} /${x(m, 5)} ms`,
|
|
2092
|
-
`
|
|
2093
|
-
font-size: .6rem;
|
|
2094
|
-
font-weight: bold;
|
|
2095
|
-
color: hsl(${Math.max(
|
|
2096
|
-
0,
|
|
2097
|
-
Math.min(120 - 120 * w, 120)
|
|
2098
|
-
)}deg 100% 31%);`,
|
|
2099
|
-
t?.key
|
|
2100
|
-
);
|
|
2101
|
-
}
|
|
2102
|
-
return t?.onChange && !(s && t.skipInitialOnChange) && t.onChange(o), s = !1, o;
|
|
2103
|
-
}
|
|
2104
|
-
return i.updateDeps = (a) => {
|
|
2105
|
-
r = a;
|
|
2106
|
-
}, i;
|
|
2107
|
-
}
|
|
2108
|
-
function Dn(e, n) {
|
|
2109
|
-
if (e === void 0)
|
|
2110
|
-
throw new Error("Unexpected undefined");
|
|
2111
|
-
return e;
|
|
2112
|
-
}
|
|
2113
|
-
const Es = (e, n) => Math.abs(e - n) < 1.01, Is = (e, n, t) => {
|
|
2114
|
-
let r;
|
|
2115
|
-
return function(...o) {
|
|
2116
|
-
e.clearTimeout(r), r = e.setTimeout(() => n.apply(this, o), t);
|
|
2117
|
-
};
|
|
2118
|
-
}, An = (e) => {
|
|
2119
|
-
const { offsetWidth: n, offsetHeight: t } = e;
|
|
2120
|
-
return { width: n, height: t };
|
|
2121
|
-
}, Rs = (e) => e, Ss = (e) => {
|
|
2122
|
-
const n = Math.max(e.startIndex - e.overscan, 0), t = Math.min(e.endIndex + e.overscan, e.count - 1), r = [];
|
|
2123
|
-
for (let o = n; o <= t; o++)
|
|
2124
|
-
r.push(o);
|
|
2125
|
-
return r;
|
|
2126
|
-
}, Os = (e, n) => {
|
|
2127
|
-
const t = e.scrollElement;
|
|
2128
|
-
if (!t)
|
|
2129
|
-
return;
|
|
2130
|
-
const r = e.targetWindow;
|
|
2131
|
-
if (!r)
|
|
2132
|
-
return;
|
|
2133
|
-
const o = (i) => {
|
|
2134
|
-
const { width: a, height: l } = i;
|
|
2135
|
-
n({ width: Math.round(a), height: Math.round(l) });
|
|
2136
|
-
};
|
|
2137
|
-
if (o(An(t)), !r.ResizeObserver)
|
|
2138
|
-
return () => {
|
|
2139
|
-
};
|
|
2140
|
-
const s = new r.ResizeObserver((i) => {
|
|
2141
|
-
const a = () => {
|
|
2142
|
-
const l = i[0];
|
|
2143
|
-
if (l?.borderBoxSize) {
|
|
2144
|
-
const c = l.borderBoxSize[0];
|
|
2145
|
-
if (c) {
|
|
2146
|
-
o({ width: c.inlineSize, height: c.blockSize });
|
|
2147
|
-
return;
|
|
2148
|
-
}
|
|
2149
|
-
}
|
|
2150
|
-
o(An(t));
|
|
2151
|
-
};
|
|
2152
|
-
e.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(a) : a();
|
|
2153
|
-
});
|
|
2154
|
-
return s.observe(t, { box: "border-box" }), () => {
|
|
2155
|
-
s.unobserve(t);
|
|
2156
|
-
};
|
|
2157
|
-
}, Fn = {
|
|
2158
|
-
passive: !0
|
|
2159
|
-
}, _n = typeof window > "u" ? !0 : "onscrollend" in window, Ts = (e, n) => {
|
|
2160
|
-
const t = e.scrollElement;
|
|
2161
|
-
if (!t)
|
|
2162
|
-
return;
|
|
2163
|
-
const r = e.targetWindow;
|
|
2164
|
-
if (!r)
|
|
2165
|
-
return;
|
|
2166
|
-
let o = 0;
|
|
2167
|
-
const s = e.options.useScrollendEvent && _n ? () => {
|
|
2168
|
-
} : Is(
|
|
2169
|
-
r,
|
|
2170
|
-
() => {
|
|
2171
|
-
n(o, !1);
|
|
2172
|
-
},
|
|
2173
|
-
e.options.isScrollingResetDelay
|
|
2174
|
-
), i = (f) => () => {
|
|
2175
|
-
const { horizontal: d, isRtl: h } = e.options;
|
|
2176
|
-
o = d ? t.scrollLeft * (h && -1 || 1) : t.scrollTop, s(), n(o, f);
|
|
2177
|
-
}, a = i(!0), l = i(!1);
|
|
2178
|
-
t.addEventListener("scroll", a, Fn);
|
|
2179
|
-
const c = e.options.useScrollendEvent && _n;
|
|
2180
|
-
return c && t.addEventListener("scrollend", l, Fn), () => {
|
|
2181
|
-
t.removeEventListener("scroll", a), c && t.removeEventListener("scrollend", l);
|
|
2182
|
-
};
|
|
2183
|
-
}, ks = (e, n, t) => {
|
|
2184
|
-
if (n?.borderBoxSize) {
|
|
2185
|
-
const r = n.borderBoxSize[0];
|
|
2186
|
-
if (r)
|
|
2187
|
-
return Math.round(
|
|
2188
|
-
r[t.options.horizontal ? "inlineSize" : "blockSize"]
|
|
2189
|
-
);
|
|
2190
|
-
}
|
|
2191
|
-
return e[t.options.horizontal ? "offsetWidth" : "offsetHeight"];
|
|
2192
|
-
}, Ms = (e, {
|
|
2193
|
-
adjustments: n = 0,
|
|
2194
|
-
behavior: t
|
|
2195
|
-
}, r) => {
|
|
2196
|
-
var o, s;
|
|
2197
|
-
const i = e + n;
|
|
2198
|
-
(s = (o = r.scrollElement) == null ? void 0 : o.scrollTo) == null || s.call(o, {
|
|
2199
|
-
[r.options.horizontal ? "left" : "top"]: i,
|
|
2200
|
-
behavior: t
|
|
2201
|
-
});
|
|
2202
|
-
};
|
|
2203
|
-
class Ns {
|
|
2204
|
-
constructor(n) {
|
|
2205
|
-
this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.currentScrollToIndex = null, this.measurementsCache = [], this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.pendingMeasuredCacheIndexes = [], this.prevLanes = void 0, this.lanesChangedFlag = !1, this.lanesSettling = !1, this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this.elementsCache = /* @__PURE__ */ new Map(), this.observer = /* @__PURE__ */ (() => {
|
|
2206
|
-
let t = null;
|
|
2207
|
-
const r = () => t || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : t = new this.targetWindow.ResizeObserver((o) => {
|
|
2208
|
-
o.forEach((s) => {
|
|
2209
|
-
const i = () => {
|
|
2210
|
-
this._measureElement(s.target, s);
|
|
2211
|
-
};
|
|
2212
|
-
this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(i) : i();
|
|
2213
|
-
});
|
|
2214
|
-
}));
|
|
2215
|
-
return {
|
|
2216
|
-
disconnect: () => {
|
|
2217
|
-
var o;
|
|
2218
|
-
(o = r()) == null || o.disconnect(), t = null;
|
|
2219
|
-
},
|
|
2220
|
-
observe: (o) => {
|
|
2221
|
-
var s;
|
|
2222
|
-
return (s = r()) == null ? void 0 : s.observe(o, { box: "border-box" });
|
|
2223
|
-
},
|
|
2224
|
-
unobserve: (o) => {
|
|
2225
|
-
var s;
|
|
2226
|
-
return (s = r()) == null ? void 0 : s.unobserve(o);
|
|
2227
|
-
}
|
|
2228
|
-
};
|
|
2229
|
-
})(), this.range = null, this.setOptions = (t) => {
|
|
2230
|
-
Object.entries(t).forEach(([r, o]) => {
|
|
2231
|
-
typeof o > "u" && delete t[r];
|
|
2232
|
-
}), this.options = {
|
|
2233
|
-
debug: !1,
|
|
2234
|
-
initialOffset: 0,
|
|
2235
|
-
overscan: 1,
|
|
2236
|
-
paddingStart: 0,
|
|
2237
|
-
paddingEnd: 0,
|
|
2238
|
-
scrollPaddingStart: 0,
|
|
2239
|
-
scrollPaddingEnd: 0,
|
|
2240
|
-
horizontal: !1,
|
|
2241
|
-
getItemKey: Rs,
|
|
2242
|
-
rangeExtractor: Ss,
|
|
2243
|
-
onChange: () => {
|
|
2244
|
-
},
|
|
2245
|
-
measureElement: ks,
|
|
2246
|
-
initialRect: { width: 0, height: 0 },
|
|
2247
|
-
scrollMargin: 0,
|
|
2248
|
-
gap: 0,
|
|
2249
|
-
indexAttribute: "data-index",
|
|
2250
|
-
initialMeasurementsCache: [],
|
|
2251
|
-
lanes: 1,
|
|
2252
|
-
isScrollingResetDelay: 150,
|
|
2253
|
-
enabled: !0,
|
|
2254
|
-
isRtl: !1,
|
|
2255
|
-
useScrollendEvent: !1,
|
|
2256
|
-
useAnimationFrameWithResizeObserver: !1,
|
|
2257
|
-
...t
|
|
2258
|
-
};
|
|
2259
|
-
}, this.notify = (t) => {
|
|
2260
|
-
var r, o;
|
|
2261
|
-
(o = (r = this.options).onChange) == null || o.call(r, this, t);
|
|
2262
|
-
}, this.maybeNotify = Ke(
|
|
2263
|
-
() => (this.calculateRange(), [
|
|
2264
|
-
this.isScrolling,
|
|
2265
|
-
this.range ? this.range.startIndex : null,
|
|
2266
|
-
this.range ? this.range.endIndex : null
|
|
2267
|
-
]),
|
|
2268
|
-
(t) => {
|
|
2269
|
-
this.notify(t);
|
|
2270
|
-
},
|
|
2271
|
-
{
|
|
2272
|
-
key: process.env.NODE_ENV !== "production" && "maybeNotify",
|
|
2273
|
-
debug: () => this.options.debug,
|
|
2274
|
-
initialDeps: [
|
|
2275
|
-
this.isScrolling,
|
|
2276
|
-
this.range ? this.range.startIndex : null,
|
|
2277
|
-
this.range ? this.range.endIndex : null
|
|
2278
|
-
]
|
|
2279
|
-
}
|
|
2280
|
-
), this.cleanup = () => {
|
|
2281
|
-
this.unsubs.filter(Boolean).forEach((t) => t()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
|
|
2282
|
-
}, this._didMount = () => () => {
|
|
2283
|
-
this.cleanup();
|
|
2284
|
-
}, this._willUpdate = () => {
|
|
2285
|
-
var t;
|
|
2286
|
-
const r = this.options.enabled ? this.options.getScrollElement() : null;
|
|
2287
|
-
if (this.scrollElement !== r) {
|
|
2288
|
-
if (this.cleanup(), !r) {
|
|
2289
|
-
this.maybeNotify();
|
|
2290
|
-
return;
|
|
2291
|
-
}
|
|
2292
|
-
this.scrollElement = r, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((t = this.scrollElement) == null ? void 0 : t.window) ?? null, this.elementsCache.forEach((o) => {
|
|
2293
|
-
this.observer.observe(o);
|
|
2294
|
-
}), this.unsubs.push(
|
|
2295
|
-
this.options.observeElementRect(this, (o) => {
|
|
2296
|
-
this.scrollRect = o, this.maybeNotify();
|
|
2297
|
-
})
|
|
2298
|
-
), this.unsubs.push(
|
|
2299
|
-
this.options.observeElementOffset(this, (o, s) => {
|
|
2300
|
-
this.scrollAdjustments = 0, this.scrollDirection = s ? this.getScrollOffset() < o ? "forward" : "backward" : null, this.scrollOffset = o, this.isScrolling = s, this.maybeNotify();
|
|
2301
|
-
})
|
|
2302
|
-
), this._scrollToOffset(this.getScrollOffset(), {
|
|
2303
|
-
adjustments: void 0,
|
|
2304
|
-
behavior: void 0
|
|
2305
|
-
});
|
|
2306
|
-
}
|
|
2307
|
-
}, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getFurthestMeasurement = (t, r) => {
|
|
2308
|
-
const o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
2309
|
-
for (let i = r - 1; i >= 0; i--) {
|
|
2310
|
-
const a = t[i];
|
|
2311
|
-
if (o.has(a.lane))
|
|
2312
|
-
continue;
|
|
2313
|
-
const l = s.get(
|
|
2314
|
-
a.lane
|
|
2315
|
-
);
|
|
2316
|
-
if (l == null || a.end > l.end ? s.set(a.lane, a) : a.end < l.end && o.set(a.lane, !0), o.size === this.options.lanes)
|
|
2317
|
-
break;
|
|
2318
|
-
}
|
|
2319
|
-
return s.size === this.options.lanes ? Array.from(s.values()).sort((i, a) => i.end === a.end ? i.index - a.index : i.end - a.end)[0] : void 0;
|
|
2320
|
-
}, this.getMeasurementOptions = Ke(
|
|
2321
|
-
() => [
|
|
2322
|
-
this.options.count,
|
|
2323
|
-
this.options.paddingStart,
|
|
2324
|
-
this.options.scrollMargin,
|
|
2325
|
-
this.options.getItemKey,
|
|
2326
|
-
this.options.enabled,
|
|
2327
|
-
this.options.lanes
|
|
2328
|
-
],
|
|
2329
|
-
(t, r, o, s, i, a) => (this.prevLanes !== void 0 && this.prevLanes !== a && (this.lanesChangedFlag = !0), this.prevLanes = a, this.pendingMeasuredCacheIndexes = [], {
|
|
2330
|
-
count: t,
|
|
2331
|
-
paddingStart: r,
|
|
2332
|
-
scrollMargin: o,
|
|
2333
|
-
getItemKey: s,
|
|
2334
|
-
enabled: i,
|
|
2335
|
-
lanes: a
|
|
2336
|
-
}),
|
|
2337
|
-
{
|
|
2338
|
-
key: !1
|
|
2339
|
-
}
|
|
2340
|
-
), this.getMeasurements = Ke(
|
|
2341
|
-
() => [this.getMeasurementOptions(), this.itemSizeCache],
|
|
2342
|
-
({ count: t, paddingStart: r, scrollMargin: o, getItemKey: s, enabled: i, lanes: a }, l) => {
|
|
2343
|
-
if (!i)
|
|
2344
|
-
return this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), [];
|
|
2345
|
-
if (this.laneAssignments.size > t)
|
|
2346
|
-
for (const h of this.laneAssignments.keys())
|
|
2347
|
-
h >= t && this.laneAssignments.delete(h);
|
|
2348
|
-
this.lanesChangedFlag && (this.lanesChangedFlag = !1, this.lanesSettling = !0, this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), this.pendingMeasuredCacheIndexes = []), this.measurementsCache.length === 0 && !this.lanesSettling && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((h) => {
|
|
2349
|
-
this.itemSizeCache.set(h.key, h.size);
|
|
2350
|
-
}));
|
|
2351
|
-
const c = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
|
|
2352
|
-
this.pendingMeasuredCacheIndexes = [], this.lanesSettling && this.measurementsCache.length === t && (this.lanesSettling = !1);
|
|
2353
|
-
const f = this.measurementsCache.slice(0, c), d = new Array(a).fill(
|
|
2354
|
-
void 0
|
|
2355
|
-
);
|
|
2356
|
-
for (let h = 0; h < c; h++) {
|
|
2357
|
-
const u = f[h];
|
|
2358
|
-
u && (d[u.lane] = h);
|
|
2359
|
-
}
|
|
2360
|
-
for (let h = c; h < t; h++) {
|
|
2361
|
-
const u = s(h), m = this.laneAssignments.get(h);
|
|
2362
|
-
let g, w;
|
|
2363
|
-
if (m !== void 0 && this.options.lanes > 1) {
|
|
2364
|
-
g = m;
|
|
2365
|
-
const C = d[g], A = C !== void 0 ? f[C] : void 0;
|
|
2366
|
-
w = A ? A.end + this.options.gap : r + o;
|
|
2367
|
-
} else {
|
|
2368
|
-
const C = this.options.lanes === 1 ? f[h - 1] : this.getFurthestMeasurement(f, h);
|
|
2369
|
-
w = C ? C.end + this.options.gap : r + o, g = C ? C.lane : h % this.options.lanes, this.options.lanes > 1 && this.laneAssignments.set(h, g);
|
|
2370
|
-
}
|
|
2371
|
-
const x = l.get(u), y = typeof x == "number" ? x : this.options.estimateSize(h), b = w + y;
|
|
2372
|
-
f[h] = {
|
|
2373
|
-
index: h,
|
|
2374
|
-
start: w,
|
|
2375
|
-
size: y,
|
|
2376
|
-
end: b,
|
|
2377
|
-
key: u,
|
|
2378
|
-
lane: g
|
|
2379
|
-
}, d[g] = h;
|
|
2380
|
-
}
|
|
2381
|
-
return this.measurementsCache = f, f;
|
|
2382
|
-
},
|
|
2383
|
-
{
|
|
2384
|
-
key: process.env.NODE_ENV !== "production" && "getMeasurements",
|
|
2385
|
-
debug: () => this.options.debug
|
|
2386
|
-
}
|
|
2387
|
-
), this.calculateRange = Ke(
|
|
2388
|
-
() => [
|
|
2389
|
-
this.getMeasurements(),
|
|
2390
|
-
this.getSize(),
|
|
2391
|
-
this.getScrollOffset(),
|
|
2392
|
-
this.options.lanes
|
|
2393
|
-
],
|
|
2394
|
-
(t, r, o, s) => this.range = t.length > 0 && r > 0 ? Ps({
|
|
2395
|
-
measurements: t,
|
|
2396
|
-
outerSize: r,
|
|
2397
|
-
scrollOffset: o,
|
|
2398
|
-
lanes: s
|
|
2399
|
-
}) : null,
|
|
2400
|
-
{
|
|
2401
|
-
key: process.env.NODE_ENV !== "production" && "calculateRange",
|
|
2402
|
-
debug: () => this.options.debug
|
|
2403
|
-
}
|
|
2404
|
-
), this.getVirtualIndexes = Ke(
|
|
2405
|
-
() => {
|
|
2406
|
-
let t = null, r = null;
|
|
2407
|
-
const o = this.calculateRange();
|
|
2408
|
-
return o && (t = o.startIndex, r = o.endIndex), this.maybeNotify.updateDeps([this.isScrolling, t, r]), [
|
|
2409
|
-
this.options.rangeExtractor,
|
|
2410
|
-
this.options.overscan,
|
|
2411
|
-
this.options.count,
|
|
2412
|
-
t,
|
|
2413
|
-
r
|
|
2414
|
-
];
|
|
2415
|
-
},
|
|
2416
|
-
(t, r, o, s, i) => s === null || i === null ? [] : t({
|
|
2417
|
-
startIndex: s,
|
|
2418
|
-
endIndex: i,
|
|
2419
|
-
overscan: r,
|
|
2420
|
-
count: o
|
|
2421
|
-
}),
|
|
2422
|
-
{
|
|
2423
|
-
key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
|
|
2424
|
-
debug: () => this.options.debug
|
|
2425
|
-
}
|
|
2426
|
-
), this.indexFromElement = (t) => {
|
|
2427
|
-
const r = this.options.indexAttribute, o = t.getAttribute(r);
|
|
2428
|
-
return o ? parseInt(o, 10) : (console.warn(
|
|
2429
|
-
`Missing attribute name '${r}={index}' on measured element.`
|
|
2430
|
-
), -1);
|
|
2431
|
-
}, this._measureElement = (t, r) => {
|
|
2432
|
-
const o = this.indexFromElement(t), s = this.measurementsCache[o];
|
|
2433
|
-
if (!s)
|
|
2434
|
-
return;
|
|
2435
|
-
const i = s.key, a = this.elementsCache.get(i);
|
|
2436
|
-
a !== t && (a && this.observer.unobserve(a), this.observer.observe(t), this.elementsCache.set(i, t)), t.isConnected && this.resizeItem(o, this.options.measureElement(t, r, this));
|
|
2437
|
-
}, this.resizeItem = (t, r) => {
|
|
2438
|
-
const o = this.measurementsCache[t];
|
|
2439
|
-
if (!o)
|
|
2440
|
-
return;
|
|
2441
|
-
const s = this.itemSizeCache.get(o.key) ?? o.size, i = r - s;
|
|
2442
|
-
i !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(o, i, this) : o.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", i), this._scrollToOffset(this.getScrollOffset(), {
|
|
2443
|
-
adjustments: this.scrollAdjustments += i,
|
|
2444
|
-
behavior: void 0
|
|
2445
|
-
})), this.pendingMeasuredCacheIndexes.push(o.index), this.itemSizeCache = new Map(this.itemSizeCache.set(o.key, r)), this.notify(!1));
|
|
2446
|
-
}, this.measureElement = (t) => {
|
|
2447
|
-
if (!t) {
|
|
2448
|
-
this.elementsCache.forEach((r, o) => {
|
|
2449
|
-
r.isConnected || (this.observer.unobserve(r), this.elementsCache.delete(o));
|
|
2450
|
-
});
|
|
2451
|
-
return;
|
|
2452
|
-
}
|
|
2453
|
-
this._measureElement(t, void 0);
|
|
2454
|
-
}, this.getVirtualItems = Ke(
|
|
2455
|
-
() => [this.getVirtualIndexes(), this.getMeasurements()],
|
|
2456
|
-
(t, r) => {
|
|
2457
|
-
const o = [];
|
|
2458
|
-
for (let s = 0, i = t.length; s < i; s++) {
|
|
2459
|
-
const a = t[s], l = r[a];
|
|
2460
|
-
o.push(l);
|
|
2461
|
-
}
|
|
2462
|
-
return o;
|
|
2463
|
-
},
|
|
2464
|
-
{
|
|
2465
|
-
key: process.env.NODE_ENV !== "production" && "getVirtualItems",
|
|
2466
|
-
debug: () => this.options.debug
|
|
2467
|
-
}
|
|
2468
|
-
), this.getVirtualItemForOffset = (t) => {
|
|
2469
|
-
const r = this.getMeasurements();
|
|
2470
|
-
if (r.length !== 0)
|
|
2471
|
-
return Dn(
|
|
2472
|
-
r[hr(
|
|
2473
|
-
0,
|
|
2474
|
-
r.length - 1,
|
|
2475
|
-
(o) => Dn(r[o]).start,
|
|
2476
|
-
t
|
|
2477
|
-
)]
|
|
2478
|
-
);
|
|
2479
|
-
}, this.getMaxScrollOffset = () => {
|
|
2480
|
-
if (!this.scrollElement) return 0;
|
|
2481
|
-
if ("scrollHeight" in this.scrollElement)
|
|
2482
|
-
return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
|
|
2483
|
-
{
|
|
2484
|
-
const t = this.scrollElement.document.documentElement;
|
|
2485
|
-
return this.options.horizontal ? t.scrollWidth - this.scrollElement.innerWidth : t.scrollHeight - this.scrollElement.innerHeight;
|
|
2486
|
-
}
|
|
2487
|
-
}, this.getOffsetForAlignment = (t, r, o = 0) => {
|
|
2488
|
-
if (!this.scrollElement) return 0;
|
|
2489
|
-
const s = this.getSize(), i = this.getScrollOffset();
|
|
2490
|
-
r === "auto" && (r = t >= i + s ? "end" : "start"), r === "center" ? t += (o - s) / 2 : r === "end" && (t -= s);
|
|
2491
|
-
const a = this.getMaxScrollOffset();
|
|
2492
|
-
return Math.max(Math.min(a, t), 0);
|
|
2493
|
-
}, this.getOffsetForIndex = (t, r = "auto") => {
|
|
2494
|
-
t = Math.max(0, Math.min(t, this.options.count - 1));
|
|
2495
|
-
const o = this.measurementsCache[t];
|
|
2496
|
-
if (!o)
|
|
2497
|
-
return;
|
|
2498
|
-
const s = this.getSize(), i = this.getScrollOffset();
|
|
2499
|
-
if (r === "auto")
|
|
2500
|
-
if (o.end >= i + s - this.options.scrollPaddingEnd)
|
|
2501
|
-
r = "end";
|
|
2502
|
-
else if (o.start <= i + this.options.scrollPaddingStart)
|
|
2503
|
-
r = "start";
|
|
2504
|
-
else
|
|
2505
|
-
return [i, r];
|
|
2506
|
-
if (r === "end" && t === this.options.count - 1)
|
|
2507
|
-
return [this.getMaxScrollOffset(), r];
|
|
2508
|
-
const a = r === "end" ? o.end + this.options.scrollPaddingEnd : o.start - this.options.scrollPaddingStart;
|
|
2509
|
-
return [
|
|
2510
|
-
this.getOffsetForAlignment(a, r, o.size),
|
|
2511
|
-
r
|
|
2512
|
-
];
|
|
2513
|
-
}, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (t, { align: r = "start", behavior: o } = {}) => {
|
|
2514
|
-
o === "smooth" && this.isDynamicMode() && console.warn(
|
|
2515
|
-
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
2516
|
-
), this._scrollToOffset(this.getOffsetForAlignment(t, r), {
|
|
2517
|
-
adjustments: void 0,
|
|
2518
|
-
behavior: o
|
|
2519
|
-
});
|
|
2520
|
-
}, this.scrollToIndex = (t, { align: r = "auto", behavior: o } = {}) => {
|
|
2521
|
-
o === "smooth" && this.isDynamicMode() && console.warn(
|
|
2522
|
-
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
2523
|
-
), t = Math.max(0, Math.min(t, this.options.count - 1)), this.currentScrollToIndex = t;
|
|
2524
|
-
let s = 0;
|
|
2525
|
-
const i = 10, a = (c) => {
|
|
2526
|
-
if (!this.targetWindow) return;
|
|
2527
|
-
const f = this.getOffsetForIndex(t, c);
|
|
2528
|
-
if (!f) {
|
|
2529
|
-
console.warn("Failed to get offset for index:", t);
|
|
2530
|
-
return;
|
|
2531
|
-
}
|
|
2532
|
-
const [d, h] = f;
|
|
2533
|
-
this._scrollToOffset(d, { adjustments: void 0, behavior: o }), this.targetWindow.requestAnimationFrame(() => {
|
|
2534
|
-
const u = () => {
|
|
2535
|
-
if (this.currentScrollToIndex !== t) return;
|
|
2536
|
-
const m = this.getScrollOffset(), g = this.getOffsetForIndex(t, h);
|
|
2537
|
-
if (!g) {
|
|
2538
|
-
console.warn("Failed to get offset for index:", t);
|
|
2539
|
-
return;
|
|
2540
|
-
}
|
|
2541
|
-
Es(g[0], m) || l(h);
|
|
2542
|
-
};
|
|
2543
|
-
this.isDynamicMode() ? this.targetWindow.requestAnimationFrame(u) : u();
|
|
2544
|
-
});
|
|
2545
|
-
}, l = (c) => {
|
|
2546
|
-
this.targetWindow && this.currentScrollToIndex === t && (s++, s < i ? (process.env.NODE_ENV !== "production" && this.options.debug && console.info("Schedule retry", s, i), this.targetWindow.requestAnimationFrame(() => a(c))) : console.warn(
|
|
2547
|
-
`Failed to scroll to index ${t} after ${i} attempts.`
|
|
2548
|
-
));
|
|
2549
|
-
};
|
|
2550
|
-
a(r);
|
|
2551
|
-
}, this.scrollBy = (t, { behavior: r } = {}) => {
|
|
2552
|
-
r === "smooth" && this.isDynamicMode() && console.warn(
|
|
2553
|
-
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
2554
|
-
), this._scrollToOffset(this.getScrollOffset() + t, {
|
|
2555
|
-
adjustments: void 0,
|
|
2556
|
-
behavior: r
|
|
2557
|
-
});
|
|
2558
|
-
}, this.getTotalSize = () => {
|
|
2559
|
-
var t;
|
|
2560
|
-
const r = this.getMeasurements();
|
|
2561
|
-
let o;
|
|
2562
|
-
if (r.length === 0)
|
|
2563
|
-
o = this.options.paddingStart;
|
|
2564
|
-
else if (this.options.lanes === 1)
|
|
2565
|
-
o = ((t = r[r.length - 1]) == null ? void 0 : t.end) ?? 0;
|
|
2566
|
-
else {
|
|
2567
|
-
const s = Array(this.options.lanes).fill(null);
|
|
2568
|
-
let i = r.length - 1;
|
|
2569
|
-
for (; i >= 0 && s.some((a) => a === null); ) {
|
|
2570
|
-
const a = r[i];
|
|
2571
|
-
s[a.lane] === null && (s[a.lane] = a.end), i--;
|
|
2572
|
-
}
|
|
2573
|
-
o = Math.max(...s.filter((a) => a !== null));
|
|
2574
|
-
}
|
|
2575
|
-
return Math.max(
|
|
2576
|
-
o - this.options.scrollMargin + this.options.paddingEnd,
|
|
2577
|
-
0
|
|
2578
|
-
);
|
|
2579
|
-
}, this._scrollToOffset = (t, {
|
|
2580
|
-
adjustments: r,
|
|
2581
|
-
behavior: o
|
|
2582
|
-
}) => {
|
|
2583
|
-
this.options.scrollToFn(t, { behavior: o, adjustments: r }, this);
|
|
2584
|
-
}, this.measure = () => {
|
|
2585
|
-
this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.notify(!1);
|
|
2586
|
-
}, this.setOptions(n);
|
|
2587
|
-
}
|
|
2588
|
-
}
|
|
2589
|
-
const hr = (e, n, t, r) => {
|
|
2590
|
-
for (; e <= n; ) {
|
|
2591
|
-
const o = (e + n) / 2 | 0, s = t(o);
|
|
2592
|
-
if (s < r)
|
|
2593
|
-
e = o + 1;
|
|
2594
|
-
else if (s > r)
|
|
2595
|
-
n = o - 1;
|
|
2596
|
-
else
|
|
2597
|
-
return o;
|
|
2598
|
-
}
|
|
2599
|
-
return e > 0 ? e - 1 : 0;
|
|
2600
|
-
};
|
|
2601
|
-
function Ps({
|
|
2602
|
-
measurements: e,
|
|
2603
|
-
outerSize: n,
|
|
2604
|
-
scrollOffset: t,
|
|
2605
|
-
lanes: r
|
|
2606
|
-
}) {
|
|
2607
|
-
const o = e.length - 1, s = (l) => e[l].start;
|
|
2608
|
-
if (e.length <= r)
|
|
2609
|
-
return {
|
|
2610
|
-
startIndex: 0,
|
|
2611
|
-
endIndex: o
|
|
2612
|
-
};
|
|
2613
|
-
let i = hr(
|
|
2614
|
-
0,
|
|
2615
|
-
o,
|
|
2616
|
-
s,
|
|
2617
|
-
t
|
|
2618
|
-
), a = i;
|
|
2619
|
-
if (r === 1)
|
|
2620
|
-
for (; a < o && e[a].end < t + n; )
|
|
2621
|
-
a++;
|
|
2622
|
-
else if (r > 1) {
|
|
2623
|
-
const l = Array(r).fill(0);
|
|
2624
|
-
for (; a < o && l.some((f) => f < t + n); ) {
|
|
2625
|
-
const f = e[a];
|
|
2626
|
-
l[f.lane] = f.end, a++;
|
|
2627
|
-
}
|
|
2628
|
-
const c = Array(r).fill(t + n);
|
|
2629
|
-
for (; i >= 0 && c.some((f) => f >= t); ) {
|
|
2630
|
-
const f = e[i];
|
|
2631
|
-
c[f.lane] = f.start, i--;
|
|
2632
|
-
}
|
|
2633
|
-
i = Math.max(0, i - i % r), a = Math.min(o, a + (r - 1 - a % r));
|
|
2634
|
-
}
|
|
2635
|
-
return { startIndex: i, endIndex: a };
|
|
2636
|
-
}
|
|
2637
|
-
const Ln = typeof document < "u" ? p.useLayoutEffect : p.useEffect;
|
|
2638
|
-
function Ds({
|
|
2639
|
-
useFlushSync: e = !0,
|
|
2640
|
-
...n
|
|
2641
|
-
}) {
|
|
2642
|
-
const t = p.useReducer(() => ({}), {})[1], r = {
|
|
2643
|
-
...n,
|
|
2644
|
-
onChange: (s, i) => {
|
|
2645
|
-
var a;
|
|
2646
|
-
e && i ? $n(t) : t(), (a = n.onChange) == null || a.call(n, s, i);
|
|
2647
|
-
}
|
|
2648
|
-
}, [o] = p.useState(
|
|
2649
|
-
() => new Ns(r)
|
|
2650
|
-
);
|
|
2651
|
-
return o.setOptions(r), Ln(() => o._didMount(), []), Ln(() => o._willUpdate()), o;
|
|
2652
|
-
}
|
|
2653
|
-
function As(e) {
|
|
2654
|
-
return Ds({
|
|
2655
|
-
observeElementRect: Os,
|
|
2656
|
-
observeElementOffset: Ts,
|
|
2657
|
-
scrollToFn: Ms,
|
|
2658
|
-
...e
|
|
2659
|
-
});
|
|
2660
|
-
}
|
|
2661
|
-
const De = Pe(void 0), mr = Pe({
|
|
2662
|
-
activeIndex: 0
|
|
2663
|
-
}), Fs = (e, n) => n.type === "SET_ACTIVE_INDEX" ? {
|
|
2664
|
-
...e,
|
|
2665
|
-
activeIndex: n.payload
|
|
2666
|
-
} : e, pr = Pe(() => {
|
|
2667
|
-
throw new Error("ComboboxIdDispatch must be used within a provider");
|
|
2668
|
-
}), _s = ({ children: e }) => {
|
|
2669
|
-
const [n, t] = _r(Fs, {
|
|
2670
|
-
activeIndex: 0
|
|
2671
|
-
});
|
|
2672
|
-
return v(mr.Provider, { value: n, children: v(pr.Provider, { value: t, children: e }) });
|
|
2673
|
-
};
|
|
2674
|
-
function en() {
|
|
2675
|
-
return oe(pr);
|
|
2676
|
-
}
|
|
2677
|
-
function It() {
|
|
2678
|
-
return oe(mr);
|
|
2679
|
-
}
|
|
2680
|
-
const br = L(({ asChild: e, interactive: n, id: t, className: r, ...o }, s) => {
|
|
2681
|
-
if (n && !t)
|
|
2682
|
-
throw new Error("If ComboboxCustom is interactive, it must have an id");
|
|
2683
|
-
const i = e ? ie : "div", a = ze(), { activeIndex: l } = It(), c = oe(De);
|
|
2684
|
-
if (!c)
|
|
2685
|
-
throw new Error("ComboboxCustom must be used within a Combobox");
|
|
2686
|
-
const { customIds: f, setListRef: d, getItemProps: h, size: u } = c, m = Le(() => t && f.indexOf(t) || 0, [t, f]), g = Gt([
|
|
2687
|
-
(w) => {
|
|
2688
|
-
d(m, w);
|
|
2689
|
-
},
|
|
2690
|
-
s
|
|
2691
|
-
]);
|
|
2692
|
-
return v(Oe, { "data-size": u, asChild: !0, children: v(i, { ref: g, tabIndex: -1, className: X("ds-combobox__custom", r), id: t || a, role: "option", "aria-selected": l === m, "data-active": l === m, ...We(["interactive"], o), ...We(["onClick", "onPointerLeave"], h()) }) });
|
|
2693
|
-
}), gr = ({ size: e, error: n, formFieldProps: t }) => v("div", { className: "ds-combobox__error-message", id: t.errorId, "aria-live": "polite", "aria-relevant": "additions removals", children: n && v(Ut, { "data-size": e, children: n }) });
|
|
2694
|
-
gr.displayName = "ComboboxError";
|
|
2695
|
-
function Ls(e) {
|
|
2696
|
-
return Vn(e) && e.type === br;
|
|
2697
|
-
}
|
|
2698
|
-
function zs(e) {
|
|
2699
|
-
return Ls(e) && e.props.interactive === !0;
|
|
2700
|
-
}
|
|
2701
|
-
const vr = "internal-option-", me = (e) => vr + e, qt = (e) => e.slice(vr.length), Je = (e, n) => {
|
|
2702
|
-
const t = e.value;
|
|
2703
|
-
e.value = n;
|
|
2704
|
-
const r = e._valueTracker;
|
|
2705
|
-
typeof r < "u" && r.setValue(t), e.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
2706
|
-
}, yr = L(function({ asChild: n, className: t, ...r }, o) {
|
|
2707
|
-
return v(n ? ie : "button", { className: X("ds-chip", t), type: n ? void 0 : "button", ref: o, ...r });
|
|
2708
|
-
}), xr = L(function(n, t) {
|
|
2709
|
-
return v(yr, { "data-removable": !0, ref: t, ...n });
|
|
2710
|
-
}), Cr = L(function({ asChild: n, children: t, className: r, "data-size": o, "data-color": s, ...i }, a) {
|
|
2711
|
-
const l = i.type ?? "checkbox";
|
|
2712
|
-
return se(n ? ie : "label", { className: X("ds-chip", r), "data-size": o, "data-color": s, ref: a, children: [v(rt, { ...i, type: l }), v(Br, { children: t })] });
|
|
2713
|
-
}), Vs = L(function(n, t) {
|
|
2714
|
-
return v(Cr, { ref: t, type: "radio", ...n });
|
|
2715
|
-
}), Rt = {
|
|
2716
|
-
Button: yr,
|
|
2717
|
-
Checkbox: Cr,
|
|
2718
|
-
Radio: Vs,
|
|
2719
|
-
Removable: xr
|
|
2720
|
-
};
|
|
2721
|
-
Rt.Button.displayName = "Chip.Button";
|
|
2722
|
-
Rt.Checkbox.displayName = "Chip.Checkbox";
|
|
2723
|
-
Rt.Radio.displayName = "Chip.Radio";
|
|
2724
|
-
Rt.Removable.displayName = "Chip.Removable";
|
|
2725
|
-
const wr = () => {
|
|
2726
|
-
const e = oe(De);
|
|
2727
|
-
if (!e)
|
|
2728
|
-
throw new Error("ComboboxContext is missing");
|
|
2729
|
-
const { size: n, readOnly: t, disabled: r, selectedOptions: o, chipSrLabel: s, handleSelectOption: i, inputRef: a } = e;
|
|
2730
|
-
return v(Ht, { children: Object.keys(o).map((l) => v(xr, { "data-size": n, disabled: r, onKeyDown: (c) => {
|
|
2731
|
-
t || r || c.key === "Enter" && (c.stopPropagation(), i({
|
|
2732
|
-
option: o[l],
|
|
2733
|
-
remove: !0
|
|
2734
|
-
}), a?.current?.focus());
|
|
2735
|
-
}, onClick: () => {
|
|
2736
|
-
t || r || i({
|
|
2737
|
-
option: o[l],
|
|
2738
|
-
remove: !0
|
|
2739
|
-
});
|
|
2740
|
-
}, "aria-label": s(o[l]), children: o[l].label }, l)) });
|
|
2741
|
-
};
|
|
2742
|
-
wr.displayName = "ComboboxChips";
|
|
2743
|
-
const Er = L((e, n) => {
|
|
2744
|
-
const t = oe(De);
|
|
2745
|
-
if (!t)
|
|
2746
|
-
throw new Error("ComboboxContext is missing");
|
|
2747
|
-
const { readOnly: r, disabled: o, clearButtonLabel: s, handleSelectOption: i } = t;
|
|
2748
|
-
return v("button", { ...e, ref: n, disabled: o, className: X("ds-combobox__clear-button", "ds-focus"), onClick: () => {
|
|
2749
|
-
r || o || i({ option: null, clear: !0 });
|
|
2750
|
-
}, onKeyDown: (a) => {
|
|
2751
|
-
r || o || a.key === "Enter" && (a.stopPropagation(), i({ option: null, clear: !0 }));
|
|
2752
|
-
}, type: "button", "aria-label": s, children: v(qr, { fontSize: "1.5em", title: "Clear selection" }) });
|
|
2753
|
-
});
|
|
2754
|
-
Er.displayName = "ComboboxClearButton";
|
|
2755
|
-
const Ir = ({ hideClearButton: e, listId: n, error: t, hideChips: r, handleKeyDown: o, ...s }) => {
|
|
2756
|
-
const i = oe(De), a = en(), l = ge(null);
|
|
2757
|
-
if (!i)
|
|
2758
|
-
throw new Error("ComboboxContext is missing");
|
|
2759
|
-
const c = (E) => {
|
|
2760
|
-
a?.({ type: "SET_ACTIVE_INDEX", payload: E });
|
|
2761
|
-
}, { forwareddRef: f, readOnly: d, disabled: h, open: u, inputRef: m, refs: g, inputValue: w, multiple: x, selectedOptions: y, formFieldProps: b, htmlSize: C, options: A, setOpen: M, getReferenceProps: $, setInputValue: K, handleSelectOption: Z, size: G } = i, q = Gt([f, m]), O = (E) => {
|
|
2762
|
-
const D = E.target.value;
|
|
2763
|
-
K(D), c(0);
|
|
2764
|
-
for (const B of Object.values(A))
|
|
2765
|
-
if (B.label.toLowerCase() === D.toLowerCase()) {
|
|
2766
|
-
if (y[me(B.value)])
|
|
2767
|
-
continue;
|
|
2768
|
-
Z({ option: B });
|
|
2769
|
-
}
|
|
2770
|
-
}, N = !e && Object.keys(y).length > 0, P = $({
|
|
2771
|
-
ref: g?.setReference,
|
|
2772
|
-
role: null,
|
|
2773
|
-
"aria-controls": null,
|
|
2774
|
-
"aria-expanded": null,
|
|
2775
|
-
"aria-haspopup": null,
|
|
2776
|
-
/* If we click the wrapper, toggle open, set index to first option, and focus the input */
|
|
2777
|
-
onClick(E) {
|
|
2778
|
-
h || d || l.current?.contains(E.target) || (M(!u), c(0), m.current?.focus());
|
|
2779
|
-
},
|
|
2780
|
-
/* Handles list navigation */
|
|
2781
|
-
onKeyDown: o,
|
|
2782
|
-
// preventDefault on keydown to avoid sending in form
|
|
2783
|
-
onKeyPress(E) {
|
|
2784
|
-
E.key === "Enter" && E.preventDefault();
|
|
2785
|
-
}
|
|
2786
|
-
});
|
|
2787
|
-
return v(Bt, { "data-size": G, asChild: !0, children: se("div", { ...P, "aria-disabled": h ? "true" : void 0, className: X("ds-textfield__input", "ds-combobox__input__wrapper", d && "ds-combobox--readonly", t && "ds-combobox--error"), children: [se("div", { className: "ds-combobox__chip-and-input", children: [x && !r && v(wr, {}), v(Bt, { "data-size": G, asChild: !0, children: v("input", { ref: q, "aria-activedescendant": P["aria-activedescendant"], readOnly: d, "aria-autocomplete": "list", role: "combobox", "aria-expanded": u, "aria-controls": u ? n : void 0, autoComplete: "off", size: C, value: w, ...We(["style", "className"], s), ...b.inputProps, className: "ds-combobox__input", onChange: (E) => {
|
|
2788
|
-
O(E), !u && M(!0), s.onChange?.(E);
|
|
2789
|
-
} }) })] }), N && v(Er, { ref: l }), v("div", { className: "ds-combobox__arrow", children: u ? v(Hr, { title: "arrow up", fontSize: "1.5em" }) : v(Ur, { title: "arrow down", fontSize: "1.5em" }) })] }) });
|
|
2790
|
-
};
|
|
2791
|
-
Ir.displayName = "ComboboxInput";
|
|
2792
|
-
const Rr = ({ label: e, description: n, hideLabel: t, size: r, readOnly: o, formFieldProps: s }) => se(Ht, { children: [e && se(Oe, { "data-size": r, htmlFor: s.inputProps.id, className: X("ds-combobox__label", t && "ds-sr-only"), children: [o && v(eo, { "aria-hidden": !0, className: "ds-combobox__readonly__icon" }), e] }), n && v(Bt, { asChild: !0, "data-size": r, children: v("div", { id: s.descriptionId, className: X("ds-combobox__description", t && "ds-sr-only"), children: n }) })] });
|
|
2793
|
-
Rr.displayName = "ComboboxLabel";
|
|
2794
|
-
const Sr = ({ selectedOptions: e, multiple: n, name: t }) => {
|
|
2795
|
-
const r = Object.keys(e).map((o) => qt(o));
|
|
2796
|
-
return v("select", { name: t, multiple: n, style: { display: "none" }, value: n ? r : r[0], onChange: () => {
|
|
2797
|
-
}, children: r.map((o) => v("option", { value: o }, o)) });
|
|
2798
|
-
};
|
|
2799
|
-
Sr.displayName = "ComboboxNative";
|
|
2800
|
-
const Or = L(({ children: e, className: n, ...t }, r) => v("span", { className: X("ds-combobox__option__description", n), ref: r, ...t, children: e }));
|
|
2801
|
-
Or.displayName = "ComboboxOptionDescription";
|
|
2802
|
-
const Tr = ({ multiple: e, selected: n }) => v("div", { className: X(e && "ds-combobox__option__icon-wrapper", n && "ds-combobox__option__icon-wrapper--selected"), children: n && v(Gr, { className: "ds-combobox__option__icon-wrapper__icon", "aria-hidden": !0 }) });
|
|
2803
|
-
Tr.displayName = "SelectedIcon";
|
|
2804
|
-
const Bs = ({ id: e, ref: n, value: t }) => {
|
|
2805
|
-
const r = ze(), o = e || r, s = oe(De), { activeIndex: i } = It(), a = en();
|
|
2806
|
-
if (!s)
|
|
2807
|
-
throw new Error("ComboboxOption must be used within a Combobox");
|
|
2808
|
-
const { selectedOptions: l, onOptionClick: c, setListRef: f, customIds: d, filteredOptions: h } = s, u = Le(() => h.indexOf(me(String(t))) + d.length, [d.length, h, t]), m = Gt([
|
|
2809
|
-
(y) => {
|
|
2810
|
-
f(u, y);
|
|
2811
|
-
},
|
|
2812
|
-
n
|
|
2813
|
-
]);
|
|
2814
|
-
if (u === -1)
|
|
2815
|
-
throw new Error("Internal error: ComboboxOption did not find index");
|
|
2816
|
-
const g = l[me(t)], w = i === u;
|
|
2817
|
-
de(() => {
|
|
2818
|
-
w && a?.({ type: "SET_ACTIVE_INDEX", payload: u });
|
|
2819
|
-
}, [r, e, a, w, u]);
|
|
2820
|
-
const x = Xt(() => c(t), 50);
|
|
2821
|
-
return {
|
|
2822
|
-
id: o,
|
|
2823
|
-
ref: m,
|
|
2824
|
-
selected: g,
|
|
2825
|
-
active: w,
|
|
2826
|
-
onOptionClick: x
|
|
2827
|
-
};
|
|
2828
|
-
}, tn = Lr(L(({ value: e, description: n, children: t, className: r, ...o }, s) => {
|
|
2829
|
-
const i = ze(), { id: a, ref: l, selected: c, active: f, onOptionClick: d } = Bs({
|
|
2830
|
-
id: o.id,
|
|
2831
|
-
ref: s,
|
|
2832
|
-
value: e
|
|
2833
|
-
}), h = oe(De);
|
|
2834
|
-
if (!h)
|
|
2835
|
-
throw new Error("ComboboxOption must be used within a Combobox");
|
|
2836
|
-
const { size: u, multiple: m, getItemProps: g } = h, w = g();
|
|
2837
|
-
return v(Oe, { "data-size": "md", asChild: !0, children: se("button", { ref: l, id: a, role: "option", type: "button", "aria-selected": !!c, "aria-labelledby": i, tabIndex: -1, onClick: (x) => {
|
|
2838
|
-
d(), o.onClick?.(x);
|
|
2839
|
-
}, className: X("ds-combobox__option", f && "ds-combobox__option--active", m && "ds-combobox__option--multiple", r), ...We(["displayValue"], o), ...We(["onClick", "onPointerLeave"], w), children: [v(Oe, { asChild: !0, "data-size": u, children: v("span", { children: v(Tr, { multiple: m, selected: !!c }) }) }), se(Oe, { className: "ds-combobox__option__label", "data-size": u, id: i, children: [t, n && v(Or, { children: n })] })] }) });
|
|
2840
|
-
}));
|
|
2841
|
-
tn.displayName = "ComboboxOption";
|
|
2842
|
-
function $s(e) {
|
|
2843
|
-
return Vn(e) && e.type === tn;
|
|
2844
|
-
}
|
|
2845
|
-
const Ks = (e) => !!e;
|
|
2846
|
-
function js({ children: e, inputValue: n, multiple: t, filter: r = (s, i) => i.label.toLowerCase().startsWith(s.toLowerCase()), initialValue: o }) {
|
|
2847
|
-
const s = zr(r, [r]), { optionsChildren: i, customIds: a, restChildren: l, interactiveChildren: c } = Le(() => dn.toArray(e).reduce((y, b) => {
|
|
2848
|
-
if ($s(b))
|
|
2849
|
-
y.optionsChildren.push(b);
|
|
2850
|
-
else if (y.restChildren.push(b), zs(b)) {
|
|
2851
|
-
const C = b;
|
|
2852
|
-
if (y.interactiveChildren.push(C), !C.props.id)
|
|
2853
|
-
throw new Error("If ComboboxCustom is interactive, it must have an id");
|
|
2854
|
-
y.customIds.push(C.props.id);
|
|
2855
|
-
}
|
|
2856
|
-
return y;
|
|
2857
|
-
}, {
|
|
2858
|
-
optionsChildren: [],
|
|
2859
|
-
customIds: [],
|
|
2860
|
-
restChildren: [],
|
|
2861
|
-
interactiveChildren: []
|
|
2862
|
-
}), [e]), f = Le(() => {
|
|
2863
|
-
const w = [], x = {};
|
|
2864
|
-
return i.map((y) => {
|
|
2865
|
-
const b = y.props;
|
|
2866
|
-
let C = b.displayValue || "";
|
|
2867
|
-
if (!b.displayValue) {
|
|
2868
|
-
let A = "";
|
|
2869
|
-
dn.forEach(b.children, (M) => {
|
|
2870
|
-
if (typeof M == "string")
|
|
2871
|
-
A += M;
|
|
2872
|
-
else
|
|
2873
|
-
throw new Error("If ComboboxOption is not a string, it must have a displayValue prop");
|
|
2874
|
-
}), C = A;
|
|
2875
|
-
}
|
|
2876
|
-
return w.includes(b.value) && console.warn(`Combobox has multiple options with the same value: ${b.value}`), w.push(b.value), x[me(String(b.value))] = {
|
|
2877
|
-
value: String(b.value),
|
|
2878
|
-
label: C,
|
|
2879
|
-
displayValue: b.displayValue,
|
|
2880
|
-
description: b.description
|
|
2881
|
-
}, null;
|
|
2882
|
-
}), x;
|
|
2883
|
-
}, [i]), d = Le(() => (o?.map((w) => me(w)) || []).reduce((w, x) => {
|
|
2884
|
-
const y = f[x];
|
|
2885
|
-
return Ks(y) && (w[x] = y), w;
|
|
2886
|
-
}, {}), [o, f]), [h, u] = Ce(d), { filteredOptions: m, filteredOptionsChildren: g } = Le(() => {
|
|
2887
|
-
const w = [], x = Object.keys(f).map((y, b) => !t && Object.keys(h).length === 1 || t && h[y] || s(n, f[y]) ? (w.push(y), i[b]) : null).filter((y) => y);
|
|
2888
|
-
return { filteredOptions: w, filteredOptionsChildren: x };
|
|
2889
|
-
}, [
|
|
2890
|
-
s,
|
|
2891
|
-
n,
|
|
2892
|
-
t,
|
|
2893
|
-
f,
|
|
2894
|
-
i,
|
|
2895
|
-
h
|
|
2896
|
-
]);
|
|
2897
|
-
return {
|
|
2898
|
-
filteredOptionsChildren: g,
|
|
2899
|
-
filteredOptions: m,
|
|
2900
|
-
restChildren: l,
|
|
2901
|
-
options: f,
|
|
2902
|
-
customIds: a,
|
|
2903
|
-
selectedOptions: h,
|
|
2904
|
-
interactiveChildren: c,
|
|
2905
|
-
setSelectedOptions: u
|
|
2906
|
-
};
|
|
2907
|
-
}
|
|
2908
|
-
const Ws = ({ readOnly: e, disabled: n, interactiveChildren: t, filteredOptions: r, inputValue: o, selectedOptions: s, multiple: i, open: a, options: l, setOpen: c, handleSelectOption: f }) => {
|
|
2909
|
-
const { activeIndex: d } = It();
|
|
2910
|
-
return Xt((m) => {
|
|
2911
|
-
if (!(e || n) && m)
|
|
2912
|
-
switch (m.key) {
|
|
2913
|
-
case "ArrowDown":
|
|
2914
|
-
if (m.preventDefault(), a)
|
|
2915
|
-
break;
|
|
2916
|
-
c(!0);
|
|
2917
|
-
break;
|
|
2918
|
-
case "ArrowUp":
|
|
2919
|
-
if (m.preventDefault(), d !== 0)
|
|
2920
|
-
break;
|
|
2921
|
-
c(!1);
|
|
2922
|
-
break;
|
|
2923
|
-
case "Enter": {
|
|
2924
|
-
if (m.preventDefault(), !a)
|
|
2925
|
-
break;
|
|
2926
|
-
if (d <= t.length - 1) {
|
|
2927
|
-
const x = t[d];
|
|
2928
|
-
if (x.props.onSelect) {
|
|
2929
|
-
x?.props.onSelect();
|
|
2930
|
-
return;
|
|
2931
|
-
}
|
|
2932
|
-
}
|
|
2933
|
-
const g = d - t.length, w = r[g];
|
|
2934
|
-
f({ option: l[w] });
|
|
2935
|
-
break;
|
|
2936
|
-
}
|
|
2937
|
-
case "Backspace":
|
|
2938
|
-
if (!i) {
|
|
2939
|
-
const g = Object.keys(s).pop();
|
|
2940
|
-
g && f({
|
|
2941
|
-
option: s[g],
|
|
2942
|
-
remove: !0
|
|
2943
|
-
});
|
|
2944
|
-
break;
|
|
2945
|
-
}
|
|
2946
|
-
if (o === "" && i) {
|
|
2947
|
-
const g = Object.keys(s).pop();
|
|
2948
|
-
g && f({
|
|
2949
|
-
option: s[g],
|
|
2950
|
-
remove: !0
|
|
2951
|
-
});
|
|
2952
|
-
}
|
|
2953
|
-
break;
|
|
2954
|
-
}
|
|
2955
|
-
}, 20);
|
|
2956
|
-
}, qs = ({ listRef: e }) => {
|
|
2957
|
-
const [n, t] = Ce(!1), { activeIndex: r } = It(), o = en(), { refs: s, floatingStyles: i, context: a } = gs({
|
|
2958
|
-
open: n,
|
|
2959
|
-
onOpenChange: (m) => {
|
|
2960
|
-
m || o?.({ type: "SET_ACTIVE_INDEX", payload: 0 }), $n(() => {
|
|
2961
|
-
s.floating.current && !m && (s.floating.current.scrollTop = 0), setTimeout(() => {
|
|
2962
|
-
t(m);
|
|
2963
|
-
}, 1);
|
|
2964
|
-
});
|
|
2965
|
-
},
|
|
2966
|
-
whileElementsMounted: (m, g, w) => (qn(m, g, w), () => {
|
|
2967
|
-
g.scrollTop = 0;
|
|
2968
|
-
}),
|
|
2969
|
-
middleware: [
|
|
2970
|
-
Bo({ padding: 10 }),
|
|
2971
|
-
$o({
|
|
2972
|
-
apply({ rects: m, elements: g }) {
|
|
2973
|
-
requestAnimationFrame(() => {
|
|
2974
|
-
Object.assign(g.floating.style, {
|
|
2975
|
-
width: `${m.reference.width}px`,
|
|
2976
|
-
maxHeight: "200px"
|
|
2977
|
-
});
|
|
2978
|
-
});
|
|
2979
|
-
}
|
|
2980
|
-
}),
|
|
2981
|
-
Vo(10)
|
|
2982
|
-
]
|
|
2983
|
-
}), l = ws(a, { role: "listbox" }), c = ps(a), f = xs(a, {
|
|
2984
|
-
listRef: e,
|
|
2985
|
-
activeIndex: r,
|
|
2986
|
-
virtual: !0,
|
|
2987
|
-
scrollItemIntoView: !0,
|
|
2988
|
-
enabled: n,
|
|
2989
|
-
focusItemOnHover: !0,
|
|
2990
|
-
onNavigate: (m) => {
|
|
2991
|
-
o?.({ type: "SET_ACTIVE_INDEX", payload: m || 0 });
|
|
2992
|
-
}
|
|
2993
|
-
}), { getReferenceProps: d, getFloatingProps: h, getItemProps: u } = vs([l, c, f]);
|
|
2994
|
-
return {
|
|
2995
|
-
open: n,
|
|
2996
|
-
setOpen: t,
|
|
2997
|
-
activeIndex: r,
|
|
2998
|
-
refs: s,
|
|
2999
|
-
floatingStyles: i,
|
|
3000
|
-
context: a,
|
|
3001
|
-
getReferenceProps: d,
|
|
3002
|
-
getFloatingProps: h,
|
|
3003
|
-
getItemProps: u
|
|
3004
|
-
};
|
|
3005
|
-
}, Hs = Pe(null), Us = (e, n) => {
|
|
3006
|
-
const t = oe(Hs), r = ze(), o = e.id ?? `${n}-${r}`, s = e.errorId ?? `${n}-error-${r}`, i = `${n}-description-${r}`, a = e.size ?? t?.size ?? "md", l = t?.disabled || e?.disabled, c = !l && !!(e.error || t?.error);
|
|
3007
|
-
return {
|
|
3008
|
-
hasError: c,
|
|
3009
|
-
errorId: s,
|
|
3010
|
-
descriptionId: i,
|
|
3011
|
-
size: a,
|
|
3012
|
-
inputProps: {
|
|
3013
|
-
id: o,
|
|
3014
|
-
disabled: l,
|
|
3015
|
-
"aria-invalid": c ? !0 : void 0,
|
|
3016
|
-
"aria-describedby": X(e["aria-describedby"], !!e?.description && typeof e?.description == "string" && i, c && !t?.error && s, c && !!t?.error && t?.errorId) || void 0
|
|
3017
|
-
}
|
|
3018
|
-
};
|
|
3019
|
-
}, Xs = L(({ value: e, initialValue: n = [], onValueChange: t, label: r, hideLabel: o = !1, description: s, multiple: i = !1, disabled: a = !1, readOnly: l = !1, hideChips: c = !1, clearButtonLabel: f = "Fjern alt", hideClearButton: d = !1, error: h, errorId: u, id: m, name: g, portal: w = !0, htmlSize: x = 0, virtual: y = !1, children: b, style: C, size: A = "md", loading: M, loadingLabel: $ = "Laster...", filter: K, chipSrLabel: Z = (N) => "Slett " + N.label, className: G, ...q }, O) => {
|
|
3020
|
-
const N = ge(null), P = ge(null), E = ge([]), [D, B] = Ce(q.inputValue || "");
|
|
3021
|
-
de(() => {
|
|
3022
|
-
typeof q.inputValue == "string" && B(q.inputValue);
|
|
3023
|
-
}, [q.inputValue]);
|
|
3024
|
-
const { selectedOptions: k, options: R, restChildren: U, interactiveChildren: te, customIds: ve, filteredOptionsChildren: fe, filteredOptions: z, setSelectedOptions: T } = js({
|
|
3025
|
-
children: b,
|
|
3026
|
-
inputValue: D,
|
|
3027
|
-
filter: K,
|
|
3028
|
-
multiple: i,
|
|
3029
|
-
initialValue: n
|
|
3030
|
-
}), { open: S, setOpen: F, refs: H, floatingStyles: ee, context: ne, getReferenceProps: Y, getFloatingProps: Ee, getItemProps: we } = qs({
|
|
3031
|
-
listRef: E
|
|
3032
|
-
}), J = Us({
|
|
3033
|
-
disabled: a,
|
|
3034
|
-
error: h,
|
|
3035
|
-
errorId: u,
|
|
3036
|
-
size: A,
|
|
3037
|
-
description: s,
|
|
3038
|
-
id: m
|
|
3039
|
-
}, "combobox");
|
|
3040
|
-
de(() => {
|
|
3041
|
-
if (e && e.length > 0 && !i) {
|
|
3042
|
-
const V = R[me(e[0])];
|
|
3043
|
-
N.current && Je(N.current, V?.label || "");
|
|
3044
|
-
}
|
|
3045
|
-
}, [i, e, R]), de(() => {
|
|
3046
|
-
if (e && Object.keys(R).length >= 0) {
|
|
3047
|
-
const V = e.map((I) => R[me(I)]);
|
|
3048
|
-
T(V.reduce((I, W) => (I[me(W.value)] = W, I), {}));
|
|
3049
|
-
}
|
|
3050
|
-
}, [i, e, R, T]);
|
|
3051
|
-
const he = Xt((V) => {
|
|
3052
|
-
const { option: I, clear: W, remove: ae } = V;
|
|
3053
|
-
if (W) {
|
|
3054
|
-
T({}), N.current && Je(N.current, ""), t?.([]);
|
|
3055
|
-
return;
|
|
3056
|
-
}
|
|
3057
|
-
if (!I)
|
|
3058
|
-
return;
|
|
3059
|
-
if (ae) {
|
|
3060
|
-
const re = { ...k };
|
|
3061
|
-
delete re[me(I.value)], T(re), t?.(Object.keys(re).map((Be) => qt(Be)));
|
|
3062
|
-
return;
|
|
3063
|
-
}
|
|
3064
|
-
const j = { ...k };
|
|
3065
|
-
if (i)
|
|
3066
|
-
j[me(I.value)] ? delete j[me(I.value)] : j[me(I.value)] = I, N.current && Je(N.current, ""), N.current?.focus();
|
|
3067
|
-
else {
|
|
3068
|
-
for (const re of Object.keys(j))
|
|
3069
|
-
delete j[re];
|
|
3070
|
-
j[me(I.value)] = I, N.current && Je(N.current, I?.label || ""), setTimeout(() => {
|
|
3071
|
-
N.current?.setSelectionRange(I?.label?.length || 0, I?.label?.length || 0);
|
|
3072
|
-
}, 0);
|
|
3073
|
-
}
|
|
3074
|
-
T(j), t?.(Object.keys(j).map((re) => qt(re))), !i && F(!1), H.domReference.current?.focus();
|
|
3075
|
-
}, 50), Ae = Ws({
|
|
3076
|
-
filteredOptions: z,
|
|
3077
|
-
selectedOptions: k,
|
|
3078
|
-
readOnly: J.readOnly || !1,
|
|
3079
|
-
disabled: a,
|
|
3080
|
-
multiple: i,
|
|
3081
|
-
inputValue: D,
|
|
3082
|
-
options: R,
|
|
3083
|
-
open: S,
|
|
3084
|
-
interactiveChildren: te,
|
|
3085
|
-
setOpen: F,
|
|
3086
|
-
handleSelectOption: he
|
|
3087
|
-
}), _ = As({
|
|
3088
|
-
count: Object.keys(fe).length,
|
|
3089
|
-
getScrollElement: () => y ? H.floating.current : null,
|
|
3090
|
-
estimateSize: () => 70,
|
|
3091
|
-
measureElement: (V) => V.getBoundingClientRect().height,
|
|
3092
|
-
overscan: 7
|
|
3093
|
-
});
|
|
3094
|
-
return se(De.Provider, { value: {
|
|
3095
|
-
size: A,
|
|
3096
|
-
options: R,
|
|
3097
|
-
selectedOptions: k,
|
|
3098
|
-
multiple: i,
|
|
3099
|
-
disabled: a,
|
|
3100
|
-
readOnly: l,
|
|
3101
|
-
open: S,
|
|
3102
|
-
inputRef: N,
|
|
3103
|
-
refs: H,
|
|
3104
|
-
inputValue: D,
|
|
3105
|
-
formFieldProps: J,
|
|
3106
|
-
htmlSize: x,
|
|
3107
|
-
clearButtonLabel: f,
|
|
3108
|
-
customIds: ve,
|
|
3109
|
-
filteredOptions: z,
|
|
3110
|
-
setInputValue: B,
|
|
3111
|
-
setOpen: F,
|
|
3112
|
-
getReferenceProps: Y,
|
|
3113
|
-
getItemProps: we,
|
|
3114
|
-
/* Recieves the value of the option, and searches for it in our values lookup */
|
|
3115
|
-
onOptionClick: (V) => {
|
|
3116
|
-
if (l || a)
|
|
3117
|
-
return;
|
|
3118
|
-
const I = R[me(V)];
|
|
3119
|
-
he({ option: I });
|
|
3120
|
-
},
|
|
3121
|
-
handleSelectOption: he,
|
|
3122
|
-
chipSrLabel: Z,
|
|
3123
|
-
listRef: E,
|
|
3124
|
-
forwareddRef: O,
|
|
3125
|
-
setListRef: (V, I) => {
|
|
3126
|
-
E.current[V] = I;
|
|
3127
|
-
}
|
|
3128
|
-
}, children: [se("div", { className: X("ds-combobox", `ds-combobox--${A}`, a && "ds-combobox__disabled", G), style: C, ref: P, children: [g && v(Sr, { name: g, selectedOptions: k, multiple: i }), v(Rr, { label: r, description: s, size: A, readOnly: l, hideLabel: o, formFieldProps: J }), v(Ir, { ...We(["inputValue"], q), hideClearButton: d, listId: ne.floatingId || "", error: h, hideChips: c, handleKeyDown: Ae, "aria-busy": M }), v(gr, { size: A, error: h, formFieldProps: J })] }), S && v(us, { root: w ? null : P, children: v(fs, { context: ne, initialFocus: -1, visuallyHiddenDismiss: !0, children: se("div", { "aria-labelledby": J.inputProps.id, "aria-autocomplete": "list", tabIndex: -1, ...Ee({
|
|
3129
|
-
ref: H.setFloating,
|
|
3130
|
-
style: {
|
|
3131
|
-
...ee
|
|
3132
|
-
}
|
|
3133
|
-
}), className: X("ds-combobox__options-wrapper", `ds-combobox--${A}`), children: [y && v("div", { style: {
|
|
3134
|
-
height: `${_.getTotalSize()}px`,
|
|
3135
|
-
width: "100%",
|
|
3136
|
-
position: "relative"
|
|
3137
|
-
}, children: _.getVirtualItems().map((V) => v("div", { ref: _.measureElement, "data-index": V.index, style: {
|
|
3138
|
-
position: "absolute",
|
|
3139
|
-
top: 0,
|
|
3140
|
-
left: 0,
|
|
3141
|
-
width: "100%",
|
|
3142
|
-
transform: `translateY(${V.start}px)`
|
|
3143
|
-
}, children: fe[V.index] }, V.index)) }), M ? se(br, { className: "ds-combobox__loading", children: [v($r, { "aria-label": "Laster", "data-size": "sm" }), $] }) : se(Ht, { children: [U, !y && fe] })] }) }) })] });
|
|
3144
|
-
}), kr = L((e, n) => v(_s, { children: v(Xs, { ...e, ref: n }) }));
|
|
3145
|
-
kr.displayName = "Combobox";
|
|
3146
|
-
const Mr = L(({ children: e, className: n, ...t }, r) => {
|
|
3147
|
-
const o = oe(De);
|
|
3148
|
-
if (!o)
|
|
3149
|
-
throw new Error("ComboboxEmpty must be used within a Combobox");
|
|
3150
|
-
const { filteredOptions: s, size: i } = o;
|
|
3151
|
-
return s.length === 0 && v(Oe, { "data-size": i, asChild: !0, children: v("div", { ref: r, className: X("ds-combobox__empty", n), ...t, children: e }) });
|
|
3152
|
-
});
|
|
3153
|
-
Mr.displayName = "ComboboxEmpty";
|
|
3154
|
-
const St = kr;
|
|
3155
|
-
St.Option = tn;
|
|
3156
|
-
St.Empty = Mr;
|
|
3157
|
-
St.Option.displayName = "Combobox.Option";
|
|
3158
|
-
St.Empty.displayName = "Combobox.Empty";
|
|
3159
|
-
const Ni = L(function({ "data-size": n, className: t, style: r, children: o, label: s, description: i, error: a, ...l }, c) {
|
|
3160
|
-
return se(ht, { "data-size": n, className: t, style: r, children: [v(rt, { type: "checkbox", ref: c, ...l }), !!s && v(Oe, { weight: "regular", children: s }), !!i && v("div", { "data-field": "description", children: i }), !!a && v(Ut, { children: a })] });
|
|
3161
|
-
}), nn = Pe({
|
|
3162
|
-
current: null
|
|
3163
|
-
}), Nr = ({ children: e }) => {
|
|
3164
|
-
const n = ge(null);
|
|
3165
|
-
return v(nn.Provider, { value: n, children: e });
|
|
3166
|
-
};
|
|
3167
|
-
Nr.displayName = "DialogTriggerContext";
|
|
3168
|
-
const Gs = L(function({ asChild: n, children: t, className: r, placement: o = "center", closeButton: s = "Lukk dialogvindu", closedby: i = "closerequest", modal: a = !0, onClose: l, open: c, ...f }, d) {
|
|
3169
|
-
const h = oe(nn), u = ge(null), m = n ? ie : "dialog", g = Ve([h, d, u]), w = a ? "showModal" : "show";
|
|
3170
|
-
return de(() => u.current?.[c ? w : "close"](), [c]), de(() => {
|
|
3171
|
-
const x = u.current, y = (C) => {
|
|
3172
|
-
if (C.defaultPrevented)
|
|
3173
|
-
return;
|
|
3174
|
-
const { clientY: A, clientX: M, target: $ } = C;
|
|
3175
|
-
if ($ instanceof Element && C.type === "click" && $.closest('[data-command="close"]'))
|
|
3176
|
-
return x?.close();
|
|
3177
|
-
if (!(x && "closedBy" in x)) {
|
|
3178
|
-
if (C instanceof KeyboardEvent)
|
|
3179
|
-
return i === "none" && C.key === "Escape" && C.preventDefault();
|
|
3180
|
-
if (!window.getSelection()?.toString() && x && $ === x && i === "any") {
|
|
3181
|
-
const { top: K, left: Z, right: G, bottom: q } = x.getBoundingClientRect();
|
|
3182
|
-
K <= A && A <= q && Z <= M && M <= G || x?.close();
|
|
3183
|
-
}
|
|
3184
|
-
}
|
|
3185
|
-
}, b = () => {
|
|
3186
|
-
const C = x?.querySelector("[autofocus]");
|
|
3187
|
-
document.activeElement !== C && C?.focus();
|
|
3188
|
-
};
|
|
3189
|
-
return x?.addEventListener("animationend", b), x?.addEventListener("click", y), x?.addEventListener("keydown", y), () => {
|
|
3190
|
-
x?.removeEventListener("animationend", b), x?.removeEventListener("click", y), x?.removeEventListener("keydown", y);
|
|
3191
|
-
};
|
|
3192
|
-
}, [i]), de(() => {
|
|
3193
|
-
const x = (b) => l?.(b), y = u.current;
|
|
3194
|
-
return y?.addEventListener("close", x), () => y?.removeEventListener("close", x);
|
|
3195
|
-
}, [l]), se(m, { className: X("ds-dialog", r), ref: g, "data-placement": o, "data-modal": a, closedby: i, ...f, children: [s !== !1 && v(Ge, { "aria-label": s, "data-color": "neutral", icon: !0, variant: "tertiary", "data-command": "close" }), t] });
|
|
3196
|
-
}), Ys = L(function({ asChild: n, className: t, ...r }, o) {
|
|
3197
|
-
return v(n ? ie : "div", { className: X("ds-dialog__block", t), ref: o, ...r });
|
|
3198
|
-
}), Zs = L(function({ asChild: n, ...t }, r) {
|
|
3199
|
-
const o = oe(nn);
|
|
3200
|
-
return v(n ? ie : Ge, { "aria-haspopup": "dialog", onClick: () => {
|
|
3201
|
-
o.current?.getAttribute("data-modal") === "true" ? o.current?.showModal() : o.current?.show();
|
|
3202
|
-
}, ref: r, ...t });
|
|
3203
|
-
}), rn = Object.assign(Gs, {
|
|
3204
|
-
Block: Ys,
|
|
3205
|
-
TriggerContext: Nr,
|
|
3206
|
-
Trigger: Zs
|
|
3207
|
-
});
|
|
3208
|
-
rn.Block.displayName = "Dialog.Block";
|
|
3209
|
-
rn.TriggerContext.displayName = "Dialog.TriggerContext";
|
|
3210
|
-
rn.Trigger.displayName = "Dialog.Trigger";
|
|
3211
|
-
const Pr = ({ children: e }) => {
|
|
3212
|
-
const n = ze(), [t, r] = Ce(n);
|
|
3213
|
-
return v(on.Provider, { value: { popoverId: t, setPopoverId: r }, children: e });
|
|
3214
|
-
};
|
|
3215
|
-
Pr.displayName = "PopoverTriggerContext";
|
|
3216
|
-
const on = Pe({}), Js = L(function({ id: n, className: t, onClose: r, onOpen: o, open: s, variant: i = "default", placement: a = "top", autoPlacement: l = !0, asChild: c = !1, ...f }, d) {
|
|
3217
|
-
const h = c ? ie : "div", u = ge(null), m = Ve([u, d]), { popoverId: g, setPopoverId: w } = oe(on), [x, y] = Ce(!1), b = s ?? x;
|
|
3218
|
-
return de(() => {
|
|
3219
|
-
const C = u.current, A = ($) => {
|
|
3220
|
-
const K = $.target, Z = K?.closest?.(`[popovertarget="${C?.id}"]`), G = !Z && !C?.contains(K);
|
|
3221
|
-
Z && $.preventDefault(), b && (Z || G) ? (y(!1), r?.()) : !b && Z && (y(!0), o?.());
|
|
3222
|
-
}, M = ($) => {
|
|
3223
|
-
$.key !== "Escape" || !b || ($.preventDefault(), y(!1), r?.());
|
|
3224
|
-
};
|
|
3225
|
-
return C?.togglePopover?.(b), document.addEventListener("click", A, !0), document.addEventListener("keydown", M), () => {
|
|
3226
|
-
document.removeEventListener("click", A, !0), document.removeEventListener("keydown", M);
|
|
3227
|
-
};
|
|
3228
|
-
}, [b]), de(() => {
|
|
3229
|
-
const C = u.current, A = document.querySelector(`[popovertarget="${C?.id}"]`);
|
|
3230
|
-
if (C && A && b)
|
|
3231
|
-
return qn(A, C, () => {
|
|
3232
|
-
Wn(A, C, {
|
|
3233
|
-
placement: a,
|
|
3234
|
-
strategy: "fixed",
|
|
3235
|
-
middleware: [
|
|
3236
|
-
jn((M) => {
|
|
3237
|
-
const $ = getComputedStyle(M.elements.floating, "::before");
|
|
3238
|
-
return parseFloat($.height);
|
|
3239
|
-
}),
|
|
3240
|
-
...l ? [Kn({ fallbackAxisSideDirection: "start" }), Zr()] : [],
|
|
3241
|
-
Qs
|
|
3242
|
-
]
|
|
3243
|
-
}).then(({ x: M, y: $ }) => {
|
|
3244
|
-
C.style.translate = `${Math.round(M)}px ${Math.round($)}px`;
|
|
3245
|
-
});
|
|
3246
|
-
});
|
|
3247
|
-
}, [b, a, n, l]), de(() => {
|
|
3248
|
-
n && w?.(n);
|
|
3249
|
-
}, [n]), v(h, { className: X("ds-popover", t), id: n || g, popover: "manual", "data-variant": i, ref: m, ...f });
|
|
3250
|
-
}), Qs = {
|
|
3251
|
-
name: "ArrowPseudoElement",
|
|
3252
|
-
fn(e) {
|
|
3253
|
-
const { elements: n, rects: t, placement: r } = e;
|
|
3254
|
-
let o = `${Math.round(t.reference.width / 2 + t.reference.x - e.x)}px`, s = `${Math.round(t.reference.height / 2 + t.reference.y - e.y)}px`;
|
|
3255
|
-
switch (t.reference.width > t.floating.width && (o = `${Math.round(t.floating.width / 2)}px`), t.reference.height > t.floating.height && (s = `${Math.round(t.floating.height / 2)}px`), r.split("-")[0]) {
|
|
3256
|
-
case "top":
|
|
3257
|
-
s = "100%";
|
|
3258
|
-
break;
|
|
3259
|
-
case "right":
|
|
3260
|
-
o = "0";
|
|
3261
|
-
break;
|
|
3262
|
-
case "bottom":
|
|
3263
|
-
s = "0";
|
|
3264
|
-
break;
|
|
3265
|
-
case "left":
|
|
3266
|
-
o = "100%";
|
|
3267
|
-
break;
|
|
3268
|
-
}
|
|
3269
|
-
return n.floating.setAttribute("data-placement", r.split("-")[0]), n.floating.style.setProperty("--ds-popover-arrow-x", o), n.floating.style.setProperty("--ds-popover-arrow-y", s), e;
|
|
3270
|
-
}
|
|
3271
|
-
}, ei = L(function({ id: n, inline: t, asChild: r, ...o }, s) {
|
|
3272
|
-
const { popoverId: i } = oe(on), a = r ? ie : t ? "button" : Ge, l = Object.assign({
|
|
3273
|
-
[Vr.startsWith("19") ? "popoverTarget" : "popovertarget"]: i,
|
|
3274
|
-
...t ? {
|
|
3275
|
-
"data-popover": "inline"
|
|
3276
|
-
} : {}
|
|
3277
|
-
}, o);
|
|
3278
|
-
return v(a, { ref: s, ...l });
|
|
3279
|
-
}), Pi = L(function({ asChild: n, ...t }, r) {
|
|
3280
|
-
return v(n ? ie : "li", { ...t, ref: r });
|
|
3281
|
-
}), Dr = (e, { asChild: n, className: t, ...r }, o) => v(n ? ie : e, { className: X("ds-list", t), ref: o, ...r }), Di = L(function(n, t) {
|
|
3282
|
-
return Dr("ul", n, t);
|
|
3283
|
-
});
|
|
3284
|
-
L(function(n, t) {
|
|
3285
|
-
return Dr("ol", n, t);
|
|
3286
|
-
});
|
|
3287
|
-
const ti = L(function({ "aria-label": n = "Sidenavigering", asChild: t, className: r, ...o }, s) {
|
|
3288
|
-
return v(t ? ie : "nav", { "aria-label": n, className: X("ds-pagination", r), ref: s, ...o });
|
|
3289
|
-
}), ni = L(function(n, t) {
|
|
3290
|
-
return v(Ge, { ref: t, ...n });
|
|
3291
|
-
}), ri = L(function({ asChild: n, className: t, ...r }, o) {
|
|
3292
|
-
return v(n ? ie : "li", { ref: o, ...r });
|
|
3293
|
-
}), oi = L(function({ asChild: n, ...t }, r) {
|
|
3294
|
-
return v(n ? ie : "ul", { ref: r, ...t });
|
|
3295
|
-
}), sn = Object.assign(ti, {
|
|
3296
|
-
List: oi,
|
|
3297
|
-
Item: ri,
|
|
3298
|
-
Button: ni
|
|
3299
|
-
});
|
|
3300
|
-
sn.List.displayName = "Pagination.List";
|
|
3301
|
-
sn.Item.displayName = "Pagination.Item";
|
|
3302
|
-
sn.Button.displayName = "Pagination.Button";
|
|
3303
|
-
const Ar = Object.assign(Js, {
|
|
3304
|
-
TriggerContext: Pr,
|
|
3305
|
-
Trigger: ei
|
|
3306
|
-
});
|
|
3307
|
-
Ar.TriggerContext.displayName = "Popover.TriggerContext";
|
|
3308
|
-
Ar.Trigger.displayName = "Popover.Trigger";
|
|
3309
|
-
const si = L(function({ className: n, ...t }, r) {
|
|
3310
|
-
return v("div", { ref: r, className: X("ds-search", n), ...t });
|
|
3311
|
-
}), ii = L(function({ children: n = "Søk", ...t }, r) {
|
|
3312
|
-
return v(Ge, { ref: r, type: "submit", ...t, children: n });
|
|
3313
|
-
}), ai = L(function({ "aria-label": n = "Tøm", onClick: t, ...r }, o) {
|
|
3314
|
-
return v(Ge, { ref: o, variant: "tertiary", type: "reset", "aria-label": n, onClick: (i) => {
|
|
3315
|
-
const a = i.target;
|
|
3316
|
-
let l = null;
|
|
3317
|
-
if (a instanceof HTMLElement && (l = a.closest(".ds-search")?.querySelector("input")), !l)
|
|
3318
|
-
throw new Error("Input is missing");
|
|
3319
|
-
if (!(l instanceof HTMLInputElement))
|
|
3320
|
-
throw new Error("Input is not an input element");
|
|
3321
|
-
i.preventDefault(), Je(l, ""), l.focus(), t?.(i);
|
|
3322
|
-
}, icon: !0, ...r });
|
|
3323
|
-
}), li = L(function({ ...n }, t) {
|
|
3324
|
-
return v(rt, {
|
|
3325
|
-
ref: t,
|
|
3326
|
-
type: "search",
|
|
3327
|
-
/* We need an empty placeholder for the clear button to be able to show/hide */
|
|
3328
|
-
placeholder: "",
|
|
3329
|
-
...n
|
|
3330
|
-
});
|
|
3331
|
-
}), an = Object.assign(si, {
|
|
3332
|
-
Clear: ai,
|
|
3333
|
-
Button: ii,
|
|
3334
|
-
Input: li
|
|
3335
|
-
});
|
|
3336
|
-
an.Clear.displayName = "Search.Clear";
|
|
3337
|
-
an.Button.displayName = "Search.Button";
|
|
3338
|
-
an.Input.displayName = "Search.Input";
|
|
3339
|
-
const Ai = L(function({ asChild: n, className: t, height: r, style: o, variant: s = "rectangle", width: i, ...a }, l) {
|
|
3340
|
-
const c = n ? ie : "span", f = s === "text", d = Kr("ds-skeleton-opacity-fade"), h = Ve([d, l]);
|
|
3341
|
-
return v(c, { "aria-hidden": "true", className: X("ds-skeleton", t), "data-text": f ? "-".repeat(Number(i) || 1) : void 0, "data-variant": s, ref: h, style: f ? o : { width: i, height: r, ...o }, ...a });
|
|
3342
|
-
}), Fi = L(function({ "data-size": n, children: t, className: r, description: o, label: s, position: i, style: a, ...l }, c) {
|
|
3343
|
-
return se(ht, { className: r, "data-position": i, "data-size": n, style: a, children: [v(rt, { type: "checkbox", role: "switch", ref: c, ...l }), !!s && v(Oe, { weight: "regular", children: s }), !!o && v("div", { "data-field": "description", children: o })] });
|
|
3344
|
-
}), Ot = Pe({}), ci = L(function({ value: n, defaultValue: t, className: r, onChange: o, ...s }, i) {
|
|
3345
|
-
const a = ge(null), l = n !== void 0, [c, f] = Ce(t), [d, h] = Ce(/* @__PURE__ */ new Map());
|
|
3346
|
-
let u = o;
|
|
3347
|
-
return l || (u = (m) => {
|
|
3348
|
-
f(m), o?.(m);
|
|
3349
|
-
}, n = c), v(Ot.Provider, { value: {
|
|
3350
|
-
value: n,
|
|
3351
|
-
defaultValue: t,
|
|
3352
|
-
onChange: u,
|
|
3353
|
-
tablistRef: a,
|
|
3354
|
-
panelButtonMap: d,
|
|
3355
|
-
setPanelButtonMap: h
|
|
3356
|
-
}, children: v("div", { className: X("ds-tabs", r), ref: i, ...s }) });
|
|
3357
|
-
}), ui = L(function({ children: n, ...t }, r) {
|
|
3358
|
-
const { value: o, tablistRef: s } = oe(Ot), i = Ve([r, s]);
|
|
3359
|
-
return v(to, { role: "tablist", activeValue: o, orientation: "ambiguous", ref: i, ...t, children: n });
|
|
3360
|
-
}), di = L(function({ children: n, value: t, id: r, ...o }, s) {
|
|
3361
|
-
const { value: i, tablistRef: a, setPanelButtonMap: l } = oe(Ot), c = t === i, f = ze(), d = r ?? `tabpanel-${f}`, [h, u] = Ce(!1), [m, g] = Ce(void 0), w = ge(null), x = Ve([s, w]);
|
|
3362
|
-
return de(() => {
|
|
3363
|
-
if (!w.current)
|
|
3364
|
-
return;
|
|
3365
|
-
const y = w.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
|
|
3366
|
-
u(y.length > 0);
|
|
3367
|
-
}, [n]), de(() => {
|
|
3368
|
-
if (!a)
|
|
3369
|
-
return;
|
|
3370
|
-
const y = a.current?.querySelector(`[role="tab"][data-value="${t}"]`);
|
|
3371
|
-
g(y ? y.id : void 0), y && l?.((b) => new Map(b).set(y.id, d));
|
|
3372
|
-
}, [a]), v("div", { ref: x, id: d, role: "tabpanel", tabIndex: h ? void 0 : 0, "aria-labelledby": m, hidden: !c, ...o, children: n });
|
|
3373
|
-
}), fi = L(function({ value: n, id: t, onClick: r, ...o }, s) {
|
|
3374
|
-
const i = oe(Ot), a = ze(), l = t ?? `tab-${a}`;
|
|
3375
|
-
return v(ro, { value: n, ...o, asChild: !0, children: v("button", { ref: s, id: l, "aria-selected": i.value === n, "data-value": n, role: "tab", type: "button", onClick: (c) => {
|
|
3376
|
-
i.onChange?.(n), r?.(c);
|
|
3377
|
-
}, "aria-controls": i.panelButtonMap?.get(l), ...o }) });
|
|
3378
|
-
}), ln = Object.assign(ci, {
|
|
3379
|
-
List: ui,
|
|
3380
|
-
Tab: fi,
|
|
3381
|
-
Panel: di
|
|
3382
|
-
});
|
|
3383
|
-
ln.Tab.displayName = "Tabs.Tab";
|
|
3384
|
-
ln.List.displayName = "Tabs.List";
|
|
3385
|
-
ln.Panel.displayName = "Tabs.Panel";
|
|
3386
|
-
const _i = L(function({ label: n, description: t, error: r, multiline: o, prefix: s, suffix: i, "data-size": a, counter: l, style: c, className: f, ...d }, h) {
|
|
3387
|
-
return se(ht, { className: f, "data-size": a, style: c, children: [!!n && v(Oe, { children: n }), !!t && v(jr, { children: t }), se(Wr, { children: [s === void 0 || v(fn, { children: s }), o === !0 ? v(Jr, { ref: h, "aria-invalid": !!r || void 0, ...d }) : v(rt, { ref: h, "aria-invalid": !!r || void 0, ...d }), i === void 0 || v(fn, { children: i })] }), !!l && v(ht.Counter, { ...typeof l == "number" ? { limit: l } : l }), !!r && v(Ut, { children: r })] });
|
|
3388
|
-
});
|
|
3389
|
-
export {
|
|
3390
|
-
ao as B,
|
|
3391
|
-
Ni as C,
|
|
3392
|
-
rn as D,
|
|
3393
|
-
lo as L,
|
|
3394
|
-
sn as P,
|
|
3395
|
-
Fi as S,
|
|
3396
|
-
_i as T,
|
|
3397
|
-
Rt as a,
|
|
3398
|
-
St as b,
|
|
3399
|
-
Pi as c,
|
|
3400
|
-
Di as d,
|
|
3401
|
-
Ar as e,
|
|
3402
|
-
an as f,
|
|
3403
|
-
Ai as g,
|
|
3404
|
-
ln as h,
|
|
3405
|
-
Mi as u
|
|
3406
|
-
};
|