@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.
@@ -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 k, jsxs as ft } from "react/jsx-runtime";
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 Nt } from "./Icons/MinusIcon.js";
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 _t, ErrorMessage as Ht, getErrorMessageId as Gt } from "./utils/formFieldUtils.js";
68
- import { cn as vt } from "./utils/twUtils.js";
69
- import * as r from "react";
70
- import { createContext as gt, useContext as ht } from "react";
71
- var Lt = Object.defineProperty, zt = Object.defineProperties, $t = Object.getOwnPropertyDescriptors, K = Object.getOwnPropertySymbols, bt = Object.prototype.hasOwnProperty, wt = Object.prototype.propertyIsEnumerable, mt = (t, n, a) => n in t ? Lt(t, n, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[n] = a, Vt = (t, n) => {
72
- for (var a in n || (n = {})) bt.call(n, a) && mt(t, a, n[a]);
73
- if (K) for (var a of K(n)) wt.call(n, a) && mt(t, a, n[a]);
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
- }, qt = (t, n) => zt(t, $t(n)), Zt = (t, n) => {
76
- var a = {};
77
- for (var u in t) bt.call(t, u) && n.indexOf(u) < 0 && (a[u] = t[u]);
78
- if (t != null && K) for (var u of K(t)) n.indexOf(u) < 0 && wt.call(t, u) && (a[u] = t[u]);
79
- return a;
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 Jt(t) {
82
- let n = setTimeout(t, 0), a = setTimeout(t, 10), u = setTimeout(t, 50);
83
- return [n, a, u];
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 Kt(t) {
86
- let n = r.useRef();
87
- return r.useEffect(() => {
88
- n.current = t;
89
- }), n.current;
85
+ function Ut(t) {
86
+ let e = n.useRef();
87
+ return n.useEffect(() => {
88
+ e.current = t;
89
+ }), e.current;
90
90
  }
91
- var Qt = 18, xt = 40, Ut = `${xt}px`, Xt = ["[data-lastpass-icon-root]", "com-1password-button", "[data-dashlanecreated]", '[style$="2147483647 !important;"]'].join(",");
92
- function Yt({ containerRef: t, inputRef: n, pushPasswordManagerStrategy: a, isFocused: u }) {
93
- let [v, s] = r.useState(!1), [b, m] = r.useState(!1), [C, j] = r.useState(!1), M = r.useMemo(() => a === "none" ? !1 : (a === "increase-width" || a === "experimental-no-flickering") && v && b, [v, b, a]), R = r.useCallback(() => {
94
- let f = t.current, y = n.current;
95
- if (!f || !y || C || a === "none") return;
96
- let g = f, w = g.getBoundingClientRect().left + g.offsetWidth, I = g.getBoundingClientRect().top + g.offsetHeight / 2, l = w - Qt, O = I;
97
- document.querySelectorAll(Xt).length === 0 && document.elementFromPoint(l, O) === f || (s(!0), j(!0));
98
- }, [t, n, C, a]);
99
- return r.useEffect(() => {
100
- let f = t.current;
101
- if (!f || a === "none") return;
102
- function y() {
103
- let w = window.innerWidth - f.getBoundingClientRect().right;
104
- m(w >= xt);
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
- y();
107
- let g = setInterval(y, 1e3);
106
+ C();
107
+ let h = setInterval(C, 1e3);
108
108
  return () => {
109
- clearInterval(g);
109
+ clearInterval(h);
110
110
  };
111
- }, [t, a]), r.useEffect(() => {
112
- let f = u || document.activeElement === n.current;
113
- if (a === "none" || !f) return;
114
- let y = setTimeout(R, 0), g = setTimeout(R, 2e3), w = setTimeout(R, 5e3), I = setTimeout(() => {
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(y), clearTimeout(g), clearTimeout(w), clearTimeout(I);
118
+ clearTimeout(C), clearTimeout(h), clearTimeout(S), clearTimeout(O);
119
119
  };
120
- }, [n, u, a, R]), { hasPWMBadge: v, willPushPWMBadge: M, PWM_BADGE_SPACE_WIDTH: Ut };
120
+ }, [e, i, o, I]), { hasPWMBadge: f, willPushPWMBadge: T, PWM_BADGE_SPACE_WIDTH: Yt };
121
121
  }
122
- var te = r.createContext({}), Et = r.forwardRef((t, n) => {
123
- var a = t, { value: u, onChange: v, maxLength: s, textAlign: b = "left", pattern: m, placeholder: C, inputMode: j = "numeric", onComplete: M, pushPasswordManagerStrategy: R = "increase-width", pasteTransformer: f, containerClassName: y, noScriptCSSFallback: g = ee, render: w, children: I } = a, l = Zt(a, ["value", "onChange", "maxLength", "textAlign", "pattern", "placeholder", "inputMode", "onComplete", "pushPasswordManagerStrategy", "pasteTransformer", "containerClassName", "noScriptCSSFallback", "render", "children"]), O, et, rt, nt, ot;
124
- let [Rt, It] = r.useState(typeof l.defaultValue == "string" ? l.defaultValue : ""), p = u ?? Rt, W = Kt(p), L = r.useCallback((e) => {
125
- v?.(e), It(e);
126
- }, [v]), P = r.useMemo(() => m ? typeof m == "string" ? new RegExp(m) : m : null, [m]), c = r.useRef(null), Q = r.useRef(null), U = r.useRef({ value: p, onChange: L, isIOS: typeof window < "u" && ((et = (O = window?.CSS) == null ? void 0 : O.supports) == null ? void 0 : et.call(O, "-webkit-touch-callout", "none")) }), Z = r.useRef({ prev: [(rt = c.current) == null ? void 0 : rt.selectionStart, (nt = c.current) == null ? void 0 : nt.selectionEnd, (ot = c.current) == null ? void 0 : ot.selectionDirection] });
127
- r.useImperativeHandle(n, () => c.current, []), r.useEffect(() => {
128
- let e = c.current, o = Q.current;
129
- if (!e || !o) return;
130
- U.current.value !== e.value && U.current.onChange(e.value), Z.current.prev = [e.selectionStart, e.selectionEnd, e.selectionDirection];
131
- function d() {
132
- if (document.activeElement !== e) {
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 i = e.selectionStart, h = e.selectionEnd, J = e.selectionDirection, S = e.maxLength, F = e.value, T = Z.current.prev, A = -1, D = -1, N;
137
- if (F.length !== 0 && i !== null && h !== null) {
138
- let Wt = i === h, Bt = i === F.length && F.length < S;
139
- if (Wt && !Bt) {
140
- let _ = i;
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 (_ === S) A = _ - 1, D = _, N = "backward";
143
- else if (S > 1 && F.length > 1) {
142
+ else if (_ === P) A = _ - 1, D = _, N = "backward";
143
+ else if (P > 1 && F.length > 1) {
144
144
  let tt = 0;
145
- if (T[0] !== null && T[1] !== null) {
146
- N = _ < T[1] ? "backward" : "forward";
147
- let Ft = T[0] === T[1] && T[0] < S;
148
- N === "backward" && !Ft && (tt = -1);
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 ct = A !== -1 ? A : i, dt = D !== -1 ? D : h, jt = N ?? J;
156
- $(ct), V(dt), Z.current.prev = [ct, dt, jt];
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", d, { capture: !0 }), d(), document.activeElement === e && X(!0), !document.getElementById("input-otp-style")) {
159
- let i = document.createElement("style");
160
- if (i.id = "input-otp-style", document.head.appendChild(i), i.sheet) {
161
- let h = "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(i.sheet, "[data-input-otp]::selection { background: transparent !important; color: transparent !important; }"), q(i.sheet, `[data-input-otp]:autofill { ${h} }`), q(i.sheet, `[data-input-otp]:-webkit-autofill { ${h} }`), q(i.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(i.sheet, "[data-input-otp] + * { pointer-events: all !important; }");
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 x = () => {
166
- o && o.style.setProperty("--root-height", `${e.clientHeight}px`);
165
+ let y = () => {
166
+ a && a.style.setProperty("--root-height", `${r.clientHeight}px`);
167
167
  };
168
- x();
169
- let E = new ResizeObserver(x);
170
- return E.observe(e), () => {
171
- document.removeEventListener("selectionchange", d, { capture: !0 }), E.disconnect();
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 [at, lt] = r.useState(!1), [z, X] = r.useState(!1), [B, $] = r.useState(null), [H, V] = r.useState(null);
175
- r.useEffect(() => {
176
- Jt(() => {
177
- var e, o, d, x;
178
- (e = c.current) == null || e.dispatchEvent(new Event("input"));
179
- let E = (o = c.current) == null ? void 0 : o.selectionStart, i = (d = c.current) == null ? void 0 : d.selectionEnd, h = (x = c.current) == null ? void 0 : x.selectionDirection;
180
- E !== null && i !== null && ($(E), V(i), Z.current.prev = [E, i, h]);
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]), r.useEffect(() => {
183
- W !== void 0 && p !== W && W.length < s && p.length === s && M?.(p);
184
- }, [s, M, W, p]);
185
- let G = Yt({ containerRef: Q, inputRef: c, pushPasswordManagerStrategy: R, isFocused: z }), it = r.useCallback((e) => {
186
- let o = e.currentTarget.value.slice(0, s);
187
- if (o.length > 0 && P && !P.test(o)) {
188
- e.preventDefault();
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" && o.length < W.length && document.dispatchEvent(new Event("selectionchange")), L(o);
192
- }, [s, L, W, P]), ut = r.useCallback(() => {
193
- var e;
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 o = Math.min(c.current.value.length, s - 1), d = c.current.value.length;
196
- (e = c.current) == null || e.setSelectionRange(o, d), $(o), V(d);
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]), st = r.useCallback((e) => {
200
- var o, d;
201
- let x = c.current;
202
- if (!f && (!U.current.isIOS || !e.clipboardData || !x)) return;
203
- let E = e.clipboardData.getData("text/plain"), i = f ? f(E) : E;
204
- e.preventDefault();
205
- let h = (o = c.current) == null ? void 0 : o.selectionStart, J = (d = c.current) == null ? void 0 : d.selectionEnd, S = (h !== J ? p.slice(0, h) + i + p.slice(J) : p.slice(0, h) + i + p.slice(h)).slice(0, s);
206
- if (S.length > 0 && P && !P.test(S)) return;
207
- x.value = S, L(S);
208
- let F = Math.min(S.length, s - 1), T = S.length;
209
- x.setSelectionRange(F, T), $(F), V(T);
210
- }, [s, L, P, p]), Ot = r.useMemo(() => ({ position: "relative", cursor: l.disabled ? "default" : "text", userSelect: "none", WebkitUserSelect: "none", pointerEvents: "none" }), [l.disabled]), pt = r.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: b, 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, b]), At = r.useMemo(() => r.createElement("input", qt(Vt({ 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: P?.source, "aria-placeholder": C, style: pt, maxLength: s, value: p, ref: c, onPaste: (e) => {
211
- var o;
212
- st(e), (o = l.onPaste) == null || o.call(l, e);
213
- }, onChange: it, onMouseOver: (e) => {
214
- var o;
215
- lt(!0), (o = l.onMouseOver) == null || o.call(l, e);
216
- }, onMouseLeave: (e) => {
217
- var o;
218
- lt(!1), (o = l.onMouseLeave) == null || o.call(l, e);
219
- }, onFocus: (e) => {
220
- var o;
221
- ut(), (o = l.onFocus) == null || o.call(l, e);
222
- }, onBlur: (e) => {
223
- var o;
224
- X(!1), (o = l.onBlur) == null || o.call(l, e);
225
- } })), [it, ut, st, j, pt, s, H, B, l, P?.source, p]), Y = r.useMemo(() => ({ slots: Array.from({ length: s }).map((e, o) => {
226
- var d;
227
- let x = z && B !== null && H !== null && (B === H && o === B || o >= B && o < H), E = p[o] !== void 0 ? p[o] : null, i = p[0] !== void 0 ? null : (d = C?.[o]) != null ? d : null;
228
- return { char: E, placeholderChar: i, isActive: x, hasFakeCaret: x && E === null };
229
- }), isFocused: z, isHovering: !l.disabled && at }), [z, at, s, H, B, l.disabled, p]), Dt = r.useMemo(() => w ? w(Y) : r.createElement(te.Provider, { value: Y }, I), [I, Y, w]);
230
- return r.createElement(r.Fragment, null, g !== null && r.createElement("noscript", null, r.createElement("style", null, g)), r.createElement("div", { ref: Q, "data-input-otp-container": !0, style: Ot, className: y }, Dt, r.createElement("div", { style: { position: "absolute", inset: 0, pointerEvents: "none" } }, At)));
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
- Et.displayName = "Input";
233
- function q(t, n) {
232
+ Ct.displayName = "Input";
233
+ function q(t, e) {
234
234
  try {
235
- t.insertRule(n);
235
+ t.insertRule(e);
236
236
  } catch {
237
- console.error("input-otp could not insert CSS rule:", n);
237
+ console.error("input-otp could not insert CSS rule:", e);
238
238
  }
239
239
  }
240
- var ee = `
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 St = gt({}), yt = gt(null), Pt = () => {
261
- const t = ht(yt);
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
- }, Ct = ({
265
+ }, kt = ({
266
266
  ref: t,
267
- autoFocus: n = !1,
268
- children: a,
269
- className: u,
270
- errorMessage: v,
267
+ autoFocus: e = !1,
268
+ children: o,
269
+ className: i,
270
+ errorMessage: f,
271
271
  hasError: s,
272
- id: b,
272
+ id: d,
273
273
  inputMode: m = "numeric",
274
- maxLength: C,
274
+ maxLength: x,
275
275
  name: j,
276
- onChange: M,
277
- onComplete: R,
278
- value: f,
279
- variant: y = "outlined",
280
- ...g
276
+ onChange: T,
277
+ onComplete: I,
278
+ value: g,
279
+ variant: C = "outlined",
280
+ ...h
281
281
  }) => {
282
- const w = _t(b, j), I = (l) => {
283
- const O = l.clipboardData.getData("text/plain").trim().replaceAll("-", "");
284
- O.length === C && typeof M == "function" && M(O);
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__ */ k(St.Provider, { value: { hasError: s }, children: /* @__PURE__ */ ft("div", { className: "flex w-max flex-col gap-y-1", children: [
287
- /* @__PURE__ */ k(
288
- Et,
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: n,
291
- containerClassName: vt("flex items-center gap-2 has-[:disabled]:opacity-50 disabled:cursor-not-allowed", u),
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: w,
297
+ id: S,
298
298
  inputMode: m,
299
- maxLength: C,
300
- onChange: M,
301
- onComplete: R,
302
- onPaste: I,
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: f,
309
- ...g,
310
- render: ({ slots: l }) => /* @__PURE__ */ k(yt.Provider, { value: { slots: l, variant: y }, children: a })
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 && v && /* @__PURE__ */ k(Ht, { dataTestId: "spectral-input-otp-error-message", id: Gt(w), message: v })
313
+ s && f && /* @__PURE__ */ w(Lt, { dataTestId: "spectral-input-otp-error-message", id: zt(S), message: f })
314
314
  ] }) });
315
315
  };
316
- Ct.displayName = "InputOTP";
317
- const Mt = ({
316
+ kt.displayName = "InputOTP";
317
+ const rt = ({
318
318
  ref: t,
319
- ...n
320
- }) => /* @__PURE__ */ k("div", { className: "flex items-center justify-center gap-x-2", "data-testid": "spectral-input-otp-group", ref: t, ...n });
321
- Mt.displayName = "InputOTP.Group";
322
- const Tt = ({
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: n,
325
- className: a,
326
- ...u
324
+ index: e,
325
+ className: o,
326
+ ...i
327
327
  }) => {
328
- const { variant: v = "outlined", slots: s = [] } = Pt(), { hasError: b } = ht(St), m = s[n] || { char: "", hasFakeCaret: !0, isActive: !1 };
329
- return /* @__PURE__ */ ft(
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: vt(
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
- v === "filled" ? "bg-level-one border-level-one" : "border-input-otp-border bg-transparent",
335
- !b && "border",
336
- b && "border-danger-400 focus-visible:outline-danger-400 border-2",
337
- m.isActive && !b && "outline-input-otp-border--focus z-10 outline-2 outline-offset-2",
338
- m.isActive && b && "outline-danger-400 outline-2 outline-offset-2",
339
- a
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": n,
341
+ "data-index": e,
342
342
  "data-testid": "spectral-input-otp-slot",
343
- "data-variant": v,
343
+ "data-variant": f,
344
344
  ref: t,
345
- ...u,
345
+ ...i,
346
346
  children: [
347
347
  m.char,
348
- m.hasFakeCaret && /* @__PURE__ */ k("div", { className: "animate-caret-blink pointer-events-none absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ k("div", { className: "bg-input-otp-caret h-8 w-px" }) })
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
- Tt.displayName = "InputOTP.Slot";
354
- const kt = ({
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
- ...n
361
+ ...e
357
362
  }) => {
358
- const { variant: a = "outlined" } = Pt();
359
- return /* @__PURE__ */ k("div", { ref: t, role: "separator", ...n, "data-testid": "spectral-input-otp-separator", "data-variant": a, children: /* @__PURE__ */ k(Nt, { size: 24, color: a === "filled" ? "var(--color-input-otp-filled-separator)" : "var(--color-input-otp-border)" }) });
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
- kt.displayName = "InputOTP.Separator";
362
- const vr = Object.assign(Ct, {
363
- Group: Mt,
364
- Slot: Tt,
365
- Separator: kt
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
- vr as InputOTP
374
+ hr as InputOTP
369
375
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spear-ai/spectral",
3
- "version": "1.6.2",
3
+ "version": "1.6.3",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "repository": {