@alfadocs/ui-kit 0.54.0 → 0.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/otp-input-xQ4Ps5VY.js +279 -0
- package/dist/_chunks/{pdf-viewer-4odMFuFW.js → pdf-viewer-XxWdtKfD.js} +63 -58
- package/dist/_chunks/{sign-document-BzHTjMVC.js → sign-document-BmAT0kKD.js} +3 -3
- package/dist/_chunks/{signature-capture-CHbrKoA_.js → signature-capture-COi0Uiqu.js} +22 -7
- package/dist/_chunks/use-signing-session-CyOZWinp.js +147 -0
- package/dist/agent-catalog.json +1 -1
- package/dist/components/otp-input/index.js +1 -1
- package/dist/components/otp-input/otp-input.d.ts +13 -1
- package/dist/components/pdf-viewer/index.js +1 -1
- package/dist/components/sign-document/index.js +1 -1
- package/dist/components/signature-capture/index.js +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/use-signing-session.d.ts +8 -0
- package/dist/i18n/locales/ar.d.ts +1 -0
- package/dist/i18n/locales/ar.js +2 -1
- package/dist/i18n/locales/de.d.ts +1 -0
- package/dist/i18n/locales/de.js +2 -1
- package/dist/i18n/locales/el.d.ts +1 -0
- package/dist/i18n/locales/el.js +2 -1
- package/dist/i18n/locales/en.d.ts +1 -0
- package/dist/i18n/locales/en.js +2 -1
- package/dist/i18n/locales/es.d.ts +1 -0
- package/dist/i18n/locales/es.js +2 -1
- package/dist/i18n/locales/fr.d.ts +1 -0
- package/dist/i18n/locales/fr.js +2 -1
- package/dist/i18n/locales/hi.d.ts +1 -0
- package/dist/i18n/locales/hi.js +2 -1
- package/dist/i18n/locales/it.d.ts +1 -0
- package/dist/i18n/locales/it.js +2 -1
- package/dist/i18n/locales/ja.d.ts +1 -0
- package/dist/i18n/locales/ja.js +2 -1
- package/dist/i18n/locales/nl.d.ts +1 -0
- package/dist/i18n/locales/nl.js +2 -1
- package/dist/i18n/locales/pl.d.ts +1 -0
- package/dist/i18n/locales/pl.js +2 -1
- package/dist/i18n/locales/pt.d.ts +1 -0
- package/dist/i18n/locales/pt.js +2 -1
- package/dist/i18n/locales/ro.d.ts +1 -0
- package/dist/i18n/locales/ro.js +2 -1
- package/dist/i18n/locales/ru.d.ts +1 -0
- package/dist/i18n/locales/ru.js +2 -1
- package/dist/i18n/locales/sq.d.ts +1 -0
- package/dist/i18n/locales/sq.js +2 -1
- package/dist/i18n/locales/sv.d.ts +1 -0
- package/dist/i18n/locales/sv.js +2 -1
- package/dist/i18n/locales/tr.d.ts +1 -0
- package/dist/i18n/locales/tr.js +2 -1
- package/dist/i18n/locales/zh.d.ts +1 -0
- package/dist/i18n/locales/zh.js +2 -1
- package/dist/index.js +5 -5
- package/dist/locales/ar.json +2 -1
- package/dist/locales/de.json +2 -1
- package/dist/locales/el.json +2 -1
- package/dist/locales/en.json +2 -1
- package/dist/locales/es.json +2 -1
- package/dist/locales/fr.json +2 -1
- package/dist/locales/hi.json +2 -1
- package/dist/locales/it.json +2 -1
- package/dist/locales/ja.json +2 -1
- package/dist/locales/nl.json +2 -1
- package/dist/locales/pl.json +2 -1
- package/dist/locales/pt.json +2 -1
- package/dist/locales/ro.json +2 -1
- package/dist/locales/ru.json +2 -1
- package/dist/locales/sq.json +2 -1
- package/dist/locales/sv.json +2 -1
- package/dist/locales/tr.json +2 -1
- package/dist/locales/zh.json +2 -1
- package/dist/tokens.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/otp-input-Chb9r5vf.js +0 -268
- package/dist/_chunks/use-signing-session-C5evzYmo.js +0 -108
package/package.json
CHANGED
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { jsxs as ee, jsx as y } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as te, useId as re, useRef as M, useState as se, useEffect as ae, useCallback as N, useMemo as oe, useImperativeHandle as ie } from "react";
|
|
3
|
-
import { c as S } from "./index-D2ZczOXr.js";
|
|
4
|
-
import { useTranslation as ne } from "react-i18next";
|
|
5
|
-
import { u as ce } from "./use-controllable-state-BiY4xTzM.js";
|
|
6
|
-
import { u as ue } from "./use-web-otp-D_utzp6S.js";
|
|
7
|
-
import { u as le } from "./form-field-context-B3APVHKx.js";
|
|
8
|
-
import { u as de } from "./registry-nPAVE19X.js";
|
|
9
|
-
const pe = {
|
|
10
|
-
id: "otp-input",
|
|
11
|
-
capabilities: ["edit_inline", "submit"],
|
|
12
|
-
state: {
|
|
13
|
-
value: {
|
|
14
|
-
type: "string",
|
|
15
|
-
descriptionKey: "ui.agent.otpInput.state.value",
|
|
16
|
-
description: "Current digits entered, packed into a single string.",
|
|
17
|
-
read: (e) => e.getValue()
|
|
18
|
-
},
|
|
19
|
-
isComplete: {
|
|
20
|
-
type: "boolean",
|
|
21
|
-
descriptionKey: "ui.agent.otpInput.state.isComplete",
|
|
22
|
-
description: "Whether all required digits have been entered.",
|
|
23
|
-
read: (e) => e.isComplete()
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
actions: {
|
|
27
|
-
set_value: {
|
|
28
|
-
safety: "write",
|
|
29
|
-
argsType: "{ value: string }",
|
|
30
|
-
descriptionKey: "ui.agent.otpInput.actions.setValue",
|
|
31
|
-
description: "Replace the entered digits.",
|
|
32
|
-
invoke: (e, a) => {
|
|
33
|
-
e.setValue(a.value);
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
clear: {
|
|
37
|
-
safety: "destructive",
|
|
38
|
-
descriptionKey: "ui.agent.otpInput.actions.clear",
|
|
39
|
-
description: "Empty all digit cells. Loses any typed value.",
|
|
40
|
-
invoke: (e) => {
|
|
41
|
-
e.clear();
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
focus: {
|
|
45
|
-
safety: "read",
|
|
46
|
-
descriptionKey: "ui.agent.otpInput.actions.focus",
|
|
47
|
-
description: "Move keyboard focus to the active digit cell.",
|
|
48
|
-
invoke: (e) => {
|
|
49
|
-
e.focus();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
domHooks: {
|
|
54
|
-
root: {
|
|
55
|
-
attr: "data-component",
|
|
56
|
-
value: "otp-input",
|
|
57
|
-
description: "Marks the OTPInput wrapper. Completion is observable via state.isComplete; the host onComplete callback fires once when all digits are filled."
|
|
58
|
-
},
|
|
59
|
-
instanceId: {
|
|
60
|
-
attr: "data-component-id",
|
|
61
|
-
sourceProp: "id",
|
|
62
|
-
description: "Sourced from the id prop."
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}, fe = S("ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]"), me = S(
|
|
66
|
-
[
|
|
67
|
-
"ds:w-[var(--min-target-size)] ds:h-[var(--min-target-size)]",
|
|
68
|
-
"ds:rounded-[var(--radius-sm)]",
|
|
69
|
-
"ds:border ds:bg-input ds:text-foreground ds:text-center ds:font-medium ds:text-[length:var(--font-size-lg)]",
|
|
70
|
-
"ds:shadow-[var(--shadow-input)]",
|
|
71
|
-
"ds:transition-[colors,box-shadow] ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none",
|
|
72
|
-
"ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid",
|
|
73
|
-
"ds:focus-visible:outline-ring ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
|
|
74
|
-
"ds:disabled:cursor-not-allowed ds:disabled:opacity-50"
|
|
75
|
-
].join(" "),
|
|
76
|
-
{
|
|
77
|
-
variants: {
|
|
78
|
-
tone: {
|
|
79
|
-
default: "ds:border-border",
|
|
80
|
-
error: "ds:border-destructive"
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
defaultVariants: { tone: "default" }
|
|
84
|
-
}
|
|
85
|
-
);
|
|
86
|
-
function F(e) {
|
|
87
|
-
return e.replace(/[\u0660-\u0669]/g, (a) => String(a.charCodeAt(0) - 1632)).replace(/[\u06F0-\u06F9]/g, (a) => String(a.charCodeAt(0) - 1776));
|
|
88
|
-
}
|
|
89
|
-
function w(e, a) {
|
|
90
|
-
return F(e).replace(/\D/g, "").slice(0, a);
|
|
91
|
-
}
|
|
92
|
-
function ve(e, a) {
|
|
93
|
-
const m = w(e, a), l = new Array(a).fill("");
|
|
94
|
-
for (let n = 0; n < m.length; n += 1)
|
|
95
|
-
l[n] = m[n];
|
|
96
|
-
return l;
|
|
97
|
-
}
|
|
98
|
-
const be = te(
|
|
99
|
-
({
|
|
100
|
-
length: e = 6,
|
|
101
|
-
value: a,
|
|
102
|
-
defaultValue: m,
|
|
103
|
-
onChange: l,
|
|
104
|
-
onComplete: n,
|
|
105
|
-
disabled: H,
|
|
106
|
-
error: $,
|
|
107
|
-
label: I,
|
|
108
|
-
id: K,
|
|
109
|
-
className: j,
|
|
110
|
-
webOtp: z = !1,
|
|
111
|
-
name: C
|
|
112
|
-
}, W) => {
|
|
113
|
-
const { t: _ } = ne(), v = le(), q = re(), O = I ? q : void 0, [G, P] = ce({
|
|
114
|
-
value: a,
|
|
115
|
-
defaultValue: w(m ?? "", e)
|
|
116
|
-
}), p = w(G ?? "", e), J = ve(p, e), b = v.disabled || !!H, B = v.invalid || !!$, Q = B ? "error" : "default", E = M([]), h = M(p.length === e), d = M(p);
|
|
117
|
-
d.current = p;
|
|
118
|
-
const U = () => {
|
|
119
|
-
const r = p.length;
|
|
120
|
-
return r >= e ? e - 1 : r;
|
|
121
|
-
}, [f, k] = se(U);
|
|
122
|
-
ae(() => {
|
|
123
|
-
f >= e && k(e - 1);
|
|
124
|
-
}, [f, e]);
|
|
125
|
-
const c = N(
|
|
126
|
-
(r) => {
|
|
127
|
-
const t = Math.max(0, Math.min(e - 1, r));
|
|
128
|
-
k(t);
|
|
129
|
-
const s = E.current[t];
|
|
130
|
-
s && (s.focus(), s.select());
|
|
131
|
-
},
|
|
132
|
-
[e]
|
|
133
|
-
), u = N(
|
|
134
|
-
(r) => {
|
|
135
|
-
const t = w(r, e);
|
|
136
|
-
P(t), d.current = t, l == null || l(t), t.length === e ? h.current || (h.current = !0, n == null || n(t)) : h.current = !1;
|
|
137
|
-
},
|
|
138
|
-
[P, e, l, n]
|
|
139
|
-
);
|
|
140
|
-
ue({
|
|
141
|
-
enabled: z && !b,
|
|
142
|
-
onCode: u
|
|
143
|
-
});
|
|
144
|
-
const X = (r) => (t) => {
|
|
145
|
-
const s = t.target.value, o = F(s).replace(/\D/g, ""), i = d.current;
|
|
146
|
-
if (o.length === 0) {
|
|
147
|
-
if (s === "" && r < i.length) {
|
|
148
|
-
const R = i.slice(0, r) + i.slice(r + 1);
|
|
149
|
-
u(R);
|
|
150
|
-
}
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
const g = i.slice(0, r), D = i.slice(r + o.length), T = (g + o + D).slice(0, e);
|
|
154
|
-
u(T);
|
|
155
|
-
const A = Math.min(r + o.length, e - 1);
|
|
156
|
-
c(A);
|
|
157
|
-
}, Y = (r) => (t) => {
|
|
158
|
-
const s = d.current;
|
|
159
|
-
if (t.key === "Backspace") {
|
|
160
|
-
if (s[r]) {
|
|
161
|
-
t.preventDefault();
|
|
162
|
-
const o = s.slice(0, r) + s.slice(r + 1);
|
|
163
|
-
u(o);
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
if (r > 0) {
|
|
167
|
-
t.preventDefault();
|
|
168
|
-
const o = s.slice(0, r - 1) + s.slice(r);
|
|
169
|
-
u(o), c(r - 1);
|
|
170
|
-
}
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
if (t.key === "ArrowLeft") {
|
|
174
|
-
t.preventDefault(), r > 0 && c(r - 1);
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
if (t.key === "ArrowRight") {
|
|
178
|
-
t.preventDefault(), r < e - 1 && c(r + 1);
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
if (t.key === "Home") {
|
|
182
|
-
t.preventDefault(), c(0);
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
t.key === "End" && (t.preventDefault(), c(e - 1));
|
|
186
|
-
}, Z = (r) => (t) => {
|
|
187
|
-
const o = t.clipboardData.getData("text").replace(/\s+/g, ""), i = F(o);
|
|
188
|
-
if (!/^[0-9]+$/.test(i)) return;
|
|
189
|
-
t.preventDefault();
|
|
190
|
-
const g = d.current, D = g.slice(0, r), T = g.slice(r + i.length), A = (D + i + T).slice(0, e);
|
|
191
|
-
u(A);
|
|
192
|
-
const R = Math.min(r + i.length, e - 1);
|
|
193
|
-
c(R);
|
|
194
|
-
}, x = (r) => (t) => {
|
|
195
|
-
k(r), t.currentTarget.select();
|
|
196
|
-
}, L = v.id, V = oe(
|
|
197
|
-
() => ({
|
|
198
|
-
getValue: () => d.current,
|
|
199
|
-
setValue: (r) => u(r),
|
|
200
|
-
clear: () => u(""),
|
|
201
|
-
focus: () => c(f),
|
|
202
|
-
isComplete: () => d.current.length === e
|
|
203
|
-
}),
|
|
204
|
-
[u, c, f, e]
|
|
205
|
-
);
|
|
206
|
-
return de(pe, V, K), ie(W, () => V, [V]), /* @__PURE__ */ ee("div", { className: fe({ className: j }), children: [
|
|
207
|
-
I ? /* @__PURE__ */ y(
|
|
208
|
-
"label",
|
|
209
|
-
{
|
|
210
|
-
id: O,
|
|
211
|
-
htmlFor: `${L}-0`,
|
|
212
|
-
className: "type-label ds:text-foreground",
|
|
213
|
-
children: I
|
|
214
|
-
}
|
|
215
|
-
) : null,
|
|
216
|
-
/* @__PURE__ */ y(
|
|
217
|
-
"div",
|
|
218
|
-
{
|
|
219
|
-
role: "group",
|
|
220
|
-
dir: "ltr",
|
|
221
|
-
"aria-labelledby": O,
|
|
222
|
-
"aria-invalid": B || void 0,
|
|
223
|
-
"aria-describedby": v.describedBy || void 0,
|
|
224
|
-
"aria-disabled": b || void 0,
|
|
225
|
-
"data-component": "otp-input",
|
|
226
|
-
"data-component-id": K,
|
|
227
|
-
className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-sm)]",
|
|
228
|
-
children: J.map((r, t) => {
|
|
229
|
-
const s = !b && t === f;
|
|
230
|
-
return /* @__PURE__ */ y(
|
|
231
|
-
"input",
|
|
232
|
-
{
|
|
233
|
-
ref: (o) => {
|
|
234
|
-
E.current[t] = o;
|
|
235
|
-
},
|
|
236
|
-
id: `${L}-${t}`,
|
|
237
|
-
type: "text",
|
|
238
|
-
inputMode: "numeric",
|
|
239
|
-
pattern: "[0-9]*",
|
|
240
|
-
autoComplete: t === 0 ? "one-time-code" : "off",
|
|
241
|
-
maxLength: 1,
|
|
242
|
-
value: r,
|
|
243
|
-
disabled: b,
|
|
244
|
-
tabIndex: s ? 0 : -1,
|
|
245
|
-
"aria-label": _("inputs.otp.digitLabel", {
|
|
246
|
-
current: t + 1,
|
|
247
|
-
total: e
|
|
248
|
-
}),
|
|
249
|
-
onChange: X(t),
|
|
250
|
-
onKeyDown: Y(t),
|
|
251
|
-
onPaste: Z(t),
|
|
252
|
-
onFocus: x(t),
|
|
253
|
-
className: me({ tone: Q })
|
|
254
|
-
},
|
|
255
|
-
t
|
|
256
|
-
);
|
|
257
|
-
})
|
|
258
|
-
}
|
|
259
|
-
),
|
|
260
|
-
C ? /* @__PURE__ */ y("input", { type: "hidden", name: C, value: p, readOnly: !0 }) : null
|
|
261
|
-
] });
|
|
262
|
-
}
|
|
263
|
-
);
|
|
264
|
-
be.displayName = "OTPInput";
|
|
265
|
-
export {
|
|
266
|
-
be as O
|
|
267
|
-
};
|
|
268
|
-
//# sourceMappingURL=otp-input-Chb9r5vf.js.map
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { useRef as w, useEffect as C, useState as y, useMemo as F, useCallback as S } from "react";
|
|
2
|
-
function b(e) {
|
|
3
|
-
return e != null && e.current ? e.current : typeof document > "u" ? null : document;
|
|
4
|
-
}
|
|
5
|
-
function A(e, o) {
|
|
6
|
-
const r = typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : (
|
|
7
|
-
// SSR / jsdom fallback — drop every character that's
|
|
8
|
-
// significant in a CSS attribute selector. Conservative but
|
|
9
|
-
// robust enough for the test environment.
|
|
10
|
-
e.replace(/["'\\[\]]/g, "")
|
|
11
|
-
), s = `[data-error-anchor="${r}"], [name="${r}"], [name$="[${r}]"]`, i = Array.from(o.querySelectorAll(s));
|
|
12
|
-
return i.length === 0 ? null : i.find((c) => c.offsetParent !== null) ?? i[0];
|
|
13
|
-
}
|
|
14
|
-
function k(e, o, r = {}) {
|
|
15
|
-
const {
|
|
16
|
-
scope: s,
|
|
17
|
-
scrollOptions: i = { behavior: "smooth", block: "center" },
|
|
18
|
-
focus: u = !0,
|
|
19
|
-
skipInitialMount: c = !0
|
|
20
|
-
} = r, a = w(!1), d = w(null), l = o.find((f) => !!e[f]) ?? null;
|
|
21
|
-
C(() => {
|
|
22
|
-
if (c && !a.current) {
|
|
23
|
-
a.current = !0, d.current = l;
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
if (!l) {
|
|
27
|
-
d.current = null;
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
if (l === d.current || typeof window > "u") return;
|
|
31
|
-
const f = window.requestAnimationFrame(() => {
|
|
32
|
-
const m = b(s);
|
|
33
|
-
if (!m) return;
|
|
34
|
-
const g = A(l, m);
|
|
35
|
-
g && (g.scrollIntoView(i), u && g.focus({ preventScroll: !0 }), d.current = l);
|
|
36
|
-
});
|
|
37
|
-
return () => window.cancelAnimationFrame(f);
|
|
38
|
-
}, [l]);
|
|
39
|
-
}
|
|
40
|
-
function v(e, o = !1) {
|
|
41
|
-
const r = {};
|
|
42
|
-
for (const s of e)
|
|
43
|
-
r[s.id] = { signed: o ? !1 : !!s.signed };
|
|
44
|
-
return r;
|
|
45
|
-
}
|
|
46
|
-
function B(e) {
|
|
47
|
-
const [o, r] = y(
|
|
48
|
-
() => v(e)
|
|
49
|
-
), [s, i] = y(null), u = F(
|
|
50
|
-
() => e.map((n) => {
|
|
51
|
-
const t = o[n.id];
|
|
52
|
-
return {
|
|
53
|
-
...n,
|
|
54
|
-
signed: t ? t.signed : !!n.signed,
|
|
55
|
-
payload: t == null ? void 0 : t.payload
|
|
56
|
-
};
|
|
57
|
-
}),
|
|
58
|
-
[e, o]
|
|
59
|
-
), c = F(
|
|
60
|
-
() => u.reduce((n, t) => t.signed ? n + 1 : n, 0),
|
|
61
|
-
[u]
|
|
62
|
-
), a = u.length, d = a > 0 && c === a, l = S((n) => {
|
|
63
|
-
i(n);
|
|
64
|
-
}, []), f = S(() => {
|
|
65
|
-
i(null);
|
|
66
|
-
}, []), m = S((n, t) => {
|
|
67
|
-
r((p) => ({ ...p, [n]: { signed: !0, payload: t } })), i((p) => p === n ? null : p);
|
|
68
|
-
}, []), g = S(
|
|
69
|
-
(n) => {
|
|
70
|
-
var t;
|
|
71
|
-
return !!((t = o[n]) != null && t.signed);
|
|
72
|
-
},
|
|
73
|
-
[o]
|
|
74
|
-
), h = S(() => {
|
|
75
|
-
r(v(e, !0)), i(null);
|
|
76
|
-
}, [e]);
|
|
77
|
-
return F(
|
|
78
|
-
() => ({
|
|
79
|
-
fields: u,
|
|
80
|
-
signedCount: c,
|
|
81
|
-
total: a,
|
|
82
|
-
isComplete: d,
|
|
83
|
-
activeFieldId: s,
|
|
84
|
-
openField: l,
|
|
85
|
-
closeField: f,
|
|
86
|
-
markSigned: m,
|
|
87
|
-
isFieldSigned: g,
|
|
88
|
-
reset: h
|
|
89
|
-
}),
|
|
90
|
-
[
|
|
91
|
-
u,
|
|
92
|
-
c,
|
|
93
|
-
a,
|
|
94
|
-
d,
|
|
95
|
-
s,
|
|
96
|
-
l,
|
|
97
|
-
f,
|
|
98
|
-
m,
|
|
99
|
-
g,
|
|
100
|
-
h
|
|
101
|
-
]
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
export {
|
|
105
|
-
B as a,
|
|
106
|
-
k as u
|
|
107
|
-
};
|
|
108
|
-
//# sourceMappingURL=use-signing-session-C5evzYmo.js.map
|