@saas-ui/forms 2.3.10 → 2.3.12

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @saas-ui/forms
2
2
 
3
+ ## 2.3.12
4
+
5
+ ### Patch Changes
6
+
7
+ - 2e7da38: Updated dependencies
8
+ - da5167a: Fixed issue where submit field props were not passed down correctly
9
+ - Updated dependencies [2e7da38]
10
+ - @saas-ui/core@2.3.6
11
+
12
+ ## 2.3.11
13
+
14
+ ### Patch Changes
15
+
16
+ - 29e5c317: Fixed issue where submit label could not be overwritten using the fields prop
17
+
3
18
  ## 2.3.10
4
19
 
5
20
  ### Patch Changes
@@ -1090,12 +1105,12 @@
1090
1105
  Add this somewhere in the root of your project.
1091
1106
 
1092
1107
  ```ts
1093
- import { Form } from "@saas-ui/react";
1094
- import { yupResolver, yupFieldResolver } from "@saas-ui/forms/yup"; // yupResolver is exported from here as well for convenience.
1095
- import { AnyObjectSchema } from "yup";
1108
+ import { Form } from '@saas-ui/react'
1109
+ import { yupResolver, yupFieldResolver } from '@saas-ui/forms/yup' // yupResolver is exported from here as well for convenience.
1110
+ import { AnyObjectSchema } from 'yup'
1096
1111
 
1097
- Form.getResolver = (schema: AnyObjectSchema) => yupResolver(schema); // @hookform/resolvers
1098
- Form.getFieldResolver = (schema: AnyObjectSchema) => yupFieldResolver(schema); // AutoForm field resolver
1112
+ Form.getResolver = (schema: AnyObjectSchema) => yupResolver(schema) // @hookform/resolvers
1113
+ Form.getFieldResolver = (schema: AnyObjectSchema) => yupFieldResolver(schema) // AutoForm field resolver
1099
1114
  ```
1100
1115
 
1101
1116
  - 9391c44: Fixed peer dependency issues.
package/dist/index.d.ts CHANGED
@@ -197,16 +197,10 @@ type DefaultFields = typeof defaultFieldTypes;
197
197
  interface SubmitButtonProps extends ButtonProps {
198
198
  /**
199
199
  * Disable the submit button if the form is untouched.
200
- *
201
- * Change the default behavior by updating
202
- * `SubmitButton.defaultProps.disableIfUntouched`
203
200
  */
204
201
  disableIfUntouched?: boolean;
205
202
  /**
206
203
  * Disable the submit button if the form is invalid.
207
- *
208
- * Change the default behavior by updating
209
- * `SubmitButton.defaultProps.disableIfInvalid`
210
204
  */
211
205
  disableIfInvalid?: boolean;
212
206
  }
@@ -818,9 +812,9 @@ declare const useFormContext: <TFieldValues extends FieldValues = FieldValues, T
818
812
  formState: react_hook_form.FormState<FieldValues>;
819
813
  resetField: react_hook_form.UseFormResetField<FieldValues>;
820
814
  reset: react_hook_form.UseFormReset<FieldValues>;
821
- handleSubmit: react_hook_form.UseFormHandleSubmit<FieldValues, undefined>;
815
+ handleSubmit: react_hook_form.UseFormHandleSubmit<FieldValues, FieldValues>;
822
816
  unregister: react_hook_form.UseFormUnregister<FieldValues>;
823
- control: react_hook_form.Control<FieldValues, any>;
817
+ control: react_hook_form.Control<FieldValues, any, FieldValues>;
824
818
  register: react_hook_form.UseFormRegister<FieldValues>;
825
819
  setFocus: react_hook_form.UseFormSetFocus<FieldValues>;
826
820
  };
package/dist/index.js CHANGED
@@ -1080,15 +1080,22 @@ var SubmitButton = (0, import_react18.forwardRef)(
1080
1080
  const {
1081
1081
  variant = "primary",
1082
1082
  children = "Submit",
1083
- disableIfUntouched = false,
1084
- disableIfInvalid = false,
1083
+ disableIfUntouched: disableIfUntouchedProp = false,
1084
+ disableIfInvalid: disableIfInvalidProp = false,
1085
1085
  isDisabled: isDisabledProp,
1086
1086
  isLoading,
1087
1087
  ...rest
1088
1088
  } = props;
1089
1089
  const { formState } = (0, import_react_hook_form5.useFormContext)();
1090
- const isDisabled = disableIfUntouched && !formState.isDirty || disableIfInvalid && !formState.isValid || isDisabledProp;
1091
1090
  const field = useFieldProps("submit");
1091
+ const {
1092
+ disableIfUntouched: disableIfUntouchedOverride,
1093
+ disableIfInvalid: disableIfInvalidOverride,
1094
+ ...fieldProps
1095
+ } = field;
1096
+ const disableIfUntouched = disableIfUntouchedOverride != null ? disableIfUntouchedOverride : disableIfUntouchedProp;
1097
+ const disableIfInvalid = disableIfInvalidOverride != null ? disableIfInvalidOverride : disableIfInvalidProp;
1098
+ const isDisabled = disableIfUntouched && !formState.isDirty || disableIfInvalid && !formState.isValid || isDisabledProp;
1092
1099
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1093
1100
  import_react18.Button,
1094
1101
  {
@@ -1097,9 +1104,9 @@ var SubmitButton = (0, import_react18.forwardRef)(
1097
1104
  type: "submit",
1098
1105
  isLoading: formState.isSubmitting || isLoading,
1099
1106
  isDisabled,
1107
+ children,
1100
1108
  ...rest,
1101
- ...field,
1102
- children
1109
+ ...fieldProps
1103
1110
  }
1104
1111
  );
1105
1112
  }