Skip to content

Commit

Permalink
update packages and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
nadbm committed Sep 14, 2019
1 parent 8ddd3ee commit ef80a69
Show file tree
Hide file tree
Showing 9 changed files with 20,673 additions and 13,301 deletions.
18,736 changes: 11,615 additions & 7,121 deletions docs/package-lock.json

Large diffs are not rendered by default.

18 changes: 15 additions & 3 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"private": true,
"homepage": "http://nadbm.github.io/react-datasheet",
"devDependencies": {
"react-scripts": "^1.0.6"
"react-scripts": "^3.1.1"
},
"dependencies": {
"gh-pages": "^1.1.0",
"mathjs": "^3.10.0",
"gh-pages": "^2.1.1",
"mathjs": "^6.2.1",
"react": "^15.4.2",
"react-dnd": "^2.5.4",
"react-dnd-html5-backend": "^2.5.4",
Expand All @@ -22,5 +22,17 @@
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
4 changes: 2 additions & 2 deletions docs/src/examples/MathSheet.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import _ from 'lodash';
import mathjs from 'mathjs';
import * as mathjs from 'mathjs';
import Datasheet from '../lib/DataSheet'

export default class MathSheet extends React.Component {
Expand Down Expand Up @@ -64,7 +64,7 @@ export default class MathSheet extends React.Component {
return {className: '', value: expr, expr: expr};
} else {
try {
value = mathjs.eval(expr.substring(1), scope)
value = mathjs.evaluate(expr.substring(1), scope)
} catch(e) {
value = null
}
Expand Down
10,422 changes: 6,974 additions & 3,448 deletions docs/yarn.lock

Large diffs are not rendered by default.

49 changes: 35 additions & 14 deletions lib/DataSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ var DataSheet = function (_PureComponent) {
document.removeEventListener('cut', this.handleCut);
document.removeEventListener('copy', this.handleCopy);
document.removeEventListener('paste', this.handlePaste);
document.removeEventListener('keydown', this.handlePaste);
}
}, {
key: 'componentDidMount',
Expand Down Expand Up @@ -243,7 +244,14 @@ var DataSheet = function (_PureComponent) {

var parse = this.props.parsePaste || defaultParsePaste;
var changes = [];
var pasteData = parse(e.clipboardData.getData('text/plain'));
var pasteData = [];
if (window.clipboardData && window.clipboardData.getData) {
// IE
pasteData = parse(window.clipboardData.getData('Text'));
} else if (e.clipboardData && e.clipboardData.getData) {
pasteData = parse(e.clipboardData.getData('text/plain'));
}

// in order of preference
var _props3 = this.props,
data = _props3.data,
Expand Down Expand Up @@ -525,6 +533,8 @@ var DataSheet = function (_PureComponent) {
}, {
key: 'onMouseDown',
value: function onMouseDown(i, j, e) {
var _this5 = this;

var editing = isEmpty(this.state.editing) || this.state.editing.i !== i || this.state.editing.j !== j ? {} : this.state.editing;

this._setState({
Expand All @@ -535,6 +545,17 @@ var DataSheet = function (_PureComponent) {
forceEdit: false
});

var ua = window.navigator.userAgent;
var isIE = /MSIE|Trident/.test(ua);
// Listen for Ctrl + V in case of IE
if (isIE) {
document.addEventListener('keydown', function (e) {
if ((e.keyCode === 86 || e.which === 86) && e.ctrlKey) {
_this5.handlePaste(e);
}
});
}

// Keep listening to mouse if user releases the mouse (dragging outside)
document.addEventListener('mouseup', this.onMouseUp);
// Listen for any outside mouse clicks
Expand Down Expand Up @@ -618,7 +639,7 @@ var DataSheet = function (_PureComponent) {
}, {
key: 'render',
value: function render() {
var _this5 = this;
var _this6 = this;

var _props6 = this.props,
SheetRenderer = _props6.sheetRenderer,
Expand All @@ -639,7 +660,7 @@ var DataSheet = function (_PureComponent) {
return _react2.default.createElement(
'span',
{ ref: function ref(r) {
_this5.dgDom = r;
_this6.dgDom = r;
}, tabIndex: '0', className: 'data-grid-container', onKeyDown: this.handleKey },
_react2.default.createElement(
SheetRenderer,
Expand All @@ -657,17 +678,17 @@ var DataSheet = function (_PureComponent) {
col: j,
cell: cell,
forceEdit: forceEdit,
onMouseDown: _this5.onMouseDown,
onMouseOver: _this5.onMouseOver,
onDoubleClick: _this5.onDoubleClick,
onContextMenu: _this5.onContextMenu,
onChange: _this5.onChange,
onRevert: _this5.onRevert,
onNavigate: _this5.handleKeyboardCellMovement,
onKey: _this5.handleKey,
selected: _this5.isSelected(i, j),
editing: _this5.isEditing(i, j),
clearing: _this5.isClearing(i, j),
onMouseDown: _this6.onMouseDown,
onMouseOver: _this6.onMouseOver,
onDoubleClick: _this6.onDoubleClick,
onContextMenu: _this6.onContextMenu,
onChange: _this6.onChange,
onRevert: _this6.onRevert,
onNavigate: _this6.handleKeyboardCellMovement,
onKey: _this6.handleKey,
selected: _this6.isSelected(i, j),
editing: _this6.isEditing(i, j),
clearing: _this6.isClearing(i, j),
attributesRenderer: attributesRenderer,
cellRenderer: cellRenderer,
valueRenderer: valueRenderer,
Expand Down
Loading

0 comments on commit ef80a69

Please sign in to comment.