rc-checkbox
Advanced tools
Comparing version 1.0.6 to 1.1.0
@@ -19,5 +19,5 @@ 'use strict'; | ||
if ('checked' in props) { | ||
checked = !!props.checked; | ||
checked = props.checked; | ||
} else { | ||
checked = !!props.defaultChecked; | ||
checked = props.defaultChecked; | ||
} | ||
@@ -34,3 +34,3 @@ return { | ||
className: '', | ||
defaultChecked: false, | ||
defaultChecked: 0, | ||
onChange: noop | ||
@@ -42,3 +42,3 @@ }; | ||
this.setState({ | ||
checked: !!nextProps.checked | ||
checked: nextProps.checked | ||
}); | ||
@@ -52,5 +52,9 @@ } | ||
var prefixCls = props.prefixCls; | ||
var checked = this.state.checked; | ||
if (typeof checked === 'boolean') { | ||
checked = checked ? 1 : 0; | ||
} | ||
return React.createElement( | ||
'span', | ||
{ className: classnames((_classnames = {}, _defineProperty(_classnames, props.className, !!props.className), _defineProperty(_classnames, prefixCls, 1), _defineProperty(_classnames, prefixCls + '-checked', this.state.checked), _defineProperty(_classnames, prefixCls + '-disabled', props.disabled), _classnames)), | ||
{ className: classnames((_classnames = {}, _defineProperty(_classnames, props.className, !!props.className), _defineProperty(_classnames, prefixCls, 1), _defineProperty(_classnames, prefixCls + '-checked', checked), _defineProperty(_classnames, prefixCls + '-checked-' + checked, !!checked), _defineProperty(_classnames, prefixCls + '-disabled', props.disabled), _classnames)), | ||
style: props.style | ||
@@ -61,3 +65,3 @@ }, | ||
className: prefixCls + '-input', | ||
checked: this.state.checked, | ||
checked: !!checked, | ||
onChange: this.handleChange | ||
@@ -71,6 +75,6 @@ })) | ||
this.setState({ | ||
checked: checked | ||
checked: checked ? 1 : 0 | ||
}); | ||
} | ||
this.props.onChange(e); | ||
this.props.onChange(e, this.state.checked); | ||
} | ||
@@ -77,0 +81,0 @@ }); |
{ | ||
"name": "rc-checkbox", | ||
"version": "1.0.6", | ||
"version": "1.1.0", | ||
"description": "checkbox ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -80,16 +80,16 @@ # rc-checkbox | ||
<td>checked</td> | ||
<td>enum: 0,1,2</td> | ||
<td></td> | ||
<td></td> | ||
<td>same with native input checkbox</td> | ||
</tr> | ||
<tr> | ||
<td>defaultChecked</td> | ||
<td></td> | ||
<td></td> | ||
<td>enum: 0,1,2</td> | ||
<td>0</td> | ||
<td>same with native input checkbox</td> | ||
<tr> | ||
<td>onChange</td> | ||
<td>Function(e:Event, checked:Number)</td> | ||
<td></td> | ||
<td></td> | ||
<td>same with native input checkbox</td> | ||
<td>called when checkbox is changed. e is native event, checked is original checked state.</td> | ||
</tr> | ||
@@ -96,0 +96,0 @@ </tbody> |
Sorry, the diff of this file is not supported yet
11176
232