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