@spear-ai/spectral 1.11.2 → 1.12.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 (116) hide show
  1. package/README.md +4 -0
  2. package/dist/.js +124 -121
  3. package/dist/{Accordion-CDXdSAST.js → Accordion-Cyrb2byI.js} +1 -1
  4. package/dist/Accordion.js +1 -1
  5. package/dist/Alert/AlertBase.js +1 -1
  6. package/dist/Alert.js +3 -3
  7. package/dist/{AnimatePresence-D-9jXfgI.js → AnimatePresence-D9FLxIGV.js} +1 -1
  8. package/dist/Avatar.js +46 -48
  9. package/dist/Badge.js +1 -1
  10. package/dist/Button.js +1 -1
  11. package/dist/ButtonGroup/ButtonGroupButton.js +1 -1
  12. package/dist/ButtonGroup.js +1 -1
  13. package/dist/ButtonIcon.js +1 -1
  14. package/dist/{Calendar-s4lyijkn.js → Calendar-Cnh_PTbQ.js} +4 -4
  15. package/dist/Checkbox/CheckboxBase.js +1 -1
  16. package/dist/Checkbox.d.ts +10 -3
  17. package/dist/Checkbox.js +55 -35
  18. package/dist/Combobox/ComboboxBase.js +1 -1
  19. package/dist/Combobox.d.ts +5 -3
  20. package/dist/Combobox.js +91 -92
  21. package/dist/{ComboboxBase-qX-mQhT6.js → ComboboxBase-BzDGK36x.js} +1 -1
  22. package/dist/ControlGroup/ControlGroupSelect.d.ts +5 -2
  23. package/dist/ControlGroup/ControlGroupSelect.js +33 -30
  24. package/dist/ControlGroup.d.ts +3 -2
  25. package/dist/ControlGroup.js +41 -33
  26. package/dist/DataCard/Card.js +1 -1
  27. package/dist/DataCard.js +1 -1
  28. package/dist/DateTimePicker/Calendar.js +1 -1
  29. package/dist/DateTimePicker/DateTimeDisplayInput.js +84 -83
  30. package/dist/DateTimePicker/DateTimeInput.js +2 -2
  31. package/dist/DateTimePicker/DateTimeUtils.js +1 -1
  32. package/dist/DateTimePicker/TimePeriodSelect.js +32 -35
  33. package/dist/DateTimePicker/TimePicker.js +2 -2
  34. package/dist/DateTimePicker.d.ts +1 -1
  35. package/dist/DateTimePicker.js +55 -52
  36. package/dist/{DateTimeUtils-DVvG6H-p.js → DateTimeUtils-BJUAMuot.js} +1 -1
  37. package/dist/Dialog.js +1 -1
  38. package/dist/DropdownMenu.d.ts +61 -0
  39. package/dist/DropdownMenu.js +869 -0
  40. package/dist/{HoverCard-CYDsIiVK.js → HoverCard-DERasp0v.js} +1 -1
  41. package/dist/HoverCard.js +1 -1
  42. package/dist/Icons/AdjustmentsIcon.d.ts +5 -0
  43. package/dist/Icons/AdjustmentsIcon.js +78 -0
  44. package/dist/Icons/MenuDotsIcon.d.ts +5 -0
  45. package/dist/Icons/MenuDotsIcon.js +36 -0
  46. package/dist/Icons/MenuIcon.d.ts +5 -0
  47. package/dist/Icons/MenuIcon.js +36 -0
  48. package/dist/Icons/index.d.ts +3 -0
  49. package/dist/Icons.js +81 -78
  50. package/dist/IconsAnimated/PanelLeftCloseIcon.js +3 -3
  51. package/dist/IconsAnimated/PanelLeftOpenIcon.js +3 -3
  52. package/dist/Input.js +1 -1
  53. package/dist/InputNumeric.js +1 -1
  54. package/dist/{InputOTP-cVn5Bzyp.js → InputOTP-BkSw_KIB.js} +12 -10
  55. package/dist/InputOTP.js +1 -1
  56. package/dist/Kbd.js +1 -1
  57. package/dist/Label.js +1 -1
  58. package/dist/MultiSelect/MultiSelectBase.d.ts +6 -4
  59. package/dist/MultiSelect/MultiSelectBase.js +235 -209
  60. package/dist/MultiSelect.d.ts +2 -1
  61. package/dist/MultiSelect.js +14 -12
  62. package/dist/Popover.js +1 -1
  63. package/dist/RadioButton.js +1 -1
  64. package/dist/RadioButtonGroup/RadioButtonGroupBase.js +1 -1
  65. package/dist/RadioButtonGroup.js +1 -1
  66. package/dist/RadioGroup-DqKggFnI.js +328 -0
  67. package/dist/RadioGroup.d.ts +7 -0
  68. package/dist/RadioGroup.js +1 -1
  69. package/dist/Select.d.ts +5 -2
  70. package/dist/Select.js +100 -85
  71. package/dist/Separator.js +1 -1
  72. package/dist/Skeleton.js +1 -1
  73. package/dist/{Slider-BzzZT3Zm.js → Slider-CfUFkWU4.js} +1 -1
  74. package/dist/Slider.js +1 -1
  75. package/dist/Switch-Wj_zov--.js +144 -0
  76. package/dist/Switch.d.ts +12 -3
  77. package/dist/Switch.js +1 -1
  78. package/dist/Tabs/TabsBase.js +4 -4
  79. package/dist/Tabs.js +1 -1
  80. package/dist/Textarea.d.ts +3 -2
  81. package/dist/Textarea.js +50 -45
  82. package/dist/{Toast-9zqXxKKO.js → Toast-CJvzLlMD.js} +1 -1
  83. package/dist/Toast.js +1 -1
  84. package/dist/Toggle.js +1 -1
  85. package/dist/ToggleGroup.js +1 -1
  86. package/dist/{Tooltip-D1K8kY1y.js → Tooltip-BR0tdif4.js} +2 -2
  87. package/dist/Tooltip.js +1 -1
  88. package/dist/Tray.js +4 -4
  89. package/dist/{chunk-h9knIhTc.js → chunk-C4rFPcKS.js} +1 -1
  90. package/dist/dist-DcUGLq_y.js +149 -0
  91. package/dist/main.js +1 -1
  92. package/dist/primitives/button.js +1 -1
  93. package/dist/primitives/input-group.js +1 -1
  94. package/dist/primitives/input.js +1 -1
  95. package/dist/primitives/popover.js +1 -1
  96. package/dist/primitives/select.d.ts.map +1 -1
  97. package/dist/primitives/select.js +56 -53
  98. package/dist/primitives/textarea.js +1 -1
  99. package/dist/{proxy-Dn10Pl_g.js → proxy-CCB7C4Pu.js} +10 -10
  100. package/dist/styles/spectral.css +1 -1
  101. package/dist/{twUtils-VNWgstKL.js → twUtils-D_qzdiwM.js} +1 -1
  102. package/dist/{use-animation-CBUDycyW.js → use-animation-C-qL83hj.js} +1 -1
  103. package/dist/utils/dropdownPositioning.d.ts +13 -0
  104. package/dist/utils/dropdownPositioning.d.ts.map +1 -0
  105. package/dist/utils/dropdownPositioning.js +43 -0
  106. package/dist/utils/dropdownPositioning.test.d.ts +2 -0
  107. package/dist/utils/dropdownPositioning.test.d.ts.map +1 -0
  108. package/dist/utils/dropdownPositioning.test.js +21 -0
  109. package/dist/utils/formFieldUtils.d.ts +15 -1
  110. package/dist/utils/formFieldUtils.d.ts.map +1 -1
  111. package/dist/utils/formFieldUtils.js +35 -19
  112. package/dist/utils/twUtils.js +1 -1
  113. package/package.json +26 -22
  114. package/dist/RadioGroup-w_q6RGEK.js +0 -447
  115. package/dist/Switch-CVzRJ-0n.js +0 -126
  116. /package/dist/{dist-B4FgboI8.js → dist-Cujfuel1.js} +0 -0
@@ -0,0 +1,328 @@
1
+ import "./styles/main.css";
2
+ import { a as e, d as t, l as n, r, t as i } from "./dist-7HRQ5IKN.js";
3
+ import { t as a } from "./dist-CGzgmYB9.js";
4
+ import { t as o } from "./dist-Bft31cJh.js";
5
+ import { t as s } from "./twUtils-D_qzdiwM.js";
6
+ import { ErrorMessage as c, WarningMessage as l, useFormFieldId as u } from "./utils/formFieldUtils.js";
7
+ import { Label as d } from "./Label.js";
8
+ import { t as f } from "./dist-BK1K0g9W.js";
9
+ import { t as p } from "./dist-s1uWaZYZ.js";
10
+ import { n as m, r as h, t as g } from "./dist-DcUGLq_y.js";
11
+ import { a as _, i as v, o as y, t as b, u as x } from "./proxy-CCB7C4Pu.js";
12
+ import { t as S } from "./AnimatePresence-D9FLxIGV.js";
13
+ import * as C from "react";
14
+ import { createContext as w, memo as T, useContext as E, useId as D, useMemo as ee, useState as O } from "react";
15
+ import { jsx as k, jsxs as A } from "react/jsx-runtime";
16
+ //#region node_modules/.pnpm/@radix-ui+react-radio-group@1.3.8_@types+react-dom@19.2.3_@types+react@19.2.14__@types+_3694a89ac1e1986bc2583e58a261f48c/node_modules/@radix-ui/react-radio-group/dist/index.mjs
17
+ var j = "Radio", [te, M] = t(j), [ne, re] = te(j), N = C.forwardRef((t, r) => {
18
+ let { __scopeRadio: a, name: o, checked: s = !1, required: c, disabled: l, value: u = "on", onCheck: d, form: f, ...p } = t, [m, h] = C.useState(null), g = n(r, (e) => h(e)), _ = C.useRef(!1), v = m ? f || !!m.closest("form") : !0;
19
+ return /* @__PURE__ */ A(ne, {
20
+ scope: a,
21
+ checked: s,
22
+ disabled: l,
23
+ children: [/* @__PURE__ */ k(i.button, {
24
+ type: "button",
25
+ role: "radio",
26
+ "aria-checked": s,
27
+ "data-state": L(s),
28
+ "data-disabled": l ? "" : void 0,
29
+ disabled: l,
30
+ value: u,
31
+ ...p,
32
+ ref: g,
33
+ onClick: e(t.onClick, (e) => {
34
+ s || d?.(), v && (_.current = e.isPropagationStopped(), _.current || e.stopPropagation());
35
+ })
36
+ }), v && /* @__PURE__ */ k(I, {
37
+ control: m,
38
+ bubbles: !_.current,
39
+ name: o,
40
+ value: u,
41
+ checked: s,
42
+ required: c,
43
+ disabled: l,
44
+ form: f,
45
+ style: { transform: "translateX(-100%)" }
46
+ })]
47
+ });
48
+ });
49
+ N.displayName = j;
50
+ var P = "RadioIndicator", F = C.forwardRef((e, t) => {
51
+ let { __scopeRadio: n, forceMount: r, ...a } = e, s = re(P, n);
52
+ return /* @__PURE__ */ k(o, {
53
+ present: r || s.checked,
54
+ children: /* @__PURE__ */ k(i.span, {
55
+ "data-state": L(s.checked),
56
+ "data-disabled": s.disabled ? "" : void 0,
57
+ ...a,
58
+ ref: t
59
+ })
60
+ });
61
+ });
62
+ F.displayName = P;
63
+ var ie = "RadioBubbleInput", I = C.forwardRef(({ __scopeRadio: e, control: t, checked: r, bubbles: a = !0, ...o }, s) => {
64
+ let c = C.useRef(null), l = n(c, s), u = p(r), d = f(t);
65
+ return C.useEffect(() => {
66
+ let e = c.current;
67
+ if (!e) return;
68
+ let t = window.HTMLInputElement.prototype, n = Object.getOwnPropertyDescriptor(t, "checked").set;
69
+ if (u !== r && n) {
70
+ let t = new Event("click", { bubbles: a });
71
+ n.call(e, r), e.dispatchEvent(t);
72
+ }
73
+ }, [
74
+ u,
75
+ r,
76
+ a
77
+ ]), /* @__PURE__ */ k(i.input, {
78
+ type: "radio",
79
+ "aria-hidden": !0,
80
+ defaultChecked: r,
81
+ ...o,
82
+ tabIndex: -1,
83
+ ref: l,
84
+ style: {
85
+ ...o.style,
86
+ ...d,
87
+ position: "absolute",
88
+ pointerEvents: "none",
89
+ opacity: 0,
90
+ margin: 0
91
+ }
92
+ });
93
+ });
94
+ I.displayName = ie;
95
+ function L(e) {
96
+ return e ? "checked" : "unchecked";
97
+ }
98
+ var ae = [
99
+ "ArrowUp",
100
+ "ArrowDown",
101
+ "ArrowLeft",
102
+ "ArrowRight"
103
+ ], R = "RadioGroup", [oe, se] = t(R, [h, M]), z = h(), B = M(), [V, ce] = oe(R), H = C.forwardRef((e, t) => {
104
+ let { __scopeRadioGroup: n, name: o, defaultValue: s, value: c, required: l = !1, disabled: u = !1, orientation: d, dir: f, loop: p = !0, onValueChange: h, ...g } = e, _ = z(n), v = a(f), [y, b] = r({
105
+ prop: c,
106
+ defaultProp: s ?? null,
107
+ onChange: h,
108
+ caller: R
109
+ });
110
+ return /* @__PURE__ */ k(V, {
111
+ scope: n,
112
+ name: o,
113
+ required: l,
114
+ disabled: u,
115
+ value: y,
116
+ onValueChange: b,
117
+ children: /* @__PURE__ */ k(m, {
118
+ asChild: !0,
119
+ ..._,
120
+ orientation: d,
121
+ dir: v,
122
+ loop: p,
123
+ children: /* @__PURE__ */ k(i.div, {
124
+ role: "radiogroup",
125
+ "aria-required": l,
126
+ "aria-orientation": d,
127
+ "data-disabled": u ? "" : void 0,
128
+ dir: v,
129
+ ...g,
130
+ ref: t
131
+ })
132
+ })
133
+ });
134
+ });
135
+ H.displayName = R;
136
+ var U = "RadioGroupItem", W = C.forwardRef((t, r) => {
137
+ let { __scopeRadioGroup: i, disabled: a, ...o } = t, s = ce(U, i), c = s.disabled || a, l = z(i), u = B(i), d = C.useRef(null), f = n(r, d), p = s.value === o.value, m = C.useRef(!1);
138
+ return C.useEffect(() => {
139
+ let e = (e) => {
140
+ ae.includes(e.key) && (m.current = !0);
141
+ }, t = () => m.current = !1;
142
+ return document.addEventListener("keydown", e), document.addEventListener("keyup", t), () => {
143
+ document.removeEventListener("keydown", e), document.removeEventListener("keyup", t);
144
+ };
145
+ }, []), /* @__PURE__ */ k(g, {
146
+ asChild: !0,
147
+ ...l,
148
+ focusable: !c,
149
+ active: p,
150
+ children: /* @__PURE__ */ k(N, {
151
+ disabled: c,
152
+ required: s.required,
153
+ checked: p,
154
+ ...u,
155
+ ...o,
156
+ name: s.name,
157
+ ref: f,
158
+ onCheck: () => s.onValueChange(o.value),
159
+ onKeyDown: e((e) => {
160
+ e.key === "Enter" && e.preventDefault();
161
+ }),
162
+ onFocus: e(o.onFocus, () => {
163
+ m.current && d.current?.click();
164
+ })
165
+ })
166
+ });
167
+ });
168
+ W.displayName = U;
169
+ var le = "RadioGroupIndicator", G = C.forwardRef((e, t) => {
170
+ let { __scopeRadioGroup: n, ...r } = e;
171
+ return /* @__PURE__ */ k(F, {
172
+ ...B(n),
173
+ ...r,
174
+ ref: t
175
+ });
176
+ });
177
+ G.displayName = le;
178
+ var ue = H, K = W, q = G;
179
+ //#endregion
180
+ //#region node_modules/.pnpm/framer-motion@12.38.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/framer-motion/dist/es/utils/reduced-motion/use-reduced-motion.mjs
181
+ function de() {
182
+ !_.current && v();
183
+ let [e] = O(y.current);
184
+ return process.env.NODE_ENV !== "production" && x(e !== !0, "You have Reduced Motion enabled on your device. Animations may not appear as expected.", "reduced-motion-disabled"), e;
185
+ }
186
+ //#endregion
187
+ //#region src/components/RadioGroup/RadioGroup.tsx
188
+ var J = w({
189
+ disabledValues: [],
190
+ groupDisabled: !1,
191
+ orientation: "vertical",
192
+ variant: "default"
193
+ }), Y = "pointer-events-none opacity-60", X = (e) => {
194
+ let t = "selected" in e, { className: n, disabled: r, errorMessage: i, itemClassName: a, name: o, onChange: d, onValueChange: f, orientation: p = "vertical", ref: m, selected: h, state: g = "default", variant: _ = "default", warningMessage: v, "aria-describedby": y, ...b } = e, x = t ? h ?? "" : h, S = u(b.id, o), C = `${S}-error`, w = `${S}-warning`, T = g === "error" && i ? C : g === "warning" && v ? w : void 0, E = (e) => {
195
+ f(e), d?.(e);
196
+ }, D = ee(() => ({
197
+ disabledValues: Array.isArray(r) ? r : [],
198
+ groupDisabled: typeof r == "boolean" ? r : !1,
199
+ itemClassName: a,
200
+ orientation: p,
201
+ selected: x,
202
+ variant: _
203
+ }), [
204
+ p,
205
+ _,
206
+ r,
207
+ a,
208
+ x
209
+ ]);
210
+ return /* @__PURE__ */ A(J.Provider, {
211
+ value: D,
212
+ children: [
213
+ /* @__PURE__ */ k(ue, {
214
+ className: s("flex w-full text-text-primary", p === "vertical" ? "gap-4 flex-col" : "gap-5 flex-row", _ === "unstyled" && "gap-2.5 w-fit", n),
215
+ "data-state": g,
216
+ "data-testid": "spectral-radio-group",
217
+ id: S,
218
+ "aria-invalid": g === "error" ? !0 : void 0,
219
+ "aria-describedby": [T, y].filter(Boolean).join(" ") || void 0,
220
+ disabled: D.groupDisabled,
221
+ name: o,
222
+ onValueChange: E,
223
+ ref: m,
224
+ value: x,
225
+ ...b
226
+ }),
227
+ g === "error" && i && /* @__PURE__ */ k(c, {
228
+ dataTestId: "spectral-radio-group-error-message",
229
+ id: C,
230
+ message: i
231
+ }),
232
+ g === "warning" && v && /* @__PURE__ */ k(l, {
233
+ dataTestId: "spectral-radio-group-warning-message",
234
+ id: w,
235
+ message: v
236
+ })
237
+ ]
238
+ });
239
+ };
240
+ X.displayName = "RadioGroup";
241
+ var fe = {
242
+ type: "spring",
243
+ stiffness: 200,
244
+ damping: 16
245
+ }, Z = T(({ className: e, id: t, isDisabled: n, ref: r, transition: i = fe, value: a, ...o }) => de() ? /* @__PURE__ */ k(K, {
246
+ className: s("h-4.5 w-4.5 border-border-subtle ring-black relative aspect-square cursor-pointer rounded-full border-2 bg-radio-bg transition-colors", "hover:border-radio-border--hover focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-accent", "data-[state=checked]:border-radio-border--selected data-[state=checked]:bg-radio-bg", n && Y, e),
247
+ "data-testid": "spectral-radio-group-item",
248
+ disabled: n,
249
+ id: t,
250
+ ref: r,
251
+ value: a,
252
+ ...o,
253
+ children: /* @__PURE__ */ k(q, { className: s("after:inset-0 after:h-2.5 after:w-2.5 after:absolute after:m-auto after:rounded-full after:bg-radio-bg--selected after:content-['']", n && Y) })
254
+ }) : /* @__PURE__ */ k(K, {
255
+ value: a,
256
+ id: t,
257
+ disabled: n,
258
+ asChild: !0,
259
+ ...o,
260
+ children: /* @__PURE__ */ k(b.button, {
261
+ className: s("h-4.5 w-4.5 border-border-subtle ring-black relative aspect-square cursor-pointer rounded-full border-2 bg-radio-bg transition-colors", "hover:border-radio-border--hover focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-accent", "data-[state=checked]:border-radio-border--selected data-[state=checked]:bg-radio-bg", n && Y, e),
262
+ "data-testid": "spectral-radio-group-item",
263
+ ref: r,
264
+ whileHover: { scale: 1.05 },
265
+ whileTap: { scale: .95 },
266
+ children: /* @__PURE__ */ k(q, {
267
+ className: "relative flex items-center justify-center",
268
+ children: /* @__PURE__ */ k(S, { children: /* @__PURE__ */ k(b.div, {
269
+ animate: {
270
+ opacity: 1,
271
+ scale: 1
272
+ },
273
+ className: "h-2.5 w-2.5 absolute rounded-full bg-radio-bg--selected",
274
+ exit: {
275
+ opacity: 0,
276
+ scale: 0
277
+ },
278
+ initial: {
279
+ opacity: 0,
280
+ scale: 0
281
+ },
282
+ transition: i
283
+ }, "radio-indicator") })
284
+ })
285
+ })
286
+ }));
287
+ Z.displayName = "RadioButton";
288
+ var Q = ({ children: e, className: t, disabled: n, ref: r, value: i, ...a }) => {
289
+ let { disabledValues: o, groupDisabled: c, itemClassName: l, variant: u, orientation: f } = E(J), p = D(), m = i.toString(), h = a.id?.toString() ?? `${m}-${p}`, g = c || o.includes(m) || !!n;
290
+ return u === "unstyled" ? /* @__PURE__ */ k(K, {
291
+ asChild: !0,
292
+ "data-testid": "spectral-radio-group-item",
293
+ disabled: g,
294
+ id: h,
295
+ ref: r,
296
+ value: m,
297
+ ...a,
298
+ children: /* @__PURE__ */ k(d, {
299
+ className: s("rounded flex h-fit w-fit border-2 border-transparent data-[state=checked]:border-radio-border--selected", g && Y, l, t),
300
+ "data-testid": "spectral-radio-group-item-label",
301
+ htmlFor: h,
302
+ children: e
303
+ })
304
+ }) : /* @__PURE__ */ A("div", {
305
+ className: s("flex items-center", g && Y, l, t, f),
306
+ children: [/* @__PURE__ */ k(Z, {
307
+ ref: r,
308
+ value: m,
309
+ id: h,
310
+ isDisabled: g,
311
+ ...a
312
+ }), e && /* @__PURE__ */ k(d, {
313
+ className: s("text-md font-normal cursor-pointer", f === "vertical" ? "ml-2" : "ml-1"),
314
+ htmlFor: h,
315
+ children: e
316
+ })]
317
+ });
318
+ };
319
+ Q.displayName = "RadioGroup.Item";
320
+ var $ = ({ ref: e, className: t, ...n }) => /* @__PURE__ */ k(d, {
321
+ ref: e,
322
+ "data-testid": "spectral-radio-group-label",
323
+ className: s("text-md font-medium block", t),
324
+ ...n
325
+ });
326
+ $.displayName = "RadioGroup.Label";
327
+ //#endregion
328
+ export { Q as n, $ as r, X as t };
@@ -1,17 +1,24 @@
1
1
  import { Label } from '../Label/Label';
2
+ import { BaseFormFieldProps, FormFieldState } from './utils/formFieldUtils';
2
3
  import { ComponentProps, ComponentRef, ReactElement, ReactNode, Ref } from 'react';
3
4
  import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
4
5
  type RadioGroupVariant = 'default' | 'unstyled';
5
6
  export interface RadioGroupProps extends Omit<ComponentProps<typeof RadioGroupPrimitive.Root>, 'onChange' | 'disabled'> {
7
+ 'aria-describedby'?: string;
8
+ 'aria-label'?: string;
6
9
  className?: string;
7
10
  disabled?: boolean | string[];
11
+ errorMessage?: BaseFormFieldProps['errorMessage'];
8
12
  itemClassName?: string;
9
13
  name: string;
14
+ onChange?: (selected: string) => void;
10
15
  onValueChange: (selected: string) => void;
11
16
  orientation?: 'horizontal' | 'vertical';
12
17
  required?: boolean;
13
18
  selected?: string;
19
+ state?: FormFieldState;
14
20
  variant?: RadioGroupVariant;
21
+ warningMessage?: BaseFormFieldProps['errorMessage'];
15
22
  }
16
23
  export interface RadioGroupItemProps extends ComponentProps<typeof RadioGroupPrimitive.Item> {
17
24
  className?: string;
@@ -1,2 +1,2 @@
1
- import { n as e, r as t, t as n } from "./RadioGroup-w_q6RGEK.js";
1
+ import { n as e, r as t, t as n } from "./RadioGroup-DqKggFnI.js";
2
2
  export { n as RadioGroup, e as RadioGroupItem, t as RadioGroupLabel };
package/dist/Select.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { BaseFormFieldProps, BaseOption, DropdownWidth } from './utils/formFieldUtils';
1
+ import { BaseFormFieldProps, BaseOption, DropdownWidth, FormFieldState } from './utils/formFieldUtils';
2
2
  import { ComponentPropsWithoutRef, ReactNode, Ref } from 'react';
3
3
  type SelectOption = BaseOption;
4
4
  type Align = 'start' | 'center' | 'end';
5
5
  type Side = 'top' | 'bottom' | 'left' | 'right';
6
- export interface SelectProps extends Omit<ComponentPropsWithoutRef<'button'>, 'value' | 'onChange' | 'aria-disabled' | 'aria-invalid' | 'aria-required' | 'aria-describedby' | 'aria-label'>, BaseFormFieldProps {
6
+ export interface SelectProps extends Omit<ComponentPropsWithoutRef<'button'>, 'value' | 'onChange' | 'aria-disabled' | 'aria-invalid' | 'aria-required' | 'aria-describedby' | 'aria-label'>, Omit<BaseFormFieldProps, 'state'> {
7
7
  defaultValue?: string;
8
8
  dropdownWidth?: DropdownWidth;
9
9
  emptyMessage?: ReactNode;
@@ -12,9 +12,12 @@ export interface SelectProps extends Omit<ComponentPropsWithoutRef<'button'>, 'v
12
12
  labelClassName?: string;
13
13
  loadingMessage?: string;
14
14
  onChange?: (value: string) => void;
15
+ onValueChange?: (value: string) => void;
15
16
  options: SelectOption[];
16
17
  placeholder?: string;
18
+ state?: Exclude<FormFieldState, 'disabled'>;
17
19
  value?: string;
20
+ warningMessage?: BaseFormFieldProps['errorMessage'];
18
21
  }
19
22
  export interface SelectExtendedProps extends SelectProps {
20
23
  align?: Align;
package/dist/Select.js CHANGED
@@ -3,59 +3,67 @@ import "./styles/main.css";
3
3
  import { CheckmarkIcon as e } from "./Icons/CheckmarkIcon.js";
4
4
  import { ChevronDownIcon as t } from "./Icons/ChevronDownIcon.js";
5
5
  import { LoaderIcon as n } from "./Icons/LoaderIcon.js";
6
- import { t as r } from "./twUtils-VNWgstKL.js";
7
- import { EmptyState as i, ErrorMessage as a, LoadingState as o, getAriaProps as s, getDropdownSurfaceClasses as c, getErrorMessageId as l, getFormFieldCSSProperties as ee, getOptionClasses as te, getStateClasses as ne, getTriggerClasses as re, groupOptions as ie, useFormFieldId as ae, useFormFieldState as oe } from "./utils/formFieldUtils.js";
6
+ import { t as r } from "./twUtils-D_qzdiwM.js";
7
+ import { EmptyState as i, ErrorMessage as a, LoadingState as o, WarningMessage as s, getAriaProps as c, getDropdownSurfaceClasses as l, getDropdownWidthStyles as ee, getErrorMessageId as te, getFormFieldCSSProperties as ne, getOptionClasses as re, getTriggerClasses as ie, groupOptions as ae, useFormFieldId as oe } from "./utils/formFieldUtils.js";
8
8
  import { Label as u } from "./Label.js";
9
- import { a as d, c as f, d as p, f as m, h, i as g, l as se, m as ce, n as le, o as ue, p as de, r as fe, t as pe, u as me } from "./dist-fW81qjVl.js";
10
- import { useState as he } from "react";
11
- import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
9
+ import { useAutoDropdownHorizontalShift as se } from "./utils/dropdownPositioning.js";
10
+ import { a as d, c as ce, d as le, f, h as p, i as ue, l as de, m as fe, n as pe, o as me, p as he, r as ge, t as _e, u as ve } from "./dist-fW81qjVl.js";
11
+ import { useState as ye } from "react";
12
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
12
13
  //#region src/components/Select/Select.tsx
13
- var b = (b) => {
14
- let x = "value" in b, { align: S = "start", alignOffset: C = 0, avoidCollisions: w = !0, className: T, collisionBoundary: E, collisionPadding: D = 10, defaultValue: O, dropdownWidth: k = "trigger", emptyMessage: A = "No options found", errorMessage: j, id: M, label: N, labelClassName: P, loadingMessage: F = "Loading…", name: I, onChange: L, options: R = [], placeholder: z = "Select an option", position: B = "popper", ref: ge, side: _e = "bottom", sideOffset: ve = 4, state: V = "default", value: H, "aria-label": ye, "aria-describedby": be, ...U } = b, W = x ? H ?? "" : H, [G, xe] = he(!1), K = ae(M, I), q = l(K), J = k === "trigger" ? "var(--radix-select-trigger-width)" : k === "content" ? "max-content" : k, Y = k === "trigger" || k === "content" ? k : "custom", Se = {
15
- "--spectral-select-content-width": J,
16
- width: B === "item-aligned" ? J : void 0
17
- }, { isDisabled: X, isLoading: Z, isInvalid: Ce } = oe(U.disabled, V), we = s(V, be, U.required, q), { groups: Q, ungrouped: $ } = ie(R), Te = () => {
18
- if (Z) return /* @__PURE__ */ v(o, {
14
+ var _ = (_) => {
15
+ let v = "value" in _, { align: y = "start", alignOffset: b = 0, avoidCollisions: x = !0, className: S, collisionBoundary: C, collisionPadding: w = 10, defaultValue: T, dropdownWidth: E = "trigger", emptyMessage: D = "No options found", errorMessage: O, disabled: k, id: A, label: j, labelClassName: M, loadingMessage: N = "Loading…", name: P, onChange: be, onValueChange: xe, options: F = [], placeholder: Se = "Select an option", position: I = "popper", ref: L, required: R, side: Ce = "bottom", sideOffset: we = 4, state: z = "default", value: B, warningMessage: V, "aria-label": Te, "aria-describedby": Ee, ...De } = _, H = v ? B ?? "" : B, [U, Oe] = ye(!1), { dropdownShiftStyle: ke, setDropdownElement: Ae } = se(U), W = oe(A, P), G = `${W}-listbox`, K = te(W), q = `${W}-warning`, je = z === "error" && O ? K : z === "warning" && V ? q : void 0, { dropdownWidthMode: J, dropdownWidthStyle: Me, resolvedDropdownWidth: Y } = ee({
16
+ dropdownWidth: E,
17
+ triggerWidth: "var(--radix-select-trigger-width)"
18
+ }), Ne = {
19
+ "--spectral-select-content-width": Y,
20
+ ...I === "item-aligned" ? { width: Y } : {},
21
+ ...Me,
22
+ ...ke
23
+ }, X = !!k, Z = z === "loading", Pe = z === "error", Fe = c(z, Ee, R, je), { groups: Q, ungrouped: $ } = ae(F), Ie = (e) => {
24
+ be?.(e), xe?.(e);
25
+ }, Le = () => {
26
+ if (Z) return /* @__PURE__ */ h(o, {
19
27
  "data-testid": "spectral-select-loading",
20
- message: F
28
+ message: N
21
29
  });
22
- if (R.length === 0) return /* @__PURE__ */ v(i, {
30
+ if (F.length === 0) return /* @__PURE__ */ h(i, {
23
31
  "data-testid": "spectral-select-empty",
24
- message: A
32
+ message: D
25
33
  });
26
34
  let t = (t) => {
27
- let n = W === t.value;
28
- return /* @__PURE__ */ y(g, {
29
- className: r(te(!!t.disabled, !1, n), "relative flex w-full cursor-pointer items-center"),
35
+ let n = H === t.value;
36
+ return /* @__PURE__ */ g(ue, {
37
+ className: r(re(!!t.disabled, !1, n), "relative flex w-full cursor-pointer items-center"),
30
38
  "data-testid": "spectral-select-item",
31
39
  disabled: t.disabled,
32
40
  value: t.value,
33
- children: [/* @__PURE__ */ v(ue, {
41
+ children: [/* @__PURE__ */ h(me, {
34
42
  "data-testid": "spectral-select-item-text",
35
43
  className: "block truncate",
36
44
  children: t.label
37
- }), /* @__PURE__ */ v(d, {
45
+ }), /* @__PURE__ */ h(d, {
38
46
  "data-testid": "spectral-select-item-selected-indicator",
39
47
  asChild: !0,
40
- children: /* @__PURE__ */ v("span", {
48
+ children: /* @__PURE__ */ h("span", {
41
49
  className: "right-2 h-4 w-4 absolute flex items-center justify-center",
42
- children: /* @__PURE__ */ v(e, { size: 16 })
50
+ children: /* @__PURE__ */ h(e, { size: 16 })
43
51
  })
44
52
  })]
45
53
  }, t.value);
46
54
  };
47
- return /* @__PURE__ */ y(_, { children: [$.length > 0 && /* @__PURE__ */ y(_, { children: [$.map(t), Object.keys(Q).length > 0 && /* @__PURE__ */ v(m, {
55
+ return /* @__PURE__ */ g(m, { children: [$.length > 0 && /* @__PURE__ */ g(m, { children: [$.map(t), Object.keys(Q).length > 0 && /* @__PURE__ */ h(f, {
48
56
  className: "-mx-1 my-1 h-px bg-border-secondary",
49
57
  "data-testid": "spectral-select-separator"
50
- })] }), Object.entries(Q).map(([e, n], i) => /* @__PURE__ */ y(le, {
58
+ })] }), Object.entries(Q).map(([e, n], i) => /* @__PURE__ */ g(pe, {
51
59
  "data-testid": "spectral-select-group",
52
60
  children: [
53
- i > 0 && /* @__PURE__ */ v(m, {
61
+ i > 0 && /* @__PURE__ */ h(f, {
54
62
  className: "-mx-1 my-1 h-px bg-border-secondary",
55
63
  "data-testid": "spectral-select-group-separator"
56
64
  }),
57
- /* @__PURE__ */ v(u, {
58
- className: r("px-2 py-1.5 text-base font-semibold text-text-primary", P),
65
+ /* @__PURE__ */ h(u, {
66
+ className: r("px-2 py-1.5 text-base font-semibold text-text-primary", M),
59
67
  "data-testid": "spectral-select-group-label",
60
68
  children: e
61
69
  }),
@@ -63,96 +71,98 @@ var b = (b) => {
63
71
  ]
64
72
  }, e))] });
65
73
  };
66
- return /* @__PURE__ */ y("div", {
74
+ return /* @__PURE__ */ g("div", {
67
75
  className: "w-full",
68
76
  children: [
69
- N && /* @__PURE__ */ v(u, {
70
- className: r("mb-2 block text-text-primary", P, X && "text-text-secondary"),
77
+ j && /* @__PURE__ */ h(u, {
78
+ className: r("mb-2 block text-text-primary", M, X && "text-text-secondary"),
71
79
  "data-testid": "spectral-select-label",
72
- htmlFor: K,
73
- children: N
80
+ htmlFor: W,
81
+ children: j
74
82
  }),
75
- /* @__PURE__ */ y(se, {
83
+ /* @__PURE__ */ g(de, {
76
84
  "data-testid": "spectral-select",
77
- defaultValue: O,
85
+ defaultValue: T,
78
86
  disabled: X,
79
- name: I,
80
- onOpenChange: xe,
81
- onValueChange: L,
82
- open: G,
83
- required: U.required,
84
- value: W,
85
- children: [/* @__PURE__ */ v(de, {
86
- "aria-controls": K,
87
- "aria-expanded": G,
88
- "aria-label": ye ?? N,
87
+ name: P,
88
+ onOpenChange: Oe,
89
+ onValueChange: Ie,
90
+ open: U,
91
+ required: R,
92
+ value: H,
93
+ children: [/* @__PURE__ */ h(he, {
94
+ "aria-controls": G,
95
+ "aria-expanded": U,
96
+ "aria-label": Te ?? j,
89
97
  asChild: !0,
90
- className: r(re(!1, V), ne(V), "text-input-text data-placeholder:text-input-text!", T),
98
+ className: r(ie(U, z), "text-input-text data-placeholder:text-input-text-placeholder!", S),
91
99
  "data-slot": "select-trigger",
92
- "data-state": V,
100
+ "data-state": z,
93
101
  "data-testid": "spectral-select-trigger",
94
- id: K,
95
- ref: ge,
102
+ id: W,
103
+ ref: L,
96
104
  role: "combobox",
97
- style: ee(),
98
- ...we,
99
- ...U,
100
- children: /* @__PURE__ */ y("button", {
101
- className: "min-w-0 gap-2 [&>span]:min-w-0 grid w-full cursor-pointer grid-cols-[minmax(0,1fr)_auto] items-center overflow-hidden text-left whitespace-nowrap text-input-text! data-placeholder:text-input-text! [&>span]:block [&>span]:overflow-hidden [&>span]:text-ellipsis [&>span]:whitespace-nowrap [&>span[data-placeholder]]:text-input-text!",
105
+ style: ne(),
106
+ ...Fe,
107
+ ...De,
108
+ children: /* @__PURE__ */ g("button", {
109
+ className: "min-w-0 gap-2 [&>span]:min-w-0 grid w-full cursor-pointer grid-cols-[minmax(0,1fr)_auto] items-center overflow-hidden text-left whitespace-nowrap text-input-text! data-placeholder:text-input-text-placeholder! [&>span]:block [&>span]:overflow-hidden [&>span]:text-ellipsis [&>span]:whitespace-nowrap [&>span[data-placeholder]]:text-input-text-placeholder!",
102
110
  type: "button",
103
111
  disabled: X,
104
- children: [/* @__PURE__ */ v(ce, {
105
- className: "min-w-0 block max-w-full flex-1 truncate text-left whitespace-nowrap text-input-text! data-placeholder:text-input-text!",
112
+ children: [/* @__PURE__ */ h(fe, {
113
+ className: "min-w-0 block max-w-full flex-1 truncate text-left whitespace-nowrap text-input-text! data-placeholder:text-input-text-placeholder!",
106
114
  "data-testid": "spectral-select-value",
107
- placeholder: z
108
- }), /* @__PURE__ */ v(fe, {
115
+ placeholder: Se
116
+ }), /* @__PURE__ */ h(ge, {
109
117
  asChild: !0,
110
- children: /* @__PURE__ */ v("div", {
118
+ children: /* @__PURE__ */ h("div", {
111
119
  className: "flex shrink-0 cursor-pointer items-center",
112
- children: Z ? /* @__PURE__ */ v(n, { size: 20 }) : /* @__PURE__ */ v(t, {
113
- className: r("transition-transform duration-200", G && "rotate-180"),
120
+ children: Z ? /* @__PURE__ */ h(n, { size: 20 }) : /* @__PURE__ */ h(t, {
121
+ className: r("transition-transform duration-200", U && "rotate-180"),
114
122
  size: 20
115
123
  })
116
124
  })
117
125
  })]
118
126
  })
119
- }), /* @__PURE__ */ v(f, { children: /* @__PURE__ */ y(pe, {
120
- align: S,
121
- alignOffset: C,
122
- avoidCollisions: w,
123
- className: r("relative z-50 motion-safe:data-[state=closed]:animate-out motion-safe:data-[state=open]:animate-in", c(), "motion-safe:data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:zoom-out-95 motion-safe:data-[state=open]:fade-in-0 motion-safe:data-[state=open]:zoom-in-95", "max-h-[min(var(--radix-select-content-available-height),300px)] motion-safe:data-[side=bottom]:slide-in-from-top-2 motion-safe:data-[side=top]:slide-in-from-bottom-2", "min-w-32 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto", B === "popper" && "data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1"),
124
- collisionBoundary: E,
125
- collisionPadding: D,
126
- "data-dropdown-width-mode": Y,
127
- "data-dropdown-width-value": Y === "custom" ? k : void 0,
127
+ }), /* @__PURE__ */ h(ce, { children: /* @__PURE__ */ g(_e, {
128
+ align: y,
129
+ alignOffset: b,
130
+ avoidCollisions: x,
131
+ className: r("relative z-50 motion-safe:data-[state=closed]:animate-out motion-safe:data-[state=open]:animate-in", l(), "motion-safe:data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:zoom-out-95 motion-safe:data-[state=open]:fade-in-0 motion-safe:data-[state=open]:zoom-in-95", "max-h-[min(var(--radix-select-content-available-height),300px)] motion-safe:data-[side=bottom]:slide-in-from-top-2 motion-safe:data-[side=top]:slide-in-from-bottom-2", "min-w-32 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto", I === "popper" && "data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1"),
132
+ collisionBoundary: C,
133
+ collisionPadding: w,
134
+ "data-dropdown-width-mode": J,
135
+ "data-dropdown-width-value": J === "custom" ? E : void 0,
136
+ id: G,
128
137
  "data-slot": "select-content",
129
138
  "data-testid": "spectral-select-content",
130
- position: B,
131
- side: _e,
132
- sideOffset: ve,
133
- style: Se,
139
+ position: I,
140
+ ref: Ae,
141
+ side: Ce,
142
+ sideOffset: we,
143
+ style: Ne,
134
144
  children: [
135
- /* @__PURE__ */ v(p, {
145
+ /* @__PURE__ */ h(le, {
136
146
  className: "py-1 flex cursor-default items-center justify-center",
137
147
  "data-testid": "spectral-select-scroll-up-button",
138
- children: /* @__PURE__ */ v(t, {
148
+ children: /* @__PURE__ */ h(t, {
139
149
  "aria-hidden": "true",
140
150
  className: "rotate-180",
141
151
  size: 18
142
152
  })
143
153
  }),
144
- /* @__PURE__ */ v(h, {
154
+ /* @__PURE__ */ h(p, {
145
155
  asChild: !0,
146
- children: /* @__PURE__ */ v("div", {
147
- className: r("p-1", B === "popper" && "scroll-my-1 h-(--radix-select-trigger-height) w-(--spectral-select-content-width) min-w-(--spectral-select-content-width)"),
156
+ children: /* @__PURE__ */ h("div", {
157
+ className: r("p-1", I === "popper" && (E === "trigger" ? "scroll-my-1 h-(--radix-select-trigger-height) w-(--spectral-select-content-width) min-w-(--spectral-select-content-width)" : "scroll-my-1 h-(--radix-select-trigger-height)")),
148
158
  "data-testid": "spectral-select-items",
149
- children: Te()
159
+ children: Le()
150
160
  })
151
161
  }),
152
- /* @__PURE__ */ v(me, {
162
+ /* @__PURE__ */ h(ve, {
153
163
  className: "py-1 flex cursor-default items-center justify-center",
154
164
  "data-testid": "spectral-select-scroll-down-button",
155
- children: /* @__PURE__ */ v(t, {
165
+ children: /* @__PURE__ */ h(t, {
156
166
  "aria-hidden": "true",
157
167
  size: 18
158
168
  })
@@ -160,14 +170,19 @@ var b = (b) => {
160
170
  ]
161
171
  }) })]
162
172
  }),
163
- Ce && j && /* @__PURE__ */ v(a, {
164
- "data-testid": "spectral-select-error-message",
173
+ Pe && O && /* @__PURE__ */ h(a, {
174
+ dataTestId: "spectral-select-error-message",
175
+ id: K,
176
+ message: O
177
+ }),
178
+ z === "warning" && V && /* @__PURE__ */ h(s, {
179
+ dataTestId: "spectral-select-warning-message",
165
180
  id: q,
166
- message: j
181
+ message: V
167
182
  })
168
183
  ]
169
184
  });
170
185
  };
171
- b.displayName = "Select";
186
+ _.displayName = "Select";
172
187
  //#endregion
173
- export { b as Select };
188
+ export { _ as Select };