shadcn-zod-formkit 1.5.0 → 1.6.0

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/index.cjs CHANGED
@@ -4944,9 +4944,9 @@ var DynamicForm = ({
4944
4944
  record = {},
4945
4945
  onSubmit,
4946
4946
  extraValidations,
4947
- withCard = false,
4948
4947
  withErrorsAlert = true,
4949
4948
  errorAlertPosition = "up",
4949
+ withCard = false,
4950
4950
  submitBtnClass = "",
4951
4951
  submitBtnLabel = "Submit"
4952
4952
  }) => {
@@ -4958,14 +4958,12 @@ var DynamicForm = ({
4958
4958
  defaultValues
4959
4959
  });
4960
4960
  React3.useEffect(() => {
4961
- console.log("\u{1F501} Redibuja cuando cambian los fields o los valores por defecto");
4962
4961
  form.reset(defaultValues);
4963
- }, []);
4962
+ }, [defaultValues, form]);
4964
4963
  const handleSubmit = (data) => {
4965
4964
  try {
4966
4965
  startTransition(async () => {
4967
4966
  const resp = { data, form };
4968
- await new Promise((resolve) => setTimeout(resolve, 3e3));
4969
4967
  onSubmit?.(resp);
4970
4968
  });
4971
4969
  } catch (error) {
@@ -4973,14 +4971,14 @@ var DynamicForm = ({
4973
4971
  }
4974
4972
  };
4975
4973
  const formContent = /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4976
- /* @__PURE__ */ jsxRuntime.jsxs(CardTitle, { className: "flex items-center gap-2 p-2 border-b", children: [
4974
+ /* @__PURE__ */ jsxRuntime.jsxs(CardTitle, { className: "flex items-center gap-2 p-2 border-b", children: [
4977
4975
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, { className: "h-5 w-5" }),
4978
4976
  formTitle
4979
4977
  ] }),
4980
- withErrorsAlert && errorAlertPosition == "up" && /* @__PURE__ */ jsxRuntime.jsx(FormErrorsAlert, { formState: form.formState, fields }),
4978
+ withErrorsAlert && errorAlertPosition === "up" && /* @__PURE__ */ jsxRuntime.jsx(FormErrorsAlert, { formState: form.formState, fields }),
4981
4979
  /* @__PURE__ */ jsxRuntime.jsx(Form, { ...form, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: form.handleSubmit(handleSubmit), className: "flex flex-col gap-2", children: [
4982
4980
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full grid grid-cols-1", children: /* @__PURE__ */ jsxRuntime.jsx(FormFieldsGrid, { fields, form }) }),
4983
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-row gap-2 justify-end items-end justify-items-end", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "submit", size: "lg", className: submitBtnClass, disabled: isPending, children: isPending ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4981
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-row gap-2 justify-end items-end", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "submit", size: "lg", className: submitBtnClass, disabled: isPending, children: isPending ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4984
4982
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "h-4 w-4 mr-2 animate-spin" }),
4985
4983
  submitBtnLabel ?? "Saving..."
4986
4984
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -4988,7 +4986,7 @@ var DynamicForm = ({
4988
4986
  submitBtnLabel ?? "Save"
4989
4987
  ] }) }) })
4990
4988
  ] }) }),
4991
- withErrorsAlert && errorAlertPosition == "down" && /* @__PURE__ */ jsxRuntime.jsx(FormErrorsAlert, { formState: form.formState, fields })
4989
+ withErrorsAlert && errorAlertPosition === "down" && /* @__PURE__ */ jsxRuntime.jsx(FormErrorsAlert, { formState: form.formState, fields })
4992
4990
  ] });
4993
4991
  if (!withCard) return formContent;
4994
4992
  return /* @__PURE__ */ jsxRuntime.jsx(Card, { children: /* @__PURE__ */ jsxRuntime.jsx(CardContent, { children: formContent }) });