/** * Main types module for Reform * Exports all types used throughout the library */ import { Control, FieldPath, UseFormRegister, UseFormReturn, UseFormSetValue } from 'react-hook-form'; import { FormErrorsState } from './core/errors/state/types'; import { FormStateManager } from './core/form/form-state'; import { FieldArrayHelpers } from './features/field-array/types'; import { ConditionalFieldsManager } from './features/conditional/types'; import { FieldConfig, ReformYupIntegration, ValidationConfig, YupSchemaConfig } from './core/validation'; import { FormGroup } from './core/form/form-groups'; import { Maybe, AnyObject } from 'yup'; import { ReformGroupHandler } from './typessss'; /** * Main return type for the useReform hook * Combines all functionality from various modules * * @template T - The type of form data */ export interface ReformReturn> extends FormErrorsState, FormStateManager, ReformGroupHandler, FieldArrayHelpers, ConditionalFieldsManager { /** React Hook Form methods */ formMethods: UseFormReturn<{ groups: FormGroup[]; }>; /** Form configuration */ config: DynamicFormConfig; /** Yup integration utilities */ yup: ReformYupIntegration; /** Get all form groups */ getGroups: () => FormGroup[]; /** Get data for a specific group */ getGroupData: (index: number) => T | undefined; } export declare type DeepPartial = { [P in keyof T]?: T[P] extends object ? DeepPartial : T[P]; }; export declare type InferFormData = T & Record; export declare type FormDataPath = FieldPath<{ groups: FormGroup[]; }>; export declare type FormControl = Control<{ groups: FormGroup[]; }>; export interface FormState { isDirty: boolean; touched: boolean; submitCount: number; isSubmitting: boolean; } export interface YupIntegrationConfig> { /** * Configuration for Yup integration */ yupConfig?: Partial>; } export declare type DynamicFormConfig = { value?: FormGroup[]; minGroups?: number; maxGroups?: number; defaultData?: Partial; fields?: { [K in keyof T]: FieldConfig; }; onChange?: (groups: FormGroup[]) => void; } & ValidationConfig & YupIntegrationConfig; export interface DynamicFormProps extends DynamicFormConfig { disabled?: boolean; className?: string; } export declare type FieldKey = keyof T; export declare type FieldValue> = T[K]; export declare type FieldData = T; export declare type FieldErrorMessage = string; export declare type FieldErrors = Record, FieldErrorMessage>; export interface FieldState { isDirty: boolean; touched: boolean; initialValue: any; } export interface FieldRenderProps { name: string; value: T[K]; error?: string; group: FormGroup; index: number; onChange: (value: T[K]) => void; register: UseFormRegister<{ groups: FormGroup[]; }>; setValue: UseFormSetValue<{ groups: FormGroup[]; }>; fieldPath: string; }