@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
package/dist/Checkbox.js CHANGED
@@ -1,42 +1,62 @@
1
1
  import "./styles/main.css";
2
2
  import { CheckmarkIcon as e } from "./Icons/CheckmarkIcon.js";
3
3
  import { MinusIcon as t } from "./Icons/MinusIcon.js";
4
- import { t as n } from "./twUtils-VNWgstKL.js";
5
- import { CheckboxBase as r, CheckboxIndicator as i } from "./Checkbox/CheckboxBase.js";
4
+ import { t as n } from "./twUtils-D_qzdiwM.js";
5
+ import { ErrorMessage as r, WarningMessage as i, useFormFieldId as a } from "./utils/formFieldUtils.js";
6
+ import { CheckboxBase as o, CheckboxIndicator as s } from "./Checkbox/CheckboxBase.js";
6
7
  import "react";
7
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
8
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
8
9
  //#region src/components/Checkbox/Checkbox.tsx
9
- var s = ({ checked: s, className: c, id: l, labelText: u, onCheckedChange: d, ref: f, required: p, ...m }) => /* @__PURE__ */ o("div", {
10
- className: "gap-2 flex items-center",
11
- children: [/* @__PURE__ */ a(r, {
12
- "aria-required": p ?? void 0,
13
- checked: s,
14
- className: n("checkbox peer h-5 w-5 rounded-sm shrink-0 border border-checkbox-border hover:opacity-80 focus:outline-none focus-visible:outline-1 focus-visible:outline-checkbox-border--focus", "focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-checkbox-border--checked", c),
15
- "data-testid": "spectral-checkbox",
16
- id: l,
17
- onCheckedChange: d,
18
- ref: f,
19
- ...m,
20
- children: /* @__PURE__ */ a(i, {
21
- "data-testid": "spectral-checkbox-indicator",
22
- className: n("checkbox-indicator flex items-center justify-center text-checkbox-indicator--checked"),
23
- children: s === "indeterminate" ? /* @__PURE__ */ a(t, {
24
- className: "checkbox-indeterminate",
25
- size: 16,
26
- strokeWidth: 4
27
- }) : /* @__PURE__ */ a(e, {
28
- className: "checkbox-check",
29
- size: 16,
30
- strokeWidth: 4
31
- })
10
+ var u = ({ checked: u, className: d, errorMessage: f, id: p, label: m, labelText: h, onCheckedChange: g, ref: _, required: v, state: y = "default", warningMessage: b, "aria-describedby": x, "aria-label": S, ...C }) => {
11
+ let w = a(p, C.name), T = h ?? m, E = `${w}-error`, D = `${w}-warning`;
12
+ return /* @__PURE__ */ l("div", { children: [
13
+ /* @__PURE__ */ l("div", {
14
+ className: "gap-2 flex items-center",
15
+ children: [/* @__PURE__ */ c(o, {
16
+ "aria-describedby": [y === "error" && f && E ? E : y === "warning" && b && D ? D : void 0, x].filter(Boolean).join(" ") || void 0,
17
+ "aria-invalid": y === "error" ? !0 : void 0,
18
+ "aria-label": S ?? (T ? void 0 : "Checkbox"),
19
+ "aria-required": v ?? void 0,
20
+ checked: u,
21
+ className: n("checkbox peer h-5 w-5 rounded-sm shrink-0 border border-checkbox-border hover:opacity-80 focus:outline-none focus-visible:outline-1 focus-visible:outline-checkbox-border--focus", "focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-checkbox-border--checked", d),
22
+ "data-field-state": y,
23
+ "data-testid": "spectral-checkbox",
24
+ id: w,
25
+ onCheckedChange: g,
26
+ ref: _,
27
+ ...C,
28
+ children: /* @__PURE__ */ c(s, {
29
+ "data-testid": "spectral-checkbox-indicator",
30
+ className: n("checkbox-indicator flex items-center justify-center text-checkbox-indicator--checked"),
31
+ children: u === "indeterminate" ? /* @__PURE__ */ c(t, {
32
+ className: "checkbox-indeterminate",
33
+ size: 16,
34
+ strokeWidth: 4
35
+ }) : /* @__PURE__ */ c(e, {
36
+ className: "checkbox-check",
37
+ size: 16,
38
+ strokeWidth: 4
39
+ })
40
+ })
41
+ }), T && /* @__PURE__ */ c("label", {
42
+ className: "text-md peer-disabled:text-neutral-400 text-text-primary",
43
+ "data-testid": "spectral-checkbox-label",
44
+ htmlFor: w,
45
+ children: T
46
+ })]
47
+ }),
48
+ y === "error" && f && E && /* @__PURE__ */ c(r, {
49
+ dataTestId: "spectral-checkbox-error-message",
50
+ id: E,
51
+ message: f
52
+ }),
53
+ y === "warning" && b && D && /* @__PURE__ */ c(i, {
54
+ dataTestId: "spectral-checkbox-warning-message",
55
+ id: D,
56
+ message: b
32
57
  })
33
- }), /* @__PURE__ */ a("label", {
34
- className: "text-md peer-disabled:text-neutral-400 text-text-primary",
35
- "data-testid": "spectral-checkbox-label",
36
- htmlFor: l,
37
- children: u
38
- })]
39
- });
40
- s.displayName = "Checkbox";
58
+ ] });
59
+ };
60
+ u.displayName = "Checkbox";
41
61
  //#endregion
42
- export { s as Checkbox };
62
+ export { u as Checkbox };
@@ -1,3 +1,3 @@
1
1
  import "../primitives/input-group.js";
2
- import { a as e, i as t, n, r, t as i } from "../ComboboxBase-qX-mQhT6.js";
2
+ import { a as e, i as t, n, r, t as i } from "../ComboboxBase-BzDGK36x.js";
3
3
  export { i as ComboboxBase, n as CommandEmpty, r as CommandInput, t as CommandItem, e as CommandList };
@@ -1,21 +1,23 @@
1
- import { BaseFormFieldProps, BaseOption, DropdownWidth } from './utils/formFieldUtils';
1
+ import { BaseFormFieldProps, BaseOption, DropdownWidth, FormFieldState } from './utils/formFieldUtils';
2
2
  import { Ref } from 'react';
3
3
  export type ComboboxOption = BaseOption;
4
- export interface ComboboxProps extends Omit<BaseFormFieldProps, 'onChange'> {
4
+ export interface ComboboxProps extends Omit<BaseFormFieldProps, 'onChange' | 'state'> {
5
5
  className?: string;
6
6
  defaultValue?: string;
7
7
  dropdownWidth?: DropdownWidth;
8
8
  emptyMessage?: string;
9
9
  labelClassName?: string;
10
10
  loadingMessage?: string;
11
+ onChange?: (value: string) => void;
11
12
  onValueChange?: (value: string) => void;
12
13
  options: ComboboxOption[];
13
14
  placeholder?: string;
15
+ state?: Exclude<FormFieldState, 'disabled'>;
14
16
  value?: string;
15
17
  warningMessage?: BaseFormFieldProps['errorMessage'];
16
18
  }
17
19
  export declare const Combobox: {
18
- ({ className, disabled, defaultValue, dropdownWidth, emptyMessage, errorMessage, id, label, labelClassName, loadingMessage, name, onValueChange, options, placeholder, ref, required, state, value: valueProp, warningMessage, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, }: ComboboxProps & {
20
+ ({ className, disabled, defaultValue, dropdownWidth, emptyMessage, errorMessage, id, label, labelClassName, loadingMessage, name, onChange, onValueChange, options, placeholder, ref, required, state, value: valueProp, warningMessage, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, }: ComboboxProps & {
19
21
  ref?: Ref<HTMLDivElement>;
20
22
  }): import("react/jsx-runtime").JSX.Element;
21
23
  displayName: string;
package/dist/Combobox.js CHANGED
@@ -2,137 +2,136 @@
2
2
  import "./styles/main.css";
3
3
  import { ChevronDownIcon as e } from "./Icons/ChevronDownIcon.js";
4
4
  import { LoaderIcon as t } from "./Icons/LoaderIcon.js";
5
- import { t as n } from "./twUtils-VNWgstKL.js";
6
- import { EmptyState as ee, ErrorMessage as r, LoadingState as te, WarningMessage as ne, getAriaProps as re, getDropdownSurfaceClasses as ie, getErrorMessageId as ae, getFormFieldCSSProperties as oe, getOptionClasses as i, getTriggerClasses as a, useFormFieldId as o, useFormFieldState as s } from "./utils/formFieldUtils.js";
7
- import { useUncontrolledState as c } from "./hooks/useUncontrolledState.js";
8
- import { Label as l } from "./Label.js";
9
- import { InputGroup as u, InputGroupAddon as d } from "./primitives/input-group.js";
10
- import { a as f, i as p, n as m, o as h } from "./ComboboxBase-qX-mQhT6.js";
11
- import { useCallback as g, useRef as _, useState as v } from "react";
12
- import { jsx as y, jsxs as b } from "react/jsx-runtime";
5
+ import { t as n } from "./twUtils-D_qzdiwM.js";
6
+ import { EmptyState as ee, ErrorMessage as r, LoadingState as i, WarningMessage as a, getAriaProps as o, getDropdownSurfaceClasses as s, getDropdownWidthStyles as c, getErrorMessageId as l, getFormFieldCSSProperties as u, getOptionClasses as d, getTriggerClasses as f, useFormFieldId as te } from "./utils/formFieldUtils.js";
7
+ import { useUncontrolledState as ne } from "./hooks/useUncontrolledState.js";
8
+ import { Label as re } from "./Label.js";
9
+ import { InputGroup as ie, InputGroupAddon as ae } from "./primitives/input-group.js";
10
+ import { useAutoDropdownHorizontalShift as oe } from "./utils/dropdownPositioning.js";
11
+ import { a as se, i as p, n as ce, o as m } from "./ComboboxBase-BzDGK36x.js";
12
+ import { useCallback as le, useRef as h, useState as g } from "react";
13
+ import { jsx as _, jsxs as v } from "react/jsx-runtime";
13
14
  //#region src/components/Combobox/Combobox.tsx
14
- var x = ({ className: x, disabled: se, defaultValue: ce = "", dropdownWidth: S = "trigger", emptyMessage: C = "No options found.", errorMessage: w, id: T, label: E, labelClassName: D, loadingMessage: O = "Loading…", name: k, onValueChange: A, options: j = [], placeholder: M = "Search…", ref: N, required: P, state: F = "default", value: I, warningMessage: L, "aria-describedby": R, "aria-label": z }) => {
15
- process.env.NODE_ENV !== "production" && !E && !z && console.warn("Combobox: provide either `label` or `aria-label` for an accessible name.");
16
- let B = _(null), V = _(null), H = o(T, k), U = `${H}-listbox`, W = ae(H), G = `${H}-warning`, le = F === "error" ? W : F === "warning" && L ? G : void 0, { isDisabled: K, isLoading: q, isInvalid: ue } = s(se, F), de = re(F, R, P, le), [J, Y] = v(!1), [fe, X] = v(""), [Z, pe] = c({
17
- value: I,
18
- defaultValue: ce,
19
- onChange: A
20
- }), me = j.find((e) => e.value === Z), Q = S === "trigger" || S === "content" ? S : "custom", $ = {
21
- maxWidth: "calc(100vw - 2rem)",
22
- overflowX: "auto",
23
- overflowY: "auto"
24
- }, he = S === "trigger" ? { width: "100%" } : S === "content" ? {
25
- minWidth: "max-content",
26
- width: "max-content",
27
- ...$
28
- } : {
29
- width: S,
30
- ...$
31
- }, ge = (e) => {
32
- pe(e === Z ? "" : e), X(""), Y(!1);
33
- }, _e = (e) => {
34
- e.key === "Escape" && Y(!1);
35
- }, ve = g(() => {
15
+ var y = ({ className: y, disabled: ue, defaultValue: de = "", dropdownWidth: b = "trigger", emptyMessage: x = "No options found.", errorMessage: S, id: C, label: w, labelClassName: T, loadingMessage: E = "Loading…", name: D, onChange: O, onValueChange: k, options: A = [], placeholder: j = "Search…", ref: M, required: N, state: P = "default", value: F, warningMessage: I, "aria-describedby": L, "aria-label": R }) => {
16
+ process.env.NODE_ENV !== "production" && !w && !R && console.warn("Combobox: provide either `label` or `aria-label` for an accessible name.");
17
+ let z = h(null), B = h(null), V = te(C, D), H = `${V}-listbox`, U = l(V), W = `${V}-warning`, fe = P === "error" ? U : P === "warning" && I ? W : void 0, G = !!ue, K = P === "loading", pe = P === "error", me = o(P, L, N, fe), [q, J] = g(!1), { dropdownShiftStyle: he, setDropdownElement: ge } = oe(q), [Y, X] = g(""), [Z, _e] = ne({
18
+ value: F,
19
+ defaultValue: de,
20
+ onChange: (e) => {
21
+ O ? O(e) : k?.(e);
22
+ }
23
+ }), Q = A.find((e) => e.value === Z), ve = !!(Q && Y.length === 0), { dropdownWidthMode: $, dropdownWidthStyle: ye } = c({
24
+ dropdownWidth: b,
25
+ triggerWidth: "var(--radix-popover-trigger-width)"
26
+ }), be = (e) => {
27
+ _e(e === Z ? "" : e), X(""), J(!1);
28
+ }, xe = (e) => {
29
+ e.key === "Escape" && J(!1);
30
+ }, Se = le(() => {
36
31
  requestAnimationFrame(() => {
37
- V.current?.contains(document.activeElement) || (Y(!1), X(""));
32
+ B.current?.contains(document.activeElement) || (J(!1), X(""));
38
33
  });
39
- }, []), ye = () => {
40
- K || q || (B.current?.focus(), Y(!0));
41
- }, be = () => q ? /* @__PURE__ */ y("div", {
42
- id: U,
34
+ }, []), Ce = () => {
35
+ G || K || (z.current?.focus(), J(!0));
36
+ }, we = () => K ? /* @__PURE__ */ _("div", {
37
+ id: H,
43
38
  role: "listbox",
44
- children: /* @__PURE__ */ y(te, { message: O })
45
- }) : j.length === 0 ? /* @__PURE__ */ y("div", {
46
- id: U,
39
+ children: /* @__PURE__ */ _(i, { message: E })
40
+ }) : A.length === 0 ? /* @__PURE__ */ _("div", {
41
+ id: H,
47
42
  role: "listbox",
48
- children: /* @__PURE__ */ y(ee, { message: C })
49
- }) : /* @__PURE__ */ b(f, {
50
- id: U,
51
- children: [/* @__PURE__ */ y(m, { children: C }), j.map((e) => /* @__PURE__ */ y(p, {
52
- className: n(i(!!e.disabled, !1, Z === e.value), "group/command-item relative flex w-full items-center data-[selected=true]:bg-input-bg--hover"),
43
+ children: /* @__PURE__ */ _(ee, { message: x })
44
+ }) : /* @__PURE__ */ v(se, {
45
+ id: H,
46
+ children: [/* @__PURE__ */ _(ce, { children: x }), A.map((e) => /* @__PURE__ */ _(p, {
47
+ className: n(d(!!e.disabled, !1, Z === e.value), "group/command-item relative flex w-full items-center data-[selected=true]:bg-input-bg--hover"),
53
48
  "data-checked": Z === e.value || void 0,
54
49
  disabled: e.disabled,
55
50
  onMouseDown: (e) => e.preventDefault(),
56
- onSelect: () => ge(e.value),
51
+ onSelect: () => be(e.value),
57
52
  value: e.label,
58
- children: /* @__PURE__ */ y("span", {
53
+ children: /* @__PURE__ */ _("span", {
59
54
  className: "min-w-0 flex-1 truncate whitespace-nowrap",
60
55
  children: e.label
61
56
  })
62
57
  }, e.value))]
63
58
  });
64
- return /* @__PURE__ */ b("div", {
59
+ return /* @__PURE__ */ v("div", {
65
60
  className: "w-full",
66
- ref: N,
61
+ ref: M,
67
62
  children: [
68
- k && /* @__PURE__ */ y("input", {
63
+ D && /* @__PURE__ */ _("input", {
69
64
  type: "hidden",
70
- name: k,
65
+ name: D,
71
66
  value: Z,
72
- disabled: K
67
+ disabled: G
73
68
  }),
74
- E && /* @__PURE__ */ y(l, {
75
- className: n("mb-2 block text-text-primary", D, K && "text-text-secondary"),
69
+ w && /* @__PURE__ */ _(re, {
70
+ className: n("mb-2 block text-text-primary", T, G && "text-text-secondary"),
76
71
  "data-testid": "spectral-combobox-label",
77
- htmlFor: H,
78
- children: E
72
+ htmlFor: V,
73
+ children: w
79
74
  }),
80
- /* @__PURE__ */ b(h, {
81
- ref: V,
82
- label: z ?? E,
83
- onKeyDown: _e,
75
+ /* @__PURE__ */ v(m, {
76
+ ref: B,
77
+ label: R ?? w,
78
+ onKeyDown: xe,
84
79
  className: "relative w-full",
85
- children: [/* @__PURE__ */ b(u, {
80
+ children: [/* @__PURE__ */ v(ie, {
86
81
  "data-slot": "combobox-content",
87
- "data-state": F,
82
+ "data-state": P,
88
83
  "data-testid": "spectral-combobox-trigger",
89
- className: n(a(J, F), "ring-0!", K && "pointer-events-none cursor-not-allowed", x),
90
- onClick: ye,
91
- style: oe(),
92
- children: [/* @__PURE__ */ y(h.Input, {
93
- ref: B,
84
+ className: n(f(q, P), "ring-0!", G && "pointer-events-none cursor-not-allowed", y),
85
+ onClick: Ce,
86
+ style: u(),
87
+ children: [/* @__PURE__ */ _(m.Input, {
88
+ ref: z,
94
89
  autoComplete: "off",
95
90
  "data-slot": "input-group-control",
96
- "aria-controls": U,
97
- "aria-expanded": J,
98
- "aria-label": z ?? E,
99
- className: "min-w-0 px-3 py-1 text-base flex-1 truncate overflow-hidden border-0 bg-transparent whitespace-nowrap text-input-text outline-hidden placeholder:text-input-text! placeholder:opacity-100 focus-visible:ring-0 focus-visible:outline-none",
100
- disabled: K,
101
- id: H,
102
- onBlur: ve,
103
- onFocus: () => !K && !q && Y(!0),
91
+ "aria-controls": H,
92
+ "aria-expanded": q,
93
+ "aria-label": R ?? w,
94
+ className: n("min-w-0 px-3 py-1 text-base flex-1 truncate overflow-hidden border-0 bg-transparent whitespace-nowrap text-input-text outline-hidden placeholder:opacity-100 focus-visible:ring-0 focus-visible:outline-none", ve ? "placeholder:text-input-text!" : "placeholder:text-input-text-placeholder!"),
95
+ disabled: G,
96
+ id: V,
97
+ onBlur: Se,
98
+ onFocus: () => !G && !K && J(!0),
104
99
  onValueChange: X,
105
- placeholder: me?.label ?? M,
100
+ placeholder: Q?.label ?? j,
106
101
  role: "combobox",
107
- value: fe,
108
- ...de
109
- }), /* @__PURE__ */ y(d, {
102
+ value: Y,
103
+ ...me
104
+ }), /* @__PURE__ */ _(ae, {
110
105
  align: "inline-end",
111
106
  className: "cursor-pointer",
112
- children: q ? /* @__PURE__ */ y(t, { className: "size-5 motion-safe:animate-spin" }) : /* @__PURE__ */ y(e, { className: n("size-5 shrink-0 transition-transform duration-200", J && "rotate-180") })
107
+ children: K ? /* @__PURE__ */ _(t, { className: "size-5 motion-safe:animate-spin" }) : /* @__PURE__ */ _(e, { className: n("size-5 shrink-0 transition-transform duration-200", q && "rotate-180") })
113
108
  })]
114
- }), /* @__PURE__ */ y("div", {
115
- className: n("left-0 mt-1 p-1 absolute top-full z-50 w-full", ie(), "motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-top-2 motion-safe:zoom-in-95", !J && "hidden"),
116
- "data-dropdown-width-mode": Q,
117
- "data-dropdown-width-value": Q === "custom" ? S : void 0,
109
+ }), /* @__PURE__ */ _("div", {
110
+ className: n("left-0 mt-1 p-1 absolute top-full z-50 w-full", s(), "motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-top-2 motion-safe:zoom-in-95", !q && "hidden"),
111
+ "data-dropdown-width-mode": $,
112
+ "data-dropdown-width-value": $ === "custom" ? b : void 0,
118
113
  "data-testid": "spectral-combobox-content",
119
- style: he,
120
- children: be()
114
+ ref: ge,
115
+ style: {
116
+ ...ye,
117
+ ...he
118
+ },
119
+ children: we()
121
120
  })]
122
121
  }),
123
- ue && w && /* @__PURE__ */ y(r, {
122
+ pe && S && /* @__PURE__ */ _(r, {
124
123
  dataTestId: "spectral-combobox-error-message",
125
- id: W,
126
- message: w
124
+ id: U,
125
+ message: S
127
126
  }),
128
- F === "warning" && L && /* @__PURE__ */ y(ne, {
127
+ P === "warning" && I && /* @__PURE__ */ _(a, {
129
128
  dataTestId: "spectral-combobox-warning-message",
130
- id: G,
131
- message: L
129
+ id: W,
130
+ message: I
132
131
  })
133
132
  ]
134
133
  });
135
134
  };
136
- x.displayName = "Combobox";
135
+ y.displayName = "Combobox";
137
136
  //#endregion
138
- export { x as Combobox };
137
+ export { y as Combobox };
@@ -3,7 +3,7 @@ import { CheckmarkIcon as e } from "./Icons/CheckmarkIcon.js";
3
3
  import { SearchIcon as t } from "./Icons/SearchIcon.js";
4
4
  import { c as n, t as r } from "./dist-7HRQ5IKN.js";
5
5
  import { t as i } from "./dist-Dtvmk11N.js";
6
- import { t as a } from "./twUtils-VNWgstKL.js";
6
+ import { t as a } from "./twUtils-D_qzdiwM.js";
7
7
  import { InputGroup as o, InputGroupAddon as s } from "./primitives/input-group.js";
8
8
  import { a as c, i as l, n as u, o as d } from "./dist-B9tup-4O.js";
9
9
  import * as f from "react";
@@ -4,6 +4,7 @@ import { DropdownWidth, FormFieldState } from '../utils/formFieldUtils';
4
4
  import { ComponentProps } from 'react';
5
5
  import { ControlGroupProps } from './ControlGroup';
6
6
  export interface SelectOptionType {
7
+ disabled?: boolean;
7
8
  label: string;
8
9
  value: string;
9
10
  }
@@ -26,6 +27,7 @@ type ControlGroupSelectBaseProps = ComponentProps<typeof Select> & Pick<ControlG
26
27
  disabled?: boolean;
27
28
  dropdownWidth?: DropdownWidth;
28
29
  errorMessage?: string | string[] | Record<string, unknown> | null;
30
+ id?: string;
29
31
  /** When `captionLayout` is `inline`, overrides the input's accessible name (defaults to `inputPlaceholder` when set). */
30
32
  inputAriaLabel?: string;
31
33
  inputPlaceholder?: string;
@@ -35,10 +37,11 @@ type ControlGroupSelectBaseProps = ComponentProps<typeof Select> & Pick<ControlG
35
37
  /** When `captionLayout` is `inline` and `selectPlaceholder` is empty, sets the select trigger's accessible name. */
36
38
  selectAriaLabel?: string;
37
39
  selectOptions: SelectOptionType[];
38
- state?: FormFieldState;
40
+ state?: Exclude<FormFieldState, 'disabled'>;
39
41
  type?: 'number' | 'text';
42
+ warningMessage?: string | string[] | Record<string, unknown> | null;
40
43
  };
41
44
  export type ControlGroupSelectProps = ControlGroupSelectBaseProps & ControlGroupSelectInputControlProps;
42
- export declare const ControlGroupSelect: ({ amountStep, ariaLabel, captionLayout, className, dataTestId, disabled, errorMessage, dropdownWidth, inputAriaLabel, inputPlaceholder, inputValue, maxAmount, minAmount, onInputChange, orientation, selectAriaLabel, selectOptions, selectPlaceholder, state, type, ...selectProps }: ControlGroupSelectProps) => import("react/jsx-runtime").JSX.Element;
45
+ export declare const ControlGroupSelect: ({ amountStep, ariaLabel, captionLayout, className, dataTestId, disabled, errorMessage, id, dropdownWidth, inputAriaLabel, inputPlaceholder, inputValue, maxAmount, minAmount, onInputChange, orientation, selectAriaLabel, selectOptions, selectPlaceholder, state, type, warningMessage, ...selectProps }: ControlGroupSelectProps) => import("react/jsx-runtime").JSX.Element;
43
46
  export {};
44
47
  //# sourceMappingURL=ControlGroupSelect.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import "../styles/main.css";
3
- import { t as e } from "../twUtils-VNWgstKL.js";
3
+ import { t as e } from "../twUtils-D_qzdiwM.js";
4
4
  import { getStateClasses as t } from "../utils/formFieldUtils.js";
5
5
  import { Label as n } from "../Label.js";
6
6
  import { Input as r } from "../primitives/input.js";
@@ -15,45 +15,47 @@ var g = "placeholder:text-small! [appearance:textfield] [&::-webkit-inner-spin-b
15
15
  }, S = (e, t) => {
16
16
  let n = e?.trim();
17
17
  return n && n.length > 0 ? n : t;
18
- }, C = ({ amountStep: e, ariaLabel: t, captionLayout: n = "inline", className: r, dataTestId: i = "spectral-control-group-select", disabled: a, errorMessage: o, dropdownWidth: s = "trigger", inputAriaLabel: c, inputPlaceholder: u, inputValue: d, maxAmount: p = 1e6, minAmount: h = 0, onInputChange: g, orientation: y = "horizontal", selectAriaLabel: b, selectOptions: C, selectPlaceholder: T, state: E = "default", type: D = "number", ...O }) => {
19
- let k = f(), A = `${k}-amount`, j = `${k}-select`, M = `${A}-label`, N = `${j}-label`, P = n === "above", F = P ? void 0 : u, I = P ? void 0 : T, L = S(u, _), R = S(T, v), z = c ?? (P ? void 0 : L), B = b ?? (P ? void 0 : R), V = x(u, 3), H = x(T, 5), U = t ?? `${L} and ${R}`, W = !!a || E === "disabled", G = d !== void 0 && g !== void 0;
18
+ }, C = ({ amountStep: e, ariaLabel: t, captionLayout: n = "inline", className: r, dataTestId: i = "spectral-control-group-select", disabled: a, errorMessage: o, id: s, dropdownWidth: c = "trigger", inputAriaLabel: u, inputPlaceholder: d, inputValue: p, maxAmount: h = 1e6, minAmount: g = 0, onInputChange: y, orientation: b = "horizontal", selectAriaLabel: C, selectOptions: T, selectPlaceholder: E, state: D = "default", type: O = "number", warningMessage: k, ...A }) => {
19
+ let j = f(), M = s ?? j, N = `${M}-amount`, P = `${M}-select`, F = `${N}-label`, I = `${P}-label`, L = n === "above", R = L ? void 0 : d, z = L ? void 0 : E, B = S(d, _), V = S(E, v), H = u ?? (L ? void 0 : B), U = C ?? (L ? void 0 : V), W = x(d, 3), G = x(E, 5), K = t ?? `${B} and ${V}`, q = !!a, J = p !== void 0 && y !== void 0;
20
20
  return /* @__PURE__ */ m(l, {
21
- "aria-label": U,
21
+ "aria-label": K,
22
22
  className: r,
23
23
  "data-testid": i,
24
24
  disabled: a,
25
25
  errorMessage: o,
26
- orientation: y,
27
- state: E,
26
+ id: M,
27
+ orientation: b,
28
+ state: D,
29
+ warningMessage: k,
28
30
  children: /* @__PURE__ */ m(w, {
29
31
  amountStep: e,
30
32
  dataTestId: i,
31
- inputAccessibleName: z,
32
- inputCaption: F,
33
- inputId: A,
34
- inputLabelId: M,
35
- inputLabelText: L,
36
- inputMinWidth: V,
37
- inputValue: G ? d : void 0,
38
- isDisabled: W,
39
- maxAmount: p,
40
- minAmount: h,
41
- onInputChange: G ? g : void 0,
42
- dropdownWidth: s,
43
- selectCaption: I,
44
- selectOptions: C,
45
- selectLabelId: N,
46
- selectLabelText: R,
47
- selectProps: O,
48
- selectTriggerAriaLabel: B,
49
- selectTriggerId: j,
50
- selectTriggerMinWidth: H,
51
- type: D,
52
- useAboveLabels: P
33
+ inputAccessibleName: H,
34
+ inputCaption: R,
35
+ inputId: N,
36
+ inputLabelId: F,
37
+ inputLabelText: B,
38
+ inputMinWidth: W,
39
+ inputValue: J ? p : void 0,
40
+ isDisabled: q,
41
+ maxAmount: h,
42
+ minAmount: g,
43
+ onInputChange: J ? y : void 0,
44
+ dropdownWidth: c,
45
+ selectCaption: z,
46
+ selectOptions: T,
47
+ selectLabelId: I,
48
+ selectLabelText: V,
49
+ selectProps: A,
50
+ selectTriggerAriaLabel: U,
51
+ selectTriggerId: P,
52
+ selectTriggerMinWidth: G,
53
+ type: O,
54
+ useAboveLabels: L
53
55
  })
54
56
  });
55
57
  }, w = ({ amountStep: l, dataTestId: f, dropdownWidth: _, inputAccessibleName: v, inputCaption: x, inputId: S, inputLabelId: C, inputLabelText: w, inputMinWidth: T, inputValue: E, isDisabled: D, maxAmount: O, minAmount: k, onInputChange: A, selectCaption: j, selectLabelId: M, selectLabelText: N, selectOptions: P, selectProps: F, selectTriggerAriaLabel: I, selectTriggerId: L, selectTriggerMinWidth: R, type: z, useAboveLabels: B }) => {
56
- let { errorMessageId: V, orientation: H, state: U } = d(), W = H === "horizontal" ? "rounded-s-md rounded-e-none" : "rounded-ss-md rounded-se-md rounded-es-none rounded-ee-none", G = H === "horizontal" ? "rounded-s-none rounded-e-md" : "rounded-ss-none rounded-se-none rounded-es-md rounded-ee-md", K = H === "horizontal" ? "me-0" : "mbe-0", q = H === "horizontal" ? "me-0 [&>*:last-child]:-ms-0.5" : "mbe-0 [&>*:last-child]:-mt-0.5", J = /* @__PURE__ */ m(r, {
58
+ let { messageId: V, orientation: H, state: U } = d(), W = H === "horizontal" ? "rounded-s-md rounded-e-none" : "rounded-ss-md rounded-se-md rounded-es-none rounded-ee-none", G = H === "horizontal" ? "rounded-s-none rounded-e-md" : "rounded-ss-none rounded-se-none rounded-es-md rounded-ee-md", K = H === "horizontal" ? "me-0" : "mbe-0", q = H === "horizontal" ? "me-0 [&>*:last-child]:-ms-0.5" : "mbe-0 [&>*:last-child]:-mt-0.5", J = /* @__PURE__ */ m(r, {
57
59
  "aria-describedby": V,
58
60
  "aria-label": v,
59
61
  "aria-labelledby": B ? C : void 0,
@@ -81,7 +83,7 @@ var g = "placeholder:text-small! [appearance:textfield] [&::-webkit-inner-spin-b
81
83
  id: B ? L : void 0,
82
84
  style: R ? { minWidth: R } : void 0,
83
85
  children: /* @__PURE__ */ m(c, {
84
- className: "min-w-0 block max-w-full truncate text-left whitespace-nowrap text-input-text! data-placeholder:text-input-text!",
86
+ className: "min-w-0 block max-w-full truncate text-left whitespace-nowrap text-input-text! data-placeholder:text-input-text-placeholder!",
85
87
  placeholder: j
86
88
  })
87
89
  });
@@ -115,6 +117,7 @@ var g = "placeholder:text-small! [appearance:textfield] [&::-webkit-inner-spin-b
115
117
  "data-testid": `${f}-select-content`,
116
118
  dropdownWidth: _,
117
119
  children: P.map((e) => /* @__PURE__ */ m(o, {
120
+ disabled: e.disabled,
118
121
  value: e.value,
119
122
  children: e.label
120
123
  }, e.value))
@@ -2,7 +2,7 @@ import { Slot } from './primitives/slot';
2
2
  import { FormFieldState } from './utils/formFieldUtils';
3
3
  import { ComponentProps } from 'react';
4
4
  interface ControlGroupContextValue {
5
- errorMessageId?: string;
5
+ messageId?: string;
6
6
  isDisabled: boolean;
7
7
  isInvalid: boolean;
8
8
  isLoading: boolean;
@@ -17,8 +17,9 @@ export interface ControlGroupProps extends ComponentProps<'div'> {
17
17
  name?: string;
18
18
  orientation?: 'horizontal' | 'vertical';
19
19
  state?: FormFieldState;
20
+ warningMessage?: string | string[] | Record<string, unknown> | null;
20
21
  }
21
- export declare const ControlGroup: ({ className, disabled, errorMessage, id, name, orientation, state, ...props }: ControlGroupProps) => import("react/jsx-runtime").JSX.Element;
22
+ export declare const ControlGroup: ({ className, disabled, errorMessage, id, name, orientation, state, warningMessage, ...props }: ControlGroupProps) => import("react/jsx-runtime").JSX.Element;
22
23
  export declare const ControlGroupItem: ({ className, ...props }: ComponentProps<typeof Slot>) => import("react/jsx-runtime").JSX.Element;
23
24
  export {};
24
25
  //# sourceMappingURL=ControlGroup.d.ts.map
@@ -1,48 +1,56 @@
1
1
  "use client";
2
2
  import "./styles/main.css";
3
- import { t as e } from "./twUtils-VNWgstKL.js";
3
+ import { t as e } from "./twUtils-D_qzdiwM.js";
4
4
  import { Slot as t } from "./primitives/slot.js";
5
- import { ErrorMessage as n, getErrorMessageId as r, useFormFieldId as i, useFormFieldState as a } from "./utils/formFieldUtils.js";
6
- import { createContext as o, useContext as s } from "react";
7
- import { jsx as c, jsxs as l } from "react/jsx-runtime";
5
+ import { ErrorMessage as n, WarningMessage as r, getErrorMessageId as i, useFormFieldId as a, useFormFieldState as o } from "./utils/formFieldUtils.js";
6
+ import { createContext as s, useContext as c } from "react";
7
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
8
8
  //#region src/components/ControlGroup/ControlGroup.tsx
9
- var u = o(null), d = () => {
10
- let e = s(u);
9
+ var d = s(null), f = () => {
10
+ let e = c(d);
11
11
  if (e === null) throw Error("useControlGroup must be used within a ControlGroup");
12
12
  return e;
13
- }, f = ({ className: t, disabled: o, errorMessage: s, id: d, name: f, orientation: p = "horizontal", state: m = "default", ...h }) => {
14
- let g = i(d, f), _ = r(g), { isDisabled: v, isLoading: y, isInvalid: b } = a(o, m);
15
- return /* @__PURE__ */ l(u.Provider, {
13
+ }, p = ({ className: t, disabled: s, errorMessage: c, id: f, name: p, orientation: m = "horizontal", state: h = "default", warningMessage: g, ..._ }) => {
14
+ let v = a(f, p), y = i(v), b = `${v}-warning`, { isDisabled: x, isLoading: S, isInvalid: C } = o(s, h), w = h === "error" && c ? y : h === "warning" && g ? b : void 0;
15
+ return /* @__PURE__ */ u(d.Provider, {
16
16
  value: {
17
- errorMessageId: b && s ? _ : void 0,
18
- isDisabled: v,
19
- isInvalid: b,
20
- isLoading: y,
21
- orientation: p,
22
- state: m
17
+ messageId: w,
18
+ isDisabled: x,
19
+ isInvalid: C,
20
+ isLoading: S,
21
+ orientation: m,
22
+ state: h
23
23
  },
24
- children: [/* @__PURE__ */ c("div", {
25
- "data-slot": "control-group",
26
- "data-orientation": p,
27
- "data-state": m,
28
- id: g,
29
- role: "group",
30
- "aria-describedby": b && s ? _ : void 0,
31
- className: e("group flex", p === "vertical" && "flex-col", v && "pointer-events-none opacity-50", t),
32
- ...h
33
- }), b && s && /* @__PURE__ */ c(n, {
34
- dataTestId: "spectral-control-group-error-message",
35
- id: _,
36
- message: s
37
- })]
24
+ children: [
25
+ /* @__PURE__ */ l("div", {
26
+ "data-slot": "control-group",
27
+ "data-orientation": m,
28
+ "data-state": h,
29
+ id: v,
30
+ role: "group",
31
+ "aria-describedby": w,
32
+ className: e("group flex", m === "vertical" && "flex-col", x && "pointer-events-none opacity-50", t),
33
+ ..._
34
+ }),
35
+ C && c && /* @__PURE__ */ l(n, {
36
+ dataTestId: "spectral-control-group-error-message",
37
+ id: y,
38
+ message: c
39
+ }),
40
+ h === "warning" && g && /* @__PURE__ */ l(r, {
41
+ dataTestId: "spectral-control-group-warning-message",
42
+ id: b,
43
+ message: g
44
+ })
45
+ ]
38
46
  });
39
- }, p = ({ className: n, ...r }) => {
40
- let { orientation: i } = d();
41
- return /* @__PURE__ */ c(t, {
47
+ }, m = ({ className: n, ...r }) => {
48
+ let { orientation: i } = f();
49
+ return /* @__PURE__ */ l(t, {
42
50
  "data-slot": "control-group-item",
43
51
  className: e("rounded-none focus-within:z-10 hover:z-10", i === "horizontal" && "first:rounded-s-md last:me-0 last:rounded-e-md -me-0.5 h-auto", i === "vertical" && "first:rounded-ss-md first:rounded-se-md last:rounded-ee-md last:rounded-es-md last:mbe-0 -mbe-0.5 w-auto", n),
44
52
  ...r
45
53
  });
46
54
  };
47
55
  //#endregion
48
- export { f as ControlGroup, p as ControlGroupItem, d as useControlGroup };
56
+ export { p as ControlGroup, m as ControlGroupItem, f as useControlGroup };