shadcn-zod-formkit 1.22.4 → 1.23.1
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 +68 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +69 -55
- package/dist/index.mjs.map +1 -1
- package/dist/shadcn-zod-formkit-1.23.1.tgz +0 -0
- package/package.json +1 -1
- package/dist/shadcn-zod-formkit-1.22.4.tgz +0 -0
package/dist/index.cjs
CHANGED
|
@@ -5655,9 +5655,13 @@ var DynamicForm = ({
|
|
|
5655
5655
|
withErrorsAlert = true,
|
|
5656
5656
|
errorAlertPosition = "up",
|
|
5657
5657
|
withCard = false,
|
|
5658
|
-
submitBtnClass = "",
|
|
5658
|
+
submitBtnClass = "text-lg w-1/4",
|
|
5659
5659
|
listBtnConfig = [],
|
|
5660
|
-
submitBtnLabel = "Guardar"
|
|
5660
|
+
submitBtnLabel = "Guardar",
|
|
5661
|
+
submitBtnLabelSubmiting = "Guardando...",
|
|
5662
|
+
withFormWrapper = true,
|
|
5663
|
+
btnGroupDirection = "flex-end",
|
|
5664
|
+
withSubmitBtn = true
|
|
5661
5665
|
}) => {
|
|
5662
5666
|
const [isPending, startTransition] = React3.useTransition();
|
|
5663
5667
|
const schema = React3.useMemo(() => {
|
|
@@ -5688,6 +5692,56 @@ var DynamicForm = ({
|
|
|
5688
5692
|
const resp = { data, form };
|
|
5689
5693
|
onClick(resp);
|
|
5690
5694
|
};
|
|
5695
|
+
const formBody = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5696
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full grid grid-cols-1", children: [
|
|
5697
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5698
|
+
FormFieldsGrid,
|
|
5699
|
+
{
|
|
5700
|
+
fields,
|
|
5701
|
+
form,
|
|
5702
|
+
readOnly
|
|
5703
|
+
}
|
|
5704
|
+
),
|
|
5705
|
+
children && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-row items-center gap-2 w-full h-full", children })
|
|
5706
|
+
] }),
|
|
5707
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ButtonGroup, { className: "flex flex-row w-full h-full", style: {
|
|
5708
|
+
justifyContent: btnGroupDirection,
|
|
5709
|
+
// Alinea horizontalmente a la derecha
|
|
5710
|
+
alignItems: "center"
|
|
5711
|
+
// Centra verticalmente (opcional)
|
|
5712
|
+
}, children: [
|
|
5713
|
+
listBtnConfig.map((btn, key) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5714
|
+
Button,
|
|
5715
|
+
{
|
|
5716
|
+
type: btn.btnType,
|
|
5717
|
+
size: "icon-lg",
|
|
5718
|
+
className: submitBtnClass,
|
|
5719
|
+
variant: btn.variant,
|
|
5720
|
+
onClick: btn.onClick,
|
|
5721
|
+
disabled: btn.disabled,
|
|
5722
|
+
children: btn.label
|
|
5723
|
+
},
|
|
5724
|
+
key
|
|
5725
|
+
)),
|
|
5726
|
+
!readOnly && withSubmitBtn && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5727
|
+
Button,
|
|
5728
|
+
{
|
|
5729
|
+
type: onClick ? "button" : "submit",
|
|
5730
|
+
size: "icon-lg",
|
|
5731
|
+
className: cn(submitBtnClass),
|
|
5732
|
+
disabled: isPending,
|
|
5733
|
+
onClick: onClick ? handleClick : void 0,
|
|
5734
|
+
children: isPending ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5735
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "h-5 w-5 mr-2 animate-spin" }),
|
|
5736
|
+
submitBtnLabelSubmiting
|
|
5737
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5738
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Save, { className: "h-5 w-5 mr-2" }),
|
|
5739
|
+
submitBtnLabel
|
|
5740
|
+
] })
|
|
5741
|
+
}
|
|
5742
|
+
)
|
|
5743
|
+
] })
|
|
5744
|
+
] });
|
|
5691
5745
|
const formContent = /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
5692
5746
|
showFormHeader && /* @__PURE__ */ jsxRuntime.jsxs(CardTitle, { className: "flex flex-row items-center gap-2 p-2 border-b", children: [
|
|
5693
5747
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row items-center gap-2 w-full", children: [
|
|
@@ -5706,58 +5760,8 @@ var DynamicForm = ({
|
|
|
5706
5760
|
fields
|
|
5707
5761
|
}
|
|
5708
5762
|
),
|
|
5709
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5710
|
-
|
|
5711
|
-
{
|
|
5712
|
-
onSubmit: form.handleSubmit(handleSubmit),
|
|
5713
|
-
className: `flex flex-col gap-2 ${readOnly ? "opacity-70 pointer-events-none select-none" : ""}`,
|
|
5714
|
-
children: [
|
|
5715
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full grid grid-cols-1", children: [
|
|
5716
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5717
|
-
FormFieldsGrid,
|
|
5718
|
-
{
|
|
5719
|
-
fields,
|
|
5720
|
-
form,
|
|
5721
|
-
readOnly
|
|
5722
|
-
}
|
|
5723
|
-
),
|
|
5724
|
-
children && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-row items-center gap-2 w-full h-full", children })
|
|
5725
|
-
] }),
|
|
5726
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ButtonGroup, { className: "flex flex-row w-full", children: [
|
|
5727
|
-
listBtnConfig.map((btn, key) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5728
|
-
Button,
|
|
5729
|
-
{
|
|
5730
|
-
type: btn.btnType,
|
|
5731
|
-
size: "lg",
|
|
5732
|
-
className: submitBtnClass,
|
|
5733
|
-
variant: btn.variant,
|
|
5734
|
-
onClick: btn.onClick,
|
|
5735
|
-
disabled: btn.disabled,
|
|
5736
|
-
children: btn.label
|
|
5737
|
-
},
|
|
5738
|
-
key
|
|
5739
|
-
)),
|
|
5740
|
-
!readOnly && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5741
|
-
Button,
|
|
5742
|
-
{
|
|
5743
|
-
type: onClick ? "button" : "submit",
|
|
5744
|
-
size: "lg",
|
|
5745
|
-
className: submitBtnClass,
|
|
5746
|
-
disabled: isPending,
|
|
5747
|
-
onClick: onClick ? handleClick : void 0,
|
|
5748
|
-
children: isPending ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5749
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "h-4 w-4 mr-2 animate-spin" }),
|
|
5750
|
-
"Guardando..."
|
|
5751
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5752
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Save, { className: "h-4 w-4 mr-2" }),
|
|
5753
|
-
submitBtnLabel
|
|
5754
|
-
] })
|
|
5755
|
-
}
|
|
5756
|
-
)
|
|
5757
|
-
] })
|
|
5758
|
-
]
|
|
5759
|
-
}
|
|
5760
|
-
) }),
|
|
5763
|
+
withFormWrapper && /* @__PURE__ */ jsxRuntime.jsx(FormWrapper, { form, handleSubmit, children: formBody }),
|
|
5764
|
+
!withFormWrapper && formBody,
|
|
5761
5765
|
withErrorsAlert && errorAlertPosition === "down" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5762
5766
|
FormErrorsAlert,
|
|
5763
5767
|
{
|
|
@@ -5769,6 +5773,16 @@ var DynamicForm = ({
|
|
|
5769
5773
|
if (!withCard) return formContent;
|
|
5770
5774
|
return /* @__PURE__ */ jsxRuntime.jsx(Card, { children: /* @__PURE__ */ jsxRuntime.jsx(CardContent, { children: formContent }) });
|
|
5771
5775
|
};
|
|
5776
|
+
var FormWrapper = ({ form, handleSubmit, children, readOnly }) => {
|
|
5777
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form, { ...form, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5778
|
+
"form",
|
|
5779
|
+
{
|
|
5780
|
+
onSubmit: form.handleSubmit(handleSubmit),
|
|
5781
|
+
className: `flex flex-col gap-2 ${readOnly ? "opacity-70 pointer-events-none select-none" : ""}`,
|
|
5782
|
+
children
|
|
5783
|
+
}
|
|
5784
|
+
) });
|
|
5785
|
+
};
|
|
5772
5786
|
var DynamicFormExample = () => {
|
|
5773
5787
|
const record = {
|
|
5774
5788
|
username: "John Doe ",
|