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