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