shadcn-zod-formkit 1.0.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.
@@ -0,0 +1,377 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import { ReactNode, JSX } from 'react';
4
+ import { ZodTypeAny, ZodType, z, ZodObject } from 'zod';
5
+ import * as react_hook_form from 'react-hook-form';
6
+ import { UseFormReturn, FieldValues, FormState, FieldPath, ControllerProps } from 'react-hook-form';
7
+ import * as AccordionPrimitive from '@radix-ui/react-accordion';
8
+ import * as class_variance_authority_types from 'class-variance-authority/types';
9
+ import { VariantProps } from 'class-variance-authority';
10
+ import { DayPicker, DayButton } from 'react-day-picker';
11
+ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
12
+ import * as DialogPrimitive from '@radix-ui/react-dialog';
13
+ import * as LabelPrimitive from '@radix-ui/react-label';
14
+ import { Slot } from '@radix-ui/react-slot';
15
+ import { OTPInput as OTPInput$1 } from 'input-otp';
16
+ import * as PopoverPrimitive from '@radix-ui/react-popover';
17
+ import * as ResizablePrimitive from 'react-resizable-panels';
18
+ import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
19
+ import * as SelectPrimitive from '@radix-ui/react-select';
20
+ import * as SeparatorPrimitive from '@radix-ui/react-separator';
21
+ import { ToasterProps } from 'sonner';
22
+ import * as SwitchPrimitive from '@radix-ui/react-switch';
23
+ import * as TooltipPrimitive from '@radix-ui/react-tooltip';
24
+
25
+ interface Props$4 {
26
+ title: string;
27
+ description: string | ReactNode;
28
+ className?: string;
29
+ variant?: "info" | "warning" | "error" | "success";
30
+ }
31
+ declare const CustomAlert: ({ title, description, className, variant, }: Props$4) => react_jsx_runtime.JSX.Element;
32
+
33
+ declare const validationMessages: {
34
+ required: string;
35
+ email: string;
36
+ invalidFormat: string;
37
+ onlyPositive: string;
38
+ minLength: (length: number) => string;
39
+ maxLength: (length: number) => string;
40
+ passwordMismatch: string;
41
+ invalidPhone: string;
42
+ };
43
+
44
+ declare enum InputTypes {
45
+ HIDDEN = "hidden",
46
+ TEXT = "text",
47
+ NUMBER = "number",
48
+ SWITCH = "switch",
49
+ SELECT = "select",
50
+ CHECK_LIST = "checklist",
51
+ GROUPED_SWITCH_LIST = "grouped_switchlist",
52
+ DATE = "date",
53
+ TEXTAREA = "textarea",
54
+ FILE = "file",
55
+ OTP = "otp",
56
+ FORM = "form",
57
+ COLOR = "color"
58
+ }
59
+ declare const inputFieldComp: InputTypes[];
60
+
61
+ interface CustomFormProps {
62
+ formTitle: string;
63
+ inputConfig: FieldProps[];
64
+ fieldsConfig: Array<FieldProps | FieldProps[]>;
65
+ defaultValues: Record<string, any>;
66
+ formSchema: ZodType<any, any, any>;
67
+ submitBtnLabel?: string;
68
+ className?: string;
69
+ isFormChild?: boolean;
70
+ columns?: number;
71
+ gap?: number;
72
+ onSubmit: (values: Record<string, any>) => void;
73
+ }
74
+ interface FieldProps {
75
+ name: string;
76
+ label: string;
77
+ placeHolder?: string;
78
+ description?: string;
79
+ className?: string;
80
+ inputType?: InputTypes;
81
+ keyboardType?: TextInputType;
82
+ disabled?: boolean;
83
+ required?: boolean;
84
+ value?: any;
85
+ min?: number;
86
+ max?: number;
87
+ zodTypeAny?: ZodTypeAny;
88
+ list?: any[];
89
+ dependsOn?: string;
90
+ loadOptions?: (dependencyValue: any) => Promise<any[]>;
91
+ optionLabel?: string;
92
+ optionValue?: string;
93
+ optionDescription?: string;
94
+ hidden?: boolean;
95
+ onListOptionChange?: (item: any) => void;
96
+ listConfig?: ListConfig;
97
+ fileConfig?: {
98
+ previewSize?: number;
99
+ showPreview?: boolean;
100
+ accept: string;
101
+ multiple: boolean;
102
+ maxSize: number;
103
+ };
104
+ }
105
+ interface ListConfig {
106
+ list: InputOption[] | GroupedOption[];
107
+ optionLabel?: string;
108
+ optionValue?: InputOption | string | number | object;
109
+ onOptionChange: (item?: InputOption | InputOption[] | GroupedOption) => void;
110
+ optionDescription?: string;
111
+ selectedList?: InputOption[];
112
+ }
113
+ interface InputOption {
114
+ id: number | string;
115
+ name: string;
116
+ label?: string;
117
+ description?: string;
118
+ disabled?: boolean;
119
+ checked?: boolean;
120
+ groupedLabel?: string;
121
+ value?: any;
122
+ }
123
+ interface GroupedOption {
124
+ id?: number;
125
+ label: string;
126
+ options: InputOption[];
127
+ totalSelected?: number;
128
+ disabled?: boolean;
129
+ value?: any;
130
+ }
131
+ interface InputSetup {
132
+ required: boolean;
133
+ disabled: boolean;
134
+ minLegth?: number;
135
+ maxLength?: number;
136
+ pattern?: RegExp;
137
+ min?: number;
138
+ max?: number;
139
+ isObscure?: boolean;
140
+ isEmail?: boolean;
141
+ isUrl?: boolean;
142
+ zopType?: z.ZodType;
143
+ }
144
+ declare enum TextInputType {
145
+ DEFAULT = "default",
146
+ NUMBER = "number",
147
+ EMAIL = "email",
148
+ PHONE = "phone",
149
+ PASSWORD = "password"
150
+ }
151
+
152
+ declare abstract class BaseInput {
153
+ protected readonly input: FieldProps;
154
+ protected readonly form: UseFormReturn;
155
+ constructor(input: FieldProps, form: UseFormReturn);
156
+ abstract render(): JSX.Element;
157
+ }
158
+
159
+ interface Props$3 {
160
+ fields: Array<FieldProps | FieldProps[]>;
161
+ record?: Record<string, any>;
162
+ onSubmit?: (data: any) => void;
163
+ }
164
+ declare const DynamicForm: ({ fields, record, onSubmit }: Props$3) => react_jsx_runtime.JSX.Element;
165
+
166
+ declare const DynamicFormExample: () => react_jsx_runtime.JSX.Element;
167
+ declare const mockFields: Array<FieldProps | FieldProps[]>;
168
+
169
+ interface Props$2<T extends FieldValues> {
170
+ formState: FormState<T>;
171
+ fields: Array<FieldProps | FieldProps[]>;
172
+ }
173
+ declare const FormErrors: <T extends FieldValues>({ formState, fields }: Props$2<T>) => react_jsx_runtime.JSX.Element;
174
+
175
+ declare class InputFactory {
176
+ static create(input: FieldProps, form: UseFormReturn): JSX.Element;
177
+ }
178
+ declare function getDefaultValues<T extends Record<string, any>>(entity: T): Record<string, any>;
179
+ declare const getDynamicSchema: (fields: Array<FieldProps | FieldProps[]>) => ZodObject<any>;
180
+
181
+ declare class CheckListInput extends BaseInput {
182
+ render(): JSX.Element;
183
+ }
184
+
185
+ declare class ColorInput extends BaseInput {
186
+ render(): JSX.Element;
187
+ }
188
+ interface ColorCompProps {
189
+ value?: string;
190
+ onChange?: (color: string) => void;
191
+ onBlur?: () => void;
192
+ disabled?: boolean;
193
+ className?: string;
194
+ placeholder?: string;
195
+ }
196
+
197
+ declare class DateInput extends BaseInput {
198
+ render(): JSX.Element;
199
+ }
200
+
201
+ declare class FileInput extends BaseInput {
202
+ render(): JSX.Element;
203
+ }
204
+
205
+ declare class GroupedSwitchInput extends BaseInput {
206
+ render(): JSX.Element;
207
+ }
208
+
209
+ declare class NumberInput extends BaseInput {
210
+ render(): JSX.Element;
211
+ }
212
+
213
+ declare class OTPInput extends BaseInput {
214
+ render(): JSX.Element;
215
+ }
216
+
217
+ declare class SelectInput extends BaseInput {
218
+ render(): react_jsx_runtime.JSX.Element;
219
+ }
220
+
221
+ declare class SwitchInput extends BaseInput {
222
+ render(): JSX.Element;
223
+ }
224
+
225
+ declare class TextAreaInput extends BaseInput {
226
+ render(): JSX.Element;
227
+ }
228
+
229
+ declare class TextInput extends BaseInput {
230
+ render(): JSX.Element;
231
+ }
232
+
233
+ interface Props$1 {
234
+ handleAddInput: (type: InputTypes, config?: InputSetup) => void;
235
+ inputsTypes: InputTypes[];
236
+ }
237
+ declare const InputList: ({ handleAddInput, inputsTypes, }: Props$1) => react_jsx_runtime.JSX.Element;
238
+
239
+ declare function Accordion({ ...props }: React.ComponentProps<typeof AccordionPrimitive.Root>): react_jsx_runtime.JSX.Element;
240
+ declare function AccordionItem({ className, ...props }: React.ComponentProps<typeof AccordionPrimitive.Item>): react_jsx_runtime.JSX.Element;
241
+ declare function AccordionTrigger({ className, children, ...props }: React.ComponentProps<typeof AccordionPrimitive.Trigger>): react_jsx_runtime.JSX.Element;
242
+ declare function AccordionContent({ className, children, ...props }: React.ComponentProps<typeof AccordionPrimitive.Content>): react_jsx_runtime.JSX.Element;
243
+
244
+ declare const alertVariants: (props?: ({
245
+ variant?: "default" | "destructive" | null | undefined;
246
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
247
+ declare function Alert({ className, variant, ...props }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>): react_jsx_runtime.JSX.Element;
248
+ declare function AlertTitle({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
249
+ declare function AlertDescription({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
250
+
251
+ declare const badgeVariants: (props?: ({
252
+ variant?: "default" | "destructive" | "secondary" | "outline" | null | undefined;
253
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
254
+ declare function Badge({ className, variant, asChild, ...props }: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & {
255
+ asChild?: boolean;
256
+ }): react_jsx_runtime.JSX.Element;
257
+
258
+ declare const buttonVariants: (props?: ({
259
+ variant?: "default" | "destructive" | "link" | "secondary" | "outline" | "ghost" | null | undefined;
260
+ size?: "default" | "sm" | "lg" | "icon" | null | undefined;
261
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
262
+ declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
263
+ asChild?: boolean;
264
+ }): react_jsx_runtime.JSX.Element;
265
+
266
+ declare function Calendar({ className, classNames, showOutsideDays, captionLayout, buttonVariant, formatters, components, ...props }: React.ComponentProps<typeof DayPicker> & {
267
+ buttonVariant?: React.ComponentProps<typeof Button>["variant"];
268
+ }): react_jsx_runtime.JSX.Element;
269
+ declare function CalendarDayButton({ className, day, modifiers, ...props }: React.ComponentProps<typeof DayButton>): react_jsx_runtime.JSX.Element;
270
+
271
+ declare function Card({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
272
+ declare function CardHeader({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
273
+ declare function CardTitle({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
274
+ declare function CardDescription({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
275
+ declare function CardAction({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
276
+ declare function CardContent({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
277
+ declare function CardFooter({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
278
+
279
+ declare function Checkbox({ className, ...props }: React.ComponentProps<typeof CheckboxPrimitive.Root>): react_jsx_runtime.JSX.Element;
280
+
281
+ interface Props {
282
+ value?: string;
283
+ onChange?: (color: string) => void;
284
+ onBlur?: () => void;
285
+ disabled?: boolean;
286
+ className?: string;
287
+ placeholder?: string;
288
+ }
289
+ declare const ColorCnInput: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLButtonElement>>;
290
+
291
+ declare function Dialog({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>): react_jsx_runtime.JSX.Element;
292
+ declare function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>): react_jsx_runtime.JSX.Element;
293
+ declare function DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>): react_jsx_runtime.JSX.Element;
294
+ declare function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>): react_jsx_runtime.JSX.Element;
295
+ declare function DialogOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>): react_jsx_runtime.JSX.Element;
296
+ declare function DialogContent({ className, children, showCloseButton, ...props }: React.ComponentProps<typeof DialogPrimitive.Content> & {
297
+ showCloseButton?: boolean;
298
+ }): react_jsx_runtime.JSX.Element;
299
+ declare function DialogHeader({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
300
+ declare function DialogFooter({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
301
+ declare function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>): react_jsx_runtime.JSX.Element;
302
+ declare function DialogDescription({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Description>): react_jsx_runtime.JSX.Element;
303
+
304
+ declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>(props: react_hook_form.FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
305
+ declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: ControllerProps<TFieldValues, TName>) => react_jsx_runtime.JSX.Element;
306
+ declare const useFormField: () => {
307
+ invalid: boolean;
308
+ isDirty: boolean;
309
+ isTouched: boolean;
310
+ isValidating: boolean;
311
+ error?: react_hook_form.FieldError;
312
+ id: string;
313
+ name: string;
314
+ formItemId: string;
315
+ formDescriptionId: string;
316
+ formMessageId: string;
317
+ };
318
+ declare function FormItem({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
319
+ declare function FormLabel({ className, ...props }: React.ComponentProps<typeof LabelPrimitive.Root>): react_jsx_runtime.JSX.Element;
320
+ declare function FormControl({ ...props }: React.ComponentProps<typeof Slot>): react_jsx_runtime.JSX.Element;
321
+ declare function FormDescription({ className, ...props }: React.ComponentProps<"p">): react_jsx_runtime.JSX.Element;
322
+ declare function FormMessage({ className, ...props }: React.ComponentProps<"p">): react_jsx_runtime.JSX.Element | null;
323
+
324
+ declare function InputOTP({ className, containerClassName, ...props }: React.ComponentProps<typeof OTPInput$1> & {
325
+ containerClassName?: string;
326
+ }): react_jsx_runtime.JSX.Element;
327
+ declare function InputOTPGroup({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
328
+ declare function InputOTPSlot({ index, className, ...props }: React.ComponentProps<"div"> & {
329
+ index: number;
330
+ }): react_jsx_runtime.JSX.Element;
331
+ declare function InputOTPSeparator({ ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
332
+
333
+ declare function Input({ className, type, ...props }: React.ComponentProps<"input">): react_jsx_runtime.JSX.Element;
334
+
335
+ declare function Label({ className, ...props }: React.ComponentProps<typeof LabelPrimitive.Root>): react_jsx_runtime.JSX.Element;
336
+
337
+ declare function Popover({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Root>): react_jsx_runtime.JSX.Element;
338
+ declare function PopoverTrigger({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Trigger>): react_jsx_runtime.JSX.Element;
339
+ declare function PopoverContent({ className, align, sideOffset, ...props }: React.ComponentProps<typeof PopoverPrimitive.Content>): react_jsx_runtime.JSX.Element;
340
+ declare function PopoverAnchor({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Anchor>): react_jsx_runtime.JSX.Element;
341
+
342
+ declare function ResizablePanelGroup({ className, ...props }: React.ComponentProps<typeof ResizablePrimitive.PanelGroup>): react_jsx_runtime.JSX.Element;
343
+ declare function ResizablePanel({ ...props }: React.ComponentProps<typeof ResizablePrimitive.Panel>): react_jsx_runtime.JSX.Element;
344
+ declare function ResizableHandle({ withHandle, className, ...props }: React.ComponentProps<typeof ResizablePrimitive.PanelResizeHandle> & {
345
+ withHandle?: boolean;
346
+ }): react_jsx_runtime.JSX.Element;
347
+
348
+ declare function ScrollArea({ className, children, ...props }: React.ComponentProps<typeof ScrollAreaPrimitive.Root>): react_jsx_runtime.JSX.Element;
349
+ declare function ScrollBar({ className, orientation, ...props }: React.ComponentProps<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>): react_jsx_runtime.JSX.Element;
350
+
351
+ declare function Select({ ...props }: React.ComponentProps<typeof SelectPrimitive.Root>): react_jsx_runtime.JSX.Element;
352
+ declare function SelectGroup({ ...props }: React.ComponentProps<typeof SelectPrimitive.Group>): react_jsx_runtime.JSX.Element;
353
+ declare function SelectValue({ ...props }: React.ComponentProps<typeof SelectPrimitive.Value>): react_jsx_runtime.JSX.Element;
354
+ declare function SelectTrigger({ className, size, children, ...props }: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
355
+ size?: "sm" | "default";
356
+ }): react_jsx_runtime.JSX.Element;
357
+ declare function SelectContent({ className, children, position, ...props }: React.ComponentProps<typeof SelectPrimitive.Content>): react_jsx_runtime.JSX.Element;
358
+ declare function SelectLabel({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.Label>): react_jsx_runtime.JSX.Element;
359
+ declare function SelectItem({ className, children, ...props }: React.ComponentProps<typeof SelectPrimitive.Item>): react_jsx_runtime.JSX.Element;
360
+ declare function SelectSeparator({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.Separator>): react_jsx_runtime.JSX.Element;
361
+ declare function SelectScrollUpButton({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>): react_jsx_runtime.JSX.Element;
362
+ declare function SelectScrollDownButton({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>): react_jsx_runtime.JSX.Element;
363
+
364
+ declare function Separator({ className, orientation, decorative, ...props }: React.ComponentProps<typeof SeparatorPrimitive.Root>): react_jsx_runtime.JSX.Element;
365
+
366
+ declare const Toaster: ({ ...props }: ToasterProps) => react_jsx_runtime.JSX.Element;
367
+
368
+ declare function Switch({ className, ...props }: React.ComponentProps<typeof SwitchPrimitive.Root>): react_jsx_runtime.JSX.Element;
369
+
370
+ declare function Textarea({ className, ...props }: React.ComponentProps<"textarea">): react_jsx_runtime.JSX.Element;
371
+
372
+ declare function TooltipProvider({ delayDuration, ...props }: React.ComponentProps<typeof TooltipPrimitive.Provider>): react_jsx_runtime.JSX.Element;
373
+ declare function Tooltip({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Root>): react_jsx_runtime.JSX.Element;
374
+ declare function TooltipTrigger({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Trigger>): react_jsx_runtime.JSX.Element;
375
+ declare function TooltipContent({ className, sideOffset, children, ...props }: React.ComponentProps<typeof TooltipPrimitive.Content>): react_jsx_runtime.JSX.Element;
376
+
377
+ 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, type CustomFormProps, DateInput, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DynamicForm, DynamicFormExample, type FieldProps, FileInput, Form, FormControl, FormDescription, FormErrors, FormField, FormItem, FormLabel, FormMessage, type GroupedOption, GroupedSwitchInput, 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, getDefaultValues, getDynamicSchema, inputFieldComp, mockFields, useFormField, validationMessages };