Comparing version 1.2.1 to 1.3.0
@@ -13,2 +13,16 @@ 'use strict'; | ||
propTypes: { | ||
onChange: React.PropTypes.func | ||
}, | ||
getDefaultProps: function getDefaultProps() { | ||
return { | ||
prefixCls: 'rc-switch', | ||
style: {}, | ||
checkedChildren: null, | ||
unCheckedChildren: null, | ||
className: '', | ||
defaultChecked: false, | ||
onChange: noop | ||
}; | ||
}, | ||
getInitialState: function getInitialState() { | ||
@@ -26,13 +40,2 @@ var props = this.props; | ||
}, | ||
getDefaultProps: function getDefaultProps() { | ||
return { | ||
prefixCls: 'rc-switch', | ||
style: {}, | ||
checkedChildren: null, | ||
unCheckedChildren: null, | ||
className: '', | ||
defaultChecked: false, | ||
onChange: noop | ||
}; | ||
}, | ||
componentWillReceiveProps: function componentWillReceiveProps(nextProps) { | ||
@@ -45,13 +48,20 @@ if ('checked' in nextProps) { | ||
}, | ||
toggle: function toggle() { | ||
var checked = !this.state.checked; | ||
this.setState({ | ||
checked: checked | ||
}); | ||
this.props.onChange(checked); | ||
}, | ||
render: function render() { | ||
var _rcUtil$classSet; | ||
var _classes; | ||
var props = this.props; | ||
var prefixCls = props.prefixCls; | ||
var classes = (_classes = {}, _defineProperty(_classes, props.className, !!props.className), _defineProperty(_classes, prefixCls, 1), _defineProperty(_classes, prefixCls + '-checked', this.state.checked), _defineProperty(_classes, prefixCls + '-disabled', props.disabled), _classes); | ||
return React.createElement( | ||
'span', | ||
{ className: rcUtil.classSet((_rcUtil$classSet = {}, _defineProperty(_rcUtil$classSet, props.className, !!props.className), _defineProperty(_rcUtil$classSet, prefixCls, 1), _defineProperty(_rcUtil$classSet, prefixCls + '-checked', this.state.checked), _defineProperty(_rcUtil$classSet, prefixCls + '-disabled', props.disabled), _rcUtil$classSet)), | ||
{ className: rcUtil.classSet(classes), | ||
onClick: props.disabled ? noop : this.toggle, | ||
style: props.style | ||
}, | ||
style: props.style }, | ||
React.createElement( | ||
@@ -63,9 +73,2 @@ 'span', | ||
); | ||
}, | ||
toggle: function toggle() { | ||
var checked = !this.state.checked; | ||
this.setState({ | ||
checked: checked | ||
}); | ||
this.props.onChange(checked); | ||
} | ||
@@ -72,0 +75,0 @@ }); |
{ | ||
"name": "rc-switch", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "switch ui component for react", | ||
@@ -11,3 +11,7 @@ "keywords": [ | ||
], | ||
"main":"lib/index", | ||
"main": "lib/index", | ||
"files": [ | ||
"lib", | ||
"assets" | ||
], | ||
"homepage": "http://github.com/react-component/switch", | ||
@@ -27,26 +31,26 @@ "repository": { | ||
"build": "rc-tools run build", | ||
"precommit": "rc-tools run precommit", | ||
"less": "rc-tools run less", | ||
"gh-pages": "rc-tools run gh-pages", | ||
"history": "rc-tools run history", | ||
"start": "node --harmony node_modules/.bin/rc-server", | ||
"publish": "rc-tools run tag", | ||
"start": "rc-server", | ||
"pub": "rc-tools run pub", | ||
"lint": "rc-tools run lint", | ||
"saucelabs": "node --harmony node_modules/.bin/rc-tools run saucelabs", | ||
"browser-test": "node --harmony node_modules/.bin/rc-tools run browser-test", | ||
"browser-test-cover": "node --harmony node_modules/.bin/rc-tools run browser-test-cover" | ||
"karma": "rc-tools run karma", | ||
"saucelabs": "rc-tools run saucelabs", | ||
"browser-test": "rc-tools run browser-test", | ||
"browser-test-cover": "rc-tools run browser-test-cover" | ||
}, | ||
"devDependencies": { | ||
"expect.js": "~0.3.1", | ||
"precommit-hook": "^1.0.7", | ||
"pre-commit": "^1.0.7", | ||
"rc-server": "3.x", | ||
"rc-tools": "3.x", | ||
"react": "^0.13.0" | ||
"rc-tools": "4.x", | ||
"react-addons-test-utils": "^0.14.0", | ||
"react": "0.14.x", | ||
"react-dom": "0.14.x" | ||
}, | ||
"precommit": [ | ||
"precommit" | ||
"pre-commit": [ | ||
"lint" | ||
], | ||
"dependencies": { | ||
"rc-util": "2.x" | ||
"rc-util": "3.x" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11452
7
205
7
+ Addedlodash._getnative@3.9.1(transitive)
+ Addedlodash.isarguments@3.1.0(transitive)
+ Addedlodash.isarray@3.0.4(transitive)
+ Addedlodash.keys@3.1.2(transitive)
+ Addedrc-util@3.4.1(transitive)
+ Addedshallowequal@0.2.2(transitive)
- Removedrc-util@2.1.1(transitive)
Updatedrc-util@3.x