@itcase/forms 1.1.28 → 1.1.29

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.
@@ -190,8 +190,8 @@ function useFieldValidationState(props) {
190
190
  // looks at what props were in initialProps, if they are there then changes
191
191
  function useValidationAppearanceInputProps(props) {
192
192
  const {
193
- validationStateKey,
194
- inputProps
193
+ inputProps,
194
+ validationStateKey
195
195
  } = props;
196
196
 
197
197
  // TODO: need to add props that can change during errors in this field
@@ -205,7 +205,7 @@ function useValidationAppearanceInputProps(props) {
205
205
  // }
206
206
  const updatedInputProps = {};
207
207
  if (validationStateKey) {
208
- Object.entries(inputProps).forEach(([propKey, propValue]) => {
208
+ Object.entries(inputProps || {}).forEach(([propKey, propValue]) => {
209
209
  // Convert the input property key to "snake_case" format.
210
210
  // e.g. "requiredBorderColor" -> "required_border_color".
211
211
  const propKeySnake = snakeCase__default.default(propKey);
@@ -1677,12 +1677,6 @@ const FormFieldPassword = /*#__PURE__*/React__default.default.memo(function Form
1677
1677
  isDisabled,
1678
1678
  classNameGroupItem,
1679
1679
  fieldProps,
1680
- iconFill,
1681
- iconFillHover,
1682
- iconRevealableHide,
1683
- iconRevealableShow,
1684
- iconShape,
1685
- iconSize,
1686
1680
  inputProps,
1687
1681
  parse,
1688
1682
  showMessage,
@@ -1719,10 +1713,10 @@ const FormFieldPassword = /*#__PURE__*/React__default.default.memo(function Form
1719
1713
  }
1720
1714
  }, [onChange, input.onChange]);
1721
1715
  const {
1722
- isErrorState,
1723
- isValidState,
1724
1716
  errorKey,
1725
- errorMessage
1717
+ errorMessage,
1718
+ isErrorState,
1719
+ isValidState
1726
1720
  } = useFieldValidationState({
1727
1721
  fieldProps: fieldProps,
1728
1722
  input: input,
@@ -1759,9 +1753,9 @@ const FormFieldPassword = /*#__PURE__*/React__default.default.memo(function Form
1759
1753
  onFocus: input.onFocus
1760
1754
  }, updatedInputProps)), /*#__PURE__*/React__default.default.createElement(Icon.Icon, {
1761
1755
  className: "form-field__icon",
1762
- size: inputProps.iconSize,
1763
- iconFill: inputProps.iconFill,
1764
- SvgImage: isRevealed ? inputProps.iconRevealableHide : inputProps.iconRevealableShow,
1756
+ size: inputProps?.iconSize,
1757
+ iconFill: inputProps?.iconFill,
1758
+ SvgImage: isRevealed ? inputProps?.iconRevealableHide : inputProps?.iconRevealableShow,
1765
1759
  onClick: onClickIconReveal
1766
1760
  }));
1767
1761
  });
@@ -2629,11 +2623,14 @@ const sendFormDataToServer = async (url, data) => {
2629
2623
 
2630
2624
  const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalForm(props, ref) {
2631
2625
  const {
2626
+ dataTestId,
2627
+ dataTour,
2632
2628
  className,
2633
2629
  type,
2634
2630
  initialValues,
2635
2631
  initialValuesEqual,
2636
2632
  config,
2633
+ validationSchema,
2637
2634
  title,
2638
2635
  titleFill,
2639
2636
  titleTextColor,
@@ -2643,6 +2640,7 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
2643
2640
  descSize,
2644
2641
  descTextColor,
2645
2642
  descTextWeight,
2643
+ buttonGap,
2646
2644
  dataTestIdPrimaryButton,
2647
2645
  dataTourPrimaryButton,
2648
2646
  primaryButton,
@@ -2684,13 +2682,10 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
2684
2682
  additionalProps = {},
2685
2683
  buttonDirection = 'vertical',
2686
2684
  buttonFill,
2687
- buttonGap,
2688
2685
  buttonJustifyContent,
2689
2686
  buttonPadding,
2690
2687
  buttonPosition,
2691
- dataTestId,
2692
2688
  dataTestIdButtons,
2693
- dataTour,
2694
2689
  dataTourButtons,
2695
2690
  disableFieldsAutoComplete = false,
2696
2691
  fieldsGap,
@@ -2709,7 +2704,6 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
2709
2704
  notificationCloseButton,
2710
2705
  notificationType,
2711
2706
  renderFieldsWrapper = wrapperChildren => wrapperChildren,
2712
- validationSchema,
2713
2707
  before,
2714
2708
  after,
2715
2709
  isLoading,
@@ -2744,15 +2738,15 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
2744
2738
  }) => {
2745
2739
  return /*#__PURE__*/React__default.default.createElement("form", {
2746
2740
  className: clsx__default.default(className, 'form', type && `form_type_${type}`, buttonPosition && `form_button-position_${buttonPosition}`, directionClass, fillClass, shapeClass, elevationClass),
2747
- name: formName,
2741
+ name: formName
2742
+ // We no need set reference to html element, we need reference to "final-form" instance
2743
+ ,
2744
+ ref: () => onRefFormInstance(form),
2748
2745
  autoCapitalize: disableFieldsAutoComplete ? 'off' : undefined,
2749
2746
  autoComplete: disableFieldsAutoComplete ? 'off' : undefined,
2750
2747
  autoCorrect: disableFieldsAutoComplete ? 'off' : undefined,
2751
2748
  "data-test-id": dataTestId,
2752
- "data-tour": dataTour
2753
- // We no need set reference to html element, we need reference to "final-form" instance
2754
- ,
2755
- ref: () => onRefFormInstance(form),
2749
+ "data-tour": dataTour,
2756
2750
  spellCheck: disableFieldsAutoComplete ? 'false' : undefined,
2757
2751
  style: formStyles,
2758
2752
  onSubmit: handleSubmit
@@ -2781,7 +2775,7 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
2781
2775
  values: true
2782
2776
  },
2783
2777
  onChange: onChangeFormValues
2784
- }), Boolean(Object.keys(config).length) && /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, renderFieldsWrapper(/*#__PURE__*/React__default.default.createElement(Group.Group, {
2778
+ }), Boolean(config && Object.keys(config).length) && /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, renderFieldsWrapper(/*#__PURE__*/React__default.default.createElement(Group.Group, {
2785
2779
  className: "form__wrapper",
2786
2780
  direction: "vertical",
2787
2781
  gap: fieldsGap || groupGap,
@@ -2798,15 +2792,17 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
2798
2792
  itemFill: loaderItemFill,
2799
2793
  shape: loaderShape
2800
2794
  }))))), (primaryButtonLabel || primaryButton || secondaryButtonLabel || secondaryButton || tertiaryButton || tertiaryButtonLabel) && /*#__PURE__*/React__default.default.createElement(Group.Group, {
2795
+ dataTestId: dataTestIdButtons,
2796
+ dataTour: dataTourButtons,
2801
2797
  className: "form__button",
2802
2798
  direction: buttonDirection,
2803
2799
  justifyContent: buttonJustifyContent,
2804
2800
  fill: buttonFill,
2805
2801
  padding: buttonPadding,
2806
- gap: buttonGap,
2807
- dataTestId: dataTestIdButtons,
2808
- dataTour: dataTourButtons
2802
+ gap: buttonGap
2809
2803
  }, primaryButtonLabel ? /*#__PURE__*/React__default.default.createElement(Button.Button, {
2804
+ dataTestId: dataTestIdPrimaryButton,
2805
+ dataTour: dataTourPrimaryButton,
2810
2806
  className: "form__button-item",
2811
2807
  appearance: primaryButtonAppearance,
2812
2808
  width: "fill",
@@ -2818,10 +2814,10 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
2818
2814
  labelTextSize: primaryButtonLabelSize,
2819
2815
  labelTextWeight: primaryButtonLabelTextWeight,
2820
2816
  isDisabled: primaryButtonIsDisabled,
2821
- dataTestId: dataTestIdPrimaryButton,
2822
- dataTour: dataTourPrimaryButton,
2823
2817
  loading: primaryButtonIsLoading
2824
2818
  }) : primaryButton, secondaryButtonLabel ? /*#__PURE__*/React__default.default.createElement(Button.Button, {
2819
+ dataTestId: dataTestIdSecondaryButton,
2820
+ dataTour: dataTourSecondaryButton,
2825
2821
  className: "form__button-item",
2826
2822
  appearance: secondaryButtonAppearance,
2827
2823
  width: "fill",
@@ -2833,11 +2829,11 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
2833
2829
  labelTextSize: secondaryButtonLabelSize,
2834
2830
  labelTextWeight: secondaryButtonLabelTextWeight,
2835
2831
  isDisabled: secondaryButtonIsDisabled,
2836
- dataTestId: dataTestIdSecondaryButton,
2837
- dataTour: dataTourSecondaryButton,
2838
2832
  loading: secondaryButtonIsLoading,
2839
2833
  onClick: onClickSecondaryButton
2840
2834
  }) : secondaryButton, tertiaryButtonLabel ? /*#__PURE__*/React__default.default.createElement(Button.Button, {
2835
+ dataTestId: dataTestIdTertiaryButton,
2836
+ dataTour: dataTourTertiaryButton,
2841
2837
  className: "form__button-item",
2842
2838
  width: "fill",
2843
2839
  size: tertiaryButtonSize,
@@ -2847,8 +2843,6 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
2847
2843
  labelTextColor: tertiaryButtonLabelTextColor,
2848
2844
  labelTextSize: tertiaryButtonLabelSize,
2849
2845
  labelTextWeight: tertiaryButtonLabelTextWeight,
2850
- dataTestId: dataTestIdTertiaryButton,
2851
- dataTour: dataTourTertiaryButton,
2852
2846
  onClick: onClickTertiaryButton
2853
2847
  }) : tertiaryButton), after);
2854
2848
  },
@@ -179,8 +179,8 @@ function useFieldValidationState(props) {
179
179
  // looks at what props were in initialProps, if they are there then changes
180
180
  function useValidationAppearanceInputProps(props) {
181
181
  const {
182
- validationStateKey,
183
- inputProps
182
+ inputProps,
183
+ validationStateKey
184
184
  } = props;
185
185
 
186
186
  // TODO: need to add props that can change during errors in this field
@@ -194,7 +194,7 @@ function useValidationAppearanceInputProps(props) {
194
194
  // }
195
195
  const updatedInputProps = {};
196
196
  if (validationStateKey) {
197
- Object.entries(inputProps).forEach(([propKey, propValue]) => {
197
+ Object.entries(inputProps || {}).forEach(([propKey, propValue]) => {
198
198
  // Convert the input property key to "snake_case" format.
199
199
  // e.g. "requiredBorderColor" -> "required_border_color".
200
200
  const propKeySnake = snakeCase(propKey);
@@ -1666,12 +1666,6 @@ const FormFieldPassword = /*#__PURE__*/React.memo(function FormFieldPassword(pro
1666
1666
  isDisabled,
1667
1667
  classNameGroupItem,
1668
1668
  fieldProps,
1669
- iconFill,
1670
- iconFillHover,
1671
- iconRevealableHide,
1672
- iconRevealableShow,
1673
- iconShape,
1674
- iconSize,
1675
1669
  inputProps,
1676
1670
  parse,
1677
1671
  showMessage,
@@ -1708,10 +1702,10 @@ const FormFieldPassword = /*#__PURE__*/React.memo(function FormFieldPassword(pro
1708
1702
  }
1709
1703
  }, [onChange, input.onChange]);
1710
1704
  const {
1711
- isErrorState,
1712
- isValidState,
1713
1705
  errorKey,
1714
- errorMessage
1706
+ errorMessage,
1707
+ isErrorState,
1708
+ isValidState
1715
1709
  } = useFieldValidationState({
1716
1710
  fieldProps: fieldProps,
1717
1711
  input: input,
@@ -1748,9 +1742,9 @@ const FormFieldPassword = /*#__PURE__*/React.memo(function FormFieldPassword(pro
1748
1742
  onFocus: input.onFocus
1749
1743
  }, updatedInputProps)), /*#__PURE__*/React.createElement(Icon, {
1750
1744
  className: "form-field__icon",
1751
- size: inputProps.iconSize,
1752
- iconFill: inputProps.iconFill,
1753
- SvgImage: isRevealed ? inputProps.iconRevealableHide : inputProps.iconRevealableShow,
1745
+ size: inputProps?.iconSize,
1746
+ iconFill: inputProps?.iconFill,
1747
+ SvgImage: isRevealed ? inputProps?.iconRevealableHide : inputProps?.iconRevealableShow,
1754
1748
  onClick: onClickIconReveal
1755
1749
  }));
1756
1750
  });
@@ -2618,11 +2612,14 @@ const sendFormDataToServer = async (url, data) => {
2618
2612
 
2619
2613
  const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2620
2614
  const {
2615
+ dataTestId,
2616
+ dataTour,
2621
2617
  className,
2622
2618
  type,
2623
2619
  initialValues,
2624
2620
  initialValuesEqual,
2625
2621
  config,
2622
+ validationSchema,
2626
2623
  title,
2627
2624
  titleFill,
2628
2625
  titleTextColor,
@@ -2632,6 +2629,7 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2632
2629
  descSize,
2633
2630
  descTextColor,
2634
2631
  descTextWeight,
2632
+ buttonGap,
2635
2633
  dataTestIdPrimaryButton,
2636
2634
  dataTourPrimaryButton,
2637
2635
  primaryButton,
@@ -2673,13 +2671,10 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2673
2671
  additionalProps = {},
2674
2672
  buttonDirection = 'vertical',
2675
2673
  buttonFill,
2676
- buttonGap,
2677
2674
  buttonJustifyContent,
2678
2675
  buttonPadding,
2679
2676
  buttonPosition,
2680
- dataTestId,
2681
2677
  dataTestIdButtons,
2682
- dataTour,
2683
2678
  dataTourButtons,
2684
2679
  disableFieldsAutoComplete = false,
2685
2680
  fieldsGap,
@@ -2698,7 +2693,6 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2698
2693
  notificationCloseButton,
2699
2694
  notificationType,
2700
2695
  renderFieldsWrapper = wrapperChildren => wrapperChildren,
2701
- validationSchema,
2702
2696
  before,
2703
2697
  after,
2704
2698
  isLoading,
@@ -2733,15 +2727,15 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2733
2727
  }) => {
2734
2728
  return /*#__PURE__*/React.createElement("form", {
2735
2729
  className: clsx(className, 'form', type && `form_type_${type}`, buttonPosition && `form_button-position_${buttonPosition}`, directionClass, fillClass, shapeClass, elevationClass),
2736
- name: formName,
2730
+ name: formName
2731
+ // We no need set reference to html element, we need reference to "final-form" instance
2732
+ ,
2733
+ ref: () => onRefFormInstance(form),
2737
2734
  autoCapitalize: disableFieldsAutoComplete ? 'off' : undefined,
2738
2735
  autoComplete: disableFieldsAutoComplete ? 'off' : undefined,
2739
2736
  autoCorrect: disableFieldsAutoComplete ? 'off' : undefined,
2740
2737
  "data-test-id": dataTestId,
2741
- "data-tour": dataTour
2742
- // We no need set reference to html element, we need reference to "final-form" instance
2743
- ,
2744
- ref: () => onRefFormInstance(form),
2738
+ "data-tour": dataTour,
2745
2739
  spellCheck: disableFieldsAutoComplete ? 'false' : undefined,
2746
2740
  style: formStyles,
2747
2741
  onSubmit: handleSubmit
@@ -2770,7 +2764,7 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2770
2764
  values: true
2771
2765
  },
2772
2766
  onChange: onChangeFormValues
2773
- }), Boolean(Object.keys(config).length) && /*#__PURE__*/React.createElement(React.Fragment, null, renderFieldsWrapper(/*#__PURE__*/React.createElement(Group, {
2767
+ }), Boolean(config && Object.keys(config).length) && /*#__PURE__*/React.createElement(React.Fragment, null, renderFieldsWrapper(/*#__PURE__*/React.createElement(Group, {
2774
2768
  className: "form__wrapper",
2775
2769
  direction: "vertical",
2776
2770
  gap: fieldsGap || groupGap,
@@ -2787,15 +2781,17 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2787
2781
  itemFill: loaderItemFill,
2788
2782
  shape: loaderShape
2789
2783
  }))))), (primaryButtonLabel || primaryButton || secondaryButtonLabel || secondaryButton || tertiaryButton || tertiaryButtonLabel) && /*#__PURE__*/React.createElement(Group, {
2784
+ dataTestId: dataTestIdButtons,
2785
+ dataTour: dataTourButtons,
2790
2786
  className: "form__button",
2791
2787
  direction: buttonDirection,
2792
2788
  justifyContent: buttonJustifyContent,
2793
2789
  fill: buttonFill,
2794
2790
  padding: buttonPadding,
2795
- gap: buttonGap,
2796
- dataTestId: dataTestIdButtons,
2797
- dataTour: dataTourButtons
2791
+ gap: buttonGap
2798
2792
  }, primaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
2793
+ dataTestId: dataTestIdPrimaryButton,
2794
+ dataTour: dataTourPrimaryButton,
2799
2795
  className: "form__button-item",
2800
2796
  appearance: primaryButtonAppearance,
2801
2797
  width: "fill",
@@ -2807,10 +2803,10 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2807
2803
  labelTextSize: primaryButtonLabelSize,
2808
2804
  labelTextWeight: primaryButtonLabelTextWeight,
2809
2805
  isDisabled: primaryButtonIsDisabled,
2810
- dataTestId: dataTestIdPrimaryButton,
2811
- dataTour: dataTourPrimaryButton,
2812
2806
  loading: primaryButtonIsLoading
2813
2807
  }) : primaryButton, secondaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
2808
+ dataTestId: dataTestIdSecondaryButton,
2809
+ dataTour: dataTourSecondaryButton,
2814
2810
  className: "form__button-item",
2815
2811
  appearance: secondaryButtonAppearance,
2816
2812
  width: "fill",
@@ -2822,11 +2818,11 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2822
2818
  labelTextSize: secondaryButtonLabelSize,
2823
2819
  labelTextWeight: secondaryButtonLabelTextWeight,
2824
2820
  isDisabled: secondaryButtonIsDisabled,
2825
- dataTestId: dataTestIdSecondaryButton,
2826
- dataTour: dataTourSecondaryButton,
2827
2821
  loading: secondaryButtonIsLoading,
2828
2822
  onClick: onClickSecondaryButton
2829
2823
  }) : secondaryButton, tertiaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
2824
+ dataTestId: dataTestIdTertiaryButton,
2825
+ dataTour: dataTourTertiaryButton,
2830
2826
  className: "form__button-item",
2831
2827
  width: "fill",
2832
2828
  size: tertiaryButtonSize,
@@ -2836,8 +2832,6 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
2836
2832
  labelTextColor: tertiaryButtonLabelTextColor,
2837
2833
  labelTextSize: tertiaryButtonLabelSize,
2838
2834
  labelTextWeight: tertiaryButtonLabelTextWeight,
2839
- dataTestId: dataTestIdTertiaryButton,
2840
- dataTour: dataTourTertiaryButton,
2841
2835
  onClick: onClickTertiaryButton
2842
2836
  }) : tertiaryButton), after);
2843
2837
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itcase/forms",
3
- "version": "1.1.28",
3
+ "version": "1.1.29",
4
4
  "description": "Forms fields, inputs, etc.",
5
5
  "keywords": [],
6
6
  "license": "MIT",