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