@strapi/ui-primitives 0.0.0-3cf3ff39

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