@itcase/forms 1.1.52 → 1.1.54

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.
@@ -15,6 +15,7 @@ import { ChipsGroup, Chips } from '@itcase/ui/components/Chips';
15
15
  import { Choice } from '@itcase/ui/components/Choice';
16
16
  import { Code } from '@itcase/ui/components/Code';
17
17
  import { Icon } from '@itcase/ui/components/Icon';
18
+ import { Dadata } from '@itcase/ui/components/Dadata';
18
19
  import { DatePickerInput } from '@itcase/ui/components/DatePicker';
19
20
  import { useDevicePropsGenerator } from '@itcase/ui/hooks/useDevicePropsGenerator';
20
21
  import axios from 'axios';
@@ -26,6 +27,7 @@ import { Button } from '@itcase/ui/components/Button';
26
27
  import { Loader } from '@itcase/ui/components/Loader';
27
28
  import { Title } from '@itcase/ui/components/Title';
28
29
  import { Input } from '@itcase/ui/components/Input';
30
+ import { InputNumber } from '@itcase/ui/components/InputNumber';
29
31
  import { useIMask } from 'react-imask';
30
32
  import { InputPassword } from '@itcase/ui/components/InputPassword';
31
33
  import { Radio } from '@itcase/ui/components/Radio';
@@ -33,36 +35,38 @@ import { Segmented } from '@itcase/ui/components/Segmented';
33
35
  import { Select } from '@itcase/ui/components/Select';
34
36
  import { Switch } from '@itcase/ui/components/Switch';
35
37
  import { Textarea } from '@itcase/ui/components/Textarea';
36
- import { Dadata } from '@itcase/ui/components/Dadata';
37
38
  import { Group } from '@itcase/ui/components/Group';
38
39
  import { Notification } from '@itcase/ui/components/Notification';
39
40
  import createDecorator from 'final-form-focus';
40
41
 
41
- const phoneValidation = value => {
42
+ var phoneValidation = function phoneValidation(value) {
42
43
  if (!value) {
43
44
  return true;
44
45
  }
45
46
  return isPossiblePhoneNumber(value, 'RU');
46
47
  };
47
- const emailValidation = value => {
48
+ var emailValidation = function emailValidation(value) {
48
49
  // from https://emailregex.com/
49
50
  if (!value) {
50
51
  return true;
51
52
  }
52
53
 
53
54
  // from https://www.regular-expressions.info/email.html
54
- const regexp = /^[a-za-яёЁ0-9_-]+(?:\.[a-za-яёЁ0-9_-]+)*@(?:[a-za-яёЁ0-9](?:[a-za-яёЁ0-9-]*[a-za-яёЁ0-9])?\.)+[a-za-яёЁ0-9]+$/;
55
+ var regexp = /^[a-za-яёЁ0-9_-]+(?:\.[a-za-яёЁ0-9_-]+)*@(?:[a-za-яёЁ0-9](?:[a-za-яёЁ0-9-]*[a-za-яёЁ0-9])?\.)+[a-za-яёЁ0-9]+$/;
55
56
  return regexp.test(String(value).toLowerCase());
56
57
  };
57
- const dateValidation = value => {
58
- const valueDate = value instanceof Date ? value : new Date(value);
59
- const isDateValid = !isNaN(valueDate.getTime());
58
+ var dateValidation = function dateValidation(value) {
59
+ var valueDate = value instanceof Date ? value : new Date(value);
60
+ var isDateValid = !isNaN(valueDate.getTime());
60
61
  return isDateValid;
61
62
  };
62
- const addRequiredFieldsParamToSchema = schema => {
63
- const fields = Object.entries(schema.fields);
64
- schema.requiredFields = fields.reduce((list, [fieldName, validationProps]) => {
65
- if (validationProps.exclusiveTests?.required) {
63
+ var addRequiredFieldsParamToSchema = function addRequiredFieldsParamToSchema(schema) {
64
+ var fields = Object.entries(schema.fields);
65
+ schema.requiredFields = fields.reduce(function (list, _ref) {
66
+ var _validationProps$excl;
67
+ var fieldName = _ref[0],
68
+ validationProps = _ref[1];
69
+ if ((_validationProps$excl = validationProps.exclusiveTests) != null && _validationProps$excl.required) {
66
70
  list.push(fieldName);
67
71
  }
68
72
  return list;
@@ -70,6 +74,169 @@ const addRequiredFieldsParamToSchema = schema => {
70
74
  return schema;
71
75
  };
72
76
 
77
+ function _arrayLikeToArray(r, a) {
78
+ (null == a || a > r.length) && (a = r.length);
79
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
80
+ return n;
81
+ }
82
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
83
+ try {
84
+ var i = n[a](c),
85
+ u = i.value;
86
+ } catch (n) {
87
+ return void e(n);
88
+ }
89
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
90
+ }
91
+ function _asyncToGenerator(n) {
92
+ return function () {
93
+ var t = this,
94
+ e = arguments;
95
+ return new Promise(function (r, o) {
96
+ var a = n.apply(t, e);
97
+ function _next(n) {
98
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
99
+ }
100
+ function _throw(n) {
101
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
102
+ }
103
+ _next(void 0);
104
+ });
105
+ };
106
+ }
107
+ function _createForOfIteratorHelperLoose(r, e) {
108
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
109
+ if (t) return (t = t.call(r)).next.bind(t);
110
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
111
+ t && (r = t);
112
+ var o = 0;
113
+ return function () {
114
+ return o >= r.length ? {
115
+ done: true
116
+ } : {
117
+ done: false,
118
+ value: r[o++]
119
+ };
120
+ };
121
+ }
122
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
123
+ }
124
+ function _regenerator() {
125
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
126
+ var e,
127
+ t,
128
+ r = "function" == typeof Symbol ? Symbol : {},
129
+ n = r.iterator || "@@iterator",
130
+ o = r.toStringTag || "@@toStringTag";
131
+ function i(r, n, o, i) {
132
+ var c = n && n.prototype instanceof Generator ? n : Generator,
133
+ u = Object.create(c.prototype);
134
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
135
+ var i,
136
+ c,
137
+ u,
138
+ f = 0,
139
+ p = o || [],
140
+ y = false,
141
+ G = {
142
+ p: 0,
143
+ n: 0,
144
+ v: e,
145
+ a: d,
146
+ f: d.bind(e, 4),
147
+ d: function (t, r) {
148
+ return i = t, c = 0, u = e, G.n = r, a;
149
+ }
150
+ };
151
+ function d(r, n) {
152
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
153
+ var o,
154
+ i = p[t],
155
+ d = G.p,
156
+ l = i[2];
157
+ r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
158
+ }
159
+ if (o || r > 1) return a;
160
+ throw y = true, n;
161
+ }
162
+ return function (o, p, l) {
163
+ if (f > 1) throw TypeError("Generator is already running");
164
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
165
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
166
+ try {
167
+ if (f = 2, i) {
168
+ if (c || (o = "next"), t = i[o]) {
169
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
170
+ if (!t.done) return t;
171
+ u = t.value, c < 2 && (c = 0);
172
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
173
+ i = e;
174
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
175
+ } catch (t) {
176
+ i = e, c = 1, u = t;
177
+ } finally {
178
+ f = 1;
179
+ }
180
+ }
181
+ return {
182
+ value: t,
183
+ done: y
184
+ };
185
+ };
186
+ }(r, o, i), true), u;
187
+ }
188
+ var a = {};
189
+ function Generator() {}
190
+ function GeneratorFunction() {}
191
+ function GeneratorFunctionPrototype() {}
192
+ t = Object.getPrototypeOf;
193
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
194
+ return this;
195
+ }), t),
196
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
197
+ function f(e) {
198
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
199
+ }
200
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
201
+ return this;
202
+ }), _regeneratorDefine(u, "toString", function () {
203
+ return "[object Generator]";
204
+ }), (_regenerator = function () {
205
+ return {
206
+ w: i,
207
+ m: f
208
+ };
209
+ })();
210
+ }
211
+ function _regeneratorDefine(e, r, n, t) {
212
+ var i = Object.defineProperty;
213
+ try {
214
+ i({}, "", {});
215
+ } catch (e) {
216
+ i = 0;
217
+ }
218
+ _regeneratorDefine = function (e, r, n, t) {
219
+ function o(r, n) {
220
+ _regeneratorDefine(e, r, function (e) {
221
+ return this._invoke(r, n, e);
222
+ });
223
+ }
224
+ r ? i ? i(e, r, {
225
+ value: n,
226
+ enumerable: !t,
227
+ configurable: !t,
228
+ writable: !t
229
+ }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
230
+ }, _regeneratorDefine(e, r, n, t);
231
+ }
232
+ function _unsupportedIterableToArray(r, a) {
233
+ if (r) {
234
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
235
+ var t = {}.toString.call(r).slice(8, -1);
236
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
237
+ }
238
+ }
239
+
73
240
  /**
74
241
  * Sets the `innerError.message` in an `errors` object at the key
75
242
  * defined by `innerError.path`.
@@ -77,7 +244,7 @@ const addRequiredFieldsParamToSchema = schema => {
77
244
  * @param {{ path: string, message: string }} innerError A `yup` field error.
78
245
  * @returns {Object} The result of setting the new error message onto `errors`.
79
246
  */
80
- const setInError = (errors, innerError) => {
247
+ var setInError = function setInError(errors, innerError) {
81
248
  return setIn(errors, innerError.path, innerError.message);
82
249
  };
83
250
 
@@ -86,7 +253,7 @@ const setInError = (errors, innerError) => {
86
253
  * value for reducing the `err.inner` array of errors
87
254
  * from a `yup~ValidationError`.
88
255
  */
89
- const emptyObj = Object.create(null);
256
+ var emptyObj = Object.create(null);
90
257
 
91
258
  /**
92
259
  * Takes a `yup` validation schema and returns a function that expects
@@ -98,27 +265,50 @@ const emptyObj = Object.create(null);
98
265
  * and resolves to either `undefined` or a map of field names to error messages.
99
266
  */
100
267
 
101
- const makeValidate = schema => {
102
- return async function validate(values) {
103
- try {
104
- await schema.validate(values, {
105
- abortEarly: false
106
- });
107
- } catch (error) {
108
- if (error.inner) {
109
- return error.inner.reduce(setInError, emptyObj);
110
- } else {
111
- console.warn('itcase-forms schema.validate error: An error not related to the form occurred during validation. Validation ignored.');
112
- }
268
+ var makeValidate = function makeValidate(schema) {
269
+ return /*#__PURE__*/function () {
270
+ var _validate = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(values) {
271
+ var _t;
272
+ return _regenerator().w(function (_context) {
273
+ while (1) switch (_context.p = _context.n) {
274
+ case 0:
275
+ _context.p = 0;
276
+ _context.n = 1;
277
+ return schema.validate(values, {
278
+ abortEarly: false
279
+ });
280
+ case 1:
281
+ _context.n = 4;
282
+ break;
283
+ case 2:
284
+ _context.p = 2;
285
+ _t = _context.v;
286
+ if (!_t.inner) {
287
+ _context.n = 3;
288
+ break;
289
+ }
290
+ return _context.a(2, _t.inner.reduce(setInError, emptyObj));
291
+ case 3:
292
+ console.warn('itcase-forms schema.validate error: An error not related to the form occurred during validation. Validation ignored.');
293
+ case 4:
294
+ return _context.a(2);
295
+ }
296
+ }, _callee, null, [[0, 2]]);
297
+ }));
298
+ function validate(_x) {
299
+ return _validate.apply(this, arguments);
113
300
  }
114
- };
301
+ return validate;
302
+ }();
115
303
  };
116
304
  function useYupValidationSchema(schema, language) {
117
- const validate = useMemo(() => schema && makeValidate(schema), [schema, language]);
305
+ var validate = useMemo(function () {
306
+ return schema && makeValidate(schema);
307
+ }, [schema, language]);
118
308
  return validate;
119
309
  }
120
310
 
121
- const defaultCheckboxProps = {
311
+ var defaultCheckboxProps = {
122
312
  appearance: 'defaultPrimary sizeL solid',
123
313
  width: 'fill',
124
314
  // useValidationAppearanceInputProps
@@ -130,20 +320,22 @@ const defaultCheckboxProps = {
130
320
 
131
321
  // Whether to display an error message based on "fieldProps" and meta-objects
132
322
  function useFieldValidationState(props) {
133
- const {
134
- fieldProps = {},
135
- input = {},
136
- meta = {}
137
- } = props;
323
+ var _meta$error;
324
+ var _props$fieldProps = props.fieldProps,
325
+ fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
326
+ _props$input = props.input,
327
+ input = _props$input === void 0 ? {} : _props$input,
328
+ _props$meta = props.meta,
329
+ meta = _props$meta === void 0 ? {} : _props$meta;
138
330
  // Determines if there's a submission error that hasn't been rectified since the last submission.
139
- const submitError = !meta.modifiedSinceLastSubmit && meta.submitError;
331
+ var submitError = !meta.modifiedSinceLastSubmit && meta.submitError;
140
332
 
141
333
  // Determines a key for the error, defaulting to 'error' if no specific key is found.
142
- const errorKey = meta.error?.key || 'error';
143
- const successKey = 'success';
334
+ var errorKey = ((_meta$error = meta.error) == null ? void 0 : _meta$error.key) || 'error';
335
+ var successKey = 'success';
144
336
 
145
337
  // Determines if the field is in an error state based on various conditions.
146
- const isErrorState = useMemo(() => {
338
+ var isErrorState = useMemo(function () {
147
339
  if (fieldProps.showErrorsOnSubmit) {
148
340
  return Boolean(meta.submitFailed && meta.touched && (meta.error || submitError));
149
341
  } else {
@@ -152,15 +344,15 @@ function useFieldValidationState(props) {
152
344
  }, [fieldProps.showErrorsOnSubmit, meta.submitFailed, meta.touched, meta.error, submitError]);
153
345
 
154
346
  // Determines if the field's input state is valid
155
- const isValidState = useMemo(() => {
156
- const hasValue = Array.isArray(input?.value) ? input?.value.length : input?.value;
157
- const isModifiedAfterSubmit = meta.modifiedSinceLastSubmit && !meta.error && submitError;
347
+ var isValidState = useMemo(function () {
348
+ var hasValue = Array.isArray(input == null ? void 0 : input.value) ? input == null ? void 0 : input.value.length : input == null ? void 0 : input.value;
349
+ var isModifiedAfterSubmit = meta.modifiedSinceLastSubmit && !meta.error && submitError;
158
350
  return Boolean(hasValue && (meta.valid || isModifiedAfterSubmit));
159
- }, [input?.value, meta.valid, meta.error, submitError, meta.modifiedSinceLastSubmit]);
160
- const errorMessage = useMemo(() => {
351
+ }, [input == null ? void 0 : input.value, meta.valid, meta.error, submitError, meta.modifiedSinceLastSubmit]);
352
+ var errorMessage = useMemo(function () {
161
353
  // If final-form field has error in "meta" render-property.
162
354
  // If field not modified after last form submit - use submit error
163
- const error = meta.error || submitError || false;
355
+ var error = meta.error || submitError || false;
164
356
  if (error) {
165
357
  // And error in "meta" is string
166
358
  if (typeof error === 'string') {
@@ -178,24 +370,22 @@ function useFieldValidationState(props) {
178
370
  return '';
179
371
  }, [meta.error, submitError]);
180
372
  return {
181
- errorKey,
182
- errorMessage,
183
- isErrorState,
184
- successKey,
185
- isValidState
373
+ errorKey: errorKey,
374
+ errorMessage: errorMessage,
375
+ isErrorState: isErrorState,
376
+ successKey: successKey,
377
+ isValidState: isValidState
186
378
  };
187
379
  }
188
380
 
189
381
  // This hook changes the props of the child component depending on the type of error,
190
382
  // looks at what props were in initialProps, if they are there then changes
191
383
  function useValidationAppearanceInputProps(props) {
192
- const {
193
- inputProps,
194
- validationStateKey
195
- } = props;
384
+ var inputProps = props.inputProps,
385
+ validationStateKey = props.validationStateKey;
196
386
 
197
387
  // TODO: need to add props that can change during errors in this field
198
- const validationAppearanceInputProps = useMemo(() => {
388
+ var validationAppearanceInputProps = useMemo(function () {
199
389
  // const resultAppearanceProps = {
200
390
  // messageTextColor: props.errorMessageTextColor,
201
391
  // messageTextSize: props.errorMessageTextSize,
@@ -203,24 +393,26 @@ function useValidationAppearanceInputProps(props) {
203
393
  // // Override appearance(styled) props for child input
204
394
  // inputProps: {},
205
395
  // }
206
- const updatedInputProps = {};
396
+ var updatedInputProps = {};
207
397
  if (validationStateKey) {
208
- Object.entries(inputProps || {}).forEach(([propKey, propValue]) => {
398
+ Object.entries(inputProps || {}).forEach(function (_ref) {
399
+ var propKey = _ref[0],
400
+ propValue = _ref[1];
209
401
  // Convert the input property key to "snake_case" format.
210
402
  // e.g. "requiredBorderColor" -> "required_border_color".
211
- const propKeySnake = snakeCase(propKey);
403
+ var propKeySnake = snakeCase(propKey);
212
404
  // Check if this property is for appearance.
213
405
  // Key maybe starts with: "error", "required", "success", etc from validation config.
214
- const isPropForValidationState = propKeySnake.startsWith(`${validationStateKey}_`);
406
+ var isPropForValidationState = propKeySnake.startsWith(validationStateKey + "_");
215
407
 
216
408
  // If property is for appearance
217
409
  if (isPropForValidationState) {
218
410
  // Remove validation state part from begin of property key, to make clean appearance property.
219
411
  // e.g. "required_border_color" -> "border_color".
220
- const stateTargetKeySnake = propKeySnake.replace(`${validationStateKey}_`, '');
412
+ var stateTargetKeySnake = propKeySnake.replace(validationStateKey + "_", '');
221
413
  // Convert clean appearance property key to "camelCase" format.
222
414
  // e.g. "border_color" -> "borderColor"
223
- const stateTargetKey = camelCase(stateTargetKeySnake);
415
+ var stateTargetKey = camelCase(stateTargetKeySnake);
224
416
  // And save the value with a new clean property key
225
417
  updatedInputProps[stateTargetKey] = propValue;
226
418
  // Else if not already added earlier
@@ -237,7 +429,7 @@ function useValidationAppearanceInputProps(props) {
237
429
  return validationAppearanceInputProps;
238
430
  }
239
431
 
240
- const defaultFieldProps = {
432
+ var defaultFieldProps = {
241
433
  width: 'fill',
242
434
  direction: 'vertical',
243
435
  labelTextColor: 'surfaceTextPrimary',
@@ -248,136 +440,134 @@ const defaultFieldProps = {
248
440
  requiredMessageTextColor: 'warningTextSecondary',
249
441
  showMessage: true
250
442
  };
251
- const defaultFieldSizeS = {
443
+ var defaultFieldSizeS = Object.assign({
252
444
  size: 's',
253
445
  labelTextSize: 's',
254
446
  messageTextSize: 's',
255
447
  errorMessageTextSize: 's',
256
448
  helpTextSize: 's',
257
- requiredMessageTextSize: 's',
258
- ...defaultFieldProps
259
- };
260
- const defaultFieldSizeM = {
449
+ requiredMessageTextSize: 's'
450
+ }, defaultFieldProps);
451
+ var defaultFieldSizeM = Object.assign({
261
452
  size: 'm',
262
453
  labelTextSize: 's',
263
454
  messageTextSize: 's',
264
455
  errorMessageTextSize: 's',
265
456
  helpTextSize: 's',
266
- requiredMessageTextSize: 's',
267
- ...defaultFieldProps
268
- };
269
- const defaultFieldSizeL = {
457
+ requiredMessageTextSize: 's'
458
+ }, defaultFieldProps);
459
+ var defaultFieldSizeL = Object.assign({
270
460
  size: 'l',
271
461
  labelTextSize: 's',
272
462
  messageTextSize: 's',
273
463
  errorMessageTextSize: 's',
274
464
  helpTextSize: 's',
275
- requiredMessageTextSize: 's',
276
- ...defaultFieldProps
277
- };
278
- const defaultFieldSizeXL = {
465
+ requiredMessageTextSize: 's'
466
+ }, defaultFieldProps);
467
+ var defaultFieldSizeXL = Object.assign({
279
468
  size: 'xl',
280
469
  labelTextSize: 's',
281
470
  messageTextSize: 's',
282
471
  errorMessageTextSize: 's',
283
472
  helpTextSize: 's',
284
- requiredMessageTextSize: 's',
285
- ...defaultFieldProps
286
- };
473
+ requiredMessageTextSize: 's'
474
+ }, defaultFieldProps);
287
475
 
288
476
  function FieldWrapperBase(props) {
289
- const {
290
- id,
291
- className,
292
- dataTour,
293
- type,
294
- label,
295
- labelHidden,
296
- labelTextColor,
297
- labelTextSize,
298
- labelTextSizeMobile,
299
- labelTextSizeTablet,
300
- labelTextWeight,
301
- messageTextSize,
302
- desc,
303
- descTextColor,
304
- descTextSize,
305
- descTextWeight,
306
- afterItem,
307
- beforeItem,
308
- dividerDirection,
309
- dividerFill,
310
- dividerSize,
311
- dividerWidth,
312
- errorKey,
313
- errorMessage,
314
- fieldClassName,
315
- helpText,
316
- helpTextColor,
317
- helpTextColorSuccess,
318
- helpTextSize,
319
- helpTextSizeMobile,
320
- helpTextWeight,
321
- inputName,
322
- inputValue,
323
- metaActive,
324
- metaError,
325
- showDivider,
326
- showMessage,
327
- tag: Tag = 'div',
328
- before,
329
- after,
330
- isDisabled,
331
- isErrorState,
332
- isHidden,
333
- isRequired,
334
- isValidState,
335
- children
336
- } = props;
337
- const formFieldClass = useMemo(() => clsx(className, isValidState && 'form__item_state_success', isRequired && 'form__item_state_required', isDisabled && 'form__item_state_disabled', metaActive && 'form__item_state_focus', inputValue && 'form__item_state_filled', isErrorState && `form__item_state_${errorKey}`), [className, isErrorState, isValidState, isRequired, metaActive, inputValue, isDisabled, metaError]);
338
- const fieldClass = useMemo(() => clsx(fieldClassName, isValidState && `${fieldClassName}_state_success`, metaActive && `${fieldClassName}_state_focus`, inputValue && `${fieldClassName}_state_filled`, isDisabled && `${fieldClassName}_state_disabled`, isErrorState && `${fieldClassName}_state_${errorKey}`), [fieldClassName, isErrorState, isValidState, metaActive, inputValue, isDisabled, metaError]);
339
- const sizeClass = useDeviceTargetClass(props, {
477
+ var id = props.id,
478
+ className = props.className,
479
+ dataTour = props.dataTour,
480
+ type = props.type,
481
+ label = props.label,
482
+ labelHidden = props.labelHidden,
483
+ labelTextColor = props.labelTextColor,
484
+ labelTextSize = props.labelTextSize,
485
+ labelTextSizeMobile = props.labelTextSizeMobile,
486
+ labelTextSizeTablet = props.labelTextSizeTablet,
487
+ labelTextWeight = props.labelTextWeight,
488
+ messageTextSize = props.messageTextSize,
489
+ desc = props.desc,
490
+ descTextColor = props.descTextColor,
491
+ descTextSize = props.descTextSize,
492
+ descTextWeight = props.descTextWeight,
493
+ afterItem = props.afterItem,
494
+ beforeItem = props.beforeItem,
495
+ dividerDirection = props.dividerDirection,
496
+ dividerFill = props.dividerFill,
497
+ dividerSize = props.dividerSize,
498
+ dividerWidth = props.dividerWidth,
499
+ errorKey = props.errorKey,
500
+ errorMessage = props.errorMessage,
501
+ fieldClassName = props.fieldClassName,
502
+ helpText = props.helpText,
503
+ helpTextColor = props.helpTextColor,
504
+ helpTextColorSuccess = props.helpTextColorSuccess,
505
+ helpTextSize = props.helpTextSize,
506
+ helpTextSizeMobile = props.helpTextSizeMobile,
507
+ helpTextWeight = props.helpTextWeight,
508
+ inputName = props.inputName,
509
+ inputValue = props.inputValue,
510
+ metaActive = props.metaActive,
511
+ metaError = props.metaError,
512
+ showDivider = props.showDivider,
513
+ showMessage = props.showMessage,
514
+ _props$tag = props.tag,
515
+ Tag = _props$tag === void 0 ? 'div' : _props$tag,
516
+ before = props.before,
517
+ after = props.after,
518
+ isDisabled = props.isDisabled,
519
+ isErrorState = props.isErrorState,
520
+ isHidden = props.isHidden,
521
+ isRequired = props.isRequired,
522
+ isValidState = props.isValidState,
523
+ children = props.children;
524
+ var formFieldClass = useMemo(function () {
525
+ return clsx(className, isValidState && 'form__item_state_success', isRequired && 'form__item_state_required', isDisabled && 'form__item_state_disabled', metaActive && 'form__item_state_focus', inputValue && 'form__item_state_filled', isErrorState && "form__item_state_" + errorKey);
526
+ }, [className, isErrorState, isValidState, isRequired, metaActive, inputValue, isDisabled, metaError]);
527
+ var fieldClass = useMemo(function () {
528
+ return clsx(fieldClassName, isValidState && fieldClassName + "_state_success", metaActive && fieldClassName + "_state_focus", inputValue && fieldClassName + "_state_filled", isDisabled && fieldClassName + "_state_disabled", isErrorState && fieldClassName + "_state_" + errorKey);
529
+ }, [fieldClassName, isErrorState, isValidState, metaActive, inputValue, isDisabled, metaError]);
530
+ var sizeClass = useDeviceTargetClass(props, {
340
531
  prefix: 'form-field_size_',
341
532
  propsKey: 'size'
342
533
  });
343
- const fillClass = useDeviceTargetClass(props, {
534
+ var fillClass = useDeviceTargetClass(props, {
344
535
  prefix: 'fill_',
345
536
  propsKey: 'fill'
346
537
  });
347
- const inputFillClass = useDeviceTargetClass(props, {
538
+ var inputFillClass = useDeviceTargetClass(props, {
348
539
  prefix: 'fill_',
349
540
  propsKey: 'inputFill'
350
541
  });
351
- const shapeClass = useDeviceTargetClass(props, {
542
+ var shapeClass = useDeviceTargetClass(props, {
352
543
  prefix: 'form-field_shape_',
353
544
  propsKey: 'shape'
354
545
  });
355
- const inputShapeClass = useDeviceTargetClass(props, {
546
+ var inputShapeClass = useDeviceTargetClass(props, {
356
547
  prefix: 'form-field__item-value_shape_',
357
548
  propsKey: 'inputShape'
358
549
  });
359
- const directionClass = useDeviceTargetClass(props, {
550
+ var directionClass = useDeviceTargetClass(props, {
360
551
  prefix: 'direction_',
361
552
  propsKey: 'direction'
362
553
  });
363
- const widthClass = useDeviceTargetClass(props, {
554
+ var widthClass = useDeviceTargetClass(props, {
364
555
  prefix: 'width_',
365
556
  propsKey: 'width'
366
557
  });
367
- const {
368
- styles: formFieldStyles
369
- } = useStyles(props);
370
- const errorTextSize = props[`${errorKey}MessageTextSize`];
371
- const errorTextColor = props[`${errorKey}MessageTextColor`];
372
- const errorTextWeight = props[`${errorKey}MessageTextWeight`];
558
+ var _useStyles = useStyles(props),
559
+ formFieldStyles = _useStyles.styles;
560
+ var errorTextSize = props[errorKey + "MessageTextSize"];
561
+ var errorTextColor = props[errorKey + "MessageTextColor"];
562
+ var errorTextWeight = props[errorKey + "MessageTextWeight"];
373
563
  return /*#__PURE__*/React.createElement(Tag, {
374
- className: clsx(formFieldClass, 'form__item', 'form-field', type && `form-field_type_${type}`, sizeClass, fillClass, shapeClass, isDisabled && `form-field_state_disabled`, isHidden && `form-field_state_hidden`, directionClass, widthClass),
375
- "data-testid": `${inputName}-field`,
564
+ className: clsx(formFieldClass, 'form__item', 'form-field', type && "form-field_type_" + type, sizeClass, fillClass, shapeClass, isDisabled && "form-field_state_disabled", isHidden && "form-field_state_hidden", directionClass, widthClass),
565
+ "data-testid": inputName + "-field",
376
566
  "data-tour": dataTour,
377
567
  style: formFieldStyles
378
568
  }, before, (label || labelHidden) && /*#__PURE__*/React.createElement("div", {
379
569
  className: clsx('form-field__label'),
380
- "data-testid": `${inputName}-field-label`,
570
+ "data-testid": inputName + "-field-label",
381
571
  htmlFor: id
382
572
  }, /*#__PURE__*/React.createElement(Text, {
383
573
  size: labelTextSize,
@@ -385,9 +575,9 @@ function FieldWrapperBase(props) {
385
575
  textWeight: labelTextWeight,
386
576
  sizeMobile: labelTextSizeMobile,
387
577
  sizeTablet: labelTextSizeTablet
388
- }, label, labelHidden && '\u00A0')), desc && /*#__PURE__*/React.createElement("div", {
578
+ }, label, labelHidden && "\xA0")), desc && /*#__PURE__*/React.createElement("div", {
389
579
  className: "form-field__desc",
390
- "data-testid": `${inputName}-field-desc`
580
+ "data-testid": inputName + "-field-desc"
391
581
  }, /*#__PURE__*/React.createElement(Text, {
392
582
  size: descTextSize,
393
583
  textColor: descTextColor,
@@ -404,63 +594,59 @@ function FieldWrapperBase(props) {
404
594
  fill: dividerFill
405
595
  })), showMessage && /*#__PURE__*/React.createElement("div", {
406
596
  className: "form-field__message",
407
- "data-testid": `${inputName}-field-message`
597
+ "data-testid": inputName + "-field-message"
408
598
  }, isErrorState && errorMessage && /*#__PURE__*/React.createElement(Text, {
409
- id: `${inputName}-error`,
599
+ id: inputName + "-error",
410
600
  className: "form-field__message-item form-field__message-item_type-error",
411
- dataTestId: `${inputName}-field-message-error`,
601
+ dataTestId: inputName + "-field-message-error",
412
602
  size: errorTextSize,
413
603
  textColor: errorTextColor,
414
604
  textWeight: errorTextWeight
415
605
  }, errorMessage), Boolean(helpText) && (!isErrorState || !errorMessage) && /*#__PURE__*/React.createElement(Text, {
416
606
  className: "form-field__message-item form-field__message-item_type_help-text",
417
- dataTestId: `${inputName}-field-message-help-text`,
607
+ dataTestId: inputName + "-field-message-help-text",
418
608
  size: helpTextSize,
419
609
  textColor: isValidState ? helpTextColorSuccess : helpTextColor,
420
610
  textWeight: helpTextWeight,
421
611
  sizeMobile: helpTextSizeMobile
422
612
  }, helpText), (!isErrorState && !helpText || isErrorState && !helpText && !errorMessage) && /*#__PURE__*/React.createElement(Text, {
423
613
  className: "form-field__message-item form-field__message-item_type_help-text",
424
- dataTestId: `${inputName}field-message-help-text`,
614
+ dataTestId: inputName + "field-message-help-text",
425
615
  size: messageTextSize
426
- }, '\u00A0')), after);
616
+ }, "\xA0")), after);
427
617
  }
428
618
  function FieldWrapper(props) {
429
- const {
430
- inputName
431
- } = props;
432
- const {
433
- change
434
- } = useForm(); // , mutators
435
-
436
- useEffect(() => {
437
- return () => {
619
+ var inputName = props.inputName;
620
+ var _useForm = useForm(),
621
+ change = _useForm.change; // , mutators
622
+
623
+ useEffect(function () {
624
+ return function () {
438
625
  change(inputName, undefined);
439
626
  };
440
627
  }, []);
441
628
  return /*#__PURE__*/React.createElement(FieldWrapperBase, props);
442
629
  }
443
630
 
444
- const FormFieldCheckbox = /*#__PURE__*/React.memo(function FormFieldCheckbox(props) {
445
- const {
446
- name,
447
- initialValue,
448
- isDisabled,
449
- classNameGroupItem,
450
- fieldProps = {},
451
- inputProps = {},
452
- showMessage,
453
- isRequired,
454
- onChange
455
- } = props;
631
+ var FormFieldCheckbox = /*#__PURE__*/React.memo(function FormFieldCheckbox(props) {
632
+ var name = props.name,
633
+ initialValue = props.initialValue,
634
+ isDisabled = props.isDisabled,
635
+ classNameGroupItem = props.classNameGroupItem,
636
+ _props$fieldProps = props.fieldProps,
637
+ fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
638
+ _props$inputProps = props.inputProps,
639
+ inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
640
+ showMessage = props.showMessage,
641
+ isRequired = props.isRequired,
642
+ onChange = props.onChange;
456
643
  return /*#__PURE__*/React.createElement(Field, {
457
644
  type: "checkbox",
458
645
  name: name,
459
646
  initialValue: initialValue
460
- }, function Render({
461
- input,
462
- meta
463
- }) {
647
+ }, function Render(_ref) {
648
+ var input = _ref.input,
649
+ meta = _ref.meta;
464
650
  /** Note:
465
651
  * Create "Render" function by "eslint-react-hooks/rules-of-hooks":
466
652
  * React Hooks cannot be called inside a callback.
@@ -468,24 +654,23 @@ const FormFieldCheckbox = /*#__PURE__*/React.memo(function FormFieldCheckbox(pro
468
654
  * custom React Hook function.
469
655
  */
470
656
 
471
- const onChangeField = useCallback(event => {
657
+ var onChangeField = useCallback(function (event) {
472
658
  input.onChange(event);
473
659
  if (onChange) {
474
660
  onChange(event.target.checked, input.name);
475
661
  }
476
662
  }, [onChange, input.onChange]);
477
- const {
478
- errorKey,
479
- errorMessage,
480
- isErrorState,
481
- successKey,
482
- isValidState
483
- } = useFieldValidationState({
484
- fieldProps: fieldProps,
485
- input: input,
486
- meta: meta
487
- });
488
- const updatedInputProps = useValidationAppearanceInputProps({
663
+ var _useFieldValidationSt = useFieldValidationState({
664
+ fieldProps: fieldProps,
665
+ input: input,
666
+ meta: meta
667
+ }),
668
+ errorKey = _useFieldValidationSt.errorKey,
669
+ errorMessage = _useFieldValidationSt.errorMessage,
670
+ isErrorState = _useFieldValidationSt.isErrorState,
671
+ successKey = _useFieldValidationSt.successKey,
672
+ isValidState = _useFieldValidationSt.isValidState;
673
+ var updatedInputProps = useValidationAppearanceInputProps({
489
674
  inputProps: inputProps,
490
675
  validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
491
676
  });
@@ -518,7 +703,7 @@ const FormFieldCheckbox = /*#__PURE__*/React.memo(function FormFieldCheckbox(pro
518
703
  });
519
704
  });
520
705
 
521
- const defaultChipsProps = {
706
+ var defaultChipsProps = {
522
707
  appearance: 'surfacePrimary sizeM rounded',
523
708
  width: 'fill',
524
709
  // useValidationAppearanceInputProps
@@ -531,32 +716,31 @@ const defaultChipsProps = {
531
716
  };
532
717
 
533
718
  function FormFieldChips(props) {
534
- const {
535
- name,
536
- initialValue,
537
- classNameGroupItem,
538
- emptyMessage,
539
- emptyMessageTextColor,
540
- emptyMessageTextSize,
541
- fieldProps,
542
- inputProps,
543
- options,
544
- showMessage,
545
- isDisabled,
546
- isRequired,
547
- onChange
548
- } = props;
549
- const {
550
- change
551
- } = useForm();
719
+ var name = props.name,
720
+ initialValue = props.initialValue,
721
+ classNameGroupItem = props.classNameGroupItem,
722
+ emptyMessage = props.emptyMessage,
723
+ emptyMessageTextColor = props.emptyMessageTextColor,
724
+ emptyMessageTextSize = props.emptyMessageTextSize,
725
+ fieldProps = props.fieldProps,
726
+ inputProps = props.inputProps,
727
+ options = props.options,
728
+ showMessage = props.showMessage,
729
+ isDisabled = props.isDisabled,
730
+ isRequired = props.isRequired,
731
+ onChange = props.onChange;
732
+ var _useForm = useForm(),
733
+ change = _useForm.change;
552
734
 
553
735
  // Callback for value changes
554
- const onChangeSomeInput = useCallback((inputValue, newOptionValue) => {
555
- const updatedValues = inputValue.includes(newOptionValue) ? inputValue.filter(selectedValue => selectedValue !== newOptionValue) : [...inputValue, newOptionValue];
736
+ var onChangeSomeInput = useCallback(function (inputValue, newOptionValue) {
737
+ var updatedValues = inputValue.includes(newOptionValue) ? inputValue.filter(function (selectedValue) {
738
+ return selectedValue !== newOptionValue;
739
+ }) : [].concat(inputValue, [newOptionValue]);
556
740
  change(name, updatedValues);
557
741
  onChange && onChange(updatedValues);
558
742
  }, [change, name, onChange]);
559
- useEffect(() => {
743
+ useEffect(function () {
560
744
  initialValue && change(name, initialValue);
561
745
  // update the form value only when the initialValue changes, so use disable eslint to ignore the warning
562
746
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -564,32 +748,33 @@ function FormFieldChips(props) {
564
748
  return /*#__PURE__*/React.createElement(Field, {
565
749
  name: name,
566
750
  initialValue: initialValue
567
- }, function Render({
568
- input,
569
- meta
570
- }) {
571
- const {
572
- errorKey,
573
- errorMessage,
574
- successKey,
575
- isErrorState,
576
- isValidState
577
- } = useFieldValidationState({
578
- fieldProps: fieldProps,
579
- input: input,
580
- meta: meta
581
- });
582
- const updatedInputProps = useValidationAppearanceInputProps({
751
+ }, function Render(_ref) {
752
+ var input = _ref.input,
753
+ meta = _ref.meta;
754
+ var _useFieldValidationSt = useFieldValidationState({
755
+ fieldProps: fieldProps,
756
+ input: input,
757
+ meta: meta
758
+ }),
759
+ errorKey = _useFieldValidationSt.errorKey,
760
+ errorMessage = _useFieldValidationSt.errorMessage,
761
+ successKey = _useFieldValidationSt.successKey,
762
+ isErrorState = _useFieldValidationSt.isErrorState,
763
+ isValidState = _useFieldValidationSt.isValidState;
764
+ var updatedInputProps = useValidationAppearanceInputProps({
583
765
  inputProps: inputProps,
584
766
  validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
585
767
  });
586
- const activeOptionsList = useMemo(() => {
587
- const emptyOptionsList = [{
768
+ var activeOptionsList = useMemo(function () {
769
+ var emptyOptionsList = [{
588
770
  label: null,
589
771
  value: null
590
772
  }];
591
- if (input?.value) {
592
- const currentOptions = options.filter(option => input.value?.includes(option.value));
773
+ if (input != null && input.value) {
774
+ var currentOptions = options.filter(function (option) {
775
+ var _input$value;
776
+ return (_input$value = input.value) == null ? void 0 : _input$value.includes(option.value);
777
+ });
593
778
  return currentOptions || emptyOptionsList;
594
779
  }
595
780
  return emptyOptionsList;
@@ -612,22 +797,28 @@ function FormFieldChips(props) {
612
797
  direction: "horizontal",
613
798
  gap: "1m",
614
799
  wrap: "wrap"
615
- }, options.map(option => /*#__PURE__*/React.createElement(Chips, Object.assign({
616
- className: clsx(meta.active && 'form-chips_state_focus', meta.error && meta.touched && `form-chips_state_${errorKey}`),
617
- key: option.value,
618
- label: option.label,
619
- value: option.value,
620
- isActive: activeOptionsList.some(activeOption => activeOption.value === option.value),
621
- isDisabled: option.isDisabled,
622
- onClick: () => onChangeSomeInput(input.value, option.value)
623
- }, updatedInputProps)))) : /*#__PURE__*/React.createElement(Text, {
800
+ }, options.map(function (option) {
801
+ return /*#__PURE__*/React.createElement(Chips, Object.assign({
802
+ className: clsx(meta.active && 'form-chips_state_focus', meta.error && meta.touched && "form-chips_state_" + errorKey),
803
+ key: option.value,
804
+ label: option.label,
805
+ value: option.value,
806
+ isActive: activeOptionsList.some(function (activeOption) {
807
+ return activeOption.value === option.value;
808
+ }),
809
+ isDisabled: option.isDisabled,
810
+ onClick: function onClick() {
811
+ return onChangeSomeInput(input.value, option.value);
812
+ }
813
+ }, updatedInputProps));
814
+ })) : /*#__PURE__*/React.createElement(Text, {
624
815
  size: emptyMessageTextSize,
625
816
  textColor: emptyMessageTextColor
626
817
  }, emptyMessage));
627
818
  });
628
819
  }
629
820
 
630
- const defaultChoiceProps = {
821
+ var defaultChoiceProps = {
631
822
  appearance: 'defaultPrimary sizeM solid rounded',
632
823
  width: 'fill',
633
824
  // useValidationAppearanceInputProps
@@ -637,27 +828,24 @@ const defaultChoiceProps = {
637
828
  requiredAppearance: 'requirePrimary sizeM solid rounded'
638
829
  };
639
830
 
640
- const FormFieldChoice = /*#__PURE__*/React.memo(function FormFieldChoice(props) {
641
- const {
642
- name,
643
- initialValue,
644
- label,
645
- messageType,
646
- isDisabled,
647
- classNameGroupItem,
648
- fieldProps,
649
- inputProps,
650
- options,
651
- placeholder,
652
- showMessage,
653
- isCheckbox,
654
- isRequired,
655
- onChange
656
- } = props;
657
- const {
658
- change
659
- } = useForm();
660
- const setActiveSegment = useCallback((option, isChecked) => {
831
+ var FormFieldChoice = /*#__PURE__*/React.memo(function FormFieldChoice(props) {
832
+ var name = props.name,
833
+ initialValue = props.initialValue,
834
+ label = props.label,
835
+ messageType = props.messageType,
836
+ isDisabled = props.isDisabled,
837
+ classNameGroupItem = props.classNameGroupItem,
838
+ fieldProps = props.fieldProps,
839
+ inputProps = props.inputProps,
840
+ options = props.options,
841
+ placeholder = props.placeholder,
842
+ showMessage = props.showMessage,
843
+ isCheckbox = props.isCheckbox,
844
+ isRequired = props.isRequired,
845
+ onChange = props.onChange;
846
+ var _useForm = useForm(),
847
+ change = _useForm.change;
848
+ var setActiveSegment = useCallback(function (option, isChecked) {
661
849
  change(name, isChecked && option.value);
662
850
  if (onChange) {
663
851
  onChange(option.value, name, isChecked);
@@ -666,39 +854,39 @@ const FormFieldChoice = /*#__PURE__*/React.memo(function FormFieldChoice(props)
666
854
  return /*#__PURE__*/React.createElement(Field, {
667
855
  initialValue: initialValue,
668
856
  name: name
669
- }, function Render({
670
- input,
671
- meta
672
- }) {
857
+ }, function Render(_ref) {
858
+ var input = _ref.input,
859
+ meta = _ref.meta;
673
860
  /** Note:
674
861
  * Create "Render" function by "eslint-react-hooks/rules-of-hooks":
675
862
  * React Hooks cannot be called inside a callback.
676
863
  * React Hooks must be called in a React function component or a
677
864
  * custom React Hook function.
678
865
  */
679
- const activeOption = useMemo(() => {
680
- const emptyOption = {
866
+ var activeOption = useMemo(function () {
867
+ var emptyOption = {
681
868
  value: null,
682
869
  label: null
683
870
  };
684
871
  if (input.value) {
685
- const currentOption = options.find(option => option.value === input.value);
872
+ var currentOption = options.find(function (option) {
873
+ return option.value === input.value;
874
+ });
686
875
  return currentOption || emptyOption;
687
876
  }
688
877
  return emptyOption;
689
878
  }, [input.value]);
690
- const {
691
- errorKey,
692
- errorMessage,
693
- isErrorState,
694
- successKey,
695
- isValidState
696
- } = useFieldValidationState({
697
- fieldProps: fieldProps,
698
- input: input,
699
- meta: meta
700
- });
701
- const updatedInputProps = useValidationAppearanceInputProps({
879
+ var _useFieldValidationSt = useFieldValidationState({
880
+ fieldProps: fieldProps,
881
+ input: input,
882
+ meta: meta
883
+ }),
884
+ errorKey = _useFieldValidationSt.errorKey,
885
+ errorMessage = _useFieldValidationSt.errorMessage,
886
+ isErrorState = _useFieldValidationSt.isErrorState,
887
+ successKey = _useFieldValidationSt.successKey,
888
+ isValidState = _useFieldValidationSt.isValidState;
889
+ var updatedInputProps = useValidationAppearanceInputProps({
702
890
  inputProps: inputProps,
703
891
  validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
704
892
  });
@@ -719,7 +907,7 @@ const FormFieldChoice = /*#__PURE__*/React.memo(function FormFieldChoice(props)
719
907
  isRequired: isRequired,
720
908
  isValidState: isValidState
721
909
  }, fieldProps), /*#__PURE__*/React.createElement(Choice, Object.assign({
722
- className: clsx(meta.active && 'form-choice_state_focus', meta.error && meta.touched && `form-choice_state_${errorKey}`),
910
+ className: clsx(meta.active && 'form-choice_state_focus', meta.error && meta.touched && "form-choice_state_" + errorKey),
723
911
  name: input.name,
724
912
  isDisabled: isDisabled,
725
913
  active: activeOption,
@@ -733,7 +921,7 @@ const FormFieldChoice = /*#__PURE__*/React.memo(function FormFieldChoice(props)
733
921
  });
734
922
  });
735
923
 
736
- const defaultCodeProps = {
924
+ var defaultCodeProps = {
737
925
  appearance: 'defaultPrimary sizeL solid rounded',
738
926
  // useValidationAppearanceInputProps
739
927
  // Error
@@ -742,26 +930,25 @@ const defaultCodeProps = {
742
930
  requiredAppearance: 'requirePrimary sizeM solid rounded'
743
931
  };
744
932
 
745
- const FormFieldCode = /*#__PURE__*/React.memo(function FormFieldCode(props) {
746
- const {
747
- name,
748
- initialValue,
749
- label,
750
- messageType,
751
- isDisabled,
752
- classNameGroupItem,
753
- fieldProps = {},
754
- inputProps = {},
755
- showMessage,
756
- isRequired
757
- } = props;
933
+ var FormFieldCode = /*#__PURE__*/React.memo(function FormFieldCode(props) {
934
+ var name = props.name,
935
+ initialValue = props.initialValue,
936
+ label = props.label,
937
+ messageType = props.messageType,
938
+ isDisabled = props.isDisabled,
939
+ classNameGroupItem = props.classNameGroupItem,
940
+ _props$fieldProps = props.fieldProps,
941
+ fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
942
+ _props$inputProps = props.inputProps,
943
+ inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
944
+ showMessage = props.showMessage,
945
+ isRequired = props.isRequired;
758
946
  return /*#__PURE__*/React.createElement(Field, {
759
947
  name: name,
760
948
  initialValue: initialValue
761
- }, function Render({
762
- input,
763
- meta
764
- }) {
949
+ }, function Render(_ref) {
950
+ var input = _ref.input,
951
+ meta = _ref.meta;
765
952
  /** Note:
766
953
  * Create "Render" function by "eslint-react-hooks/rules-of-hooks":
767
954
  * React Hooks cannot be called inside a callback.
@@ -769,18 +956,17 @@ const FormFieldCode = /*#__PURE__*/React.memo(function FormFieldCode(props) {
769
956
  * custom React Hook function.
770
957
  */
771
958
 
772
- const {
773
- errorKey,
774
- errorMessage,
775
- isErrorState,
776
- successKey,
777
- isValidState
778
- } = useFieldValidationState({
779
- fieldProps: fieldProps,
780
- input: input,
781
- meta: meta
782
- });
783
- const updatedInputProps = useValidationAppearanceInputProps({
959
+ var _useFieldValidationSt = useFieldValidationState({
960
+ fieldProps: fieldProps,
961
+ input: input,
962
+ meta: meta
963
+ }),
964
+ errorKey = _useFieldValidationSt.errorKey,
965
+ errorMessage = _useFieldValidationSt.errorMessage,
966
+ isErrorState = _useFieldValidationSt.isErrorState,
967
+ successKey = _useFieldValidationSt.successKey,
968
+ isValidState = _useFieldValidationSt.isValidState;
969
+ var updatedInputProps = useValidationAppearanceInputProps({
784
970
  inputProps: inputProps,
785
971
  validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
786
972
  });
@@ -810,30 +996,28 @@ const FormFieldCode = /*#__PURE__*/React.memo(function FormFieldCode(props) {
810
996
  });
811
997
  });
812
998
 
813
- const FormFieldCustom = /*#__PURE__*/React.memo(function FormFieldCustom(props) {
814
- const {
815
- Component,
816
- isDisabled,
817
- isRequired,
818
- name,
819
- initialValue,
820
- fieldProps = {},
821
- classNameGroupItem,
822
- showMessage,
823
- clearIcon,
824
- clearIconFill,
825
- clearIconFillHover,
826
- clearIconShape,
827
- clearIconSize,
828
- onClickClearIcon
829
- } = props;
999
+ var FormFieldCustom = /*#__PURE__*/React.memo(function FormFieldCustom(props) {
1000
+ var Component = props.Component,
1001
+ isDisabled = props.isDisabled,
1002
+ isRequired = props.isRequired,
1003
+ name = props.name,
1004
+ initialValue = props.initialValue,
1005
+ _props$fieldProps = props.fieldProps,
1006
+ fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
1007
+ classNameGroupItem = props.classNameGroupItem,
1008
+ showMessage = props.showMessage,
1009
+ clearIcon = props.clearIcon,
1010
+ clearIconFill = props.clearIconFill,
1011
+ clearIconFillHover = props.clearIconFillHover,
1012
+ clearIconShape = props.clearIconShape,
1013
+ clearIconSize = props.clearIconSize,
1014
+ onClickClearIcon = props.onClickClearIcon;
830
1015
  return /*#__PURE__*/React.createElement(Field, {
831
1016
  initialValue: initialValue,
832
1017
  name: name
833
- }, function Render({
834
- input,
835
- meta
836
- }) {
1018
+ }, function Render(_ref) {
1019
+ var input = _ref.input,
1020
+ meta = _ref.meta;
837
1021
  /** Note:
838
1022
  * Create "Render" function by "eslint-react-hooks/rules-of-hooks":
839
1023
  * React Hooks cannot be called inside a callback.
@@ -841,17 +1025,16 @@ const FormFieldCustom = /*#__PURE__*/React.memo(function FormFieldCustom(props)
841
1025
  * custom React Hook function.
842
1026
  */
843
1027
 
844
- const {
845
- isErrorState,
846
- isValidState,
847
- errorKey,
848
- errorMessage
849
- } = useFieldValidationState({
850
- fieldProps: fieldProps,
851
- input: input,
852
- meta: meta
853
- });
854
- const updatedInputProps = useValidationAppearanceInputProps({
1028
+ var _useFieldValidationSt = useFieldValidationState({
1029
+ fieldProps: fieldProps,
1030
+ input: input,
1031
+ meta: meta
1032
+ }),
1033
+ isErrorState = _useFieldValidationSt.isErrorState,
1034
+ isValidState = _useFieldValidationSt.isValidState,
1035
+ errorKey = _useFieldValidationSt.errorKey,
1036
+ errorMessage = _useFieldValidationSt.errorMessage;
1037
+ var updatedInputProps = useValidationAppearanceInputProps({
855
1038
  validationStateKey: isErrorState ? errorKey : 'success',
856
1039
  // For "Custom" field we pass all props. Can contain some special props, we don't known.
857
1040
  inputProps: props
@@ -887,7 +1070,99 @@ const FormFieldCustom = /*#__PURE__*/React.memo(function FormFieldCustom(props)
887
1070
  });
888
1071
  });
889
1072
 
890
- const defaultDatepickerProps = {
1073
+ var defaultDadataInputProps = {
1074
+ appearance: 'defaultPrimary sizeM solid rounded',
1075
+ // useValidationAppearanceInputProps
1076
+ // Error
1077
+ errorAppearance: 'errorPrimary sizeM solid rounded',
1078
+ // Success
1079
+ successAppearance: 'successPrimary sizeM solid rounded',
1080
+ // Required
1081
+ requiredAppearance: 'requirePrimary sizeM solid rounded'
1082
+ };
1083
+
1084
+ var FormFieldDadataInput = /*#__PURE__*/React.memo(function FormFieldDadataInput(props) {
1085
+ var name = props.name,
1086
+ initialValue = props.initialValue,
1087
+ isDisabled = props.isDisabled,
1088
+ classNameGroupItem = props.classNameGroupItem,
1089
+ fieldProps = props.fieldProps,
1090
+ inputProps = props.inputProps,
1091
+ parse = props.parse,
1092
+ showMessage = props.showMessage,
1093
+ token = props.token,
1094
+ isRequired = props.isRequired,
1095
+ onDadataAutocomplete = props.onDadataAutocomplete;
1096
+ if (process.env.NODE_ENV === 'development') {
1097
+ var hint = "Check your form config at field \"" + name + "\".";
1098
+ if (!token) {
1099
+ var message = "FormFieldDadataInput: 'token' prop is missing, instead got " + token + ".";
1100
+ throw new Error(message + '\n' + hint);
1101
+ }
1102
+ if (!onDadataAutocomplete) {
1103
+ var _message = "FormFieldDadataInput: 'onDadataAutocomplete' prop is missing, instead got " + onDadataAutocomplete + ".";
1104
+ throw new Error(_message + '\n' + hint);
1105
+ }
1106
+ }
1107
+ return /*#__PURE__*/React.createElement(Field, {
1108
+ name: name,
1109
+ initialValue: initialValue,
1110
+ parse: parse
1111
+ }, function Render(_ref) {
1112
+ var input = _ref.input,
1113
+ meta = _ref.meta;
1114
+ /** Note:
1115
+ * Create "Render" function by "eslint-react-hooks/rules-of-hooks":
1116
+ * React Hooks cannot be called inside a callback.
1117
+ * React Hooks must be called in a React function component or a
1118
+ * custom React Hook function.
1119
+ */
1120
+
1121
+ var _useFieldValidationSt = useFieldValidationState({
1122
+ fieldProps: fieldProps,
1123
+ input: input,
1124
+ meta: meta
1125
+ }),
1126
+ errorKey = _useFieldValidationSt.errorKey,
1127
+ errorMessage = _useFieldValidationSt.errorMessage,
1128
+ isErrorState = _useFieldValidationSt.isErrorState,
1129
+ successKey = _useFieldValidationSt.successKey,
1130
+ isValidState = _useFieldValidationSt.isValidState;
1131
+ var updatedInputProps = useValidationAppearanceInputProps({
1132
+ inputProps: inputProps,
1133
+ validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
1134
+ });
1135
+ return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
1136
+ className: clsx('form-field_input-dadata', 'form__item_input-dadata', classNameGroupItem),
1137
+ errorKey: errorKey,
1138
+ errorMessage: errorMessage,
1139
+ isErrorState: isErrorState,
1140
+ metaError: meta.error,
1141
+ isDisabled: isDisabled,
1142
+ fieldClassName: "form-dadata",
1143
+ inputName: input.name,
1144
+ inputValue: input.value || '',
1145
+ metaActive: meta.active,
1146
+ showMessage: showMessage,
1147
+ isRequired: isRequired,
1148
+ isValidState: isValidState
1149
+ }, fieldProps), /*#__PURE__*/React.createElement(Dadata
1150
+ // dataTestId={`${input.name}FieldInputDadata`}
1151
+ // className={clsx(
1152
+ // meta.active && 'input-dadata_state_focus',
1153
+ // meta.error && meta.touched && `input-dadata_state_${errorKey}`,
1154
+ // )}
1155
+ , {
1156
+ input: input,
1157
+ inputProps: updatedInputProps,
1158
+ meta: meta,
1159
+ setValue: onDadataAutocomplete,
1160
+ token: token
1161
+ }));
1162
+ });
1163
+ });
1164
+
1165
+ var defaultDatepickerProps = {
891
1166
  appearance: 'surfacePrimary sizeS',
892
1167
  dateFormat: 'dd/MM/yyyy - HH:mm',
893
1168
  readOnly: false,
@@ -901,23 +1176,22 @@ const defaultDatepickerProps = {
901
1176
  };
902
1177
 
903
1178
  function FormFieldDatePicker(props) {
904
- const {
905
- name,
906
- isDisabled,
907
- classNameGroupItem,
908
- datePickerProps,
909
- fieldProps = {},
910
- inputProps = {},
911
- showMessage,
912
- isRequired,
913
- onChange
914
- } = props;
1179
+ var name = props.name,
1180
+ isDisabled = props.isDisabled,
1181
+ classNameGroupItem = props.classNameGroupItem,
1182
+ datePickerProps = props.datePickerProps,
1183
+ _props$fieldProps = props.fieldProps,
1184
+ fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
1185
+ _props$inputProps = props.inputProps,
1186
+ inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
1187
+ showMessage = props.showMessage,
1188
+ isRequired = props.isRequired,
1189
+ onChange = props.onChange;
915
1190
  return /*#__PURE__*/React.createElement(Field, {
916
1191
  name: name
917
- }, function Render({
918
- input,
919
- meta
920
- }) {
1192
+ }, function Render(_ref) {
1193
+ var input = _ref.input,
1194
+ meta = _ref.meta;
921
1195
  /** Note:
922
1196
  * Create "Render" function by "eslint-react-hooks/rules-of-hooks":
923
1197
  * React Hooks cannot be called inside a callback.
@@ -925,7 +1199,7 @@ function FormFieldDatePicker(props) {
925
1199
  * custom React Hook function.
926
1200
  */
927
1201
 
928
- const onChangeField = useCallback((startDate, endDate) => {
1202
+ var onChangeField = useCallback(function (startDate, endDate) {
929
1203
  if (!datePickerProps.selectsRange) {
930
1204
  // When we need to save single date, value is date
931
1205
  // TODO: make object with one date? need to check all forms with FormFieldDatePicker
@@ -933,26 +1207,25 @@ function FormFieldDatePicker(props) {
933
1207
  } else {
934
1208
  // When we need to save range, value is object with two date
935
1209
  input.onChange({
936
- endDate,
937
- startDate
1210
+ endDate: endDate,
1211
+ startDate: startDate
938
1212
  });
939
1213
  }
940
1214
  if (onChange) {
941
1215
  onChange(startDate, endDate);
942
1216
  }
943
1217
  }, [input.onChange, onChange]);
944
- const {
945
- errorKey,
946
- errorMessage,
947
- isErrorState,
948
- successKey,
949
- isValidState
950
- } = useFieldValidationState({
951
- fieldProps: fieldProps,
952
- input: input,
953
- meta: meta
954
- });
955
- const updatedInputProps = useValidationAppearanceInputProps({
1218
+ var _useFieldValidationSt = useFieldValidationState({
1219
+ fieldProps: fieldProps,
1220
+ input: input,
1221
+ meta: meta
1222
+ }),
1223
+ errorKey = _useFieldValidationSt.errorKey,
1224
+ errorMessage = _useFieldValidationSt.errorMessage,
1225
+ isErrorState = _useFieldValidationSt.isErrorState,
1226
+ successKey = _useFieldValidationSt.successKey,
1227
+ isValidState = _useFieldValidationSt.isValidState;
1228
+ var updatedInputProps = useValidationAppearanceInputProps({
956
1229
  inputProps: inputProps,
957
1230
  validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
958
1231
  });
@@ -984,7 +1257,7 @@ function FormFieldDatePicker(props) {
984
1257
  });
985
1258
  }
986
1259
 
987
- const defaultDropzoneProps = {
1260
+ var defaultDropzoneProps = {
988
1261
  fill: 'surfaceSecondary',
989
1262
  fillHover: 'surfaceTertiary',
990
1263
  // borderColor: 'surfaceBorderTertiary',
@@ -1006,45 +1279,45 @@ const defaultDropzoneProps = {
1006
1279
  isPreviews: true
1007
1280
  };
1008
1281
 
1009
- const FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props) {
1010
- const {
1011
- // className, unused
1012
- maxFiles,
1013
- maxSize,
1014
- // size, unused
1015
- fileErrorText,
1016
- dropzoneProps = {},
1017
- hintDescription,
1018
- hintTitle,
1019
- inputName,
1020
- inputValue,
1021
- showFilename,
1022
- thumbColumn,
1023
- isPreviews,
1024
- onAddFiles,
1025
- onClickPreview,
1026
- onDeleteFile
1027
- } = props;
1282
+ var FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(props) {
1283
+ var maxFiles = props.maxFiles,
1284
+ maxSize = props.maxSize,
1285
+ fileErrorText = props.fileErrorText,
1286
+ _props$dropzoneProps = props.dropzoneProps,
1287
+ dropzoneProps = _props$dropzoneProps === void 0 ? {} : _props$dropzoneProps,
1288
+ hintDescription = props.hintDescription,
1289
+ hintTitle = props.hintTitle,
1290
+ inputName = props.inputName,
1291
+ inputValue = props.inputValue,
1292
+ showFilename = props.showFilename,
1293
+ thumbColumn = props.thumbColumn,
1294
+ isPreviews = props.isPreviews,
1295
+ onAddFiles = props.onAddFiles,
1296
+ onClickPreview = props.onClickPreview,
1297
+ onDeleteFile = props.onDeleteFile;
1028
1298
 
1029
1299
  // TODO: delete react-final-form things out of here?
1030
- const {
1031
- change
1032
- } = useForm();
1033
- const [fileError, setFileError] = useState('');
1034
- const [fileIsLoading, setFileIsLoading] = useState(false);
1035
- const prevFilesListRef = useRef(null);
1036
- const filesList = useMemo(() => {
1037
- const newFilesList = inputValue ? castArray(inputValue) : [];
1300
+ var _useForm = useForm(),
1301
+ change = _useForm.change;
1302
+ var _useState = useState(''),
1303
+ fileError = _useState[0],
1304
+ setFileError = _useState[1];
1305
+ var _useState2 = useState(false),
1306
+ fileIsLoading = _useState2[0],
1307
+ setFileIsLoading = _useState2[1];
1308
+ var prevFilesListRef = useRef(null);
1309
+ var filesList = useMemo(function () {
1310
+ var newFilesList = inputValue ? castArray(inputValue) : [];
1038
1311
  if (prevFilesListRef.current === null) {
1039
1312
  prevFilesListRef.current = newFilesList;
1040
1313
  return newFilesList;
1041
1314
  }
1042
1315
  // keep track of previous state and revoke unused object urls
1043
- prevFilesListRef.current.forEach(prevFile => {
1316
+ prevFilesListRef.current.forEach(function (prevFile) {
1044
1317
  if (!prevFile.preview) {
1045
1318
  return;
1046
1319
  }
1047
- const isFileDeleted = !newFilesList.some(newFile => {
1320
+ var isFileDeleted = !newFilesList.some(function (newFile) {
1048
1321
  return newFile.preview === prevFile.preview;
1049
1322
  });
1050
1323
  if (isFileDeleted) {
@@ -1054,10 +1327,10 @@ const FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(pro
1054
1327
  prevFilesListRef.current = newFilesList;
1055
1328
  return newFilesList;
1056
1329
  }, [inputValue]);
1057
- const changeFormState = useCallback(newFiles => {
1330
+ var changeFormState = useCallback(function (newFiles) {
1058
1331
  // If max files in dropzone is 1 - return file as it self, else as array of files
1059
1332
  // ps: for old projects compatibility
1060
- const toSave = dropzoneProps.maxFiles == 1 ? newFiles[0] : newFiles;
1333
+ var toSave = dropzoneProps.maxFiles == 1 ? newFiles[0] : newFiles;
1061
1334
  change(inputName, toSave);
1062
1335
  return toSave;
1063
1336
  },
@@ -1066,28 +1339,57 @@ const FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(pro
1066
1339
  [dropzoneProps, change]);
1067
1340
 
1068
1341
  //
1069
- const convertFiledValueAndSaveAsFiles = useCallback(async currentFilesList => {
1070
- setFileIsLoading(true);
1071
- const newFiles = [];
1072
- for (const fileItem of currentFilesList) {
1073
- if (typeof fileItem === 'string') {
1074
- const newFile = await convertToFile(fileItem, isPreviews);
1075
- if (newFile) {
1076
- newFiles.push(newFile);
1342
+ var convertFiledValueAndSaveAsFiles = useCallback(/*#__PURE__*/function () {
1343
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(currentFilesList) {
1344
+ var newFiles, _iterator, _step, fileItem, newFile;
1345
+ return _regenerator().w(function (_context) {
1346
+ while (1) switch (_context.n) {
1347
+ case 0:
1348
+ setFileIsLoading(true);
1349
+ newFiles = [];
1350
+ _iterator = _createForOfIteratorHelperLoose(currentFilesList);
1351
+ case 1:
1352
+ if ((_step = _iterator()).done) {
1353
+ _context.n = 5;
1354
+ break;
1355
+ }
1356
+ fileItem = _step.value;
1357
+ if (!(typeof fileItem === 'string')) {
1358
+ _context.n = 3;
1359
+ break;
1360
+ }
1361
+ _context.n = 2;
1362
+ return convertToFile(fileItem, isPreviews);
1363
+ case 2:
1364
+ newFile = _context.v;
1365
+ if (newFile) {
1366
+ newFiles.push(newFile);
1367
+ }
1368
+ _context.n = 4;
1369
+ break;
1370
+ case 3:
1371
+ newFiles.push(fileItem);
1372
+ case 4:
1373
+ _context.n = 1;
1374
+ break;
1375
+ case 5:
1376
+ changeFormState(newFiles);
1377
+ setFileIsLoading(false);
1378
+ case 6:
1379
+ return _context.a(2);
1077
1380
  }
1078
- } else {
1079
- newFiles.push(fileItem);
1080
- }
1081
- }
1082
- changeFormState(newFiles);
1083
- setFileIsLoading(false);
1084
- }, [isPreviews, changeFormState]);
1381
+ }, _callee);
1382
+ }));
1383
+ return function (_x) {
1384
+ return _ref.apply(this, arguments);
1385
+ };
1386
+ }(), [isPreviews, changeFormState]);
1085
1387
 
1086
1388
  // Delete file from dropzone
1087
- const removeFile = useCallback((event, index) => {
1389
+ var removeFile = useCallback(function (event, index) {
1088
1390
  event.stopPropagation();
1089
1391
  event.preventDefault();
1090
- const newFiles = [...filesList];
1392
+ var newFiles = [].concat(filesList);
1091
1393
  newFiles.splice(index, 1);
1092
1394
  if (onDeleteFile) {
1093
1395
  onDeleteFile(filesList[index], inputName);
@@ -1099,165 +1401,184 @@ const FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(pro
1099
1401
  [filesList, changeFormState, onDeleteFile]);
1100
1402
 
1101
1403
  // Create dropzone options
1102
- const {
1103
- getInputProps,
1104
- getRootProps
1105
- } = useDropzone({
1106
- maxFiles: maxFiles || 5,
1107
- maxSize: maxSize || 10485760,
1108
- // 10mb
1109
- // accept: { 'image/*': [] },
1110
- ...dropzoneProps,
1111
- getFilesFromEvent: async event => {
1112
- const result = await fromEvent(event);
1113
- const newFiles = result.filter(item => item instanceof File);
1114
- // Add exists and new files to accepted(or rejected)
1115
- return [...filesList, ...newFiles];
1116
- },
1117
- onDropAccepted: acceptedFiles => {
1118
- // If dropped files has accepted and we need a previews
1119
- if (isPreviews) {
1120
- // Add preview to every file
1121
- acceptedFiles.forEach(file => {
1122
- if (!file.error && !file.preview) {
1123
- file.preview = URL.createObjectURL(file);
1404
+ var _useDropzone = useDropzone(Object.assign({
1405
+ maxFiles: maxFiles || 5,
1406
+ maxSize: maxSize || 10485760
1407
+ }, dropzoneProps, {
1408
+ getFilesFromEvent: function () {
1409
+ var _getFilesFromEvent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(event) {
1410
+ var result, newFiles;
1411
+ return _regenerator().w(function (_context2) {
1412
+ while (1) switch (_context2.n) {
1413
+ case 0:
1414
+ _context2.n = 1;
1415
+ return fromEvent(event);
1416
+ case 1:
1417
+ result = _context2.v;
1418
+ newFiles = result.filter(function (item) {
1419
+ return item instanceof File;
1420
+ }); // Add exists and new files to accepted(or rejected)
1421
+ return _context2.a(2, [].concat(filesList, newFiles));
1422
+ }
1423
+ }, _callee2);
1424
+ }));
1425
+ function getFilesFromEvent(_x2) {
1426
+ return _getFilesFromEvent.apply(this, arguments);
1427
+ }
1428
+ return getFilesFromEvent;
1429
+ }(),
1430
+ onDropAccepted: function onDropAccepted(acceptedFiles) {
1431
+ // If dropped files has accepted and we need a previews
1432
+ if (isPreviews) {
1433
+ // Add preview to every file
1434
+ acceptedFiles.forEach(function (file) {
1435
+ if (!file.error && !file.preview) {
1436
+ file.preview = URL.createObjectURL(file);
1437
+ }
1438
+ });
1439
+ }
1440
+ // Save to form data (including empty when files are not valid)
1441
+ var filesToSave = changeFormState(acceptedFiles);
1442
+ setFileError('');
1443
+
1444
+ // Save DataURL for all files
1445
+ var readerPromisesList = acceptedFiles.map(function (file) {
1446
+ return new Promise(function (resolve) {
1447
+ return setFileDataURL(file, resolve);
1448
+ });
1449
+ });
1450
+ // Save files to form values
1451
+ Promise.all(readerPromisesList).then(function () {
1452
+ if (onAddFiles) {
1453
+ onAddFiles(filesToSave, inputName);
1124
1454
  }
1125
1455
  });
1126
- }
1127
- // Save to form data (including empty when files are not valid)
1128
- const filesToSave = changeFormState(acceptedFiles);
1129
- setFileError('');
1130
-
1131
- // Save DataURL for all files
1132
- const readerPromisesList = acceptedFiles.map(file => {
1133
- return new Promise(resolve => setFileDataURL(file, resolve));
1134
- });
1135
- // Save files to form values
1136
- Promise.all(readerPromisesList).then(() => {
1137
- if (onAddFiles) {
1138
- onAddFiles(filesToSave, inputName);
1139
- }
1140
- });
1141
- },
1142
- onDropRejected: rejectedFiles => {
1143
- // If dropped files has rejected
1144
- if (rejectedFiles.length) {
1145
- let fileErrorMessage = 'Ошибка при добавлении файла';
1146
- const firstFileErrorItem = rejectedFiles[0].errors[0];
1147
- if (firstFileErrorItem) {
1148
- if (firstFileErrorItem.code === ErrorCode.TooManyFiles) {
1149
- fileErrorMessage = `Максимальное количество файлов: ${maxFiles}`;
1150
- } else {
1151
- fileErrorMessage = firstFileErrorItem.message;
1456
+ },
1457
+ onDropRejected: function onDropRejected(rejectedFiles) {
1458
+ // If dropped files has rejected
1459
+ if (rejectedFiles.length) {
1460
+ var fileErrorMessage = 'Ошибка при добавлении файла';
1461
+ var firstFileErrorItem = rejectedFiles[0].errors[0];
1462
+ if (firstFileErrorItem) {
1463
+ if (firstFileErrorItem.code === ErrorCode.TooManyFiles) {
1464
+ fileErrorMessage = "\u041C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u043E\u0435 \u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u0444\u0430\u0439\u043B\u043E\u0432: " + maxFiles;
1465
+ } else {
1466
+ fileErrorMessage = firstFileErrorItem.message;
1467
+ }
1152
1468
  }
1469
+ // Show error
1470
+ setFileError(fileErrorMessage);
1471
+ } else {
1472
+ // Else clean error
1473
+ setFileError('');
1153
1474
  }
1154
- // Show error
1155
- setFileError(fileErrorMessage);
1156
- } else {
1157
- // Else clean error
1158
- setFileError('');
1159
1475
  }
1160
- }
1161
- });
1162
- useEffect(() => {
1163
- const currentFilesList = castArray(inputValue);
1164
- const isNeedToConvert = currentFilesList.some(fileItem => typeof fileItem === 'string');
1476
+ })),
1477
+ getInputProps = _useDropzone.getInputProps,
1478
+ getRootProps = _useDropzone.getRootProps;
1479
+ useEffect(function () {
1480
+ var currentFilesList = castArray(inputValue);
1481
+ var isNeedToConvert = currentFilesList.some(function (fileItem) {
1482
+ return typeof fileItem === 'string';
1483
+ });
1165
1484
  if (isNeedToConvert) {
1166
1485
  // First time convert value to Files and save to local and form state
1167
1486
  convertFiledValueAndSaveAsFiles(currentFilesList);
1168
1487
  }
1169
1488
  // eslint-disable-next-line react-hooks/exhaustive-deps
1170
1489
  }, [inputValue]);
1171
- useEffect(() => {
1490
+ useEffect(function () {
1172
1491
  // Make sure to revoke the data uris to avoid memory leaks, will run on unmount
1173
- return () => {
1174
- prevFilesListRef.current.forEach(file => {
1492
+ return function () {
1493
+ prevFilesListRef.current.forEach(function (file) {
1175
1494
  if (file.preview) {
1176
1495
  URL.revokeObjectURL(file.preview);
1177
1496
  }
1178
1497
  });
1179
1498
  };
1180
1499
  }, []);
1181
- const propsGenerator = useDevicePropsGenerator(props);
1182
- const {
1183
- fillClass,
1184
- fillHoverClass,
1185
- borderColorClass,
1186
- borderColorHoverClass,
1187
- borderTypeClass,
1188
- borderWidthClass,
1189
- errorMessageTextColor,
1190
- errorMessageTextSize,
1191
- errorMessageTextWeight,
1192
- hintDescriptionTextColor,
1193
- hintDescriptionTextSize,
1194
- hintDescriptionTextWeight,
1195
- hintDescriptionTextWrap,
1196
- hintTitleTextColor,
1197
- hintTitleTextSize,
1198
- hintTitleTextWeight,
1199
- hintTitleTextWrap,
1200
- removeThumbAppearance,
1201
- removeThumbShape,
1202
- removeThumbText,
1203
- removeThumbTextWeight,
1204
- shapeClass,
1205
- thumbBorderColorClass,
1206
- thumbBorderColorHoverClass,
1207
- thumbBorderTypeClass,
1208
- thumbBorderWidthClass,
1209
- thumbDirectionClass,
1210
- thumbNameTextColor,
1211
- thumbNameTextSize,
1212
- thumbNameTextWeight,
1213
- thumbNameTextWrap
1214
- } = propsGenerator;
1500
+ var propsGenerator = useDevicePropsGenerator(props);
1501
+ var fillClass = propsGenerator.fillClass,
1502
+ fillHoverClass = propsGenerator.fillHoverClass,
1503
+ borderColorClass = propsGenerator.borderColorClass,
1504
+ borderColorHoverClass = propsGenerator.borderColorHoverClass,
1505
+ borderTypeClass = propsGenerator.borderTypeClass,
1506
+ borderWidthClass = propsGenerator.borderWidthClass,
1507
+ errorMessageTextColor = propsGenerator.errorMessageTextColor,
1508
+ errorMessageTextSize = propsGenerator.errorMessageTextSize,
1509
+ errorMessageTextWeight = propsGenerator.errorMessageTextWeight,
1510
+ hintDescriptionTextColor = propsGenerator.hintDescriptionTextColor,
1511
+ hintDescriptionTextSize = propsGenerator.hintDescriptionTextSize,
1512
+ hintDescriptionTextWeight = propsGenerator.hintDescriptionTextWeight,
1513
+ hintDescriptionTextWrap = propsGenerator.hintDescriptionTextWrap,
1514
+ hintTitleTextColor = propsGenerator.hintTitleTextColor,
1515
+ hintTitleTextSize = propsGenerator.hintTitleTextSize,
1516
+ hintTitleTextWeight = propsGenerator.hintTitleTextWeight,
1517
+ hintTitleTextWrap = propsGenerator.hintTitleTextWrap,
1518
+ removeThumbAppearance = propsGenerator.removeThumbAppearance,
1519
+ removeThumbShape = propsGenerator.removeThumbShape,
1520
+ removeThumbText = propsGenerator.removeThumbText,
1521
+ removeThumbTextWeight = propsGenerator.removeThumbTextWeight,
1522
+ shapeClass = propsGenerator.shapeClass,
1523
+ thumbBorderColorClass = propsGenerator.thumbBorderColorClass,
1524
+ thumbBorderColorHoverClass = propsGenerator.thumbBorderColorHoverClass,
1525
+ thumbBorderTypeClass = propsGenerator.thumbBorderTypeClass,
1526
+ thumbBorderWidthClass = propsGenerator.thumbBorderWidthClass,
1527
+ thumbDirectionClass = propsGenerator.thumbDirectionClass,
1528
+ thumbNameTextColor = propsGenerator.thumbNameTextColor,
1529
+ thumbNameTextSize = propsGenerator.thumbNameTextSize,
1530
+ thumbNameTextWeight = propsGenerator.thumbNameTextWeight,
1531
+ thumbNameTextWrap = propsGenerator.thumbNameTextWrap;
1215
1532
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", getRootProps({
1216
1533
  // className: `form-dropzone__dropzone dropzone ${className} form-dropzone__dropzone_size_${size} ${shapeClass}`,
1217
- className: `form-dropzone__dropzone dropzone`
1534
+ className: "form-dropzone__dropzone dropzone"
1218
1535
  }), /*#__PURE__*/React.createElement("input", Object.assign({}, getInputProps(), {
1219
1536
  name: inputName
1220
1537
  })), /*#__PURE__*/React.createElement("div", {
1221
- className: clsx('form-dropzone__dropzone-wrapper', thumbColumn && `form-dropzone__dropzone-wrapper_column_${thumbColumn}`, fillClass && `fill_${fillClass}`, fillHoverClass && `fill_hover_${fillHoverClass}`, borderWidthClass && `border-width_${borderWidthClass}`, borderColorClass && `border-color_${borderColorClass}`, borderColorHoverClass && `border-color_hover_${borderColorHoverClass}`, borderTypeClass && `border_type_${borderTypeClass}`, shapeClass && `shape_${shapeClass}`)
1222
- }, filesList.map((file, index) => /*#__PURE__*/React.createElement("aside", {
1223
- className: clsx('form-dropzone__thumb', fillClass, thumbDirectionClass, thumbBorderWidthClass, thumbBorderColorClass, thumbBorderColorHoverClass, thumbBorderTypeClass),
1224
- key: file.id || `${file.name}_${index}`
1225
- }, isPreviews && !file.error && /*#__PURE__*/React.createElement("div", {
1226
- className: "form-dropzone__thumb-image"
1227
- }, /*#__PURE__*/React.createElement("img", {
1228
- className: "form-dropzone__thumb-image-inner",
1229
- src: file.preview || file.image,
1230
- onClick: event => {
1231
- onClickPreview && onClickPreview(file, event);
1232
- }
1233
- })), file.error && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Text, {
1234
- size: thumbNameTextSize,
1235
- textColor: thumbNameTextColor,
1236
- textWeight: thumbNameTextWeight,
1237
- textWrap: thumbNameTextWrap
1238
- }, fileErrorText || file.error)), showFilename && /*#__PURE__*/React.createElement("div", {
1239
- className: "form-dropzone__thumb-name"
1240
- }, /*#__PURE__*/React.createElement(Text, {
1241
- className: "form-dropzone__thumb-name-inner",
1242
- size: thumbNameTextSize,
1243
- textColor: thumbNameTextColor,
1244
- textWeight: thumbNameTextWeight,
1245
- textWrap: thumbNameTextWrap
1246
- }, file.name)), fileIsLoading && /*#__PURE__*/React.createElement("div", {
1247
- className: "form-dropzone__thumb-loader"
1248
- }, /*#__PURE__*/React.createElement(Loader, {
1249
- width: "fill",
1250
- height: "fill"
1251
- })), /*#__PURE__*/React.createElement("div", {
1252
- className: clsx('form-dropzone__thumb-remove')
1253
- }, /*#__PURE__*/React.createElement(Button, {
1254
- className: "form-dropzone__thumb-remove-text",
1255
- appearance: removeThumbAppearance,
1256
- label: removeThumbText || 'Удалить',
1257
- labelTextWeight: removeThumbTextWeight,
1258
- shape: removeThumbShape,
1259
- onClick: event => removeFile(event, index)
1260
- })))), !filesList.length ? /*#__PURE__*/React.createElement("div", {
1538
+ className: clsx('form-dropzone__dropzone-wrapper', thumbColumn && "form-dropzone__dropzone-wrapper_column_" + thumbColumn, fillClass && "fill_" + fillClass, fillHoverClass && "fill_hover_" + fillHoverClass, borderWidthClass && "border-width_" + borderWidthClass, borderColorClass && "border-color_" + borderColorClass, borderColorHoverClass && "border-color_hover_" + borderColorHoverClass, borderTypeClass && "border_type_" + borderTypeClass, shapeClass && "shape_" + shapeClass)
1539
+ }, filesList.map(function (file, index) {
1540
+ return /*#__PURE__*/React.createElement("aside", {
1541
+ className: clsx('form-dropzone__thumb', fillClass, thumbDirectionClass, thumbBorderWidthClass, thumbBorderColorClass, thumbBorderColorHoverClass, thumbBorderTypeClass),
1542
+ key: file.id || file.name + "_" + index
1543
+ }, isPreviews && !file.error && /*#__PURE__*/React.createElement("div", {
1544
+ className: "form-dropzone__thumb-image"
1545
+ }, /*#__PURE__*/React.createElement("img", {
1546
+ className: "form-dropzone__thumb-image-inner",
1547
+ src: file.preview || file.image,
1548
+ onClick: function onClick(event) {
1549
+ onClickPreview && onClickPreview(file, event);
1550
+ }
1551
+ })), file.error && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Text, {
1552
+ size: thumbNameTextSize,
1553
+ textColor: thumbNameTextColor,
1554
+ textWeight: thumbNameTextWeight,
1555
+ textWrap: thumbNameTextWrap
1556
+ }, fileErrorText || file.error)), showFilename && /*#__PURE__*/React.createElement("div", {
1557
+ className: "form-dropzone__thumb-name"
1558
+ }, /*#__PURE__*/React.createElement(Text, {
1559
+ className: "form-dropzone__thumb-name-inner",
1560
+ size: thumbNameTextSize,
1561
+ textColor: thumbNameTextColor,
1562
+ textWeight: thumbNameTextWeight,
1563
+ textWrap: thumbNameTextWrap
1564
+ }, file.name)), fileIsLoading && /*#__PURE__*/React.createElement("div", {
1565
+ className: "form-dropzone__thumb-loader"
1566
+ }, /*#__PURE__*/React.createElement(Loader, {
1567
+ width: "fill",
1568
+ height: "fill"
1569
+ })), /*#__PURE__*/React.createElement("div", {
1570
+ className: clsx('form-dropzone__thumb-remove')
1571
+ }, /*#__PURE__*/React.createElement(Button, {
1572
+ className: "form-dropzone__thumb-remove-text",
1573
+ appearance: removeThumbAppearance,
1574
+ label: removeThumbText || 'Удалить',
1575
+ labelTextWeight: removeThumbTextWeight,
1576
+ shape: removeThumbShape,
1577
+ onClick: function onClick(event) {
1578
+ return removeFile(event, index);
1579
+ }
1580
+ })));
1581
+ }), !filesList.length ? /*#__PURE__*/React.createElement("div", {
1261
1582
  className: "form-dropzone__hint"
1262
1583
  }, /*#__PURE__*/React.createElement(Text, {
1263
1584
  className: "form-dropzone__hint-title",
@@ -1294,67 +1615,101 @@ const FileInputDropzone = /*#__PURE__*/React.memo(function FileInputDropzone(pro
1294
1615
  textWeight: errorMessageTextWeight
1295
1616
  }, fileError)));
1296
1617
  });
1297
- async function getFileByURL(url) {
1298
- try {
1299
- const response = await axios({
1300
- url: url,
1301
- responseType: 'blob'
1302
- });
1303
- const blobObject = response.data;
1304
- const dirtyFilename = response.headers['content-disposition']?.split('filename=')[1];
1305
- // Remove double quotes
1306
- let filename = dirtyFilename?.substring(1).slice(0, -1);
1307
- if (!filename) {
1308
- filename = url.split('/').at(-1);
1309
- // const typeParts = blobObject.type.split('/')
1310
- // const fileType = typeParts[typeParts.length - 1]
1311
- // filename = `${new Date().getTime()}.${fileType}`
1312
- }
1313
- return new File([blobObject], filename, {
1314
- type: blobObject.type
1315
- });
1316
- } catch (error) {
1317
- console.log('error: ', error);
1318
- return null;
1319
- }
1618
+ function getFileByURL(_x3) {
1619
+ return _getFileByURL.apply(this, arguments);
1320
1620
  }
1321
- async function convertToFile(inputValue, isPreviews) {
1322
- let newFile = null;
1323
-
1324
- // Download image by url and save as File instance
1325
- const isURL = typeof inputValue === 'string' && inputValue.includes('/');
1326
- if (inputValue.image || isURL) {
1327
- newFile = await getFileByURL(inputValue.image || inputValue);
1328
- if (newFile) {
1329
- setFileDataURL(newFile);
1330
- }
1331
- }
1332
-
1333
- // Convert dataURL to File instance
1334
- if (inputValue.dataURL) {
1335
- newFile = createFileFromDataURL(inputValue.name || inputValue.path, inputValue.dataURL);
1336
- newFile.dataURL = inputValue.dataURL;
1337
- }
1621
+ function _getFileByURL() {
1622
+ _getFileByURL = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(url) {
1623
+ var _response$headers$con, response, blobObject, dirtyFilename, filename, _t;
1624
+ return _regenerator().w(function (_context3) {
1625
+ while (1) switch (_context3.p = _context3.n) {
1626
+ case 0:
1627
+ _context3.p = 0;
1628
+ _context3.n = 1;
1629
+ return axios({
1630
+ url: url,
1631
+ responseType: 'blob'
1632
+ });
1633
+ case 1:
1634
+ response = _context3.v;
1635
+ blobObject = response.data;
1636
+ dirtyFilename = (_response$headers$con = response.headers['content-disposition']) == null ? void 0 : _response$headers$con.split('filename=')[1]; // Remove double quotes
1637
+ filename = dirtyFilename == null ? void 0 : dirtyFilename.substring(1).slice(0, -1);
1638
+ if (!filename) {
1639
+ filename = url.split('/').at(-1);
1640
+ // const typeParts = blobObject.type.split('/')
1641
+ // const fileType = typeParts[typeParts.length - 1]
1642
+ // filename = `${new Date().getTime()}.${fileType}`
1643
+ }
1644
+ return _context3.a(2, new File([blobObject], filename, {
1645
+ type: blobObject.type
1646
+ }));
1647
+ case 2:
1648
+ _context3.p = 2;
1649
+ _t = _context3.v;
1650
+ console.log('error: ', _t);
1651
+ return _context3.a(2, null);
1652
+ }
1653
+ }, _callee3, null, [[0, 2]]);
1654
+ }));
1655
+ return _getFileByURL.apply(this, arguments);
1656
+ }
1657
+ function convertToFile(_x4, _x5) {
1658
+ return _convertToFile.apply(this, arguments);
1659
+ }
1660
+ function _convertToFile() {
1661
+ _convertToFile = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(inputValue, isPreviews) {
1662
+ var newFile, isURL;
1663
+ return _regenerator().w(function (_context4) {
1664
+ while (1) switch (_context4.n) {
1665
+ case 0:
1666
+ newFile = null; // Download image by url and save as File instance
1667
+ isURL = typeof inputValue === 'string' && inputValue.includes('/');
1668
+ if (!(inputValue.image || isURL)) {
1669
+ _context4.n = 2;
1670
+ break;
1671
+ }
1672
+ _context4.n = 1;
1673
+ return getFileByURL(inputValue.image || inputValue);
1674
+ case 1:
1675
+ newFile = _context4.v;
1676
+ if (newFile) {
1677
+ setFileDataURL(newFile);
1678
+ }
1679
+ case 2:
1680
+ // Convert dataURL to File instance
1681
+ if (inputValue.dataURL) {
1682
+ newFile = createFileFromDataURL(inputValue.name || inputValue.path, inputValue.dataURL);
1683
+ newFile.dataURL = inputValue.dataURL;
1684
+ }
1338
1685
 
1339
- // Save new File to state
1340
- if (newFile) {
1341
- newFile.id = inputValue.id;
1342
- if (isPreviews) {
1343
- newFile.preview = URL.createObjectURL(newFile);
1344
- }
1345
- }
1346
- return newFile;
1686
+ // Save new File to state
1687
+ if (newFile) {
1688
+ newFile.id = inputValue.id;
1689
+ if (isPreviews) {
1690
+ newFile.preview = URL.createObjectURL(newFile);
1691
+ }
1692
+ }
1693
+ return _context4.a(2, newFile);
1694
+ }
1695
+ }, _callee4);
1696
+ }));
1697
+ return _convertToFile.apply(this, arguments);
1347
1698
  }
1348
1699
  function setFileDataURL(file, resolve) {
1349
- resolve = resolve || (() => {});
1700
+ resolve = resolve || function () {};
1350
1701
  // Init reader and save his file
1351
- const reader = new FileReader();
1702
+ var reader = new FileReader();
1352
1703
  reader._readedFile = file;
1353
1704
 
1354
1705
  // Set handlers
1355
- reader.onabort = () => resolve();
1356
- reader.onerror = () => resolve();
1357
- reader.onload = event => {
1706
+ reader.onabort = function () {
1707
+ return resolve();
1708
+ };
1709
+ reader.onerror = function () {
1710
+ return resolve();
1711
+ };
1712
+ reader.onload = function (event) {
1358
1713
  event.target._readedFile.dataURL = reader.result;
1359
1714
  resolve();
1360
1715
  };
@@ -1366,70 +1721,67 @@ function setFileDataURL(file, resolve) {
1366
1721
  }
1367
1722
  }
1368
1723
 
1369
- const FormFieldFileInput = /*#__PURE__*/React.memo(function FormFieldFileInput(props) {
1370
- const {
1371
- className,
1372
- name,
1373
- width,
1374
- maxFiles,
1375
- maxSize,
1376
- label,
1377
- fileErrorText,
1378
- classNameGroupItem,
1379
- dropzoneProps,
1380
- fieldProps,
1381
- hintDescription,
1382
- hintTitle,
1383
- showFilename,
1384
- showMessage,
1385
- isPreviews,
1386
- isRequired,
1387
- onAddFiles,
1388
- onClickPreview,
1389
- onDeleteFile
1390
- } = props;
1391
- const propsGenerator = useDevicePropsGenerator(props);
1392
- const {
1393
- size,
1394
- fill,
1395
- fillHover,
1396
- labelTextColor,
1397
- borderColorHover,
1398
- borderType,
1399
- borderWidth,
1400
- errorMessageTextColor,
1401
- errorMessageTextSize,
1402
- errorMessageTextWeight,
1403
- hintDescriptionTextColor,
1404
- hintDescriptionTextSize,
1405
- hintDescriptionTextWeight,
1406
- hintDescriptionTextWrap,
1407
- hintTitleTextColor,
1408
- hintTitleTextSize,
1409
- hintTitleTextWeight,
1410
- hintTitleTextWrap,
1411
- removeThumbAppearance,
1412
- removeThumbShape,
1413
- removeThumbText,
1414
- removeThumbTextWeight,
1415
- shape,
1416
- thumbBorderColor,
1417
- thumbBorderColorHover,
1418
- thumbBorderType,
1419
- thumbBorderWidth,
1420
- thumbColumn = 1,
1421
- thumbDirection = 'vertical',
1422
- thumbNameTextColor,
1423
- thumbNameTextSize,
1424
- thumbNameTextWeight,
1425
- thumbNameTextWrap
1426
- } = propsGenerator;
1724
+ var FormFieldFileInput = /*#__PURE__*/React.memo(function FormFieldFileInput(props) {
1725
+ var className = props.className,
1726
+ name = props.name,
1727
+ width = props.width,
1728
+ maxFiles = props.maxFiles,
1729
+ maxSize = props.maxSize,
1730
+ label = props.label,
1731
+ fileErrorText = props.fileErrorText,
1732
+ classNameGroupItem = props.classNameGroupItem,
1733
+ dropzoneProps = props.dropzoneProps,
1734
+ fieldProps = props.fieldProps,
1735
+ hintDescription = props.hintDescription,
1736
+ hintTitle = props.hintTitle,
1737
+ showFilename = props.showFilename,
1738
+ showMessage = props.showMessage,
1739
+ isPreviews = props.isPreviews,
1740
+ isRequired = props.isRequired,
1741
+ onAddFiles = props.onAddFiles,
1742
+ onClickPreview = props.onClickPreview,
1743
+ onDeleteFile = props.onDeleteFile;
1744
+ var propsGenerator = useDevicePropsGenerator(props);
1745
+ var size = propsGenerator.size,
1746
+ fill = propsGenerator.fill,
1747
+ fillHover = propsGenerator.fillHover,
1748
+ labelTextColor = propsGenerator.labelTextColor,
1749
+ borderColorHover = propsGenerator.borderColorHover,
1750
+ borderType = propsGenerator.borderType,
1751
+ borderWidth = propsGenerator.borderWidth,
1752
+ errorMessageTextColor = propsGenerator.errorMessageTextColor,
1753
+ errorMessageTextSize = propsGenerator.errorMessageTextSize,
1754
+ errorMessageTextWeight = propsGenerator.errorMessageTextWeight,
1755
+ hintDescriptionTextColor = propsGenerator.hintDescriptionTextColor,
1756
+ hintDescriptionTextSize = propsGenerator.hintDescriptionTextSize,
1757
+ hintDescriptionTextWeight = propsGenerator.hintDescriptionTextWeight,
1758
+ hintDescriptionTextWrap = propsGenerator.hintDescriptionTextWrap,
1759
+ hintTitleTextColor = propsGenerator.hintTitleTextColor,
1760
+ hintTitleTextSize = propsGenerator.hintTitleTextSize,
1761
+ hintTitleTextWeight = propsGenerator.hintTitleTextWeight,
1762
+ hintTitleTextWrap = propsGenerator.hintTitleTextWrap,
1763
+ removeThumbAppearance = propsGenerator.removeThumbAppearance,
1764
+ removeThumbShape = propsGenerator.removeThumbShape,
1765
+ removeThumbText = propsGenerator.removeThumbText,
1766
+ removeThumbTextWeight = propsGenerator.removeThumbTextWeight,
1767
+ shape = propsGenerator.shape,
1768
+ thumbBorderColor = propsGenerator.thumbBorderColor,
1769
+ thumbBorderColorHover = propsGenerator.thumbBorderColorHover,
1770
+ thumbBorderType = propsGenerator.thumbBorderType,
1771
+ thumbBorderWidth = propsGenerator.thumbBorderWidth,
1772
+ _propsGenerator$thumb = propsGenerator.thumbColumn,
1773
+ thumbColumn = _propsGenerator$thumb === void 0 ? 1 : _propsGenerator$thumb,
1774
+ _propsGenerator$thumb2 = propsGenerator.thumbDirection,
1775
+ thumbDirection = _propsGenerator$thumb2 === void 0 ? 'vertical' : _propsGenerator$thumb2,
1776
+ thumbNameTextColor = propsGenerator.thumbNameTextColor,
1777
+ thumbNameTextSize = propsGenerator.thumbNameTextSize,
1778
+ thumbNameTextWeight = propsGenerator.thumbNameTextWeight,
1779
+ thumbNameTextWrap = propsGenerator.thumbNameTextWrap;
1427
1780
  return /*#__PURE__*/React.createElement(Field, {
1428
1781
  name: name
1429
- }, function Render({
1430
- input,
1431
- meta
1432
- }) {
1782
+ }, function Render(_ref) {
1783
+ var input = _ref.input,
1784
+ meta = _ref.meta;
1433
1785
  /** Note:
1434
1786
  * Create "Render" function by "eslint-react-hooks/rules-of-hooks":
1435
1787
  * React Hooks cannot be called inside a callback.
@@ -1437,17 +1789,16 @@ const FormFieldFileInput = /*#__PURE__*/React.memo(function FormFieldFileInput(p
1437
1789
  * custom React Hook function.
1438
1790
  */
1439
1791
 
1440
- const {
1441
- errorKey,
1442
- errorMessage,
1443
- isErrorState,
1444
- isValidState
1445
- } = useFieldValidationState({
1446
- fieldProps: fieldProps,
1447
- input: input,
1448
- meta: meta
1449
- });
1450
- const updatedInputProps = useValidationAppearanceInputProps({
1792
+ var _useFieldValidationSt = useFieldValidationState({
1793
+ fieldProps: fieldProps,
1794
+ input: input,
1795
+ meta: meta
1796
+ }),
1797
+ errorKey = _useFieldValidationSt.errorKey,
1798
+ errorMessage = _useFieldValidationSt.errorMessage,
1799
+ isErrorState = _useFieldValidationSt.isErrorState,
1800
+ isValidState = _useFieldValidationSt.isValidState;
1801
+ var updatedInputProps = useValidationAppearanceInputProps({
1451
1802
  inputProps: props,
1452
1803
  validationStateKey: isErrorState ? errorKey : 'success'
1453
1804
  });
@@ -1526,7 +1877,7 @@ const FormFieldFileInput = /*#__PURE__*/React.memo(function FormFieldFileInput(p
1526
1877
  });
1527
1878
  });
1528
1879
 
1529
- const defaultGroupProps = {
1880
+ var defaultGroupProps = {
1530
1881
  width: 'fill',
1531
1882
  labelTextSize: 's',
1532
1883
  messageTextColor: 'surfaceTextPrimary',
@@ -1538,63 +1889,58 @@ const defaultGroupProps = {
1538
1889
  requiredMessageTextSize: 's'
1539
1890
  };
1540
1891
 
1541
- const FormBlockGroup = /*#__PURE__*/React.memo(function Group(props) {
1542
- const {
1543
- dataTour,
1544
- className,
1545
- name,
1546
- title,
1547
- titleTextColor,
1548
- titleTextSize,
1549
- titleTextWeight,
1550
- label,
1551
- labelTextColor,
1552
- labelTextSize,
1553
- labelTextWeight,
1554
- message,
1555
- messageTextColor,
1556
- messageTextSize,
1557
- messageTextWeight,
1558
- column,
1559
- showGroupMessage,
1560
- before,
1561
- after,
1562
- isHidden,
1563
- children
1564
- } = props;
1892
+ var FormBlockGroup = /*#__PURE__*/React.memo(function Group(props) {
1893
+ var dataTour = props.dataTour,
1894
+ className = props.className,
1895
+ name = props.name,
1896
+ title = props.title,
1897
+ titleTextColor = props.titleTextColor,
1898
+ titleTextSize = props.titleTextSize,
1899
+ titleTextWeight = props.titleTextWeight,
1900
+ label = props.label,
1901
+ labelTextColor = props.labelTextColor,
1902
+ labelTextSize = props.labelTextSize,
1903
+ labelTextWeight = props.labelTextWeight,
1904
+ message = props.message,
1905
+ messageTextColor = props.messageTextColor,
1906
+ messageTextSize = props.messageTextSize,
1907
+ messageTextWeight = props.messageTextWeight,
1908
+ column = props.column,
1909
+ showGroupMessage = props.showGroupMessage,
1910
+ before = props.before,
1911
+ after = props.after,
1912
+ isHidden = props.isHidden,
1913
+ children = props.children;
1565
1914
 
1566
1915
  // @ts-expect-error
1567
- const {
1568
- styles: styles
1569
- } = useStyles(props);
1916
+ var _useStyles = useStyles(props),
1917
+ styles = _useStyles.styles;
1570
1918
  return /*#__PURE__*/React.createElement(Field, {
1571
1919
  name: name
1572
- }, function Render({
1573
- input,
1574
- meta
1575
- }) {
1920
+ }, function Render(_ref) {
1921
+ var input = _ref.input,
1922
+ meta = _ref.meta;
1576
1923
  /** Note:
1577
1924
  * Create "Render" function by "eslint-react-hooks/rules-of-hooks":
1578
1925
  * React Hooks cannot be called inside a callback.
1579
1926
  * React Hooks must be called in a React function component or a
1580
1927
  * custom React Hook function.
1581
1928
  */
1582
- const {
1583
- errorKey,
1584
- errorMessage,
1585
- isErrorState
1586
- } = useFieldValidationState({
1587
- fieldProps: props,
1588
- // or fieldProps?
1589
- input: input,
1590
- meta: meta
1591
- });
1592
- const updatedProps = useValidationAppearanceInputProps({
1929
+ var _useFieldValidationSt = useFieldValidationState({
1930
+ fieldProps: props,
1931
+ // or fieldProps?
1932
+ input: input,
1933
+ meta: meta
1934
+ }),
1935
+ errorKey = _useFieldValidationSt.errorKey,
1936
+ errorMessage = _useFieldValidationSt.errorMessage,
1937
+ isErrorState = _useFieldValidationSt.isErrorState;
1938
+ var updatedProps = useValidationAppearanceInputProps({
1593
1939
  inputProps: props,
1594
1940
  validationStateKey: isErrorState ? errorKey : 'success'
1595
1941
  });
1596
1942
  return /*#__PURE__*/React.createElement("div", {
1597
- className: clsx('form__group', className, isHidden && 'form__group_hidden', column && `form__group_column_${column}`),
1943
+ className: clsx('form__group', className, isHidden && 'form__group_hidden', column && "form__group_column_" + column),
1598
1944
  "data-tour": dataTour,
1599
1945
  style: styles
1600
1946
  }, /*#__PURE__*/React.createElement("div", {
@@ -1614,8 +1960,8 @@ const FormBlockGroup = /*#__PURE__*/React.memo(function Group(props) {
1614
1960
  }, label)), /*#__PURE__*/React.createElement("div", {
1615
1961
  className: "form__group-items"
1616
1962
  }, children), after), showGroupMessage && /*#__PURE__*/React.createElement(React.Fragment, null, isErrorState && errorMessage && /*#__PURE__*/React.createElement(Text, {
1617
- id: `${name}-error`,
1618
- className: `form__group-message form__group-message_type-${errorKey}`,
1963
+ id: name + "-error",
1964
+ className: "form__group-message form__group-message_type-" + errorKey,
1619
1965
  size: updatedProps.messageTextSize,
1620
1966
  textColor: updatedProps.messageTextColor,
1621
1967
  textWeight: updatedProps.messageTextWeight
@@ -1627,11 +1973,11 @@ const FormBlockGroup = /*#__PURE__*/React.memo(function Group(props) {
1627
1973
  }, message), !isErrorState && !message && /*#__PURE__*/React.createElement(Text, {
1628
1974
  className: "form__group-message",
1629
1975
  size: messageTextSize
1630
- }, '\u00A0')));
1976
+ }, "\xA0")));
1631
1977
  });
1632
1978
  });
1633
1979
 
1634
- const defaultInputProps = {
1980
+ var defaultInputProps = {
1635
1981
  appearance: 'defaultPrimary sizeM solid rounded',
1636
1982
  width: 'fill',
1637
1983
  // useValidationAppearanceInputProps
@@ -1643,33 +1989,32 @@ const defaultInputProps = {
1643
1989
  successAppearance: 'successPrimary sizeM solid rounded'
1644
1990
  };
1645
1991
 
1646
- const FormFieldInput = /*#__PURE__*/React.memo(function FormFieldInput(props) {
1647
- const {
1648
- name,
1649
- initialValue,
1650
- classNameGroupItem,
1651
- clearIcon,
1652
- clearIconFill,
1653
- clearIconFillHover,
1654
- clearIconShape,
1655
- clearIconSize,
1656
- fieldProps = {},
1657
- inputProps = {},
1658
- parse,
1659
- showMessage,
1660
- isDisabled,
1661
- isRequired,
1662
- onClickClearIcon,
1663
- onChange
1664
- } = props;
1992
+ var FormFieldInput = /*#__PURE__*/React.memo(function FormFieldInput(props) {
1993
+ var name = props.name,
1994
+ initialValue = props.initialValue,
1995
+ classNameGroupItem = props.classNameGroupItem,
1996
+ clearIcon = props.clearIcon,
1997
+ clearIconFill = props.clearIconFill,
1998
+ clearIconFillHover = props.clearIconFillHover,
1999
+ clearIconShape = props.clearIconShape,
2000
+ clearIconSize = props.clearIconSize,
2001
+ _props$fieldProps = props.fieldProps,
2002
+ fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
2003
+ _props$inputProps = props.inputProps,
2004
+ inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
2005
+ parse = props.parse,
2006
+ showMessage = props.showMessage,
2007
+ isDisabled = props.isDisabled,
2008
+ isRequired = props.isRequired,
2009
+ onClickClearIcon = props.onClickClearIcon,
2010
+ onChange = props.onChange;
1665
2011
  return /*#__PURE__*/React.createElement(Field, {
1666
2012
  name: name,
1667
2013
  initialValue: initialValue,
1668
2014
  parse: parse
1669
- }, function Render({
1670
- input,
1671
- meta
1672
- }) {
2015
+ }, function Render(_ref) {
2016
+ var input = _ref.input,
2017
+ meta = _ref.meta;
1673
2018
  /** Note:
1674
2019
  * Create "Render" function by "eslint-react-hooks/rules-of-hooks":
1675
2020
  * React Hooks cannot be called inside a callback.
@@ -1677,24 +2022,23 @@ const FormFieldInput = /*#__PURE__*/React.memo(function FormFieldInput(props) {
1677
2022
  * custom React Hook function.
1678
2023
  */
1679
2024
 
1680
- const onChangeField = useCallback(event => {
2025
+ var onChangeField = useCallback(function (event) {
1681
2026
  input.onChange(event);
1682
2027
  if (onChange) {
1683
2028
  onChange(event.target.value, input.name);
1684
2029
  }
1685
2030
  }, [onChange, input.onChange]);
1686
- const {
1687
- errorKey,
1688
- errorMessage,
1689
- successKey,
1690
- isErrorState,
1691
- isValidState
1692
- } = useFieldValidationState({
1693
- fieldProps: fieldProps,
1694
- input: input,
1695
- meta: meta
1696
- });
1697
- const updatedInputProps = useValidationAppearanceInputProps({
2031
+ var _useFieldValidationSt = useFieldValidationState({
2032
+ fieldProps: fieldProps,
2033
+ input: input,
2034
+ meta: meta
2035
+ }),
2036
+ errorKey = _useFieldValidationSt.errorKey,
2037
+ errorMessage = _useFieldValidationSt.errorMessage,
2038
+ successKey = _useFieldValidationSt.successKey,
2039
+ isErrorState = _useFieldValidationSt.isErrorState,
2040
+ isValidState = _useFieldValidationSt.isValidState;
2041
+ var updatedInputProps = useValidationAppearanceInputProps({
1698
2042
  inputProps: inputProps,
1699
2043
  validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
1700
2044
  });
@@ -1713,8 +2057,8 @@ const FormFieldInput = /*#__PURE__*/React.memo(function FormFieldInput(props) {
1713
2057
  isRequired: isRequired,
1714
2058
  isValidState: isValidState
1715
2059
  }, fieldProps), /*#__PURE__*/React.createElement(Input, Object.assign({
1716
- className: clsx(meta.active && 'input_state_focus', meta.error && meta.touched && `input_state_${errorKey}`),
1717
- dataTestId: `${input.name}-field-input`,
2060
+ className: clsx(meta.active && 'input_state_focus', meta.error && meta.touched && "input_state_" + errorKey),
2061
+ dataTestId: input.name + "-field-input",
1718
2062
  type: "text",
1719
2063
  name: input.name,
1720
2064
  autoComplete: "nope",
@@ -1736,32 +2080,101 @@ const FormFieldInput = /*#__PURE__*/React.memo(function FormFieldInput(props) {
1736
2080
  });
1737
2081
  });
1738
2082
 
1739
- const FormFieldMaskedInput = /*#__PURE__*/React.memo(function FormFieldMaskedInput(props) {
1740
- const {
1741
- name,
1742
- initialValue,
1743
- classNameGroupItem,
1744
- clearIcon,
1745
- clearIconFill,
1746
- clearIconFillHover,
1747
- clearIconShape,
1748
- clearIconSize,
1749
- fieldProps = {},
1750
- inputProps = {},
1751
- optionsMask,
1752
- showMessage,
1753
- unmasked,
1754
- isDisabled,
1755
- isRequired,
1756
- onClickClearIcon
1757
- } = props;
2083
+ var defaultInputNumberProps = {
2084
+ appearance: 'surfaceSecondary sizeM solid rounded',
2085
+ width: 'fill'
2086
+ };
2087
+
2088
+ var FormFieldInputNumber = /*#__PURE__*/React.memo(function FormFieldInputNumber(props) {
2089
+ var _props$type = props.type,
2090
+ type = _props$type === void 0 ? 'custom' : _props$type,
2091
+ name = props.name,
2092
+ initialValue = props.initialValue,
2093
+ classNameGroupItem = props.classNameGroupItem,
2094
+ _props$fieldProps = props.fieldProps,
2095
+ fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
2096
+ _props$inputProps = props.inputProps,
2097
+ inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
2098
+ parse = props.parse,
2099
+ showMessage = props.showMessage,
2100
+ isDisabled = props.isDisabled,
2101
+ isRequired = props.isRequired,
2102
+ onChange = props.onChange;
2103
+ return /*#__PURE__*/React.createElement(Field, {
2104
+ name: name,
2105
+ initialValue: initialValue,
2106
+ parse: parse
2107
+ }, function Render(_ref) {
2108
+ var input = _ref.input,
2109
+ meta = _ref.meta;
2110
+ var onChangeField = useCallback(function (event) {
2111
+ input.onChange(event);
2112
+ if (onChange) {
2113
+ onChange(event.target.value);
2114
+ }
2115
+ }, [onChange, input.onChange]);
2116
+ var _useFieldValidationSt = useFieldValidationState({
2117
+ fieldProps: fieldProps,
2118
+ input: input,
2119
+ meta: meta
2120
+ }),
2121
+ errorKey = _useFieldValidationSt.errorKey,
2122
+ errorMessage = _useFieldValidationSt.errorMessage,
2123
+ isErrorState = _useFieldValidationSt.isErrorState,
2124
+ isValidState = _useFieldValidationSt.isValidState;
2125
+ var updatedInputProps = useValidationAppearanceInputProps({
2126
+ inputProps: inputProps
2127
+ });
2128
+ return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
2129
+ className: clsx('form-field_input-number', 'form__item_input-number', classNameGroupItem),
2130
+ errorKey: errorKey,
2131
+ errorMessage: errorMessage,
2132
+ fieldClassName: "form-input-number",
2133
+ inputName: input.name,
2134
+ inputValue: input.value || '',
2135
+ metaActive: meta.active,
2136
+ metaError: meta.error,
2137
+ showMessage: showMessage,
2138
+ isDisabled: isDisabled,
2139
+ isErrorState: isErrorState,
2140
+ isRequired: isRequired,
2141
+ isValidState: isValidState
2142
+ }, fieldProps), /*#__PURE__*/React.createElement(InputNumber, Object.assign({
2143
+ className: clsx(meta.active && 'input_state_focus', (meta.submitFailed || meta.touched) && meta.error && "input_state_" + errorKey),
2144
+ dataTestId: input.name + "FieldInputNumber",
2145
+ type: type,
2146
+ name: input.name,
2147
+ value: input.value || 0,
2148
+ onChange: onChangeField
2149
+ }, updatedInputProps)));
2150
+ });
2151
+ });
2152
+
2153
+ var FormFieldMaskedInput = /*#__PURE__*/React.memo(function FormFieldMaskedInput(props) {
2154
+ var name = props.name,
2155
+ initialValue = props.initialValue,
2156
+ classNameGroupItem = props.classNameGroupItem,
2157
+ clearIcon = props.clearIcon,
2158
+ clearIconFill = props.clearIconFill,
2159
+ clearIconFillHover = props.clearIconFillHover,
2160
+ clearIconShape = props.clearIconShape,
2161
+ clearIconSize = props.clearIconSize,
2162
+ _props$fieldProps = props.fieldProps,
2163
+ fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
2164
+ _props$inputProps = props.inputProps,
2165
+ inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
2166
+ optionsMask = props.optionsMask,
2167
+ showMessage = props.showMessage,
2168
+ unmasked = props.unmasked,
2169
+ isDisabled = props.isDisabled,
2170
+ isRequired = props.isRequired,
2171
+ onClickClearIcon = props.onClickClearIcon;
1758
2172
  return /*#__PURE__*/React.createElement(Field, {
1759
2173
  name: name,
1760
2174
  initialValue: initialValue
1761
- }, function Render({
1762
- input,
1763
- meta
1764
- }) {
2175
+ }, function Render(_ref) {
2176
+ var input = _ref.input,
2177
+ meta = _ref.meta;
1765
2178
  /** Note:
1766
2179
  * Create "Render" function by "eslint-react-hooks/rules-of-hooks":
1767
2180
  * React Hooks cannot be called inside a callback.
@@ -1769,36 +2182,34 @@ const FormFieldMaskedInput = /*#__PURE__*/React.memo(function FormFieldMaskedInp
1769
2182
  * custom React Hook function.
1770
2183
  */
1771
2184
 
1772
- const {
1773
- ref,
1774
- unmaskedValue,
1775
- value,
1776
- setUnmaskedValue
1777
- } = useIMask(optionsMask, {
1778
- defaultValue: initialValue,
1779
- onAccept: (_newValue, event, element) => {
1780
- if (element) {
1781
- input.onChange(event._unmaskedValue);
2185
+ var _useIMask = useIMask(optionsMask, {
2186
+ defaultValue: initialValue,
2187
+ onAccept: function onAccept(_newValue, event, element) {
2188
+ if (element) {
2189
+ input.onChange(event._unmaskedValue);
2190
+ }
1782
2191
  }
1783
- }
1784
- });
1785
- useEffect(() => {
2192
+ }),
2193
+ ref = _useIMask.ref,
2194
+ unmaskedValue = _useIMask.unmaskedValue,
2195
+ value = _useIMask.value,
2196
+ setUnmaskedValue = _useIMask.setUnmaskedValue;
2197
+ useEffect(function () {
1786
2198
  if (input.value !== unmaskedValue) {
1787
2199
  setUnmaskedValue(input.value.replace(unmasked, ''));
1788
2200
  }
1789
2201
  }, [input.value]);
1790
- const {
1791
- errorKey,
1792
- errorMessage,
1793
- successKey,
1794
- isErrorState,
1795
- isValidState
1796
- } = useFieldValidationState({
1797
- fieldProps: fieldProps,
1798
- input: input,
1799
- meta: meta
1800
- });
1801
- const updatedInputProps = useValidationAppearanceInputProps({
2202
+ var _useFieldValidationSt = useFieldValidationState({
2203
+ fieldProps: fieldProps,
2204
+ input: input,
2205
+ meta: meta
2206
+ }),
2207
+ errorKey = _useFieldValidationSt.errorKey,
2208
+ errorMessage = _useFieldValidationSt.errorMessage,
2209
+ successKey = _useFieldValidationSt.successKey,
2210
+ isErrorState = _useFieldValidationSt.isErrorState,
2211
+ isValidState = _useFieldValidationSt.isValidState;
2212
+ var updatedInputProps = useValidationAppearanceInputProps({
1802
2213
  inputProps: inputProps,
1803
2214
  validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
1804
2215
  });
@@ -1817,7 +2228,7 @@ const FormFieldMaskedInput = /*#__PURE__*/React.memo(function FormFieldMaskedInp
1817
2228
  isRequired: isRequired,
1818
2229
  isValidState: isValidState
1819
2230
  }, fieldProps), /*#__PURE__*/React.createElement(Input, Object.assign({
1820
- className: clsx(meta.active && 'input_state_focus', meta.error && meta.touched && `input_state_${errorKey}`),
2231
+ className: clsx(meta.active && 'input_state_focus', meta.error && meta.touched && "input_state_" + errorKey),
1821
2232
  ref: ref,
1822
2233
  value: value,
1823
2234
  onBlur: input.onBlur,
@@ -1835,7 +2246,7 @@ const FormFieldMaskedInput = /*#__PURE__*/React.memo(function FormFieldMaskedInp
1835
2246
  });
1836
2247
  });
1837
2248
 
1838
- const defaultPasswordProps = {
2249
+ var defaultPasswordProps = {
1839
2250
  appearance: 'defaultPrimary sizeM solid rounded',
1840
2251
  // useValidationAppearanceInputProps
1841
2252
  // Error
@@ -1846,27 +2257,24 @@ const defaultPasswordProps = {
1846
2257
  successAppearance: 'successPrimary sizeM solid rounded'
1847
2258
  };
1848
2259
 
1849
- const FormFieldPassword = /*#__PURE__*/React.memo(function FormFieldPassword(props) {
1850
- const {
1851
- name,
1852
- initialValue,
1853
- classNameGroupItem,
1854
- fieldProps,
1855
- inputProps,
1856
- parse,
1857
- showMessage,
1858
- isDisabled,
1859
- isRequired,
1860
- onChange
1861
- } = props;
2260
+ var FormFieldPassword = /*#__PURE__*/React.memo(function FormFieldPassword(props) {
2261
+ var name = props.name,
2262
+ initialValue = props.initialValue,
2263
+ classNameGroupItem = props.classNameGroupItem,
2264
+ fieldProps = props.fieldProps,
2265
+ inputProps = props.inputProps,
2266
+ parse = props.parse,
2267
+ showMessage = props.showMessage,
2268
+ isDisabled = props.isDisabled,
2269
+ isRequired = props.isRequired,
2270
+ onChange = props.onChange;
1862
2271
  return /*#__PURE__*/React.createElement(Field, {
1863
2272
  name: name,
1864
2273
  initialValue: initialValue,
1865
2274
  parse: parse
1866
- }, function Render({
1867
- input,
1868
- meta
1869
- }) {
2275
+ }, function Render(_ref) {
2276
+ var input = _ref.input,
2277
+ meta = _ref.meta;
1870
2278
  /** Note:
1871
2279
  * Create "Render" function by "eslint-react-hooks/rules-of-hooks":
1872
2280
  * React Hooks cannot be called inside a callback.
@@ -1874,24 +2282,23 @@ const FormFieldPassword = /*#__PURE__*/React.memo(function FormFieldPassword(pro
1874
2282
  * custom React Hook function.
1875
2283
  */
1876
2284
 
1877
- const onChangeField = useCallback(event => {
2285
+ var onChangeField = useCallback(function (event) {
1878
2286
  input.onChange(event);
1879
2287
  if (onChange) {
1880
2288
  onChange(event.target.value, input.name);
1881
2289
  }
1882
2290
  }, [onChange, input.onChange]);
1883
- const {
1884
- errorKey,
1885
- errorMessage,
1886
- successKey,
1887
- isErrorState,
1888
- isValidState
1889
- } = useFieldValidationState({
1890
- fieldProps: fieldProps,
1891
- input: input,
1892
- meta: meta
1893
- });
1894
- const updatedInputProps = useValidationAppearanceInputProps({
2291
+ var _useFieldValidationSt = useFieldValidationState({
2292
+ fieldProps: fieldProps,
2293
+ input: input,
2294
+ meta: meta
2295
+ }),
2296
+ errorKey = _useFieldValidationSt.errorKey,
2297
+ errorMessage = _useFieldValidationSt.errorMessage,
2298
+ successKey = _useFieldValidationSt.successKey,
2299
+ isErrorState = _useFieldValidationSt.isErrorState,
2300
+ isValidState = _useFieldValidationSt.isValidState;
2301
+ var updatedInputProps = useValidationAppearanceInputProps({
1895
2302
  inputProps: inputProps,
1896
2303
  validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
1897
2304
  });
@@ -1910,8 +2317,8 @@ const FormFieldPassword = /*#__PURE__*/React.memo(function FormFieldPassword(pro
1910
2317
  isRequired: isRequired,
1911
2318
  isValidState: isValidState
1912
2319
  }, fieldProps), /*#__PURE__*/React.createElement(InputPassword, Object.assign({
1913
- className: clsx(meta.active && 'input-password_state_focus', meta.error && meta.touched && `input-password_state_${errorKey}`),
1914
- dataTestId: `${input.name}-field-input-password`,
2320
+ className: clsx(meta.active && 'input-password_state_focus', meta.error && meta.touched && "input-password_state_" + errorKey),
2321
+ dataTestId: input.name + "-field-input-password",
1915
2322
  name: input.name,
1916
2323
  autoComplete: "nope",
1917
2324
  value: input.value || '',
@@ -1923,20 +2330,18 @@ const FormFieldPassword = /*#__PURE__*/React.memo(function FormFieldPassword(pro
1923
2330
  });
1924
2331
  });
1925
2332
 
1926
- const defaultRadioProps = {
2333
+ var defaultRadioProps = {
1927
2334
  appearance: 'defaultPrimary sizeM solid circular'
1928
2335
  };
1929
2336
 
1930
2337
  function FormFieldRadioGroupList(props) {
1931
- const {
1932
- input,
1933
- inputProps,
1934
- options,
1935
- onChange
1936
- } = props;
2338
+ var input = props.input,
2339
+ inputProps = props.inputProps,
2340
+ options = props.options,
2341
+ onChange = props.onChange;
1937
2342
 
1938
2343
  // Callback for value changes
1939
- const onChangeSomeInput = useCallback(value => {
2344
+ var onChangeSomeInput = useCallback(function (value) {
1940
2345
  // Save to form values
1941
2346
  input.onChange(value);
1942
2347
  if (onChange) {
@@ -1946,44 +2351,47 @@ function FormFieldRadioGroupList(props) {
1946
2351
  }, [input, onChange]);
1947
2352
 
1948
2353
  // Handle for radio inputs
1949
- const onChangeRadio = useCallback(event => {
2354
+ var onChangeRadio = useCallback(function (event) {
1950
2355
  if (event.target.checked) {
1951
2356
  onChangeSomeInput(event.target.value);
1952
2357
  }
1953
2358
  }, [onChange]);
1954
- return /*#__PURE__*/React.createElement(React.Fragment, null, options.map(option => /*#__PURE__*/React.createElement(Radio, Object.assign({
1955
- className: "form-radio__item",
1956
- key: option.value,
1957
- type: "radio",
1958
- name: input.name,
1959
- label: option.label,
1960
- checked: option.value === input.value,
1961
- value: option.value,
1962
- onBlur: input.onBlur,
1963
- onChange: onChangeRadio,
1964
- onFocus: input.onFocus
1965
- }, inputProps))));
2359
+ return /*#__PURE__*/React.createElement(React.Fragment, null, options.map(function (option) {
2360
+ return /*#__PURE__*/React.createElement(Radio, Object.assign({
2361
+ className: "form-radio__item",
2362
+ key: option.value,
2363
+ type: "radio",
2364
+ name: input.name,
2365
+ label: option.label,
2366
+ checked: option.value === input.value,
2367
+ value: option.value,
2368
+ onBlur: input.onBlur,
2369
+ onChange: onChangeRadio,
2370
+ onFocus: input.onFocus
2371
+ }, inputProps));
2372
+ }));
1966
2373
  }
1967
2374
 
1968
- const FormFieldRadioGroup = /*#__PURE__*/React.memo(function FormFieldRadioGroup(props) {
1969
- const {
1970
- name,
1971
- isDisabled,
1972
- editableProps = {},
1973
- fieldProps = {},
1974
- inputProps = {},
1975
- options = [],
1976
- classNameGroupItem,
1977
- showMessage,
1978
- isRequired,
1979
- onChange
1980
- } = props;
2375
+ var FormFieldRadioGroup = /*#__PURE__*/React.memo(function FormFieldRadioGroup(props) {
2376
+ var name = props.name,
2377
+ isDisabled = props.isDisabled,
2378
+ _props$editableProps = props.editableProps,
2379
+ editableProps = _props$editableProps === void 0 ? {} : _props$editableProps,
2380
+ _props$fieldProps = props.fieldProps,
2381
+ fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
2382
+ _props$inputProps = props.inputProps,
2383
+ inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
2384
+ _props$options = props.options,
2385
+ options = _props$options === void 0 ? [] : _props$options,
2386
+ classNameGroupItem = props.classNameGroupItem,
2387
+ showMessage = props.showMessage,
2388
+ isRequired = props.isRequired,
2389
+ onChange = props.onChange;
1981
2390
  return /*#__PURE__*/React.createElement(Field, {
1982
2391
  name: name
1983
- }, function Render({
1984
- input,
1985
- meta
1986
- }) {
2392
+ }, function Render(_ref) {
2393
+ var input = _ref.input,
2394
+ meta = _ref.meta;
1987
2395
  /** Note:
1988
2396
  * Create "Render" function by "eslint-react-hooks/rules-of-hooks":
1989
2397
  * React Hooks cannot be called inside a callback.
@@ -1991,17 +2399,16 @@ const FormFieldRadioGroup = /*#__PURE__*/React.memo(function FormFieldRadioGroup
1991
2399
  * custom React Hook function.
1992
2400
  */
1993
2401
 
1994
- const {
1995
- errorKey,
1996
- errorMessage,
1997
- isErrorState,
1998
- isValidState
1999
- } = useFieldValidationState({
2000
- fieldProps: fieldProps,
2001
- input: input,
2002
- meta: meta
2003
- });
2004
- const updatedInputProps = useValidationAppearanceInputProps({
2402
+ var _useFieldValidationSt = useFieldValidationState({
2403
+ fieldProps: fieldProps,
2404
+ input: input,
2405
+ meta: meta
2406
+ }),
2407
+ errorKey = _useFieldValidationSt.errorKey,
2408
+ errorMessage = _useFieldValidationSt.errorMessage,
2409
+ isErrorState = _useFieldValidationSt.isErrorState,
2410
+ isValidState = _useFieldValidationSt.isValidState;
2411
+ var updatedInputProps = useValidationAppearanceInputProps({
2005
2412
  inputProps: inputProps,
2006
2413
  validationStateKey: isErrorState ? errorKey : 'success'
2007
2414
  });
@@ -2030,7 +2437,7 @@ const FormFieldRadioGroup = /*#__PURE__*/React.memo(function FormFieldRadioGroup
2030
2437
  });
2031
2438
  });
2032
2439
 
2033
- const defaultSegmentedProps = {
2440
+ var defaultSegmentedProps = {
2034
2441
  appearance: 'defaultPrimary sizeM solid rounded',
2035
2442
  width: 'fill',
2036
2443
  // useValidationAppearanceInputProps
@@ -2041,27 +2448,23 @@ const defaultSegmentedProps = {
2041
2448
  };
2042
2449
 
2043
2450
  function FormFieldSegmented(props) {
2044
- const {
2045
- name,
2046
- isDisabled,
2047
- fieldProps,
2048
- inputProps,
2049
- options,
2050
- showMessage,
2051
- isRequired
2052
- } = props;
2053
- const {
2054
- change
2055
- } = useForm();
2056
- const setActiveSegment = useCallback(option => {
2451
+ var name = props.name,
2452
+ isDisabled = props.isDisabled,
2453
+ fieldProps = props.fieldProps,
2454
+ inputProps = props.inputProps,
2455
+ options = props.options,
2456
+ showMessage = props.showMessage,
2457
+ isRequired = props.isRequired;
2458
+ var _useForm = useForm(),
2459
+ change = _useForm.change;
2460
+ var setActiveSegment = useCallback(function (option) {
2057
2461
  change(name, option.value);
2058
2462
  }, [change]);
2059
2463
  return /*#__PURE__*/React.createElement(Field, {
2060
2464
  name: name
2061
- }, function Render({
2062
- input,
2063
- meta
2064
- }) {
2465
+ }, function Render(_ref) {
2466
+ var input = _ref.input,
2467
+ meta = _ref.meta;
2065
2468
  /** Note:
2066
2469
  * Create "Render" function by "eslint-react-hooks/rules-of-hooks":
2067
2470
  * React Hooks cannot be called inside a callback.
@@ -2069,29 +2472,30 @@ function FormFieldSegmented(props) {
2069
2472
  * custom React Hook function.
2070
2473
  */
2071
2474
 
2072
- const activeOption = useMemo(() => {
2073
- const emptyOption = {
2475
+ var activeOption = useMemo(function () {
2476
+ var emptyOption = {
2074
2477
  label: null,
2075
2478
  value: null
2076
2479
  };
2077
2480
  if (input.value) {
2078
- const currentOption = options.find(option => option.value === input.value);
2481
+ var currentOption = options.find(function (option) {
2482
+ return option.value === input.value;
2483
+ });
2079
2484
  return currentOption || emptyOption;
2080
2485
  }
2081
2486
  return emptyOption;
2082
2487
  }, [input.value]);
2083
- const {
2084
- errorKey,
2085
- errorMessage,
2086
- isErrorState,
2087
- successKey,
2088
- isValidState
2089
- } = useFieldValidationState({
2090
- fieldProps: fieldProps,
2091
- input: input,
2092
- meta: meta
2093
- });
2094
- const updatedInputProps = useValidationAppearanceInputProps({
2488
+ var _useFieldValidationSt = useFieldValidationState({
2489
+ fieldProps: fieldProps,
2490
+ input: input,
2491
+ meta: meta
2492
+ }),
2493
+ errorKey = _useFieldValidationSt.errorKey,
2494
+ errorMessage = _useFieldValidationSt.errorMessage,
2495
+ isErrorState = _useFieldValidationSt.isErrorState,
2496
+ successKey = _useFieldValidationSt.successKey,
2497
+ isValidState = _useFieldValidationSt.isValidState;
2498
+ var updatedInputProps = useValidationAppearanceInputProps({
2095
2499
  inputProps: inputProps,
2096
2500
  validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
2097
2501
  });
@@ -2118,7 +2522,7 @@ function FormFieldSegmented(props) {
2118
2522
  });
2119
2523
  }
2120
2524
 
2121
- const defaultSelectProps = {
2525
+ var defaultSelectProps = {
2122
2526
  appearance: 'defaultPrimary sizeM solid rounded',
2123
2527
  // useValidationAppearanceInputProps
2124
2528
  // Error
@@ -2130,12 +2534,12 @@ const defaultSelectProps = {
2130
2534
  };
2131
2535
 
2132
2536
  function getDefaultValue(options, selectValue) {
2133
- const selectValues = Array.isArray(selectValue) ? selectValue : [selectValue];
2134
- let result = [];
2135
- options.forEach(item => {
2136
- const isValue = selectValues.includes(item.value);
2137
- const isLabel = selectValues.includes(item.label);
2138
- let childOptions = [];
2537
+ var selectValues = Array.isArray(selectValue) ? selectValue : [selectValue];
2538
+ var result = [];
2539
+ options.forEach(function (item) {
2540
+ var isValue = selectValues.includes(item.value);
2541
+ var isLabel = selectValues.includes(item.label);
2542
+ var childOptions = [];
2139
2543
  if (item.options) {
2140
2544
  childOptions = getDefaultValue(item.options, selectValue);
2141
2545
  }
@@ -2147,38 +2551,39 @@ function getDefaultValue(options, selectValue) {
2147
2551
  });
2148
2552
  return result;
2149
2553
  }
2150
- const FormFieldSelect = /*#__PURE__*/React.memo(function FormFieldSelect(props) {
2151
- const {
2152
- isDisabled,
2153
- isRequired,
2154
- classNameGroupItem,
2155
- fieldProps,
2156
- initialValue,
2157
- name,
2158
- options = [],
2159
- selectProps,
2160
- selectRef,
2161
- showMessage,
2162
- onChange,
2163
- onInputChange
2164
- } = props;
2554
+ var FormFieldSelect = /*#__PURE__*/React.memo(function FormFieldSelect(props) {
2555
+ var isDisabled = props.isDisabled,
2556
+ isRequired = props.isRequired,
2557
+ classNameGroupItem = props.classNameGroupItem,
2558
+ fieldProps = props.fieldProps,
2559
+ initialValue = props.initialValue,
2560
+ name = props.name,
2561
+ _props$options = props.options,
2562
+ options = _props$options === void 0 ? [] : _props$options,
2563
+ selectProps = props.selectProps,
2564
+ selectRef = props.selectRef,
2565
+ showMessage = props.showMessage,
2566
+ onChange = props.onChange,
2567
+ onInputChange = props.onInputChange;
2165
2568
  return /*#__PURE__*/React.createElement(Field, {
2166
2569
  name: name,
2167
2570
  initialValue: initialValue
2168
- }, function Render({
2169
- input,
2170
- meta
2171
- }) {
2571
+ }, function Render(_ref) {
2572
+ var input = _ref.input,
2573
+ meta = _ref.meta;
2172
2574
  /** Note:
2173
2575
  * Create "Render" function by "eslint-react-hooks/rules-of-hooks":
2174
2576
  * React Hooks cannot be called inside a callback.
2175
2577
  * React Hooks must be called in a React function component or a
2176
2578
  * custom React Hook function.
2177
2579
  */
2178
- const [selectedOptions, setSelectedOptions] = useState(null);
2179
- const defaultValue = useMemo(() => {
2180
- const optionsValues = getDefaultValue(options, input.value);
2181
- if (!optionsValues.length && input.value?.length) {
2580
+ var _useState = useState(null),
2581
+ selectedOptions = _useState[0],
2582
+ setSelectedOptions = _useState[1];
2583
+ var defaultValue = useMemo(function () {
2584
+ var _input$value;
2585
+ var optionsValues = getDefaultValue(options, input.value);
2586
+ if (!optionsValues.length && (_input$value = input.value) != null && _input$value.length) {
2182
2587
  optionsValues.push({
2183
2588
  label: input.value,
2184
2589
  value: input.value
@@ -2186,32 +2591,33 @@ const FormFieldSelect = /*#__PURE__*/React.memo(function FormFieldSelect(props)
2186
2591
  }
2187
2592
  return optionsValues;
2188
2593
  }, [input.value]);
2189
- const onChangeField = useCallback(value => {
2594
+ var onChangeField = useCallback(function (value) {
2190
2595
  input.onChange(value);
2191
2596
  if (onChange) {
2192
2597
  onChange(value, input.name);
2193
2598
  }
2194
2599
  }, [onChange, input.onChange]);
2195
- const onChangeValue = useCallback((option, actionMeta) => {
2196
- const value = Array.isArray(option) ? option.map(o => o.value) : option?.value || null;
2600
+ var onChangeValue = useCallback(function (option, actionMeta) {
2601
+ var value = Array.isArray(option) ? option.map(function (o) {
2602
+ return o.value;
2603
+ }) : (option == null ? void 0 : option.value) || null;
2197
2604
  setSelectedOptions(option);
2198
2605
  onChangeField(value);
2199
2606
  }, [onChangeField]);
2200
- useEffect(() => {
2607
+ useEffect(function () {
2201
2608
  setSelectedOptions(defaultValue);
2202
2609
  }, [defaultValue]);
2203
- const {
2204
- errorKey,
2205
- errorMessage,
2206
- isErrorState,
2207
- successKey,
2208
- isValidState
2209
- } = useFieldValidationState({
2210
- fieldProps: fieldProps,
2211
- input: input,
2212
- meta: meta
2213
- });
2214
- const updatedSelectProps = useValidationAppearanceInputProps({
2610
+ var _useFieldValidationSt = useFieldValidationState({
2611
+ fieldProps: fieldProps,
2612
+ input: input,
2613
+ meta: meta
2614
+ }),
2615
+ errorKey = _useFieldValidationSt.errorKey,
2616
+ errorMessage = _useFieldValidationSt.errorMessage,
2617
+ isErrorState = _useFieldValidationSt.isErrorState,
2618
+ successKey = _useFieldValidationSt.successKey,
2619
+ isValidState = _useFieldValidationSt.isValidState;
2620
+ var updatedSelectProps = useValidationAppearanceInputProps({
2215
2621
  inputProps: selectProps,
2216
2622
  validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
2217
2623
  });
@@ -2233,7 +2639,7 @@ const FormFieldSelect = /*#__PURE__*/React.memo(function FormFieldSelect(props)
2233
2639
  className: "form-select-item",
2234
2640
  ref: selectRef,
2235
2641
  isDisabled: isDisabled,
2236
- instanceId: `id_${input.name}`,
2642
+ instanceId: "id_" + input.name,
2237
2643
  options: options,
2238
2644
  value: selectedOptions,
2239
2645
  onChange: onChangeValue,
@@ -2242,31 +2648,30 @@ const FormFieldSelect = /*#__PURE__*/React.memo(function FormFieldSelect(props)
2242
2648
  });
2243
2649
  });
2244
2650
 
2245
- const defaultSwitchProps = {
2651
+ var defaultSwitchProps = {
2246
2652
  appearance: 'defaultPrimary sizeL solid rounded',
2247
2653
  errorAppearance: 'errorPrimary sizeL solid rounded',
2248
2654
  successAppearance: 'successPrimary sizeL solid rounded',
2249
2655
  requiredAppearance: 'requirePrimary sizeL solid rounded'
2250
2656
  };
2251
2657
 
2252
- const FormFieldSwitch = /*#__PURE__*/React.memo(function FormFieldSwitch(props) {
2253
- const {
2254
- name,
2255
- isDisabled,
2256
- classNameGroupItem,
2257
- fieldProps = {},
2258
- inputProps = {},
2259
- showMessage,
2260
- isRequired,
2261
- onChange
2262
- } = props;
2658
+ var FormFieldSwitch = /*#__PURE__*/React.memo(function FormFieldSwitch(props) {
2659
+ var name = props.name,
2660
+ isDisabled = props.isDisabled,
2661
+ classNameGroupItem = props.classNameGroupItem,
2662
+ _props$fieldProps = props.fieldProps,
2663
+ fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
2664
+ _props$inputProps = props.inputProps,
2665
+ inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
2666
+ showMessage = props.showMessage,
2667
+ isRequired = props.isRequired,
2668
+ onChange = props.onChange;
2263
2669
  return /*#__PURE__*/React.createElement(Field, {
2264
2670
  type: "checkbox",
2265
2671
  name: name
2266
- }, function Render({
2267
- input,
2268
- meta
2269
- }) {
2672
+ }, function Render(_ref) {
2673
+ var input = _ref.input,
2674
+ meta = _ref.meta;
2270
2675
  /** Note:
2271
2676
  * Create "Render" function by "eslint-react-hooks/rules-of-hooks":
2272
2677
  * React Hooks cannot be called inside a callback.
@@ -2274,24 +2679,23 @@ const FormFieldSwitch = /*#__PURE__*/React.memo(function FormFieldSwitch(props)
2274
2679
  * custom React Hook function.
2275
2680
  */
2276
2681
 
2277
- const onChangeField = useCallback(event => {
2682
+ var onChangeField = useCallback(function (event) {
2278
2683
  input.onChange(event);
2279
2684
  if (onChange) {
2280
2685
  onChange(event.target.checked, input.name);
2281
2686
  }
2282
2687
  }, [onChange, input.onChange]);
2283
- const {
2284
- errorKey,
2285
- errorMessage,
2286
- isErrorState,
2287
- successKey,
2288
- isValidState
2289
- } = useFieldValidationState({
2290
- fieldProps: fieldProps,
2291
- input: input,
2292
- meta: meta
2293
- });
2294
- const updatedInputProps = useValidationAppearanceInputProps({
2688
+ var _useFieldValidationSt = useFieldValidationState({
2689
+ fieldProps: fieldProps,
2690
+ input: input,
2691
+ meta: meta
2692
+ }),
2693
+ errorKey = _useFieldValidationSt.errorKey,
2694
+ errorMessage = _useFieldValidationSt.errorMessage,
2695
+ isErrorState = _useFieldValidationSt.isErrorState,
2696
+ successKey = _useFieldValidationSt.successKey,
2697
+ isValidState = _useFieldValidationSt.isValidState;
2698
+ var updatedInputProps = useValidationAppearanceInputProps({
2295
2699
  inputProps: inputProps,
2296
2700
  validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
2297
2701
  });
@@ -2323,7 +2727,7 @@ const FormFieldSwitch = /*#__PURE__*/React.memo(function FormFieldSwitch(props)
2323
2727
  });
2324
2728
  });
2325
2729
 
2326
- const defaultTextareaProps = {
2730
+ var defaultTextareaProps = {
2327
2731
  appearance: 'defaultPrimary sizeM solid rounded',
2328
2732
  // useValidationAppearanceInputProps
2329
2733
  // Error
@@ -2334,22 +2738,21 @@ const defaultTextareaProps = {
2334
2738
  requiredAppearance: 'requirePrimary sizeM solid rounded'
2335
2739
  };
2336
2740
 
2337
- const FormFieldTextarea = /*#__PURE__*/React.memo(function FormFieldTextarea(props) {
2338
- const {
2339
- name,
2340
- classNameGroupItem,
2341
- fieldProps = {},
2342
- inputProps = {},
2343
- showMessage,
2344
- isDisabled,
2345
- isRequired
2346
- } = props;
2741
+ var FormFieldTextarea = /*#__PURE__*/React.memo(function FormFieldTextarea(props) {
2742
+ var name = props.name,
2743
+ classNameGroupItem = props.classNameGroupItem,
2744
+ _props$fieldProps = props.fieldProps,
2745
+ fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
2746
+ _props$inputProps = props.inputProps,
2747
+ inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
2748
+ showMessage = props.showMessage,
2749
+ isDisabled = props.isDisabled,
2750
+ isRequired = props.isRequired;
2347
2751
  return /*#__PURE__*/React.createElement(Field, {
2348
2752
  name: name
2349
- }, function Render({
2350
- input,
2351
- meta
2352
- }) {
2753
+ }, function Render(_ref) {
2754
+ var input = _ref.input,
2755
+ meta = _ref.meta;
2353
2756
  /** Note:
2354
2757
  * Create "Render" function by "eslint-react-hooks/rules-of-hooks":
2355
2758
  * React Hooks cannot be called inside a callback.
@@ -2357,18 +2760,17 @@ const FormFieldTextarea = /*#__PURE__*/React.memo(function FormFieldTextarea(pro
2357
2760
  * custom React Hook function.
2358
2761
  */
2359
2762
 
2360
- const {
2361
- errorKey,
2362
- errorMessage,
2363
- successKey,
2364
- isErrorState,
2365
- isValidState
2366
- } = useFieldValidationState({
2367
- fieldProps: fieldProps,
2368
- input: input,
2369
- meta: meta
2370
- });
2371
- const updatedInputProps = useValidationAppearanceInputProps({
2763
+ var _useFieldValidationSt = useFieldValidationState({
2764
+ fieldProps: fieldProps,
2765
+ input: input,
2766
+ meta: meta
2767
+ }),
2768
+ errorKey = _useFieldValidationSt.errorKey,
2769
+ errorMessage = _useFieldValidationSt.errorMessage,
2770
+ successKey = _useFieldValidationSt.successKey,
2771
+ isErrorState = _useFieldValidationSt.isErrorState,
2772
+ isValidState = _useFieldValidationSt.isValidState;
2773
+ var updatedInputProps = useValidationAppearanceInputProps({
2372
2774
  inputProps: inputProps,
2373
2775
  validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
2374
2776
  });
@@ -2387,8 +2789,8 @@ const FormFieldTextarea = /*#__PURE__*/React.memo(function FormFieldTextarea(pro
2387
2789
  isRequired: isRequired,
2388
2790
  isValidState: isValidState
2389
2791
  }, fieldProps), /*#__PURE__*/React.createElement(Textarea, Object.assign({
2390
- className: clsx(meta.active && 'textarea_state_focus', meta.error && meta.touched && `textarea_state_${errorKey}`),
2391
- dataTestId: `${input.name}-field-textarea`,
2792
+ className: clsx(meta.active && 'textarea_state_focus', meta.error && meta.touched && "textarea_state_" + errorKey),
2793
+ dataTestId: input.name + "-field-textarea",
2392
2794
  name: input.name,
2393
2795
  autoComplete: "nope",
2394
2796
  value: input.value || '',
@@ -2400,108 +2802,12 @@ const FormFieldTextarea = /*#__PURE__*/React.memo(function FormFieldTextarea(pro
2400
2802
  });
2401
2803
  });
2402
2804
 
2403
- const defaultDadataInputProps = {
2404
- appearance: 'defaultPrimary sizeM solid rounded',
2405
- // useValidationAppearanceInputProps
2406
- // Error
2407
- errorAppearance: 'errorPrimary sizeM solid rounded',
2408
- // Success
2409
- successAppearance: 'successPrimary sizeM solid rounded',
2410
- // Required
2411
- requiredAppearance: 'requirePrimary sizeM solid rounded'
2412
- };
2413
-
2414
- const FormFieldDadataInput = /*#__PURE__*/React.memo(function FormFieldDadataInput(props) {
2415
- const {
2416
- name,
2417
- initialValue,
2418
- isDisabled,
2419
- classNameGroupItem,
2420
- fieldProps,
2421
- inputProps,
2422
- parse,
2423
- showMessage,
2424
- token,
2425
- isRequired,
2426
- onDadataAutocomplete
2427
- } = props;
2428
- if (process.env.NODE_ENV === 'development') {
2429
- const hint = `Check your form config at field "${name}".`;
2430
- if (!token) {
2431
- const message = `FormFieldDadataInput: 'token' prop is missing, instead got ${token}.`;
2432
- throw new Error(message + '\n' + hint);
2433
- }
2434
- if (!onDadataAutocomplete) {
2435
- const message = `FormFieldDadataInput: 'onDadataAutocomplete' prop is missing, instead got ${onDadataAutocomplete}.`;
2436
- throw new Error(message + '\n' + hint);
2437
- }
2438
- }
2439
- return /*#__PURE__*/React.createElement(Field, {
2440
- name: name,
2441
- initialValue: initialValue,
2442
- parse: parse
2443
- }, function Render({
2444
- input,
2445
- meta
2446
- }) {
2447
- /** Note:
2448
- * Create "Render" function by "eslint-react-hooks/rules-of-hooks":
2449
- * React Hooks cannot be called inside a callback.
2450
- * React Hooks must be called in a React function component or a
2451
- * custom React Hook function.
2452
- */
2453
-
2454
- const {
2455
- errorKey,
2456
- errorMessage,
2457
- isErrorState,
2458
- successKey,
2459
- isValidState
2460
- } = useFieldValidationState({
2461
- fieldProps: fieldProps,
2462
- input: input,
2463
- meta: meta
2464
- });
2465
- const updatedInputProps = useValidationAppearanceInputProps({
2466
- inputProps: inputProps,
2467
- validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
2468
- });
2469
- return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
2470
- className: clsx('form-field_input-dadata', 'form__item_input-dadata', classNameGroupItem),
2471
- errorKey: errorKey,
2472
- errorMessage: errorMessage,
2473
- isErrorState: isErrorState,
2474
- metaError: meta.error,
2475
- isDisabled: isDisabled,
2476
- fieldClassName: "form-dadata",
2477
- inputName: input.name,
2478
- inputValue: input.value || '',
2479
- metaActive: meta.active,
2480
- showMessage: showMessage,
2481
- isRequired: isRequired,
2482
- isValidState: isValidState
2483
- }, fieldProps), /*#__PURE__*/React.createElement(Dadata
2484
- // dataTestId={`${input.name}FieldInputDadata`}
2485
- // className={clsx(
2486
- // meta.active && 'input-dadata_state_focus',
2487
- // meta.error && meta.touched && `input-dadata_state_${errorKey}`,
2488
- // )}
2489
- , {
2490
- input: input,
2491
- inputProps: updatedInputProps,
2492
- meta: meta,
2493
- setValue: onDadataAutocomplete,
2494
- token: token
2495
- }));
2496
- });
2497
- });
2498
-
2499
- const formTypes = {
2805
+ var formTypes = {
2806
+ custom: 'custom',
2500
2807
  password: 'password',
2501
2808
  code: 'code',
2502
2809
  text: 'text',
2503
2810
  textarea: 'textarea',
2504
- custom: 'custom',
2505
2811
  checkbox: 'checkbox',
2506
2812
  chips: 'chips',
2507
2813
  choice: 'choice',
@@ -2510,11 +2816,12 @@ const formTypes = {
2510
2816
  dateRangePicker: 'dateRangePicker',
2511
2817
  fileInput: 'fileInput',
2512
2818
  group: 'group',
2819
+ inputNumber: 'inputNumber',
2513
2820
  maskedInput: 'maskedInput',
2514
2821
  radioGroup: 'radioGroup',
2515
2822
  segmented: 'segmented',
2516
2823
  select: 'select',
2517
- switch: 'switch'
2824
+ "switch": 'switch'
2518
2825
  };
2519
2826
  function generateField(field, config, props) {
2520
2827
  switch (field.type) {
@@ -2548,7 +2855,7 @@ function generateField(field, config, props) {
2548
2855
  key: config.key
2549
2856
  }, field, props));
2550
2857
  }
2551
- case formTypes.switch:
2858
+ case formTypes["switch"]:
2552
2859
  {
2553
2860
  return /*#__PURE__*/React.createElement(FormFieldSwitch, Object.assign({
2554
2861
  key: config.key
@@ -2614,16 +2921,23 @@ function generateField(field, config, props) {
2614
2921
  key: config.key
2615
2922
  }, field, props));
2616
2923
  }
2924
+ case formTypes.inputNumber:
2925
+ {
2926
+ return /*#__PURE__*/React.createElement(FormFieldInputNumber, Object.assign({
2927
+ key: config.key
2928
+ }, field, props));
2929
+ }
2617
2930
  case formTypes.group:
2618
2931
  {
2619
2932
  return /*#__PURE__*/React.createElement(FormBlockGroup, Object.assign({
2620
2933
  key: config.key
2621
- }, field, props), Object.entries(field.group).map(([key, value]) => {
2622
- const groupProps = {
2623
- ...value,
2934
+ }, field, props), Object.entries(field.group).map(function (_ref) {
2935
+ var key = _ref[0],
2936
+ value = _ref[1];
2937
+ var groupProps = Object.assign({}, value, {
2624
2938
  classNameGroupItem: value.classNameGroupItem || 'form__group-item',
2625
2939
  showMessage: field.showMessage
2626
- };
2940
+ });
2627
2941
  return generateField(groupProps, {
2628
2942
  key: key + '_form_group'
2629
2943
  }, props);
@@ -2632,32 +2946,32 @@ function generateField(field, config, props) {
2632
2946
  }
2633
2947
  }
2634
2948
 
2635
- const focusOnError = (formElementsList, errors) => {
2636
- const selectsIds = Object.keys(errors).map(fieldName => {
2949
+ var focusOnError = function focusOnError(formElementsList, errors) {
2950
+ var selectsIds = Object.keys(errors).map(function (fieldName) {
2637
2951
  if (fieldName === FORM_ERROR) {
2638
2952
  // TODO: get from somewhere
2639
2953
  return 'notification__item_status_error';
2640
2954
  }
2641
- return `react-select-id_${fieldName}-input`;
2955
+ return "react-select-id_" + fieldName + "-input";
2642
2956
  });
2643
- const errorFieldElement = formElementsList.find(element => {
2957
+ var errorFieldElement = formElementsList.find(function (element) {
2644
2958
  if (element.name) {
2645
2959
  return getIn(errors, element.name);
2646
2960
  } else {
2647
2961
  return selectsIds.includes(element.id);
2648
2962
  }
2649
2963
  });
2650
- const errorsList = Object.keys(errors);
2964
+ var errorsList = Object.keys(errors);
2651
2965
  if (!errorFieldElement && errorsList.length) {
2652
- let errorElement;
2966
+ var errorElement;
2653
2967
  try {
2654
- const fieldName = errorsList[0];
2968
+ var fieldName = errorsList[0];
2655
2969
  if (fieldName === FORM_ERROR) {
2656
2970
  errorElement = document.querySelector('notification__item_status_error');
2657
2971
  } else {
2658
- errorElement = document.querySelector(`#${fieldName}-error`);
2972
+ errorElement = document.querySelector("#" + fieldName + "-error");
2659
2973
  if (!errorElement) {
2660
- errorElement = document.querySelector(`#id_${fieldName}`);
2974
+ errorElement = document.querySelector("#id_" + fieldName);
2661
2975
  }
2662
2976
  }
2663
2977
  } catch (err) {
@@ -2679,11 +2993,12 @@ const focusOnError = (formElementsList, errors) => {
2679
2993
  }
2680
2994
  return null;
2681
2995
  };
2682
- const focusOnErrorDecorator = createDecorator(null, focusOnError);
2683
- const setErrorsMutator = (args, state) => {
2684
- const [fieldName, data] = args;
2685
- const submitError = data.submitError;
2686
- const fieldError = data.error;
2996
+ var focusOnErrorDecorator = createDecorator(null, focusOnError);
2997
+ var setErrorsMutator = function setErrorsMutator(args, state) {
2998
+ var fieldName = args[0],
2999
+ data = args[1];
3000
+ var submitError = data.submitError;
3001
+ var fieldError = data.error;
2687
3002
  if (fieldName === 'non_field_errors' || fieldName === FORM_ERROR) {
2688
3003
  // state.formState.invalid = true
2689
3004
  // state.formState.valid = false
@@ -2694,18 +3009,16 @@ const setErrorsMutator = (args, state) => {
2694
3009
 
2695
3010
  // TODO: make clear error not by empty string check
2696
3011
  if (fieldError || fieldError === '') {
2697
- const errorsState = Object.assign({}, state.formState.errors, {
2698
- [fieldName]: fieldError
2699
- });
3012
+ var _Object$assign;
3013
+ var errorsState = Object.assign({}, state.formState.errors, (_Object$assign = {}, _Object$assign[fieldName] = fieldError, _Object$assign));
2700
3014
  state.fields[fieldName].error = fieldError;
2701
3015
  state.formState.errors = errorsState;
2702
3016
  }
2703
3017
 
2704
3018
  // TODO: make clear error not by empty string check
2705
3019
  if (submitError || submitError === '') {
2706
- const submitErrorsState = Object.assign({}, state.formState.submitErrors, {
2707
- [fieldName]: submitError
2708
- });
3020
+ var _Object$assign2;
3021
+ var submitErrorsState = Object.assign({}, state.formState.submitErrors, (_Object$assign2 = {}, _Object$assign2[fieldName] = submitError, _Object$assign2));
2709
3022
  state.fields[fieldName].submitFailed = true;
2710
3023
  state.fields[fieldName].submitSucceeded = false;
2711
3024
  state.fields[fieldName].submitError = submitError;
@@ -2716,163 +3029,186 @@ const setErrorsMutator = (args, state) => {
2716
3029
  }
2717
3030
  }
2718
3031
  };
2719
- const sendFormDataToServer = async (url, data) => {
2720
- try {
2721
- const response = await axios({
2722
- url: url,
2723
- method: 'POST',
2724
- data: data
2725
- });
2726
- return {
2727
- success: true,
2728
- response
2729
- };
2730
- } catch (error) {
2731
- const formErrors = {};
2732
- if (typeof error.response?.data === 'string') {
2733
- formErrors[FORM_ERROR] = 'Something went wrong';
2734
- }
2735
- if (typeof error.response?.data === 'object') {
2736
- Object.entries(error.response.data).forEach(([fieldName, errorsList]) => {
2737
- formErrors[fieldName] = errorsList[0];
2738
- });
2739
- }
2740
- return {
2741
- error,
2742
- success: false,
2743
- formErrors
2744
- };
2745
- }
2746
- };
2747
-
2748
- const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2749
- const {
2750
- className,
2751
- dataTestId,
2752
- dataTour,
2753
- type,
2754
- name,
2755
- initialValues,
2756
- initialValuesEqual,
2757
- config,
2758
- validationSchema,
2759
- title,
2760
- titleFill,
2761
- titlePosition,
2762
- titleTextColor,
2763
- titleTextSize,
2764
- titleTextWeight,
2765
- desc,
2766
- descSize,
2767
- descTextColor,
2768
- descTextWeight,
2769
- buttonGap,
2770
- additionalProps = {},
2771
- buttonDirection = 'vertical',
2772
- buttonFill,
2773
- buttonJustifyContent,
2774
- buttonPadding,
2775
- buttonPosition,
2776
- dataTestIdButtons,
2777
- dataTestIdPrimaryButton,
2778
- dataTestIdSecondaryButton,
2779
- dataTestIdTertiaryButton,
2780
- dataTourButtons,
2781
- dataTourPrimaryButton,
2782
- dataTourSecondaryButton,
2783
- dataTourTertiaryButton,
2784
- disableFieldsAutoComplete = false,
2785
- fieldsGap,
2786
- formName,
2787
- groupGap,
2788
- heightClass,
2789
- language,
2790
- loader,
2791
- loaderAppearance,
2792
- loaderFill = 'surfacePrimary',
2793
- loaderItemFill = 'accentItemSecondary',
2794
- loaderShape,
2795
- loaderSize = 'l',
2796
- loaderText,
2797
- loaderType = 'simple',
2798
- mutators,
2799
- notificationCloseButton,
2800
- notificationType,
2801
- primaryButton,
2802
- primaryButtonAppearance,
2803
- primaryButtonFill,
2804
- primaryButtonFillHover,
2805
- primaryButtonHtmlType,
2806
- primaryButtonIsDisabled,
2807
- primaryButtonIsLoading,
2808
- primaryButtonLabel,
2809
- primaryButtonLabelSize,
2810
- primaryButtonLabelTextColor,
2811
- primaryButtonLabelTextWeight,
2812
- primaryButtonSize,
2813
- primarySecondaryHtmlType,
2814
- renderFieldsWrapper = wrapperChildren => wrapperChildren,
2815
- secondaryButton,
2816
- secondaryButtonAppearance,
2817
- secondaryButtonFill,
2818
- secondaryButtonFillHover,
2819
- secondaryButtonIsDisabled,
2820
- secondaryButtonIsLoading,
2821
- secondaryButtonLabel,
2822
- secondaryButtonLabelSize,
2823
- secondaryButtonLabelTextColor,
2824
- secondaryButtonLabelTextWeight,
2825
- secondaryButtonSize,
2826
- shapeStrengthClass,
2827
- tertiaryButton,
2828
- tertiaryButtonFill,
2829
- tertiaryButtonFillHover,
2830
- tertiaryButtonLabel,
2831
- tertiaryButtonLabelSize,
2832
- tertiaryButtonLabelTextColor,
2833
- tertiaryButtonLabelTextWeight,
2834
- tertiaryButtonSize,
2835
- widthClass,
2836
- before,
2837
- after,
2838
- isLoading,
2839
- onClickSecondaryButton,
2840
- onClickTertiaryButton,
2841
- onChangeFormValues,
2842
- onSubmit
2843
- } = props;
2844
- const validate = useYupValidationSchema(validationSchema, language);
2845
- const onRefFormInstance = useCallback(formInstance => {
3032
+ var sendFormDataToServer = /*#__PURE__*/function () {
3033
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(url, data) {
3034
+ var response, _error$response, _error$response2, formErrors, _t;
3035
+ return _regenerator().w(function (_context) {
3036
+ while (1) switch (_context.p = _context.n) {
3037
+ case 0:
3038
+ _context.p = 0;
3039
+ _context.n = 1;
3040
+ return axios({
3041
+ url: url,
3042
+ method: 'POST',
3043
+ data: data
3044
+ });
3045
+ case 1:
3046
+ response = _context.v;
3047
+ return _context.a(2, {
3048
+ success: true,
3049
+ response: response
3050
+ });
3051
+ case 2:
3052
+ _context.p = 2;
3053
+ _t = _context.v;
3054
+ formErrors = {};
3055
+ if (typeof ((_error$response = _t.response) == null ? void 0 : _error$response.data) === 'string') {
3056
+ formErrors[FORM_ERROR] = 'Something went wrong';
3057
+ }
3058
+ if (typeof ((_error$response2 = _t.response) == null ? void 0 : _error$response2.data) === 'object') {
3059
+ Object.entries(_t.response.data).forEach(function (_ref2) {
3060
+ var fieldName = _ref2[0],
3061
+ errorsList = _ref2[1];
3062
+ formErrors[fieldName] = errorsList[0];
3063
+ });
3064
+ }
3065
+ return _context.a(2, {
3066
+ error: _t,
3067
+ success: false,
3068
+ formErrors: formErrors
3069
+ });
3070
+ }
3071
+ }, _callee, null, [[0, 2]]);
3072
+ }));
3073
+ return function sendFormDataToServer(_x, _x2) {
3074
+ return _ref.apply(this, arguments);
3075
+ };
3076
+ }();
3077
+
3078
+ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
3079
+ var className = props.className,
3080
+ dataTestId = props.dataTestId,
3081
+ dataTour = props.dataTour,
3082
+ type = props.type,
3083
+ name = props.name,
3084
+ initialValues = props.initialValues,
3085
+ initialValuesEqual = props.initialValuesEqual,
3086
+ config = props.config,
3087
+ validationSchema = props.validationSchema,
3088
+ title = props.title,
3089
+ titleFill = props.titleFill,
3090
+ titlePosition = props.titlePosition,
3091
+ titleTextColor = props.titleTextColor,
3092
+ titleTextSize = props.titleTextSize,
3093
+ titleTextWeight = props.titleTextWeight,
3094
+ desc = props.desc,
3095
+ descSize = props.descSize,
3096
+ descTextColor = props.descTextColor,
3097
+ descTextWeight = props.descTextWeight,
3098
+ buttonGap = props.buttonGap,
3099
+ _props$additionalProp = props.additionalProps,
3100
+ additionalProps = _props$additionalProp === void 0 ? {} : _props$additionalProp,
3101
+ _props$buttonDirectio = props.buttonDirection,
3102
+ buttonDirection = _props$buttonDirectio === void 0 ? 'vertical' : _props$buttonDirectio,
3103
+ buttonFill = props.buttonFill,
3104
+ buttonJustifyContent = props.buttonJustifyContent,
3105
+ buttonPadding = props.buttonPadding,
3106
+ buttonPosition = props.buttonPosition,
3107
+ dataTestIdButtons = props.dataTestIdButtons,
3108
+ dataTestIdPrimaryButton = props.dataTestIdPrimaryButton,
3109
+ dataTestIdSecondaryButton = props.dataTestIdSecondaryButton,
3110
+ dataTestIdTertiaryButton = props.dataTestIdTertiaryButton,
3111
+ dataTourButtons = props.dataTourButtons,
3112
+ dataTourPrimaryButton = props.dataTourPrimaryButton,
3113
+ dataTourSecondaryButton = props.dataTourSecondaryButton,
3114
+ dataTourTertiaryButton = props.dataTourTertiaryButton,
3115
+ _props$disableFieldsA = props.disableFieldsAutoComplete,
3116
+ disableFieldsAutoComplete = _props$disableFieldsA === void 0 ? false : _props$disableFieldsA,
3117
+ fieldsGap = props.fieldsGap,
3118
+ formName = props.formName,
3119
+ groupGap = props.groupGap,
3120
+ heightClass = props.heightClass,
3121
+ language = props.language,
3122
+ loader = props.loader,
3123
+ loaderAppearance = props.loaderAppearance,
3124
+ _props$loaderFill = props.loaderFill,
3125
+ loaderFill = _props$loaderFill === void 0 ? 'surfacePrimary' : _props$loaderFill,
3126
+ _props$loaderItemFill = props.loaderItemFill,
3127
+ loaderItemFill = _props$loaderItemFill === void 0 ? 'accentItemSecondary' : _props$loaderItemFill,
3128
+ loaderShape = props.loaderShape,
3129
+ _props$loaderSize = props.loaderSize,
3130
+ loaderSize = _props$loaderSize === void 0 ? 'l' : _props$loaderSize,
3131
+ loaderText = props.loaderText,
3132
+ _props$loaderType = props.loaderType,
3133
+ loaderType = _props$loaderType === void 0 ? 'simple' : _props$loaderType,
3134
+ mutators = props.mutators,
3135
+ notificationCloseButton = props.notificationCloseButton,
3136
+ notificationType = props.notificationType,
3137
+ primaryButton = props.primaryButton,
3138
+ primaryButtonAppearance = props.primaryButtonAppearance,
3139
+ primaryButtonFill = props.primaryButtonFill,
3140
+ primaryButtonFillHover = props.primaryButtonFillHover,
3141
+ primaryButtonHtmlType = props.primaryButtonHtmlType,
3142
+ primaryButtonIsDisabled = props.primaryButtonIsDisabled,
3143
+ primaryButtonIsLoading = props.primaryButtonIsLoading,
3144
+ primaryButtonLabel = props.primaryButtonLabel,
3145
+ primaryButtonLabelSize = props.primaryButtonLabelSize,
3146
+ primaryButtonLabelTextColor = props.primaryButtonLabelTextColor,
3147
+ primaryButtonLabelTextWeight = props.primaryButtonLabelTextWeight,
3148
+ primaryButtonSize = props.primaryButtonSize,
3149
+ primarySecondaryHtmlType = props.primarySecondaryHtmlType,
3150
+ _props$renderFieldsWr = props.renderFieldsWrapper,
3151
+ renderFieldsWrapper = _props$renderFieldsWr === void 0 ? function (wrapperChildren) {
3152
+ return wrapperChildren;
3153
+ } : _props$renderFieldsWr,
3154
+ secondaryButton = props.secondaryButton,
3155
+ secondaryButtonAppearance = props.secondaryButtonAppearance,
3156
+ secondaryButtonFill = props.secondaryButtonFill,
3157
+ secondaryButtonFillHover = props.secondaryButtonFillHover,
3158
+ secondaryButtonIsDisabled = props.secondaryButtonIsDisabled,
3159
+ secondaryButtonIsLoading = props.secondaryButtonIsLoading,
3160
+ secondaryButtonLabel = props.secondaryButtonLabel,
3161
+ secondaryButtonLabelSize = props.secondaryButtonLabelSize,
3162
+ secondaryButtonLabelTextColor = props.secondaryButtonLabelTextColor,
3163
+ secondaryButtonLabelTextWeight = props.secondaryButtonLabelTextWeight,
3164
+ secondaryButtonSize = props.secondaryButtonSize,
3165
+ shapeStrengthClass = props.shapeStrengthClass,
3166
+ tertiaryButton = props.tertiaryButton,
3167
+ tertiaryButtonFill = props.tertiaryButtonFill,
3168
+ tertiaryButtonFillHover = props.tertiaryButtonFillHover,
3169
+ tertiaryButtonLabel = props.tertiaryButtonLabel,
3170
+ tertiaryButtonLabelSize = props.tertiaryButtonLabelSize,
3171
+ tertiaryButtonLabelTextColor = props.tertiaryButtonLabelTextColor,
3172
+ tertiaryButtonLabelTextWeight = props.tertiaryButtonLabelTextWeight,
3173
+ tertiaryButtonSize = props.tertiaryButtonSize,
3174
+ widthClass = props.widthClass,
3175
+ before = props.before,
3176
+ after = props.after,
3177
+ isLoading = props.isLoading,
3178
+ onClickSecondaryButton = props.onClickSecondaryButton,
3179
+ onClickTertiaryButton = props.onClickTertiaryButton,
3180
+ onChangeFormValues = props.onChangeFormValues,
3181
+ onSubmit = props.onSubmit;
3182
+ var validate = useYupValidationSchema(validationSchema, language);
3183
+ var onRefFormInstance = useCallback(function (formInstance) {
2846
3184
  if (ref) {
2847
3185
  ref.current = formInstance;
2848
3186
  }
2849
3187
  }, [ref]);
2850
- const propsGenerator = useDevicePropsGenerator(props);
2851
- const {
2852
- directionClass,
2853
- fillClass,
2854
- elevationClass,
2855
- shapeClass
2856
- } = propsGenerator;
2857
- const {
2858
- styles: formStyles,
2859
- wrapper: wrapperStyles
2860
- } = useStyles(props);
3188
+ var propsGenerator = useDevicePropsGenerator(props);
3189
+ var directionClass = propsGenerator.directionClass,
3190
+ fillClass = propsGenerator.fillClass,
3191
+ elevationClass = propsGenerator.elevationClass,
3192
+ shapeClass = propsGenerator.shapeClass;
3193
+ var _useStyles = useStyles(props),
3194
+ formStyles = _useStyles.styles,
3195
+ wrapperStyles = _useStyles.wrapper;
2861
3196
  return /*#__PURE__*/React.createElement(Form, {
2862
3197
  initialValues: initialValues,
2863
3198
  initialValuesEqual: initialValuesEqual,
2864
- render: ({
2865
- form,
2866
- handleSubmit,
2867
- modifiedSinceLastSubmit,
2868
- submitError
2869
- }) => {
3199
+ render: function render(_ref) {
3200
+ var form = _ref.form,
3201
+ handleSubmit = _ref.handleSubmit,
3202
+ modifiedSinceLastSubmit = _ref.modifiedSinceLastSubmit,
3203
+ submitError = _ref.submitError;
2870
3204
  return /*#__PURE__*/React.createElement("form", {
2871
- className: clsx(className, 'form', type && `form_type_${type}`, widthClass && `width_${widthClass}`, heightClass && `height_${heightClass}`, titlePosition && `form_title-position_${titlePosition}`, buttonPosition && `form_button-position_${buttonPosition}`, directionClass && `direction_${directionClass}`, fillClass && `fill_${fillClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`, elevationClass && `elevation_${elevationClass}`),
3205
+ className: clsx(className, 'form', type && "form_type_" + type, widthClass && "width_" + widthClass, heightClass && "height_" + heightClass, titlePosition && "form_title-position_" + titlePosition, buttonPosition && "form_button-position_" + buttonPosition, directionClass && "direction_" + directionClass, fillClass && "fill_" + fillClass, shapeClass && "shape_" + shapeClass, shapeStrengthClass && "shape-strength_" + shapeStrengthClass, elevationClass && "elevation_" + elevationClass),
2872
3206
  name: formName || 'form'
2873
3207
  // We no need set reference to html element, we need reference to "final-form" instance
2874
3208
  ,
2875
- ref: () => onRefFormInstance(form),
3209
+ ref: function ref() {
3210
+ return onRefFormInstance(form);
3211
+ },
2876
3212
  autoCapitalize: disableFieldsAutoComplete ? 'off' : undefined,
2877
3213
  autoComplete: disableFieldsAutoComplete ? 'off' : undefined,
2878
3214
  autoCorrect: disableFieldsAutoComplete ? 'off' : undefined,
@@ -2893,7 +3229,7 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2893
3229
  textColor: descTextColor,
2894
3230
  textWeight: descTextWeight
2895
3231
  }, desc), submitError && !modifiedSinceLastSubmit && /*#__PURE__*/React.createElement("div", {
2896
- className: clsx('notification', 'form-notification', notificationType ? `form-notification_${notificationType}` : 'form-notification_global')
3232
+ className: clsx('notification', 'form-notification', notificationType ? "form-notification_" + notificationType : 'form-notification_global')
2897
3233
  }, /*#__PURE__*/React.createElement(Notification, {
2898
3234
  appearance: "errorPrimary sizeM solid rounded",
2899
3235
  type: "global",
@@ -2910,9 +3246,11 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2910
3246
  direction: "vertical",
2911
3247
  gap: fieldsGap || groupGap,
2912
3248
  style: wrapperStyles
2913
- }, Object.keys(config).map(key => generateField(config[key], {
2914
- key
2915
- }, additionalProps[config[key].name])), isLoading && (loader || /*#__PURE__*/React.createElement(Loader, {
3249
+ }, Object.keys(config).map(function (key) {
3250
+ return generateField(config[key], {
3251
+ key: key
3252
+ }, additionalProps[config[key].name]);
3253
+ }), isLoading && (loader || /*#__PURE__*/React.createElement(Loader, {
2916
3254
  appearance: loaderAppearance,
2917
3255
  className: "form__loader",
2918
3256
  type: loaderType,
@@ -2933,7 +3271,7 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2933
3271
  }, primaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
2934
3272
  appearance: primaryButtonAppearance,
2935
3273
  className: "form__button-item",
2936
- dataTestId: dataTestIdPrimaryButton || (name ? `${name}-primary` : 'form-primary'),
3274
+ dataTestId: dataTestIdPrimaryButton || (name ? name + "-primary" : 'form-primary'),
2937
3275
  dataTour: dataTourPrimaryButton,
2938
3276
  width: "fill",
2939
3277
  size: primaryButtonSize,
@@ -2949,7 +3287,7 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2949
3287
  }) : primaryButton, secondaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
2950
3288
  appearance: secondaryButtonAppearance,
2951
3289
  className: "form__button-item",
2952
- dataTestId: dataTestIdSecondaryButton || (name ? `${name}-secondary` : 'form-secondary'),
3290
+ dataTestId: dataTestIdSecondaryButton || (name ? name + "-secondary" : 'form-secondary'),
2953
3291
  dataTour: dataTourSecondaryButton,
2954
3292
  width: "fill",
2955
3293
  size: secondaryButtonSize,
@@ -2994,31 +3332,31 @@ FinalForm.defaultProps = {
2994
3332
  direction: 'vertical'
2995
3333
  };
2996
3334
 
2997
- const DEFAULT_MESSAGES_REQUIRED = {
3335
+ var DEFAULT_MESSAGES_REQUIRED = {
2998
3336
  required: {
2999
3337
  key: 'required',
3000
3338
  message: 'Обязательное поле'
3001
3339
  }
3002
3340
  };
3003
- const DEFAULT_MESSAGES_ERROR = {
3341
+ var DEFAULT_MESSAGES_ERROR = {
3004
3342
  invalid_value: {
3005
3343
  key: 'error',
3006
3344
  message: 'Некорректное значение'
3007
3345
  }
3008
3346
  };
3009
- const DEFAULT_MESSAGES_URL = {
3347
+ var DEFAULT_MESSAGES_URL = {
3010
3348
  url: {
3011
3349
  key: 'error',
3012
3350
  message: 'Введите корректный URL-адрес'
3013
3351
  }
3014
3352
  };
3015
- const DEFAULT_MESSAGES_PASSWORD = {
3353
+ var DEFAULT_MESSAGES_PASSWORD = {
3016
3354
  password_required: {
3017
3355
  key: 'required',
3018
3356
  message: 'Введите пароль'
3019
3357
  }
3020
3358
  };
3021
- const DEFAULT_MESSAGES_NUMBER = {
3359
+ var DEFAULT_MESSAGES_NUMBER = {
3022
3360
  matches: {
3023
3361
  key: 'error',
3024
3362
  message: 'Допускается ввод только цифр от 0 до 9'
@@ -3028,21 +3366,23 @@ const DEFAULT_MESSAGES_NUMBER = {
3028
3366
  message: 'Только числовое значение'
3029
3367
  }
3030
3368
  };
3031
- const DEFAULT_MESSAGES_MIN_MAX = {
3369
+ var DEFAULT_MESSAGES_MIN_MAX = {
3032
3370
  min: {
3033
3371
  key: 'error',
3034
- message: ({
3035
- min
3036
- }) => `Значение должно быть не менее ${min} символов`
3372
+ message: function message(_ref) {
3373
+ var min = _ref.min;
3374
+ return "\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u043C\u0435\u043D\u0435\u0435 " + min + " \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432";
3375
+ }
3037
3376
  },
3038
3377
  max: {
3039
3378
  key: 'error',
3040
- message: ({
3041
- max
3042
- }) => `Значение должно быть не менее ${max} символов`
3379
+ message: function message(_ref2) {
3380
+ var max = _ref2.max;
3381
+ return "\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u043C\u0435\u043D\u0435\u0435 " + max + " \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432";
3382
+ }
3043
3383
  }
3044
3384
  };
3045
- const DEFAULT_MESSAGES_PHONE = {
3385
+ var DEFAULT_MESSAGES_PHONE = {
3046
3386
  phone_error: {
3047
3387
  key: 'error',
3048
3388
  message: 'Введите корректный номер телефона'
@@ -3056,7 +3396,7 @@ const DEFAULT_MESSAGES_PHONE = {
3056
3396
  message: 'Укажите номер телефона'
3057
3397
  }
3058
3398
  };
3059
- const DEFAULT_MESSAGES_EMAIL = {
3399
+ var DEFAULT_MESSAGES_EMAIL = {
3060
3400
  email_error: {
3061
3401
  key: 'error',
3062
3402
  message: 'Введите корректный адрес электронной почты'
@@ -3131,20 +3471,11 @@ const DEFAULT_MESSAGES_EMAIL = {
3131
3471
  ... etc
3132
3472
  */
3133
3473
 
3134
- const DEFAULT_MESSAGES_FIELDS = {
3135
- ...DEFAULT_MESSAGES_EMAIL,
3136
- ...DEFAULT_MESSAGES_ERROR,
3137
- ...DEFAULT_MESSAGES_MIN_MAX,
3138
- ...DEFAULT_MESSAGES_NUMBER,
3139
- ...DEFAULT_MESSAGES_PASSWORD,
3140
- ...DEFAULT_MESSAGES_PHONE,
3141
- ...DEFAULT_MESSAGES_REQUIRED,
3142
- ...DEFAULT_MESSAGES_URL
3143
- };
3474
+ var DEFAULT_MESSAGES_FIELDS = Object.assign({}, DEFAULT_MESSAGES_EMAIL, DEFAULT_MESSAGES_ERROR, DEFAULT_MESSAGES_MIN_MAX, DEFAULT_MESSAGES_NUMBER, DEFAULT_MESSAGES_PASSWORD, DEFAULT_MESSAGES_PHONE, DEFAULT_MESSAGES_REQUIRED, DEFAULT_MESSAGES_URL);
3144
3475
 
3145
- const parseNumericField = value => {
3146
- const numberValue = value.slice(0, 10).replace(/,/g, '.').replace(/[^\d.]/g, '');
3147
- const parsedValue = parseFloat(numberValue);
3476
+ var parseNumericField = function parseNumericField(value) {
3477
+ var numberValue = value.slice(0, 10).replace(/,/g, '.').replace(/[^\d.]/g, '');
3478
+ var parsedValue = parseFloat(numberValue);
3148
3479
  if (parsedValue || parsedValue === 0) {
3149
3480
  if (numberValue.endsWith('.')) {
3150
3481
  if ((numberValue.match(/\./g) || []).length > 1) {
@@ -3208,22 +3539,23 @@ const parseNumericField = value => {
3208
3539
  // return formErrors
3209
3540
  // }
3210
3541
 
3211
- const getErrorsForFinalForm = error => {
3542
+ var getErrorsForFinalForm = function getErrorsForFinalForm(error) {
3543
+ var _error$response;
3212
3544
  /*
3213
3545
  * error - its an "axios" error in many cases
3214
3546
  */
3215
3547
 
3216
- const formErrors = {};
3217
- const serverErrors = error.response?.data || error;
3548
+ var formErrors = {};
3549
+ var serverErrors = ((_error$response = error.response) == null ? void 0 : _error$response.data) || error;
3218
3550
  if (serverErrors) {
3219
3551
  // Collect errors for some fields, which in the response from server
3220
3552
  if (typeof serverErrors === 'string') {
3221
3553
  // Server may send an html page as error data
3222
3554
  formErrors[FORM_ERROR] = 'Во время обработки запроса произошла ошибка, попробуйте повторить запрос';
3223
3555
  } else {
3224
- for (const key in serverErrors) {
3556
+ for (var key in serverErrors) {
3225
3557
  // "non_field_errors" and "detail" is special keys in django to mark errors not for fields
3226
- const errorFieldKey = key === 'non_field_errors' || key === 'detail' ? FORM_ERROR : key;
3558
+ var errorFieldKey = key === 'non_field_errors' || key === 'detail' ? FORM_ERROR : key;
3227
3559
 
3228
3560
  // Say to "react-final-form" that we have some fields errors
3229
3561
  formErrors[errorFieldKey] = castArray(serverErrors[key])[0];
@@ -3240,4 +3572,4 @@ const getErrorsForFinalForm = error => {
3240
3572
  return formErrors;
3241
3573
  };
3242
3574
 
3243
- export { DEFAULT_MESSAGES_FIELDS, FieldWrapper, FieldWrapperBase, FinalForm, FormBlockGroup, FormFieldCheckbox, FormFieldChips, FormFieldChoice, FormFieldCode, FormFieldCustom, FormFieldDadataInput, FormFieldDatePicker, FormFieldFileInput, FormFieldInput, FormFieldMaskedInput, FormFieldPassword, FormFieldRadioGroup, FormFieldSegmented, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, addRequiredFieldsParamToSchema, dateValidation, defaultCheckboxProps, defaultChipsProps, defaultChoiceProps, defaultCodeProps, defaultDadataInputProps, defaultDatepickerProps, defaultDropzoneProps, defaultFieldProps, defaultFieldSizeL, defaultFieldSizeM, defaultFieldSizeS, defaultFieldSizeXL, defaultGroupProps, defaultInputProps, defaultPasswordProps, defaultRadioProps, defaultSegmentedProps, defaultSelectProps, defaultSwitchProps, defaultTextareaProps, emailValidation, focusOnError, focusOnErrorDecorator, formTypes, generateField, getErrorsForFinalForm, parseNumericField, phoneValidation, sendFormDataToServer, setErrorsMutator, useYupValidationSchema };
3575
+ export { DEFAULT_MESSAGES_FIELDS, FieldWrapper, FieldWrapperBase, FinalForm, FormBlockGroup, FormFieldCheckbox, FormFieldChips, FormFieldChoice, FormFieldCode, FormFieldCustom, FormFieldDadataInput, FormFieldDatePicker, FormFieldFileInput, FormFieldInput, FormFieldInputNumber, FormFieldMaskedInput, FormFieldPassword, FormFieldRadioGroup, FormFieldSegmented, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, addRequiredFieldsParamToSchema, dateValidation, defaultCheckboxProps, defaultChipsProps, defaultChoiceProps, defaultCodeProps, defaultDadataInputProps, defaultDatepickerProps, defaultDropzoneProps, defaultFieldProps, defaultFieldSizeL, defaultFieldSizeM, defaultFieldSizeS, defaultFieldSizeXL, defaultGroupProps, defaultInputNumberProps, defaultInputProps, defaultPasswordProps, defaultRadioProps, defaultSegmentedProps, defaultSelectProps, defaultSwitchProps, defaultTextareaProps, emailValidation, focusOnError, focusOnErrorDecorator, formTypes, generateField, getErrorsForFinalForm, parseNumericField, phoneValidation, sendFormDataToServer, setErrorsMutator, useYupValidationSchema };