Skip to content

Commit ef80a69

Browse files
committed
update packages and fix test
1 parent 8ddd3ee commit ef80a69

File tree

9 files changed

+20673
-13301
lines changed

9 files changed

+20673
-13301
lines changed

docs/package-lock.json

Lines changed: 11615 additions & 7121 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/package.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"private": true,
55
"homepage": "http://nadbm.github.io/react-datasheet",
66
"devDependencies": {
7-
"react-scripts": "^1.0.6"
7+
"react-scripts": "^3.1.1"
88
},
99
"dependencies": {
10-
"gh-pages": "^1.1.0",
11-
"mathjs": "^3.10.0",
10+
"gh-pages": "^2.1.1",
11+
"mathjs": "^6.2.1",
1212
"react": "^15.4.2",
1313
"react-dnd": "^2.5.4",
1414
"react-dnd-html5-backend": "^2.5.4",
@@ -22,5 +22,17 @@
2222
"eject": "react-scripts eject",
2323
"predeploy": "npm run build",
2424
"deploy": "gh-pages -d build"
25+
},
26+
"browserslist": {
27+
"production": [
28+
">0.2%",
29+
"not dead",
30+
"not op_mini all"
31+
],
32+
"development": [
33+
"last 1 chrome version",
34+
"last 1 firefox version",
35+
"last 1 safari version"
36+
]
2537
}
2638
}

docs/src/examples/MathSheet.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import _ from 'lodash';
3-
import mathjs from 'mathjs';
3+
import * as mathjs from 'mathjs';
44
import Datasheet from '../lib/DataSheet'
55

66
export default class MathSheet extends React.Component {
@@ -64,7 +64,7 @@ export default class MathSheet extends React.Component {
6464
return {className: '', value: expr, expr: expr};
6565
} else {
6666
try {
67-
value = mathjs.eval(expr.substring(1), scope)
67+
value = mathjs.evaluate(expr.substring(1), scope)
6868
} catch(e) {
6969
value = null
7070
}

docs/yarn.lock

Lines changed: 6974 additions & 3448 deletions
Large diffs are not rendered by default.

lib/DataSheet.js

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ var DataSheet = function (_PureComponent) {
121121
document.removeEventListener('cut', this.handleCut);
122122
document.removeEventListener('copy', this.handleCopy);
123123
document.removeEventListener('paste', this.handlePaste);
124+
document.removeEventListener('keydown', this.handlePaste);
124125
}
125126
}, {
126127
key: 'componentDidMount',
@@ -243,7 +244,14 @@ var DataSheet = function (_PureComponent) {
243244

244245
var parse = this.props.parsePaste || defaultParsePaste;
245246
var changes = [];
246-
var pasteData = parse(e.clipboardData.getData('text/plain'));
247+
var pasteData = [];
248+
if (window.clipboardData && window.clipboardData.getData) {
249+
// IE
250+
pasteData = parse(window.clipboardData.getData('Text'));
251+
} else if (e.clipboardData && e.clipboardData.getData) {
252+
pasteData = parse(e.clipboardData.getData('text/plain'));
253+
}
254+
247255
// in order of preference
248256
var _props3 = this.props,
249257
data = _props3.data,
@@ -525,6 +533,8 @@ var DataSheet = function (_PureComponent) {
525533
}, {
526534
key: 'onMouseDown',
527535
value: function onMouseDown(i, j, e) {
536+
var _this5 = this;
537+
528538
var editing = isEmpty(this.state.editing) || this.state.editing.i !== i || this.state.editing.j !== j ? {} : this.state.editing;
529539

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

548+
var ua = window.navigator.userAgent;
549+
var isIE = /MSIE|Trident/.test(ua);
550+
// Listen for Ctrl + V in case of IE
551+
if (isIE) {
552+
document.addEventListener('keydown', function (e) {
553+
if ((e.keyCode === 86 || e.which === 86) && e.ctrlKey) {
554+
_this5.handlePaste(e);
555+
}
556+
});
557+
}
558+
538559
// Keep listening to mouse if user releases the mouse (dragging outside)
539560
document.addEventListener('mouseup', this.onMouseUp);
540561
// Listen for any outside mouse clicks
@@ -618,7 +639,7 @@ var DataSheet = function (_PureComponent) {
618639
}, {
619640
key: 'render',
620641
value: function render() {
621-
var _this5 = this;
642+
var _this6 = this;
622643

623644
var _props6 = this.props,
624645
SheetRenderer = _props6.sheetRenderer,
@@ -639,7 +660,7 @@ var DataSheet = function (_PureComponent) {
639660
return _react2.default.createElement(
640661
'span',
641662
{ ref: function ref(r) {
642-
_this5.dgDom = r;
663+
_this6.dgDom = r;
643664
}, tabIndex: '0', className: 'data-grid-container', onKeyDown: this.handleKey },
644665
_react2.default.createElement(
645666
SheetRenderer,
@@ -657,17 +678,17 @@ var DataSheet = function (_PureComponent) {
657678
col: j,
658679
cell: cell,
659680
forceEdit: forceEdit,
660-
onMouseDown: _this5.onMouseDown,
661-
onMouseOver: _this5.onMouseOver,
662-
onDoubleClick: _this5.onDoubleClick,
663-
onContextMenu: _this5.onContextMenu,
664-
onChange: _this5.onChange,
665-
onRevert: _this5.onRevert,
666-
onNavigate: _this5.handleKeyboardCellMovement,
667-
onKey: _this5.handleKey,
668-
selected: _this5.isSelected(i, j),
669-
editing: _this5.isEditing(i, j),
670-
clearing: _this5.isClearing(i, j),
681+
onMouseDown: _this6.onMouseDown,
682+
onMouseOver: _this6.onMouseOver,
683+
onDoubleClick: _this6.onDoubleClick,
684+
onContextMenu: _this6.onContextMenu,
685+
onChange: _this6.onChange,
686+
onRevert: _this6.onRevert,
687+
onNavigate: _this6.handleKeyboardCellMovement,
688+
onKey: _this6.handleKey,
689+
selected: _this6.isSelected(i, j),
690+
editing: _this6.isEditing(i, j),
691+
clearing: _this6.isClearing(i, j),
671692
attributesRenderer: attributesRenderer,
672693
cellRenderer: cellRenderer,
673694
valueRenderer: valueRenderer,

0 commit comments

Comments
 (0)