@spear-ai/spectral 1.13.0 → 1.13.1

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 (49) hide show
  1. package/dist/.js +41 -40
  2. package/dist/Button.d.ts +1 -1
  3. package/dist/Button.js +46 -45
  4. package/dist/Checkbox.js +6 -5
  5. package/dist/{Combobox-DCCcIDgq.js → Combobox-DRQqx0os.js} +9 -8
  6. package/dist/Combobox.js +1 -1
  7. package/dist/ControlGroup/ControlGroupSelect.d.ts +5 -1
  8. package/dist/ControlGroup/ControlGroupSelect.js +73 -67
  9. package/dist/ControlGroup.js +29 -24
  10. package/dist/DateTimePicker/TimePeriodSelect.js +1 -1
  11. package/dist/DateTimePicker.js +8 -7
  12. package/dist/{DropdownMenu-B8I8IRcu.js → DropdownMenu-BO_RPCVU.js} +204 -202
  13. package/dist/DropdownMenu.d.ts +3 -2
  14. package/dist/DropdownMenu.js +1 -1
  15. package/dist/FormFieldMessage.d.ts +11 -0
  16. package/dist/FormFieldMessage.js +55 -0
  17. package/dist/Input.d.ts +1 -0
  18. package/dist/Input.js +68 -67
  19. package/dist/InputNumeric.js +3 -14
  20. package/dist/{InputOTP-DyhesOLs.js → InputOTP-DLn7ja7J.js} +5 -4
  21. package/dist/InputOTP.js +1 -1
  22. package/dist/MultiSelect/MultiSelectBase.js +105 -104
  23. package/dist/{RadioGroup-BsBK247l.js → RadioGroup-D-XjCU4Q.js} +33 -28
  24. package/dist/RadioGroup.js +1 -1
  25. package/dist/Select.js +21 -20
  26. package/dist/{Switch-Vep4hsq4.js → Switch-CSmXtkia.js} +26 -25
  27. package/dist/Switch.js +1 -1
  28. package/dist/Textarea/TextareaUtils.js +4 -8
  29. package/dist/Textarea.js +23 -22
  30. package/dist/Toggle.d.ts +1 -1
  31. package/dist/Toggle.js +10 -10
  32. package/dist/ToggleGroup/ToggleGroupBase.d.ts +1 -1
  33. package/dist/ToggleGroup/ToggleGroupBase.js +19 -19
  34. package/dist/ToggleGroup/ToggleGroupItem.js +2 -2
  35. package/dist/ToggleGroup/ToggleGroupSplitMenuItem.d.ts +5 -2
  36. package/dist/ToggleGroup/ToggleGroupSplitMenuItem.js +91 -52
  37. package/dist/ToggleGroup.js +1 -1
  38. package/dist/index.d.ts +1 -0
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/primitives/select.d.ts +1 -1
  41. package/dist/primitives/select.d.ts.map +1 -1
  42. package/dist/primitives/select.js +1 -1
  43. package/dist/primitives/textarea.js +1 -1
  44. package/dist/{select-oAOoVl5g.js → select-DFE8xm1L.js} +230 -259
  45. package/dist/styles/spectral.css +1 -1
  46. package/dist/utils/formFieldUtils.d.ts +1 -13
  47. package/dist/utils/formFieldUtils.d.ts.map +1 -1
  48. package/dist/utils/formFieldUtils.js +48 -69
  49. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { DropdownWidth } from './utils/formFieldUtils';
2
- import { ComponentPropsWithoutRef, ReactNode } from 'react';
2
+ import { ComponentPropsWithoutRef, RefObject, ReactNode } from 'react';
3
3
  import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
4
4
  type Align = 'start' | 'center' | 'end';
5
5
  type Side = 'top' | 'bottom' | 'left' | 'right';
@@ -39,6 +39,7 @@ export interface DropdownMenuProps extends Omit<ComponentPropsWithoutRef<typeof
39
39
  defaultOpen?: boolean;
40
40
  defaultValue?: DropdownValue;
41
41
  disabled?: boolean;
42
+ dropdownContentRef?: RefObject<HTMLDivElement | null>;
42
43
  dropdownWidth?: DropdownWidth;
43
44
  emptyMessage?: ReactNode;
44
45
  loadingMessage?: string;
@@ -54,7 +55,7 @@ export interface DropdownMenuProps extends Omit<ComponentPropsWithoutRef<typeof
54
55
  value?: DropdownValue;
55
56
  }
56
57
  export declare const DropdownMenu: {
57
- ({ align, asChild, alignOffset, avoidCollisions, className, collisionBoundary, collisionPadding, contentClassName, dataTestId, defaultOpen, defaultValue, disabled, dropdownWidth, emptyMessage, loadingMessage, modal, onOpenChange, onValueChange, open: openProp, options, selectionMode, side, sideOffset, state, trigger, value: valueProp, }: DropdownMenuProps): import("react/jsx-runtime").JSX.Element;
58
+ ({ align, asChild, alignOffset, avoidCollisions, className, collisionBoundary, collisionPadding, contentClassName, dataTestId, defaultOpen, defaultValue, disabled, dropdownContentRef, dropdownWidth, emptyMessage, loadingMessage, modal, onOpenChange, onValueChange, open: openProp, options, selectionMode, side, sideOffset, state, trigger, value: valueProp, }: DropdownMenuProps): import("react/jsx-runtime").JSX.Element;
58
59
  displayName: string;
59
60
  };
60
61
  export {};
@@ -1,3 +1,3 @@
1
1
  'use client'
2
- import { t as e } from "./DropdownMenu-B8I8IRcu.js";
2
+ import { t as e } from "./DropdownMenu-BO_RPCVU.js";
3
3
  export { e as DropdownMenu };
@@ -0,0 +1,11 @@
1
+ export type FormFieldMessageValue = string | string[] | Record<string, unknown> | null | undefined;
2
+ interface BaseFieldMessageProps {
3
+ className?: string;
4
+ dataTestId?: string;
5
+ id: string;
6
+ message: FormFieldMessageValue;
7
+ }
8
+ export declare const ErrorMessage: ({ className, dataTestId, id, message }: BaseFieldMessageProps) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const WarningMessage: ({ className, dataTestId, id, message }: BaseFieldMessageProps) => import("react/jsx-runtime").JSX.Element;
10
+ export {};
11
+ //# sourceMappingURL=FormFieldMessage.d.ts.map
@@ -0,0 +1,55 @@
1
+ 'use client'
2
+ import './styles/main.css'
3
+ import { t as e } from "./twUtils-BpqlKSeB.js";
4
+ import "react";
5
+ import { jsx as t } from "react/jsx-runtime";
6
+ //#region src/components/FormFieldMessage/FormFieldMessage.tsx
7
+ var n = (e) => {
8
+ if (!e) return null;
9
+ if (typeof e == "string") return e;
10
+ if (Array.isArray(e)) return e.join(", ");
11
+ if (typeof e == "object") {
12
+ if ("message" in e && typeof e.message == "string") return e.message;
13
+ if ("error" in e && typeof e.error == "string") return e.error;
14
+ if ("details" in e && typeof e.details == "string") return e.details;
15
+ try {
16
+ return JSON.stringify(e);
17
+ } catch {
18
+ return "[Circular]";
19
+ }
20
+ }
21
+ return String(e);
22
+ }, r = ({ ariaLive: r, className: i, dataTestId: a, id: o, message: s, role: c, tone: l }) => {
23
+ let u = n(s), d = !!u, f = l === "danger" ? "text-danger-400!" : "text-warning-400!";
24
+ return /* @__PURE__ */ t("div", {
25
+ "aria-hidden": !d,
26
+ className: e("transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-none", d ? "translate-y-0 opacity-100" : "-translate-y-1 opacity-0"),
27
+ children: /* @__PURE__ */ t("p", {
28
+ "aria-atomic": d ? "true" : void 0,
29
+ "aria-live": d ? r : void 0,
30
+ className: e("m-0! min-h-0 text-sm overflow-hidden", f, i),
31
+ "data-testid": d ? a : void 0,
32
+ id: o,
33
+ role: d ? c : void 0,
34
+ children: u
35
+ })
36
+ });
37
+ }, i = ({ className: e, dataTestId: n = "spectral-form-field-error-message", id: i, message: a }) => /* @__PURE__ */ t(r, {
38
+ ariaLive: "assertive",
39
+ className: e,
40
+ dataTestId: n,
41
+ id: i,
42
+ message: a,
43
+ role: "alert",
44
+ tone: "danger"
45
+ }), a = ({ className: e, dataTestId: n = "spectral-form-field-warning-message", id: i, message: a }) => /* @__PURE__ */ t(r, {
46
+ ariaLive: "polite",
47
+ className: e,
48
+ dataTestId: n,
49
+ id: i,
50
+ message: a,
51
+ role: "status",
52
+ tone: "warning"
53
+ });
54
+ //#endregion
55
+ export { i as ErrorMessage, a as WarningMessage };
package/dist/Input.d.ts CHANGED
@@ -12,6 +12,7 @@ export type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'onC
12
12
  placeholder?: string;
13
13
  prefix?: string;
14
14
  showClearButton?: boolean;
15
+ showStateIcon?: boolean;
15
16
  startIcon?: ReactElement;
16
17
  suppressHydrationWarning?: boolean;
17
18
  type?: InputType;
package/dist/Input.js CHANGED
@@ -4,22 +4,23 @@ import { CheckCircleIcon as e } from "./Icons/CheckCircleIcon.js";
4
4
  import { CloseCircleIcon as t } from "./Icons/CloseCircleIcon.js";
5
5
  import { ErrorIcon as ee } from "./Icons/ErrorIcon.js";
6
6
  import { EyeClosedIcon as te } from "./Icons/EyeClosedIcon.js";
7
- import { EyeOpenIcon as n } from "./Icons/EyeOpenIcon.js";
8
- import { LoaderIcon as ne } from "./Icons/LoaderIcon.js";
9
- import { WarningIcon as re } from "./Icons/WarningIcon.js";
10
- import { t as r } from "./twUtils-BpqlKSeB.js";
11
- import { ErrorMessage as i, WarningMessage as ie, getAriaProps as a, getFormFieldCSSProperties as o, getInputClasses as s, useFormFieldId as c, useFormFieldState as l } from "./utils/formFieldUtils.js";
7
+ import { EyeOpenIcon as ne } from "./Icons/EyeOpenIcon.js";
8
+ import { LoaderIcon as re } from "./Icons/LoaderIcon.js";
9
+ import { WarningIcon as ie } from "./Icons/WarningIcon.js";
10
+ import { t as n } from "./twUtils-BpqlKSeB.js";
11
+ import { ErrorMessage as r, WarningMessage as i } from "./FormFieldMessage.js";
12
+ import { getAriaProps as a, getFormFieldCSSProperties as o, getInputClasses as s, useFormFieldId as c, useFormFieldState as l } from "./utils/formFieldUtils.js";
12
13
  import { useUncontrolledState as u } from "./hooks/useUncontrolledState.js";
13
14
  import { Label as d } from "./Label.js";
14
- import { useClearOnFocus as f, usePasswordVisibility as p, usePrefixWidth as m } from "./Input/InputUtils.js";
15
- import { useCallback as h, useRef as ae } from "react";
16
- import { jsx as g, jsxs as _ } from "react/jsx-runtime";
15
+ import { useClearOnFocus as f, usePasswordVisibility as p, usePrefixWidth as ae } from "./Input/InputUtils.js";
16
+ import { useCallback as m, useRef as oe } from "react";
17
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
17
18
  //#region src/components/Input/Input.tsx
18
- var oe = (...e) => (t) => {
19
+ var se = (...e) => (t) => {
19
20
  e.forEach((e) => {
20
21
  e && (typeof e == "function" ? e(t) : e.current = t);
21
22
  });
22
- }, se = (e) => ({
23
+ }, ce = (e) => ({
23
24
  date: "off",
24
25
  email: "email",
25
26
  number: "off",
@@ -28,127 +29,127 @@ var oe = (...e) => (t) => {
28
29
  text: "off",
29
30
  url: "url",
30
31
  "datetime-local": "off"
31
- })[e] || "off", v = (v) => {
32
- let { className: ce, clearOnFocus: le = !1, defaultValue: y, disabled: ue, endIcon: b, errorMessage: x, id: S, label: C, labelClassName: w, name: T, onBlur: E, onChange: D, onFocus: O, placeholder: k, prefix: A, ref: j, required: M, showClearButton: N = !1, startIcon: P, state: F = "default", suppressHydrationWarning: I = !0, type: L = "text", value: R, warningMessage: z, "aria-label": B, "aria-describedby": V, ...H } = v, U = c(S, T), W = `${U}-error`, G = `${U}-warning`, { isDisabled: K, isLoading: de, isInvalid: fe } = l(ue, F), pe = a(F, V, M, F === "error" ? W : F === "warning" && z ? G : void 0), [q, J] = u({
33
- value: R,
34
- defaultValue: typeof y == "string" ? y : y == null ? "" : String(y),
32
+ })[e] || "off", _ = (_) => {
33
+ let { className: le, clearOnFocus: ue = !1, defaultValue: v, disabled: y, endIcon: b, errorMessage: x, id: S, label: C, labelClassName: w, name: T, onBlur: E, onChange: D, onFocus: O, placeholder: k, prefix: A, ref: j, required: M, showClearButton: N = !1, showStateIcon: P = !0, startIcon: F, state: I = "default", suppressHydrationWarning: L = !0, type: R = "text", value: z, warningMessage: B, "aria-label": V, "aria-describedby": H, ...de } = _, U = c(S, T), W = `${U}-error`, G = `${U}-warning`, { isDisabled: K, isLoading: fe, isInvalid: pe } = l(y, I), me = a(I, H, M, I === "error" ? W : I === "warning" && B ? G : void 0), [q, J] = u({
34
+ value: z,
35
+ defaultValue: typeof v == "string" ? v : v == null ? "" : String(v),
35
36
  onChange: D
36
- }), Y = ae(null), me = oe(j, Y), { isVisible: X, toggleVisibility: he, inputType: ge } = p(), { prefixWidth: _e, prefixRef: ve } = m(A), { handleFocus: Z } = f(le, (e) => J(e.target.value)), ye = h((e) => {
37
+ }), Y = oe(null), he = se(j, Y), { isVisible: X, toggleVisibility: ge, inputType: _e } = p(), { prefixWidth: ve, prefixRef: ye } = ae(A), { handleFocus: Z } = f(ue, (e) => J(e.target.value)), be = m((e) => {
37
38
  E?.(e);
38
- }, [E]), be = h((e) => {
39
+ }, [E]), xe = m((e) => {
39
40
  Z(e, O);
40
- }, [Z, O]), xe = h((e) => {
41
+ }, [Z, O]), Q = m((e) => {
41
42
  let t = e.target.value;
42
43
  J(t);
43
- }, [J]), Se = h(() => {
44
+ }, [J]), Se = m(() => {
44
45
  let e = Y.current;
45
46
  e && (J(""), e.focus());
46
- }, [J]), Q = N && q.length > 0, Ce = () => {
47
- let r = "absolute right-4 top-1/2 -translate-y-1/2 text-input-icon hover:text-input-icon--hover focus:outline-none cursor-pointer", i = {
48
- password: () => /* @__PURE__ */ g("button", {
47
+ }, [J]), $ = N && q.length > 0, Ce = () => {
48
+ let n = "absolute right-4 top-1/2 -translate-y-1/2 text-input-icon hover:text-input-icon--hover focus:outline-none cursor-pointer", r = {
49
+ password: () => /* @__PURE__ */ h("button", {
49
50
  "aria-controls": U,
50
51
  "aria-label": X ? `Hide ${C ?? "password"}` : `Show ${C ?? "password"}`,
51
52
  "aria-pressed": X,
52
- className: r,
53
+ className: n,
53
54
  "data-testid": "spectral-input-password-toggle",
54
- onClick: he,
55
+ onClick: ge,
55
56
  type: "button",
56
- children: g(X ? te : n, { size: 22 })
57
+ children: h(X ? te : ne, { size: 22 })
57
58
  }),
58
- clear: () => /* @__PURE__ */ g("button", {
59
+ clear: () => /* @__PURE__ */ h("button", {
59
60
  "aria-label": String(`Clear ${C ?? "input"}`),
60
- className: r,
61
+ className: n,
61
62
  "data-testid": "spectral-input-clear-button",
62
63
  onClick: Se,
63
64
  type: "button",
64
- children: /* @__PURE__ */ g(t, { size: 24 })
65
+ children: /* @__PURE__ */ h(t, { size: 24 })
65
66
  }),
66
- loading: () => /* @__PURE__ */ g("div", {
67
+ loading: () => /* @__PURE__ */ h("div", {
67
68
  className: "right-4 text-input-icon absolute top-1/2 -translate-y-1/2",
68
69
  "data-testid": "spectral-input-loading-icon",
69
- children: /* @__PURE__ */ g(ne, { size: 24 })
70
+ children: /* @__PURE__ */ h(re, { size: 24 })
70
71
  }),
71
- error: () => /* @__PURE__ */ g("div", {
72
+ error: () => /* @__PURE__ */ h("div", {
72
73
  className: "right-4 absolute top-1/2 -translate-y-1/2 text-danger-400",
73
74
  "data-testid": "spectral-input-error-icon",
74
- children: /* @__PURE__ */ g(ee, { size: 24 })
75
+ children: /* @__PURE__ */ h(ee, { size: 24 })
75
76
  }),
76
- success: () => /* @__PURE__ */ g("div", {
77
+ success: () => /* @__PURE__ */ h("div", {
77
78
  className: "right-4 absolute top-1/2 -translate-y-1/2 text-success-400",
78
79
  "data-testid": "spectral-input-success-icon",
79
- children: /* @__PURE__ */ g(e, { size: 24 })
80
+ children: /* @__PURE__ */ h(e, { size: 24 })
80
81
  }),
81
- warning: () => /* @__PURE__ */ g("div", {
82
+ warning: () => /* @__PURE__ */ h("div", {
82
83
  className: "right-4 absolute top-1/2 -translate-y-1/2 text-warning-400",
83
84
  "data-testid": "spectral-input-warning-icon",
84
- children: /* @__PURE__ */ g(re, { size: 24 })
85
+ children: /* @__PURE__ */ h(ie, { size: 24 })
85
86
  })
86
87
  };
87
- return b ? /* @__PURE__ */ g("div", {
88
+ return b ? /* @__PURE__ */ h("div", {
88
89
  className: "right-4 text-input-icon absolute top-1/2 -translate-y-1/2",
89
90
  children: b
90
- }) : L === "password" ? i.password() : Q ? i.clear() : de ? i.loading() : F === "success" ? i.success() : F === "warning" ? i.warning() : F === "error" ? i.error() : null;
91
- }, $ = () => P || null, we = L === "number" || L === "date" || L === "datetime-local", Te = r(s(F, ce), "[text-indent:var(--prefix-width)]", Q && "pr-10", we && "tabular-nums"), Ee = r("inset-y-0 left-4 text-base pointer-events-none absolute flex items-center text-input-text-prefix opacity-100 peer-disabled:opacity-50");
92
- return /* @__PURE__ */ _("div", {
91
+ }) : R === "password" ? r.password() : $ ? r.clear() : fe ? r.loading() : !P && (I === "success" || I === "warning" || I === "error") ? null : I === "success" ? r.success() : I === "warning" ? r.warning() : I === "error" ? r.error() : null;
92
+ }, we = () => F || null, Te = R === "number" || R === "date" || R === "datetime-local", Ee = n(s(I, le), "[text-indent:var(--prefix-width)]", $ && "pr-10", Te && "tabular-nums"), De = n("inset-y-0 left-4 text-base pointer-events-none absolute flex items-center text-input-text-prefix opacity-100 peer-disabled:opacity-50");
93
+ return /* @__PURE__ */ g("div", {
93
94
  className: "space-y-1.5 w-full",
94
95
  "data-testid": "spectral-input-container",
95
- children: [C && /* @__PURE__ */ g(d, {
96
- className: r("mb-2 block", w, K && "cursor-not-allowed text-input-text--disabled placeholder:text-input-text-placeholder"),
96
+ children: [C && /* @__PURE__ */ h(d, {
97
+ className: n("mb-2 block", w, K && "cursor-not-allowed text-input-text--disabled placeholder:text-input-text-placeholder"),
97
98
  "data-testid": "spectral-input-label",
98
99
  htmlFor: U,
99
100
  children: C
100
- }), /* @__PURE__ */ _("div", {
101
+ }), /* @__PURE__ */ g("div", {
101
102
  className: "relative",
102
103
  "data-testid": "spectral-input-wrapper",
103
104
  children: [
104
- /* @__PURE__ */ _("div", {
105
+ /* @__PURE__ */ g("div", {
105
106
  className: "relative",
106
107
  children: [
107
- $(),
108
- A && /* @__PURE__ */ g("span", {
109
- ref: ve,
110
- className: Ee,
108
+ we(),
109
+ A && /* @__PURE__ */ h("span", {
110
+ ref: ye,
111
+ className: De,
111
112
  children: A
112
113
  }),
113
- /* @__PURE__ */ g("input", {
114
- "aria-label": B ?? C,
115
- autoComplete: se(L),
116
- className: Te,
117
- "data-state": F,
114
+ /* @__PURE__ */ h("input", {
115
+ "aria-label": V ?? C,
116
+ autoComplete: ce(R),
117
+ className: Ee,
118
+ "data-state": I,
118
119
  "data-testid": "spectral-input",
119
120
  disabled: K,
120
121
  id: U,
121
122
  name: T,
122
- onBlur: ye,
123
- onChange: xe,
124
- onFocus: be,
123
+ onBlur: be,
124
+ onChange: Q,
125
+ onFocus: xe,
125
126
  placeholder: k ?? C,
126
- ref: me,
127
+ ref: he,
127
128
  required: M,
128
- style: o({ "--prefix-width": A ? `${_e}px` : "0" }),
129
- suppressHydrationWarning: I,
130
- type: L === "password" ? ge : L,
129
+ style: o({ "--prefix-width": A ? `${ve}px` : "0" }),
130
+ suppressHydrationWarning: L,
131
+ type: R === "password" ? _e : R,
131
132
  value: q,
132
- ...pe,
133
- ...H
133
+ ...me,
134
+ ...de
134
135
  }),
135
136
  Ce()
136
137
  ]
137
138
  }),
138
- fe && x && /* @__PURE__ */ g(i, {
139
+ /* @__PURE__ */ h(r, {
139
140
  dataTestId: "spectral-input-error-message",
140
141
  id: W,
141
- message: x
142
+ message: pe ? x ?? null : null
142
143
  }),
143
- F === "warning" && z && /* @__PURE__ */ g(ie, {
144
+ /* @__PURE__ */ h(i, {
144
145
  dataTestId: "spectral-input-warning-message",
145
146
  id: G,
146
- message: z
147
+ message: I === "warning" ? B ?? null : null
147
148
  })
148
149
  ]
149
150
  })]
150
151
  });
151
152
  };
152
- v.displayName = "Input";
153
+ _.displayName = "Input";
153
154
  //#endregion
154
- export { v as Input };
155
+ export { _ as Input };
@@ -59,7 +59,7 @@ var a = /^\d$/, o = new Set([
59
59
  }, g = ({ allowDecimal: g = !0, allowNegative: _ = !1, className: v, defaultValue: y = "", locale: b, max: x, min: S, onChange: C, onKeyDown: w, onPaste: T, step: E, value: D, ...O }) => {
60
60
  let [k, A] = t({
61
61
  value: D,
62
- defaultValue: y,
62
+ defaultValue: typeof y == "string" ? y : y == null ? "" : String(y),
63
63
  onChange: C
64
64
  }), j = c(b), M = p(S), N = p(x), P = p(E), F = P && P > 0 ? P : 1, I = M ?? (_ ? void 0 : 0), L = r((e) => {
65
65
  if (w?.(e), !(e.defaultPrevented || e.nativeEvent.isComposing) && !(e.metaKey || e.ctrlKey || e.altKey)) {
@@ -98,19 +98,8 @@ var a = /^\d$/, o = new Set([
98
98
  F,
99
99
  k
100
100
  ]), R = r((e) => {
101
- if (T?.(e), e.defaultPrevented) return;
102
- let t = e.clipboardData.getData("text"), n = u(t, g, _, j);
103
- if (l(t, j) === n) return;
104
- e.preventDefault();
105
- let r = e.currentTarget, i = r.selectionStart ?? r.value.length, a = r.selectionEnd ?? r.value.length;
106
- A(u(`${r.value.slice(0, i)}${n}${r.value.slice(a)}`, g, _, j));
107
- }, [
108
- g,
109
- _,
110
- j,
111
- T,
112
- A
113
- ]), z = r((e) => {
101
+ T?.(e);
102
+ }, [T]), z = r((e) => {
114
103
  A(u(e, g, _, j));
115
104
  }, [
116
105
  g,
@@ -1,7 +1,8 @@
1
1
  import './styles/main.css'
2
2
  import { MinusIcon as e } from "./Icons/MinusIcon.js";
3
3
  import { t } from "./twUtils-BpqlKSeB.js";
4
- import { ErrorMessage as n, getErrorMessageId as r, useFormFieldId as i, useFormFieldState as a } from "./utils/formFieldUtils.js";
4
+ import { ErrorMessage as n } from "./FormFieldMessage.js";
5
+ import { getErrorMessageId as r, useFormFieldId as i, useFormFieldState as a } from "./utils/formFieldUtils.js";
5
6
  import * as o from "react";
6
7
  import { createContext as s, useContext as c } from "react";
7
8
  import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
@@ -394,10 +395,10 @@ var j = "\n[data-input-otp] {\n --nojs-bg: white !important;\n --nojs-fg: blac
394
395
  },
395
396
  children: o ?? /* @__PURE__ */ u(I, { children: /* @__PURE__ */ u(R, {}) })
396
397
  })
397
- }), T && c && /* @__PURE__ */ u(n, {
398
+ }), /* @__PURE__ */ u(n, {
398
399
  dataTestId: "spectral-input-otp-error-message",
399
400
  id: w,
400
- message: c
401
+ message: T ? c : null
401
402
  })]
402
403
  })
403
404
  });
@@ -417,7 +418,7 @@ var L = ({ className: e, index: n, ref: r, ...i }) => {
417
418
  isActive: !1
418
419
  };
419
420
  return /* @__PURE__ */ d("div", {
420
- className: t("h-12 w-10 relative z-10 flex items-center justify-center rounded-[8px] border tabular-nums transition duration-200 focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2", a === "filled" ? "border-level-one bg-level-one" : "border-input-otp-border bg-transparent", !s && "border", s && "border-2 border-danger-400 focus-visible:outline-danger-400", l.isActive && !s && "z-10 outline-2 outline-offset-2 outline-input-otp-border--focus", l.isActive && s && "outline-2 outline-offset-2 outline-danger-400", e),
421
+ className: t("h-12 w-10 relative z-10 flex items-center justify-center rounded-[8px] border tabular-nums transition duration-200 focus:outline-none", a === "filled" ? "border-level-one bg-level-one" : "border-input-otp-border bg-transparent", !s && "border", s && "border-2 border-danger-400", l.isActive && !s && "z-10 border-input-otp-border--focus", l.isActive && s && "z-10 border-danger-400 focus-visible:outline-1 focus-visible:outline-offset-1 focus-visible:outline-danger-400", e),
421
422
  "data-index": n,
422
423
  "data-testid": "spectral-input-otp-slot",
423
424
  "data-variant": a,
package/dist/InputOTP.js CHANGED
@@ -1,3 +1,3 @@
1
1
  'use client'
2
- import { t as e } from "./InputOTP-DyhesOLs.js";
2
+ import { t as e } from "./InputOTP-DLn7ja7J.js";
3
3
  export { e as InputOTP };