Skip to content

Commit fc9836f

Browse files
committed
feat(form): add success validation type to setValidateMessage
1 parent ad0ef45 commit fc9836f

File tree

6 files changed

+32
-32
lines changed

6 files changed

+32
-32
lines changed

db/TDesign.db

0 Bytes
Binary file not shown.

packages/products/tdesign-vue-next/packages/components/common.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ export interface UploadDisplayDragEvents {
4141

4242
export type ImageEvent = Event;
4343

44-
/**
45-
* 通用全局类型
46-
* */
4744
export type PlainObject = { [key: string]: any };
4845

4946
export type OptionData = {
@@ -63,6 +60,9 @@ export type TreeOptionData<T = string | number> = {
6360
content?: string | TNode;
6461
} & PlainObject;
6562

63+
/**
64+
* 通用全局类型
65+
* */
6666
export type SizeEnum = 'small' | 'medium' | 'large';
6767

6868
export type ShapeEnum = 'circle' | 'round';

packages/products/tdesign-vue-next/packages/components/form/form.en-US.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
name | type | default | description | required
88
-- | -- | -- | -- | --
99
colon | Boolean | false | \- | N
10-
data | Object | {} | Typescript`FormData` | N
10+
data | Object | {} | Typescript: `FormData` | N
1111
disabled | Boolean | undefined | \- | N
12-
errorMessage | Object | - | Typescript`FormErrorMessage` | N
13-
formControlledComponents | Array | - | Typescript`Array<string>` | N
12+
errorMessage | Object | - | Typescript: `FormErrorMessage` | N
13+
formControlledComponents | Array | - | Typescript: `Array<string>` | N
1414
id | String | undefined | native id attribute of the form,which supports being used in conjunction with non-form buttons through the form attribute to trigger form events | N
1515
labelAlign | String | right | options: left/right/top | N
1616
labelWidth | String / Number | '100px' | \- | N
@@ -20,20 +20,20 @@ readonly | Boolean | undefined | \- | N
2020
requiredMark | Boolean | true | \- | N
2121
requiredMarkPosition | String | left | Display position of required symbols。options: left/right | N
2222
resetType | String | empty | options: empty/initial | N
23-
rules | Object | - | Typescript`FormRules<FormData>` `type FormRules<T extends Data = any> = { [field in keyof T]?: Array<FormRule> }`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/form/type.ts) | N
23+
rules | Object | - | Typescript: `FormRules<FormData>` `type FormRules<T extends Data = any> = { [field in keyof T]?: Array<FormRule> }`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/form/type.ts) | N
2424
scrollToFirstError | String | - | options: ''/smooth/auto | N
2525
showErrorMessage | Boolean | true | \- | N
26-
statusIcon | Boolean / Slot / Function | undefined | Typescript`boolean \| TNode<TdFormItemProps>`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
26+
statusIcon | Boolean / Slot / Function | undefined | Typescript: `boolean \| TNode<TdFormItemProps>`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
2727
submitWithWarningMessage | Boolean | false | \- | N
28-
onReset | Function | | Typescript`(context: { e?: FormResetEvent }) => void`<br/> | N
29-
onSubmit | Function | | Typescript`(context: SubmitContext<FormData>) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/form/type.ts)。<br/>`interface SubmitContext<T extends Data = Data> { e?: FormSubmitEvent; validateResult: FormValidateResult<T>; firstError?: string; fields?: any }`<br/><br/>`type FormValidateResult<T> = boolean \| ValidateResultObj<T>`<br/><br/>`type ValidateResultObj<T> = { [key in keyof T]: boolean \| ValidateResultList }`<br/><br/>`type ValidateResultList = Array<AllValidateResult>`<br/><br/>`type AllValidateResult = CustomValidateObj \| ValidateResultType`<br/><br/>`interface ValidateResultType extends FormRule { result: boolean }`<br/><br/>`type ValidateResult<T> = { [key in keyof T]: boolean \| ErrorList }`<br/><br/>`type ErrorList = Array<FormRule>`<br/> | N
30-
onValidate | Function | | Typescript`(result: ValidateResultContext<FormData>) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/form/type.ts)。<br/>`type ValidateResultContext<T extends Data> = Omit<SubmitContext<T>, 'e'>`<br/> | N
28+
onReset | Function | | Typescript: `(context: { e?: FormResetEvent }) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
29+
onSubmit | Function | | Typescript: `(context: SubmitContext<FormData>) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/form/type.ts)。<br/>`interface SubmitContext<T extends Data = Data> { e?: FormSubmitEvent; validateResult: FormValidateResult<T>; firstError?: string; fields?: any }`<br/><br/>`type FormValidateResult<T> = boolean \| ValidateResultObj<T>`<br/><br/>`type ValidateResultObj<T> = { [key in keyof T]: boolean \| ValidateResultList }`<br/><br/>`type ValidateResultList = Array<AllValidateResult>`<br/><br/>`type AllValidateResult = CustomValidateObj \| ValidateResultType`<br/><br/>`interface ValidateResultType extends FormRule { result: boolean }`<br/><br/>`type ValidateResult<T> = { [key in keyof T]: boolean \| ErrorList }`<br/><br/>`type ErrorList = Array<FormRule>`<br/> | N
30+
onValidate | Function | | Typescript: `(result: ValidateResultContext<FormData>) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/form/type.ts)。<br/>`type ValidateResultContext<T extends Data> = Omit<SubmitContext<T>, 'e'>`<br/> | N
3131

3232
### Form Events
3333

3434
name | params | description
3535
-- | -- | --
36-
reset | `(context: { e?: FormResetEvent })` | \-
36+
reset | `(context: { e?: FormResetEvent })` | [see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts)
3737
submit | `(context: SubmitContext<FormData>)` | [see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/form/type.ts)。<br/>`interface SubmitContext<T extends Data = Data> { e?: FormSubmitEvent; validateResult: FormValidateResult<T>; firstError?: string; fields?: any }`<br/><br/>`type FormValidateResult<T> = boolean \| ValidateResultObj<T>`<br/><br/>`type ValidateResultObj<T> = { [key in keyof T]: boolean \| ValidateResultList }`<br/><br/>`type ValidateResultList = Array<AllValidateResult>`<br/><br/>`type AllValidateResult = CustomValidateObj \| ValidateResultType`<br/><br/>`interface ValidateResultType extends FormRule { result: boolean }`<br/><br/>`type ValidateResult<T> = { [key in keyof T]: boolean \| ErrorList }`<br/><br/>`type ErrorList = Array<FormRule>`<br/>
3838
validate | `(result: ValidateResultContext<FormData>)` | [see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/form/type.ts)。<br/>`type ValidateResultContext<T extends Data> = Omit<SubmitContext<T>, 'e'>`<br/>
3939

@@ -43,7 +43,7 @@ name | params | return | description
4343
-- | -- | -- | --
4444
clearValidate | `(fields?: Array<keyof FormData>)` | \- | required
4545
reset | `(params?: FormResetParams<FormData>)` | \- | required。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/form/type.ts)。<br/>`interface FormResetParams<FormData> { type?: 'initial' \| 'empty'; fields?: Array<keyof FormData> }`<br/>
46-
setValidateMessage | `(message: FormValidateMessage<FormData>)` | \- | required。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/form/type.ts)。<br/>`type FormValidateMessage<FormData> = { [field in keyof FormData]: FormItemValidateMessage[] }`<br/><br/>`interface FormItemValidateMessage { type: 'warning' \| 'error'; message: string }`<br/>
46+
setValidateMessage | `(message: FormValidateMessage<FormData>)` | \- | required。Sets custom validation results, such as directly displaying remote validation messages. Note: This method must be called after the component is mounted. `FormData` refers to the generic type of form data。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/form/type.ts)。<br/>`type FormValidateMessage<FormData> = { [field in keyof FormData]: FormItemValidateMessage[] }`<br/><br/>`interface FormItemValidateMessage { type: 'warning' \| 'error' \| 'success'; message: string }`<br/>
4747
submit | `(params?: { showErrorMessage?: boolean })` | \- | required
4848
validate | `(params?: FormValidateParams)` | `Promise<FormValidateResult<FormData>>` | required。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/form/type.ts)。<br/>`interface FormValidateParams { fields?: Array<string>; showErrorMessage?: boolean; trigger?: ValidateTriggerType }`<br/><br/>`type ValidateTriggerType = 'blur' \| 'change' \| 'submit' \| 'all'`<br/>
4949
validateOnly | `(params?: Pick<FormValidateParams, 'fields' \| 'trigger'>)` | `Promise<FormValidateResult<FormData>>` | required
@@ -54,40 +54,40 @@ validateOnly | `(params?: Pick<FormValidateParams, 'fields' \| 'trigger'>)` | `P
5454
name | type | default | description | required
5555
-- | -- | -- | -- | --
5656
for | String | - | \- | N
57-
help | String / Slot / Function | - | Typescript`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
58-
label | String / Slot / Function | '' | Typescript`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
57+
help | String / Slot / Function | - | Typescript: `string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
58+
label | String / Slot / Function | '' | Typescript: `string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
5959
labelAlign | String | - | options: left/right/top | N
6060
labelWidth | String / Number | - | \- | N
6161
name | String | - | \- | N
6262
requiredMark | Boolean | undefined | \- | N
63-
rules | Array | - | Typescript`Array<FormRule>` | N
63+
rules | Array | - | Typescript: `Array<FormRule>` | N
6464
showErrorMessage | Boolean | undefined | \- | N
65-
status | String | - | Typescript`'error' \| 'warning' \| 'success' \| 'validating'` | N
66-
statusIcon | Boolean / Slot / Function | undefined | Typescript`boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
65+
status | String | - | Typescript: `'error' \| 'warning' \| 'success' \| 'validating'` | N
66+
statusIcon | Boolean / Slot / Function | undefined | Typescript: `boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
6767
successBorder | Boolean | false | \- | N
68-
tips | String / Slot / Function | - | Typescript`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
68+
tips | String / Slot / Function | - | Typescript: `string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
6969

7070
### FormRule
7171

7272
name | type | default | description | required
7373
-- | -- | -- | -- | --
7474
boolean | Boolean | - | \- | N
75-
date | Boolean / Object | - | Typescript`boolean \| IsDateOptions` `interface IsDateOptions { format: string; strictMode: boolean; delimiters: string[] }`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/form/type.ts) | N
76-
email | Boolean / Object | - | Typescript`boolean \| IsEmailOptions` `import { IsEmailOptions } from 'validator/es/lib/isEmail'`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/form/type.ts) | N
77-
enum | Array | - | Typescript`Array<string>` | N
75+
date | Boolean / Object | - | Typescript: `boolean \| IsDateOptions` `interface IsDateOptions { format: string; strictMode: boolean; delimiters: string[] }`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/form/type.ts) | N
76+
email | Boolean / Object | - | Typescript: `boolean \| IsEmailOptions` `import { IsEmailOptions } from 'validator/es/lib/isEmail'`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/form/type.ts) | N
77+
enum | Array | - | Typescript: `Array<string>` | N
7878
idcard | Boolean | - | \- | N
7979
len | Number / Boolean | - | \- | N
8080
max | Number / Boolean | - | \- | N
8181
message | String | - | \- | N
8282
min | Number / Boolean | - | \- | N
8383
number | Boolean | - | \- | N
84-
pattern | String / Object | - | Typescript`RegExp \| string` | N
84+
pattern | String / Object | - | Typescript: `RegExp \| string` | N
8585
required | Boolean | - | \- | N
8686
telnumber | Boolean | - | \- | N
87-
trigger | String | change | Typescript`ValidateTriggerType` | N
87+
trigger | String | change | Typescript: `ValidateTriggerType` | N
8888
type | String | error | options: error/warning | N
89-
url | Boolean / Object | - | Typescript`boolean \| IsURLOptions` `import { IsURLOptions } from 'validator/es/lib/isURL'`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/form/type.ts) | N
90-
validator | Function | - | Typescript`CustomValidator` `type CustomValidator = (val: ValueType) => CustomValidateResolveType \| Promise<CustomValidateResolveType>` `type CustomValidateResolveType = boolean \| CustomValidateObj` `interface CustomValidateObj { result: boolean; message: string; type?: 'error' \| 'warning' \| 'success' }` `type ValueType = any`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/form/type.ts) | N
89+
url | Boolean / Object | - | Typescript: `boolean \| IsURLOptions` `import { IsURLOptions } from 'validator/es/lib/isURL'`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/form/type.ts) | N
90+
validator | Function | - | Typescript: `CustomValidator` `type CustomValidator = (val: ValueType) => CustomValidateResolveType \| Promise<CustomValidateResolveType>` `type CustomValidateResolveType = boolean \| CustomValidateObj` `interface CustomValidateObj { result: boolean; message: string; type?: 'error' \| 'warning' \| 'success' }` `type ValueType = any`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/form/type.ts) | N
9191
whitespace | Boolean | - | \- | N
9292

9393
### FormErrorMessage

0 commit comments

Comments
 (0)