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

rc-switch

Package Overview
Dependencies
Maintainers
2
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.2.2

70

lib/Switch.js

@@ -6,3 +6,3 @@ 'use strict';

var React = require('react');
var rcUtil = require('rc-util');
var classNames = require('classnames');

@@ -14,2 +14,22 @@ function noop() {}

propTypes: {
className: React.PropTypes.string,
prefixCls: React.PropTypes.string,
disabled: React.PropTypes.bool,
style: React.PropTypes.object,
checkedChildren: React.PropTypes.any,
unCheckedChildren: React.PropTypes.any,
onChange: React.PropTypes.func
},
getDefaultProps: function getDefaultProps() {
return {
prefixCls: 'rc-switch',
style: {},
checkedChildren: null,
unCheckedChildren: null,
className: '',
defaultChecked: false,
onChange: noop
};
},
getInitialState: function getInitialState() {

@@ -27,13 +47,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) {

@@ -46,26 +55,33 @@ 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 _classNames;
var props = this.props;
var prefixCls = props.prefixCls;
var _props = this.props;
var className = _props.className;
var prefixCls = _props.prefixCls;
var disabled = _props.disabled;
var style = _props.style;
var checkedChildren = _props.checkedChildren;
var unCheckedChildren = _props.unCheckedChildren;
var checked = this.state.checked;
var switchClassName = classNames((_classNames = {}, _defineProperty(_classNames, className, !!className), _defineProperty(_classNames, prefixCls, true), _defineProperty(_classNames, prefixCls + '-checked', checked), _defineProperty(_classNames, prefixCls + '-disabled', disabled), _classNames));
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)),
onClick: props.disabled ? noop : this.toggle,
style: props.style
},
{ className: switchClassName,
onClick: disabled ? noop : this.toggle,
style: style },
React.createElement(
'span',
{ className: prefixCls + '-inner' },
this.state.checked ? props.checkedChildren : props.unCheckedChildren
checked ? checkedChildren : unCheckedChildren
)
);
},
toggle: function toggle() {
var checked = !this.state.checked;
this.setState({
checked: checked
});
this.props.onChange(checked);
}

@@ -72,0 +88,0 @@ });

{
"name": "rc-switch",
"version": "1.2.1",
"version": "1.2.2",
"description": "switch ui component for react",

@@ -11,3 +11,3 @@ "keywords": [

],
"main":"lib/index",
"main": "lib/index",
"homepage": "http://github.com/react-component/switch",

@@ -27,26 +27,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.x",
"rc-server": "3.x",
"rc-tools": "3.x",
"react": "^0.13.0"
"rc-tools": "4.x",
"react": "^0.14.0",
"react-addons-test-utils": "~0.14.0",
"react-dom": "~0.14.0"
},
"precommit": [
"precommit"
"pre-commit": [
"lint"
],
"dependencies": {
"rc-util": "2.x"
"classnames": "^2.2.1"
}
}

Sorry, the diff of this file is not supported yet

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