@incodetech/web 0.0.0-dev-20260313-bc2dab4 → 0.0.0-dev-20260317-ce5d28b

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.
@@ -0,0 +1,151 @@
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";
3
+ import "./uiConfig-Z6RT23Sl.js";
4
+ import { t as Q } from "./formField-B2HDj15w.js";
5
+ import { I as R } from "./dropdownComposed-DBm7cotT.js";
6
+ import "@incodetech/core";
7
+ import { u as q } from "./useMediaQuery-CiSMgDyi.js";
8
+ function G(c, f) {
9
+ const [A, h] = d(!1);
10
+ return M(() => {
11
+ const o = c.current;
12
+ if (!o) return;
13
+ const i = () => h(o.scrollHeight > o.clientHeight);
14
+ i();
15
+ const u = new ResizeObserver(i);
16
+ return u.observe(o), () => u.disconnect();
17
+ }, [f, c]), A;
18
+ }
19
+ const J = ({
20
+ label: c,
21
+ value: f,
22
+ error: A,
23
+ errorParams: h,
24
+ suggestions: o,
25
+ readonly: i,
26
+ optional: u,
27
+ onChange: w,
28
+ onSearch: k,
29
+ onSelect: N
30
+ }) => {
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
+ M(() => {
33
+ function e(t) {
34
+ v.current && !v.current.contains(t.target) && a(!1);
35
+ }
36
+ return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
37
+ }, []), M(() => {
38
+ r(-1);
39
+ }, [o]);
40
+ const b = F(
41
+ (e) => {
42
+ N(e), a(!1), m(!1), r(-1);
43
+ },
44
+ [N]
45
+ ), $ = (e) => {
46
+ w(e), e.length >= 3 ? I ? (m(!0), S(e)) : (k(e), a(!0)) : a(!1);
47
+ }, O = (e) => {
48
+ !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
+ return /* @__PURE__ */ l("div", { className: "IncodeAddressAutocomplete", ref: v, children: [
51
+ /* @__PURE__ */ l(
52
+ R,
53
+ {
54
+ id: "ekyc-street",
55
+ label: E,
56
+ name: "street",
57
+ value: f,
58
+ readOnly: i,
59
+ error: Q(n, A, h),
60
+ onInput: (e) => $(e.target.value),
61
+ onKeyDown: O,
62
+ role: "combobox",
63
+ "aria-expanded": y,
64
+ "aria-controls": p,
65
+ "aria-activedescendant": L,
66
+ "aria-autocomplete": "list",
67
+ "data-testid": "ekyc-address-input"
68
+ }
69
+ ),
70
+ y && /* @__PURE__ */ l(
71
+ "ul",
72
+ {
73
+ id: p,
74
+ role: "listbox",
75
+ className: "IncodeAddressAutocompleteSuggestions",
76
+ children: o.map((e, t) => /* @__PURE__ */ l(
77
+ "li",
78
+ {
79
+ id: `${p}-option-${t}`,
80
+ role: "option",
81
+ "aria-selected": t === s,
82
+ className: `IncodeAddressAutocompleteSuggestion${t === s ? "IncodeAddressAutocompleteSuggestionActive" : ""}`,
83
+ onClick: () => b(e),
84
+ children: e.label
85
+ },
86
+ e.id
87
+ ))
88
+ }
89
+ ),
90
+ I && D && /* @__PURE__ */ l("div", { className: "IncodeAddressAutocompleteModalOverlay", children: /* @__PURE__ */ l("div", { className: "IncodeAddressAutocompleteModal", children: [
91
+ /* @__PURE__ */ l("div", { className: "IncodeAddressAutocompleteModalHeader", children: [
92
+ /* @__PURE__ */ l("h3", { children: n("verification.addressSearch") }),
93
+ /* @__PURE__ */ l(
94
+ "button",
95
+ {
96
+ className: "IncodeAddressAutocompleteModalClose",
97
+ onClick: () => m(!1),
98
+ type: "button",
99
+ children: "×"
100
+ }
101
+ )
102
+ ] }),
103
+ /* @__PURE__ */ l("div", { className: "IncodeAddressAutocompleteModalBody", children: [
104
+ /* @__PURE__ */ l(
105
+ "input",
106
+ {
107
+ className: "IncodeAddressAutocompleteModalInput",
108
+ type: "text",
109
+ value: C,
110
+ placeholder: n("verification.addressPlaceholder"),
111
+ onInput: (e) => {
112
+ const t = e.target.value;
113
+ S(t), t.length >= 3 && k(t);
114
+ },
115
+ autoFocus: !0
116
+ }
117
+ ),
118
+ o.length > 0 && /* @__PURE__ */ l(
119
+ "ul",
120
+ {
121
+ role: "listbox",
122
+ className: "IncodeAddressAutocompleteModalSuggestions",
123
+ children: o.map((e) => /* @__PURE__ */ l(
124
+ "li",
125
+ {
126
+ role: "option",
127
+ className: "IncodeAddressAutocompleteModalSuggestion",
128
+ onClick: () => b(e),
129
+ children: e.label
130
+ },
131
+ e.id
132
+ ))
133
+ }
134
+ ),
135
+ /* @__PURE__ */ l(
136
+ "button",
137
+ {
138
+ className: "IncodeAddressAutocompleteEnterManually",
139
+ onClick: () => m(!1),
140
+ type: "button",
141
+ children: n("verification.enterManually")
142
+ }
143
+ )
144
+ ] })
145
+ ] }) })
146
+ ] });
147
+ };
148
+ export {
149
+ J as A,
150
+ G as u
151
+ };
package/dist/base.css CHANGED
@@ -882,13 +882,66 @@
882
882
  font-family: inherit;
883
883
  display: inline-block;
884
884
  }
885
- .IncodePhoneInputComposed .IncodeDropdownComposedTrigger {
885
+ .IncodePhoneInputComposed {
886
+ width: 100%;
887
+ max-width: 420px;
888
+ position: relative;
889
+ }
890
+ .IncodePhoneInputComposedLabel {
891
+ margin: var(--spacing-0, var(--spacing-none, 0px));
892
+ margin-bottom: var(--spacing-8, var(--spacing-8, 8px));
893
+ font-family: var(--typography-label-family);
894
+ font-size: var(--typography-label-m-size);
895
+ font-weight: var(--typography-label-m-weight);
896
+ line-height: var(--typography-label-m-line-height);
897
+ letter-spacing: var(--typography-label-m-letter-spacing);
898
+ display: inline-block;
899
+ }
900
+ .IncodePhoneInputComposedRequired {
901
+ color: var(--color-input-text-helper-negative, var(--input-text-helper-negative));
902
+ }
903
+ .IncodePhoneInputComposedDropdown {
904
+ max-width: none;
905
+ }
906
+ .IncodePhoneInputComposedDropdown .IncodeDropdownComposedTrigger {
886
907
  flex-shrink: 0;
887
908
  width: auto;
909
+ min-width: 120px;
888
910
  }
889
- .IncodePhoneInputComposed .IncodeDropdownComposedSibling .IncodeInputComposed, .IncodePhoneInputComposed .IncodeDropdownComposedSibling .IncodeInput {
911
+ .IncodePhoneInputComposedDropdown .IncodeDropdownComposedSibling .IncodeInputComposed, .IncodePhoneInputComposedDropdown .IncodeDropdownComposedSibling .IncodeInput {
890
912
  max-width: none;
891
913
  }
914
+ .IncodePhoneInputComposedErrorWrapper, .IncodePhoneInputComposedHelperWrapper {
915
+ margin-top: var(--spacing-8, var(--spacing-8, 8px));
916
+ align-items: center;
917
+ display: flex;
918
+ }
919
+ .IncodePhoneInputComposedIconWrapper {
920
+ margin-right: var(--spacing-8, var(--spacing-8, 8px));
921
+ justify-content: center;
922
+ align-items: center;
923
+ display: flex;
924
+ }
925
+ .IncodePhoneInputComposedError {
926
+ margin: var(--spacing-0, var(--spacing-none, 0px));
927
+ font-family: var(--typography-body-family);
928
+ font-size: var(--typography-body-m-regular-size);
929
+ font-weight: var(--typography-body-m-regular-weight);
930
+ line-height: var(--typography-body-m-regular-line-height);
931
+ letter-spacing: var(--typography-body-m-regular-letter-spacing);
932
+ color: var(--color-input-text-helper-negative, var(--input-text-helper-negative));
933
+ display: inline-block;
934
+ }
935
+ .IncodePhoneInputComposedHelper {
936
+ margin: var(--spacing-0, var(--spacing-none, 0px));
937
+ font-family: var(--typography-body-family);
938
+ font-size: var(--typography-body-m-regular-size);
939
+ font-weight: var(--typography-body-m-regular-weight);
940
+ line-height: var(--typography-body-m-regular-line-height);
941
+ letter-spacing: var(--typography-body-m-regular-letter-spacing);
942
+ color: var(--color-input-text-helper-default, var(--input-text-helper-default));
943
+ display: inline-block;
944
+ }
892
945
  .IncodeOtpInput {
893
946
  flex-direction: column;
894
947
  flex: 1;
@@ -29,6 +29,10 @@
29
29
  margin-bottom: var(--spacing-0, var(--spacing-none, 0px));
30
30
  }
31
31
 
32
+ .IncodeEkybForm .IncodeAddressAutocomplete {
33
+ margin-inline: auto;
34
+ }
35
+
32
36
  @media (min-width: 768px) {
33
37
  .IncodePageContainer.IncodeEkybPage {
34
38
  margin-top: var(--spacing-0, var(--spacing-none, 0px));
@@ -0,0 +1,299 @@
1
+ import { b as k, u as o, I as w, a as D, S as L, B as T } from "./button-Ca1tRSTI.js";
2
+ import { SUPPORTED_COUNTRIES as F, DEV_ONLY_COUNTRIES as O, createEkybManager as _ } from "@incodetech/core/ekyb";
3
+ import { T as q, y as g, A as S, k as B } from "./vendor-preact-BXf0bkEs.js";
4
+ import "./uiConfig-Z6RT23Sl.js";
5
+ import "@incodetech/core";
6
+ import { u as V, A as G } from "./addressAutocomplete-CL7IcYGQ.js";
7
+ import { P as K } from "./page-BVHG3h0V.js";
8
+ import { t as $, F as z, V as v } from "./formField-B2HDj15w.js";
9
+ import { r as W } from "./incodeModule-aE-LkKwM.js";
10
+ import { D as P, I as f } from "./dropdownComposed-DBm7cotT.js";
11
+ function Y(e) {
12
+ return [...e.toUpperCase()].map((r) => String.fromCodePoint(127462 + r.charCodeAt(0) - 65)).join("");
13
+ }
14
+ const j = {
15
+ BR: "Brazil",
16
+ CM: "Cameroon",
17
+ CN: "China",
18
+ FR: "France",
19
+ DE: "Germany",
20
+ IL: "Israel",
21
+ IT: "Italy",
22
+ KE: "Kenya",
23
+ MX: "Mexico",
24
+ NG: "Nigeria",
25
+ ES: "Spain",
26
+ GB: "United Kingdom",
27
+ US: "USA"
28
+ };
29
+ function H(e) {
30
+ const r = j[e] ?? e;
31
+ return { value: e, label: `${Y(e)} ${r}` };
32
+ }
33
+ function X() {
34
+ if (typeof window > "u") return !1;
35
+ const { hostname: e } = window.location;
36
+ return e === "localhost" || e.includes("stage") || e.includes("demo");
37
+ }
38
+ const J = ({
39
+ value: e,
40
+ onChange: r
41
+ }) => {
42
+ const { t: u } = k(), i = q(() => (X() ? [...F, ...O] : [...F]).map(H).sort((l, a) => l.label.localeCompare(a.label)), []);
43
+ return /* @__PURE__ */ o("div", { className: "IncodeEkybCountrySelector", children: /* @__PURE__ */ o(
44
+ P,
45
+ {
46
+ id: "ekyb-country",
47
+ label: u("ekyb.country"),
48
+ value: e,
49
+ options: i,
50
+ onChange: r,
51
+ "data-testid": "ekyb-country-selector"
52
+ }
53
+ ) });
54
+ }, U = ({
55
+ field: e,
56
+ value: r,
57
+ error: u,
58
+ errorParams: i,
59
+ country: s,
60
+ onChange: l
61
+ }) => {
62
+ const { t: a } = k(), m = !e.required, p = a(e.label);
63
+ if (e.type === "dropdown") {
64
+ const d = m ? `${p} (${a("common.optional")})` : p, n = e.name === "state" ? a("ekyb.selectState") : void 0;
65
+ return /* @__PURE__ */ o(
66
+ P,
67
+ {
68
+ id: `ekyb-${e.name}`,
69
+ label: d,
70
+ placeholder: n,
71
+ value: r,
72
+ options: (e.options ?? []).map((b) => ({
73
+ ...b,
74
+ label: a(b.label)
75
+ })),
76
+ error: $(a, u, i),
77
+ searchable: !0,
78
+ onChange: (b) => l(e.name, b),
79
+ "data-testid": `ekyb-field-${e.name}`
80
+ }
81
+ );
82
+ }
83
+ return /* @__PURE__ */ o(
84
+ z,
85
+ {
86
+ name: e.name,
87
+ label: e.label,
88
+ value: r,
89
+ error: u,
90
+ errorParams: i,
91
+ required: e.required,
92
+ optional: m,
93
+ onChange: l
94
+ }
95
+ );
96
+ }, Q = ({
97
+ ubos: e,
98
+ errors: r,
99
+ errorParams: u,
100
+ canAddUbo: i,
101
+ onSetField: s,
102
+ onAdd: l,
103
+ onRemove: a
104
+ }) => {
105
+ const { t: m } = k(), p = (d) => $(m, r[d], u[d]);
106
+ return e.length === 0 ? null : /* @__PURE__ */ o("div", { className: "IncodeEkybUbos", children: [
107
+ e.map((d, n) => {
108
+ const b = n === 0 ? m("ekyb.uboName") : m("ekyb.uboNameWithNumber", { number: n + 1 }), C = n === 0 ? m("ekyb.uboSurname") : m("ekyb.uboSurnameWithNumber", { number: n + 1 }), E = n === 0;
109
+ return /* @__PURE__ */ o("div", { className: "IncodeEkybUboEntry", children: [
110
+ /* @__PURE__ */ o(
111
+ f,
112
+ {
113
+ id: `ubo-${n}-name`,
114
+ label: b,
115
+ name: `ubo-${n}-name`,
116
+ value: d.name,
117
+ error: p(`ubo-${n}-name`),
118
+ onInput: (h) => s(n, "name", h.target.value),
119
+ "data-testid": `ekyb-ubo-${n}-name`
120
+ }
121
+ ),
122
+ /* @__PURE__ */ o(
123
+ f,
124
+ {
125
+ id: `ubo-${n}-surname`,
126
+ label: C,
127
+ name: `ubo-${n}-surname`,
128
+ value: d.surname,
129
+ error: p(`ubo-${n}-surname`),
130
+ onInput: (h) => s(
131
+ n,
132
+ "surname",
133
+ h.target.value
134
+ ),
135
+ "data-testid": `ekyb-ubo-${n}-surname`
136
+ }
137
+ ),
138
+ !E && /* @__PURE__ */ o(
139
+ "button",
140
+ {
141
+ className: "IncodeEkybRemoveUbo",
142
+ onClick: () => a(n),
143
+ type: "button",
144
+ children: m("common.remove")
145
+ }
146
+ )
147
+ ] }, d.id);
148
+ }),
149
+ i && /* @__PURE__ */ o(
150
+ "button",
151
+ {
152
+ className: "IncodeEkybAddUbo",
153
+ onClick: l,
154
+ type: "button",
155
+ "data-testid": "ekyb-add-ubo",
156
+ children: m("ekyb.addAnotherUbo")
157
+ }
158
+ )
159
+ ] });
160
+ }, Z = ({ config: e, onFinish: r, onError: u }) => {
161
+ const { t: i } = k(), [s, l] = D(() => _({ config: e }));
162
+ g(() => {
163
+ (s.status === "finished" || s.status === "closed") && r?.();
164
+ }, [s.status, r]);
165
+ const a = s.status === "error" ? s.errorMessage : void 0;
166
+ return g(() => {
167
+ s.status === "error" && u?.(a);
168
+ }, [s.status, u, a]), s.status === "finished" || s.status === "closed" ? null : s.status === "loading" ? /* @__PURE__ */ o(
169
+ v,
170
+ {
171
+ status: "submitting",
172
+ submittingTitle: i("common.loading")
173
+ }
174
+ ) : s.status === "submitting" ? /* @__PURE__ */ o(v, { status: "submitting" }) : s.status === "success" ? /* @__PURE__ */ o(v, { status: "success" }) : s.status === "error" ? /* @__PURE__ */ o(v, { status: "failure", onRetry: () => l.retry() }) : s.status === "form" ? /* @__PURE__ */ o(x, { state: s, manager: l }) : null;
175
+ }, A = /* @__PURE__ */ new Set([
176
+ "street",
177
+ "houseNo",
178
+ "addressLine2",
179
+ "city",
180
+ "state",
181
+ "postalCode"
182
+ ]), x = ({ state: e, manager: r }) => {
183
+ const {
184
+ country: u,
185
+ fields: i,
186
+ values: s,
187
+ displayErrors: l,
188
+ errorParams: a,
189
+ isValid: m,
190
+ ubos: p,
191
+ canAddUbo: d,
192
+ addressSuggestions: n
193
+ } = e, { t: b } = k(), C = S(null), E = S(null), h = S(void 0), R = V(C, i.length);
194
+ g(() => {
195
+ const t = l.postalCode, c = h.current;
196
+ if (h.current = t, !t || c === t)
197
+ return;
198
+ const y = requestAnimationFrame(() => {
199
+ const I = E.current;
200
+ if (!I) return;
201
+ (I.querySelector("#postalCode-error") ?? I).scrollIntoView({
202
+ behavior: "smooth",
203
+ block: "nearest"
204
+ });
205
+ });
206
+ return () => cancelAnimationFrame(y);
207
+ }, [l.postalCode]);
208
+ const M = i.filter((t) => !A.has(t.name)), N = i.filter((t) => A.has(t.name));
209
+ return /* @__PURE__ */ o(K, { className: `IncodeEkybPage${R ? " IncodeEkybPageScrollable" : ""}`, title: b("ekyb.title"), children: [
210
+ /* @__PURE__ */ o("div", { ref: C, className: "IncodeEkybForm", children: [
211
+ /* @__PURE__ */ o(
212
+ J,
213
+ {
214
+ value: u,
215
+ onChange: (t) => r.setCountry(t)
216
+ }
217
+ ),
218
+ M.map((t) => /* @__PURE__ */ o(
219
+ U,
220
+ {
221
+ field: t,
222
+ value: s[t.name] ?? "",
223
+ error: l[t.name],
224
+ errorParams: a[t.name],
225
+ country: u,
226
+ onChange: (c, y) => r.setField(c, y)
227
+ },
228
+ t.name
229
+ )),
230
+ /* @__PURE__ */ o(
231
+ Q,
232
+ {
233
+ ubos: p,
234
+ errors: l,
235
+ errorParams: a,
236
+ canAddUbo: d,
237
+ onSetField: (t, c, y) => r.setUboField(t, c, y),
238
+ onAdd: () => r.addUbo(),
239
+ onRemove: (t) => r.removeUbo(t)
240
+ }
241
+ ),
242
+ N.length > 0 && /* @__PURE__ */ o(B, { children: [
243
+ /* @__PURE__ */ o("h3", { className: "IncodeEkybSectionHeader", children: b("ekyb.addressDetails") }),
244
+ N.map((t) => t.name === "street" ? /* @__PURE__ */ o(
245
+ G,
246
+ {
247
+ label: t.label,
248
+ value: s.street ?? "",
249
+ error: l.street,
250
+ errorParams: a.street,
251
+ suggestions: n,
252
+ optional: !t.required,
253
+ onChange: (c) => r.setField("street", c),
254
+ onSearch: (c) => r.searchAddress(c),
255
+ onSelect: (c) => r.selectAddress(c)
256
+ },
257
+ t.name
258
+ ) : /* @__PURE__ */ o(
259
+ "div",
260
+ {
261
+ ref: t.name === "postalCode" ? E : void 0,
262
+ children: /* @__PURE__ */ o(
263
+ U,
264
+ {
265
+ field: t,
266
+ value: s[t.name] ?? "",
267
+ error: l[t.name],
268
+ errorParams: a[t.name],
269
+ country: u,
270
+ onChange: (c, y) => r.setField(c, y)
271
+ }
272
+ )
273
+ },
274
+ t.name
275
+ ))
276
+ ] })
277
+ ] }),
278
+ /* @__PURE__ */ o("div", { className: "IncodeEkybFooter", children: [
279
+ /* @__PURE__ */ o(L, { size: 32 }),
280
+ /* @__PURE__ */ o(
281
+ T,
282
+ {
283
+ onClick: () => r.submit(),
284
+ disabled: !m,
285
+ "data-testid": "ekyb-submit",
286
+ children: b("ekyb.continue")
287
+ }
288
+ )
289
+ ] })
290
+ ] });
291
+ }, ee = ({
292
+ config: e,
293
+ onFinish: r,
294
+ onError: u
295
+ }) => /* @__PURE__ */ o(w, { children: e ? /* @__PURE__ */ o(Z, { config: e, onFinish: r, onError: u }) : null });
296
+ W(ee, "incode-ekyb");
297
+ export {
298
+ ee as EkybModule
299
+ };