@spear-ai/spectral 1.12.6 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,869 +1,3 @@
1
1
  'use client'
2
- import './styles/main.css'
3
- import { CheckmarkIcon as e } from "./Icons/CheckmarkIcon.js";
4
- import { a as t, c as n, d as r, l as i, n as a, o, r as s, t as c } from "./dist-DEkDg4Sk.js";
5
- import { n as l, t as u } from "./dist-CcsVPym2.js";
6
- import { t as d } from "./dist-D9FsQh8P.js";
7
- import { t as f } from "./dist-Br_xj9vz.js";
8
- import { t as p } from "./twUtils-BpqlKSeB.js";
9
- import { EmptyState as m, LoadingState as h, getDropdownSurfaceClasses as g, getDropdownWidthStyles as _, getOptionClasses as v } from "./utils/formFieldUtils.js";
10
- import { useUncontrolledState as y } from "./hooks/useUncontrolledState.js";
11
- import { t as b } from "./dist-C4MHwt9g.js";
12
- import { n as ee, t as x } from "./dist-iDaHUF3d.js";
13
- import { i as te, n as S, r as ne, t as re } from "./Combination-MimnVFUU.js";
14
- import { a as C, i as w, n as T, r as ie, t as E } from "./dist-CwYxT5fv.js";
15
- import { useAutoDropdownHorizontalShift as D } from "./utils/dropdownPositioning.js";
16
- import { n as ae, r as O, t as k } from "./dist-DBLajRTL.js";
17
- import * as A from "react";
18
- import { jsx as j, jsxs as M } from "react/jsx-runtime";
19
- //#region node_modules/.pnpm/@radix-ui+react-menu@2.1.16_@types+react-dom@19.2.3_@types+react@19.2.14__@types+react@_af24564827454c35f463162a4c5cfd35/node_modules/@radix-ui/react-menu/dist/index.mjs
20
- var N = ["Enter", " "], P = [
21
- "ArrowDown",
22
- "PageUp",
23
- "Home"
24
- ], F = [
25
- "ArrowUp",
26
- "PageDown",
27
- "End"
28
- ], I = [...P, ...F], L = {
29
- ltr: [...N, "ArrowRight"],
30
- rtl: [...N, "ArrowLeft"]
31
- }, R = {
32
- ltr: ["ArrowLeft"],
33
- rtl: ["ArrowRight"]
34
- }, z = "Menu", [B, oe, se] = l(z), [V, H] = r(z, [
35
- se,
36
- C,
37
- O
38
- ]), U = C(), ce = O(), [le, W] = V(z), [ue, G] = V(z), de = (e) => {
39
- let { __scopeMenu: t, open: n = !1, children: r, dir: i, onOpenChange: a, modal: o = !0 } = e, s = U(t), [c, l] = A.useState(null), d = A.useRef(!1), f = b(a), p = u(i);
40
- return A.useEffect(() => {
41
- let e = () => {
42
- d.current = !0, document.addEventListener("pointerdown", t, {
43
- capture: !0,
44
- once: !0
45
- }), document.addEventListener("pointermove", t, {
46
- capture: !0,
47
- once: !0
48
- });
49
- }, t = () => d.current = !1;
50
- return document.addEventListener("keydown", e, { capture: !0 }), () => {
51
- document.removeEventListener("keydown", e, { capture: !0 }), document.removeEventListener("pointerdown", t, { capture: !0 }), document.removeEventListener("pointermove", t, { capture: !0 });
52
- };
53
- }, []), /* @__PURE__ */ j(w, {
54
- ...s,
55
- children: /* @__PURE__ */ j(le, {
56
- scope: t,
57
- open: n,
58
- onOpenChange: f,
59
- content: c,
60
- onContentChange: l,
61
- children: /* @__PURE__ */ j(ue, {
62
- scope: t,
63
- onClose: A.useCallback(() => f(!1), [f]),
64
- isUsingKeyboardRef: d,
65
- dir: p,
66
- modal: o,
67
- children: r
68
- })
69
- })
70
- });
71
- };
72
- de.displayName = z;
73
- var fe = "MenuAnchor", pe = A.forwardRef((e, t) => {
74
- let { __scopeMenu: n, ...r } = e;
75
- return /* @__PURE__ */ j(E, {
76
- ...U(n),
77
- ...r,
78
- ref: t
79
- });
80
- });
81
- pe.displayName = fe;
82
- var me = "MenuPortal", [he, ge] = V(me, { forceMount: void 0 }), _e = (e) => {
83
- let { __scopeMenu: t, forceMount: n, children: r, container: i } = e, a = W(me, t);
84
- return /* @__PURE__ */ j(he, {
85
- scope: t,
86
- forceMount: n,
87
- children: /* @__PURE__ */ j(d, {
88
- present: n || a.open,
89
- children: /* @__PURE__ */ j(x, {
90
- asChild: !0,
91
- container: i,
92
- children: r
93
- })
94
- })
95
- });
96
- };
97
- _e.displayName = me;
98
- var K = "MenuContent", [ve, ye] = V(K), be = A.forwardRef((e, t) => {
99
- let n = ge(K, e.__scopeMenu), { forceMount: r = n.forceMount, ...i } = e, a = W(K, e.__scopeMenu), o = G(K, e.__scopeMenu);
100
- return /* @__PURE__ */ j(B.Provider, {
101
- scope: e.__scopeMenu,
102
- children: /* @__PURE__ */ j(d, {
103
- present: r || a.open,
104
- children: /* @__PURE__ */ j(B.Slot, {
105
- scope: e.__scopeMenu,
106
- children: o.modal ? /* @__PURE__ */ j(xe, {
107
- ...i,
108
- ref: t
109
- }) : /* @__PURE__ */ j(Se, {
110
- ...i,
111
- ref: t
112
- })
113
- })
114
- })
115
- });
116
- }), xe = A.forwardRef((e, n) => {
117
- let r = W(K, e.__scopeMenu), a = A.useRef(null), o = i(n, a);
118
- return A.useEffect(() => {
119
- let e = a.current;
120
- if (e) return S(e);
121
- }, []), /* @__PURE__ */ j(we, {
122
- ...e,
123
- ref: o,
124
- trapFocus: r.open,
125
- disableOutsidePointerEvents: r.open,
126
- disableOutsideScroll: !0,
127
- onFocusOutside: t(e.onFocusOutside, (e) => e.preventDefault(), { checkForDefaultPrevented: !1 }),
128
- onDismiss: () => r.onOpenChange(!1)
129
- });
130
- }), Se = A.forwardRef((e, t) => {
131
- let n = W(K, e.__scopeMenu);
132
- return /* @__PURE__ */ j(we, {
133
- ...e,
134
- ref: t,
135
- trapFocus: !1,
136
- disableOutsidePointerEvents: !1,
137
- disableOutsideScroll: !1,
138
- onDismiss: () => n.onOpenChange(!1)
139
- });
140
- }), Ce = o("MenuContent.ScrollLock"), we = A.forwardRef((e, n) => {
141
- let { __scopeMenu: r, loop: a = !1, trapFocus: o, onOpenAutoFocus: s, onCloseAutoFocus: c, disableOutsidePointerEvents: l, onEntryFocus: u, onEscapeKeyDown: d, onPointerDownOutside: f, onFocusOutside: p, onInteractOutside: m, onDismiss: h, disableOutsideScroll: g, ..._ } = e, v = W(K, r), y = G(K, r), b = U(r), x = ce(r), S = oe(r), [C, w] = A.useState(null), T = A.useRef(null), E = i(n, T, v.onContentChange), D = A.useRef(0), O = A.useRef(""), k = A.useRef(0), M = A.useRef(null), N = A.useRef("right"), P = A.useRef(0), L = g ? re : A.Fragment, R = g ? {
142
- as: Ce,
143
- allowPinchZoom: !0
144
- } : void 0, z = (e) => {
145
- let t = O.current + e, n = S().filter((e) => !e.disabled), r = document.activeElement, i = n.find((e) => e.ref.current === r)?.textValue, a = it(n.map((e) => e.textValue), t, i), o = n.find((e) => e.textValue === a)?.ref.current;
146
- (function e(t) {
147
- O.current = t, window.clearTimeout(D.current), t !== "" && (D.current = window.setTimeout(() => e(""), 1e3));
148
- })(t), o && setTimeout(() => o.focus());
149
- };
150
- A.useEffect(() => () => window.clearTimeout(D.current), []), te();
151
- let B = A.useCallback((e) => N.current === M.current?.side && ot(e, M.current?.area), []);
152
- return /* @__PURE__ */ j(ve, {
153
- scope: r,
154
- searchRef: O,
155
- onItemEnter: A.useCallback((e) => {
156
- B(e) && e.preventDefault();
157
- }, [B]),
158
- onItemLeave: A.useCallback((e) => {
159
- B(e) || (T.current?.focus(), w(null));
160
- }, [B]),
161
- onTriggerLeave: A.useCallback((e) => {
162
- B(e) && e.preventDefault();
163
- }, [B]),
164
- pointerGraceTimerRef: k,
165
- onPointerGraceIntentChange: A.useCallback((e) => {
166
- M.current = e;
167
- }, []),
168
- children: /* @__PURE__ */ j(L, {
169
- ...R,
170
- children: /* @__PURE__ */ j(ne, {
171
- asChild: !0,
172
- trapped: o,
173
- onMountAutoFocus: t(s, (e) => {
174
- e.preventDefault(), T.current?.focus({ preventScroll: !0 });
175
- }),
176
- onUnmountAutoFocus: c,
177
- children: /* @__PURE__ */ j(ee, {
178
- asChild: !0,
179
- disableOutsidePointerEvents: l,
180
- onEscapeKeyDown: d,
181
- onPointerDownOutside: f,
182
- onFocusOutside: p,
183
- onInteractOutside: m,
184
- onDismiss: h,
185
- children: /* @__PURE__ */ j(ae, {
186
- asChild: !0,
187
- ...x,
188
- dir: y.dir,
189
- orientation: "vertical",
190
- loop: a,
191
- currentTabStopId: C,
192
- onCurrentTabStopIdChange: w,
193
- onEntryFocus: t(u, (e) => {
194
- y.isUsingKeyboardRef.current || e.preventDefault();
195
- }),
196
- preventScrollOnEntryFocus: !0,
197
- children: /* @__PURE__ */ j(ie, {
198
- role: "menu",
199
- "aria-orientation": "vertical",
200
- "data-state": et(v.open),
201
- "data-radix-menu-content": "",
202
- dir: y.dir,
203
- ...b,
204
- ..._,
205
- ref: E,
206
- style: {
207
- outline: "none",
208
- ..._.style
209
- },
210
- onKeyDown: t(_.onKeyDown, (e) => {
211
- let t = e.target.closest("[data-radix-menu-content]") === e.currentTarget, n = e.ctrlKey || e.altKey || e.metaKey, r = e.key.length === 1;
212
- t && (e.key === "Tab" && e.preventDefault(), !n && r && z(e.key));
213
- let i = T.current;
214
- if (e.target !== i || !I.includes(e.key)) return;
215
- e.preventDefault();
216
- let a = S().filter((e) => !e.disabled).map((e) => e.ref.current);
217
- F.includes(e.key) && a.reverse(), nt(a);
218
- }),
219
- onBlur: t(e.onBlur, (e) => {
220
- e.currentTarget.contains(e.target) || (window.clearTimeout(D.current), O.current = "");
221
- }),
222
- onPointerMove: t(e.onPointerMove, Z((e) => {
223
- let t = e.target, n = P.current !== e.clientX;
224
- e.currentTarget.contains(t) && n && (N.current = e.clientX > P.current ? "right" : "left", P.current = e.clientX);
225
- }))
226
- })
227
- })
228
- })
229
- })
230
- })
231
- });
232
- });
233
- be.displayName = K;
234
- var Te = "MenuGroup", Ee = A.forwardRef((e, t) => {
235
- let { __scopeMenu: n, ...r } = e;
236
- return /* @__PURE__ */ j(c.div, {
237
- role: "group",
238
- ...r,
239
- ref: t
240
- });
241
- });
242
- Ee.displayName = Te;
243
- var De = "MenuLabel", Oe = A.forwardRef((e, t) => {
244
- let { __scopeMenu: n, ...r } = e;
245
- return /* @__PURE__ */ j(c.div, {
246
- ...r,
247
- ref: t
248
- });
249
- });
250
- Oe.displayName = De;
251
- var q = "MenuItem", ke = "menu.itemSelect", J = A.forwardRef((e, n) => {
252
- let { disabled: r = !1, onSelect: o, ...s } = e, c = A.useRef(null), l = G(q, e.__scopeMenu), u = ye(q, e.__scopeMenu), d = i(n, c), f = A.useRef(!1), p = () => {
253
- let e = c.current;
254
- if (!r && e) {
255
- let t = new CustomEvent(ke, {
256
- bubbles: !0,
257
- cancelable: !0
258
- });
259
- e.addEventListener(ke, (e) => o?.(e), { once: !0 }), a(e, t), t.defaultPrevented ? f.current = !1 : l.onClose();
260
- }
261
- };
262
- return /* @__PURE__ */ j(Ae, {
263
- ...s,
264
- ref: d,
265
- disabled: r,
266
- onClick: t(e.onClick, p),
267
- onPointerDown: (t) => {
268
- e.onPointerDown?.(t), f.current = !0;
269
- },
270
- onPointerUp: t(e.onPointerUp, (e) => {
271
- f.current || e.currentTarget?.click();
272
- }),
273
- onKeyDown: t(e.onKeyDown, (e) => {
274
- let t = u.searchRef.current !== "";
275
- r || t && e.key === " " || N.includes(e.key) && (e.currentTarget.click(), e.preventDefault());
276
- })
277
- });
278
- });
279
- J.displayName = q;
280
- var Ae = A.forwardRef((e, n) => {
281
- let { __scopeMenu: r, disabled: a = !1, textValue: o, ...s } = e, l = ye(q, r), u = ce(r), d = A.useRef(null), f = i(n, d), [p, m] = A.useState(!1), [h, g] = A.useState("");
282
- return A.useEffect(() => {
283
- let e = d.current;
284
- e && g((e.textContent ?? "").trim());
285
- }, [s.children]), /* @__PURE__ */ j(B.ItemSlot, {
286
- scope: r,
287
- disabled: a,
288
- textValue: o ?? h,
289
- children: /* @__PURE__ */ j(k, {
290
- asChild: !0,
291
- ...u,
292
- focusable: !a,
293
- children: /* @__PURE__ */ j(c.div, {
294
- role: "menuitem",
295
- "data-highlighted": p ? "" : void 0,
296
- "aria-disabled": a || void 0,
297
- "data-disabled": a ? "" : void 0,
298
- ...s,
299
- ref: f,
300
- onPointerMove: t(e.onPointerMove, Z((e) => {
301
- a ? l.onItemLeave(e) : (l.onItemEnter(e), e.defaultPrevented || e.currentTarget.focus({ preventScroll: !0 }));
302
- })),
303
- onPointerLeave: t(e.onPointerLeave, Z((e) => l.onItemLeave(e))),
304
- onFocus: t(e.onFocus, () => m(!0)),
305
- onBlur: t(e.onBlur, () => m(!1))
306
- })
307
- })
308
- });
309
- }), je = "MenuCheckboxItem", Me = A.forwardRef((e, n) => {
310
- let { checked: r = !1, onCheckedChange: i, ...a } = e;
311
- return /* @__PURE__ */ j(Be, {
312
- scope: e.__scopeMenu,
313
- checked: r,
314
- children: /* @__PURE__ */ j(J, {
315
- role: "menuitemcheckbox",
316
- "aria-checked": X(r) ? "mixed" : r,
317
- ...a,
318
- ref: n,
319
- "data-state": tt(r),
320
- onSelect: t(a.onSelect, () => i?.(X(r) ? !0 : !r), { checkForDefaultPrevented: !1 })
321
- })
322
- });
323
- });
324
- Me.displayName = je;
325
- var Ne = "MenuRadioGroup", [Pe, Fe] = V(Ne, {
326
- value: void 0,
327
- onValueChange: () => {}
328
- }), Ie = A.forwardRef((e, t) => {
329
- let { value: n, onValueChange: r, ...i } = e, a = b(r);
330
- return /* @__PURE__ */ j(Pe, {
331
- scope: e.__scopeMenu,
332
- value: n,
333
- onValueChange: a,
334
- children: /* @__PURE__ */ j(Ee, {
335
- ...i,
336
- ref: t
337
- })
338
- });
339
- });
340
- Ie.displayName = Ne;
341
- var Le = "MenuRadioItem", Re = A.forwardRef((e, n) => {
342
- let { value: r, ...i } = e, a = Fe(Le, e.__scopeMenu), o = r === a.value;
343
- return /* @__PURE__ */ j(Be, {
344
- scope: e.__scopeMenu,
345
- checked: o,
346
- children: /* @__PURE__ */ j(J, {
347
- role: "menuitemradio",
348
- "aria-checked": o,
349
- ...i,
350
- ref: n,
351
- "data-state": tt(o),
352
- onSelect: t(i.onSelect, () => a.onValueChange?.(r), { checkForDefaultPrevented: !1 })
353
- })
354
- });
355
- });
356
- Re.displayName = Le;
357
- var ze = "MenuItemIndicator", [Be, Ve] = V(ze, { checked: !1 }), He = A.forwardRef((e, t) => {
358
- let { __scopeMenu: n, forceMount: r, ...i } = e, a = Ve(ze, n);
359
- return /* @__PURE__ */ j(d, {
360
- present: r || X(a.checked) || a.checked === !0,
361
- children: /* @__PURE__ */ j(c.span, {
362
- ...i,
363
- ref: t,
364
- "data-state": tt(a.checked)
365
- })
366
- });
367
- });
368
- He.displayName = ze;
369
- var Ue = "MenuSeparator", We = A.forwardRef((e, t) => {
370
- let { __scopeMenu: n, ...r } = e;
371
- return /* @__PURE__ */ j(c.div, {
372
- role: "separator",
373
- "aria-orientation": "horizontal",
374
- ...r,
375
- ref: t
376
- });
377
- });
378
- We.displayName = Ue;
379
- var Ge = "MenuArrow", Ke = A.forwardRef((e, t) => {
380
- let { __scopeMenu: n, ...r } = e;
381
- return /* @__PURE__ */ j(T, {
382
- ...U(n),
383
- ...r,
384
- ref: t
385
- });
386
- });
387
- Ke.displayName = Ge;
388
- var qe = "MenuSub", [Je, Ye] = V(qe), Xe = (e) => {
389
- let { __scopeMenu: t, children: n, open: r = !1, onOpenChange: i } = e, a = W(qe, t), o = U(t), [s, c] = A.useState(null), [l, u] = A.useState(null), d = b(i);
390
- return A.useEffect(() => (a.open === !1 && d(!1), () => d(!1)), [a.open, d]), /* @__PURE__ */ j(w, {
391
- ...o,
392
- children: /* @__PURE__ */ j(le, {
393
- scope: t,
394
- open: r,
395
- onOpenChange: d,
396
- content: l,
397
- onContentChange: u,
398
- children: /* @__PURE__ */ j(Je, {
399
- scope: t,
400
- contentId: f(),
401
- triggerId: f(),
402
- trigger: s,
403
- onTriggerChange: c,
404
- children: n
405
- })
406
- })
407
- });
408
- };
409
- Xe.displayName = qe;
410
- var Y = "MenuSubTrigger", Ze = A.forwardRef((e, r) => {
411
- let i = W(Y, e.__scopeMenu), a = G(Y, e.__scopeMenu), o = Ye(Y, e.__scopeMenu), s = ye(Y, e.__scopeMenu), c = A.useRef(null), { pointerGraceTimerRef: l, onPointerGraceIntentChange: u } = s, d = { __scopeMenu: e.__scopeMenu }, f = A.useCallback(() => {
412
- c.current && window.clearTimeout(c.current), c.current = null;
413
- }, []);
414
- return A.useEffect(() => f, [f]), A.useEffect(() => {
415
- let e = l.current;
416
- return () => {
417
- window.clearTimeout(e), u(null);
418
- };
419
- }, [l, u]), /* @__PURE__ */ j(pe, {
420
- asChild: !0,
421
- ...d,
422
- children: /* @__PURE__ */ j(Ae, {
423
- id: o.triggerId,
424
- "aria-haspopup": "menu",
425
- "aria-expanded": i.open,
426
- "aria-controls": o.contentId,
427
- "data-state": et(i.open),
428
- ...e,
429
- ref: n(r, o.onTriggerChange),
430
- onClick: (t) => {
431
- e.onClick?.(t), !(e.disabled || t.defaultPrevented) && (t.currentTarget.focus(), i.open || i.onOpenChange(!0));
432
- },
433
- onPointerMove: t(e.onPointerMove, Z((t) => {
434
- s.onItemEnter(t), !t.defaultPrevented && !e.disabled && !i.open && !c.current && (s.onPointerGraceIntentChange(null), c.current = window.setTimeout(() => {
435
- i.onOpenChange(!0), f();
436
- }, 100));
437
- })),
438
- onPointerLeave: t(e.onPointerLeave, Z((e) => {
439
- f();
440
- let t = i.content?.getBoundingClientRect();
441
- if (t) {
442
- let n = i.content?.dataset.side, r = n === "right", a = r ? -5 : 5, o = t[r ? "left" : "right"], c = t[r ? "right" : "left"];
443
- s.onPointerGraceIntentChange({
444
- area: [
445
- {
446
- x: e.clientX + a,
447
- y: e.clientY
448
- },
449
- {
450
- x: o,
451
- y: t.top
452
- },
453
- {
454
- x: c,
455
- y: t.top
456
- },
457
- {
458
- x: c,
459
- y: t.bottom
460
- },
461
- {
462
- x: o,
463
- y: t.bottom
464
- }
465
- ],
466
- side: n
467
- }), window.clearTimeout(l.current), l.current = window.setTimeout(() => s.onPointerGraceIntentChange(null), 300);
468
- } else {
469
- if (s.onTriggerLeave(e), e.defaultPrevented) return;
470
- s.onPointerGraceIntentChange(null);
471
- }
472
- })),
473
- onKeyDown: t(e.onKeyDown, (t) => {
474
- let n = s.searchRef.current !== "";
475
- e.disabled || n && t.key === " " || L[a.dir].includes(t.key) && (i.onOpenChange(!0), i.content?.focus(), t.preventDefault());
476
- })
477
- })
478
- });
479
- });
480
- Ze.displayName = Y;
481
- var Qe = "MenuSubContent", $e = A.forwardRef((e, n) => {
482
- let r = ge(K, e.__scopeMenu), { forceMount: a = r.forceMount, ...o } = e, s = W(K, e.__scopeMenu), c = G(K, e.__scopeMenu), l = Ye(Qe, e.__scopeMenu), u = A.useRef(null), f = i(n, u);
483
- return /* @__PURE__ */ j(B.Provider, {
484
- scope: e.__scopeMenu,
485
- children: /* @__PURE__ */ j(d, {
486
- present: a || s.open,
487
- children: /* @__PURE__ */ j(B.Slot, {
488
- scope: e.__scopeMenu,
489
- children: /* @__PURE__ */ j(we, {
490
- id: l.contentId,
491
- "aria-labelledby": l.triggerId,
492
- ...o,
493
- ref: f,
494
- align: "start",
495
- side: c.dir === "rtl" ? "left" : "right",
496
- disableOutsidePointerEvents: !1,
497
- disableOutsideScroll: !1,
498
- trapFocus: !1,
499
- onOpenAutoFocus: (e) => {
500
- c.isUsingKeyboardRef.current && u.current?.focus(), e.preventDefault();
501
- },
502
- onCloseAutoFocus: (e) => e.preventDefault(),
503
- onFocusOutside: t(e.onFocusOutside, (e) => {
504
- e.target !== l.trigger && s.onOpenChange(!1);
505
- }),
506
- onEscapeKeyDown: t(e.onEscapeKeyDown, (e) => {
507
- c.onClose(), e.preventDefault();
508
- }),
509
- onKeyDown: t(e.onKeyDown, (e) => {
510
- let t = e.currentTarget.contains(e.target), n = R[c.dir].includes(e.key);
511
- t && n && (s.onOpenChange(!1), l.trigger?.focus(), e.preventDefault());
512
- })
513
- })
514
- })
515
- })
516
- });
517
- });
518
- $e.displayName = Qe;
519
- function et(e) {
520
- return e ? "open" : "closed";
521
- }
522
- function X(e) {
523
- return e === "indeterminate";
524
- }
525
- function tt(e) {
526
- return X(e) ? "indeterminate" : e ? "checked" : "unchecked";
527
- }
528
- function nt(e) {
529
- let t = document.activeElement;
530
- for (let n of e) if (n === t || (n.focus(), document.activeElement !== t)) return;
531
- }
532
- function rt(e, t) {
533
- return e.map((n, r) => e[(t + r) % e.length]);
534
- }
535
- function it(e, t, n) {
536
- let r = t.length > 1 && Array.from(t).every((e) => e === t[0]) ? t[0] : t, i = n ? e.indexOf(n) : -1, a = rt(e, Math.max(i, 0));
537
- r.length === 1 && (a = a.filter((e) => e !== n));
538
- let o = a.find((e) => e.toLowerCase().startsWith(r.toLowerCase()));
539
- return o === n ? void 0 : o;
540
- }
541
- function at(e, t) {
542
- let { x: n, y: r } = e, i = !1;
543
- for (let e = 0, a = t.length - 1; e < t.length; a = e++) {
544
- let o = t[e], s = t[a], c = o.x, l = o.y, u = s.x, d = s.y;
545
- l > r != d > r && n < (u - c) * (r - l) / (d - l) + c && (i = !i);
546
- }
547
- return i;
548
- }
549
- function ot(e, t) {
550
- return t ? at({
551
- x: e.clientX,
552
- y: e.clientY
553
- }, t) : !1;
554
- }
555
- function Z(e) {
556
- return (t) => t.pointerType === "mouse" ? e(t) : void 0;
557
- }
558
- var st = de, ct = pe, lt = _e, ut = be, dt = Ee, ft = Oe, pt = J, mt = Me, ht = Ie, gt = Re, _t = He, vt = We, yt = Ke, bt = Ze, xt = $e, Q = "DropdownMenu", [St, Ct] = r(Q, [H]), $ = H(), [wt, Tt] = St(Q), Et = (e) => {
559
- let { __scopeDropdownMenu: t, children: n, dir: r, open: i, defaultOpen: a, onOpenChange: o, modal: c = !0 } = e, l = $(t), u = A.useRef(null), [d, p] = s({
560
- prop: i,
561
- defaultProp: a ?? !1,
562
- onChange: o,
563
- caller: Q
564
- });
565
- return /* @__PURE__ */ j(wt, {
566
- scope: t,
567
- triggerId: f(),
568
- triggerRef: u,
569
- contentId: f(),
570
- open: d,
571
- onOpenChange: p,
572
- onOpenToggle: A.useCallback(() => p((e) => !e), [p]),
573
- modal: c,
574
- children: /* @__PURE__ */ j(st, {
575
- ...l,
576
- open: d,
577
- onOpenChange: p,
578
- dir: r,
579
- modal: c,
580
- children: n
581
- })
582
- });
583
- };
584
- Et.displayName = Q;
585
- var Dt = "DropdownMenuTrigger", Ot = A.forwardRef((e, r) => {
586
- let { __scopeDropdownMenu: i, disabled: a = !1, ...o } = e, s = Tt(Dt, i);
587
- return /* @__PURE__ */ j(ct, {
588
- asChild: !0,
589
- ...$(i),
590
- children: /* @__PURE__ */ j(c.button, {
591
- type: "button",
592
- id: s.triggerId,
593
- "aria-haspopup": "menu",
594
- "aria-expanded": s.open,
595
- "aria-controls": s.open ? s.contentId : void 0,
596
- "data-state": s.open ? "open" : "closed",
597
- "data-disabled": a ? "" : void 0,
598
- disabled: a,
599
- ...o,
600
- ref: n(r, s.triggerRef),
601
- onPointerDown: t(e.onPointerDown, (e) => {
602
- !a && e.button === 0 && e.ctrlKey === !1 && (s.onOpenToggle(), s.open || e.preventDefault());
603
- }),
604
- onKeyDown: t(e.onKeyDown, (e) => {
605
- a || (["Enter", " "].includes(e.key) && s.onOpenToggle(), e.key === "ArrowDown" && s.onOpenChange(!0), [
606
- "Enter",
607
- " ",
608
- "ArrowDown"
609
- ].includes(e.key) && e.preventDefault());
610
- })
611
- })
612
- });
613
- });
614
- Ot.displayName = Dt;
615
- var kt = "DropdownMenuPortal", At = (e) => {
616
- let { __scopeDropdownMenu: t, ...n } = e;
617
- return /* @__PURE__ */ j(lt, {
618
- ...$(t),
619
- ...n
620
- });
621
- };
622
- At.displayName = kt;
623
- var jt = "DropdownMenuContent", Mt = A.forwardRef((e, n) => {
624
- let { __scopeDropdownMenu: r, ...i } = e, a = Tt(jt, r), o = $(r), s = A.useRef(!1);
625
- return /* @__PURE__ */ j(ut, {
626
- id: a.contentId,
627
- "aria-labelledby": a.triggerId,
628
- ...o,
629
- ...i,
630
- ref: n,
631
- onCloseAutoFocus: t(e.onCloseAutoFocus, (e) => {
632
- s.current || a.triggerRef.current?.focus(), s.current = !1, e.preventDefault();
633
- }),
634
- onInteractOutside: t(e.onInteractOutside, (e) => {
635
- let t = e.detail.originalEvent, n = t.button === 0 && t.ctrlKey === !0, r = t.button === 2 || n;
636
- (!a.modal || r) && (s.current = !0);
637
- }),
638
- style: {
639
- ...e.style,
640
- "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
641
- "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
642
- "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
643
- "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
644
- "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
645
- }
646
- });
647
- });
648
- Mt.displayName = jt;
649
- var Nt = "DropdownMenuGroup", Pt = A.forwardRef((e, t) => {
650
- let { __scopeDropdownMenu: n, ...r } = e;
651
- return /* @__PURE__ */ j(dt, {
652
- ...$(n),
653
- ...r,
654
- ref: t
655
- });
656
- });
657
- Pt.displayName = Nt;
658
- var Ft = "DropdownMenuLabel", It = A.forwardRef((e, t) => {
659
- let { __scopeDropdownMenu: n, ...r } = e;
660
- return /* @__PURE__ */ j(ft, {
661
- ...$(n),
662
- ...r,
663
- ref: t
664
- });
665
- });
666
- It.displayName = Ft;
667
- var Lt = "DropdownMenuItem", Rt = A.forwardRef((e, t) => {
668
- let { __scopeDropdownMenu: n, ...r } = e;
669
- return /* @__PURE__ */ j(pt, {
670
- ...$(n),
671
- ...r,
672
- ref: t
673
- });
674
- });
675
- Rt.displayName = Lt;
676
- var zt = "DropdownMenuCheckboxItem", Bt = A.forwardRef((e, t) => {
677
- let { __scopeDropdownMenu: n, ...r } = e;
678
- return /* @__PURE__ */ j(mt, {
679
- ...$(n),
680
- ...r,
681
- ref: t
682
- });
683
- });
684
- Bt.displayName = zt;
685
- var Vt = "DropdownMenuRadioGroup", Ht = A.forwardRef((e, t) => {
686
- let { __scopeDropdownMenu: n, ...r } = e;
687
- return /* @__PURE__ */ j(ht, {
688
- ...$(n),
689
- ...r,
690
- ref: t
691
- });
692
- });
693
- Ht.displayName = Vt;
694
- var Ut = "DropdownMenuRadioItem", Wt = A.forwardRef((e, t) => {
695
- let { __scopeDropdownMenu: n, ...r } = e;
696
- return /* @__PURE__ */ j(gt, {
697
- ...$(n),
698
- ...r,
699
- ref: t
700
- });
701
- });
702
- Wt.displayName = Ut;
703
- var Gt = "DropdownMenuItemIndicator", Kt = A.forwardRef((e, t) => {
704
- let { __scopeDropdownMenu: n, ...r } = e;
705
- return /* @__PURE__ */ j(_t, {
706
- ...$(n),
707
- ...r,
708
- ref: t
709
- });
710
- });
711
- Kt.displayName = Gt;
712
- var qt = "DropdownMenuSeparator", Jt = A.forwardRef((e, t) => {
713
- let { __scopeDropdownMenu: n, ...r } = e;
714
- return /* @__PURE__ */ j(vt, {
715
- ...$(n),
716
- ...r,
717
- ref: t
718
- });
719
- });
720
- Jt.displayName = qt;
721
- var Yt = "DropdownMenuArrow", Xt = A.forwardRef((e, t) => {
722
- let { __scopeDropdownMenu: n, ...r } = e;
723
- return /* @__PURE__ */ j(yt, {
724
- ...$(n),
725
- ...r,
726
- ref: t
727
- });
728
- });
729
- Xt.displayName = Yt;
730
- var Zt = "DropdownMenuSubTrigger", Qt = A.forwardRef((e, t) => {
731
- let { __scopeDropdownMenu: n, ...r } = e;
732
- return /* @__PURE__ */ j(bt, {
733
- ...$(n),
734
- ...r,
735
- ref: t
736
- });
737
- });
738
- Qt.displayName = Zt;
739
- var $t = "DropdownMenuSubContent", en = A.forwardRef((e, t) => {
740
- let { __scopeDropdownMenu: n, ...r } = e;
741
- return /* @__PURE__ */ j(xt, {
742
- ...$(n),
743
- ...r,
744
- ref: t,
745
- style: {
746
- ...e.style,
747
- "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
748
- "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
749
- "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
750
- "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
751
- "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
752
- }
753
- });
754
- });
755
- en.displayName = $t;
756
- var tn = Et, nn = Ot, rn = At, an = Mt, on = It, sn = Rt, cn = Bt, ln = Kt, un = Jt, dn = (e, t) => t === "multiple" ? Array.isArray(e) ? e : e ? [e] : [] : Array.isArray(e) ? e[0] ?? "" : e ?? "", fn = (e) => e.type !== "separator" && e.type !== "label", pn = ({ align: t = "start", asChild: n = !0, alignOffset: r = 0, avoidCollisions: i = !0, className: a, collisionBoundary: o, collisionPadding: s = 10, contentClassName: c, dataTestId: l, defaultOpen: u, defaultValue: d, disabled: f = !1, dropdownWidth: b = "content", emptyMessage: ee = "No options found", loadingMessage: x = "Loading…", modal: te = !0, onOpenChange: S, onValueChange: ne, open: re, options: C, selectionMode: w = "single", side: T = "bottom", sideOffset: ie = 4, state: E = "default", trigger: ae, value: O }) => {
757
- let [k, A] = y({
758
- value: re,
759
- defaultValue: u ?? !1,
760
- onChange: S
761
- }), { dropdownShiftStyle: N, setDropdownElement: P } = D(k), F = dn(d, w), [I, L] = y({
762
- value: O === void 0 ? void 0 : dn(O, w),
763
- defaultValue: F,
764
- onChange: ne
765
- }), { dropdownWidthMode: R, dropdownWidthStyle: z } = _({
766
- dropdownWidth: b,
767
- triggerWidth: "var(--radix-dropdown-menu-trigger-width)"
768
- }), B = f || E === "loading", oe = C.filter(fn), se = (e) => w === "multiple" ? (Array.isArray(I) ? I : []).includes(e) : I === e, V = (e) => {
769
- if (w === "multiple") {
770
- let t = Array.isArray(I) ? I : [];
771
- L(t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
772
- return;
773
- }
774
- L(e), A(!1);
775
- }, H = (t, n) => {
776
- if (t.type === "separator") return /* @__PURE__ */ j(un, {
777
- className: "-mx-1 my-1 h-px bg-border-secondary",
778
- "data-testid": "spectral-dropdown-menu-separator"
779
- }, t.id ?? `separator-${n}`);
780
- if (t.type === "label") return /* @__PURE__ */ j(on, {
781
- className: "px-2 py-1.5 text-base font-semibold text-text-primary",
782
- "data-testid": "spectral-dropdown-menu-label",
783
- children: t.label
784
- }, t.id ?? `label-${n}`);
785
- let r = se(t.value), i = p(v(!!t.disabled, !1, r), "group/spectral-dropdown-menu-item pr-2 gap-4 relative flex w-full justify-between");
786
- return w === "multiple" || t.type === "checkbox" ? /* @__PURE__ */ M(cn, {
787
- checked: r,
788
- className: i,
789
- "data-testid": "spectral-dropdown-menu-checkbox-item",
790
- disabled: t.disabled,
791
- onCheckedChange: () => V(t.value),
792
- onSelect: (e) => e.preventDefault(),
793
- children: [
794
- /* @__PURE__ */ j("span", {
795
- className: "min-w-0 flex-1 truncate whitespace-nowrap",
796
- children: t.label
797
- }),
798
- t.shortcut && /* @__PURE__ */ j("span", {
799
- className: "text-xs tracking-widest ml-auto text-input-text-placeholder",
800
- children: t.shortcut
801
- }),
802
- /* @__PURE__ */ j("span", {
803
- "aria-hidden": "true",
804
- className: "ml-2 size-4 flex shrink-0 items-center justify-center",
805
- children: /* @__PURE__ */ j(ln, {
806
- asChild: !0,
807
- children: /* @__PURE__ */ j("span", {
808
- className: "size-4 flex items-center justify-center",
809
- children: /* @__PURE__ */ j(e, { size: 16 })
810
- })
811
- })
812
- })
813
- ]
814
- }, t.value) : /* @__PURE__ */ M(sn, {
815
- className: i,
816
- "data-testid": "spectral-dropdown-menu-item",
817
- disabled: t.disabled,
818
- onSelect: () => V(t.value),
819
- children: [
820
- /* @__PURE__ */ j("span", {
821
- className: "min-w-0 flex-1 truncate whitespace-nowrap",
822
- children: t.label
823
- }),
824
- t.shortcut && /* @__PURE__ */ j("span", {
825
- className: "text-xs tracking-widest ml-auto text-input-text-placeholder",
826
- children: t.shortcut
827
- }),
828
- /* @__PURE__ */ j("span", {
829
- "aria-hidden": "true",
830
- className: "ml-2 size-4 flex shrink-0 items-center justify-center",
831
- children: r && /* @__PURE__ */ j(e, { size: 16 })
832
- })
833
- ]
834
- }, t.value);
835
- };
836
- return /* @__PURE__ */ M(tn, {
837
- modal: te,
838
- onOpenChange: A,
839
- open: k,
840
- children: [/* @__PURE__ */ j(nn, {
841
- asChild: n,
842
- className: p(a, "transition-opacity duration-200 hover:cursor-pointer hover:opacity-80"),
843
- "data-testid": l ?? "spectral-dropdown-menu-trigger",
844
- disabled: B,
845
- children: ae
846
- }), /* @__PURE__ */ j(rn, { children: /* @__PURE__ */ j(an, {
847
- align: t,
848
- alignOffset: r,
849
- avoidCollisions: i,
850
- className: p("p-1 relative z-50 motion-safe:data-[state=closed]:animate-out motion-safe:data-[state=open]:animate-in", g(), "motion-safe:data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:zoom-out-95 motion-safe:data-[state=open]:fade-in-0 motion-safe:data-[state=open]:zoom-in-95", "max-h-[min(var(--radix-dropdown-menu-content-available-height),300px)] motion-safe:data-[side=bottom]:slide-in-from-top-2 motion-safe:data-[side=top]:slide-in-from-bottom-2", "min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto", c),
851
- collisionBoundary: o,
852
- collisionPadding: s,
853
- "data-dropdown-width-mode": R,
854
- "data-dropdown-width-value": R === "custom" ? b : void 0,
855
- "data-testid": "spectral-dropdown-menu-content",
856
- ref: P,
857
- side: T,
858
- sideOffset: ie,
859
- style: {
860
- ...z,
861
- ...N
862
- },
863
- children: E === "loading" ? /* @__PURE__ */ j(h, { message: x }) : oe.length === 0 ? /* @__PURE__ */ j(m, { message: ee }) : C.map(H)
864
- }) })]
865
- });
866
- };
867
- pn.displayName = "DropdownMenu";
868
- //#endregion
869
- export { pn as DropdownMenu };
2
+ import { t as e } from "./DropdownMenu-B8I8IRcu.js";
3
+ export { e as DropdownMenu };