@@ -14,32 +14,37 @@ function Group(props) {
1414
1515 let checkedValue = value ? [ ...value ] : value ;
1616
17- const group = Children . map ( children , ( child ) => cloneElement ( child , {
18- disabled : disabled === undefined ? child . props . disabled : disabled ,
19-
20- checked :
21- checkedValue === undefined
22- ? undefined
23- : checkedValue . indexOf ( child . props . value ) > - 1 ,
24-
25- onChange ( checked , val ) {
26- if ( checkedValue === undefined ) {
27- checkedValue = [ ] ;
28- }
29-
30- const index = checkedValue . indexOf ( val ) ;
31-
32- if ( index > - 1 && ! checked ) {
33- checkedValue . splice ( index , 1 ) ;
34- }
35-
36- if ( index === - 1 && checked ) {
37- checkedValue . push ( val ) ;
38- }
39-
40- onChange ( checkedValue ) ;
41- } ,
42- } ) ) ;
17+ const group = Children . map ( children , ( child ) => {
18+ if ( child && child . type && [ 'Checkbox' , 'ComplexCheckbox' ] . includes ( child . type . displayName ) ) {
19+ return cloneElement ( child , {
20+ disabled : disabled === undefined ? child . props . disabled : disabled ,
21+
22+ checked :
23+ checkedValue === undefined
24+ ? undefined
25+ : checkedValue . indexOf ( child . props . value ) > - 1 ,
26+
27+ onChange ( checked , val ) {
28+ if ( checkedValue === undefined ) {
29+ checkedValue = [ ] ;
30+ }
31+
32+ const index = checkedValue . indexOf ( val ) ;
33+
34+ if ( index > - 1 && ! checked ) {
35+ checkedValue . splice ( index , 1 ) ;
36+ }
37+
38+ if ( index === - 1 && checked ) {
39+ checkedValue . push ( val ) ;
40+ }
41+
42+ onChange ( checkedValue ) ;
43+ } ,
44+ } ) ;
45+ }
46+ return child ;
47+ } ) ;
4348
4449 const classes = classNames ( `${ classSelector } -group` , {
4550 vertical : layout === 'v' ,
@@ -159,4 +164,6 @@ class Checkbox extends React.Component {
159164 }
160165}
161166
167+ Checkbox . displayName = 'Checkbox' ;
168+
162169export default Checkbox ;
0 commit comments