@itcase/forms 1.0.59 → 1.0.60
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
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,43 +583,56 @@ 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]),
|
|
@@ -510,6 +640,7 @@ ChoiceField.propTypes = {
|
|
|
510
640
|
name: PropTypes__default.default.string,
|
|
511
641
|
options: Choice.Choice.propTypes.options,
|
|
512
642
|
placeholder: PropTypes__default.default.string,
|
|
643
|
+
showMessage: PropTypes__default.default.bool,
|
|
513
644
|
onChange: PropTypes__default.default.func
|
|
514
645
|
};
|
|
515
646
|
|
|
@@ -525,45 +656,68 @@ const CustomField = /*#__PURE__*/React__default.default.memo(function CustomFiel
|
|
|
525
656
|
showMessage
|
|
526
657
|
} = props;
|
|
527
658
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
}, ({
|
|
659
|
+
initialValue: initialValue,
|
|
660
|
+
name: name
|
|
661
|
+
}, function Render({
|
|
531
662
|
input,
|
|
532
663
|
meta
|
|
533
|
-
})
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
664
|
+
}) {
|
|
665
|
+
/** Note:
|
|
666
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
667
|
+
* React Hooks cannot be called inside a callback.
|
|
668
|
+
* React Hooks must be called in a React function component or a
|
|
669
|
+
* custom React Hook function.
|
|
670
|
+
*/
|
|
671
|
+
|
|
672
|
+
const {
|
|
673
|
+
isErrorState,
|
|
674
|
+
isValidState,
|
|
675
|
+
errorKey,
|
|
676
|
+
errorMessage
|
|
677
|
+
} = useFieldValidationState({
|
|
678
|
+
fieldProps: fieldProps,
|
|
679
|
+
input: input,
|
|
680
|
+
meta: meta
|
|
681
|
+
});
|
|
682
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
683
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
684
|
+
// For "Custom" field we pass all props. Can contain some special props, we don't known.
|
|
685
|
+
inputProps: props
|
|
686
|
+
});
|
|
687
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
688
|
+
className: clsx__default.default('form-field_type_custom', 'form__item_type_custom', classNameGroupItem),
|
|
689
|
+
errorKey: errorKey,
|
|
690
|
+
errorMessage: errorMessage,
|
|
691
|
+
fieldClassName: 'form-custom',
|
|
692
|
+
inputName: input.name,
|
|
693
|
+
inputValue: input.value,
|
|
694
|
+
isDisabled: isDisabled,
|
|
695
|
+
isErrorState: isErrorState,
|
|
696
|
+
isRequired: isRequired,
|
|
697
|
+
isValidState: isValidState,
|
|
698
|
+
metaActive: meta.active,
|
|
699
|
+
metaError: meta.error,
|
|
700
|
+
showMessage: showMessage
|
|
701
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Component, Object.assign({}, updatedInputProps, {
|
|
702
|
+
input: input,
|
|
703
|
+
isDisabled: isDisabled,
|
|
704
|
+
meta: meta
|
|
705
|
+
})));
|
|
706
|
+
});
|
|
553
707
|
});
|
|
554
708
|
CustomField.defaultProps = {
|
|
555
709
|
inputProps: {},
|
|
556
710
|
fieldProps: {}
|
|
557
711
|
};
|
|
558
712
|
CustomField.propTypes = {
|
|
559
|
-
|
|
713
|
+
name: PropTypes__default.default.string.isRequired,
|
|
560
714
|
classNameGroupItem: PropTypes__default.default.string,
|
|
715
|
+
Component: PropTypes__default.default.element,
|
|
561
716
|
fieldProps: PropTypes__default.default.object,
|
|
562
717
|
initialValue: PropTypes__default.default.any,
|
|
563
718
|
inputProps: PropTypes__default.default.object,
|
|
564
719
|
isDisabled: PropTypes__default.default.bool,
|
|
565
720
|
isRequired: PropTypes__default.default.bool,
|
|
566
|
-
name: PropTypes__default.default.string.isRequired,
|
|
567
721
|
showMessage: PropTypes__default.default.bool
|
|
568
722
|
};
|
|
569
723
|
|
|
@@ -581,33 +735,55 @@ const CodeField = /*#__PURE__*/React__default.default.memo(function CodeField(pr
|
|
|
581
735
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
582
736
|
name: name,
|
|
583
737
|
initialValue: initialValue
|
|
584
|
-
}, ({
|
|
738
|
+
}, function Render({
|
|
585
739
|
input,
|
|
586
740
|
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
|
-
|
|
741
|
+
}) {
|
|
742
|
+
/** Note:
|
|
743
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
744
|
+
* React Hooks cannot be called inside a callback.
|
|
745
|
+
* React Hooks must be called in a React function component or a
|
|
746
|
+
* custom React Hook function.
|
|
747
|
+
*/
|
|
748
|
+
|
|
749
|
+
const {
|
|
750
|
+
isErrorState,
|
|
751
|
+
isValidState,
|
|
752
|
+
errorKey,
|
|
753
|
+
errorMessage
|
|
754
|
+
} = useFieldValidationState({
|
|
755
|
+
fieldProps: fieldProps,
|
|
756
|
+
input: input,
|
|
757
|
+
meta: meta
|
|
758
|
+
});
|
|
759
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
760
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
761
|
+
inputProps: inputProps
|
|
762
|
+
});
|
|
763
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
764
|
+
className: clsx__default.default('form-field_type_code', 'form__item_type_code', classNameGroupItem),
|
|
765
|
+
fieldClassName: 'form-code',
|
|
766
|
+
inputName: input.name,
|
|
767
|
+
inputValue: input.value,
|
|
768
|
+
isRequired: isRequired,
|
|
769
|
+
isDisabled: isDisabled,
|
|
770
|
+
metaActive: meta.active,
|
|
771
|
+
metaError: meta.error,
|
|
772
|
+
showMessage: showMessage,
|
|
773
|
+
isErrorState: isErrorState,
|
|
774
|
+
isValidState: isValidState,
|
|
775
|
+
errorKey: errorKey,
|
|
776
|
+
errorMessage: errorMessage
|
|
777
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Code.Code, Object.assign({
|
|
778
|
+
autoComplete: "nope",
|
|
779
|
+
name: input.name,
|
|
780
|
+
isDisabled: isDisabled,
|
|
781
|
+
value: input.value,
|
|
782
|
+
onBlur: input.onBlur,
|
|
783
|
+
onChange: input.onChange,
|
|
784
|
+
onFocus: input.onFocus
|
|
785
|
+
}, updatedInputProps)));
|
|
786
|
+
});
|
|
611
787
|
});
|
|
612
788
|
CodeField.defaultProps = {
|
|
613
789
|
inputProps: {},
|
|
@@ -626,60 +802,72 @@ CodeField.propTypes = {
|
|
|
626
802
|
|
|
627
803
|
function DatePickerField(props) {
|
|
628
804
|
const {
|
|
629
|
-
|
|
805
|
+
classNameGroupItem,
|
|
806
|
+
datePickerProps,
|
|
630
807
|
fieldProps,
|
|
631
808
|
inputProps,
|
|
632
|
-
datePickerProps,
|
|
633
|
-
name,
|
|
634
|
-
iconSize,
|
|
635
|
-
iconBorder,
|
|
636
|
-
iconBorderHover,
|
|
637
|
-
iconFill,
|
|
638
|
-
iconFillHover,
|
|
639
809
|
isDisabled,
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
iconShape,
|
|
810
|
+
isRequired,
|
|
811
|
+
name,
|
|
643
812
|
showMessage,
|
|
644
|
-
onChange
|
|
645
|
-
classNameGroupItem
|
|
813
|
+
onChange
|
|
646
814
|
} = props;
|
|
647
815
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
648
816
|
name: name
|
|
649
|
-
}, ({
|
|
817
|
+
}, function Render({
|
|
650
818
|
input,
|
|
651
819
|
meta
|
|
652
|
-
})
|
|
820
|
+
}) {
|
|
821
|
+
/** Note:
|
|
822
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
823
|
+
* React Hooks cannot be called inside a callback.
|
|
824
|
+
* React Hooks must be called in a React function component or a
|
|
825
|
+
* custom React Hook function.
|
|
826
|
+
*/
|
|
827
|
+
|
|
653
828
|
const onChangeField = React.useCallback(value => {
|
|
654
829
|
input.onChange(value);
|
|
655
830
|
if (onChange) {
|
|
656
831
|
onChange(value, input.name);
|
|
657
832
|
}
|
|
658
|
-
}, [onChange]);
|
|
833
|
+
}, [onChange, input.onChange]);
|
|
834
|
+
const {
|
|
835
|
+
isErrorState,
|
|
836
|
+
isValidState,
|
|
837
|
+
errorKey,
|
|
838
|
+
errorMessage
|
|
839
|
+
} = useFieldValidationState({
|
|
840
|
+
fieldProps: fieldProps,
|
|
841
|
+
input: input,
|
|
842
|
+
meta: meta
|
|
843
|
+
});
|
|
844
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
845
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
846
|
+
inputProps: inputProps
|
|
847
|
+
});
|
|
659
848
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
660
849
|
className: clsx__default.default('form-field_type_datepicker', 'form__item_type_datepicker', classNameGroupItem),
|
|
850
|
+
errorKey: errorKey,
|
|
851
|
+
errorMessage: errorMessage,
|
|
661
852
|
fieldClassName: "form-datepicker",
|
|
662
853
|
inputName: input.name,
|
|
663
854
|
inputValue: input.value || '',
|
|
664
|
-
isRequired: isRequired,
|
|
665
855
|
isDisabled: isDisabled,
|
|
856
|
+
isErrorState: isErrorState,
|
|
857
|
+
isRequired: isRequired,
|
|
858
|
+
isValidState: isValidState,
|
|
666
859
|
metaActive: meta.active,
|
|
667
860
|
metaError: meta.error,
|
|
668
|
-
metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
|
|
669
|
-
metaSubmitError: meta.submitError,
|
|
670
|
-
metaSubmitFailed: meta.submitFailed,
|
|
671
|
-
metaTouched: meta.touched,
|
|
672
|
-
metaValid: meta.valid,
|
|
673
861
|
showMessage: showMessage
|
|
674
862
|
}, fieldProps), /*#__PURE__*/React__default.default.createElement(DatePicker.DatePickerInput, {
|
|
863
|
+
datePickerProps: datePickerProps,
|
|
864
|
+
inputProps: updatedInputProps,
|
|
865
|
+
isDisabled: isDisabled,
|
|
675
866
|
name: input.name,
|
|
676
867
|
value: input.value || '',
|
|
677
868
|
onBlur: input.onBlur,
|
|
678
|
-
isDisabled: isDisabled,
|
|
679
869
|
onChange: onChangeField,
|
|
680
|
-
onFocus: input.onFocus
|
|
681
|
-
inputProps: inputProps,
|
|
682
|
-
datePickerProps: datePickerProps
|
|
870
|
+
onFocus: input.onFocus
|
|
683
871
|
}));
|
|
684
872
|
});
|
|
685
873
|
}
|
|
@@ -688,10 +876,14 @@ DatePickerField.defaultProps = {
|
|
|
688
876
|
fieldProps: {}
|
|
689
877
|
};
|
|
690
878
|
DatePickerField.propTypes = {
|
|
879
|
+
name: PropTypes__default.default.string.isRequired,
|
|
880
|
+
classNameGroupItem: PropTypes__default.default.string,
|
|
881
|
+
datePickerProps: PropTypes__default.default.object,
|
|
691
882
|
fieldProps: PropTypes__default.default.object,
|
|
692
883
|
inputProps: PropTypes__default.default.object,
|
|
884
|
+
isDisabled: PropTypes__default.default.bool,
|
|
693
885
|
isRequired: PropTypes__default.default.bool,
|
|
694
|
-
|
|
886
|
+
showMessage: PropTypes__default.default.bool,
|
|
695
887
|
onChange: PropTypes__default.default.func
|
|
696
888
|
};
|
|
697
889
|
|
|
@@ -1082,7 +1274,6 @@ const FileInput = /*#__PURE__*/React__default.default.memo(function FileInput(pr
|
|
|
1082
1274
|
shape,
|
|
1083
1275
|
size,
|
|
1084
1276
|
borderWidth,
|
|
1085
|
-
borderColor,
|
|
1086
1277
|
borderColorHover,
|
|
1087
1278
|
borderType,
|
|
1088
1279
|
label,
|
|
@@ -1134,77 +1325,104 @@ const FileInput = /*#__PURE__*/React__default.default.memo(function FileInput(pr
|
|
|
1134
1325
|
} = props;
|
|
1135
1326
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1136
1327
|
name: name
|
|
1137
|
-
}, ({
|
|
1328
|
+
}, function Render({
|
|
1138
1329
|
input,
|
|
1139
1330
|
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
|
-
|
|
1331
|
+
}) {
|
|
1332
|
+
/** Note:
|
|
1333
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
1334
|
+
* React Hooks cannot be called inside a callback.
|
|
1335
|
+
* React Hooks must be called in a React function component or a
|
|
1336
|
+
* custom React Hook function.
|
|
1337
|
+
*/
|
|
1338
|
+
|
|
1339
|
+
const {
|
|
1340
|
+
isErrorState,
|
|
1341
|
+
isValidState,
|
|
1342
|
+
errorKey,
|
|
1343
|
+
errorMessage
|
|
1344
|
+
} = useFieldValidationState({
|
|
1345
|
+
fieldProps: fieldProps,
|
|
1346
|
+
input: input,
|
|
1347
|
+
meta: meta
|
|
1348
|
+
});
|
|
1349
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1350
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
1351
|
+
inputProps: props
|
|
1352
|
+
});
|
|
1353
|
+
|
|
1354
|
+
/** TODO:
|
|
1355
|
+
* REFACTOR PROPERTIES
|
|
1356
|
+
*/
|
|
1357
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1358
|
+
className: clsx__default.default('form-field_type_dropzone', 'form__item_type_dropzone', classNameGroupItem),
|
|
1359
|
+
fieldClassName: "form-dropzone",
|
|
1360
|
+
inputName: input.name,
|
|
1361
|
+
inputValue: input.value,
|
|
1362
|
+
isRequired: isRequired,
|
|
1363
|
+
label: label,
|
|
1364
|
+
labelTextColor: labelTextColor,
|
|
1365
|
+
metaActive: meta.active,
|
|
1366
|
+
metaError: meta.error,
|
|
1367
|
+
metaTouched: meta.touched,
|
|
1368
|
+
showMessage: showMessage,
|
|
1369
|
+
width: width,
|
|
1370
|
+
isErrorState: isErrorState,
|
|
1371
|
+
isValidState: isValidState,
|
|
1372
|
+
errorKey: errorKey,
|
|
1373
|
+
errorMessage: errorMessage
|
|
1374
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(FileInputDropzone, {
|
|
1375
|
+
dropzoneProps: dropzoneProps,
|
|
1376
|
+
hintDescription: hintDescription,
|
|
1377
|
+
hintTitle: hintTitle,
|
|
1378
|
+
borderWidth: borderWidth,
|
|
1379
|
+
borderColor: updatedInputProps.borderColor,
|
|
1380
|
+
borderColorHover: borderColorHover,
|
|
1381
|
+
borderType: borderType,
|
|
1382
|
+
thumbBorderWidth: thumbBorderWidth,
|
|
1383
|
+
thumbBorderColor: thumbBorderColor,
|
|
1384
|
+
thumbBorderColorHover: thumbBorderColorHover,
|
|
1385
|
+
thumbBorderType: thumbBorderType,
|
|
1386
|
+
fileErrorText: fileErrorText,
|
|
1387
|
+
fill: fill,
|
|
1388
|
+
size: size,
|
|
1389
|
+
maxFiles: maxFiles,
|
|
1390
|
+
maxSize: maxSize,
|
|
1391
|
+
removeThumbTextHoverColor: removeThumbTextHoverColor,
|
|
1392
|
+
fillHover: fillHover,
|
|
1393
|
+
className: className,
|
|
1394
|
+
thumbColumn: thumbColumn,
|
|
1395
|
+
thumbDirection: thumbDirection,
|
|
1396
|
+
inputName: input.name,
|
|
1397
|
+
inputValue: input.value,
|
|
1398
|
+
thumbNameTextSize: thumbNameTextSize,
|
|
1399
|
+
thumbNameTextColor: thumbNameTextColor,
|
|
1400
|
+
thumbNameTextWrap: thumbNameTextWrap,
|
|
1401
|
+
thumbNameTextWeight: thumbNameTextWeight,
|
|
1402
|
+
hintTitleTextSize: hintTitleTextSize,
|
|
1403
|
+
hintTitleTextColor: hintTitleTextColor,
|
|
1404
|
+
hintTitleTextWrap: hintTitleTextWrap,
|
|
1405
|
+
hintTitleTextWeight: hintTitleTextWeight,
|
|
1406
|
+
removeThumbTextSize: removeThumbTextSize,
|
|
1407
|
+
removeThumbTextColor: removeThumbTextColor,
|
|
1408
|
+
removeThumbTextWeight: removeThumbTextWeight,
|
|
1409
|
+
hintDescriptionTextSize: hintDescriptionTextSize,
|
|
1410
|
+
hintDescriptionTextColor: hintDescriptionTextColor,
|
|
1411
|
+
hintDescriptionTextWrap: hintDescriptionTextWrap,
|
|
1412
|
+
hintDescriptionTextWeight: hintDescriptionTextWeight,
|
|
1413
|
+
errorMessageTextSize: errorMessageTextSize,
|
|
1414
|
+
errorMessageWeight: errorMessageTextWeight,
|
|
1415
|
+
errorMessageTextColor: errorMessageTextColor,
|
|
1416
|
+
isPreviews: isPreviews,
|
|
1417
|
+
shape: shape,
|
|
1418
|
+
showFilename: showFilename,
|
|
1419
|
+
metaError: meta.error,
|
|
1420
|
+
metaTouched: meta.touched,
|
|
1421
|
+
removeThumbText: removeThumbText,
|
|
1422
|
+
onAddFiles: onAddFiles,
|
|
1423
|
+
onDeleteFile: onDeleteFile
|
|
1424
|
+
}));
|
|
1425
|
+
});
|
|
1208
1426
|
});
|
|
1209
1427
|
FileInput.defaultProps = {
|
|
1210
1428
|
errorMessageTextSize: 's',
|
|
@@ -1241,32 +1459,41 @@ const Group = /*#__PURE__*/React__default.default.memo(function Group(props) {
|
|
|
1241
1459
|
labelTextSize,
|
|
1242
1460
|
labelTextWeight,
|
|
1243
1461
|
message,
|
|
1244
|
-
errorMessageTextSize,
|
|
1245
|
-
errorMessageTextWeight,
|
|
1246
|
-
errorMessageTextColor,
|
|
1247
1462
|
messageTextSize,
|
|
1248
1463
|
messageTextWeight,
|
|
1249
1464
|
messageTextColor,
|
|
1250
1465
|
children,
|
|
1251
1466
|
dataTour,
|
|
1252
1467
|
showGroupMessage,
|
|
1253
|
-
name
|
|
1254
|
-
showErrorsOnSubmit
|
|
1468
|
+
name
|
|
1255
1469
|
} = props;
|
|
1256
1470
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1257
1471
|
name: name
|
|
1258
|
-
}, ({
|
|
1472
|
+
}, function Render({
|
|
1259
1473
|
input,
|
|
1260
1474
|
meta
|
|
1261
|
-
})
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1475
|
+
}) {
|
|
1476
|
+
/** Note:
|
|
1477
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
1478
|
+
* React Hooks cannot be called inside a callback.
|
|
1479
|
+
* React Hooks must be called in a React function component or a
|
|
1480
|
+
* custom React Hook function.
|
|
1481
|
+
*/
|
|
1482
|
+
const {
|
|
1483
|
+
isErrorState,
|
|
1484
|
+
isValidState,
|
|
1485
|
+
errorKey,
|
|
1486
|
+
errorMessage
|
|
1487
|
+
} = useFieldValidationState({
|
|
1488
|
+
fieldProps: props,
|
|
1489
|
+
// or fieldProps?
|
|
1490
|
+
input: input,
|
|
1491
|
+
meta: meta
|
|
1492
|
+
});
|
|
1493
|
+
const updatedProps = useValidationAppearanceInputProps({
|
|
1494
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
1495
|
+
inputProps: props
|
|
1496
|
+
});
|
|
1270
1497
|
return /*#__PURE__*/React__default.default.createElement("div", {
|
|
1271
1498
|
className: clsx__default.default('form__group', className),
|
|
1272
1499
|
"data-tour": dataTour
|
|
@@ -1275,23 +1502,23 @@ const Group = /*#__PURE__*/React__default.default.memo(function Group(props) {
|
|
|
1275
1502
|
}, before, /*#__PURE__*/React__default.default.createElement("div", {
|
|
1276
1503
|
className: "form__group-label"
|
|
1277
1504
|
}, /*#__PURE__*/React__default.default.createElement(Title.Title, {
|
|
1278
|
-
textColor: labelTextColor,
|
|
1279
1505
|
size: labelTextSize,
|
|
1506
|
+
textColor: labelTextColor,
|
|
1280
1507
|
textWeight: labelTextWeight
|
|
1281
1508
|
}, label)), /*#__PURE__*/React__default.default.createElement("div", {
|
|
1282
1509
|
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
|
-
},
|
|
1510
|
+
}, children), after), showGroupMessage && /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, isErrorState && errorMessage && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1511
|
+
className: `form__group-message form__group-message_type-${errorKey}`,
|
|
1512
|
+
id: `${name}-error`,
|
|
1513
|
+
size: updatedProps.messageTextSize,
|
|
1514
|
+
textColor: updatedProps.messageTextColor,
|
|
1515
|
+
textWeight: updatedProps.messageTextWeight
|
|
1516
|
+
}, errorMessage), Boolean(message) && (!isErrorState || !errorMessage) && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1290
1517
|
className: "form__group-message",
|
|
1291
1518
|
size: messageTextSize,
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
}, message),
|
|
1519
|
+
textColor: messageTextColor,
|
|
1520
|
+
textWeight: messageTextWeight
|
|
1521
|
+
}, message), !isErrorState && !message && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1295
1522
|
className: "form__group-message",
|
|
1296
1523
|
size: messageTextSize
|
|
1297
1524
|
}, '\u00A0')));
|
|
@@ -1308,34 +1535,34 @@ Group.defaultProps = {
|
|
|
1308
1535
|
};
|
|
1309
1536
|
Group.propTypes = {
|
|
1310
1537
|
name: PropTypes__default.default.string.isRequired,
|
|
1311
|
-
isRequired: PropTypes__default.default.bool,
|
|
1312
1538
|
fieldProps: PropTypes__default.default.object,
|
|
1313
|
-
inputProps: PropTypes__default.default.object
|
|
1539
|
+
inputProps: PropTypes__default.default.object,
|
|
1540
|
+
isRequired: PropTypes__default.default.bool
|
|
1314
1541
|
};
|
|
1315
1542
|
|
|
1316
1543
|
const InputField = /*#__PURE__*/React__default.default.memo(function InputField(props) {
|
|
1317
1544
|
const {
|
|
1318
|
-
|
|
1319
|
-
isRequired,
|
|
1545
|
+
classNameGroupItem,
|
|
1320
1546
|
fieldProps,
|
|
1321
|
-
inputProps,
|
|
1322
|
-
isRevealable,
|
|
1323
|
-
name,
|
|
1324
|
-
parse,
|
|
1325
|
-
dataTestId,
|
|
1326
|
-
iconSize,
|
|
1327
|
-
isDisabled,
|
|
1328
|
-
iconBorder,
|
|
1329
|
-
iconBorderHover,
|
|
1330
1547
|
iconFill,
|
|
1331
1548
|
iconFillHover,
|
|
1332
1549
|
iconRevealableHide,
|
|
1333
1550
|
iconRevealableShow,
|
|
1334
1551
|
iconShape,
|
|
1552
|
+
iconSize,
|
|
1335
1553
|
initialValue,
|
|
1554
|
+
inputProps,
|
|
1555
|
+
isDisabled,
|
|
1556
|
+
isPassword,
|
|
1557
|
+
isRequired,
|
|
1558
|
+
isRevealable,
|
|
1559
|
+
name,
|
|
1560
|
+
parse,
|
|
1336
1561
|
showMessage,
|
|
1337
|
-
onChange
|
|
1338
|
-
|
|
1562
|
+
onChange
|
|
1563
|
+
// dataTestId,
|
|
1564
|
+
// iconBorder,
|
|
1565
|
+
// iconBorderHover,
|
|
1339
1566
|
} = props;
|
|
1340
1567
|
const [isRevealed, setIsRevealed] = React.useState(false);
|
|
1341
1568
|
const inputType = React.useMemo(() => {
|
|
@@ -1345,59 +1572,79 @@ const InputField = /*#__PURE__*/React__default.default.memo(function InputField(
|
|
|
1345
1572
|
return 'text';
|
|
1346
1573
|
}
|
|
1347
1574
|
}, [isRevealed, isPassword]);
|
|
1348
|
-
const
|
|
1349
|
-
|
|
1575
|
+
const onClickIconReveal = React.useCallback(event => {
|
|
1576
|
+
event.preventDefault();
|
|
1350
1577
|
setIsRevealed(prev => !prev);
|
|
1351
|
-
}, [
|
|
1578
|
+
}, []);
|
|
1352
1579
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1580
|
+
initialValue: initialValue,
|
|
1353
1581
|
name: name,
|
|
1354
|
-
parse: parse
|
|
1355
|
-
|
|
1356
|
-
}, ({
|
|
1582
|
+
parse: parse
|
|
1583
|
+
}, function Render({
|
|
1357
1584
|
input,
|
|
1358
1585
|
meta
|
|
1359
|
-
})
|
|
1586
|
+
}) {
|
|
1587
|
+
/** Note:
|
|
1588
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
1589
|
+
* React Hooks cannot be called inside a callback.
|
|
1590
|
+
* React Hooks must be called in a React function component or a
|
|
1591
|
+
* custom React Hook function.
|
|
1592
|
+
*/
|
|
1593
|
+
|
|
1360
1594
|
const onChangeField = React.useCallback(event => {
|
|
1361
1595
|
input.onChange(event);
|
|
1362
1596
|
if (onChange) {
|
|
1363
1597
|
onChange(event.target.value, input.name);
|
|
1364
1598
|
}
|
|
1365
|
-
}, [onChange]);
|
|
1599
|
+
}, [onChange, input.onChange]);
|
|
1600
|
+
const {
|
|
1601
|
+
isErrorState,
|
|
1602
|
+
isValidState,
|
|
1603
|
+
errorKey,
|
|
1604
|
+
errorMessage
|
|
1605
|
+
} = useFieldValidationState({
|
|
1606
|
+
fieldProps: fieldProps,
|
|
1607
|
+
input: input,
|
|
1608
|
+
meta: meta
|
|
1609
|
+
});
|
|
1610
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1611
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
1612
|
+
inputProps: inputProps
|
|
1613
|
+
});
|
|
1366
1614
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1367
1615
|
className: clsx__default.default('form-field_type_input', 'form__item_type_input', classNameGroupItem),
|
|
1616
|
+
errorKey: errorKey,
|
|
1617
|
+
errorMessage: errorMessage,
|
|
1368
1618
|
fieldClassName: isRevealable ? 'form-password' : 'form-input',
|
|
1369
1619
|
inputName: input.name,
|
|
1370
1620
|
inputValue: input.value || '',
|
|
1371
|
-
isRequired: isRequired,
|
|
1372
1621
|
isDisabled: isDisabled,
|
|
1622
|
+
isErrorState: isErrorState,
|
|
1623
|
+
isRequired: isRequired,
|
|
1624
|
+
isValidState: isValidState,
|
|
1373
1625
|
metaActive: meta.active,
|
|
1374
1626
|
metaError: meta.error,
|
|
1375
|
-
metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
|
|
1376
|
-
metaSubmitError: meta.submitError,
|
|
1377
|
-
metaSubmitFailed: meta.submitFailed,
|
|
1378
|
-
metaTouched: meta.touched,
|
|
1379
|
-
metaValid: meta.valid,
|
|
1380
1627
|
showMessage: showMessage
|
|
1381
1628
|
}, 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
1629
|
autoComplete: "nope",
|
|
1630
|
+
className: clsx__default.default(meta.active && 'input_state_focus', meta.error && meta.touched && `input_state_${errorKey}`),
|
|
1631
|
+
dataTestId: `${input.name}FieldInput`,
|
|
1632
|
+
isDisabled: isDisabled,
|
|
1384
1633
|
name: input.name,
|
|
1385
1634
|
type: inputType,
|
|
1386
1635
|
value: input.value || '',
|
|
1387
1636
|
onBlur: input.onBlur,
|
|
1388
1637
|
onChange: onChangeField,
|
|
1389
|
-
onFocus: input.onFocus
|
|
1390
|
-
|
|
1391
|
-
dataTestId: `${input.name}FieldInput`
|
|
1392
|
-
}, inputProps)), isRevealable && /*#__PURE__*/React__default.default.createElement(Icon.Icon, {
|
|
1638
|
+
onFocus: input.onFocus
|
|
1639
|
+
}, updatedInputProps)), isRevealable && /*#__PURE__*/React__default.default.createElement(Icon.Icon, {
|
|
1393
1640
|
className: "form-field__icon",
|
|
1394
1641
|
iconFill: iconFill,
|
|
1395
1642
|
iconFillHover: iconFillHover,
|
|
1396
|
-
SvgImage: isRevealed ? iconRevealableHide : iconRevealableShow,
|
|
1397
1643
|
imageSrc: isRevealed ? iconRevealableHide : iconRevealableShow,
|
|
1398
1644
|
shape: iconShape,
|
|
1399
1645
|
size: iconSize,
|
|
1400
|
-
|
|
1646
|
+
SvgImage: isRevealed ? iconRevealableHide : iconRevealableShow,
|
|
1647
|
+
onClick: onClickIconReveal
|
|
1401
1648
|
}));
|
|
1402
1649
|
});
|
|
1403
1650
|
});
|
|
@@ -1406,13 +1653,26 @@ InputField.defaultProps = {
|
|
|
1406
1653
|
fieldProps: {}
|
|
1407
1654
|
};
|
|
1408
1655
|
InputField.propTypes = {
|
|
1656
|
+
name: PropTypes__default.default.string.isRequired,
|
|
1657
|
+
classNameGroupItem: PropTypes__default.default.string,
|
|
1658
|
+
dataTestId: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number]),
|
|
1409
1659
|
fieldProps: PropTypes__default.default.object,
|
|
1660
|
+
iconBorder: PropTypes__default.default.string,
|
|
1661
|
+
iconBorderHover: PropTypes__default.default.string,
|
|
1662
|
+
iconFill: PropTypes__default.default.string,
|
|
1663
|
+
iconFillHover: PropTypes__default.default.string,
|
|
1664
|
+
iconRevealableHide: PropTypes__default.default.oneOfType([PropTypes__default.default.elementType, PropTypes__default.default.func, PropTypes__default.default.object]),
|
|
1665
|
+
iconRevealableShow: PropTypes__default.default.oneOfType([PropTypes__default.default.elementType, PropTypes__default.default.func, PropTypes__default.default.object]),
|
|
1666
|
+
iconShape: PropTypes__default.default.oneOf(shapeProps__default.default),
|
|
1667
|
+
iconSize: PropTypes__default.default.oneOf(iconSizeProps__default.default),
|
|
1410
1668
|
initialValue: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number]),
|
|
1411
1669
|
inputProps: PropTypes__default.default.object,
|
|
1670
|
+
isDisabled: PropTypes__default.default.bool,
|
|
1412
1671
|
isPassword: PropTypes__default.default.bool,
|
|
1413
1672
|
isRequired: PropTypes__default.default.bool,
|
|
1414
1673
|
isRevealable: PropTypes__default.default.bool,
|
|
1415
|
-
|
|
1674
|
+
parse: PropTypes__default.default.func,
|
|
1675
|
+
showMessage: PropTypes__default.default.bool,
|
|
1416
1676
|
onChange: PropTypes__default.default.func
|
|
1417
1677
|
};
|
|
1418
1678
|
|
|
@@ -1569,32 +1829,54 @@ const RadioGroup = /*#__PURE__*/React__default.default.memo(function RadioGroup(
|
|
|
1569
1829
|
} = props;
|
|
1570
1830
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1571
1831
|
name: name
|
|
1572
|
-
}, ({
|
|
1832
|
+
}, function Render({
|
|
1573
1833
|
input,
|
|
1574
1834
|
meta
|
|
1575
|
-
})
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1835
|
+
}) {
|
|
1836
|
+
/** Note:
|
|
1837
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
1838
|
+
* React Hooks cannot be called inside a callback.
|
|
1839
|
+
* React Hooks must be called in a React function component or a
|
|
1840
|
+
* custom React Hook function.
|
|
1841
|
+
*/
|
|
1842
|
+
|
|
1843
|
+
const {
|
|
1844
|
+
isErrorState,
|
|
1845
|
+
isValidState,
|
|
1846
|
+
errorKey,
|
|
1847
|
+
errorMessage
|
|
1848
|
+
} = useFieldValidationState({
|
|
1849
|
+
fieldProps: fieldProps,
|
|
1850
|
+
input: input,
|
|
1851
|
+
meta: meta
|
|
1852
|
+
});
|
|
1853
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1854
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
1855
|
+
inputProps: inputProps
|
|
1856
|
+
});
|
|
1857
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1858
|
+
className: "form__item_type_radio",
|
|
1859
|
+
errorKey: errorKey,
|
|
1860
|
+
errorMessage: errorMessage,
|
|
1861
|
+
fieldClassName: 'form-radio',
|
|
1862
|
+
inputName: input.name,
|
|
1863
|
+
inputValue: input.value || '',
|
|
1864
|
+
isDisabled: isDisabled,
|
|
1865
|
+
isErrorState: isErrorState,
|
|
1866
|
+
isRequired: isRequired,
|
|
1867
|
+
isValidState: isValidState,
|
|
1868
|
+
metaActive: meta.active,
|
|
1869
|
+
metaError: meta.error,
|
|
1870
|
+
showMessage: showMessage
|
|
1871
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(RadioGroupList, {
|
|
1872
|
+
editableProps: editableProps,
|
|
1873
|
+
input: input,
|
|
1874
|
+
inputProps: updatedInputProps,
|
|
1875
|
+
isDisabled: isDisabled,
|
|
1876
|
+
options: options,
|
|
1877
|
+
onChange: onChange
|
|
1878
|
+
}));
|
|
1879
|
+
});
|
|
1598
1880
|
});
|
|
1599
1881
|
RadioGroup.defaultProps = {
|
|
1600
1882
|
editableProps: {},
|
|
@@ -1603,12 +1885,12 @@ RadioGroup.defaultProps = {
|
|
|
1603
1885
|
options: []
|
|
1604
1886
|
};
|
|
1605
1887
|
RadioGroup.propTypes = {
|
|
1888
|
+
name: PropTypes__default.default.string.isRequired,
|
|
1606
1889
|
editableProps: PropTypes__default.default.object,
|
|
1607
1890
|
fieldProps: PropTypes__default.default.object,
|
|
1608
1891
|
inputProps: PropTypes__default.default.object,
|
|
1609
1892
|
isDisabled: PropTypes__default.default.bool,
|
|
1610
1893
|
isRequired: PropTypes__default.default.bool,
|
|
1611
|
-
name: PropTypes__default.default.string.isRequired,
|
|
1612
1894
|
options: PropTypes__default.default.array,
|
|
1613
1895
|
showMessage: PropTypes__default.default.bool,
|
|
1614
1896
|
onChange: PropTypes__default.default.func
|
|
@@ -1632,10 +1914,17 @@ function SegmentedField(props) {
|
|
|
1632
1914
|
}, [change]);
|
|
1633
1915
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1634
1916
|
name: name
|
|
1635
|
-
}, ({
|
|
1917
|
+
}, function Render({
|
|
1636
1918
|
input,
|
|
1637
1919
|
meta
|
|
1638
|
-
})
|
|
1920
|
+
}) {
|
|
1921
|
+
/** Note:
|
|
1922
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
1923
|
+
* React Hooks cannot be called inside a callback.
|
|
1924
|
+
* React Hooks must be called in a React function component or a
|
|
1925
|
+
* custom React Hook function.
|
|
1926
|
+
*/
|
|
1927
|
+
|
|
1639
1928
|
const activeOption = React.useMemo(() => {
|
|
1640
1929
|
const emptyOption = {
|
|
1641
1930
|
value: null,
|
|
@@ -1647,30 +1936,45 @@ function SegmentedField(props) {
|
|
|
1647
1936
|
}
|
|
1648
1937
|
return emptyOption;
|
|
1649
1938
|
}, [input.value]);
|
|
1939
|
+
const {
|
|
1940
|
+
isErrorState,
|
|
1941
|
+
isValidState,
|
|
1942
|
+
errorKey,
|
|
1943
|
+
errorMessage
|
|
1944
|
+
} = useFieldValidationState({
|
|
1945
|
+
fieldProps: fieldProps,
|
|
1946
|
+
input: input,
|
|
1947
|
+
meta: meta
|
|
1948
|
+
});
|
|
1949
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1950
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
1951
|
+
inputProps: inputProps
|
|
1952
|
+
});
|
|
1650
1953
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1651
1954
|
className: clsx__default.default('form-field_type_segmented', 'form__item_type_segmented'),
|
|
1955
|
+
errorKey: errorKey,
|
|
1956
|
+
errorMessage: errorMessage,
|
|
1652
1957
|
fieldClassName: "form-segmented",
|
|
1653
1958
|
inputName: input.name,
|
|
1654
1959
|
inputValue: input.value || [],
|
|
1655
|
-
isRequired: isRequired,
|
|
1656
1960
|
isDisabled: isDisabled,
|
|
1961
|
+
isErrorState: isErrorState,
|
|
1962
|
+
isRequired: isRequired,
|
|
1963
|
+
isValidState: isValidState,
|
|
1657
1964
|
metaActive: meta.active,
|
|
1658
1965
|
metaError: meta.error,
|
|
1659
|
-
metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
|
|
1660
|
-
metaSubmitError: meta.submitError,
|
|
1661
|
-
metaSubmitFailed: meta.submitFailed,
|
|
1662
|
-
metaTouched: meta.touched,
|
|
1663
|
-
metaValid: meta.valid,
|
|
1664
1966
|
showMessage: showMessage
|
|
1665
1967
|
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Segmented.Segmented, Object.assign({
|
|
1666
|
-
|
|
1968
|
+
activeSegment: activeOption,
|
|
1667
1969
|
isDisabled: isDisabled,
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
},
|
|
1970
|
+
segments: options,
|
|
1971
|
+
setActiveSegment: setActiveSegment
|
|
1972
|
+
}, updatedInputProps)));
|
|
1671
1973
|
});
|
|
1672
1974
|
}
|
|
1673
1975
|
SegmentedField.propTypes = {
|
|
1976
|
+
name: PropTypes__default.default.string.isRequired,
|
|
1977
|
+
options: PropTypes__default.default.array.isRequired,
|
|
1674
1978
|
className: PropTypes__default.default.string,
|
|
1675
1979
|
fieldProps: PropTypes__default.default.object,
|
|
1676
1980
|
inputClass: PropTypes__default.default.string,
|
|
@@ -1678,8 +1982,6 @@ SegmentedField.propTypes = {
|
|
|
1678
1982
|
isDisabled: PropTypes__default.default.bool,
|
|
1679
1983
|
isRequired: PropTypes__default.default.bool,
|
|
1680
1984
|
label: PropTypes__default.default.string,
|
|
1681
|
-
name: PropTypes__default.default.string.isRequired,
|
|
1682
|
-
options: PropTypes__default.default.array.isRequired,
|
|
1683
1985
|
placeholder: PropTypes__default.default.string,
|
|
1684
1986
|
showMessage: PropTypes__default.default.bool
|
|
1685
1987
|
};
|
|
@@ -1717,10 +2019,16 @@ const SelectField = /*#__PURE__*/React__default.default.memo(function SelectFiel
|
|
|
1717
2019
|
} = props;
|
|
1718
2020
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1719
2021
|
name: name
|
|
1720
|
-
}, ({
|
|
2022
|
+
}, function Render({
|
|
1721
2023
|
input,
|
|
1722
2024
|
meta
|
|
1723
|
-
})
|
|
2025
|
+
}) {
|
|
2026
|
+
/** Note:
|
|
2027
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
2028
|
+
* React Hooks cannot be called inside a callback.
|
|
2029
|
+
* React Hooks must be called in a React function component or a
|
|
2030
|
+
* custom React Hook function.
|
|
2031
|
+
*/
|
|
1724
2032
|
const [selectedOptions, setSelectedOptions] = React.useState(null);
|
|
1725
2033
|
const defaultValue = React.useMemo(() => {
|
|
1726
2034
|
const optionsValues = getDefaultValue(options, input.value);
|
|
@@ -1737,47 +2045,60 @@ const SelectField = /*#__PURE__*/React__default.default.memo(function SelectFiel
|
|
|
1737
2045
|
if (onChange) {
|
|
1738
2046
|
onChange(value, input.name);
|
|
1739
2047
|
}
|
|
1740
|
-
}, [onChange]);
|
|
2048
|
+
}, [onChange, input.onChange]);
|
|
1741
2049
|
const onChangeValue = React.useCallback((option, actionMeta) => {
|
|
1742
2050
|
const value = Array.isArray(option) ? option.map(o => o.value) : option?.value || null;
|
|
1743
2051
|
setSelectedOptions(option);
|
|
1744
2052
|
onChangeField(value);
|
|
1745
2053
|
}, [onChangeField]);
|
|
1746
2054
|
React.useEffect(() => setSelectedOptions(defaultValue), [defaultValue]);
|
|
2055
|
+
const {
|
|
2056
|
+
isErrorState,
|
|
2057
|
+
isValidState,
|
|
2058
|
+
errorKey,
|
|
2059
|
+
errorMessage
|
|
2060
|
+
} = useFieldValidationState({
|
|
2061
|
+
fieldProps: fieldProps,
|
|
2062
|
+
input: input,
|
|
2063
|
+
meta: meta
|
|
2064
|
+
});
|
|
2065
|
+
const updatedSelectProps = useValidationAppearanceInputProps({
|
|
2066
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
2067
|
+
inputProps: selectProps
|
|
2068
|
+
});
|
|
1747
2069
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1748
2070
|
className: clsx__default.default('form-field_type_select', 'form__item_type_select', classNameGroupItem),
|
|
2071
|
+
errorKey: errorKey,
|
|
2072
|
+
errorMessage: errorMessage,
|
|
1749
2073
|
fieldClassName: 'form-select',
|
|
1750
2074
|
inputName: input.name,
|
|
1751
2075
|
inputValue: input.value,
|
|
1752
|
-
isRequired: isRequired,
|
|
1753
2076
|
isDisabled: isDisabled,
|
|
2077
|
+
isErrorState: isErrorState,
|
|
2078
|
+
isRequired: isRequired,
|
|
2079
|
+
isValidState: isValidState,
|
|
1754
2080
|
metaActive: meta.active,
|
|
1755
2081
|
metaError: meta.error,
|
|
1756
|
-
metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
|
|
1757
|
-
metaSubmitError: meta.submitError,
|
|
1758
|
-
metaSubmitFailed: meta.submitFailed,
|
|
1759
|
-
metaTouched: meta.touched,
|
|
1760
|
-
metaValid: meta.valid,
|
|
1761
2082
|
showMessage: showMessage
|
|
1762
2083
|
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Select.Select, Object.assign({
|
|
1763
2084
|
className: "form-select-item",
|
|
1764
2085
|
instanceId: `id_${input.name}`,
|
|
1765
|
-
value: selectedOptions,
|
|
1766
|
-
onChange: onChangeValue,
|
|
1767
2086
|
isDisabled: isDisabled,
|
|
1768
2087
|
options: options,
|
|
1769
|
-
ref: selectRef
|
|
1770
|
-
|
|
2088
|
+
ref: selectRef,
|
|
2089
|
+
value: selectedOptions,
|
|
2090
|
+
onChange: onChangeValue
|
|
2091
|
+
}, updatedSelectProps)));
|
|
1771
2092
|
});
|
|
1772
2093
|
});
|
|
1773
2094
|
SelectField.propTypes = {
|
|
2095
|
+
name: PropTypes__default.default.string.isRequired,
|
|
1774
2096
|
classNameGroupItem: PropTypes__default.default.string,
|
|
1775
2097
|
fieldProps: PropTypes__default.default.object,
|
|
1776
2098
|
isDisabled: PropTypes__default.default.bool,
|
|
1777
2099
|
isRequired: PropTypes__default.default.bool,
|
|
1778
2100
|
label: PropTypes__default.default.any,
|
|
1779
2101
|
messageType: PropTypes__default.default.string,
|
|
1780
|
-
name: PropTypes__default.default.string.isRequired,
|
|
1781
2102
|
options: PropTypes__default.default.array,
|
|
1782
2103
|
selectProps: PropTypes__default.default.object,
|
|
1783
2104
|
selectRef: PropTypes__default.default.any,
|
|
@@ -1799,42 +2120,62 @@ const SwitchField = /*#__PURE__*/React__default.default.memo(function SwitchFiel
|
|
|
1799
2120
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1800
2121
|
name: name,
|
|
1801
2122
|
type: "checkbox"
|
|
1802
|
-
}, ({
|
|
2123
|
+
}, function Render({
|
|
1803
2124
|
input,
|
|
1804
2125
|
meta
|
|
1805
|
-
})
|
|
2126
|
+
}) {
|
|
2127
|
+
/** Note:
|
|
2128
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
2129
|
+
* React Hooks cannot be called inside a callback.
|
|
2130
|
+
* React Hooks must be called in a React function component or a
|
|
2131
|
+
* custom React Hook function.
|
|
2132
|
+
*/
|
|
2133
|
+
|
|
1806
2134
|
const onChangeField = React.useCallback(event => {
|
|
1807
2135
|
input.onChange(event);
|
|
1808
2136
|
if (onChange) {
|
|
1809
2137
|
onChange(event.target.checked, input.name);
|
|
1810
2138
|
}
|
|
1811
|
-
}, [onChange]);
|
|
2139
|
+
}, [onChange, input.onChange]);
|
|
2140
|
+
const {
|
|
2141
|
+
isErrorState,
|
|
2142
|
+
isValidState,
|
|
2143
|
+
errorKey,
|
|
2144
|
+
errorMessage
|
|
2145
|
+
} = useFieldValidationState({
|
|
2146
|
+
fieldProps: fieldProps,
|
|
2147
|
+
input: input,
|
|
2148
|
+
meta: meta
|
|
2149
|
+
});
|
|
2150
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
2151
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
2152
|
+
inputProps: inputProps
|
|
2153
|
+
});
|
|
1812
2154
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1813
2155
|
className: clsx__default.default('form-field_type_switch', 'form__item_type_switch', classNameGroupItem),
|
|
2156
|
+
errorKey: errorKey,
|
|
2157
|
+
errorMessage: errorMessage,
|
|
1814
2158
|
fieldClassName: "form-switch",
|
|
1815
2159
|
inputName: input.name,
|
|
1816
2160
|
inputValue: input.checked,
|
|
1817
|
-
isRequired: isRequired,
|
|
1818
2161
|
isDisabled: isDisabled,
|
|
2162
|
+
isErrorState: isErrorState,
|
|
2163
|
+
isRequired: isRequired,
|
|
2164
|
+
isValidState: isValidState,
|
|
1819
2165
|
metaActive: meta.active,
|
|
1820
2166
|
metaError: meta.error,
|
|
1821
|
-
metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
|
|
1822
|
-
metaSubmitError: meta.submitError,
|
|
1823
|
-
metaSubmitFailed: meta.submitFailed,
|
|
1824
|
-
metaTouched: meta.touched,
|
|
1825
|
-
metaValid: meta.valid,
|
|
1826
2167
|
showMessage: showMessage,
|
|
1827
2168
|
tag: "label"
|
|
1828
2169
|
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Switch.Switch, Object.assign({
|
|
1829
2170
|
autoComplete: "nope",
|
|
1830
|
-
isDisabled: isDisabled,
|
|
1831
2171
|
checked: input.checked,
|
|
2172
|
+
isDisabled: isDisabled,
|
|
1832
2173
|
name: input.name,
|
|
1833
2174
|
type: "checkbox",
|
|
1834
2175
|
onBlur: input.onBlur,
|
|
1835
2176
|
onChange: onChangeField,
|
|
1836
2177
|
onFocus: input.onFocus
|
|
1837
|
-
},
|
|
2178
|
+
}, updatedInputProps)));
|
|
1838
2179
|
});
|
|
1839
2180
|
});
|
|
1840
2181
|
SwitchField.defaultProps = {
|
|
@@ -1864,48 +2205,168 @@ const TextareaField = /*#__PURE__*/React__default.default.memo(function Textarea
|
|
|
1864
2205
|
} = props;
|
|
1865
2206
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1866
2207
|
name: name
|
|
1867
|
-
}, ({
|
|
2208
|
+
}, function Render({
|
|
1868
2209
|
input,
|
|
1869
2210
|
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
|
-
|
|
2211
|
+
}) {
|
|
2212
|
+
/** Note:
|
|
2213
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
2214
|
+
* React Hooks cannot be called inside a callback.
|
|
2215
|
+
* React Hooks must be called in a React function component or a
|
|
2216
|
+
* custom React Hook function.
|
|
2217
|
+
*/
|
|
2218
|
+
|
|
2219
|
+
const {
|
|
2220
|
+
isErrorState,
|
|
2221
|
+
isValidState,
|
|
2222
|
+
errorKey,
|
|
2223
|
+
errorMessage
|
|
2224
|
+
} = useFieldValidationState({
|
|
2225
|
+
fieldProps: fieldProps,
|
|
2226
|
+
input: input,
|
|
2227
|
+
meta: meta
|
|
2228
|
+
});
|
|
2229
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
2230
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
2231
|
+
inputProps: inputProps
|
|
2232
|
+
});
|
|
2233
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
2234
|
+
className: clsx__default.default('form-field_type_textarea', 'form__item_type_textarea', classNameGroupItem),
|
|
2235
|
+
errorKey: errorKey,
|
|
2236
|
+
errorMessage: errorMessage,
|
|
2237
|
+
fieldClassName: 'form-textarea',
|
|
2238
|
+
inputName: input.name,
|
|
2239
|
+
inputValue: input.value,
|
|
2240
|
+
isDisabled: isDisabled,
|
|
2241
|
+
isErrorState: isErrorState,
|
|
2242
|
+
isRequired: isRequired,
|
|
2243
|
+
isValidState: isValidState,
|
|
2244
|
+
metaActive: meta.active,
|
|
2245
|
+
metaError: meta.error,
|
|
2246
|
+
showMessage: showMessage
|
|
2247
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Textarea.Textarea, Object.assign({
|
|
2248
|
+
autoComplete: "nope",
|
|
2249
|
+
isDisabled: isDisabled,
|
|
2250
|
+
name: input.name,
|
|
2251
|
+
value: input.value,
|
|
2252
|
+
onBlur: input.onBlur,
|
|
2253
|
+
onChange: input.onChange,
|
|
2254
|
+
onFocus: input.onFocus
|
|
2255
|
+
}, updatedInputProps)));
|
|
2256
|
+
});
|
|
1894
2257
|
});
|
|
1895
2258
|
TextareaField.defaultProps = {
|
|
1896
2259
|
inputProps: {},
|
|
1897
2260
|
fieldProps: {}
|
|
1898
2261
|
};
|
|
1899
2262
|
TextareaField.propTypes = {
|
|
2263
|
+
name: PropTypes__default.default.string.isRequired,
|
|
1900
2264
|
classNameGroupItem: PropTypes__default.default.string,
|
|
1901
2265
|
fieldProps: PropTypes__default.default.object,
|
|
1902
2266
|
inputProps: PropTypes__default.default.object,
|
|
1903
2267
|
isDisabled: PropTypes__default.default.bool,
|
|
1904
2268
|
isRequired: PropTypes__default.default.bool,
|
|
1905
|
-
name: PropTypes__default.default.string.isRequired,
|
|
1906
2269
|
showMessage: PropTypes__default.default.bool
|
|
1907
2270
|
};
|
|
1908
2271
|
|
|
2272
|
+
const MaskedInputField = /*#__PURE__*/React__default.default.memo(function MaskedInputField(props) {
|
|
2273
|
+
const {
|
|
2274
|
+
isDisabled,
|
|
2275
|
+
isRequired,
|
|
2276
|
+
name,
|
|
2277
|
+
initialValue,
|
|
2278
|
+
fieldProps,
|
|
2279
|
+
classNameGroupItem,
|
|
2280
|
+
showMessage,
|
|
2281
|
+
inputProps,
|
|
2282
|
+
optionsMask,
|
|
2283
|
+
unmasked
|
|
2284
|
+
} = props;
|
|
2285
|
+
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
2286
|
+
initialValue: initialValue,
|
|
2287
|
+
name: name
|
|
2288
|
+
}, function Render({
|
|
2289
|
+
input,
|
|
2290
|
+
meta
|
|
2291
|
+
}) {
|
|
2292
|
+
/** Note:
|
|
2293
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
2294
|
+
* React Hooks cannot be called inside a callback.
|
|
2295
|
+
* React Hooks must be called in a React function component or a
|
|
2296
|
+
* custom React Hook function.
|
|
2297
|
+
*/
|
|
2298
|
+
|
|
2299
|
+
const {
|
|
2300
|
+
ref,
|
|
2301
|
+
value,
|
|
2302
|
+
unmaskedValue,
|
|
2303
|
+
setUnmaskedValue
|
|
2304
|
+
} = reactImask.useIMask(optionsMask, {
|
|
2305
|
+
onAccept: (newValue, event, element) => {
|
|
2306
|
+
if (element) {
|
|
2307
|
+
input.onChange(event._unmaskedValue);
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
});
|
|
2311
|
+
React.useEffect(() => {
|
|
2312
|
+
if (input.value !== unmaskedValue) {
|
|
2313
|
+
setUnmaskedValue(input.value.replace(unmasked, ''));
|
|
2314
|
+
}
|
|
2315
|
+
}, [input.value]);
|
|
2316
|
+
const {
|
|
2317
|
+
isErrorState,
|
|
2318
|
+
isValidState,
|
|
2319
|
+
errorKey,
|
|
2320
|
+
errorMessage
|
|
2321
|
+
} = useFieldValidationState({
|
|
2322
|
+
fieldProps: fieldProps,
|
|
2323
|
+
input: input,
|
|
2324
|
+
meta: meta
|
|
2325
|
+
});
|
|
2326
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
2327
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
2328
|
+
inputProps: inputProps
|
|
2329
|
+
});
|
|
2330
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
2331
|
+
className: clsx__default.default('form-field_type_maskedInput', 'form__item_type_maskedInput', classNameGroupItem),
|
|
2332
|
+
errorKey: errorKey,
|
|
2333
|
+
errorMessage: errorMessage,
|
|
2334
|
+
fieldClassName: 'form-maskedInput',
|
|
2335
|
+
inputName: input.name,
|
|
2336
|
+
inputValue: input.value,
|
|
2337
|
+
isDisabled: isDisabled,
|
|
2338
|
+
isErrorState: isErrorState,
|
|
2339
|
+
isRequired: isRequired,
|
|
2340
|
+
isValidState: isValidState,
|
|
2341
|
+
metaActive: meta.active,
|
|
2342
|
+
metaError: meta.error,
|
|
2343
|
+
showMessage: showMessage
|
|
2344
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Input.Input, Object.assign({
|
|
2345
|
+
className: clsx__default.default(meta.active && 'input_state_focus', meta.error && meta.touched && `input_state_${errorKey}`),
|
|
2346
|
+
ref: ref,
|
|
2347
|
+
value: value,
|
|
2348
|
+
onBlur: input.onBlur,
|
|
2349
|
+
onFocus: input.onFocus
|
|
2350
|
+
}, updatedInputProps)));
|
|
2351
|
+
});
|
|
2352
|
+
});
|
|
2353
|
+
MaskedInputField.defaultProps = {
|
|
2354
|
+
inputProps: {},
|
|
2355
|
+
fieldProps: {}
|
|
2356
|
+
};
|
|
2357
|
+
MaskedInputField.propTypes = {
|
|
2358
|
+
name: PropTypes__default.default.string.isRequired,
|
|
2359
|
+
classNameGroupItem: PropTypes__default.default.string,
|
|
2360
|
+
fieldProps: PropTypes__default.default.object,
|
|
2361
|
+
initialValue: PropTypes__default.default.any,
|
|
2362
|
+
inputProps: PropTypes__default.default.object,
|
|
2363
|
+
isDisabled: PropTypes__default.default.bool,
|
|
2364
|
+
isRequired: PropTypes__default.default.bool,
|
|
2365
|
+
optionsMask: PropTypes__default.default.object,
|
|
2366
|
+
showMessage: PropTypes__default.default.bool,
|
|
2367
|
+
unmasked: PropTypes__default.default.string
|
|
2368
|
+
};
|
|
2369
|
+
|
|
1909
2370
|
const focusOnError = (formElementsList, errors) => {
|
|
1910
2371
|
const selectsIds = Object.keys(errors).map(fieldName => {
|
|
1911
2372
|
if (fieldName === finalForm.FORM_ERROR) {
|
|
@@ -2030,7 +2491,8 @@ const formTypes = {
|
|
|
2030
2491
|
select: 'select',
|
|
2031
2492
|
switch: 'switch',
|
|
2032
2493
|
text: 'text',
|
|
2033
|
-
textarea: 'textarea'
|
|
2494
|
+
textarea: 'textarea',
|
|
2495
|
+
maskedInput: 'maskedInput'
|
|
2034
2496
|
};
|
|
2035
2497
|
function generateField(field, config, props) {
|
|
2036
2498
|
switch (field.type) {
|
|
@@ -2100,6 +2562,12 @@ function generateField(field, config, props) {
|
|
|
2100
2562
|
key: config.key
|
|
2101
2563
|
}, field, props));
|
|
2102
2564
|
}
|
|
2565
|
+
case formTypes.maskedInput:
|
|
2566
|
+
{
|
|
2567
|
+
return /*#__PURE__*/React__default.default.createElement(MaskedInputField, Object.assign({
|
|
2568
|
+
key: config.key
|
|
2569
|
+
}, field, props));
|
|
2570
|
+
}
|
|
2103
2571
|
case formTypes.custom:
|
|
2104
2572
|
{
|
|
2105
2573
|
return /*#__PURE__*/React__default.default.createElement(CustomField, Object.assign({
|
|
@@ -2433,6 +2901,118 @@ FinalForm.defaultProps = {
|
|
|
2433
2901
|
disableFieldsAutoComplete: false
|
|
2434
2902
|
};
|
|
2435
2903
|
|
|
2904
|
+
const DEFAULT_MESSAGES_FIELDS = {
|
|
2905
|
+
/*
|
|
2906
|
+
!!! it also works without props simply based on the class and key as before `input_state_${meta.error.key}`
|
|
2907
|
+
the KEY is needed for example for border color
|
|
2908
|
+
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
|
|
2909
|
+
...example
|
|
2910
|
+
required - KEY for yellow color
|
|
2911
|
+
error - KEY for red color
|
|
2912
|
+
custom or blue - KEY blue or other color
|
|
2913
|
+
requiredBorderColor: 'warningBorderPrimary',
|
|
2914
|
+
errorBorderColor: 'errorBorderPrimary',
|
|
2915
|
+
customBorderColor: 'customBorderPrimary',
|
|
2916
|
+
blueBorderColor: 'blueBorderPrimary',
|
|
2917
|
+
const defaultFieldProps = {
|
|
2918
|
+
messageTextSize: 's',
|
|
2919
|
+
messageTextColor: 'surfaceTextSecondary',
|
|
2920
|
+
requiredMessageTextSize: 's',
|
|
2921
|
+
requiredMessageTextColor: 'warningTextPrimary',
|
|
2922
|
+
errorMessageTextSize: 's',
|
|
2923
|
+
errorMessageTextColor: 'errorTextPrimary',
|
|
2924
|
+
}
|
|
2925
|
+
// INPUT
|
|
2926
|
+
const defaultInputProps = {
|
|
2927
|
+
... other
|
|
2928
|
+
stateBorderColor: 'surfaceBorderTertiary',
|
|
2929
|
+
requiredStateBorderColor: 'warningBorderPrimary',
|
|
2930
|
+
errorStateBorderColor: 'errorBorderPrimary',
|
|
2931
|
+
}
|
|
2932
|
+
// RADIO
|
|
2933
|
+
const defaultRadioProps = {
|
|
2934
|
+
... other
|
|
2935
|
+
stateBorderColor: 'surfaceBorderTertiary',
|
|
2936
|
+
requiredStateBorderColor: 'warningBorderPrimary',
|
|
2937
|
+
errorStateBorderColor: 'errorBorderPrimary',
|
|
2938
|
+
}
|
|
2939
|
+
// SELECT
|
|
2940
|
+
const defaultSelectProps = {
|
|
2941
|
+
... other
|
|
2942
|
+
borderColor: 'surfaceBorderTertiary',
|
|
2943
|
+
requiredBorderColor: 'warningBorderPrimary',
|
|
2944
|
+
errorBorderColor: 'errorBorderPrimary',
|
|
2945
|
+
inputBorderColor: 'surfaceBorderTertiary',
|
|
2946
|
+
requiredInputBorderColor: 'warningBorderPrimary',
|
|
2947
|
+
errorInputBorderColor: 'errorBorderPrimary',
|
|
2948
|
+
}
|
|
2949
|
+
... etc
|
|
2950
|
+
*/
|
|
2951
|
+
|
|
2952
|
+
// DEFAULT
|
|
2953
|
+
// required - KEY for yellow color
|
|
2954
|
+
// error - KEY for red color
|
|
2955
|
+
|
|
2956
|
+
// key: 'required'
|
|
2957
|
+
required: {
|
|
2958
|
+
key: 'required',
|
|
2959
|
+
message: 'Обязательное поле'
|
|
2960
|
+
},
|
|
2961
|
+
phone_required: {
|
|
2962
|
+
key: 'required',
|
|
2963
|
+
message: 'Укажите номер телефона'
|
|
2964
|
+
},
|
|
2965
|
+
email_required: {
|
|
2966
|
+
key: 'required',
|
|
2967
|
+
message: 'Укажите адрес электронной почты'
|
|
2968
|
+
},
|
|
2969
|
+
password_required: {
|
|
2970
|
+
key: 'required',
|
|
2971
|
+
message: 'Введите пароль'
|
|
2972
|
+
},
|
|
2973
|
+
phone_or_email_required: {
|
|
2974
|
+
key: 'required',
|
|
2975
|
+
message: 'Введите телефон или адрес эл. почты'
|
|
2976
|
+
},
|
|
2977
|
+
// key: 'error'
|
|
2978
|
+
matches: {
|
|
2979
|
+
key: 'error',
|
|
2980
|
+
message: 'Допускается ввод только цифр от 0 до 9'
|
|
2981
|
+
},
|
|
2982
|
+
min: {
|
|
2983
|
+
key: 'error',
|
|
2984
|
+
message: ({
|
|
2985
|
+
min
|
|
2986
|
+
}) => `Значение должно быть не менее ${min} символов`
|
|
2987
|
+
},
|
|
2988
|
+
max: {
|
|
2989
|
+
key: 'error',
|
|
2990
|
+
message: ({
|
|
2991
|
+
max
|
|
2992
|
+
}) => `Значение должно быть не менее ${max} символов`
|
|
2993
|
+
},
|
|
2994
|
+
url: {
|
|
2995
|
+
key: 'error',
|
|
2996
|
+
message: 'Введите корректный URL-адрес'
|
|
2997
|
+
},
|
|
2998
|
+
invalid_value: {
|
|
2999
|
+
key: 'error',
|
|
3000
|
+
message: 'Некорректное значение'
|
|
3001
|
+
},
|
|
3002
|
+
numeric_value: {
|
|
3003
|
+
key: 'error',
|
|
3004
|
+
message: 'Только числовое значение'
|
|
3005
|
+
},
|
|
3006
|
+
phone_error: {
|
|
3007
|
+
key: 'error',
|
|
3008
|
+
message: 'Введите корректный номер телефона'
|
|
3009
|
+
},
|
|
3010
|
+
email_error: {
|
|
3011
|
+
key: 'error',
|
|
3012
|
+
message: 'Введите корректный адрес электронной почты'
|
|
3013
|
+
}
|
|
3014
|
+
};
|
|
3015
|
+
|
|
2436
3016
|
Object.defineProperty(exports, "Field", {
|
|
2437
3017
|
enumerable: true,
|
|
2438
3018
|
get: function () { return reactFinalForm.Field; }
|
|
@@ -2449,6 +3029,7 @@ exports.Checkbox = CheckboxField;
|
|
|
2449
3029
|
exports.ChoiceField = ChoiceField;
|
|
2450
3030
|
exports.CodeField = CodeField;
|
|
2451
3031
|
exports.CustomField = CustomField;
|
|
3032
|
+
exports.DEFAULT_MESSAGES_FIELDS = DEFAULT_MESSAGES_FIELDS;
|
|
2452
3033
|
exports.DatePickerField = DatePickerField;
|
|
2453
3034
|
exports.FieldWrapper = FieldWrapper;
|
|
2454
3035
|
exports.FieldWrapperBase = FieldWrapperBase;
|
|
@@ -2456,6 +3037,7 @@ exports.FileInput = FileInput;
|
|
|
2456
3037
|
exports.FinalForm = FinalForm;
|
|
2457
3038
|
exports.Group = Group;
|
|
2458
3039
|
exports.InputField = InputField;
|
|
3040
|
+
exports.MaskedInputField = MaskedInputField;
|
|
2459
3041
|
exports.RadioGroup = RadioGroup;
|
|
2460
3042
|
exports.SegmentedField = SegmentedField;
|
|
2461
3043
|
exports.SelectField = SelectField;
|