@deephaven/grid 0.7.3-beta.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CellInputField.d.ts +4 -4
- package/dist/CellInputField.d.ts.map +1 -1
- package/dist/CellInputField.js +10 -11
- package/dist/CellInputField.js.map +1 -1
- package/dist/EditableGridModel.d.ts +70 -0
- package/dist/EditableGridModel.d.ts.map +1 -0
- package/dist/EditableGridModel.js +13 -0
- package/dist/EditableGridModel.js.map +1 -0
- package/dist/EventHandlerResult.d.ts +17 -0
- package/dist/EventHandlerResult.d.ts.map +1 -0
- package/dist/EventHandlerResult.js +2 -0
- package/dist/EventHandlerResult.js.map +1 -0
- package/dist/ExpandableGridModel.d.ts +34 -0
- package/dist/ExpandableGridModel.d.ts.map +1 -0
- package/dist/ExpandableGridModel.js +7 -0
- package/dist/ExpandableGridModel.js.map +1 -0
- package/dist/Grid.d.ts +283 -234
- package/dist/Grid.d.ts.map +1 -1
- package/dist/Grid.js +397 -165
- package/dist/Grid.js.map +1 -1
- package/dist/GridColorUtils.d.ts +22 -12
- package/dist/GridColorUtils.d.ts.map +1 -1
- package/dist/GridColorUtils.js +26 -21
- package/dist/GridColorUtils.js.map +1 -1
- package/dist/GridMetricCalculator.d.ts.map +1 -1
- package/dist/GridMetricCalculator.js +8 -4
- package/dist/GridMetricCalculator.js.map +1 -1
- package/dist/GridModel.d.ts +54 -60
- package/dist/GridModel.d.ts.map +1 -1
- package/dist/GridModel.js +54 -122
- package/dist/GridModel.js.map +1 -1
- package/dist/GridMouseHandler.d.ts +23 -24
- package/dist/GridMouseHandler.d.ts.map +1 -1
- package/dist/GridMouseHandler.js +8 -14
- package/dist/GridMouseHandler.js.map +1 -1
- package/dist/GridRange.d.ts +2 -2
- package/dist/GridRange.d.ts.map +1 -1
- package/dist/GridRange.js +1 -1
- package/dist/GridRange.js.map +1 -1
- package/dist/GridRenderer.d.ts +117 -69
- package/dist/GridRenderer.d.ts.map +1 -1
- package/dist/GridRenderer.js +183 -168
- package/dist/GridRenderer.js.map +1 -1
- package/dist/GridUtils.d.ts +4 -4
- package/dist/GridUtils.js +4 -4
- package/dist/GridUtils.js.map +1 -1
- package/dist/KeyHandler.d.ts +10 -7
- package/dist/KeyHandler.d.ts.map +1 -1
- package/dist/KeyHandler.js +6 -5
- package/dist/KeyHandler.js.map +1 -1
- package/dist/MockGridData.d.ts +1 -1
- package/dist/MockGridData.d.ts.map +1 -1
- package/dist/MockGridData.js.map +1 -1
- package/dist/MockGridModel.d.ts +39 -12
- package/dist/MockGridModel.d.ts.map +1 -1
- package/dist/MockGridModel.js +43 -10
- package/dist/MockGridModel.js.map +1 -1
- package/dist/MockTreeGridModel.d.ts +37 -22
- package/dist/MockTreeGridModel.d.ts.map +1 -1
- package/dist/MockTreeGridModel.js +38 -20
- package/dist/MockTreeGridModel.js.map +1 -1
- package/dist/errors/AssertionError.d.ts +5 -0
- package/dist/errors/AssertionError.d.ts.map +1 -0
- package/dist/errors/AssertionError.js +12 -0
- package/dist/errors/AssertionError.js.map +1 -0
- package/dist/errors/PasteError.d.ts +1 -1
- package/dist/errors/PasteError.d.ts.map +1 -1
- package/dist/errors/PasteError.js +1 -2
- package/dist/errors/PasteError.js.map +1 -1
- package/dist/errors/assertIsDefined.d.ts +3 -0
- package/dist/errors/assertIsDefined.d.ts.map +1 -0
- package/dist/errors/assertIsDefined.js +8 -0
- package/dist/errors/assertIsDefined.js.map +1 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +2 -1
- package/dist/errors/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/key-handlers/EditKeyHandler.d.ts +3 -2
- package/dist/key-handlers/EditKeyHandler.d.ts.map +1 -1
- package/dist/key-handlers/EditKeyHandler.js +10 -9
- package/dist/key-handlers/EditKeyHandler.js.map +1 -1
- package/dist/key-handlers/PasteKeyHandler.d.ts +3 -5
- package/dist/key-handlers/PasteKeyHandler.d.ts.map +1 -1
- package/dist/key-handlers/PasteKeyHandler.js +3 -3
- package/dist/key-handlers/PasteKeyHandler.js.map +1 -1
- package/dist/key-handlers/SelectionKeyHandler.d.ts +5 -5
- package/dist/key-handlers/SelectionKeyHandler.d.ts.map +1 -1
- package/dist/key-handlers/SelectionKeyHandler.js +16 -15
- package/dist/key-handlers/SelectionKeyHandler.js.map +1 -1
- package/dist/key-handlers/TreeKeyHandler.d.ts +2 -2
- package/dist/key-handlers/TreeKeyHandler.d.ts.map +1 -1
- package/dist/key-handlers/TreeKeyHandler.js +14 -12
- package/dist/key-handlers/TreeKeyHandler.js.map +1 -1
- package/dist/memoizeClear.d.ts +13 -3
- package/dist/memoizeClear.d.ts.map +1 -1
- package/dist/memoizeClear.js +7 -7
- package/dist/memoizeClear.js.map +1 -1
- package/dist/mouse-handlers/EditMouseHandler.d.ts +3 -4
- package/dist/mouse-handlers/EditMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/EditMouseHandler.js +3 -2
- package/dist/mouse-handlers/EditMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridColumnMoveMouseHandler.d.ts +12 -5
- package/dist/mouse-handlers/GridColumnMoveMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridColumnMoveMouseHandler.js +13 -10
- package/dist/mouse-handlers/GridColumnMoveMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.d.ts +24 -3
- package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.js +2 -1
- package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridHorizontalScrollBarMouseHandler.d.ts +16 -6
- package/dist/mouse-handlers/GridHorizontalScrollBarMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridHorizontalScrollBarMouseHandler.js +41 -37
- package/dist/mouse-handlers/GridHorizontalScrollBarMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowMoveMouseHandler.d.ts +10 -3
- package/dist/mouse-handlers/GridRowMoveMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridRowMoveMouseHandler.js +14 -11
- package/dist/mouse-handlers/GridRowMoveMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.d.ts +24 -3
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.js +4 -3
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowTreeMouseHandler.d.ts +8 -3
- package/dist/mouse-handlers/GridRowTreeMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridRowTreeMouseHandler.js +12 -7
- package/dist/mouse-handlers/GridRowTreeMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridScrollBarCornerMouseHandler.d.ts +9 -3
- package/dist/mouse-handlers/GridScrollBarCornerMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridScrollBarCornerMouseHandler.js +2 -1
- package/dist/mouse-handlers/GridScrollBarCornerMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridSelectionMouseHandler.d.ts +15 -9
- package/dist/mouse-handlers/GridSelectionMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridSelectionMouseHandler.js +26 -16
- package/dist/mouse-handlers/GridSelectionMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridSeparatorMouseHandler.d.ts +46 -28
- package/dist/mouse-handlers/GridSeparatorMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridSeparatorMouseHandler.js +57 -74
- package/dist/mouse-handlers/GridSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridVerticalScrollBarMouseHandler.d.ts +16 -6
- package/dist/mouse-handlers/GridVerticalScrollBarMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridVerticalScrollBarMouseHandler.js +41 -37
- package/dist/mouse-handlers/GridVerticalScrollBarMouseHandler.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/Grid.js
CHANGED
|
@@ -12,21 +12,21 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
12
12
|
import React, { PureComponent } from 'react';
|
|
13
13
|
import classNames from 'classnames';
|
|
14
14
|
import memoize from 'memoize-one';
|
|
15
|
-
import PropTypes from 'prop-types';
|
|
16
15
|
import clamp from 'lodash.clamp';
|
|
17
16
|
import GridMetricCalculator from "./GridMetricCalculator.js";
|
|
18
|
-
import GridModel from "./GridModel.js";
|
|
19
|
-
import GridMouseHandler from "./GridMouseHandler.js";
|
|
20
17
|
import GridTheme from "./GridTheme.js";
|
|
21
|
-
import GridRange from "./GridRange.js";
|
|
18
|
+
import GridRange, { SELECTION_DIRECTION } from "./GridRange.js";
|
|
22
19
|
import GridRenderer from "./GridRenderer.js";
|
|
23
20
|
import GridUtils from "./GridUtils.js";
|
|
24
21
|
import { GridSelectionMouseHandler, GridColumnMoveMouseHandler, GridColumnSeparatorMouseHandler, GridHorizontalScrollBarMouseHandler, GridRowMoveMouseHandler, GridRowSeparatorMouseHandler, GridRowTreeMouseHandler, GridScrollBarCornerMouseHandler, GridVerticalScrollBarMouseHandler, EditMouseHandler } from "./mouse-handlers/index.js";
|
|
25
22
|
import "./Grid.css";
|
|
26
|
-
import KeyHandler from "./KeyHandler.js";
|
|
27
23
|
import { EditKeyHandler, PasteKeyHandler, SelectionKeyHandler, TreeKeyHandler } from "./key-handlers/index.js";
|
|
28
24
|
import CellInputField from "./CellInputField.js";
|
|
29
25
|
import PasteError from "./errors/PasteError.js";
|
|
26
|
+
import { isExpandableGridModel } from "./ExpandableGridModel.js";
|
|
27
|
+
import { assertIsEditableGridModel, isEditableGridModel } from "./EditableGridModel.js";
|
|
28
|
+
import { assertIsDefined } from "./errors/index.js";
|
|
29
|
+
|
|
30
30
|
/**
|
|
31
31
|
* High performance, extendible, themeable grid component.
|
|
32
32
|
* Architectured to be fast and handle billions of rows/columns by default.
|
|
@@ -41,23 +41,66 @@ import PasteError from "./errors/PasteError.js";
|
|
|
41
41
|
* Add an onViewChanged callback to page in/out data as user moves around the grid
|
|
42
42
|
* Can also add onClick and onContextMenu handlers to add custom functionality and menus.
|
|
43
43
|
*/
|
|
44
|
-
|
|
45
44
|
class Grid extends PureComponent {
|
|
46
45
|
// use same constant as chrome source for windows
|
|
47
46
|
// https://github.com/chromium/chromium/blob/973af9d461b6b5dc60208c8d3d66adc27e53da78/ui/events/blink/web_input_event_builders_win.cc#L285
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* On some devices there may be different scaling required for high DPI. Get the scale required for the canvas.
|
|
50
|
+
* @param context The canvas context
|
|
51
|
+
* @returns The scale to use
|
|
52
|
+
*/
|
|
48
53
|
static getScale(context) {
|
|
49
|
-
var devicePixelRatio = window.devicePixelRatio || 1;
|
|
50
|
-
|
|
54
|
+
var devicePixelRatio = window.devicePixelRatio || 1; // backingStorePixelRatio is deprecated, but check it just in case
|
|
55
|
+
|
|
56
|
+
var legacyContext = context;
|
|
57
|
+
var backingStorePixelRatio = legacyContext.webkitBackingStorePixelRatio || legacyContext.mozBackingStorePixelRatio || legacyContext.msBackingStorePixelRatio || legacyContext.oBackingStorePixelRatio || legacyContext.backingStorePixelRatio || 1;
|
|
51
58
|
return devicePixelRatio / backingStorePixelRatio;
|
|
52
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Get the class name from the cursor provided
|
|
62
|
+
* @param cursor The grid cursor to use
|
|
63
|
+
* @returns Class name with the grid-cursor prefix or null if no cursor provided
|
|
64
|
+
*/
|
|
65
|
+
|
|
53
66
|
|
|
54
67
|
static getCursorClassName(cursor) {
|
|
55
68
|
return cursor ? "grid-cursor-".concat(cursor) : null;
|
|
56
|
-
}
|
|
69
|
+
} // Need to disable react/sort-comp so I can put the fields here
|
|
70
|
+
|
|
71
|
+
/* eslint-disable react/sort-comp */
|
|
57
72
|
|
|
73
|
+
|
|
74
|
+
/* eslint-enable react/sort-comp */
|
|
58
75
|
constructor(props) {
|
|
59
76
|
super(props);
|
|
60
77
|
|
|
78
|
+
_defineProperty(this, "renderer", void 0);
|
|
79
|
+
|
|
80
|
+
_defineProperty(this, "metricCalculator", void 0);
|
|
81
|
+
|
|
82
|
+
_defineProperty(this, "canvas", void 0);
|
|
83
|
+
|
|
84
|
+
_defineProperty(this, "canvasContext", void 0);
|
|
85
|
+
|
|
86
|
+
_defineProperty(this, "animationFrame", void 0);
|
|
87
|
+
|
|
88
|
+
_defineProperty(this, "prevMetrics", void 0);
|
|
89
|
+
|
|
90
|
+
_defineProperty(this, "metrics", void 0);
|
|
91
|
+
|
|
92
|
+
_defineProperty(this, "isStuckToBottom", void 0);
|
|
93
|
+
|
|
94
|
+
_defineProperty(this, "isStuckToRight", void 0);
|
|
95
|
+
|
|
96
|
+
_defineProperty(this, "documentCursor", void 0);
|
|
97
|
+
|
|
98
|
+
_defineProperty(this, "dragTimer", void 0);
|
|
99
|
+
|
|
100
|
+
_defineProperty(this, "keyHandlers", void 0);
|
|
101
|
+
|
|
102
|
+
_defineProperty(this, "mouseHandlers", void 0);
|
|
103
|
+
|
|
61
104
|
_defineProperty(this, "getCachedKeyHandlers", memoize(keyHandlers => [...keyHandlers, ...this.keyHandlers].sort((a, b) => a.order - b.order)));
|
|
62
105
|
|
|
63
106
|
_defineProperty(this, "getCachedMouseHandlers", memoize(mouseHandlers => [...mouseHandlers, ...this.mouseHandlers].sort((a, b) => a.order - b.order)));
|
|
@@ -148,11 +191,13 @@ class Grid extends PureComponent {
|
|
|
148
191
|
}
|
|
149
192
|
|
|
150
193
|
componentDidMount() {
|
|
194
|
+
var _this$canvas;
|
|
195
|
+
|
|
151
196
|
this.initContext(); // Need to explicitly add wheel event to canvas so we can preventDefault/avoid passive listener issue
|
|
152
197
|
// Otherwise React attaches listener at doc level and you can't prevent default
|
|
153
198
|
// https://github.com/facebook/react/issues/14856
|
|
154
199
|
|
|
155
|
-
this.canvas.addEventListener('wheel', this.handleWheel, {
|
|
200
|
+
(_this$canvas = this.canvas) === null || _this$canvas === void 0 ? void 0 : _this$canvas.addEventListener('wheel', this.handleWheel, {
|
|
156
201
|
passive: false
|
|
157
202
|
});
|
|
158
203
|
window.addEventListener('resize', this.handleResize);
|
|
@@ -167,20 +212,25 @@ class Grid extends PureComponent {
|
|
|
167
212
|
movedColumns,
|
|
168
213
|
movedRows,
|
|
169
214
|
onMovedColumnsChanged,
|
|
170
|
-
onMoveColumnComplete
|
|
215
|
+
onMoveColumnComplete,
|
|
216
|
+
onMovedRowsChanged,
|
|
217
|
+
onMoveRowComplete
|
|
171
218
|
} = this.props;
|
|
172
219
|
var {
|
|
173
220
|
isStickyBottom: prevIsStickyBottom,
|
|
174
221
|
isStickyRight: prevIsStickyRight,
|
|
175
222
|
movedColumns: prevPropMovedColumns,
|
|
176
|
-
movedRows:
|
|
223
|
+
movedRows: prevPropMovedRows
|
|
177
224
|
} = prevProps;
|
|
178
225
|
var {
|
|
179
|
-
movedColumns: prevStateMovedColumns
|
|
226
|
+
movedColumns: prevStateMovedColumns,
|
|
227
|
+
movedRows: prevStateMovedRows
|
|
180
228
|
} = prevState;
|
|
181
229
|
var {
|
|
182
230
|
draggingColumn,
|
|
183
|
-
|
|
231
|
+
draggingRow,
|
|
232
|
+
movedColumns: currentStateMovedColumns,
|
|
233
|
+
movedRows: currentStateMovedRows
|
|
184
234
|
} = this.state;
|
|
185
235
|
|
|
186
236
|
if (prevPropMovedColumns !== movedColumns) {
|
|
@@ -189,7 +239,7 @@ class Grid extends PureComponent {
|
|
|
189
239
|
});
|
|
190
240
|
}
|
|
191
241
|
|
|
192
|
-
if (
|
|
242
|
+
if (prevPropMovedRows !== movedRows) {
|
|
193
243
|
this.setState({
|
|
194
244
|
movedRows
|
|
195
245
|
});
|
|
@@ -203,6 +253,14 @@ class Grid extends PureComponent {
|
|
|
203
253
|
onMoveColumnComplete(currentStateMovedColumns);
|
|
204
254
|
}
|
|
205
255
|
|
|
256
|
+
if (prevStateMovedRows !== currentStateMovedRows) {
|
|
257
|
+
onMovedRowsChanged(currentStateMovedRows);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (prevState.draggingRow != null && draggingRow == null) {
|
|
261
|
+
onMoveRowComplete(currentStateMovedRows);
|
|
262
|
+
}
|
|
263
|
+
|
|
206
264
|
if (isStickyBottom !== prevIsStickyBottom) {
|
|
207
265
|
this.isStuckToBottom = false;
|
|
208
266
|
}
|
|
@@ -262,13 +320,13 @@ class Grid extends PureComponent {
|
|
|
262
320
|
}
|
|
263
321
|
|
|
264
322
|
componentWillUnmount() {
|
|
323
|
+
var _this$canvas2;
|
|
324
|
+
|
|
265
325
|
if (this.animationFrame != null) {
|
|
266
326
|
cancelAnimationFrame(this.animationFrame);
|
|
267
327
|
}
|
|
268
328
|
|
|
269
|
-
this.canvas.removeEventListener('wheel', this.handleWheel
|
|
270
|
-
passive: false
|
|
271
|
-
});
|
|
329
|
+
(_this$canvas2 = this.canvas) === null || _this$canvas2 === void 0 ? void 0 : _this$canvas2.removeEventListener('wheel', this.handleWheel);
|
|
272
330
|
window.removeEventListener('mousemove', this.handleMouseDrag, true);
|
|
273
331
|
window.removeEventListener('mouseup', this.handleMouseUp, true);
|
|
274
332
|
window.removeEventListener('resize', this.handleResize);
|
|
@@ -283,6 +341,7 @@ class Grid extends PureComponent {
|
|
|
283
341
|
}
|
|
284
342
|
|
|
285
343
|
getGridPointFromEvent(event) {
|
|
344
|
+
assertIsDefined(this.canvas);
|
|
286
345
|
var rect = this.canvas.getBoundingClientRect();
|
|
287
346
|
var x = event.clientX - rect.left;
|
|
288
347
|
var y = event.clientY - rect.top;
|
|
@@ -290,6 +349,7 @@ class Grid extends PureComponent {
|
|
|
290
349
|
}
|
|
291
350
|
|
|
292
351
|
getGridPointFromXY(x, y) {
|
|
352
|
+
if (!this.metrics) throw new Error('metrics must be set');
|
|
293
353
|
return GridUtils.getGridPointFromXY(x, y, this.metrics);
|
|
294
354
|
}
|
|
295
355
|
|
|
@@ -300,6 +360,11 @@ class Grid extends PureComponent {
|
|
|
300
360
|
model,
|
|
301
361
|
stateOverride
|
|
302
362
|
} = this.props;
|
|
363
|
+
|
|
364
|
+
if (!this.canvasContext || !this.canvas) {
|
|
365
|
+
throw new Error('Canvas and context must be defined to get metrics');
|
|
366
|
+
}
|
|
367
|
+
|
|
303
368
|
var context = this.canvasContext;
|
|
304
369
|
var width = this.canvas.clientWidth;
|
|
305
370
|
var height = this.canvas.clientHeight;
|
|
@@ -343,33 +408,56 @@ class Grid extends PureComponent {
|
|
|
343
408
|
} = this.props;
|
|
344
409
|
return this.getCachedMouseHandlers(mouseHandlers);
|
|
345
410
|
}
|
|
411
|
+
/**
|
|
412
|
+
* Translate from the provided visible index to the model index
|
|
413
|
+
* @param columnIndex The column index to get the model for
|
|
414
|
+
* @returns The model index
|
|
415
|
+
*/
|
|
416
|
+
|
|
346
417
|
|
|
347
418
|
getModelColumn(columnIndex) {
|
|
348
419
|
var _this$metrics, _this$metrics$modelCo;
|
|
349
420
|
|
|
350
|
-
|
|
421
|
+
var modelIndex = (_this$metrics = this.metrics) === null || _this$metrics === void 0 ? void 0 : (_this$metrics$modelCo = _this$metrics.modelColumns) === null || _this$metrics$modelCo === void 0 ? void 0 : _this$metrics$modelCo.get(columnIndex);
|
|
422
|
+
|
|
423
|
+
if (modelIndex === undefined) {
|
|
424
|
+
throw new Error("Unable to get ModelIndex for column ".concat(columnIndex));
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return modelIndex;
|
|
351
428
|
}
|
|
429
|
+
/**
|
|
430
|
+
* Translate from the provided visible index to the model index
|
|
431
|
+
* @param rowIndex The row index to get the model for
|
|
432
|
+
* @returns The model index
|
|
433
|
+
*/
|
|
434
|
+
|
|
352
435
|
|
|
353
436
|
getModelRow(rowIndex) {
|
|
354
437
|
var _this$metrics2, _this$metrics2$modelR;
|
|
355
438
|
|
|
356
|
-
|
|
439
|
+
var modelIndex = (_this$metrics2 = this.metrics) === null || _this$metrics2 === void 0 ? void 0 : (_this$metrics2$modelR = _this$metrics2.modelRows) === null || _this$metrics2$modelR === void 0 ? void 0 : _this$metrics2$modelR.get(rowIndex);
|
|
440
|
+
|
|
441
|
+
if (modelIndex === undefined) {
|
|
442
|
+
throw new Error("Unable to get ModelIndex for row ".concat(rowIndex));
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
return modelIndex;
|
|
357
446
|
}
|
|
447
|
+
/**
|
|
448
|
+
* Toggle a row between expanded and collapsed states
|
|
449
|
+
* @param row The row to toggle expansion for
|
|
450
|
+
*/
|
|
451
|
+
|
|
358
452
|
|
|
359
453
|
toggleRowExpanded(row) {
|
|
360
|
-
var
|
|
361
|
-
metrics
|
|
362
|
-
} = this;
|
|
363
|
-
var {
|
|
364
|
-
modelRows
|
|
365
|
-
} = metrics;
|
|
366
|
-
var modelRow = modelRows.get(row);
|
|
454
|
+
var modelRow = this.getModelRow(row);
|
|
367
455
|
var {
|
|
368
456
|
model
|
|
369
457
|
} = this.props; // We only want to set expansion if the row is expandable
|
|
370
458
|
// If it's not, still move the cursor to that position, as it may be outside of the current viewport and we don't know if it's expandable yet
|
|
371
459
|
|
|
372
|
-
if (model.isRowExpandable(modelRow)) {
|
|
460
|
+
if (isExpandableGridModel(model) && model.isRowExpandable(modelRow)) {
|
|
373
461
|
model.setRowExpanded(modelRow, !model.isRowExpanded(modelRow));
|
|
374
462
|
}
|
|
375
463
|
|
|
@@ -380,7 +468,11 @@ class Grid extends PureComponent {
|
|
|
380
468
|
this.commitSelection();
|
|
381
469
|
this.isStuckToBottom = false;
|
|
382
470
|
}
|
|
383
|
-
/**
|
|
471
|
+
/**
|
|
472
|
+
* Allows the selected ranges to be set programatically
|
|
473
|
+
* Will update the cursor and selection start/end based on the new ranges
|
|
474
|
+
* @param gridRanges The new selected ranges to set
|
|
475
|
+
*/
|
|
384
476
|
|
|
385
477
|
|
|
386
478
|
setSelectedRanges(gridRanges) {
|
|
@@ -431,6 +523,7 @@ class Grid extends PureComponent {
|
|
|
431
523
|
var {
|
|
432
524
|
canvasOptions
|
|
433
525
|
} = this.props;
|
|
526
|
+
if (!canvas) throw new Error('Canvas not set');
|
|
434
527
|
this.canvasContext = canvas.getContext('2d', canvasOptions);
|
|
435
528
|
}
|
|
436
529
|
|
|
@@ -441,6 +534,7 @@ class Grid extends PureComponent {
|
|
|
441
534
|
|
|
442
535
|
this.animationFrame = requestAnimationFrame(() => {
|
|
443
536
|
this.animationFrame = null;
|
|
537
|
+
if (!this.metrics) throw new Error('Metrics not set');
|
|
444
538
|
this.updateCanvas(this.metrics);
|
|
445
539
|
});
|
|
446
540
|
}
|
|
@@ -460,6 +554,9 @@ class Grid extends PureComponent {
|
|
|
460
554
|
canvas,
|
|
461
555
|
canvasContext
|
|
462
556
|
} = this;
|
|
557
|
+
if (!canvas) throw new Error('canvas not set');
|
|
558
|
+
if (!canvasContext) throw new Error('canvasContext not set');
|
|
559
|
+
if (!canvas.parentElement) throw new Error('Canvas has no parent element');
|
|
463
560
|
var scale = Grid.getScale(canvasContext); // the parent wrapper has 100% width/height, and is used for determining size
|
|
464
561
|
// we don't want to stretch the canvas to 100%, to avoid fractional pixels.
|
|
465
562
|
// A wrapper element must be used for sizing, and canvas size must be
|
|
@@ -486,6 +583,11 @@ class Grid extends PureComponent {
|
|
|
486
583
|
this.metrics = metricCalculator.getMetrics(metricState);
|
|
487
584
|
return this.metrics;
|
|
488
585
|
}
|
|
586
|
+
/**
|
|
587
|
+
* Check if the selection state has changed, and call the onSelectionChanged callback if they have
|
|
588
|
+
* @param prevState The previous grid state
|
|
589
|
+
*/
|
|
590
|
+
|
|
489
591
|
|
|
490
592
|
checkSelectionChange(prevState) {
|
|
491
593
|
var {
|
|
@@ -502,6 +604,11 @@ class Grid extends PureComponent {
|
|
|
502
604
|
onSelectionChanged(selectedRanges);
|
|
503
605
|
}
|
|
504
606
|
}
|
|
607
|
+
/**
|
|
608
|
+
* Validate the current selection, and reset if it is invalid
|
|
609
|
+
* @returns True if the selection is valid, false if the selection was invalid and has been reset
|
|
610
|
+
*/
|
|
611
|
+
|
|
505
612
|
|
|
506
613
|
validateSelection() {
|
|
507
614
|
var {
|
|
@@ -530,6 +637,10 @@ class Grid extends PureComponent {
|
|
|
530
637
|
|
|
531
638
|
return true;
|
|
532
639
|
}
|
|
640
|
+
/**
|
|
641
|
+
* Clears all selected ranges
|
|
642
|
+
*/
|
|
643
|
+
|
|
533
644
|
|
|
534
645
|
clearSelectedRanges() {
|
|
535
646
|
var {
|
|
@@ -554,6 +665,12 @@ class Grid extends PureComponent {
|
|
|
554
665
|
});
|
|
555
666
|
}
|
|
556
667
|
}
|
|
668
|
+
/**
|
|
669
|
+
* Begin a selection operation at the provided location
|
|
670
|
+
* @param column Column where the selection is beginning
|
|
671
|
+
* @param row Row where the selection is beginning
|
|
672
|
+
*/
|
|
673
|
+
|
|
557
674
|
|
|
558
675
|
beginSelection(column, row) {
|
|
559
676
|
this.setState({
|
|
@@ -567,10 +684,10 @@ class Grid extends PureComponent {
|
|
|
567
684
|
}
|
|
568
685
|
/**
|
|
569
686
|
* Moves the selection to the cell specified
|
|
570
|
-
* @param
|
|
571
|
-
* @param
|
|
572
|
-
* @param
|
|
573
|
-
* @param
|
|
687
|
+
* @param column The column index to move the cursor to
|
|
688
|
+
* @param row The row index to move the cursor to
|
|
689
|
+
* @param extendSelection Whether to extend the current selection (eg. holding Shift)
|
|
690
|
+
* @param maximizePreviousRange When true, maximize/add to the previous range only, ignoring where the selection was started.
|
|
574
691
|
*/
|
|
575
692
|
|
|
576
693
|
|
|
@@ -599,10 +716,12 @@ class Grid extends PureComponent {
|
|
|
599
716
|
var bottom = null;
|
|
600
717
|
|
|
601
718
|
if (maximizePreviousRange) {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
719
|
+
var _lastSelectedRange$st, _lastSelectedRange$st2, _lastSelectedRange$en, _lastSelectedRange$en2;
|
|
720
|
+
|
|
721
|
+
left = autoSelectRow ? null : Math.min(column !== null && column !== void 0 ? column : 0, (_lastSelectedRange$st = lastSelectedRange.startColumn) !== null && _lastSelectedRange$st !== void 0 ? _lastSelectedRange$st : 0);
|
|
722
|
+
top = autoSelectColumn ? null : Math.min(row !== null && row !== void 0 ? row : 0, (_lastSelectedRange$st2 = lastSelectedRange.startRow) !== null && _lastSelectedRange$st2 !== void 0 ? _lastSelectedRange$st2 : 0);
|
|
723
|
+
right = autoSelectRow ? null : Math.max(column !== null && column !== void 0 ? column : 0, (_lastSelectedRange$en = lastSelectedRange.endColumn) !== null && _lastSelectedRange$en !== void 0 ? _lastSelectedRange$en : 0);
|
|
724
|
+
bottom = autoSelectColumn ? null : Math.max(row !== null && row !== void 0 ? row : 0, (_lastSelectedRange$en2 = lastSelectedRange.endRow) !== null && _lastSelectedRange$en2 !== void 0 ? _lastSelectedRange$en2 : 0);
|
|
606
725
|
} else {
|
|
607
726
|
left = lastSelectedRange.startColumn;
|
|
608
727
|
top = lastSelectedRange.startRow;
|
|
@@ -627,8 +746,7 @@ class Grid extends PureComponent {
|
|
|
627
746
|
return null;
|
|
628
747
|
}
|
|
629
748
|
|
|
630
|
-
var _newRanges = []
|
|
631
|
-
|
|
749
|
+
var _newRanges = [...selectedRanges];
|
|
632
750
|
_newRanges[_newRanges.length - 1] = selectedRange;
|
|
633
751
|
return {
|
|
634
752
|
selectedRanges: _newRanges,
|
|
@@ -637,7 +755,7 @@ class Grid extends PureComponent {
|
|
|
637
755
|
};
|
|
638
756
|
}
|
|
639
757
|
|
|
640
|
-
var newRanges = []
|
|
758
|
+
var newRanges = [...selectedRanges];
|
|
641
759
|
var selectedColumn = autoSelectRow ? null : column;
|
|
642
760
|
var selectedRow = autoSelectColumn ? null : row;
|
|
643
761
|
newRanges.push(GridRange.makeNormalized(selectedColumn, selectedRow, selectedColumn, selectedRow));
|
|
@@ -676,7 +794,9 @@ class Grid extends PureComponent {
|
|
|
676
794
|
// For if we click on one cell multiple times.
|
|
677
795
|
return {
|
|
678
796
|
selectedRanges: [],
|
|
679
|
-
lastSelectedRanges: []
|
|
797
|
+
lastSelectedRanges: [],
|
|
798
|
+
cursorColumn,
|
|
799
|
+
cursorRow
|
|
680
800
|
};
|
|
681
801
|
}
|
|
682
802
|
|
|
@@ -736,6 +856,10 @@ class Grid extends PureComponent {
|
|
|
736
856
|
};
|
|
737
857
|
});
|
|
738
858
|
}
|
|
859
|
+
/**
|
|
860
|
+
* Set the selection to the entire grid
|
|
861
|
+
*/
|
|
862
|
+
|
|
739
863
|
|
|
740
864
|
selectAll() {
|
|
741
865
|
var {
|
|
@@ -752,6 +876,13 @@ class Grid extends PureComponent {
|
|
|
752
876
|
var right = autoSelectRow ? null : model.columnCount - 1;
|
|
753
877
|
this.setSelectedRanges([new GridRange(left, top, right, bottom)]);
|
|
754
878
|
}
|
|
879
|
+
/**
|
|
880
|
+
* Move the cursor in relation to the current cursor position
|
|
881
|
+
* @param deltaColumn Number of columns to move the cursor
|
|
882
|
+
* @param deltaRow Number of rows to move the cursor
|
|
883
|
+
* @param extendSelection True if the current selection should be extended, false to start a new selection
|
|
884
|
+
*/
|
|
885
|
+
|
|
755
886
|
|
|
756
887
|
moveCursor(deltaColumn, deltaRow, extendSelection) {
|
|
757
888
|
var {
|
|
@@ -787,7 +918,7 @@ class Grid extends PureComponent {
|
|
|
787
918
|
}
|
|
788
919
|
/**
|
|
789
920
|
* Move the cursor in the provided selection direction
|
|
790
|
-
* @param
|
|
921
|
+
* @param direction The direction to move the cursor in
|
|
791
922
|
*/
|
|
792
923
|
|
|
793
924
|
|
|
@@ -843,11 +974,11 @@ class Grid extends PureComponent {
|
|
|
843
974
|
}
|
|
844
975
|
/**
|
|
845
976
|
* Move a cursor to the specified position in the grid.
|
|
846
|
-
* @param
|
|
847
|
-
* @param
|
|
848
|
-
* @param
|
|
849
|
-
* @param
|
|
850
|
-
* @param
|
|
977
|
+
* @param column The column index to move the cursor to
|
|
978
|
+
* @param row The row index to move the cursor to
|
|
979
|
+
* @param extendSelection Whether to extend the current selection (eg. holding Shift)
|
|
980
|
+
* @param keepCursorInView Whether to move the viewport so that the cursor is in view
|
|
981
|
+
* @param maximizePreviousRange With this and `extendSelection` true, it will maximize/add to the previous range only, ignoring where the selection was started
|
|
851
982
|
*/
|
|
852
983
|
|
|
853
984
|
|
|
@@ -869,12 +1000,13 @@ class Grid extends PureComponent {
|
|
|
869
1000
|
/**
|
|
870
1001
|
* Moves the view to make the specified cell visible
|
|
871
1002
|
*
|
|
872
|
-
* @param
|
|
873
|
-
* @param
|
|
1003
|
+
* @param column The column index to bring into view
|
|
1004
|
+
* @param row The row index to bring into view
|
|
874
1005
|
*/
|
|
875
1006
|
|
|
876
1007
|
|
|
877
1008
|
moveViewToCell(column, row) {
|
|
1009
|
+
if (!this.metrics) throw new Error('metrics not set');
|
|
878
1010
|
var {
|
|
879
1011
|
metricCalculator
|
|
880
1012
|
} = this;
|
|
@@ -922,13 +1054,14 @@ class Grid extends PureComponent {
|
|
|
922
1054
|
/**
|
|
923
1055
|
* Checks the `top` and `left` properties that are set and updates the isStuckToBottom/Right properties
|
|
924
1056
|
* Should be called when user interaction occurs
|
|
925
|
-
* @param
|
|
926
|
-
* @param
|
|
1057
|
+
* @param viewState New state properties to set.
|
|
1058
|
+
* @param forceUpdate Whether to force an update.
|
|
927
1059
|
*/
|
|
928
1060
|
|
|
929
1061
|
|
|
930
1062
|
setViewState(viewState) {
|
|
931
1063
|
var forceUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1064
|
+
if (!this.metrics) throw new Error('metrics not set');
|
|
932
1065
|
var {
|
|
933
1066
|
isStickyBottom,
|
|
934
1067
|
isStickyRight
|
|
@@ -959,21 +1092,22 @@ class Grid extends PureComponent {
|
|
|
959
1092
|
/**
|
|
960
1093
|
* Start editing the data at the given index
|
|
961
1094
|
*
|
|
962
|
-
* @param
|
|
963
|
-
* @param
|
|
964
|
-
* @param
|
|
965
|
-
* @param
|
|
966
|
-
* @param
|
|
1095
|
+
* @param column The visible column index to start editing
|
|
1096
|
+
* @param row The visible row index to start editing
|
|
1097
|
+
* @param isQuickEdit If this is a quick edit (the arrow keys can commit)
|
|
1098
|
+
* @param selectionRange The tuple [start,end] text selection range of the value to select when editing
|
|
1099
|
+
* @param value The value to start with in the edit field. Leave undefined to use the current value.
|
|
967
1100
|
*/
|
|
968
1101
|
|
|
969
1102
|
|
|
970
1103
|
startEditing(column, row) {
|
|
971
1104
|
var isQuickEdit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
972
|
-
var selectionRange = arguments.length > 3
|
|
973
|
-
var value = arguments.length > 4
|
|
1105
|
+
var selectionRange = arguments.length > 3 ? arguments[3] : undefined;
|
|
1106
|
+
var value = arguments.length > 4 ? arguments[4] : undefined;
|
|
974
1107
|
var {
|
|
975
1108
|
model
|
|
976
1109
|
} = this.props;
|
|
1110
|
+
if (!isEditableGridModel(model)) throw new Error('model is not editable');
|
|
977
1111
|
var modelColumn = this.getModelColumn(column);
|
|
978
1112
|
var modelRow = this.getModelRow(row);
|
|
979
1113
|
var cell = {
|
|
@@ -990,6 +1124,14 @@ class Grid extends PureComponent {
|
|
|
990
1124
|
});
|
|
991
1125
|
this.moveViewToCell(column, row);
|
|
992
1126
|
}
|
|
1127
|
+
/**
|
|
1128
|
+
* Check if a value is valid for a specific cell
|
|
1129
|
+
* @param column Column index of the cell to check
|
|
1130
|
+
* @param row Row index of the cell to check
|
|
1131
|
+
* @param value Value to check
|
|
1132
|
+
* @returns True if the value is valid for the provided cell, false otherwise
|
|
1133
|
+
*/
|
|
1134
|
+
|
|
993
1135
|
|
|
994
1136
|
isValidForCell(column, row, value) {
|
|
995
1137
|
var {
|
|
@@ -997,13 +1139,13 @@ class Grid extends PureComponent {
|
|
|
997
1139
|
} = this.props;
|
|
998
1140
|
var modelColumn = this.getModelColumn(column);
|
|
999
1141
|
var modelRow = this.getModelRow(row);
|
|
1000
|
-
return model.isValidForCell(modelColumn, modelRow, value);
|
|
1142
|
+
return isEditableGridModel(model) && model.isValidForCell(modelColumn, modelRow, value);
|
|
1001
1143
|
}
|
|
1002
1144
|
/**
|
|
1003
1145
|
* Paste a value with the current selection
|
|
1004
1146
|
* It first needs to validate that the pasted table is valid for the given selection.
|
|
1005
1147
|
* Also may update selection if single cells are selected and a table is pasted.
|
|
1006
|
-
* @param
|
|
1148
|
+
* @param value Table or a string that is being pasted
|
|
1007
1149
|
*/
|
|
1008
1150
|
|
|
1009
1151
|
|
|
@@ -1021,6 +1163,8 @@ class Grid extends PureComponent {
|
|
|
1021
1163
|
} = _this.state;
|
|
1022
1164
|
|
|
1023
1165
|
try {
|
|
1166
|
+
assertIsEditableGridModel(model);
|
|
1167
|
+
|
|
1024
1168
|
if (!model.isEditable || !selectedRanges.every(range => model.isEditableRange(range))) {
|
|
1025
1169
|
throw new PasteError("Can't paste in to read-only area.");
|
|
1026
1170
|
}
|
|
@@ -1033,10 +1177,10 @@ class Grid extends PureComponent {
|
|
|
1033
1177
|
// Just paste the value into all the selected cells
|
|
1034
1178
|
var _edits = [];
|
|
1035
1179
|
var modelRanges = GridUtils.getModelRanges(selectedRanges, movedColumns, movedRows);
|
|
1036
|
-
GridRange.forEachCell(modelRanges, (
|
|
1180
|
+
GridRange.forEachCell(modelRanges, (column, row) => {
|
|
1037
1181
|
_edits.push({
|
|
1038
|
-
|
|
1039
|
-
|
|
1182
|
+
column,
|
|
1183
|
+
row,
|
|
1040
1184
|
text: value
|
|
1041
1185
|
});
|
|
1042
1186
|
});
|
|
@@ -1051,31 +1195,43 @@ class Grid extends PureComponent {
|
|
|
1051
1195
|
columnCount,
|
|
1052
1196
|
rowCount
|
|
1053
1197
|
} = model;
|
|
1054
|
-
var
|
|
1198
|
+
var _ranges = selectedRanges; // If each cell is a single selection, we need to update the selection to map to the newly pasted data
|
|
1055
1199
|
|
|
1056
|
-
if (
|
|
1200
|
+
if (_ranges.every(range => {
|
|
1201
|
+
var _range$startColumn, _range$startRow;
|
|
1202
|
+
|
|
1203
|
+
return GridRange.cellCount([range]) === 1 && ((_range$startColumn = range.startColumn) !== null && _range$startColumn !== void 0 ? _range$startColumn : 0) + tableWidth <= columnCount && ((_range$startRow = range.startRow) !== null && _range$startRow !== void 0 ? _range$startRow : 0) + tableHeight <= rowCount;
|
|
1204
|
+
})) {
|
|
1057
1205
|
// Remap the selected ranges
|
|
1058
|
-
|
|
1206
|
+
_ranges = _ranges.map(range => {
|
|
1207
|
+
var _range$startColumn2, _range$startRow2;
|
|
1208
|
+
|
|
1209
|
+
return new GridRange(range.startColumn, range.startRow, ((_range$startColumn2 = range.startColumn) !== null && _range$startColumn2 !== void 0 ? _range$startColumn2 : 0) + tableWidth - 1, ((_range$startRow2 = range.startRow) !== null && _range$startRow2 !== void 0 ? _range$startRow2 : 0) + tableHeight - 1);
|
|
1210
|
+
});
|
|
1059
1211
|
|
|
1060
|
-
_this.setSelectedRanges(
|
|
1212
|
+
_this.setSelectedRanges(_ranges);
|
|
1061
1213
|
}
|
|
1062
1214
|
|
|
1063
|
-
if (!
|
|
1215
|
+
if (!_ranges.every(range => GridRange.rowCount([range]) === tableHeight && GridRange.columnCount([range]) === tableWidth)) {
|
|
1064
1216
|
throw new PasteError('Copy and paste area are not same size.');
|
|
1065
1217
|
}
|
|
1066
1218
|
|
|
1067
1219
|
var edits = [];
|
|
1068
|
-
|
|
1220
|
+
|
|
1221
|
+
_ranges.forEach(range => {
|
|
1069
1222
|
for (var x = 0; x < tableWidth; x += 1) {
|
|
1070
1223
|
for (var y = 0; y < tableHeight; y += 1) {
|
|
1224
|
+
var _range$startColumn3, _range$startRow3;
|
|
1225
|
+
|
|
1071
1226
|
edits.push({
|
|
1072
|
-
|
|
1073
|
-
|
|
1227
|
+
column: ((_range$startColumn3 = range.startColumn) !== null && _range$startColumn3 !== void 0 ? _range$startColumn3 : 0) + x,
|
|
1228
|
+
row: ((_range$startRow3 = range.startRow) !== null && _range$startRow3 !== void 0 ? _range$startRow3 : 0) + y,
|
|
1074
1229
|
text: value[y][x]
|
|
1075
1230
|
});
|
|
1076
1231
|
}
|
|
1077
1232
|
}
|
|
1078
1233
|
});
|
|
1234
|
+
|
|
1079
1235
|
yield model.setValues(edits);
|
|
1080
1236
|
} catch (e) {
|
|
1081
1237
|
var {
|
|
@@ -1085,18 +1241,36 @@ class Grid extends PureComponent {
|
|
|
1085
1241
|
}
|
|
1086
1242
|
})();
|
|
1087
1243
|
}
|
|
1244
|
+
/**
|
|
1245
|
+
* Set a value to a specific cell. If the value is not valid for that cell, do not set it
|
|
1246
|
+
* @param column Column index to set the value for
|
|
1247
|
+
* @param row Row index to set the value for
|
|
1248
|
+
* @param value Value to set at that cell
|
|
1249
|
+
* @returns true If the value was valid and attempted to be set, false is it was not valid
|
|
1250
|
+
*/
|
|
1251
|
+
|
|
1088
1252
|
|
|
1089
1253
|
setValueForCell(column, row, value) {
|
|
1090
1254
|
var {
|
|
1091
1255
|
model
|
|
1092
1256
|
} = this.props;
|
|
1257
|
+
assertIsEditableGridModel(model);
|
|
1093
1258
|
var modelColumn = this.getModelColumn(column);
|
|
1094
1259
|
var modelRow = this.getModelRow(row);
|
|
1095
1260
|
|
|
1096
1261
|
if (model.isValidForCell(modelColumn, modelRow, value)) {
|
|
1097
1262
|
model.setValueForCell(modelColumn, modelRow, value);
|
|
1263
|
+
return true;
|
|
1098
1264
|
}
|
|
1265
|
+
|
|
1266
|
+
return false;
|
|
1099
1267
|
}
|
|
1268
|
+
/**
|
|
1269
|
+
* Set a value on all the ranges provided
|
|
1270
|
+
* @param ranges Ranges to set
|
|
1271
|
+
* @param value The value to set on all the ranges
|
|
1272
|
+
*/
|
|
1273
|
+
|
|
1100
1274
|
|
|
1101
1275
|
setValueForRanges(ranges, value) {
|
|
1102
1276
|
var {
|
|
@@ -1107,8 +1281,18 @@ class Grid extends PureComponent {
|
|
|
1107
1281
|
movedRows
|
|
1108
1282
|
} = this.state;
|
|
1109
1283
|
var modelRanges = GridUtils.getModelRanges(ranges, movedColumns, movedRows);
|
|
1110
|
-
|
|
1284
|
+
|
|
1285
|
+
if (isEditableGridModel(model)) {
|
|
1286
|
+
model.setValueForRanges(modelRanges, value);
|
|
1287
|
+
}
|
|
1111
1288
|
}
|
|
1289
|
+
/**
|
|
1290
|
+
* Check if a given cell is within the current selection
|
|
1291
|
+
* @param row Row to check
|
|
1292
|
+
* @param column Column to check
|
|
1293
|
+
* @returns True if the cell is in the current selection, false otherwise
|
|
1294
|
+
*/
|
|
1295
|
+
|
|
1112
1296
|
|
|
1113
1297
|
isSelected(row, column) {
|
|
1114
1298
|
var {
|
|
@@ -1116,9 +1300,11 @@ class Grid extends PureComponent {
|
|
|
1116
1300
|
} = this.state;
|
|
1117
1301
|
|
|
1118
1302
|
for (var i = 0; i < selectedRanges.length; i += 1) {
|
|
1303
|
+
var _selectedRange$endRow, _selectedRange$endCol;
|
|
1304
|
+
|
|
1119
1305
|
var selectedRange = selectedRanges[i];
|
|
1120
|
-
var rowSelected = selectedRange.startRow === null || selectedRange.startRow <= row && row <= selectedRange.endRow;
|
|
1121
|
-
var columnSelected = selectedRange.startColumn === null || selectedRange.startColumn <= column && column <= selectedRange.endColumn;
|
|
1306
|
+
var rowSelected = selectedRange.startRow === null || selectedRange.startRow <= row && row <= ((_selectedRange$endRow = selectedRange.endRow) !== null && _selectedRange$endRow !== void 0 ? _selectedRange$endRow : 0);
|
|
1307
|
+
var columnSelected = selectedRange.startColumn === null || selectedRange.startColumn <= column && column <= ((_selectedRange$endCol = selectedRange.endColumn) !== null && _selectedRange$endCol !== void 0 ? _selectedRange$endCol : 0);
|
|
1122
1308
|
|
|
1123
1309
|
if (rowSelected && columnSelected) {
|
|
1124
1310
|
return true;
|
|
@@ -1131,9 +1317,17 @@ class Grid extends PureComponent {
|
|
|
1131
1317
|
addDocumentCursor() {
|
|
1132
1318
|
var cursor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
1133
1319
|
if (this.documentCursor === Grid.getCursorClassName(cursor)) return;
|
|
1134
|
-
|
|
1320
|
+
|
|
1321
|
+
if (this.documentCursor) {
|
|
1322
|
+
document.documentElement.classList.remove(this.documentCursor);
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1135
1325
|
this.documentCursor = Grid.getCursorClassName(cursor);
|
|
1136
|
-
|
|
1326
|
+
|
|
1327
|
+
if (this.documentCursor) {
|
|
1328
|
+
document.documentElement.classList.add(this.documentCursor);
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1137
1331
|
document.documentElement.classList.add('grid-block-events');
|
|
1138
1332
|
}
|
|
1139
1333
|
|
|
@@ -1147,7 +1341,7 @@ class Grid extends PureComponent {
|
|
|
1147
1341
|
|
|
1148
1342
|
startDragTimer(event) {
|
|
1149
1343
|
this.stopDragTimer();
|
|
1150
|
-
var mouseEvent = new MouseEvent('custom', event);
|
|
1344
|
+
var mouseEvent = new MouseEvent('custom', event.nativeEvent);
|
|
1151
1345
|
this.dragTimer = setTimeout(() => {
|
|
1152
1346
|
this.handleMouseDrag(mouseEvent);
|
|
1153
1347
|
}, Grid.dragTimeout);
|
|
@@ -1160,13 +1354,17 @@ class Grid extends PureComponent {
|
|
|
1160
1354
|
}
|
|
1161
1355
|
}
|
|
1162
1356
|
/**
|
|
1357
|
+
* Draw the grid with the metrics provided
|
|
1163
1358
|
* When scrolling you've have to re-draw the whole canvas. As a consequence, all these drawing methods
|
|
1164
1359
|
* must be very quick.
|
|
1360
|
+
* @param metrics Metrics to use for rendering the grid
|
|
1165
1361
|
*/
|
|
1166
1362
|
|
|
1167
1363
|
|
|
1168
1364
|
drawCanvas() {
|
|
1169
1365
|
var metrics = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.updateMetrics();
|
|
1366
|
+
if (!this.canvas) throw new Error('canvas is not set');
|
|
1367
|
+
if (!this.canvasContext) throw new Error('context not set');
|
|
1170
1368
|
var {
|
|
1171
1369
|
left,
|
|
1172
1370
|
top,
|
|
@@ -1228,16 +1426,35 @@ class Grid extends PureComponent {
|
|
|
1228
1426
|
renderer.drawCanvas(renderState);
|
|
1229
1427
|
context.restore();
|
|
1230
1428
|
}
|
|
1429
|
+
/**
|
|
1430
|
+
* Set focus to this grid element
|
|
1431
|
+
*/
|
|
1432
|
+
|
|
1231
1433
|
|
|
1232
1434
|
focus() {
|
|
1233
|
-
|
|
1435
|
+
var _this$canvas3;
|
|
1436
|
+
|
|
1437
|
+
(_this$canvas3 = this.canvas) === null || _this$canvas3 === void 0 ? void 0 : _this$canvas3.focus();
|
|
1234
1438
|
}
|
|
1439
|
+
/**
|
|
1440
|
+
* Check if this grid is currently focused
|
|
1441
|
+
* @returns True if the active element is this grid
|
|
1442
|
+
*/
|
|
1443
|
+
|
|
1235
1444
|
|
|
1236
1445
|
isFocused() {
|
|
1237
1446
|
return document.activeElement === this.canvas;
|
|
1238
1447
|
}
|
|
1448
|
+
/**
|
|
1449
|
+
* Handle a mouse click event. Pass the event to the registered mouse handlers until one handles it.
|
|
1450
|
+
* Focuses the grid after the click.
|
|
1451
|
+
* @param event The mouse event
|
|
1452
|
+
*/
|
|
1453
|
+
|
|
1239
1454
|
|
|
1240
1455
|
handleClick(event) {
|
|
1456
|
+
var _this$canvas4;
|
|
1457
|
+
|
|
1241
1458
|
var gridPoint = this.getGridPointFromEvent(event);
|
|
1242
1459
|
var mouseHandlers = this.getMouseHandlers();
|
|
1243
1460
|
|
|
@@ -1251,8 +1468,13 @@ class Grid extends PureComponent {
|
|
|
1251
1468
|
}
|
|
1252
1469
|
}
|
|
1253
1470
|
|
|
1254
|
-
this.canvas.focus();
|
|
1471
|
+
(_this$canvas4 = this.canvas) === null || _this$canvas4 === void 0 ? void 0 : _this$canvas4.focus();
|
|
1255
1472
|
}
|
|
1473
|
+
/**
|
|
1474
|
+
* Handle a mouse context menu event. Pass the event to the registered mouse handlers until one handles it.
|
|
1475
|
+
* @param event The mouse event triggering the context menu
|
|
1476
|
+
*/
|
|
1477
|
+
|
|
1256
1478
|
|
|
1257
1479
|
handleContextMenu(event) {
|
|
1258
1480
|
var gridPoint = this.getGridPointFromEvent(event);
|
|
@@ -1268,29 +1490,35 @@ class Grid extends PureComponent {
|
|
|
1268
1490
|
}
|
|
1269
1491
|
}
|
|
1270
1492
|
}
|
|
1493
|
+
/**
|
|
1494
|
+
* Handle a key down event from the keyboard. Pass the event to the registered keyboard handlers until one handles it.
|
|
1495
|
+
* @param event Keyboard event
|
|
1496
|
+
*/
|
|
1497
|
+
|
|
1271
1498
|
|
|
1272
|
-
handleKeyDown(
|
|
1499
|
+
handleKeyDown(event) {
|
|
1273
1500
|
var keyHandlers = this.getKeyHandlers();
|
|
1274
1501
|
|
|
1275
1502
|
for (var i = 0; i < keyHandlers.length; i += 1) {
|
|
1276
1503
|
var keyHandler = keyHandlers[i];
|
|
1277
|
-
var result = keyHandler.onDown(
|
|
1504
|
+
var result = keyHandler.onDown(event, this);
|
|
1278
1505
|
|
|
1279
1506
|
if (result) {
|
|
1280
|
-
var
|
|
1507
|
+
var _options$stopPropagat, _options$preventDefau;
|
|
1281
1508
|
|
|
1282
|
-
|
|
1283
|
-
if ((
|
|
1509
|
+
var options = result;
|
|
1510
|
+
if ((_options$stopPropagat = options === null || options === void 0 ? void 0 : options.stopPropagation) !== null && _options$stopPropagat !== void 0 ? _options$stopPropagat : true) event.stopPropagation();
|
|
1511
|
+
if ((_options$preventDefau = options === null || options === void 0 ? void 0 : options.preventDefault) !== null && _options$preventDefau !== void 0 ? _options$preventDefau : true) event.preventDefault();
|
|
1284
1512
|
break;
|
|
1285
1513
|
}
|
|
1286
1514
|
}
|
|
1287
1515
|
}
|
|
1288
1516
|
/**
|
|
1289
1517
|
* Notify all of the mouse handlers for this grid of a mouse event.
|
|
1290
|
-
* @param
|
|
1291
|
-
* @param
|
|
1292
|
-
* @param
|
|
1293
|
-
* @param
|
|
1518
|
+
* @param functionName The name of the function in the mouse handler to call
|
|
1519
|
+
* @param event The mouse event to notify
|
|
1520
|
+
* @param updateCoordinates Whether to update the mouse coordinates
|
|
1521
|
+
* @param addCursorToDocument Whether to add a cursor overlay or not (for dragging)
|
|
1294
1522
|
*/
|
|
1295
1523
|
|
|
1296
1524
|
|
|
@@ -1306,7 +1534,7 @@ class Grid extends PureComponent {
|
|
|
1306
1534
|
var result = mouseHandler[functionName] && mouseHandler[functionName](gridPoint, this, event);
|
|
1307
1535
|
|
|
1308
1536
|
if (result) {
|
|
1309
|
-
var
|
|
1537
|
+
var _options$stopPropagat2, _options$preventDefau2;
|
|
1310
1538
|
|
|
1311
1539
|
if (mouseHandler.cursor != null) {
|
|
1312
1540
|
({
|
|
@@ -1319,8 +1547,9 @@ class Grid extends PureComponent {
|
|
|
1319
1547
|
} // result is bool or object, events are stopped by default
|
|
1320
1548
|
|
|
1321
1549
|
|
|
1322
|
-
|
|
1323
|
-
if ((
|
|
1550
|
+
var options = result;
|
|
1551
|
+
if ((_options$stopPropagat2 = options === null || options === void 0 ? void 0 : options.stopPropagation) !== null && _options$stopPropagat2 !== void 0 ? _options$stopPropagat2 : true) event.stopPropagation();
|
|
1552
|
+
if ((_options$preventDefau2 = options === null || options === void 0 ? void 0 : options.preventDefault) !== null && _options$preventDefau2 !== void 0 ? _options$preventDefau2 : true) event.preventDefault();
|
|
1324
1553
|
break;
|
|
1325
1554
|
}
|
|
1326
1555
|
}
|
|
@@ -1349,20 +1578,20 @@ class Grid extends PureComponent {
|
|
|
1349
1578
|
return;
|
|
1350
1579
|
}
|
|
1351
1580
|
|
|
1352
|
-
this.notifyMouseHandlers(
|
|
1581
|
+
this.notifyMouseHandlers('onDown', event);
|
|
1353
1582
|
this.startDragTimer(event);
|
|
1354
1583
|
}
|
|
1355
1584
|
|
|
1356
1585
|
handleDoubleClick(event) {
|
|
1357
|
-
this.notifyMouseHandlers(
|
|
1586
|
+
this.notifyMouseHandlers('onDoubleClick', event);
|
|
1358
1587
|
}
|
|
1359
1588
|
|
|
1360
1589
|
handleMouseMove(event) {
|
|
1361
|
-
this.notifyMouseHandlers(
|
|
1590
|
+
this.notifyMouseHandlers('onMove', event);
|
|
1362
1591
|
}
|
|
1363
1592
|
|
|
1364
1593
|
handleMouseLeave(event) {
|
|
1365
|
-
this.notifyMouseHandlers(
|
|
1594
|
+
this.notifyMouseHandlers('onLeave', event, false);
|
|
1366
1595
|
this.setState({
|
|
1367
1596
|
mouseX: null,
|
|
1368
1597
|
mouseY: null
|
|
@@ -1373,7 +1602,7 @@ class Grid extends PureComponent {
|
|
|
1373
1602
|
this.setState({
|
|
1374
1603
|
isDragging: true
|
|
1375
1604
|
});
|
|
1376
|
-
this.notifyMouseHandlers(
|
|
1605
|
+
this.notifyMouseHandlers('onDrag', event, true, true);
|
|
1377
1606
|
this.stopDragTimer();
|
|
1378
1607
|
}
|
|
1379
1608
|
|
|
@@ -1385,7 +1614,7 @@ class Grid extends PureComponent {
|
|
|
1385
1614
|
return;
|
|
1386
1615
|
}
|
|
1387
1616
|
|
|
1388
|
-
this.notifyMouseHandlers(
|
|
1617
|
+
this.notifyMouseHandlers('onUp', event, false);
|
|
1389
1618
|
this.stopDragTimer();
|
|
1390
1619
|
this.removeDocumentCursor();
|
|
1391
1620
|
}
|
|
@@ -1403,10 +1632,10 @@ class Grid extends PureComponent {
|
|
|
1403
1632
|
this.forceUpdate();
|
|
1404
1633
|
}
|
|
1405
1634
|
|
|
1406
|
-
handleWheel(
|
|
1407
|
-
this.notifyMouseHandlers(
|
|
1635
|
+
handleWheel(event) {
|
|
1636
|
+
this.notifyMouseHandlers('onWheel', event);
|
|
1408
1637
|
|
|
1409
|
-
if (
|
|
1638
|
+
if (event.defaultPrevented) {
|
|
1410
1639
|
return;
|
|
1411
1640
|
}
|
|
1412
1641
|
|
|
@@ -1415,6 +1644,7 @@ class Grid extends PureComponent {
|
|
|
1415
1644
|
metrics
|
|
1416
1645
|
} = this;
|
|
1417
1646
|
var metricState = this.getMetricState();
|
|
1647
|
+
if (!metrics) throw new Error('metrics not set');
|
|
1418
1648
|
var {
|
|
1419
1649
|
lastTop,
|
|
1420
1650
|
lastLeft
|
|
@@ -1429,7 +1659,7 @@ class Grid extends PureComponent {
|
|
|
1429
1659
|
var {
|
|
1430
1660
|
deltaX,
|
|
1431
1661
|
deltaY
|
|
1432
|
-
} = GridUtils.getScrollDelta(
|
|
1662
|
+
} = GridUtils.getScrollDelta(event, metrics.barWidth, metrics.barHeight, metrics.rowHeight, metrics.rowHeight); // iterate through each column to determine column width and figure out how far to scroll
|
|
1433
1663
|
// get column width of next column to scroll to, and subract it from the remaining distance to travel
|
|
1434
1664
|
|
|
1435
1665
|
while (deltaX !== 0) {
|
|
@@ -1532,9 +1762,13 @@ class Grid extends PureComponent {
|
|
|
1532
1762
|
leftOffset,
|
|
1533
1763
|
topOffset
|
|
1534
1764
|
});
|
|
1535
|
-
|
|
1536
|
-
|
|
1765
|
+
event.stopPropagation();
|
|
1766
|
+
event.preventDefault();
|
|
1537
1767
|
}
|
|
1768
|
+
/**
|
|
1769
|
+
* Handle cancelling the cell edit action
|
|
1770
|
+
*/
|
|
1771
|
+
|
|
1538
1772
|
|
|
1539
1773
|
handleEditCellCancel() {
|
|
1540
1774
|
this.setState({
|
|
@@ -1542,34 +1776,60 @@ class Grid extends PureComponent {
|
|
|
1542
1776
|
});
|
|
1543
1777
|
this.focus();
|
|
1544
1778
|
}
|
|
1779
|
+
/**
|
|
1780
|
+
* Handle a change in the value in an editing cell
|
|
1781
|
+
* @param value New value set
|
|
1782
|
+
*/
|
|
1783
|
+
|
|
1545
1784
|
|
|
1546
1785
|
handleEditCellChange(value) {
|
|
1547
1786
|
this.setState(_ref => {
|
|
1548
1787
|
var {
|
|
1549
1788
|
editingCell
|
|
1550
1789
|
} = _ref;
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1790
|
+
|
|
1791
|
+
try {
|
|
1792
|
+
assertIsDefined(editingCell);
|
|
1793
|
+
return {
|
|
1794
|
+
editingCell: _objectSpread(_objectSpread({}, editingCell), {}, {
|
|
1795
|
+
value
|
|
1796
|
+
})
|
|
1797
|
+
};
|
|
1798
|
+
} catch (e) {
|
|
1799
|
+
// This case should _never_ happen, since the editingCell shouldn't be null if this method is called
|
|
1800
|
+
var {
|
|
1801
|
+
onError
|
|
1802
|
+
} = this.props;
|
|
1803
|
+
onError(e);
|
|
1804
|
+
return null;
|
|
1805
|
+
}
|
|
1556
1806
|
});
|
|
1557
1807
|
}
|
|
1808
|
+
/**
|
|
1809
|
+
* Commit an edit for the currently editing cell
|
|
1810
|
+
* @param value Value that was committed
|
|
1811
|
+
* @param options Options for committing
|
|
1812
|
+
*/
|
|
1813
|
+
|
|
1558
1814
|
|
|
1559
1815
|
handleEditCellCommit(value) {
|
|
1560
1816
|
var {
|
|
1561
|
-
direction =
|
|
1817
|
+
direction = SELECTION_DIRECTION.DOWN,
|
|
1562
1818
|
fillRange = false
|
|
1563
1819
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1564
1820
|
var {
|
|
1565
|
-
|
|
1566
|
-
cursorRow: row,
|
|
1821
|
+
editingCell,
|
|
1567
1822
|
selectedRanges
|
|
1568
1823
|
} = this.state;
|
|
1824
|
+
if (!editingCell) throw new Error('editingCell not set');
|
|
1825
|
+
var {
|
|
1826
|
+
column,
|
|
1827
|
+
row
|
|
1828
|
+
} = editingCell;
|
|
1569
1829
|
|
|
1570
1830
|
if (!this.isValidForCell(column, row, value)) {
|
|
1571
1831
|
// Don't allow an invalid value to be commited, the editing cell should show an error
|
|
1572
|
-
if (direction
|
|
1832
|
+
if (direction === null) {
|
|
1573
1833
|
// If they clicked off of the editing cell, just remove focus
|
|
1574
1834
|
this.setState({
|
|
1575
1835
|
editingCell: null
|
|
@@ -1585,7 +1845,7 @@ class Grid extends PureComponent {
|
|
|
1585
1845
|
this.setValueForCell(column, row, value);
|
|
1586
1846
|
}
|
|
1587
1847
|
|
|
1588
|
-
if (direction
|
|
1848
|
+
if (direction !== null) {
|
|
1589
1849
|
this.moveCursorInDirection(direction);
|
|
1590
1850
|
}
|
|
1591
1851
|
|
|
@@ -1606,19 +1866,19 @@ class Grid extends PureComponent {
|
|
|
1606
1866
|
metrics
|
|
1607
1867
|
} = this;
|
|
1608
1868
|
|
|
1609
|
-
if (editingCell == null || metrics == null) {
|
|
1869
|
+
if (editingCell == null || metrics == null || !isEditableGridModel(model)) {
|
|
1610
1870
|
return null;
|
|
1611
1871
|
}
|
|
1612
1872
|
|
|
1613
1873
|
var {
|
|
1614
|
-
selectionRange
|
|
1874
|
+
selectionRange,
|
|
1615
1875
|
value,
|
|
1616
1876
|
isQuickEdit
|
|
1617
1877
|
} = editingCell;
|
|
1618
1878
|
var {
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
} =
|
|
1879
|
+
column,
|
|
1880
|
+
row
|
|
1881
|
+
} = editingCell;
|
|
1622
1882
|
var {
|
|
1623
1883
|
gridX,
|
|
1624
1884
|
gridY,
|
|
@@ -1630,10 +1890,9 @@ class Grid extends PureComponent {
|
|
|
1630
1890
|
var x = visibleColumnXs.get(column);
|
|
1631
1891
|
var y = visibleRowYs.get(row);
|
|
1632
1892
|
var w = visibleColumnWidths.get(column);
|
|
1633
|
-
var h = visibleRowHeights.get(row);
|
|
1634
|
-
var isVisible = x != null && y != null && w != null && h != null; // If the cell isn't visible, we still need to display an invisible cell for focus purposes
|
|
1893
|
+
var h = visibleRowHeights.get(row); // If the cell isn't visible, we still need to display an invisible cell for focus purposes
|
|
1635
1894
|
|
|
1636
|
-
var wrapperStyle =
|
|
1895
|
+
var wrapperStyle = x != null && y != null && w != null && h != null ? {
|
|
1637
1896
|
position: 'absolute',
|
|
1638
1897
|
left: gridX + x,
|
|
1639
1898
|
top: gridY + y,
|
|
@@ -1646,7 +1905,7 @@ class Grid extends PureComponent {
|
|
|
1646
1905
|
var modelRow = this.getModelRow(row);
|
|
1647
1906
|
var inputStyle = modelColumn != null && modelRow != null ? {
|
|
1648
1907
|
textAlign: model.textAlignForCell(modelColumn, modelRow)
|
|
1649
|
-
} :
|
|
1908
|
+
} : undefined;
|
|
1650
1909
|
var isValid = model.isValidForCell(modelColumn, modelRow, value);
|
|
1651
1910
|
return /*#__PURE__*/React.createElement("div", {
|
|
1652
1911
|
style: wrapperStyle
|
|
@@ -1687,62 +1946,35 @@ class Grid extends PureComponent {
|
|
|
1687
1946
|
|
|
1688
1947
|
}
|
|
1689
1948
|
|
|
1690
|
-
_defineProperty(Grid, "
|
|
1691
|
-
|
|
1692
|
-
_defineProperty(Grid, "dragTimeout", 1000);
|
|
1693
|
-
|
|
1694
|
-
_defineProperty(Grid, "getTheme", memoize(userTheme => _objectSpread(_objectSpread({}, GridTheme), userTheme)));
|
|
1695
|
-
|
|
1696
|
-
Grid.propTypes = {
|
|
1697
|
-
canvasOptions: PropTypes.shape({}),
|
|
1698
|
-
isStickyBottom: PropTypes.bool,
|
|
1699
|
-
isStickyRight: PropTypes.bool,
|
|
1700
|
-
metricCalculator: PropTypes.instanceOf(GridMetricCalculator),
|
|
1701
|
-
model: PropTypes.instanceOf(GridModel).isRequired,
|
|
1702
|
-
keyHandlers: PropTypes.arrayOf(PropTypes.instanceOf(KeyHandler)),
|
|
1703
|
-
mouseHandlers: PropTypes.arrayOf(PropTypes.instanceOf(GridMouseHandler)),
|
|
1704
|
-
movedColumns: PropTypes.arrayOf(PropTypes.shape({
|
|
1705
|
-
from: PropTypes.number.isRequired,
|
|
1706
|
-
to: PropTypes.number.isRequired
|
|
1707
|
-
})),
|
|
1708
|
-
movedRows: PropTypes.arrayOf(PropTypes.shape({
|
|
1709
|
-
from: PropTypes.number.isRequired,
|
|
1710
|
-
to: PropTypes.number.isRequired
|
|
1711
|
-
})),
|
|
1712
|
-
onError: PropTypes.func,
|
|
1713
|
-
onSelectionChanged: PropTypes.func,
|
|
1714
|
-
onMovedColumnsChanged: PropTypes.func,
|
|
1715
|
-
onMoveColumnComplete: PropTypes.func,
|
|
1716
|
-
onViewChanged: PropTypes.func,
|
|
1717
|
-
renderer: PropTypes.instanceOf(GridRenderer),
|
|
1718
|
-
stateOverride: PropTypes.shape({}),
|
|
1719
|
-
theme: PropTypes.shape({
|
|
1720
|
-
autoSelectColumn: PropTypes.bool,
|
|
1721
|
-
autoSelectRow: PropTypes.bool
|
|
1722
|
-
})
|
|
1723
|
-
};
|
|
1724
|
-
Grid.defaultProps = {
|
|
1949
|
+
_defineProperty(Grid, "defaultProps", {
|
|
1725
1950
|
canvasOptions: {
|
|
1726
1951
|
alpha: false
|
|
1727
1952
|
},
|
|
1728
1953
|
isStickyBottom: false,
|
|
1729
1954
|
isStickyRight: false,
|
|
1730
|
-
metricCalculator: null,
|
|
1731
1955
|
keyHandlers: [],
|
|
1732
1956
|
mouseHandlers: [],
|
|
1733
1957
|
movedColumns: [],
|
|
1734
1958
|
movedRows: [],
|
|
1735
|
-
onError: () =>
|
|
1736
|
-
onSelectionChanged: () =>
|
|
1737
|
-
onMovedColumnsChanged: () =>
|
|
1738
|
-
onMoveColumnComplete: () =>
|
|
1739
|
-
|
|
1740
|
-
|
|
1959
|
+
onError: () => undefined,
|
|
1960
|
+
onSelectionChanged: () => undefined,
|
|
1961
|
+
onMovedColumnsChanged: () => undefined,
|
|
1962
|
+
onMoveColumnComplete: () => undefined,
|
|
1963
|
+
onMovedRowsChanged: () => undefined,
|
|
1964
|
+
onMoveRowComplete: () => undefined,
|
|
1965
|
+
onViewChanged: () => undefined,
|
|
1741
1966
|
stateOverride: {},
|
|
1742
1967
|
theme: {
|
|
1743
1968
|
autoSelectColumn: false,
|
|
1744
1969
|
autoSelectRow: false
|
|
1745
1970
|
}
|
|
1746
|
-
};
|
|
1971
|
+
});
|
|
1972
|
+
|
|
1973
|
+
_defineProperty(Grid, "pixelsPerLine", 100 / 3);
|
|
1974
|
+
|
|
1975
|
+
_defineProperty(Grid, "dragTimeout", 1000);
|
|
1976
|
+
|
|
1977
|
+
_defineProperty(Grid, "getTheme", memoize(userTheme => _objectSpread(_objectSpread({}, GridTheme), userTheme)));
|
|
1978
|
+
|
|
1747
1979
|
export default Grid;
|
|
1748
1980
|
//# sourceMappingURL=Grid.js.map
|