1
- import { reactive , watch , nextTick } from '@vue/runtime-dom' ;
1
+ import { reactive , watch , nextTick , ExtractPropTypes } from '@vue/runtime-dom' ;
2
2
import cloneDeep from 'lodash-es/cloneDeep' ;
3
3
import intersection from 'lodash-es/intersection' ;
4
4
import isEqual from 'lodash-es/isEqual' ;
5
5
import debounce from 'lodash-es/debounce' ;
6
6
import omit from 'lodash-es/omit' ;
7
+ import { FormItemProps as formItemProps } from 'ant-design-vue/es/form/FormItem' ;
7
8
import { validateRules } from 'ant-design-vue/es/form/utils/validateUtil' ;
8
9
import { defaultValidateMessages } from 'ant-design-vue/es/form/utils/messages' ;
9
10
import { allPromiseFinish } from 'ant-design-vue/es/form/utils/asyncUtil' ;
@@ -16,6 +17,8 @@ interface DebounceSettings {
16
17
trailing ?: boolean ;
17
18
}
18
19
20
+ type FormItemProps = Partial < ExtractPropTypes < typeof formItemProps > > ;
21
+
19
22
function isRequired ( rules : any [ ] ) {
20
23
let isRequired = false ;
21
24
if ( rules && rules . length ) {
@@ -101,7 +104,7 @@ type namesType = string | string[];
101
104
export interface validateInfo {
102
105
autoLink ?: boolean ;
103
106
required ?: boolean ;
104
- validateStatus ?: 'validating' | 'error' | 'success' | null ;
107
+ validateStatus ?: FormItemProps [ 'validateStatus' ] ;
105
108
help ?: string ;
106
109
}
107
110
@@ -278,7 +281,12 @@ function useForm(
278
281
279
282
return returnPromise ;
280
283
} ;
281
- const validateField = < T extends unknown = any > ( name : string , value : any , rules : any , option : validateOptions ) : Promise < T > => {
284
+ const validateField = < T extends unknown = any > (
285
+ name : string ,
286
+ value : any ,
287
+ rules : any ,
288
+ option : validateOptions ,
289
+ ) : Promise < T > => {
282
290
const promise = validateRules (
283
291
[ name ] ,
284
292
value ,
@@ -301,7 +309,10 @@ function useForm(
301
309
return promise ;
302
310
} ;
303
311
304
- const validate = < T extends unknown = any > ( names ?: namesType , option ?: validateOptions ) : Promise < T > => {
312
+ const validate = < T extends unknown = any > (
313
+ names ?: namesType ,
314
+ option ?: validateOptions ,
315
+ ) : Promise < T > => {
305
316
let keys = [ ] ;
306
317
let strict = true ;
307
318
if ( ! names ) {
0 commit comments