import { RefObject } from 'react'; import { UseFormStateHook, Values } from './useFormState'; import { UseFormValuesHook } from './useFormValues'; import { UseFormErrorsHook } from './useFormErrors'; import { UseFormStatusHook } from './useFormStatus'; export type AfterSubmitOption = 'clear' | 'initialize' | 'reset' | null; export type UseFormSubmissionOptions = { /** * Tells what to do with form values after submit. */ afterSubmit?: AfterSubmitOption; /** * The form errors hook. */ formErrors: UseFormErrorsHook; /** * The form state hook. */ formState: UseFormStateHook; /** * The form status hook. */ formStatus: UseFormStatusHook; /** * The form values hook. */ formValues: UseFormValuesHook; /** * Replaces empty string by null on change and on submit. */ nullify?: boolean; /** * Called when form submission has failed. * @param error */ onError?(error: Error): void; /** * Called when form has been successfully submitted. * @param result * @param values */ onSuccess?(result: R, values: V): void; /** * Handle values to submit. * @param values */ submit?(values: V): Promise; /** * Enables trimming on submit. */ trimOnSubmit?: boolean; }; export type UseFormSubmissionHook = { /** * Submits form values. */ submit: () => Promise; /** * The ref of the submit function. */ submitRef: RefObject['submit']>; }; declare function useFormSubmission(options: UseFormSubmissionOptions): UseFormSubmissionHook; export default useFormSubmission; //# sourceMappingURL=useFormSubmission.d.ts.map