import { IsEmailOptions } from 'validator/es/lib/isEmail';
import { IsURLOptions } from 'validator/es/lib/isURL';
import { TNode, FormResetEvent, FormSubmitEvent } from '../common';
export interface TdFormProps<FormData extends Data = Data> {
    colon?: boolean;
    data?: FormData;
    disabled?: boolean;
    errorMessage?: FormErrorMessage;
    formControlledComponents?: Array<string>;
    labelAlign?: 'left' | 'right' | 'top';
    labelWidth?: string | number;
    layout?: 'vertical' | 'inline';
    preventSubmitDefault?: boolean;
    requiredMark?: boolean;
    resetType?: 'empty' | 'initial';
    rules?: {
        [field in keyof FormData]: Array<FormRule>;
    };
    scrollToFirstError?: '' | 'smooth' | 'auto';
    showErrorMessage?: boolean;
    statusIcon?: boolean | TNode<TdFormItemProps>;
    submitWithWarningMessage?: boolean;
    onReset?: (context: {
        e?: FormResetEvent;
    }) => void;
    onSubmit?: (context: SubmitContext<FormData>) => void;
    onValidate?: (result: ValidateResultContext<FormData>) => void;
}
export interface FormInstanceFunctions<FormData extends Data = Data> {
    clearValidate?: (fields?: Array<keyof FormData>) => void;
    reset?: (params?: FormResetParams<FormData>) => void;
    setValidateMessage?: (message: FormValidateMessage<FormData>) => void;
    submit?: (params?: {
        showErrorMessage?: boolean;
    }) => void;
    validate?: (params?: FormValidateParams) => Promise<FormValidateResult<FormData>>;
    validateOnly?: (params?: Pick<FormValidateParams, 'fields' | 'trigger'>) => Promise<FormValidateResult<FormData>>;
}
export interface TdFormItemProps {
    for?: string;
    help?: string | TNode;
    label?: string | TNode;
    labelAlign?: 'left' | 'right' | 'top';
    labelWidth?: string | number;
    name?: string | number;
    requiredMark?: boolean;
    rules?: Array<FormRule>;
    showErrorMessage?: boolean;
    statusIcon?: boolean | TNode;
    successBorder?: boolean;
}
export interface FormRule {
    boolean?: boolean;
    date?: boolean | IsDateOptions;
    email?: boolean | IsEmailOptions;
    enum?: Array<string>;
    idcard?: boolean;
    len?: number | boolean;
    max?: number | boolean;
    message?: string;
    min?: number | boolean;
    number?: boolean;
    pattern?: RegExp;
    required?: boolean;
    telnumber?: boolean;
    trigger?: 'change' | 'blur';
    type?: 'error' | 'warning';
    url?: boolean | IsURLOptions;
    validator?: CustomValidator;
}
export interface FormErrorMessage {
    boolean?: string;
    date?: string;
    enum?: string;
    idcard?: string;
    len?: string;
    max?: string;
    min?: string;
    number?: string;
    pattern?: string;
    required?: string;
    telnumber?: string;
    url?: string;
    validator?: string;
}
export interface SubmitContext<T extends Data = Data> {
    e?: FormSubmitEvent;
    validateResult: FormValidateResult<T>;
    firstError?: string;
}
export declare type FormValidateResult<T> = boolean | ValidateResultObj<T>;
export declare type ValidateResultObj<T> = {
    [key in keyof T]: boolean | ValidateResultList;
};
export declare type ValidateResultList = Array<AllValidateResult>;
export declare type AllValidateResult = CustomValidateObj | ValidateResultType;
export interface ValidateResultType extends FormRule {
    result: boolean;
}
export declare type ValidateResult<T> = {
    [key in keyof T]: boolean | ErrorList;
};
export declare type ErrorList = Array<FormRule>;
export declare type ValidateResultContext<T> = Omit<SubmitContext<T>, 'e'>;
export interface FormResetParams<FormData> {
    type?: 'initial' | 'empty';
    fields?: Array<keyof FormData>;
}
export declare type FormValidateMessage<FormData> = {
    [field in keyof FormData]: FormItemValidateMessage[];
};
export interface FormItemValidateMessage {
    type: 'warning' | 'error';
    message: string;
}
export interface FormValidateParams {
    fields?: Array<string>;
    showErrorMessage?: boolean;
    trigger?: ValidateTriggerType;
}
export declare type ValidateTriggerType = 'blur' | 'change' | 'all';
export declare type Data = {
    [key: string]: any;
};
export interface IsDateOptions {
    format: string;
    strictMode: boolean;
    delimiters: string[];
}
export declare type CustomValidator = (val: ValueType) => CustomValidateResolveType | Promise<CustomValidateResolveType>;
export declare type CustomValidateResolveType = boolean | CustomValidateObj;
export interface CustomValidateObj {
    result: boolean;
    message: string;
    type?: 'error' | 'warning' | 'success';
}
export declare type ValueType = any;
