diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000000..0946b0a5ee
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,20 @@
+# EditorConfig helps developers define and maintain consistent
+# coding styles between different editors and IDEs
+# http://editorconfig.org
+
+root = true
+
+[*]
+
+# Change these settings to your own preference
+indent_style = space
+indent_size = 2
+
+# We recommend you to keep these unchanged
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+trim_trailing_whitespace = false
diff --git a/config/webpack.config.prod.js b/config/webpack.config.prod.js
index 571b938f42..fc4c2408e9 100644
--- a/config/webpack.config.prod.js
+++ b/config/webpack.config.prod.js
@@ -6,10 +6,7 @@ const config = {
'react-data-grid-addons/dist/react-data-grid-addons': ['./packages/react-data-grid-addons/src'],
'react-data-grid/dist/react-data-grid.min': ['./packages/react-data-grid/src'],
'react-data-grid-addons/dist/react-data-grid-addons.min': ['./packages/react-data-grid-addons/src'],
- 'react-data-grid-examples/dist/shared': './packages/react-data-grid-examples/src/shared.js',
- 'react-data-grid-examples/dist/examples': './packages/react-data-grid-examples/src/examples.js',
- 'react-data-grid-examples/dist/index': './packages/react-data-grid-examples/src/index.js',
- 'react-data-grid-examples/dist/documentation': './packages/react-data-grid-examples/src/documentation.js'
+ 'react-data-grid-examples/dist/index': './packages/react-data-grid-examples/src'
},
output: {
path: './packages',
diff --git a/package.json b/package.json
index f56d932572..021785012b 100644
--- a/package.json
+++ b/package.json
@@ -23,23 +23,23 @@
"react-component"
],
"peerDependencies": {
- "react": "^15.6.2",
- "react-dom": "^15.6.2"
+ "react": "^15.0.0 || ^16.0.0",
+ "react-dom": "^15.0.0 || ^16.0.0"
},
"dependencies": {
- "classnames": "^1.2.0",
+ "classnames": "^2.2.5",
"es5-shim": "^4.0.3",
- "fbjs": "^0.6.1",
"fs-extra": "^0.30.0",
- "object-assign": "^2.0.0",
+ "keymirror": "^0.1.1",
+ "object-assign": "^4.1.1",
"prop-types": "^15.5.10",
"react-contextmenu": "^2.9.2",
- "react-dnd": "^2.1.4",
- "react-dnd-html5-backend": "^2.1.2",
- "react-input-autosize": "1.1.0",
- "react-select": "^1.0.0-beta14",
+ "react-dnd": "^2.5.4",
+ "react-dnd-html5-backend": "^2.5.4",
+ "react-select": "^1.2.1",
"reselect": "^2.5.1",
- "ron-react-autocomplete": "^4.0.5"
+ "ron-react-autocomplete": "^4.0.5",
+ "shallowequal": "^1.0.2"
},
"devDependencies": {
"avcoveralls": "^1.0.0",
@@ -57,7 +57,8 @@
"copy-dir": "^0.3.0",
"css-loader": "^0.26.0",
"del": "^1.2.1",
- "enzyme": "^2.9.1",
+ "enzyme": "^3.3.0",
+ "enzyme-adapter-react-16": "^1.1.1",
"eslint": "^1.10.3",
"eslint-loader": "^1.2.0",
"eslint-plugin-react": "^3.15.0",
@@ -69,7 +70,7 @@
"immutable": "^3.7.3",
"istanbul-instrumenter-loader": "^0.1.2",
"jasmine-core": "2.6.1",
- "jasmine-enzyme": "^1.2.0",
+ "jasmine-enzyme": "^4.2.0",
"karma": "^1.1.0",
"karma-chrome-launcher": "^0.2.0",
"karma-coverage": "^0.4.0",
@@ -88,14 +89,12 @@
"mkdirp": "^0.5.1",
"moment": "^2.10.6",
"node-dir": "^0.1.12",
- "object-assign": "^2.1.1",
"open": "0.0.5",
- "react": "^15.6.2",
- "react-addons-perf": "^15.4.2",
- "react-dnd-test-backend": "^1.0.2",
+ "react": "^16.2.0",
+ "react-dnd-test-backend": "^2.5.4",
"react-docgen": "^2.8.2",
- "react-dom": "^15.6.2",
- "react-test-renderer": "^15.6.2",
+ "react-dom": "^16.2.0",
+ "react-test-renderer": "^16.2.0",
"rewire": "^2.1.3",
"rewire-webpack": "^1.0.0",
"run-sequence": "^1.2.2",
diff --git a/packages/react-data-grid-addons/src/__tests__/Grid.spec.js b/packages/react-data-grid-addons/src/__tests__/Grid.spec.js
index 90dacf4b57..4b9a9c4438 100644
--- a/packages/react-data-grid-addons/src/__tests__/Grid.spec.js
+++ b/packages/react-data-grid-addons/src/__tests__/Grid.spec.js
@@ -86,7 +86,7 @@ describe('Grid', function() {
};
this.componentWrapper = this.createComponent();
- this.component = this.componentWrapper.node;
+ this.component = this.componentWrapper.instance();
});
it('should create a new instance of Grid', function() {
@@ -109,7 +109,7 @@ describe('Grid', function() {
describe('for defaults props', function() {
beforeEach(function() {
const ToolBarStub = new StubComponent('Toolbar');
- this.component = this.createComponent({ toolbar: }).node;
+ this.component = this.createComponent({ toolbar: }).instance();
this.toolbarInstance = TestUtils.findRenderedComponentWithType(this.component, ToolBarStub);
this.toolbarInstance.props.onToggleFilter();
this.baseGrid = this.getBaseGrid();
@@ -131,7 +131,7 @@ describe('Grid', function() {
describe('for a given row height prop', function() {
beforeEach(function() {
const ToolBarStub = new StubComponent('Toolbar');
- this.component = this.createComponent({ toolbar: , rowHeight: 40 }).node;
+ this.component = this.createComponent({ toolbar: , rowHeight: 40 }).instance();
this.toolbarInstance = TestUtils.findRenderedComponentWithType(this.component, ToolBarStub);
this.toolbarInstance.props.onToggleFilter();
this.baseGrid = this.getBaseGrid();
@@ -153,7 +153,7 @@ describe('Grid', function() {
describe('for given row and header height props', function() {
beforeEach(function() {
const ToolBarStub = new StubComponent('Toolbar');
- this.component = this.createComponent({ toolbar: , rowHeight: 40, headerRowHeight: 50, headerFiltersHeight: 60 }).node;
+ this.component = this.createComponent({ toolbar: , rowHeight: 40, headerRowHeight: 50, headerFiltersHeight: 60 }).instance();
this.toolbarInstance = TestUtils.findRenderedComponentWithType(this.component, ToolBarStub);
this.toolbarInstance.props.onToggleFilter();
this.baseGrid = this.getBaseGrid();
@@ -176,7 +176,7 @@ describe('Grid', function() {
describe('if passed in as props to grid', function() {
beforeEach(function() {
const ToolBarStub = new StubComponent('Toolbar');
- this.component = this.createComponent({ toolbar: }).node;
+ this.component = this.createComponent({ toolbar: }).instance();
this.toolbarInstance = TestUtils.findRenderedComponentWithType(this.component, ToolBarStub);
});
@@ -207,7 +207,7 @@ describe('Grid', function() {
rowGetter: this.rowGetter,
rowsCount: this._rows.length,
width: 300
- }).node;
+ }).instance();
});
it('grid should be initialized with selected state of {rowIdx : -1, idx : -1}', function() {
@@ -217,7 +217,7 @@ describe('Grid', function() {
describe('When row selection enabled', function() {
beforeEach(function() {
- this.component = this.createComponent({ enableRowSelect: true}).node;
+ this.component = this.createComponent({ enableRowSelect: true}).instance();
this.baseGrid = this.getBaseGrid();
this.selectRowCol = this.baseGrid.props.columnMetrics.columns[0];
});
@@ -302,7 +302,7 @@ describe('Grid', function() {
describe('Cell Navigation', function() {
describe('when cell navigation is configured to default, none', function() {
beforeEach(function() {
- this.component = this.createComponent({enableCellSelect: true}).node;
+ this.component = this.createComponent({enableCellSelect: true}).instance();
});
describe('when on last cell in a row', function() {
@@ -336,7 +336,7 @@ describe('Grid', function() {
describe('when cell navigation is configured to change rows', function() {
beforeEach(function() {
- this.component = this.createComponent({cellNavigationMode: 'changeRow', enableCellSelect: true}).node;
+ this.component = this.createComponent({cellNavigationMode: 'changeRow', enableCellSelect: true}).instance();
});
describe('when on last cell in a row that\'s not the last', function() {
@@ -388,7 +388,7 @@ describe('Grid', function() {
describe('when cell navigation is configured to loop over cells in row', function() {
beforeEach(function() {
- this.component = this.createComponent({cellNavigationMode: 'loopOverRow', enableCellSelect: true}).node;
+ this.component = this.createComponent({cellNavigationMode: 'loopOverRow', enableCellSelect: true}).instance();
});
describe('when on last cell, looping enabled', function() {
@@ -445,7 +445,7 @@ describe('Grid', function() {
const extraProps = { onCellSelected: this.noop, onCellDeSelected: this.noop };
spyOn(extraProps, 'onCellSelected');
spyOn(extraProps, 'onCellDeSelected');
- this.component = this.createComponent(extraProps).node;
+ this.component = this.createComponent(extraProps).instance();
});
describe('cell is selected', function() {
@@ -489,7 +489,7 @@ describe('Grid', function() {
onRowsDeselected: function(deselectedRows) {
self._deselectedRows = deselectedRows;
}
- }}).node;
+ }}).instance();
this.baseGrid = this.getBaseGrid();
this.selectRowCol = this.baseGrid.props.columnMetrics.columns[0];
});
@@ -550,7 +550,7 @@ describe('Grid', function() {
onRowsDeselected: function(deselectedRows) {
self._deselectedRows = deselectedRows;
}
- }}).node;
+ }}).instance();
this.baseGrid = this.getBaseGrid();
this.selectRowCol = this.baseGrid.props.columnMetrics.columns[0];
@@ -587,7 +587,7 @@ describe('Grid', function() {
onRowsDeselected: function(deselectedRows) {
self._deselectedRows = deselectedRows;
}
- }}).node;
+ }}).instance();
this.baseGrid = this.getBaseGrid();
this.selectRowCol = this.baseGrid.props.columnMetrics.columns[0];
@@ -656,7 +656,7 @@ describe('Grid', function() {
beforeEach(function() {
const editableColumn = Object.assign({ editable: true }, this.columns[1]);
this.columns[1] = editableColumn;
- this.component = this.createComponent({ columns: this.columns }).node;
+ this.component = this.createComponent({ columns: this.columns }).instance();
});
describe('copy a cell value', function() {
@@ -679,7 +679,7 @@ describe('Grid', function() {
const vCharacterKeyCode = 118;
spyOn(this.testProps, 'onCellCopyPaste');
wrapper.setProps({ onCellCopyPaste: this.testProps.onCellCopyPaste });
- this.component = wrapper.node;
+ this.component = wrapper.instance();
this.component.setState({
textToCopy: 'banana',
selected: { idx: 1, rowIdx: 5 },
@@ -801,7 +801,7 @@ describe('Grid', function() {
let wrapper = this.createComponent();
spyOn(this.testProps, 'onCellsDragged');
wrapper.setProps({ onCellsDragged: this.testProps.onCellsDragged });
- this.component = wrapper.node;
+ this.component = wrapper.instance();
this.component.setState({
selected: { idx: 1, rowIdx: 2 },
dragged: { idx: 1, rowIdx: 2, value: 'apple', overRowIdx: 6 }
@@ -834,7 +834,7 @@ describe('Grid', function() {
const newColumns = Object.assign([], this.columns);
newColumns.splice(2, 0, newColumn);
wrapper.setProps({ columns: newColumns });
- this.component = wrapper.node;
+ this.component = wrapper.instance();
this.columns = this.component.state.columnMetrics.columns;
});
@@ -853,7 +853,7 @@ describe('Grid', function() {
const newColumns = Object.assign([], this.columns);
newColumns.splice(1, 1);
wrapper.setProps({ columns: newColumns });
- this.component = wrapper.node;
+ this.component = wrapper.instance();
this.columns = this.component.state.columnMetrics.columns;
});
@@ -921,7 +921,7 @@ describe('Grid', function() {
let wrapper = this.createComponent();
spyOn(this.testProps, 'onRowUpdated');
wrapper.setProps({ onRowUpdated: this.testProps.onRowUpdated });
- this.component = wrapper.node;
+ this.component = wrapper.instance();
this.component.setState({ selected: { idx: 3, rowIdx: 3, active: true } });
this.getCellMetaData().onCommit(this.buildFakeCellUodate());
});
@@ -1007,7 +1007,7 @@ describe('Grid', function() {
const editableColumn = Object.assign({ editable: true }, this.columns[0]);
this.columns[0] = editableColumn;
wrapper.setProps({ columns: this.columns });
- this.component = wrapper.node;
+ this.component = wrapper.instance();
});
it('should keep original metric information', function() {
@@ -1025,7 +1025,7 @@ describe('Grid', function() {
beforeEach(function() {
wrapper = this.createComponent();
- this.component = wrapper.node;
+ this.component = wrapper.instance();
this.tableElement = ReactDOM.findDOMNode(this.component);
});
@@ -1036,7 +1036,7 @@ describe('Grid', function() {
describe('providing table width as prop', function() {
beforeEach(function() {
wrapper.setProps({ minWidth: 900 });
- this.component = wrapper.node;
+ this.component = wrapper.instance();
});
it('should set the width of the table', function() {
@@ -1060,7 +1060,7 @@ describe('Grid', function() {
this.component = this.createComponent({rowsCount: this.rows.length, rowGetter: rowGetter, columns: columns, onRowClick: function(rowIdx, row, column) {
self.rowClicked = {row, column};
self.rowClicks++;
- }}).node;
+ }}).instance();
});
it('calls handler when row (cell) clicked', function() {
diff --git a/packages/react-data-grid-addons/src/draggable-header/DraggableContainer.js b/packages/react-data-grid-addons/src/draggable-header/DraggableContainer.js
index e8651d1320..05d11d1124 100644
--- a/packages/react-data-grid-addons/src/draggable-header/DraggableContainer.js
+++ b/packages/react-data-grid-addons/src/draggable-header/DraggableContainer.js
@@ -1,7 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
-import { DragDropContext } from 'react-dnd';
-import HTML5Backend from 'react-dnd-html5-backend';
+import html5DragDropContext from '../shared/html5DragDropContext';
import DraggableHeaderCell from './DraggableHeaderCell';
class DraggableContainer extends React.Component {
@@ -27,4 +26,4 @@ DraggableContainer.propTypes = {
children: PropTypes.element
};
-export default DragDropContext(HTML5Backend)(DraggableContainer);
+export default html5DragDropContext(DraggableContainer);
diff --git a/packages/react-data-grid-addons/src/draggable/DragDropContainer.js b/packages/react-data-grid-addons/src/draggable/DragDropContainer.js
index 7d3f4f0a6c..4b134ad173 100644
--- a/packages/react-data-grid-addons/src/draggable/DragDropContainer.js
+++ b/packages/react-data-grid-addons/src/draggable/DragDropContainer.js
@@ -1,6 +1,5 @@
import React, {Component} from 'react';
-import HTML5Backend from 'react-dnd-html5-backend';
-import { DragDropContext } from 'react-dnd';
+import html5DragDropContext from '../shared/html5DragDropContext';
import DraggableHeaderCell from './DraggableHeaderCell';
import RowDragLayer from './RowDragLayer';
import { utils } from 'react-data-grid';
@@ -41,4 +40,4 @@ DraggableContainer.propTypes = {
getDragPreviewRow: PropTypes.func
};
-export default DragDropContext(HTML5Backend)(DraggableContainer);
+export default html5DragDropContext(DraggableContainer);
diff --git a/packages/react-data-grid-addons/src/draggable/__tests__/DropTargetRowContainer.spec.js b/packages/react-data-grid-addons/src/draggable/__tests__/DropTargetRowContainer.spec.js
index 35cd3441a3..6831f79c60 100644
--- a/packages/react-data-grid-addons/src/draggable/__tests__/DropTargetRowContainer.spec.js
+++ b/packages/react-data-grid-addons/src/draggable/__tests__/DropTargetRowContainer.spec.js
@@ -41,7 +41,7 @@ describe(' ', () => {
beforeEach(() => {
ComponentUnderTest = wrapInTestContext(dropTargetRowContainer(fakeRow));
wrapper = mount( );
- manager = wrapper.node.getManager();
+ manager = wrapper.instance().getManager();
backend = manager.getBackend();
registry = manager.getRegistry();
});
diff --git a/packages/react-data-grid-addons/src/editors/__tests__/ContainerEditorWrapper.spec.js b/packages/react-data-grid-addons/src/editors/__tests__/ContainerEditorWrapper.spec.js
index 61bebd9911..2fb0a678d8 100644
--- a/packages/react-data-grid-addons/src/editors/__tests__/ContainerEditorWrapper.spec.js
+++ b/packages/react-data-grid-addons/src/editors/__tests__/ContainerEditorWrapper.spec.js
@@ -39,8 +39,8 @@ describe('ContainerEditorWrapper', () => {
const renderedComp = Enzyme.mount( );
// ASSERT
- let redneredContainerEditorWrapper = renderedComp.find('ContainerEditorWrapper').node;
- let renderedFakeComponent = renderedComp.find('FakeComponent').node;
+ let redneredContainerEditorWrapper = renderedComp.find('ContainerEditorWrapper').instance();
+ let renderedFakeComponent = renderedComp.find('FakeComponent').instance();
redneredContainerEditorWrapper.getValue();
expect(renderedComp).toBeDefined();
@@ -55,8 +55,8 @@ describe('ContainerEditorWrapper', () => {
const renderedComp = Enzyme.mount( );
// ASSERT
- let redneredContainerEditorWrapper = renderedComp.find('ContainerEditorWrapper').node;
- let renderedFakeComponent = renderedComp.find('FakeComponent').node;
+ let redneredContainerEditorWrapper = renderedComp.find('ContainerEditorWrapper').instance();
+ let renderedFakeComponent = renderedComp.find('FakeComponent').instance();
redneredContainerEditorWrapper.getInputNode();
expect(renderedComp).toBeDefined();
diff --git a/packages/react-data-grid-addons/src/shared/html5DragDropContext.js b/packages/react-data-grid-addons/src/shared/html5DragDropContext.js
new file mode 100644
index 0000000000..a9708ef978
--- /dev/null
+++ b/packages/react-data-grid-addons/src/shared/html5DragDropContext.js
@@ -0,0 +1,4 @@
+import { DragDropContext } from 'react-dnd';
+import HTML5Backend from 'react-dnd-html5-backend';
+
+export default DragDropContext(HTML5Backend);
diff --git a/packages/react-data-grid-examples/package.json b/packages/react-data-grid-examples/package.json
index 66cbb2fa50..527f48a326 100644
--- a/packages/react-data-grid-examples/package.json
+++ b/packages/react-data-grid-examples/package.json
@@ -19,14 +19,14 @@
"dependencies": {
"immutability-helper": "^2.4.0",
"react-data-grid": "^3.0.11",
- "react-data-grid-addons": "^3.0.11"
+ "react-data-grid-addons": "^3.0.11",
+ "react-router-dom": "^4.2.2"
},
"devDependencies": {
"bootstrap": "^3.2.0",
"jquery": "^2.1.1",
"lodash": "^4.13.1",
"lodash.groupby": "^4.5.1",
- "react-router": "^0.13.3",
"markdown": "^0.5.0"
}
}
diff --git a/packages/react-data-grid-examples/src/__tests__/Grid-perf.spec.js b/packages/react-data-grid-examples/src/__tests__/Grid-perf.spec.js
deleted file mode 100644
index bd7f5fa27d..0000000000
--- a/packages/react-data-grid-examples/src/__tests__/Grid-perf.spec.js
+++ /dev/null
@@ -1,95 +0,0 @@
-import ReactPerf from 'react-addons-perf';
-import GridRunner from './GridRunner';
-const { Component: ImmutableGrid } = require('../scripts/example11-immutable-data');
-const { Utils: { performance: { SummaryParser } } } = require('react-data-grid-addons');
-
-const ScrollType = {
- VERTICAL: 0,
- HORIZONTAL: 1
-};
-
-const NAVIGATION_BY_SCROLLTYPE = {
- [ScrollType.VERTICAL]: {
- key: 'ArrowDown',
- getNext: (x, y) => { return { y: y + 1, x }; },
- shouldStop: (x, y, expected) => y === expected
- },
- [ScrollType.HORIZONTAL]: {
- key: 'ArrowRight',
- getNext: (x, y) => { return { y, x: x + 1 }; },
- shouldStop: (x, y, expected) => x === expected
- }
-};
-
-const doScroll = (xx, yy, total, gridRunner, onComplete, scrollType) => {
- const { key, getNext, shouldStop } = NAVIGATION_BY_SCROLLTYPE[scrollType];
-
- if (shouldStop(xx, yy, total)) {
- onComplete();
- return;
- }
-
- let cell = gridRunner.getCell({ cellIdx: xx, rowIdx: yy });
- gridRunner.keyDown({ key }, cell);
-
- const { x, y } = getNext(xx, yy);
-
- setTimeout(() => {
- doScroll(x, y, total, gridRunner, onComplete, scrollType);
- }, 1);
-};
-
-const doHorizontalScroll = (x, y, total, gridRunner, onComplete) => {
- doScroll(x, y, total, gridRunner, onComplete, ScrollType.HORIZONTAL);
-};
-
-const doVerticalScroll = (x, y, total, gridRunner, onComplete) => {
- doScroll(x, y, total, gridRunner, onComplete, ScrollType.VERTICAL);
-};
-
-const onScrollComplete = (done) => {
- ReactPerf.stop();
- let measurements = ReactPerf.getLastMeasurements();
-
- let summary = ReactPerf.getMeasurementsSummaryMap(measurements);
- ReactPerf.printWasted(measurements);
- let summaryParser = new SummaryParser(summary);
-
- expect(summaryParser.getByComponent('Cell').wastedInstances <= 1000).toBeTruthy();
- done();
-};
-
-xdescribe('Grid peformance tests', () => {
- let originalTimeout;
- let grid = {};
- beforeEach(() => {
- grid = new GridRunner({renderIntoBody: true, GridUnderTest: ImmutableGrid});
- originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
- jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000;
- });
-
- afterEach(() => {
- grid.dispose();
- jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
- });
-
- describe('Vertical Scroll', () => {
- it('should not waste instances on scroll', (done) => {
- const ROWS_TO_SCROLL = 1200;
- grid.selectCell({cellIdx: 0, rowIdx: 0});
- ReactPerf.start();
-
- doVerticalScroll(0, 0, ROWS_TO_SCROLL, grid, onScrollComplete.bind(null, done), ScrollType.VERTICAL);
- });
- });
-
- describe('Horizontal scroll', () => {
- it('should not waste instances on scroll', (done) => {
- const COLUMNS_TO_SCROLL = 20;
- grid.selectCell({cellIdx: 0, rowIdx: 0});
- ReactPerf.start();
-
- doHorizontalScroll(0, 0, COLUMNS_TO_SCROLL, grid, onScrollComplete.bind(null, done), ScrollType.HORIZONTAL);
- });
- });
-});
diff --git a/packages/react-data-grid-examples/src/__tests__/Grid.integration-spec.js b/packages/react-data-grid-examples/src/__tests__/Grid.integration-spec.js
index 7aeac7a199..0d4796cf10 100644
--- a/packages/react-data-grid-examples/src/__tests__/Grid.integration-spec.js
+++ b/packages/react-data-grid-examples/src/__tests__/Grid.integration-spec.js
@@ -1,6 +1,5 @@
import TestUtils from 'react-dom/test-utils';
import GridRunner from './GridRunner';
-import ReactDOM from 'react-dom';
describe('Grid Integration', () => {
let gridRunner;
@@ -47,11 +46,11 @@ describe('Grid Integration', () => {
gridRunner.selectCell({cellIdx: firstCellIdx, rowIdx: 1}).copy();
let firstCell = gridRunner.getCell({cellIdx: firstCellIdx, rowIdx: 1});
- expect(ReactDOM.findDOMNode(firstCell.node).className.indexOf('copied') > -1).toBe(true);
+ expect(firstCell.getDOMNode().className.indexOf('copied') > -1).toBe(true);
gridRunner.selectCell({cellIdx: 4, rowIdx: 1})
.copy();
- expect(ReactDOM.findDOMNode(firstCell.node).className.indexOf('copied') > -1).toBe(false);
+ expect(firstCell.getDOMNode().className.indexOf('copied') > -1).toBe(false);
});
});
@@ -107,20 +106,27 @@ describe('Grid Integration', () => {
it('Start editing by pressing a key', () => {
const letterEKeyCode = 69;
- gridRunner.selectCell({rowIdx: 3, cellIdx: 5})
+ const coords = {rowIdx: 3, cellIdx: 5};
+ gridRunner.selectCell(coords)
.keyDown({
keyCode: letterEKeyCode
}, gridRunner.cell )
+ .resetCell(coords)
.isEditable()
+ .resetCell(coords)
.keyDown({key: 'Enter'})
+ .resetCell(coords)
.hasCommitted('E') // keydown ALWAYS upper case http://stackoverflow.com/questions/2263889/why-always-uppercase-in-my-code
.isNotEditable()
.dispose();
});
it('Start editing by pressing enter', () => {
- gridRunner.selectCell({rowIdx: 3, cellIdx: 5})
+ const coords = {rowIdx: 3, cellIdx: 5};
+ gridRunner.selectCell(coords)
+ .resetCell(coords)
.keyDown({key: 'Enter'}, gridRunner.cell)
+ .resetCell(coords)
.isEditable()
.dispose();
});
@@ -146,6 +152,7 @@ describe('Grid Integration', () => {
it('should commit editor changes on blur', () => {
gridRunner = new GridRunner({});
gridRunner.clickIntoEditor({ rowIdx: 3, cellIdx: 5})
+ .resetCell({ rowIdx: 3, cellIdx: 5})
.setValue('Test')
.selectCell({ rowIdx: 4, cellIdx: 3 })
.selectCell({ rowIdx: 3, cellIdx: 5 })
@@ -155,9 +162,13 @@ describe('Grid Integration', () => {
it('Arrow Left doesnt commit your change if you are not at the start of the text', () => {
gridRunner = new GridRunner({renderIntoBody: true});
- gridRunner.clickIntoEditor({rowIdx: 3, cellIdx: 4})
+ const coords = {rowIdx: 3, cellIdx: 4};
+ gridRunner.clickIntoEditor(coords)
+ .resetCell(coords)
.setValue('Test')
+ .resetCell(coords)
.setCursor(2)
+ .resetCell(coords)
.keyDown({key: 'ArrowLeft'})
.isEditable()
// Need to escape the editor here since dispose will prompt componentWillUnmount,
@@ -178,10 +189,15 @@ describe('Grid Integration', () => {
it('Arrow Right commits your change when you are at the end of the text', () => {
gridRunner = new GridRunner({renderIntoBody: true});
- gridRunner.clickIntoEditor({rowIdx: 3, cellIdx: 4})
+ const coords = {rowIdx: 3, cellIdx: 4};
+ gridRunner.clickIntoEditor(coords)
+ .resetCell(coords)
.setValue('Test')
+ .resetCell(coords)
.setCursor(4)
+ .resetCell(coords)
.keyDown({key: 'ArrowRight'})
+ .resetCell(coords)
.hasCommitted('Test')
.hasSelected({rowIdx: 3, cellIdx: 5})
.dispose();
@@ -189,9 +205,13 @@ describe('Grid Integration', () => {
it('Arrow Right doesnt commit your change when you are not at the end of the text', () => {
gridRunner = new GridRunner({renderIntoBody: true});
- gridRunner.clickIntoEditor({rowIdx: 3, cellIdx: 4})
+ const coords = {rowIdx: 3, cellIdx: 4};
+ gridRunner.clickIntoEditor(coords)
+ .resetCell(coords)
.setValue('Test')
+ .resetCell(coords)
.setCursor(2)
+ .resetCell(coords)
.keyDown({key: 'ArrowRight'})
.isEditable()
// Need to escape the editor here since dispose will prompt componentWillUnmount,
diff --git a/packages/react-data-grid-examples/src/__tests__/GridRunner.js b/packages/react-data-grid-examples/src/__tests__/GridRunner.js
index 53ac32e013..1cdd49cdc0 100644
--- a/packages/react-data-grid-examples/src/__tests__/GridRunner.js
+++ b/packages/react-data-grid-examples/src/__tests__/GridRunner.js
@@ -12,7 +12,7 @@ export default class GridRunner {
this.renderIntoBody = renderIntoBody;
this.example = GridUnderTest;
this.gridWrapper = this._renderGrid(renderIntoBody);
- this.grid = this.gridWrapper.node;
+ this.grid = this.gridWrapper.instance();
}
_renderGrid(intoBody) {
@@ -37,11 +37,16 @@ export default class GridRunner {
// Helpers - these are just wrappers to run several steps
// NOTE: these are 'final' functions, ie they call dispose at the end
changeCell({select: {cell: selectCell, row: selectRow}, val, ev, expectToSelect: {row: expectRow, cell: expectCell}}) {
+ const coords = {cellIdx: selectCell, rowIdx: selectRow};
this
- .clickIntoEditor({cellIdx: selectCell, rowIdx: selectRow})
+ .clickIntoEditor(coords)
+ .resetCell(coords)
.setValue(val)
+ .resetCell(coords)
.keyDown(ev)
+ .resetCell(coords)
.hasCommitted(val)
+ .resetCell(coords)
.hasSelected({cellIdx: expectCell, rowIdx: expectRow})
.dispose();
}
@@ -49,6 +54,12 @@ export default class GridRunner {
/* =====
ACTIONS
======== */
+ resetCell({cellIdx, rowIdx}) {
+ // Caching components do not work in V3 so find the cell again after each operation
+ this.cell = this.getCell({ cellIdx, rowIdx });
+ return this;
+ }
+
rightClickCell({cellIdx, rowIdx}) {
this.row = this.getRow(rowIdx);
this.cell = this.getCell({ cellIdx, rowIdx });
@@ -144,14 +155,14 @@ export default class GridRunner {
return this.cell.find('input');
}
setValue(val) {
- this.getEditor().node.value = val;
+ this.getEditor().instance().value = val;
// remember to set the value via the dom node, not the component!
return this;
}
// you MUST have set the grid to render into body to use this
// chrome (et al) dont do cursor positions unless you are properly visibile
setCursor(start, end = start) {
- const input = ReactDOM.findDOMNode(this.getEditor().node);
+ const input = ReactDOM.findDOMNode(this.getEditor().instance());
input.setSelectionRange(start, end);
expect(input.selectionStart).toEqual(start, `Couldnt set the cursor.
You probably havent rendered the grid into the *actual* dom.
@@ -204,25 +215,25 @@ export default class GridRunner {
}
isNotEditable() {
let editor = this.cell.find('input');
- expect(editor.nodes.length === 0).toBe(true);
+ expect(editor.length === 0).toBe(true);
return this;
}
isEditable() {
let editor = this.cell.find('input');
- expect(editor.nodes.length > 0).toBe(true);
+ expect(editor.length > 0).toBe(true);
return this;
}
hasSelected({rowIdx, cellIdx}) {
// and should move to the appropriate cell/row
let cell = this.getCell({cellIdx, rowIdx});
- expect(cell.node.isSelected()).toBe(true);
+ expect(cell.instance().isSelected()).toBe(true);
return this;
}
hasCopied({cellIdx, rowIdx}) {
let baseGrid = this.grid.reactDataGrid;
expect(baseGrid.state.copied.idx).toEqual(cellIdx); // increment by 1 due to checckbox col
expect(baseGrid.state.copied.rowIdx).toEqual(rowIdx);
- expect(ReactDOM.findDOMNode(this.cell.node).className.indexOf('copied') > -1).toBe(true);
+ expect(ReactDOM.findDOMNode(this.cell.instance()).className.indexOf('copied') > -1).toBe(true);
}
hasDragged({from, to, col, cellKey}) {
// check onCellDrag called with correct data
@@ -241,7 +252,7 @@ export default class GridRunner {
expect(toCell.props().value).toEqual(expected);
// and finally the rendered data
// (use trim as we are reading from the dom so get some whitespace at the end)
- expect(toCell.find('.react-grid-Cell__value').node.textContent.trim()).toEqual(expected.trim());
+ expect(toCell.find('.react-grid-Cell__value').instance().textContent.trim()).toEqual(expected.trim());
}
}
}
diff --git a/packages/react-data-grid-examples/src/components/App.js b/packages/react-data-grid-examples/src/components/App.js
new file mode 100644
index 0000000000..dd84854862
--- /dev/null
+++ b/packages/react-data-grid-examples/src/components/App.js
@@ -0,0 +1,22 @@
+import React from 'react';
+import { Route } from 'react-router-dom';
+
+import Navbar from './Navbar';
+import Home from './Home';
+import Examples from './Examples';
+import Documentation from './Documentation';
+
+class App extends React.Component {
+ render() {
+ return (
+
+
+
+
+
+
+ );
+ }
+}
+
+export default App;
diff --git a/packages/react-data-grid-examples/src/components/Documentation.js b/packages/react-data-grid-examples/src/components/Documentation.js
new file mode 100644
index 0000000000..816e74e423
--- /dev/null
+++ b/packages/react-data-grid-examples/src/components/Documentation.js
@@ -0,0 +1,42 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { Link, Route, Redirect, Switch } from 'react-router-dom';
+
+import GettingStarted from '../scripts/documentation01-gettingstarted';
+import ApiReference from '../scripts/documentation02-apireference';
+import ComponentsDocs from '../scripts/documentation03-components';
+
+function Documentation({ match: { url, path } }) {
+ return (
+
+ );
+}
+
+Documentation.propTypes = {
+ match: PropTypes.shape({
+ url: PropTypes.string,
+ path: PropTypes.string
+ })
+};
+
+export default Documentation;
diff --git a/packages/react-data-grid-examples/src/components/ExampleList.js b/packages/react-data-grid-examples/src/components/ExampleList.js
index f5f539567f..07c65ee81d 100644
--- a/packages/react-data-grid-examples/src/components/ExampleList.js
+++ b/packages/react-data-grid-examples/src/components/ExampleList.js
@@ -1,11 +1,15 @@
import React from 'react';
-import PropTypes from 'prop-types';
+import { Link } from 'react-router-dom';
+
+import exampleScripts from '../scripts';
class ExampleList extends React.Component {
render() {
- let links = this.props.links.map(l => {
- return {l.name} ;
- });
+ const links = exampleScripts.map(s => (
+
+ {s.name}
+
+ ));
return (
{links}
@@ -14,8 +18,4 @@ class ExampleList extends React.Component {
}
}
-ExampleList.propTypes = {
- links: PropTypes.array.isRequired
-};
-
export default ExampleList;
diff --git a/packages/react-data-grid-examples/src/components/Examples.js b/packages/react-data-grid-examples/src/components/Examples.js
new file mode 100644
index 0000000000..de308241fb
--- /dev/null
+++ b/packages/react-data-grid-examples/src/components/Examples.js
@@ -0,0 +1,47 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { Route, Redirect, Switch } from 'react-router-dom';
+
+import exampleScripts from '../scripts';
+import ExampleList from './ExampleList';
+
+function Examples({ match }) {
+ const routes = exampleScripts.map((s, index) => (
+
+ ));
+
+ return (
+
+
+
+
+
+
+
+
React Data Grid Examples
+
+ {routes}
+
+
+
+
+
+
+ );
+}
+
+Examples.propTypes = {
+ match: PropTypes.shape({
+ url: PropTypes.string
+ })
+};
+
+export default Examples;
diff --git a/packages/react-data-grid-examples/src/components/Home.js b/packages/react-data-grid-examples/src/components/Home.js
new file mode 100644
index 0000000000..35aad423d5
--- /dev/null
+++ b/packages/react-data-grid-examples/src/components/Home.js
@@ -0,0 +1,141 @@
+import React from 'react';
+import { Link } from 'react-router-dom';
+
+import ExampleList from './ExampleList';
+
+function Home() {
+ return (
+
+
+
+
+
+
React Data Grid
+
Excel-like grid component built with React
+
+ DEMO
+ DOWNLOAD NOW
+
+
+
+
+
+
+
+
+
+
Lightning Fast Rendering
+
+
Combines the performance power of React as well as partial rendering techniques in order to smoothly scroll though hundreds of thousands of rows.
+
+
+
+
Rich Editing and Formatting
+
+
View and edit cells using a wide range of formatters and editors. If these don't suit your needs, you can easily create and plugin your own
+
+
+
+
Configurable & Customizable
+
+
Quickly configure and customise features such as grid and column properties, row and cell renderers. As the Grid is a React component it is easy to extend and add custom functionality.
+
+
+
+
Packed full of Excel Features
+
+
Full keyboard navigation, cell copy & paste, cell drag down, frozen columns, column resizing, sorting, filtering and many more features on the way.
+
+
+
+
+
+
+
+
+
+
+
Check out these examples
+
+
+
+
+
+
+
+
+
+
+
+
+
Quick Start
+
Installation
+
Using Common JS
+
React Data Grid is available in the npm repository. You can install it from the command line using the following commands
+
npm install react --save
+
npm install react-data-grid --save
+
Once downloaded, require both React and React Data Grid and you should be good to go
+
+
import React from 'react'; import ReactDataGrid from 'react-data-grid';
+
+
If you want to use extra features such as built in editors, formatters, toolbars and other plugins, you need to require the addons module as well
+
+
import ReactDataGridPlugins from 'react-data-grid/addons';
+
+
+
Using Distribution Scripts
+
If you prefer not to use a module system, you can reference the distribution scripts directly in your html pages. First you need to download the scripts. This can be done in 3 ways, either download directly from github source, using npm as above
+
+
<script src="//fb.me/react-0.14.6.js"></script> <script type="text/javascript" src="react-data-grid/dist/react-data-grid.js"></script>
+
+
+ And include react-data-grid.ui-plugins.js to use advanced features. Plugins will be availble on the ReactDataGridPlugins namespace
+
+
<script type="text/javascript" src="react-data-grid/dist/react-data-grid.ui-plugins.js"></script>"
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export default Home;
diff --git a/packages/react-data-grid-examples/src/components/Navbar.js b/packages/react-data-grid-examples/src/components/Navbar.js
index 15e3b084f3..d014d4f7f3 100644
--- a/packages/react-data-grid-examples/src/components/Navbar.js
+++ b/packages/react-data-grid-examples/src/components/Navbar.js
@@ -1,5 +1,6 @@
import React from 'react';
-import PropTypes from 'prop-types';
+import { Link } from 'react-router-dom';
+
import ExampleList from './ExampleList';
class Navbar extends React.Component {
@@ -8,37 +9,40 @@ class Navbar extends React.Component {
+
);
}
}
-Navbar.propTypes = {
- exampleLinks: PropTypes.array.isRequired
-};
-
export default Navbar;
diff --git a/packages/react-data-grid-examples/src/components/exampleWrapper.js b/packages/react-data-grid-examples/src/components/exampleWrapper.js
index e9e013c5cf..2c0b4b7fb6 100644
--- a/packages/react-data-grid-examples/src/components/exampleWrapper.js
+++ b/packages/react-data-grid-examples/src/components/exampleWrapper.js
@@ -27,7 +27,7 @@ const exampleWrapper = ({
Play around with it
{ exampleName }
- { exampleDescription }
+ { exampleDescription }
);
diff --git a/packages/react-data-grid-examples/src/documentation.html b/packages/react-data-grid-examples/src/documentation.html
deleted file mode 100644
index d7e74cbdae..0000000000
--- a/packages/react-data-grid-examples/src/documentation.html
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
-
-
-
-
-
-
- React Data Grid - Excel-like grid component built with React
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/packages/react-data-grid-examples/src/documentation.js b/packages/react-data-grid-examples/src/documentation.js
deleted file mode 100644
index 6bd6441d8c..0000000000
--- a/packages/react-data-grid-examples/src/documentation.js
+++ /dev/null
@@ -1,32 +0,0 @@
-var React = require('react');
-var ReactDOM = require('react-dom');
-var ReactRouter = require('react-router');
-
-var gettingStarted = require('./scripts/documentation01-gettingstarted');
-var apiReference = require('./scripts/documentation02-apireference');
-var componentsDocs = require('./scripts/documentation03-components');
-
-var { Route, RouteHandler } = ReactRouter;
-
-class App extends React.Component {
- render() {
- return (
-
-
Documentation
-
-
- );
- }
-}
-
-var routes = (
-
-
-
-
-
-);
-
-ReactRouter.run(routes, function (Handler) {
- ReactDOM.render(
, document.getElementById('documentation'));
-});
diff --git a/packages/react-data-grid-examples/src/examples.html b/packages/react-data-grid-examples/src/examples.html
deleted file mode 100644
index 0111754a7e..0000000000
--- a/packages/react-data-grid-examples/src/examples.html
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-
-
-
-
-
-
-
React Data Grid - Excel-like grid component built with React
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/packages/react-data-grid-examples/src/examples.js b/packages/react-data-grid-examples/src/examples.js
deleted file mode 100644
index 7a7899adc1..0000000000
--- a/packages/react-data-grid-examples/src/examples.js
+++ /dev/null
@@ -1,34 +0,0 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
-import ReactRouter, {Route, RouteHandler} from 'react-router';
-import ExampleList from './components/ExampleList';
-import ExampleScripts from './scripts';
-
-window.React = React;
-
-class App extends React.Component {
- render() {
- return (
-
-
React Data Grid Examples
-
-
- );
- }
-}
-
-let allRoutes = ExampleScripts.map(e => {
- let routeHandler = e.module;
- return
;
-});
-
-let routes = (
-
- {allRoutes}
-
-);
-
-ReactRouter.run(routes, function(Handler) {
- ReactDOM.render(
, document.getElementById('example'));
-});
-ReactDOM.render(
, document.getElementById('grid-examples-div'));
diff --git a/packages/react-data-grid-examples/src/examples.less b/packages/react-data-grid-examples/src/examples.less
deleted file mode 100644
index 3444e68566..0000000000
--- a/packages/react-data-grid-examples/src/examples.less
+++ /dev/null
@@ -1,2 +0,0 @@
-@import "node_modules/bootstrap/less/bootstrap.less";
-@import "themes/bootstrap.less";
diff --git a/packages/react-data-grid-examples/src/index.html b/packages/react-data-grid-examples/src/index.html
index d8677362c5..a4fda9b6eb 100644
--- a/packages/react-data-grid-examples/src/index.html
+++ b/packages/react-data-grid-examples/src/index.html
@@ -1,184 +1,48 @@
-
+
-
-
-
-
-
-
-
ReactData Grid - Excel-like grid component built with React
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
React Data Grid
-
Excel-like grid component built with React
-
- DEMO
- DOWNLOAD NOW
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Lightning Fast Rendering
-
-
Combines the performance power of React as well as partial rendering techniques in order to smoothly scroll though hundreds of thousands of rows.
-
-
-
-
Rich Editing and Formatting
-
-
View and edit cells using a wide range of formatters and editors. If these don't suit your needs, you can easily create and plugin your own
-
-
-
-
Configurable & Customizable
-
-
Quickly configure and customise features such as grid and column properties, row and cell renderers. As the Grid is a React component it is easy to extend and add custom functionality.
-
-
-
-
Packed full of Excel Features
-
-
Full keyboard navigation, cell copy & paste, cell drag down, frozen columns, column resizing, sorting, filtering and many more features on the way.
-
-
-
-
-
-
-
-
-
-
-
Check out these examples
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Quick Start
-
Installation
-
Using Common JS
-
React Data Grid is available in the npm repository. You can install it from the command line using the following commands
-
npm install react --save
-
npm install react-data-grid --save
-
Once downloaded, require both React and React Data Grid and you should be good to go
-
-
import React from 'react'; import ReactDataGrid from 'react-data-grid';
-
-
If you want to use extra features such as built in editors, formatters, toolbars and other plugins, you need to require the addons module as well
-
-
import ReactDataGridPlugins from 'react-data-grid/addons';
-
-
-
Using Distribution Scripts
-
If you prefer not to use a module system, you can reference the distribution scripts directly in your html pages. First you need to download the scripts. This can be done in 3 ways, either download directly from github source, using npm as above
-
-
<script src="//fb.me/react-0.14.6.js"></script> <script type="text/javascript" src="react-data-grid/dist/react-data-grid.js"></script>
-
-
- And include react-data-grid.ui-plugins.js to use advanced features. Plugins will be availble on the ReactDataGridPlugins namespace
-
-
<script type="text/javascript" src="react-data-grid/dist/react-data-grid.ui-plugins.js"></script>"
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
diff --git a/packages/react-data-grid-examples/src/index.js b/packages/react-data-grid-examples/src/index.js
index 0785acc799..edf7e83008 100644
--- a/packages/react-data-grid-examples/src/index.js
+++ b/packages/react-data-grid-examples/src/index.js
@@ -1,8 +1,11 @@
import React from 'react';
-import ReactDom from 'react-dom';
-import ExampleList from './components/ExampleList';
-import ExampleScripts from './scripts';
+import ReactDOM from 'react-dom';
+import { HashRouter as Router } from 'react-router-dom';
-window.React = React;
+import App from './components/App';
-ReactDom.render(
, document.getElementById('grid-examples-div'));
+ReactDOM.render((
+
+
+
+), document.getElementById('root'));
diff --git a/packages/react-data-grid-examples/src/scripts/documentation03-components.js b/packages/react-data-grid-examples/src/scripts/documentation03-components.js
index 2f00f64b3d..1f34cd4e1b 100644
--- a/packages/react-data-grid-examples/src/scripts/documentation03-components.js
+++ b/packages/react-data-grid-examples/src/scripts/documentation03-components.js
@@ -57,7 +57,7 @@ class ComponentDocs extends React.Component {
const className = key === this.state.selectedDocumentIndex ? 'active' : '';
const doc = generatedDocs[key];
docsToRender.push(
-
+
{doc.name}
);
}
diff --git a/packages/react-data-grid-examples/src/shared.js b/packages/react-data-grid-examples/src/shared.js
deleted file mode 100644
index b91a0b2b91..0000000000
--- a/packages/react-data-grid-examples/src/shared.js
+++ /dev/null
@@ -1,6 +0,0 @@
-import React from 'react';
-import ReactDom from 'react-dom';
-import Navbar from './components/Navbar';
-import ExampleScripts from './scripts';
-
-ReactDom.render(
, document.getElementById('navbarContainer'));
diff --git a/packages/react-data-grid/src/AppConstants.js b/packages/react-data-grid/src/AppConstants.js
index 07a761bffb..fd6411ee06 100644
--- a/packages/react-data-grid/src/AppConstants.js
+++ b/packages/react-data-grid/src/AppConstants.js
@@ -1,4 +1,4 @@
-import keyMirror from 'fbjs/lib/keyMirror';
+import keyMirror from 'keymirror';
const constants = {
UpdateActions: keyMirror({
diff --git a/packages/react-data-grid/src/Canvas.js b/packages/react-data-grid/src/Canvas.js
index 7cc0894781..c39fe0b750 100644
--- a/packages/react-data-grid/src/Canvas.js
+++ b/packages/react-data-grid/src/Canvas.js
@@ -7,7 +7,7 @@ const RowUtils = require('./RowUtils');
import { createScrollShim } from './utils/scrollUtils';
require('../../../themes/react-data-grid-core.css');
-import shallowEqual from 'fbjs/lib/shallowEqual';
+import shallowEqual from 'shallowequal';
import RowsContainer from './RowsContainer';
import RowGroup from './RowGroup';
diff --git a/packages/react-data-grid/src/HeaderRow.js b/packages/react-data-grid/src/HeaderRow.js
index 7f6e107eea..72108455bb 100644
--- a/packages/react-data-grid/src/HeaderRow.js
+++ b/packages/react-data-grid/src/HeaderRow.js
@@ -1,5 +1,5 @@
const React = require('react');
-const shallowEqual = require('fbjs/lib/shallowEqual');
+const shallowEqual = require('shallowequal');
const BaseHeaderCell = require('./HeaderCell');
const getScrollbarSize = require('./getScrollbarSize');
const ExcelColumn = require('./PropTypeShapes/ExcelColumn');
diff --git a/packages/react-data-grid/src/__tests__/Canvas.spec.js b/packages/react-data-grid/src/__tests__/Canvas.spec.js
index d09f830bb6..3d2780cafe 100644
--- a/packages/react-data-grid/src/__tests__/Canvas.spec.js
+++ b/packages/react-data-grid/src/__tests__/Canvas.spec.js
@@ -37,7 +37,7 @@ describe('Canvas Tests', () => {
beforeEach(() => {
testElement = renderComponent();
- testElementNode = testElement.node;
+ testElementNode = testElement.instance();
});
it('should create a new instance of Canvas', () => {
diff --git a/packages/react-data-grid/src/__tests__/Cell.spec.js b/packages/react-data-grid/src/__tests__/Cell.spec.js
index b6ec8d65e0..67d8582fc6 100644
--- a/packages/react-data-grid/src/__tests__/Cell.spec.js
+++ b/packages/react-data-grid/src/__tests__/Cell.spec.js
@@ -119,7 +119,7 @@ describe('Cell Tests', () => {
}
});
- expect(testElement.node.isDraggedCellChanging(DEFAULT_NEXT_PROPS)).toBeFalsy();
+ expect(testElement.instance().isDraggedCellChanging(DEFAULT_NEXT_PROPS)).toBeFalsy();
});
it('should be true if the cell is about to be dragged', () => {
@@ -137,7 +137,7 @@ describe('Cell Tests', () => {
}
});
- expect(testElement.node.isDraggedCellChanging(nextProps)).toBeTruthy();
+ expect(testElement.instance().isDraggedCellChanging(nextProps)).toBeTruthy();
});
it('should be true if the cell is currently dragged ', () => {
@@ -149,7 +149,7 @@ describe('Cell Tests', () => {
}
});
- expect(testElement.node.isDraggedCellChanging(DEFAULT_NEXT_PROPS)).toBeTruthy();
+ expect(testElement.instance().isDraggedCellChanging(DEFAULT_NEXT_PROPS)).toBeTruthy();
});
it('should be false if the cell is not currently dragged and not about to be dragged', () => {
@@ -169,7 +169,7 @@ describe('Cell Tests', () => {
}
});
- expect(testElement.node.isDraggedCellChanging(nextProps)).toBeFalsy();
+ expect(testElement.instance().isDraggedCellChanging(nextProps)).toBeFalsy();
});
it('should render null when hidden', () => {
@@ -182,7 +182,7 @@ describe('Cell Tests', () => {
describe('hasChangedDependentValues tests', () => {
describe('when column getRowMetaData is not defined', () => {
it('should return false', () => {
- expect(testElement.node.hasChangedDependentValues()).toBeFalsy();
+ expect(testElement.instance().hasChangedDependentValues()).toBeFalsy();
});
});
@@ -198,7 +198,7 @@ describe('Cell Tests', () => {
it('should return false when the dependentValues are equal', () => {
let nextProps = propsWithColumnGetRowMetaData;
- expect(testElement.node.hasChangedDependentValues(nextProps)).toBeFalsy();
+ expect(testElement.instance().hasChangedDependentValues(nextProps)).toBeFalsy();
});
it('should return true when the dependentValues are different', () => {
@@ -207,7 +207,7 @@ describe('Cell Tests', () => {
propsWithColumnGetRowMetaData,
{ rowData: { name: 'Johnny Test', location: 'Wicklow', likesTesting: 'Every Day!' }});
- expect(testElement.node.hasChangedDependentValues(nextProps)).toBeTruthy();
+ expect(testElement.instance().hasChangedDependentValues(nextProps)).toBeTruthy();
});
});
});
@@ -224,7 +224,7 @@ describe('Cell Tests', () => {
it('should be true if no cell is selected', () => {
testElement = renderComponent(getSelectedCellMetadata(undefined));
- expect(testElement.node.isCellSelectionChanging(DEFAULT_NEXT_PROPS)).toBeTruthy();
+ expect(testElement.instance().isCellSelectionChanging(DEFAULT_NEXT_PROPS)).toBeTruthy();
});
it('should be false if no cell will be selected', () => {
@@ -232,7 +232,7 @@ describe('Cell Tests', () => {
let nextProps = Object.assign({}, DEFAULT_NEXT_PROPS, getSelectedCellMetadata(undefined));
- expect(testElement.node.isCellSelectionChanging(nextProps)).toBeTruthy();
+ expect(testElement.instance().isCellSelectionChanging(nextProps)).toBeTruthy();
});
it('should be true when the next selected cell is the current cell', () => {
@@ -240,7 +240,7 @@ describe('Cell Tests', () => {
let nextProps = Object.assign({}, DEFAULT_NEXT_PROPS, getSelectedCellMetadata({ idx: testProps.idx }));
- expect(testElement.node.isCellSelectionChanging(nextProps)).toBeTruthy();
+ expect(testElement.instance().isCellSelectionChanging(nextProps)).toBeTruthy();
});
it('should be true when the current cell is selected', () => {
@@ -248,7 +248,7 @@ describe('Cell Tests', () => {
let nextProps = Object.assign({}, DEFAULT_NEXT_PROPS, getSelectedCellMetadata({ idx: testProps.idx }));
- expect(testElement.node.isCellSelectionChanging(nextProps)).toBeTruthy();
+ expect(testElement.instance().isCellSelectionChanging(nextProps)).toBeTruthy();
});
it('should be false when current cell is not selected and is not going to be selected', () => {
@@ -256,7 +256,7 @@ describe('Cell Tests', () => {
let nextProps = Object.assign({}, DEFAULT_NEXT_PROPS, getSelectedCellMetadata({ idx: testProps.idx - 1}));
- expect(testElement.node.isCellSelectionChanging(nextProps)).toBeFalsy();
+ expect(testElement.instance().isCellSelectionChanging(nextProps)).toBeFalsy();
});
});
@@ -272,7 +272,7 @@ describe('Cell Tests', () => {
it('should be false if there is no copied cell', () => {
testElement = renderComponent(getCopiedCellMetadata(undefined));
- expect(testElement.node.isCopyCellChanging(DEFAULT_NEXT_PROPS)).toBeFalsy();
+ expect(testElement.instance().isCopyCellChanging(DEFAULT_NEXT_PROPS)).toBeFalsy();
});
it('should be true if the next copied cell is the current cell', () => {
@@ -280,7 +280,7 @@ describe('Cell Tests', () => {
let nextProps = Object.assign({}, DEFAULT_NEXT_PROPS, getCopiedCellMetadata({ idx: testProps.idx }));
- expect(testElement.node.isCopyCellChanging(nextProps)).toBeTruthy();
+ expect(testElement.instance().isCopyCellChanging(nextProps)).toBeTruthy();
});
it('should be true if the current cell is copied', () => {
@@ -288,7 +288,7 @@ describe('Cell Tests', () => {
let nextProps = Object.assign({}, DEFAULT_NEXT_PROPS, getCopiedCellMetadata({ idx: testProps.idx + 1}));
- expect(testElement.node.isCopyCellChanging(nextProps)).toBeTruthy();
+ expect(testElement.instance().isCopyCellChanging(nextProps)).toBeTruthy();
});
it('should be false if the current cell is not copied and is not about to be copied', () => {
@@ -296,7 +296,7 @@ describe('Cell Tests', () => {
let nextProps = Object.assign({}, DEFAULT_NEXT_PROPS, getCopiedCellMetadata({ idx: testProps.idx + 1}));
- expect(testElement.node.isCopyCellChanging(nextProps)).toBeFalsy();
+ expect(testElement.instance().isCopyCellChanging(nextProps)).toBeFalsy();
});
});
@@ -357,7 +357,9 @@ describe('Cell Tests', () => {
// force update
let newValue = 'London';
testElement.setProps({ value: newValue, selectedColumn: testProps.column });
- let cellHasUpdateClass = testElement.find('.react-grid-Cell').hasClass(UPDATE_CLASS);
+ // TODO: why the updated class is not reflected when the element is searched using the find method
+ // let cellHasUpdateClass = testElement.find('.react-grid-Cell').hasClass(UPDATE_CLASS);
+ let cellHasUpdateClass = testElement.getDOMNode().className.indexOf(UPDATE_CLASS) > -1;
expect(cellHasUpdateClass).toBeTruthy();
});
@@ -365,7 +367,7 @@ describe('Cell Tests', () => {
let cellEvents;
beforeEach(() => {
- cellEvents = testElement.node.getEvents();
+ cellEvents = testElement.instance().getEvents();
});
it('should have a onClick event associated', () => {
@@ -401,7 +403,7 @@ describe('Cell Tests', () => {
});
it('should call metaData onDragHandleDoubleClick when it is defined', () => {
- let cellInstance = testElement.node;
+ let cellInstance = testElement.instance();
cellInstance.onDragHandleDoubleClick(document.createEvent('Event'));
@@ -409,7 +411,7 @@ describe('Cell Tests', () => {
});
it('should call metaData onCellContextMenu if defined', () => {
- let cellInstance = testElement.node;
+ let cellInstance = testElement.instance();
cellInstance.onCellContextMenu();
@@ -455,7 +457,7 @@ describe('Cell Tests', () => {
});
testElement = renderComponent({ column, cellMetaData });
- cellEvents = testElement.node.getEvents();
+ cellEvents = testElement.instance().getEvents();
});
afterEach(() => {
@@ -538,7 +540,7 @@ describe('Cell Tests', () => {
it('focuses on the cell when document has no active element', () => {
const enzymeWrapper = renderCellComponent(getProps({ enableCellAutoFocus }));
spyOn(document, 'activeElement').and.returnValue(null);
- const cellDiv = enzymeWrapper.find('div').at(0).node;
+ const cellDiv = enzymeWrapper.find('div').at(0).instance();
spyOn(cellDiv, 'focus');
enzymeWrapper.instance().checkFocus();
expect(cellDiv.focus).toHaveBeenCalled();
@@ -546,7 +548,7 @@ describe('Cell Tests', () => {
it('focuses on the cell when document is focused on body and cell autofocus is enabled', () => {
const enzymeWrapper = renderCellComponent(getProps({ enableCellAutoFocus }));
spyOn(document, 'activeElement').and.returnValue({ nodeName: 'body' });
- const cellDiv = enzymeWrapper.find('div').at(0).node;
+ const cellDiv = enzymeWrapper.find('div').at(0).instance();
spyOn(cellDiv, 'focus');
enzymeWrapper.instance().checkFocus();
expect(cellDiv.focus).toHaveBeenCalled();
@@ -557,7 +559,7 @@ describe('Cell Tests', () => {
it('does not focus on the cell when document has no active element', () => {
const enzymeWrapper = renderCellComponent(getProps({ enableCellAutoFocus }));
spyOn(document, 'activeElement').and.returnValue(null);
- const cellDiv = enzymeWrapper.find('div').at(0).node;
+ const cellDiv = enzymeWrapper.find('div').at(0).instance();
spyOn(cellDiv, 'focus');
enzymeWrapper.instance().checkFocus();
expect(cellDiv.focus).not.toHaveBeenCalled();
@@ -565,7 +567,7 @@ describe('Cell Tests', () => {
it('does not focus on the cell when document is focused on body and cell autofocus is enabled', () => {
const enzymeWrapper = renderCellComponent(getProps({ enableCellAutoFocus }));
spyOn(document, 'activeElement').and.returnValue({ nodeName: 'body' });
- const cellDiv = enzymeWrapper.find('div').at(0).node;
+ const cellDiv = enzymeWrapper.find('div').at(0).instance();
spyOn(cellDiv, 'focus');
enzymeWrapper.instance().checkFocus();
expect(cellDiv.focus).not.toHaveBeenCalled();
diff --git a/packages/react-data-grid/src/__tests__/FocusableComponentTestRunner.js b/packages/react-data-grid/src/__tests__/FocusableComponentTestRunner.js
index 01f293fccc..a2d73a4ca5 100644
--- a/packages/react-data-grid/src/__tests__/FocusableComponentTestRunner.js
+++ b/packages/react-data-grid/src/__tests__/FocusableComponentTestRunner.js
@@ -1,5 +1,5 @@
import React from 'react';
-import { mount, shallow } from 'enzyme';
+import { mount } from 'enzyme';
const COMPONENT_DID_MOUNT_SOURCE = 'CDM';
const COMPONENT_DID_UPDATE_SOURCE = 'CDU';
@@ -112,13 +112,6 @@ class FocusableComponentTestRunner {
expect(this.componentPrototype.focus).not.toHaveBeenCalled();
});
-
- it('should focus when scrolling and selected', () => {
- let cellMetaData = Object.assign({ }, this._props.cellMetaData, { isScrollingVerticallyWithKeyboard: true, isScrollingHorizontallyWithKeyboard: true });
- this._componentWrapper = shallow(
, { lifecycleExperimental: true });
- this._componentWrapper.setProps({cellMetaData});
- expect(this.componentPrototype.focus).toHaveBeenCalled();
- });
}
_addFocusBeforeEach() {
diff --git a/packages/react-data-grid/src/__tests__/OverflowCell.spec.js b/packages/react-data-grid/src/__tests__/OverflowCell.spec.js
index a79a72b7ff..34ea194b0f 100644
--- a/packages/react-data-grid/src/__tests__/OverflowCell.spec.js
+++ b/packages/react-data-grid/src/__tests__/OverflowCell.spec.js
@@ -1,5 +1,4 @@
import React from 'react';
-import ReactDOM from 'react-dom';
import { mount } from 'enzyme';
import OverflowCell, { OverflowCellComponent } from '../OverflowCell';
import FocusableComponentTestRunner from './FocusableComponentTestRunner';
@@ -25,11 +24,11 @@ describe('OverflowCell', () => {
});
it('should render without crashing', () => {
- expect(overflowCellElementWrapper.node).toBeDefined();
+ expect(overflowCellElementWrapper.instance()).toBeDefined();
});
it('render with the correct style based on props', () => {
- let domNode = ReactDOM.findDOMNode(overflowCellElementWrapper.component);
+ let domNode = overflowCellElementWrapper.getDOMNode();
const { width, height, left } = domNode.style;
diff --git a/packages/react-data-grid/src/__tests__/OverflowRow.spec.js b/packages/react-data-grid/src/__tests__/OverflowRow.spec.js
index f0f0d79e9c..93f1f87f3a 100644
--- a/packages/react-data-grid/src/__tests__/OverflowRow.spec.js
+++ b/packages/react-data-grid/src/__tests__/OverflowRow.spec.js
@@ -15,7 +15,7 @@ describe('OverflowRow', () => {
describe('render tests', () => {
it('should render without crashing', () => {
const overflowCellElementWrapper = mount(
);
- expect(overflowCellElementWrapper.node).toBeDefined();
+ expect(overflowCellElementWrapper.instance()).toBeDefined();
});
});
diff --git a/packages/react-data-grid/src/editors/__tests__/CheckboxEditor.spec.js b/packages/react-data-grid/src/editors/__tests__/CheckboxEditor.spec.js
index 8cc30a4090..9c4ef4e771 100644
--- a/packages/react-data-grid/src/editors/__tests__/CheckboxEditor.spec.js
+++ b/packages/react-data-grid/src/editors/__tests__/CheckboxEditor.spec.js
@@ -19,7 +19,7 @@ describe('CheckboxEditor', () => {
value={true}
rowIdx={1}
column={testColumn}/>);
- component = componentWrapper.node;
+ component = componentWrapper.instance();
});
it('should create a new CheckboxEditor instance', () => {
diff --git a/packages/react-data-grid/src/editors/__tests__/SimpleTextEditor.spec.js b/packages/react-data-grid/src/editors/__tests__/SimpleTextEditor.spec.js
index ac09631bae..93ce569a9d 100644
--- a/packages/react-data-grid/src/editors/__tests__/SimpleTextEditor.spec.js
+++ b/packages/react-data-grid/src/editors/__tests__/SimpleTextEditor.spec.js
@@ -16,7 +16,7 @@ describe('SimpleTextEditor', () => {
onKeyDown={fakeFunction}
commit={fakeFunction}
column={fakeColumn}
- />).node;
+ />).instance();
});
it('should create a new SimpleTextEditor instance', () => {
diff --git a/test/FullTests.jsx b/test/FullTests.jsx
index 71d89c0082..1ceb64eb08 100644
--- a/test/FullTests.jsx
+++ b/test/FullTests.jsx
@@ -1,2 +1,10 @@
-var testsContext = require.context("../packages", true, /^.*\.(spec|integration-spec)$/);
+const Enzyme = require('enzyme');
+const Adapter = require('enzyme-adapter-react-16');
+
+Enzyme.configure({
+ adapter: new Adapter(),
+ disableLifecycleMethods: true
+});
+
+const testsContext = require.context("../packages", true, /^.*\.(spec|integration-spec)$/);
testsContext.keys().forEach(testsContext);
diff --git a/test/StubComponent.js b/test/StubComponent.js
index c719b17d0c..550b170cca 100644
--- a/test/StubComponent.js
+++ b/test/StubComponent.js
@@ -1,10 +1,9 @@
-var React = require('react');
+import React from 'react';
-module.exports = function(mockTagName: string){
+module.exports = function(mockTagName) {
return class extends React.Component {
- render () {
- var mockTagName = mockTagName || "div";
- return React.DOM[mockTagName](null, this.props.children);
+ render() {
+ return React.createFactory(mockTagName || 'div', this.props);
}
};
};
diff --git a/webpack-dev-server.js b/webpack-dev-server.js
index 2343c224bc..b349a6ef71 100644
--- a/webpack-dev-server.js
+++ b/webpack-dev-server.js
@@ -4,10 +4,7 @@ const webpack = require('webpack');
const specificConfig = {
entry: {
- index: ['./packages/react-data-grid-examples/src/index.js'],
- shared: ['./packages/react-data-grid-examples/src/shared.js'],
- examples: ['./packages/react-data-grid-examples/src/examples.js'],
- documentation: ['./packages/react-data-grid-examples/src/documentation.js']
+ index: ['./packages/react-data-grid-examples/src']
},
output: {
path: '/packages/react-data-grid-examples/src/',
@@ -30,8 +27,6 @@ const specificConfig = {
const config = Object.assign({ }, webpackCommon, specificConfig);
config.entry.index.unshift('webpack-dev-server/client?http://localhost:8080/', 'webpack/hot/dev-server');
-config.entry.shared.unshift('webpack-dev-server/client?http://localhost:8080/', 'webpack/hot/dev-server');
-config.entry.examples.unshift('webpack-dev-server/client?http://localhost:8080/', 'webpack/hot/dev-server');
const compiler = webpack(config);
const server = new WebpackDevServer(compiler, {