import { type ComponentProps } from "react";
import type { RPC } from "./rpc";
import type { ApiRouterHandler } from "../http/ApiRouter";
import type { UnwrapPromise } from "../utils/type";
import type { UrlParser } from "./types";
type Any = any;
type GetResult<T> = T extends ApiRouterHandler<Any, infer Result, Any> ? UnwrapPromise<Result> : never;
type PostRequests = {
    [K in keyof RPC as K extends `POST:${infer P}` ? P : never]: GetResult<RPC[K]>;
};
type PutRequests = {
    [K in keyof RPC as K extends `PUT:${infer P}` ? P : never]: GetResult<RPC[K]>;
};
type DeleteRequests = {
    [K in keyof RPC as K extends `DELETE:${infer P}` ? P : never]: GetResult<RPC[K]>;
};
type PatchRequests = {
    [K in keyof RPC as K extends `PATCH:${infer P}` ? P : never]: GetResult<RPC[K]>;
};
type Methods = {
    POST: PostRequests;
    PUT: PutRequests;
    DELETE: DeleteRequests;
    PATCH: PatchRequests;
};
interface FormProps<M extends keyof Methods, K extends keyof Methods[M]> extends Omit<ComponentProps<"form">, "action" | "onError"> {
    method?: M;
    action: K;
    onSuccess?: (result: Methods[M][K], form: HTMLFormElement) => void;
    onError?: (error: Any, form: HTMLFormElement) => void;
    params?: Partial<UrlParser<`${K & string}`>>;
    search?: Record<string, string>;
    dynamicInputs?: (formData: FormData) => Record<string, any>;
}
export declare function Form<K extends keyof Methods[T], T extends keyof Methods = "POST">(props: FormProps<T, K>): import("react/jsx-runtime").JSX.Element;
export declare function useMutationStatus(): {
    isPending: boolean;
};
export declare function useFormStatus(): {
    isPending: boolean;
    validationErrors: Record<string, string[]>;
    formError: string;
};
export declare function useFormData(): unknown;
export declare const ValidationErrors: (props: {
    name: string;
    className?: string;
    render?: (props: ComponentProps<"div">) => React.JSX.Element;
}) => import("react/jsx-runtime").JSX.Element;
export declare const FormFieldContainer: (props: ComponentProps<"div"> & {
    name: string;
}) => import("react/jsx-runtime").JSX.Element;
export declare const FormError: (props: ComponentProps<"div">) => import("react/jsx-runtime").JSX.Element;
export {};
//# sourceMappingURL=Mutation.d.ts.map