@spear-ai/spectral 1.3.56 → 1.3.57

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,41 +1,512 @@
1
1
  "use client";
2
2
  import "./styles/main.css";
3
- import { jsx as t, jsxs as d } from "react/jsx-runtime";
4
- import { RadioGroup as l, RadioGroupItem as n, RadioGroupIndicator as m } from "./RadioGroup/RadioGroupBase.js";
5
- import { c as e } from "./twUtils-CRiPKpXj.js";
6
- import { createContext as u, useContext as p } from "react";
7
- import { c as f } from "./createLucideIcon-CI1yJrZf.js";
8
- /**
9
- * @license lucide-react v0.542.0 - ISC
10
- *
11
- * This source code is licensed under the ISC license.
12
- * See the LICENSE file in the root directory of this source tree.
13
- */
14
- const x = [["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]], y = f("circle", x), i = u({
15
- variant: "default"
16
- }), v = ({ className: r, variant: o = "default", ...a }) => /* @__PURE__ */ t(i.Provider, { value: { variant: o }, children: /* @__PURE__ */ t(
17
- l,
18
- {
19
- "data-slot": "radio-group",
20
- className: e("grid gap-3", r),
21
- variant: o,
3
+ import { jsx as n, jsxs as N } from "react/jsx-runtime";
4
+ import { Label as O } from "./Label.js";
5
+ import * as c from "react";
6
+ import { createContext as Re, forwardRef as A, useMemo as ge, memo as Ie, useContext as he } from "react";
7
+ import { c as K, b as we, P as F, e as w, a as G, d as Y, h as ye } from "./index-CA7haECj.js";
8
+ import { c as Ce, u as j, a as Ee } from "./index-CbXx14YO.js";
9
+ import { u as Se } from "./index-Cb7rjMhE.js";
10
+ import { P as Fe } from "./index-CBwRmAsQ.js";
11
+ import { c as S } from "./twUtils-CRiPKpXj.js";
12
+ var L = "rovingFocusGroup.onEntryFocus", xe = { bubbles: !1, cancelable: !0 }, x = "RovingFocusGroup", [M, z, Ne] = Ce(x), [_e, H] = K(
13
+ x,
14
+ [Ne]
15
+ ), [Ae, Ge] = _e(x), $ = c.forwardRef(
16
+ (e, t) => /* @__PURE__ */ n(M.Provider, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ n(M.Slot, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ n(Pe, { ...e, ref: t }) }) })
17
+ );
18
+ $.displayName = x;
19
+ var Pe = c.forwardRef((e, t) => {
20
+ const {
21
+ __scopeRovingFocusGroup: o,
22
+ orientation: r,
23
+ loop: a = !1,
24
+ dir: s,
25
+ currentTabStopId: i,
26
+ defaultCurrentTabStopId: v,
27
+ onCurrentTabStopIdChange: b,
28
+ onEntryFocus: d,
29
+ preventScrollOnEntryFocus: u = !1,
30
+ ...R
31
+ } = e, m = c.useRef(null), l = G(t, m), f = j(s), [g, p] = Y({
32
+ prop: i,
33
+ defaultProp: v ?? null,
34
+ onChange: b,
35
+ caller: x
36
+ }), [y, T] = c.useState(!1), h = ye(d), C = z(o), k = c.useRef(!1), [fe, V] = c.useState(0);
37
+ return c.useEffect(() => {
38
+ const I = m.current;
39
+ if (I)
40
+ return I.addEventListener(L, h), () => I.removeEventListener(L, h);
41
+ }, [h]), /* @__PURE__ */ n(
42
+ Ae,
43
+ {
44
+ scope: o,
45
+ orientation: r,
46
+ dir: f,
47
+ loop: a,
48
+ currentTabStopId: g,
49
+ onItemFocus: c.useCallback(
50
+ (I) => p(I),
51
+ [p]
52
+ ),
53
+ onItemShiftTab: c.useCallback(() => T(!0), []),
54
+ onFocusableItemAdd: c.useCallback(
55
+ () => V((I) => I + 1),
56
+ []
57
+ ),
58
+ onFocusableItemRemove: c.useCallback(
59
+ () => V((I) => I - 1),
60
+ []
61
+ ),
62
+ children: /* @__PURE__ */ n(
63
+ F.div,
64
+ {
65
+ tabIndex: y || fe === 0 ? -1 : 0,
66
+ "data-orientation": r,
67
+ ...R,
68
+ ref: l,
69
+ style: { outline: "none", ...e.style },
70
+ onMouseDown: w(e.onMouseDown, () => {
71
+ k.current = !0;
72
+ }),
73
+ onFocus: w(e.onFocus, (I) => {
74
+ const pe = !k.current;
75
+ if (I.target === I.currentTarget && pe && !y) {
76
+ const q = new CustomEvent(L, xe);
77
+ if (I.currentTarget.dispatchEvent(q), !q.defaultPrevented) {
78
+ const D = C().filter((E) => E.focusable), me = D.find((E) => E.active), ve = D.find((E) => E.id === g), be = [me, ve, ...D].filter(
79
+ Boolean
80
+ ).map((E) => E.ref.current);
81
+ J(be, u);
82
+ }
83
+ }
84
+ k.current = !1;
85
+ }),
86
+ onBlur: w(e.onBlur, () => T(!1))
87
+ }
88
+ )
89
+ }
90
+ );
91
+ }), W = "RovingFocusGroupItem", X = c.forwardRef(
92
+ (e, t) => {
93
+ const {
94
+ __scopeRovingFocusGroup: o,
95
+ focusable: r = !0,
96
+ active: a = !1,
97
+ tabStopId: s,
98
+ children: i,
99
+ ...v
100
+ } = e, b = we(), d = s || b, u = Ge(W, o), R = u.currentTabStopId === d, m = z(o), { onFocusableItemAdd: l, onFocusableItemRemove: f, currentTabStopId: g } = u;
101
+ return c.useEffect(() => {
102
+ if (r)
103
+ return l(), () => f();
104
+ }, [r, l, f]), /* @__PURE__ */ n(
105
+ M.ItemSlot,
106
+ {
107
+ scope: o,
108
+ id: d,
109
+ focusable: r,
110
+ active: a,
111
+ children: /* @__PURE__ */ n(
112
+ F.span,
113
+ {
114
+ tabIndex: R ? 0 : -1,
115
+ "data-orientation": u.orientation,
116
+ ...v,
117
+ ref: t,
118
+ onMouseDown: w(e.onMouseDown, (p) => {
119
+ r ? u.onItemFocus(d) : p.preventDefault();
120
+ }),
121
+ onFocus: w(e.onFocus, () => u.onItemFocus(d)),
122
+ onKeyDown: w(e.onKeyDown, (p) => {
123
+ if (p.key === "Tab" && p.shiftKey) {
124
+ u.onItemShiftTab();
125
+ return;
126
+ }
127
+ if (p.target !== p.currentTarget) return;
128
+ const y = De(p, u.orientation, u.dir);
129
+ if (y !== void 0) {
130
+ if (p.metaKey || p.ctrlKey || p.altKey || p.shiftKey) return;
131
+ p.preventDefault();
132
+ let h = m().filter((C) => C.focusable).map((C) => C.ref.current);
133
+ if (y === "last") h.reverse();
134
+ else if (y === "prev" || y === "next") {
135
+ y === "prev" && h.reverse();
136
+ const C = h.indexOf(p.currentTarget);
137
+ h = u.loop ? Le(h, C + 1) : h.slice(C + 1);
138
+ }
139
+ setTimeout(() => J(h));
140
+ }
141
+ }),
142
+ children: typeof i == "function" ? i({ isCurrentTabStop: R, hasTabStop: g != null }) : i
143
+ }
144
+ )
145
+ }
146
+ );
147
+ }
148
+ );
149
+ X.displayName = W;
150
+ var Te = {
151
+ ArrowLeft: "prev",
152
+ ArrowUp: "prev",
153
+ ArrowRight: "next",
154
+ ArrowDown: "next",
155
+ PageUp: "first",
156
+ Home: "first",
157
+ PageDown: "last",
158
+ End: "last"
159
+ };
160
+ function ke(e, t) {
161
+ return t !== "rtl" ? e : e === "ArrowLeft" ? "ArrowRight" : e === "ArrowRight" ? "ArrowLeft" : e;
162
+ }
163
+ function De(e, t, o) {
164
+ const r = ke(e.key, o);
165
+ if (!(t === "vertical" && ["ArrowLeft", "ArrowRight"].includes(r)) && !(t === "horizontal" && ["ArrowUp", "ArrowDown"].includes(r)))
166
+ return Te[r];
167
+ }
168
+ function J(e, t = !1) {
169
+ const o = document.activeElement;
170
+ for (const r of e)
171
+ if (r === o || (r.focus({ preventScroll: t }), document.activeElement !== o)) return;
172
+ }
173
+ function Le(e, t) {
174
+ return e.map((o, r) => e[(t + r) % e.length]);
175
+ }
176
+ var Oe = $, Me = X, U = "Radio", [Be, Q] = K(U), [Ke, Ue] = Be(U), Z = c.forwardRef(
177
+ (e, t) => {
178
+ const {
179
+ __scopeRadio: o,
180
+ name: r,
181
+ checked: a = !1,
182
+ required: s,
183
+ disabled: i,
184
+ value: v = "on",
185
+ onCheck: b,
186
+ form: d,
187
+ ...u
188
+ } = e, [R, m] = c.useState(null), l = G(t, (p) => m(p)), f = c.useRef(!1), g = R ? d || !!R.closest("form") : !0;
189
+ return /* @__PURE__ */ N(Ke, { scope: o, checked: a, disabled: i, children: [
190
+ /* @__PURE__ */ n(
191
+ F.button,
192
+ {
193
+ type: "button",
194
+ role: "radio",
195
+ "aria-checked": a,
196
+ "data-state": re(a),
197
+ "data-disabled": i ? "" : void 0,
198
+ disabled: i,
199
+ value: v,
200
+ ...u,
201
+ ref: l,
202
+ onClick: w(e.onClick, (p) => {
203
+ a || b?.(), g && (f.current = p.isPropagationStopped(), f.current || p.stopPropagation());
204
+ })
205
+ }
206
+ ),
207
+ g && /* @__PURE__ */ n(
208
+ te,
209
+ {
210
+ control: R,
211
+ bubbles: !f.current,
212
+ name: r,
213
+ value: v,
214
+ checked: a,
215
+ required: s,
216
+ disabled: i,
217
+ form: d,
218
+ style: { transform: "translateX(-100%)" }
219
+ }
220
+ )
221
+ ] });
222
+ }
223
+ );
224
+ Z.displayName = U;
225
+ var ee = "RadioIndicator", oe = c.forwardRef(
226
+ (e, t) => {
227
+ const { __scopeRadio: o, forceMount: r, ...a } = e, s = Ue(ee, o);
228
+ return /* @__PURE__ */ n(Fe, { present: r || s.checked, children: /* @__PURE__ */ n(
229
+ F.span,
230
+ {
231
+ "data-state": re(s.checked),
232
+ "data-disabled": s.disabled ? "" : void 0,
233
+ ...a,
234
+ ref: t
235
+ }
236
+ ) });
237
+ }
238
+ );
239
+ oe.displayName = ee;
240
+ var Ve = "RadioBubbleInput", te = c.forwardRef(
241
+ ({
242
+ __scopeRadio: e,
243
+ control: t,
244
+ checked: o,
245
+ bubbles: r = !0,
22
246
  ...a
247
+ }, s) => {
248
+ const i = c.useRef(null), v = G(i, s), b = Ee(o), d = Se(t);
249
+ return c.useEffect(() => {
250
+ const u = i.current;
251
+ if (!u) return;
252
+ const R = window.HTMLInputElement.prototype, l = Object.getOwnPropertyDescriptor(
253
+ R,
254
+ "checked"
255
+ ).set;
256
+ if (b !== o && l) {
257
+ const f = new Event("click", { bubbles: r });
258
+ l.call(u, o), u.dispatchEvent(f);
259
+ }
260
+ }, [b, o, r]), /* @__PURE__ */ n(
261
+ F.input,
262
+ {
263
+ type: "radio",
264
+ "aria-hidden": !0,
265
+ defaultChecked: o,
266
+ ...a,
267
+ tabIndex: -1,
268
+ ref: v,
269
+ style: {
270
+ ...a.style,
271
+ ...d,
272
+ position: "absolute",
273
+ pointerEvents: "none",
274
+ opacity: 0,
275
+ margin: 0
276
+ }
277
+ }
278
+ );
23
279
  }
24
- ) }), C = ({ className: r, children: o, ...a }) => {
25
- const { variant: s } = p(i), c = s === "unstyled";
26
- return /* @__PURE__ */ d(n, { "data-slot": "radio-group-item", className: e(r), ...a, children: [
27
- !c && /* @__PURE__ */ t(
28
- m,
280
+ );
281
+ te.displayName = Ve;
282
+ function re(e) {
283
+ return e ? "checked" : "unchecked";
284
+ }
285
+ var qe = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"], P = "RadioGroup", [Ye] = K(P, [
286
+ H,
287
+ Q
288
+ ]), ae = H(), ne = Q(), [je, ze] = Ye(P), se = c.forwardRef(
289
+ (e, t) => {
290
+ const {
291
+ __scopeRadioGroup: o,
292
+ name: r,
293
+ defaultValue: a,
294
+ value: s,
295
+ required: i = !1,
296
+ disabled: v = !1,
297
+ orientation: b,
298
+ dir: d,
299
+ loop: u = !0,
300
+ onValueChange: R,
301
+ ...m
302
+ } = e, l = ae(o), f = j(d), [g, p] = Y({
303
+ prop: s,
304
+ defaultProp: a ?? null,
305
+ onChange: R,
306
+ caller: P
307
+ });
308
+ return /* @__PURE__ */ n(
309
+ je,
29
310
  {
30
- "data-slot": "radio-group-indicator",
31
- className: "relative flex items-center justify-center",
32
- children: /* @__PURE__ */ t(y, { className: "fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2" })
311
+ scope: o,
312
+ name: r,
313
+ required: i,
314
+ disabled: v,
315
+ value: g,
316
+ onValueChange: p,
317
+ children: /* @__PURE__ */ n(
318
+ Oe,
319
+ {
320
+ asChild: !0,
321
+ ...l,
322
+ orientation: b,
323
+ dir: f,
324
+ loop: u,
325
+ children: /* @__PURE__ */ n(
326
+ F.div,
327
+ {
328
+ role: "radiogroup",
329
+ "aria-required": i,
330
+ "aria-orientation": b,
331
+ "data-disabled": v ? "" : void 0,
332
+ dir: f,
333
+ ...m,
334
+ ref: t
335
+ }
336
+ )
337
+ }
338
+ )
33
339
  }
34
- ),
35
- o
36
- ] });
37
- };
340
+ );
341
+ }
342
+ );
343
+ se.displayName = P;
344
+ var ie = "RadioGroupItem", ce = c.forwardRef(
345
+ (e, t) => {
346
+ const { __scopeRadioGroup: o, disabled: r, ...a } = e, s = ze(ie, o), i = s.disabled || r, v = ae(o), b = ne(o), d = c.useRef(null), u = G(t, d), R = s.value === a.value, m = c.useRef(!1);
347
+ return c.useEffect(() => {
348
+ const l = (g) => {
349
+ qe.includes(g.key) && (m.current = !0);
350
+ }, f = () => m.current = !1;
351
+ return document.addEventListener("keydown", l), document.addEventListener("keyup", f), () => {
352
+ document.removeEventListener("keydown", l), document.removeEventListener("keyup", f);
353
+ };
354
+ }, []), /* @__PURE__ */ n(
355
+ Me,
356
+ {
357
+ asChild: !0,
358
+ ...v,
359
+ focusable: !i,
360
+ active: R,
361
+ children: /* @__PURE__ */ n(
362
+ Z,
363
+ {
364
+ disabled: i,
365
+ required: s.required,
366
+ checked: R,
367
+ ...b,
368
+ ...a,
369
+ name: s.name,
370
+ ref: u,
371
+ onCheck: () => s.onValueChange(a.value),
372
+ onKeyDown: w((l) => {
373
+ l.key === "Enter" && l.preventDefault();
374
+ }),
375
+ onFocus: w(a.onFocus, () => {
376
+ m.current && d.current?.click();
377
+ })
378
+ }
379
+ )
380
+ }
381
+ );
382
+ }
383
+ );
384
+ ce.displayName = ie;
385
+ var He = "RadioGroupIndicator", ue = c.forwardRef(
386
+ (e, t) => {
387
+ const { __scopeRadioGroup: o, ...r } = e, a = ne(o);
388
+ return /* @__PURE__ */ n(oe, { ...a, ...r, ref: t });
389
+ }
390
+ );
391
+ ue.displayName = He;
392
+ var $e = se, de = ce, We = ue;
393
+ const le = Re({
394
+ orientation: "vertical",
395
+ variant: "default",
396
+ disabledValues: [],
397
+ groupDisabled: !1
398
+ }), _ = "pointer-events-none opacity-60", Xe = A(
399
+ ({
400
+ className: e,
401
+ itemClassName: t,
402
+ onValueChange: o,
403
+ orientation: r = "vertical",
404
+ disabled: a,
405
+ selected: s,
406
+ variant: i = "default",
407
+ ...v
408
+ }, b) => {
409
+ const d = ge(
410
+ () => ({
411
+ orientation: r,
412
+ variant: i,
413
+ disabledValues: Array.isArray(a) ? a : [],
414
+ groupDisabled: typeof a == "boolean" ? a : !1,
415
+ itemClassName: t,
416
+ selected: s
417
+ }),
418
+ [r, i, a, t, s]
419
+ );
420
+ return /* @__PURE__ */ n(le.Provider, { value: d, children: /* @__PURE__ */ n(
421
+ $e,
422
+ {
423
+ className: S(
424
+ "text-text-primary flex w-full",
425
+ r === "vertical" ? "flex-col gap-4" : "flex-row gap-4",
426
+ e
427
+ ),
428
+ ref: b,
429
+ onValueChange: o,
430
+ value: s,
431
+ disabled: d.groupDisabled,
432
+ ...v
433
+ }
434
+ ) });
435
+ }
436
+ );
437
+ Xe.displayName = "RadioGroup";
438
+ const B = Ie(
439
+ A(({ value: e, id: t, isDisabled: o, className: r, ...a }, s) => /* @__PURE__ */ n(
440
+ de,
441
+ {
442
+ ref: s,
443
+ className: S(
444
+ "border-border-subtle bg-radio-bg relative aspect-square h-4.5 w-4.5 cursor-pointer rounded-full border-2 ring-black transition-colors",
445
+ "hover:border-radio-border--hover focus-visible:ring-1 focus-visible:ring-offset-2",
446
+ "[&[data-state=checked]]:border-radio-border--selected [&[data-state=checked]]:bg-radio-bg",
447
+ o && _,
448
+ r
449
+ ),
450
+ disabled: o,
451
+ value: e,
452
+ id: t,
453
+ ...a,
454
+ children: /* @__PURE__ */ n(We, { className: "after:bg-radio-bg--selected transition-colors after:absolute after:inset-0 after:m-auto after:h-2.5 after:w-2.5 after:rounded-full after:content-['']" })
455
+ }
456
+ ))
457
+ );
458
+ B.displayName = "RadioButton";
459
+ const Je = A(
460
+ ({ className: e, children: t, value: o, description: r, disabled: a, ...s }, i) => {
461
+ const { disabledValues: v, groupDisabled: b, itemClassName: d, variant: u, selected: R } = he(le), m = o.toString(), l = s.id?.toString() || m, f = b || v.includes(m) || !!a, g = R === m;
462
+ return u === "tiles" ? /* @__PURE__ */ n(
463
+ O,
464
+ {
465
+ htmlFor: l,
466
+ className: S(
467
+ "border-border-subtle flex w-full cursor-pointer items-start rounded-xl border p-4",
468
+ g && "border-tile-border--selected bg-tile-bg--selected",
469
+ f && _,
470
+ d,
471
+ e
472
+ ),
473
+ children: /* @__PURE__ */ N("div", { className: "flex w-full items-start justify-between gap-4", children: [
474
+ /* @__PURE__ */ n("div", { className: "relative top-0.75 mr-3 flex-shrink-0", children: /* @__PURE__ */ n(B, { ref: i, value: m, id: l, isDisabled: f, ...s }) }),
475
+ /* @__PURE__ */ N("div", { className: "flex flex-grow flex-col", children: [
476
+ /* @__PURE__ */ n("div", { className: "font-bold", children: t }),
477
+ r && /* @__PURE__ */ n("div", { className: "mt-1 text-sm", children: r })
478
+ ] })
479
+ ] })
480
+ }
481
+ ) : u === "unstyled" ? /* @__PURE__ */ n(
482
+ de,
483
+ {
484
+ ref: i,
485
+ value: m,
486
+ id: l,
487
+ disabled: f,
488
+ className: S(
489
+ "[&[data-state=checked]]:border-radio-border--selected flex h-fit w-fit rounded border-2 border-transparent",
490
+ f && _,
491
+ d,
492
+ e
493
+ ),
494
+ ...s,
495
+ children: t
496
+ }
497
+ ) : /* @__PURE__ */ N("div", { className: S("flex items-center", f && _, d, e), children: [
498
+ /* @__PURE__ */ n(B, { ref: i, value: m, id: l, isDisabled: f, ...s }),
499
+ t && /* @__PURE__ */ n(O, { className: "text-md ml-2 cursor-pointer font-normal", htmlFor: l, children: t })
500
+ ] });
501
+ }
502
+ );
503
+ Je.displayName = "RadioGroup.Item";
504
+ const Qe = A(
505
+ ({ className: e, ...t }, o) => /* @__PURE__ */ n(O, { ref: o, className: S("text-md block font-medium", e), ...t })
506
+ );
507
+ Qe.displayName = "RadioGroup.Label";
38
508
  export {
39
- v as RadioGroup,
40
- C as RadioGroupItem
509
+ Xe as RadioGroup,
510
+ Je as RadioGroupItem,
511
+ Qe as RadioGroupLabel
41
512
  };