@itcase/forms 1.0.64 → 1.0.66
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 +182 -177
- package/dist/itcase-forms.esm.js +182 -177
- package/package.json +16 -16
package/dist/itcase-forms.cjs.js
CHANGED
|
@@ -156,6 +156,7 @@ function FieldWrapperBase(props) {
|
|
|
156
156
|
labelTextColor,
|
|
157
157
|
labelTextSize,
|
|
158
158
|
labelTextSizeMobile,
|
|
159
|
+
labelTextSizeTablet,
|
|
159
160
|
labelTextWeight,
|
|
160
161
|
helpText,
|
|
161
162
|
helpTextSize,
|
|
@@ -227,6 +228,7 @@ function FieldWrapperBase(props) {
|
|
|
227
228
|
}, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
228
229
|
size: labelTextSize,
|
|
229
230
|
sizeMobile: labelTextSizeMobile,
|
|
231
|
+
sizeTablet: labelTextSizeTablet,
|
|
230
232
|
textColor: labelTextColor,
|
|
231
233
|
textWeight: labelTextWeight
|
|
232
234
|
}, label, labelHidden && '\u00A0')), desc && /*#__PURE__*/React__default.default.createElement("div", {
|
|
@@ -2477,116 +2479,6 @@ ChipsField.propTypes = {
|
|
|
2477
2479
|
onChange: PropTypes__default.default.func
|
|
2478
2480
|
};
|
|
2479
2481
|
|
|
2480
|
-
const focusOnError = (formElementsList, errors) => {
|
|
2481
|
-
const selectsIds = Object.keys(errors).map(fieldName => {
|
|
2482
|
-
if (fieldName === finalForm.FORM_ERROR) {
|
|
2483
|
-
// TODO: get from somewhere
|
|
2484
|
-
return 'notification__item_status_error';
|
|
2485
|
-
}
|
|
2486
|
-
return `react-select-id_${fieldName}-input`;
|
|
2487
|
-
});
|
|
2488
|
-
const errorFieldElement = formElementsList.find(element => {
|
|
2489
|
-
if (element.name) {
|
|
2490
|
-
return finalForm.getIn(errors, element.name);
|
|
2491
|
-
} else {
|
|
2492
|
-
return selectsIds.includes(element.id);
|
|
2493
|
-
}
|
|
2494
|
-
});
|
|
2495
|
-
const errorsList = Object.keys(errors);
|
|
2496
|
-
if (!errorFieldElement && errorsList.length) {
|
|
2497
|
-
let errorElement;
|
|
2498
|
-
try {
|
|
2499
|
-
const fieldName = errorsList[0];
|
|
2500
|
-
if (fieldName === finalForm.FORM_ERROR) {
|
|
2501
|
-
errorElement = document.querySelector('notification__item_status_error');
|
|
2502
|
-
} else {
|
|
2503
|
-
errorElement = document.querySelector(`#${fieldName}-error`);
|
|
2504
|
-
if (!errorElement) {
|
|
2505
|
-
errorElement = document.querySelector(`#id_${fieldName}`);
|
|
2506
|
-
}
|
|
2507
|
-
}
|
|
2508
|
-
} catch (err) {
|
|
2509
|
-
console.warn(err);
|
|
2510
|
-
}
|
|
2511
|
-
if (errorElement) {
|
|
2512
|
-
errorElement.scrollIntoView({
|
|
2513
|
-
block: 'center'
|
|
2514
|
-
}); // , behavior: 'smooth'
|
|
2515
|
-
}
|
|
2516
|
-
}
|
|
2517
|
-
|
|
2518
|
-
// The field is covered by the header because header is "sticky",
|
|
2519
|
-
// that's we scroll manually so that the field falls into the center of the visible area
|
|
2520
|
-
if (errorFieldElement) {
|
|
2521
|
-
errorFieldElement.scrollIntoView({
|
|
2522
|
-
block: 'center'
|
|
2523
|
-
});
|
|
2524
|
-
}
|
|
2525
|
-
return null;
|
|
2526
|
-
};
|
|
2527
|
-
const focusOnErrorDecorator = createDecorator__default.default(null, focusOnError);
|
|
2528
|
-
const setErrorsMutator = (args, state) => {
|
|
2529
|
-
const [fieldName, data] = args;
|
|
2530
|
-
const submitError = data.submitError;
|
|
2531
|
-
const fieldError = data.error;
|
|
2532
|
-
if (fieldName === 'non_field_errors') {
|
|
2533
|
-
// state.formState.invalid = true
|
|
2534
|
-
// state.formState.valid = false
|
|
2535
|
-
state.formState.error = fieldError;
|
|
2536
|
-
state.formState.submitError = submitError;
|
|
2537
|
-
} else if (fieldName in state.fields) {
|
|
2538
|
-
if (fieldError) {
|
|
2539
|
-
const errorsState = Object.assign({}, state.formState.errors, {
|
|
2540
|
-
[fieldName]: fieldError
|
|
2541
|
-
});
|
|
2542
|
-
state.fields[fieldName].touched = true;
|
|
2543
|
-
state.fields[fieldName].error = fieldError;
|
|
2544
|
-
state.formState.errors = errorsState;
|
|
2545
|
-
}
|
|
2546
|
-
if (submitError) {
|
|
2547
|
-
const submitErrorsState = Object.assign({}, state.formState.submitErrors, {
|
|
2548
|
-
[fieldName]: submitError
|
|
2549
|
-
});
|
|
2550
|
-
|
|
2551
|
-
// state.fields[fieldName].submitFailed = true
|
|
2552
|
-
// state.fields[fieldName].submitSucceeded = false
|
|
2553
|
-
state.fields[fieldName].submitError = submitError;
|
|
2554
|
-
state.formState.submitErrors = submitErrorsState;
|
|
2555
|
-
state.formState.submitFailed = true;
|
|
2556
|
-
state.formState.submitSucceeded = false;
|
|
2557
|
-
state.formState.lastSubmittedValues = state.formState.values;
|
|
2558
|
-
}
|
|
2559
|
-
}
|
|
2560
|
-
};
|
|
2561
|
-
const sendFormDataToServer = async (url, data) => {
|
|
2562
|
-
try {
|
|
2563
|
-
const response = await axios__default.default({
|
|
2564
|
-
url: url,
|
|
2565
|
-
method: 'POST',
|
|
2566
|
-
data: data
|
|
2567
|
-
});
|
|
2568
|
-
return {
|
|
2569
|
-
success: true,
|
|
2570
|
-
response
|
|
2571
|
-
};
|
|
2572
|
-
} catch (error) {
|
|
2573
|
-
const formErrors = {};
|
|
2574
|
-
if (typeof error.response?.data === 'string') {
|
|
2575
|
-
formErrors[finalForm.FORM_ERROR] = 'Something went wrong';
|
|
2576
|
-
}
|
|
2577
|
-
if (typeof error.response?.data === 'object') {
|
|
2578
|
-
Object.entries(error.response.data).forEach(([fieldName, errorsList]) => {
|
|
2579
|
-
formErrors[fieldName] = errorsList[0];
|
|
2580
|
-
});
|
|
2581
|
-
}
|
|
2582
|
-
return {
|
|
2583
|
-
success: false,
|
|
2584
|
-
formErrors,
|
|
2585
|
-
error
|
|
2586
|
-
};
|
|
2587
|
-
}
|
|
2588
|
-
};
|
|
2589
|
-
|
|
2590
2482
|
const formTypes = {
|
|
2591
2483
|
checkbox: 'checkbox',
|
|
2592
2484
|
custom: 'custom',
|
|
@@ -2709,8 +2601,119 @@ function generateField(field, config, props) {
|
|
|
2709
2601
|
}
|
|
2710
2602
|
}
|
|
2711
2603
|
|
|
2604
|
+
const focusOnError = (formElementsList, errors) => {
|
|
2605
|
+
const selectsIds = Object.keys(errors).map(fieldName => {
|
|
2606
|
+
if (fieldName === finalForm.FORM_ERROR) {
|
|
2607
|
+
// TODO: get from somewhere
|
|
2608
|
+
return 'notification__item_status_error';
|
|
2609
|
+
}
|
|
2610
|
+
return `react-select-id_${fieldName}-input`;
|
|
2611
|
+
});
|
|
2612
|
+
const errorFieldElement = formElementsList.find(element => {
|
|
2613
|
+
if (element.name) {
|
|
2614
|
+
return finalForm.getIn(errors, element.name);
|
|
2615
|
+
} else {
|
|
2616
|
+
return selectsIds.includes(element.id);
|
|
2617
|
+
}
|
|
2618
|
+
});
|
|
2619
|
+
const errorsList = Object.keys(errors);
|
|
2620
|
+
if (!errorFieldElement && errorsList.length) {
|
|
2621
|
+
let errorElement;
|
|
2622
|
+
try {
|
|
2623
|
+
const fieldName = errorsList[0];
|
|
2624
|
+
if (fieldName === finalForm.FORM_ERROR) {
|
|
2625
|
+
errorElement = document.querySelector('notification__item_status_error');
|
|
2626
|
+
} else {
|
|
2627
|
+
errorElement = document.querySelector(`#${fieldName}-error`);
|
|
2628
|
+
if (!errorElement) {
|
|
2629
|
+
errorElement = document.querySelector(`#id_${fieldName}`);
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
} catch (err) {
|
|
2633
|
+
console.warn(err);
|
|
2634
|
+
}
|
|
2635
|
+
if (errorElement) {
|
|
2636
|
+
errorElement.scrollIntoView({
|
|
2637
|
+
block: 'center'
|
|
2638
|
+
}); // , behavior: 'smooth'
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
|
|
2642
|
+
// The field is covered by the header because header is "sticky",
|
|
2643
|
+
// that's we scroll manually so that the field falls into the center of the visible area
|
|
2644
|
+
if (errorFieldElement) {
|
|
2645
|
+
errorFieldElement.scrollIntoView({
|
|
2646
|
+
block: 'center'
|
|
2647
|
+
});
|
|
2648
|
+
}
|
|
2649
|
+
return null;
|
|
2650
|
+
};
|
|
2651
|
+
const focusOnErrorDecorator = createDecorator__default.default(null, focusOnError);
|
|
2652
|
+
const setErrorsMutator = (args, state) => {
|
|
2653
|
+
const [fieldName, data] = args;
|
|
2654
|
+
const submitError = data.submitError;
|
|
2655
|
+
const fieldError = data.error;
|
|
2656
|
+
if (fieldName === 'non_field_errors') {
|
|
2657
|
+
// state.formState.invalid = true
|
|
2658
|
+
// state.formState.valid = false
|
|
2659
|
+
state.formState.error = fieldError;
|
|
2660
|
+
state.formState.submitError = submitError;
|
|
2661
|
+
} else if (fieldName in state.fields) {
|
|
2662
|
+
if (fieldError) {
|
|
2663
|
+
const errorsState = Object.assign({}, state.formState.errors, {
|
|
2664
|
+
[fieldName]: fieldError
|
|
2665
|
+
});
|
|
2666
|
+
state.fields[fieldName].touched = true;
|
|
2667
|
+
state.fields[fieldName].error = fieldError;
|
|
2668
|
+
state.formState.errors = errorsState;
|
|
2669
|
+
}
|
|
2670
|
+
if (submitError) {
|
|
2671
|
+
const submitErrorsState = Object.assign({}, state.formState.submitErrors, {
|
|
2672
|
+
[fieldName]: submitError
|
|
2673
|
+
});
|
|
2674
|
+
|
|
2675
|
+
// state.fields[fieldName].submitFailed = true
|
|
2676
|
+
// state.fields[fieldName].submitSucceeded = false
|
|
2677
|
+
state.fields[fieldName].submitError = submitError;
|
|
2678
|
+
state.formState.submitErrors = submitErrorsState;
|
|
2679
|
+
state.formState.submitFailed = true;
|
|
2680
|
+
state.formState.submitSucceeded = false;
|
|
2681
|
+
state.formState.lastSubmittedValues = state.formState.values;
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
};
|
|
2685
|
+
const sendFormDataToServer = async (url, data) => {
|
|
2686
|
+
try {
|
|
2687
|
+
const response = await axios__default.default({
|
|
2688
|
+
url: url,
|
|
2689
|
+
method: 'POST',
|
|
2690
|
+
data: data
|
|
2691
|
+
});
|
|
2692
|
+
return {
|
|
2693
|
+
success: true,
|
|
2694
|
+
response
|
|
2695
|
+
};
|
|
2696
|
+
} catch (error) {
|
|
2697
|
+
const formErrors = {};
|
|
2698
|
+
if (typeof error.response?.data === 'string') {
|
|
2699
|
+
formErrors[finalForm.FORM_ERROR] = 'Something went wrong';
|
|
2700
|
+
}
|
|
2701
|
+
if (typeof error.response?.data === 'object') {
|
|
2702
|
+
Object.entries(error.response.data).forEach(([fieldName, errorsList]) => {
|
|
2703
|
+
formErrors[fieldName] = errorsList[0];
|
|
2704
|
+
});
|
|
2705
|
+
}
|
|
2706
|
+
return {
|
|
2707
|
+
success: false,
|
|
2708
|
+
formErrors,
|
|
2709
|
+
error
|
|
2710
|
+
};
|
|
2711
|
+
}
|
|
2712
|
+
};
|
|
2713
|
+
|
|
2712
2714
|
const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalForm(props, ref) {
|
|
2713
2715
|
const {
|
|
2716
|
+
isLoading,
|
|
2714
2717
|
additionalProps,
|
|
2715
2718
|
after,
|
|
2716
2719
|
before,
|
|
@@ -2721,13 +2724,13 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2721
2724
|
buttonPadding,
|
|
2722
2725
|
className,
|
|
2723
2726
|
config,
|
|
2724
|
-
dataTour,
|
|
2725
2727
|
dataTestId,
|
|
2726
|
-
dataTourButtons,
|
|
2727
2728
|
dataTestIdButtons,
|
|
2728
2729
|
dataTestIdPrimaryButton,
|
|
2729
2730
|
dataTestIdSecondaryButton,
|
|
2730
2731
|
dataTestIdTertiaryButton,
|
|
2732
|
+
dataTour,
|
|
2733
|
+
dataTourButtons,
|
|
2731
2734
|
dataTourPrimaryButton,
|
|
2732
2735
|
dataTourSecondaryButton,
|
|
2733
2736
|
dataTourTertiaryButton,
|
|
@@ -2741,7 +2744,6 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2741
2744
|
groupGap,
|
|
2742
2745
|
initialValues,
|
|
2743
2746
|
initialValuesEqual,
|
|
2744
|
-
isLoading,
|
|
2745
2747
|
language,
|
|
2746
2748
|
loader,
|
|
2747
2749
|
loaderFill,
|
|
@@ -2751,10 +2753,6 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2751
2753
|
mutators,
|
|
2752
2754
|
notificationCloseButton,
|
|
2753
2755
|
notificationType,
|
|
2754
|
-
onChangeFormValues,
|
|
2755
|
-
onClickSecondaryButton,
|
|
2756
|
-
onClickTertiaryButton,
|
|
2757
|
-
onSubmit,
|
|
2758
2756
|
primaryButton,
|
|
2759
2757
|
primaryButtonFill,
|
|
2760
2758
|
primaryButtonFillHover,
|
|
@@ -2763,6 +2761,7 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2763
2761
|
primaryButtonLabelTextColor,
|
|
2764
2762
|
primaryButtonLabelTextWeight,
|
|
2765
2763
|
primaryButtonSize,
|
|
2764
|
+
renderFieldsWrapper = wrapperChildren => wrapperChildren,
|
|
2766
2765
|
secondaryButton,
|
|
2767
2766
|
secondaryButtonFill,
|
|
2768
2767
|
secondaryButtonFillHover,
|
|
@@ -2785,7 +2784,11 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2785
2784
|
titleTextSize,
|
|
2786
2785
|
titleTextWeight,
|
|
2787
2786
|
type,
|
|
2788
|
-
validationSchema
|
|
2787
|
+
validationSchema,
|
|
2788
|
+
onChangeFormValues,
|
|
2789
|
+
onClickSecondaryButton,
|
|
2790
|
+
onClickTertiaryButton,
|
|
2791
|
+
onSubmit
|
|
2789
2792
|
} = props;
|
|
2790
2793
|
const validate = useYupValidationSchema(validationSchema, language);
|
|
2791
2794
|
const onRefFormInstance = React.useCallback(formInstance => {
|
|
@@ -2810,33 +2813,35 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2810
2813
|
propsKey: 'elevation'
|
|
2811
2814
|
});
|
|
2812
2815
|
const {
|
|
2813
|
-
styles: formStyles
|
|
2816
|
+
styles: formStyles,
|
|
2817
|
+
wrapper: wrapperStyles
|
|
2814
2818
|
} = useStyles.useStyles(props);
|
|
2815
2819
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Form, {
|
|
2816
2820
|
decorators: [focusOnErrorDecorator],
|
|
2817
2821
|
initialValues: initialValues,
|
|
2818
2822
|
initialValuesEqual: initialValuesEqual,
|
|
2819
2823
|
mutators: mutators,
|
|
2824
|
+
validate: validate,
|
|
2820
2825
|
render: ({
|
|
2826
|
+
form,
|
|
2821
2827
|
handleSubmit,
|
|
2822
|
-
submitError,
|
|
2823
2828
|
modifiedSinceLastSubmit,
|
|
2824
|
-
|
|
2829
|
+
submitError
|
|
2825
2830
|
}) => {
|
|
2826
2831
|
return /*#__PURE__*/React__default.default.createElement("form", {
|
|
2827
|
-
|
|
2828
|
-
className: clsx__default.default(className, 'form', set && `form_set_${set}`, type && `form_type_${type}`, directionClass, fillClass, shapeClass, elevationClass),
|
|
2829
|
-
name: formName,
|
|
2830
|
-
"data-tour": dataTour,
|
|
2831
|
-
"data-test-id": dataTestId
|
|
2832
|
+
className: clsx__default.default(className, 'form', set && `form_set_${set}`, type && `form_type_${type}`, directionClass, fillClass, shapeClass, elevationClass)
|
|
2832
2833
|
// We no need set reference to html element, we need reference to "final-form" instance
|
|
2833
2834
|
,
|
|
2834
2835
|
ref: () => onRefFormInstance(form),
|
|
2835
|
-
|
|
2836
|
+
name: formName,
|
|
2837
|
+
autoCapitalize: disableFieldsAutoComplete ? 'off' : undefined,
|
|
2836
2838
|
autoComplete: disableFieldsAutoComplete ? 'off' : undefined,
|
|
2837
2839
|
autoCorrect: disableFieldsAutoComplete ? 'off' : undefined,
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
+
"data-test-id": dataTestId,
|
|
2841
|
+
"data-tour": dataTour,
|
|
2842
|
+
spellCheck: disableFieldsAutoComplete ? 'false' : undefined,
|
|
2843
|
+
style: formStyles,
|
|
2844
|
+
onSubmit: handleSubmit
|
|
2840
2845
|
}, before, title && /*#__PURE__*/React__default.default.createElement(Title.Title, {
|
|
2841
2846
|
className: "form__title",
|
|
2842
2847
|
size: titleTextSize,
|
|
@@ -2851,88 +2856,89 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2851
2856
|
className: clsx__default.default('notification', 'form-notification', notificationType ? `form-notification_type_${notificationType}` : 'form-notification_type_global')
|
|
2852
2857
|
}, /*#__PURE__*/React__default.default.createElement(Notification.NotificationItem, {
|
|
2853
2858
|
className: "form-notification__item",
|
|
2854
|
-
titleTextSize: "h6",
|
|
2855
2859
|
closeButton: notificationCloseButton,
|
|
2860
|
+
status: "error",
|
|
2856
2861
|
title: form.getState().submitError,
|
|
2857
|
-
|
|
2858
|
-
|
|
2862
|
+
titleTextSize: "h6",
|
|
2863
|
+
set: "form"
|
|
2859
2864
|
})), onChangeFormValues && /*#__PURE__*/React__default.default.createElement(reactFinalForm.FormSpy, {
|
|
2860
2865
|
subscription: {
|
|
2861
2866
|
values: true
|
|
2862
2867
|
},
|
|
2863
2868
|
onChange: onChangeFormValues
|
|
2864
|
-
}), Boolean(Object.keys(config).length) && /*#__PURE__*/React__default.default.createElement(Group$1.Group, {
|
|
2869
|
+
}), Boolean(Object.keys(config).length) && /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, renderFieldsWrapper( /*#__PURE__*/React__default.default.createElement(Group$1.Group, {
|
|
2870
|
+
className: "form__wrapper",
|
|
2865
2871
|
direction: "vertical",
|
|
2866
2872
|
gap: fieldsGap || groupGap,
|
|
2867
|
-
|
|
2873
|
+
style: wrapperStyles
|
|
2868
2874
|
}, Object.keys(config).map(key => generateField(config[key], {
|
|
2869
2875
|
key
|
|
2870
2876
|
}, additionalProps[config[key].name])), isLoading && (loader || /*#__PURE__*/React__default.default.createElement(Loader.Loader, {
|
|
2871
2877
|
className: "form__loader",
|
|
2872
|
-
set: loaderSet,
|
|
2873
2878
|
fill: loaderFill,
|
|
2874
2879
|
itemFill: loaderItemFill,
|
|
2875
|
-
text: loaderText
|
|
2876
|
-
|
|
2880
|
+
text: loaderText,
|
|
2881
|
+
set: loaderSet
|
|
2882
|
+
}))))), (primaryButtonLabel || primaryButton || secondaryButtonLabel || secondaryButton || tertiaryButton || tertiaryButtonLabel) && /*#__PURE__*/React__default.default.createElement(Group$1.Group, {
|
|
2883
|
+
className: "form__button",
|
|
2877
2884
|
fill: buttonFill,
|
|
2878
|
-
justifyContent: buttonJustifyContent,
|
|
2879
|
-
direction: buttonDirection,
|
|
2880
2885
|
padding: buttonPadding,
|
|
2881
|
-
|
|
2882
|
-
className: "form__button",
|
|
2886
|
+
dataTestId: dataTestIdButtons,
|
|
2883
2887
|
dataTour: dataTourButtons,
|
|
2884
|
-
|
|
2888
|
+
direction: buttonDirection,
|
|
2889
|
+
gap: buttonGap,
|
|
2890
|
+
justifyContent: buttonJustifyContent
|
|
2885
2891
|
}, primaryButtonLabel ? /*#__PURE__*/React__default.default.createElement(Button.Button, {
|
|
2886
|
-
width: "fill",
|
|
2887
2892
|
className: "form__button-item",
|
|
2893
|
+
width: "fill",
|
|
2894
|
+
labelTextColor: primaryButtonLabelTextColor,
|
|
2895
|
+
labelTextSize: primaryButtonLabelSize,
|
|
2888
2896
|
fill: primaryButtonFill,
|
|
2889
2897
|
fillHover: primaryButtonFillHover,
|
|
2890
|
-
|
|
2891
|
-
labelTextColor: primaryButtonLabelTextColor,
|
|
2892
|
-
labelSize: primaryButtonLabelSize,
|
|
2893
|
-
labelTextWeight: primaryButtonLabelTextWeight,
|
|
2894
|
-
label: primaryButtonLabel,
|
|
2898
|
+
dataTestId: dataTestIdPrimaryButton,
|
|
2895
2899
|
dataTour: dataTourPrimaryButton,
|
|
2896
|
-
|
|
2900
|
+
label: primaryButtonLabel,
|
|
2901
|
+
labelTextWeight: primaryButtonLabelTextWeight,
|
|
2902
|
+
size: primaryButtonSize
|
|
2897
2903
|
}) : primaryButton, secondaryButtonLabel ? /*#__PURE__*/React__default.default.createElement(Button.Button, {
|
|
2898
|
-
width: "fill",
|
|
2899
2904
|
className: "form__button-item",
|
|
2905
|
+
width: "fill",
|
|
2906
|
+
labelTextColor: secondaryButtonLabelTextColor,
|
|
2907
|
+
labelTextSize: secondaryButtonLabelSize,
|
|
2900
2908
|
fill: secondaryButtonFill,
|
|
2901
2909
|
fillHover: secondaryButtonFillHover,
|
|
2902
|
-
|
|
2903
|
-
labelTextColor: secondaryButtonLabelTextColor,
|
|
2904
|
-
labelSize: secondaryButtonLabelSize,
|
|
2905
|
-
labelTextWeight: secondaryButtonLabelTextWeight,
|
|
2906
|
-
label: secondaryButtonLabel,
|
|
2907
|
-
onClick: onClickSecondaryButton,
|
|
2910
|
+
dataTestId: dataTestIdSecondaryButton,
|
|
2908
2911
|
dataTour: dataTourSecondaryButton,
|
|
2909
|
-
|
|
2912
|
+
label: secondaryButtonLabel,
|
|
2913
|
+
labelTextWeight: secondaryButtonLabelTextWeight,
|
|
2914
|
+
size: secondaryButtonSize,
|
|
2915
|
+
onClick: onClickSecondaryButton
|
|
2910
2916
|
}) : secondaryButton, tertiaryButtonLabel ? /*#__PURE__*/React__default.default.createElement(Button.Button, {
|
|
2911
|
-
width: "fill",
|
|
2912
2917
|
className: "form__button-item",
|
|
2918
|
+
width: "fill",
|
|
2919
|
+
labelTextColor: tertiaryButtonLabelTextColor,
|
|
2920
|
+
labelTextSize: tertiaryButtonLabelSize,
|
|
2913
2921
|
fill: tertiaryButtonFill,
|
|
2914
2922
|
fillHover: tertiaryButtonFillHover,
|
|
2915
|
-
|
|
2916
|
-
labelTextColor: tertiaryButtonLabelTextColor,
|
|
2917
|
-
labelSize: tertiaryButtonLabelSize,
|
|
2918
|
-
labelTextWeight: tertiaryButtonLabelTextWeight,
|
|
2919
|
-
label: tertiaryButtonLabel,
|
|
2920
|
-
onClick: onClickTertiaryButton,
|
|
2923
|
+
dataTestId: dataTestIdTertiaryButton,
|
|
2921
2924
|
dataTour: dataTourTertiaryButton,
|
|
2922
|
-
|
|
2925
|
+
label: tertiaryButtonLabel,
|
|
2926
|
+
labelTextWeight: tertiaryButtonLabelTextWeight,
|
|
2927
|
+
size: tertiaryButtonSize,
|
|
2928
|
+
onClick: onClickTertiaryButton
|
|
2923
2929
|
}) : tertiaryButton), after);
|
|
2924
2930
|
},
|
|
2925
2931
|
subscription: {
|
|
2926
|
-
submitting: true,
|
|
2927
|
-
pristine: true,
|
|
2928
2932
|
modifiedSinceLastSubmit: true,
|
|
2929
|
-
|
|
2933
|
+
pristine: true,
|
|
2934
|
+
submitError: true,
|
|
2935
|
+
submitting: true
|
|
2930
2936
|
},
|
|
2931
|
-
validate: validate,
|
|
2932
2937
|
onSubmit: onSubmit
|
|
2933
2938
|
});
|
|
2934
2939
|
});
|
|
2935
2940
|
FinalForm.propTypes = {
|
|
2941
|
+
isLoading: PropTypes__default.default.bool,
|
|
2936
2942
|
additionalProps: PropTypes__default.default.object,
|
|
2937
2943
|
after: PropTypes__default.default.any,
|
|
2938
2944
|
before: PropTypes__default.default.any,
|
|
@@ -2958,7 +2964,6 @@ FinalForm.propTypes = {
|
|
|
2958
2964
|
groupGap: PropTypes__default.default.string,
|
|
2959
2965
|
initialValues: PropTypes__default.default.any,
|
|
2960
2966
|
initialValuesEqual: PropTypes__default.default.any,
|
|
2961
|
-
isLoading: PropTypes__default.default.bool,
|
|
2962
2967
|
language: PropTypes__default.default.string,
|
|
2963
2968
|
loader: PropTypes__default.default.element,
|
|
2964
2969
|
loaderFill: PropTypes__default.default.string,
|
|
@@ -3006,16 +3011,16 @@ FinalForm.propTypes = {
|
|
|
3006
3011
|
onSubmit: PropTypes__default.default.func
|
|
3007
3012
|
};
|
|
3008
3013
|
FinalForm.defaultProps = {
|
|
3009
|
-
|
|
3014
|
+
direction: 'vertical',
|
|
3010
3015
|
isLoading: false,
|
|
3011
|
-
|
|
3016
|
+
additionalProps: {},
|
|
3017
|
+
buttonDirection: 'vertical',
|
|
3018
|
+
disableFieldsAutoComplete: false,
|
|
3019
|
+
language: 'en',
|
|
3012
3020
|
loaderFill: 'surfacePrimary',
|
|
3013
3021
|
loaderItemFill: 'surfaceItemAccent',
|
|
3014
|
-
|
|
3015
|
-
titleSize: 'h1'
|
|
3016
|
-
buttonDirection: 'vertical',
|
|
3017
|
-
direction: 'vertical',
|
|
3018
|
-
disableFieldsAutoComplete: false
|
|
3022
|
+
loaderSet: 'simple',
|
|
3023
|
+
titleSize: 'h1'
|
|
3019
3024
|
};
|
|
3020
3025
|
|
|
3021
3026
|
const DEFAULT_MESSAGES_FIELDS = {
|
package/dist/itcase-forms.esm.js
CHANGED
|
@@ -142,6 +142,7 @@ function FieldWrapperBase(props) {
|
|
|
142
142
|
labelTextColor,
|
|
143
143
|
labelTextSize,
|
|
144
144
|
labelTextSizeMobile,
|
|
145
|
+
labelTextSizeTablet,
|
|
145
146
|
labelTextWeight,
|
|
146
147
|
helpText,
|
|
147
148
|
helpTextSize,
|
|
@@ -213,6 +214,7 @@ function FieldWrapperBase(props) {
|
|
|
213
214
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
214
215
|
size: labelTextSize,
|
|
215
216
|
sizeMobile: labelTextSizeMobile,
|
|
217
|
+
sizeTablet: labelTextSizeTablet,
|
|
216
218
|
textColor: labelTextColor,
|
|
217
219
|
textWeight: labelTextWeight
|
|
218
220
|
}, label, labelHidden && '\u00A0')), desc && /*#__PURE__*/React.createElement("div", {
|
|
@@ -2463,116 +2465,6 @@ ChipsField.propTypes = {
|
|
|
2463
2465
|
onChange: PropTypes.func
|
|
2464
2466
|
};
|
|
2465
2467
|
|
|
2466
|
-
const focusOnError = (formElementsList, errors) => {
|
|
2467
|
-
const selectsIds = Object.keys(errors).map(fieldName => {
|
|
2468
|
-
if (fieldName === FORM_ERROR) {
|
|
2469
|
-
// TODO: get from somewhere
|
|
2470
|
-
return 'notification__item_status_error';
|
|
2471
|
-
}
|
|
2472
|
-
return `react-select-id_${fieldName}-input`;
|
|
2473
|
-
});
|
|
2474
|
-
const errorFieldElement = formElementsList.find(element => {
|
|
2475
|
-
if (element.name) {
|
|
2476
|
-
return getIn(errors, element.name);
|
|
2477
|
-
} else {
|
|
2478
|
-
return selectsIds.includes(element.id);
|
|
2479
|
-
}
|
|
2480
|
-
});
|
|
2481
|
-
const errorsList = Object.keys(errors);
|
|
2482
|
-
if (!errorFieldElement && errorsList.length) {
|
|
2483
|
-
let errorElement;
|
|
2484
|
-
try {
|
|
2485
|
-
const fieldName = errorsList[0];
|
|
2486
|
-
if (fieldName === FORM_ERROR) {
|
|
2487
|
-
errorElement = document.querySelector('notification__item_status_error');
|
|
2488
|
-
} else {
|
|
2489
|
-
errorElement = document.querySelector(`#${fieldName}-error`);
|
|
2490
|
-
if (!errorElement) {
|
|
2491
|
-
errorElement = document.querySelector(`#id_${fieldName}`);
|
|
2492
|
-
}
|
|
2493
|
-
}
|
|
2494
|
-
} catch (err) {
|
|
2495
|
-
console.warn(err);
|
|
2496
|
-
}
|
|
2497
|
-
if (errorElement) {
|
|
2498
|
-
errorElement.scrollIntoView({
|
|
2499
|
-
block: 'center'
|
|
2500
|
-
}); // , behavior: 'smooth'
|
|
2501
|
-
}
|
|
2502
|
-
}
|
|
2503
|
-
|
|
2504
|
-
// The field is covered by the header because header is "sticky",
|
|
2505
|
-
// that's we scroll manually so that the field falls into the center of the visible area
|
|
2506
|
-
if (errorFieldElement) {
|
|
2507
|
-
errorFieldElement.scrollIntoView({
|
|
2508
|
-
block: 'center'
|
|
2509
|
-
});
|
|
2510
|
-
}
|
|
2511
|
-
return null;
|
|
2512
|
-
};
|
|
2513
|
-
const focusOnErrorDecorator = createDecorator(null, focusOnError);
|
|
2514
|
-
const setErrorsMutator = (args, state) => {
|
|
2515
|
-
const [fieldName, data] = args;
|
|
2516
|
-
const submitError = data.submitError;
|
|
2517
|
-
const fieldError = data.error;
|
|
2518
|
-
if (fieldName === 'non_field_errors') {
|
|
2519
|
-
// state.formState.invalid = true
|
|
2520
|
-
// state.formState.valid = false
|
|
2521
|
-
state.formState.error = fieldError;
|
|
2522
|
-
state.formState.submitError = submitError;
|
|
2523
|
-
} else if (fieldName in state.fields) {
|
|
2524
|
-
if (fieldError) {
|
|
2525
|
-
const errorsState = Object.assign({}, state.formState.errors, {
|
|
2526
|
-
[fieldName]: fieldError
|
|
2527
|
-
});
|
|
2528
|
-
state.fields[fieldName].touched = true;
|
|
2529
|
-
state.fields[fieldName].error = fieldError;
|
|
2530
|
-
state.formState.errors = errorsState;
|
|
2531
|
-
}
|
|
2532
|
-
if (submitError) {
|
|
2533
|
-
const submitErrorsState = Object.assign({}, state.formState.submitErrors, {
|
|
2534
|
-
[fieldName]: submitError
|
|
2535
|
-
});
|
|
2536
|
-
|
|
2537
|
-
// state.fields[fieldName].submitFailed = true
|
|
2538
|
-
// state.fields[fieldName].submitSucceeded = false
|
|
2539
|
-
state.fields[fieldName].submitError = submitError;
|
|
2540
|
-
state.formState.submitErrors = submitErrorsState;
|
|
2541
|
-
state.formState.submitFailed = true;
|
|
2542
|
-
state.formState.submitSucceeded = false;
|
|
2543
|
-
state.formState.lastSubmittedValues = state.formState.values;
|
|
2544
|
-
}
|
|
2545
|
-
}
|
|
2546
|
-
};
|
|
2547
|
-
const sendFormDataToServer = async (url, data) => {
|
|
2548
|
-
try {
|
|
2549
|
-
const response = await axios({
|
|
2550
|
-
url: url,
|
|
2551
|
-
method: 'POST',
|
|
2552
|
-
data: data
|
|
2553
|
-
});
|
|
2554
|
-
return {
|
|
2555
|
-
success: true,
|
|
2556
|
-
response
|
|
2557
|
-
};
|
|
2558
|
-
} catch (error) {
|
|
2559
|
-
const formErrors = {};
|
|
2560
|
-
if (typeof error.response?.data === 'string') {
|
|
2561
|
-
formErrors[FORM_ERROR] = 'Something went wrong';
|
|
2562
|
-
}
|
|
2563
|
-
if (typeof error.response?.data === 'object') {
|
|
2564
|
-
Object.entries(error.response.data).forEach(([fieldName, errorsList]) => {
|
|
2565
|
-
formErrors[fieldName] = errorsList[0];
|
|
2566
|
-
});
|
|
2567
|
-
}
|
|
2568
|
-
return {
|
|
2569
|
-
success: false,
|
|
2570
|
-
formErrors,
|
|
2571
|
-
error
|
|
2572
|
-
};
|
|
2573
|
-
}
|
|
2574
|
-
};
|
|
2575
|
-
|
|
2576
2468
|
const formTypes = {
|
|
2577
2469
|
checkbox: 'checkbox',
|
|
2578
2470
|
custom: 'custom',
|
|
@@ -2695,8 +2587,119 @@ function generateField(field, config, props) {
|
|
|
2695
2587
|
}
|
|
2696
2588
|
}
|
|
2697
2589
|
|
|
2590
|
+
const focusOnError = (formElementsList, errors) => {
|
|
2591
|
+
const selectsIds = Object.keys(errors).map(fieldName => {
|
|
2592
|
+
if (fieldName === FORM_ERROR) {
|
|
2593
|
+
// TODO: get from somewhere
|
|
2594
|
+
return 'notification__item_status_error';
|
|
2595
|
+
}
|
|
2596
|
+
return `react-select-id_${fieldName}-input`;
|
|
2597
|
+
});
|
|
2598
|
+
const errorFieldElement = formElementsList.find(element => {
|
|
2599
|
+
if (element.name) {
|
|
2600
|
+
return getIn(errors, element.name);
|
|
2601
|
+
} else {
|
|
2602
|
+
return selectsIds.includes(element.id);
|
|
2603
|
+
}
|
|
2604
|
+
});
|
|
2605
|
+
const errorsList = Object.keys(errors);
|
|
2606
|
+
if (!errorFieldElement && errorsList.length) {
|
|
2607
|
+
let errorElement;
|
|
2608
|
+
try {
|
|
2609
|
+
const fieldName = errorsList[0];
|
|
2610
|
+
if (fieldName === FORM_ERROR) {
|
|
2611
|
+
errorElement = document.querySelector('notification__item_status_error');
|
|
2612
|
+
} else {
|
|
2613
|
+
errorElement = document.querySelector(`#${fieldName}-error`);
|
|
2614
|
+
if (!errorElement) {
|
|
2615
|
+
errorElement = document.querySelector(`#id_${fieldName}`);
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
} catch (err) {
|
|
2619
|
+
console.warn(err);
|
|
2620
|
+
}
|
|
2621
|
+
if (errorElement) {
|
|
2622
|
+
errorElement.scrollIntoView({
|
|
2623
|
+
block: 'center'
|
|
2624
|
+
}); // , behavior: 'smooth'
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
// The field is covered by the header because header is "sticky",
|
|
2629
|
+
// that's we scroll manually so that the field falls into the center of the visible area
|
|
2630
|
+
if (errorFieldElement) {
|
|
2631
|
+
errorFieldElement.scrollIntoView({
|
|
2632
|
+
block: 'center'
|
|
2633
|
+
});
|
|
2634
|
+
}
|
|
2635
|
+
return null;
|
|
2636
|
+
};
|
|
2637
|
+
const focusOnErrorDecorator = createDecorator(null, focusOnError);
|
|
2638
|
+
const setErrorsMutator = (args, state) => {
|
|
2639
|
+
const [fieldName, data] = args;
|
|
2640
|
+
const submitError = data.submitError;
|
|
2641
|
+
const fieldError = data.error;
|
|
2642
|
+
if (fieldName === 'non_field_errors') {
|
|
2643
|
+
// state.formState.invalid = true
|
|
2644
|
+
// state.formState.valid = false
|
|
2645
|
+
state.formState.error = fieldError;
|
|
2646
|
+
state.formState.submitError = submitError;
|
|
2647
|
+
} else if (fieldName in state.fields) {
|
|
2648
|
+
if (fieldError) {
|
|
2649
|
+
const errorsState = Object.assign({}, state.formState.errors, {
|
|
2650
|
+
[fieldName]: fieldError
|
|
2651
|
+
});
|
|
2652
|
+
state.fields[fieldName].touched = true;
|
|
2653
|
+
state.fields[fieldName].error = fieldError;
|
|
2654
|
+
state.formState.errors = errorsState;
|
|
2655
|
+
}
|
|
2656
|
+
if (submitError) {
|
|
2657
|
+
const submitErrorsState = Object.assign({}, state.formState.submitErrors, {
|
|
2658
|
+
[fieldName]: submitError
|
|
2659
|
+
});
|
|
2660
|
+
|
|
2661
|
+
// state.fields[fieldName].submitFailed = true
|
|
2662
|
+
// state.fields[fieldName].submitSucceeded = false
|
|
2663
|
+
state.fields[fieldName].submitError = submitError;
|
|
2664
|
+
state.formState.submitErrors = submitErrorsState;
|
|
2665
|
+
state.formState.submitFailed = true;
|
|
2666
|
+
state.formState.submitSucceeded = false;
|
|
2667
|
+
state.formState.lastSubmittedValues = state.formState.values;
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
};
|
|
2671
|
+
const sendFormDataToServer = async (url, data) => {
|
|
2672
|
+
try {
|
|
2673
|
+
const response = await axios({
|
|
2674
|
+
url: url,
|
|
2675
|
+
method: 'POST',
|
|
2676
|
+
data: data
|
|
2677
|
+
});
|
|
2678
|
+
return {
|
|
2679
|
+
success: true,
|
|
2680
|
+
response
|
|
2681
|
+
};
|
|
2682
|
+
} catch (error) {
|
|
2683
|
+
const formErrors = {};
|
|
2684
|
+
if (typeof error.response?.data === 'string') {
|
|
2685
|
+
formErrors[FORM_ERROR] = 'Something went wrong';
|
|
2686
|
+
}
|
|
2687
|
+
if (typeof error.response?.data === 'object') {
|
|
2688
|
+
Object.entries(error.response.data).forEach(([fieldName, errorsList]) => {
|
|
2689
|
+
formErrors[fieldName] = errorsList[0];
|
|
2690
|
+
});
|
|
2691
|
+
}
|
|
2692
|
+
return {
|
|
2693
|
+
success: false,
|
|
2694
|
+
formErrors,
|
|
2695
|
+
error
|
|
2696
|
+
};
|
|
2697
|
+
}
|
|
2698
|
+
};
|
|
2699
|
+
|
|
2698
2700
|
const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
2699
2701
|
const {
|
|
2702
|
+
isLoading,
|
|
2700
2703
|
additionalProps,
|
|
2701
2704
|
after,
|
|
2702
2705
|
before,
|
|
@@ -2707,13 +2710,13 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
2707
2710
|
buttonPadding,
|
|
2708
2711
|
className,
|
|
2709
2712
|
config,
|
|
2710
|
-
dataTour,
|
|
2711
2713
|
dataTestId,
|
|
2712
|
-
dataTourButtons,
|
|
2713
2714
|
dataTestIdButtons,
|
|
2714
2715
|
dataTestIdPrimaryButton,
|
|
2715
2716
|
dataTestIdSecondaryButton,
|
|
2716
2717
|
dataTestIdTertiaryButton,
|
|
2718
|
+
dataTour,
|
|
2719
|
+
dataTourButtons,
|
|
2717
2720
|
dataTourPrimaryButton,
|
|
2718
2721
|
dataTourSecondaryButton,
|
|
2719
2722
|
dataTourTertiaryButton,
|
|
@@ -2727,7 +2730,6 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
2727
2730
|
groupGap,
|
|
2728
2731
|
initialValues,
|
|
2729
2732
|
initialValuesEqual,
|
|
2730
|
-
isLoading,
|
|
2731
2733
|
language,
|
|
2732
2734
|
loader,
|
|
2733
2735
|
loaderFill,
|
|
@@ -2737,10 +2739,6 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
2737
2739
|
mutators,
|
|
2738
2740
|
notificationCloseButton,
|
|
2739
2741
|
notificationType,
|
|
2740
|
-
onChangeFormValues,
|
|
2741
|
-
onClickSecondaryButton,
|
|
2742
|
-
onClickTertiaryButton,
|
|
2743
|
-
onSubmit,
|
|
2744
2742
|
primaryButton,
|
|
2745
2743
|
primaryButtonFill,
|
|
2746
2744
|
primaryButtonFillHover,
|
|
@@ -2749,6 +2747,7 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
2749
2747
|
primaryButtonLabelTextColor,
|
|
2750
2748
|
primaryButtonLabelTextWeight,
|
|
2751
2749
|
primaryButtonSize,
|
|
2750
|
+
renderFieldsWrapper = wrapperChildren => wrapperChildren,
|
|
2752
2751
|
secondaryButton,
|
|
2753
2752
|
secondaryButtonFill,
|
|
2754
2753
|
secondaryButtonFillHover,
|
|
@@ -2771,7 +2770,11 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
2771
2770
|
titleTextSize,
|
|
2772
2771
|
titleTextWeight,
|
|
2773
2772
|
type,
|
|
2774
|
-
validationSchema
|
|
2773
|
+
validationSchema,
|
|
2774
|
+
onChangeFormValues,
|
|
2775
|
+
onClickSecondaryButton,
|
|
2776
|
+
onClickTertiaryButton,
|
|
2777
|
+
onSubmit
|
|
2775
2778
|
} = props;
|
|
2776
2779
|
const validate = useYupValidationSchema(validationSchema, language);
|
|
2777
2780
|
const onRefFormInstance = useCallback(formInstance => {
|
|
@@ -2796,33 +2799,35 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
2796
2799
|
propsKey: 'elevation'
|
|
2797
2800
|
});
|
|
2798
2801
|
const {
|
|
2799
|
-
styles: formStyles
|
|
2802
|
+
styles: formStyles,
|
|
2803
|
+
wrapper: wrapperStyles
|
|
2800
2804
|
} = useStyles(props);
|
|
2801
2805
|
return /*#__PURE__*/React.createElement(Form, {
|
|
2802
2806
|
decorators: [focusOnErrorDecorator],
|
|
2803
2807
|
initialValues: initialValues,
|
|
2804
2808
|
initialValuesEqual: initialValuesEqual,
|
|
2805
2809
|
mutators: mutators,
|
|
2810
|
+
validate: validate,
|
|
2806
2811
|
render: ({
|
|
2812
|
+
form,
|
|
2807
2813
|
handleSubmit,
|
|
2808
|
-
submitError,
|
|
2809
2814
|
modifiedSinceLastSubmit,
|
|
2810
|
-
|
|
2815
|
+
submitError
|
|
2811
2816
|
}) => {
|
|
2812
2817
|
return /*#__PURE__*/React.createElement("form", {
|
|
2813
|
-
|
|
2814
|
-
className: clsx(className, 'form', set && `form_set_${set}`, type && `form_type_${type}`, directionClass, fillClass, shapeClass, elevationClass),
|
|
2815
|
-
name: formName,
|
|
2816
|
-
"data-tour": dataTour,
|
|
2817
|
-
"data-test-id": dataTestId
|
|
2818
|
+
className: clsx(className, 'form', set && `form_set_${set}`, type && `form_type_${type}`, directionClass, fillClass, shapeClass, elevationClass)
|
|
2818
2819
|
// We no need set reference to html element, we need reference to "final-form" instance
|
|
2819
2820
|
,
|
|
2820
2821
|
ref: () => onRefFormInstance(form),
|
|
2821
|
-
|
|
2822
|
+
name: formName,
|
|
2823
|
+
autoCapitalize: disableFieldsAutoComplete ? 'off' : undefined,
|
|
2822
2824
|
autoComplete: disableFieldsAutoComplete ? 'off' : undefined,
|
|
2823
2825
|
autoCorrect: disableFieldsAutoComplete ? 'off' : undefined,
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
+
"data-test-id": dataTestId,
|
|
2827
|
+
"data-tour": dataTour,
|
|
2828
|
+
spellCheck: disableFieldsAutoComplete ? 'false' : undefined,
|
|
2829
|
+
style: formStyles,
|
|
2830
|
+
onSubmit: handleSubmit
|
|
2826
2831
|
}, before, title && /*#__PURE__*/React.createElement(Title, {
|
|
2827
2832
|
className: "form__title",
|
|
2828
2833
|
size: titleTextSize,
|
|
@@ -2837,88 +2842,89 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
2837
2842
|
className: clsx('notification', 'form-notification', notificationType ? `form-notification_type_${notificationType}` : 'form-notification_type_global')
|
|
2838
2843
|
}, /*#__PURE__*/React.createElement(NotificationItem, {
|
|
2839
2844
|
className: "form-notification__item",
|
|
2840
|
-
titleTextSize: "h6",
|
|
2841
2845
|
closeButton: notificationCloseButton,
|
|
2846
|
+
status: "error",
|
|
2842
2847
|
title: form.getState().submitError,
|
|
2843
|
-
|
|
2844
|
-
|
|
2848
|
+
titleTextSize: "h6",
|
|
2849
|
+
set: "form"
|
|
2845
2850
|
})), onChangeFormValues && /*#__PURE__*/React.createElement(FormSpy, {
|
|
2846
2851
|
subscription: {
|
|
2847
2852
|
values: true
|
|
2848
2853
|
},
|
|
2849
2854
|
onChange: onChangeFormValues
|
|
2850
|
-
}), Boolean(Object.keys(config).length) && /*#__PURE__*/React.createElement(Group$1, {
|
|
2855
|
+
}), Boolean(Object.keys(config).length) && /*#__PURE__*/React.createElement(React.Fragment, null, renderFieldsWrapper( /*#__PURE__*/React.createElement(Group$1, {
|
|
2856
|
+
className: "form__wrapper",
|
|
2851
2857
|
direction: "vertical",
|
|
2852
2858
|
gap: fieldsGap || groupGap,
|
|
2853
|
-
|
|
2859
|
+
style: wrapperStyles
|
|
2854
2860
|
}, Object.keys(config).map(key => generateField(config[key], {
|
|
2855
2861
|
key
|
|
2856
2862
|
}, additionalProps[config[key].name])), isLoading && (loader || /*#__PURE__*/React.createElement(Loader, {
|
|
2857
2863
|
className: "form__loader",
|
|
2858
|
-
set: loaderSet,
|
|
2859
2864
|
fill: loaderFill,
|
|
2860
2865
|
itemFill: loaderItemFill,
|
|
2861
|
-
text: loaderText
|
|
2862
|
-
|
|
2866
|
+
text: loaderText,
|
|
2867
|
+
set: loaderSet
|
|
2868
|
+
}))))), (primaryButtonLabel || primaryButton || secondaryButtonLabel || secondaryButton || tertiaryButton || tertiaryButtonLabel) && /*#__PURE__*/React.createElement(Group$1, {
|
|
2869
|
+
className: "form__button",
|
|
2863
2870
|
fill: buttonFill,
|
|
2864
|
-
justifyContent: buttonJustifyContent,
|
|
2865
|
-
direction: buttonDirection,
|
|
2866
2871
|
padding: buttonPadding,
|
|
2867
|
-
|
|
2868
|
-
className: "form__button",
|
|
2872
|
+
dataTestId: dataTestIdButtons,
|
|
2869
2873
|
dataTour: dataTourButtons,
|
|
2870
|
-
|
|
2874
|
+
direction: buttonDirection,
|
|
2875
|
+
gap: buttonGap,
|
|
2876
|
+
justifyContent: buttonJustifyContent
|
|
2871
2877
|
}, primaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
|
|
2872
|
-
width: "fill",
|
|
2873
2878
|
className: "form__button-item",
|
|
2879
|
+
width: "fill",
|
|
2880
|
+
labelTextColor: primaryButtonLabelTextColor,
|
|
2881
|
+
labelTextSize: primaryButtonLabelSize,
|
|
2874
2882
|
fill: primaryButtonFill,
|
|
2875
2883
|
fillHover: primaryButtonFillHover,
|
|
2876
|
-
|
|
2877
|
-
labelTextColor: primaryButtonLabelTextColor,
|
|
2878
|
-
labelSize: primaryButtonLabelSize,
|
|
2879
|
-
labelTextWeight: primaryButtonLabelTextWeight,
|
|
2880
|
-
label: primaryButtonLabel,
|
|
2884
|
+
dataTestId: dataTestIdPrimaryButton,
|
|
2881
2885
|
dataTour: dataTourPrimaryButton,
|
|
2882
|
-
|
|
2886
|
+
label: primaryButtonLabel,
|
|
2887
|
+
labelTextWeight: primaryButtonLabelTextWeight,
|
|
2888
|
+
size: primaryButtonSize
|
|
2883
2889
|
}) : primaryButton, secondaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
|
|
2884
|
-
width: "fill",
|
|
2885
2890
|
className: "form__button-item",
|
|
2891
|
+
width: "fill",
|
|
2892
|
+
labelTextColor: secondaryButtonLabelTextColor,
|
|
2893
|
+
labelTextSize: secondaryButtonLabelSize,
|
|
2886
2894
|
fill: secondaryButtonFill,
|
|
2887
2895
|
fillHover: secondaryButtonFillHover,
|
|
2888
|
-
|
|
2889
|
-
labelTextColor: secondaryButtonLabelTextColor,
|
|
2890
|
-
labelSize: secondaryButtonLabelSize,
|
|
2891
|
-
labelTextWeight: secondaryButtonLabelTextWeight,
|
|
2892
|
-
label: secondaryButtonLabel,
|
|
2893
|
-
onClick: onClickSecondaryButton,
|
|
2896
|
+
dataTestId: dataTestIdSecondaryButton,
|
|
2894
2897
|
dataTour: dataTourSecondaryButton,
|
|
2895
|
-
|
|
2898
|
+
label: secondaryButtonLabel,
|
|
2899
|
+
labelTextWeight: secondaryButtonLabelTextWeight,
|
|
2900
|
+
size: secondaryButtonSize,
|
|
2901
|
+
onClick: onClickSecondaryButton
|
|
2896
2902
|
}) : secondaryButton, tertiaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
|
|
2897
|
-
width: "fill",
|
|
2898
2903
|
className: "form__button-item",
|
|
2904
|
+
width: "fill",
|
|
2905
|
+
labelTextColor: tertiaryButtonLabelTextColor,
|
|
2906
|
+
labelTextSize: tertiaryButtonLabelSize,
|
|
2899
2907
|
fill: tertiaryButtonFill,
|
|
2900
2908
|
fillHover: tertiaryButtonFillHover,
|
|
2901
|
-
|
|
2902
|
-
labelTextColor: tertiaryButtonLabelTextColor,
|
|
2903
|
-
labelSize: tertiaryButtonLabelSize,
|
|
2904
|
-
labelTextWeight: tertiaryButtonLabelTextWeight,
|
|
2905
|
-
label: tertiaryButtonLabel,
|
|
2906
|
-
onClick: onClickTertiaryButton,
|
|
2909
|
+
dataTestId: dataTestIdTertiaryButton,
|
|
2907
2910
|
dataTour: dataTourTertiaryButton,
|
|
2908
|
-
|
|
2911
|
+
label: tertiaryButtonLabel,
|
|
2912
|
+
labelTextWeight: tertiaryButtonLabelTextWeight,
|
|
2913
|
+
size: tertiaryButtonSize,
|
|
2914
|
+
onClick: onClickTertiaryButton
|
|
2909
2915
|
}) : tertiaryButton), after);
|
|
2910
2916
|
},
|
|
2911
2917
|
subscription: {
|
|
2912
|
-
submitting: true,
|
|
2913
|
-
pristine: true,
|
|
2914
2918
|
modifiedSinceLastSubmit: true,
|
|
2915
|
-
|
|
2919
|
+
pristine: true,
|
|
2920
|
+
submitError: true,
|
|
2921
|
+
submitting: true
|
|
2916
2922
|
},
|
|
2917
|
-
validate: validate,
|
|
2918
2923
|
onSubmit: onSubmit
|
|
2919
2924
|
});
|
|
2920
2925
|
});
|
|
2921
2926
|
FinalForm.propTypes = {
|
|
2927
|
+
isLoading: PropTypes.bool,
|
|
2922
2928
|
additionalProps: PropTypes.object,
|
|
2923
2929
|
after: PropTypes.any,
|
|
2924
2930
|
before: PropTypes.any,
|
|
@@ -2944,7 +2950,6 @@ FinalForm.propTypes = {
|
|
|
2944
2950
|
groupGap: PropTypes.string,
|
|
2945
2951
|
initialValues: PropTypes.any,
|
|
2946
2952
|
initialValuesEqual: PropTypes.any,
|
|
2947
|
-
isLoading: PropTypes.bool,
|
|
2948
2953
|
language: PropTypes.string,
|
|
2949
2954
|
loader: PropTypes.element,
|
|
2950
2955
|
loaderFill: PropTypes.string,
|
|
@@ -2992,16 +2997,16 @@ FinalForm.propTypes = {
|
|
|
2992
2997
|
onSubmit: PropTypes.func
|
|
2993
2998
|
};
|
|
2994
2999
|
FinalForm.defaultProps = {
|
|
2995
|
-
|
|
3000
|
+
direction: 'vertical',
|
|
2996
3001
|
isLoading: false,
|
|
2997
|
-
|
|
3002
|
+
additionalProps: {},
|
|
3003
|
+
buttonDirection: 'vertical',
|
|
3004
|
+
disableFieldsAutoComplete: false,
|
|
3005
|
+
language: 'en',
|
|
2998
3006
|
loaderFill: 'surfacePrimary',
|
|
2999
3007
|
loaderItemFill: 'surfaceItemAccent',
|
|
3000
|
-
|
|
3001
|
-
titleSize: 'h1'
|
|
3002
|
-
buttonDirection: 'vertical',
|
|
3003
|
-
direction: 'vertical',
|
|
3004
|
-
disableFieldsAutoComplete: false
|
|
3008
|
+
loaderSet: 'simple',
|
|
3009
|
+
titleSize: 'h1'
|
|
3005
3010
|
};
|
|
3006
3011
|
|
|
3007
3012
|
const DEFAULT_MESSAGES_FIELDS = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itcase/forms",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.66",
|
|
4
4
|
"description": "Forms fields, inputs, etc.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"registry": "https://registry.npmjs.org/"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@itcase/common": "^1.2.
|
|
34
|
-
"@itcase/ui": "^1.
|
|
35
|
-
"axios": "^1.7.
|
|
33
|
+
"@itcase/common": "^1.2.8",
|
|
34
|
+
"@itcase/ui": "^1.2.2",
|
|
35
|
+
"axios": "^1.7.4",
|
|
36
36
|
"clsx": "^2.1.1",
|
|
37
37
|
"final-form": "^4.20.10",
|
|
38
38
|
"final-form-focus": "^1.1.2",
|
|
39
|
-
"libphonenumber-js": "^1.11.
|
|
39
|
+
"libphonenumber-js": "^1.11.7",
|
|
40
40
|
"lodash": "^4.17.21",
|
|
41
41
|
"luxon": "^3.5.0",
|
|
42
42
|
"postcss": "^8.4.41",
|
|
@@ -51,12 +51,12 @@
|
|
|
51
51
|
"react-select": "^5.8.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@itcase/lint": "^1.0.
|
|
54
|
+
"@itcase/lint": "^1.0.10",
|
|
55
55
|
"@babel/core": "^7.25.2",
|
|
56
56
|
"@babel/eslint-parser": "^7.25.1",
|
|
57
57
|
"@babel/preset-env": "^7.25.3",
|
|
58
58
|
"@babel/preset-react": "^7.24.7",
|
|
59
|
-
"@commitlint/cli": "^19.
|
|
59
|
+
"@commitlint/cli": "^19.4.0",
|
|
60
60
|
"@commitlint/config-conventional": "^19.2.2",
|
|
61
61
|
"@eslint/compat": "^1.1.1",
|
|
62
62
|
"@eslint/eslintrc": "^3.1.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"babel-plugin-inline-react-svg": "^2.0.2",
|
|
75
75
|
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
76
76
|
"conventional-changelog-conventionalcommits": "^8.0.0",
|
|
77
|
-
"eslint": "9.
|
|
77
|
+
"eslint": "9.9.0",
|
|
78
78
|
"eslint-config-prettier": "9.1.0",
|
|
79
79
|
"eslint-config-standard": "17.1.0",
|
|
80
80
|
"eslint-plugin-babel": "5.3.1",
|
|
@@ -82,18 +82,18 @@
|
|
|
82
82
|
"eslint-plugin-n": "17.10.2",
|
|
83
83
|
"eslint-plugin-node": "11.1.0",
|
|
84
84
|
"eslint-plugin-prettier": "5.2.1",
|
|
85
|
-
"eslint-plugin-promise": "7.
|
|
85
|
+
"eslint-plugin-promise": "7.1.0",
|
|
86
86
|
"eslint-plugin-react": "7.35.0",
|
|
87
87
|
"eslint-plugin-react-hooks": "4.6.2",
|
|
88
88
|
"eslint-plugin-standard": "5.0.0",
|
|
89
|
-
"husky": "^9.1.
|
|
90
|
-
"lint-staged": "^15.2.
|
|
89
|
+
"husky": "^9.1.5",
|
|
90
|
+
"lint-staged": "^15.2.9",
|
|
91
91
|
"npm": "^10.8.2",
|
|
92
92
|
"postcss-aspect-ratio-polyfill": "^2.0.0",
|
|
93
93
|
"postcss-cli": "^11.0.0",
|
|
94
94
|
"postcss-combine-duplicated-selectors": "^10.0.3",
|
|
95
95
|
"postcss-dark-theme-class": "^1.3.0",
|
|
96
|
-
"postcss-discard-duplicates": "^7.0.
|
|
96
|
+
"postcss-discard-duplicates": "^7.0.1",
|
|
97
97
|
"postcss-each": "^1.1.0",
|
|
98
98
|
"postcss-easings": "^4.0.0",
|
|
99
99
|
"postcss-extend-rule": "^4.0.0",
|
|
@@ -106,15 +106,15 @@
|
|
|
106
106
|
"postcss-nested-ancestors": "^3.0.0",
|
|
107
107
|
"postcss-normalize": "^10.0.1",
|
|
108
108
|
"postcss-prepend-imports": "^1.0.1",
|
|
109
|
-
"postcss-preset-env": "^10.0.
|
|
109
|
+
"postcss-preset-env": "^10.0.2",
|
|
110
110
|
"postcss-pxtorem": "^6.1.0",
|
|
111
111
|
"postcss-responsive-type": "github:ITCase/postcss-responsive-type",
|
|
112
112
|
"postcss-sort-media-queries": "^5.2.0",
|
|
113
113
|
"prettier": "3.3.3",
|
|
114
|
-
"rollup": "^4.
|
|
114
|
+
"rollup": "^4.21.0",
|
|
115
115
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
116
|
-
"semantic-release": "^24.
|
|
117
|
-
"stylelint": "^16.8.
|
|
116
|
+
"semantic-release": "^24.1.0",
|
|
117
|
+
"stylelint": "^16.8.2",
|
|
118
118
|
"stylelint-config-standard": "^36.0.1",
|
|
119
119
|
"stylelint-no-unsupported-browser-features": "^8.0.1",
|
|
120
120
|
"stylelint-order": "^6.0.4",
|