@spear-ai/spectral 1.4.2 → 1.4.4

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 (130) hide show
  1. package/dist/Accordion.d.ts +7 -7
  2. package/dist/Accordion.js +53 -51
  3. package/dist/Alert/AlertBase.js +7 -7
  4. package/dist/Alert.js +1 -1
  5. package/dist/Avatar.d.ts +2 -2
  6. package/dist/Avatar.js +46 -46
  7. package/dist/Badge.js +3 -3
  8. package/dist/Button.js +22 -15
  9. package/dist/ButtonGroup/ButtonGroupButton.d.ts +1 -1
  10. package/dist/ButtonGroup/ButtonGroupButton.js +10 -10
  11. package/dist/ButtonGroup.d.ts +8 -5
  12. package/dist/ButtonGroup.js +23 -15
  13. package/dist/ButtonIcon.d.ts +1 -1
  14. package/dist/ButtonIcon.js +5 -5
  15. package/dist/Card.d.ts +2 -7
  16. package/dist/Card.js +9 -20
  17. package/dist/Checkbox/CheckboxBase.d.ts +6 -6
  18. package/dist/Checkbox/CheckboxBase.js +65 -63
  19. package/dist/Checkbox.js +16 -14
  20. package/dist/DataCard.d.ts +11 -0
  21. package/dist/DataCard.js +18 -0
  22. package/dist/Dialog/DialogBase.d.ts +37 -25
  23. package/dist/Dialog/DialogBase.js +130 -104
  24. package/dist/Dialog.d.ts +8 -8
  25. package/dist/Dialog.js +46 -36
  26. package/dist/Drawer.js +17 -17
  27. package/dist/HoverCard.d.ts +4 -4
  28. package/dist/HoverCard.js +34 -33
  29. package/dist/Input.js +58 -58
  30. package/dist/InputOTP.d.ts +1 -1
  31. package/dist/InputOTP.js +113 -112
  32. package/dist/MultiSelect/MultiSelectBase.d.ts +16 -16
  33. package/dist/MultiSelect/MultiSelectBase.js +236 -177
  34. package/dist/MultiSelect/MutiSelect.d.ts +6 -4
  35. package/dist/MultiSelect/MutiSelect.js +13 -12
  36. package/dist/Popover.js +2 -1
  37. package/dist/RadioButtonGroup/RadioButtonGroupBase.js +18 -17
  38. package/dist/RadioGroup.js +5 -3
  39. package/dist/Select.js +70 -51
  40. package/dist/Slider.js +8 -4
  41. package/dist/Switch/SwitchBase.d.ts +6 -6
  42. package/dist/Switch/SwitchBase.js +39 -38
  43. package/dist/Switch.js +17 -16
  44. package/dist/Tabs/TabsBase.js +40 -25
  45. package/dist/Tabs.js +18 -21
  46. package/dist/Textarea.d.ts +1 -0
  47. package/dist/Textarea.js +33 -33
  48. package/dist/Toggle.js +4 -4
  49. package/dist/ToggleGroup/ToggleGroupBase.d.ts +7 -7
  50. package/dist/ToggleGroup/ToggleGroupBase.js +64 -64
  51. package/dist/ToggleGroup.js +19 -17
  52. package/dist/Tooltip/TooltipBase.d.ts +8 -8
  53. package/dist/Tooltip/TooltipBase.js +76 -74
  54. package/dist/Tooltip.d.ts +1 -1
  55. package/dist/Tooltip.js +12 -11
  56. package/dist/Tray.d.ts +1 -1
  57. package/dist/Tray.js +4910 -117
  58. package/dist/primitives/input.js +4 -4
  59. package/dist/primitives/select.d.ts +11 -11
  60. package/dist/primitives/select.d.ts.map +1 -1
  61. package/dist/primitives/select.js +28 -21
  62. package/dist/styles/base-colors.css +12 -12
  63. package/dist/styles/main.css +1 -1
  64. package/dist/utils/{refs.d.ts → createForwardRef.d.ts} +1 -1
  65. package/dist/utils/createForwardRef.d.ts.map +1 -0
  66. package/dist/utils/formFieldUtils.d.ts +22 -18
  67. package/dist/utils/formFieldUtils.d.ts.map +1 -1
  68. package/dist/utils/formFieldUtils.js +46 -46
  69. package/package.json +9 -3
  70. package/dist/analyzer/list.yml.webp +0 -0
  71. package/dist/analyzer/network.webp +0 -0
  72. package/dist/analyzer/sunburst.webp +0 -0
  73. package/dist/analyzer/visual.webp +0 -0
  74. package/dist/auth-background.json +0 -90
  75. package/dist/favicon-invert.svg +0 -5
  76. package/dist/favicon.svg +0 -5
  77. package/dist/features/AuthCard/AuthCard.d.ts +0 -3
  78. package/dist/features/AuthCard/AuthCard.d.ts.map +0 -1
  79. package/dist/features/AuthCard/AuthToggle.d.ts +0 -9
  80. package/dist/features/AuthCard/AuthToggle.d.ts.map +0 -1
  81. package/dist/features/AuthCard/AuthToggle.js +0 -20
  82. package/dist/features/AuthCard/ForgotPasswordEmailForm.d.ts +0 -11
  83. package/dist/features/AuthCard/ForgotPasswordEmailForm.d.ts.map +0 -1
  84. package/dist/features/AuthCard/ForgotPasswordEmailForm.js +0 -86
  85. package/dist/features/AuthCard/ForgotPasswordResetForm.d.ts +0 -11
  86. package/dist/features/AuthCard/ForgotPasswordResetForm.d.ts.map +0 -1
  87. package/dist/features/AuthCard/ForgotPasswordResetForm.js +0 -21
  88. package/dist/features/AuthCard/OTPInput.d.ts +0 -12
  89. package/dist/features/AuthCard/OTPInput.d.ts.map +0 -1
  90. package/dist/features/AuthCard/OTPInput.js +0 -12
  91. package/dist/features/AuthCard/PasswordInput.d.ts +0 -13
  92. package/dist/features/AuthCard/PasswordInput.d.ts.map +0 -1
  93. package/dist/features/AuthCard/PasswordInput.js +0 -93
  94. package/dist/features/AuthCard/SignInForm.d.ts +0 -9
  95. package/dist/features/AuthCard/SignInForm.d.ts.map +0 -1
  96. package/dist/features/AuthCard/SignInForm.js +0 -86
  97. package/dist/features/AuthCard/SignUpForm.d.ts +0 -8
  98. package/dist/features/AuthCard/SignUpForm.d.ts.map +0 -1
  99. package/dist/features/AuthCard/SignUpForm.js +0 -100
  100. package/dist/features/AuthCard.js +0 -202
  101. package/dist/features/ClearDialog/ClearDialog.d.ts +0 -2
  102. package/dist/features/ClearDialog/ClearDialog.d.ts.map +0 -1
  103. package/dist/features/ClearDialog.js +0 -31
  104. package/dist/features/LabelingToolbar/LabelingToolbar.d.ts +0 -8
  105. package/dist/features/LabelingToolbar/LabelingToolbar.d.ts.map +0 -1
  106. package/dist/features/LabelingToolbar.js +0 -13
  107. package/dist/features/LabelingTools/LabelingTools.d.ts +0 -2
  108. package/dist/features/LabelingTools/LabelingTools.d.ts.map +0 -1
  109. package/dist/features/LabelingTools.js +0 -134
  110. package/dist/features/SensorMetadata/SensorMetadata.d.ts +0 -2
  111. package/dist/features/SensorMetadata/SensorMetadata.d.ts.map +0 -1
  112. package/dist/features/SensorMetadata.js +0 -117
  113. package/dist/features/SettingsPopover/SettingsPopover.d.ts +0 -2
  114. package/dist/features/SettingsPopover/SettingsPopover.d.ts.map +0 -1
  115. package/dist/features/SettingsPopover.js +0 -204
  116. package/dist/index-BIpuW_o8.js +0 -146
  117. package/dist/linear-cursor-small.png +0 -0
  118. package/dist/loader-circle-CdRVlFhN.js +0 -11
  119. package/dist/logo/wordmark-dark-side-by-side.svg +0 -6
  120. package/dist/logo/wordmark-light-side-by-side.svg +0 -6
  121. package/dist/message-alert-matte-glass-gradient.webp +0 -0
  122. package/dist/proxy-C9AqCss6.js +0 -4670
  123. package/dist/speech-bubble-fluid-glass-gradient.webp +0 -0
  124. package/dist/themes/grayscale-theme.webp +0 -0
  125. package/dist/themes/green-black-theme.webp +0 -0
  126. package/dist/themes/reverse-grayscale-theme.webp +0 -0
  127. package/dist/themes/viridis-theme.webp +0 -0
  128. package/dist/utils/refs.d.ts.map +0 -1
  129. package/dist/x-Dl66o_vF.js +0 -14
  130. /package/dist/utils/{refs.js → createForwardRef.js} +0 -0
@@ -3,19 +3,19 @@ import "../styles/main.css";
3
3
  import { jsx as x, jsxs as R } from "react/jsx-runtime";
4
4
  import { generateId as $, prefersReducedMotion as _, debounce as L, getIndicatorPosition as S, calculateIndicatorStyle as K } from "./tabsUtils.js";
5
5
  import { cn as y } from "../utils/twUtils.js";
6
- import { createContext as M, forwardRef as z, useState as D, useId as N, useCallback as p, useRef as k, useEffect as O, useContext as P } from "react";
6
+ import { createContext as M, forwardRef as z, useState as D, useId as N, useCallback as w, useRef as k, useEffect as O, useContext as P } from "react";
7
7
  const E = M(null), C = (I = "Tabs") => {
8
8
  const u = P(E);
9
9
  if (u === null)
10
10
  throw new Error(`${I} components must be used within a Tabs.Root`);
11
11
  return u;
12
12
  }, B = z(function({ activationMode: u = "automatic", children: e, defaultValue: h, dir: b = "ltr", disabled: l = !1, onValueChange: f, orientation: o = "horizontal", value: v, ...s }, c) {
13
- const [m, g] = D(h ?? ""), d = N() ?? $("tabs"), r = v !== void 0, t = r ? v : m, n = p(
14
- (w) => {
15
- l || (r || g(w), f?.(w));
13
+ const [m, g] = D(h ?? ""), d = N() ?? $("tabs"), a = v !== void 0, t = a ? v : m, n = w(
14
+ (p) => {
15
+ l || (a || g(p), f?.(p));
16
16
  },
17
- [r, f, l]
18
- ), a = {
17
+ [a, f, l]
18
+ ), r = {
19
19
  value: t,
20
20
  onValueChange: n,
21
21
  orientation: o,
@@ -24,7 +24,7 @@ const E = M(null), C = (I = "Tabs") => {
24
24
  disabled: l,
25
25
  baseId: d
26
26
  };
27
- return /* @__PURE__ */ x(E.Provider, { value: a, children: /* @__PURE__ */ x("div", { ref: c, "data-orientation": o, "data-disabled": l ? "" : void 0, dir: b, ...s, children: e }) });
27
+ return /* @__PURE__ */ x(E.Provider, { value: r, children: /* @__PURE__ */ x("div", { ref: c, "data-testid": "spectral-tabs-root", "data-orientation": o, "data-disabled": l ? "" : void 0, dir: b, ...s, children: e }) });
28
28
  }), H = z(function({ className: u, loop: e = !0, ...h }, b) {
29
29
  const { orientation: l, disabled: f } = C("TabsList"), [o, v] = D(() => ({
30
30
  left: 0,
@@ -33,7 +33,7 @@ const E = M(null), C = (I = "Tabs") => {
33
33
  height: 0,
34
34
  orientation: "horizontal",
35
35
  isEnclosed: !1
36
- })), s = k(null), c = _(), m = p(
36
+ })), s = k(null), c = _(), m = w(
37
37
  L(() => {
38
38
  const d = K(s);
39
39
  v(d);
@@ -43,30 +43,30 @@ const E = M(null), C = (I = "Tabs") => {
43
43
  );
44
44
  O(() => {
45
45
  m();
46
- const d = new ResizeObserver(m), r = new MutationObserver(m), t = s.current;
47
- return t && (d.observe(t), r.observe(t, {
46
+ const d = new ResizeObserver(m), a = new MutationObserver(m), t = s.current;
47
+ return t && (d.observe(t), a.observe(t, {
48
48
  attributes: !0,
49
49
  childList: !0,
50
50
  subtree: !0
51
51
  })), () => {
52
- d.disconnect(), r.disconnect();
52
+ d.disconnect(), a.disconnect();
53
53
  };
54
54
  }, [m]);
55
- const g = p(
55
+ const g = w(
56
56
  (d) => {
57
57
  if (f) return;
58
- const r = Array.from(s.current?.querySelectorAll("[role='tab']:not([disabled]):not([aria-disabled='true'])") ?? []);
59
- if (r.length === 0) return;
60
- const t = r.findIndex((T) => T === document.activeElement);
58
+ const a = Array.from(s.current?.querySelectorAll("[role='tab']:not([disabled]):not([aria-disabled='true'])") ?? []);
59
+ if (a.length === 0) return;
60
+ const t = a.findIndex((T) => T === document.activeElement);
61
61
  if (t === -1) return;
62
62
  let n = null;
63
- const { key: a, ctrlKey: w, metaKey: A } = d, i = w || A;
64
- l === "horizontal" ? a === "ArrowLeft" || a === "ArrowUp" && i ? n = t > 0 ? t - 1 : e ? r.length - 1 : t : (a === "ArrowRight" || a === "ArrowDown" && i) && (n = t < r.length - 1 ? t + 1 : e ? 0 : t) : a === "ArrowUp" || a === "ArrowLeft" && i ? n = t > 0 ? t - 1 : e ? r.length - 1 : t : (a === "ArrowDown" || a === "ArrowRight" && i) && (n = t < r.length - 1 ? t + 1 : e ? 0 : t), a === "Home" ? n = 0 : a === "End" && (n = r.length - 1), n !== null && n !== t && (d.preventDefault(), d.stopPropagation(), r[n]?.focus());
63
+ const { key: r, ctrlKey: p, metaKey: A } = d, i = p || A;
64
+ l === "horizontal" ? r === "ArrowLeft" || r === "ArrowUp" && i ? n = t > 0 ? t - 1 : e ? a.length - 1 : t : (r === "ArrowRight" || r === "ArrowDown" && i) && (n = t < a.length - 1 ? t + 1 : e ? 0 : t) : r === "ArrowUp" || r === "ArrowLeft" && i ? n = t > 0 ? t - 1 : e ? a.length - 1 : t : (r === "ArrowDown" || r === "ArrowRight" && i) && (n = t < a.length - 1 ? t + 1 : e ? 0 : t), r === "Home" ? n = 0 : r === "End" && (n = a.length - 1), n !== null && n !== t && (d.preventDefault(), d.stopPropagation(), a[n]?.focus());
65
65
  },
66
66
  [f, l, e]
67
67
  );
68
68
  return /* @__PURE__ */ R("div", { className: "relative", ref: s, children: [
69
- /* @__PURE__ */ x("div", { ref: b, role: "tablist", "aria-orientation": l, "aria-disabled": f, className: y("tabs-list", u), onKeyDown: g, ...h }),
69
+ /* @__PURE__ */ x("div", { ref: b, role: "tablist", "data-testid": "spectral-tabs-list", "aria-orientation": l, "aria-disabled": f, className: y("tabs-list", u), onKeyDown: g, ...h }),
70
70
  /* @__PURE__ */ x(
71
71
  "div",
72
72
  {
@@ -92,7 +92,7 @@ const E = M(null), C = (I = "Tabs") => {
92
92
  )
93
93
  ] });
94
94
  }), G = z(function({ className: u, value: e, onClick: h, onKeyDown: b, disabled: l = !1, ...f }, o) {
95
- const { value: v, onValueChange: s, activationMode: c, disabled: m, baseId: g } = C("TabsTrigger"), d = `${g}-trigger-${e}`, r = `${g}-content-${e}`, t = v === e, n = m || l, a = p(
95
+ const { value: v, onValueChange: s, activationMode: c, disabled: m, baseId: g } = C("TabsTrigger"), d = `${g}-trigger-${e}`, a = `${g}-content-${e}`, t = v === e, n = m || l, r = w(
96
96
  (i) => {
97
97
  if (n) {
98
98
  i.preventDefault();
@@ -101,7 +101,7 @@ const E = M(null), C = (I = "Tabs") => {
101
101
  s(e), h?.(i);
102
102
  },
103
103
  [e, s, h, n]
104
- ), w = p(
104
+ ), p = w(
105
105
  (i) => {
106
106
  if (n) {
107
107
  i.preventDefault();
@@ -111,7 +111,7 @@ const E = M(null), C = (I = "Tabs") => {
111
111
  (T === "Enter" || T === " ") && (i.preventDefault(), i.stopPropagation(), s(e)), b?.(i);
112
112
  },
113
113
  [e, s, b, n]
114
- ), A = p(() => {
114
+ ), A = w(() => {
115
115
  n || c === "automatic" && s(e);
116
116
  }, [c, s, e, n]);
117
117
  return /* @__PURE__ */ x(
@@ -120,8 +120,9 @@ const E = M(null), C = (I = "Tabs") => {
120
120
  ref: o,
121
121
  role: "tab",
122
122
  type: "button",
123
+ "data-testid": "spectral-tabs-trigger",
123
124
  id: d,
124
- "aria-controls": r,
125
+ "aria-controls": a,
125
126
  "aria-selected": t,
126
127
  "aria-disabled": n,
127
128
  disabled: n,
@@ -129,15 +130,29 @@ const E = M(null), C = (I = "Tabs") => {
129
130
  "data-disabled": n ? "" : void 0,
130
131
  tabIndex: t ? 0 : -1,
131
132
  className: y("tabs-trigger z-10 focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600", u),
132
- onClick: a,
133
- onKeyDown: w,
133
+ onClick: r,
134
+ onKeyDown: p,
134
135
  onFocus: A,
135
136
  ...f
136
137
  }
137
138
  );
138
139
  }), J = z(function({ className: u, value: e, forceMount: h = !1, ...b }, l) {
139
140
  const { value: f, baseId: o } = C("TabsContent"), v = `${o}-content-${e}`, s = `${o}-trigger-${e}`, c = f === e;
140
- return !h && !c ? null : /* @__PURE__ */ x("div", { ref: l, role: "tabpanel", id: v, "aria-labelledby": s, "data-state": c ? "active" : "inactive", tabIndex: 0, className: y("tabs-content focus:outline-none focus-visible:outline-none", u), hidden: !c, ...b });
141
+ return !h && !c ? null : /* @__PURE__ */ x(
142
+ "div",
143
+ {
144
+ ref: l,
145
+ role: "tabpanel",
146
+ "data-testid": "spectral-tabs-content",
147
+ id: v,
148
+ "aria-labelledby": s,
149
+ "data-state": c ? "active" : "inactive",
150
+ tabIndex: 0,
151
+ className: y("tabs-content focus:outline-none focus-visible:outline-none", u),
152
+ hidden: !c,
153
+ ...b
154
+ }
155
+ );
141
156
  });
142
157
  export {
143
158
  B as TabsBase,
package/dist/Tabs.js CHANGED
@@ -1,43 +1,40 @@
1
1
  import "./styles/main.css";
2
- import { jsxs as f, jsx as a } from "react/jsx-runtime";
2
+ import { jsx as a, jsxs as x } from "react/jsx-runtime";
3
3
  import { TabsBase as N, TabsList as T, TabsTrigger as z, TabsContent as k } from "./Tabs/TabsBase.js";
4
- import { validateTabValues as E, getTabKeys as V } from "./Tabs/tabsUtils.js";
4
+ import { validateTabValues as j, getTabKeys as C } from "./Tabs/tabsUtils.js";
5
5
  import { cn as r } from "./utils/twUtils.js";
6
6
  import "react";
7
- const j = ({ tabCount: d, orientation: s }) => /* @__PURE__ */ f("div", { className: "flex flex-col relative w-full", role: "status", children: [
7
+ const V = ({ tabCount: d, orientation: s }) => /* @__PURE__ */ x("div", { className: "flex flex-col relative w-full", role: "status", children: [
8
8
  /* @__PURE__ */ a("div", { className: r("inline-flex items-center justify-start w-full", s === "horizontal" && "border-b border-neutral-600", s === "vertical" && "flex-col items-stretch border-r border-neutral-600"), children: Array.from({ length: Math.min(d, 5) }, (i, t) => /* @__PURE__ */ a("div", { className: r("animate-pulse bg-neutral-600 rounded", s === "horizontal" ? "h-6 w-16 mx-2 my-2" : "h-6 w-full mx-2 my-1"), "aria-hidden": "true" }, t)) }),
9
9
  /* @__PURE__ */ a("div", { className: "animate-pulse bg-neutral-600 h-32 w-full mt-4 rounded", "aria-hidden": "true" }),
10
10
  /* @__PURE__ */ a("span", { className: "sr-only", children: "Loading tabs…" })
11
- ] }), A = ({ ariaLabel: d, className: s, openOnLoad: i, orientation: t = "horizontal", tabValues: h = [], variant: l = "default", activationMode: m = "automatic", loading: p = !1, onError: n, onBeforeChange: v, onValueChange: x, ...y }) => {
12
- const o = h.filter((e) => e.key !== void 0);
13
- if (!E(o)) {
11
+ ] }), L = ({ ariaLabel: d, className: s, openOnLoad: i, orientation: t = "horizontal", tabValues: f = [], variant: l = "default", activationMode: m = "automatic", loading: p = !1, onError: n, onBeforeChange: h, onValueChange: v, ...y }) => {
12
+ const o = f.filter((e) => e.key !== void 0);
13
+ if (!j(o)) {
14
14
  const e = new Error("Invalid tabValues provided to Tabs component");
15
- return n?.(e), /* @__PURE__ */ f("div", { className: "flex flex-col relative w-full p-4 text-center text-gray-500", role: "alert", "aria-live": "polite", children: [
16
- /* @__PURE__ */ a("p", { children: "No valid tabs provided" }),
17
- process.env.NODE_ENV !== "production" && /* @__PURE__ */ a("p", { className: "text-xs mt-2 text-gray-400", children: "Check console for detailed validation errors" })
18
- ] });
15
+ return n?.(e), /* @__PURE__ */ a("div", { className: "flex flex-col relative w-full p-4 text-center text-gray-500", role: "alert", "aria-live": "polite", children: /* @__PURE__ */ a("p", { children: "No valid tabs provided" }) });
19
16
  }
20
17
  if (p)
21
- return /* @__PURE__ */ a(j, { tabCount: h.length || 3, orientation: t });
22
- const u = V(o);
23
- let c = i ?? u[0];
24
- if (i && !u.includes(i) && (process.env.NODE_ENV !== "production" && console.warn(`Tabs: openOnLoad value '${i}' not found in tabValues. Using first tab.`), c = u[0]), !c) {
18
+ return /* @__PURE__ */ a(V, { tabCount: f.length || 3, orientation: t });
19
+ const b = C(o);
20
+ let c = i ?? b[0];
21
+ if (i && !b.includes(i) && (console.warn(`Tabs: openOnLoad value '${i}' is not a valid tab key`), c = b[0]), !c) {
25
22
  const e = new Error("No valid default tab available");
26
23
  return n?.(e), /* @__PURE__ */ a("div", { className: "flex flex-col relative w-full p-4 text-center text-text-secondary", role: "alert", "aria-live": "polite", children: /* @__PURE__ */ a("p", { children: "Unable to render tabs" }) });
27
24
  }
28
25
  const g = async (e) => {
29
- if (v && x) {
26
+ if (h && v) {
30
27
  const w = c;
31
28
  try {
32
- if (await v(e, w) === !1) return;
33
- } catch (b) {
34
- n?.(b instanceof Error ? b : new Error("Before change callback failed"));
29
+ if (await h(e, w) === !1) return;
30
+ } catch (u) {
31
+ n?.(u instanceof Error ? u : new Error("Before change callback failed"));
35
32
  return;
36
33
  }
37
34
  }
38
- x?.(e);
35
+ v?.(e);
39
36
  };
40
- return /* @__PURE__ */ a("div", { className: "flex flex-col relative w-full", children: /* @__PURE__ */ f(N, { "aria-label": d, className: r("relative w-full data-[orientation=vertical]:flex", l, s), defaultValue: c, orientation: t, activationMode: m, onValueChange: g, ...y, children: [
37
+ return /* @__PURE__ */ a("div", { className: "flex flex-col relative w-full", children: /* @__PURE__ */ x(N, { "aria-label": d, className: r("relative w-full data-[orientation=vertical]:flex", l, s), defaultValue: c, orientation: t, activationMode: m, onValueChange: g, ...y, children: [
41
38
  /* @__PURE__ */ a(
42
39
  T,
43
40
  {
@@ -86,7 +83,7 @@ const j = ({ tabCount: d, orientation: s }) => /* @__PURE__ */ f("div", { classN
86
83
  ] }) });
87
84
  };
88
85
  export {
89
- A as Tabs,
86
+ L as Tabs,
90
87
  k as TabsContent,
91
88
  T as TabsList,
92
89
  N as TabsRoot,
@@ -13,6 +13,7 @@ export type TextareaProps = Omit<ComponentProps<'textarea'>, 'onChange'> & {
13
13
  onChange?: (value: string) => void;
14
14
  onFocus?: (e: FocusEvent<HTMLTextAreaElement>) => void;
15
15
  placeholder?: string | undefined;
16
+ required?: boolean;
16
17
  state?: TextareaState;
17
18
  value?: string | undefined;
18
19
  };
package/dist/Textarea.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import "./styles/main.css";
3
3
  import { jsxs as n, jsx as e } from "react/jsx-runtime";
4
- import { useTextarea as B } from "./Textarea/TextareaUtils.js";
4
+ import { useTextarea as z } from "./Textarea/TextareaUtils.js";
5
5
  import "./Icons/AnalyzeIcon.js";
6
6
  import "./Icons/AnnotationsIcon.js";
7
7
  import "./Icons/ApprovedIcon.js";
@@ -33,7 +33,7 @@ import "./Icons/LassoIcon.js";
33
33
  import "./Icons/LineToolIcon.js";
34
34
  import "./Icons/LineToolIcon2.js";
35
35
  import "./Icons/LiveViewIcon.js";
36
- import { LoaderIcon as D } from "./Icons/LoaderIcon.js";
36
+ import { LoaderIcon as B } from "./Icons/LoaderIcon.js";
37
37
  import "./Icons/LocationIcon.js";
38
38
  import "./Icons/LogoutIcon.js";
39
39
  import "./Icons/MessagesIcon.js";
@@ -59,67 +59,67 @@ import "./Icons/WarningIcon.js";
59
59
  import "./Icons/ZoomAllIcon.js";
60
60
  import "./Icons/ZoomXIcon.js";
61
61
  import "./Icons/ZoomYIcon.js";
62
- import { Label as E } from "./Label.js";
63
- import { useFormFieldId as O, getAriaProps as _, getErrorMessageId as $, getTextareaClasses as G, useFormFieldState as M } from "./utils/formFieldUtils.js";
62
+ import { Label as D } from "./Label.js";
63
+ import { useFormFieldId as M, getAriaProps as O, getErrorMessageId as _, getTextareaClasses as $, useFormFieldState as G, ErrorMessage as V } from "./utils/formFieldUtils.js";
64
64
  import { cn as g } from "./utils/twUtils.js";
65
- import { forwardRef as V, useRef as H } from "react";
66
- const J = "absolute right-4 top-4", K = (t) => t || "off", Q = (t, a) => {
67
- const m = "absolute bottom-2 right-3 text-xs pointer-events-none z-10 tabular-nums", o = t >= a ? "text-danger-400" : "text-text-secondary";
68
- return g(m, o);
69
- }, U = V(
70
- ({ autoComplete: t, className: a, disabled: m, errorMessage: o, id: C, label: d, labelClassName: b, maxLength: i = 280, name: c, onBlur: N, onChange: F, onFocus: I, placeholder: v, required: u, state: r = "default", value: s = "", ...x }, S) => {
71
- const p = O(C, c), h = $(p), y = H(null), P = S || y, { handleFocus: w, handleBlur: A, handleChange: R, handlePaste: T } = B({
65
+ import { forwardRef as H, useRef as J } from "react";
66
+ const K = "absolute right-4 top-4", Q = (t) => t || "off", U = (t, a) => {
67
+ const s = "absolute bottom-2 right-3 text-xs pointer-events-none z-10 tabular-nums", o = t >= a ? "text-danger-400" : "text-text-secondary";
68
+ return g(s, o);
69
+ }, W = H(
70
+ ({ autoComplete: t, className: a, disabled: s, errorMessage: o, id: C, label: c, labelClassName: b, maxLength: i = 280, name: d, onBlur: N, onChange: I, onFocus: F, placeholder: S, required: u, state: r = "default", value: m = "", ...x }, v) => {
71
+ const p = M(C, d), h = _(p), y = J(null), P = v || y, { handleFocus: T, handleBlur: A, handleChange: R, handlePaste: w } = z({
72
72
  maxLength: i,
73
- value: s,
74
- onChange: F || (() => {
73
+ value: m,
74
+ onChange: I || (() => {
75
75
  }),
76
- onFocus: I,
76
+ onFocus: F,
77
77
  onBlur: N
78
- }), { isDisabled: f, isLoading: L } = M(m, r), j = _(r, u, h, x["aria-describedby"]), l = s?.length || 0, k = G(r, a), z = () => ({
78
+ }), { isDisabled: f, isLoading: E } = G(s, r), L = O(r, h, u, x["aria-describedby"]), l = m?.length || 0, j = $(r, a), k = () => ({
79
79
  "--textarea-min-height": "6rem",
80
80
  "--textarea-max-height": "12rem",
81
81
  "--textarea-border-radius": "0.5rem"
82
82
  });
83
- return /* @__PURE__ */ n("div", { className: "w-full", "data-testid": "textarea-root", children: [
84
- d && /* @__PURE__ */ e(E, { htmlFor: p, className: g("block mb-2", f && "opacity-50 cursor-not-allowed", b), children: d }),
85
- /* @__PURE__ */ n("div", { className: "relative", "data-testid": "textarea-wrapper", children: [
83
+ return /* @__PURE__ */ n("div", { className: "w-full", children: [
84
+ c && /* @__PURE__ */ e(D, { "data-testid": "spectral-textarea-label", htmlFor: p, className: g("block mb-2", f && "opacity-50 cursor-not-allowed", b), children: c }),
85
+ /* @__PURE__ */ n("div", { className: "relative", "data-testid": "spectral-textarea-container", children: [
86
86
  /* @__PURE__ */ e(
87
87
  "textarea",
88
88
  {
89
89
  "aria-multiline": "true",
90
- autoComplete: K(t),
91
- className: k,
90
+ autoComplete: Q(t),
91
+ className: j,
92
92
  "data-state": r,
93
- "data-testid": "textarea-textarea",
93
+ "data-testid": "spectral-textarea",
94
94
  disabled: f,
95
95
  id: p,
96
- name: c,
96
+ name: d,
97
97
  onBlur: A,
98
98
  onChange: R,
99
- onFocus: w,
100
- onPaste: T,
101
- placeholder: v,
99
+ onFocus: T,
100
+ onPaste: w,
101
+ placeholder: S,
102
102
  ref: P,
103
103
  required: u,
104
104
  spellCheck: "true",
105
- style: z(),
106
- value: s,
107
- ...j,
105
+ style: k(),
106
+ value: m,
107
+ ...L,
108
108
  ...x
109
109
  }
110
110
  ),
111
- L && /* @__PURE__ */ e("div", { className: J, "data-testid": "textarea-loading-icon", children: /* @__PURE__ */ e(D, { size: 24 }) }),
112
- /* @__PURE__ */ n("div", { className: Q(l, i), role: "status", "aria-live": "polite", "aria-label": `${l} of ${i} characters used`, children: [
111
+ E && /* @__PURE__ */ e("div", { className: K, "data-testid": "spectral-textarea-loading-icon", children: /* @__PURE__ */ e(B, { size: 24 }) }),
112
+ /* @__PURE__ */ n("div", { className: U(l, i), role: "status", "aria-live": "polite", "aria-label": `${l} of ${i} characters used`, children: [
113
113
  l,
114
114
  "/",
115
115
  i
116
116
  ] })
117
117
  ] }),
118
- r === "error" && o && /* @__PURE__ */ e("p", { id: h, className: "mt-1.5 text-sm !text-danger-300", "data-testid": "textarea-error-message", "aria-live": "polite", "aria-atomic": "true", children: o })
118
+ r === "error" && o && /* @__PURE__ */ e(V, { dataTestId: "spectral-textarea-error-message", id: h, message: o })
119
119
  ] });
120
120
  }
121
121
  );
122
- U.displayName = "Textarea";
122
+ W.displayName = "Textarea";
123
123
  export {
124
- U as Textarea
124
+ W as Textarea
125
125
  };
package/dist/Toggle.js CHANGED
@@ -20,9 +20,9 @@ const v = d(
20
20
  outline: "border-toggle-outline-border hover:bg-toggle-bg--hover"
21
21
  },
22
22
  size: {
23
- default: 'h-9 px-3 min-w-9 [&_svg:not([class*="size-"]):not([width]):not([height])]:size-4',
24
- sm: 'h-8 px-1.5 min-w-8 [&_svg:not([class*="size-"]):not([width]):not([height])]:size-3',
25
- lg: 'h-10 px-2.5 min-w-10 [&_svg:not([class*="size-"]):not([width]):not([height])]:size-5'
23
+ default: "h-9 px-3 min-w-9 [&_svg:not([class*='size-']:not([width]):not([height])]:size-4",
24
+ sm: "h-8 px-1.5 min-w-8 [&_svg:not([class*='size-']:not([width]):not([height])]:size-3",
25
+ lg: "h-10 px-2.5 min-w-10 [&_svg:not([class*='size-']:not([width]):not([height])]:size-5"
26
26
  },
27
27
  layout: {
28
28
  default: "w-fit",
@@ -35,7 +35,7 @@ const v = d(
35
35
  layout: "default"
36
36
  }
37
37
  }
38
- ), m = l(({ className: e, variant: t, size: o, layout: r, ...a }, i) => /* @__PURE__ */ g(n, { ref: i, "data-slot": "toggle", className: s(v({ variant: t, size: o, layout: r }), e), ...a }));
38
+ ), m = l(({ className: e, variant: t, size: o, layout: r, ...a }, i) => /* @__PURE__ */ g(n, { ref: i, "data-slot": "toggle", "data-testid": "spectral-toggle", className: s(v({ variant: t, size: o, layout: r }), e), ...a }));
39
39
  export {
40
40
  m as Toggle,
41
41
  v as toggleVariants
@@ -1,14 +1,14 @@
1
1
  import { ButtonHTMLAttributes, HTMLAttributes, ReactNode } from 'react';
2
2
  type Orientation = 'horizontal' | 'vertical';
3
3
  export type CommonGroupProps = {
4
- orientation?: Orientation;
5
- loop?: boolean;
4
+ className?: string;
5
+ defaultValue?: string | string[];
6
6
  disabled?: boolean;
7
+ loop?: boolean;
7
8
  name?: string;
8
- value?: string | string[];
9
- defaultValue?: string | string[];
10
9
  onValueChange?: (v: string | string[]) => void;
11
- className?: string;
10
+ orientation?: Orientation;
11
+ value?: string | string[];
12
12
  };
13
13
  export type SingleProps = CommonGroupProps & {
14
14
  type?: 'single';
@@ -18,10 +18,10 @@ export type MultipleProps = CommonGroupProps & {
18
18
  };
19
19
  export type ToggleGroupProps = (SingleProps | MultipleProps) & Omit<HTMLAttributes<HTMLDivElement>, 'onChange'>;
20
20
  export type ItemRenderProps = {
21
- value: string;
22
- disabled?: boolean;
23
21
  children?: ReactNode;
24
22
  className?: string;
23
+ disabled?: boolean;
24
+ value: string;
25
25
  };
26
26
  export declare const ToggleGroupBase: (props: ToggleGroupProps & Record<`data-${string}`, any>) => import("react/jsx-runtime").JSX.Element;
27
27
  export type ToggleGroupItemProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange' | 'onPressedChange' | 'pressed' | 'defaultPressed'> & ItemRenderProps;
@@ -1,96 +1,96 @@
1
1
  "use client";
2
2
  import "../styles/main.css";
3
- import { jsx as B, jsxs as E } from "react/jsx-runtime";
3
+ import { jsx as C, jsxs as E } from "react/jsx-runtime";
4
4
  import { useControllableState as R } from "../hooks/useControllableState.js";
5
5
  import { clamp as M } from "../utils/sharedUtils.js";
6
- import { createContext as j, forwardRef as H, useContext as K, useRef as S, useImperativeHandle as L, useEffect as N, useCallback as i, useMemo as U } from "react";
7
- const T = j(null), W = (C) => {
6
+ import { createContext as j, forwardRef as H, useContext as K, useRef as S, useImperativeHandle as L, useEffect as N, useCallback as l, useMemo as U } from "react";
7
+ const T = j(null), W = (z) => {
8
8
  const {
9
- type: n = "single",
10
- orientation: l = "horizontal",
11
- loop: d = !0,
12
- disabled: I = !1,
9
+ className: o,
10
+ defaultValue: i,
11
+ disabled: x = !1,
12
+ loop: c = !0,
13
13
  name: u,
14
- className: x,
15
- value: z,
16
- defaultValue: A,
17
- onValueChange: a,
18
- "data-variant": D,
19
- "data-size": v,
20
- "data-slot": c,
21
- "data-layout": b,
14
+ onValueChange: v,
15
+ orientation: b = "horizontal",
16
+ type: d = "single",
17
+ value: a,
18
+ "data-variant": V,
19
+ "data-size": w,
20
+ "data-slot": f,
21
+ "data-layout": A,
22
22
  ...G
23
- } = C, f = n === "multiple", [r, p] = R({
24
- value: z,
25
- defaultValue: typeof A < "u" ? A : f ? [] : "",
26
- onChange: a
27
- }), o = S([]), m = i((t, s) => {
23
+ } = z, p = d === "multiple", [n, m] = R({
24
+ defaultValue: typeof i < "u" ? i : p ? [] : "",
25
+ onChange: v,
26
+ value: a
27
+ }), r = S([]), g = l((t, s) => {
28
28
  const P = { val: t, el: s, disabled: !!s?.disabled };
29
- return o.current = [...o.current.filter((w) => w.val !== t), P], () => {
30
- o.current = o.current.filter((w) => w.val !== t);
29
+ return r.current = [...r.current.filter((D) => D.val !== t), P], () => {
30
+ r.current = r.current.filter((D) => D.val !== t);
31
31
  };
32
- }, []), V = i(() => o.current.slice(), []), k = i(
33
- (t) => f ? Array.isArray(r) && r.includes(t) : r === t,
34
- [f, r]
35
- ), e = i((t) => p(t), [p]), g = i(
32
+ }, []), k = l(() => r.current.slice(), []), B = l(
33
+ (t) => p ? Array.isArray(n) && n.includes(t) : n === t,
34
+ [p, n]
35
+ ), e = l((t) => m(t), [m]), y = l(
36
36
  (t) => {
37
- const s = o.current;
37
+ const s = r.current;
38
38
  if (s.length === 0) return;
39
- const P = s.length - 1, w = d ? (t % s.length + s.length) % s.length : M(t, 0, P);
40
- s[w]?.el?.focus();
39
+ const P = s.length - 1, D = c ? (t % s.length + s.length) % s.length : M(t, 0, P);
40
+ s[D]?.el?.focus();
41
41
  },
42
- [d]
43
- ), y = U(
42
+ [c]
43
+ ), h = U(
44
44
  () => ({
45
- type: n,
46
- value: r,
47
- setValue: e,
48
- orientation: l,
49
- loop: d,
50
- groupDisabled: I,
45
+ focusItemByIndex: y,
46
+ groupDisabled: x,
47
+ isItemPressed: B,
48
+ itemsSnapshot: k,
49
+ loop: c,
51
50
  name: u,
52
- register: m,
53
- isItemPressed: k,
54
- focusItemByIndex: g,
55
- itemsSnapshot: V
51
+ orientation: b,
52
+ register: g,
53
+ setValue: e,
54
+ type: d,
55
+ value: n
56
56
  }),
57
- [I, k, V, d, u, l, e, n, r]
58
- ), h = u;
59
- return /* @__PURE__ */ E("div", { ...G, role: "group", "data-orientation": l, "data-disabled": I ? "" : void 0, "data-variant": D, "data-size": v, "data-slot": c, "data-layout": b, className: x, children: [
60
- /* @__PURE__ */ B(T.Provider, { value: y, children: C.children }),
61
- h && n === "single" && typeof r == "string" ? /* @__PURE__ */ B("input", { type: "hidden", name: h, value: r }) : null,
62
- h && n === "multiple" && Array.isArray(r) ? r.map((t) => /* @__PURE__ */ B("input", { type: "hidden", name: h + "[]", value: t }, t)) : null
57
+ [x, B, k, c, u, b, e, d, n]
58
+ ), I = u;
59
+ return /* @__PURE__ */ E("div", { className: o, "data-disabled": x ? "" : void 0, "data-layout": A, "data-orientation": b, "data-size": w, "data-slot": f, "data-variant": V, role: "group", ...G, children: [
60
+ /* @__PURE__ */ C(T.Provider, { value: h, children: z.children }),
61
+ I && d === "single" && typeof n == "string" ? /* @__PURE__ */ C("input", { type: "hidden", name: I, value: n }) : null,
62
+ I && d === "multiple" && Array.isArray(n) ? n.map((t) => /* @__PURE__ */ C("input", { type: "hidden", name: I + "[]", value: t }, t)) : null
63
63
  ] });
64
- }, X = H(function({ value: n, disabled: l, className: d, children: I, onKeyDown: u, onClick: x, ...z }, A) {
64
+ }, X = H(function({ value: o, disabled: i, className: x, children: c, onKeyDown: u, onClick: v, ...b }, d) {
65
65
  const a = K(T);
66
66
  if (!a) throw new Error("ToggleGroupItem must be used within ToggleGroup");
67
- const { type: D, orientation: v, groupDisabled: c, setValue: b, isItemPressed: G, itemsSnapshot: f, register: r } = a, p = S(null);
68
- L(A, () => p.current), N(() => r(n, p.current), [r, n]);
69
- const o = G(n), m = i(() => {
70
- if (!(c || l))
71
- if (D === "single") b(o ? "" : n);
67
+ const { type: V, orientation: w, groupDisabled: f, setValue: A, isItemPressed: G, itemsSnapshot: p, register: n } = a, m = S(null);
68
+ L(d, () => m.current), N(() => n(o, m.current), [n, o]);
69
+ const r = G(o), g = l(() => {
70
+ if (!(f || i))
71
+ if (V === "single") A(r ? "" : o);
72
72
  else {
73
- const e = a.value, g = o ? e.filter((y) => y !== n) : [...e, n];
74
- b(g);
73
+ const e = a.value, y = r ? e.filter((h) => h !== o) : [...e, o];
74
+ A(y);
75
75
  }
76
- }, [a.value, l, c, o, b, D, n]), V = i(
76
+ }, [a.value, i, f, r, A, V, o]), k = l(
77
77
  (e) => {
78
78
  if (u && u(e), e.defaultPrevented) return;
79
79
  if (e.key === " " || e.key === "Enter") {
80
- e.preventDefault(), m();
80
+ e.preventDefault(), g();
81
81
  return;
82
82
  }
83
- const g = f(), y = g.findIndex((s) => s.val === n), h = v === "horizontal" ? "ArrowLeft" : "ArrowUp", t = v === "horizontal" ? "ArrowRight" : "ArrowDown";
84
- e.key === h ? (e.preventDefault(), a.focusItemByIndex(y - 1)) : e.key === t ? (e.preventDefault(), a.focusItemByIndex(y + 1)) : e.key === "Home" ? (e.preventDefault(), a.focusItemByIndex(0)) : e.key === "End" && (e.preventDefault(), a.focusItemByIndex(g.length - 1));
83
+ const y = p(), h = y.findIndex((s) => s.val === o), I = w === "horizontal" ? "ArrowLeft" : "ArrowUp", t = w === "horizontal" ? "ArrowRight" : "ArrowDown";
84
+ e.key === I ? (e.preventDefault(), a.focusItemByIndex(h - 1)) : e.key === t ? (e.preventDefault(), a.focusItemByIndex(h + 1)) : e.key === "Home" ? (e.preventDefault(), a.focusItemByIndex(0)) : e.key === "End" && (e.preventDefault(), a.focusItemByIndex(y.length - 1));
85
85
  },
86
- [a, f, u, v, m, n]
87
- ), k = i(
86
+ [a, p, u, w, g, o]
87
+ ), B = l(
88
88
  (e) => {
89
- x && x(e), !e.defaultPrevented && m();
89
+ v && v(e), !e.defaultPrevented && g();
90
90
  },
91
- [x, m]
91
+ [v, g]
92
92
  );
93
- return /* @__PURE__ */ B("button", { ...z, ref: p, type: "button", "aria-pressed": o, "data-state": o ? "on" : "off", "data-disabled": c || l ? "" : void 0, disabled: c || l, onKeyDown: V, onClick: k, className: d, children: I });
93
+ return /* @__PURE__ */ C("button", { "aria-pressed": r, className: x, "data-disabled": f || i ? "" : void 0, "data-state": r ? "on" : "off", disabled: f || i, onClick: B, onKeyDown: k, ref: m, type: "button", ...b, children: c });
94
94
  });
95
95
  export {
96
96
  W as ToggleGroupBase,