@alfadocs/ui-kit 1.3.5 → 1.3.7

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.
@@ -1,403 +0,0 @@
1
- import { jsx as a, jsxs as r } from "react/jsx-runtime";
2
- import { forwardRef as pe, useRef as A, useState as S, useEffect as J } from "react";
3
- import { useTranslation as ve } from "react-i18next";
4
- import { D as m } from "./dialog-UbKJCi1X.js";
5
- import { B as k } from "./button-CPGiR_bH.js";
6
- import { I as ge } from "./icon-button-C_kbcd7I.js";
7
- import { C as K } from "./checkbox-BuZ1u__2.js";
8
- import { a as fe } from "./whatsapp-button-BIy6NaJK.js";
9
- import { S as Q } from "./select-BW5ecXlX.js";
10
- import { S as xe } from "./switch-OILsBLWo.js";
11
- import { A as y } from "./alert-CiJT540z.js";
12
- import { I as Re } from "./info-tip-Bxk3w6UM.js";
13
- import { S as be } from "./separator-CYU_bGFn.js";
14
- import { A as Y } from "./avatar-BNQNhoyL.js";
15
- import { c as ae } from "./createLucideIcon-DhHxpK9K.js";
16
- import { P as qe } from "./plus-DzMQ_c6b.js";
17
- import { X as Ne } from "./x-B5YnXwCz.js";
18
- import { P as we } from "./pen-line-D0De5zdl.js";
19
- import { M as Ce } from "./mail-BqXVF2zH.js";
20
- import { M as Ie } from "./message-square-Bye4ATvx.js";
21
- /**
22
- * @license lucide-react v1.22.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */
27
- const Se = [
28
- ["rect", { width: "16", height: "20", x: "4", y: "2", rx: "2", ry: "2", key: "76otgf" }],
29
- ["line", { x1: "12", x2: "12.01", y1: "18", y2: "18", key: "1dp563" }]
30
- ], ke = ae("tablet", Se);
31
- /**
32
- * @license lucide-react v1.22.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */
37
- const ye = [
38
- ["path", { d: "M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2", key: "1yyitq" }],
39
- ["circle", { cx: "9", cy: "7", r: "4", key: "nufk8" }],
40
- ["line", { x1: "19", x2: "19", y1: "8", y2: "14", key: "1bvyxn" }],
41
- ["line", { x1: "22", x2: "16", y1: "11", y2: "11", key: "1shjgl" }]
42
- ], ze = ae("user-plus", ye), v = "__assign-later__", Z = [
43
- "sms",
44
- "email",
45
- "whatsapp",
46
- "on-device"
47
- ];
48
- function ee(h, z) {
49
- var c;
50
- return ((c = h.find((o) => o.value === z)) == null ? void 0 : c.label) ?? "";
51
- }
52
- const Oe = pe(
53
- ({
54
- open: h,
55
- onOpenChange: z,
56
- operators: c,
57
- signerOptions: o,
58
- currentOperatorId: O,
59
- allowAssignLater: _ = !0,
60
- initialOperatorId: B,
61
- initialOperatorChannel: L,
62
- initialSigners: D,
63
- maxSigners: se = 2,
64
- busy: i = !1,
65
- error: j,
66
- title: ne,
67
- description: te,
68
- onRequestSignature: le,
69
- contentProps: re
70
- }, ie) => {
71
- const { t: n } = ve(), E = A(0), F = A(null), H = (e) => {
72
- var l;
73
- const s = (l = o.find(
74
- (d) => d.value === e
75
- )) == null ? void 0 : l.availableChannels;
76
- return s && s.length > 0 ? Z.filter((d) => s.includes(d)) : Z;
77
- }, M = (e, s) => {
78
- const l = H(e);
79
- return l.includes(s) ? s : l[0];
80
- }, U = () => {
81
- var e, s;
82
- return B === null ? _ ? v : ((e = c[0]) == null ? void 0 : e.value) ?? v : B ?? ((s = c[0]) == null ? void 0 : s.value) ?? (_ ? v : "");
83
- }, V = () => (D && D.length > 0 ? D : o.length > 0 ? [
84
- {
85
- signerId: o[0].value,
86
- channel: M(o[0].value, "on-device")
87
- }
88
- ] : []).map((s) => ({ ...s, rowId: E.current++ })), g = (e) => {
89
- var s;
90
- return ((s = c.find((l) => l.value === e)) == null ? void 0 : s.defaultChannel) ?? "email";
91
- }, W = (e, s) => L === "on-device" ? s.some((l) => l.channel === "on-device") ? "on-device" : g(e) : L ?? g(e), [p, T] = S(U), [u, b] = S(V), [q, f] = S(
92
- () => W(p, u)
93
- ), [G, x] = S(null), X = A(h);
94
- J(() => {
95
- if (h && !X.current) {
96
- const e = U(), s = V();
97
- T(e), b(s), f(W(e, s)), x(null);
98
- }
99
- X.current = h;
100
- }, [h]);
101
- const N = u.some(
102
- (e) => e.channel === "on-device"
103
- );
104
- J(() => {
105
- if (q === "on-device" && !N) {
106
- const e = g(p);
107
- f(e), x(e);
108
- }
109
- }, [q, N, p]);
110
- const de = _ ? [
111
- ...c,
112
- { value: v, label: n("signatureRequest.assignLater") }
113
- ] : c, w = p === v, R = {
114
- sms: {
115
- label: n("signatureRequest.viaSms"),
116
- icon: /* @__PURE__ */ a(Ie, { className: "ds:size-4", "aria-hidden": !0 })
117
- },
118
- email: {
119
- label: n("signatureRequest.viaEmail"),
120
- icon: /* @__PURE__ */ a(Ce, { className: "ds:size-4", "aria-hidden": !0 })
121
- },
122
- whatsapp: {
123
- label: n("signatureRequest.viaWhatsapp"),
124
- icon: /* @__PURE__ */ a(fe, { className: "ds:size-4", "aria-hidden": !0 })
125
- },
126
- "on-device": {
127
- label: n("signatureRequest.onThisDevice"),
128
- icon: /* @__PURE__ */ a(ke, { className: "ds:size-4", "aria-hidden": !0 })
129
- }
130
- }, ce = [
131
- { value: "sms", ...R.sms },
132
- { value: "email", ...R.email },
133
- {
134
- value: "on-device",
135
- ...R["on-device"],
136
- disabled: !N,
137
- hint: N ? void 0 : n("signatureRequest.onDeviceUnavailableHint")
138
- }
139
- ], $ = u.map((e) => e.signerId), C = o.find(
140
- (e) => !$.includes(e.value)
141
- ), oe = !i && u.length < se && C !== void 0, P = (e, s) => {
142
- b(
143
- (l) => l.map(
144
- (d) => d.rowId === e ? { ...d, ...s } : d
145
- )
146
- );
147
- }, ue = () => {
148
- C && b((e) => [
149
- ...e,
150
- {
151
- signerId: C.value,
152
- channel: M(C.value, "sms"),
153
- rowId: E.current++
154
- }
155
- ]);
156
- }, me = (e) => {
157
- var s;
158
- (s = F.current) == null || s.focus(), b(
159
- (l) => l.filter((d) => d.rowId !== e)
160
- );
161
- }, he = () => {
162
- le({
163
- operatorId: w ? null : p,
164
- operatorChannel: w ? null : q,
165
- signers: u.map(({ rowId: e, ...s }) => s)
166
- });
167
- };
168
- return /* @__PURE__ */ a("div", { ref: ie, className: "ds:contents", "data-component": "signature-request", children: /* @__PURE__ */ a(m, { open: h, onOpenChange: z, children: /* @__PURE__ */ r(m.Content, { size: "lg", hideCloseButton: !0, ...re, children: [
169
- /* @__PURE__ */ r(m.Header, { children: [
170
- /* @__PURE__ */ a(m.Title, { children: ne ?? n("signatureRequest.title") }),
171
- /* @__PURE__ */ a(m.Description, { children: te ?? n("signatureRequest.noSignedVersions") })
172
- ] }),
173
- /* @__PURE__ */ r(m.Body, { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
174
- /* @__PURE__ */ r("section", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
175
- /* @__PURE__ */ r("div", { className: "ds:flex ds:items-center ds:justify-between ds:gap-[var(--spacing-sm)]", children: [
176
- /* @__PURE__ */ a("p", { className: "type-eyebrow ds:text-start ds:text-[color:var(--muted-foreground)]", children: n("signatureRequest.operatorSection") }),
177
- O !== void 0 ? /* @__PURE__ */ a(
178
- k,
179
- {
180
- intent: "primary",
181
- size: "sm",
182
- startIcon: /* @__PURE__ */ a(ze, {}),
183
- disabled: i,
184
- onClick: () => {
185
- T(O), f(
186
- g(O)
187
- ), x(null);
188
- },
189
- children: n("signatureRequest.assignToMe")
190
- }
191
- ) : null
192
- ] }),
193
- /* @__PURE__ */ r("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-sm)]", children: [
194
- /* @__PURE__ */ a(
195
- Y,
196
- {
197
- "aria-hidden": "true",
198
- name: w ? void 0 : ee(c, p),
199
- size: "sm"
200
- }
201
- ),
202
- /* @__PURE__ */ a("div", { className: "ds:min-w-0 ds:flex-1 ds:text-start", children: /* @__PURE__ */ a(
203
- Q,
204
- {
205
- options: de,
206
- value: p,
207
- onValueChange: (e) => {
208
- e && (T(e), f(
209
- e === v ? "email" : g(e)
210
- ), x(null));
211
- },
212
- required: !0,
213
- disabled: i,
214
- placeholder: n("signatureRequest.operatorPlaceholder"),
215
- "aria-label": n("signatureRequest.operatorSection")
216
- }
217
- ) })
218
- ] }),
219
- w ? null : /* @__PURE__ */ a(
220
- "div",
221
- {
222
- role: "group",
223
- "aria-label": n("signatureRequest.operatorChannelLabel"),
224
- className: "ds:flex ds:flex-wrap ds:items-center ds:gap-x-[var(--spacing-lg)] ds:gap-y-[var(--spacing-sm)] ds:ps-[var(--spacing-xl)]",
225
- children: ce.map((e) => /* @__PURE__ */ r(
226
- "span",
227
- {
228
- className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-sm)]",
229
- children: [
230
- /* @__PURE__ */ a(
231
- K,
232
- {
233
- checked: q === e.value,
234
- disabled: i || e.disabled,
235
- onCheckedChange: (s) => {
236
- s === !0 && (f(e.value), x(null));
237
- },
238
- label: /* @__PURE__ */ r("span", { className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]", children: [
239
- /* @__PURE__ */ a(
240
- "span",
241
- {
242
- "aria-hidden": "true",
243
- className: "ds:text-[var(--accent)]",
244
- children: e.icon
245
- }
246
- ),
247
- e.label
248
- ] })
249
- }
250
- ),
251
- e.hint ? /* @__PURE__ */ a(Re, { size: "sm", content: e.hint }) : null
252
- ]
253
- },
254
- e.value
255
- ))
256
- }
257
- ),
258
- /* @__PURE__ */ a("span", { role: "status", className: "ds:sr-only", children: G ? n("signatureRequest.operatorChannelReverted", {
259
- channel: R[G].label
260
- }) : null })
261
- ] }),
262
- /* @__PURE__ */ a(be, { decorative: !0 }),
263
- /* @__PURE__ */ r("section", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)] ds:text-start", children: [
264
- /* @__PURE__ */ r("div", { className: "ds:flex ds:items-center ds:justify-between ds:gap-[var(--spacing-sm)]", children: [
265
- /* @__PURE__ */ a("p", { className: "type-eyebrow ds:text-[color:var(--muted-foreground)]", children: n("signatureRequest.signersSection") }),
266
- /* @__PURE__ */ a(
267
- k,
268
- {
269
- ref: F,
270
- intent: "primary",
271
- size: "sm",
272
- startIcon: /* @__PURE__ */ a(qe, {}),
273
- disabled: !oe,
274
- onClick: ue,
275
- children: n("signatureRequest.addSigner")
276
- }
277
- )
278
- ] }),
279
- u.map((e) => {
280
- const s = o.filter(
281
- (t) => t.value === e.signerId || !$.includes(t.value)
282
- ), l = ee(o, e.signerId), d = H(e.signerId).map(
283
- (t) => ({ value: t, ...R[t] })
284
- );
285
- return /* @__PURE__ */ r(
286
- "div",
287
- {
288
- role: "group",
289
- "aria-label": l,
290
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
291
- children: [
292
- /* @__PURE__ */ r("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-sm)]", children: [
293
- /* @__PURE__ */ a(Y, { "aria-hidden": "true", name: l, size: "sm" }),
294
- /* @__PURE__ */ a("div", { className: "ds:min-w-0 ds:flex-1", children: /* @__PURE__ */ a(
295
- Q,
296
- {
297
- options: s,
298
- value: e.signerId,
299
- onValueChange: (t) => {
300
- if (!t) return;
301
- const I = M(
302
- t,
303
- e.channel
304
- );
305
- P(e.rowId, {
306
- signerId: t,
307
- channel: I,
308
- skipOtp: I === "on-device" ? e.skipOtp : void 0
309
- });
310
- },
311
- required: !0,
312
- disabled: i,
313
- placeholder: n(
314
- "signatureRequest.signerPlaceholder"
315
- ),
316
- "aria-label": n("signatureRequest.signerPlaceholder")
317
- }
318
- ) }),
319
- u.length > 1 ? /* @__PURE__ */ a(
320
- ge,
321
- {
322
- intent: "ghost",
323
- size: "sm",
324
- icon: /* @__PURE__ */ a(Ne, {}),
325
- disabled: i,
326
- "aria-label": n("signatureRequest.removeSigner"),
327
- onClick: () => me(e.rowId)
328
- }
329
- ) : null
330
- ] }),
331
- /* @__PURE__ */ a(
332
- "div",
333
- {
334
- role: "group",
335
- "aria-label": n("signatureRequest.channelLabel"),
336
- className: "ds:flex ds:flex-wrap ds:items-center ds:gap-x-[var(--spacing-lg)] ds:gap-y-[var(--spacing-sm)] ds:ps-[var(--spacing-xl)]",
337
- children: d.map((t) => /* @__PURE__ */ a(
338
- K,
339
- {
340
- checked: e.channel === t.value,
341
- disabled: i,
342
- onCheckedChange: (I) => I === !0 && P(e.rowId, {
343
- channel: t.value,
344
- skipOtp: void 0
345
- }),
346
- label: /* @__PURE__ */ r("span", { className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]", children: [
347
- /* @__PURE__ */ a(
348
- "span",
349
- {
350
- "aria-hidden": "true",
351
- className: "ds:text-[var(--accent)]",
352
- children: t.icon
353
- }
354
- ),
355
- t.label
356
- ] })
357
- },
358
- t.value
359
- ))
360
- }
361
- ),
362
- e.channel === "on-device" ? /* @__PURE__ */ a("div", { className: "ds:ps-[var(--spacing-xl)]", children: /* @__PURE__ */ a(
363
- xe,
364
- {
365
- label: n("signatureRequest.noOtp"),
366
- checked: e.skipOtp === !0,
367
- disabled: i,
368
- onCheckedChange: (t) => P(e.rowId, { skipOtp: t })
369
- }
370
- ) }) : null
371
- ]
372
- },
373
- e.rowId
374
- );
375
- })
376
- ] }),
377
- u.some(
378
- (e) => e.channel === "on-device" && e.skipOtp === !0
379
- ) ? /* @__PURE__ */ a(y, { variant: "warning", children: /* @__PURE__ */ a(y.Description, { children: n("signatureRequest.noOtpWarning") }) }) : null,
380
- j ? /* @__PURE__ */ a(y, { variant: "error", children: /* @__PURE__ */ a(y.Description, { children: j }) }) : null
381
- ] }),
382
- /* @__PURE__ */ r(m.Footer, { children: [
383
- /* @__PURE__ */ a(
384
- k,
385
- {
386
- intent: "primary",
387
- startIcon: /* @__PURE__ */ a(we, {}),
388
- onClick: he,
389
- disabled: i || u.length === 0,
390
- loading: i,
391
- children: n("signatureRequest.requestSignature")
392
- }
393
- ),
394
- /* @__PURE__ */ a(m.Close, { asChild: !0, children: /* @__PURE__ */ a(k, { intent: "outline", disabled: i, children: n("signatureRequest.close") }) })
395
- ] })
396
- ] }) }) });
397
- }
398
- );
399
- Oe.displayName = "SignatureRequestModal";
400
- export {
401
- Oe as S
402
- };
403
- //# sourceMappingURL=signature-request-DZEFtbER.js.map