@liam-michel/validated-form 0.1.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 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/ValidatedForm.tsx","../src/createForm.tsx","../src/fields/TextField.tsx","../src/utils/cn.ts","../src/fields/TextAreaField.tsx","../src/fields/NumberField.tsx","../src/fields/SelectField.tsx","../src/fields/CheckboxField.tsx","../src/fields/DateField.tsx","../src/fields/SliderField.tsx","../src/fields/MultiSelectField.tsx","../src/hooks/useValidatedForm.ts"],"sourcesContent":["export { ValidatedForm } from './ValidatedForm';\nexport { createForm } from './createForm';\nexport { useValidatedForm } from './hooks/useValidatedForm';\n\nexport {\n TextField,\n TextAreaField,\n NumberField,\n SelectField,\n CheckboxField,\n DateField,\n SliderField,\n MultiSelectField,\n} from './fields';\n\nexport type {\n BaseFieldProps,\n StringFieldsOf,\n NumberFieldsOf,\n BooleanFieldsOf,\n DateFieldsOf,\n SelectFieldsOf,\n PasswordFieldsOf,\n} from './types';\n","import { useForm, FormProvider } from 'react-hook-form';\nimport type { FieldValues } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { z } from 'zod';\nimport type { ValidatedFormProps } from './types';\n\nexport function ValidatedForm<\n TSchema extends z.ZodType<FieldValues, FieldValues>,\n TInput extends FieldValues = z.input<TSchema> & FieldValues,\n TOutput extends FieldValues = z.output<TSchema> & FieldValues,\n>({\n children,\n schema,\n onSubmit,\n defaultValues,\n form: externalForm,\n submitLabel,\n hideSubmit,\n renderSubmit,\n renderError,\n}: ValidatedFormProps<TInput, TOutput, TSchema>) {\n const internalForm = useForm<TInput, any, TOutput>({\n resolver: zodResolver(schema as any),\n defaultValues,\n });\n\n const form = externalForm ?? internalForm;\n\n const handleSubmit = form.handleSubmit(async (data) => {\n try {\n await onSubmit(data);\n } catch (err: any) {\n const fieldErrors = err?.data?.fieldErrors;\n if (fieldErrors) {\n Object.entries(fieldErrors).forEach(([field, message]) => {\n form.setError(field as any, { message: message as string });\n });\n } else {\n form.setError('root', {\n message: err?.data?.message ?? err?.message ?? 'Something went wrong',\n });\n }\n }\n });\n\n return (\n <FormProvider {...form}>\n <form onSubmit={handleSubmit} className=\"space-y-4\">\n {typeof children === 'function' ? children(form) : children}\n {form.formState.errors.root &&\n (renderError ? (\n renderError(form.formState.errors.root.message!)\n ) : (\n <p className=\"text-sm font-medium text-destructive\">\n {form.formState.errors.root.message}\n </p>\n ))}\n {renderSubmit\n ? renderSubmit({\n isSubmitting: form.formState.isSubmitting,\n reset: form.reset,\n })\n : !hideSubmit && (\n <button\n type=\"submit\"\n disabled={form.formState.isSubmitting}\n className=\"inline-flex h-9 items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-50\"\n >\n {form.formState.isSubmitting\n ? 'Submitting...'\n : (submitLabel ?? 'Submit')}\n </button>\n )}\n </form>\n </FormProvider>\n );\n}\n","import { ValidatedForm } from '.';\nimport z from 'zod';\nimport type { DefaultValues } from 'react-hook-form';\nimport {\n TextField,\n TextAreaField,\n NumberField,\n SelectField,\n CheckboxField,\n DateField,\n SliderField,\n MultiSelectField,\n} from './fields';\nimport type { SelectFieldsOf } from '.';\nimport type { FormComponents } from './types';\nexport function createForm<TSchema extends z.ZodObject<Record<string, any>>>(\n schema: TSchema,\n) {\n const Form = ({\n children,\n onSubmit,\n defaultValues,\n components,\n }: {\n children: React.ReactNode;\n onSubmit: (data: z.output<TSchema>) => Promise<void>;\n defaultValues?: DefaultValues<z.input<TSchema>>;\n components?: Partial<FormComponents>; // add this\n }) => (\n <ValidatedForm\n schema={schema as any}\n onSubmit={onSubmit}\n defaultValues={defaultValues}\n components={components}\n >\n {children}\n </ValidatedForm>\n );\n Form.displayName = 'Form';\n\n const SchemaTextField = (\n props: Omit<Parameters<typeof TextField<TSchema>>[0], 'form'>,\n ) => <TextField<TSchema> {...props} />;\n SchemaTextField.displayName = 'TextField';\n\n const SchemaPasswordField = (\n props: Omit<Parameters<typeof TextField<TSchema>>[0], 'form'>,\n ) => <TextField<TSchema> {...props} />;\n SchemaPasswordField.displayName = 'PasswordField';\n\n const SchemaTextAreaField = (\n props: Omit<Parameters<typeof TextAreaField<TSchema>>[0], 'form'>,\n ) => <TextAreaField<TSchema> {...props} />;\n SchemaTextAreaField.displayName = 'TextAreaField';\n\n const SchemaNumberField = (\n props: Omit<Parameters<typeof NumberField<TSchema>>[0], 'form'>,\n ) => <NumberField<TSchema> {...props} />;\n SchemaNumberField.displayName = 'NumberField';\n\n const SchemaSelectField = <TField extends SelectFieldsOf<TSchema>>(\n props: Omit<Parameters<typeof SelectField<TSchema, TField>>[0], 'form'>,\n ) => <SelectField<TSchema, TField> {...props} />;\n SchemaSelectField.displayName = 'SelectField';\n\n const SchemaCheckboxField = (\n props: Omit<Parameters<typeof CheckboxField<TSchema>>[0], 'form'>,\n ) => <CheckboxField<TSchema> {...props} />;\n SchemaCheckboxField.displayName = 'CheckboxField';\n\n const SchemaDateField = (\n props: Omit<Parameters<typeof DateField<TSchema>>[0], 'form'>,\n ) => <DateField<TSchema> {...props} />;\n SchemaDateField.displayName = 'DateField';\n\n const SchemaSliderField = (\n props: Omit<Parameters<typeof SliderField<TSchema>>[0], 'form'>,\n ) => <SliderField<TSchema> {...props} />;\n SchemaSliderField.displayName = 'SliderField';\n\n const SchemaMultiSelectField = (\n props: Omit<Parameters<typeof MultiSelectField<TSchema>>[0], 'form'>,\n ) => <MultiSelectField<TSchema> {...props} />;\n SchemaMultiSelectField.displayName = 'MultiSelectField';\n\n return {\n Form,\n TextField: SchemaTextField,\n PasswordField: SchemaPasswordField,\n TextAreaField: SchemaTextAreaField,\n NumberField: SchemaNumberField,\n SelectField: SchemaSelectField,\n CheckboxField: SchemaCheckboxField,\n DateField: SchemaDateField,\n SliderField: SchemaSliderField,\n MultiSelectField: SchemaMultiSelectField,\n };\n}\n","import React from 'react';\nimport { Controller, useFormContext } from 'react-hook-form';\nimport type { UseFormReturn } from 'react-hook-form';\nimport { z } from 'zod';\nimport { cn } from '../utils/cn';\nimport type { BaseFieldProps, StringFieldsOf } from '../types';\n\nexport function TextField<TSchema extends z.ZodObject<Record<string, any>>>({\n name,\n label,\n placeholder,\n disabled,\n description,\n className,\n form,\n type = 'text',\n showReset,\n}: BaseFieldProps & {\n name: StringFieldsOf<TSchema>;\n type?: React.HTMLInputTypeAttribute;\n form?: UseFormReturn<z.input<TSchema>>;\n}) {\n const contextForm = useFormContext<z.input<TSchema>>();\n const actualForm = form || contextForm;\n\n return (\n <Controller\n control={actualForm.control}\n name={name as any}\n render={({ field, fieldState }) => (\n <div className={cn('space-y-2', className)}>\n <div className=\"flex items-center justify-between\">\n <label\n htmlFor={name as string}\n className=\"text-sm font-medium leading-none\"\n >\n {label}\n </label>\n {showReset && (\n <button\n type=\"button\"\n onClick={() => actualForm.resetField(name as any)}\n className=\"text-xs text-muted-foreground hover:text-foreground\"\n >\n Reset\n </button>\n )}\n </div>\n <input\n {...field}\n id={name as string}\n value={(field.value as string) ?? ''}\n placeholder={placeholder}\n disabled={disabled}\n type={type}\n className=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50\"\n />\n {description && (\n <p className=\"text-sm text-muted-foreground\">{description}</p>\n )}\n {fieldState.error && (\n <p className=\"text-sm font-medium text-destructive\">\n {fieldState.error.message}\n </p>\n )}\n </div>\n )}\n />\n );\n}\n","import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","import React from 'react';\nimport { Controller, useFormContext } from 'react-hook-form';\nimport type { UseFormReturn } from 'react-hook-form';\nimport { z } from 'zod';\nimport { cn } from '../utils/cn';\nimport type { BaseFieldProps, StringFieldsOf } from '../types';\n\nexport function TextAreaField<\n TSchema extends z.ZodObject<Record<string, any>>,\n>({\n name,\n label,\n placeholder,\n disabled,\n description,\n className,\n form,\n showReset,\n}: BaseFieldProps & {\n name: StringFieldsOf<TSchema>;\n form?: UseFormReturn<z.input<TSchema>>;\n}) {\n const contextForm = useFormContext<z.input<TSchema>>();\n const actualForm = form || contextForm;\n\n return (\n <Controller\n control={actualForm.control}\n name={name as any}\n render={({ field, fieldState }) => (\n <div className={cn('space-y-2', className)}>\n <div className=\"flex items-center justify-between\">\n <label htmlFor={name as string} className=\"text-sm font-medium leading-none\">{label}</label>\n {showReset && (\n <button\n type=\"button\"\n onClick={() => actualForm.resetField(name as any)}\n className=\"text-xs text-muted-foreground hover:text-foreground\"\n >\n Reset\n </button>\n )}\n </div>\n <textarea\n {...field}\n id={name as string}\n value={(field.value as string) ?? ''}\n placeholder={placeholder}\n disabled={disabled}\n className=\"flex min-h-[75px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50\"\n />\n {description && (\n <p className=\"text-sm text-muted-foreground\">{description}</p>\n )}\n {fieldState.error && (\n <p className=\"text-sm font-medium text-destructive\">\n {fieldState.error.message}\n </p>\n )}\n </div>\n )}\n />\n );\n}\n","import React from 'react';\nimport { Controller, useFormContext } from 'react-hook-form';\nimport type { UseFormReturn } from 'react-hook-form';\nimport { z } from 'zod';\nimport { cn } from '../utils/cn';\nimport type { BaseFieldProps, NumberFieldsOf } from '../types';\n\nexport function NumberField<TSchema extends z.ZodObject<Record<string, any>>>({\n name,\n label,\n placeholder,\n disabled,\n description,\n className,\n form,\n showReset,\n}: BaseFieldProps & {\n name: NumberFieldsOf<TSchema>;\n form?: UseFormReturn<z.input<TSchema>>;\n}) {\n const contextForm = useFormContext<z.input<TSchema>>();\n const actualForm = form || contextForm;\n\n return (\n <Controller\n control={actualForm.control}\n name={name as any}\n render={({ field, fieldState }) => (\n <div className={cn('space-y-2', className)}>\n <div className=\"flex items-center justify-between\">\n <label htmlFor={name as string} className=\"text-sm font-medium leading-none\">{label}</label>\n {showReset && (\n <button\n type=\"button\"\n onClick={() => actualForm.resetField(name as any)}\n className=\"text-xs text-muted-foreground hover:text-foreground\"\n >\n Reset\n </button>\n )}\n </div>\n <input\n {...field}\n id={name as string}\n value={(field.value as number) ?? ''}\n placeholder={placeholder}\n disabled={disabled}\n type=\"number\"\n onChange={(e) => {\n const value = e.target.value;\n field.onChange(value === '' ? undefined : Number(value));\n }}\n className=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50\"\n />\n {description && (\n <p className=\"text-sm text-muted-foreground\">{description}</p>\n )}\n {fieldState.error && (\n <p className=\"text-sm font-medium text-destructive\">\n {fieldState.error.message}\n </p>\n )}\n </div>\n )}\n />\n );\n}\n","import React from 'react';\nimport { Controller, useFormContext } from 'react-hook-form';\nimport type { UseFormReturn } from 'react-hook-form';\nimport { z } from 'zod';\nimport * as SelectPrimitive from '@radix-ui/react-select';\nimport { Check, ChevronDown } from 'lucide-react';\nimport { cn } from '../utils/cn';\nimport type { BaseFieldProps, SelectFieldsOf } from '../types';\n\nexport function SelectField<\n TSchema extends z.ZodObject<Record<string, any>>,\n TField extends SelectFieldsOf<TSchema>,\n>({\n name,\n label,\n placeholder,\n disabled,\n description,\n className,\n form,\n options,\n showReset,\n}: BaseFieldProps & {\n name: TField;\n form?: UseFormReturn<z.input<TSchema>>;\n options: Array<{\n value: z.input<TSchema>[TField];\n label: string;\n }>;\n}) {\n const contextForm = useFormContext<z.input<TSchema>>();\n const actualForm = form || contextForm;\n\n return (\n <Controller\n control={actualForm.control}\n name={name as any}\n render={({ field, fieldState }) => (\n <div className={cn('space-y-2', className)}>\n <div className=\"flex items-center justify-between\">\n <label htmlFor={name as string} className=\"text-sm font-medium leading-none\">{label}</label>\n {showReset && (\n <button\n type=\"button\"\n onClick={() => actualForm.resetField(name as any)}\n className=\"text-xs text-muted-foreground hover:text-foreground\"\n >\n Reset\n </button>\n )}\n </div>\n <SelectPrimitive.Root\n onValueChange={field.onChange}\n value={String(field.value || '')}\n disabled={disabled}\n >\n <SelectPrimitive.Trigger className=\"flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50\">\n <SelectPrimitive.Value\n placeholder={placeholder ?? 'Select an option'}\n />\n <SelectPrimitive.Icon>\n <ChevronDown className=\"h-4 w-4 opacity-50\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n <SelectPrimitive.Portal>\n <SelectPrimitive.Content className=\"relative z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md\">\n <SelectPrimitive.Viewport className=\"p-1\">\n {options.map((option) => (\n <SelectPrimitive.Item\n key={String(option.value)}\n value={String(option.value)}\n className=\"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50\"\n >\n <span className=\"absolute left-2 flex h-3.5 w-3.5 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <Check className=\"h-4 w-4\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n <SelectPrimitive.ItemText>\n {option.label}\n </SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n ))}\n </SelectPrimitive.Viewport>\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n </SelectPrimitive.Root>\n {description && (\n <p className=\"text-sm text-muted-foreground\">{description}</p>\n )}\n {fieldState.error && (\n <p className=\"text-sm font-medium text-destructive\">\n {fieldState.error.message}\n </p>\n )}\n </div>\n )}\n />\n );\n}\n","import { Controller, useFormContext } from 'react-hook-form';\nimport type { UseFormReturn } from 'react-hook-form';\nimport { z } from 'zod';\nimport * as CheckboxPrimitive from '@radix-ui/react-checkbox';\nimport { Check } from 'lucide-react';\nimport { cn } from '../utils/cn';\nimport type { BaseFieldProps, BooleanFieldsOf } from '../types';\n\nexport function CheckboxField<\n TSchema extends z.ZodObject<Record<string, any>>,\n>({\n name,\n label,\n disabled,\n description,\n className,\n form,\n}: BaseFieldProps & {\n name: BooleanFieldsOf<TSchema>;\n form?: UseFormReturn<z.input<TSchema>>;\n}) {\n const contextForm = useFormContext<z.input<TSchema>>();\n const actualForm = form || contextForm;\n\n return (\n <Controller\n control={actualForm.control}\n name={name as any}\n render={({ field, fieldState }) => (\n <div className={cn('space-y-2', className)}>\n <div className=\"flex items-center gap-3\">\n <CheckboxPrimitive.Root\n id={name as string}\n checked={!!field.value}\n onCheckedChange={(checked) => field.onChange(checked)}\n disabled={disabled}\n className=\"h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground\"\n >\n <CheckboxPrimitive.Indicator className=\"flex items-center justify-center text-current\">\n <Check className=\"h-3 w-3\" />\n </CheckboxPrimitive.Indicator>\n </CheckboxPrimitive.Root>\n <label\n htmlFor={name as string}\n className=\"text-sm font-medium leading-none\"\n >\n {label}\n </label>\n </div>\n {description && (\n <p className=\"text-sm text-muted-foreground\">{description}</p>\n )}\n {fieldState.error && (\n <p className=\"text-sm font-medium text-destructive\">\n {fieldState.error.message}\n </p>\n )}\n </div>\n )}\n />\n );\n}\n","import React from 'react';\nimport { Controller, useFormContext } from 'react-hook-form';\nimport type { UseFormReturn } from 'react-hook-form';\nimport { z } from 'zod';\nimport { DayPicker } from 'react-day-picker';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { format } from 'date-fns';\nimport { CalendarIcon } from 'lucide-react';\nimport { cn } from '../utils/cn';\nimport type { BaseFieldProps, DateFieldsOf } from '../types';\n\nexport function DateField<TSchema extends z.ZodObject<Record<string, any>>>({\n name,\n label,\n description,\n className,\n form,\n showReset,\n}: BaseFieldProps & {\n name: DateFieldsOf<TSchema>;\n form?: UseFormReturn<z.input<TSchema>>;\n}) {\n const contextForm = useFormContext<z.input<TSchema>>();\n const actualForm = form || contextForm;\n\n return (\n <Controller\n control={actualForm.control}\n name={name as any}\n render={({ field, fieldState }) => {\n const date = field.value ? new Date(field.value as any) : undefined;\n\n return (\n <div className={cn('space-y-2', className)}>\n <div className=\"flex items-center justify-between\">\n <label htmlFor={name as string} className=\"text-sm font-medium leading-none\">\n {label}\n </label>\n {showReset && (\n <button\n type=\"button\"\n onClick={() => actualForm.resetField(name as any)}\n className=\"text-xs text-muted-foreground hover:text-foreground\"\n >\n Reset\n </button>\n )}\n </div>\n <PopoverPrimitive.Root>\n <PopoverPrimitive.Trigger asChild>\n <button\n type=\"button\"\n className={cn(\n 'flex h-9 w-full items-center justify-start gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50',\n !date && 'text-muted-foreground',\n )}\n >\n <CalendarIcon className=\"h-4 w-4\" />\n {date ? format(date, 'PPP') : 'Pick a date'}\n </button>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n align=\"start\"\n className=\"z-50 rounded-md border bg-popover p-0 text-popover-foreground shadow-md outline-none\"\n >\n <DayPicker\n mode=\"single\"\n selected={date}\n onSelect={(d) => field.onChange(d)}\n className=\"p-3\"\n />\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n {description && (\n <p className=\"text-sm text-muted-foreground\">{description}</p>\n )}\n {fieldState.error && (\n <p className=\"text-sm font-medium text-destructive\">\n {fieldState.error.message}\n </p>\n )}\n </div>\n );\n }}\n />\n );\n}\n","import React from 'react';\nimport { Controller, useFormContext } from 'react-hook-form';\nimport type { UseFormReturn } from 'react-hook-form';\nimport { z } from 'zod';\nimport * as SliderPrimitive from '@radix-ui/react-slider';\nimport { cn } from '../utils/cn';\nimport type { BaseFieldProps, NumberFieldsOf } from '../types';\n\nexport function SliderField<TSchema extends z.ZodObject<Record<string, any>>>({\n name,\n label,\n description,\n disabled,\n className,\n form,\n min = 0,\n max = 100,\n step = 1,\n showReset,\n}: BaseFieldProps & {\n name: NumberFieldsOf<TSchema>;\n form?: UseFormReturn<z.input<TSchema>>;\n min?: number;\n max?: number;\n step?: number;\n}) {\n const contextForm = useFormContext<z.input<TSchema>>();\n const actualForm = form || contextForm;\n\n return (\n <Controller\n control={actualForm.control}\n name={name as any}\n render={({ field, fieldState }) => {\n const value = field.value !== undefined ? (field.value as number) : min;\n\n return (\n <div className={cn('space-y-2', className)}>\n <div className=\"flex items-center justify-between\">\n <label htmlFor={name as string} className=\"text-sm font-medium leading-none\">\n {label}\n </label>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-sm text-muted-foreground\">{value}</span>\n {showReset && (\n <button\n type=\"button\"\n onClick={() => actualForm.resetField(name as any)}\n className=\"text-xs text-muted-foreground hover:text-foreground\"\n >\n Reset\n </button>\n )}\n </div>\n </div>\n <SliderPrimitive.Root\n value={[value]}\n onValueChange={([val]) => field.onChange(val)}\n min={min}\n max={max}\n step={step}\n disabled={disabled}\n className=\"relative flex w-full touch-none select-none items-center\"\n >\n <SliderPrimitive.Track className=\"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20\">\n <SliderPrimitive.Range className=\"absolute h-full bg-primary\" />\n </SliderPrimitive.Track>\n <SliderPrimitive.Thumb className=\"block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\" />\n </SliderPrimitive.Root>\n {description && (\n <p className=\"text-sm text-muted-foreground\">{description}</p>\n )}\n {fieldState.error && (\n <p className=\"text-sm font-medium text-destructive\">\n {fieldState.error.message}\n </p>\n )}\n </div>\n );\n }}\n />\n );\n}\n","import React from 'react';\nimport { Controller, useFormContext } from 'react-hook-form';\nimport type { UseFormReturn } from 'react-hook-form';\nimport { z } from 'zod';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { Command } from 'cmdk';\nimport { Check, ChevronsUpDown, X } from 'lucide-react';\nimport { cn } from '../utils/cn';\nimport type { BaseFieldProps } from '../types';\n\nexport function MultiSelectField<\n TSchema extends z.ZodObject<Record<string, any>>,\n>({\n name,\n label,\n description,\n disabled,\n form,\n className,\n options,\n placeholder = 'Select options...',\n showReset,\n}: BaseFieldProps & {\n name: keyof z.input<TSchema>;\n form?: UseFormReturn<z.input<TSchema>>;\n options: Array<{ value: string; label: string }>;\n}) {\n const contextForm = useFormContext<z.input<TSchema>>();\n const actualForm = form || contextForm;\n\n return (\n <Controller\n control={actualForm.control}\n name={name as any}\n render={({ field, fieldState }) => {\n const selected: string[] = Array.isArray(field.value)\n ? field.value\n : [];\n\n const toggle = (val: string) => {\n const next = selected.includes(val)\n ? selected.filter((v) => v !== val)\n : [...selected, val];\n field.onChange(next);\n };\n\n return (\n <div className={cn('space-y-2', className)}>\n <div className=\"flex items-center justify-between\">\n <label className=\"text-sm font-medium leading-none\">\n {label}\n </label>\n {showReset && (\n <button\n type=\"button\"\n onClick={() => actualForm.resetField(name as any)}\n className=\"text-xs text-muted-foreground hover:text-foreground\"\n >\n Reset\n </button>\n )}\n </div>\n <PopoverPrimitive.Root>\n <PopoverPrimitive.Trigger asChild>\n <button\n type=\"button\"\n role=\"combobox\"\n disabled={disabled}\n className={cn(\n 'flex min-h-9 w-full flex-wrap items-center justify-between gap-1 rounded-md border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50',\n !selected.length && 'text-muted-foreground',\n )}\n >\n <div className=\"flex flex-wrap gap-1\">\n {selected.length\n ? selected.map((val) => (\n <span\n key={val}\n className=\"inline-flex items-center gap-1 rounded-md border bg-secondary px-1.5 py-0.5 text-xs text-secondary-foreground\"\n >\n {options.find((o) => o.value === val)?.label ?? val}\n <span\n onClick={(e) => {\n e.stopPropagation();\n toggle(val);\n }}\n className=\"cursor-pointer\"\n >\n <X className=\"h-3 w-3\" />\n </span>\n </span>\n ))\n : placeholder}\n </div>\n <ChevronsUpDown className=\"ml-2 h-4 w-4 shrink-0 opacity-50\" />\n </button>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n align=\"start\"\n className=\"z-50 min-w-[200px] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md outline-none\"\n >\n <Command>\n <div className=\"flex items-center border-b px-3\">\n <Command.Input\n placeholder=\"Search...\"\n className=\"flex h-9 w-full bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground\"\n />\n </div>\n <Command.List className=\"max-h-[200px] overflow-y-auto p-1\">\n <Command.Empty className=\"py-6 text-center text-sm\">\n No options found.\n </Command.Empty>\n <Command.Group>\n {options.map((option) => (\n <Command.Item\n key={option.value}\n value={option.value}\n onSelect={() => toggle(option.value)}\n className=\"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground\"\n >\n <Check\n className={cn(\n 'mr-2 h-4 w-4',\n selected.includes(option.value)\n ? 'opacity-100'\n : 'opacity-0',\n )}\n />\n {option.label}\n </Command.Item>\n ))}\n </Command.Group>\n </Command.List>\n </Command>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n {description && (\n <p className=\"text-sm text-muted-foreground\">{description}</p>\n )}\n {fieldState.error && (\n <p className=\"text-sm font-medium text-destructive\">\n {fieldState.error.message}\n </p>\n )}\n </div>\n );\n }}\n />\n );\n}\n","import { useForm } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport type { DefaultValues, FieldValues } from 'react-hook-form';\nimport type { z } from 'zod';\n\nexport function useValidatedForm<TSchema extends z.ZodType<any, FieldValues>>({\n schema,\n defaultValues,\n}: {\n schema: TSchema;\n defaultValues?: DefaultValues<z.input<TSchema>>;\n}) {\n return useForm<z.input<TSchema>, any, z.output<TSchema>>({\n resolver: zodResolver(schema),\n defaultValues,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,6BAAsC;AAEtC,iBAA4B;AAC5B,IAAAA,cAAkB;AA4CZ;AAzCC,SAAS,cAId;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAM;AAAA,EACN;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAiD;AAC/C,QAAM,mBAAe,gCAA8B;AAAA,IACjD,cAAU,wBAAY,MAAa;AAAA,IACnC;AAAA,EACF,CAAC;AAED,QAAM,OAAO,gBAAgB;AAE7B,QAAM,eAAe,KAAK,aAAa,OAAO,SAAS;AACrD,QAAI;AACF,YAAM,SAAS,IAAI;AAAA,IACrB,SAAS,KAAU;AACjB,YAAM,cAAc,KAAK,MAAM;AAC/B,UAAI,aAAa;AACf,eAAO,QAAQ,WAAW,EAAE,QAAQ,CAAC,CAAC,OAAO,OAAO,MAAM;AACxD,eAAK,SAAS,OAAc,EAAE,QAA2B,CAAC;AAAA,QAC5D,CAAC;AAAA,MACH,OAAO;AACL,aAAK,SAAS,QAAQ;AAAA,UACpB,SAAS,KAAK,MAAM,WAAW,KAAK,WAAW;AAAA,QACjD,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF,CAAC;AAED,SACE,4CAAC,uCAAc,GAAG,MAChB,uDAAC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AG,OAAO;AACpC,sBAAoB,cAAc;AAElC,QAAM,sBAAsB,CAC1B,UACG,8CAAC,iBAAwB,GAAG,OAAO;AACxC,sBAAoB,cAAc;AAElC,QAAM,oBAAoB,CACxB,UACG,8CAAC,eAAsB,GAAG,OAAO;AACtC,oBAAkB,cAAc;AAEhC,QAAM,oBAAoB,CACxB,UACG,8CAAC,eAA8B,GAAG,OAAO;AAC9C,oBAAkB,cAAc;AAEhC,QAAM,sBAAsB,CAC1B,UACG,8CAAC,iBAAwB,GAAG,OAAO;AACxC,sBAAoB,cAAc;AAElC,QAAM,kBAAkB,CACtB,UACG,8CAAC,aAAoB,GAAG,OAAO;AACpC,kBAAgB,cAAc;AAE9B,QAAM,oBAAoB,CACxB,UACG,8CAAC,eAAsB,GAAG,OAAO;AACtC,oBAAkB,cAAc;AAEhC,QAAM,yBAAyB,CAC7B,UACG,8CAAC,oBAA2B,GAAG,OAAO;AAC3C,yBAAuB,cAAc;AAErC,SAAO;AAAA,IACL;AAAA,IACA,WAAW;AAAA,IACX,eAAe;AAAA,IACf,eAAe;AAAA,IACf,aAAa;AAAA,IACb,aAAa;AAAA,IACb,eAAe;AAAA,IACf,WAAW;AAAA,IACX,aAAa;AAAA,IACb,kBAAkB;AAAA,EACpB;AACF;;;AUjGA,IAAAC,2BAAwB;AACxB,IAAAC,eAA4B;AAIrB,SAAS,iBAA8D;AAAA,EAC5E;AAAA,EACA;AACF,GAGG;AACD,aAAO,kCAAkD;AAAA,IACvD,cAAU,0BAAY,MAAM;AAAA,IAC5B;AAAA,EACF,CAAC;AACH;","names":["import_zod","import_zod","import_react_hook_form","import_zod","import_jsx_runtime","import_react","import_react_hook_form","import_zod","import_jsx_runtime","import_react","import_react_hook_form","import_zod","import_jsx_runtime","import_react","import_react_hook_form","import_zod","import_jsx_runtime","import_react_hook_form","import_zod","import_lucide_react","import_jsx_runtime","import_react","import_react_hook_form","import_zod","import_lucide_react","import_jsx_runtime","import_react","import_react_hook_form","import_zod","import_jsx_runtime","import_react","import_react_hook_form","import_zod","PopoverPrimitive","import_lucide_react","import_jsx_runtime","import_jsx_runtime","import_react_hook_form","import_zod"]}
@@ -0,0 +1,165 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react_hook_form from 'react-hook-form';
3
+ import { FieldValues, DefaultValues, UseFormReturn } from 'react-hook-form';
4
+ import z, { z as z$1 } from 'zod';
5
+ import React$1 from 'react';
6
+
7
+ type BaseFieldProps = {
8
+ label: string;
9
+ description?: string;
10
+ placeholder?: string;
11
+ disabled?: boolean;
12
+ className?: string;
13
+ showReset?: boolean;
14
+ };
15
+ type ValidatedFormProps<TInput extends FieldValues, TOutput, TSchema> = {
16
+ schema: TSchema;
17
+ onSubmit: (data: TOutput) => Promise<void>;
18
+ defaultValues?: DefaultValues<TInput>;
19
+ children: React.ReactNode | ((form: UseFormReturn<TInput, any, TOutput>) => React.ReactNode);
20
+ form?: UseFormReturn<TInput, any, TOutput>;
21
+ submitLabel?: string;
22
+ hideSubmit?: boolean;
23
+ renderSubmit?: (state: {
24
+ isSubmitting: boolean;
25
+ reset: () => void;
26
+ }) => React.ReactNode;
27
+ renderError?: (message: string) => React.ReactNode;
28
+ components?: Partial<FormComponents>;
29
+ };
30
+ type FormComponents = {
31
+ Input: React.ComponentType<React.InputHTMLAttributes<HTMLInputElement>>;
32
+ Textarea: React.ComponentType<React.TextareaHTMLAttributes<HTMLTextAreaElement>>;
33
+ Button: React.ComponentType<React.ButtonHTMLAttributes<HTMLButtonElement> & {
34
+ variant?: string;
35
+ size?: string;
36
+ }>;
37
+ Label: React.ComponentType<React.LabelHTMLAttributes<HTMLLabelElement>>;
38
+ };
39
+ type StringFieldsOf<TSchema extends z.ZodObject<Record<string, any>>> = {
40
+ [K in keyof z.input<TSchema>]: NonNullable<z.input<TSchema>[K]> extends string ? K : never;
41
+ }[keyof z.input<TSchema>];
42
+ type PasswordFieldsOf<TSchema extends z.ZodObject<Record<string, any>>> = {
43
+ [K in keyof z.input<TSchema>]: NonNullable<z.input<TSchema>[K]> extends string ? K : never;
44
+ }[keyof z.input<TSchema>];
45
+ type NumberFieldsOf<TSchema extends z.ZodObject<Record<string, any>>> = {
46
+ [K in keyof z.input<TSchema>]: NonNullable<z.input<TSchema>[K]> extends number ? K : never;
47
+ }[keyof z.input<TSchema>];
48
+ type BooleanFieldsOf<TSchema extends z.ZodObject<Record<string, any>>> = {
49
+ [K in keyof z.input<TSchema>]: NonNullable<z.input<TSchema>[K]> extends boolean ? K : never;
50
+ }[keyof z.input<TSchema>];
51
+ type DateFieldsOf<TSchema extends z.ZodObject<Record<string, any>>> = {
52
+ [K in keyof z.input<TSchema>]: NonNullable<z.input<TSchema>[K]> extends Date | string ? K : never;
53
+ }[keyof z.input<TSchema>];
54
+ type SelectFieldsOf<TSchema extends z.ZodObject<Record<string, any>>> = {
55
+ [K in keyof TSchema['shape']]: TSchema['shape'][K] extends z.ZodOptional<z.ZodEnum<any>> | z.ZodNullable<z.ZodEnum<any>> | z.ZodEnum<any> | z.ZodOptional<z.ZodEnum<any>> | z.ZodUnion<readonly [z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]> | z.ZodOptional<z.ZodUnion<readonly [z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]>> ? K : never;
56
+ }[keyof TSchema['shape']];
57
+
58
+ declare function ValidatedForm<TSchema extends z$1.ZodType<FieldValues, FieldValues>, TInput extends FieldValues = z$1.input<TSchema> & FieldValues, TOutput extends FieldValues = z$1.output<TSchema> & FieldValues>({ children, schema, onSubmit, defaultValues, form: externalForm, submitLabel, hideSubmit, renderSubmit, renderError, }: ValidatedFormProps<TInput, TOutput, TSchema>): react_jsx_runtime.JSX.Element;
59
+
60
+ declare function TextField<TSchema extends z$1.ZodObject<Record<string, any>>>({ name, label, placeholder, disabled, description, className, form, type, showReset, }: BaseFieldProps & {
61
+ name: StringFieldsOf<TSchema>;
62
+ type?: React$1.HTMLInputTypeAttribute;
63
+ form?: UseFormReturn<z$1.input<TSchema>>;
64
+ }): react_jsx_runtime.JSX.Element;
65
+
66
+ declare function TextAreaField<TSchema extends z$1.ZodObject<Record<string, any>>>({ name, label, placeholder, disabled, description, className, form, showReset, }: BaseFieldProps & {
67
+ name: StringFieldsOf<TSchema>;
68
+ form?: UseFormReturn<z$1.input<TSchema>>;
69
+ }): react_jsx_runtime.JSX.Element;
70
+
71
+ declare function NumberField<TSchema extends z$1.ZodObject<Record<string, any>>>({ name, label, placeholder, disabled, description, className, form, showReset, }: BaseFieldProps & {
72
+ name: NumberFieldsOf<TSchema>;
73
+ form?: UseFormReturn<z$1.input<TSchema>>;
74
+ }): react_jsx_runtime.JSX.Element;
75
+
76
+ declare function SelectField<TSchema extends z$1.ZodObject<Record<string, any>>, TField extends SelectFieldsOf<TSchema>>({ name, label, placeholder, disabled, description, className, form, options, showReset, }: BaseFieldProps & {
77
+ name: TField;
78
+ form?: UseFormReturn<z$1.input<TSchema>>;
79
+ options: Array<{
80
+ value: z$1.input<TSchema>[TField];
81
+ label: string;
82
+ }>;
83
+ }): react_jsx_runtime.JSX.Element;
84
+
85
+ declare function CheckboxField<TSchema extends z$1.ZodObject<Record<string, any>>>({ name, label, disabled, description, className, form, }: BaseFieldProps & {
86
+ name: BooleanFieldsOf<TSchema>;
87
+ form?: UseFormReturn<z$1.input<TSchema>>;
88
+ }): react_jsx_runtime.JSX.Element;
89
+
90
+ declare function DateField<TSchema extends z$1.ZodObject<Record<string, any>>>({ name, label, description, className, form, showReset, }: BaseFieldProps & {
91
+ name: DateFieldsOf<TSchema>;
92
+ form?: UseFormReturn<z$1.input<TSchema>>;
93
+ }): react_jsx_runtime.JSX.Element;
94
+
95
+ declare function SliderField<TSchema extends z$1.ZodObject<Record<string, any>>>({ name, label, description, disabled, className, form, min, max, step, showReset, }: BaseFieldProps & {
96
+ name: NumberFieldsOf<TSchema>;
97
+ form?: UseFormReturn<z$1.input<TSchema>>;
98
+ min?: number;
99
+ max?: number;
100
+ step?: number;
101
+ }): react_jsx_runtime.JSX.Element;
102
+
103
+ declare function MultiSelectField<TSchema extends z$1.ZodObject<Record<string, any>>>({ name, label, description, disabled, form, className, options, placeholder, showReset, }: BaseFieldProps & {
104
+ name: keyof z$1.input<TSchema>;
105
+ form?: UseFormReturn<z$1.input<TSchema>>;
106
+ options: Array<{
107
+ value: string;
108
+ label: string;
109
+ }>;
110
+ }): react_jsx_runtime.JSX.Element;
111
+
112
+ declare function createForm<TSchema extends z.ZodObject<Record<string, any>>>(schema: TSchema): {
113
+ Form: {
114
+ ({ children, onSubmit, defaultValues, components, }: {
115
+ children: React.ReactNode;
116
+ onSubmit: (data: z.output<TSchema>) => Promise<void>;
117
+ defaultValues?: DefaultValues<z.input<TSchema>>;
118
+ components?: Partial<FormComponents>;
119
+ }): react_jsx_runtime.JSX.Element;
120
+ displayName: string;
121
+ };
122
+ TextField: {
123
+ (props: Omit<Parameters<typeof TextField<TSchema>>[0], "form">): react_jsx_runtime.JSX.Element;
124
+ displayName: string;
125
+ };
126
+ PasswordField: {
127
+ (props: Omit<Parameters<typeof TextField<TSchema>>[0], "form">): react_jsx_runtime.JSX.Element;
128
+ displayName: string;
129
+ };
130
+ TextAreaField: {
131
+ (props: Omit<Parameters<typeof TextAreaField<TSchema>>[0], "form">): react_jsx_runtime.JSX.Element;
132
+ displayName: string;
133
+ };
134
+ NumberField: {
135
+ (props: Omit<Parameters<typeof NumberField<TSchema>>[0], "form">): react_jsx_runtime.JSX.Element;
136
+ displayName: string;
137
+ };
138
+ SelectField: {
139
+ <TField extends SelectFieldsOf<TSchema>>(props: Omit<Parameters<typeof SelectField<TSchema, TField>>[0], "form">): react_jsx_runtime.JSX.Element;
140
+ displayName: string;
141
+ };
142
+ CheckboxField: {
143
+ (props: Omit<Parameters<typeof CheckboxField<TSchema>>[0], "form">): react_jsx_runtime.JSX.Element;
144
+ displayName: string;
145
+ };
146
+ DateField: {
147
+ (props: Omit<Parameters<typeof DateField<TSchema>>[0], "form">): react_jsx_runtime.JSX.Element;
148
+ displayName: string;
149
+ };
150
+ SliderField: {
151
+ (props: Omit<Parameters<typeof SliderField<TSchema>>[0], "form">): react_jsx_runtime.JSX.Element;
152
+ displayName: string;
153
+ };
154
+ MultiSelectField: {
155
+ (props: Omit<Parameters<typeof MultiSelectField<TSchema>>[0], "form">): react_jsx_runtime.JSX.Element;
156
+ displayName: string;
157
+ };
158
+ };
159
+
160
+ declare function useValidatedForm<TSchema extends z$1.ZodType<any, FieldValues>>({ schema, defaultValues, }: {
161
+ schema: TSchema;
162
+ defaultValues?: DefaultValues<z$1.input<TSchema>>;
163
+ }): react_hook_form.UseFormReturn<z$1.core.input<TSchema>, any, z$1.core.output<TSchema>>;
164
+
165
+ export { type BaseFieldProps, type BooleanFieldsOf, CheckboxField, DateField, type DateFieldsOf, MultiSelectField, NumberField, type NumberFieldsOf, type PasswordFieldsOf, SelectField, type SelectFieldsOf, SliderField, type StringFieldsOf, TextAreaField, TextField, ValidatedForm, createForm, useValidatedForm };
@@ -0,0 +1,165 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react_hook_form from 'react-hook-form';
3
+ import { FieldValues, DefaultValues, UseFormReturn } from 'react-hook-form';
4
+ import z, { z as z$1 } from 'zod';
5
+ import React$1 from 'react';
6
+
7
+ type BaseFieldProps = {
8
+ label: string;
9
+ description?: string;
10
+ placeholder?: string;
11
+ disabled?: boolean;
12
+ className?: string;
13
+ showReset?: boolean;
14
+ };
15
+ type ValidatedFormProps<TInput extends FieldValues, TOutput, TSchema> = {
16
+ schema: TSchema;
17
+ onSubmit: (data: TOutput) => Promise<void>;
18
+ defaultValues?: DefaultValues<TInput>;
19
+ children: React.ReactNode | ((form: UseFormReturn<TInput, any, TOutput>) => React.ReactNode);
20
+ form?: UseFormReturn<TInput, any, TOutput>;
21
+ submitLabel?: string;
22
+ hideSubmit?: boolean;
23
+ renderSubmit?: (state: {
24
+ isSubmitting: boolean;
25
+ reset: () => void;
26
+ }) => React.ReactNode;
27
+ renderError?: (message: string) => React.ReactNode;
28
+ components?: Partial<FormComponents>;
29
+ };
30
+ type FormComponents = {
31
+ Input: React.ComponentType<React.InputHTMLAttributes<HTMLInputElement>>;
32
+ Textarea: React.ComponentType<React.TextareaHTMLAttributes<HTMLTextAreaElement>>;
33
+ Button: React.ComponentType<React.ButtonHTMLAttributes<HTMLButtonElement> & {
34
+ variant?: string;
35
+ size?: string;
36
+ }>;
37
+ Label: React.ComponentType<React.LabelHTMLAttributes<HTMLLabelElement>>;
38
+ };
39
+ type StringFieldsOf<TSchema extends z.ZodObject<Record<string, any>>> = {
40
+ [K in keyof z.input<TSchema>]: NonNullable<z.input<TSchema>[K]> extends string ? K : never;
41
+ }[keyof z.input<TSchema>];
42
+ type PasswordFieldsOf<TSchema extends z.ZodObject<Record<string, any>>> = {
43
+ [K in keyof z.input<TSchema>]: NonNullable<z.input<TSchema>[K]> extends string ? K : never;
44
+ }[keyof z.input<TSchema>];
45
+ type NumberFieldsOf<TSchema extends z.ZodObject<Record<string, any>>> = {
46
+ [K in keyof z.input<TSchema>]: NonNullable<z.input<TSchema>[K]> extends number ? K : never;
47
+ }[keyof z.input<TSchema>];
48
+ type BooleanFieldsOf<TSchema extends z.ZodObject<Record<string, any>>> = {
49
+ [K in keyof z.input<TSchema>]: NonNullable<z.input<TSchema>[K]> extends boolean ? K : never;
50
+ }[keyof z.input<TSchema>];
51
+ type DateFieldsOf<TSchema extends z.ZodObject<Record<string, any>>> = {
52
+ [K in keyof z.input<TSchema>]: NonNullable<z.input<TSchema>[K]> extends Date | string ? K : never;
53
+ }[keyof z.input<TSchema>];
54
+ type SelectFieldsOf<TSchema extends z.ZodObject<Record<string, any>>> = {
55
+ [K in keyof TSchema['shape']]: TSchema['shape'][K] extends z.ZodOptional<z.ZodEnum<any>> | z.ZodNullable<z.ZodEnum<any>> | z.ZodEnum<any> | z.ZodOptional<z.ZodEnum<any>> | z.ZodUnion<readonly [z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]> | z.ZodOptional<z.ZodUnion<readonly [z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]>> ? K : never;
56
+ }[keyof TSchema['shape']];
57
+
58
+ declare function ValidatedForm<TSchema extends z$1.ZodType<FieldValues, FieldValues>, TInput extends FieldValues = z$1.input<TSchema> & FieldValues, TOutput extends FieldValues = z$1.output<TSchema> & FieldValues>({ children, schema, onSubmit, defaultValues, form: externalForm, submitLabel, hideSubmit, renderSubmit, renderError, }: ValidatedFormProps<TInput, TOutput, TSchema>): react_jsx_runtime.JSX.Element;
59
+
60
+ declare function TextField<TSchema extends z$1.ZodObject<Record<string, any>>>({ name, label, placeholder, disabled, description, className, form, type, showReset, }: BaseFieldProps & {
61
+ name: StringFieldsOf<TSchema>;
62
+ type?: React$1.HTMLInputTypeAttribute;
63
+ form?: UseFormReturn<z$1.input<TSchema>>;
64
+ }): react_jsx_runtime.JSX.Element;
65
+
66
+ declare function TextAreaField<TSchema extends z$1.ZodObject<Record<string, any>>>({ name, label, placeholder, disabled, description, className, form, showReset, }: BaseFieldProps & {
67
+ name: StringFieldsOf<TSchema>;
68
+ form?: UseFormReturn<z$1.input<TSchema>>;
69
+ }): react_jsx_runtime.JSX.Element;
70
+
71
+ declare function NumberField<TSchema extends z$1.ZodObject<Record<string, any>>>({ name, label, placeholder, disabled, description, className, form, showReset, }: BaseFieldProps & {
72
+ name: NumberFieldsOf<TSchema>;
73
+ form?: UseFormReturn<z$1.input<TSchema>>;
74
+ }): react_jsx_runtime.JSX.Element;
75
+
76
+ declare function SelectField<TSchema extends z$1.ZodObject<Record<string, any>>, TField extends SelectFieldsOf<TSchema>>({ name, label, placeholder, disabled, description, className, form, options, showReset, }: BaseFieldProps & {
77
+ name: TField;
78
+ form?: UseFormReturn<z$1.input<TSchema>>;
79
+ options: Array<{
80
+ value: z$1.input<TSchema>[TField];
81
+ label: string;
82
+ }>;
83
+ }): react_jsx_runtime.JSX.Element;
84
+
85
+ declare function CheckboxField<TSchema extends z$1.ZodObject<Record<string, any>>>({ name, label, disabled, description, className, form, }: BaseFieldProps & {
86
+ name: BooleanFieldsOf<TSchema>;
87
+ form?: UseFormReturn<z$1.input<TSchema>>;
88
+ }): react_jsx_runtime.JSX.Element;
89
+
90
+ declare function DateField<TSchema extends z$1.ZodObject<Record<string, any>>>({ name, label, description, className, form, showReset, }: BaseFieldProps & {
91
+ name: DateFieldsOf<TSchema>;
92
+ form?: UseFormReturn<z$1.input<TSchema>>;
93
+ }): react_jsx_runtime.JSX.Element;
94
+
95
+ declare function SliderField<TSchema extends z$1.ZodObject<Record<string, any>>>({ name, label, description, disabled, className, form, min, max, step, showReset, }: BaseFieldProps & {
96
+ name: NumberFieldsOf<TSchema>;
97
+ form?: UseFormReturn<z$1.input<TSchema>>;
98
+ min?: number;
99
+ max?: number;
100
+ step?: number;
101
+ }): react_jsx_runtime.JSX.Element;
102
+
103
+ declare function MultiSelectField<TSchema extends z$1.ZodObject<Record<string, any>>>({ name, label, description, disabled, form, className, options, placeholder, showReset, }: BaseFieldProps & {
104
+ name: keyof z$1.input<TSchema>;
105
+ form?: UseFormReturn<z$1.input<TSchema>>;
106
+ options: Array<{
107
+ value: string;
108
+ label: string;
109
+ }>;
110
+ }): react_jsx_runtime.JSX.Element;
111
+
112
+ declare function createForm<TSchema extends z.ZodObject<Record<string, any>>>(schema: TSchema): {
113
+ Form: {
114
+ ({ children, onSubmit, defaultValues, components, }: {
115
+ children: React.ReactNode;
116
+ onSubmit: (data: z.output<TSchema>) => Promise<void>;
117
+ defaultValues?: DefaultValues<z.input<TSchema>>;
118
+ components?: Partial<FormComponents>;
119
+ }): react_jsx_runtime.JSX.Element;
120
+ displayName: string;
121
+ };
122
+ TextField: {
123
+ (props: Omit<Parameters<typeof TextField<TSchema>>[0], "form">): react_jsx_runtime.JSX.Element;
124
+ displayName: string;
125
+ };
126
+ PasswordField: {
127
+ (props: Omit<Parameters<typeof TextField<TSchema>>[0], "form">): react_jsx_runtime.JSX.Element;
128
+ displayName: string;
129
+ };
130
+ TextAreaField: {
131
+ (props: Omit<Parameters<typeof TextAreaField<TSchema>>[0], "form">): react_jsx_runtime.JSX.Element;
132
+ displayName: string;
133
+ };
134
+ NumberField: {
135
+ (props: Omit<Parameters<typeof NumberField<TSchema>>[0], "form">): react_jsx_runtime.JSX.Element;
136
+ displayName: string;
137
+ };
138
+ SelectField: {
139
+ <TField extends SelectFieldsOf<TSchema>>(props: Omit<Parameters<typeof SelectField<TSchema, TField>>[0], "form">): react_jsx_runtime.JSX.Element;
140
+ displayName: string;
141
+ };
142
+ CheckboxField: {
143
+ (props: Omit<Parameters<typeof CheckboxField<TSchema>>[0], "form">): react_jsx_runtime.JSX.Element;
144
+ displayName: string;
145
+ };
146
+ DateField: {
147
+ (props: Omit<Parameters<typeof DateField<TSchema>>[0], "form">): react_jsx_runtime.JSX.Element;
148
+ displayName: string;
149
+ };
150
+ SliderField: {
151
+ (props: Omit<Parameters<typeof SliderField<TSchema>>[0], "form">): react_jsx_runtime.JSX.Element;
152
+ displayName: string;
153
+ };
154
+ MultiSelectField: {
155
+ (props: Omit<Parameters<typeof MultiSelectField<TSchema>>[0], "form">): react_jsx_runtime.JSX.Element;
156
+ displayName: string;
157
+ };
158
+ };
159
+
160
+ declare function useValidatedForm<TSchema extends z$1.ZodType<any, FieldValues>>({ schema, defaultValues, }: {
161
+ schema: TSchema;
162
+ defaultValues?: DefaultValues<z$1.input<TSchema>>;
163
+ }): react_hook_form.UseFormReturn<z$1.core.input<TSchema>, any, z$1.core.output<TSchema>>;
164
+
165
+ export { type BaseFieldProps, type BooleanFieldsOf, CheckboxField, DateField, type DateFieldsOf, MultiSelectField, NumberField, type NumberFieldsOf, type PasswordFieldsOf, SelectField, type SelectFieldsOf, SliderField, type StringFieldsOf, TextAreaField, TextField, ValidatedForm, createForm, useValidatedForm };