@itcase/forms 1.1.55 → 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/itcase-forms.cjs.js +476 -375
- package/dist/itcase-forms.esm.js +462 -362
- 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) {
|
|
@@ -474,9 +472,9 @@ var defaultFieldSizeXL = Object.assign({
|
|
|
474
472
|
}, defaultFieldProps);
|
|
475
473
|
|
|
476
474
|
function FieldWrapperBase(props) {
|
|
477
|
-
var _React$createElement, _React$createElement2;
|
|
478
475
|
var id = props.id,
|
|
479
476
|
className = props.className,
|
|
477
|
+
dataTestId = props.dataTestId,
|
|
480
478
|
dataTour = props.dataTour,
|
|
481
479
|
type = props.type,
|
|
482
480
|
label = props.label,
|
|
@@ -513,7 +511,7 @@ function FieldWrapperBase(props) {
|
|
|
513
511
|
showDivider = props.showDivider,
|
|
514
512
|
showMessage = props.showMessage,
|
|
515
513
|
_props$tag = props.tag,
|
|
516
|
-
Tag = _props$tag === void 0 ?
|
|
514
|
+
Tag = _props$tag === void 0 ? 'div' : _props$tag,
|
|
517
515
|
before = props.before,
|
|
518
516
|
after = props.after,
|
|
519
517
|
isDisabled = props.isDisabled,
|
|
@@ -523,38 +521,38 @@ function FieldWrapperBase(props) {
|
|
|
523
521
|
isValidState = props.isValidState,
|
|
524
522
|
children = props.children;
|
|
525
523
|
var formFieldClass = useMemo(function () {
|
|
526
|
-
return clsx(className, isValidState &&
|
|
524
|
+
return clsx(className, isValidState && 'form__item_state_success', isRequired && 'form__item_state_required', isDisabled && 'form__item_state_disabled', metaActive && 'form__item_state_focus', inputValue && 'form__item_state_filled', isErrorState && "form__item_state_" + errorKey);
|
|
527
525
|
}, [className, isErrorState, isValidState, isRequired, metaActive, inputValue, isDisabled, metaError]);
|
|
528
526
|
var fieldClass = useMemo(function () {
|
|
529
527
|
return clsx(fieldClassName, isValidState && fieldClassName + "_state_success", metaActive && fieldClassName + "_state_focus", inputValue && fieldClassName + "_state_filled", isDisabled && fieldClassName + "_state_disabled", isErrorState && fieldClassName + "_state_" + errorKey);
|
|
530
528
|
}, [fieldClassName, isErrorState, isValidState, metaActive, inputValue, isDisabled, metaError]);
|
|
531
529
|
var sizeClass = useDeviceTargetClass(props, {
|
|
532
|
-
prefix:
|
|
533
|
-
propsKey:
|
|
530
|
+
prefix: 'form-field_size_',
|
|
531
|
+
propsKey: 'size'
|
|
534
532
|
});
|
|
535
533
|
var fillClass = useDeviceTargetClass(props, {
|
|
536
|
-
prefix:
|
|
537
|
-
propsKey:
|
|
534
|
+
prefix: 'fill_',
|
|
535
|
+
propsKey: 'fill'
|
|
538
536
|
});
|
|
539
537
|
var inputFillClass = useDeviceTargetClass(props, {
|
|
540
|
-
prefix:
|
|
541
|
-
propsKey:
|
|
538
|
+
prefix: 'fill_',
|
|
539
|
+
propsKey: 'inputFill'
|
|
542
540
|
});
|
|
543
541
|
var shapeClass = useDeviceTargetClass(props, {
|
|
544
|
-
prefix:
|
|
545
|
-
propsKey:
|
|
542
|
+
prefix: 'form-field_shape_',
|
|
543
|
+
propsKey: 'shape'
|
|
546
544
|
});
|
|
547
545
|
var inputShapeClass = useDeviceTargetClass(props, {
|
|
548
|
-
prefix:
|
|
549
|
-
propsKey:
|
|
546
|
+
prefix: 'form-field__item-value_shape_',
|
|
547
|
+
propsKey: 'inputShape'
|
|
550
548
|
});
|
|
551
549
|
var directionClass = useDeviceTargetClass(props, {
|
|
552
|
-
prefix:
|
|
553
|
-
propsKey:
|
|
550
|
+
prefix: 'direction_',
|
|
551
|
+
propsKey: 'direction'
|
|
554
552
|
});
|
|
555
553
|
var widthClass = useDeviceTargetClass(props, {
|
|
556
|
-
prefix:
|
|
557
|
-
propsKey:
|
|
554
|
+
prefix: 'width_',
|
|
555
|
+
propsKey: 'width'
|
|
558
556
|
});
|
|
559
557
|
var _useStyles = useStyles(props),
|
|
560
558
|
formFieldStyles = _useStyles.styles;
|
|
@@ -562,13 +560,13 @@ function FieldWrapperBase(props) {
|
|
|
562
560
|
var errorTextColor = props[errorKey + "MessageTextColor"];
|
|
563
561
|
var errorTextWeight = props[errorKey + "MessageTextWeight"];
|
|
564
562
|
return /*#__PURE__*/React.createElement(Tag, {
|
|
565
|
-
className: clsx(formFieldClass,
|
|
566
|
-
"data-testid":
|
|
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),
|
|
564
|
+
"data-testid": dataTestId,
|
|
567
565
|
"data-tour": dataTour,
|
|
568
566
|
style: formFieldStyles
|
|
569
567
|
}, before, (label || labelHidden) && /*#__PURE__*/React.createElement("div", {
|
|
570
|
-
className: clsx(
|
|
571
|
-
"data-testid":
|
|
568
|
+
className: clsx('form-field__label'),
|
|
569
|
+
"data-testid": dataTestId + "Label",
|
|
572
570
|
htmlFor: id
|
|
573
571
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
574
572
|
size: labelTextSize,
|
|
@@ -578,15 +576,15 @@ function FieldWrapperBase(props) {
|
|
|
578
576
|
sizeTablet: labelTextSizeTablet
|
|
579
577
|
}, label, labelHidden && "\xA0")), desc && /*#__PURE__*/React.createElement("div", {
|
|
580
578
|
className: "form-field__desc",
|
|
581
|
-
"data-testid":
|
|
579
|
+
"data-testid": dataTestId + "Desc"
|
|
582
580
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
583
581
|
size: descTextSize,
|
|
584
582
|
textColor: descTextColor,
|
|
585
583
|
textWeight: descTextWeight
|
|
586
584
|
}, desc)), /*#__PURE__*/React.createElement("div", {
|
|
587
|
-
className: clsx(
|
|
585
|
+
className: clsx('form-field__content', inputFillClass, inputShapeClass)
|
|
588
586
|
}, /*#__PURE__*/React.createElement("div", {
|
|
589
|
-
className: clsx(
|
|
587
|
+
className: clsx('form-field__content-inner', fieldClass)
|
|
590
588
|
}, beforeItem, children, afterItem), showDivider && /*#__PURE__*/React.createElement(Divider, {
|
|
591
589
|
className: "form-field__item-divider",
|
|
592
590
|
width: dividerWidth,
|
|
@@ -596,16 +594,23 @@ function FieldWrapperBase(props) {
|
|
|
596
594
|
})), showMessage && /*#__PURE__*/React.createElement("div", {
|
|
597
595
|
className: "form-field__message",
|
|
598
596
|
"data-testid": inputName + "-field-message"
|
|
599
|
-
}, isErrorState && errorMessage && /*#__PURE__*/React.createElement(Text,
|
|
597
|
+
}, isErrorState && errorMessage && /*#__PURE__*/React.createElement(Text, {
|
|
600
598
|
id: inputName + "-error",
|
|
601
599
|
className: "form-field__message-item form-field__message-item_type-error",
|
|
602
|
-
dataTestId:
|
|
603
|
-
|
|
600
|
+
dataTestId: dataTestId + "MessageError",
|
|
601
|
+
size: errorTextSize,
|
|
602
|
+
textColor: errorTextColor,
|
|
603
|
+
textWeight: errorTextWeight
|
|
604
|
+
}, errorMessage), Boolean(helpText) && (!isErrorState || !errorMessage) && /*#__PURE__*/React.createElement(Text, {
|
|
604
605
|
className: "form-field__message-item form-field__message-item_type_help-text",
|
|
605
|
-
dataTestId:
|
|
606
|
-
|
|
606
|
+
dataTestId: dataTestId + "MessageHelpText",
|
|
607
|
+
size: helpTextSize,
|
|
608
|
+
textColor: isValidState ? helpTextColorSuccess : helpTextColor,
|
|
609
|
+
textWeight: helpTextWeight,
|
|
610
|
+
sizeMobile: helpTextSizeMobile
|
|
611
|
+
}, helpText), (!isErrorState && !helpText || isErrorState && !helpText && !errorMessage) && /*#__PURE__*/React.createElement(Text, {
|
|
607
612
|
className: "form-field__message-item form-field__message-item_type_help-text",
|
|
608
|
-
dataTestId:
|
|
613
|
+
dataTestId: dataTestId + "MessageHelpText",
|
|
609
614
|
size: messageTextSize
|
|
610
615
|
}, "\xA0")), after);
|
|
611
616
|
}
|
|
@@ -622,16 +627,150 @@ function FieldWrapper(props) {
|
|
|
622
627
|
return /*#__PURE__*/React.createElement(FieldWrapperBase, props);
|
|
623
628
|
}
|
|
624
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
|
+
|
|
625
763
|
var FormFieldCheckbox = /*#__PURE__*/React.memo(function FormFieldCheckbox(props) {
|
|
626
|
-
var
|
|
764
|
+
var dataTestId = props.dataTestId,
|
|
765
|
+
name = props.name,
|
|
627
766
|
initialValue = props.initialValue,
|
|
628
|
-
isDisabled = props.isDisabled,
|
|
629
767
|
classNameGroupItem = props.classNameGroupItem,
|
|
630
768
|
_props$fieldProps = props.fieldProps,
|
|
631
769
|
fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
|
|
632
770
|
_props$inputProps = props.inputProps,
|
|
633
771
|
inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
|
|
634
772
|
showMessage = props.showMessage,
|
|
773
|
+
isDisabled = props.isDisabled,
|
|
635
774
|
isRequired = props.isRequired,
|
|
636
775
|
onChange = props.onChange;
|
|
637
776
|
return /*#__PURE__*/React.createElement(Field, {
|
|
@@ -661,35 +800,37 @@ var FormFieldCheckbox = /*#__PURE__*/React.memo(function FormFieldCheckbox(props
|
|
|
661
800
|
}),
|
|
662
801
|
errorKey = _useFieldValidationSt.errorKey,
|
|
663
802
|
errorMessage = _useFieldValidationSt.errorMessage,
|
|
664
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
665
803
|
successKey = _useFieldValidationSt.successKey,
|
|
804
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
666
805
|
isValidState = _useFieldValidationSt.isValidState;
|
|
667
806
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
668
807
|
inputProps: inputProps,
|
|
669
808
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
670
809
|
});
|
|
810
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
671
811
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
672
812
|
className: clsx('form-field-checkbox', 'form__item_checkbox', classNameGroupItem),
|
|
813
|
+
dataTestId: dataTestIdField,
|
|
673
814
|
errorKey: errorKey,
|
|
674
815
|
errorMessage: errorMessage,
|
|
675
|
-
isErrorState: isErrorState,
|
|
676
|
-
metaError: meta.error,
|
|
677
|
-
isDisabled: isDisabled,
|
|
678
816
|
fieldClassName: "form-checkbox",
|
|
679
817
|
inputName: input.name,
|
|
680
818
|
inputValue: input.checked,
|
|
681
819
|
metaActive: meta.active,
|
|
820
|
+
metaError: meta.error,
|
|
682
821
|
showMessage: showMessage,
|
|
683
822
|
tag: "label",
|
|
823
|
+
isDisabled: isDisabled,
|
|
824
|
+
isErrorState: isErrorState,
|
|
684
825
|
isRequired: isRequired,
|
|
685
826
|
isValidState: isValidState
|
|
686
827
|
}, fieldProps), /*#__PURE__*/React.createElement(Checkbox, Object.assign({
|
|
687
828
|
type: "checkbox",
|
|
688
829
|
name: input.name,
|
|
689
|
-
isDisabled: isDisabled,
|
|
690
830
|
autoComplete: "nope",
|
|
691
831
|
checked: input.checked,
|
|
692
832
|
isActive: input.checked,
|
|
833
|
+
isDisabled: isDisabled,
|
|
693
834
|
onBlur: input.onBlur,
|
|
694
835
|
onChange: onChangeField,
|
|
695
836
|
onFocus: input.onFocus
|
|
@@ -710,7 +851,8 @@ var defaultChipsProps = {
|
|
|
710
851
|
};
|
|
711
852
|
|
|
712
853
|
function FormFieldChips(props) {
|
|
713
|
-
var
|
|
854
|
+
var dataTestId = props.dataTestId,
|
|
855
|
+
name = props.name,
|
|
714
856
|
initialValue = props.initialValue,
|
|
715
857
|
classNameGroupItem = props.classNameGroupItem,
|
|
716
858
|
emptyMessage = props.emptyMessage,
|
|
@@ -773,8 +915,10 @@ function FormFieldChips(props) {
|
|
|
773
915
|
}
|
|
774
916
|
return emptyOptionsList;
|
|
775
917
|
}, [input.value]);
|
|
918
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
776
919
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
777
920
|
className: clsx('form-field_chips', 'form__item_chips', classNameGroupItem),
|
|
921
|
+
dataTestId: dataTestIdField,
|
|
778
922
|
errorKey: errorKey,
|
|
779
923
|
errorMessage: errorMessage,
|
|
780
924
|
fieldClassName: "form-chips",
|
|
@@ -823,7 +967,8 @@ var defaultChoiceProps = {
|
|
|
823
967
|
};
|
|
824
968
|
|
|
825
969
|
var FormFieldChoice = /*#__PURE__*/React.memo(function FormFieldChoice(props) {
|
|
826
|
-
var
|
|
970
|
+
var dataTestId = props.dataTestId,
|
|
971
|
+
name = props.name,
|
|
827
972
|
initialValue = props.initialValue,
|
|
828
973
|
label = props.label,
|
|
829
974
|
messageType = props.messageType,
|
|
@@ -846,8 +991,8 @@ var FormFieldChoice = /*#__PURE__*/React.memo(function FormFieldChoice(props) {
|
|
|
846
991
|
}
|
|
847
992
|
}, [change, onChange]);
|
|
848
993
|
return /*#__PURE__*/React.createElement(Field, {
|
|
849
|
-
|
|
850
|
-
|
|
994
|
+
name: name,
|
|
995
|
+
initialValue: initialValue
|
|
851
996
|
}, function Render(_ref) {
|
|
852
997
|
var input = _ref.input,
|
|
853
998
|
meta = _ref.meta;
|
|
@@ -859,8 +1004,8 @@ var FormFieldChoice = /*#__PURE__*/React.memo(function FormFieldChoice(props) {
|
|
|
859
1004
|
*/
|
|
860
1005
|
var activeOption = useMemo(function () {
|
|
861
1006
|
var emptyOption = {
|
|
862
|
-
|
|
863
|
-
|
|
1007
|
+
label: null,
|
|
1008
|
+
value: null
|
|
864
1009
|
};
|
|
865
1010
|
if (input.value) {
|
|
866
1011
|
var currentOption = options.find(function (option) {
|
|
@@ -877,27 +1022,29 @@ var FormFieldChoice = /*#__PURE__*/React.memo(function FormFieldChoice(props) {
|
|
|
877
1022
|
}),
|
|
878
1023
|
errorKey = _useFieldValidationSt.errorKey,
|
|
879
1024
|
errorMessage = _useFieldValidationSt.errorMessage,
|
|
880
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
881
1025
|
successKey = _useFieldValidationSt.successKey,
|
|
1026
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
882
1027
|
isValidState = _useFieldValidationSt.isValidState;
|
|
883
1028
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
884
1029
|
inputProps: inputProps,
|
|
885
1030
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
886
1031
|
});
|
|
1032
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
887
1033
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
888
1034
|
className: clsx('form-field_choice', 'form__item_choice', classNameGroupItem),
|
|
1035
|
+
dataTestId: dataTestIdField,
|
|
889
1036
|
label: label,
|
|
890
1037
|
messageType: messageType,
|
|
891
1038
|
errorKey: errorKey,
|
|
892
1039
|
errorMessage: errorMessage,
|
|
893
|
-
isErrorState: isErrorState,
|
|
894
|
-
metaError: meta.error,
|
|
895
|
-
isDisabled: isDisabled,
|
|
896
1040
|
fieldClassName: "form-choice",
|
|
897
1041
|
inputName: input.name,
|
|
898
1042
|
inputValue: input.value || [],
|
|
899
1043
|
metaActive: meta.active,
|
|
1044
|
+
metaError: meta.error,
|
|
900
1045
|
showMessage: showMessage,
|
|
1046
|
+
isDisabled: isDisabled,
|
|
1047
|
+
isErrorState: isErrorState,
|
|
901
1048
|
isRequired: isRequired,
|
|
902
1049
|
isValidState: isValidState
|
|
903
1050
|
}, fieldProps), /*#__PURE__*/React.createElement(Choice, Object.assign({
|
|
@@ -925,17 +1072,18 @@ var defaultCodeProps = {
|
|
|
925
1072
|
};
|
|
926
1073
|
|
|
927
1074
|
var FormFieldCode = /*#__PURE__*/React.memo(function FormFieldCode(props) {
|
|
928
|
-
var
|
|
1075
|
+
var dataTestId = props.dataTestId,
|
|
1076
|
+
name = props.name,
|
|
929
1077
|
initialValue = props.initialValue,
|
|
930
1078
|
label = props.label,
|
|
931
1079
|
messageType = props.messageType,
|
|
932
|
-
isDisabled = props.isDisabled,
|
|
933
1080
|
classNameGroupItem = props.classNameGroupItem,
|
|
934
1081
|
_props$fieldProps = props.fieldProps,
|
|
935
1082
|
fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
|
|
936
1083
|
_props$inputProps = props.inputProps,
|
|
937
1084
|
inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
|
|
938
1085
|
showMessage = props.showMessage,
|
|
1086
|
+
isDisabled = props.isDisabled,
|
|
939
1087
|
isRequired = props.isRequired;
|
|
940
1088
|
return /*#__PURE__*/React.createElement(Field, {
|
|
941
1089
|
name: name,
|
|
@@ -957,32 +1105,34 @@ var FormFieldCode = /*#__PURE__*/React.memo(function FormFieldCode(props) {
|
|
|
957
1105
|
}),
|
|
958
1106
|
errorKey = _useFieldValidationSt.errorKey,
|
|
959
1107
|
errorMessage = _useFieldValidationSt.errorMessage,
|
|
960
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
961
1108
|
successKey = _useFieldValidationSt.successKey,
|
|
1109
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
962
1110
|
isValidState = _useFieldValidationSt.isValidState;
|
|
963
1111
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
964
1112
|
inputProps: inputProps,
|
|
965
1113
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
966
1114
|
});
|
|
1115
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
967
1116
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
968
1117
|
className: clsx('form-field-code', 'form__item_code', classNameGroupItem),
|
|
1118
|
+
dataTestId: dataTestIdField,
|
|
969
1119
|
label: label,
|
|
970
1120
|
messageType: messageType,
|
|
971
1121
|
errorKey: errorKey,
|
|
972
1122
|
errorMessage: errorMessage,
|
|
973
|
-
isErrorState: isErrorState,
|
|
974
1123
|
fieldClassName: 'form-code',
|
|
975
1124
|
inputName: input.name,
|
|
976
1125
|
inputValue: input.value,
|
|
977
1126
|
metaActive: meta.active,
|
|
978
1127
|
showMessage: showMessage,
|
|
1128
|
+
isErrorState: isErrorState,
|
|
979
1129
|
isRequired: isRequired,
|
|
980
1130
|
isValidState: isValidState
|
|
981
1131
|
}, fieldProps), /*#__PURE__*/React.createElement(Code, Object.assign({
|
|
982
1132
|
name: input.name,
|
|
983
1133
|
initialValue: input.value,
|
|
984
|
-
isDisabled: isDisabled,
|
|
985
1134
|
autoComplete: "nope",
|
|
1135
|
+
isDisabled: isDisabled,
|
|
986
1136
|
onBlur: input.onBlur,
|
|
987
1137
|
onChange: input.onChange,
|
|
988
1138
|
onFocus: input.onFocus
|
|
@@ -991,24 +1141,25 @@ var FormFieldCode = /*#__PURE__*/React.memo(function FormFieldCode(props) {
|
|
|
991
1141
|
});
|
|
992
1142
|
|
|
993
1143
|
var FormFieldCustom = /*#__PURE__*/React.memo(function FormFieldCustom(props) {
|
|
994
|
-
var
|
|
995
|
-
isDisabled = props.isDisabled,
|
|
996
|
-
isRequired = props.isRequired,
|
|
1144
|
+
var dataTestId = props.dataTestId,
|
|
997
1145
|
name = props.name,
|
|
998
1146
|
initialValue = props.initialValue,
|
|
999
|
-
_props$fieldProps = props.fieldProps,
|
|
1000
|
-
fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
|
|
1001
1147
|
classNameGroupItem = props.classNameGroupItem,
|
|
1002
|
-
showMessage = props.showMessage,
|
|
1003
1148
|
clearIcon = props.clearIcon,
|
|
1004
1149
|
clearIconFill = props.clearIconFill,
|
|
1005
1150
|
clearIconFillHover = props.clearIconFillHover,
|
|
1006
1151
|
clearIconShape = props.clearIconShape,
|
|
1007
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,
|
|
1008
1159
|
onClickClearIcon = props.onClickClearIcon;
|
|
1009
1160
|
return /*#__PURE__*/React.createElement(Field, {
|
|
1010
|
-
|
|
1011
|
-
|
|
1161
|
+
name: name,
|
|
1162
|
+
initialValue: initialValue
|
|
1012
1163
|
}, function Render(_ref) {
|
|
1013
1164
|
var input = _ref.input,
|
|
1014
1165
|
meta = _ref.meta;
|
|
@@ -1024,40 +1175,42 @@ var FormFieldCustom = /*#__PURE__*/React.memo(function FormFieldCustom(props) {
|
|
|
1024
1175
|
input: input,
|
|
1025
1176
|
meta: meta
|
|
1026
1177
|
}),
|
|
1027
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
1028
|
-
isValidState = _useFieldValidationSt.isValidState,
|
|
1029
1178
|
errorKey = _useFieldValidationSt.errorKey,
|
|
1030
|
-
errorMessage = _useFieldValidationSt.errorMessage
|
|
1179
|
+
errorMessage = _useFieldValidationSt.errorMessage,
|
|
1180
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
1181
|
+
isValidState = _useFieldValidationSt.isValidState;
|
|
1031
1182
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
1032
|
-
validationStateKey: isErrorState ? errorKey : 'success',
|
|
1033
1183
|
// For "Custom" field we pass all props. Can contain some special props, we don't known.
|
|
1034
|
-
inputProps: props
|
|
1184
|
+
inputProps: props,
|
|
1185
|
+
validationStateKey: isErrorState ? errorKey : 'success'
|
|
1035
1186
|
});
|
|
1187
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
1036
1188
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
1037
1189
|
className: clsx('form-field_custom', 'form__item_custom', classNameGroupItem),
|
|
1190
|
+
dataTestId: dataTestIdField,
|
|
1038
1191
|
errorKey: errorKey,
|
|
1039
1192
|
errorMessage: errorMessage,
|
|
1040
1193
|
fieldClassName: 'form-custom',
|
|
1041
1194
|
inputName: input.name,
|
|
1042
1195
|
inputValue: input.value,
|
|
1196
|
+
metaActive: meta.active,
|
|
1197
|
+
metaError: meta.error,
|
|
1198
|
+
showMessage: showMessage,
|
|
1043
1199
|
isDisabled: isDisabled,
|
|
1044
1200
|
isErrorState: isErrorState,
|
|
1045
1201
|
isRequired: isRequired,
|
|
1046
|
-
isValidState: isValidState
|
|
1047
|
-
metaActive: meta.active,
|
|
1048
|
-
metaError: meta.error,
|
|
1049
|
-
showMessage: showMessage
|
|
1202
|
+
isValidState: isValidState
|
|
1050
1203
|
}, fieldProps), /*#__PURE__*/React.createElement(Component, Object.assign({}, updatedInputProps, {
|
|
1051
1204
|
input: input,
|
|
1052
|
-
|
|
1053
|
-
|
|
1205
|
+
meta: meta,
|
|
1206
|
+
isDisabled: isDisabled
|
|
1054
1207
|
})), clearIcon && /*#__PURE__*/React.createElement(Icon, {
|
|
1055
1208
|
className: "form-field__icon",
|
|
1209
|
+
size: clearIconSize,
|
|
1056
1210
|
iconFill: clearIconFill,
|
|
1057
1211
|
iconFillHover: clearIconFillHover,
|
|
1058
1212
|
imageSrc: clearIcon,
|
|
1059
1213
|
shape: clearIconShape,
|
|
1060
|
-
size: clearIconSize,
|
|
1061
1214
|
SvgImage: clearIcon,
|
|
1062
1215
|
onClick: onClickClearIcon
|
|
1063
1216
|
}));
|
|
@@ -1076,15 +1229,16 @@ var defaultDadataInputProps = {
|
|
|
1076
1229
|
};
|
|
1077
1230
|
|
|
1078
1231
|
var FormFieldDadataInput = /*#__PURE__*/React.memo(function FormFieldDadataInput(props) {
|
|
1079
|
-
var
|
|
1232
|
+
var dataTestId = props.dataTestId,
|
|
1233
|
+
name = props.name,
|
|
1080
1234
|
initialValue = props.initialValue,
|
|
1081
|
-
isDisabled = props.isDisabled,
|
|
1082
1235
|
classNameGroupItem = props.classNameGroupItem,
|
|
1083
1236
|
fieldProps = props.fieldProps,
|
|
1084
1237
|
inputProps = props.inputProps,
|
|
1085
1238
|
parse = props.parse,
|
|
1086
1239
|
showMessage = props.showMessage,
|
|
1087
1240
|
token = props.token,
|
|
1241
|
+
isDisabled = props.isDisabled,
|
|
1088
1242
|
isRequired = props.isRequired,
|
|
1089
1243
|
onDadataAutocomplete = props.onDadataAutocomplete;
|
|
1090
1244
|
if (process.env.NODE_ENV === 'development') {
|
|
@@ -1119,25 +1273,27 @@ var FormFieldDadataInput = /*#__PURE__*/React.memo(function FormFieldDadataInput
|
|
|
1119
1273
|
}),
|
|
1120
1274
|
errorKey = _useFieldValidationSt.errorKey,
|
|
1121
1275
|
errorMessage = _useFieldValidationSt.errorMessage,
|
|
1122
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
1123
1276
|
successKey = _useFieldValidationSt.successKey,
|
|
1277
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
1124
1278
|
isValidState = _useFieldValidationSt.isValidState;
|
|
1125
1279
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
1126
1280
|
inputProps: inputProps,
|
|
1127
1281
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1128
1282
|
});
|
|
1283
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
1129
1284
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
1130
1285
|
className: clsx('form-field_input-dadata', 'form__item_input-dadata', classNameGroupItem),
|
|
1286
|
+
dataTestId: dataTestIdField,
|
|
1131
1287
|
errorKey: errorKey,
|
|
1132
1288
|
errorMessage: errorMessage,
|
|
1133
|
-
isErrorState: isErrorState,
|
|
1134
|
-
metaError: meta.error,
|
|
1135
|
-
isDisabled: isDisabled,
|
|
1136
1289
|
fieldClassName: "form-dadata",
|
|
1137
1290
|
inputName: input.name,
|
|
1138
1291
|
inputValue: input.value || '',
|
|
1139
1292
|
metaActive: meta.active,
|
|
1293
|
+
metaError: meta.error,
|
|
1140
1294
|
showMessage: showMessage,
|
|
1295
|
+
isDisabled: isDisabled,
|
|
1296
|
+
isErrorState: isErrorState,
|
|
1141
1297
|
isRequired: isRequired,
|
|
1142
1298
|
isValidState: isValidState
|
|
1143
1299
|
}, fieldProps), /*#__PURE__*/React.createElement(Dadata
|
|
@@ -1150,8 +1306,8 @@ var FormFieldDadataInput = /*#__PURE__*/React.memo(function FormFieldDadataInput
|
|
|
1150
1306
|
input: input,
|
|
1151
1307
|
inputProps: updatedInputProps,
|
|
1152
1308
|
meta: meta,
|
|
1153
|
-
|
|
1154
|
-
|
|
1309
|
+
token: token,
|
|
1310
|
+
setValue: onDadataAutocomplete
|
|
1155
1311
|
}));
|
|
1156
1312
|
});
|
|
1157
1313
|
});
|
|
@@ -1170,8 +1326,8 @@ var defaultDatepickerProps = {
|
|
|
1170
1326
|
};
|
|
1171
1327
|
|
|
1172
1328
|
function FormFieldDatePicker(props) {
|
|
1173
|
-
var
|
|
1174
|
-
|
|
1329
|
+
var dataTestId = props.dataTestId,
|
|
1330
|
+
name = props.name,
|
|
1175
1331
|
classNameGroupItem = props.classNameGroupItem,
|
|
1176
1332
|
datePickerProps = props.datePickerProps,
|
|
1177
1333
|
_props$fieldProps = props.fieldProps,
|
|
@@ -1179,6 +1335,7 @@ function FormFieldDatePicker(props) {
|
|
|
1179
1335
|
_props$inputProps = props.inputProps,
|
|
1180
1336
|
inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
|
|
1181
1337
|
showMessage = props.showMessage,
|
|
1338
|
+
isDisabled = props.isDisabled,
|
|
1182
1339
|
isRequired = props.isRequired,
|
|
1183
1340
|
onChange = props.onChange;
|
|
1184
1341
|
return /*#__PURE__*/React.createElement(Field, {
|
|
@@ -1216,34 +1373,36 @@ function FormFieldDatePicker(props) {
|
|
|
1216
1373
|
}),
|
|
1217
1374
|
errorKey = _useFieldValidationSt.errorKey,
|
|
1218
1375
|
errorMessage = _useFieldValidationSt.errorMessage,
|
|
1219
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
1220
1376
|
successKey = _useFieldValidationSt.successKey,
|
|
1377
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
1221
1378
|
isValidState = _useFieldValidationSt.isValidState;
|
|
1222
1379
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
1223
1380
|
inputProps: inputProps,
|
|
1224
1381
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1225
1382
|
});
|
|
1383
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
1226
1384
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
1227
1385
|
className: clsx('form-field_datepicker', 'form__item_datepicker', classNameGroupItem),
|
|
1386
|
+
dataTestId: dataTestIdField,
|
|
1228
1387
|
errorKey: errorKey,
|
|
1229
1388
|
errorMessage: errorMessage,
|
|
1230
|
-
isErrorState: isErrorState,
|
|
1231
|
-
metaError: meta.error,
|
|
1232
|
-
isDisabled: isDisabled,
|
|
1233
1389
|
fieldClassName: "form-datepicker",
|
|
1234
1390
|
inputName: input.name,
|
|
1235
1391
|
inputValue: input.value || '',
|
|
1236
1392
|
metaActive: meta.active,
|
|
1393
|
+
metaError: meta.error,
|
|
1237
1394
|
showMessage: showMessage,
|
|
1395
|
+
isDisabled: isDisabled,
|
|
1396
|
+
isErrorState: isErrorState,
|
|
1238
1397
|
isRequired: isRequired,
|
|
1239
1398
|
isValidState: isValidState
|
|
1240
1399
|
}, fieldProps), /*#__PURE__*/React.createElement(DatePickerInput, {
|
|
1241
1400
|
name: input.name,
|
|
1242
|
-
isDisabled: isDisabled,
|
|
1243
1401
|
datePickerProps: datePickerProps,
|
|
1244
1402
|
endValue: datePickerProps.selectsRange ? input.value.endDate : null,
|
|
1245
1403
|
inputProps: updatedInputProps,
|
|
1246
1404
|
value: datePickerProps.selectsRange ? input.value.startDate : input.value,
|
|
1405
|
+
isDisabled: isDisabled,
|
|
1247
1406
|
onBlur: input.onBlur,
|
|
1248
1407
|
onChange: onChangeField,
|
|
1249
1408
|
onFocus: input.onFocus
|
|
@@ -1717,23 +1876,24 @@ function setFileDataURL(file, resolve) {
|
|
|
1717
1876
|
|
|
1718
1877
|
var FormFieldFileInput = /*#__PURE__*/React.memo(function FormFieldFileInput(props) {
|
|
1719
1878
|
var className = props.className,
|
|
1879
|
+
dataTestId = props.dataTestId,
|
|
1720
1880
|
name = props.name,
|
|
1721
1881
|
width = props.width,
|
|
1722
1882
|
maxFiles = props.maxFiles,
|
|
1723
1883
|
maxSize = props.maxSize,
|
|
1724
1884
|
label = props.label,
|
|
1725
|
-
fileErrorText = props.fileErrorText,
|
|
1726
1885
|
classNameGroupItem = props.classNameGroupItem,
|
|
1727
1886
|
dropzoneProps = props.dropzoneProps,
|
|
1728
1887
|
fieldProps = props.fieldProps,
|
|
1888
|
+
fileErrorText = props.fileErrorText,
|
|
1729
1889
|
hintDescription = props.hintDescription,
|
|
1730
1890
|
hintTitle = props.hintTitle,
|
|
1731
1891
|
showFilename = props.showFilename,
|
|
1732
1892
|
showMessage = props.showMessage,
|
|
1733
1893
|
isPreviews = props.isPreviews,
|
|
1734
1894
|
isRequired = props.isRequired,
|
|
1735
|
-
onAddFiles = props.onAddFiles,
|
|
1736
1895
|
onClickPreview = props.onClickPreview,
|
|
1896
|
+
onAddFiles = props.onAddFiles,
|
|
1737
1897
|
onDeleteFile = props.onDeleteFile;
|
|
1738
1898
|
var propsGenerator = useDevicePropsGenerator(props);
|
|
1739
1899
|
var size = propsGenerator.size,
|
|
@@ -1796,25 +1956,27 @@ var FormFieldFileInput = /*#__PURE__*/React.memo(function FormFieldFileInput(pro
|
|
|
1796
1956
|
inputProps: props,
|
|
1797
1957
|
validationStateKey: isErrorState ? errorKey : 'success'
|
|
1798
1958
|
});
|
|
1959
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
1799
1960
|
|
|
1800
1961
|
/** TODO:
|
|
1801
1962
|
* REFACTOR PROPERTIES
|
|
1802
1963
|
*/
|
|
1803
1964
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
1804
1965
|
className: clsx('form-field_type_dropzone', 'form__item_type_dropzone', classNameGroupItem),
|
|
1966
|
+
dataTestId: dataTestIdField,
|
|
1805
1967
|
width: width,
|
|
1806
1968
|
label: label,
|
|
1807
1969
|
labelTextColor: labelTextColor,
|
|
1808
1970
|
errorKey: errorKey,
|
|
1809
1971
|
errorMessage: errorMessage,
|
|
1810
|
-
isErrorState: isErrorState,
|
|
1811
|
-
metaError: meta.error,
|
|
1812
1972
|
fieldClassName: "form-dropzone",
|
|
1813
1973
|
inputName: input.name,
|
|
1814
1974
|
inputValue: input.value,
|
|
1815
1975
|
metaActive: meta.active,
|
|
1976
|
+
metaError: meta.error,
|
|
1816
1977
|
metaTouched: meta.touched,
|
|
1817
1978
|
showMessage: showMessage,
|
|
1979
|
+
isErrorState: isErrorState,
|
|
1818
1980
|
isRequired: isRequired,
|
|
1819
1981
|
isValidState: isValidState
|
|
1820
1982
|
}, fieldProps), /*#__PURE__*/React.createElement(FileInputDropzone, {
|
|
@@ -1828,12 +1990,11 @@ var FormFieldFileInput = /*#__PURE__*/React.memo(function FormFieldFileInput(pro
|
|
|
1828
1990
|
borderColorHover: borderColorHover,
|
|
1829
1991
|
borderType: borderType,
|
|
1830
1992
|
borderWidth: borderWidth,
|
|
1993
|
+
dropzoneProps: dropzoneProps,
|
|
1831
1994
|
errorMessageTextColor: errorMessageTextColor,
|
|
1832
1995
|
errorMessageTextSize: errorMessageTextSize,
|
|
1833
1996
|
errorMessageWeight: errorMessageTextWeight,
|
|
1834
1997
|
fileErrorText: fileErrorText,
|
|
1835
|
-
metaError: meta.error,
|
|
1836
|
-
dropzoneProps: dropzoneProps,
|
|
1837
1998
|
hintDescription: hintDescription,
|
|
1838
1999
|
hintDescriptionTextColor: hintDescriptionTextColor,
|
|
1839
2000
|
hintDescriptionTextSize: hintDescriptionTextSize,
|
|
@@ -1846,6 +2007,7 @@ var FormFieldFileInput = /*#__PURE__*/React.memo(function FormFieldFileInput(pro
|
|
|
1846
2007
|
hintTitleTextWrap: hintTitleTextWrap,
|
|
1847
2008
|
inputName: input.name,
|
|
1848
2009
|
inputValue: input.value,
|
|
2010
|
+
metaError: meta.error,
|
|
1849
2011
|
metaTouched: meta.touched,
|
|
1850
2012
|
removeThumbAppearance: removeThumbAppearance,
|
|
1851
2013
|
removeThumbShape: removeThumbShape,
|
|
@@ -1864,8 +2026,8 @@ var FormFieldFileInput = /*#__PURE__*/React.memo(function FormFieldFileInput(pro
|
|
|
1864
2026
|
thumbNameTextWeight: thumbNameTextWeight,
|
|
1865
2027
|
thumbNameTextWrap: thumbNameTextWrap,
|
|
1866
2028
|
isPreviews: isPreviews,
|
|
1867
|
-
onAddFiles: onAddFiles,
|
|
1868
2029
|
onClickPreview: onClickPreview,
|
|
2030
|
+
onAddFiles: onAddFiles,
|
|
1869
2031
|
onDeleteFile: onDeleteFile
|
|
1870
2032
|
}));
|
|
1871
2033
|
});
|
|
@@ -1884,8 +2046,9 @@ var defaultGroupProps = {
|
|
|
1884
2046
|
};
|
|
1885
2047
|
|
|
1886
2048
|
var FormBlockGroup = /*#__PURE__*/React.memo(function Group(props) {
|
|
1887
|
-
var
|
|
1888
|
-
|
|
2049
|
+
var className = props.className,
|
|
2050
|
+
dataTestId = props.dataTestId,
|
|
2051
|
+
dataTour = props.dataTour,
|
|
1889
2052
|
name = props.name,
|
|
1890
2053
|
title = props.title,
|
|
1891
2054
|
titleTextColor = props.titleTextColor,
|
|
@@ -1909,6 +2072,7 @@ var FormBlockGroup = /*#__PURE__*/React.memo(function Group(props) {
|
|
|
1909
2072
|
// @ts-expect-error
|
|
1910
2073
|
var _useStyles = useStyles(props),
|
|
1911
2074
|
styles = _useStyles.styles;
|
|
2075
|
+
var dataTestIdField = createDataTestIdField(name, dataTestId);
|
|
1912
2076
|
return /*#__PURE__*/React.createElement(Field, {
|
|
1913
2077
|
name: name
|
|
1914
2078
|
}, function Render(_ref) {
|
|
@@ -1935,7 +2099,7 @@ var FormBlockGroup = /*#__PURE__*/React.memo(function Group(props) {
|
|
|
1935
2099
|
});
|
|
1936
2100
|
return /*#__PURE__*/React.createElement("div", {
|
|
1937
2101
|
className: clsx('form__group', className, isHidden && 'form__group_hidden', column && "form__group_column_" + column),
|
|
1938
|
-
"data-test-id":
|
|
2102
|
+
"data-test-id": dataTestIdField,
|
|
1939
2103
|
"data-tour": dataTour,
|
|
1940
2104
|
style: styles
|
|
1941
2105
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -1943,32 +2107,32 @@ var FormBlockGroup = /*#__PURE__*/React.memo(function Group(props) {
|
|
|
1943
2107
|
}, before, title && /*#__PURE__*/React.createElement("div", {
|
|
1944
2108
|
className: "form__group-title"
|
|
1945
2109
|
}, /*#__PURE__*/React.createElement(Title, {
|
|
2110
|
+
dataTestId: dataTestIdField + "Title",
|
|
1946
2111
|
size: titleTextSize,
|
|
1947
2112
|
textColor: titleTextColor,
|
|
1948
|
-
textWeight: titleTextWeight
|
|
1949
|
-
dataTestId: name + "GroupTitle"
|
|
2113
|
+
textWeight: titleTextWeight
|
|
1950
2114
|
}, title)), label && /*#__PURE__*/React.createElement("div", {
|
|
1951
2115
|
className: "form__group-label"
|
|
1952
2116
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
2117
|
+
dataTestId: dataTestIdField + "Label",
|
|
1953
2118
|
size: labelTextSize,
|
|
1954
2119
|
textColor: labelTextColor,
|
|
1955
|
-
textWeight: labelTextWeight
|
|
1956
|
-
dataTestId: name + "GroupLabel"
|
|
2120
|
+
textWeight: labelTextWeight
|
|
1957
2121
|
}, label)), /*#__PURE__*/React.createElement("div", {
|
|
1958
2122
|
className: "form__group-items"
|
|
1959
2123
|
}, children), after), showGroupMessage && /*#__PURE__*/React.createElement(React.Fragment, null, isErrorState && errorMessage && /*#__PURE__*/React.createElement(Text, {
|
|
1960
2124
|
id: name + "-error",
|
|
1961
2125
|
className: "form__group-message form__group-message_type-" + errorKey,
|
|
2126
|
+
dataTestId: dataTestIdField + "MessageError",
|
|
1962
2127
|
size: updatedProps.messageTextSize,
|
|
1963
2128
|
textColor: updatedProps.messageTextColor,
|
|
1964
|
-
textWeight: updatedProps.messageTextWeight
|
|
1965
|
-
dataTestId: name + "GroupMessageError"
|
|
2129
|
+
textWeight: updatedProps.messageTextWeight
|
|
1966
2130
|
}, errorMessage), Boolean(message) && (!isErrorState || !errorMessage) && /*#__PURE__*/React.createElement(Text, {
|
|
1967
2131
|
className: "form__group-message",
|
|
2132
|
+
dataTestId: name + "GroupMessage",
|
|
1968
2133
|
size: messageTextSize,
|
|
1969
2134
|
textColor: messageTextColor,
|
|
1970
|
-
textWeight: messageTextWeight
|
|
1971
|
-
dataTestId: name + "GroupMessage"
|
|
2135
|
+
textWeight: messageTextWeight
|
|
1972
2136
|
}, message), !isErrorState && !message && /*#__PURE__*/React.createElement(Text, {
|
|
1973
2137
|
className: "form__group-message",
|
|
1974
2138
|
size: messageTextSize
|
|
@@ -1989,7 +2153,8 @@ var defaultInputProps = {
|
|
|
1989
2153
|
};
|
|
1990
2154
|
|
|
1991
2155
|
var FormFieldInput = /*#__PURE__*/React.memo(function FormFieldInput(props) {
|
|
1992
|
-
var
|
|
2156
|
+
var dataTestId = props.dataTestId,
|
|
2157
|
+
name = props.name,
|
|
1993
2158
|
initialValue = props.initialValue,
|
|
1994
2159
|
classNameGroupItem = props.classNameGroupItem,
|
|
1995
2160
|
clearIcon = props.clearIcon,
|
|
@@ -2041,13 +2206,15 @@ var FormFieldInput = /*#__PURE__*/React.memo(function FormFieldInput(props) {
|
|
|
2041
2206
|
inputProps: inputProps,
|
|
2042
2207
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2043
2208
|
});
|
|
2209
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2044
2210
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2045
|
-
className: clsx(
|
|
2211
|
+
className: clsx('form-field_input', 'form__item_input', classNameGroupItem),
|
|
2212
|
+
dataTestId: dataTestIdField,
|
|
2046
2213
|
errorKey: errorKey,
|
|
2047
2214
|
errorMessage: errorMessage,
|
|
2048
2215
|
fieldClassName: "form-input",
|
|
2049
2216
|
inputName: input.name,
|
|
2050
|
-
inputValue: input.value ||
|
|
2217
|
+
inputValue: input.value || '',
|
|
2051
2218
|
metaActive: meta.active,
|
|
2052
2219
|
metaError: meta.error,
|
|
2053
2220
|
showMessage: showMessage,
|
|
@@ -2056,24 +2223,25 @@ var FormFieldInput = /*#__PURE__*/React.memo(function FormFieldInput(props) {
|
|
|
2056
2223
|
isRequired: isRequired,
|
|
2057
2224
|
isValidState: isValidState
|
|
2058
2225
|
}, fieldProps), /*#__PURE__*/React.createElement(Input, Object.assign({
|
|
2059
|
-
className: clsx(meta.active &&
|
|
2060
|
-
dataTestId:
|
|
2226
|
+
className: clsx(meta.active && 'input_state_focus', meta.error && meta.touched && "input_state_" + errorKey),
|
|
2227
|
+
dataTestId: dataTestIdField + "Input",
|
|
2061
2228
|
type: "text",
|
|
2062
2229
|
name: input.name,
|
|
2063
2230
|
autoComplete: "nope",
|
|
2064
|
-
value: input.value ||
|
|
2231
|
+
value: input.value || '',
|
|
2065
2232
|
isDisabled: isDisabled,
|
|
2066
2233
|
onBlur: input.onBlur,
|
|
2067
2234
|
onChange: onChangeField,
|
|
2068
2235
|
onFocus: input.onFocus
|
|
2069
2236
|
}, updatedInputProps)), clearIcon && /*#__PURE__*/React.createElement(Icon, {
|
|
2070
2237
|
className: "form-field__icon",
|
|
2238
|
+
dataTestId: dataTestIdField + "InputIcon",
|
|
2071
2239
|
size: clearIconSize,
|
|
2072
2240
|
iconFill: clearIconFill,
|
|
2073
2241
|
iconFillHover: clearIconFillHover,
|
|
2074
|
-
imageSrc: typeof clearIcon ===
|
|
2242
|
+
imageSrc: typeof clearIcon === 'string' && clearIcon,
|
|
2075
2243
|
shape: clearIconShape,
|
|
2076
|
-
SvgImage: typeof clearIcon !==
|
|
2244
|
+
SvgImage: typeof clearIcon !== 'string' && clearIcon,
|
|
2077
2245
|
onClick: onClickClearIcon
|
|
2078
2246
|
}));
|
|
2079
2247
|
});
|
|
@@ -2085,7 +2253,8 @@ var defaultInputNumberProps = {
|
|
|
2085
2253
|
};
|
|
2086
2254
|
|
|
2087
2255
|
var FormFieldInputNumber = /*#__PURE__*/React.memo(function FormFieldInputNumber(props) {
|
|
2088
|
-
var
|
|
2256
|
+
var dataTestId = props.dataTestId,
|
|
2257
|
+
_props$type = props.type,
|
|
2089
2258
|
type = _props$type === void 0 ? 'custom' : _props$type,
|
|
2090
2259
|
name = props.name,
|
|
2091
2260
|
initialValue = props.initialValue,
|
|
@@ -2124,8 +2293,10 @@ var FormFieldInputNumber = /*#__PURE__*/React.memo(function FormFieldInputNumber
|
|
|
2124
2293
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
2125
2294
|
inputProps: inputProps
|
|
2126
2295
|
});
|
|
2296
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2127
2297
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2128
2298
|
className: clsx('form-field_input-number', 'form__item_input-number', classNameGroupItem),
|
|
2299
|
+
dataTestId: dataTestIdField,
|
|
2129
2300
|
errorKey: errorKey,
|
|
2130
2301
|
errorMessage: errorMessage,
|
|
2131
2302
|
fieldClassName: "form-input-number",
|
|
@@ -2140,7 +2311,7 @@ var FormFieldInputNumber = /*#__PURE__*/React.memo(function FormFieldInputNumber
|
|
|
2140
2311
|
isValidState: isValidState
|
|
2141
2312
|
}, fieldProps), /*#__PURE__*/React.createElement(InputNumber, Object.assign({
|
|
2142
2313
|
className: clsx(meta.active && 'input_state_focus', (meta.submitFailed || meta.touched) && meta.error && "input_state_" + errorKey),
|
|
2143
|
-
dataTestId:
|
|
2314
|
+
dataTestId: dataTestIdField + "InputNumber",
|
|
2144
2315
|
type: type,
|
|
2145
2316
|
name: input.name,
|
|
2146
2317
|
value: input.value || 0,
|
|
@@ -2150,7 +2321,8 @@ var FormFieldInputNumber = /*#__PURE__*/React.memo(function FormFieldInputNumber
|
|
|
2150
2321
|
});
|
|
2151
2322
|
|
|
2152
2323
|
var FormFieldMaskedInput = /*#__PURE__*/React.memo(function FormFieldMaskedInput(props) {
|
|
2153
|
-
var
|
|
2324
|
+
var dataTestId = props.dataTestId,
|
|
2325
|
+
name = props.name,
|
|
2154
2326
|
initialValue = props.initialValue,
|
|
2155
2327
|
classNameGroupItem = props.classNameGroupItem,
|
|
2156
2328
|
clearIcon = props.clearIcon,
|
|
@@ -2212,8 +2384,10 @@ var FormFieldMaskedInput = /*#__PURE__*/React.memo(function FormFieldMaskedInput
|
|
|
2212
2384
|
inputProps: inputProps,
|
|
2213
2385
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2214
2386
|
});
|
|
2387
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2215
2388
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2216
2389
|
className: clsx('form-field-masked-input', 'form__item_masked-input', classNameGroupItem),
|
|
2390
|
+
dataTestId: dataTestIdField,
|
|
2217
2391
|
errorKey: errorKey,
|
|
2218
2392
|
errorMessage: errorMessage,
|
|
2219
2393
|
fieldClassName: 'form-maskedInput',
|
|
@@ -2257,7 +2431,8 @@ var defaultPasswordProps = {
|
|
|
2257
2431
|
};
|
|
2258
2432
|
|
|
2259
2433
|
var FormFieldPassword = /*#__PURE__*/React.memo(function FormFieldPassword(props) {
|
|
2260
|
-
var
|
|
2434
|
+
var dataTestId = props.dataTestId,
|
|
2435
|
+
name = props.name,
|
|
2261
2436
|
initialValue = props.initialValue,
|
|
2262
2437
|
classNameGroupItem = props.classNameGroupItem,
|
|
2263
2438
|
fieldProps = props.fieldProps,
|
|
@@ -2301,13 +2476,15 @@ var FormFieldPassword = /*#__PURE__*/React.memo(function FormFieldPassword(props
|
|
|
2301
2476
|
inputProps: inputProps,
|
|
2302
2477
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2303
2478
|
});
|
|
2479
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2304
2480
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2305
|
-
className: clsx(
|
|
2481
|
+
className: clsx('form-field_input-password', 'form__item_input-password', classNameGroupItem),
|
|
2482
|
+
dataTestId: dataTestIdField,
|
|
2306
2483
|
errorKey: errorKey,
|
|
2307
2484
|
errorMessage: errorMessage,
|
|
2308
2485
|
fieldClassName: "form-password",
|
|
2309
2486
|
inputName: input.name,
|
|
2310
|
-
inputValue: input.value ||
|
|
2487
|
+
inputValue: input.value || '',
|
|
2311
2488
|
metaActive: meta.active,
|
|
2312
2489
|
metaError: meta.error,
|
|
2313
2490
|
showMessage: showMessage,
|
|
@@ -2316,11 +2493,11 @@ var FormFieldPassword = /*#__PURE__*/React.memo(function FormFieldPassword(props
|
|
|
2316
2493
|
isRequired: isRequired,
|
|
2317
2494
|
isValidState: isValidState
|
|
2318
2495
|
}, fieldProps), /*#__PURE__*/React.createElement(InputPassword, Object.assign({
|
|
2319
|
-
className: clsx(meta.active &&
|
|
2320
|
-
dataTestId:
|
|
2496
|
+
className: clsx(meta.active && 'input-password_state_focus', meta.error && meta.touched && "input-password_state_" + errorKey),
|
|
2497
|
+
dataTestId: dataTestIdField + "InputPassword",
|
|
2321
2498
|
name: input.name,
|
|
2322
2499
|
autoComplete: "nope",
|
|
2323
|
-
value: input.value ||
|
|
2500
|
+
value: input.value || '',
|
|
2324
2501
|
isDisabled: isDisabled,
|
|
2325
2502
|
onBlur: input.onBlur,
|
|
2326
2503
|
onChange: onChangeField,
|
|
@@ -2372,8 +2549,9 @@ function FormFieldRadioGroupList(props) {
|
|
|
2372
2549
|
}
|
|
2373
2550
|
|
|
2374
2551
|
var FormFieldRadioGroup = /*#__PURE__*/React.memo(function FormFieldRadioGroup(props) {
|
|
2375
|
-
var
|
|
2376
|
-
|
|
2552
|
+
var dataTestId = props.dataTestId,
|
|
2553
|
+
name = props.name,
|
|
2554
|
+
classNameGroupItem = props.classNameGroupItem,
|
|
2377
2555
|
_props$editableProps = props.editableProps,
|
|
2378
2556
|
editableProps = _props$editableProps === void 0 ? {} : _props$editableProps,
|
|
2379
2557
|
_props$fieldProps = props.fieldProps,
|
|
@@ -2382,8 +2560,8 @@ var FormFieldRadioGroup = /*#__PURE__*/React.memo(function FormFieldRadioGroup(p
|
|
|
2382
2560
|
inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
|
|
2383
2561
|
_props$options = props.options,
|
|
2384
2562
|
options = _props$options === void 0 ? [] : _props$options,
|
|
2385
|
-
classNameGroupItem = props.classNameGroupItem,
|
|
2386
2563
|
showMessage = props.showMessage,
|
|
2564
|
+
isDisabled = props.isDisabled,
|
|
2387
2565
|
isRequired = props.isRequired,
|
|
2388
2566
|
onChange = props.onChange;
|
|
2389
2567
|
return /*#__PURE__*/React.createElement(Field, {
|
|
@@ -2411,26 +2589,28 @@ var FormFieldRadioGroup = /*#__PURE__*/React.memo(function FormFieldRadioGroup(p
|
|
|
2411
2589
|
inputProps: inputProps,
|
|
2412
2590
|
validationStateKey: isErrorState ? errorKey : 'success'
|
|
2413
2591
|
});
|
|
2592
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2414
2593
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2415
2594
|
className: clsx('form-field_radio', 'form__item_radio', classNameGroupItem),
|
|
2595
|
+
dataTestId: dataTestIdField,
|
|
2416
2596
|
errorKey: errorKey,
|
|
2417
2597
|
errorMessage: errorMessage,
|
|
2418
|
-
isErrorState: isErrorState,
|
|
2419
|
-
metaError: meta.error,
|
|
2420
|
-
isDisabled: isDisabled,
|
|
2421
2598
|
fieldClassName: 'form-radio',
|
|
2422
2599
|
inputName: input.name,
|
|
2423
2600
|
inputValue: input.value || '',
|
|
2424
2601
|
metaActive: meta.active,
|
|
2602
|
+
metaError: meta.error,
|
|
2425
2603
|
showMessage: showMessage,
|
|
2604
|
+
isDisabled: isDisabled,
|
|
2605
|
+
isErrorState: isErrorState,
|
|
2426
2606
|
isRequired: isRequired,
|
|
2427
2607
|
isValidState: isValidState
|
|
2428
2608
|
}, fieldProps), /*#__PURE__*/React.createElement(FormFieldRadioGroupList, {
|
|
2429
|
-
isDisabled: isDisabled,
|
|
2430
2609
|
editableProps: editableProps,
|
|
2431
2610
|
input: input,
|
|
2432
2611
|
inputProps: updatedInputProps,
|
|
2433
2612
|
options: options,
|
|
2613
|
+
isDisabled: isDisabled,
|
|
2434
2614
|
onChange: onChange
|
|
2435
2615
|
}));
|
|
2436
2616
|
});
|
|
@@ -2447,12 +2627,13 @@ var defaultSegmentedProps = {
|
|
|
2447
2627
|
};
|
|
2448
2628
|
|
|
2449
2629
|
function FormFieldSegmented(props) {
|
|
2450
|
-
var
|
|
2451
|
-
|
|
2630
|
+
var dataTestId = props.dataTestId,
|
|
2631
|
+
name = props.name,
|
|
2452
2632
|
fieldProps = props.fieldProps,
|
|
2453
2633
|
inputProps = props.inputProps,
|
|
2454
2634
|
options = props.options,
|
|
2455
2635
|
showMessage = props.showMessage,
|
|
2636
|
+
isDisabled = props.isDisabled,
|
|
2456
2637
|
isRequired = props.isRequired;
|
|
2457
2638
|
var _useForm = useForm(),
|
|
2458
2639
|
change = _useForm.change;
|
|
@@ -2491,31 +2672,33 @@ function FormFieldSegmented(props) {
|
|
|
2491
2672
|
}),
|
|
2492
2673
|
errorKey = _useFieldValidationSt.errorKey,
|
|
2493
2674
|
errorMessage = _useFieldValidationSt.errorMessage,
|
|
2494
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
2495
2675
|
successKey = _useFieldValidationSt.successKey,
|
|
2676
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
2496
2677
|
isValidState = _useFieldValidationSt.isValidState;
|
|
2497
2678
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
2498
2679
|
inputProps: inputProps,
|
|
2499
2680
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2500
2681
|
});
|
|
2682
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2501
2683
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2502
2684
|
className: clsx('form-field_segmented', 'form__item_segmented'),
|
|
2685
|
+
dataTestId: dataTestIdField,
|
|
2503
2686
|
errorKey: errorKey,
|
|
2504
2687
|
errorMessage: errorMessage,
|
|
2505
|
-
isErrorState: isErrorState,
|
|
2506
|
-
metaError: meta.error,
|
|
2507
|
-
isDisabled: isDisabled,
|
|
2508
2688
|
fieldClassName: "form-segmented",
|
|
2509
2689
|
inputName: input.name,
|
|
2510
2690
|
inputValue: input.value || [],
|
|
2511
2691
|
metaActive: meta.active,
|
|
2692
|
+
metaError: meta.error,
|
|
2512
2693
|
showMessage: showMessage,
|
|
2694
|
+
isDisabled: isDisabled,
|
|
2695
|
+
isErrorState: isErrorState,
|
|
2513
2696
|
isRequired: isRequired,
|
|
2514
2697
|
isValidState: isValidState
|
|
2515
2698
|
}, fieldProps), /*#__PURE__*/React.createElement(Segmented, Object.assign({
|
|
2516
|
-
isDisabled: isDisabled,
|
|
2517
2699
|
activeSegment: activeOption,
|
|
2518
2700
|
segments: options,
|
|
2701
|
+
isDisabled: isDisabled,
|
|
2519
2702
|
setActiveSegment: setActiveSegment
|
|
2520
2703
|
}, updatedInputProps)));
|
|
2521
2704
|
});
|
|
@@ -2551,17 +2734,18 @@ function getDefaultValue(options, selectValue) {
|
|
|
2551
2734
|
return result;
|
|
2552
2735
|
}
|
|
2553
2736
|
var FormFieldSelect = /*#__PURE__*/React.memo(function FormFieldSelect(props) {
|
|
2554
|
-
var
|
|
2555
|
-
|
|
2737
|
+
var dataTestId = props.dataTestId,
|
|
2738
|
+
name = props.name,
|
|
2739
|
+
initialValue = props.initialValue,
|
|
2556
2740
|
classNameGroupItem = props.classNameGroupItem,
|
|
2557
2741
|
fieldProps = props.fieldProps,
|
|
2558
|
-
initialValue = props.initialValue,
|
|
2559
|
-
name = props.name,
|
|
2560
2742
|
_props$options = props.options,
|
|
2561
2743
|
options = _props$options === void 0 ? [] : _props$options,
|
|
2562
2744
|
selectProps = props.selectProps,
|
|
2563
2745
|
selectRef = props.selectRef,
|
|
2564
2746
|
showMessage = props.showMessage,
|
|
2747
|
+
isDisabled = props.isDisabled,
|
|
2748
|
+
isRequired = props.isRequired,
|
|
2565
2749
|
onChange = props.onChange,
|
|
2566
2750
|
onInputChange = props.onInputChange;
|
|
2567
2751
|
return /*#__PURE__*/React.createElement(Field, {
|
|
@@ -2613,34 +2797,36 @@ var FormFieldSelect = /*#__PURE__*/React.memo(function FormFieldSelect(props) {
|
|
|
2613
2797
|
}),
|
|
2614
2798
|
errorKey = _useFieldValidationSt.errorKey,
|
|
2615
2799
|
errorMessage = _useFieldValidationSt.errorMessage,
|
|
2616
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
2617
2800
|
successKey = _useFieldValidationSt.successKey,
|
|
2801
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
2618
2802
|
isValidState = _useFieldValidationSt.isValidState;
|
|
2619
2803
|
var updatedSelectProps = useValidationAppearanceInputProps({
|
|
2620
2804
|
inputProps: selectProps,
|
|
2621
2805
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2622
2806
|
});
|
|
2807
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2623
2808
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2624
2809
|
className: clsx('form-field_select', 'form__item_select', classNameGroupItem),
|
|
2810
|
+
dataTestId: dataTestIdField,
|
|
2625
2811
|
errorKey: errorKey,
|
|
2626
2812
|
errorMessage: errorMessage,
|
|
2627
|
-
isErrorState: isErrorState,
|
|
2628
|
-
metaError: meta.error,
|
|
2629
|
-
isDisabled: isDisabled,
|
|
2630
2813
|
fieldClassName: 'form-select',
|
|
2631
2814
|
inputName: input.name,
|
|
2632
2815
|
inputValue: input.value,
|
|
2633
2816
|
metaActive: meta.active,
|
|
2817
|
+
metaError: meta.error,
|
|
2634
2818
|
showMessage: showMessage,
|
|
2819
|
+
isDisabled: isDisabled,
|
|
2820
|
+
isErrorState: isErrorState,
|
|
2635
2821
|
isRequired: isRequired,
|
|
2636
2822
|
isValidState: isValidState
|
|
2637
2823
|
}, fieldProps), /*#__PURE__*/React.createElement(Select, Object.assign({
|
|
2638
2824
|
className: "form-select-item",
|
|
2639
2825
|
ref: selectRef,
|
|
2640
|
-
isDisabled: isDisabled,
|
|
2641
2826
|
instanceId: "id_" + input.name,
|
|
2642
2827
|
options: options,
|
|
2643
2828
|
value: selectedOptions,
|
|
2829
|
+
isDisabled: isDisabled,
|
|
2644
2830
|
onChange: onChangeValue,
|
|
2645
2831
|
onInputChange: onInputChange
|
|
2646
2832
|
}, updatedSelectProps)));
|
|
@@ -2655,14 +2841,15 @@ var defaultSwitchProps = {
|
|
|
2655
2841
|
};
|
|
2656
2842
|
|
|
2657
2843
|
var FormFieldSwitch = /*#__PURE__*/React.memo(function FormFieldSwitch(props) {
|
|
2658
|
-
var
|
|
2659
|
-
|
|
2844
|
+
var dataTestId = props.dataTestId,
|
|
2845
|
+
name = props.name,
|
|
2660
2846
|
classNameGroupItem = props.classNameGroupItem,
|
|
2661
2847
|
_props$fieldProps = props.fieldProps,
|
|
2662
2848
|
fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
|
|
2663
2849
|
_props$inputProps = props.inputProps,
|
|
2664
2850
|
inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
|
|
2665
2851
|
showMessage = props.showMessage,
|
|
2852
|
+
isDisabled = props.isDisabled,
|
|
2666
2853
|
isRequired = props.isRequired,
|
|
2667
2854
|
onChange = props.onChange;
|
|
2668
2855
|
return /*#__PURE__*/React.createElement(Field, {
|
|
@@ -2691,34 +2878,36 @@ var FormFieldSwitch = /*#__PURE__*/React.memo(function FormFieldSwitch(props) {
|
|
|
2691
2878
|
}),
|
|
2692
2879
|
errorKey = _useFieldValidationSt.errorKey,
|
|
2693
2880
|
errorMessage = _useFieldValidationSt.errorMessage,
|
|
2694
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
2695
2881
|
successKey = _useFieldValidationSt.successKey,
|
|
2882
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
2696
2883
|
isValidState = _useFieldValidationSt.isValidState;
|
|
2697
2884
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
2698
2885
|
inputProps: inputProps,
|
|
2699
2886
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2700
2887
|
});
|
|
2888
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2701
2889
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2702
2890
|
className: clsx('form-field-switch', 'form__item_switch', classNameGroupItem),
|
|
2891
|
+
dataTestId: dataTestIdField,
|
|
2703
2892
|
errorKey: errorKey,
|
|
2704
2893
|
errorMessage: errorMessage,
|
|
2705
|
-
isErrorState: isErrorState,
|
|
2706
|
-
metaError: meta.error,
|
|
2707
|
-
isDisabled: isDisabled,
|
|
2708
2894
|
fieldClassName: "form-switch",
|
|
2709
2895
|
inputName: input.name,
|
|
2710
2896
|
inputValue: input.checked,
|
|
2711
2897
|
metaActive: meta.active,
|
|
2898
|
+
metaError: meta.error,
|
|
2712
2899
|
showMessage: showMessage,
|
|
2713
2900
|
tag: "label",
|
|
2901
|
+
isDisabled: isDisabled,
|
|
2902
|
+
isErrorState: isErrorState,
|
|
2714
2903
|
isRequired: isRequired,
|
|
2715
2904
|
isValidState: isValidState
|
|
2716
2905
|
}, fieldProps), /*#__PURE__*/React.createElement(Switch, Object.assign({
|
|
2717
2906
|
type: "checkbox",
|
|
2718
2907
|
name: input.name,
|
|
2719
|
-
isDisabled: isDisabled,
|
|
2720
2908
|
autoComplete: "nope",
|
|
2721
2909
|
isActive: input.checked,
|
|
2910
|
+
isDisabled: isDisabled,
|
|
2722
2911
|
onBlur: input.onBlur,
|
|
2723
2912
|
onChange: onChangeField,
|
|
2724
2913
|
onFocus: input.onFocus
|
|
@@ -2738,7 +2927,8 @@ var defaultTextareaProps = {
|
|
|
2738
2927
|
};
|
|
2739
2928
|
|
|
2740
2929
|
var FormFieldTextarea = /*#__PURE__*/React.memo(function FormFieldTextarea(props) {
|
|
2741
|
-
var
|
|
2930
|
+
var dataTestId = props.dataTestId,
|
|
2931
|
+
name = props.name,
|
|
2742
2932
|
classNameGroupItem = props.classNameGroupItem,
|
|
2743
2933
|
_props$fieldProps = props.fieldProps,
|
|
2744
2934
|
fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
|
|
@@ -2773,11 +2963,13 @@ var FormFieldTextarea = /*#__PURE__*/React.memo(function FormFieldTextarea(props
|
|
|
2773
2963
|
inputProps: inputProps,
|
|
2774
2964
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2775
2965
|
});
|
|
2966
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2776
2967
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2777
|
-
className: clsx(
|
|
2968
|
+
className: clsx('form-field_textarea', 'form__item_textarea', classNameGroupItem),
|
|
2969
|
+
dataTestId: dataTestIdField,
|
|
2778
2970
|
errorKey: errorKey,
|
|
2779
2971
|
errorMessage: errorMessage,
|
|
2780
|
-
fieldClassName:
|
|
2972
|
+
fieldClassName: 'form-textarea',
|
|
2781
2973
|
inputName: input.name,
|
|
2782
2974
|
inputValue: input.value,
|
|
2783
2975
|
metaActive: meta.active,
|
|
@@ -2788,11 +2980,11 @@ var FormFieldTextarea = /*#__PURE__*/React.memo(function FormFieldTextarea(props
|
|
|
2788
2980
|
isRequired: isRequired,
|
|
2789
2981
|
isValidState: isValidState
|
|
2790
2982
|
}, fieldProps), /*#__PURE__*/React.createElement(Textarea, Object.assign({
|
|
2791
|
-
className: clsx(meta.active &&
|
|
2792
|
-
dataTestId:
|
|
2983
|
+
className: clsx(meta.active && 'textarea_state_focus', meta.error && meta.touched && "textarea_state_" + errorKey),
|
|
2984
|
+
dataTestId: dataTestIdField + "Textarea",
|
|
2793
2985
|
name: input.name,
|
|
2794
2986
|
autoComplete: "nope",
|
|
2795
|
-
value: input.value ||
|
|
2987
|
+
value: input.value || '',
|
|
2796
2988
|
isDisabled: isDisabled,
|
|
2797
2989
|
onBlur: input.onBlur,
|
|
2798
2990
|
onChange: input.onChange,
|
|
@@ -2822,115 +3014,151 @@ var formTypes = {
|
|
|
2822
3014
|
select: 'select',
|
|
2823
3015
|
"switch": 'switch'
|
|
2824
3016
|
};
|
|
2825
|
-
function generateField(field, config,
|
|
3017
|
+
function generateField(field, config, dataTestId) {
|
|
2826
3018
|
switch (field.type) {
|
|
2827
3019
|
case formTypes.password:
|
|
2828
3020
|
{
|
|
2829
3021
|
return /*#__PURE__*/React.createElement(FormFieldPassword, Object.assign({
|
|
2830
3022
|
key: config.key
|
|
2831
|
-
}, field,
|
|
3023
|
+
}, field, {
|
|
3024
|
+
dataTestId: dataTestId
|
|
3025
|
+
}));
|
|
2832
3026
|
}
|
|
2833
3027
|
case formTypes.checkbox:
|
|
2834
3028
|
{
|
|
2835
3029
|
return /*#__PURE__*/React.createElement(FormFieldCheckbox, Object.assign({
|
|
2836
3030
|
key: config.key
|
|
2837
|
-
}, field,
|
|
3031
|
+
}, field, {
|
|
3032
|
+
dataTestId: dataTestId
|
|
3033
|
+
}));
|
|
2838
3034
|
}
|
|
2839
3035
|
case formTypes.choice:
|
|
2840
3036
|
{
|
|
2841
3037
|
return /*#__PURE__*/React.createElement(FormFieldChoice, Object.assign({
|
|
2842
3038
|
key: config.key
|
|
2843
|
-
}, field,
|
|
3039
|
+
}, field, {
|
|
3040
|
+
dataTestId: dataTestId
|
|
3041
|
+
}));
|
|
2844
3042
|
}
|
|
2845
3043
|
case formTypes.code:
|
|
2846
3044
|
{
|
|
2847
3045
|
return /*#__PURE__*/React.createElement(FormFieldCode, Object.assign({
|
|
2848
3046
|
key: config.key
|
|
2849
|
-
}, field,
|
|
3047
|
+
}, field, {
|
|
3048
|
+
dataTestId: dataTestId
|
|
3049
|
+
}));
|
|
2850
3050
|
}
|
|
2851
3051
|
case formTypes.chips:
|
|
2852
3052
|
{
|
|
2853
3053
|
return /*#__PURE__*/React.createElement(FormFieldChips, Object.assign({
|
|
2854
3054
|
key: config.key
|
|
2855
|
-
}, field,
|
|
3055
|
+
}, field, {
|
|
3056
|
+
dataTestId: dataTestId
|
|
3057
|
+
}));
|
|
2856
3058
|
}
|
|
2857
3059
|
case formTypes["switch"]:
|
|
2858
3060
|
{
|
|
2859
3061
|
return /*#__PURE__*/React.createElement(FormFieldSwitch, Object.assign({
|
|
2860
3062
|
key: config.key
|
|
2861
|
-
}, field,
|
|
3063
|
+
}, field, {
|
|
3064
|
+
dataTestId: dataTestId
|
|
3065
|
+
}));
|
|
2862
3066
|
}
|
|
2863
3067
|
case formTypes.segmented:
|
|
2864
3068
|
{
|
|
2865
3069
|
return /*#__PURE__*/React.createElement(FormFieldSegmented, Object.assign({
|
|
2866
3070
|
key: config.key
|
|
2867
|
-
}, field,
|
|
3071
|
+
}, field, {
|
|
3072
|
+
dataTestId: dataTestId
|
|
3073
|
+
}));
|
|
2868
3074
|
}
|
|
2869
3075
|
case formTypes.datePicker:
|
|
2870
3076
|
{
|
|
2871
3077
|
return /*#__PURE__*/React.createElement(FormFieldDatePicker, Object.assign({
|
|
2872
3078
|
key: config.key
|
|
2873
|
-
}, field,
|
|
3079
|
+
}, field, {
|
|
3080
|
+
dataTestId: dataTestId
|
|
3081
|
+
}));
|
|
2874
3082
|
}
|
|
2875
3083
|
case formTypes.fileInput:
|
|
2876
3084
|
{
|
|
2877
3085
|
return /*#__PURE__*/React.createElement(FormFieldFileInput, Object.assign({
|
|
2878
3086
|
key: config.key
|
|
2879
|
-
}, field,
|
|
3087
|
+
}, field, {
|
|
3088
|
+
dataTestId: dataTestId
|
|
3089
|
+
}));
|
|
2880
3090
|
}
|
|
2881
3091
|
case formTypes.radioGroup:
|
|
2882
3092
|
{
|
|
2883
3093
|
return /*#__PURE__*/React.createElement(FormFieldRadioGroup, Object.assign({
|
|
2884
3094
|
key: config.key
|
|
2885
|
-
}, field,
|
|
3095
|
+
}, field, {
|
|
3096
|
+
dataTestId: dataTestId
|
|
3097
|
+
}));
|
|
2886
3098
|
}
|
|
2887
3099
|
case formTypes.select:
|
|
2888
3100
|
{
|
|
2889
3101
|
return /*#__PURE__*/React.createElement(FormFieldSelect, Object.assign({
|
|
2890
3102
|
key: config.key
|
|
2891
|
-
}, field,
|
|
3103
|
+
}, field, {
|
|
3104
|
+
dataTestId: dataTestId
|
|
3105
|
+
}));
|
|
2892
3106
|
}
|
|
2893
3107
|
case formTypes.text:
|
|
2894
3108
|
{
|
|
2895
3109
|
return /*#__PURE__*/React.createElement(FormFieldInput, Object.assign({
|
|
2896
3110
|
key: config.key
|
|
2897
|
-
}, field,
|
|
3111
|
+
}, field, {
|
|
3112
|
+
dataTestId: dataTestId
|
|
3113
|
+
}));
|
|
2898
3114
|
}
|
|
2899
3115
|
case formTypes.textarea:
|
|
2900
3116
|
{
|
|
2901
3117
|
return /*#__PURE__*/React.createElement(FormFieldTextarea, Object.assign({
|
|
2902
3118
|
key: config.key
|
|
2903
|
-
}, field,
|
|
3119
|
+
}, field, {
|
|
3120
|
+
dataTestId: dataTestId
|
|
3121
|
+
}));
|
|
2904
3122
|
}
|
|
2905
3123
|
case formTypes.maskedInput:
|
|
2906
3124
|
{
|
|
2907
3125
|
return /*#__PURE__*/React.createElement(FormFieldMaskedInput, Object.assign({
|
|
2908
3126
|
key: config.key
|
|
2909
|
-
}, field,
|
|
3127
|
+
}, field, {
|
|
3128
|
+
dataTestId: dataTestId
|
|
3129
|
+
}));
|
|
2910
3130
|
}
|
|
2911
3131
|
case formTypes.custom:
|
|
2912
3132
|
{
|
|
2913
3133
|
return /*#__PURE__*/React.createElement(FormFieldCustom, Object.assign({
|
|
2914
3134
|
key: config.key
|
|
2915
|
-
}, field,
|
|
3135
|
+
}, field, {
|
|
3136
|
+
dataTestId: dataTestId
|
|
3137
|
+
}));
|
|
2916
3138
|
}
|
|
2917
3139
|
case formTypes.dadataInput:
|
|
2918
3140
|
{
|
|
2919
3141
|
return /*#__PURE__*/React.createElement(FormFieldDadataInput, Object.assign({
|
|
2920
3142
|
key: config.key
|
|
2921
|
-
}, field,
|
|
3143
|
+
}, field, {
|
|
3144
|
+
dataTestId: dataTestId
|
|
3145
|
+
}));
|
|
2922
3146
|
}
|
|
2923
3147
|
case formTypes.inputNumber:
|
|
2924
3148
|
{
|
|
2925
3149
|
return /*#__PURE__*/React.createElement(FormFieldInputNumber, Object.assign({
|
|
2926
3150
|
key: config.key
|
|
2927
|
-
}, field,
|
|
3151
|
+
}, field, {
|
|
3152
|
+
dataTestId: dataTestId
|
|
3153
|
+
}));
|
|
2928
3154
|
}
|
|
2929
3155
|
case formTypes.group:
|
|
2930
3156
|
{
|
|
2931
3157
|
return /*#__PURE__*/React.createElement(FormBlockGroup, Object.assign({
|
|
2932
3158
|
key: config.key
|
|
2933
|
-
}, field,
|
|
3159
|
+
}, field, {
|
|
3160
|
+
dataTestId: dataTestId
|
|
3161
|
+
}), Object.entries(field.group).map(function (_ref) {
|
|
2934
3162
|
var key = _ref[0],
|
|
2935
3163
|
value = _ref[1];
|
|
2936
3164
|
var groupProps = Object.assign({}, value, {
|
|
@@ -2939,147 +3167,17 @@ function generateField(field, config, props) {
|
|
|
2939
3167
|
});
|
|
2940
3168
|
return generateField(groupProps, {
|
|
2941
3169
|
key: key + '_form_group'
|
|
2942
|
-
},
|
|
3170
|
+
}, dataTestId);
|
|
2943
3171
|
}));
|
|
2944
3172
|
}
|
|
2945
3173
|
}
|
|
2946
3174
|
}
|
|
2947
3175
|
|
|
2948
|
-
var focusOnError = function focusOnError(formElementsList, errors) {
|
|
2949
|
-
var selectsIds = Object.keys(errors).map(function (fieldName) {
|
|
2950
|
-
if (fieldName === FORM_ERROR) {
|
|
2951
|
-
// TODO: get from somewhere
|
|
2952
|
-
return 'notification__item_status_error';
|
|
2953
|
-
}
|
|
2954
|
-
return "react-select-id_" + fieldName + "-input";
|
|
2955
|
-
});
|
|
2956
|
-
var errorFieldElement = formElementsList.find(function (element) {
|
|
2957
|
-
if (element.name) {
|
|
2958
|
-
return getIn(errors, element.name);
|
|
2959
|
-
} else {
|
|
2960
|
-
return selectsIds.includes(element.id);
|
|
2961
|
-
}
|
|
2962
|
-
});
|
|
2963
|
-
var errorsList = Object.keys(errors);
|
|
2964
|
-
if (!errorFieldElement && errorsList.length) {
|
|
2965
|
-
var errorElement;
|
|
2966
|
-
try {
|
|
2967
|
-
var fieldName = errorsList[0];
|
|
2968
|
-
if (fieldName === FORM_ERROR) {
|
|
2969
|
-
errorElement = document.querySelector('notification__item_status_error');
|
|
2970
|
-
} else {
|
|
2971
|
-
errorElement = document.querySelector("#" + fieldName + "-error");
|
|
2972
|
-
if (!errorElement) {
|
|
2973
|
-
errorElement = document.querySelector("#id_" + fieldName);
|
|
2974
|
-
}
|
|
2975
|
-
}
|
|
2976
|
-
} catch (err) {
|
|
2977
|
-
console.warn(err);
|
|
2978
|
-
}
|
|
2979
|
-
if (errorElement) {
|
|
2980
|
-
errorElement.scrollIntoView({
|
|
2981
|
-
block: 'center'
|
|
2982
|
-
}); // , behavior: 'smooth'
|
|
2983
|
-
}
|
|
2984
|
-
}
|
|
2985
|
-
|
|
2986
|
-
// The field is covered by the header because header is "sticky",
|
|
2987
|
-
// that's we scroll manually so that the field falls into the center of the visible area
|
|
2988
|
-
if (errorFieldElement) {
|
|
2989
|
-
errorFieldElement.scrollIntoView({
|
|
2990
|
-
block: 'center'
|
|
2991
|
-
});
|
|
2992
|
-
}
|
|
2993
|
-
return null;
|
|
2994
|
-
};
|
|
2995
|
-
var focusOnErrorDecorator = createDecorator(null, focusOnError);
|
|
2996
|
-
var setErrorsMutator = function setErrorsMutator(args, state) {
|
|
2997
|
-
var fieldName = args[0],
|
|
2998
|
-
data = args[1];
|
|
2999
|
-
var submitError = data.submitError;
|
|
3000
|
-
var fieldError = data.error;
|
|
3001
|
-
if (fieldName === 'non_field_errors' || fieldName === FORM_ERROR) {
|
|
3002
|
-
// state.formState.invalid = true
|
|
3003
|
-
// state.formState.valid = false
|
|
3004
|
-
state.formState.error = fieldError;
|
|
3005
|
-
state.formState.submitError = submitError;
|
|
3006
|
-
} else if (fieldName in state.fields) {
|
|
3007
|
-
state.fields[fieldName].touched = true;
|
|
3008
|
-
|
|
3009
|
-
// TODO: make clear error not by empty string check
|
|
3010
|
-
if (fieldError || fieldError === '') {
|
|
3011
|
-
var _Object$assign;
|
|
3012
|
-
var errorsState = Object.assign({}, state.formState.errors, (_Object$assign = {}, _Object$assign[fieldName] = fieldError, _Object$assign));
|
|
3013
|
-
state.fields[fieldName].error = fieldError;
|
|
3014
|
-
state.formState.errors = errorsState;
|
|
3015
|
-
}
|
|
3016
|
-
|
|
3017
|
-
// TODO: make clear error not by empty string check
|
|
3018
|
-
if (submitError || submitError === '') {
|
|
3019
|
-
var _Object$assign2;
|
|
3020
|
-
var submitErrorsState = Object.assign({}, state.formState.submitErrors, (_Object$assign2 = {}, _Object$assign2[fieldName] = submitError, _Object$assign2));
|
|
3021
|
-
state.fields[fieldName].submitFailed = true;
|
|
3022
|
-
state.fields[fieldName].submitSucceeded = false;
|
|
3023
|
-
state.fields[fieldName].submitError = submitError;
|
|
3024
|
-
state.formState.submitErrors = submitErrorsState;
|
|
3025
|
-
state.formState.submitFailed = true;
|
|
3026
|
-
state.formState.submitSucceeded = false;
|
|
3027
|
-
state.formState.lastSubmittedValues = state.formState.values;
|
|
3028
|
-
}
|
|
3029
|
-
}
|
|
3030
|
-
};
|
|
3031
|
-
var sendFormDataToServer = /*#__PURE__*/function () {
|
|
3032
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(url, data) {
|
|
3033
|
-
var response, _error$response, _error$response2, formErrors, _t;
|
|
3034
|
-
return _regenerator().w(function (_context) {
|
|
3035
|
-
while (1) switch (_context.p = _context.n) {
|
|
3036
|
-
case 0:
|
|
3037
|
-
_context.p = 0;
|
|
3038
|
-
_context.n = 1;
|
|
3039
|
-
return axios({
|
|
3040
|
-
url: url,
|
|
3041
|
-
method: 'POST',
|
|
3042
|
-
data: data
|
|
3043
|
-
});
|
|
3044
|
-
case 1:
|
|
3045
|
-
response = _context.v;
|
|
3046
|
-
return _context.a(2, {
|
|
3047
|
-
success: true,
|
|
3048
|
-
response: response
|
|
3049
|
-
});
|
|
3050
|
-
case 2:
|
|
3051
|
-
_context.p = 2;
|
|
3052
|
-
_t = _context.v;
|
|
3053
|
-
formErrors = {};
|
|
3054
|
-
if (typeof ((_error$response = _t.response) == null ? void 0 : _error$response.data) === 'string') {
|
|
3055
|
-
formErrors[FORM_ERROR] = 'Something went wrong';
|
|
3056
|
-
}
|
|
3057
|
-
if (typeof ((_error$response2 = _t.response) == null ? void 0 : _error$response2.data) === 'object') {
|
|
3058
|
-
Object.entries(_t.response.data).forEach(function (_ref2) {
|
|
3059
|
-
var fieldName = _ref2[0],
|
|
3060
|
-
errorsList = _ref2[1];
|
|
3061
|
-
formErrors[fieldName] = errorsList[0];
|
|
3062
|
-
});
|
|
3063
|
-
}
|
|
3064
|
-
return _context.a(2, {
|
|
3065
|
-
error: _t,
|
|
3066
|
-
success: false,
|
|
3067
|
-
formErrors: formErrors
|
|
3068
|
-
});
|
|
3069
|
-
}
|
|
3070
|
-
}, _callee, null, [[0, 2]]);
|
|
3071
|
-
}));
|
|
3072
|
-
return function sendFormDataToServer(_x, _x2) {
|
|
3073
|
-
return _ref.apply(this, arguments);
|
|
3074
|
-
};
|
|
3075
|
-
}();
|
|
3076
|
-
|
|
3077
3176
|
var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
3078
3177
|
var className = props.className,
|
|
3079
3178
|
dataTestId = props.dataTestId,
|
|
3080
3179
|
dataTour = props.dataTour,
|
|
3081
3180
|
type = props.type,
|
|
3082
|
-
name = props.name,
|
|
3083
3181
|
initialValues = props.initialValues,
|
|
3084
3182
|
initialValuesEqual = props.initialValuesEqual,
|
|
3085
3183
|
config = props.config,
|
|
@@ -3094,11 +3192,10 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3094
3192
|
descSize = props.descSize,
|
|
3095
3193
|
descTextColor = props.descTextColor,
|
|
3096
3194
|
descTextWeight = props.descTextWeight,
|
|
3097
|
-
buttonGap = props.buttonGap
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
_props$buttonDirectio
|
|
3101
|
-
buttonDirection = _props$buttonDirectio === void 0 ? "vertical" : _props$buttonDirectio,
|
|
3195
|
+
buttonGap = props.buttonGap;
|
|
3196
|
+
props.additionalProps;
|
|
3197
|
+
var _props$buttonDirectio = props.buttonDirection,
|
|
3198
|
+
buttonDirection = _props$buttonDirectio === void 0 ? 'vertical' : _props$buttonDirectio,
|
|
3102
3199
|
buttonFill = props.buttonFill,
|
|
3103
3200
|
buttonJustifyContent = props.buttonJustifyContent,
|
|
3104
3201
|
buttonPadding = props.buttonPadding,
|
|
@@ -3114,22 +3211,21 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3114
3211
|
_props$disableFieldsA = props.disableFieldsAutoComplete,
|
|
3115
3212
|
disableFieldsAutoComplete = _props$disableFieldsA === void 0 ? false : _props$disableFieldsA,
|
|
3116
3213
|
fieldsGap = props.fieldsGap,
|
|
3117
|
-
formName = props.formName,
|
|
3118
3214
|
groupGap = props.groupGap,
|
|
3119
3215
|
heightClass = props.heightClass,
|
|
3120
3216
|
language = props.language,
|
|
3121
3217
|
loader = props.loader,
|
|
3122
3218
|
loaderAppearance = props.loaderAppearance,
|
|
3123
3219
|
_props$loaderFill = props.loaderFill,
|
|
3124
|
-
loaderFill = _props$loaderFill === void 0 ?
|
|
3220
|
+
loaderFill = _props$loaderFill === void 0 ? 'surfacePrimary' : _props$loaderFill,
|
|
3125
3221
|
_props$loaderItemFill = props.loaderItemFill,
|
|
3126
|
-
loaderItemFill = _props$loaderItemFill === void 0 ?
|
|
3222
|
+
loaderItemFill = _props$loaderItemFill === void 0 ? 'accentItemSecondary' : _props$loaderItemFill,
|
|
3127
3223
|
loaderShape = props.loaderShape,
|
|
3128
3224
|
_props$loaderSize = props.loaderSize,
|
|
3129
|
-
loaderSize = _props$loaderSize === void 0 ?
|
|
3225
|
+
loaderSize = _props$loaderSize === void 0 ? 'l' : _props$loaderSize,
|
|
3130
3226
|
loaderText = props.loaderText,
|
|
3131
3227
|
_props$loaderType = props.loaderType,
|
|
3132
|
-
loaderType = _props$loaderType === void 0 ?
|
|
3228
|
+
loaderType = _props$loaderType === void 0 ? 'dot' : _props$loaderType,
|
|
3133
3229
|
mutators = props.mutators,
|
|
3134
3230
|
notificationCloseButton = props.notificationCloseButton,
|
|
3135
3231
|
notificationType = props.notificationType,
|
|
@@ -3163,6 +3259,7 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3163
3259
|
secondaryButtonSize = props.secondaryButtonSize,
|
|
3164
3260
|
shapeStrengthClass = props.shapeStrengthClass,
|
|
3165
3261
|
tertiaryButton = props.tertiaryButton,
|
|
3262
|
+
tertiaryButtonAppearance = props.tertiaryButtonAppearance,
|
|
3166
3263
|
tertiaryButtonFill = props.tertiaryButtonFill,
|
|
3167
3264
|
tertiaryButtonFillHover = props.tertiaryButtonFillHover,
|
|
3168
3265
|
tertiaryButtonLabel = props.tertiaryButtonLabel,
|
|
@@ -3201,19 +3298,18 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3201
3298
|
modifiedSinceLastSubmit = _ref.modifiedSinceLastSubmit,
|
|
3202
3299
|
submitError = _ref.submitError;
|
|
3203
3300
|
return /*#__PURE__*/React.createElement("form", {
|
|
3204
|
-
className: clsx(className,
|
|
3205
|
-
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)
|
|
3206
3302
|
// We no need set reference to html element, we need reference to "final-form" instance
|
|
3207
3303
|
,
|
|
3208
3304
|
ref: function ref() {
|
|
3209
3305
|
return onRefFormInstance(form);
|
|
3210
3306
|
},
|
|
3211
|
-
autoCapitalize: disableFieldsAutoComplete ?
|
|
3212
|
-
autoComplete: disableFieldsAutoComplete ?
|
|
3213
|
-
autoCorrect: disableFieldsAutoComplete ?
|
|
3214
|
-
"data-testid": dataTestId ||
|
|
3307
|
+
autoCapitalize: disableFieldsAutoComplete ? 'off' : undefined,
|
|
3308
|
+
autoComplete: disableFieldsAutoComplete ? 'off' : undefined,
|
|
3309
|
+
autoCorrect: disableFieldsAutoComplete ? 'off' : undefined,
|
|
3310
|
+
"data-testid": dataTestId || 'Form',
|
|
3215
3311
|
"data-tour": dataTour,
|
|
3216
|
-
spellCheck: disableFieldsAutoComplete ?
|
|
3312
|
+
spellCheck: disableFieldsAutoComplete ? 'false' : undefined,
|
|
3217
3313
|
style: formStyles,
|
|
3218
3314
|
onSubmit: handleSubmit
|
|
3219
3315
|
}, before, title && /*#__PURE__*/React.createElement(Title, {
|
|
@@ -3221,14 +3317,16 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3221
3317
|
size: titleTextSize,
|
|
3222
3318
|
fill: titleFill,
|
|
3223
3319
|
textColor: titleTextColor,
|
|
3224
|
-
textWeight: titleTextWeight
|
|
3320
|
+
textWeight: titleTextWeight,
|
|
3321
|
+
"data-testid": dataTestId ? dataTestId + "Title" : 'FormTitle'
|
|
3225
3322
|
}, title), desc && /*#__PURE__*/React.createElement(Text, {
|
|
3226
3323
|
className: "form__desc",
|
|
3227
3324
|
size: descSize,
|
|
3228
3325
|
textColor: descTextColor,
|
|
3229
|
-
textWeight: descTextWeight
|
|
3326
|
+
textWeight: descTextWeight,
|
|
3327
|
+
"data-testid": dataTestId ? dataTestId + "Desc" : 'FormDesc'
|
|
3230
3328
|
}, desc), submitError && !modifiedSinceLastSubmit && /*#__PURE__*/React.createElement("div", {
|
|
3231
|
-
className: clsx(
|
|
3329
|
+
className: clsx('notification', 'form-notification', notificationType ? "form-notification_" + notificationType : 'form-notification_global')
|
|
3232
3330
|
}, /*#__PURE__*/React.createElement(Notification, {
|
|
3233
3331
|
appearance: "errorPrimary sizeM solid rounded",
|
|
3234
3332
|
type: "global",
|
|
@@ -3248,7 +3346,7 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3248
3346
|
}, Object.keys(config).map(function (key) {
|
|
3249
3347
|
return generateField(config[key], {
|
|
3250
3348
|
key: key
|
|
3251
|
-
},
|
|
3349
|
+
}, dataTestId);
|
|
3252
3350
|
}), isLoading && (loader || /*#__PURE__*/React.createElement(Loader, {
|
|
3253
3351
|
appearance: loaderAppearance,
|
|
3254
3352
|
className: "form__loader",
|
|
@@ -3256,11 +3354,12 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3256
3354
|
size: loaderSize,
|
|
3257
3355
|
fill: loaderFill,
|
|
3258
3356
|
text: loaderText,
|
|
3357
|
+
"data-testid": dataTestId + "Loader",
|
|
3259
3358
|
itemFill: loaderItemFill,
|
|
3260
3359
|
shape: loaderShape
|
|
3261
3360
|
}))))), (primaryButtonLabel || primaryButton || secondaryButtonLabel || secondaryButton || tertiaryButton || tertiaryButtonLabel) && /*#__PURE__*/React.createElement(Group, {
|
|
3262
3361
|
className: "form__button",
|
|
3263
|
-
dataTestId: dataTestIdButtons,
|
|
3362
|
+
dataTestId: dataTestIdButtons || dataTestId + "Buttons",
|
|
3264
3363
|
dataTour: dataTourButtons,
|
|
3265
3364
|
direction: buttonDirection,
|
|
3266
3365
|
justifyContent: buttonJustifyContent,
|
|
@@ -3270,7 +3369,7 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3270
3369
|
}, primaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
|
|
3271
3370
|
appearance: primaryButtonAppearance,
|
|
3272
3371
|
className: "form__button-item",
|
|
3273
|
-
dataTestId: dataTestIdPrimaryButton ||
|
|
3372
|
+
dataTestId: dataTestIdPrimaryButton || dataTestId && dataTestId + "PrimaryButton" || 'FormPrimaryButton',
|
|
3274
3373
|
dataTour: dataTourPrimaryButton,
|
|
3275
3374
|
width: "fill",
|
|
3276
3375
|
size: primaryButtonSize,
|
|
@@ -3280,13 +3379,13 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3280
3379
|
labelTextColor: primaryButtonLabelTextColor,
|
|
3281
3380
|
labelTextSize: primaryButtonLabelSize,
|
|
3282
3381
|
labelTextWeight: primaryButtonLabelTextWeight,
|
|
3283
|
-
htmlType: primaryButtonHtmlType ||
|
|
3382
|
+
htmlType: primaryButtonHtmlType || 'submit',
|
|
3284
3383
|
loading: primaryButtonIsLoading,
|
|
3285
3384
|
isDisabled: primaryButtonIsDisabled
|
|
3286
3385
|
}) : primaryButton, secondaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
|
|
3287
3386
|
appearance: secondaryButtonAppearance,
|
|
3288
3387
|
className: "form__button-item",
|
|
3289
|
-
dataTestId: dataTestIdSecondaryButton ||
|
|
3388
|
+
dataTestId: dataTestIdSecondaryButton || dataTestId && dataTestId + "SecondaryButton" || 'FormSecondaryButton',
|
|
3290
3389
|
dataTour: dataTourSecondaryButton,
|
|
3291
3390
|
width: "fill",
|
|
3292
3391
|
size: secondaryButtonSize,
|
|
@@ -3301,8 +3400,9 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3301
3400
|
isDisabled: secondaryButtonIsDisabled,
|
|
3302
3401
|
onClick: onClickSecondaryButton
|
|
3303
3402
|
}) : secondaryButton, tertiaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
|
|
3403
|
+
appearance: tertiaryButtonAppearance,
|
|
3304
3404
|
className: "form__button-item",
|
|
3305
|
-
dataTestId: dataTestIdTertiaryButton,
|
|
3405
|
+
dataTestId: dataTestIdTertiaryButton || dataTestId && dataTestId + "TertiaryButton" || 'FormTertiaryButton',
|
|
3306
3406
|
dataTour: dataTourTertiaryButton,
|
|
3307
3407
|
width: "fill",
|
|
3308
3408
|
size: tertiaryButtonSize,
|
|
@@ -3328,7 +3428,7 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3328
3428
|
});
|
|
3329
3429
|
});
|
|
3330
3430
|
FinalForm.defaultProps = {
|
|
3331
|
-
direction:
|
|
3431
|
+
direction: 'vertical'
|
|
3332
3432
|
};
|
|
3333
3433
|
|
|
3334
3434
|
var DEFAULT_MESSAGES_REQUIRED = {
|
|
@@ -3571,4 +3671,4 @@ var getErrorsForFinalForm = function getErrorsForFinalForm(error) {
|
|
|
3571
3671
|
return formErrors;
|
|
3572
3672
|
};
|
|
3573
3673
|
|
|
3574
|
-
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 };
|