@spear-ai/spectral 1.6.16 → 1.7.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.
Files changed (150) hide show
  1. package/dist/.js +196 -191
  2. package/dist/Accordion.d.ts +13 -15
  3. package/dist/Accordion.js +172 -165
  4. package/dist/Alert/AlertBase.d.ts +7 -7
  5. package/dist/Alert/AlertBase.js +23 -21
  6. package/dist/Alert.d.ts +2 -2
  7. package/dist/Alert.js +32 -30
  8. package/dist/Avatar.d.ts +2 -2
  9. package/dist/Avatar.js +30 -22
  10. package/dist/Badge.d.ts +1 -1
  11. package/dist/Badge.js +3 -2
  12. package/dist/Button.d.ts +3 -3
  13. package/dist/Button.js +108 -46
  14. package/dist/ButtonGroup/ButtonGroupButton.d.ts +1 -1
  15. package/dist/ButtonGroup/ButtonGroupButton.js +5 -5
  16. package/dist/ButtonGroup.d.ts +5 -5
  17. package/dist/ButtonGroup.js +21 -21
  18. package/dist/ButtonIcon.d.ts +2 -2
  19. package/dist/ButtonIcon.js +31 -30
  20. package/dist/Checkbox/CheckboxBase.d.ts +2 -2
  21. package/dist/Checkbox/CheckboxBase.js +50 -57
  22. package/dist/Checkbox.js +16 -18
  23. package/dist/DataCard/Card.d.ts +1 -1
  24. package/dist/DataCard/Card.js +1 -1
  25. package/dist/DataCard.js +1 -1
  26. package/dist/DateTimePicker/Calendar.d.ts +4 -4
  27. package/dist/DateTimePicker/Calendar.js +4 -2
  28. package/dist/DateTimePicker/DateTimeDisplayInput.js +126 -136
  29. package/dist/DateTimePicker/DateTimeInput.js +4 -4
  30. package/dist/DateTimePicker/DateTimeUtils.d.ts +31 -31
  31. package/dist/DateTimePicker/DateTimeUtils.js +139 -197
  32. package/dist/DateTimePicker/TimePicker.d.ts +4 -4
  33. package/dist/DateTimePicker/TimePicker.js +3 -3
  34. package/dist/DateTimePicker.d.ts +5 -5
  35. package/dist/DateTimePicker.js +96 -74
  36. package/dist/Dialog.d.ts +13 -13
  37. package/dist/Dialog.js +57 -84
  38. package/dist/Drawer.d.ts +2 -2
  39. package/dist/Drawer.js +8 -8
  40. package/dist/HoverCard.d.ts +6 -5
  41. package/dist/HoverCard.js +64 -64
  42. package/dist/Icons/LineToolIcon.js +37 -10
  43. package/dist/Icons/MeasureIcon.d.ts +5 -0
  44. package/dist/Icons/MeasureIcon.js +26 -0
  45. package/dist/Icons/SearchIcon.d.ts +5 -0
  46. package/dist/Icons/SearchIcon.js +10 -0
  47. package/dist/Icons/index.d.ts +2 -0
  48. package/dist/Icons.js +76 -72
  49. package/dist/IconsAnimated/PanelLeftCloseIcon.js +2 -2
  50. package/dist/IconsAnimated/PanelLeftOpenIcon.js +2 -2
  51. package/dist/Input/InputUtils.d.ts +2 -2
  52. package/dist/Input/InputUtils.js +4 -4
  53. package/dist/Input.d.ts +1 -1
  54. package/dist/Input.js +31 -29
  55. package/dist/InputOTP.d.ts +10 -10
  56. package/dist/InputOTP.js +125 -123
  57. package/dist/Kbd.d.ts +8 -5
  58. package/dist/Kbd.js +85 -20
  59. package/dist/Label.d.ts +4 -2
  60. package/dist/Label.js +3 -3
  61. package/dist/MultiSelect/MultiSelectBase.d.ts +1 -1
  62. package/dist/MultiSelect/MultiSelectBase.js +278 -200
  63. package/dist/MultiSelect.d.ts +6 -6
  64. package/dist/MultiSelect.js +9 -9
  65. package/dist/Popover.js +22 -237
  66. package/dist/RadioButtonGroup/RadioButtonGroupBase.d.ts +11 -11
  67. package/dist/RadioButtonGroup/RadioButtonGroupBase.js +28 -28
  68. package/dist/RadioButtonGroup.d.ts +1 -1
  69. package/dist/RadioGroup.d.ts +15 -15
  70. package/dist/RadioGroup.js +253 -236
  71. package/dist/Select.d.ts +3 -1
  72. package/dist/Select.js +92 -87
  73. package/dist/Separator.js +4 -4
  74. package/dist/Skeleton.d.ts +1 -2
  75. package/dist/Skeleton.js +2 -4
  76. package/dist/Slider.d.ts +6 -6
  77. package/dist/Slider.js +78 -78
  78. package/dist/Switch/SwitchBase.d.ts +4 -4
  79. package/dist/Switch/SwitchBase.js +68 -68
  80. package/dist/Switch.d.ts +3 -3
  81. package/dist/Switch.js +9 -9
  82. package/dist/Tabs/TabsBase.js +39 -38
  83. package/dist/Tabs/tabsUtils.js +7 -7
  84. package/dist/Tabs.d.ts +0 -4
  85. package/dist/Tabs.js +62 -66
  86. package/dist/Textarea/TextareaUtils.d.ts +7 -7
  87. package/dist/Textarea/TextareaUtils.js +13 -13
  88. package/dist/Textarea.js +34 -22
  89. package/dist/Toast.d.ts +43 -0
  90. package/dist/Toast.js +883 -0
  91. package/dist/Toggle/ToggleBase.d.ts +4 -4
  92. package/dist/Toggle/ToggleBase.js +32 -33
  93. package/dist/Toggle.d.ts +1 -1
  94. package/dist/Toggle.js +7 -12
  95. package/dist/ToggleGroup/ToggleGroupBase.d.ts +5 -5
  96. package/dist/ToggleGroup/ToggleGroupBase.js +30 -30
  97. package/dist/ToggleGroup.d.ts +1 -1
  98. package/dist/ToggleGroup.js +27 -30
  99. package/dist/Tooltip.d.ts +1 -1
  100. package/dist/Tooltip.js +97 -97
  101. package/dist/Tray.d.ts +9 -9
  102. package/dist/Tray.js +77 -74
  103. package/dist/hooks/useAccordionAutoScroll.d.ts.map +1 -1
  104. package/dist/hooks/useAccordionAutoScroll.js +42 -39
  105. package/dist/hooks/useControllableState.d.ts +2 -2
  106. package/dist/hooks/useControllableState.d.ts.map +1 -1
  107. package/dist/hooks/useControllableState.js +2 -2
  108. package/dist/index-C12FUuIW.js +13 -0
  109. package/dist/{index-yU8jOTzS.js → index-CpovUAO-.js} +1 -1
  110. package/dist/{index-BdS7Ix8W.js → index-CqbPiOid.js} +1 -1
  111. package/dist/{index-B3UpsZ2x.js → index-CrjD9cAD.js} +1 -1
  112. package/dist/index-DEYs15GP.js +66 -0
  113. package/dist/index-DdFoGvON.js +146 -0
  114. package/dist/index-Q3N6lgwg.js +225 -0
  115. package/dist/index.d.ts +3 -3
  116. package/dist/index.d.ts.map +1 -1
  117. package/dist/primitives/button.d.ts +1 -1
  118. package/dist/primitives/button.js +4 -4
  119. package/dist/primitives/input.d.ts.map +1 -1
  120. package/dist/primitives/input.js +8 -5
  121. package/dist/primitives/select.d.ts +12 -13
  122. package/dist/primitives/select.d.ts.map +1 -1
  123. package/dist/primitives/select.js +68 -95
  124. package/dist/primitives/slot.d.ts +5 -5
  125. package/dist/primitives/slot.d.ts.map +1 -1
  126. package/dist/primitives/slot.js +24 -33
  127. package/dist/primitives/textarea.d.ts.map +1 -1
  128. package/dist/primitives/textarea.js +4 -3
  129. package/dist/{proxy-Cukf-VVj.js → proxy-CgaCj1WQ.js} +7 -3
  130. package/dist/styles/base-colors.css +30 -30
  131. package/dist/styles/horizon/base-colors.css +30 -30
  132. package/dist/styles/horizon/colors.css +40 -11
  133. package/dist/styles/horizon/utilities.css +26 -3
  134. package/dist/styles/main.css +1 -1
  135. package/dist/styles/spectral.css +1 -1
  136. package/dist/styles/theme.css +96 -44
  137. package/dist/{use-animation-zNd5Nq85.js → use-animation-CR-SdV2l.js} +1 -1
  138. package/dist/utils/formFieldUtils.d.ts +2 -2
  139. package/dist/utils/formFieldUtils.d.ts.map +1 -1
  140. package/dist/utils/formFieldUtils.js +14 -11
  141. package/dist/utils/sharedUtils.d.ts +3 -3
  142. package/dist/utils/sharedUtils.d.ts.map +1 -1
  143. package/dist/utils/sharedUtils.js +1 -4
  144. package/dist/utils/twUtils.d.ts +1 -1
  145. package/dist/utils/twUtils.d.ts.map +1 -1
  146. package/dist/utils/twUtils.js +1 -4
  147. package/package.json +5 -1
  148. package/dist/createLucideIcon-D4r5Phnh.js +0 -70
  149. package/dist/index-CeP1E2kK.js +0 -209
  150. package/dist/index-Dy-Hzr7y.js +0 -13
package/dist/Switch.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { SwitchProps as SwitchBaseProps } from './SwitchBase';
2
2
  import { Ref } from 'react';
3
3
  export type SwitchProps = Omit<SwitchBaseProps, 'onCheckedChange'> & {
4
+ hideLabel?: boolean;
5
+ id: string;
4
6
  labelPosition?: 'left' | 'right';
5
7
  labelText: string;
6
- id: string;
7
- hideLabel?: boolean;
8
8
  onChange?: (checked: boolean) => void;
9
9
  ref?: Ref<HTMLButtonElement>;
10
10
  required?: boolean;
@@ -12,7 +12,7 @@ export type SwitchProps = Omit<SwitchBaseProps, 'onCheckedChange'> & {
12
12
  variant?: 'default' | 'squared';
13
13
  };
14
14
  export declare const Switch: {
15
- ({ ref, className, disabled, id, labelPosition, labelText, name, onChange, required, value, hideLabel, variant, ...props }: SwitchProps): import("react/jsx-runtime").JSX.Element;
15
+ ({ className, disabled, hideLabel, id, labelPosition, labelText, name, onChange, ref, required, value, variant, ...props }: SwitchProps): import("react/jsx-runtime").JSX.Element;
16
16
  displayName: string;
17
17
  };
18
18
  //# sourceMappingURL=Switch.d.ts.map
package/dist/Switch.js CHANGED
@@ -4,24 +4,24 @@ import { Switch as w, SwitchThumb as k } from "./Switch/SwitchBase.js";
4
4
  import { Label as r } from "./Label.js";
5
5
  import { cn as l } from "./utils/twUtils.js";
6
6
  import "react";
7
- const x = ({ ref: o, className: d, disabled: h, id: e, labelPosition: i = "right", labelText: s, name: b, onChange: u, required: c, value: m, hideLabel: a = !1, variant: f, ...g }) => {
7
+ const x = ({ className: o, disabled: d, hideLabel: s = !1, id: e, labelPosition: i = "right", labelText: a, name: h, onChange: b, ref: u, required: c, value: m, variant: f, ...g }) => {
8
8
  const n = f === "squared";
9
9
  return /* @__PURE__ */ p("div", { className: "flex items-center", "data-testid": "spectral-switch-container", children: [
10
- i === "left" && !a && /* @__PURE__ */ t(r, { htmlFor: e, className: "mr-2", "data-testid": "spectral-switch-label-left", children: s }),
10
+ i === "left" && !s && /* @__PURE__ */ t(r, { className: "mr-2", "data-testid": "spectral-switch-label-left", htmlFor: e, children: a }),
11
11
  /* @__PURE__ */ t(
12
12
  w,
13
13
  {
14
14
  "aria-required": c,
15
15
  className: l(
16
16
  n ? "peer data-[state=checked]:bg-switch-bg--checked data-[state=unchecked]:bg-switch-bg inline-flex h-6 w-10 shrink-0 items-center rounded-sm border-2 border-transparent transition-all outline-none focus-visible:ring-[3px] focus-visible:ring-black disabled:cursor-not-allowed disabled:opacity-50 [&_span]:rounded-[4px]" : "focus-visible:ring-ring focus-visible:ring-offset-background peer data-[state=checked]:bg-switch-bg--checked data-[state=unchecked]:bg-switch-bg inline-flex h-6 w-10 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-2xs transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
17
- d
17
+ o
18
18
  ),
19
19
  "data-testid": "spectral-switch",
20
- disabled: h,
20
+ disabled: d,
21
21
  id: e,
22
- name: b,
23
- onCheckedChange: u,
24
- ref: o,
22
+ name: h,
23
+ onCheckedChange: b,
24
+ ref: u,
25
25
  required: c,
26
26
  value: m,
27
27
  ...g,
@@ -35,8 +35,8 @@ const x = ({ ref: o, className: d, disabled: h, id: e, labelPosition: i = "right
35
35
  )
36
36
  }
37
37
  ),
38
- i === "right" && !a && /* @__PURE__ */ t(r, { htmlFor: e, id: `${e}-label`, className: "ml-2", "data-testid": "spectral-switch-label-right", children: s }),
39
- a && /* @__PURE__ */ t(r, { htmlFor: e, className: "sr-only", "data-testid": "spectral-switch-label-hidden", children: s })
38
+ i === "right" && !s && /* @__PURE__ */ t(r, { className: "ml-2", "data-testid": "spectral-switch-label-right", htmlFor: e, id: `${e}-label`, children: a }),
39
+ s && /* @__PURE__ */ t(r, { className: "sr-only", "data-testid": "spectral-switch-label-hidden", htmlFor: e, children: a })
40
40
  ] });
41
41
  };
42
42
  x.displayName = "Switch";
@@ -4,20 +4,21 @@ import { jsx as p, jsxs as E } from "react/jsx-runtime";
4
4
  import { generateId as K, prefersReducedMotion as $, calculateIndicatorStyle as S, debounce as j } from "./tabsUtils.js";
5
5
  import { cn as x } from "../utils/twUtils.js";
6
6
  import { createContext as k, useContext as U, useState as M, useId as F, useCallback as T, useRef as q, useMemo as B, useEffect as R } from "react";
7
- import { j as H, A as G } from "../index-CeP1E2kK.js";
8
- import { m as D } from "../proxy-Cukf-VVj.js";
7
+ import { j as H } from "../index-DEYs15GP.js";
8
+ import { m as D } from "../proxy-CgaCj1WQ.js";
9
+ import { A as G } from "../index-DdFoGvON.js";
9
10
  const N = k(null), A = (y = "Tabs") => {
10
11
  const d = U(N);
11
12
  if (d === null)
12
13
  throw new Error(`${y} components must be used within a Tabs.Root`);
13
14
  return d;
14
- }, _ = function({
15
+ }, V = function({
15
16
  ref: d,
16
17
  activationMode: g = "automatic",
17
18
  children: o,
18
19
  defaultValue: s,
19
- dir: u = "ltr",
20
- disabled: f = !1,
20
+ dir: f = "ltr",
21
+ disabled: u = !1,
21
22
  onValueChange: n,
22
23
  orientation: m = "horizontal",
23
24
  rightSlot: b,
@@ -26,27 +27,27 @@ const N = k(null), A = (y = "Tabs") => {
26
27
  }) {
27
28
  const [w, I] = M(s ?? ""), v = F() ?? K("tabs"), h = t !== void 0, c = h ? t : w, r = T(
28
29
  (e) => {
29
- f || (h || I(e), n?.(e));
30
+ u || (h || I(e), n?.(e));
30
31
  },
31
- [h, n, f]
32
+ [h, n, u]
32
33
  ), a = {
33
34
  activationMode: g,
34
35
  baseId: v,
35
- dir: u,
36
- disabled: f,
36
+ dir: f,
37
+ disabled: u,
37
38
  onValueChange: r,
38
39
  orientation: m,
39
40
  rightSlot: b,
40
41
  value: c
41
42
  };
42
- return /* @__PURE__ */ p(N.Provider, { value: a, children: /* @__PURE__ */ p("div", { ref: d, "data-testid": "spectral-tabs", "data-orientation": m, "data-disabled": f ? "" : void 0, dir: u, ...C, children: o }) });
43
- }, V = function({
43
+ return /* @__PURE__ */ p(N.Provider, { value: a, children: /* @__PURE__ */ p("div", { ref: d, "data-testid": "spectral-tabs", "data-orientation": m, "data-disabled": u ? "" : void 0, dir: f, ...C, children: o }) });
44
+ }, tt = function({
44
45
  ref: d,
45
46
  children: g,
46
47
  className: o,
47
48
  loop: s = !0,
48
- rightSlot: u,
49
- ...f
49
+ rightSlot: f,
50
+ ...u
50
51
  }) {
51
52
  const { orientation: n, disabled: m, value: b } = A("TabsList"), [t, C] = M(null), w = q(null), I = $(), v = T(() => {
52
53
  const r = S(w);
@@ -90,10 +91,10 @@ const N = k(null), A = (y = "Tabs") => {
90
91
  "aria-disabled": m,
91
92
  className: x("tabs-list flex", n === "horizontal" && "items-center justify-between", n === "vertical" && "flex-col", o),
92
93
  onKeyDown: c,
93
- ...f,
94
+ ...u,
94
95
  children: [
95
96
  /* @__PURE__ */ p("div", { className: x("flex", n === "horizontal" && "items-center", n === "vertical" && "flex-col"), children: g }),
96
- u && /* @__PURE__ */ p("div", { className: "z-10 flex items-center", children: u })
97
+ f && /* @__PURE__ */ p("div", { className: "z-10 flex items-center", children: f })
97
98
  ]
98
99
  }
99
100
  ),
@@ -102,10 +103,10 @@ const N = k(null), A = (y = "Tabs") => {
102
103
  {
103
104
  className: x(
104
105
  "pointer-events-none absolute top-0 left-0 will-change-transform select-none",
105
- t.orientation === "horizontal" && !t.isEnclosed && ["bottom-[1px] after:absolute after:bottom-0 after:left-0 after:w-full after:content-['']", "after:border-tabs-indicator z-10 after:rounded-t-[0.3rem] after:border-b-[0.3rem]"],
106
- t.orientation === "vertical" && !t.isEnclosed && ["right-[1px]", "after:absolute after:top-0 after:right-0 after:h-full after:w-1 after:content-['']", "after:border-tabs-indicator z-10 after:rounded-l-[0.3rem] after:border-r-[0.3rem]"],
107
- t.orientation === "horizontal" && t.isEnclosed && ["bg-tabs-enclosed-indicator z-0 rounded-lg shadow-lg"],
108
- t.orientation === "vertical" && t.isEnclosed && ["bg-tabs-enclosed-indicator z-0 rounded-lg shadow-lg"]
106
+ t.orientation === "horizontal" && !t.isEnclosed && "after:border-tabs-indicator bottom-px z-10 after:absolute after:bottom-0 after:left-0 after:w-full after:rounded-t-[0.3rem] after:border-b-[0.3rem] after:content-['']",
107
+ t.orientation === "vertical" && !t.isEnclosed && "after:border-tabs-indicator right-px z-10 after:absolute after:top-0 after:right-0 after:h-full after:w-1 after:rounded-l-[0.3rem] after:border-r-[0.3rem] after:content-['']",
108
+ t.orientation === "horizontal" && t.isEnclosed && "bg-tabs-enclosed-indicator z-0 rounded-lg shadow-lg",
109
+ t.orientation === "vertical" && t.isEnclosed && "bg-tabs-enclosed-indicator z-0 rounded-lg shadow-lg"
109
110
  ),
110
111
  initial: !1,
111
112
  animate: {
@@ -128,16 +129,16 @@ const N = k(null), A = (y = "Tabs") => {
128
129
  }
129
130
  )
130
131
  ] });
131
- }, tt = function({
132
+ }, et = function({
132
133
  ref: d,
133
134
  className: g,
134
135
  value: o,
135
136
  onClick: s,
136
- onKeyDown: u,
137
- disabled: f = !1,
137
+ onKeyDown: f,
138
+ disabled: u = !1,
138
139
  ...n
139
140
  }) {
140
- const { value: m, onValueChange: b, activationMode: t, disabled: C, baseId: w } = A("TabsTrigger"), I = `${w}-trigger-${o}`, v = `${w}-content-${o}`, h = m === o, c = C || f, r = T(
141
+ const { value: m, onValueChange: b, activationMode: t, disabled: C, baseId: w } = A("TabsTrigger"), I = `${w}-trigger-${o}`, v = `${w}-content-${o}`, h = m === o, c = C || u, r = T(
141
142
  (i) => {
142
143
  if (c) {
143
144
  i.preventDefault();
@@ -153,9 +154,9 @@ const N = k(null), A = (y = "Tabs") => {
153
154
  return;
154
155
  }
155
156
  const { key: l } = i;
156
- (l === "Enter" || l === " ") && (i.preventDefault(), i.stopPropagation(), b(o)), u?.(i);
157
+ (l === "Enter" || l === " ") && (i.preventDefault(), i.stopPropagation(), b(o)), f?.(i);
157
158
  },
158
- [o, b, u, c]
159
+ [o, b, f, c]
159
160
  ), e = T(() => {
160
161
  c || t === "automatic" && b(o);
161
162
  }, [t, b, o, c]);
@@ -181,12 +182,12 @@ const N = k(null), A = (y = "Tabs") => {
181
182
  ...n
182
183
  }
183
184
  );
184
- }, et = function({
185
+ }, nt = function({
185
186
  ref: d,
186
187
  children: g,
187
188
  className: o
188
189
  }) {
189
- const { value: s } = A("TabsContentContainer"), [u, f] = H(), n = $();
190
+ const { value: s } = A("TabsContentContainer"), [f, u] = H(), n = $();
190
191
  return /* @__PURE__ */ p(
191
192
  D.div,
192
193
  {
@@ -194,7 +195,7 @@ const N = k(null), A = (y = "Tabs") => {
194
195
  className: x("overflow-hidden", o),
195
196
  "data-testid": "spectral-tabs-content-container",
196
197
  animate: {
197
- height: f.height || "auto"
198
+ height: u.height || "auto"
198
199
  },
199
200
  transition: n ? { duration: 0 } : {
200
201
  duration: 0.3,
@@ -203,7 +204,7 @@ const N = k(null), A = (y = "Tabs") => {
203
204
  children: /* @__PURE__ */ p(G, { mode: "wait", initial: !1, children: /* @__PURE__ */ p(
204
205
  D.div,
205
206
  {
206
- ref: u,
207
+ ref: f,
207
208
  initial: n ? !1 : { opacity: 0, y: 8 },
208
209
  animate: { opacity: 1, y: 0 },
209
210
  exit: n ? void 0 : { opacity: 0, y: -8 },
@@ -217,14 +218,14 @@ const N = k(null), A = (y = "Tabs") => {
217
218
  ) })
218
219
  }
219
220
  );
220
- }, nt = function({
221
+ }, ot = function({
221
222
  ref: d,
222
223
  className: g,
223
224
  value: o,
224
225
  forceMount: s = !1,
225
- ...u
226
+ ...f
226
227
  }) {
227
- const { value: f, baseId: n } = A("TabsContent"), m = `${n}-content-${o}`, b = `${n}-trigger-${o}`, t = f === o;
228
+ const { value: u, baseId: n } = A("TabsContent"), m = `${n}-content-${o}`, b = `${n}-trigger-${o}`, t = u === o;
228
229
  return !s && !t ? null : /* @__PURE__ */ p(
229
230
  "div",
230
231
  {
@@ -237,16 +238,16 @@ const N = k(null), A = (y = "Tabs") => {
237
238
  ref: d,
238
239
  role: "tabpanel",
239
240
  tabIndex: 0,
240
- ...u
241
+ ...f
241
242
  }
242
243
  );
243
244
  };
244
245
  export {
245
- _ as TabsBase,
246
- nt as TabsContent,
247
- et as TabsContentContainer,
246
+ V as TabsBase,
247
+ ot as TabsContent,
248
+ nt as TabsContentContainer,
248
249
  N as TabsContext,
249
- V as TabsList,
250
- tt as TabsTrigger,
250
+ tt as TabsList,
251
+ et as TabsTrigger,
251
252
  A as useTabsContext
252
253
  };
@@ -13,19 +13,19 @@ const s = (e) => {
13
13
  if (!t) return { ...n, orientation: r, isEnclosed: o };
14
14
  const a = t.getBoundingClientRect(), i = e.current.getBoundingClientRect();
15
15
  return {
16
- left: a.left - i.left,
17
- top: a.top - i.top,
18
- width: a.width,
19
16
  height: a.height,
17
+ isEnclosed: o,
18
+ left: a.left - i.left,
20
19
  orientation: r,
21
- isEnclosed: o
20
+ top: a.top - i.top,
21
+ width: a.width
22
22
  };
23
23
  }, u = (e) => e.orientation === "horizontal" ? {
24
24
  left: `${e.left}px`,
25
25
  width: `${e.width}px`
26
26
  } : {
27
- top: `${e.top}px`,
28
- height: `${e.height}px`
27
+ height: `${e.height}px`,
28
+ top: `${e.top}px`
29
29
  }, d = (e, n) => {
30
30
  let t = null;
31
31
  const r = (...o) => {
@@ -52,7 +52,7 @@ const s = (e) => {
52
52
  if (!Array.isArray(e) || e.length === 0)
53
53
  return console.warn("Tabs: tabValues must be a non-empty array"), !1;
54
54
  const n = /* @__PURE__ */ new Set();
55
- for (let t = 0; t < e.length; t++) {
55
+ for (let t = 0; t < e.length; t += 1) {
56
56
  const r = e[t];
57
57
  if (!c(r, t))
58
58
  return !1;
package/dist/Tabs.d.ts CHANGED
@@ -17,10 +17,6 @@ export interface TabsProps extends Omit<TabsBaseProps, 'children' | 'defaultValu
17
17
  onBeforeChange?: (newValue: string, oldValue: string) => boolean | Promise<boolean> | undefined;
18
18
  onError?: ((error: Error) => void) | undefined;
19
19
  loading?: boolean | undefined;
20
- /**
21
- * Initial tab to open (uncontrolled mode).
22
- * Mutually exclusive with `value` - use one or the other.
23
- */
24
20
  openOnLoad?: string | undefined;
25
21
  rightSlot?: ReactNode | undefined;
26
22
  tabValues: TabValue[] | undefined;
package/dist/Tabs.js CHANGED
@@ -1,92 +1,88 @@
1
1
  import "./styles/main.css";
2
- import { jsx as l, jsxs as N } from "react/jsx-runtime";
3
- import { TabsBase as j, TabsList as E, TabsTrigger as K, TabsContentContainer as $, TabsContent as A } from "./Tabs/TabsBase.js";
2
+ import { jsx as a, jsxs as C } from "react/jsx-runtime";
3
+ import { TabsBase as j, TabsList as E, TabsTrigger as K, TabsContentContainer as V, TabsContent as $ } from "./Tabs/TabsBase.js";
4
4
  import { validateTabValues as B, getTabKeys as I } from "./Tabs/tabsUtils.js";
5
- import { cn as r } from "./utils/twUtils.js";
5
+ import { cn as s } from "./utils/twUtils.js";
6
6
  import "react";
7
- const L = ({ tabCount: f, orientation: s, hideContent: v }) => /* @__PURE__ */ N("div", { className: "relative flex w-full flex-col", role: "status", children: [
8
- /* @__PURE__ */ l("div", { className: r("inline-flex w-full items-center justify-start", s === "horizontal" && "border-b border-neutral-600", s === "vertical" && "flex-col items-stretch border-r border-neutral-600"), children: Array.from({ length: Math.min(f, 5) }, (h, x) => /* @__PURE__ */ l("div", { className: r("animate-pulse rounded bg-neutral-600", s === "horizontal" ? "mx-2 my-2 h-6 w-16" : "mx-2 my-1 h-6 w-full"), "aria-hidden": "true" }, x)) }),
9
- !v && /* @__PURE__ */ l("div", { className: "mt-4 h-32 w-full animate-pulse rounded bg-neutral-600", "aria-hidden": "true" }),
10
- /* @__PURE__ */ l("span", { className: "sr-only", children: "Loading tabs…" })
11
- ] }), _ = ({
12
- activationMode: f = "automatic",
13
- ariaLabel: s,
14
- className: v,
15
- hideContent: h = !1,
16
- loading: x = !1,
17
- onBeforeChange: y,
18
- onError: m,
19
- onValueChange: g,
20
- openOnLoad: o,
21
- orientation: a = "horizontal",
22
- rightSlot: T,
23
- tabValues: w = [],
24
- value: d,
25
- variant: t = "default",
26
- ...k
7
+ const F = ({
8
+ activationMode: p = "automatic",
9
+ ariaLabel: h,
10
+ className: m,
11
+ hideContent: y = !1,
12
+ loading: g = !1,
13
+ onBeforeChange: v,
14
+ onError: f,
15
+ onValueChange: x,
16
+ openOnLoad: c,
17
+ orientation: t = "horizontal",
18
+ rightSlot: w,
19
+ tabValues: T = [],
20
+ value: o,
21
+ variant: l = "default",
22
+ ...N
27
23
  }) => {
28
- const n = w.filter((e) => e.key !== void 0), b = d !== void 0;
29
- if (!B(n)) {
24
+ if (g)
25
+ return /* @__PURE__ */ a("div", { className: "text-text-secondary relative flex w-full flex-col p-4 text-center", role: "status", "aria-live": "polite", children: /* @__PURE__ */ a("p", { children: "Loading tabs…" }) });
26
+ const d = T.filter((e) => e.key !== void 0), n = o !== void 0;
27
+ if (!B(d)) {
30
28
  const e = new Error("Invalid tabValues provided to Tabs component");
31
- return m?.(e), /* @__PURE__ */ l("div", { className: "relative flex w-full flex-col p-4 text-center text-gray-500", role: "alert", "aria-live": "polite", children: /* @__PURE__ */ l("p", { children: "No valid tabs provided" }) });
29
+ return f?.(e), /* @__PURE__ */ a("div", { className: "relative flex w-full flex-col p-4 text-center text-gray-500", role: "alert", "aria-live": "polite", children: /* @__PURE__ */ a("p", { children: "No valid tabs provided" }) });
32
30
  }
33
- if (x)
34
- return /* @__PURE__ */ l(L, { tabCount: w.length || 3, orientation: a, hideContent: h });
35
- const i = I(n);
36
- let u;
37
- b && (i.includes(d) ? u = d : (console.warn(`Tabs: value '${d}' is not a valid tab key, falling back to first tab`), u = i[0]));
38
- let c;
39
- if (!b && (c = o ?? i[0], o && !i.includes(o) && (console.warn(`Tabs: openOnLoad value '${o}' is not a valid tab key`), c = i[0]), !c)) {
31
+ const r = I(d);
32
+ let b;
33
+ n && (r.includes(o) ? b = o : (console.warn(`Tabs: value '${o}' is not a valid tab key, falling back to first tab`), b = r[0]));
34
+ let i;
35
+ if (!n && (i = c ?? r[0], c && !r.includes(c) && (console.warn(`Tabs: openOnLoad value '${c}' is not a valid tab key`), i = r[0]), !i)) {
40
36
  const e = new Error("No valid default tab available");
41
- return m?.(e), /* @__PURE__ */ l("div", { className: "text-text-secondary relative flex w-full flex-col p-4 text-center", role: "alert", "aria-live": "polite", children: /* @__PURE__ */ l("p", { children: "Unable to render tabs" }) });
37
+ return f?.(e), /* @__PURE__ */ a("div", { className: "text-text-secondary relative flex w-full flex-col p-4 text-center", role: "alert", "aria-live": "polite", children: /* @__PURE__ */ a("p", { children: "Unable to render tabs" }) });
42
38
  }
43
- const z = async (e) => {
44
- if (y && g) {
45
- const C = b ? u : c;
39
+ const k = async (e) => {
40
+ if (v && x) {
41
+ const z = n ? b ?? "" : i ?? "";
46
42
  try {
47
- if (await y(e, C) === !1) return;
48
- } catch (p) {
49
- m?.(p instanceof Error ? p : new Error("Before change callback failed"));
43
+ if (await v(e, z) === !1) return;
44
+ } catch (u) {
45
+ f?.(u instanceof Error ? u : new Error("Before change callback failed"));
50
46
  return;
51
47
  }
52
48
  }
53
- g?.(e);
49
+ x?.(e);
54
50
  };
55
- return /* @__PURE__ */ l("div", { className: "relative flex w-full flex-col", children: /* @__PURE__ */ N(
51
+ return /* @__PURE__ */ a("div", { className: "relative flex w-full flex-col", children: /* @__PURE__ */ C(
56
52
  j,
57
53
  {
58
- "aria-label": s,
59
- className: r("relative w-full data-[orientation=vertical]:flex", t, v),
60
- ...b ? { value: u } : { defaultValue: c },
61
- orientation: a,
62
- activationMode: f,
63
- onValueChange: z,
64
- ...k,
54
+ "aria-label": h,
55
+ className: s("relative w-full data-[orientation=vertical]:flex", l, m),
56
+ ...n ? { value: b } : { defaultValue: i },
57
+ orientation: t,
58
+ activationMode: p,
59
+ onValueChange: k,
60
+ ...N,
65
61
  children: [
66
- /* @__PURE__ */ l(
62
+ /* @__PURE__ */ a(
67
63
  E,
68
64
  {
69
- className: r(
65
+ className: s(
70
66
  "inline-flex w-full items-center justify-between",
71
- a === "horizontal" && t === "default" && ["border-tabs-border border-b"],
72
- a === "vertical" && t === "default" && ["border-tabs-border relative m-0 h-auto w-auto flex-col items-stretch border-r py-1"],
73
- a === "horizontal" && t === "enclosed" && ["bg-tabs-group-bg relative rounded-lg border-0 p-1"],
74
- a === "vertical" && t === "enclosed" && ["bg-tabs-group-bg w-auto flex-col rounded-lg border-0 p-1"]
67
+ t === "horizontal" && l === "default" && "border-tabs-border border-b",
68
+ t === "vertical" && l === "default" && "border-tabs-border relative m-0 h-auto w-auto flex-col items-stretch border-r py-1",
69
+ t === "horizontal" && l === "enclosed" && "bg-tabs-group-bg relative rounded-lg border-0 p-1",
70
+ t === "vertical" && l === "enclosed" && "bg-tabs-group-bg w-auto flex-col rounded-lg border-0 p-1"
75
71
  ),
76
- rightSlot: T,
77
- children: n.map((e) => /* @__PURE__ */ l(
72
+ rightSlot: w,
73
+ children: d.map((e) => /* @__PURE__ */ a(
78
74
  K,
79
75
  {
80
76
  value: e.key,
81
77
  disabled: e.disabled,
82
78
  "aria-label": e["aria-label"],
83
79
  "aria-describedby": e["aria-describedby"],
84
- className: r(
80
+ className: s(
85
81
  "relative font-semibold whitespace-nowrap transition-all duration-500 ease-in-out focus:outline-none focus-visible:outline-none",
86
- a === "horizontal" && t === "default" && ["text-text-primary hover:text-accent hover:bg-tabs-bg--hover px-4 py-2"],
87
- a === "vertical" && t === "default" && ["text-text-primary data-[state=active]:text-accent hover:text-accent hover:bg-tabs-bg--hover flex h-10 items-center px-4 py-2"],
88
- a === "horizontal" && t === "enclosed" && ["text-text-primary data-[state=active]:text-accent hover:text-accent hover:bg-tabs-bg--hover z-[1] inline-flex items-center justify-center px-4 py-2"],
89
- a === "vertical" && t === "enclosed" && ["text-text-primary data-[state=active]:text-accent hover:text-accent hover:bg-tabs-bg--hover z-[1] px-4 py-2"],
82
+ t === "horizontal" && l === "default" && "text-text-primary hover:text-accent hover:bg-tabs-bg--hover px-4 py-2",
83
+ t === "vertical" && l === "default" && "text-text-primary data-[state=active]:text-accent hover:text-accent hover:bg-tabs-bg--hover flex h-10 items-center px-4 py-2",
84
+ t === "horizontal" && l === "enclosed" && "text-text-primary data-[state=active]:text-accent hover:text-accent hover:bg-tabs-bg--hover z-[1] inline-flex items-center justify-center px-4 py-2",
85
+ t === "vertical" && l === "enclosed" && "text-text-primary data-[state=active]:text-accent hover:text-accent hover:bg-tabs-bg--hover z-1 px-4 py-2",
90
86
  "disabled:hover:text-text-primary disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent"
91
87
  ),
92
88
  children: e.label
@@ -95,15 +91,15 @@ const L = ({ tabCount: f, orientation: s, hideContent: v }) => /* @__PURE__ */ N
95
91
  ))
96
92
  }
97
93
  ),
98
- !h && /* @__PURE__ */ l($, { className: r(a === "vertical" && "flex-1"), children: n.map((e) => /* @__PURE__ */ l(A, { value: e.key, className: r("focus-visible:outline-accent text-text-primary focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2", a === "horizontal" && "pb-4", a === "vertical" && "px-4 py-2"), children: e.children }, e.key)) })
94
+ !y && /* @__PURE__ */ a(V, { className: s(t === "vertical" && "flex-1"), children: d.map((e) => /* @__PURE__ */ a($, { value: e.key, className: s("focus-visible:outline-accent text-text-primary focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2", t === "horizontal" && "pb-4", t === "vertical" && "px-4 py-2"), children: e.children }, e.key)) })
99
95
  ]
100
96
  }
101
97
  ) });
102
98
  };
103
99
  export {
104
- _ as Tabs,
105
- A as TabsContent,
106
- $ as TabsContentContainer,
100
+ F as Tabs,
101
+ $ as TabsContent,
102
+ V as TabsContentContainer,
107
103
  E as TabsList,
108
104
  j as TabsRoot,
109
105
  K as TabsTrigger
@@ -1,17 +1,17 @@
1
1
  import { ChangeEvent, ClipboardEvent, FocusEvent } from 'react';
2
- export type UseTextareaOptions = {
2
+ export interface UseTextareaOptions {
3
3
  maxLength: number;
4
- value: string;
4
+ onBlur?: (e: FocusEvent<HTMLTextAreaElement>) => void;
5
5
  onChange: (value: string) => void;
6
6
  onFocus?: (e: FocusEvent<HTMLTextAreaElement>) => void;
7
- onBlur?: (e: FocusEvent<HTMLTextAreaElement>) => void;
8
- };
9
- export type UseTextareaReturn = {
10
- handleFocus: (e: FocusEvent<HTMLTextAreaElement>) => void;
7
+ value: string;
8
+ }
9
+ export interface UseTextareaReturn {
11
10
  handleBlur: (e: FocusEvent<HTMLTextAreaElement>) => void;
12
11
  handleChange: (e: ChangeEvent<HTMLTextAreaElement>) => void;
12
+ handleFocus: (e: FocusEvent<HTMLTextAreaElement>) => void;
13
13
  handlePaste: (e: ClipboardEvent<HTMLTextAreaElement>) => void;
14
- };
14
+ }
15
15
  /**
16
16
  * Custom hook for textarea functionality with character limits and event handling
17
17
  */
@@ -1,24 +1,24 @@
1
1
  "use client";
2
2
  import { useCallback as i } from "react";
3
- const T = (t, n, s) => {
4
- const a = t.target.value;
5
- a.length <= n && s?.(a);
6
- }, V = (t, n, s, a) => {
7
- const r = t.clipboardData.getData("text"), c = n || "", o = t.currentTarget, l = o.selectionStart || 0, u = o.selectionEnd || 0, e = c.substring(0, l), d = c.substring(u);
8
- if ((e + r + d).length > s) {
3
+ const T = (t, a, s) => {
4
+ const n = t.target.value;
5
+ n.length <= a && s?.(n);
6
+ }, V = (t, a, s, n) => {
7
+ const r = t.clipboardData.getData("text"), c = s || "", o = t.currentTarget, l = o.selectionStart || 0, u = o.selectionEnd || 0, e = c.substring(0, l), d = c.substring(u);
8
+ if ((e + r + d).length > a) {
9
9
  t.preventDefault();
10
- const g = u - l, h = s - c.length + g, p = r.substring(0, Math.max(0, h)), f = e + p + d;
11
- a?.(f), setTimeout(() => {
10
+ const g = u - l, h = a - c.length + g, p = r.substring(0, Math.max(0, h)), f = e + p + d;
11
+ n?.(f), setTimeout(() => {
12
12
  const b = l + p.length;
13
13
  o.setSelectionRange(b, b);
14
14
  }, 0);
15
15
  }
16
- }, P = ({ maxLength: t, value: n, onChange: s, onFocus: a, onBlur: r }) => {
16
+ }, P = ({ maxLength: t, value: a, onChange: s, onFocus: n, onBlur: r }) => {
17
17
  const c = i(
18
18
  (e) => {
19
- a?.(e);
19
+ n?.(e);
20
20
  },
21
- [a]
21
+ [n]
22
22
  ), o = i(
23
23
  (e) => {
24
24
  r?.(e);
@@ -31,9 +31,9 @@ const T = (t, n, s) => {
31
31
  [t, s]
32
32
  ), u = i(
33
33
  (e) => {
34
- V(e, n, t, s);
34
+ V(e, t, a, s);
35
35
  },
36
- [n, t, s]
36
+ [a, t, s]
37
37
  );
38
38
  return {
39
39
  handleFocus: c,