docthub-core-components 3.3.8 → 3.3.9
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.
|
@@ -5,97 +5,97 @@ import { useRef as _, useId as G, useLayoutEffect as tt } from "react";
|
|
|
5
5
|
import { Input as et } from "../../../ui/input.js";
|
|
6
6
|
import { Label as rt } from "../../../ui/label.js";
|
|
7
7
|
import { cn as Y } from "../../../../lib/utils.js";
|
|
8
|
-
const
|
|
8
|
+
const ut = (N) => {
|
|
9
9
|
const t = x(46), {
|
|
10
10
|
length: H,
|
|
11
|
-
label:
|
|
11
|
+
label: f,
|
|
12
12
|
value: d,
|
|
13
13
|
onChange: j,
|
|
14
14
|
onComplete: g,
|
|
15
15
|
className: C,
|
|
16
|
-
error:
|
|
16
|
+
error: n,
|
|
17
17
|
inputClassName: J,
|
|
18
18
|
autoFocus: Q,
|
|
19
19
|
autoSubmit: U,
|
|
20
20
|
secure: V
|
|
21
|
-
} =
|
|
21
|
+
} = N, o = H === void 0 ? 6 : H, K = J === void 0 ? "h-10 w-10" : J, q = Q === void 0 ? !1 : Q, L = U === void 0 ? !1 : U, E = V === void 0 ? !1 : V;
|
|
22
22
|
let M;
|
|
23
23
|
t[0] === Symbol.for("react.memo_cache_sentinel") ? (M = [], t[0] = M) : M = t[0];
|
|
24
24
|
const a = _(M), h = G(), v = G(), S = G();
|
|
25
25
|
let O;
|
|
26
26
|
if (t[1] !== o || t[2] !== S) {
|
|
27
|
-
let
|
|
28
|
-
t[4] !== S ? (
|
|
27
|
+
let i;
|
|
28
|
+
t[4] !== S ? (i = (W, z) => `${S}-digit-${z + 1}`, t[4] = S, t[5] = i) : i = t[5], O = Array.from({
|
|
29
29
|
length: o
|
|
30
|
-
},
|
|
30
|
+
}, i), t[1] = o, t[2] = S, t[3] = O;
|
|
31
31
|
} else
|
|
32
32
|
O = t[3];
|
|
33
33
|
const T = O;
|
|
34
34
|
let A, P;
|
|
35
35
|
t[6] !== q ? (A = () => {
|
|
36
|
-
var
|
|
37
|
-
q && ((
|
|
36
|
+
var i;
|
|
37
|
+
q && ((i = a.current[0]) == null || i.focus({
|
|
38
38
|
preventScroll: !0
|
|
39
39
|
}));
|
|
40
40
|
}, P = [q], t[6] = q, t[7] = A, t[8] = P) : (A = t[7], P = t[8]), tt(A, P);
|
|
41
|
-
let b, y, D, I, u,
|
|
42
|
-
if (t[9] !== L || t[10] !== C || t[11] !==
|
|
43
|
-
const
|
|
44
|
-
var
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
41
|
+
let b, y, D, I, u, m;
|
|
42
|
+
if (t[9] !== L || t[10] !== C || t[11] !== n || t[12] !== v || t[13] !== K || t[14] !== f || t[15] !== h || t[16] !== o || t[17] !== j || t[18] !== g || t[19] !== T || t[20] !== E || t[21] !== d) {
|
|
43
|
+
const i = (r, e) => {
|
|
44
|
+
var c;
|
|
45
|
+
const l = e.replace(/\D/g, "").slice(0, 1);
|
|
46
|
+
if (e && !l || e.length > 1 && l.length <= 1)
|
|
47
47
|
return;
|
|
48
|
-
const
|
|
49
|
-
r
|
|
48
|
+
const s = [...d];
|
|
49
|
+
s[r] = l, j(s), l && r < o - 1 && ((c = a.current[r + 1]) == null || c.focus()), s.every(st) && (g && g(s.join("")), L && queueMicrotask(() => {
|
|
50
50
|
var $;
|
|
51
|
-
const B = ($ = a.current[
|
|
51
|
+
const B = ($ = a.current[r]) == null ? void 0 : $.closest("form");
|
|
52
52
|
B && B.requestSubmit();
|
|
53
53
|
}));
|
|
54
|
-
}, W = (
|
|
54
|
+
}, W = (r, e) => {
|
|
55
55
|
var $;
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
const s = (e.clipboardData.getData("text") || "").replace(/\D/g, "").slice(0, o - r).split("");
|
|
58
|
+
if (s.length === 0)
|
|
59
59
|
return;
|
|
60
|
-
const
|
|
61
|
-
for (let p = 0; p <
|
|
62
|
-
|
|
63
|
-
j(
|
|
64
|
-
const B = Math.min(
|
|
65
|
-
($ = a.current[B]) == null || $.focus(),
|
|
60
|
+
const c = [...d];
|
|
61
|
+
for (let p = 0; p < s.length && r + p < o; p++)
|
|
62
|
+
c[r + p] = s[p];
|
|
63
|
+
j(c);
|
|
64
|
+
const B = Math.min(r + s.length, o - 1);
|
|
65
|
+
($ = a.current[B]) == null || $.focus(), c.every(ot) && (g && g(c.join("")), L && queueMicrotask(() => {
|
|
66
66
|
var X;
|
|
67
|
-
const p = (X = a.current[
|
|
67
|
+
const p = (X = a.current[r]) == null ? void 0 : X.closest("form");
|
|
68
68
|
p && p.requestSubmit();
|
|
69
69
|
}));
|
|
70
|
-
}, z = (
|
|
71
|
-
var
|
|
72
|
-
|
|
70
|
+
}, z = (r, e) => {
|
|
71
|
+
var l, s, c;
|
|
72
|
+
e.key.length === 1 && !/\d/.test(e.key) ? e.preventDefault() : e.key === "Backspace" && !d[r] && r > 0 ? (l = a.current[r - 1]) == null || l.focus() : e.key === "ArrowLeft" && r > 0 ? (e.preventDefault(), (s = a.current[r - 1]) == null || s.focus()) : e.key === "ArrowRight" && r < o - 1 && (e.preventDefault(), (c = a.current[r + 1]) == null || c.focus());
|
|
73
73
|
};
|
|
74
|
-
t[28] !== C ? (u = Y("space-y-2", C), t[28] = C, t[29] = u) : u = t[29], t[30] !==
|
|
75
|
-
const
|
|
76
|
-
return /* @__PURE__ */ F(et, { ref: (
|
|
77
|
-
a.current[
|
|
78
|
-
}, type: E ? "password" : "text", inputMode: "numeric", maxLength: 1, value:
|
|
79
|
-
}), t[9] = L, t[10] = C, t[11] =
|
|
74
|
+
t[28] !== C ? (u = Y("space-y-2", C), t[28] = C, t[29] = u) : u = t[29], t[30] !== f || t[31] !== h ? (m = f && /* @__PURE__ */ F(rt, { id: h, className: "text-sm font-medium text-gray-700", children: f }), t[30] = f, t[31] = h, t[32] = m) : m = t[32], b = "flex gap-2 border-0 p-0 m-0", y = f ? h : void 0, D = n ? v : void 0, I = T.map((r, e) => {
|
|
75
|
+
const l = d[e] ?? "";
|
|
76
|
+
return /* @__PURE__ */ F(et, { ref: (s) => {
|
|
77
|
+
a.current[e] = s;
|
|
78
|
+
}, type: E ? "password" : "text", inputMode: "numeric", maxLength: 1, value: l, onChange: (s) => i(e, s.target.value), onKeyDown: (s) => z(e, s), onPaste: (s) => W(e, s), className: Y("text-center p-0 text-lg font-semibold", n && "border-destructive", K), "aria-label": `${f || "OTP"} digit ${e + 1} of ${o}`, "aria-invalid": n ? "true" : "false" }, r);
|
|
79
|
+
}), t[9] = L, t[10] = C, t[11] = n, t[12] = v, t[13] = K, t[14] = f, t[15] = h, t[16] = o, t[17] = j, t[18] = g, t[19] = T, t[20] = E, t[21] = d, t[22] = b, t[23] = y, t[24] = D, t[25] = I, t[26] = u, t[27] = m;
|
|
80
80
|
} else
|
|
81
|
-
b = t[22], y = t[23], D = t[24], I = t[25], u = t[26],
|
|
81
|
+
b = t[22], y = t[23], D = t[24], I = t[25], u = t[26], m = t[27];
|
|
82
|
+
let k;
|
|
83
|
+
t[33] !== b || t[34] !== y || t[35] !== D || t[36] !== I ? (k = /* @__PURE__ */ F("fieldset", { className: b, "aria-labelledby": y, "aria-describedby": D, children: I }), t[33] = b, t[34] = y, t[35] = D, t[36] = I, t[37] = k) : k = t[37];
|
|
82
84
|
let w;
|
|
83
|
-
t[
|
|
84
|
-
let N;
|
|
85
|
-
t[38] !== c || t[39] !== v ? (N = c && /* @__PURE__ */ F("p", { id: v, className: "text-xs text-destructive mt-1", role: "alert", children: c }), t[38] = c, t[39] = v, t[40] = N) : N = t[40];
|
|
85
|
+
t[38] !== n || t[39] !== v ? (w = n && /* @__PURE__ */ F("p", { id: v, className: "text-xs text-destructive mt-1", role: "alert", children: n }), t[38] = n, t[39] = v, t[40] = w) : w = t[40];
|
|
86
86
|
let R;
|
|
87
|
-
return t[41] !== u || t[42] !==
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
] }), t[41] = u, t[42] =
|
|
87
|
+
return t[41] !== u || t[42] !== m || t[43] !== k || t[44] !== w ? (R = /* @__PURE__ */ Z("div", { className: u, children: [
|
|
88
|
+
m,
|
|
89
|
+
k,
|
|
90
|
+
w
|
|
91
|
+
] }), t[41] = u, t[42] = m, t[43] = k, t[44] = w, t[45] = R) : R = t[45], R;
|
|
92
92
|
};
|
|
93
|
-
function st(
|
|
94
|
-
return
|
|
93
|
+
function st(N) {
|
|
94
|
+
return N !== "";
|
|
95
95
|
}
|
|
96
|
-
function ot(
|
|
97
|
-
return
|
|
96
|
+
function ot(N) {
|
|
97
|
+
return N !== "";
|
|
98
98
|
}
|
|
99
99
|
export {
|
|
100
|
-
|
|
100
|
+
ut as OtpInput
|
|
101
101
|
};
|