@strapi/ui-primitives 1.7.0-alpha.0 → 1.7.0-alpha.2
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/components/Collection/Collection.d.ts +34 -0
- package/dist/components/Collection/index.d.ts +2 -0
- package/dist/components/Combobox/Combobox.d.ts +96 -0
- package/dist/components/Combobox/index.d.ts +1 -0
- package/dist/components/Select/Select.d.ts +163 -0
- package/dist/components/Select/index.d.ts +1 -0
- package/dist/hooks/useCollator.d.ts +9 -0
- package/dist/hooks/useFilter.d.ts +16 -0
- package/dist/hooks/usePrev.d.ts +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1449 -0
- package/package.json +2 -2
package/dist/index.js
ADDED
|
@@ -0,0 +1,1449 @@
|
|
|
1
|
+
import * as r from "react";
|
|
2
|
+
import { composeEventHandlers as T } from "@radix-ui/primitive";
|
|
3
|
+
import { useComposedRefs as M } from "@radix-ui/react-compose-refs";
|
|
4
|
+
import { createContextScope as Qe, createContext as et } from "@radix-ui/react-context";
|
|
5
|
+
import { DismissableLayer as tt } from "@radix-ui/react-dismissable-layer";
|
|
6
|
+
import { useId as oe } from "@radix-ui/react-id";
|
|
7
|
+
import * as re from "@radix-ui/react-popper";
|
|
8
|
+
import { createPopperScope as ot } from "@radix-ui/react-popper";
|
|
9
|
+
import { Portal as nt } from "@radix-ui/react-portal";
|
|
10
|
+
import { Primitive as A } from "@radix-ui/react-primitive";
|
|
11
|
+
import { useControllableState as ie } from "@radix-ui/react-use-controllable-state";
|
|
12
|
+
import { hideOthers as rt } from "aria-hidden";
|
|
13
|
+
import * as Ae from "react-dom";
|
|
14
|
+
import { RemoveScroll as lt } from "react-remove-scroll";
|
|
15
|
+
import { jsx as d, jsxs as pe, Fragment as _e } from "react/jsx-runtime";
|
|
16
|
+
import { Slot as Te } from "@radix-ui/react-slot";
|
|
17
|
+
import { clamp as Ze } from "@radix-ui/number";
|
|
18
|
+
import { createCollection as Vt } from "@radix-ui/react-collection";
|
|
19
|
+
import { useDirection as Rt } from "@radix-ui/react-direction";
|
|
20
|
+
import { useFocusGuards as Nt } from "@radix-ui/react-focus-guards";
|
|
21
|
+
import { FocusScope as At } from "@radix-ui/react-focus-scope";
|
|
22
|
+
import { useCallbackRef as _t } from "@radix-ui/react-use-callback-ref";
|
|
23
|
+
import { useLayoutEffect as Z } from "@radix-ui/react-use-layout-effect";
|
|
24
|
+
import { usePrevious as Mt } from "@radix-ui/react-use-previous";
|
|
25
|
+
import { VisuallyHidden as Ot } from "@radix-ui/react-visually-hidden";
|
|
26
|
+
let Ie = /* @__PURE__ */ new Map();
|
|
27
|
+
function Dt(n, s) {
|
|
28
|
+
let e = n + (s ? Object.entries(s).sort((o, l) => o[0] < l[0] ? -1 : 1).join() : "");
|
|
29
|
+
if (Ie.has(e))
|
|
30
|
+
return Ie.get(e);
|
|
31
|
+
let t = new Intl.Collator(n, s);
|
|
32
|
+
return Ie.set(e, t), t;
|
|
33
|
+
}
|
|
34
|
+
function Me(n, s) {
|
|
35
|
+
let e = Dt(n, {
|
|
36
|
+
usage: "search",
|
|
37
|
+
...s
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
startsWith(t, o) {
|
|
41
|
+
return o.length === 0 ? !0 : (t = t.normalize("NFC"), o = o.normalize("NFC"), e.compare(t.slice(0, o.length), o) === 0);
|
|
42
|
+
},
|
|
43
|
+
endsWith(t, o) {
|
|
44
|
+
return o.length === 0 ? !0 : (t = t.normalize("NFC"), o = o.normalize("NFC"), e.compare(t.slice(-o.length), o) === 0);
|
|
45
|
+
},
|
|
46
|
+
contains(t, o) {
|
|
47
|
+
if (o.length === 0)
|
|
48
|
+
return !0;
|
|
49
|
+
t = t.normalize("NFC"), o = o.normalize("NFC");
|
|
50
|
+
let l = 0, i = o.length;
|
|
51
|
+
for (; l + i <= t.length; l++) {
|
|
52
|
+
let c = t.slice(l, l + i);
|
|
53
|
+
if (e.compare(o, c) === 0)
|
|
54
|
+
return !0;
|
|
55
|
+
}
|
|
56
|
+
return !1;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const Lt = (n) => {
|
|
61
|
+
const s = r.useRef();
|
|
62
|
+
return r.useEffect(() => {
|
|
63
|
+
s.current = n;
|
|
64
|
+
}), s.current;
|
|
65
|
+
};
|
|
66
|
+
function kt(n) {
|
|
67
|
+
const s = `${n}CollectionProvider`, [e, t] = Qe(s), [o, l] = e(s, {
|
|
68
|
+
collectionRef: {
|
|
69
|
+
current: null
|
|
70
|
+
},
|
|
71
|
+
itemMap: /* @__PURE__ */ new Map(),
|
|
72
|
+
listeners: /* @__PURE__ */ new Set()
|
|
73
|
+
}), i = (u) => {
|
|
74
|
+
const {
|
|
75
|
+
scope: p,
|
|
76
|
+
children: v
|
|
77
|
+
} = u, C = r.useRef(null), x = r.useRef(/* @__PURE__ */ new Map()).current, h = r.useRef(/* @__PURE__ */ new Set()).current;
|
|
78
|
+
return /* @__PURE__ */ d(o, {
|
|
79
|
+
scope: p,
|
|
80
|
+
itemMap: x,
|
|
81
|
+
collectionRef: C,
|
|
82
|
+
listeners: h,
|
|
83
|
+
children: v
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
i.displayName = s;
|
|
87
|
+
const c = `${n}CollectionSlot`, a = r.forwardRef((u, p) => {
|
|
88
|
+
const {
|
|
89
|
+
scope: v,
|
|
90
|
+
children: C
|
|
91
|
+
} = u, x = l(c, v), h = M(p, x.collectionRef);
|
|
92
|
+
return /* @__PURE__ */ d(Te, {
|
|
93
|
+
ref: h,
|
|
94
|
+
children: C
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
a.displayName = c;
|
|
98
|
+
const g = `${n}CollectionItemSlot`, f = "data-radix-collection-item", b = r.forwardRef((u, p) => {
|
|
99
|
+
const {
|
|
100
|
+
scope: v,
|
|
101
|
+
children: C,
|
|
102
|
+
...x
|
|
103
|
+
} = u, h = r.useRef(null), w = M(p, h), _ = l(g, v);
|
|
104
|
+
return r.useEffect(() => {
|
|
105
|
+
const E = Array.from(_.itemMap.values());
|
|
106
|
+
return _.itemMap.set(h, {
|
|
107
|
+
ref: h,
|
|
108
|
+
...x
|
|
109
|
+
}), _.listeners.forEach((O) => O(Array.from(_.itemMap.values()), E)), () => {
|
|
110
|
+
const O = Array.from(_.itemMap.values());
|
|
111
|
+
_.itemMap.delete(h), _.listeners.forEach((P) => P(Array.from(_.itemMap.values()), O));
|
|
112
|
+
};
|
|
113
|
+
}), /* @__PURE__ */ d(Te, {
|
|
114
|
+
[f]: "",
|
|
115
|
+
ref: w,
|
|
116
|
+
children: C
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
b.displayName = g;
|
|
120
|
+
function m(u) {
|
|
121
|
+
const p = l(`${n}CollectionConsumer`, u), v = r.useCallback(() => {
|
|
122
|
+
const x = p.collectionRef.current;
|
|
123
|
+
if (!x)
|
|
124
|
+
return [];
|
|
125
|
+
const h = Array.from(x.querySelectorAll(`[${f}]`));
|
|
126
|
+
return Array.from(p.itemMap.values()).sort((E, O) => h.indexOf(E.ref.current) - h.indexOf(O.ref.current));
|
|
127
|
+
}, [p.collectionRef, p.itemMap]), C = r.useCallback((x) => (p.listeners.add(x), () => p.listeners.delete(x)), [p.listeners]);
|
|
128
|
+
return {
|
|
129
|
+
getItems: v,
|
|
130
|
+
subscribe: C
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return [{
|
|
134
|
+
Provider: i,
|
|
135
|
+
Slot: a,
|
|
136
|
+
ItemSlot: b
|
|
137
|
+
}, m, t];
|
|
138
|
+
}
|
|
139
|
+
const Ft = [" ", "Enter", "ArrowUp", "ArrowDown"], Bt = ["Enter"], Je = (n) => Boolean(n.length === 1 && n.match(/\S| /)), st = "Combobox", [me, xe] = kt(st), [Ht, Y] = et(st), $t = ({
|
|
140
|
+
children: n
|
|
141
|
+
}) => /* @__PURE__ */ d(re.Root, {
|
|
142
|
+
children: /* @__PURE__ */ d(me.Provider, {
|
|
143
|
+
scope: void 0,
|
|
144
|
+
children: n
|
|
145
|
+
})
|
|
146
|
+
}), Ut = (n) => {
|
|
147
|
+
const {
|
|
148
|
+
allowCustomValue: s = !1,
|
|
149
|
+
autocomplete: e = "none",
|
|
150
|
+
children: t,
|
|
151
|
+
open: o,
|
|
152
|
+
defaultOpen: l,
|
|
153
|
+
onOpenChange: i,
|
|
154
|
+
value: c,
|
|
155
|
+
defaultValue: a,
|
|
156
|
+
onValueChange: g,
|
|
157
|
+
disabled: f,
|
|
158
|
+
required: b = !1,
|
|
159
|
+
locale: m = "en-EN",
|
|
160
|
+
onTextValueChange: u,
|
|
161
|
+
textValue: p,
|
|
162
|
+
defaultTextValue: v,
|
|
163
|
+
filterValue: C,
|
|
164
|
+
defaultFilterValue: x,
|
|
165
|
+
onFilterValueChange: h
|
|
166
|
+
} = n, [w, _] = r.useState(null), [E, O] = r.useState(null), [P, L] = r.useState(null), [k, H] = r.useState(null), [G = !1, $] = ie({
|
|
167
|
+
prop: o,
|
|
168
|
+
defaultProp: l,
|
|
169
|
+
onChange: i
|
|
170
|
+
}), [W, U] = ie({
|
|
171
|
+
prop: c,
|
|
172
|
+
defaultProp: a,
|
|
173
|
+
onChange: g
|
|
174
|
+
}), [F, V] = ie({
|
|
175
|
+
prop: p,
|
|
176
|
+
defaultProp: v,
|
|
177
|
+
onChange: u
|
|
178
|
+
}), [B, K] = ie({
|
|
179
|
+
prop: C,
|
|
180
|
+
defaultProp: x,
|
|
181
|
+
onChange: h
|
|
182
|
+
}), z = oe(), ue = r.useCallback((le, se) => {
|
|
183
|
+
const de = se.map((y) => y.ref.current), [X, ...ce] = de, [Q] = ce.slice(-1), S = k;
|
|
184
|
+
for (const y of le) {
|
|
185
|
+
if (y === S)
|
|
186
|
+
return;
|
|
187
|
+
if (y?.scrollIntoView({
|
|
188
|
+
block: "nearest"
|
|
189
|
+
}), y === X && E && (E.scrollTop = 0), y === Q && E && (E.scrollTop = E.scrollHeight), H(y), e === "both") {
|
|
190
|
+
const D = se.find((I) => I.ref.current === y);
|
|
191
|
+
D && V(D.textValue);
|
|
192
|
+
}
|
|
193
|
+
if (y !== S)
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
}, [e, V, E, k]);
|
|
197
|
+
return r.useEffect(() => {
|
|
198
|
+
e !== "both" && H(null);
|
|
199
|
+
}, [F, e]), r.useEffect(() => {
|
|
200
|
+
if (P && w)
|
|
201
|
+
return rt([P, w]);
|
|
202
|
+
}, [P, w]), /* @__PURE__ */ d($t, {
|
|
203
|
+
children: /* @__PURE__ */ d(Ht, {
|
|
204
|
+
allowCustomValue: s,
|
|
205
|
+
autocomplete: e,
|
|
206
|
+
required: b,
|
|
207
|
+
trigger: w,
|
|
208
|
+
onTriggerChange: _,
|
|
209
|
+
contentId: z,
|
|
210
|
+
value: W,
|
|
211
|
+
onValueChange: U,
|
|
212
|
+
open: G,
|
|
213
|
+
onOpenChange: $,
|
|
214
|
+
disabled: f,
|
|
215
|
+
locale: m,
|
|
216
|
+
focusFirst: ue,
|
|
217
|
+
textValue: F,
|
|
218
|
+
onTextValueChange: V,
|
|
219
|
+
onViewportChange: O,
|
|
220
|
+
onContentChange: L,
|
|
221
|
+
visuallyFocussedItem: k,
|
|
222
|
+
filterValue: B,
|
|
223
|
+
onFilterValueChange: K,
|
|
224
|
+
onVisuallyFocussedItemChange: H,
|
|
225
|
+
children: t
|
|
226
|
+
})
|
|
227
|
+
});
|
|
228
|
+
}, Kt = "ComboboxTrigger", Wt = r.forwardRef((n, s) => {
|
|
229
|
+
const {
|
|
230
|
+
...e
|
|
231
|
+
} = n, t = Y(Kt);
|
|
232
|
+
return /* @__PURE__ */ d(re.Anchor, {
|
|
233
|
+
asChild: !0,
|
|
234
|
+
children: /* @__PURE__ */ d("div", {
|
|
235
|
+
ref: s,
|
|
236
|
+
"data-disabled": t.disabled ? "" : void 0,
|
|
237
|
+
...e
|
|
238
|
+
})
|
|
239
|
+
});
|
|
240
|
+
}), ct = "ComboboxInput", zt = r.forwardRef((n, s) => {
|
|
241
|
+
const e = Y(ct), t = r.useRef(null), {
|
|
242
|
+
getItems: o
|
|
243
|
+
} = xe(void 0), {
|
|
244
|
+
startsWith: l
|
|
245
|
+
} = Me(e.locale, {
|
|
246
|
+
sensitivity: "base"
|
|
247
|
+
}), i = e.disabled, c = M(t, s, e.onTriggerChange), a = () => {
|
|
248
|
+
i || e.onOpenChange(!0);
|
|
249
|
+
}, g = Lt(e.filterValue);
|
|
250
|
+
return r.useLayoutEffect(() => {
|
|
251
|
+
setTimeout(() => {
|
|
252
|
+
if (e.textValue === "" || e.textValue === void 0 || e.filterValue === "" || e.filterValue === void 0)
|
|
253
|
+
return;
|
|
254
|
+
const f = o().find((m) => m.type === "option" && l(m.textValue, e.textValue)), b = So(g ?? "", e.filterValue);
|
|
255
|
+
f && !e.visuallyFocussedItem && b === e.filterValue.length && t.current.setSelectionRange(e.filterValue.length, e.textValue.length);
|
|
256
|
+
});
|
|
257
|
+
}, [e.textValue, e.filterValue, l, e.visuallyFocussedItem, o, g]), /* @__PURE__ */ d("input", {
|
|
258
|
+
type: "text",
|
|
259
|
+
role: "combobox",
|
|
260
|
+
"aria-controls": e.contentId,
|
|
261
|
+
"aria-expanded": e.open,
|
|
262
|
+
"aria-required": e.required,
|
|
263
|
+
"aria-autocomplete": e.autocomplete,
|
|
264
|
+
"data-state": e.open ? "open" : "closed",
|
|
265
|
+
"aria-disabled": i,
|
|
266
|
+
"aria-activedescendant": e.visuallyFocussedItem?.id,
|
|
267
|
+
disabled: i,
|
|
268
|
+
"data-disabled": i ? "" : void 0,
|
|
269
|
+
"data-placeholder": e.textValue === void 0 ? "" : void 0,
|
|
270
|
+
value: e.textValue ?? "",
|
|
271
|
+
...n,
|
|
272
|
+
ref: c,
|
|
273
|
+
onClick: T(n.onClick, (f) => {
|
|
274
|
+
f.currentTarget.focus();
|
|
275
|
+
}),
|
|
276
|
+
onPointerDown: T(n.onPointerDown, (f) => {
|
|
277
|
+
f.button === 0 && f.ctrlKey === !1 && (a(), f.currentTarget.focus());
|
|
278
|
+
}),
|
|
279
|
+
onKeyDown: T(n.onKeyDown, (f) => {
|
|
280
|
+
if (["ArrowUp", "ArrowDown", "Home", "End"].includes(f.key))
|
|
281
|
+
setTimeout(() => {
|
|
282
|
+
let m = o().filter((u) => !u.disabled).map((u) => u.ref.current);
|
|
283
|
+
if (["ArrowUp", "End"].includes(f.key) && (m = m.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(f.key)) {
|
|
284
|
+
const u = e.visuallyFocussedItem ?? f.target;
|
|
285
|
+
let p = m.indexOf(u);
|
|
286
|
+
p === m.length - 1 && (p = -1), m = m.slice(p + 1);
|
|
287
|
+
}
|
|
288
|
+
if (["ArrowDown"].includes(f.key) && e.autocomplete === "both" && m.length > 1) {
|
|
289
|
+
const [u, ...p] = m, v = o().find((C) => C.ref.current === u).textValue;
|
|
290
|
+
e.textValue === v && (m = p);
|
|
291
|
+
}
|
|
292
|
+
e.focusFirst(m, o());
|
|
293
|
+
}), f.preventDefault();
|
|
294
|
+
else if (["Escape"].includes(f.key))
|
|
295
|
+
e.open ? e.onOpenChange(!1) : (e.onValueChange(void 0), e.onTextValueChange("")), f.preventDefault();
|
|
296
|
+
else if (Bt.includes(f.key)) {
|
|
297
|
+
if (e.visuallyFocussedItem) {
|
|
298
|
+
const b = o().find((m) => m.ref.current === e.visuallyFocussedItem);
|
|
299
|
+
b && (e.onValueChange(b.value), e.onTextValueChange(b.textValue), e.autocomplete === "both" && e.onFilterValueChange(b.textValue), b.ref.current?.click());
|
|
300
|
+
}
|
|
301
|
+
e.onOpenChange(!1), f.preventDefault();
|
|
302
|
+
} else
|
|
303
|
+
e.onVisuallyFocussedItemChange(null);
|
|
304
|
+
}),
|
|
305
|
+
onChange: T(n.onChange, (f) => {
|
|
306
|
+
e.onTextValueChange(f.currentTarget.value), e.autocomplete === "both" && e.onFilterValueChange(f.currentTarget.value);
|
|
307
|
+
}),
|
|
308
|
+
onKeyUp: T(n.onKeyUp, (f) => {
|
|
309
|
+
if (!e.open && (Je(f.key) || ["ArrowUp", "ArrowDown", "Home", "End", "Backspace"].includes(f.key)) && a(), e.autocomplete === "both" && Je(f.key) && e.filterValue !== void 0) {
|
|
310
|
+
const b = e.filterValue, m = o().find((u) => l(u.textValue, b));
|
|
311
|
+
m && e.onTextValueChange(m.textValue);
|
|
312
|
+
}
|
|
313
|
+
}),
|
|
314
|
+
onBlur: T(n.onBlur, (f) => {
|
|
315
|
+
e.onVisuallyFocussedItemChange(null);
|
|
316
|
+
const [b] = o().filter((u) => u.textValue === e.textValue && u.type === "option");
|
|
317
|
+
if (e.allowCustomValue) {
|
|
318
|
+
b && (e.onValueChange(b.value), e.autocomplete === "both" && e.onFilterValueChange(b.textValue));
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
const [m] = o().filter((u) => u.value === e.value && u.type === "option");
|
|
322
|
+
b ? e.onValueChange(b.value) : m && f.currentTarget.value !== "" ? (e.onTextValueChange(m.textValue), e.autocomplete === "both" && e.onFilterValueChange(m.textValue)) : (e.onValueChange(void 0), e.onTextValueChange(""));
|
|
323
|
+
})
|
|
324
|
+
});
|
|
325
|
+
}), Gt = r.forwardRef((n, s) => {
|
|
326
|
+
const {
|
|
327
|
+
children: e,
|
|
328
|
+
...t
|
|
329
|
+
} = n, o = Y(ct), l = o.disabled, i = () => {
|
|
330
|
+
l || (o.onOpenChange(!0), o.trigger?.focus());
|
|
331
|
+
};
|
|
332
|
+
return /* @__PURE__ */ d(A.button, {
|
|
333
|
+
"aria-hidden": !0,
|
|
334
|
+
type: "button",
|
|
335
|
+
"aria-disabled": l,
|
|
336
|
+
"aria-controls": o.contentId,
|
|
337
|
+
"aria-expanded": o.open,
|
|
338
|
+
disabled: l,
|
|
339
|
+
"data-disabled": l ? "" : void 0,
|
|
340
|
+
...t,
|
|
341
|
+
tabIndex: -1,
|
|
342
|
+
ref: s,
|
|
343
|
+
onClick: T(t.onClick, () => {
|
|
344
|
+
o.trigger?.focus();
|
|
345
|
+
}),
|
|
346
|
+
onPointerDown: T(t.onPointerDown, (c) => {
|
|
347
|
+
c.button === 0 && c.ctrlKey === !1 && (i(), c.preventDefault());
|
|
348
|
+
}),
|
|
349
|
+
onKeyDown: T(t.onKeyDown, (c) => {
|
|
350
|
+
Ft.includes(c.key) && (i(), c.preventDefault());
|
|
351
|
+
}),
|
|
352
|
+
children: e || "\u25BC"
|
|
353
|
+
});
|
|
354
|
+
}), jt = "ComboboxPortal", it = (n) => /* @__PURE__ */ d(nt, {
|
|
355
|
+
asChild: !0,
|
|
356
|
+
...n
|
|
357
|
+
});
|
|
358
|
+
it.displayName = jt;
|
|
359
|
+
const at = "ComboboxContent", Yt = r.forwardRef((n, s) => {
|
|
360
|
+
const e = Y(at), [t, o] = r.useState();
|
|
361
|
+
if (r.useLayoutEffect(() => {
|
|
362
|
+
o(new DocumentFragment());
|
|
363
|
+
}, []), !e.open) {
|
|
364
|
+
const l = t;
|
|
365
|
+
return l ? Ae.createPortal(/* @__PURE__ */ d(me.Slot, {
|
|
366
|
+
scope: void 0,
|
|
367
|
+
children: /* @__PURE__ */ d("div", {
|
|
368
|
+
children: n.children
|
|
369
|
+
})
|
|
370
|
+
}), l) : null;
|
|
371
|
+
}
|
|
372
|
+
return /* @__PURE__ */ d(Xt, {
|
|
373
|
+
...n,
|
|
374
|
+
ref: s
|
|
375
|
+
});
|
|
376
|
+
}), qt = 10, Xt = r.forwardRef((n, s) => {
|
|
377
|
+
const {
|
|
378
|
+
onEscapeKeyDown: e,
|
|
379
|
+
onPointerDownOutside: t,
|
|
380
|
+
...o
|
|
381
|
+
} = n, l = Y(at), i = M(s, (a) => l.onContentChange(a)), {
|
|
382
|
+
onOpenChange: c
|
|
383
|
+
} = l;
|
|
384
|
+
return r.useEffect(() => {
|
|
385
|
+
const a = () => c(!1);
|
|
386
|
+
return window.addEventListener("blur", a), window.addEventListener("resize", a), () => {
|
|
387
|
+
window.removeEventListener("blur", a), window.removeEventListener("resize", a);
|
|
388
|
+
};
|
|
389
|
+
}, [c]), /* @__PURE__ */ d(lt, {
|
|
390
|
+
allowPinchZoom: !0,
|
|
391
|
+
children: /* @__PURE__ */ d(tt, {
|
|
392
|
+
asChild: !0,
|
|
393
|
+
onEscapeKeyDown: e,
|
|
394
|
+
onPointerDownOutside: t,
|
|
395
|
+
onFocusOutside: (a) => a.preventDefault(),
|
|
396
|
+
onDismiss: () => {
|
|
397
|
+
l.onOpenChange(!1), l.trigger?.focus({
|
|
398
|
+
preventScroll: !0
|
|
399
|
+
});
|
|
400
|
+
},
|
|
401
|
+
children: /* @__PURE__ */ d(Zt, {
|
|
402
|
+
role: "listbox",
|
|
403
|
+
id: l.contentId,
|
|
404
|
+
"data-state": l.open ? "open" : "closed",
|
|
405
|
+
onContextMenu: (a) => a.preventDefault(),
|
|
406
|
+
...o,
|
|
407
|
+
ref: i,
|
|
408
|
+
style: {
|
|
409
|
+
display: "flex",
|
|
410
|
+
flexDirection: "column",
|
|
411
|
+
outline: "none",
|
|
412
|
+
...o.style
|
|
413
|
+
}
|
|
414
|
+
})
|
|
415
|
+
})
|
|
416
|
+
});
|
|
417
|
+
}), Zt = r.forwardRef((n, s) => {
|
|
418
|
+
const {
|
|
419
|
+
align: e = "start",
|
|
420
|
+
collisionPadding: t = qt,
|
|
421
|
+
...o
|
|
422
|
+
} = n;
|
|
423
|
+
return /* @__PURE__ */ d(re.Content, {
|
|
424
|
+
...o,
|
|
425
|
+
ref: s,
|
|
426
|
+
align: e,
|
|
427
|
+
collisionPadding: t,
|
|
428
|
+
style: {
|
|
429
|
+
boxSizing: "border-box",
|
|
430
|
+
...o.style,
|
|
431
|
+
"--radix-combobox-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
432
|
+
"--radix-combobox-content-available-width": "var(--radix-popper-available-width)",
|
|
433
|
+
"--radix-combobox-content-available-height": "var(--radix-popper-available-height)",
|
|
434
|
+
"--radix-combobox-trigger-width": "var(--radix-popper-anchor-width)",
|
|
435
|
+
"--radix-combobox-trigger-height": "var(--radix-popper-anchor-height)"
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
}), Jt = "ComboboxViewport", Qt = r.forwardRef((n, s) => {
|
|
439
|
+
const e = Y(Jt), t = M(s, e.onViewportChange);
|
|
440
|
+
return /* @__PURE__ */ pe(_e, {
|
|
441
|
+
children: [/* @__PURE__ */ d("style", {
|
|
442
|
+
dangerouslySetInnerHTML: {
|
|
443
|
+
__html: "[data-radix-combobox-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-combobox-viewport]::-webkit-scrollbar{display:none}"
|
|
444
|
+
}
|
|
445
|
+
}), /* @__PURE__ */ d(me.Slot, {
|
|
446
|
+
scope: void 0,
|
|
447
|
+
children: /* @__PURE__ */ d(A.div, {
|
|
448
|
+
"data-radix-combobox-viewport": "",
|
|
449
|
+
role: "presentation",
|
|
450
|
+
...n,
|
|
451
|
+
ref: t,
|
|
452
|
+
style: {
|
|
453
|
+
position: "relative",
|
|
454
|
+
flex: 1,
|
|
455
|
+
overflow: "auto",
|
|
456
|
+
...n.style
|
|
457
|
+
}
|
|
458
|
+
})
|
|
459
|
+
})]
|
|
460
|
+
});
|
|
461
|
+
}), ut = "ComboboxItem", [eo, dt] = et(ut), ft = r.forwardRef((n, s) => {
|
|
462
|
+
const {
|
|
463
|
+
value: e,
|
|
464
|
+
disabled: t = !1,
|
|
465
|
+
textValue: o,
|
|
466
|
+
...l
|
|
467
|
+
} = n, i = r.useRef(null), c = M(s, i), {
|
|
468
|
+
getItems: a
|
|
469
|
+
} = xe(void 0), {
|
|
470
|
+
onTextValueChange: g,
|
|
471
|
+
textValue: f,
|
|
472
|
+
visuallyFocussedItem: b,
|
|
473
|
+
...m
|
|
474
|
+
} = Y(ut), u = oe(), [p, v] = r.useState(o ?? ""), C = r.useMemo(() => b === a().find((O) => O.ref.current === i.current)?.ref.current, [a, b]), x = m.value === e, h = () => {
|
|
475
|
+
t || (m.onValueChange(e), g(p), m.onOpenChange(!1), m.autocomplete === "both" && m.onFilterValueChange(p), m.trigger?.focus({
|
|
476
|
+
preventScroll: !0
|
|
477
|
+
}));
|
|
478
|
+
}, {
|
|
479
|
+
startsWith: w
|
|
480
|
+
} = Me(m.locale, {
|
|
481
|
+
sensitivity: "base"
|
|
482
|
+
}), _ = r.useCallback((O) => {
|
|
483
|
+
v((P) => P || (O?.textContent ?? "").trim());
|
|
484
|
+
}, []);
|
|
485
|
+
r.useEffect(() => {
|
|
486
|
+
x && f === void 0 && p !== "" && g(p);
|
|
487
|
+
}, [p, x, f, g]);
|
|
488
|
+
const E = oe();
|
|
489
|
+
return m.autocomplete === "list" && p && f && !w(p, f) || m.autocomplete === "both" && p && m.filterValue && !w(p, m.filterValue) ? null : /* @__PURE__ */ d(eo, {
|
|
490
|
+
textId: u,
|
|
491
|
+
onTextValueChange: _,
|
|
492
|
+
isSelected: x,
|
|
493
|
+
children: /* @__PURE__ */ d(me.ItemSlot, {
|
|
494
|
+
scope: void 0,
|
|
495
|
+
value: e,
|
|
496
|
+
textValue: p,
|
|
497
|
+
disabled: t,
|
|
498
|
+
type: "option",
|
|
499
|
+
children: /* @__PURE__ */ d(A.div, {
|
|
500
|
+
role: "option",
|
|
501
|
+
"aria-labelledby": u,
|
|
502
|
+
"data-highlighted": C ? "" : void 0,
|
|
503
|
+
"aria-selected": x && C,
|
|
504
|
+
"data-state": x ? "checked" : "unchecked",
|
|
505
|
+
"aria-disabled": t || void 0,
|
|
506
|
+
"data-disabled": t ? "" : void 0,
|
|
507
|
+
tabIndex: t ? void 0 : -1,
|
|
508
|
+
...l,
|
|
509
|
+
id: E,
|
|
510
|
+
ref: c,
|
|
511
|
+
onPointerUp: T(l.onPointerUp, h)
|
|
512
|
+
})
|
|
513
|
+
})
|
|
514
|
+
});
|
|
515
|
+
}), to = "ComboboxItemText", oo = r.forwardRef((n, s) => {
|
|
516
|
+
const {
|
|
517
|
+
className: e,
|
|
518
|
+
style: t,
|
|
519
|
+
...o
|
|
520
|
+
} = n, l = dt(to), i = M(s, l.onTextValueChange);
|
|
521
|
+
return /* @__PURE__ */ d(A.span, {
|
|
522
|
+
id: l.textId,
|
|
523
|
+
...o,
|
|
524
|
+
ref: i
|
|
525
|
+
});
|
|
526
|
+
}), no = "ComboboxItemIndicator", ro = r.forwardRef((n, s) => {
|
|
527
|
+
const {
|
|
528
|
+
isSelected: e
|
|
529
|
+
} = dt(no);
|
|
530
|
+
return e ? /* @__PURE__ */ d(A.span, {
|
|
531
|
+
"aria-hidden": !0,
|
|
532
|
+
...n,
|
|
533
|
+
ref: s
|
|
534
|
+
}) : null;
|
|
535
|
+
}), pt = "ComboboxNoValueFound", lo = r.forwardRef((n, s) => {
|
|
536
|
+
const {
|
|
537
|
+
textValue: e = "",
|
|
538
|
+
locale: t
|
|
539
|
+
} = Y(pt), [o, l] = r.useState([]), {
|
|
540
|
+
subscribe: i
|
|
541
|
+
} = xe(void 0), {
|
|
542
|
+
startsWith: c
|
|
543
|
+
} = Me(t, {
|
|
544
|
+
sensitivity: "base"
|
|
545
|
+
});
|
|
546
|
+
return r.useEffect(() => {
|
|
547
|
+
const a = i((g) => {
|
|
548
|
+
l(g);
|
|
549
|
+
});
|
|
550
|
+
return () => {
|
|
551
|
+
a();
|
|
552
|
+
};
|
|
553
|
+
}, [i]), o.some((a) => c(a.textValue, e)) ? null : /* @__PURE__ */ d(A.div, {
|
|
554
|
+
...n,
|
|
555
|
+
ref: s
|
|
556
|
+
});
|
|
557
|
+
}), so = r.forwardRef((n, s) => {
|
|
558
|
+
const {
|
|
559
|
+
disabled: e = !1,
|
|
560
|
+
...t
|
|
561
|
+
} = n, o = Y(pt), {
|
|
562
|
+
textValue: l,
|
|
563
|
+
visuallyFocussedItem: i
|
|
564
|
+
} = o, {
|
|
565
|
+
getItems: c,
|
|
566
|
+
subscribe: a
|
|
567
|
+
} = xe(void 0), g = r.useRef(null), [f, b] = r.useState(!1), m = M(s, g), u = r.useMemo(() => i === c().find((C) => C.ref.current === g.current)?.ref.current, [c, i]), p = oe(), v = () => {
|
|
568
|
+
!e && l && (o.onValueChange(l), o.onTextValueChange(l), o.onOpenChange(!1), o.autocomplete === "both" && o.onFilterValueChange(l), o.trigger?.focus({
|
|
569
|
+
preventScroll: !0
|
|
570
|
+
}));
|
|
571
|
+
};
|
|
572
|
+
return r.useLayoutEffect(() => {
|
|
573
|
+
const C = a((x) => {
|
|
574
|
+
b(!x.some((h) => h.textValue === l && h.type !== "create"));
|
|
575
|
+
});
|
|
576
|
+
return () => {
|
|
577
|
+
C();
|
|
578
|
+
};
|
|
579
|
+
}, [l, a]), !l || !f ? null : /* @__PURE__ */ d(me.ItemSlot, {
|
|
580
|
+
scope: void 0,
|
|
581
|
+
value: l ?? "",
|
|
582
|
+
textValue: l ?? "",
|
|
583
|
+
disabled: e,
|
|
584
|
+
type: "create",
|
|
585
|
+
children: /* @__PURE__ */ d(A.div, {
|
|
586
|
+
role: "option",
|
|
587
|
+
tabIndex: e ? void 0 : -1,
|
|
588
|
+
"aria-disabled": e || void 0,
|
|
589
|
+
"data-disabled": e ? "" : void 0,
|
|
590
|
+
"data-highlighted": u ? "" : void 0,
|
|
591
|
+
...t,
|
|
592
|
+
id: p,
|
|
593
|
+
ref: m,
|
|
594
|
+
onPointerUp: T(t.onPointerUp, v)
|
|
595
|
+
})
|
|
596
|
+
});
|
|
597
|
+
}), co = Ut, io = Wt, ao = zt, uo = Gt, fo = it, po = Yt, mo = Qt, ho = ft, go = oo, Co = ro, xo = lo, vo = so;
|
|
598
|
+
function So(n, s) {
|
|
599
|
+
const e = Math.min(n.length, s.length);
|
|
600
|
+
for (let t = 0; t < e; t++)
|
|
601
|
+
if (n[t] !== s[t])
|
|
602
|
+
return t;
|
|
603
|
+
return e;
|
|
604
|
+
}
|
|
605
|
+
const Tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
606
|
+
__proto__: null,
|
|
607
|
+
ComboboxItem: ft,
|
|
608
|
+
Root: co,
|
|
609
|
+
Trigger: io,
|
|
610
|
+
TextInput: ao,
|
|
611
|
+
Icon: uo,
|
|
612
|
+
Portal: fo,
|
|
613
|
+
Content: po,
|
|
614
|
+
Viewport: mo,
|
|
615
|
+
Item: ho,
|
|
616
|
+
ItemText: go,
|
|
617
|
+
ItemIndicator: Co,
|
|
618
|
+
NoValueFound: xo,
|
|
619
|
+
CreateItem: vo
|
|
620
|
+
}, Symbol.toStringTag, { value: "Module" })), bo = [" ", "Enter", "ArrowUp", "ArrowDown"], wo = [" ", "Enter"], he = "Select", [ve, ge, yo] = Vt(he), [ae, Io] = Qe(he, [yo, ot]), Se = ot(), [To, q] = ae(he), [Eo, Po] = ae(he), Oe = (n) => {
|
|
621
|
+
const {
|
|
622
|
+
__scopeSelect: s,
|
|
623
|
+
children: e,
|
|
624
|
+
open: t,
|
|
625
|
+
defaultOpen: o,
|
|
626
|
+
onOpenChange: l,
|
|
627
|
+
value: i,
|
|
628
|
+
defaultValue: c,
|
|
629
|
+
onValueChange: a,
|
|
630
|
+
dir: g,
|
|
631
|
+
name: f,
|
|
632
|
+
autoComplete: b,
|
|
633
|
+
disabled: m,
|
|
634
|
+
required: u,
|
|
635
|
+
multi: p = !1
|
|
636
|
+
} = n, v = Se(s), [C, x] = r.useState(null), [h, w] = r.useState(null), [_, E] = r.useState(!1), O = Rt(g), [P = !1, L] = ie({
|
|
637
|
+
prop: t,
|
|
638
|
+
defaultProp: o,
|
|
639
|
+
onChange: l
|
|
640
|
+
}), [k, H] = ie({
|
|
641
|
+
prop: i,
|
|
642
|
+
defaultProp: c,
|
|
643
|
+
onChange(V) {
|
|
644
|
+
a && (Array.isArray(V), a(V));
|
|
645
|
+
}
|
|
646
|
+
}), G = r.useRef(null), $ = C ? Boolean(C.closest("form")) : !0, [W, U] = r.useState(/* @__PURE__ */ new Set()), F = Array.from(W).map((V) => V.props.value).join(";");
|
|
647
|
+
return /* @__PURE__ */ d(re.Root, {
|
|
648
|
+
...v,
|
|
649
|
+
children: /* @__PURE__ */ pe(To, {
|
|
650
|
+
required: u,
|
|
651
|
+
scope: s,
|
|
652
|
+
trigger: C,
|
|
653
|
+
onTriggerChange: x,
|
|
654
|
+
valueNode: h,
|
|
655
|
+
onValueNodeChange: w,
|
|
656
|
+
valueNodeHasChildren: _,
|
|
657
|
+
onValueNodeHasChildrenChange: E,
|
|
658
|
+
contentId: oe(),
|
|
659
|
+
value: k,
|
|
660
|
+
onValueChange: H,
|
|
661
|
+
open: P,
|
|
662
|
+
onOpenChange: L,
|
|
663
|
+
dir: O,
|
|
664
|
+
triggerPointerDownPosRef: G,
|
|
665
|
+
disabled: m,
|
|
666
|
+
multi: p,
|
|
667
|
+
children: [/* @__PURE__ */ d(ve.Provider, {
|
|
668
|
+
scope: s,
|
|
669
|
+
children: /* @__PURE__ */ d(Eo, {
|
|
670
|
+
scope: n.__scopeSelect,
|
|
671
|
+
onNativeOptionAdd: r.useCallback((V) => {
|
|
672
|
+
U((B) => new Set(B).add(V));
|
|
673
|
+
}, []),
|
|
674
|
+
onNativeOptionRemove: r.useCallback((V) => {
|
|
675
|
+
U((B) => {
|
|
676
|
+
const K = new Set(B);
|
|
677
|
+
return K.delete(V), K;
|
|
678
|
+
});
|
|
679
|
+
}, []),
|
|
680
|
+
children: e
|
|
681
|
+
})
|
|
682
|
+
}), $ ? /* @__PURE__ */ pe(It, {
|
|
683
|
+
"aria-hidden": !0,
|
|
684
|
+
required: u,
|
|
685
|
+
tabIndex: -1,
|
|
686
|
+
name: f,
|
|
687
|
+
autoComplete: b,
|
|
688
|
+
value: k,
|
|
689
|
+
onChange: (V) => H(V.target.value),
|
|
690
|
+
disabled: m,
|
|
691
|
+
children: [k === void 0 ? /* @__PURE__ */ d("option", {
|
|
692
|
+
value: ""
|
|
693
|
+
}) : null, Array.from(W)]
|
|
694
|
+
}, F) : null]
|
|
695
|
+
})
|
|
696
|
+
});
|
|
697
|
+
};
|
|
698
|
+
Oe.displayName = he;
|
|
699
|
+
const mt = "SelectTrigger", De = r.forwardRef((n, s) => {
|
|
700
|
+
const {
|
|
701
|
+
__scopeSelect: e,
|
|
702
|
+
...t
|
|
703
|
+
} = n, o = Se(e), l = q(mt, e), i = l.disabled, c = M(s, l.onTriggerChange), a = ge(e), [g, f, b] = Tt((u) => {
|
|
704
|
+
const p = a().filter((x) => !x.disabled), v = p.find((x) => x.value === l.value), C = Et(p, u, v);
|
|
705
|
+
if (C !== void 0 && !Array.isArray(C.value)) {
|
|
706
|
+
const x = l.multi ? [C.value] : C.value;
|
|
707
|
+
l.onValueChange(x);
|
|
708
|
+
}
|
|
709
|
+
}), m = () => {
|
|
710
|
+
i || (l.onOpenChange(!0), b());
|
|
711
|
+
};
|
|
712
|
+
return /* @__PURE__ */ d(re.Anchor, {
|
|
713
|
+
asChild: !0,
|
|
714
|
+
...o,
|
|
715
|
+
children: /* @__PURE__ */ d(A.div, {
|
|
716
|
+
role: "combobox",
|
|
717
|
+
"aria-controls": l.contentId,
|
|
718
|
+
"aria-expanded": l.open,
|
|
719
|
+
"aria-required": l.required,
|
|
720
|
+
"aria-autocomplete": "none",
|
|
721
|
+
dir: l.dir,
|
|
722
|
+
"data-state": l.open ? "open" : "closed",
|
|
723
|
+
"data-disabled": i ? "" : void 0,
|
|
724
|
+
"data-placeholder": l.value === void 0 ? "" : void 0,
|
|
725
|
+
tabIndex: i ? void 0 : 0,
|
|
726
|
+
...t,
|
|
727
|
+
ref: c,
|
|
728
|
+
onClick: T(t.onClick, (u) => {
|
|
729
|
+
u.currentTarget.focus();
|
|
730
|
+
}),
|
|
731
|
+
onPointerDown: T(t.onPointerDown, (u) => {
|
|
732
|
+
const p = u.target;
|
|
733
|
+
p.hasPointerCapture(u.pointerId) && p.releasePointerCapture(u.pointerId), (p.closest("button") ?? p.closest("div")) === u.currentTarget && u.button === 0 && u.ctrlKey === !1 && (m(), l.triggerPointerDownPosRef.current = {
|
|
734
|
+
x: Math.round(u.pageX),
|
|
735
|
+
y: Math.round(u.pageY)
|
|
736
|
+
}, u.preventDefault());
|
|
737
|
+
}),
|
|
738
|
+
onKeyDown: T(t.onKeyDown, (u) => {
|
|
739
|
+
const p = g.current !== "", v = u.ctrlKey || u.altKey || u.metaKey, C = u.target;
|
|
740
|
+
(C.closest("button") ?? C.closest("div")) === u.currentTarget && (!v && u.key.length === 1 && f(u.key), !(p && u.key === " ") && bo.includes(u.key) && (m(), u.preventDefault()));
|
|
741
|
+
})
|
|
742
|
+
})
|
|
743
|
+
});
|
|
744
|
+
});
|
|
745
|
+
De.displayName = mt;
|
|
746
|
+
const ht = "SelectValue", Le = r.forwardRef((n, s) => {
|
|
747
|
+
const {
|
|
748
|
+
__scopeSelect: e,
|
|
749
|
+
children: t,
|
|
750
|
+
placeholder: o,
|
|
751
|
+
...l
|
|
752
|
+
} = n, i = q(ht, e), {
|
|
753
|
+
onValueNodeHasChildrenChange: c
|
|
754
|
+
} = i, a = t !== void 0, g = M(s, i.onValueNodeChange), [f, b] = r.useState([]), m = ge(e);
|
|
755
|
+
Z(() => {
|
|
756
|
+
c(a);
|
|
757
|
+
}, [c, a]), r.useLayoutEffect(() => {
|
|
758
|
+
if (Array.isArray(i.value) && f.length !== i.value.length) {
|
|
759
|
+
const p = setTimeout(() => {
|
|
760
|
+
const v = m().filter((C) => Array.isArray(C.value) ? !1 : i.value?.includes(C.value));
|
|
761
|
+
b(v);
|
|
762
|
+
});
|
|
763
|
+
return () => {
|
|
764
|
+
clearTimeout(p);
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
}, [i.value, m, f]);
|
|
768
|
+
let u = t;
|
|
769
|
+
if ((i.value === void 0 || i.value.length === 0) && o !== void 0)
|
|
770
|
+
u = o;
|
|
771
|
+
else if (typeof t == "function")
|
|
772
|
+
if (Array.isArray(i.value)) {
|
|
773
|
+
const p = i.value.map((v) => {
|
|
774
|
+
const C = f.find((x) => x.value === v);
|
|
775
|
+
return C ? t({
|
|
776
|
+
value: v,
|
|
777
|
+
textValue: C?.textValue
|
|
778
|
+
}) : null;
|
|
779
|
+
});
|
|
780
|
+
u = p.every((v) => v === null) ? o : p;
|
|
781
|
+
} else
|
|
782
|
+
u = t(i.value);
|
|
783
|
+
return /* @__PURE__ */ d(A.span, {
|
|
784
|
+
...l,
|
|
785
|
+
ref: g,
|
|
786
|
+
children: u
|
|
787
|
+
});
|
|
788
|
+
});
|
|
789
|
+
Le.displayName = ht;
|
|
790
|
+
const Vo = "SelectIcon", ke = r.forwardRef((n, s) => {
|
|
791
|
+
const {
|
|
792
|
+
__scopeSelect: e,
|
|
793
|
+
children: t,
|
|
794
|
+
...o
|
|
795
|
+
} = n;
|
|
796
|
+
return /* @__PURE__ */ d(A.span, {
|
|
797
|
+
"aria-hidden": !0,
|
|
798
|
+
...o,
|
|
799
|
+
ref: s,
|
|
800
|
+
children: t || "\u25BC"
|
|
801
|
+
});
|
|
802
|
+
});
|
|
803
|
+
ke.displayName = Vo;
|
|
804
|
+
const Ro = "SelectPortal", Fe = (n) => /* @__PURE__ */ d(nt, {
|
|
805
|
+
asChild: !0,
|
|
806
|
+
...n
|
|
807
|
+
});
|
|
808
|
+
Fe.displayName = Ro;
|
|
809
|
+
const ne = "SelectContent", Be = r.forwardRef((n, s) => {
|
|
810
|
+
const e = q(ne, n.__scopeSelect), [t, o] = r.useState();
|
|
811
|
+
if (Z(() => {
|
|
812
|
+
o(new DocumentFragment());
|
|
813
|
+
}, []), !e.open) {
|
|
814
|
+
const l = t;
|
|
815
|
+
return l ? Ae.createPortal(/* @__PURE__ */ d(gt, {
|
|
816
|
+
scope: n.__scopeSelect,
|
|
817
|
+
children: /* @__PURE__ */ d(ve.Slot, {
|
|
818
|
+
scope: n.__scopeSelect,
|
|
819
|
+
children: /* @__PURE__ */ d("div", {
|
|
820
|
+
children: n.children
|
|
821
|
+
})
|
|
822
|
+
})
|
|
823
|
+
}), l) : null;
|
|
824
|
+
}
|
|
825
|
+
return /* @__PURE__ */ d(Ct, {
|
|
826
|
+
...n,
|
|
827
|
+
ref: s
|
|
828
|
+
});
|
|
829
|
+
});
|
|
830
|
+
Be.displayName = ne;
|
|
831
|
+
const j = 10, [gt, J] = ae(ne), No = "SelectContentImpl", Ct = r.forwardRef((n, s) => {
|
|
832
|
+
const {
|
|
833
|
+
__scopeSelect: e,
|
|
834
|
+
position: t = "item-aligned",
|
|
835
|
+
onCloseAutoFocus: o,
|
|
836
|
+
onEscapeKeyDown: l,
|
|
837
|
+
onPointerDownOutside: i,
|
|
838
|
+
side: c,
|
|
839
|
+
sideOffset: a,
|
|
840
|
+
align: g,
|
|
841
|
+
alignOffset: f,
|
|
842
|
+
arrowPadding: b,
|
|
843
|
+
collisionBoundary: m,
|
|
844
|
+
collisionPadding: u,
|
|
845
|
+
sticky: p,
|
|
846
|
+
hideWhenDetached: v,
|
|
847
|
+
avoidCollisions: C,
|
|
848
|
+
...x
|
|
849
|
+
} = n, h = q(ne, e), [w, _] = r.useState(null), [E, O] = r.useState(null), P = M(s, (S) => _(S)), [L, k] = r.useState(null), [H, G] = r.useState(null), $ = ge(e), [W, U] = r.useState(!1), F = r.useRef(!1);
|
|
850
|
+
r.useEffect(() => {
|
|
851
|
+
if (w)
|
|
852
|
+
return rt(w);
|
|
853
|
+
}, [w]), Nt();
|
|
854
|
+
const V = r.useCallback((S) => {
|
|
855
|
+
const [y, ...D] = $().map((N) => N.ref.current), [I] = D.slice(-1), R = document.activeElement;
|
|
856
|
+
for (const N of S)
|
|
857
|
+
if (N === R || (N?.scrollIntoView({
|
|
858
|
+
block: "nearest"
|
|
859
|
+
}), N === y && E && (E.scrollTop = 0), N === I && E && (E.scrollTop = E.scrollHeight), N?.focus(), document.activeElement !== R))
|
|
860
|
+
return;
|
|
861
|
+
}, [$, E]), B = r.useCallback(() => V([L, w]), [V, L, w]);
|
|
862
|
+
r.useEffect(() => {
|
|
863
|
+
W && B();
|
|
864
|
+
}, [W, B]);
|
|
865
|
+
const {
|
|
866
|
+
onOpenChange: K,
|
|
867
|
+
triggerPointerDownPosRef: z
|
|
868
|
+
} = h;
|
|
869
|
+
r.useEffect(() => {
|
|
870
|
+
if (w) {
|
|
871
|
+
let S = {
|
|
872
|
+
x: 0,
|
|
873
|
+
y: 0
|
|
874
|
+
};
|
|
875
|
+
const y = (I) => {
|
|
876
|
+
S = {
|
|
877
|
+
x: Math.abs(Math.round(I.pageX) - (z.current?.x ?? 0)),
|
|
878
|
+
y: Math.abs(Math.round(I.pageY) - (z.current?.y ?? 0))
|
|
879
|
+
};
|
|
880
|
+
}, D = (I) => {
|
|
881
|
+
S.x <= 10 && S.y <= 10 ? I.preventDefault() : w.contains(I.target) || K(!1), document.removeEventListener("pointermove", y), z.current = null;
|
|
882
|
+
};
|
|
883
|
+
return z.current !== null && (document.addEventListener("pointermove", y), document.addEventListener("pointerup", D, {
|
|
884
|
+
capture: !0,
|
|
885
|
+
once: !0
|
|
886
|
+
})), () => {
|
|
887
|
+
document.removeEventListener("pointermove", y), document.removeEventListener("pointerup", D, {
|
|
888
|
+
capture: !0
|
|
889
|
+
});
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
}, [w, K, z]), r.useEffect(() => {
|
|
893
|
+
const S = () => K(!1);
|
|
894
|
+
return window.addEventListener("blur", S), window.addEventListener("resize", S), () => {
|
|
895
|
+
window.removeEventListener("blur", S), window.removeEventListener("resize", S);
|
|
896
|
+
};
|
|
897
|
+
}, [K]);
|
|
898
|
+
const [ue, le] = Tt((S) => {
|
|
899
|
+
const y = $().filter((R) => !R.disabled), D = y.find((R) => R.ref.current === document.activeElement), I = Et(y, S, D);
|
|
900
|
+
I && setTimeout(() => I.ref.current.focus());
|
|
901
|
+
}), se = r.useCallback((S, y, D) => {
|
|
902
|
+
const I = !F.current && !D;
|
|
903
|
+
(h.value !== void 0 && h.value === y || I) && (k(S), I && (F.current = !0));
|
|
904
|
+
}, [h.value]), de = r.useCallback(() => w?.focus(), [w]), X = r.useCallback((S, y, D) => {
|
|
905
|
+
const I = !F.current && !D;
|
|
906
|
+
(h.value !== void 0 && (Array.isArray(y) ? y.every((N) => h.value?.includes(N)) : h.value === y) || I) && G(S);
|
|
907
|
+
}, [h.value]), ce = t === "popper" ? Ee : xt, Q = ce === Ee ? {
|
|
908
|
+
side: c,
|
|
909
|
+
sideOffset: a,
|
|
910
|
+
align: g,
|
|
911
|
+
alignOffset: f,
|
|
912
|
+
arrowPadding: b,
|
|
913
|
+
collisionBoundary: m,
|
|
914
|
+
collisionPadding: u,
|
|
915
|
+
sticky: p,
|
|
916
|
+
hideWhenDetached: v,
|
|
917
|
+
avoidCollisions: C
|
|
918
|
+
} : {};
|
|
919
|
+
return /* @__PURE__ */ d(gt, {
|
|
920
|
+
scope: e,
|
|
921
|
+
content: w,
|
|
922
|
+
viewport: E,
|
|
923
|
+
onViewportChange: O,
|
|
924
|
+
itemRefCallback: se,
|
|
925
|
+
selectedItem: L,
|
|
926
|
+
onItemLeave: de,
|
|
927
|
+
itemTextRefCallback: X,
|
|
928
|
+
focusSelectedItem: B,
|
|
929
|
+
selectedItemText: H,
|
|
930
|
+
position: t,
|
|
931
|
+
isPositioned: W,
|
|
932
|
+
searchRef: ue,
|
|
933
|
+
children: /* @__PURE__ */ d(lt, {
|
|
934
|
+
as: Te,
|
|
935
|
+
allowPinchZoom: !0,
|
|
936
|
+
children: /* @__PURE__ */ d(At, {
|
|
937
|
+
asChild: !0,
|
|
938
|
+
trapped: h.open,
|
|
939
|
+
onMountAutoFocus: (S) => {
|
|
940
|
+
S.preventDefault();
|
|
941
|
+
},
|
|
942
|
+
onUnmountAutoFocus: T(o, (S) => {
|
|
943
|
+
h.trigger?.focus({
|
|
944
|
+
preventScroll: !0
|
|
945
|
+
}), S.preventDefault();
|
|
946
|
+
}),
|
|
947
|
+
children: /* @__PURE__ */ d(tt, {
|
|
948
|
+
asChild: !0,
|
|
949
|
+
disableOutsidePointerEvents: !0,
|
|
950
|
+
onEscapeKeyDown: l,
|
|
951
|
+
onPointerDownOutside: i,
|
|
952
|
+
onFocusOutside: (S) => S.preventDefault(),
|
|
953
|
+
onDismiss: () => h.onOpenChange(!1),
|
|
954
|
+
children: /* @__PURE__ */ d(ce, {
|
|
955
|
+
role: "listbox",
|
|
956
|
+
id: h.contentId,
|
|
957
|
+
"data-state": h.open ? "open" : "closed",
|
|
958
|
+
"aria-multiselectable": h.multi ? "true" : void 0,
|
|
959
|
+
dir: h.dir,
|
|
960
|
+
onContextMenu: (S) => S.preventDefault(),
|
|
961
|
+
...x,
|
|
962
|
+
...Q,
|
|
963
|
+
onPlaced: () => U(!0),
|
|
964
|
+
ref: P,
|
|
965
|
+
style: {
|
|
966
|
+
display: "flex",
|
|
967
|
+
flexDirection: "column",
|
|
968
|
+
outline: "none",
|
|
969
|
+
...x.style
|
|
970
|
+
},
|
|
971
|
+
onKeyDown: T(x.onKeyDown, (S) => {
|
|
972
|
+
const y = S.ctrlKey || S.altKey || S.metaKey;
|
|
973
|
+
if (S.key === "Tab" && S.preventDefault(), !y && S.key.length === 1 && le(S.key), ["ArrowUp", "ArrowDown", "Home", "End"].includes(S.key)) {
|
|
974
|
+
let I = $().filter((R) => !R.disabled).map((R) => R.ref.current);
|
|
975
|
+
if (["ArrowUp", "End"].includes(S.key) && (I = I.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(S.key)) {
|
|
976
|
+
const R = S.target, N = I.indexOf(R);
|
|
977
|
+
I = I.slice(N + 1);
|
|
978
|
+
}
|
|
979
|
+
setTimeout(() => V(I)), S.preventDefault();
|
|
980
|
+
}
|
|
981
|
+
})
|
|
982
|
+
})
|
|
983
|
+
})
|
|
984
|
+
})
|
|
985
|
+
})
|
|
986
|
+
});
|
|
987
|
+
});
|
|
988
|
+
Ct.displayName = No;
|
|
989
|
+
const Ao = "SelectItemAlignedPosition", xt = r.forwardRef((n, s) => {
|
|
990
|
+
const {
|
|
991
|
+
__scopeSelect: e,
|
|
992
|
+
onPlaced: t,
|
|
993
|
+
...o
|
|
994
|
+
} = n, l = q(ne, e), i = J(ne, e), [c, a] = r.useState(null), [g, f] = r.useState(null), b = M(s, (P) => f(P)), m = ge(e), u = r.useRef(!1), p = r.useRef(!0), {
|
|
995
|
+
viewport: v,
|
|
996
|
+
selectedItem: C,
|
|
997
|
+
selectedItemText: x,
|
|
998
|
+
focusSelectedItem: h
|
|
999
|
+
} = i, w = r.useCallback(() => {
|
|
1000
|
+
if (l.trigger && l.valueNode && c && g && v && C && x) {
|
|
1001
|
+
const P = l.trigger.getBoundingClientRect(), L = g.getBoundingClientRect(), k = l.valueNode.getBoundingClientRect(), H = x.getBoundingClientRect();
|
|
1002
|
+
if (l.dir !== "rtl") {
|
|
1003
|
+
const R = H.left - L.left, N = k.left - R, ee = P.left - N, te = P.width + ee, be = Math.max(te, L.width), we = window.innerWidth - j, ye = Ze(N, [j, we - be]);
|
|
1004
|
+
c.style.minWidth = `${te}px`, c.style.left = `${ye}px`;
|
|
1005
|
+
} else {
|
|
1006
|
+
const R = L.right - H.right, N = window.innerWidth - k.right - R, ee = window.innerWidth - P.right - N, te = P.width + ee, be = Math.max(te, L.width), we = window.innerWidth - j, ye = Ze(N, [j, we - be]);
|
|
1007
|
+
c.style.minWidth = `${te}px`, c.style.right = `${ye}px`;
|
|
1008
|
+
}
|
|
1009
|
+
const G = m(), $ = window.innerHeight - j * 2, W = v.scrollHeight, U = window.getComputedStyle(g), F = parseInt(U.borderTopWidth, 10), V = parseInt(U.paddingTop, 10), B = parseInt(U.borderBottomWidth, 10), K = parseInt(U.paddingBottom, 10), z = F + V + W + K + B, ue = Math.min(C.offsetHeight * 5, z), le = window.getComputedStyle(v), se = parseInt(le.paddingTop, 10), de = parseInt(le.paddingBottom, 10), X = P.top + P.height / 2 - j, ce = $ - X, Q = C.offsetHeight / 2, S = C.offsetTop + Q, y = F + V + S, D = z - y;
|
|
1010
|
+
if (y <= X) {
|
|
1011
|
+
const R = C === G[G.length - 1].ref.current;
|
|
1012
|
+
c.style.bottom = `${0}px`;
|
|
1013
|
+
const N = g.clientHeight - v.offsetTop - v.offsetHeight, ee = Math.max(ce, Q + (R ? de : 0) + N + B), te = y + ee;
|
|
1014
|
+
c.style.height = `${te}px`;
|
|
1015
|
+
} else {
|
|
1016
|
+
const R = C === G[0].ref.current;
|
|
1017
|
+
c.style.top = `${0}px`;
|
|
1018
|
+
const ee = Math.max(X, F + v.offsetTop + (R ? se : 0) + Q) + D;
|
|
1019
|
+
c.style.height = `${ee}px`, v.scrollTop = y - X + v.offsetTop;
|
|
1020
|
+
}
|
|
1021
|
+
c.style.margin = `${j}px 0`, c.style.minHeight = `${ue}px`, c.style.maxHeight = `${$}px`, t?.(), requestAnimationFrame(() => u.current = !0);
|
|
1022
|
+
}
|
|
1023
|
+
}, [m, l.trigger, l.valueNode, c, g, v, C, x, l.dir, t]);
|
|
1024
|
+
Z(() => w(), [w]);
|
|
1025
|
+
const [_, E] = r.useState();
|
|
1026
|
+
Z(() => {
|
|
1027
|
+
g && E(window.getComputedStyle(g).zIndex);
|
|
1028
|
+
}, [g]);
|
|
1029
|
+
const O = r.useCallback((P) => {
|
|
1030
|
+
P && p.current === !0 && (w(), h?.(), p.current = !1);
|
|
1031
|
+
}, [w, h]);
|
|
1032
|
+
return /* @__PURE__ */ d(Mo, {
|
|
1033
|
+
scope: e,
|
|
1034
|
+
contentWrapper: c,
|
|
1035
|
+
shouldExpandOnScrollRef: u,
|
|
1036
|
+
onScrollButtonChange: O,
|
|
1037
|
+
children: /* @__PURE__ */ d("div", {
|
|
1038
|
+
ref: a,
|
|
1039
|
+
style: {
|
|
1040
|
+
display: "flex",
|
|
1041
|
+
flexDirection: "column",
|
|
1042
|
+
position: "fixed",
|
|
1043
|
+
zIndex: _
|
|
1044
|
+
},
|
|
1045
|
+
children: /* @__PURE__ */ d(A.div, {
|
|
1046
|
+
...o,
|
|
1047
|
+
ref: b,
|
|
1048
|
+
style: {
|
|
1049
|
+
boxSizing: "border-box",
|
|
1050
|
+
maxHeight: "100%",
|
|
1051
|
+
...o.style
|
|
1052
|
+
}
|
|
1053
|
+
})
|
|
1054
|
+
})
|
|
1055
|
+
});
|
|
1056
|
+
});
|
|
1057
|
+
xt.displayName = Ao;
|
|
1058
|
+
const _o = "SelectPopperPosition", Ee = r.forwardRef((n, s) => {
|
|
1059
|
+
const {
|
|
1060
|
+
__scopeSelect: e,
|
|
1061
|
+
align: t = "start",
|
|
1062
|
+
collisionPadding: o = j,
|
|
1063
|
+
...l
|
|
1064
|
+
} = n, i = Se(e);
|
|
1065
|
+
return /* @__PURE__ */ d(re.Content, {
|
|
1066
|
+
...i,
|
|
1067
|
+
...l,
|
|
1068
|
+
ref: s,
|
|
1069
|
+
align: t,
|
|
1070
|
+
collisionPadding: o,
|
|
1071
|
+
style: {
|
|
1072
|
+
boxSizing: "border-box",
|
|
1073
|
+
...l.style,
|
|
1074
|
+
"--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
1075
|
+
"--radix-select-content-available-width": "var(--radix-popper-available-width)",
|
|
1076
|
+
"--radix-select-content-available-height": "var(--radix-popper-available-height)",
|
|
1077
|
+
"--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
|
|
1078
|
+
"--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
|
|
1079
|
+
}
|
|
1080
|
+
});
|
|
1081
|
+
});
|
|
1082
|
+
Ee.displayName = _o;
|
|
1083
|
+
const [Mo, He] = ae(ne, {}), Pe = "SelectViewport", $e = r.forwardRef((n, s) => {
|
|
1084
|
+
const {
|
|
1085
|
+
__scopeSelect: e,
|
|
1086
|
+
...t
|
|
1087
|
+
} = n, o = J(Pe, e), l = He(Pe, e), i = M(s, o.onViewportChange), c = r.useRef(0);
|
|
1088
|
+
return /* @__PURE__ */ pe(_e, {
|
|
1089
|
+
children: [/* @__PURE__ */ d("style", {
|
|
1090
|
+
dangerouslySetInnerHTML: {
|
|
1091
|
+
__html: "[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"
|
|
1092
|
+
}
|
|
1093
|
+
}), /* @__PURE__ */ d(ve.Slot, {
|
|
1094
|
+
scope: e,
|
|
1095
|
+
children: /* @__PURE__ */ d(A.div, {
|
|
1096
|
+
"data-radix-select-viewport": "",
|
|
1097
|
+
role: "presentation",
|
|
1098
|
+
...t,
|
|
1099
|
+
ref: i,
|
|
1100
|
+
style: {
|
|
1101
|
+
position: "relative",
|
|
1102
|
+
flex: 1,
|
|
1103
|
+
overflow: "auto",
|
|
1104
|
+
...t.style
|
|
1105
|
+
},
|
|
1106
|
+
onScroll: T(t.onScroll, (a) => {
|
|
1107
|
+
const g = a.currentTarget, {
|
|
1108
|
+
contentWrapper: f,
|
|
1109
|
+
shouldExpandOnScrollRef: b
|
|
1110
|
+
} = l;
|
|
1111
|
+
if (b?.current && f) {
|
|
1112
|
+
const m = Math.abs(c.current - g.scrollTop);
|
|
1113
|
+
if (m > 0) {
|
|
1114
|
+
const u = window.innerHeight - j * 2, p = parseFloat(f.style.minHeight), v = parseFloat(f.style.height), C = Math.max(p, v);
|
|
1115
|
+
if (C < u) {
|
|
1116
|
+
const x = C + m, h = Math.min(u, x), w = x - h;
|
|
1117
|
+
f.style.height = `${h}px`, f.style.bottom === "0px" && (g.scrollTop = w > 0 ? w : 0, f.style.justifyContent = "flex-end");
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
c.current = g.scrollTop;
|
|
1122
|
+
})
|
|
1123
|
+
})
|
|
1124
|
+
})]
|
|
1125
|
+
});
|
|
1126
|
+
});
|
|
1127
|
+
$e.displayName = Pe;
|
|
1128
|
+
const vt = "SelectGroup", [Oo, Do] = ae(vt), Ue = r.forwardRef((n, s) => {
|
|
1129
|
+
const {
|
|
1130
|
+
__scopeSelect: e,
|
|
1131
|
+
...t
|
|
1132
|
+
} = n, o = oe();
|
|
1133
|
+
return /* @__PURE__ */ d(Oo, {
|
|
1134
|
+
scope: e,
|
|
1135
|
+
id: o,
|
|
1136
|
+
children: /* @__PURE__ */ d(A.div, {
|
|
1137
|
+
role: "group",
|
|
1138
|
+
"aria-labelledby": o,
|
|
1139
|
+
...t,
|
|
1140
|
+
ref: s
|
|
1141
|
+
})
|
|
1142
|
+
});
|
|
1143
|
+
});
|
|
1144
|
+
Ue.displayName = vt;
|
|
1145
|
+
const St = "SelectLabel", Ke = r.forwardRef((n, s) => {
|
|
1146
|
+
const {
|
|
1147
|
+
__scopeSelect: e,
|
|
1148
|
+
...t
|
|
1149
|
+
} = n, o = Do(St, e);
|
|
1150
|
+
return /* @__PURE__ */ d(A.div, {
|
|
1151
|
+
id: o.id,
|
|
1152
|
+
...t,
|
|
1153
|
+
ref: s
|
|
1154
|
+
});
|
|
1155
|
+
});
|
|
1156
|
+
Ke.displayName = St;
|
|
1157
|
+
const Ce = "SelectItem", [Lo, bt] = ae(Ce), We = r.forwardRef((n, s) => {
|
|
1158
|
+
const {
|
|
1159
|
+
__scopeSelect: e,
|
|
1160
|
+
value: t,
|
|
1161
|
+
disabled: o = !1,
|
|
1162
|
+
textValue: l,
|
|
1163
|
+
...i
|
|
1164
|
+
} = n, c = q(Ce, e), a = J(Ce, e), g = typeof t == "string" ? Array.isArray(c.value) ? c.value.includes(t) : c.value === t : t.every((h) => c.value?.includes(h)), f = Array.isArray(c.value) && Array.isArray(t) && t.some((h) => c.value?.includes(h)), [b, m] = r.useState(l ?? ""), [u, p] = r.useState(!1), v = M(s, (h) => a.itemRefCallback?.(h, t, o)), C = oe(), x = () => {
|
|
1165
|
+
if (!o) {
|
|
1166
|
+
let h = c.multi && typeof t == "string" ? [t] : t;
|
|
1167
|
+
f && !g ? c.onValueChange(h) : Array.isArray(c.value) && (h = Pt(t, c.value)), c.onValueChange(h), c.multi || c.onOpenChange(!1);
|
|
1168
|
+
}
|
|
1169
|
+
};
|
|
1170
|
+
if (!c.multi && Array.isArray(t))
|
|
1171
|
+
throw new Error("You can only pass an array of values in multi selects");
|
|
1172
|
+
return /* @__PURE__ */ d(Lo, {
|
|
1173
|
+
scope: e,
|
|
1174
|
+
value: t,
|
|
1175
|
+
disabled: o,
|
|
1176
|
+
textId: C,
|
|
1177
|
+
isSelected: g,
|
|
1178
|
+
isIntermediate: f,
|
|
1179
|
+
onItemTextChange: r.useCallback((h) => {
|
|
1180
|
+
m((w) => w || (h?.textContent ?? "").trim());
|
|
1181
|
+
}, []),
|
|
1182
|
+
children: /* @__PURE__ */ d(ve.ItemSlot, {
|
|
1183
|
+
scope: e,
|
|
1184
|
+
value: t,
|
|
1185
|
+
disabled: o,
|
|
1186
|
+
textValue: b,
|
|
1187
|
+
children: /* @__PURE__ */ d(A.div, {
|
|
1188
|
+
role: "option",
|
|
1189
|
+
"aria-labelledby": C,
|
|
1190
|
+
"data-highlighted": u ? "" : void 0,
|
|
1191
|
+
"aria-selected": c.multi ? void 0 : g && u,
|
|
1192
|
+
"aria-checked": c.multi ? g : void 0,
|
|
1193
|
+
"data-state": g ? "checked" : "unchecked",
|
|
1194
|
+
"aria-disabled": o || void 0,
|
|
1195
|
+
"data-disabled": o ? "" : void 0,
|
|
1196
|
+
tabIndex: o ? void 0 : -1,
|
|
1197
|
+
...i,
|
|
1198
|
+
ref: v,
|
|
1199
|
+
onFocus: T(i.onFocus, () => p(!0)),
|
|
1200
|
+
onBlur: T(i.onBlur, () => p(!1)),
|
|
1201
|
+
onPointerUp: T(i.onPointerUp, x),
|
|
1202
|
+
onPointerMove: T(i.onPointerMove, (h) => {
|
|
1203
|
+
o ? a.onItemLeave?.() : h.currentTarget.focus({
|
|
1204
|
+
preventScroll: !0
|
|
1205
|
+
});
|
|
1206
|
+
}),
|
|
1207
|
+
onPointerLeave: T(i.onPointerLeave, (h) => {
|
|
1208
|
+
h.currentTarget === document.activeElement && a.onItemLeave?.();
|
|
1209
|
+
}),
|
|
1210
|
+
onKeyDown: T(i.onKeyDown, (h) => {
|
|
1211
|
+
a.searchRef?.current !== "" && h.key === " " || (wo.includes(h.key) && x(), h.key === " " && h.preventDefault());
|
|
1212
|
+
})
|
|
1213
|
+
})
|
|
1214
|
+
})
|
|
1215
|
+
});
|
|
1216
|
+
});
|
|
1217
|
+
We.displayName = Ce;
|
|
1218
|
+
const fe = "SelectItemText", ze = r.forwardRef((n, s) => {
|
|
1219
|
+
const {
|
|
1220
|
+
__scopeSelect: e,
|
|
1221
|
+
className: t,
|
|
1222
|
+
style: o,
|
|
1223
|
+
...l
|
|
1224
|
+
} = n, i = q(fe, e), c = J(fe, e), a = bt(fe, e), g = Po(fe, e), [f, b] = r.useState(null), m = M(s, (x) => b(x), a.onItemTextChange, (x) => c.itemTextRefCallback?.(x, a.value, a.disabled)), u = f?.textContent, p = r.useMemo(() => /* @__PURE__ */ d("option", {
|
|
1225
|
+
value: a.value,
|
|
1226
|
+
disabled: a.disabled,
|
|
1227
|
+
children: u
|
|
1228
|
+
}, Array.isArray(a.value) ? a.value.join(";") : a.value), [a.disabled, a.value, u]), {
|
|
1229
|
+
onNativeOptionAdd: v,
|
|
1230
|
+
onNativeOptionRemove: C
|
|
1231
|
+
} = g;
|
|
1232
|
+
return Z(() => (v(p), () => C(p)), [v, C, p]), /* @__PURE__ */ pe(_e, {
|
|
1233
|
+
children: [/* @__PURE__ */ d(A.span, {
|
|
1234
|
+
id: a.textId,
|
|
1235
|
+
...l,
|
|
1236
|
+
ref: m
|
|
1237
|
+
}), a.isSelected && i.valueNode && !i.valueNodeHasChildren ? Ae.createPortal(l.children, i.valueNode) : null]
|
|
1238
|
+
});
|
|
1239
|
+
});
|
|
1240
|
+
ze.displayName = fe;
|
|
1241
|
+
const wt = "SelectItemIndicator", Ge = r.forwardRef((n, s) => {
|
|
1242
|
+
const {
|
|
1243
|
+
__scopeSelect: e,
|
|
1244
|
+
...t
|
|
1245
|
+
} = n, o = bt(wt, e);
|
|
1246
|
+
return typeof n.children == "function" ? /* @__PURE__ */ d(A.span, {
|
|
1247
|
+
"aria-hidden": !0,
|
|
1248
|
+
...t,
|
|
1249
|
+
ref: s,
|
|
1250
|
+
children: n.children({
|
|
1251
|
+
isSelected: o.isSelected,
|
|
1252
|
+
isIntermediate: o.isIntermediate
|
|
1253
|
+
})
|
|
1254
|
+
}) : o.isSelected ? /* @__PURE__ */ d(A.span, {
|
|
1255
|
+
"aria-hidden": !0,
|
|
1256
|
+
...t,
|
|
1257
|
+
ref: s
|
|
1258
|
+
}) : null;
|
|
1259
|
+
});
|
|
1260
|
+
Ge.displayName = wt;
|
|
1261
|
+
const Ve = "SelectScrollUpButton", je = r.forwardRef((n, s) => {
|
|
1262
|
+
const e = J(Ve, n.__scopeSelect), t = He(Ve, n.__scopeSelect), [o, l] = r.useState(!1), i = M(s, t.onScrollButtonChange);
|
|
1263
|
+
return Z(() => {
|
|
1264
|
+
if (e.viewport && e.isPositioned) {
|
|
1265
|
+
const c = e.viewport, a = () => {
|
|
1266
|
+
const g = c.scrollTop > 0;
|
|
1267
|
+
l(g);
|
|
1268
|
+
};
|
|
1269
|
+
return a(), c.addEventListener("scroll", a), () => c.removeEventListener("scroll", a);
|
|
1270
|
+
}
|
|
1271
|
+
}, [e.viewport, e.isPositioned]), o ? /* @__PURE__ */ d(yt, {
|
|
1272
|
+
...n,
|
|
1273
|
+
ref: i,
|
|
1274
|
+
onAutoScroll: () => {
|
|
1275
|
+
const {
|
|
1276
|
+
viewport: c,
|
|
1277
|
+
selectedItem: a
|
|
1278
|
+
} = e;
|
|
1279
|
+
c && a && (c.scrollTop -= a.offsetHeight);
|
|
1280
|
+
}
|
|
1281
|
+
}) : null;
|
|
1282
|
+
});
|
|
1283
|
+
je.displayName = Ve;
|
|
1284
|
+
const Re = "SelectScrollDownButton", Ye = r.forwardRef((n, s) => {
|
|
1285
|
+
const e = J(Re, n.__scopeSelect), t = He(Re, n.__scopeSelect), [o, l] = r.useState(!1), i = M(s, t.onScrollButtonChange);
|
|
1286
|
+
return Z(() => {
|
|
1287
|
+
if (e.viewport && e.isPositioned) {
|
|
1288
|
+
const c = e.viewport, a = () => {
|
|
1289
|
+
const g = c.scrollHeight - c.clientHeight, f = Math.ceil(c.scrollTop) < g;
|
|
1290
|
+
l(f);
|
|
1291
|
+
};
|
|
1292
|
+
return a(), c.addEventListener("scroll", a), () => c.removeEventListener("scroll", a);
|
|
1293
|
+
}
|
|
1294
|
+
}, [e.viewport, e.isPositioned]), o ? /* @__PURE__ */ d(yt, {
|
|
1295
|
+
...n,
|
|
1296
|
+
ref: i,
|
|
1297
|
+
onAutoScroll: () => {
|
|
1298
|
+
const {
|
|
1299
|
+
viewport: c,
|
|
1300
|
+
selectedItem: a
|
|
1301
|
+
} = e;
|
|
1302
|
+
c && a && (c.scrollTop += a.offsetHeight);
|
|
1303
|
+
}
|
|
1304
|
+
}) : null;
|
|
1305
|
+
});
|
|
1306
|
+
Ye.displayName = Re;
|
|
1307
|
+
const yt = r.forwardRef((n, s) => {
|
|
1308
|
+
const {
|
|
1309
|
+
__scopeSelect: e,
|
|
1310
|
+
onAutoScroll: t,
|
|
1311
|
+
...o
|
|
1312
|
+
} = n, l = J("SelectScrollButton", e), i = r.useRef(null), c = ge(e), a = r.useCallback(() => {
|
|
1313
|
+
i.current !== null && (window.clearInterval(i.current), i.current = null);
|
|
1314
|
+
}, []);
|
|
1315
|
+
return r.useEffect(() => () => a(), [a]), Z(() => {
|
|
1316
|
+
c().find((f) => f.ref.current === document.activeElement)?.ref.current?.scrollIntoView({
|
|
1317
|
+
block: "nearest"
|
|
1318
|
+
});
|
|
1319
|
+
}, [c]), /* @__PURE__ */ d(A.div, {
|
|
1320
|
+
"aria-hidden": !0,
|
|
1321
|
+
...o,
|
|
1322
|
+
ref: s,
|
|
1323
|
+
style: {
|
|
1324
|
+
flexShrink: 0,
|
|
1325
|
+
...o.style
|
|
1326
|
+
},
|
|
1327
|
+
onPointerMove: T(o.onPointerMove, () => {
|
|
1328
|
+
l.onItemLeave?.(), i.current === null && (i.current = window.setInterval(t, 50));
|
|
1329
|
+
}),
|
|
1330
|
+
onPointerLeave: T(o.onPointerLeave, () => {
|
|
1331
|
+
a();
|
|
1332
|
+
})
|
|
1333
|
+
});
|
|
1334
|
+
}), ko = "SelectSeparator", qe = r.forwardRef((n, s) => {
|
|
1335
|
+
const {
|
|
1336
|
+
__scopeSelect: e,
|
|
1337
|
+
...t
|
|
1338
|
+
} = n;
|
|
1339
|
+
return /* @__PURE__ */ d(A.div, {
|
|
1340
|
+
"aria-hidden": !0,
|
|
1341
|
+
...t,
|
|
1342
|
+
ref: s
|
|
1343
|
+
});
|
|
1344
|
+
});
|
|
1345
|
+
qe.displayName = ko;
|
|
1346
|
+
const Ne = "SelectArrow", Xe = r.forwardRef((n, s) => {
|
|
1347
|
+
const {
|
|
1348
|
+
__scopeSelect: e,
|
|
1349
|
+
...t
|
|
1350
|
+
} = n, o = Se(e), l = q(Ne, e), i = J(Ne, e);
|
|
1351
|
+
return l.open && i.position === "popper" ? /* @__PURE__ */ d(re.Arrow, {
|
|
1352
|
+
...o,
|
|
1353
|
+
...t,
|
|
1354
|
+
ref: s
|
|
1355
|
+
}) : null;
|
|
1356
|
+
});
|
|
1357
|
+
Xe.displayName = Ne;
|
|
1358
|
+
const Fo = "BubbleSelect", It = r.forwardRef((n, s) => {
|
|
1359
|
+
const {
|
|
1360
|
+
value: e,
|
|
1361
|
+
...t
|
|
1362
|
+
} = n, o = r.useRef(null), l = M(s, o), i = Mt(e), c = q(Fo, void 0);
|
|
1363
|
+
r.useEffect(() => {
|
|
1364
|
+
const g = o.current, f = window.HTMLSelectElement.prototype, m = Object.getOwnPropertyDescriptor(f, "value").set;
|
|
1365
|
+
if (i !== e && m) {
|
|
1366
|
+
const u = new Event("change", {
|
|
1367
|
+
bubbles: !0
|
|
1368
|
+
});
|
|
1369
|
+
m.call(g, e), g.dispatchEvent(u);
|
|
1370
|
+
}
|
|
1371
|
+
}, [i, e]);
|
|
1372
|
+
let a = e;
|
|
1373
|
+
return c.multi && !Array.isArray(e) && (a = []), /* @__PURE__ */ d(Ot, {
|
|
1374
|
+
asChild: !0,
|
|
1375
|
+
children: /* @__PURE__ */ d("select", {
|
|
1376
|
+
...t,
|
|
1377
|
+
multiple: c.multi ? !0 : void 0,
|
|
1378
|
+
ref: l,
|
|
1379
|
+
defaultValue: a
|
|
1380
|
+
})
|
|
1381
|
+
});
|
|
1382
|
+
});
|
|
1383
|
+
It.displayName = "BubbleSelect";
|
|
1384
|
+
function Tt(n) {
|
|
1385
|
+
const s = _t(n), e = r.useRef(""), t = r.useRef(0), o = r.useCallback((i) => {
|
|
1386
|
+
const c = e.current + i;
|
|
1387
|
+
s(c), function a(g) {
|
|
1388
|
+
e.current = g, window.clearTimeout(t.current), g !== "" && (t.current = window.setTimeout(() => a(""), 1e3));
|
|
1389
|
+
}(c);
|
|
1390
|
+
}, [s]), l = r.useCallback(() => {
|
|
1391
|
+
e.current = "", window.clearTimeout(t.current);
|
|
1392
|
+
}, []);
|
|
1393
|
+
return r.useEffect(() => () => window.clearTimeout(t.current), []), [e, o, l];
|
|
1394
|
+
}
|
|
1395
|
+
function Et(n, s, e) {
|
|
1396
|
+
const o = s.length > 1 && Array.from(s).every((g) => g === s[0]) ? s[0] : s, l = e ? n.indexOf(e) : -1;
|
|
1397
|
+
let i = Bo(n, Math.max(l, 0));
|
|
1398
|
+
o.length === 1 && (i = i.filter((g) => g !== e));
|
|
1399
|
+
const a = i.find((g) => g.textValue.toLowerCase().startsWith(o.toLowerCase()));
|
|
1400
|
+
return a !== e ? a : void 0;
|
|
1401
|
+
}
|
|
1402
|
+
function Bo(n, s) {
|
|
1403
|
+
return n.map((e, t) => n[(s + t) % n.length]);
|
|
1404
|
+
}
|
|
1405
|
+
const Pt = (n, s = []) => {
|
|
1406
|
+
if (Array.isArray(n))
|
|
1407
|
+
return n.reduce((t, o) => Pt(o, t), s);
|
|
1408
|
+
const e = s.indexOf(n);
|
|
1409
|
+
return e === -1 ? [...s, n] : [...s.slice(0, e), ...s.slice(e + 1)];
|
|
1410
|
+
}, Ho = Oe, $o = De, Uo = Le, Ko = ke, Wo = Fe, zo = Be, Go = $e, jo = Ue, Yo = Ke, qo = We, Xo = ze, Zo = Ge, Jo = je, Qo = Ye, en = qe, tn = Xe, En = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1411
|
+
__proto__: null,
|
|
1412
|
+
createSelectScope: Io,
|
|
1413
|
+
Select: Oe,
|
|
1414
|
+
SelectTrigger: De,
|
|
1415
|
+
SelectValue: Le,
|
|
1416
|
+
SelectIcon: ke,
|
|
1417
|
+
SelectPortal: Fe,
|
|
1418
|
+
SelectContent: Be,
|
|
1419
|
+
SelectViewport: $e,
|
|
1420
|
+
SelectGroup: Ue,
|
|
1421
|
+
SelectLabel: Ke,
|
|
1422
|
+
SelectItem: We,
|
|
1423
|
+
SelectItemText: ze,
|
|
1424
|
+
SelectItemIndicator: Ge,
|
|
1425
|
+
SelectScrollUpButton: je,
|
|
1426
|
+
SelectScrollDownButton: Ye,
|
|
1427
|
+
SelectSeparator: qe,
|
|
1428
|
+
SelectArrow: Xe,
|
|
1429
|
+
Root: Ho,
|
|
1430
|
+
Trigger: $o,
|
|
1431
|
+
Value: Uo,
|
|
1432
|
+
Icon: Ko,
|
|
1433
|
+
Portal: Wo,
|
|
1434
|
+
Content: zo,
|
|
1435
|
+
Viewport: Go,
|
|
1436
|
+
Group: jo,
|
|
1437
|
+
Label: Yo,
|
|
1438
|
+
Item: qo,
|
|
1439
|
+
ItemText: Xo,
|
|
1440
|
+
ItemIndicator: Zo,
|
|
1441
|
+
ScrollUpButton: Jo,
|
|
1442
|
+
ScrollDownButton: Qo,
|
|
1443
|
+
Separator: en,
|
|
1444
|
+
Arrow: tn
|
|
1445
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1446
|
+
export {
|
|
1447
|
+
Tn as Combobox,
|
|
1448
|
+
En as Select
|
|
1449
|
+
};
|