@alfadocs/ui-kit-debug 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/_chunks/otp-input-xQ4Ps5VY.js.map +1 -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/components/otp-input/otp-input.d.ts.map +1 -1
- package/dist/i18n/locales/ar.d.ts +1 -0
- package/dist/i18n/locales/ar.d.ts.map +1 -1
- package/dist/i18n/locales/ar.js +2 -1
- package/dist/i18n/locales/ar.js.map +1 -1
- package/dist/i18n/locales/de.d.ts +1 -0
- package/dist/i18n/locales/de.d.ts.map +1 -1
- package/dist/i18n/locales/de.js +2 -1
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/el.d.ts +1 -0
- package/dist/i18n/locales/el.d.ts.map +1 -1
- package/dist/i18n/locales/el.js +2 -1
- package/dist/i18n/locales/el.js.map +1 -1
- package/dist/i18n/locales/en.d.ts +1 -0
- package/dist/i18n/locales/en.d.ts.map +1 -1
- package/dist/i18n/locales/en.js +2 -1
- package/dist/i18n/locales/en.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +1 -0
- package/dist/i18n/locales/es.d.ts.map +1 -1
- package/dist/i18n/locales/es.js +2 -1
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +1 -0
- package/dist/i18n/locales/fr.d.ts.map +1 -1
- package/dist/i18n/locales/fr.js +2 -1
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hi.d.ts +1 -0
- package/dist/i18n/locales/hi.d.ts.map +1 -1
- package/dist/i18n/locales/hi.js +2 -1
- package/dist/i18n/locales/hi.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +1 -0
- package/dist/i18n/locales/it.d.ts.map +1 -1
- package/dist/i18n/locales/it.js +2 -1
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/ja.d.ts +1 -0
- package/dist/i18n/locales/ja.d.ts.map +1 -1
- package/dist/i18n/locales/ja.js +2 -1
- package/dist/i18n/locales/ja.js.map +1 -1
- package/dist/i18n/locales/nl.d.ts +1 -0
- package/dist/i18n/locales/nl.d.ts.map +1 -1
- package/dist/i18n/locales/nl.js +2 -1
- package/dist/i18n/locales/nl.js.map +1 -1
- package/dist/i18n/locales/pl.d.ts +1 -0
- package/dist/i18n/locales/pl.d.ts.map +1 -1
- package/dist/i18n/locales/pl.js +2 -1
- package/dist/i18n/locales/pl.js.map +1 -1
- package/dist/i18n/locales/pt.d.ts +1 -0
- package/dist/i18n/locales/pt.d.ts.map +1 -1
- package/dist/i18n/locales/pt.js +2 -1
- package/dist/i18n/locales/pt.js.map +1 -1
- package/dist/i18n/locales/ro.d.ts +1 -0
- package/dist/i18n/locales/ro.d.ts.map +1 -1
- package/dist/i18n/locales/ro.js +2 -1
- package/dist/i18n/locales/ro.js.map +1 -1
- package/dist/i18n/locales/ru.d.ts +1 -0
- package/dist/i18n/locales/ru.d.ts.map +1 -1
- package/dist/i18n/locales/ru.js +2 -1
- package/dist/i18n/locales/ru.js.map +1 -1
- package/dist/i18n/locales/sq.d.ts +1 -0
- package/dist/i18n/locales/sq.d.ts.map +1 -1
- package/dist/i18n/locales/sq.js +2 -1
- package/dist/i18n/locales/sq.js.map +1 -1
- package/dist/i18n/locales/sv.d.ts +1 -0
- package/dist/i18n/locales/sv.d.ts.map +1 -1
- package/dist/i18n/locales/sv.js +2 -1
- package/dist/i18n/locales/sv.js.map +1 -1
- package/dist/i18n/locales/tr.d.ts +1 -0
- package/dist/i18n/locales/tr.d.ts.map +1 -1
- package/dist/i18n/locales/tr.js +2 -1
- package/dist/i18n/locales/tr.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +1 -0
- package/dist/i18n/locales/zh.d.ts.map +1 -1
- package/dist/i18n/locales/zh.js +2 -1
- package/dist/i18n/locales/zh.js.map +1 -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
- package/dist/_chunks/otp-input-Chb9r5vf.js.map +0 -1
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otp-input-xQ4Ps5VY.js","sources":["../../src/components/otp-input/otp-input.agent.ts","../../src/components/otp-input/otp-input.tsx"],"sourcesContent":["/* -------------------------------------------------------------------- */\n/* Agent adapter — OTPInput. */\n/* */\n/* See `src/docs/26-agent-readiness.mdx` for the contract. */\n/* -------------------------------------------------------------------- */\n\nimport type { AgentAdapter } from '../../agent/types';\nimport type { OTPInputHandle } from './otp-input';\n\nexport const otpInputAgent: AgentAdapter<OTPInputHandle> = {\n id: 'otp-input',\n capabilities: ['edit_inline', 'submit'],\n state: {\n value: {\n type: 'string',\n descriptionKey: 'ui.agent.otpInput.state.value',\n description: 'Current digits entered, packed into a single string.',\n read: (handle) => handle.getValue(),\n },\n isComplete: {\n type: 'boolean',\n descriptionKey: 'ui.agent.otpInput.state.isComplete',\n description: 'Whether all required digits have been entered.',\n read: (handle) => handle.isComplete(),\n },\n },\n actions: {\n set_value: {\n safety: 'write',\n argsType: '{ value: string }',\n descriptionKey: 'ui.agent.otpInput.actions.setValue',\n description: 'Replace the entered digits.',\n invoke: (handle, args: { value: string }) => {\n handle.setValue(args.value);\n },\n },\n clear: {\n safety: 'destructive',\n descriptionKey: 'ui.agent.otpInput.actions.clear',\n description: 'Empty all digit cells. Loses any typed value.',\n invoke: (handle) => {\n handle.clear();\n },\n },\n focus: {\n safety: 'read',\n descriptionKey: 'ui.agent.otpInput.actions.focus',\n description: 'Move keyboard focus to the active digit cell.',\n invoke: (handle) => {\n handle.focus();\n },\n },\n },\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'otp-input',\n description:\n 'Marks the OTPInput wrapper. Completion is observable via state.isComplete; the host onComplete callback fires once when all digits are filled.',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description: 'Sourced from the id prop.',\n },\n },\n};\n","import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n type ChangeEvent,\n type ClipboardEvent,\n type FocusEvent,\n type KeyboardEvent,\n} from 'react';\nimport { cva } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { useControllableState } from '../../hooks/use-controllable-state';\nimport { useWebOtp } from '../../hooks/use-web-otp';\nimport { useFormField } from '../form-field/form-field-context';\nimport { useAgentRegistration } from '../../agent';\nimport { otpInputAgent } from './otp-input.agent';\n\nexport type OTPMode = 'numeric' | 'alphanumeric';\n\n/** Agent-readiness curated handle for OTPInput. */\nexport interface OTPInputHandle {\n getValue: () => string;\n setValue: (value: string) => void;\n clear: () => void;\n focus: () => void;\n isComplete: () => boolean;\n}\n\nconst wrapperVariants = cva('ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]');\n\nconst boxVariants = cva(\n [\n 'ds:w-[var(--min-target-size)] ds:h-[var(--min-target-size)]',\n 'ds:rounded-[var(--radius-sm)]',\n 'ds:border ds:bg-input ds:text-foreground ds:text-center ds:font-medium ds:text-[length:var(--font-size-lg)]',\n 'ds:shadow-[var(--shadow-input)]',\n 'ds:transition-[colors,box-shadow] ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none',\n 'ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid',\n 'ds:focus-visible:outline-ring ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]',\n 'ds:disabled:cursor-not-allowed ds:disabled:opacity-50',\n ].join(' '),\n {\n variants: {\n tone: {\n default: 'ds:border-border',\n error: 'ds:border-destructive',\n },\n },\n defaultVariants: { tone: 'default' },\n },\n);\n\nexport interface OTPInputProps {\n /**\n * Number of boxes. Default 6. Any integer in [3, 10] is honoured;\n * out-of-range values are clamped (with a DEV warning).\n */\n length?: number;\n value?: string;\n defaultValue?: string;\n onChange?: (value: string) => void;\n onComplete?: (code: string) => void;\n disabled?: boolean;\n error?: boolean;\n label?: string;\n /** Stable id, used to address this instance from the agent runtime. */\n id?: string;\n className?: string;\n /**\n * Opt into Chrome-Android's WebOTP API for one-tap SMS autofill. When\n * the browser surfaces a matching SMS-bound credential, the kit spreads\n * the code across every digit box and fires `onComplete` automatically.\n *\n * Falls back silently to manual entry on Firefox / desktop / iOS — those\n * platforms either don't ship the API at all or rely on the\n * `autocomplete=\"one-time-code\"` QuickType heuristic the kit already\n * applies to the first input.\n *\n * Prerequisites the prop can't enforce: page must be HTTPS, and the SMS\n * body must end with `@<origin> #<code>` on its last line (Chrome's\n * spec — without it the browser refuses to surface the message).\n * Default `false` so the listener stays opt-in.\n */\n webOtp?: boolean;\n /**\n * When set, renders a hidden `<input name={name}>` kept in sync with the\n * packed code so consumers can POST the OTP declaratively, e.g.\n * `sms_code_form[code]`. Default off — no behaviour change.\n */\n name?: string;\n /**\n * Character set. `numeric` (default) accepts digits only (with Arabic-Indic\n * digit folding) — byte-identical to prior behaviour. `alphanumeric` accepts\n * `[A-Za-z0-9]`, uppercases the value, and switches the boxes to text input\n * (for SMS codes that mix letters and digits).\n */\n mode?: OTPMode;\n}\n\nfunction normaliseDigits(str: string): string {\n return str\n .replace(/[\\u0660-\\u0669]/g, (c) => String(c.charCodeAt(0) - 0x0660))\n .replace(/[\\u06F0-\\u06F9]/g, (c) => String(c.charCodeAt(0) - 0x06f0));\n}\n\nconst MIN_LENGTH = 3;\nconst MAX_LENGTH = 10;\n\n/** Clamp an arbitrary length into a sane range; DEV-warn if it had to. */\nfunction resolveLength(length: number): number {\n // Fall back to the default for non-finite input (e.g. `length={parseInt(x)}`\n // yielding NaN) so the component never reaches `new Array(NaN)`.\n const n = Number.isFinite(length) ? Math.floor(length) : 6;\n const clamped = Math.max(MIN_LENGTH, Math.min(MAX_LENGTH, n));\n if (import.meta.env.DEV && clamped !== length) {\n console.warn(\n `[OTPInput] length ${length} is out of range [${MIN_LENGTH}, ${MAX_LENGTH}] \\u2014 clamped to ${clamped}.`,\n );\n }\n return clamped;\n}\n\n/**\n * Filter + normalise a string to the mode's charset, then clamp to length.\n * - `numeric`: Arabic-Indic digits folded to ASCII, then digits only.\n * - `alphanumeric`: `[A-Za-z0-9]` only, uppercased (codes are uppercase and the\n * server compares case-insensitively \\u2014 uppercasing keeps the display and the\n * posted value consistent).\n */\nfunction packValue(value: string, length: number, mode: OTPMode): string {\n const filtered =\n mode === 'alphanumeric'\n ? value.replace(/[^A-Za-z0-9]/g, '').toUpperCase()\n : normaliseDigits(value).replace(/\\D/g, '');\n return filtered.slice(0, length);\n}\n\nfunction valueToArray(value: string, length: number, mode: OTPMode): string[] {\n const packed = packValue(value, length, mode);\n const arr = new Array<string>(length).fill('');\n for (let i = 0; i < packed.length; i += 1) {\n arr[i] = packed[i];\n }\n return arr;\n}\n\nexport const OTPInput = forwardRef<OTPInputHandle, OTPInputProps>(\n (\n {\n length: lengthProp = 6,\n value,\n defaultValue,\n onChange,\n onComplete,\n disabled,\n error,\n label,\n id,\n className,\n webOtp = false,\n name,\n mode = 'numeric',\n },\n ref,\n ) => {\n const { t } = useTranslation();\n const length = resolveLength(lengthProp);\n const ctx = useFormField();\n const generatedLabelId = useId();\n const labelId = label ? generatedLabelId : undefined;\n\n const [internalValueRaw, setInternalValue] = useControllableState<string>({\n value,\n defaultValue: packValue(defaultValue ?? '', length, mode),\n });\n const currentValue = packValue(internalValueRaw ?? '', length, mode);\n const digits = valueToArray(currentValue, length, mode);\n\n const effectiveDisabled = ctx.disabled || Boolean(disabled);\n const effectiveError = ctx.invalid || Boolean(error);\n const effectiveTone = effectiveError ? 'error' : 'default';\n\n const inputsRef = useRef<Array<HTMLInputElement | null>>([]);\n const completedRef = useRef(currentValue.length === length);\n const valueRef = useRef(currentValue);\n valueRef.current = currentValue;\n\n const computeInitialIndex = () => {\n const firstEmpty = currentValue.length;\n if (firstEmpty >= length) return length - 1;\n return firstEmpty;\n };\n const [activeIndex, setActiveIndex] = useState<number>(computeInitialIndex);\n\n useEffect(() => {\n if (activeIndex >= length) setActiveIndex(length - 1);\n }, [activeIndex, length]);\n\n const focusBox = useCallback(\n (index: number) => {\n const clamped = Math.max(0, Math.min(length - 1, index));\n setActiveIndex(clamped);\n const node = inputsRef.current[clamped];\n if (node) {\n node.focus();\n node.select();\n }\n },\n [length],\n );\n\n const commit = useCallback(\n (next: string) => {\n const packed = packValue(next, length, mode);\n setInternalValue(packed);\n valueRef.current = packed;\n onChange?.(packed);\n if (packed.length === length) {\n if (!completedRef.current) {\n completedRef.current = true;\n onComplete?.(packed);\n }\n } else {\n completedRef.current = false;\n }\n },\n [setInternalValue, length, mode, onChange, onComplete],\n );\n\n // WebOTP one-tap autofill. The hook silently no-ops when the API is\n // unavailable (Firefox / Safari / desktop Chromium) — `commit()` is\n // the same path manual entry takes, so `onChange` + `onComplete` fire\n // identically whether the digits arrived via SMS, paste, or typing.\n useWebOtp({\n enabled: webOtp && !effectiveDisabled,\n onCode: commit,\n });\n\n const handleChange =\n (index: number) => (event: ChangeEvent<HTMLInputElement>) => {\n const raw = event.target.value;\n const norm =\n mode === 'alphanumeric'\n ? raw.replace(/[^A-Za-z0-9]/g, '').toUpperCase()\n : normaliseDigits(raw).replace(/\\D/g, '');\n const current = valueRef.current;\n\n if (norm.length === 0) {\n if (raw === '' && index < current.length) {\n const newValue = current.slice(0, index) + current.slice(index + 1);\n commit(newValue);\n }\n return;\n }\n\n const before = current.slice(0, index);\n const after = current.slice(index + norm.length);\n const newValue = (before + norm + after).slice(0, length);\n commit(newValue);\n\n const focusTarget = Math.min(index + norm.length, length - 1);\n focusBox(focusTarget);\n };\n\n const handleKeyDown =\n (index: number) => (event: KeyboardEvent<HTMLInputElement>) => {\n const current = valueRef.current;\n if (event.key === 'Backspace') {\n if (current[index]) {\n event.preventDefault();\n const newValue = current.slice(0, index) + current.slice(index + 1);\n commit(newValue);\n return;\n }\n if (index > 0) {\n event.preventDefault();\n const newValue = current.slice(0, index - 1) + current.slice(index);\n commit(newValue);\n focusBox(index - 1);\n }\n return;\n }\n if (event.key === 'ArrowLeft') {\n event.preventDefault();\n if (index > 0) focusBox(index - 1);\n return;\n }\n if (event.key === 'ArrowRight') {\n event.preventDefault();\n if (index < length - 1) focusBox(index + 1);\n return;\n }\n if (event.key === 'Home') {\n event.preventDefault();\n focusBox(0);\n return;\n }\n if (event.key === 'End') {\n event.preventDefault();\n focusBox(length - 1);\n }\n };\n\n const handlePaste =\n (index: number) => (event: ClipboardEvent<HTMLInputElement>) => {\n const text = event.clipboardData.getData('text');\n const stripped = text.replace(/\\s+/g, '');\n const norm =\n mode === 'alphanumeric'\n ? stripped.replace(/[^A-Za-z0-9]/g, '').toUpperCase()\n : normaliseDigits(stripped);\n // numeric: reject the whole paste unless it is all digits (byte-identical\n // to prior behaviour); alphanumeric: accept the stripped [A-Za-z0-9].\n if (\n mode === 'alphanumeric' ? norm.length === 0 : !/^[0-9]+$/.test(norm)\n ) {\n return;\n }\n event.preventDefault();\n const current = valueRef.current;\n const before = current.slice(0, index);\n const after = current.slice(index + norm.length);\n const newValue = (before + norm + after).slice(0, length);\n commit(newValue);\n const focusTarget = Math.min(index + norm.length, length - 1);\n focusBox(focusTarget);\n };\n\n const handleFocus =\n (index: number) => (event: FocusEvent<HTMLInputElement>) => {\n setActiveIndex(index);\n event.currentTarget.select();\n };\n\n const baseId = ctx.id;\n\n const agentHandle = useMemo<OTPInputHandle>(\n () => ({\n getValue: () => valueRef.current,\n setValue: (next) => commit(next),\n clear: () => commit(''),\n focus: () => focusBox(activeIndex),\n isComplete: () => valueRef.current.length === length,\n }),\n [commit, focusBox, activeIndex, length],\n );\n useAgentRegistration(otpInputAgent, agentHandle, id);\n // Expose the same imperative handle to React refs so consumers can\n // focus / read / clear the field (e.g. focus the boxes on a step change).\n useImperativeHandle(ref, () => agentHandle, [agentHandle]);\n\n return (\n <div className={wrapperVariants({ className })}>\n {label ? (\n <label\n id={labelId}\n htmlFor={`${baseId}-0`}\n className=\"type-label ds:text-foreground\"\n >\n {label}\n </label>\n ) : null}\n {/* eslint-disable-next-line jsx-a11y/role-supports-aria-props -- aria-invalid is a global ARIA state; conveys group-level validation */}\n <div\n role=\"group\"\n dir=\"ltr\"\n aria-labelledby={labelId}\n aria-invalid={effectiveError || undefined}\n aria-describedby={ctx.describedBy || undefined}\n aria-disabled={effectiveDisabled || undefined}\n data-component=\"otp-input\"\n data-component-id={id}\n className=\"ds:inline-flex ds:items-center ds:gap-[var(--spacing-sm)]\"\n >\n {digits.map((digit, index) => {\n const isTabbable = !effectiveDisabled && index === activeIndex;\n return (\n <input\n key={index}\n ref={(node) => {\n inputsRef.current[index] = node;\n }}\n id={`${baseId}-${index}`}\n type=\"text\"\n inputMode={mode === 'alphanumeric' ? 'text' : 'numeric'}\n pattern={mode === 'alphanumeric' ? '[A-Za-z0-9]*' : '[0-9]*'}\n autoCapitalize={\n mode === 'alphanumeric' ? 'characters' : undefined\n }\n autoComplete={index === 0 ? 'one-time-code' : 'off'}\n maxLength={1}\n value={digit}\n disabled={effectiveDisabled}\n tabIndex={isTabbable ? 0 : -1}\n aria-label={t(\n mode === 'alphanumeric'\n ? 'inputs.otp.charLabel'\n : 'inputs.otp.digitLabel',\n {\n current: index + 1,\n total: length,\n },\n )}\n onChange={handleChange(index)}\n onKeyDown={handleKeyDown(index)}\n onPaste={handlePaste(index)}\n onFocus={handleFocus(index)}\n className={boxVariants({ tone: effectiveTone })}\n />\n );\n })}\n </div>\n {name ? (\n <input type=\"hidden\" name={name} value={currentValue} readOnly />\n ) : null}\n </div>\n );\n },\n);\n\nOTPInput.displayName = 'OTPInput';\n"],"names":["otpInputAgent","handle","args","wrapperVariants","cva","boxVariants","normaliseDigits","str","c","MIN_LENGTH","MAX_LENGTH","resolveLength","length","packValue","value","mode","valueToArray","packed","arr","i","OTPInput","forwardRef","lengthProp","defaultValue","onChange","onComplete","disabled","error","label","id","className","webOtp","name","ref","t","useTranslation","ctx","useFormField","generatedLabelId","useId","labelId","internalValueRaw","setInternalValue","useControllableState","currentValue","digits","effectiveDisabled","effectiveError","effectiveTone","inputsRef","useRef","completedRef","valueRef","computeInitialIndex","firstEmpty","activeIndex","setActiveIndex","useState","useEffect","focusBox","useCallback","index","clamped","node","commit","next","useWebOtp","handleChange","event","raw","norm","current","newValue","before","after","focusTarget","handleKeyDown","handlePaste","stripped","handleFocus","baseId","agentHandle","useMemo","useAgentRegistration","useImperativeHandle","jsx","digit","isTabbable"],"mappings":";;;;;;;;AASO,MAAMA,KAA8C;AAAA,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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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otp-input.d.ts","sourceRoot":"","sources":["../../../src/components/otp-input/otp-input.tsx"],"names":[],"mappings":"AAsBA,mDAAmD;AACnD,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,MAAM,CAAC;IACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI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O,MAAM,QAAQ,0GAgRpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ar.d.ts","sourceRoot":"","sources":["../../../src/i18n/locales/ar.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,IAAI
|
|
1
|
+
{"version":3,"file":"ar.d.ts","sourceRoot":"","sources":["../../../src/i18n/locales/ar.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6lFP,CAAC"}
|
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: "الحد الأدنى",
|