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