import type { IsEmailOptions } from 'validator/es/lib/isEmail';
import type { IsURLOptions } from 'validator/es/lib/isURL';
import type { FormResetEvent, FormSubmitEvent, LNode } from '../../common';
export interface TypeFormProps<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 | LNode<TypeFormItemProps>;
    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 TypeFormItemProps {
    for?: string;
    help?: string | LNode;
    label?: string | LNode;
    labelAlign?: 'left' | 'right' | 'top';
    labelWidth?: string | number;
    name?: string | number;
    requiredMark?: boolean;
    rules?: Array<FormRule>;
    showErrorMessage?: boolean;
    status?: 'error' | 'warning' | 'success' | 'validating';
    statusIcon?: boolean | LNode;
    successBorder?: boolean;
    tips?: string | LNode;
}
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;
    whitespace?: boolean;
}
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 type FormValidateResult<T> = boolean | ValidateResultObj<T>;
export type ValidateResultObj<T> = {
    [key in keyof T]: boolean | ValidateResultList;
};
export type ValidateResultList = Array<AllValidateResult>;
export type AllValidateResult = CustomValidateObj | ValidateResultType;
export interface ValidateResultType extends FormRule {
    result: boolean;
}
export type ValidateResult<T> = {
    [key in keyof T]: boolean | ErrorList;
};
export type ErrorList = Array<FormRule>;
export type ValidateResultContext<T> = Omit<SubmitContext<T>, 'e'>;
export interface FormResetParams<FormData> {
    type?: 'initial' | 'empty';
    fields?: Array<keyof FormData>;
}
export 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 type ValidateTriggerType = 'blur' | 'change' | 'all';
export interface Data {
    [key: string]: any;
}
export interface IsDateOptions {
    format: string;
    strictMode: boolean;
    delimiters: string[];
}
export type CustomValidator = (val: ValueType) => CustomValidateResolveType | Promise<CustomValidateResolveType>;
export type CustomValidateResolveType = boolean | CustomValidateObj;
export interface CustomValidateObj {
    result: boolean;
    message: string;
    type?: 'error' | 'warning' | 'success';
}
export type ValueType = any;
