@itcase/forms 1.1.53 → 1.1.55

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