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