1
- import type { ExtractPropTypes , InjectionKey , PropType , Ref } from 'vue' ;
1
+ import type { ExtractPropTypes , InjectionKey , Ref } from 'vue' ;
2
2
import type { MouseEventHandler } from '../_util/EventInterface' ;
3
3
import type { VueNode } from '../_util/type' ;
4
4
import PropTypes from '../_util/vue-types' ;
5
+ import { booleanType , functionType , stringType , arrayType } from '../_util/type' ;
5
6
6
7
export type CheckboxValueType = string | number | boolean ;
7
8
export interface CheckboxOptionType {
@@ -27,10 +28,9 @@ export const abstractCheckboxGroupProps = () => {
27
28
return {
28
29
name : String ,
29
30
prefixCls : String ,
30
- options : {
31
- type : Array as PropType < Array < CheckboxOptionType | string | number > > ,
32
- default : ( ) => [ ] as Array < CheckboxOptionType | string | number > ,
33
- } ,
31
+ options : arrayType < Array < CheckboxOptionType | string | number > > (
32
+ [ ] as Array < CheckboxOptionType | string | number > ,
33
+ ) ,
34
34
disabled : Boolean ,
35
35
id : String ,
36
36
} ;
@@ -39,12 +39,10 @@ export const abstractCheckboxGroupProps = () => {
39
39
export const checkboxGroupProps = ( ) => {
40
40
return {
41
41
...abstractCheckboxGroupProps ( ) ,
42
- defaultValue : { type : Array as PropType < Array < CheckboxValueType > > } ,
43
- value : { type : Array as PropType < Array < CheckboxValueType > > } ,
44
- onChange : { type : Function as PropType < ( checkedValue : Array < CheckboxValueType > ) => void > } ,
45
- 'onUpdate:value' : {
46
- type : Function as PropType < ( checkedValue : Array < CheckboxValueType > ) => void > ,
47
- } ,
42
+ defaultValue : arrayType < Array < CheckboxValueType > > ( ) ,
43
+ value : arrayType < Array < CheckboxValueType > > ( ) ,
44
+ onChange : functionType < ( checkedValue : Array < CheckboxValueType > ) => void > ( ) ,
45
+ 'onUpdate:value' : functionType < ( checkedValue : Array < CheckboxValueType > ) => void > ( ) ,
48
46
} ;
49
47
} ;
50
48
@@ -53,27 +51,27 @@ export type CheckboxGroupProps = Partial<ExtractPropTypes<ReturnType<typeof chec
53
51
export const abstractCheckboxProps = ( ) => {
54
52
return {
55
53
prefixCls : String ,
56
- defaultChecked : { type : Boolean , default : undefined } ,
57
- checked : { type : Boolean , default : undefined } ,
58
- disabled : { type : Boolean , default : undefined } ,
59
- isGroup : { type : Boolean , default : undefined } ,
54
+ defaultChecked : booleanType ( ) ,
55
+ checked : booleanType ( ) ,
56
+ disabled : booleanType ( ) ,
57
+ isGroup : booleanType ( ) ,
60
58
value : PropTypes . any ,
61
59
name : String ,
62
60
id : String ,
63
- indeterminate : { type : Boolean , default : undefined } ,
64
- type : { type : String , default : 'checkbox' } ,
65
- autofocus : { type : Boolean , default : undefined } ,
66
- onChange : Function as PropType < ( e : CheckboxChangeEvent ) => void > ,
67
- 'onUpdate:checked' : Function as PropType < ( checked : boolean ) => void > ,
68
- onClick : Function as PropType < MouseEventHandler > ,
69
- skipGroup : { type : Boolean , default : false } ,
61
+ indeterminate : booleanType ( ) ,
62
+ type : stringType ( 'checkbox' ) ,
63
+ autofocus : booleanType ( ) ,
64
+ onChange : functionType < ( e : CheckboxChangeEvent ) => void > ( ) ,
65
+ 'onUpdate:checked' : functionType < ( checked : boolean ) => void > ( ) ,
66
+ onClick : functionType < MouseEventHandler > ( ) ,
67
+ skipGroup : booleanType ( false ) ,
70
68
} ;
71
69
} ;
72
70
73
71
export const checkboxProps = ( ) => {
74
72
return {
75
73
...abstractCheckboxProps ( ) ,
76
- indeterminate : { type : Boolean , default : false } ,
74
+ indeterminate : booleanType ( false ) ,
77
75
} ;
78
76
} ;
79
77
0 commit comments