@spear-ai/spectral 1.6.2 → 1.6.3
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/InputOTP.d.ts +9 -0
- package/dist/InputOTP.js +206 -200
- package/package.json +1 -1
package/dist/InputOTP.d.ts
CHANGED
|
@@ -20,6 +20,11 @@ export type InputOTPProps = InputOTPRootProps & ({
|
|
|
20
20
|
hasError?: false;
|
|
21
21
|
errorMessage?: never;
|
|
22
22
|
});
|
|
23
|
+
type SlotsProps = {
|
|
24
|
+
start?: number;
|
|
25
|
+
count?: number;
|
|
26
|
+
className?: string;
|
|
27
|
+
};
|
|
23
28
|
export declare const InputOTP: {
|
|
24
29
|
({ ref, autoFocus, children, className, errorMessage, hasError, id, inputMode, maxLength, name, onChange, onComplete, value, variant, ...props }: InputOTPProps & {
|
|
25
30
|
ref?: Ref<ComponentRef<typeof OTPInput>>;
|
|
@@ -39,6 +44,10 @@ export declare const InputOTP: {
|
|
|
39
44
|
}): import("react/jsx-runtime").JSX.Element;
|
|
40
45
|
displayName: string;
|
|
41
46
|
};
|
|
47
|
+
Slots: {
|
|
48
|
+
({ start, count, className }: SlotsProps): import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
displayName: string;
|
|
50
|
+
};
|
|
42
51
|
Separator: {
|
|
43
52
|
({ ref, ...props }: ComponentPropsWithoutRef<"div"> & {
|
|
44
53
|
ref?: Ref<ComponentRef<"div">>;
|
package/dist/InputOTP.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "./styles/main.css";
|
|
3
|
-
import { jsx as
|
|
3
|
+
import { jsx as w, jsxs as bt, Fragment as _t } from "react/jsx-runtime";
|
|
4
4
|
import "./Icons/AnalyzeIcon.js";
|
|
5
5
|
import "./Icons/AnnotationsIcon.js";
|
|
6
6
|
import "./Icons/ApprovedIcon.js";
|
|
@@ -40,7 +40,7 @@ import "./Icons/LocationIcon.js";
|
|
|
40
40
|
import "./Icons/LogoutIcon.js";
|
|
41
41
|
import "./Icons/MessagesIcon.js";
|
|
42
42
|
import "./Icons/MetadataIcon.js";
|
|
43
|
-
import { MinusIcon as
|
|
43
|
+
import { MinusIcon as Ht } from "./Icons/MinusIcon.js";
|
|
44
44
|
import "./Icons/OntologyIcon.js";
|
|
45
45
|
import "./Icons/PanelIconClose.js";
|
|
46
46
|
import "./Icons/PanelIconOpen.js";
|
|
@@ -64,180 +64,180 @@ import "./Icons/WarningIcon.js";
|
|
|
64
64
|
import "./Icons/ZoomAllIcon.js";
|
|
65
65
|
import "./Icons/ZoomXIcon.js";
|
|
66
66
|
import "./Icons/ZoomYIcon.js";
|
|
67
|
-
import { useFormFieldId as
|
|
68
|
-
import { cn as
|
|
69
|
-
import * as
|
|
70
|
-
import { createContext as
|
|
71
|
-
var
|
|
72
|
-
for (var
|
|
73
|
-
if (K) for (var
|
|
67
|
+
import { useFormFieldId as Gt, ErrorMessage as Lt, getErrorMessageId as zt } from "./utils/formFieldUtils.js";
|
|
68
|
+
import { cn as wt } from "./utils/twUtils.js";
|
|
69
|
+
import * as n from "react";
|
|
70
|
+
import { createContext as St, useContext as yt } from "react";
|
|
71
|
+
var $t = Object.defineProperty, Vt = Object.defineProperties, qt = Object.getOwnPropertyDescriptors, K = Object.getOwnPropertySymbols, Et = Object.prototype.hasOwnProperty, Pt = Object.prototype.propertyIsEnumerable, ht = (t, e, o) => e in t ? $t(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, Zt = (t, e) => {
|
|
72
|
+
for (var o in e || (e = {})) Et.call(e, o) && ht(t, o, e[o]);
|
|
73
|
+
if (K) for (var o of K(e)) Pt.call(e, o) && ht(t, o, e[o]);
|
|
74
74
|
return t;
|
|
75
|
-
},
|
|
76
|
-
var
|
|
77
|
-
for (var
|
|
78
|
-
if (t != null && K) for (var
|
|
79
|
-
return
|
|
75
|
+
}, Jt = (t, e) => Vt(t, qt(e)), Kt = (t, e) => {
|
|
76
|
+
var o = {};
|
|
77
|
+
for (var i in t) Et.call(t, i) && e.indexOf(i) < 0 && (o[i] = t[i]);
|
|
78
|
+
if (t != null && K) for (var i of K(t)) e.indexOf(i) < 0 && Pt.call(t, i) && (o[i] = t[i]);
|
|
79
|
+
return o;
|
|
80
80
|
};
|
|
81
|
-
function
|
|
82
|
-
let
|
|
83
|
-
return [
|
|
81
|
+
function Qt(t) {
|
|
82
|
+
let e = setTimeout(t, 0), o = setTimeout(t, 10), i = setTimeout(t, 50);
|
|
83
|
+
return [e, o, i];
|
|
84
84
|
}
|
|
85
|
-
function
|
|
86
|
-
let
|
|
87
|
-
return
|
|
88
|
-
|
|
89
|
-
}),
|
|
85
|
+
function Ut(t) {
|
|
86
|
+
let e = n.useRef();
|
|
87
|
+
return n.useEffect(() => {
|
|
88
|
+
e.current = t;
|
|
89
|
+
}), e.current;
|
|
90
90
|
}
|
|
91
|
-
var
|
|
92
|
-
function
|
|
93
|
-
let [
|
|
94
|
-
let
|
|
95
|
-
if (!
|
|
96
|
-
let
|
|
97
|
-
document.querySelectorAll(
|
|
98
|
-
}, [t,
|
|
99
|
-
return
|
|
100
|
-
let
|
|
101
|
-
if (!
|
|
102
|
-
function
|
|
103
|
-
let
|
|
104
|
-
m(
|
|
91
|
+
var Xt = 18, xt = 40, Yt = `${xt}px`, te = ["[data-lastpass-icon-root]", "com-1password-button", "[data-dashlanecreated]", '[style$="2147483647 !important;"]'].join(",");
|
|
92
|
+
function ee({ containerRef: t, inputRef: e, pushPasswordManagerStrategy: o, isFocused: i }) {
|
|
93
|
+
let [f, s] = n.useState(!1), [d, m] = n.useState(!1), [x, j] = n.useState(!1), T = n.useMemo(() => o === "none" ? !1 : (o === "increase-width" || o === "experimental-no-flickering") && f && d, [f, d, o]), I = n.useCallback(() => {
|
|
94
|
+
let g = t.current, C = e.current;
|
|
95
|
+
if (!g || !C || x || o === "none") return;
|
|
96
|
+
let h = g, S = h.getBoundingClientRect().left + h.offsetWidth, O = h.getBoundingClientRect().top + h.offsetHeight / 2, l = S - Xt, R = O;
|
|
97
|
+
document.querySelectorAll(te).length === 0 && document.elementFromPoint(l, R) === g || (s(!0), j(!0));
|
|
98
|
+
}, [t, e, x, o]);
|
|
99
|
+
return n.useEffect(() => {
|
|
100
|
+
let g = t.current;
|
|
101
|
+
if (!g || o === "none") return;
|
|
102
|
+
function C() {
|
|
103
|
+
let S = window.innerWidth - g.getBoundingClientRect().right;
|
|
104
|
+
m(S >= xt);
|
|
105
105
|
}
|
|
106
|
-
|
|
107
|
-
let
|
|
106
|
+
C();
|
|
107
|
+
let h = setInterval(C, 1e3);
|
|
108
108
|
return () => {
|
|
109
|
-
clearInterval(
|
|
109
|
+
clearInterval(h);
|
|
110
110
|
};
|
|
111
|
-
}, [t,
|
|
112
|
-
let
|
|
113
|
-
if (
|
|
114
|
-
let
|
|
111
|
+
}, [t, o]), n.useEffect(() => {
|
|
112
|
+
let g = i || document.activeElement === e.current;
|
|
113
|
+
if (o === "none" || !g) return;
|
|
114
|
+
let C = setTimeout(I, 0), h = setTimeout(I, 2e3), S = setTimeout(I, 5e3), O = setTimeout(() => {
|
|
115
115
|
j(!0);
|
|
116
116
|
}, 6e3);
|
|
117
117
|
return () => {
|
|
118
|
-
clearTimeout(
|
|
118
|
+
clearTimeout(C), clearTimeout(h), clearTimeout(S), clearTimeout(O);
|
|
119
119
|
};
|
|
120
|
-
}, [
|
|
120
|
+
}, [e, i, o, I]), { hasPWMBadge: f, willPushPWMBadge: T, PWM_BADGE_SPACE_WIDTH: Yt };
|
|
121
121
|
}
|
|
122
|
-
var
|
|
123
|
-
var
|
|
124
|
-
let [
|
|
125
|
-
|
|
126
|
-
}, [
|
|
127
|
-
|
|
128
|
-
let
|
|
129
|
-
if (!
|
|
130
|
-
U.current.value !==
|
|
131
|
-
function
|
|
132
|
-
if (document.activeElement !==
|
|
122
|
+
var re = n.createContext({}), Ct = n.forwardRef((t, e) => {
|
|
123
|
+
var o = t, { value: i, onChange: f, maxLength: s, textAlign: d = "left", pattern: m, placeholder: x, inputMode: j = "numeric", onComplete: T, pushPasswordManagerStrategy: I = "increase-width", pasteTransformer: g, containerClassName: C, noScriptCSSFallback: h = ne, render: S, children: O } = o, l = Kt(o, ["value", "onChange", "maxLength", "textAlign", "pattern", "placeholder", "inputMode", "onComplete", "pushPasswordManagerStrategy", "pasteTransformer", "containerClassName", "noScriptCSSFallback", "render", "children"]), R, at, lt, it, st;
|
|
124
|
+
let [Ot, Rt] = n.useState(typeof l.defaultValue == "string" ? l.defaultValue : ""), p = i ?? Ot, W = Ut(p), L = n.useCallback((r) => {
|
|
125
|
+
f?.(r), Rt(r);
|
|
126
|
+
}, [f]), M = n.useMemo(() => m ? typeof m == "string" ? new RegExp(m) : m : null, [m]), c = n.useRef(null), Q = n.useRef(null), U = n.useRef({ value: p, onChange: L, isIOS: typeof window < "u" && ((at = (R = window?.CSS) == null ? void 0 : R.supports) == null ? void 0 : at.call(R, "-webkit-touch-callout", "none")) }), Z = n.useRef({ prev: [(lt = c.current) == null ? void 0 : lt.selectionStart, (it = c.current) == null ? void 0 : it.selectionEnd, (st = c.current) == null ? void 0 : st.selectionDirection] });
|
|
127
|
+
n.useImperativeHandle(e, () => c.current, []), n.useEffect(() => {
|
|
128
|
+
let r = c.current, a = Q.current;
|
|
129
|
+
if (!r || !a) return;
|
|
130
|
+
U.current.value !== r.value && U.current.onChange(r.value), Z.current.prev = [r.selectionStart, r.selectionEnd, r.selectionDirection];
|
|
131
|
+
function v() {
|
|
132
|
+
if (document.activeElement !== r) {
|
|
133
133
|
$(null), V(null);
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
|
-
let
|
|
137
|
-
if (F.length !== 0 &&
|
|
138
|
-
let
|
|
139
|
-
if (
|
|
140
|
-
let _ =
|
|
136
|
+
let u = r.selectionStart, b = r.selectionEnd, J = r.selectionDirection, P = r.maxLength, F = r.value, k = Z.current.prev, A = -1, D = -1, N;
|
|
137
|
+
if (F.length !== 0 && u !== null && b !== null) {
|
|
138
|
+
let Bt = u === b, Ft = u === F.length && F.length < P;
|
|
139
|
+
if (Bt && !Ft) {
|
|
140
|
+
let _ = u;
|
|
141
141
|
if (_ === 0) A = 0, D = 1, N = "forward";
|
|
142
|
-
else if (_ ===
|
|
143
|
-
else if (
|
|
142
|
+
else if (_ === P) A = _ - 1, D = _, N = "backward";
|
|
143
|
+
else if (P > 1 && F.length > 1) {
|
|
144
144
|
let tt = 0;
|
|
145
|
-
if (
|
|
146
|
-
N = _ <
|
|
147
|
-
let
|
|
148
|
-
N === "backward" && !
|
|
145
|
+
if (k[0] !== null && k[1] !== null) {
|
|
146
|
+
N = _ < k[1] ? "backward" : "forward";
|
|
147
|
+
let Nt = k[0] === k[1] && k[0] < P;
|
|
148
|
+
N === "backward" && !Nt && (tt = -1);
|
|
149
149
|
}
|
|
150
150
|
A = tt + _, D = tt + _ + 1;
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
A !== -1 && D !== -1 && A !== D && c.current.setSelectionRange(A, D, N);
|
|
154
154
|
}
|
|
155
|
-
let
|
|
156
|
-
$(
|
|
155
|
+
let vt = A !== -1 ? A : u, gt = D !== -1 ? D : b, Wt = N ?? J;
|
|
156
|
+
$(vt), V(gt), Z.current.prev = [vt, gt, Wt];
|
|
157
157
|
}
|
|
158
|
-
if (document.addEventListener("selectionchange",
|
|
159
|
-
let
|
|
160
|
-
if (
|
|
161
|
-
let
|
|
162
|
-
q(
|
|
158
|
+
if (document.addEventListener("selectionchange", v, { capture: !0 }), v(), document.activeElement === r && X(!0), !document.getElementById("input-otp-style")) {
|
|
159
|
+
let u = document.createElement("style");
|
|
160
|
+
if (u.id = "input-otp-style", document.head.appendChild(u), u.sheet) {
|
|
161
|
+
let b = "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;";
|
|
162
|
+
q(u.sheet, "[data-input-otp]::selection { background: transparent !important; color: transparent !important; }"), q(u.sheet, `[data-input-otp]:autofill { ${b} }`), q(u.sheet, `[data-input-otp]:-webkit-autofill { ${b} }`), q(u.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; } }"), q(u.sheet, "[data-input-otp] + * { pointer-events: all !important; }");
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
let
|
|
166
|
-
|
|
165
|
+
let y = () => {
|
|
166
|
+
a && a.style.setProperty("--root-height", `${r.clientHeight}px`);
|
|
167
167
|
};
|
|
168
|
-
|
|
169
|
-
let E = new ResizeObserver(
|
|
170
|
-
return E.observe(
|
|
171
|
-
document.removeEventListener("selectionchange",
|
|
168
|
+
y();
|
|
169
|
+
let E = new ResizeObserver(y);
|
|
170
|
+
return E.observe(r), () => {
|
|
171
|
+
document.removeEventListener("selectionchange", v, { capture: !0 }), E.disconnect();
|
|
172
172
|
};
|
|
173
173
|
}, []);
|
|
174
|
-
let [
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
var
|
|
178
|
-
(
|
|
179
|
-
let E = (
|
|
180
|
-
E !== null &&
|
|
174
|
+
let [ut, pt] = n.useState(!1), [z, X] = n.useState(!1), [B, $] = n.useState(null), [H, V] = n.useState(null);
|
|
175
|
+
n.useEffect(() => {
|
|
176
|
+
Qt(() => {
|
|
177
|
+
var r, a, v, y;
|
|
178
|
+
(r = c.current) == null || r.dispatchEvent(new Event("input"));
|
|
179
|
+
let E = (a = c.current) == null ? void 0 : a.selectionStart, u = (v = c.current) == null ? void 0 : v.selectionEnd, b = (y = c.current) == null ? void 0 : y.selectionDirection;
|
|
180
|
+
E !== null && u !== null && ($(E), V(u), Z.current.prev = [E, u, b]);
|
|
181
181
|
});
|
|
182
|
-
}, [p, z]),
|
|
183
|
-
W !== void 0 && p !== W && W.length < s && p.length === s &&
|
|
184
|
-
}, [s,
|
|
185
|
-
let G =
|
|
186
|
-
let
|
|
187
|
-
if (
|
|
188
|
-
|
|
182
|
+
}, [p, z]), n.useEffect(() => {
|
|
183
|
+
W !== void 0 && p !== W && W.length < s && p.length === s && T?.(p);
|
|
184
|
+
}, [s, T, W, p]);
|
|
185
|
+
let G = ee({ containerRef: Q, inputRef: c, pushPasswordManagerStrategy: I, isFocused: z }), ct = n.useCallback((r) => {
|
|
186
|
+
let a = r.currentTarget.value.slice(0, s);
|
|
187
|
+
if (a.length > 0 && M && !M.test(a)) {
|
|
188
|
+
r.preventDefault();
|
|
189
189
|
return;
|
|
190
190
|
}
|
|
191
|
-
typeof W == "string" &&
|
|
192
|
-
}, [s, L, W,
|
|
193
|
-
var
|
|
191
|
+
typeof W == "string" && a.length < W.length && document.dispatchEvent(new Event("selectionchange")), L(a);
|
|
192
|
+
}, [s, L, W, M]), dt = n.useCallback(() => {
|
|
193
|
+
var r;
|
|
194
194
|
if (c.current) {
|
|
195
|
-
let
|
|
196
|
-
(
|
|
195
|
+
let a = Math.min(c.current.value.length, s - 1), v = c.current.value.length;
|
|
196
|
+
(r = c.current) == null || r.setSelectionRange(a, v), $(a), V(v);
|
|
197
197
|
}
|
|
198
198
|
X(!0);
|
|
199
|
-
}, [s]),
|
|
200
|
-
var
|
|
201
|
-
let
|
|
202
|
-
if (!
|
|
203
|
-
let E =
|
|
204
|
-
|
|
205
|
-
let
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
-
let F = Math.min(
|
|
209
|
-
|
|
210
|
-
}, [s, L,
|
|
211
|
-
var
|
|
212
|
-
|
|
213
|
-
}, onChange:
|
|
214
|
-
var
|
|
215
|
-
|
|
216
|
-
}, onMouseLeave: (
|
|
217
|
-
var
|
|
218
|
-
|
|
219
|
-
}, onFocus: (
|
|
220
|
-
var
|
|
221
|
-
|
|
222
|
-
}, onBlur: (
|
|
223
|
-
var
|
|
224
|
-
X(!1), (
|
|
225
|
-
} })), [
|
|
226
|
-
var
|
|
227
|
-
let
|
|
228
|
-
return { char: E, placeholderChar:
|
|
229
|
-
}), isFocused: z, isHovering: !l.disabled &&
|
|
230
|
-
return
|
|
199
|
+
}, [s]), mt = n.useCallback((r) => {
|
|
200
|
+
var a, v;
|
|
201
|
+
let y = c.current;
|
|
202
|
+
if (!g && (!U.current.isIOS || !r.clipboardData || !y)) return;
|
|
203
|
+
let E = r.clipboardData.getData("text/plain"), u = g ? g(E) : E;
|
|
204
|
+
r.preventDefault();
|
|
205
|
+
let b = (a = c.current) == null ? void 0 : a.selectionStart, J = (v = c.current) == null ? void 0 : v.selectionEnd, P = (b !== J ? p.slice(0, b) + u + p.slice(J) : p.slice(0, b) + u + p.slice(b)).slice(0, s);
|
|
206
|
+
if (P.length > 0 && M && !M.test(P)) return;
|
|
207
|
+
y.value = P, L(P);
|
|
208
|
+
let F = Math.min(P.length, s - 1), k = P.length;
|
|
209
|
+
y.setSelectionRange(F, k), $(F), V(k);
|
|
210
|
+
}, [s, L, M, p]), At = n.useMemo(() => ({ position: "relative", cursor: l.disabled ? "default" : "text", userSelect: "none", WebkitUserSelect: "none", pointerEvents: "none" }), [l.disabled]), ft = n.useMemo(() => ({ position: "absolute", inset: 0, width: G.willPushPWMBadge ? `calc(100% + ${G.PWM_BADGE_SPACE_WIDTH})` : "100%", clipPath: G.willPushPWMBadge ? `inset(0 ${G.PWM_BADGE_SPACE_WIDTH} 0 0)` : void 0, height: "100%", display: "flex", textAlign: d, opacity: "1", color: "transparent", pointerEvents: "all", background: "transparent", caretColor: "transparent", border: "0 solid transparent", outline: "0 solid transparent", boxShadow: "none", lineHeight: "1", letterSpacing: "-.5em", fontSize: "var(--root-height)", fontFamily: "monospace", fontVariantNumeric: "tabular-nums" }), [G.PWM_BADGE_SPACE_WIDTH, G.willPushPWMBadge, d]), Dt = n.useMemo(() => n.createElement("input", Jt(Zt({ autoComplete: l.autoComplete || "one-time-code" }, l), { "data-input-otp": !0, "data-input-otp-placeholder-shown": p.length === 0 || void 0, "data-input-otp-mss": B, "data-input-otp-mse": H, inputMode: j, pattern: M?.source, "aria-placeholder": x, style: ft, maxLength: s, value: p, ref: c, onPaste: (r) => {
|
|
211
|
+
var a;
|
|
212
|
+
mt(r), (a = l.onPaste) == null || a.call(l, r);
|
|
213
|
+
}, onChange: ct, onMouseOver: (r) => {
|
|
214
|
+
var a;
|
|
215
|
+
pt(!0), (a = l.onMouseOver) == null || a.call(l, r);
|
|
216
|
+
}, onMouseLeave: (r) => {
|
|
217
|
+
var a;
|
|
218
|
+
pt(!1), (a = l.onMouseLeave) == null || a.call(l, r);
|
|
219
|
+
}, onFocus: (r) => {
|
|
220
|
+
var a;
|
|
221
|
+
dt(), (a = l.onFocus) == null || a.call(l, r);
|
|
222
|
+
}, onBlur: (r) => {
|
|
223
|
+
var a;
|
|
224
|
+
X(!1), (a = l.onBlur) == null || a.call(l, r);
|
|
225
|
+
} })), [ct, dt, mt, j, ft, s, H, B, l, M?.source, p]), Y = n.useMemo(() => ({ slots: Array.from({ length: s }).map((r, a) => {
|
|
226
|
+
var v;
|
|
227
|
+
let y = z && B !== null && H !== null && (B === H && a === B || a >= B && a < H), E = p[a] !== void 0 ? p[a] : null, u = p[0] !== void 0 ? null : (v = x?.[a]) != null ? v : null;
|
|
228
|
+
return { char: E, placeholderChar: u, isActive: y, hasFakeCaret: y && E === null };
|
|
229
|
+
}), isFocused: z, isHovering: !l.disabled && ut }), [z, ut, s, H, B, l.disabled, p]), jt = n.useMemo(() => S ? S(Y) : n.createElement(re.Provider, { value: Y }, O), [O, Y, S]);
|
|
230
|
+
return n.createElement(n.Fragment, null, h !== null && n.createElement("noscript", null, n.createElement("style", null, h)), n.createElement("div", { ref: Q, "data-input-otp-container": !0, style: At, className: C }, jt, n.createElement("div", { style: { position: "absolute", inset: 0, pointerEvents: "none" } }, Dt)));
|
|
231
231
|
});
|
|
232
|
-
|
|
233
|
-
function q(t,
|
|
232
|
+
Ct.displayName = "Input";
|
|
233
|
+
function q(t, e) {
|
|
234
234
|
try {
|
|
235
|
-
t.insertRule(
|
|
235
|
+
t.insertRule(e);
|
|
236
236
|
} catch {
|
|
237
|
-
console.error("input-otp could not insert CSS rule:",
|
|
237
|
+
console.error("input-otp could not insert CSS rule:", e);
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
-
var
|
|
240
|
+
var ne = `
|
|
241
241
|
[data-input-otp] {
|
|
242
242
|
--nojs-bg: white !important;
|
|
243
243
|
--nojs-fg: black !important;
|
|
@@ -257,113 +257,119 @@ var ee = `
|
|
|
257
257
|
--nojs-fg: white !important;
|
|
258
258
|
}
|
|
259
259
|
}`;
|
|
260
|
-
const
|
|
261
|
-
const t =
|
|
260
|
+
const Mt = St({}), Tt = St(null), et = () => {
|
|
261
|
+
const t = yt(Tt);
|
|
262
262
|
if (!t)
|
|
263
263
|
throw new Error("useRoot must be used within an InputOTP");
|
|
264
264
|
return t;
|
|
265
|
-
},
|
|
265
|
+
}, kt = ({
|
|
266
266
|
ref: t,
|
|
267
|
-
autoFocus:
|
|
268
|
-
children:
|
|
269
|
-
className:
|
|
270
|
-
errorMessage:
|
|
267
|
+
autoFocus: e = !1,
|
|
268
|
+
children: o,
|
|
269
|
+
className: i,
|
|
270
|
+
errorMessage: f,
|
|
271
271
|
hasError: s,
|
|
272
|
-
id:
|
|
272
|
+
id: d,
|
|
273
273
|
inputMode: m = "numeric",
|
|
274
|
-
maxLength:
|
|
274
|
+
maxLength: x,
|
|
275
275
|
name: j,
|
|
276
|
-
onChange:
|
|
277
|
-
onComplete:
|
|
278
|
-
value:
|
|
279
|
-
variant:
|
|
280
|
-
...
|
|
276
|
+
onChange: T,
|
|
277
|
+
onComplete: I,
|
|
278
|
+
value: g,
|
|
279
|
+
variant: C = "outlined",
|
|
280
|
+
...h
|
|
281
281
|
}) => {
|
|
282
|
-
const
|
|
283
|
-
const
|
|
284
|
-
|
|
282
|
+
const S = Gt(d, j), O = (l) => {
|
|
283
|
+
const R = l.clipboardData.getData("text/plain").trim().replaceAll("-", "");
|
|
284
|
+
R.length === x && typeof T == "function" && T(R);
|
|
285
285
|
};
|
|
286
|
-
return /* @__PURE__ */
|
|
287
|
-
/* @__PURE__ */
|
|
288
|
-
|
|
286
|
+
return /* @__PURE__ */ w(Mt.Provider, { value: { hasError: s }, children: /* @__PURE__ */ bt("div", { className: "flex w-max flex-col gap-y-1", children: [
|
|
287
|
+
/* @__PURE__ */ w(
|
|
288
|
+
Ct,
|
|
289
289
|
{
|
|
290
|
-
autoFocus:
|
|
291
|
-
containerClassName:
|
|
290
|
+
autoFocus: e,
|
|
291
|
+
containerClassName: wt("flex items-center gap-2 has-[:disabled]:opacity-50 disabled:cursor-not-allowed", i),
|
|
292
292
|
"data-1p-ignore": "true",
|
|
293
293
|
"data-dashlane-disabled-on-field": "true",
|
|
294
294
|
"data-lpignore": "true",
|
|
295
295
|
"data-protonpass-ignore": "true",
|
|
296
296
|
"data-testid": "spectral-input-otp",
|
|
297
|
-
id:
|
|
297
|
+
id: S,
|
|
298
298
|
inputMode: m,
|
|
299
|
-
maxLength:
|
|
300
|
-
onChange:
|
|
301
|
-
onComplete:
|
|
302
|
-
onPaste:
|
|
299
|
+
maxLength: x,
|
|
300
|
+
onChange: T,
|
|
301
|
+
onComplete: I,
|
|
302
|
+
onPaste: O,
|
|
303
303
|
pasteTransformer: (l) => l.replaceAll("-", ""),
|
|
304
304
|
pushPasswordManagerStrategy: "none",
|
|
305
305
|
ref: t,
|
|
306
306
|
role: "textbox",
|
|
307
307
|
textAlign: "center",
|
|
308
|
-
value:
|
|
309
|
-
...
|
|
310
|
-
render: ({ slots: l }) => /* @__PURE__ */
|
|
308
|
+
value: g,
|
|
309
|
+
...h,
|
|
310
|
+
render: ({ slots: l }) => /* @__PURE__ */ w(Tt.Provider, { value: { slots: l, variant: C, maxLength: x }, children: o ?? /* @__PURE__ */ w(rt, { children: /* @__PURE__ */ w(ot, {}) }) })
|
|
311
311
|
}
|
|
312
312
|
),
|
|
313
|
-
s &&
|
|
313
|
+
s && f && /* @__PURE__ */ w(Lt, { dataTestId: "spectral-input-otp-error-message", id: zt(S), message: f })
|
|
314
314
|
] }) });
|
|
315
315
|
};
|
|
316
|
-
|
|
317
|
-
const
|
|
316
|
+
kt.displayName = "InputOTP";
|
|
317
|
+
const rt = ({
|
|
318
318
|
ref: t,
|
|
319
|
-
...
|
|
320
|
-
}) => /* @__PURE__ */
|
|
321
|
-
|
|
322
|
-
const
|
|
319
|
+
...e
|
|
320
|
+
}) => /* @__PURE__ */ w("div", { className: "flex items-center justify-center gap-x-2", "data-testid": "spectral-input-otp-group", ref: t, ...e });
|
|
321
|
+
rt.displayName = "InputOTP.Group";
|
|
322
|
+
const nt = ({
|
|
323
323
|
ref: t,
|
|
324
|
-
index:
|
|
325
|
-
className:
|
|
326
|
-
...
|
|
324
|
+
index: e,
|
|
325
|
+
className: o,
|
|
326
|
+
...i
|
|
327
327
|
}) => {
|
|
328
|
-
const { variant:
|
|
329
|
-
return /* @__PURE__ */
|
|
328
|
+
const { variant: f = "outlined", slots: s = [] } = et(), { hasError: d } = yt(Mt), m = s[e] || { char: "", hasFakeCaret: !0, isActive: !1 };
|
|
329
|
+
return /* @__PURE__ */ bt(
|
|
330
330
|
"div",
|
|
331
331
|
{
|
|
332
|
-
className:
|
|
332
|
+
className: wt(
|
|
333
333
|
"relative z-10 flex h-12 w-10 items-center justify-center rounded-[8px] border-1 transition duration-200 focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2",
|
|
334
|
-
|
|
335
|
-
!
|
|
336
|
-
|
|
337
|
-
m.isActive && !
|
|
338
|
-
m.isActive &&
|
|
339
|
-
|
|
334
|
+
f === "filled" ? "bg-level-one border-level-one" : "border-input-otp-border bg-transparent",
|
|
335
|
+
!d && "border",
|
|
336
|
+
d && "border-danger-400 focus-visible:outline-danger-400 border-2",
|
|
337
|
+
m.isActive && !d && "outline-input-otp-border--focus z-10 outline-2 outline-offset-2",
|
|
338
|
+
m.isActive && d && "outline-danger-400 outline-2 outline-offset-2",
|
|
339
|
+
o
|
|
340
340
|
),
|
|
341
|
-
"data-index":
|
|
341
|
+
"data-index": e,
|
|
342
342
|
"data-testid": "spectral-input-otp-slot",
|
|
343
|
-
"data-variant":
|
|
343
|
+
"data-variant": f,
|
|
344
344
|
ref: t,
|
|
345
|
-
...
|
|
345
|
+
...i,
|
|
346
346
|
children: [
|
|
347
347
|
m.char,
|
|
348
|
-
m.hasFakeCaret && /* @__PURE__ */
|
|
348
|
+
m.hasFakeCaret && /* @__PURE__ */ w("div", { className: "animate-caret-blink pointer-events-none absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ w("div", { className: "bg-input-otp-caret h-8 w-px" }) })
|
|
349
349
|
]
|
|
350
350
|
}
|
|
351
351
|
);
|
|
352
352
|
};
|
|
353
|
-
|
|
354
|
-
const
|
|
353
|
+
nt.displayName = "InputOTP.Slot";
|
|
354
|
+
const ot = ({ start: t = 0, count: e, className: o }) => {
|
|
355
|
+
const { maxLength: i = 0 } = et(), f = e !== void 0 ? t + e : i, s = Array.from({ length: f - t }, (d, m) => t + m);
|
|
356
|
+
return /* @__PURE__ */ w(_t, { children: s.map((d) => /* @__PURE__ */ w(nt, { index: d, className: o }, d)) });
|
|
357
|
+
};
|
|
358
|
+
ot.displayName = "InputOTP.Slots";
|
|
359
|
+
const It = ({
|
|
355
360
|
ref: t,
|
|
356
|
-
...
|
|
361
|
+
...e
|
|
357
362
|
}) => {
|
|
358
|
-
const { variant:
|
|
359
|
-
return /* @__PURE__ */
|
|
363
|
+
const { variant: o = "outlined" } = et();
|
|
364
|
+
return /* @__PURE__ */ w("div", { ref: t, role: "separator", ...e, "data-testid": "spectral-input-otp-separator", "data-variant": o, children: /* @__PURE__ */ w(Ht, { size: 24, color: o === "filled" ? "var(--color-input-otp-filled-separator)" : "var(--color-input-otp-border)" }) });
|
|
360
365
|
};
|
|
361
|
-
|
|
362
|
-
const
|
|
363
|
-
Group:
|
|
364
|
-
Slot:
|
|
365
|
-
|
|
366
|
+
It.displayName = "InputOTP.Separator";
|
|
367
|
+
const hr = Object.assign(kt, {
|
|
368
|
+
Group: rt,
|
|
369
|
+
Slot: nt,
|
|
370
|
+
Slots: ot,
|
|
371
|
+
Separator: It
|
|
366
372
|
});
|
|
367
373
|
export {
|
|
368
|
-
|
|
374
|
+
hr as InputOTP
|
|
369
375
|
};
|