@@ -7,18 +7,41 @@ import $ from 'jquery';
77
88export default class Checkbox extends Component {
99 static propTypes = {
10+ beforeChecked : PropTypes . func ,
11+ beforeDeterminate : PropTypes . func ,
12+ beforeIndeterminate : PropTypes . func ,
13+ beforeUnchecked : PropTypes . func ,
1014 className : PropTypes . string ,
1115 label : PropTypes . string ,
12- name : PropTypes . string ,
13- settings : PropTypes . object ,
16+ onChange : PropTypes . func ,
17+ onChecked : PropTypes . func ,
18+ onDeterminate : PropTypes . func ,
19+ onDisable : PropTypes . func ,
20+ onEnable : PropTypes . func ,
21+ onIndeterminate : PropTypes . func ,
22+ onUnchecked : PropTypes . func ,
1423 type : PropTypes . string ,
1524 } ;
1625
17- state = { checked : false } ;
26+ static defaultProps = {
27+ type : 'checkbox'
28+ } ;
1829
1930 componentDidMount ( ) {
2031 this . element = $ ( this . refs . element ) ;
21- // this.element.checkbox(this.props.settings);
32+ this . element . checkbox ( {
33+ onChange : this . props . onChange ,
34+ onChecked : this . props . onChecked ,
35+ onIndeterminate : this . props . onIndeterminate ,
36+ onDeterminate : this . props . onDeterminate ,
37+ onUnchecked : this . props . onUnchecked ,
38+ beforeChecked : this . props . beforeChecked ,
39+ beforeIndeterminate : this . props . beforeIndeterminate ,
40+ beforeDeterminate : this . props . beforeDeterminate ,
41+ beforeUnchecked : this . props . beforeUnchecked ,
42+ onEnable : this . props . onEnable ,
43+ onDisable : this . props . onDisable ,
44+ } ) ;
2245 }
2346
2447 componentWillUnmount ( ) {
@@ -32,16 +55,13 @@ export default class Checkbox extends Component {
3255 } ;
3356
3457 plugin ( ) {
35- this . element . checkbox ( ...arguments ) ;
58+ return this . element . checkbox ( ...arguments ) ;
3659 }
3760
3861 render ( ) {
3962 let type = this . props . type ;
40- if ( ! type ) {
41- type = 'checkbox' ;
42- if ( _ . includes ( this . props . className , 'radio' ) ) {
43- type = 'radio' ;
44- }
63+ if ( _ . includes ( this . props . className , 'radio' ) ) {
64+ type = 'radio' ;
4565 }
4666 const classes = classNames (
4767 'sd-checkbox' ,
0 commit comments