Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rc-switch

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-switch - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

assets/index.less

47

lib/Switch.js

@@ -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"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc