chore: update form type (#2724)

* chore: update form type

* fix: form-item name type
This commit is contained in:
言肆 2020-08-19 21:46:01 +08:00 committed by GitHub
parent a60c0d37bc
commit 13b01d7a70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 94 additions and 57 deletions

View File

@ -10,6 +10,7 @@ export declare type InternalNamePath = (string | number)[];
export declare type NamePath = string | number | InternalNamePath;
export declare class FormItem extends AntdComponent {
$props: {
/**
* Used with label, whether to display : after label text.
* @default true
@ -21,7 +22,7 @@ export declare class FormItem extends AntdComponent {
* The extra prompt message. It is similar to help. Usage example: to display error message and prompt message at the same time.
* @type any (string | slot)
*/
extra?: any;
extra?: string | VNodeChild | JSX.Element;
/**
* Used with validateStatus, this option specifies the validation status icon. Recommended to be used only with Input.
@ -40,36 +41,60 @@ export declare class FormItem extends AntdComponent {
* Label test
* @type any (string | slot)
*/
label: string | VNodeChild | JSX.Element;
label?: string | VNodeChild | JSX.Element;
/**
* 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>
* @type Col
*/
labelCol: Col;
labelCol?: Col;
/**
* Whether provided or not, it will be generated by the validation rule.
* @default false
* @type boolean
*/
required: boolean;
required?: boolean;
/**
* The validation status. If not provided, it will be generated by validation rule. options: 'success' 'warning' 'error' 'validating'
* @type string
*/
validateStatus: '' | 'success' | 'warning' | 'error' | 'validating';
validateStatus?: '' | 'success' | 'warning' | 'error' | 'validating';
/**
* The layout for input controls, same as labelCol
* @type Col
*/
wrapperCol: Col;
labelAlign: 'left' | 'right';
name?: InternalNamePath;
rules: object | object[];
autoLink: boolean;
wrapperCol?: Col;
/**
* Set sub label htmlFor.
*/
htmlFor?: string;
/**
* text align of label
*/
labelAlign?: 'left' | 'right';
/**
* a key of model. In the use of validate and resetFields method, the attribute is required
*/
name?: NamePath;
/**
* validation rules of form
*/
rules?: object | object[];
/**
* Whether to automatically associate form fields. In most cases, you can use automatic association.
* If the conditions for automatic association are not met, you can manually associate them. See the notes below.
*/
autoLink?: boolean;
/**
* Whether stop validate on first rule of error for this field.
*/
validateFirst?: boolean;
/**
* When to validate the value of children node
*/
validateTrigger?: string | string[] | false;
};
}

18
types/form/form.d.ts vendored
View File

@ -5,7 +5,6 @@
import { AntdComponent } from '../component';
import { Col } from '../grid/col';
import { FormItem } from './form-item';
export { Options as ScrollOptions } from 'scroll-into-view-if-needed';
export declare type InternalNamePath = (string | number)[];
export declare type NamePath = string | number | InternalNamePath;
@ -232,8 +231,21 @@ export declare class Form extends AntdComponent {
scrollToFirstError?: boolean;
validateTrigger?: string | string[] | false;
onFinish?: (values: object) => void;
onFinishFailed?: (errorInfo: ValidateErrorEntity) => void;
/**
* Defines a function will be called if form data validation.
* @param e
*/
onSubmit?: (e?: Event) => void;
/**
* Trigger after submitting the form and verifying data successfully
* @param values
*/
onFinish?: (values?: object) => void;
/**
* Trigger after submitting the form and verifying data failed
* @param errorInfo
*/
onFinishFailed?: (errorInfo?: ValidateErrorEntity) => void;
};
/**
* clear validation message for certain fields.