1
+ import type { ExtractPropTypes } from 'vue' ;
1
2
import { defineComponent , inject , nextTick } from 'vue' ;
2
3
import PropTypes from '../_util/vue-types' ;
3
4
import classNames from '../_util/classNames' ;
@@ -9,11 +10,8 @@ import type { RadioChangeEvent } from '../radio/interface';
9
10
import type { EventHandler } from '../_util/EventInterface' ;
10
11
function noop ( ) { }
11
12
12
- export default defineComponent ( {
13
- name : 'ACheckbox' ,
14
- inheritAttrs : false ,
15
- __ANT_CHECKBOX : true ,
16
- props : {
13
+ export const checkboxProps = ( ) => {
14
+ return {
17
15
prefixCls : PropTypes . string ,
18
16
defaultChecked : PropTypes . looseBool ,
19
17
checked : PropTypes . looseBool ,
@@ -27,7 +25,17 @@ export default defineComponent({
27
25
autofocus : PropTypes . looseBool ,
28
26
onChange : PropTypes . func ,
29
27
'onUpdate:checked' : PropTypes . func ,
30
- } ,
28
+ skipGroup : PropTypes . looseBool ,
29
+ } ;
30
+ } ;
31
+
32
+ export type CheckboxProps = Partial < ExtractPropTypes < ReturnType < typeof checkboxProps > > > ;
33
+
34
+ export default defineComponent ( {
35
+ name : 'ACheckbox' ,
36
+ inheritAttrs : false ,
37
+ __ANT_CHECKBOX : true ,
38
+ props : checkboxProps ( ) ,
31
39
emits : [ 'change' , 'update:checked' ] ,
32
40
setup ( ) {
33
41
return {
@@ -38,6 +46,9 @@ export default defineComponent({
38
46
39
47
watch : {
40
48
value ( value , prevValue ) {
49
+ if ( this . skipGroup ) {
50
+ return ;
51
+ }
41
52
nextTick ( ( ) => {
42
53
const { checkboxGroupContext : checkboxGroup = { } } = this ;
43
54
if ( checkboxGroup . registerValue && checkboxGroup . cancelValue ) {
@@ -85,7 +96,7 @@ export default defineComponent({
85
96
const props = getOptionProps ( this ) ;
86
97
const { checkboxGroupContext : checkboxGroup , $attrs } = this ;
87
98
const children = getSlot ( this ) ;
88
- const { indeterminate, prefixCls : customizePrefixCls , ...restProps } = props ;
99
+ const { indeterminate, prefixCls : customizePrefixCls , skipGroup , ...restProps } = props ;
89
100
const getPrefixCls = this . configProvider . getPrefixCls ;
90
101
const prefixCls = getPrefixCls ( 'checkbox' , customizePrefixCls ) ;
91
102
const {
@@ -101,7 +112,7 @@ export default defineComponent({
101
112
prefixCls,
102
113
...restAttrs ,
103
114
} ;
104
- if ( checkboxGroup ) {
115
+ if ( checkboxGroup && ! skipGroup ) {
105
116
checkboxProps . onChange = ( ...args ) => {
106
117
this . $emit ( 'change' , ...args ) ;
107
118
checkboxGroup . toggleOption ( { label : children , value : props . value } ) ;
0 commit comments