import { z, ZodSchema } from "zod"; import { type FormEvent } from "react"; import { type ErrorResponse, type InvalidSubmissionResponse } from "../utils/error.js"; import { type DefaultValue } from "@conform-to/react"; import type { Submission } from "@conform-to/dom"; import { type ActionFunction, type FetcherWithComponents } from "react-router"; type ActionReturnType = Awaited>; export type SuccessResponseData = Exclude, InvalidSubmissionResponse>["reply"]>> | ErrorResponse>; interface UseActionOptions { path?: string; method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE"; onSuccess?(response: SuccessResponseData): void; onError?(response: InvalidSubmissionResponse>["reply"]>> | ErrorResponse): void; } declare function useAction(options: UseActionOptions): { submit: (data: z.infer) => void; fetcher: FetcherWithComponents>>; }; interface UseActionFormOptions extends UseActionOptions { schema: TSchema; onFormSubmit?: (event: FormEvent, data: z.infer) => void; defaultValue?: DefaultValue>; } declare function useActionForm(options: UseActionFormOptions & { schema: TSchema; }): { form: import("@conform-to/react").FormMetadata, string[]>; fields: Required<{ [Key in keyof import("@conform-to/dom").Combine>]: import("@conform-to/react").FieldMetadata>[Key], z.TypeOf, string[]>; }>; fetcher: FetcherWithComponents>>; submit: (data: z.TypeOf) => void; }; export { useAction, useActionForm };