@alfadocs/ui-kit-debug 0.33.1 → 0.33.3
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/{map-view-knHSNLoe.js → map-view-ZgbhfRqy.js} +384 -376
- package/dist/_chunks/{map-view-knHSNLoe.js.map → map-view-ZgbhfRqy.js.map} +1 -1
- package/dist/_chunks/{otp-input-BEg_sn8A.js → otp-input-CDTWT5EK.js} +83 -76
- package/dist/_chunks/otp-input-CDTWT5EK.js.map +1 -0
- package/dist/_chunks/{practice-results-Dwm5tzLV.js → practice-results-YD4dvqje.js} +2 -2
- package/dist/_chunks/{practice-results-Dwm5tzLV.js.map → practice-results-YD4dvqje.js.map} +1 -1
- package/dist/_chunks/use-web-otp-D_utzp6S.js +33 -0
- package/dist/_chunks/use-web-otp-D_utzp6S.js.map +1 -0
- package/dist/agent-catalog.json +1 -1
- package/dist/components/map-view/index.js +1 -1
- package/dist/components/map-view/map-view.d.ts.map +1 -1
- package/dist/components/otp-input/index.js +1 -1
- package/dist/components/otp-input/otp-input.d.ts +16 -0
- package/dist/components/otp-input/otp-input.d.ts.map +1 -1
- package/dist/components/practice-results/index.js +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +27 -25
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/use-web-otp.d.ts +22 -0
- package/dist/hooks/use-web-otp.d.ts.map +1 -0
- package/dist/index.js +3 -3
- package/package.json +1 -1
- package/dist/_chunks/otp-input-BEg_sn8A.js.map +0 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { jsxs as x, jsx as A } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as ee, useId as te, useRef as R, useState as se, useEffect as re, useCallback as L, useMemo as ae } from "react";
|
|
3
3
|
import { c as N } from "./index-D2ZczOXr.js";
|
|
4
|
-
import { useTranslation as
|
|
5
|
-
import { u as
|
|
6
|
-
import { u as
|
|
7
|
-
import { u as
|
|
8
|
-
|
|
4
|
+
import { useTranslation as oe } from "react-i18next";
|
|
5
|
+
import { u as ie } from "./use-controllable-state-BiY4xTzM.js";
|
|
6
|
+
import { u as ne } from "./use-web-otp-D_utzp6S.js";
|
|
7
|
+
import { u as ce } from "./form-field-context-B3APVHKx.js";
|
|
8
|
+
import { u as ue } from "./registry-nPAVE19X.js";
|
|
9
|
+
const le = {
|
|
9
10
|
id: "otp-input",
|
|
10
11
|
capabilities: ["edit_inline", "submit"],
|
|
11
12
|
state: {
|
|
@@ -61,7 +62,7 @@ const ce = {
|
|
|
61
62
|
description: "Sourced from the id prop."
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
|
-
},
|
|
65
|
+
}, de = N("ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]"), pe = N(
|
|
65
66
|
[
|
|
66
67
|
"ds:w-[var(--min-target-size)] ds:h-[var(--min-target-size)]",
|
|
67
68
|
"ds:rounded-[var(--radius-sm)]",
|
|
@@ -85,89 +86,95 @@ const ce = {
|
|
|
85
86
|
function M(e) {
|
|
86
87
|
return e.replace(/[\u0660-\u0669]/g, (a) => String(a.charCodeAt(0) - 1632)).replace(/[\u06F0-\u06F9]/g, (a) => String(a.charCodeAt(0) - 1776));
|
|
87
88
|
}
|
|
88
|
-
function
|
|
89
|
+
function y(e, a) {
|
|
89
90
|
return M(e).replace(/\D/g, "").slice(0, a);
|
|
90
91
|
}
|
|
91
|
-
function
|
|
92
|
-
const m =
|
|
92
|
+
function fe(e, a) {
|
|
93
|
+
const m = y(e, a), l = new Array(a).fill("");
|
|
93
94
|
for (let n = 0; n < m.length; n += 1)
|
|
94
95
|
l[n] = m[n];
|
|
95
96
|
return l;
|
|
96
97
|
}
|
|
97
|
-
const
|
|
98
|
+
const me = ee(
|
|
98
99
|
({
|
|
99
100
|
length: e = 6,
|
|
100
101
|
value: a,
|
|
101
102
|
defaultValue: m,
|
|
102
103
|
onChange: l,
|
|
103
104
|
onComplete: n,
|
|
104
|
-
disabled:
|
|
105
|
-
error:
|
|
106
|
-
label:
|
|
105
|
+
disabled: O,
|
|
106
|
+
error: S,
|
|
107
|
+
label: w,
|
|
107
108
|
id: F,
|
|
108
|
-
className:
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
className: $,
|
|
110
|
+
webOtp: j = !1
|
|
111
|
+
}, z) => {
|
|
112
|
+
const { t: H } = oe(), b = ce(), W = te(), K = w ? W : void 0, [_, C] = ie({
|
|
111
113
|
value: a,
|
|
112
|
-
defaultValue:
|
|
113
|
-
}), p =
|
|
114
|
+
defaultValue: y(m ?? "", e)
|
|
115
|
+
}), p = y(_ ?? "", e), q = fe(p, e), v = b.disabled || !!O, P = b.invalid || !!S, G = P ? "error" : "default", B = R([]), I = R(p.length === e), d = R(p);
|
|
114
116
|
d.current = p;
|
|
115
|
-
const
|
|
116
|
-
const
|
|
117
|
-
return
|
|
118
|
-
}, [f, h] =
|
|
117
|
+
const J = () => {
|
|
118
|
+
const s = p.length;
|
|
119
|
+
return s >= e ? e - 1 : s;
|
|
120
|
+
}, [f, h] = se(J);
|
|
119
121
|
re(() => {
|
|
120
122
|
f >= e && h(e - 1);
|
|
121
123
|
}, [f, e]);
|
|
122
124
|
const c = L(
|
|
123
|
-
(
|
|
124
|
-
const t = Math.max(0, Math.min(e - 1,
|
|
125
|
+
(s) => {
|
|
126
|
+
const t = Math.max(0, Math.min(e - 1, s));
|
|
125
127
|
h(t);
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
+
const r = B.current[t];
|
|
129
|
+
r && (r.focus(), r.select());
|
|
128
130
|
},
|
|
129
131
|
[e]
|
|
130
132
|
), u = L(
|
|
131
|
-
(
|
|
132
|
-
const t =
|
|
133
|
-
|
|
133
|
+
(s) => {
|
|
134
|
+
const t = y(s, e);
|
|
135
|
+
C(t), d.current = t, l == null || l(t), t.length === e ? I.current || (I.current = !0, n == null || n(t)) : I.current = !1;
|
|
134
136
|
},
|
|
135
|
-
[
|
|
136
|
-
)
|
|
137
|
-
|
|
137
|
+
[C, e, l, n]
|
|
138
|
+
);
|
|
139
|
+
ne({
|
|
140
|
+
enabled: j && !v,
|
|
141
|
+
onCode: u
|
|
142
|
+
});
|
|
143
|
+
const Q = (s) => (t) => {
|
|
144
|
+
const r = t.target.value, o = M(r).replace(/\D/g, ""), i = d.current;
|
|
138
145
|
if (o.length === 0) {
|
|
139
|
-
if (
|
|
140
|
-
const T = i.slice(0,
|
|
146
|
+
if (r === "" && s < i.length) {
|
|
147
|
+
const T = i.slice(0, s) + i.slice(s + 1);
|
|
141
148
|
u(T);
|
|
142
149
|
}
|
|
143
150
|
return;
|
|
144
151
|
}
|
|
145
|
-
const
|
|
152
|
+
const g = i.slice(0, s), k = i.slice(s + o.length), V = (g + o + k).slice(0, e);
|
|
146
153
|
u(V);
|
|
147
|
-
const D = Math.min(
|
|
154
|
+
const D = Math.min(s + o.length, e - 1);
|
|
148
155
|
c(D);
|
|
149
|
-
},
|
|
150
|
-
const
|
|
156
|
+
}, U = (s) => (t) => {
|
|
157
|
+
const r = d.current;
|
|
151
158
|
if (t.key === "Backspace") {
|
|
152
|
-
if (s
|
|
159
|
+
if (r[s]) {
|
|
153
160
|
t.preventDefault();
|
|
154
|
-
const o =
|
|
161
|
+
const o = r.slice(0, s) + r.slice(s + 1);
|
|
155
162
|
u(o);
|
|
156
163
|
return;
|
|
157
164
|
}
|
|
158
|
-
if (
|
|
165
|
+
if (s > 0) {
|
|
159
166
|
t.preventDefault();
|
|
160
|
-
const o =
|
|
161
|
-
u(o), c(
|
|
167
|
+
const o = r.slice(0, s - 1) + r.slice(s);
|
|
168
|
+
u(o), c(s - 1);
|
|
162
169
|
}
|
|
163
170
|
return;
|
|
164
171
|
}
|
|
165
172
|
if (t.key === "ArrowLeft") {
|
|
166
|
-
t.preventDefault(),
|
|
173
|
+
t.preventDefault(), s > 0 && c(s - 1);
|
|
167
174
|
return;
|
|
168
175
|
}
|
|
169
176
|
if (t.key === "ArrowRight") {
|
|
170
|
-
t.preventDefault(),
|
|
177
|
+
t.preventDefault(), s < e - 1 && c(s + 1);
|
|
171
178
|
return;
|
|
172
179
|
}
|
|
173
180
|
if (t.key === "Home") {
|
|
@@ -175,56 +182,56 @@ const pe = x(
|
|
|
175
182
|
return;
|
|
176
183
|
}
|
|
177
184
|
t.key === "End" && (t.preventDefault(), c(e - 1));
|
|
178
|
-
},
|
|
185
|
+
}, X = (s) => (t) => {
|
|
179
186
|
const o = t.clipboardData.getData("text").replace(/\s+/g, ""), i = M(o);
|
|
180
187
|
if (!/^[0-9]+$/.test(i)) return;
|
|
181
188
|
t.preventDefault();
|
|
182
|
-
const
|
|
189
|
+
const g = d.current, k = g.slice(0, s), V = g.slice(s + i.length), D = (k + i + V).slice(0, e);
|
|
183
190
|
u(D);
|
|
184
|
-
const T = Math.min(
|
|
191
|
+
const T = Math.min(s + i.length, e - 1);
|
|
185
192
|
c(T);
|
|
186
|
-
},
|
|
187
|
-
h(
|
|
188
|
-
}, E =
|
|
193
|
+
}, Y = (s) => (t) => {
|
|
194
|
+
h(s), t.currentTarget.select();
|
|
195
|
+
}, E = b.id, Z = ae(
|
|
189
196
|
() => ({
|
|
190
197
|
getValue: () => d.current,
|
|
191
|
-
setValue: (
|
|
198
|
+
setValue: (s) => u(s),
|
|
192
199
|
clear: () => u(""),
|
|
193
200
|
focus: () => c(f),
|
|
194
201
|
isComplete: () => d.current.length === e
|
|
195
202
|
}),
|
|
196
203
|
[u, c, f, e]
|
|
197
204
|
);
|
|
198
|
-
return
|
|
199
|
-
|
|
205
|
+
return ue(le, Z, F), /* @__PURE__ */ x("div", { className: de({ className: $ }), children: [
|
|
206
|
+
w ? /* @__PURE__ */ A(
|
|
200
207
|
"label",
|
|
201
208
|
{
|
|
202
209
|
id: K,
|
|
203
210
|
htmlFor: `${E}-0`,
|
|
204
211
|
className: "type-label ds:text-foreground",
|
|
205
|
-
children:
|
|
212
|
+
children: w
|
|
206
213
|
}
|
|
207
214
|
) : null,
|
|
208
215
|
/* @__PURE__ */ A(
|
|
209
216
|
"div",
|
|
210
217
|
{
|
|
211
|
-
ref:
|
|
218
|
+
ref: z,
|
|
212
219
|
role: "group",
|
|
213
220
|
dir: "ltr",
|
|
214
221
|
"aria-labelledby": K,
|
|
215
|
-
"aria-invalid":
|
|
216
|
-
"aria-describedby":
|
|
217
|
-
"aria-disabled":
|
|
222
|
+
"aria-invalid": P || void 0,
|
|
223
|
+
"aria-describedby": b.describedBy || void 0,
|
|
224
|
+
"aria-disabled": v || void 0,
|
|
218
225
|
"data-component": "otp-input",
|
|
219
226
|
"data-component-id": F,
|
|
220
227
|
className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-sm)]",
|
|
221
|
-
children: q.map((
|
|
222
|
-
const
|
|
228
|
+
children: q.map((s, t) => {
|
|
229
|
+
const r = !v && t === f;
|
|
223
230
|
return /* @__PURE__ */ A(
|
|
224
231
|
"input",
|
|
225
232
|
{
|
|
226
233
|
ref: (o) => {
|
|
227
|
-
|
|
234
|
+
B.current[t] = o;
|
|
228
235
|
},
|
|
229
236
|
id: `${E}-${t}`,
|
|
230
237
|
type: "text",
|
|
@@ -232,18 +239,18 @@ const pe = x(
|
|
|
232
239
|
pattern: "[0-9]*",
|
|
233
240
|
autoComplete: t === 0 ? "one-time-code" : "off",
|
|
234
241
|
maxLength: 1,
|
|
235
|
-
value:
|
|
236
|
-
disabled:
|
|
237
|
-
tabIndex:
|
|
238
|
-
"aria-label":
|
|
242
|
+
value: s,
|
|
243
|
+
disabled: v,
|
|
244
|
+
tabIndex: r ? 0 : -1,
|
|
245
|
+
"aria-label": H("inputs.otp.digitLabel", {
|
|
239
246
|
current: t + 1,
|
|
240
247
|
total: e
|
|
241
248
|
}),
|
|
242
|
-
onChange:
|
|
243
|
-
onKeyDown:
|
|
244
|
-
onPaste:
|
|
245
|
-
onFocus:
|
|
246
|
-
className:
|
|
249
|
+
onChange: Q(t),
|
|
250
|
+
onKeyDown: U(t),
|
|
251
|
+
onPaste: X(t),
|
|
252
|
+
onFocus: Y(t),
|
|
253
|
+
className: pe({ tone: G })
|
|
247
254
|
},
|
|
248
255
|
t
|
|
249
256
|
);
|
|
@@ -253,8 +260,8 @@ const pe = x(
|
|
|
253
260
|
] });
|
|
254
261
|
}
|
|
255
262
|
);
|
|
256
|
-
|
|
263
|
+
me.displayName = "OTPInput";
|
|
257
264
|
export {
|
|
258
|
-
|
|
265
|
+
me as O
|
|
259
266
|
};
|
|
260
|
-
//# sourceMappingURL=otp-input-
|
|
267
|
+
//# sourceMappingURL=otp-input-CDTWT5EK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otp-input-CDTWT5EK.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 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<HTMLDivElement, 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\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 ref={ref}\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","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,GCpCME,KAAkBC,EAAI,gDAAgD,GAEtEC,KAAcD;AAAA,EAClB;A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OwB;AAAA,gBACP,UAAUvC;AAAA,gBACV,UAAUwC,IAAa,IAAI;AAAA,gBAC3B,cAAYpD,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;"}
|
|
@@ -7,7 +7,7 @@ import { A as we } from "./avatar-BNQNhoyL.js";
|
|
|
7
7
|
import { B as G } from "./button-DD_0Xdmr.js";
|
|
8
8
|
import { D as H } from "./dropdown-menu-BC5ZdOMo.js";
|
|
9
9
|
import { E as Qe } from "./empty-state-BLy7tigq.js";
|
|
10
|
-
import { M as Je } from "./map-view-
|
|
10
|
+
import { M as Je } from "./map-view-ZgbhfRqy.js";
|
|
11
11
|
import { R as ke } from "./rating-BRD7O74e.js";
|
|
12
12
|
import { S as z } from "./sheet-BV-yuLE2.js";
|
|
13
13
|
import { S as We } from "./skeleton-CZbwyJAA.js";
|
|
@@ -1565,4 +1565,4 @@ export {
|
|
|
1565
1565
|
kt as P,
|
|
1566
1566
|
it as p
|
|
1567
1567
|
};
|
|
1568
|
-
//# sourceMappingURL=practice-results-
|
|
1568
|
+
//# sourceMappingURL=practice-results-YD4dvqje.js.map
|