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

nuke-switch

Package Overview
Dependencies
Maintainers
3
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuke-switch - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

docs/control.md

116

lib/index.js
/* @jsx createElement */
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});

@@ -15,5 +14,5 @@

var _raxSwitch = require('rax-switch');
var _switch = require('./view/switch');
var _raxSwitch2 = _interopRequireDefault(_raxSwitch);
var _switch2 = _interopRequireDefault(_switch);

@@ -31,74 +30,71 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var Switch = function (_Component) {
_inherits(Switch, _Component);
_inherits(Switch, _Component);
function Switch(props) {
_classCallCheck(this, Switch);
function Switch(props) {
_classCallCheck(this, Switch);
var _this = _possibleConstructorReturn(this, (Switch.__proto__ || Object.getPrototypeOf(Switch)).call(this, props));
var _this = _possibleConstructorReturn(this, (Switch.__proto__ || Object.getPrototypeOf(Switch)).call(this, props));
_initialiseProps.call(_this);
_initialiseProps.call(_this);
var checked = false;
if ('checked' in props) {
checked = props.checked;
} else {
checked = props.defaultChecked;
}
var checked = false;
if ('checked' in props) {
checked = props.checked;
} else {
checked = props.defaultChecked;
}
_this.state = {
checked: checked
};
return _this;
_this.state = {
checked: checked
};
return _this;
}
_createClass(Switch, [{
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
if ('checked' in nextProps) {
this.setState({ checked: nextProps.checked });
}
}
}, {
key: 'render',
value: function render() {
var checked = this.state.checked;
_createClass(Switch, [{
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
if ('checked' in nextProps) {
this.setState({ checked: nextProps.checked });
}
}
}, {
key: 'render',
value: function render() {
var checked = this.state.checked;
return (0, _rax.createElement)(_switch2.default, _extends({}, this.props, {
onValueChange: this.handleClick,
value: checked
}));
}
}]);
return (0, _rax.createElement)(_raxSwitch2.default, _extends({}, this.props, { onValueChange: this.handleClick, value: checked }));
}
}]);
return Switch;
return Switch;
}(_rax.Component);
Switch.defaultProps = {
onValueChange: noop,
size: 'medium',
defaultChecked: false,
defaultIndeterminate: false,
onTintColor: '#00e158',
thumbTintColor: '#fff',
tintColor: '#ffffff'
onValueChange: noop
};
var _initialiseProps = function _initialiseProps() {
var _this2 = this;
var _this2 = this;
this.handleClick = function (e) {
var _props = _this2.props,
_props$disabled = _props.disabled,
disabled = _props$disabled === undefined ? false : _props$disabled,
_props$onValueChange = _props.onValueChange,
onValueChange = _props$onValueChange === undefined ? function () {} : _props$onValueChange;
this.handleClick = function (e) {
var _props = _this2.props,
_props$disabled = _props.disabled,
disabled = _props$disabled === undefined ? false : _props$disabled,
_props$onValueChange = _props.onValueChange,
onValueChange = _props$onValueChange === undefined ? function () {} : _props$onValueChange;
if (disabled) {
return null;
}
var checked = !_this2.state.checked;
if (!('checked' in _this2.props)) {
_this2.setState({
checked: checked
});
}
onValueChange(checked, e);
};
if (disabled) {
return null;
}
var checked = !_this2.state.checked;
if (!('checked' in _this2.props)) {
_this2.setState({
checked: checked
});
}
onValueChange(checked, e);
};
};

@@ -105,0 +101,0 @@

{
"name": "nuke-switch",
"version": "0.1.2",
"version": "0.1.3",
"description": "开关",

@@ -47,3 +47,2 @@ "main": "lib/index",

"dependencies": {
"rax-switch": "^0.3.7",
"nuke-env": "^0.x.x"

@@ -59,2 +58,2 @@ },

}
}
}
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