@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.
- package/README.md +6 -5
- package/dist/.js +112 -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 -274
- package/dist/DateTimePicker/DateTimeInput.d.ts +5 -3
- package/dist/DateTimePicker/DateTimeInput.js +133 -88
- 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 -23
- 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/InputOTP-XUWW9xcI.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/useTheme.js +21 -17
- package/dist/index.d.ts +2 -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.d.ts.map +1 -1
- package/dist/primitives/popover.js +34 -25
- 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
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
import "./styles/main.css";
|
|
2
|
+
import { MinusIcon as e } from "./Icons/MinusIcon.js";
|
|
3
|
+
import { t } from "./twUtils-VNWgstKL.js";
|
|
4
|
+
import { ErrorMessage as n, getErrorMessageId as r, useFormFieldId as i, useFormFieldState as a } from "./utils/formFieldUtils.js";
|
|
5
|
+
import * as o from "react";
|
|
6
|
+
import { createContext as s, useContext as c } from "react";
|
|
7
|
+
import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
8
|
+
//#region node_modules/.pnpm/input-otp@1.4.2_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/input-otp/dist/index.mjs
|
|
9
|
+
var f = Object.defineProperty, p = Object.defineProperties, m = Object.getOwnPropertyDescriptors, h = Object.getOwnPropertySymbols, g = Object.prototype.hasOwnProperty, _ = Object.prototype.propertyIsEnumerable, v = (e, t, n) => t in e ? f(e, t, {
|
|
10
|
+
enumerable: !0,
|
|
11
|
+
configurable: !0,
|
|
12
|
+
writable: !0,
|
|
13
|
+
value: n
|
|
14
|
+
}) : e[t] = n, y = (e, t) => {
|
|
15
|
+
for (var n in t ||= {}) g.call(t, n) && v(e, n, t[n]);
|
|
16
|
+
if (h) for (var n of h(t)) _.call(t, n) && v(e, n, t[n]);
|
|
17
|
+
return e;
|
|
18
|
+
}, b = (e, t) => p(e, m(t)), x = (e, t) => {
|
|
19
|
+
var n = {};
|
|
20
|
+
for (var r in e) g.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
|
|
21
|
+
if (e != null && h) for (var r of h(e)) t.indexOf(r) < 0 && _.call(e, r) && (n[r] = e[r]);
|
|
22
|
+
return n;
|
|
23
|
+
};
|
|
24
|
+
function S(e) {
|
|
25
|
+
return [
|
|
26
|
+
setTimeout(e, 0),
|
|
27
|
+
setTimeout(e, 10),
|
|
28
|
+
setTimeout(e, 50)
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
function C(e) {
|
|
32
|
+
let t = o.useRef();
|
|
33
|
+
return o.useEffect(() => {
|
|
34
|
+
t.current = e;
|
|
35
|
+
}), t.current;
|
|
36
|
+
}
|
|
37
|
+
var w = 18, T = 40, E = `${T}px`, D = [
|
|
38
|
+
"[data-lastpass-icon-root]",
|
|
39
|
+
"com-1password-button",
|
|
40
|
+
"[data-dashlanecreated]",
|
|
41
|
+
"[style$=\"2147483647 !important;\"]"
|
|
42
|
+
].join(",");
|
|
43
|
+
function ee({ containerRef: e, inputRef: t, pushPasswordManagerStrategy: n, isFocused: r }) {
|
|
44
|
+
let [i, a] = o.useState(!1), [s, c] = o.useState(!1), [l, u] = o.useState(!1), d = o.useMemo(() => n === "none" ? !1 : (n === "increase-width" || n === "experimental-no-flickering") && i && s, [
|
|
45
|
+
i,
|
|
46
|
+
s,
|
|
47
|
+
n
|
|
48
|
+
]), f = o.useCallback(() => {
|
|
49
|
+
let r = e.current, i = t.current;
|
|
50
|
+
if (!r || !i || l || n === "none") return;
|
|
51
|
+
let o = r, s = o.getBoundingClientRect().left + o.offsetWidth, c = o.getBoundingClientRect().top + o.offsetHeight / 2, d = s - w, f = c;
|
|
52
|
+
document.querySelectorAll(D).length === 0 && document.elementFromPoint(d, f) === r || (a(!0), u(!0));
|
|
53
|
+
}, [
|
|
54
|
+
e,
|
|
55
|
+
t,
|
|
56
|
+
l,
|
|
57
|
+
n
|
|
58
|
+
]);
|
|
59
|
+
return o.useEffect(() => {
|
|
60
|
+
let t = e.current;
|
|
61
|
+
if (!t || n === "none") return;
|
|
62
|
+
function r() {
|
|
63
|
+
c(window.innerWidth - t.getBoundingClientRect().right >= T);
|
|
64
|
+
}
|
|
65
|
+
r();
|
|
66
|
+
let i = setInterval(r, 1e3);
|
|
67
|
+
return () => {
|
|
68
|
+
clearInterval(i);
|
|
69
|
+
};
|
|
70
|
+
}, [e, n]), o.useEffect(() => {
|
|
71
|
+
let e = r || document.activeElement === t.current;
|
|
72
|
+
if (n === "none" || !e) return;
|
|
73
|
+
let i = setTimeout(f, 0), a = setTimeout(f, 2e3), o = setTimeout(f, 5e3), s = setTimeout(() => {
|
|
74
|
+
u(!0);
|
|
75
|
+
}, 6e3);
|
|
76
|
+
return () => {
|
|
77
|
+
clearTimeout(i), clearTimeout(a), clearTimeout(o), clearTimeout(s);
|
|
78
|
+
};
|
|
79
|
+
}, [
|
|
80
|
+
t,
|
|
81
|
+
r,
|
|
82
|
+
n,
|
|
83
|
+
f
|
|
84
|
+
]), {
|
|
85
|
+
hasPWMBadge: i,
|
|
86
|
+
willPushPWMBadge: d,
|
|
87
|
+
PWM_BADGE_SPACE_WIDTH: E
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
var O = o.createContext({}), k = o.forwardRef((e, t) => {
|
|
91
|
+
var n = e, { value: r, onChange: i, maxLength: a, textAlign: s = "left", pattern: c, placeholder: l, inputMode: u = "numeric", onComplete: d, pushPasswordManagerStrategy: f = "increase-width", pasteTransformer: p, containerClassName: m, noScriptCSSFallback: h = j, render: g, children: _ } = n, v = x(n, [
|
|
92
|
+
"value",
|
|
93
|
+
"onChange",
|
|
94
|
+
"maxLength",
|
|
95
|
+
"textAlign",
|
|
96
|
+
"pattern",
|
|
97
|
+
"placeholder",
|
|
98
|
+
"inputMode",
|
|
99
|
+
"onComplete",
|
|
100
|
+
"pushPasswordManagerStrategy",
|
|
101
|
+
"pasteTransformer",
|
|
102
|
+
"containerClassName",
|
|
103
|
+
"noScriptCSSFallback",
|
|
104
|
+
"render",
|
|
105
|
+
"children"
|
|
106
|
+
]), w;
|
|
107
|
+
let [T, E] = o.useState(typeof v.defaultValue == "string" ? v.defaultValue : ""), D = r ?? T, k = C(D), M = o.useCallback((e) => {
|
|
108
|
+
i?.(e), E(e);
|
|
109
|
+
}, [i]), N = o.useMemo(() => c ? typeof c == "string" ? new RegExp(c) : c : null, [c]), P = o.useRef(null), F = o.useRef(null), I = o.useRef({
|
|
110
|
+
value: D,
|
|
111
|
+
onChange: M,
|
|
112
|
+
isIOS: typeof window < "u" && ((w = window == null ? void 0 : window.CSS)?.supports)?.call(w, "-webkit-touch-callout", "none")
|
|
113
|
+
}), L = o.useRef({ prev: [
|
|
114
|
+
P.current?.selectionStart,
|
|
115
|
+
P.current?.selectionEnd,
|
|
116
|
+
P.current?.selectionDirection
|
|
117
|
+
] });
|
|
118
|
+
o.useImperativeHandle(t, () => P.current, []), o.useEffect(() => {
|
|
119
|
+
let e = P.current, t = F.current;
|
|
120
|
+
if (!e || !t) return;
|
|
121
|
+
I.current.value !== e.value && I.current.onChange(e.value), L.current.prev = [
|
|
122
|
+
e.selectionStart,
|
|
123
|
+
e.selectionEnd,
|
|
124
|
+
e.selectionDirection
|
|
125
|
+
];
|
|
126
|
+
function n() {
|
|
127
|
+
if (document.activeElement !== e) {
|
|
128
|
+
U(null), G(null);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
let t = e.selectionStart, n = e.selectionEnd, r = e.selectionDirection, i = e.maxLength, a = e.value, o = L.current.prev, s = -1, c = -1, l;
|
|
132
|
+
if (a.length !== 0 && t !== null && n !== null) {
|
|
133
|
+
let e = t === n, r = t === a.length && a.length < i;
|
|
134
|
+
if (e && !r) {
|
|
135
|
+
let e = t;
|
|
136
|
+
if (e === 0) s = 0, c = 1, l = "forward";
|
|
137
|
+
else if (e === i) s = e - 1, c = e, l = "backward";
|
|
138
|
+
else if (i > 1 && a.length > 1) {
|
|
139
|
+
let t = 0;
|
|
140
|
+
if (o[0] !== null && o[1] !== null) {
|
|
141
|
+
l = e < o[1] ? "backward" : "forward";
|
|
142
|
+
let n = o[0] === o[1] && o[0] < i;
|
|
143
|
+
l === "backward" && !n && (t = -1);
|
|
144
|
+
}
|
|
145
|
+
s = t + e, c = t + e + 1;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
s !== -1 && c !== -1 && s !== c && P.current.setSelectionRange(s, c, l);
|
|
149
|
+
}
|
|
150
|
+
let u = s === -1 ? t : s, d = c === -1 ? n : c, f = l ?? r;
|
|
151
|
+
U(u), G(d), L.current.prev = [
|
|
152
|
+
u,
|
|
153
|
+
d,
|
|
154
|
+
f
|
|
155
|
+
];
|
|
156
|
+
}
|
|
157
|
+
if (document.addEventListener("selectionchange", n, { capture: !0 }), n(), document.activeElement === e && V(!0), !document.getElementById("input-otp-style")) {
|
|
158
|
+
let e = document.createElement("style");
|
|
159
|
+
if (e.id = "input-otp-style", document.head.appendChild(e), e.sheet) {
|
|
160
|
+
let t = "background: transparent !important; color: transparent !important; border-color: transparent !important; opacity: 0 !important; box-shadow: none !important; -webkit-box-shadow: none !important; -webkit-text-fill-color: transparent !important;";
|
|
161
|
+
A(e.sheet, "[data-input-otp]::selection { background: transparent !important; color: transparent !important; }"), A(e.sheet, `[data-input-otp]:autofill { ${t} }`), A(e.sheet, `[data-input-otp]:-webkit-autofill { ${t} }`), A(e.sheet, "@supports (-webkit-touch-callout: none) { [data-input-otp] { letter-spacing: -.6em !important; font-weight: 100 !important; font-stretch: ultra-condensed; font-optical-sizing: none !important; left: -1px !important; right: 1px !important; } }"), A(e.sheet, "[data-input-otp] + * { pointer-events: all !important; }");
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
let r = () => {
|
|
165
|
+
t && t.style.setProperty("--root-height", `${e.clientHeight}px`);
|
|
166
|
+
};
|
|
167
|
+
r();
|
|
168
|
+
let i = new ResizeObserver(r);
|
|
169
|
+
return i.observe(e), () => {
|
|
170
|
+
document.removeEventListener("selectionchange", n, { capture: !0 }), i.disconnect();
|
|
171
|
+
};
|
|
172
|
+
}, []);
|
|
173
|
+
let [R, z] = o.useState(!1), [B, V] = o.useState(!1), [H, U] = o.useState(null), [W, G] = o.useState(null);
|
|
174
|
+
o.useEffect(() => {
|
|
175
|
+
S(() => {
|
|
176
|
+
var e;
|
|
177
|
+
(e = P.current) == null || e.dispatchEvent(new Event("input"));
|
|
178
|
+
let t = P.current?.selectionStart, n = P.current?.selectionEnd, r = P.current?.selectionDirection;
|
|
179
|
+
t !== null && n !== null && (U(t), G(n), L.current.prev = [
|
|
180
|
+
t,
|
|
181
|
+
n,
|
|
182
|
+
r
|
|
183
|
+
]);
|
|
184
|
+
});
|
|
185
|
+
}, [D, B]), o.useEffect(() => {
|
|
186
|
+
k !== void 0 && D !== k && k.length < a && D.length === a && d?.(D);
|
|
187
|
+
}, [
|
|
188
|
+
a,
|
|
189
|
+
d,
|
|
190
|
+
k,
|
|
191
|
+
D
|
|
192
|
+
]);
|
|
193
|
+
let K = ee({
|
|
194
|
+
containerRef: F,
|
|
195
|
+
inputRef: P,
|
|
196
|
+
pushPasswordManagerStrategy: f,
|
|
197
|
+
isFocused: B
|
|
198
|
+
}), q = o.useCallback((e) => {
|
|
199
|
+
let t = e.currentTarget.value.slice(0, a);
|
|
200
|
+
if (t.length > 0 && N && !N.test(t)) {
|
|
201
|
+
e.preventDefault();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
typeof k == "string" && t.length < k.length && document.dispatchEvent(new Event("selectionchange")), M(t);
|
|
205
|
+
}, [
|
|
206
|
+
a,
|
|
207
|
+
M,
|
|
208
|
+
k,
|
|
209
|
+
N
|
|
210
|
+
]), J = o.useCallback(() => {
|
|
211
|
+
var e;
|
|
212
|
+
if (P.current) {
|
|
213
|
+
let t = Math.min(P.current.value.length, a - 1), n = P.current.value.length;
|
|
214
|
+
(e = P.current) == null || e.setSelectionRange(t, n), U(t), G(n);
|
|
215
|
+
}
|
|
216
|
+
V(!0);
|
|
217
|
+
}, [a]), Y = o.useCallback((e) => {
|
|
218
|
+
let t = P.current;
|
|
219
|
+
if (!p && (!I.current.isIOS || !e.clipboardData || !t)) return;
|
|
220
|
+
let n = e.clipboardData.getData("text/plain"), r = p ? p(n) : n;
|
|
221
|
+
e.preventDefault();
|
|
222
|
+
let i = P.current?.selectionStart, o = P.current?.selectionEnd, s = (i === o ? D.slice(0, i) + r + D.slice(i) : D.slice(0, i) + r + D.slice(o)).slice(0, a);
|
|
223
|
+
if (s.length > 0 && N && !N.test(s)) return;
|
|
224
|
+
t.value = s, M(s);
|
|
225
|
+
let c = Math.min(s.length, a - 1), l = s.length;
|
|
226
|
+
t.setSelectionRange(c, l), U(c), G(l);
|
|
227
|
+
}, [
|
|
228
|
+
a,
|
|
229
|
+
M,
|
|
230
|
+
N,
|
|
231
|
+
D
|
|
232
|
+
]), X = o.useMemo(() => ({
|
|
233
|
+
position: "relative",
|
|
234
|
+
cursor: v.disabled ? "default" : "text",
|
|
235
|
+
userSelect: "none",
|
|
236
|
+
WebkitUserSelect: "none",
|
|
237
|
+
pointerEvents: "none"
|
|
238
|
+
}), [v.disabled]), Z = o.useMemo(() => ({
|
|
239
|
+
position: "absolute",
|
|
240
|
+
inset: 0,
|
|
241
|
+
width: K.willPushPWMBadge ? `calc(100% + ${K.PWM_BADGE_SPACE_WIDTH})` : "100%",
|
|
242
|
+
clipPath: K.willPushPWMBadge ? `inset(0 ${K.PWM_BADGE_SPACE_WIDTH} 0 0)` : void 0,
|
|
243
|
+
height: "100%",
|
|
244
|
+
display: "flex",
|
|
245
|
+
textAlign: s,
|
|
246
|
+
opacity: "1",
|
|
247
|
+
color: "transparent",
|
|
248
|
+
pointerEvents: "all",
|
|
249
|
+
background: "transparent",
|
|
250
|
+
caretColor: "transparent",
|
|
251
|
+
border: "0 solid transparent",
|
|
252
|
+
outline: "0 solid transparent",
|
|
253
|
+
boxShadow: "none",
|
|
254
|
+
lineHeight: "1",
|
|
255
|
+
letterSpacing: "-.5em",
|
|
256
|
+
fontSize: "var(--root-height)",
|
|
257
|
+
fontFamily: "monospace",
|
|
258
|
+
fontVariantNumeric: "tabular-nums"
|
|
259
|
+
}), [
|
|
260
|
+
K.PWM_BADGE_SPACE_WIDTH,
|
|
261
|
+
K.willPushPWMBadge,
|
|
262
|
+
s
|
|
263
|
+
]), Q = o.useMemo(() => o.createElement("input", b(y({ autoComplete: v.autoComplete || "one-time-code" }, v), {
|
|
264
|
+
"data-input-otp": !0,
|
|
265
|
+
"data-input-otp-placeholder-shown": D.length === 0 || void 0,
|
|
266
|
+
"data-input-otp-mss": H,
|
|
267
|
+
"data-input-otp-mse": W,
|
|
268
|
+
inputMode: u,
|
|
269
|
+
pattern: N?.source,
|
|
270
|
+
"aria-placeholder": l,
|
|
271
|
+
style: Z,
|
|
272
|
+
maxLength: a,
|
|
273
|
+
value: D,
|
|
274
|
+
ref: P,
|
|
275
|
+
onPaste: (e) => {
|
|
276
|
+
var t;
|
|
277
|
+
Y(e), (t = v.onPaste) == null || t.call(v, e);
|
|
278
|
+
},
|
|
279
|
+
onChange: q,
|
|
280
|
+
onMouseOver: (e) => {
|
|
281
|
+
var t;
|
|
282
|
+
z(!0), (t = v.onMouseOver) == null || t.call(v, e);
|
|
283
|
+
},
|
|
284
|
+
onMouseLeave: (e) => {
|
|
285
|
+
var t;
|
|
286
|
+
z(!1), (t = v.onMouseLeave) == null || t.call(v, e);
|
|
287
|
+
},
|
|
288
|
+
onFocus: (e) => {
|
|
289
|
+
var t;
|
|
290
|
+
J(), (t = v.onFocus) == null || t.call(v, e);
|
|
291
|
+
},
|
|
292
|
+
onBlur: (e) => {
|
|
293
|
+
var t;
|
|
294
|
+
V(!1), (t = v.onBlur) == null || t.call(v, e);
|
|
295
|
+
}
|
|
296
|
+
})), [
|
|
297
|
+
q,
|
|
298
|
+
J,
|
|
299
|
+
Y,
|
|
300
|
+
u,
|
|
301
|
+
Z,
|
|
302
|
+
a,
|
|
303
|
+
W,
|
|
304
|
+
H,
|
|
305
|
+
v,
|
|
306
|
+
N?.source,
|
|
307
|
+
D
|
|
308
|
+
]), $ = o.useMemo(() => ({
|
|
309
|
+
slots: Array.from({ length: a }).map((e, t) => {
|
|
310
|
+
let n = B && H !== null && W !== null && (H === W && t === H || t >= H && t < W), r = D[t] === void 0 ? null : D[t];
|
|
311
|
+
return {
|
|
312
|
+
char: r,
|
|
313
|
+
placeholderChar: D[0] === void 0 ? l?.[t] ?? null : null,
|
|
314
|
+
isActive: n,
|
|
315
|
+
hasFakeCaret: n && r === null
|
|
316
|
+
};
|
|
317
|
+
}),
|
|
318
|
+
isFocused: B,
|
|
319
|
+
isHovering: !v.disabled && R
|
|
320
|
+
}), [
|
|
321
|
+
B,
|
|
322
|
+
R,
|
|
323
|
+
a,
|
|
324
|
+
W,
|
|
325
|
+
H,
|
|
326
|
+
v.disabled,
|
|
327
|
+
D
|
|
328
|
+
]), te = o.useMemo(() => g ? g($) : o.createElement(O.Provider, { value: $ }, _), [
|
|
329
|
+
_,
|
|
330
|
+
$,
|
|
331
|
+
g
|
|
332
|
+
]);
|
|
333
|
+
return o.createElement(o.Fragment, null, h !== null && o.createElement("noscript", null, o.createElement("style", null, h)), o.createElement("div", {
|
|
334
|
+
ref: F,
|
|
335
|
+
"data-input-otp-container": !0,
|
|
336
|
+
style: X,
|
|
337
|
+
className: m
|
|
338
|
+
}, te, o.createElement("div", { style: {
|
|
339
|
+
position: "absolute",
|
|
340
|
+
inset: 0,
|
|
341
|
+
pointerEvents: "none"
|
|
342
|
+
} }, Q)));
|
|
343
|
+
});
|
|
344
|
+
k.displayName = "Input";
|
|
345
|
+
function A(e, t) {
|
|
346
|
+
try {
|
|
347
|
+
e.insertRule(t);
|
|
348
|
+
} catch {
|
|
349
|
+
console.error("input-otp could not insert CSS rule:", t);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
var j = "\n[data-input-otp] {\n --nojs-bg: white !important;\n --nojs-fg: black !important;\n\n background-color: var(--nojs-bg) !important;\n color: var(--nojs-fg) !important;\n caret-color: var(--nojs-fg) !important;\n letter-spacing: .25em !important;\n text-align: center !important;\n border: 1px solid var(--nojs-fg) !important;\n border-radius: 4px !important;\n width: 100% !important;\n}\n@media (prefers-color-scheme: dark) {\n [data-input-otp] {\n --nojs-bg: black !important;\n --nojs-fg: white !important;\n }\n}", M = s({}), N = s(null), P = () => {
|
|
353
|
+
let e = c(N);
|
|
354
|
+
if (!e) throw Error("useRoot must be used within an InputOTP");
|
|
355
|
+
return e;
|
|
356
|
+
}, F = ({ autoFocus: e = !1, children: o, className: s, errorMessage: c, id: l, inputMode: f = "numeric", maxLength: p, name: m, onChange: h, onComplete: g, pattern: _, ref: v, state: y = "default", value: b, variant: x = "outlined", ...S }) => {
|
|
357
|
+
let C = i(l, m), { isInvalid: w } = a(!1, y), T = _ ?? (f === "numeric" ? "^\\d+$" : void 0), E = (e) => {
|
|
358
|
+
let t = e.clipboardData.getData("text/plain").trim().replaceAll("-", "");
|
|
359
|
+
f === "numeric" && (t = t.replace(/\D/g, "")), t.length === p && typeof h == "function" && h(t);
|
|
360
|
+
};
|
|
361
|
+
return /* @__PURE__ */ u(M.Provider, {
|
|
362
|
+
value: { isInvalid: w },
|
|
363
|
+
children: /* @__PURE__ */ d("div", {
|
|
364
|
+
className: "gap-y-1 flex w-max flex-col",
|
|
365
|
+
children: [/* @__PURE__ */ u(k, {
|
|
366
|
+
autoFocus: e,
|
|
367
|
+
containerClassName: t("gap-2 flex items-center disabled:cursor-not-allowed has-[disabled]:opacity-50", s),
|
|
368
|
+
"data-1p-ignore": "true",
|
|
369
|
+
"data-dashlane-disabled-on-field": "true",
|
|
370
|
+
"data-lpignore": "true",
|
|
371
|
+
"data-protonpass-ignore": "true",
|
|
372
|
+
"data-testid": "spectral-input-otp",
|
|
373
|
+
id: C,
|
|
374
|
+
inputMode: f,
|
|
375
|
+
maxLength: p,
|
|
376
|
+
onChange: h,
|
|
377
|
+
onComplete: g,
|
|
378
|
+
onPaste: E,
|
|
379
|
+
pasteTransformer: (e) => e.replaceAll("-", ""),
|
|
380
|
+
pattern: T,
|
|
381
|
+
pushPasswordManagerStrategy: "none",
|
|
382
|
+
ref: v,
|
|
383
|
+
role: "textbox",
|
|
384
|
+
textAlign: "center",
|
|
385
|
+
value: b,
|
|
386
|
+
...S,
|
|
387
|
+
render: ({ slots: e }) => /* @__PURE__ */ u(N.Provider, {
|
|
388
|
+
value: {
|
|
389
|
+
slots: e,
|
|
390
|
+
variant: x,
|
|
391
|
+
maxLength: p
|
|
392
|
+
},
|
|
393
|
+
children: o ?? /* @__PURE__ */ u(I, { children: /* @__PURE__ */ u(R, {}) })
|
|
394
|
+
})
|
|
395
|
+
}), w && c && /* @__PURE__ */ u(n, {
|
|
396
|
+
dataTestId: "spectral-input-otp-error-message",
|
|
397
|
+
id: r(C),
|
|
398
|
+
message: c
|
|
399
|
+
})]
|
|
400
|
+
})
|
|
401
|
+
});
|
|
402
|
+
};
|
|
403
|
+
F.displayName = "InputOTP";
|
|
404
|
+
var I = ({ ref: e, ...t }) => /* @__PURE__ */ u("div", {
|
|
405
|
+
className: "gap-x-2 flex items-center justify-center",
|
|
406
|
+
"data-testid": "spectral-input-otp-group",
|
|
407
|
+
ref: e,
|
|
408
|
+
...t
|
|
409
|
+
});
|
|
410
|
+
I.displayName = "InputOTP.Group";
|
|
411
|
+
var L = ({ className: e, index: n, ref: r, ...i }) => {
|
|
412
|
+
let { variant: a = "outlined", slots: o = [] } = P(), { isInvalid: s } = c(M), l = o[n] || {
|
|
413
|
+
char: "",
|
|
414
|
+
hasFakeCaret: !0,
|
|
415
|
+
isActive: !1
|
|
416
|
+
};
|
|
417
|
+
return /* @__PURE__ */ d("div", {
|
|
418
|
+
className: t("h-12 w-10 relative z-10 flex items-center justify-center rounded-[8px] border transition duration-200 focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2", a === "filled" ? "border-level-one bg-level-one" : "border-input-otp-border bg-transparent", !s && "border", s && "border-2 border-danger-400 focus-visible:outline-danger-400", l.isActive && !s && "z-10 outline-2 outline-offset-2 outline-input-otp-border--focus", l.isActive && s && "outline-2 outline-offset-2 outline-danger-400", e),
|
|
419
|
+
"data-index": n,
|
|
420
|
+
"data-testid": "spectral-input-otp-slot",
|
|
421
|
+
"data-variant": a,
|
|
422
|
+
ref: r,
|
|
423
|
+
...i,
|
|
424
|
+
children: [l.char, l.hasFakeCaret && /* @__PURE__ */ u("div", {
|
|
425
|
+
className: "inset-0 pointer-events-none absolute flex items-center justify-center motion-safe:animate-caret-blink",
|
|
426
|
+
children: /* @__PURE__ */ u("div", { className: "h-8 w-px bg-input-otp-caret" })
|
|
427
|
+
})]
|
|
428
|
+
});
|
|
429
|
+
};
|
|
430
|
+
L.displayName = "InputOTP.Slot";
|
|
431
|
+
var R = ({ start: e = 0, count: t, className: n }) => {
|
|
432
|
+
let { maxLength: r = 0 } = P(), i = t === void 0 ? r : e + t;
|
|
433
|
+
return /* @__PURE__ */ u(l, { children: Array.from({ length: i - e }, (t, n) => e + n).map((e) => /* @__PURE__ */ u(L, {
|
|
434
|
+
index: e,
|
|
435
|
+
className: n
|
|
436
|
+
}, e)) });
|
|
437
|
+
};
|
|
438
|
+
R.displayName = "InputOTP.Slots";
|
|
439
|
+
var z = ({ ref: t, ...n }) => {
|
|
440
|
+
let { variant: r = "outlined" } = P();
|
|
441
|
+
return /* @__PURE__ */ u("div", {
|
|
442
|
+
ref: t,
|
|
443
|
+
role: "separator",
|
|
444
|
+
...n,
|
|
445
|
+
"data-testid": "spectral-input-otp-separator",
|
|
446
|
+
"data-variant": r,
|
|
447
|
+
children: /* @__PURE__ */ u(e, {
|
|
448
|
+
size: 24,
|
|
449
|
+
color: r === "filled" ? "var(--color-input-otp-filled-separator)" : "var(--color-input-otp-border)"
|
|
450
|
+
})
|
|
451
|
+
});
|
|
452
|
+
};
|
|
453
|
+
z.displayName = "InputOTP.Separator";
|
|
454
|
+
var B = Object.assign(F, {
|
|
455
|
+
Group: I,
|
|
456
|
+
Slot: L,
|
|
457
|
+
Slots: R,
|
|
458
|
+
Separator: z
|
|
459
|
+
});
|
|
460
|
+
//#endregion
|
|
461
|
+
export { B as t };
|