shadcn-zod-formkit 1.18.1 → 1.19.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 +58 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.mjs +58 -36
- package/dist/index.mjs.map +1 -1
- package/dist/shadcn-zod-formkit-1.19.0.tgz +0 -0
- package/package.json +1 -1
- package/dist/shadcn-zod-formkit-1.18.1.tgz +0 -0
package/dist/index.d.mts
CHANGED
|
@@ -137,6 +137,13 @@ interface ListConfig {
|
|
|
137
137
|
selectedList?: InputOption[];
|
|
138
138
|
sortable?: boolean;
|
|
139
139
|
}
|
|
140
|
+
interface BtnConfig {
|
|
141
|
+
label: string;
|
|
142
|
+
btnType: 'submit' | 'button';
|
|
143
|
+
onClick: () => void;
|
|
144
|
+
variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
145
|
+
disabled?: boolean;
|
|
146
|
+
}
|
|
140
147
|
interface InputOption {
|
|
141
148
|
id: number | string;
|
|
142
149
|
name: string;
|
|
@@ -212,8 +219,9 @@ interface Props$4<T extends Record<string, any>> {
|
|
|
212
219
|
submitBtnClass?: string;
|
|
213
220
|
children?: ReactNode;
|
|
214
221
|
childrenHeader?: ReactNode;
|
|
222
|
+
listBtnConfig?: BtnConfig[];
|
|
215
223
|
}
|
|
216
|
-
declare const DynamicForm: <T extends Record<string, any>>({ formTitle, formSubTitle, fields, readOnly, record, onSubmit, onClick, extraValidations, children, childrenHeader, showIcon, showFormHeader, withErrorsAlert, errorAlertPosition, withCard, submitBtnClass, submitBtnLabel, }: Props$4<T>) => react_jsx_runtime.JSX.Element;
|
|
224
|
+
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;
|
|
217
225
|
|
|
218
226
|
declare const DynamicFormExample: () => react_jsx_runtime.JSX.Element;
|
|
219
227
|
declare const mockFields: Array<FieldProps | FieldProps[]>;
|
|
@@ -311,14 +319,14 @@ declare function AlertTitle({ className, ...props }: React$1.ComponentProps<"div
|
|
|
311
319
|
declare function AlertDescription({ className, ...props }: React$1.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
|
|
312
320
|
|
|
313
321
|
declare const badgeVariants: (props?: ({
|
|
314
|
-
variant?: "default" | "destructive" | "
|
|
322
|
+
variant?: "default" | "destructive" | "outline" | "secondary" | null | undefined;
|
|
315
323
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
316
324
|
declare function Badge({ className, variant, asChild, ...props }: React$1.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & {
|
|
317
325
|
asChild?: boolean;
|
|
318
326
|
}): react_jsx_runtime.JSX.Element;
|
|
319
327
|
|
|
320
328
|
declare const buttonVariants: (props?: ({
|
|
321
|
-
variant?: "default" | "destructive" | "link" | "
|
|
329
|
+
variant?: "default" | "destructive" | "link" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
322
330
|
size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg" | null | undefined;
|
|
323
331
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
324
332
|
declare function Button({ className, variant, size, asChild, ...props }: React$1.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
|
|
@@ -438,4 +446,4 @@ declare function TooltipContent({ className, sideOffset, children, ...props }: R
|
|
|
438
446
|
|
|
439
447
|
declare function cn(...inputs: ClassValue[]): string;
|
|
440
448
|
|
|
441
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Badge, BaseInput, Button, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CheckListInput, Checkbox, ColorCnInput, type ColorCompProps, ColorInput, CustomAlert, DateInput, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DynamicForm, DynamicFormExample, type FieldProps, FileInput, Form, FormControl, FormDescription, FormErrorsAlert, FormField, FormItem, FormLabel, FormMessage, type FormResp, type GroupedOption, GroupedSwitchInput, GroupedSwitches, Input, InputFactory, InputList, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, type InputOption, type InputSetup, InputTypes, Label, NumberInput, OTPInput, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, type Props, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectInput, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Switch, SwitchInput, TextAreaInput, TextInput, TextInputType, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cn, entitiesToGroupedOption, entitiesToInputOption, entityToGroupedOption, entityToInputOption, getDefaultValues, getDynamicSchema, getFieldLabel, inputFieldComp, mockFields, useFormField, validationMessages };
|
|
449
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Badge, BaseInput, type BtnConfig, Button, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CheckListInput, Checkbox, ColorCnInput, type ColorCompProps, ColorInput, CustomAlert, DateInput, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DynamicForm, DynamicFormExample, type FieldProps, FileInput, Form, FormControl, FormDescription, FormErrorsAlert, FormField, FormItem, FormLabel, FormMessage, type FormResp, type GroupedOption, GroupedSwitchInput, GroupedSwitches, Input, InputFactory, InputList, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, type InputOption, type InputSetup, InputTypes, Label, NumberInput, OTPInput, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, type Props, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectInput, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Switch, SwitchInput, TextAreaInput, TextInput, TextInputType, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cn, entitiesToGroupedOption, entitiesToInputOption, entityToGroupedOption, entityToInputOption, getDefaultValues, getDynamicSchema, getFieldLabel, inputFieldComp, mockFields, useFormField, validationMessages };
|
package/dist/index.d.ts
CHANGED
|
@@ -137,6 +137,13 @@ interface ListConfig {
|
|
|
137
137
|
selectedList?: InputOption[];
|
|
138
138
|
sortable?: boolean;
|
|
139
139
|
}
|
|
140
|
+
interface BtnConfig {
|
|
141
|
+
label: string;
|
|
142
|
+
btnType: 'submit' | 'button';
|
|
143
|
+
onClick: () => void;
|
|
144
|
+
variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
145
|
+
disabled?: boolean;
|
|
146
|
+
}
|
|
140
147
|
interface InputOption {
|
|
141
148
|
id: number | string;
|
|
142
149
|
name: string;
|
|
@@ -212,8 +219,9 @@ interface Props$4<T extends Record<string, any>> {
|
|
|
212
219
|
submitBtnClass?: string;
|
|
213
220
|
children?: ReactNode;
|
|
214
221
|
childrenHeader?: ReactNode;
|
|
222
|
+
listBtnConfig?: BtnConfig[];
|
|
215
223
|
}
|
|
216
|
-
declare const DynamicForm: <T extends Record<string, any>>({ formTitle, formSubTitle, fields, readOnly, record, onSubmit, onClick, extraValidations, children, childrenHeader, showIcon, showFormHeader, withErrorsAlert, errorAlertPosition, withCard, submitBtnClass, submitBtnLabel, }: Props$4<T>) => react_jsx_runtime.JSX.Element;
|
|
224
|
+
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;
|
|
217
225
|
|
|
218
226
|
declare const DynamicFormExample: () => react_jsx_runtime.JSX.Element;
|
|
219
227
|
declare const mockFields: Array<FieldProps | FieldProps[]>;
|
|
@@ -311,14 +319,14 @@ declare function AlertTitle({ className, ...props }: React$1.ComponentProps<"div
|
|
|
311
319
|
declare function AlertDescription({ className, ...props }: React$1.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
|
|
312
320
|
|
|
313
321
|
declare const badgeVariants: (props?: ({
|
|
314
|
-
variant?: "default" | "destructive" | "
|
|
322
|
+
variant?: "default" | "destructive" | "outline" | "secondary" | null | undefined;
|
|
315
323
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
316
324
|
declare function Badge({ className, variant, asChild, ...props }: React$1.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & {
|
|
317
325
|
asChild?: boolean;
|
|
318
326
|
}): react_jsx_runtime.JSX.Element;
|
|
319
327
|
|
|
320
328
|
declare const buttonVariants: (props?: ({
|
|
321
|
-
variant?: "default" | "destructive" | "link" | "
|
|
329
|
+
variant?: "default" | "destructive" | "link" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
322
330
|
size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg" | null | undefined;
|
|
323
331
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
324
332
|
declare function Button({ className, variant, size, asChild, ...props }: React$1.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
|
|
@@ -438,4 +446,4 @@ declare function TooltipContent({ className, sideOffset, children, ...props }: R
|
|
|
438
446
|
|
|
439
447
|
declare function cn(...inputs: ClassValue[]): string;
|
|
440
448
|
|
|
441
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Badge, BaseInput, Button, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CheckListInput, Checkbox, ColorCnInput, type ColorCompProps, ColorInput, CustomAlert, DateInput, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DynamicForm, DynamicFormExample, type FieldProps, FileInput, Form, FormControl, FormDescription, FormErrorsAlert, FormField, FormItem, FormLabel, FormMessage, type FormResp, type GroupedOption, GroupedSwitchInput, GroupedSwitches, Input, InputFactory, InputList, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, type InputOption, type InputSetup, InputTypes, Label, NumberInput, OTPInput, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, type Props, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectInput, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Switch, SwitchInput, TextAreaInput, TextInput, TextInputType, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cn, entitiesToGroupedOption, entitiesToInputOption, entityToGroupedOption, entityToInputOption, getDefaultValues, getDynamicSchema, getFieldLabel, inputFieldComp, mockFields, useFormField, validationMessages };
|
|
449
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Badge, BaseInput, type BtnConfig, Button, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CheckListInput, Checkbox, ColorCnInput, type ColorCompProps, ColorInput, CustomAlert, DateInput, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DynamicForm, DynamicFormExample, type FieldProps, FileInput, Form, FormControl, FormDescription, FormErrorsAlert, FormField, FormItem, FormLabel, FormMessage, type FormResp, type GroupedOption, GroupedSwitchInput, GroupedSwitches, Input, InputFactory, InputList, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, type InputOption, type InputSetup, InputTypes, Label, NumberInput, OTPInput, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, type Props, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectInput, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Switch, SwitchInput, TextAreaInput, TextInput, TextInputType, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cn, entitiesToGroupedOption, entitiesToInputOption, entityToGroupedOption, entityToInputOption, getDefaultValues, getDynamicSchema, getFieldLabel, inputFieldComp, mockFields, useFormField, validationMessages };
|
package/dist/index.mjs
CHANGED
|
@@ -1777,22 +1777,17 @@ var FieldButtonGroup = ({ input, form, isSubmitting }) => {
|
|
|
1777
1777
|
form.setValue(input.name, value, { shouldValidate: true });
|
|
1778
1778
|
};
|
|
1779
1779
|
const selectedValue = form.watch(input.name);
|
|
1780
|
-
return (
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
children: option.label ?? option.name
|
|
1792
|
-
},
|
|
1793
|
-
option.value
|
|
1794
|
-
)) })
|
|
1795
|
-
);
|
|
1780
|
+
return /* @__PURE__ */ jsx(ButtonGroup, { children: options.map((option) => /* @__PURE__ */ jsx(
|
|
1781
|
+
Button,
|
|
1782
|
+
{
|
|
1783
|
+
type: "button",
|
|
1784
|
+
variant: selectedValue === option.value ? "default" : "outline",
|
|
1785
|
+
onClick: () => handleSelect(option.value),
|
|
1786
|
+
disabled: isSubmitting,
|
|
1787
|
+
children: option.label ?? option.name
|
|
1788
|
+
},
|
|
1789
|
+
option.value
|
|
1790
|
+
)) });
|
|
1796
1791
|
};
|
|
1797
1792
|
var CheckListInput = class extends BaseInput {
|
|
1798
1793
|
render() {
|
|
@@ -4340,7 +4335,8 @@ var FieldTextGroup = ({ form, input, isSubmitting }) => {
|
|
|
4340
4335
|
return !fieldState.error && value !== void 0 && value !== "";
|
|
4341
4336
|
});
|
|
4342
4337
|
const [showPassword, setShowPassword] = useState(false);
|
|
4343
|
-
const isPasswordField = input.keyboardType === "password"
|
|
4338
|
+
const isPasswordField = input.keyboardType === "password" /* PASSWORD */;
|
|
4339
|
+
const isNumberField = input.keyboardType === "number" /* NUMBER */;
|
|
4344
4340
|
const showInputGroupAddons = iconsRight.length > 0 || textRight || autoValidate || infoTooltip || isPasswordField;
|
|
4345
4341
|
const formField = /* @__PURE__ */ jsx(
|
|
4346
4342
|
FormField,
|
|
@@ -4362,8 +4358,18 @@ var FieldTextGroup = ({ form, input, isSubmitting }) => {
|
|
|
4362
4358
|
{
|
|
4363
4359
|
placeholder: input.placeHolder,
|
|
4364
4360
|
disabled: input.disabled || isSubmitting,
|
|
4365
|
-
|
|
4366
|
-
|
|
4361
|
+
onBlur: field.onBlur,
|
|
4362
|
+
name: field.name,
|
|
4363
|
+
ref: field.ref,
|
|
4364
|
+
type: isPasswordField && !showPassword ? "password" : isNumberField ? "number" : "text",
|
|
4365
|
+
value: field.value ?? "",
|
|
4366
|
+
onChange: (e) => {
|
|
4367
|
+
let value = e.target.value;
|
|
4368
|
+
if (isNumberField) {
|
|
4369
|
+
value = e.target.value === "" ? "" : Number(e.target.value);
|
|
4370
|
+
}
|
|
4371
|
+
field.onChange(value);
|
|
4372
|
+
}
|
|
4367
4373
|
}
|
|
4368
4374
|
),
|
|
4369
4375
|
showInputGroupAddons && /* @__PURE__ */ jsxs(InputGroupAddon, { align: "inline-end", children: [
|
|
@@ -5592,6 +5598,7 @@ var DynamicForm = ({
|
|
|
5592
5598
|
errorAlertPosition = "up",
|
|
5593
5599
|
withCard = false,
|
|
5594
5600
|
submitBtnClass = "",
|
|
5601
|
+
listBtnConfig = [],
|
|
5595
5602
|
submitBtnLabel = "Guardar"
|
|
5596
5603
|
}) => {
|
|
5597
5604
|
const [isPending, startTransition] = useTransition();
|
|
@@ -5642,23 +5649,38 @@ var DynamicForm = ({
|
|
|
5642
5649
|
/* @__PURE__ */ jsx(FormFieldsGrid, { fields, form, readOnly }),
|
|
5643
5650
|
children && /* @__PURE__ */ jsx("div", { className: "flex flex-row items-center gap-2 w-full h-full", children })
|
|
5644
5651
|
] }),
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5652
|
+
/* @__PURE__ */ jsxs(ButtonGroup, { className: "flex flex-row w-full", children: [
|
|
5653
|
+
listBtnConfig.map((btn, key) => /* @__PURE__ */ jsx(
|
|
5654
|
+
Button,
|
|
5655
|
+
{
|
|
5656
|
+
type: btn.btnType,
|
|
5657
|
+
size: "lg",
|
|
5658
|
+
className: submitBtnClass,
|
|
5659
|
+
variant: btn.variant,
|
|
5660
|
+
onClick: btn.onClick,
|
|
5661
|
+
disabled: btn.disabled,
|
|
5662
|
+
children: btn.label
|
|
5663
|
+
},
|
|
5664
|
+
key
|
|
5665
|
+
)),
|
|
5666
|
+
!readOnly && /* @__PURE__ */ jsx(
|
|
5667
|
+
Button,
|
|
5668
|
+
{
|
|
5669
|
+
type: onClick ? "button" : "submit",
|
|
5670
|
+
size: "lg",
|
|
5671
|
+
className: submitBtnClass,
|
|
5672
|
+
disabled: isPending,
|
|
5673
|
+
onClick: onClick ? handleClick : void 0,
|
|
5674
|
+
children: isPending ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5675
|
+
/* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 mr-2 animate-spin" }),
|
|
5676
|
+
"Guardando..."
|
|
5677
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5678
|
+
/* @__PURE__ */ jsx(Save, { className: "h-4 w-4 mr-2" }),
|
|
5679
|
+
submitBtnLabel
|
|
5680
|
+
] })
|
|
5681
|
+
}
|
|
5682
|
+
)
|
|
5683
|
+
] })
|
|
5662
5684
|
]
|
|
5663
5685
|
}
|
|
5664
5686
|
) }),
|