@alfadocs/ui-kit-debug 0.12.0 → 0.13.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/{ai-prompt-input-noh-N3cf.js → ai-prompt-input-DEiQwIMn.js} +21 -20
- package/dist/_chunks/ai-prompt-input-DEiQwIMn.js.map +1 -0
- package/dist/_chunks/{audio-recorder-BHBonrFf.js → audio-recorder-CRh4uyFL.js} +2 -2
- package/dist/_chunks/{audio-recorder-BHBonrFf.js.map → audio-recorder-CRh4uyFL.js.map} +1 -1
- package/dist/_chunks/{autocomplete-C34hbfKh.js → autocomplete-mOg7WLOh.js} +2 -2
- package/dist/_chunks/{autocomplete-C34hbfKh.js.map → autocomplete-mOg7WLOh.js.map} +1 -1
- package/dist/_chunks/{chat-input-Bov-gkwP.js → chat-input-UK-bXU7u.js} +9 -8
- package/dist/_chunks/chat-input-UK-bXU7u.js.map +1 -0
- package/dist/_chunks/{combobox-BHhnR3qm.js → combobox-D5tWe0t_.js} +2 -2
- package/dist/_chunks/{combobox-BHhnR3qm.js.map → combobox-D5tWe0t_.js.map} +1 -1
- package/dist/_chunks/{date-picker-BD5FYW08.js → date-picker-BlhtBhPo.js} +2 -2
- package/dist/_chunks/{date-picker-BD5FYW08.js.map → date-picker-BlhtBhPo.js.map} +1 -1
- package/dist/_chunks/{date-range-picker-BZLVgcXE.js → date-range-picker-C2hRu_Ke.js} +2 -2
- package/dist/_chunks/{date-range-picker-BZLVgcXE.js.map → date-range-picker-C2hRu_Ke.js.map} +1 -1
- package/dist/_chunks/{date-time-picker-CCoRWX7R.js → date-time-picker-B67mPZmP.js} +2 -2
- package/dist/_chunks/{date-time-picker-CCoRWX7R.js.map → date-time-picker-B67mPZmP.js.map} +1 -1
- package/dist/_chunks/{input-surface-u4QB0lxe.js → input-surface-xyERuLU_.js} +9 -3
- package/dist/_chunks/input-surface-xyERuLU_.js.map +1 -0
- package/dist/_chunks/{leo-sidebar-B054wsZm.js → leo-sidebar-D3TuyH5_.js} +2 -2
- package/dist/_chunks/{leo-sidebar-B054wsZm.js.map → leo-sidebar-D3TuyH5_.js.map} +1 -1
- package/dist/_chunks/{multi-select-Bh-xR8kP.js → multi-select-DooDzQIp.js} +2 -2
- package/dist/_chunks/{multi-select-Bh-xR8kP.js.map → multi-select-DooDzQIp.js.map} +1 -1
- package/dist/_chunks/{number-input-mpSLk-ld.js → number-input-DH00o0DN.js} +28 -27
- package/dist/_chunks/number-input-DH00o0DN.js.map +1 -0
- package/dist/_chunks/{otp-input-CI-Zv5q6.js → otp-input-BBXYvLx5.js} +49 -48
- package/dist/_chunks/otp-input-BBXYvLx5.js.map +1 -0
- package/dist/_chunks/{phone-input-DtBVs5fz.js → phone-input-DKSHX7NQ.js} +23 -22
- package/dist/_chunks/phone-input-DKSHX7NQ.js.map +1 -0
- package/dist/_chunks/{react-day-picker-C04L_28V.js → react-day-picker-C5F3-TTX.js} +6 -3
- package/dist/_chunks/{react-day-picker-C04L_28V.js.map → react-day-picker-C5F3-TTX.js.map} +1 -1
- package/dist/_chunks/{search-bar-DmZZ9UvV.js → search-bar-DORSAzNt.js} +2 -2
- package/dist/_chunks/{search-bar-DmZZ9UvV.js.map → search-bar-DORSAzNt.js.map} +1 -1
- package/dist/_chunks/{search-input-BBtSRH-Q.js → search-input-BtEJAJHa.js} +2 -2
- package/dist/_chunks/{search-input-BBtSRH-Q.js.map → search-input-BtEJAJHa.js.map} +1 -1
- package/dist/_chunks/{select-i9MwQeQy.js → select-Ca6ibiDL.js} +13 -12
- package/dist/_chunks/select-Ca6ibiDL.js.map +1 -0
- package/dist/_chunks/{tabs-Cg794H0Q.js → tabs-CRCyPpJo.js} +2 -2
- package/dist/_chunks/{tabs-Cg794H0Q.js.map → tabs-CRCyPpJo.js.map} +1 -1
- package/dist/_chunks/{text-area-DHtcpcLv.js → text-area-D5GAe8pV.js} +26 -25
- package/dist/_chunks/text-area-D5GAe8pV.js.map +1 -0
- package/dist/_chunks/{text-input-1oqFRbVI.js → text-input-CakysYnD.js} +26 -25
- package/dist/_chunks/text-input-CakysYnD.js.map +1 -0
- package/dist/_chunks/{transcript-panel-BpJqPr7I.js → transcript-panel-DUrjx5sa.js} +2 -2
- package/dist/_chunks/{transcript-panel-BpJqPr7I.js.map → transcript-panel-DUrjx5sa.js.map} +1 -1
- package/dist/_chunks/{use-password-requirements-DbPZMfV9.js → use-password-requirements-BOgFsoIe.js} +2 -2
- package/dist/_chunks/{use-password-requirements-DbPZMfV9.js.map → use-password-requirements-BOgFsoIe.js.map} +1 -1
- package/dist/agent-catalog.json +1 -1
- package/dist/components/_shared/date-picker-variants.d.ts.map +1 -1
- package/dist/components/_shared/input-surface.d.ts.map +1 -1
- package/dist/components/ai-prompt-input/ai-prompt-input.d.ts.map +1 -1
- package/dist/components/ai-prompt-input/index.js +1 -1
- package/dist/components/audio-recorder/index.js +1 -1
- package/dist/components/autocomplete/index.js +1 -1
- package/dist/components/chat-input/chat-input.d.ts.map +1 -1
- package/dist/components/chat-input/index.js +1 -1
- package/dist/components/combobox/index.js +1 -1
- package/dist/components/date-picker/index.js +1 -1
- package/dist/components/date-range-picker/index.js +1 -1
- package/dist/components/date-time-picker/index.js +1 -1
- package/dist/components/multi-select/index.js +1 -1
- package/dist/components/number-input/index.js +1 -1
- package/dist/components/number-input/number-input.d.ts.map +1 -1
- package/dist/components/otp-input/index.js +1 -1
- package/dist/components/otp-input/otp-input.d.ts.map +1 -1
- package/dist/components/password-input/index.js +1 -1
- package/dist/components/phone-input/index.js +1 -1
- package/dist/components/phone-input/phone-input.d.ts.map +1 -1
- package/dist/components/search-bar/index.js +1 -1
- package/dist/components/search-input/index.js +1 -1
- package/dist/components/select/index.js +1 -1
- package/dist/components/select/select.d.ts.map +1 -1
- package/dist/components/tabs/index.js +1 -1
- package/dist/components/text-area/index.js +1 -1
- package/dist/components/text-area/text-area.d.ts.map +1 -1
- package/dist/components/text-input/index.js +1 -1
- package/dist/components/text-input/text-input.d.ts.map +1 -1
- package/dist/components/transcript-panel/index.js +1 -1
- package/dist/index.js +21 -21
- package/dist/patterns/leo-assistant/index.js +1 -1
- package/dist/tokens.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/ai-prompt-input-noh-N3cf.js.map +0 -1
- package/dist/_chunks/chat-input-Bov-gkwP.js.map +0 -1
- package/dist/_chunks/input-surface-u4QB0lxe.js.map +0 -1
- package/dist/_chunks/number-input-mpSLk-ld.js.map +0 -1
- package/dist/_chunks/otp-input-CI-Zv5q6.js.map +0 -1
- package/dist/_chunks/phone-input-DtBVs5fz.js.map +0 -1
- package/dist/_chunks/select-i9MwQeQy.js.map +0 -1
- package/dist/_chunks/text-area-DHtcpcLv.js.map +0 -1
- package/dist/_chunks/text-input-1oqFRbVI.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsxs as be, jsx as
|
|
1
|
+
import { jsxs as be, jsx as F } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo as J, forwardRef as ge, useRef as A, useState as E, useCallback as $, useEffect as he } from "react";
|
|
3
3
|
import { c as Ne } from "./index-D2ZczOXr.js";
|
|
4
4
|
import { useTranslation as ye } from "react-i18next";
|
|
5
5
|
import { u as we } from "./form-field-context-B3APVHKx.js";
|
|
6
6
|
import { c as Ie } from "./compose-refs-C0k0tdqF.js";
|
|
7
7
|
import { u as De } from "./registry-C9nwlNyL.js";
|
|
8
|
-
import { C as
|
|
9
|
-
import { C as
|
|
8
|
+
import { C as xe } from "./chevron-down-BX_NP2Yh.js";
|
|
9
|
+
import { C as Fe } from "./chevron-up-zOEDrmBB.js";
|
|
10
10
|
const Se = {
|
|
11
11
|
id: "number-input",
|
|
12
12
|
capabilities: ["edit_inline"],
|
|
@@ -83,9 +83,9 @@ function Ve(t, r, u) {
|
|
|
83
83
|
maximumFractionDigits: 4
|
|
84
84
|
}) : r === "integer" ? new Intl.NumberFormat(t, { maximumFractionDigits: 0 }) : new Intl.NumberFormat(t, { maximumFractionDigits: 10 }), T = (a) => Number.isFinite(a) ? p.format(a) : "", z = (a) => {
|
|
85
85
|
if (!a) return NaN;
|
|
86
|
-
const
|
|
86
|
+
const C = Me(a), g = C.trim(), I = g.startsWith("-") || g.startsWith("−");
|
|
87
87
|
let c = "";
|
|
88
|
-
for (const h of
|
|
88
|
+
for (const h of C)
|
|
89
89
|
h >= "0" && h <= "9" ? c += h : h === d && (c += ".");
|
|
90
90
|
if (!c || c === ".") return NaN;
|
|
91
91
|
let m = Number(c);
|
|
@@ -113,11 +113,12 @@ function Ve(t, r, u) {
|
|
|
113
113
|
};
|
|
114
114
|
}, [t, r, u]);
|
|
115
115
|
}
|
|
116
|
-
const
|
|
116
|
+
const Ce = Ne(
|
|
117
117
|
[
|
|
118
118
|
"ds:flex ds:items-center ds:w-full ds:rounded-[var(--radius-sm)]",
|
|
119
|
-
"ds:border ds:bg-
|
|
120
|
-
"ds:
|
|
119
|
+
"ds:border ds:bg-input ds:text-foreground",
|
|
120
|
+
"ds:shadow-[var(--shadow-input)]",
|
|
121
|
+
"ds:transition-[colors,box-shadow] ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none",
|
|
121
122
|
"ds:focus-within:outline-[length:var(--focus-ring-width)] ds:focus-within:outline-solid",
|
|
122
123
|
"ds:focus-within:outline-ring ds:focus-within:outline-offset-[length:var(--focus-ring-offset)]",
|
|
123
124
|
"ds:has-[:disabled]:cursor-not-allowed ds:has-[:disabled]:opacity-50"
|
|
@@ -142,7 +143,7 @@ const ke = Ne(
|
|
|
142
143
|
"ds:text-muted-foreground ds:hover:text-foreground",
|
|
143
144
|
"ds:transition-colors ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none",
|
|
144
145
|
"ds:disabled:cursor-not-allowed ds:disabled:opacity-50"
|
|
145
|
-
].join(" "),
|
|
146
|
+
].join(" "), ke = () => typeof navigator < "u" && navigator.language ? navigator.language : "en-US";
|
|
146
147
|
function Te(t) {
|
|
147
148
|
if (!Number.isFinite(t)) return 0;
|
|
148
149
|
const r = String(t), u = r.indexOf(".");
|
|
@@ -168,13 +169,13 @@ const Pe = ge(
|
|
|
168
169
|
tone: M,
|
|
169
170
|
className: V,
|
|
170
171
|
id: a,
|
|
171
|
-
disabled:
|
|
172
|
+
disabled: C,
|
|
172
173
|
onFocus: g,
|
|
173
174
|
onBlur: I,
|
|
174
175
|
onKeyDown: c,
|
|
175
176
|
...m
|
|
176
177
|
}, h) => {
|
|
177
|
-
const { t: U } = ye(), D = we(), Q = a ?? D.id,
|
|
178
|
+
const { t: U } = ye(), D = we(), Q = a ?? D.id, k = !!(D.disabled || C), X = z ?? ke(), P = Ve(X, p, T), {
|
|
178
179
|
decimalSeparator: B,
|
|
179
180
|
format: R,
|
|
180
181
|
parse: K
|
|
@@ -182,7 +183,7 @@ const Pe = ge(
|
|
|
182
183
|
r ?? null
|
|
183
184
|
), s = H ? t ?? null : Z, W = A(s);
|
|
184
185
|
W.current = s;
|
|
185
|
-
const
|
|
186
|
+
const x = $(
|
|
186
187
|
(e) => {
|
|
187
188
|
const i = p === "percentage" ? e * 100 : e;
|
|
188
189
|
return (Number.isInteger(i) ? String(i) : i.toString()).replace(".", B);
|
|
@@ -202,14 +203,14 @@ const Pe = ge(
|
|
|
202
203
|
}, w = (e) => {
|
|
203
204
|
let o = (s ?? 0) + S * e;
|
|
204
205
|
n !== void 0 && (o = Math.max(n, o)), d !== void 0 && (o = Math.min(d, o)), o = ze(o, S), v(o), y(!1), l(
|
|
205
|
-
N.current ?
|
|
206
|
+
N.current ? x(o) : f(o)
|
|
206
207
|
);
|
|
207
208
|
}, O = (e) => {
|
|
208
209
|
v(e), y(!1), l(
|
|
209
|
-
N.current ?
|
|
210
|
+
N.current ? x(e) : f(e)
|
|
210
211
|
);
|
|
211
212
|
}, se = (e) => {
|
|
212
|
-
if (c == null || c(e), e.defaultPrevented ||
|
|
213
|
+
if (c == null || c(e), e.defaultPrevented || k) return;
|
|
213
214
|
const { key: i, shiftKey: o } = e;
|
|
214
215
|
i === "ArrowUp" ? (e.preventDefault(), w(o ? 10 : 1)) : i === "ArrowDown" ? (e.preventDefault(), w(o ? -10 : -1)) : i === "PageUp" ? (e.preventDefault(), w(100)) : i === "PageDown" ? (e.preventDefault(), w(-100)) : i === "Home" && n !== void 0 ? (e.preventDefault(), O(n)) : i === "End" && d !== void 0 && (e.preventDefault(), O(d));
|
|
215
216
|
}, ie = (e) => {
|
|
@@ -221,7 +222,7 @@ const Pe = ge(
|
|
|
221
222
|
const o = K(i);
|
|
222
223
|
Number.isNaN(o) || v(o);
|
|
223
224
|
}, oe = (e) => {
|
|
224
|
-
g == null || g(e), N.current = !0, s != null && l(
|
|
225
|
+
g == null || g(e), N.current = !0, s != null && l(x(s));
|
|
225
226
|
}, ae = (e) => {
|
|
226
227
|
if (I == null || I(e), N.current = !1, j.trim() === "") {
|
|
227
228
|
v(null), y(!1), l("");
|
|
@@ -241,7 +242,7 @@ const Pe = ge(
|
|
|
241
242
|
getValue: () => W.current,
|
|
242
243
|
setValue: (e) => {
|
|
243
244
|
v(e), l(
|
|
244
|
-
e === null ? "" : N.current ?
|
|
245
|
+
e === null ? "" : N.current ? x(e) : f(e)
|
|
245
246
|
);
|
|
246
247
|
},
|
|
247
248
|
clear: () => {
|
|
@@ -255,14 +256,14 @@ const Pe = ge(
|
|
|
255
256
|
// The handle is reconstructed per render; consumers (the agent runtime)
|
|
256
257
|
// re-register only when the identity changes, which is a cheap no-op.
|
|
257
258
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
258
|
-
[
|
|
259
|
+
[x, f]
|
|
259
260
|
);
|
|
260
261
|
De(Se, le, a);
|
|
261
|
-
const ce =
|
|
262
|
+
const ce = k || n !== void 0 && s !== null && s <= n, fe = k || d !== void 0 && s !== null && s >= d, pe = s ?? void 0, me = (p === "currency" || p === "percentage") && s !== null && s !== null ? R(s) : void 0, ve = P.inputMode === "numeric" ? "[0-9]*" : void 0;
|
|
262
263
|
return /* @__PURE__ */ be(
|
|
263
264
|
"div",
|
|
264
265
|
{
|
|
265
|
-
className:
|
|
266
|
+
className: Ce({
|
|
266
267
|
size: b,
|
|
267
268
|
tone: re,
|
|
268
269
|
className: V
|
|
@@ -271,7 +272,7 @@ const Pe = ge(
|
|
|
271
272
|
"data-component-id": a,
|
|
272
273
|
"data-mode": p,
|
|
273
274
|
children: [
|
|
274
|
-
/* @__PURE__ */
|
|
275
|
+
/* @__PURE__ */ F(
|
|
275
276
|
"button",
|
|
276
277
|
{
|
|
277
278
|
type: "button",
|
|
@@ -281,10 +282,10 @@ const Pe = ge(
|
|
|
281
282
|
onMouseDown: _,
|
|
282
283
|
disabled: ce,
|
|
283
284
|
className: `${G} ds:ps-2 ds:pe-1`,
|
|
284
|
-
children: /* @__PURE__ */
|
|
285
|
+
children: /* @__PURE__ */ F(xe, { "aria-hidden": "true", className: "ds:size-4" })
|
|
285
286
|
}
|
|
286
287
|
),
|
|
287
|
-
/* @__PURE__ */
|
|
288
|
+
/* @__PURE__ */ F(
|
|
288
289
|
"input",
|
|
289
290
|
{
|
|
290
291
|
ref: Y,
|
|
@@ -295,7 +296,7 @@ const Pe = ge(
|
|
|
295
296
|
pattern: ve,
|
|
296
297
|
autoComplete: "off",
|
|
297
298
|
value: j,
|
|
298
|
-
disabled:
|
|
299
|
+
disabled: k,
|
|
299
300
|
"aria-valuemin": n,
|
|
300
301
|
"aria-valuemax": d,
|
|
301
302
|
"aria-valuenow": pe,
|
|
@@ -311,7 +312,7 @@ const Pe = ge(
|
|
|
311
312
|
...m
|
|
312
313
|
}
|
|
313
314
|
),
|
|
314
|
-
/* @__PURE__ */
|
|
315
|
+
/* @__PURE__ */ F(
|
|
315
316
|
"button",
|
|
316
317
|
{
|
|
317
318
|
type: "button",
|
|
@@ -321,7 +322,7 @@ const Pe = ge(
|
|
|
321
322
|
onMouseDown: _,
|
|
322
323
|
disabled: fe,
|
|
323
324
|
className: `${G} ds:ps-1 ds:pe-2`,
|
|
324
|
-
children: /* @__PURE__ */
|
|
325
|
+
children: /* @__PURE__ */ F(Fe, { "aria-hidden": "true", className: "ds:size-4" })
|
|
325
326
|
}
|
|
326
327
|
)
|
|
327
328
|
]
|
|
@@ -334,4 +335,4 @@ export {
|
|
|
334
335
|
Pe as N,
|
|
335
336
|
Ve as u
|
|
336
337
|
};
|
|
337
|
-
//# sourceMappingURL=number-input-
|
|
338
|
+
//# sourceMappingURL=number-input-DH00o0DN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-input-DH00o0DN.js","sources":["../../src/components/number-input/number-input.agent.ts","../../src/components/number-input/use-locale-number.ts","../../src/components/number-input/number-input.tsx"],"sourcesContent":["/* -------------------------------------------------------------------- */\n/* Agent adapter — NumberInput. */\n/* */\n/* See `src/docs/26-agent-readiness.mdx` for the contract. */\n/* -------------------------------------------------------------------- */\n\nimport type { AgentAdapter } from '../../agent/types';\nimport type { NumberInputHandle } from './number-input';\n\nexport const numberInputAgent: AgentAdapter<NumberInputHandle> = {\n id: 'number-input',\n capabilities: ['edit_inline'],\n state: {\n value: {\n type: 'number | null',\n descriptionKey: 'ui.agent.numberInput.state.value',\n description: 'Current numeric value, or null when empty.',\n read: (handle) => handle.getValue(),\n },\n isEmpty: {\n type: 'boolean',\n descriptionKey: 'ui.agent.numberInput.state.isEmpty',\n description: 'Whether the input has no value.',\n read: (handle) => handle.getValue() === null,\n },\n },\n actions: {\n set_value: {\n safety: 'write',\n argsType: '{ value: number | null }',\n descriptionKey: 'ui.agent.numberInput.actions.setValue',\n description: 'Replace the numeric value, or pass null to clear.',\n invoke: (handle, args: { value: number | null }) => {\n handle.setValue(args.value);\n },\n },\n clear: {\n safety: 'destructive',\n descriptionKey: 'ui.agent.numberInput.actions.clear',\n description: 'Empty the input. Loses any typed value.',\n invoke: (handle) => {\n handle.clear();\n },\n },\n focus: {\n safety: 'read',\n descriptionKey: 'ui.agent.numberInput.actions.focus',\n description: 'Move keyboard focus to the input.',\n invoke: (handle) => {\n handle.focus();\n },\n },\n },\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'number-input',\n description: 'Marks the NumberInput wrapper.',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description: 'Sourced from the id prop.',\n },\n },\n};\n","import { useMemo } from 'react';\n\nexport type NumberInputMode = 'integer' | 'decimal' | 'currency' | 'percentage';\n\nexport interface LocaleNumber {\n /** Format a JS number for display (e.g. `1234.5` → `1.234,5` in de-DE). */\n format: (value: number) => string;\n /** Parse a locale-formatted string back to a JS number. Returns `NaN` for invalid input. */\n parse: (text: string) => number;\n /** The decimal separator for this locale (e.g. `.` or `,`). */\n decimalSeparator: string;\n /** The grouping separator for this locale (e.g. `,` or `.` or ` `). */\n groupingSeparator: string;\n /** The correct `inputMode` for the virtual keyboard. */\n inputMode: 'numeric' | 'decimal';\n}\n\nfunction normalizeDigits(text: string): string {\n let result = '';\n for (const ch of text) {\n const code = ch.codePointAt(0);\n if (code === undefined) continue;\n if (code >= 0x0660 && code <= 0x0669) {\n result += String.fromCodePoint(0x30 + (code - 0x0660));\n } else if (code >= 0x06f0 && code <= 0x06f9) {\n result += String.fromCodePoint(0x30 + (code - 0x06f0));\n } else {\n result += ch;\n }\n }\n return result;\n}\n\nexport function useLocaleNumber(\n locale: string,\n mode: NumberInputMode,\n currency?: string,\n): LocaleNumber {\n return useMemo(() => {\n const parts = new Intl.NumberFormat(locale).formatToParts(1234.5);\n const decimalSeparator =\n parts.find((p) => p.type === 'decimal')?.value ?? '.';\n const groupingSeparator =\n parts.find((p) => p.type === 'group')?.value ?? ',';\n\n const displayFormatter: Intl.NumberFormat = (() => {\n if (mode === 'currency') {\n return new Intl.NumberFormat(locale, {\n style: 'currency',\n currency: currency ?? 'USD',\n });\n }\n if (mode === 'percentage') {\n return new Intl.NumberFormat(locale, {\n style: 'percent',\n maximumFractionDigits: 4,\n });\n }\n if (mode === 'integer') {\n return new Intl.NumberFormat(locale, { maximumFractionDigits: 0 });\n }\n return new Intl.NumberFormat(locale, { maximumFractionDigits: 10 });\n })();\n\n const format = (value: number): string => {\n if (!Number.isFinite(value)) return '';\n return displayFormatter.format(value);\n };\n\n const parse = (text: string): number => {\n if (!text) return NaN;\n const normalized = normalizeDigits(text);\n const trimmed = normalized.trim();\n const hasMinus = trimmed.startsWith('-') || trimmed.startsWith('\\u2212');\n\n let cleaned = '';\n for (const ch of normalized) {\n if (ch >= '0' && ch <= '9') {\n cleaned += ch;\n } else if (ch === decimalSeparator) {\n cleaned += '.';\n }\n }\n if (!cleaned || cleaned === '.') return NaN;\n\n let n = Number(cleaned);\n if (!Number.isFinite(n)) return NaN;\n if (hasMinus) n = -n;\n if (mode === 'percentage') n = n / 100;\n return n;\n };\n\n let inputMode: 'numeric' | 'decimal' = 'decimal';\n if (mode === 'integer') {\n inputMode = 'numeric';\n } else if (mode === 'currency') {\n try {\n const { maximumFractionDigits } = new Intl.NumberFormat(locale, {\n style: 'currency',\n currency: currency ?? 'USD',\n }).resolvedOptions();\n inputMode = maximumFractionDigits === 0 ? 'numeric' : 'decimal';\n } catch {\n inputMode = 'decimal';\n }\n }\n\n return {\n format,\n parse,\n decimalSeparator,\n groupingSeparator,\n inputMode,\n };\n }, [locale, mode, currency]);\n}\n","import {\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ChangeEvent,\n type FocusEvent,\n type InputHTMLAttributes,\n type KeyboardEvent,\n type MouseEvent,\n} from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { ChevronDown, ChevronUp } from 'lucide-react';\nimport { useFormField } from '../form-field/form-field-context';\nimport { composeRefs } from '../_shared/compose-refs';\nimport { useAgentRegistration } from '../../agent';\nimport { numberInputAgent } from './number-input.agent';\nimport { useLocaleNumber, type NumberInputMode } from './use-locale-number';\n\n/** Agent-readiness curated handle for NumberInput. */\nexport interface NumberInputHandle {\n getValue: () => number | null;\n setValue: (value: number | null) => void;\n clear: () => void;\n focus: () => void;\n}\n\nconst numberInputVariants = cva(\n [\n 'ds:flex ds:items-center ds:w-full ds:rounded-[var(--radius-sm)]',\n 'ds:border ds:bg-input ds:text-foreground',\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-within:outline-[length:var(--focus-ring-width)] ds:focus-within:outline-solid',\n 'ds:focus-within:outline-ring ds:focus-within:outline-offset-[length:var(--focus-ring-offset)]',\n 'ds:has-[:disabled]:cursor-not-allowed ds:has-[:disabled]:opacity-50',\n ].join(' '),\n {\n variants: {\n size: {\n sm: 'ds:h-8 ds:text-[length:var(--font-size-sm)]',\n md: 'ds:h-[var(--min-target-size)] ds:text-[length:var(--font-size-base)]',\n lg: 'ds:h-12 ds:text-[length:var(--font-size-lg)]',\n },\n tone: {\n default: 'ds:border-border',\n error: 'ds:border-destructive ds:focus-within:outline-destructive',\n },\n },\n defaultVariants: { size: 'md', tone: 'default' },\n },\n);\n\nconst spinnerButton = [\n 'ds:inline-flex ds:items-center ds:justify-center',\n 'ds:h-full ds:shrink-0',\n 'ds:text-muted-foreground ds:hover:text-foreground',\n 'ds:transition-colors ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none',\n 'ds:disabled:cursor-not-allowed ds:disabled:opacity-50',\n].join(' ');\n\nexport type { NumberInputMode };\n\nexport interface NumberInputProps\n extends\n Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'type' | 'onChange' | 'value' | 'defaultValue' | 'size'\n >,\n VariantProps<typeof numberInputVariants> {\n /** Current numeric value (controlled). */\n value?: number | null;\n /** Initial value (uncontrolled). */\n defaultValue?: number;\n /** Fires with the parsed number (not a string). `null` when the field is empty. */\n onChange?: (value: number | null) => void;\n /** Minimum allowed value. Maps to `aria-valuemin`. */\n min?: number;\n /** Maximum allowed value. Maps to `aria-valuemax`. */\n max?: number;\n /** Increment step. Defaults to `1`. */\n step?: number;\n /** Display/parse mode. Defaults to `'integer'`. */\n mode?: NumberInputMode;\n /** ISO 4217 currency code, required when `mode='currency'`. */\n currency?: string;\n /** BCP 47 locale. Defaults to `navigator.language` or `'en-US'`. */\n locale?: string;\n /** Size variant. */\n size?: 'sm' | 'md' | 'lg';\n /** Additional class names on the wrapper. */\n className?: string;\n}\n\nconst resolveDefaultLocale = (): string => {\n if (typeof navigator !== 'undefined' && navigator.language) {\n return navigator.language;\n }\n return 'en-US';\n};\n\nfunction decimalPlaces(n: number): number {\n if (!Number.isFinite(n)) return 0;\n const s = String(n);\n const dot = s.indexOf('.');\n if (dot === -1) return 0;\n return s.length - dot - 1;\n}\n\nfunction roundToStep(value: number, step: number): number {\n if (step <= 0 || !Number.isFinite(step)) return value;\n const precision = decimalPlaces(step);\n const factor = 10 ** precision;\n return Math.round(value * factor) / factor;\n}\n\nexport const NumberInput = forwardRef<HTMLInputElement, NumberInputProps>(\n (\n {\n value,\n defaultValue,\n onChange,\n min,\n max,\n step = 1,\n mode = 'integer',\n currency,\n locale,\n size = 'md',\n tone,\n className,\n id,\n disabled,\n onFocus,\n onBlur,\n onKeyDown,\n ...rest\n },\n ref,\n ) => {\n const { t } = useTranslation();\n const ctx = useFormField();\n const inputId = id ?? ctx.id;\n const effectiveDisabled = Boolean(ctx.disabled || disabled);\n\n const resolvedLocale = locale ?? resolveDefaultLocale();\n const localeNumber = useLocaleNumber(resolvedLocale, mode, currency);\n const {\n decimalSeparator,\n format: localeFormat,\n parse: localeParse,\n } = localeNumber;\n\n const innerInputRef = useRef<HTMLInputElement | null>(null);\n const composedRef = composeRefs(ref, innerInputRef);\n\n const isControlled = value !== undefined;\n const [internalValue, setInternalValue] = useState<number | null>(\n defaultValue ?? null,\n );\n const currentValue: number | null = isControlled\n ? (value ?? null)\n : internalValue;\n\n const currentValueRef = useRef<number | null>(currentValue);\n currentValueRef.current = currentValue;\n\n const formatForEdit = useCallback(\n (n: number): string => {\n const displayed = mode === 'percentage' ? n * 100 : n;\n const raw = Number.isInteger(displayed)\n ? String(displayed)\n : displayed.toString();\n return raw.replace('.', decimalSeparator);\n },\n [mode, decimalSeparator],\n );\n\n const formatCurrent = useCallback(\n (n: number | null | undefined): string =>\n n === null || n === undefined || Number.isNaN(n) ? '' : localeFormat(n),\n [localeFormat],\n );\n\n const [inputText, setInputText] = useState<string>(() =>\n formatCurrent(currentValue),\n );\n const isFocusedRef = useRef(false);\n const [crossedBounds, setCrossedBounds] = useState(false);\n\n useEffect(() => {\n if (!isFocusedRef.current) {\n setInputText(formatCurrent(currentValue));\n }\n }, [currentValue, formatCurrent]);\n\n const computedInvalid =\n crossedBounds ||\n (currentValue !== null &&\n ((min !== undefined && currentValue < min) ||\n (max !== undefined && currentValue > max)));\n const ariaInvalid = ctx.invalid || computedInvalid;\n const effectiveTone: 'default' | 'error' = ariaInvalid\n ? 'error'\n : (tone ?? 'default');\n\n const commitValue = (next: number | null) => {\n if (!isControlled) setInternalValue(next);\n onChange?.(next);\n };\n\n const applyDelta = (multiplier: number) => {\n const base = currentValue ?? 0;\n let next = base + step * multiplier;\n if (min !== undefined) next = Math.max(min, next);\n if (max !== undefined) next = Math.min(max, next);\n next = roundToStep(next, step);\n commitValue(next);\n setCrossedBounds(false);\n setInputText(\n isFocusedRef.current ? formatForEdit(next) : formatCurrent(next),\n );\n };\n\n const jumpTo = (target: number) => {\n commitValue(target);\n setCrossedBounds(false);\n setInputText(\n isFocusedRef.current ? formatForEdit(target) : formatCurrent(target),\n );\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n if (effectiveDisabled) return;\n\n const { key, shiftKey } = event;\n if (key === 'ArrowUp') {\n event.preventDefault();\n applyDelta(shiftKey ? 10 : 1);\n } else if (key === 'ArrowDown') {\n event.preventDefault();\n applyDelta(shiftKey ? -10 : -1);\n } else if (key === 'PageUp') {\n event.preventDefault();\n applyDelta(100);\n } else if (key === 'PageDown') {\n event.preventDefault();\n applyDelta(-100);\n } else if (key === 'Home' && min !== undefined) {\n event.preventDefault();\n jumpTo(min);\n } else if (key === 'End' && max !== undefined) {\n event.preventDefault();\n jumpTo(max);\n }\n };\n\n const handleInputChange = (event: ChangeEvent<HTMLInputElement>) => {\n const text = event.target.value;\n setInputText(text);\n if (text.trim() === '') {\n commitValue(null);\n setCrossedBounds(false);\n return;\n }\n const parsed = localeParse(text);\n if (!Number.isNaN(parsed)) {\n commitValue(parsed);\n }\n };\n\n const handleFocus = (event: FocusEvent<HTMLInputElement>) => {\n onFocus?.(event);\n isFocusedRef.current = true;\n if (currentValue !== null && currentValue !== undefined) {\n setInputText(formatForEdit(currentValue));\n }\n };\n\n const handleBlur = (event: FocusEvent<HTMLInputElement>) => {\n onBlur?.(event);\n isFocusedRef.current = false;\n\n if (inputText.trim() === '') {\n commitValue(null);\n setCrossedBounds(false);\n setInputText('');\n return;\n }\n const parsed = localeParse(inputText);\n if (Number.isNaN(parsed)) {\n setInputText(formatCurrent(currentValue));\n return;\n }\n const crossed =\n (min !== undefined && parsed < min) ||\n (max !== undefined && parsed > max);\n setCrossedBounds(crossed);\n commitValue(parsed);\n setInputText(formatCurrent(parsed));\n };\n\n const preventButtonBlur = (event: MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n };\n\n const handleIncrement = () => applyDelta(1);\n const handleDecrement = () => applyDelta(-1);\n\n const agentHandle = useMemo<NumberInputHandle>(\n () => ({\n getValue: () => currentValueRef.current,\n setValue: (next) => {\n commitValue(next);\n setInputText(\n next === null\n ? ''\n : isFocusedRef.current\n ? formatForEdit(next)\n : formatCurrent(next),\n );\n },\n clear: () => {\n commitValue(null);\n setInputText('');\n setCrossedBounds(false);\n },\n focus: () => innerInputRef.current?.focus(),\n }),\n // The handle is reconstructed per render; consumers (the agent runtime)\n // re-register only when the identity changes, which is a cheap no-op.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [formatForEdit, formatCurrent],\n );\n useAgentRegistration(numberInputAgent, agentHandle, id);\n\n const decrementDisabled =\n effectiveDisabled ||\n (min !== undefined && currentValue !== null && currentValue <= min);\n const incrementDisabled =\n effectiveDisabled ||\n (max !== undefined && currentValue !== null && currentValue >= max);\n\n const valueNow = currentValue ?? undefined;\n const valueTextNeeded =\n (mode === 'currency' || mode === 'percentage') && currentValue !== null;\n const valueText =\n valueTextNeeded && currentValue !== null\n ? localeFormat(currentValue)\n : undefined;\n\n const patternAttr =\n localeNumber.inputMode === 'numeric' ? '[0-9]*' : undefined;\n\n return (\n <div\n className={numberInputVariants({\n size,\n tone: effectiveTone,\n className,\n })}\n data-component=\"number-input\"\n data-component-id={id}\n data-mode={mode}\n >\n <button\n type=\"button\"\n tabIndex={-1}\n aria-label={t('inputs.number.decrement', 'Decrement')}\n onClick={handleDecrement}\n onMouseDown={preventButtonBlur}\n disabled={decrementDisabled}\n className={`${spinnerButton} ds:ps-2 ds:pe-1`}\n >\n <ChevronDown aria-hidden=\"true\" className=\"ds:size-4\" />\n </button>\n <input\n ref={composedRef}\n id={inputId}\n type=\"text\"\n role=\"spinbutton\"\n inputMode={localeNumber.inputMode}\n pattern={patternAttr}\n autoComplete=\"off\"\n value={inputText}\n disabled={effectiveDisabled}\n aria-valuemin={min}\n aria-valuemax={max}\n aria-valuenow={valueNow}\n aria-valuetext={valueText}\n aria-invalid={ariaInvalid || undefined}\n aria-required={ctx.required || undefined}\n aria-describedby={ctx.describedBy || undefined}\n onChange={handleInputChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n className=\"ds:flex-1 ds:w-full ds:min-w-0 ds:bg-transparent ds:outline-none ds:ps-2 ds:pe-2 ds:text-start ds:tabular-nums ds:disabled:cursor-not-allowed\"\n {...rest}\n />\n <button\n type=\"button\"\n tabIndex={-1}\n aria-label={t('inputs.number.increment', 'Increment')}\n onClick={handleIncrement}\n onMouseDown={preventButtonBlur}\n disabled={incrementDisabled}\n className={`${spinnerButton} ds:ps-1 ds:pe-2`}\n >\n <ChevronUp aria-hidden=\"true\" className=\"ds:size-4\" />\n </button>\n </div>\n );\n },\n);\n\nNumberInput.displayName = 'NumberInput';\n"],"names":["numberInputAgent","handle","args","normalizeDigits","text","result","ch","code","useLocaleNumber","locale","mode","currency","useMemo","parts","decimalSeparator","_a","p","groupingSeparator","_b","displayFormatter","format","value","parse","normalized","trimmed","hasMinus","cleaned","n","inputMode","maximumFractionDigits","numberInputVariants","cva","spinnerButton","resolveDefaultLocale","decimalPlaces","s","dot","roundToStep","step","factor","NumberInput","forwardRef","defaultValue","onChange","min","max","size","tone","className","id","disabled","onFocus","onBlur","onKeyDown","rest","ref","t","useTranslation","ctx","useFormField","inputId","effectiveDisabled","resolvedLocale","localeNumber","localeFormat","localeParse","innerInputRef","useRef","composedRef","composeRefs","isControlled","internalValue","setInternalValue","useState","currentValue","currentValueRef","formatForEdit","useCallback","displayed","formatCurrent","inputText","setInputText","isFocusedRef","crossedBounds","setCrossedBounds","useEffect","computedInvalid","ariaInvalid","effectiveTone","commitValue","next","applyDelta","multiplier","jumpTo","target","handleKeyDown","event","key","shiftKey","handleInputChange","parsed","handleFocus","handleBlur","crossed","preventButtonBlur","handleIncrement","handleDecrement","agentHandle","useAgentRegistration","decrementDisabled","incrementDisabled","valueNow","valueText","patternAttr","jsxs","jsx","ChevronDown","ChevronUp"],"mappings":";;;;;;;;;AASO,MAAMA,KAAoD;AAAA,EAC/D,IAAI;AAAA,EACJ,cAAc,CAAC,aAAa;AAAA,EAC5B,OAAO;AAAA,IACL,OAAO;AAAA,MACL,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,MAAM,CAACC,MAAWA,EAAO,SAAA;AAAA,IAAS;AAAA,IAEpC,SAAS;AAAA,MACP,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,MAAM,CAACA,MAAWA,EAAO,eAAe;AAAA,IAAA;AAAA,EAC1C;AAAA,EAEF,SAAS;AAAA,IACP,WAAW;AAAA,MACT,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,gBAAgB;AAAA,M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AAAA,IAAA;AAAA,EAGN;AACF;AAEA7E,GAAY,cAAc;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as ee, jsx as M } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as te, useId as
|
|
2
|
+
import { forwardRef as te, useId as se, useState as L, useRef as R, useEffect as re, useCallback as N, useMemo as oe } from "react";
|
|
3
3
|
import { c as O } from "./index-D2ZczOXr.js";
|
|
4
4
|
import { useTranslation as ae } from "react-i18next";
|
|
5
5
|
import { u as ie } from "./form-field-context-B3APVHKx.js";
|
|
@@ -64,8 +64,9 @@ const ce = {
|
|
|
64
64
|
[
|
|
65
65
|
"ds:w-[var(--min-target-size)] ds:h-[var(--min-target-size)]",
|
|
66
66
|
"ds:rounded-[var(--radius-sm)]",
|
|
67
|
-
"ds:border ds:bg-
|
|
68
|
-
"ds:
|
|
67
|
+
"ds:border ds:bg-input ds:text-foreground ds:text-center ds:font-medium ds:text-[length:var(--font-size-lg)]",
|
|
68
|
+
"ds:shadow-[var(--shadow-input)]",
|
|
69
|
+
"ds:transition-[colors,box-shadow] ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none",
|
|
69
70
|
"ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid",
|
|
70
71
|
"ds:focus-visible:outline-ring ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
|
|
71
72
|
"ds:disabled:cursor-not-allowed ds:disabled:opacity-50"
|
|
@@ -105,69 +106,69 @@ const pe = te(
|
|
|
105
106
|
id: K,
|
|
106
107
|
className: j
|
|
107
108
|
}, z) => {
|
|
108
|
-
const { t: H } = ae(), v = ie(), _ =
|
|
109
|
+
const { t: H } = ae(), v = ie(), _ = se(), P = y ? _ : void 0, w = o !== void 0, [q, W] = L(
|
|
109
110
|
() => g(m ?? "", e)
|
|
110
111
|
), p = g(
|
|
111
|
-
|
|
112
|
+
w ? o : q,
|
|
112
113
|
e
|
|
113
|
-
), G = de(p, e),
|
|
114
|
+
), G = de(p, e), I = v.disabled || !!S, B = v.invalid || !!$, J = B ? "error" : "default", C = R([]), h = R(p.length === e), d = R(p);
|
|
114
115
|
d.current = p;
|
|
115
116
|
const Q = () => {
|
|
116
|
-
const
|
|
117
|
-
return
|
|
118
|
-
}, [f,
|
|
119
|
-
|
|
120
|
-
f >= e &&
|
|
117
|
+
const s = p.length;
|
|
118
|
+
return s >= e ? e - 1 : s;
|
|
119
|
+
}, [f, k] = L(Q);
|
|
120
|
+
re(() => {
|
|
121
|
+
f >= e && k(e - 1);
|
|
121
122
|
}, [f, e]);
|
|
122
123
|
const c = N(
|
|
123
|
-
(
|
|
124
|
-
const t = Math.max(0, Math.min(e - 1,
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
|
|
124
|
+
(s) => {
|
|
125
|
+
const t = Math.max(0, Math.min(e - 1, s));
|
|
126
|
+
k(t);
|
|
127
|
+
const r = C.current[t];
|
|
128
|
+
r && (r.focus(), r.select());
|
|
128
129
|
},
|
|
129
130
|
[e]
|
|
130
131
|
), u = N(
|
|
131
|
-
(
|
|
132
|
-
const t = g(
|
|
133
|
-
|
|
132
|
+
(s) => {
|
|
133
|
+
const t = g(s, e);
|
|
134
|
+
w || W(t), d.current = t, l == null || l(t), t.length === e ? h.current || (h.current = !0, n == null || n(t)) : h.current = !1;
|
|
134
135
|
},
|
|
135
|
-
[
|
|
136
|
-
), U = (
|
|
137
|
-
const
|
|
136
|
+
[w, e, l, n]
|
|
137
|
+
), U = (s) => (t) => {
|
|
138
|
+
const r = t.target.value, a = F(r).replace(/\D/g, ""), i = d.current;
|
|
138
139
|
if (a.length === 0) {
|
|
139
|
-
if (
|
|
140
|
-
const A = i.slice(0,
|
|
140
|
+
if (r === "" && s < i.length) {
|
|
141
|
+
const A = i.slice(0, s) + i.slice(s + 1);
|
|
141
142
|
u(A);
|
|
142
143
|
}
|
|
143
144
|
return;
|
|
144
145
|
}
|
|
145
|
-
const b = i.slice(0,
|
|
146
|
+
const b = i.slice(0, s), V = i.slice(s + a.length), D = (b + a + V).slice(0, e);
|
|
146
147
|
u(D);
|
|
147
|
-
const T = Math.min(
|
|
148
|
+
const T = Math.min(s + a.length, e - 1);
|
|
148
149
|
c(T);
|
|
149
|
-
}, X = (
|
|
150
|
-
const
|
|
150
|
+
}, X = (s) => (t) => {
|
|
151
|
+
const r = d.current;
|
|
151
152
|
if (t.key === "Backspace") {
|
|
152
|
-
if (s
|
|
153
|
+
if (r[s]) {
|
|
153
154
|
t.preventDefault();
|
|
154
|
-
const a =
|
|
155
|
+
const a = r.slice(0, s) + r.slice(s + 1);
|
|
155
156
|
u(a);
|
|
156
157
|
return;
|
|
157
158
|
}
|
|
158
|
-
if (
|
|
159
|
+
if (s > 0) {
|
|
159
160
|
t.preventDefault();
|
|
160
|
-
const a =
|
|
161
|
-
u(a), c(
|
|
161
|
+
const a = r.slice(0, s - 1) + r.slice(s);
|
|
162
|
+
u(a), c(s - 1);
|
|
162
163
|
}
|
|
163
164
|
return;
|
|
164
165
|
}
|
|
165
166
|
if (t.key === "ArrowLeft") {
|
|
166
|
-
t.preventDefault(),
|
|
167
|
+
t.preventDefault(), s > 0 && c(s - 1);
|
|
167
168
|
return;
|
|
168
169
|
}
|
|
169
170
|
if (t.key === "ArrowRight") {
|
|
170
|
-
t.preventDefault(),
|
|
171
|
+
t.preventDefault(), s < e - 1 && c(s + 1);
|
|
171
172
|
return;
|
|
172
173
|
}
|
|
173
174
|
if (t.key === "Home") {
|
|
@@ -175,20 +176,20 @@ const pe = te(
|
|
|
175
176
|
return;
|
|
176
177
|
}
|
|
177
178
|
t.key === "End" && (t.preventDefault(), c(e - 1));
|
|
178
|
-
}, Y = (
|
|
179
|
+
}, Y = (s) => (t) => {
|
|
179
180
|
const a = t.clipboardData.getData("text").replace(/\s+/g, ""), i = F(a);
|
|
180
181
|
if (!/^[0-9]+$/.test(i)) return;
|
|
181
182
|
t.preventDefault();
|
|
182
|
-
const b = d.current,
|
|
183
|
+
const b = d.current, V = b.slice(0, s), D = b.slice(s + i.length), T = (V + i + D).slice(0, e);
|
|
183
184
|
u(T);
|
|
184
|
-
const A = Math.min(
|
|
185
|
+
const A = Math.min(s + i.length, e - 1);
|
|
185
186
|
c(A);
|
|
186
|
-
}, Z = (
|
|
187
|
-
|
|
187
|
+
}, Z = (s) => (t) => {
|
|
188
|
+
k(s), t.currentTarget.select();
|
|
188
189
|
}, E = v.id, x = oe(
|
|
189
190
|
() => ({
|
|
190
191
|
getValue: () => d.current,
|
|
191
|
-
setValue: (
|
|
192
|
+
setValue: (s) => u(s),
|
|
192
193
|
clear: () => u(""),
|
|
193
194
|
focus: () => c(f),
|
|
194
195
|
isComplete: () => d.current.length === e
|
|
@@ -214,12 +215,12 @@ const pe = te(
|
|
|
214
215
|
"aria-labelledby": P,
|
|
215
216
|
"aria-invalid": B || void 0,
|
|
216
217
|
"aria-describedby": v.describedBy || void 0,
|
|
217
|
-
"aria-disabled":
|
|
218
|
+
"aria-disabled": I || void 0,
|
|
218
219
|
"data-component": "otp-input",
|
|
219
220
|
"data-component-id": K,
|
|
220
221
|
className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-sm)]",
|
|
221
|
-
children: G.map((
|
|
222
|
-
const
|
|
222
|
+
children: G.map((s, t) => {
|
|
223
|
+
const r = !I && t === f;
|
|
223
224
|
return /* @__PURE__ */ M(
|
|
224
225
|
"input",
|
|
225
226
|
{
|
|
@@ -232,9 +233,9 @@ const pe = te(
|
|
|
232
233
|
pattern: "[0-9]*",
|
|
233
234
|
autoComplete: t === 0 ? "one-time-code" : "off",
|
|
234
235
|
maxLength: 1,
|
|
235
|
-
value:
|
|
236
|
-
disabled:
|
|
237
|
-
tabIndex:
|
|
236
|
+
value: s,
|
|
237
|
+
disabled: I,
|
|
238
|
+
tabIndex: r ? 0 : -1,
|
|
238
239
|
"aria-label": H("inputs.otp.digitLabel", {
|
|
239
240
|
current: t + 1,
|
|
240
241
|
total: e
|
|
@@ -257,4 +258,4 @@ pe.displayName = "OTPInput";
|
|
|
257
258
|
export {
|
|
258
259
|
pe as O
|
|
259
260
|
};
|
|
260
|
-
//# sourceMappingURL=otp-input-
|
|
261
|
+
//# sourceMappingURL=otp-input-BBXYvLx5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otp-input-BBXYvLx5.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 { 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\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 },\n ref,\n ) => {\n const { t } = useTranslation();\n const ctx = useFormField();\n const generatedLabelId = useId();\n const labelId = label ? generatedLabelId : undefined;\n\n const isControlled = value !== undefined;\n const [internalValue, setInternalValue] = useState<string>(() =>\n packValue(defaultValue ?? '', length),\n );\n const currentValue = packValue(\n isControlled ? value : internalValue,\n length,\n );\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 if (!isControlled) 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 [isControlled, length, onChange, onComplete],\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","ref","t","useTranslation","ctx","useFormField","generatedLabelId","useId","labelId","isControlled","internalValue","setInternalValue","useState","currentValue","digits","effectiveDisabled","effectiveError","effectiveTone","inputsRef","useRef","completedRef","valueRef","computeInitialIndex","firstEmpty","activeIndex","setActiveIndex","useEffect","focusBox","useCallback","index","clamped","node","commit","next","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,Q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pB,MAAS;AACb,kBAAAb,EAAU,QAAQW,CAAK,IAAIE;AAAA,gBAC7B;AAAA,gBACA,IAAI,GAAGgB,CAAM,IAAIlB,CAAK;AAAA,gBACtB,MAAK;AAAA,gBACL,WAAU;AAAA,gBACV,SAAQ;AAAA,gBACR,cAAcA,MAAU,IAAI,kBAAkB;AAAA,gBAC9C,WAAW;AAAA,gBACX,OAAOuB;AAAA,gBACP,UAAUrC;AAAA,gBACV,UAAUsC,IAAa,IAAI;AAAA,gBAC3B,cAAYnD,EAAE,yBAAyB;AAAA,kBACrC,SAAS2B,IAAQ;AAAA,kBACjB,OAAO3C;AAAA,gBAAA,CACR;AAAA,gBACD,UAAUgD,EAAaL,CAAK;AAAA,gBAC5B,WAAWc,EAAcd,CAAK;AAAA,gBAC9B,SAASe,EAAYf,CAAK;AAAA,gBAC1B,SAASiB,EAAYjB,CAAK;AAAA,gBAC1B,WAAWjD,GAAY,EAAE,MAAMqC,GAAe;AAAA,cAAA;AAAA,cArBzCY;AAAA,YAAA;AAAA,UAwBX,CAAC;AAAA,QAAA;AAAA,MAAA;AAAA,IACH,GACF;AAAA,EAEJ;AACF;AAEAtC,GAAS,cAAc;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as f, jsx as i } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as
|
|
2
|
+
import { forwardRef as ke, useContext as Pe, useMemo as m, useState as P, useRef as $, useEffect as Ve, useLayoutEffect as Fe, useCallback as se } from "react";
|
|
3
3
|
import * as V from "@radix-ui/react-popover";
|
|
4
4
|
import { R as Ee, _ as b } from "./index-4xgbg-sn.js";
|
|
5
5
|
import { c as H } from "./index-D2ZczOXr.js";
|
|
@@ -70,9 +70,10 @@ const Me = {
|
|
|
70
70
|
}, qe = H(
|
|
71
71
|
[
|
|
72
72
|
"ds:group ds:relative ds:inline-flex ds:items-stretch ds:w-full",
|
|
73
|
-
"ds:rounded-[var(--radius-sm)] ds:border ds:border-border ds:bg-
|
|
73
|
+
"ds:rounded-[var(--radius-sm)] ds:border ds:border-border ds:bg-input",
|
|
74
|
+
"ds:shadow-[var(--shadow-input)]",
|
|
74
75
|
"ds:text-foreground",
|
|
75
|
-
"ds:transition-colors ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none",
|
|
76
|
+
"ds:transition-[colors,box-shadow] ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none",
|
|
76
77
|
"ds:focus-within:outline-[length:var(--focus-ring-width)] ds:focus-within:outline-solid",
|
|
77
78
|
"ds:focus-within:outline-ring ds:focus-within:outline-offset-[length:var(--focus-ring-offset)]",
|
|
78
79
|
"ds:forced-colors:focus-within:outline-[CanvasText]",
|
|
@@ -218,7 +219,7 @@ function et(n, r) {
|
|
|
218
219
|
})), y = new Intl.Collator(n);
|
|
219
220
|
return a.sort((o, u) => y.compare(o.name, u.name));
|
|
220
221
|
}
|
|
221
|
-
const tt =
|
|
222
|
+
const tt = ke(
|
|
222
223
|
function({
|
|
223
224
|
value: r,
|
|
224
225
|
defaultValue: d,
|
|
@@ -237,7 +238,7 @@ const tt = Se(
|
|
|
237
238
|
required: ue,
|
|
238
239
|
"aria-label": pe
|
|
239
240
|
}, fe) {
|
|
240
|
-
const { t: v, i18n: j } = je(), C = Te(),
|
|
241
|
+
const { t: v, i18n: j } = je(), C = Te(), x = Pe(Ae) !== null, z = m(
|
|
241
242
|
() => new Set(Be()),
|
|
242
243
|
[]
|
|
243
244
|
), G = m(() => {
|
|
@@ -257,7 +258,7 @@ const tt = Se(
|
|
|
257
258
|
return { country: e, display: "" };
|
|
258
259
|
}, []), [l, B] = P(G.country), [O, p] = P(
|
|
259
260
|
G.display
|
|
260
|
-
), [D, T] = P(!1), [me, U] = P(""), W = r !== void 0, A = $(""), R = $(null),
|
|
261
|
+
), [D, T] = P(!1), [me, U] = P(""), W = r !== void 0, A = $(""), R = $(null), S = $(null), he = Le(fe, S);
|
|
261
262
|
Ve(() => {
|
|
262
263
|
if (!W) return;
|
|
263
264
|
const e = r ?? "";
|
|
@@ -272,7 +273,7 @@ const tt = Se(
|
|
|
272
273
|
if (R.current == null) return;
|
|
273
274
|
const e = R.current;
|
|
274
275
|
R.current = null;
|
|
275
|
-
const t =
|
|
276
|
+
const t = S.current;
|
|
276
277
|
t && document.activeElement === t && t.setSelectionRange(e, e);
|
|
277
278
|
});
|
|
278
279
|
const h = se(
|
|
@@ -286,11 +287,11 @@ const tt = Se(
|
|
|
286
287
|
});
|
|
287
288
|
},
|
|
288
289
|
[o]
|
|
289
|
-
), ge = E ?? (
|
|
290
|
+
), ge = E ?? (x ? C.id : void 0), Y = (x ? C.disabled : !1) || !!ie, be = (x ? C.required : !1) || !!ue, Z = x ? C.invalid : !1, ye = Z ? "error" : ae, ve = x && C.describedBy ? C.describedBy : void 0, Ce = de ?? v("inputs.phone.placeholder", "Phone number"), we = (e) => {
|
|
290
291
|
if (_) return;
|
|
291
|
-
const t = e.target, s = t.value, c = t.selectionStart ?? s.length,
|
|
292
|
-
R.current = Qe(K,
|
|
293
|
-
}, J = A,
|
|
292
|
+
const t = e.target, s = t.value, c = t.selectionStart ?? s.length, w = Je(s, c), K = new M(l).input(s);
|
|
293
|
+
R.current = Qe(K, w), p(K), h(K, l);
|
|
294
|
+
}, J = A, xe = m(
|
|
294
295
|
() => ({
|
|
295
296
|
getValue: () => J.current,
|
|
296
297
|
setValue: (e) => {
|
|
@@ -311,12 +312,12 @@ const tt = Se(
|
|
|
311
312
|
},
|
|
312
313
|
focus: () => {
|
|
313
314
|
var e;
|
|
314
|
-
return (e =
|
|
315
|
+
return (e = S.current) == null ? void 0 : e.focus();
|
|
315
316
|
}
|
|
316
317
|
}),
|
|
317
318
|
[l, h, J]
|
|
318
319
|
);
|
|
319
|
-
Ke(Me,
|
|
320
|
+
Ke(Me, xe, E);
|
|
320
321
|
const ze = (e) => {
|
|
321
322
|
if (e === l) {
|
|
322
323
|
T(!1);
|
|
@@ -324,8 +325,8 @@ const tt = Se(
|
|
|
324
325
|
}
|
|
325
326
|
const t = O.replace(/\D/g, ""), s = new M(e), c = t ? s.input(t) : "";
|
|
326
327
|
B(e), p(c), T(!1), U(""), h(c, e), requestAnimationFrame(() => {
|
|
327
|
-
var
|
|
328
|
-
(
|
|
328
|
+
var w;
|
|
329
|
+
(w = S.current) == null || w.focus();
|
|
329
330
|
});
|
|
330
331
|
}, g = m(
|
|
331
332
|
() => et(
|
|
@@ -343,15 +344,15 @@ const tt = Se(
|
|
|
343
344
|
), Ne = m(
|
|
344
345
|
() => L.size > 0 ? g.filter((e) => !L.has(e.code)) : g,
|
|
345
346
|
[g, L]
|
|
346
|
-
),
|
|
347
|
+
), k = m(
|
|
347
348
|
() => g.find((e) => e.code === l),
|
|
348
349
|
[g, l]
|
|
349
|
-
), Q =
|
|
350
|
+
), Q = k ? k.dialCode : "", Ie = k ? k.name : l, X = v("inputs.phone.countryPickerLabel", "Country"), Re = `${X}: ${Ie}, +${Q}`, Se = se(
|
|
350
351
|
(e, t, s) => {
|
|
351
|
-
const c = q(e),
|
|
352
|
+
const c = q(e), w = q(t), te = s == null ? void 0 : s.map(q);
|
|
352
353
|
return Ee(
|
|
353
354
|
c,
|
|
354
|
-
|
|
355
|
+
w,
|
|
355
356
|
te
|
|
356
357
|
);
|
|
357
358
|
},
|
|
@@ -427,7 +428,7 @@ const tt = Se(
|
|
|
427
428
|
sideOffset: 6,
|
|
428
429
|
align: "start",
|
|
429
430
|
className: Ge,
|
|
430
|
-
children: /* @__PURE__ */ f(b, { filter:
|
|
431
|
+
children: /* @__PURE__ */ f(b, { filter: Se, shouldFilter: !0, loop: !0, label: X, children: [
|
|
431
432
|
/* @__PURE__ */ i(
|
|
432
433
|
b.Input,
|
|
433
434
|
{
|
|
@@ -489,7 +490,7 @@ const tt = Se(
|
|
|
489
490
|
"aria-label": pe,
|
|
490
491
|
"aria-describedby": ve,
|
|
491
492
|
"aria-invalid": Z || void 0,
|
|
492
|
-
onChange:
|
|
493
|
+
onChange: we,
|
|
493
494
|
className: _e({ size: u })
|
|
494
495
|
}
|
|
495
496
|
)
|
|
@@ -505,4 +506,4 @@ export {
|
|
|
505
506
|
He as c,
|
|
506
507
|
qe as p
|
|
507
508
|
};
|
|
508
|
-
//# sourceMappingURL=phone-input-
|
|
509
|
+
//# sourceMappingURL=phone-input-DKSHX7NQ.js.map
|