@incodetech/web 0.0.0-dev-20260309-4e885f1 → 0.0.0-dev-20260309-7c6c9b5

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.
@@ -3,7 +3,7 @@ import { SUPPORTED_COUNTRIES as I, DEV_ONLY_COUNTRIES as R, createEkybManager as
3
3
  import { T as w, y as v, A as L, k as A } from "./vendor-preact-DP-hbKuj.js";
4
4
  import "./uiConfig-B8PUPgHY.js";
5
5
  import "@incodetech/core";
6
- import { F as P, V as E, u as O } from "./verificationResult-BLkF37Z6.js";
6
+ import { F as P, V as E, u as O } from "./verificationResult-BUDATjlJ.js";
7
7
  import { P as T } from "./page-CcgnVEBJ.js";
8
8
  import { D as f, I as N } from "./dropdownComposed-BjDHcYMb.js";
9
9
  function B(e) {
@@ -0,0 +1,463 @@
1
+ import { u as t, b as O, I as H, a as U, S as j, B as Q, r as W } from "./incodeModule-DAveRAyZ.js";
2
+ import { createEkycManager as z } from "@incodetech/core/ekyc";
3
+ import { d as w, A as x, T as R, y as F, q as M } from "./vendor-preact-DP-hbKuj.js";
4
+ import "./uiConfig-B8PUPgHY.js";
5
+ import "@incodetech/core";
6
+ import { V as D, u as G, F as Y } from "./verificationResult-BUDATjlJ.js";
7
+ import { D as J } from "./dateInputComposed-BvBQiMdN.js";
8
+ import { I as B, D as K } from "./dropdownComposed-BjDHcYMb.js";
9
+ import { P as X } from "./page-CcgnVEBJ.js";
10
+ import { c as Z, g as L, p as V, A as T } from "./countries-DDCxQhGs.js";
11
+ import { u as ee } from "./useMediaQuery-Rn91JcLv.js";
12
+ const te = ({
13
+ id: f,
14
+ label: c,
15
+ countryCode: y = "US",
16
+ value: l,
17
+ placeholder: r = "(123) 123-6789",
18
+ error: I,
19
+ disabled: k = !1,
20
+ disableCountrySelector: S = !1,
21
+ required: $,
22
+ onChange: b,
23
+ "data-testid": N
24
+ }) => {
25
+ const [a, A] = w(y), [v, _] = w(""), E = x(!1), C = R(
26
+ () => Z.map((o) => ({
27
+ value: o.code,
28
+ label: `${o.emoji} ${o.callingCode} ${o.name}`
29
+ })),
30
+ []
31
+ ), i = R(
32
+ () => L(a) ?? L("US"),
33
+ [a]
34
+ );
35
+ F(() => {
36
+ if (E.current || !l || !i) return;
37
+ E.current = !0;
38
+ const o = l.startsWith("+") ? l : `+${l}`, s = V(o);
39
+ if (s?.isValid() && s.country) {
40
+ s.country !== a && A(s.country);
41
+ const g = new T(s.country);
42
+ _(g.input(s.nationalNumber));
43
+ }
44
+ }, [l, i, a]);
45
+ const e = M(
46
+ (o, s) => {
47
+ const g = `${s.callingCode}${o.replace(/\D/g, "")}`;
48
+ try {
49
+ const P = V(g, s.code);
50
+ b?.(g, P?.isValid() ?? !1);
51
+ } catch {
52
+ b?.(g, !1);
53
+ }
54
+ },
55
+ [b]
56
+ ), d = M(
57
+ (o) => {
58
+ A(o);
59
+ const s = L(o);
60
+ s && v && e(v, s);
61
+ },
62
+ [v, e]
63
+ ), h = M(
64
+ (o) => {
65
+ const s = o.target.value;
66
+ if (!i) {
67
+ _(s);
68
+ return;
69
+ }
70
+ const g = `${i.callingCode}${s}`, n = new T(i.code).input(g).replace(i.callingCode, "").trimStart();
71
+ _(n), e(s, i);
72
+ },
73
+ [i, e]
74
+ ), u = `${f}-country`, m = `${f}-phone`;
75
+ return /* @__PURE__ */ t(
76
+ K,
77
+ {
78
+ id: u,
79
+ label: c,
80
+ options: C,
81
+ value: a,
82
+ onChange: d,
83
+ error: I,
84
+ disabled: k || S,
85
+ required: $,
86
+ searchable: !0,
87
+ searchPlaceholder: "Search countries...",
88
+ renderSelectedLabel: (o) => {
89
+ const s = L(o.value);
90
+ return s ? `${s.emoji} ${s.callingCode}` : o.label;
91
+ },
92
+ class: "IncodePhoneInputComposed",
93
+ siblingElement: /* @__PURE__ */ t(
94
+ B,
95
+ {
96
+ id: m,
97
+ type: "tel",
98
+ value: v,
99
+ onInput: h,
100
+ placeholder: r,
101
+ error: I,
102
+ disabled: k,
103
+ suppressMessages: !0,
104
+ "aria-label": "Phone number",
105
+ "data-testid": N
106
+ }
107
+ )
108
+ }
109
+ );
110
+ }, oe = ({
111
+ label: f,
112
+ value: c,
113
+ error: y,
114
+ suggestions: l,
115
+ readonly: r,
116
+ optional: I,
117
+ onChange: k,
118
+ onSearch: S,
119
+ onSelect: $
120
+ }) => {
121
+ const { t: b } = O(), [N, a] = w(!1), [A, v] = w(!1), [_, E] = w(""), [C, i] = w(-1), e = x(null), d = "ekyc-address-listbox", h = ee(), u = b(f), m = I ? `${u} (${b("common.optional")})` : u;
122
+ F(() => {
123
+ function n(p) {
124
+ e.current && !e.current.contains(p.target) && a(!1);
125
+ }
126
+ return document.addEventListener("mousedown", n), () => document.removeEventListener("mousedown", n);
127
+ }, []), F(() => {
128
+ i(-1);
129
+ }, [l]);
130
+ const o = M(
131
+ (n) => {
132
+ $(n), a(!1), v(!1), i(-1);
133
+ },
134
+ [$]
135
+ ), s = (n) => {
136
+ k(n), n.length >= 3 ? h ? (v(!0), E(n)) : (S(n), a(!0)) : a(!1);
137
+ }, g = (n) => {
138
+ !N || l.length === 0 || (n.key === "ArrowDown" ? (n.preventDefault(), i((p) => p < l.length - 1 ? p + 1 : 0)) : n.key === "ArrowUp" ? (n.preventDefault(), i((p) => p > 0 ? p - 1 : l.length - 1)) : n.key === "Enter" && C >= 0 ? (n.preventDefault(), o(l[C])) : n.key === "Escape" && (a(!1), i(-1)));
139
+ }, P = !h && N && l.length > 0, q = P && C >= 0 ? `${d}-option-${C}` : void 0;
140
+ return /* @__PURE__ */ t("div", { className: "IncodeAddressAutocomplete", ref: e, children: [
141
+ /* @__PURE__ */ t(
142
+ B,
143
+ {
144
+ id: "ekyc-street",
145
+ label: m,
146
+ name: "street",
147
+ value: c,
148
+ readOnly: r,
149
+ error: y ? b(y) : void 0,
150
+ onInput: (n) => s(n.target.value),
151
+ onKeyDown: g,
152
+ role: "combobox",
153
+ "aria-expanded": P,
154
+ "aria-controls": d,
155
+ "aria-activedescendant": q,
156
+ "aria-autocomplete": "list",
157
+ "data-testid": "ekyc-address-input"
158
+ }
159
+ ),
160
+ P && /* @__PURE__ */ t(
161
+ "ul",
162
+ {
163
+ id: d,
164
+ role: "listbox",
165
+ className: "IncodeAddressAutocomplete__suggestions",
166
+ children: l.map((n, p) => /* @__PURE__ */ t(
167
+ "li",
168
+ {
169
+ id: `${d}-option-${p}`,
170
+ role: "option",
171
+ "aria-selected": p === C,
172
+ className: `IncodeAddressAutocomplete__suggestion${p === C ? "IncodeAddressAutocomplete__suggestion--active" : ""}`,
173
+ onClick: () => o(n),
174
+ children: n.label
175
+ },
176
+ n.id
177
+ ))
178
+ }
179
+ ),
180
+ h && A && /* @__PURE__ */ t("div", { className: "IncodeAddressAutocomplete__modalOverlay", children: /* @__PURE__ */ t("div", { className: "IncodeAddressAutocomplete__modal", children: [
181
+ /* @__PURE__ */ t("div", { className: "IncodeAddressAutocomplete__modalHeader", children: [
182
+ /* @__PURE__ */ t("h3", { children: b("verification.addressSearch") }),
183
+ /* @__PURE__ */ t(
184
+ "button",
185
+ {
186
+ className: "IncodeAddressAutocomplete__modalClose",
187
+ onClick: () => v(!1),
188
+ type: "button",
189
+ children: "×"
190
+ }
191
+ )
192
+ ] }),
193
+ /* @__PURE__ */ t("div", { className: "IncodeAddressAutocomplete__modalBody", children: [
194
+ /* @__PURE__ */ t(
195
+ "input",
196
+ {
197
+ className: "IncodeAddressAutocomplete__modalInput",
198
+ type: "text",
199
+ value: _,
200
+ placeholder: b("verification.addressPlaceholder"),
201
+ onInput: (n) => {
202
+ const p = n.target.value;
203
+ E(p), p.length >= 3 && S(p);
204
+ },
205
+ autoFocus: !0
206
+ }
207
+ ),
208
+ l.length > 0 && /* @__PURE__ */ t(
209
+ "ul",
210
+ {
211
+ role: "listbox",
212
+ className: "IncodeAddressAutocomplete__modalSuggestions",
213
+ children: l.map((n) => /* @__PURE__ */ t(
214
+ "li",
215
+ {
216
+ role: "option",
217
+ className: "IncodeAddressAutocomplete__modalSuggestion",
218
+ onClick: () => o(n),
219
+ children: n.label
220
+ },
221
+ n.id
222
+ ))
223
+ }
224
+ ),
225
+ /* @__PURE__ */ t(
226
+ "button",
227
+ {
228
+ className: "IncodeAddressAutocomplete__enterManually",
229
+ onClick: () => v(!1),
230
+ type: "button",
231
+ children: b("verification.enterManually")
232
+ }
233
+ )
234
+ ] })
235
+ ] }) })
236
+ ] });
237
+ }, se = ({ config: f, onFinish: c, onError: y }) => {
238
+ const { t: l } = O(), [r, I] = U(() => z({ config: f }));
239
+ F(() => {
240
+ (r.status === "finished" || r.status === "closed") && c?.();
241
+ }, [r.status, c]);
242
+ const k = r.status === "error" ? r.errorMessage : void 0;
243
+ return F(() => {
244
+ r.status === "error" && y?.(k);
245
+ }, [r.status, y, k]), r.status === "finished" || r.status === "closed" ? null : r.status === "loading" ? /* @__PURE__ */ t(
246
+ D,
247
+ {
248
+ status: "submitting",
249
+ submittingTitle: l("common.loading")
250
+ }
251
+ ) : r.status === "submitting" ? /* @__PURE__ */ t(D, { status: "submitting" }) : r.status === "success" ? /* @__PURE__ */ t(D, { status: "success" }) : r.status === "error" ? /* @__PURE__ */ t(
252
+ D,
253
+ {
254
+ status: "failure",
255
+ onRetry: () => I.retry(),
256
+ onSkip: () => I.skip()
257
+ }
258
+ ) : r.status === "misconfigured" ? /* @__PURE__ */ t(
259
+ D,
260
+ {
261
+ status: "failure",
262
+ failureTitle: l("verification.noFormFields"),
263
+ onSkip: () => I.close(),
264
+ skipLabel: l("common.close")
265
+ }
266
+ ) : r.status === "form" ? /* @__PURE__ */ t(ne, { state: r, manager: I }) : null;
267
+ }, ne = ({ state: f, manager: c }) => {
268
+ const {
269
+ fields: y,
270
+ values: l,
271
+ displayErrors: r,
272
+ errorParams: I,
273
+ isValid: k,
274
+ addressSuggestions: S,
275
+ prefilled: $,
276
+ hideEmail: b,
277
+ fieldsCountry: N
278
+ } = f, { t: a } = O(), A = x(null), v = x(null), _ = x(void 0), E = G(A, y.length);
279
+ F(() => {
280
+ const e = r.postalCode, d = _.current;
281
+ if (_.current = e, !e || d === e)
282
+ return;
283
+ const h = requestAnimationFrame(() => {
284
+ const u = v.current;
285
+ if (!u) return;
286
+ (u.querySelector("#postalCode-error") ?? u).scrollIntoView({
287
+ behavior: "smooth",
288
+ block: "nearest"
289
+ });
290
+ });
291
+ return () => cancelAnimationFrame(h);
292
+ }, [r.postalCode]);
293
+ let C;
294
+ return /* @__PURE__ */ t(X, { className: `IncodeEkycPage${E ? " IncodeEkycPage--scrollable" : ""}`, title: a("verification.title"), children: [
295
+ /* @__PURE__ */ t("div", { ref: A, className: "IncodeEkyc__form", children: y.map((e) => {
296
+ if (e.name === "email" && b) return null;
297
+ let d = null;
298
+ e.section && e.section !== C && (C = e.section, d = /* @__PURE__ */ t("h3", { className: "IncodeEkyc__sectionHeader", children: a({
299
+ address: "verification.labels.addressDetailsSection",
300
+ driverLicense: "verification.labels.dlDetailsSection"
301
+ }[e.section] ?? e.section) }));
302
+ const h = e.readonly || $[e.name], u = l[e.name] ?? "", m = r[e.name];
303
+ if (e.name === "street" && e.section === "address")
304
+ return /* @__PURE__ */ t("div", { children: [
305
+ d,
306
+ /* @__PURE__ */ t(
307
+ oe,
308
+ {
309
+ label: e.label,
310
+ value: u,
311
+ error: m,
312
+ suggestions: S,
313
+ readonly: h,
314
+ onChange: (o) => c.setField("street", o),
315
+ onSearch: (o) => c.searchAddress(o),
316
+ onSelect: (o) => c.selectAddress(o)
317
+ }
318
+ )
319
+ ] }, e.name);
320
+ if (e.type === "dropdown") {
321
+ const o = a(e.label);
322
+ return /* @__PURE__ */ t("div", { children: [
323
+ d,
324
+ /* @__PURE__ */ t(
325
+ K,
326
+ {
327
+ id: `ekyc-${e.name}`,
328
+ label: o,
329
+ placeholder: e.placeholder ? a(e.placeholder) : void 0,
330
+ value: u,
331
+ options: (e.options ?? []).map((s) => ({
332
+ ...s,
333
+ label: a(s.label)
334
+ })),
335
+ error: m ? a(m) : void 0,
336
+ disabled: h,
337
+ searchable: !0,
338
+ onChange: (s) => c.setField(e.name, s),
339
+ "data-testid": `ekyc-field-${e.name}`
340
+ }
341
+ )
342
+ ] }, e.name);
343
+ }
344
+ if (e.type === "date") {
345
+ const o = a(e.label);
346
+ return /* @__PURE__ */ t("div", { children: [
347
+ d,
348
+ /* @__PURE__ */ t(
349
+ J,
350
+ {
351
+ id: `ekyc-${e.name}`,
352
+ label: o,
353
+ value: u,
354
+ error: m ? a(m) : void 0,
355
+ disabled: h,
356
+ onInput: (s) => {
357
+ const g = s.target;
358
+ c.setField(e.name, g.value);
359
+ },
360
+ "data-testid": `ekyc-field-${e.name}`
361
+ }
362
+ )
363
+ ] }, e.name);
364
+ }
365
+ if (e.type === "phone") {
366
+ const o = a(e.label);
367
+ return /* @__PURE__ */ t("div", { children: [
368
+ d,
369
+ /* @__PURE__ */ t(
370
+ te,
371
+ {
372
+ id: `ekyc-${e.name}`,
373
+ label: o,
374
+ countryCode: N,
375
+ value: u,
376
+ placeholder: e.placeholder,
377
+ error: m ? a(m) : void 0,
378
+ disabled: h,
379
+ disableCountrySelector: e.disableCountrySelector,
380
+ required: e.required,
381
+ onChange: (s) => c.setField(e.name, s),
382
+ "data-testid": `ekyc-field-${e.name}`
383
+ }
384
+ )
385
+ ] }, e.name);
386
+ }
387
+ return e.type === "radio" ? /* @__PURE__ */ t("div", { children: [
388
+ d,
389
+ /* @__PURE__ */ t("div", { className: "IncodeEkyc__radioGroup", children: [
390
+ /* @__PURE__ */ t("label", { className: "IncodeEkyc__radioLabel", children: a(e.label) }),
391
+ /* @__PURE__ */ t("div", { className: "IncodeEkyc__radioOptions", children: e.options?.map((o) => /* @__PURE__ */ t(
392
+ "label",
393
+ {
394
+ className: "IncodeEkyc__radioOption",
395
+ children: [
396
+ /* @__PURE__ */ t(
397
+ "input",
398
+ {
399
+ type: "radio",
400
+ name: e.name,
401
+ value: o.value,
402
+ checked: u === o.value,
403
+ onChange: () => c.setField(e.name, o.value),
404
+ disabled: h
405
+ }
406
+ ),
407
+ /* @__PURE__ */ t("span", { children: a(o.label) })
408
+ ]
409
+ },
410
+ o.value
411
+ )) }),
412
+ m && /* @__PURE__ */ t("span", { className: "IncodeEkyc__fieldError", children: a(m) })
413
+ ] })
414
+ ] }, e.name) : /* @__PURE__ */ t(
415
+ "div",
416
+ {
417
+ ref: e.name === "postalCode" ? v : void 0,
418
+ children: [
419
+ d,
420
+ /* @__PURE__ */ t(
421
+ Y,
422
+ {
423
+ name: e.name,
424
+ label: e.label,
425
+ value: u,
426
+ error: m,
427
+ errorParams: I[e.name],
428
+ type: e.type,
429
+ placeholder: e.placeholder,
430
+ placeholderParams: e.placeholderParams,
431
+ required: e.required,
432
+ readonly: h,
433
+ maxLength: e.maxLength,
434
+ onChange: (o, s) => c.setField(o, s)
435
+ }
436
+ )
437
+ ]
438
+ },
439
+ e.name
440
+ );
441
+ }) }),
442
+ /* @__PURE__ */ t("div", { className: "IncodeEkyc__footer", children: [
443
+ /* @__PURE__ */ t(j, { size: 32 }),
444
+ /* @__PURE__ */ t(
445
+ Q,
446
+ {
447
+ onClick: () => c.submit(),
448
+ disabled: !k,
449
+ "data-testid": "ekyc-submit",
450
+ children: a("common.continue")
451
+ }
452
+ )
453
+ ] })
454
+ ] });
455
+ }, ae = ({
456
+ config: f,
457
+ onFinish: c,
458
+ onError: y
459
+ }) => /* @__PURE__ */ t(H, { children: f ? /* @__PURE__ */ t(se, { config: f, onFinish: c, onError: y }) : null });
460
+ W(ae, "incode-ekyc");
461
+ export {
462
+ ae as EkycModule
463
+ };