@alfadocs/ui-kit 0.17.0 → 0.17.2
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/{accordion-DOmxGEWU.js → accordion-CNcodXuO.js} +6 -6
- package/dist/_chunks/{ai-prompt-input-DEiQwIMn.js → ai-prompt-input-B-w5Rx3V.js} +184 -181
- package/dist/_chunks/{alert-pgdXrEO5.js → alert-DBnawbmf.js} +64 -59
- package/dist/_chunks/{audio-recorder-CRh4uyFL.js → audio-recorder-DNkQLW1G.js} +3 -3
- package/dist/_chunks/{autocomplete-mOg7WLOh.js → autocomplete-BxfabhZ8.js} +167 -164
- package/dist/_chunks/{balance-cell-renderer-DWWtX-VM.js → balance-cell-renderer-DJB6WDPe.js} +2 -2
- package/dist/_chunks/{carousel.agent-OTn-kMQg.js → carousel.agent-Xuw9LPZN.js} +14 -7
- package/dist/_chunks/{chat-input-UK-bXU7u.js → chat-input-B3XmFGDw.js} +123 -122
- package/dist/_chunks/checkbox-group-Bwmt1ovQ.js +213 -0
- package/dist/_chunks/{checkbox-D5EHnB14.js → checkbox-mwbrPZDY.js} +75 -70
- package/dist/_chunks/{collapsible-CuxUBoHJ.js → collapsible-hHiyZp0b.js} +61 -63
- package/dist/_chunks/{color-picker-BPfcByHH.js → color-picker-Bm-gzpsh.js} +2 -2
- package/dist/_chunks/{combobox-D5tWe0t_.js → combobox-Da9eq00i.js} +214 -211
- package/dist/_chunks/{copy-field-BCHAZ8QV.js → copy-field-BAF4mt9h.js} +95 -132
- package/dist/_chunks/{date-picker-BlhtBhPo.js → date-picker-BIoSLRly.js} +222 -219
- package/dist/_chunks/{date-range-picker-C2hRu_Ke.js → date-range-picker-9gANFNG9.js} +81 -78
- package/dist/_chunks/{date-time-picker-B67mPZmP.js → date-time-picker-DG7BiGdb.js} +98 -95
- package/dist/_chunks/{dialog-DRp6Dejy.js → dialog-DUomPCRS.js} +69 -71
- package/dist/_chunks/{dropdown-menu-dyV7gHh_.js → dropdown-menu-DZxwF23X.js} +108 -110
- package/dist/_chunks/{freemium-paywall-BTEiVkes.js → freemium-paywall-DXc7XlGE.js} +98 -97
- package/dist/_chunks/{leo-sidebar-D3TuyH5_.js → leo-sidebar-DIsiTju3.js} +2 -2
- package/dist/_chunks/{list-DcjV0m5B.js → list-BdvDctBz.js} +184 -180
- package/dist/_chunks/{message-tray-Fsend-du.js → message-tray-BNAS8al4.js} +111 -111
- package/dist/_chunks/{multi-select-DooDzQIp.js → multi-select-CyspR5ZF.js} +157 -154
- package/dist/_chunks/{navigation-menu-DdufF-_4.js → navigation-menu-CyS1fBJ7.js} +85 -87
- package/dist/_chunks/{notification-tray-C3dYdLAF.js → notification-tray-D_69dXFY.js} +114 -114
- package/dist/_chunks/{number-input-DH00o0DN.js → number-input-BZXu6bPY.js} +92 -89
- package/dist/_chunks/{otp-input-BBXYvLx5.js → otp-input-BDF_iNpa.js} +92 -93
- package/dist/_chunks/{pagination-F1ei4khE.js → pagination-BWaXF7W0.js} +194 -211
- package/dist/_chunks/{patient-shell-BE0CdPOJ.js → patient-shell-BOOaWZA9.js} +3 -3
- package/dist/_chunks/{payment-form-CI77oIx1.js → payment-form-BjkuQeqR.js} +2 -2
- package/dist/_chunks/{pdf-viewer-CnEJvmXC.js → pdf-viewer-BG_nsFT5.js} +2 -2
- package/dist/_chunks/{public-header.agent-sDi9N9su.js → public-header.agent-BIBQzkeV.js} +7 -12
- package/dist/_chunks/{radio-group-Cz1a4QCA.js → radio-group-BHZOxrIK.js} +4 -4
- package/dist/_chunks/{select-Ca6ibiDL.js → select-C92AT_OZ.js} +7 -7
- package/dist/_chunks/{sidebar-D8Lq065m.js → sidebar-BqzlRBvC.js} +271 -291
- package/dist/_chunks/{slider-CkR6CLun.js → slider-CfEzeseL.js} +4 -4
- package/dist/_chunks/{tabs-CRCyPpJo.js → tabs-aEQfQV3x.js} +8 -8
- package/dist/_chunks/{theme-toggle-B3meAb3y.js → theme-toggle-BswYl0Yp.js} +2 -2
- package/dist/_chunks/use-controllable-state-BiY4xTzM.js +23 -0
- package/dist/_chunks/use-copy-to-clipboard-Cyfc_dlv.js +43 -0
- package/dist/_chunks/use-persistent-state-i23OWy6G.js +24 -0
- package/dist/_chunks/{warning-stack-CeRihME9.js → warning-stack-CDH9TudY.js} +2 -2
- package/dist/_chunks/{workflow-map-D3MvrsZV.js → workflow-map-BeKe23uw.js} +3 -3
- package/dist/agent-catalog.json +1 -1
- package/dist/components/_shared/use-debounced-callback.d.ts +1 -5
- package/dist/components/_shared/use-direction.d.ts +1 -18
- package/dist/components/_shared/use-focus-trap.d.ts +1 -31
- package/dist/components/accordion/index.js +1 -1
- package/dist/components/ai-prompt-input/index.js +1 -1
- package/dist/components/alert/index.js +1 -1
- package/dist/components/audio-recorder/index.js +1 -1
- package/dist/components/autocomplete/index.js +1 -1
- package/dist/components/carousel/index.js +1 -1
- package/dist/components/chat-input/index.js +1 -1
- package/dist/components/checkbox/index.js +1 -1
- package/dist/components/checkbox-group/index.js +1 -1
- package/dist/components/collapsible/index.js +1 -1
- package/dist/components/color-picker/index.js +1 -1
- package/dist/components/combobox/index.js +1 -1
- package/dist/components/command-palette/command-palette.d.ts +1 -1
- package/dist/components/copy-field/index.js +1 -1
- package/dist/components/data-table/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/dialog/index.js +1 -1
- package/dist/components/dropdown-menu/index.js +1 -1
- package/dist/components/freemium-paywall/index.js +1 -1
- package/dist/components/icon-button-group/icon-button-group.d.ts +14 -14
- package/dist/components/list/index.js +1 -1
- package/dist/components/message-tray/index.js +1 -1
- package/dist/components/multi-select/index.js +1 -1
- package/dist/components/navigation-menu/index.js +1 -1
- package/dist/components/notification-tray/index.js +1 -1
- package/dist/components/number-input/index.js +1 -1
- package/dist/components/otp-input/index.js +1 -1
- package/dist/components/pagination/index.js +1 -1
- package/dist/components/payment-form/index.js +1 -1
- package/dist/components/pdf-viewer/index.js +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/radio-group/index.js +1 -1
- package/dist/components/select/index.js +1 -1
- package/dist/components/sidebar/index.js +8 -7
- package/dist/components/sidebar/sidebar.d.ts +1 -1
- package/dist/components/slider/index.js +1 -1
- package/dist/components/tabs/index.js +1 -1
- package/dist/components/theme-toggle/index.js +1 -1
- package/dist/components/warning-stack/index.js +1 -1
- package/dist/components/workflow/index.js +1 -1
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/index.js +98 -15
- package/dist/hooks/use-debounced-callback.d.ts +19 -0
- package/dist/hooks/use-debounced-value.d.ts +16 -0
- package/dist/hooks/use-direction.d.ts +19 -0
- package/dist/hooks/use-focus-trap.d.ts +32 -0
- package/dist/hooks/use-isomorphic-layout-effect.d.ts +13 -0
- package/dist/hooks/use-persistent-state.d.ts +16 -0
- package/dist/index.js +493 -492
- package/dist/patterns/leo-assistant/index.js +1 -1
- package/dist/patterns/patient-shell/index.js +1 -1
- package/dist/tokens.css +1 -1
- package/package.json +4 -2
- package/dist/_chunks/checkbox-group-Qkm3Rg1S.js +0 -208
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { c as
|
|
4
|
-
import { useTranslation as
|
|
1
|
+
import { jsxs as ve, jsx as F } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as G, forwardRef as be, useRef as A, useCallback as O, useState as _, useEffect as ge } from "react";
|
|
3
|
+
import { c as he } from "./index-D2ZczOXr.js";
|
|
4
|
+
import { useTranslation as Ne } from "react-i18next";
|
|
5
|
+
import { u as ye } from "./use-controllable-state-BiY4xTzM.js";
|
|
5
6
|
import { u as we } from "./form-field-context-B3APVHKx.js";
|
|
6
7
|
import { c as Ie } from "./compose-refs-C0k0tdqF.js";
|
|
7
8
|
import { u as De } from "./registry-C9nwlNyL.js";
|
|
8
9
|
import { C as xe } from "./chevron-down-BX_NP2Yh.js";
|
|
9
10
|
import { C as Fe } from "./chevron-up-zOEDrmBB.js";
|
|
10
|
-
const
|
|
11
|
+
const Ce = {
|
|
11
12
|
id: "number-input",
|
|
12
13
|
capabilities: ["edit_inline"],
|
|
13
14
|
state: {
|
|
@@ -64,29 +65,29 @@ const Se = {
|
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
};
|
|
67
|
-
function
|
|
68
|
+
function Se(t) {
|
|
68
69
|
let r = "";
|
|
69
|
-
for (const
|
|
70
|
-
const n =
|
|
71
|
-
n !== void 0 && (n >= 1632 && n <= 1641 ? r += String.fromCodePoint(48 + (n - 1632)) : n >= 1776 && n <= 1785 ? r += String.fromCodePoint(48 + (n - 1776)) : r +=
|
|
70
|
+
for (const d of t) {
|
|
71
|
+
const n = d.codePointAt(0);
|
|
72
|
+
n !== void 0 && (n >= 1632 && n <= 1641 ? r += String.fromCodePoint(48 + (n - 1632)) : n >= 1776 && n <= 1785 ? r += String.fromCodePoint(48 + (n - 1776)) : r += d);
|
|
72
73
|
}
|
|
73
74
|
return r;
|
|
74
75
|
}
|
|
75
|
-
function Ve(t, r,
|
|
76
|
-
return
|
|
77
|
-
var
|
|
78
|
-
const n = new Intl.NumberFormat(t).formatToParts(1234.5),
|
|
76
|
+
function Ve(t, r, d) {
|
|
77
|
+
return G(() => {
|
|
78
|
+
var S, V;
|
|
79
|
+
const n = new Intl.NumberFormat(t).formatToParts(1234.5), u = ((S = n.find((a) => a.type === "decimal")) == null ? void 0 : S.value) ?? ".", C = ((V = n.find((a) => a.type === "group")) == null ? void 0 : V.value) ?? ",", p = r === "currency" ? new Intl.NumberFormat(t, {
|
|
79
80
|
style: "currency",
|
|
80
|
-
currency:
|
|
81
|
+
currency: d ?? "USD"
|
|
81
82
|
}) : r === "percentage" ? new Intl.NumberFormat(t, {
|
|
82
83
|
style: "percent",
|
|
83
84
|
maximumFractionDigits: 4
|
|
84
85
|
}) : 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
86
|
if (!a) return NaN;
|
|
86
|
-
const
|
|
87
|
+
const M = Se(a), g = M.trim(), I = g.startsWith("-") || g.startsWith("−");
|
|
87
88
|
let c = "";
|
|
88
|
-
for (const h of
|
|
89
|
-
h >= "0" && h <= "9" ? c += h : h ===
|
|
89
|
+
for (const h of M)
|
|
90
|
+
h >= "0" && h <= "9" ? c += h : h === u && (c += ".");
|
|
90
91
|
if (!c || c === ".") return NaN;
|
|
91
92
|
let m = Number(c);
|
|
92
93
|
return Number.isFinite(m) ? (I && (m = -m), r === "percentage" && (m = m / 100), m) : NaN;
|
|
@@ -98,7 +99,7 @@ function Ve(t, r, u) {
|
|
|
98
99
|
try {
|
|
99
100
|
const { maximumFractionDigits: a } = new Intl.NumberFormat(t, {
|
|
100
101
|
style: "currency",
|
|
101
|
-
currency:
|
|
102
|
+
currency: d ?? "USD"
|
|
102
103
|
}).resolvedOptions();
|
|
103
104
|
b = a === 0 ? "numeric" : "decimal";
|
|
104
105
|
} catch {
|
|
@@ -107,13 +108,13 @@ function Ve(t, r, u) {
|
|
|
107
108
|
return {
|
|
108
109
|
format: T,
|
|
109
110
|
parse: z,
|
|
110
|
-
decimalSeparator:
|
|
111
|
-
groupingSeparator:
|
|
111
|
+
decimalSeparator: u,
|
|
112
|
+
groupingSeparator: C,
|
|
112
113
|
inputMode: b
|
|
113
114
|
};
|
|
114
|
-
}, [t, r,
|
|
115
|
+
}, [t, r, d]);
|
|
115
116
|
}
|
|
116
|
-
const
|
|
117
|
+
const Me = he(
|
|
117
118
|
[
|
|
118
119
|
"ds:flex ds:items-center ds:w-full ds:rounded-[var(--radius-sm)]",
|
|
119
120
|
"ds:border ds:bg-input ds:text-foreground",
|
|
@@ -137,7 +138,7 @@ const Ce = Ne(
|
|
|
137
138
|
},
|
|
138
139
|
defaultVariants: { size: "md", tone: "default" }
|
|
139
140
|
}
|
|
140
|
-
),
|
|
141
|
+
), $ = [
|
|
141
142
|
"ds:inline-flex ds:items-center ds:justify-center",
|
|
142
143
|
"ds:h-full ds:shrink-0",
|
|
143
144
|
"ds:text-muted-foreground ds:hover:text-foreground",
|
|
@@ -146,100 +147,102 @@ const Ce = Ne(
|
|
|
146
147
|
].join(" "), ke = () => typeof navigator < "u" && navigator.language ? navigator.language : "en-US";
|
|
147
148
|
function Te(t) {
|
|
148
149
|
if (!Number.isFinite(t)) return 0;
|
|
149
|
-
const r = String(t),
|
|
150
|
-
return
|
|
150
|
+
const r = String(t), d = r.indexOf(".");
|
|
151
|
+
return d === -1 ? 0 : r.length - d - 1;
|
|
151
152
|
}
|
|
152
153
|
function ze(t, r) {
|
|
153
154
|
if (r <= 0 || !Number.isFinite(r)) return t;
|
|
154
155
|
const n = 10 ** Te(r);
|
|
155
156
|
return Math.round(t * n) / n;
|
|
156
157
|
}
|
|
157
|
-
const Pe =
|
|
158
|
+
const Pe = be(
|
|
158
159
|
({
|
|
159
160
|
value: t,
|
|
160
161
|
defaultValue: r,
|
|
161
|
-
onChange:
|
|
162
|
+
onChange: d,
|
|
162
163
|
min: n,
|
|
163
|
-
max:
|
|
164
|
-
step:
|
|
164
|
+
max: u,
|
|
165
|
+
step: C = 1,
|
|
165
166
|
mode: p = "integer",
|
|
166
167
|
currency: T,
|
|
167
168
|
locale: z,
|
|
168
169
|
size: b = "md",
|
|
169
|
-
tone:
|
|
170
|
+
tone: S,
|
|
170
171
|
className: V,
|
|
171
172
|
id: a,
|
|
172
|
-
disabled:
|
|
173
|
+
disabled: M,
|
|
173
174
|
onFocus: g,
|
|
174
175
|
onBlur: I,
|
|
175
176
|
onKeyDown: c,
|
|
176
177
|
...m
|
|
177
178
|
}, h) => {
|
|
178
|
-
const { t:
|
|
179
|
-
decimalSeparator:
|
|
179
|
+
const { t: E } = Ne(), D = we(), J = a ?? D.id, k = !!(D.disabled || M), Q = z ?? ke(), P = Ve(Q, p, T), {
|
|
180
|
+
decimalSeparator: U,
|
|
180
181
|
format: R,
|
|
181
|
-
parse:
|
|
182
|
-
} = P,
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
parse: B
|
|
183
|
+
} = P, K = A(null), X = Ie(h, K), [Y, Z] = ye({
|
|
184
|
+
value: t,
|
|
185
|
+
defaultValue: r ?? null,
|
|
186
|
+
onChange: d
|
|
187
|
+
}), s = Y ?? null, L = A(s);
|
|
188
|
+
L.current = s;
|
|
189
|
+
const x = O(
|
|
187
190
|
(e) => {
|
|
188
191
|
const i = p === "percentage" ? e * 100 : e;
|
|
189
|
-
return (Number.isInteger(i) ? String(i) : i.toString()).replace(".",
|
|
192
|
+
return (Number.isInteger(i) ? String(i) : i.toString()).replace(".", U);
|
|
190
193
|
},
|
|
191
|
-
[p,
|
|
192
|
-
), f =
|
|
194
|
+
[p, U]
|
|
195
|
+
), f = O(
|
|
193
196
|
(e) => e == null || Number.isNaN(e) ? "" : R(e),
|
|
194
197
|
[R]
|
|
195
|
-
), [j, l] =
|
|
198
|
+
), [j, l] = _(
|
|
196
199
|
() => f(s)
|
|
197
|
-
), N = A(!1), [
|
|
198
|
-
|
|
200
|
+
), N = A(!1), [ee, y] = _(!1);
|
|
201
|
+
ge(() => {
|
|
199
202
|
N.current || l(f(s));
|
|
200
203
|
}, [s, f]);
|
|
201
|
-
const
|
|
202
|
-
|
|
204
|
+
const te = ee || s !== null && (n !== void 0 && s < n || u !== void 0 && s > u), H = D.invalid || te, ne = H ? "error" : S ?? "default", v = (e) => {
|
|
205
|
+
Z(e);
|
|
203
206
|
}, w = (e) => {
|
|
204
|
-
let o = (s ?? 0) +
|
|
205
|
-
n !== void 0 && (o = Math.max(n, o)),
|
|
207
|
+
let o = (s ?? 0) + C * e;
|
|
208
|
+
n !== void 0 && (o = Math.max(n, o)), u !== void 0 && (o = Math.min(u, o)), o = ze(o, C), v(o), y(!1), l(
|
|
206
209
|
N.current ? x(o) : f(o)
|
|
207
210
|
);
|
|
208
|
-
},
|
|
211
|
+
}, W = (e) => {
|
|
209
212
|
v(e), y(!1), l(
|
|
210
213
|
N.current ? x(e) : f(e)
|
|
211
214
|
);
|
|
212
|
-
},
|
|
215
|
+
}, re = (e) => {
|
|
213
216
|
if (c == null || c(e), e.defaultPrevented || k) return;
|
|
214
217
|
const { key: i, shiftKey: o } = e;
|
|
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(),
|
|
216
|
-
},
|
|
218
|
+
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(), W(n)) : i === "End" && u !== void 0 && (e.preventDefault(), W(u));
|
|
219
|
+
}, se = (e) => {
|
|
217
220
|
const i = e.target.value;
|
|
218
221
|
if (l(i), i.trim() === "") {
|
|
219
222
|
v(null), y(!1);
|
|
220
223
|
return;
|
|
221
224
|
}
|
|
222
|
-
const o =
|
|
225
|
+
const o = B(i);
|
|
223
226
|
Number.isNaN(o) || v(o);
|
|
224
|
-
},
|
|
227
|
+
}, ie = (e) => {
|
|
225
228
|
g == null || g(e), N.current = !0, s != null && l(x(s));
|
|
226
|
-
},
|
|
229
|
+
}, oe = (e) => {
|
|
227
230
|
if (I == null || I(e), N.current = !1, j.trim() === "") {
|
|
228
231
|
v(null), y(!1), l("");
|
|
229
232
|
return;
|
|
230
233
|
}
|
|
231
|
-
const i =
|
|
234
|
+
const i = B(j);
|
|
232
235
|
if (Number.isNaN(i)) {
|
|
233
236
|
l(f(s));
|
|
234
237
|
return;
|
|
235
238
|
}
|
|
236
|
-
const o = n !== void 0 && i < n ||
|
|
239
|
+
const o = n !== void 0 && i < n || u !== void 0 && i > u;
|
|
237
240
|
y(o), v(i), l(f(i));
|
|
238
|
-
},
|
|
241
|
+
}, q = (e) => {
|
|
239
242
|
e.preventDefault();
|
|
240
|
-
},
|
|
243
|
+
}, ae = () => w(1), ue = () => w(-1), de = G(
|
|
241
244
|
() => ({
|
|
242
|
-
getValue: () =>
|
|
245
|
+
getValue: () => L.current,
|
|
243
246
|
setValue: (e) => {
|
|
244
247
|
v(e), l(
|
|
245
248
|
e === null ? "" : N.current ? x(e) : f(e)
|
|
@@ -250,7 +253,7 @@ const Pe = ge(
|
|
|
250
253
|
},
|
|
251
254
|
focus: () => {
|
|
252
255
|
var e;
|
|
253
|
-
return (e =
|
|
256
|
+
return (e = K.current) == null ? void 0 : e.focus();
|
|
254
257
|
}
|
|
255
258
|
}),
|
|
256
259
|
// The handle is reconstructed per render; consumers (the agent runtime)
|
|
@@ -258,14 +261,14 @@ const Pe = ge(
|
|
|
258
261
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
259
262
|
[x, f]
|
|
260
263
|
);
|
|
261
|
-
De(
|
|
262
|
-
const
|
|
263
|
-
return /* @__PURE__ */
|
|
264
|
+
De(Ce, de, a);
|
|
265
|
+
const le = k || n !== void 0 && s !== null && s <= n, ce = k || u !== void 0 && s !== null && s >= u, fe = s ?? void 0, pe = (p === "currency" || p === "percentage") && s !== null && s !== null ? R(s) : void 0, me = P.inputMode === "numeric" ? "[0-9]*" : void 0;
|
|
266
|
+
return /* @__PURE__ */ ve(
|
|
264
267
|
"div",
|
|
265
268
|
{
|
|
266
|
-
className:
|
|
269
|
+
className: Me({
|
|
267
270
|
size: b,
|
|
268
|
-
tone:
|
|
271
|
+
tone: ne,
|
|
269
272
|
className: V
|
|
270
273
|
}),
|
|
271
274
|
"data-component": "number-input",
|
|
@@ -277,37 +280,37 @@ const Pe = ge(
|
|
|
277
280
|
{
|
|
278
281
|
type: "button",
|
|
279
282
|
tabIndex: -1,
|
|
280
|
-
"aria-label":
|
|
281
|
-
onClick:
|
|
282
|
-
onMouseDown:
|
|
283
|
-
disabled:
|
|
284
|
-
className: `${
|
|
283
|
+
"aria-label": E("inputs.number.decrement", "Decrement"),
|
|
284
|
+
onClick: ue,
|
|
285
|
+
onMouseDown: q,
|
|
286
|
+
disabled: le,
|
|
287
|
+
className: `${$} ds:ps-2 ds:pe-1`,
|
|
285
288
|
children: /* @__PURE__ */ F(xe, { "aria-hidden": "true", className: "ds:size-4" })
|
|
286
289
|
}
|
|
287
290
|
),
|
|
288
291
|
/* @__PURE__ */ F(
|
|
289
292
|
"input",
|
|
290
293
|
{
|
|
291
|
-
ref:
|
|
292
|
-
id:
|
|
294
|
+
ref: X,
|
|
295
|
+
id: J,
|
|
293
296
|
type: "text",
|
|
294
297
|
role: "spinbutton",
|
|
295
298
|
inputMode: P.inputMode,
|
|
296
|
-
pattern:
|
|
299
|
+
pattern: me,
|
|
297
300
|
autoComplete: "off",
|
|
298
301
|
value: j,
|
|
299
302
|
disabled: k,
|
|
300
303
|
"aria-valuemin": n,
|
|
301
|
-
"aria-valuemax":
|
|
302
|
-
"aria-valuenow":
|
|
303
|
-
"aria-valuetext":
|
|
304
|
-
"aria-invalid":
|
|
304
|
+
"aria-valuemax": u,
|
|
305
|
+
"aria-valuenow": fe,
|
|
306
|
+
"aria-valuetext": pe,
|
|
307
|
+
"aria-invalid": H || void 0,
|
|
305
308
|
"aria-required": D.required || void 0,
|
|
306
309
|
"aria-describedby": D.describedBy || void 0,
|
|
307
|
-
onChange:
|
|
308
|
-
onFocus:
|
|
309
|
-
onBlur:
|
|
310
|
-
onKeyDown:
|
|
310
|
+
onChange: se,
|
|
311
|
+
onFocus: ie,
|
|
312
|
+
onBlur: oe,
|
|
313
|
+
onKeyDown: re,
|
|
311
314
|
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",
|
|
312
315
|
...m
|
|
313
316
|
}
|
|
@@ -317,11 +320,11 @@ const Pe = ge(
|
|
|
317
320
|
{
|
|
318
321
|
type: "button",
|
|
319
322
|
tabIndex: -1,
|
|
320
|
-
"aria-label":
|
|
321
|
-
onClick:
|
|
322
|
-
onMouseDown:
|
|
323
|
-
disabled:
|
|
324
|
-
className: `${
|
|
323
|
+
"aria-label": E("inputs.number.increment", "Increment"),
|
|
324
|
+
onClick: ae,
|
|
325
|
+
onMouseDown: q,
|
|
326
|
+
disabled: ce,
|
|
327
|
+
className: `${$} ds:ps-1 ds:pe-2`,
|
|
325
328
|
children: /* @__PURE__ */ F(Fe, { "aria-hidden": "true", className: "ds:size-4" })
|
|
326
329
|
}
|
|
327
330
|
)
|
|
@@ -335,4 +338,4 @@ export {
|
|
|
335
338
|
Pe as N,
|
|
336
339
|
Ve as u
|
|
337
340
|
};
|
|
338
|
-
//# sourceMappingURL=number-input-
|
|
341
|
+
//# sourceMappingURL=number-input-BZXu6bPY.js.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { c as
|
|
1
|
+
import { jsxs as Z, jsx as A } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as x, useId as ee, useRef as R, useState as te, useEffect as re, useCallback as L, useMemo as se } from "react";
|
|
3
|
+
import { c as N } from "./index-D2ZczOXr.js";
|
|
4
4
|
import { useTranslation as ae } from "react-i18next";
|
|
5
|
+
import { u as oe } from "./use-controllable-state-BiY4xTzM.js";
|
|
5
6
|
import { u as ie } from "./form-field-context-B3APVHKx.js";
|
|
6
7
|
import { u as ne } from "./registry-C9nwlNyL.js";
|
|
7
8
|
const ce = {
|
|
@@ -27,8 +28,8 @@ const ce = {
|
|
|
27
28
|
argsType: "{ value: string }",
|
|
28
29
|
descriptionKey: "ui.agent.otpInput.actions.setValue",
|
|
29
30
|
description: "Replace the entered digits.",
|
|
30
|
-
invoke: (e,
|
|
31
|
-
e.setValue(
|
|
31
|
+
invoke: (e, a) => {
|
|
32
|
+
e.setValue(a.value);
|
|
32
33
|
}
|
|
33
34
|
},
|
|
34
35
|
clear: {
|
|
@@ -60,7 +61,7 @@ const ce = {
|
|
|
60
61
|
description: "Sourced from the id prop."
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
|
-
}, ue =
|
|
64
|
+
}, ue = N("ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]"), le = N(
|
|
64
65
|
[
|
|
65
66
|
"ds:w-[var(--min-target-size)] ds:h-[var(--min-target-size)]",
|
|
66
67
|
"ds:rounded-[var(--radius-sm)]",
|
|
@@ -81,94 +82,92 @@ const ce = {
|
|
|
81
82
|
defaultVariants: { tone: "default" }
|
|
82
83
|
}
|
|
83
84
|
);
|
|
84
|
-
function
|
|
85
|
-
return e.replace(/[\u0660-\u0669]/g, (
|
|
85
|
+
function M(e) {
|
|
86
|
+
return e.replace(/[\u0660-\u0669]/g, (a) => String(a.charCodeAt(0) - 1632)).replace(/[\u06F0-\u06F9]/g, (a) => String(a.charCodeAt(0) - 1776));
|
|
86
87
|
}
|
|
87
|
-
function g(e,
|
|
88
|
-
return
|
|
88
|
+
function g(e, a) {
|
|
89
|
+
return M(e).replace(/\D/g, "").slice(0, a);
|
|
89
90
|
}
|
|
90
|
-
function de(e,
|
|
91
|
-
const m = g(e,
|
|
91
|
+
function de(e, a) {
|
|
92
|
+
const m = g(e, a), l = new Array(a).fill("");
|
|
92
93
|
for (let n = 0; n < m.length; n += 1)
|
|
93
94
|
l[n] = m[n];
|
|
94
95
|
return l;
|
|
95
96
|
}
|
|
96
|
-
const pe =
|
|
97
|
+
const pe = x(
|
|
97
98
|
({
|
|
98
99
|
length: e = 6,
|
|
99
|
-
value:
|
|
100
|
+
value: a,
|
|
100
101
|
defaultValue: m,
|
|
101
102
|
onChange: l,
|
|
102
103
|
onComplete: n,
|
|
103
104
|
disabled: S,
|
|
104
|
-
error:
|
|
105
|
+
error: O,
|
|
105
106
|
label: y,
|
|
106
|
-
id:
|
|
107
|
-
className:
|
|
108
|
-
},
|
|
109
|
-
const { t:
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
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);
|
|
107
|
+
id: F,
|
|
108
|
+
className: $
|
|
109
|
+
}, j) => {
|
|
110
|
+
const { t: z } = ae(), v = ie(), H = ee(), K = y ? H : void 0, [_, P] = oe({
|
|
111
|
+
value: a,
|
|
112
|
+
defaultValue: g(m ?? "", e)
|
|
113
|
+
}), p = g(_ ?? "", e), q = de(p, e), w = v.disabled || !!S, B = v.invalid || !!O, W = B ? "error" : "default", C = R([]), I = R(p.length === e), d = R(p);
|
|
115
114
|
d.current = p;
|
|
116
|
-
const
|
|
117
|
-
const
|
|
118
|
-
return
|
|
119
|
-
}, [f,
|
|
115
|
+
const G = () => {
|
|
116
|
+
const r = p.length;
|
|
117
|
+
return r >= e ? e - 1 : r;
|
|
118
|
+
}, [f, h] = te(G);
|
|
120
119
|
re(() => {
|
|
121
|
-
f >= e &&
|
|
120
|
+
f >= e && h(e - 1);
|
|
122
121
|
}, [f, e]);
|
|
123
|
-
const c =
|
|
124
|
-
(
|
|
125
|
-
const t = Math.max(0, Math.min(e - 1,
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
|
|
122
|
+
const c = L(
|
|
123
|
+
(r) => {
|
|
124
|
+
const t = Math.max(0, Math.min(e - 1, r));
|
|
125
|
+
h(t);
|
|
126
|
+
const s = C.current[t];
|
|
127
|
+
s && (s.focus(), s.select());
|
|
129
128
|
},
|
|
130
129
|
[e]
|
|
131
|
-
), u =
|
|
132
|
-
(
|
|
133
|
-
const t = g(
|
|
134
|
-
|
|
130
|
+
), u = L(
|
|
131
|
+
(r) => {
|
|
132
|
+
const t = g(r, e);
|
|
133
|
+
P(t), d.current = t, l == null || l(t), t.length === e ? I.current || (I.current = !0, n == null || n(t)) : I.current = !1;
|
|
135
134
|
},
|
|
136
|
-
[
|
|
137
|
-
),
|
|
138
|
-
const
|
|
139
|
-
if (
|
|
140
|
-
if (
|
|
141
|
-
const
|
|
142
|
-
u(
|
|
135
|
+
[P, e, l, n]
|
|
136
|
+
), J = (r) => (t) => {
|
|
137
|
+
const s = t.target.value, o = M(s).replace(/\D/g, ""), i = d.current;
|
|
138
|
+
if (o.length === 0) {
|
|
139
|
+
if (s === "" && r < i.length) {
|
|
140
|
+
const T = i.slice(0, r) + i.slice(r + 1);
|
|
141
|
+
u(T);
|
|
143
142
|
}
|
|
144
143
|
return;
|
|
145
144
|
}
|
|
146
|
-
const b = i.slice(0,
|
|
147
|
-
u(
|
|
148
|
-
const
|
|
149
|
-
c(
|
|
150
|
-
},
|
|
151
|
-
const
|
|
145
|
+
const b = i.slice(0, r), k = i.slice(r + o.length), V = (b + o + k).slice(0, e);
|
|
146
|
+
u(V);
|
|
147
|
+
const D = Math.min(r + o.length, e - 1);
|
|
148
|
+
c(D);
|
|
149
|
+
}, Q = (r) => (t) => {
|
|
150
|
+
const s = d.current;
|
|
152
151
|
if (t.key === "Backspace") {
|
|
153
|
-
if (r
|
|
152
|
+
if (s[r]) {
|
|
154
153
|
t.preventDefault();
|
|
155
|
-
const
|
|
156
|
-
u(
|
|
154
|
+
const o = s.slice(0, r) + s.slice(r + 1);
|
|
155
|
+
u(o);
|
|
157
156
|
return;
|
|
158
157
|
}
|
|
159
|
-
if (
|
|
158
|
+
if (r > 0) {
|
|
160
159
|
t.preventDefault();
|
|
161
|
-
const
|
|
162
|
-
u(
|
|
160
|
+
const o = s.slice(0, r - 1) + s.slice(r);
|
|
161
|
+
u(o), c(r - 1);
|
|
163
162
|
}
|
|
164
163
|
return;
|
|
165
164
|
}
|
|
166
165
|
if (t.key === "ArrowLeft") {
|
|
167
|
-
t.preventDefault(),
|
|
166
|
+
t.preventDefault(), r > 0 && c(r - 1);
|
|
168
167
|
return;
|
|
169
168
|
}
|
|
170
169
|
if (t.key === "ArrowRight") {
|
|
171
|
-
t.preventDefault(),
|
|
170
|
+
t.preventDefault(), r < e - 1 && c(r + 1);
|
|
172
171
|
return;
|
|
173
172
|
}
|
|
174
173
|
if (t.key === "Home") {
|
|
@@ -176,56 +175,56 @@ const pe = te(
|
|
|
176
175
|
return;
|
|
177
176
|
}
|
|
178
177
|
t.key === "End" && (t.preventDefault(), c(e - 1));
|
|
179
|
-
},
|
|
180
|
-
const
|
|
178
|
+
}, U = (r) => (t) => {
|
|
179
|
+
const o = t.clipboardData.getData("text").replace(/\s+/g, ""), i = M(o);
|
|
181
180
|
if (!/^[0-9]+$/.test(i)) return;
|
|
182
181
|
t.preventDefault();
|
|
183
|
-
const b = d.current,
|
|
184
|
-
u(
|
|
185
|
-
const
|
|
186
|
-
c(
|
|
187
|
-
},
|
|
188
|
-
|
|
189
|
-
}, E = v.id,
|
|
182
|
+
const b = d.current, k = b.slice(0, r), V = b.slice(r + i.length), D = (k + i + V).slice(0, e);
|
|
183
|
+
u(D);
|
|
184
|
+
const T = Math.min(r + i.length, e - 1);
|
|
185
|
+
c(T);
|
|
186
|
+
}, X = (r) => (t) => {
|
|
187
|
+
h(r), t.currentTarget.select();
|
|
188
|
+
}, E = v.id, Y = se(
|
|
190
189
|
() => ({
|
|
191
190
|
getValue: () => d.current,
|
|
192
|
-
setValue: (
|
|
191
|
+
setValue: (r) => u(r),
|
|
193
192
|
clear: () => u(""),
|
|
194
193
|
focus: () => c(f),
|
|
195
194
|
isComplete: () => d.current.length === e
|
|
196
195
|
}),
|
|
197
196
|
[u, c, f, e]
|
|
198
197
|
);
|
|
199
|
-
return ne(ce,
|
|
200
|
-
y ? /* @__PURE__ */
|
|
198
|
+
return ne(ce, Y, F), /* @__PURE__ */ Z("div", { className: ue({ className: $ }), children: [
|
|
199
|
+
y ? /* @__PURE__ */ A(
|
|
201
200
|
"label",
|
|
202
201
|
{
|
|
203
|
-
id:
|
|
202
|
+
id: K,
|
|
204
203
|
htmlFor: `${E}-0`,
|
|
205
204
|
className: "type-label ds:text-foreground",
|
|
206
205
|
children: y
|
|
207
206
|
}
|
|
208
207
|
) : null,
|
|
209
|
-
/* @__PURE__ */
|
|
208
|
+
/* @__PURE__ */ A(
|
|
210
209
|
"div",
|
|
211
210
|
{
|
|
212
|
-
ref:
|
|
211
|
+
ref: j,
|
|
213
212
|
role: "group",
|
|
214
213
|
dir: "ltr",
|
|
215
|
-
"aria-labelledby":
|
|
214
|
+
"aria-labelledby": K,
|
|
216
215
|
"aria-invalid": B || void 0,
|
|
217
216
|
"aria-describedby": v.describedBy || void 0,
|
|
218
|
-
"aria-disabled":
|
|
217
|
+
"aria-disabled": w || void 0,
|
|
219
218
|
"data-component": "otp-input",
|
|
220
|
-
"data-component-id":
|
|
219
|
+
"data-component-id": F,
|
|
221
220
|
className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-sm)]",
|
|
222
|
-
children:
|
|
223
|
-
const
|
|
224
|
-
return /* @__PURE__ */
|
|
221
|
+
children: q.map((r, t) => {
|
|
222
|
+
const s = !w && t === f;
|
|
223
|
+
return /* @__PURE__ */ A(
|
|
225
224
|
"input",
|
|
226
225
|
{
|
|
227
|
-
ref: (
|
|
228
|
-
C.current[t] =
|
|
226
|
+
ref: (o) => {
|
|
227
|
+
C.current[t] = o;
|
|
229
228
|
},
|
|
230
229
|
id: `${E}-${t}`,
|
|
231
230
|
type: "text",
|
|
@@ -233,18 +232,18 @@ const pe = te(
|
|
|
233
232
|
pattern: "[0-9]*",
|
|
234
233
|
autoComplete: t === 0 ? "one-time-code" : "off",
|
|
235
234
|
maxLength: 1,
|
|
236
|
-
value:
|
|
237
|
-
disabled:
|
|
238
|
-
tabIndex:
|
|
239
|
-
"aria-label":
|
|
235
|
+
value: r,
|
|
236
|
+
disabled: w,
|
|
237
|
+
tabIndex: s ? 0 : -1,
|
|
238
|
+
"aria-label": z("inputs.otp.digitLabel", {
|
|
240
239
|
current: t + 1,
|
|
241
240
|
total: e
|
|
242
241
|
}),
|
|
243
|
-
onChange:
|
|
244
|
-
onKeyDown:
|
|
245
|
-
onPaste:
|
|
246
|
-
onFocus:
|
|
247
|
-
className: le({ tone:
|
|
242
|
+
onChange: J(t),
|
|
243
|
+
onKeyDown: Q(t),
|
|
244
|
+
onPaste: U(t),
|
|
245
|
+
onFocus: X(t),
|
|
246
|
+
className: le({ tone: W })
|
|
248
247
|
},
|
|
249
248
|
t
|
|
250
249
|
);
|
|
@@ -258,4 +257,4 @@ pe.displayName = "OTPInput";
|
|
|
258
257
|
export {
|
|
259
258
|
pe as O
|
|
260
259
|
};
|
|
261
|
-
//# sourceMappingURL=otp-input-
|
|
260
|
+
//# sourceMappingURL=otp-input-BDF_iNpa.js.map
|