@spear-ai/spectral 1.4.26 → 1.4.27

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 (203) hide show
  1. package/dist/Accordion.d.ts +28 -9
  2. package/dist/Accordion.js +203 -183
  3. package/dist/Alert/AlertBase.d.ts +24 -16
  4. package/dist/Alert/AlertBase.js +33 -18
  5. package/dist/Alert.js +1 -1
  6. package/dist/Avatar.js +11 -11
  7. package/dist/Button.d.ts +7 -2
  8. package/dist/Button.js +25 -12
  9. package/dist/ButtonIcon.d.ts +7 -2
  10. package/dist/ButtonIcon.js +25 -16
  11. package/dist/Card.js +1 -1
  12. package/dist/Checkbox/CheckboxBase.d.ts +13 -13
  13. package/dist/Checkbox/CheckboxBase.js +128 -125
  14. package/dist/Checkbox.d.ts +7 -2
  15. package/dist/Checkbox.js +29 -22
  16. package/dist/DataCard.js +3 -3
  17. package/dist/Dialog.js +2 -2
  18. package/dist/Drawer.js +2 -2
  19. package/dist/HoverCard.js +1 -1
  20. package/dist/Icons/AnalyzeIcon.d.ts +3 -1
  21. package/dist/Icons/AnalyzeIcon.js +3 -6
  22. package/dist/Icons/AnnotationsIcon.d.ts +3 -1
  23. package/dist/Icons/AnnotationsIcon.js +3 -6
  24. package/dist/Icons/ApprovedIcon.d.ts +3 -1
  25. package/dist/Icons/ApprovedIcon.js +3 -6
  26. package/dist/Icons/ArrowDownIcon.d.ts +3 -1
  27. package/dist/Icons/ArrowDownIcon.js +3 -6
  28. package/dist/Icons/ArrowUpIcon.d.ts +3 -1
  29. package/dist/Icons/ArrowUpIcon.js +4 -7
  30. package/dist/Icons/CalendarIcon.d.ts +3 -1
  31. package/dist/Icons/CalendarIcon.js +9 -12
  32. package/dist/Icons/CheckCircleIcon.d.ts +3 -1
  33. package/dist/Icons/CheckCircleIcon.js +2 -5
  34. package/dist/Icons/CheckSquareIcon.d.ts +3 -1
  35. package/dist/Icons/CheckSquareIcon.js +4 -7
  36. package/dist/Icons/CheckmarkIcon.d.ts +3 -1
  37. package/dist/Icons/CheckmarkIcon.js +5 -8
  38. package/dist/Icons/ChevronDownIcon.d.ts +3 -1
  39. package/dist/Icons/ChevronDownIcon.js +5 -8
  40. package/dist/Icons/ChevronUpIcon.d.ts +3 -1
  41. package/dist/Icons/ChevronUpIcon.js +5 -8
  42. package/dist/Icons/ClockIcon.d.ts +3 -1
  43. package/dist/Icons/ClockIcon.js +5 -8
  44. package/dist/Icons/CloseCircleIcon.d.ts +3 -1
  45. package/dist/Icons/CloseCircleIcon.js +4 -7
  46. package/dist/Icons/CloseIcon.d.ts +3 -1
  47. package/dist/Icons/CloseIcon.js +5 -8
  48. package/dist/Icons/DashboardIcon.d.ts +3 -1
  49. package/dist/Icons/DashboardIcon.js +3 -6
  50. package/dist/Icons/DatabaseIcon.d.ts +3 -1
  51. package/dist/Icons/DatabaseIcon.js +4 -7
  52. package/dist/Icons/DeleteIcon.d.ts +3 -1
  53. package/dist/Icons/DeleteIcon.js +4 -7
  54. package/dist/Icons/DurationIcon.d.ts +3 -1
  55. package/dist/Icons/DurationIcon.js +3 -6
  56. package/dist/Icons/EditIcon.d.ts +3 -1
  57. package/dist/Icons/EditIcon.js +3 -6
  58. package/dist/Icons/EmailIcon.d.ts +3 -1
  59. package/dist/Icons/EmailIcon.js +4 -7
  60. package/dist/Icons/EraserIcon.d.ts +3 -1
  61. package/dist/Icons/EraserIcon.js +9 -10
  62. package/dist/Icons/ErrorIcon.d.ts +3 -1
  63. package/dist/Icons/ErrorIcon.js +4 -7
  64. package/dist/Icons/EyeClosedIcon.d.ts +3 -1
  65. package/dist/Icons/EyeClosedIcon.js +4 -7
  66. package/dist/Icons/EyeClosedIcon2.d.ts +3 -1
  67. package/dist/Icons/EyeClosedIcon2.js +3 -6
  68. package/dist/Icons/EyeOpenIcon.d.ts +3 -1
  69. package/dist/Icons/EyeOpenIcon.js +6 -9
  70. package/dist/Icons/GoToFirstIcon.d.ts +3 -1
  71. package/dist/Icons/GoToFirstIcon.js +4 -7
  72. package/dist/Icons/GoToLastIcon.d.ts +3 -1
  73. package/dist/Icons/GoToLastIcon.js +4 -7
  74. package/dist/Icons/HarmonicCursorsIcon.d.ts +3 -1
  75. package/dist/Icons/HarmonicCursorsIcon.js +4 -7
  76. package/dist/Icons/IconBase.d.ts +4 -2
  77. package/dist/Icons/IconBase.js +17 -8
  78. package/dist/Icons/InfoIcon.d.ts +3 -1
  79. package/dist/Icons/InfoIcon.js +4 -7
  80. package/dist/Icons/LabelIcon.d.ts +3 -1
  81. package/dist/Icons/LabelIcon.js +3 -6
  82. package/dist/Icons/LassoIcon.d.ts +3 -1
  83. package/dist/Icons/LassoIcon.js +5 -8
  84. package/dist/Icons/LineToolIcon.d.ts +3 -1
  85. package/dist/Icons/LineToolIcon.js +3 -6
  86. package/dist/Icons/LineToolIcon2.d.ts +3 -1
  87. package/dist/Icons/LineToolIcon2.js +3 -6
  88. package/dist/Icons/LiveViewIcon.d.ts +3 -1
  89. package/dist/Icons/LiveViewIcon.js +2 -5
  90. package/dist/Icons/LoaderIcon.d.ts +3 -1
  91. package/dist/Icons/LoaderIcon.js +6 -7
  92. package/dist/Icons/LocationIcon.d.ts +3 -1
  93. package/dist/Icons/LocationIcon.js +3 -6
  94. package/dist/Icons/LogoutIcon.d.ts +3 -1
  95. package/dist/Icons/LogoutIcon.js +4 -7
  96. package/dist/Icons/MessagesIcon.d.ts +3 -1
  97. package/dist/Icons/MessagesIcon.js +5 -8
  98. package/dist/Icons/MetadataIcon.d.ts +3 -1
  99. package/dist/Icons/MetadataIcon.js +4 -7
  100. package/dist/Icons/MinusIcon.d.ts +3 -1
  101. package/dist/Icons/MinusIcon.js +3 -6
  102. package/dist/Icons/OntologyIcon.d.ts +3 -1
  103. package/dist/Icons/OntologyIcon.js +2 -5
  104. package/dist/Icons/PanelIconClose.d.ts +3 -1
  105. package/dist/Icons/PanelIconClose.js +4 -7
  106. package/dist/Icons/PanelIconOpen.d.ts +3 -1
  107. package/dist/Icons/PanelIconOpen.js +8 -11
  108. package/dist/Icons/PlayIcon.d.ts +3 -1
  109. package/dist/Icons/PlayIcon.js +3 -6
  110. package/dist/Icons/PlusIcon.d.ts +3 -1
  111. package/dist/Icons/PlusIcon.js +4 -7
  112. package/dist/Icons/ResetIcon.d.ts +3 -1
  113. package/dist/Icons/ResetIcon.js +4 -7
  114. package/dist/Icons/ReviewedIcon.d.ts +3 -1
  115. package/dist/Icons/ReviewedIcon.js +3 -6
  116. package/dist/Icons/ScissorsIcon.d.ts +3 -1
  117. package/dist/Icons/ScissorsIcon.js +6 -9
  118. package/dist/Icons/SettingsIcon.d.ts +3 -1
  119. package/dist/Icons/SettingsIcon.js +3 -6
  120. package/dist/Icons/SortAscendingIcon.d.ts +3 -1
  121. package/dist/Icons/SortAscendingIcon.js +3 -6
  122. package/dist/Icons/SortAtoZIcon.d.ts +3 -1
  123. package/dist/Icons/SortAtoZIcon.js +3 -6
  124. package/dist/Icons/SortDescendingIcon.d.ts +3 -1
  125. package/dist/Icons/SortDescendingIcon.js +3 -6
  126. package/dist/Icons/SortZtoAIcon.d.ts +3 -1
  127. package/dist/Icons/SortZtoAIcon.js +3 -6
  128. package/dist/Icons/StackIcon.d.ts +3 -1
  129. package/dist/Icons/StackIcon.js +4 -7
  130. package/dist/Icons/StarIcon.d.ts +3 -1
  131. package/dist/Icons/StarIcon.js +3 -6
  132. package/dist/Icons/TrashIcon.d.ts +3 -1
  133. package/dist/Icons/TrashIcon.js +3 -6
  134. package/dist/Icons/UndoIcon.d.ts +3 -1
  135. package/dist/Icons/UndoIcon.js +4 -7
  136. package/dist/Icons/UserIcon.d.ts +3 -1
  137. package/dist/Icons/UserIcon.js +3 -6
  138. package/dist/Icons/WarningIcon.d.ts +3 -1
  139. package/dist/Icons/WarningIcon.js +5 -8
  140. package/dist/Icons/ZoomAllIcon.d.ts +3 -1
  141. package/dist/Icons/ZoomAllIcon.js +3 -6
  142. package/dist/Icons/ZoomXIcon.d.ts +3 -1
  143. package/dist/Icons/ZoomXIcon.js +4 -7
  144. package/dist/Icons/ZoomYIcon.d.ts +3 -1
  145. package/dist/Icons/ZoomYIcon.js +4 -7
  146. package/dist/Input/InputUtils.d.ts +4 -4
  147. package/dist/Input/InputUtils.js +1 -1
  148. package/dist/Input.d.ts +7 -17
  149. package/dist/Input.js +105 -101
  150. package/dist/InputOTP.d.ts +27 -7
  151. package/dist/InputOTP.js +171 -146
  152. package/dist/Label.d.ts +7 -2
  153. package/dist/Label.js +12 -9
  154. package/dist/MultiSelect/MultiSelectBase.d.ts +7 -2
  155. package/dist/MultiSelect/MultiSelectBase.js +212 -213
  156. package/dist/{MultiSelect/MutiSelect.d.ts → MultiSelect.d.ts} +8 -2
  157. package/dist/MultiSelect.js +27 -0
  158. package/dist/Popover.js +1 -1
  159. package/dist/RadioButtonGroup.js +1 -1
  160. package/dist/RadioGroup.d.ts +20 -14
  161. package/dist/RadioGroup.js +177 -148
  162. package/dist/Select.d.ts +7 -2
  163. package/dist/Select.js +108 -109
  164. package/dist/Separator.d.ts +8 -8
  165. package/dist/Separator.js +14 -15
  166. package/dist/Switch/SwitchBase.d.ts +13 -11
  167. package/dist/Switch/SwitchBase.js +84 -61
  168. package/dist/Switch.d.ts +11 -4
  169. package/dist/Switch.js +19 -20
  170. package/dist/Tabs/TabsBase.d.ts +16 -6
  171. package/dist/Tabs/TabsBase.js +133 -96
  172. package/dist/Tabs/tabsUtils.d.ts +6 -2
  173. package/dist/Tabs/tabsUtils.js +5 -2
  174. package/dist/Tabs.js +18 -18
  175. package/dist/Textarea.d.ts +7 -2
  176. package/dist/Textarea.js +78 -61
  177. package/dist/Toggle/ToggleBase.d.ts +4 -8
  178. package/dist/Toggle/ToggleBase.js +29 -16
  179. package/dist/Toggle.d.ts +4 -2
  180. package/dist/Toggle.js +23 -13
  181. package/dist/ToggleGroup/ToggleGroupBase.d.ts +4 -7
  182. package/dist/ToggleGroup/ToggleGroupBase.js +82 -73
  183. package/dist/ToggleGroup.d.ts +7 -2
  184. package/dist/ToggleGroup.js +31 -19
  185. package/dist/Tray.d.ts +47 -15
  186. package/dist/Tray.js +98 -60
  187. package/dist/hooks/useAccordionAutoScroll.d.ts +1 -1
  188. package/dist/hooks/useAccordionAutoScroll.d.ts.map +1 -1
  189. package/dist/hooks/useAccordionAutoScroll.js +35 -34
  190. package/dist/{index-BSCg4Mei.js → index-B0Kp8R0j.js} +3 -3
  191. package/dist/{index-jgQ7sgLl.js → index-D4jMMaAi.js} +5 -5
  192. package/dist/primitives/input.d.ts.map +1 -1
  193. package/dist/primitives/input.js +1 -4
  194. package/dist/primitives/select.d.ts.map +1 -1
  195. package/dist/primitives/select.js +4 -11
  196. package/dist/primitives/slot.d.ts +11 -4
  197. package/dist/primitives/slot.d.ts.map +1 -1
  198. package/dist/primitives/slot.js +32 -28
  199. package/dist/primitives/textarea.d.ts.map +1 -1
  200. package/dist/primitives/textarea.js +1 -3
  201. package/dist/utils/formFieldUtils.js +2 -2
  202. package/package.json +1 -1
  203. package/dist/MultiSelect/MutiSelect.js +0 -19
package/dist/Select.js CHANGED
@@ -64,118 +64,117 @@ import "./Icons/ZoomAllIcon.js";
64
64
  import "./Icons/ZoomXIcon.js";
65
65
  import "./Icons/ZoomYIcon.js";
66
66
  import { Label as C } from "./Label.js";
67
- import { R as X, T as Y, f as Z, e as _, C as $, c as tt, V as et, S as rt, d as I, G as at, I as it, b as st, a as ot } from "./index-BSCg4Mei.js";
68
- import { useFormFieldId as lt, useFormFieldState as dt, getAriaProps as mt, getErrorMessageId as ct, groupOptions as pt, getFormFieldCSSProperties as nt, getStateClasses as ut, getTriggerClasses as ht, ErrorMessage as gt, LoadingState as bt, EmptyState as ft, getOptionClasses as xt } from "./utils/formFieldUtils.js";
67
+ import { R as X, T as Y, f as Z, e as _, C as $, c as tt, V as et, S as rt, d as I, G as at, I as it, b as st, a as ot } from "./index-B0Kp8R0j.js";
68
+ import { useFormFieldId as lt, useFormFieldState as dt, getAriaProps as mt, groupOptions as ct, getFormFieldCSSProperties as pt, getStateClasses as nt, getTriggerClasses as ut, ErrorMessage as ht, getErrorMessageId as gt, LoadingState as bt, EmptyState as ft, getOptionClasses as xt } from "./utils/formFieldUtils.js";
69
69
  import { cn as s } from "./utils/twUtils.js";
70
- import { forwardRef as yt, useState as Nt } from "react";
71
- const vt = yt(
72
- ({
73
- align: w = "start",
74
- alignOffset: z = 0,
75
- className: F,
76
- collisionPadding: O = 10,
77
- defaultValue: j,
78
- emptyMessage: k = "No options found",
79
- errorMessage: p,
80
- id: L,
81
- label: l,
82
- labelClassName: n,
83
- loadingMessage: T = "Loading…",
84
- name: u,
85
- onChange: V,
86
- options: h = [],
87
- placeholder: q = "Select an option",
88
- position: D = "popper",
89
- side: E = "bottom",
90
- sideOffset: P = 4,
91
- state: a = "default",
92
- value: g,
93
- "aria-label": R,
94
- "aria-describedby": B,
95
- ...o
96
- }, G) => {
97
- const [b, M] = Nt(!1), i = lt(L, u), f = ct(i), { isDisabled: d, isLoading: x, isInvalid: A } = dt(o.disabled, a), H = mt(a, B, o.required, f), { groups: y, ungrouped: N } = pt(h), U = () => {
98
- if (x)
99
- return /* @__PURE__ */ t(bt, { "data-testid": "spectral-select-loading", message: T });
100
- if (h.length === 0)
101
- return /* @__PURE__ */ t(ft, { "data-testid": "spectral-select-empty", message: k });
102
- const v = (e) => {
103
- const m = g === e.value;
104
- return /* @__PURE__ */ r(it, { className: s(xt(!!e.disabled, !1, m), "relative flex w-full cursor-pointer items-center"), "data-testid": "spectral-select-item", disabled: e.disabled, value: e.value, children: [
105
- /* @__PURE__ */ t(st, { "data-testid": "spectral-select-item-text", className: "block truncate", children: e.label }),
106
- /* @__PURE__ */ t(ot, { "data-testid": "spectral-select-item-selected-indicator", asChild: !0, children: /* @__PURE__ */ t("span", { className: "absolute right-2 flex h-4 w-4 items-center justify-center", children: /* @__PURE__ */ t(Q, { size: 16 }) }) })
107
- ] }, e.value);
108
- };
109
- return /* @__PURE__ */ r(S, { children: [
110
- N.length > 0 && /* @__PURE__ */ r(S, { children: [
111
- N.map(v),
112
- Object.keys(y).length > 0 && /* @__PURE__ */ t(I, { className: "-mx-1 my-1 h-px bg-border-secondary", "data-testid": "spectral-select-separator" })
113
- ] }),
114
- Object.entries(y).map(([e, m], J) => /* @__PURE__ */ r(at, { "data-testid": "spectral-select-group", children: [
115
- J > 0 && /* @__PURE__ */ t(I, { className: "-mx-1 my-1 h-px bg-border-secondary", "data-testid": "spectral-select-group-separator" }),
116
- /* @__PURE__ */ t(C, { "data-testid": "spectral-select-group-label", htmlFor: i, className: s("px-2 py-1.5 text-base font-semibold text-text-primary", n), children: e }),
117
- m.map((K) => v(K))
118
- ] }, e))
119
- ] });
70
+ import { useState as yt } from "react";
71
+ const Nt = ({
72
+ ref: w,
73
+ align: z = "start",
74
+ alignOffset: F = 0,
75
+ className: O,
76
+ collisionPadding: j = 10,
77
+ defaultValue: k,
78
+ emptyMessage: L = "No options found",
79
+ errorMessage: p,
80
+ id: T,
81
+ label: l,
82
+ labelClassName: n,
83
+ loadingMessage: V = "Loading…",
84
+ name: u,
85
+ onChange: q,
86
+ options: h = [],
87
+ placeholder: D = "Select an option",
88
+ position: E = "popper",
89
+ side: P = "bottom",
90
+ sideOffset: B = 4,
91
+ state: a = "default",
92
+ value: g,
93
+ "aria-label": G,
94
+ "aria-describedby": M,
95
+ ...o
96
+ }) => {
97
+ const [b, R] = yt(!1), i = lt(T, u), f = gt(i), { isDisabled: d, isLoading: x, isInvalid: A } = dt(o.disabled, a), H = mt(a, M, o.required, f), { groups: y, ungrouped: N } = ct(h), U = () => {
98
+ if (x)
99
+ return /* @__PURE__ */ t(bt, { "data-testid": "spectral-select-loading", message: V });
100
+ if (h.length === 0)
101
+ return /* @__PURE__ */ t(ft, { "data-testid": "spectral-select-empty", message: L });
102
+ const v = (e) => {
103
+ const m = g === e.value;
104
+ return /* @__PURE__ */ r(it, { className: s(xt(!!e.disabled, !1, m), "relative flex w-full cursor-pointer items-center"), "data-testid": "spectral-select-item", disabled: e.disabled, value: e.value, children: [
105
+ /* @__PURE__ */ t(st, { "data-testid": "spectral-select-item-text", className: "block truncate", children: e.label }),
106
+ /* @__PURE__ */ t(ot, { "data-testid": "spectral-select-item-selected-indicator", asChild: !0, children: /* @__PURE__ */ t("span", { className: "absolute right-2 flex h-4 w-4 items-center justify-center", children: /* @__PURE__ */ t(Q, { size: 16 }) }) })
107
+ ] }, e.value);
120
108
  };
121
- return /* @__PURE__ */ r("div", { className: "w-full", children: [
122
- l && /* @__PURE__ */ t(C, { "data-testid": "spectral-select-label", htmlFor: i, className: s("block mb-4 text-text-primary", n, d && "text-text-secondary"), children: l }),
123
- /* @__PURE__ */ r(X, { "data-testid": "spectral-select", defaultValue: j, disabled: d, name: u, onOpenChange: M, onValueChange: V, open: b, required: o.required, value: g, children: [
124
- /* @__PURE__ */ t(
125
- Y,
126
- {
127
- "aria-controls": i,
128
- "aria-expanded": b,
129
- "aria-label": R || l,
130
- asChild: !0,
131
- className: s(ht(!1, a), ut(a), F),
132
- "data-slot": "select-trigger",
133
- "data-state": a,
134
- "data-testid": "spectral-select-trigger",
135
- id: i,
136
- ref: G,
137
- role: "combobox",
138
- style: nt(),
139
- ...H,
140
- ...o,
141
- children: /* @__PURE__ */ r("button", { type: "button", disabled: d, children: [
142
- /* @__PURE__ */ t(Z, { placeholder: q, className: "block truncate", "data-testid": "spectral-select-value" }),
143
- /* @__PURE__ */ t(_, { asChild: !0, children: /* @__PURE__ */ t("div", { className: "flex items-center", children: x ? /* @__PURE__ */ t(W, { size: 20 }) : /* @__PURE__ */ t(c, { className: "transition-transform duration-200 data-[state=open]:rotate-180", size: 20 }) }) })
144
- ] })
145
- }
146
- ),
147
- /* @__PURE__ */ t($, { align: w, alignOffset: z, "data-slot": "select-content", "data-testid": "spectral-select-content", asChild: !0, collisionPadding: O, position: D, side: E, sideOffset: P, children: /* @__PURE__ */ r(
148
- "div",
149
- {
150
- className: s(
151
- "z-50 rounded-lg border border-input-border bg-input-bg shadow-md",
152
- "data-[state=open]:animate-in data-[state=closed]:animate-out",
153
- "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
154
- "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
155
- "data-[side=bottom]:slide-in-from-top-2",
156
- "data-[side=left]:slide-in-from-right-2",
157
- "data-[side=right]:slide-in-from-left-2",
158
- "data-[side=top]:slide-in-from-bottom-2"
159
- ),
160
- style: {
161
- boxSizing: "border-box",
162
- maxHeight: "var(--radix-select-content-available-height)",
163
- position: "fixed",
164
- width: "var(--radix-select-trigger-width)"
165
- },
166
- children: [
167
- /* @__PURE__ */ t(tt, { className: "flex cursor-default items-center justify-center py-1", "data-testid": "spectral-select-scroll-up-button", children: /* @__PURE__ */ t(c, { className: "rotate-180", size: 18 }) }),
168
- /* @__PURE__ */ t(et, { asChild: !0, children: /* @__PURE__ */ t("div", { className: "p-1 max-h-96", "data-testid": "spectral-select-items", style: { position: "relative", overflow: "hidden auto" }, children: U() }) }),
169
- /* @__PURE__ */ t(rt, { className: "flex cursor-default items-center justify-center py-1", "data-testid": "spectral-select-scroll-down-button", children: /* @__PURE__ */ t(c, { size: 18 }) })
170
- ]
171
- }
172
- ) })
109
+ return /* @__PURE__ */ r(S, { children: [
110
+ N.length > 0 && /* @__PURE__ */ r(S, { children: [
111
+ N.map(v),
112
+ Object.keys(y).length > 0 && /* @__PURE__ */ t(I, { className: "bg-border-secondary -mx-1 my-1 h-px", "data-testid": "spectral-select-separator" })
173
113
  ] }),
174
- A && p && /* @__PURE__ */ t(gt, { "data-testid": "spectral-select-error-message", id: f, message: p })
114
+ Object.entries(y).map(([e, m], J) => /* @__PURE__ */ r(at, { "data-testid": "spectral-select-group", children: [
115
+ J > 0 && /* @__PURE__ */ t(I, { className: "bg-border-secondary -mx-1 my-1 h-px", "data-testid": "spectral-select-group-separator" }),
116
+ /* @__PURE__ */ t(C, { "data-testid": "spectral-select-group-label", htmlFor: i, className: s("text-text-primary px-2 py-1.5 text-base font-semibold", n), children: e }),
117
+ m.map((K) => v(K))
118
+ ] }, e))
175
119
  ] });
176
- }
177
- );
178
- vt.displayName = "Select";
120
+ };
121
+ return /* @__PURE__ */ r("div", { className: "w-full", children: [
122
+ l && /* @__PURE__ */ t(C, { "data-testid": "spectral-select-label", htmlFor: i, className: s("text-text-primary mb-4 block", n, d && "text-text-secondary"), children: l }),
123
+ /* @__PURE__ */ r(X, { "data-testid": "spectral-select", defaultValue: k, disabled: d, name: u, onOpenChange: R, onValueChange: q, open: b, required: o.required, value: g, children: [
124
+ /* @__PURE__ */ t(
125
+ Y,
126
+ {
127
+ "aria-controls": i,
128
+ "aria-expanded": b,
129
+ "aria-label": G || l,
130
+ asChild: !0,
131
+ className: s(ut(!1, a), nt(a), O),
132
+ "data-slot": "select-trigger",
133
+ "data-state": a,
134
+ "data-testid": "spectral-select-trigger",
135
+ id: i,
136
+ ref: w,
137
+ role: "combobox",
138
+ style: pt(),
139
+ ...H,
140
+ ...o,
141
+ children: /* @__PURE__ */ r("button", { type: "button", disabled: d, children: [
142
+ /* @__PURE__ */ t(Z, { placeholder: D, className: "block truncate", "data-testid": "spectral-select-value" }),
143
+ /* @__PURE__ */ t(_, { asChild: !0, children: /* @__PURE__ */ t("div", { className: "flex items-center", children: x ? /* @__PURE__ */ t(W, { size: 20 }) : /* @__PURE__ */ t(c, { className: "transition-transform duration-200 data-[state=open]:rotate-180", size: 20 }) }) })
144
+ ] })
145
+ }
146
+ ),
147
+ /* @__PURE__ */ t($, { align: z, alignOffset: F, "data-slot": "select-content", "data-testid": "spectral-select-content", asChild: !0, collisionPadding: j, position: E, side: P, sideOffset: B, children: /* @__PURE__ */ r(
148
+ "div",
149
+ {
150
+ className: s(
151
+ "border-input-border bg-input-bg z-50 rounded-lg border shadow-md",
152
+ "data-[state=open]:animate-in data-[state=closed]:animate-out",
153
+ "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
154
+ "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
155
+ "data-[side=bottom]:slide-in-from-top-2",
156
+ "data-[side=left]:slide-in-from-right-2",
157
+ "data-[side=right]:slide-in-from-left-2",
158
+ "data-[side=top]:slide-in-from-bottom-2"
159
+ ),
160
+ style: {
161
+ boxSizing: "border-box",
162
+ maxHeight: "var(--radix-select-content-available-height)",
163
+ position: "fixed",
164
+ width: "var(--radix-select-trigger-width)"
165
+ },
166
+ children: [
167
+ /* @__PURE__ */ t(tt, { className: "flex cursor-default items-center justify-center py-1", "data-testid": "spectral-select-scroll-up-button", children: /* @__PURE__ */ t(c, { className: "rotate-180", size: 18 }) }),
168
+ /* @__PURE__ */ t(et, { asChild: !0, children: /* @__PURE__ */ t("div", { className: "max-h-96 p-1", "data-testid": "spectral-select-items", style: { position: "relative", overflow: "hidden auto" }, children: U() }) }),
169
+ /* @__PURE__ */ t(rt, { className: "flex cursor-default items-center justify-center py-1", "data-testid": "spectral-select-scroll-down-button", children: /* @__PURE__ */ t(c, { size: 18 }) })
170
+ ]
171
+ }
172
+ ) })
173
+ ] }),
174
+ A && p && /* @__PURE__ */ t(ht, { "data-testid": "spectral-select-error-message", id: f, message: p })
175
+ ] });
176
+ };
177
+ Nt.displayName = "Select";
179
178
  export {
180
- vt as Select
179
+ Nt as Select
181
180
  };
@@ -1,12 +1,12 @@
1
- import { ComponentPropsWithoutRef } from 'react';
1
+ import { ComponentPropsWithoutRef, Ref } from 'react';
2
2
  export type SeparatorProps = {
3
- orientation?: 'horizontal' | 'vertical';
4
- decorative?: boolean;
5
3
  className?: string;
6
- } & ComponentPropsWithoutRef<'div'>;
7
- export declare const Separator: import('react').ForwardRefExoticComponent<{
8
- orientation?: "horizontal" | "vertical";
9
4
  decorative?: boolean;
10
- className?: string;
11
- } & Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
5
+ orientation?: 'horizontal' | 'vertical';
6
+ ref?: Ref<HTMLDivElement>;
7
+ } & ComponentPropsWithoutRef<'div'>;
8
+ export declare const Separator: {
9
+ ({ className, decorative, orientation, ref, ...props }: SeparatorProps): import("react/jsx-runtime").JSX.Element;
10
+ displayName: string;
11
+ };
12
12
  //# sourceMappingURL=Separator.d.ts.map
package/dist/Separator.js CHANGED
@@ -1,22 +1,21 @@
1
- "use client";
2
1
  import "./styles/main.css";
3
- import { jsx as i } from "react/jsx-runtime";
4
- import { cn as p } from "./utils/twUtils.js";
5
- import { forwardRef as l } from "react";
6
- const n = l(({ className: o, orientation: r = "horizontal", decorative: a = !0, ...t }, e) => /* @__PURE__ */ i(
2
+ import { jsx as p } from "react/jsx-runtime";
3
+ import { cn as e } from "./utils/twUtils.js";
4
+ import "react";
5
+ const l = ({ className: o, decorative: r = !0, orientation: a = "horizontal", ref: t, ...i }) => /* @__PURE__ */ p(
7
6
  "div",
8
7
  {
9
- ref: e,
8
+ ref: t,
10
9
  "data-slot": "separator",
11
- "data-orientation": r,
12
- role: a ? "none" : "separator",
13
- "aria-hidden": a ? "true" : void 0,
14
- "aria-orientation": a ? void 0 : r,
15
- className: p("bg-border shrink-0", r === "horizontal" ? "h-px w-full" : "h-full w-px", o),
16
- ...t
10
+ "data-orientation": a,
11
+ role: r ? "none" : "separator",
12
+ "aria-hidden": r ? "true" : void 0,
13
+ "aria-orientation": r ? void 0 : a,
14
+ className: e("bg-border shrink-0", a === "horizontal" ? "h-px w-full" : "h-full w-px", o),
15
+ ...i
17
16
  }
18
- ));
19
- n.displayName = "Separator";
17
+ );
18
+ l.displayName = "Separator";
20
19
  export {
21
- n as Separator
20
+ l as Separator
22
21
  };
@@ -1,5 +1,5 @@
1
1
  import { AsChildProp } from '../primitives/slot';
2
- import { ButtonHTMLAttributes, HTMLAttributes } from 'react';
2
+ import { ButtonHTMLAttributes, HTMLAttributes, Ref } from 'react';
3
3
  type BaseButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange' | 'value'>;
4
4
  export type SwitchProps = BaseButtonProps & AsChildProp & {
5
5
  checked?: boolean;
@@ -10,16 +10,18 @@ export type SwitchProps = BaseButtonProps & AsChildProp & {
10
10
  required?: boolean;
11
11
  value?: string;
12
12
  };
13
- export declare const Switch: import('react').ForwardRefExoticComponent<BaseButtonProps & AsChildProp & {
14
- checked?: boolean;
15
- defaultChecked?: boolean;
16
- form?: string;
17
- name?: string;
18
- onCheckedChange?: (checked: boolean) => void;
19
- required?: boolean;
20
- value?: string;
21
- } & import('react').RefAttributes<HTMLButtonElement>>;
13
+ export declare const Switch: {
14
+ ({ ref, asChild, className, checked, defaultChecked, onCheckedChange, name, value, required, form, disabled, id, onClick, onKeyDown, children, ...rest }: SwitchProps & {
15
+ ref?: Ref<HTMLButtonElement>;
16
+ }): import("react/jsx-runtime").JSX.Element;
17
+ displayName: string;
18
+ };
22
19
  export type SwitchThumbProps = HTMLAttributes<HTMLSpanElement> & AsChildProp;
23
- export declare const SwitchThumb: import('react').ForwardRefExoticComponent<HTMLAttributes<HTMLSpanElement> & AsChildProp & import('react').RefAttributes<HTMLSpanElement>>;
20
+ export declare const SwitchThumb: {
21
+ ({ ref, asChild, className, ...props }: SwitchThumbProps & {
22
+ ref?: Ref<HTMLSpanElement>;
23
+ }): import("react/jsx-runtime").JSX.Element;
24
+ displayName: string;
25
+ };
24
26
  export {};
25
27
  //# sourceMappingURL=SwitchBase.d.ts.map
@@ -1,80 +1,99 @@
1
1
  "use client";
2
2
  import "../styles/main.css";
3
- import { jsx as p, jsxs as K } from "react/jsx-runtime";
4
- import { useControllableState as M } from "../hooks/useControllableState.js";
5
- import { Slot as g } from "../primitives/slot.js";
6
- import { cn as x } from "../utils/twUtils.js";
7
- import { createContext as O, forwardRef as y, useRef as V, useId as $, useEffect as k, useCallback as d, useContext as z } from "react";
8
- const C = O(null), A = y(({ asChild: u, className: l, checked: h, defaultChecked: r = !1, onCheckedChange: o, name: f, value: m = "on", required: E, form: S, disabled: n, id: R, onClick: b, onKeyDown: v, children: I, ...N }, P) => {
9
- const c = V(null), T = $(), j = R ?? `swt-${T}`, [t, s] = M({
3
+ import { jsx as f, jsxs as F } from "react/jsx-runtime";
4
+ import { useControllableState as K } from "../hooks/useControllableState.js";
5
+ import { Slot as w } from "../primitives/slot.js";
6
+ import { cn as g } from "../utils/twUtils.js";
7
+ import { createContext as M, useRef as O, useId as V, useEffect as v, useCallback as a, useContext as $ } from "react";
8
+ const x = M(null), z = ({
9
+ ref: u,
10
+ asChild: d,
11
+ className: l,
12
+ checked: h,
13
+ defaultChecked: n = !1,
14
+ onCheckedChange: m,
15
+ name: y,
16
+ value: C = "on",
17
+ required: E,
18
+ form: S,
19
+ disabled: r,
20
+ id: I,
21
+ onClick: p,
22
+ onKeyDown: b,
23
+ children: N,
24
+ ...P
25
+ }) => {
26
+ const c = O(null), R = V(), T = I ?? `swt-${R}`, [t, s] = K({
10
27
  value: h,
11
- defaultValue: r,
12
- onChange: o
28
+ defaultValue: n,
29
+ onChange: m
13
30
  });
14
- k(() => {
31
+ v(() => {
15
32
  c.current && (c.current.checked = t);
16
- }, [t]), k(() => {
33
+ }, [t]), v(() => {
17
34
  const e = c.current?.form ?? null;
18
35
  if (!e) return;
19
- const a = () => s(r);
20
- return e.addEventListener("reset", a), () => e.removeEventListener("reset", a);
21
- }, [r, s]);
22
- const w = d(() => {
23
- const e = c.current;
24
- if (!e) return;
25
- e.checked = t;
26
- const a = new Event("change", { bubbles: !0 });
27
- e.dispatchEvent(a);
28
- }, [t]), i = d(() => {
29
- n || (s(!t), queueMicrotask(() => w()));
30
- }, [n, w, t, s]), D = d(
36
+ const o = () => s(n);
37
+ return e.addEventListener("reset", o), () => e.removeEventListener("reset", o);
38
+ }, [n, s]);
39
+ const k = a((e) => {
40
+ const o = c.current;
41
+ if (!o) return;
42
+ o.checked = e;
43
+ const q = new Event("change", { bubbles: !0 });
44
+ o.dispatchEvent(q);
45
+ }, []), i = a(() => {
46
+ if (r) return;
47
+ const e = !t;
48
+ s(e), queueMicrotask(() => k(e));
49
+ }, [r, k, t, s]), j = a(
31
50
  (e) => {
32
- b?.(e), !e.defaultPrevented && i();
51
+ p?.(e), !e.defaultPrevented && i();
33
52
  },
34
- [b, i]
35
- ), L = d(
53
+ [p, i]
54
+ ), D = a(
36
55
  (e) => {
37
- v?.(e), !e.defaultPrevented && (e.key === " " || e.key === "Enter") && (e.preventDefault(), i());
56
+ b?.(e), !e.defaultPrevented && (e.key === " " || e.key === "Enter") && (e.preventDefault(), i());
38
57
  },
39
- [v, i]
40
- ), q = u ? g : "button", F = P;
41
- return /* @__PURE__ */ p(C.Provider, { value: { checked: t, disabled: n }, children: /* @__PURE__ */ K(
42
- q,
58
+ [b, i]
59
+ ), L = d ? w : "button";
60
+ return /* @__PURE__ */ f(x.Provider, { value: { checked: t, disabled: r }, children: /* @__PURE__ */ F(
61
+ L,
43
62
  {
44
63
  "aria-checked": t,
45
- "aria-disabled": n || void 0,
46
- className: x(
64
+ "aria-disabled": r || void 0,
65
+ className: g(
47
66
  "peer border-input inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border",
48
67
  "bg-input focus-visible:ring-ring transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",
49
68
  "disabled:cursor-not-allowed disabled:opacity-50",
50
69
  "data-[state=checked]:bg-primary",
51
70
  l
52
71
  ),
53
- "data-disabled": n || void 0,
72
+ "data-disabled": r || void 0,
54
73
  "data-state": t ? "checked" : "unchecked",
55
- disabled: n,
56
- id: j,
57
- onClick: D,
58
- onKeyDown: L,
59
- ref: F,
74
+ disabled: r,
75
+ id: T,
76
+ onClick: j,
77
+ onKeyDown: D,
78
+ ref: u,
60
79
  role: "switch",
61
80
  type: "button",
62
- ...N,
81
+ ...P,
63
82
  children: [
64
- /* @__PURE__ */ p(
83
+ /* @__PURE__ */ f(
65
84
  "input",
66
85
  {
67
86
  "aria-hidden": "true",
68
87
  checked: t,
69
- disabled: n,
88
+ disabled: r,
70
89
  form: S,
71
- name: f,
90
+ name: y,
72
91
  readOnly: !0,
73
92
  ref: c,
74
93
  required: E,
75
94
  tabIndex: -1,
76
95
  type: "checkbox",
77
- value: m,
96
+ value: C,
78
97
  style: {
79
98
  position: "absolute",
80
99
  opacity: 0,
@@ -84,29 +103,33 @@ const C = O(null), A = y(({ asChild: u, className: l, checked: h, defaultChecked
84
103
  }
85
104
  }
86
105
  ),
87
- I
106
+ N
88
107
  ]
89
108
  }
90
109
  ) });
91
- });
92
- A.displayName = "Switch";
93
- const B = y(({ asChild: u, className: l, ...h }, r) => {
94
- const o = z(C);
95
- if (!o) throw new Error("SwitchThumb must be used within Switch");
96
- const f = u ? g : "span", m = r;
97
- return /* @__PURE__ */ p(
98
- f,
110
+ };
111
+ z.displayName = "Switch";
112
+ const A = ({
113
+ ref: u,
114
+ asChild: d,
115
+ className: l,
116
+ ...h
117
+ }) => {
118
+ const n = $(x);
119
+ if (!n) throw new Error("SwitchThumb must be used within Switch");
120
+ return /* @__PURE__ */ f(
121
+ d ? w : "span",
99
122
  {
100
- className: x("bg-background pointer-events-none block h-5 w-5 rounded-full shadow-lg ring-0 transition-transform", "translate-x-0 data-[state=checked]:translate-x-5", l),
101
- "data-disabled": o.disabled || void 0,
102
- "data-state": o.checked ? "checked" : "unchecked",
103
- ref: m,
123
+ className: g("bg-background pointer-events-none block h-5 w-5 rounded-full shadow-lg ring-0 transition-transform", "translate-x-0 data-[state=checked]:translate-x-5", l),
124
+ "data-disabled": n.disabled || void 0,
125
+ "data-state": n.checked ? "checked" : "unchecked",
126
+ ref: u,
104
127
  ...h
105
128
  }
106
129
  );
107
- });
108
- B.displayName = "SwitchThumb";
130
+ };
131
+ A.displayName = "SwitchThumb";
109
132
  export {
110
- A as Switch,
111
- B as SwitchThumb
133
+ z as Switch,
134
+ A as SwitchThumb
112
135
  };
package/dist/Switch.d.ts CHANGED
@@ -1,12 +1,19 @@
1
1
  import { SwitchProps as SwitchBaseProps } from './SwitchBase';
2
- export declare const Switch: import('react').ForwardRefExoticComponent<Omit<SwitchBaseProps, "onCheckedChange"> & {
3
- labelPosition?: "left" | "right";
2
+ import { Ref } from 'react';
3
+ type SwitchProps = Omit<SwitchBaseProps, 'onCheckedChange'> & {
4
+ labelPosition?: 'left' | 'right';
4
5
  labelText: string;
5
6
  id: string;
6
7
  hideLabel?: boolean;
7
8
  onChange?: (checked: boolean) => void;
9
+ ref?: Ref<HTMLButtonElement>;
8
10
  required?: boolean;
9
11
  value?: string;
10
- variant?: "default" | "squared";
11
- } & import('react').RefAttributes<HTMLButtonElement>>;
12
+ variant?: 'default' | 'squared';
13
+ };
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;
16
+ displayName: string;
17
+ };
18
+ export {};
12
19
  //# sourceMappingURL=Switch.d.ts.map
package/dist/Switch.js CHANGED
@@ -1,35 +1,34 @@
1
- "use client";
2
1
  import "./styles/main.css";
3
- import { jsxs as w, jsx as t } from "react/jsx-runtime";
4
- import { Switch as p, SwitchThumb as k } from "./Switch/SwitchBase.js";
2
+ import { jsxs as p, jsx as t } from "react/jsx-runtime";
3
+ import { Switch as w, SwitchThumb as k } from "./Switch/SwitchBase.js";
5
4
  import { Label as r } from "./Label.js";
6
- import { cn as o } from "./utils/twUtils.js";
7
- import { forwardRef as x } from "react";
8
- const v = x(({ className: l, disabled: d, id: e, labelPosition: i = "right", labelText: s, name: h, onChange: b, required: c, value: m, hideLabel: a = !1, variant: u, ...f }, g) => {
9
- const n = u === "squared";
10
- return /* @__PURE__ */ w("div", { className: "flex items-center", "data-testid": "spectral-switch-container", children: [
5
+ import { cn as l } from "./utils/twUtils.js";
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 }) => {
8
+ const n = f === "squared";
9
+ return /* @__PURE__ */ p("div", { className: "flex items-center", "data-testid": "spectral-switch-container", children: [
11
10
  i === "left" && !a && /* @__PURE__ */ t(r, { htmlFor: e, className: "mr-2", "data-testid": "spectral-switch-label-left", children: s }),
12
11
  /* @__PURE__ */ t(
13
- p,
12
+ w,
14
13
  {
15
14
  "aria-required": c,
16
- className: o(
15
+ className: l(
17
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",
18
- l
17
+ d
19
18
  ),
20
19
  "data-testid": "spectral-switch",
21
- disabled: d,
20
+ disabled: h,
22
21
  id: e,
23
- name: h,
24
- onCheckedChange: b,
25
- ref: g,
22
+ name: b,
23
+ onCheckedChange: u,
24
+ ref: o,
26
25
  required: c,
27
26
  value: m,
28
- ...f,
27
+ ...g,
29
28
  children: /* @__PURE__ */ t(
30
29
  k,
31
30
  {
32
- className: o(
31
+ className: l(
33
32
  n ? "bg-switch-thumb pointer-events-none block size-5 rounded-full shadow-xs ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0 data-[state=checked]:rtl:-translate-x-4" : "bg-switch-thumb pointer-events-none block h-5 w-5 rounded-full shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
34
33
  )
35
34
  }
@@ -39,8 +38,8 @@ const v = x(({ className: l, disabled: d, id: e, labelPosition: i = "right", lab
39
38
  i === "right" && !a && /* @__PURE__ */ t(r, { htmlFor: e, id: `${e}-label`, className: "ml-2", "data-testid": "spectral-switch-label-right", children: s }),
40
39
  a && /* @__PURE__ */ t(r, { htmlFor: e, className: "sr-only", "data-testid": "spectral-switch-label-hidden", children: s })
41
40
  ] });
42
- });
43
- v.displayName = "Switch";
41
+ };
42
+ x.displayName = "Switch";
44
43
  export {
45
- v as Switch
44
+ x as Switch
46
45
  };