Comparing version 1.4.1 to 1.4.2
'use strict'; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
@@ -17,6 +21,6 @@ | ||
disabled: React.PropTypes.bool, | ||
style: React.PropTypes.object, | ||
checkedChildren: React.PropTypes.any, | ||
unCheckedChildren: React.PropTypes.any, | ||
onChange: React.PropTypes.func | ||
onChange: React.PropTypes.func, | ||
onMouseUp: React.PropTypes.func | ||
}, | ||
@@ -26,3 +30,2 @@ getDefaultProps: function getDefaultProps() { | ||
prefixCls: 'rc-switch', | ||
style: {}, | ||
checkedChildren: null, | ||
@@ -74,2 +77,11 @@ unCheckedChildren: null, | ||
}, | ||
// Handle auto focus when click switch in Chrome | ||
handleMouseUp: function handleMouseUp(e) { | ||
if (this.refs.node) { | ||
this.refs.node.blur(); | ||
} | ||
if (this.props.onMouseUp) { | ||
this.props.onMouseUp(e); | ||
} | ||
}, | ||
render: function render() { | ||
@@ -82,6 +94,7 @@ var _classNames; | ||
var disabled = _props.disabled; | ||
var style = _props.style; | ||
var checkedChildren = _props.checkedChildren; | ||
var unCheckedChildren = _props.unCheckedChildren; | ||
var restProps = _objectWithoutProperties(_props, ['className', 'prefixCls', 'disabled', 'checkedChildren', 'unCheckedChildren']); | ||
var checked = this.state.checked; | ||
@@ -91,7 +104,9 @@ var switchClassName = classNames((_classNames = {}, _defineProperty(_classNames, className, !!className), _defineProperty(_classNames, prefixCls, true), _defineProperty(_classNames, prefixCls + '-checked', checked), _defineProperty(_classNames, prefixCls + '-disabled', disabled), _classNames)); | ||
'span', | ||
{ className: switchClassName, | ||
_extends({}, restProps, { | ||
className: switchClassName, | ||
tabIndex: '0', | ||
ref: 'node', | ||
onKeyDown: this.handleKeyDown, | ||
onClick: disabled ? noop : this.toggle, | ||
style: style }, | ||
onMouseUp: this.handleMouseUp }), | ||
React.createElement( | ||
@@ -98,0 +113,0 @@ 'span', |
{ | ||
"name": "rc-switch", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "switch ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
11144
245