@@ -4,7 +4,7 @@ import VcCheckbox from '../vc-checkbox/Checkbox';
4
4
import { flattenChildren } from '../_util/props-util' ;
5
5
import warning from '../_util/warning' ;
6
6
import type { EventHandler } from '../_util/EventInterface' ;
7
- import { useInjectFormItemContext } from '../form/FormItemContext' ;
7
+ import { FormItemInputContext , useInjectFormItemContext } from '../form/FormItemContext' ;
8
8
import useConfigInject from '../_util/hooks/useConfigInject' ;
9
9
10
10
import type { CheckboxChangeEvent , CheckboxProps } from './interface' ;
@@ -18,6 +18,7 @@ export default defineComponent({
18
18
// emits: ['change', 'update:checked'],
19
19
setup ( props , { emit, attrs, slots, expose } ) {
20
20
const formItemContext = useInjectFormItemContext ( ) ;
21
+ const formItemInputContext = FormItemInputContext . useInject ( ) ;
21
22
const { prefixCls, direction } = useConfigInject ( 'checkbox' , props ) ;
22
23
const checkboxGroup = inject ( CheckboxGroupContextKey , undefined ) ;
23
24
const uniId = Symbol ( 'checkboxUniId' ) ;
@@ -84,20 +85,27 @@ export default defineComponent({
84
85
[ `${ prefixCls . value } -rtl` ] : direction . value === 'rtl' ,
85
86
[ `${ prefixCls . value } -wrapper-checked` ] : checkboxProps . checked ,
86
87
[ `${ prefixCls . value } -wrapper-disabled` ] : checkboxProps . disabled ,
88
+ [ `${ prefixCls . value } -wrapper-in-form-item` ] : formItemInputContext . isFormItemInput ,
87
89
} ,
88
90
className ,
89
91
) ;
90
92
const checkboxClass = classNames ( {
91
93
[ `${ prefixCls . value } -indeterminate` ] : indeterminate ,
92
94
} ) ;
95
+ const ariaChecked = indeterminate ? 'mixed' : undefined ;
93
96
return (
94
97
< label
95
98
class = { classString }
96
99
style = { style }
97
100
onMouseenter = { onMouseenter as EventHandler }
98
101
onMouseleave = { onMouseleave as EventHandler }
99
102
>
100
- < VcCheckbox { ...checkboxProps } class = { checkboxClass } ref = { checkboxRef } />
103
+ < VcCheckbox
104
+ aria-checked = { ariaChecked }
105
+ { ...checkboxProps }
106
+ class = { checkboxClass }
107
+ ref = { checkboxRef }
108
+ />
101
109
{ children . length ? < span > { children } </ span > : null }
102
110
</ label >
103
111
) ;
0 commit comments