import { ErrorValue, FormDataErrors, FormDataKeys, FormDataValues, Progress, UrlMethodPair, UseFormTransformCallback, UseFormWithPrecognitionArguments } from '@inertiajs/core'; import { NamedInputEvent, ValidationConfig, Validator } from 'laravel-precognition'; type PrecognitionValidationConfig = ValidationConfig & { only?: TKeys[] | Iterable | ArrayLike; }; export interface FormStateProps { isDirty: boolean; errors: FormDataErrors; hasErrors: boolean; processing: boolean; progress: Progress | null; wasSuccessful: boolean; recentlySuccessful: boolean; data(): TForm; transform(callback: UseFormTransformCallback): this; defaults(): this; defaults>(field: T, value: FormDataValues): this; defaults(fields: Partial): this; reset>(...fields: K[]): this; clearErrors>(...fields: K[]): this; resetAndClearErrors>(...fields: K[]): this; setError>(field: K, value: ErrorValue): this; setError(errors: FormDataErrors): this; withPrecognition(...args: UseFormWithPrecognitionArguments): this & FormStateValidationProps; } export interface FormStateValidationProps { invalid>(field: K): boolean; setValidationTimeout(duration: number): this; touch>(field: K | NamedInputEvent | Array, ...fields: K[]): this; touched>(field?: K): boolean; valid>(field: K): boolean; validate>(field?: K | NamedInputEvent | PrecognitionValidationConfig, config?: PrecognitionValidationConfig): this; validateFiles(): this; validating: boolean; validator: () => Validator; withAllErrors(): this; withoutFileValidation(): this; setErrors(errors: FormDataErrors | Record): this; forgetError | NamedInputEvent>(field: K): this; } interface InternalPrecognitionState { __touched: string[]; __valid: string[]; } export type FormState = TForm & FormStateProps; export type FormStateWithPrecognition = FormState & FormStateValidationProps & InternalPrecognitionState; interface InternalRememberState { __rememberable: boolean; __remember: () => { data: TForm; errors: FormDataErrors; }; __restore: (restored: { data: TForm; errors: FormDataErrors; }) => void; } export interface UseFormStateOptions { data: TForm | (() => TForm); rememberKey?: string | null; precognitionEndpoint?: (() => UrlMethodPair) | null; } export interface UseFormStateReturn { form: FormState & InternalRememberState; setDefaults: (newDefaults: TForm) => void; getTransform: () => UseFormTransformCallback; getPrecognitionEndpoint: () => (() => UrlMethodPair) | null; markAsSuccessful: () => void; wasDefaultsCalledInOnSuccess: () => boolean; resetDefaultsCalledInOnSuccess: () => void; setRememberExcludeKeys: (keys: FormDataKeys[]) => void; resetBeforeSubmit: () => void; finishProcessing: () => void; withAllErrors: { enabled: () => boolean; enable: () => void; }; } export default function useFormState(options: UseFormStateOptions): UseFormStateReturn; export {};