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