export type TResolver = (values: T, fieldName?: string) => Promise; export type TUseFormOptions = { defaultValues: T; resolver?: TResolver; debounceMs?: number; }; export type TRegister = { name: string; onchange: (ev: Event) => void; oninput?: (ev: Event) => void; value?: string; checked?: boolean; }; export type TRegisterOptions = { beforeChange?: (value: string, ev: Event) => string | undefined; value?: string; }; export type TUseForm = { register: (path: keyof T, options?: TRegisterOptions) => TRegister; formState: TFormState; onChange: (callback: (data: T) => void) => void; onSubmit: (callback: (data: T, ev: Event) => void) => (ev: SubmitEvent) => void; onErrors: (callback: (errors: TFormValidateResult) => void) => void; destroy: () => void; }; export type TFormState = { errors: (path: keyof T) => HTMLElement | Text; setValue: (path: K, value: T[K]) => void; setValues: (values: Partial) => void; getValue: (path: K) => T[K]; getValues: () => T; isValid: (path?: keyof T) => Promise; getErrors: () => TFormValidateResult; setError: (field: keyof T, message: string) => void; setErrors: (errors: TFormValidateResult) => void; reset: () => void; }; export type TFormValidateResult = { errors: Array<{ path: string; message: string; }>; };