@propellerads/kyc-form 6.0.0 → 7.0.0

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.css ADDED
@@ -0,0 +1 @@
1
+ .kyc-form{flex-direction:column;align-items:flex-start;width:100%;display:flex}.kyc-form__title{font-size:14px}.kyc-form__documents{width:100%;margin-bottom:24px}.kyc-form__button{justify-content:flex-end;width:100%;display:flex}.kyc-form-item{margin-top:24px}.kyc-form-item__title{color:var(--color-dark-inversion,#000);margin-bottom:4px;font-size:14px;font-weight:700}.kyc-form-item__description{color:var(--color-quiet-text,gray);margin-left:16px;font-size:12px}.kyc-document-part{margin-top:16px;margin-left:16px}.kyc-document-part--extra{flex-direction:column;display:flex}.kyc-document-part__title{margin-bottom:4px}.kyc-document-part__preview{background-color:var(--color-formal,#f2f2f2);border-radius:8px;align-items:center;padding:8px;display:flex}.kyc-document-part__preview-name{width:100%;margin-left:16px;margin-right:8px}.kyc-document-part__preview-remove{margin-right:8px;cursor:pointer!important}.kyc-document-part__uploader{height:66px}.kyc-document-part__image{object-fit:contain;border-radius:8px;width:auto;max-width:204px;height:50px}.kyc-document-part__icon{background-color:var(--color-light-inversion,#fff);border-radius:8px;justify-content:center;align-items:center;min-width:50px;height:50px;display:flex}.kyc-error-label{color:var(--color-danger,#ee2b2b);align-items:center;margin-top:8px;margin-bottom:16px;display:flex}.kyc-error-label__icon{background-color:var(--color-danger,#ee2b2b);border-radius:100%;justify-content:center;align-items:center;width:14px;height:14px;display:flex}.kyc-error-label__icon:before{color:var(--color-light,#fff);content:"!"}.kyc-error-label__text{margin-left:8px}.kyc-status-screen{flex-direction:column;display:flex}.kyc-status-screen__item{margin-bottom:32px}.kyc-status-screen__item--fail{margin-bottom:24px}.kyc-status-screen__support{color:var(--color-quiet-text,gray)}.kyc-status-screen__success-title{min-height:36px;color:var(--color-success,#00b359);align-items:center;gap:4px;display:inline-flex}@media (width>=1024px){.kyc-status-screen__success-title{white-space:nowrap;max-width:350px}}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
+ import * as react from 'react';
1
2
  import { ReactNode } from 'react';
2
- import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  import { ImageUploaderProps } from '@propellerads/image-uploader';
4
4
 
5
5
  type KYCSuccessScreenProps = {
@@ -101,9 +101,9 @@ type KYCFormProps = {
101
101
  };
102
102
 
103
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;
104
+ (props: KYCFormProps): react.JSX.Element;
105
+ SuccessScreen: (props: KYCSuccessScreenProps) => react.JSX.Element;
106
+ FailScreen: (props: KYCFailScreenProps) => react.JSX.Element;
107
107
  };
108
108
 
109
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 };
package/dist/index.js CHANGED
@@ -3,11 +3,9 @@ import { useEffect as n, useState as r } from "react";
3
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
4
  import d, { Direction as f } from "@propellerads/image-uploader";
5
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";
9
- //#region src/document.types.ts
10
- var O = {
6
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
7
+ import './index.css';// src/document.types.ts
8
+ var g = {
11
9
  Id: "id",
12
10
  Ub: "ub",
13
11
  IdExtra: "id_extra",
@@ -21,7 +19,7 @@ var O = {
21
19
  TransactionConfirmation: "transaction_confirmation",
22
20
  Other: "other",
23
21
  Feedback: "feedback"
24
- }, k = {
22
+ }, _ = {
25
23
  IdFront: "id_front",
26
24
  IdBack: "id_back",
27
25
  Ub: "ub_item",
@@ -35,154 +33,127 @@ var O = {
35
33
  TransactionConfirmationImage: "transaction_confirmation_image",
36
34
  OtherImage: "other_image",
37
35
  Feedback: "feedback"
38
- }, A = 5242880, te = 3, j = "application/pdf", M = "image/heic", N = {
36
+ }, v = 5242880, y = 3, b = "application/pdf", x = "image/heic", S = {
39
37
  "image/png": [".png"],
40
38
  "image/jpeg": [
41
39
  ".jpg",
42
40
  ".jpe",
43
41
  ".jpeg"
44
42
  ],
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`
60
- display: flex;
61
- align-items: center;
62
- color: ${_};
63
- margin-top: ${w * 2}px;
64
- margin-bottom: ${w * 4}px;
65
- `, F = m.span`
66
- display: flex;
67
- align-items: center;
68
- justify-content: center;
69
- width: 14px;
70
- height: 14px;
71
- border-radius: 100%;
72
- background-color: ${_};
73
-
74
- &:before {
75
- font-size: ${y};
76
- color: ${T};
77
- content: '!';
78
- }
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) => {
43
+ [b]: [".pdf"],
44
+ [x]: [".heic"]
45
+ }, C = [
46
+ g.Card,
47
+ g.Card,
48
+ g.PaypalDetailsPage,
49
+ g.BankWireDetails,
50
+ g.TransactionConfirmation,
51
+ g.SelfieWithIdCard,
52
+ g.PaymentSystemScreen,
53
+ g.Other
54
+ ], w = {
55
+ [g.Id]: { parts: [_.IdBack] },
56
+ [g.IdExtra]: { parts: [_.IdBack] }
57
+ }, T = (e) => /* @__PURE__ */ h("div", {
58
+ className: "kyc-error-label",
59
+ children: [e.isDocumentPartError ? /* @__PURE__ */ m("span", { className: "kyc-error-label__icon" }) : /* @__PURE__ */ m(a, {
60
+ color: o.Error,
61
+ hoverColor: o.Error,
62
+ size: u.Small
63
+ }), /* @__PURE__ */ m("span", {
64
+ className: "kyc-error-label__text",
65
+ children: e.label
66
+ })]
67
+ }), E = (e) => C.includes(e), D = (e, t) => E(e) && t.every((e) => !!e.data) && t.length < 3 && t.length > 0, O = (e) => e?.match(/[^:]\w+\/[\w-+\d.]+(?=;|,)/)?.[0], k = (e) => O(e) === b, A = (e) => O(e) === x, j = (e, t) => t.every((t) => t.data !== e?.data), M = async (e) => {
86
68
  let t = new FileReader();
87
69
  return new Promise((n, r) => {
88
70
  t.onload = () => n(t.result), t.onerror = (e) => r(e), t.readAsDataURL(e);
89
71
  });
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`
96
- display: flex;
97
- align-items: center;
98
- background-color: ${x};
99
- padding: ${w * 2}px;
100
- border-radius: ${g}px;
101
- `, G = m.span`
102
- width: 100%;
103
- margin-left: ${w * 4}px;
104
- margin-right: ${w * 2}px;
105
- `, K = m.span`
106
- cursor: pointer !important;
107
- margin-right: ${w * 2}px;
108
- `, q = m.div`
109
- height: 66px;
110
- `, se = m.div`
111
- display: flex;
112
- flex-direction: column;
113
- margin-top: ${w * 4}px;
114
- margin-left: ${w * 4}px;
115
- `, ce = m.img`
116
- width: auto;
117
- max-width: 204px;
118
- height: 50px;
119
- object-fit: contain;
120
- border-radius: ${g}px;
121
- `, le = m.div`
122
- display: flex;
123
- align-items: center;
124
- justify-content: center;
125
- min-width: 50px;
126
- height: 50px;
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 = {
72
+ }, N = (e) => {
73
+ let { data: t } = e, n = k(t), r = A(t);
74
+ return n || r ? /* @__PURE__ */ h("div", {
75
+ className: "kyc-document-part__icon",
76
+ children: [n && /* @__PURE__ */ m(l, {
77
+ color: o.Gray,
78
+ hoverColor: o.Gray
79
+ }), r && /* @__PURE__ */ m(c, {
80
+ color: o.Gray,
81
+ hoverColor: o.Gray
82
+ })]
83
+ }) : /* @__PURE__ */ m("img", {
84
+ className: "kyc-document-part__image",
85
+ src: t,
86
+ alt: ""
87
+ });
88
+ }, P = {
139
89
  KYCFormItemFileExtraPart: (e) => {
140
90
  let { elementId: t, title: n, uploaderLabels: r, onFileAdd: i } = e;
141
- return /* @__PURE__ */ D(se, {
91
+ return /* @__PURE__ */ h("div", {
92
+ className: "kyc-document-part kyc-document-part--extra",
142
93
  id: t,
143
- children: [n && /* @__PURE__ */ E(U, { children: n }), /* @__PURE__ */ E(q, { children: /* @__PURE__ */ E(d, {
144
- title: r.title,
145
- action: r.action,
146
- maxSize: A,
147
- acceptFormats: N,
148
- elementId: `${t}_uploader`,
149
- direction: f.Row,
150
- onDrop: (e) => {
151
- let [t] = e;
152
- t && i(t);
153
- }
154
- }) })]
94
+ children: [n && /* @__PURE__ */ m("div", {
95
+ className: "kyc-document-part__title",
96
+ children: n
97
+ }), /* @__PURE__ */ m("div", {
98
+ className: "kyc-document-part__uploader",
99
+ children: /* @__PURE__ */ m(d, {
100
+ title: r.title,
101
+ action: r.action,
102
+ maxSize: v,
103
+ acceptFormats: S,
104
+ elementId: `${t}_uploader`,
105
+ direction: f.Row,
106
+ onDrop: (e) => {
107
+ let [t] = e;
108
+ t && i(t);
109
+ }
110
+ })
111
+ })]
155
112
  });
156
113
  },
157
114
  KYCFormItemFile: (e) => {
158
115
  let { name: t, title: n, data: r, error: i, elementId: a, uploaderLabels: c, onFileChange: l, onFileRemove: u } = e;
159
- return /* @__PURE__ */ D(H, {
116
+ return /* @__PURE__ */ h("div", {
117
+ className: "kyc-document-part",
160
118
  id: a,
161
119
  children: [
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
120
+ n && /* @__PURE__ */ m("div", {
121
+ className: "kyc-document-part__title",
122
+ children: n
123
+ }),
124
+ r ? /* @__PURE__ */ h("div", {
125
+ className: "kyc-document-part__preview",
126
+ children: [
127
+ /* @__PURE__ */ m(N, { data: r }),
128
+ /* @__PURE__ */ m("span", {
129
+ className: "kyc-document-part__preview-name",
130
+ children: t
131
+ }),
132
+ /* @__PURE__ */ m("span", {
133
+ className: "kyc-document-part__preview-remove",
134
+ onClick: u,
135
+ children: /* @__PURE__ */ m(s, {
136
+ color: o.Blue,
137
+ hoverColor: o.Blue
138
+ })
171
139
  })
140
+ ]
141
+ }) : /* @__PURE__ */ m("div", {
142
+ className: "kyc-document-part__uploader",
143
+ children: /* @__PURE__ */ m(d, {
144
+ title: c.title,
145
+ action: c.action,
146
+ maxSize: v,
147
+ acceptFormats: S,
148
+ elementId: `${a}_uploader`,
149
+ direction: f.Row,
150
+ onDrop: (e) => {
151
+ let [t] = e;
152
+ t && l(t);
153
+ }
172
154
  })
173
- ] }) : /* @__PURE__ */ E(q, { children: /* @__PURE__ */ E(d, {
174
- title: c.title,
175
- action: c.action,
176
- maxSize: A,
177
- acceptFormats: N,
178
- elementId: `${a}_uploader`,
179
- direction: f.Row,
180
- onDrop: (e) => {
181
- let [t] = e;
182
- t && l(t);
183
- }
184
- }) }),
185
- i && /* @__PURE__ */ E(L, {
155
+ }),
156
+ i && /* @__PURE__ */ m(T, {
186
157
  label: i,
187
158
  isDocumentPartError: !0
188
159
  })
@@ -191,35 +162,27 @@ var O = {
191
162
  },
192
163
  KYCFormItemText: (e) => {
193
164
  let { onFeedbackChange: t, value: n = "" } = e;
194
- return /* @__PURE__ */ E(H, { children: /* @__PURE__ */ E(p, {
195
- onChange: (e) => t(e.target.value),
196
- onBlur: (e) => t(e.target.value),
197
- value: n,
198
- rows: 5,
199
- name: "kyc-client-comments",
200
- id: "kyc-feedback-textarea",
201
- "aria-label": "Comments"
202
- }) });
165
+ return /* @__PURE__ */ m("div", {
166
+ className: "kyc-document-part",
167
+ children: /* @__PURE__ */ m(p, {
168
+ onChange: (e) => t(e.target.value),
169
+ onBlur: (e) => t(e.target.value),
170
+ value: n,
171
+ rows: 5,
172
+ name: "kyc-client-comments",
173
+ id: "kyc-feedback-textarea",
174
+ "aria-label": "Comments"
175
+ })
176
+ });
203
177
  }
204
- }, de = m.div`
205
- margin-top: ${w * 6}px;
206
- `, fe = m.div`
207
- font-size: ${v}px;
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) => {
178
+ }, F = (e, t) => `[${e}].parts[${t}].data`, I = (e) => {
179
+ 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 = D(t, s), p = a?.parts, g = s[0], v = g ? p?.[g.type]?.title : void 0, [y, b] = r(/* @__PURE__ */ new Map()), x = (e) => {
217
180
  let t = new Map(u);
218
- t.set(Y(n, e), i.oversizeError), d(t);
219
- }, y = (e) => {
181
+ t.set(F(n, e), i.oversizeError), d(t);
182
+ }, S = (e) => {
220
183
  let t = new Map(u);
221
- t.delete(Y(n, e)), d(t);
222
- }, b = (e, n, r) => {
184
+ t.delete(F(n, e)), d(t);
185
+ }, C = (e, n, r) => {
223
186
  let i = {
224
187
  ...e,
225
188
  data: r
@@ -228,168 +191,163 @@ var O = {
228
191
  type: t,
229
192
  parts: a
230
193
  });
231
- }, x = async (e, t) => {
194
+ }, w = async (e, t) => {
232
195
  if (!t) {
233
- v(e);
196
+ x(e);
234
197
  return;
235
198
  }
236
199
  let n = s[e] ?? s[0];
237
200
  if (!n) return;
238
- let r = await V(t);
239
- b(n, e, r);
240
- let i = new Map(g);
241
- i.set(r, t.name), _(i), y(e);
242
- }, S = (e) => {
201
+ let r = await M(t);
202
+ C(n, e, r);
203
+ let i = new Map(y);
204
+ i.set(r, t.name), b(i), S(e);
205
+ }, T = (e) => {
243
206
  let t = s[e];
244
207
  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
- }, C = (e) => {
249
- if (e) return g.get(e);
250
- }, w = (e, t) => {
208
+ C(t, e);
209
+ let n = s[e], r = new Map(y);
210
+ n?.data && j(n, s) && r.delete(n?.data), b(r), S(e);
211
+ }, O = (e) => {
212
+ if (e) return y.get(e);
213
+ }, k = (e, t) => {
251
214
  let n = s[e] ?? s[0];
252
- n && b(n, e, t);
215
+ n && C(n, e, t);
253
216
  };
254
- return /* @__PURE__ */ D(de, {
217
+ return /* @__PURE__ */ h("div", {
218
+ className: "kyc-form-item",
255
219
  id: o,
256
220
  children: [
257
- /* @__PURE__ */ E(fe, { children: `${n + 1}. ${a?.title}` }),
258
- a?.description && /* @__PURE__ */ E(pe, { children: a?.description }),
221
+ /* @__PURE__ */ m("div", {
222
+ className: "kyc-form-item__title",
223
+ children: `${n + 1}. ${a?.title}`
224
+ }),
225
+ a?.description && /* @__PURE__ */ m("div", {
226
+ className: "kyc-form-item__description",
227
+ children: a?.description
228
+ }),
259
229
  s.map((e, r) => {
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, {
230
+ let a = `kyc-form_item_file_${e.type}`, l = E(t), d = p?.[e.type], f = l ? void 0 : d?.title;
231
+ E(t) && e.data && (a = `${a}_${e.data?.substr(-32)}`, j(e, s) || (a = `${a}_${r}`));
232
+ let h = c?.[F(n, r)], g = u.get(F(n, r));
233
+ return e.type === _.Feedback ? /* @__PURE__ */ m(P.KYCFormItemText, {
264
234
  value: e.data,
265
- onFeedbackChange: (e) => w(r, e)
266
- }, a) : /* @__PURE__ */ E(J.KYCFormItemFile, {
235
+ onFeedbackChange: (e) => k(r, e)
236
+ }, a) : /* @__PURE__ */ m(P.KYCFormItemFile, {
267
237
  title: f,
268
238
  data: e.data,
269
239
  type: e.type,
270
- name: C(e.data),
240
+ name: O(e.data),
271
241
  uploaderLabels: i,
272
- error: h || m,
242
+ error: g || h,
273
243
  elementId: `${o}_part_${e.type}_${r}`,
274
- onFileChange: (e) => x(r, e),
275
- onFileRemove: () => S(r)
244
+ onFileChange: (e) => w(r, e),
245
+ onFileRemove: () => T(r)
276
246
  }, a);
277
247
  }),
278
- f && m && /* @__PURE__ */ E(J.KYCFormItemFileExtraPart, {
248
+ f && g && /* @__PURE__ */ m(P.KYCFormItemFileExtraPart, {
279
249
  elementId: `${o}_extra`,
280
- title: h,
250
+ title: v,
281
251
  uploaderLabels: i,
282
- onFileAdd: (e) => x(s.length, e)
252
+ onFileAdd: (e) => w(s.length, e)
283
253
  })
284
254
  ]
285
255
  });
286
- }, he = m.div`
287
- display: flex;
288
- flex-direction: column;
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`
305
- display: flex;
306
- flex-direction: column;
307
- `, Z = m.span`
308
- margin-bottom: ${w * 6}px;
309
- `, Q = {
256
+ }, L = {
310
257
  KYCSuccessScreen: (e) => {
311
258
  let { elementId: t, title: n, description: r, support: a } = e;
312
- return /* @__PURE__ */ D(he, {
259
+ return /* @__PURE__ */ h("div", {
260
+ className: "kyc-status-screen",
313
261
  id: t,
314
262
  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]
322
- }) }),
323
- r && /* @__PURE__ */ E(X, { children: r }),
324
- a && /* @__PURE__ */ E(ge, { children: a })
263
+ /* @__PURE__ */ m("span", {
264
+ className: "kyc-status-screen__item",
265
+ children: /* @__PURE__ */ h("span", {
266
+ className: "kyc-status-screen__success-title",
267
+ id: `${t}_success`,
268
+ role: "status",
269
+ children: [/* @__PURE__ */ m(i, {
270
+ color: o.Success,
271
+ size: u.Small
272
+ }), n]
273
+ })
274
+ }),
275
+ r && /* @__PURE__ */ m("span", {
276
+ className: "kyc-status-screen__item",
277
+ children: r
278
+ }),
279
+ a && /* @__PURE__ */ m("span", {
280
+ className: "kyc-status-screen__support",
281
+ children: a
282
+ })
325
283
  ]
326
284
  });
327
285
  },
328
286
  KYCFailScreen: (e) => {
329
287
  let { elementId: t, title: n, support: r } = e;
330
- return /* @__PURE__ */ D(ve, {
288
+ return /* @__PURE__ */ h("div", {
289
+ className: "kyc-status-screen",
331
290
  id: t,
332
- children: [/* @__PURE__ */ E(Z, { children: /* @__PURE__ */ E(L, {
333
- label: n,
334
- isDocumentPartError: !1
335
- }) }), r]
291
+ children: [/* @__PURE__ */ m("span", {
292
+ className: "kyc-status-screen__item kyc-status-screen__item--fail",
293
+ children: /* @__PURE__ */ m(T, {
294
+ label: n,
295
+ isDocumentPartError: !1
296
+ })
297
+ }), r]
336
298
  });
337
299
  }
338
- }, ye = m.div`
339
- display: flex;
340
- flex-direction: column;
341
- align-items: flex-start;
342
- width: 100%;
343
- `, be = m.div`
344
- font-size: ${v}px;
345
- `, xe = m.div`
346
- width: 100%;
347
- margin-bottom: ${w * 6}px;
348
- `, Se = m.div`
349
- display: flex;
350
- justify-content: flex-end;
351
- width: 100%;
352
- `, $ = (i) => {
353
- 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);
300
+ }, R = (i) => {
301
+ let { elementId: a, title: o, uploadButtonLabel: s, uploaderLabels: c, documentsLabels: l, documents: u, errors: d, isLoading: f, validator: p, onUploadClick: g } = i, [_, v] = r(u), [y, b] = r(!0);
354
302
  n(() => {
355
- g(u);
303
+ v(u);
356
304
  }, [u]), n(() => {
357
- v(!p(h));
358
- }, [h, p]);
359
- let y = (e, t) => {
360
- let n = [...h];
361
- n.splice(e, 1, t), g(n);
305
+ let e = p(_);
306
+ b(!e);
307
+ }, [_, p]);
308
+ let x = (e, t) => {
309
+ let n = [..._];
310
+ n.splice(e, 1, t), v(n);
362
311
  };
363
- return /* @__PURE__ */ D(ye, {
312
+ return /* @__PURE__ */ h("div", {
313
+ className: "kyc-form",
364
314
  id: a,
365
315
  children: [
366
- o && /* @__PURE__ */ E(be, { children: o }),
367
- /* @__PURE__ */ E(xe, { children: h.map((e, t) => {
368
- let n = `kyc-form_item_${e.type}_${t}`;
369
- return /* @__PURE__ */ E(me, {
370
- index: t,
371
- type: e.type,
372
- parts: e.parts,
373
- documentLabels: l[e.type],
374
- uploaderLabels: c,
375
- errors: d,
376
- elementId: `${a}_item_${e.type}`,
377
- onDocumentChange: (e) => y(t, e)
378
- }, n);
379
- }) }),
380
- /* @__PURE__ */ E(Se, { children: /* @__PURE__ */ E(e, {
381
- id: `${a}_button`,
382
- variant: t.Primary,
383
- isDisabled: _,
384
- isLoading: f || !1,
385
- onClick: () => m(h),
386
- children: s
387
- }) })
316
+ o && /* @__PURE__ */ m("div", {
317
+ className: "kyc-form__title",
318
+ children: o
319
+ }),
320
+ /* @__PURE__ */ m("div", {
321
+ className: "kyc-form__documents",
322
+ children: _.map((e, t) => {
323
+ let n = `kyc-form_item_${e.type}_${t}`;
324
+ return /* @__PURE__ */ m(I, {
325
+ index: t,
326
+ type: e.type,
327
+ parts: e.parts,
328
+ documentLabels: l[e.type],
329
+ uploaderLabels: c,
330
+ errors: d,
331
+ elementId: `${a}_item_${e.type}`,
332
+ onDocumentChange: (e) => x(t, e)
333
+ }, n);
334
+ })
335
+ }),
336
+ /* @__PURE__ */ m("div", {
337
+ className: "kyc-form__button",
338
+ children: /* @__PURE__ */ m(e, {
339
+ id: `${a}_button`,
340
+ variant: t.Primary,
341
+ isDisabled: y,
342
+ isLoading: f || !1,
343
+ onClick: () => g(_),
344
+ children: s
345
+ })
346
+ })
388
347
  ]
389
348
  });
390
349
  };
391
- $.SuccessScreen = Q.KYCSuccessScreen, $.FailScreen = Q.KYCFailScreen;
392
- //#endregion
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 };
350
+ R.SuccessScreen = L.KYCSuccessScreen, R.FailScreen = L.KYCFailScreen;
351
+ export { S as ACCEPT_FORMATS, C as AVAILABLE_EXTRA_PARTS_DOCUMENTS, g as DocumentType, y as MAX_EXTRA_PARTS_COUNT, v as MAX_FILE_SIZE, w as OPTIONAL_DOCUMENT_PARTS, b as PDF_MIME_TYPE, _ as PartType, R as default };
394
352
 
395
353
  //# 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 {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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,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":["KYCDocumentParts","KYCStatusScreen","Button","ImageUploader","DocumentType","PartType","MAX_FILE_SIZE","MAX_EXTRA_PARTS_COUNT","PDF_MIME_TYPE","HEIC_MIME_TYPE","ACCEPT_FORMATS","AVAILABLE_EXTRA_PARTS_DOCUMENTS","OPTIONAL_DOCUMENT_PARTS","KYCErrorLabel","props","Close","Color","Size","isDocumentExtraPartAvailable","documentType","canAddExtraPart","parts","part","getMimeType","partData","isPDF","isHEIC","isFileUniqueInDocument","file","getFileBase64","reader","resolve","reject","error","KYCDocumentPartMiniature","isPDFPart","data","isHEICPart","Pdf","Insert","KYCDocumentParts_default","elementId","title","uploaderLabels","Direction","files","onFileAdd","name","onFileRemove","Delete","onFileChange","Textarea","onFeedbackChange","event","getErrorKey","documentIndex","partIndex","KYCFormItem","localErrors","setLocalErrors","useState","isAddExtraPartAvailable","type","documentLabelsParts","documentLabels","firstPart","extraPartTitle","fileNames","setFileNames","setLocalErrorByPartIndex","newLocalErrors","index","deleteLocalErrorByPartIndex","updateDocumentPart","newPart","newParts","onDocumentChange","newFileNames","removedPart","getFileName","key","itemKey","isExtraPartAvailable","partLabels","partTitle","partError","errors","localPartError","value","KYCStatusScreen_default","Check","description","support","KYCForm","userDocuments","setUserDocuments","documents","isButtonDisabled","setButtonDisabled","useEffect","isValid","validator","newDocuments","document","documentsLabels","doc","ButtonVariant","isLoading","onUploadClick","uploadButtonLabel"],"sources":["../src/document.types.ts","../src/constants.ts","../src/KYCErrorLabel/index.tsx","../src/utils.ts","../src/KYCDocumentParts/index.tsx","../src/KYCFormItem/index.tsx","../src/KYCStatusScreen/index.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 {Close, Color, Size} from '@propellerads/icon';\nimport {KYCErrorLabelProps} from './types';\n\nconst KYCErrorLabel = (props: KYCErrorLabelProps) => (\n <div className=\"kyc-error-label\">\n {props.isDocumentPartError ? (\n <span className=\"kyc-error-label__icon\" />\n ) : (\n <Close color={Color.Error} hoverColor={Color.Error} size={Size.Small} />\n )}\n <span className=\"kyc-error-label__text\">{props.label}</span>\n </div>\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 {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 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 <div className=\"kyc-document-part__icon\">\n {isPDFPart && <Pdf color={Color.Gray} hoverColor={Color.Gray} />}\n {isHEICPart && <Insert color={Color.Gray} hoverColor={Color.Gray} />}\n </div>\n );\n }\n\n // Beside the file name, which says what the file is: the miniature adds nothing to read out\n return <img className=\"kyc-document-part__image\" src={data} alt=\"\" />;\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 <div className=\"kyc-document-part kyc-document-part--extra\" id={elementId}>\n {title && <div className=\"kyc-document-part__title\">{title}</div>}\n\n <div className=\"kyc-document-part__uploader\">\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 </div>\n </div>\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 <div className=\"kyc-document-part\" id={elementId}>\n {title && <div className=\"kyc-document-part__title\">{title}</div>}\n\n {data ? (\n <div className=\"kyc-document-part__preview\">\n <KYCDocumentPartMiniature data={data} />\n <span className=\"kyc-document-part__preview-name\">{name}</span>\n {/* biome-ignore lint/a11y/useKeyWithClickEvents: a remove without a keyboard path is the behaviour of 6.x, out of scope of moving off styled-components */}\n <span className=\"kyc-document-part__preview-remove\" onClick={onFileRemove}>\n <Delete color={Color.Blue} hoverColor={Color.Blue} />\n </span>\n </div>\n ) : (\n <div className=\"kyc-document-part__uploader\">\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 </div>\n )}\n\n {error && <KYCErrorLabel label={error} isDocumentPartError />}\n </div>\n );\n};\n\nconst KYCFormItemText = (props: KYCFormItemTextProps) => {\n const {onFeedbackChange, value = ''} = props;\n\n return (\n <div className=\"kyc-document-part\">\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 </div>\n );\n};\n\nexport default {\n KYCFormItemFileExtraPart,\n KYCFormItemFile,\n KYCFormItemText,\n};\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 {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 <div className=\"kyc-form-item\" id={elementId}>\n <div className=\"kyc-form-item__title\">{`${index + 1}. ${documentLabels?.title}`}</div>\n\n {documentLabels?.description && <div className=\"kyc-form-item__description\">{documentLabels?.description}</div>}\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 </div>\n );\n};\n\nexport default KYCFormItem;\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 {KYCFailScreenProps, KYCSuccessScreenProps} from './types';\n\nconst KYCSuccessScreen = (props: KYCSuccessScreenProps) => {\n const {elementId, title, description, support} = props;\n\n return (\n <div className=\"kyc-status-screen\" id={elementId}>\n <span className=\"kyc-status-screen__item\">\n <span className=\"kyc-status-screen__success-title\" id={`${elementId}_success`} role=\"status\">\n <Check color={Color.Success} size={Size.Small} />\n {title}\n </span>\n </span>\n\n {description && <span className=\"kyc-status-screen__item\">{description}</span>}\n\n {support && <span className=\"kyc-status-screen__support\">{support}</span>}\n </div>\n );\n};\n\nconst KYCFailScreen = (props: KYCFailScreenProps) => {\n const {elementId, title, support} = props;\n\n return (\n <div className=\"kyc-status-screen\" id={elementId}>\n <span className=\"kyc-status-screen__item kyc-status-screen__item--fail\">\n <KYCErrorLabel label={title} isDocumentPartError={false} />\n </span>\n\n {support}\n </div>\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 './kyc-form.css';\nimport 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 {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 <div className=\"kyc-form\" id={elementId}>\n {title && <div className=\"kyc-form__title\">{title}</div>}\n\n <div className=\"kyc-form__documents\">\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 </div>\n <div className=\"kyc-form__button\">\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 </div>\n </div>\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,IAAaI,IAAe;CAC1B,IAAI;CACJ,IAAI;CACJ,SAAS;CACT,MAAM;CACN,qBAAqB;CACrB,wBAAwB;CACxB,6BAA6B;CAC7B,kBAAkB;CAClB,mBAAmB;CACnB,iBAAiB;CACjB,yBAAy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C;GACE,CAAA;GACL,kBAAC,OAAD;IAAK,WAAU;IACb,UAAA,kBAAC9E,GAAD;KACE,IAAI,GAAGuC,EAAU;KACjB,SAASiE,EAAc;KACvB,YAAYT;KACZ,WAAWU,KAAa;KACxB,eAAeC,EAAcd,CAAa;KAEzC,UAAAe;IACK,CAAA;GACL,CAAA;EACF;;AAET;AAEA,EAAQ,gBAAgB5G,EAAgB,kBACxC,EAAQ,aAAaA,EAAgB"}
package/package.json CHANGED
@@ -1,14 +1,19 @@
1
1
  {
2
2
  "name": "@propellerads/kyc-form",
3
- "version": "6.0.0",
3
+ "version": "7.0.0",
4
4
  "type": "module",
5
5
  "types": "dist/index.d.ts",
6
+ "style": "dist/index.css",
6
7
  "exports": {
7
8
  ".": {
8
9
  "types": "./dist/index.d.ts",
9
10
  "import": "./dist/index.js"
10
- }
11
+ },
12
+ "./index.css": "./dist/index.css"
11
13
  },
14
+ "sideEffects": [
15
+ "**/*.css"
16
+ ],
12
17
  "files": [
13
18
  "dist"
14
19
  ],
@@ -19,27 +24,28 @@
19
24
  "url": "https://github.com/propellerads/ui-components/issues"
20
25
  },
21
26
  "scripts": {
22
- "build": "tsc && vite build && bunx rollup -c rollup.dts.config.mjs"
27
+ "build": "tsc && vite build && rollup -c rollup.dts.config.mjs"
23
28
  },
24
29
  "homepage": "https://github.com/propellerads/ui-components#readme",
25
30
  "private": false,
26
31
  "dependencies": {
27
- "@propellerads/button": "^13.0.0",
28
- "@propellerads/icon": "^9.0.0",
29
- "@propellerads/image-uploader": "^5.0.0",
30
- "@propellerads/input": "^2.1.0",
31
- "@propellerads/stylevariables": "^2.0.2"
32
+ "@propellerads/button": "^14.0.0",
33
+ "@propellerads/icon": "^11.0.0",
34
+ "@propellerads/image-uploader": "^6.0.0",
35
+ "@propellerads/input": "^3.0.0"
32
36
  },
33
37
  "peerDependencies": {
34
- "react": "^18.0.0 || ^19.0.0",
35
- "styled-components": "^5.1.1 || ^6.0.0"
38
+ "@propellerads/tokens": ">=0.5.0",
39
+ "react": "^18.0.0 || ^19.0.0"
36
40
  },
37
41
  "devDependencies": {
42
+ "@propellerads/tokens": "workspace:^",
38
43
  "@types/react": "^19.2.14",
39
44
  "@vitejs/plugin-react": "^6.0.1",
40
45
  "rollup": "^4.60.3",
41
46
  "rollup-plugin-dts": "^6.4.1",
42
47
  "typescript": "^6.0.3",
43
- "vite": "^8.0.11"
48
+ "vite": "^8.0.11",
49
+ "vite-plugin-lib-inject-css": "^2.2.2"
44
50
  }
45
51
  }