riku
10 小时以前 8e3f3890e93d097df4be744648b9ac404d20a558
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import { IsEmailOptions } from 'validator/es/lib/isEmail';
import { IsURLOptions } from 'validator/es/lib/isURL';
export interface TdFormProps<FormData extends Data = Data> {
    colon?: {
        type: BooleanConstructor;
        value?: boolean;
    };
    data?: {
        type: ObjectConstructor;
        value?: FormData;
    };
    errorMessage?: {
        type: ObjectConstructor;
        value?: FormErrorMessage;
    };
    labelAlign?: {
        type: StringConstructor;
        value?: 'left' | 'right' | 'top';
    };
    labelWidth?: {
        type: null;
        value?: string | number;
    };
    requiredMark?: {
        type: BooleanConstructor;
        value?: boolean;
    };
    requiredMarkPosition?: {
        type: StringConstructor;
        value?: 'left' | 'right';
    };
    resetType?: {
        type: StringConstructor;
        value?: 'empty' | 'initial';
    };
    rules?: {
        type: ObjectConstructor;
        value?: FormRules<FormData>;
    };
    scrollToFirstError?: {
        type: StringConstructor;
        value?: '' | 'smooth' | 'auto';
    };
    showErrorMessage?: {
        type: BooleanConstructor;
        value?: boolean;
    };
    submitWithWarningMessage?: {
        type: BooleanConstructor;
        value?: boolean;
    };
}
export interface FormInstanceFunctions<FormData extends Data = Data> {
    clearValidate: {
        type: undefined;
        value?: (fields?: Array<keyof FormData>) => void;
        required?: boolean;
    };
    reset: {
        type: undefined;
        value?: (params?: FormResetParams<FormData>) => void;
        required?: boolean;
    };
    setValidateMessage: {
        type: undefined;
        value?: (message: FormValidateMessage<FormData>) => void;
        required?: boolean;
    };
    submit: {
        type: undefined;
        value?: (params?: {
            showErrorMessage?: boolean;
        }) => void;
        required?: boolean;
    };
    validate: {
        type: undefined;
        value?: (params?: FormValidateParams) => Promise<FormValidateResult<FormData>>;
        required?: 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 | string;
    required?: boolean;
    telnumber?: boolean;
    trigger?: ValidateTriggerType;
    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;
    whitespace?: string;
}
export declare type FormRules<T extends Data = any> = {
    [field in keyof T]?: Array<FormRule>;
};
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' | 'submit' | 'all';
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 Data = {
    [key: string]: any;
};
export interface IsDateOptions {
    format: string;
    strictMode: boolean;
    delimiters: string[];
}
export declare type CustomValidator = (val: ValueType, context?: {
    formData: Data;
    name: string;
}) => 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;