@spear-ai/spectral 1.10.0 → 1.10.2
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/dist/.js +19 -18
- package/dist/ControlGroup/ControlGroupSelect.js +87 -64
- package/dist/ControlGroup.js +29 -29
- package/dist/DataCard.js +1 -1
- package/dist/Input.js +41 -41
- package/dist/InputNumeric.d.ts +14 -0
- package/dist/InputNumeric.js +137 -0
- package/dist/{InputOTP-XUWW9xcI.js → InputOTP-cVn5Bzyp.js} +1 -1
- package/dist/InputOTP.js +1 -1
- 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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/styles/horizon/colors.css +2 -2
- package/dist/styles/main.css +1 -1
- package/dist/styles/spectral.css +1 -1
- package/dist/styles/theme.css +2 -2
- package/package.json +2 -2
package/dist/.js
CHANGED
|
@@ -92,21 +92,22 @@ import { SpectralProvider as Ke } from "./SpectralProvider.js";
|
|
|
92
92
|
import { Drawer as qe } from "./Drawer.js";
|
|
93
93
|
import { n as Je, r as Ye, t as Xe } from "./HoverCard-CYDsIiVK.js";
|
|
94
94
|
import { Input as Ze } from "./Input.js";
|
|
95
|
-
import {
|
|
96
|
-
import {
|
|
97
|
-
import {
|
|
98
|
-
import {
|
|
99
|
-
import {
|
|
100
|
-
import {
|
|
101
|
-
import {
|
|
102
|
-
import {
|
|
103
|
-
import {
|
|
104
|
-
import { t as ut } from "./
|
|
105
|
-
import {
|
|
106
|
-
import {
|
|
107
|
-
import {
|
|
108
|
-
import {
|
|
109
|
-
import {
|
|
110
|
-
import {
|
|
111
|
-
import {
|
|
112
|
-
|
|
95
|
+
import { InputNumeric as Qe } from "./InputNumeric.js";
|
|
96
|
+
import { t as $e } from "./InputOTP-cVn5Bzyp.js";
|
|
97
|
+
import { Kbd as et, KbdGroup as tt } from "./Kbd.js";
|
|
98
|
+
import { MultiSelect as nt } from "./MultiSelect.js";
|
|
99
|
+
import { RadioButtonGroup as rt, RadioButtonGroupItem as it } from "./RadioButtonGroup.js";
|
|
100
|
+
import { RadioButton as at } from "./RadioButton.js";
|
|
101
|
+
import { n as ot, t as st } from "./RadioGroup-w_q6RGEK.js";
|
|
102
|
+
import { Select as ct } from "./Select.js";
|
|
103
|
+
import { Skeleton as lt } from "./Skeleton.js";
|
|
104
|
+
import { t as ut } from "./Slider-BzzZT3Zm.js";
|
|
105
|
+
import { t as dt } from "./Switch-CVzRJ-0n.js";
|
|
106
|
+
import { Tabs as ft } from "./Tabs.js";
|
|
107
|
+
import { Textarea as pt } from "./Textarea.js";
|
|
108
|
+
import { n as mt, t as ht } from "./Toast-9zqXxKKO.js";
|
|
109
|
+
import { Toggle as gt } from "./Toggle.js";
|
|
110
|
+
import { ToggleGroup as _t, ToggleGroupItem as vt } from "./ToggleGroup.js";
|
|
111
|
+
import { i as yt, n as bt, t as xt } from "./Tooltip-D1K8kY1y.js";
|
|
112
|
+
import { Tray as St } from "./Tray.js";
|
|
113
|
+
export { ve as Accordion, be as Alert, n as AnalyzeIcon, r as AnnotationsIcon, i as ApprovedIcon, a as ArrowDownIcon, o as ArrowUpIcon, xe as Avatar, Se as Badge, s as BoxToolIcon, Ce as Button, Te as ButtonGroup, Ee as ButtonGroupItem, De as ButtonGroupSeparator, Oe as ButtonIcon, c as CalendarIcon, l as CheckCircleIcon, u as CheckSquareIcon, Ae as Checkbox, d as CheckmarkIcon, f as ChevronDownIcon, p as ChevronUpIcon, m as ClockIcon, h as CloseCircleIcon, g as CloseIcon, Re as Combobox, ze as ControlGroupSelect, _ as DashboardIcon, Be as DataCard, v as DatabaseIcon, We as DateTimePicker, y as DeleteIcon, Ge as Dialog, qe as Drawer, b as DurationIcon, x as EditIcon, S as EmailIcon, C as EraserIcon, w as ErrorIcon, T as EyeClosedIcon, E as EyeClosedIcon2, D as EyeOpenIcon, O as FileDownloadIcon, k as GoToFirstIcon, A as GoToLastIcon, j as HarmonicCursorsIcon, Xe as HoverCard, Je as HoverCardContent, Ye as HoverCardTrigger, e as IconBase, M as InfoIcon, Ze as Input, Me as InputGroup, Ne as InputGroupAddon, Pe as InputGroupButton, Fe as InputGroupInput, Ie as InputGroupText, Le as InputGroupTextarea, Qe as InputNumeric, $e as InputOTP, et as Kbd, tt as KbdGroup, N as KeyboardIcon, je as Label, P as LabelIcon, F as LassoIcon, I as LineToolIcon, L as LiveViewIcon, R as LoaderIcon, z as LocationIcon, B as LogoutIcon, V as MeasureIcon, H as MessagesIcon, U as MetadataIcon, W as MinusIcon, nt as MultiSelect, G as OntologyIcon, K as PanelIconClose, q as PanelIconOpen, J as PlayIcon, Y as PlusIcon, X as PolygonIcon, Ve as Popover, He as PopoverContent, Ue as PopoverTrigger, Z as ProgressCheckIcon, at as RadioButton, rt as RadioButtonGroup, it as RadioButtonGroupItem, st as RadioGroup, ot as RadioGroupItem, Q as ResetIcon, $ as ReviewedIcon, ee as ScissorsIcon, te as SearchIcon, ct as Select, we as Separator, ne as SettingsIcon, lt as Skeleton, ut as Slider, re as SortAscendingIcon, ie as SortAtoZIcon, ae as SortDescendingIcon, oe as SortZtoAIcon, Ke as SpectralProvider, se as StackIcon, ce as StarIcon, t as SvgIdContext, dt as Switch, ft as Tabs, pt as Textarea, ht as Toast, gt as Toggle, _t as ToggleGroup, vt as ToggleGroupItem, xt as Tooltip, bt as TooltipContent, yt as TooltipTrigger, le as TrashIcon, St as Tray, ue as UndoIcon, de as User2Icon, fe as UserIcon, pe as WarningIcon, me as ZoomAllIcon, he as ZoomXIcon, ge as ZoomYIcon, ye as cn, mt as toast, _e as useAccordionAutoScroll, ke as useControllableState };
|
|
@@ -1,88 +1,111 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../styles/main.css";
|
|
3
3
|
import { t as e } from "../twUtils-VNWgstKL.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
4
|
+
import { getStateClasses as t } from "../utils/formFieldUtils.js";
|
|
5
|
+
import { Label as n } from "../Label.js";
|
|
6
|
+
import { Input as r } from "../primitives/input.js";
|
|
7
|
+
import { Select as i, SelectContent as a, SelectItem as o, SelectTrigger as s, SelectValue as c } from "../primitives/select.js";
|
|
8
|
+
import { ControlGroup as l, ControlGroupItem as u, useControlGroup as d } from "../ControlGroup.js";
|
|
9
|
+
import { useId as f } from "react";
|
|
10
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
10
11
|
//#region src/components/ControlGroup/ControlGroupSelect.tsx
|
|
11
|
-
var
|
|
12
|
-
let
|
|
13
|
-
return
|
|
14
|
-
|
|
12
|
+
var g = "placeholder:text-small! [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none", _ = "Amount", v = "Select an option", y = "flex w-full min-w-0 flex-col gap-1.5", b = "!h-12 min-h-12 !border-2 border-input-border bg-input-bg text-base text-input-text transition duration-200 placeholder:text-input-text-placeholder hover:border-input-border--hover focus:border-input-border--focus focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-input-border--focus disabled:pointer-events-none disabled:border-input-border--disabled disabled:bg-input-bg--disabled disabled:text-input-text--disabled", x = (e, t = 0) => {
|
|
13
|
+
let n = e?.trim();
|
|
14
|
+
if (n) return `${Math.max(n.length + t, 8)}ch`;
|
|
15
|
+
}, S = (e, t) => {
|
|
16
|
+
let n = e?.trim();
|
|
17
|
+
return n && n.length > 0 ? n : t;
|
|
18
|
+
}, C = ({ amountStep: e, ariaLabel: t, captionLayout: n = "inline", className: r, dataTestId: i = "spectral-control-group-select", disabled: a, errorMessage: o, inputAriaLabel: s, inputPlaceholder: c, maxAmount: u = 1e6, minAmount: d = 0, orientation: p = "horizontal", selectAriaLabel: h, selectOptions: g, selectPlaceholder: y, state: b = "default", type: C = "number", ...T }) => {
|
|
19
|
+
let E = f(), D = `${E}-amount`, O = `${E}-select`, k = `${D}-label`, A = `${O}-label`, j = n === "above", M = j ? void 0 : c, N = j ? void 0 : y, P = S(c, _), F = S(y, v), I = s ?? (j ? void 0 : P), L = h ?? (j ? void 0 : F), R = x(c, 3), z = x(y, 5), B = t ?? `${P} and ${F}`, V = !!a || b === "disabled";
|
|
20
|
+
return /* @__PURE__ */ m(l, {
|
|
21
|
+
"aria-label": B,
|
|
15
22
|
className: r,
|
|
16
23
|
"data-testid": i,
|
|
17
24
|
disabled: a,
|
|
18
25
|
errorMessage: o,
|
|
19
|
-
orientation:
|
|
20
|
-
state:
|
|
21
|
-
children: /* @__PURE__ */
|
|
26
|
+
orientation: p,
|
|
27
|
+
state: b,
|
|
28
|
+
children: /* @__PURE__ */ m(w, {
|
|
22
29
|
amountStep: e,
|
|
23
30
|
dataTestId: i,
|
|
24
|
-
inputAccessibleName:
|
|
25
|
-
inputCaption:
|
|
26
|
-
inputId:
|
|
27
|
-
|
|
31
|
+
inputAccessibleName: I,
|
|
32
|
+
inputCaption: M,
|
|
33
|
+
inputId: D,
|
|
34
|
+
inputLabelId: k,
|
|
35
|
+
inputLabelText: P,
|
|
36
|
+
inputMinWidth: R,
|
|
37
|
+
isDisabled: V,
|
|
28
38
|
maxAmount: u,
|
|
29
|
-
minAmount:
|
|
30
|
-
selectCaption:
|
|
39
|
+
minAmount: d,
|
|
40
|
+
selectCaption: N,
|
|
31
41
|
selectOptions: g,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
selectLabelId: A,
|
|
43
|
+
selectLabelText: F,
|
|
44
|
+
selectProps: T,
|
|
45
|
+
selectTriggerAriaLabel: L,
|
|
46
|
+
selectTriggerId: O,
|
|
47
|
+
selectTriggerMinWidth: z,
|
|
48
|
+
type: C,
|
|
49
|
+
useAboveLabels: j
|
|
39
50
|
})
|
|
40
51
|
});
|
|
41
|
-
},
|
|
42
|
-
let { errorMessageId:
|
|
43
|
-
"aria-describedby":
|
|
52
|
+
}, w = ({ amountStep: l, dataTestId: f, inputAccessibleName: _, inputCaption: v, inputId: x, inputLabelId: S, inputLabelText: C, inputMinWidth: w, isDisabled: T, maxAmount: E, minAmount: D, selectCaption: O, selectLabelId: k, selectLabelText: A, selectOptions: j, selectProps: M, selectTriggerAriaLabel: N, selectTriggerId: P, selectTriggerMinWidth: F, type: I, useAboveLabels: L }) => {
|
|
53
|
+
let { errorMessageId: R, orientation: z, state: B } = d(), V = z === "horizontal" ? "rounded-s-md rounded-e-none" : "rounded-ss-md rounded-se-md rounded-es-none rounded-ee-none", H = z === "horizontal" ? "rounded-s-none rounded-e-md" : "rounded-ss-none rounded-se-none rounded-es-md rounded-ee-md", U = z === "horizontal" ? "me-0" : "mbe-0", W = z === "horizontal" ? "me-0 [&>*:last-child]:-ms-0.5" : "mbe-0 [&>*:last-child]:-mt-0.5", G = /* @__PURE__ */ m(r, {
|
|
54
|
+
"aria-describedby": R,
|
|
44
55
|
"aria-label": _,
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
56
|
+
"aria-labelledby": L ? S : void 0,
|
|
57
|
+
className: e(b, V, t(B), I === "number" && g, I === "number" && "tabular-nums"),
|
|
58
|
+
"data-testid": `${f}-input`,
|
|
59
|
+
disabled: T,
|
|
60
|
+
id: L ? x : void 0,
|
|
61
|
+
type: I === "number" ? "number" : "text",
|
|
50
62
|
placeholder: v,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"aria-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
style: w ? { minWidth: w } : void 0,
|
|
64
|
+
min: D ?? 0,
|
|
65
|
+
max: E ?? 1e6,
|
|
66
|
+
step: l ?? 1
|
|
67
|
+
}), K = /* @__PURE__ */ m(s, {
|
|
68
|
+
"aria-describedby": R,
|
|
69
|
+
"aria-label": N,
|
|
70
|
+
"aria-labelledby": L ? k : void 0,
|
|
71
|
+
className: e(b, H, "px-4 w-full justify-between focus-visible:ring-0", t(B)),
|
|
72
|
+
"data-testid": `${f}-select-trigger`,
|
|
73
|
+
disabled: T,
|
|
74
|
+
id: L ? P : void 0,
|
|
75
|
+
style: F ? { minWidth: F } : void 0,
|
|
76
|
+
children: /* @__PURE__ */ m(c, { placeholder: O })
|
|
62
77
|
});
|
|
63
|
-
return /* @__PURE__ */
|
|
64
|
-
className:
|
|
65
|
-
children:
|
|
66
|
-
className:
|
|
67
|
-
|
|
68
|
-
children: b
|
|
69
|
-
}) : null, N]
|
|
70
|
-
}) : N }), /* @__PURE__ */ m(r, {
|
|
71
|
-
"data-testid": `${d}-select-root`,
|
|
72
|
-
disabled: x,
|
|
73
|
-
...D,
|
|
74
|
-
children: [/* @__PURE__ */ p(l, { children: j ? /* @__PURE__ */ m("div", {
|
|
75
|
-
className: g,
|
|
76
|
-
children: [E ? /* @__PURE__ */ p(t, {
|
|
78
|
+
return /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(u, {
|
|
79
|
+
className: L ? U : void 0,
|
|
80
|
+
children: L ? /* @__PURE__ */ h("div", {
|
|
81
|
+
className: y,
|
|
82
|
+
children: [/* @__PURE__ */ m(n, {
|
|
77
83
|
className: "text-text-primary",
|
|
78
|
-
htmlFor:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
htmlFor: x,
|
|
85
|
+
id: S,
|
|
86
|
+
children: C
|
|
87
|
+
}), G]
|
|
88
|
+
}) : G
|
|
89
|
+
}), /* @__PURE__ */ h(i, {
|
|
90
|
+
"data-testid": `${f}-select-root`,
|
|
91
|
+
disabled: T,
|
|
92
|
+
...M,
|
|
93
|
+
children: [/* @__PURE__ */ m(u, {
|
|
94
|
+
className: L ? W : void 0,
|
|
95
|
+
children: L ? /* @__PURE__ */ h("div", {
|
|
96
|
+
className: y,
|
|
97
|
+
children: [/* @__PURE__ */ m(n, {
|
|
98
|
+
className: "text-text-primary",
|
|
99
|
+
htmlFor: P,
|
|
100
|
+
id: k,
|
|
101
|
+
children: A
|
|
102
|
+
}), K]
|
|
103
|
+
}) : K
|
|
104
|
+
}), /* @__PURE__ */ m(a, { children: j.map((e) => /* @__PURE__ */ m(o, {
|
|
82
105
|
value: e.value,
|
|
83
106
|
children: e.label
|
|
84
107
|
}, e.value)) })]
|
|
85
108
|
})] });
|
|
86
109
|
};
|
|
87
110
|
//#endregion
|
|
88
|
-
export {
|
|
111
|
+
export { C as ControlGroupSelect };
|
package/dist/ControlGroup.js
CHANGED
|
@@ -2,47 +2,47 @@
|
|
|
2
2
|
import "./styles/main.css";
|
|
3
3
|
import { t as e } from "./twUtils-VNWgstKL.js";
|
|
4
4
|
import { Slot as t } from "./primitives/slot.js";
|
|
5
|
-
import { ErrorMessage as n, getErrorMessageId as r,
|
|
6
|
-
import { createContext as
|
|
7
|
-
import { jsx as
|
|
5
|
+
import { ErrorMessage as n, getErrorMessageId as r, useFormFieldId as i, useFormFieldState as a } from "./utils/formFieldUtils.js";
|
|
6
|
+
import { createContext as o, useContext as s } from "react";
|
|
7
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
8
8
|
//#region src/components/ControlGroup/ControlGroup.tsx
|
|
9
|
-
var
|
|
10
|
-
let e =
|
|
9
|
+
var u = o(null), d = () => {
|
|
10
|
+
let e = s(u);
|
|
11
11
|
if (e === null) throw Error("useControlGroup must be used within a ControlGroup");
|
|
12
12
|
return e;
|
|
13
|
-
},
|
|
14
|
-
let
|
|
15
|
-
return /* @__PURE__ */ u
|
|
13
|
+
}, f = ({ className: t, disabled: o, errorMessage: s, id: d, name: f, orientation: p = "horizontal", state: m = "default", ...h }) => {
|
|
14
|
+
let g = i(d, f), _ = r(g), { isDisabled: v, isLoading: y, isInvalid: b } = a(o, m);
|
|
15
|
+
return /* @__PURE__ */ l(u.Provider, {
|
|
16
16
|
value: {
|
|
17
|
-
errorMessageId:
|
|
18
|
-
isDisabled:
|
|
19
|
-
isInvalid:
|
|
20
|
-
isLoading:
|
|
21
|
-
orientation:
|
|
22
|
-
state:
|
|
17
|
+
errorMessageId: b && s ? _ : void 0,
|
|
18
|
+
isDisabled: v,
|
|
19
|
+
isInvalid: b,
|
|
20
|
+
isLoading: y,
|
|
21
|
+
orientation: p,
|
|
22
|
+
state: m
|
|
23
23
|
},
|
|
24
|
-
children: [/* @__PURE__ */
|
|
24
|
+
children: [/* @__PURE__ */ c("div", {
|
|
25
25
|
"data-slot": "control-group",
|
|
26
|
-
"data-orientation":
|
|
27
|
-
"data-state":
|
|
28
|
-
id:
|
|
26
|
+
"data-orientation": p,
|
|
27
|
+
"data-state": m,
|
|
28
|
+
id: g,
|
|
29
29
|
role: "group",
|
|
30
|
-
"aria-describedby":
|
|
31
|
-
className: e("group
|
|
32
|
-
...
|
|
33
|
-
}),
|
|
30
|
+
"aria-describedby": b && s ? _ : void 0,
|
|
31
|
+
className: e("group flex", p === "vertical" && "flex-col", v && "pointer-events-none opacity-50", t),
|
|
32
|
+
...h
|
|
33
|
+
}), b && s && /* @__PURE__ */ c(n, {
|
|
34
34
|
dataTestId: "spectral-control-group-error-message",
|
|
35
|
-
id:
|
|
36
|
-
message:
|
|
35
|
+
id: _,
|
|
36
|
+
message: s
|
|
37
37
|
})]
|
|
38
38
|
});
|
|
39
|
-
},
|
|
40
|
-
let { orientation: i } =
|
|
41
|
-
return /* @__PURE__ */
|
|
39
|
+
}, p = ({ className: n, ...r }) => {
|
|
40
|
+
let { orientation: i } = d();
|
|
41
|
+
return /* @__PURE__ */ c(t, {
|
|
42
42
|
"data-slot": "control-group-item",
|
|
43
|
-
className: e("rounded-none focus-within:z-10", i === "horizontal" && "first:rounded-s-md last:me-0 last:rounded-e-md -me-
|
|
43
|
+
className: e("rounded-none focus-within:z-10 hover:z-10", i === "horizontal" && "first:rounded-s-md last:me-0 last:rounded-e-md -me-0.5 h-auto", i === "vertical" && "first:rounded-ss-md first:rounded-se-md last:rounded-ee-md last:rounded-es-md last:mbe-0 -mbe-0.5 w-auto", n),
|
|
44
44
|
...r
|
|
45
45
|
});
|
|
46
46
|
};
|
|
47
47
|
//#endregion
|
|
48
|
-
export {
|
|
48
|
+
export { f as ControlGroup, p as ControlGroupItem, d as useControlGroup };
|
package/dist/DataCard.js
CHANGED
|
@@ -23,7 +23,7 @@ var s = ({ accentColor: s, cardHeaderEndSlot: c, className: l, dataDescription:
|
|
|
23
23
|
}), /* @__PURE__ */ a(n, { children: /* @__PURE__ */ o("div", {
|
|
24
24
|
className: "gap-4 flex flex-col",
|
|
25
25
|
children: [/* @__PURE__ */ a("div", {
|
|
26
|
-
className: "text-4xl font-bold",
|
|
26
|
+
className: "text-4xl font-bold tabular-nums",
|
|
27
27
|
"data-testid": "spectral-datacard-data-value",
|
|
28
28
|
style: { color: s },
|
|
29
29
|
children: d
|
package/dist/Input.js
CHANGED
|
@@ -5,19 +5,19 @@ import { CloseCircleIcon as t } from "./Icons/CloseCircleIcon.js";
|
|
|
5
5
|
import { ErrorIcon as n } from "./Icons/ErrorIcon.js";
|
|
6
6
|
import { EyeClosedIcon as r } from "./Icons/EyeClosedIcon.js";
|
|
7
7
|
import { EyeOpenIcon as i } from "./Icons/EyeOpenIcon.js";
|
|
8
|
-
import { LoaderIcon as
|
|
9
|
-
import { t as
|
|
10
|
-
import { ErrorMessage as
|
|
11
|
-
import { Label as
|
|
12
|
-
import { useClearOnFocus as te, usePasswordVisibility as
|
|
13
|
-
import { useCallback as
|
|
14
|
-
import { jsx as
|
|
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
15
|
//#region src/components/Input/Input.tsx
|
|
16
|
-
var
|
|
16
|
+
var y = (...e) => (t) => {
|
|
17
17
|
e.forEach((e) => {
|
|
18
18
|
e && (typeof e == "function" ? e(t) : e.current = t);
|
|
19
19
|
});
|
|
20
|
-
},
|
|
20
|
+
}, ne = (e) => ({
|
|
21
21
|
date: "off",
|
|
22
22
|
email: "email",
|
|
23
23
|
number: "off",
|
|
@@ -27,81 +27,81 @@ var v = (...e) => (t) => {
|
|
|
27
27
|
url: "url",
|
|
28
28
|
"datetime-local": "off"
|
|
29
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 =
|
|
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
31
|
O?.(e);
|
|
32
|
-
}, [O]), ue =
|
|
32
|
+
}, [O]), ue = h((e) => {
|
|
33
33
|
Q(e, A);
|
|
34
|
-
}, [Q, A]), de =
|
|
34
|
+
}, [Q, A]), de = h((e) => {
|
|
35
35
|
let t = e.target.value;
|
|
36
36
|
k?.(t);
|
|
37
|
-
}, [k]), fe =
|
|
37
|
+
}, [k]), fe = h(() => {
|
|
38
38
|
let e = X.current;
|
|
39
39
|
e && (e.value = "", e.dispatchEvent(new Event("input", { bubbles: !0 })), e.focus());
|
|
40
40
|
}, []), $ = F && B.length > 0, pe = () => {
|
|
41
|
-
let
|
|
42
|
-
password: () => /* @__PURE__ */
|
|
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
43
|
"aria-controls": W,
|
|
44
44
|
"aria-label": Z ? `Hide ${T ?? "password"}` : `Show ${T ?? "password"}`,
|
|
45
45
|
"aria-pressed": Z,
|
|
46
|
-
className:
|
|
46
|
+
className: o,
|
|
47
47
|
"data-testid": "spectral-input-password-toggle",
|
|
48
48
|
onClick: ae,
|
|
49
49
|
type: "button",
|
|
50
|
-
children:
|
|
50
|
+
children: _(Z ? r : i, { size: 22 })
|
|
51
51
|
}),
|
|
52
|
-
clear: () => /* @__PURE__ */
|
|
52
|
+
clear: () => /* @__PURE__ */ _("button", {
|
|
53
53
|
"aria-label": String(`Clear ${T ?? "input"}`),
|
|
54
|
-
className:
|
|
54
|
+
className: o,
|
|
55
55
|
"data-testid": "spectral-input-clear-button",
|
|
56
56
|
onClick: fe,
|
|
57
57
|
type: "button",
|
|
58
|
-
children: /* @__PURE__ */
|
|
58
|
+
children: /* @__PURE__ */ _(t, { size: 24 })
|
|
59
59
|
}),
|
|
60
|
-
loading: () => /* @__PURE__ */
|
|
60
|
+
loading: () => /* @__PURE__ */ _("div", {
|
|
61
61
|
className: "right-4 text-input-icon absolute top-1/2 -translate-y-1/2",
|
|
62
62
|
"data-testid": "spectral-input-loading-icon",
|
|
63
|
-
children: /* @__PURE__ */
|
|
63
|
+
children: /* @__PURE__ */ _(a, { size: 24 })
|
|
64
64
|
}),
|
|
65
|
-
error: () => /* @__PURE__ */
|
|
65
|
+
error: () => /* @__PURE__ */ _("div", {
|
|
66
66
|
className: "right-4 absolute top-1/2 -translate-y-1/2 text-danger-400",
|
|
67
67
|
"data-testid": "spectral-input-error-icon",
|
|
68
|
-
children: /* @__PURE__ */
|
|
68
|
+
children: /* @__PURE__ */ _(n, { size: 24 })
|
|
69
69
|
}),
|
|
70
|
-
success: () => /* @__PURE__ */
|
|
70
|
+
success: () => /* @__PURE__ */ _("div", {
|
|
71
71
|
className: "right-4 absolute top-1/2 -translate-y-1/2 text-success-400",
|
|
72
72
|
"data-testid": "spectral-input-success-icon",
|
|
73
|
-
children: /* @__PURE__ */
|
|
73
|
+
children: /* @__PURE__ */ _(e, { size: 24 })
|
|
74
74
|
})
|
|
75
75
|
};
|
|
76
|
-
return C ? /* @__PURE__ */
|
|
76
|
+
return C ? /* @__PURE__ */ _("div", {
|
|
77
77
|
className: "right-4 text-input-icon absolute top-1/2 -translate-y-1/2",
|
|
78
78
|
children: C
|
|
79
|
-
}) : z === "password" ?
|
|
80
|
-
}, me = () => I || null, he =
|
|
81
|
-
return /* @__PURE__ */
|
|
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
82
|
className: "space-y-1.5 w-full",
|
|
83
83
|
"data-testid": "spectral-input-container",
|
|
84
|
-
children: [T && /* @__PURE__ */
|
|
85
|
-
className:
|
|
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
86
|
"data-testid": "spectral-input-label",
|
|
87
87
|
htmlFor: W,
|
|
88
88
|
children: T
|
|
89
|
-
}), /* @__PURE__ */
|
|
89
|
+
}), /* @__PURE__ */ v("div", {
|
|
90
90
|
className: "relative",
|
|
91
91
|
"data-testid": "spectral-input-wrapper",
|
|
92
|
-
children: [/* @__PURE__ */
|
|
92
|
+
children: [/* @__PURE__ */ v("div", {
|
|
93
93
|
className: "relative",
|
|
94
94
|
children: [
|
|
95
95
|
me(),
|
|
96
|
-
M && /* @__PURE__ */
|
|
96
|
+
M && /* @__PURE__ */ _("span", {
|
|
97
97
|
ref: ce,
|
|
98
|
-
className:
|
|
98
|
+
className: _e,
|
|
99
99
|
children: M
|
|
100
100
|
}),
|
|
101
|
-
/* @__PURE__ */
|
|
101
|
+
/* @__PURE__ */ _("input", {
|
|
102
102
|
"aria-label": V ?? T,
|
|
103
|
-
autoComplete:
|
|
104
|
-
className:
|
|
103
|
+
autoComplete: ne(z),
|
|
104
|
+
className: ge,
|
|
105
105
|
"data-state": L,
|
|
106
106
|
"data-testid": "spectral-input",
|
|
107
107
|
disabled: K,
|
|
@@ -113,7 +113,7 @@ var v = (...e) => (t) => {
|
|
|
113
113
|
placeholder: j ?? T,
|
|
114
114
|
ref: ie,
|
|
115
115
|
required: P,
|
|
116
|
-
style:
|
|
116
|
+
style: l({ "--prefix-width": M ? `${se}px` : "0" }),
|
|
117
117
|
suppressHydrationWarning: R,
|
|
118
118
|
type: z === "password" ? oe : z,
|
|
119
119
|
value: B,
|
|
@@ -122,7 +122,7 @@ var v = (...e) => (t) => {
|
|
|
122
122
|
}),
|
|
123
123
|
pe()
|
|
124
124
|
]
|
|
125
|
-
}), J && w && /* @__PURE__ */
|
|
125
|
+
}), J && w && /* @__PURE__ */ _(s, {
|
|
126
126
|
dataTestId: "spectral-input-error-message",
|
|
127
127
|
id: G,
|
|
128
128
|
message: w
|
|
@@ -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 };
|