@itcase/forms 1.1.55 → 1.1.57
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 +484 -377
- package/dist/itcase-forms.esm.js +470 -364
- 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,36 +2223,44 @@ 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
|
});
|
|
2080
2248
|
});
|
|
2081
2249
|
|
|
2082
2250
|
var defaultInputNumberProps = {
|
|
2083
|
-
appearance: '
|
|
2084
|
-
width: 'fill'
|
|
2251
|
+
appearance: 'defaultPrimary sizeM solid rounded',
|
|
2252
|
+
width: 'fill',
|
|
2253
|
+
// Error
|
|
2254
|
+
errorAppearance: 'errorPrimary sizeM solid rounded',
|
|
2255
|
+
// Required
|
|
2256
|
+
requiredAppearance: 'requirePrimary sizeM solid rounded',
|
|
2257
|
+
// Success
|
|
2258
|
+
successAppearance: 'successPrimary sizeM solid rounded'
|
|
2085
2259
|
};
|
|
2086
2260
|
|
|
2087
2261
|
var FormFieldInputNumber = /*#__PURE__*/React.memo(function FormFieldInputNumber(props) {
|
|
2088
|
-
var
|
|
2262
|
+
var dataTestId = props.dataTestId,
|
|
2263
|
+
_props$type = props.type,
|
|
2089
2264
|
type = _props$type === void 0 ? 'custom' : _props$type,
|
|
2090
2265
|
name = props.name,
|
|
2091
2266
|
initialValue = props.initialValue,
|
|
@@ -2124,8 +2299,10 @@ var FormFieldInputNumber = /*#__PURE__*/React.memo(function FormFieldInputNumber
|
|
|
2124
2299
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
2125
2300
|
inputProps: inputProps
|
|
2126
2301
|
});
|
|
2302
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2127
2303
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2128
2304
|
className: clsx('form-field_input-number', 'form__item_input-number', classNameGroupItem),
|
|
2305
|
+
dataTestId: dataTestIdField,
|
|
2129
2306
|
errorKey: errorKey,
|
|
2130
2307
|
errorMessage: errorMessage,
|
|
2131
2308
|
fieldClassName: "form-input-number",
|
|
@@ -2140,7 +2317,7 @@ var FormFieldInputNumber = /*#__PURE__*/React.memo(function FormFieldInputNumber
|
|
|
2140
2317
|
isValidState: isValidState
|
|
2141
2318
|
}, fieldProps), /*#__PURE__*/React.createElement(InputNumber, Object.assign({
|
|
2142
2319
|
className: clsx(meta.active && 'input_state_focus', (meta.submitFailed || meta.touched) && meta.error && "input_state_" + errorKey),
|
|
2143
|
-
dataTestId:
|
|
2320
|
+
dataTestId: dataTestIdField + "InputNumber",
|
|
2144
2321
|
type: type,
|
|
2145
2322
|
name: input.name,
|
|
2146
2323
|
value: input.value || 0,
|
|
@@ -2150,7 +2327,8 @@ var FormFieldInputNumber = /*#__PURE__*/React.memo(function FormFieldInputNumber
|
|
|
2150
2327
|
});
|
|
2151
2328
|
|
|
2152
2329
|
var FormFieldMaskedInput = /*#__PURE__*/React.memo(function FormFieldMaskedInput(props) {
|
|
2153
|
-
var
|
|
2330
|
+
var dataTestId = props.dataTestId,
|
|
2331
|
+
name = props.name,
|
|
2154
2332
|
initialValue = props.initialValue,
|
|
2155
2333
|
classNameGroupItem = props.classNameGroupItem,
|
|
2156
2334
|
clearIcon = props.clearIcon,
|
|
@@ -2212,8 +2390,10 @@ var FormFieldMaskedInput = /*#__PURE__*/React.memo(function FormFieldMaskedInput
|
|
|
2212
2390
|
inputProps: inputProps,
|
|
2213
2391
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2214
2392
|
});
|
|
2393
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2215
2394
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2216
2395
|
className: clsx('form-field-masked-input', 'form__item_masked-input', classNameGroupItem),
|
|
2396
|
+
dataTestId: dataTestIdField,
|
|
2217
2397
|
errorKey: errorKey,
|
|
2218
2398
|
errorMessage: errorMessage,
|
|
2219
2399
|
fieldClassName: 'form-maskedInput',
|
|
@@ -2257,7 +2437,8 @@ var defaultPasswordProps = {
|
|
|
2257
2437
|
};
|
|
2258
2438
|
|
|
2259
2439
|
var FormFieldPassword = /*#__PURE__*/React.memo(function FormFieldPassword(props) {
|
|
2260
|
-
var
|
|
2440
|
+
var dataTestId = props.dataTestId,
|
|
2441
|
+
name = props.name,
|
|
2261
2442
|
initialValue = props.initialValue,
|
|
2262
2443
|
classNameGroupItem = props.classNameGroupItem,
|
|
2263
2444
|
fieldProps = props.fieldProps,
|
|
@@ -2301,13 +2482,15 @@ var FormFieldPassword = /*#__PURE__*/React.memo(function FormFieldPassword(props
|
|
|
2301
2482
|
inputProps: inputProps,
|
|
2302
2483
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2303
2484
|
});
|
|
2485
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2304
2486
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2305
|
-
className: clsx(
|
|
2487
|
+
className: clsx('form-field_input-password', 'form__item_input-password', classNameGroupItem),
|
|
2488
|
+
dataTestId: dataTestIdField,
|
|
2306
2489
|
errorKey: errorKey,
|
|
2307
2490
|
errorMessage: errorMessage,
|
|
2308
2491
|
fieldClassName: "form-password",
|
|
2309
2492
|
inputName: input.name,
|
|
2310
|
-
inputValue: input.value ||
|
|
2493
|
+
inputValue: input.value || '',
|
|
2311
2494
|
metaActive: meta.active,
|
|
2312
2495
|
metaError: meta.error,
|
|
2313
2496
|
showMessage: showMessage,
|
|
@@ -2316,11 +2499,11 @@ var FormFieldPassword = /*#__PURE__*/React.memo(function FormFieldPassword(props
|
|
|
2316
2499
|
isRequired: isRequired,
|
|
2317
2500
|
isValidState: isValidState
|
|
2318
2501
|
}, fieldProps), /*#__PURE__*/React.createElement(InputPassword, Object.assign({
|
|
2319
|
-
className: clsx(meta.active &&
|
|
2320
|
-
dataTestId:
|
|
2502
|
+
className: clsx(meta.active && 'input-password_state_focus', meta.error && meta.touched && "input-password_state_" + errorKey),
|
|
2503
|
+
dataTestId: dataTestIdField + "InputPassword",
|
|
2321
2504
|
name: input.name,
|
|
2322
2505
|
autoComplete: "nope",
|
|
2323
|
-
value: input.value ||
|
|
2506
|
+
value: input.value || '',
|
|
2324
2507
|
isDisabled: isDisabled,
|
|
2325
2508
|
onBlur: input.onBlur,
|
|
2326
2509
|
onChange: onChangeField,
|
|
@@ -2372,8 +2555,9 @@ function FormFieldRadioGroupList(props) {
|
|
|
2372
2555
|
}
|
|
2373
2556
|
|
|
2374
2557
|
var FormFieldRadioGroup = /*#__PURE__*/React.memo(function FormFieldRadioGroup(props) {
|
|
2375
|
-
var
|
|
2376
|
-
|
|
2558
|
+
var dataTestId = props.dataTestId,
|
|
2559
|
+
name = props.name,
|
|
2560
|
+
classNameGroupItem = props.classNameGroupItem,
|
|
2377
2561
|
_props$editableProps = props.editableProps,
|
|
2378
2562
|
editableProps = _props$editableProps === void 0 ? {} : _props$editableProps,
|
|
2379
2563
|
_props$fieldProps = props.fieldProps,
|
|
@@ -2382,8 +2566,8 @@ var FormFieldRadioGroup = /*#__PURE__*/React.memo(function FormFieldRadioGroup(p
|
|
|
2382
2566
|
inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
|
|
2383
2567
|
_props$options = props.options,
|
|
2384
2568
|
options = _props$options === void 0 ? [] : _props$options,
|
|
2385
|
-
classNameGroupItem = props.classNameGroupItem,
|
|
2386
2569
|
showMessage = props.showMessage,
|
|
2570
|
+
isDisabled = props.isDisabled,
|
|
2387
2571
|
isRequired = props.isRequired,
|
|
2388
2572
|
onChange = props.onChange;
|
|
2389
2573
|
return /*#__PURE__*/React.createElement(Field, {
|
|
@@ -2411,26 +2595,28 @@ var FormFieldRadioGroup = /*#__PURE__*/React.memo(function FormFieldRadioGroup(p
|
|
|
2411
2595
|
inputProps: inputProps,
|
|
2412
2596
|
validationStateKey: isErrorState ? errorKey : 'success'
|
|
2413
2597
|
});
|
|
2598
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2414
2599
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2415
2600
|
className: clsx('form-field_radio', 'form__item_radio', classNameGroupItem),
|
|
2601
|
+
dataTestId: dataTestIdField,
|
|
2416
2602
|
errorKey: errorKey,
|
|
2417
2603
|
errorMessage: errorMessage,
|
|
2418
|
-
isErrorState: isErrorState,
|
|
2419
|
-
metaError: meta.error,
|
|
2420
|
-
isDisabled: isDisabled,
|
|
2421
2604
|
fieldClassName: 'form-radio',
|
|
2422
2605
|
inputName: input.name,
|
|
2423
2606
|
inputValue: input.value || '',
|
|
2424
2607
|
metaActive: meta.active,
|
|
2608
|
+
metaError: meta.error,
|
|
2425
2609
|
showMessage: showMessage,
|
|
2610
|
+
isDisabled: isDisabled,
|
|
2611
|
+
isErrorState: isErrorState,
|
|
2426
2612
|
isRequired: isRequired,
|
|
2427
2613
|
isValidState: isValidState
|
|
2428
2614
|
}, fieldProps), /*#__PURE__*/React.createElement(FormFieldRadioGroupList, {
|
|
2429
|
-
isDisabled: isDisabled,
|
|
2430
2615
|
editableProps: editableProps,
|
|
2431
2616
|
input: input,
|
|
2432
2617
|
inputProps: updatedInputProps,
|
|
2433
2618
|
options: options,
|
|
2619
|
+
isDisabled: isDisabled,
|
|
2434
2620
|
onChange: onChange
|
|
2435
2621
|
}));
|
|
2436
2622
|
});
|
|
@@ -2447,12 +2633,13 @@ var defaultSegmentedProps = {
|
|
|
2447
2633
|
};
|
|
2448
2634
|
|
|
2449
2635
|
function FormFieldSegmented(props) {
|
|
2450
|
-
var
|
|
2451
|
-
|
|
2636
|
+
var dataTestId = props.dataTestId,
|
|
2637
|
+
name = props.name,
|
|
2452
2638
|
fieldProps = props.fieldProps,
|
|
2453
2639
|
inputProps = props.inputProps,
|
|
2454
2640
|
options = props.options,
|
|
2455
2641
|
showMessage = props.showMessage,
|
|
2642
|
+
isDisabled = props.isDisabled,
|
|
2456
2643
|
isRequired = props.isRequired;
|
|
2457
2644
|
var _useForm = useForm(),
|
|
2458
2645
|
change = _useForm.change;
|
|
@@ -2491,31 +2678,33 @@ function FormFieldSegmented(props) {
|
|
|
2491
2678
|
}),
|
|
2492
2679
|
errorKey = _useFieldValidationSt.errorKey,
|
|
2493
2680
|
errorMessage = _useFieldValidationSt.errorMessage,
|
|
2494
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
2495
2681
|
successKey = _useFieldValidationSt.successKey,
|
|
2682
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
2496
2683
|
isValidState = _useFieldValidationSt.isValidState;
|
|
2497
2684
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
2498
2685
|
inputProps: inputProps,
|
|
2499
2686
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2500
2687
|
});
|
|
2688
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2501
2689
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2502
2690
|
className: clsx('form-field_segmented', 'form__item_segmented'),
|
|
2691
|
+
dataTestId: dataTestIdField,
|
|
2503
2692
|
errorKey: errorKey,
|
|
2504
2693
|
errorMessage: errorMessage,
|
|
2505
|
-
isErrorState: isErrorState,
|
|
2506
|
-
metaError: meta.error,
|
|
2507
|
-
isDisabled: isDisabled,
|
|
2508
2694
|
fieldClassName: "form-segmented",
|
|
2509
2695
|
inputName: input.name,
|
|
2510
2696
|
inputValue: input.value || [],
|
|
2511
2697
|
metaActive: meta.active,
|
|
2698
|
+
metaError: meta.error,
|
|
2512
2699
|
showMessage: showMessage,
|
|
2700
|
+
isDisabled: isDisabled,
|
|
2701
|
+
isErrorState: isErrorState,
|
|
2513
2702
|
isRequired: isRequired,
|
|
2514
2703
|
isValidState: isValidState
|
|
2515
2704
|
}, fieldProps), /*#__PURE__*/React.createElement(Segmented, Object.assign({
|
|
2516
|
-
isDisabled: isDisabled,
|
|
2517
2705
|
activeSegment: activeOption,
|
|
2518
2706
|
segments: options,
|
|
2707
|
+
isDisabled: isDisabled,
|
|
2519
2708
|
setActiveSegment: setActiveSegment
|
|
2520
2709
|
}, updatedInputProps)));
|
|
2521
2710
|
});
|
|
@@ -2551,17 +2740,18 @@ function getDefaultValue(options, selectValue) {
|
|
|
2551
2740
|
return result;
|
|
2552
2741
|
}
|
|
2553
2742
|
var FormFieldSelect = /*#__PURE__*/React.memo(function FormFieldSelect(props) {
|
|
2554
|
-
var
|
|
2555
|
-
|
|
2743
|
+
var dataTestId = props.dataTestId,
|
|
2744
|
+
name = props.name,
|
|
2745
|
+
initialValue = props.initialValue,
|
|
2556
2746
|
classNameGroupItem = props.classNameGroupItem,
|
|
2557
2747
|
fieldProps = props.fieldProps,
|
|
2558
|
-
initialValue = props.initialValue,
|
|
2559
|
-
name = props.name,
|
|
2560
2748
|
_props$options = props.options,
|
|
2561
2749
|
options = _props$options === void 0 ? [] : _props$options,
|
|
2562
2750
|
selectProps = props.selectProps,
|
|
2563
2751
|
selectRef = props.selectRef,
|
|
2564
2752
|
showMessage = props.showMessage,
|
|
2753
|
+
isDisabled = props.isDisabled,
|
|
2754
|
+
isRequired = props.isRequired,
|
|
2565
2755
|
onChange = props.onChange,
|
|
2566
2756
|
onInputChange = props.onInputChange;
|
|
2567
2757
|
return /*#__PURE__*/React.createElement(Field, {
|
|
@@ -2613,34 +2803,36 @@ var FormFieldSelect = /*#__PURE__*/React.memo(function FormFieldSelect(props) {
|
|
|
2613
2803
|
}),
|
|
2614
2804
|
errorKey = _useFieldValidationSt.errorKey,
|
|
2615
2805
|
errorMessage = _useFieldValidationSt.errorMessage,
|
|
2616
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
2617
2806
|
successKey = _useFieldValidationSt.successKey,
|
|
2807
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
2618
2808
|
isValidState = _useFieldValidationSt.isValidState;
|
|
2619
2809
|
var updatedSelectProps = useValidationAppearanceInputProps({
|
|
2620
2810
|
inputProps: selectProps,
|
|
2621
2811
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2622
2812
|
});
|
|
2813
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2623
2814
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2624
2815
|
className: clsx('form-field_select', 'form__item_select', classNameGroupItem),
|
|
2816
|
+
dataTestId: dataTestIdField,
|
|
2625
2817
|
errorKey: errorKey,
|
|
2626
2818
|
errorMessage: errorMessage,
|
|
2627
|
-
isErrorState: isErrorState,
|
|
2628
|
-
metaError: meta.error,
|
|
2629
|
-
isDisabled: isDisabled,
|
|
2630
2819
|
fieldClassName: 'form-select',
|
|
2631
2820
|
inputName: input.name,
|
|
2632
2821
|
inputValue: input.value,
|
|
2633
2822
|
metaActive: meta.active,
|
|
2823
|
+
metaError: meta.error,
|
|
2634
2824
|
showMessage: showMessage,
|
|
2825
|
+
isDisabled: isDisabled,
|
|
2826
|
+
isErrorState: isErrorState,
|
|
2635
2827
|
isRequired: isRequired,
|
|
2636
2828
|
isValidState: isValidState
|
|
2637
2829
|
}, fieldProps), /*#__PURE__*/React.createElement(Select, Object.assign({
|
|
2638
2830
|
className: "form-select-item",
|
|
2639
2831
|
ref: selectRef,
|
|
2640
|
-
isDisabled: isDisabled,
|
|
2641
2832
|
instanceId: "id_" + input.name,
|
|
2642
2833
|
options: options,
|
|
2643
2834
|
value: selectedOptions,
|
|
2835
|
+
isDisabled: isDisabled,
|
|
2644
2836
|
onChange: onChangeValue,
|
|
2645
2837
|
onInputChange: onInputChange
|
|
2646
2838
|
}, updatedSelectProps)));
|
|
@@ -2655,14 +2847,15 @@ var defaultSwitchProps = {
|
|
|
2655
2847
|
};
|
|
2656
2848
|
|
|
2657
2849
|
var FormFieldSwitch = /*#__PURE__*/React.memo(function FormFieldSwitch(props) {
|
|
2658
|
-
var
|
|
2659
|
-
|
|
2850
|
+
var dataTestId = props.dataTestId,
|
|
2851
|
+
name = props.name,
|
|
2660
2852
|
classNameGroupItem = props.classNameGroupItem,
|
|
2661
2853
|
_props$fieldProps = props.fieldProps,
|
|
2662
2854
|
fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
|
|
2663
2855
|
_props$inputProps = props.inputProps,
|
|
2664
2856
|
inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
|
|
2665
2857
|
showMessage = props.showMessage,
|
|
2858
|
+
isDisabled = props.isDisabled,
|
|
2666
2859
|
isRequired = props.isRequired,
|
|
2667
2860
|
onChange = props.onChange;
|
|
2668
2861
|
return /*#__PURE__*/React.createElement(Field, {
|
|
@@ -2691,34 +2884,36 @@ var FormFieldSwitch = /*#__PURE__*/React.memo(function FormFieldSwitch(props) {
|
|
|
2691
2884
|
}),
|
|
2692
2885
|
errorKey = _useFieldValidationSt.errorKey,
|
|
2693
2886
|
errorMessage = _useFieldValidationSt.errorMessage,
|
|
2694
|
-
isErrorState = _useFieldValidationSt.isErrorState,
|
|
2695
2887
|
successKey = _useFieldValidationSt.successKey,
|
|
2888
|
+
isErrorState = _useFieldValidationSt.isErrorState,
|
|
2696
2889
|
isValidState = _useFieldValidationSt.isValidState;
|
|
2697
2890
|
var updatedInputProps = useValidationAppearanceInputProps({
|
|
2698
2891
|
inputProps: inputProps,
|
|
2699
2892
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2700
2893
|
});
|
|
2894
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2701
2895
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2702
2896
|
className: clsx('form-field-switch', 'form__item_switch', classNameGroupItem),
|
|
2897
|
+
dataTestId: dataTestIdField,
|
|
2703
2898
|
errorKey: errorKey,
|
|
2704
2899
|
errorMessage: errorMessage,
|
|
2705
|
-
isErrorState: isErrorState,
|
|
2706
|
-
metaError: meta.error,
|
|
2707
|
-
isDisabled: isDisabled,
|
|
2708
2900
|
fieldClassName: "form-switch",
|
|
2709
2901
|
inputName: input.name,
|
|
2710
2902
|
inputValue: input.checked,
|
|
2711
2903
|
metaActive: meta.active,
|
|
2904
|
+
metaError: meta.error,
|
|
2712
2905
|
showMessage: showMessage,
|
|
2713
2906
|
tag: "label",
|
|
2907
|
+
isDisabled: isDisabled,
|
|
2908
|
+
isErrorState: isErrorState,
|
|
2714
2909
|
isRequired: isRequired,
|
|
2715
2910
|
isValidState: isValidState
|
|
2716
2911
|
}, fieldProps), /*#__PURE__*/React.createElement(Switch, Object.assign({
|
|
2717
2912
|
type: "checkbox",
|
|
2718
2913
|
name: input.name,
|
|
2719
|
-
isDisabled: isDisabled,
|
|
2720
2914
|
autoComplete: "nope",
|
|
2721
2915
|
isActive: input.checked,
|
|
2916
|
+
isDisabled: isDisabled,
|
|
2722
2917
|
onBlur: input.onBlur,
|
|
2723
2918
|
onChange: onChangeField,
|
|
2724
2919
|
onFocus: input.onFocus
|
|
@@ -2738,7 +2933,8 @@ var defaultTextareaProps = {
|
|
|
2738
2933
|
};
|
|
2739
2934
|
|
|
2740
2935
|
var FormFieldTextarea = /*#__PURE__*/React.memo(function FormFieldTextarea(props) {
|
|
2741
|
-
var
|
|
2936
|
+
var dataTestId = props.dataTestId,
|
|
2937
|
+
name = props.name,
|
|
2742
2938
|
classNameGroupItem = props.classNameGroupItem,
|
|
2743
2939
|
_props$fieldProps = props.fieldProps,
|
|
2744
2940
|
fieldProps = _props$fieldProps === void 0 ? {} : _props$fieldProps,
|
|
@@ -2773,11 +2969,13 @@ var FormFieldTextarea = /*#__PURE__*/React.memo(function FormFieldTextarea(props
|
|
|
2773
2969
|
inputProps: inputProps,
|
|
2774
2970
|
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2775
2971
|
});
|
|
2972
|
+
var dataTestIdField = createDataTestIdField(input.name, dataTestId);
|
|
2776
2973
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2777
|
-
className: clsx(
|
|
2974
|
+
className: clsx('form-field_textarea', 'form__item_textarea', classNameGroupItem),
|
|
2975
|
+
dataTestId: dataTestIdField,
|
|
2778
2976
|
errorKey: errorKey,
|
|
2779
2977
|
errorMessage: errorMessage,
|
|
2780
|
-
fieldClassName:
|
|
2978
|
+
fieldClassName: 'form-textarea',
|
|
2781
2979
|
inputName: input.name,
|
|
2782
2980
|
inputValue: input.value,
|
|
2783
2981
|
metaActive: meta.active,
|
|
@@ -2788,11 +2986,11 @@ var FormFieldTextarea = /*#__PURE__*/React.memo(function FormFieldTextarea(props
|
|
|
2788
2986
|
isRequired: isRequired,
|
|
2789
2987
|
isValidState: isValidState
|
|
2790
2988
|
}, fieldProps), /*#__PURE__*/React.createElement(Textarea, Object.assign({
|
|
2791
|
-
className: clsx(meta.active &&
|
|
2792
|
-
dataTestId:
|
|
2989
|
+
className: clsx(meta.active && 'textarea_state_focus', meta.error && meta.touched && "textarea_state_" + errorKey),
|
|
2990
|
+
dataTestId: dataTestIdField + "Textarea",
|
|
2793
2991
|
name: input.name,
|
|
2794
2992
|
autoComplete: "nope",
|
|
2795
|
-
value: input.value ||
|
|
2993
|
+
value: input.value || '',
|
|
2796
2994
|
isDisabled: isDisabled,
|
|
2797
2995
|
onBlur: input.onBlur,
|
|
2798
2996
|
onChange: input.onChange,
|
|
@@ -2822,115 +3020,151 @@ var formTypes = {
|
|
|
2822
3020
|
select: 'select',
|
|
2823
3021
|
"switch": 'switch'
|
|
2824
3022
|
};
|
|
2825
|
-
function generateField(field, config,
|
|
3023
|
+
function generateField(field, config, dataTestId) {
|
|
2826
3024
|
switch (field.type) {
|
|
2827
3025
|
case formTypes.password:
|
|
2828
3026
|
{
|
|
2829
3027
|
return /*#__PURE__*/React.createElement(FormFieldPassword, Object.assign({
|
|
2830
3028
|
key: config.key
|
|
2831
|
-
}, field,
|
|
3029
|
+
}, field, {
|
|
3030
|
+
dataTestId: dataTestId
|
|
3031
|
+
}));
|
|
2832
3032
|
}
|
|
2833
3033
|
case formTypes.checkbox:
|
|
2834
3034
|
{
|
|
2835
3035
|
return /*#__PURE__*/React.createElement(FormFieldCheckbox, Object.assign({
|
|
2836
3036
|
key: config.key
|
|
2837
|
-
}, field,
|
|
3037
|
+
}, field, {
|
|
3038
|
+
dataTestId: dataTestId
|
|
3039
|
+
}));
|
|
2838
3040
|
}
|
|
2839
3041
|
case formTypes.choice:
|
|
2840
3042
|
{
|
|
2841
3043
|
return /*#__PURE__*/React.createElement(FormFieldChoice, Object.assign({
|
|
2842
3044
|
key: config.key
|
|
2843
|
-
}, field,
|
|
3045
|
+
}, field, {
|
|
3046
|
+
dataTestId: dataTestId
|
|
3047
|
+
}));
|
|
2844
3048
|
}
|
|
2845
3049
|
case formTypes.code:
|
|
2846
3050
|
{
|
|
2847
3051
|
return /*#__PURE__*/React.createElement(FormFieldCode, Object.assign({
|
|
2848
3052
|
key: config.key
|
|
2849
|
-
}, field,
|
|
3053
|
+
}, field, {
|
|
3054
|
+
dataTestId: dataTestId
|
|
3055
|
+
}));
|
|
2850
3056
|
}
|
|
2851
3057
|
case formTypes.chips:
|
|
2852
3058
|
{
|
|
2853
3059
|
return /*#__PURE__*/React.createElement(FormFieldChips, Object.assign({
|
|
2854
3060
|
key: config.key
|
|
2855
|
-
}, field,
|
|
3061
|
+
}, field, {
|
|
3062
|
+
dataTestId: dataTestId
|
|
3063
|
+
}));
|
|
2856
3064
|
}
|
|
2857
3065
|
case formTypes["switch"]:
|
|
2858
3066
|
{
|
|
2859
3067
|
return /*#__PURE__*/React.createElement(FormFieldSwitch, Object.assign({
|
|
2860
3068
|
key: config.key
|
|
2861
|
-
}, field,
|
|
3069
|
+
}, field, {
|
|
3070
|
+
dataTestId: dataTestId
|
|
3071
|
+
}));
|
|
2862
3072
|
}
|
|
2863
3073
|
case formTypes.segmented:
|
|
2864
3074
|
{
|
|
2865
3075
|
return /*#__PURE__*/React.createElement(FormFieldSegmented, Object.assign({
|
|
2866
3076
|
key: config.key
|
|
2867
|
-
}, field,
|
|
3077
|
+
}, field, {
|
|
3078
|
+
dataTestId: dataTestId
|
|
3079
|
+
}));
|
|
2868
3080
|
}
|
|
2869
3081
|
case formTypes.datePicker:
|
|
2870
3082
|
{
|
|
2871
3083
|
return /*#__PURE__*/React.createElement(FormFieldDatePicker, Object.assign({
|
|
2872
3084
|
key: config.key
|
|
2873
|
-
}, field,
|
|
3085
|
+
}, field, {
|
|
3086
|
+
dataTestId: dataTestId
|
|
3087
|
+
}));
|
|
2874
3088
|
}
|
|
2875
3089
|
case formTypes.fileInput:
|
|
2876
3090
|
{
|
|
2877
3091
|
return /*#__PURE__*/React.createElement(FormFieldFileInput, Object.assign({
|
|
2878
3092
|
key: config.key
|
|
2879
|
-
}, field,
|
|
3093
|
+
}, field, {
|
|
3094
|
+
dataTestId: dataTestId
|
|
3095
|
+
}));
|
|
2880
3096
|
}
|
|
2881
3097
|
case formTypes.radioGroup:
|
|
2882
3098
|
{
|
|
2883
3099
|
return /*#__PURE__*/React.createElement(FormFieldRadioGroup, Object.assign({
|
|
2884
3100
|
key: config.key
|
|
2885
|
-
}, field,
|
|
3101
|
+
}, field, {
|
|
3102
|
+
dataTestId: dataTestId
|
|
3103
|
+
}));
|
|
2886
3104
|
}
|
|
2887
3105
|
case formTypes.select:
|
|
2888
3106
|
{
|
|
2889
3107
|
return /*#__PURE__*/React.createElement(FormFieldSelect, Object.assign({
|
|
2890
3108
|
key: config.key
|
|
2891
|
-
}, field,
|
|
3109
|
+
}, field, {
|
|
3110
|
+
dataTestId: dataTestId
|
|
3111
|
+
}));
|
|
2892
3112
|
}
|
|
2893
3113
|
case formTypes.text:
|
|
2894
3114
|
{
|
|
2895
3115
|
return /*#__PURE__*/React.createElement(FormFieldInput, Object.assign({
|
|
2896
3116
|
key: config.key
|
|
2897
|
-
}, field,
|
|
3117
|
+
}, field, {
|
|
3118
|
+
dataTestId: dataTestId
|
|
3119
|
+
}));
|
|
2898
3120
|
}
|
|
2899
3121
|
case formTypes.textarea:
|
|
2900
3122
|
{
|
|
2901
3123
|
return /*#__PURE__*/React.createElement(FormFieldTextarea, Object.assign({
|
|
2902
3124
|
key: config.key
|
|
2903
|
-
}, field,
|
|
3125
|
+
}, field, {
|
|
3126
|
+
dataTestId: dataTestId
|
|
3127
|
+
}));
|
|
2904
3128
|
}
|
|
2905
3129
|
case formTypes.maskedInput:
|
|
2906
3130
|
{
|
|
2907
3131
|
return /*#__PURE__*/React.createElement(FormFieldMaskedInput, Object.assign({
|
|
2908
3132
|
key: config.key
|
|
2909
|
-
}, field,
|
|
3133
|
+
}, field, {
|
|
3134
|
+
dataTestId: dataTestId
|
|
3135
|
+
}));
|
|
2910
3136
|
}
|
|
2911
3137
|
case formTypes.custom:
|
|
2912
3138
|
{
|
|
2913
3139
|
return /*#__PURE__*/React.createElement(FormFieldCustom, Object.assign({
|
|
2914
3140
|
key: config.key
|
|
2915
|
-
}, field,
|
|
3141
|
+
}, field, {
|
|
3142
|
+
dataTestId: dataTestId
|
|
3143
|
+
}));
|
|
2916
3144
|
}
|
|
2917
3145
|
case formTypes.dadataInput:
|
|
2918
3146
|
{
|
|
2919
3147
|
return /*#__PURE__*/React.createElement(FormFieldDadataInput, Object.assign({
|
|
2920
3148
|
key: config.key
|
|
2921
|
-
}, field,
|
|
3149
|
+
}, field, {
|
|
3150
|
+
dataTestId: dataTestId
|
|
3151
|
+
}));
|
|
2922
3152
|
}
|
|
2923
3153
|
case formTypes.inputNumber:
|
|
2924
3154
|
{
|
|
2925
3155
|
return /*#__PURE__*/React.createElement(FormFieldInputNumber, Object.assign({
|
|
2926
3156
|
key: config.key
|
|
2927
|
-
}, field,
|
|
3157
|
+
}, field, {
|
|
3158
|
+
dataTestId: dataTestId
|
|
3159
|
+
}));
|
|
2928
3160
|
}
|
|
2929
3161
|
case formTypes.group:
|
|
2930
3162
|
{
|
|
2931
3163
|
return /*#__PURE__*/React.createElement(FormBlockGroup, Object.assign({
|
|
2932
3164
|
key: config.key
|
|
2933
|
-
}, field,
|
|
3165
|
+
}, field, {
|
|
3166
|
+
dataTestId: dataTestId
|
|
3167
|
+
}), Object.entries(field.group).map(function (_ref) {
|
|
2934
3168
|
var key = _ref[0],
|
|
2935
3169
|
value = _ref[1];
|
|
2936
3170
|
var groupProps = Object.assign({}, value, {
|
|
@@ -2939,147 +3173,17 @@ function generateField(field, config, props) {
|
|
|
2939
3173
|
});
|
|
2940
3174
|
return generateField(groupProps, {
|
|
2941
3175
|
key: key + '_form_group'
|
|
2942
|
-
},
|
|
3176
|
+
}, dataTestId);
|
|
2943
3177
|
}));
|
|
2944
3178
|
}
|
|
2945
3179
|
}
|
|
2946
3180
|
}
|
|
2947
3181
|
|
|
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
3182
|
var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
3078
3183
|
var className = props.className,
|
|
3079
3184
|
dataTestId = props.dataTestId,
|
|
3080
3185
|
dataTour = props.dataTour,
|
|
3081
3186
|
type = props.type,
|
|
3082
|
-
name = props.name,
|
|
3083
3187
|
initialValues = props.initialValues,
|
|
3084
3188
|
initialValuesEqual = props.initialValuesEqual,
|
|
3085
3189
|
config = props.config,
|
|
@@ -3094,11 +3198,10 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3094
3198
|
descSize = props.descSize,
|
|
3095
3199
|
descTextColor = props.descTextColor,
|
|
3096
3200
|
descTextWeight = props.descTextWeight,
|
|
3097
|
-
buttonGap = props.buttonGap
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
_props$buttonDirectio
|
|
3101
|
-
buttonDirection = _props$buttonDirectio === void 0 ? "vertical" : _props$buttonDirectio,
|
|
3201
|
+
buttonGap = props.buttonGap;
|
|
3202
|
+
props.additionalProps;
|
|
3203
|
+
var _props$buttonDirectio = props.buttonDirection,
|
|
3204
|
+
buttonDirection = _props$buttonDirectio === void 0 ? 'vertical' : _props$buttonDirectio,
|
|
3102
3205
|
buttonFill = props.buttonFill,
|
|
3103
3206
|
buttonJustifyContent = props.buttonJustifyContent,
|
|
3104
3207
|
buttonPadding = props.buttonPadding,
|
|
@@ -3114,22 +3217,21 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3114
3217
|
_props$disableFieldsA = props.disableFieldsAutoComplete,
|
|
3115
3218
|
disableFieldsAutoComplete = _props$disableFieldsA === void 0 ? false : _props$disableFieldsA,
|
|
3116
3219
|
fieldsGap = props.fieldsGap,
|
|
3117
|
-
formName = props.formName,
|
|
3118
3220
|
groupGap = props.groupGap,
|
|
3119
3221
|
heightClass = props.heightClass,
|
|
3120
3222
|
language = props.language,
|
|
3121
3223
|
loader = props.loader,
|
|
3122
3224
|
loaderAppearance = props.loaderAppearance,
|
|
3123
3225
|
_props$loaderFill = props.loaderFill,
|
|
3124
|
-
loaderFill = _props$loaderFill === void 0 ?
|
|
3226
|
+
loaderFill = _props$loaderFill === void 0 ? 'surfacePrimary' : _props$loaderFill,
|
|
3125
3227
|
_props$loaderItemFill = props.loaderItemFill,
|
|
3126
|
-
loaderItemFill = _props$loaderItemFill === void 0 ?
|
|
3228
|
+
loaderItemFill = _props$loaderItemFill === void 0 ? 'accentItemSecondary' : _props$loaderItemFill,
|
|
3127
3229
|
loaderShape = props.loaderShape,
|
|
3128
3230
|
_props$loaderSize = props.loaderSize,
|
|
3129
|
-
loaderSize = _props$loaderSize === void 0 ?
|
|
3231
|
+
loaderSize = _props$loaderSize === void 0 ? 'l' : _props$loaderSize,
|
|
3130
3232
|
loaderText = props.loaderText,
|
|
3131
3233
|
_props$loaderType = props.loaderType,
|
|
3132
|
-
loaderType = _props$loaderType === void 0 ?
|
|
3234
|
+
loaderType = _props$loaderType === void 0 ? 'dot' : _props$loaderType,
|
|
3133
3235
|
mutators = props.mutators,
|
|
3134
3236
|
notificationCloseButton = props.notificationCloseButton,
|
|
3135
3237
|
notificationType = props.notificationType,
|
|
@@ -3163,6 +3265,7 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3163
3265
|
secondaryButtonSize = props.secondaryButtonSize,
|
|
3164
3266
|
shapeStrengthClass = props.shapeStrengthClass,
|
|
3165
3267
|
tertiaryButton = props.tertiaryButton,
|
|
3268
|
+
tertiaryButtonAppearance = props.tertiaryButtonAppearance,
|
|
3166
3269
|
tertiaryButtonFill = props.tertiaryButtonFill,
|
|
3167
3270
|
tertiaryButtonFillHover = props.tertiaryButtonFillHover,
|
|
3168
3271
|
tertiaryButtonLabel = props.tertiaryButtonLabel,
|
|
@@ -3201,19 +3304,18 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3201
3304
|
modifiedSinceLastSubmit = _ref.modifiedSinceLastSubmit,
|
|
3202
3305
|
submitError = _ref.submitError;
|
|
3203
3306
|
return /*#__PURE__*/React.createElement("form", {
|
|
3204
|
-
className: clsx(className,
|
|
3205
|
-
name: formName || "form"
|
|
3307
|
+
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
3308
|
// We no need set reference to html element, we need reference to "final-form" instance
|
|
3207
3309
|
,
|
|
3208
3310
|
ref: function ref() {
|
|
3209
3311
|
return onRefFormInstance(form);
|
|
3210
3312
|
},
|
|
3211
|
-
autoCapitalize: disableFieldsAutoComplete ?
|
|
3212
|
-
autoComplete: disableFieldsAutoComplete ?
|
|
3213
|
-
autoCorrect: disableFieldsAutoComplete ?
|
|
3214
|
-
"data-testid": dataTestId ||
|
|
3313
|
+
autoCapitalize: disableFieldsAutoComplete ? 'off' : undefined,
|
|
3314
|
+
autoComplete: disableFieldsAutoComplete ? 'off' : undefined,
|
|
3315
|
+
autoCorrect: disableFieldsAutoComplete ? 'off' : undefined,
|
|
3316
|
+
"data-testid": dataTestId || 'Form',
|
|
3215
3317
|
"data-tour": dataTour,
|
|
3216
|
-
spellCheck: disableFieldsAutoComplete ?
|
|
3318
|
+
spellCheck: disableFieldsAutoComplete ? 'false' : undefined,
|
|
3217
3319
|
style: formStyles,
|
|
3218
3320
|
onSubmit: handleSubmit
|
|
3219
3321
|
}, before, title && /*#__PURE__*/React.createElement(Title, {
|
|
@@ -3221,14 +3323,16 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3221
3323
|
size: titleTextSize,
|
|
3222
3324
|
fill: titleFill,
|
|
3223
3325
|
textColor: titleTextColor,
|
|
3224
|
-
textWeight: titleTextWeight
|
|
3326
|
+
textWeight: titleTextWeight,
|
|
3327
|
+
"data-testid": dataTestId ? dataTestId + "Title" : 'FormTitle'
|
|
3225
3328
|
}, title), desc && /*#__PURE__*/React.createElement(Text, {
|
|
3226
3329
|
className: "form__desc",
|
|
3227
3330
|
size: descSize,
|
|
3228
3331
|
textColor: descTextColor,
|
|
3229
|
-
textWeight: descTextWeight
|
|
3332
|
+
textWeight: descTextWeight,
|
|
3333
|
+
"data-testid": dataTestId ? dataTestId + "Desc" : 'FormDesc'
|
|
3230
3334
|
}, desc), submitError && !modifiedSinceLastSubmit && /*#__PURE__*/React.createElement("div", {
|
|
3231
|
-
className: clsx(
|
|
3335
|
+
className: clsx('notification', 'form-notification', notificationType ? "form-notification_" + notificationType : 'form-notification_global')
|
|
3232
3336
|
}, /*#__PURE__*/React.createElement(Notification, {
|
|
3233
3337
|
appearance: "errorPrimary sizeM solid rounded",
|
|
3234
3338
|
type: "global",
|
|
@@ -3248,7 +3352,7 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3248
3352
|
}, Object.keys(config).map(function (key) {
|
|
3249
3353
|
return generateField(config[key], {
|
|
3250
3354
|
key: key
|
|
3251
|
-
},
|
|
3355
|
+
}, dataTestId);
|
|
3252
3356
|
}), isLoading && (loader || /*#__PURE__*/React.createElement(Loader, {
|
|
3253
3357
|
appearance: loaderAppearance,
|
|
3254
3358
|
className: "form__loader",
|
|
@@ -3256,11 +3360,12 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3256
3360
|
size: loaderSize,
|
|
3257
3361
|
fill: loaderFill,
|
|
3258
3362
|
text: loaderText,
|
|
3363
|
+
"data-testid": dataTestId + "Loader",
|
|
3259
3364
|
itemFill: loaderItemFill,
|
|
3260
3365
|
shape: loaderShape
|
|
3261
3366
|
}))))), (primaryButtonLabel || primaryButton || secondaryButtonLabel || secondaryButton || tertiaryButton || tertiaryButtonLabel) && /*#__PURE__*/React.createElement(Group, {
|
|
3262
3367
|
className: "form__button",
|
|
3263
|
-
dataTestId: dataTestIdButtons,
|
|
3368
|
+
dataTestId: dataTestIdButtons || dataTestId + "Buttons",
|
|
3264
3369
|
dataTour: dataTourButtons,
|
|
3265
3370
|
direction: buttonDirection,
|
|
3266
3371
|
justifyContent: buttonJustifyContent,
|
|
@@ -3270,7 +3375,7 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3270
3375
|
}, primaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
|
|
3271
3376
|
appearance: primaryButtonAppearance,
|
|
3272
3377
|
className: "form__button-item",
|
|
3273
|
-
dataTestId: dataTestIdPrimaryButton ||
|
|
3378
|
+
dataTestId: dataTestIdPrimaryButton || dataTestId && dataTestId + "PrimaryButton" || 'FormPrimaryButton',
|
|
3274
3379
|
dataTour: dataTourPrimaryButton,
|
|
3275
3380
|
width: "fill",
|
|
3276
3381
|
size: primaryButtonSize,
|
|
@@ -3280,13 +3385,13 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3280
3385
|
labelTextColor: primaryButtonLabelTextColor,
|
|
3281
3386
|
labelTextSize: primaryButtonLabelSize,
|
|
3282
3387
|
labelTextWeight: primaryButtonLabelTextWeight,
|
|
3283
|
-
htmlType: primaryButtonHtmlType ||
|
|
3388
|
+
htmlType: primaryButtonHtmlType || 'submit',
|
|
3284
3389
|
loading: primaryButtonIsLoading,
|
|
3285
3390
|
isDisabled: primaryButtonIsDisabled
|
|
3286
3391
|
}) : primaryButton, secondaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
|
|
3287
3392
|
appearance: secondaryButtonAppearance,
|
|
3288
3393
|
className: "form__button-item",
|
|
3289
|
-
dataTestId: dataTestIdSecondaryButton ||
|
|
3394
|
+
dataTestId: dataTestIdSecondaryButton || dataTestId && dataTestId + "SecondaryButton" || 'FormSecondaryButton',
|
|
3290
3395
|
dataTour: dataTourSecondaryButton,
|
|
3291
3396
|
width: "fill",
|
|
3292
3397
|
size: secondaryButtonSize,
|
|
@@ -3301,8 +3406,9 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3301
3406
|
isDisabled: secondaryButtonIsDisabled,
|
|
3302
3407
|
onClick: onClickSecondaryButton
|
|
3303
3408
|
}) : secondaryButton, tertiaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
|
|
3409
|
+
appearance: tertiaryButtonAppearance,
|
|
3304
3410
|
className: "form__button-item",
|
|
3305
|
-
dataTestId: dataTestIdTertiaryButton,
|
|
3411
|
+
dataTestId: dataTestIdTertiaryButton || dataTestId && dataTestId + "TertiaryButton" || 'FormTertiaryButton',
|
|
3306
3412
|
dataTour: dataTourTertiaryButton,
|
|
3307
3413
|
width: "fill",
|
|
3308
3414
|
size: tertiaryButtonSize,
|
|
@@ -3328,7 +3434,7 @@ var FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
3328
3434
|
});
|
|
3329
3435
|
});
|
|
3330
3436
|
FinalForm.defaultProps = {
|
|
3331
|
-
direction:
|
|
3437
|
+
direction: 'vertical'
|
|
3332
3438
|
};
|
|
3333
3439
|
|
|
3334
3440
|
var DEFAULT_MESSAGES_REQUIRED = {
|
|
@@ -3571,4 +3677,4 @@ var getErrorsForFinalForm = function getErrorsForFinalForm(error) {
|
|
|
3571
3677
|
return formErrors;
|
|
3572
3678
|
};
|
|
3573
3679
|
|
|
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 };
|
|
3680
|
+
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 };
|