import { ITouched, IValues, IValueTest, ValidateFunction, IErrors, IError, IFormState, IFields } from './useForm/reducer.js';
import { IStore, DispatchFunction } from './utils/useReducer.js';

type SendFunction = (api: Function) => Promise<any>;
interface IUseFormControl {
    send: SendFunction;
    validate: (checkOnlyFilled?: boolean) => void;
    setValue: (name: string, value: any, silent?: boolean, checkOnlyFilled?: boolean, type?: string) => void;
    setTouchedByName: (name: string, value?: boolean, silent?: boolean) => void;
    setTouched: (newTouched: ITouched, silent?: boolean, checkOnlyFilled?: boolean) => void;
    setValues: (newValues: IValues, silent?: boolean, checkOnlyFilled?: boolean, type?: string) => void;
    getValues: () => IValues;
    setTests: (newTests: IValueTest[], silent?: boolean, checkOnlyFilled?: boolean) => void;
    setValidate: (newValidate: ValidateFunction, silent?: boolean, checkOnlyFilled?: boolean) => void;
    setErrors: (newErrors: IErrors) => void;
    setCustomErrors: (newErrors: IErrors) => void;
    setCustomErrorByName: (name: string, error: IError) => void;
}
declare const useFormControl: (props: IFormConfig, store: IStore<IFormState>, dispatch: DispatchFunction) => IUseFormControl;

type FormState<T extends IValues = IValues> = {
    state: IFormState<T>;
    dispatch: DispatchFunction;
    store: IStore<IFormState<T>>;
};
declare const useFormState: <T extends Record<string, unknown> = Record<string, unknown>>(props: IFormConfig) => FormState<T>;

interface IInitialFormConfig {
    initialValues: IValues;
    valueTests: IValueTest[];
    fields: IFields;
    validate?: ValidateFunction;
}
interface IFormConfig extends Partial<IInitialFormConfig> {
    middlewares?: any[];
    debug?: boolean;
}
interface IUseForm<T extends IValues = IValues> {
    /**
     * @deprecated
     */
    IsFormValid: (c: boolean) => boolean;
    isFormValid: (c: boolean) => boolean;
    hasFormErrors: (c: boolean) => [boolean, IErrors];
    getErrors: () => IErrors;
    store: IStore<IFormState<T>>;
    dispatch: DispatchFunction;
    send: SendFunction;
}
type UseFormConfig<T extends Record<string, unknown> = IValues> = IUseForm<T> & Omit<IFormState<T>, "validate"> & IUseFormControl;
type UseFormFieldRuleFunction = (v: unknown) => boolean;
type IUseFormFieldRule = [UseFormFieldRuleFunction[], string?];
interface IUseFormField {
    label: string;
    initialValue?: any;
    rules?: IUseFormFieldRule[];
}
type TypeUseFormField = IUseFormField | string;
type FormSettingsTypeFields = Record<string, TypeUseFormField>;
interface IUseFormSettings {
    fields: FormSettingsTypeFields;
    value?: IValues;
    onChange?: (v: IValues) => void;
    onError?: (v: IErrors) => void;
    options?: IFormConfig;
}
declare const useFormCoreParams: (formSettings: IUseFormSettings) => [IFormConfig, FormState];
declare const useForm: (formSettings: IUseFormSettings) => UseFormConfig<Record<string, unknown>>;

export { FormState as F, IUseFormSettings as I, SendFunction as S, TypeUseFormField as T, UseFormFieldRuleFunction as U, useFormState as a, useFormCoreParams as b, IInitialFormConfig as c, IUseForm as d, UseFormConfig as e, IFormConfig as f, IUseFormFieldRule as g, useFormControl as h, IUseFormControl as i, IUseFormField as j, FormSettingsTypeFields as k, useForm as u };
