import { type Ref } from "vue"; import type { LoaderName, LoaderOptions, Loaders } from "#build/types/loader-types.d.ts"; export type UpdateFunction = (args: UpdateArguments) => void; interface UpdateArguments { result: Ref; } export interface UseFormAction { run?: ActionFunction; loader?: N; loaderOptions?: LoaderOptions; } type ActionFunction = (args: ActionFunctionArgs) => void; interface ActionFunctionArgs { /** * Cancel the default submission. */ cancel: () => void; /** * Handle optimistic updates * * @param update Update callback to update the result. */ optimistic: (update: UpdateFunction) => void; /** * An object version of the `FormData` from this form */ formData: Record; /** * The original submit event. */ event: SubmitEvent; /** * The name of the action. */ action: string; /** * The form element. */ form: HTMLFormElement; /** * The Element that submitted. */ submitter: HTMLElement; /** * The loader URL. */ loader: string | undefined; /** * The default submit function. */ submitForm: () => Promise; } export type ActionResponsePayload = Response & { _data: { data?: Record; action?: Record; }; }; export interface ErrorRef { statusCode: number; statusMessage: string; data: unknown; } export {};