@itcase/forms 1.0.80 → 1.0.82

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.
@@ -10,8 +10,8 @@
10
10
  }
11
11
  &__message {
12
12
  &-item {
13
- height: var(--form-field-helptext-height, 20px);
14
- line-height: var(--form-field-helptext-line-height, 20px);
13
+ height: var(--form-field-helptext-height);
14
+ line-height: var(--form-field-helptext-line-height);
15
15
  padding: var(--form-field-helptext-padding, 0);
16
16
  display: block;
17
17
  }
@@ -36,7 +36,7 @@ var Button = require('@itcase/ui/components/Button');
36
36
  var Group$1 = require('@itcase/ui/components/Group');
37
37
  var Notification = require('@itcase/ui/components/Notification');
38
38
  var createDecorator = require('final-form-focus');
39
- var apisauce = require('apisauce');
39
+ require('apisauce');
40
40
 
41
41
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
42
42
 
@@ -2446,15 +2446,15 @@ MaskedInputField.propTypes = {
2446
2446
 
2447
2447
  function ChipsField(props) {
2448
2448
  const {
2449
+ name,
2450
+ initialValue,
2449
2451
  classNameGroupItem,
2450
2452
  fieldProps,
2451
- initialValue,
2452
2453
  inputProps,
2453
- isDisabled,
2454
- isRequired,
2455
- name,
2456
2454
  options,
2457
2455
  showMessage,
2456
+ isDisabled,
2457
+ isRequired,
2458
2458
  onChange
2459
2459
  } = props;
2460
2460
  const {
@@ -2473,30 +2473,30 @@ function ChipsField(props) {
2473
2473
  // eslint-disable-next-line react-hooks/exhaustive-deps
2474
2474
  }, [initialValue]);
2475
2475
  return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
2476
- initialValue: initialValue,
2477
- name: name
2476
+ name: name,
2477
+ initialValue: initialValue
2478
2478
  }, function Render({
2479
2479
  input,
2480
2480
  meta
2481
2481
  }) {
2482
2482
  const {
2483
- isErrorState,
2484
- isValidState,
2485
2483
  errorKey,
2486
- errorMessage
2484
+ errorMessage,
2485
+ isErrorState,
2486
+ isValidState
2487
2487
  } = useFieldValidationState({
2488
2488
  fieldProps: fieldProps,
2489
2489
  input: input,
2490
2490
  meta: meta
2491
2491
  });
2492
2492
  const updatedInputProps = useValidationAppearanceInputProps({
2493
- validationStateKey: isErrorState ? errorKey : 'success',
2494
- inputProps: inputProps
2493
+ inputProps: inputProps,
2494
+ validationStateKey: isErrorState ? errorKey : 'success'
2495
2495
  });
2496
2496
  const activeOptionsList = React.useMemo(() => {
2497
2497
  const emptyOptionsList = [{
2498
- value: null,
2499
- label: null
2498
+ label: null,
2499
+ value: null
2500
2500
  }];
2501
2501
  if (input?.value) {
2502
2502
  const currentOptions = options.filter(option => input.value?.includes(option.value));
@@ -2508,40 +2508,41 @@ function ChipsField(props) {
2508
2508
  className: clsx__default.default('form-field_type_chips', 'form__item_type_chips', classNameGroupItem),
2509
2509
  errorKey: errorKey,
2510
2510
  errorMessage: errorMessage,
2511
- fieldClassName: 'form-chips',
2511
+ metaError: meta.error,
2512
+ fieldClassName: "form-chips",
2512
2513
  inputName: input.name,
2513
2514
  inputValue: input.value,
2515
+ metaActive: meta.active,
2516
+ showMessage: showMessage,
2514
2517
  isDisabled: isDisabled,
2515
2518
  isErrorState: isErrorState,
2516
2519
  isRequired: isRequired,
2517
- isValidState: isValidState,
2518
- metaActive: meta.active,
2519
- metaError: meta.error,
2520
- showMessage: showMessage
2520
+ isValidState: isValidState
2521
2521
  }, fieldProps), options.map(option => /*#__PURE__*/React__default.default.createElement(Chips.Chips, Object.assign({
2522
- isActive: activeOptionsList.includes(option),
2523
2522
  className: clsx__default.default(meta.active && 'form-chips_state_focus', meta.error && meta.touched && `form-chips_state_${errorKey}`),
2524
2523
  key: option.value,
2525
2524
  label: option.label,
2526
2525
  value: option.value,
2526
+ isActive: activeOptionsList.some(activeOption => activeOption.value === option.value),
2527
+ isDisabled: option.isDisabled,
2527
2528
  onClick: () => onChangeSomeInput(input.value, option.value)
2528
2529
  }, updatedInputProps))));
2529
2530
  });
2530
2531
  }
2531
2532
  ChipsField.propTypes = {
2532
- isDisabled: PropTypes__default.default.bool,
2533
- isRequired: PropTypes__default.default.bool,
2533
+ name: PropTypes__default.default.string,
2534
+ initialValue: PropTypes__default.default.array,
2534
2535
  classNameGroupItem: PropTypes__default.default.string,
2535
2536
  fieldProps: PropTypes__default.default.object,
2536
- initialValue: PropTypes__default.default.array,
2537
2537
  input: PropTypes__default.default.object,
2538
2538
  inputProps: PropTypes__default.default.object,
2539
- name: PropTypes__default.default.string,
2540
2539
  options: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
2541
- value: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number, PropTypes__default.default.bool]),
2542
- label: PropTypes__default.default.string
2540
+ label: PropTypes__default.default.string,
2541
+ value: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number, PropTypes__default.default.bool])
2543
2542
  })),
2544
2543
  showMessage: PropTypes__default.default.bool,
2544
+ isDisabled: PropTypes__default.default.bool,
2545
+ isRequired: PropTypes__default.default.bool,
2545
2546
  onChange: PropTypes__default.default.func
2546
2547
  };
2547
2548
 
@@ -2779,46 +2780,19 @@ const sendFormDataToServer = async (url, data) => {
2779
2780
 
2780
2781
  const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalForm(props, ref) {
2781
2782
  const {
2782
- isLoading,
2783
- additionalProps,
2784
- after,
2785
- before,
2786
- buttonDirection,
2787
- buttonFill,
2788
- buttonGap,
2789
- buttonJustifyContent,
2790
- buttonPadding,
2791
2783
  className,
2784
+ type,
2785
+ initialValues,
2786
+ initialValuesEqual,
2792
2787
  config,
2793
- dataTestId,
2794
- dataTestIdButtons,
2795
- dataTestIdPrimaryButton,
2796
- dataTestIdSecondaryButton,
2797
- dataTestIdTertiaryButton,
2798
- dataTour,
2799
- dataTourButtons,
2800
- dataTourPrimaryButton,
2801
- dataTourSecondaryButton,
2802
- dataTourTertiaryButton,
2788
+ title,
2789
+ titleTextColor,
2790
+ titleTextSize,
2791
+ titleTextWeight,
2803
2792
  description,
2804
2793
  descriptionSize,
2805
2794
  descriptionTextColor,
2806
2795
  descriptionTextWeight,
2807
- disableFieldsAutoComplete,
2808
- fieldsGap,
2809
- formName,
2810
- groupGap,
2811
- initialValues,
2812
- initialValuesEqual,
2813
- language,
2814
- loader,
2815
- loaderFill,
2816
- loaderItemFill,
2817
- loaderSet,
2818
- loaderText,
2819
- mutators,
2820
- notificationCloseButton,
2821
- notificationType,
2822
2796
  primaryButton,
2823
2797
  primaryButtonFill,
2824
2798
  primaryButtonFillHover,
@@ -2827,7 +2801,6 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
2827
2801
  primaryButtonLabelTextColor,
2828
2802
  primaryButtonLabelTextWeight,
2829
2803
  primaryButtonSize,
2830
- renderFieldsWrapper = wrapperChildren => wrapperChildren,
2831
2804
  secondaryButton,
2832
2805
  secondaryButtonFill,
2833
2806
  secondaryButtonFillHover,
@@ -2836,7 +2809,6 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
2836
2809
  secondaryButtonLabelTextColor,
2837
2810
  secondaryButtonLabelTextWeight,
2838
2811
  secondaryButtonSize,
2839
- set,
2840
2812
  tertiaryButton,
2841
2813
  tertiaryButtonFill,
2842
2814
  tertiaryButtonFillHover,
@@ -2845,12 +2817,41 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
2845
2817
  tertiaryButtonLabelTextColor,
2846
2818
  tertiaryButtonLabelTextWeight,
2847
2819
  tertiaryButtonSize,
2848
- title,
2849
- titleTextColor,
2850
- titleTextSize,
2851
- titleTextWeight,
2852
- type,
2820
+ dataTestIdPrimaryButton,
2821
+ dataTourPrimaryButton,
2822
+ dataTestIdSecondaryButton,
2823
+ dataTourSecondaryButton,
2824
+ dataTestIdTertiaryButton,
2825
+ dataTourTertiaryButton,
2826
+ additionalProps,
2827
+ buttonDirection,
2828
+ buttonFill,
2829
+ buttonGap,
2830
+ buttonJustifyContent,
2831
+ buttonPadding,
2832
+ dataTestId,
2833
+ dataTestIdButtons,
2834
+ dataTour,
2835
+ dataTourButtons,
2836
+ disableFieldsAutoComplete,
2837
+ fieldsGap,
2838
+ formName,
2839
+ groupGap,
2840
+ language,
2841
+ loader,
2842
+ loaderFill,
2843
+ loaderItemFill,
2844
+ loaderSet,
2845
+ loaderText,
2846
+ mutators,
2847
+ notificationCloseButton,
2848
+ notificationType,
2849
+ renderFieldsWrapper = wrapperChildren => wrapperChildren,
2853
2850
  validationSchema,
2851
+ before,
2852
+ after,
2853
+ isLoading,
2854
+ set,
2854
2855
  onChangeFormValues,
2855
2856
  onClickSecondaryButton,
2856
2857
  onClickTertiaryButton,
@@ -2883,28 +2884,25 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
2883
2884
  wrapper: wrapperStyles
2884
2885
  } = useStyles.useStyles(props);
2885
2886
  return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Form, {
2886
- decorators: [focusOnErrorDecorator],
2887
2887
  initialValues: initialValues,
2888
2888
  initialValuesEqual: initialValuesEqual,
2889
- mutators: mutators,
2890
- validate: validate,
2891
2889
  render: ({
2890
+ submitError,
2892
2891
  form,
2893
2892
  handleSubmit,
2894
- modifiedSinceLastSubmit,
2895
- submitError
2893
+ modifiedSinceLastSubmit
2896
2894
  }) => {
2897
2895
  return /*#__PURE__*/React__default.default.createElement("form", {
2898
- className: clsx__default.default(className, 'form', set && `form_set_${set}`, type && `form_type_${type}`, directionClass, fillClass, shapeClass, elevationClass)
2899
- // We no need set reference to html element, we need reference to "final-form" instance
2900
- ,
2901
- ref: () => onRefFormInstance(form),
2896
+ className: clsx__default.default(className, 'form', set && `form_set_${set}`, type && `form_type_${type}`, directionClass, fillClass, shapeClass, elevationClass),
2902
2897
  name: formName,
2903
2898
  autoCapitalize: disableFieldsAutoComplete ? 'off' : undefined,
2904
2899
  autoComplete: disableFieldsAutoComplete ? 'off' : undefined,
2905
2900
  autoCorrect: disableFieldsAutoComplete ? 'off' : undefined,
2906
2901
  "data-test-id": dataTestId,
2907
- "data-tour": dataTour,
2902
+ "data-tour": dataTour
2903
+ // We no need set reference to html element, we need reference to "final-form" instance
2904
+ ,
2905
+ ref: () => onRefFormInstance(form),
2908
2906
  spellCheck: disableFieldsAutoComplete ? 'false' : undefined,
2909
2907
  style: formStyles,
2910
2908
  onSubmit: handleSubmit
@@ -2922,10 +2920,10 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
2922
2920
  className: clsx__default.default('notification', 'form-notification', notificationType ? `form-notification_type_${notificationType}` : 'form-notification_type_global')
2923
2921
  }, /*#__PURE__*/React__default.default.createElement(Notification.NotificationItem, {
2924
2922
  className: "form-notification__item",
2925
- closeButton: notificationCloseButton,
2926
- status: "error",
2927
2923
  title: form.getState().submitError,
2928
2924
  titleTextSize: "h6",
2925
+ status: "error",
2926
+ closeButton: notificationCloseButton,
2929
2927
  set: "form"
2930
2928
  })), onChangeFormValues && /*#__PURE__*/React__default.default.createElement(reactFinalForm.FormSpy, {
2931
2929
  subscription: {
@@ -2942,103 +2940,85 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
2942
2940
  }, additionalProps[config[key].name])), isLoading && (loader || /*#__PURE__*/React__default.default.createElement(Loader.Loader, {
2943
2941
  className: "form__loader",
2944
2942
  fill: loaderFill,
2945
- itemFill: loaderItemFill,
2946
2943
  text: loaderText,
2944
+ itemFill: loaderItemFill,
2947
2945
  set: loaderSet
2948
2946
  }))))), (primaryButtonLabel || primaryButton || secondaryButtonLabel || secondaryButton || tertiaryButton || tertiaryButtonLabel) && /*#__PURE__*/React__default.default.createElement(Group$1.Group, {
2949
2947
  className: "form__button",
2948
+ direction: buttonDirection,
2949
+ justifyContent: buttonJustifyContent,
2950
2950
  fill: buttonFill,
2951
2951
  padding: buttonPadding,
2952
- dataTestId: dataTestIdButtons,
2953
- dataTour: dataTourButtons,
2954
- direction: buttonDirection,
2955
2952
  gap: buttonGap,
2956
- justifyContent: buttonJustifyContent
2953
+ dataTestId: dataTestIdButtons,
2954
+ dataTour: dataTourButtons
2957
2955
  }, primaryButtonLabel ? /*#__PURE__*/React__default.default.createElement(Button.Button, {
2958
2956
  className: "form__button-item",
2959
2957
  width: "fill",
2960
- labelTextColor: primaryButtonLabelTextColor,
2961
- labelTextSize: primaryButtonLabelSize,
2958
+ size: primaryButtonSize,
2962
2959
  fill: primaryButtonFill,
2963
2960
  fillHover: primaryButtonFillHover,
2964
- dataTestId: dataTestIdPrimaryButton,
2965
- dataTour: dataTourPrimaryButton,
2966
2961
  label: primaryButtonLabel,
2962
+ labelTextColor: primaryButtonLabelTextColor,
2963
+ labelTextSize: primaryButtonLabelSize,
2967
2964
  labelTextWeight: primaryButtonLabelTextWeight,
2968
- size: primaryButtonSize
2965
+ dataTestId: dataTestIdPrimaryButton,
2966
+ dataTour: dataTourPrimaryButton
2969
2967
  }) : primaryButton, secondaryButtonLabel ? /*#__PURE__*/React__default.default.createElement(Button.Button, {
2970
2968
  className: "form__button-item",
2971
2969
  width: "fill",
2972
- labelTextColor: secondaryButtonLabelTextColor,
2973
- labelTextSize: secondaryButtonLabelSize,
2970
+ size: secondaryButtonSize,
2974
2971
  fill: secondaryButtonFill,
2975
2972
  fillHover: secondaryButtonFillHover,
2976
- dataTestId: dataTestIdSecondaryButton,
2977
- dataTour: dataTourSecondaryButton,
2978
2973
  label: secondaryButtonLabel,
2974
+ labelTextColor: secondaryButtonLabelTextColor,
2975
+ labelTextSize: secondaryButtonLabelSize,
2979
2976
  labelTextWeight: secondaryButtonLabelTextWeight,
2980
- size: secondaryButtonSize,
2977
+ dataTestId: dataTestIdSecondaryButton,
2978
+ dataTour: dataTourSecondaryButton,
2981
2979
  onClick: onClickSecondaryButton
2982
2980
  }) : secondaryButton, tertiaryButtonLabel ? /*#__PURE__*/React__default.default.createElement(Button.Button, {
2983
2981
  className: "form__button-item",
2984
2982
  width: "fill",
2985
- labelTextColor: tertiaryButtonLabelTextColor,
2986
- labelTextSize: tertiaryButtonLabelSize,
2983
+ size: tertiaryButtonSize,
2987
2984
  fill: tertiaryButtonFill,
2988
2985
  fillHover: tertiaryButtonFillHover,
2989
- dataTestId: dataTestIdTertiaryButton,
2990
- dataTour: dataTourTertiaryButton,
2991
2986
  label: tertiaryButtonLabel,
2987
+ labelTextColor: tertiaryButtonLabelTextColor,
2988
+ labelTextSize: tertiaryButtonLabelSize,
2992
2989
  labelTextWeight: tertiaryButtonLabelTextWeight,
2993
- size: tertiaryButtonSize,
2990
+ dataTestId: dataTestIdTertiaryButton,
2991
+ dataTour: dataTourTertiaryButton,
2994
2992
  onClick: onClickTertiaryButton
2995
2993
  }) : tertiaryButton), after);
2996
2994
  },
2995
+ decorators: [focusOnErrorDecorator],
2996
+ mutators: mutators,
2997
2997
  subscription: {
2998
+ submitError: true,
2998
2999
  modifiedSinceLastSubmit: true,
2999
3000
  pristine: true,
3000
- submitError: true,
3001
3001
  submitting: true
3002
3002
  },
3003
+ validate: validate,
3003
3004
  onSubmit: onSubmit
3004
3005
  });
3005
3006
  });
3006
3007
  FinalForm.propTypes = {
3007
- isLoading: PropTypes__default.default.bool,
3008
- additionalProps: PropTypes__default.default.object,
3009
- after: PropTypes__default.default.any,
3010
- before: PropTypes__default.default.any,
3011
- buttonDirection: PropTypes__default.default.string,
3012
- buttonFill: PropTypes__default.default.string,
3013
- buttonGap: PropTypes__default.default.string,
3014
- buttonJustifyContent: PropTypes__default.default.string,
3015
- buttonPadding: PropTypes__default.default.string,
3016
3008
  className: PropTypes__default.default.string,
3009
+ type: PropTypes__default.default.string,
3010
+ initialValues: PropTypes__default.default.any,
3011
+ initialValuesEqual: PropTypes__default.default.any,
3017
3012
  config: PropTypes__default.default.object,
3018
- dataTour: PropTypes__default.default.string,
3019
- dataTourButtons: PropTypes__default.default.string,
3020
- dataTourPrimaryButton: PropTypes__default.default.string,
3021
- dataTourSecondaryButton: PropTypes__default.default.string,
3022
- dataTourTertiaryButton: PropTypes__default.default.string,
3013
+ title: PropTypes__default.default.string,
3014
+ titleSize: PropTypes__default.default.string,
3015
+ titleTextColor: PropTypes__default.default.string,
3016
+ titleTextSize: PropTypes__default.default.string,
3017
+ titleTextWeight: PropTypes__default.default.string,
3023
3018
  description: PropTypes__default.default.string,
3024
3019
  descriptionSize: PropTypes__default.default.string,
3025
3020
  descriptionTextColor: PropTypes__default.default.string,
3026
3021
  descriptionTextWeight: PropTypes__default.default.string,
3027
- disableFieldsAutoComplete: PropTypes__default.default.bool,
3028
- fieldsGap: PropTypes__default.default.string,
3029
- formName: PropTypes__default.default.string,
3030
- groupGap: PropTypes__default.default.string,
3031
- initialValues: PropTypes__default.default.any,
3032
- initialValuesEqual: PropTypes__default.default.any,
3033
- language: PropTypes__default.default.string,
3034
- loader: PropTypes__default.default.element,
3035
- loaderFill: PropTypes__default.default.string,
3036
- loaderItemFill: PropTypes__default.default.string,
3037
- loaderSet: PropTypes__default.default.string,
3038
- loaderText: PropTypes__default.default.string,
3039
- mutators: PropTypes__default.default.any,
3040
- notificationCloseButton: PropTypes__default.default.element,
3041
- notificationType: PropTypes__default.default.string,
3042
3022
  primaryButton: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.element]),
3043
3023
  primaryButtonFill: PropTypes__default.default.string,
3044
3024
  primaryButtonFillHover: PropTypes__default.default.string,
@@ -3055,7 +3035,6 @@ FinalForm.propTypes = {
3055
3035
  secondaryButtonLabelTextColor: PropTypes__default.default.string,
3056
3036
  secondaryButtonLabelTextWeight: PropTypes__default.default.string,
3057
3037
  secondaryButtonSize: PropTypes__default.default.string,
3058
- set: PropTypes__default.default.string,
3059
3038
  tertiaryButton: PropTypes__default.default.element,
3060
3039
  tertiaryButtonFill: PropTypes__default.default.string,
3061
3040
  tertiaryButtonFillHover: PropTypes__default.default.string,
@@ -3064,13 +3043,35 @@ FinalForm.propTypes = {
3064
3043
  tertiaryButtonLabelTextColor: PropTypes__default.default.string,
3065
3044
  tertiaryButtonLabelTextWeight: PropTypes__default.default.string,
3066
3045
  tertiaryButtonSize: PropTypes__default.default.string,
3067
- title: PropTypes__default.default.string,
3068
- titleSize: PropTypes__default.default.string,
3069
- titleTextColor: PropTypes__default.default.string,
3070
- titleTextSize: PropTypes__default.default.string,
3071
- titleTextWeight: PropTypes__default.default.string,
3072
- type: PropTypes__default.default.string,
3046
+ dataTourPrimaryButton: PropTypes__default.default.string,
3047
+ dataTourSecondaryButton: PropTypes__default.default.string,
3048
+ dataTourTertiaryButton: PropTypes__default.default.string,
3049
+ additionalProps: PropTypes__default.default.object,
3050
+ buttonDirection: PropTypes__default.default.string,
3051
+ buttonFill: PropTypes__default.default.string,
3052
+ buttonGap: PropTypes__default.default.string,
3053
+ buttonJustifyContent: PropTypes__default.default.string,
3054
+ buttonPadding: PropTypes__default.default.string,
3055
+ dataTour: PropTypes__default.default.string,
3056
+ dataTourButtons: PropTypes__default.default.string,
3057
+ disableFieldsAutoComplete: PropTypes__default.default.bool,
3058
+ fieldsGap: PropTypes__default.default.string,
3059
+ formName: PropTypes__default.default.string,
3060
+ groupGap: PropTypes__default.default.string,
3061
+ language: PropTypes__default.default.string,
3062
+ loader: PropTypes__default.default.element,
3063
+ loaderFill: PropTypes__default.default.string,
3064
+ loaderItemFill: PropTypes__default.default.string,
3065
+ loaderSet: PropTypes__default.default.string,
3066
+ loaderText: PropTypes__default.default.string,
3067
+ mutators: PropTypes__default.default.any,
3068
+ notificationCloseButton: PropTypes__default.default.element,
3069
+ notificationType: PropTypes__default.default.string,
3073
3070
  validationSchema: PropTypes__default.default.object,
3071
+ before: PropTypes__default.default.any,
3072
+ after: PropTypes__default.default.any,
3073
+ isLoading: PropTypes__default.default.bool,
3074
+ set: PropTypes__default.default.string,
3074
3075
  onChangeFormValues: PropTypes__default.default.func,
3075
3076
  onClickSecondaryButton: PropTypes__default.default.func,
3076
3077
  onClickTertiaryButton: PropTypes__default.default.func,
@@ -3078,7 +3079,7 @@ FinalForm.propTypes = {
3078
3079
  };
3079
3080
  FinalForm.defaultProps = {
3080
3081
  direction: 'vertical',
3081
- isLoading: false,
3082
+ titleSize: 'h1',
3082
3083
  additionalProps: {},
3083
3084
  buttonDirection: 'vertical',
3084
3085
  disableFieldsAutoComplete: false,
@@ -3086,7 +3087,7 @@ FinalForm.defaultProps = {
3086
3087
  loaderFill: 'surfacePrimary',
3087
3088
  loaderItemFill: 'surfaceItemAccent',
3088
3089
  loaderSet: 'simple',
3089
- titleSize: 'h1'
3090
+ isLoading: false
3090
3091
  };
3091
3092
 
3092
3093
  const DEFAULT_MESSAGES_FIELDS = {
@@ -3215,49 +3216,86 @@ const parseNumericField = value => {
3215
3216
  }
3216
3217
  return '';
3217
3218
  };
3218
- const getErrorsForFinalForm = errorData => {
3219
+
3220
+ // const getErrorsForFinalForm = (errorData) => {
3221
+ // /*
3222
+ // * errorData - its an "axios" error
3223
+ // */
3224
+
3225
+ // const formErrors = {}
3226
+
3227
+ // const responseErrorMessage = errorData.toJSON ? errorData.toJSON().message : errorData.message
3228
+
3229
+ // // const status = (errorData.response && errorData.response.status) || null
3230
+ // const problemError = getProblemFromError(errorData)
3231
+ // // const problemStatus = getProblemFromStatus(status)
3232
+
3233
+ // if (problemError === NETWORK_ERROR || problemError === CONNECTION_ERROR) {
3234
+ // // Say to "react-final-form" that we have general error
3235
+ // formErrors[FORM_ERROR] = 'Проблемы с подключением к сервису'
3236
+ // } else if (errorData.response?.data) {
3237
+ // // Collect errors for some fields, which in the response from server
3238
+ // const serverErrors = errorData.response.data
3239
+ // if (typeof serverErrors === 'string') {
3240
+ // if (errorData.response.status === 500) {
3241
+ // formErrors[FORM_ERROR] =
3242
+ // 'Во время обработки запроса произошла ошибка, попробуйте повторить запрос'
3243
+ // }
3244
+ // // formErrors[FORM_ERROR] = responseErrorMessage
3245
+ // } else {
3246
+ // if (errorData.response.status === 500) {
3247
+ // formErrors[FORM_ERROR] =
3248
+ // 'Во время обработки запроса произошла ошибка, попробуйте повторить запрос'
3249
+ // }
3250
+ // for (const key in serverErrors) {
3251
+ // // TODO: what is forms has "detail" field? show as form error is well?
3252
+ // const errorFieldKey = key === 'non_field_errors' || key === 'detail' ? FORM_ERROR : key
3253
+ // // Say to "react-final-form" that we have some fields errors
3254
+ // formErrors[errorFieldKey] = castArray(serverErrors[key])[0]
3255
+ // }
3256
+ // }
3257
+ // } else if (typeof errorData === 'object' && Object.keys(errorData).length) {
3258
+ // for (const key in errorData) {
3259
+ // const errorFieldKey = key === 'non_field_errors' || key === 'detail' ? FORM_ERROR : key
3260
+ // // Say to "react-final-form" that we have some fields errors
3261
+ // formErrors[errorFieldKey] = castArray(errorData[key])[0]
3262
+ // }
3263
+ // } else {
3264
+ // // Say to "react-final-form" that we have general error
3265
+ // formErrors[FORM_ERROR] = responseErrorMessage || 'Произошла ошибка'
3266
+ // }
3267
+
3268
+ // return formErrors
3269
+ // }
3270
+
3271
+ const getErrorsForFinalForm = error => {
3219
3272
  /*
3220
- * errorData - its an "axios" error
3273
+ * error - its an "axios" error in many cases
3221
3274
  */
3222
3275
 
3223
3276
  const formErrors = {};
3224
- const responseErrorMessage = errorData.toJSON ? errorData.toJSON().message : errorData.message;
3225
-
3226
- // const status = (errorData.response && errorData.response.status) || null
3227
- const problemError = apisauce.getProblemFromError(errorData);
3228
- // const problemStatus = getProblemFromStatus(status)
3229
-
3230
- if (problemError === apisauce.NETWORK_ERROR || problemError === apisauce.CONNECTION_ERROR) {
3231
- // Say to "react-final-form" that we have general error
3232
- formErrors[finalForm.FORM_ERROR] = 'Проблемы с подключением к сервису';
3233
- } else if (errorData.response?.data) {
3277
+ const serverErrors = error.response?.data;
3278
+ if (serverErrors) {
3234
3279
  // Collect errors for some fields, which in the response from server
3235
- const serverErrors = errorData.response.data;
3236
3280
  if (typeof serverErrors === 'string') {
3237
- if (errorData.response.status === 500) {
3238
- formErrors[finalForm.FORM_ERROR] = 'Во время обработки запроса произошла ошибка, попробуйте повторить запрос';
3239
- }
3240
- // formErrors[FORM_ERROR] = responseErrorMessage
3281
+ // Server may send an html page as error data
3282
+ formErrors[finalForm.FORM_ERROR] = 'Во время обработки запроса произошла ошибка, попробуйте повторить запрос';
3241
3283
  } else {
3242
- if (errorData.response.status === 500) {
3243
- formErrors[finalForm.FORM_ERROR] = 'Во время обработки запроса произошла ошибка, попробуйте повторить запрос';
3244
- }
3245
3284
  for (const key in serverErrors) {
3246
- // TODO: what is forms has "detail" field? show as form error is well?
3285
+ // "non_field_errors" and "detail" is special keys in django to mark errors not for fields
3247
3286
  const errorFieldKey = key === 'non_field_errors' || key === 'detail' ? finalForm.FORM_ERROR : key;
3287
+
3248
3288
  // Say to "react-final-form" that we have some fields errors
3249
3289
  formErrors[errorFieldKey] = castArray__default.default(serverErrors[key])[0];
3250
3290
  }
3251
3291
  }
3252
- } else if (typeof errorData === 'object' && Object.keys(errorData).length) {
3253
- for (const key in errorData) {
3254
- const errorFieldKey = key === 'non_field_errors' || key === 'detail' ? finalForm.FORM_ERROR : key;
3255
- // Say to "react-final-form" that we have some fields errors
3256
- formErrors[errorFieldKey] = castArray__default.default(errorData[key])[0];
3257
- }
3258
3292
  } else {
3293
+ // const responseErrorMessage = error.toJSON
3294
+ // ? error.toJSON().message
3295
+ // : error.message
3296
+
3259
3297
  // Say to "react-final-form" that we have general error
3260
- formErrors[finalForm.FORM_ERROR] = responseErrorMessage || 'Произошла ошибка';
3298
+ formErrors[finalForm.FORM_ERROR] = error.message || 'Произошла ошибка';
3261
3299
  }
3262
3300
  return formErrors;
3263
3301
  };
@@ -35,7 +35,7 @@ import { Button } from '@itcase/ui/components/Button';
35
35
  import { Group as Group$1 } from '@itcase/ui/components/Group';
36
36
  import { NotificationItem } from '@itcase/ui/components/Notification';
37
37
  import createDecorator from 'final-form-focus';
38
- import { getProblemFromError, NETWORK_ERROR, CONNECTION_ERROR } from 'apisauce';
38
+ import 'apisauce';
39
39
 
40
40
  const phoneValidation = value => {
41
41
  if (!value) {
@@ -2434,15 +2434,15 @@ MaskedInputField.propTypes = {
2434
2434
 
2435
2435
  function ChipsField(props) {
2436
2436
  const {
2437
+ name,
2438
+ initialValue,
2437
2439
  classNameGroupItem,
2438
2440
  fieldProps,
2439
- initialValue,
2440
2441
  inputProps,
2441
- isDisabled,
2442
- isRequired,
2443
- name,
2444
2442
  options,
2445
2443
  showMessage,
2444
+ isDisabled,
2445
+ isRequired,
2446
2446
  onChange
2447
2447
  } = props;
2448
2448
  const {
@@ -2461,30 +2461,30 @@ function ChipsField(props) {
2461
2461
  // eslint-disable-next-line react-hooks/exhaustive-deps
2462
2462
  }, [initialValue]);
2463
2463
  return /*#__PURE__*/React.createElement(Field, {
2464
- initialValue: initialValue,
2465
- name: name
2464
+ name: name,
2465
+ initialValue: initialValue
2466
2466
  }, function Render({
2467
2467
  input,
2468
2468
  meta
2469
2469
  }) {
2470
2470
  const {
2471
- isErrorState,
2472
- isValidState,
2473
2471
  errorKey,
2474
- errorMessage
2472
+ errorMessage,
2473
+ isErrorState,
2474
+ isValidState
2475
2475
  } = useFieldValidationState({
2476
2476
  fieldProps: fieldProps,
2477
2477
  input: input,
2478
2478
  meta: meta
2479
2479
  });
2480
2480
  const updatedInputProps = useValidationAppearanceInputProps({
2481
- validationStateKey: isErrorState ? errorKey : 'success',
2482
- inputProps: inputProps
2481
+ inputProps: inputProps,
2482
+ validationStateKey: isErrorState ? errorKey : 'success'
2483
2483
  });
2484
2484
  const activeOptionsList = useMemo(() => {
2485
2485
  const emptyOptionsList = [{
2486
- value: null,
2487
- label: null
2486
+ label: null,
2487
+ value: null
2488
2488
  }];
2489
2489
  if (input?.value) {
2490
2490
  const currentOptions = options.filter(option => input.value?.includes(option.value));
@@ -2496,40 +2496,41 @@ function ChipsField(props) {
2496
2496
  className: clsx('form-field_type_chips', 'form__item_type_chips', classNameGroupItem),
2497
2497
  errorKey: errorKey,
2498
2498
  errorMessage: errorMessage,
2499
- fieldClassName: 'form-chips',
2499
+ metaError: meta.error,
2500
+ fieldClassName: "form-chips",
2500
2501
  inputName: input.name,
2501
2502
  inputValue: input.value,
2503
+ metaActive: meta.active,
2504
+ showMessage: showMessage,
2502
2505
  isDisabled: isDisabled,
2503
2506
  isErrorState: isErrorState,
2504
2507
  isRequired: isRequired,
2505
- isValidState: isValidState,
2506
- metaActive: meta.active,
2507
- metaError: meta.error,
2508
- showMessage: showMessage
2508
+ isValidState: isValidState
2509
2509
  }, fieldProps), options.map(option => /*#__PURE__*/React.createElement(Chips, Object.assign({
2510
- isActive: activeOptionsList.includes(option),
2511
2510
  className: clsx(meta.active && 'form-chips_state_focus', meta.error && meta.touched && `form-chips_state_${errorKey}`),
2512
2511
  key: option.value,
2513
2512
  label: option.label,
2514
2513
  value: option.value,
2514
+ isActive: activeOptionsList.some(activeOption => activeOption.value === option.value),
2515
+ isDisabled: option.isDisabled,
2515
2516
  onClick: () => onChangeSomeInput(input.value, option.value)
2516
2517
  }, updatedInputProps))));
2517
2518
  });
2518
2519
  }
2519
2520
  ChipsField.propTypes = {
2520
- isDisabled: PropTypes.bool,
2521
- isRequired: PropTypes.bool,
2521
+ name: PropTypes.string,
2522
+ initialValue: PropTypes.array,
2522
2523
  classNameGroupItem: PropTypes.string,
2523
2524
  fieldProps: PropTypes.object,
2524
- initialValue: PropTypes.array,
2525
2525
  input: PropTypes.object,
2526
2526
  inputProps: PropTypes.object,
2527
- name: PropTypes.string,
2528
2527
  options: PropTypes.arrayOf(PropTypes.shape({
2529
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
2530
- label: PropTypes.string
2528
+ label: PropTypes.string,
2529
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool])
2531
2530
  })),
2532
2531
  showMessage: PropTypes.bool,
2532
+ isDisabled: PropTypes.bool,
2533
+ isRequired: PropTypes.bool,
2533
2534
  onChange: PropTypes.func
2534
2535
  };
2535
2536
 
@@ -2767,46 +2768,19 @@ const sendFormDataToServer = async (url, data) => {
2767
2768
 
2768
2769
  const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2769
2770
  const {
2770
- isLoading,
2771
- additionalProps,
2772
- after,
2773
- before,
2774
- buttonDirection,
2775
- buttonFill,
2776
- buttonGap,
2777
- buttonJustifyContent,
2778
- buttonPadding,
2779
2771
  className,
2772
+ type,
2773
+ initialValues,
2774
+ initialValuesEqual,
2780
2775
  config,
2781
- dataTestId,
2782
- dataTestIdButtons,
2783
- dataTestIdPrimaryButton,
2784
- dataTestIdSecondaryButton,
2785
- dataTestIdTertiaryButton,
2786
- dataTour,
2787
- dataTourButtons,
2788
- dataTourPrimaryButton,
2789
- dataTourSecondaryButton,
2790
- dataTourTertiaryButton,
2776
+ title,
2777
+ titleTextColor,
2778
+ titleTextSize,
2779
+ titleTextWeight,
2791
2780
  description,
2792
2781
  descriptionSize,
2793
2782
  descriptionTextColor,
2794
2783
  descriptionTextWeight,
2795
- disableFieldsAutoComplete,
2796
- fieldsGap,
2797
- formName,
2798
- groupGap,
2799
- initialValues,
2800
- initialValuesEqual,
2801
- language,
2802
- loader,
2803
- loaderFill,
2804
- loaderItemFill,
2805
- loaderSet,
2806
- loaderText,
2807
- mutators,
2808
- notificationCloseButton,
2809
- notificationType,
2810
2784
  primaryButton,
2811
2785
  primaryButtonFill,
2812
2786
  primaryButtonFillHover,
@@ -2815,7 +2789,6 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2815
2789
  primaryButtonLabelTextColor,
2816
2790
  primaryButtonLabelTextWeight,
2817
2791
  primaryButtonSize,
2818
- renderFieldsWrapper = wrapperChildren => wrapperChildren,
2819
2792
  secondaryButton,
2820
2793
  secondaryButtonFill,
2821
2794
  secondaryButtonFillHover,
@@ -2824,7 +2797,6 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2824
2797
  secondaryButtonLabelTextColor,
2825
2798
  secondaryButtonLabelTextWeight,
2826
2799
  secondaryButtonSize,
2827
- set,
2828
2800
  tertiaryButton,
2829
2801
  tertiaryButtonFill,
2830
2802
  tertiaryButtonFillHover,
@@ -2833,12 +2805,41 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2833
2805
  tertiaryButtonLabelTextColor,
2834
2806
  tertiaryButtonLabelTextWeight,
2835
2807
  tertiaryButtonSize,
2836
- title,
2837
- titleTextColor,
2838
- titleTextSize,
2839
- titleTextWeight,
2840
- type,
2808
+ dataTestIdPrimaryButton,
2809
+ dataTourPrimaryButton,
2810
+ dataTestIdSecondaryButton,
2811
+ dataTourSecondaryButton,
2812
+ dataTestIdTertiaryButton,
2813
+ dataTourTertiaryButton,
2814
+ additionalProps,
2815
+ buttonDirection,
2816
+ buttonFill,
2817
+ buttonGap,
2818
+ buttonJustifyContent,
2819
+ buttonPadding,
2820
+ dataTestId,
2821
+ dataTestIdButtons,
2822
+ dataTour,
2823
+ dataTourButtons,
2824
+ disableFieldsAutoComplete,
2825
+ fieldsGap,
2826
+ formName,
2827
+ groupGap,
2828
+ language,
2829
+ loader,
2830
+ loaderFill,
2831
+ loaderItemFill,
2832
+ loaderSet,
2833
+ loaderText,
2834
+ mutators,
2835
+ notificationCloseButton,
2836
+ notificationType,
2837
+ renderFieldsWrapper = wrapperChildren => wrapperChildren,
2841
2838
  validationSchema,
2839
+ before,
2840
+ after,
2841
+ isLoading,
2842
+ set,
2842
2843
  onChangeFormValues,
2843
2844
  onClickSecondaryButton,
2844
2845
  onClickTertiaryButton,
@@ -2871,28 +2872,25 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2871
2872
  wrapper: wrapperStyles
2872
2873
  } = useStyles(props);
2873
2874
  return /*#__PURE__*/React.createElement(Form, {
2874
- decorators: [focusOnErrorDecorator],
2875
2875
  initialValues: initialValues,
2876
2876
  initialValuesEqual: initialValuesEqual,
2877
- mutators: mutators,
2878
- validate: validate,
2879
2877
  render: ({
2878
+ submitError,
2880
2879
  form,
2881
2880
  handleSubmit,
2882
- modifiedSinceLastSubmit,
2883
- submitError
2881
+ modifiedSinceLastSubmit
2884
2882
  }) => {
2885
2883
  return /*#__PURE__*/React.createElement("form", {
2886
- className: clsx(className, 'form', set && `form_set_${set}`, type && `form_type_${type}`, directionClass, fillClass, shapeClass, elevationClass)
2887
- // We no need set reference to html element, we need reference to "final-form" instance
2888
- ,
2889
- ref: () => onRefFormInstance(form),
2884
+ className: clsx(className, 'form', set && `form_set_${set}`, type && `form_type_${type}`, directionClass, fillClass, shapeClass, elevationClass),
2890
2885
  name: formName,
2891
2886
  autoCapitalize: disableFieldsAutoComplete ? 'off' : undefined,
2892
2887
  autoComplete: disableFieldsAutoComplete ? 'off' : undefined,
2893
2888
  autoCorrect: disableFieldsAutoComplete ? 'off' : undefined,
2894
2889
  "data-test-id": dataTestId,
2895
- "data-tour": dataTour,
2890
+ "data-tour": dataTour
2891
+ // We no need set reference to html element, we need reference to "final-form" instance
2892
+ ,
2893
+ ref: () => onRefFormInstance(form),
2896
2894
  spellCheck: disableFieldsAutoComplete ? 'false' : undefined,
2897
2895
  style: formStyles,
2898
2896
  onSubmit: handleSubmit
@@ -2910,10 +2908,10 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2910
2908
  className: clsx('notification', 'form-notification', notificationType ? `form-notification_type_${notificationType}` : 'form-notification_type_global')
2911
2909
  }, /*#__PURE__*/React.createElement(NotificationItem, {
2912
2910
  className: "form-notification__item",
2913
- closeButton: notificationCloseButton,
2914
- status: "error",
2915
2911
  title: form.getState().submitError,
2916
2912
  titleTextSize: "h6",
2913
+ status: "error",
2914
+ closeButton: notificationCloseButton,
2917
2915
  set: "form"
2918
2916
  })), onChangeFormValues && /*#__PURE__*/React.createElement(FormSpy, {
2919
2917
  subscription: {
@@ -2930,103 +2928,85 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2930
2928
  }, additionalProps[config[key].name])), isLoading && (loader || /*#__PURE__*/React.createElement(Loader, {
2931
2929
  className: "form__loader",
2932
2930
  fill: loaderFill,
2933
- itemFill: loaderItemFill,
2934
2931
  text: loaderText,
2932
+ itemFill: loaderItemFill,
2935
2933
  set: loaderSet
2936
2934
  }))))), (primaryButtonLabel || primaryButton || secondaryButtonLabel || secondaryButton || tertiaryButton || tertiaryButtonLabel) && /*#__PURE__*/React.createElement(Group$1, {
2937
2935
  className: "form__button",
2936
+ direction: buttonDirection,
2937
+ justifyContent: buttonJustifyContent,
2938
2938
  fill: buttonFill,
2939
2939
  padding: buttonPadding,
2940
- dataTestId: dataTestIdButtons,
2941
- dataTour: dataTourButtons,
2942
- direction: buttonDirection,
2943
2940
  gap: buttonGap,
2944
- justifyContent: buttonJustifyContent
2941
+ dataTestId: dataTestIdButtons,
2942
+ dataTour: dataTourButtons
2945
2943
  }, primaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
2946
2944
  className: "form__button-item",
2947
2945
  width: "fill",
2948
- labelTextColor: primaryButtonLabelTextColor,
2949
- labelTextSize: primaryButtonLabelSize,
2946
+ size: primaryButtonSize,
2950
2947
  fill: primaryButtonFill,
2951
2948
  fillHover: primaryButtonFillHover,
2952
- dataTestId: dataTestIdPrimaryButton,
2953
- dataTour: dataTourPrimaryButton,
2954
2949
  label: primaryButtonLabel,
2950
+ labelTextColor: primaryButtonLabelTextColor,
2951
+ labelTextSize: primaryButtonLabelSize,
2955
2952
  labelTextWeight: primaryButtonLabelTextWeight,
2956
- size: primaryButtonSize
2953
+ dataTestId: dataTestIdPrimaryButton,
2954
+ dataTour: dataTourPrimaryButton
2957
2955
  }) : primaryButton, secondaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
2958
2956
  className: "form__button-item",
2959
2957
  width: "fill",
2960
- labelTextColor: secondaryButtonLabelTextColor,
2961
- labelTextSize: secondaryButtonLabelSize,
2958
+ size: secondaryButtonSize,
2962
2959
  fill: secondaryButtonFill,
2963
2960
  fillHover: secondaryButtonFillHover,
2964
- dataTestId: dataTestIdSecondaryButton,
2965
- dataTour: dataTourSecondaryButton,
2966
2961
  label: secondaryButtonLabel,
2962
+ labelTextColor: secondaryButtonLabelTextColor,
2963
+ labelTextSize: secondaryButtonLabelSize,
2967
2964
  labelTextWeight: secondaryButtonLabelTextWeight,
2968
- size: secondaryButtonSize,
2965
+ dataTestId: dataTestIdSecondaryButton,
2966
+ dataTour: dataTourSecondaryButton,
2969
2967
  onClick: onClickSecondaryButton
2970
2968
  }) : secondaryButton, tertiaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
2971
2969
  className: "form__button-item",
2972
2970
  width: "fill",
2973
- labelTextColor: tertiaryButtonLabelTextColor,
2974
- labelTextSize: tertiaryButtonLabelSize,
2971
+ size: tertiaryButtonSize,
2975
2972
  fill: tertiaryButtonFill,
2976
2973
  fillHover: tertiaryButtonFillHover,
2977
- dataTestId: dataTestIdTertiaryButton,
2978
- dataTour: dataTourTertiaryButton,
2979
2974
  label: tertiaryButtonLabel,
2975
+ labelTextColor: tertiaryButtonLabelTextColor,
2976
+ labelTextSize: tertiaryButtonLabelSize,
2980
2977
  labelTextWeight: tertiaryButtonLabelTextWeight,
2981
- size: tertiaryButtonSize,
2978
+ dataTestId: dataTestIdTertiaryButton,
2979
+ dataTour: dataTourTertiaryButton,
2982
2980
  onClick: onClickTertiaryButton
2983
2981
  }) : tertiaryButton), after);
2984
2982
  },
2983
+ decorators: [focusOnErrorDecorator],
2984
+ mutators: mutators,
2985
2985
  subscription: {
2986
+ submitError: true,
2986
2987
  modifiedSinceLastSubmit: true,
2987
2988
  pristine: true,
2988
- submitError: true,
2989
2989
  submitting: true
2990
2990
  },
2991
+ validate: validate,
2991
2992
  onSubmit: onSubmit
2992
2993
  });
2993
2994
  });
2994
2995
  FinalForm.propTypes = {
2995
- isLoading: PropTypes.bool,
2996
- additionalProps: PropTypes.object,
2997
- after: PropTypes.any,
2998
- before: PropTypes.any,
2999
- buttonDirection: PropTypes.string,
3000
- buttonFill: PropTypes.string,
3001
- buttonGap: PropTypes.string,
3002
- buttonJustifyContent: PropTypes.string,
3003
- buttonPadding: PropTypes.string,
3004
2996
  className: PropTypes.string,
2997
+ type: PropTypes.string,
2998
+ initialValues: PropTypes.any,
2999
+ initialValuesEqual: PropTypes.any,
3005
3000
  config: PropTypes.object,
3006
- dataTour: PropTypes.string,
3007
- dataTourButtons: PropTypes.string,
3008
- dataTourPrimaryButton: PropTypes.string,
3009
- dataTourSecondaryButton: PropTypes.string,
3010
- dataTourTertiaryButton: PropTypes.string,
3001
+ title: PropTypes.string,
3002
+ titleSize: PropTypes.string,
3003
+ titleTextColor: PropTypes.string,
3004
+ titleTextSize: PropTypes.string,
3005
+ titleTextWeight: PropTypes.string,
3011
3006
  description: PropTypes.string,
3012
3007
  descriptionSize: PropTypes.string,
3013
3008
  descriptionTextColor: PropTypes.string,
3014
3009
  descriptionTextWeight: PropTypes.string,
3015
- disableFieldsAutoComplete: PropTypes.bool,
3016
- fieldsGap: PropTypes.string,
3017
- formName: PropTypes.string,
3018
- groupGap: PropTypes.string,
3019
- initialValues: PropTypes.any,
3020
- initialValuesEqual: PropTypes.any,
3021
- language: PropTypes.string,
3022
- loader: PropTypes.element,
3023
- loaderFill: PropTypes.string,
3024
- loaderItemFill: PropTypes.string,
3025
- loaderSet: PropTypes.string,
3026
- loaderText: PropTypes.string,
3027
- mutators: PropTypes.any,
3028
- notificationCloseButton: PropTypes.element,
3029
- notificationType: PropTypes.string,
3030
3010
  primaryButton: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
3031
3011
  primaryButtonFill: PropTypes.string,
3032
3012
  primaryButtonFillHover: PropTypes.string,
@@ -3043,7 +3023,6 @@ FinalForm.propTypes = {
3043
3023
  secondaryButtonLabelTextColor: PropTypes.string,
3044
3024
  secondaryButtonLabelTextWeight: PropTypes.string,
3045
3025
  secondaryButtonSize: PropTypes.string,
3046
- set: PropTypes.string,
3047
3026
  tertiaryButton: PropTypes.element,
3048
3027
  tertiaryButtonFill: PropTypes.string,
3049
3028
  tertiaryButtonFillHover: PropTypes.string,
@@ -3052,13 +3031,35 @@ FinalForm.propTypes = {
3052
3031
  tertiaryButtonLabelTextColor: PropTypes.string,
3053
3032
  tertiaryButtonLabelTextWeight: PropTypes.string,
3054
3033
  tertiaryButtonSize: PropTypes.string,
3055
- title: PropTypes.string,
3056
- titleSize: PropTypes.string,
3057
- titleTextColor: PropTypes.string,
3058
- titleTextSize: PropTypes.string,
3059
- titleTextWeight: PropTypes.string,
3060
- type: PropTypes.string,
3034
+ dataTourPrimaryButton: PropTypes.string,
3035
+ dataTourSecondaryButton: PropTypes.string,
3036
+ dataTourTertiaryButton: PropTypes.string,
3037
+ additionalProps: PropTypes.object,
3038
+ buttonDirection: PropTypes.string,
3039
+ buttonFill: PropTypes.string,
3040
+ buttonGap: PropTypes.string,
3041
+ buttonJustifyContent: PropTypes.string,
3042
+ buttonPadding: PropTypes.string,
3043
+ dataTour: PropTypes.string,
3044
+ dataTourButtons: PropTypes.string,
3045
+ disableFieldsAutoComplete: PropTypes.bool,
3046
+ fieldsGap: PropTypes.string,
3047
+ formName: PropTypes.string,
3048
+ groupGap: PropTypes.string,
3049
+ language: PropTypes.string,
3050
+ loader: PropTypes.element,
3051
+ loaderFill: PropTypes.string,
3052
+ loaderItemFill: PropTypes.string,
3053
+ loaderSet: PropTypes.string,
3054
+ loaderText: PropTypes.string,
3055
+ mutators: PropTypes.any,
3056
+ notificationCloseButton: PropTypes.element,
3057
+ notificationType: PropTypes.string,
3061
3058
  validationSchema: PropTypes.object,
3059
+ before: PropTypes.any,
3060
+ after: PropTypes.any,
3061
+ isLoading: PropTypes.bool,
3062
+ set: PropTypes.string,
3062
3063
  onChangeFormValues: PropTypes.func,
3063
3064
  onClickSecondaryButton: PropTypes.func,
3064
3065
  onClickTertiaryButton: PropTypes.func,
@@ -3066,7 +3067,7 @@ FinalForm.propTypes = {
3066
3067
  };
3067
3068
  FinalForm.defaultProps = {
3068
3069
  direction: 'vertical',
3069
- isLoading: false,
3070
+ titleSize: 'h1',
3070
3071
  additionalProps: {},
3071
3072
  buttonDirection: 'vertical',
3072
3073
  disableFieldsAutoComplete: false,
@@ -3074,7 +3075,7 @@ FinalForm.defaultProps = {
3074
3075
  loaderFill: 'surfacePrimary',
3075
3076
  loaderItemFill: 'surfaceItemAccent',
3076
3077
  loaderSet: 'simple',
3077
- titleSize: 'h1'
3078
+ isLoading: false
3078
3079
  };
3079
3080
 
3080
3081
  const DEFAULT_MESSAGES_FIELDS = {
@@ -3203,49 +3204,86 @@ const parseNumericField = value => {
3203
3204
  }
3204
3205
  return '';
3205
3206
  };
3206
- const getErrorsForFinalForm = errorData => {
3207
+
3208
+ // const getErrorsForFinalForm = (errorData) => {
3209
+ // /*
3210
+ // * errorData - its an "axios" error
3211
+ // */
3212
+
3213
+ // const formErrors = {}
3214
+
3215
+ // const responseErrorMessage = errorData.toJSON ? errorData.toJSON().message : errorData.message
3216
+
3217
+ // // const status = (errorData.response && errorData.response.status) || null
3218
+ // const problemError = getProblemFromError(errorData)
3219
+ // // const problemStatus = getProblemFromStatus(status)
3220
+
3221
+ // if (problemError === NETWORK_ERROR || problemError === CONNECTION_ERROR) {
3222
+ // // Say to "react-final-form" that we have general error
3223
+ // formErrors[FORM_ERROR] = 'Проблемы с подключением к сервису'
3224
+ // } else if (errorData.response?.data) {
3225
+ // // Collect errors for some fields, which in the response from server
3226
+ // const serverErrors = errorData.response.data
3227
+ // if (typeof serverErrors === 'string') {
3228
+ // if (errorData.response.status === 500) {
3229
+ // formErrors[FORM_ERROR] =
3230
+ // 'Во время обработки запроса произошла ошибка, попробуйте повторить запрос'
3231
+ // }
3232
+ // // formErrors[FORM_ERROR] = responseErrorMessage
3233
+ // } else {
3234
+ // if (errorData.response.status === 500) {
3235
+ // formErrors[FORM_ERROR] =
3236
+ // 'Во время обработки запроса произошла ошибка, попробуйте повторить запрос'
3237
+ // }
3238
+ // for (const key in serverErrors) {
3239
+ // // TODO: what is forms has "detail" field? show as form error is well?
3240
+ // const errorFieldKey = key === 'non_field_errors' || key === 'detail' ? FORM_ERROR : key
3241
+ // // Say to "react-final-form" that we have some fields errors
3242
+ // formErrors[errorFieldKey] = castArray(serverErrors[key])[0]
3243
+ // }
3244
+ // }
3245
+ // } else if (typeof errorData === 'object' && Object.keys(errorData).length) {
3246
+ // for (const key in errorData) {
3247
+ // const errorFieldKey = key === 'non_field_errors' || key === 'detail' ? FORM_ERROR : key
3248
+ // // Say to "react-final-form" that we have some fields errors
3249
+ // formErrors[errorFieldKey] = castArray(errorData[key])[0]
3250
+ // }
3251
+ // } else {
3252
+ // // Say to "react-final-form" that we have general error
3253
+ // formErrors[FORM_ERROR] = responseErrorMessage || 'Произошла ошибка'
3254
+ // }
3255
+
3256
+ // return formErrors
3257
+ // }
3258
+
3259
+ const getErrorsForFinalForm = error => {
3207
3260
  /*
3208
- * errorData - its an "axios" error
3261
+ * error - its an "axios" error in many cases
3209
3262
  */
3210
3263
 
3211
3264
  const formErrors = {};
3212
- const responseErrorMessage = errorData.toJSON ? errorData.toJSON().message : errorData.message;
3213
-
3214
- // const status = (errorData.response && errorData.response.status) || null
3215
- const problemError = getProblemFromError(errorData);
3216
- // const problemStatus = getProblemFromStatus(status)
3217
-
3218
- if (problemError === NETWORK_ERROR || problemError === CONNECTION_ERROR) {
3219
- // Say to "react-final-form" that we have general error
3220
- formErrors[FORM_ERROR] = 'Проблемы с подключением к сервису';
3221
- } else if (errorData.response?.data) {
3265
+ const serverErrors = error.response?.data;
3266
+ if (serverErrors) {
3222
3267
  // Collect errors for some fields, which in the response from server
3223
- const serverErrors = errorData.response.data;
3224
3268
  if (typeof serverErrors === 'string') {
3225
- if (errorData.response.status === 500) {
3226
- formErrors[FORM_ERROR] = 'Во время обработки запроса произошла ошибка, попробуйте повторить запрос';
3227
- }
3228
- // formErrors[FORM_ERROR] = responseErrorMessage
3269
+ // Server may send an html page as error data
3270
+ formErrors[FORM_ERROR] = 'Во время обработки запроса произошла ошибка, попробуйте повторить запрос';
3229
3271
  } else {
3230
- if (errorData.response.status === 500) {
3231
- formErrors[FORM_ERROR] = 'Во время обработки запроса произошла ошибка, попробуйте повторить запрос';
3232
- }
3233
3272
  for (const key in serverErrors) {
3234
- // TODO: what is forms has "detail" field? show as form error is well?
3273
+ // "non_field_errors" and "detail" is special keys in django to mark errors not for fields
3235
3274
  const errorFieldKey = key === 'non_field_errors' || key === 'detail' ? FORM_ERROR : key;
3275
+
3236
3276
  // Say to "react-final-form" that we have some fields errors
3237
3277
  formErrors[errorFieldKey] = castArray(serverErrors[key])[0];
3238
3278
  }
3239
3279
  }
3240
- } else if (typeof errorData === 'object' && Object.keys(errorData).length) {
3241
- for (const key in errorData) {
3242
- const errorFieldKey = key === 'non_field_errors' || key === 'detail' ? FORM_ERROR : key;
3243
- // Say to "react-final-form" that we have some fields errors
3244
- formErrors[errorFieldKey] = castArray(errorData[key])[0];
3245
- }
3246
3280
  } else {
3281
+ // const responseErrorMessage = error.toJSON
3282
+ // ? error.toJSON().message
3283
+ // : error.message
3284
+
3247
3285
  // Say to "react-final-form" that we have general error
3248
- formErrors[FORM_ERROR] = responseErrorMessage || 'Произошла ошибка';
3286
+ formErrors[FORM_ERROR] = error.message || 'Произошла ошибка';
3249
3287
  }
3250
3288
  return formErrors;
3251
3289
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itcase/forms",
3
- "version": "1.0.80",
3
+ "version": "1.0.82",
4
4
  "description": "Forms fields, inputs, etc.",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -30,9 +30,9 @@
30
30
  "registry": "https://registry.npmjs.org/"
31
31
  },
32
32
  "dependencies": {
33
- "@itcase/common": "^1.2.19",
33
+ "@itcase/common": "^1.2.22",
34
34
  "@itcase/config": "^1.0.26",
35
- "@itcase/ui": "^1.3.36",
35
+ "@itcase/ui": "^1.4.5",
36
36
  "axios": "^1.8.4",
37
37
  "clsx": "^2.1.1",
38
38
  "final-form": "^4.20.10",
@@ -43,7 +43,7 @@
43
43
  "prop-types": "^15.8.1",
44
44
  "react": "^18.3.1",
45
45
  "react-date-range": "^2.0.1",
46
- "react-datepicker": "^8.2.1",
46
+ "react-datepicker": "^8.3.0",
47
47
  "react-dom": "^18.3.1",
48
48
  "react-dropzone": "^14.3.8",
49
49
  "react-final-form": "^6.5.9",
@@ -51,7 +51,7 @@
51
51
  "react-select": "^5.10.1"
52
52
  },
53
53
  "devDependencies": {
54
- "@itcase/lint": "^1.0.49",
54
+ "@itcase/lint": "^1.1.4",
55
55
  "@babel/core": "^7.26.10",
56
56
  "@babel/eslint-parser": "^7.27.0",
57
57
  "@babel/preset-env": "^7.26.9",
@@ -71,15 +71,15 @@
71
71
  "babel-plugin-inline-react-svg": "^2.0.2",
72
72
  "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
73
73
  "conventional-changelog-conventionalcommits": "^8.0.0",
74
- "eslint": "9.23.0",
74
+ "eslint": "9.24.0",
75
75
  "husky": "^9.1.7",
76
76
  "lint-staged": "^15.5.0",
77
77
  "postcss": "^8.5.3",
78
78
  "prettier": "3.5.3",
79
- "rollup": "^4.38.0",
79
+ "rollup": "^4.39.0",
80
80
  "rollup-plugin-peer-deps-external": "^2.2.4",
81
81
  "semantic-release": "^24.2.3",
82
- "stylelint": "^16.17.0",
83
- "typescript": "^5.8.2"
82
+ "stylelint": "^16.18.0",
83
+ "typescript": "^5.8.3"
84
84
  }
85
85
  }