@deephaven/grid 0.22.3-beta.18 → 0.22.3-beta.21
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 +5 -5
- package/dist/CellInputField.d.ts.map +1 -1
- package/dist/CellInputField.js +6 -23
- package/dist/CellInputField.js.map +1 -1
- package/dist/EditableGridModel.js +1 -0
- package/dist/EditableGridModel.js.map +1 -1
- package/dist/ExpandableGridModel.js +1 -0
- package/dist/ExpandableGridModel.js.map +1 -1
- package/dist/Grid.js +77 -315
- package/dist/Grid.js.map +1 -1
- package/dist/GridAxisRange.js.map +1 -1
- package/dist/GridColorUtils.js +1 -2
- package/dist/GridColorUtils.js.map +1 -1
- package/dist/GridMetricCalculator.js +83 -240
- package/dist/GridMetricCalculator.js.map +1 -1
- package/dist/GridModel.js +13 -31
- package/dist/GridModel.js.map +1 -1
- package/dist/GridMouseHandler.js +2 -15
- package/dist/GridMouseHandler.js.map +1 -1
- package/dist/GridRange.js +46 -160
- package/dist/GridRange.js.map +1 -1
- package/dist/GridRenderer.js +126 -407
- package/dist/GridRenderer.js.map +1 -1
- package/dist/GridTestUtils.js +0 -5
- package/dist/GridTestUtils.js.map +1 -1
- package/dist/GridTheme.js.map +1 -1
- package/dist/GridUtils.js +68 -217
- package/dist/GridUtils.js.map +1 -1
- package/dist/KeyHandler.js +2 -8
- package/dist/KeyHandler.js.map +1 -1
- package/dist/MockGridData.js.map +1 -1
- package/dist/MockGridModel.js +0 -42
- package/dist/MockGridModel.js.map +1 -1
- package/dist/MockTreeGridModel.js +6 -55
- package/dist/MockTreeGridModel.js.map +1 -1
- package/dist/StaticDataGridModel.js +0 -15
- package/dist/StaticDataGridModel.js.map +1 -1
- package/dist/ThemeContext.js.map +1 -1
- package/dist/ViewportDataGridModel.js +0 -14
- package/dist/ViewportDataGridModel.js.map +1 -1
- package/dist/errors/AssertionError.js +0 -3
- package/dist/errors/AssertionError.js.map +1 -1
- package/dist/errors/PasteError.js +0 -3
- package/dist/errors/PasteError.js.map +1 -1
- package/dist/errors/assertIsDefined.js.map +1 -1
- package/dist/errors/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/key-handlers/EditKeyHandler.js +0 -12
- package/dist/key-handlers/EditKeyHandler.js.map +1 -1
- package/dist/key-handlers/PasteKeyHandler.js +15 -33
- package/dist/key-handlers/PasteKeyHandler.js.map +1 -1
- package/dist/key-handlers/SelectionKeyHandler.js +6 -53
- package/dist/key-handlers/SelectionKeyHandler.js.map +1 -1
- package/dist/key-handlers/TreeKeyHandler.js +0 -11
- package/dist/key-handlers/TreeKeyHandler.js.map +1 -1
- package/dist/key-handlers/index.js.map +1 -1
- package/dist/memoizeClear.js +1 -4
- package/dist/memoizeClear.js.map +1 -1
- package/dist/mouse-handlers/EditMouseHandler.js +0 -5
- package/dist/mouse-handlers/EditMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridColumnMoveMouseHandler.js +35 -123
- package/dist/mouse-handlers/GridColumnMoveMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.js +2 -27
- package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridHorizontalScrollBarMouseHandler.js +0 -28
- package/dist/mouse-handlers/GridHorizontalScrollBarMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowMoveMouseHandler.js +0 -27
- package/dist/mouse-handlers/GridRowMoveMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.js +0 -23
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowTreeMouseHandler.js +0 -10
- package/dist/mouse-handlers/GridRowTreeMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridScrollBarCornerMouseHandler.js +0 -6
- package/dist/mouse-handlers/GridScrollBarCornerMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridSelectionMouseHandler.js +8 -38
- package/dist/mouse-handlers/GridSelectionMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridSeparatorMouseHandler.js +5 -54
- package/dist/mouse-handlers/GridSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridVerticalScrollBarMouseHandler.js +0 -28
- package/dist/mouse-handlers/GridVerticalScrollBarMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/index.js.map +1 -1
- package/package.json +4 -4
package/dist/Grid.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
2
|
-
|
|
3
2
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4
|
-
|
|
5
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
-
|
|
7
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
|
-
|
|
9
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
-
|
|
11
6
|
/* eslint react/no-did-update-set-state: "off" */
|
|
12
7
|
import React, { PureComponent } from 'react';
|
|
13
8
|
import classNames from 'classnames';
|
|
@@ -27,7 +22,6 @@ import { isExpandableGridModel } from "./ExpandableGridModel.js";
|
|
|
27
22
|
import { assertIsEditableGridModel, isEditableGridModel } from "./EditableGridModel.js";
|
|
28
23
|
import { assertIsDefined } from "./errors/index.js";
|
|
29
24
|
import ThemeContext from "./ThemeContext.js";
|
|
30
|
-
|
|
31
25
|
/**
|
|
32
26
|
* High performance, extendible, themeable grid component.
|
|
33
27
|
* Architectured to be fast and handle billions of rows/columns by default.
|
|
@@ -52,59 +46,47 @@ class Grid extends PureComponent {
|
|
|
52
46
|
* @returns The scale to use
|
|
53
47
|
*/
|
|
54
48
|
static getScale(context) {
|
|
55
|
-
var
|
|
49
|
+
var _ref, _ref2, _ref3, _ref4, _legacyContext$webkit;
|
|
50
|
+
var devicePixelRatio = window.devicePixelRatio || 1;
|
|
56
51
|
|
|
52
|
+
// backingStorePixelRatio is deprecated, but check it just in case
|
|
57
53
|
var legacyContext = context;
|
|
58
54
|
var backingStorePixelRatio = // Not worth converting to a massive if structure
|
|
59
55
|
// Converting would reduce readability and maintainability
|
|
60
56
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
61
|
-
legacyContext.webkitBackingStorePixelRatio
|
|
57
|
+
(_ref = (_ref2 = (_ref3 = (_ref4 = (_legacyContext$webkit = legacyContext.webkitBackingStorePixelRatio) !== null && _legacyContext$webkit !== void 0 ? _legacyContext$webkit : legacyContext.mozBackingStorePixelRatio) !== null && _ref4 !== void 0 ? _ref4 : legacyContext.msBackingStorePixelRatio) !== null && _ref3 !== void 0 ? _ref3 : legacyContext.oBackingStorePixelRatio) !== null && _ref2 !== void 0 ? _ref2 : legacyContext.backingStorePixelRatio) !== null && _ref !== void 0 ? _ref : 1;
|
|
62
58
|
return devicePixelRatio / backingStorePixelRatio;
|
|
63
59
|
}
|
|
60
|
+
|
|
64
61
|
/**
|
|
65
62
|
* Get the class name from the cursor provided
|
|
66
63
|
* @param cursor The grid cursor to use
|
|
67
64
|
* @returns Class name with the grid-cursor prefix or null if no cursor provided
|
|
68
65
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
66
|
static getCursorClassName(cursor) {
|
|
72
67
|
return cursor != null && cursor !== '' ? "grid-cursor-".concat(cursor) : null;
|
|
73
|
-
}
|
|
68
|
+
}
|
|
74
69
|
|
|
70
|
+
// Need to disable react/sort-comp so I can put the fields here
|
|
75
71
|
/* eslint-disable react/sort-comp */
|
|
76
72
|
|
|
77
|
-
|
|
78
73
|
/* eslint-enable react/sort-comp */
|
|
74
|
+
|
|
79
75
|
constructor(props) {
|
|
80
76
|
super(props);
|
|
81
|
-
|
|
82
77
|
_defineProperty(this, "renderer", void 0);
|
|
83
|
-
|
|
84
78
|
_defineProperty(this, "metricCalculator", void 0);
|
|
85
|
-
|
|
86
79
|
_defineProperty(this, "canvas", void 0);
|
|
87
|
-
|
|
88
80
|
_defineProperty(this, "canvasContext", void 0);
|
|
89
|
-
|
|
90
81
|
_defineProperty(this, "animationFrame", void 0);
|
|
91
|
-
|
|
92
82
|
_defineProperty(this, "prevMetrics", void 0);
|
|
93
|
-
|
|
94
83
|
_defineProperty(this, "metrics", void 0);
|
|
95
|
-
|
|
96
84
|
_defineProperty(this, "documentCursor", void 0);
|
|
97
|
-
|
|
98
85
|
_defineProperty(this, "dragTimer", void 0);
|
|
99
|
-
|
|
100
86
|
_defineProperty(this, "keyHandlers", void 0);
|
|
101
|
-
|
|
102
87
|
_defineProperty(this, "mouseHandlers", void 0);
|
|
103
|
-
|
|
104
88
|
_defineProperty(this, "getCachedKeyHandlers", memoize(keyHandlers => [...keyHandlers, ...this.keyHandlers].sort((a, b) => a.order - b.order)));
|
|
105
|
-
|
|
106
89
|
_defineProperty(this, "getCachedMouseHandlers", memoize(mouseHandlers => [...mouseHandlers, ...this.mouseHandlers].sort((a, b) => a.order - b.order)));
|
|
107
|
-
|
|
108
90
|
this.handleClick = this.handleClick.bind(this);
|
|
109
91
|
this.handleContextMenu = this.handleContextMenu.bind(this);
|
|
110
92
|
this.handleEditCellCancel = this.handleEditCellCancel.bind(this);
|
|
@@ -133,14 +115,16 @@ class Grid extends PureComponent {
|
|
|
133
115
|
this.canvasContext = null;
|
|
134
116
|
this.animationFrame = null;
|
|
135
117
|
this.prevMetrics = null;
|
|
136
|
-
this.metrics = null;
|
|
118
|
+
this.metrics = null;
|
|
119
|
+
|
|
120
|
+
// Track the cursor that is currently added to the document
|
|
137
121
|
// Add to document so that when dragging the cursor stays, even if mouse leaves the canvas
|
|
138
122
|
// Note: on document, not body so that cursor styling can be combined with
|
|
139
123
|
// blocked pointer events that would otherwise prevent cursor styling from showing
|
|
140
|
-
|
|
141
124
|
this.documentCursor = null;
|
|
142
|
-
this.dragTimer = null;
|
|
125
|
+
this.dragTimer = null;
|
|
143
126
|
|
|
127
|
+
// specify handler ordering, such that any extensions can insert handlers in between
|
|
144
128
|
this.keyHandlers = [new EditKeyHandler(400), new PasteKeyHandler(450), new SelectionKeyHandler(500), new TreeKeyHandler(900)];
|
|
145
129
|
this.mouseHandlers = [new GridRowSeparatorMouseHandler(100), new GridColumnSeparatorMouseHandler(200), new GridRowMoveMouseHandler(300), new GridColumnMoveMouseHandler(400), new EditMouseHandler(450), new GridVerticalScrollBarMouseHandler(500), new GridHorizontalScrollBarMouseHandler(600), new GridScrollBarCornerMouseHandler(700), new GridRowTreeMouseHandler(800), new GridSelectionMouseHandler(900)];
|
|
146
130
|
this.state = {
|
|
@@ -190,36 +174,33 @@ class Grid extends PureComponent {
|
|
|
190
174
|
isStuckToRight
|
|
191
175
|
};
|
|
192
176
|
}
|
|
193
|
-
|
|
194
177
|
componentDidMount() {
|
|
195
178
|
var _this$canvas;
|
|
179
|
+
this.initContext();
|
|
196
180
|
|
|
197
|
-
|
|
181
|
+
// Need to explicitly add wheel event to canvas so we can preventDefault/avoid passive listener issue
|
|
198
182
|
// Otherwise React attaches listener at doc level and you can't prevent default
|
|
199
183
|
// https://github.com/facebook/react/issues/14856
|
|
200
|
-
|
|
201
184
|
(_this$canvas = this.canvas) === null || _this$canvas === void 0 ? void 0 : _this$canvas.addEventListener('wheel', this.handleWheel, {
|
|
202
185
|
passive: false
|
|
203
186
|
});
|
|
204
187
|
window.addEventListener('resize', this.handleResize);
|
|
205
188
|
this.updateCanvasScale();
|
|
206
|
-
this.updateCanvas();
|
|
207
|
-
// https://github.com/deephaven/web-client-ui/issues/581
|
|
189
|
+
this.updateCanvas();
|
|
208
190
|
|
|
191
|
+
// apply on mount, so that it works with a static model
|
|
192
|
+
// https://github.com/deephaven/web-client-ui/issues/581
|
|
209
193
|
var {
|
|
210
194
|
isStuckToBottom,
|
|
211
195
|
isStuckToRight
|
|
212
196
|
} = this.props;
|
|
213
|
-
|
|
214
197
|
if (isStuckToBottom) {
|
|
215
198
|
this.scrollToBottom();
|
|
216
199
|
}
|
|
217
|
-
|
|
218
200
|
if (isStuckToRight) {
|
|
219
201
|
this.scrollToRight();
|
|
220
202
|
}
|
|
221
203
|
}
|
|
222
|
-
|
|
223
204
|
componentDidUpdate(prevProps, prevState) {
|
|
224
205
|
var {
|
|
225
206
|
isStickyBottom,
|
|
@@ -247,54 +228,43 @@ class Grid extends PureComponent {
|
|
|
247
228
|
movedColumns: currentStateMovedColumns,
|
|
248
229
|
movedRows: currentStateMovedRows
|
|
249
230
|
} = this.state;
|
|
250
|
-
|
|
251
231
|
if (prevPropMovedColumns !== movedColumns) {
|
|
252
232
|
this.setState({
|
|
253
233
|
movedColumns
|
|
254
234
|
});
|
|
255
235
|
}
|
|
256
|
-
|
|
257
236
|
if (prevPropMovedRows !== movedRows) {
|
|
258
237
|
this.setState({
|
|
259
238
|
movedRows
|
|
260
239
|
});
|
|
261
240
|
}
|
|
262
|
-
|
|
263
241
|
if (prevStateMovedColumns !== currentStateMovedColumns) {
|
|
264
242
|
onMovedColumnsChanged(currentStateMovedColumns);
|
|
265
243
|
}
|
|
266
|
-
|
|
267
244
|
if (prevState.draggingColumn != null && draggingColumn == null) {
|
|
268
245
|
onMoveColumnComplete(currentStateMovedColumns);
|
|
269
246
|
}
|
|
270
|
-
|
|
271
247
|
if (prevStateMovedRows !== currentStateMovedRows) {
|
|
272
248
|
onMovedRowsChanged(currentStateMovedRows);
|
|
273
249
|
}
|
|
274
|
-
|
|
275
250
|
if (prevState.draggingRow != null && draggingRow == null) {
|
|
276
251
|
onMoveRowComplete(currentStateMovedRows);
|
|
277
252
|
}
|
|
278
|
-
|
|
279
253
|
if (isStickyBottom !== prevIsStickyBottom) {
|
|
280
254
|
this.setState({
|
|
281
255
|
isStuckToBottom: false
|
|
282
256
|
});
|
|
283
257
|
}
|
|
284
|
-
|
|
285
258
|
if (isStickyRight !== prevIsStickyRight) {
|
|
286
259
|
this.setState({
|
|
287
260
|
isStuckToRight: false
|
|
288
261
|
});
|
|
289
262
|
}
|
|
290
|
-
|
|
291
263
|
this.updateMetrics();
|
|
292
264
|
this.requestUpdateCanvas();
|
|
293
|
-
|
|
294
265
|
if (!this.metrics || !this.prevMetrics) {
|
|
295
266
|
return;
|
|
296
267
|
}
|
|
297
|
-
|
|
298
268
|
var {
|
|
299
269
|
rowCount,
|
|
300
270
|
columnCount,
|
|
@@ -307,53 +277,43 @@ class Grid extends PureComponent {
|
|
|
307
277
|
height: prevHeight,
|
|
308
278
|
width: prevWidth
|
|
309
279
|
} = this.prevMetrics;
|
|
310
|
-
|
|
311
280
|
if (prevRowCount !== rowCount || height !== prevHeight) {
|
|
312
281
|
var {
|
|
313
282
|
isStuckToBottom
|
|
314
283
|
} = this.state;
|
|
315
|
-
|
|
316
284
|
if (isStuckToBottom) {
|
|
317
285
|
this.scrollToBottom();
|
|
318
286
|
}
|
|
319
287
|
}
|
|
320
|
-
|
|
321
288
|
if (prevColumnCount !== columnCount || width !== prevWidth) {
|
|
322
289
|
var {
|
|
323
290
|
isStuckToRight
|
|
324
291
|
} = this.state;
|
|
325
|
-
|
|
326
292
|
if (isStuckToRight) {
|
|
327
293
|
this.scrollToRight();
|
|
328
294
|
}
|
|
329
295
|
}
|
|
330
|
-
|
|
331
296
|
if (this.validateSelection()) {
|
|
332
297
|
this.checkSelectionChange(prevState);
|
|
333
298
|
}
|
|
334
299
|
}
|
|
335
|
-
|
|
336
300
|
componentWillUnmount() {
|
|
337
301
|
var _this$canvas2;
|
|
338
|
-
|
|
339
302
|
if (this.animationFrame != null) {
|
|
340
303
|
cancelAnimationFrame(this.animationFrame);
|
|
341
304
|
}
|
|
342
|
-
|
|
343
305
|
(_this$canvas2 = this.canvas) === null || _this$canvas2 === void 0 ? void 0 : _this$canvas2.removeEventListener('wheel', this.handleWheel);
|
|
344
306
|
window.removeEventListener('mousemove', this.handleMouseDrag, true);
|
|
345
307
|
window.removeEventListener('mouseup', this.handleMouseUp, true);
|
|
346
308
|
window.removeEventListener('resize', this.handleResize);
|
|
347
309
|
this.stopDragTimer();
|
|
348
310
|
}
|
|
349
|
-
|
|
350
311
|
getTheme() {
|
|
351
312
|
var {
|
|
352
313
|
theme
|
|
353
314
|
} = this.props;
|
|
354
315
|
return Grid.getTheme(this.context, theme);
|
|
355
316
|
}
|
|
356
|
-
|
|
357
317
|
getGridPointFromEvent(event) {
|
|
358
318
|
assertIsDefined(this.canvas);
|
|
359
319
|
var rect = this.canvas.getBoundingClientRect();
|
|
@@ -361,12 +321,10 @@ class Grid extends PureComponent {
|
|
|
361
321
|
var y = event.clientY - rect.top;
|
|
362
322
|
return this.getGridPointFromXY(x, y);
|
|
363
323
|
}
|
|
364
|
-
|
|
365
324
|
getGridPointFromXY(x, y) {
|
|
366
325
|
if (!this.metrics) throw new Error('metrics must be set');
|
|
367
326
|
return GridUtils.getGridPointFromXY(x, y, this.metrics);
|
|
368
327
|
}
|
|
369
|
-
|
|
370
328
|
getMetricState() {
|
|
371
329
|
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.state;
|
|
372
330
|
var theme = this.getTheme();
|
|
@@ -374,11 +332,9 @@ class Grid extends PureComponent {
|
|
|
374
332
|
model,
|
|
375
333
|
stateOverride
|
|
376
334
|
} = this.props;
|
|
377
|
-
|
|
378
335
|
if (!this.canvasContext || !this.canvas) {
|
|
379
336
|
throw new Error('Canvas and context must be defined to get metrics');
|
|
380
337
|
}
|
|
381
|
-
|
|
382
338
|
var context = this.canvasContext;
|
|
383
339
|
var width = this.canvas.clientWidth;
|
|
384
340
|
var height = this.canvas.clientHeight;
|
|
@@ -410,87 +366,73 @@ class Grid extends PureComponent {
|
|
|
410
366
|
draggingColumn
|
|
411
367
|
}, stateOverride);
|
|
412
368
|
}
|
|
413
|
-
|
|
414
369
|
getKeyHandlers() {
|
|
415
370
|
var {
|
|
416
371
|
keyHandlers
|
|
417
372
|
} = this.props;
|
|
418
373
|
return this.getCachedKeyHandlers(keyHandlers);
|
|
419
374
|
}
|
|
420
|
-
|
|
421
375
|
getMouseHandlers() {
|
|
422
376
|
var {
|
|
423
377
|
mouseHandlers
|
|
424
378
|
} = this.props;
|
|
425
379
|
return this.getCachedMouseHandlers(mouseHandlers);
|
|
426
380
|
}
|
|
381
|
+
|
|
427
382
|
/**
|
|
428
383
|
* Translate from the provided visible index to the model index
|
|
429
384
|
* @param columnIndex The column index to get the model for
|
|
430
385
|
* @returns The model index
|
|
431
386
|
*/
|
|
432
|
-
|
|
433
|
-
|
|
434
387
|
getModelColumn(columnIndex) {
|
|
435
388
|
var _this$metrics, _this$metrics$modelCo;
|
|
436
|
-
|
|
437
389
|
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);
|
|
438
|
-
|
|
439
390
|
if (modelIndex === undefined) {
|
|
440
391
|
throw new Error("Unable to get ModelIndex for column ".concat(columnIndex));
|
|
441
392
|
}
|
|
442
|
-
|
|
443
393
|
return modelIndex;
|
|
444
394
|
}
|
|
395
|
+
|
|
445
396
|
/**
|
|
446
397
|
* Translate from the provided visible index to the model index
|
|
447
398
|
* @param rowIndex The row index to get the model for
|
|
448
399
|
* @returns The model index
|
|
449
400
|
*/
|
|
450
|
-
|
|
451
|
-
|
|
452
401
|
getModelRow(rowIndex) {
|
|
453
402
|
var _this$metrics2, _this$metrics2$modelR;
|
|
454
|
-
|
|
455
403
|
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);
|
|
456
|
-
|
|
457
404
|
if (modelIndex === undefined) {
|
|
458
405
|
throw new Error("Unable to get ModelIndex for row ".concat(rowIndex));
|
|
459
406
|
}
|
|
460
|
-
|
|
461
407
|
return modelIndex;
|
|
462
408
|
}
|
|
409
|
+
|
|
463
410
|
/**
|
|
464
411
|
* Toggle a row between expanded and collapsed states
|
|
465
412
|
* @param row The row to toggle expansion for
|
|
466
413
|
*/
|
|
467
|
-
|
|
468
|
-
|
|
469
414
|
toggleRowExpanded(row) {
|
|
470
415
|
var modelRow = this.getModelRow(row);
|
|
471
416
|
var {
|
|
472
417
|
model
|
|
473
|
-
} = this.props;
|
|
418
|
+
} = this.props;
|
|
419
|
+
// We only want to set expansion if the row is expandable
|
|
474
420
|
// 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
|
|
475
|
-
|
|
476
421
|
if (isExpandableGridModel(model) && model.isRowExpandable(modelRow)) {
|
|
477
422
|
model.setRowExpanded(modelRow, !model.isRowExpanded(modelRow));
|
|
478
423
|
}
|
|
479
|
-
|
|
480
424
|
this.clearSelectedRanges();
|
|
481
425
|
this.commitSelection(); // Need to commit before moving in case we're selecting same row again
|
|
482
|
-
|
|
483
426
|
this.moveCursorToPosition(0, row);
|
|
484
427
|
this.commitSelection();
|
|
485
428
|
this.setState({
|
|
486
429
|
isStuckToBottom: false
|
|
487
430
|
});
|
|
488
431
|
}
|
|
432
|
+
|
|
489
433
|
/**
|
|
490
434
|
* Scrolls to bottom, if not already at bottom
|
|
491
435
|
*/
|
|
492
|
-
|
|
493
|
-
|
|
494
436
|
scrollToBottom() {
|
|
495
437
|
if (!this.metrics) return;
|
|
496
438
|
var {
|
|
@@ -499,18 +441,16 @@ class Grid extends PureComponent {
|
|
|
499
441
|
top,
|
|
500
442
|
lastTop
|
|
501
443
|
} = this.metrics;
|
|
502
|
-
|
|
503
444
|
if (bottomVisible < rowCount - 1 && bottomVisible > 0 || top > lastTop) {
|
|
504
445
|
this.setState({
|
|
505
446
|
top: lastTop
|
|
506
447
|
});
|
|
507
448
|
}
|
|
508
449
|
}
|
|
450
|
+
|
|
509
451
|
/**
|
|
510
452
|
* Scrolls to right, if not already at right
|
|
511
453
|
*/
|
|
512
|
-
|
|
513
|
-
|
|
514
454
|
scrollToRight() {
|
|
515
455
|
if (!this.metrics) return;
|
|
516
456
|
var {
|
|
@@ -519,20 +459,18 @@ class Grid extends PureComponent {
|
|
|
519
459
|
left,
|
|
520
460
|
lastLeft
|
|
521
461
|
} = this.metrics;
|
|
522
|
-
|
|
523
462
|
if (rightVisible < columnCount - 1 && rightVisible > 0 || left > lastLeft) {
|
|
524
463
|
this.setState({
|
|
525
464
|
left: lastLeft
|
|
526
465
|
});
|
|
527
466
|
}
|
|
528
467
|
}
|
|
468
|
+
|
|
529
469
|
/**
|
|
530
470
|
* Allows the selected ranges to be set programatically
|
|
531
471
|
* Will update the cursor and selection start/end based on the new ranges
|
|
532
472
|
* @param gridRanges The new selected ranges to set
|
|
533
473
|
*/
|
|
534
|
-
|
|
535
|
-
|
|
536
474
|
setSelectedRanges(gridRanges) {
|
|
537
475
|
var {
|
|
538
476
|
model
|
|
@@ -550,19 +488,16 @@ class Grid extends PureComponent {
|
|
|
550
488
|
selectedRanges: gridRanges,
|
|
551
489
|
lastSelectedRanges: selectedRanges
|
|
552
490
|
});
|
|
553
|
-
|
|
554
491
|
if (gridRanges.length > 0) {
|
|
555
492
|
var range = GridRange.boundedRange(gridRanges[0], columnCount, rowCount);
|
|
556
493
|
var newCursorRow = cursorRow;
|
|
557
494
|
var newCursorColumn = cursorColumn;
|
|
558
|
-
|
|
559
495
|
if (!range.containsCell(cursorColumn, cursorRow)) {
|
|
560
496
|
({
|
|
561
497
|
row: newCursorRow,
|
|
562
498
|
column: newCursorColumn
|
|
563
499
|
} = range.startCell());
|
|
564
500
|
}
|
|
565
|
-
|
|
566
501
|
this.setState({
|
|
567
502
|
selectionStartColumn: range.startColumn,
|
|
568
503
|
selectionStartRow: range.startRow,
|
|
@@ -573,7 +508,6 @@ class Grid extends PureComponent {
|
|
|
573
508
|
});
|
|
574
509
|
}
|
|
575
510
|
}
|
|
576
|
-
|
|
577
511
|
initContext() {
|
|
578
512
|
var {
|
|
579
513
|
canvas
|
|
@@ -584,19 +518,16 @@ class Grid extends PureComponent {
|
|
|
584
518
|
if (!canvas) throw new Error('Canvas not set');
|
|
585
519
|
this.canvasContext = canvas.getContext('2d', canvasOptions);
|
|
586
520
|
}
|
|
587
|
-
|
|
588
521
|
requestUpdateCanvas() {
|
|
589
522
|
if (this.animationFrame != null) {
|
|
590
523
|
return;
|
|
591
524
|
}
|
|
592
|
-
|
|
593
525
|
this.animationFrame = requestAnimationFrame(() => {
|
|
594
526
|
this.animationFrame = null;
|
|
595
527
|
if (!this.metrics) throw new Error('Metrics not set');
|
|
596
528
|
this.updateCanvas(this.metrics);
|
|
597
529
|
});
|
|
598
530
|
}
|
|
599
|
-
|
|
600
531
|
updateCanvas() {
|
|
601
532
|
var metrics = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.updateMetrics();
|
|
602
533
|
this.updateCanvasScale();
|
|
@@ -606,7 +537,6 @@ class Grid extends PureComponent {
|
|
|
606
537
|
onViewChanged(metrics);
|
|
607
538
|
this.drawCanvas(metrics);
|
|
608
539
|
}
|
|
609
|
-
|
|
610
540
|
updateCanvasScale() {
|
|
611
541
|
var {
|
|
612
542
|
canvas,
|
|
@@ -615,11 +545,11 @@ class Grid extends PureComponent {
|
|
|
615
545
|
if (!canvas) throw new Error('canvas not set');
|
|
616
546
|
if (!canvasContext) throw new Error('canvasContext not set');
|
|
617
547
|
if (!canvas.parentElement) throw new Error('Canvas has no parent element');
|
|
618
|
-
var scale = Grid.getScale(canvasContext);
|
|
548
|
+
var scale = Grid.getScale(canvasContext);
|
|
549
|
+
// the parent wrapper has 100% width/height, and is used for determining size
|
|
619
550
|
// we don't want to stretch the canvas to 100%, to avoid fractional pixels.
|
|
620
551
|
// A wrapper element must be used for sizing, and canvas size must be
|
|
621
552
|
// set manually to a floored value in css and a scaled value in width/height
|
|
622
|
-
|
|
623
553
|
var rect = canvas.parentElement.getBoundingClientRect();
|
|
624
554
|
var width = Math.floor(rect.width);
|
|
625
555
|
var height = Math.floor(rect.height);
|
|
@@ -629,7 +559,6 @@ class Grid extends PureComponent {
|
|
|
629
559
|
canvas.height = height * scale;
|
|
630
560
|
canvasContext.scale(scale, scale);
|
|
631
561
|
}
|
|
632
|
-
|
|
633
562
|
updateMetrics() {
|
|
634
563
|
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.state;
|
|
635
564
|
this.prevMetrics = this.metrics;
|
|
@@ -640,12 +569,11 @@ class Grid extends PureComponent {
|
|
|
640
569
|
this.metrics = metricCalculator.getMetrics(metricState);
|
|
641
570
|
return this.metrics;
|
|
642
571
|
}
|
|
572
|
+
|
|
643
573
|
/**
|
|
644
574
|
* Check if the selection state has changed, and call the onSelectionChanged callback if they have
|
|
645
575
|
* @param prevState The previous grid state
|
|
646
576
|
*/
|
|
647
|
-
|
|
648
|
-
|
|
649
577
|
checkSelectionChange(prevState) {
|
|
650
578
|
var {
|
|
651
579
|
selectedRanges: oldSelectedRanges
|
|
@@ -653,7 +581,6 @@ class Grid extends PureComponent {
|
|
|
653
581
|
var {
|
|
654
582
|
selectedRanges
|
|
655
583
|
} = this.state;
|
|
656
|
-
|
|
657
584
|
if (selectedRanges !== oldSelectedRanges) {
|
|
658
585
|
var {
|
|
659
586
|
onSelectionChanged
|
|
@@ -661,12 +588,11 @@ class Grid extends PureComponent {
|
|
|
661
588
|
onSelectionChanged(selectedRanges);
|
|
662
589
|
}
|
|
663
590
|
}
|
|
591
|
+
|
|
664
592
|
/**
|
|
665
593
|
* Validate the current selection, and reset if it is invalid
|
|
666
594
|
* @returns True if the selection is valid, false if the selection was invalid and has been reset
|
|
667
595
|
*/
|
|
668
|
-
|
|
669
|
-
|
|
670
596
|
validateSelection() {
|
|
671
597
|
var {
|
|
672
598
|
model
|
|
@@ -678,10 +604,8 @@ class Grid extends PureComponent {
|
|
|
678
604
|
columnCount,
|
|
679
605
|
rowCount
|
|
680
606
|
} = model;
|
|
681
|
-
|
|
682
607
|
for (var i = 0; i < selectedRanges.length; i += 1) {
|
|
683
608
|
var range = selectedRanges[i];
|
|
684
|
-
|
|
685
609
|
if (range.endColumn != null && range.endColumn >= columnCount || range.endRow != null && range.endRow >= rowCount) {
|
|
686
610
|
// Just clear the selection rather than trying to trim it.
|
|
687
611
|
this.setState({
|
|
@@ -691,14 +615,12 @@ class Grid extends PureComponent {
|
|
|
691
615
|
return false;
|
|
692
616
|
}
|
|
693
617
|
}
|
|
694
|
-
|
|
695
618
|
return true;
|
|
696
619
|
}
|
|
620
|
+
|
|
697
621
|
/**
|
|
698
622
|
* Clears all selected ranges
|
|
699
623
|
*/
|
|
700
|
-
|
|
701
|
-
|
|
702
624
|
clearSelectedRanges() {
|
|
703
625
|
var {
|
|
704
626
|
selectedRanges
|
|
@@ -708,27 +630,24 @@ class Grid extends PureComponent {
|
|
|
708
630
|
lastSelectedRanges: selectedRanges
|
|
709
631
|
});
|
|
710
632
|
}
|
|
711
|
-
/** Clears all but the last selected range */
|
|
712
|
-
|
|
713
633
|
|
|
634
|
+
/** Clears all but the last selected range */
|
|
714
635
|
trimSelectedRanges() {
|
|
715
636
|
var {
|
|
716
637
|
selectedRanges
|
|
717
638
|
} = this.state;
|
|
718
|
-
|
|
719
639
|
if (selectedRanges.length > 0) {
|
|
720
640
|
this.setState({
|
|
721
641
|
selectedRanges: selectedRanges.slice(selectedRanges.length - 1)
|
|
722
642
|
});
|
|
723
643
|
}
|
|
724
644
|
}
|
|
645
|
+
|
|
725
646
|
/**
|
|
726
647
|
* Begin a selection operation at the provided location
|
|
727
648
|
* @param column Column where the selection is beginning
|
|
728
649
|
* @param row Row where the selection is beginning
|
|
729
650
|
*/
|
|
730
|
-
|
|
731
|
-
|
|
732
651
|
beginSelection(column, row) {
|
|
733
652
|
this.setState({
|
|
734
653
|
selectionStartColumn: column,
|
|
@@ -739,6 +658,7 @@ class Grid extends PureComponent {
|
|
|
739
658
|
cursorRow: row
|
|
740
659
|
});
|
|
741
660
|
}
|
|
661
|
+
|
|
742
662
|
/**
|
|
743
663
|
* Moves the selection to the cell specified
|
|
744
664
|
* @param column The column index to move the cursor to
|
|
@@ -746,8 +666,6 @@ class Grid extends PureComponent {
|
|
|
746
666
|
* @param extendSelection Whether to extend the current selection (eg. holding Shift)
|
|
747
667
|
* @param maximizePreviousRange When true, maximize/add to the previous range only, ignoring where the selection was started.
|
|
748
668
|
*/
|
|
749
|
-
|
|
750
|
-
|
|
751
669
|
moveSelection(column, row) {
|
|
752
670
|
var extendSelection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
753
671
|
var maximizePreviousRange = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
@@ -764,17 +682,14 @@ class Grid extends PureComponent {
|
|
|
764
682
|
autoSelectRow,
|
|
765
683
|
autoSelectColumn
|
|
766
684
|
} = theme;
|
|
767
|
-
|
|
768
685
|
if (extendSelection && selectedRanges.length > 0) {
|
|
769
686
|
var lastSelectedRange = selectedRanges[selectedRanges.length - 1];
|
|
770
687
|
var left = null;
|
|
771
688
|
var top = null;
|
|
772
689
|
var right = null;
|
|
773
690
|
var bottom = null;
|
|
774
|
-
|
|
775
691
|
if (maximizePreviousRange) {
|
|
776
692
|
var _lastSelectedRange$st, _lastSelectedRange$st2, _lastSelectedRange$en, _lastSelectedRange$en2;
|
|
777
|
-
|
|
778
693
|
left = autoSelectRow !== undefined && autoSelectRow ? null : Math.min(column !== null && column !== void 0 ? column : 0, (_lastSelectedRange$st = lastSelectedRange.startColumn) !== null && _lastSelectedRange$st !== void 0 ? _lastSelectedRange$st : 0);
|
|
779
694
|
top = autoSelectColumn !== undefined && autoSelectColumn ? null : Math.min(row !== null && row !== void 0 ? row : 0, (_lastSelectedRange$st2 = lastSelectedRange.startRow) !== null && _lastSelectedRange$st2 !== void 0 ? _lastSelectedRange$st2 : 0);
|
|
780
695
|
right = autoSelectRow !== undefined && autoSelectRow ? null : Math.max(column !== null && column !== void 0 ? column : 0, (_lastSelectedRange$en = lastSelectedRange.endColumn) !== null && _lastSelectedRange$en !== void 0 ? _lastSelectedRange$en : 0);
|
|
@@ -782,27 +697,21 @@ class Grid extends PureComponent {
|
|
|
782
697
|
} else {
|
|
783
698
|
left = lastSelectedRange.startColumn;
|
|
784
699
|
top = lastSelectedRange.startRow;
|
|
785
|
-
|
|
786
700
|
if (selectionStartColumn != null || selectionStartRow != null) {
|
|
787
701
|
if (autoSelectRow === undefined || !autoSelectRow) {
|
|
788
702
|
left = selectionStartColumn;
|
|
789
703
|
}
|
|
790
|
-
|
|
791
704
|
if (autoSelectColumn === undefined || !autoSelectColumn) {
|
|
792
705
|
top = selectionStartRow;
|
|
793
706
|
}
|
|
794
707
|
}
|
|
795
|
-
|
|
796
708
|
right = autoSelectRow !== undefined && autoSelectRow ? null : column;
|
|
797
709
|
bottom = autoSelectColumn !== undefined && autoSelectColumn ? null : row;
|
|
798
710
|
}
|
|
799
|
-
|
|
800
711
|
var selectedRange = GridRange.makeNormalized(left, top, right, bottom);
|
|
801
|
-
|
|
802
712
|
if (lastSelectedRange.equals(selectedRange)) {
|
|
803
713
|
return null;
|
|
804
714
|
}
|
|
805
|
-
|
|
806
715
|
var _newRanges = [...selectedRanges];
|
|
807
716
|
_newRanges[_newRanges.length - 1] = selectedRange;
|
|
808
717
|
return {
|
|
@@ -811,7 +720,6 @@ class Grid extends PureComponent {
|
|
|
811
720
|
selectionEndRow: row
|
|
812
721
|
};
|
|
813
722
|
}
|
|
814
|
-
|
|
815
723
|
var newRanges = [...selectedRanges];
|
|
816
724
|
var selectedColumn = autoSelectRow !== undefined && autoSelectRow ? null : column;
|
|
817
725
|
var selectedRow = autoSelectColumn !== undefined && autoSelectColumn ? null : row;
|
|
@@ -823,14 +731,13 @@ class Grid extends PureComponent {
|
|
|
823
731
|
};
|
|
824
732
|
});
|
|
825
733
|
}
|
|
734
|
+
|
|
826
735
|
/**
|
|
827
736
|
* Commits the last selected range to the selected ranges.
|
|
828
737
|
* First checks if the last range is completely contained within another range, and if it
|
|
829
738
|
* is then it blows those ranges apart.
|
|
830
739
|
* Then it consolidates all the selected ranges, reducing them.
|
|
831
740
|
*/
|
|
832
|
-
|
|
833
|
-
|
|
834
741
|
commitSelection() {
|
|
835
742
|
this.setState(state => {
|
|
836
743
|
var {
|
|
@@ -845,7 +752,6 @@ class Grid extends PureComponent {
|
|
|
845
752
|
cursorRow,
|
|
846
753
|
cursorColumn
|
|
847
754
|
} = state;
|
|
848
|
-
|
|
849
755
|
if (selectedRanges.length === 1 && (autoSelectRow !== undefined && autoSelectRow ? GridRange.rowCount(selectedRanges) === 1 : GridRange.cellCount(selectedRanges) === 1) && GridRange.rangeArraysEqual(selectedRanges, lastSelectedRanges)) {
|
|
850
756
|
// If it's the exact same single selection, then deselect.
|
|
851
757
|
// For if we click on one cell multiple times.
|
|
@@ -856,17 +762,13 @@ class Grid extends PureComponent {
|
|
|
856
762
|
cursorRow
|
|
857
763
|
};
|
|
858
764
|
}
|
|
859
|
-
|
|
860
765
|
var newSelectedRanges = selectedRanges.slice();
|
|
861
|
-
|
|
862
766
|
if (newSelectedRanges.length > 1) {
|
|
863
767
|
// Check if the latest selection is entirely within a previously selected range
|
|
864
768
|
// If that's the case, then deselect that section instead
|
|
865
769
|
var lastRange = newSelectedRanges[newSelectedRanges.length - 1];
|
|
866
|
-
|
|
867
770
|
for (var i = 0; i < newSelectedRanges.length - 1; i += 1) {
|
|
868
771
|
var selectedRange = newSelectedRanges[i];
|
|
869
|
-
|
|
870
772
|
if (selectedRange.contains(lastRange)) {
|
|
871
773
|
// We found a match, now remove the two matching ranges, and add back
|
|
872
774
|
// the remainder of the two
|
|
@@ -877,13 +779,10 @@ class Grid extends PureComponent {
|
|
|
877
779
|
break;
|
|
878
780
|
}
|
|
879
781
|
}
|
|
880
|
-
|
|
881
782
|
newSelectedRanges = GridRange.consolidate(newSelectedRanges);
|
|
882
783
|
}
|
|
883
|
-
|
|
884
784
|
var newCursorColumn = cursorColumn;
|
|
885
785
|
var newCursorRow = cursorRow;
|
|
886
|
-
|
|
887
786
|
if (!GridRange.containsCell(newSelectedRanges, cursorColumn, cursorRow)) {
|
|
888
787
|
var {
|
|
889
788
|
model
|
|
@@ -893,7 +792,6 @@ class Grid extends PureComponent {
|
|
|
893
792
|
rowCount
|
|
894
793
|
} = model;
|
|
895
794
|
var nextCursor = GridRange.nextCell(GridRange.boundedRanges(selectedRanges, columnCount, rowCount));
|
|
896
|
-
|
|
897
795
|
if (nextCursor != null) {
|
|
898
796
|
({
|
|
899
797
|
column: newCursorColumn,
|
|
@@ -904,7 +802,6 @@ class Grid extends PureComponent {
|
|
|
904
802
|
newCursorRow = null;
|
|
905
803
|
}
|
|
906
804
|
}
|
|
907
|
-
|
|
908
805
|
return {
|
|
909
806
|
cursorRow: newCursorRow,
|
|
910
807
|
cursorColumn: newCursorColumn,
|
|
@@ -913,14 +810,11 @@ class Grid extends PureComponent {
|
|
|
913
810
|
};
|
|
914
811
|
});
|
|
915
812
|
}
|
|
916
|
-
|
|
917
813
|
setFocusRow(focusedRow) {
|
|
918
814
|
var _userRowHeights$get;
|
|
919
|
-
|
|
920
815
|
if (!this.metrics || !this.prevMetrics) {
|
|
921
816
|
return;
|
|
922
817
|
}
|
|
923
|
-
|
|
924
818
|
var {
|
|
925
819
|
gridY,
|
|
926
820
|
height,
|
|
@@ -941,11 +835,10 @@ class Grid extends PureComponent {
|
|
|
941
835
|
} = this.state;
|
|
942
836
|
this.moveCursorToPosition(cursorColumn, focusedRow, false, false);
|
|
943
837
|
}
|
|
838
|
+
|
|
944
839
|
/**
|
|
945
840
|
* Set the selection to the entire grid
|
|
946
841
|
*/
|
|
947
|
-
|
|
948
|
-
|
|
949
842
|
selectAll() {
|
|
950
843
|
var {
|
|
951
844
|
model,
|
|
@@ -961,14 +854,13 @@ class Grid extends PureComponent {
|
|
|
961
854
|
var right = autoSelectRow !== undefined && autoSelectRow ? null : model.columnCount - 1;
|
|
962
855
|
this.setSelectedRanges([new GridRange(left, top, right, bottom)]);
|
|
963
856
|
}
|
|
857
|
+
|
|
964
858
|
/**
|
|
965
859
|
* Move the cursor in relation to the current cursor position
|
|
966
860
|
* @param deltaColumn Number of columns to move the cursor
|
|
967
861
|
* @param deltaRow Number of rows to move the cursor
|
|
968
862
|
* @param extendSelection True if the current selection should be extended, false to start a new selection
|
|
969
863
|
*/
|
|
970
|
-
|
|
971
|
-
|
|
972
864
|
moveCursor(deltaColumn, deltaRow, extendSelection) {
|
|
973
865
|
var {
|
|
974
866
|
cursorRow,
|
|
@@ -978,7 +870,6 @@ class Grid extends PureComponent {
|
|
|
978
870
|
} = this.state;
|
|
979
871
|
var column = extendSelection ? selectionEndColumn : cursorColumn;
|
|
980
872
|
var row = extendSelection ? selectionEndRow : cursorRow;
|
|
981
|
-
|
|
982
873
|
if (row === null || column === null) {
|
|
983
874
|
var {
|
|
984
875
|
left,
|
|
@@ -993,20 +884,16 @@ class Grid extends PureComponent {
|
|
|
993
884
|
columnCount,
|
|
994
885
|
rowCount
|
|
995
886
|
} = model;
|
|
996
|
-
|
|
997
887
|
var _left = clamp(column + deltaColumn, 0, columnCount - 1);
|
|
998
|
-
|
|
999
888
|
var _top = clamp(row + deltaRow, 0, rowCount - 1);
|
|
1000
|
-
|
|
1001
889
|
this.moveCursorToPosition(_left, _top, extendSelection);
|
|
1002
890
|
}
|
|
1003
891
|
}
|
|
892
|
+
|
|
1004
893
|
/**
|
|
1005
894
|
* Move the cursor in the provided selection direction
|
|
1006
895
|
* @param direction The direction to move the cursor in
|
|
1007
896
|
*/
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
897
|
moveCursorInDirection() {
|
|
1011
898
|
var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : GridRange.SELECTION_DIRECTION.DOWN;
|
|
1012
899
|
var {
|
|
@@ -1023,17 +910,14 @@ class Grid extends PureComponent {
|
|
|
1023
910
|
} = this.state;
|
|
1024
911
|
var ranges = selectedRanges.length > 0 ? selectedRanges : [GridRange.makeCell(cursorColumn, cursorRow)];
|
|
1025
912
|
var nextCursor = null;
|
|
1026
|
-
|
|
1027
913
|
if (ranges.length === 1 && GridRange.cellCount(ranges) === 1) {
|
|
1028
914
|
var _gridRange$nextCell;
|
|
1029
|
-
|
|
1030
915
|
// If we only have one cell selected, we want to update the cursor and we want to update the selected cells
|
|
1031
916
|
var gridRange = new GridRange(0, 0, columnCount - 1, rowCount - 1);
|
|
1032
917
|
nextCursor = (_gridRange$nextCell = gridRange.nextCell(cursorColumn, cursorRow, direction)) !== null && _gridRange$nextCell !== void 0 ? _gridRange$nextCell : gridRange.startCell(direction);
|
|
1033
918
|
} else {
|
|
1034
919
|
nextCursor = GridRange.nextCell(GridRange.boundedRanges(ranges, columnCount, rowCount), cursorColumn, cursorRow, direction);
|
|
1035
920
|
}
|
|
1036
|
-
|
|
1037
921
|
if (nextCursor != null) {
|
|
1038
922
|
var {
|
|
1039
923
|
column,
|
|
@@ -1043,7 +927,6 @@ class Grid extends PureComponent {
|
|
|
1043
927
|
cursorColumn: column,
|
|
1044
928
|
cursorRow: row
|
|
1045
929
|
});
|
|
1046
|
-
|
|
1047
930
|
if (!GridRange.containsCell(selectedRanges, column, row)) {
|
|
1048
931
|
this.setState({
|
|
1049
932
|
selectedRanges: [GridRange.makeCell(column, row)],
|
|
@@ -1053,10 +936,10 @@ class Grid extends PureComponent {
|
|
|
1053
936
|
selectionEndRow: row
|
|
1054
937
|
});
|
|
1055
938
|
}
|
|
1056
|
-
|
|
1057
939
|
this.moveViewToCell(nextCursor.column, nextCursor.row);
|
|
1058
940
|
}
|
|
1059
941
|
}
|
|
942
|
+
|
|
1060
943
|
/**
|
|
1061
944
|
* Move a cursor to the specified position in the grid.
|
|
1062
945
|
* @param column The column index to move the cursor to
|
|
@@ -1065,31 +948,25 @@ class Grid extends PureComponent {
|
|
|
1065
948
|
* @param keepCursorInView Whether to move the viewport so that the cursor is in view
|
|
1066
949
|
* @param maximizePreviousRange With this and `extendSelection` true, it will maximize/add to the previous range only, ignoring where the selection was started
|
|
1067
950
|
*/
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
951
|
moveCursorToPosition(column, row) {
|
|
1071
952
|
var extendSelection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1072
953
|
var keepCursorInView = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
1073
954
|
var maximizePreviousRange = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
1074
|
-
|
|
1075
955
|
if (!extendSelection) {
|
|
1076
956
|
this.beginSelection(column, row);
|
|
1077
957
|
}
|
|
1078
|
-
|
|
1079
958
|
this.moveSelection(column, row, extendSelection, maximizePreviousRange);
|
|
1080
|
-
|
|
1081
959
|
if (keepCursorInView) {
|
|
1082
960
|
this.moveViewToCell(column, row);
|
|
1083
961
|
}
|
|
1084
962
|
}
|
|
963
|
+
|
|
1085
964
|
/**
|
|
1086
965
|
* Moves the view to make the specified cell visible
|
|
1087
966
|
*
|
|
1088
967
|
* @param column The column index to bring into view
|
|
1089
968
|
* @param row The row index to bring into view
|
|
1090
969
|
*/
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
970
|
moveViewToCell(column, row) {
|
|
1094
971
|
if (!this.metrics) throw new Error('metrics not set');
|
|
1095
972
|
var {
|
|
@@ -1108,7 +985,6 @@ class Grid extends PureComponent {
|
|
|
1108
985
|
topOffset,
|
|
1109
986
|
leftOffset
|
|
1110
987
|
} = this.state;
|
|
1111
|
-
|
|
1112
988
|
if (row != null && !GridUtils.isFloatingRow(row, this.metrics)) {
|
|
1113
989
|
if (row < topVisible) {
|
|
1114
990
|
top = metricCalculator.getTopForTopVisible(metricState, row);
|
|
@@ -1118,7 +994,6 @@ class Grid extends PureComponent {
|
|
|
1118
994
|
topOffset = 0;
|
|
1119
995
|
}
|
|
1120
996
|
}
|
|
1121
|
-
|
|
1122
997
|
if (column != null && !GridUtils.isFloatingColumn(column, this.metrics)) {
|
|
1123
998
|
if (column < leftVisible) {
|
|
1124
999
|
left = metricCalculator.getLeftForLeftVisible(metricState, column);
|
|
@@ -1128,7 +1003,6 @@ class Grid extends PureComponent {
|
|
|
1128
1003
|
leftOffset = 0;
|
|
1129
1004
|
}
|
|
1130
1005
|
}
|
|
1131
|
-
|
|
1132
1006
|
this.setViewState({
|
|
1133
1007
|
top,
|
|
1134
1008
|
left,
|
|
@@ -1136,14 +1010,13 @@ class Grid extends PureComponent {
|
|
|
1136
1010
|
leftOffset
|
|
1137
1011
|
});
|
|
1138
1012
|
}
|
|
1013
|
+
|
|
1139
1014
|
/**
|
|
1140
1015
|
* Checks the `top` and `left` properties that are set and updates the isStuckToBottom/Right properties
|
|
1141
1016
|
* Should be called when user interaction occurs
|
|
1142
1017
|
* @param viewState New state properties to set.
|
|
1143
1018
|
* @param forceUpdate Whether to force an update.
|
|
1144
1019
|
*/
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
1020
|
setViewState(viewState) {
|
|
1148
1021
|
var forceUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1149
1022
|
if (!this.metrics) throw new Error('metrics not set');
|
|
@@ -1159,25 +1032,22 @@ class Grid extends PureComponent {
|
|
|
1159
1032
|
lastTop,
|
|
1160
1033
|
lastLeft
|
|
1161
1034
|
} = this.metrics;
|
|
1162
|
-
|
|
1163
1035
|
if (top != null) {
|
|
1164
1036
|
this.setState({
|
|
1165
1037
|
isStuckToBottom: isStickyBottom && top >= lastTop
|
|
1166
1038
|
});
|
|
1167
1039
|
}
|
|
1168
|
-
|
|
1169
1040
|
if (left != null) {
|
|
1170
1041
|
this.setState({
|
|
1171
1042
|
isStuckToRight: isStickyRight && left >= lastLeft
|
|
1172
1043
|
});
|
|
1173
1044
|
}
|
|
1174
|
-
|
|
1175
1045
|
this.setState(viewState);
|
|
1176
|
-
|
|
1177
1046
|
if (forceUpdate) {
|
|
1178
1047
|
this.forceUpdate();
|
|
1179
1048
|
}
|
|
1180
1049
|
}
|
|
1050
|
+
|
|
1181
1051
|
/**
|
|
1182
1052
|
* Start editing the data at the given index
|
|
1183
1053
|
*
|
|
@@ -1187,8 +1057,6 @@ class Grid extends PureComponent {
|
|
|
1187
1057
|
* @param selectionRange The tuple [start,end] text selection range of the value to select when editing
|
|
1188
1058
|
* @param value The value to start with in the edit field. Leave undefined to use the current value.
|
|
1189
1059
|
*/
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
1060
|
startEditing(column, row) {
|
|
1193
1061
|
var isQuickEdit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1194
1062
|
var selectionRange = arguments.length > 3 ? arguments[3] : undefined;
|
|
@@ -1213,6 +1081,7 @@ class Grid extends PureComponent {
|
|
|
1213
1081
|
});
|
|
1214
1082
|
this.moveViewToCell(column, row);
|
|
1215
1083
|
}
|
|
1084
|
+
|
|
1216
1085
|
/**
|
|
1217
1086
|
* Check if a value is valid for a specific cell
|
|
1218
1087
|
* @param column Column index of the cell to check
|
|
@@ -1220,8 +1089,6 @@ class Grid extends PureComponent {
|
|
|
1220
1089
|
* @param value Value to check
|
|
1221
1090
|
* @returns True if the value is valid for the provided cell, false otherwise
|
|
1222
1091
|
*/
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
1092
|
isValidForCell(column, row, value) {
|
|
1226
1093
|
var {
|
|
1227
1094
|
model
|
|
@@ -1230,17 +1097,15 @@ class Grid extends PureComponent {
|
|
|
1230
1097
|
var modelRow = this.getModelRow(row);
|
|
1231
1098
|
return isEditableGridModel(model) && model.isValidForCell(modelColumn, modelRow, value);
|
|
1232
1099
|
}
|
|
1100
|
+
|
|
1233
1101
|
/**
|
|
1234
1102
|
* Paste a value with the current selection
|
|
1235
1103
|
* It first needs to validate that the pasted table is valid for the given selection.
|
|
1236
1104
|
* Also may update selection if single cells are selected and a table is pasted.
|
|
1237
1105
|
* @param value Table or a string that is being pasted
|
|
1238
1106
|
*/
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
1107
|
pasteValue(value) {
|
|
1242
1108
|
var _this = this;
|
|
1243
|
-
|
|
1244
1109
|
return _asyncToGenerator(function* () {
|
|
1245
1110
|
var {
|
|
1246
1111
|
model
|
|
@@ -1250,18 +1115,14 @@ class Grid extends PureComponent {
|
|
|
1250
1115
|
movedRows,
|
|
1251
1116
|
selectedRanges
|
|
1252
1117
|
} = _this.state;
|
|
1253
|
-
|
|
1254
1118
|
try {
|
|
1255
1119
|
assertIsEditableGridModel(model);
|
|
1256
|
-
|
|
1257
1120
|
if (!model.isEditable || !selectedRanges.every(range => model.isEditableRange(range))) {
|
|
1258
1121
|
throw new PasteError("Can't paste in to read-only area.");
|
|
1259
1122
|
}
|
|
1260
|
-
|
|
1261
1123
|
if (selectedRanges.length <= 0) {
|
|
1262
1124
|
throw new PasteError('Select an area to paste to.');
|
|
1263
1125
|
}
|
|
1264
|
-
|
|
1265
1126
|
if (typeof value === 'string') {
|
|
1266
1127
|
// Just paste the value into all the selected cells
|
|
1267
1128
|
var _edits = [];
|
|
@@ -1275,43 +1136,36 @@ class Grid extends PureComponent {
|
|
|
1275
1136
|
});
|
|
1276
1137
|
yield model.setValues(_edits);
|
|
1277
1138
|
return;
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1139
|
+
}
|
|
1280
1140
|
|
|
1141
|
+
// Otherwise it's a table of data
|
|
1281
1142
|
var tableHeight = value.length;
|
|
1282
1143
|
var tableWidth = value[0].length;
|
|
1283
1144
|
var {
|
|
1284
1145
|
columnCount,
|
|
1285
1146
|
rowCount
|
|
1286
1147
|
} = model;
|
|
1287
|
-
var _ranges = selectedRanges;
|
|
1288
|
-
|
|
1148
|
+
var _ranges = selectedRanges;
|
|
1149
|
+
// If each cell is a single selection, we need to update the selection to map to the newly pasted data
|
|
1289
1150
|
if (_ranges.every(range => {
|
|
1290
1151
|
var _range$startColumn, _range$startRow;
|
|
1291
|
-
|
|
1292
1152
|
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;
|
|
1293
1153
|
})) {
|
|
1294
1154
|
// Remap the selected ranges
|
|
1295
1155
|
_ranges = _ranges.map(range => {
|
|
1296
1156
|
var _range$startColumn2, _range$startRow2;
|
|
1297
|
-
|
|
1298
1157
|
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);
|
|
1299
1158
|
});
|
|
1300
|
-
|
|
1301
1159
|
_this.setSelectedRanges(_ranges);
|
|
1302
1160
|
}
|
|
1303
|
-
|
|
1304
1161
|
if (!_ranges.every(range => GridRange.rowCount([range]) === tableHeight && GridRange.columnCount([range]) === tableWidth)) {
|
|
1305
1162
|
throw new PasteError('Copy and paste area are not same size.');
|
|
1306
1163
|
}
|
|
1307
|
-
|
|
1308
1164
|
var edits = [];
|
|
1309
|
-
|
|
1310
1165
|
_ranges.forEach(range => {
|
|
1311
1166
|
for (var x = 0; x < tableWidth; x += 1) {
|
|
1312
1167
|
for (var y = 0; y < tableHeight; y += 1) {
|
|
1313
1168
|
var _range$startColumn3, _range$startRow3;
|
|
1314
|
-
|
|
1315
1169
|
edits.push({
|
|
1316
1170
|
column: ((_range$startColumn3 = range.startColumn) !== null && _range$startColumn3 !== void 0 ? _range$startColumn3 : 0) + x,
|
|
1317
1171
|
row: ((_range$startRow3 = range.startRow) !== null && _range$startRow3 !== void 0 ? _range$startRow3 : 0) + y,
|
|
@@ -1320,7 +1174,6 @@ class Grid extends PureComponent {
|
|
|
1320
1174
|
}
|
|
1321
1175
|
}
|
|
1322
1176
|
});
|
|
1323
|
-
|
|
1324
1177
|
yield model.setValues(edits);
|
|
1325
1178
|
} catch (e) {
|
|
1326
1179
|
var {
|
|
@@ -1330,6 +1183,7 @@ class Grid extends PureComponent {
|
|
|
1330
1183
|
}
|
|
1331
1184
|
})();
|
|
1332
1185
|
}
|
|
1186
|
+
|
|
1333
1187
|
/**
|
|
1334
1188
|
* Set a value to a specific cell. If the value is not valid for that cell, do not set it
|
|
1335
1189
|
* @param column Column index to set the value for
|
|
@@ -1337,8 +1191,6 @@ class Grid extends PureComponent {
|
|
|
1337
1191
|
* @param value Value to set at that cell
|
|
1338
1192
|
* @returns true If the value was valid and attempted to be set, false is it was not valid
|
|
1339
1193
|
*/
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
1194
|
setValueForCell(column, row, value) {
|
|
1343
1195
|
var {
|
|
1344
1196
|
model
|
|
@@ -1346,21 +1198,18 @@ class Grid extends PureComponent {
|
|
|
1346
1198
|
assertIsEditableGridModel(model);
|
|
1347
1199
|
var modelColumn = this.getModelColumn(column);
|
|
1348
1200
|
var modelRow = this.getModelRow(row);
|
|
1349
|
-
|
|
1350
1201
|
if (model.isValidForCell(modelColumn, modelRow, value)) {
|
|
1351
1202
|
model.setValueForCell(modelColumn, modelRow, value);
|
|
1352
1203
|
return true;
|
|
1353
1204
|
}
|
|
1354
|
-
|
|
1355
1205
|
return false;
|
|
1356
1206
|
}
|
|
1207
|
+
|
|
1357
1208
|
/**
|
|
1358
1209
|
* Set a value on all the ranges provided
|
|
1359
1210
|
* @param ranges Ranges to set
|
|
1360
1211
|
* @param value The value to set on all the ranges
|
|
1361
1212
|
*/
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
1213
|
setValueForRanges(ranges, value) {
|
|
1365
1214
|
var {
|
|
1366
1215
|
model
|
|
@@ -1370,56 +1219,44 @@ class Grid extends PureComponent {
|
|
|
1370
1219
|
movedRows
|
|
1371
1220
|
} = this.state;
|
|
1372
1221
|
var modelRanges = GridUtils.getModelRanges(ranges, movedColumns, movedRows);
|
|
1373
|
-
|
|
1374
1222
|
if (isEditableGridModel(model)) {
|
|
1375
1223
|
model.setValueForRanges(modelRanges, value);
|
|
1376
1224
|
}
|
|
1377
1225
|
}
|
|
1226
|
+
|
|
1378
1227
|
/**
|
|
1379
1228
|
* Check if a given cell is within the current selection
|
|
1380
1229
|
* @param row Row to check
|
|
1381
1230
|
* @param column Column to check
|
|
1382
1231
|
* @returns True if the cell is in the current selection, false otherwise
|
|
1383
1232
|
*/
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
1233
|
isSelected(row, column) {
|
|
1387
1234
|
var {
|
|
1388
1235
|
selectedRanges
|
|
1389
1236
|
} = this.state;
|
|
1390
|
-
|
|
1391
1237
|
for (var i = 0; i < selectedRanges.length; i += 1) {
|
|
1392
1238
|
var _selectedRange$endRow, _selectedRange$endCol;
|
|
1393
|
-
|
|
1394
1239
|
var selectedRange = selectedRanges[i];
|
|
1395
1240
|
var rowSelected = selectedRange.startRow === null || selectedRange.startRow <= row && row <= ((_selectedRange$endRow = selectedRange.endRow) !== null && _selectedRange$endRow !== void 0 ? _selectedRange$endRow : 0);
|
|
1396
1241
|
var columnSelected = selectedRange.startColumn === null || selectedRange.startColumn <= column && column <= ((_selectedRange$endCol = selectedRange.endColumn) !== null && _selectedRange$endCol !== void 0 ? _selectedRange$endCol : 0);
|
|
1397
|
-
|
|
1398
1242
|
if (rowSelected && columnSelected) {
|
|
1399
1243
|
return true;
|
|
1400
1244
|
}
|
|
1401
1245
|
}
|
|
1402
|
-
|
|
1403
1246
|
return false;
|
|
1404
1247
|
}
|
|
1405
|
-
|
|
1406
1248
|
addDocumentCursor() {
|
|
1407
1249
|
var cursor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
1408
1250
|
if (this.documentCursor === Grid.getCursorClassName(cursor)) return;
|
|
1409
|
-
|
|
1410
1251
|
if (this.documentCursor != null) {
|
|
1411
1252
|
document.documentElement.classList.remove(this.documentCursor);
|
|
1412
1253
|
}
|
|
1413
|
-
|
|
1414
1254
|
this.documentCursor = Grid.getCursorClassName(cursor);
|
|
1415
|
-
|
|
1416
1255
|
if (this.documentCursor != null) {
|
|
1417
1256
|
document.documentElement.classList.add(this.documentCursor);
|
|
1418
1257
|
}
|
|
1419
|
-
|
|
1420
1258
|
document.documentElement.classList.add('grid-block-events');
|
|
1421
1259
|
}
|
|
1422
|
-
|
|
1423
1260
|
removeDocumentCursor() {
|
|
1424
1261
|
if (this.documentCursor != null) {
|
|
1425
1262
|
document.documentElement.classList.remove(this.documentCursor);
|
|
@@ -1427,7 +1264,6 @@ class Grid extends PureComponent {
|
|
|
1427
1264
|
this.documentCursor = null;
|
|
1428
1265
|
}
|
|
1429
1266
|
}
|
|
1430
|
-
|
|
1431
1267
|
startDragTimer(event) {
|
|
1432
1268
|
this.stopDragTimer();
|
|
1433
1269
|
var mouseEvent = new MouseEvent('custom', event.nativeEvent);
|
|
@@ -1435,21 +1271,19 @@ class Grid extends PureComponent {
|
|
|
1435
1271
|
this.handleMouseDrag(mouseEvent);
|
|
1436
1272
|
}, Grid.dragTimeout);
|
|
1437
1273
|
}
|
|
1438
|
-
|
|
1439
1274
|
stopDragTimer() {
|
|
1440
1275
|
if (this.dragTimer) {
|
|
1441
1276
|
clearTimeout(this.dragTimer);
|
|
1442
1277
|
this.dragTimer = null;
|
|
1443
1278
|
}
|
|
1444
1279
|
}
|
|
1280
|
+
|
|
1445
1281
|
/**
|
|
1446
1282
|
* Draw the grid with the metrics provided
|
|
1447
1283
|
* When scrolling you've have to re-draw the whole canvas. As a consequence, all these drawing methods
|
|
1448
1284
|
* must be very quick.
|
|
1449
1285
|
* @param metrics Metrics to use for rendering the grid
|
|
1450
1286
|
*/
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
1287
|
drawCanvas() {
|
|
1454
1288
|
var metrics = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.updateMetrics();
|
|
1455
1289
|
if (!this.canvas) throw new Error('canvas is not set');
|
|
@@ -1483,7 +1317,6 @@ class Grid extends PureComponent {
|
|
|
1483
1317
|
var theme = this.getTheme();
|
|
1484
1318
|
var width = this.canvas.clientWidth;
|
|
1485
1319
|
var height = this.canvas.clientHeight;
|
|
1486
|
-
|
|
1487
1320
|
var renderState = _objectSpread({
|
|
1488
1321
|
left,
|
|
1489
1322
|
top,
|
|
@@ -1508,68 +1341,56 @@ class Grid extends PureComponent {
|
|
|
1508
1341
|
cursorColumn,
|
|
1509
1342
|
cursorRow
|
|
1510
1343
|
}, stateOverride);
|
|
1511
|
-
|
|
1512
1344
|
context.save();
|
|
1513
1345
|
renderer.drawCanvas(renderState);
|
|
1514
1346
|
context.restore();
|
|
1515
1347
|
}
|
|
1348
|
+
|
|
1516
1349
|
/**
|
|
1517
1350
|
* Set focus to this grid element
|
|
1518
1351
|
*/
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
1352
|
focus() {
|
|
1522
1353
|
var _this$canvas3;
|
|
1523
|
-
|
|
1524
1354
|
(_this$canvas3 = this.canvas) === null || _this$canvas3 === void 0 ? void 0 : _this$canvas3.focus();
|
|
1525
1355
|
}
|
|
1356
|
+
|
|
1526
1357
|
/**
|
|
1527
1358
|
* Check if this grid is currently focused
|
|
1528
1359
|
* @returns True if the active element is this grid
|
|
1529
1360
|
*/
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
1361
|
isFocused() {
|
|
1533
1362
|
return document.activeElement === this.canvas;
|
|
1534
1363
|
}
|
|
1364
|
+
|
|
1535
1365
|
/**
|
|
1536
1366
|
* Handle a mouse click event. Pass the event to the registered mouse handlers until one handles it.
|
|
1537
1367
|
* Focuses the grid after the click.
|
|
1538
1368
|
* @param event The mouse event
|
|
1539
1369
|
*/
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
1370
|
handleClick(event) {
|
|
1543
1371
|
var _this$canvas4;
|
|
1544
|
-
|
|
1545
1372
|
var gridPoint = this.getGridPointFromEvent(event);
|
|
1546
1373
|
var mouseHandlers = this.getMouseHandlers();
|
|
1547
|
-
|
|
1548
1374
|
for (var i = 0; i < mouseHandlers.length; i += 1) {
|
|
1549
1375
|
var mouseHandler = mouseHandlers[i];
|
|
1550
|
-
|
|
1551
1376
|
if (mouseHandler.onClick(gridPoint, this, event) !== false) {
|
|
1552
1377
|
event.stopPropagation();
|
|
1553
1378
|
event.preventDefault();
|
|
1554
1379
|
break;
|
|
1555
1380
|
}
|
|
1556
1381
|
}
|
|
1557
|
-
|
|
1558
1382
|
(_this$canvas4 = this.canvas) === null || _this$canvas4 === void 0 ? void 0 : _this$canvas4.focus();
|
|
1559
1383
|
}
|
|
1384
|
+
|
|
1560
1385
|
/**
|
|
1561
1386
|
* Handle a mouse context menu event. Pass the event to the registered mouse handlers until one handles it.
|
|
1562
1387
|
* @param event The mouse event triggering the context menu
|
|
1563
1388
|
*/
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
1389
|
handleContextMenu(event) {
|
|
1567
1390
|
var gridPoint = this.getGridPointFromEvent(event);
|
|
1568
1391
|
var mouseHandlers = this.getMouseHandlers();
|
|
1569
|
-
|
|
1570
1392
|
for (var i = 0; i < mouseHandlers.length; i += 1) {
|
|
1571
1393
|
var mouseHandler = mouseHandlers[i];
|
|
1572
|
-
|
|
1573
1394
|
if (mouseHandler.onContextMenu(gridPoint, this, event) !== false) {
|
|
1574
1395
|
event.stopPropagation();
|
|
1575
1396
|
event.preventDefault();
|
|
@@ -1577,22 +1398,18 @@ class Grid extends PureComponent {
|
|
|
1577
1398
|
}
|
|
1578
1399
|
}
|
|
1579
1400
|
}
|
|
1401
|
+
|
|
1580
1402
|
/**
|
|
1581
1403
|
* Handle a key down event from the keyboard. Pass the event to the registered keyboard handlers until one handles it.
|
|
1582
1404
|
* @param event Keyboard event
|
|
1583
1405
|
*/
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
1406
|
handleKeyDown(event) {
|
|
1587
1407
|
var keyHandlers = this.getKeyHandlers();
|
|
1588
|
-
|
|
1589
1408
|
for (var i = 0; i < keyHandlers.length; i += 1) {
|
|
1590
1409
|
var keyHandler = keyHandlers[i];
|
|
1591
1410
|
var result = keyHandler.onDown(event, this);
|
|
1592
|
-
|
|
1593
1411
|
if (result !== false) {
|
|
1594
1412
|
var _options$stopPropagat, _options$preventDefau;
|
|
1595
|
-
|
|
1596
1413
|
var options = result;
|
|
1597
1414
|
if ((_options$stopPropagat = options === null || options === void 0 ? void 0 : options.stopPropagation) !== null && _options$stopPropagat !== void 0 ? _options$stopPropagat : true) event.stopPropagation();
|
|
1598
1415
|
if ((_options$preventDefau = options === null || options === void 0 ? void 0 : options.preventDefault) !== null && _options$preventDefau !== void 0 ? _options$preventDefau : true) event.preventDefault();
|
|
@@ -1600,6 +1417,7 @@ class Grid extends PureComponent {
|
|
|
1600
1417
|
}
|
|
1601
1418
|
}
|
|
1602
1419
|
}
|
|
1420
|
+
|
|
1603
1421
|
/**
|
|
1604
1422
|
* Notify all of the mouse handlers for this grid of a mouse event.
|
|
1605
1423
|
* @param functionName The name of the function in the mouse handler to call
|
|
@@ -1607,44 +1425,36 @@ class Grid extends PureComponent {
|
|
|
1607
1425
|
* @param updateCoordinates Whether to update the mouse coordinates
|
|
1608
1426
|
* @param addCursorToDocument Whether to add a cursor overlay or not (for dragging)
|
|
1609
1427
|
*/
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
1428
|
notifyMouseHandlers(functionName, event) {
|
|
1613
1429
|
var updateCoordinates = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
1614
1430
|
var addCursorToDocument = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
1615
1431
|
var gridPoint = this.getGridPointFromEvent(event);
|
|
1616
1432
|
var mouseHandlers = this.getMouseHandlers();
|
|
1617
1433
|
var cursor = null;
|
|
1618
|
-
|
|
1619
1434
|
for (var i = 0; i < mouseHandlers.length; i += 1) {
|
|
1620
1435
|
var mouseHandler = mouseHandlers[i];
|
|
1621
1436
|
var result = mouseHandler[functionName] != null && mouseHandler[functionName](gridPoint, this, event);
|
|
1622
|
-
|
|
1623
1437
|
if (result !== false) {
|
|
1624
1438
|
var _options$stopPropagat2, _options$preventDefau2;
|
|
1625
|
-
|
|
1626
1439
|
if (mouseHandler.cursor != null) {
|
|
1627
1440
|
({
|
|
1628
1441
|
cursor
|
|
1629
1442
|
} = mouseHandler);
|
|
1630
|
-
|
|
1631
1443
|
if (addCursorToDocument) {
|
|
1632
1444
|
this.addDocumentCursor(cursor);
|
|
1633
1445
|
}
|
|
1634
|
-
}
|
|
1635
|
-
|
|
1446
|
+
}
|
|
1636
1447
|
|
|
1448
|
+
// result is bool or object, events are stopped by default
|
|
1637
1449
|
var options = result;
|
|
1638
1450
|
if ((_options$stopPropagat2 = options === null || options === void 0 ? void 0 : options.stopPropagation) !== null && _options$stopPropagat2 !== void 0 ? _options$stopPropagat2 : true) event.stopPropagation();
|
|
1639
1451
|
if ((_options$preventDefau2 = options === null || options === void 0 ? void 0 : options.preventDefault) !== null && _options$preventDefau2 !== void 0 ? _options$preventDefau2 : true) event.preventDefault();
|
|
1640
1452
|
break;
|
|
1641
1453
|
}
|
|
1642
1454
|
}
|
|
1643
|
-
|
|
1644
1455
|
this.setState({
|
|
1645
1456
|
cursor
|
|
1646
1457
|
});
|
|
1647
|
-
|
|
1648
1458
|
if (updateCoordinates) {
|
|
1649
1459
|
var {
|
|
1650
1460
|
x,
|
|
@@ -1656,27 +1466,21 @@ class Grid extends PureComponent {
|
|
|
1656
1466
|
});
|
|
1657
1467
|
}
|
|
1658
1468
|
}
|
|
1659
|
-
|
|
1660
1469
|
handleMouseDown(event) {
|
|
1661
1470
|
window.addEventListener('mousemove', this.handleMouseDrag, true);
|
|
1662
1471
|
window.addEventListener('mouseup', this.handleMouseUp, true);
|
|
1663
|
-
|
|
1664
1472
|
if (event.button != null && event.button !== 0) {
|
|
1665
1473
|
return;
|
|
1666
1474
|
}
|
|
1667
|
-
|
|
1668
1475
|
this.notifyMouseHandlers('onDown', event);
|
|
1669
1476
|
this.startDragTimer(event);
|
|
1670
1477
|
}
|
|
1671
|
-
|
|
1672
1478
|
handleDoubleClick(event) {
|
|
1673
1479
|
this.notifyMouseHandlers('onDoubleClick', event);
|
|
1674
1480
|
}
|
|
1675
|
-
|
|
1676
1481
|
handleMouseMove(event) {
|
|
1677
1482
|
this.notifyMouseHandlers('onMove', event);
|
|
1678
1483
|
}
|
|
1679
|
-
|
|
1680
1484
|
handleMouseLeave(event) {
|
|
1681
1485
|
this.notifyMouseHandlers('onLeave', event, false);
|
|
1682
1486
|
this.setState({
|
|
@@ -1684,7 +1488,6 @@ class Grid extends PureComponent {
|
|
|
1684
1488
|
mouseY: null
|
|
1685
1489
|
});
|
|
1686
1490
|
}
|
|
1687
|
-
|
|
1688
1491
|
handleMouseDrag(event) {
|
|
1689
1492
|
this.setState({
|
|
1690
1493
|
isDragging: true
|
|
@@ -1692,20 +1495,16 @@ class Grid extends PureComponent {
|
|
|
1692
1495
|
this.notifyMouseHandlers('onDrag', event, true, true);
|
|
1693
1496
|
this.stopDragTimer();
|
|
1694
1497
|
}
|
|
1695
|
-
|
|
1696
1498
|
handleMouseUp(event) {
|
|
1697
1499
|
window.removeEventListener('mousemove', this.handleMouseDrag, true);
|
|
1698
1500
|
window.removeEventListener('mouseup', this.handleMouseUp, true);
|
|
1699
|
-
|
|
1700
1501
|
if (event.button != null && event.button !== 0) {
|
|
1701
1502
|
return;
|
|
1702
1503
|
}
|
|
1703
|
-
|
|
1704
1504
|
this.notifyMouseHandlers('onUp', event, false);
|
|
1705
1505
|
this.stopDragTimer();
|
|
1706
1506
|
this.removeDocumentCursor();
|
|
1707
1507
|
}
|
|
1708
|
-
|
|
1709
1508
|
handleResize() {
|
|
1710
1509
|
/**
|
|
1711
1510
|
* We need to always redraw the canvas in the same frame as the updateCanvasScale
|
|
@@ -1725,31 +1524,25 @@ class Grid extends PureComponent {
|
|
|
1725
1524
|
lastLeft,
|
|
1726
1525
|
lastTop
|
|
1727
1526
|
} = this.metrics;
|
|
1728
|
-
|
|
1729
1527
|
if (left > lastLeft) {
|
|
1730
1528
|
this.setState({
|
|
1731
1529
|
left: lastLeft,
|
|
1732
1530
|
leftOffset: 0
|
|
1733
1531
|
});
|
|
1734
1532
|
}
|
|
1735
|
-
|
|
1736
1533
|
if (top > lastTop) {
|
|
1737
1534
|
this.setState({
|
|
1738
1535
|
top: lastTop,
|
|
1739
1536
|
topOffset: 0
|
|
1740
1537
|
});
|
|
1741
1538
|
}
|
|
1742
|
-
|
|
1743
1539
|
this.forceUpdate();
|
|
1744
1540
|
}
|
|
1745
|
-
|
|
1746
1541
|
handleWheel(event) {
|
|
1747
1542
|
this.notifyMouseHandlers('onWheel', event);
|
|
1748
|
-
|
|
1749
1543
|
if (event.defaultPrevented) {
|
|
1750
1544
|
return;
|
|
1751
1545
|
}
|
|
1752
|
-
|
|
1753
1546
|
var {
|
|
1754
1547
|
metricCalculator,
|
|
1755
1548
|
metrics
|
|
@@ -1778,13 +1571,13 @@ class Grid extends PureComponent {
|
|
|
1778
1571
|
var {
|
|
1779
1572
|
deltaX,
|
|
1780
1573
|
deltaY
|
|
1781
|
-
} = GridUtils.getScrollDelta(event, metrics.barWidth, metrics.barHeight, metrics.rowHeight, metrics.rowHeight);
|
|
1782
|
-
// get column width of next column to scroll to, and subract it from the remaining distance to travel
|
|
1574
|
+
} = GridUtils.getScrollDelta(event, metrics.barWidth, metrics.barHeight, metrics.rowHeight, metrics.rowHeight);
|
|
1783
1575
|
|
|
1576
|
+
// iterate through each column to determine column width and figure out how far to scroll
|
|
1577
|
+
// get column width of next column to scroll to, and subract it from the remaining distance to travel
|
|
1784
1578
|
while (hasHorizontalBar && deltaX !== 0) {
|
|
1785
1579
|
leftOffset += deltaX;
|
|
1786
1580
|
deltaX = 0;
|
|
1787
|
-
|
|
1788
1581
|
if (columnCount > 1) {
|
|
1789
1582
|
// no scrolling needed, at directional edge
|
|
1790
1583
|
if (leftOffset > 0 && left >= lastLeft || leftOffset < 0 && left <= 0) {
|
|
@@ -1797,22 +1590,18 @@ class Grid extends PureComponent {
|
|
|
1797
1590
|
leftOffset = 0;
|
|
1798
1591
|
break;
|
|
1799
1592
|
}
|
|
1800
|
-
|
|
1801
1593
|
var maxLeftOffset = scrollableContentWidth - scrollableViewportWidth;
|
|
1802
|
-
|
|
1803
1594
|
if (leftOffset >= maxLeftOffset) {
|
|
1804
1595
|
leftOffset = maxLeftOffset;
|
|
1805
1596
|
break;
|
|
1806
1597
|
}
|
|
1807
1598
|
}
|
|
1808
|
-
|
|
1809
1599
|
if (leftOffset > 0) {
|
|
1810
1600
|
var _metrics$visibleColum;
|
|
1811
|
-
|
|
1812
1601
|
// scroll right
|
|
1602
|
+
|
|
1813
1603
|
// get width of next column
|
|
1814
1604
|
var columnWidth = (_metrics$visibleColum = metrics.visibleColumnWidths.get(left)) !== null && _metrics$visibleColum !== void 0 ? _metrics$visibleColum : metricCalculator.getVisibleColumnWidth(left, metricState);
|
|
1815
|
-
|
|
1816
1605
|
if (leftOffset >= columnWidth) {
|
|
1817
1606
|
// remove width from balance and advance by 1 column
|
|
1818
1607
|
deltaX = leftOffset - columnWidth;
|
|
@@ -1825,11 +1614,10 @@ class Grid extends PureComponent {
|
|
|
1825
1614
|
}
|
|
1826
1615
|
} else if (leftOffset < 0) {
|
|
1827
1616
|
var _metrics$visibleColum2;
|
|
1828
|
-
|
|
1829
1617
|
// scroll left
|
|
1618
|
+
|
|
1830
1619
|
// get width of next column
|
|
1831
1620
|
var _columnWidth = (_metrics$visibleColum2 = metrics.visibleColumnWidths.get(left - 1)) !== null && _metrics$visibleColum2 !== void 0 ? _metrics$visibleColum2 : metricCalculator.getVisibleColumnWidth(left - 1, metricState);
|
|
1832
|
-
|
|
1833
1621
|
if (Math.abs(leftOffset) <= _columnWidth && theme.scrollSnapToColumn && columnCount > 1) {
|
|
1834
1622
|
// if there's still a balance to travel but its less then a column and snapping is on
|
|
1835
1623
|
leftOffset = 0;
|
|
@@ -1841,14 +1629,13 @@ class Grid extends PureComponent {
|
|
|
1841
1629
|
left -= 1;
|
|
1842
1630
|
}
|
|
1843
1631
|
}
|
|
1844
|
-
}
|
|
1845
|
-
// get row height of next row to scroll to, and subract it from the remaining distance to travel
|
|
1846
|
-
|
|
1632
|
+
}
|
|
1847
1633
|
|
|
1634
|
+
// iterate through each row to determine row height and figure out how far to scroll
|
|
1635
|
+
// get row height of next row to scroll to, and subract it from the remaining distance to travel
|
|
1848
1636
|
while (hasVerticalBar && deltaY !== 0) {
|
|
1849
1637
|
topOffset += deltaY;
|
|
1850
1638
|
deltaY = 0;
|
|
1851
|
-
|
|
1852
1639
|
if (rowCount > 1) {
|
|
1853
1640
|
// no scrolling needed, at directional edge
|
|
1854
1641
|
if (topOffset > 0 && top >= lastTop || topOffset < 0 && top <= 0) {
|
|
@@ -1861,22 +1648,18 @@ class Grid extends PureComponent {
|
|
|
1861
1648
|
topOffset = 0;
|
|
1862
1649
|
break;
|
|
1863
1650
|
}
|
|
1864
|
-
|
|
1865
1651
|
var maxTopOffset = scrollableContentHeight - scrollableViewportHeight;
|
|
1866
|
-
|
|
1867
1652
|
if (topOffset >= maxTopOffset) {
|
|
1868
1653
|
topOffset = maxTopOffset;
|
|
1869
1654
|
break;
|
|
1870
1655
|
}
|
|
1871
1656
|
}
|
|
1872
|
-
|
|
1873
1657
|
if (topOffset > 0) {
|
|
1874
1658
|
var _metrics$visibleRowHe;
|
|
1875
|
-
|
|
1876
1659
|
// scroll direction down
|
|
1660
|
+
|
|
1877
1661
|
// get height of next row
|
|
1878
1662
|
var rowHeight = (_metrics$visibleRowHe = metrics.visibleRowHeights.get(top)) !== null && _metrics$visibleRowHe !== void 0 ? _metrics$visibleRowHe : metricCalculator.getVisibleRowHeight(top, metricState);
|
|
1879
|
-
|
|
1880
1663
|
if (topOffset >= rowHeight) {
|
|
1881
1664
|
// remove height from balance and advance by 1 row
|
|
1882
1665
|
deltaY = topOffset - rowHeight;
|
|
@@ -1889,11 +1672,10 @@ class Grid extends PureComponent {
|
|
|
1889
1672
|
}
|
|
1890
1673
|
} else if (topOffset < 0) {
|
|
1891
1674
|
var _metrics$visibleRowHe2;
|
|
1892
|
-
|
|
1893
1675
|
// scroll direction up
|
|
1676
|
+
|
|
1894
1677
|
// get height of next row
|
|
1895
1678
|
var _rowHeight = (_metrics$visibleRowHe2 = metrics.visibleRowHeights.get(top - 1)) !== null && _metrics$visibleRowHe2 !== void 0 ? _metrics$visibleRowHe2 : metricCalculator.getVisibleRowHeight(top - 1, metricState);
|
|
1896
|
-
|
|
1897
1679
|
if (Math.abs(topOffset) <= _rowHeight && theme.scrollSnapToRow && rowCount > 1) {
|
|
1898
1680
|
// if there's still a balance to travel but its less then a row and snapping is on
|
|
1899
1681
|
topOffset = 0;
|
|
@@ -1906,7 +1688,6 @@ class Grid extends PureComponent {
|
|
|
1906
1688
|
}
|
|
1907
1689
|
}
|
|
1908
1690
|
}
|
|
1909
|
-
|
|
1910
1691
|
this.setViewState({
|
|
1911
1692
|
top,
|
|
1912
1693
|
left,
|
|
@@ -1916,29 +1697,26 @@ class Grid extends PureComponent {
|
|
|
1916
1697
|
event.stopPropagation();
|
|
1917
1698
|
event.preventDefault();
|
|
1918
1699
|
}
|
|
1700
|
+
|
|
1919
1701
|
/**
|
|
1920
1702
|
* Handle cancelling the cell edit action
|
|
1921
1703
|
*/
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
1704
|
handleEditCellCancel() {
|
|
1925
1705
|
this.setState({
|
|
1926
1706
|
editingCell: null
|
|
1927
1707
|
});
|
|
1928
1708
|
this.focus();
|
|
1929
1709
|
}
|
|
1710
|
+
|
|
1930
1711
|
/**
|
|
1931
1712
|
* Handle a change in the value in an editing cell
|
|
1932
1713
|
* @param value New value set
|
|
1933
1714
|
*/
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
1715
|
handleEditCellChange(value) {
|
|
1937
|
-
this.setState(
|
|
1716
|
+
this.setState(_ref5 => {
|
|
1938
1717
|
var {
|
|
1939
1718
|
editingCell
|
|
1940
|
-
} =
|
|
1941
|
-
|
|
1719
|
+
} = _ref5;
|
|
1942
1720
|
try {
|
|
1943
1721
|
assertIsDefined(editingCell);
|
|
1944
1722
|
return {
|
|
@@ -1956,13 +1734,12 @@ class Grid extends PureComponent {
|
|
|
1956
1734
|
}
|
|
1957
1735
|
});
|
|
1958
1736
|
}
|
|
1737
|
+
|
|
1959
1738
|
/**
|
|
1960
1739
|
* Commit an edit for the currently editing cell
|
|
1961
1740
|
* @param value Value that was committed
|
|
1962
1741
|
* @param options Options for committing
|
|
1963
1742
|
*/
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
1743
|
handleEditCellCommit(value) {
|
|
1967
1744
|
var {
|
|
1968
1745
|
direction = SELECTION_DIRECTION.DOWN,
|
|
@@ -1977,7 +1754,6 @@ class Grid extends PureComponent {
|
|
|
1977
1754
|
column,
|
|
1978
1755
|
row
|
|
1979
1756
|
} = editingCell;
|
|
1980
|
-
|
|
1981
1757
|
if (!this.isValidForCell(column, row, value)) {
|
|
1982
1758
|
// Don't allow an invalid value to be commited, the editing cell should show an error
|
|
1983
1759
|
if (direction === null) {
|
|
@@ -1986,26 +1762,21 @@ class Grid extends PureComponent {
|
|
|
1986
1762
|
editingCell: null
|
|
1987
1763
|
});
|
|
1988
1764
|
}
|
|
1989
|
-
|
|
1990
1765
|
return;
|
|
1991
1766
|
}
|
|
1992
|
-
|
|
1993
1767
|
if (fillRange) {
|
|
1994
1768
|
this.setValueForRanges(selectedRanges, value);
|
|
1995
1769
|
} else {
|
|
1996
1770
|
this.setValueForCell(column, row, value);
|
|
1997
1771
|
}
|
|
1998
|
-
|
|
1999
1772
|
if (direction !== null) {
|
|
2000
1773
|
this.moveCursorInDirection(direction);
|
|
2001
1774
|
}
|
|
2002
|
-
|
|
2003
1775
|
this.setState({
|
|
2004
1776
|
editingCell: null
|
|
2005
1777
|
});
|
|
2006
1778
|
this.focus();
|
|
2007
1779
|
}
|
|
2008
|
-
|
|
2009
1780
|
renderInputField() {
|
|
2010
1781
|
var {
|
|
2011
1782
|
model
|
|
@@ -2016,11 +1787,9 @@ class Grid extends PureComponent {
|
|
|
2016
1787
|
var {
|
|
2017
1788
|
metrics
|
|
2018
1789
|
} = this;
|
|
2019
|
-
|
|
2020
1790
|
if (editingCell == null || metrics == null || !isEditableGridModel(model)) {
|
|
2021
1791
|
return null;
|
|
2022
1792
|
}
|
|
2023
|
-
|
|
2024
1793
|
var {
|
|
2025
1794
|
selectionRange,
|
|
2026
1795
|
value,
|
|
@@ -2041,8 +1810,9 @@ class Grid extends PureComponent {
|
|
|
2041
1810
|
var x = visibleColumnXs.get(column);
|
|
2042
1811
|
var y = visibleRowYs.get(row);
|
|
2043
1812
|
var w = visibleColumnWidths.get(column);
|
|
2044
|
-
var h = visibleRowHeights.get(row);
|
|
1813
|
+
var h = visibleRowHeights.get(row);
|
|
2045
1814
|
|
|
1815
|
+
// If the cell isn't visible, we still need to display an invisible cell for focus purposes
|
|
2046
1816
|
var wrapperStyle = x != null && y != null && w != null && h != null ? {
|
|
2047
1817
|
position: 'absolute',
|
|
2048
1818
|
left: gridX + x,
|
|
@@ -2074,7 +1844,6 @@ class Grid extends PureComponent {
|
|
|
2074
1844
|
value: value
|
|
2075
1845
|
}));
|
|
2076
1846
|
}
|
|
2077
|
-
|
|
2078
1847
|
render() {
|
|
2079
1848
|
var {
|
|
2080
1849
|
cursor
|
|
@@ -2094,11 +1863,8 @@ class Grid extends PureComponent {
|
|
|
2094
1863
|
tabIndex: 0
|
|
2095
1864
|
}, "Your browser does not support HTML canvas. Update your browser?"), this.renderInputField());
|
|
2096
1865
|
}
|
|
2097
|
-
|
|
2098
1866
|
}
|
|
2099
|
-
|
|
2100
1867
|
_defineProperty(Grid, "contextType", ThemeContext);
|
|
2101
|
-
|
|
2102
1868
|
_defineProperty(Grid, "defaultProps", {
|
|
2103
1869
|
canvasOptions: {
|
|
2104
1870
|
alpha: false
|
|
@@ -2124,12 +1890,8 @@ _defineProperty(Grid, "defaultProps", {
|
|
|
2124
1890
|
autoSelectRow: false
|
|
2125
1891
|
}
|
|
2126
1892
|
});
|
|
2127
|
-
|
|
2128
1893
|
_defineProperty(Grid, "pixelsPerLine", 100 / 3);
|
|
2129
|
-
|
|
2130
1894
|
_defineProperty(Grid, "dragTimeout", 1000);
|
|
2131
|
-
|
|
2132
1895
|
_defineProperty(Grid, "getTheme", memoize((contextTheme, userTheme) => _objectSpread(_objectSpread(_objectSpread({}, GridTheme), contextTheme), userTheme)));
|
|
2133
|
-
|
|
2134
1896
|
export default Grid;
|
|
2135
1897
|
//# sourceMappingURL=Grid.js.map
|