@itcase/forms 1.0.59 → 1.0.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/form/Field/Choice/Choice.css +1 -1
- package/dist/css/form/Field/DatePicker/DatePicker.css +4 -4
- package/dist/css/form/Field/Segmented/Segmented.css +1 -1
- package/dist/css/form/FormField/FormField.css +12 -4
- package/dist/itcase-forms.cjs.js +982 -401
- package/dist/itcase-forms.esm.js +977 -402
- package/package.json +45 -39
package/dist/itcase-forms.cjs.js
CHANGED
|
@@ -11,6 +11,8 @@ var Divider = require('@itcase/ui/components/Divider');
|
|
|
11
11
|
var Text = require('@itcase/ui/components/Text');
|
|
12
12
|
var useDeviceTargetClass = require('@itcase/ui/hooks/useDeviceTargetClass');
|
|
13
13
|
var useStyles = require('@itcase/ui/hooks/useStyles');
|
|
14
|
+
var camelCase = require('lodash/camelCase');
|
|
15
|
+
var snakeCase = require('lodash/snakeCase');
|
|
14
16
|
var Choice = require('@itcase/ui/components/Choice');
|
|
15
17
|
var Code = require('@itcase/ui/components/Code');
|
|
16
18
|
var DatePicker = require('@itcase/ui/components/DatePicker');
|
|
@@ -21,13 +23,16 @@ var castArray = require('lodash/castArray');
|
|
|
21
23
|
var common = require('@itcase/common');
|
|
22
24
|
var Loader = require('@itcase/ui/components/Loader');
|
|
23
25
|
var Title = require('@itcase/ui/components/Title');
|
|
24
|
-
var Input = require('@itcase/ui/components/Input');
|
|
25
26
|
var Icon = require('@itcase/ui/components/Icon');
|
|
27
|
+
var Input = require('@itcase/ui/components/Input');
|
|
28
|
+
var iconSizeProps = require('@itcase/ui/constants/componentProps/iconSize');
|
|
29
|
+
var shapeProps = require('@itcase/ui/constants/componentProps/shape');
|
|
26
30
|
var Radio = require('@itcase/ui/components/Radio');
|
|
27
31
|
var Segmented = require('@itcase/ui/components/Segmented');
|
|
28
32
|
var Select = require('@itcase/ui/components/Select');
|
|
29
33
|
var Switch = require('@itcase/ui/components/Switch');
|
|
30
34
|
var Textarea = require('@itcase/ui/components/Textarea');
|
|
35
|
+
var reactImask = require('react-imask');
|
|
31
36
|
var Button = require('@itcase/ui/components/Button');
|
|
32
37
|
var Group$1 = require('@itcase/ui/components/Group');
|
|
33
38
|
var Notification = require('@itcase/ui/components/Notification');
|
|
@@ -38,8 +43,12 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
38
43
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
39
44
|
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
40
45
|
var clsx__default = /*#__PURE__*/_interopDefault(clsx);
|
|
46
|
+
var camelCase__default = /*#__PURE__*/_interopDefault(camelCase);
|
|
47
|
+
var snakeCase__default = /*#__PURE__*/_interopDefault(snakeCase);
|
|
41
48
|
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
42
49
|
var castArray__default = /*#__PURE__*/_interopDefault(castArray);
|
|
50
|
+
var iconSizeProps__default = /*#__PURE__*/_interopDefault(iconSizeProps);
|
|
51
|
+
var shapeProps__default = /*#__PURE__*/_interopDefault(shapeProps);
|
|
43
52
|
var createDecorator__default = /*#__PURE__*/_interopDefault(createDecorator);
|
|
44
53
|
|
|
45
54
|
const phoneValidation = (value, context) => {
|
|
@@ -134,9 +143,6 @@ function FieldWrapperBase(props) {
|
|
|
134
143
|
dividerFill,
|
|
135
144
|
dividerSize,
|
|
136
145
|
dividerWidth,
|
|
137
|
-
errorMessageTextColor,
|
|
138
|
-
errorMessageTextSize,
|
|
139
|
-
errorMessageTextWeight,
|
|
140
146
|
fieldClassName,
|
|
141
147
|
id,
|
|
142
148
|
inputName,
|
|
@@ -153,42 +159,28 @@ function FieldWrapperBase(props) {
|
|
|
153
159
|
helpTextSize,
|
|
154
160
|
helpTextWeight,
|
|
155
161
|
helpTextColor,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
message,
|
|
160
|
-
messageTextColor,
|
|
162
|
+
isErrorState,
|
|
163
|
+
isValidState,
|
|
164
|
+
errorMessage,
|
|
161
165
|
messageTextSize,
|
|
162
|
-
messageTextWeight,
|
|
163
166
|
metaActive,
|
|
164
167
|
metaError,
|
|
165
|
-
metaModifiedSinceLastSubmit,
|
|
166
|
-
metaSubmitError,
|
|
167
|
-
metaSubmitFailed,
|
|
168
|
-
metaTouched,
|
|
169
|
-
metaValid,
|
|
170
168
|
set,
|
|
171
169
|
showDivider,
|
|
172
|
-
showErrorsOnSubmit,
|
|
173
170
|
showMessage,
|
|
171
|
+
errorKey,
|
|
174
172
|
tag: Tag,
|
|
175
173
|
type
|
|
176
174
|
} = props;
|
|
177
|
-
const
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const hasValue = Array.isArray(inputValue) ? inputValue.length : inputValue;
|
|
187
|
-
const isModifiedAfterSubmit = !metaError && metaSubmitError && metaModifiedSinceLastSubmit;
|
|
188
|
-
return hasValue && (metaValid || isModifiedAfterSubmit);
|
|
189
|
-
}, [inputValue, metaValid, metaError, metaSubmitError, metaModifiedSinceLastSubmit]);
|
|
190
|
-
const formFieldClass = React.useMemo(() => clsx__default.default(className, showError && 'form__item_state_error', showValid && 'form__item_state_success', isRequired && 'form__item_state_required', isDisabled && 'form__item_state_disabled', metaActive && 'form__item_state_focus', inputValue && 'form__item_state_filled'), [className, showError, showValid, isRequired, metaActive, inputValue, isDisabled]);
|
|
191
|
-
const fieldClass = React.useMemo(() => clsx__default.default(fieldClassName, showError && `${fieldClassName}_state_error`, showValid && `${fieldClassName}_state_success`, metaActive && `${fieldClassName}_state_focus`, inputValue && `${fieldClassName}_state_filled`, isDisabled && `${fieldClassName}_state_disabled`), [fieldClassName, showError, showValid, metaActive, inputValue, isDisabled]);
|
|
175
|
+
const formFieldClass = React.useMemo(() => clsx__default.default(className, isValidState && 'form__item_state_success', isRequired && 'form__item_state_required', isDisabled && 'form__item_state_disabled', metaActive && 'form__item_state_focus', inputValue && 'form__item_state_filled', isErrorState && `form__item_state_${errorKey}`), [className, isErrorState, isValidState, isRequired, metaActive, inputValue, isDisabled, metaError]);
|
|
176
|
+
const fieldClass = React.useMemo(() => clsx__default.default(fieldClassName, isValidState && `${fieldClassName}_state_success`, metaActive && `${fieldClassName}_state_focus`, inputValue && `${fieldClassName}_state_filled`, isDisabled && `${fieldClassName}_state_disabled`, isErrorState && `${fieldClassName}_state_${errorKey}`), [fieldClassName, isErrorState, isValidState, metaActive, inputValue, isDisabled, metaError]);
|
|
177
|
+
const validationAppearance = React.useMemo(() => {
|
|
178
|
+
return {
|
|
179
|
+
textColor: props[`${errorKey}MessageTextColor`],
|
|
180
|
+
textSize: props[`${errorKey}MessageTextSize`],
|
|
181
|
+
textWeight: props[`${errorKey}MessageTextWeight`]
|
|
182
|
+
};
|
|
183
|
+
}, [errorKey, isErrorState]);
|
|
192
184
|
const sizeClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
193
185
|
prefix: 'form-field_size_',
|
|
194
186
|
propsKey: 'size'
|
|
@@ -222,59 +214,61 @@ function FieldWrapperBase(props) {
|
|
|
222
214
|
} = useStyles.useStyles(props);
|
|
223
215
|
return /*#__PURE__*/React__default.default.createElement(Tag, {
|
|
224
216
|
className: clsx__default.default(formFieldClass, 'form__item', 'form-field', type && `form-field_type_${type}`, set && `form-field_set_${set}`, sizeClass, fillClass, shapeClass, isDisabled && `form-field_state_disabled`, isHidden && `form-field_state_hidden`, directionClass, widthClass),
|
|
225
|
-
"data-tour": dataTour,
|
|
226
217
|
"data-test-id": `${inputName}Field`,
|
|
218
|
+
"data-tour": dataTour,
|
|
227
219
|
style: formFieldStyles
|
|
228
220
|
}, before, (label || labelHidden) && /*#__PURE__*/React__default.default.createElement("div", {
|
|
229
|
-
htmlFor: id,
|
|
230
221
|
className: clsx__default.default('form-field__label'),
|
|
231
|
-
"data-test-id": `${inputName}FieldLabel
|
|
222
|
+
"data-test-id": `${inputName}FieldLabel`,
|
|
223
|
+
htmlFor: id
|
|
232
224
|
}, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
233
225
|
size: labelTextSize,
|
|
234
|
-
|
|
235
|
-
|
|
226
|
+
textColor: labelTextColor,
|
|
227
|
+
textWeight: labelTextWidth
|
|
236
228
|
}, label, labelHidden && '\u00A0')), desc && /*#__PURE__*/React__default.default.createElement("div", {
|
|
237
229
|
className: "form-field__desc",
|
|
238
230
|
"data-test-id": `${inputName}FieldDesc`
|
|
239
231
|
}, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
240
232
|
size: descTextSize,
|
|
241
|
-
|
|
242
|
-
|
|
233
|
+
textColor: descTextColor,
|
|
234
|
+
textWeight: descTextWidth
|
|
243
235
|
}, desc)), /*#__PURE__*/React__default.default.createElement("div", {
|
|
244
236
|
className: clsx__default.default('form-field__content', inputFillClass, inputShapeClass)
|
|
245
237
|
}, /*#__PURE__*/React__default.default.createElement("div", {
|
|
246
238
|
className: clsx__default.default('form-field__content-inner', fieldClass)
|
|
247
239
|
}, beforeItem, children, afterItem), showDivider && /*#__PURE__*/React__default.default.createElement(Divider.Divider, {
|
|
248
240
|
className: "form-field__item-divider",
|
|
249
|
-
width: dividerWidth,
|
|
250
241
|
direction: dividerDirection,
|
|
242
|
+
fill: dividerFill,
|
|
251
243
|
size: dividerSize,
|
|
252
|
-
|
|
244
|
+
width: dividerWidth
|
|
253
245
|
})), showMessage && /*#__PURE__*/React__default.default.createElement("div", {
|
|
254
246
|
className: "form-field__message",
|
|
255
247
|
"data-test-id": `${inputName}FieldMessage`
|
|
256
|
-
},
|
|
248
|
+
}, isErrorState && errorMessage && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
257
249
|
className: "form-field__message-item form-field__message-item_type-error",
|
|
258
|
-
|
|
259
|
-
textWeight: errorMessageTextWeight,
|
|
260
|
-
textColor: errorMessageTextColor,
|
|
250
|
+
dataTestId: `${inputName}FieldMessageError`,
|
|
261
251
|
id: `${inputName}-error`,
|
|
262
|
-
|
|
263
|
-
|
|
252
|
+
size: validationAppearance?.textSize,
|
|
253
|
+
textColor: validationAppearance?.textColor,
|
|
254
|
+
textWeight: validationAppearance?.textWeight
|
|
255
|
+
}, errorMessage), Boolean(helpText) && (!isErrorState || !errorMessage) && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
264
256
|
className: "form-field__message-item form-field__message-item_type_help-text",
|
|
257
|
+
dataTestId: `${inputName}FieldMessageHelpText`,
|
|
265
258
|
size: helpTextSize,
|
|
266
|
-
textWeight: helpTextWeight,
|
|
267
259
|
textColor: helpTextColor,
|
|
268
|
-
|
|
269
|
-
}, helpText), (!
|
|
260
|
+
textWeight: helpTextWeight
|
|
261
|
+
}, helpText), (!isErrorState && !helpText || isErrorState && !helpText && !errorMessage) && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
270
262
|
className: "form-field__message-item form-field__message-item_type_help-text",
|
|
271
|
-
|
|
272
|
-
|
|
263
|
+
dataTestId: `${inputName}FieldMessageHelpText`,
|
|
264
|
+
size: messageTextSize
|
|
273
265
|
}, '\u00A0')), after);
|
|
274
266
|
}
|
|
275
267
|
FieldWrapperBase.defaultProps = {
|
|
276
|
-
|
|
268
|
+
requiredMessageTextSize: 's',
|
|
269
|
+
requiredMessageTextColor: 'warningTextPrimary',
|
|
277
270
|
errorMessageTextSize: 's',
|
|
271
|
+
errorMessageTextColor: 'errorTextPrimary',
|
|
278
272
|
tag: 'div',
|
|
279
273
|
type: 'normal'
|
|
280
274
|
};
|
|
@@ -295,10 +289,6 @@ FieldWrapperBase.propTypes = {
|
|
|
295
289
|
dividerFill: PropTypes__default.default.string,
|
|
296
290
|
dividerSize: PropTypes__default.default.string,
|
|
297
291
|
dividerWidth: PropTypes__default.default.string,
|
|
298
|
-
errorMessageTextColor: PropTypes__default.default.string,
|
|
299
|
-
errorMessageTextSize: PropTypes__default.default.string,
|
|
300
|
-
errorMessageTextWeight: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number]),
|
|
301
|
-
errorMessageTextWidth: PropTypes__default.default.string,
|
|
302
292
|
fieldClassName: PropTypes__default.default.string,
|
|
303
293
|
id: PropTypes__default.default.string,
|
|
304
294
|
inputName: PropTypes__default.default.string,
|
|
@@ -323,14 +313,8 @@ FieldWrapperBase.propTypes = {
|
|
|
323
313
|
messageTextWidth: PropTypes__default.default.string,
|
|
324
314
|
metaActive: PropTypes__default.default.bool,
|
|
325
315
|
metaError: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.bool]),
|
|
326
|
-
metaModifiedSinceLastSubmit: PropTypes__default.default.bool,
|
|
327
|
-
metaSubmitError: PropTypes__default.default.string,
|
|
328
|
-
metaSubmitFailed: PropTypes__default.default.bool,
|
|
329
|
-
metaTouched: PropTypes__default.default.bool,
|
|
330
|
-
metaValid: PropTypes__default.default.bool,
|
|
331
316
|
set: PropTypes__default.default.string,
|
|
332
317
|
showDivider: PropTypes__default.default.bool,
|
|
333
|
-
showErrorsOnSubmit: PropTypes__default.default.bool,
|
|
334
318
|
showMessage: PropTypes__default.default.bool,
|
|
335
319
|
tag: PropTypes__default.default.oneOfType([PropTypes__default.default.elementType, PropTypes__default.default.string]),
|
|
336
320
|
type: PropTypes__default.default.string
|
|
@@ -352,6 +336,113 @@ function FieldWrapper(props) {
|
|
|
352
336
|
}
|
|
353
337
|
FieldWrapper.propTypes = FieldWrapperBase.propTypes;
|
|
354
338
|
|
|
339
|
+
// Whether to display an error message based on "fieldProps" and meta-objects
|
|
340
|
+
function useFieldValidationState(props) {
|
|
341
|
+
const {
|
|
342
|
+
fieldProps,
|
|
343
|
+
meta,
|
|
344
|
+
input
|
|
345
|
+
} = props;
|
|
346
|
+
// Determines if there's a submission error that hasn't been rectified since the last submission.
|
|
347
|
+
const submitError = !meta.modifiedSinceLastSubmit && meta.submitError;
|
|
348
|
+
|
|
349
|
+
// Determines a key for the error, defaulting to 'error' if no specific key is found.
|
|
350
|
+
const errorKey = meta.error?.key || 'error';
|
|
351
|
+
const successKey = 'success';
|
|
352
|
+
|
|
353
|
+
// Determines if the field is in an error state based on various conditions.
|
|
354
|
+
const isErrorState = React.useMemo(() => {
|
|
355
|
+
if (fieldProps.showErrorsOnSubmit) {
|
|
356
|
+
return Boolean(meta.submitFailed && meta.touched && (meta.error || submitError));
|
|
357
|
+
} else {
|
|
358
|
+
return Boolean(meta.touched && (meta.error || submitError));
|
|
359
|
+
}
|
|
360
|
+
}, [fieldProps.showErrorsOnSubmit, meta.submitFailed, meta.touched, meta.error, submitError]);
|
|
361
|
+
|
|
362
|
+
// Determines if the field's input state is valid
|
|
363
|
+
const isValidState = React.useMemo(() => {
|
|
364
|
+
const hasValue = Array.isArray(input?.value) ? input?.value.length : input?.value;
|
|
365
|
+
const isModifiedAfterSubmit = meta.modifiedSinceLastSubmit && !meta.error && submitError;
|
|
366
|
+
return Boolean(hasValue && (meta.valid || isModifiedAfterSubmit));
|
|
367
|
+
}, [input?.value, meta.valid, meta.error, submitError, meta.modifiedSinceLastSubmit]);
|
|
368
|
+
const errorMessage = React.useMemo(() => {
|
|
369
|
+
// If final-form field has error in "meta" render-property.
|
|
370
|
+
// If field not modified after last form submit - use submit error
|
|
371
|
+
const error = meta.error || submitError || false;
|
|
372
|
+
if (error) {
|
|
373
|
+
// And error in "meta" is string
|
|
374
|
+
if (typeof error === 'string') {
|
|
375
|
+
// Return error as message
|
|
376
|
+
return error;
|
|
377
|
+
}
|
|
378
|
+
// Or if error in "meta" has "message" property(is object of error)
|
|
379
|
+
if (error.message) {
|
|
380
|
+
// Return message from error
|
|
381
|
+
return error.message;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// Field doesn't have error message
|
|
386
|
+
return '';
|
|
387
|
+
}, [meta.error, submitError]);
|
|
388
|
+
return {
|
|
389
|
+
errorKey,
|
|
390
|
+
successKey,
|
|
391
|
+
isErrorState,
|
|
392
|
+
isValidState,
|
|
393
|
+
errorMessage
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// This hook changes the props of the child component depending on the type of error,
|
|
398
|
+
// looks at what props were in initialProps, if they are there then changes
|
|
399
|
+
function useValidationAppearanceInputProps(props) {
|
|
400
|
+
const {
|
|
401
|
+
validationStateKey,
|
|
402
|
+
inputProps
|
|
403
|
+
} = props;
|
|
404
|
+
|
|
405
|
+
// TODO: need to add props that can change during errors in this field
|
|
406
|
+
const validationAppearanceInputProps = React.useMemo(() => {
|
|
407
|
+
// const resultAppearanceProps = {
|
|
408
|
+
// messageTextColor: props.errorMessageTextColor,
|
|
409
|
+
// messageTextSize: props.errorMessageTextSize,
|
|
410
|
+
// messageTextWeight: props.errorMessageTextWeight,
|
|
411
|
+
// // Override appearance(styled) props for child input
|
|
412
|
+
// inputProps: {},
|
|
413
|
+
// }
|
|
414
|
+
const updatedInputProps = {};
|
|
415
|
+
if (validationStateKey) {
|
|
416
|
+
Object.entries(inputProps).forEach(([propKey, propValue]) => {
|
|
417
|
+
// Convert the input property key to "snake_case" format.
|
|
418
|
+
// e.g. "requiredBorderColor" -> "required_border_color".
|
|
419
|
+
const propKeySnake = snakeCase__default.default(propKey);
|
|
420
|
+
// Check if this property is for appearance.
|
|
421
|
+
// Key maybe starts with: "error", "required", "success", etc from validation config.
|
|
422
|
+
const isPropForValidationState = propKeySnake.startsWith(`${validationStateKey}_`);
|
|
423
|
+
|
|
424
|
+
// If property is for appearance
|
|
425
|
+
if (isPropForValidationState) {
|
|
426
|
+
// Remove validation state part from begin of property key, to make clean appearance property.
|
|
427
|
+
// e.g. "required_border_color" -> "border_color".
|
|
428
|
+
const stateTargetKeySnake = propKeySnake.replace(`${validationStateKey}_`, '');
|
|
429
|
+
// Convert clean appearance property key to "camelCase" format.
|
|
430
|
+
// e.g. "border_color" -> "borderColor"
|
|
431
|
+
const stateTargetKey = camelCase__default.default(stateTargetKeySnake);
|
|
432
|
+
// And save the value with a new clean property key
|
|
433
|
+
updatedInputProps[stateTargetKey] = propValue;
|
|
434
|
+
// Else if not already added earlier
|
|
435
|
+
} else if (!updatedInputProps[propKey]) {
|
|
436
|
+
// Just save original property
|
|
437
|
+
updatedInputProps[propKey] = propValue;
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
return updatedInputProps;
|
|
442
|
+
}, [validationStateKey, inputProps]);
|
|
443
|
+
return validationAppearanceInputProps;
|
|
444
|
+
}
|
|
445
|
+
|
|
355
446
|
const CheckboxField = /*#__PURE__*/React__default.default.memo(function CheckboxField(props) {
|
|
356
447
|
const {
|
|
357
448
|
classNameGroupItem,
|
|
@@ -365,45 +456,65 @@ const CheckboxField = /*#__PURE__*/React__default.default.memo(function Checkbox
|
|
|
365
456
|
onChange
|
|
366
457
|
} = props;
|
|
367
458
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
459
|
+
initialValue: initialValue,
|
|
368
460
|
name: name,
|
|
369
|
-
type: "checkbox"
|
|
370
|
-
|
|
371
|
-
}, ({
|
|
461
|
+
type: "checkbox"
|
|
462
|
+
}, function Render({
|
|
372
463
|
input,
|
|
373
464
|
meta
|
|
374
|
-
})
|
|
465
|
+
}) {
|
|
466
|
+
/** Note:
|
|
467
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
468
|
+
* React Hooks cannot be called inside a callback.
|
|
469
|
+
* React Hooks must be called in a React function component or a
|
|
470
|
+
* custom React Hook function.
|
|
471
|
+
*/
|
|
472
|
+
|
|
375
473
|
const onChangeField = React.useCallback(event => {
|
|
376
474
|
input.onChange(event);
|
|
377
475
|
if (onChange) {
|
|
378
476
|
onChange(event.target.checked, input.name);
|
|
379
477
|
}
|
|
380
|
-
}, [onChange]);
|
|
478
|
+
}, [onChange, input.onChange]);
|
|
479
|
+
const {
|
|
480
|
+
isErrorState,
|
|
481
|
+
isValidState,
|
|
482
|
+
errorKey,
|
|
483
|
+
errorMessage
|
|
484
|
+
} = useFieldValidationState({
|
|
485
|
+
fieldProps: fieldProps,
|
|
486
|
+
input: input,
|
|
487
|
+
meta: meta
|
|
488
|
+
});
|
|
489
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
490
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
491
|
+
inputProps: inputProps
|
|
492
|
+
});
|
|
381
493
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
382
494
|
className: clsx__default.default('form-field_type_checkbox', 'form__item_type_checkbox', classNameGroupItem),
|
|
495
|
+
errorKey: errorKey,
|
|
496
|
+
errorMessage: errorMessage,
|
|
383
497
|
fieldClassName: "form-checkbox",
|
|
384
498
|
inputName: input.name,
|
|
385
499
|
inputValue: input.checked,
|
|
386
|
-
isRequired: isRequired,
|
|
387
500
|
isDisabled: isDisabled,
|
|
501
|
+
isErrorState: isErrorState,
|
|
502
|
+
isRequired: isRequired,
|
|
503
|
+
isValidState: isValidState,
|
|
388
504
|
metaActive: meta.active,
|
|
389
505
|
metaError: meta.error,
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
metaSubmitFailed: meta.submitFailed,
|
|
393
|
-
metaTouched: meta.touched,
|
|
394
|
-
metaValid: meta.valid,
|
|
395
|
-
tag: "label",
|
|
396
|
-
showMessage: showMessage
|
|
506
|
+
showMessage: showMessage,
|
|
507
|
+
tag: "label"
|
|
397
508
|
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Checkbox.Checkbox, Object.assign({
|
|
398
509
|
autoComplete: "nope",
|
|
399
510
|
checked: input.checked,
|
|
400
|
-
name: input.name,
|
|
401
511
|
isDisabled: isDisabled,
|
|
512
|
+
name: input.name,
|
|
402
513
|
type: "checkbox",
|
|
403
514
|
onBlur: input.onBlur,
|
|
404
515
|
onChange: onChangeField,
|
|
405
516
|
onFocus: input.onFocus
|
|
406
|
-
},
|
|
517
|
+
}, updatedInputProps)));
|
|
407
518
|
});
|
|
408
519
|
});
|
|
409
520
|
CheckboxField.defaultProps = {
|
|
@@ -411,9 +522,9 @@ CheckboxField.defaultProps = {
|
|
|
411
522
|
inputProps: {}
|
|
412
523
|
};
|
|
413
524
|
CheckboxField.propTypes = {
|
|
414
|
-
initialValue: PropTypes__default.default.bool,
|
|
415
525
|
classNameGroupItem: PropTypes__default.default.string,
|
|
416
526
|
fieldProps: PropTypes__default.default.object,
|
|
527
|
+
initialValue: PropTypes__default.default.bool,
|
|
417
528
|
inputProps: PropTypes__default.default.object,
|
|
418
529
|
isDisabled: PropTypes__default.default.bool,
|
|
419
530
|
isRequired: PropTypes__default.default.bool,
|
|
@@ -426,17 +537,17 @@ const ChoiceField = /*#__PURE__*/React__default.default.memo(function ChoiceFiel
|
|
|
426
537
|
const {
|
|
427
538
|
classNameGroupItem,
|
|
428
539
|
fieldProps,
|
|
429
|
-
showMessage,
|
|
430
540
|
initialValue,
|
|
431
541
|
inputProps,
|
|
542
|
+
isDisabled,
|
|
432
543
|
isMultiple,
|
|
433
544
|
isRequired,
|
|
434
|
-
isDisabled,
|
|
435
545
|
label,
|
|
436
546
|
messageType,
|
|
437
547
|
name,
|
|
438
548
|
options,
|
|
439
549
|
placeholder,
|
|
550
|
+
showMessage,
|
|
440
551
|
onChange
|
|
441
552
|
} = props;
|
|
442
553
|
const {
|
|
@@ -447,14 +558,20 @@ const ChoiceField = /*#__PURE__*/React__default.default.memo(function ChoiceFiel
|
|
|
447
558
|
if (onChange) {
|
|
448
559
|
onChange(option.value, name, isChecked);
|
|
449
560
|
}
|
|
450
|
-
}, [change]);
|
|
561
|
+
}, [change, onChange]);
|
|
451
562
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
}, ({
|
|
563
|
+
initialValue: initialValue,
|
|
564
|
+
name: name
|
|
565
|
+
}, function Render({
|
|
455
566
|
input,
|
|
456
567
|
meta
|
|
457
|
-
})
|
|
568
|
+
}) {
|
|
569
|
+
/** Note:
|
|
570
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
571
|
+
* React Hooks cannot be called inside a callback.
|
|
572
|
+
* React Hooks must be called in a React function component or a
|
|
573
|
+
* custom React Hook function.
|
|
574
|
+
*/
|
|
458
575
|
const activeOption = React.useMemo(() => {
|
|
459
576
|
const emptyOption = {
|
|
460
577
|
value: null,
|
|
@@ -466,50 +583,63 @@ const ChoiceField = /*#__PURE__*/React__default.default.memo(function ChoiceFiel
|
|
|
466
583
|
}
|
|
467
584
|
return emptyOption;
|
|
468
585
|
}, [input.value]);
|
|
586
|
+
const {
|
|
587
|
+
isErrorState,
|
|
588
|
+
isValidState,
|
|
589
|
+
errorKey,
|
|
590
|
+
errorMessage
|
|
591
|
+
} = useFieldValidationState({
|
|
592
|
+
fieldProps: fieldProps,
|
|
593
|
+
input: input,
|
|
594
|
+
meta: meta
|
|
595
|
+
});
|
|
596
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
597
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
598
|
+
inputProps: inputProps
|
|
599
|
+
});
|
|
469
600
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
470
601
|
className: clsx__default.default('form-field_type_choice', 'form__item_type_choice', classNameGroupItem),
|
|
602
|
+
errorKey: errorKey,
|
|
603
|
+
errorMessage: errorMessage,
|
|
471
604
|
fieldClassName: "form-choice",
|
|
472
605
|
inputName: input.name,
|
|
473
606
|
inputValue: input.value || [],
|
|
474
|
-
isRequired: isRequired,
|
|
475
607
|
isDisabled: isDisabled,
|
|
608
|
+
isErrorState: isErrorState,
|
|
609
|
+
isRequired: isRequired,
|
|
610
|
+
isValidState: isValidState,
|
|
476
611
|
label: label,
|
|
477
612
|
messageType: messageType,
|
|
478
613
|
metaActive: meta.active,
|
|
479
614
|
metaError: meta.error,
|
|
480
|
-
metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
|
|
481
|
-
metaSubmitError: meta.submitError,
|
|
482
|
-
metaSubmitFailed: meta.submitFailed,
|
|
483
|
-
metaTouched: meta.touched,
|
|
484
|
-
metaValid: meta.valid,
|
|
485
615
|
showMessage: showMessage
|
|
486
616
|
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Choice.Choice, Object.assign({
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
name: input.name,
|
|
617
|
+
active: activeOption,
|
|
618
|
+
className: clsx__default.default(meta.active && 'form-choice_state_focus', meta.error && meta.touched && `form-choice_state_${errorKey}`),
|
|
490
619
|
inputValue: input.value || [],
|
|
620
|
+
isDisabled: isDisabled,
|
|
491
621
|
isMultiple: isMultiple,
|
|
492
622
|
isRequired: isRequired,
|
|
623
|
+
name: input.name,
|
|
624
|
+
options: options,
|
|
493
625
|
placeholder: placeholder,
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
isDisabled: isDisabled
|
|
497
|
-
}, inputProps)));
|
|
626
|
+
setActiveSegment: setActiveSegment
|
|
627
|
+
}, updatedInputProps)));
|
|
498
628
|
});
|
|
499
629
|
});
|
|
500
630
|
ChoiceField.propTypes = {
|
|
501
631
|
classNameGroupItem: PropTypes__default.default.string,
|
|
502
632
|
fieldProps: PropTypes__default.default.object,
|
|
503
|
-
showMessage: PropTypes__default.default.bool,
|
|
504
633
|
initialValue: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number, PropTypes__default.default.bool]),
|
|
505
634
|
inputProps: PropTypes__default.default.object,
|
|
635
|
+
isDisabled: PropTypes__default.default.bool,
|
|
506
636
|
isMultiple: PropTypes__default.default.bool,
|
|
507
637
|
isRequired: PropTypes__default.default.bool,
|
|
508
638
|
label: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.element]),
|
|
509
639
|
messageType: PropTypes__default.default.string,
|
|
510
640
|
name: PropTypes__default.default.string,
|
|
511
|
-
options: Choice.Choice.propTypes.options,
|
|
512
641
|
placeholder: PropTypes__default.default.string,
|
|
642
|
+
showMessage: PropTypes__default.default.bool,
|
|
513
643
|
onChange: PropTypes__default.default.func
|
|
514
644
|
};
|
|
515
645
|
|
|
@@ -525,45 +655,68 @@ const CustomField = /*#__PURE__*/React__default.default.memo(function CustomFiel
|
|
|
525
655
|
showMessage
|
|
526
656
|
} = props;
|
|
527
657
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
}, ({
|
|
658
|
+
initialValue: initialValue,
|
|
659
|
+
name: name
|
|
660
|
+
}, function Render({
|
|
531
661
|
input,
|
|
532
662
|
meta
|
|
533
|
-
})
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
663
|
+
}) {
|
|
664
|
+
/** Note:
|
|
665
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
666
|
+
* React Hooks cannot be called inside a callback.
|
|
667
|
+
* React Hooks must be called in a React function component or a
|
|
668
|
+
* custom React Hook function.
|
|
669
|
+
*/
|
|
670
|
+
|
|
671
|
+
const {
|
|
672
|
+
isErrorState,
|
|
673
|
+
isValidState,
|
|
674
|
+
errorKey,
|
|
675
|
+
errorMessage
|
|
676
|
+
} = useFieldValidationState({
|
|
677
|
+
fieldProps: fieldProps,
|
|
678
|
+
input: input,
|
|
679
|
+
meta: meta
|
|
680
|
+
});
|
|
681
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
682
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
683
|
+
// For "Custom" field we pass all props. Can contain some special props, we don't known.
|
|
684
|
+
inputProps: props
|
|
685
|
+
});
|
|
686
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
687
|
+
className: clsx__default.default('form-field_type_custom', 'form__item_type_custom', classNameGroupItem),
|
|
688
|
+
errorKey: errorKey,
|
|
689
|
+
errorMessage: errorMessage,
|
|
690
|
+
fieldClassName: 'form-custom',
|
|
691
|
+
inputName: input.name,
|
|
692
|
+
inputValue: input.value,
|
|
693
|
+
isDisabled: isDisabled,
|
|
694
|
+
isErrorState: isErrorState,
|
|
695
|
+
isRequired: isRequired,
|
|
696
|
+
isValidState: isValidState,
|
|
697
|
+
metaActive: meta.active,
|
|
698
|
+
metaError: meta.error,
|
|
699
|
+
showMessage: showMessage
|
|
700
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Component, Object.assign({}, updatedInputProps, {
|
|
701
|
+
input: input,
|
|
702
|
+
isDisabled: isDisabled,
|
|
703
|
+
meta: meta
|
|
704
|
+
})));
|
|
705
|
+
});
|
|
553
706
|
});
|
|
554
707
|
CustomField.defaultProps = {
|
|
555
708
|
inputProps: {},
|
|
556
709
|
fieldProps: {}
|
|
557
710
|
};
|
|
558
711
|
CustomField.propTypes = {
|
|
559
|
-
|
|
712
|
+
name: PropTypes__default.default.string.isRequired,
|
|
560
713
|
classNameGroupItem: PropTypes__default.default.string,
|
|
714
|
+
Component: PropTypes__default.default.element,
|
|
561
715
|
fieldProps: PropTypes__default.default.object,
|
|
562
716
|
initialValue: PropTypes__default.default.any,
|
|
563
717
|
inputProps: PropTypes__default.default.object,
|
|
564
718
|
isDisabled: PropTypes__default.default.bool,
|
|
565
719
|
isRequired: PropTypes__default.default.bool,
|
|
566
|
-
name: PropTypes__default.default.string.isRequired,
|
|
567
720
|
showMessage: PropTypes__default.default.bool
|
|
568
721
|
};
|
|
569
722
|
|
|
@@ -581,33 +734,55 @@ const CodeField = /*#__PURE__*/React__default.default.memo(function CodeField(pr
|
|
|
581
734
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
582
735
|
name: name,
|
|
583
736
|
initialValue: initialValue
|
|
584
|
-
}, ({
|
|
737
|
+
}, function Render({
|
|
585
738
|
input,
|
|
586
739
|
meta
|
|
587
|
-
})
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
740
|
+
}) {
|
|
741
|
+
/** Note:
|
|
742
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
743
|
+
* React Hooks cannot be called inside a callback.
|
|
744
|
+
* React Hooks must be called in a React function component or a
|
|
745
|
+
* custom React Hook function.
|
|
746
|
+
*/
|
|
747
|
+
|
|
748
|
+
const {
|
|
749
|
+
isErrorState,
|
|
750
|
+
isValidState,
|
|
751
|
+
errorKey,
|
|
752
|
+
errorMessage
|
|
753
|
+
} = useFieldValidationState({
|
|
754
|
+
fieldProps: fieldProps,
|
|
755
|
+
input: input,
|
|
756
|
+
meta: meta
|
|
757
|
+
});
|
|
758
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
759
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
760
|
+
inputProps: inputProps
|
|
761
|
+
});
|
|
762
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
763
|
+
className: clsx__default.default('form-field_type_code', 'form__item_type_code', classNameGroupItem),
|
|
764
|
+
fieldClassName: 'form-code',
|
|
765
|
+
inputName: input.name,
|
|
766
|
+
inputValue: input.value,
|
|
767
|
+
isRequired: isRequired,
|
|
768
|
+
isDisabled: isDisabled,
|
|
769
|
+
metaActive: meta.active,
|
|
770
|
+
metaError: meta.error,
|
|
771
|
+
showMessage: showMessage,
|
|
772
|
+
isErrorState: isErrorState,
|
|
773
|
+
isValidState: isValidState,
|
|
774
|
+
errorKey: errorKey,
|
|
775
|
+
errorMessage: errorMessage
|
|
776
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Code.Code, Object.assign({
|
|
777
|
+
autoComplete: "nope",
|
|
778
|
+
name: input.name,
|
|
779
|
+
isDisabled: isDisabled,
|
|
780
|
+
value: input.value,
|
|
781
|
+
onBlur: input.onBlur,
|
|
782
|
+
onChange: input.onChange,
|
|
783
|
+
onFocus: input.onFocus
|
|
784
|
+
}, updatedInputProps)));
|
|
785
|
+
});
|
|
611
786
|
});
|
|
612
787
|
CodeField.defaultProps = {
|
|
613
788
|
inputProps: {},
|
|
@@ -626,60 +801,72 @@ CodeField.propTypes = {
|
|
|
626
801
|
|
|
627
802
|
function DatePickerField(props) {
|
|
628
803
|
const {
|
|
629
|
-
|
|
804
|
+
classNameGroupItem,
|
|
805
|
+
datePickerProps,
|
|
630
806
|
fieldProps,
|
|
631
807
|
inputProps,
|
|
632
|
-
datePickerProps,
|
|
633
|
-
name,
|
|
634
|
-
iconSize,
|
|
635
|
-
iconBorder,
|
|
636
|
-
iconBorderHover,
|
|
637
|
-
iconFill,
|
|
638
|
-
iconFillHover,
|
|
639
808
|
isDisabled,
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
iconShape,
|
|
809
|
+
isRequired,
|
|
810
|
+
name,
|
|
643
811
|
showMessage,
|
|
644
|
-
onChange
|
|
645
|
-
classNameGroupItem
|
|
812
|
+
onChange
|
|
646
813
|
} = props;
|
|
647
814
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
648
815
|
name: name
|
|
649
|
-
}, ({
|
|
816
|
+
}, function Render({
|
|
650
817
|
input,
|
|
651
818
|
meta
|
|
652
|
-
})
|
|
819
|
+
}) {
|
|
820
|
+
/** Note:
|
|
821
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
822
|
+
* React Hooks cannot be called inside a callback.
|
|
823
|
+
* React Hooks must be called in a React function component or a
|
|
824
|
+
* custom React Hook function.
|
|
825
|
+
*/
|
|
826
|
+
|
|
653
827
|
const onChangeField = React.useCallback(value => {
|
|
654
828
|
input.onChange(value);
|
|
655
829
|
if (onChange) {
|
|
656
830
|
onChange(value, input.name);
|
|
657
831
|
}
|
|
658
|
-
}, [onChange]);
|
|
832
|
+
}, [onChange, input.onChange]);
|
|
833
|
+
const {
|
|
834
|
+
isErrorState,
|
|
835
|
+
isValidState,
|
|
836
|
+
errorKey,
|
|
837
|
+
errorMessage
|
|
838
|
+
} = useFieldValidationState({
|
|
839
|
+
fieldProps: fieldProps,
|
|
840
|
+
input: input,
|
|
841
|
+
meta: meta
|
|
842
|
+
});
|
|
843
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
844
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
845
|
+
inputProps: inputProps
|
|
846
|
+
});
|
|
659
847
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
660
848
|
className: clsx__default.default('form-field_type_datepicker', 'form__item_type_datepicker', classNameGroupItem),
|
|
849
|
+
errorKey: errorKey,
|
|
850
|
+
errorMessage: errorMessage,
|
|
661
851
|
fieldClassName: "form-datepicker",
|
|
662
852
|
inputName: input.name,
|
|
663
853
|
inputValue: input.value || '',
|
|
664
|
-
isRequired: isRequired,
|
|
665
854
|
isDisabled: isDisabled,
|
|
855
|
+
isErrorState: isErrorState,
|
|
856
|
+
isRequired: isRequired,
|
|
857
|
+
isValidState: isValidState,
|
|
666
858
|
metaActive: meta.active,
|
|
667
859
|
metaError: meta.error,
|
|
668
|
-
metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
|
|
669
|
-
metaSubmitError: meta.submitError,
|
|
670
|
-
metaSubmitFailed: meta.submitFailed,
|
|
671
|
-
metaTouched: meta.touched,
|
|
672
|
-
metaValid: meta.valid,
|
|
673
860
|
showMessage: showMessage
|
|
674
861
|
}, fieldProps), /*#__PURE__*/React__default.default.createElement(DatePicker.DatePickerInput, {
|
|
862
|
+
datePickerProps: datePickerProps,
|
|
863
|
+
inputProps: updatedInputProps,
|
|
864
|
+
isDisabled: isDisabled,
|
|
675
865
|
name: input.name,
|
|
676
866
|
value: input.value || '',
|
|
677
867
|
onBlur: input.onBlur,
|
|
678
|
-
isDisabled: isDisabled,
|
|
679
868
|
onChange: onChangeField,
|
|
680
|
-
onFocus: input.onFocus
|
|
681
|
-
inputProps: inputProps,
|
|
682
|
-
datePickerProps: datePickerProps
|
|
869
|
+
onFocus: input.onFocus
|
|
683
870
|
}));
|
|
684
871
|
});
|
|
685
872
|
}
|
|
@@ -688,10 +875,14 @@ DatePickerField.defaultProps = {
|
|
|
688
875
|
fieldProps: {}
|
|
689
876
|
};
|
|
690
877
|
DatePickerField.propTypes = {
|
|
878
|
+
name: PropTypes__default.default.string.isRequired,
|
|
879
|
+
classNameGroupItem: PropTypes__default.default.string,
|
|
880
|
+
datePickerProps: PropTypes__default.default.object,
|
|
691
881
|
fieldProps: PropTypes__default.default.object,
|
|
692
882
|
inputProps: PropTypes__default.default.object,
|
|
883
|
+
isDisabled: PropTypes__default.default.bool,
|
|
693
884
|
isRequired: PropTypes__default.default.bool,
|
|
694
|
-
|
|
885
|
+
showMessage: PropTypes__default.default.bool,
|
|
695
886
|
onChange: PropTypes__default.default.func
|
|
696
887
|
};
|
|
697
888
|
|
|
@@ -1082,7 +1273,6 @@ const FileInput = /*#__PURE__*/React__default.default.memo(function FileInput(pr
|
|
|
1082
1273
|
shape,
|
|
1083
1274
|
size,
|
|
1084
1275
|
borderWidth,
|
|
1085
|
-
borderColor,
|
|
1086
1276
|
borderColorHover,
|
|
1087
1277
|
borderType,
|
|
1088
1278
|
label,
|
|
@@ -1134,77 +1324,104 @@ const FileInput = /*#__PURE__*/React__default.default.memo(function FileInput(pr
|
|
|
1134
1324
|
} = props;
|
|
1135
1325
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1136
1326
|
name: name
|
|
1137
|
-
}, ({
|
|
1327
|
+
}, function Render({
|
|
1138
1328
|
input,
|
|
1139
1329
|
meta
|
|
1140
|
-
})
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1330
|
+
}) {
|
|
1331
|
+
/** Note:
|
|
1332
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
1333
|
+
* React Hooks cannot be called inside a callback.
|
|
1334
|
+
* React Hooks must be called in a React function component or a
|
|
1335
|
+
* custom React Hook function.
|
|
1336
|
+
*/
|
|
1337
|
+
|
|
1338
|
+
const {
|
|
1339
|
+
isErrorState,
|
|
1340
|
+
isValidState,
|
|
1341
|
+
errorKey,
|
|
1342
|
+
errorMessage
|
|
1343
|
+
} = useFieldValidationState({
|
|
1344
|
+
fieldProps: fieldProps,
|
|
1345
|
+
input: input,
|
|
1346
|
+
meta: meta
|
|
1347
|
+
});
|
|
1348
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1349
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
1350
|
+
inputProps: props
|
|
1351
|
+
});
|
|
1352
|
+
|
|
1353
|
+
/** TODO:
|
|
1354
|
+
* REFACTOR PROPERTIES
|
|
1355
|
+
*/
|
|
1356
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1357
|
+
className: clsx__default.default('form-field_type_dropzone', 'form__item_type_dropzone', classNameGroupItem),
|
|
1358
|
+
fieldClassName: "form-dropzone",
|
|
1359
|
+
inputName: input.name,
|
|
1360
|
+
inputValue: input.value,
|
|
1361
|
+
isRequired: isRequired,
|
|
1362
|
+
label: label,
|
|
1363
|
+
labelTextColor: labelTextColor,
|
|
1364
|
+
metaActive: meta.active,
|
|
1365
|
+
metaError: meta.error,
|
|
1366
|
+
metaTouched: meta.touched,
|
|
1367
|
+
showMessage: showMessage,
|
|
1368
|
+
width: width,
|
|
1369
|
+
isErrorState: isErrorState,
|
|
1370
|
+
isValidState: isValidState,
|
|
1371
|
+
errorKey: errorKey,
|
|
1372
|
+
errorMessage: errorMessage
|
|
1373
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(FileInputDropzone, {
|
|
1374
|
+
dropzoneProps: dropzoneProps,
|
|
1375
|
+
hintDescription: hintDescription,
|
|
1376
|
+
hintTitle: hintTitle,
|
|
1377
|
+
borderWidth: borderWidth,
|
|
1378
|
+
borderColor: updatedInputProps.borderColor,
|
|
1379
|
+
borderColorHover: borderColorHover,
|
|
1380
|
+
borderType: borderType,
|
|
1381
|
+
thumbBorderWidth: thumbBorderWidth,
|
|
1382
|
+
thumbBorderColor: thumbBorderColor,
|
|
1383
|
+
thumbBorderColorHover: thumbBorderColorHover,
|
|
1384
|
+
thumbBorderType: thumbBorderType,
|
|
1385
|
+
fileErrorText: fileErrorText,
|
|
1386
|
+
fill: fill,
|
|
1387
|
+
size: size,
|
|
1388
|
+
maxFiles: maxFiles,
|
|
1389
|
+
maxSize: maxSize,
|
|
1390
|
+
removeThumbTextHoverColor: removeThumbTextHoverColor,
|
|
1391
|
+
fillHover: fillHover,
|
|
1392
|
+
className: className,
|
|
1393
|
+
thumbColumn: thumbColumn,
|
|
1394
|
+
thumbDirection: thumbDirection,
|
|
1395
|
+
inputName: input.name,
|
|
1396
|
+
inputValue: input.value,
|
|
1397
|
+
thumbNameTextSize: thumbNameTextSize,
|
|
1398
|
+
thumbNameTextColor: thumbNameTextColor,
|
|
1399
|
+
thumbNameTextWrap: thumbNameTextWrap,
|
|
1400
|
+
thumbNameTextWeight: thumbNameTextWeight,
|
|
1401
|
+
hintTitleTextSize: hintTitleTextSize,
|
|
1402
|
+
hintTitleTextColor: hintTitleTextColor,
|
|
1403
|
+
hintTitleTextWrap: hintTitleTextWrap,
|
|
1404
|
+
hintTitleTextWeight: hintTitleTextWeight,
|
|
1405
|
+
removeThumbTextSize: removeThumbTextSize,
|
|
1406
|
+
removeThumbTextColor: removeThumbTextColor,
|
|
1407
|
+
removeThumbTextWeight: removeThumbTextWeight,
|
|
1408
|
+
hintDescriptionTextSize: hintDescriptionTextSize,
|
|
1409
|
+
hintDescriptionTextColor: hintDescriptionTextColor,
|
|
1410
|
+
hintDescriptionTextWrap: hintDescriptionTextWrap,
|
|
1411
|
+
hintDescriptionTextWeight: hintDescriptionTextWeight,
|
|
1412
|
+
errorMessageTextSize: errorMessageTextSize,
|
|
1413
|
+
errorMessageWeight: errorMessageTextWeight,
|
|
1414
|
+
errorMessageTextColor: errorMessageTextColor,
|
|
1415
|
+
isPreviews: isPreviews,
|
|
1416
|
+
shape: shape,
|
|
1417
|
+
showFilename: showFilename,
|
|
1418
|
+
metaError: meta.error,
|
|
1419
|
+
metaTouched: meta.touched,
|
|
1420
|
+
removeThumbText: removeThumbText,
|
|
1421
|
+
onAddFiles: onAddFiles,
|
|
1422
|
+
onDeleteFile: onDeleteFile
|
|
1423
|
+
}));
|
|
1424
|
+
});
|
|
1208
1425
|
});
|
|
1209
1426
|
FileInput.defaultProps = {
|
|
1210
1427
|
errorMessageTextSize: 's',
|
|
@@ -1241,32 +1458,41 @@ const Group = /*#__PURE__*/React__default.default.memo(function Group(props) {
|
|
|
1241
1458
|
labelTextSize,
|
|
1242
1459
|
labelTextWeight,
|
|
1243
1460
|
message,
|
|
1244
|
-
errorMessageTextSize,
|
|
1245
|
-
errorMessageTextWeight,
|
|
1246
|
-
errorMessageTextColor,
|
|
1247
1461
|
messageTextSize,
|
|
1248
1462
|
messageTextWeight,
|
|
1249
1463
|
messageTextColor,
|
|
1250
1464
|
children,
|
|
1251
1465
|
dataTour,
|
|
1252
1466
|
showGroupMessage,
|
|
1253
|
-
name
|
|
1254
|
-
showErrorsOnSubmit
|
|
1467
|
+
name
|
|
1255
1468
|
} = props;
|
|
1256
1469
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1257
1470
|
name: name
|
|
1258
|
-
}, ({
|
|
1471
|
+
}, function Render({
|
|
1259
1472
|
input,
|
|
1260
1473
|
meta
|
|
1261
|
-
})
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1474
|
+
}) {
|
|
1475
|
+
/** Note:
|
|
1476
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
1477
|
+
* React Hooks cannot be called inside a callback.
|
|
1478
|
+
* React Hooks must be called in a React function component or a
|
|
1479
|
+
* custom React Hook function.
|
|
1480
|
+
*/
|
|
1481
|
+
const {
|
|
1482
|
+
isErrorState,
|
|
1483
|
+
isValidState,
|
|
1484
|
+
errorKey,
|
|
1485
|
+
errorMessage
|
|
1486
|
+
} = useFieldValidationState({
|
|
1487
|
+
fieldProps: props,
|
|
1488
|
+
// or fieldProps?
|
|
1489
|
+
input: input,
|
|
1490
|
+
meta: meta
|
|
1491
|
+
});
|
|
1492
|
+
const updatedProps = useValidationAppearanceInputProps({
|
|
1493
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
1494
|
+
inputProps: props
|
|
1495
|
+
});
|
|
1270
1496
|
return /*#__PURE__*/React__default.default.createElement("div", {
|
|
1271
1497
|
className: clsx__default.default('form__group', className),
|
|
1272
1498
|
"data-tour": dataTour
|
|
@@ -1275,23 +1501,23 @@ const Group = /*#__PURE__*/React__default.default.memo(function Group(props) {
|
|
|
1275
1501
|
}, before, /*#__PURE__*/React__default.default.createElement("div", {
|
|
1276
1502
|
className: "form__group-label"
|
|
1277
1503
|
}, /*#__PURE__*/React__default.default.createElement(Title.Title, {
|
|
1278
|
-
textColor: labelTextColor,
|
|
1279
1504
|
size: labelTextSize,
|
|
1505
|
+
textColor: labelTextColor,
|
|
1280
1506
|
textWeight: labelTextWeight
|
|
1281
1507
|
}, label)), /*#__PURE__*/React__default.default.createElement("div", {
|
|
1282
1508
|
className: "form__group-items"
|
|
1283
|
-
}, children), after), showGroupMessage && /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null,
|
|
1284
|
-
className:
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
textColor:
|
|
1288
|
-
|
|
1289
|
-
},
|
|
1509
|
+
}, children), after), showGroupMessage && /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, isErrorState && errorMessage && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1510
|
+
className: `form__group-message form__group-message_type-${errorKey}`,
|
|
1511
|
+
id: `${name}-error`,
|
|
1512
|
+
size: updatedProps.messageTextSize,
|
|
1513
|
+
textColor: updatedProps.messageTextColor,
|
|
1514
|
+
textWeight: updatedProps.messageTextWeight
|
|
1515
|
+
}, errorMessage), Boolean(message) && (!isErrorState || !errorMessage) && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1290
1516
|
className: "form__group-message",
|
|
1291
1517
|
size: messageTextSize,
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
}, message),
|
|
1518
|
+
textColor: messageTextColor,
|
|
1519
|
+
textWeight: messageTextWeight
|
|
1520
|
+
}, message), !isErrorState && !message && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1295
1521
|
className: "form__group-message",
|
|
1296
1522
|
size: messageTextSize
|
|
1297
1523
|
}, '\u00A0')));
|
|
@@ -1308,34 +1534,34 @@ Group.defaultProps = {
|
|
|
1308
1534
|
};
|
|
1309
1535
|
Group.propTypes = {
|
|
1310
1536
|
name: PropTypes__default.default.string.isRequired,
|
|
1311
|
-
isRequired: PropTypes__default.default.bool,
|
|
1312
1537
|
fieldProps: PropTypes__default.default.object,
|
|
1313
|
-
inputProps: PropTypes__default.default.object
|
|
1538
|
+
inputProps: PropTypes__default.default.object,
|
|
1539
|
+
isRequired: PropTypes__default.default.bool
|
|
1314
1540
|
};
|
|
1315
1541
|
|
|
1316
1542
|
const InputField = /*#__PURE__*/React__default.default.memo(function InputField(props) {
|
|
1317
1543
|
const {
|
|
1318
|
-
|
|
1319
|
-
isRequired,
|
|
1544
|
+
classNameGroupItem,
|
|
1320
1545
|
fieldProps,
|
|
1321
|
-
inputProps,
|
|
1322
|
-
isRevealable,
|
|
1323
|
-
name,
|
|
1324
|
-
parse,
|
|
1325
|
-
dataTestId,
|
|
1326
|
-
iconSize,
|
|
1327
|
-
isDisabled,
|
|
1328
|
-
iconBorder,
|
|
1329
|
-
iconBorderHover,
|
|
1330
1546
|
iconFill,
|
|
1331
1547
|
iconFillHover,
|
|
1332
1548
|
iconRevealableHide,
|
|
1333
1549
|
iconRevealableShow,
|
|
1334
1550
|
iconShape,
|
|
1551
|
+
iconSize,
|
|
1335
1552
|
initialValue,
|
|
1553
|
+
inputProps,
|
|
1554
|
+
isDisabled,
|
|
1555
|
+
isPassword,
|
|
1556
|
+
isRequired,
|
|
1557
|
+
isRevealable,
|
|
1558
|
+
name,
|
|
1559
|
+
parse,
|
|
1336
1560
|
showMessage,
|
|
1337
|
-
onChange
|
|
1338
|
-
|
|
1561
|
+
onChange
|
|
1562
|
+
// dataTestId,
|
|
1563
|
+
// iconBorder,
|
|
1564
|
+
// iconBorderHover,
|
|
1339
1565
|
} = props;
|
|
1340
1566
|
const [isRevealed, setIsRevealed] = React.useState(false);
|
|
1341
1567
|
const inputType = React.useMemo(() => {
|
|
@@ -1345,59 +1571,79 @@ const InputField = /*#__PURE__*/React__default.default.memo(function InputField(
|
|
|
1345
1571
|
return 'text';
|
|
1346
1572
|
}
|
|
1347
1573
|
}, [isRevealed, isPassword]);
|
|
1348
|
-
const
|
|
1349
|
-
|
|
1574
|
+
const onClickIconReveal = React.useCallback(event => {
|
|
1575
|
+
event.preventDefault();
|
|
1350
1576
|
setIsRevealed(prev => !prev);
|
|
1351
|
-
}, [
|
|
1577
|
+
}, []);
|
|
1352
1578
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1579
|
+
initialValue: initialValue,
|
|
1353
1580
|
name: name,
|
|
1354
|
-
parse: parse
|
|
1355
|
-
|
|
1356
|
-
}, ({
|
|
1581
|
+
parse: parse
|
|
1582
|
+
}, function Render({
|
|
1357
1583
|
input,
|
|
1358
1584
|
meta
|
|
1359
|
-
})
|
|
1585
|
+
}) {
|
|
1586
|
+
/** Note:
|
|
1587
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
1588
|
+
* React Hooks cannot be called inside a callback.
|
|
1589
|
+
* React Hooks must be called in a React function component or a
|
|
1590
|
+
* custom React Hook function.
|
|
1591
|
+
*/
|
|
1592
|
+
|
|
1360
1593
|
const onChangeField = React.useCallback(event => {
|
|
1361
1594
|
input.onChange(event);
|
|
1362
1595
|
if (onChange) {
|
|
1363
1596
|
onChange(event.target.value, input.name);
|
|
1364
1597
|
}
|
|
1365
|
-
}, [onChange]);
|
|
1598
|
+
}, [onChange, input.onChange]);
|
|
1599
|
+
const {
|
|
1600
|
+
isErrorState,
|
|
1601
|
+
isValidState,
|
|
1602
|
+
errorKey,
|
|
1603
|
+
errorMessage
|
|
1604
|
+
} = useFieldValidationState({
|
|
1605
|
+
fieldProps: fieldProps,
|
|
1606
|
+
input: input,
|
|
1607
|
+
meta: meta
|
|
1608
|
+
});
|
|
1609
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1610
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
1611
|
+
inputProps: inputProps
|
|
1612
|
+
});
|
|
1366
1613
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1367
1614
|
className: clsx__default.default('form-field_type_input', 'form__item_type_input', classNameGroupItem),
|
|
1615
|
+
errorKey: errorKey,
|
|
1616
|
+
errorMessage: errorMessage,
|
|
1368
1617
|
fieldClassName: isRevealable ? 'form-password' : 'form-input',
|
|
1369
1618
|
inputName: input.name,
|
|
1370
1619
|
inputValue: input.value || '',
|
|
1371
|
-
isRequired: isRequired,
|
|
1372
1620
|
isDisabled: isDisabled,
|
|
1621
|
+
isErrorState: isErrorState,
|
|
1622
|
+
isRequired: isRequired,
|
|
1623
|
+
isValidState: isValidState,
|
|
1373
1624
|
metaActive: meta.active,
|
|
1374
1625
|
metaError: meta.error,
|
|
1375
|
-
metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
|
|
1376
|
-
metaSubmitError: meta.submitError,
|
|
1377
|
-
metaSubmitFailed: meta.submitFailed,
|
|
1378
|
-
metaTouched: meta.touched,
|
|
1379
|
-
metaValid: meta.valid,
|
|
1380
1626
|
showMessage: showMessage
|
|
1381
1627
|
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Input.Input, Object.assign({
|
|
1382
|
-
className: clsx__default.default(meta.active && 'input_state_focus', meta.error && meta.touched && 'input_state_error'),
|
|
1383
1628
|
autoComplete: "nope",
|
|
1629
|
+
className: clsx__default.default(meta.active && 'input_state_focus', meta.error && meta.touched && `input_state_${errorKey}`),
|
|
1630
|
+
dataTestId: `${input.name}FieldInput`,
|
|
1631
|
+
isDisabled: isDisabled,
|
|
1384
1632
|
name: input.name,
|
|
1385
1633
|
type: inputType,
|
|
1386
1634
|
value: input.value || '',
|
|
1387
1635
|
onBlur: input.onBlur,
|
|
1388
1636
|
onChange: onChangeField,
|
|
1389
|
-
onFocus: input.onFocus
|
|
1390
|
-
|
|
1391
|
-
dataTestId: `${input.name}FieldInput`
|
|
1392
|
-
}, inputProps)), isRevealable && /*#__PURE__*/React__default.default.createElement(Icon.Icon, {
|
|
1637
|
+
onFocus: input.onFocus
|
|
1638
|
+
}, updatedInputProps)), isRevealable && /*#__PURE__*/React__default.default.createElement(Icon.Icon, {
|
|
1393
1639
|
className: "form-field__icon",
|
|
1394
1640
|
iconFill: iconFill,
|
|
1395
1641
|
iconFillHover: iconFillHover,
|
|
1396
|
-
SvgImage: isRevealed ? iconRevealableHide : iconRevealableShow,
|
|
1397
1642
|
imageSrc: isRevealed ? iconRevealableHide : iconRevealableShow,
|
|
1398
1643
|
shape: iconShape,
|
|
1399
1644
|
size: iconSize,
|
|
1400
|
-
|
|
1645
|
+
SvgImage: isRevealed ? iconRevealableHide : iconRevealableShow,
|
|
1646
|
+
onClick: onClickIconReveal
|
|
1401
1647
|
}));
|
|
1402
1648
|
});
|
|
1403
1649
|
});
|
|
@@ -1406,13 +1652,26 @@ InputField.defaultProps = {
|
|
|
1406
1652
|
fieldProps: {}
|
|
1407
1653
|
};
|
|
1408
1654
|
InputField.propTypes = {
|
|
1655
|
+
name: PropTypes__default.default.string.isRequired,
|
|
1656
|
+
classNameGroupItem: PropTypes__default.default.string,
|
|
1657
|
+
dataTestId: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number]),
|
|
1409
1658
|
fieldProps: PropTypes__default.default.object,
|
|
1659
|
+
iconBorder: PropTypes__default.default.string,
|
|
1660
|
+
iconBorderHover: PropTypes__default.default.string,
|
|
1661
|
+
iconFill: PropTypes__default.default.string,
|
|
1662
|
+
iconFillHover: PropTypes__default.default.string,
|
|
1663
|
+
iconRevealableHide: PropTypes__default.default.oneOfType([PropTypes__default.default.elementType, PropTypes__default.default.func, PropTypes__default.default.object]),
|
|
1664
|
+
iconRevealableShow: PropTypes__default.default.oneOfType([PropTypes__default.default.elementType, PropTypes__default.default.func, PropTypes__default.default.object]),
|
|
1665
|
+
iconShape: PropTypes__default.default.oneOf(shapeProps__default.default),
|
|
1666
|
+
iconSize: PropTypes__default.default.oneOf(iconSizeProps__default.default),
|
|
1410
1667
|
initialValue: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number]),
|
|
1411
1668
|
inputProps: PropTypes__default.default.object,
|
|
1669
|
+
isDisabled: PropTypes__default.default.bool,
|
|
1412
1670
|
isPassword: PropTypes__default.default.bool,
|
|
1413
1671
|
isRequired: PropTypes__default.default.bool,
|
|
1414
1672
|
isRevealable: PropTypes__default.default.bool,
|
|
1415
|
-
|
|
1673
|
+
parse: PropTypes__default.default.func,
|
|
1674
|
+
showMessage: PropTypes__default.default.bool,
|
|
1416
1675
|
onChange: PropTypes__default.default.func
|
|
1417
1676
|
};
|
|
1418
1677
|
|
|
@@ -1569,32 +1828,54 @@ const RadioGroup = /*#__PURE__*/React__default.default.memo(function RadioGroup(
|
|
|
1569
1828
|
} = props;
|
|
1570
1829
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1571
1830
|
name: name
|
|
1572
|
-
}, ({
|
|
1831
|
+
}, function Render({
|
|
1573
1832
|
input,
|
|
1574
1833
|
meta
|
|
1575
|
-
})
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1834
|
+
}) {
|
|
1835
|
+
/** Note:
|
|
1836
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
1837
|
+
* React Hooks cannot be called inside a callback.
|
|
1838
|
+
* React Hooks must be called in a React function component or a
|
|
1839
|
+
* custom React Hook function.
|
|
1840
|
+
*/
|
|
1841
|
+
|
|
1842
|
+
const {
|
|
1843
|
+
isErrorState,
|
|
1844
|
+
isValidState,
|
|
1845
|
+
errorKey,
|
|
1846
|
+
errorMessage
|
|
1847
|
+
} = useFieldValidationState({
|
|
1848
|
+
fieldProps: fieldProps,
|
|
1849
|
+
input: input,
|
|
1850
|
+
meta: meta
|
|
1851
|
+
});
|
|
1852
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1853
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
1854
|
+
inputProps: inputProps
|
|
1855
|
+
});
|
|
1856
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1857
|
+
className: "form__item_type_radio",
|
|
1858
|
+
errorKey: errorKey,
|
|
1859
|
+
errorMessage: errorMessage,
|
|
1860
|
+
fieldClassName: 'form-radio',
|
|
1861
|
+
inputName: input.name,
|
|
1862
|
+
inputValue: input.value || '',
|
|
1863
|
+
isDisabled: isDisabled,
|
|
1864
|
+
isErrorState: isErrorState,
|
|
1865
|
+
isRequired: isRequired,
|
|
1866
|
+
isValidState: isValidState,
|
|
1867
|
+
metaActive: meta.active,
|
|
1868
|
+
metaError: meta.error,
|
|
1869
|
+
showMessage: showMessage
|
|
1870
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(RadioGroupList, {
|
|
1871
|
+
editableProps: editableProps,
|
|
1872
|
+
input: input,
|
|
1873
|
+
inputProps: updatedInputProps,
|
|
1874
|
+
isDisabled: isDisabled,
|
|
1875
|
+
options: options,
|
|
1876
|
+
onChange: onChange
|
|
1877
|
+
}));
|
|
1878
|
+
});
|
|
1598
1879
|
});
|
|
1599
1880
|
RadioGroup.defaultProps = {
|
|
1600
1881
|
editableProps: {},
|
|
@@ -1603,12 +1884,12 @@ RadioGroup.defaultProps = {
|
|
|
1603
1884
|
options: []
|
|
1604
1885
|
};
|
|
1605
1886
|
RadioGroup.propTypes = {
|
|
1887
|
+
name: PropTypes__default.default.string.isRequired,
|
|
1606
1888
|
editableProps: PropTypes__default.default.object,
|
|
1607
1889
|
fieldProps: PropTypes__default.default.object,
|
|
1608
1890
|
inputProps: PropTypes__default.default.object,
|
|
1609
1891
|
isDisabled: PropTypes__default.default.bool,
|
|
1610
1892
|
isRequired: PropTypes__default.default.bool,
|
|
1611
|
-
name: PropTypes__default.default.string.isRequired,
|
|
1612
1893
|
options: PropTypes__default.default.array,
|
|
1613
1894
|
showMessage: PropTypes__default.default.bool,
|
|
1614
1895
|
onChange: PropTypes__default.default.func
|
|
@@ -1632,10 +1913,17 @@ function SegmentedField(props) {
|
|
|
1632
1913
|
}, [change]);
|
|
1633
1914
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1634
1915
|
name: name
|
|
1635
|
-
}, ({
|
|
1916
|
+
}, function Render({
|
|
1636
1917
|
input,
|
|
1637
1918
|
meta
|
|
1638
|
-
})
|
|
1919
|
+
}) {
|
|
1920
|
+
/** Note:
|
|
1921
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
1922
|
+
* React Hooks cannot be called inside a callback.
|
|
1923
|
+
* React Hooks must be called in a React function component or a
|
|
1924
|
+
* custom React Hook function.
|
|
1925
|
+
*/
|
|
1926
|
+
|
|
1639
1927
|
const activeOption = React.useMemo(() => {
|
|
1640
1928
|
const emptyOption = {
|
|
1641
1929
|
value: null,
|
|
@@ -1647,30 +1935,45 @@ function SegmentedField(props) {
|
|
|
1647
1935
|
}
|
|
1648
1936
|
return emptyOption;
|
|
1649
1937
|
}, [input.value]);
|
|
1938
|
+
const {
|
|
1939
|
+
isErrorState,
|
|
1940
|
+
isValidState,
|
|
1941
|
+
errorKey,
|
|
1942
|
+
errorMessage
|
|
1943
|
+
} = useFieldValidationState({
|
|
1944
|
+
fieldProps: fieldProps,
|
|
1945
|
+
input: input,
|
|
1946
|
+
meta: meta
|
|
1947
|
+
});
|
|
1948
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1949
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
1950
|
+
inputProps: inputProps
|
|
1951
|
+
});
|
|
1650
1952
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1651
1953
|
className: clsx__default.default('form-field_type_segmented', 'form__item_type_segmented'),
|
|
1954
|
+
errorKey: errorKey,
|
|
1955
|
+
errorMessage: errorMessage,
|
|
1652
1956
|
fieldClassName: "form-segmented",
|
|
1653
1957
|
inputName: input.name,
|
|
1654
1958
|
inputValue: input.value || [],
|
|
1655
|
-
isRequired: isRequired,
|
|
1656
1959
|
isDisabled: isDisabled,
|
|
1960
|
+
isErrorState: isErrorState,
|
|
1961
|
+
isRequired: isRequired,
|
|
1962
|
+
isValidState: isValidState,
|
|
1657
1963
|
metaActive: meta.active,
|
|
1658
1964
|
metaError: meta.error,
|
|
1659
|
-
metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
|
|
1660
|
-
metaSubmitError: meta.submitError,
|
|
1661
|
-
metaSubmitFailed: meta.submitFailed,
|
|
1662
|
-
metaTouched: meta.touched,
|
|
1663
|
-
metaValid: meta.valid,
|
|
1664
1965
|
showMessage: showMessage
|
|
1665
1966
|
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Segmented.Segmented, Object.assign({
|
|
1666
|
-
|
|
1967
|
+
activeSegment: activeOption,
|
|
1667
1968
|
isDisabled: isDisabled,
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
},
|
|
1969
|
+
segments: options,
|
|
1970
|
+
setActiveSegment: setActiveSegment
|
|
1971
|
+
}, updatedInputProps)));
|
|
1671
1972
|
});
|
|
1672
1973
|
}
|
|
1673
1974
|
SegmentedField.propTypes = {
|
|
1975
|
+
name: PropTypes__default.default.string.isRequired,
|
|
1976
|
+
options: PropTypes__default.default.array.isRequired,
|
|
1674
1977
|
className: PropTypes__default.default.string,
|
|
1675
1978
|
fieldProps: PropTypes__default.default.object,
|
|
1676
1979
|
inputClass: PropTypes__default.default.string,
|
|
@@ -1678,8 +1981,6 @@ SegmentedField.propTypes = {
|
|
|
1678
1981
|
isDisabled: PropTypes__default.default.bool,
|
|
1679
1982
|
isRequired: PropTypes__default.default.bool,
|
|
1680
1983
|
label: PropTypes__default.default.string,
|
|
1681
|
-
name: PropTypes__default.default.string.isRequired,
|
|
1682
|
-
options: PropTypes__default.default.array.isRequired,
|
|
1683
1984
|
placeholder: PropTypes__default.default.string,
|
|
1684
1985
|
showMessage: PropTypes__default.default.bool
|
|
1685
1986
|
};
|
|
@@ -1717,10 +2018,16 @@ const SelectField = /*#__PURE__*/React__default.default.memo(function SelectFiel
|
|
|
1717
2018
|
} = props;
|
|
1718
2019
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1719
2020
|
name: name
|
|
1720
|
-
}, ({
|
|
2021
|
+
}, function Render({
|
|
1721
2022
|
input,
|
|
1722
2023
|
meta
|
|
1723
|
-
})
|
|
2024
|
+
}) {
|
|
2025
|
+
/** Note:
|
|
2026
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
2027
|
+
* React Hooks cannot be called inside a callback.
|
|
2028
|
+
* React Hooks must be called in a React function component or a
|
|
2029
|
+
* custom React Hook function.
|
|
2030
|
+
*/
|
|
1724
2031
|
const [selectedOptions, setSelectedOptions] = React.useState(null);
|
|
1725
2032
|
const defaultValue = React.useMemo(() => {
|
|
1726
2033
|
const optionsValues = getDefaultValue(options, input.value);
|
|
@@ -1737,47 +2044,60 @@ const SelectField = /*#__PURE__*/React__default.default.memo(function SelectFiel
|
|
|
1737
2044
|
if (onChange) {
|
|
1738
2045
|
onChange(value, input.name);
|
|
1739
2046
|
}
|
|
1740
|
-
}, [onChange]);
|
|
2047
|
+
}, [onChange, input.onChange]);
|
|
1741
2048
|
const onChangeValue = React.useCallback((option, actionMeta) => {
|
|
1742
2049
|
const value = Array.isArray(option) ? option.map(o => o.value) : option?.value || null;
|
|
1743
2050
|
setSelectedOptions(option);
|
|
1744
2051
|
onChangeField(value);
|
|
1745
2052
|
}, [onChangeField]);
|
|
1746
2053
|
React.useEffect(() => setSelectedOptions(defaultValue), [defaultValue]);
|
|
2054
|
+
const {
|
|
2055
|
+
isErrorState,
|
|
2056
|
+
isValidState,
|
|
2057
|
+
errorKey,
|
|
2058
|
+
errorMessage
|
|
2059
|
+
} = useFieldValidationState({
|
|
2060
|
+
fieldProps: fieldProps,
|
|
2061
|
+
input: input,
|
|
2062
|
+
meta: meta
|
|
2063
|
+
});
|
|
2064
|
+
const updatedSelectProps = useValidationAppearanceInputProps({
|
|
2065
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
2066
|
+
inputProps: selectProps
|
|
2067
|
+
});
|
|
1747
2068
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1748
2069
|
className: clsx__default.default('form-field_type_select', 'form__item_type_select', classNameGroupItem),
|
|
2070
|
+
errorKey: errorKey,
|
|
2071
|
+
errorMessage: errorMessage,
|
|
1749
2072
|
fieldClassName: 'form-select',
|
|
1750
2073
|
inputName: input.name,
|
|
1751
2074
|
inputValue: input.value,
|
|
1752
|
-
isRequired: isRequired,
|
|
1753
2075
|
isDisabled: isDisabled,
|
|
2076
|
+
isErrorState: isErrorState,
|
|
2077
|
+
isRequired: isRequired,
|
|
2078
|
+
isValidState: isValidState,
|
|
1754
2079
|
metaActive: meta.active,
|
|
1755
2080
|
metaError: meta.error,
|
|
1756
|
-
metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
|
|
1757
|
-
metaSubmitError: meta.submitError,
|
|
1758
|
-
metaSubmitFailed: meta.submitFailed,
|
|
1759
|
-
metaTouched: meta.touched,
|
|
1760
|
-
metaValid: meta.valid,
|
|
1761
2081
|
showMessage: showMessage
|
|
1762
2082
|
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Select.Select, Object.assign({
|
|
1763
2083
|
className: "form-select-item",
|
|
1764
2084
|
instanceId: `id_${input.name}`,
|
|
1765
|
-
value: selectedOptions,
|
|
1766
|
-
onChange: onChangeValue,
|
|
1767
2085
|
isDisabled: isDisabled,
|
|
1768
2086
|
options: options,
|
|
1769
|
-
ref: selectRef
|
|
1770
|
-
|
|
2087
|
+
ref: selectRef,
|
|
2088
|
+
value: selectedOptions,
|
|
2089
|
+
onChange: onChangeValue
|
|
2090
|
+
}, updatedSelectProps)));
|
|
1771
2091
|
});
|
|
1772
2092
|
});
|
|
1773
2093
|
SelectField.propTypes = {
|
|
2094
|
+
name: PropTypes__default.default.string.isRequired,
|
|
1774
2095
|
classNameGroupItem: PropTypes__default.default.string,
|
|
1775
2096
|
fieldProps: PropTypes__default.default.object,
|
|
1776
2097
|
isDisabled: PropTypes__default.default.bool,
|
|
1777
2098
|
isRequired: PropTypes__default.default.bool,
|
|
1778
2099
|
label: PropTypes__default.default.any,
|
|
1779
2100
|
messageType: PropTypes__default.default.string,
|
|
1780
|
-
name: PropTypes__default.default.string.isRequired,
|
|
1781
2101
|
options: PropTypes__default.default.array,
|
|
1782
2102
|
selectProps: PropTypes__default.default.object,
|
|
1783
2103
|
selectRef: PropTypes__default.default.any,
|
|
@@ -1799,42 +2119,62 @@ const SwitchField = /*#__PURE__*/React__default.default.memo(function SwitchFiel
|
|
|
1799
2119
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1800
2120
|
name: name,
|
|
1801
2121
|
type: "checkbox"
|
|
1802
|
-
}, ({
|
|
2122
|
+
}, function Render({
|
|
1803
2123
|
input,
|
|
1804
2124
|
meta
|
|
1805
|
-
})
|
|
2125
|
+
}) {
|
|
2126
|
+
/** Note:
|
|
2127
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
2128
|
+
* React Hooks cannot be called inside a callback.
|
|
2129
|
+
* React Hooks must be called in a React function component or a
|
|
2130
|
+
* custom React Hook function.
|
|
2131
|
+
*/
|
|
2132
|
+
|
|
1806
2133
|
const onChangeField = React.useCallback(event => {
|
|
1807
2134
|
input.onChange(event);
|
|
1808
2135
|
if (onChange) {
|
|
1809
2136
|
onChange(event.target.checked, input.name);
|
|
1810
2137
|
}
|
|
1811
|
-
}, [onChange]);
|
|
2138
|
+
}, [onChange, input.onChange]);
|
|
2139
|
+
const {
|
|
2140
|
+
isErrorState,
|
|
2141
|
+
isValidState,
|
|
2142
|
+
errorKey,
|
|
2143
|
+
errorMessage
|
|
2144
|
+
} = useFieldValidationState({
|
|
2145
|
+
fieldProps: fieldProps,
|
|
2146
|
+
input: input,
|
|
2147
|
+
meta: meta
|
|
2148
|
+
});
|
|
2149
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
2150
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
2151
|
+
inputProps: inputProps
|
|
2152
|
+
});
|
|
1812
2153
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1813
2154
|
className: clsx__default.default('form-field_type_switch', 'form__item_type_switch', classNameGroupItem),
|
|
2155
|
+
errorKey: errorKey,
|
|
2156
|
+
errorMessage: errorMessage,
|
|
1814
2157
|
fieldClassName: "form-switch",
|
|
1815
2158
|
inputName: input.name,
|
|
1816
2159
|
inputValue: input.checked,
|
|
1817
|
-
isRequired: isRequired,
|
|
1818
2160
|
isDisabled: isDisabled,
|
|
2161
|
+
isErrorState: isErrorState,
|
|
2162
|
+
isRequired: isRequired,
|
|
2163
|
+
isValidState: isValidState,
|
|
1819
2164
|
metaActive: meta.active,
|
|
1820
2165
|
metaError: meta.error,
|
|
1821
|
-
metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
|
|
1822
|
-
metaSubmitError: meta.submitError,
|
|
1823
|
-
metaSubmitFailed: meta.submitFailed,
|
|
1824
|
-
metaTouched: meta.touched,
|
|
1825
|
-
metaValid: meta.valid,
|
|
1826
2166
|
showMessage: showMessage,
|
|
1827
2167
|
tag: "label"
|
|
1828
2168
|
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Switch.Switch, Object.assign({
|
|
1829
2169
|
autoComplete: "nope",
|
|
1830
|
-
isDisabled: isDisabled,
|
|
1831
2170
|
checked: input.checked,
|
|
2171
|
+
isDisabled: isDisabled,
|
|
1832
2172
|
name: input.name,
|
|
1833
2173
|
type: "checkbox",
|
|
1834
2174
|
onBlur: input.onBlur,
|
|
1835
2175
|
onChange: onChangeField,
|
|
1836
2176
|
onFocus: input.onFocus
|
|
1837
|
-
},
|
|
2177
|
+
}, updatedInputProps)));
|
|
1838
2178
|
});
|
|
1839
2179
|
});
|
|
1840
2180
|
SwitchField.defaultProps = {
|
|
@@ -1864,48 +2204,168 @@ const TextareaField = /*#__PURE__*/React__default.default.memo(function Textarea
|
|
|
1864
2204
|
} = props;
|
|
1865
2205
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1866
2206
|
name: name
|
|
1867
|
-
}, ({
|
|
2207
|
+
}, function Render({
|
|
1868
2208
|
input,
|
|
1869
2209
|
meta
|
|
1870
|
-
})
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
2210
|
+
}) {
|
|
2211
|
+
/** Note:
|
|
2212
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
2213
|
+
* React Hooks cannot be called inside a callback.
|
|
2214
|
+
* React Hooks must be called in a React function component or a
|
|
2215
|
+
* custom React Hook function.
|
|
2216
|
+
*/
|
|
2217
|
+
|
|
2218
|
+
const {
|
|
2219
|
+
isErrorState,
|
|
2220
|
+
isValidState,
|
|
2221
|
+
errorKey,
|
|
2222
|
+
errorMessage
|
|
2223
|
+
} = useFieldValidationState({
|
|
2224
|
+
fieldProps: fieldProps,
|
|
2225
|
+
input: input,
|
|
2226
|
+
meta: meta
|
|
2227
|
+
});
|
|
2228
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
2229
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
2230
|
+
inputProps: inputProps
|
|
2231
|
+
});
|
|
2232
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
2233
|
+
className: clsx__default.default('form-field_type_textarea', 'form__item_type_textarea', classNameGroupItem),
|
|
2234
|
+
errorKey: errorKey,
|
|
2235
|
+
errorMessage: errorMessage,
|
|
2236
|
+
fieldClassName: 'form-textarea',
|
|
2237
|
+
inputName: input.name,
|
|
2238
|
+
inputValue: input.value,
|
|
2239
|
+
isDisabled: isDisabled,
|
|
2240
|
+
isErrorState: isErrorState,
|
|
2241
|
+
isRequired: isRequired,
|
|
2242
|
+
isValidState: isValidState,
|
|
2243
|
+
metaActive: meta.active,
|
|
2244
|
+
metaError: meta.error,
|
|
2245
|
+
showMessage: showMessage
|
|
2246
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Textarea.Textarea, Object.assign({
|
|
2247
|
+
autoComplete: "nope",
|
|
2248
|
+
isDisabled: isDisabled,
|
|
2249
|
+
name: input.name,
|
|
2250
|
+
value: input.value,
|
|
2251
|
+
onBlur: input.onBlur,
|
|
2252
|
+
onChange: input.onChange,
|
|
2253
|
+
onFocus: input.onFocus
|
|
2254
|
+
}, updatedInputProps)));
|
|
2255
|
+
});
|
|
1894
2256
|
});
|
|
1895
2257
|
TextareaField.defaultProps = {
|
|
1896
2258
|
inputProps: {},
|
|
1897
2259
|
fieldProps: {}
|
|
1898
2260
|
};
|
|
1899
2261
|
TextareaField.propTypes = {
|
|
2262
|
+
name: PropTypes__default.default.string.isRequired,
|
|
1900
2263
|
classNameGroupItem: PropTypes__default.default.string,
|
|
1901
2264
|
fieldProps: PropTypes__default.default.object,
|
|
1902
2265
|
inputProps: PropTypes__default.default.object,
|
|
1903
2266
|
isDisabled: PropTypes__default.default.bool,
|
|
1904
2267
|
isRequired: PropTypes__default.default.bool,
|
|
1905
|
-
name: PropTypes__default.default.string.isRequired,
|
|
1906
2268
|
showMessage: PropTypes__default.default.bool
|
|
1907
2269
|
};
|
|
1908
2270
|
|
|
2271
|
+
const MaskedInputField = /*#__PURE__*/React__default.default.memo(function MaskedInputField(props) {
|
|
2272
|
+
const {
|
|
2273
|
+
isDisabled,
|
|
2274
|
+
isRequired,
|
|
2275
|
+
name,
|
|
2276
|
+
initialValue,
|
|
2277
|
+
fieldProps,
|
|
2278
|
+
classNameGroupItem,
|
|
2279
|
+
showMessage,
|
|
2280
|
+
inputProps,
|
|
2281
|
+
optionsMask,
|
|
2282
|
+
unmasked
|
|
2283
|
+
} = props;
|
|
2284
|
+
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
2285
|
+
initialValue: initialValue,
|
|
2286
|
+
name: name
|
|
2287
|
+
}, function Render({
|
|
2288
|
+
input,
|
|
2289
|
+
meta
|
|
2290
|
+
}) {
|
|
2291
|
+
/** Note:
|
|
2292
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
2293
|
+
* React Hooks cannot be called inside a callback.
|
|
2294
|
+
* React Hooks must be called in a React function component or a
|
|
2295
|
+
* custom React Hook function.
|
|
2296
|
+
*/
|
|
2297
|
+
|
|
2298
|
+
const {
|
|
2299
|
+
ref,
|
|
2300
|
+
value,
|
|
2301
|
+
unmaskedValue,
|
|
2302
|
+
setUnmaskedValue
|
|
2303
|
+
} = reactImask.useIMask(optionsMask, {
|
|
2304
|
+
onAccept: (newValue, event, element) => {
|
|
2305
|
+
if (element) {
|
|
2306
|
+
input.onChange(event._unmaskedValue);
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
});
|
|
2310
|
+
React.useEffect(() => {
|
|
2311
|
+
if (input.value !== unmaskedValue) {
|
|
2312
|
+
setUnmaskedValue(input.value.replace(unmasked, ''));
|
|
2313
|
+
}
|
|
2314
|
+
}, [input.value]);
|
|
2315
|
+
const {
|
|
2316
|
+
isErrorState,
|
|
2317
|
+
isValidState,
|
|
2318
|
+
errorKey,
|
|
2319
|
+
errorMessage
|
|
2320
|
+
} = useFieldValidationState({
|
|
2321
|
+
fieldProps: fieldProps,
|
|
2322
|
+
input: input,
|
|
2323
|
+
meta: meta
|
|
2324
|
+
});
|
|
2325
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
2326
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
2327
|
+
inputProps: inputProps
|
|
2328
|
+
});
|
|
2329
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
2330
|
+
className: clsx__default.default('form-field_type_maskedInput', 'form__item_type_maskedInput', classNameGroupItem),
|
|
2331
|
+
errorKey: errorKey,
|
|
2332
|
+
errorMessage: errorMessage,
|
|
2333
|
+
fieldClassName: 'form-maskedInput',
|
|
2334
|
+
inputName: input.name,
|
|
2335
|
+
inputValue: input.value,
|
|
2336
|
+
isDisabled: isDisabled,
|
|
2337
|
+
isErrorState: isErrorState,
|
|
2338
|
+
isRequired: isRequired,
|
|
2339
|
+
isValidState: isValidState,
|
|
2340
|
+
metaActive: meta.active,
|
|
2341
|
+
metaError: meta.error,
|
|
2342
|
+
showMessage: showMessage
|
|
2343
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Input.Input, Object.assign({
|
|
2344
|
+
className: clsx__default.default(meta.active && 'input_state_focus', meta.error && meta.touched && `input_state_${errorKey}`),
|
|
2345
|
+
ref: ref,
|
|
2346
|
+
value: value,
|
|
2347
|
+
onBlur: input.onBlur,
|
|
2348
|
+
onFocus: input.onFocus
|
|
2349
|
+
}, updatedInputProps)));
|
|
2350
|
+
});
|
|
2351
|
+
});
|
|
2352
|
+
MaskedInputField.defaultProps = {
|
|
2353
|
+
inputProps: {},
|
|
2354
|
+
fieldProps: {}
|
|
2355
|
+
};
|
|
2356
|
+
MaskedInputField.propTypes = {
|
|
2357
|
+
name: PropTypes__default.default.string.isRequired,
|
|
2358
|
+
classNameGroupItem: PropTypes__default.default.string,
|
|
2359
|
+
fieldProps: PropTypes__default.default.object,
|
|
2360
|
+
initialValue: PropTypes__default.default.any,
|
|
2361
|
+
inputProps: PropTypes__default.default.object,
|
|
2362
|
+
isDisabled: PropTypes__default.default.bool,
|
|
2363
|
+
isRequired: PropTypes__default.default.bool,
|
|
2364
|
+
optionsMask: PropTypes__default.default.object,
|
|
2365
|
+
showMessage: PropTypes__default.default.bool,
|
|
2366
|
+
unmasked: PropTypes__default.default.string
|
|
2367
|
+
};
|
|
2368
|
+
|
|
1909
2369
|
const focusOnError = (formElementsList, errors) => {
|
|
1910
2370
|
const selectsIds = Object.keys(errors).map(fieldName => {
|
|
1911
2371
|
if (fieldName === finalForm.FORM_ERROR) {
|
|
@@ -2030,7 +2490,8 @@ const formTypes = {
|
|
|
2030
2490
|
select: 'select',
|
|
2031
2491
|
switch: 'switch',
|
|
2032
2492
|
text: 'text',
|
|
2033
|
-
textarea: 'textarea'
|
|
2493
|
+
textarea: 'textarea',
|
|
2494
|
+
maskedInput: 'maskedInput'
|
|
2034
2495
|
};
|
|
2035
2496
|
function generateField(field, config, props) {
|
|
2036
2497
|
switch (field.type) {
|
|
@@ -2100,6 +2561,12 @@ function generateField(field, config, props) {
|
|
|
2100
2561
|
key: config.key
|
|
2101
2562
|
}, field, props));
|
|
2102
2563
|
}
|
|
2564
|
+
case formTypes.maskedInput:
|
|
2565
|
+
{
|
|
2566
|
+
return /*#__PURE__*/React__default.default.createElement(MaskedInputField, Object.assign({
|
|
2567
|
+
key: config.key
|
|
2568
|
+
}, field, props));
|
|
2569
|
+
}
|
|
2103
2570
|
case formTypes.custom:
|
|
2104
2571
|
{
|
|
2105
2572
|
return /*#__PURE__*/React__default.default.createElement(CustomField, Object.assign({
|
|
@@ -2433,6 +2900,118 @@ FinalForm.defaultProps = {
|
|
|
2433
2900
|
disableFieldsAutoComplete: false
|
|
2434
2901
|
};
|
|
2435
2902
|
|
|
2903
|
+
const DEFAULT_MESSAGES_FIELDS = {
|
|
2904
|
+
/*
|
|
2905
|
+
!!! it also works without props simply based on the class and key as before `input_state_${meta.error.key}`
|
|
2906
|
+
the KEY is needed for example for border color
|
|
2907
|
+
the name of the key is anything you want, the main thing is that there is a props with the same KEY and color in FieldProps
|
|
2908
|
+
...example
|
|
2909
|
+
required - KEY for yellow color
|
|
2910
|
+
error - KEY for red color
|
|
2911
|
+
custom or blue - KEY blue or other color
|
|
2912
|
+
requiredBorderColor: 'warningBorderPrimary',
|
|
2913
|
+
errorBorderColor: 'errorBorderPrimary',
|
|
2914
|
+
customBorderColor: 'customBorderPrimary',
|
|
2915
|
+
blueBorderColor: 'blueBorderPrimary',
|
|
2916
|
+
const defaultFieldProps = {
|
|
2917
|
+
messageTextSize: 's',
|
|
2918
|
+
messageTextColor: 'surfaceTextSecondary',
|
|
2919
|
+
requiredMessageTextSize: 's',
|
|
2920
|
+
requiredMessageTextColor: 'warningTextPrimary',
|
|
2921
|
+
errorMessageTextSize: 's',
|
|
2922
|
+
errorMessageTextColor: 'errorTextPrimary',
|
|
2923
|
+
}
|
|
2924
|
+
// INPUT
|
|
2925
|
+
const defaultInputProps = {
|
|
2926
|
+
... other
|
|
2927
|
+
stateBorderColor: 'surfaceBorderTertiary',
|
|
2928
|
+
requiredStateBorderColor: 'warningBorderPrimary',
|
|
2929
|
+
errorStateBorderColor: 'errorBorderPrimary',
|
|
2930
|
+
}
|
|
2931
|
+
// RADIO
|
|
2932
|
+
const defaultRadioProps = {
|
|
2933
|
+
... other
|
|
2934
|
+
stateBorderColor: 'surfaceBorderTertiary',
|
|
2935
|
+
requiredStateBorderColor: 'warningBorderPrimary',
|
|
2936
|
+
errorStateBorderColor: 'errorBorderPrimary',
|
|
2937
|
+
}
|
|
2938
|
+
// SELECT
|
|
2939
|
+
const defaultSelectProps = {
|
|
2940
|
+
... other
|
|
2941
|
+
borderColor: 'surfaceBorderTertiary',
|
|
2942
|
+
requiredBorderColor: 'warningBorderPrimary',
|
|
2943
|
+
errorBorderColor: 'errorBorderPrimary',
|
|
2944
|
+
inputBorderColor: 'surfaceBorderTertiary',
|
|
2945
|
+
requiredInputBorderColor: 'warningBorderPrimary',
|
|
2946
|
+
errorInputBorderColor: 'errorBorderPrimary',
|
|
2947
|
+
}
|
|
2948
|
+
... etc
|
|
2949
|
+
*/
|
|
2950
|
+
|
|
2951
|
+
// DEFAULT
|
|
2952
|
+
// required - KEY for yellow color
|
|
2953
|
+
// error - KEY for red color
|
|
2954
|
+
|
|
2955
|
+
// key: 'required'
|
|
2956
|
+
required: {
|
|
2957
|
+
key: 'required',
|
|
2958
|
+
message: 'Обязательное поле'
|
|
2959
|
+
},
|
|
2960
|
+
phone_required: {
|
|
2961
|
+
key: 'required',
|
|
2962
|
+
message: 'Укажите номер телефона'
|
|
2963
|
+
},
|
|
2964
|
+
email_required: {
|
|
2965
|
+
key: 'required',
|
|
2966
|
+
message: 'Укажите адрес электронной почты'
|
|
2967
|
+
},
|
|
2968
|
+
password_required: {
|
|
2969
|
+
key: 'required',
|
|
2970
|
+
message: 'Введите пароль'
|
|
2971
|
+
},
|
|
2972
|
+
phone_or_email_required: {
|
|
2973
|
+
key: 'required',
|
|
2974
|
+
message: 'Введите телефон или адрес эл. почты'
|
|
2975
|
+
},
|
|
2976
|
+
// key: 'error'
|
|
2977
|
+
matches: {
|
|
2978
|
+
key: 'error',
|
|
2979
|
+
message: 'Допускается ввод только цифр от 0 до 9'
|
|
2980
|
+
},
|
|
2981
|
+
min: {
|
|
2982
|
+
key: 'error',
|
|
2983
|
+
message: ({
|
|
2984
|
+
min
|
|
2985
|
+
}) => `Значение должно быть не менее ${min} символов`
|
|
2986
|
+
},
|
|
2987
|
+
max: {
|
|
2988
|
+
key: 'error',
|
|
2989
|
+
message: ({
|
|
2990
|
+
max
|
|
2991
|
+
}) => `Значение должно быть не менее ${max} символов`
|
|
2992
|
+
},
|
|
2993
|
+
url: {
|
|
2994
|
+
key: 'error',
|
|
2995
|
+
message: 'Введите корректный URL-адрес'
|
|
2996
|
+
},
|
|
2997
|
+
invalid_value: {
|
|
2998
|
+
key: 'error',
|
|
2999
|
+
message: 'Некорректное значение'
|
|
3000
|
+
},
|
|
3001
|
+
numeric_value: {
|
|
3002
|
+
key: 'error',
|
|
3003
|
+
message: 'Только числовое значение'
|
|
3004
|
+
},
|
|
3005
|
+
phone_error: {
|
|
3006
|
+
key: 'error',
|
|
3007
|
+
message: 'Введите корректный номер телефона'
|
|
3008
|
+
},
|
|
3009
|
+
email_error: {
|
|
3010
|
+
key: 'error',
|
|
3011
|
+
message: 'Введите корректный адрес электронной почты'
|
|
3012
|
+
}
|
|
3013
|
+
};
|
|
3014
|
+
|
|
2436
3015
|
Object.defineProperty(exports, "Field", {
|
|
2437
3016
|
enumerable: true,
|
|
2438
3017
|
get: function () { return reactFinalForm.Field; }
|
|
@@ -2449,6 +3028,7 @@ exports.Checkbox = CheckboxField;
|
|
|
2449
3028
|
exports.ChoiceField = ChoiceField;
|
|
2450
3029
|
exports.CodeField = CodeField;
|
|
2451
3030
|
exports.CustomField = CustomField;
|
|
3031
|
+
exports.DEFAULT_MESSAGES_FIELDS = DEFAULT_MESSAGES_FIELDS;
|
|
2452
3032
|
exports.DatePickerField = DatePickerField;
|
|
2453
3033
|
exports.FieldWrapper = FieldWrapper;
|
|
2454
3034
|
exports.FieldWrapperBase = FieldWrapperBase;
|
|
@@ -2456,6 +3036,7 @@ exports.FileInput = FileInput;
|
|
|
2456
3036
|
exports.FinalForm = FinalForm;
|
|
2457
3037
|
exports.Group = Group;
|
|
2458
3038
|
exports.InputField = InputField;
|
|
3039
|
+
exports.MaskedInputField = MaskedInputField;
|
|
2459
3040
|
exports.RadioGroup = RadioGroup;
|
|
2460
3041
|
exports.SegmentedField = SegmentedField;
|
|
2461
3042
|
exports.SelectField = SelectField;
|