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