react-base-table
Advanced tools
Comparing version 1.6.3 to 1.6.4
@@ -5,2 +5,6 @@ # CHANGELOG | ||
## v1.6.4 (2019-07-09) | ||
- fix: content been selected when dragging on IE/FF (regression from #56) | ||
## v1.6.3 (2019-07-09) | ||
@@ -7,0 +11,0 @@ |
@@ -8,4 +8,32 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
import PropTypes from 'prop-types'; | ||
import { noop } from './utils'; | ||
var INVALID_VALUE = null; | ||
import { noop, addClassName, removeClassName } from './utils'; | ||
var INVALID_VALUE = null; // copied from https://github.com/mzabriskie/react-draggable/blob/master/lib/utils/domFns.js | ||
export function addUserSelectStyles(doc) { | ||
if (!doc) return; | ||
var styleEl = doc.getElementById('react-draggable-style-el'); | ||
if (!styleEl) { | ||
styleEl = doc.createElement('style'); | ||
styleEl.type = 'text/css'; | ||
styleEl.id = 'react-draggable-style-el'; | ||
styleEl.innerHTML = '.react-draggable-transparent-selection *::-moz-selection {background: transparent;}\n'; | ||
styleEl.innerHTML += '.react-draggable-transparent-selection *::selection {background: transparent;}\n'; | ||
doc.getElementsByTagName('head')[0].appendChild(styleEl); | ||
} | ||
if (doc.body) addClassName(doc.body, 'react-draggable-transparent-selection'); | ||
} | ||
export function removeUserSelectStyles(doc) { | ||
try { | ||
if (doc && doc.body) removeClassName(doc.body, 'react-draggable-transparent-selection'); | ||
if (doc.selection) { | ||
doc.selection.empty(); | ||
} else { | ||
window.getSelection().removeAllRanges(); // remove selection caused by scroll | ||
} | ||
} catch (e) {// probably IE | ||
} | ||
} | ||
/** | ||
@@ -42,2 +70,3 @@ * ColumnResizer for BaseTable | ||
ownerDocument.addEventListener('mouseup', this._handleMouseUp); | ||
removeUserSelectStyles(ownerDocument); | ||
} | ||
@@ -88,2 +117,3 @@ }; | ||
var ownerDocument = this.handleRef.ownerDocument; | ||
addUserSelectStyles(ownerDocument); | ||
ownerDocument.addEventListener('mousemove', this._handleMouseMove); | ||
@@ -98,2 +128,3 @@ ownerDocument.addEventListener('mouseup', this._handleMouseUp); | ||
var ownerDocument = this.handleRef.ownerDocument; | ||
removeUserSelectStyles(ownerDocument); | ||
ownerDocument.removeEventListener('mousemove', this._handleMouseMove); | ||
@@ -100,0 +131,0 @@ ownerDocument.addEventListener('mouseup', this._handleMouseUp); |
@@ -238,2 +238,18 @@ import _objectSpread from "@babel/runtime/helpers/objectSpread"; | ||
} | ||
export function addClassName(el, className) { | ||
if (el.classList) { | ||
el.classList.add(className); | ||
} else { | ||
if (!el.className.match(new RegExp("(?:^|\\s)" + className + "(?!\\S)"))) { | ||
el.className += " " + className; | ||
} | ||
} | ||
} | ||
export function removeClassName(el, className) { | ||
if (el.classList) { | ||
el.classList.remove(className); | ||
} else { | ||
el.className = el.className.replace(new RegExp("(?:^|\\s)" + className + "(?!\\S)", 'g'), ''); | ||
} | ||
} | ||
//# sourceMappingURL=utils.js.map |
@@ -8,2 +8,4 @@ "use strict"; | ||
}); | ||
exports.addUserSelectStyles = addUserSelectStyles; | ||
exports.removeUserSelectStyles = removeUserSelectStyles; | ||
exports["default"] = void 0; | ||
@@ -35,3 +37,32 @@ | ||
var INVALID_VALUE = null; | ||
var INVALID_VALUE = null; // copied from https://github.com/mzabriskie/react-draggable/blob/master/lib/utils/domFns.js | ||
function addUserSelectStyles(doc) { | ||
if (!doc) return; | ||
var styleEl = doc.getElementById('react-draggable-style-el'); | ||
if (!styleEl) { | ||
styleEl = doc.createElement('style'); | ||
styleEl.type = 'text/css'; | ||
styleEl.id = 'react-draggable-style-el'; | ||
styleEl.innerHTML = '.react-draggable-transparent-selection *::-moz-selection {background: transparent;}\n'; | ||
styleEl.innerHTML += '.react-draggable-transparent-selection *::selection {background: transparent;}\n'; | ||
doc.getElementsByTagName('head')[0].appendChild(styleEl); | ||
} | ||
if (doc.body) (0, _utils.addClassName)(doc.body, 'react-draggable-transparent-selection'); | ||
} | ||
function removeUserSelectStyles(doc) { | ||
try { | ||
if (doc && doc.body) (0, _utils.removeClassName)(doc.body, 'react-draggable-transparent-selection'); | ||
if (doc.selection) { | ||
doc.selection.empty(); | ||
} else { | ||
window.getSelection().removeAllRanges(); // remove selection caused by scroll | ||
} | ||
} catch (e) {// probably IE | ||
} | ||
} | ||
/** | ||
@@ -41,2 +72,3 @@ * ColumnResizer for BaseTable | ||
var ColumnResizer = | ||
@@ -70,2 +102,3 @@ /*#__PURE__*/ | ||
ownerDocument.addEventListener('mouseup', this._handleMouseUp); | ||
removeUserSelectStyles(ownerDocument); | ||
} | ||
@@ -119,2 +152,3 @@ } | ||
var ownerDocument = this.handleRef.ownerDocument; | ||
addUserSelectStyles(ownerDocument); | ||
ownerDocument.addEventListener('mousemove', this._handleMouseMove); | ||
@@ -130,2 +164,3 @@ ownerDocument.addEventListener('mouseup', this._handleMouseUp); | ||
var ownerDocument = this.handleRef.ownerDocument; | ||
removeUserSelectStyles(ownerDocument); | ||
ownerDocument.removeEventListener('mousemove', this._handleMouseMove); | ||
@@ -132,0 +167,0 @@ ownerDocument.addEventListener('mouseup', this._handleMouseUp); |
@@ -21,2 +21,4 @@ "use strict"; | ||
exports.getScrollbarSize = getScrollbarSize; | ||
exports.addClassName = addClassName; | ||
exports.removeClassName = removeClassName; | ||
@@ -261,2 +263,20 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
} | ||
function addClassName(el, className) { | ||
if (el.classList) { | ||
el.classList.add(className); | ||
} else { | ||
if (!el.className.match(new RegExp("(?:^|\\s)".concat(className, "(?!\\S)")))) { | ||
el.className += " ".concat(className); | ||
} | ||
} | ||
} | ||
function removeClassName(el, className) { | ||
if (el.classList) { | ||
el.classList.remove(className); | ||
} else { | ||
el.className = el.className.replace(new RegExp("(?:^|\\s)".concat(className, "(?!\\S)"), 'g'), ''); | ||
} | ||
} | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "react-base-table", | ||
"version": "1.6.3", | ||
"version": "1.6.4", | ||
"description": "a react table component to display large data set with high performance and flexibility", | ||
@@ -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 not supported yet
Sorry, the diff of this file is not supported yet
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
816163
6126