@itcase/forms 1.0.36 → 1.0.38

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.
@@ -32,28 +32,25 @@ import { Group as Group$1 } from '@itcase/ui/components/Group';
32
32
  import { NotificationItem } from '@itcase/ui/components/Notification';
33
33
  import createDecorator from 'final-form-focus';
34
34
 
35
- var phoneValidation = function phoneValidation(value, context) {
35
+ const phoneValidation = (value, context) => {
36
36
  if (!value) {
37
37
  return true;
38
38
  }
39
39
  return isPossiblePhoneNumber(value, 'RU');
40
40
  };
41
- var emailValidation = function emailValidation(value, context) {
41
+ const emailValidation = (value, context) => {
42
42
  // from https://emailregex.com/
43
43
  if (!value) {
44
44
  return true;
45
45
  }
46
46
  // eslint-disable-next-line
47
- var regexp = /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9]{2,}(?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/;
47
+ const regexp = /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9]{2,}(?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/;
48
48
  return regexp.test(String(value).toLowerCase());
49
49
  };
50
- var addRequiredFieldsParamToSchema = function addRequiredFieldsParamToSchema(schema) {
51
- var fields = Object.entries(schema.fields);
52
- schema.requiredFields = fields.reduce(function (list, _ref) {
53
- var _validationProps$excl;
54
- var fieldName = _ref[0],
55
- validationProps = _ref[1];
56
- if ((_validationProps$excl = validationProps.exclusiveTests) != null && _validationProps$excl.required) {
50
+ const addRequiredFieldsParamToSchema = schema => {
51
+ const fields = Object.entries(schema.fields);
52
+ schema.requiredFields = fields.reduce((list, [fieldName, validationProps]) => {
53
+ if (validationProps.exclusiveTests?.required) {
57
54
  list.push(fieldName);
58
55
  }
59
56
  return list;
@@ -61,382 +58,6 @@ var addRequiredFieldsParamToSchema = function addRequiredFieldsParamToSchema(sch
61
58
  return schema;
62
59
  };
63
60
 
64
- function _asyncIterator(r) {
65
- var n,
66
- t,
67
- o,
68
- e = 2;
69
- for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) {
70
- if (t && null != (n = r[t])) return n.call(r);
71
- if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
72
- t = "@@asyncIterator", o = "@@iterator";
73
- }
74
- throw new TypeError("Object is not async iterable");
75
- }
76
- function AsyncFromSyncIterator(r) {
77
- function AsyncFromSyncIteratorContinuation(r) {
78
- if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object."));
79
- var n = r.done;
80
- return Promise.resolve(r.value).then(function (r) {
81
- return {
82
- value: r,
83
- done: n
84
- };
85
- });
86
- }
87
- return AsyncFromSyncIterator = function (r) {
88
- this.s = r, this.n = r.next;
89
- }, AsyncFromSyncIterator.prototype = {
90
- s: null,
91
- n: null,
92
- next: function () {
93
- return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
94
- },
95
- return: function (r) {
96
- var n = this.s.return;
97
- return void 0 === n ? Promise.resolve({
98
- value: r,
99
- done: !0
100
- }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
101
- },
102
- throw: function (r) {
103
- var n = this.s.return;
104
- return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
105
- }
106
- }, new AsyncFromSyncIterator(r);
107
- }
108
- function _regeneratorRuntime() {
109
- _regeneratorRuntime = function () {
110
- return e;
111
- };
112
- var t,
113
- e = {},
114
- r = Object.prototype,
115
- n = r.hasOwnProperty,
116
- o = Object.defineProperty || function (t, e, r) {
117
- t[e] = r.value;
118
- },
119
- i = "function" == typeof Symbol ? Symbol : {},
120
- a = i.iterator || "@@iterator",
121
- c = i.asyncIterator || "@@asyncIterator",
122
- u = i.toStringTag || "@@toStringTag";
123
- function define(t, e, r) {
124
- return Object.defineProperty(t, e, {
125
- value: r,
126
- enumerable: !0,
127
- configurable: !0,
128
- writable: !0
129
- }), t[e];
130
- }
131
- try {
132
- define({}, "");
133
- } catch (t) {
134
- define = function (t, e, r) {
135
- return t[e] = r;
136
- };
137
- }
138
- function wrap(t, e, r, n) {
139
- var i = e && e.prototype instanceof Generator ? e : Generator,
140
- a = Object.create(i.prototype),
141
- c = new Context(n || []);
142
- return o(a, "_invoke", {
143
- value: makeInvokeMethod(t, r, c)
144
- }), a;
145
- }
146
- function tryCatch(t, e, r) {
147
- try {
148
- return {
149
- type: "normal",
150
- arg: t.call(e, r)
151
- };
152
- } catch (t) {
153
- return {
154
- type: "throw",
155
- arg: t
156
- };
157
- }
158
- }
159
- e.wrap = wrap;
160
- var h = "suspendedStart",
161
- l = "suspendedYield",
162
- f = "executing",
163
- s = "completed",
164
- y = {};
165
- function Generator() {}
166
- function GeneratorFunction() {}
167
- function GeneratorFunctionPrototype() {}
168
- var p = {};
169
- define(p, a, function () {
170
- return this;
171
- });
172
- var d = Object.getPrototypeOf,
173
- v = d && d(d(values([])));
174
- v && v !== r && n.call(v, a) && (p = v);
175
- var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
176
- function defineIteratorMethods(t) {
177
- ["next", "throw", "return"].forEach(function (e) {
178
- define(t, e, function (t) {
179
- return this._invoke(e, t);
180
- });
181
- });
182
- }
183
- function AsyncIterator(t, e) {
184
- function invoke(r, o, i, a) {
185
- var c = tryCatch(t[r], t, o);
186
- if ("throw" !== c.type) {
187
- var u = c.arg,
188
- h = u.value;
189
- return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
190
- invoke("next", t, i, a);
191
- }, function (t) {
192
- invoke("throw", t, i, a);
193
- }) : e.resolve(h).then(function (t) {
194
- u.value = t, i(u);
195
- }, function (t) {
196
- return invoke("throw", t, i, a);
197
- });
198
- }
199
- a(c.arg);
200
- }
201
- var r;
202
- o(this, "_invoke", {
203
- value: function (t, n) {
204
- function callInvokeWithMethodAndArg() {
205
- return new e(function (e, r) {
206
- invoke(t, n, e, r);
207
- });
208
- }
209
- return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
210
- }
211
- });
212
- }
213
- function makeInvokeMethod(e, r, n) {
214
- var o = h;
215
- return function (i, a) {
216
- if (o === f) throw new Error("Generator is already running");
217
- if (o === s) {
218
- if ("throw" === i) throw a;
219
- return {
220
- value: t,
221
- done: !0
222
- };
223
- }
224
- for (n.method = i, n.arg = a;;) {
225
- var c = n.delegate;
226
- if (c) {
227
- var u = maybeInvokeDelegate(c, n);
228
- if (u) {
229
- if (u === y) continue;
230
- return u;
231
- }
232
- }
233
- if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
234
- if (o === h) throw o = s, n.arg;
235
- n.dispatchException(n.arg);
236
- } else "return" === n.method && n.abrupt("return", n.arg);
237
- o = f;
238
- var p = tryCatch(e, r, n);
239
- if ("normal" === p.type) {
240
- if (o = n.done ? s : l, p.arg === y) continue;
241
- return {
242
- value: p.arg,
243
- done: n.done
244
- };
245
- }
246
- "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
247
- }
248
- };
249
- }
250
- function maybeInvokeDelegate(e, r) {
251
- var n = r.method,
252
- o = e.iterator[n];
253
- if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
254
- var i = tryCatch(o, e.iterator, r.arg);
255
- if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
256
- var a = i.arg;
257
- return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
258
- }
259
- function pushTryEntry(t) {
260
- var e = {
261
- tryLoc: t[0]
262
- };
263
- 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
264
- }
265
- function resetTryEntry(t) {
266
- var e = t.completion || {};
267
- e.type = "normal", delete e.arg, t.completion = e;
268
- }
269
- function Context(t) {
270
- this.tryEntries = [{
271
- tryLoc: "root"
272
- }], t.forEach(pushTryEntry, this), this.reset(!0);
273
- }
274
- function values(e) {
275
- if (e || "" === e) {
276
- var r = e[a];
277
- if (r) return r.call(e);
278
- if ("function" == typeof e.next) return e;
279
- if (!isNaN(e.length)) {
280
- var o = -1,
281
- i = function next() {
282
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
283
- return next.value = t, next.done = !0, next;
284
- };
285
- return i.next = i;
286
- }
287
- }
288
- throw new TypeError(typeof e + " is not iterable");
289
- }
290
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
291
- value: GeneratorFunctionPrototype,
292
- configurable: !0
293
- }), o(GeneratorFunctionPrototype, "constructor", {
294
- value: GeneratorFunction,
295
- configurable: !0
296
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
297
- var e = "function" == typeof t && t.constructor;
298
- return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
299
- }, e.mark = function (t) {
300
- return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
301
- }, e.awrap = function (t) {
302
- return {
303
- __await: t
304
- };
305
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
306
- return this;
307
- }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
308
- void 0 === i && (i = Promise);
309
- var a = new AsyncIterator(wrap(t, r, n, o), i);
310
- return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
311
- return t.done ? t.value : a.next();
312
- });
313
- }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
314
- return this;
315
- }), define(g, "toString", function () {
316
- return "[object Generator]";
317
- }), e.keys = function (t) {
318
- var e = Object(t),
319
- r = [];
320
- for (var n in e) r.push(n);
321
- return r.reverse(), function next() {
322
- for (; r.length;) {
323
- var t = r.pop();
324
- if (t in e) return next.value = t, next.done = !1, next;
325
- }
326
- return next.done = !0, next;
327
- };
328
- }, e.values = values, Context.prototype = {
329
- constructor: Context,
330
- reset: function (e) {
331
- if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
332
- },
333
- stop: function () {
334
- this.done = !0;
335
- var t = this.tryEntries[0].completion;
336
- if ("throw" === t.type) throw t.arg;
337
- return this.rval;
338
- },
339
- dispatchException: function (e) {
340
- if (this.done) throw e;
341
- var r = this;
342
- function handle(n, o) {
343
- return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
344
- }
345
- for (var o = this.tryEntries.length - 1; o >= 0; --o) {
346
- var i = this.tryEntries[o],
347
- a = i.completion;
348
- if ("root" === i.tryLoc) return handle("end");
349
- if (i.tryLoc <= this.prev) {
350
- var c = n.call(i, "catchLoc"),
351
- u = n.call(i, "finallyLoc");
352
- if (c && u) {
353
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
354
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
355
- } else if (c) {
356
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
357
- } else {
358
- if (!u) throw new Error("try statement without catch or finally");
359
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
360
- }
361
- }
362
- }
363
- },
364
- abrupt: function (t, e) {
365
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
366
- var o = this.tryEntries[r];
367
- if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
368
- var i = o;
369
- break;
370
- }
371
- }
372
- i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
373
- var a = i ? i.completion : {};
374
- return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
375
- },
376
- complete: function (t, e) {
377
- if ("throw" === t.type) throw t.arg;
378
- return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
379
- },
380
- finish: function (t) {
381
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
382
- var r = this.tryEntries[e];
383
- if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
384
- }
385
- },
386
- catch: function (t) {
387
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
388
- var r = this.tryEntries[e];
389
- if (r.tryLoc === t) {
390
- var n = r.completion;
391
- if ("throw" === n.type) {
392
- var o = n.arg;
393
- resetTryEntry(r);
394
- }
395
- return o;
396
- }
397
- }
398
- throw new Error("illegal catch attempt");
399
- },
400
- delegateYield: function (e, r, n) {
401
- return this.delegate = {
402
- iterator: values(e),
403
- resultName: r,
404
- nextLoc: n
405
- }, "next" === this.method && (this.arg = t), y;
406
- }
407
- }, e;
408
- }
409
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
410
- try {
411
- var info = gen[key](arg);
412
- var value = info.value;
413
- } catch (error) {
414
- reject(error);
415
- return;
416
- }
417
- if (info.done) {
418
- resolve(value);
419
- } else {
420
- Promise.resolve(value).then(_next, _throw);
421
- }
422
- }
423
- function _asyncToGenerator(fn) {
424
- return function () {
425
- var self = this,
426
- args = arguments;
427
- return new Promise(function (resolve, reject) {
428
- var gen = fn.apply(self, args);
429
- function _next(value) {
430
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
431
- }
432
- function _throw(err) {
433
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
434
- }
435
- _next(undefined);
436
- });
437
- };
438
- }
439
-
440
61
  /**
441
62
  * Sets the `innerError.message` in an `errors` object at the key
442
63
  * defined by `innerError.path`.
@@ -444,7 +65,7 @@ function _asyncToGenerator(fn) {
444
65
  * @param {{ path: string, message: string }} innerError A `yup` field error.
445
66
  * @returns {Object} The result of setting the new error message onto `errors`.
446
67
  */
447
- var setInError = function setInError(errors, innerError) {
68
+ const setInError = (errors, innerError) => {
448
69
  return setIn(errors, innerError.path, innerError.message);
449
70
  };
450
71
 
@@ -453,7 +74,7 @@ var setInError = function setInError(errors, innerError) {
453
74
  * value for reducing the `err.inner` array of errors
454
75
  * from a `yup~ValidationError`.
455
76
  */
456
- var emptyObj = Object.create(null);
77
+ const emptyObj = Object.create(null);
457
78
 
458
79
  /**
459
80
  * Takes a `yup` validation schema and returns a function that expects
@@ -465,146 +86,122 @@ var emptyObj = Object.create(null);
465
86
  * and resolves to either `undefined` or a map of field names to error messages.
466
87
  */
467
88
 
468
- var makeValidate = function makeValidate(schema) {
469
- return /*#__PURE__*/function () {
470
- var _validate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(values) {
471
- return _regeneratorRuntime().wrap(function _callee$(_context) {
472
- while (1) switch (_context.prev = _context.next) {
473
- case 0:
474
- _context.prev = 0;
475
- _context.next = 3;
476
- return schema.validate(values, {
477
- abortEarly: false
478
- });
479
- case 3:
480
- _context.next = 12;
481
- break;
482
- case 5:
483
- _context.prev = 5;
484
- _context.t0 = _context["catch"](0);
485
- if (!_context.t0.inner) {
486
- _context.next = 11;
487
- break;
488
- }
489
- return _context.abrupt("return", _context.t0.inner.reduce(setInError, emptyObj));
490
- case 11:
491
- console.warn('itcase-forms schema.validate error: An error not related to the form occurred during validation. Validation ignored.');
492
- case 12:
493
- case "end":
494
- return _context.stop();
495
- }
496
- }, _callee, null, [[0, 5]]);
497
- }));
498
- function validate(_x) {
499
- return _validate.apply(this, arguments);
89
+ const makeValidate = schema => {
90
+ return async function validate(values) {
91
+ try {
92
+ await schema.validate(values, {
93
+ abortEarly: false
94
+ });
95
+ } catch (error) {
96
+ if (error.inner) {
97
+ return error.inner.reduce(setInError, emptyObj);
98
+ } else {
99
+ console.warn('itcase-forms schema.validate error: An error not related to the form occurred during validation. Validation ignored.');
100
+ }
500
101
  }
501
- return validate;
502
- }();
102
+ };
503
103
  };
504
104
  function useYupValidationSchema(schema, language) {
505
- var validate = useMemo(function () {
506
- return schema && makeValidate(schema);
507
- }, [schema, language]);
105
+ const validate = useMemo(() => schema && makeValidate(schema), [schema, language]);
508
106
  return validate;
509
107
  }
510
108
 
511
109
  function FieldWrapperBase(props) {
512
- var after = props.after,
513
- afterItem = props.afterItem,
514
- before = props.before,
515
- beforeItem = props.beforeItem,
516
- children = props.children,
517
- className = props.className,
518
- desc = props.desc,
519
- descTextSize = props.descTextSize,
520
- descTextColor = props.descTextColor,
521
- descTextWidth = props.descTextWidth,
522
- divider = props.divider,
523
- dividerDirection = props.dividerDirection,
524
- dividerFill = props.dividerFill,
525
- dividerSize = props.dividerSize,
526
- dividerWidth = props.dividerWidth,
527
- fieldClassName = props.fieldClassName,
528
- id = props.id,
529
- inputName = props.inputName,
530
- inputValue = props.inputValue,
531
- isRequired = props.isRequired,
532
- label = props.label,
533
- labelTextSize = props.labelTextSize,
534
- labelTextColor = props.labelTextColor,
535
- labelTextWidth = props.labelTextWidth,
536
- errorMessageTextSize = props.errorMessageTextSize,
537
- errorMessageTextWeight = props.errorMessageTextWeight,
538
- errorMessageTextColor = props.errorMessageTextColor,
539
- message = props.message,
540
- messageTextSize = props.messageTextSize,
541
- messageTextColor = props.messageTextColor,
542
- messageTextWeight = props.messageTextWeight,
543
- metaActive = props.metaActive,
544
- metaError = props.metaError,
545
- metaModifiedSinceLastSubmit = props.metaModifiedSinceLastSubmit,
546
- metaSubmitError = props.metaSubmitError,
547
- metaSubmitFailed = props.metaSubmitFailed,
548
- metaTouched = props.metaTouched,
549
- metaValid = props.metaValid,
550
- set = props.set,
551
- type = props.type,
552
- hideMessage = props.hideMessage,
553
- isHidden = props.isHidden,
554
- Tag = props.tag,
555
- dataTour = props.dataTour,
556
- showErrorsOnSubmit = props.showErrorsOnSubmit;
557
- var error = metaError || !metaModifiedSinceLastSubmit && metaSubmitError || false;
558
- var showError = useMemo(function () {
110
+ const {
111
+ after,
112
+ afterItem,
113
+ before,
114
+ beforeItem,
115
+ children,
116
+ className,
117
+ desc,
118
+ descTextSize,
119
+ descTextColor,
120
+ descTextWidth,
121
+ divider,
122
+ dividerDirection,
123
+ dividerFill,
124
+ dividerSize,
125
+ dividerWidth,
126
+ fieldClassName,
127
+ id,
128
+ inputName,
129
+ inputValue,
130
+ isRequired,
131
+ label,
132
+ labelTextSize,
133
+ labelTextColor,
134
+ labelTextWidth,
135
+ errorMessageTextSize,
136
+ errorMessageTextWeight,
137
+ errorMessageTextColor,
138
+ message,
139
+ messageTextSize,
140
+ messageTextColor,
141
+ messageTextWeight,
142
+ metaActive,
143
+ metaError,
144
+ metaModifiedSinceLastSubmit,
145
+ metaSubmitError,
146
+ metaSubmitFailed,
147
+ metaTouched,
148
+ metaValid,
149
+ set,
150
+ type,
151
+ hideMessage,
152
+ isHidden,
153
+ tag: Tag,
154
+ dataTour,
155
+ showErrorsOnSubmit
156
+ } = props;
157
+ const error = metaError || !metaModifiedSinceLastSubmit && metaSubmitError || false;
158
+ const showError = useMemo(() => {
559
159
  if (showErrorsOnSubmit) {
560
160
  return metaSubmitFailed && metaTouched && error;
561
161
  } else {
562
162
  return metaTouched && error;
563
163
  }
564
164
  }, [showErrorsOnSubmit, metaSubmitFailed, metaTouched, error]);
565
- var showValid = useMemo(function () {
566
- var hasValue = Array.isArray(inputValue) ? inputValue.length : inputValue;
567
- var isModifiedAfterSubmit = !metaError && metaSubmitError && metaModifiedSinceLastSubmit;
165
+ const showValid = useMemo(() => {
166
+ const hasValue = Array.isArray(inputValue) ? inputValue.length : inputValue;
167
+ const isModifiedAfterSubmit = !metaError && metaSubmitError && metaModifiedSinceLastSubmit;
568
168
  return hasValue && (metaValid || isModifiedAfterSubmit);
569
169
  }, [inputValue, metaValid, metaError, metaSubmitError, metaModifiedSinceLastSubmit]);
570
- var formFieldClass = useMemo(function () {
571
- return clsx(className, showError && 'form__item_state_error', showValid && 'form__item_state_success', isRequired && 'form__item_state_required', metaActive && 'form__item_state_focus', inputValue && 'form__item_state_filled');
572
- }, [className, showError, showValid, isRequired, metaActive, inputValue]);
573
- var fieldClass = useMemo(function () {
574
- return clsx(fieldClassName, showError && fieldClassName + "_state_error", showValid && fieldClassName + "_state_success", metaActive && fieldClassName + "_state_focus", inputValue && fieldClassName + "_state_filled");
575
- }, [fieldClassName, showError, showValid, metaActive, inputValue]);
576
- var sizeClass = useDeviceTargetClass(props, {
170
+ const formFieldClass = useMemo(() => clsx(className, showError && 'form__item_state_error', showValid && 'form__item_state_success', isRequired && 'form__item_state_required', metaActive && 'form__item_state_focus', inputValue && 'form__item_state_filled'), [className, showError, showValid, isRequired, metaActive, inputValue]);
171
+ const fieldClass = useMemo(() => clsx(fieldClassName, showError && `${fieldClassName}_state_error`, showValid && `${fieldClassName}_state_success`, metaActive && `${fieldClassName}_state_focus`, inputValue && `${fieldClassName}_state_filled`), [fieldClassName, showError, showValid, metaActive, inputValue]);
172
+ const sizeClass = useDeviceTargetClass(props, {
577
173
  prefix: 'form-field_size_',
578
174
  propsKey: 'size'
579
175
  });
580
- var fillClass = useDeviceTargetClass(props, {
176
+ const fillClass = useDeviceTargetClass(props, {
581
177
  prefix: 'fill_',
582
178
  propsKey: 'fill'
583
179
  });
584
- var inputFillClass = useDeviceTargetClass(props, {
180
+ const inputFillClass = useDeviceTargetClass(props, {
585
181
  prefix: 'fill_',
586
182
  propsKey: 'inputFill'
587
183
  });
588
- var shapeClass = useDeviceTargetClass(props, {
184
+ const shapeClass = useDeviceTargetClass(props, {
589
185
  prefix: 'form-field_shape_',
590
186
  propsKey: 'shape'
591
187
  });
592
- var inputShapeClass = useDeviceTargetClass(props, {
188
+ const inputShapeClass = useDeviceTargetClass(props, {
593
189
  prefix: 'form-field__item-value_shape_',
594
190
  propsKey: 'inputShape'
595
191
  });
596
- var directionClass = useDeviceTargetClass(props, {
192
+ const directionClass = useDeviceTargetClass(props, {
597
193
  prefix: 'direction_',
598
194
  propsKey: 'direction'
599
195
  });
600
- var widthClass = useDeviceTargetClass(props, {
196
+ const widthClass = useDeviceTargetClass(props, {
601
197
  prefix: 'width_',
602
198
  propsKey: 'width'
603
199
  });
604
- var _useStyles = useStyles(props),
605
- formFieldStyles = _useStyles.styles;
200
+ const {
201
+ styles: formFieldStyles
202
+ } = useStyles(props);
606
203
  return /*#__PURE__*/React.createElement(Tag, {
607
- className: clsx(formFieldClass, 'form__item', 'form-field', type && "form-field_type_" + type, set && "form-field_set_" + set, sizeClass, fillClass, shapeClass, isHidden && "form-field_state_hidden", directionClass, widthClass),
204
+ className: clsx(formFieldClass, 'form__item', 'form-field', type && `form-field_type_${type}`, set && `form-field_set_${set}`, sizeClass, fillClass, shapeClass, isHidden && `form-field_state_hidden`, directionClass, widthClass),
608
205
  "data-tour": dataTour,
609
206
  style: formFieldStyles
610
207
  }, before, label && /*#__PURE__*/React.createElement("div", {
@@ -637,7 +234,7 @@ function FieldWrapperBase(props) {
637
234
  size: errorMessageTextSize,
638
235
  textWeight: errorMessageTextWeight,
639
236
  textColor: errorMessageTextColor,
640
- id: inputName + "-error"
237
+ id: `${inputName}-error`
641
238
  }, error), Boolean(message) && !showError && /*#__PURE__*/React.createElement(Text, {
642
239
  className: "form-field__message-item form-field__message-item_type_message",
643
240
  size: messageTextSize,
@@ -646,7 +243,7 @@ function FieldWrapperBase(props) {
646
243
  }, message), Boolean(!showError) && Boolean(!message) && /*#__PURE__*/React.createElement(Text, {
647
244
  className: "form-field__message-item form-field__message-item_type_message",
648
245
  size: messageTextSize
649
- }, "\xA0")), after);
246
+ }, '\u00A0')), after);
650
247
  }
651
248
  FieldWrapperBase.defaultProps = {
652
249
  tag: 'div',
@@ -702,12 +299,15 @@ FieldWrapperBase.propTypes = {
702
299
  type: PropTypes.string
703
300
  };
704
301
  function FieldWrapper(props) {
705
- var inputName = props.inputName;
706
- var _useForm = useForm(),
707
- change = _useForm.change; // , mutators
302
+ const {
303
+ inputName
304
+ } = props;
305
+ const {
306
+ change
307
+ } = useForm(); // , mutators
708
308
 
709
- useEffect(function () {
710
- return function () {
309
+ useEffect(() => {
310
+ return () => {
711
311
  change(inputName, undefined);
712
312
  };
713
313
  }, []);
@@ -737,21 +337,24 @@ FieldWrapper.propTypes = {
737
337
  showErrorsOnSubmit: PropTypes.bool
738
338
  };
739
339
 
740
- var CheckboxField = /*#__PURE__*/React.memo(function CheckboxField(props) {
741
- var name = props.name,
742
- isRequired = props.isRequired,
743
- onChange = props.onChange,
744
- fieldProps = props.fieldProps,
745
- inputProps = props.inputProps,
746
- classNameGroupItem = props.classNameGroupItem,
747
- hideMessage = props.hideMessage;
340
+ const CheckboxField = /*#__PURE__*/React.memo(function CheckboxField(props) {
341
+ const {
342
+ name,
343
+ isRequired,
344
+ onChange,
345
+ fieldProps,
346
+ inputProps,
347
+ classNameGroupItem,
348
+ hideMessage
349
+ } = props;
748
350
  return /*#__PURE__*/React.createElement(Field, {
749
351
  name: name,
750
352
  type: "checkbox"
751
- }, function (_ref) {
752
- var input = _ref.input,
753
- meta = _ref.meta;
754
- var onChangeField = useCallback(function (event) {
353
+ }, ({
354
+ input,
355
+ meta
356
+ }) => {
357
+ const onChangeField = useCallback(event => {
755
358
  input.onChange(event);
756
359
  if (onChange) {
757
360
  onChange(event.target.checked, input.name);
@@ -795,41 +398,43 @@ CheckboxField.propTypes = {
795
398
  onChange: PropTypes.func
796
399
  };
797
400
 
798
- var ChoiceField = /*#__PURE__*/React.memo(function ChoiceField(props) {
799
- var options = props.options,
800
- classNameGroupItem = props.classNameGroupItem,
801
- fieldProps = props.fieldProps,
802
- inputProps = props.inputProps,
803
- isMultiple = props.isMultiple,
804
- isRequired = props.isRequired,
805
- initialValue = props.initialValue,
806
- label = props.label,
807
- name = props.name,
808
- messageType = props.messageType,
809
- hideMessage = props.hideMessage,
810
- placeholder = props.placeholder;
811
- var _useForm = useForm(),
812
- change = _useForm.change;
401
+ const ChoiceField = /*#__PURE__*/React.memo(function ChoiceField(props) {
402
+ const {
403
+ options,
404
+ classNameGroupItem,
405
+ fieldProps,
406
+ inputProps,
407
+ isMultiple,
408
+ isRequired,
409
+ initialValue,
410
+ label,
411
+ name,
412
+ messageType,
413
+ hideMessage,
414
+ placeholder
415
+ } = props;
416
+ const {
417
+ change
418
+ } = useForm();
813
419
  return /*#__PURE__*/React.createElement(Field, {
814
420
  name: name,
815
421
  initialValue: initialValue
816
- }, function (_ref) {
817
- var input = _ref.input,
818
- meta = _ref.meta;
819
- var activeOption = useMemo(function () {
820
- var emptyOption = {
422
+ }, ({
423
+ input,
424
+ meta
425
+ }) => {
426
+ const activeOption = useMemo(() => {
427
+ const emptyOption = {
821
428
  value: null,
822
429
  label: null
823
430
  };
824
431
  if (input.value) {
825
- var currentOption = options.find(function (option) {
826
- return option.value === input.value;
827
- });
432
+ const currentOption = options.find(option => option.value === input.value);
828
433
  return currentOption || emptyOption;
829
434
  }
830
435
  return emptyOption;
831
436
  }, [input.value]);
832
- var setActiveSegment = useCallback(function (option) {
437
+ const setActiveSegment = useCallback(option => {
833
438
  change(name, option.value);
834
439
  }, [change]);
835
440
  return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
@@ -872,37 +477,38 @@ ChoiceField.propTypes = {
872
477
  placeholder: PropTypes.string
873
478
  };
874
479
 
875
- var CustomField = /*#__PURE__*/React.memo(function CustomField(props) {
876
- var Component = props.Component,
877
- isRequired = props.isRequired,
878
- name = props.name,
879
- fieldProps = props.fieldProps,
880
- classNameGroupItem = props.classNameGroupItem,
881
- hideMessage = props.hideMessage;
480
+ const CustomField = /*#__PURE__*/React.memo(function CustomField(props) {
481
+ const {
482
+ Component,
483
+ isRequired,
484
+ name,
485
+ fieldProps,
486
+ classNameGroupItem,
487
+ hideMessage
488
+ } = props;
882
489
  return /*#__PURE__*/React.createElement(Field, {
883
490
  name: name
884
- }, function (_ref) {
885
- var input = _ref.input,
886
- meta = _ref.meta;
887
- return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
888
- className: clsx('form-field_type_custom', 'form__item_type_custom', classNameGroupItem),
889
- fieldClassName: 'form-custom',
890
- inputName: input.name,
891
- inputValue: input.value,
892
- isRequired: isRequired,
893
- metaActive: meta.active,
894
- metaError: meta.error,
895
- metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
896
- metaSubmitError: meta.submitError,
897
- metaSubmitFailed: meta.submitFailed,
898
- metaTouched: meta.touched,
899
- metaValid: meta.valid,
900
- hideMessage: hideMessage
901
- }, fieldProps), /*#__PURE__*/React.createElement(Component, Object.assign({}, props, {
902
- input: input,
903
- meta: meta
904
- })));
905
- });
491
+ }, ({
492
+ input,
493
+ meta
494
+ }) => /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
495
+ className: clsx('form-field_type_custom', 'form__item_type_custom', classNameGroupItem),
496
+ fieldClassName: 'form-custom',
497
+ inputName: input.name,
498
+ inputValue: input.value,
499
+ isRequired: isRequired,
500
+ metaActive: meta.active,
501
+ metaError: meta.error,
502
+ metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
503
+ metaSubmitError: meta.submitError,
504
+ metaSubmitFailed: meta.submitFailed,
505
+ metaTouched: meta.touched,
506
+ metaValid: meta.valid,
507
+ hideMessage: hideMessage
508
+ }, fieldProps), /*#__PURE__*/React.createElement(Component, Object.assign({}, props, {
509
+ input: input,
510
+ meta: meta
511
+ }))));
906
512
  });
907
513
  CustomField.defaultProps = {
908
514
  inputProps: {},
@@ -915,41 +521,42 @@ CustomField.propTypes = {
915
521
  inputProps: PropTypes.object
916
522
  };
917
523
 
918
- var CodeField = /*#__PURE__*/React.memo(function CodeField(props) {
919
- var isRequired = props.isRequired,
920
- name = props.name,
921
- fieldProps = props.fieldProps,
922
- inputProps = props.inputProps,
923
- classNameGroupItem = props.classNameGroupItem,
924
- hideMessage = props.hideMessage;
524
+ const CodeField = /*#__PURE__*/React.memo(function CodeField(props) {
525
+ const {
526
+ isRequired,
527
+ name,
528
+ fieldProps,
529
+ inputProps,
530
+ classNameGroupItem,
531
+ hideMessage
532
+ } = props;
925
533
  return /*#__PURE__*/React.createElement(Field, {
926
534
  name: name
927
- }, function (_ref) {
928
- var input = _ref.input,
929
- meta = _ref.meta;
930
- return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
931
- className: clsx('form-field_type_code', 'form__item_type_code', classNameGroupItem),
932
- fieldClassName: 'form-code',
933
- inputName: input.name,
934
- inputValue: input.value,
935
- isRequired: isRequired,
936
- metaActive: meta.active,
937
- metaError: meta.error,
938
- metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
939
- metaSubmitError: meta.submitError,
940
- metaSubmitFailed: meta.submitFailed,
941
- metaTouched: meta.touched,
942
- metaValid: meta.valid,
943
- hideMessage: hideMessage
944
- }, fieldProps), /*#__PURE__*/React.createElement(Code, Object.assign({
945
- autoComplete: "nope",
946
- name: input.name,
947
- value: input.value,
948
- onBlur: input.onBlur,
949
- onChange: input.onChange,
950
- onFocus: input.onFocus
951
- }, inputProps)));
952
- });
535
+ }, ({
536
+ input,
537
+ meta
538
+ }) => /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
539
+ className: clsx('form-field_type_code', 'form__item_type_code', classNameGroupItem),
540
+ fieldClassName: 'form-code',
541
+ inputName: input.name,
542
+ inputValue: input.value,
543
+ isRequired: isRequired,
544
+ metaActive: meta.active,
545
+ metaError: meta.error,
546
+ metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
547
+ metaSubmitError: meta.submitError,
548
+ metaSubmitFailed: meta.submitFailed,
549
+ metaTouched: meta.touched,
550
+ metaValid: meta.valid,
551
+ hideMessage: hideMessage
552
+ }, fieldProps), /*#__PURE__*/React.createElement(Code, Object.assign({
553
+ autoComplete: "nope",
554
+ name: input.name,
555
+ value: input.value,
556
+ onBlur: input.onBlur,
557
+ onChange: input.onChange,
558
+ onFocus: input.onFocus
559
+ }, inputProps))));
953
560
  });
954
561
  CodeField.defaultProps = {
955
562
  inputProps: {},
@@ -963,28 +570,31 @@ CodeField.propTypes = {
963
570
  };
964
571
 
965
572
  function DatePickerField(props) {
966
- var isRequired = props.isRequired,
967
- fieldProps = props.fieldProps,
968
- inputProps = props.inputProps,
969
- datePickerProps = props.datePickerProps,
970
- name = props.name;
971
- props.iconSize;
972
- props.iconBorder;
973
- props.iconBorderHover;
974
- props.iconFill;
975
- props.iconFillHover;
976
- props.iconRevealableShow;
977
- props.iconRevealableHide;
978
- props.iconShape;
979
- var hideMessage = props.hideMessage,
980
- onChange = props.onChange,
981
- classNameGroupItem = props.classNameGroupItem;
573
+ const {
574
+ isRequired,
575
+ fieldProps,
576
+ inputProps,
577
+ datePickerProps,
578
+ name,
579
+ iconSize,
580
+ iconBorder,
581
+ iconBorderHover,
582
+ iconFill,
583
+ iconFillHover,
584
+ iconRevealableShow,
585
+ iconRevealableHide,
586
+ iconShape,
587
+ hideMessage,
588
+ onChange,
589
+ classNameGroupItem
590
+ } = props;
982
591
  return /*#__PURE__*/React.createElement(Field, {
983
592
  name: name
984
- }, function (_ref) {
985
- var input = _ref.input,
986
- meta = _ref.meta;
987
- var onChangeField = useCallback(function (value) {
593
+ }, ({
594
+ input,
595
+ meta
596
+ }) => {
597
+ const onChangeField = useCallback(value => {
988
598
  input.onChange(value);
989
599
  if (onChange) {
990
600
  onChange(value, input.name);
@@ -1027,161 +637,78 @@ DatePickerField.propTypes = {
1027
637
  onChange: PropTypes.func
1028
638
  };
1029
639
 
1030
- function getFileByURL(_x) {
1031
- return _getFileByURL.apply(this, arguments);
640
+ async function getFileByURL(url) {
641
+ try {
642
+ const response = await axios({
643
+ url: `/api/${url}/`,
644
+ responseType: 'blob'
645
+ });
646
+ const blobObject = response.data;
647
+ const dirtyFilename = response.headers['content-disposition']?.split('filename=')[1];
648
+ // Remove double quotes
649
+ let filename = dirtyFilename?.substring(1).slice(0, -1);
650
+ if (!filename) {
651
+ const typeParts = blobObject.type.split('/');
652
+ const fileType = typeParts[typeParts.length - 1];
653
+ filename = `${new Date().getTime()}.${fileType}`;
654
+ }
655
+ return new File([blobObject], filename, {
656
+ type: blobObject.type
657
+ });
658
+ } catch (error) {
659
+ console.log('error: ', error);
660
+ return null;
661
+ }
1032
662
  }
1033
- function _getFileByURL() {
1034
- _getFileByURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(url) {
1035
- var _response$headers$con, response, blobObject, dirtyFilename, filename, typeParts, fileType;
1036
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1037
- while (1) switch (_context3.prev = _context3.next) {
1038
- case 0:
1039
- _context3.prev = 0;
1040
- _context3.next = 3;
1041
- return axios({
1042
- url: "/api/" + url + "/",
1043
- responseType: 'blob'
1044
- });
1045
- case 3:
1046
- response = _context3.sent;
1047
- blobObject = response.data;
1048
- dirtyFilename = (_response$headers$con = response.headers['content-disposition']) == null ? void 0 : _response$headers$con.split('filename=')[1]; // Remove double quotes
1049
- filename = dirtyFilename == null ? void 0 : dirtyFilename.substring(1).slice(0, -1);
1050
- if (!filename) {
1051
- typeParts = blobObject.type.split('/');
1052
- fileType = typeParts[typeParts.length - 1];
1053
- filename = new Date().getTime() + "." + fileType;
1054
- }
1055
- return _context3.abrupt("return", new File([blobObject], filename, {
1056
- type: blobObject.type
1057
- }));
1058
- case 11:
1059
- _context3.prev = 11;
1060
- _context3.t0 = _context3["catch"](0);
1061
- console.log('error: ', _context3.t0);
1062
- return _context3.abrupt("return", null);
1063
- case 15:
1064
- case "end":
1065
- return _context3.stop();
663
+ async function convertToFiles(inputValue, isPreviews) {
664
+ const newFiles = [];
665
+ for await (const value of castArray(inputValue)) {
666
+ let newFile = null;
667
+
668
+ // Download image by url and save as File instance
669
+ const isURL = typeof value === 'string' && value.includes('/');
670
+ if (value.image || isURL) {
671
+ newFile = await getFileByURL(value.image || value);
672
+ if (newFile) {
673
+ setFileDataURL(newFile);
1066
674
  }
1067
- }, _callee3, null, [[0, 11]]);
1068
- }));
1069
- return _getFileByURL.apply(this, arguments);
1070
- }
1071
- function convertToFiles(_x2, _x3) {
1072
- return _convertToFiles.apply(this, arguments);
1073
- }
1074
- function _convertToFiles() {
1075
- _convertToFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(inputValue, isPreviews) {
1076
- var newFiles, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, value, newFile, isURL;
1077
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
1078
- while (1) switch (_context4.prev = _context4.next) {
1079
- case 0:
1080
- newFiles = [];
1081
- _iteratorAbruptCompletion = false;
1082
- _didIteratorError = false;
1083
- _context4.prev = 3;
1084
- _iterator = _asyncIterator(castArray(inputValue));
1085
- case 5:
1086
- _context4.next = 7;
1087
- return _iterator.next();
1088
- case 7:
1089
- if (!(_iteratorAbruptCompletion = !(_step = _context4.sent).done)) {
1090
- _context4.next = 21;
1091
- break;
1092
- }
1093
- value = _step.value;
1094
- newFile = null; // Download image by url and save as File instance
1095
- isURL = typeof value === 'string' && value.includes('/');
1096
- if (!(value.image || isURL)) {
1097
- _context4.next = 16;
1098
- break;
1099
- }
1100
- _context4.next = 14;
1101
- return getFileByURL(value.image || value);
1102
- case 14:
1103
- newFile = _context4.sent;
1104
- if (newFile) {
1105
- setFileDataURL(newFile);
1106
- }
1107
- case 16:
1108
- // Convert dataURL to File instance
1109
- if (value.dataURL) {
1110
- newFile = createFileFromDataURL(value.name || value.path, value.dataURL);
1111
- newFile.dataURL = value.dataURL;
1112
- }
675
+ }
1113
676
 
1114
- // Save new File to state
1115
- if (newFile) {
1116
- newFile.id = value.id;
1117
- if (isPreviews) {
1118
- newFile.preview = URL.createObjectURL(newFile);
1119
- }
1120
- newFiles.push(newFile);
1121
- }
677
+ // Convert dataURL to File instance
678
+ if (value.dataURL) {
679
+ newFile = createFileFromDataURL(value.name || value.path, value.dataURL);
680
+ newFile.dataURL = value.dataURL;
681
+ }
1122
682
 
1123
- // else if (value) {
1124
- // newFiles.push({
1125
- // name: value,
1126
- // error: 'File is unavailable',
1127
- // })
1128
- // }
1129
- case 18:
1130
- _iteratorAbruptCompletion = false;
1131
- _context4.next = 5;
1132
- break;
1133
- case 21:
1134
- _context4.next = 27;
1135
- break;
1136
- case 23:
1137
- _context4.prev = 23;
1138
- _context4.t0 = _context4["catch"](3);
1139
- _didIteratorError = true;
1140
- _iteratorError = _context4.t0;
1141
- case 27:
1142
- _context4.prev = 27;
1143
- _context4.prev = 28;
1144
- if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
1145
- _context4.next = 32;
1146
- break;
1147
- }
1148
- _context4.next = 32;
1149
- return _iterator["return"]();
1150
- case 32:
1151
- _context4.prev = 32;
1152
- if (!_didIteratorError) {
1153
- _context4.next = 35;
1154
- break;
1155
- }
1156
- throw _iteratorError;
1157
- case 35:
1158
- return _context4.finish(32);
1159
- case 36:
1160
- return _context4.finish(27);
1161
- case 37:
1162
- return _context4.abrupt("return", newFiles);
1163
- case 38:
1164
- case "end":
1165
- return _context4.stop();
683
+ // Save new File to state
684
+ if (newFile) {
685
+ newFile.id = value.id;
686
+ if (isPreviews) {
687
+ newFile.preview = URL.createObjectURL(newFile);
1166
688
  }
1167
- }, _callee4, null, [[3, 23, 27, 37], [28,, 32, 36]]);
1168
- }));
1169
- return _convertToFiles.apply(this, arguments);
689
+ newFiles.push(newFile);
690
+ }
691
+
692
+ // else if (value) {
693
+ // newFiles.push({
694
+ // name: value,
695
+ // error: 'File is unavailable',
696
+ // })
697
+ // }
698
+ }
699
+
700
+ return newFiles;
1170
701
  }
1171
702
  function setFileDataURL(file, resolve) {
1172
- resolve = resolve || function () {};
703
+ resolve = resolve || (() => {});
1173
704
  // Init reader and save his file
1174
- var reader = new FileReader();
705
+ const reader = new FileReader();
1175
706
  reader._readedFile = file;
1176
707
 
1177
708
  // Set handlers
1178
- reader.onabort = function () {
1179
- return resolve();
1180
- };
1181
- reader.onerror = function () {
1182
- return resolve();
1183
- };
1184
- reader.onload = function (event) {
709
+ reader.onabort = () => resolve();
710
+ reader.onerror = () => resolve();
711
+ reader.onload = event => {
1185
712
  event.target._readedFile.dataURL = reader.result;
1186
713
  resolve();
1187
714
  };
@@ -1192,146 +719,122 @@ function setFileDataURL(file, resolve) {
1192
719
  resolve();
1193
720
  }
1194
721
  }
1195
- var FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props) {
1196
- var inputName = props.inputName,
1197
- size = props.size,
1198
- className = props.className,
1199
- fileErrorText = props.fileErrorText,
1200
- hintTitleTextSize = props.hintTitleTextSize,
1201
- removeThumbTextSize = props.removeThumbTextSize,
1202
- removeThumbTextColor = props.removeThumbTextColor,
1203
- removeThumbTextWeight = props.removeThumbTextWeight,
1204
- thumbNameTextSize = props.thumbNameTextSize,
1205
- thumbNameTextColor = props.thumbNameTextColor,
1206
- removeThumbTextHoverColor = props.removeThumbTextHoverColor,
1207
- thumbNameTextWrap = props.thumbNameTextWrap,
1208
- thumbNameTextWeight = props.thumbNameTextWeight,
1209
- hintTitleTextColor = props.hintTitleTextColor,
1210
- hintTitleTextWrap = props.hintTitleTextWrap,
1211
- thumbColumn = props.thumbColumn,
1212
- hintTitleTextWeight = props.hintTitleTextWeight,
1213
- hintDescriptionTextSize = props.hintDescriptionTextSize,
1214
- hintDescriptionTextColor = props.hintDescriptionTextColor,
1215
- hintDescriptionTextWrap = props.hintDescriptionTextWrap,
1216
- hintDescriptionTextWeight = props.hintDescriptionTextWeight,
1217
- errorMessageTextSize = props.errorMessageTextSize,
1218
- errorMessageTextWeight = props.errorMessageTextWeight,
1219
- errorMessageTextColor = props.errorMessageTextColor,
1220
- inputValue = props.inputValue,
1221
- maxFiles = props.maxFiles,
1222
- maxSize = props.maxSize,
1223
- removeThumbText = props.removeThumbText,
1224
- hintTitle = props.hintTitle,
1225
- hintDescription = props.hintDescription,
1226
- isShowFilename = props.isShowFilename,
1227
- isPreviews = props.isPreviews;
1228
- props.loadingText;
1229
- var _props$dropzoneProps = props.dropzoneProps,
1230
- dropzoneProps = _props$dropzoneProps === void 0 ? {} : _props$dropzoneProps,
1231
- onAddFiles = props.onAddFiles,
1232
- onDeleteFile = props.onDeleteFile;
1233
- var _useState = useState(''),
1234
- fileError = _useState[0],
1235
- setFileError = _useState[1];
1236
- var _useState2 = useState(false),
1237
- fileIsLoading = _useState2[0],
1238
- setFileIsLoading = _useState2[1];
722
+ const FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props) {
723
+ const {
724
+ inputName,
725
+ size,
726
+ className,
727
+ fileErrorText,
728
+ hintTitleTextSize,
729
+ removeThumbTextSize,
730
+ removeThumbTextColor,
731
+ removeThumbTextWeight,
732
+ thumbNameTextSize,
733
+ thumbNameTextColor,
734
+ removeThumbTextHoverColor,
735
+ thumbNameTextWrap,
736
+ thumbNameTextWeight,
737
+ hintTitleTextColor,
738
+ hintTitleTextWrap,
739
+ thumbColumn,
740
+ hintTitleTextWeight,
741
+ hintDescriptionTextSize,
742
+ hintDescriptionTextColor,
743
+ hintDescriptionTextWrap,
744
+ hintDescriptionTextWeight,
745
+ errorMessageTextSize,
746
+ errorMessageTextWeight,
747
+ errorMessageTextColor,
748
+ inputValue,
749
+ maxFiles,
750
+ maxSize,
751
+ removeThumbText,
752
+ hintTitle,
753
+ hintDescription,
754
+ isShowFilename,
755
+ isPreviews,
756
+ loadingText,
757
+ dropzoneProps = {},
758
+ onAddFiles,
759
+ onDeleteFile
760
+ } = props;
761
+ const [fileError, setFileError] = useState('');
762
+ const [fileIsLoading, setFileIsLoading] = useState(false);
1239
763
  // State with instances of "File" type
1240
- var _useState3 = useState(inputValue ? castArray(inputValue) : []),
1241
- files = _useState3[0],
1242
- setFiles = _useState3[1];
764
+ const [files, setFiles] = useState(inputValue ? castArray(inputValue) : []);
1243
765
 
1244
766
  // Save to mobx state
1245
- var _useForm = useForm(),
1246
- change = _useForm.change;
1247
- var changeFormState = useCallback(function (newFiles) {
767
+ const {
768
+ change
769
+ } = useForm();
770
+ const changeFormState = useCallback(newFiles => {
1248
771
  // If max files in dropzone is 1 - return file as it self, else as array of files
1249
772
  // ps: for old projects compatibility
1250
- var toSave = dropzoneProps.maxFiles == 1 ? newFiles[0] : newFiles;
773
+ const toSave = dropzoneProps.maxFiles == 1 ? newFiles[0] : newFiles;
1251
774
  change(inputName, toSave);
1252
775
  return toSave;
1253
776
  }, [dropzoneProps, change]);
1254
777
 
1255
778
  // Create dropzone options
1256
- var _useDropzone = useDropzone(Object.assign({
1257
- maxSize: maxSize || 10485760,
1258
- // 10mb
1259
- maxFiles: maxFiles || 5
1260
- }, dropzoneProps, {
1261
- getFilesFromEvent: function () {
1262
- var _getFilesFromEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
1263
- var result, newFiles;
1264
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1265
- while (1) switch (_context.prev = _context.next) {
1266
- case 0:
1267
- _context.next = 2;
1268
- return fromEvent(event);
1269
- case 2:
1270
- result = _context.sent;
1271
- newFiles = result.filter(function (item) {
1272
- return item instanceof File;
1273
- }); // Add exists and new files to accepted(or rejected)
1274
- return _context.abrupt("return", [].concat(files, newFiles));
1275
- case 5:
1276
- case "end":
1277
- return _context.stop();
1278
- }
1279
- }, _callee);
1280
- }));
1281
- function getFilesFromEvent(_x4) {
1282
- return _getFilesFromEvent.apply(this, arguments);
1283
- }
1284
- return getFilesFromEvent;
1285
- }(),
1286
- onDropAccepted: function onDropAccepted(acceptedFiles, event) {
1287
- // If dropped files has accepted and we need a previews
1288
- if (isPreviews) {
1289
- // Add preview to every file
1290
- acceptedFiles.forEach(function (file) {
1291
- if (!file.error) {
1292
- file.preview = URL.createObjectURL(file);
1293
- }
1294
- });
1295
- }
1296
- // Save to form data (including empty when files are not valid)
1297
- setFiles(acceptedFiles);
1298
- setFileError('');
1299
-
1300
- // Save DataURL for all files
1301
- var readerPromisesList = acceptedFiles.map(function (file) {
1302
- return new Promise(function (resolve) {
1303
- return setFileDataURL(file, resolve);
1304
- });
1305
- });
1306
- // Save files to form values
1307
- Promise.all(readerPromisesList).then(function () {
1308
- var filesToSave = changeFormState(acceptedFiles);
1309
- if (onAddFiles) {
1310
- onAddFiles(filesToSave, inputName);
779
+ const {
780
+ getRootProps,
781
+ getInputProps
782
+ } = useDropzone({
783
+ maxSize: maxSize || 10485760,
784
+ // 10mb
785
+ maxFiles: maxFiles || 5,
786
+ // accept: { 'image/*': [] },
787
+ ...dropzoneProps,
788
+ getFilesFromEvent: async event => {
789
+ const result = await fromEvent(event);
790
+ const newFiles = result.filter(item => item instanceof File);
791
+ // Add exists and new files to accepted(or rejected)
792
+ return [...files, ...newFiles];
793
+ },
794
+ onDropAccepted: (acceptedFiles, event) => {
795
+ // If dropped files has accepted and we need a previews
796
+ if (isPreviews) {
797
+ // Add preview to every file
798
+ acceptedFiles.forEach(file => {
799
+ if (!file.error) {
800
+ file.preview = URL.createObjectURL(file);
1311
801
  }
1312
802
  });
1313
- },
1314
- onDropRejected: function onDropRejected(rejectedFiles, event) {
1315
- // If dropped files has rejected
1316
- if (rejectedFiles.length) {
1317
- var _rejectedFiles$0$erro;
1318
- var firstFileError = (_rejectedFiles$0$erro = rejectedFiles[0].errors[0]) == null ? void 0 : _rejectedFiles$0$erro.message;
1319
- // Show error
1320
- setFileError(firstFileError || 'Error on adding file');
1321
- } else {
1322
- // Else clean error
1323
- setFileError('');
803
+ }
804
+ // Save to form data (including empty when files are not valid)
805
+ setFiles(acceptedFiles);
806
+ setFileError('');
807
+
808
+ // Save DataURL for all files
809
+ const readerPromisesList = acceptedFiles.map(file => {
810
+ return new Promise(resolve => setFileDataURL(file, resolve));
811
+ });
812
+ // Save files to form values
813
+ Promise.all(readerPromisesList).then(() => {
814
+ const filesToSave = changeFormState(acceptedFiles);
815
+ if (onAddFiles) {
816
+ onAddFiles(filesToSave, inputName);
1324
817
  }
818
+ });
819
+ },
820
+ onDropRejected: (rejectedFiles, event) => {
821
+ // If dropped files has rejected
822
+ if (rejectedFiles.length) {
823
+ const firstFileError = rejectedFiles[0].errors[0]?.message;
824
+ // Show error
825
+ setFileError(firstFileError || 'Error on adding file');
826
+ } else {
827
+ // Else clean error
828
+ setFileError('');
1325
829
  }
1326
- })),
1327
- getRootProps = _useDropzone.getRootProps,
1328
- getInputProps = _useDropzone.getInputProps;
830
+ }
831
+ });
1329
832
 
1330
833
  // Delete file from dropzone
1331
- var removeFile = useCallback(function (event, index) {
834
+ const removeFile = useCallback((event, index) => {
1332
835
  event.stopPropagation();
1333
836
  event.preventDefault();
1334
- var newFiles = [].concat(files);
837
+ const newFiles = [...files];
1335
838
  newFiles.splice(index, 1);
1336
839
  if (onDeleteFile) {
1337
840
  onDeleteFile(files[index], inputName);
@@ -1340,38 +843,19 @@ var FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props
1340
843
  }, [files, changeFormState, onDeleteFile]);
1341
844
 
1342
845
  //
1343
- var convertFiledValueAndSaveAsFiles = useCallback( /*#__PURE__*/function () {
1344
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(newInputValue) {
1345
- var newFiles;
1346
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1347
- while (1) switch (_context2.prev = _context2.next) {
1348
- case 0:
1349
- setFileIsLoading(true);
1350
- _context2.next = 3;
1351
- return convertToFiles(newInputValue, isPreviews);
1352
- case 3:
1353
- newFiles = _context2.sent;
1354
- setFileIsLoading(false);
1355
- setFiles(newFiles);
1356
- return _context2.abrupt("return", newFiles);
1357
- case 7:
1358
- case "end":
1359
- return _context2.stop();
1360
- }
1361
- }, _callee2);
1362
- }));
1363
- return function (_x5) {
1364
- return _ref.apply(this, arguments);
1365
- };
1366
- }(), [isPreviews]);
1367
- useEffect(function () {
846
+ const convertFiledValueAndSaveAsFiles = useCallback(async newInputValue => {
847
+ setFileIsLoading(true);
848
+ const newFiles = await convertToFiles(newInputValue, isPreviews);
849
+ setFileIsLoading(false);
850
+ setFiles(newFiles);
851
+ return newFiles;
852
+ }, [isPreviews]);
853
+ useEffect(() => {
1368
854
  // First time convert value to Files and save to local and form state
1369
- convertFiledValueAndSaveAsFiles(inputValue).then(function (newFiles) {
1370
- return changeFormState(newFiles);
1371
- });
855
+ convertFiledValueAndSaveAsFiles(inputValue).then(newFiles => changeFormState(newFiles));
1372
856
  }, []); // eslint-disable-line
1373
857
 
1374
- useEffect(function () {
858
+ useEffect(() => {
1375
859
  // Everytime convert value to Files and save to local state
1376
860
  if (!inputValue) {
1377
861
  setFiles([]);
@@ -1381,116 +865,108 @@ var FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props
1381
865
  // only "inputValue"
1382
866
  }, [inputValue]); // eslint-disable-line
1383
867
 
1384
- useEffect(function () {
868
+ useEffect(() => {
1385
869
  // Make sure to revoke the data uris to avoid memory leaks, will run on unmount
1386
- return function () {
1387
- return files.forEach(function (file) {
1388
- return URL.revokeObjectURL(file == null ? void 0 : file.preview);
1389
- });
1390
- };
870
+ return () => files.forEach(file => URL.revokeObjectURL(file?.preview));
1391
871
  }, []); // eslint-disable-line
1392
872
 
1393
- var fillClass = useDeviceTargetClass(props, {
873
+ const fillClass = useDeviceTargetClass(props, {
1394
874
  prefix: 'fill_',
1395
875
  propsKey: 'fill'
1396
876
  });
1397
- var fillHoverClass = useDeviceTargetClass(props, {
877
+ const fillHoverClass = useDeviceTargetClass(props, {
1398
878
  prefix: 'fill_hover_',
1399
879
  propsKey: 'fillHover'
1400
880
  });
1401
- var borderWidthClass = useDeviceTargetClass(props, {
881
+ const borderWidthClass = useDeviceTargetClass(props, {
1402
882
  prefix: 'border-width_',
1403
883
  propsKey: 'borderWidth'
1404
884
  });
1405
- var borderColorClass = useDeviceTargetClass(props, {
885
+ const borderColorClass = useDeviceTargetClass(props, {
1406
886
  prefix: 'border-color_',
1407
887
  propsKey: 'borderColor'
1408
888
  });
1409
- var borderColorHoverClass = useDeviceTargetClass(props, {
889
+ const borderColorHoverClass = useDeviceTargetClass(props, {
1410
890
  prefix: 'border-color_hover_',
1411
891
  propsKey: 'borderColorHover'
1412
892
  });
1413
- var borderTypeClass = useDeviceTargetClass(props, {
893
+ const borderTypeClass = useDeviceTargetClass(props, {
1414
894
  prefix: 'border_type_',
1415
895
  propsKey: 'borderType'
1416
896
  });
1417
- var shapeClass = useDeviceTargetClass(props, {
897
+ const shapeClass = useDeviceTargetClass(props, {
1418
898
  prefix: 'form-dropzone_shape_',
1419
899
  propsKey: 'shape'
1420
900
  });
1421
- var thumbBorderWidthClass = useDeviceTargetClass(props, {
901
+ const thumbBorderWidthClass = useDeviceTargetClass(props, {
1422
902
  prefix: 'border-width_',
1423
903
  propsKey: 'thumbBorderWidth'
1424
904
  });
1425
- var thumbDirectionClass = useDeviceTargetClass(props, {
905
+ const thumbDirectionClass = useDeviceTargetClass(props, {
1426
906
  prefix: 'form-dropzone__thumb_direction_',
1427
907
  propsKey: 'thumbDirection'
1428
908
  });
1429
- var thumbBorderColorClass = useDeviceTargetClass(props, {
909
+ const thumbBorderColorClass = useDeviceTargetClass(props, {
1430
910
  prefix: 'border-color_',
1431
911
  propsKey: 'thumbBorderColor'
1432
912
  });
1433
- var thumbBorderColorHoverClass = useDeviceTargetClass(props, {
913
+ const thumbBorderColorHoverClass = useDeviceTargetClass(props, {
1434
914
  prefix: 'border-color_hover_',
1435
915
  propsKey: 'thumbBorderColorHover'
1436
916
  });
1437
- var thumbBorderTypeClass = useDeviceTargetClass(props, {
917
+ const thumbBorderTypeClass = useDeviceTargetClass(props, {
1438
918
  prefix: 'border_type_',
1439
919
  propsKey: 'thumbBorderType'
1440
920
  });
1441
921
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", getRootProps({
1442
- className: "form-dropzone__dropzone dropzone " + className + " thumbColumn form-dropzone__dropzone_size_" + size + " " + shapeClass
922
+ className: `form-dropzone__dropzone dropzone ${className} thumbColumn form-dropzone__dropzone_size_${size} ${shapeClass}`
1443
923
  }), /*#__PURE__*/React.createElement("input", Object.assign({}, getInputProps(), {
1444
924
  name: inputName
1445
925
  })), /*#__PURE__*/React.createElement("div", {
1446
- className: clsx('form-dropzone__dropzone-wrapper', thumbColumn && "form-dropzone__dropzone-wrapper_column_" + thumbColumn, fillClass, fillHoverClass, borderWidthClass, borderColorClass, borderColorHoverClass, borderTypeClass)
1447
- }, files.map(function (file, i) {
1448
- return /*#__PURE__*/React.createElement("aside", {
1449
- className: clsx('form-dropzone__thumb', fillClass, thumbDirectionClass, thumbBorderWidthClass, thumbBorderColorClass, thumbBorderColorHoverClass, thumbBorderTypeClass),
1450
- key: "" + (file.id || file.name + "_" + i || 'i' + i)
1451
- }, isPreviews && !file.error && /*#__PURE__*/React.createElement("div", {
1452
- className: "form-dropzone__thumb-image"
1453
- }, /*#__PURE__*/React.createElement("img", {
1454
- className: "form-dropzone__thumb-image-inner",
1455
- src: file.preview || file.image,
1456
- onLoad: function onLoad() {
1457
- // Revoke data uri after image is loaded
1458
- URL.revokeObjectURL(file.preview);
1459
- }
1460
- })), file.error && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Text, {
1461
- size: thumbNameTextSize,
1462
- textColor: thumbNameTextColor,
1463
- textWrap: thumbNameTextWrap,
1464
- textWeight: thumbNameTextWeight
1465
- }, fileErrorText || file.error)), isShowFilename && /*#__PURE__*/React.createElement("div", {
1466
- className: "form-dropzone__thumb-name"
1467
- }, /*#__PURE__*/React.createElement(Text, {
1468
- size: thumbNameTextSize,
1469
- textColor: thumbNameTextColor,
1470
- textWrap: thumbNameTextWrap,
1471
- textWeight: thumbNameTextWeight,
1472
- className: "form-dropzone__thumb-name-inner"
1473
- }, file.name)), fileIsLoading && /*#__PURE__*/React.createElement("div", {
1474
- className: "form-dropzone__thumb-loader"
1475
- }, /*#__PURE__*/React.createElement(Loader, {
1476
- fill: "surfacePrimary",
1477
- height: "fill",
1478
- itemFill: "surfaceItemAccent",
1479
- set: "simple",
1480
- width: "fill"
1481
- })), /*#__PURE__*/React.createElement("div", {
1482
- className: "form-dropzone__thumb-remove",
1483
- onClick: function onClick(event) {
1484
- return removeFile(event, i);
1485
- }
1486
- }, /*#__PURE__*/React.createElement(Text, {
1487
- size: removeThumbTextSize,
1488
- textColor: removeThumbTextColor,
1489
- textWeight: removeThumbTextWeight,
1490
- textColorHover: removeThumbTextHoverColor,
1491
- className: "form-dropzone__thumb-remove-text"
1492
- }, removeThumbText || 'Remove')));
1493
- }), !files.length ? /*#__PURE__*/React.createElement("div", {
926
+ className: clsx('form-dropzone__dropzone-wrapper', thumbColumn && `form-dropzone__dropzone-wrapper_column_${thumbColumn}`, fillClass, fillHoverClass, borderWidthClass, borderColorClass, borderColorHoverClass, borderTypeClass)
927
+ }, files.map((file, i) => /*#__PURE__*/React.createElement("aside", {
928
+ className: clsx('form-dropzone__thumb', fillClass, thumbDirectionClass, thumbBorderWidthClass, thumbBorderColorClass, thumbBorderColorHoverClass, thumbBorderTypeClass),
929
+ key: `${file.id || `${file.name}_${i}` || 'i' + i}`
930
+ }, isPreviews && !file.error && /*#__PURE__*/React.createElement("div", {
931
+ className: "form-dropzone__thumb-image"
932
+ }, /*#__PURE__*/React.createElement("img", {
933
+ className: "form-dropzone__thumb-image-inner",
934
+ src: file.preview || file.image,
935
+ onLoad: () => {
936
+ // Revoke data uri after image is loaded
937
+ URL.revokeObjectURL(file.preview);
938
+ }
939
+ })), file.error && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Text, {
940
+ size: thumbNameTextSize,
941
+ textColor: thumbNameTextColor,
942
+ textWrap: thumbNameTextWrap,
943
+ textWeight: thumbNameTextWeight
944
+ }, fileErrorText || file.error)), isShowFilename && /*#__PURE__*/React.createElement("div", {
945
+ className: "form-dropzone__thumb-name"
946
+ }, /*#__PURE__*/React.createElement(Text, {
947
+ size: thumbNameTextSize,
948
+ textColor: thumbNameTextColor,
949
+ textWrap: thumbNameTextWrap,
950
+ textWeight: thumbNameTextWeight,
951
+ className: "form-dropzone__thumb-name-inner"
952
+ }, file.name)), fileIsLoading && /*#__PURE__*/React.createElement("div", {
953
+ className: "form-dropzone__thumb-loader"
954
+ }, /*#__PURE__*/React.createElement(Loader, {
955
+ fill: "surfacePrimary",
956
+ height: "fill",
957
+ itemFill: "surfaceItemAccent",
958
+ set: "simple",
959
+ width: "fill"
960
+ })), /*#__PURE__*/React.createElement("div", {
961
+ className: "form-dropzone__thumb-remove",
962
+ onClick: event => removeFile(event, i)
963
+ }, /*#__PURE__*/React.createElement(Text, {
964
+ size: removeThumbTextSize,
965
+ textColor: removeThumbTextColor,
966
+ textWeight: removeThumbTextWeight,
967
+ textColorHover: removeThumbTextHoverColor,
968
+ className: "form-dropzone__thumb-remove-text"
969
+ }, removeThumbText || 'Remove')))), !files.length ? /*#__PURE__*/React.createElement("div", {
1494
970
  className: "form-dropzone__hint"
1495
971
  }, /*#__PURE__*/React.createElement(Text, {
1496
972
  size: hintTitleTextSize,
@@ -1543,132 +1019,133 @@ FileInputDropzone.propTypes = {
1543
1019
  onDeleteFile: PropTypes.func
1544
1020
  };
1545
1021
 
1546
- var FileInput = /*#__PURE__*/React.memo(function FileInput(props) {
1547
- var name = props.name,
1548
- shape = props.shape,
1549
- size = props.size,
1550
- borderWidth = props.borderWidth,
1551
- borderColor = props.borderColor,
1552
- borderColorHover = props.borderColorHover,
1553
- borderType = props.borderType,
1554
- label = props.label,
1555
- thumbBorderWidth = props.thumbBorderWidth,
1556
- thumbBorderColor = props.thumbBorderColor,
1557
- thumbBorderColorHover = props.thumbBorderColorHover,
1558
- thumbBorderType = props.thumbBorderType,
1559
- removeThumbTextHoverColor = props.removeThumbTextHoverColor,
1560
- labelTextColor = props.labelTextColor,
1561
- fill = props.fill,
1562
- fillHover = props.fillHover,
1563
- className = props.className,
1564
- removeThumbText = props.removeThumbText,
1565
- thumbNameTextSize = props.thumbNameTextSize,
1566
- thumbNameTextColor = props.thumbNameTextColor,
1567
- thumbNameTextWrap = props.thumbNameTextWrap,
1568
- thumbNameTextWeight = props.thumbNameTextWeight,
1569
- removeThumbTextSize = props.removeThumbTextSize,
1570
- removeThumbTextColor = props.removeThumbTextColor,
1571
- removeThumbTextWeight = props.removeThumbTextWeight,
1572
- hintTitle = props.hintTitle,
1573
- errorMessageTextSize = props.errorMessageTextSize,
1574
- errorMessageTextWeight = props.errorMessageTextWeight,
1575
- errorMessageTextColor = props.errorMessageTextColor,
1576
- fieldProps = props.fieldProps,
1577
- hintTitleTextSize = props.hintTitleTextSize,
1578
- hintTitleTextColor = props.hintTitleTextColor,
1579
- hintTitleTextWrap = props.hintTitleTextWrap,
1580
- hintTitleTextWeight = props.hintTitleTextWeight,
1581
- hintDescriptionTextSize = props.hintDescriptionTextSize,
1582
- hintDescriptionTextColor = props.hintDescriptionTextColor,
1583
- hintDescriptionTextWrap = props.hintDescriptionTextWrap,
1584
- hintDescriptionTextWeight = props.hintDescriptionTextWeight,
1585
- hideMessage = props.hideMessage,
1586
- thumbDirection = props.thumbDirection,
1587
- hintDescription = props.hintDescription,
1588
- isShowFilename = props.isShowFilename,
1589
- fileErrorText = props.fileErrorText,
1590
- dropzoneProps = props.dropzoneProps,
1591
- maxFiles = props.maxFiles,
1592
- maxSize = props.maxSize,
1593
- thumbColumn = props.thumbColumn,
1594
- isRequired = props.isRequired,
1595
- isPreviews = props.isPreviews,
1596
- onAddFiles = props.onAddFiles,
1597
- onDeleteFile = props.onDeleteFile,
1598
- classNameGroupItem = props.classNameGroupItem;
1022
+ const FileInput = /*#__PURE__*/React.memo(function FileInput(props) {
1023
+ const {
1024
+ name,
1025
+ shape,
1026
+ size,
1027
+ borderWidth,
1028
+ borderColor,
1029
+ borderColorHover,
1030
+ borderType,
1031
+ label,
1032
+ thumbBorderWidth,
1033
+ thumbBorderColor,
1034
+ thumbBorderColorHover,
1035
+ thumbBorderType,
1036
+ removeThumbTextHoverColor,
1037
+ labelTextColor,
1038
+ fill,
1039
+ fillHover,
1040
+ className,
1041
+ removeThumbText,
1042
+ thumbNameTextSize,
1043
+ thumbNameTextColor,
1044
+ thumbNameTextWrap,
1045
+ thumbNameTextWeight,
1046
+ removeThumbTextSize,
1047
+ removeThumbTextColor,
1048
+ removeThumbTextWeight,
1049
+ hintTitle,
1050
+ errorMessageTextSize,
1051
+ errorMessageTextWeight,
1052
+ errorMessageTextColor,
1053
+ fieldProps,
1054
+ hintTitleTextSize,
1055
+ hintTitleTextColor,
1056
+ hintTitleTextWrap,
1057
+ hintTitleTextWeight,
1058
+ hintDescriptionTextSize,
1059
+ hintDescriptionTextColor,
1060
+ hintDescriptionTextWrap,
1061
+ hintDescriptionTextWeight,
1062
+ hideMessage,
1063
+ thumbDirection,
1064
+ hintDescription,
1065
+ isShowFilename,
1066
+ fileErrorText,
1067
+ dropzoneProps,
1068
+ maxFiles,
1069
+ maxSize,
1070
+ thumbColumn,
1071
+ isRequired,
1072
+ isPreviews,
1073
+ onAddFiles,
1074
+ onDeleteFile,
1075
+ classNameGroupItem
1076
+ } = props;
1599
1077
  return /*#__PURE__*/React.createElement(Field, {
1600
1078
  name: name
1601
- }, function (_ref) {
1602
- var input = _ref.input,
1603
- meta = _ref.meta;
1604
- return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
1605
- className: clsx('form-field_type_dropzone', 'form__item_type_dropzone', classNameGroupItem),
1606
- fieldClassName: "form-dropzone",
1607
- inputName: input.name,
1608
- inputValue: input.value,
1609
- isRequired: isRequired,
1610
- label: label,
1611
- labelTextColor: labelTextColor,
1612
- metaActive: meta.active,
1613
- metaError: meta.error,
1614
- metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
1615
- metaSubmitError: meta.submitError,
1616
- metaSubmitFailed: meta.submitFailed,
1617
- metaTouched: meta.touched,
1618
- metaValid: meta.valid,
1619
- hideMessage: hideMessage
1620
- }, fieldProps), /*#__PURE__*/React.createElement(FileInputDropzone, {
1621
- dropzoneProps: dropzoneProps,
1622
- hintDescription: hintDescription,
1623
- hintTitle: hintTitle,
1624
- borderWidth: borderWidth,
1625
- borderColor: borderColor,
1626
- borderColorHover: borderColorHover,
1627
- borderType: borderType,
1628
- thumbBorderWidth: thumbBorderWidth,
1629
- thumbBorderColor: thumbBorderColor,
1630
- thumbBorderColorHover: thumbBorderColorHover,
1631
- thumbBorderType: thumbBorderType,
1632
- fileErrorText: fileErrorText,
1633
- fill: fill,
1634
- size: size,
1635
- maxFiles: maxFiles,
1636
- maxSize: maxSize,
1637
- removeThumbTextHoverColor: removeThumbTextHoverColor,
1638
- fillHover: fillHover,
1639
- className: className,
1640
- thumbColumn: thumbColumn,
1641
- thumbDirection: thumbDirection,
1642
- inputName: input.name,
1643
- inputValue: input.value,
1644
- thumbNameTextSize: thumbNameTextSize,
1645
- thumbNameTextColor: thumbNameTextColor,
1646
- thumbNameTextWrap: thumbNameTextWrap,
1647
- thumbNameTextWeight: thumbNameTextWeight,
1648
- hintTitleTextSize: hintTitleTextSize,
1649
- hintTitleTextColor: hintTitleTextColor,
1650
- hintTitleTextWrap: hintTitleTextWrap,
1651
- hintTitleTextWeight: hintTitleTextWeight,
1652
- removeThumbTextSize: removeThumbTextSize,
1653
- removeThumbTextColor: removeThumbTextColor,
1654
- removeThumbTextWeight: removeThumbTextWeight,
1655
- hintDescriptionTextSize: hintDescriptionTextSize,
1656
- hintDescriptionTextColor: hintDescriptionTextColor,
1657
- hintDescriptionTextWrap: hintDescriptionTextWrap,
1658
- hintDescriptionTextWeight: hintDescriptionTextWeight,
1659
- errorMessageTextSize: errorMessageTextSize,
1660
- errorMessageWeight: errorMessageTextWeight,
1661
- errorMessageTextColor: errorMessageTextColor,
1662
- isPreviews: isPreviews,
1663
- shape: shape,
1664
- isShowFilename: isShowFilename,
1665
- metaError: meta.error,
1666
- metaTouched: meta.touched,
1667
- removeThumbText: removeThumbText,
1668
- onAddFiles: onAddFiles,
1669
- onDeleteFile: onDeleteFile
1670
- }));
1671
- });
1079
+ }, ({
1080
+ input,
1081
+ meta
1082
+ }) => /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
1083
+ className: clsx('form-field_type_dropzone', 'form__item_type_dropzone', classNameGroupItem),
1084
+ fieldClassName: "form-dropzone",
1085
+ inputName: input.name,
1086
+ inputValue: input.value,
1087
+ isRequired: isRequired,
1088
+ label: label,
1089
+ labelTextColor: labelTextColor,
1090
+ metaActive: meta.active,
1091
+ metaError: meta.error,
1092
+ metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
1093
+ metaSubmitError: meta.submitError,
1094
+ metaSubmitFailed: meta.submitFailed,
1095
+ metaTouched: meta.touched,
1096
+ metaValid: meta.valid,
1097
+ hideMessage: hideMessage
1098
+ }, fieldProps), /*#__PURE__*/React.createElement(FileInputDropzone, {
1099
+ dropzoneProps: dropzoneProps,
1100
+ hintDescription: hintDescription,
1101
+ hintTitle: hintTitle,
1102
+ borderWidth: borderWidth,
1103
+ borderColor: borderColor,
1104
+ borderColorHover: borderColorHover,
1105
+ borderType: borderType,
1106
+ thumbBorderWidth: thumbBorderWidth,
1107
+ thumbBorderColor: thumbBorderColor,
1108
+ thumbBorderColorHover: thumbBorderColorHover,
1109
+ thumbBorderType: thumbBorderType,
1110
+ fileErrorText: fileErrorText,
1111
+ fill: fill,
1112
+ size: size,
1113
+ maxFiles: maxFiles,
1114
+ maxSize: maxSize,
1115
+ removeThumbTextHoverColor: removeThumbTextHoverColor,
1116
+ fillHover: fillHover,
1117
+ className: className,
1118
+ thumbColumn: thumbColumn,
1119
+ thumbDirection: thumbDirection,
1120
+ inputName: input.name,
1121
+ inputValue: input.value,
1122
+ thumbNameTextSize: thumbNameTextSize,
1123
+ thumbNameTextColor: thumbNameTextColor,
1124
+ thumbNameTextWrap: thumbNameTextWrap,
1125
+ thumbNameTextWeight: thumbNameTextWeight,
1126
+ hintTitleTextSize: hintTitleTextSize,
1127
+ hintTitleTextColor: hintTitleTextColor,
1128
+ hintTitleTextWrap: hintTitleTextWrap,
1129
+ hintTitleTextWeight: hintTitleTextWeight,
1130
+ removeThumbTextSize: removeThumbTextSize,
1131
+ removeThumbTextColor: removeThumbTextColor,
1132
+ removeThumbTextWeight: removeThumbTextWeight,
1133
+ hintDescriptionTextSize: hintDescriptionTextSize,
1134
+ hintDescriptionTextColor: hintDescriptionTextColor,
1135
+ hintDescriptionTextWrap: hintDescriptionTextWrap,
1136
+ hintDescriptionTextWeight: hintDescriptionTextWeight,
1137
+ errorMessageTextSize: errorMessageTextSize,
1138
+ errorMessageWeight: errorMessageTextWeight,
1139
+ errorMessageTextColor: errorMessageTextColor,
1140
+ isPreviews: isPreviews,
1141
+ shape: shape,
1142
+ isShowFilename: isShowFilename,
1143
+ metaError: meta.error,
1144
+ metaTouched: meta.touched,
1145
+ removeThumbText: removeThumbText,
1146
+ onAddFiles: onAddFiles,
1147
+ onDeleteFile: onDeleteFile
1148
+ })));
1672
1149
  });
1673
1150
  FileInput.defaultProps = {
1674
1151
  errorMessageTextSize: 's',
@@ -1695,33 +1172,36 @@ FileInput.propTypes = {
1695
1172
  onDeleteFile: PropTypes.func
1696
1173
  };
1697
1174
 
1698
- var Group = /*#__PURE__*/React.memo(function Group(props) {
1699
- var after = props.after,
1700
- before = props.before,
1701
- className = props.className,
1702
- label = props.label,
1703
- labelTextColor = props.labelTextColor,
1704
- labelTextSize = props.labelTextSize,
1705
- labelTextWeight = props.labelTextWeight,
1706
- message = props.message,
1707
- errorMessageTextSize = props.errorMessageTextSize,
1708
- errorMessageTextWeight = props.errorMessageTextWeight,
1709
- errorMessageTextColor = props.errorMessageTextColor,
1710
- messageTextSize = props.messageTextSize,
1711
- messageTextWeight = props.messageTextWeight,
1712
- messageTextColor = props.messageTextColor,
1713
- children = props.children,
1714
- dataTour = props.dataTour,
1715
- hideMessage = props.hideMessage,
1716
- name = props.name,
1717
- showErrorsOnSubmit = props.showErrorsOnSubmit;
1175
+ const Group = /*#__PURE__*/React.memo(function Group(props) {
1176
+ const {
1177
+ after,
1178
+ before,
1179
+ className,
1180
+ label,
1181
+ labelTextColor,
1182
+ labelTextSize,
1183
+ labelTextWeight,
1184
+ message,
1185
+ errorMessageTextSize,
1186
+ errorMessageTextWeight,
1187
+ errorMessageTextColor,
1188
+ messageTextSize,
1189
+ messageTextWeight,
1190
+ messageTextColor,
1191
+ children,
1192
+ dataTour,
1193
+ hideMessage,
1194
+ name,
1195
+ showErrorsOnSubmit
1196
+ } = props;
1718
1197
  return /*#__PURE__*/React.createElement(Field, {
1719
1198
  name: name
1720
- }, function (_ref) {
1721
- _ref.input;
1722
- var meta = _ref.meta;
1723
- var error = meta.error || !meta.modifiedSinceLastSubmit && meta.submitError || false;
1724
- var showError = useMemo(function () {
1199
+ }, ({
1200
+ input,
1201
+ meta
1202
+ }) => {
1203
+ const error = meta.error || !meta.modifiedSinceLastSubmit && meta.submitError || false;
1204
+ const showError = useMemo(() => {
1725
1205
  if (showErrorsOnSubmit) {
1726
1206
  return meta.submitFailed && meta.touched && error;
1727
1207
  } else {
@@ -1746,7 +1226,7 @@ var Group = /*#__PURE__*/React.memo(function Group(props) {
1746
1226
  size: errorMessageTextSize,
1747
1227
  textWeight: errorMessageTextWeight,
1748
1228
  textColor: errorMessageTextColor,
1749
- id: name + "-error"
1229
+ id: `${name}-error`
1750
1230
  }, error), Boolean(message) && !showError && /*#__PURE__*/React.createElement(Text, {
1751
1231
  className: "form__group-message",
1752
1232
  size: messageTextSize,
@@ -1755,7 +1235,7 @@ var Group = /*#__PURE__*/React.memo(function Group(props) {
1755
1235
  }, message), Boolean(!showError) && Boolean(!message) && /*#__PURE__*/React.createElement(Text, {
1756
1236
  className: "form__group-message",
1757
1237
  size: messageTextSize
1758
- }, "\xA0")));
1238
+ }, '\u00A0')));
1759
1239
  });
1760
1240
  });
1761
1241
  Group.defaultProps = {
@@ -1774,48 +1254,47 @@ Group.propTypes = {
1774
1254
  inputProps: PropTypes.object
1775
1255
  };
1776
1256
 
1777
- var InputField = /*#__PURE__*/React.memo(function InputField(props) {
1778
- var isPassword = props.isPassword,
1779
- isRequired = props.isRequired,
1780
- fieldProps = props.fieldProps,
1781
- inputProps = props.inputProps,
1782
- isRevealable = props.isRevealable,
1783
- name = props.name,
1784
- parse = props.parse,
1785
- iconSize = props.iconSize;
1786
- props.iconBorder;
1787
- props.iconBorderHover;
1788
- var iconFill = props.iconFill,
1789
- iconFillHover = props.iconFillHover,
1790
- iconRevealableShow = props.iconRevealableShow,
1791
- iconRevealableHide = props.iconRevealableHide,
1792
- iconShape = props.iconShape,
1793
- hideMessage = props.hideMessage,
1794
- onChange = props.onChange,
1795
- classNameGroupItem = props.classNameGroupItem;
1796
- var _useState = useState(false),
1797
- isRevealed = _useState[0],
1798
- setIsRevealed = _useState[1];
1799
- var inputType = useMemo(function () {
1257
+ const InputField = /*#__PURE__*/React.memo(function InputField(props) {
1258
+ const {
1259
+ isPassword,
1260
+ isRequired,
1261
+ fieldProps,
1262
+ inputProps,
1263
+ isRevealable,
1264
+ name,
1265
+ parse,
1266
+ iconSize,
1267
+ iconBorder,
1268
+ iconBorderHover,
1269
+ iconFill,
1270
+ iconFillHover,
1271
+ iconRevealableShow,
1272
+ iconRevealableHide,
1273
+ iconShape,
1274
+ hideMessage,
1275
+ onChange,
1276
+ classNameGroupItem
1277
+ } = props;
1278
+ const [isRevealed, setIsRevealed] = useState(false);
1279
+ const inputType = useMemo(() => {
1800
1280
  if (isPassword) {
1801
1281
  return isRevealed ? 'text' : 'password';
1802
1282
  } else {
1803
1283
  return 'text';
1804
1284
  }
1805
1285
  }, [isRevealed, isPassword]);
1806
- var revealeHandler = useCallback(function (e) {
1286
+ const revealeHandler = useCallback(e => {
1807
1287
  e.preventDefault();
1808
- setIsRevealed(function (prev) {
1809
- return !prev;
1810
- });
1288
+ setIsRevealed(prev => !prev);
1811
1289
  }, [setIsRevealed]);
1812
1290
  return /*#__PURE__*/React.createElement(Field, {
1813
1291
  name: name,
1814
1292
  parse: parse
1815
- }, function (_ref) {
1816
- var input = _ref.input,
1817
- meta = _ref.meta;
1818
- var onChangeField = useCallback(function (event) {
1293
+ }, ({
1294
+ input,
1295
+ meta
1296
+ }) => {
1297
+ const onChangeField = useCallback(event => {
1819
1298
  input.onChange(event);
1820
1299
  if (onChange) {
1821
1300
  onChange(event.target.value, input.name);
@@ -1871,11 +1350,13 @@ InputField.propTypes = {
1871
1350
  };
1872
1351
 
1873
1352
  function RadioGroupItem(props) {
1874
- var input = props.input,
1875
- option = props.option,
1876
- onChange = props.onChange,
1877
- inputProps = props.inputProps;
1878
- var onChangeField = useCallback(function (event) {
1353
+ const {
1354
+ input,
1355
+ option,
1356
+ onChange,
1357
+ inputProps
1358
+ } = props;
1359
+ const onChangeField = useCallback(event => {
1879
1360
  if (event.target.checked) {
1880
1361
  onChange(option.value);
1881
1362
  }
@@ -1909,12 +1390,12 @@ RadioGroupItem.propTypes = {
1909
1390
  };
1910
1391
 
1911
1392
  function RadioGroupInput(props) {
1912
- var input = props.input,
1913
- value = props.value,
1914
- onChange = props.onChange;
1915
- var onChangeField = useCallback(function (event) {
1916
- return onChange(event.target.value);
1917
- }, [onChange]);
1393
+ const {
1394
+ input,
1395
+ value,
1396
+ onChange
1397
+ } = props;
1398
+ const onChangeField = useCallback(event => onChange(event.target.value), [onChange]);
1918
1399
  return /*#__PURE__*/React.createElement(Input, Object.assign({
1919
1400
  autoComplete: "nope",
1920
1401
  name: input.name,
@@ -1932,29 +1413,25 @@ RadioGroupInput.propTypes = {
1932
1413
  };
1933
1414
 
1934
1415
  function RadioGroupList(props) {
1935
- var input = props.input,
1936
- options = props.options,
1937
- editableProps = props.editableProps,
1938
- onChange = props.onChange,
1939
- inputProps = props.inputProps;
1940
- var _useState = useState(function () {
1941
- var isRadioValue = options.find(function (option) {
1942
- return option.value === input.value;
1943
- });
1944
- if (!isRadioValue) {
1945
- return input.value;
1946
- }
1947
- return '';
1948
- }),
1949
- editableValue = _useState[0],
1950
- setEditableValue = _useState[1];
1951
- useEffect(function () {
1416
+ const {
1417
+ input,
1418
+ options,
1419
+ editableProps,
1420
+ onChange,
1421
+ inputProps
1422
+ } = props;
1423
+ const [editableValue, setEditableValue] = useState(() => {
1424
+ const isRadioValue = options.find(option => option.value === input.value);
1425
+ if (!isRadioValue) {
1426
+ return input.value;
1427
+ }
1428
+ return '';
1429
+ });
1430
+ useEffect(() => {
1952
1431
  // When a new value from outside enters the form
1953
1432
  if (input.value) {
1954
1433
  // Check value for radio type
1955
- var isRadioValue = options.find(function (option) {
1956
- return option.value === input.value && !option.editable;
1957
- });
1434
+ const isRadioValue = options.find(option => option.value === input.value && !option.editable);
1958
1435
  // If new value not in radio list - set to editable input
1959
1436
  setEditableValue(isRadioValue ? '' : input.value);
1960
1437
  } else {
@@ -1964,7 +1441,7 @@ function RadioGroupList(props) {
1964
1441
  }, [input.value]);
1965
1442
 
1966
1443
  // Callback for value changes
1967
- var onChangeSomeInput = useCallback(function (value) {
1444
+ const onChangeSomeInput = useCallback(value => {
1968
1445
  // Save to form values
1969
1446
  input.onChange(value);
1970
1447
  if (onChange) {
@@ -1974,33 +1451,31 @@ function RadioGroupList(props) {
1974
1451
  }, [input, onChange]);
1975
1452
 
1976
1453
  // Handle for radio inputs
1977
- var onChangeRadio = useCallback(function (value) {
1454
+ const onChangeRadio = useCallback(value => {
1978
1455
  setEditableValue('');
1979
1456
  onChangeSomeInput(value);
1980
1457
  }, [onChangeSomeInput]);
1981
1458
 
1982
1459
  // Handle for text input
1983
- var onChangeEditable = useCallback(function (value) {
1460
+ const onChangeEditable = useCallback(value => {
1984
1461
  setEditableValue(value);
1985
1462
  onChangeSomeInput(value);
1986
1463
  }, [onChangeSomeInput]);
1987
- return /*#__PURE__*/React.createElement(React.Fragment, null, options.map(function (option) {
1988
- return option.editable ? /*#__PURE__*/React.createElement(RadioGroupInput, {
1989
- key: option.label,
1990
- input: input,
1991
- value: editableValue,
1992
- option: option,
1993
- onChange: onChangeEditable,
1994
- editableProps: editableProps,
1995
- inputProps: inputProps
1996
- }) : /*#__PURE__*/React.createElement(RadioGroupItem, {
1997
- key: option.value,
1998
- input: input,
1999
- option: option,
2000
- onChange: onChangeRadio,
2001
- inputProps: inputProps
2002
- });
2003
- }));
1464
+ return /*#__PURE__*/React.createElement(React.Fragment, null, options.map(option => option.editable ? /*#__PURE__*/React.createElement(RadioGroupInput, {
1465
+ key: option.label,
1466
+ input: input,
1467
+ value: editableValue,
1468
+ option: option,
1469
+ onChange: onChangeEditable,
1470
+ editableProps: editableProps,
1471
+ inputProps: inputProps
1472
+ }) : /*#__PURE__*/React.createElement(RadioGroupItem, {
1473
+ key: option.value,
1474
+ input: input,
1475
+ option: option,
1476
+ onChange: onChangeRadio,
1477
+ inputProps: inputProps
1478
+ })));
2004
1479
  }
2005
1480
  RadioGroupList.propTypes = {
2006
1481
  editableProps: PropTypes.object,
@@ -2010,42 +1485,43 @@ RadioGroupList.propTypes = {
2010
1485
  options: PropTypes.object
2011
1486
  };
2012
1487
 
2013
- var RadioGroup = /*#__PURE__*/React.memo(function RadioGroup(props) {
2014
- var isRequired = props.isRequired,
2015
- name = props.name,
2016
- options = props.options,
2017
- fieldProps = props.fieldProps,
2018
- editableProps = props.editableProps,
2019
- inputProps = props.inputProps,
2020
- onChange = props.onChange,
2021
- hideMessage = props.hideMessage;
1488
+ const RadioGroup = /*#__PURE__*/React.memo(function RadioGroup(props) {
1489
+ const {
1490
+ isRequired,
1491
+ name,
1492
+ options,
1493
+ fieldProps,
1494
+ editableProps,
1495
+ inputProps,
1496
+ onChange,
1497
+ hideMessage
1498
+ } = props;
2022
1499
  return /*#__PURE__*/React.createElement(Field, {
2023
1500
  name: name
2024
- }, function (_ref) {
2025
- var input = _ref.input,
2026
- meta = _ref.meta;
2027
- return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
2028
- className: "form__item_type_radio",
2029
- fieldClassName: 'form-radio',
2030
- inputName: input.name,
2031
- inputValue: input.value || '',
2032
- isRequired: isRequired,
2033
- metaActive: meta.active,
2034
- metaError: meta.error,
2035
- metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
2036
- metaSubmitError: meta.submitError,
2037
- metaSubmitFailed: meta.submitFailed,
2038
- metaTouched: meta.touched,
2039
- metaValid: meta.valid,
2040
- hideMessage: hideMessage
2041
- }, fieldProps), /*#__PURE__*/React.createElement(RadioGroupList, {
2042
- input: input,
2043
- options: options,
2044
- onChange: onChange,
2045
- editableProps: editableProps,
2046
- inputProps: inputProps
2047
- }));
2048
- });
1501
+ }, ({
1502
+ input,
1503
+ meta
1504
+ }) => /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
1505
+ className: "form__item_type_radio",
1506
+ fieldClassName: 'form-radio',
1507
+ inputName: input.name,
1508
+ inputValue: input.value || '',
1509
+ isRequired: isRequired,
1510
+ metaActive: meta.active,
1511
+ metaError: meta.error,
1512
+ metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
1513
+ metaSubmitError: meta.submitError,
1514
+ metaSubmitFailed: meta.submitFailed,
1515
+ metaTouched: meta.touched,
1516
+ metaValid: meta.valid,
1517
+ hideMessage: hideMessage
1518
+ }, fieldProps), /*#__PURE__*/React.createElement(RadioGroupList, {
1519
+ input: input,
1520
+ options: options,
1521
+ onChange: onChange,
1522
+ editableProps: editableProps,
1523
+ inputProps: inputProps
1524
+ })));
2049
1525
  });
2050
1526
  RadioGroup.defaultProps = {
2051
1527
  fieldProps: {},
@@ -2065,33 +1541,35 @@ RadioGroup.propTypes = {
2065
1541
 
2066
1542
  // const SegmentedField = React.memo(
2067
1543
  function SegmentedField(props) {
2068
- var options = props.options,
2069
- isRequired = props.isRequired,
2070
- name = props.name,
2071
- fieldProps = props.fieldProps,
2072
- inputProps = props.inputProps,
2073
- hideMessage = props.hideMessage;
2074
- var _useForm = useForm(),
2075
- change = _useForm.change;
1544
+ const {
1545
+ options,
1546
+ isRequired,
1547
+ name,
1548
+ fieldProps,
1549
+ inputProps,
1550
+ hideMessage
1551
+ } = props;
1552
+ const {
1553
+ change
1554
+ } = useForm();
2076
1555
  return /*#__PURE__*/React.createElement(Field, {
2077
1556
  name: name
2078
- }, function (_ref) {
2079
- var input = _ref.input,
2080
- meta = _ref.meta;
2081
- var activeOption = useMemo(function () {
2082
- var emptyOption = {
1557
+ }, ({
1558
+ input,
1559
+ meta
1560
+ }) => {
1561
+ const activeOption = useMemo(() => {
1562
+ const emptyOption = {
2083
1563
  value: null,
2084
1564
  label: null
2085
1565
  };
2086
1566
  if (input.value) {
2087
- var currentOption = options.find(function (option) {
2088
- return option.value === input.value;
2089
- });
1567
+ const currentOption = options.find(option => option.value === input.value);
2090
1568
  return currentOption || emptyOption;
2091
1569
  }
2092
1570
  return emptyOption;
2093
1571
  }, [input.value]);
2094
- var setActiveSegment = useCallback(function (option) {
1572
+ const setActiveSegment = useCallback(option => {
2095
1573
  change(name, option.value);
2096
1574
  }, [change]);
2097
1575
  return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
@@ -2130,12 +1608,12 @@ SegmentedField.propTypes = {
2130
1608
  };
2131
1609
 
2132
1610
  function getDefaultValue(options, selectValue) {
2133
- var selectValues = Array.isArray(selectValue) ? selectValue : [selectValue];
2134
- var result = [];
2135
- options.forEach(function (item) {
2136
- var isValue = selectValues.includes(item.value);
2137
- var isLabel = selectValues.includes(item.label);
2138
- var childOptions = [];
1611
+ const selectValues = Array.isArray(selectValue) ? selectValue : [selectValue];
1612
+ let result = [];
1613
+ options.forEach(item => {
1614
+ const isValue = selectValues.includes(item.value);
1615
+ const isLabel = selectValues.includes(item.label);
1616
+ let childOptions = [];
2139
1617
  if (item.options) {
2140
1618
  childOptions = getDefaultValue(item.options, selectValue);
2141
1619
  }
@@ -2147,35 +1625,35 @@ function getDefaultValue(options, selectValue) {
2147
1625
  });
2148
1626
  return result;
2149
1627
  }
2150
- var SelectField = /*#__PURE__*/React.memo(function SelectField(props) {
2151
- var isRequired = props.isRequired,
2152
- key = props.key,
2153
- name = props.name,
2154
- options = props.options,
2155
- fieldProps = props.fieldProps,
2156
- selectProps = props.selectProps,
2157
- selectRef = props.selectRef,
2158
- onChange = props.onChange,
2159
- classNameGroupItem = props.classNameGroupItem,
2160
- hideMessage = props.hideMessage;
1628
+ const SelectField = /*#__PURE__*/React.memo(function SelectField(props) {
1629
+ const {
1630
+ isRequired,
1631
+ key,
1632
+ name,
1633
+ options,
1634
+ fieldProps,
1635
+ selectProps,
1636
+ selectRef,
1637
+ onChange,
1638
+ classNameGroupItem,
1639
+ hideMessage
1640
+ } = props;
2161
1641
  return /*#__PURE__*/React.createElement(Field, {
2162
1642
  name: name
2163
- }, function (_ref) {
2164
- var input = _ref.input,
2165
- meta = _ref.meta;
2166
- var onChangeField = useCallback(function (value) {
1643
+ }, ({
1644
+ input,
1645
+ meta
1646
+ }) => {
1647
+ const onChangeField = useCallback(value => {
2167
1648
  input.onChange(value);
2168
1649
  if (onChange) {
2169
1650
  onChange(value, input.name);
2170
1651
  }
2171
1652
  }, [onChange]);
2172
- var _useState = useState(null),
2173
- selectedOptions = _useState[0],
2174
- setSelectedOptions = _useState[1];
2175
- var defaultValue = useMemo(function () {
2176
- var _input$value;
2177
- var optionsValues = getDefaultValue(options, input.value);
2178
- if (!optionsValues.length && (_input$value = input.value) != null && _input$value.length) {
1653
+ const [selectedOptions, setSelectedOptions] = useState(null);
1654
+ const defaultValue = useMemo(() => {
1655
+ const optionsValues = getDefaultValue(options, input.value);
1656
+ if (!optionsValues.length && input.value?.length) {
2179
1657
  optionsValues.push({
2180
1658
  value: input.value,
2181
1659
  label: input.value
@@ -2183,13 +1661,9 @@ var SelectField = /*#__PURE__*/React.memo(function SelectField(props) {
2183
1661
  }
2184
1662
  return optionsValues;
2185
1663
  }, [input.value]);
2186
- useEffect(function () {
2187
- return setSelectedOptions(defaultValue);
2188
- }, [defaultValue]);
2189
- var onChangeValue = useCallback(function (option, actionMeta) {
2190
- var value = Array.isArray(option) ? option.map(function (o) {
2191
- return o.value;
2192
- }) : (option == null ? void 0 : option.value) || null;
1664
+ useEffect(() => setSelectedOptions(defaultValue), [defaultValue]);
1665
+ const onChangeValue = useCallback((option, actionMeta) => {
1666
+ const value = Array.isArray(option) ? option.map(o => o.value) : option?.value || null;
2193
1667
  setSelectedOptions(option);
2194
1668
  onChangeField(value);
2195
1669
  }, [onChangeField]);
@@ -2209,7 +1683,7 @@ var SelectField = /*#__PURE__*/React.memo(function SelectField(props) {
2209
1683
  hideMessage: hideMessage
2210
1684
  }, fieldProps), /*#__PURE__*/React.createElement(Select, Object.assign({
2211
1685
  className: "form-select-item",
2212
- instanceId: "id_" + input.name,
1686
+ instanceId: `id_${input.name}`,
2213
1687
  value: selectedOptions,
2214
1688
  onChange: onChangeValue,
2215
1689
  options: options,
@@ -2228,21 +1702,24 @@ SelectField.propTypes = {
2228
1702
  onChange: PropTypes.func
2229
1703
  };
2230
1704
 
2231
- var SwitchField = /*#__PURE__*/React.memo(function SwitchField(props) {
2232
- var name = props.name,
2233
- isRequired = props.isRequired,
2234
- onChange = props.onChange,
2235
- fieldProps = props.fieldProps,
2236
- inputProps = props.inputProps,
2237
- classNameGroupItem = props.classNameGroupItem,
2238
- hideMessage = props.hideMessage;
1705
+ const SwitchField = /*#__PURE__*/React.memo(function SwitchField(props) {
1706
+ const {
1707
+ name,
1708
+ isRequired,
1709
+ onChange,
1710
+ fieldProps,
1711
+ inputProps,
1712
+ classNameGroupItem,
1713
+ hideMessage
1714
+ } = props;
2239
1715
  return /*#__PURE__*/React.createElement(Field, {
2240
1716
  name: name,
2241
1717
  type: "checkbox"
2242
- }, function (_ref) {
2243
- var input = _ref.input,
2244
- meta = _ref.meta;
2245
- var onChangeField = useCallback(function (event) {
1718
+ }, ({
1719
+ input,
1720
+ meta
1721
+ }) => {
1722
+ const onChangeField = useCallback(event => {
2246
1723
  input.onChange(event);
2247
1724
  if (onChange) {
2248
1725
  onChange(event.target.checked, input.name);
@@ -2286,41 +1763,42 @@ SwitchField.propTypes = {
2286
1763
  onChange: PropTypes.func
2287
1764
  };
2288
1765
 
2289
- var TextareaField = /*#__PURE__*/React.memo(function TextareaField(props) {
2290
- var isRequired = props.isRequired,
2291
- name = props.name,
2292
- fieldProps = props.fieldProps,
2293
- inputProps = props.inputProps,
2294
- classNameGroupItem = props.classNameGroupItem,
2295
- hideMessage = props.hideMessage;
1766
+ const TextareaField = /*#__PURE__*/React.memo(function TextareaField(props) {
1767
+ const {
1768
+ isRequired,
1769
+ name,
1770
+ fieldProps,
1771
+ inputProps,
1772
+ classNameGroupItem,
1773
+ hideMessage
1774
+ } = props;
2296
1775
  return /*#__PURE__*/React.createElement(Field, {
2297
1776
  name: name
2298
- }, function (_ref) {
2299
- var input = _ref.input,
2300
- meta = _ref.meta;
2301
- return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
2302
- className: clsx('form-field_type_textarea', 'form__item_type_textarea', classNameGroupItem),
2303
- fieldClassName: 'form-textarea',
2304
- inputName: input.name,
2305
- inputValue: input.value,
2306
- isRequired: isRequired,
2307
- metaActive: meta.active,
2308
- metaError: meta.error,
2309
- metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
2310
- metaSubmitError: meta.submitError,
2311
- metaSubmitFailed: meta.submitFailed,
2312
- metaTouched: meta.touched,
2313
- metaValid: meta.valid,
2314
- hideMessage: hideMessage
2315
- }, fieldProps), /*#__PURE__*/React.createElement(Textarea, Object.assign({
2316
- autoComplete: "nope",
2317
- name: input.name,
2318
- value: input.value,
2319
- onBlur: input.onBlur,
2320
- onChange: input.onChange,
2321
- onFocus: input.onFocus
2322
- }, inputProps)));
2323
- });
1777
+ }, ({
1778
+ input,
1779
+ meta
1780
+ }) => /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
1781
+ className: clsx('form-field_type_textarea', 'form__item_type_textarea', classNameGroupItem),
1782
+ fieldClassName: 'form-textarea',
1783
+ inputName: input.name,
1784
+ inputValue: input.value,
1785
+ isRequired: isRequired,
1786
+ metaActive: meta.active,
1787
+ metaError: meta.error,
1788
+ metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
1789
+ metaSubmitError: meta.submitError,
1790
+ metaSubmitFailed: meta.submitFailed,
1791
+ metaTouched: meta.touched,
1792
+ metaValid: meta.valid,
1793
+ hideMessage: hideMessage
1794
+ }, fieldProps), /*#__PURE__*/React.createElement(Textarea, Object.assign({
1795
+ autoComplete: "nope",
1796
+ name: input.name,
1797
+ value: input.value,
1798
+ onBlur: input.onBlur,
1799
+ onChange: input.onChange,
1800
+ onFocus: input.onFocus
1801
+ }, inputProps))));
2324
1802
  });
2325
1803
  TextareaField.defaultProps = {
2326
1804
  inputProps: {},
@@ -2333,32 +1811,32 @@ TextareaField.propTypes = {
2333
1811
  inputProps: PropTypes.object
2334
1812
  };
2335
1813
 
2336
- var focusOnError = function focusOnError(formElementsList, errors) {
2337
- var selectsIds = Object.keys(errors).map(function (fieldName) {
1814
+ const focusOnError = (formElementsList, errors) => {
1815
+ const selectsIds = Object.keys(errors).map(fieldName => {
2338
1816
  if (fieldName === FORM_ERROR) {
2339
1817
  // TODO: get from somewhere
2340
1818
  return 'notification__item_status_error';
2341
1819
  }
2342
- return "react-select-id_" + fieldName + "-input";
1820
+ return `react-select-id_${fieldName}-input`;
2343
1821
  });
2344
- var errorFieldElement = formElementsList.find(function (element) {
1822
+ const errorFieldElement = formElementsList.find(element => {
2345
1823
  if (element.name) {
2346
1824
  return getIn(errors, element.name);
2347
1825
  } else {
2348
1826
  return selectsIds.includes(element.id);
2349
1827
  }
2350
1828
  });
2351
- var errorsList = Object.keys(errors);
1829
+ const errorsList = Object.keys(errors);
2352
1830
  if (!errorFieldElement && errorsList.length) {
2353
- var errorElement;
1831
+ let errorElement;
2354
1832
  try {
2355
- var fieldName = errorsList[0];
1833
+ const fieldName = errorsList[0];
2356
1834
  if (fieldName === FORM_ERROR) {
2357
1835
  errorElement = document.querySelector('notification__item_status_error');
2358
1836
  } else {
2359
- errorElement = document.querySelector("#" + fieldName + "-error");
1837
+ errorElement = document.querySelector(`#${fieldName}-error`);
2360
1838
  if (!errorElement) {
2361
- errorElement = document.querySelector("#id_" + fieldName);
1839
+ errorElement = document.querySelector(`#id_${fieldName}`);
2362
1840
  }
2363
1841
  }
2364
1842
  } catch (err) {
@@ -2380,12 +1858,11 @@ var focusOnError = function focusOnError(formElementsList, errors) {
2380
1858
  }
2381
1859
  return null;
2382
1860
  };
2383
- var focusOnErrorDecorator = createDecorator(null, focusOnError);
2384
- var setErrorsMutator = function setErrorsMutator(args, state) {
2385
- var fieldName = args[0],
2386
- data = args[1];
2387
- var submitError = data.submitError;
2388
- var fieldError = data.error;
1861
+ const focusOnErrorDecorator = createDecorator(null, focusOnError);
1862
+ const setErrorsMutator = (args, state) => {
1863
+ const [fieldName, data] = args;
1864
+ const submitError = data.submitError;
1865
+ const fieldError = data.error;
2389
1866
  if (fieldName === 'non_field_errors') {
2390
1867
  // state.formState.invalid = true
2391
1868
  // state.formState.valid = false
@@ -2393,15 +1870,17 @@ var setErrorsMutator = function setErrorsMutator(args, state) {
2393
1870
  state.formState.submitError = submitError;
2394
1871
  } else if (fieldName in state.fields) {
2395
1872
  if (fieldError) {
2396
- var _Object$assign;
2397
- var errorsState = Object.assign({}, state.formState.errors, (_Object$assign = {}, _Object$assign[fieldName] = fieldError, _Object$assign));
1873
+ const errorsState = Object.assign({}, state.formState.errors, {
1874
+ [fieldName]: fieldError
1875
+ });
2398
1876
  state.fields[fieldName].touched = true;
2399
1877
  state.fields[fieldName].error = fieldError;
2400
1878
  state.formState.errors = errorsState;
2401
1879
  }
2402
1880
  if (submitError) {
2403
- var _Object$assign2;
2404
- var submitErrorsState = Object.assign({}, state.formState.submitErrors, (_Object$assign2 = {}, _Object$assign2[fieldName] = submitError, _Object$assign2));
1881
+ const submitErrorsState = Object.assign({}, state.formState.submitErrors, {
1882
+ [fieldName]: submitError
1883
+ });
2405
1884
 
2406
1885
  // state.fields[fieldName].submitFailed = true
2407
1886
  // state.fields[fieldName].submitSucceeded = false
@@ -2413,56 +1892,36 @@ var setErrorsMutator = function setErrorsMutator(args, state) {
2413
1892
  }
2414
1893
  }
2415
1894
  };
2416
- var sendFormDataToServer = /*#__PURE__*/function () {
2417
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url, data) {
2418
- var response, _error$response, _error$response2, formErrors;
2419
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2420
- while (1) switch (_context.prev = _context.next) {
2421
- case 0:
2422
- _context.prev = 0;
2423
- _context.next = 3;
2424
- return axios({
2425
- url: url,
2426
- method: 'POST',
2427
- data: data
2428
- });
2429
- case 3:
2430
- response = _context.sent;
2431
- return _context.abrupt("return", {
2432
- success: true,
2433
- response: response
2434
- });
2435
- case 7:
2436
- _context.prev = 7;
2437
- _context.t0 = _context["catch"](0);
2438
- formErrors = {};
2439
- if (typeof ((_error$response = _context.t0.response) == null ? void 0 : _error$response.data) === 'string') {
2440
- formErrors[FORM_ERROR] = 'Something went wrong';
2441
- }
2442
- if (typeof ((_error$response2 = _context.t0.response) == null ? void 0 : _error$response2.data) === 'object') {
2443
- Object.entries(_context.t0.response.data).forEach(function (_ref2) {
2444
- var fieldName = _ref2[0],
2445
- errorsList = _ref2[1];
2446
- formErrors[fieldName] = errorsList[0];
2447
- });
2448
- }
2449
- return _context.abrupt("return", {
2450
- success: false,
2451
- formErrors: formErrors,
2452
- error: _context.t0
2453
- });
2454
- case 13:
2455
- case "end":
2456
- return _context.stop();
2457
- }
2458
- }, _callee, null, [[0, 7]]);
2459
- }));
2460
- return function sendFormDataToServer(_x, _x2) {
2461
- return _ref.apply(this, arguments);
2462
- };
2463
- }();
1895
+ const sendFormDataToServer = async (url, data) => {
1896
+ try {
1897
+ const response = await axios({
1898
+ url: url,
1899
+ method: 'POST',
1900
+ data: data
1901
+ });
1902
+ return {
1903
+ success: true,
1904
+ response
1905
+ };
1906
+ } catch (error) {
1907
+ const formErrors = {};
1908
+ if (typeof error.response?.data === 'string') {
1909
+ formErrors[FORM_ERROR] = 'Something went wrong';
1910
+ }
1911
+ if (typeof error.response?.data === 'object') {
1912
+ Object.entries(error.response.data).forEach(([fieldName, errorsList]) => {
1913
+ formErrors[fieldName] = errorsList[0];
1914
+ });
1915
+ }
1916
+ return {
1917
+ success: false,
1918
+ formErrors,
1919
+ error
1920
+ };
1921
+ }
1922
+ };
2464
1923
 
2465
- var formTypes = {
1924
+ const formTypes = {
2466
1925
  checkbox: 'checkbox',
2467
1926
  custom: 'custom',
2468
1927
  choice: 'choice',
@@ -2474,7 +1933,7 @@ var formTypes = {
2474
1933
  radioGroup: 'radioGroup',
2475
1934
  segmented: 'segmented',
2476
1935
  select: 'select',
2477
- "switch": 'switch',
1936
+ switch: 'switch',
2478
1937
  text: 'text',
2479
1938
  textarea: 'textarea'
2480
1939
  };
@@ -2498,7 +1957,7 @@ function generateField(field, config, props) {
2498
1957
  key: config.key
2499
1958
  }, field, props));
2500
1959
  }
2501
- case formTypes["switch"]:
1960
+ case formTypes.switch:
2502
1961
  {
2503
1962
  return /*#__PURE__*/React.createElement(SwitchField, Object.assign({
2504
1963
  key: config.key
@@ -2556,13 +2015,12 @@ function generateField(field, config, props) {
2556
2015
  {
2557
2016
  return /*#__PURE__*/React.createElement(Group, Object.assign({
2558
2017
  key: config.key
2559
- }, field, props), Object.entries(field.group).map(function (_ref) {
2560
- var key = _ref[0],
2561
- value = _ref[1];
2562
- var groupProps = Object.assign({}, value, {
2018
+ }, field, props), Object.entries(field.group).map(([key, value]) => {
2019
+ const groupProps = {
2020
+ ...value,
2563
2021
  hideMessage: field.hideMessage,
2564
2022
  classNameGroupItem: value.classNameGroupItem || 'form__group-item'
2565
- });
2023
+ };
2566
2024
  return generateField(groupProps, {
2567
2025
  key: key + '_form_group'
2568
2026
  }, props);
@@ -2571,118 +2029,121 @@ function generateField(field, config, props) {
2571
2029
  }
2572
2030
  }
2573
2031
 
2574
- var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2575
- var additionalProps = props.additionalProps,
2576
- after = props.after,
2577
- before = props.before,
2578
- buttonDirection = props.buttonDirection,
2579
- buttonGap = props.buttonGap,
2580
- buttonPadding = props.buttonPadding,
2581
- groupGap = props.groupGap,
2582
- className = props.className,
2583
- config = props.config,
2584
- description = props.description,
2585
- descriptionSize = props.descriptionSize,
2586
- descriptionTextColor = props.descriptionTextColor,
2587
- descriptionTextWeight = props.descriptionTextWeight,
2588
- disableFieldsAutoComplete = props.disableFieldsAutoComplete,
2589
- fieldsGap = props.fieldsGap,
2590
- formName = props.formName,
2591
- initialValues = props.initialValues,
2592
- initialValuesEqual = props.initialValuesEqual,
2593
- isLoading = props.isLoading,
2594
- loader = props.loader,
2595
- loaderSet = props.loaderSet,
2596
- loaderFill = props.loaderFill,
2597
- loaderItemFill = props.loaderItemFill,
2598
- loaderText = props.loaderText,
2599
- language = props.language,
2600
- mutators = props.mutators,
2601
- onChangeFormValues = props.onChangeFormValues,
2602
- onClickSecondaryButton = props.onClickSecondaryButton,
2603
- onClickTertiaryButton = props.onClickTertiaryButton,
2604
- onSubmit = props.onSubmit,
2605
- primaryButton = props.primaryButton,
2606
- primaryButtonLabel = props.primaryButtonLabel,
2607
- secondaryButton = props.secondaryButton,
2608
- secondaryButtonLabel = props.secondaryButtonLabel,
2609
- primaryButtonFill = props.primaryButtonFill,
2610
- primaryButtonFillHover = props.primaryButtonFillHover,
2611
- secondaryButtonFill = props.secondaryButtonFill,
2612
- secondaryButtonFillHover = props.secondaryButtonFillHover,
2613
- primaryButtonSize = props.primaryButtonSize,
2614
- primaryButtonLabelTextColor = props.primaryButtonLabelTextColor,
2615
- primaryButtonLabelSize = props.primaryButtonLabelSize,
2616
- primaryButtonLabelTextWeight = props.primaryButtonLabelTextWeight,
2617
- secondaryButtonSize = props.secondaryButtonSize,
2618
- secondaryButtonLabelTextColor = props.secondaryButtonLabelTextColor,
2619
- secondaryButtonLabelSize = props.secondaryButtonLabelSize,
2620
- secondaryButtonLabelTextWeight = props.secondaryButtonLabelTextWeight,
2621
- tertiaryButton = props.tertiaryButton,
2622
- tertiaryButtonFill = props.tertiaryButtonFill,
2623
- tertiaryButtonFillHover = props.tertiaryButtonFillHover,
2624
- tertiaryButtonSize = props.tertiaryButtonSize,
2625
- tertiaryButtonLabelTextColor = props.tertiaryButtonLabelTextColor,
2626
- tertiaryButtonLabelSize = props.tertiaryButtonLabelSize,
2627
- tertiaryButtonLabelTextWeight = props.tertiaryButtonLabelTextWeight,
2628
- tertiaryButtonLabel = props.tertiaryButtonLabel,
2629
- set = props.set,
2630
- type = props.type,
2631
- buttonJustifyContent = props.buttonJustifyContent,
2632
- title = props.title,
2633
- notificationType = props.notificationType,
2634
- buttonFill = props.buttonFill,
2635
- titleTextSize = props.titleTextSize,
2636
- titleTextColor = props.titleTextColor,
2637
- titleTextWeight = props.titleTextWeight,
2638
- validationSchema = props.validationSchema,
2639
- dataTour = props.dataTour,
2640
- dataTourButtons = props.dataTourButtons,
2641
- dataTourPrimaryButton = props.dataTourPrimaryButton,
2642
- dataTourSecondaryButton = props.dataTourSecondaryButton,
2643
- dataTourTertiaryButton = props.dataTourTertiaryButton;
2644
- var validate = useYupValidationSchema(validationSchema, language);
2645
- var onRefFormInstance = useCallback(function (formInstance) {
2032
+ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2033
+ const {
2034
+ additionalProps,
2035
+ after,
2036
+ before,
2037
+ buttonDirection,
2038
+ buttonGap,
2039
+ buttonPadding,
2040
+ groupGap,
2041
+ className,
2042
+ config,
2043
+ description,
2044
+ descriptionSize,
2045
+ descriptionTextColor,
2046
+ descriptionTextWeight,
2047
+ disableFieldsAutoComplete,
2048
+ fieldsGap,
2049
+ formName,
2050
+ initialValues,
2051
+ initialValuesEqual,
2052
+ isLoading,
2053
+ loader,
2054
+ loaderSet,
2055
+ loaderFill,
2056
+ loaderItemFill,
2057
+ loaderText,
2058
+ language,
2059
+ mutators,
2060
+ onChangeFormValues,
2061
+ onClickSecondaryButton,
2062
+ onClickTertiaryButton,
2063
+ onSubmit,
2064
+ primaryButton,
2065
+ primaryButtonLabel,
2066
+ secondaryButton,
2067
+ secondaryButtonLabel,
2068
+ primaryButtonFill,
2069
+ primaryButtonFillHover,
2070
+ secondaryButtonFill,
2071
+ secondaryButtonFillHover,
2072
+ primaryButtonSize,
2073
+ primaryButtonLabelTextColor,
2074
+ primaryButtonLabelSize,
2075
+ primaryButtonLabelTextWeight,
2076
+ secondaryButtonSize,
2077
+ secondaryButtonLabelTextColor,
2078
+ secondaryButtonLabelSize,
2079
+ secondaryButtonLabelTextWeight,
2080
+ tertiaryButton,
2081
+ tertiaryButtonFill,
2082
+ tertiaryButtonFillHover,
2083
+ tertiaryButtonSize,
2084
+ tertiaryButtonLabelTextColor,
2085
+ tertiaryButtonLabelSize,
2086
+ tertiaryButtonLabelTextWeight,
2087
+ tertiaryButtonLabel,
2088
+ set,
2089
+ type,
2090
+ buttonJustifyContent,
2091
+ title,
2092
+ notificationType,
2093
+ notificationClose,
2094
+ buttonFill,
2095
+ titleTextSize,
2096
+ titleTextColor,
2097
+ titleTextWeight,
2098
+ validationSchema,
2099
+ dataTour,
2100
+ dataTourButtons,
2101
+ dataTourPrimaryButton,
2102
+ dataTourSecondaryButton,
2103
+ dataTourTertiaryButton
2104
+ } = props;
2105
+ const validate = useYupValidationSchema(validationSchema, language);
2106
+ const onRefFormInstance = useCallback(formInstance => {
2646
2107
  if (ref) {
2647
2108
  ref.current = formInstance;
2648
2109
  }
2649
2110
  }, [ref]);
2650
- var fillClass = useDeviceTargetClass(props, {
2111
+ const fillClass = useDeviceTargetClass(props, {
2651
2112
  prefix: 'fill_',
2652
2113
  propsKey: 'fill'
2653
2114
  });
2654
- var directionClass = useDeviceTargetClass(props, {
2115
+ const directionClass = useDeviceTargetClass(props, {
2655
2116
  prefix: 'direction_',
2656
2117
  propsKey: 'direction'
2657
2118
  });
2658
- var shapeClass = useDeviceTargetClass(props, {
2119
+ const shapeClass = useDeviceTargetClass(props, {
2659
2120
  prefix: 'shape_',
2660
2121
  propsKey: 'shape'
2661
2122
  });
2662
- var elevationClass = useDeviceTargetClass(props, {
2123
+ const elevationClass = useDeviceTargetClass(props, {
2663
2124
  prefix: 'elevation_',
2664
2125
  propsKey: 'elevation'
2665
2126
  });
2666
- var _useStyles = useStyles(props),
2667
- formStyles = _useStyles.styles;
2127
+ const {
2128
+ styles: formStyles
2129
+ } = useStyles(props);
2668
2130
  return /*#__PURE__*/React.createElement(Form, {
2669
2131
  decorators: [focusOnErrorDecorator],
2670
2132
  initialValues: initialValues,
2671
2133
  initialValuesEqual: initialValuesEqual,
2672
2134
  mutators: mutators,
2673
- render: function render(_ref) {
2674
- var handleSubmit = _ref.handleSubmit,
2675
- submitError = _ref.submitError,
2676
- modifiedSinceLastSubmit = _ref.modifiedSinceLastSubmit,
2677
- form = _ref.form;
2135
+ render: ({
2136
+ handleSubmit,
2137
+ submitError,
2138
+ modifiedSinceLastSubmit,
2139
+ form
2140
+ }) => {
2678
2141
  return /*#__PURE__*/React.createElement("form", {
2679
2142
  style: formStyles,
2680
- className: clsx(className, 'form', set && "form_set_" + set, type && "form_type_" + type, directionClass, fillClass, shapeClass, elevationClass),
2143
+ className: clsx(className, 'form', set && `form_set_${set}`, type && `form_type_${type}`, directionClass, fillClass, shapeClass, elevationClass),
2681
2144
  name: formName,
2682
2145
  "data-tour": dataTour,
2683
- ref: function ref() {
2684
- return onRefFormInstance(form);
2685
- },
2146
+ ref: () => onRefFormInstance(form),
2686
2147
  onSubmit: handleSubmit,
2687
2148
  autoComplete: disableFieldsAutoComplete ? 'off' : undefined,
2688
2149
  autoCorrect: disableFieldsAutoComplete ? 'off' : undefined,
@@ -2699,10 +2160,11 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2699
2160
  textColor: descriptionTextColor,
2700
2161
  textWeight: descriptionTextWeight
2701
2162
  }, description), submitError && !modifiedSinceLastSubmit && /*#__PURE__*/React.createElement("div", {
2702
- className: clsx('notification', 'form-notification', notificationType ? "form-notification_type_" + notificationType : 'form-notification_type_global')
2163
+ className: clsx('notification', 'form-notification', notificationType ? `form-notification_type_${notificationType}` : 'form-notification_type_global')
2703
2164
  }, /*#__PURE__*/React.createElement(NotificationItem, {
2704
2165
  className: "form-notification__item",
2705
2166
  titleTextSize: "h6",
2167
+ notificationClose: notificationClose,
2706
2168
  title: form.getState().submitError,
2707
2169
  set: "form",
2708
2170
  status: "error"
@@ -2715,11 +2177,9 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2715
2177
  direction: "vertical",
2716
2178
  gap: fieldsGap || groupGap,
2717
2179
  className: "form__wrapper"
2718
- }, Object.keys(config).map(function (key) {
2719
- return generateField(config[key], {
2720
- key: key
2721
- }, additionalProps[config[key].name]);
2722
- }), isLoading && (loader || /*#__PURE__*/React.createElement(Loader, {
2180
+ }, Object.keys(config).map(key => generateField(config[key], {
2181
+ key
2182
+ }, additionalProps[config[key].name])), isLoading && (loader || /*#__PURE__*/React.createElement(Loader, {
2723
2183
  className: "form__loader",
2724
2184
  set: loaderSet,
2725
2185
  fill: loaderFill,