prometeo-design-system 1.7.6 → 1.8.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.
@@ -1,176 +1,178 @@
1
- import { j as h } from "./jsx-runtime-ByW6EXIE.js";
2
- import { c as he } from "./cn-B6yFEsav.js";
3
- import * as t from "react";
4
- var Re = Object.defineProperty, De = Object.defineProperties, Te = Object.getOwnPropertyDescriptors, K = Object.getOwnPropertySymbols, ve = Object.prototype.hasOwnProperty, ge = Object.prototype.propertyIsEnumerable, me = (n, l, a) => l in n ? Re(n, l, { enumerable: !0, configurable: !0, writable: !0, value: a }) : n[l] = a, Ae = (n, l) => {
5
- for (var a in l || (l = {})) ve.call(l, a) && me(n, a, l[a]);
6
- if (K) for (var a of K(l)) ge.call(l, a) && me(n, a, l[a]);
7
- return n;
8
- }, Oe = (n, l) => De(n, Te(l)), We = (n, l) => {
1
+ import { j as p } from "./jsx-runtime-ByW6EXIE.js";
2
+ import { Icons as ve } from "./Icons.es.js";
3
+ import { c as L } from "./cn-B6yFEsav.js";
4
+ import * as n from "react";
5
+ import ge from "react";
6
+ var De = Object.defineProperty, Te = Object.defineProperties, Oe = Object.getOwnPropertyDescriptors, te = Object.getOwnPropertySymbols, we = Object.prototype.hasOwnProperty, ye = Object.prototype.propertyIsEnumerable, xe = (t, r, a) => r in t ? De(t, r, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[r] = a, We = (t, r) => {
7
+ for (var a in r || (r = {})) we.call(r, a) && xe(t, a, r[a]);
8
+ if (te) for (var a of te(r)) ye.call(r, a) && xe(t, a, r[a]);
9
+ return t;
10
+ }, Ae = (t, r) => Te(t, Oe(r)), Be = (t, r) => {
9
11
  var a = {};
10
- for (var u in n) ve.call(n, u) && l.indexOf(u) < 0 && (a[u] = n[u]);
11
- if (n != null && K) for (var u of K(n)) l.indexOf(u) < 0 && ge.call(n, u) && (a[u] = n[u]);
12
+ for (var u in t) we.call(t, u) && r.indexOf(u) < 0 && (a[u] = t[u]);
13
+ if (t != null && te) for (var u of te(t)) r.indexOf(u) < 0 && ye.call(t, u) && (a[u] = t[u]);
12
14
  return a;
13
15
  };
14
- function Be(n) {
15
- let l = setTimeout(n, 0), a = setTimeout(n, 10), u = setTimeout(n, 50);
16
- return [l, a, u];
16
+ function _e(t) {
17
+ let r = setTimeout(t, 0), a = setTimeout(t, 10), u = setTimeout(t, 50);
18
+ return [r, a, u];
17
19
  }
18
- function Ne(n) {
19
- let l = t.useRef();
20
- return t.useEffect(() => {
21
- l.current = n;
22
- }), l.current;
20
+ function Ie(t) {
21
+ let r = n.useRef();
22
+ return n.useEffect(() => {
23
+ r.current = t;
24
+ }), r.current;
23
25
  }
24
- var Ie = 18, be = 40, _e = `${be}px`, Fe = ["[data-lastpass-icon-root]", "com-1password-button", "[data-dashlanecreated]", '[style$="2147483647 !important;"]'].join(",");
25
- function He({ containerRef: n, inputRef: l, pushPasswordManagerStrategy: a, isFocused: u }) {
26
- let [E, d] = t.useState(!1), [T, y] = t.useState(!1), [k, A] = t.useState(!1), C = t.useMemo(() => a === "none" ? !1 : (a === "increase-width" || a === "experimental-no-flickering") && E && T, [E, T, a]), P = t.useCallback(() => {
27
- let p = n.current, v = l.current;
28
- if (!p || !v || k || a === "none") return;
29
- let x = p, j = x.getBoundingClientRect().left + x.offsetWidth, _ = x.getBoundingClientRect().top + x.offsetHeight / 2, i = j - Ie, L = _;
30
- document.querySelectorAll(Fe).length === 0 && document.elementFromPoint(i, L) === p || (d(!0), A(!0));
31
- }, [n, l, k, a]);
32
- return t.useEffect(() => {
33
- let p = n.current;
34
- if (!p || a === "none") return;
26
+ var Fe = 18, Ee = 40, He = `${Ee}px`, Le = ["[data-lastpass-icon-root]", "com-1password-button", "[data-dashlanecreated]", '[style$="2147483647 !important;"]'].join(",");
27
+ function $e({ containerRef: t, inputRef: r, pushPasswordManagerStrategy: a, isFocused: u }) {
28
+ let [C, d] = n.useState(!1), [R, M] = n.useState(!1), [D, W] = n.useState(!1), A = n.useMemo(() => a === "none" ? !1 : (a === "increase-width" || a === "experimental-no-flickering") && C && R, [C, R, a]), x = n.useCallback(() => {
29
+ let f = t.current, v = r.current;
30
+ if (!f || !v || D || a === "none") return;
31
+ let m = f, b = m.getBoundingClientRect().left + m.offsetWidth, w = m.getBoundingClientRect().top + m.offsetHeight / 2, o = b - Fe, j = w;
32
+ document.querySelectorAll(Le).length === 0 && document.elementFromPoint(o, j) === f || (d(!0), W(!0));
33
+ }, [t, r, D, a]);
34
+ return n.useEffect(() => {
35
+ let f = t.current;
36
+ if (!f || a === "none") return;
35
37
  function v() {
36
- let j = window.innerWidth - p.getBoundingClientRect().right;
37
- y(j >= be);
38
+ let b = window.innerWidth - f.getBoundingClientRect().right;
39
+ M(b >= Ee);
38
40
  }
39
41
  v();
40
- let x = setInterval(v, 1e3);
42
+ let m = setInterval(v, 1e3);
41
43
  return () => {
42
- clearInterval(x);
44
+ clearInterval(m);
43
45
  };
44
- }, [n, a]), t.useEffect(() => {
45
- let p = u || document.activeElement === l.current;
46
- if (a === "none" || !p) return;
47
- let v = setTimeout(P, 0), x = setTimeout(P, 2e3), j = setTimeout(P, 5e3), _ = setTimeout(() => {
48
- A(!0);
46
+ }, [t, a]), n.useEffect(() => {
47
+ let f = u || document.activeElement === r.current;
48
+ if (a === "none" || !f) return;
49
+ let v = setTimeout(x, 0), m = setTimeout(x, 2e3), b = setTimeout(x, 5e3), w = setTimeout(() => {
50
+ W(!0);
49
51
  }, 6e3);
50
52
  return () => {
51
- clearTimeout(v), clearTimeout(x), clearTimeout(j), clearTimeout(_);
53
+ clearTimeout(v), clearTimeout(m), clearTimeout(b), clearTimeout(w);
52
54
  };
53
- }, [l, u, a, P]), { hasPWMBadge: E, willPushPWMBadge: C, PWM_BADGE_SPACE_WIDTH: _e };
55
+ }, [r, u, a, x]), { hasPWMBadge: C, willPushPWMBadge: A, PWM_BADGE_SPACE_WIDTH: He };
54
56
  }
55
- var Le = t.createContext({}), xe = t.forwardRef((n, l) => {
56
- var a = n, { value: u, onChange: E, maxLength: d, textAlign: T = "left", pattern: y, placeholder: k, inputMode: A = "numeric", onComplete: C, pushPasswordManagerStrategy: P = "increase-width", pasteTransformer: p, containerClassName: v, noScriptCSSFallback: x = $e, render: j, children: _ } = a, i = We(a, ["value", "onChange", "maxLength", "textAlign", "pattern", "placeholder", "inputMode", "onComplete", "pushPasswordManagerStrategy", "pasteTransformer", "containerClassName", "noScriptCSSFallback", "render", "children"]), L, te, ne, re, le;
57
- let [we, Ee] = t.useState(typeof i.defaultValue == "string" ? i.defaultValue : ""), s = u ?? we, O = Ne(s), $ = t.useCallback((e) => {
58
- E?.(e), Ee(e);
59
- }, [E]), S = t.useMemo(() => y ? typeof y == "string" ? new RegExp(y) : y : null, [y]), c = t.useRef(null), Q = t.useRef(null), U = t.useRef({ value: s, onChange: $, isIOS: typeof window < "u" && ((te = (L = window?.CSS) == null ? void 0 : L.supports) == null ? void 0 : te.call(L, "-webkit-touch-callout", "none")) }), Z = t.useRef({ prev: [(ne = c.current) == null ? void 0 : ne.selectionStart, (re = c.current) == null ? void 0 : re.selectionEnd, (le = c.current) == null ? void 0 : le.selectionDirection] });
60
- t.useImperativeHandle(l, () => c.current, []), t.useEffect(() => {
61
- let e = c.current, r = Q.current;
62
- if (!e || !r) return;
63
- U.current.value !== e.value && U.current.onChange(e.value), Z.current.prev = [e.selectionStart, e.selectionEnd, e.selectionDirection];
64
- function m() {
57
+ var ze = n.createContext({}), Se = n.forwardRef((t, r) => {
58
+ var a = t, { value: u, onChange: C, maxLength: d, textAlign: R = "left", pattern: M, placeholder: D, inputMode: W = "numeric", onComplete: A, pushPasswordManagerStrategy: x = "increase-width", pasteTransformer: f, containerClassName: v, noScriptCSSFallback: m = Ge, render: b, children: w } = a, o = Be(a, ["value", "onChange", "maxLength", "textAlign", "pattern", "placeholder", "inputMode", "onComplete", "pushPasswordManagerStrategy", "pasteTransformer", "containerClassName", "noScriptCSSFallback", "render", "children"]), j, k, $, V, X;
59
+ let [ne, q] = n.useState(typeof o.defaultValue == "string" ? o.defaultValue : ""), i = u ?? ne, B = Ie(i), Z = n.useCallback((e) => {
60
+ C?.(e), q(e);
61
+ }, [C]), P = n.useMemo(() => M ? typeof M == "string" ? new RegExp(M) : M : null, [M]), c = n.useRef(null), le = n.useRef(null), re = n.useRef({ value: i, onChange: Z, isIOS: typeof window < "u" && ((k = (j = window?.CSS) == null ? void 0 : j.supports) == null ? void 0 : k.call(j, "-webkit-touch-callout", "none")) }), Y = n.useRef({ prev: [($ = c.current) == null ? void 0 : $.selectionStart, (V = c.current) == null ? void 0 : V.selectionEnd, (X = c.current) == null ? void 0 : X.selectionDirection] });
62
+ n.useImperativeHandle(r, () => c.current, []), n.useEffect(() => {
63
+ let e = c.current, l = le.current;
64
+ if (!e || !l) return;
65
+ re.current.value !== e.value && re.current.onChange(e.value), Y.current.prev = [e.selectionStart, e.selectionEnd, e.selectionDirection];
66
+ function h() {
65
67
  if (document.activeElement !== e) {
66
- z(null), V(null);
68
+ K(null), Q(null);
67
69
  return;
68
70
  }
69
- let o = e.selectionStart, f = e.selectionEnd, J = e.selectionDirection, w = e.maxLength, B = e.value, M = Z.current.prev, R = -1, D = -1, N;
70
- if (B.length !== 0 && o !== null && f !== null) {
71
- let je = o === f, Me = o === B.length && B.length < w;
72
- if (je && !Me) {
73
- let I = o;
74
- if (I === 0) R = 0, D = 1, N = "forward";
75
- else if (I === w) R = I - 1, D = I, N = "backward";
76
- else if (w > 1 && B.length > 1) {
77
- let ee = 0;
78
- if (M[0] !== null && M[1] !== null) {
79
- N = I < M[1] ? "backward" : "forward";
80
- let ke = M[0] === M[1] && M[0] < w;
81
- N === "backward" && !ke && (ee = -1);
71
+ let s = e.selectionStart, g = e.selectionEnd, ee = e.selectionDirection, S = e.maxLength, I = e.value, N = Y.current.prev, T = -1, O = -1, F;
72
+ if (I.length !== 0 && s !== null && g !== null) {
73
+ let ke = s === g, Ne = s === I.length && I.length < S;
74
+ if (ke && !Ne) {
75
+ let H = s;
76
+ if (H === 0) T = 0, O = 1, F = "forward";
77
+ else if (H === S) T = H - 1, O = H, F = "backward";
78
+ else if (S > 1 && I.length > 1) {
79
+ let ie = 0;
80
+ if (N[0] !== null && N[1] !== null) {
81
+ F = H < N[1] ? "backward" : "forward";
82
+ let Re = N[0] === N[1] && N[0] < S;
83
+ F === "backward" && !Re && (ie = -1);
82
84
  }
83
- R = ee + I, D = ee + I + 1;
85
+ T = ie + H, O = ie + H + 1;
84
86
  }
85
87
  }
86
- R !== -1 && D !== -1 && R !== D && c.current.setSelectionRange(R, D, N);
88
+ T !== -1 && O !== -1 && T !== O && c.current.setSelectionRange(T, O, F);
87
89
  }
88
- let de = R !== -1 ? R : o, pe = D !== -1 ? D : f, Pe = N ?? J;
89
- z(de), V(pe), Z.current.prev = [de, pe, Pe];
90
+ let me = T !== -1 ? T : s, he = O !== -1 ? O : g, Me = F ?? ee;
91
+ K(me), Q(he), Y.current.prev = [me, he, Me];
90
92
  }
91
- if (document.addEventListener("selectionchange", m, { capture: !0 }), m(), document.activeElement === e && X(!0), !document.getElementById("input-otp-style")) {
92
- let o = document.createElement("style");
93
- if (o.id = "input-otp-style", document.head.appendChild(o), o.sheet) {
94
- let f = "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;";
95
- q(o.sheet, "[data-input-otp]::selection { background: transparent !important; color: transparent !important; }"), q(o.sheet, `[data-input-otp]:autofill { ${f} }`), q(o.sheet, `[data-input-otp]:-webkit-autofill { ${f} }`), q(o.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(o.sheet, "[data-input-otp] + * { pointer-events: all !important; }");
93
+ if (document.addEventListener("selectionchange", h, { capture: !0 }), h(), document.activeElement === e && ae(!0), !document.getElementById("input-otp-style")) {
94
+ let s = document.createElement("style");
95
+ if (s.id = "input-otp-style", document.head.appendChild(s), s.sheet) {
96
+ let g = "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;";
97
+ U(s.sheet, "[data-input-otp]::selection { background: transparent !important; color: transparent !important; }"), U(s.sheet, `[data-input-otp]:autofill { ${g} }`), U(s.sheet, `[data-input-otp]:-webkit-autofill { ${g} }`), U(s.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; } }"), U(s.sheet, "[data-input-otp] + * { pointer-events: all !important; }");
96
98
  }
97
99
  }
98
- let g = () => {
99
- r && r.style.setProperty("--root-height", `${e.clientHeight}px`);
100
+ let y = () => {
101
+ l && l.style.setProperty("--root-height", `${e.clientHeight}px`);
100
102
  };
101
- g();
102
- let b = new ResizeObserver(g);
103
- return b.observe(e), () => {
104
- document.removeEventListener("selectionchange", m, { capture: !0 }), b.disconnect();
103
+ y();
104
+ let E = new ResizeObserver(y);
105
+ return E.observe(e), () => {
106
+ document.removeEventListener("selectionchange", h, { capture: !0 }), E.disconnect();
105
107
  };
106
108
  }, []);
107
- let [ae, oe] = t.useState(!1), [G, X] = t.useState(!1), [W, z] = t.useState(null), [F, V] = t.useState(null);
108
- t.useEffect(() => {
109
- Be(() => {
110
- var e, r, m, g;
109
+ let [se, ue] = n.useState(!1), [J, ae] = n.useState(!1), [_, K] = n.useState(null), [z, Q] = n.useState(null);
110
+ n.useEffect(() => {
111
+ _e(() => {
112
+ var e, l, h, y;
111
113
  (e = c.current) == null || e.dispatchEvent(new Event("input"));
112
- let b = (r = c.current) == null ? void 0 : r.selectionStart, o = (m = c.current) == null ? void 0 : m.selectionEnd, f = (g = c.current) == null ? void 0 : g.selectionDirection;
113
- b !== null && o !== null && (z(b), V(o), Z.current.prev = [b, o, f]);
114
+ let E = (l = c.current) == null ? void 0 : l.selectionStart, s = (h = c.current) == null ? void 0 : h.selectionEnd, g = (y = c.current) == null ? void 0 : y.selectionDirection;
115
+ E !== null && s !== null && (K(E), Q(s), Y.current.prev = [E, s, g]);
114
116
  });
115
- }, [s, G]), t.useEffect(() => {
116
- O !== void 0 && s !== O && O.length < d && s.length === d && C?.(s);
117
- }, [d, C, O, s]);
118
- let H = He({ containerRef: Q, inputRef: c, pushPasswordManagerStrategy: P, isFocused: G }), ie = t.useCallback((e) => {
119
- let r = e.currentTarget.value.slice(0, d);
120
- if (r.length > 0 && S && !S.test(r)) {
117
+ }, [i, J]), n.useEffect(() => {
118
+ B !== void 0 && i !== B && B.length < d && i.length === d && A?.(i);
119
+ }, [d, A, B, i]);
120
+ let G = $e({ containerRef: le, inputRef: c, pushPasswordManagerStrategy: x, isFocused: J }), ce = n.useCallback((e) => {
121
+ let l = e.currentTarget.value.slice(0, d);
122
+ if (l.length > 0 && P && !P.test(l)) {
121
123
  e.preventDefault();
122
124
  return;
123
125
  }
124
- typeof O == "string" && r.length < O.length && document.dispatchEvent(new Event("selectionchange")), $(r);
125
- }, [d, $, O, S]), ue = t.useCallback(() => {
126
+ typeof B == "string" && l.length < B.length && document.dispatchEvent(new Event("selectionchange")), Z(l);
127
+ }, [d, Z, B, P]), de = n.useCallback(() => {
126
128
  var e;
127
129
  if (c.current) {
128
- let r = Math.min(c.current.value.length, d - 1), m = c.current.value.length;
129
- (e = c.current) == null || e.setSelectionRange(r, m), z(r), V(m);
130
+ let l = Math.min(c.current.value.length, d - 1), h = c.current.value.length;
131
+ (e = c.current) == null || e.setSelectionRange(l, h), K(l), Q(h);
130
132
  }
131
- X(!0);
132
- }, [d]), se = t.useCallback((e) => {
133
- var r, m;
134
- let g = c.current;
135
- if (!p && (!U.current.isIOS || !e.clipboardData || !g)) return;
136
- let b = e.clipboardData.getData("text/plain"), o = p ? p(b) : b;
133
+ ae(!0);
134
+ }, [d]), fe = n.useCallback((e) => {
135
+ var l, h;
136
+ let y = c.current;
137
+ if (!f && (!re.current.isIOS || !e.clipboardData || !y)) return;
138
+ let E = e.clipboardData.getData("text/plain"), s = f ? f(E) : E;
137
139
  e.preventDefault();
138
- let f = (r = c.current) == null ? void 0 : r.selectionStart, J = (m = c.current) == null ? void 0 : m.selectionEnd, w = (f !== J ? s.slice(0, f) + o + s.slice(J) : s.slice(0, f) + o + s.slice(f)).slice(0, d);
139
- if (w.length > 0 && S && !S.test(w)) return;
140
- g.value = w, $(w);
141
- let B = Math.min(w.length, d - 1), M = w.length;
142
- g.setSelectionRange(B, M), z(B), V(M);
143
- }, [d, $, S, s]), Se = t.useMemo(() => ({ position: "relative", cursor: i.disabled ? "default" : "text", userSelect: "none", WebkitUserSelect: "none", pointerEvents: "none" }), [i.disabled]), ce = t.useMemo(() => ({ position: "absolute", inset: 0, width: H.willPushPWMBadge ? `calc(100% + ${H.PWM_BADGE_SPACE_WIDTH})` : "100%", clipPath: H.willPushPWMBadge ? `inset(0 ${H.PWM_BADGE_SPACE_WIDTH} 0 0)` : void 0, height: "100%", display: "flex", textAlign: T, 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" }), [H.PWM_BADGE_SPACE_WIDTH, H.willPushPWMBadge, T]), ye = t.useMemo(() => t.createElement("input", Oe(Ae({ autoComplete: i.autoComplete || "one-time-code" }, i), { "data-input-otp": !0, "data-input-otp-placeholder-shown": s.length === 0 || void 0, "data-input-otp-mss": W, "data-input-otp-mse": F, inputMode: A, pattern: S?.source, "aria-placeholder": k, style: ce, maxLength: d, value: s, ref: c, onPaste: (e) => {
144
- var r;
145
- se(e), (r = i.onPaste) == null || r.call(i, e);
146
- }, onChange: ie, onMouseOver: (e) => {
147
- var r;
148
- oe(!0), (r = i.onMouseOver) == null || r.call(i, e);
140
+ let g = (l = c.current) == null ? void 0 : l.selectionStart, ee = (h = c.current) == null ? void 0 : h.selectionEnd, S = (g !== ee ? i.slice(0, g) + s + i.slice(ee) : i.slice(0, g) + s + i.slice(g)).slice(0, d);
141
+ if (S.length > 0 && P && !P.test(S)) return;
142
+ y.value = S, Z(S);
143
+ let I = Math.min(S.length, d - 1), N = S.length;
144
+ y.setSelectionRange(I, N), K(I), Q(N);
145
+ }, [d, Z, P, i]), je = n.useMemo(() => ({ position: "relative", cursor: o.disabled ? "default" : "text", userSelect: "none", WebkitUserSelect: "none", pointerEvents: "none" }), [o.disabled]), pe = 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: R, 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, R]), Pe = n.useMemo(() => n.createElement("input", Ae(We({ autoComplete: o.autoComplete || "one-time-code" }, o), { "data-input-otp": !0, "data-input-otp-placeholder-shown": i.length === 0 || void 0, "data-input-otp-mss": _, "data-input-otp-mse": z, inputMode: W, pattern: P?.source, "aria-placeholder": D, style: pe, maxLength: d, value: i, ref: c, onPaste: (e) => {
146
+ var l;
147
+ fe(e), (l = o.onPaste) == null || l.call(o, e);
148
+ }, onChange: ce, onMouseOver: (e) => {
149
+ var l;
150
+ ue(!0), (l = o.onMouseOver) == null || l.call(o, e);
149
151
  }, onMouseLeave: (e) => {
150
- var r;
151
- oe(!1), (r = i.onMouseLeave) == null || r.call(i, e);
152
+ var l;
153
+ ue(!1), (l = o.onMouseLeave) == null || l.call(o, e);
152
154
  }, onFocus: (e) => {
153
- var r;
154
- ue(), (r = i.onFocus) == null || r.call(i, e);
155
+ var l;
156
+ de(), (l = o.onFocus) == null || l.call(o, e);
155
157
  }, onBlur: (e) => {
156
- var r;
157
- X(!1), (r = i.onBlur) == null || r.call(i, e);
158
- } })), [ie, ue, se, A, ce, d, F, W, i, S?.source, s]), Y = t.useMemo(() => ({ slots: Array.from({ length: d }).map((e, r) => {
159
- var m;
160
- let g = G && W !== null && F !== null && (W === F && r === W || r >= W && r < F), b = s[r] !== void 0 ? s[r] : null, o = s[0] !== void 0 ? null : (m = k?.[r]) != null ? m : null;
161
- return { char: b, placeholderChar: o, isActive: g, hasFakeCaret: g && b === null };
162
- }), isFocused: G, isHovering: !i.disabled && ae }), [G, ae, d, F, W, i.disabled, s]), Ce = t.useMemo(() => j ? j(Y) : t.createElement(Le.Provider, { value: Y }, _), [_, Y, j]);
163
- return t.createElement(t.Fragment, null, x !== null && t.createElement("noscript", null, t.createElement("style", null, x)), t.createElement("div", { ref: Q, "data-input-otp-container": !0, style: Se, className: v }, Ce, t.createElement("div", { style: { position: "absolute", inset: 0, pointerEvents: "none" } }, ye)));
158
+ var l;
159
+ ae(!1), (l = o.onBlur) == null || l.call(o, e);
160
+ } })), [ce, de, fe, W, pe, d, z, _, o, P?.source, i]), oe = n.useMemo(() => ({ slots: Array.from({ length: d }).map((e, l) => {
161
+ var h;
162
+ let y = J && _ !== null && z !== null && (_ === z && l === _ || l >= _ && l < z), E = i[l] !== void 0 ? i[l] : null, s = i[0] !== void 0 ? null : (h = D?.[l]) != null ? h : null;
163
+ return { char: E, placeholderChar: s, isActive: y, hasFakeCaret: y && E === null };
164
+ }), isFocused: J, isHovering: !o.disabled && se }), [J, se, d, z, _, o.disabled, i]), Ce = n.useMemo(() => b ? b(oe) : n.createElement(ze.Provider, { value: oe }, w), [w, oe, b]);
165
+ return n.createElement(n.Fragment, null, m !== null && n.createElement("noscript", null, n.createElement("style", null, m)), n.createElement("div", { ref: le, "data-input-otp-container": !0, style: je, className: v }, Ce, n.createElement("div", { style: { position: "absolute", inset: 0, pointerEvents: "none" } }, Pe)));
164
166
  });
165
- xe.displayName = "Input";
166
- function q(n, l) {
167
+ Se.displayName = "Input";
168
+ function U(t, r) {
167
169
  try {
168
- n.insertRule(l);
170
+ t.insertRule(r);
169
171
  } catch {
170
- console.error("input-otp could not insert CSS rule:", l);
172
+ console.error("input-otp could not insert CSS rule:", r);
171
173
  }
172
174
  }
173
- var $e = `
175
+ var Ge = `
174
176
  [data-input-otp] {
175
177
  --nojs-bg: white !important;
176
178
  --nojs-fg: black !important;
@@ -190,55 +192,105 @@ var $e = `
190
192
  --nojs-fg: white !important;
191
193
  }
192
194
  }`;
193
- const Ve = ({
194
- value: n = "",
195
- onChange: l,
196
- onComplete: a,
197
- maxLength: u = 6,
198
- placeholder: E = "•",
199
- disabled: d = !1,
200
- className: T,
201
- autoFocus: y = !1,
202
- pasteTransformer: k,
203
- errorComponent: A,
204
- hasError: C
205
- }) => /* @__PURE__ */ h.jsx(
206
- xe,
207
- {
208
- value: n,
209
- autoFocus: y,
210
- onChange: l,
211
- onComplete: a,
212
- maxLength: u,
213
- disabled: d,
214
- pasteTransformer: k,
215
- containerClassName: he("group flex items-center has-[:disabled]:opacity-30", T),
216
- render: ({ slots: P }) => /* @__PURE__ */ h.jsxs("div", { className: "flex flex-col items-center", children: [
217
- /* @__PURE__ */ h.jsxs("div", { className: "flex items-center", children: [
218
- /* @__PURE__ */ h.jsx("div", { className: "flex", children: P.slice(0, 3).map((p, v) => /* @__PURE__ */ h.jsx(fe, { ...p, placeholder: E, hasError: C }, v)) }),
219
- /* @__PURE__ */ h.jsx("hr", { className: "w-2 h-1 mx-2 border-neutral-default-default" }),
220
- /* @__PURE__ */ h.jsx("div", { className: "flex", children: P.slice(3).map((p, v) => /* @__PURE__ */ h.jsx(fe, { ...p, placeholder: E, hasError: C }, v)) })
221
- ] }),
222
- C && /* @__PURE__ */ h.jsx("span", { className: "text-error-default-default text-xs mt-1", children: A })
223
- ] })
224
- }
225
- ), fe = (n) => /* @__PURE__ */ h.jsxs(
226
- "div",
227
- {
228
- className: he(
229
- "relative w-14 h-14 text-[1.2rem] text-white",
230
- "flex items-center justify-center",
231
- "transition-all duration-300",
232
- "border-2 border-neutral-default-default rounded-md mx-1",
233
- { "border-2 border-primary-default-default": n.isActive },
234
- n.hasError && "border-error-default-default"
235
- ),
236
- children: [
237
- /* @__PURE__ */ h.jsx("div", { className: "group-has-[input[data-input-otp-placeholder-shown]]:opacity-20", children: n.char ?? n.placeholder }),
238
- n.hasFakeCaret && /* @__PURE__ */ h.jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ h.jsx("div", { className: "w-3 h-1 rounded-full bg-neutral-default-default animate-pulse" }) })
239
- ]
240
- }
241
- );
195
+ const Ke = ({
196
+ value: t = "",
197
+ name: r,
198
+ onChange: a,
199
+ onComplete: u,
200
+ onBlur: C,
201
+ maxLength: d = 6,
202
+ placeholder: R = "•",
203
+ disabled: M = !1,
204
+ className: D,
205
+ autoFocus: W = !1,
206
+ pasteTransformer: A,
207
+ errorComponent: x,
208
+ hasError: f,
209
+ helperComponent: v,
210
+ helperAlignment: m = "left",
211
+ slotClassName: b,
212
+ variant: w = "default",
213
+ hideSlotsMiddleSeparator: o = !1
214
+ }) => {
215
+ const j = m === "left" ? "justify-start w-full text-left" : m === "center" ? "justify-center" : "justify-end text-right w-full", k = {
216
+ default: {
217
+ text: "text-neutral-default-default",
218
+ icon: null
219
+ },
220
+ error: {
221
+ text: "text-error-default-default",
222
+ icon: /* @__PURE__ */ p.jsx(ve.Error, { size: 18, className: "text-error-default-default" })
223
+ },
224
+ success: {
225
+ text: "text-success-default-default",
226
+ icon: /* @__PURE__ */ p.jsx(ve.Check, { size: 18, className: "text-success-default-default" })
227
+ }
228
+ };
229
+ return /* @__PURE__ */ p.jsx(
230
+ Se,
231
+ {
232
+ value: t,
233
+ name: r,
234
+ autoFocus: W,
235
+ onChange: a,
236
+ onComplete: u,
237
+ onBlur: C,
238
+ maxLength: d,
239
+ disabled: M,
240
+ pasteTransformer: A,
241
+ spellCheck: !1,
242
+ containerClassName: L("group flex items-center has-[:disabled]:opacity-30 w-max justify-center", D),
243
+ render: ({ slots: $ }) => {
244
+ const V = Math.floor($.length / 2), X = $.slice(0, V), ne = $.slice(V);
245
+ return /* @__PURE__ */ p.jsxs("div", { className: "flex flex-col items-center", children: [
246
+ /* @__PURE__ */ p.jsxs("div", { className: "flex items-center", children: [
247
+ /* @__PURE__ */ p.jsx("div", { className: "flex", children: X.map((q, i) => /* @__PURE__ */ p.jsx(be, { ...q, placeholder: R, hasError: f, className: b, variant: w }, i)) }),
248
+ /* @__PURE__ */ p.jsx("hr", { className: L("w-2 h-1 mx-2 border-neutral-default-default", o && "hidden") }),
249
+ /* @__PURE__ */ p.jsx("div", { className: "flex", children: ne.map((q, i) => /* @__PURE__ */ p.jsx(be, { ...q, placeholder: R, hasError: f, variant: w, className: b }, i)) })
250
+ ] }),
251
+ f && x && (typeof x == "string" ? /* @__PURE__ */ p.jsxs("span", { className: L("text-error-default-default text-xs mt-1 flex items-center gap-1", j, k.error.text), children: [
252
+ k.error.icon,
253
+ x
254
+ ] }) : ge.cloneElement(x, { className: L(
255
+ "text-error-default-default text-xs mt-1",
256
+ j,
257
+ k.error.text,
258
+ x?.props?.className
259
+ ) })),
260
+ v && m && (typeof v == "string" ? /* @__PURE__ */ p.jsxs("span", { className: L("text-neutral-medium-default text-xs mt-1 flex items-center gap-1", k[w].text, j), children: [
261
+ k[w].icon,
262
+ v
263
+ ] }) : ge.cloneElement(v, { className: L("text-neutral-medium-default text-xs mt-1", j, k[w].text, v?.props?.className) }))
264
+ ] });
265
+ }
266
+ }
267
+ );
268
+ }, be = (t) => {
269
+ const r = {
270
+ default: "border-neutral-default-default",
271
+ error: "border-error-default-default",
272
+ success: "border-success-default-default"
273
+ };
274
+ return /* @__PURE__ */ p.jsxs(
275
+ "div",
276
+ {
277
+ className: L(
278
+ "relative w-14 h-14 text-[1.2rem] text-white",
279
+ "flex items-center justify-center",
280
+ "transition-all duration-300",
281
+ "border-2 border-neutral-default-default rounded-md mx-1",
282
+ { "border-2 border-primary-default-default": t.isActive },
283
+ r[t.variant || "default"],
284
+ t.className,
285
+ t.hasError && r.error
286
+ ),
287
+ children: [
288
+ /* @__PURE__ */ p.jsx("div", { className: "group-has-[input[data-input-otp-placeholder-shown]]:opacity-20", children: t.char ?? t.placeholder }),
289
+ t.hasFakeCaret && /* @__PURE__ */ p.jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ p.jsx("div", { className: "w-3 h-1 rounded-full bg-neutral-default-default animate-pulse" }) })
290
+ ]
291
+ }
292
+ );
293
+ };
242
294
  export {
243
- Ve as default
295
+ Ke as default
244
296
  };