Skip to content

Commit 13b01d7

Browse files
authored
chore: update form type (#2724)
* chore: update form type * fix: form-item name type
1 parent a60c0d3 commit 13b01d7

File tree

2 files changed

+94
-57
lines changed

2 files changed

+94
-57
lines changed

types/form/form-item.d.ts

Lines changed: 79 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -10,66 +10,91 @@ export declare type InternalNamePath = (string | number)[];
1010
export declare type NamePath = string | number | InternalNamePath;
1111

1212
export declare class FormItem extends AntdComponent {
13-
/**
14-
* Used with label, whether to display : after label text.
15-
* @default true
16-
* @type boolean
17-
*/
18-
colon?: boolean;
13+
$props: {
14+
/**
15+
* Used with label, whether to display : after label text.
16+
* @default true
17+
* @type boolean
18+
*/
19+
colon?: boolean;
1920

20-
/**
21-
* The extra prompt message. It is similar to help. Usage example: to display error message and prompt message at the same time.
22-
* @type any (string | slot)
23-
*/
24-
extra?: any;
21+
/**
22+
* The extra prompt message. It is similar to help. Usage example: to display error message and prompt message at the same time.
23+
* @type any (string | slot)
24+
*/
25+
extra?: string | VNodeChild | JSX.Element;
2526

26-
/**
27-
* Used with validateStatus, this option specifies the validation status icon. Recommended to be used only with Input.
28-
* @default false
29-
* @type boolean
30-
*/
31-
hasFeedback?: boolean;
27+
/**
28+
* Used with validateStatus, this option specifies the validation status icon. Recommended to be used only with Input.
29+
* @default false
30+
* @type boolean
31+
*/
32+
hasFeedback?: boolean;
3233

33-
/**
34-
* The prompt message. If not provided, the prompt message will be generated by the validation rule.
35-
* @type any (string | slot)
36-
*/
37-
help?: string | VNodeChild | JSX.Element;
34+
/**
35+
* The prompt message. If not provided, the prompt message will be generated by the validation rule.
36+
* @type any (string | slot)
37+
*/
38+
help?: string | VNodeChild | JSX.Element;
3839

39-
/**
40-
* Label test
41-
* @type any (string | slot)
42-
*/
43-
label: string | VNodeChild | JSX.Element;
40+
/**
41+
* Label test
42+
* @type any (string | slot)
43+
*/
44+
label?: string | VNodeChild | JSX.Element;
4445

45-
/**
46-
* The layout of label. You can set span offset to something like {span: 3, offset: 12} or sm: {span: 3, offset: 12} same as with <Col>
47-
* @type Col
48-
*/
49-
labelCol: Col;
46+
/**
47+
* The layout of label. You can set span offset to something like {span: 3, offset: 12} or sm: {span: 3, offset: 12} same as with <Col>
48+
* @type Col
49+
*/
50+
labelCol?: Col;
5051

51-
/**
52-
* Whether provided or not, it will be generated by the validation rule.
53-
* @default false
54-
* @type boolean
55-
*/
56-
required: boolean;
52+
/**
53+
* Whether provided or not, it will be generated by the validation rule.
54+
* @default false
55+
* @type boolean
56+
*/
57+
required?: boolean;
5758

58-
/**
59-
* The validation status. If not provided, it will be generated by validation rule. options: 'success' 'warning' 'error' 'validating'
60-
* @type string
61-
*/
62-
validateStatus: '' | 'success' | 'warning' | 'error' | 'validating';
59+
/**
60+
* The validation status. If not provided, it will be generated by validation rule. options: 'success' 'warning' 'error' 'validating'
61+
* @type string
62+
*/
63+
validateStatus?: '' | 'success' | 'warning' | 'error' | 'validating';
6364

64-
/**
65-
* The layout for input controls, same as labelCol
66-
* @type Col
67-
*/
68-
wrapperCol: Col;
69-
labelAlign: 'left' | 'right';
70-
name?: InternalNamePath;
71-
rules: object | object[];
72-
autoLink: boolean;
73-
validateFirst?: boolean;
74-
validateTrigger?: string | string[] | false;
65+
/**
66+
* The layout for input controls, same as labelCol
67+
* @type Col
68+
*/
69+
wrapperCol?: Col;
70+
/**
71+
* Set sub label htmlFor.
72+
*/
73+
htmlFor?: string;
74+
/**
75+
* text align of label
76+
*/
77+
labelAlign?: 'left' | 'right';
78+
/**
79+
* a key of model. In the use of validate and resetFields method, the attribute is required
80+
*/
81+
name?: NamePath;
82+
/**
83+
* validation rules of form
84+
*/
85+
rules?: object | object[];
86+
/**
87+
* Whether to automatically associate form fields. In most cases, you can use automatic association.
88+
* If the conditions for automatic association are not met, you can manually associate them. See the notes below.
89+
*/
90+
autoLink?: boolean;
91+
/**
92+
* Whether stop validate on first rule of error for this field.
93+
*/
94+
validateFirst?: boolean;
95+
/**
96+
* When to validate the value of children node
97+
*/
98+
validateTrigger?: string | string[] | false;
99+
};
75100
}

types/form/form.d.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import { AntdComponent } from '../component';
66
import { Col } from '../grid/col';
77
import { FormItem } from './form-item';
8-
export { Options as ScrollOptions } from 'scroll-into-view-if-needed';
98

109
export declare type InternalNamePath = (string | number)[];
1110
export declare type NamePath = string | number | InternalNamePath;
@@ -232,8 +231,21 @@ export declare class Form extends AntdComponent {
232231
scrollToFirstError?: boolean;
233232

234233
validateTrigger?: string | string[] | false;
235-
onFinish?: (values: object) => void;
236-
onFinishFailed?: (errorInfo: ValidateErrorEntity) => void;
234+
/**
235+
* Defines a function will be called if form data validation.
236+
* @param e
237+
*/
238+
onSubmit?: (e?: Event) => void;
239+
/**
240+
* Trigger after submitting the form and verifying data successfully
241+
* @param values
242+
*/
243+
onFinish?: (values?: object) => void;
244+
/**
245+
* Trigger after submitting the form and verifying data failed
246+
* @param errorInfo
247+
*/
248+
onFinishFailed?: (errorInfo?: ValidateErrorEntity) => void;
237249
};
238250
/**
239251
* clear validation message for certain fields.

0 commit comments

Comments
 (0)