@spear-ai/spectral 1.3.49 → 1.3.50

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.
Files changed (65) hide show
  1. package/dist/.js +141 -140
  2. package/dist/Alert.js +53 -48
  3. package/dist/ButtonIcon.js +9 -8
  4. package/dist/Drawer.js +74 -73
  5. package/dist/Icons/CheckmarkIcon.d.ts +3 -0
  6. package/dist/Icons/CheckmarkIcon.js +29 -0
  7. package/dist/Icons/index.d.ts +1 -0
  8. package/dist/Icons.js +80 -78
  9. package/dist/Input.d.ts +2 -0
  10. package/dist/Input.js +112 -96
  11. package/dist/Label.js +18 -8
  12. package/dist/MultiSelect/MultiSelectBase.js +102 -89
  13. package/dist/Popover.js +24 -23
  14. package/dist/Select.d.ts +22 -46
  15. package/dist/Select.js +1024 -116
  16. package/dist/Tabs/TabsBase.js +72 -73
  17. package/dist/Tabs/tabsStoryData.d.ts +11 -0
  18. package/dist/Tabs/tabsStoryData.js +79 -1
  19. package/dist/Tabs.d.ts +2 -3
  20. package/dist/Tabs.js +73 -73
  21. package/dist/Textarea.d.ts +12 -10
  22. package/dist/Textarea.js +63 -74
  23. package/dist/Tooltip.js +93 -114
  24. package/dist/components/Alert/Alert.d.ts.map +1 -1
  25. package/dist/components/Icons/CheckmarkIcon.d.ts +3 -0
  26. package/dist/components/Icons/CheckmarkIcon.d.ts.map +1 -0
  27. package/dist/components/Icons/index.d.ts +1 -0
  28. package/dist/components/Icons/index.d.ts.map +1 -1
  29. package/dist/components/Input/Input.d.ts +2 -0
  30. package/dist/components/Input/Input.d.ts.map +1 -1
  31. package/dist/components/Label/Label.d.ts.map +1 -1
  32. package/dist/components/RadioButtonGroup/RadioButtonGroup.d.ts.map +1 -1
  33. package/dist/components/Select/Select.d.ts +22 -46
  34. package/dist/components/Select/Select.d.ts.map +1 -1
  35. package/dist/components/Tabs/Tabs.d.ts +2 -3
  36. package/dist/components/Tabs/Tabs.d.ts.map +1 -1
  37. package/dist/components/Tabs/TabsBase.d.ts.map +1 -1
  38. package/dist/components/Tabs/tabsStoryData.d.ts +11 -0
  39. package/dist/components/Tabs/tabsStoryData.d.ts.map +1 -1
  40. package/dist/components/Textarea/Textarea.d.ts +12 -10
  41. package/dist/components/Textarea/Textarea.d.ts.map +1 -1
  42. package/dist/features/LabelingTools.js +3 -2
  43. package/dist/features/SensorMetadata.js +3 -2
  44. package/dist/features/SettingsPopover.js +3 -2
  45. package/dist/{index-gg2zpNk0.js → index-BDYruyoU.js} +10 -10
  46. package/dist/{index-sDEISz8i.js → index-C18a1qz_.js} +50 -50
  47. package/dist/index-CFeaEsew.js +32 -0
  48. package/dist/index-Ddc_4vXe.js +80 -0
  49. package/dist/index-DfFzqLW6.js +373 -0
  50. package/dist/index.d.ts +1 -0
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/styles/main.css +1 -1
  53. package/dist/utils/constants.d.ts +2 -0
  54. package/dist/utils/constants.d.ts.map +1 -0
  55. package/dist/utils/constants.js +4 -0
  56. package/dist/utils/formFieldUtils.d.ts +7 -9
  57. package/dist/utils/formFieldUtils.d.ts.map +1 -1
  58. package/dist/utils/formFieldUtils.js +73 -73
  59. package/package.json +2 -1
  60. package/dist/Select/SelectBase.d.ts +0 -26
  61. package/dist/Select/SelectBase.js +0 -233
  62. package/dist/chevron-down-UbkgS76q.js +0 -19
  63. package/dist/components/Select/SelectBase.d.ts +0 -26
  64. package/dist/components/Select/SelectBase.d.ts.map +0 -1
  65. package/dist/index-B7LSgz_k.js +0 -447
package/dist/Select.js CHANGED
@@ -1,136 +1,1044 @@
1
1
  "use client";
2
2
  import "./styles/main.css";
3
- import { jsx as s, jsxs as m } from "react/jsx-runtime";
4
- import { SelectBase as E } from "./Select/SelectBase.js";
5
- import { c as i } from "./twUtils-CRiPKpXj.js";
6
- import { forwardRef as o, useId as $ } from "react";
7
- import { a as k } from "./chevron-down-UbkgS76q.js";
8
- import { L as O } from "./loader-circle-CvdzOiQ_.js";
9
- const q = ({ children: e, ...t }) => /* @__PURE__ */ s("div", { ...t, children: e }), p = o(({ className: e, ...t }, a) => /* @__PURE__ */ s("div", { ref: a, className: i("text-text-secondary px-2 py-1.5 text-sm font-semibold", e), ...t }));
10
- p.displayName = "SelectGroup";
11
- const z = ({ placeholder: e, children: t }) => /* @__PURE__ */ s("span", { children: t || e }), b = o(
12
- ({ className: e, children: t, ...a }, l) => /* @__PURE__ */ s("button", { ref: l, className: e, ...a, children: t })
13
- );
14
- b.displayName = "SelectTrigger";
15
- const u = o(
16
- ({ className: e, children: t, ...a }, l) => /* @__PURE__ */ s("div", { ref: l, className: e, ...a, children: t })
17
- );
18
- u.displayName = "SelectContent";
19
- const g = o(({ className: e, ...t }, a) => /* @__PURE__ */ s("div", { ref: a, className: i("text-input-text-secondary px-2 py-1.5 text-sm font-semibold", e), ...t }));
20
- g.displayName = "SelectLabel";
21
- const y = o(
22
- ({ className: e, children: t, disabled: a, ...l }, r) => /* @__PURE__ */ m(
23
- "div",
3
+ import { jsx as s, jsxs as F, Fragment as ce } from "react/jsx-runtime";
4
+ import "./Icons/AnnotationsIcon.js";
5
+ import "./Icons/CalendarIcon.js";
6
+ import "./Icons/CheckCircleIcon.js";
7
+ import "./Icons/CheckSquareIcon.js";
8
+ import { CheckmarkIcon as dt } from "./Icons/CheckmarkIcon.js";
9
+ import { ChevronDownIcon as xe } from "./Icons/ChevronDownIcon.js";
10
+ import "./Icons/ChevronUpIcon.js";
11
+ import "./Icons/ClockIcon.js";
12
+ import "./Icons/CloseCircleIcon.js";
13
+ import "./Icons/CloseIcon.js";
14
+ import "./Icons/DashboardIcon.js";
15
+ import "./Icons/DeleteIcon.js";
16
+ import "./Icons/DurationIcon.js";
17
+ import "./Icons/EraserIcon.js";
18
+ import "./Icons/ErrorIcon.js";
19
+ import "./Icons/EyeClosedIcon.js";
20
+ import "./Icons/EyeClosedIcon2.js";
21
+ import "./Icons/EyeOpenIcon.js";
22
+ import "./Icons/GoToFirstIcon.js";
23
+ import "./Icons/GoToLastIcon.js";
24
+ import "./Icons/HarmonicCursorsIcon.js";
25
+ import "./Icons/InfoIcon.js";
26
+ import "./Icons/LabelIcon.js";
27
+ import "./Icons/LassoIcon.js";
28
+ import "./Icons/LineToolIcon.js";
29
+ import "./Icons/LiveViewIcon.js";
30
+ import { LoaderIcon as ut } from "./Icons/LoaderIcon.js";
31
+ import "./Icons/LocationIcon.js";
32
+ import "./Icons/LogoutIcon.js";
33
+ import "./Icons/MetadataIcon.js";
34
+ import "./Icons/OntologyIcon.js";
35
+ import "./Icons/PanelIcon.js";
36
+ import "./Icons/PlayIcon.js";
37
+ import "./Icons/PlusIcon.js";
38
+ import "./Icons/ResetIcon.js";
39
+ import "./Icons/ScissorsIcon.js";
40
+ import "./Icons/SettingsIcon.js";
41
+ import "./Icons/TrashIcon.js";
42
+ import "./Icons/UndoIcon.js";
43
+ import "./Icons/UserIcon.js";
44
+ import "./Icons/WarningIcon.js";
45
+ import "./Icons/ZoomAllIcon.js";
46
+ import "./Icons/ZoomXIcon.js";
47
+ import "./Icons/ZoomYIcon.js";
48
+ import { Label as pt } from "./Label.js";
49
+ import * as o from "react";
50
+ import ee, { forwardRef as mt } from "react";
51
+ import * as Ae from "react-dom";
52
+ import { c as De, b as U, f as ye, a as _e, u as Pe, P as k, d as O, g as $, i as ft, D as ht } from "./index-DfFzqLW6.js";
53
+ import { h as gt, u as vt, R as St, F as Ct } from "./index-BDYruyoU.js";
54
+ import { c as Le, R as wt, a as xt, C as yt, A as It } from "./index-C18a1qz_.js";
55
+ import { V as bt } from "./index-CFeaEsew.js";
56
+ import { useFormFieldId as Tt, useFormFieldState as Rt, getAriaProps as Nt, getErrorMessageId as Pt, groupOptions as Et, getFormFieldCSSProperties as _t, getStateClasses as Mt, getTriggerClasses as Ot, ErrorMessage as At, LoadingState as Dt, EmptyState as Lt, getOptionClasses as kt } from "./utils/formFieldUtils.js";
57
+ import { c as ue } from "./twUtils-CRiPKpXj.js";
58
+ function Me(t, [n, e]) {
59
+ return Math.min(e, Math.max(n, t));
60
+ }
61
+ function Vt(t) {
62
+ const n = t + "CollectionProvider", [e, d] = De(n), [c, p] = e(
63
+ n,
64
+ { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
65
+ ), r = (a) => {
66
+ const { scope: f, children: v } = a, u = ee.useRef(null), g = ee.useRef(/* @__PURE__ */ new Map()).current;
67
+ return /* @__PURE__ */ s(c, { scope: f, itemMap: g, collectionRef: u, children: v });
68
+ };
69
+ r.displayName = n;
70
+ const i = t + "CollectionSlot", l = ye(i), m = ee.forwardRef(
71
+ (a, f) => {
72
+ const { scope: v, children: u } = a, g = p(i, v), P = U(f, g.collectionRef);
73
+ return /* @__PURE__ */ s(l, { ref: P, children: u });
74
+ }
75
+ );
76
+ m.displayName = i;
77
+ const S = t + "CollectionItemSlot", C = "data-radix-collection-item", b = ye(S), x = ee.forwardRef(
78
+ (a, f) => {
79
+ const { scope: v, children: u, ...g } = a, P = ee.useRef(null), E = U(f, P), V = p(S, v);
80
+ return ee.useEffect(() => (V.itemMap.set(P, { ref: P, ...g }), () => void V.itemMap.delete(P))), /* @__PURE__ */ s(b, { [C]: "", ref: E, children: u });
81
+ }
82
+ );
83
+ x.displayName = S;
84
+ function w(a) {
85
+ const f = p(t + "CollectionConsumer", a);
86
+ return ee.useCallback(() => {
87
+ const u = f.collectionRef.current;
88
+ if (!u) return [];
89
+ const g = Array.from(u.querySelectorAll(`[${C}]`));
90
+ return Array.from(f.itemMap.values()).sort(
91
+ (V, T) => g.indexOf(V.ref.current) - g.indexOf(T.ref.current)
92
+ );
93
+ }, [f.collectionRef, f.itemMap]);
94
+ }
95
+ return [
96
+ { Provider: r, Slot: m, ItemSlot: x },
97
+ w,
98
+ d
99
+ ];
100
+ }
101
+ var Bt = o.createContext(void 0);
102
+ function Ht(t) {
103
+ const n = o.useContext(Bt);
104
+ return t || n || "ltr";
105
+ }
106
+ function Ft(t) {
107
+ const n = o.useRef({ value: t, previous: t });
108
+ return o.useMemo(() => (n.current.value !== t && (n.current.previous = n.current.value, n.current.value = t), n.current.previous), [t]);
109
+ }
110
+ var Ut = [" ", "Enter", "ArrowUp", "ArrowDown"], Wt = [" ", "Enter"], te = "Select", [me, fe, Kt] = Vt(te), [re] = De(te, [
111
+ Kt,
112
+ Le
113
+ ]), he = Le(), [zt, X] = re(te), [Gt, jt] = re(te), ke = (t) => {
114
+ const {
115
+ __scopeSelect: n,
116
+ children: e,
117
+ open: d,
118
+ defaultOpen: c,
119
+ onOpenChange: p,
120
+ value: r,
121
+ defaultValue: i,
122
+ onValueChange: l,
123
+ dir: m,
124
+ name: S,
125
+ autoComplete: C,
126
+ disabled: b,
127
+ required: x,
128
+ form: w
129
+ } = t, a = he(n), [f, v] = o.useState(null), [u, g] = o.useState(null), [P, E] = o.useState(!1), V = Ht(m), [T, A] = _e({
130
+ prop: d,
131
+ defaultProp: c ?? !1,
132
+ onChange: p,
133
+ caller: te
134
+ }), [W, q] = _e({
135
+ prop: r,
136
+ defaultProp: i,
137
+ onChange: l,
138
+ caller: te
139
+ }), B = o.useRef(null), K = f ? w || !!f.closest("form") : !0, [z, H] = o.useState(/* @__PURE__ */ new Set()), G = Array.from(z).map((M) => M.props.value).join(";");
140
+ return /* @__PURE__ */ s(wt, { ...a, children: /* @__PURE__ */ F(
141
+ zt,
24
142
  {
25
- ref: r,
26
- className: i(
27
- "relative flex w-full cursor-default items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none select-none",
28
- "hover:bg-input-bg--hover focus:bg-input-bg--hover hover:cursor-pointer",
29
- "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
30
- e
31
- ),
32
- "data-disabled": a,
33
- ...l,
143
+ required: x,
144
+ scope: n,
145
+ trigger: f,
146
+ onTriggerChange: v,
147
+ valueNode: u,
148
+ onValueNodeChange: g,
149
+ valueNodeHasChildren: P,
150
+ onValueNodeHasChildrenChange: E,
151
+ contentId: Pe(),
152
+ value: W,
153
+ onValueChange: q,
154
+ open: T,
155
+ onOpenChange: A,
156
+ dir: V,
157
+ triggerPointerDownPosRef: B,
158
+ disabled: b,
34
159
  children: [
35
- /* @__PURE__ */ s("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ s(k, { className: "text-input-text h-4 w-4" }) }),
36
- /* @__PURE__ */ s("span", { children: t })
160
+ /* @__PURE__ */ s(me.Provider, { scope: n, children: /* @__PURE__ */ s(
161
+ Gt,
162
+ {
163
+ scope: t.__scopeSelect,
164
+ onNativeOptionAdd: o.useCallback((M) => {
165
+ H((R) => new Set(R).add(M));
166
+ }, []),
167
+ onNativeOptionRemove: o.useCallback((M) => {
168
+ H((R) => {
169
+ const D = new Set(R);
170
+ return D.delete(M), D;
171
+ });
172
+ }, []),
173
+ children: e
174
+ }
175
+ ) }),
176
+ K ? /* @__PURE__ */ F(
177
+ it,
178
+ {
179
+ "aria-hidden": !0,
180
+ required: x,
181
+ tabIndex: -1,
182
+ name: S,
183
+ autoComplete: C,
184
+ value: W,
185
+ onChange: (M) => q(M.target.value),
186
+ disabled: b,
187
+ form: w,
188
+ children: [
189
+ W === void 0 ? /* @__PURE__ */ s("option", { value: "" }) : null,
190
+ Array.from(z)
191
+ ]
192
+ },
193
+ G
194
+ ) : null
37
195
  ]
38
196
  }
39
- )
197
+ ) });
198
+ };
199
+ ke.displayName = te;
200
+ var Ve = "SelectTrigger", Be = o.forwardRef(
201
+ (t, n) => {
202
+ const { __scopeSelect: e, disabled: d = !1, ...c } = t, p = he(e), r = X(Ve, e), i = r.disabled || d, l = U(n, r.onTriggerChange), m = fe(e), S = o.useRef("touch"), [C, b, x] = ct((a) => {
203
+ const f = m().filter((g) => !g.disabled), v = f.find((g) => g.value === r.value), u = at(f, a, v);
204
+ u !== void 0 && r.onValueChange(u.value);
205
+ }), w = (a) => {
206
+ i || (r.onOpenChange(!0), x()), a && (r.triggerPointerDownPosRef.current = {
207
+ x: Math.round(a.pageX),
208
+ y: Math.round(a.pageY)
209
+ });
210
+ };
211
+ return /* @__PURE__ */ s(xt, { asChild: !0, ...p, children: /* @__PURE__ */ s(
212
+ k.button,
213
+ {
214
+ type: "button",
215
+ role: "combobox",
216
+ "aria-controls": r.contentId,
217
+ "aria-expanded": r.open,
218
+ "aria-required": r.required,
219
+ "aria-autocomplete": "none",
220
+ dir: r.dir,
221
+ "data-state": r.open ? "open" : "closed",
222
+ disabled: i,
223
+ "data-disabled": i ? "" : void 0,
224
+ "data-placeholder": lt(r.value) ? "" : void 0,
225
+ ...c,
226
+ ref: l,
227
+ onClick: O(c.onClick, (a) => {
228
+ a.currentTarget.focus(), S.current !== "mouse" && w(a);
229
+ }),
230
+ onPointerDown: O(c.onPointerDown, (a) => {
231
+ S.current = a.pointerType;
232
+ const f = a.target;
233
+ f.hasPointerCapture(a.pointerId) && f.releasePointerCapture(a.pointerId), a.button === 0 && a.ctrlKey === !1 && a.pointerType === "mouse" && (w(a), a.preventDefault());
234
+ }),
235
+ onKeyDown: O(c.onKeyDown, (a) => {
236
+ const f = C.current !== "";
237
+ !(a.ctrlKey || a.altKey || a.metaKey) && a.key.length === 1 && b(a.key), !(f && a.key === " ") && Ut.includes(a.key) && (w(), a.preventDefault());
238
+ })
239
+ }
240
+ ) });
241
+ }
40
242
  );
41
- y.displayName = "SelectItem";
42
- const x = o(({ className: e, ...t }, a) => /* @__PURE__ */ s("div", { ref: a, className: i("bg-input-border -mx-1 my-1 h-px", e), ...t }));
43
- x.displayName = "SelectSeparator";
44
- const S = o(
45
- ({ className: e, children: t, ...a }, l) => /* @__PURE__ */ s(
46
- "div",
47
- {
48
- ref: l,
49
- className: i("text-input-text-secondary py-6 text-center text-sm", e),
50
- role: "status",
51
- ...a,
52
- children: t
243
+ Be.displayName = Ve;
244
+ var He = "SelectValue", Fe = o.forwardRef(
245
+ (t, n) => {
246
+ const { __scopeSelect: e, className: d, style: c, children: p, placeholder: r = "", ...i } = t, l = X(He, e), { onValueNodeHasChildrenChange: m } = l, S = p !== void 0, C = U(n, l.onValueNodeChange);
247
+ return $(() => {
248
+ m(S);
249
+ }, [m, S]), /* @__PURE__ */ s(
250
+ k.span,
251
+ {
252
+ ...i,
253
+ ref: C,
254
+ style: { pointerEvents: "none" },
255
+ children: lt(l.value) ? /* @__PURE__ */ s(ce, { children: r }) : p
256
+ }
257
+ );
258
+ }
259
+ );
260
+ Fe.displayName = He;
261
+ var qt = "SelectIcon", Ue = o.forwardRef(
262
+ (t, n) => {
263
+ const { __scopeSelect: e, children: d, ...c } = t;
264
+ return /* @__PURE__ */ s(k.span, { "aria-hidden": !0, ...c, ref: n, children: d || "▼" });
265
+ }
266
+ );
267
+ Ue.displayName = qt;
268
+ var oe = "SelectContent", We = o.forwardRef(
269
+ (t, n) => {
270
+ const e = X(oe, t.__scopeSelect), [d, c] = o.useState();
271
+ if ($(() => {
272
+ c(new DocumentFragment());
273
+ }, []), !e.open) {
274
+ const p = d;
275
+ return p ? Ae.createPortal(
276
+ /* @__PURE__ */ s(Ke, { scope: t.__scopeSelect, children: /* @__PURE__ */ s(me.Slot, { scope: t.__scopeSelect, children: /* @__PURE__ */ s("div", { children: t.children }) }) }),
277
+ p
278
+ ) : null;
53
279
  }
54
- )
280
+ return /* @__PURE__ */ s(ze, { ...t, ref: n });
281
+ }
282
+ );
283
+ We.displayName = oe;
284
+ var j = 10, [Ke, Z] = re(oe), Yt = "SelectContentImpl", $t = ye("SelectContent.RemoveScroll"), ze = o.forwardRef(
285
+ (t, n) => {
286
+ const {
287
+ __scopeSelect: e,
288
+ position: d = "item-aligned",
289
+ onCloseAutoFocus: c,
290
+ onEscapeKeyDown: p,
291
+ onPointerDownOutside: r,
292
+ //
293
+ // PopperContent props
294
+ side: i,
295
+ sideOffset: l,
296
+ align: m,
297
+ alignOffset: S,
298
+ arrowPadding: C,
299
+ collisionBoundary: b,
300
+ collisionPadding: x,
301
+ sticky: w,
302
+ hideWhenDetached: a,
303
+ avoidCollisions: f,
304
+ //
305
+ ...v
306
+ } = t, u = X(oe, e), [g, P] = o.useState(null), [E, V] = o.useState(null), T = U(n, (h) => P(h)), [A, W] = o.useState(null), [q, B] = o.useState(
307
+ null
308
+ ), K = fe(e), [z, H] = o.useState(!1), G = o.useRef(!1);
309
+ o.useEffect(() => {
310
+ if (g) return gt(g);
311
+ }, [g]), vt();
312
+ const M = o.useCallback(
313
+ (h) => {
314
+ const [N, ...L] = K().map((_) => _.ref.current), [y] = L.slice(-1), I = document.activeElement;
315
+ for (const _ of h)
316
+ if (_ === I || (_?.scrollIntoView({ block: "nearest" }), _ === N && E && (E.scrollTop = 0), _ === y && E && (E.scrollTop = E.scrollHeight), _?.focus(), document.activeElement !== I)) return;
317
+ },
318
+ [K, E]
319
+ ), R = o.useCallback(
320
+ () => M([A, g]),
321
+ [M, A, g]
322
+ );
323
+ o.useEffect(() => {
324
+ z && R();
325
+ }, [z, R]);
326
+ const { onOpenChange: D, triggerPointerDownPosRef: Y } = u;
327
+ o.useEffect(() => {
328
+ if (g) {
329
+ let h = { x: 0, y: 0 };
330
+ const N = (y) => {
331
+ h = {
332
+ x: Math.abs(Math.round(y.pageX) - (Y.current?.x ?? 0)),
333
+ y: Math.abs(Math.round(y.pageY) - (Y.current?.y ?? 0))
334
+ };
335
+ }, L = (y) => {
336
+ h.x <= 10 && h.y <= 10 ? y.preventDefault() : g.contains(y.target) || D(!1), document.removeEventListener("pointermove", N), Y.current = null;
337
+ };
338
+ return Y.current !== null && (document.addEventListener("pointermove", N), document.addEventListener("pointerup", L, { capture: !0, once: !0 })), () => {
339
+ document.removeEventListener("pointermove", N), document.removeEventListener("pointerup", L, { capture: !0 });
340
+ };
341
+ }
342
+ }, [g, D, Y]), o.useEffect(() => {
343
+ const h = () => D(!1);
344
+ return window.addEventListener("blur", h), window.addEventListener("resize", h), () => {
345
+ window.removeEventListener("blur", h), window.removeEventListener("resize", h);
346
+ };
347
+ }, [D]);
348
+ const [se, ae] = ct((h) => {
349
+ const N = K().filter((I) => !I.disabled), L = N.find((I) => I.ref.current === document.activeElement), y = at(N, h, L);
350
+ y && setTimeout(() => y.ref.current.focus());
351
+ }), ge = o.useCallback(
352
+ (h, N, L) => {
353
+ const y = !G.current && !L;
354
+ (u.value !== void 0 && u.value === N || y) && (W(h), y && (G.current = !0));
355
+ },
356
+ [u.value]
357
+ ), ve = o.useCallback(() => g?.focus(), [g]), ne = o.useCallback(
358
+ (h, N, L) => {
359
+ const y = !G.current && !L;
360
+ (u.value !== void 0 && u.value === N || y) && B(h);
361
+ },
362
+ [u.value]
363
+ ), de = d === "popper" ? Ie : Ge, ie = de === Ie ? {
364
+ side: i,
365
+ sideOffset: l,
366
+ align: m,
367
+ alignOffset: S,
368
+ arrowPadding: C,
369
+ collisionBoundary: b,
370
+ collisionPadding: x,
371
+ sticky: w,
372
+ hideWhenDetached: a,
373
+ avoidCollisions: f
374
+ } : {};
375
+ return /* @__PURE__ */ s(
376
+ Ke,
377
+ {
378
+ scope: e,
379
+ content: g,
380
+ viewport: E,
381
+ onViewportChange: V,
382
+ itemRefCallback: ge,
383
+ selectedItem: A,
384
+ onItemLeave: ve,
385
+ itemTextRefCallback: ne,
386
+ focusSelectedItem: R,
387
+ selectedItemText: q,
388
+ position: d,
389
+ isPositioned: z,
390
+ searchRef: se,
391
+ children: /* @__PURE__ */ s(St, { as: $t, allowPinchZoom: !0, children: /* @__PURE__ */ s(
392
+ Ct,
393
+ {
394
+ asChild: !0,
395
+ trapped: u.open,
396
+ onMountAutoFocus: (h) => {
397
+ h.preventDefault();
398
+ },
399
+ onUnmountAutoFocus: O(c, (h) => {
400
+ u.trigger?.focus({ preventScroll: !0 }), h.preventDefault();
401
+ }),
402
+ children: /* @__PURE__ */ s(
403
+ ht,
404
+ {
405
+ asChild: !0,
406
+ disableOutsidePointerEvents: !0,
407
+ onEscapeKeyDown: p,
408
+ onPointerDownOutside: r,
409
+ onFocusOutside: (h) => h.preventDefault(),
410
+ onDismiss: () => u.onOpenChange(!1),
411
+ children: /* @__PURE__ */ s(
412
+ de,
413
+ {
414
+ role: "listbox",
415
+ id: u.contentId,
416
+ "data-state": u.open ? "open" : "closed",
417
+ dir: u.dir,
418
+ onContextMenu: (h) => h.preventDefault(),
419
+ ...v,
420
+ ...ie,
421
+ onPlaced: () => H(!0),
422
+ ref: T,
423
+ style: {
424
+ // flex layout so we can place the scroll buttons properly
425
+ display: "flex",
426
+ flexDirection: "column",
427
+ // reset the outline by default as the content MAY get focused
428
+ outline: "none",
429
+ ...v.style
430
+ },
431
+ onKeyDown: O(v.onKeyDown, (h) => {
432
+ const N = h.ctrlKey || h.altKey || h.metaKey;
433
+ if (h.key === "Tab" && h.preventDefault(), !N && h.key.length === 1 && ae(h.key), ["ArrowUp", "ArrowDown", "Home", "End"].includes(h.key)) {
434
+ let y = K().filter((I) => !I.disabled).map((I) => I.ref.current);
435
+ if (["ArrowUp", "End"].includes(h.key) && (y = y.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(h.key)) {
436
+ const I = h.target, _ = y.indexOf(I);
437
+ y = y.slice(_ + 1);
438
+ }
439
+ setTimeout(() => M(y)), h.preventDefault();
440
+ }
441
+ })
442
+ }
443
+ )
444
+ }
445
+ )
446
+ }
447
+ ) })
448
+ }
449
+ );
450
+ }
55
451
  );
56
- S.displayName = "SelectEmptyMessage";
57
- const f = o(
58
- ({ className: e, message: t = "Loading...", children: a, ...l }, r) => /* @__PURE__ */ m(
59
- "div",
452
+ ze.displayName = Yt;
453
+ var Xt = "SelectItemAlignedPosition", Ge = o.forwardRef((t, n) => {
454
+ const { __scopeSelect: e, onPlaced: d, ...c } = t, p = X(oe, e), r = Z(oe, e), [i, l] = o.useState(null), [m, S] = o.useState(null), C = U(n, (T) => S(T)), b = fe(e), x = o.useRef(!1), w = o.useRef(!0), { viewport: a, selectedItem: f, selectedItemText: v, focusSelectedItem: u } = r, g = o.useCallback(() => {
455
+ if (p.trigger && p.valueNode && i && m && a && f && v) {
456
+ const T = p.trigger.getBoundingClientRect(), A = m.getBoundingClientRect(), W = p.valueNode.getBoundingClientRect(), q = v.getBoundingClientRect();
457
+ if (p.dir !== "rtl") {
458
+ const I = q.left - A.left, _ = W.left - I, J = T.left - _, Q = T.width + J, Se = Math.max(Q, A.width), Ce = window.innerWidth - j, we = Me(_, [
459
+ j,
460
+ // Prevents the content from going off the starting edge of the
461
+ // viewport. It may still go off the ending edge, but this can be
462
+ // controlled by the user since they may want to manage overflow in a
463
+ // specific way.
464
+ // https://github.com/radix-ui/primitives/issues/2049
465
+ Math.max(j, Ce - Se)
466
+ ]);
467
+ i.style.minWidth = Q + "px", i.style.left = we + "px";
468
+ } else {
469
+ const I = A.right - q.right, _ = window.innerWidth - W.right - I, J = window.innerWidth - T.right - _, Q = T.width + J, Se = Math.max(Q, A.width), Ce = window.innerWidth - j, we = Me(_, [
470
+ j,
471
+ Math.max(j, Ce - Se)
472
+ ]);
473
+ i.style.minWidth = Q + "px", i.style.right = we + "px";
474
+ }
475
+ const B = b(), K = window.innerHeight - j * 2, z = a.scrollHeight, H = window.getComputedStyle(m), G = parseInt(H.borderTopWidth, 10), M = parseInt(H.paddingTop, 10), R = parseInt(H.borderBottomWidth, 10), D = parseInt(H.paddingBottom, 10), Y = G + M + z + D + R, se = Math.min(f.offsetHeight * 5, Y), ae = window.getComputedStyle(a), ge = parseInt(ae.paddingTop, 10), ve = parseInt(ae.paddingBottom, 10), ne = T.top + T.height / 2 - j, de = K - ne, ie = f.offsetHeight / 2, h = f.offsetTop + ie, N = G + M + h, L = Y - N;
476
+ if (N <= ne) {
477
+ const I = B.length > 0 && f === B[B.length - 1].ref.current;
478
+ i.style.bottom = "0px";
479
+ const _ = m.clientHeight - a.offsetTop - a.offsetHeight, J = Math.max(
480
+ de,
481
+ ie + // viewport might have padding bottom, include it to avoid a scrollable viewport
482
+ (I ? ve : 0) + _ + R
483
+ ), Q = N + J;
484
+ i.style.height = Q + "px";
485
+ } else {
486
+ const I = B.length > 0 && f === B[0].ref.current;
487
+ i.style.top = "0px";
488
+ const J = Math.max(
489
+ ne,
490
+ G + a.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
491
+ (I ? ge : 0) + ie
492
+ ) + L;
493
+ i.style.height = J + "px", a.scrollTop = N - ne + a.offsetTop;
494
+ }
495
+ i.style.margin = `${j}px 0`, i.style.minHeight = se + "px", i.style.maxHeight = K + "px", d?.(), requestAnimationFrame(() => x.current = !0);
496
+ }
497
+ }, [
498
+ b,
499
+ p.trigger,
500
+ p.valueNode,
501
+ i,
502
+ m,
503
+ a,
504
+ f,
505
+ v,
506
+ p.dir,
507
+ d
508
+ ]);
509
+ $(() => g(), [g]);
510
+ const [P, E] = o.useState();
511
+ $(() => {
512
+ m && E(window.getComputedStyle(m).zIndex);
513
+ }, [m]);
514
+ const V = o.useCallback(
515
+ (T) => {
516
+ T && w.current === !0 && (g(), u?.(), w.current = !1);
517
+ },
518
+ [g, u]
519
+ );
520
+ return /* @__PURE__ */ s(
521
+ Jt,
60
522
  {
61
- ref: r,
62
- className: i("text-input-text-secondary flex items-center justify-center gap-2 py-6 text-sm", e),
63
- role: "status",
64
- "aria-live": "polite",
65
- ...l,
66
- children: [
67
- /* @__PURE__ */ s(O, { className: "h-4 w-4 animate-spin" }),
68
- a || t
69
- ]
523
+ scope: e,
524
+ contentWrapper: i,
525
+ shouldExpandOnScrollRef: x,
526
+ onScrollButtonChange: V,
527
+ children: /* @__PURE__ */ s(
528
+ "div",
529
+ {
530
+ ref: l,
531
+ style: {
532
+ display: "flex",
533
+ flexDirection: "column",
534
+ position: "fixed",
535
+ zIndex: P
536
+ },
537
+ children: /* @__PURE__ */ s(
538
+ k.div,
539
+ {
540
+ ...c,
541
+ ref: C,
542
+ style: {
543
+ // When we get the height of the content, it includes borders. If we were to set
544
+ // the height without having `boxSizing: 'border-box'` it would be too big.
545
+ boxSizing: "border-box",
546
+ // We need to ensure the content doesn't get taller than the wrapper
547
+ maxHeight: "100%",
548
+ ...c.style
549
+ }
550
+ }
551
+ )
552
+ }
553
+ )
70
554
  }
71
- )
72
- );
73
- f.displayName = "SelectLoadingMessage";
74
- const N = o((e, t) => {
555
+ );
556
+ });
557
+ Ge.displayName = Xt;
558
+ var Zt = "SelectPopperPosition", Ie = o.forwardRef((t, n) => {
75
559
  const {
76
- defaultValue: a,
77
- items: l = [],
78
- onValueChange: r,
79
- placeholder: v,
80
- triggerClassName: h,
81
- value: C,
82
- disabled: L,
83
- name: c,
84
- id: I,
85
- state: d = "default",
86
- emptyMessage: M = "No items found",
87
- errorMessage: j,
88
- label: w,
89
- "aria-label": V,
90
- "aria-describedby": D,
91
- ...G
92
- } = e, R = $(), T = I || `${c}-${R}`, B = l.map((n) => ({
93
- label: n.label,
94
- value: n.value,
95
- disabled: n.disabled
96
- }));
560
+ __scopeSelect: e,
561
+ align: d = "start",
562
+ collisionPadding: c = j,
563
+ ...p
564
+ } = t, r = he(e);
97
565
  return /* @__PURE__ */ s(
98
- E,
566
+ yt,
99
567
  {
100
- ref: t,
101
- id: T,
102
- name: c,
103
- value: C,
104
- defaultValue: a,
105
- onChange: r,
106
- options: B,
107
- placeholder: v,
108
- state: d,
109
- errorMessage: j,
110
- emptyMessage: M,
111
- label: w,
112
- disabled: L || d === "disabled",
113
- "aria-label": V,
114
- "aria-describedby": D,
115
- className: h,
116
- ...G
568
+ ...r,
569
+ ...p,
570
+ ref: n,
571
+ align: d,
572
+ collisionPadding: c,
573
+ style: {
574
+ // Ensure border-box for floating-ui calculations
575
+ boxSizing: "border-box",
576
+ ...p.style,
577
+ "--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
578
+ "--radix-select-content-available-width": "var(--radix-popper-available-width)",
579
+ "--radix-select-content-available-height": "var(--radix-popper-available-height)",
580
+ "--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
581
+ "--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
582
+ }
117
583
  }
118
584
  );
119
585
  });
120
- N.displayName = "Select";
121
- const U = Object.assign(N, {
122
- Root: q,
123
- Group: p,
124
- Value: z,
125
- Trigger: b,
126
- Content: u,
127
- Label: g,
128
- Item: y,
129
- Separator: x,
130
- EmptyMessage: S,
131
- LoadingMessage: f
586
+ Ie.displayName = Zt;
587
+ var [Jt, Ee] = re(oe, {}), be = "SelectViewport", je = o.forwardRef(
588
+ (t, n) => {
589
+ const { __scopeSelect: e, nonce: d, ...c } = t, p = Z(be, e), r = Ee(be, e), i = U(n, p.onViewportChange), l = o.useRef(0);
590
+ return /* @__PURE__ */ F(ce, { children: [
591
+ /* @__PURE__ */ s(
592
+ "style",
593
+ {
594
+ dangerouslySetInnerHTML: {
595
+ __html: "[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"
596
+ },
597
+ nonce: d
598
+ }
599
+ ),
600
+ /* @__PURE__ */ s(me.Slot, { scope: e, children: /* @__PURE__ */ s(
601
+ k.div,
602
+ {
603
+ "data-radix-select-viewport": "",
604
+ role: "presentation",
605
+ ...c,
606
+ ref: i,
607
+ style: {
608
+ // we use position: 'relative' here on the `viewport` so that when we call
609
+ // `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
610
+ // (independent of the scrollUpButton).
611
+ position: "relative",
612
+ flex: 1,
613
+ // Viewport should only be scrollable in the vertical direction.
614
+ // This won't work in vertical writing modes, so we'll need to
615
+ // revisit this if/when that is supported
616
+ // https://developer.chrome.com/blog/vertical-form-controls
617
+ overflow: "hidden auto",
618
+ ...c.style
619
+ },
620
+ onScroll: O(c.onScroll, (m) => {
621
+ const S = m.currentTarget, { contentWrapper: C, shouldExpandOnScrollRef: b } = r;
622
+ if (b?.current && C) {
623
+ const x = Math.abs(l.current - S.scrollTop);
624
+ if (x > 0) {
625
+ const w = window.innerHeight - j * 2, a = parseFloat(C.style.minHeight), f = parseFloat(C.style.height), v = Math.max(a, f);
626
+ if (v < w) {
627
+ const u = v + x, g = Math.min(w, u), P = u - g;
628
+ C.style.height = g + "px", C.style.bottom === "0px" && (S.scrollTop = P > 0 ? P : 0, C.style.justifyContent = "flex-end");
629
+ }
630
+ }
631
+ }
632
+ l.current = S.scrollTop;
633
+ })
634
+ }
635
+ ) })
636
+ ] });
637
+ }
638
+ );
639
+ je.displayName = be;
640
+ var qe = "SelectGroup", [Qt, eo] = re(qe), Ye = o.forwardRef(
641
+ (t, n) => {
642
+ const { __scopeSelect: e, ...d } = t, c = Pe();
643
+ return /* @__PURE__ */ s(Qt, { scope: e, id: c, children: /* @__PURE__ */ s(k.div, { role: "group", "aria-labelledby": c, ...d, ref: n }) });
644
+ }
645
+ );
646
+ Ye.displayName = qe;
647
+ var $e = "SelectLabel", Xe = o.forwardRef(
648
+ (t, n) => {
649
+ const { __scopeSelect: e, ...d } = t, c = eo($e, e);
650
+ return /* @__PURE__ */ s(k.div, { id: c.id, ...d, ref: n });
651
+ }
652
+ );
653
+ Xe.displayName = $e;
654
+ var pe = "SelectItem", [to, Ze] = re(pe), Je = o.forwardRef(
655
+ (t, n) => {
656
+ const {
657
+ __scopeSelect: e,
658
+ value: d,
659
+ disabled: c = !1,
660
+ textValue: p,
661
+ ...r
662
+ } = t, i = X(pe, e), l = Z(pe, e), m = i.value === d, [S, C] = o.useState(p ?? ""), [b, x] = o.useState(!1), w = U(
663
+ n,
664
+ (u) => l.itemRefCallback?.(u, d, c)
665
+ ), a = Pe(), f = o.useRef("touch"), v = () => {
666
+ c || (i.onValueChange(d), i.onOpenChange(!1));
667
+ };
668
+ if (d === "")
669
+ throw new Error(
670
+ "A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder."
671
+ );
672
+ return /* @__PURE__ */ s(
673
+ to,
674
+ {
675
+ scope: e,
676
+ value: d,
677
+ disabled: c,
678
+ textId: a,
679
+ isSelected: m,
680
+ onItemTextChange: o.useCallback((u) => {
681
+ C((g) => g || (u?.textContent ?? "").trim());
682
+ }, []),
683
+ children: /* @__PURE__ */ s(
684
+ me.ItemSlot,
685
+ {
686
+ scope: e,
687
+ value: d,
688
+ disabled: c,
689
+ textValue: S,
690
+ children: /* @__PURE__ */ s(
691
+ k.div,
692
+ {
693
+ role: "option",
694
+ "aria-labelledby": a,
695
+ "data-highlighted": b ? "" : void 0,
696
+ "aria-selected": m && b,
697
+ "data-state": m ? "checked" : "unchecked",
698
+ "aria-disabled": c || void 0,
699
+ "data-disabled": c ? "" : void 0,
700
+ tabIndex: c ? void 0 : -1,
701
+ ...r,
702
+ ref: w,
703
+ onFocus: O(r.onFocus, () => x(!0)),
704
+ onBlur: O(r.onBlur, () => x(!1)),
705
+ onClick: O(r.onClick, () => {
706
+ f.current !== "mouse" && v();
707
+ }),
708
+ onPointerUp: O(r.onPointerUp, () => {
709
+ f.current === "mouse" && v();
710
+ }),
711
+ onPointerDown: O(r.onPointerDown, (u) => {
712
+ f.current = u.pointerType;
713
+ }),
714
+ onPointerMove: O(r.onPointerMove, (u) => {
715
+ f.current = u.pointerType, c ? l.onItemLeave?.() : f.current === "mouse" && u.currentTarget.focus({ preventScroll: !0 });
716
+ }),
717
+ onPointerLeave: O(r.onPointerLeave, (u) => {
718
+ u.currentTarget === document.activeElement && l.onItemLeave?.();
719
+ }),
720
+ onKeyDown: O(r.onKeyDown, (u) => {
721
+ l.searchRef?.current !== "" && u.key === " " || (Wt.includes(u.key) && v(), u.key === " " && u.preventDefault());
722
+ })
723
+ }
724
+ )
725
+ }
726
+ )
727
+ }
728
+ );
729
+ }
730
+ );
731
+ Je.displayName = pe;
732
+ var le = "SelectItemText", Qe = o.forwardRef(
733
+ (t, n) => {
734
+ const { __scopeSelect: e, className: d, style: c, ...p } = t, r = X(le, e), i = Z(le, e), l = Ze(le, e), m = jt(le, e), [S, C] = o.useState(null), b = U(
735
+ n,
736
+ (v) => C(v),
737
+ l.onItemTextChange,
738
+ (v) => i.itemTextRefCallback?.(v, l.value, l.disabled)
739
+ ), x = S?.textContent, w = o.useMemo(
740
+ () => /* @__PURE__ */ s("option", { value: l.value, disabled: l.disabled, children: x }, l.value),
741
+ [l.disabled, l.value, x]
742
+ ), { onNativeOptionAdd: a, onNativeOptionRemove: f } = m;
743
+ return $(() => (a(w), () => f(w)), [a, f, w]), /* @__PURE__ */ F(ce, { children: [
744
+ /* @__PURE__ */ s(k.span, { id: l.textId, ...p, ref: b }),
745
+ l.isSelected && r.valueNode && !r.valueNodeHasChildren ? Ae.createPortal(p.children, r.valueNode) : null
746
+ ] });
747
+ }
748
+ );
749
+ Qe.displayName = le;
750
+ var et = "SelectItemIndicator", tt = o.forwardRef(
751
+ (t, n) => {
752
+ const { __scopeSelect: e, ...d } = t;
753
+ return Ze(et, e).isSelected ? /* @__PURE__ */ s(k.span, { "aria-hidden": !0, ...d, ref: n }) : null;
754
+ }
755
+ );
756
+ tt.displayName = et;
757
+ var Te = "SelectScrollUpButton", ot = o.forwardRef((t, n) => {
758
+ const e = Z(Te, t.__scopeSelect), d = Ee(Te, t.__scopeSelect), [c, p] = o.useState(!1), r = U(n, d.onScrollButtonChange);
759
+ return $(() => {
760
+ if (e.viewport && e.isPositioned) {
761
+ let i = function() {
762
+ const m = l.scrollTop > 0;
763
+ p(m);
764
+ };
765
+ const l = e.viewport;
766
+ return i(), l.addEventListener("scroll", i), () => l.removeEventListener("scroll", i);
767
+ }
768
+ }, [e.viewport, e.isPositioned]), c ? /* @__PURE__ */ s(
769
+ rt,
770
+ {
771
+ ...t,
772
+ ref: r,
773
+ onAutoScroll: () => {
774
+ const { viewport: i, selectedItem: l } = e;
775
+ i && l && (i.scrollTop = i.scrollTop - l.offsetHeight);
776
+ }
777
+ }
778
+ ) : null;
779
+ });
780
+ ot.displayName = Te;
781
+ var Re = "SelectScrollDownButton", nt = o.forwardRef((t, n) => {
782
+ const e = Z(Re, t.__scopeSelect), d = Ee(Re, t.__scopeSelect), [c, p] = o.useState(!1), r = U(n, d.onScrollButtonChange);
783
+ return $(() => {
784
+ if (e.viewport && e.isPositioned) {
785
+ let i = function() {
786
+ const m = l.scrollHeight - l.clientHeight, S = Math.ceil(l.scrollTop) < m;
787
+ p(S);
788
+ };
789
+ const l = e.viewport;
790
+ return i(), l.addEventListener("scroll", i), () => l.removeEventListener("scroll", i);
791
+ }
792
+ }, [e.viewport, e.isPositioned]), c ? /* @__PURE__ */ s(
793
+ rt,
794
+ {
795
+ ...t,
796
+ ref: r,
797
+ onAutoScroll: () => {
798
+ const { viewport: i, selectedItem: l } = e;
799
+ i && l && (i.scrollTop = i.scrollTop + l.offsetHeight);
800
+ }
801
+ }
802
+ ) : null;
132
803
  });
804
+ nt.displayName = Re;
805
+ var rt = o.forwardRef((t, n) => {
806
+ const { __scopeSelect: e, onAutoScroll: d, ...c } = t, p = Z("SelectScrollButton", e), r = o.useRef(null), i = fe(e), l = o.useCallback(() => {
807
+ r.current !== null && (window.clearInterval(r.current), r.current = null);
808
+ }, []);
809
+ return o.useEffect(() => () => l(), [l]), $(() => {
810
+ i().find((S) => S.ref.current === document.activeElement)?.ref.current?.scrollIntoView({ block: "nearest" });
811
+ }, [i]), /* @__PURE__ */ s(
812
+ k.div,
813
+ {
814
+ "aria-hidden": !0,
815
+ ...c,
816
+ ref: n,
817
+ style: { flexShrink: 0, ...c.style },
818
+ onPointerDown: O(c.onPointerDown, () => {
819
+ r.current === null && (r.current = window.setInterval(d, 50));
820
+ }),
821
+ onPointerMove: O(c.onPointerMove, () => {
822
+ p.onItemLeave?.(), r.current === null && (r.current = window.setInterval(d, 50));
823
+ }),
824
+ onPointerLeave: O(c.onPointerLeave, () => {
825
+ l();
826
+ })
827
+ }
828
+ );
829
+ }), oo = "SelectSeparator", st = o.forwardRef(
830
+ (t, n) => {
831
+ const { __scopeSelect: e, ...d } = t;
832
+ return /* @__PURE__ */ s(k.div, { "aria-hidden": !0, ...d, ref: n });
833
+ }
834
+ );
835
+ st.displayName = oo;
836
+ var Ne = "SelectArrow", no = o.forwardRef(
837
+ (t, n) => {
838
+ const { __scopeSelect: e, ...d } = t, c = he(e), p = X(Ne, e), r = Z(Ne, e);
839
+ return p.open && r.position === "popper" ? /* @__PURE__ */ s(It, { ...c, ...d, ref: n }) : null;
840
+ }
841
+ );
842
+ no.displayName = Ne;
843
+ var ro = "SelectBubbleInput", it = o.forwardRef(
844
+ ({ __scopeSelect: t, value: n, ...e }, d) => {
845
+ const c = o.useRef(null), p = U(d, c), r = Ft(n);
846
+ return o.useEffect(() => {
847
+ const i = c.current;
848
+ if (!i) return;
849
+ const l = window.HTMLSelectElement.prototype, S = Object.getOwnPropertyDescriptor(
850
+ l,
851
+ "value"
852
+ ).set;
853
+ if (r !== n && S) {
854
+ const C = new Event("change", { bubbles: !0 });
855
+ S.call(i, n), i.dispatchEvent(C);
856
+ }
857
+ }, [r, n]), /* @__PURE__ */ s(
858
+ k.select,
859
+ {
860
+ ...e,
861
+ style: { ...bt, ...e.style },
862
+ ref: p,
863
+ defaultValue: n
864
+ }
865
+ );
866
+ }
867
+ );
868
+ it.displayName = ro;
869
+ function lt(t) {
870
+ return t === "" || t === void 0;
871
+ }
872
+ function ct(t) {
873
+ const n = ft(t), e = o.useRef(""), d = o.useRef(0), c = o.useCallback(
874
+ (r) => {
875
+ const i = e.current + r;
876
+ n(i), (function l(m) {
877
+ e.current = m, window.clearTimeout(d.current), m !== "" && (d.current = window.setTimeout(() => l(""), 1e3));
878
+ })(i);
879
+ },
880
+ [n]
881
+ ), p = o.useCallback(() => {
882
+ e.current = "", window.clearTimeout(d.current);
883
+ }, []);
884
+ return o.useEffect(() => () => window.clearTimeout(d.current), []), [e, c, p];
885
+ }
886
+ function at(t, n, e) {
887
+ const c = n.length > 1 && Array.from(n).every((m) => m === n[0]) ? n[0] : n, p = e ? t.indexOf(e) : -1;
888
+ let r = so(t, Math.max(p, 0));
889
+ c.length === 1 && (r = r.filter((m) => m !== e));
890
+ const l = r.find(
891
+ (m) => m.textValue.toLowerCase().startsWith(c.toLowerCase())
892
+ );
893
+ return l !== e ? l : void 0;
894
+ }
895
+ function so(t, n) {
896
+ return t.map((e, d) => t[(n + d) % t.length]);
897
+ }
898
+ var io = ke, lo = Be, co = Fe, ao = Ue, uo = We, po = je, mo = Ye, fo = Xe, ho = Je, go = Qe, vo = tt, So = ot, Co = nt, Oe = st;
899
+ const wo = mt(
900
+ ({
901
+ align: t = "start",
902
+ alignOffset: n = 0,
903
+ className: e,
904
+ collisionPadding: d = 10,
905
+ defaultValue: c,
906
+ emptyMessage: p = "No options found",
907
+ errorMessage: r,
908
+ id: i,
909
+ label: l,
910
+ loadingMessage: m = "Loading…",
911
+ name: S,
912
+ onChange: C,
913
+ options: b = [],
914
+ placeholder: x = "Select an option",
915
+ position: w = "popper",
916
+ side: a = "bottom",
917
+ sideOffset: f = 4,
918
+ state: v = "default",
919
+ value: u,
920
+ "aria-label": g,
921
+ "aria-describedby": P,
922
+ ...E
923
+ }, V) => {
924
+ const T = Tt(i, S), A = Pt(T), { isDisabled: W, isLoading: q, isInvalid: B } = Rt(E.disabled, v), K = Nt(v, B, A, P), { groups: z, ungrouped: H } = Et(b), G = () => {
925
+ if (q)
926
+ return /* @__PURE__ */ s(Dt, { message: m });
927
+ if (b.length === 0)
928
+ return /* @__PURE__ */ s(Lt, { message: p });
929
+ const M = (R) => {
930
+ const D = u === R.value;
931
+ return /* @__PURE__ */ F(
932
+ ho,
933
+ {
934
+ value: R.value,
935
+ disabled: R.disabled,
936
+ className: ue(
937
+ kt(D, !1, R.disabled),
938
+ "relative flex w-full cursor-pointer items-center"
939
+ ),
940
+ children: [
941
+ /* @__PURE__ */ s(go, { className: "block truncate", children: R.label }),
942
+ /* @__PURE__ */ s(vo, { asChild: !0, children: /* @__PURE__ */ s("span", { className: "absolute right-2 flex h-4 w-4 items-center justify-center", children: /* @__PURE__ */ s(dt, { size: 16 }) }) })
943
+ ]
944
+ },
945
+ R.value
946
+ );
947
+ };
948
+ return /* @__PURE__ */ F(ce, { children: [
949
+ H.length > 0 && /* @__PURE__ */ F(ce, { children: [
950
+ H.map(M),
951
+ Object.keys(z).length > 0 && /* @__PURE__ */ s(Oe, { className: "bg-border-secondary -mx-1 my-1 h-px" })
952
+ ] }),
953
+ Object.entries(z).map(([R, D], Y) => /* @__PURE__ */ F(mo, { children: [
954
+ Y > 0 && /* @__PURE__ */ s(Oe, { className: "bg-border-secondary -mx-1 my-1 h-px" }),
955
+ /* @__PURE__ */ s(fo, { className: "text-text-primary px-2 py-1.5 text-base font-semibold", children: R }),
956
+ D.map((se) => M(se))
957
+ ] }, R))
958
+ ] });
959
+ };
960
+ return /* @__PURE__ */ F("div", { className: "w-full", "data-testid": "select-root", children: [
961
+ l && /* @__PURE__ */ s(pt, { htmlFor: T, className: ue("text-text-primary mb-4 block", W && "text-text-secondary"), children: l }),
962
+ /* @__PURE__ */ F(
963
+ io,
964
+ {
965
+ value: u,
966
+ defaultValue: c,
967
+ onValueChange: C,
968
+ disabled: W,
969
+ name: S,
970
+ required: E.required,
971
+ children: [
972
+ /* @__PURE__ */ s(
973
+ lo,
974
+ {
975
+ ref: V,
976
+ id: T,
977
+ className: ue(Ot(v, !1), Mt(v), e),
978
+ "aria-label": g || l,
979
+ "data-state": v,
980
+ style: _t(),
981
+ ...K,
982
+ ...E,
983
+ asChild: !0,
984
+ children: /* @__PURE__ */ F("button", { type: "button", children: [
985
+ /* @__PURE__ */ s(co, { placeholder: x, className: "block truncate" }),
986
+ /* @__PURE__ */ s(ao, { asChild: !0, children: /* @__PURE__ */ s("div", { className: "flex items-center", children: q ? /* @__PURE__ */ s(ut, { size: 20 }) : /* @__PURE__ */ s(
987
+ xe,
988
+ {
989
+ className: "transition-transform duration-200 data-[state=open]:rotate-180",
990
+ size: 20
991
+ }
992
+ ) }) })
993
+ ] })
994
+ }
995
+ ),
996
+ /* @__PURE__ */ s(
997
+ uo,
998
+ {
999
+ position: w,
1000
+ side: a,
1001
+ align: t,
1002
+ sideOffset: f,
1003
+ alignOffset: n,
1004
+ collisionPadding: d,
1005
+ asChild: !0,
1006
+ children: /* @__PURE__ */ F(
1007
+ "div",
1008
+ {
1009
+ className: ue(
1010
+ "border-input-border bg-input-bg z-50 rounded-lg border shadow-md",
1011
+ "data-[state=open]:animate-in data-[state=closed]:animate-out",
1012
+ "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
1013
+ "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
1014
+ "data-[side=bottom]:slide-in-from-top-2",
1015
+ "data-[side=left]:slide-in-from-right-2",
1016
+ "data-[side=right]:slide-in-from-left-2",
1017
+ "data-[side=top]:slide-in-from-bottom-2"
1018
+ ),
1019
+ style: {
1020
+ position: "fixed",
1021
+ boxSizing: "border-box",
1022
+ width: "var(--radix-select-trigger-width)",
1023
+ maxHeight: "var(--radix-select-content-available-height)"
1024
+ },
1025
+ children: [
1026
+ /* @__PURE__ */ s(So, { className: "flex cursor-default items-center justify-center py-1", children: /* @__PURE__ */ s(xe, { className: "rotate-180", size: 18 }) }),
1027
+ /* @__PURE__ */ s(po, { asChild: !0, children: /* @__PURE__ */ s("div", { className: "max-h-96 p-1", style: { position: "relative", overflow: "hidden auto" }, children: G() }) }),
1028
+ /* @__PURE__ */ s(Co, { className: "flex cursor-default items-center justify-center py-1", children: /* @__PURE__ */ s(xe, { size: 18 }) })
1029
+ ]
1030
+ }
1031
+ )
1032
+ }
1033
+ )
1034
+ ]
1035
+ }
1036
+ ),
1037
+ B && r && /* @__PURE__ */ s(At, { id: A, message: r })
1038
+ ] });
1039
+ }
1040
+ );
1041
+ wo.displayName = "Select";
133
1042
  export {
134
- U as Select,
135
- E as SelectBase
1043
+ wo as Select
136
1044
  };