import { FormHTMLAttributes, ComponentType } from 'react';
import { ServerFn } from './server-fn.js';
import { R as RetryOptions } from './api-client-C1YzJu3J.js';
import './cache.js';
import './server-fn-error-DDh14a0V.js';
import './integration-api-BbaiokCC.js';
import './client-cache-BwNdIy9R.js';
import './route-CZkTBD-s.js';
type ServerFnActionStatus = "idle" | "pending" | "success" | "error";
type ServerFnSubmit = [unknown] extends [TInput] ? (input?: TInput | FormData) => Promise : (input: TInput | FormData) => Promise;
type ServerFnOptimisticContext = {
input: TInput | FormData | undefined;
formData?: FormData;
current: TResult | null;
};
type UseServerFnOptions = {
initialResult?: TResult | null;
resetOnSubmit?: boolean;
throwOnFormError?: boolean;
optimistic?: (context: ServerFnOptimisticContext) => TResult | null | undefined;
rollbackOnError?: boolean;
/** Retry failed submissions with the API client's retry shape. Defaults to no retries. */
retry?: RetryOptions;
onSuccess?: (result: TResult) => void;
onError?: (error: TError) => void;
onSettled?: (result: TResult | null, error: TError | null) => void;
};
type UseServerFnReturn = {
pending: boolean;
status: ServerFnActionStatus;
result: TResult | null;
error: TError | null;
submit: ServerFnSubmit;
formAction: (formData: FormData) => Promise;
reset: () => void;
};
type UseActionFormProps = Omit, "action">;
type RouteActionTarget> = {
readonly action: TServerFn;
};
type UseActionReturn = ServerFnSubmit & {
pending: boolean;
status: ServerFnActionStatus;
data: TResult | null;
result: TResult | null;
error: TError | null;
formAction: (formData: FormData) => Promise;
Form: ComponentType;
reset: () => void;
};
declare function useServerFn(serverFn: ServerFn, options?: UseServerFnOptions): UseServerFnReturn;
/**
* Wrap a server function, or a route's default server function, as a callable
* RPC with React mutation state.
*/
declare function useAction(route: RouteActionTarget>, options?: UseServerFnOptions): UseActionReturn;
declare function useAction(serverFn: ServerFn, options?: UseServerFnOptions): UseActionReturn;
export { type RouteActionTarget, type ServerFnActionStatus, type ServerFnOptimisticContext, type ServerFnSubmit, type UseActionFormProps, type UseActionReturn, type UseServerFnOptions, type UseServerFnReturn, useAction, useServerFn };