nuke-switch
Advanced tools
Comparing version 0.1.2 to 0.1.3
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 @@ }, | ||
} | ||
} | ||
} |
27414
1
11
383
- Removedrax-switch@^0.3.7
- Removeddriver-browser@0.6.7(transitive)
- Removeddriver-server@0.6.5(transitive)
- Removeddriver-weex@0.6.5(transitive)
- Removedrax@0.6.7(transitive)
- Removedrax-switch@0.3.8(transitive)
- Removedstyle-unit@0.6.5(transitive)
- Removeduniversal-env@0.3.80.6.6(transitive)