@spear-ai/spectral 1.9.1 → 1.10.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.
- package/README.md +6 -5
- package/dist/.js +113 -239
- package/dist/Accordion-CDXdSAST.js +363 -0
- package/dist/Accordion.js +3 -498
- package/dist/Alert/AlertBase.js +69 -152
- package/dist/Alert.js +58 -106
- package/dist/AnimatePresence-D-9jXfgI.js +178 -0
- package/dist/App.js +6 -6
- package/dist/Avatar.js +83 -65
- package/dist/Badge.d.ts +1 -3
- package/dist/Badge.js +21 -25
- package/dist/Button.js +102 -178
- package/dist/ButtonGroup/ButtonGroupButton.js +38 -40
- package/dist/ButtonGroup.js +55 -59
- package/dist/ButtonIcon.js +58 -134
- package/dist/Calendar-s4lyijkn.js +3109 -0
- package/dist/Checkbox/CheckboxBase.js +94 -126
- package/dist/Checkbox.d.ts +1 -1
- package/dist/Checkbox.js +40 -105
- package/dist/Combobox/ComboboxBase.js +2 -79
- package/dist/Combobox.js +106 -172
- package/dist/ComboboxBase-D8Nf4xC-.js +491 -0
- package/dist/ControlGroup/ControlGroupSelect.d.ts +1 -1
- package/dist/ControlGroup/ControlGroupSelect.js +85 -101
- package/dist/ControlGroup.js +45 -48
- package/dist/DataCard/Card.js +37 -12
- package/dist/DataCard.d.ts +1 -1
- package/dist/DataCard.js +36 -16
- package/dist/DateTimePicker/Calendar.js +2 -2967
- package/dist/DateTimePicker/DateTimeDisplayInput.d.ts +1 -1
- package/dist/DateTimePicker/DateTimeDisplayInput.js +379 -275
- package/dist/DateTimePicker/DateTimeInput.d.ts +1 -1
- package/dist/DateTimePicker/DateTimeInput.js +133 -141
- package/dist/DateTimePicker/DateTimeUtils.js +2 -2193
- package/dist/DateTimePicker/TimePeriodSelect.d.ts +1 -1
- package/dist/DateTimePicker/TimePeriodSelect.js +45 -20
- package/dist/DateTimePicker/TimePicker.d.ts +1 -1
- package/dist/DateTimePicker/TimePicker.js +76 -60
- package/dist/DateTimePicker.d.ts +2 -2
- package/dist/DateTimePicker.js +87 -205
- package/dist/DateTimeUtils-DVvG6H-p.js +2098 -0
- package/dist/Dialog.js +74 -74
- package/dist/Drawer.js +67 -37
- package/dist/HoverCard-CYDsIiVK.js +201 -0
- package/dist/HoverCard.d.ts +1 -1
- package/dist/HoverCard.js +2 -218
- package/dist/Icons/AnalyzeIcon.js +50 -57
- package/dist/Icons/AnnotationsIcon.js +20 -15
- package/dist/Icons/ApprovedIcon.js +26 -18
- package/dist/Icons/ArrowDownIcon.js +20 -6
- package/dist/Icons/ArrowUpIcon.js +20 -6
- package/dist/Icons/BoxToolIcon.js +17 -12
- package/dist/Icons/CalendarIcon.js +43 -20
- package/dist/Icons/CheckCircleIcon.js +26 -10
- package/dist/Icons/CheckSquareIcon.js +26 -10
- package/dist/Icons/CheckmarkIcon.js +22 -9
- package/dist/Icons/ChevronDownIcon.js +22 -9
- package/dist/Icons/ChevronUpIcon.js +22 -9
- package/dist/Icons/ClockIcon.js +26 -18
- package/dist/Icons/CloseCircleIcon.js +26 -10
- package/dist/Icons/CloseIcon.js +18 -9
- package/dist/Icons/DashboardIcon.js +36 -10
- package/dist/Icons/DatabaseIcon.js +36 -19
- package/dist/Icons/DeleteIcon.js +36 -19
- package/dist/Icons/DurationIcon.js +57 -22
- package/dist/Icons/EditIcon.js +26 -27
- package/dist/Icons/EmailIcon.js +26 -10
- package/dist/Icons/EraserIcon.js +41 -25
- package/dist/Icons/ErrorIcon.js +27 -11
- package/dist/Icons/EyeClosedIcon.js +29 -13
- package/dist/Icons/EyeClosedIcon2.js +27 -11
- package/dist/Icons/EyeOpenIcon.js +22 -9
- package/dist/Icons/FileDownloadIcon.js +43 -20
- package/dist/Icons/GoToFirstIcon.js +26 -9
- package/dist/Icons/GoToLastIcon.js +26 -9
- package/dist/Icons/HarmonicCursorsIcon.js +23 -9
- package/dist/Icons/IconBase.d.ts +3 -3
- package/dist/Icons/IconBase.js +49 -66
- package/dist/Icons/InfoIcon.js +36 -10
- package/dist/Icons/KeyboardIcon.js +26 -27
- package/dist/Icons/LabelIcon.js +19 -14
- package/dist/Icons/LassoIcon.js +36 -28
- package/dist/Icons/LineToolIcon.js +48 -39
- package/dist/Icons/LiveViewIcon.js +50 -12
- package/dist/Icons/LoaderIcon.js +67 -27
- package/dist/Icons/LocationIcon.js +26 -27
- package/dist/Icons/LogoutIcon.js +20 -15
- package/dist/Icons/MeasureIcon.js +78 -25
- package/dist/Icons/MessagesIcon.js +33 -18
- package/dist/Icons/MetadataIcon.js +20 -15
- package/dist/Icons/MinusIcon.d.ts +1 -1
- package/dist/Icons/MinusIcon.js +18 -6
- package/dist/Icons/OntologyIcon.js +87 -71
- package/dist/Icons/PanelIconClose.js +28 -10
- package/dist/Icons/PanelIconOpen.js +28 -10
- package/dist/Icons/PlayIcon.js +20 -6
- package/dist/Icons/PlusIcon.js +20 -14
- package/dist/Icons/PolygonIcon.js +50 -39
- package/dist/Icons/ProgressCheckIcon.d.ts +5 -0
- package/dist/Icons/ProgressCheckIcon.js +58 -0
- package/dist/Icons/ResetIcon.js +17 -12
- package/dist/Icons/ReviewedIcon.js +36 -19
- package/dist/Icons/ScissorsIcon.js +22 -17
- package/dist/Icons/SearchIcon.js +26 -9
- package/dist/Icons/SettingsIcon.js +26 -27
- package/dist/Icons/SortAscendingIcon.js +50 -12
- package/dist/Icons/SortAtoZIcon.js +50 -12
- package/dist/Icons/SortDescendingIcon.js +50 -12
- package/dist/Icons/SortZtoAIcon.js +50 -12
- package/dist/Icons/StackIcon.js +26 -9
- package/dist/Icons/StarIcon.js +20 -6
- package/dist/Icons/TrashIcon.js +17 -12
- package/dist/Icons/UndoIcon.js +20 -15
- package/dist/Icons/User2Icon.js +26 -10
- package/dist/Icons/UserIcon.js +19 -14
- package/dist/Icons/WarningIcon.js +19 -14
- package/dist/Icons/ZoomAllIcon.js +71 -15
- package/dist/Icons/ZoomXIcon.js +36 -10
- package/dist/Icons/ZoomYIcon.js +36 -10
- package/dist/Icons/index.d.ts +1 -0
- package/dist/Icons.js +68 -136
- package/dist/IconsAnimated/PanelLeftCloseIcon.js +66 -36
- package/dist/IconsAnimated/PanelLeftOpenIcon.js +66 -36
- package/dist/IconsAnimated.js +3 -6
- package/dist/Input/InputUtils.js +51 -52
- package/dist/Input.js +132 -185
- package/dist/InputNumeric.d.ts +14 -0
- package/dist/InputNumeric.js +137 -0
- package/dist/InputOTP-cVn5Bzyp.js +461 -0
- package/dist/InputOTP.js +2 -382
- package/dist/Kbd.d.ts +1 -1
- package/dist/Kbd.js +182 -86
- package/dist/Label.js +12 -14
- package/dist/MultiSelect/MultiSelectBase.js +331 -403
- package/dist/MultiSelect.d.ts +1 -1
- package/dist/MultiSelect.js +23 -23
- package/dist/Popover.js +28 -32
- package/dist/RadioButton.d.ts +17 -0
- package/dist/RadioButton.js +33 -0
- package/dist/RadioButtonGroup/RadioButtonGroupBase.d.ts +3 -1
- package/dist/RadioButtonGroup/RadioButtonGroupBase.js +49 -46
- package/dist/RadioButtonGroup.d.ts +1 -1
- package/dist/RadioButtonGroup.js +11 -8
- package/dist/RadioGroup-w_q6RGEK.js +447 -0
- package/dist/RadioGroup.js +2 -505
- package/dist/Select.js +163 -186
- package/dist/Separator.js +16 -19
- package/dist/Skeleton.js +10 -6
- package/dist/Slider-BzzZT3Zm.js +490 -0
- package/dist/Slider.js +2 -562
- package/dist/SpectralProvider.js +8 -5
- package/dist/Switch/SwitchBase.js +91 -95
- package/dist/Switch-CVzRJ-0n.js +126 -0
- package/dist/Switch.d.ts +1 -1
- package/dist/Switch.js +2 -134
- package/dist/Tabs/TabsBase.js +242 -250
- package/dist/Tabs/tabsUtils.js +65 -73
- package/dist/Tabs.d.ts +1 -1
- package/dist/Tabs.js +73 -103
- package/dist/Textarea/TextareaUtils.js +35 -46
- package/dist/Textarea.js +83 -160
- package/dist/Toast-9zqXxKKO.js +711 -0
- package/dist/Toast.js +2 -885
- package/dist/Toggle/ToggleBase.js +46 -56
- package/dist/Toggle.d.ts +1 -1
- package/dist/Toggle.js +52 -62
- package/dist/ToggleGroup/ToggleGroupBase.js +128 -104
- package/dist/ToggleGroup.d.ts +1 -1
- package/dist/ToggleGroup.js +52 -63
- package/dist/Tooltip-D1K8kY1y.js +389 -0
- package/dist/Tooltip.js +2 -365
- package/dist/Tray.js +174 -217
- package/dist/chunk-h9knIhTc.js +20 -0
- package/dist/clsx-jM1GlMvB.js +16 -0
- package/dist/dist-3Af8168y.js +913 -0
- package/dist/dist-7HRQ5IKN.js +249 -0
- package/dist/dist-B2k1iWFp.js +129 -0
- package/dist/dist-B4FgboI8.js +122 -0
- package/dist/dist-B4g6zpUF.js +33 -0
- package/dist/dist-B9tup-4O.js +216 -0
- package/dist/dist-BK1K0g9W.js +29 -0
- package/dist/dist-Bfjk-jx9.js +28 -0
- package/dist/dist-Bft31cJh.js +65 -0
- package/dist/dist-BtdmHAzK.js +190 -0
- package/dist/dist-C0Hifjgh.js +1287 -0
- package/dist/dist-CGzgmYB9.js +68 -0
- package/dist/dist-ClmepHp4.js +10 -0
- package/dist/dist-D8Wb_MX9.js +6 -0
- package/dist/dist-Dtvmk11N.js +12 -0
- package/dist/dist-fW81qjVl.js +677 -0
- package/dist/dist-s1uWaZYZ.js +11 -0
- package/dist/es2015-YHaMV-St.js +701 -0
- package/dist/hooks/useAccordionAutoScroll.js +66 -67
- package/dist/hooks/useControllableState.js +14 -13
- package/dist/hooks/useConvertToOklch.d.ts +3 -0
- package/dist/hooks/useConvertToOklch.d.ts.map +1 -0
- package/dist/hooks/useConvertToOklch.js +51 -0
- package/dist/hooks/useTheme.js +21 -17
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/main.js +18954 -27224
- package/dist/primitives/button.js +39 -41
- package/dist/primitives/input-group.js +57 -73
- package/dist/primitives/input.js +11 -20
- package/dist/primitives/popover.js +34 -28
- package/dist/primitives/select.js +70 -138
- package/dist/primitives/slot.js +32 -31
- package/dist/primitives/textarea.js +10 -16
- package/dist/proxy-Dn10Pl_g.js +4920 -0
- package/dist/styles/main.css +2 -1
- package/dist/styles/spectral.css +1 -1
- package/dist/twUtils-VNWgstKL.js +1673 -0
- package/dist/use-animation-CBUDycyW.js +57 -0
- package/dist/utils/constants.js +4 -4
- package/dist/utils/formFieldUtils.js +136 -148
- package/dist/utils/sharedUtils.js +26 -7
- package/dist/utils/twUtils.js +2 -2919
- package/package.json +24 -28
- package/dist/ComboboxBase-CxNxYtdT.js +0 -408
- package/dist/clsx-OuTLNxxd.js +0 -16
- package/dist/index-0ioNhtNM.js +0 -10
- package/dist/index-6oYKCvIn.js +0 -677
- package/dist/index-BFOf48AQ.js +0 -69
- package/dist/index-BZPx6jYI.js +0 -8
- package/dist/index-BlHU_t18.js +0 -142
- package/dist/index-Bm1RbF6w.js +0 -1037
- package/dist/index-Bv2OIg5P.js +0 -225
- package/dist/index-CKEI0pDv.js +0 -56
- package/dist/index-CM_hWgfC.js +0 -32
- package/dist/index-C_YVr64u.js +0 -1538
- package/dist/index-Cl8VeY0o.js +0 -149
- package/dist/index-CwSyIPrv.js +0 -13
- package/dist/index-D29mdTf5.js +0 -34
- package/dist/index-DEYs15GP.js +0 -66
- package/dist/index-Dc0No4pV.js +0 -233
- package/dist/index-T6XEa11q.js +0 -822
- package/dist/index-pBCLb6Gr.js +0 -240
- package/dist/index-psiVrsnE.js +0 -27
- package/dist/index-rKs9bXHr.js +0 -6
- package/dist/proxy-CO_-Vget.js +0 -4975
- package/dist/use-animation-DhEPRwZ3.js +0 -62
package/dist/Input.js
CHANGED
|
@@ -1,188 +1,135 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "./styles/main.css";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import "./Icons/
|
|
6
|
-
import "./Icons/
|
|
7
|
-
import "./Icons/
|
|
8
|
-
import "./Icons/
|
|
9
|
-
import "./
|
|
10
|
-
import "./
|
|
11
|
-
import "./
|
|
12
|
-
import {
|
|
13
|
-
import "
|
|
14
|
-
import "
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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 a } from "./Icons/LoaderIcon.js";
|
|
9
|
+
import { t as o } from "./twUtils-VNWgstKL.js";
|
|
10
|
+
import { ErrorMessage as s, getAriaProps as c, getFormFieldCSSProperties as l, getInputClasses as u, useFormFieldId as d, useFormFieldState as f } from "./utils/formFieldUtils.js";
|
|
11
|
+
import { Label as ee } from "./Label.js";
|
|
12
|
+
import { useClearOnFocus as te, usePasswordVisibility as p, usePrefixWidth as m } from "./Input/InputUtils.js";
|
|
13
|
+
import { useCallback as h, useRef as g } from "react";
|
|
14
|
+
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
15
|
+
//#region src/components/Input/Input.tsx
|
|
16
|
+
var y = (...e) => (t) => {
|
|
17
|
+
e.forEach((e) => {
|
|
18
|
+
e && (typeof e == "function" ? e(t) : e.current = t);
|
|
19
|
+
});
|
|
20
|
+
}, ne = (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 = d(re, D), G = `${W}-error`, { isDisabled: K, isLoading: q, isInvalid: J } = f(S, L), Y = c(L, H, P, G), X = g(null), ie = y(N, X), { isVisible: Z, toggleVisibility: ae, inputType: oe } = p(), { prefixWidth: se, prefixRef: ce } = m(M), { handleFocus: Q } = te(x, k ? (e) => k(e.target.value) : void 0), le = h((e) => {
|
|
31
|
+
O?.(e);
|
|
32
|
+
}, [O]), ue = h((e) => {
|
|
33
|
+
Q(e, A);
|
|
34
|
+
}, [Q, A]), de = h((e) => {
|
|
35
|
+
let t = e.target.value;
|
|
36
|
+
k?.(t);
|
|
37
|
+
}, [k]), fe = h(() => {
|
|
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 o = "absolute right-4 top-1/2 -translate-y-1/2 text-input-icon hover:text-input-icon--hover focus:outline-none cursor-pointer", s = {
|
|
42
|
+
password: () => /* @__PURE__ */ _("button", {
|
|
43
|
+
"aria-controls": W,
|
|
44
|
+
"aria-label": Z ? `Hide ${T ?? "password"}` : `Show ${T ?? "password"}`,
|
|
45
|
+
"aria-pressed": Z,
|
|
46
|
+
className: o,
|
|
47
|
+
"data-testid": "spectral-input-password-toggle",
|
|
48
|
+
onClick: ae,
|
|
49
|
+
type: "button",
|
|
50
|
+
children: _(Z ? r : i, { size: 22 })
|
|
51
|
+
}),
|
|
52
|
+
clear: () => /* @__PURE__ */ _("button", {
|
|
53
|
+
"aria-label": String(`Clear ${T ?? "input"}`),
|
|
54
|
+
className: o,
|
|
55
|
+
"data-testid": "spectral-input-clear-button",
|
|
56
|
+
onClick: fe,
|
|
57
|
+
type: "button",
|
|
58
|
+
children: /* @__PURE__ */ _(t, { size: 24 })
|
|
59
|
+
}),
|
|
60
|
+
loading: () => /* @__PURE__ */ _("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__ */ _(a, { size: 24 })
|
|
64
|
+
}),
|
|
65
|
+
error: () => /* @__PURE__ */ _("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__ */ _(n, { size: 24 })
|
|
69
|
+
}),
|
|
70
|
+
success: () => /* @__PURE__ */ _("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__ */ _(e, { size: 24 })
|
|
74
|
+
})
|
|
75
|
+
};
|
|
76
|
+
return C ? /* @__PURE__ */ _("div", {
|
|
77
|
+
className: "right-4 text-input-icon absolute top-1/2 -translate-y-1/2",
|
|
78
|
+
children: C
|
|
79
|
+
}) : z === "password" ? s.password() : $ ? s.clear() : q ? s.loading() : L === "success" ? s.success() : L === "error" ? s.error() : null;
|
|
80
|
+
}, me = () => I || null, he = z === "number" || z === "date" || z === "datetime-local", ge = o(u(L, b), "[text-indent:var(--prefix-width)]", $ && "pr-10", he && "tabular-nums"), _e = o("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__ */ v("div", {
|
|
82
|
+
className: "space-y-1.5 w-full",
|
|
83
|
+
"data-testid": "spectral-input-container",
|
|
84
|
+
children: [T && /* @__PURE__ */ _(ee, {
|
|
85
|
+
className: o("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__ */ v("div", {
|
|
90
|
+
className: "relative",
|
|
91
|
+
"data-testid": "spectral-input-wrapper",
|
|
92
|
+
children: [/* @__PURE__ */ v("div", {
|
|
93
|
+
className: "relative",
|
|
94
|
+
children: [
|
|
95
|
+
me(),
|
|
96
|
+
M && /* @__PURE__ */ _("span", {
|
|
97
|
+
ref: ce,
|
|
98
|
+
className: _e,
|
|
99
|
+
children: M
|
|
100
|
+
}),
|
|
101
|
+
/* @__PURE__ */ _("input", {
|
|
102
|
+
"aria-label": V ?? T,
|
|
103
|
+
autoComplete: ne(z),
|
|
104
|
+
className: ge,
|
|
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: l({ "--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__ */ _(s, {
|
|
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 };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { InputProps } from '../Input/Input';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
export type InputNumericProps = Omit<InputProps, 'inputMode' | 'onChange' | 'pattern' | 'type'> & {
|
|
4
|
+
allowDecimal?: boolean;
|
|
5
|
+
allowNegative?: boolean;
|
|
6
|
+
locale?: string;
|
|
7
|
+
onChange?: (value: string) => void;
|
|
8
|
+
value?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const InputNumeric: {
|
|
11
|
+
({ allowDecimal, allowNegative, className, locale, max, min, onChange, onKeyDown, onPaste, step, value, ...props }: InputNumericProps): ReactElement;
|
|
12
|
+
displayName: string;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=InputNumeric.d.ts.map
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "./styles/main.css";
|
|
3
|
+
import { t as e } from "./twUtils-VNWgstKL.js";
|
|
4
|
+
import { Input as t } from "./Input.js";
|
|
5
|
+
import { useCallback as n } from "react";
|
|
6
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/InputNumeric/InputNumeric.tsx
|
|
8
|
+
var i = /^\d$/, a = new Set([
|
|
9
|
+
"e",
|
|
10
|
+
"E",
|
|
11
|
+
"+"
|
|
12
|
+
]), o = new Set([
|
|
13
|
+
"Backspace",
|
|
14
|
+
"Delete",
|
|
15
|
+
"ArrowLeft",
|
|
16
|
+
"ArrowRight",
|
|
17
|
+
"ArrowUp",
|
|
18
|
+
"ArrowDown",
|
|
19
|
+
"Home",
|
|
20
|
+
"End",
|
|
21
|
+
"Tab",
|
|
22
|
+
"Enter",
|
|
23
|
+
"Escape"
|
|
24
|
+
]), s = (e) => {
|
|
25
|
+
try {
|
|
26
|
+
return new Intl.NumberFormat(e).formatToParts(1.1).find((e) => e.type === "decimal")?.value ?? ".";
|
|
27
|
+
} catch {
|
|
28
|
+
return ".";
|
|
29
|
+
}
|
|
30
|
+
}, c = (e, t) => t === "." ? e : e.replaceAll(t, "."), l = (e, t, n, r) => {
|
|
31
|
+
if (!e) return "";
|
|
32
|
+
let i = c(e, r).replace(/[^\d.-]/g, "");
|
|
33
|
+
if (n ? (i = i.replace(/(?!^)-/g, ""), i.startsWith("--") && (i = `-${i.replace(/-/g, "")}`)) : i = i.replace(/-/g, ""), !t) i = i.replace(/\./g, "");
|
|
34
|
+
else {
|
|
35
|
+
let e = i.indexOf(".");
|
|
36
|
+
e >= 0 && (i = `${i.slice(0, e + 1)}${i.slice(e + 1).replace(/\./g, "")}`);
|
|
37
|
+
}
|
|
38
|
+
return i;
|
|
39
|
+
}, u = (e) => {
|
|
40
|
+
if (e.selectionStart === null || e.selectionEnd === null) return !e.value.includes(".");
|
|
41
|
+
let t = e.value.slice(e.selectionStart, e.selectionEnd);
|
|
42
|
+
return !e.value.includes(".") || t.includes(".");
|
|
43
|
+
}, d = (e) => {
|
|
44
|
+
if (e.selectionStart === null || e.selectionEnd === null) return e.value.length === 0;
|
|
45
|
+
let t = e.selectionStart === 0, n = e.value.slice(e.selectionStart, e.selectionEnd);
|
|
46
|
+
return t && (!e.value.includes("-") || n.includes("-"));
|
|
47
|
+
}, f = (e) => {
|
|
48
|
+
if (e == null || e === "") return;
|
|
49
|
+
let t = typeof e == "number" ? e : Number.parseFloat(e);
|
|
50
|
+
return Number.isFinite(t) ? t : void 0;
|
|
51
|
+
}, p = (e) => {
|
|
52
|
+
let t = e.toString();
|
|
53
|
+
return t.includes(".") ? t.split(".")[1]?.length ?? 0 : 0;
|
|
54
|
+
}, m = (e, t) => {
|
|
55
|
+
if (t <= 0) return e;
|
|
56
|
+
let n = 10 ** t;
|
|
57
|
+
return Math.round(e * n) / n;
|
|
58
|
+
}, h = ({ allowDecimal: h = !0, allowNegative: g = !1, className: _, locale: v, max: y, min: b, onChange: x, onKeyDown: S, onPaste: C, step: w, value: T = "", ...E }) => {
|
|
59
|
+
let D = s(v), O = f(b), k = f(y), A = f(w), j = A && A > 0 ? A : 1, M = O ?? (g ? void 0 : 0), N = n((e) => {
|
|
60
|
+
if (S?.(e), !(e.defaultPrevented || e.nativeEvent.isComposing) && !(e.metaKey || e.ctrlKey || e.altKey)) {
|
|
61
|
+
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
let t = e.key === "ArrowUp" ? 1 : -1, n = c(T, D), r = Number.parseFloat(n), i = (Number.isFinite(r) ? r : M ?? 0) + t * j;
|
|
64
|
+
M !== void 0 && (i = Math.max(M, i)), k !== void 0 && (i = Math.min(k, i)), h || (i = Math.trunc(i));
|
|
65
|
+
let a = h ? p(j) : 0, o = m(i, a), s = Object.is(o, -0) ? 0 : o, u = a > 0 ? s.toFixed(a).replace(/\.?0+$/, "") : s.toString();
|
|
66
|
+
x?.(l(u, h, g, D));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (!o.has(e.key) && !i.test(e.key)) {
|
|
70
|
+
if (a.has(e.key)) {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (e.key === "." || e.key === D) {
|
|
75
|
+
(!h || !u(e.currentTarget)) && e.preventDefault();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (e.key === "-") {
|
|
79
|
+
(!g || !d(e.currentTarget)) && e.preventDefault();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}, [
|
|
86
|
+
h,
|
|
87
|
+
g,
|
|
88
|
+
D,
|
|
89
|
+
M,
|
|
90
|
+
x,
|
|
91
|
+
S,
|
|
92
|
+
k,
|
|
93
|
+
j,
|
|
94
|
+
T
|
|
95
|
+
]), P = n((e) => {
|
|
96
|
+
if (C?.(e), e.defaultPrevented) return;
|
|
97
|
+
let t = e.clipboardData.getData("text"), n = l(t, h, g, D);
|
|
98
|
+
if (c(t, D) === n) return;
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
let r = e.currentTarget, i = r.selectionStart ?? r.value.length, a = r.selectionEnd ?? r.value.length, o = l(`${r.value.slice(0, i)}${n}${r.value.slice(a)}`, h, g, D);
|
|
101
|
+
x?.(o);
|
|
102
|
+
}, [
|
|
103
|
+
h,
|
|
104
|
+
g,
|
|
105
|
+
D,
|
|
106
|
+
x,
|
|
107
|
+
C
|
|
108
|
+
]), F = n((e) => {
|
|
109
|
+
x?.(l(e, h, g, D));
|
|
110
|
+
}, [
|
|
111
|
+
h,
|
|
112
|
+
g,
|
|
113
|
+
D,
|
|
114
|
+
x
|
|
115
|
+
]), I = h ? "decimal" : "numeric", L = h ? "[0-9]*[.]?[0-9]*" : "[0-9]*", R = c(T, D), z = R === "" || R === "-" || R === "." ? void 0 : Number.parseFloat(R);
|
|
116
|
+
return /* @__PURE__ */ r(t, {
|
|
117
|
+
...E,
|
|
118
|
+
"aria-valuemax": k,
|
|
119
|
+
"aria-valuemin": M,
|
|
120
|
+
"aria-valuenow": Number.isFinite(z) ? z : void 0,
|
|
121
|
+
className: e("tabular-nums", _),
|
|
122
|
+
inputMode: I,
|
|
123
|
+
max: y,
|
|
124
|
+
min: b,
|
|
125
|
+
onChange: F,
|
|
126
|
+
onKeyDown: N,
|
|
127
|
+
onPaste: P,
|
|
128
|
+
pattern: L,
|
|
129
|
+
role: "spinbutton",
|
|
130
|
+
step: w,
|
|
131
|
+
type: "text",
|
|
132
|
+
value: T
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
h.displayName = "InputNumeric";
|
|
136
|
+
//#endregion
|
|
137
|
+
export { h as InputNumeric };
|