@alfadocs/ui-kit 0.53.0 → 0.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/otp-input-xQ4Ps5VY.js +279 -0
- package/dist/agent-catalog.json +1 -1
- package/dist/components/otp-input/index.js +1 -1
- package/dist/components/otp-input/otp-input.d.ts +13 -1
- package/dist/i18n/locales/ar.d.ts +1 -0
- package/dist/i18n/locales/ar.js +2 -1
- package/dist/i18n/locales/de.d.ts +1 -0
- package/dist/i18n/locales/de.js +2 -1
- package/dist/i18n/locales/el.d.ts +1 -0
- package/dist/i18n/locales/el.js +2 -1
- package/dist/i18n/locales/en.d.ts +1 -0
- package/dist/i18n/locales/en.js +2 -1
- package/dist/i18n/locales/es.d.ts +1 -0
- package/dist/i18n/locales/es.js +2 -1
- package/dist/i18n/locales/fr.d.ts +1 -0
- package/dist/i18n/locales/fr.js +2 -1
- package/dist/i18n/locales/hi.d.ts +1 -0
- package/dist/i18n/locales/hi.js +2 -1
- package/dist/i18n/locales/it.d.ts +1 -0
- package/dist/i18n/locales/it.js +2 -1
- package/dist/i18n/locales/ja.d.ts +1 -0
- package/dist/i18n/locales/ja.js +2 -1
- package/dist/i18n/locales/nl.d.ts +1 -0
- package/dist/i18n/locales/nl.js +2 -1
- package/dist/i18n/locales/pl.d.ts +1 -0
- package/dist/i18n/locales/pl.js +2 -1
- package/dist/i18n/locales/pt.d.ts +1 -0
- package/dist/i18n/locales/pt.js +2 -1
- package/dist/i18n/locales/ro.d.ts +1 -0
- package/dist/i18n/locales/ro.js +2 -1
- package/dist/i18n/locales/ru.d.ts +1 -0
- package/dist/i18n/locales/ru.js +2 -1
- package/dist/i18n/locales/sq.d.ts +1 -0
- package/dist/i18n/locales/sq.js +2 -1
- package/dist/i18n/locales/sv.d.ts +1 -0
- package/dist/i18n/locales/sv.js +2 -1
- package/dist/i18n/locales/tr.d.ts +1 -0
- package/dist/i18n/locales/tr.js +2 -1
- package/dist/i18n/locales/zh.d.ts +1 -0
- package/dist/i18n/locales/zh.js +2 -1
- package/dist/index.js +1 -1
- package/dist/locales/ar.json +2 -1
- package/dist/locales/de.json +2 -1
- package/dist/locales/el.json +2 -1
- package/dist/locales/en.json +2 -1
- package/dist/locales/es.json +2 -1
- package/dist/locales/fr.json +2 -1
- package/dist/locales/hi.json +2 -1
- package/dist/locales/it.json +2 -1
- package/dist/locales/ja.json +2 -1
- package/dist/locales/nl.json +2 -1
- package/dist/locales/pl.json +2 -1
- package/dist/locales/pt.json +2 -1
- package/dist/locales/ro.json +2 -1
- package/dist/locales/ru.json +2 -1
- package/dist/locales/sq.json +2 -1
- package/dist/locales/sv.json +2 -1
- package/dist/locales/tr.json +2 -1
- package/dist/locales/zh.json +2 -1
- package/package.json +1 -1
- package/dist/_chunks/otp-input-Chb9r5vf.js +0 -268
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { jsxs as re, jsx as I } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as ae, useId as se, useRef as R, useState as ne, useEffect as oe, useCallback as S, useMemo as ie, useImperativeHandle as ce } from "react";
|
|
3
|
+
import { c as Z } from "./index-D2ZczOXr.js";
|
|
4
|
+
import { useTranslation as le } from "react-i18next";
|
|
5
|
+
import { u as ue } from "./use-controllable-state-BiY4xTzM.js";
|
|
6
|
+
import { u as de } from "./use-web-otp-D_utzp6S.js";
|
|
7
|
+
import { u as pe } from "./form-field-context-B3APVHKx.js";
|
|
8
|
+
import { u as fe } from "./registry-nPAVE19X.js";
|
|
9
|
+
const ge = {
|
|
10
|
+
id: "otp-input",
|
|
11
|
+
capabilities: ["edit_inline", "submit"],
|
|
12
|
+
state: {
|
|
13
|
+
value: {
|
|
14
|
+
type: "string",
|
|
15
|
+
descriptionKey: "ui.agent.otpInput.state.value",
|
|
16
|
+
description: "Current digits entered, packed into a single string.",
|
|
17
|
+
read: (a) => a.getValue()
|
|
18
|
+
},
|
|
19
|
+
isComplete: {
|
|
20
|
+
type: "boolean",
|
|
21
|
+
descriptionKey: "ui.agent.otpInput.state.isComplete",
|
|
22
|
+
description: "Whether all required digits have been entered.",
|
|
23
|
+
read: (a) => a.isComplete()
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
actions: {
|
|
27
|
+
set_value: {
|
|
28
|
+
safety: "write",
|
|
29
|
+
argsType: "{ value: string }",
|
|
30
|
+
descriptionKey: "ui.agent.otpInput.actions.setValue",
|
|
31
|
+
description: "Replace the entered digits.",
|
|
32
|
+
invoke: (a, n) => {
|
|
33
|
+
a.setValue(n.value);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
clear: {
|
|
37
|
+
safety: "destructive",
|
|
38
|
+
descriptionKey: "ui.agent.otpInput.actions.clear",
|
|
39
|
+
description: "Empty all digit cells. Loses any typed value.",
|
|
40
|
+
invoke: (a) => {
|
|
41
|
+
a.clear();
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
focus: {
|
|
45
|
+
safety: "read",
|
|
46
|
+
descriptionKey: "ui.agent.otpInput.actions.focus",
|
|
47
|
+
description: "Move keyboard focus to the active digit cell.",
|
|
48
|
+
invoke: (a) => {
|
|
49
|
+
a.focus();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
domHooks: {
|
|
54
|
+
root: {
|
|
55
|
+
attr: "data-component",
|
|
56
|
+
value: "otp-input",
|
|
57
|
+
description: "Marks the OTPInput wrapper. Completion is observable via state.isComplete; the host onComplete callback fires once when all digits are filled."
|
|
58
|
+
},
|
|
59
|
+
instanceId: {
|
|
60
|
+
attr: "data-component-id",
|
|
61
|
+
sourceProp: "id",
|
|
62
|
+
description: "Sourced from the id prop."
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}, me = Z("ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]"), he = Z(
|
|
66
|
+
[
|
|
67
|
+
"ds:w-[var(--min-target-size)] ds:h-[var(--min-target-size)]",
|
|
68
|
+
"ds:rounded-[var(--radius-sm)]",
|
|
69
|
+
"ds:border ds:bg-input ds:text-foreground ds:text-center ds:font-medium ds:text-[length:var(--font-size-lg)]",
|
|
70
|
+
"ds:shadow-[var(--shadow-input)]",
|
|
71
|
+
"ds:transition-[colors,box-shadow] ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none",
|
|
72
|
+
"ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid",
|
|
73
|
+
"ds:focus-visible:outline-ring ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
|
|
74
|
+
"ds:disabled:cursor-not-allowed ds:disabled:opacity-50"
|
|
75
|
+
].join(" "),
|
|
76
|
+
{
|
|
77
|
+
variants: {
|
|
78
|
+
tone: {
|
|
79
|
+
default: "ds:border-border",
|
|
80
|
+
error: "ds:border-destructive"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
defaultVariants: { tone: "default" }
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
function z(a) {
|
|
87
|
+
return a.replace(/[\u0660-\u0669]/g, (n) => String(n.charCodeAt(0) - 1632)).replace(/[\u06F0-\u06F9]/g, (n) => String(n.charCodeAt(0) - 1776));
|
|
88
|
+
}
|
|
89
|
+
const ve = 3, be = 10;
|
|
90
|
+
function ye(a) {
|
|
91
|
+
const n = Number.isFinite(a) ? Math.floor(a) : 6;
|
|
92
|
+
return Math.max(ve, Math.min(be, n));
|
|
93
|
+
}
|
|
94
|
+
function k(a, n, g) {
|
|
95
|
+
return (g === "alphanumeric" ? a.replace(/[^A-Za-z0-9]/g, "").toUpperCase() : z(a).replace(/\D/g, "")).slice(0, n);
|
|
96
|
+
}
|
|
97
|
+
function we(a, n, g) {
|
|
98
|
+
const d = k(a, n, g), p = new Array(n).fill("");
|
|
99
|
+
for (let m = 0; m < d.length; m += 1)
|
|
100
|
+
p[m] = d[m];
|
|
101
|
+
return p;
|
|
102
|
+
}
|
|
103
|
+
const Ie = ae(
|
|
104
|
+
({
|
|
105
|
+
length: a = 6,
|
|
106
|
+
value: n,
|
|
107
|
+
defaultValue: g,
|
|
108
|
+
onChange: d,
|
|
109
|
+
onComplete: p,
|
|
110
|
+
disabled: m,
|
|
111
|
+
error: _,
|
|
112
|
+
label: V,
|
|
113
|
+
id: F,
|
|
114
|
+
className: $,
|
|
115
|
+
webOtp: j = !1,
|
|
116
|
+
name: E,
|
|
117
|
+
mode: i = "numeric"
|
|
118
|
+
}, U) => {
|
|
119
|
+
const { t: G } = le(), r = ye(a), b = pe(), W = se(), K = V ? W : void 0, [q, H] = ue({
|
|
120
|
+
value: n,
|
|
121
|
+
defaultValue: k(g ?? "", r, i)
|
|
122
|
+
}), h = k(q ?? "", r, i), x = we(h, r, i), y = b.disabled || !!m, O = b.invalid || !!_, X = O ? "error" : "default", P = R([]), D = R(h.length === r), f = R(h);
|
|
123
|
+
f.current = h;
|
|
124
|
+
const J = () => {
|
|
125
|
+
const t = h.length;
|
|
126
|
+
return t >= r ? r - 1 : t;
|
|
127
|
+
}, [v, A] = ne(J);
|
|
128
|
+
oe(() => {
|
|
129
|
+
v >= r && A(r - 1);
|
|
130
|
+
}, [v, r]);
|
|
131
|
+
const l = S(
|
|
132
|
+
(t) => {
|
|
133
|
+
const e = Math.max(0, Math.min(r - 1, t));
|
|
134
|
+
A(e);
|
|
135
|
+
const s = P.current[e];
|
|
136
|
+
s && (s.focus(), s.select());
|
|
137
|
+
},
|
|
138
|
+
[r]
|
|
139
|
+
), u = S(
|
|
140
|
+
(t) => {
|
|
141
|
+
const e = k(t, r, i);
|
|
142
|
+
H(e), f.current = e, d == null || d(e), e.length === r ? D.current || (D.current = !0, p == null || p(e)) : D.current = !1;
|
|
143
|
+
},
|
|
144
|
+
[H, r, i, d, p]
|
|
145
|
+
);
|
|
146
|
+
de({
|
|
147
|
+
enabled: j && !y,
|
|
148
|
+
onCode: u
|
|
149
|
+
});
|
|
150
|
+
const Q = (t) => (e) => {
|
|
151
|
+
const s = e.target.value, o = i === "alphanumeric" ? s.replace(/[^A-Za-z0-9]/g, "").toUpperCase() : z(s).replace(/\D/g, ""), c = f.current;
|
|
152
|
+
if (o.length === 0) {
|
|
153
|
+
if (s === "" && t < c.length) {
|
|
154
|
+
const N = c.slice(0, t) + c.slice(t + 1);
|
|
155
|
+
u(N);
|
|
156
|
+
}
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const w = c.slice(0, t), T = c.slice(t + o.length), C = (w + o + T).slice(0, r);
|
|
160
|
+
u(C);
|
|
161
|
+
const L = Math.min(t + o.length, r - 1);
|
|
162
|
+
l(L);
|
|
163
|
+
}, Y = (t) => (e) => {
|
|
164
|
+
const s = f.current;
|
|
165
|
+
if (e.key === "Backspace") {
|
|
166
|
+
if (s[t]) {
|
|
167
|
+
e.preventDefault();
|
|
168
|
+
const o = s.slice(0, t) + s.slice(t + 1);
|
|
169
|
+
u(o);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (t > 0) {
|
|
173
|
+
e.preventDefault();
|
|
174
|
+
const o = s.slice(0, t - 1) + s.slice(t);
|
|
175
|
+
u(o), l(t - 1);
|
|
176
|
+
}
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (e.key === "ArrowLeft") {
|
|
180
|
+
e.preventDefault(), t > 0 && l(t - 1);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (e.key === "ArrowRight") {
|
|
184
|
+
e.preventDefault(), t < r - 1 && l(t + 1);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (e.key === "Home") {
|
|
188
|
+
e.preventDefault(), l(0);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
e.key === "End" && (e.preventDefault(), l(r - 1));
|
|
192
|
+
}, ee = (t) => (e) => {
|
|
193
|
+
const o = e.clipboardData.getData("text").replace(/\s+/g, ""), c = i === "alphanumeric" ? o.replace(/[^A-Za-z0-9]/g, "").toUpperCase() : z(o);
|
|
194
|
+
if (i === "alphanumeric" ? c.length === 0 : !/^[0-9]+$/.test(c))
|
|
195
|
+
return;
|
|
196
|
+
e.preventDefault();
|
|
197
|
+
const w = f.current, T = w.slice(0, t), C = w.slice(t + c.length), L = (T + c + C).slice(0, r);
|
|
198
|
+
u(L);
|
|
199
|
+
const N = Math.min(t + c.length, r - 1);
|
|
200
|
+
l(N);
|
|
201
|
+
}, te = (t) => (e) => {
|
|
202
|
+
A(t), e.currentTarget.select();
|
|
203
|
+
}, B = b.id, M = ie(
|
|
204
|
+
() => ({
|
|
205
|
+
getValue: () => f.current,
|
|
206
|
+
setValue: (t) => u(t),
|
|
207
|
+
clear: () => u(""),
|
|
208
|
+
focus: () => l(v),
|
|
209
|
+
isComplete: () => f.current.length === r
|
|
210
|
+
}),
|
|
211
|
+
[u, l, v, r]
|
|
212
|
+
);
|
|
213
|
+
return fe(ge, M, F), ce(U, () => M, [M]), /* @__PURE__ */ re("div", { className: me({ className: $ }), children: [
|
|
214
|
+
V ? /* @__PURE__ */ I(
|
|
215
|
+
"label",
|
|
216
|
+
{
|
|
217
|
+
id: K,
|
|
218
|
+
htmlFor: `${B}-0`,
|
|
219
|
+
className: "type-label ds:text-foreground",
|
|
220
|
+
children: V
|
|
221
|
+
}
|
|
222
|
+
) : null,
|
|
223
|
+
/* @__PURE__ */ I(
|
|
224
|
+
"div",
|
|
225
|
+
{
|
|
226
|
+
role: "group",
|
|
227
|
+
dir: "ltr",
|
|
228
|
+
"aria-labelledby": K,
|
|
229
|
+
"aria-invalid": O || void 0,
|
|
230
|
+
"aria-describedby": b.describedBy || void 0,
|
|
231
|
+
"aria-disabled": y || void 0,
|
|
232
|
+
"data-component": "otp-input",
|
|
233
|
+
"data-component-id": F,
|
|
234
|
+
className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-sm)]",
|
|
235
|
+
children: x.map((t, e) => {
|
|
236
|
+
const s = !y && e === v;
|
|
237
|
+
return /* @__PURE__ */ I(
|
|
238
|
+
"input",
|
|
239
|
+
{
|
|
240
|
+
ref: (o) => {
|
|
241
|
+
P.current[e] = o;
|
|
242
|
+
},
|
|
243
|
+
id: `${B}-${e}`,
|
|
244
|
+
type: "text",
|
|
245
|
+
inputMode: i === "alphanumeric" ? "text" : "numeric",
|
|
246
|
+
pattern: i === "alphanumeric" ? "[A-Za-z0-9]*" : "[0-9]*",
|
|
247
|
+
autoCapitalize: i === "alphanumeric" ? "characters" : void 0,
|
|
248
|
+
autoComplete: e === 0 ? "one-time-code" : "off",
|
|
249
|
+
maxLength: 1,
|
|
250
|
+
value: t,
|
|
251
|
+
disabled: y,
|
|
252
|
+
tabIndex: s ? 0 : -1,
|
|
253
|
+
"aria-label": G(
|
|
254
|
+
i === "alphanumeric" ? "inputs.otp.charLabel" : "inputs.otp.digitLabel",
|
|
255
|
+
{
|
|
256
|
+
current: e + 1,
|
|
257
|
+
total: r
|
|
258
|
+
}
|
|
259
|
+
),
|
|
260
|
+
onChange: Q(e),
|
|
261
|
+
onKeyDown: Y(e),
|
|
262
|
+
onPaste: ee(e),
|
|
263
|
+
onFocus: te(e),
|
|
264
|
+
className: he({ tone: X })
|
|
265
|
+
},
|
|
266
|
+
e
|
|
267
|
+
);
|
|
268
|
+
})
|
|
269
|
+
}
|
|
270
|
+
),
|
|
271
|
+
E ? /* @__PURE__ */ I("input", { type: "hidden", name: E, value: h, readOnly: !0 }) : null
|
|
272
|
+
] });
|
|
273
|
+
}
|
|
274
|
+
);
|
|
275
|
+
Ie.displayName = "OTPInput";
|
|
276
|
+
export {
|
|
277
|
+
Ie as O
|
|
278
|
+
};
|
|
279
|
+
//# sourceMappingURL=otp-input-xQ4Ps5VY.js.map
|
package/dist/agent-catalog.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type OTPMode = 'numeric' | 'alphanumeric';
|
|
1
2
|
/** Agent-readiness curated handle for OTPInput. */
|
|
2
3
|
export interface OTPInputHandle {
|
|
3
4
|
getValue: () => string;
|
|
@@ -7,7 +8,11 @@ export interface OTPInputHandle {
|
|
|
7
8
|
isComplete: () => boolean;
|
|
8
9
|
}
|
|
9
10
|
export interface OTPInputProps {
|
|
10
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Number of boxes. Default 6. Any integer in [3, 10] is honoured;
|
|
13
|
+
* out-of-range values are clamped (with a DEV warning).
|
|
14
|
+
*/
|
|
15
|
+
length?: number;
|
|
11
16
|
value?: string;
|
|
12
17
|
defaultValue?: string;
|
|
13
18
|
onChange?: (value: string) => void;
|
|
@@ -40,6 +45,13 @@ export interface OTPInputProps {
|
|
|
40
45
|
* `sms_code_form[code]`. Default off — no behaviour change.
|
|
41
46
|
*/
|
|
42
47
|
name?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Character set. `numeric` (default) accepts digits only (with Arabic-Indic
|
|
50
|
+
* digit folding) — byte-identical to prior behaviour. `alphanumeric` accepts
|
|
51
|
+
* `[A-Za-z0-9]`, uppercases the value, and switches the boxes to text input
|
|
52
|
+
* (for SMS codes that mix letters and digits).
|
|
53
|
+
*/
|
|
54
|
+
mode?: OTPMode;
|
|
43
55
|
}
|
|
44
56
|
export declare const OTPInput: import("react").ForwardRefExoticComponent<OTPInputProps & import("react").RefAttributes<OTPInputHandle>>;
|
|
45
57
|
//# sourceMappingURL=otp-input.d.ts.map
|
package/dist/i18n/locales/ar.js
CHANGED
|
@@ -139,7 +139,8 @@ const e = {
|
|
|
139
139
|
clear: "مسح الاختيار"
|
|
140
140
|
},
|
|
141
141
|
otp: {
|
|
142
|
-
digitLabel: "الرقم {{current}} من {{total}}"
|
|
142
|
+
digitLabel: "الرقم {{current}} من {{total}}",
|
|
143
|
+
charLabel: "الحرف {{current}} من {{total}}"
|
|
143
144
|
},
|
|
144
145
|
slider: {
|
|
145
146
|
minLabel: "الحد الأدنى",
|
package/dist/i18n/locales/de.js
CHANGED
|
@@ -128,7 +128,8 @@ const e = {
|
|
|
128
128
|
clear: "Auswahl aufheben"
|
|
129
129
|
},
|
|
130
130
|
otp: {
|
|
131
|
-
digitLabel: "Ziffer {{current}} von {{total}}"
|
|
131
|
+
digitLabel: "Ziffer {{current}} von {{total}}",
|
|
132
|
+
charLabel: "Zeichen {{current}} von {{total}}"
|
|
132
133
|
},
|
|
133
134
|
slider: {
|
|
134
135
|
minLabel: "Minimum",
|
package/dist/i18n/locales/el.js
CHANGED
|
@@ -139,7 +139,8 @@ const e = {
|
|
|
139
139
|
clear: "Εκκαθάριση επιλογής"
|
|
140
140
|
},
|
|
141
141
|
otp: {
|
|
142
|
-
digitLabel: "Ψηφίο {{current}} από {{total}}"
|
|
142
|
+
digitLabel: "Ψηφίο {{current}} από {{total}}",
|
|
143
|
+
charLabel: "Χαρακτήρας {{current}} από {{total}}"
|
|
143
144
|
},
|
|
144
145
|
slider: {
|
|
145
146
|
minLabel: "Ελάχιστο",
|
package/dist/i18n/locales/en.js
CHANGED
|
@@ -139,7 +139,8 @@ const e = {
|
|
|
139
139
|
clear: "Clear selection"
|
|
140
140
|
},
|
|
141
141
|
otp: {
|
|
142
|
-
digitLabel: "Digit {{current}} of {{total}}"
|
|
142
|
+
digitLabel: "Digit {{current}} of {{total}}",
|
|
143
|
+
charLabel: "Character {{current}} of {{total}}"
|
|
143
144
|
},
|
|
144
145
|
slider: {
|
|
145
146
|
minLabel: "Minimum",
|
package/dist/i18n/locales/es.js
CHANGED
|
@@ -128,7 +128,8 @@ const e = {
|
|
|
128
128
|
clear: "Borrar selección"
|
|
129
129
|
},
|
|
130
130
|
otp: {
|
|
131
|
-
digitLabel: "Dígito {{current}} de {{total}}"
|
|
131
|
+
digitLabel: "Dígito {{current}} de {{total}}",
|
|
132
|
+
charLabel: "Carácter {{current}} de {{total}}"
|
|
132
133
|
},
|
|
133
134
|
slider: {
|
|
134
135
|
minLabel: "Mínimo",
|
package/dist/i18n/locales/fr.js
CHANGED
|
@@ -139,7 +139,8 @@ const e = {
|
|
|
139
139
|
clear: "Effacer la sélection"
|
|
140
140
|
},
|
|
141
141
|
otp: {
|
|
142
|
-
digitLabel: "Chiffre {{current}} sur {{total}}"
|
|
142
|
+
digitLabel: "Chiffre {{current}} sur {{total}}",
|
|
143
|
+
charLabel: "Caractère {{current}} sur {{total}}"
|
|
143
144
|
},
|
|
144
145
|
slider: {
|
|
145
146
|
minLabel: "Minimum",
|
package/dist/i18n/locales/hi.js
CHANGED
|
@@ -139,7 +139,8 @@ const e = {
|
|
|
139
139
|
clear: "चयन हटाएं"
|
|
140
140
|
},
|
|
141
141
|
otp: {
|
|
142
|
-
digitLabel: "{{current}} में से {{total}} का अंक"
|
|
142
|
+
digitLabel: "{{current}} में से {{total}} का अंक",
|
|
143
|
+
charLabel: "{{current}} में से {{total}} का वर्ण"
|
|
143
144
|
},
|
|
144
145
|
slider: {
|
|
145
146
|
minLabel: "न्यूनतम",
|
package/dist/i18n/locales/it.js
CHANGED
|
@@ -139,7 +139,8 @@ const e = {
|
|
|
139
139
|
clear: "Cancella selezione"
|
|
140
140
|
},
|
|
141
141
|
otp: {
|
|
142
|
-
digitLabel: "Cifra {{current}} di {{total}}"
|
|
142
|
+
digitLabel: "Cifra {{current}} di {{total}}",
|
|
143
|
+
charLabel: "Carattere {{current}} di {{total}}"
|
|
143
144
|
},
|
|
144
145
|
slider: {
|
|
145
146
|
minLabel: "Minimo",
|
package/dist/i18n/locales/ja.js
CHANGED
package/dist/i18n/locales/nl.js
CHANGED
|
@@ -128,7 +128,8 @@ const e = {
|
|
|
128
128
|
clear: "Selectie wissen"
|
|
129
129
|
},
|
|
130
130
|
otp: {
|
|
131
|
-
digitLabel: "Cijfer {{current}} van {{total}}"
|
|
131
|
+
digitLabel: "Cijfer {{current}} van {{total}}",
|
|
132
|
+
charLabel: "Teken {{current}} van {{total}}"
|
|
132
133
|
},
|
|
133
134
|
slider: {
|
|
134
135
|
minLabel: "Minimum",
|
package/dist/i18n/locales/pl.js
CHANGED
package/dist/i18n/locales/pt.js
CHANGED
|
@@ -139,7 +139,8 @@ const e = {
|
|
|
139
139
|
clear: "Limpar seleção"
|
|
140
140
|
},
|
|
141
141
|
otp: {
|
|
142
|
-
digitLabel: "Dígito {{current}} de {{total}}"
|
|
142
|
+
digitLabel: "Dígito {{current}} de {{total}}",
|
|
143
|
+
charLabel: "Caractere {{current}} de {{total}}"
|
|
143
144
|
},
|
|
144
145
|
slider: {
|
|
145
146
|
minLabel: "Mínimo",
|
package/dist/i18n/locales/ro.js
CHANGED
|
@@ -128,7 +128,8 @@ const e = {
|
|
|
128
128
|
clear: "Anulează selecția"
|
|
129
129
|
},
|
|
130
130
|
otp: {
|
|
131
|
-
digitLabel: "Cifra {{current}} din {{total}}"
|
|
131
|
+
digitLabel: "Cifra {{current}} din {{total}}",
|
|
132
|
+
charLabel: "Caracterul {{current}} din {{total}}"
|
|
132
133
|
},
|
|
133
134
|
slider: {
|
|
134
135
|
minLabel: "Minim",
|
package/dist/i18n/locales/ru.js
CHANGED
|
@@ -139,7 +139,8 @@ const e = {
|
|
|
139
139
|
clear: "Очистить выбор"
|
|
140
140
|
},
|
|
141
141
|
otp: {
|
|
142
|
-
digitLabel: "Цифра {{current}} из {{total}}"
|
|
142
|
+
digitLabel: "Цифра {{current}} из {{total}}",
|
|
143
|
+
charLabel: "Символ {{current}} из {{total}}"
|
|
143
144
|
},
|
|
144
145
|
slider: {
|
|
145
146
|
minLabel: "Минимум",
|
package/dist/i18n/locales/sq.js
CHANGED
|
@@ -139,7 +139,8 @@ const e = {
|
|
|
139
139
|
clear: "Pastro zgjedhjen"
|
|
140
140
|
},
|
|
141
141
|
otp: {
|
|
142
|
-
digitLabel: "Shifra {{current}} nga {{total}}"
|
|
142
|
+
digitLabel: "Shifra {{current}} nga {{total}}",
|
|
143
|
+
charLabel: "Karakteri {{current}} nga {{total}}"
|
|
143
144
|
},
|
|
144
145
|
slider: {
|
|
145
146
|
minLabel: "Minimumi",
|
package/dist/i18n/locales/sv.js
CHANGED
|
@@ -144,6 +144,7 @@ export declare const trUi: {
|
|
|
144
144
|
};
|
|
145
145
|
readonly otp: {
|
|
146
146
|
readonly digitLabel: "{{total}} basamaktan {{current}}. basamak";
|
|
147
|
+
readonly charLabel: "{{total}} karakterden {{current}}. karakter";
|
|
147
148
|
};
|
|
148
149
|
readonly slider: {
|
|
149
150
|
readonly minLabel: "Minimum";
|
package/dist/i18n/locales/tr.js
CHANGED
|
@@ -139,7 +139,8 @@ const e = {
|
|
|
139
139
|
clear: "Seçimi temizle"
|
|
140
140
|
},
|
|
141
141
|
otp: {
|
|
142
|
-
digitLabel: "{{total}} basamaktan {{current}}. basamak"
|
|
142
|
+
digitLabel: "{{total}} basamaktan {{current}}. basamak",
|
|
143
|
+
charLabel: "{{total}} karakterden {{current}}. karakter"
|
|
143
144
|
},
|
|
144
145
|
slider: {
|
|
145
146
|
minLabel: "Minimum",
|
package/dist/i18n/locales/zh.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -34,7 +34,7 @@ import { F as Ya } from "./_chunks/form-field-BOm9hK35.js";
|
|
|
34
34
|
import { F as Qa, u as ja } from "./_chunks/form-field-context-B3APVHKx.js";
|
|
35
35
|
import { M as Xa, m as Ja, a as Za } from "./_chunks/multi-select-DOLO3K_z.js";
|
|
36
36
|
import { N as ae, u as ee } from "./_chunks/number-input-Dj5L3pXK.js";
|
|
37
|
-
import { O as oe } from "./_chunks/otp-input-
|
|
37
|
+
import { O as oe } from "./_chunks/otp-input-xQ4Ps5VY.js";
|
|
38
38
|
import { P as se, u as ne } from "./_chunks/use-password-requirements-DsgduV1x.js";
|
|
39
39
|
import { P as pe, c as me, p as le, a as de } from "./_chunks/phone-input-DfZbPPvh.js";
|
|
40
40
|
import { R as fe, r as ge } from "./_chunks/recaptcha-widget-BCNHsgqt.js";
|
package/dist/locales/ar.json
CHANGED
|
@@ -139,7 +139,8 @@
|
|
|
139
139
|
"clear": "مسح الاختيار"
|
|
140
140
|
},
|
|
141
141
|
"otp": {
|
|
142
|
-
"digitLabel": "الرقم {{current}} من {{total}}"
|
|
142
|
+
"digitLabel": "الرقم {{current}} من {{total}}",
|
|
143
|
+
"charLabel": "الحرف {{current}} من {{total}}"
|
|
143
144
|
},
|
|
144
145
|
"slider": {
|
|
145
146
|
"minLabel": "الحد الأدنى",
|
package/dist/locales/de.json
CHANGED
|
@@ -128,7 +128,8 @@
|
|
|
128
128
|
"clear": "Auswahl aufheben"
|
|
129
129
|
},
|
|
130
130
|
"otp": {
|
|
131
|
-
"digitLabel": "Ziffer {{current}} von {{total}}"
|
|
131
|
+
"digitLabel": "Ziffer {{current}} von {{total}}",
|
|
132
|
+
"charLabel": "Zeichen {{current}} von {{total}}"
|
|
132
133
|
},
|
|
133
134
|
"slider": {
|
|
134
135
|
"minLabel": "Minimum",
|
package/dist/locales/el.json
CHANGED
|
@@ -139,7 +139,8 @@
|
|
|
139
139
|
"clear": "Εκκαθάριση επιλογής"
|
|
140
140
|
},
|
|
141
141
|
"otp": {
|
|
142
|
-
"digitLabel": "Ψηφίο {{current}} από {{total}}"
|
|
142
|
+
"digitLabel": "Ψηφίο {{current}} από {{total}}",
|
|
143
|
+
"charLabel": "Χαρακτήρας {{current}} από {{total}}"
|
|
143
144
|
},
|
|
144
145
|
"slider": {
|
|
145
146
|
"minLabel": "Ελάχιστο",
|
package/dist/locales/en.json
CHANGED
|
@@ -139,7 +139,8 @@
|
|
|
139
139
|
"clear": "Clear selection"
|
|
140
140
|
},
|
|
141
141
|
"otp": {
|
|
142
|
-
"digitLabel": "Digit {{current}} of {{total}}"
|
|
142
|
+
"digitLabel": "Digit {{current}} of {{total}}",
|
|
143
|
+
"charLabel": "Character {{current}} of {{total}}"
|
|
143
144
|
},
|
|
144
145
|
"slider": {
|
|
145
146
|
"minLabel": "Minimum",
|
package/dist/locales/es.json
CHANGED
|
@@ -128,7 +128,8 @@
|
|
|
128
128
|
"clear": "Borrar selección"
|
|
129
129
|
},
|
|
130
130
|
"otp": {
|
|
131
|
-
"digitLabel": "Dígito {{current}} de {{total}}"
|
|
131
|
+
"digitLabel": "Dígito {{current}} de {{total}}",
|
|
132
|
+
"charLabel": "Carácter {{current}} de {{total}}"
|
|
132
133
|
},
|
|
133
134
|
"slider": {
|
|
134
135
|
"minLabel": "Mínimo",
|
package/dist/locales/fr.json
CHANGED
|
@@ -139,7 +139,8 @@
|
|
|
139
139
|
"clear": "Effacer la sélection"
|
|
140
140
|
},
|
|
141
141
|
"otp": {
|
|
142
|
-
"digitLabel": "Chiffre {{current}} sur {{total}}"
|
|
142
|
+
"digitLabel": "Chiffre {{current}} sur {{total}}",
|
|
143
|
+
"charLabel": "Caractère {{current}} sur {{total}}"
|
|
143
144
|
},
|
|
144
145
|
"slider": {
|
|
145
146
|
"minLabel": "Minimum",
|
package/dist/locales/hi.json
CHANGED
|
@@ -139,7 +139,8 @@
|
|
|
139
139
|
"clear": "चयन हटाएं"
|
|
140
140
|
},
|
|
141
141
|
"otp": {
|
|
142
|
-
"digitLabel": "{{current}} में से {{total}} का अंक"
|
|
142
|
+
"digitLabel": "{{current}} में से {{total}} का अंक",
|
|
143
|
+
"charLabel": "{{current}} में से {{total}} का वर्ण"
|
|
143
144
|
},
|
|
144
145
|
"slider": {
|
|
145
146
|
"minLabel": "न्यूनतम",
|
package/dist/locales/it.json
CHANGED
|
@@ -139,7 +139,8 @@
|
|
|
139
139
|
"clear": "Cancella selezione"
|
|
140
140
|
},
|
|
141
141
|
"otp": {
|
|
142
|
-
"digitLabel": "Cifra {{current}} di {{total}}"
|
|
142
|
+
"digitLabel": "Cifra {{current}} di {{total}}",
|
|
143
|
+
"charLabel": "Carattere {{current}} di {{total}}"
|
|
143
144
|
},
|
|
144
145
|
"slider": {
|
|
145
146
|
"minLabel": "Minimo",
|
package/dist/locales/ja.json
CHANGED
package/dist/locales/nl.json
CHANGED
|
@@ -128,7 +128,8 @@
|
|
|
128
128
|
"clear": "Selectie wissen"
|
|
129
129
|
},
|
|
130
130
|
"otp": {
|
|
131
|
-
"digitLabel": "Cijfer {{current}} van {{total}}"
|
|
131
|
+
"digitLabel": "Cijfer {{current}} van {{total}}",
|
|
132
|
+
"charLabel": "Teken {{current}} van {{total}}"
|
|
132
133
|
},
|
|
133
134
|
"slider": {
|
|
134
135
|
"minLabel": "Minimum",
|
package/dist/locales/pl.json
CHANGED
package/dist/locales/pt.json
CHANGED
|
@@ -139,7 +139,8 @@
|
|
|
139
139
|
"clear": "Limpar seleção"
|
|
140
140
|
},
|
|
141
141
|
"otp": {
|
|
142
|
-
"digitLabel": "Dígito {{current}} de {{total}}"
|
|
142
|
+
"digitLabel": "Dígito {{current}} de {{total}}",
|
|
143
|
+
"charLabel": "Caractere {{current}} de {{total}}"
|
|
143
144
|
},
|
|
144
145
|
"slider": {
|
|
145
146
|
"minLabel": "Mínimo",
|
package/dist/locales/ro.json
CHANGED
|
@@ -128,7 +128,8 @@
|
|
|
128
128
|
"clear": "Anulează selecția"
|
|
129
129
|
},
|
|
130
130
|
"otp": {
|
|
131
|
-
"digitLabel": "Cifra {{current}} din {{total}}"
|
|
131
|
+
"digitLabel": "Cifra {{current}} din {{total}}",
|
|
132
|
+
"charLabel": "Caracterul {{current}} din {{total}}"
|
|
132
133
|
},
|
|
133
134
|
"slider": {
|
|
134
135
|
"minLabel": "Minim",
|
package/dist/locales/ru.json
CHANGED
|
@@ -139,7 +139,8 @@
|
|
|
139
139
|
"clear": "Очистить выбор"
|
|
140
140
|
},
|
|
141
141
|
"otp": {
|
|
142
|
-
"digitLabel": "Цифра {{current}} из {{total}}"
|
|
142
|
+
"digitLabel": "Цифра {{current}} из {{total}}",
|
|
143
|
+
"charLabel": "Символ {{current}} из {{total}}"
|
|
143
144
|
},
|
|
144
145
|
"slider": {
|
|
145
146
|
"minLabel": "Минимум",
|
package/dist/locales/sq.json
CHANGED
|
@@ -139,7 +139,8 @@
|
|
|
139
139
|
"clear": "Pastro zgjedhjen"
|
|
140
140
|
},
|
|
141
141
|
"otp": {
|
|
142
|
-
"digitLabel": "Shifra {{current}} nga {{total}}"
|
|
142
|
+
"digitLabel": "Shifra {{current}} nga {{total}}",
|
|
143
|
+
"charLabel": "Karakteri {{current}} nga {{total}}"
|
|
143
144
|
},
|
|
144
145
|
"slider": {
|
|
145
146
|
"minLabel": "Minimumi",
|
package/dist/locales/sv.json
CHANGED
|
@@ -139,7 +139,8 @@
|
|
|
139
139
|
"clear": "Rensa val"
|
|
140
140
|
},
|
|
141
141
|
"otp": {
|
|
142
|
-
"digitLabel": "Siffra {{current}} av {{total}}"
|
|
142
|
+
"digitLabel": "Siffra {{current}} av {{total}}",
|
|
143
|
+
"charLabel": "Tecken {{current}} av {{total}}"
|
|
143
144
|
},
|
|
144
145
|
"slider": {
|
|
145
146
|
"minLabel": "Minimum",
|
package/dist/locales/tr.json
CHANGED
|
@@ -139,7 +139,8 @@
|
|
|
139
139
|
"clear": "Seçimi temizle"
|
|
140
140
|
},
|
|
141
141
|
"otp": {
|
|
142
|
-
"digitLabel": "{{total}} basamaktan {{current}}. basamak"
|
|
142
|
+
"digitLabel": "{{total}} basamaktan {{current}}. basamak",
|
|
143
|
+
"charLabel": "{{total}} karakterden {{current}}. karakter"
|
|
143
144
|
},
|
|
144
145
|
"slider": {
|
|
145
146
|
"minLabel": "Minimum",
|
package/dist/locales/zh.json
CHANGED
package/package.json
CHANGED
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { jsxs as ee, jsx as y } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as te, useId as re, useRef as M, useState as se, useEffect as ae, useCallback as N, useMemo as oe, useImperativeHandle as ie } from "react";
|
|
3
|
-
import { c as S } from "./index-D2ZczOXr.js";
|
|
4
|
-
import { useTranslation as ne } from "react-i18next";
|
|
5
|
-
import { u as ce } from "./use-controllable-state-BiY4xTzM.js";
|
|
6
|
-
import { u as ue } from "./use-web-otp-D_utzp6S.js";
|
|
7
|
-
import { u as le } from "./form-field-context-B3APVHKx.js";
|
|
8
|
-
import { u as de } from "./registry-nPAVE19X.js";
|
|
9
|
-
const pe = {
|
|
10
|
-
id: "otp-input",
|
|
11
|
-
capabilities: ["edit_inline", "submit"],
|
|
12
|
-
state: {
|
|
13
|
-
value: {
|
|
14
|
-
type: "string",
|
|
15
|
-
descriptionKey: "ui.agent.otpInput.state.value",
|
|
16
|
-
description: "Current digits entered, packed into a single string.",
|
|
17
|
-
read: (e) => e.getValue()
|
|
18
|
-
},
|
|
19
|
-
isComplete: {
|
|
20
|
-
type: "boolean",
|
|
21
|
-
descriptionKey: "ui.agent.otpInput.state.isComplete",
|
|
22
|
-
description: "Whether all required digits have been entered.",
|
|
23
|
-
read: (e) => e.isComplete()
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
actions: {
|
|
27
|
-
set_value: {
|
|
28
|
-
safety: "write",
|
|
29
|
-
argsType: "{ value: string }",
|
|
30
|
-
descriptionKey: "ui.agent.otpInput.actions.setValue",
|
|
31
|
-
description: "Replace the entered digits.",
|
|
32
|
-
invoke: (e, a) => {
|
|
33
|
-
e.setValue(a.value);
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
clear: {
|
|
37
|
-
safety: "destructive",
|
|
38
|
-
descriptionKey: "ui.agent.otpInput.actions.clear",
|
|
39
|
-
description: "Empty all digit cells. Loses any typed value.",
|
|
40
|
-
invoke: (e) => {
|
|
41
|
-
e.clear();
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
focus: {
|
|
45
|
-
safety: "read",
|
|
46
|
-
descriptionKey: "ui.agent.otpInput.actions.focus",
|
|
47
|
-
description: "Move keyboard focus to the active digit cell.",
|
|
48
|
-
invoke: (e) => {
|
|
49
|
-
e.focus();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
domHooks: {
|
|
54
|
-
root: {
|
|
55
|
-
attr: "data-component",
|
|
56
|
-
value: "otp-input",
|
|
57
|
-
description: "Marks the OTPInput wrapper. Completion is observable via state.isComplete; the host onComplete callback fires once when all digits are filled."
|
|
58
|
-
},
|
|
59
|
-
instanceId: {
|
|
60
|
-
attr: "data-component-id",
|
|
61
|
-
sourceProp: "id",
|
|
62
|
-
description: "Sourced from the id prop."
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}, fe = S("ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]"), me = S(
|
|
66
|
-
[
|
|
67
|
-
"ds:w-[var(--min-target-size)] ds:h-[var(--min-target-size)]",
|
|
68
|
-
"ds:rounded-[var(--radius-sm)]",
|
|
69
|
-
"ds:border ds:bg-input ds:text-foreground ds:text-center ds:font-medium ds:text-[length:var(--font-size-lg)]",
|
|
70
|
-
"ds:shadow-[var(--shadow-input)]",
|
|
71
|
-
"ds:transition-[colors,box-shadow] ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none",
|
|
72
|
-
"ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid",
|
|
73
|
-
"ds:focus-visible:outline-ring ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
|
|
74
|
-
"ds:disabled:cursor-not-allowed ds:disabled:opacity-50"
|
|
75
|
-
].join(" "),
|
|
76
|
-
{
|
|
77
|
-
variants: {
|
|
78
|
-
tone: {
|
|
79
|
-
default: "ds:border-border",
|
|
80
|
-
error: "ds:border-destructive"
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
defaultVariants: { tone: "default" }
|
|
84
|
-
}
|
|
85
|
-
);
|
|
86
|
-
function F(e) {
|
|
87
|
-
return e.replace(/[\u0660-\u0669]/g, (a) => String(a.charCodeAt(0) - 1632)).replace(/[\u06F0-\u06F9]/g, (a) => String(a.charCodeAt(0) - 1776));
|
|
88
|
-
}
|
|
89
|
-
function w(e, a) {
|
|
90
|
-
return F(e).replace(/\D/g, "").slice(0, a);
|
|
91
|
-
}
|
|
92
|
-
function ve(e, a) {
|
|
93
|
-
const m = w(e, a), l = new Array(a).fill("");
|
|
94
|
-
for (let n = 0; n < m.length; n += 1)
|
|
95
|
-
l[n] = m[n];
|
|
96
|
-
return l;
|
|
97
|
-
}
|
|
98
|
-
const be = te(
|
|
99
|
-
({
|
|
100
|
-
length: e = 6,
|
|
101
|
-
value: a,
|
|
102
|
-
defaultValue: m,
|
|
103
|
-
onChange: l,
|
|
104
|
-
onComplete: n,
|
|
105
|
-
disabled: H,
|
|
106
|
-
error: $,
|
|
107
|
-
label: I,
|
|
108
|
-
id: K,
|
|
109
|
-
className: j,
|
|
110
|
-
webOtp: z = !1,
|
|
111
|
-
name: C
|
|
112
|
-
}, W) => {
|
|
113
|
-
const { t: _ } = ne(), v = le(), q = re(), O = I ? q : void 0, [G, P] = ce({
|
|
114
|
-
value: a,
|
|
115
|
-
defaultValue: w(m ?? "", e)
|
|
116
|
-
}), p = w(G ?? "", e), J = ve(p, e), b = v.disabled || !!H, B = v.invalid || !!$, Q = B ? "error" : "default", E = M([]), h = M(p.length === e), d = M(p);
|
|
117
|
-
d.current = p;
|
|
118
|
-
const U = () => {
|
|
119
|
-
const r = p.length;
|
|
120
|
-
return r >= e ? e - 1 : r;
|
|
121
|
-
}, [f, k] = se(U);
|
|
122
|
-
ae(() => {
|
|
123
|
-
f >= e && k(e - 1);
|
|
124
|
-
}, [f, e]);
|
|
125
|
-
const c = N(
|
|
126
|
-
(r) => {
|
|
127
|
-
const t = Math.max(0, Math.min(e - 1, r));
|
|
128
|
-
k(t);
|
|
129
|
-
const s = E.current[t];
|
|
130
|
-
s && (s.focus(), s.select());
|
|
131
|
-
},
|
|
132
|
-
[e]
|
|
133
|
-
), u = N(
|
|
134
|
-
(r) => {
|
|
135
|
-
const t = w(r, e);
|
|
136
|
-
P(t), d.current = t, l == null || l(t), t.length === e ? h.current || (h.current = !0, n == null || n(t)) : h.current = !1;
|
|
137
|
-
},
|
|
138
|
-
[P, e, l, n]
|
|
139
|
-
);
|
|
140
|
-
ue({
|
|
141
|
-
enabled: z && !b,
|
|
142
|
-
onCode: u
|
|
143
|
-
});
|
|
144
|
-
const X = (r) => (t) => {
|
|
145
|
-
const s = t.target.value, o = F(s).replace(/\D/g, ""), i = d.current;
|
|
146
|
-
if (o.length === 0) {
|
|
147
|
-
if (s === "" && r < i.length) {
|
|
148
|
-
const R = i.slice(0, r) + i.slice(r + 1);
|
|
149
|
-
u(R);
|
|
150
|
-
}
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
const g = i.slice(0, r), D = i.slice(r + o.length), T = (g + o + D).slice(0, e);
|
|
154
|
-
u(T);
|
|
155
|
-
const A = Math.min(r + o.length, e - 1);
|
|
156
|
-
c(A);
|
|
157
|
-
}, Y = (r) => (t) => {
|
|
158
|
-
const s = d.current;
|
|
159
|
-
if (t.key === "Backspace") {
|
|
160
|
-
if (s[r]) {
|
|
161
|
-
t.preventDefault();
|
|
162
|
-
const o = s.slice(0, r) + s.slice(r + 1);
|
|
163
|
-
u(o);
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
if (r > 0) {
|
|
167
|
-
t.preventDefault();
|
|
168
|
-
const o = s.slice(0, r - 1) + s.slice(r);
|
|
169
|
-
u(o), c(r - 1);
|
|
170
|
-
}
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
if (t.key === "ArrowLeft") {
|
|
174
|
-
t.preventDefault(), r > 0 && c(r - 1);
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
if (t.key === "ArrowRight") {
|
|
178
|
-
t.preventDefault(), r < e - 1 && c(r + 1);
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
if (t.key === "Home") {
|
|
182
|
-
t.preventDefault(), c(0);
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
t.key === "End" && (t.preventDefault(), c(e - 1));
|
|
186
|
-
}, Z = (r) => (t) => {
|
|
187
|
-
const o = t.clipboardData.getData("text").replace(/\s+/g, ""), i = F(o);
|
|
188
|
-
if (!/^[0-9]+$/.test(i)) return;
|
|
189
|
-
t.preventDefault();
|
|
190
|
-
const g = d.current, D = g.slice(0, r), T = g.slice(r + i.length), A = (D + i + T).slice(0, e);
|
|
191
|
-
u(A);
|
|
192
|
-
const R = Math.min(r + i.length, e - 1);
|
|
193
|
-
c(R);
|
|
194
|
-
}, x = (r) => (t) => {
|
|
195
|
-
k(r), t.currentTarget.select();
|
|
196
|
-
}, L = v.id, V = oe(
|
|
197
|
-
() => ({
|
|
198
|
-
getValue: () => d.current,
|
|
199
|
-
setValue: (r) => u(r),
|
|
200
|
-
clear: () => u(""),
|
|
201
|
-
focus: () => c(f),
|
|
202
|
-
isComplete: () => d.current.length === e
|
|
203
|
-
}),
|
|
204
|
-
[u, c, f, e]
|
|
205
|
-
);
|
|
206
|
-
return de(pe, V, K), ie(W, () => V, [V]), /* @__PURE__ */ ee("div", { className: fe({ className: j }), children: [
|
|
207
|
-
I ? /* @__PURE__ */ y(
|
|
208
|
-
"label",
|
|
209
|
-
{
|
|
210
|
-
id: O,
|
|
211
|
-
htmlFor: `${L}-0`,
|
|
212
|
-
className: "type-label ds:text-foreground",
|
|
213
|
-
children: I
|
|
214
|
-
}
|
|
215
|
-
) : null,
|
|
216
|
-
/* @__PURE__ */ y(
|
|
217
|
-
"div",
|
|
218
|
-
{
|
|
219
|
-
role: "group",
|
|
220
|
-
dir: "ltr",
|
|
221
|
-
"aria-labelledby": O,
|
|
222
|
-
"aria-invalid": B || void 0,
|
|
223
|
-
"aria-describedby": v.describedBy || void 0,
|
|
224
|
-
"aria-disabled": b || void 0,
|
|
225
|
-
"data-component": "otp-input",
|
|
226
|
-
"data-component-id": K,
|
|
227
|
-
className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-sm)]",
|
|
228
|
-
children: J.map((r, t) => {
|
|
229
|
-
const s = !b && t === f;
|
|
230
|
-
return /* @__PURE__ */ y(
|
|
231
|
-
"input",
|
|
232
|
-
{
|
|
233
|
-
ref: (o) => {
|
|
234
|
-
E.current[t] = o;
|
|
235
|
-
},
|
|
236
|
-
id: `${L}-${t}`,
|
|
237
|
-
type: "text",
|
|
238
|
-
inputMode: "numeric",
|
|
239
|
-
pattern: "[0-9]*",
|
|
240
|
-
autoComplete: t === 0 ? "one-time-code" : "off",
|
|
241
|
-
maxLength: 1,
|
|
242
|
-
value: r,
|
|
243
|
-
disabled: b,
|
|
244
|
-
tabIndex: s ? 0 : -1,
|
|
245
|
-
"aria-label": _("inputs.otp.digitLabel", {
|
|
246
|
-
current: t + 1,
|
|
247
|
-
total: e
|
|
248
|
-
}),
|
|
249
|
-
onChange: X(t),
|
|
250
|
-
onKeyDown: Y(t),
|
|
251
|
-
onPaste: Z(t),
|
|
252
|
-
onFocus: x(t),
|
|
253
|
-
className: me({ tone: Q })
|
|
254
|
-
},
|
|
255
|
-
t
|
|
256
|
-
);
|
|
257
|
-
})
|
|
258
|
-
}
|
|
259
|
-
),
|
|
260
|
-
C ? /* @__PURE__ */ y("input", { type: "hidden", name: C, value: p, readOnly: !0 }) : null
|
|
261
|
-
] });
|
|
262
|
-
}
|
|
263
|
-
);
|
|
264
|
-
be.displayName = "OTPInput";
|
|
265
|
-
export {
|
|
266
|
-
be as O
|
|
267
|
-
};
|
|
268
|
-
//# sourceMappingURL=otp-input-Chb9r5vf.js.map
|