rc-color-picker
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -0,1 +1,5 @@ | ||
## 1.2.2 | ||
- compatility react 16 [!50](https://github.com/react-component/color-picker/pull/50) | ||
## 1.2.1 | ||
@@ -2,0 +6,0 @@ |
@@ -71,3 +71,3 @@ 'use strict'; | ||
var events = ['onTriggerClick', 'onChange', 'onBlur', 'getPickerElement', 'getRootDOMNode', 'getTriggerDOMNode', 'onVisibleChange', 'setOpen', 'open', 'close', 'focus']; | ||
var events = ['onTriggerClick', 'onChange', 'onBlur', 'getPickerElement', 'getRootDOMNode', 'getTriggerDOMNode', 'onVisibleChange', 'onPanelMount', 'setOpen', 'open', 'close', 'focus']; | ||
@@ -78,3 +78,2 @@ events.forEach(function (e) { | ||
_this.savePickerPanelRef = refFn.bind(_this, 'pickerPanelInstance'); | ||
_this.saveTriggerRef = refFn.bind(_this, 'triggerInstance'); | ||
@@ -116,13 +115,13 @@ return _this; | ||
ColorPicker.prototype.onVisibleChange = function onVisibleChange(open) { | ||
var _this3 = this; | ||
this.setOpen(open); | ||
}; | ||
this.setOpen(open, function () { | ||
if (open) { | ||
(0, _reactDom.findDOMNode)(_this3.pickerPanelInstance).focus(); | ||
} | ||
}); | ||
ColorPicker.prototype.onPanelMount = function onPanelMount(panelDOMRef) { | ||
if (this.state.open) { | ||
panelDOMRef.focus(); | ||
} | ||
}; | ||
ColorPicker.prototype.setOpen = function setOpen(open, callback) { | ||
var _this4 = this; | ||
var _this3 = this; | ||
@@ -134,12 +133,12 @@ if (this.state.open !== open) { | ||
if (typeof callback === 'function') callback(); | ||
var _props = _this4.props, | ||
var _props = _this3.props, | ||
onOpen = _props.onOpen, | ||
onClose = _props.onClose; | ||
if (_this4.state.open) { | ||
onOpen(_this4.state); | ||
if (_this3.state.open) { | ||
onOpen(_this3.state); | ||
} else { | ||
onClose(_this4.state); | ||
onClose(_this3.state); | ||
} | ||
_this4.props.onChange(_this4.state); | ||
_this3.props.onChange(_this3.state); | ||
}); | ||
@@ -160,3 +159,3 @@ } | ||
return _react2["default"].createElement(_Panel2["default"], { | ||
ref: this.savePickerPanelRef, | ||
onMount: this.onPanelMount, | ||
defaultColor: this.state.color, | ||
@@ -209,3 +208,3 @@ alpha: this.state.alpha, | ||
ref: this.saveTriggerRef, | ||
unselectable: true, | ||
unselectable: 'unselectable', | ||
style: { | ||
@@ -212,0 +211,0 @@ backgroundColor: 'rgba(' + RGBA.join(',') + ')' |
@@ -82,2 +82,6 @@ 'use strict'; | ||
Panel.prototype.componentDidMount = function componentDidMount() { | ||
this.props.onMount(this.ref); | ||
}; | ||
Panel.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { | ||
@@ -111,3 +115,4 @@ if (nextProps.color) { | ||
Panel.prototype.render = function render() { | ||
var _cx; | ||
var _cx, | ||
_this2 = this; | ||
@@ -127,2 +132,5 @@ var _props = this.props, | ||
{ | ||
ref: function ref(_ref) { | ||
return _this2.ref = _ref; | ||
}, | ||
className: [prefixCls, this.props.className].join(' '), | ||
@@ -189,3 +197,3 @@ style: this.props.style, | ||
var _initialiseProps = function _initialiseProps() { | ||
var _this2 = this; | ||
var _this3 = this; | ||
@@ -195,3 +203,3 @@ this.onSystemColorPickerOpen = function (e) { | ||
if (e.target.type === 'color') { | ||
_this2.systemColorPickerOpen = true; | ||
_this3.systemColorPickerOpen = true; | ||
} | ||
@@ -201,7 +209,7 @@ }; | ||
this.onFocus = function () { | ||
if (_this2._blurTimer) { | ||
clearTimeout(_this2._blurTimer); | ||
_this2._blurTimer = null; | ||
if (_this3._blurTimer) { | ||
clearTimeout(_this3._blurTimer); | ||
_this3._blurTimer = null; | ||
} else { | ||
_this2.props.onFocus(); | ||
_this3.props.onFocus(); | ||
} | ||
@@ -211,13 +219,13 @@ }; | ||
this.onBlur = function () { | ||
if (_this2._blurTimer) { | ||
clearTimeout(_this2._blurTimer); | ||
if (_this3._blurTimer) { | ||
clearTimeout(_this3._blurTimer); | ||
} | ||
_this2._blurTimer = setTimeout(function () { | ||
_this3._blurTimer = setTimeout(function () { | ||
// if is system color picker open, then stop run blur | ||
if (_this2.systemColorPickerOpen) { | ||
_this2.systemColorPickerOpen = false; | ||
if (_this3.systemColorPickerOpen) { | ||
_this3.systemColorPickerOpen = false; | ||
return; | ||
} | ||
_this2.props.onBlur(); | ||
_this3.props.onBlur(); | ||
}, 100); | ||
@@ -227,11 +235,11 @@ }; | ||
this.handleAlphaChange = function (alpha) { | ||
var color = _this2.state.color; | ||
var color = _this3.state.color; | ||
color.alpha = alpha; | ||
_this2.setState({ | ||
_this3.setState({ | ||
alpha: alpha, | ||
color: color | ||
}); | ||
_this2.props.onChange({ | ||
_this3.props.onChange({ | ||
color: color.toHexString(), | ||
@@ -243,8 +251,8 @@ alpha: alpha | ||
this.handleChange = function (color) { | ||
var alpha = _this2.state.alpha; | ||
var alpha = _this3.state.alpha; | ||
color.alpha = alpha; | ||
_this2.setState({ color: color }); | ||
_this2.props.onChange({ | ||
_this3.setState({ color: color }); | ||
_this3.props.onChange({ | ||
color: color.toHexString(), | ||
@@ -270,2 +278,3 @@ alpha: color.alpha | ||
onFocus: _propTypes2["default"].func, | ||
onMount: _propTypes2["default"].func, | ||
prefixCls: _propTypes2["default"].string, | ||
@@ -284,2 +293,3 @@ style: _propTypes2["default"].object | ||
onFocus: noop, | ||
onMount: noop, | ||
prefixCls: 'rc-color-picker-panel', | ||
@@ -286,0 +296,0 @@ style: {} |
{ | ||
"name": "rc-color-picker", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "color-picker ui component for react", | ||
@@ -55,4 +55,4 @@ "main": "./lib/index.js", | ||
"rc-tools": "^5.10.1", | ||
"react": "15.x", | ||
"react-dom": "15.x" | ||
"react": "16.x", | ||
"react-dom": "16.x" | ||
}, | ||
@@ -67,4 +67,4 @@ "dependencies": { | ||
"peerDependencies": { | ||
"react": "15.x", | ||
"react-dom": "15.x" | ||
"react": "16.x", | ||
"react-dom": "16.x" | ||
}, | ||
@@ -71,0 +71,0 @@ "pre-commit": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
1888713
12272