@spear-ai/spectral 1.9.0 → 1.10.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 (237) hide show
  1. package/README.md +6 -5
  2. package/dist/.js +112 -239
  3. package/dist/Accordion-CDXdSAST.js +363 -0
  4. package/dist/Accordion.js +3 -498
  5. package/dist/Alert/AlertBase.js +69 -152
  6. package/dist/Alert.js +58 -106
  7. package/dist/AnimatePresence-D-9jXfgI.js +178 -0
  8. package/dist/App.js +6 -6
  9. package/dist/Avatar.js +83 -65
  10. package/dist/Badge.d.ts +1 -3
  11. package/dist/Badge.js +21 -25
  12. package/dist/Button.js +102 -178
  13. package/dist/ButtonGroup/ButtonGroupButton.js +38 -40
  14. package/dist/ButtonGroup.js +55 -59
  15. package/dist/ButtonIcon.js +58 -134
  16. package/dist/Calendar-s4lyijkn.js +3109 -0
  17. package/dist/Checkbox/CheckboxBase.js +94 -126
  18. package/dist/Checkbox.d.ts +1 -1
  19. package/dist/Checkbox.js +40 -105
  20. package/dist/Combobox/ComboboxBase.js +2 -79
  21. package/dist/Combobox.js +106 -172
  22. package/dist/ComboboxBase-D8Nf4xC-.js +491 -0
  23. package/dist/ControlGroup/ControlGroupSelect.d.ts +1 -1
  24. package/dist/ControlGroup/ControlGroupSelect.js +85 -101
  25. package/dist/ControlGroup.js +45 -48
  26. package/dist/DataCard/Card.js +37 -12
  27. package/dist/DataCard.d.ts +1 -1
  28. package/dist/DataCard.js +36 -16
  29. package/dist/DateTimePicker/Calendar.js +2 -2967
  30. package/dist/DateTimePicker/DateTimeDisplayInput.d.ts +1 -1
  31. package/dist/DateTimePicker/DateTimeDisplayInput.js +379 -274
  32. package/dist/DateTimePicker/DateTimeInput.d.ts +5 -3
  33. package/dist/DateTimePicker/DateTimeInput.js +133 -88
  34. package/dist/DateTimePicker/DateTimeUtils.js +2 -2193
  35. package/dist/DateTimePicker/TimePeriodSelect.d.ts +1 -1
  36. package/dist/DateTimePicker/TimePeriodSelect.js +45 -20
  37. package/dist/DateTimePicker/TimePicker.d.ts +1 -1
  38. package/dist/DateTimePicker/TimePicker.js +76 -60
  39. package/dist/DateTimePicker.d.ts +2 -2
  40. package/dist/DateTimePicker.js +87 -205
  41. package/dist/DateTimeUtils-DVvG6H-p.js +2098 -0
  42. package/dist/Dialog.js +74 -74
  43. package/dist/Drawer.js +67 -37
  44. package/dist/HoverCard-CYDsIiVK.js +201 -0
  45. package/dist/HoverCard.d.ts +1 -1
  46. package/dist/HoverCard.js +2 -218
  47. package/dist/Icons/AnalyzeIcon.js +50 -57
  48. package/dist/Icons/AnnotationsIcon.js +20 -15
  49. package/dist/Icons/ApprovedIcon.js +26 -18
  50. package/dist/Icons/ArrowDownIcon.js +20 -6
  51. package/dist/Icons/ArrowUpIcon.js +20 -6
  52. package/dist/Icons/BoxToolIcon.js +17 -12
  53. package/dist/Icons/CalendarIcon.js +43 -20
  54. package/dist/Icons/CheckCircleIcon.js +26 -10
  55. package/dist/Icons/CheckSquareIcon.js +26 -10
  56. package/dist/Icons/CheckmarkIcon.js +22 -9
  57. package/dist/Icons/ChevronDownIcon.js +22 -9
  58. package/dist/Icons/ChevronUpIcon.js +22 -9
  59. package/dist/Icons/ClockIcon.js +26 -18
  60. package/dist/Icons/CloseCircleIcon.js +26 -10
  61. package/dist/Icons/CloseIcon.js +18 -9
  62. package/dist/Icons/DashboardIcon.js +36 -10
  63. package/dist/Icons/DatabaseIcon.js +36 -19
  64. package/dist/Icons/DeleteIcon.js +36 -19
  65. package/dist/Icons/DurationIcon.js +57 -22
  66. package/dist/Icons/EditIcon.js +26 -27
  67. package/dist/Icons/EmailIcon.js +26 -10
  68. package/dist/Icons/EraserIcon.js +41 -25
  69. package/dist/Icons/ErrorIcon.js +27 -11
  70. package/dist/Icons/EyeClosedIcon.js +29 -13
  71. package/dist/Icons/EyeClosedIcon2.js +27 -11
  72. package/dist/Icons/EyeOpenIcon.js +22 -9
  73. package/dist/Icons/FileDownloadIcon.js +43 -20
  74. package/dist/Icons/GoToFirstIcon.js +26 -9
  75. package/dist/Icons/GoToLastIcon.js +26 -9
  76. package/dist/Icons/HarmonicCursorsIcon.js +23 -9
  77. package/dist/Icons/IconBase.d.ts +3 -3
  78. package/dist/Icons/IconBase.js +49 -23
  79. package/dist/Icons/InfoIcon.js +36 -10
  80. package/dist/Icons/KeyboardIcon.js +26 -27
  81. package/dist/Icons/LabelIcon.js +19 -14
  82. package/dist/Icons/LassoIcon.js +36 -28
  83. package/dist/Icons/LineToolIcon.js +48 -39
  84. package/dist/Icons/LiveViewIcon.js +50 -12
  85. package/dist/Icons/LoaderIcon.js +67 -27
  86. package/dist/Icons/LocationIcon.js +26 -27
  87. package/dist/Icons/LogoutIcon.js +20 -15
  88. package/dist/Icons/MeasureIcon.js +78 -25
  89. package/dist/Icons/MessagesIcon.js +33 -18
  90. package/dist/Icons/MetadataIcon.js +20 -15
  91. package/dist/Icons/MinusIcon.d.ts +1 -1
  92. package/dist/Icons/MinusIcon.js +18 -6
  93. package/dist/Icons/OntologyIcon.js +87 -71
  94. package/dist/Icons/PanelIconClose.js +28 -10
  95. package/dist/Icons/PanelIconOpen.js +28 -10
  96. package/dist/Icons/PlayIcon.js +20 -6
  97. package/dist/Icons/PlusIcon.js +20 -14
  98. package/dist/Icons/PolygonIcon.js +50 -39
  99. package/dist/Icons/ProgressCheckIcon.d.ts +5 -0
  100. package/dist/Icons/ProgressCheckIcon.js +58 -0
  101. package/dist/Icons/ResetIcon.js +17 -12
  102. package/dist/Icons/ReviewedIcon.js +36 -19
  103. package/dist/Icons/ScissorsIcon.js +22 -17
  104. package/dist/Icons/SearchIcon.js +26 -9
  105. package/dist/Icons/SettingsIcon.js +26 -27
  106. package/dist/Icons/SortAscendingIcon.js +50 -12
  107. package/dist/Icons/SortAtoZIcon.js +50 -12
  108. package/dist/Icons/SortDescendingIcon.js +50 -12
  109. package/dist/Icons/SortZtoAIcon.js +50 -12
  110. package/dist/Icons/StackIcon.js +26 -9
  111. package/dist/Icons/StarIcon.js +20 -6
  112. package/dist/Icons/TrashIcon.js +17 -12
  113. package/dist/Icons/UndoIcon.js +20 -15
  114. package/dist/Icons/User2Icon.js +26 -10
  115. package/dist/Icons/UserIcon.js +19 -14
  116. package/dist/Icons/WarningIcon.js +19 -14
  117. package/dist/Icons/ZoomAllIcon.js +71 -15
  118. package/dist/Icons/ZoomXIcon.js +36 -10
  119. package/dist/Icons/ZoomYIcon.js +36 -10
  120. package/dist/Icons/index.d.ts +1 -0
  121. package/dist/Icons.js +68 -136
  122. package/dist/IconsAnimated/PanelLeftCloseIcon.js +66 -36
  123. package/dist/IconsAnimated/PanelLeftOpenIcon.js +66 -36
  124. package/dist/IconsAnimated.js +3 -6
  125. package/dist/Input/InputUtils.js +51 -52
  126. package/dist/Input.js +132 -185
  127. package/dist/InputOTP-XUWW9xcI.js +461 -0
  128. package/dist/InputOTP.js +2 -382
  129. package/dist/Kbd.d.ts +1 -1
  130. package/dist/Kbd.js +182 -86
  131. package/dist/Label.js +12 -14
  132. package/dist/MultiSelect/MultiSelectBase.js +331 -403
  133. package/dist/MultiSelect.d.ts +1 -1
  134. package/dist/MultiSelect.js +23 -23
  135. package/dist/Popover.js +28 -32
  136. package/dist/RadioButton.d.ts +17 -0
  137. package/dist/RadioButton.js +33 -0
  138. package/dist/RadioButtonGroup/RadioButtonGroupBase.d.ts +3 -1
  139. package/dist/RadioButtonGroup/RadioButtonGroupBase.js +49 -46
  140. package/dist/RadioButtonGroup.d.ts +1 -1
  141. package/dist/RadioButtonGroup.js +11 -8
  142. package/dist/RadioGroup-w_q6RGEK.js +447 -0
  143. package/dist/RadioGroup.js +2 -505
  144. package/dist/Select.js +163 -186
  145. package/dist/Separator.js +16 -19
  146. package/dist/Skeleton.js +10 -6
  147. package/dist/Slider-BzzZT3Zm.js +490 -0
  148. package/dist/Slider.js +2 -562
  149. package/dist/SpectralProvider.js +8 -5
  150. package/dist/Switch/SwitchBase.js +91 -95
  151. package/dist/Switch-CVzRJ-0n.js +126 -0
  152. package/dist/Switch.d.ts +1 -1
  153. package/dist/Switch.js +2 -134
  154. package/dist/Tabs/TabsBase.js +242 -250
  155. package/dist/Tabs/tabsUtils.js +65 -73
  156. package/dist/Tabs.d.ts +1 -1
  157. package/dist/Tabs.js +73 -103
  158. package/dist/Textarea/TextareaUtils.js +35 -46
  159. package/dist/Textarea.js +83 -160
  160. package/dist/Toast-9zqXxKKO.js +711 -0
  161. package/dist/Toast.js +2 -885
  162. package/dist/Toggle/ToggleBase.js +46 -56
  163. package/dist/Toggle.d.ts +1 -1
  164. package/dist/Toggle.js +52 -62
  165. package/dist/ToggleGroup/ToggleGroupBase.js +128 -104
  166. package/dist/ToggleGroup.d.ts +1 -1
  167. package/dist/ToggleGroup.js +52 -63
  168. package/dist/Tooltip-D1K8kY1y.js +389 -0
  169. package/dist/Tooltip.js +2 -365
  170. package/dist/Tray.js +174 -217
  171. package/dist/chunk-h9knIhTc.js +20 -0
  172. package/dist/clsx-jM1GlMvB.js +16 -0
  173. package/dist/dist-3Af8168y.js +913 -0
  174. package/dist/dist-7HRQ5IKN.js +249 -0
  175. package/dist/dist-B2k1iWFp.js +129 -0
  176. package/dist/dist-B4FgboI8.js +122 -0
  177. package/dist/dist-B4g6zpUF.js +33 -0
  178. package/dist/dist-B9tup-4O.js +216 -0
  179. package/dist/dist-BK1K0g9W.js +29 -0
  180. package/dist/dist-Bfjk-jx9.js +28 -0
  181. package/dist/dist-Bft31cJh.js +65 -0
  182. package/dist/dist-BtdmHAzK.js +190 -0
  183. package/dist/dist-C0Hifjgh.js +1287 -0
  184. package/dist/dist-CGzgmYB9.js +68 -0
  185. package/dist/dist-ClmepHp4.js +10 -0
  186. package/dist/dist-D8Wb_MX9.js +6 -0
  187. package/dist/dist-Dtvmk11N.js +12 -0
  188. package/dist/dist-fW81qjVl.js +677 -0
  189. package/dist/dist-s1uWaZYZ.js +11 -0
  190. package/dist/es2015-YHaMV-St.js +701 -0
  191. package/dist/hooks/useAccordionAutoScroll.js +66 -67
  192. package/dist/hooks/useControllableState.js +14 -13
  193. package/dist/hooks/useTheme.js +21 -17
  194. package/dist/index.d.ts +2 -1
  195. package/dist/index.d.ts.map +1 -1
  196. package/dist/main.js +18954 -27224
  197. package/dist/primitives/button.js +39 -41
  198. package/dist/primitives/input-group.js +57 -73
  199. package/dist/primitives/input.js +11 -20
  200. package/dist/primitives/popover.d.ts.map +1 -1
  201. package/dist/primitives/popover.js +34 -25
  202. package/dist/primitives/select.js +70 -138
  203. package/dist/primitives/slot.js +32 -31
  204. package/dist/primitives/textarea.js +10 -16
  205. package/dist/proxy-Dn10Pl_g.js +4920 -0
  206. package/dist/styles/main.css +2 -1
  207. package/dist/styles/spectral.css +1 -1
  208. package/dist/twUtils-VNWgstKL.js +1673 -0
  209. package/dist/use-animation-CBUDycyW.js +57 -0
  210. package/dist/utils/constants.js +4 -4
  211. package/dist/utils/formFieldUtils.js +136 -148
  212. package/dist/utils/sharedUtils.js +26 -7
  213. package/dist/utils/twUtils.js +2 -2919
  214. package/package.json +24 -28
  215. package/dist/ComboboxBase-CxNxYtdT.js +0 -408
  216. package/dist/clsx-OuTLNxxd.js +0 -16
  217. package/dist/index-0ioNhtNM.js +0 -10
  218. package/dist/index-6oYKCvIn.js +0 -677
  219. package/dist/index-BFOf48AQ.js +0 -69
  220. package/dist/index-BZPx6jYI.js +0 -8
  221. package/dist/index-BlHU_t18.js +0 -142
  222. package/dist/index-Bm1RbF6w.js +0 -1037
  223. package/dist/index-Bv2OIg5P.js +0 -225
  224. package/dist/index-CKEI0pDv.js +0 -56
  225. package/dist/index-CM_hWgfC.js +0 -32
  226. package/dist/index-C_YVr64u.js +0 -1538
  227. package/dist/index-Cl8VeY0o.js +0 -149
  228. package/dist/index-CwSyIPrv.js +0 -13
  229. package/dist/index-D29mdTf5.js +0 -34
  230. package/dist/index-DEYs15GP.js +0 -66
  231. package/dist/index-Dc0No4pV.js +0 -233
  232. package/dist/index-T6XEa11q.js +0 -822
  233. package/dist/index-pBCLb6Gr.js +0 -240
  234. package/dist/index-psiVrsnE.js +0 -27
  235. package/dist/index-rKs9bXHr.js +0 -6
  236. package/dist/proxy-CO_-Vget.js +0 -4975
  237. package/dist/use-animation-DhEPRwZ3.js +0 -62
@@ -1,39 +1,69 @@
1
1
  "use client";
2
2
  import "../styles/main.css";
3
- import { jsx as e, jsxs as h } from "react/jsx-runtime";
4
- import { cn as p } from "../utils/twUtils.js";
5
- import { useRef as f, useImperativeHandle as x, useCallback as i } from "react";
6
- import { u as v } from "../use-animation-DhEPRwZ3.js";
7
- import { m as A } from "../proxy-CO_-Vget.js";
8
- const w = {
9
- times: [0, 0.4, 1],
10
- duration: 0.5
11
- }, g = {
12
- normal: { x: 0 },
13
- animate: { x: [0, 1.5, 0] }
14
- }, R = ({ onMouseEnter: o, onMouseLeave: s, className: m, size: a = 28, ref: l, ...c }) => {
15
- const t = v(), n = f(!1);
16
- x(l, () => (n.current = !0, {
17
- startAnimation: () => t.start("animate"),
18
- stopAnimation: () => t.start("normal")
19
- }));
20
- const u = i(
21
- (r) => {
22
- n.current ? o?.(r) : t.start("animate");
23
- },
24
- [t, o]
25
- ), d = i(
26
- (r) => {
27
- n.current ? s?.(r) : t.start("normal");
28
- },
29
- [t, s]
30
- );
31
- return /* @__PURE__ */ e("div", { className: p(m), onMouseEnter: u, onMouseLeave: d, ...c, children: /* @__PURE__ */ h("svg", { fill: "none", height: a, stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", viewBox: "0 0 24 24", width: a, xmlns: "http://www.w3.org/2000/svg", children: [
32
- /* @__PURE__ */ e("rect", { height: "18", rx: "2", width: "18", x: "3", y: "3" }),
33
- /* @__PURE__ */ e("path", { d: "M9 3v18" }),
34
- /* @__PURE__ */ e(A.path, { animate: t, d: "m14 9 3 3-3 3", transition: w, variants: g })
35
- ] }) });
36
- };
37
- export {
38
- R as PanelLeftOpenIcon
3
+ import { t as e } from "../twUtils-VNWgstKL.js";
4
+ import { t } from "../proxy-Dn10Pl_g.js";
5
+ import { t as n } from "../use-animation-CBUDycyW.js";
6
+ import { useCallback as r, useImperativeHandle as i, useRef as a } from "react";
7
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
8
+ //#region src/components/IconsAnimated/PanelLeftOpenIcon.tsx
9
+ var c = {
10
+ times: [
11
+ 0,
12
+ .4,
13
+ 1
14
+ ],
15
+ duration: .5
16
+ }, l = {
17
+ normal: { x: 0 },
18
+ animate: { x: [
19
+ 0,
20
+ 1.5,
21
+ 0
22
+ ] }
23
+ }, u = ({ onMouseEnter: u, onMouseLeave: d, className: f, size: p = 28, ref: m, ...h }) => {
24
+ let g = n(), _ = a(!1);
25
+ i(m, () => (_.current = !0, {
26
+ startAnimation: () => g.start("animate"),
27
+ stopAnimation: () => g.start("normal")
28
+ }));
29
+ let v = r((e) => {
30
+ _.current ? u?.(e) : g.start("animate");
31
+ }, [g, u]), y = r((e) => {
32
+ _.current ? d?.(e) : g.start("normal");
33
+ }, [g, d]);
34
+ return /* @__PURE__ */ o("div", {
35
+ className: e(f),
36
+ onMouseEnter: v,
37
+ onMouseLeave: y,
38
+ ...h,
39
+ children: /* @__PURE__ */ s("svg", {
40
+ fill: "none",
41
+ height: p,
42
+ stroke: "currentColor",
43
+ strokeLinecap: "round",
44
+ strokeLinejoin: "round",
45
+ strokeWidth: "2",
46
+ viewBox: "0 0 24 24",
47
+ width: p,
48
+ xmlns: "http://www.w3.org/2000/svg",
49
+ children: [
50
+ /* @__PURE__ */ o("rect", {
51
+ height: "18",
52
+ rx: "2",
53
+ width: "18",
54
+ x: "3",
55
+ y: "3"
56
+ }),
57
+ /* @__PURE__ */ o("path", { d: "M9 3v18" }),
58
+ /* @__PURE__ */ o(t.path, {
59
+ animate: g,
60
+ d: "m14 9 3 3-3 3",
61
+ transition: c,
62
+ variants: l
63
+ })
64
+ ]
65
+ })
66
+ });
39
67
  };
68
+ //#endregion
69
+ export { u as PanelLeftOpenIcon };
@@ -1,6 +1,3 @@
1
- import { PanelLeftOpenIcon as n } from "./IconsAnimated/PanelLeftOpenIcon.js";
2
- import { PanelLeftCloseIcon as r } from "./IconsAnimated/PanelLeftCloseIcon.js";
3
- export {
4
- r as PanelLeftCloseIcon,
5
- n as PanelLeftOpenIcon
6
- };
1
+ import { PanelLeftOpenIcon as e } from "./IconsAnimated/PanelLeftOpenIcon.js";
2
+ import { PanelLeftCloseIcon as t } from "./IconsAnimated/PanelLeftCloseIcon.js";
3
+ export { t as PanelLeftCloseIcon, e as PanelLeftOpenIcon };
@@ -1,54 +1,53 @@
1
1
  "use client";
2
- import { useState as u, useCallback as f, useRef as l, useLayoutEffect as d } from "react";
3
- const h = (t) => {
4
- const [r, s] = u(0), e = l(null);
5
- return d(() => {
6
- if (t && e.current) {
7
- const n = () => {
8
- e.current && s(e.current.offsetWidth + 2);
9
- };
10
- n();
11
- const i = new ResizeObserver(n);
12
- return i.observe(e.current), () => {
13
- i.disconnect();
14
- };
15
- }
16
- s(0);
17
- }, [t]), { prefixWidth: r, prefixRef: e };
18
- }, p = () => {
19
- const [t, r] = u(!1), s = f(() => {
20
- r((e) => !e);
21
- }, []);
22
- return {
23
- inputType: t ? "text" : "password",
24
- isVisible: t,
25
- toggleVisibility: s
26
- };
27
- }, v = (t, r) => {
28
- const [s, e] = u(!1), n = f(
29
- (i, o) => {
30
- if (t && !s) {
31
- const c = i.target;
32
- if (c.value = "", e(!0), r) {
33
- const a = {
34
- ...i,
35
- target: c,
36
- currentTarget: c
37
- };
38
- r(a);
39
- }
40
- }
41
- o && o(i);
42
- },
43
- [t, s, r]
44
- );
45
- return {
46
- hasBeenFocused: s,
47
- handleFocus: n
48
- };
49
- };
50
- export {
51
- v as useClearOnFocus,
52
- p as usePasswordVisibility,
53
- h as usePrefixWidth
2
+ import { useCallback as e, useLayoutEffect as t, useRef as n, useState as r } from "react";
3
+ //#region src/components/Input/InputUtils.tsx
4
+ var i = (e) => {
5
+ let [i, a] = r(0), o = n(null);
6
+ return t(() => {
7
+ if (e && o.current) {
8
+ let e = () => {
9
+ o.current && a(o.current.offsetWidth + 2);
10
+ };
11
+ e();
12
+ let t = new ResizeObserver(e);
13
+ return t.observe(o.current), () => {
14
+ t.disconnect();
15
+ };
16
+ }
17
+ a(0);
18
+ }, [e]), {
19
+ prefixWidth: i,
20
+ prefixRef: o
21
+ };
22
+ }, a = () => {
23
+ let [t, n] = r(!1), i = e(() => {
24
+ n((e) => !e);
25
+ }, []);
26
+ return {
27
+ inputType: t ? "text" : "password",
28
+ isVisible: t,
29
+ toggleVisibility: i
30
+ };
31
+ }, o = (t, n) => {
32
+ let [i, a] = r(!1);
33
+ return {
34
+ hasBeenFocused: i,
35
+ handleFocus: e((e, r) => {
36
+ if (t && !i) {
37
+ let t = e.target;
38
+ t.value = "", a(!0), n && n({
39
+ ...e,
40
+ target: t,
41
+ currentTarget: t
42
+ });
43
+ }
44
+ r && r(e);
45
+ }, [
46
+ t,
47
+ i,
48
+ n
49
+ ])
50
+ };
54
51
  };
52
+ //#endregion
53
+ export { o as useClearOnFocus, a as usePasswordVisibility, i as usePrefixWidth };
package/dist/Input.js CHANGED
@@ -1,188 +1,135 @@
1
1
  "use client";
2
2
  import "./styles/main.css";
3
- import { jsxs as f, jsx as t } from "react/jsx-runtime";
4
- import { usePasswordVisibility as tt, usePrefixWidth as rt, useClearOnFocus as et } from "./Input/InputUtils.js";
5
- import "./Icons/AnalyzeIcon.js";
6
- import "./Icons/AnnotationsIcon.js";
7
- import "./Icons/ApprovedIcon.js";
8
- import "./Icons/ArrowDownIcon.js";
9
- import "./Icons/ArrowUpIcon.js";
10
- import "./Icons/BoxToolIcon.js";
11
- import "./Icons/CalendarIcon.js";
12
- import { CheckCircleIcon as ot } from "./Icons/CheckCircleIcon.js";
13
- import "./Icons/CheckSquareIcon.js";
14
- import "./Icons/CheckmarkIcon.js";
15
- import "./Icons/ChevronDownIcon.js";
16
- import "./Icons/ChevronUpIcon.js";
17
- import "./Icons/ClockIcon.js";
18
- import { CloseCircleIcon as it } from "./Icons/CloseCircleIcon.js";
19
- import "./Icons/CloseIcon.js";
20
- import "./Icons/DashboardIcon.js";
21
- import "./Icons/DatabaseIcon.js";
22
- import "./Icons/DeleteIcon.js";
23
- import "./Icons/DurationIcon.js";
24
- import "./Icons/EditIcon.js";
25
- import "./Icons/EmailIcon.js";
26
- import "./Icons/EraserIcon.js";
27
- import { ErrorIcon as st } from "./Icons/ErrorIcon.js";
28
- import { EyeClosedIcon as at } from "./Icons/EyeClosedIcon.js";
29
- import "./Icons/EyeClosedIcon2.js";
30
- import { EyeOpenIcon as pt } from "./Icons/EyeOpenIcon.js";
31
- import "./Icons/FileDownloadIcon.js";
32
- import "./Icons/GoToFirstIcon.js";
33
- import "./Icons/GoToLastIcon.js";
34
- import "./Icons/HarmonicCursorsIcon.js";
35
- import "./Icons/InfoIcon.js";
36
- import "./Icons/KeyboardIcon.js";
37
- import "./Icons/LabelIcon.js";
38
- import "./Icons/LassoIcon.js";
39
- import "./Icons/LineToolIcon.js";
40
- import "./Icons/LiveViewIcon.js";
41
- import { LoaderIcon as nt } from "./Icons/LoaderIcon.js";
42
- import "./Icons/LocationIcon.js";
43
- import "./Icons/LogoutIcon.js";
44
- import "./Icons/MeasureIcon.js";
45
- import "./Icons/MessagesIcon.js";
46
- import "./Icons/MetadataIcon.js";
47
- import "./Icons/MinusIcon.js";
48
- import "./Icons/OntologyIcon.js";
49
- import "./Icons/PanelIconClose.js";
50
- import "./Icons/PanelIconOpen.js";
51
- import "./Icons/PlayIcon.js";
52
- import "./Icons/PlusIcon.js";
53
- import "./Icons/PolygonIcon.js";
54
- import "./Icons/ResetIcon.js";
55
- import "./Icons/ReviewedIcon.js";
56
- import "./Icons/ScissorsIcon.js";
57
- import "./Icons/SearchIcon.js";
58
- import "./Icons/SettingsIcon.js";
59
- import "./Icons/SortAscendingIcon.js";
60
- import "./Icons/SortAtoZIcon.js";
61
- import "./Icons/SortDescendingIcon.js";
62
- import "./Icons/SortZtoAIcon.js";
63
- import "./Icons/StackIcon.js";
64
- import "./Icons/StarIcon.js";
65
- import "./Icons/TrashIcon.js";
66
- import "./Icons/UndoIcon.js";
67
- import "./Icons/User2Icon.js";
68
- import "./Icons/UserIcon.js";
69
- import "./Icons/WarningIcon.js";
70
- import "./Icons/ZoomAllIcon.js";
71
- import "./Icons/ZoomXIcon.js";
72
- import "./Icons/ZoomYIcon.js";
73
- import { Label as lt } from "./Label.js";
74
- import { useFormFieldId as ct, useFormFieldState as mt, getAriaProps as dt, getInputClasses as ut, getFormFieldCSSProperties as ft, ErrorMessage as ht } from "./utils/formFieldUtils.js";
75
- import { cn as h } from "./utils/twUtils.js";
76
- import { useRef as bt, useCallback as d } from "react";
77
- const gt = (...a) => (p) => {
78
- a.forEach((i) => {
79
- i && (typeof i == "function" ? i(p) : i.current = p);
80
- });
81
- }, xt = (a) => ({
82
- date: "off",
83
- email: "email",
84
- number: "off",
85
- password: "current-password",
86
- tel: "tel",
87
- text: "off",
88
- url: "url",
89
- "datetime-local": "off"
90
- })[a] || "off", Ct = ({
91
- className: a,
92
- clearOnFocus: p = !1,
93
- disabled: i,
94
- endIcon: b,
95
- errorMessage: g,
96
- id: k,
97
- label: e,
98
- labelClassName: P,
99
- name: x,
100
- onBlur: C,
101
- onChange: n,
102
- onFocus: w,
103
- placeholder: R,
104
- prefix: l,
105
- ref: V,
106
- required: v,
107
- showClearButton: $ = !1,
108
- startIcon: y,
109
- state: s = "default",
110
- suppressHydrationWarning: L = !0,
111
- type: c = "text",
112
- value: I = "",
113
- "aria-label": M,
114
- "aria-describedby": O,
115
- ...j
116
- }) => {
117
- const m = ct(k, x), N = `${m}-error`, { isDisabled: F, isLoading: A, isInvalid: B } = mt(i, s), H = dt(s, O, v, N), E = bt(null), T = gt(V, E), { isVisible: u, toggleVisibility: W, inputType: D } = tt(), { prefixWidth: G, prefixRef: J } = rt(l), { handleFocus: z } = et(p, n ? (r) => n(r.target.value) : void 0), K = d(
118
- (r) => {
119
- C?.(r);
120
- },
121
- [C]
122
- ), Q = d(
123
- (r) => {
124
- z(r, w);
125
- },
126
- [z, w]
127
- ), U = d(
128
- (r) => {
129
- const o = r.target.value;
130
- n?.(o);
131
- },
132
- [n]
133
- ), X = d(() => {
134
- const r = E.current;
135
- r && (r.value = "", r.dispatchEvent(new Event("input", { bubbles: !0 })), r.focus());
136
- }, []), S = $ && I.length > 0, Y = () => {
137
- 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 = {
138
- password: () => /* @__PURE__ */ t("button", { "aria-controls": m, "aria-label": u ? `Hide ${e ?? "password"}` : `Show ${e ?? "password"}`, "aria-pressed": u, className: r, "data-testid": "spectral-input-password-toggle", onClick: W, type: "button", children: u ? /* @__PURE__ */ t(at, { size: 22 }) : /* @__PURE__ */ t(pt, { size: 22 }) }),
139
- clear: () => /* @__PURE__ */ t("button", { "aria-label": `Clear ${e ?? "input"}`, className: r, "data-testid": "spectral-input-clear-button", onClick: X, type: "button", children: /* @__PURE__ */ t(it, { size: 24 }) }),
140
- loading: () => /* @__PURE__ */ t("div", { className: "text-input-icon absolute top-1/2 right-4 -translate-y-1/2", "data-testid": "spectral-input-loading-icon", children: /* @__PURE__ */ t(nt, { size: 24 }) }),
141
- error: () => /* @__PURE__ */ t("div", { className: "text-danger-400 absolute top-1/2 right-4 -translate-y-1/2", "data-testid": "spectral-input-error-icon", children: /* @__PURE__ */ t(st, { size: 24 }) }),
142
- success: () => /* @__PURE__ */ t("div", { className: "text-success-400 absolute top-1/2 right-4 -translate-y-1/2", "data-testid": "spectral-input-success-icon", children: /* @__PURE__ */ t(ot, { size: 24 }) })
143
- };
144
- return b ? /* @__PURE__ */ t("div", { className: "text-input-icon absolute top-1/2 right-4 -translate-y-1/2", children: b }) : c === "password" ? o.password() : S ? o.clear() : A ? o.loading() : s === "success" ? o.success() : s === "error" ? o.error() : null;
145
- }, Z = () => y || null, _ = h(ut(s, a), "[text-indent:var(--prefix-width)]", S && "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");
146
- return /* @__PURE__ */ f("div", { className: "w-full space-y-1.5", "data-testid": "spectral-input-container", children: [
147
- e && /* @__PURE__ */ t(lt, { className: h("mb-2 block", P, F && "text-input-text--disabled placeholder:text-input-text-placeholder cursor-not-allowed"), "data-testid": "spectral-input-label", htmlFor: m, children: e }),
148
- /* @__PURE__ */ f("div", { className: "relative", "data-testid": "spectral-input-wrapper", children: [
149
- /* @__PURE__ */ f("div", { className: "relative", children: [
150
- Z(),
151
- l && /* @__PURE__ */ t("span", { ref: J, className: q, children: l }),
152
- /* @__PURE__ */ t(
153
- "input",
154
- {
155
- "aria-label": M ?? e,
156
- autoComplete: xt(c),
157
- className: _,
158
- "data-state": s,
159
- "data-testid": "spectral-input",
160
- disabled: F,
161
- id: m,
162
- name: x,
163
- onBlur: K,
164
- onChange: U,
165
- onFocus: Q,
166
- placeholder: R ?? e,
167
- ref: T,
168
- required: v,
169
- style: ft({
170
- "--prefix-width": l ? `${G}px` : "0"
171
- }),
172
- suppressHydrationWarning: L,
173
- type: c === "password" ? D : c,
174
- value: I,
175
- ...H,
176
- ...j
177
- }
178
- ),
179
- Y()
180
- ] }),
181
- B && g && /* @__PURE__ */ t(ht, { dataTestId: "spectral-input-error-message", id: N, message: g })
182
- ] })
183
- ] });
184
- };
185
- Ct.displayName = "Input";
186
- export {
187
- Ct as Input
3
+ import { CheckCircleIcon as e } from "./Icons/CheckCircleIcon.js";
4
+ import { CloseCircleIcon as t } from "./Icons/CloseCircleIcon.js";
5
+ import { ErrorIcon as n } from "./Icons/ErrorIcon.js";
6
+ import { EyeClosedIcon as r } from "./Icons/EyeClosedIcon.js";
7
+ import { EyeOpenIcon as i } from "./Icons/EyeOpenIcon.js";
8
+ import { LoaderIcon as ee } from "./Icons/LoaderIcon.js";
9
+ import { t as a } from "./twUtils-VNWgstKL.js";
10
+ import { ErrorMessage as o, getAriaProps as s, getFormFieldCSSProperties as c, getInputClasses as l, useFormFieldId as u, useFormFieldState as d } from "./utils/formFieldUtils.js";
11
+ import { Label as f } from "./Label.js";
12
+ import { useClearOnFocus as te, usePasswordVisibility as ne, usePrefixWidth as p } from "./Input/InputUtils.js";
13
+ import { useCallback as m, useRef as h } from "react";
14
+ import { jsx as g, jsxs as _ } from "react/jsx-runtime";
15
+ //#region src/components/Input/Input.tsx
16
+ var v = (...e) => (t) => {
17
+ e.forEach((e) => {
18
+ e && (typeof e == "function" ? e(t) : e.current = t);
19
+ });
20
+ }, y = (e) => ({
21
+ date: "off",
22
+ email: "email",
23
+ number: "off",
24
+ password: "current-password",
25
+ tel: "tel",
26
+ text: "off",
27
+ url: "url",
28
+ "datetime-local": "off"
29
+ })[e] || "off", b = ({ className: b, clearOnFocus: x = !1, disabled: S, endIcon: C, errorMessage: w, id: re, label: T, labelClassName: E, name: D, onBlur: O, onChange: k, onFocus: A, placeholder: j, prefix: M, ref: N, required: P, showClearButton: F = !1, startIcon: I, state: L = "default", suppressHydrationWarning: R = !0, type: z = "text", value: B = "", "aria-label": V, "aria-describedby": H, ...U }) => {
30
+ let W = u(re, D), G = `${W}-error`, { isDisabled: K, isLoading: q, isInvalid: J } = d(S, L), Y = s(L, H, P, G), X = h(null), ie = v(N, X), { isVisible: Z, toggleVisibility: ae, inputType: oe } = ne(), { prefixWidth: se, prefixRef: ce } = p(M), { handleFocus: Q } = te(x, k ? (e) => k(e.target.value) : void 0), le = m((e) => {
31
+ O?.(e);
32
+ }, [O]), ue = m((e) => {
33
+ Q(e, A);
34
+ }, [Q, A]), de = m((e) => {
35
+ let t = e.target.value;
36
+ k?.(t);
37
+ }, [k]), fe = m(() => {
38
+ let e = X.current;
39
+ e && (e.value = "", e.dispatchEvent(new Event("input", { bubbles: !0 })), e.focus());
40
+ }, []), $ = F && B.length > 0, pe = () => {
41
+ let a = "absolute right-4 top-1/2 -translate-y-1/2 text-input-icon hover:text-input-icon--hover focus:outline-none cursor-pointer", o = {
42
+ password: () => /* @__PURE__ */ g("button", {
43
+ "aria-controls": W,
44
+ "aria-label": Z ? `Hide ${T ?? "password"}` : `Show ${T ?? "password"}`,
45
+ "aria-pressed": Z,
46
+ className: a,
47
+ "data-testid": "spectral-input-password-toggle",
48
+ onClick: ae,
49
+ type: "button",
50
+ children: g(Z ? r : i, { size: 22 })
51
+ }),
52
+ clear: () => /* @__PURE__ */ g("button", {
53
+ "aria-label": String(`Clear ${T ?? "input"}`),
54
+ className: a,
55
+ "data-testid": "spectral-input-clear-button",
56
+ onClick: fe,
57
+ type: "button",
58
+ children: /* @__PURE__ */ g(t, { size: 24 })
59
+ }),
60
+ loading: () => /* @__PURE__ */ g("div", {
61
+ className: "right-4 text-input-icon absolute top-1/2 -translate-y-1/2",
62
+ "data-testid": "spectral-input-loading-icon",
63
+ children: /* @__PURE__ */ g(ee, { size: 24 })
64
+ }),
65
+ error: () => /* @__PURE__ */ g("div", {
66
+ className: "right-4 absolute top-1/2 -translate-y-1/2 text-danger-400",
67
+ "data-testid": "spectral-input-error-icon",
68
+ children: /* @__PURE__ */ g(n, { size: 24 })
69
+ }),
70
+ success: () => /* @__PURE__ */ g("div", {
71
+ className: "right-4 absolute top-1/2 -translate-y-1/2 text-success-400",
72
+ "data-testid": "spectral-input-success-icon",
73
+ children: /* @__PURE__ */ g(e, { size: 24 })
74
+ })
75
+ };
76
+ return C ? /* @__PURE__ */ g("div", {
77
+ className: "right-4 text-input-icon absolute top-1/2 -translate-y-1/2",
78
+ children: C
79
+ }) : z === "password" ? o.password() : $ ? o.clear() : q ? o.loading() : L === "success" ? o.success() : L === "error" ? o.error() : null;
80
+ }, me = () => I || null, he = a(l(L, b), "[text-indent:var(--prefix-width)]", $ && "pr-10"), ge = a("inset-y-0 left-4 text-base pointer-events-none absolute flex items-center text-input-text-prefix opacity-100 peer-disabled:opacity-50");
81
+ return /* @__PURE__ */ _("div", {
82
+ className: "space-y-1.5 w-full",
83
+ "data-testid": "spectral-input-container",
84
+ children: [T && /* @__PURE__ */ g(f, {
85
+ className: a("mb-2 block", E, K && "cursor-not-allowed text-input-text--disabled placeholder:text-input-text-placeholder"),
86
+ "data-testid": "spectral-input-label",
87
+ htmlFor: W,
88
+ children: T
89
+ }), /* @__PURE__ */ _("div", {
90
+ className: "relative",
91
+ "data-testid": "spectral-input-wrapper",
92
+ children: [/* @__PURE__ */ _("div", {
93
+ className: "relative",
94
+ children: [
95
+ me(),
96
+ M && /* @__PURE__ */ g("span", {
97
+ ref: ce,
98
+ className: ge,
99
+ children: M
100
+ }),
101
+ /* @__PURE__ */ g("input", {
102
+ "aria-label": V ?? T,
103
+ autoComplete: y(z),
104
+ className: he,
105
+ "data-state": L,
106
+ "data-testid": "spectral-input",
107
+ disabled: K,
108
+ id: W,
109
+ name: D,
110
+ onBlur: le,
111
+ onChange: de,
112
+ onFocus: ue,
113
+ placeholder: j ?? T,
114
+ ref: ie,
115
+ required: P,
116
+ style: c({ "--prefix-width": M ? `${se}px` : "0" }),
117
+ suppressHydrationWarning: R,
118
+ type: z === "password" ? oe : z,
119
+ value: B,
120
+ ...Y,
121
+ ...U
122
+ }),
123
+ pe()
124
+ ]
125
+ }), J && w && /* @__PURE__ */ g(o, {
126
+ dataTestId: "spectral-input-error-message",
127
+ id: G,
128
+ message: w
129
+ })]
130
+ })]
131
+ });
188
132
  };
133
+ b.displayName = "Input";
134
+ //#endregion
135
+ export { b as Input };