@strapi/ui-primitives 1.7.0 → 1.7.1

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