import { FetchOptions } from '../utils';
export type FormPrepareData = (formData: FormData) => Promise<void> | void;
export type FormOnSubmit<T> = (formData: FormData) => Promise<T> | T | undefined;
export type FormOnSuccess<T> = (data: T) => void;
export type FormOnError = (e: unknown, formData: FormData) => void;
export type FormField = HTMLElement | Field;
export type FormOptions<T> = {
    fields?: FormField[];
    url?: string;
    fetchOptions?: FetchOptions<'json', any>;
    buttonElement?: HTMLButtonElement;
    buttonText?: string;
    prepareData?: FormPrepareData;
    onSubmit?: FormOnSubmit<T>;
    onSuccess?: FormOnSuccess<T>;
    onError?: FormOnError;
};
export declare class Form<T> {
    readonly options?: FormOptions<T> | undefined;
    private form;
    private _fields;
    private _buttonSubmit;
    private _loading;
    private _prepareData?;
    private _onSubmit?;
    private _onSuccess?;
    private _onError?;
    constructor(options?: FormOptions<T> | undefined);
    get isLoading(): boolean;
    get fields(): FormField[];
    addField(...fields: FormField[]): this;
    prepareData(fn?: FormPrepareData): this;
    onSubmit(fn?: FormOnSubmit<T>): this;
    onSuccess(fn?: FormOnSuccess<T>): this;
    onError(fn?: FormOnError): this;
    render(): HTMLFormElement;
    startLoading(): void;
    finishLoading(): void;
    showError(message: string): void;
    clearError(): void;
    submit(event: SubmitEvent): Promise<void>;
}
export declare function createForm<T>(props?: FormOptions<T>): Form<T>;
export type Field = (HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement) & {
    container: HTMLDivElement;
    label?: HTMLLabelElement;
};
export type CreateFieldProps = {
    name: string;
    field?: 'input' | 'select' | 'textarea';
    label?: string | boolean;
    [key: string]: any;
};
export declare function createField(props: CreateFieldProps): Field;
