@propellerads/kyc-form 4.1.8 → 5.0.1

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/README.md CHANGED
@@ -10,15 +10,15 @@
10
10
 
11
11
  ## Installation
12
12
 
13
- - `yarn add @propellerads/kyc-form` or `npm install @propellerads/kyc-form -S`
13
+ - `bun add @propellerads/kyc-form` or `npm install @propellerads/kyc-form -S`
14
14
 
15
15
  ### How to use
16
16
 
17
- - `import KycForm from '@propellerads/kyc-form';`
17
+ - `import KYCForm, {DocumentType, PartType} from '@propellerads/kyc-form';`
18
18
  - And render
19
19
 
20
- ```
21
- <KycForm
20
+ ```tsx
21
+ <KYCForm
22
22
  elementId="kyc-form-component"
23
23
  title="PropellerAds is integrating KYC systems into the business processes. To continue working we kindly ask you to provide the following documents:"
24
24
  uploadButtonLabel="Send documents"
@@ -27,18 +27,18 @@
27
27
  action: 'upload from your computer',
28
28
  oversizeError: 'File is too big',
29
29
  }}
30
- documentsLabels={
31
- [DOCUMENT_TYPES.CARD]: {
30
+ documentsLabels={{
31
+ [DocumentType.Card]: {
32
32
  title: 'Photo of the account owner’s ID card.',
33
33
  description: '(Passport/driver’s license/aadhar card etc.)',
34
34
  }
35
- }
35
+ }}
36
36
  documents={[{
37
- type: DOCUMENT_TYPES.ID,
37
+ type: DocumentType.Id,
38
38
  parts:[{
39
- type: PART_TYPES.ID_FRONT,
39
+ type: PartType.IdFront,
40
40
  }, {
41
- type: PART_TYPES.ID_BACK,
41
+ type: PartType.IdBack,
42
42
  }],
43
43
  }]}
44
44
  onUploadClick={console.log}
package/dist/index.d.ts CHANGED
@@ -1,11 +1,110 @@
1
- import React from 'react';
2
- import { ACCEPT_FORMATS, AVAILABLE_EXTRA_PARTS_DOCUMENTS, MAX_EXTRA_PARTS_COUNT, MAX_FILE_SIZE, OPTIONAL_DOCUMENT_PARTS, PDF_MIME_TYPE } from './constants';
3
- import { DOCUMENT_TYPES, PART_TYPES } from './document.types';
4
- import { KYCFormProps } from './types';
5
- declare const KYCForm: {
6
- (props: KYCFormProps): React.JSX.Element;
7
- SucessScreen: (props: import("./KYCStatusScreen/types").KYCSucessScreenProps) => React.JSX.Element;
8
- FailScreen: (props: import("./KYCStatusScreen/types").KYCFailScreenProps) => React.JSX.Element;
9
- };
10
- export default KYCForm;
11
- export { ACCEPT_FORMATS, AVAILABLE_EXTRA_PARTS_DOCUMENTS, DOCUMENT_TYPES, MAX_EXTRA_PARTS_COUNT, MAX_FILE_SIZE, OPTIONAL_DOCUMENT_PARTS, PART_TYPES, PDF_MIME_TYPE, };
1
+ import { ReactNode } from 'react';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+ import { ImageUploaderProps } from '@propellerads/image-uploader';
4
+
5
+ type KYCSuccessScreenProps = {
6
+ elementId: string;
7
+ title: string;
8
+ description?: ReactNode;
9
+ support?: ReactNode;
10
+ };
11
+ type KYCFailScreenProps = {
12
+ elementId: string;
13
+ title: string;
14
+ support?: ReactNode;
15
+ };
16
+
17
+ declare const DocumentType: {
18
+ readonly Id: "id";
19
+ readonly Ub: "ub";
20
+ readonly IdExtra: "id_extra";
21
+ readonly Card: "bank_card";
22
+ readonly PaymentSystemScreen: "payment_system_screen";
23
+ readonly OnlineBankingStatement: "online_banking_statement";
24
+ readonly CompanyRegistrationDocument: "company_registration_document";
25
+ readonly SelfieWithIdCard: "selfie_with_id_card_or_bank_card";
26
+ readonly PaypalDetailsPage: "pay_pal_details_page";
27
+ readonly BankWireDetails: "bank_wire_details";
28
+ readonly TransactionConfirmation: "transaction_confirmation";
29
+ readonly Other: "other";
30
+ readonly Feedback: "feedback";
31
+ };
32
+ type DocumentType = (typeof DocumentType)[keyof typeof DocumentType];
33
+ declare const PartType: {
34
+ readonly IdFront: "id_front";
35
+ readonly IdBack: "id_back";
36
+ readonly Ub: "ub_item";
37
+ readonly Card: "card_item";
38
+ readonly PaymentSystemScreen: "screen_item";
39
+ readonly OnlineBankingStatement: "obs_item";
40
+ readonly CompanyRegistrationDocument: "crd_item";
41
+ readonly SelfieWithIdCard: "selfie_item";
42
+ readonly PaypalDetailsPageImage: "pay_pal_details_page_image";
43
+ readonly BankWireDetailsPage: "bank_wire_details_image";
44
+ readonly TransactionConfirmationImage: "transaction_confirmation_image";
45
+ readonly OtherImage: "other_image";
46
+ readonly Feedback: "feedback";
47
+ };
48
+ type PartType = (typeof PartType)[keyof typeof PartType];
49
+ type KYCFileData = string | undefined;
50
+ type KYCFile = {
51
+ type: PartType;
52
+ data?: KYCFileData;
53
+ };
54
+ type KYCDocument = {
55
+ type: DocumentType;
56
+ parts: KYCFile[];
57
+ };
58
+
59
+ declare const MAX_FILE_SIZE = 5242880;
60
+ declare const MAX_EXTRA_PARTS_COUNT = 3;
61
+ declare const PDF_MIME_TYPE = "application/pdf";
62
+ declare const ACCEPT_FORMATS: ImageUploaderProps['acceptFormats'];
63
+ declare const AVAILABLE_EXTRA_PARTS_DOCUMENTS: DocumentType[];
64
+ declare const OPTIONAL_DOCUMENT_PARTS: {
65
+ id: {
66
+ parts: "id_back"[];
67
+ };
68
+ id_extra: {
69
+ parts: "id_back"[];
70
+ };
71
+ };
72
+
73
+ type UploaderLabels = {
74
+ title?: string;
75
+ description?: string;
76
+ action?: string;
77
+ oversizeError: string;
78
+ };
79
+ type PartLabels = {
80
+ title?: string;
81
+ };
82
+ type PartsLabels = Partial<Record<PartType, PartLabels>>;
83
+ type DocumentLabels = {
84
+ title: string;
85
+ description?: string;
86
+ parts?: PartsLabels;
87
+ };
88
+ type DocumentsLabels = Partial<Record<DocumentType, DocumentLabels>>;
89
+
90
+ type KYCFormProps = {
91
+ elementId: string;
92
+ title: ReactNode;
93
+ uploadButtonLabel: string;
94
+ uploaderLabels: UploaderLabels;
95
+ documentsLabels: DocumentsLabels;
96
+ documents: KYCDocument[];
97
+ isLoading?: boolean;
98
+ errors?: Record<string, string>;
99
+ validator: (documents: KYCDocument[]) => boolean;
100
+ onUploadClick: (documents: KYCDocument[]) => void;
101
+ };
102
+
103
+ declare const KYCForm: {
104
+ (props: KYCFormProps): react_jsx_runtime.JSX.Element;
105
+ SuccessScreen: (props: KYCSuccessScreenProps) => react_jsx_runtime.JSX.Element;
106
+ FailScreen: (props: KYCFailScreenProps) => react_jsx_runtime.JSX.Element;
107
+ };
108
+
109
+ export { ACCEPT_FORMATS, AVAILABLE_EXTRA_PARTS_DOCUMENTS, DocumentType, MAX_EXTRA_PARTS_COUNT, MAX_FILE_SIZE, OPTIONAL_DOCUMENT_PARTS, PDF_MIME_TYPE, PartType, KYCForm as default };
110
+ export type { KYCDocument, KYCFile };
package/dist/index.js CHANGED
@@ -1,8 +1,381 @@
1
+ import e, { ButtonType as t } from "@propellerads/button";
2
+ import { useEffect as n, useState as r } from "react";
3
+ import { Close as i, Color as a, Delete as o, Insert as s, Pdf as c, Size as l } from "@propellerads/icon";
4
+ import u, { Direction as d } from "@propellerads/image-uploader";
5
+ import f from "@propellerads/textarea";
6
+ import p from "styled-components";
7
+ import { black as m, borderRadius as h, errorColor as g, fontNormal as _, fontSmall as v, gray50 as y, gray95 as b, spacing as x, white as S } from "@propellerads/stylevariables";
8
+ import { jsx as C, jsxs as w } from "react/jsx-runtime";
9
+ import T from "@propellerads/success-label";
10
+ //#region src/document.types.ts
11
+ var E = {
12
+ Id: "id",
13
+ Ub: "ub",
14
+ IdExtra: "id_extra",
15
+ Card: "bank_card",
16
+ PaymentSystemScreen: "payment_system_screen",
17
+ OnlineBankingStatement: "online_banking_statement",
18
+ CompanyRegistrationDocument: "company_registration_document",
19
+ SelfieWithIdCard: "selfie_with_id_card_or_bank_card",
20
+ PaypalDetailsPage: "pay_pal_details_page",
21
+ BankWireDetails: "bank_wire_details",
22
+ TransactionConfirmation: "transaction_confirmation",
23
+ Other: "other",
24
+ Feedback: "feedback"
25
+ }, D = {
26
+ IdFront: "id_front",
27
+ IdBack: "id_back",
28
+ Ub: "ub_item",
29
+ Card: "card_item",
30
+ PaymentSystemScreen: "screen_item",
31
+ OnlineBankingStatement: "obs_item",
32
+ CompanyRegistrationDocument: "crd_item",
33
+ SelfieWithIdCard: "selfie_item",
34
+ PaypalDetailsPageImage: "pay_pal_details_page_image",
35
+ BankWireDetailsPage: "bank_wire_details_image",
36
+ TransactionConfirmationImage: "transaction_confirmation_image",
37
+ OtherImage: "other_image",
38
+ Feedback: "feedback"
39
+ }, O = 5242880, ee = 3, k = "application/pdf", A = "image/heic", j = {
40
+ "image/png": [".png"],
41
+ "image/jpeg": [
42
+ ".jpg",
43
+ ".jpe",
44
+ ".jpeg"
45
+ ],
46
+ [k]: [".pdf"],
47
+ [A]: [".heic"]
48
+ }, M = [
49
+ E.Card,
50
+ E.Card,
51
+ E.PaypalDetailsPage,
52
+ E.BankWireDetails,
53
+ E.TransactionConfirmation,
54
+ E.SelfieWithIdCard,
55
+ E.PaymentSystemScreen,
56
+ E.Other
57
+ ], te = {
58
+ [E.Id]: { parts: [D.IdBack] },
59
+ [E.IdExtra]: { parts: [D.IdBack] }
60
+ }, N = p.div`
61
+ display: flex;
62
+ align-items: center;
63
+ color: ${g};
64
+ margin-top: ${x * 2}px;
65
+ margin-bottom: ${x * 4}px;
66
+ `, P = p.span`
67
+ display: flex;
68
+ align-items: center;
69
+ justify-content: center;
70
+ width: 14px;
71
+ height: 14px;
72
+ border-radius: 100%;
73
+ background-color: ${g};
1
74
 
2
- 'use strict'
75
+ &:before {
76
+ font-size: ${v};
77
+ color: ${S};
78
+ content: '!';
79
+ }
80
+ `, F = p.span`
81
+ margin-left: ${x * 2}px;
82
+ `, I = (e) => /* @__PURE__ */ w(N, { children: [e.isDocumentPartError ? /* @__PURE__ */ C(P, {}) : /* @__PURE__ */ C(i, {
83
+ color: a.Error,
84
+ hoverColor: a.Error,
85
+ size: l.Small
86
+ }), /* @__PURE__ */ C(F, { children: e.label })] }), L = (e) => M.includes(e), ne = (e, t) => L(e) && t.every((e) => !!e.data) && t.length < 3 && t.length > 0, R = (e) => e?.match(/[^:]\w+\/[\w-+\d.]+(?=;|,)/)?.[0], z = (e) => R(e) === k, re = (e) => R(e) === A, B = (e, t) => t.every((t) => t.data !== e?.data), ie = async (e) => {
87
+ let t = new FileReader();
88
+ return new Promise((n, r) => {
89
+ t.onload = () => n(t.result), t.onerror = (e) => r(e), t.readAsDataURL(e);
90
+ });
91
+ }, V = p.div`
92
+ margin-top: ${x * 4}px;
93
+ margin-left: ${x * 4}px;
94
+ `, H = p.div`
95
+ margin-bottom: ${x}px;
96
+ `, U = p.div`
97
+ display: flex;
98
+ align-items: center;
99
+ background-color: ${b};
100
+ padding: ${x * 2}px;
101
+ border-radius: ${h}px;
102
+ `, W = p.span`
103
+ width: 100%;
104
+ margin-left: ${x * 4}px;
105
+ margin-right: ${x * 2}px;
106
+ `, G = p.span`
107
+ cursor: pointer !important;
108
+ margin-right: ${x * 2}px;
109
+ `, K = p.div`
110
+ height: 66px;
111
+ `, q = p.div`
112
+ display: flex;
113
+ flex-direction: column;
114
+ margin-top: ${x * 4}px;
115
+ margin-left: ${x * 4}px;
116
+ `, J = p.img`
117
+ width: auto;
118
+ max-width: 204px;
119
+ height: 50px;
120
+ object-fit: contain;
121
+ border-radius: ${h}px;
122
+ `, ae = p.div`
123
+ display: flex;
124
+ align-items: center;
125
+ justify-content: center;
126
+ min-width: 50px;
127
+ height: 50px;
128
+ border-radius: ${h}px;
129
+ background-color: ${S};
130
+ `, oe = (e) => {
131
+ let { data: t } = e, n = z(t), r = re(t);
132
+ return n || r ? /* @__PURE__ */ w(ae, { children: [n && /* @__PURE__ */ C(c, {
133
+ color: a.Gray,
134
+ hoverColor: a.Gray
135
+ }), r && /* @__PURE__ */ C(s, {
136
+ color: a.Gray,
137
+ hoverColor: a.Gray
138
+ })] }) : /* @__PURE__ */ C(J, { src: t });
139
+ }, Y = {
140
+ KYCFormItemFileExtraPart: (e) => {
141
+ let { elementId: t, title: n, uploaderLabels: r, onFileAdd: i } = e;
142
+ return /* @__PURE__ */ w(q, {
143
+ id: t,
144
+ children: [n && /* @__PURE__ */ C(H, { children: n }), /* @__PURE__ */ C(K, { children: /* @__PURE__ */ C(u, {
145
+ title: r.title,
146
+ action: r.action,
147
+ maxSize: O,
148
+ acceptFormats: j,
149
+ elementId: `${t}_uploader`,
150
+ direction: d.Row,
151
+ onDrop: (e) => {
152
+ let [t] = e;
153
+ t && i(t);
154
+ }
155
+ }) })]
156
+ });
157
+ },
158
+ KYCFormItemFile: (e) => {
159
+ let { name: t, title: n, data: r, error: i, elementId: s, uploaderLabels: c, onFileChange: l, onFileRemove: f } = e;
160
+ return /* @__PURE__ */ w(V, {
161
+ id: s,
162
+ children: [
163
+ n && /* @__PURE__ */ C(H, { children: n }),
164
+ r ? /* @__PURE__ */ w(U, { children: [
165
+ /* @__PURE__ */ C(oe, { data: r }),
166
+ /* @__PURE__ */ C(W, { children: t }),
167
+ /* @__PURE__ */ C(G, {
168
+ onClick: f,
169
+ children: /* @__PURE__ */ C(o, {
170
+ color: a.Blue,
171
+ hoverColor: a.Blue
172
+ })
173
+ })
174
+ ] }) : /* @__PURE__ */ C(K, { children: /* @__PURE__ */ C(u, {
175
+ title: c.title,
176
+ action: c.action,
177
+ maxSize: O,
178
+ acceptFormats: j,
179
+ elementId: `${s}_uploader`,
180
+ direction: d.Row,
181
+ onDrop: (e) => {
182
+ let [t] = e;
183
+ t && l(t);
184
+ }
185
+ }) }),
186
+ i && /* @__PURE__ */ C(I, {
187
+ label: i,
188
+ isDocumentPartError: !0
189
+ })
190
+ ]
191
+ });
192
+ },
193
+ KYCFormItemText: (e) => {
194
+ let { onFeedbackChange: t, value: n = "" } = e, r = (e) => t(e);
195
+ return /* @__PURE__ */ C(V, { children: /* @__PURE__ */ C(f, {
196
+ onChange: r,
197
+ onBlur: r,
198
+ value: n,
199
+ errors: [],
200
+ name: "kyc-client-comments",
201
+ elementId: "kyc-feedback-textarea"
202
+ }) });
203
+ }
204
+ }, se = p.div`
205
+ margin-top: ${x * 6}px;
206
+ `, ce = p.div`
207
+ font-size: ${_}px;
208
+ font-weight: bold;
209
+ color: ${m};
210
+ margin-bottom: ${x}px;
211
+ `, le = p.div`
212
+ font-size: ${v}px;
213
+ color: ${y};
214
+ margin-left: ${x * 4}px;
215
+ `, X = (e, t) => `[${e}].parts[${t}].data`, ue = (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 = ne(t, s), p = a?.parts, m = s[0], h = m ? p?.[m.type]?.title : void 0, [g, _] = r(/* @__PURE__ */ new Map()), v = (e) => {
217
+ let t = new Map(u);
218
+ t.set(X(n, e), i.oversizeError), d(t);
219
+ }, y = (e) => {
220
+ let t = new Map(u);
221
+ t.delete(X(n, e)), d(t);
222
+ }, b = (e, n, r) => {
223
+ let i = {
224
+ ...e,
225
+ data: r
226
+ }, a = [...s];
227
+ a.splice(n, 1, i), l({
228
+ type: t,
229
+ parts: a
230
+ });
231
+ }, x = async (e, t) => {
232
+ if (!t) {
233
+ v(e);
234
+ return;
235
+ }
236
+ let n = s[e] ?? s[0];
237
+ if (!n) return;
238
+ let r = await ie(t);
239
+ b(n, e, r);
240
+ let i = new Map(g);
241
+ i.set(r, t.name), _(i), y(e);
242
+ }, S = (e) => {
243
+ let t = s[e];
244
+ if (!t) return;
245
+ b(t, e);
246
+ let n = s[e], r = new Map(g);
247
+ n?.data && B(n, s) && r.delete(n?.data), _(r), y(e);
248
+ }, T = (e) => {
249
+ if (e) return g.get(e);
250
+ }, E = (e, t) => {
251
+ let n = s[e] ?? s[0];
252
+ n && b(n, e, t);
253
+ };
254
+ return /* @__PURE__ */ w(se, {
255
+ id: o,
256
+ children: [
257
+ /* @__PURE__ */ C(ce, { children: `${n + 1}. ${a?.title}` }),
258
+ a?.description && /* @__PURE__ */ C(le, { children: a?.description }),
259
+ s.map((e, r) => {
260
+ let a = `kyc-form_item_file_${e.type}`, l = L(t), d = p?.[e.type], f = l ? void 0 : d?.title;
261
+ L(t) && e.data && (a = `${a}_${e.data?.substr(-32)}`, B(e, s) || (a = `${a}_${r}`));
262
+ let m = c?.[X(n, r)], h = u.get(X(n, r));
263
+ return e.type === D.Feedback ? /* @__PURE__ */ C(Y.KYCFormItemText, {
264
+ value: e.data,
265
+ onFeedbackChange: (e) => E(r, e)
266
+ }, a) : /* @__PURE__ */ C(Y.KYCFormItemFile, {
267
+ title: f,
268
+ data: e.data,
269
+ type: e.type,
270
+ name: T(e.data),
271
+ uploaderLabels: i,
272
+ error: h || m,
273
+ elementId: `${o}_part_${e.type}_${r}`,
274
+ onFileChange: (e) => x(r, e),
275
+ onFileRemove: () => S(r)
276
+ }, a);
277
+ }),
278
+ f && m && /* @__PURE__ */ C(Y.KYCFormItemFileExtraPart, {
279
+ elementId: `${o}_extra`,
280
+ title: h,
281
+ uploaderLabels: i,
282
+ onFileAdd: (e) => x(s.length, e)
283
+ })
284
+ ]
285
+ });
286
+ }, de = p.div`
287
+ display: flex;
288
+ flex-direction: column;
289
+ `, Z = p.span`
290
+ margin-bottom: ${x * 8}px;
291
+ `, fe = p.span`
292
+ color: ${y};
293
+ `, pe = p.div`
294
+ display: flex;
295
+ flex-direction: column;
296
+ `, me = p.span`
297
+ margin-bottom: ${x * 6}px;
298
+ `, Q = {
299
+ KYCSuccessScreen: (e) => {
300
+ let { elementId: t, title: n, description: r, support: i } = e;
301
+ return /* @__PURE__ */ w(de, {
302
+ id: t,
303
+ children: [
304
+ /* @__PURE__ */ C(Z, { children: /* @__PURE__ */ C(T, {
305
+ show: !0,
306
+ elementId: `${t}_success`,
307
+ children: n
308
+ }) }),
309
+ r && /* @__PURE__ */ C(Z, { children: r }),
310
+ i && /* @__PURE__ */ C(fe, { children: i })
311
+ ]
312
+ });
313
+ },
314
+ KYCFailScreen: (e) => {
315
+ let { elementId: t, title: n, support: r } = e;
316
+ return /* @__PURE__ */ w(pe, {
317
+ id: t,
318
+ children: [/* @__PURE__ */ C(me, { children: /* @__PURE__ */ C(I, {
319
+ label: n,
320
+ isDocumentPartError: !1
321
+ }) }), r]
322
+ });
323
+ }
324
+ }, he = p.div`
325
+ display: flex;
326
+ flex-direction: column;
327
+ align-items: flex-start;
328
+ width: 100%;
329
+ `, ge = p.div`
330
+ font-size: ${_}px;
331
+ `, _e = p.div`
332
+ width: 100%;
333
+ margin-bottom: ${x * 6}px;
334
+ `, ve = p.div`
335
+ display: flex;
336
+ justify-content: flex-end;
337
+ width: 100%;
338
+ `, $ = (i) => {
339
+ let { elementId: a, title: o, uploadButtonLabel: s, uploaderLabels: c, documentsLabels: l, documents: u, errors: d, isLoading: f, validator: p, onUploadClick: m } = i, [h, g] = r(u), [_, v] = r(!0);
340
+ n(() => {
341
+ g(u);
342
+ }, [u]), n(() => {
343
+ v(!p(h));
344
+ }, [h, p]);
345
+ let y = (e, t) => {
346
+ let n = [...h];
347
+ n.splice(e, 1, t), g(n);
348
+ };
349
+ return /* @__PURE__ */ w(he, {
350
+ id: a,
351
+ children: [
352
+ o && /* @__PURE__ */ C(ge, { children: o }),
353
+ /* @__PURE__ */ C(_e, { children: h.map((e, t) => {
354
+ let n = `kyc-form_item_${e.type}_${t}`;
355
+ return /* @__PURE__ */ C(ue, {
356
+ index: t,
357
+ type: e.type,
358
+ parts: e.parts,
359
+ documentLabels: l[e.type],
360
+ uploaderLabels: c,
361
+ errors: d,
362
+ elementId: `${a}_item_${e.type}`,
363
+ onDocumentChange: (e) => y(t, e)
364
+ }, n);
365
+ }) }),
366
+ /* @__PURE__ */ C(ve, { children: /* @__PURE__ */ C(e, {
367
+ elementId: `${a}_button`,
368
+ type: t.Primary,
369
+ isDisabled: _,
370
+ isLoading: f || !1,
371
+ onClick: () => m(h),
372
+ children: s
373
+ }) })
374
+ ]
375
+ });
376
+ };
377
+ $.SuccessScreen = Q.KYCSuccessScreen, $.FailScreen = Q.KYCFailScreen;
378
+ //#endregion
379
+ export { j as ACCEPT_FORMATS, M as AVAILABLE_EXTRA_PARTS_DOCUMENTS, E as DocumentType, ee as MAX_EXTRA_PARTS_COUNT, O as MAX_FILE_SIZE, te as OPTIONAL_DOCUMENT_PARTS, k as PDF_MIME_TYPE, D as PartType, $ as default };
3
380
 
4
- if (process.env.NODE_ENV === 'production') {
5
- module.exports = require('./kyc-form.cjs.production.min.js')
6
- } else {
7
- module.exports = require('./kyc-form.cjs.development.js')
8
- }
381
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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/textarea';\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 const handleChange = (newValue: string) => onFeedbackChange(newValue);\n\n return (\n <StyledKYCFormItem>\n <TextArea\n onChange={handleChange}\n onBlur={handleChange}\n value={value}\n errors={[]}\n name=\"kyc-client-comments\"\n elementId=\"kyc-feedback-textarea\"\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, {ButtonType} 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 elementId={`${elementId}_button`}\n type={ButtonType.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,I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