@spear-ai/spectral 1.3.44 → 1.3.46

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 (80) hide show
  1. package/dist/.js +150 -146
  2. package/dist/Accordion/AccordionBase.js +141 -150
  3. package/dist/ButtonIcon.d.ts +14 -0
  4. package/dist/ButtonIcon.js +119 -0
  5. package/dist/Checkbox/CheckboxBase.js +6 -5
  6. package/dist/Icons/AnnotationsIcon.js +6 -5
  7. package/dist/Icons/CalendarIcon.js +4 -3
  8. package/dist/Icons/CheckCircleIcon.js +6 -5
  9. package/dist/Icons/CheckSquareIcon.js +6 -5
  10. package/dist/Icons/ChevronDownIcon.js +6 -5
  11. package/dist/Icons/ChevronUpIcon.js +9 -8
  12. package/dist/Icons/ClockIcon.js +11 -10
  13. package/dist/Icons/CloseCircleIcon.js +12 -11
  14. package/dist/Icons/CloseIcon.js +10 -9
  15. package/dist/Icons/DashboardIcon.js +6 -5
  16. package/dist/Icons/DeleteIcon.js +10 -9
  17. package/dist/Icons/DurationIcon.js +3 -2
  18. package/dist/Icons/EraserIcon.js +12 -11
  19. package/dist/Icons/ErrorIcon.js +3 -2
  20. package/dist/Icons/EyeClosedIcon.js +9 -8
  21. package/dist/Icons/EyeClosedIcon2.js +6 -5
  22. package/dist/Icons/EyeOpenIcon.js +11 -10
  23. package/dist/Icons/GoToFirstIcon.js +5 -4
  24. package/dist/Icons/GoToLastIcon.js +6 -5
  25. package/dist/Icons/HarmonicCursorsIcon.js +10 -9
  26. package/dist/Icons/InfoIcon.js +9 -8
  27. package/dist/Icons/LabelIcon.js +6 -5
  28. package/dist/Icons/LassoIcon.js +8 -7
  29. package/dist/Icons/LineToolIcon.js +9 -8
  30. package/dist/Icons/LiveViewIcon.js +7 -6
  31. package/dist/Icons/LoaderIcon.js +6 -5
  32. package/dist/Icons/LocationIcon.js +12 -11
  33. package/dist/Icons/LogoutIcon.js +4 -3
  34. package/dist/Icons/MetadataIcon.js +6 -5
  35. package/dist/Icons/OntologyIcon.js +3 -2
  36. package/dist/Icons/PanelIcon.js +4 -3
  37. package/dist/Icons/PlayIcon.js +8 -7
  38. package/dist/Icons/PlusIcon.js +8 -7
  39. package/dist/Icons/ResetIcon.js +14 -13
  40. package/dist/Icons/ScissorsIcon.js +7 -6
  41. package/dist/Icons/SettingsIcon.js +3 -2
  42. package/dist/Icons/TrashIcon.js +9 -8
  43. package/dist/Icons/UndoIcon.js +6 -5
  44. package/dist/Icons/UserIcon.js +7 -6
  45. package/dist/Icons/WarningIcon.js +13 -12
  46. package/dist/Icons/ZoomAllIcon.js +7 -6
  47. package/dist/Icons/ZoomXIcon.js +9 -8
  48. package/dist/Icons/ZoomYIcon.js +9 -8
  49. package/dist/Input.d.ts +2 -0
  50. package/dist/Input.js +48 -46
  51. package/dist/RadioGroup/RadioGroupBase.js +130 -138
  52. package/dist/Switch/SwitchBase.js +22 -21
  53. package/dist/Toggle/ToggleBase.js +4 -4
  54. package/dist/ToggleGroup/ToggleGroupBase.js +6 -5
  55. package/dist/components/Accordion/AccordionBase.d.ts.map +1 -1
  56. package/dist/components/ButtonIcon/ButtonIcon.d.ts +14 -0
  57. package/dist/components/ButtonIcon/ButtonIcon.d.ts.map +1 -0
  58. package/dist/components/Checkbox/CheckboxBase.d.ts.map +1 -1
  59. package/dist/components/Input/Input.d.ts +2 -0
  60. package/dist/components/Input/Input.d.ts.map +1 -1
  61. package/dist/components/RadioGroup/RadioGroupBase.d.ts.map +1 -1
  62. package/dist/components/Switch/SwitchBase.d.ts.map +1 -1
  63. package/dist/components/Toggle/ToggleBase.d.ts.map +1 -1
  64. package/dist/components/ToggleGroup/ToggleGroupBase.d.ts.map +1 -1
  65. package/dist/hooks/useControllableState.d.ts +9 -0
  66. package/dist/hooks/useControllableState.d.ts.map +1 -0
  67. package/dist/hooks/useControllableState.js +15 -0
  68. package/dist/index.d.ts +2 -0
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/styles/main.css +1 -1
  71. package/dist/utils/sharedUtils.d.ts +2 -0
  72. package/dist/utils/sharedUtils.d.ts.map +1 -0
  73. package/dist/utils/sharedUtils.js +6 -0
  74. package/package.json +1 -1
  75. package/dist/hooks/useOutsideClick.d.ts +0 -8
  76. package/dist/hooks/useOutsideClick.d.ts.map +0 -1
  77. package/dist/hooks/useOutsideClick.js +0 -16
  78. package/dist/utils/shared.d.ts +0 -24
  79. package/dist/utils/shared.d.ts.map +0 -1
  80. package/dist/utils/shared.js +0 -29
package/dist/Input.js CHANGED
@@ -1,24 +1,24 @@
1
1
  "use client";
2
2
  import "./styles/main.css";
3
3
  import { jsx as t, jsxs as I } from "react/jsx-runtime";
4
- import { usePasswordVisibility as Q, usePrefixWidth as U, useClearOnFocus as X } from "./Input/InputUtils.js";
4
+ import { usePasswordVisibility as U, usePrefixWidth as X, useClearOnFocus as Y } from "./Input/InputUtils.js";
5
5
  import "./Icons/AnnotationsIcon.js";
6
6
  import "./Icons/CalendarIcon.js";
7
- import { CheckCircleIcon as Y } from "./Icons/CheckCircleIcon.js";
7
+ import { CheckCircleIcon as Z } from "./Icons/CheckCircleIcon.js";
8
8
  import "./Icons/CheckSquareIcon.js";
9
9
  import "./Icons/ChevronDownIcon.js";
10
10
  import "./Icons/ChevronUpIcon.js";
11
11
  import "./Icons/ClockIcon.js";
12
- import { CloseCircleIcon as Z } from "./Icons/CloseCircleIcon.js";
12
+ import { CloseCircleIcon as _ } from "./Icons/CloseCircleIcon.js";
13
13
  import "./Icons/CloseIcon.js";
14
14
  import "./Icons/DashboardIcon.js";
15
15
  import "./Icons/DeleteIcon.js";
16
16
  import "./Icons/DurationIcon.js";
17
17
  import "./Icons/EraserIcon.js";
18
- import { ErrorIcon as _ } from "./Icons/ErrorIcon.js";
19
- import { EyeClosedIcon as q } from "./Icons/EyeClosedIcon.js";
18
+ import { ErrorIcon as q } from "./Icons/ErrorIcon.js";
19
+ import { EyeClosedIcon as tt } from "./Icons/EyeClosedIcon.js";
20
20
  import "./Icons/EyeClosedIcon2.js";
21
- import { EyeOpenIcon as tt } from "./Icons/EyeOpenIcon.js";
21
+ import { EyeOpenIcon as et } from "./Icons/EyeOpenIcon.js";
22
22
  import "./Icons/GoToFirstIcon.js";
23
23
  import "./Icons/GoToLastIcon.js";
24
24
  import "./Icons/HarmonicCursorsIcon.js";
@@ -27,7 +27,7 @@ import "./Icons/LabelIcon.js";
27
27
  import "./Icons/LassoIcon.js";
28
28
  import "./Icons/LineToolIcon.js";
29
29
  import "./Icons/LiveViewIcon.js";
30
- import { LoaderIcon as et } from "./Icons/LoaderIcon.js";
30
+ import { LoaderIcon as rt } from "./Icons/LoaderIcon.js";
31
31
  import "./Icons/LocationIcon.js";
32
32
  import "./Icons/LogoutIcon.js";
33
33
  import "./Icons/MetadataIcon.js";
@@ -45,10 +45,10 @@ import "./Icons/WarningIcon.js";
45
45
  import "./Icons/ZoomAllIcon.js";
46
46
  import "./Icons/ZoomXIcon.js";
47
47
  import "./Icons/ZoomYIcon.js";
48
- import { useFormFieldId as rt, getAriaProps as ot, getInputClasses as it, useFormFieldState as st, getFormFieldCSSProperties as at, ErrorMessage as nt } from "./utils/formFieldUtils.js";
48
+ import { useFormFieldId as ot, getAriaProps as it, getInputClasses as st, useFormFieldState as at, getFormFieldCSSProperties as nt, ErrorMessage as pt } from "./utils/formFieldUtils.js";
49
49
  import { c as N } from "./twUtils-CRiPKpXj.js";
50
- import { forwardRef as pt, useRef as lt, useCallback as m } from "react";
51
- const ct = (p) => ({
50
+ import { forwardRef as lt, useRef as ct, useCallback as m } from "react";
51
+ const mt = (p) => ({
52
52
  email: "email",
53
53
  password: "current-password",
54
54
  tel: "tel",
@@ -57,7 +57,7 @@ const ct = (p) => ({
57
57
  number: "off",
58
58
  date: "off",
59
59
  "datetime-local": "off"
60
- })[p] || "off", mt = pt(
60
+ })[p] || "off", dt = lt(
61
61
  ({
62
62
  className: p,
63
63
  clearOnFocus: d = !1,
@@ -71,39 +71,40 @@ const ct = (p) => ({
71
71
  onFocus: C,
72
72
  prefix: a,
73
73
  showClearButton: z = !1,
74
+ suppressHydrationWarning: P = !0,
74
75
  state: e = "default",
75
76
  type: n = "text",
76
77
  value: g = "",
77
78
  required: x,
78
- "aria-label": P,
79
- "aria-describedby": R,
80
- ...$
81
- }, k) => {
82
- const l = rt(E, f), w = `${l}-error`, { isDisabled: S, isLoading: V, isInvalid: M } = st(F, e), O = ot(e, x, w, R), j = lt(null), r = k || j, { isVisible: c, toggleVisibility: A, inputType: B } = Q(), { prefixWidth: H, prefixRef: L } = U(a), { handleFocus: y } = X(d, b), W = m(
79
+ "aria-label": R,
80
+ "aria-describedby": $,
81
+ ...k
82
+ }, S) => {
83
+ const l = ot(E, f), w = `${l}-error`, { isDisabled: V, isLoading: M, isInvalid: O } = at(F, e), j = it(e, x, w, $), A = ct(null), r = S || A, { isVisible: c, toggleVisibility: B, inputType: H } = U(), { prefixWidth: L, prefixRef: W } = X(a), { handleFocus: y } = Y(d, b), D = m(
83
84
  (o) => {
84
85
  h?.(o);
85
86
  },
86
87
  [h]
87
- ), D = m(
88
+ ), T = m(
88
89
  (o) => {
89
90
  y(o, C);
90
91
  },
91
92
  [y, C]
92
- ), T = m(() => {
93
+ ), G = m(() => {
93
94
  r.current && (r.current.value = "", r.current.dispatchEvent(new Event("input", { bubbles: !0 })), r.current.focus());
94
- }, [r]), v = z && g.length > 0, G = () => {
95
+ }, [r]), v = z && g.length > 0, J = () => {
95
96
  const o = "absolute right-4 top-1/2 -translate-y-1/2 text-input-icon hover:text-input-icon--hover focus:outline-none cursor-pointer", s = {
96
97
  password: () => /* @__PURE__ */ t(
97
98
  "button",
98
99
  {
99
100
  className: o,
100
101
  type: "button",
101
- onClick: A,
102
+ onClick: B,
102
103
  "aria-label": c ? `Hide ${i}` : `Show ${i}`,
103
104
  "aria-pressed": c,
104
105
  "aria-controls": l,
105
106
  "data-testid": "input-password-toggle",
106
- children: c ? /* @__PURE__ */ t(q, { size: 22 }) : /* @__PURE__ */ t(tt, { size: 22 })
107
+ children: c ? /* @__PURE__ */ t(tt, { size: 22 }) : /* @__PURE__ */ t(et, { size: 22 })
107
108
  }
108
109
  ),
109
110
  clear: () => /* @__PURE__ */ t(
@@ -111,60 +112,61 @@ const ct = (p) => ({
111
112
  {
112
113
  className: o,
113
114
  type: "button",
114
- onClick: T,
115
+ onClick: G,
115
116
  "aria-label": `Clear ${i}`,
116
117
  "data-testid": "input-clear-button",
117
- children: /* @__PURE__ */ t(Z, { size: 24 })
118
+ children: /* @__PURE__ */ t(_, { size: 24 })
118
119
  }
119
120
  ),
120
- loading: () => /* @__PURE__ */ t("div", { className: "absolute top-1/2 right-4 -translate-y-1/2", "data-testid": "input-loading-icon", children: /* @__PURE__ */ t(et, { size: 24 }) }),
121
- error: () => /* @__PURE__ */ t("div", { className: "text-danger-400 absolute top-1/2 right-4 -translate-y-1/2", "data-testid": "input-error-icon", children: /* @__PURE__ */ t(_, { size: 24 }) }),
122
- success: () => /* @__PURE__ */ t("div", { className: "text-success-400 absolute top-1/2 right-4 -translate-y-1/2", "data-testid": "input-success-icon", children: /* @__PURE__ */ t(Y, { size: 24 }) })
121
+ loading: () => /* @__PURE__ */ t("div", { className: "absolute top-1/2 right-4 -translate-y-1/2", "data-testid": "input-loading-icon", children: /* @__PURE__ */ t(rt, { size: 24 }) }),
122
+ error: () => /* @__PURE__ */ t("div", { className: "text-danger-400 absolute top-1/2 right-4 -translate-y-1/2", "data-testid": "input-error-icon", children: /* @__PURE__ */ t(q, { size: 24 }) }),
123
+ success: () => /* @__PURE__ */ t("div", { className: "text-success-400 absolute top-1/2 right-4 -translate-y-1/2", "data-testid": "input-success-icon", children: /* @__PURE__ */ t(Z, { size: 24 }) })
123
124
  };
124
- return n === "password" ? s.password() : v ? s.clear() : V ? s.loading() : e === "success" ? s.success() : e === "error" ? s.error() : null;
125
- }, J = N(
126
- it(e, p),
125
+ return n === "password" ? s.password() : v ? s.clear() : M ? s.loading() : e === "success" ? s.success() : e === "error" ? s.error() : null;
126
+ }, K = N(
127
+ st(e, p),
127
128
  "[text-indent:var(--prefix-width)]",
128
129
  v && "pr-10"
129
- ), K = N(
130
+ ), Q = N(
130
131
  "pointer-events-none absolute inset-y-0 left-4 flex items-center text-base text-input-text-prefix opacity-100 peer-disabled:opacity-50"
131
132
  );
132
133
  return /* @__PURE__ */ t("div", { className: "w-full space-y-1.5", "data-testid": "input-root", children: /* @__PURE__ */ I("div", { className: "relative", "data-testid": "input-wrapper", children: [
133
134
  /* @__PURE__ */ I("div", { className: "relative", children: [
134
- a && /* @__PURE__ */ t("span", { ref: L, className: K, children: a }),
135
+ a && /* @__PURE__ */ t("span", { ref: W, className: Q, children: a }),
135
136
  /* @__PURE__ */ t(
136
137
  "input",
137
138
  {
138
139
  id: l,
139
140
  name: f,
140
141
  ref: r,
141
- type: n === "password" ? B : n,
142
+ type: n === "password" ? H : n,
142
143
  value: g,
143
- disabled: S,
144
+ disabled: V,
144
145
  required: x,
145
- autoComplete: ct(n),
146
- className: J,
146
+ autoComplete: mt(n),
147
+ className: K,
147
148
  onChange: b,
148
- onFocus: D,
149
- onBlur: W,
149
+ onFocus: T,
150
+ onBlur: D,
150
151
  placeholder: i,
151
- ...O,
152
- ...$,
152
+ suppressHydrationWarning: P,
153
+ ...j,
154
+ ...k,
153
155
  "data-testid": "input-input",
154
156
  "data-state": e,
155
- style: at({
156
- "--prefix-width": a ? `${H}px` : "0px"
157
+ style: nt({
158
+ "--prefix-width": a ? `${L}px` : "0px"
157
159
  }),
158
- "aria-label": P || i
160
+ "aria-label": R || i
159
161
  }
160
162
  ),
161
- G()
163
+ J()
162
164
  ] }),
163
- M && u && /* @__PURE__ */ t(nt, { id: w, message: u })
165
+ O && u && /* @__PURE__ */ t(pt, { id: w, message: u })
164
166
  ] }) });
165
167
  }
166
168
  );
167
- mt.displayName = "Input";
169
+ dt.displayName = "Input";
168
170
  export {
169
- mt as Input
171
+ dt as Input
170
172
  };
@@ -1,203 +1,195 @@
1
1
  "use client";
2
2
  import "../styles/main.css";
3
3
  import { jsx as A, jsxs as T } from "react/jsx-runtime";
4
+ import { useControllableState as z } from "../hooks/useControllableState.js";
4
5
  import { Slot as L } from "../primitives/slot.js";
5
- import { createContext as z, forwardRef as P, useId as $, useState as U, useRef as G, useEffect as C, useCallback as E, useContext as B, useImperativeHandle as K } from "react";
6
- function q(...s) {
7
- return s.filter(Boolean).join(" ");
6
+ import { createContext as J, forwardRef as P, useId as U, useState as $, useRef as V, useEffect as E, useCallback as G, useContext as B, useImperativeHandle as K } from "react";
7
+ function q(...u) {
8
+ return u.filter(Boolean).join(" ");
8
9
  }
9
- const H = z(null);
10
- function J(s) {
11
- const { value: i, defaultValue: t, onChange: r } = s, [d, n] = U(t), u = i !== void 0, g = u ? i : d, l = E(
12
- (e) => {
13
- u || n(e), r?.(e);
14
- },
15
- [u, r]
16
- );
17
- return [g, l];
18
- }
19
- function Q(s, i, t, r) {
20
- const d = s.length;
21
- let n = i;
22
- for (let u = 0; u < d; u += 1) {
23
- if (n = t === "next" ? n + 1 : n - 1, r && (n < 0 && (n = d - 1), n >= d && (n = 0)), n < 0 || n >= d) return i;
24
- if (!s[n].disabled) return n;
10
+ const H = J(null);
11
+ function Q(u, a, t, o) {
12
+ const l = u.length;
13
+ let n = a;
14
+ for (let f = 0; f < l; f += 1) {
15
+ if (n = t === "next" ? n + 1 : n - 1, o && (n < 0 && (n = l - 1), n >= l && (n = 0)), n < 0 || n >= l) return a;
16
+ if (!u[n].disabled) return n;
25
17
  }
26
- return i;
18
+ return a;
27
19
  }
28
- function W(s, i, t) {
29
- const { key: r } = s;
30
- return r === "Home" ? "first" : r === "End" ? "last" : i === "vertical" ? r === "ArrowDown" ? "next" : r === "ArrowUp" ? "prev" : null : r === "ArrowRight" ? t === "rtl" ? "prev" : "next" : r === "ArrowLeft" ? t === "rtl" ? "next" : "prev" : null;
20
+ function W(u, a, t) {
21
+ const { key: o } = u;
22
+ return o === "Home" ? "first" : o === "End" ? "last" : a === "vertical" ? o === "ArrowDown" ? "next" : o === "ArrowUp" ? "prev" : null : o === "ArrowRight" ? t === "rtl" ? "prev" : "next" : o === "ArrowLeft" ? t === "rtl" ? "next" : "prev" : null;
31
23
  }
32
24
  const X = P(
33
25
  ({
34
- asChild: s,
35
- className: i,
26
+ asChild: u,
27
+ className: a,
36
28
  value: t,
37
- defaultValue: r,
38
- onValueChange: d,
29
+ defaultValue: o,
30
+ onValueChange: l,
39
31
  name: n,
40
- required: u = !1,
41
- form: g,
42
- disabled: l = !1,
32
+ required: f = !1,
33
+ form: y,
34
+ disabled: b = !1,
43
35
  orientation: e = "vertical",
44
36
  dir: N = "ltr",
45
37
  loop: p = !0,
46
- variant: m = "default",
47
- id: f,
48
- ...b
49
- }, v) => {
50
- const O = $(), F = f ?? `rg-${O}`, [R, x] = J({
38
+ variant: v = "default",
39
+ id: c,
40
+ ...d
41
+ }, m) => {
42
+ const O = U(), F = c ?? `rg-${O}`, [g, k] = z({
51
43
  value: t,
52
- defaultValue: r ?? void 0,
53
- onChange: d
54
- }), [w, V] = U(R), y = G([]), I = G(null);
55
- C(() => {
56
- R !== void 0 && V(R);
57
- }, [R]), C(() => {
58
- const c = I.current;
59
- if (!c) return;
60
- const a = () => {
61
- x(r ?? void 0);
44
+ defaultValue: o ?? void 0,
45
+ onChange: l
46
+ }), [w, C] = $(g), R = V([]), I = V(null);
47
+ E(() => {
48
+ g !== void 0 && C(g);
49
+ }, [g]), E(() => {
50
+ const s = I.current;
51
+ if (!s) return;
52
+ const i = () => {
53
+ k(o ?? void 0);
62
54
  };
63
- return c.addEventListener("reset", a), () => c.removeEventListener("reset", a);
64
- }, [r, x]);
65
- const o = E((c) => (y.current.push(c), () => {
66
- y.current = y.current.filter((a) => a.value !== c.value);
67
- }), []), h = E(
68
- (c, a) => {
69
- l || (x(c), a?.focus && (V(c), y.current.find((M) => M.value === c)?.ref.current?.focus()));
55
+ return s.addEventListener("reset", i), () => s.removeEventListener("reset", i);
56
+ }, [o, k]);
57
+ const r = G((s) => (R.current.push(s), () => {
58
+ R.current = R.current.filter((i) => i.value !== s.value);
59
+ }), []), h = G(
60
+ (s, i) => {
61
+ b || (k(s), i?.focus && (C(s), R.current.find((M) => M.value === s)?.ref.current?.focus()));
70
62
  },
71
- [l, x]
72
- ), k = {
73
- value: R,
63
+ [b, k]
64
+ ), x = {
65
+ value: g,
74
66
  setValue: h,
75
67
  name: n,
76
- required: u,
77
- form: g,
78
- disabled: l,
68
+ required: f,
69
+ form: y,
70
+ disabled: b,
79
71
  orientation: e,
80
72
  dir: N,
81
73
  loop: p,
82
- registerItem: o,
74
+ registerItem: r,
83
75
  focusableValue: w,
84
- setFocusableValue: V,
76
+ setFocusableValue: C,
85
77
  formElRef: I,
86
- itemsRef: y,
87
- variant: m
88
- }, D = s ? L : "div", S = v;
89
- return /* @__PURE__ */ A(H.Provider, { value: k, children: /* @__PURE__ */ A(
78
+ itemsRef: R,
79
+ variant: v
80
+ }, D = u ? L : "div", S = m;
81
+ return /* @__PURE__ */ A(H.Provider, { value: x, children: /* @__PURE__ */ A(
90
82
  D,
91
83
  {
92
84
  id: F,
93
85
  ref: S,
94
86
  role: "radiogroup",
95
87
  "aria-orientation": e,
96
- "data-disabled": l ? "" : void 0,
97
- className: q(i),
98
- ...b
88
+ "data-disabled": b ? "" : void 0,
89
+ className: q(a),
90
+ ...d
99
91
  }
100
92
  ) });
101
93
  }
102
94
  );
103
95
  X.displayName = "RadioGroup";
104
96
  const Y = P(
105
- ({ asChild: s, className: i, value: t, disabled: r, id: d, onKeyDown: n, onClick: u, ...g }, l) => {
97
+ ({ asChild: u, className: a, value: t, disabled: o, id: l, onKeyDown: n, onClick: f, ...y }, b) => {
106
98
  const e = B(H);
107
99
  if (!e) throw new Error("RadioGroupItem must be used within RadioGroup");
108
- const N = $(), p = d ?? `rgi-${N}`, m = G(null), f = G(null);
100
+ const N = U(), p = l ?? `rgi-${N}`, v = V(null), c = V(null);
109
101
  K(
110
- l,
111
- () => m.current,
102
+ b,
103
+ () => v.current,
112
104
  []
113
105
  );
114
- const b = e.value === t, v = !!r || e.disabled;
115
- C(() => {
116
- const o = { value: t, ref: m, disabled: !!v, id: p };
117
- return e.registerItem(o);
118
- }, [t, v, p]), C(() => {
119
- !e.formElRef.current && f.current?.form && (e.formElRef.current = f.current.form);
120
- }, [e.formElRef]), C(() => {
121
- f.current && (f.current.checked = b);
122
- }, [b]);
123
- const F = (e.focusableValue ? e.focusableValue === t : b) && !v ? 0 : -1, R = s ? L : "button", x = (o) => {
124
- m.current = o;
125
- }, w = E(
126
- (o) => {
127
- if (!v && (e.setValue(t, { focus: !0, user: o }), f.current)) {
106
+ const d = e.value === t, m = !!o || e.disabled;
107
+ E(() => {
108
+ const r = { value: t, ref: v, disabled: !!m, id: p };
109
+ return e.registerItem(r);
110
+ }, [t, m, p]), E(() => {
111
+ !e.formElRef.current && c.current?.form && (e.formElRef.current = c.current.form);
112
+ }, [e.formElRef]), E(() => {
113
+ c.current && (c.current.checked = d);
114
+ }, [d]);
115
+ const F = (e.focusableValue ? e.focusableValue === t : d) && !m ? 0 : -1, g = u ? L : "button", k = (r) => {
116
+ v.current = r;
117
+ }, w = G(
118
+ (r) => {
119
+ if (!m && (e.setValue(t, { focus: !0, user: r }), c.current)) {
128
120
  const h = new Event("change", { bubbles: !0 });
129
- f.current.dispatchEvent(h);
121
+ c.current.dispatchEvent(h);
130
122
  }
131
123
  },
132
- [e, v, t]
133
- ), V = E(
134
- (o) => {
135
- u?.(o), !o.defaultPrevented && w(!0);
124
+ [e, m, t]
125
+ ), C = G(
126
+ (r) => {
127
+ f?.(r), !r.defaultPrevented && w(!0);
136
128
  },
137
- [u, w]
138
- ), y = E(
139
- (o) => {
140
- if (n?.(o), o.defaultPrevented) return;
141
- if (o.key === " " || o.key === "Enter") {
142
- o.preventDefault(), w(!0);
129
+ [f, w]
130
+ ), R = G(
131
+ (r) => {
132
+ if (n?.(r), r.defaultPrevented) return;
133
+ if (r.key === " " || r.key === "Enter") {
134
+ r.preventDefault(), w(!0);
143
135
  return;
144
136
  }
145
- const h = W(o, e.orientation, e.dir);
137
+ const h = W(r, e.orientation, e.dir);
146
138
  if (h) {
147
- o.preventDefault();
148
- const k = [...e.itemsRef.current], D = k.findIndex((a) => a.value === t);
139
+ r.preventDefault();
140
+ const x = [...e.itemsRef.current], D = x.findIndex((i) => i.value === t);
149
141
  if (D === -1) return;
150
142
  if (h === "first") {
151
- const a = k.find((j) => !j.disabled);
152
- a && e.setValue(a.value, { focus: !0, user: !0 });
143
+ const i = x.find((j) => !j.disabled);
144
+ i && e.setValue(i.value, { focus: !0, user: !0 });
153
145
  return;
154
146
  }
155
147
  if (h === "last") {
156
- const a = [...k].reverse().find((j) => !j.disabled);
157
- a && e.setValue(a.value, { focus: !0, user: !0 });
148
+ const i = [...x].reverse().find((j) => !j.disabled);
149
+ i && e.setValue(i.value, { focus: !0, user: !0 });
158
150
  return;
159
151
  }
160
- const S = Q(k, D, h, e.loop), c = k[S];
161
- c && !c.disabled && e.setValue(c.value, { focus: !0, user: !0 });
152
+ const S = Q(x, D, h, e.loop), s = x[S];
153
+ s && !s.disabled && e.setValue(s.value, { focus: !0, user: !0 });
162
154
  }
163
155
  },
164
156
  [e, n, w, t]
165
157
  ), I = e.variant === "unstyled";
166
158
  return /* @__PURE__ */ T(
167
- R,
159
+ g,
168
160
  {
169
161
  id: p,
170
- ref: x,
162
+ ref: k,
171
163
  type: "button",
172
164
  role: "radio",
173
- "aria-checked": b,
174
- "aria-disabled": v || void 0,
175
- "data-state": b ? "checked" : "unchecked",
176
- "data-disabled": v ? "" : void 0,
165
+ "aria-checked": d,
166
+ "aria-disabled": m || void 0,
167
+ "data-state": d ? "checked" : "unchecked",
168
+ "data-disabled": m ? "" : void 0,
177
169
  tabIndex: F,
178
- onClick: V,
179
- onKeyDown: y,
170
+ onClick: C,
171
+ onKeyDown: R,
180
172
  className: q(
181
173
  // Only apply default styles when not unstyled
182
174
  !I && "border-input bg-background focus-visible:ring-ring inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border focus-visible:ring-2 focus-visible:ring-offset-2",
183
175
  !I && "data-[state=checked]:border-primary data-[state=checked]:bg-primary/10 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
184
176
  // Always preserve basic accessibility for unstyled variant
185
177
  I && "border-sm focus-visible:ring-ring data-[state=checked]:border-selected-primary cursor-pointer rounded-sm border-2 border-transparent transition-opacity hover:opacity-70 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",
186
- i
178
+ a
187
179
  ),
188
- ...g,
180
+ ...y,
189
181
  children: [
190
182
  /* @__PURE__ */ A(
191
183
  "input",
192
184
  {
193
- ref: f,
185
+ ref: c,
194
186
  type: "radio",
195
187
  name: e.name,
196
188
  value: t,
197
189
  required: e.required,
198
- disabled: v,
190
+ disabled: m,
199
191
  form: e.form,
200
- checked: b,
192
+ checked: d,
201
193
  readOnly: !0,
202
194
  tabIndex: -1,
203
195
  "aria-hidden": "true",
@@ -210,7 +202,7 @@ const Y = P(
210
202
  }
211
203
  }
212
204
  ),
213
- g.children
205
+ y.children
214
206
  ]
215
207
  }
216
208
  );
@@ -218,33 +210,33 @@ const Y = P(
218
210
  );
219
211
  Y.displayName = "RadioGroupItem";
220
212
  const Z = P(
221
- ({ asChild: s, className: i, forceMount: t, ...r }, d) => {
213
+ ({ asChild: u, className: a, forceMount: t, ...o }, l) => {
222
214
  if (!B(H)) return null;
223
- const [u, g] = U(!1), l = G(null);
215
+ const [f, y] = $(!1), b = V(null);
224
216
  return K(
225
- d,
226
- () => l.current,
217
+ l,
218
+ () => b.current,
227
219
  []
228
- ), C(() => {
229
- const p = l.current;
220
+ ), E(() => {
221
+ const p = b.current;
230
222
  if (!p) return;
231
- const m = p.closest('[role="radio"]');
232
- if (!m) return;
233
- const f = () => {
234
- g(m.getAttribute("aria-checked") === "true");
223
+ const v = p.closest('[role="radio"]');
224
+ if (!v) return;
225
+ const c = () => {
226
+ y(v.getAttribute("aria-checked") === "true");
235
227
  };
236
- f();
237
- const b = new MutationObserver(f);
238
- return b.observe(m, { attributes: !0, attributeFilter: ["aria-checked"] }), () => b.disconnect();
239
- }, []), !u && !t ? null : /* @__PURE__ */ A(
240
- s ? L : "span",
228
+ c();
229
+ const d = new MutationObserver(c);
230
+ return d.observe(v, { attributes: !0, attributeFilter: ["aria-checked"] }), () => d.disconnect();
231
+ }, []), !f && !t ? null : /* @__PURE__ */ A(
232
+ u ? L : "span",
241
233
  {
242
234
  ref: (p) => {
243
- l.current = p;
235
+ b.current = p;
244
236
  },
245
- "data-state": u ? "checked" : "unchecked",
246
- className: q("flex items-center justify-center text-current", i),
247
- ...r
237
+ "data-state": f ? "checked" : "unchecked",
238
+ className: q("flex items-center justify-center text-current", a),
239
+ ...o
248
240
  }
249
241
  );
250
242
  }