react-sheet
Advanced tools
Comparing version 0.0.25 to 0.0.26
@@ -55,7 +55,5 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
data = _props.data, | ||
bodyHeight = _props.bodyHeight, | ||
rowHeight = _props.rowHeight, | ||
columns = _props.columns, | ||
selection = _props.selection, | ||
height = _props.height, | ||
className = _props.className, | ||
@@ -62,0 +60,0 @@ setSelection = _props.setSelection, |
@@ -183,2 +183,6 @@ 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; }; | ||
_this.onBlur = function () { | ||
_this.removeListeners(); | ||
}; | ||
_this.focus = function () { | ||
@@ -220,2 +224,22 @@ var _this$state$selection = _this.state.selection, | ||
_this.isVisible = function (elem) { | ||
return !!elem && !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length); | ||
}; | ||
_this.hideOnClickOutside = function (element) { | ||
var outsideClickListener = function outsideClickListener(event) { | ||
if (!element.contains(event.target)) { | ||
if (_this.isVisible(element)) { | ||
_this.removeListeners(); | ||
} | ||
} | ||
}; | ||
var removeClickListener = function removeClickListener() { | ||
document.removeEventListener('click', outsideClickListener); | ||
}; | ||
document.addEventListener('click', outsideClickListener); | ||
}; | ||
_this.state = { | ||
@@ -236,2 +260,3 @@ selection: { | ||
this.addListeners(); | ||
this.hideOnClickOutside(this.keyWrapper); | ||
}; | ||
@@ -256,12 +281,23 @@ | ||
return React.createElement(WrappedComponent, _extends({ | ||
ref: function ref(elem) { | ||
_this2.keyWrapper = elem; | ||
return React.createElement( | ||
'div', | ||
{ | ||
ref: function ref(elem) { | ||
return _this2.keyWrapper = elem; | ||
}, | ||
className: 'key-events', | ||
onClick: this.addListeners, | ||
onBlur: this.removeListeners | ||
}, | ||
focus: this.focus, | ||
selection: selection, | ||
onEnter: this.onEnter, | ||
focusedCell: focusedCell, | ||
setSelection: this.setSelection | ||
}, this.props)); | ||
React.createElement(WrappedComponent, _extends({ | ||
ref: function ref(elem) { | ||
_this2.keyWrapper = elem; | ||
}, | ||
focus: this.focus, | ||
selection: selection, | ||
onEnter: this.onEnter, | ||
focusedCell: focusedCell, | ||
setSelection: this.setSelection | ||
}, this.props)) | ||
); | ||
}; | ||
@@ -268,0 +304,0 @@ |
@@ -73,7 +73,5 @@ 'use strict'; | ||
data = _props.data, | ||
bodyHeight = _props.bodyHeight, | ||
rowHeight = _props.rowHeight, | ||
columns = _props.columns, | ||
selection = _props.selection, | ||
height = _props.height, | ||
className = _props.className, | ||
@@ -80,0 +78,0 @@ setSelection = _props.setSelection, |
@@ -198,2 +198,6 @@ 'use strict'; | ||
_this.onBlur = function () { | ||
_this.removeListeners(); | ||
}; | ||
_this.focus = function () { | ||
@@ -235,2 +239,22 @@ var _this$state$selection = _this.state.selection, | ||
_this.isVisible = function (elem) { | ||
return !!elem && !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length); | ||
}; | ||
_this.hideOnClickOutside = function (element) { | ||
var outsideClickListener = function outsideClickListener(event) { | ||
if (!element.contains(event.target)) { | ||
if (_this.isVisible(element)) { | ||
_this.removeListeners(); | ||
} | ||
} | ||
}; | ||
var removeClickListener = function removeClickListener() { | ||
document.removeEventListener('click', outsideClickListener); | ||
}; | ||
document.addEventListener('click', outsideClickListener); | ||
}; | ||
_this.state = { | ||
@@ -251,2 +275,3 @@ selection: { | ||
this.addListeners(); | ||
this.hideOnClickOutside(this.keyWrapper); | ||
}; | ||
@@ -271,12 +296,23 @@ | ||
return _react2.default.createElement(WrappedComponent, _extends({ | ||
ref: function ref(elem) { | ||
_this2.keyWrapper = elem; | ||
return _react2.default.createElement( | ||
'div', | ||
{ | ||
ref: function ref(elem) { | ||
return _this2.keyWrapper = elem; | ||
}, | ||
className: 'key-events', | ||
onClick: this.addListeners, | ||
onBlur: this.removeListeners | ||
}, | ||
focus: this.focus, | ||
selection: selection, | ||
onEnter: this.onEnter, | ||
focusedCell: focusedCell, | ||
setSelection: this.setSelection | ||
}, this.props)); | ||
_react2.default.createElement(WrappedComponent, _extends({ | ||
ref: function ref(elem) { | ||
_this2.keyWrapper = elem; | ||
}, | ||
focus: this.focus, | ||
selection: selection, | ||
onEnter: this.onEnter, | ||
focusedCell: focusedCell, | ||
setSelection: this.setSelection | ||
}, this.props)) | ||
); | ||
}; | ||
@@ -283,0 +319,0 @@ |
{ | ||
"name": "react-sheet", | ||
"version": "0.0.25", | ||
"version": "0.0.26", | ||
"description": "Spreadsheet component for react", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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 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
3175663
38250