@propellerads/kyc-form 5.0.4 → 5.0.6
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/index.js +167 -154
- package/dist/index.js.map +1 -1
- package/package.json +6 -7
package/dist/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import e, { ButtonVariant as t } from "@propellerads/button";
|
|
2
2
|
import { useEffect as n, useState as r } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { Textarea as
|
|
6
|
-
import
|
|
7
|
-
import { black as
|
|
8
|
-
import { jsx as
|
|
9
|
-
import T from "@propellerads/success-label";
|
|
3
|
+
import { Check as i, Close as a, Color as o, Delete as s, Insert as c, Pdf as l, Size as u } from "@propellerads/icon";
|
|
4
|
+
import d, { Direction as f } from "@propellerads/image-uploader";
|
|
5
|
+
import { Textarea as p } from "@propellerads/input";
|
|
6
|
+
import m from "styled-components";
|
|
7
|
+
import { black as h, borderRadius as g, errorColor as _, fontNormal as v, fontSmall as y, gray50 as b, gray95 as x, lineHeight as S, mediumDevices as C, spacing as w, successColor as ee, white as T } from "@propellerads/stylevariables";
|
|
8
|
+
import { jsx as E, jsxs as D } from "react/jsx-runtime";
|
|
10
9
|
//#region src/document.types.ts
|
|
11
|
-
var
|
|
10
|
+
var O = {
|
|
12
11
|
Id: "id",
|
|
13
12
|
Ub: "ub",
|
|
14
13
|
IdExtra: "id_extra",
|
|
@@ -22,7 +21,7 @@ var E = {
|
|
|
22
21
|
TransactionConfirmation: "transaction_confirmation",
|
|
23
22
|
Other: "other",
|
|
24
23
|
Feedback: "feedback"
|
|
25
|
-
},
|
|
24
|
+
}, k = {
|
|
26
25
|
IdFront: "id_front",
|
|
27
26
|
IdBack: "id_back",
|
|
28
27
|
Ub: "ub_item",
|
|
@@ -36,118 +35,118 @@ var E = {
|
|
|
36
35
|
TransactionConfirmationImage: "transaction_confirmation_image",
|
|
37
36
|
OtherImage: "other_image",
|
|
38
37
|
Feedback: "feedback"
|
|
39
|
-
},
|
|
38
|
+
}, A = 5242880, te = 3, j = "application/pdf", M = "image/heic", N = {
|
|
40
39
|
"image/png": [".png"],
|
|
41
40
|
"image/jpeg": [
|
|
42
41
|
".jpg",
|
|
43
42
|
".jpe",
|
|
44
43
|
".jpeg"
|
|
45
44
|
],
|
|
46
|
-
[
|
|
47
|
-
[
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
],
|
|
58
|
-
[
|
|
59
|
-
[
|
|
60
|
-
},
|
|
45
|
+
[j]: [".pdf"],
|
|
46
|
+
[M]: [".heic"]
|
|
47
|
+
}, P = [
|
|
48
|
+
O.Card,
|
|
49
|
+
O.Card,
|
|
50
|
+
O.PaypalDetailsPage,
|
|
51
|
+
O.BankWireDetails,
|
|
52
|
+
O.TransactionConfirmation,
|
|
53
|
+
O.SelfieWithIdCard,
|
|
54
|
+
O.PaymentSystemScreen,
|
|
55
|
+
O.Other
|
|
56
|
+
], ne = {
|
|
57
|
+
[O.Id]: { parts: [k.IdBack] },
|
|
58
|
+
[O.IdExtra]: { parts: [k.IdBack] }
|
|
59
|
+
}, re = m.div`
|
|
61
60
|
display: flex;
|
|
62
61
|
align-items: center;
|
|
63
|
-
color: ${
|
|
64
|
-
margin-top: ${
|
|
65
|
-
margin-bottom: ${
|
|
66
|
-
`,
|
|
62
|
+
color: ${_};
|
|
63
|
+
margin-top: ${w * 2}px;
|
|
64
|
+
margin-bottom: ${w * 4}px;
|
|
65
|
+
`, F = m.span`
|
|
67
66
|
display: flex;
|
|
68
67
|
align-items: center;
|
|
69
68
|
justify-content: center;
|
|
70
69
|
width: 14px;
|
|
71
70
|
height: 14px;
|
|
72
71
|
border-radius: 100%;
|
|
73
|
-
background-color: ${
|
|
72
|
+
background-color: ${_};
|
|
74
73
|
|
|
75
74
|
&:before {
|
|
76
|
-
font-size: ${
|
|
77
|
-
color: ${
|
|
75
|
+
font-size: ${y};
|
|
76
|
+
color: ${T};
|
|
78
77
|
content: '!';
|
|
79
78
|
}
|
|
80
|
-
`,
|
|
81
|
-
margin-left: ${
|
|
82
|
-
`,
|
|
83
|
-
color:
|
|
84
|
-
hoverColor:
|
|
85
|
-
size:
|
|
86
|
-
}), /* @__PURE__ */
|
|
79
|
+
`, I = m.span`
|
|
80
|
+
margin-left: ${w * 2}px;
|
|
81
|
+
`, L = (e) => /* @__PURE__ */ D(re, { children: [e.isDocumentPartError ? /* @__PURE__ */ E(F, {}) : /* @__PURE__ */ E(a, {
|
|
82
|
+
color: o.Error,
|
|
83
|
+
hoverColor: o.Error,
|
|
84
|
+
size: u.Small
|
|
85
|
+
}), /* @__PURE__ */ E(I, { children: e.label })] }), R = (e) => P.includes(e), ie = (e, t) => R(e) && t.every((e) => !!e.data) && t.length < 3 && t.length > 0, z = (e) => e?.match(/[^:]\w+\/[\w-+\d.]+(?=;|,)/)?.[0], ae = (e) => z(e) === j, oe = (e) => z(e) === M, B = (e, t) => t.every((t) => t.data !== e?.data), V = async (e) => {
|
|
87
86
|
let t = new FileReader();
|
|
88
87
|
return new Promise((n, r) => {
|
|
89
88
|
t.onload = () => n(t.result), t.onerror = (e) => r(e), t.readAsDataURL(e);
|
|
90
89
|
});
|
|
91
|
-
},
|
|
92
|
-
margin-top: ${
|
|
93
|
-
margin-left: ${
|
|
94
|
-
`,
|
|
95
|
-
margin-bottom: ${
|
|
96
|
-
`,
|
|
90
|
+
}, H = m.div`
|
|
91
|
+
margin-top: ${w * 4}px;
|
|
92
|
+
margin-left: ${w * 4}px;
|
|
93
|
+
`, U = m.div`
|
|
94
|
+
margin-bottom: ${w}px;
|
|
95
|
+
`, W = m.div`
|
|
97
96
|
display: flex;
|
|
98
97
|
align-items: center;
|
|
99
|
-
background-color: ${
|
|
100
|
-
padding: ${
|
|
101
|
-
border-radius: ${
|
|
102
|
-
`,
|
|
98
|
+
background-color: ${x};
|
|
99
|
+
padding: ${w * 2}px;
|
|
100
|
+
border-radius: ${g}px;
|
|
101
|
+
`, G = m.span`
|
|
103
102
|
width: 100%;
|
|
104
|
-
margin-left: ${
|
|
105
|
-
margin-right: ${
|
|
106
|
-
`,
|
|
103
|
+
margin-left: ${w * 4}px;
|
|
104
|
+
margin-right: ${w * 2}px;
|
|
105
|
+
`, K = m.span`
|
|
107
106
|
cursor: pointer !important;
|
|
108
|
-
margin-right: ${
|
|
109
|
-
`,
|
|
107
|
+
margin-right: ${w * 2}px;
|
|
108
|
+
`, q = m.div`
|
|
110
109
|
height: 66px;
|
|
111
|
-
`,
|
|
110
|
+
`, se = m.div`
|
|
112
111
|
display: flex;
|
|
113
112
|
flex-direction: column;
|
|
114
|
-
margin-top: ${
|
|
115
|
-
margin-left: ${
|
|
116
|
-
`,
|
|
113
|
+
margin-top: ${w * 4}px;
|
|
114
|
+
margin-left: ${w * 4}px;
|
|
115
|
+
`, ce = m.img`
|
|
117
116
|
width: auto;
|
|
118
117
|
max-width: 204px;
|
|
119
118
|
height: 50px;
|
|
120
119
|
object-fit: contain;
|
|
121
|
-
border-radius: ${
|
|
122
|
-
`,
|
|
120
|
+
border-radius: ${g}px;
|
|
121
|
+
`, le = m.div`
|
|
123
122
|
display: flex;
|
|
124
123
|
align-items: center;
|
|
125
124
|
justify-content: center;
|
|
126
125
|
min-width: 50px;
|
|
127
126
|
height: 50px;
|
|
128
|
-
border-radius: ${
|
|
129
|
-
background-color: ${
|
|
130
|
-
`,
|
|
131
|
-
let { data: t } = e, n =
|
|
132
|
-
return n || r ? /* @__PURE__ */
|
|
133
|
-
color:
|
|
134
|
-
hoverColor:
|
|
135
|
-
}), r && /* @__PURE__ */
|
|
136
|
-
color:
|
|
137
|
-
hoverColor:
|
|
138
|
-
})] }) : /* @__PURE__ */
|
|
139
|
-
},
|
|
127
|
+
border-radius: ${g}px;
|
|
128
|
+
background-color: ${T};
|
|
129
|
+
`, ue = (e) => {
|
|
130
|
+
let { data: t } = e, n = ae(t), r = oe(t);
|
|
131
|
+
return n || r ? /* @__PURE__ */ D(le, { children: [n && /* @__PURE__ */ E(l, {
|
|
132
|
+
color: o.Gray,
|
|
133
|
+
hoverColor: o.Gray
|
|
134
|
+
}), r && /* @__PURE__ */ E(c, {
|
|
135
|
+
color: o.Gray,
|
|
136
|
+
hoverColor: o.Gray
|
|
137
|
+
})] }) : /* @__PURE__ */ E(ce, { src: t });
|
|
138
|
+
}, J = {
|
|
140
139
|
KYCFormItemFileExtraPart: (e) => {
|
|
141
140
|
let { elementId: t, title: n, uploaderLabels: r, onFileAdd: i } = e;
|
|
142
|
-
return /* @__PURE__ */
|
|
141
|
+
return /* @__PURE__ */ D(se, {
|
|
143
142
|
id: t,
|
|
144
|
-
children: [n && /* @__PURE__ */
|
|
143
|
+
children: [n && /* @__PURE__ */ E(U, { children: n }), /* @__PURE__ */ E(q, { children: /* @__PURE__ */ E(d, {
|
|
145
144
|
title: r.title,
|
|
146
145
|
action: r.action,
|
|
147
|
-
maxSize:
|
|
148
|
-
acceptFormats:
|
|
146
|
+
maxSize: A,
|
|
147
|
+
acceptFormats: N,
|
|
149
148
|
elementId: `${t}_uploader`,
|
|
150
|
-
direction:
|
|
149
|
+
direction: f.Row,
|
|
151
150
|
onDrop: (e) => {
|
|
152
151
|
let [t] = e;
|
|
153
152
|
t && i(t);
|
|
@@ -156,34 +155,34 @@ var E = {
|
|
|
156
155
|
});
|
|
157
156
|
},
|
|
158
157
|
KYCFormItemFile: (e) => {
|
|
159
|
-
let { name: t, title: n, data: r, error: i, elementId:
|
|
160
|
-
return /* @__PURE__ */
|
|
161
|
-
id:
|
|
158
|
+
let { name: t, title: n, data: r, error: i, elementId: a, uploaderLabels: c, onFileChange: l, onFileRemove: u } = e;
|
|
159
|
+
return /* @__PURE__ */ D(H, {
|
|
160
|
+
id: a,
|
|
162
161
|
children: [
|
|
163
|
-
n && /* @__PURE__ */
|
|
164
|
-
r ? /* @__PURE__ */
|
|
165
|
-
/* @__PURE__ */
|
|
166
|
-
/* @__PURE__ */
|
|
167
|
-
/* @__PURE__ */
|
|
168
|
-
onClick:
|
|
169
|
-
children: /* @__PURE__ */
|
|
170
|
-
color:
|
|
171
|
-
hoverColor:
|
|
162
|
+
n && /* @__PURE__ */ E(U, { children: n }),
|
|
163
|
+
r ? /* @__PURE__ */ D(W, { children: [
|
|
164
|
+
/* @__PURE__ */ E(ue, { data: r }),
|
|
165
|
+
/* @__PURE__ */ E(G, { children: t }),
|
|
166
|
+
/* @__PURE__ */ E(K, {
|
|
167
|
+
onClick: u,
|
|
168
|
+
children: /* @__PURE__ */ E(s, {
|
|
169
|
+
color: o.Blue,
|
|
170
|
+
hoverColor: o.Blue
|
|
172
171
|
})
|
|
173
172
|
})
|
|
174
|
-
] }) : /* @__PURE__ */
|
|
173
|
+
] }) : /* @__PURE__ */ E(q, { children: /* @__PURE__ */ E(d, {
|
|
175
174
|
title: c.title,
|
|
176
175
|
action: c.action,
|
|
177
|
-
maxSize:
|
|
178
|
-
acceptFormats:
|
|
179
|
-
elementId: `${
|
|
180
|
-
direction:
|
|
176
|
+
maxSize: A,
|
|
177
|
+
acceptFormats: N,
|
|
178
|
+
elementId: `${a}_uploader`,
|
|
179
|
+
direction: f.Row,
|
|
181
180
|
onDrop: (e) => {
|
|
182
181
|
let [t] = e;
|
|
183
182
|
t && l(t);
|
|
184
183
|
}
|
|
185
184
|
}) }),
|
|
186
|
-
i && /* @__PURE__ */
|
|
185
|
+
i && /* @__PURE__ */ E(L, {
|
|
187
186
|
label: i,
|
|
188
187
|
isDocumentPartError: !0
|
|
189
188
|
})
|
|
@@ -192,7 +191,7 @@ var E = {
|
|
|
192
191
|
},
|
|
193
192
|
KYCFormItemText: (e) => {
|
|
194
193
|
let { onFeedbackChange: t, value: n = "" } = e;
|
|
195
|
-
return /* @__PURE__ */
|
|
194
|
+
return /* @__PURE__ */ E(H, { children: /* @__PURE__ */ E(p, {
|
|
196
195
|
onChange: (e) => t(e.target.value),
|
|
197
196
|
onBlur: (e) => t(e.target.value),
|
|
198
197
|
value: n,
|
|
@@ -202,24 +201,24 @@ var E = {
|
|
|
202
201
|
"aria-label": "Comments"
|
|
203
202
|
}) });
|
|
204
203
|
}
|
|
205
|
-
},
|
|
206
|
-
margin-top: ${
|
|
207
|
-
`,
|
|
208
|
-
font-size: ${_}px;
|
|
209
|
-
font-weight: bold;
|
|
210
|
-
color: ${m};
|
|
211
|
-
margin-bottom: ${x}px;
|
|
212
|
-
`, le = p.div`
|
|
204
|
+
}, de = m.div`
|
|
205
|
+
margin-top: ${w * 6}px;
|
|
206
|
+
`, fe = m.div`
|
|
213
207
|
font-size: ${v}px;
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
208
|
+
font-weight: bold;
|
|
209
|
+
color: ${h};
|
|
210
|
+
margin-bottom: ${w}px;
|
|
211
|
+
`, pe = m.div`
|
|
212
|
+
font-size: ${y}px;
|
|
213
|
+
color: ${b};
|
|
214
|
+
margin-left: ${w * 4}px;
|
|
215
|
+
`, Y = (e, t) => `[${e}].parts[${t}].data`, me = (e) => {
|
|
216
|
+
let { type: t, index: n, uploaderLabels: i, documentLabels: a, elementId: o, parts: s, errors: c, onDocumentChange: l } = e, [u, d] = r(/* @__PURE__ */ new Map()), f = ie(t, s), p = a?.parts, m = s[0], h = m ? p?.[m.type]?.title : void 0, [g, _] = r(/* @__PURE__ */ new Map()), v = (e) => {
|
|
218
217
|
let t = new Map(u);
|
|
219
|
-
t.set(
|
|
218
|
+
t.set(Y(n, e), i.oversizeError), d(t);
|
|
220
219
|
}, y = (e) => {
|
|
221
220
|
let t = new Map(u);
|
|
222
|
-
t.delete(
|
|
221
|
+
t.delete(Y(n, e)), d(t);
|
|
223
222
|
}, b = (e, n, r) => {
|
|
224
223
|
let i = {
|
|
225
224
|
...e,
|
|
@@ -236,7 +235,7 @@ var E = {
|
|
|
236
235
|
}
|
|
237
236
|
let n = s[e] ?? s[0];
|
|
238
237
|
if (!n) return;
|
|
239
|
-
let r = await
|
|
238
|
+
let r = await V(t);
|
|
240
239
|
b(n, e, r);
|
|
241
240
|
let i = new Map(g);
|
|
242
241
|
i.set(r, t.name), _(i), y(e);
|
|
@@ -246,29 +245,29 @@ var E = {
|
|
|
246
245
|
b(t, e);
|
|
247
246
|
let n = s[e], r = new Map(g);
|
|
248
247
|
n?.data && B(n, s) && r.delete(n?.data), _(r), y(e);
|
|
249
|
-
},
|
|
248
|
+
}, C = (e) => {
|
|
250
249
|
if (e) return g.get(e);
|
|
251
|
-
},
|
|
250
|
+
}, w = (e, t) => {
|
|
252
251
|
let n = s[e] ?? s[0];
|
|
253
252
|
n && b(n, e, t);
|
|
254
253
|
};
|
|
255
|
-
return /* @__PURE__ */
|
|
254
|
+
return /* @__PURE__ */ D(de, {
|
|
256
255
|
id: o,
|
|
257
256
|
children: [
|
|
258
|
-
/* @__PURE__ */
|
|
259
|
-
a?.description && /* @__PURE__ */
|
|
257
|
+
/* @__PURE__ */ E(fe, { children: `${n + 1}. ${a?.title}` }),
|
|
258
|
+
a?.description && /* @__PURE__ */ E(pe, { children: a?.description }),
|
|
260
259
|
s.map((e, r) => {
|
|
261
|
-
let a = `kyc-form_item_file_${e.type}`, l =
|
|
262
|
-
|
|
263
|
-
let m = c?.[
|
|
264
|
-
return e.type ===
|
|
260
|
+
let a = `kyc-form_item_file_${e.type}`, l = R(t), d = p?.[e.type], f = l ? void 0 : d?.title;
|
|
261
|
+
R(t) && e.data && (a = `${a}_${e.data?.substr(-32)}`, B(e, s) || (a = `${a}_${r}`));
|
|
262
|
+
let m = c?.[Y(n, r)], h = u.get(Y(n, r));
|
|
263
|
+
return e.type === k.Feedback ? /* @__PURE__ */ E(J.KYCFormItemText, {
|
|
265
264
|
value: e.data,
|
|
266
|
-
onFeedbackChange: (e) =>
|
|
267
|
-
}, a) : /* @__PURE__ */
|
|
265
|
+
onFeedbackChange: (e) => w(r, e)
|
|
266
|
+
}, a) : /* @__PURE__ */ E(J.KYCFormItemFile, {
|
|
268
267
|
title: f,
|
|
269
268
|
data: e.data,
|
|
270
269
|
type: e.type,
|
|
271
|
-
name:
|
|
270
|
+
name: C(e.data),
|
|
272
271
|
uploaderLabels: i,
|
|
273
272
|
error: h || m,
|
|
274
273
|
elementId: `${o}_part_${e.type}_${r}`,
|
|
@@ -276,7 +275,7 @@ var E = {
|
|
|
276
275
|
onFileRemove: () => S(r)
|
|
277
276
|
}, a);
|
|
278
277
|
}),
|
|
279
|
-
f && m && /* @__PURE__ */
|
|
278
|
+
f && m && /* @__PURE__ */ E(J.KYCFormItemFileExtraPart, {
|
|
280
279
|
elementId: `${o}_extra`,
|
|
281
280
|
title: h,
|
|
282
281
|
uploaderLabels: i,
|
|
@@ -284,55 +283,69 @@ var E = {
|
|
|
284
283
|
})
|
|
285
284
|
]
|
|
286
285
|
});
|
|
287
|
-
},
|
|
286
|
+
}, he = m.div`
|
|
288
287
|
display: flex;
|
|
289
288
|
flex-direction: column;
|
|
290
|
-
`,
|
|
291
|
-
margin-bottom: ${
|
|
292
|
-
`,
|
|
293
|
-
color: ${
|
|
294
|
-
`,
|
|
289
|
+
`, X = m.span`
|
|
290
|
+
margin-bottom: ${w * 8}px;
|
|
291
|
+
`, ge = m.span`
|
|
292
|
+
color: ${b};
|
|
293
|
+
`, _e = m.span`
|
|
294
|
+
display: inline-flex;
|
|
295
|
+
align-items: center;
|
|
296
|
+
gap: ${w}px;
|
|
297
|
+
min-height: ${S}px;
|
|
298
|
+
color: ${ee};
|
|
299
|
+
|
|
300
|
+
@media (min-width: ${C}px) {
|
|
301
|
+
max-width: 350px;
|
|
302
|
+
white-space: nowrap;
|
|
303
|
+
}
|
|
304
|
+
`, ve = m.div`
|
|
295
305
|
display: flex;
|
|
296
306
|
flex-direction: column;
|
|
297
|
-
`,
|
|
298
|
-
margin-bottom: ${
|
|
307
|
+
`, Z = m.span`
|
|
308
|
+
margin-bottom: ${w * 6}px;
|
|
299
309
|
`, Q = {
|
|
300
310
|
KYCSuccessScreen: (e) => {
|
|
301
|
-
let { elementId: t, title: n, description: r, support:
|
|
302
|
-
return /* @__PURE__ */
|
|
311
|
+
let { elementId: t, title: n, description: r, support: a } = e;
|
|
312
|
+
return /* @__PURE__ */ D(he, {
|
|
303
313
|
id: t,
|
|
304
314
|
children: [
|
|
305
|
-
/* @__PURE__ */
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
children:
|
|
315
|
+
/* @__PURE__ */ E(X, { children: /* @__PURE__ */ D(_e, {
|
|
316
|
+
id: `${t}_success`,
|
|
317
|
+
role: "status",
|
|
318
|
+
children: [/* @__PURE__ */ E(i, {
|
|
319
|
+
color: o.Success,
|
|
320
|
+
size: u.Small
|
|
321
|
+
}), n]
|
|
309
322
|
}) }),
|
|
310
|
-
r && /* @__PURE__ */
|
|
311
|
-
|
|
323
|
+
r && /* @__PURE__ */ E(X, { children: r }),
|
|
324
|
+
a && /* @__PURE__ */ E(ge, { children: a })
|
|
312
325
|
]
|
|
313
326
|
});
|
|
314
327
|
},
|
|
315
328
|
KYCFailScreen: (e) => {
|
|
316
329
|
let { elementId: t, title: n, support: r } = e;
|
|
317
|
-
return /* @__PURE__ */
|
|
330
|
+
return /* @__PURE__ */ D(ve, {
|
|
318
331
|
id: t,
|
|
319
|
-
children: [/* @__PURE__ */
|
|
332
|
+
children: [/* @__PURE__ */ E(Z, { children: /* @__PURE__ */ E(L, {
|
|
320
333
|
label: n,
|
|
321
334
|
isDocumentPartError: !1
|
|
322
335
|
}) }), r]
|
|
323
336
|
});
|
|
324
337
|
}
|
|
325
|
-
},
|
|
338
|
+
}, ye = m.div`
|
|
326
339
|
display: flex;
|
|
327
340
|
flex-direction: column;
|
|
328
341
|
align-items: flex-start;
|
|
329
342
|
width: 100%;
|
|
330
|
-
`,
|
|
331
|
-
font-size: ${
|
|
332
|
-
`,
|
|
343
|
+
`, be = m.div`
|
|
344
|
+
font-size: ${v}px;
|
|
345
|
+
`, xe = m.div`
|
|
333
346
|
width: 100%;
|
|
334
|
-
margin-bottom: ${
|
|
335
|
-
`,
|
|
347
|
+
margin-bottom: ${w * 6}px;
|
|
348
|
+
`, Se = m.div`
|
|
336
349
|
display: flex;
|
|
337
350
|
justify-content: flex-end;
|
|
338
351
|
width: 100%;
|
|
@@ -347,13 +360,13 @@ var E = {
|
|
|
347
360
|
let n = [...h];
|
|
348
361
|
n.splice(e, 1, t), g(n);
|
|
349
362
|
};
|
|
350
|
-
return /* @__PURE__ */
|
|
363
|
+
return /* @__PURE__ */ D(ye, {
|
|
351
364
|
id: a,
|
|
352
365
|
children: [
|
|
353
|
-
o && /* @__PURE__ */
|
|
354
|
-
/* @__PURE__ */
|
|
366
|
+
o && /* @__PURE__ */ E(be, { children: o }),
|
|
367
|
+
/* @__PURE__ */ E(xe, { children: h.map((e, t) => {
|
|
355
368
|
let n = `kyc-form_item_${e.type}_${t}`;
|
|
356
|
-
return /* @__PURE__ */
|
|
369
|
+
return /* @__PURE__ */ E(me, {
|
|
357
370
|
index: t,
|
|
358
371
|
type: e.type,
|
|
359
372
|
parts: e.parts,
|
|
@@ -364,7 +377,7 @@ var E = {
|
|
|
364
377
|
onDocumentChange: (e) => y(t, e)
|
|
365
378
|
}, n);
|
|
366
379
|
}) }),
|
|
367
|
-
/* @__PURE__ */
|
|
380
|
+
/* @__PURE__ */ E(Se, { children: /* @__PURE__ */ E(e, {
|
|
368
381
|
id: `${a}_button`,
|
|
369
382
|
variant: t.Primary,
|
|
370
383
|
isDisabled: _,
|
|
@@ -377,6 +390,6 @@ var E = {
|
|
|
377
390
|
};
|
|
378
391
|
$.SuccessScreen = Q.KYCSuccessScreen, $.FailScreen = Q.KYCFailScreen;
|
|
379
392
|
//#endregion
|
|
380
|
-
export {
|
|
393
|
+
export { N as ACCEPT_FORMATS, P as AVAILABLE_EXTRA_PARTS_DOCUMENTS, O as DocumentType, te as MAX_EXTRA_PARTS_COUNT, A as MAX_FILE_SIZE, ne as OPTIONAL_DOCUMENT_PARTS, j as PDF_MIME_TYPE, k as PartType, $ as default };
|
|
381
394
|
|
|
382
395
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/document.types.ts","../src/constants.ts","../src/KYCErrorLabel/style.tsx","../src/KYCErrorLabel/index.tsx","../src/utils.ts","../src/KYCDocumentParts/style.tsx","../src/KYCDocumentParts/index.tsx","../src/KYCFormItem/style.tsx","../src/KYCFormItem/index.tsx","../src/KYCStatusScreen/style.tsx","../src/KYCStatusScreen/index.tsx","../src/style.tsx","../src/index.tsx"],"sourcesContent":["export const DocumentType = {\n Id: 'id',\n Ub: 'ub',\n IdExtra: 'id_extra',\n Card: 'bank_card',\n PaymentSystemScreen: 'payment_system_screen',\n OnlineBankingStatement: 'online_banking_statement',\n CompanyRegistrationDocument: 'company_registration_document',\n SelfieWithIdCard: 'selfie_with_id_card_or_bank_card',\n PaypalDetailsPage: 'pay_pal_details_page',\n BankWireDetails: 'bank_wire_details',\n TransactionConfirmation: 'transaction_confirmation',\n Other: 'other',\n Feedback: 'feedback',\n} as const;\nexport type DocumentType = (typeof DocumentType)[keyof typeof DocumentType];\n\nexport const PartType = {\n IdFront: 'id_front',\n IdBack: 'id_back',\n Ub: 'ub_item',\n Card: 'card_item',\n PaymentSystemScreen: 'screen_item',\n OnlineBankingStatement: 'obs_item',\n CompanyRegistrationDocument: 'crd_item',\n SelfieWithIdCard: 'selfie_item',\n PaypalDetailsPageImage: 'pay_pal_details_page_image',\n BankWireDetailsPage: 'bank_wire_details_image',\n TransactionConfirmationImage: 'transaction_confirmation_image',\n OtherImage: 'other_image',\n Feedback: 'feedback',\n} as const;\nexport type PartType = (typeof PartType)[keyof typeof PartType];\n\nexport type KYCFileData = string | undefined;\n\nexport type KYCFile = {\n type: PartType;\n data?: KYCFileData;\n};\n\nexport type KYCDocument = {\n type: DocumentType;\n parts: KYCFile[];\n};\n","import type {ImageUploaderProps} from '@propellerads/image-uploader';\nimport {DocumentType, PartType} from './document.types';\n\nexport const MAX_FILE_SIZE = 5242880;\n\nexport const MAX_EXTRA_PARTS_COUNT = 3;\n\nexport const PDF_MIME_TYPE = 'application/pdf';\nexport const HEIC_MIME_TYPE = 'image/heic';\nexport const ACCEPT_FORMATS: ImageUploaderProps['acceptFormats'] = {\n 'image/png': ['.png'],\n 'image/jpeg': ['.jpg', '.jpe', '.jpeg'],\n [PDF_MIME_TYPE]: ['.pdf'],\n [HEIC_MIME_TYPE]: ['.heic'],\n};\n\nexport const AVAILABLE_EXTRA_PARTS_DOCUMENTS: DocumentType[] = [\n DocumentType.Card,\n DocumentType.Card,\n DocumentType.PaypalDetailsPage,\n DocumentType.BankWireDetails,\n DocumentType.TransactionConfirmation,\n DocumentType.SelfieWithIdCard,\n DocumentType.PaymentSystemScreen,\n DocumentType.Other,\n];\n\nexport const OPTIONAL_DOCUMENT_PARTS = {\n [DocumentType.Id]: {\n parts: [PartType.IdBack],\n },\n [DocumentType.IdExtra]: {\n parts: [PartType.IdBack],\n },\n};\n","import styled from 'styled-components';\nimport {fontSmall, spacing, white, errorColor} from '@propellerads/stylevariables';\n\nconst StyledKYCErrorLabel = styled.div`\n display: flex;\n align-items: center;\n color: ${errorColor};\n margin-top: ${spacing * 2}px;\n margin-bottom: ${spacing * 4}px;\n`;\n\nconst StyledKYCErrorLabelIcon = styled.span`\n display: flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n border-radius: 100%;\n background-color: ${errorColor};\n\n &:before {\n font-size: ${fontSmall};\n color: ${white};\n content: '!';\n }\n`;\n\nconst StyledKYCErrorLabelText = styled.span`\n margin-left: ${spacing * 2}px;\n`;\n\nexport {StyledKYCErrorLabel, StyledKYCErrorLabelIcon, StyledKYCErrorLabelText};\n","import {Close, Color, Size} from '@propellerads/icon';\nimport {StyledKYCErrorLabel, StyledKYCErrorLabelIcon, StyledKYCErrorLabelText} from './style';\nimport {KYCErrorLabelProps} from './types';\n\nconst KYCErrorLabel = (props: KYCErrorLabelProps) => (\n <StyledKYCErrorLabel>\n {props.isDocumentPartError ? (\n <StyledKYCErrorLabelIcon />\n ) : (\n <Close color={Color.Error} hoverColor={Color.Error} size={Size.Small} />\n )}\n <StyledKYCErrorLabelText>{props.label}</StyledKYCErrorLabelText>\n </StyledKYCErrorLabel>\n);\n\nexport default KYCErrorLabel;\n","import {AVAILABLE_EXTRA_PARTS_DOCUMENTS, HEIC_MIME_TYPE, MAX_EXTRA_PARTS_COUNT, PDF_MIME_TYPE} from './constants';\nimport {DocumentType, KYCFile, KYCFileData} from './document.types';\n\nconst isDocumentExtraPartAvailable = (documentType: DocumentType): boolean =>\n AVAILABLE_EXTRA_PARTS_DOCUMENTS.includes(documentType);\n\nconst canAddExtraPart = (documentType: DocumentType, parts: KYCFile[]): boolean =>\n isDocumentExtraPartAvailable(documentType) &&\n parts.every((part: KYCFile) => Boolean(part.data)) &&\n parts.length < MAX_EXTRA_PARTS_COUNT &&\n parts.length > 0;\n\nconst canRemoveExtraPart = (documentType: DocumentType, parts: KYCFile[]): boolean =>\n AVAILABLE_EXTRA_PARTS_DOCUMENTS.includes(documentType) && parts.length > 1;\n\nconst getMimeType = (partData: KYCFileData): string | undefined => partData?.match(/[^:]\\w+\\/[\\w-+\\d.]+(?=;|,)/)?.[0];\n\nconst isPDF = (partData: KYCFileData): boolean => {\n const mimeType: string | undefined = getMimeType(partData);\n return mimeType === PDF_MIME_TYPE;\n};\n\nconst isHEIC = (partData: KYCFileData): boolean => {\n const mimeType: string | undefined = getMimeType(partData);\n return mimeType === HEIC_MIME_TYPE;\n};\n\nconst isFileUniqueInDocument = (file: KYCFile, parts: KYCFile[]): boolean =>\n parts.every((part: KYCFile) => part.data !== file?.data);\n\nconst getFileBase64 = async (file: File): Promise<string> => {\n const reader: FileReader = new FileReader();\n\n return new Promise<string>((resolve, reject) => {\n reader.onload = () => resolve(reader.result as string);\n reader.onerror = (error) => reject(error);\n\n reader.readAsDataURL(file);\n });\n};\n\nexport {\n canAddExtraPart,\n canRemoveExtraPart,\n getFileBase64,\n isDocumentExtraPartAvailable,\n isFileUniqueInDocument,\n isHEIC,\n isPDF,\n};\n","import styled from 'styled-components';\nimport {borderRadius, spacing, gray95, white} from '@propellerads/stylevariables';\n\nconst StyledKYCFormItem = styled.div`\n margin-top: ${spacing * 4}px;\n margin-left: ${spacing * 4}px;\n`;\n\nconst StyledKYCFormItemFileTitle = styled.div`\n margin-bottom: ${spacing}px;\n`;\n\nconst StyledKYCFormItemFilePreview = styled.div`\n display: flex;\n align-items: center;\n background-color: ${gray95};\n padding: ${spacing * 2}px;\n border-radius: ${borderRadius}px;\n`;\n\nconst StyledKYCFormItemFilePreviewName = styled.span`\n width: 100%;\n margin-left: ${spacing * 4}px;\n margin-right: ${spacing * 2}px;\n`;\n\nconst StyledKYCFormItemFilePreviewRemove = styled.span`\n cursor: pointer !important;\n margin-right: ${spacing * 2}px;\n`;\n\nconst StyledKYCFormItemFileUploaderContainer = styled.div`\n height: 66px;\n`;\n\nconst StyledKYCFormItemFileExtraPart = styled.div`\n display: flex;\n flex-direction: column;\n margin-top: ${spacing * 4}px;\n margin-left: ${spacing * 4}px;\n`;\n\nconst StyledKYCDocumentPartImgMiniature = styled.img`\n width: auto;\n max-width: 204px;\n height: 50px;\n object-fit: contain;\n border-radius: ${borderRadius}px;\n`;\n\nconst StyledKYCDocumentPartIconMiniature = styled.div`\n display: flex;\n align-items: center;\n justify-content: center;\n min-width: 50px;\n height: 50px;\n border-radius: ${borderRadius}px;\n background-color: ${white};\n`;\n\nexport {\n StyledKYCFormItem,\n StyledKYCFormItemFilePreview,\n StyledKYCFormItemFilePreviewName,\n StyledKYCFormItemFilePreviewRemove,\n StyledKYCFormItemFileTitle,\n StyledKYCFormItemFileUploaderContainer,\n StyledKYCFormItemFileExtraPart,\n StyledKYCDocumentPartImgMiniature,\n StyledKYCDocumentPartIconMiniature,\n};\n","import {Color, Delete, Insert, Pdf} from '@propellerads/icon';\nimport ImageUploader, {Direction} from '@propellerads/image-uploader';\nimport {Textarea} from '@propellerads/input';\nimport {ACCEPT_FORMATS, MAX_FILE_SIZE} from '../constants';\nimport KYCErrorLabel from '../KYCErrorLabel';\nimport {isHEIC, isPDF} from '../utils';\nimport {\n StyledKYCDocumentPartIconMiniature,\n StyledKYCDocumentPartImgMiniature,\n StyledKYCFormItem,\n StyledKYCFormItemFileExtraPart,\n StyledKYCFormItemFilePreview,\n StyledKYCFormItemFilePreviewName,\n StyledKYCFormItemFilePreviewRemove,\n StyledKYCFormItemFileTitle,\n StyledKYCFormItemFileUploaderContainer,\n} from './style';\nimport {\n KYCDocumentPartMiniatureProps,\n KYCFormItemFileExtraPartProps,\n KYCFormItemFileProps,\n KYCFormItemTextProps,\n} from './types';\n\nconst KYCDocumentPartMiniature = (props: KYCDocumentPartMiniatureProps) => {\n const {data} = props;\n const isPDFPart: boolean = isPDF(data);\n const isHEICPart: boolean = isHEIC(data);\n\n if (isPDFPart || isHEICPart) {\n return (\n <StyledKYCDocumentPartIconMiniature>\n {isPDFPart && <Pdf color={Color.Gray} hoverColor={Color.Gray} />}\n {isHEICPart && <Insert color={Color.Gray} hoverColor={Color.Gray} />}\n </StyledKYCDocumentPartIconMiniature>\n );\n }\n\n return <StyledKYCDocumentPartImgMiniature src={data} />;\n};\n\nconst KYCFormItemFileExtraPart = (props: KYCFormItemFileExtraPartProps) => {\n const {elementId, title, uploaderLabels, onFileAdd} = props;\n const handleDrop = (files: File[]) => {\n const [file] = files;\n\n if (file) {\n onFileAdd(file);\n }\n };\n\n return (\n <StyledKYCFormItemFileExtraPart id={elementId}>\n {title && <StyledKYCFormItemFileTitle>{title}</StyledKYCFormItemFileTitle>}\n\n <StyledKYCFormItemFileUploaderContainer>\n <ImageUploader\n title={uploaderLabels.title}\n action={uploaderLabels.action}\n maxSize={MAX_FILE_SIZE}\n acceptFormats={ACCEPT_FORMATS}\n elementId={`${elementId}_uploader`}\n direction={Direction.Row}\n onDrop={handleDrop}\n />\n </StyledKYCFormItemFileUploaderContainer>\n </StyledKYCFormItemFileExtraPart>\n );\n};\n\nconst KYCFormItemFile = (props: KYCFormItemFileProps) => {\n const {name, title, data, error, elementId, uploaderLabels, onFileChange, onFileRemove} = props;\n const handleDrop = (files: File[]) => {\n const [file] = files;\n\n if (file) {\n onFileChange(file);\n }\n };\n\n return (\n <StyledKYCFormItem id={elementId}>\n {title && <StyledKYCFormItemFileTitle>{title}</StyledKYCFormItemFileTitle>}\n\n {data ? (\n <StyledKYCFormItemFilePreview>\n <KYCDocumentPartMiniature data={data} />\n <StyledKYCFormItemFilePreviewName>{name}</StyledKYCFormItemFilePreviewName>\n <StyledKYCFormItemFilePreviewRemove onClick={onFileRemove}>\n <Delete color={Color.Blue} hoverColor={Color.Blue} />\n </StyledKYCFormItemFilePreviewRemove>\n </StyledKYCFormItemFilePreview>\n ) : (\n <StyledKYCFormItemFileUploaderContainer>\n <ImageUploader\n title={uploaderLabels.title}\n action={uploaderLabels.action}\n maxSize={MAX_FILE_SIZE}\n acceptFormats={ACCEPT_FORMATS}\n elementId={`${elementId}_uploader`}\n direction={Direction.Row}\n onDrop={handleDrop}\n />\n </StyledKYCFormItemFileUploaderContainer>\n )}\n\n {error && <KYCErrorLabel label={error} isDocumentPartError />}\n </StyledKYCFormItem>\n );\n};\n\nconst KYCFormItemText = (props: KYCFormItemTextProps) => {\n const {onFeedbackChange, value = ''} = props;\n\n return (\n <StyledKYCFormItem>\n <Textarea\n onChange={(event) => onFeedbackChange(event.target.value)}\n onBlur={(event) => onFeedbackChange(event.target.value)}\n value={value}\n rows={5}\n name=\"kyc-client-comments\"\n id=\"kyc-feedback-textarea\"\n aria-label=\"Comments\"\n />\n </StyledKYCFormItem>\n );\n};\n\nexport default {\n KYCFormItemFileExtraPart,\n KYCFormItemFile,\n KYCFormItemText,\n};\n","import styled from 'styled-components';\nimport {fontNormal, fontSmall, spacing, gray50, black} from '@propellerads/stylevariables';\n\nconst StyledKYCFormItem = styled.div`\n margin-top: ${spacing * 6}px;\n`;\n\nconst StyledKYCFormItemTitle = styled.div`\n font-size: ${fontNormal}px;\n font-weight: bold;\n color: ${black};\n margin-bottom: ${spacing}px;\n`;\n\nconst StyledKYCFormItemDescription = styled.div`\n font-size: ${fontSmall}px;\n color: ${gray50};\n margin-left: ${spacing * 4}px;\n`;\n\nexport {StyledKYCFormItem, StyledKYCFormItemTitle, StyledKYCFormItemDescription};\n","import {useState} from 'react';\nimport {KYCDocument, KYCFile, KYCFileData, PartType} from '../document.types';\nimport KYCDocumentParts from '../KYCDocumentParts';\nimport {PartLabels, PartsLabels} from '../labels.types';\nimport {canAddExtraPart, getFileBase64, isDocumentExtraPartAvailable, isFileUniqueInDocument} from '../utils';\nimport {StyledKYCFormItem, StyledKYCFormItemDescription, StyledKYCFormItemTitle} from './style';\nimport {KYCFormItemProps} from './types';\n\nconst getErrorKey = (documentIndex: number, partIndex: number) => `[${documentIndex}].parts[${partIndex}].data`;\n\nconst KYCFormItem = (props: KYCFormItemProps) => {\n const {type, index, uploaderLabels, documentLabels, elementId, parts, errors, onDocumentChange} = props;\n const [localErrors, setLocalErrors] = useState<Map<string, string>>(new Map<string, string>());\n\n const isAddExtraPartAvailable: boolean = canAddExtraPart(type, parts);\n const documentLabelsParts: PartsLabels | undefined = documentLabels?.parts;\n const firstPart = parts[0];\n const extraPartTitle = firstPart ? documentLabelsParts?.[firstPart.type]?.title : undefined;\n\n const [fileNames, setFileNames] = useState<Map<string, string>>(new Map<string, string>());\n\n const setLocalErrorByPartIndex = (partIndex: number) => {\n const newLocalErrors = new Map<string, string>(localErrors);\n newLocalErrors.set(getErrorKey(index, partIndex), uploaderLabels.oversizeError);\n setLocalErrors(newLocalErrors);\n };\n\n const deleteLocalErrorByPartIndex = (partIndex: number) => {\n const newLocalErrors = new Map<string, string>(localErrors);\n newLocalErrors.delete(getErrorKey(index, partIndex));\n setLocalErrors(newLocalErrors);\n };\n\n const updateDocumentPart = (part: KYCFile, partIndex: number, data?: KYCFileData) => {\n const newPart: KYCFile = {\n ...part,\n data,\n };\n\n const newParts: KYCFile[] = [...parts];\n newParts.splice(partIndex, 1, newPart);\n\n const newDocument: KYCDocument = {\n type,\n parts: newParts,\n };\n\n onDocumentChange(newDocument);\n };\n\n const onFileChange = async (partIndex: number, file: File) => {\n if (!file) {\n setLocalErrorByPartIndex(partIndex);\n return;\n }\n\n const part = parts[partIndex] ?? parts[0];\n\n if (!part) {\n return;\n }\n\n const data: string = await getFileBase64(file);\n\n updateDocumentPart(part, partIndex, data);\n\n const newFileNames = new Map<string, string>(fileNames);\n newFileNames.set(data, file.name);\n setFileNames(newFileNames);\n\n deleteLocalErrorByPartIndex(partIndex);\n };\n\n const onFileRemove = (partIndex: number) => {\n const part = parts[partIndex];\n\n if (!part) {\n return;\n }\n\n updateDocumentPart(part, partIndex);\n\n const removedPart = parts[partIndex];\n const newFileNames = new Map<string, string>(fileNames);\n\n if (removedPart?.data && isFileUniqueInDocument(removedPart, parts)) {\n newFileNames.delete(removedPart?.data);\n }\n\n setFileNames(newFileNames);\n\n deleteLocalErrorByPartIndex(partIndex);\n };\n\n const getFileName = (key: string | undefined): string | undefined => {\n if (!key) {\n return undefined;\n }\n\n return fileNames.get(key);\n };\n\n const onFeedbackChange = (partIndex: number, data: string) => {\n const part = parts[partIndex] ?? parts[0];\n\n if (!part) {\n return;\n }\n\n updateDocumentPart(part, partIndex, data);\n };\n\n return (\n <StyledKYCFormItem id={elementId}>\n <StyledKYCFormItemTitle>{`${index + 1}. ${documentLabels?.title}`}</StyledKYCFormItemTitle>\n\n {documentLabels?.description && (\n <StyledKYCFormItemDescription>{documentLabels?.description}</StyledKYCFormItemDescription>\n )}\n\n {parts.map((part, partIndex) => {\n let itemKey = `kyc-form_item_file_${part.type}`;\n\n const isExtraPartAvailable: boolean = isDocumentExtraPartAvailable(type);\n const partLabels: PartLabels | undefined = documentLabelsParts?.[part.type];\n const partTitle = isExtraPartAvailable ? undefined : partLabels?.title;\n\n if (isDocumentExtraPartAvailable(type) && part.data) {\n itemKey = `${itemKey}_${part.data?.substr(-32)}`;\n\n if (!isFileUniqueInDocument(part, parts)) {\n itemKey = `${itemKey}_${partIndex}`;\n }\n }\n\n const partError = errors?.[getErrorKey(index, partIndex)];\n const localPartError = localErrors.get(getErrorKey(index, partIndex));\n\n if (part.type === PartType.Feedback) {\n return (\n <KYCDocumentParts.KYCFormItemText\n key={itemKey}\n value={part.data}\n onFeedbackChange={(value) => onFeedbackChange(partIndex, value)}\n />\n );\n }\n\n return (\n <KYCDocumentParts.KYCFormItemFile\n title={partTitle}\n data={part.data}\n type={part.type}\n name={getFileName(part.data)}\n uploaderLabels={uploaderLabels}\n error={localPartError || partError}\n key={itemKey}\n elementId={`${elementId}_part_${part.type}_${partIndex}`}\n onFileChange={(file) => onFileChange(partIndex, file)}\n onFileRemove={() => onFileRemove(partIndex)}\n />\n );\n })}\n\n {isAddExtraPartAvailable && firstPart && (\n <KYCDocumentParts.KYCFormItemFileExtraPart\n elementId={`${elementId}_extra`}\n title={extraPartTitle}\n uploaderLabels={uploaderLabels}\n onFileAdd={(file) => onFileChange(parts.length, file)}\n />\n )}\n </StyledKYCFormItem>\n );\n};\n\nexport default KYCFormItem;\n","import styled from 'styled-components';\nimport {spacing, gray50} from '@propellerads/stylevariables';\n\nconst StyledKYCSucessScreen = styled.div`\n display: flex;\n flex-direction: column;\n`;\n\nconst StyledKYCSucessScreenItem = styled.span`\n margin-bottom: ${spacing * 8}px;\n`;\n\nconst StyledKYCSucessScreenSuppport = styled.span`\n color: ${gray50};\n`;\n\nconst StyledKYCFailScreen = styled.div`\n display: flex;\n flex-direction: column;\n`;\n\nconst StyledKYCFailScreenItem = styled.span`\n margin-bottom: ${spacing * 6}px;\n`;\n\nexport {\n StyledKYCSucessScreen,\n StyledKYCSucessScreenItem,\n StyledKYCSucessScreenSuppport,\n StyledKYCFailScreen,\n StyledKYCFailScreenItem,\n};\n","import SuccessLabel from '@propellerads/success-label';\nimport {\n ACCEPT_FORMATS,\n AVAILABLE_EXTRA_PARTS_DOCUMENTS,\n MAX_EXTRA_PARTS_COUNT,\n MAX_FILE_SIZE,\n PDF_MIME_TYPE,\n} from '../constants';\nimport KYCErrorLabel from '../KYCErrorLabel';\nimport {\n StyledKYCFailScreen,\n StyledKYCFailScreenItem,\n StyledKYCSucessScreen,\n StyledKYCSucessScreenItem,\n StyledKYCSucessScreenSuppport,\n} from './style';\nimport {KYCFailScreenProps, KYCSuccessScreenProps} from './types';\n\nconst KYCSuccessScreen = (props: KYCSuccessScreenProps) => {\n const {elementId, title, description, support} = props;\n\n return (\n <StyledKYCSucessScreen id={elementId}>\n <StyledKYCSucessScreenItem>\n <SuccessLabel show elementId={`${elementId}_success`}>\n {title}\n </SuccessLabel>\n </StyledKYCSucessScreenItem>\n\n {description && <StyledKYCSucessScreenItem>{description}</StyledKYCSucessScreenItem>}\n\n {support && <StyledKYCSucessScreenSuppport>{support}</StyledKYCSucessScreenSuppport>}\n </StyledKYCSucessScreen>\n );\n};\n\nconst KYCFailScreen = (props: KYCFailScreenProps) => {\n const {elementId, title, support} = props;\n\n return (\n <StyledKYCFailScreen id={elementId}>\n <StyledKYCFailScreenItem>\n <KYCErrorLabel label={title} isDocumentPartError={false} />\n </StyledKYCFailScreenItem>\n\n {support}\n </StyledKYCFailScreen>\n );\n};\n\nexport default {\n KYCSuccessScreen,\n KYCFailScreen,\n};\n\nexport {ACCEPT_FORMATS, AVAILABLE_EXTRA_PARTS_DOCUMENTS, MAX_EXTRA_PARTS_COUNT, MAX_FILE_SIZE, PDF_MIME_TYPE};\n","import styled from 'styled-components';\nimport {fontNormal, spacing} from '@propellerads/stylevariables';\n\nconst StyledKYCForm = styled.div`\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n width: 100%;\n`;\n\nconst StyledKYCFormTitle = styled.div`\n font-size: ${fontNormal}px;\n`;\n\nconst StyledKYCFormDocuments = styled.div`\n width: 100%;\n margin-bottom: ${spacing * 6}px;\n`;\n\nconst StyledKYCFormButton = styled.div`\n display: flex;\n justify-content: flex-end;\n width: 100%;\n`;\n\nexport {StyledKYCForm, StyledKYCFormTitle, StyledKYCFormDocuments, StyledKYCFormButton};\n","import Button, {ButtonVariant} from '@propellerads/button';\nimport {useEffect, useState} from 'react';\nimport {\n ACCEPT_FORMATS,\n AVAILABLE_EXTRA_PARTS_DOCUMENTS,\n MAX_EXTRA_PARTS_COUNT,\n MAX_FILE_SIZE,\n OPTIONAL_DOCUMENT_PARTS,\n PDF_MIME_TYPE,\n} from './constants';\nimport {DocumentType, KYCDocument, PartType, KYCFile} from './document.types';\nimport KYCFormItem from './KYCFormItem';\nimport KYCStatusScreen from './KYCStatusScreen';\nimport {StyledKYCForm, StyledKYCFormButton, StyledKYCFormDocuments, StyledKYCFormTitle} from './style';\nimport {KYCFormProps} from './types';\n\nconst KYCForm = (props: KYCFormProps) => {\n const {\n elementId,\n title,\n uploadButtonLabel,\n uploaderLabels,\n documentsLabels,\n documents,\n errors,\n isLoading,\n validator,\n onUploadClick,\n } = props;\n\n const [userDocuments, setUserDocuments] = useState<KYCDocument[]>(documents);\n const [isButtonDisabled, setButtonDisabled] = useState<boolean>(true);\n\n useEffect(() => {\n setUserDocuments(documents);\n }, [documents]);\n\n useEffect(() => {\n const isValid: boolean = validator(userDocuments);\n setButtonDisabled(!isValid);\n }, [userDocuments, validator]);\n\n const onDocumentChange = (index: number, document: KYCDocument) => {\n const newDocuments: KYCDocument[] = [...userDocuments];\n newDocuments.splice(index, 1, document);\n\n setUserDocuments(newDocuments);\n };\n\n return (\n <StyledKYCForm id={elementId}>\n {title && <StyledKYCFormTitle>{title}</StyledKYCFormTitle>}\n\n <StyledKYCFormDocuments>\n {userDocuments.map((document, index) => {\n const key = `kyc-form_item_${document.type}_${index}`;\n\n return (\n <KYCFormItem\n index={index}\n type={document.type}\n parts={document.parts}\n documentLabels={documentsLabels[document.type]}\n uploaderLabels={uploaderLabels}\n errors={errors}\n elementId={`${elementId}_item_${document.type}`}\n key={key}\n onDocumentChange={(doc) => onDocumentChange(index, doc)}\n />\n );\n })}\n </StyledKYCFormDocuments>\n <StyledKYCFormButton>\n <Button\n id={`${elementId}_button`}\n variant={ButtonVariant.Primary}\n isDisabled={isButtonDisabled}\n isLoading={isLoading || false}\n onClick={() => onUploadClick(userDocuments)}\n >\n {uploadButtonLabel}\n </Button>\n </StyledKYCFormButton>\n </StyledKYCForm>\n );\n};\n\nKYCForm.SuccessScreen = KYCStatusScreen.KYCSuccessScreen;\nKYCForm.FailScreen = KYCStatusScreen.KYCFailScreen;\n\nexport default KYCForm;\n\nexport {\n ACCEPT_FORMATS,\n AVAILABLE_EXTRA_PARTS_DOCUMENTS,\n DocumentType,\n MAX_EXTRA_PARTS_COUNT,\n MAX_FILE_SIZE,\n OPTIONAL_DOCUMENT_PARTS,\n PartType,\n PDF_MIME_TYPE,\n};\nexport type {KYCDocument, KYCFile};\n"],"mappings":";;;;;;;;;;AAAA,IAAa,IAAe;CAC1B,IAAI;CACJ,IAAI;CACJ,SAAS;CACT,MAAM;CACN,qBAAqB;CACrB,wBAAwB;CACxB,6BAA6B;CAC7B,kBAAkB;CAClB,mBAAmB;CACnB,iBAAiB;CACjB,yBAAyB;CACzB,OAAO;CACP,UAAU;CACX,EAGY,IAAW;CACtB,SAAS;CACT,QAAQ;CACR,IAAI;CACJ,MAAM;CACN,qBAAqB;CACrB,wBAAwB;CACxB,6BAA6B;CAC7B,kBAAkB;CAClB,wBAAwB;CACxB,qBAAqB;CACrB,8BAA8B;CAC9B,YAAY;CACZ,UAAU;CACX,EC5BY,IAAgB,SAEhB,KAAwB,GAExB,IAAgB,mBAChB,IAAiB,cACjB,IAAsD;CACjE,aAAa,CAAC,OAAO;CACrB,cAAc;EAAC;EAAQ;EAAQ;EAAQ;EACtC,IAAgB,CAAC,OAAO;EACxB,IAAiB,CAAC,QAAQ;CAC5B,EAEY,IAAkD;CAC7D,EAAa;CACb,EAAa;CACb,EAAa;CACb,EAAa;CACb,EAAa;CACb,EAAa;CACb,EAAa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,WACA,cACA,cACA,qBACE,GAEE,CAAC,GAAe,KAAoB,EAAwB,EAAU,EACtE,CAAC,GAAkB,KAAqB,EAAkB,GAAK;CAMrE,AAJA,QAAgB;EACd,EAAiB,EAAU;IAC1B,CAAC,EAAU,CAAC,EAEf,QAAgB;EAEd,EAAkB,CADO,EAAU,EAChB,CAAQ;IAC1B,CAAC,GAAe,EAAU,CAAC;CAE9B,IAAM,KAAoB,GAAe,MAA0B;EACjE,IAAM,IAA8B,CAAC,GAAG,EAAc;EAGtD,AAFA,EAAa,OAAO,GAAO,GAAG,EAAS,EAEvC,EAAiB,EAAa;;CAGhC,OACE,kBAAC,IAAD;EAAe,IAAI;YAAnB;GACG,KAAS,kBAAC,IAAD,EAAA,UAAqB,GAA2B,CAAA;GAE1D,kBAAC,IAAD,EAAA,UACG,EAAc,KAAK,GAAU,MAAU;IACtC,IAAM,IAAM,iBAAiB,EAAS,KAAK,GAAG;IAE9C,OACE,kBAAC,IAAD;KACS;KACP,MAAM,EAAS;KACf,OAAO,EAAS;KAChB,gBAAgB,EAAgB,EAAS;KACzB;KACR;KACR,WAAW,GAAG,EAAU,QAAQ,EAAS;KAEzC,mBAAmB,MAAQ,EAAiB,GAAO,EAAI;KACvD,EAFK,EAEL;KAEJ,EACqB,CAAA;GACzB,kBAAC,IAAD,EAAA,UACE,kBAAC,GAAD;IACE,IAAI,GAAG,EAAU;IACjB,SAAS,EAAc;IACvB,YAAY;IACZ,WAAW,KAAa;IACxB,eAAe,EAAc,EAAc;cAE1C;IACM,CAAA,EACW,CAAA;GACR;;;AAIpB,EAAQ,gBAAgB,EAAgB,kBACxC,EAAQ,aAAa,EAAgB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/document.types.ts","../src/constants.ts","../src/KYCErrorLabel/style.tsx","../src/KYCErrorLabel/index.tsx","../src/utils.ts","../src/KYCDocumentParts/style.tsx","../src/KYCDocumentParts/index.tsx","../src/KYCFormItem/style.tsx","../src/KYCFormItem/index.tsx","../src/KYCStatusScreen/style.tsx","../src/KYCStatusScreen/index.tsx","../src/style.tsx","../src/index.tsx"],"sourcesContent":["export const DocumentType = {\n Id: 'id',\n Ub: 'ub',\n IdExtra: 'id_extra',\n Card: 'bank_card',\n PaymentSystemScreen: 'payment_system_screen',\n OnlineBankingStatement: 'online_banking_statement',\n CompanyRegistrationDocument: 'company_registration_document',\n SelfieWithIdCard: 'selfie_with_id_card_or_bank_card',\n PaypalDetailsPage: 'pay_pal_details_page',\n BankWireDetails: 'bank_wire_details',\n TransactionConfirmation: 'transaction_confirmation',\n Other: 'other',\n Feedback: 'feedback',\n} as const;\nexport type DocumentType = (typeof DocumentType)[keyof typeof DocumentType];\n\nexport const PartType = {\n IdFront: 'id_front',\n IdBack: 'id_back',\n Ub: 'ub_item',\n Card: 'card_item',\n PaymentSystemScreen: 'screen_item',\n OnlineBankingStatement: 'obs_item',\n CompanyRegistrationDocument: 'crd_item',\n SelfieWithIdCard: 'selfie_item',\n PaypalDetailsPageImage: 'pay_pal_details_page_image',\n BankWireDetailsPage: 'bank_wire_details_image',\n TransactionConfirmationImage: 'transaction_confirmation_image',\n OtherImage: 'other_image',\n Feedback: 'feedback',\n} as const;\nexport type PartType = (typeof PartType)[keyof typeof PartType];\n\nexport type KYCFileData = string | undefined;\n\nexport type KYCFile = {\n type: PartType;\n data?: KYCFileData;\n};\n\nexport type KYCDocument = {\n type: DocumentType;\n parts: KYCFile[];\n};\n","import type {ImageUploaderProps} from '@propellerads/image-uploader';\nimport {DocumentType, PartType} from './document.types';\n\nexport const MAX_FILE_SIZE = 5242880;\n\nexport const MAX_EXTRA_PARTS_COUNT = 3;\n\nexport const PDF_MIME_TYPE = 'application/pdf';\nexport const HEIC_MIME_TYPE = 'image/heic';\nexport const ACCEPT_FORMATS: ImageUploaderProps['acceptFormats'] = {\n 'image/png': ['.png'],\n 'image/jpeg': ['.jpg', '.jpe', '.jpeg'],\n [PDF_MIME_TYPE]: ['.pdf'],\n [HEIC_MIME_TYPE]: ['.heic'],\n};\n\nexport const AVAILABLE_EXTRA_PARTS_DOCUMENTS: DocumentType[] = [\n DocumentType.Card,\n DocumentType.Card,\n DocumentType.PaypalDetailsPage,\n DocumentType.BankWireDetails,\n DocumentType.TransactionConfirmation,\n DocumentType.SelfieWithIdCard,\n DocumentType.PaymentSystemScreen,\n DocumentType.Other,\n];\n\nexport const OPTIONAL_DOCUMENT_PARTS = {\n [DocumentType.Id]: {\n parts: [PartType.IdBack],\n },\n [DocumentType.IdExtra]: {\n parts: [PartType.IdBack],\n },\n};\n","import styled from 'styled-components';\nimport {fontSmall, spacing, white, errorColor} from '@propellerads/stylevariables';\n\nconst StyledKYCErrorLabel = styled.div`\n display: flex;\n align-items: center;\n color: ${errorColor};\n margin-top: ${spacing * 2}px;\n margin-bottom: ${spacing * 4}px;\n`;\n\nconst StyledKYCErrorLabelIcon = styled.span`\n display: flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n border-radius: 100%;\n background-color: ${errorColor};\n\n &:before {\n font-size: ${fontSmall};\n color: ${white};\n content: '!';\n }\n`;\n\nconst StyledKYCErrorLabelText = styled.span`\n margin-left: ${spacing * 2}px;\n`;\n\nexport {StyledKYCErrorLabel, StyledKYCErrorLabelIcon, StyledKYCErrorLabelText};\n","import {Close, Color, Size} from '@propellerads/icon';\nimport {StyledKYCErrorLabel, StyledKYCErrorLabelIcon, StyledKYCErrorLabelText} from './style';\nimport {KYCErrorLabelProps} from './types';\n\nconst KYCErrorLabel = (props: KYCErrorLabelProps) => (\n <StyledKYCErrorLabel>\n {props.isDocumentPartError ? (\n <StyledKYCErrorLabelIcon />\n ) : (\n <Close color={Color.Error} hoverColor={Color.Error} size={Size.Small} />\n )}\n <StyledKYCErrorLabelText>{props.label}</StyledKYCErrorLabelText>\n </StyledKYCErrorLabel>\n);\n\nexport default KYCErrorLabel;\n","import {AVAILABLE_EXTRA_PARTS_DOCUMENTS, HEIC_MIME_TYPE, MAX_EXTRA_PARTS_COUNT, PDF_MIME_TYPE} from './constants';\nimport {DocumentType, KYCFile, KYCFileData} from './document.types';\n\nconst isDocumentExtraPartAvailable = (documentType: DocumentType): boolean =>\n AVAILABLE_EXTRA_PARTS_DOCUMENTS.includes(documentType);\n\nconst canAddExtraPart = (documentType: DocumentType, parts: KYCFile[]): boolean =>\n isDocumentExtraPartAvailable(documentType) &&\n parts.every((part: KYCFile) => Boolean(part.data)) &&\n parts.length < MAX_EXTRA_PARTS_COUNT &&\n parts.length > 0;\n\nconst canRemoveExtraPart = (documentType: DocumentType, parts: KYCFile[]): boolean =>\n AVAILABLE_EXTRA_PARTS_DOCUMENTS.includes(documentType) && parts.length > 1;\n\nconst getMimeType = (partData: KYCFileData): string | undefined => partData?.match(/[^:]\\w+\\/[\\w-+\\d.]+(?=;|,)/)?.[0];\n\nconst isPDF = (partData: KYCFileData): boolean => {\n const mimeType: string | undefined = getMimeType(partData);\n return mimeType === PDF_MIME_TYPE;\n};\n\nconst isHEIC = (partData: KYCFileData): boolean => {\n const mimeType: string | undefined = getMimeType(partData);\n return mimeType === HEIC_MIME_TYPE;\n};\n\nconst isFileUniqueInDocument = (file: KYCFile, parts: KYCFile[]): boolean =>\n parts.every((part: KYCFile) => part.data !== file?.data);\n\nconst getFileBase64 = async (file: File): Promise<string> => {\n const reader: FileReader = new FileReader();\n\n return new Promise<string>((resolve, reject) => {\n reader.onload = () => resolve(reader.result as string);\n reader.onerror = (error) => reject(error);\n\n reader.readAsDataURL(file);\n });\n};\n\nexport {\n canAddExtraPart,\n canRemoveExtraPart,\n getFileBase64,\n isDocumentExtraPartAvailable,\n isFileUniqueInDocument,\n isHEIC,\n isPDF,\n};\n","import styled from 'styled-components';\nimport {borderRadius, spacing, gray95, white} from '@propellerads/stylevariables';\n\nconst StyledKYCFormItem = styled.div`\n margin-top: ${spacing * 4}px;\n margin-left: ${spacing * 4}px;\n`;\n\nconst StyledKYCFormItemFileTitle = styled.div`\n margin-bottom: ${spacing}px;\n`;\n\nconst StyledKYCFormItemFilePreview = styled.div`\n display: flex;\n align-items: center;\n background-color: ${gray95};\n padding: ${spacing * 2}px;\n border-radius: ${borderRadius}px;\n`;\n\nconst StyledKYCFormItemFilePreviewName = styled.span`\n width: 100%;\n margin-left: ${spacing * 4}px;\n margin-right: ${spacing * 2}px;\n`;\n\nconst StyledKYCFormItemFilePreviewRemove = styled.span`\n cursor: pointer !important;\n margin-right: ${spacing * 2}px;\n`;\n\nconst StyledKYCFormItemFileUploaderContainer = styled.div`\n height: 66px;\n`;\n\nconst StyledKYCFormItemFileExtraPart = styled.div`\n display: flex;\n flex-direction: column;\n margin-top: ${spacing * 4}px;\n margin-left: ${spacing * 4}px;\n`;\n\nconst StyledKYCDocumentPartImgMiniature = styled.img`\n width: auto;\n max-width: 204px;\n height: 50px;\n object-fit: contain;\n border-radius: ${borderRadius}px;\n`;\n\nconst StyledKYCDocumentPartIconMiniature = styled.div`\n display: flex;\n align-items: center;\n justify-content: center;\n min-width: 50px;\n height: 50px;\n border-radius: ${borderRadius}px;\n background-color: ${white};\n`;\n\nexport {\n StyledKYCFormItem,\n StyledKYCFormItemFilePreview,\n StyledKYCFormItemFilePreviewName,\n StyledKYCFormItemFilePreviewRemove,\n StyledKYCFormItemFileTitle,\n StyledKYCFormItemFileUploaderContainer,\n StyledKYCFormItemFileExtraPart,\n StyledKYCDocumentPartImgMiniature,\n StyledKYCDocumentPartIconMiniature,\n};\n","import {Color, Delete, Insert, Pdf} from '@propellerads/icon';\nimport ImageUploader, {Direction} from '@propellerads/image-uploader';\nimport {Textarea} from '@propellerads/input';\nimport {ACCEPT_FORMATS, MAX_FILE_SIZE} from '../constants';\nimport KYCErrorLabel from '../KYCErrorLabel';\nimport {isHEIC, isPDF} from '../utils';\nimport {\n StyledKYCDocumentPartIconMiniature,\n StyledKYCDocumentPartImgMiniature,\n StyledKYCFormItem,\n StyledKYCFormItemFileExtraPart,\n StyledKYCFormItemFilePreview,\n StyledKYCFormItemFilePreviewName,\n StyledKYCFormItemFilePreviewRemove,\n StyledKYCFormItemFileTitle,\n StyledKYCFormItemFileUploaderContainer,\n} from './style';\nimport {\n KYCDocumentPartMiniatureProps,\n KYCFormItemFileExtraPartProps,\n KYCFormItemFileProps,\n KYCFormItemTextProps,\n} from './types';\n\nconst KYCDocumentPartMiniature = (props: KYCDocumentPartMiniatureProps) => {\n const {data} = props;\n const isPDFPart: boolean = isPDF(data);\n const isHEICPart: boolean = isHEIC(data);\n\n if (isPDFPart || isHEICPart) {\n return (\n <StyledKYCDocumentPartIconMiniature>\n {isPDFPart && <Pdf color={Color.Gray} hoverColor={Color.Gray} />}\n {isHEICPart && <Insert color={Color.Gray} hoverColor={Color.Gray} />}\n </StyledKYCDocumentPartIconMiniature>\n );\n }\n\n return <StyledKYCDocumentPartImgMiniature src={data} />;\n};\n\nconst KYCFormItemFileExtraPart = (props: KYCFormItemFileExtraPartProps) => {\n const {elementId, title, uploaderLabels, onFileAdd} = props;\n const handleDrop = (files: File[]) => {\n const [file] = files;\n\n if (file) {\n onFileAdd(file);\n }\n };\n\n return (\n <StyledKYCFormItemFileExtraPart id={elementId}>\n {title && <StyledKYCFormItemFileTitle>{title}</StyledKYCFormItemFileTitle>}\n\n <StyledKYCFormItemFileUploaderContainer>\n <ImageUploader\n title={uploaderLabels.title}\n action={uploaderLabels.action}\n maxSize={MAX_FILE_SIZE}\n acceptFormats={ACCEPT_FORMATS}\n elementId={`${elementId}_uploader`}\n direction={Direction.Row}\n onDrop={handleDrop}\n />\n </StyledKYCFormItemFileUploaderContainer>\n </StyledKYCFormItemFileExtraPart>\n );\n};\n\nconst KYCFormItemFile = (props: KYCFormItemFileProps) => {\n const {name, title, data, error, elementId, uploaderLabels, onFileChange, onFileRemove} = props;\n const handleDrop = (files: File[]) => {\n const [file] = files;\n\n if (file) {\n onFileChange(file);\n }\n };\n\n return (\n <StyledKYCFormItem id={elementId}>\n {title && <StyledKYCFormItemFileTitle>{title}</StyledKYCFormItemFileTitle>}\n\n {data ? (\n <StyledKYCFormItemFilePreview>\n <KYCDocumentPartMiniature data={data} />\n <StyledKYCFormItemFilePreviewName>{name}</StyledKYCFormItemFilePreviewName>\n <StyledKYCFormItemFilePreviewRemove onClick={onFileRemove}>\n <Delete color={Color.Blue} hoverColor={Color.Blue} />\n </StyledKYCFormItemFilePreviewRemove>\n </StyledKYCFormItemFilePreview>\n ) : (\n <StyledKYCFormItemFileUploaderContainer>\n <ImageUploader\n title={uploaderLabels.title}\n action={uploaderLabels.action}\n maxSize={MAX_FILE_SIZE}\n acceptFormats={ACCEPT_FORMATS}\n elementId={`${elementId}_uploader`}\n direction={Direction.Row}\n onDrop={handleDrop}\n />\n </StyledKYCFormItemFileUploaderContainer>\n )}\n\n {error && <KYCErrorLabel label={error} isDocumentPartError />}\n </StyledKYCFormItem>\n );\n};\n\nconst KYCFormItemText = (props: KYCFormItemTextProps) => {\n const {onFeedbackChange, value = ''} = props;\n\n return (\n <StyledKYCFormItem>\n <Textarea\n onChange={(event) => onFeedbackChange(event.target.value)}\n onBlur={(event) => onFeedbackChange(event.target.value)}\n value={value}\n rows={5}\n name=\"kyc-client-comments\"\n id=\"kyc-feedback-textarea\"\n aria-label=\"Comments\"\n />\n </StyledKYCFormItem>\n );\n};\n\nexport default {\n KYCFormItemFileExtraPart,\n KYCFormItemFile,\n KYCFormItemText,\n};\n","import styled from 'styled-components';\nimport {fontNormal, fontSmall, spacing, gray50, black} from '@propellerads/stylevariables';\n\nconst StyledKYCFormItem = styled.div`\n margin-top: ${spacing * 6}px;\n`;\n\nconst StyledKYCFormItemTitle = styled.div`\n font-size: ${fontNormal}px;\n font-weight: bold;\n color: ${black};\n margin-bottom: ${spacing}px;\n`;\n\nconst StyledKYCFormItemDescription = styled.div`\n font-size: ${fontSmall}px;\n color: ${gray50};\n margin-left: ${spacing * 4}px;\n`;\n\nexport {StyledKYCFormItem, StyledKYCFormItemTitle, StyledKYCFormItemDescription};\n","import {useState} from 'react';\nimport {KYCDocument, KYCFile, KYCFileData, PartType} from '../document.types';\nimport KYCDocumentParts from '../KYCDocumentParts';\nimport {PartLabels, PartsLabels} from '../labels.types';\nimport {canAddExtraPart, getFileBase64, isDocumentExtraPartAvailable, isFileUniqueInDocument} from '../utils';\nimport {StyledKYCFormItem, StyledKYCFormItemDescription, StyledKYCFormItemTitle} from './style';\nimport {KYCFormItemProps} from './types';\n\nconst getErrorKey = (documentIndex: number, partIndex: number) => `[${documentIndex}].parts[${partIndex}].data`;\n\nconst KYCFormItem = (props: KYCFormItemProps) => {\n const {type, index, uploaderLabels, documentLabels, elementId, parts, errors, onDocumentChange} = props;\n const [localErrors, setLocalErrors] = useState<Map<string, string>>(new Map<string, string>());\n\n const isAddExtraPartAvailable: boolean = canAddExtraPart(type, parts);\n const documentLabelsParts: PartsLabels | undefined = documentLabels?.parts;\n const firstPart = parts[0];\n const extraPartTitle = firstPart ? documentLabelsParts?.[firstPart.type]?.title : undefined;\n\n const [fileNames, setFileNames] = useState<Map<string, string>>(new Map<string, string>());\n\n const setLocalErrorByPartIndex = (partIndex: number) => {\n const newLocalErrors = new Map<string, string>(localErrors);\n newLocalErrors.set(getErrorKey(index, partIndex), uploaderLabels.oversizeError);\n setLocalErrors(newLocalErrors);\n };\n\n const deleteLocalErrorByPartIndex = (partIndex: number) => {\n const newLocalErrors = new Map<string, string>(localErrors);\n newLocalErrors.delete(getErrorKey(index, partIndex));\n setLocalErrors(newLocalErrors);\n };\n\n const updateDocumentPart = (part: KYCFile, partIndex: number, data?: KYCFileData) => {\n const newPart: KYCFile = {\n ...part,\n data,\n };\n\n const newParts: KYCFile[] = [...parts];\n newParts.splice(partIndex, 1, newPart);\n\n const newDocument: KYCDocument = {\n type,\n parts: newParts,\n };\n\n onDocumentChange(newDocument);\n };\n\n const onFileChange = async (partIndex: number, file: File) => {\n if (!file) {\n setLocalErrorByPartIndex(partIndex);\n return;\n }\n\n const part = parts[partIndex] ?? parts[0];\n\n if (!part) {\n return;\n }\n\n const data: string = await getFileBase64(file);\n\n updateDocumentPart(part, partIndex, data);\n\n const newFileNames = new Map<string, string>(fileNames);\n newFileNames.set(data, file.name);\n setFileNames(newFileNames);\n\n deleteLocalErrorByPartIndex(partIndex);\n };\n\n const onFileRemove = (partIndex: number) => {\n const part = parts[partIndex];\n\n if (!part) {\n return;\n }\n\n updateDocumentPart(part, partIndex);\n\n const removedPart = parts[partIndex];\n const newFileNames = new Map<string, string>(fileNames);\n\n if (removedPart?.data && isFileUniqueInDocument(removedPart, parts)) {\n newFileNames.delete(removedPart?.data);\n }\n\n setFileNames(newFileNames);\n\n deleteLocalErrorByPartIndex(partIndex);\n };\n\n const getFileName = (key: string | undefined): string | undefined => {\n if (!key) {\n return undefined;\n }\n\n return fileNames.get(key);\n };\n\n const onFeedbackChange = (partIndex: number, data: string) => {\n const part = parts[partIndex] ?? parts[0];\n\n if (!part) {\n return;\n }\n\n updateDocumentPart(part, partIndex, data);\n };\n\n return (\n <StyledKYCFormItem id={elementId}>\n <StyledKYCFormItemTitle>{`${index + 1}. ${documentLabels?.title}`}</StyledKYCFormItemTitle>\n\n {documentLabels?.description && (\n <StyledKYCFormItemDescription>{documentLabels?.description}</StyledKYCFormItemDescription>\n )}\n\n {parts.map((part, partIndex) => {\n let itemKey = `kyc-form_item_file_${part.type}`;\n\n const isExtraPartAvailable: boolean = isDocumentExtraPartAvailable(type);\n const partLabels: PartLabels | undefined = documentLabelsParts?.[part.type];\n const partTitle = isExtraPartAvailable ? undefined : partLabels?.title;\n\n if (isDocumentExtraPartAvailable(type) && part.data) {\n itemKey = `${itemKey}_${part.data?.substr(-32)}`;\n\n if (!isFileUniqueInDocument(part, parts)) {\n itemKey = `${itemKey}_${partIndex}`;\n }\n }\n\n const partError = errors?.[getErrorKey(index, partIndex)];\n const localPartError = localErrors.get(getErrorKey(index, partIndex));\n\n if (part.type === PartType.Feedback) {\n return (\n <KYCDocumentParts.KYCFormItemText\n key={itemKey}\n value={part.data}\n onFeedbackChange={(value) => onFeedbackChange(partIndex, value)}\n />\n );\n }\n\n return (\n <KYCDocumentParts.KYCFormItemFile\n title={partTitle}\n data={part.data}\n type={part.type}\n name={getFileName(part.data)}\n uploaderLabels={uploaderLabels}\n error={localPartError || partError}\n key={itemKey}\n elementId={`${elementId}_part_${part.type}_${partIndex}`}\n onFileChange={(file) => onFileChange(partIndex, file)}\n onFileRemove={() => onFileRemove(partIndex)}\n />\n );\n })}\n\n {isAddExtraPartAvailable && firstPart && (\n <KYCDocumentParts.KYCFormItemFileExtraPart\n elementId={`${elementId}_extra`}\n title={extraPartTitle}\n uploaderLabels={uploaderLabels}\n onFileAdd={(file) => onFileChange(parts.length, file)}\n />\n )}\n </StyledKYCFormItem>\n );\n};\n\nexport default KYCFormItem;\n","import {gray50, lineHeight, mediumDevices, spacing, successColor} from '@propellerads/stylevariables';\nimport styled from 'styled-components';\n\nconst StyledKYCSucessScreen = styled.div`\n display: flex;\n flex-direction: column;\n`;\n\nconst StyledKYCSucessScreenItem = styled.span`\n margin-bottom: ${spacing * 8}px;\n`;\n\nconst StyledKYCSucessScreenSuppport = styled.span`\n color: ${gray50};\n`;\n\n// The success title, as @propellerads/success-label drew it: a check and the\n// text in the success colour.\nconst StyledKYCSuccessTitle = styled.span`\n display: inline-flex;\n align-items: center;\n gap: ${spacing}px;\n min-height: ${lineHeight}px;\n color: ${successColor};\n\n @media (min-width: ${mediumDevices}px) {\n max-width: 350px;\n white-space: nowrap;\n }\n`;\n\nconst StyledKYCFailScreen = styled.div`\n display: flex;\n flex-direction: column;\n`;\n\nconst StyledKYCFailScreenItem = styled.span`\n margin-bottom: ${spacing * 6}px;\n`;\n\nexport {\n StyledKYCFailScreen,\n StyledKYCFailScreenItem,\n StyledKYCSuccessTitle,\n StyledKYCSucessScreen,\n StyledKYCSucessScreenItem,\n StyledKYCSucessScreenSuppport,\n};\n","import {Check, Color, Size} from '@propellerads/icon';\nimport {\n ACCEPT_FORMATS,\n AVAILABLE_EXTRA_PARTS_DOCUMENTS,\n MAX_EXTRA_PARTS_COUNT,\n MAX_FILE_SIZE,\n PDF_MIME_TYPE,\n} from '../constants';\nimport KYCErrorLabel from '../KYCErrorLabel';\nimport {\n StyledKYCFailScreen,\n StyledKYCFailScreenItem,\n StyledKYCSuccessTitle,\n StyledKYCSucessScreen,\n StyledKYCSucessScreenItem,\n StyledKYCSucessScreenSuppport,\n} from './style';\nimport {KYCFailScreenProps, KYCSuccessScreenProps} from './types';\n\nconst KYCSuccessScreen = (props: KYCSuccessScreenProps) => {\n const {elementId, title, description, support} = props;\n\n return (\n <StyledKYCSucessScreen id={elementId}>\n <StyledKYCSucessScreenItem>\n <StyledKYCSuccessTitle id={`${elementId}_success`} role=\"status\">\n <Check color={Color.Success} size={Size.Small} />\n {title}\n </StyledKYCSuccessTitle>\n </StyledKYCSucessScreenItem>\n\n {description && <StyledKYCSucessScreenItem>{description}</StyledKYCSucessScreenItem>}\n\n {support && <StyledKYCSucessScreenSuppport>{support}</StyledKYCSucessScreenSuppport>}\n </StyledKYCSucessScreen>\n );\n};\n\nconst KYCFailScreen = (props: KYCFailScreenProps) => {\n const {elementId, title, support} = props;\n\n return (\n <StyledKYCFailScreen id={elementId}>\n <StyledKYCFailScreenItem>\n <KYCErrorLabel label={title} isDocumentPartError={false} />\n </StyledKYCFailScreenItem>\n\n {support}\n </StyledKYCFailScreen>\n );\n};\n\nexport default {\n KYCSuccessScreen,\n KYCFailScreen,\n};\n\nexport {ACCEPT_FORMATS, AVAILABLE_EXTRA_PARTS_DOCUMENTS, MAX_EXTRA_PARTS_COUNT, MAX_FILE_SIZE, PDF_MIME_TYPE};\n","import styled from 'styled-components';\nimport {fontNormal, spacing} from '@propellerads/stylevariables';\n\nconst StyledKYCForm = styled.div`\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n width: 100%;\n`;\n\nconst StyledKYCFormTitle = styled.div`\n font-size: ${fontNormal}px;\n`;\n\nconst StyledKYCFormDocuments = styled.div`\n width: 100%;\n margin-bottom: ${spacing * 6}px;\n`;\n\nconst StyledKYCFormButton = styled.div`\n display: flex;\n justify-content: flex-end;\n width: 100%;\n`;\n\nexport {StyledKYCForm, StyledKYCFormTitle, StyledKYCFormDocuments, StyledKYCFormButton};\n","import Button, {ButtonVariant} from '@propellerads/button';\nimport {useEffect, useState} from 'react';\nimport {\n ACCEPT_FORMATS,\n AVAILABLE_EXTRA_PARTS_DOCUMENTS,\n MAX_EXTRA_PARTS_COUNT,\n MAX_FILE_SIZE,\n OPTIONAL_DOCUMENT_PARTS,\n PDF_MIME_TYPE,\n} from './constants';\nimport {DocumentType, KYCDocument, PartType, KYCFile} from './document.types';\nimport KYCFormItem from './KYCFormItem';\nimport KYCStatusScreen from './KYCStatusScreen';\nimport {StyledKYCForm, StyledKYCFormButton, StyledKYCFormDocuments, StyledKYCFormTitle} from './style';\nimport {KYCFormProps} from './types';\n\nconst KYCForm = (props: KYCFormProps) => {\n const {\n elementId,\n title,\n uploadButtonLabel,\n uploaderLabels,\n documentsLabels,\n documents,\n errors,\n isLoading,\n validator,\n onUploadClick,\n } = props;\n\n const [userDocuments, setUserDocuments] = useState<KYCDocument[]>(documents);\n const [isButtonDisabled, setButtonDisabled] = useState<boolean>(true);\n\n useEffect(() => {\n setUserDocuments(documents);\n }, [documents]);\n\n useEffect(() => {\n const isValid: boolean = validator(userDocuments);\n setButtonDisabled(!isValid);\n }, [userDocuments, validator]);\n\n const onDocumentChange = (index: number, document: KYCDocument) => {\n const newDocuments: KYCDocument[] = [...userDocuments];\n newDocuments.splice(index, 1, document);\n\n setUserDocuments(newDocuments);\n };\n\n return (\n <StyledKYCForm id={elementId}>\n {title && <StyledKYCFormTitle>{title}</StyledKYCFormTitle>}\n\n <StyledKYCFormDocuments>\n {userDocuments.map((document, index) => {\n const key = `kyc-form_item_${document.type}_${index}`;\n\n return (\n <KYCFormItem\n index={index}\n type={document.type}\n parts={document.parts}\n documentLabels={documentsLabels[document.type]}\n uploaderLabels={uploaderLabels}\n errors={errors}\n elementId={`${elementId}_item_${document.type}`}\n key={key}\n onDocumentChange={(doc) => onDocumentChange(index, doc)}\n />\n );\n })}\n </StyledKYCFormDocuments>\n <StyledKYCFormButton>\n <Button\n id={`${elementId}_button`}\n variant={ButtonVariant.Primary}\n isDisabled={isButtonDisabled}\n isLoading={isLoading || false}\n onClick={() => onUploadClick(userDocuments)}\n >\n {uploadButtonLabel}\n </Button>\n </StyledKYCFormButton>\n </StyledKYCForm>\n );\n};\n\nKYCForm.SuccessScreen = KYCStatusScreen.KYCSuccessScreen;\nKYCForm.FailScreen = KYCStatusScreen.KYCFailScreen;\n\nexport default KYCForm;\n\nexport {\n ACCEPT_FORMATS,\n AVAILABLE_EXTRA_PARTS_DOCUMENTS,\n DocumentType,\n MAX_EXTRA_PARTS_COUNT,\n MAX_FILE_SIZE,\n OPTIONAL_DOCUMENT_PARTS,\n PartType,\n PDF_MIME_TYPE,\n};\nexport type {KYCDocument, KYCFile};\n"],"mappings":";;;;;;;;;AAAA,IAAa,IAAe;CAC1B,IAAI;CACJ,IAAI;CACJ,SAAS;CACT,MAAM;CACN,qBAAqB;CACrB,wBAAwB;CACxB,6BAA6B;CAC7B,kBAAkB;CAClB,mBAAmB;CACnB,iBAAiB;CACjB,yBAAyB;CACzB,OAAO;CACP,UAAU;CACX,EAGY,IAAW;CACtB,SAAS;CACT,QAAQ;CACR,IAAI;CACJ,MAAM;CACN,qBAAqB;CACrB,wBAAwB;CACxB,6BAA6B;CAC7B,kBAAkB;CAClB,wBAAwB;CACxB,qBAAqB;CACrB,8BAA8B;CAC9B,YAAY;CACZ,UAAU;CACX,EC5BY,IAAgB,SAEhB,KAAwB,GAExB,IAAgB,mBAChB,IAAiB,cACjB,IAAsD;CACjE,aAAa,CAAC,OAAO;CACrB,cAAc;EAAC;EAAQ;EAAQ;EAAQ;EACtC,IAAgB,CAAC,OAAO;EACxB,IAAiB,CAAC,QAAQ;CAC5B,EAEY,IAAkD;CAC7D,EAAa;CACb,EAAa;CACb,EAAa;CACb,EAAa;CACb,EAAa;CACb,EAAa;CACb,EAAa;CACb,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|
|
2
2
|
"name": "@propellerads/kyc-form",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -24,12 +24,11 @@
|
|
|
24
24
|
"homepage": "https://github.com/propellerads/ui-components#readme",
|
|
25
25
|
"private": false,
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@propellerads/button": "^
|
|
27
|
+
"@propellerads/button": "^12.0.0",
|
|
28
28
|
"@propellerads/icon": "^8.0.0",
|
|
29
|
-
"@propellerads/image-uploader": "^4.0.
|
|
30
|
-
"@propellerads/input": "^
|
|
31
|
-
"@propellerads/stylevariables": "^2.0.2"
|
|
32
|
-
"@propellerads/success-label": "^4.0.1"
|
|
29
|
+
"@propellerads/image-uploader": "^4.0.2",
|
|
30
|
+
"@propellerads/input": "^1.0.0",
|
|
31
|
+
"@propellerads/stylevariables": "^2.0.2"
|
|
33
32
|
},
|
|
34
33
|
"peerDependencies": {
|
|
35
34
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -41,6 +40,6 @@
|
|
|
41
40
|
"rollup": "^4.60.3",
|
|
42
41
|
"rollup-plugin-dts": "^6.4.1",
|
|
43
42
|
"typescript": "^6.0.3",
|
|
44
|
-
"vite": "^8.0.
|
|
43
|
+
"vite": "^8.0.11"
|
|
45
44
|
}
|
|
46
45
|
}
|