@itcase/forms 1.1.40 → 1.1.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/form/Field/RadioGroup/{RadioGroup.css → FormFieldRadioGroup.css} +1 -1
- package/dist/css/form/FormField/FormField.css +6 -0
- package/dist/css/styles/main.css +1 -1
- package/dist/itcase-forms.cjs.js +1345 -1365
- package/dist/itcase-forms.esm.js +1345 -1365
- package/package.json +17 -17
- /package/dist/css/form/Field/FileInput/{FileInput.css → FormFieldFileInput.css} +0 -0
package/dist/itcase-forms.cjs.js
CHANGED
|
@@ -5,13 +5,19 @@ var React = require('react');
|
|
|
5
5
|
var finalForm = require('final-form');
|
|
6
6
|
var reactFinalForm = require('react-final-form');
|
|
7
7
|
var clsx = require('clsx');
|
|
8
|
-
var
|
|
8
|
+
var Checkbox = require('@itcase/ui/components/Checkbox');
|
|
9
9
|
var camelCase = require('lodash/camelCase');
|
|
10
10
|
var snakeCase = require('lodash/snakeCase');
|
|
11
11
|
var Divider = require('@itcase/ui/components/Divider');
|
|
12
12
|
var Text = require('@itcase/ui/components/Text');
|
|
13
13
|
var useDeviceTargetClass = require('@itcase/ui/hooks/useDeviceTargetClass');
|
|
14
14
|
var useStyles = require('@itcase/ui/hooks/useStyles');
|
|
15
|
+
var Chips = require('@itcase/ui/components/Chips');
|
|
16
|
+
var Choice = require('@itcase/ui/components/Choice');
|
|
17
|
+
var Code = require('@itcase/ui/components/Code');
|
|
18
|
+
var Icon = require('@itcase/ui/components/Icon');
|
|
19
|
+
var DatePicker = require('@itcase/ui/components/DatePicker');
|
|
20
|
+
var useDevicePropsGenerator = require('@itcase/ui/hooks/useDevicePropsGenerator');
|
|
15
21
|
var axios = require('axios');
|
|
16
22
|
var fileSelector = require('file-selector');
|
|
17
23
|
var castArray = require('lodash/castArray');
|
|
@@ -20,20 +26,14 @@ var common = require('@itcase/common');
|
|
|
20
26
|
var Button = require('@itcase/ui/components/Button');
|
|
21
27
|
var Loader = require('@itcase/ui/components/Loader');
|
|
22
28
|
var Title = require('@itcase/ui/components/Title');
|
|
23
|
-
var Checkbox = require('@itcase/ui/components/Checkbox');
|
|
24
|
-
var Chips = require('@itcase/ui/components/Chips');
|
|
25
|
-
var Choice = require('@itcase/ui/components/Choice');
|
|
26
|
-
var Code = require('@itcase/ui/components/Code');
|
|
27
|
-
var Icon = require('@itcase/ui/components/Icon');
|
|
28
|
-
var DatePicker = require('@itcase/ui/components/DatePicker');
|
|
29
29
|
var Input = require('@itcase/ui/components/Input');
|
|
30
|
-
var
|
|
30
|
+
var reactImask = require('react-imask');
|
|
31
|
+
var InputPassword = require('@itcase/ui/components/InputPassword');
|
|
32
|
+
var Radio = require('@itcase/ui/components/Radio');
|
|
31
33
|
var Segmented = require('@itcase/ui/components/Segmented');
|
|
32
34
|
var Select = require('@itcase/ui/components/Select');
|
|
33
35
|
var Switch = require('@itcase/ui/components/Switch');
|
|
34
36
|
var Textarea = require('@itcase/ui/components/Textarea');
|
|
35
|
-
var reactImask = require('react-imask');
|
|
36
|
-
var Radio = require('@itcase/ui/components/Radio');
|
|
37
37
|
var Group = require('@itcase/ui/components/Group');
|
|
38
38
|
var Notification = require('@itcase/ui/components/Notification');
|
|
39
39
|
var createDecorator = require('final-form-focus');
|
|
@@ -128,6 +128,16 @@ function useYupValidationSchema(schema, language) {
|
|
|
128
128
|
return validate;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
const defaultCheckboxProps = {
|
|
132
|
+
appearance: 'defaultPrimary sizeL solid',
|
|
133
|
+
width: 'fill',
|
|
134
|
+
// useValidationAppearanceInputProps
|
|
135
|
+
// Error
|
|
136
|
+
errorAppearance: 'errorPrimary sizeL solid',
|
|
137
|
+
// Required
|
|
138
|
+
requiredAppearance: 'requirePrimary sizeL solid'
|
|
139
|
+
};
|
|
140
|
+
|
|
131
141
|
// Whether to display an error message based on "fieldProps" and meta-objects
|
|
132
142
|
function useFieldValidationState(props) {
|
|
133
143
|
const {
|
|
@@ -441,428 +451,477 @@ function FieldWrapper(props) {
|
|
|
441
451
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapperBase, props);
|
|
442
452
|
}
|
|
443
453
|
|
|
444
|
-
const
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
454
|
+
const FormFieldCheckbox = /*#__PURE__*/React__default.default.memo(function FormFieldCheckbox(props) {
|
|
455
|
+
const {
|
|
456
|
+
name,
|
|
457
|
+
initialValue,
|
|
458
|
+
isDisabled,
|
|
459
|
+
classNameGroupItem,
|
|
460
|
+
fieldProps = {},
|
|
461
|
+
inputProps = {},
|
|
462
|
+
showMessage,
|
|
463
|
+
isRequired,
|
|
464
|
+
onChange
|
|
465
|
+
} = props;
|
|
466
|
+
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
467
|
+
type: "checkbox",
|
|
468
|
+
name: name,
|
|
469
|
+
initialValue: initialValue
|
|
470
|
+
}, function Render({
|
|
471
|
+
input,
|
|
472
|
+
meta
|
|
473
|
+
}) {
|
|
474
|
+
/** Note:
|
|
475
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
476
|
+
* React Hooks cannot be called inside a callback.
|
|
477
|
+
* React Hooks must be called in a React function component or a
|
|
478
|
+
* custom React Hook function.
|
|
479
|
+
*/
|
|
480
|
+
|
|
481
|
+
const onChangeField = React.useCallback(event => {
|
|
482
|
+
input.onChange(event);
|
|
483
|
+
if (onChange) {
|
|
484
|
+
onChange(event.target.checked, input.name);
|
|
485
|
+
}
|
|
486
|
+
}, [onChange, input.onChange]);
|
|
487
|
+
const {
|
|
488
|
+
errorKey,
|
|
489
|
+
errorMessage,
|
|
490
|
+
isErrorState,
|
|
491
|
+
successKey,
|
|
492
|
+
isValidState
|
|
493
|
+
} = useFieldValidationState({
|
|
494
|
+
fieldProps: fieldProps,
|
|
495
|
+
input: input,
|
|
496
|
+
meta: meta
|
|
497
|
+
});
|
|
498
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
499
|
+
inputProps: inputProps,
|
|
500
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
501
|
+
});
|
|
502
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
503
|
+
className: clsx__default.default('form-field-checkbox', 'form__item_checkbox', classNameGroupItem),
|
|
504
|
+
errorKey: errorKey,
|
|
505
|
+
errorMessage: errorMessage,
|
|
506
|
+
isErrorState: isErrorState,
|
|
507
|
+
metaError: meta.error,
|
|
508
|
+
isDisabled: isDisabled,
|
|
509
|
+
fieldClassName: "form-checkbox",
|
|
510
|
+
inputName: input.name,
|
|
511
|
+
inputValue: input.checked,
|
|
512
|
+
metaActive: meta.active,
|
|
513
|
+
showMessage: showMessage,
|
|
514
|
+
tag: "label",
|
|
515
|
+
isRequired: isRequired,
|
|
516
|
+
isValidState: isValidState
|
|
517
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Checkbox.Checkbox, Object.assign({
|
|
518
|
+
type: "checkbox",
|
|
519
|
+
name: input.name,
|
|
520
|
+
isDisabled: isDisabled,
|
|
521
|
+
autoComplete: "nope",
|
|
522
|
+
checked: input.checked,
|
|
523
|
+
isActive: input.checked,
|
|
524
|
+
onBlur: input.onBlur,
|
|
525
|
+
onChange: onChangeField,
|
|
526
|
+
onFocus: input.onFocus
|
|
527
|
+
}, updatedInputProps)));
|
|
528
|
+
});
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
const defaultChipsProps = {
|
|
532
|
+
appearance: 'surfacePrimary sizeM rounded',
|
|
533
|
+
width: 'fill',
|
|
534
|
+
// useValidationAppearanceInputProps
|
|
535
|
+
// Error
|
|
536
|
+
errorAppearance: 'errorPrimary sizeM solid rounded',
|
|
537
|
+
// Required
|
|
538
|
+
requiredAppearance: 'requirePrimary sizeM solid rounded'
|
|
539
|
+
// Success
|
|
540
|
+
// successAppearance: 'successPrimary sizeM solid rounded',
|
|
464
541
|
};
|
|
465
542
|
|
|
466
|
-
|
|
543
|
+
function FormFieldChips(props) {
|
|
467
544
|
const {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
onAddFiles,
|
|
482
|
-
onClickPreview,
|
|
483
|
-
onDeleteFile
|
|
545
|
+
name,
|
|
546
|
+
initialValue,
|
|
547
|
+
isDisabled,
|
|
548
|
+
classNameGroupItem,
|
|
549
|
+
emptyMessage,
|
|
550
|
+
emptyMessageTextColor,
|
|
551
|
+
emptyMessageTextSize,
|
|
552
|
+
fieldProps,
|
|
553
|
+
inputProps,
|
|
554
|
+
options,
|
|
555
|
+
showMessage,
|
|
556
|
+
isRequired,
|
|
557
|
+
onChange
|
|
484
558
|
} = props;
|
|
485
|
-
|
|
486
|
-
// TODO: delete react-final-form things out of here?
|
|
487
559
|
const {
|
|
488
560
|
change
|
|
489
561
|
} = reactFinalForm.useForm();
|
|
490
|
-
const [fileError, setFileError] = React.useState('');
|
|
491
|
-
const [fileIsLoading, setFileIsLoading] = React.useState(false);
|
|
492
|
-
const filesList = React.useMemo(() => inputValue ? castArray__default.default(inputValue) : [], [inputValue]);
|
|
493
|
-
const changeFormState = React.useCallback(newFiles => {
|
|
494
|
-
// If max files in dropzone is 1 - return file as it self, else as array of files
|
|
495
|
-
// ps: for old projects compatibility
|
|
496
|
-
const toSave = dropzoneProps.maxFiles == 1 ? newFiles[0] : newFiles;
|
|
497
|
-
change(inputName, toSave);
|
|
498
|
-
return toSave;
|
|
499
|
-
},
|
|
500
|
-
// If "inputName" will be changes, then it should be a different field
|
|
501
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
502
|
-
[dropzoneProps, change]);
|
|
503
562
|
|
|
504
|
-
//
|
|
505
|
-
const
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
563
|
+
// Callback for value changes
|
|
564
|
+
const onChangeSomeInput = React.useCallback((inputValue, newOptionValue) => {
|
|
565
|
+
const updatedValues = inputValue.includes(newOptionValue) ? inputValue.filter(selectedValue => selectedValue !== newOptionValue) : [...inputValue, newOptionValue];
|
|
566
|
+
change(name, updatedValues);
|
|
567
|
+
onChange && onChange(updatedValues);
|
|
568
|
+
}, [change, name, onChange]);
|
|
569
|
+
React.useEffect(() => {
|
|
570
|
+
initialValue && change(name, initialValue);
|
|
571
|
+
// update the form value only when the initialValue changes, so use disable eslint to ignore the warning
|
|
572
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
573
|
+
}, [initialValue]);
|
|
574
|
+
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
575
|
+
name: name,
|
|
576
|
+
initialValue: initialValue
|
|
577
|
+
}, function Render({
|
|
578
|
+
input,
|
|
579
|
+
meta
|
|
580
|
+
}) {
|
|
581
|
+
const {
|
|
582
|
+
errorKey,
|
|
583
|
+
errorMessage,
|
|
584
|
+
isErrorState,
|
|
585
|
+
successKey,
|
|
586
|
+
isValidState
|
|
587
|
+
} = useFieldValidationState({
|
|
588
|
+
fieldProps: fieldProps,
|
|
589
|
+
input: input,
|
|
590
|
+
meta: meta
|
|
591
|
+
});
|
|
592
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
593
|
+
inputProps: inputProps,
|
|
594
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
595
|
+
});
|
|
596
|
+
const activeOptionsList = React.useMemo(() => {
|
|
597
|
+
const emptyOptionsList = [{
|
|
598
|
+
label: null,
|
|
599
|
+
value: null
|
|
600
|
+
}];
|
|
601
|
+
if (input?.value) {
|
|
602
|
+
const currentOptions = options.filter(option => input.value?.includes(option.value));
|
|
603
|
+
return currentOptions || emptyOptionsList;
|
|
516
604
|
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
const newFiles = result.filter(item => item instanceof File);
|
|
550
|
-
// Add exists and new files to accepted(or rejected)
|
|
551
|
-
return [...filesList, ...newFiles];
|
|
552
|
-
},
|
|
553
|
-
onDropAccepted: acceptedFiles => {
|
|
554
|
-
// If dropped files has accepted and we need a previews
|
|
555
|
-
if (isPreviews) {
|
|
556
|
-
// Add preview to every file
|
|
557
|
-
acceptedFiles.forEach(file => {
|
|
558
|
-
if (!file.error) {
|
|
559
|
-
file.preview = URL.createObjectURL(file);
|
|
560
|
-
}
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
// Save to form data (including empty when files are not valid)
|
|
564
|
-
const filesToSave = changeFormState(acceptedFiles);
|
|
565
|
-
setFileError('');
|
|
566
|
-
|
|
567
|
-
// Save DataURL for all files
|
|
568
|
-
const readerPromisesList = acceptedFiles.map(file => {
|
|
569
|
-
return new Promise(resolve => setFileDataURL(file, resolve));
|
|
570
|
-
});
|
|
571
|
-
// Save files to form values
|
|
572
|
-
Promise.all(readerPromisesList).then(() => {
|
|
573
|
-
if (onAddFiles) {
|
|
574
|
-
onAddFiles(filesToSave, inputName);
|
|
575
|
-
}
|
|
576
|
-
});
|
|
577
|
-
},
|
|
578
|
-
onDropRejected: rejectedFiles => {
|
|
579
|
-
// If dropped files has rejected
|
|
580
|
-
if (rejectedFiles.length) {
|
|
581
|
-
let fileErrorMessage = 'Ошибка при добавлении файла';
|
|
582
|
-
const firstFileErrorItem = rejectedFiles[0].errors[0];
|
|
583
|
-
if (firstFileErrorItem) {
|
|
584
|
-
if (firstFileErrorItem.code === reactDropzone.ErrorCode.TooManyFiles) {
|
|
585
|
-
fileErrorMessage = `Максимальное количество файлов: ${maxFiles}`;
|
|
586
|
-
} else {
|
|
587
|
-
fileErrorMessage = firstFileErrorItem.message;
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
// Show error
|
|
591
|
-
setFileError(fileErrorMessage);
|
|
592
|
-
} else {
|
|
593
|
-
// Else clean error
|
|
594
|
-
setFileError('');
|
|
595
|
-
}
|
|
596
|
-
}
|
|
605
|
+
return emptyOptionsList;
|
|
606
|
+
}, [input.value]);
|
|
607
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
608
|
+
className: clsx__default.default('form-field_chips', 'form__item_chips', classNameGroupItem),
|
|
609
|
+
errorKey: errorKey,
|
|
610
|
+
errorMessage: errorMessage,
|
|
611
|
+
isErrorState: isErrorState,
|
|
612
|
+
metaError: meta.error,
|
|
613
|
+
isDisabled: isDisabled,
|
|
614
|
+
fieldClassName: "form-chips",
|
|
615
|
+
inputName: input.name,
|
|
616
|
+
inputValue: input.value,
|
|
617
|
+
metaActive: meta.active,
|
|
618
|
+
showMessage: showMessage,
|
|
619
|
+
isRequired: isRequired,
|
|
620
|
+
isValidState: isValidState
|
|
621
|
+
}, fieldProps), options.length ? /*#__PURE__*/React__default.default.createElement(Chips.ChipsGroup, {
|
|
622
|
+
direction: "horizontal",
|
|
623
|
+
gap: "1m",
|
|
624
|
+
wrap: "wrap"
|
|
625
|
+
}, options.map(option => /*#__PURE__*/React__default.default.createElement(Chips.Chips, Object.assign({
|
|
626
|
+
className: clsx__default.default(meta.active && 'form-chips_state_focus', meta.error && meta.touched && `form-chips_state_${errorKey}`),
|
|
627
|
+
key: option.value,
|
|
628
|
+
label: option.label,
|
|
629
|
+
isDisabled: option.isDisabled,
|
|
630
|
+
value: option.value,
|
|
631
|
+
isActive: activeOptionsList.some(activeOption => activeOption.value === option.value),
|
|
632
|
+
onClick: () => onChangeSomeInput(input.value, option.value)
|
|
633
|
+
}, updatedInputProps)))) : /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
634
|
+
size: emptyMessageTextSize,
|
|
635
|
+
textColor: emptyMessageTextColor
|
|
636
|
+
}, emptyMessage));
|
|
597
637
|
});
|
|
598
|
-
React.useEffect(() => {
|
|
599
|
-
const currentFilesList = castArray__default.default(inputValue);
|
|
600
|
-
const isNeedToConvert = currentFilesList.some(fileItem => typeof fileItem === 'string');
|
|
601
|
-
if (isNeedToConvert) {
|
|
602
|
-
// First time convert value to Files and save to local and form state
|
|
603
|
-
convertFiledValueAndSaveAsFiles(currentFilesList);
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
// Make sure to revoke the data uris to avoid memory leaks, will run on unmount
|
|
607
|
-
return () => {
|
|
608
|
-
filesList.forEach(file => {
|
|
609
|
-
if (file?.preview) {
|
|
610
|
-
URL.revokeObjectURL(file.preview);
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
};
|
|
614
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
615
|
-
}, [inputValue]);
|
|
616
|
-
const propsGenerator = useDevicePropsGenerator.useDevicePropsGenerator(props);
|
|
617
|
-
const {
|
|
618
|
-
fillClass,
|
|
619
|
-
fillHoverClass,
|
|
620
|
-
borderColorClass,
|
|
621
|
-
borderColorHoverClass,
|
|
622
|
-
borderTypeClass,
|
|
623
|
-
borderWidthClass,
|
|
624
|
-
errorMessageTextColor,
|
|
625
|
-
errorMessageTextSize,
|
|
626
|
-
errorMessageTextWeight,
|
|
627
|
-
hintDescriptionTextColor,
|
|
628
|
-
hintDescriptionTextSize,
|
|
629
|
-
hintDescriptionTextWeight,
|
|
630
|
-
hintDescriptionTextWrap,
|
|
631
|
-
hintTitleTextColor,
|
|
632
|
-
hintTitleTextSize,
|
|
633
|
-
hintTitleTextWeight,
|
|
634
|
-
hintTitleTextWrap,
|
|
635
|
-
removeThumbAppearance,
|
|
636
|
-
removeThumbShape,
|
|
637
|
-
removeThumbText,
|
|
638
|
-
removeThumbTextWeight,
|
|
639
|
-
shapeClass,
|
|
640
|
-
thumbBorderColorClass,
|
|
641
|
-
thumbBorderColorHoverClass,
|
|
642
|
-
thumbBorderTypeClass,
|
|
643
|
-
thumbBorderWidthClass,
|
|
644
|
-
thumbDirectionClass,
|
|
645
|
-
thumbNameTextColor,
|
|
646
|
-
thumbNameTextSize,
|
|
647
|
-
thumbNameTextWeight,
|
|
648
|
-
thumbNameTextWrap
|
|
649
|
-
} = propsGenerator;
|
|
650
|
-
return /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, /*#__PURE__*/React__default.default.createElement("div", getRootProps({
|
|
651
|
-
// className: `form-dropzone__dropzone dropzone ${className} form-dropzone__dropzone_size_${size} ${shapeClass}`,
|
|
652
|
-
className: `form-dropzone__dropzone dropzone`
|
|
653
|
-
}), /*#__PURE__*/React__default.default.createElement("input", Object.assign({}, getInputProps(), {
|
|
654
|
-
name: inputName
|
|
655
|
-
})), /*#__PURE__*/React__default.default.createElement("div", {
|
|
656
|
-
className: clsx__default.default('form-dropzone__dropzone-wrapper', thumbColumn && `form-dropzone__dropzone-wrapper_column_${thumbColumn}`, fillClass && `fill_${fillClass}`, fillHoverClass && `fill_hover_${fillHoverClass}`, borderWidthClass && `border-width_${borderWidthClass}`, borderColorClass && `border-color_${borderColorClass}`, borderColorHoverClass && `border-color_hover_${borderColorHoverClass}`, borderTypeClass && `border_type_${borderTypeClass}`, shapeClass && `shape_${shapeClass}`)
|
|
657
|
-
}, filesList.map((file, index) => /*#__PURE__*/React__default.default.createElement("aside", {
|
|
658
|
-
className: clsx__default.default('form-dropzone__thumb', fillClass, thumbDirectionClass, thumbBorderWidthClass, thumbBorderColorClass, thumbBorderColorHoverClass, thumbBorderTypeClass),
|
|
659
|
-
key: file.id || `${file.name}_${index}`
|
|
660
|
-
}, isPreviews && !file.error && /*#__PURE__*/React__default.default.createElement("div", {
|
|
661
|
-
className: "form-dropzone__thumb-image"
|
|
662
|
-
}, /*#__PURE__*/React__default.default.createElement("img", {
|
|
663
|
-
className: "form-dropzone__thumb-image-inner",
|
|
664
|
-
src: file.preview || file.image,
|
|
665
|
-
onClick: event => {
|
|
666
|
-
onClickPreview && onClickPreview(file, event);
|
|
667
|
-
},
|
|
668
|
-
onLoad: () => {
|
|
669
|
-
// Revoke data uri after image is loaded
|
|
670
|
-
URL.revokeObjectURL(file.preview);
|
|
671
|
-
}
|
|
672
|
-
})), file.error && /*#__PURE__*/React__default.default.createElement("div", null, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
673
|
-
size: thumbNameTextSize,
|
|
674
|
-
textColor: thumbNameTextColor,
|
|
675
|
-
textWeight: thumbNameTextWeight,
|
|
676
|
-
textWrap: thumbNameTextWrap
|
|
677
|
-
}, fileErrorText || file.error)), showFilename && /*#__PURE__*/React__default.default.createElement("div", {
|
|
678
|
-
className: "form-dropzone__thumb-name"
|
|
679
|
-
}, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
680
|
-
className: "form-dropzone__thumb-name-inner",
|
|
681
|
-
size: thumbNameTextSize,
|
|
682
|
-
textColor: thumbNameTextColor,
|
|
683
|
-
textWeight: thumbNameTextWeight,
|
|
684
|
-
textWrap: thumbNameTextWrap
|
|
685
|
-
}, file.name)), fileIsLoading && /*#__PURE__*/React__default.default.createElement("div", {
|
|
686
|
-
className: "form-dropzone__thumb-loader"
|
|
687
|
-
}, /*#__PURE__*/React__default.default.createElement(Loader.Loader, {
|
|
688
|
-
width: "fill",
|
|
689
|
-
height: "fill"
|
|
690
|
-
})), /*#__PURE__*/React__default.default.createElement("div", {
|
|
691
|
-
className: clsx__default.default('form-dropzone__thumb-remove')
|
|
692
|
-
}, /*#__PURE__*/React__default.default.createElement(Button.Button, {
|
|
693
|
-
className: "form-dropzone__thumb-remove-text",
|
|
694
|
-
appearance: removeThumbAppearance,
|
|
695
|
-
label: removeThumbText || 'Удалить',
|
|
696
|
-
labelTextWeight: removeThumbTextWeight,
|
|
697
|
-
shape: removeThumbShape,
|
|
698
|
-
onClick: event => removeFile(event, index)
|
|
699
|
-
})))), !filesList.length ? /*#__PURE__*/React__default.default.createElement("div", {
|
|
700
|
-
className: "form-dropzone__hint"
|
|
701
|
-
}, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
702
|
-
className: "form-dropzone__hint-title",
|
|
703
|
-
size: hintTitleTextSize,
|
|
704
|
-
textColor: hintTitleTextColor,
|
|
705
|
-
textWeight: hintTitleTextWeight,
|
|
706
|
-
textWrap: hintTitleTextWrap
|
|
707
|
-
}, hintTitle || 'Select a file or drag in form'), hintDescription && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
708
|
-
className: "form-dropzone__hint-text",
|
|
709
|
-
size: hintDescriptionTextSize,
|
|
710
|
-
textColor: hintDescriptionTextColor,
|
|
711
|
-
textWeight: hintDescriptionTextWeight,
|
|
712
|
-
textWrap: hintDescriptionTextWrap
|
|
713
|
-
}, hintDescription)) : /*#__PURE__*/React__default.default.createElement("div", {
|
|
714
|
-
className: "form-dropzone__hint form-dropzone__hint_type_add-more"
|
|
715
|
-
}, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
716
|
-
className: "form-dropzone__hint-title",
|
|
717
|
-
size: hintTitleTextSize,
|
|
718
|
-
textColor: hintTitleTextColor,
|
|
719
|
-
textWeight: hintTitleTextWeight,
|
|
720
|
-
textWrap: hintTitleTextWrap
|
|
721
|
-
}, hintTitle || 'Select a file or drag in form'), hintDescription && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
722
|
-
className: "form-dropzone__hint-text",
|
|
723
|
-
size: hintDescriptionTextSize,
|
|
724
|
-
textColor: hintDescriptionTextColor,
|
|
725
|
-
textWeight: hintDescriptionTextWeight,
|
|
726
|
-
textWrap: hintDescriptionTextWrap
|
|
727
|
-
}, hintDescription)))), fileError && /*#__PURE__*/React__default.default.createElement("div", {
|
|
728
|
-
className: "form-field__message"
|
|
729
|
-
}, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
730
|
-
className: "form-field__message-item form-field__message-item_type_message",
|
|
731
|
-
size: errorMessageTextSize,
|
|
732
|
-
textColor: errorMessageTextColor,
|
|
733
|
-
textWeight: errorMessageTextWeight
|
|
734
|
-
}, fileError)));
|
|
735
|
-
});
|
|
736
|
-
async function getFileByURL(url) {
|
|
737
|
-
try {
|
|
738
|
-
const response = await axios__default.default({
|
|
739
|
-
url: url,
|
|
740
|
-
responseType: 'blob'
|
|
741
|
-
});
|
|
742
|
-
const blobObject = response.data;
|
|
743
|
-
const dirtyFilename = response.headers['content-disposition']?.split('filename=')[1];
|
|
744
|
-
// Remove double quotes
|
|
745
|
-
let filename = dirtyFilename?.substring(1).slice(0, -1);
|
|
746
|
-
if (!filename) {
|
|
747
|
-
filename = url.split('/').at(-1);
|
|
748
|
-
// const typeParts = blobObject.type.split('/')
|
|
749
|
-
// const fileType = typeParts[typeParts.length - 1]
|
|
750
|
-
// filename = `${new Date().getTime()}.${fileType}`
|
|
751
|
-
}
|
|
752
|
-
return new File([blobObject], filename, {
|
|
753
|
-
type: blobObject.type
|
|
754
|
-
});
|
|
755
|
-
} catch (error) {
|
|
756
|
-
console.log('error: ', error);
|
|
757
|
-
return null;
|
|
758
|
-
}
|
|
759
638
|
}
|
|
760
|
-
async function convertToFile(inputValue, isPreviews) {
|
|
761
|
-
let newFile = null;
|
|
762
639
|
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
// Convert dataURL to File instance
|
|
773
|
-
if (inputValue.dataURL) {
|
|
774
|
-
newFile = common.createFileFromDataURL(inputValue.name || inputValue.path, inputValue.dataURL);
|
|
775
|
-
newFile.dataURL = inputValue.dataURL;
|
|
776
|
-
}
|
|
640
|
+
const defaultChoiceProps = {
|
|
641
|
+
appearance: 'defaultPrimary sizeM solid rounded',
|
|
642
|
+
width: 'fill',
|
|
643
|
+
// useValidationAppearanceInputProps
|
|
644
|
+
// Error
|
|
645
|
+
errorAppearance: 'errorPrimary sizeM solid rounded',
|
|
646
|
+
// Required
|
|
647
|
+
requiredAppearance: 'requirePrimary sizeM solid rounded'
|
|
648
|
+
};
|
|
777
649
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
650
|
+
const FormFieldChoice = /*#__PURE__*/React__default.default.memo(function FormFieldChoice(props) {
|
|
651
|
+
const {
|
|
652
|
+
name,
|
|
653
|
+
initialValue,
|
|
654
|
+
label,
|
|
655
|
+
messageType,
|
|
656
|
+
isDisabled,
|
|
657
|
+
classNameGroupItem,
|
|
658
|
+
fieldProps,
|
|
659
|
+
inputProps,
|
|
660
|
+
options,
|
|
661
|
+
placeholder,
|
|
662
|
+
showMessage,
|
|
663
|
+
isCheckbox,
|
|
664
|
+
isRequired,
|
|
665
|
+
onChange
|
|
666
|
+
} = props;
|
|
667
|
+
const {
|
|
668
|
+
change
|
|
669
|
+
} = reactFinalForm.useForm();
|
|
670
|
+
const setActiveSegment = React.useCallback((option, isChecked) => {
|
|
671
|
+
change(name, isChecked && option.value);
|
|
672
|
+
if (onChange) {
|
|
673
|
+
onChange(option.value, name, isChecked);
|
|
783
674
|
}
|
|
784
|
-
}
|
|
785
|
-
return
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
675
|
+
}, [change, onChange]);
|
|
676
|
+
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
677
|
+
initialValue: initialValue,
|
|
678
|
+
name: name
|
|
679
|
+
}, function Render({
|
|
680
|
+
input,
|
|
681
|
+
meta
|
|
682
|
+
}) {
|
|
683
|
+
/** Note:
|
|
684
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
685
|
+
* React Hooks cannot be called inside a callback.
|
|
686
|
+
* React Hooks must be called in a React function component or a
|
|
687
|
+
* custom React Hook function.
|
|
688
|
+
*/
|
|
689
|
+
const activeOption = React.useMemo(() => {
|
|
690
|
+
const emptyOption = {
|
|
691
|
+
value: null,
|
|
692
|
+
label: null
|
|
693
|
+
};
|
|
694
|
+
if (input.value) {
|
|
695
|
+
const currentOption = options.find(option => option.value === input.value);
|
|
696
|
+
return currentOption || emptyOption;
|
|
697
|
+
}
|
|
698
|
+
return emptyOption;
|
|
699
|
+
}, [input.value]);
|
|
700
|
+
const {
|
|
701
|
+
errorKey,
|
|
702
|
+
errorMessage,
|
|
703
|
+
isErrorState,
|
|
704
|
+
successKey,
|
|
705
|
+
isValidState
|
|
706
|
+
} = useFieldValidationState({
|
|
707
|
+
fieldProps: fieldProps,
|
|
708
|
+
input: input,
|
|
709
|
+
meta: meta
|
|
710
|
+
});
|
|
711
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
712
|
+
inputProps: inputProps,
|
|
713
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
714
|
+
});
|
|
715
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
716
|
+
className: clsx__default.default('form-field_choice', 'form__item_choice', classNameGroupItem),
|
|
717
|
+
label: label,
|
|
718
|
+
messageType: messageType,
|
|
719
|
+
errorKey: errorKey,
|
|
720
|
+
errorMessage: errorMessage,
|
|
721
|
+
isErrorState: isErrorState,
|
|
722
|
+
metaError: meta.error,
|
|
723
|
+
isDisabled: isDisabled,
|
|
724
|
+
fieldClassName: "form-choice",
|
|
725
|
+
inputName: input.name,
|
|
726
|
+
inputValue: input.value || [],
|
|
727
|
+
metaActive: meta.active,
|
|
728
|
+
showMessage: showMessage,
|
|
729
|
+
isRequired: isRequired,
|
|
730
|
+
isValidState: isValidState
|
|
731
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Choice.Choice, Object.assign({
|
|
732
|
+
className: clsx__default.default(meta.active && 'form-choice_state_focus', meta.error && meta.touched && `form-choice_state_${errorKey}`),
|
|
733
|
+
name: input.name,
|
|
734
|
+
isDisabled: isDisabled,
|
|
735
|
+
active: activeOption,
|
|
736
|
+
inputValue: input.value || [],
|
|
737
|
+
options: options,
|
|
738
|
+
placeholder: placeholder,
|
|
739
|
+
setActiveSegment: setActiveSegment,
|
|
740
|
+
isCheckbox: isCheckbox,
|
|
741
|
+
isRequired: isRequired
|
|
742
|
+
}, updatedInputProps)));
|
|
743
|
+
});
|
|
744
|
+
});
|
|
792
745
|
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
if (file instanceof File) {
|
|
802
|
-
reader.readAsDataURL(file);
|
|
803
|
-
} else {
|
|
804
|
-
resolve();
|
|
805
|
-
}
|
|
806
|
-
}
|
|
746
|
+
const defaultCodeProps = {
|
|
747
|
+
appearance: 'defaultPrimary sizeL solid rounded',
|
|
748
|
+
// useValidationAppearanceInputProps
|
|
749
|
+
// Error
|
|
750
|
+
errorAppearance: 'errorPrimary sizeM solid rounded',
|
|
751
|
+
// Required
|
|
752
|
+
requiredAppearance: 'requirePrimary sizeM solid rounded'
|
|
753
|
+
};
|
|
807
754
|
|
|
808
|
-
const
|
|
755
|
+
const FormFieldCode = /*#__PURE__*/React__default.default.memo(function FormFieldCode(props) {
|
|
809
756
|
const {
|
|
810
|
-
className,
|
|
811
757
|
name,
|
|
812
|
-
|
|
813
|
-
maxFiles,
|
|
814
|
-
maxSize,
|
|
758
|
+
initialValue,
|
|
815
759
|
label,
|
|
816
|
-
|
|
760
|
+
messageType,
|
|
761
|
+
isDisabled,
|
|
817
762
|
classNameGroupItem,
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
hintDescription,
|
|
821
|
-
hintTitle,
|
|
822
|
-
showFilename,
|
|
763
|
+
fieldProps = {},
|
|
764
|
+
inputProps = {},
|
|
823
765
|
showMessage,
|
|
824
|
-
|
|
825
|
-
isRequired,
|
|
826
|
-
onAddFiles,
|
|
827
|
-
onClickPreview,
|
|
828
|
-
onDeleteFile
|
|
766
|
+
isRequired
|
|
829
767
|
} = props;
|
|
830
|
-
|
|
768
|
+
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
769
|
+
name: name,
|
|
770
|
+
initialValue: initialValue
|
|
771
|
+
}, function Render({
|
|
772
|
+
input,
|
|
773
|
+
meta
|
|
774
|
+
}) {
|
|
775
|
+
/** Note:
|
|
776
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
777
|
+
* React Hooks cannot be called inside a callback.
|
|
778
|
+
* React Hooks must be called in a React function component or a
|
|
779
|
+
* custom React Hook function.
|
|
780
|
+
*/
|
|
781
|
+
|
|
782
|
+
const {
|
|
783
|
+
errorKey,
|
|
784
|
+
errorMessage,
|
|
785
|
+
isErrorState,
|
|
786
|
+
successKey,
|
|
787
|
+
isValidState
|
|
788
|
+
} = useFieldValidationState({
|
|
789
|
+
fieldProps: fieldProps,
|
|
790
|
+
input: input,
|
|
791
|
+
meta: meta
|
|
792
|
+
});
|
|
793
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
794
|
+
inputProps: inputProps,
|
|
795
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
796
|
+
});
|
|
797
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
798
|
+
className: clsx__default.default('form-field-code', 'form__item_code', classNameGroupItem),
|
|
799
|
+
label: label,
|
|
800
|
+
messageType: messageType,
|
|
801
|
+
errorKey: errorKey,
|
|
802
|
+
errorMessage: errorMessage,
|
|
803
|
+
isErrorState: isErrorState,
|
|
804
|
+
fieldClassName: 'form-code',
|
|
805
|
+
inputName: input.name,
|
|
806
|
+
inputValue: input.value,
|
|
807
|
+
metaActive: meta.active,
|
|
808
|
+
showMessage: showMessage,
|
|
809
|
+
isRequired: isRequired,
|
|
810
|
+
isValidState: isValidState
|
|
811
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Code.Code, Object.assign({
|
|
812
|
+
name: input.name,
|
|
813
|
+
initialValue: input.value,
|
|
814
|
+
isDisabled: isDisabled,
|
|
815
|
+
autoComplete: "nope",
|
|
816
|
+
onBlur: input.onBlur,
|
|
817
|
+
onChange: input.onChange,
|
|
818
|
+
onFocus: input.onFocus
|
|
819
|
+
}, updatedInputProps)));
|
|
820
|
+
});
|
|
821
|
+
});
|
|
822
|
+
|
|
823
|
+
const FormFieldCustom = /*#__PURE__*/React__default.default.memo(function FormFieldCustom(props) {
|
|
831
824
|
const {
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
825
|
+
Component,
|
|
826
|
+
isDisabled,
|
|
827
|
+
isRequired,
|
|
828
|
+
name,
|
|
829
|
+
initialValue,
|
|
830
|
+
fieldProps = {},
|
|
831
|
+
classNameGroupItem,
|
|
832
|
+
showMessage,
|
|
833
|
+
clearIcon,
|
|
834
|
+
clearIconFill,
|
|
835
|
+
clearIconFillHover,
|
|
836
|
+
clearIconShape,
|
|
837
|
+
clearIconSize,
|
|
838
|
+
onClickClearIcon
|
|
839
|
+
} = props;
|
|
840
|
+
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
841
|
+
initialValue: initialValue,
|
|
842
|
+
name: name
|
|
843
|
+
}, function Render({
|
|
844
|
+
input,
|
|
845
|
+
meta
|
|
846
|
+
}) {
|
|
847
|
+
/** Note:
|
|
848
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
849
|
+
* React Hooks cannot be called inside a callback.
|
|
850
|
+
* React Hooks must be called in a React function component or a
|
|
851
|
+
* custom React Hook function.
|
|
852
|
+
*/
|
|
853
|
+
|
|
854
|
+
const {
|
|
855
|
+
isErrorState,
|
|
856
|
+
isValidState,
|
|
857
|
+
errorKey,
|
|
858
|
+
errorMessage
|
|
859
|
+
} = useFieldValidationState({
|
|
860
|
+
fieldProps: fieldProps,
|
|
861
|
+
input: input,
|
|
862
|
+
meta: meta
|
|
863
|
+
});
|
|
864
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
865
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
866
|
+
// For "Custom" field we pass all props. Can contain some special props, we don't known.
|
|
867
|
+
inputProps: props
|
|
868
|
+
});
|
|
869
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
870
|
+
className: clsx__default.default('form-field_custom', 'form__item_custom', classNameGroupItem),
|
|
871
|
+
errorKey: errorKey,
|
|
872
|
+
errorMessage: errorMessage,
|
|
873
|
+
fieldClassName: 'form-custom',
|
|
874
|
+
inputName: input.name,
|
|
875
|
+
inputValue: input.value,
|
|
876
|
+
isDisabled: isDisabled,
|
|
877
|
+
isErrorState: isErrorState,
|
|
878
|
+
isRequired: isRequired,
|
|
879
|
+
isValidState: isValidState,
|
|
880
|
+
metaActive: meta.active,
|
|
881
|
+
metaError: meta.error,
|
|
882
|
+
showMessage: showMessage
|
|
883
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Component, Object.assign({}, updatedInputProps, {
|
|
884
|
+
input: input,
|
|
885
|
+
isDisabled: isDisabled,
|
|
886
|
+
meta: meta
|
|
887
|
+
})), clearIcon && /*#__PURE__*/React__default.default.createElement(Icon.Icon, {
|
|
888
|
+
className: "form-field__icon",
|
|
889
|
+
iconFill: clearIconFill,
|
|
890
|
+
iconFillHover: clearIconFillHover,
|
|
891
|
+
imageSrc: clearIcon,
|
|
892
|
+
shape: clearIconShape,
|
|
893
|
+
size: clearIconSize,
|
|
894
|
+
SvgImage: clearIcon,
|
|
895
|
+
onClick: onClickClearIcon
|
|
896
|
+
}));
|
|
897
|
+
});
|
|
898
|
+
});
|
|
899
|
+
|
|
900
|
+
const defaultDatepickerProps = {
|
|
901
|
+
appearance: 'surfacePrimary sizeS',
|
|
902
|
+
dateFormat: 'dd/MM/yyyy - HH:mm',
|
|
903
|
+
readOnly: false,
|
|
904
|
+
selectsRange: false,
|
|
905
|
+
showTimeSelect: true,
|
|
906
|
+
timeCaption: 'Время',
|
|
907
|
+
timeFormat: 'p',
|
|
908
|
+
timeIntervals: 60,
|
|
909
|
+
isClearable: true,
|
|
910
|
+
isStartDefaultNull: true
|
|
911
|
+
};
|
|
912
|
+
|
|
913
|
+
function FormFieldDatePicker(props) {
|
|
914
|
+
const {
|
|
915
|
+
name,
|
|
916
|
+
isDisabled,
|
|
917
|
+
classNameGroupItem,
|
|
918
|
+
datePickerProps,
|
|
919
|
+
fieldProps = {},
|
|
920
|
+
inputProps = {},
|
|
921
|
+
showMessage,
|
|
922
|
+
isRequired,
|
|
923
|
+
onChange
|
|
924
|
+
} = props;
|
|
866
925
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
867
926
|
name: name
|
|
868
927
|
}, function Render({
|
|
@@ -876,10 +935,27 @@ const FileInput = /*#__PURE__*/React__default.default.memo(function FileInput(pr
|
|
|
876
935
|
* custom React Hook function.
|
|
877
936
|
*/
|
|
878
937
|
|
|
938
|
+
const onChangeField = React.useCallback((startDate, endDate) => {
|
|
939
|
+
if (!datePickerProps.selectsRange) {
|
|
940
|
+
// When we need to save single date, value is date
|
|
941
|
+
// TODO: make object with one date? need to check all forms with FormFieldDatePicker
|
|
942
|
+
input.onChange(startDate);
|
|
943
|
+
} else {
|
|
944
|
+
// When we need to save range, value is object with two date
|
|
945
|
+
input.onChange({
|
|
946
|
+
endDate,
|
|
947
|
+
startDate
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
if (onChange) {
|
|
951
|
+
onChange(startDate, endDate);
|
|
952
|
+
}
|
|
953
|
+
}, [input.onChange, onChange]);
|
|
879
954
|
const {
|
|
880
955
|
errorKey,
|
|
881
956
|
errorMessage,
|
|
882
957
|
isErrorState,
|
|
958
|
+
successKey,
|
|
883
959
|
isValidState
|
|
884
960
|
} = useFieldValidationState({
|
|
885
961
|
fieldProps: fieldProps,
|
|
@@ -887,423 +963,460 @@ const FileInput = /*#__PURE__*/React__default.default.memo(function FileInput(pr
|
|
|
887
963
|
meta: meta
|
|
888
964
|
});
|
|
889
965
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
890
|
-
inputProps:
|
|
891
|
-
validationStateKey: isErrorState ? errorKey :
|
|
966
|
+
inputProps: inputProps,
|
|
967
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
892
968
|
});
|
|
893
|
-
|
|
894
|
-
/** TODO:
|
|
895
|
-
* REFACTOR PROPERTIES
|
|
896
|
-
*/
|
|
897
969
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
898
|
-
className: clsx__default.default('form-
|
|
899
|
-
width: width,
|
|
900
|
-
label: label,
|
|
901
|
-
labelTextColor: labelTextColor,
|
|
970
|
+
className: clsx__default.default('form-field_datepicker', 'form__item_datepicker', classNameGroupItem),
|
|
902
971
|
errorKey: errorKey,
|
|
903
972
|
errorMessage: errorMessage,
|
|
904
973
|
isErrorState: isErrorState,
|
|
905
974
|
metaError: meta.error,
|
|
906
|
-
|
|
975
|
+
isDisabled: isDisabled,
|
|
976
|
+
fieldClassName: "form-datepicker",
|
|
907
977
|
inputName: input.name,
|
|
908
|
-
inputValue: input.value,
|
|
978
|
+
inputValue: input.value || '',
|
|
909
979
|
metaActive: meta.active,
|
|
910
|
-
metaTouched: meta.touched,
|
|
911
980
|
showMessage: showMessage,
|
|
912
981
|
isRequired: isRequired,
|
|
913
982
|
isValidState: isValidState
|
|
914
|
-
}, fieldProps), /*#__PURE__*/React__default.default.createElement(
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
borderWidth: borderWidth,
|
|
925
|
-
errorMessageTextColor: errorMessageTextColor,
|
|
926
|
-
errorMessageTextSize: errorMessageTextSize,
|
|
927
|
-
errorMessageWeight: errorMessageTextWeight,
|
|
928
|
-
fileErrorText: fileErrorText,
|
|
929
|
-
metaError: meta.error,
|
|
930
|
-
dropzoneProps: dropzoneProps,
|
|
931
|
-
hintDescription: hintDescription,
|
|
932
|
-
hintDescriptionTextColor: hintDescriptionTextColor,
|
|
933
|
-
hintDescriptionTextSize: hintDescriptionTextSize,
|
|
934
|
-
hintDescriptionTextWeight: hintDescriptionTextWeight,
|
|
935
|
-
hintDescriptionTextWrap: hintDescriptionTextWrap,
|
|
936
|
-
hintTitle: hintTitle,
|
|
937
|
-
hintTitleTextColor: hintTitleTextColor,
|
|
938
|
-
hintTitleTextSize: hintTitleTextSize,
|
|
939
|
-
hintTitleTextWeight: hintTitleTextWeight,
|
|
940
|
-
hintTitleTextWrap: hintTitleTextWrap,
|
|
941
|
-
inputName: input.name,
|
|
942
|
-
inputValue: input.value,
|
|
943
|
-
metaTouched: meta.touched,
|
|
944
|
-
removeThumbAppearance: removeThumbAppearance,
|
|
945
|
-
removeThumbShape: removeThumbShape,
|
|
946
|
-
removeThumbText: removeThumbText,
|
|
947
|
-
removeThumbTextWeight: removeThumbTextWeight,
|
|
948
|
-
shape: shape,
|
|
949
|
-
showFilename: showFilename,
|
|
950
|
-
thumbBorderColor: thumbBorderColor,
|
|
951
|
-
thumbBorderColorHover: thumbBorderColorHover,
|
|
952
|
-
thumbBorderType: thumbBorderType,
|
|
953
|
-
thumbBorderWidth: thumbBorderWidth,
|
|
954
|
-
thumbColumn: thumbColumn,
|
|
955
|
-
thumbDirection: thumbDirection,
|
|
956
|
-
thumbNameTextColor: thumbNameTextColor,
|
|
957
|
-
thumbNameTextSize: thumbNameTextSize,
|
|
958
|
-
thumbNameTextWeight: thumbNameTextWeight,
|
|
959
|
-
thumbNameTextWrap: thumbNameTextWrap,
|
|
960
|
-
isPreviews: isPreviews,
|
|
961
|
-
onAddFiles: onAddFiles,
|
|
962
|
-
onClickPreview: onClickPreview,
|
|
963
|
-
onDeleteFile: onDeleteFile
|
|
983
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(DatePicker.DatePickerInput, {
|
|
984
|
+
name: input.name,
|
|
985
|
+
isDisabled: isDisabled,
|
|
986
|
+
datePickerProps: datePickerProps,
|
|
987
|
+
endValue: datePickerProps.selectsRange ? input.value.endDate : null,
|
|
988
|
+
inputProps: updatedInputProps,
|
|
989
|
+
value: datePickerProps.selectsRange ? input.value.startDate : input.value,
|
|
990
|
+
onBlur: input.onBlur,
|
|
991
|
+
onChange: onChangeField,
|
|
992
|
+
onFocus: input.onFocus
|
|
964
993
|
}));
|
|
965
994
|
});
|
|
966
|
-
}
|
|
995
|
+
}
|
|
967
996
|
|
|
968
|
-
const
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
997
|
+
const defaultDropzoneProps = {
|
|
998
|
+
fill: 'surfaceSecondary',
|
|
999
|
+
fillHover: 'surfaceTertiary',
|
|
1000
|
+
// borderColor: 'surfaceBorderTertiary',
|
|
1001
|
+
// borderColorHover: 'surfaceBorderQuaternary',
|
|
1002
|
+
hintTitle: 'Перетащите изображение или выберите файл с компьютера',
|
|
1003
|
+
hintTitleTextColor: 'surfaceTextPrimary',
|
|
1004
|
+
hintTitleTextSize: 'm',
|
|
1005
|
+
removeThumbText: 'удалить',
|
|
1006
|
+
removeThumbTextColor: 'errorTextPrimary',
|
|
1007
|
+
removeThumbTextHoverColor: 'errorTextPrimaryHover',
|
|
1008
|
+
removeThumbTextSize: 's',
|
|
1009
|
+
shape: 'rounded',
|
|
1010
|
+
showFilename: true,
|
|
1011
|
+
thumbBorderColor: 'surfaceBorderTertiary',
|
|
1012
|
+
thumbBorderColorHover: 'surfaceBorderQuaternary',
|
|
1013
|
+
thumbBorderWidth: 1,
|
|
1014
|
+
thumbNameTextColor: 'surfaceTextPrimary',
|
|
1015
|
+
thumbNameTextSize: 's',
|
|
1016
|
+
isPreviews: true
|
|
978
1017
|
};
|
|
979
1018
|
|
|
980
|
-
const
|
|
1019
|
+
const FileInputDropzone = /*#__PURE__*/React__default.default.memo(function FileInputDropzone(props) {
|
|
981
1020
|
const {
|
|
982
|
-
dataTour,
|
|
983
1021
|
className,
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
after,
|
|
1001
|
-
isHidden,
|
|
1002
|
-
children
|
|
1003
|
-
} = props;
|
|
1004
|
-
|
|
1005
|
-
// @ts-expect-error
|
|
1006
|
-
const {
|
|
1007
|
-
styles: styles
|
|
1008
|
-
} = useStyles.useStyles(props);
|
|
1009
|
-
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1010
|
-
name: name
|
|
1011
|
-
}, function Render({
|
|
1012
|
-
input,
|
|
1013
|
-
meta
|
|
1014
|
-
}) {
|
|
1015
|
-
/** Note:
|
|
1016
|
-
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
1017
|
-
* React Hooks cannot be called inside a callback.
|
|
1018
|
-
* React Hooks must be called in a React function component or a
|
|
1019
|
-
* custom React Hook function.
|
|
1020
|
-
*/
|
|
1021
|
-
const {
|
|
1022
|
-
errorKey,
|
|
1023
|
-
errorMessage,
|
|
1024
|
-
isErrorState
|
|
1025
|
-
} = useFieldValidationState({
|
|
1026
|
-
fieldProps: props,
|
|
1027
|
-
// or fieldProps?
|
|
1028
|
-
input: input,
|
|
1029
|
-
meta: meta
|
|
1030
|
-
});
|
|
1031
|
-
const updatedProps = useValidationAppearanceInputProps({
|
|
1032
|
-
inputProps: props,
|
|
1033
|
-
validationStateKey: isErrorState ? errorKey : 'success'
|
|
1034
|
-
});
|
|
1035
|
-
return /*#__PURE__*/React__default.default.createElement("div", {
|
|
1036
|
-
className: clsx__default.default('form__group', className, isHidden && 'form__group_hidden', column && `form__group_column_${column}`),
|
|
1037
|
-
"data-tour": dataTour,
|
|
1038
|
-
style: styles
|
|
1039
|
-
}, /*#__PURE__*/React__default.default.createElement("div", {
|
|
1040
|
-
className: "form__group-wrapper"
|
|
1041
|
-
}, before, title && /*#__PURE__*/React__default.default.createElement("div", {
|
|
1042
|
-
className: "form__group-title"
|
|
1043
|
-
}, /*#__PURE__*/React__default.default.createElement(Title.Title, {
|
|
1044
|
-
size: titleTextSize,
|
|
1045
|
-
textColor: titleTextColor,
|
|
1046
|
-
textWeight: titleTextWeight
|
|
1047
|
-
}, title)), label && /*#__PURE__*/React__default.default.createElement("div", {
|
|
1048
|
-
className: "form__group-label"
|
|
1049
|
-
}, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1050
|
-
size: labelTextSize,
|
|
1051
|
-
textColor: labelTextColor,
|
|
1052
|
-
textWeight: labelTextWeight
|
|
1053
|
-
}, label)), /*#__PURE__*/React__default.default.createElement("div", {
|
|
1054
|
-
className: "form__group-items"
|
|
1055
|
-
}, children), after), showGroupMessage && /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, isErrorState && errorMessage && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1056
|
-
id: `${name}-error`,
|
|
1057
|
-
className: `form__group-message form__group-message_type-${errorKey}`,
|
|
1058
|
-
size: updatedProps.messageTextSize,
|
|
1059
|
-
textColor: updatedProps.messageTextColor,
|
|
1060
|
-
textWeight: updatedProps.messageTextWeight
|
|
1061
|
-
}, errorMessage), Boolean(message) && (!isErrorState || !errorMessage) && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1062
|
-
className: "form__group-message",
|
|
1063
|
-
size: messageTextSize,
|
|
1064
|
-
textColor: messageTextColor,
|
|
1065
|
-
textWeight: messageTextWeight
|
|
1066
|
-
}, message), !isErrorState && !message && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1067
|
-
className: "form__group-message",
|
|
1068
|
-
size: messageTextSize
|
|
1069
|
-
}, '\u00A0')));
|
|
1070
|
-
});
|
|
1071
|
-
});
|
|
1022
|
+
maxFiles,
|
|
1023
|
+
maxSize,
|
|
1024
|
+
size,
|
|
1025
|
+
fileErrorText,
|
|
1026
|
+
dropzoneProps = {},
|
|
1027
|
+
hintDescription,
|
|
1028
|
+
hintTitle,
|
|
1029
|
+
inputName,
|
|
1030
|
+
inputValue,
|
|
1031
|
+
showFilename,
|
|
1032
|
+
thumbColumn,
|
|
1033
|
+
isPreviews,
|
|
1034
|
+
onAddFiles,
|
|
1035
|
+
onClickPreview,
|
|
1036
|
+
onDeleteFile
|
|
1037
|
+
} = props;
|
|
1072
1038
|
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1039
|
+
// TODO: delete react-final-form things out of here?
|
|
1040
|
+
const {
|
|
1041
|
+
change
|
|
1042
|
+
} = reactFinalForm.useForm();
|
|
1043
|
+
const [fileError, setFileError] = React.useState('');
|
|
1044
|
+
const [fileIsLoading, setFileIsLoading] = React.useState(false);
|
|
1045
|
+
const filesList = React.useMemo(() => inputValue ? castArray__default.default(inputValue) : [], [inputValue]);
|
|
1046
|
+
const changeFormState = React.useCallback(newFiles => {
|
|
1047
|
+
// If max files in dropzone is 1 - return file as it self, else as array of files
|
|
1048
|
+
// ps: for old projects compatibility
|
|
1049
|
+
const toSave = dropzoneProps.maxFiles == 1 ? newFiles[0] : newFiles;
|
|
1050
|
+
change(inputName, toSave);
|
|
1051
|
+
return toSave;
|
|
1052
|
+
},
|
|
1053
|
+
// If "inputName" will be changes, then it should be a different field
|
|
1054
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1055
|
+
[dropzoneProps, change]);
|
|
1082
1056
|
|
|
1083
|
-
|
|
1057
|
+
//
|
|
1058
|
+
const convertFiledValueAndSaveAsFiles = React.useCallback(async currentFilesList => {
|
|
1059
|
+
setFileIsLoading(true);
|
|
1060
|
+
const newFiles = [];
|
|
1061
|
+
for (const fileItem of currentFilesList) {
|
|
1062
|
+
if (typeof fileItem === 'string') {
|
|
1063
|
+
const newFile = await convertToFile(fileItem, isPreviews);
|
|
1064
|
+
if (newFile) {
|
|
1065
|
+
newFiles.push(newFile);
|
|
1066
|
+
}
|
|
1067
|
+
} else {
|
|
1068
|
+
newFiles.push(fileItem);
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
changeFormState(newFiles);
|
|
1072
|
+
setFileIsLoading(false);
|
|
1073
|
+
}, [isPreviews, changeFormState]);
|
|
1074
|
+
|
|
1075
|
+
// Delete file from dropzone
|
|
1076
|
+
const removeFile = React.useCallback((event, index) => {
|
|
1077
|
+
event.stopPropagation();
|
|
1078
|
+
event.preventDefault();
|
|
1079
|
+
const newFiles = [...filesList];
|
|
1080
|
+
newFiles.splice(index, 1);
|
|
1081
|
+
if (onDeleteFile) {
|
|
1082
|
+
onDeleteFile(filesList[index], inputName);
|
|
1083
|
+
}
|
|
1084
|
+
changeFormState(newFiles);
|
|
1085
|
+
},
|
|
1086
|
+
// If "inputName" will be changes, then it should be a different field
|
|
1087
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1088
|
+
[filesList, changeFormState, onDeleteFile]);
|
|
1089
|
+
|
|
1090
|
+
// Create dropzone options
|
|
1084
1091
|
const {
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1092
|
+
getInputProps,
|
|
1093
|
+
getRootProps
|
|
1094
|
+
} = reactDropzone.useDropzone({
|
|
1095
|
+
maxFiles: maxFiles || 5,
|
|
1096
|
+
maxSize: maxSize || 10485760,
|
|
1097
|
+
// 10mb
|
|
1098
|
+
// accept: { 'image/*': [] },
|
|
1099
|
+
...dropzoneProps,
|
|
1100
|
+
getFilesFromEvent: async event => {
|
|
1101
|
+
const result = await fileSelector.fromEvent(event);
|
|
1102
|
+
const newFiles = result.filter(item => item instanceof File);
|
|
1103
|
+
// Add exists and new files to accepted(or rejected)
|
|
1104
|
+
return [...filesList, ...newFiles];
|
|
1105
|
+
},
|
|
1106
|
+
onDropAccepted: acceptedFiles => {
|
|
1107
|
+
// If dropped files has accepted and we need a previews
|
|
1108
|
+
if (isPreviews) {
|
|
1109
|
+
// Add preview to every file
|
|
1110
|
+
acceptedFiles.forEach(file => {
|
|
1111
|
+
if (!file.error) {
|
|
1112
|
+
file.preview = URL.createObjectURL(file);
|
|
1113
|
+
}
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
// Save to form data (including empty when files are not valid)
|
|
1117
|
+
const filesToSave = changeFormState(acceptedFiles);
|
|
1118
|
+
setFileError('');
|
|
1109
1119
|
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1120
|
+
// Save DataURL for all files
|
|
1121
|
+
const readerPromisesList = acceptedFiles.map(file => {
|
|
1122
|
+
return new Promise(resolve => setFileDataURL(file, resolve));
|
|
1123
|
+
});
|
|
1124
|
+
// Save files to form values
|
|
1125
|
+
Promise.all(readerPromisesList).then(() => {
|
|
1126
|
+
if (onAddFiles) {
|
|
1127
|
+
onAddFiles(filesToSave, inputName);
|
|
1128
|
+
}
|
|
1129
|
+
});
|
|
1130
|
+
},
|
|
1131
|
+
onDropRejected: rejectedFiles => {
|
|
1132
|
+
// If dropped files has rejected
|
|
1133
|
+
if (rejectedFiles.length) {
|
|
1134
|
+
let fileErrorMessage = 'Ошибка при добавлении файла';
|
|
1135
|
+
const firstFileErrorItem = rejectedFiles[0].errors[0];
|
|
1136
|
+
if (firstFileErrorItem) {
|
|
1137
|
+
if (firstFileErrorItem.code === reactDropzone.ErrorCode.TooManyFiles) {
|
|
1138
|
+
fileErrorMessage = `Максимальное количество файлов: ${maxFiles}`;
|
|
1139
|
+
} else {
|
|
1140
|
+
fileErrorMessage = firstFileErrorItem.message;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
// Show error
|
|
1144
|
+
setFileError(fileErrorMessage);
|
|
1145
|
+
} else {
|
|
1146
|
+
// Else clean error
|
|
1147
|
+
setFileError('');
|
|
1114
1148
|
}
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1149
|
+
}
|
|
1150
|
+
});
|
|
1151
|
+
React.useEffect(() => {
|
|
1152
|
+
const currentFilesList = castArray__default.default(inputValue);
|
|
1153
|
+
const isNeedToConvert = currentFilesList.some(fileItem => typeof fileItem === 'string');
|
|
1154
|
+
if (isNeedToConvert) {
|
|
1155
|
+
// First time convert value to Files and save to local and form state
|
|
1156
|
+
convertFiledValueAndSaveAsFiles(currentFilesList);
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
// Make sure to revoke the data uris to avoid memory leaks, will run on unmount
|
|
1160
|
+
return () => {
|
|
1161
|
+
filesList.forEach(file => {
|
|
1162
|
+
if (file?.preview) {
|
|
1163
|
+
URL.revokeObjectURL(file.preview);
|
|
1164
|
+
}
|
|
1165
|
+
});
|
|
1166
|
+
};
|
|
1167
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1168
|
+
}, [inputValue]);
|
|
1169
|
+
const propsGenerator = useDevicePropsGenerator.useDevicePropsGenerator(props);
|
|
1170
|
+
const {
|
|
1171
|
+
fillClass,
|
|
1172
|
+
fillHoverClass,
|
|
1173
|
+
borderColorClass,
|
|
1174
|
+
borderColorHoverClass,
|
|
1175
|
+
borderTypeClass,
|
|
1176
|
+
borderWidthClass,
|
|
1177
|
+
errorMessageTextColor,
|
|
1178
|
+
errorMessageTextSize,
|
|
1179
|
+
errorMessageTextWeight,
|
|
1180
|
+
hintDescriptionTextColor,
|
|
1181
|
+
hintDescriptionTextSize,
|
|
1182
|
+
hintDescriptionTextWeight,
|
|
1183
|
+
hintDescriptionTextWrap,
|
|
1184
|
+
hintTitleTextColor,
|
|
1185
|
+
hintTitleTextSize,
|
|
1186
|
+
hintTitleTextWeight,
|
|
1187
|
+
hintTitleTextWrap,
|
|
1188
|
+
removeThumbAppearance,
|
|
1189
|
+
removeThumbShape,
|
|
1190
|
+
removeThumbText,
|
|
1191
|
+
removeThumbTextWeight,
|
|
1192
|
+
shapeClass,
|
|
1193
|
+
thumbBorderColorClass,
|
|
1194
|
+
thumbBorderColorHoverClass,
|
|
1195
|
+
thumbBorderTypeClass,
|
|
1196
|
+
thumbBorderWidthClass,
|
|
1197
|
+
thumbDirectionClass,
|
|
1198
|
+
thumbNameTextColor,
|
|
1199
|
+
thumbNameTextSize,
|
|
1200
|
+
thumbNameTextWeight,
|
|
1201
|
+
thumbNameTextWrap
|
|
1202
|
+
} = propsGenerator;
|
|
1203
|
+
return /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, /*#__PURE__*/React__default.default.createElement("div", getRootProps({
|
|
1204
|
+
// className: `form-dropzone__dropzone dropzone ${className} form-dropzone__dropzone_size_${size} ${shapeClass}`,
|
|
1205
|
+
className: `form-dropzone__dropzone dropzone`
|
|
1206
|
+
}), /*#__PURE__*/React__default.default.createElement("input", Object.assign({}, getInputProps(), {
|
|
1207
|
+
name: inputName
|
|
1208
|
+
})), /*#__PURE__*/React__default.default.createElement("div", {
|
|
1209
|
+
className: clsx__default.default('form-dropzone__dropzone-wrapper', thumbColumn && `form-dropzone__dropzone-wrapper_column_${thumbColumn}`, fillClass && `fill_${fillClass}`, fillHoverClass && `fill_hover_${fillHoverClass}`, borderWidthClass && `border-width_${borderWidthClass}`, borderColorClass && `border-color_${borderColorClass}`, borderColorHoverClass && `border-color_hover_${borderColorHoverClass}`, borderTypeClass && `border_type_${borderTypeClass}`, shapeClass && `shape_${shapeClass}`)
|
|
1210
|
+
}, filesList.map((file, index) => /*#__PURE__*/React__default.default.createElement("aside", {
|
|
1211
|
+
className: clsx__default.default('form-dropzone__thumb', fillClass, thumbDirectionClass, thumbBorderWidthClass, thumbBorderColorClass, thumbBorderColorHoverClass, thumbBorderTypeClass),
|
|
1212
|
+
key: file.id || `${file.name}_${index}`
|
|
1213
|
+
}, isPreviews && !file.error && /*#__PURE__*/React__default.default.createElement("div", {
|
|
1214
|
+
className: "form-dropzone__thumb-image"
|
|
1215
|
+
}, /*#__PURE__*/React__default.default.createElement("img", {
|
|
1216
|
+
className: "form-dropzone__thumb-image-inner",
|
|
1217
|
+
src: file.preview || file.image,
|
|
1218
|
+
onClick: event => {
|
|
1219
|
+
onClickPreview && onClickPreview(file, event);
|
|
1220
|
+
},
|
|
1221
|
+
onLoad: () => {
|
|
1222
|
+
// Revoke data uri after image is loaded
|
|
1223
|
+
URL.revokeObjectURL(file.preview);
|
|
1224
|
+
}
|
|
1225
|
+
})), file.error && /*#__PURE__*/React__default.default.createElement("div", null, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1226
|
+
size: thumbNameTextSize,
|
|
1227
|
+
textColor: thumbNameTextColor,
|
|
1228
|
+
textWeight: thumbNameTextWeight,
|
|
1229
|
+
textWrap: thumbNameTextWrap
|
|
1230
|
+
}, fileErrorText || file.error)), showFilename && /*#__PURE__*/React__default.default.createElement("div", {
|
|
1231
|
+
className: "form-dropzone__thumb-name"
|
|
1232
|
+
}, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1233
|
+
className: "form-dropzone__thumb-name-inner",
|
|
1234
|
+
size: thumbNameTextSize,
|
|
1235
|
+
textColor: thumbNameTextColor,
|
|
1236
|
+
textWeight: thumbNameTextWeight,
|
|
1237
|
+
textWrap: thumbNameTextWrap
|
|
1238
|
+
}, file.name)), fileIsLoading && /*#__PURE__*/React__default.default.createElement("div", {
|
|
1239
|
+
className: "form-dropzone__thumb-loader"
|
|
1240
|
+
}, /*#__PURE__*/React__default.default.createElement(Loader.Loader, {
|
|
1241
|
+
width: "fill",
|
|
1242
|
+
height: "fill"
|
|
1243
|
+
})), /*#__PURE__*/React__default.default.createElement("div", {
|
|
1244
|
+
className: clsx__default.default('form-dropzone__thumb-remove')
|
|
1245
|
+
}, /*#__PURE__*/React__default.default.createElement(Button.Button, {
|
|
1246
|
+
className: "form-dropzone__thumb-remove-text",
|
|
1247
|
+
appearance: removeThumbAppearance,
|
|
1248
|
+
label: removeThumbText || 'Удалить',
|
|
1249
|
+
labelTextWeight: removeThumbTextWeight,
|
|
1250
|
+
shape: removeThumbShape,
|
|
1251
|
+
onClick: event => removeFile(event, index)
|
|
1252
|
+
})))), !filesList.length ? /*#__PURE__*/React__default.default.createElement("div", {
|
|
1253
|
+
className: "form-dropzone__hint"
|
|
1254
|
+
}, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1255
|
+
className: "form-dropzone__hint-title",
|
|
1256
|
+
size: hintTitleTextSize,
|
|
1257
|
+
textColor: hintTitleTextColor,
|
|
1258
|
+
textWeight: hintTitleTextWeight,
|
|
1259
|
+
textWrap: hintTitleTextWrap
|
|
1260
|
+
}, hintTitle || 'Select a file or drag in form'), hintDescription && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1261
|
+
className: "form-dropzone__hint-text",
|
|
1262
|
+
size: hintDescriptionTextSize,
|
|
1263
|
+
textColor: hintDescriptionTextColor,
|
|
1264
|
+
textWeight: hintDescriptionTextWeight,
|
|
1265
|
+
textWrap: hintDescriptionTextWrap
|
|
1266
|
+
}, hintDescription)) : /*#__PURE__*/React__default.default.createElement("div", {
|
|
1267
|
+
className: "form-dropzone__hint form-dropzone__hint_type_add-more"
|
|
1268
|
+
}, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1269
|
+
className: "form-dropzone__hint-title",
|
|
1270
|
+
size: hintTitleTextSize,
|
|
1271
|
+
textColor: hintTitleTextColor,
|
|
1272
|
+
textWeight: hintTitleTextWeight,
|
|
1273
|
+
textWrap: hintTitleTextWrap
|
|
1274
|
+
}, hintTitle || 'Select a file or drag in form'), hintDescription && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1275
|
+
className: "form-dropzone__hint-text",
|
|
1276
|
+
size: hintDescriptionTextSize,
|
|
1277
|
+
textColor: hintDescriptionTextColor,
|
|
1278
|
+
textWeight: hintDescriptionTextWeight,
|
|
1279
|
+
textWrap: hintDescriptionTextWrap
|
|
1280
|
+
}, hintDescription)))), fileError && /*#__PURE__*/React__default.default.createElement("div", {
|
|
1281
|
+
className: "form-field__message"
|
|
1282
|
+
}, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1283
|
+
className: "form-field__message-item form-field__message-item_type_message",
|
|
1284
|
+
size: errorMessageTextSize,
|
|
1285
|
+
textColor: errorMessageTextColor,
|
|
1286
|
+
textWeight: errorMessageTextWeight
|
|
1287
|
+
}, fileError)));
|
|
1288
|
+
});
|
|
1289
|
+
async function getFileByURL(url) {
|
|
1290
|
+
try {
|
|
1291
|
+
const response = await axios__default.default({
|
|
1292
|
+
url: url,
|
|
1293
|
+
responseType: 'blob'
|
|
1126
1294
|
});
|
|
1127
|
-
const
|
|
1128
|
-
|
|
1129
|
-
|
|
1295
|
+
const blobObject = response.data;
|
|
1296
|
+
const dirtyFilename = response.headers['content-disposition']?.split('filename=')[1];
|
|
1297
|
+
// Remove double quotes
|
|
1298
|
+
let filename = dirtyFilename?.substring(1).slice(0, -1);
|
|
1299
|
+
if (!filename) {
|
|
1300
|
+
filename = url.split('/').at(-1);
|
|
1301
|
+
// const typeParts = blobObject.type.split('/')
|
|
1302
|
+
// const fileType = typeParts[typeParts.length - 1]
|
|
1303
|
+
// filename = `${new Date().getTime()}.${fileType}`
|
|
1304
|
+
}
|
|
1305
|
+
return new File([blobObject], filename, {
|
|
1306
|
+
type: blobObject.type
|
|
1130
1307
|
});
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
fieldClassName: "form-checkbox",
|
|
1139
|
-
inputName: input.name,
|
|
1140
|
-
inputValue: input.checked,
|
|
1141
|
-
metaActive: meta.active,
|
|
1142
|
-
showMessage: showMessage,
|
|
1143
|
-
tag: "label",
|
|
1144
|
-
isRequired: isRequired,
|
|
1145
|
-
isValidState: isValidState
|
|
1146
|
-
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Checkbox.Checkbox, Object.assign({
|
|
1147
|
-
type: "checkbox",
|
|
1148
|
-
name: input.name,
|
|
1149
|
-
isDisabled: isDisabled,
|
|
1150
|
-
autoComplete: "nope",
|
|
1151
|
-
checked: input.checked,
|
|
1152
|
-
isActive: input.checked,
|
|
1153
|
-
onBlur: input.onBlur,
|
|
1154
|
-
onChange: onChangeField,
|
|
1155
|
-
onFocus: input.onFocus
|
|
1156
|
-
}, updatedInputProps)));
|
|
1157
|
-
});
|
|
1158
|
-
});
|
|
1308
|
+
} catch (error) {
|
|
1309
|
+
console.log('error: ', error);
|
|
1310
|
+
return null;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
async function convertToFile(inputValue, isPreviews) {
|
|
1314
|
+
let newFile = null;
|
|
1159
1315
|
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
// Success
|
|
1169
|
-
// successAppearance: 'successPrimary sizeM solid rounded',
|
|
1170
|
-
};
|
|
1316
|
+
// Download image by url and save as File instance
|
|
1317
|
+
const isURL = typeof inputValue === 'string' && inputValue.includes('/');
|
|
1318
|
+
if (inputValue.image || isURL) {
|
|
1319
|
+
newFile = await getFileByURL(inputValue.image || inputValue);
|
|
1320
|
+
if (newFile) {
|
|
1321
|
+
setFileDataURL(newFile);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1171
1324
|
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
name,
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
classNameGroupItem,
|
|
1178
|
-
emptyMessage,
|
|
1179
|
-
emptyMessageTextColor,
|
|
1180
|
-
emptyMessageTextSize,
|
|
1181
|
-
fieldProps,
|
|
1182
|
-
inputProps,
|
|
1183
|
-
options,
|
|
1184
|
-
showMessage,
|
|
1185
|
-
isRequired,
|
|
1186
|
-
onChange
|
|
1187
|
-
} = props;
|
|
1188
|
-
const {
|
|
1189
|
-
change
|
|
1190
|
-
} = reactFinalForm.useForm();
|
|
1325
|
+
// Convert dataURL to File instance
|
|
1326
|
+
if (inputValue.dataURL) {
|
|
1327
|
+
newFile = common.createFileFromDataURL(inputValue.name || inputValue.path, inputValue.dataURL);
|
|
1328
|
+
newFile.dataURL = inputValue.dataURL;
|
|
1329
|
+
}
|
|
1191
1330
|
|
|
1192
|
-
//
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
// update the form value only when the initialValue changes, so use disable eslint to ignore the warning
|
|
1201
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1202
|
-
}, [initialValue]);
|
|
1203
|
-
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1204
|
-
name: name,
|
|
1205
|
-
initialValue: initialValue
|
|
1206
|
-
}, function Render({
|
|
1207
|
-
input,
|
|
1208
|
-
meta
|
|
1209
|
-
}) {
|
|
1210
|
-
const {
|
|
1211
|
-
errorKey,
|
|
1212
|
-
errorMessage,
|
|
1213
|
-
isErrorState,
|
|
1214
|
-
successKey,
|
|
1215
|
-
isValidState
|
|
1216
|
-
} = useFieldValidationState({
|
|
1217
|
-
fieldProps: fieldProps,
|
|
1218
|
-
input: input,
|
|
1219
|
-
meta: meta
|
|
1220
|
-
});
|
|
1221
|
-
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1222
|
-
inputProps: inputProps,
|
|
1223
|
-
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1224
|
-
});
|
|
1225
|
-
const activeOptionsList = React.useMemo(() => {
|
|
1226
|
-
const emptyOptionsList = [{
|
|
1227
|
-
label: null,
|
|
1228
|
-
value: null
|
|
1229
|
-
}];
|
|
1230
|
-
if (input?.value) {
|
|
1231
|
-
const currentOptions = options.filter(option => input.value?.includes(option.value));
|
|
1232
|
-
return currentOptions || emptyOptionsList;
|
|
1233
|
-
}
|
|
1234
|
-
return emptyOptionsList;
|
|
1235
|
-
}, [input.value]);
|
|
1236
|
-
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1237
|
-
className: clsx__default.default('form-field_chips', 'form__item_chips', classNameGroupItem),
|
|
1238
|
-
errorKey: errorKey,
|
|
1239
|
-
errorMessage: errorMessage,
|
|
1240
|
-
isErrorState: isErrorState,
|
|
1241
|
-
metaError: meta.error,
|
|
1242
|
-
isDisabled: isDisabled,
|
|
1243
|
-
fieldClassName: "form-chips",
|
|
1244
|
-
inputName: input.name,
|
|
1245
|
-
inputValue: input.value,
|
|
1246
|
-
metaActive: meta.active,
|
|
1247
|
-
showMessage: showMessage,
|
|
1248
|
-
isRequired: isRequired,
|
|
1249
|
-
isValidState: isValidState
|
|
1250
|
-
}, fieldProps), options.length ? /*#__PURE__*/React__default.default.createElement(Chips.ChipsGroup, {
|
|
1251
|
-
direction: "horizontal",
|
|
1252
|
-
gap: "1m",
|
|
1253
|
-
wrap: "wrap"
|
|
1254
|
-
}, options.map(option => /*#__PURE__*/React__default.default.createElement(Chips.Chips, Object.assign({
|
|
1255
|
-
className: clsx__default.default(meta.active && 'form-chips_state_focus', meta.error && meta.touched && `form-chips_state_${errorKey}`),
|
|
1256
|
-
key: option.value,
|
|
1257
|
-
label: option.label,
|
|
1258
|
-
isDisabled: option.isDisabled,
|
|
1259
|
-
value: option.value,
|
|
1260
|
-
isActive: activeOptionsList.some(activeOption => activeOption.value === option.value),
|
|
1261
|
-
onClick: () => onChangeSomeInput(input.value, option.value)
|
|
1262
|
-
}, updatedInputProps)))) : /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1263
|
-
size: emptyMessageTextSize,
|
|
1264
|
-
textColor: emptyMessageTextColor
|
|
1265
|
-
}, emptyMessage));
|
|
1266
|
-
});
|
|
1331
|
+
// Save new File to state
|
|
1332
|
+
if (newFile) {
|
|
1333
|
+
newFile.id = inputValue.id;
|
|
1334
|
+
if (isPreviews) {
|
|
1335
|
+
newFile.preview = URL.createObjectURL(newFile);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
return newFile;
|
|
1267
1339
|
}
|
|
1340
|
+
function setFileDataURL(file, resolve) {
|
|
1341
|
+
resolve = resolve || (() => {});
|
|
1342
|
+
// Init reader and save his file
|
|
1343
|
+
const reader = new FileReader();
|
|
1344
|
+
reader._readedFile = file;
|
|
1268
1345
|
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1346
|
+
// Set handlers
|
|
1347
|
+
reader.onabort = () => resolve();
|
|
1348
|
+
reader.onerror = () => resolve();
|
|
1349
|
+
reader.onload = event => {
|
|
1350
|
+
event.target._readedFile.dataURL = reader.result;
|
|
1351
|
+
resolve();
|
|
1352
|
+
};
|
|
1353
|
+
// Run reader
|
|
1354
|
+
if (file instanceof File) {
|
|
1355
|
+
reader.readAsDataURL(file);
|
|
1356
|
+
} else {
|
|
1357
|
+
resolve();
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1278
1360
|
|
|
1279
|
-
const
|
|
1361
|
+
const FormFieldFileInput = /*#__PURE__*/React__default.default.memo(function FormFieldFileInput(props) {
|
|
1280
1362
|
const {
|
|
1363
|
+
className,
|
|
1281
1364
|
name,
|
|
1282
|
-
|
|
1365
|
+
width,
|
|
1366
|
+
maxFiles,
|
|
1367
|
+
maxSize,
|
|
1283
1368
|
label,
|
|
1284
|
-
|
|
1285
|
-
isDisabled,
|
|
1369
|
+
fileErrorText,
|
|
1286
1370
|
classNameGroupItem,
|
|
1371
|
+
dropzoneProps,
|
|
1287
1372
|
fieldProps,
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1373
|
+
hintDescription,
|
|
1374
|
+
hintTitle,
|
|
1375
|
+
showFilename,
|
|
1291
1376
|
showMessage,
|
|
1292
|
-
|
|
1377
|
+
isPreviews,
|
|
1293
1378
|
isRequired,
|
|
1294
|
-
|
|
1379
|
+
onAddFiles,
|
|
1380
|
+
onClickPreview,
|
|
1381
|
+
onDeleteFile
|
|
1295
1382
|
} = props;
|
|
1383
|
+
const propsGenerator = useDevicePropsGenerator.useDevicePropsGenerator(props);
|
|
1296
1384
|
const {
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1385
|
+
size,
|
|
1386
|
+
fill,
|
|
1387
|
+
fillHover,
|
|
1388
|
+
labelTextColor,
|
|
1389
|
+
borderColorHover,
|
|
1390
|
+
borderType,
|
|
1391
|
+
borderWidth,
|
|
1392
|
+
errorMessageTextColor,
|
|
1393
|
+
errorMessageTextSize,
|
|
1394
|
+
errorMessageTextWeight,
|
|
1395
|
+
hintDescriptionTextColor,
|
|
1396
|
+
hintDescriptionTextSize,
|
|
1397
|
+
hintDescriptionTextWeight,
|
|
1398
|
+
hintDescriptionTextWrap,
|
|
1399
|
+
hintTitleTextColor,
|
|
1400
|
+
hintTitleTextSize,
|
|
1401
|
+
hintTitleTextWeight,
|
|
1402
|
+
hintTitleTextWrap,
|
|
1403
|
+
removeThumbAppearance,
|
|
1404
|
+
removeThumbShape,
|
|
1405
|
+
removeThumbText,
|
|
1406
|
+
removeThumbTextWeight,
|
|
1407
|
+
shape,
|
|
1408
|
+
thumbBorderColor,
|
|
1409
|
+
thumbBorderColorHover,
|
|
1410
|
+
thumbBorderType,
|
|
1411
|
+
thumbBorderWidth,
|
|
1412
|
+
thumbColumn = 1,
|
|
1413
|
+
thumbDirection = 'vertical',
|
|
1414
|
+
thumbNameTextColor,
|
|
1415
|
+
thumbNameTextSize,
|
|
1416
|
+
thumbNameTextWeight,
|
|
1417
|
+
thumbNameTextWrap
|
|
1418
|
+
} = propsGenerator;
|
|
1305
1419
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1306
|
-
initialValue: initialValue,
|
|
1307
1420
|
name: name
|
|
1308
1421
|
}, function Render({
|
|
1309
1422
|
input,
|
|
@@ -1315,22 +1428,11 @@ const FormFieldChoice = /*#__PURE__*/React__default.default.memo(function FormFi
|
|
|
1315
1428
|
* React Hooks must be called in a React function component or a
|
|
1316
1429
|
* custom React Hook function.
|
|
1317
1430
|
*/
|
|
1318
|
-
|
|
1319
|
-
const emptyOption = {
|
|
1320
|
-
value: null,
|
|
1321
|
-
label: null
|
|
1322
|
-
};
|
|
1323
|
-
if (input.value) {
|
|
1324
|
-
const currentOption = options.find(option => option.value === input.value);
|
|
1325
|
-
return currentOption || emptyOption;
|
|
1326
|
-
}
|
|
1327
|
-
return emptyOption;
|
|
1328
|
-
}, [input.value]);
|
|
1431
|
+
|
|
1329
1432
|
const {
|
|
1330
1433
|
errorKey,
|
|
1331
1434
|
errorMessage,
|
|
1332
1435
|
isErrorState,
|
|
1333
|
-
successKey,
|
|
1334
1436
|
isValidState
|
|
1335
1437
|
} = useFieldValidationState({
|
|
1336
1438
|
fieldProps: fieldProps,
|
|
@@ -1338,65 +1440,127 @@ const FormFieldChoice = /*#__PURE__*/React__default.default.memo(function FormFi
|
|
|
1338
1440
|
meta: meta
|
|
1339
1441
|
});
|
|
1340
1442
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1341
|
-
inputProps:
|
|
1342
|
-
validationStateKey: isErrorState ? errorKey :
|
|
1443
|
+
inputProps: props,
|
|
1444
|
+
validationStateKey: isErrorState ? errorKey : 'success'
|
|
1343
1445
|
});
|
|
1446
|
+
|
|
1447
|
+
/** TODO:
|
|
1448
|
+
* REFACTOR PROPERTIES
|
|
1449
|
+
*/
|
|
1344
1450
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1345
|
-
className: clsx__default.default('form-
|
|
1451
|
+
className: clsx__default.default('form-field_type_dropzone', 'form__item_type_dropzone', classNameGroupItem),
|
|
1452
|
+
width: width,
|
|
1346
1453
|
label: label,
|
|
1347
|
-
|
|
1454
|
+
labelTextColor: labelTextColor,
|
|
1348
1455
|
errorKey: errorKey,
|
|
1349
1456
|
errorMessage: errorMessage,
|
|
1350
1457
|
isErrorState: isErrorState,
|
|
1351
1458
|
metaError: meta.error,
|
|
1352
|
-
|
|
1353
|
-
fieldClassName: "form-choice",
|
|
1459
|
+
fieldClassName: "form-dropzone",
|
|
1354
1460
|
inputName: input.name,
|
|
1355
|
-
inputValue: input.value
|
|
1461
|
+
inputValue: input.value,
|
|
1356
1462
|
metaActive: meta.active,
|
|
1463
|
+
metaTouched: meta.touched,
|
|
1357
1464
|
showMessage: showMessage,
|
|
1358
1465
|
isRequired: isRequired,
|
|
1359
1466
|
isValidState: isValidState
|
|
1360
|
-
}, fieldProps), /*#__PURE__*/React__default.default.createElement(
|
|
1361
|
-
className:
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1467
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(FileInputDropzone, {
|
|
1468
|
+
className: className,
|
|
1469
|
+
maxFiles: maxFiles,
|
|
1470
|
+
maxSize: maxSize,
|
|
1471
|
+
size: size,
|
|
1472
|
+
fill: fill,
|
|
1473
|
+
fillHover: fillHover,
|
|
1474
|
+
borderColor: updatedInputProps.borderColor,
|
|
1475
|
+
borderColorHover: borderColorHover,
|
|
1476
|
+
borderType: borderType,
|
|
1477
|
+
borderWidth: borderWidth,
|
|
1478
|
+
errorMessageTextColor: errorMessageTextColor,
|
|
1479
|
+
errorMessageTextSize: errorMessageTextSize,
|
|
1480
|
+
errorMessageWeight: errorMessageTextWeight,
|
|
1481
|
+
fileErrorText: fileErrorText,
|
|
1482
|
+
metaError: meta.error,
|
|
1483
|
+
dropzoneProps: dropzoneProps,
|
|
1484
|
+
hintDescription: hintDescription,
|
|
1485
|
+
hintDescriptionTextColor: hintDescriptionTextColor,
|
|
1486
|
+
hintDescriptionTextSize: hintDescriptionTextSize,
|
|
1487
|
+
hintDescriptionTextWeight: hintDescriptionTextWeight,
|
|
1488
|
+
hintDescriptionTextWrap: hintDescriptionTextWrap,
|
|
1489
|
+
hintTitle: hintTitle,
|
|
1490
|
+
hintTitleTextColor: hintTitleTextColor,
|
|
1491
|
+
hintTitleTextSize: hintTitleTextSize,
|
|
1492
|
+
hintTitleTextWeight: hintTitleTextWeight,
|
|
1493
|
+
hintTitleTextWrap: hintTitleTextWrap,
|
|
1494
|
+
inputName: input.name,
|
|
1495
|
+
inputValue: input.value,
|
|
1496
|
+
metaTouched: meta.touched,
|
|
1497
|
+
removeThumbAppearance: removeThumbAppearance,
|
|
1498
|
+
removeThumbShape: removeThumbShape,
|
|
1499
|
+
removeThumbText: removeThumbText,
|
|
1500
|
+
removeThumbTextWeight: removeThumbTextWeight,
|
|
1501
|
+
shape: shape,
|
|
1502
|
+
showFilename: showFilename,
|
|
1503
|
+
thumbBorderColor: thumbBorderColor,
|
|
1504
|
+
thumbBorderColorHover: thumbBorderColorHover,
|
|
1505
|
+
thumbBorderType: thumbBorderType,
|
|
1506
|
+
thumbBorderWidth: thumbBorderWidth,
|
|
1507
|
+
thumbColumn: thumbColumn,
|
|
1508
|
+
thumbDirection: thumbDirection,
|
|
1509
|
+
thumbNameTextColor: thumbNameTextColor,
|
|
1510
|
+
thumbNameTextSize: thumbNameTextSize,
|
|
1511
|
+
thumbNameTextWeight: thumbNameTextWeight,
|
|
1512
|
+
thumbNameTextWrap: thumbNameTextWrap,
|
|
1513
|
+
isPreviews: isPreviews,
|
|
1514
|
+
onAddFiles: onAddFiles,
|
|
1515
|
+
onClickPreview: onClickPreview,
|
|
1516
|
+
onDeleteFile: onDeleteFile
|
|
1517
|
+
}));
|
|
1372
1518
|
});
|
|
1373
1519
|
});
|
|
1374
1520
|
|
|
1375
|
-
const
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1521
|
+
const defaultGroupProps = {
|
|
1522
|
+
width: 'fill',
|
|
1523
|
+
labelTextSize: 's',
|
|
1524
|
+
messageTextColor: 'surfaceTextPrimary',
|
|
1525
|
+
messageTextSize: 's',
|
|
1526
|
+
errorMessageTextSize: 's',
|
|
1527
|
+
errorMessageTextColor: 'errorTextSecondary',
|
|
1528
|
+
helpTextSize: 's',
|
|
1529
|
+
requiredMessageTextColor: 'warningTextSecondary',
|
|
1530
|
+
requiredMessageTextSize: 's'
|
|
1382
1531
|
};
|
|
1383
1532
|
|
|
1384
|
-
const
|
|
1533
|
+
const FormBlockGroup = /*#__PURE__*/React__default.default.memo(function Group(props) {
|
|
1385
1534
|
const {
|
|
1535
|
+
dataTour,
|
|
1536
|
+
className,
|
|
1386
1537
|
name,
|
|
1387
|
-
|
|
1538
|
+
title,
|
|
1539
|
+
titleTextColor,
|
|
1540
|
+
titleTextSize,
|
|
1541
|
+
titleTextWeight,
|
|
1388
1542
|
label,
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1543
|
+
labelTextColor,
|
|
1544
|
+
labelTextSize,
|
|
1545
|
+
labelTextWeight,
|
|
1546
|
+
message,
|
|
1547
|
+
messageTextColor,
|
|
1548
|
+
messageTextSize,
|
|
1549
|
+
messageTextWeight,
|
|
1550
|
+
column,
|
|
1551
|
+
showGroupMessage,
|
|
1552
|
+
before,
|
|
1553
|
+
after,
|
|
1554
|
+
isHidden,
|
|
1555
|
+
children
|
|
1396
1556
|
} = props;
|
|
1557
|
+
|
|
1558
|
+
// @ts-expect-error
|
|
1559
|
+
const {
|
|
1560
|
+
styles: styles
|
|
1561
|
+
} = useStyles.useStyles(props);
|
|
1397
1562
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1398
|
-
name: name
|
|
1399
|
-
initialValue: initialValue
|
|
1563
|
+
name: name
|
|
1400
1564
|
}, function Render({
|
|
1401
1565
|
input,
|
|
1402
1566
|
meta
|
|
@@ -1407,68 +1571,93 @@ const FormFieldCode = /*#__PURE__*/React__default.default.memo(function FormFiel
|
|
|
1407
1571
|
* React Hooks must be called in a React function component or a
|
|
1408
1572
|
* custom React Hook function.
|
|
1409
1573
|
*/
|
|
1410
|
-
|
|
1411
1574
|
const {
|
|
1412
1575
|
errorKey,
|
|
1413
1576
|
errorMessage,
|
|
1414
|
-
isErrorState
|
|
1415
|
-
successKey,
|
|
1416
|
-
isValidState
|
|
1577
|
+
isErrorState
|
|
1417
1578
|
} = useFieldValidationState({
|
|
1418
|
-
fieldProps:
|
|
1579
|
+
fieldProps: props,
|
|
1580
|
+
// or fieldProps?
|
|
1419
1581
|
input: input,
|
|
1420
1582
|
meta: meta
|
|
1421
1583
|
});
|
|
1422
|
-
const
|
|
1423
|
-
inputProps:
|
|
1424
|
-
validationStateKey: isErrorState ? errorKey :
|
|
1584
|
+
const updatedProps = useValidationAppearanceInputProps({
|
|
1585
|
+
inputProps: props,
|
|
1586
|
+
validationStateKey: isErrorState ? errorKey : 'success'
|
|
1425
1587
|
});
|
|
1426
|
-
return /*#__PURE__*/React__default.default.createElement(
|
|
1427
|
-
className: clsx__default.default('
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
},
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1588
|
+
return /*#__PURE__*/React__default.default.createElement("div", {
|
|
1589
|
+
className: clsx__default.default('form__group', className, isHidden && 'form__group_hidden', column && `form__group_column_${column}`),
|
|
1590
|
+
"data-tour": dataTour,
|
|
1591
|
+
style: styles
|
|
1592
|
+
}, /*#__PURE__*/React__default.default.createElement("div", {
|
|
1593
|
+
className: "form__group-wrapper"
|
|
1594
|
+
}, before, title && /*#__PURE__*/React__default.default.createElement("div", {
|
|
1595
|
+
className: "form__group-title"
|
|
1596
|
+
}, /*#__PURE__*/React__default.default.createElement(Title.Title, {
|
|
1597
|
+
size: titleTextSize,
|
|
1598
|
+
textColor: titleTextColor,
|
|
1599
|
+
textWeight: titleTextWeight
|
|
1600
|
+
}, title)), label && /*#__PURE__*/React__default.default.createElement("div", {
|
|
1601
|
+
className: "form__group-label"
|
|
1602
|
+
}, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1603
|
+
size: labelTextSize,
|
|
1604
|
+
textColor: labelTextColor,
|
|
1605
|
+
textWeight: labelTextWeight
|
|
1606
|
+
}, label)), /*#__PURE__*/React__default.default.createElement("div", {
|
|
1607
|
+
className: "form__group-items"
|
|
1608
|
+
}, children), after), showGroupMessage && /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, isErrorState && errorMessage && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1609
|
+
id: `${name}-error`,
|
|
1610
|
+
className: `form__group-message form__group-message_type-${errorKey}`,
|
|
1611
|
+
size: updatedProps.messageTextSize,
|
|
1612
|
+
textColor: updatedProps.messageTextColor,
|
|
1613
|
+
textWeight: updatedProps.messageTextWeight
|
|
1614
|
+
}, errorMessage), Boolean(message) && (!isErrorState || !errorMessage) && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1615
|
+
className: "form__group-message",
|
|
1616
|
+
size: messageTextSize,
|
|
1617
|
+
textColor: messageTextColor,
|
|
1618
|
+
textWeight: messageTextWeight
|
|
1619
|
+
}, message), !isErrorState && !message && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1620
|
+
className: "form__group-message",
|
|
1621
|
+
size: messageTextSize
|
|
1622
|
+
}, '\u00A0')));
|
|
1449
1623
|
});
|
|
1450
1624
|
});
|
|
1451
1625
|
|
|
1452
|
-
const
|
|
1626
|
+
const defaultInputProps = {
|
|
1627
|
+
appearance: 'defaultPrimary sizeM solid rounded',
|
|
1628
|
+
width: 'fill',
|
|
1629
|
+
// useValidationAppearanceInputProps
|
|
1630
|
+
// Error
|
|
1631
|
+
errorAppearance: 'errorPrimary sizeM solid rounded',
|
|
1632
|
+
// Required
|
|
1633
|
+
requiredAppearance: 'requirePrimary sizeM solid rounded',
|
|
1634
|
+
// Success
|
|
1635
|
+
successAppearance: 'successPrimary sizeM solid rounded'
|
|
1636
|
+
};
|
|
1637
|
+
|
|
1638
|
+
const FormFieldInput = /*#__PURE__*/React__default.default.memo(function FormFieldInput(props) {
|
|
1453
1639
|
const {
|
|
1454
|
-
Component,
|
|
1455
|
-
isDisabled,
|
|
1456
|
-
isRequired,
|
|
1457
1640
|
name,
|
|
1458
1641
|
initialValue,
|
|
1459
|
-
fieldProps = {},
|
|
1460
1642
|
classNameGroupItem,
|
|
1461
|
-
showMessage,
|
|
1462
1643
|
clearIcon,
|
|
1463
1644
|
clearIconFill,
|
|
1464
1645
|
clearIconFillHover,
|
|
1465
1646
|
clearIconShape,
|
|
1466
1647
|
clearIconSize,
|
|
1467
|
-
|
|
1648
|
+
fieldProps = {},
|
|
1649
|
+
inputProps = {},
|
|
1650
|
+
parse,
|
|
1651
|
+
showMessage,
|
|
1652
|
+
isDisabled,
|
|
1653
|
+
isRequired,
|
|
1654
|
+
onClickClearIcon,
|
|
1655
|
+
onChange
|
|
1468
1656
|
} = props;
|
|
1469
1657
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1658
|
+
name: name,
|
|
1470
1659
|
initialValue: initialValue,
|
|
1471
|
-
|
|
1660
|
+
parse: parse
|
|
1472
1661
|
}, function Render({
|
|
1473
1662
|
input,
|
|
1474
1663
|
meta
|
|
@@ -1480,79 +1669,87 @@ const FormFieldCustom = /*#__PURE__*/React__default.default.memo(function FormFi
|
|
|
1480
1669
|
* custom React Hook function.
|
|
1481
1670
|
*/
|
|
1482
1671
|
|
|
1672
|
+
const onChangeField = React.useCallback(event => {
|
|
1673
|
+
input.onChange(event);
|
|
1674
|
+
if (onChange) {
|
|
1675
|
+
onChange(event.target.value, input.name);
|
|
1676
|
+
}
|
|
1677
|
+
}, [onChange, input.onChange]);
|
|
1483
1678
|
const {
|
|
1484
|
-
isErrorState,
|
|
1485
|
-
isValidState,
|
|
1486
1679
|
errorKey,
|
|
1487
|
-
errorMessage
|
|
1680
|
+
errorMessage,
|
|
1681
|
+
successKey,
|
|
1682
|
+
isErrorState,
|
|
1683
|
+
isValidState
|
|
1488
1684
|
} = useFieldValidationState({
|
|
1489
1685
|
fieldProps: fieldProps,
|
|
1490
1686
|
input: input,
|
|
1491
1687
|
meta: meta
|
|
1492
1688
|
});
|
|
1493
1689
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
inputProps: props
|
|
1690
|
+
inputProps: inputProps,
|
|
1691
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1497
1692
|
});
|
|
1498
1693
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1499
|
-
className: clsx__default.default('form-
|
|
1694
|
+
className: clsx__default.default('form-field_input', 'form__item_input', classNameGroupItem),
|
|
1500
1695
|
errorKey: errorKey,
|
|
1501
1696
|
errorMessage: errorMessage,
|
|
1502
|
-
fieldClassName:
|
|
1697
|
+
fieldClassName: "form-input",
|
|
1503
1698
|
inputName: input.name,
|
|
1504
|
-
inputValue: input.value,
|
|
1699
|
+
inputValue: input.value || '',
|
|
1700
|
+
metaActive: meta.active,
|
|
1701
|
+
metaError: meta.error,
|
|
1702
|
+
showMessage: showMessage,
|
|
1505
1703
|
isDisabled: isDisabled,
|
|
1506
1704
|
isErrorState: isErrorState,
|
|
1507
1705
|
isRequired: isRequired,
|
|
1508
|
-
isValidState: isValidState
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1706
|
+
isValidState: isValidState
|
|
1707
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Input.Input, Object.assign({
|
|
1708
|
+
className: clsx__default.default(meta.active && 'input_state_focus', meta.error && meta.touched && `input_state_${errorKey}`),
|
|
1709
|
+
dataTestId: `${input.name}FieldInput`,
|
|
1710
|
+
type: "text",
|
|
1711
|
+
name: input.name,
|
|
1712
|
+
autoComplete: "nope",
|
|
1713
|
+
value: input.value || '',
|
|
1514
1714
|
isDisabled: isDisabled,
|
|
1515
|
-
|
|
1516
|
-
|
|
1715
|
+
onBlur: input.onBlur,
|
|
1716
|
+
onChange: onChangeField,
|
|
1717
|
+
onFocus: input.onFocus
|
|
1718
|
+
}, updatedInputProps)), clearIcon && /*#__PURE__*/React__default.default.createElement(Icon.Icon, {
|
|
1517
1719
|
className: "form-field__icon",
|
|
1720
|
+
size: clearIconSize,
|
|
1518
1721
|
iconFill: clearIconFill,
|
|
1519
1722
|
iconFillHover: clearIconFillHover,
|
|
1520
|
-
imageSrc: clearIcon,
|
|
1723
|
+
imageSrc: typeof clearIcon === 'string' && clearIcon,
|
|
1521
1724
|
shape: clearIconShape,
|
|
1522
|
-
|
|
1523
|
-
SvgImage: clearIcon,
|
|
1725
|
+
SvgImage: typeof clearIcon !== 'string' && clearIcon,
|
|
1524
1726
|
onClick: onClickClearIcon
|
|
1525
1727
|
}));
|
|
1526
1728
|
});
|
|
1527
1729
|
});
|
|
1528
1730
|
|
|
1529
|
-
const
|
|
1530
|
-
appearance: 'surfacePrimary sizeS',
|
|
1531
|
-
dateFormat: 'dd/MM/yyyy - HH:mm',
|
|
1532
|
-
readOnly: false,
|
|
1533
|
-
selectsRange: false,
|
|
1534
|
-
showTimeSelect: true,
|
|
1535
|
-
timeCaption: 'Время',
|
|
1536
|
-
timeFormat: 'p',
|
|
1537
|
-
timeIntervals: 60,
|
|
1538
|
-
isClearable: true,
|
|
1539
|
-
isStartDefaultNull: true
|
|
1540
|
-
};
|
|
1541
|
-
|
|
1542
|
-
function FormFieldDatePicker(props) {
|
|
1731
|
+
const FormFieldMaskedInput = /*#__PURE__*/React__default.default.memo(function FormFieldMaskedInput(props) {
|
|
1543
1732
|
const {
|
|
1544
1733
|
name,
|
|
1545
|
-
|
|
1734
|
+
initialValue,
|
|
1546
1735
|
classNameGroupItem,
|
|
1547
|
-
|
|
1736
|
+
clearIcon,
|
|
1737
|
+
clearIconFill,
|
|
1738
|
+
clearIconFillHover,
|
|
1739
|
+
clearIconShape,
|
|
1740
|
+
clearIconSize,
|
|
1548
1741
|
fieldProps = {},
|
|
1549
1742
|
inputProps = {},
|
|
1743
|
+
optionsMask,
|
|
1550
1744
|
showMessage,
|
|
1745
|
+
unmasked,
|
|
1746
|
+
isDisabled,
|
|
1551
1747
|
isRequired,
|
|
1552
|
-
|
|
1748
|
+
onClickClearIcon
|
|
1553
1749
|
} = props;
|
|
1554
1750
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1555
|
-
name: name
|
|
1751
|
+
name: name,
|
|
1752
|
+
initialValue: initialValue
|
|
1556
1753
|
}, function Render({
|
|
1557
1754
|
input,
|
|
1558
1755
|
meta
|
|
@@ -1564,27 +1761,35 @@ function FormFieldDatePicker(props) {
|
|
|
1564
1761
|
* custom React Hook function.
|
|
1565
1762
|
*/
|
|
1566
1763
|
|
|
1567
|
-
const
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
});
|
|
1764
|
+
const {
|
|
1765
|
+
ref,
|
|
1766
|
+
unmaskedValue,
|
|
1767
|
+
value,
|
|
1768
|
+
setUnmaskedValue
|
|
1769
|
+
} = reactImask.useIMask(optionsMask, {
|
|
1770
|
+
onAccept: (newValue, event, element) => {
|
|
1771
|
+
if (element) {
|
|
1772
|
+
input.onChange(event._unmaskedValue);
|
|
1773
|
+
}
|
|
1578
1774
|
}
|
|
1579
|
-
|
|
1580
|
-
|
|
1775
|
+
});
|
|
1776
|
+
React.useEffect(() => {
|
|
1777
|
+
if (input.value !== unmaskedValue) {
|
|
1778
|
+
setUnmaskedValue(input.value.replace(unmasked, ''));
|
|
1581
1779
|
}
|
|
1582
|
-
}, [input.
|
|
1780
|
+
}, [input.value]);
|
|
1781
|
+
|
|
1782
|
+
// useEffect(() => {
|
|
1783
|
+
// if (unmaskedValue !== input.value) {
|
|
1784
|
+
// input.onChange(unmaskedValue)
|
|
1785
|
+
// }
|
|
1786
|
+
// }, [unmaskedValue])
|
|
1787
|
+
|
|
1583
1788
|
const {
|
|
1584
1789
|
errorKey,
|
|
1585
1790
|
errorMessage,
|
|
1586
|
-
isErrorState,
|
|
1587
1791
|
successKey,
|
|
1792
|
+
isErrorState,
|
|
1588
1793
|
isValidState
|
|
1589
1794
|
} = useFieldValidationState({
|
|
1590
1795
|
fieldProps: fieldProps,
|
|
@@ -1596,36 +1801,40 @@ function FormFieldDatePicker(props) {
|
|
|
1596
1801
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1597
1802
|
});
|
|
1598
1803
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1599
|
-
className: clsx__default.default('form-
|
|
1804
|
+
className: clsx__default.default('form-field-masked-input', 'form__item_masked-input', classNameGroupItem),
|
|
1600
1805
|
errorKey: errorKey,
|
|
1601
1806
|
errorMessage: errorMessage,
|
|
1602
|
-
|
|
1603
|
-
metaError: meta.error,
|
|
1604
|
-
isDisabled: isDisabled,
|
|
1605
|
-
fieldClassName: "form-datepicker",
|
|
1807
|
+
fieldClassName: 'form-maskedInput',
|
|
1606
1808
|
inputName: input.name,
|
|
1607
|
-
inputValue: input.value
|
|
1809
|
+
inputValue: input.value,
|
|
1608
1810
|
metaActive: meta.active,
|
|
1811
|
+
metaError: meta.error,
|
|
1609
1812
|
showMessage: showMessage,
|
|
1813
|
+
isDisabled: isDisabled,
|
|
1814
|
+
isErrorState: isErrorState,
|
|
1610
1815
|
isRequired: isRequired,
|
|
1611
1816
|
isValidState: isValidState
|
|
1612
|
-
}, fieldProps), /*#__PURE__*/React__default.default.createElement(
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
endValue: datePickerProps.selectsRange ? input.value.endDate : null,
|
|
1617
|
-
inputProps: updatedInputProps,
|
|
1618
|
-
value: datePickerProps.selectsRange ? input.value.startDate : input.value,
|
|
1817
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Input.Input, Object.assign({
|
|
1818
|
+
className: clsx__default.default(meta.active && 'input_state_focus', meta.error && meta.touched && `input_state_${errorKey}`),
|
|
1819
|
+
ref: ref,
|
|
1820
|
+
value: value,
|
|
1619
1821
|
onBlur: input.onBlur,
|
|
1620
|
-
onChange: onChangeField,
|
|
1621
1822
|
onFocus: input.onFocus
|
|
1823
|
+
}, updatedInputProps)), clearIcon && /*#__PURE__*/React__default.default.createElement(Icon.Icon, {
|
|
1824
|
+
className: "form-field__icon",
|
|
1825
|
+
size: clearIconSize,
|
|
1826
|
+
iconFill: clearIconFill,
|
|
1827
|
+
iconFillHover: clearIconFillHover,
|
|
1828
|
+
imageSrc: clearIcon,
|
|
1829
|
+
shape: clearIconShape,
|
|
1830
|
+
SvgImage: clearIcon,
|
|
1831
|
+
onClick: onClickClearIcon
|
|
1622
1832
|
}));
|
|
1623
1833
|
});
|
|
1624
|
-
}
|
|
1834
|
+
});
|
|
1625
1835
|
|
|
1626
|
-
const
|
|
1836
|
+
const defaultPasswordProps = {
|
|
1627
1837
|
appearance: 'defaultPrimary sizeM solid rounded',
|
|
1628
|
-
width: 'fill',
|
|
1629
1838
|
// useValidationAppearanceInputProps
|
|
1630
1839
|
// Error
|
|
1631
1840
|
errorAppearance: 'errorPrimary sizeM solid rounded',
|
|
@@ -1635,27 +1844,18 @@ const defaultInputProps = {
|
|
|
1635
1844
|
successAppearance: 'successPrimary sizeM solid rounded'
|
|
1636
1845
|
};
|
|
1637
1846
|
|
|
1638
|
-
const
|
|
1847
|
+
const FormFieldPassword = /*#__PURE__*/React__default.default.memo(function FormFieldPassword(props) {
|
|
1639
1848
|
const {
|
|
1640
1849
|
name,
|
|
1641
1850
|
initialValue,
|
|
1642
|
-
isDisabled,
|
|
1643
1851
|
classNameGroupItem,
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
// iconBorderHover,
|
|
1647
|
-
clearIcon,
|
|
1648
|
-
clearIconFill,
|
|
1649
|
-
clearIconFillHover,
|
|
1650
|
-
clearIconShape,
|
|
1651
|
-
clearIconSize,
|
|
1652
|
-
fieldProps = {},
|
|
1653
|
-
inputProps = {},
|
|
1852
|
+
fieldProps,
|
|
1853
|
+
inputProps,
|
|
1654
1854
|
parse,
|
|
1655
1855
|
showMessage,
|
|
1856
|
+
isDisabled,
|
|
1656
1857
|
isRequired,
|
|
1657
|
-
onChange
|
|
1658
|
-
onClickClearIcon
|
|
1858
|
+
onChange
|
|
1659
1859
|
} = props;
|
|
1660
1860
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1661
1861
|
name: name,
|
|
@@ -1681,8 +1881,8 @@ const FormFieldInput = /*#__PURE__*/React__default.default.memo(function FormFie
|
|
|
1681
1881
|
const {
|
|
1682
1882
|
errorKey,
|
|
1683
1883
|
errorMessage,
|
|
1684
|
-
isErrorState,
|
|
1685
1884
|
successKey,
|
|
1885
|
+
isErrorState,
|
|
1686
1886
|
isValidState
|
|
1687
1887
|
} = useFieldValidationState({
|
|
1688
1888
|
fieldProps: fieldProps,
|
|
@@ -1694,79 +1894,90 @@ const FormFieldInput = /*#__PURE__*/React__default.default.memo(function FormFie
|
|
|
1694
1894
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1695
1895
|
});
|
|
1696
1896
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1697
|
-
className: clsx__default.default('form-field_input', 'form__item_input', classNameGroupItem),
|
|
1897
|
+
className: clsx__default.default('form-field_input-password', 'form__item_input-password', classNameGroupItem),
|
|
1698
1898
|
errorKey: errorKey,
|
|
1699
1899
|
errorMessage: errorMessage,
|
|
1700
|
-
|
|
1701
|
-
metaError: meta.error,
|
|
1702
|
-
isDisabled: isDisabled,
|
|
1703
|
-
fieldClassName: "form-input",
|
|
1900
|
+
fieldClassName: "form-password",
|
|
1704
1901
|
inputName: input.name,
|
|
1705
1902
|
inputValue: input.value || '',
|
|
1706
1903
|
metaActive: meta.active,
|
|
1904
|
+
metaError: meta.error,
|
|
1707
1905
|
showMessage: showMessage,
|
|
1906
|
+
isDisabled: isDisabled,
|
|
1907
|
+
isErrorState: isErrorState,
|
|
1708
1908
|
isRequired: isRequired,
|
|
1709
1909
|
isValidState: isValidState
|
|
1710
|
-
}, fieldProps), /*#__PURE__*/React__default.default.createElement(
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
type: "text",
|
|
1910
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(InputPassword.InputPassword, Object.assign({
|
|
1911
|
+
className: clsx__default.default(meta.active && 'input-password_state_focus', meta.error && meta.touched && `input-password_state_${errorKey}`),
|
|
1912
|
+
dataTestId: `${input.name}FieldInputPassword`,
|
|
1714
1913
|
name: input.name,
|
|
1715
|
-
isDisabled: isDisabled,
|
|
1716
1914
|
autoComplete: "nope",
|
|
1717
|
-
value: input.value || '',
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
size: clearIconSize,
|
|
1724
|
-
iconFill: clearIconFill,
|
|
1725
|
-
iconFillHover: clearIconFillHover,
|
|
1726
|
-
imageSrc: typeof clearIcon === 'string' && clearIcon,
|
|
1727
|
-
shape: clearIconShape,
|
|
1728
|
-
SvgImage: typeof clearIcon !== 'string' && clearIcon,
|
|
1729
|
-
onClick: onClickClearIcon
|
|
1730
|
-
}));
|
|
1915
|
+
value: input.value || '',
|
|
1916
|
+
isDisabled: isDisabled,
|
|
1917
|
+
onBlur: input.onBlur,
|
|
1918
|
+
onChange: onChangeField,
|
|
1919
|
+
onFocus: input.onFocus
|
|
1920
|
+
}, updatedInputProps)));
|
|
1731
1921
|
});
|
|
1732
1922
|
});
|
|
1733
1923
|
|
|
1734
|
-
const
|
|
1735
|
-
appearance: 'sizeM
|
|
1736
|
-
// useValidationAppearanceInputProps
|
|
1737
|
-
// Error
|
|
1738
|
-
errorAppearance: 'errorPrimary sizeM solid rounded',
|
|
1739
|
-
// Required
|
|
1740
|
-
iconRevealableHide: _default.icons24.View.HideValue,
|
|
1741
|
-
iconRevealableShow: _default.icons24.View.ShowValue,
|
|
1742
|
-
requiredAppearance: 'requirePrimary sizeM solid rounded'
|
|
1924
|
+
const defaultRadioProps = {
|
|
1925
|
+
appearance: 'defaultPrimary sizeM solid circular'
|
|
1743
1926
|
};
|
|
1744
1927
|
|
|
1745
|
-
|
|
1928
|
+
function FormFieldRadioGroupList(props) {
|
|
1929
|
+
const {
|
|
1930
|
+
input,
|
|
1931
|
+
inputProps,
|
|
1932
|
+
options,
|
|
1933
|
+
onChange
|
|
1934
|
+
} = props;
|
|
1935
|
+
|
|
1936
|
+
// Callback for value changes
|
|
1937
|
+
const onChangeSomeInput = React.useCallback(value => {
|
|
1938
|
+
// Save to form values
|
|
1939
|
+
input.onChange(value);
|
|
1940
|
+
if (onChange) {
|
|
1941
|
+
// Pass to custom event
|
|
1942
|
+
onChange(value, input.name);
|
|
1943
|
+
}
|
|
1944
|
+
}, [input, onChange]);
|
|
1945
|
+
|
|
1946
|
+
// Handle for radio inputs
|
|
1947
|
+
const onChangeRadio = React.useCallback(event => {
|
|
1948
|
+
if (event.target.checked) {
|
|
1949
|
+
onChangeSomeInput(event.target.value);
|
|
1950
|
+
}
|
|
1951
|
+
}, [onChange]);
|
|
1952
|
+
return /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, options.map(option => /*#__PURE__*/React__default.default.createElement(Radio.Radio, Object.assign({
|
|
1953
|
+
className: "form-radio__item",
|
|
1954
|
+
key: option.value,
|
|
1955
|
+
type: "radio",
|
|
1956
|
+
name: input.name,
|
|
1957
|
+
label: option.label,
|
|
1958
|
+
checked: option.value === input.value,
|
|
1959
|
+
value: option.value,
|
|
1960
|
+
onBlur: input.onBlur,
|
|
1961
|
+
onChange: onChangeRadio,
|
|
1962
|
+
onFocus: input.onFocus
|
|
1963
|
+
}, inputProps))));
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
const FormFieldRadioGroup = /*#__PURE__*/React__default.default.memo(function FormFieldRadioGroup(props) {
|
|
1746
1967
|
const {
|
|
1747
1968
|
name,
|
|
1748
|
-
initialValue,
|
|
1749
1969
|
isDisabled,
|
|
1970
|
+
editableProps = {},
|
|
1971
|
+
fieldProps = {},
|
|
1972
|
+
inputProps = {},
|
|
1973
|
+
options = [],
|
|
1750
1974
|
classNameGroupItem,
|
|
1751
|
-
fieldProps,
|
|
1752
|
-
inputProps,
|
|
1753
|
-
parse,
|
|
1754
1975
|
showMessage,
|
|
1755
1976
|
isRequired,
|
|
1756
1977
|
onChange
|
|
1757
1978
|
} = props;
|
|
1758
|
-
const [isRevealed, setIsRevealed] = React.useState(false);
|
|
1759
|
-
const inputType = React.useMemo(() => {
|
|
1760
|
-
return isRevealed ? 'text' : 'password';
|
|
1761
|
-
}, [isRevealed]);
|
|
1762
|
-
const onClickIconReveal = React.useCallback(event => {
|
|
1763
|
-
event.preventDefault();
|
|
1764
|
-
setIsRevealed(prev => !prev);
|
|
1765
|
-
}, []);
|
|
1766
1979
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1767
|
-
name: name
|
|
1768
|
-
initialValue: initialValue,
|
|
1769
|
-
parse: parse
|
|
1980
|
+
name: name
|
|
1770
1981
|
}, function Render({
|
|
1771
1982
|
input,
|
|
1772
1983
|
meta
|
|
@@ -1778,17 +1989,10 @@ const FormFieldPassword = /*#__PURE__*/React__default.default.memo(function Form
|
|
|
1778
1989
|
* custom React Hook function.
|
|
1779
1990
|
*/
|
|
1780
1991
|
|
|
1781
|
-
const onChangeField = React.useCallback(event => {
|
|
1782
|
-
input.onChange(event);
|
|
1783
|
-
if (onChange) {
|
|
1784
|
-
onChange(event.target.value, input.name);
|
|
1785
|
-
}
|
|
1786
|
-
}, [onChange, input.onChange]);
|
|
1787
1992
|
const {
|
|
1788
1993
|
errorKey,
|
|
1789
1994
|
errorMessage,
|
|
1790
1995
|
isErrorState,
|
|
1791
|
-
successKey,
|
|
1792
1996
|
isValidState
|
|
1793
1997
|
} = useFieldValidationState({
|
|
1794
1998
|
fieldProps: fieldProps,
|
|
@@ -1797,39 +2001,29 @@ const FormFieldPassword = /*#__PURE__*/React__default.default.memo(function Form
|
|
|
1797
2001
|
});
|
|
1798
2002
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1799
2003
|
inputProps: inputProps,
|
|
1800
|
-
validationStateKey: isErrorState ? errorKey :
|
|
2004
|
+
validationStateKey: isErrorState ? errorKey : 'success'
|
|
1801
2005
|
});
|
|
1802
2006
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1803
|
-
className: clsx__default.default('form-
|
|
2007
|
+
className: clsx__default.default('form-field_radio', 'form__item_radio', classNameGroupItem),
|
|
1804
2008
|
errorKey: errorKey,
|
|
1805
2009
|
errorMessage: errorMessage,
|
|
1806
2010
|
isErrorState: isErrorState,
|
|
1807
2011
|
metaError: meta.error,
|
|
1808
2012
|
isDisabled: isDisabled,
|
|
1809
|
-
fieldClassName:
|
|
2013
|
+
fieldClassName: 'form-radio',
|
|
1810
2014
|
inputName: input.name,
|
|
1811
2015
|
inputValue: input.value || '',
|
|
1812
2016
|
metaActive: meta.active,
|
|
1813
2017
|
showMessage: showMessage,
|
|
1814
2018
|
isRequired: isRequired,
|
|
1815
2019
|
isValidState: isValidState
|
|
1816
|
-
}, fieldProps), /*#__PURE__*/React__default.default.createElement(
|
|
1817
|
-
dataTestId: `${input.name}FieldInputPassword`,
|
|
1818
|
-
className: clsx__default.default(meta.active && 'input_state_focus', meta.error && meta.touched && `input_state_${errorKey}`),
|
|
1819
|
-
type: inputType,
|
|
1820
|
-
name: input.name,
|
|
2020
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(FormFieldRadioGroupList, {
|
|
1821
2021
|
isDisabled: isDisabled,
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
}, updatedInputProps)), /*#__PURE__*/React__default.default.createElement(Icon.Icon, {
|
|
1828
|
-
className: "form-field__icon",
|
|
1829
|
-
size: inputProps?.iconSize,
|
|
1830
|
-
iconFill: inputProps?.iconFill,
|
|
1831
|
-
SvgImage: isRevealed ? inputProps?.iconRevealableHide : inputProps?.iconRevealableShow,
|
|
1832
|
-
onClick: onClickIconReveal
|
|
2022
|
+
editableProps: editableProps,
|
|
2023
|
+
input: input,
|
|
2024
|
+
inputProps: updatedInputProps,
|
|
2025
|
+
options: options,
|
|
2026
|
+
onChange: onChange
|
|
1833
2027
|
}));
|
|
1834
2028
|
});
|
|
1835
2029
|
});
|
|
@@ -2016,220 +2210,57 @@ const FormFieldSelect = /*#__PURE__*/React__default.default.memo(function FormFi
|
|
|
2016
2210
|
meta: meta
|
|
2017
2211
|
});
|
|
2018
2212
|
const updatedSelectProps = useValidationAppearanceInputProps({
|
|
2019
|
-
inputProps: selectProps,
|
|
2020
|
-
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2021
|
-
});
|
|
2022
|
-
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
2023
|
-
className: clsx__default.default('form-field_select', 'form__item_select', classNameGroupItem),
|
|
2024
|
-
errorKey: errorKey,
|
|
2025
|
-
errorMessage: errorMessage,
|
|
2026
|
-
isErrorState: isErrorState,
|
|
2027
|
-
metaError: meta.error,
|
|
2028
|
-
isDisabled: isDisabled,
|
|
2029
|
-
fieldClassName: 'form-select',
|
|
2030
|
-
inputName: input.name,
|
|
2031
|
-
inputValue: input.value,
|
|
2032
|
-
metaActive: meta.active,
|
|
2033
|
-
showMessage: showMessage,
|
|
2034
|
-
isRequired: isRequired,
|
|
2035
|
-
isValidState: isValidState
|
|
2036
|
-
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Select.Select, Object.assign({
|
|
2037
|
-
className: "form-select-item",
|
|
2038
|
-
ref: selectRef,
|
|
2039
|
-
isDisabled: isDisabled,
|
|
2040
|
-
instanceId: `id_${input.name}`,
|
|
2041
|
-
options: options,
|
|
2042
|
-
value: selectedOptions,
|
|
2043
|
-
onChange: onChangeValue,
|
|
2044
|
-
onInputChange: onInputChange
|
|
2045
|
-
}, updatedSelectProps)));
|
|
2046
|
-
});
|
|
2047
|
-
});
|
|
2048
|
-
|
|
2049
|
-
const defaultSwitchProps = {
|
|
2050
|
-
appearance: 'defaultPrimary sizeL solid rounded',
|
|
2051
|
-
// useValidationAppearanceInputProps
|
|
2052
|
-
// Error
|
|
2053
|
-
errorAppearance: 'errorPrimary sizeL solid rounded',
|
|
2054
|
-
// Success
|
|
2055
|
-
successAppearance: 'successPrimary sizeL solid rounded',
|
|
2056
|
-
// Required
|
|
2057
|
-
requiredAppearance: 'requirePrimary sizeL solid rounded'
|
|
2058
|
-
};
|
|
2059
|
-
|
|
2060
|
-
const FormFieldSwitch = /*#__PURE__*/React__default.default.memo(function FormFieldSwitch(props) {
|
|
2061
|
-
const {
|
|
2062
|
-
name,
|
|
2063
|
-
isDisabled,
|
|
2064
|
-
classNameGroupItem,
|
|
2065
|
-
fieldProps = {},
|
|
2066
|
-
inputProps = {},
|
|
2067
|
-
showMessage,
|
|
2068
|
-
isRequired,
|
|
2069
|
-
onChange
|
|
2070
|
-
} = props;
|
|
2071
|
-
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
2072
|
-
type: "checkbox",
|
|
2073
|
-
name: name
|
|
2074
|
-
}, function Render({
|
|
2075
|
-
input,
|
|
2076
|
-
meta
|
|
2077
|
-
}) {
|
|
2078
|
-
/** Note:
|
|
2079
|
-
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
2080
|
-
* React Hooks cannot be called inside a callback.
|
|
2081
|
-
* React Hooks must be called in a React function component or a
|
|
2082
|
-
* custom React Hook function.
|
|
2083
|
-
*/
|
|
2084
|
-
|
|
2085
|
-
const onChangeField = React.useCallback(event => {
|
|
2086
|
-
input.onChange(event);
|
|
2087
|
-
if (onChange) {
|
|
2088
|
-
onChange(event.target.checked, input.name);
|
|
2089
|
-
}
|
|
2090
|
-
}, [onChange, input.onChange]);
|
|
2091
|
-
const {
|
|
2092
|
-
errorKey,
|
|
2093
|
-
errorMessage,
|
|
2094
|
-
isErrorState,
|
|
2095
|
-
successKey,
|
|
2096
|
-
isValidState
|
|
2097
|
-
} = useFieldValidationState({
|
|
2098
|
-
fieldProps: fieldProps,
|
|
2099
|
-
input: input,
|
|
2100
|
-
meta: meta
|
|
2101
|
-
});
|
|
2102
|
-
const updatedInputProps = useValidationAppearanceInputProps({
|
|
2103
|
-
inputProps: inputProps,
|
|
2104
|
-
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2105
|
-
});
|
|
2106
|
-
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
2107
|
-
className: clsx__default.default('form-field-switch', 'form__item_switch', classNameGroupItem),
|
|
2108
|
-
errorKey: errorKey,
|
|
2109
|
-
errorMessage: errorMessage,
|
|
2110
|
-
isErrorState: isErrorState,
|
|
2111
|
-
metaError: meta.error,
|
|
2112
|
-
isDisabled: isDisabled,
|
|
2113
|
-
fieldClassName: "form-switch",
|
|
2114
|
-
inputName: input.name,
|
|
2115
|
-
inputValue: input.checked,
|
|
2116
|
-
metaActive: meta.active,
|
|
2117
|
-
showMessage: showMessage,
|
|
2118
|
-
tag: "label",
|
|
2119
|
-
isRequired: isRequired,
|
|
2120
|
-
isValidState: isValidState
|
|
2121
|
-
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Switch.Switch, Object.assign({
|
|
2122
|
-
type: "checkbox",
|
|
2123
|
-
name: input.name,
|
|
2124
|
-
isDisabled: isDisabled,
|
|
2125
|
-
autoComplete: "nope",
|
|
2126
|
-
isActive: input.checked,
|
|
2127
|
-
onBlur: input.onBlur,
|
|
2128
|
-
onChange: onChangeField,
|
|
2129
|
-
onFocus: input.onFocus
|
|
2130
|
-
}, updatedInputProps)));
|
|
2131
|
-
});
|
|
2132
|
-
});
|
|
2133
|
-
|
|
2134
|
-
const defaultTextareaProps = {
|
|
2135
|
-
appearance: 'defaultPrimary sizeM solid rounded',
|
|
2136
|
-
// useValidationAppearanceInputProps
|
|
2137
|
-
// Error
|
|
2138
|
-
errorAppearance: 'errorPrimary sizeM solid rounded',
|
|
2139
|
-
// Success
|
|
2140
|
-
successAppearance: 'successPrimary sizeM solid rounded',
|
|
2141
|
-
// Required
|
|
2142
|
-
requiredAppearance: 'requirePrimary sizeM solid rounded'
|
|
2143
|
-
};
|
|
2144
|
-
|
|
2145
|
-
const FormFieldTextarea = /*#__PURE__*/React__default.default.memo(function FormFieldTextarea(props) {
|
|
2146
|
-
const {
|
|
2147
|
-
name,
|
|
2148
|
-
isDisabled,
|
|
2149
|
-
classNameGroupItem,
|
|
2150
|
-
fieldProps = {},
|
|
2151
|
-
inputProps = {},
|
|
2152
|
-
showMessage,
|
|
2153
|
-
isRequired
|
|
2154
|
-
} = props;
|
|
2155
|
-
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
2156
|
-
name: name
|
|
2157
|
-
}, function Render({
|
|
2158
|
-
input,
|
|
2159
|
-
meta
|
|
2160
|
-
}) {
|
|
2161
|
-
/** Note:
|
|
2162
|
-
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
2163
|
-
* React Hooks cannot be called inside a callback.
|
|
2164
|
-
* React Hooks must be called in a React function component or a
|
|
2165
|
-
* custom React Hook function.
|
|
2166
|
-
*/
|
|
2167
|
-
|
|
2168
|
-
const {
|
|
2169
|
-
errorKey,
|
|
2170
|
-
errorMessage,
|
|
2171
|
-
isErrorState,
|
|
2172
|
-
successKey,
|
|
2173
|
-
isValidState
|
|
2174
|
-
} = useFieldValidationState({
|
|
2175
|
-
fieldProps: fieldProps,
|
|
2176
|
-
input: input,
|
|
2177
|
-
meta: meta
|
|
2178
|
-
});
|
|
2179
|
-
const updatedInputProps = useValidationAppearanceInputProps({
|
|
2180
|
-
inputProps: inputProps,
|
|
2213
|
+
inputProps: selectProps,
|
|
2181
2214
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2182
2215
|
});
|
|
2183
2216
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
2184
|
-
className: clsx__default.default('form-
|
|
2217
|
+
className: clsx__default.default('form-field_select', 'form__item_select', classNameGroupItem),
|
|
2185
2218
|
errorKey: errorKey,
|
|
2186
2219
|
errorMessage: errorMessage,
|
|
2187
2220
|
isErrorState: isErrorState,
|
|
2188
2221
|
metaError: meta.error,
|
|
2189
2222
|
isDisabled: isDisabled,
|
|
2190
|
-
fieldClassName: 'form-
|
|
2223
|
+
fieldClassName: 'form-select',
|
|
2191
2224
|
inputName: input.name,
|
|
2192
2225
|
inputValue: input.value,
|
|
2193
2226
|
metaActive: meta.active,
|
|
2194
2227
|
showMessage: showMessage,
|
|
2195
2228
|
isRequired: isRequired,
|
|
2196
2229
|
isValidState: isValidState
|
|
2197
|
-
}, fieldProps), /*#__PURE__*/React__default.default.createElement(
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
name: input.name,
|
|
2230
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Select.Select, Object.assign({
|
|
2231
|
+
className: "form-select-item",
|
|
2232
|
+
ref: selectRef,
|
|
2201
2233
|
isDisabled: isDisabled,
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
onChange:
|
|
2206
|
-
|
|
2207
|
-
},
|
|
2234
|
+
instanceId: `id_${input.name}`,
|
|
2235
|
+
options: options,
|
|
2236
|
+
value: selectedOptions,
|
|
2237
|
+
onChange: onChangeValue,
|
|
2238
|
+
onInputChange: onInputChange
|
|
2239
|
+
}, updatedSelectProps)));
|
|
2208
2240
|
});
|
|
2209
2241
|
});
|
|
2210
2242
|
|
|
2211
|
-
const
|
|
2243
|
+
const defaultSwitchProps = {
|
|
2244
|
+
appearance: 'defaultPrimary sizeL solid rounded',
|
|
2245
|
+
errorAppearance: 'errorPrimary sizeL solid rounded',
|
|
2246
|
+
successAppearance: 'successPrimary sizeL solid rounded',
|
|
2247
|
+
requiredAppearance: 'requirePrimary sizeL solid rounded'
|
|
2248
|
+
};
|
|
2249
|
+
|
|
2250
|
+
const FormFieldSwitch = /*#__PURE__*/React__default.default.memo(function FormFieldSwitch(props) {
|
|
2212
2251
|
const {
|
|
2213
2252
|
name,
|
|
2214
|
-
initialValue,
|
|
2215
2253
|
isDisabled,
|
|
2216
2254
|
classNameGroupItem,
|
|
2217
|
-
clearIcon,
|
|
2218
|
-
clearIconFill,
|
|
2219
|
-
clearIconFillHover,
|
|
2220
|
-
clearIconShape,
|
|
2221
|
-
clearIconSize,
|
|
2222
2255
|
fieldProps = {},
|
|
2223
2256
|
inputProps = {},
|
|
2224
|
-
optionsMask,
|
|
2225
2257
|
showMessage,
|
|
2226
|
-
unmasked,
|
|
2227
2258
|
isRequired,
|
|
2228
|
-
|
|
2259
|
+
onChange
|
|
2229
2260
|
} = props;
|
|
2230
2261
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
2231
|
-
|
|
2232
|
-
|
|
2262
|
+
type: "checkbox",
|
|
2263
|
+
name: name
|
|
2233
2264
|
}, function Render({
|
|
2234
2265
|
input,
|
|
2235
2266
|
meta
|
|
@@ -2241,28 +2272,12 @@ const FormFieldMaskedInput = /*#__PURE__*/React__default.default.memo(function F
|
|
|
2241
2272
|
* custom React Hook function.
|
|
2242
2273
|
*/
|
|
2243
2274
|
|
|
2244
|
-
const {
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
value
|
|
2249
|
-
} = reactImask.useIMask(optionsMask, {
|
|
2250
|
-
onAccept: (newValue, event, element) => {
|
|
2251
|
-
if (element) {
|
|
2252
|
-
input.onChange(event._unmaskedValue);
|
|
2253
|
-
}
|
|
2254
|
-
}
|
|
2255
|
-
});
|
|
2256
|
-
React.useEffect(() => {
|
|
2257
|
-
if (input.value !== unmaskedValue) {
|
|
2258
|
-
setUnmaskedValue(input.value.replace(unmasked, ''));
|
|
2259
|
-
}
|
|
2260
|
-
}, [input.value]);
|
|
2261
|
-
React.useEffect(() => {
|
|
2262
|
-
if (unmaskedValue !== input.value) {
|
|
2263
|
-
input.onChange(unmaskedValue);
|
|
2275
|
+
const onChangeField = React.useCallback(event => {
|
|
2276
|
+
input.onChange(event);
|
|
2277
|
+
if (onChange) {
|
|
2278
|
+
onChange(event.target.checked, input.name);
|
|
2264
2279
|
}
|
|
2265
|
-
}, [
|
|
2280
|
+
}, [onChange, input.onChange]);
|
|
2266
2281
|
const {
|
|
2267
2282
|
errorKey,
|
|
2268
2283
|
errorMessage,
|
|
@@ -2279,92 +2294,53 @@ const FormFieldMaskedInput = /*#__PURE__*/React__default.default.memo(function F
|
|
|
2279
2294
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2280
2295
|
});
|
|
2281
2296
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
2282
|
-
className: clsx__default.default('form-field-
|
|
2297
|
+
className: clsx__default.default('form-field-switch', 'form__item_switch', classNameGroupItem),
|
|
2283
2298
|
errorKey: errorKey,
|
|
2284
2299
|
errorMessage: errorMessage,
|
|
2285
2300
|
isErrorState: isErrorState,
|
|
2286
2301
|
metaError: meta.error,
|
|
2287
2302
|
isDisabled: isDisabled,
|
|
2288
|
-
fieldClassName:
|
|
2303
|
+
fieldClassName: "form-switch",
|
|
2289
2304
|
inputName: input.name,
|
|
2290
|
-
inputValue: input.
|
|
2305
|
+
inputValue: input.checked,
|
|
2291
2306
|
metaActive: meta.active,
|
|
2292
2307
|
showMessage: showMessage,
|
|
2308
|
+
tag: "label",
|
|
2293
2309
|
isRequired: isRequired,
|
|
2294
2310
|
isValidState: isValidState
|
|
2295
|
-
}, fieldProps), /*#__PURE__*/React__default.default.createElement(
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2311
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Switch.Switch, Object.assign({
|
|
2312
|
+
type: "checkbox",
|
|
2313
|
+
name: input.name,
|
|
2314
|
+
isDisabled: isDisabled,
|
|
2315
|
+
autoComplete: "nope",
|
|
2316
|
+
isActive: input.checked,
|
|
2299
2317
|
onBlur: input.onBlur,
|
|
2318
|
+
onChange: onChangeField,
|
|
2300
2319
|
onFocus: input.onFocus
|
|
2301
|
-
}, updatedInputProps))
|
|
2302
|
-
className: "form-field__icon",
|
|
2303
|
-
size: clearIconSize,
|
|
2304
|
-
iconFill: clearIconFill,
|
|
2305
|
-
iconFillHover: clearIconFillHover,
|
|
2306
|
-
imageSrc: clearIcon,
|
|
2307
|
-
shape: clearIconShape,
|
|
2308
|
-
SvgImage: clearIcon,
|
|
2309
|
-
onClick: onClickClearIcon
|
|
2310
|
-
}));
|
|
2320
|
+
}, updatedInputProps)));
|
|
2311
2321
|
});
|
|
2312
2322
|
});
|
|
2313
2323
|
|
|
2314
|
-
const
|
|
2315
|
-
appearance: 'defaultPrimary sizeM solid
|
|
2324
|
+
const defaultTextareaProps = {
|
|
2325
|
+
appearance: 'defaultPrimary sizeM solid rounded',
|
|
2326
|
+
// useValidationAppearanceInputProps
|
|
2327
|
+
// Error
|
|
2328
|
+
errorAppearance: 'errorPrimary sizeM solid rounded',
|
|
2329
|
+
// Success
|
|
2330
|
+
successAppearance: 'successPrimary sizeM solid rounded',
|
|
2331
|
+
// Required
|
|
2332
|
+
requiredAppearance: 'requirePrimary sizeM solid rounded'
|
|
2316
2333
|
};
|
|
2317
2334
|
|
|
2318
|
-
function
|
|
2319
|
-
const {
|
|
2320
|
-
input,
|
|
2321
|
-
inputProps,
|
|
2322
|
-
options,
|
|
2323
|
-
onChange
|
|
2324
|
-
} = props;
|
|
2325
|
-
|
|
2326
|
-
// Callback for value changes
|
|
2327
|
-
const onChangeSomeInput = React.useCallback(value => {
|
|
2328
|
-
// Save to form values
|
|
2329
|
-
input.onChange(value);
|
|
2330
|
-
if (onChange) {
|
|
2331
|
-
// Pass to custom event
|
|
2332
|
-
onChange(value, input.name);
|
|
2333
|
-
}
|
|
2334
|
-
}, [input, onChange]);
|
|
2335
|
-
|
|
2336
|
-
// Handle for radio inputs
|
|
2337
|
-
const onChangeRadio = React.useCallback(event => {
|
|
2338
|
-
if (event.target.checked) {
|
|
2339
|
-
onChangeSomeInput(event.target.value);
|
|
2340
|
-
}
|
|
2341
|
-
}, [onChange]);
|
|
2342
|
-
return /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, options.map(option => /*#__PURE__*/React__default.default.createElement(Radio.Radio, Object.assign({
|
|
2343
|
-
className: "form-radio__item",
|
|
2344
|
-
key: option.value,
|
|
2345
|
-
type: "radio",
|
|
2346
|
-
name: input.name,
|
|
2347
|
-
label: option.label,
|
|
2348
|
-
checked: option.value === input.value,
|
|
2349
|
-
value: option.value,
|
|
2350
|
-
onBlur: input.onBlur,
|
|
2351
|
-
onChange: onChangeRadio,
|
|
2352
|
-
onFocus: input.onFocus
|
|
2353
|
-
}, inputProps))));
|
|
2354
|
-
}
|
|
2355
|
-
|
|
2356
|
-
const RadioGroup = /*#__PURE__*/React__default.default.memo(function RadioGroup(props) {
|
|
2335
|
+
const FormFieldTextarea = /*#__PURE__*/React__default.default.memo(function FormFieldTextarea(props) {
|
|
2357
2336
|
const {
|
|
2358
2337
|
name,
|
|
2359
2338
|
isDisabled,
|
|
2360
|
-
|
|
2339
|
+
classNameGroupItem,
|
|
2361
2340
|
fieldProps = {},
|
|
2362
2341
|
inputProps = {},
|
|
2363
|
-
options = [],
|
|
2364
|
-
classNameGroupItem,
|
|
2365
2342
|
showMessage,
|
|
2366
|
-
isRequired
|
|
2367
|
-
onChange
|
|
2343
|
+
isRequired
|
|
2368
2344
|
} = props;
|
|
2369
2345
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
2370
2346
|
name: name
|
|
@@ -2383,6 +2359,7 @@ const RadioGroup = /*#__PURE__*/React__default.default.memo(function RadioGroup(
|
|
|
2383
2359
|
errorKey,
|
|
2384
2360
|
errorMessage,
|
|
2385
2361
|
isErrorState,
|
|
2362
|
+
successKey,
|
|
2386
2363
|
isValidState
|
|
2387
2364
|
} = useFieldValidationState({
|
|
2388
2365
|
fieldProps: fieldProps,
|
|
@@ -2391,30 +2368,33 @@ const RadioGroup = /*#__PURE__*/React__default.default.memo(function RadioGroup(
|
|
|
2391
2368
|
});
|
|
2392
2369
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
2393
2370
|
inputProps: inputProps,
|
|
2394
|
-
validationStateKey: isErrorState ? errorKey :
|
|
2371
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2395
2372
|
});
|
|
2396
2373
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
2397
|
-
className: clsx__default.default('form-
|
|
2374
|
+
className: clsx__default.default('form-field_textarea', 'form__item_textarea', classNameGroupItem),
|
|
2398
2375
|
errorKey: errorKey,
|
|
2399
2376
|
errorMessage: errorMessage,
|
|
2400
2377
|
isErrorState: isErrorState,
|
|
2401
2378
|
metaError: meta.error,
|
|
2402
2379
|
isDisabled: isDisabled,
|
|
2403
|
-
fieldClassName: 'form-
|
|
2380
|
+
fieldClassName: 'form-textarea',
|
|
2404
2381
|
inputName: input.name,
|
|
2405
|
-
inputValue: input.value
|
|
2382
|
+
inputValue: input.value,
|
|
2406
2383
|
metaActive: meta.active,
|
|
2407
2384
|
showMessage: showMessage,
|
|
2408
2385
|
isRequired: isRequired,
|
|
2409
2386
|
isValidState: isValidState
|
|
2410
|
-
}, fieldProps), /*#__PURE__*/React__default.default.createElement(
|
|
2387
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Textarea.Textarea, Object.assign({
|
|
2388
|
+
dataTestId: `${input.name}FieldTextarea`,
|
|
2389
|
+
className: clsx__default.default(meta.active && 'textarea_state_focus', meta.error && meta.touched && `textarea_state_${errorKey}`),
|
|
2390
|
+
name: input.name,
|
|
2411
2391
|
isDisabled: isDisabled,
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
}));
|
|
2392
|
+
autoComplete: "nope",
|
|
2393
|
+
value: input.value || '',
|
|
2394
|
+
onBlur: input.onBlur,
|
|
2395
|
+
onChange: input.onChange,
|
|
2396
|
+
onFocus: input.onFocus
|
|
2397
|
+
}, updatedInputProps)));
|
|
2418
2398
|
});
|
|
2419
2399
|
});
|
|
2420
2400
|
|
|
@@ -2489,13 +2469,13 @@ function generateField(field, config, props) {
|
|
|
2489
2469
|
}
|
|
2490
2470
|
case formTypes.fileInput:
|
|
2491
2471
|
{
|
|
2492
|
-
return /*#__PURE__*/React__default.default.createElement(
|
|
2472
|
+
return /*#__PURE__*/React__default.default.createElement(FormFieldFileInput, Object.assign({
|
|
2493
2473
|
key: config.key
|
|
2494
2474
|
}, field, props));
|
|
2495
2475
|
}
|
|
2496
2476
|
case formTypes.radioGroup:
|
|
2497
2477
|
{
|
|
2498
|
-
return /*#__PURE__*/React__default.default.createElement(
|
|
2478
|
+
return /*#__PURE__*/React__default.default.createElement(FormFieldRadioGroup, Object.assign({
|
|
2499
2479
|
key: config.key
|
|
2500
2480
|
}, field, props));
|
|
2501
2481
|
}
|
|
@@ -2662,9 +2642,9 @@ const sendFormDataToServer = async (url, data) => {
|
|
|
2662
2642
|
|
|
2663
2643
|
const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalForm(props, ref) {
|
|
2664
2644
|
const {
|
|
2645
|
+
className,
|
|
2665
2646
|
dataTestId,
|
|
2666
2647
|
dataTour,
|
|
2667
|
-
className,
|
|
2668
2648
|
type,
|
|
2669
2649
|
initialValues,
|
|
2670
2650
|
initialValuesEqual,
|
|
@@ -2680,8 +2660,36 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2680
2660
|
descTextColor,
|
|
2681
2661
|
descTextWeight,
|
|
2682
2662
|
buttonGap,
|
|
2663
|
+
additionalProps = {},
|
|
2664
|
+
buttonDirection = 'vertical',
|
|
2665
|
+
buttonFill,
|
|
2666
|
+
buttonJustifyContent,
|
|
2667
|
+
buttonPadding,
|
|
2668
|
+
buttonPosition,
|
|
2669
|
+
dataTestIdButtons,
|
|
2683
2670
|
dataTestIdPrimaryButton,
|
|
2671
|
+
dataTestIdSecondaryButton,
|
|
2672
|
+
dataTestIdTertiaryButton,
|
|
2673
|
+
dataTourButtons,
|
|
2684
2674
|
dataTourPrimaryButton,
|
|
2675
|
+
dataTourSecondaryButton,
|
|
2676
|
+
dataTourTertiaryButton,
|
|
2677
|
+
disableFieldsAutoComplete = false,
|
|
2678
|
+
fieldsGap,
|
|
2679
|
+
formName,
|
|
2680
|
+
groupGap,
|
|
2681
|
+
language,
|
|
2682
|
+
loader,
|
|
2683
|
+
loaderAppearance,
|
|
2684
|
+
loaderFill = 'surfacePrimary',
|
|
2685
|
+
loaderItemFill = 'accentItemSecondary',
|
|
2686
|
+
loaderShape,
|
|
2687
|
+
loaderSize = 'l',
|
|
2688
|
+
loaderText,
|
|
2689
|
+
loaderType = 'simple',
|
|
2690
|
+
mutators,
|
|
2691
|
+
notificationCloseButton,
|
|
2692
|
+
notificationType,
|
|
2685
2693
|
primaryButton,
|
|
2686
2694
|
primaryButtonAppearance,
|
|
2687
2695
|
primaryButtonFill,
|
|
@@ -2693,9 +2701,7 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2693
2701
|
primaryButtonLabelTextColor,
|
|
2694
2702
|
primaryButtonLabelTextWeight,
|
|
2695
2703
|
primaryButtonSize,
|
|
2696
|
-
|
|
2697
|
-
dataTourSecondaryButton,
|
|
2698
|
-
onClickSecondaryButton,
|
|
2704
|
+
renderFieldsWrapper = wrapperChildren => wrapperChildren,
|
|
2699
2705
|
secondaryButton,
|
|
2700
2706
|
secondaryButtonAppearance,
|
|
2701
2707
|
secondaryButtonFill,
|
|
@@ -2707,9 +2713,7 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2707
2713
|
secondaryButtonLabelTextColor,
|
|
2708
2714
|
secondaryButtonLabelTextWeight,
|
|
2709
2715
|
secondaryButtonSize,
|
|
2710
|
-
|
|
2711
|
-
dataTourTertiaryButton,
|
|
2712
|
-
onClickTertiaryButton,
|
|
2716
|
+
shapeStrengthClass,
|
|
2713
2717
|
tertiaryButton,
|
|
2714
2718
|
tertiaryButtonFill,
|
|
2715
2719
|
tertiaryButtonFillHover,
|
|
@@ -2718,35 +2722,11 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2718
2722
|
tertiaryButtonLabelTextColor,
|
|
2719
2723
|
tertiaryButtonLabelTextWeight,
|
|
2720
2724
|
tertiaryButtonSize,
|
|
2721
|
-
additionalProps = {},
|
|
2722
|
-
buttonDirection = 'vertical',
|
|
2723
|
-
buttonFill,
|
|
2724
|
-
buttonJustifyContent,
|
|
2725
|
-
buttonPadding,
|
|
2726
|
-
buttonPosition,
|
|
2727
|
-
dataTestIdButtons,
|
|
2728
|
-
dataTourButtons,
|
|
2729
|
-
disableFieldsAutoComplete = false,
|
|
2730
|
-
fieldsGap,
|
|
2731
|
-
formName,
|
|
2732
|
-
groupGap,
|
|
2733
|
-
language,
|
|
2734
|
-
loader,
|
|
2735
|
-
loaderAppearance = 'surfacePrimary sizeM',
|
|
2736
|
-
loaderFill,
|
|
2737
|
-
loaderItemFill,
|
|
2738
|
-
loaderShape,
|
|
2739
|
-
loaderSize,
|
|
2740
|
-
loaderText,
|
|
2741
|
-
loaderType = 'simple',
|
|
2742
|
-
mutators,
|
|
2743
|
-
notificationCloseButton,
|
|
2744
|
-
notificationType,
|
|
2745
|
-
renderFieldsWrapper = wrapperChildren => wrapperChildren,
|
|
2746
|
-
shapeStrengthClass,
|
|
2747
2725
|
before,
|
|
2748
2726
|
after,
|
|
2749
2727
|
isLoading,
|
|
2728
|
+
onClickSecondaryButton,
|
|
2729
|
+
onClickTertiaryButton,
|
|
2750
2730
|
onChangeFormValues,
|
|
2751
2731
|
onSubmit
|
|
2752
2732
|
} = props;
|
|
@@ -2771,10 +2751,10 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2771
2751
|
initialValues: initialValues,
|
|
2772
2752
|
initialValuesEqual: initialValuesEqual,
|
|
2773
2753
|
render: ({
|
|
2774
|
-
submitError,
|
|
2775
2754
|
form,
|
|
2776
2755
|
handleSubmit,
|
|
2777
|
-
modifiedSinceLastSubmit
|
|
2756
|
+
modifiedSinceLastSubmit,
|
|
2757
|
+
submitError
|
|
2778
2758
|
}) => {
|
|
2779
2759
|
return /*#__PURE__*/React__default.default.createElement("form", {
|
|
2780
2760
|
className: clsx__default.default(className, 'form', type && `form_type_${type}`, buttonPosition && `form_button-position_${buttonPosition}`, directionClass && `direction_${directionClass}`, fillClass && `fill_${fillClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`, elevationClass && `elevation_${elevationClass}`),
|
|
@@ -2804,8 +2784,8 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2804
2784
|
}, desc), submitError && !modifiedSinceLastSubmit && /*#__PURE__*/React__default.default.createElement("div", {
|
|
2805
2785
|
className: clsx__default.default('notification', 'form-notification', notificationType ? `form-notification_${notificationType}` : 'form-notification_global')
|
|
2806
2786
|
}, /*#__PURE__*/React__default.default.createElement(Notification.Notification, {
|
|
2807
|
-
className: "form-notification__item",
|
|
2808
2787
|
appearance: "errorPrimary",
|
|
2788
|
+
className: "form-notification__item",
|
|
2809
2789
|
title: form.getState().submitError,
|
|
2810
2790
|
titleTextSize: "h6",
|
|
2811
2791
|
status: "error",
|
|
@@ -2823,28 +2803,28 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2823
2803
|
}, Object.keys(config).map(key => generateField(config[key], {
|
|
2824
2804
|
key
|
|
2825
2805
|
}, additionalProps[config[key].name])), isLoading && (loader || /*#__PURE__*/React__default.default.createElement(Loader.Loader, {
|
|
2806
|
+
appearance: loaderAppearance,
|
|
2826
2807
|
className: "form__loader",
|
|
2827
2808
|
type: loaderType,
|
|
2828
|
-
appearance: loaderAppearance,
|
|
2829
2809
|
size: loaderSize,
|
|
2830
2810
|
fill: loaderFill,
|
|
2831
2811
|
text: loaderText,
|
|
2832
2812
|
itemFill: loaderItemFill,
|
|
2833
2813
|
shape: loaderShape
|
|
2834
2814
|
}))))), (primaryButtonLabel || primaryButton || secondaryButtonLabel || secondaryButton || tertiaryButton || tertiaryButtonLabel) && /*#__PURE__*/React__default.default.createElement(Group.Group, {
|
|
2815
|
+
className: "form__button",
|
|
2835
2816
|
dataTestId: dataTestIdButtons,
|
|
2836
2817
|
dataTour: dataTourButtons,
|
|
2837
|
-
className: "form__button",
|
|
2838
2818
|
direction: buttonDirection,
|
|
2839
2819
|
justifyContent: buttonJustifyContent,
|
|
2840
2820
|
fill: buttonFill,
|
|
2841
2821
|
padding: buttonPadding,
|
|
2842
2822
|
gap: buttonGap
|
|
2843
2823
|
}, primaryButtonLabel ? /*#__PURE__*/React__default.default.createElement(Button.Button, {
|
|
2824
|
+
appearance: primaryButtonAppearance,
|
|
2825
|
+
className: "form__button-item",
|
|
2844
2826
|
dataTestId: dataTestIdPrimaryButton,
|
|
2845
2827
|
dataTour: dataTourPrimaryButton,
|
|
2846
|
-
className: "form__button-item",
|
|
2847
|
-
appearance: primaryButtonAppearance,
|
|
2848
2828
|
width: "fill",
|
|
2849
2829
|
size: primaryButtonSize,
|
|
2850
2830
|
fill: primaryButtonFill,
|
|
@@ -2853,13 +2833,13 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2853
2833
|
labelTextColor: primaryButtonLabelTextColor,
|
|
2854
2834
|
labelTextSize: primaryButtonLabelSize,
|
|
2855
2835
|
labelTextWeight: primaryButtonLabelTextWeight,
|
|
2856
|
-
|
|
2857
|
-
|
|
2836
|
+
loading: primaryButtonIsLoading,
|
|
2837
|
+
isDisabled: primaryButtonIsDisabled
|
|
2858
2838
|
}) : primaryButton, secondaryButtonLabel ? /*#__PURE__*/React__default.default.createElement(Button.Button, {
|
|
2839
|
+
appearance: secondaryButtonAppearance,
|
|
2840
|
+
className: "form__button-item",
|
|
2859
2841
|
dataTestId: dataTestIdSecondaryButton,
|
|
2860
2842
|
dataTour: dataTourSecondaryButton,
|
|
2861
|
-
className: "form__button-item",
|
|
2862
|
-
appearance: secondaryButtonAppearance,
|
|
2863
2843
|
width: "fill",
|
|
2864
2844
|
size: secondaryButtonSize,
|
|
2865
2845
|
fill: secondaryButtonFill,
|
|
@@ -2868,13 +2848,13 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2868
2848
|
labelTextColor: secondaryButtonLabelTextColor,
|
|
2869
2849
|
labelTextSize: secondaryButtonLabelSize,
|
|
2870
2850
|
labelTextWeight: secondaryButtonLabelTextWeight,
|
|
2871
|
-
isDisabled: secondaryButtonIsDisabled,
|
|
2872
2851
|
loading: secondaryButtonIsLoading,
|
|
2852
|
+
isDisabled: secondaryButtonIsDisabled,
|
|
2873
2853
|
onClick: onClickSecondaryButton
|
|
2874
2854
|
}) : secondaryButton, tertiaryButtonLabel ? /*#__PURE__*/React__default.default.createElement(Button.Button, {
|
|
2855
|
+
className: "form__button-item",
|
|
2875
2856
|
dataTestId: dataTestIdTertiaryButton,
|
|
2876
2857
|
dataTour: dataTourTertiaryButton,
|
|
2877
|
-
className: "form__button-item",
|
|
2878
2858
|
width: "fill",
|
|
2879
2859
|
size: tertiaryButtonSize,
|
|
2880
2860
|
fill: tertiaryButtonFill,
|
|
@@ -2889,9 +2869,9 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2889
2869
|
decorators: [focusOnErrorDecorator],
|
|
2890
2870
|
mutators: mutators,
|
|
2891
2871
|
subscription: {
|
|
2892
|
-
submitError: true,
|
|
2893
2872
|
modifiedSinceLastSubmit: true,
|
|
2894
2873
|
pristine: true,
|
|
2874
|
+
submitError: true,
|
|
2895
2875
|
submitting: true
|
|
2896
2876
|
},
|
|
2897
2877
|
validate: validate,
|
|
@@ -3163,7 +3143,6 @@ Object.defineProperty(exports, "useFormState", {
|
|
|
3163
3143
|
exports.DEFAULT_MESSAGES_FIELDS = DEFAULT_MESSAGES_FIELDS;
|
|
3164
3144
|
exports.FieldWrapper = FieldWrapper;
|
|
3165
3145
|
exports.FieldWrapperBase = FieldWrapperBase;
|
|
3166
|
-
exports.FileInput = FileInput;
|
|
3167
3146
|
exports.FinalForm = FinalForm;
|
|
3168
3147
|
exports.FormBlockGroup = FormBlockGroup;
|
|
3169
3148
|
exports.FormFieldCheckbox = FormFieldCheckbox;
|
|
@@ -3172,14 +3151,15 @@ exports.FormFieldChoice = FormFieldChoice;
|
|
|
3172
3151
|
exports.FormFieldCode = FormFieldCode;
|
|
3173
3152
|
exports.FormFieldCustom = FormFieldCustom;
|
|
3174
3153
|
exports.FormFieldDatePicker = FormFieldDatePicker;
|
|
3154
|
+
exports.FormFieldFileInput = FormFieldFileInput;
|
|
3175
3155
|
exports.FormFieldInput = FormFieldInput;
|
|
3176
3156
|
exports.FormFieldMaskedInput = FormFieldMaskedInput;
|
|
3177
3157
|
exports.FormFieldPassword = FormFieldPassword;
|
|
3158
|
+
exports.FormFieldRadioGroup = FormFieldRadioGroup;
|
|
3178
3159
|
exports.FormFieldSegmented = FormFieldSegmented;
|
|
3179
3160
|
exports.FormFieldSelect = FormFieldSelect;
|
|
3180
3161
|
exports.FormFieldSwitch = FormFieldSwitch;
|
|
3181
3162
|
exports.FormFieldTextarea = FormFieldTextarea;
|
|
3182
|
-
exports.RadioGroup = RadioGroup;
|
|
3183
3163
|
exports.addRequiredFieldsParamToSchema = addRequiredFieldsParamToSchema;
|
|
3184
3164
|
exports.dateValidation = dateValidation;
|
|
3185
3165
|
exports.defaultCheckboxProps = defaultCheckboxProps;
|