@spear-ai/spectral 1.4.25 → 1.4.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/dist/Accordion.d.ts +28 -9
  2. package/dist/Accordion.js +203 -183
  3. package/dist/Alert/AlertBase.d.ts +24 -16
  4. package/dist/Alert/AlertBase.js +33 -18
  5. package/dist/Alert.js +1 -1
  6. package/dist/Avatar.js +11 -11
  7. package/dist/Button.d.ts +7 -2
  8. package/dist/Button.js +25 -12
  9. package/dist/ButtonIcon.d.ts +7 -2
  10. package/dist/ButtonIcon.js +25 -16
  11. package/dist/Card.js +1 -1
  12. package/dist/Checkbox/CheckboxBase.d.ts +13 -13
  13. package/dist/Checkbox/CheckboxBase.js +128 -125
  14. package/dist/Checkbox.d.ts +7 -2
  15. package/dist/Checkbox.js +29 -22
  16. package/dist/DataCard.js +3 -3
  17. package/dist/Dialog.js +2 -2
  18. package/dist/Drawer.js +2 -2
  19. package/dist/HoverCard.js +1 -1
  20. package/dist/Icons/AnalyzeIcon.d.ts +3 -1
  21. package/dist/Icons/AnalyzeIcon.js +3 -6
  22. package/dist/Icons/AnnotationsIcon.d.ts +3 -1
  23. package/dist/Icons/AnnotationsIcon.js +3 -6
  24. package/dist/Icons/ApprovedIcon.d.ts +3 -1
  25. package/dist/Icons/ApprovedIcon.js +3 -6
  26. package/dist/Icons/ArrowDownIcon.d.ts +3 -1
  27. package/dist/Icons/ArrowDownIcon.js +3 -6
  28. package/dist/Icons/ArrowUpIcon.d.ts +3 -1
  29. package/dist/Icons/ArrowUpIcon.js +4 -7
  30. package/dist/Icons/CalendarIcon.d.ts +3 -1
  31. package/dist/Icons/CalendarIcon.js +9 -12
  32. package/dist/Icons/CheckCircleIcon.d.ts +3 -1
  33. package/dist/Icons/CheckCircleIcon.js +2 -5
  34. package/dist/Icons/CheckSquareIcon.d.ts +3 -1
  35. package/dist/Icons/CheckSquareIcon.js +4 -7
  36. package/dist/Icons/CheckmarkIcon.d.ts +3 -1
  37. package/dist/Icons/CheckmarkIcon.js +5 -8
  38. package/dist/Icons/ChevronDownIcon.d.ts +3 -1
  39. package/dist/Icons/ChevronDownIcon.js +5 -8
  40. package/dist/Icons/ChevronUpIcon.d.ts +3 -1
  41. package/dist/Icons/ChevronUpIcon.js +5 -8
  42. package/dist/Icons/ClockIcon.d.ts +3 -1
  43. package/dist/Icons/ClockIcon.js +5 -8
  44. package/dist/Icons/CloseCircleIcon.d.ts +3 -1
  45. package/dist/Icons/CloseCircleIcon.js +4 -7
  46. package/dist/Icons/CloseIcon.d.ts +3 -1
  47. package/dist/Icons/CloseIcon.js +5 -8
  48. package/dist/Icons/DashboardIcon.d.ts +3 -1
  49. package/dist/Icons/DashboardIcon.js +3 -6
  50. package/dist/Icons/DatabaseIcon.d.ts +3 -1
  51. package/dist/Icons/DatabaseIcon.js +4 -7
  52. package/dist/Icons/DeleteIcon.d.ts +3 -1
  53. package/dist/Icons/DeleteIcon.js +4 -7
  54. package/dist/Icons/DurationIcon.d.ts +3 -1
  55. package/dist/Icons/DurationIcon.js +3 -6
  56. package/dist/Icons/EditIcon.d.ts +3 -1
  57. package/dist/Icons/EditIcon.js +3 -6
  58. package/dist/Icons/EmailIcon.d.ts +3 -1
  59. package/dist/Icons/EmailIcon.js +4 -7
  60. package/dist/Icons/EraserIcon.d.ts +3 -1
  61. package/dist/Icons/EraserIcon.js +9 -10
  62. package/dist/Icons/ErrorIcon.d.ts +3 -1
  63. package/dist/Icons/ErrorIcon.js +4 -7
  64. package/dist/Icons/EyeClosedIcon.d.ts +3 -1
  65. package/dist/Icons/EyeClosedIcon.js +4 -7
  66. package/dist/Icons/EyeClosedIcon2.d.ts +3 -1
  67. package/dist/Icons/EyeClosedIcon2.js +3 -6
  68. package/dist/Icons/EyeOpenIcon.d.ts +3 -1
  69. package/dist/Icons/EyeOpenIcon.js +6 -9
  70. package/dist/Icons/GoToFirstIcon.d.ts +3 -1
  71. package/dist/Icons/GoToFirstIcon.js +4 -7
  72. package/dist/Icons/GoToLastIcon.d.ts +3 -1
  73. package/dist/Icons/GoToLastIcon.js +4 -7
  74. package/dist/Icons/HarmonicCursorsIcon.d.ts +3 -1
  75. package/dist/Icons/HarmonicCursorsIcon.js +4 -7
  76. package/dist/Icons/IconBase.d.ts +4 -2
  77. package/dist/Icons/IconBase.js +17 -8
  78. package/dist/Icons/InfoIcon.d.ts +3 -1
  79. package/dist/Icons/InfoIcon.js +4 -7
  80. package/dist/Icons/LabelIcon.d.ts +3 -1
  81. package/dist/Icons/LabelIcon.js +3 -6
  82. package/dist/Icons/LassoIcon.d.ts +3 -1
  83. package/dist/Icons/LassoIcon.js +5 -8
  84. package/dist/Icons/LineToolIcon.d.ts +3 -1
  85. package/dist/Icons/LineToolIcon.js +3 -6
  86. package/dist/Icons/LineToolIcon2.d.ts +3 -1
  87. package/dist/Icons/LineToolIcon2.js +3 -6
  88. package/dist/Icons/LiveViewIcon.d.ts +3 -1
  89. package/dist/Icons/LiveViewIcon.js +2 -5
  90. package/dist/Icons/LoaderIcon.d.ts +3 -1
  91. package/dist/Icons/LoaderIcon.js +6 -7
  92. package/dist/Icons/LocationIcon.d.ts +3 -1
  93. package/dist/Icons/LocationIcon.js +3 -6
  94. package/dist/Icons/LogoutIcon.d.ts +3 -1
  95. package/dist/Icons/LogoutIcon.js +4 -7
  96. package/dist/Icons/MessagesIcon.d.ts +3 -1
  97. package/dist/Icons/MessagesIcon.js +5 -8
  98. package/dist/Icons/MetadataIcon.d.ts +3 -1
  99. package/dist/Icons/MetadataIcon.js +4 -7
  100. package/dist/Icons/MinusIcon.d.ts +3 -1
  101. package/dist/Icons/MinusIcon.js +3 -6
  102. package/dist/Icons/OntologyIcon.d.ts +3 -1
  103. package/dist/Icons/OntologyIcon.js +2 -5
  104. package/dist/Icons/PanelIconClose.d.ts +3 -1
  105. package/dist/Icons/PanelIconClose.js +4 -7
  106. package/dist/Icons/PanelIconOpen.d.ts +3 -1
  107. package/dist/Icons/PanelIconOpen.js +8 -11
  108. package/dist/Icons/PlayIcon.d.ts +3 -1
  109. package/dist/Icons/PlayIcon.js +3 -6
  110. package/dist/Icons/PlusIcon.d.ts +3 -1
  111. package/dist/Icons/PlusIcon.js +4 -7
  112. package/dist/Icons/ResetIcon.d.ts +3 -1
  113. package/dist/Icons/ResetIcon.js +4 -7
  114. package/dist/Icons/ReviewedIcon.d.ts +3 -1
  115. package/dist/Icons/ReviewedIcon.js +3 -6
  116. package/dist/Icons/ScissorsIcon.d.ts +3 -1
  117. package/dist/Icons/ScissorsIcon.js +6 -9
  118. package/dist/Icons/SettingsIcon.d.ts +3 -1
  119. package/dist/Icons/SettingsIcon.js +3 -6
  120. package/dist/Icons/SortAscendingIcon.d.ts +3 -1
  121. package/dist/Icons/SortAscendingIcon.js +3 -6
  122. package/dist/Icons/SortAtoZIcon.d.ts +3 -1
  123. package/dist/Icons/SortAtoZIcon.js +3 -6
  124. package/dist/Icons/SortDescendingIcon.d.ts +3 -1
  125. package/dist/Icons/SortDescendingIcon.js +3 -6
  126. package/dist/Icons/SortZtoAIcon.d.ts +3 -1
  127. package/dist/Icons/SortZtoAIcon.js +3 -6
  128. package/dist/Icons/StackIcon.d.ts +3 -1
  129. package/dist/Icons/StackIcon.js +4 -7
  130. package/dist/Icons/StarIcon.d.ts +3 -1
  131. package/dist/Icons/StarIcon.js +3 -6
  132. package/dist/Icons/TrashIcon.d.ts +3 -1
  133. package/dist/Icons/TrashIcon.js +3 -6
  134. package/dist/Icons/UndoIcon.d.ts +3 -1
  135. package/dist/Icons/UndoIcon.js +4 -7
  136. package/dist/Icons/UserIcon.d.ts +3 -1
  137. package/dist/Icons/UserIcon.js +3 -6
  138. package/dist/Icons/WarningIcon.d.ts +3 -1
  139. package/dist/Icons/WarningIcon.js +5 -8
  140. package/dist/Icons/ZoomAllIcon.d.ts +3 -1
  141. package/dist/Icons/ZoomAllIcon.js +3 -6
  142. package/dist/Icons/ZoomXIcon.d.ts +3 -1
  143. package/dist/Icons/ZoomXIcon.js +4 -7
  144. package/dist/Icons/ZoomYIcon.d.ts +3 -1
  145. package/dist/Icons/ZoomYIcon.js +4 -7
  146. package/dist/Input/InputUtils.d.ts +4 -4
  147. package/dist/Input/InputUtils.js +1 -1
  148. package/dist/Input.d.ts +7 -17
  149. package/dist/Input.js +105 -101
  150. package/dist/InputOTP.d.ts +27 -7
  151. package/dist/InputOTP.js +171 -146
  152. package/dist/Label.d.ts +7 -2
  153. package/dist/Label.js +12 -9
  154. package/dist/MultiSelect/MultiSelectBase.d.ts +7 -2
  155. package/dist/MultiSelect/MultiSelectBase.js +212 -213
  156. package/dist/{MultiSelect/MutiSelect.d.ts → MultiSelect.d.ts} +8 -2
  157. package/dist/MultiSelect.js +27 -0
  158. package/dist/Popover.js +1 -1
  159. package/dist/RadioButtonGroup.js +1 -1
  160. package/dist/RadioGroup.d.ts +20 -14
  161. package/dist/RadioGroup.js +177 -148
  162. package/dist/Select.d.ts +7 -2
  163. package/dist/Select.js +108 -109
  164. package/dist/Separator.d.ts +8 -8
  165. package/dist/Separator.js +14 -15
  166. package/dist/Switch/SwitchBase.d.ts +13 -11
  167. package/dist/Switch/SwitchBase.js +84 -61
  168. package/dist/Switch.d.ts +11 -4
  169. package/dist/Switch.js +19 -20
  170. package/dist/Tabs/TabsBase.d.ts +16 -6
  171. package/dist/Tabs/TabsBase.js +133 -96
  172. package/dist/Tabs/tabsUtils.d.ts +6 -2
  173. package/dist/Tabs/tabsUtils.js +5 -2
  174. package/dist/Tabs.js +18 -18
  175. package/dist/Textarea.d.ts +7 -2
  176. package/dist/Textarea.js +78 -61
  177. package/dist/Toggle/ToggleBase.d.ts +4 -8
  178. package/dist/Toggle/ToggleBase.js +29 -16
  179. package/dist/Toggle.d.ts +4 -2
  180. package/dist/Toggle.js +23 -13
  181. package/dist/ToggleGroup/ToggleGroupBase.d.ts +4 -7
  182. package/dist/ToggleGroup/ToggleGroupBase.js +82 -73
  183. package/dist/ToggleGroup.d.ts +7 -2
  184. package/dist/ToggleGroup.js +31 -19
  185. package/dist/Tray.d.ts +47 -15
  186. package/dist/Tray.js +98 -60
  187. package/dist/hooks/useAccordionAutoScroll.d.ts +1 -1
  188. package/dist/hooks/useAccordionAutoScroll.d.ts.map +1 -1
  189. package/dist/hooks/useAccordionAutoScroll.js +35 -34
  190. package/dist/{index-BSCg4Mei.js → index-B0Kp8R0j.js} +3 -3
  191. package/dist/{index-jgQ7sgLl.js → index-D4jMMaAi.js} +5 -5
  192. package/dist/primitives/input.d.ts.map +1 -1
  193. package/dist/primitives/input.js +1 -4
  194. package/dist/primitives/select.d.ts.map +1 -1
  195. package/dist/primitives/select.js +4 -11
  196. package/dist/primitives/slot.d.ts +11 -4
  197. package/dist/primitives/slot.d.ts.map +1 -1
  198. package/dist/primitives/slot.js +32 -28
  199. package/dist/primitives/textarea.d.ts.map +1 -1
  200. package/dist/primitives/textarea.js +1 -3
  201. package/dist/utils/formFieldUtils.js +2 -2
  202. package/package.json +1 -1
  203. package/dist/MultiSelect/MutiSelect.js +0 -19
@@ -1,15 +1,15 @@
1
- import { RefObject } from 'react';
1
+ import { ChangeEvent, FocusEvent, Ref } from 'react';
2
2
  export declare const usePrefixWidth: (prefix?: string) => {
3
3
  prefixWidth: number;
4
- prefixRef: RefObject<HTMLSpanElement | null>;
4
+ prefixRef: Ref<HTMLSpanElement | null>;
5
5
  };
6
6
  export declare const usePasswordVisibility: () => {
7
7
  isVisible: boolean;
8
8
  toggleVisibility: () => void;
9
9
  inputType: "text" | "password";
10
10
  };
11
- export declare const useClearOnFocus: (clearOnFocus: boolean, onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void) => {
11
+ export declare const useClearOnFocus: (clearOnFocus: boolean, onChange?: (e: ChangeEvent<HTMLInputElement>) => void) => {
12
12
  hasBeenFocused: boolean;
13
- handleFocus: (e: React.FocusEvent<HTMLInputElement>, originalOnFocus?: (e: React.FocusEvent<HTMLInputElement>) => void) => void;
13
+ handleFocus: (e: FocusEvent<HTMLInputElement>, originalOnFocus?: (e: FocusEvent<HTMLInputElement>) => void) => void;
14
14
  };
15
15
  //# sourceMappingURL=InputUtils.d.ts.map
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { useState as u, useCallback as f, useRef as l, useLayoutEffect as d } from "react";
2
+ import { useState as u, useRef as l, useLayoutEffect as d, useCallback as f } from "react";
3
3
  const h = (t) => {
4
4
  const [r, s] = u(0), e = l(null);
5
5
  return d(() => {
package/dist/Input.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { BaseFormFieldProps } from './utils/formFieldUtils';
2
- import { FocusEvent, InputHTMLAttributes, ReactElement } from 'react';
2
+ import { FocusEvent, InputHTMLAttributes, ReactElement, Ref } from 'react';
3
3
  export type InputType = 'text' | 'email' | 'url' | 'tel' | 'password' | 'number' | 'date' | 'datetime-local';
4
4
  export type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'onChange'> & BaseFormFieldProps & {
5
5
  className?: string;
@@ -17,20 +17,10 @@ export type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'onC
17
17
  type?: InputType;
18
18
  value?: string;
19
19
  };
20
- export declare const Input: import('react').ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "id" | "onChange"> & BaseFormFieldProps & {
21
- className?: string;
22
- clearOnFocus?: boolean;
23
- endIcon?: ReactElement;
24
- labelClassName?: string;
25
- onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
26
- onChange?: (value: string) => void;
27
- onFocus?: (e: FocusEvent<HTMLInputElement>) => void;
28
- placeholder?: string;
29
- prefix?: string;
30
- showClearButton?: boolean;
31
- startIcon?: ReactElement;
32
- suppressHydrationWarning?: boolean;
33
- type?: InputType;
34
- value?: string;
35
- } & import('react').RefAttributes<HTMLInputElement>>;
20
+ export declare const Input: {
21
+ ({ ref, className, clearOnFocus, disabled, endIcon, errorMessage, id, label, labelClassName, name, onBlur, onChange, onFocus, placeholder, prefix, required, showClearButton, startIcon, state, suppressHydrationWarning, type, value, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, ...props }: InputProps & {
22
+ ref?: Ref<HTMLInputElement>;
23
+ }): ReactElement;
24
+ displayName: string;
25
+ };
36
26
  //# sourceMappingURL=Input.d.ts.map
package/dist/Input.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import "./styles/main.css";
3
- import { jsxs as u, jsx as t } from "react/jsx-runtime";
4
- import { usePasswordVisibility as tt, usePrefixWidth as rt, useClearOnFocus as et } from "./Input/InputUtils.js";
3
+ import { jsxs as f, jsx as e } from "react/jsx-runtime";
4
+ import { usePasswordVisibility as tt, usePrefixWidth as et, useClearOnFocus as rt } from "./Input/InputUtils.js";
5
5
  import "./Icons/AnalyzeIcon.js";
6
6
  import "./Icons/AnnotationsIcon.js";
7
7
  import "./Icons/ApprovedIcon.js";
@@ -65,10 +65,14 @@ import "./Icons/ZoomAllIcon.js";
65
65
  import "./Icons/ZoomXIcon.js";
66
66
  import "./Icons/ZoomYIcon.js";
67
67
  import { Label as lt } from "./Label.js";
68
- import { useFormFieldId as ct, getAriaProps as mt, getInputClasses as dt, useFormFieldState as ut, getFormFieldCSSProperties as ft, ErrorMessage as ht } from "./utils/formFieldUtils.js";
69
- import { cn as f } from "./utils/twUtils.js";
70
- import { forwardRef as bt, useRef as xt, useCallback as c } from "react";
71
- const gt = (m) => ({
68
+ import { useFormFieldId as ct, useFormFieldState as mt, getAriaProps as dt, getInputClasses as ut, getFormFieldCSSProperties as ft, ErrorMessage as ht } from "./utils/formFieldUtils.js";
69
+ import { cn as h } from "./utils/twUtils.js";
70
+ import { useRef as bt, useCallback as d } from "react";
71
+ const gt = (...a) => (p) => {
72
+ a.forEach((i) => {
73
+ i && (typeof i == "function" ? i(p) : i.current = p);
74
+ });
75
+ }, xt = (a) => ({
72
76
  email: "email",
73
77
  password: "current-password",
74
78
  tel: "tel",
@@ -77,101 +81,101 @@ const gt = (m) => ({
77
81
  number: "off",
78
82
  date: "off",
79
83
  "datetime-local": "off"
80
- })[m] || "off", Ct = bt(
81
- ({
82
- className: m,
83
- clearOnFocus: h = !1,
84
- disabled: k,
85
- endIcon: b,
86
- errorMessage: x,
87
- id: P,
88
- label: e,
89
- labelClassName: R,
90
- name: g,
91
- onBlur: C,
92
- onChange: a,
93
- onFocus: w,
94
- placeholder: S,
95
- prefix: p,
96
- required: v,
97
- showClearButton: V = !1,
98
- startIcon: y,
99
- state: i = "default",
100
- suppressHydrationWarning: $ = !0,
101
- type: n = "text",
102
- value: I = "",
103
- "aria-label": L,
104
- "aria-describedby": M,
105
- ...O
106
- }, j) => {
107
- const l = ct(P, g), N = `${l}-error`, { isDisabled: F, isLoading: A, isInvalid: B } = ut(k, i), H = mt(i, M, v, N), T = xt(null), s = j || T, { isVisible: d, toggleVisibility: W, inputType: D } = tt(), { prefixWidth: G, prefixRef: J } = rt(p), { handleFocus: E } = et(h, a ? (r) => a(r.target.value) : void 0), K = c(
108
- (r) => {
109
- C?.(r);
110
- },
111
- [C]
112
- ), Q = c(
113
- (r) => {
114
- E(r, w);
115
- },
116
- [E, w]
117
- ), U = c(
118
- (r) => {
119
- const o = r.target.value;
120
- a?.(o);
121
- },
122
- [a]
123
- ), X = c(() => {
124
- s.current && (s.current.value = "", s.current.dispatchEvent(new Event("input", { bubbles: !0 })), s.current.focus());
125
- }, [s]), z = V && I.length > 0, Y = () => {
126
- const r = "absolute right-4 top-1/2 -translate-y-1/2 text-input-icon hover:text-input-icon--hover focus:outline-none cursor-pointer", o = {
127
- password: () => /* @__PURE__ */ t("button", { "aria-controls": l, "aria-label": d ? `Hide ${e}` : `Show ${e}`, "aria-pressed": d, className: r, "data-testid": "spectral-input-password-toggle", onClick: W, type: "button", children: d ? /* @__PURE__ */ t(at, { size: 22 }) : /* @__PURE__ */ t(pt, { size: 22 }) }),
128
- clear: () => /* @__PURE__ */ t("button", { "aria-label": `Clear ${e}`, "aria-pressed": !1, className: r, "data-testid": "spectral-input-clear-button", onClick: X, type: "button", children: /* @__PURE__ */ t(it, { size: 24 }) }),
129
- loading: () => /* @__PURE__ */ t("div", { className: "absolute right-4 top-1/2 -translate-y-1/2 text-input-icon", "data-testid": "spectral-input-loading-icon", children: /* @__PURE__ */ t(nt, { size: 24 }) }),
130
- error: () => /* @__PURE__ */ t("div", { className: "absolute right-4 top-1/2 -translate-y-1/2 text-danger-400", "data-testid": "spectral-input-error-icon", children: /* @__PURE__ */ t(st, { size: 24 }) }),
131
- success: () => /* @__PURE__ */ t("div", { className: "absolute right-4 top-1/2 -translate-y-1/2 text-success-400", "data-testid": "spectral-input-success-icon", children: /* @__PURE__ */ t(ot, { size: 24 }) })
132
- };
133
- return b || (n === "password" ? o.password() : z ? o.clear() : A ? o.loading() : i === "success" ? o.success() : i === "error" ? o.error() : null);
134
- }, Z = () => y || null, _ = f(dt(i, m), "[text-indent:var(--prefix-width)]", z && "pr-10"), q = f("pointer-events-none absolute inset-y-0 left-4 flex items-center text-base text-input-text-prefix opacity-100 peer-disabled:opacity-50");
135
- return /* @__PURE__ */ u("div", { className: "w-full space-y-1.5", "data-testid": "spectral-input-container", children: [
136
- e && /* @__PURE__ */ t(lt, { className: f("block mb-2", R, F && "text-input-text--disabled placeholder:text-input-text-placeholder cursor-not-allowed"), "data-testid": "spectral-input-label", htmlFor: l, children: e }),
137
- /* @__PURE__ */ u("div", { className: "relative", "data-testid": "spectral-input-wrapper", children: [
138
- /* @__PURE__ */ u("div", { className: "relative", children: [
139
- Z(),
140
- p && /* @__PURE__ */ t("span", { ref: J, className: q, children: p }),
141
- /* @__PURE__ */ t(
142
- "input",
143
- {
144
- "aria-label": L || e,
145
- autoComplete: gt(n),
146
- className: _,
147
- "data-state": i,
148
- "data-testid": "spectral-input",
149
- disabled: F,
150
- id: l,
151
- name: g,
152
- onBlur: K,
153
- onChange: U,
154
- onFocus: Q,
155
- placeholder: S || e,
156
- ref: s,
157
- required: v,
158
- style: ft({
159
- "--prefix-width": p ? `${G}px` : "0px"
160
- }),
161
- suppressHydrationWarning: $,
162
- type: n === "password" ? D : n,
163
- value: I,
164
- ...H,
165
- ...O
166
- }
167
- ),
168
- Y()
169
- ] }),
170
- B && x && /* @__PURE__ */ t(ht, { dataTestId: "spectral-input-error-message", id: N, message: x })
171
- ] })
172
- ] });
173
- }
174
- );
84
+ })[a] || "off", Ct = ({
85
+ ref: a,
86
+ className: p,
87
+ clearOnFocus: i = !1,
88
+ disabled: P,
89
+ endIcon: b,
90
+ errorMessage: g,
91
+ id: R,
92
+ label: r,
93
+ labelClassName: S,
94
+ name: x,
95
+ onBlur: C,
96
+ onChange: n,
97
+ onFocus: w,
98
+ placeholder: V,
99
+ prefix: l,
100
+ required: v,
101
+ showClearButton: $ = !1,
102
+ startIcon: y,
103
+ state: s = "default",
104
+ suppressHydrationWarning: L = !0,
105
+ type: c = "text",
106
+ value: I = "",
107
+ "aria-label": M,
108
+ "aria-describedby": O,
109
+ ...j
110
+ }) => {
111
+ const m = ct(R, x), N = `${m}-error`, { isDisabled: F, isLoading: A, isInvalid: B } = mt(P, s), H = dt(s, O, v, N), E = bt(null), T = gt(a, E), { isVisible: u, toggleVisibility: W, inputType: D } = tt(), { prefixWidth: G, prefixRef: J } = et(l), { handleFocus: z } = rt(i, n ? (t) => n(t.target.value) : void 0), K = d(
112
+ (t) => {
113
+ C?.(t);
114
+ },
115
+ [C]
116
+ ), Q = d(
117
+ (t) => {
118
+ z(t, w);
119
+ },
120
+ [z, w]
121
+ ), U = d(
122
+ (t) => {
123
+ const o = t.target.value;
124
+ n?.(o);
125
+ },
126
+ [n]
127
+ ), X = d(() => {
128
+ const t = E.current;
129
+ t && (t.value = "", t.dispatchEvent(new Event("input", { bubbles: !0 })), t.focus());
130
+ }, []), k = $ && I.length > 0, Y = () => {
131
+ const t = "absolute right-4 top-1/2 -translate-y-1/2 text-input-icon hover:text-input-icon--hover focus:outline-none cursor-pointer", o = {
132
+ password: () => /* @__PURE__ */ e("button", { "aria-controls": m, "aria-label": u ? `Hide ${r}` : `Show ${r}`, "aria-pressed": u, className: t, "data-testid": "spectral-input-password-toggle", onClick: W, type: "button", children: u ? /* @__PURE__ */ e(at, { size: 22 }) : /* @__PURE__ */ e(pt, { size: 22 }) }),
133
+ clear: () => /* @__PURE__ */ e("button", { "aria-label": `Clear ${r}`, "aria-pressed": !1, className: t, "data-testid": "spectral-input-clear-button", onClick: X, type: "button", children: /* @__PURE__ */ e(it, { size: 24 }) }),
134
+ loading: () => /* @__PURE__ */ e("div", { className: "text-input-icon absolute top-1/2 right-4 -translate-y-1/2", "data-testid": "spectral-input-loading-icon", children: /* @__PURE__ */ e(nt, { size: 24 }) }),
135
+ error: () => /* @__PURE__ */ e("div", { className: "text-danger-400 absolute top-1/2 right-4 -translate-y-1/2", "data-testid": "spectral-input-error-icon", children: /* @__PURE__ */ e(st, { size: 24 }) }),
136
+ success: () => /* @__PURE__ */ e("div", { className: "text-success-400 absolute top-1/2 right-4 -translate-y-1/2", "data-testid": "spectral-input-success-icon", children: /* @__PURE__ */ e(ot, { size: 24 }) })
137
+ };
138
+ return b || (c === "password" ? o.password() : k ? o.clear() : A ? o.loading() : s === "success" ? o.success() : s === "error" ? o.error() : null);
139
+ }, Z = () => y || null, _ = h(ut(s, p), "[text-indent:var(--prefix-width)]", k && "pr-10"), q = h("pointer-events-none absolute inset-y-0 left-4 flex items-center text-base text-input-text-prefix opacity-100 peer-disabled:opacity-50");
140
+ return /* @__PURE__ */ f("div", { className: "w-full space-y-1.5", "data-testid": "spectral-input-container", children: [
141
+ r && /* @__PURE__ */ e(lt, { className: h("mb-2 block", S, F && "text-input-text--disabled placeholder:text-input-text-placeholder cursor-not-allowed"), "data-testid": "spectral-input-label", htmlFor: m, children: r }),
142
+ /* @__PURE__ */ f("div", { className: "relative", "data-testid": "spectral-input-wrapper", children: [
143
+ /* @__PURE__ */ f("div", { className: "relative", children: [
144
+ Z(),
145
+ l && /* @__PURE__ */ e("span", { ref: J, className: q, children: l }),
146
+ /* @__PURE__ */ e(
147
+ "input",
148
+ {
149
+ "aria-label": M || r,
150
+ autoComplete: xt(c),
151
+ className: _,
152
+ "data-state": s,
153
+ "data-testid": "spectral-input",
154
+ disabled: F,
155
+ id: m,
156
+ name: x,
157
+ onBlur: K,
158
+ onChange: U,
159
+ onFocus: Q,
160
+ placeholder: V || r,
161
+ ref: T,
162
+ required: v,
163
+ style: ft({
164
+ "--prefix-width": l ? `${G}px` : "0px"
165
+ }),
166
+ suppressHydrationWarning: L,
167
+ type: c === "password" ? D : c,
168
+ value: I,
169
+ ...H,
170
+ ...j
171
+ }
172
+ ),
173
+ Y()
174
+ ] }),
175
+ B && g && /* @__PURE__ */ e(ht, { dataTestId: "spectral-input-error-message", id: N, message: g })
176
+ ] })
177
+ ] });
178
+ };
175
179
  Ct.displayName = "Input";
176
180
  export {
177
181
  Ct as Input
@@ -1,4 +1,5 @@
1
- import { OTPInputProps } from 'input-otp';
1
+ import { OTPInput, OTPInputProps } from 'input-otp';
2
+ import { ComponentPropsWithoutRef, ComponentRef, Ref } from 'react';
2
3
  type InputOTPRootProps = Omit<OTPInputProps, 'textAlign' | 'pushPasswordManagerStrategy' | 'pasteTransformer' | 'noScriptCSSFallback' | 'placeholder' | 'containerClassName' | 'render'> & {
3
4
  onComplete?: (...args: unknown[]) => void;
4
5
  className?: string;
@@ -19,12 +20,31 @@ export type InputOTPProps = InputOTPRootProps & ({
19
20
  hasError?: false;
20
21
  errorMessage?: never;
21
22
  });
22
- export declare const InputOTP: import('react').ForwardRefExoticComponent<InputOTPProps & import('react').RefAttributes<HTMLInputElement>> & {
23
- Group: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
24
- Slot: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
25
- index: number;
26
- } & import('react').RefAttributes<HTMLDivElement>>;
27
- Separator: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
23
+ export declare const InputOTP: {
24
+ ({ ref, autoFocus, children, className, errorMessage, hasError, id, inputMode, maxLength, name, onChange, onComplete, value, variant, ...props }: InputOTPProps & {
25
+ ref?: Ref<ComponentRef<typeof OTPInput>>;
26
+ }): import("react/jsx-runtime").JSX.Element;
27
+ displayName: string;
28
+ } & {
29
+ Group: {
30
+ ({ ref, ...props }: ComponentPropsWithoutRef<"div"> & {
31
+ ref?: Ref<ComponentRef<"div">>;
32
+ }): import("react/jsx-runtime").JSX.Element;
33
+ displayName: string;
34
+ };
35
+ Slot: {
36
+ ({ ref, index, className, ...props }: ComponentPropsWithoutRef<"div"> & {
37
+ ref?: Ref<ComponentRef<"div">>;
38
+ index: number;
39
+ }): import("react/jsx-runtime").JSX.Element;
40
+ displayName: string;
41
+ };
42
+ Separator: {
43
+ ({ ref, ...props }: ComponentPropsWithoutRef<"div"> & {
44
+ ref?: Ref<ComponentRef<"div">>;
45
+ }): import("react/jsx-runtime").JSX.Element;
46
+ displayName: string;
47
+ };
28
48
  };
29
49
  export {};
30
50
  //# sourceMappingURL=InputOTP.d.ts.map