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