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.d.mts
CHANGED
|
@@ -219,13 +219,17 @@ interface Props$4<T extends Record<string, any>> {
|
|
|
219
219
|
withErrorsAlert?: boolean;
|
|
220
220
|
errorAlertPosition?: alertPositionType;
|
|
221
221
|
withCard?: boolean;
|
|
222
|
+
withFormWrapper?: boolean;
|
|
223
|
+
withSubmitBtn?: boolean;
|
|
222
224
|
submitBtnLabel?: string;
|
|
225
|
+
submitBtnLabelSubmiting?: string;
|
|
223
226
|
submitBtnClass?: string;
|
|
227
|
+
btnGroupDirection?: 'flex-start' | 'flex-end' | 'flex-center';
|
|
224
228
|
children?: ReactNode;
|
|
225
229
|
childrenHeader?: ReactNode;
|
|
226
230
|
listBtnConfig?: BtnConfig[];
|
|
227
231
|
}
|
|
228
|
-
declare const DynamicForm: <T extends Record<string, any>>({ formTitle, formSubTitle, fields, readOnly, record, onSubmit, onClick, extraValidations, children, childrenHeader, showIcon, showFormHeader, withErrorsAlert, errorAlertPosition, withCard, submitBtnClass, listBtnConfig, submitBtnLabel, }: Props$4<T>) => react_jsx_runtime.JSX.Element;
|
|
232
|
+
declare const DynamicForm: <T extends Record<string, any>>({ formTitle, formSubTitle, fields, readOnly, record, onSubmit, onClick, extraValidations, children, childrenHeader, showIcon, showFormHeader, withErrorsAlert, errorAlertPosition, withCard, submitBtnClass, listBtnConfig, submitBtnLabel, submitBtnLabelSubmiting, withFormWrapper, btnGroupDirection, withSubmitBtn }: Props$4<T>) => react_jsx_runtime.JSX.Element;
|
|
229
233
|
|
|
230
234
|
declare const DynamicFormExample: () => react_jsx_runtime.JSX.Element;
|
|
231
235
|
declare const mockFields: Array<FieldProps | FieldProps[]>;
|
package/dist/index.d.ts
CHANGED
|
@@ -219,13 +219,17 @@ interface Props$4<T extends Record<string, any>> {
|
|
|
219
219
|
withErrorsAlert?: boolean;
|
|
220
220
|
errorAlertPosition?: alertPositionType;
|
|
221
221
|
withCard?: boolean;
|
|
222
|
+
withFormWrapper?: boolean;
|
|
223
|
+
withSubmitBtn?: boolean;
|
|
222
224
|
submitBtnLabel?: string;
|
|
225
|
+
submitBtnLabelSubmiting?: string;
|
|
223
226
|
submitBtnClass?: string;
|
|
227
|
+
btnGroupDirection?: 'flex-start' | 'flex-end' | 'flex-center';
|
|
224
228
|
children?: ReactNode;
|
|
225
229
|
childrenHeader?: ReactNode;
|
|
226
230
|
listBtnConfig?: BtnConfig[];
|
|
227
231
|
}
|
|
228
|
-
declare const DynamicForm: <T extends Record<string, any>>({ formTitle, formSubTitle, fields, readOnly, record, onSubmit, onClick, extraValidations, children, childrenHeader, showIcon, showFormHeader, withErrorsAlert, errorAlertPosition, withCard, submitBtnClass, listBtnConfig, submitBtnLabel, }: Props$4<T>) => react_jsx_runtime.JSX.Element;
|
|
232
|
+
declare const DynamicForm: <T extends Record<string, any>>({ formTitle, formSubTitle, fields, readOnly, record, onSubmit, onClick, extraValidations, children, childrenHeader, showIcon, showFormHeader, withErrorsAlert, errorAlertPosition, withCard, submitBtnClass, listBtnConfig, submitBtnLabel, submitBtnLabelSubmiting, withFormWrapper, btnGroupDirection, withSubmitBtn }: Props$4<T>) => react_jsx_runtime.JSX.Element;
|
|
229
233
|
|
|
230
234
|
declare const DynamicFormExample: () => react_jsx_runtime.JSX.Element;
|
|
231
235
|
declare const mockFields: Array<FieldProps | FieldProps[]>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CheckIcon, XIcon, MinusIcon, GripVerticalIcon, ChevronUpIcon, CalendarIcon, EyeOff, Eye,
|
|
1
|
+
import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CheckIcon, XIcon, MinusIcon, GripVerticalIcon, ChevronUpIcon, CalendarIcon, EyeOff, Eye, Loader2, Save, Pencil, Plus, MessageCircleWarning, Info, CircleCheck, CircleX, Trash2, ChevronsUpDown, Check, Upload, GripVertical, SearchIcon, CircleIcon } from 'lucide-react';
|
|
2
2
|
import { InfoCircledIcon } from '@radix-ui/react-icons';
|
|
3
3
|
import { cva } from 'class-variance-authority';
|
|
4
4
|
import { twMerge } from 'tailwind-merge';
|
|
@@ -5617,9 +5617,13 @@ var DynamicForm = ({
|
|
|
5617
5617
|
withErrorsAlert = true,
|
|
5618
5618
|
errorAlertPosition = "up",
|
|
5619
5619
|
withCard = false,
|
|
5620
|
-
submitBtnClass = "",
|
|
5620
|
+
submitBtnClass = "text-lg w-1/4",
|
|
5621
5621
|
listBtnConfig = [],
|
|
5622
|
-
submitBtnLabel = "Guardar"
|
|
5622
|
+
submitBtnLabel = "Guardar",
|
|
5623
|
+
submitBtnLabelSubmiting = "Guardando...",
|
|
5624
|
+
withFormWrapper = true,
|
|
5625
|
+
btnGroupDirection = "flex-end",
|
|
5626
|
+
withSubmitBtn = true
|
|
5623
5627
|
}) => {
|
|
5624
5628
|
const [isPending, startTransition] = useTransition();
|
|
5625
5629
|
const schema = useMemo(() => {
|
|
@@ -5650,6 +5654,56 @@ var DynamicForm = ({
|
|
|
5650
5654
|
const resp = { data, form };
|
|
5651
5655
|
onClick(resp);
|
|
5652
5656
|
};
|
|
5657
|
+
const formBody = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5658
|
+
/* @__PURE__ */ jsxs("div", { className: "w-full grid grid-cols-1", children: [
|
|
5659
|
+
/* @__PURE__ */ jsx(
|
|
5660
|
+
FormFieldsGrid,
|
|
5661
|
+
{
|
|
5662
|
+
fields,
|
|
5663
|
+
form,
|
|
5664
|
+
readOnly
|
|
5665
|
+
}
|
|
5666
|
+
),
|
|
5667
|
+
children && /* @__PURE__ */ jsx("div", { className: "flex flex-row items-center gap-2 w-full h-full", children })
|
|
5668
|
+
] }),
|
|
5669
|
+
/* @__PURE__ */ jsxs(ButtonGroup, { className: "flex flex-row w-full h-full", style: {
|
|
5670
|
+
justifyContent: btnGroupDirection,
|
|
5671
|
+
// Alinea horizontalmente a la derecha
|
|
5672
|
+
alignItems: "center"
|
|
5673
|
+
// Centra verticalmente (opcional)
|
|
5674
|
+
}, children: [
|
|
5675
|
+
listBtnConfig.map((btn, key) => /* @__PURE__ */ jsx(
|
|
5676
|
+
Button,
|
|
5677
|
+
{
|
|
5678
|
+
type: btn.btnType,
|
|
5679
|
+
size: "icon-lg",
|
|
5680
|
+
className: submitBtnClass,
|
|
5681
|
+
variant: btn.variant,
|
|
5682
|
+
onClick: btn.onClick,
|
|
5683
|
+
disabled: btn.disabled,
|
|
5684
|
+
children: btn.label
|
|
5685
|
+
},
|
|
5686
|
+
key
|
|
5687
|
+
)),
|
|
5688
|
+
!readOnly && withSubmitBtn && /* @__PURE__ */ jsx(
|
|
5689
|
+
Button,
|
|
5690
|
+
{
|
|
5691
|
+
type: onClick ? "button" : "submit",
|
|
5692
|
+
size: "icon-lg",
|
|
5693
|
+
className: cn(submitBtnClass),
|
|
5694
|
+
disabled: isPending,
|
|
5695
|
+
onClick: onClick ? handleClick : void 0,
|
|
5696
|
+
children: isPending ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5697
|
+
/* @__PURE__ */ jsx(Loader2, { className: "h-5 w-5 mr-2 animate-spin" }),
|
|
5698
|
+
submitBtnLabelSubmiting
|
|
5699
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5700
|
+
/* @__PURE__ */ jsx(Save, { className: "h-5 w-5 mr-2" }),
|
|
5701
|
+
submitBtnLabel
|
|
5702
|
+
] })
|
|
5703
|
+
}
|
|
5704
|
+
)
|
|
5705
|
+
] })
|
|
5706
|
+
] });
|
|
5653
5707
|
const formContent = /* @__PURE__ */ jsxs("div", { children: [
|
|
5654
5708
|
showFormHeader && /* @__PURE__ */ jsxs(CardTitle, { className: "flex flex-row items-center gap-2 p-2 border-b", children: [
|
|
5655
5709
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center gap-2 w-full", children: [
|
|
@@ -5668,58 +5722,8 @@ var DynamicForm = ({
|
|
|
5668
5722
|
fields
|
|
5669
5723
|
}
|
|
5670
5724
|
),
|
|
5671
|
-
/* @__PURE__ */ jsx(
|
|
5672
|
-
|
|
5673
|
-
{
|
|
5674
|
-
onSubmit: form.handleSubmit(handleSubmit),
|
|
5675
|
-
className: `flex flex-col gap-2 ${readOnly ? "opacity-70 pointer-events-none select-none" : ""}`,
|
|
5676
|
-
children: [
|
|
5677
|
-
/* @__PURE__ */ jsxs("div", { className: "w-full grid grid-cols-1", children: [
|
|
5678
|
-
/* @__PURE__ */ jsx(
|
|
5679
|
-
FormFieldsGrid,
|
|
5680
|
-
{
|
|
5681
|
-
fields,
|
|
5682
|
-
form,
|
|
5683
|
-
readOnly
|
|
5684
|
-
}
|
|
5685
|
-
),
|
|
5686
|
-
children && /* @__PURE__ */ jsx("div", { className: "flex flex-row items-center gap-2 w-full h-full", children })
|
|
5687
|
-
] }),
|
|
5688
|
-
/* @__PURE__ */ jsxs(ButtonGroup, { className: "flex flex-row w-full", children: [
|
|
5689
|
-
listBtnConfig.map((btn, key) => /* @__PURE__ */ jsx(
|
|
5690
|
-
Button,
|
|
5691
|
-
{
|
|
5692
|
-
type: btn.btnType,
|
|
5693
|
-
size: "lg",
|
|
5694
|
-
className: submitBtnClass,
|
|
5695
|
-
variant: btn.variant,
|
|
5696
|
-
onClick: btn.onClick,
|
|
5697
|
-
disabled: btn.disabled,
|
|
5698
|
-
children: btn.label
|
|
5699
|
-
},
|
|
5700
|
-
key
|
|
5701
|
-
)),
|
|
5702
|
-
!readOnly && /* @__PURE__ */ jsx(
|
|
5703
|
-
Button,
|
|
5704
|
-
{
|
|
5705
|
-
type: onClick ? "button" : "submit",
|
|
5706
|
-
size: "lg",
|
|
5707
|
-
className: submitBtnClass,
|
|
5708
|
-
disabled: isPending,
|
|
5709
|
-
onClick: onClick ? handleClick : void 0,
|
|
5710
|
-
children: isPending ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5711
|
-
/* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 mr-2 animate-spin" }),
|
|
5712
|
-
"Guardando..."
|
|
5713
|
-
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5714
|
-
/* @__PURE__ */ jsx(Save, { className: "h-4 w-4 mr-2" }),
|
|
5715
|
-
submitBtnLabel
|
|
5716
|
-
] })
|
|
5717
|
-
}
|
|
5718
|
-
)
|
|
5719
|
-
] })
|
|
5720
|
-
]
|
|
5721
|
-
}
|
|
5722
|
-
) }),
|
|
5725
|
+
withFormWrapper && /* @__PURE__ */ jsx(FormWrapper, { form, handleSubmit, children: formBody }),
|
|
5726
|
+
!withFormWrapper && formBody,
|
|
5723
5727
|
withErrorsAlert && errorAlertPosition === "down" && /* @__PURE__ */ jsx(
|
|
5724
5728
|
FormErrorsAlert,
|
|
5725
5729
|
{
|
|
@@ -5731,6 +5735,16 @@ var DynamicForm = ({
|
|
|
5731
5735
|
if (!withCard) return formContent;
|
|
5732
5736
|
return /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(CardContent, { children: formContent }) });
|
|
5733
5737
|
};
|
|
5738
|
+
var FormWrapper = ({ form, handleSubmit, children, readOnly }) => {
|
|
5739
|
+
return /* @__PURE__ */ jsx(Form, { ...form, children: /* @__PURE__ */ jsx(
|
|
5740
|
+
"form",
|
|
5741
|
+
{
|
|
5742
|
+
onSubmit: form.handleSubmit(handleSubmit),
|
|
5743
|
+
className: `flex flex-col gap-2 ${readOnly ? "opacity-70 pointer-events-none select-none" : ""}`,
|
|
5744
|
+
children
|
|
5745
|
+
}
|
|
5746
|
+
) });
|
|
5747
|
+
};
|
|
5734
5748
|
var DynamicFormExample = () => {
|
|
5735
5749
|
const record = {
|
|
5736
5750
|
username: "John Doe ",
|