@alfadocs/ui-kit-debug 0.52.0 → 0.54.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-CMphfBxZ.js → otp-input-Chb9r5vf.js} +89 -87
- package/dist/_chunks/{otp-input-CMphfBxZ.js.map → otp-input-Chb9r5vf.js.map} +1 -1
- package/dist/_chunks/{public-header.agent-BY6FH71R.js → public-header.agent-DyVpPwmv.js} +72 -62
- package/dist/_chunks/public-header.agent-DyVpPwmv.js.map +1 -0
- package/dist/_chunks/{sign-document-Bzld9jVM.js → sign-document-BzHTjMVC.js} +2 -2
- package/dist/_chunks/{sign-document-Bzld9jVM.js.map → sign-document-BzHTjMVC.js.map} +1 -1
- package/dist/_chunks/{signature-capture-CpMBhqQ9.js → signature-capture-CHbrKoA_.js} +163 -152
- package/dist/_chunks/signature-capture-CHbrKoA_.js.map +1 -0
- package/dist/_chunks/signature-field-DhscKdgk.js +152 -0
- package/dist/_chunks/signature-field-DhscKdgk.js.map +1 -0
- package/dist/_chunks/use-signing-session-C5evzYmo.js +108 -0
- package/dist/_chunks/use-signing-session-C5evzYmo.js.map +1 -0
- package/dist/agent-catalog.json +1 -1
- package/dist/components/index.d.ts +3 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/otp-input/index.js +1 -1
- package/dist/components/otp-input/otp-input.d.ts +6 -0
- package/dist/components/otp-input/otp-input.d.ts.map +1 -1
- package/dist/components/pdf-viewer/index.d.ts +1 -1
- package/dist/components/pdf-viewer/index.d.ts.map +1 -1
- package/dist/components/public-header/index.js +1 -1
- package/dist/components/public-header/public-header.d.ts +1 -1
- package/dist/components/public-header/public-header.d.ts.map +1 -1
- package/dist/components/sign-document/index.js +1 -1
- package/dist/components/signature-capture/index.js +1 -1
- package/dist/components/signature-capture/signature-capture.d.ts +7 -0
- package/dist/components/signature-capture/signature-capture.d.ts.map +1 -1
- package/dist/components/signature-field/index.d.ts +3 -0
- package/dist/components/signature-field/index.d.ts.map +1 -0
- package/dist/components/signature-field/index.js +6 -0
- package/dist/components/signature-field/index.js.map +1 -0
- package/dist/components/signature-field/signature-field.d.ts +35 -0
- package/dist/components/signature-field/signature-field.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +42 -41
- package/dist/hooks/use-signing-session.d.ts +36 -0
- package/dist/hooks/use-signing-session.d.ts.map +1 -0
- package/dist/i18n/locales/ar.d.ts +8 -0
- package/dist/i18n/locales/ar.d.ts.map +1 -1
- package/dist/i18n/locales/ar.js +8 -0
- package/dist/i18n/locales/ar.js.map +1 -1
- package/dist/i18n/locales/de.d.ts +8 -0
- package/dist/i18n/locales/de.d.ts.map +1 -1
- package/dist/i18n/locales/de.js +8 -0
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/el.d.ts +8 -0
- package/dist/i18n/locales/el.d.ts.map +1 -1
- package/dist/i18n/locales/el.js +8 -0
- package/dist/i18n/locales/el.js.map +1 -1
- package/dist/i18n/locales/en.d.ts +8 -0
- package/dist/i18n/locales/en.d.ts.map +1 -1
- package/dist/i18n/locales/en.js +8 -0
- package/dist/i18n/locales/en.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +8 -0
- package/dist/i18n/locales/es.d.ts.map +1 -1
- package/dist/i18n/locales/es.js +8 -0
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +8 -0
- package/dist/i18n/locales/fr.d.ts.map +1 -1
- package/dist/i18n/locales/fr.js +8 -0
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hi.d.ts +8 -0
- package/dist/i18n/locales/hi.d.ts.map +1 -1
- package/dist/i18n/locales/hi.js +8 -0
- package/dist/i18n/locales/hi.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +8 -0
- package/dist/i18n/locales/it.d.ts.map +1 -1
- package/dist/i18n/locales/it.js +8 -0
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/ja.d.ts +8 -0
- package/dist/i18n/locales/ja.d.ts.map +1 -1
- package/dist/i18n/locales/ja.js +8 -0
- package/dist/i18n/locales/ja.js.map +1 -1
- package/dist/i18n/locales/nl.d.ts +8 -0
- package/dist/i18n/locales/nl.d.ts.map +1 -1
- package/dist/i18n/locales/nl.js +8 -0
- package/dist/i18n/locales/nl.js.map +1 -1
- package/dist/i18n/locales/pl.d.ts +8 -0
- package/dist/i18n/locales/pl.d.ts.map +1 -1
- package/dist/i18n/locales/pl.js +8 -0
- package/dist/i18n/locales/pl.js.map +1 -1
- package/dist/i18n/locales/pt.d.ts +8 -0
- package/dist/i18n/locales/pt.d.ts.map +1 -1
- package/dist/i18n/locales/pt.js +8 -0
- package/dist/i18n/locales/pt.js.map +1 -1
- package/dist/i18n/locales/ro.d.ts +8 -0
- package/dist/i18n/locales/ro.d.ts.map +1 -1
- package/dist/i18n/locales/ro.js +8 -0
- package/dist/i18n/locales/ro.js.map +1 -1
- package/dist/i18n/locales/ru.d.ts +8 -0
- package/dist/i18n/locales/ru.d.ts.map +1 -1
- package/dist/i18n/locales/ru.js +8 -0
- package/dist/i18n/locales/ru.js.map +1 -1
- package/dist/i18n/locales/sq.d.ts +8 -0
- package/dist/i18n/locales/sq.d.ts.map +1 -1
- package/dist/i18n/locales/sq.js +8 -0
- package/dist/i18n/locales/sq.js.map +1 -1
- package/dist/i18n/locales/sv.d.ts +8 -0
- package/dist/i18n/locales/sv.d.ts.map +1 -1
- package/dist/i18n/locales/sv.js +8 -0
- package/dist/i18n/locales/sv.js.map +1 -1
- package/dist/i18n/locales/tr.d.ts +8 -0
- package/dist/i18n/locales/tr.d.ts.map +1 -1
- package/dist/i18n/locales/tr.js +8 -0
- package/dist/i18n/locales/tr.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +8 -0
- package/dist/i18n/locales/zh.d.ts.map +1 -1
- package/dist/i18n/locales/zh.js +8 -0
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.js +701 -697
- package/dist/index.js.map +1 -1
- package/dist/locales/ar.json +8 -0
- package/dist/locales/de.json +8 -0
- package/dist/locales/el.json +8 -0
- package/dist/locales/en.json +8 -0
- package/dist/locales/es.json +8 -0
- package/dist/locales/fr.json +8 -0
- package/dist/locales/hi.json +8 -0
- package/dist/locales/it.json +8 -0
- package/dist/locales/ja.json +8 -0
- package/dist/locales/nl.json +8 -0
- package/dist/locales/pl.json +8 -0
- package/dist/locales/pt.json +8 -0
- package/dist/locales/ro.json +8 -0
- package/dist/locales/ru.json +8 -0
- package/dist/locales/sq.json +8 -0
- package/dist/locales/sv.json +8 -0
- package/dist/locales/tr.json +8 -0
- package/dist/locales/zh.json +8 -0
- package/dist/tokens.css +1 -1
- package/package.json +5 -1
- package/dist/_chunks/public-header.agent-BY6FH71R.js.map +0 -1
- package/dist/_chunks/signature-capture-CpMBhqQ9.js.map +0 -1
- package/dist/_chunks/use-scroll-to-first-error-4Za-u5Nw.js +0 -43
- package/dist/_chunks/use-scroll-to-first-error-4Za-u5Nw.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { c as
|
|
4
|
-
import { useTranslation as
|
|
5
|
-
import { u as
|
|
6
|
-
import { u as
|
|
7
|
-
import { u as
|
|
8
|
-
import { u as
|
|
9
|
-
const
|
|
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
10
|
id: "otp-input",
|
|
11
11
|
capabilities: ["edit_inline", "submit"],
|
|
12
12
|
state: {
|
|
@@ -62,7 +62,7 @@ const de = {
|
|
|
62
62
|
description: "Sourced from the id prop."
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
},
|
|
65
|
+
}, fe = S("ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]"), me = S(
|
|
66
66
|
[
|
|
67
67
|
"ds:w-[var(--min-target-size)] ds:h-[var(--min-target-size)]",
|
|
68
68
|
"ds:rounded-[var(--radius-sm)]",
|
|
@@ -86,95 +86,96 @@ const de = {
|
|
|
86
86
|
function F(e) {
|
|
87
87
|
return e.replace(/[\u0660-\u0669]/g, (a) => String(a.charCodeAt(0) - 1632)).replace(/[\u06F0-\u06F9]/g, (a) => String(a.charCodeAt(0) - 1776));
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function w(e, a) {
|
|
90
90
|
return F(e).replace(/\D/g, "").slice(0, a);
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
const m =
|
|
92
|
+
function ve(e, a) {
|
|
93
|
+
const m = w(e, a), l = new Array(a).fill("");
|
|
94
94
|
for (let n = 0; n < m.length; n += 1)
|
|
95
95
|
l[n] = m[n];
|
|
96
96
|
return l;
|
|
97
97
|
}
|
|
98
|
-
const
|
|
98
|
+
const be = te(
|
|
99
99
|
({
|
|
100
100
|
length: e = 6,
|
|
101
101
|
value: a,
|
|
102
102
|
defaultValue: m,
|
|
103
103
|
onChange: l,
|
|
104
104
|
onComplete: n,
|
|
105
|
-
disabled:
|
|
106
|
-
error:
|
|
107
|
-
label:
|
|
105
|
+
disabled: H,
|
|
106
|
+
error: $,
|
|
107
|
+
label: I,
|
|
108
108
|
id: K,
|
|
109
|
-
className:
|
|
110
|
-
webOtp:
|
|
111
|
-
|
|
112
|
-
|
|
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({
|
|
113
114
|
value: a,
|
|
114
|
-
defaultValue:
|
|
115
|
-
}), p =
|
|
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);
|
|
116
117
|
d.current = p;
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
return
|
|
120
|
-
}, [f,
|
|
121
|
-
|
|
122
|
-
f >= e &&
|
|
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);
|
|
123
124
|
}, [f, e]);
|
|
124
125
|
const c = N(
|
|
125
|
-
(
|
|
126
|
-
const t = Math.max(0, Math.min(e - 1,
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
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());
|
|
130
131
|
},
|
|
131
132
|
[e]
|
|
132
133
|
), u = N(
|
|
133
|
-
(
|
|
134
|
-
const t =
|
|
135
|
-
P(t), d.current = t, l == null || l(t), t.length === e ?
|
|
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;
|
|
136
137
|
},
|
|
137
138
|
[P, e, l, n]
|
|
138
139
|
);
|
|
139
|
-
|
|
140
|
-
enabled:
|
|
140
|
+
ue({
|
|
141
|
+
enabled: z && !b,
|
|
141
142
|
onCode: u
|
|
142
143
|
});
|
|
143
|
-
const
|
|
144
|
-
const
|
|
144
|
+
const X = (r) => (t) => {
|
|
145
|
+
const s = t.target.value, o = F(s).replace(/\D/g, ""), i = d.current;
|
|
145
146
|
if (o.length === 0) {
|
|
146
|
-
if (
|
|
147
|
-
const
|
|
148
|
-
u(
|
|
147
|
+
if (s === "" && r < i.length) {
|
|
148
|
+
const R = i.slice(0, r) + i.slice(r + 1);
|
|
149
|
+
u(R);
|
|
149
150
|
}
|
|
150
151
|
return;
|
|
151
152
|
}
|
|
152
|
-
const g = i.slice(0,
|
|
153
|
-
u(
|
|
154
|
-
const
|
|
155
|
-
c(
|
|
156
|
-
},
|
|
157
|
-
const
|
|
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;
|
|
158
159
|
if (t.key === "Backspace") {
|
|
159
|
-
if (r
|
|
160
|
+
if (s[r]) {
|
|
160
161
|
t.preventDefault();
|
|
161
|
-
const o =
|
|
162
|
+
const o = s.slice(0, r) + s.slice(r + 1);
|
|
162
163
|
u(o);
|
|
163
164
|
return;
|
|
164
165
|
}
|
|
165
|
-
if (
|
|
166
|
+
if (r > 0) {
|
|
166
167
|
t.preventDefault();
|
|
167
|
-
const o =
|
|
168
|
-
u(o), c(
|
|
168
|
+
const o = s.slice(0, r - 1) + s.slice(r);
|
|
169
|
+
u(o), c(r - 1);
|
|
169
170
|
}
|
|
170
171
|
return;
|
|
171
172
|
}
|
|
172
173
|
if (t.key === "ArrowLeft") {
|
|
173
|
-
t.preventDefault(),
|
|
174
|
+
t.preventDefault(), r > 0 && c(r - 1);
|
|
174
175
|
return;
|
|
175
176
|
}
|
|
176
177
|
if (t.key === "ArrowRight") {
|
|
177
|
-
t.preventDefault(),
|
|
178
|
+
t.preventDefault(), r < e - 1 && c(r + 1);
|
|
178
179
|
return;
|
|
179
180
|
}
|
|
180
181
|
if (t.key === "Home") {
|
|
@@ -182,51 +183,51 @@ const ve = ee(
|
|
|
182
183
|
return;
|
|
183
184
|
}
|
|
184
185
|
t.key === "End" && (t.preventDefault(), c(e - 1));
|
|
185
|
-
},
|
|
186
|
+
}, Z = (r) => (t) => {
|
|
186
187
|
const o = t.clipboardData.getData("text").replace(/\s+/g, ""), i = F(o);
|
|
187
188
|
if (!/^[0-9]+$/.test(i)) return;
|
|
188
189
|
t.preventDefault();
|
|
189
|
-
const g = d.current,
|
|
190
|
-
u(
|
|
191
|
-
const
|
|
192
|
-
c(
|
|
193
|
-
},
|
|
194
|
-
|
|
195
|
-
}, L = v.id,
|
|
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(
|
|
196
197
|
() => ({
|
|
197
198
|
getValue: () => d.current,
|
|
198
|
-
setValue: (
|
|
199
|
+
setValue: (r) => u(r),
|
|
199
200
|
clear: () => u(""),
|
|
200
201
|
focus: () => c(f),
|
|
201
202
|
isComplete: () => d.current.length === e
|
|
202
203
|
}),
|
|
203
204
|
[u, c, f, e]
|
|
204
205
|
);
|
|
205
|
-
return
|
|
206
|
-
|
|
206
|
+
return de(pe, V, K), ie(W, () => V, [V]), /* @__PURE__ */ ee("div", { className: fe({ className: j }), children: [
|
|
207
|
+
I ? /* @__PURE__ */ y(
|
|
207
208
|
"label",
|
|
208
209
|
{
|
|
209
|
-
id:
|
|
210
|
+
id: O,
|
|
210
211
|
htmlFor: `${L}-0`,
|
|
211
212
|
className: "type-label ds:text-foreground",
|
|
212
|
-
children:
|
|
213
|
+
children: I
|
|
213
214
|
}
|
|
214
215
|
) : null,
|
|
215
|
-
/* @__PURE__ */
|
|
216
|
+
/* @__PURE__ */ y(
|
|
216
217
|
"div",
|
|
217
218
|
{
|
|
218
219
|
role: "group",
|
|
219
220
|
dir: "ltr",
|
|
220
|
-
"aria-labelledby":
|
|
221
|
+
"aria-labelledby": O,
|
|
221
222
|
"aria-invalid": B || void 0,
|
|
222
223
|
"aria-describedby": v.describedBy || void 0,
|
|
223
224
|
"aria-disabled": b || void 0,
|
|
224
225
|
"data-component": "otp-input",
|
|
225
226
|
"data-component-id": K,
|
|
226
227
|
className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-sm)]",
|
|
227
|
-
children:
|
|
228
|
-
const
|
|
229
|
-
return /* @__PURE__ */
|
|
228
|
+
children: J.map((r, t) => {
|
|
229
|
+
const s = !b && t === f;
|
|
230
|
+
return /* @__PURE__ */ y(
|
|
230
231
|
"input",
|
|
231
232
|
{
|
|
232
233
|
ref: (o) => {
|
|
@@ -238,29 +239,30 @@ const ve = ee(
|
|
|
238
239
|
pattern: "[0-9]*",
|
|
239
240
|
autoComplete: t === 0 ? "one-time-code" : "off",
|
|
240
241
|
maxLength: 1,
|
|
241
|
-
value:
|
|
242
|
+
value: r,
|
|
242
243
|
disabled: b,
|
|
243
|
-
tabIndex:
|
|
244
|
-
"aria-label":
|
|
244
|
+
tabIndex: s ? 0 : -1,
|
|
245
|
+
"aria-label": _("inputs.otp.digitLabel", {
|
|
245
246
|
current: t + 1,
|
|
246
247
|
total: e
|
|
247
248
|
}),
|
|
248
|
-
onChange:
|
|
249
|
-
onKeyDown:
|
|
250
|
-
onPaste:
|
|
251
|
-
onFocus:
|
|
252
|
-
className:
|
|
249
|
+
onChange: X(t),
|
|
250
|
+
onKeyDown: Y(t),
|
|
251
|
+
onPaste: Z(t),
|
|
252
|
+
onFocus: x(t),
|
|
253
|
+
className: me({ tone: Q })
|
|
253
254
|
},
|
|
254
255
|
t
|
|
255
256
|
);
|
|
256
257
|
})
|
|
257
258
|
}
|
|
258
|
-
)
|
|
259
|
+
),
|
|
260
|
+
C ? /* @__PURE__ */ y("input", { type: "hidden", name: C, value: p, readOnly: !0 }) : null
|
|
259
261
|
] });
|
|
260
262
|
}
|
|
261
263
|
);
|
|
262
|
-
|
|
264
|
+
be.displayName = "OTPInput";
|
|
263
265
|
export {
|
|
264
|
-
|
|
266
|
+
be as O
|
|
265
267
|
};
|
|
266
|
-
//# sourceMappingURL=otp-input-
|
|
268
|
+
//# sourceMappingURL=otp-input-Chb9r5vf.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otp-input-CMphfBxZ.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\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 length?: 4 | 6 | 8;\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\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\nfunction packValue(value: string, length: number): string {\n return normaliseDigits(value).replace(/\\D/g, '').slice(0, length);\n}\n\nfunction valueToArray(value: string, length: number): string[] {\n const packed = packValue(value, length);\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 = 6,\n value,\n defaultValue,\n onChange,\n onComplete,\n disabled,\n error,\n label,\n id,\n className,\n webOtp = false,\n },\n ref,\n ) => {\n const { t } = useTranslation();\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),\n });\n const currentValue = packValue(internalValueRaw ?? '', length);\n const digits = valueToArray(currentValue, length);\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);\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, 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 = 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 = normaliseDigits(stripped);\n if (!/^[0-9]+$/.test(norm)) return;\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=\"numeric\"\n pattern=\"[0-9]*\"\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('inputs.otp.digitLabel', {\n current: index + 1,\n total: length,\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 </div>\n );\n },\n);\n\nOTPInput.displayName = 'OTPInput';\n"],"names":["otpInputAgent","handle","args","wrapperVariants","cva","boxVariants","normaliseDigits","str","c","packValue","value","length","valueToArray","packed","arr","i","OTPInput","forwardRef","defaultValue","onChange","onComplete","disabled","error","label","id","className","webOtp","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,EACzD,IAAI;AAAA,EACJ,cAAc,CAAC,eAAe,QAAQ;AAAA,EACtC,OAAO;AAAA,IACL,OAAO;AAAA,MACL,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,MAAM,CAACC,MAAWA,EAAO,SAAA;AAAA,IAAS;AAAA,IAEpC,YAAY;AAAA,MACV,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,MAAM,CAACA,MAAWA,EAAO,WAAA;AAAA,IAAW;AAAA,EACtC;AAAA,EAEF,SAAS;AAAA,IACP,WAAW;AAAA,MACT,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,QAAQ,CAACA,GAAQC,MAA4B;AAC3C,QAAAD,EAAO,SAASC,EAAK,KAAK;AAAA,MAC5B;AAAA,IAAA;AAAA,IAEF,OAAO;AAAA,MACL,QAAQ;AAAA,MACR,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,QAAQ,CAACD,MAAW;AAClB,QAAAA,EAAO,MAAA;AAAA,MACT;AAAA,IAAA;AAAA,IAEF,OAAO;AAAA,MACL,QAAQ;AAAA,MACR,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,QAAQ,CAACA,MAAW;AAClB,QAAAA,EAAO,MAAA;AAAA,MACT;AAAA,IAAA;AAAA,EACF;AAAA,EAEF,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,OAAO;AAAA,MACP,aACE;AAAA,IAAA;AAAA,IAEJ,YAAY;AAAA,MACV,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,aAAa;AAAA,IAAA;AAAA,EACf;AAEJ,GCnCME,KAAkBC,EAAI,gDAAgD,GAEtEC,K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A,MAAU,IAAI,kBAAkB;AAAA,gBAC9C,WAAW;AAAA,gBACX,OAAOyB;AAAA,gBACP,UAAUxC;AAAA,gBACV,UAAUyC,IAAa,IAAI;AAAA,gBAC3B,cAAYrD,EAAE,yBAAyB;AAAA,kBACrC,SAAS2B,IAAQ;AAAA,kBACjB,OAAO5C;AAAA,gBAAA,CACR;AAAA,gBACD,UAAUkD,EAAaN,CAAK;AAAA,gBAC5B,WAAWe,EAAcf,CAAK;AAAA,gBAC9B,SAASgB,EAAYhB,CAAK;AAAA,gBAC1B,SAASkB,EAAYlB,CAAK;AAAA,gBAC1B,WAAWlD,GAAY,EAAE,MAAMqC,GAAe;AAAA,cAAA;AAAA,cArBzCa;AAAA,YAAA;AAAA,UAwBX,CAAC;AAAA,QAAA;AAAA,MAAA;AAAA,IACH,GACF;AAAA,EAEJ;AACF;AAEAvC,GAAS,cAAc;"}
|
|
1
|
+
{"version":3,"file":"otp-input-Chb9r5vf.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\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 length?: 4 | 6 | 8;\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\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\nfunction packValue(value: string, length: number): string {\n return normaliseDigits(value).replace(/\\D/g, '').slice(0, length);\n}\n\nfunction valueToArray(value: string, length: number): string[] {\n const packed = packValue(value, length);\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 = 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 },\n ref,\n ) => {\n const { t } = useTranslation();\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),\n });\n const currentValue = packValue(internalValueRaw ?? '', length);\n const digits = valueToArray(currentValue, length);\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);\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, 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 = 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 = normaliseDigits(stripped);\n if (!/^[0-9]+$/.test(norm)) return;\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=\"numeric\"\n pattern=\"[0-9]*\"\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('inputs.otp.digitLabel', {\n current: index + 1,\n total: length,\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","packValue","value","length","valueToArray","packed","arr","i","OTPInput","forwardRef","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,EACzD,IAAI;AAAA,EACJ,cAAc,CAAC,eAAe,QAAQ;AAAA,EACtC,OAAO;AAAA,IACL,OAAO;AAAA,MACL,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,MAAM,CAACC,MAAWA,EAAO,SAAA;AAAA,IAAS;AAAA,IAEpC,YAAY;AAAA,MACV,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,MAAM,CAACA,MAAWA,EAAO,WAAA;AAAA,IAAW;AAAA,EACtC;AAAA,EAEF,SAAS;AAAA,IACP,WAAW;AAAA,MACT,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,QAAQ,CAACA,GAAQC,MAA4B;AAC3C,QAAAD,EAAO,SAASC,EAAK,KAAK;AAAA,MAC5B;AAAA,IAAA;AAAA,IAEF,OAAO;AAAA,MACL,QAAQ;AAAA,MACR,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,QAAQ,CAACD,MAAW;AAClB,QAAAA,EAAO,MAAA;AAAA,MACT;AAAA,IAAA;AAAA,IAEF,OAAO;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