UNPKG

hoxa

Version:

A comprehensive collection of 100+ production-ready React hooks for state management, UI effects, forms, animations, and more. Carefully curated and optimized for performance and developer experience.

23 lines (22 loc) 797 B
type ValidationRules<T> = { [K in keyof T]?: (value: T[K], values: T) => string | null; }; type FormOptions<T> = { initialValues: T; validate?: ValidationRules<T>; onSubmit: (values: T) => void | Promise<void>; }; export declare function useForm<T extends Record<string, any>>(options: FormOptions<T>): { values: T; errors: Record<keyof T, string | null>; touched: Record<keyof T, boolean>; isSubmitting: boolean; isValid: boolean; handleChange: <K extends keyof T>(field: K, value: T[K]) => void; handleBlur: (field: keyof T) => void; handleSubmit: (e?: React.FormEvent) => Promise<void>; resetForm: () => void; setFieldValue: <K extends keyof T>(field: K, value: T[K]) => void; setFieldTouched: (field: keyof T) => void; }; export {};