@incodetech/web 0.0.0-dev-20260317-6ffceac → 0.0.0-dev-20260317-737b25e

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,11 +1,11 @@
1
- import { d, y as M, A as H, q as F } from "./vendor-preact-BXf0bkEs.js";
2
- import { b as K, u as l } from "./button-Ca1tRSTI.js";
1
+ import { d, y as M, A as F, q as K } from "./vendor-preact-BXf0bkEs.js";
2
+ import { b as Q, u as l } from "./button-Ca1tRSTI.js";
3
3
  import "./uiConfig-Z6RT23Sl.js";
4
- import { t as Q } from "./formField-UWsp-7Fj.js";
5
- import { I as R } from "./inputComposed-BHi-MSpP.js";
4
+ import { t as R } from "./formField-FeX9N4c8.js";
5
+ import { I as q } from "./inputComposed-BHi-MSpP.js";
6
6
  import "@incodetech/core";
7
- import { u as q } from "./useMediaQuery-CiSMgDyi.js";
8
- function G(c, f) {
7
+ import { u as z } from "./useMediaQuery-CiSMgDyi.js";
8
+ function J(c, f) {
9
9
  const [A, h] = d(!1);
10
10
  return M(() => {
11
11
  const o = c.current;
@@ -16,7 +16,7 @@ function G(c, f) {
16
16
  return u.observe(o), () => u.disconnect();
17
17
  }, [f, c]), A;
18
18
  }
19
- const J = ({
19
+ const V = ({
20
20
  label: c,
21
21
  value: f,
22
22
  error: A,
@@ -26,9 +26,10 @@ const J = ({
26
26
  optional: u,
27
27
  onChange: w,
28
28
  onSearch: k,
29
- onSelect: N
29
+ onSelect: N,
30
+ onBlur: D
30
31
  }) => {
31
- const { t: n } = K(), [x, a] = d(!1), [D, m] = d(!1), [C, S] = d(""), [s, r] = d(-1), v = H(null), p = "ekyc-address-listbox", I = q(), g = n(c), E = u ? `${g} (${n("common.optional")})` : g;
32
+ const { t: n } = Q(), [x, a] = d(!1), [C, m] = d(!1), [E, S] = d(""), [s, r] = d(-1), v = F(null), p = "ekyc-address-listbox", I = z(), g = n(c), $ = u ? `${g} (${n("common.optional")})` : g;
32
33
  M(() => {
33
34
  function e(t) {
34
35
  v.current && !v.current.contains(t.target) && a(!1);
@@ -37,32 +38,33 @@ const J = ({
37
38
  }, []), M(() => {
38
39
  r(-1);
39
40
  }, [o]);
40
- const b = F(
41
+ const b = K(
41
42
  (e) => {
42
43
  N(e), a(!1), m(!1), r(-1);
43
44
  },
44
45
  [N]
45
- ), $ = (e) => {
46
+ ), O = (e) => {
46
47
  w(e), e.length >= 3 ? I ? (m(!0), S(e)) : (k(e), a(!0)) : a(!1);
47
- }, O = (e) => {
48
+ }, L = (e) => {
48
49
  !x || o.length === 0 || (e.key === "ArrowDown" ? (e.preventDefault(), r((t) => t < o.length - 1 ? t + 1 : 0)) : e.key === "ArrowUp" ? (e.preventDefault(), r((t) => t > 0 ? t - 1 : o.length - 1)) : e.key === "Enter" && s >= 0 ? (e.preventDefault(), b(o[s])) : e.key === "Escape" && (a(!1), r(-1)));
49
- }, y = !I && x && o.length > 0, L = y && s >= 0 ? `${p}-option-${s}` : void 0;
50
+ }, y = !I && x && o.length > 0, H = y && s >= 0 ? `${p}-option-${s}` : void 0;
50
51
  return /* @__PURE__ */ l("div", { className: "IncodeAddressAutocomplete", ref: v, children: [
51
52
  /* @__PURE__ */ l(
52
- R,
53
+ q,
53
54
  {
54
55
  id: "ekyc-street",
55
- label: E,
56
+ label: $,
56
57
  name: "street",
57
58
  value: f,
58
59
  readOnly: i,
59
- error: Q(n, A, h),
60
- onInput: (e) => $(e.target.value),
61
- onKeyDown: O,
60
+ error: R(n, A, h),
61
+ onInput: (e) => O(e.target.value),
62
+ onKeyDown: L,
63
+ onBlur: D,
62
64
  role: "combobox",
63
65
  "aria-expanded": y,
64
66
  "aria-controls": p,
65
- "aria-activedescendant": L,
67
+ "aria-activedescendant": H,
66
68
  "aria-autocomplete": "list",
67
69
  "data-testid": "ekyc-address-input"
68
70
  }
@@ -87,7 +89,7 @@ const J = ({
87
89
  ))
88
90
  }
89
91
  ),
90
- I && D && /* @__PURE__ */ l("div", { className: "IncodeAddressAutocompleteModalOverlay", children: /* @__PURE__ */ l("div", { className: "IncodeAddressAutocompleteModal", children: [
92
+ I && C && /* @__PURE__ */ l("div", { className: "IncodeAddressAutocompleteModalOverlay", children: /* @__PURE__ */ l("div", { className: "IncodeAddressAutocompleteModal", children: [
91
93
  /* @__PURE__ */ l("div", { className: "IncodeAddressAutocompleteModalHeader", children: [
92
94
  /* @__PURE__ */ l("h3", { children: n("verification.addressSearch") }),
93
95
  /* @__PURE__ */ l(
@@ -106,7 +108,7 @@ const J = ({
106
108
  {
107
109
  className: "IncodeAddressAutocompleteModalInput",
108
110
  type: "text",
109
- value: C,
111
+ value: E,
110
112
  placeholder: n("verification.addressPlaceholder"),
111
113
  onInput: (e) => {
112
114
  const t = e.target.value;
@@ -146,6 +148,6 @@ const J = ({
146
148
  ] });
147
149
  };
148
150
  export {
149
- J as A,
150
- G as u
151
+ V as A,
152
+ J as u
151
153
  };
@@ -33,6 +33,10 @@
33
33
  margin-inline: auto;
34
34
  }
35
35
 
36
+ .IncodeEkybFooter {
37
+ margin-top: var(--spacing-24, var(--spacing-24, 24px));
38
+ }
39
+
36
40
  @media (min-width: 768px) {
37
41
  .IncodePageContainer.IncodeEkybPage {
38
42
  margin-top: var(--spacing-0, var(--spacing-none, 0px));
@@ -55,7 +59,6 @@
55
59
  .IncodeEkybPage .IncodeEkybForm {
56
60
  min-height: var(--spacing-0, var(--spacing-none, 0px));
57
61
  padding-bottom: var(--spacing-8, var(--spacing-8, 8px));
58
- flex: 1;
59
62
  overflow-y: auto;
60
63
  }
61
64
 
@@ -0,0 +1,348 @@
1
+ import { b as v, u as o, I as X, a as J, B as Q } from "./button-Ca1tRSTI.js";
2
+ import { SUPPORTED_COUNTRIES as M, DEV_ONLY_COUNTRIES as Z, computeEkybDisplayErrors as x, createEkybManager as ee } from "@incodetech/core/ekyb";
3
+ import { T as q, y as V, A as P, d as te, q as S, k as oe } from "./vendor-preact-BXf0bkEs.js";
4
+ import "./uiConfig-Z6RT23Sl.js";
5
+ import "@incodetech/core";
6
+ import { u as re, A as se } from "./addressAutocomplete-DetZGxBZ.js";
7
+ import { P as ne } from "./page-BVHG3h0V.js";
8
+ import { t as K, F as ae, V as A } from "./formField-FeX9N4c8.js";
9
+ import { r as ue } from "./incodeModule-aE-LkKwM.js";
10
+ import { D as G } from "./dropdownComposed-B5ZuQS8C.js";
11
+ import { I as _ } from "./inputComposed-BHi-MSpP.js";
12
+ function ce(t) {
13
+ return [...t.toUpperCase()].map((r) => String.fromCodePoint(127462 + r.charCodeAt(0) - 65)).join("");
14
+ }
15
+ const le = {
16
+ BR: "Brazil",
17
+ CM: "Cameroon",
18
+ CN: "China",
19
+ FR: "France",
20
+ DE: "Germany",
21
+ IL: "Israel",
22
+ IT: "Italy",
23
+ KE: "Kenya",
24
+ MX: "Mexico",
25
+ NG: "Nigeria",
26
+ ES: "Spain",
27
+ GB: "United Kingdom",
28
+ US: "USA"
29
+ };
30
+ function ie(t) {
31
+ const r = le[t] ?? t;
32
+ return { value: t, label: `${ce(t)} ${r}` };
33
+ }
34
+ function me() {
35
+ if (typeof window > "u") return !1;
36
+ const { hostname: t } = window.location;
37
+ return t === "localhost" || t.includes("stage") || t.includes("demo");
38
+ }
39
+ const de = ({
40
+ value: t,
41
+ onChange: r
42
+ }) => {
43
+ const { t: u } = v(), s = q(() => (me() ? [...M, ...Z] : [...M]).map(ie).sort((c, d) => c.label.localeCompare(d.label)), []);
44
+ return /* @__PURE__ */ o("div", { className: "IncodeEkybCountrySelector", children: /* @__PURE__ */ o(
45
+ G,
46
+ {
47
+ id: "ekyb-country",
48
+ label: u("ekyb.country"),
49
+ value: t,
50
+ options: s,
51
+ onChange: r,
52
+ "data-testid": "ekyb-country-selector"
53
+ }
54
+ ) });
55
+ }, B = ({
56
+ field: t,
57
+ value: r,
58
+ error: u,
59
+ errorParams: s,
60
+ country: i,
61
+ onChange: c,
62
+ onBlur: d
63
+ }) => {
64
+ const { t: b } = v(), l = !t.required, h = b(t.label);
65
+ if (t.type === "dropdown") {
66
+ const m = l ? `${h} (${b("common.optional")})` : h, n = t.name === "state" ? b("ekyb.selectState") : void 0;
67
+ return /* @__PURE__ */ o(
68
+ G,
69
+ {
70
+ id: `ekyb-${t.name}`,
71
+ label: m,
72
+ placeholder: n,
73
+ value: r,
74
+ options: (t.options ?? []).map((p) => ({
75
+ ...p,
76
+ label: b(p.label)
77
+ })),
78
+ error: K(b, u, s),
79
+ searchable: !0,
80
+ onChange: (p) => c(t.name, p),
81
+ onBlur: d ? () => d(t.name) : void 0,
82
+ "data-testid": `ekyb-field-${t.name}`
83
+ }
84
+ );
85
+ }
86
+ return /* @__PURE__ */ o(
87
+ ae,
88
+ {
89
+ name: t.name,
90
+ label: t.label,
91
+ value: r,
92
+ error: u,
93
+ errorParams: s,
94
+ required: t.required,
95
+ optional: l,
96
+ onChange: c,
97
+ onBlur: d
98
+ }
99
+ );
100
+ }, be = ({
101
+ ubos: t,
102
+ errors: r,
103
+ errorParams: u,
104
+ canAddUbo: s,
105
+ onSetField: i,
106
+ onBlur: c,
107
+ onAdd: d,
108
+ onRemove: b
109
+ }) => {
110
+ const { t: l } = v(), h = (m) => K(l, r[m], u[m]);
111
+ return t.length === 0 ? null : /* @__PURE__ */ o("div", { className: "IncodeEkybUbos", children: [
112
+ t.map((m, n) => {
113
+ const p = n === 0 ? l("ekyb.uboName") : l("ekyb.uboNameWithNumber", { number: n + 1 }), f = n === 0 ? l("ekyb.uboSurname") : l("ekyb.uboSurnameWithNumber", { number: n + 1 }), N = n === 0;
114
+ return /* @__PURE__ */ o("div", { className: "IncodeEkybUboEntry", children: [
115
+ /* @__PURE__ */ o(
116
+ _,
117
+ {
118
+ id: `ubo-${n}-name`,
119
+ label: p,
120
+ name: `ubo-${n}-name`,
121
+ value: m.name,
122
+ error: h(`ubo-${n}-name`),
123
+ onInput: (I) => i(n, "name", I.target.value),
124
+ onBlur: c ? () => c(`ubo-${n}-name`) : void 0,
125
+ "data-testid": `ekyb-ubo-${n}-name`
126
+ }
127
+ ),
128
+ /* @__PURE__ */ o(
129
+ _,
130
+ {
131
+ id: `ubo-${n}-surname`,
132
+ label: f,
133
+ name: `ubo-${n}-surname`,
134
+ value: m.surname,
135
+ error: h(`ubo-${n}-surname`),
136
+ onInput: (I) => i(
137
+ n,
138
+ "surname",
139
+ I.target.value
140
+ ),
141
+ onBlur: c ? () => c(`ubo-${n}-surname`) : void 0,
142
+ "data-testid": `ekyb-ubo-${n}-surname`
143
+ }
144
+ ),
145
+ !N && /* @__PURE__ */ o(
146
+ "button",
147
+ {
148
+ className: "IncodeEkybRemoveUbo",
149
+ onClick: () => b(n),
150
+ type: "button",
151
+ children: l("common.remove")
152
+ }
153
+ )
154
+ ] }, m.id);
155
+ }),
156
+ s && /* @__PURE__ */ o(
157
+ "button",
158
+ {
159
+ className: "IncodeEkybAddUbo",
160
+ onClick: d,
161
+ type: "button",
162
+ "data-testid": "ekyb-add-ubo",
163
+ children: l("ekyb.addAnotherUbo")
164
+ }
165
+ )
166
+ ] });
167
+ }, pe = ({ config: t, onFinish: r }) => {
168
+ const { t: u } = v(), [s, i] = J(() => ee({ config: t }));
169
+ return V(() => {
170
+ (s.status === "finished" || s.status === "closed") && r?.();
171
+ }, [s.status, r]), s.status === "finished" || s.status === "closed" ? null : s.status === "loading" ? /* @__PURE__ */ o(
172
+ A,
173
+ {
174
+ status: "submitting",
175
+ submittingTitle: u("common.loading")
176
+ }
177
+ ) : s.status === "submitting" ? /* @__PURE__ */ o(A, { status: "submitting" }) : s.status === "success" ? /* @__PURE__ */ o(A, { status: "success" }) : s.status === "error" ? /* @__PURE__ */ o(A, { status: "failure", onRetry: () => i.retry() }) : s.status === "form" ? /* @__PURE__ */ o(he, { state: s, manager: i }) : null;
178
+ }, O = /* @__PURE__ */ new Set([
179
+ "street",
180
+ "houseNo",
181
+ "addressLine2",
182
+ "city",
183
+ "state",
184
+ "postalCode"
185
+ ]), ye = ["street", "city", "state", "postalCode", "houseNo"], he = ({ state: t, manager: r }) => {
186
+ const {
187
+ country: u,
188
+ fields: s,
189
+ values: i,
190
+ errors: c,
191
+ isValid: d,
192
+ ubos: b,
193
+ canAddUbo: l,
194
+ addressSuggestions: h,
195
+ submitAttempted: m
196
+ } = t, { t: n } = v(), p = P(null), f = P(null), N = P(void 0), I = re(p, s.length), [w, T] = te({}), y = S((e) => {
197
+ T((a) => a[e] ? a : { ...a, [e]: !0 });
198
+ }, []), { displayErrors: E, errorParams: F } = q(
199
+ () => x(
200
+ c,
201
+ w,
202
+ m,
203
+ u,
204
+ s
205
+ ),
206
+ [c, w, m, u, s]
207
+ ), $ = S(
208
+ (e) => y(e),
209
+ [y]
210
+ ), U = S(
211
+ (e, a) => {
212
+ y(e), r.setField(e, a);
213
+ },
214
+ [r, y]
215
+ ), Y = S(
216
+ (e, a, k) => {
217
+ y(`ubo-${e}-${a}`), r.setUboField(e, a, k);
218
+ },
219
+ [r, y]
220
+ ), j = S(
221
+ (e) => {
222
+ for (const a of ye) y(a);
223
+ r.selectAddress(e);
224
+ },
225
+ [r, y]
226
+ ), W = S(
227
+ (e) => {
228
+ r.removeUbo(e), T((a) => {
229
+ const k = {};
230
+ for (const [C, R] of Object.entries(a)) {
231
+ const D = C.match(/^ubo-(\d+)-(name|surname)$/);
232
+ if (!D) {
233
+ k[C] = R;
234
+ continue;
235
+ }
236
+ const g = Number(D[1]);
237
+ if (g === e) continue;
238
+ const H = g > e ? g - 1 : g;
239
+ k[`ubo-${H}-${D[2]}`] = R;
240
+ }
241
+ return k;
242
+ });
243
+ },
244
+ [r]
245
+ );
246
+ V(() => {
247
+ const e = E.postalCode, a = N.current;
248
+ if (N.current = e, !e || a === e)
249
+ return;
250
+ const k = requestAnimationFrame(() => {
251
+ const C = f.current;
252
+ if (!C) return;
253
+ (C.querySelector("#postalCode-error") ?? C).scrollIntoView({
254
+ behavior: "smooth",
255
+ block: "nearest"
256
+ });
257
+ });
258
+ return () => cancelAnimationFrame(k);
259
+ }, [E.postalCode]);
260
+ const z = s.filter((e) => !O.has(e.name)), L = s.filter((e) => O.has(e.name));
261
+ return /* @__PURE__ */ o(ne, { className: `IncodeEkybPage${I ? " IncodeEkybPageScrollable" : ""}`, title: n("ekyb.title"), children: [
262
+ /* @__PURE__ */ o("div", { ref: p, className: "IncodeEkybForm", children: [
263
+ /* @__PURE__ */ o(
264
+ de,
265
+ {
266
+ value: u,
267
+ onChange: (e) => r.setCountry(e)
268
+ }
269
+ ),
270
+ z.map((e) => /* @__PURE__ */ o(
271
+ B,
272
+ {
273
+ field: e,
274
+ value: i[e.name] ?? "",
275
+ error: E[e.name],
276
+ errorParams: F[e.name],
277
+ country: u,
278
+ onChange: U,
279
+ onBlur: $
280
+ },
281
+ e.name
282
+ )),
283
+ /* @__PURE__ */ o(
284
+ be,
285
+ {
286
+ ubos: b,
287
+ errors: E,
288
+ errorParams: F,
289
+ canAddUbo: l,
290
+ onSetField: Y,
291
+ onBlur: $,
292
+ onAdd: () => r.addUbo(),
293
+ onRemove: W
294
+ }
295
+ ),
296
+ L.length > 0 && /* @__PURE__ */ o(oe, { children: [
297
+ /* @__PURE__ */ o("h3", { className: "IncodeEkybSectionHeader", children: n("ekyb.addressDetails") }),
298
+ L.map((e) => e.name === "street" ? /* @__PURE__ */ o(
299
+ se,
300
+ {
301
+ label: e.label,
302
+ value: i.street ?? "",
303
+ error: E.street,
304
+ errorParams: F.street,
305
+ suggestions: h,
306
+ optional: !e.required,
307
+ onChange: (a) => U("street", a),
308
+ onSearch: (a) => r.searchAddress(a),
309
+ onSelect: j,
310
+ onBlur: () => $("street")
311
+ },
312
+ e.name
313
+ ) : /* @__PURE__ */ o(
314
+ "div",
315
+ {
316
+ ref: e.name === "postalCode" ? f : void 0,
317
+ children: /* @__PURE__ */ o(
318
+ B,
319
+ {
320
+ field: e,
321
+ value: i[e.name] ?? "",
322
+ error: E[e.name],
323
+ errorParams: F[e.name],
324
+ country: u,
325
+ onChange: U,
326
+ onBlur: $
327
+ }
328
+ )
329
+ },
330
+ e.name
331
+ ))
332
+ ] })
333
+ ] }),
334
+ /* @__PURE__ */ o("div", { className: "IncodeEkybFooter", children: /* @__PURE__ */ o(
335
+ Q,
336
+ {
337
+ onClick: () => r.submit(),
338
+ disabled: !d,
339
+ "data-testid": "ekyb-submit",
340
+ children: n("ekyb.continue")
341
+ }
342
+ ) })
343
+ ] });
344
+ }, ke = ({ config: t, onFinish: r }) => /* @__PURE__ */ o(X, { children: t ? /* @__PURE__ */ o(pe, { config: t, onFinish: r }) : null });
345
+ ue(ke, "incode-ekyb");
346
+ export {
347
+ ke as EkybModule
348
+ };
@@ -22,7 +22,7 @@
22
22
  display: flex;
23
23
  }
24
24
 
25
- .IncodeEkycForm .IncodeInputComposed, .IncodeEkycForm .IncodeDropdownComposed, .IncodeEkycForm .IncodeDateInputComposed, .IncodeEkycForm .IncodeAddressAutocomplete {
25
+ .IncodeEkycForm .IncodeInputComposed, .IncodeEkycForm .IncodeDropdownComposed, .IncodeEkycForm .IncodeDateInputComposed, .IncodeEkycForm .IncodePhoneInputComposed, .IncodeEkycForm .IncodeAddressAutocomplete {
26
26
  margin-inline: auto;
27
27
  }
28
28
 
@@ -30,6 +30,14 @@
30
30
  margin-bottom: var(--spacing-0, var(--spacing-none, 0px));
31
31
  }
32
32
 
33
+ .IncodeEkycFooter {
34
+ margin-top: var(--spacing-24, var(--spacing-24, 24px));
35
+ align-items: center;
36
+ gap: var(--spacing-12, var(--spacing-12, 12px));
37
+ flex-direction: column;
38
+ display: flex;
39
+ }
40
+
33
41
  @media (min-width: 768px) {
34
42
  .IncodePageContainer.IncodeEkycPage {
35
43
  height: 100dvh;
@@ -52,7 +60,6 @@
52
60
  .IncodeEkycPage .IncodeEkycForm {
53
61
  min-height: var(--spacing-0, var(--spacing-none, 0px));
54
62
  padding-bottom: var(--spacing-8, var(--spacing-8, 8px));
55
- flex: 1;
56
63
  overflow-y: auto;
57
64
  }
58
65