@itcase/forms 1.1.54 → 1.1.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/form/Field/RadioGroup/FormFieldRadioGroup.css +7 -2
- package/dist/itcase-forms.cjs.js +422 -322
- package/dist/itcase-forms.esm.js +408 -309
- package/package.json +20 -19
package/dist/itcase-forms.esm.js
CHANGED
|
@@ -4,40 +4,38 @@ import { setIn, FORM_ERROR, getIn } from 'final-form';
|
|
|
4
4
|
import { useForm, Field, Form, FormSpy } from 'react-final-form';
|
|
5
5
|
export { Field, useForm, useFormState } from 'react-final-form';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
|
-
import { Checkbox } from '@itcase/ui/components/Checkbox';
|
|
7
|
+
import { Checkbox } from '@itcase/ui-web/components/Checkbox';
|
|
8
8
|
import camelCase from 'lodash/camelCase';
|
|
9
9
|
import snakeCase from 'lodash/snakeCase';
|
|
10
|
-
import { Divider } from '@itcase/ui/components/Divider';
|
|
11
|
-
import { Text } from '@itcase/ui/components/Text';
|
|
12
|
-
import { useDeviceTargetClass } from '@itcase/ui/hooks
|
|
13
|
-
import { useStyles } from '@itcase/ui/hooks/useStyles';
|
|
14
|
-
import { ChipsGroup, Chips } from '@itcase/ui/components/Chips';
|
|
15
|
-
import { Choice } from '@itcase/ui/components/Choice';
|
|
16
|
-
import { Code } from '@itcase/ui/components/Code';
|
|
17
|
-
import { Icon } from '@itcase/ui/components/Icon';
|
|
18
|
-
import { Dadata } from '@itcase/ui/components/Dadata';
|
|
19
|
-
import { DatePickerInput } from '@itcase/ui/components/DatePicker';
|
|
20
|
-
import { useDevicePropsGenerator } from '@itcase/ui/hooks/useDevicePropsGenerator';
|
|
10
|
+
import { Divider } from '@itcase/ui-web/components/Divider';
|
|
11
|
+
import { Text } from '@itcase/ui-web/components/Text';
|
|
12
|
+
import { useDeviceTargetClass, useStyles, useDevicePropsGenerator } from '@itcase/ui-core/hooks';
|
|
21
13
|
import axios from 'axios';
|
|
14
|
+
import createDecorator from 'final-form-focus';
|
|
15
|
+
import { ChipsGroup, Chips } from '@itcase/ui-web/components/Chips';
|
|
16
|
+
import { Choice } from '@itcase/ui-web/components/Choice';
|
|
17
|
+
import { Code } from '@itcase/ui-web/components/Code';
|
|
18
|
+
import { Icon } from '@itcase/ui-web/components/Icon';
|
|
19
|
+
import { Dadata } from '@itcase/ui-web/components/Dadata';
|
|
20
|
+
import { DatePickerInput } from '@itcase/ui-web/components/DatePicker';
|
|
22
21
|
import { fromEvent } from 'file-selector';
|
|
23
22
|
import castArray from 'lodash/castArray';
|
|
24
23
|
import { useDropzone, ErrorCode } from 'react-dropzone';
|
|
25
24
|
import { createFileFromDataURL } from '@itcase/common';
|
|
26
|
-
import { Button } from '@itcase/ui/components/Button';
|
|
27
|
-
import { Loader } from '@itcase/ui/components/Loader';
|
|
28
|
-
import { Title } from '@itcase/ui/components/Title';
|
|
29
|
-
import { Input } from '@itcase/ui/components/Input';
|
|
30
|
-
import { InputNumber } from '@itcase/ui/components/InputNumber';
|
|
25
|
+
import { Button } from '@itcase/ui-web/components/Button';
|
|
26
|
+
import { Loader } from '@itcase/ui-web/components/Loader';
|
|
27
|
+
import { Title } from '@itcase/ui-web/components/Title';
|
|
28
|
+
import { Input } from '@itcase/ui-web/components/Input';
|
|
29
|
+
import { InputNumber } from '@itcase/ui-web/components/InputNumber';
|
|
31
30
|
import { useIMask } from 'react-imask';
|
|
32
|
-
import { InputPassword } from '@itcase/ui/components/InputPassword';
|
|
33
|
-
import { Radio } from '@itcase/ui/components/Radio';
|
|
34
|
-
import { Segmented } from '@itcase/ui/components/Segmented';
|
|
35
|
-
import { Select } from '@itcase/ui/components/Select';
|
|
36
|
-
import { Switch } from '@itcase/ui/components/Switch';
|
|
37
|
-
import { Textarea } from '@itcase/ui/components/Textarea';
|
|
38
|
-
import { Group } from '@itcase/ui/components/Group';
|
|
39
|
-
import { Notification } from '@itcase/ui/components/Notification';
|
|
40
|
-
import createDecorator from 'final-form-focus';
|
|
31
|
+
import { InputPassword } from '@itcase/ui-web/components/InputPassword';
|
|
32
|
+
import { Radio } from '@itcase/ui-web/components/Radio';
|
|
33
|
+
import { Segmented } from '@itcase/ui-web/components/Segmented';
|
|
34
|
+
import { Select } from '@itcase/ui-web/components/Select';
|
|
35
|
+
import { Switch } from '@itcase/ui-web/components/Switch';
|
|
36
|
+
import { Textarea } from '@itcase/ui-web/components/Textarea';
|
|
37
|
+
import { Group } from '@itcase/ui-web/components/Group';
|
|
38
|
+
import { Notification } from '@itcase/ui-web/components/Notification';
|
|
41
39
|
|
|
42
40
|
var phoneValidation = function phoneValidation(value) {
|
|
43
41
|
if (!value) {
|
|
@@ -434,8 +432,8 @@ var defaultFieldProps = {
|
|
|
434
432
|
direction: 'vertical',
|
|
435
433
|
labelTextColor: 'surfaceTextPrimary',
|
|
436
434
|
messageTextColor: 'surfaceTextSecondary',
|
|
437
|
-
errorMessageTextColor: 'errorTextSecondary',
|
|
438
435
|
dividerFill: 'errorPrimary',
|
|
436
|
+
errorMessageTextColor: 'errorTextSecondary',
|
|
439
437
|
helpTextColor: 'surfaceTextQuaternary',
|
|
440
438
|
requiredMessageTextColor: 'warningTextSecondary',
|
|
441
439
|
showMessage: true
|
|
@@ -476,6 +474,7 @@ var defaultFieldSizeXL = Object.assign({
|
|
|
476
474
|
function FieldWrapperBase(props) {
|
|
477
475
|
var id = props.id,
|
|
478
476
|
className = props.className,
|
|
477
|
+
dataTestId = props.dataTestId,
|
|
479
478
|
dataTour = props.dataTour,
|
|
480
479
|
type = props.type,
|
|
481
480
|
label = props.label,
|
|
@@ -562,12 +561,12 @@ function FieldWrapperBase(props) {
|
|
|
562
561
|
var errorTextWeight = props[errorKey + "MessageTextWeight"];
|
|
563
562
|
return /*#__PURE__*/React.createElement(Tag, {
|
|
564
563
|
className: clsx(formFieldClass, 'form__item', 'form-field', type && "form-field_type_" + type, sizeClass, fillClass, shapeClass, isDisabled && "form-field_state_disabled", isHidden && "form-field_state_hidden", directionClass, widthClass),
|
|
565
|
-
"data-testid":
|
|
564
|
+
"data-testid": dataTestId,
|
|
566
565
|
"data-tour": dataTour,
|
|
567
566
|
style: formFieldStyles
|
|
568
567
|
}, before, (label || labelHidden) && /*#__PURE__*/React.createElement("div", {
|
|
569
568
|
className: clsx('form-field__label'),
|
|
570
|
-
"data-testid":
|
|
569
|
+
"data-testid": dataTestId + "Label",
|
|
571
570
|
htmlFor: id
|
|
572
571
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
573
572
|
size: labelTextSize,
|
|
@@ -577,7 +576,7 @@ function FieldWrapperBase(props) {
|
|
|
577
576
|
sizeTablet: labelTextSizeTablet
|
|
578
577
|
}, label, labelHidden && "\xA0")), desc && /*#__PURE__*/React.createElement("div", {
|
|
579
578
|
className: "form-field__desc",
|
|
580
|
-
"data-testid":
|
|
579
|
+
"data-testid": dataTestId + "Desc"
|
|
581
580
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
582
581
|
size: descTextSize,
|
|
583
582
|
textColor: descTextColor,
|
|
@@ -598,20 +597,20 @@ function FieldWrapperBase(props) {
|
|
|
598
597
|
}, isErrorState && errorMessage && /*#__PURE__*/React.createElement(Text, {
|
|
599
598
|
id: inputName + "-error",
|
|
600
599
|
className: "form-field__message-item form-field__message-item_type-error",
|
|
601
|
-
dataTestId:
|
|
600
|
+
dataTestId: dataTestId + "MessageError",
|
|
602
601
|
size: errorTextSize,
|
|
603
602
|
textColor: errorTextColor,
|
|
604
603
|
textWeight: errorTextWeight
|
|
605
604
|
}, errorMessage), Boolean(helpText) && (!isErrorState || !errorMessage) && /*#__PURE__*/React.createElement(Text, {
|
|
606
605
|
className: "form-field__message-item form-field__message-item_type_help-text",
|
|
607
|
-
dataTestId:
|
|
606
|
+
dataTestId: dataTestId + "MessageHelpText",
|
|
608
607
|
size: helpTextSize,
|
|
609
608
|
textColor: isValidState ? helpTextColorSuccess : helpTextColor,
|
|
610
609
|
textWeight: helpTextWeight,
|
|
611
610
|
sizeMobile: helpTextSizeMobile
|
|
612
611
|
}, helpText), (!isErrorState && !helpText || isErrorState && !helpText && !errorMessage) && /*#__PURE__*/React.createElement(Text, {
|
|
613
612
|
className: "form-field__message-item form-field__message-item_type_help-text",
|
|
614
|
-
dataTestId:
|
|
613
|
+
dataTestId: dataTestId + "MessageHelpText",
|
|
615
614
|
size: messageTextSize
|
|
616
615
|
}, "\xA0")), after);
|
|
617
616
|
}
|
|
@@ -628,16 +627,150 @@ function FieldWrapper(props) {
|
|
|
628
627
|
return /*#__PURE__*/React.createElement(FieldWrapperBase, props);
|
|
629
628
|
}
|
|
630
629
|
|
|
630
|
+
var focusOnError = function focusOnError(formElementsList, errors) {
|
|
631
|
+
var selectsIds = Object.keys(errors).map(function (fieldName) {
|
|
632
|
+
if (fieldName === FORM_ERROR) {
|
|
633
|
+
// TODO: get from somewhere
|
|
634
|
+
return 'notification__item_status_error';
|
|
635
|
+
}
|
|
636
|
+
return "react-select-id_" + fieldName + "-input";
|
|
637
|
+
});
|
|
638
|
+
var errorFieldElement = formElementsList.find(function (element) {
|
|
639
|
+
if (element.name) {
|
|
640
|
+
return getIn(errors, element.name);
|
|
641
|
+
} else {
|
|
642
|
+
return selectsIds.includes(element.id);
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
var errorsList = Object.keys(errors);
|
|
646
|
+
if (!errorFieldElement && errorsList.length) {
|
|
647
|
+
var errorElement;
|
|
648
|
+
try {
|
|
649
|
+
var fieldName = errorsList[0];
|
|
650
|
+
if (fieldName === FORM_ERROR) {
|
|
651
|
+
errorElement = document.querySelector('notification__item_status_error');
|
|
652
|
+
} else {
|
|
653
|
+
errorElement = document.querySelector("#" + fieldName + "-error");
|
|
654
|
+
if (!errorElement) {
|
|
655
|
+
errorElement = document.querySelector("#id_" + fieldName);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
} catch (err) {
|
|
659
|
+
console.warn(err);
|
|
660
|
+
}
|
|
661
|
+
if (errorElement) {
|
|
662
|
+
errorElement.scrollIntoView({
|
|
663
|
+
block: 'center'
|
|
664
|
+
}); // , behavior: 'smooth'
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
// The field is covered by the header because header is "sticky",
|
|
669
|
+
// that's we scroll manually so that the field falls into the center of the visible area
|
|
670
|
+
if (errorFieldElement) {
|
|
671
|
+
errorFieldElement.scrollIntoView({
|
|
672
|
+
block: 'center'
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
return null;
|
|
676
|
+
};
|
|
677
|
+
var focusOnErrorDecorator = createDecorator(null, focusOnError);
|
|
678
|
+
var setErrorsMutator = function setErrorsMutator(args, state) {
|
|
679
|
+
var fieldName = args[0],
|
|
680
|
+
data = args[1];
|
|
681
|
+
var submitError = data.submitError;
|
|
682
|
+
var fieldError = data.error;
|
|
683
|
+
if (fieldName === 'non_field_errors' || fieldName === FORM_ERROR) {
|
|
684
|
+
// state.formState.invalid = true
|
|
685
|
+
// state.formState.valid = false
|
|
686
|
+
state.formState.error = fieldError;
|
|
687
|
+
state.formState.submitError = submitError;
|
|
688
|
+
} else if (fieldName in state.fields) {
|
|
689
|
+
state.fields[fieldName].touched = true;
|
|
690
|
+
|
|
691
|
+
// TODO: make clear error not by empty string check
|
|
692
|
+
if (fieldError || fieldError === '') {
|
|
693
|
+
var _Object$assign;
|
|
694
|
+
var errorsState = Object.assign({}, state.formState.errors, (_Object$assign = {}, _Object$assign[fieldName] = fieldError, _Object$assign));
|
|
695
|
+
state.fields[fieldName].error = fieldError;
|
|
696
|
+
state.formState.errors = errorsState;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
// TODO: make clear error not by empty string check
|
|
700
|
+
if (submitError || submitError === '') {
|
|
701
|
+
var _Object$assign2;
|
|
702
|
+
var submitErrorsState = Object.assign({}, state.formState.submitErrors, (_Object$assign2 = {}, _Object$assign2[fieldName] = submitError, _Object$assign2));
|
|
703
|
+
state.fields[fieldName].submitFailed = true;
|
|
704
|
+
state.fields[fieldName].submitSucceeded = false;
|
|
705
|
+
state.fields[fieldName].submitError = submitError;
|
|
706
|
+
state.formState.submitErrors = submitErrorsState;
|
|
707
|
+
state.formState.submitFailed = true;
|
|
708
|
+
state.formState.submitSucceeded = false;
|
|
709
|
+
state.formState.lastSubmittedValues = state.formState.values;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
var sendFormDataToServer = /*#__PURE__*/function () {
|
|
714
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(url, data) {
|
|
715
|
+
var response, _error$response, _error$response2, formErrors, _t;
|
|
716
|
+
return _regenerator().w(function (_context) {
|
|
717
|
+
while (1) switch (_context.p = _context.n) {
|
|
718
|
+
case 0:
|
|
719
|
+
_context.p = 0;
|
|
720
|
+
_context.n = 1;
|
|
721
|
+
return axios({
|
|
722
|
+
url: url,
|
|
723
|
+
method: 'POST',
|
|
724
|
+
data: data
|
|
725
|
+
});
|
|
726
|
+
case 1:
|
|
727
|
+
response = _context.v;
|
|
728
|
+
return _context.a(2, {
|
|
729
|
+
response: response,
|
|
730
|
+
success: true
|
|
731
|
+
});
|
|
732
|
+
case 2:
|
|
733
|
+
_context.p = 2;
|
|
734
|
+
_t = _context.v;
|
|
735
|
+
formErrors = {};
|
|
736
|
+
if (typeof ((_error$response = _t.response) == null ? void 0 : _error$response.data) === 'string') {
|
|
737
|
+
formErrors[FORM_ERROR] = 'Something went wrong';
|
|
738
|
+
}
|
|
739
|
+
if (typeof ((_error$response2 = _t.response) == null ? void 0 : _error$response2.data) === 'object') {
|
|
740
|
+
Object.entries(_t.response.data).forEach(function (_ref2) {
|
|
741
|
+
var fieldName = _ref2[0],
|
|
742
|
+
errorsList = _ref2[1];
|
|
743
|
+
formErrors[fieldName] = errorsList[0];
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
return _context.a(2, {
|
|
747
|
+
error: _t,
|
|
748
|
+
formErrors: formErrors,
|
|
749
|
+
success: false
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
}, _callee, null, [[0, 2]]);
|
|
753
|
+
}));
|
|
754
|
+
return function sendFormDataToServer(_x, _x2) {
|
|
755
|
+
return _ref.apply(this, arguments);
|
|
756
|
+
};
|
|
757
|
+
}();
|
|
758
|
+
var createDataTestIdField = function createDataTestIdField(fieldname, dataTestId) {
|
|
759
|
+
var dataTestIdField = dataTestId + fieldname[0].toUpperCase() + fieldname.slice(1) + 'Field';
|
|
760
|
+
return dataTestIdField;
|
|
761
|
+
};
|
|
762
|
+
|
|
631
763
|
var FormFieldCheckbox = /*#__PURE__*/React.memo(function FormFieldCheckbox(props) {
|
|
632
|
-
var
|
|
764
|
+
var dataTestId = props.dataTestId,
|
|
765
|
+
name = props.name,
|
|
633
766
|
initialValue = props.initialValue,
|
|
634
|
-
isDisabled = props.isDisabled,
|
|
635
767
|
classNameGroupItem = props.classNameGroupItem,
|
|
636
768
|
_props$fieldProps = props.fieldProps,
|
|
637
769
|
fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
|
|
638
770
|
_props$inputProps = props.inputProps,
|
|
639
771
|
inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
|
|
640
772
|
showMessage = props.showMessage,
|
|
773
|
+
isDisabled = props.isDisabled,
|
|
641
774
|
isRequired = props.isRequired,
|
|
642
775
|
onChange = props.onChange;
|
|
643
776
|
return /*#__PURE__*/React.createElement(Field, {
|
|
@@ -667,35 +800,37 @@ var FormFieldCheckbox = /*#__PURE__*/React.memo(function FormFieldCheckbox(props
|
|
|
667
800
|
}),
|
|
668
801
|
errorKey = _useFieldValidationSt.errorKey,
|
|
669
802
|
errorMessage = _useFieldValidationSt.errorMessage,
|
|
670
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
671
803
|
successKey = _useFieldValidationSt.successKey,
|
|
804
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
672
805
|
isValidState = _useFieldValidationSt.isValidState;
|
|
673
806
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
674
807
|
inputProps: inputProps,
|
|
675
808
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
676
809
|
});
|
|
810
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
677
811
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
678
812
|
className: clsx('form-field-checkbox', 'form__item_checkbox', classNameGroupItem),
|
|
813
|
+
dataTestId: dataTestIdField,
|
|
679
814
|
errorKey: errorKey,
|
|
680
815
|
errorMessage: errorMessage,
|
|
681
|
-
isErrorState: isErrorState,
|
|
682
|
-
metaError: meta.error,
|
|
683
|
-
isDisabled: isDisabled,
|
|
684
816
|
fieldClassName: "form-checkbox",
|
|
685
817
|
inputName: input.name,
|
|
686
818
|
inputValue: input.checked,
|
|
687
819
|
metaActive: meta.active,
|
|
820
|
+
metaError: meta.error,
|
|
688
821
|
showMessage: showMessage,
|
|
689
822
|
tag: "label",
|
|
823
|
+
isDisabled: isDisabled,
|
|
824
|
+
isErrorState: isErrorState,
|
|
690
825
|
isRequired: isRequired,
|
|
691
826
|
isValidState: isValidState
|
|
692
827
|
}, fieldProps), /*#__PURE__*/React.createElement(Checkbox, Object.assign({
|
|
693
828
|
type: "checkbox",
|
|
694
829
|
name: input.name,
|
|
695
|
-
isDisabled: isDisabled,
|
|
696
830
|
autoComplete: "nope",
|
|
697
831
|
checked: input.checked,
|
|
698
832
|
isActive: input.checked,
|
|
833
|
+
isDisabled: isDisabled,
|
|
699
834
|
onBlur: input.onBlur,
|
|
700
835
|
onChange: onChangeField,
|
|
701
836
|
onFocus: input.onFocus
|
|
@@ -716,7 +851,8 @@ var defaultChipsProps = {
|
|
|
716
851
|
};
|
|
717
852
|
|
|
718
853
|
function FormFieldChips(props) {
|
|
719
|
-
var
|
|
854
|
+
var dataTestId = props.dataTestId,
|
|
855
|
+
name = props.name,
|
|
720
856
|
initialValue = props.initialValue,
|
|
721
857
|
classNameGroupItem = props.classNameGroupItem,
|
|
722
858
|
emptyMessage = props.emptyMessage,
|
|
@@ -779,8 +915,10 @@ function FormFieldChips(props) {
|
|
|
779
915
|
}
|
|
780
916
|
return emptyOptionsList;
|
|
781
917
|
}, [input.value]);
|
|
918
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
782
919
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
783
920
|
className: clsx('form-field_chips', 'form__item_chips', classNameGroupItem),
|
|
921
|
+
dataTestId: dataTestIdField,
|
|
784
922
|
errorKey: errorKey,
|
|
785
923
|
errorMessage: errorMessage,
|
|
786
924
|
fieldClassName: "form-chips",
|
|
@@ -829,17 +967,18 @@ var defaultChoiceProps = {
|
|
|
829
967
|
};
|
|
830
968
|
|
|
831
969
|
var FormFieldChoice = /*#__PURE__*/React.memo(function FormFieldChoice(props) {
|
|
832
|
-
var
|
|
970
|
+
var dataTestId = props.dataTestId,
|
|
971
|
+
name = props.name,
|
|
833
972
|
initialValue = props.initialValue,
|
|
834
973
|
label = props.label,
|
|
835
974
|
messageType = props.messageType,
|
|
836
|
-
isDisabled = props.isDisabled,
|
|
837
975
|
classNameGroupItem = props.classNameGroupItem,
|
|
838
976
|
fieldProps = props.fieldProps,
|
|
839
977
|
inputProps = props.inputProps,
|
|
840
978
|
options = props.options,
|
|
841
979
|
placeholder = props.placeholder,
|
|
842
980
|
showMessage = props.showMessage,
|
|
981
|
+
isDisabled = props.isDisabled,
|
|
843
982
|
isCheckbox = props.isCheckbox,
|
|
844
983
|
isRequired = props.isRequired,
|
|
845
984
|
onChange = props.onChange;
|
|
@@ -852,8 +991,8 @@ var FormFieldChoice = /*#__PURE__*/React.memo(function FormFieldChoice(props) {
|
|
|
852
991
|
}
|
|
853
992
|
}, [change, onChange]);
|
|
854
993
|
return /*#__PURE__*/React.createElement(Field, {
|
|
855
|
-
|
|
856
|
-
|
|
994
|
+
name: name,
|
|
995
|
+
initialValue: initialValue
|
|
857
996
|
}, function Render(_ref) {
|
|
858
997
|
var input = _ref.input,
|
|
859
998
|
meta = _ref.meta;
|
|
@@ -865,8 +1004,8 @@ var FormFieldChoice = /*#__PURE__*/React.memo(function FormFieldChoice(props) {
|
|
|
865
1004
|
*/
|
|
866
1005
|
var activeOption = useMemo(function () {
|
|
867
1006
|
var emptyOption = {
|
|
868
|
-
|
|
869
|
-
|
|
1007
|
+
label: null,
|
|
1008
|
+
value: null
|
|
870
1009
|
};
|
|
871
1010
|
if (input.value) {
|
|
872
1011
|
var currentOption = options.find(function (option) {
|
|
@@ -883,40 +1022,42 @@ var FormFieldChoice = /*#__PURE__*/React.memo(function FormFieldChoice(props) {
|
|
|
883
1022
|
}),
|
|
884
1023
|
errorKey = _useFieldValidationSt.errorKey,
|
|
885
1024
|
errorMessage = _useFieldValidationSt.errorMessage,
|
|
886
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
887
1025
|
successKey = _useFieldValidationSt.successKey,
|
|
1026
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
888
1027
|
isValidState = _useFieldValidationSt.isValidState;
|
|
889
1028
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
890
1029
|
inputProps: inputProps,
|
|
891
1030
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
892
1031
|
});
|
|
1032
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
893
1033
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
894
1034
|
className: clsx('form-field_choice', 'form__item_choice', classNameGroupItem),
|
|
1035
|
+
dataTestId: dataTestIdField,
|
|
895
1036
|
label: label,
|
|
896
1037
|
messageType: messageType,
|
|
897
1038
|
errorKey: errorKey,
|
|
898
1039
|
errorMessage: errorMessage,
|
|
899
|
-
isErrorState: isErrorState,
|
|
900
|
-
metaError: meta.error,
|
|
901
|
-
isDisabled: isDisabled,
|
|
902
1040
|
fieldClassName: "form-choice",
|
|
903
1041
|
inputName: input.name,
|
|
904
1042
|
inputValue: input.value || [],
|
|
905
1043
|
metaActive: meta.active,
|
|
1044
|
+
metaError: meta.error,
|
|
906
1045
|
showMessage: showMessage,
|
|
1046
|
+
isDisabled: isDisabled,
|
|
1047
|
+
isErrorState: isErrorState,
|
|
907
1048
|
isRequired: isRequired,
|
|
908
1049
|
isValidState: isValidState
|
|
909
1050
|
}, fieldProps), /*#__PURE__*/React.createElement(Choice, Object.assign({
|
|
910
1051
|
className: clsx(meta.active && 'form-choice_state_focus', meta.error && meta.touched && "form-choice_state_" + errorKey),
|
|
911
1052
|
name: input.name,
|
|
912
|
-
isDisabled: isDisabled,
|
|
913
1053
|
active: activeOption,
|
|
914
1054
|
inputValue: input.value || [],
|
|
915
1055
|
options: options,
|
|
916
1056
|
placeholder: placeholder,
|
|
917
|
-
|
|
1057
|
+
isDisabled: isDisabled,
|
|
918
1058
|
isCheckbox: isCheckbox,
|
|
919
|
-
isRequired: isRequired
|
|
1059
|
+
isRequired: isRequired,
|
|
1060
|
+
setActiveSegment: setActiveSegment
|
|
920
1061
|
}, updatedInputProps)));
|
|
921
1062
|
});
|
|
922
1063
|
});
|
|
@@ -931,17 +1072,18 @@ var defaultCodeProps = {
|
|
|
931
1072
|
};
|
|
932
1073
|
|
|
933
1074
|
var FormFieldCode = /*#__PURE__*/React.memo(function FormFieldCode(props) {
|
|
934
|
-
var
|
|
1075
|
+
var dataTestId = props.dataTestId,
|
|
1076
|
+
name = props.name,
|
|
935
1077
|
initialValue = props.initialValue,
|
|
936
1078
|
label = props.label,
|
|
937
1079
|
messageType = props.messageType,
|
|
938
|
-
isDisabled = props.isDisabled,
|
|
939
1080
|
classNameGroupItem = props.classNameGroupItem,
|
|
940
1081
|
_props$fieldProps = props.fieldProps,
|
|
941
1082
|
fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
|
|
942
1083
|
_props$inputProps = props.inputProps,
|
|
943
1084
|
inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
|
|
944
1085
|
showMessage = props.showMessage,
|
|
1086
|
+
isDisabled = props.isDisabled,
|
|
945
1087
|
isRequired = props.isRequired;
|
|
946
1088
|
return /*#__PURE__*/React.createElement(Field, {
|
|
947
1089
|
name: name,
|
|
@@ -963,32 +1105,34 @@ var FormFieldCode = /*#__PURE__*/React.memo(function FormFieldCode(props) {
|
|
|
963
1105
|
}),
|
|
964
1106
|
errorKey = _useFieldValidationSt.errorKey,
|
|
965
1107
|
errorMessage = _useFieldValidationSt.errorMessage,
|
|
966
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
967
1108
|
successKey = _useFieldValidationSt.successKey,
|
|
1109
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
968
1110
|
isValidState = _useFieldValidationSt.isValidState;
|
|
969
1111
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
970
1112
|
inputProps: inputProps,
|
|
971
1113
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
972
1114
|
});
|
|
1115
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
973
1116
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
974
1117
|
className: clsx('form-field-code', 'form__item_code', classNameGroupItem),
|
|
1118
|
+
dataTestId: dataTestIdField,
|
|
975
1119
|
label: label,
|
|
976
1120
|
messageType: messageType,
|
|
977
1121
|
errorKey: errorKey,
|
|
978
1122
|
errorMessage: errorMessage,
|
|
979
|
-
isErrorState: isErrorState,
|
|
980
1123
|
fieldClassName: 'form-code',
|
|
981
1124
|
inputName: input.name,
|
|
982
1125
|
inputValue: input.value,
|
|
983
1126
|
metaActive: meta.active,
|
|
984
1127
|
showMessage: showMessage,
|
|
1128
|
+
isErrorState: isErrorState,
|
|
985
1129
|
isRequired: isRequired,
|
|
986
1130
|
isValidState: isValidState
|
|
987
1131
|
}, fieldProps), /*#__PURE__*/React.createElement(Code, Object.assign({
|
|
988
1132
|
name: input.name,
|
|
989
1133
|
initialValue: input.value,
|
|
990
|
-
isDisabled: isDisabled,
|
|
991
1134
|
autoComplete: "nope",
|
|
1135
|
+
isDisabled: isDisabled,
|
|
992
1136
|
onBlur: input.onBlur,
|
|
993
1137
|
onChange: input.onChange,
|
|
994
1138
|
onFocus: input.onFocus
|
|
@@ -997,24 +1141,25 @@ var FormFieldCode = /*#__PURE__*/React.memo(function FormFieldCode(props) {
|
|
|
997
1141
|
});
|
|
998
1142
|
|
|
999
1143
|
var FormFieldCustom = /*#__PURE__*/React.memo(function FormFieldCustom(props) {
|
|
1000
|
-
var
|
|
1001
|
-
isDisabled = props.isDisabled,
|
|
1002
|
-
isRequired = props.isRequired,
|
|
1144
|
+
var dataTestId = props.dataTestId,
|
|
1003
1145
|
name = props.name,
|
|
1004
1146
|
initialValue = props.initialValue,
|
|
1005
|
-
_props$fieldProps = props.fieldProps,
|
|
1006
|
-
fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
|
|
1007
1147
|
classNameGroupItem = props.classNameGroupItem,
|
|
1008
|
-
showMessage = props.showMessage,
|
|
1009
1148
|
clearIcon = props.clearIcon,
|
|
1010
1149
|
clearIconFill = props.clearIconFill,
|
|
1011
1150
|
clearIconFillHover = props.clearIconFillHover,
|
|
1012
1151
|
clearIconShape = props.clearIconShape,
|
|
1013
1152
|
clearIconSize = props.clearIconSize,
|
|
1153
|
+
Component = props.Component,
|
|
1154
|
+
_props$fieldProps = props.fieldProps,
|
|
1155
|
+
fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
|
|
1156
|
+
showMessage = props.showMessage,
|
|
1157
|
+
isDisabled = props.isDisabled,
|
|
1158
|
+
isRequired = props.isRequired,
|
|
1014
1159
|
onClickClearIcon = props.onClickClearIcon;
|
|
1015
1160
|
return /*#__PURE__*/React.createElement(Field, {
|
|
1016
|
-
|
|
1017
|
-
|
|
1161
|
+
name: name,
|
|
1162
|
+
initialValue: initialValue
|
|
1018
1163
|
}, function Render(_ref) {
|
|
1019
1164
|
var input = _ref.input,
|
|
1020
1165
|
meta = _ref.meta;
|
|
@@ -1030,40 +1175,42 @@ var FormFieldCustom = /*#__PURE__*/React.memo(function FormFieldCustom(props) {
|
|
|
1030
1175
|
input: input,
|
|
1031
1176
|
meta: meta
|
|
1032
1177
|
}),
|
|
1033
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
1034
|
-
isValidState = _useFieldValidationSt.isValidState,
|
|
1035
1178
|
errorKey = _useFieldValidationSt.errorKey,
|
|
1036
|
-
errorMessage = _useFieldValidationSt.errorMessage
|
|
1179
|
+
errorMessage = _useFieldValidationSt.errorMessage,
|
|
1180
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
1181
|
+
isValidState = _useFieldValidationSt.isValidState;
|
|
1037
1182
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
1038
|
-
validationStateKey: isErrorState ? errorKey : 'success',
|
|
1039
1183
|
// For "Custom" field we pass all props. Can contain some special props, we don't known.
|
|
1040
|
-
inputProps: props
|
|
1184
|
+
inputProps: props,
|
|
1185
|
+
validationStateKey: isErrorState ? errorKey : 'success'
|
|
1041
1186
|
});
|
|
1187
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
1042
1188
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
1043
1189
|
className: clsx('form-field_custom', 'form__item_custom', classNameGroupItem),
|
|
1190
|
+
dataTestId: dataTestIdField,
|
|
1044
1191
|
errorKey: errorKey,
|
|
1045
1192
|
errorMessage: errorMessage,
|
|
1046
1193
|
fieldClassName: 'form-custom',
|
|
1047
1194
|
inputName: input.name,
|
|
1048
1195
|
inputValue: input.value,
|
|
1196
|
+
metaActive: meta.active,
|
|
1197
|
+
metaError: meta.error,
|
|
1198
|
+
showMessage: showMessage,
|
|
1049
1199
|
isDisabled: isDisabled,
|
|
1050
1200
|
isErrorState: isErrorState,
|
|
1051
1201
|
isRequired: isRequired,
|
|
1052
|
-
isValidState: isValidState
|
|
1053
|
-
metaActive: meta.active,
|
|
1054
|
-
metaError: meta.error,
|
|
1055
|
-
showMessage: showMessage
|
|
1202
|
+
isValidState: isValidState
|
|
1056
1203
|
}, fieldProps), /*#__PURE__*/React.createElement(Component, Object.assign({}, updatedInputProps, {
|
|
1057
1204
|
input: input,
|
|
1058
|
-
|
|
1059
|
-
|
|
1205
|
+
meta: meta,
|
|
1206
|
+
isDisabled: isDisabled
|
|
1060
1207
|
})), clearIcon && /*#__PURE__*/React.createElement(Icon, {
|
|
1061
1208
|
className: "form-field__icon",
|
|
1209
|
+
size: clearIconSize,
|
|
1062
1210
|
iconFill: clearIconFill,
|
|
1063
1211
|
iconFillHover: clearIconFillHover,
|
|
1064
1212
|
imageSrc: clearIcon,
|
|
1065
1213
|
shape: clearIconShape,
|
|
1066
|
-
size: clearIconSize,
|
|
1067
1214
|
SvgImage: clearIcon,
|
|
1068
1215
|
onClick: onClickClearIcon
|
|
1069
1216
|
}));
|
|
@@ -1082,15 +1229,16 @@ var defaultDadataInputProps = {
|
|
|
1082
1229
|
};
|
|
1083
1230
|
|
|
1084
1231
|
var FormFieldDadataInput = /*#__PURE__*/React.memo(function FormFieldDadataInput(props) {
|
|
1085
|
-
var
|
|
1232
|
+
var dataTestId = props.dataTestId,
|
|
1233
|
+
name = props.name,
|
|
1086
1234
|
initialValue = props.initialValue,
|
|
1087
|
-
isDisabled = props.isDisabled,
|
|
1088
1235
|
classNameGroupItem = props.classNameGroupItem,
|
|
1089
1236
|
fieldProps = props.fieldProps,
|
|
1090
1237
|
inputProps = props.inputProps,
|
|
1091
1238
|
parse = props.parse,
|
|
1092
1239
|
showMessage = props.showMessage,
|
|
1093
1240
|
token = props.token,
|
|
1241
|
+
isDisabled = props.isDisabled,
|
|
1094
1242
|
isRequired = props.isRequired,
|
|
1095
1243
|
onDadataAutocomplete = props.onDadataAutocomplete;
|
|
1096
1244
|
if (process.env.NODE_ENV === 'development') {
|
|
@@ -1125,25 +1273,27 @@ var FormFieldDadataInput = /*#__PURE__*/React.memo(function FormFieldDadataInput
|
|
|
1125
1273
|
}),
|
|
1126
1274
|
errorKey = _useFieldValidationSt.errorKey,
|
|
1127
1275
|
errorMessage = _useFieldValidationSt.errorMessage,
|
|
1128
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
1129
1276
|
successKey = _useFieldValidationSt.successKey,
|
|
1277
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
1130
1278
|
isValidState = _useFieldValidationSt.isValidState;
|
|
1131
1279
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
1132
1280
|
inputProps: inputProps,
|
|
1133
1281
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1134
1282
|
});
|
|
1283
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
1135
1284
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
1136
1285
|
className: clsx('form-field_input-dadata', 'form__item_input-dadata', classNameGroupItem),
|
|
1286
|
+
dataTestId: dataTestIdField,
|
|
1137
1287
|
errorKey: errorKey,
|
|
1138
1288
|
errorMessage: errorMessage,
|
|
1139
|
-
isErrorState: isErrorState,
|
|
1140
|
-
metaError: meta.error,
|
|
1141
|
-
isDisabled: isDisabled,
|
|
1142
1289
|
fieldClassName: "form-dadata",
|
|
1143
1290
|
inputName: input.name,
|
|
1144
1291
|
inputValue: input.value || '',
|
|
1145
1292
|
metaActive: meta.active,
|
|
1293
|
+
metaError: meta.error,
|
|
1146
1294
|
showMessage: showMessage,
|
|
1295
|
+
isDisabled: isDisabled,
|
|
1296
|
+
isErrorState: isErrorState,
|
|
1147
1297
|
isRequired: isRequired,
|
|
1148
1298
|
isValidState: isValidState
|
|
1149
1299
|
}, fieldProps), /*#__PURE__*/React.createElement(Dadata
|
|
@@ -1156,8 +1306,8 @@ var FormFieldDadataInput = /*#__PURE__*/React.memo(function FormFieldDadataInput
|
|
|
1156
1306
|
input: input,
|
|
1157
1307
|
inputProps: updatedInputProps,
|
|
1158
1308
|
meta: meta,
|
|
1159
|
-
|
|
1160
|
-
|
|
1309
|
+
token: token,
|
|
1310
|
+
setValue: onDadataAutocomplete
|
|
1161
1311
|
}));
|
|
1162
1312
|
});
|
|
1163
1313
|
});
|
|
@@ -1176,8 +1326,8 @@ var defaultDatepickerProps = {
|
|
|
1176
1326
|
};
|
|
1177
1327
|
|
|
1178
1328
|
function FormFieldDatePicker(props) {
|
|
1179
|
-
var
|
|
1180
|
-
|
|
1329
|
+
var dataTestId = props.dataTestId,
|
|
1330
|
+
name = props.name,
|
|
1181
1331
|
classNameGroupItem = props.classNameGroupItem,
|
|
1182
1332
|
datePickerProps = props.datePickerProps,
|
|
1183
1333
|
_props$fieldProps = props.fieldProps,
|
|
@@ -1185,6 +1335,7 @@ function FormFieldDatePicker(props) {
|
|
|
1185
1335
|
_props$inputProps = props.inputProps,
|
|
1186
1336
|
inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
|
|
1187
1337
|
showMessage = props.showMessage,
|
|
1338
|
+
isDisabled = props.isDisabled,
|
|
1188
1339
|
isRequired = props.isRequired,
|
|
1189
1340
|
onChange = props.onChange;
|
|
1190
1341
|
return /*#__PURE__*/React.createElement(Field, {
|
|
@@ -1222,34 +1373,36 @@ function FormFieldDatePicker(props) {
|
|
|
1222
1373
|
}),
|
|
1223
1374
|
errorKey = _useFieldValidationSt.errorKey,
|
|
1224
1375
|
errorMessage = _useFieldValidationSt.errorMessage,
|
|
1225
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
1226
1376
|
successKey = _useFieldValidationSt.successKey,
|
|
1377
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
1227
1378
|
isValidState = _useFieldValidationSt.isValidState;
|
|
1228
1379
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
1229
1380
|
inputProps: inputProps,
|
|
1230
1381
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1231
1382
|
});
|
|
1383
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
1232
1384
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
1233
1385
|
className: clsx('form-field_datepicker', 'form__item_datepicker', classNameGroupItem),
|
|
1386
|
+
dataTestId: dataTestIdField,
|
|
1234
1387
|
errorKey: errorKey,
|
|
1235
1388
|
errorMessage: errorMessage,
|
|
1236
|
-
isErrorState: isErrorState,
|
|
1237
|
-
metaError: meta.error,
|
|
1238
|
-
isDisabled: isDisabled,
|
|
1239
1389
|
fieldClassName: "form-datepicker",
|
|
1240
1390
|
inputName: input.name,
|
|
1241
1391
|
inputValue: input.value || '',
|
|
1242
1392
|
metaActive: meta.active,
|
|
1393
|
+
metaError: meta.error,
|
|
1243
1394
|
showMessage: showMessage,
|
|
1395
|
+
isDisabled: isDisabled,
|
|
1396
|
+
isErrorState: isErrorState,
|
|
1244
1397
|
isRequired: isRequired,
|
|
1245
1398
|
isValidState: isValidState
|
|
1246
1399
|
}, fieldProps), /*#__PURE__*/React.createElement(DatePickerInput, {
|
|
1247
1400
|
name: input.name,
|
|
1248
|
-
isDisabled: isDisabled,
|
|
1249
1401
|
datePickerProps: datePickerProps,
|
|
1250
1402
|
endValue: datePickerProps.selectsRange ? input.value.endDate : null,
|
|
1251
1403
|
inputProps: updatedInputProps,
|
|
1252
1404
|
value: datePickerProps.selectsRange ? input.value.startDate : input.value,
|
|
1405
|
+
isDisabled: isDisabled,
|
|
1253
1406
|
onBlur: input.onBlur,
|
|
1254
1407
|
onChange: onChangeField,
|
|
1255
1408
|
onFocus: input.onFocus
|
|
@@ -1723,23 +1876,24 @@ function setFileDataURL(file, resolve) {
|
|
|
1723
1876
|
|
|
1724
1877
|
var FormFieldFileInput = /*#__PURE__*/React.memo(function FormFieldFileInput(props) {
|
|
1725
1878
|
var className = props.className,
|
|
1879
|
+
dataTestId = props.dataTestId,
|
|
1726
1880
|
name = props.name,
|
|
1727
1881
|
width = props.width,
|
|
1728
1882
|
maxFiles = props.maxFiles,
|
|
1729
1883
|
maxSize = props.maxSize,
|
|
1730
1884
|
label = props.label,
|
|
1731
|
-
fileErrorText = props.fileErrorText,
|
|
1732
1885
|
classNameGroupItem = props.classNameGroupItem,
|
|
1733
1886
|
dropzoneProps = props.dropzoneProps,
|
|
1734
1887
|
fieldProps = props.fieldProps,
|
|
1888
|
+
fileErrorText = props.fileErrorText,
|
|
1735
1889
|
hintDescription = props.hintDescription,
|
|
1736
1890
|
hintTitle = props.hintTitle,
|
|
1737
1891
|
showFilename = props.showFilename,
|
|
1738
1892
|
showMessage = props.showMessage,
|
|
1739
1893
|
isPreviews = props.isPreviews,
|
|
1740
1894
|
isRequired = props.isRequired,
|
|
1741
|
-
onAddFiles = props.onAddFiles,
|
|
1742
1895
|
onClickPreview = props.onClickPreview,
|
|
1896
|
+
onAddFiles = props.onAddFiles,
|
|
1743
1897
|
onDeleteFile = props.onDeleteFile;
|
|
1744
1898
|
var propsGenerator = useDevicePropsGenerator(props);
|
|
1745
1899
|
var size = propsGenerator.size,
|
|
@@ -1802,25 +1956,27 @@ var FormFieldFileInput = /*#__PURE__*/React.memo(function FormFieldFileInput(pro
|
|
|
1802
1956
|
inputProps: props,
|
|
1803
1957
|
validationStateKey: isErrorState ? errorKey : 'success'
|
|
1804
1958
|
});
|
|
1959
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
1805
1960
|
|
|
1806
1961
|
/** TODO:
|
|
1807
1962
|
* REFACTOR PROPERTIES
|
|
1808
1963
|
*/
|
|
1809
1964
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
1810
1965
|
className: clsx('form-field_type_dropzone', 'form__item_type_dropzone', classNameGroupItem),
|
|
1966
|
+
dataTestId: dataTestIdField,
|
|
1811
1967
|
width: width,
|
|
1812
1968
|
label: label,
|
|
1813
1969
|
labelTextColor: labelTextColor,
|
|
1814
1970
|
errorKey: errorKey,
|
|
1815
1971
|
errorMessage: errorMessage,
|
|
1816
|
-
isErrorState: isErrorState,
|
|
1817
|
-
metaError: meta.error,
|
|
1818
1972
|
fieldClassName: "form-dropzone",
|
|
1819
1973
|
inputName: input.name,
|
|
1820
1974
|
inputValue: input.value,
|
|
1821
1975
|
metaActive: meta.active,
|
|
1976
|
+
metaError: meta.error,
|
|
1822
1977
|
metaTouched: meta.touched,
|
|
1823
1978
|
showMessage: showMessage,
|
|
1979
|
+
isErrorState: isErrorState,
|
|
1824
1980
|
isRequired: isRequired,
|
|
1825
1981
|
isValidState: isValidState
|
|
1826
1982
|
}, fieldProps), /*#__PURE__*/React.createElement(FileInputDropzone, {
|
|
@@ -1834,12 +1990,11 @@ var FormFieldFileInput = /*#__PURE__*/React.memo(function FormFieldFileInput(pro
|
|
|
1834
1990
|
borderColorHover: borderColorHover,
|
|
1835
1991
|
borderType: borderType,
|
|
1836
1992
|
borderWidth: borderWidth,
|
|
1993
|
+
dropzoneProps: dropzoneProps,
|
|
1837
1994
|
errorMessageTextColor: errorMessageTextColor,
|
|
1838
1995
|
errorMessageTextSize: errorMessageTextSize,
|
|
1839
1996
|
errorMessageWeight: errorMessageTextWeight,
|
|
1840
1997
|
fileErrorText: fileErrorText,
|
|
1841
|
-
metaError: meta.error,
|
|
1842
|
-
dropzoneProps: dropzoneProps,
|
|
1843
1998
|
hintDescription: hintDescription,
|
|
1844
1999
|
hintDescriptionTextColor: hintDescriptionTextColor,
|
|
1845
2000
|
hintDescriptionTextSize: hintDescriptionTextSize,
|
|
@@ -1852,6 +2007,7 @@ var FormFieldFileInput = /*#__PURE__*/React.memo(function FormFieldFileInput(pro
|
|
|
1852
2007
|
hintTitleTextWrap: hintTitleTextWrap,
|
|
1853
2008
|
inputName: input.name,
|
|
1854
2009
|
inputValue: input.value,
|
|
2010
|
+
metaError: meta.error,
|
|
1855
2011
|
metaTouched: meta.touched,
|
|
1856
2012
|
removeThumbAppearance: removeThumbAppearance,
|
|
1857
2013
|
removeThumbShape: removeThumbShape,
|
|
@@ -1870,8 +2026,8 @@ var FormFieldFileInput = /*#__PURE__*/React.memo(function FormFieldFileInput(pro
|
|
|
1870
2026
|
thumbNameTextWeight: thumbNameTextWeight,
|
|
1871
2027
|
thumbNameTextWrap: thumbNameTextWrap,
|
|
1872
2028
|
isPreviews: isPreviews,
|
|
1873
|
-
onAddFiles: onAddFiles,
|
|
1874
2029
|
onClickPreview: onClickPreview,
|
|
2030
|
+
onAddFiles: onAddFiles,
|
|
1875
2031
|
onDeleteFile: onDeleteFile
|
|
1876
2032
|
}));
|
|
1877
2033
|
});
|
|
@@ -1890,8 +2046,9 @@ var defaultGroupProps = {
|
|
|
1890
2046
|
};
|
|
1891
2047
|
|
|
1892
2048
|
var FormBlockGroup = /*#__PURE__*/React.memo(function Group(props) {
|
|
1893
|
-
var
|
|
1894
|
-
|
|
2049
|
+
var className = props.className,
|
|
2050
|
+
dataTestId = props.dataTestId,
|
|
2051
|
+
dataTour = props.dataTour,
|
|
1895
2052
|
name = props.name,
|
|
1896
2053
|
title = props.title,
|
|
1897
2054
|
titleTextColor = props.titleTextColor,
|
|
@@ -1915,6 +2072,7 @@ var FormBlockGroup = /*#__PURE__*/React.memo(function Group(props) {
|
|
|
1915
2072
|
// @ts-expect-error
|
|
1916
2073
|
var _useStyles = useStyles(props),
|
|
1917
2074
|
styles = _useStyles.styles;
|
|
2075
|
+
var dataTestIdField = createDataTestIdField(name, dataTestId);
|
|
1918
2076
|
return /*#__PURE__*/React.createElement(Field, {
|
|
1919
2077
|
name: name
|
|
1920
2078
|
}, function Render(_ref) {
|
|
@@ -1941,6 +2099,7 @@ var FormBlockGroup = /*#__PURE__*/React.memo(function Group(props) {
|
|
|
1941
2099
|
});
|
|
1942
2100
|
return /*#__PURE__*/React.createElement("div", {
|
|
1943
2101
|
className: clsx('form__group', className, isHidden && 'form__group_hidden', column && "form__group_column_" + column),
|
|
2102
|
+
"data-test-id": dataTestIdField,
|
|
1944
2103
|
"data-tour": dataTour,
|
|
1945
2104
|
style: styles
|
|
1946
2105
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -1948,12 +2107,14 @@ var FormBlockGroup = /*#__PURE__*/React.memo(function Group(props) {
|
|
|
1948
2107
|
}, before, title && /*#__PURE__*/React.createElement("div", {
|
|
1949
2108
|
className: "form__group-title"
|
|
1950
2109
|
}, /*#__PURE__*/React.createElement(Title, {
|
|
2110
|
+
dataTestId: dataTestIdField + "Title",
|
|
1951
2111
|
size: titleTextSize,
|
|
1952
2112
|
textColor: titleTextColor,
|
|
1953
2113
|
textWeight: titleTextWeight
|
|
1954
2114
|
}, title)), label && /*#__PURE__*/React.createElement("div", {
|
|
1955
2115
|
className: "form__group-label"
|
|
1956
2116
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
2117
|
+
dataTestId: dataTestIdField + "Label",
|
|
1957
2118
|
size: labelTextSize,
|
|
1958
2119
|
textColor: labelTextColor,
|
|
1959
2120
|
textWeight: labelTextWeight
|
|
@@ -1962,11 +2123,13 @@ var FormBlockGroup = /*#__PURE__*/React.memo(function Group(props) {
|
|
|
1962
2123
|
}, children), after), showGroupMessage && /*#__PURE__*/React.createElement(React.Fragment, null, isErrorState && errorMessage && /*#__PURE__*/React.createElement(Text, {
|
|
1963
2124
|
id: name + "-error",
|
|
1964
2125
|
className: "form__group-message form__group-message_type-" + errorKey,
|
|
2126
|
+
dataTestId: dataTestIdField + "MessageError",
|
|
1965
2127
|
size: updatedProps.messageTextSize,
|
|
1966
2128
|
textColor: updatedProps.messageTextColor,
|
|
1967
2129
|
textWeight: updatedProps.messageTextWeight
|
|
1968
2130
|
}, errorMessage), Boolean(message) && (!isErrorState || !errorMessage) && /*#__PURE__*/React.createElement(Text, {
|
|
1969
2131
|
className: "form__group-message",
|
|
2132
|
+
dataTestId: name + "GroupMessage",
|
|
1970
2133
|
size: messageTextSize,
|
|
1971
2134
|
textColor: messageTextColor,
|
|
1972
2135
|
textWeight: messageTextWeight
|
|
@@ -1990,7 +2153,8 @@ var defaultInputProps = {
|
|
|
1990
2153
|
};
|
|
1991
2154
|
|
|
1992
2155
|
var FormFieldInput = /*#__PURE__*/React.memo(function FormFieldInput(props) {
|
|
1993
|
-
var
|
|
2156
|
+
var dataTestId = props.dataTestId,
|
|
2157
|
+
name = props.name,
|
|
1994
2158
|
initialValue = props.initialValue,
|
|
1995
2159
|
classNameGroupItem = props.classNameGroupItem,
|
|
1996
2160
|
clearIcon = props.clearIcon,
|
|
@@ -2042,8 +2206,10 @@ var FormFieldInput = /*#__PURE__*/React.memo(function FormFieldInput(props) {
|
|
|
2042
2206
|
inputProps: inputProps,
|
|
2043
2207
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2044
2208
|
});
|
|
2209
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2045
2210
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2046
2211
|
className: clsx('form-field_input', 'form__item_input', classNameGroupItem),
|
|
2212
|
+
dataTestId: dataTestIdField,
|
|
2047
2213
|
errorKey: errorKey,
|
|
2048
2214
|
errorMessage: errorMessage,
|
|
2049
2215
|
fieldClassName: "form-input",
|
|
@@ -2058,7 +2224,7 @@ var FormFieldInput = /*#__PURE__*/React.memo(function FormFieldInput(props) {
|
|
|
2058
2224
|
isValidState: isValidState
|
|
2059
2225
|
}, fieldProps), /*#__PURE__*/React.createElement(Input, Object.assign({
|
|
2060
2226
|
className: clsx(meta.active && 'input_state_focus', meta.error && meta.touched && "input_state_" + errorKey),
|
|
2061
|
-
dataTestId:
|
|
2227
|
+
dataTestId: dataTestIdField + "Input",
|
|
2062
2228
|
type: "text",
|
|
2063
2229
|
name: input.name,
|
|
2064
2230
|
autoComplete: "nope",
|
|
@@ -2069,6 +2235,7 @@ var FormFieldInput = /*#__PURE__*/React.memo(function FormFieldInput(props) {
|
|
|
2069
2235
|
onFocus: input.onFocus
|
|
2070
2236
|
}, updatedInputProps)), clearIcon && /*#__PURE__*/React.createElement(Icon, {
|
|
2071
2237
|
className: "form-field__icon",
|
|
2238
|
+
dataTestId: dataTestIdField + "InputIcon",
|
|
2072
2239
|
size: clearIconSize,
|
|
2073
2240
|
iconFill: clearIconFill,
|
|
2074
2241
|
iconFillHover: clearIconFillHover,
|
|
@@ -2086,7 +2253,8 @@ var defaultInputNumberProps = {
|
|
|
2086
2253
|
};
|
|
2087
2254
|
|
|
2088
2255
|
var FormFieldInputNumber = /*#__PURE__*/React.memo(function FormFieldInputNumber(props) {
|
|
2089
|
-
var
|
|
2256
|
+
var dataTestId = props.dataTestId,
|
|
2257
|
+
_props$type = props.type,
|
|
2090
2258
|
type = _props$type === void 0 ? 'custom' : _props$type,
|
|
2091
2259
|
name = props.name,
|
|
2092
2260
|
initialValue = props.initialValue,
|
|
@@ -2125,8 +2293,10 @@ var FormFieldInputNumber = /*#__PURE__*/React.memo(function FormFieldInputNumber
|
|
|
2125
2293
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
2126
2294
|
inputProps: inputProps
|
|
2127
2295
|
});
|
|
2296
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2128
2297
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2129
2298
|
className: clsx('form-field_input-number', 'form__item_input-number', classNameGroupItem),
|
|
2299
|
+
dataTestId: dataTestIdField,
|
|
2130
2300
|
errorKey: errorKey,
|
|
2131
2301
|
errorMessage: errorMessage,
|
|
2132
2302
|
fieldClassName: "form-input-number",
|
|
@@ -2141,7 +2311,7 @@ var FormFieldInputNumber = /*#__PURE__*/React.memo(function FormFieldInputNumber
|
|
|
2141
2311
|
isValidState: isValidState
|
|
2142
2312
|
}, fieldProps), /*#__PURE__*/React.createElement(InputNumber, Object.assign({
|
|
2143
2313
|
className: clsx(meta.active && 'input_state_focus', (meta.submitFailed || meta.touched) && meta.error && "input_state_" + errorKey),
|
|
2144
|
-
dataTestId:
|
|
2314
|
+
dataTestId: dataTestIdField + "InputNumber",
|
|
2145
2315
|
type: type,
|
|
2146
2316
|
name: input.name,
|
|
2147
2317
|
value: input.value || 0,
|
|
@@ -2151,7 +2321,8 @@ var FormFieldInputNumber = /*#__PURE__*/React.memo(function FormFieldInputNumber
|
|
|
2151
2321
|
});
|
|
2152
2322
|
|
|
2153
2323
|
var FormFieldMaskedInput = /*#__PURE__*/React.memo(function FormFieldMaskedInput(props) {
|
|
2154
|
-
var
|
|
2324
|
+
var dataTestId = props.dataTestId,
|
|
2325
|
+
name = props.name,
|
|
2155
2326
|
initialValue = props.initialValue,
|
|
2156
2327
|
classNameGroupItem = props.classNameGroupItem,
|
|
2157
2328
|
clearIcon = props.clearIcon,
|
|
@@ -2213,8 +2384,10 @@ var FormFieldMaskedInput = /*#__PURE__*/React.memo(function FormFieldMaskedInput
|
|
|
2213
2384
|
inputProps: inputProps,
|
|
2214
2385
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2215
2386
|
});
|
|
2387
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2216
2388
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2217
2389
|
className: clsx('form-field-masked-input', 'form__item_masked-input', classNameGroupItem),
|
|
2390
|
+
dataTestId: dataTestIdField,
|
|
2218
2391
|
errorKey: errorKey,
|
|
2219
2392
|
errorMessage: errorMessage,
|
|
2220
2393
|
fieldClassName: 'form-maskedInput',
|
|
@@ -2258,7 +2431,8 @@ var defaultPasswordProps = {
|
|
|
2258
2431
|
};
|
|
2259
2432
|
|
|
2260
2433
|
var FormFieldPassword = /*#__PURE__*/React.memo(function FormFieldPassword(props) {
|
|
2261
|
-
var
|
|
2434
|
+
var dataTestId = props.dataTestId,
|
|
2435
|
+
name = props.name,
|
|
2262
2436
|
initialValue = props.initialValue,
|
|
2263
2437
|
classNameGroupItem = props.classNameGroupItem,
|
|
2264
2438
|
fieldProps = props.fieldProps,
|
|
@@ -2302,8 +2476,10 @@ var FormFieldPassword = /*#__PURE__*/React.memo(function FormFieldPassword(props
|
|
|
2302
2476
|
inputProps: inputProps,
|
|
2303
2477
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2304
2478
|
});
|
|
2479
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2305
2480
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2306
2481
|
className: clsx('form-field_input-password', 'form__item_input-password', classNameGroupItem),
|
|
2482
|
+
dataTestId: dataTestIdField,
|
|
2307
2483
|
errorKey: errorKey,
|
|
2308
2484
|
errorMessage: errorMessage,
|
|
2309
2485
|
fieldClassName: "form-password",
|
|
@@ -2318,7 +2494,7 @@ var FormFieldPassword = /*#__PURE__*/React.memo(function FormFieldPassword(props
|
|
|
2318
2494
|
isValidState: isValidState
|
|
2319
2495
|
}, fieldProps), /*#__PURE__*/React.createElement(InputPassword, Object.assign({
|
|
2320
2496
|
className: clsx(meta.active && 'input-password_state_focus', meta.error && meta.touched && "input-password_state_" + errorKey),
|
|
2321
|
-
dataTestId:
|
|
2497
|
+
dataTestId: dataTestIdField + "InputPassword",
|
|
2322
2498
|
name: input.name,
|
|
2323
2499
|
autoComplete: "nope",
|
|
2324
2500
|
value: input.value || '',
|
|
@@ -2373,8 +2549,9 @@ function FormFieldRadioGroupList(props) {
|
|
|
2373
2549
|
}
|
|
2374
2550
|
|
|
2375
2551
|
var FormFieldRadioGroup = /*#__PURE__*/React.memo(function FormFieldRadioGroup(props) {
|
|
2376
|
-
var
|
|
2377
|
-
|
|
2552
|
+
var dataTestId = props.dataTestId,
|
|
2553
|
+
name = props.name,
|
|
2554
|
+
classNameGroupItem = props.classNameGroupItem,
|
|
2378
2555
|
_props$editableProps = props.editableProps,
|
|
2379
2556
|
editableProps = _props$editableProps === void 0 ? {} : _props$editableProps,
|
|
2380
2557
|
_props$fieldProps = props.fieldProps,
|
|
@@ -2383,8 +2560,8 @@ var FormFieldRadioGroup = /*#__PURE__*/React.memo(function FormFieldRadioGroup(p
|
|
|
2383
2560
|
inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
|
|
2384
2561
|
_props$options = props.options,
|
|
2385
2562
|
options = _props$options === void 0 ? [] : _props$options,
|
|
2386
|
-
classNameGroupItem = props.classNameGroupItem,
|
|
2387
2563
|
showMessage = props.showMessage,
|
|
2564
|
+
isDisabled = props.isDisabled,
|
|
2388
2565
|
isRequired = props.isRequired,
|
|
2389
2566
|
onChange = props.onChange;
|
|
2390
2567
|
return /*#__PURE__*/React.createElement(Field, {
|
|
@@ -2412,26 +2589,28 @@ var FormFieldRadioGroup = /*#__PURE__*/React.memo(function FormFieldRadioGroup(p
|
|
|
2412
2589
|
inputProps: inputProps,
|
|
2413
2590
|
validationStateKey: isErrorState ? errorKey : 'success'
|
|
2414
2591
|
});
|
|
2592
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2415
2593
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2416
2594
|
className: clsx('form-field_radio', 'form__item_radio', classNameGroupItem),
|
|
2595
|
+
dataTestId: dataTestIdField,
|
|
2417
2596
|
errorKey: errorKey,
|
|
2418
2597
|
errorMessage: errorMessage,
|
|
2419
|
-
isErrorState: isErrorState,
|
|
2420
|
-
metaError: meta.error,
|
|
2421
|
-
isDisabled: isDisabled,
|
|
2422
2598
|
fieldClassName: 'form-radio',
|
|
2423
2599
|
inputName: input.name,
|
|
2424
2600
|
inputValue: input.value || '',
|
|
2425
2601
|
metaActive: meta.active,
|
|
2602
|
+
metaError: meta.error,
|
|
2426
2603
|
showMessage: showMessage,
|
|
2604
|
+
isDisabled: isDisabled,
|
|
2605
|
+
isErrorState: isErrorState,
|
|
2427
2606
|
isRequired: isRequired,
|
|
2428
2607
|
isValidState: isValidState
|
|
2429
2608
|
}, fieldProps), /*#__PURE__*/React.createElement(FormFieldRadioGroupList, {
|
|
2430
|
-
isDisabled: isDisabled,
|
|
2431
2609
|
editableProps: editableProps,
|
|
2432
2610
|
input: input,
|
|
2433
2611
|
inputProps: updatedInputProps,
|
|
2434
2612
|
options: options,
|
|
2613
|
+
isDisabled: isDisabled,
|
|
2435
2614
|
onChange: onChange
|
|
2436
2615
|
}));
|
|
2437
2616
|
});
|
|
@@ -2448,12 +2627,13 @@ var defaultSegmentedProps = {
|
|
|
2448
2627
|
};
|
|
2449
2628
|
|
|
2450
2629
|
function FormFieldSegmented(props) {
|
|
2451
|
-
var
|
|
2452
|
-
|
|
2630
|
+
var dataTestId = props.dataTestId,
|
|
2631
|
+
name = props.name,
|
|
2453
2632
|
fieldProps = props.fieldProps,
|
|
2454
2633
|
inputProps = props.inputProps,
|
|
2455
2634
|
options = props.options,
|
|
2456
2635
|
showMessage = props.showMessage,
|
|
2636
|
+
isDisabled = props.isDisabled,
|
|
2457
2637
|
isRequired = props.isRequired;
|
|
2458
2638
|
var _useForm = useForm(),
|
|
2459
2639
|
change = _useForm.change;
|
|
@@ -2492,31 +2672,33 @@ function FormFieldSegmented(props) {
|
|
|
2492
2672
|
}),
|
|
2493
2673
|
errorKey = _useFieldValidationSt.errorKey,
|
|
2494
2674
|
errorMessage = _useFieldValidationSt.errorMessage,
|
|
2495
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
2496
2675
|
successKey = _useFieldValidationSt.successKey,
|
|
2676
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
2497
2677
|
isValidState = _useFieldValidationSt.isValidState;
|
|
2498
2678
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
2499
2679
|
inputProps: inputProps,
|
|
2500
2680
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2501
2681
|
});
|
|
2682
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2502
2683
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2503
2684
|
className: clsx('form-field_segmented', 'form__item_segmented'),
|
|
2685
|
+
dataTestId: dataTestIdField,
|
|
2504
2686
|
errorKey: errorKey,
|
|
2505
2687
|
errorMessage: errorMessage,
|
|
2506
|
-
isErrorState: isErrorState,
|
|
2507
|
-
metaError: meta.error,
|
|
2508
|
-
isDisabled: isDisabled,
|
|
2509
2688
|
fieldClassName: "form-segmented",
|
|
2510
2689
|
inputName: input.name,
|
|
2511
2690
|
inputValue: input.value || [],
|
|
2512
2691
|
metaActive: meta.active,
|
|
2692
|
+
metaError: meta.error,
|
|
2513
2693
|
showMessage: showMessage,
|
|
2694
|
+
isDisabled: isDisabled,
|
|
2695
|
+
isErrorState: isErrorState,
|
|
2514
2696
|
isRequired: isRequired,
|
|
2515
2697
|
isValidState: isValidState
|
|
2516
2698
|
}, fieldProps), /*#__PURE__*/React.createElement(Segmented, Object.assign({
|
|
2517
|
-
isDisabled: isDisabled,
|
|
2518
2699
|
activeSegment: activeOption,
|
|
2519
2700
|
segments: options,
|
|
2701
|
+
isDisabled: isDisabled,
|
|
2520
2702
|
setActiveSegment: setActiveSegment
|
|
2521
2703
|
}, updatedInputProps)));
|
|
2522
2704
|
});
|
|
@@ -2552,17 +2734,18 @@ function getDefaultValue(options, selectValue) {
|
|
|
2552
2734
|
return result;
|
|
2553
2735
|
}
|
|
2554
2736
|
var FormFieldSelect = /*#__PURE__*/React.memo(function FormFieldSelect(props) {
|
|
2555
|
-
var
|
|
2556
|
-
|
|
2737
|
+
var dataTestId = props.dataTestId,
|
|
2738
|
+
name = props.name,
|
|
2739
|
+
initialValue = props.initialValue,
|
|
2557
2740
|
classNameGroupItem = props.classNameGroupItem,
|
|
2558
2741
|
fieldProps = props.fieldProps,
|
|
2559
|
-
initialValue = props.initialValue,
|
|
2560
|
-
name = props.name,
|
|
2561
2742
|
_props$options = props.options,
|
|
2562
2743
|
options = _props$options === void 0 ? [] : _props$options,
|
|
2563
2744
|
selectProps = props.selectProps,
|
|
2564
2745
|
selectRef = props.selectRef,
|
|
2565
2746
|
showMessage = props.showMessage,
|
|
2747
|
+
isDisabled = props.isDisabled,
|
|
2748
|
+
isRequired = props.isRequired,
|
|
2566
2749
|
onChange = props.onChange,
|
|
2567
2750
|
onInputChange = props.onInputChange;
|
|
2568
2751
|
return /*#__PURE__*/React.createElement(Field, {
|
|
@@ -2614,34 +2797,36 @@ var FormFieldSelect = /*#__PURE__*/React.memo(function FormFieldSelect(props) {
|
|
|
2614
2797
|
}),
|
|
2615
2798
|
errorKey = _useFieldValidationSt.errorKey,
|
|
2616
2799
|
errorMessage = _useFieldValidationSt.errorMessage,
|
|
2617
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
2618
2800
|
successKey = _useFieldValidationSt.successKey,
|
|
2801
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
2619
2802
|
isValidState = _useFieldValidationSt.isValidState;
|
|
2620
2803
|
var updatedSelectProps = useValidationAppearanceInputProps({
|
|
2621
2804
|
inputProps: selectProps,
|
|
2622
2805
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2623
2806
|
});
|
|
2807
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2624
2808
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2625
2809
|
className: clsx('form-field_select', 'form__item_select', classNameGroupItem),
|
|
2810
|
+
dataTestId: dataTestIdField,
|
|
2626
2811
|
errorKey: errorKey,
|
|
2627
2812
|
errorMessage: errorMessage,
|
|
2628
|
-
isErrorState: isErrorState,
|
|
2629
|
-
metaError: meta.error,
|
|
2630
|
-
isDisabled: isDisabled,
|
|
2631
2813
|
fieldClassName: 'form-select',
|
|
2632
2814
|
inputName: input.name,
|
|
2633
2815
|
inputValue: input.value,
|
|
2634
2816
|
metaActive: meta.active,
|
|
2817
|
+
metaError: meta.error,
|
|
2635
2818
|
showMessage: showMessage,
|
|
2819
|
+
isDisabled: isDisabled,
|
|
2820
|
+
isErrorState: isErrorState,
|
|
2636
2821
|
isRequired: isRequired,
|
|
2637
2822
|
isValidState: isValidState
|
|
2638
2823
|
}, fieldProps), /*#__PURE__*/React.createElement(Select, Object.assign({
|
|
2639
2824
|
className: "form-select-item",
|
|
2640
2825
|
ref: selectRef,
|
|
2641
|
-
isDisabled: isDisabled,
|
|
2642
2826
|
instanceId: "id_" + input.name,
|
|
2643
2827
|
options: options,
|
|
2644
2828
|
value: selectedOptions,
|
|
2829
|
+
isDisabled: isDisabled,
|
|
2645
2830
|
onChange: onChangeValue,
|
|
2646
2831
|
onInputChange: onInputChange
|
|
2647
2832
|
}, updatedSelectProps)));
|
|
@@ -2656,14 +2841,15 @@ var defaultSwitchProps = {
|
|
|
2656
2841
|
};
|
|
2657
2842
|
|
|
2658
2843
|
var FormFieldSwitch = /*#__PURE__*/React.memo(function FormFieldSwitch(props) {
|
|
2659
|
-
var
|
|
2660
|
-
|
|
2844
|
+
var dataTestId = props.dataTestId,
|
|
2845
|
+
name = props.name,
|
|
2661
2846
|
classNameGroupItem = props.classNameGroupItem,
|
|
2662
2847
|
_props$fieldProps = props.fieldProps,
|
|
2663
2848
|
fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
|
|
2664
2849
|
_props$inputProps = props.inputProps,
|
|
2665
2850
|
inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
|
|
2666
2851
|
showMessage = props.showMessage,
|
|
2852
|
+
isDisabled = props.isDisabled,
|
|
2667
2853
|
isRequired = props.isRequired,
|
|
2668
2854
|
onChange = props.onChange;
|
|
2669
2855
|
return /*#__PURE__*/React.createElement(Field, {
|
|
@@ -2692,34 +2878,36 @@ var FormFieldSwitch = /*#__PURE__*/React.memo(function FormFieldSwitch(props) {
|
|
|
2692
2878
|
}),
|
|
2693
2879
|
errorKey = _useFieldValidationSt.errorKey,
|
|
2694
2880
|
errorMessage = _useFieldValidationSt.errorMessage,
|
|
2695
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
2696
2881
|
successKey = _useFieldValidationSt.successKey,
|
|
2882
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
2697
2883
|
isValidState = _useFieldValidationSt.isValidState;
|
|
2698
2884
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
2699
2885
|
inputProps: inputProps,
|
|
2700
2886
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2701
2887
|
});
|
|
2888
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2702
2889
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2703
2890
|
className: clsx('form-field-switch', 'form__item_switch', classNameGroupItem),
|
|
2891
|
+
dataTestId: dataTestIdField,
|
|
2704
2892
|
errorKey: errorKey,
|
|
2705
2893
|
errorMessage: errorMessage,
|
|
2706
|
-
isErrorState: isErrorState,
|
|
2707
|
-
metaError: meta.error,
|
|
2708
|
-
isDisabled: isDisabled,
|
|
2709
2894
|
fieldClassName: "form-switch",
|
|
2710
2895
|
inputName: input.name,
|
|
2711
2896
|
inputValue: input.checked,
|
|
2712
2897
|
metaActive: meta.active,
|
|
2898
|
+
metaError: meta.error,
|
|
2713
2899
|
showMessage: showMessage,
|
|
2714
2900
|
tag: "label",
|
|
2901
|
+
isDisabled: isDisabled,
|
|
2902
|
+
isErrorState: isErrorState,
|
|
2715
2903
|
isRequired: isRequired,
|
|
2716
2904
|
isValidState: isValidState
|
|
2717
2905
|
}, fieldProps), /*#__PURE__*/React.createElement(Switch, Object.assign({
|
|
2718
2906
|
type: "checkbox",
|
|
2719
2907
|
name: input.name,
|
|
2720
|
-
isDisabled: isDisabled,
|
|
2721
2908
|
autoComplete: "nope",
|
|
2722
2909
|
isActive: input.checked,
|
|
2910
|
+
isDisabled: isDisabled,
|
|
2723
2911
|
onBlur: input.onBlur,
|
|
2724
2912
|
onChange: onChangeField,
|
|
2725
2913
|
onFocus: input.onFocus
|
|
@@ -2739,7 +2927,8 @@ var defaultTextareaProps = {
|
|
|
2739
2927
|
};
|
|
2740
2928
|
|
|
2741
2929
|
var FormFieldTextarea = /*#__PURE__*/React.memo(function FormFieldTextarea(props) {
|
|
2742
|
-
var
|
|
2930
|
+
var dataTestId = props.dataTestId,
|
|
2931
|
+
name = props.name,
|
|
2743
2932
|
classNameGroupItem = props.classNameGroupItem,
|
|
2744
2933
|
_props$fieldProps = props.fieldProps,
|
|
2745
2934
|
fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
|
|
@@ -2774,8 +2963,10 @@ var FormFieldTextarea = /*#__PURE__*/React.memo(function FormFieldTextarea(props
|
|
|
2774
2963
|
inputProps: inputProps,
|
|
2775
2964
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2776
2965
|
});
|
|
2966
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2777
2967
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2778
2968
|
className: clsx('form-field_textarea', 'form__item_textarea', classNameGroupItem),
|
|
2969
|
+
dataTestId: dataTestIdField,
|
|
2779
2970
|
errorKey: errorKey,
|
|
2780
2971
|
errorMessage: errorMessage,
|
|
2781
2972
|
fieldClassName: 'form-textarea',
|
|
@@ -2790,7 +2981,7 @@ var FormFieldTextarea = /*#__PURE__*/React.memo(function FormFieldTextarea(props
|
|
|
2790
2981
|
isValidState: isValidState
|
|
2791
2982
|
}, fieldProps), /*#__PURE__*/React.createElement(Textarea, Object.assign({
|
|
2792
2983
|
className: clsx(meta.active && 'textarea_state_focus', meta.error && meta.touched && "textarea_state_" + errorKey),
|
|
2793
|
-
dataTestId:
|
|
2984
|
+
dataTestId: dataTestIdField + "Textarea",
|
|
2794
2985
|
name: input.name,
|
|
2795
2986
|
autoComplete: "nope",
|
|
2796
2987
|
value: input.value || '',
|
|
@@ -2823,115 +3014,151 @@ var formTypes = {
|
|
|
2823
3014
|
select: 'select',
|
|
2824
3015
|
"switch": 'switch'
|
|
2825
3016
|
};
|
|
2826
|
-
function generateField(field, config,
|
|
3017
|
+
function generateField(field, config, dataTestId) {
|
|
2827
3018
|
switch (field.type) {
|
|
2828
3019
|
case formTypes.password:
|
|
2829
3020
|
{
|
|
2830
3021
|
return /*#__PURE__*/React.createElement(FormFieldPassword, Object.assign({
|
|
2831
3022
|
key: config.key
|
|
2832
|
-
}, field,
|
|
3023
|
+
}, field, {
|
|
3024
|
+
dataTestId: dataTestId
|
|
3025
|
+
}));
|
|
2833
3026
|
}
|
|
2834
3027
|
case formTypes.checkbox:
|
|
2835
3028
|
{
|
|
2836
3029
|
return /*#__PURE__*/React.createElement(FormFieldCheckbox, Object.assign({
|
|
2837
3030
|
key: config.key
|
|
2838
|
-
}, field,
|
|
3031
|
+
}, field, {
|
|
3032
|
+
dataTestId: dataTestId
|
|
3033
|
+
}));
|
|
2839
3034
|
}
|
|
2840
3035
|
case formTypes.choice:
|
|
2841
3036
|
{
|
|
2842
3037
|
return /*#__PURE__*/React.createElement(FormFieldChoice, Object.assign({
|
|
2843
3038
|
key: config.key
|
|
2844
|
-
}, field,
|
|
3039
|
+
}, field, {
|
|
3040
|
+
dataTestId: dataTestId
|
|
3041
|
+
}));
|
|
2845
3042
|
}
|
|
2846
3043
|
case formTypes.code:
|
|
2847
3044
|
{
|
|
2848
3045
|
return /*#__PURE__*/React.createElement(FormFieldCode, Object.assign({
|
|
2849
3046
|
key: config.key
|
|
2850
|
-
}, field,
|
|
3047
|
+
}, field, {
|
|
3048
|
+
dataTestId: dataTestId
|
|
3049
|
+
}));
|
|
2851
3050
|
}
|
|
2852
3051
|
case formTypes.chips:
|
|
2853
3052
|
{
|
|
2854
3053
|
return /*#__PURE__*/React.createElement(FormFieldChips, Object.assign({
|
|
2855
3054
|
key: config.key
|
|
2856
|
-
}, field,
|
|
3055
|
+
}, field, {
|
|
3056
|
+
dataTestId: dataTestId
|
|
3057
|
+
}));
|
|
2857
3058
|
}
|
|
2858
3059
|
case formTypes["switch"]:
|
|
2859
3060
|
{
|
|
2860
3061
|
return /*#__PURE__*/React.createElement(FormFieldSwitch, Object.assign({
|
|
2861
3062
|
key: config.key
|
|
2862
|
-
}, field,
|
|
3063
|
+
}, field, {
|
|
3064
|
+
dataTestId: dataTestId
|
|
3065
|
+
}));
|
|
2863
3066
|
}
|
|
2864
3067
|
case formTypes.segmented:
|
|
2865
3068
|
{
|
|
2866
3069
|
return /*#__PURE__*/React.createElement(FormFieldSegmented, Object.assign({
|
|
2867
3070
|
key: config.key
|
|
2868
|
-
}, field,
|
|
3071
|
+
}, field, {
|
|
3072
|
+
dataTestId: dataTestId
|
|
3073
|
+
}));
|
|
2869
3074
|
}
|
|
2870
3075
|
case formTypes.datePicker:
|
|
2871
3076
|
{
|
|
2872
3077
|
return /*#__PURE__*/React.createElement(FormFieldDatePicker, Object.assign({
|
|
2873
3078
|
key: config.key
|
|
2874
|
-
}, field,
|
|
3079
|
+
}, field, {
|
|
3080
|
+
dataTestId: dataTestId
|
|
3081
|
+
}));
|
|
2875
3082
|
}
|
|
2876
3083
|
case formTypes.fileInput:
|
|
2877
3084
|
{
|
|
2878
3085
|
return /*#__PURE__*/React.createElement(FormFieldFileInput, Object.assign({
|
|
2879
3086
|
key: config.key
|
|
2880
|
-
}, field,
|
|
3087
|
+
}, field, {
|
|
3088
|
+
dataTestId: dataTestId
|
|
3089
|
+
}));
|
|
2881
3090
|
}
|
|
2882
3091
|
case formTypes.radioGroup:
|
|
2883
3092
|
{
|
|
2884
3093
|
return /*#__PURE__*/React.createElement(FormFieldRadioGroup, Object.assign({
|
|
2885
3094
|
key: config.key
|
|
2886
|
-
}, field,
|
|
3095
|
+
}, field, {
|
|
3096
|
+
dataTestId: dataTestId
|
|
3097
|
+
}));
|
|
2887
3098
|
}
|
|
2888
3099
|
case formTypes.select:
|
|
2889
3100
|
{
|
|
2890
3101
|
return /*#__PURE__*/React.createElement(FormFieldSelect, Object.assign({
|
|
2891
3102
|
key: config.key
|
|
2892
|
-
}, field,
|
|
3103
|
+
}, field, {
|
|
3104
|
+
dataTestId: dataTestId
|
|
3105
|
+
}));
|
|
2893
3106
|
}
|
|
2894
3107
|
case formTypes.text:
|
|
2895
3108
|
{
|
|
2896
3109
|
return /*#__PURE__*/React.createElement(FormFieldInput, Object.assign({
|
|
2897
3110
|
key: config.key
|
|
2898
|
-
}, field,
|
|
3111
|
+
}, field, {
|
|
3112
|
+
dataTestId: dataTestId
|
|
3113
|
+
}));
|
|
2899
3114
|
}
|
|
2900
3115
|
case formTypes.textarea:
|
|
2901
3116
|
{
|
|
2902
3117
|
return /*#__PURE__*/React.createElement(FormFieldTextarea, Object.assign({
|
|
2903
3118
|
key: config.key
|
|
2904
|
-
}, field,
|
|
3119
|
+
}, field, {
|
|
3120
|
+
dataTestId: dataTestId
|
|
3121
|
+
}));
|
|
2905
3122
|
}
|
|
2906
3123
|
case formTypes.maskedInput:
|
|
2907
3124
|
{
|
|
2908
3125
|
return /*#__PURE__*/React.createElement(FormFieldMaskedInput, Object.assign({
|
|
2909
3126
|
key: config.key
|
|
2910
|
-
}, field,
|
|
3127
|
+
}, field, {
|
|
3128
|
+
dataTestId: dataTestId
|
|
3129
|
+
}));
|
|
2911
3130
|
}
|
|
2912
3131
|
case formTypes.custom:
|
|
2913
3132
|
{
|
|
2914
3133
|
return /*#__PURE__*/React.createElement(FormFieldCustom, Object.assign({
|
|
2915
3134
|
key: config.key
|
|
2916
|
-
}, field,
|
|
3135
|
+
}, field, {
|
|
3136
|
+
dataTestId: dataTestId
|
|
3137
|
+
}));
|
|
2917
3138
|
}
|
|
2918
3139
|
case formTypes.dadataInput:
|
|
2919
3140
|
{
|
|
2920
3141
|
return /*#__PURE__*/React.createElement(FormFieldDadataInput, Object.assign({
|
|
2921
3142
|
key: config.key
|
|
2922
|
-
}, field,
|
|
3143
|
+
}, field, {
|
|
3144
|
+
dataTestId: dataTestId
|
|
3145
|
+
}));
|
|
2923
3146
|
}
|
|
2924
3147
|
case formTypes.inputNumber:
|
|
2925
3148
|
{
|
|
2926
3149
|
return /*#__PURE__*/React.createElement(FormFieldInputNumber, Object.assign({
|
|
2927
3150
|
key: config.key
|
|
2928
|
-
}, field,
|
|
3151
|
+
}, field, {
|
|
3152
|
+
dataTestId: dataTestId
|
|
3153
|
+
}));
|
|
2929
3154
|
}
|
|
2930
3155
|
case formTypes.group:
|
|
2931
3156
|
{
|
|
2932
3157
|
return /*#__PURE__*/React.createElement(FormBlockGroup, Object.assign({
|
|
2933
3158
|
key: config.key
|
|
2934
|
-
}, field,
|
|
3159
|
+
}, field, {
|
|
3160
|
+
dataTestId: dataTestId
|
|
3161
|
+
}), Object.entries(field.group).map(function (_ref) {
|
|
2935
3162
|
var key = _ref[0],
|
|
2936
3163
|
value = _ref[1];
|
|
2937
3164
|
var groupProps = Object.assign({}, value, {
|
|
@@ -2940,147 +3167,17 @@ function generateField(field, config, props) {
|
|
|
2940
3167
|
});
|
|
2941
3168
|
return generateField(groupProps, {
|
|
2942
3169
|
key: key + '_form_group'
|
|
2943
|
-
},
|
|
3170
|
+
}, dataTestId);
|
|
2944
3171
|
}));
|
|
2945
3172
|
}
|
|
2946
3173
|
}
|
|
2947
3174
|
}
|
|
2948
3175
|
|
|
2949
|
-
var focusOnError = function focusOnError(formElementsList, errors) {
|
|
2950
|
-
var selectsIds = Object.keys(errors).map(function (fieldName) {
|
|
2951
|
-
if (fieldName === FORM_ERROR) {
|
|
2952
|
-
// TODO: get from somewhere
|
|
2953
|
-
return 'notification__item_status_error';
|
|
2954
|
-
}
|
|
2955
|
-
return "react-select-id_" + fieldName + "-input";
|
|
2956
|
-
});
|
|
2957
|
-
var errorFieldElement = formElementsList.find(function (element) {
|
|
2958
|
-
if (element.name) {
|
|
2959
|
-
return getIn(errors, element.name);
|
|
2960
|
-
} else {
|
|
2961
|
-
return selectsIds.includes(element.id);
|
|
2962
|
-
}
|
|
2963
|
-
});
|
|
2964
|
-
var errorsList = Object.keys(errors);
|
|
2965
|
-
if (!errorFieldElement && errorsList.length) {
|
|
2966
|
-
var errorElement;
|
|
2967
|
-
try {
|
|
2968
|
-
var fieldName = errorsList[0];
|
|
2969
|
-
if (fieldName === FORM_ERROR) {
|
|
2970
|
-
errorElement = document.querySelector('notification__item_status_error');
|
|
2971
|
-
} else {
|
|
2972
|
-
errorElement = document.querySelector("#" + fieldName + "-error");
|
|
2973
|
-
if (!errorElement) {
|
|
2974
|
-
errorElement = document.querySelector("#id_" + fieldName);
|
|
2975
|
-
}
|
|
2976
|
-
}
|
|
2977
|
-
} catch (err) {
|
|
2978
|
-
console.warn(err);
|
|
2979
|
-
}
|
|
2980
|
-
if (errorElement) {
|
|
2981
|
-
errorElement.scrollIntoView({
|
|
2982
|
-
block: 'center'
|
|
2983
|
-
}); // , behavior: 'smooth'
|
|
2984
|
-
}
|
|
2985
|
-
}
|
|
2986
|
-
|
|
2987
|
-
// The field is covered by the header because header is "sticky",
|
|
2988
|
-
// that's we scroll manually so that the field falls into the center of the visible area
|
|
2989
|
-
if (errorFieldElement) {
|
|
2990
|
-
errorFieldElement.scrollIntoView({
|
|
2991
|
-
block: 'center'
|
|
2992
|
-
});
|
|
2993
|
-
}
|
|
2994
|
-
return null;
|
|
2995
|
-
};
|
|
2996
|
-
var focusOnErrorDecorator = createDecorator(null, focusOnError);
|
|
2997
|
-
var setErrorsMutator = function setErrorsMutator(args, state) {
|
|
2998
|
-
var fieldName = args[0],
|
|
2999
|
-
data = args[1];
|
|
3000
|
-
var submitError = data.submitError;
|
|
3001
|
-
var fieldError = data.error;
|
|
3002
|
-
if (fieldName === 'non_field_errors' || fieldName === FORM_ERROR) {
|
|
3003
|
-
// state.formState.invalid = true
|
|
3004
|
-
// state.formState.valid = false
|
|
3005
|
-
state.formState.error = fieldError;
|
|
3006
|
-
state.formState.submitError = submitError;
|
|
3007
|
-
} else if (fieldName in state.fields) {
|
|
3008
|
-
state.fields[fieldName].touched = true;
|
|
3009
|
-
|
|
3010
|
-
// TODO: make clear error not by empty string check
|
|
3011
|
-
if (fieldError || fieldError === '') {
|
|
3012
|
-
var _Object$assign;
|
|
3013
|
-
var errorsState = Object.assign({}, state.formState.errors, (_Object$assign = {}, _Object$assign[fieldName] = fieldError, _Object$assign));
|
|
3014
|
-
state.fields[fieldName].error = fieldError;
|
|
3015
|
-
state.formState.errors = errorsState;
|
|
3016
|
-
}
|
|
3017
|
-
|
|
3018
|
-
// TODO: make clear error not by empty string check
|
|
3019
|
-
if (submitError || submitError === '') {
|
|
3020
|
-
var _Object$assign2;
|
|
3021
|
-
var submitErrorsState = Object.assign({}, state.formState.submitErrors, (_Object$assign2 = {}, _Object$assign2[fieldName] = submitError, _Object$assign2));
|
|
3022
|
-
state.fields[fieldName].submitFailed = true;
|
|
3023
|
-
state.fields[fieldName].submitSucceeded = false;
|
|
3024
|
-
state.fields[fieldName].submitError = submitError;
|
|
3025
|
-
state.formState.submitErrors = submitErrorsState;
|
|
3026
|
-
state.formState.submitFailed = true;
|
|
3027
|
-
state.formState.submitSucceeded = false;
|
|
3028
|
-
state.formState.lastSubmittedValues = state.formState.values;
|
|
3029
|
-
}
|
|
3030
|
-
}
|
|
3031
|
-
};
|
|
3032
|
-
var sendFormDataToServer = /*#__PURE__*/function () {
|
|
3033
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(url, data) {
|
|
3034
|
-
var response, _error$response, _error$response2, formErrors, _t;
|
|
3035
|
-
return _regenerator().w(function (_context) {
|
|
3036
|
-
while (1) switch (_context.p = _context.n) {
|
|
3037
|
-
case 0:
|
|
3038
|
-
_context.p = 0;
|
|
3039
|
-
_context.n = 1;
|
|
3040
|
-
return axios({
|
|
3041
|
-
url: url,
|
|
3042
|
-
method: 'POST',
|
|
3043
|
-
data: data
|
|
3044
|
-
});
|
|
3045
|
-
case 1:
|
|
3046
|
-
response = _context.v;
|
|
3047
|
-
return _context.a(2, {
|
|
3048
|
-
success: true,
|
|
3049
|
-
response: response
|
|
3050
|
-
});
|
|
3051
|
-
case 2:
|
|
3052
|
-
_context.p = 2;
|
|
3053
|
-
_t = _context.v;
|
|
3054
|
-
formErrors = {};
|
|
3055
|
-
if (typeof ((_error$response = _t.response) == null ? void 0 : _error$response.data) === 'string') {
|
|
3056
|
-
formErrors[FORM_ERROR] = 'Something went wrong';
|
|
3057
|
-
}
|
|
3058
|
-
if (typeof ((_error$response2 = _t.response) == null ? void 0 : _error$response2.data) === 'object') {
|
|
3059
|
-
Object.entries(_t.response.data).forEach(function (_ref2) {
|
|
3060
|
-
var fieldName = _ref2[0],
|
|
3061
|
-
errorsList = _ref2[1];
|
|
3062
|
-
formErrors[fieldName] = errorsList[0];
|
|
3063
|
-
});
|
|
3064
|
-
}
|
|
3065
|
-
return _context.a(2, {
|
|
3066
|
-
error: _t,
|
|
3067
|
-
success: false,
|
|
3068
|
-
formErrors: formErrors
|
|
3069
|
-
});
|
|
3070
|
-
}
|
|
3071
|
-
}, _callee, null, [[0, 2]]);
|
|
3072
|
-
}));
|
|
3073
|
-
return function sendFormDataToServer(_x, _x2) {
|
|
3074
|
-
return _ref.apply(this, arguments);
|
|
3075
|
-
};
|
|
3076
|
-
}();
|
|
3077
|
-
|
|
3078
3176
|
var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
3079
3177
|
var className = props.className,
|
|
3080
3178
|
dataTestId = props.dataTestId,
|
|
3081
3179
|
dataTour = props.dataTour,
|
|
3082
3180
|
type = props.type,
|
|
3083
|
-
name = props.name,
|
|
3084
3181
|
initialValues = props.initialValues,
|
|
3085
3182
|
initialValuesEqual = props.initialValuesEqual,
|
|
3086
3183
|
config = props.config,
|
|
@@ -3095,10 +3192,9 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3095
3192
|
descSize = props.descSize,
|
|
3096
3193
|
descTextColor = props.descTextColor,
|
|
3097
3194
|
descTextWeight = props.descTextWeight,
|
|
3098
|
-
buttonGap = props.buttonGap
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
_props$buttonDirectio = props.buttonDirection,
|
|
3195
|
+
buttonGap = props.buttonGap;
|
|
3196
|
+
props.additionalProps;
|
|
3197
|
+
var _props$buttonDirectio = props.buttonDirection,
|
|
3102
3198
|
buttonDirection = _props$buttonDirectio === void 0 ? 'vertical' : _props$buttonDirectio,
|
|
3103
3199
|
buttonFill = props.buttonFill,
|
|
3104
3200
|
buttonJustifyContent = props.buttonJustifyContent,
|
|
@@ -3115,7 +3211,6 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3115
3211
|
_props$disableFieldsA = props.disableFieldsAutoComplete,
|
|
3116
3212
|
disableFieldsAutoComplete = _props$disableFieldsA === void 0 ? false : _props$disableFieldsA,
|
|
3117
3213
|
fieldsGap = props.fieldsGap,
|
|
3118
|
-
formName = props.formName,
|
|
3119
3214
|
groupGap = props.groupGap,
|
|
3120
3215
|
heightClass = props.heightClass,
|
|
3121
3216
|
language = props.language,
|
|
@@ -3130,7 +3225,7 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3130
3225
|
loaderSize = _props$loaderSize === void 0 ? 'l' : _props$loaderSize,
|
|
3131
3226
|
loaderText = props.loaderText,
|
|
3132
3227
|
_props$loaderType = props.loaderType,
|
|
3133
|
-
loaderType = _props$loaderType === void 0 ? '
|
|
3228
|
+
loaderType = _props$loaderType === void 0 ? 'dot' : _props$loaderType,
|
|
3134
3229
|
mutators = props.mutators,
|
|
3135
3230
|
notificationCloseButton = props.notificationCloseButton,
|
|
3136
3231
|
notificationType = props.notificationType,
|
|
@@ -3164,6 +3259,7 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3164
3259
|
secondaryButtonSize = props.secondaryButtonSize,
|
|
3165
3260
|
shapeStrengthClass = props.shapeStrengthClass,
|
|
3166
3261
|
tertiaryButton = props.tertiaryButton,
|
|
3262
|
+
tertiaryButtonAppearance = props.tertiaryButtonAppearance,
|
|
3167
3263
|
tertiaryButtonFill = props.tertiaryButtonFill,
|
|
3168
3264
|
tertiaryButtonFillHover = props.tertiaryButtonFillHover,
|
|
3169
3265
|
tertiaryButtonLabel = props.tertiaryButtonLabel,
|
|
@@ -3202,8 +3298,7 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3202
3298
|
modifiedSinceLastSubmit = _ref.modifiedSinceLastSubmit,
|
|
3203
3299
|
submitError = _ref.submitError;
|
|
3204
3300
|
return /*#__PURE__*/React.createElement("form", {
|
|
3205
|
-
className: clsx(className, 'form', type && "form_type_" + type, widthClass && "width_" + widthClass, heightClass && "height_" + heightClass, titlePosition && "form_title-position_" + titlePosition, buttonPosition && "form_button-position_" + buttonPosition, directionClass && "direction_" + directionClass, fillClass && "fill_" + fillClass, shapeClass && "shape_" + shapeClass, shapeStrengthClass && "shape-strength_" + shapeStrengthClass, elevationClass && "elevation_" + elevationClass)
|
|
3206
|
-
name: formName || 'form'
|
|
3301
|
+
className: clsx(className, 'form', type && "form_type_" + type, widthClass && "width_" + widthClass, heightClass && "height_" + heightClass, titlePosition && "form_title-position_" + titlePosition, buttonPosition && "form_button-position_" + buttonPosition, directionClass && "direction_" + directionClass, fillClass && "fill_" + fillClass, shapeClass && "shape_" + shapeClass, shapeStrengthClass && "shape-strength_" + shapeStrengthClass, elevationClass && "elevation_" + elevationClass)
|
|
3207
3302
|
// We no need set reference to html element, we need reference to "final-form" instance
|
|
3208
3303
|
,
|
|
3209
3304
|
ref: function ref() {
|
|
@@ -3212,7 +3307,7 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3212
3307
|
autoCapitalize: disableFieldsAutoComplete ? 'off' : undefined,
|
|
3213
3308
|
autoComplete: disableFieldsAutoComplete ? 'off' : undefined,
|
|
3214
3309
|
autoCorrect: disableFieldsAutoComplete ? 'off' : undefined,
|
|
3215
|
-
"data-testid": dataTestId ||
|
|
3310
|
+
"data-testid": dataTestId || 'Form',
|
|
3216
3311
|
"data-tour": dataTour,
|
|
3217
3312
|
spellCheck: disableFieldsAutoComplete ? 'false' : undefined,
|
|
3218
3313
|
style: formStyles,
|
|
@@ -3222,12 +3317,14 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3222
3317
|
size: titleTextSize,
|
|
3223
3318
|
fill: titleFill,
|
|
3224
3319
|
textColor: titleTextColor,
|
|
3225
|
-
textWeight: titleTextWeight
|
|
3320
|
+
textWeight: titleTextWeight,
|
|
3321
|
+
"data-testid": dataTestId ? dataTestId + "Title" : 'FormTitle'
|
|
3226
3322
|
}, title), desc && /*#__PURE__*/React.createElement(Text, {
|
|
3227
3323
|
className: "form__desc",
|
|
3228
3324
|
size: descSize,
|
|
3229
3325
|
textColor: descTextColor,
|
|
3230
|
-
textWeight: descTextWeight
|
|
3326
|
+
textWeight: descTextWeight,
|
|
3327
|
+
"data-testid": dataTestId ? dataTestId + "Desc" : 'FormDesc'
|
|
3231
3328
|
}, desc), submitError && !modifiedSinceLastSubmit && /*#__PURE__*/React.createElement("div", {
|
|
3232
3329
|
className: clsx('notification', 'form-notification', notificationType ? "form-notification_" + notificationType : 'form-notification_global')
|
|
3233
3330
|
}, /*#__PURE__*/React.createElement(Notification, {
|
|
@@ -3249,7 +3346,7 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3249
3346
|
}, Object.keys(config).map(function (key) {
|
|
3250
3347
|
return generateField(config[key], {
|
|
3251
3348
|
key: key
|
|
3252
|
-
},
|
|
3349
|
+
}, dataTestId);
|
|
3253
3350
|
}), isLoading && (loader || /*#__PURE__*/React.createElement(Loader, {
|
|
3254
3351
|
appearance: loaderAppearance,
|
|
3255
3352
|
className: "form__loader",
|
|
@@ -3257,11 +3354,12 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3257
3354
|
size: loaderSize,
|
|
3258
3355
|
fill: loaderFill,
|
|
3259
3356
|
text: loaderText,
|
|
3357
|
+
"data-testid": dataTestId + "Loader",
|
|
3260
3358
|
itemFill: loaderItemFill,
|
|
3261
3359
|
shape: loaderShape
|
|
3262
3360
|
}))))), (primaryButtonLabel || primaryButton || secondaryButtonLabel || secondaryButton || tertiaryButton || tertiaryButtonLabel) && /*#__PURE__*/React.createElement(Group, {
|
|
3263
3361
|
className: "form__button",
|
|
3264
|
-
dataTestId: dataTestIdButtons,
|
|
3362
|
+
dataTestId: dataTestIdButtons || dataTestId + "Buttons",
|
|
3265
3363
|
dataTour: dataTourButtons,
|
|
3266
3364
|
direction: buttonDirection,
|
|
3267
3365
|
justifyContent: buttonJustifyContent,
|
|
@@ -3271,7 +3369,7 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3271
3369
|
}, primaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
|
|
3272
3370
|
appearance: primaryButtonAppearance,
|
|
3273
3371
|
className: "form__button-item",
|
|
3274
|
-
dataTestId: dataTestIdPrimaryButton ||
|
|
3372
|
+
dataTestId: dataTestIdPrimaryButton || dataTestId && dataTestId + "PrimaryButton" || 'FormPrimaryButton',
|
|
3275
3373
|
dataTour: dataTourPrimaryButton,
|
|
3276
3374
|
width: "fill",
|
|
3277
3375
|
size: primaryButtonSize,
|
|
@@ -3287,7 +3385,7 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3287
3385
|
}) : primaryButton, secondaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
|
|
3288
3386
|
appearance: secondaryButtonAppearance,
|
|
3289
3387
|
className: "form__button-item",
|
|
3290
|
-
dataTestId: dataTestIdSecondaryButton ||
|
|
3388
|
+
dataTestId: dataTestIdSecondaryButton || dataTestId && dataTestId + "SecondaryButton" || 'FormSecondaryButton',
|
|
3291
3389
|
dataTour: dataTourSecondaryButton,
|
|
3292
3390
|
width: "fill",
|
|
3293
3391
|
size: secondaryButtonSize,
|
|
@@ -3302,8 +3400,9 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3302
3400
|
isDisabled: secondaryButtonIsDisabled,
|
|
3303
3401
|
onClick: onClickSecondaryButton
|
|
3304
3402
|
}) : secondaryButton, tertiaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
|
|
3403
|
+
appearance: tertiaryButtonAppearance,
|
|
3305
3404
|
className: "form__button-item",
|
|
3306
|
-
dataTestId: dataTestIdTertiaryButton,
|
|
3405
|
+
dataTestId: dataTestIdTertiaryButton || dataTestId && dataTestId + "TertiaryButton" || 'FormTertiaryButton',
|
|
3307
3406
|
dataTour: dataTourTertiaryButton,
|
|
3308
3407
|
width: "fill",
|
|
3309
3408
|
size: tertiaryButtonSize,
|
|
@@ -3572,4 +3671,4 @@ var getErrorsForFinalForm = function getErrorsForFinalForm(error) {
|
|
|
3572
3671
|
return formErrors;
|
|
3573
3672
|
};
|
|
3574
3673
|
|
|
3575
|
-
export { DEFAULT_MESSAGES_FIELDS, FieldWrapper, FieldWrapperBase, FinalForm, FormBlockGroup, FormFieldCheckbox, FormFieldChips, FormFieldChoice, FormFieldCode, FormFieldCustom, FormFieldDadataInput, FormFieldDatePicker, FormFieldFileInput, FormFieldInput, FormFieldInputNumber, FormFieldMaskedInput, FormFieldPassword, FormFieldRadioGroup, FormFieldSegmented, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, addRequiredFieldsParamToSchema, dateValidation, defaultCheckboxProps, defaultChipsProps, defaultChoiceProps, defaultCodeProps, defaultDadataInputProps, defaultDatepickerProps, defaultDropzoneProps, defaultFieldProps, defaultFieldSizeL, defaultFieldSizeM, defaultFieldSizeS, defaultFieldSizeXL, defaultGroupProps, defaultInputNumberProps, defaultInputProps, defaultPasswordProps, defaultRadioProps, defaultSegmentedProps, defaultSelectProps, defaultSwitchProps, defaultTextareaProps, emailValidation, focusOnError, focusOnErrorDecorator, formTypes, generateField, getErrorsForFinalForm, parseNumericField, phoneValidation, sendFormDataToServer, setErrorsMutator, useYupValidationSchema };
|
|
3674
|
+
export { DEFAULT_MESSAGES_FIELDS, FieldWrapper, FieldWrapperBase, FinalForm, FormBlockGroup, FormFieldCheckbox, FormFieldChips, FormFieldChoice, FormFieldCode, FormFieldCustom, FormFieldDadataInput, FormFieldDatePicker, FormFieldFileInput, FormFieldInput, FormFieldInputNumber, FormFieldMaskedInput, FormFieldPassword, FormFieldRadioGroup, FormFieldSegmented, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, addRequiredFieldsParamToSchema, createDataTestIdField, dateValidation, defaultCheckboxProps, defaultChipsProps, defaultChoiceProps, defaultCodeProps, defaultDadataInputProps, defaultDatepickerProps, defaultDropzoneProps, defaultFieldProps, defaultFieldSizeL, defaultFieldSizeM, defaultFieldSizeS, defaultFieldSizeXL, defaultGroupProps, defaultInputNumberProps, defaultInputProps, defaultPasswordProps, defaultRadioProps, defaultSegmentedProps, defaultSelectProps, defaultSwitchProps, defaultTextareaProps, emailValidation, focusOnError, focusOnErrorDecorator, formTypes, generateField, getErrorsForFinalForm, parseNumericField, phoneValidation, sendFormDataToServer, setErrorsMutator, useYupValidationSchema };
|