@deephaven/grid 0.6.3-beta.9 → 0.6.3

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.
Files changed (38) hide show
  1. package/dist/CellInputField.js +1 -1
  2. package/dist/CellInputField.js.map +1 -1
  3. package/dist/Grid.d.ts +13 -3
  4. package/dist/Grid.d.ts.map +1 -1
  5. package/dist/Grid.js +2 -2
  6. package/dist/GridMetricCalculator.d.ts +165 -448
  7. package/dist/GridMetricCalculator.d.ts.map +1 -1
  8. package/dist/GridMetricCalculator.js +122 -521
  9. package/dist/GridMetricCalculator.js.map +1 -1
  10. package/dist/GridRange.d.ts +111 -186
  11. package/dist/GridRange.d.ts.map +1 -1
  12. package/dist/GridRange.js +87 -185
  13. package/dist/GridRange.js.map +1 -1
  14. package/dist/GridRenderer.js +1 -6
  15. package/dist/GridRenderer.js.map +1 -1
  16. package/dist/GridTheme.d.ts +37 -49
  17. package/dist/GridTheme.d.ts.map +1 -1
  18. package/dist/GridTheme.js +0 -8
  19. package/dist/GridTheme.js.map +1 -1
  20. package/dist/GridUtils.d.ts +97 -236
  21. package/dist/GridUtils.d.ts.map +1 -1
  22. package/dist/GridUtils.js +76 -241
  23. package/dist/GridUtils.js.map +1 -1
  24. package/dist/index.d.ts +1 -0
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +1 -0
  27. package/dist/index.js.map +1 -1
  28. package/dist/memoizeClear.js +1 -1
  29. package/dist/mouse-handlers/GridRowSeparatorMouseHandler.d.ts +1 -1
  30. package/dist/mouse-handlers/GridRowSeparatorMouseHandler.d.ts.map +1 -1
  31. package/dist/mouse-handlers/GridSelectionMouseHandler.js +4 -4
  32. package/dist/mouse-handlers/GridSelectionMouseHandler.js.map +1 -1
  33. package/dist/tsconfig.tsbuildinfo +1 -1
  34. package/package.json +4 -4
  35. package/dist/GridMetrics.d.ts +0 -97
  36. package/dist/GridMetrics.d.ts.map +0 -1
  37. package/dist/GridMetrics.js +0 -2
  38. package/dist/GridMetrics.js.map +0 -1
@@ -1,75 +1,10 @@
1
1
  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; }
2
2
 
3
3
  import GridUtils from "./GridUtils.js";
4
+ /* eslint class-methods-use-this: "off" */
4
5
 
5
- /**
6
- * Retrieve a value from a map. If the value is not found and no default value is provided, throw.
7
- * Use when the value _must_ be present
8
- * @param map The map to get the value from
9
- * @param key The key to fetch the value for
10
- * @param defaultValue A default value to set if the key is not present
11
- * @returns The value set for that key
12
- */
13
- export function getOrThrow(map, key) {
14
- var _map$get;
15
-
16
- var defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
17
- var value = (_map$get = map.get(key)) !== null && _map$get !== void 0 ? _map$get : defaultValue;
18
-
19
- if (value !== undefined) {
20
- return value;
21
- }
22
-
23
- throw new Error("Missing value for key ".concat(key));
24
- }
25
- /**
26
- * Trim the provided map in place. Trims oldest inserted items down to the target size if the cache size is exceeded.
27
- * Instead of trimming one item on every tick, we trim half the items so there isn't a cache clear on every new item.
28
- * @param map The map to trim
29
- * @param cacheSize The maximum number of elements to cache
30
- * @param targetSize The number of elements to reduce the cache down to if `cacheSize` is exceeded
31
- */
32
-
33
- export function trimMap(map) {
34
- var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : GridMetricCalculator.CACHE_SIZE;
35
- var targetSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Math.floor(cacheSize / 2);
36
-
37
- if (map.size > cacheSize) {
38
- var iter = map.keys();
39
-
40
- while (map.size > targetSize) {
41
- map.delete(iter.next().value);
42
- }
43
- }
44
- }
45
- /**
46
- * Get the coordinates of floating items in one dimension.
47
- * Can be used for getting the y coordinates of floating rows, or x coordinates of floating columns, calculated using the `sizeMap` passed in.
48
- * @param startCount The number of floating items at the start (ie. `floatingTopRowCount` for rows, `floatingLeftColumnCount` for columns)
49
- * @param endCount The number of floating items at the end (ie. `floatingBottomRowCount` for rows, `floatingRightColumnCount` for columns)
50
- * @param totalCount Total number of items in this dimension (ie. `rowCount` for rows, `columnCount` for columns)
51
- * @param max The max coordinate value (ie. `maxY` for rows, `maxX` for columns)
52
- * @param sizeMap Map from index to size of item (ie. `rowHeightMap` for rows, `columnWidthMap` for columns)
53
- */
54
-
55
- export function getFloatingCoordinates(startCount, endCount, totalCount, max, sizeMap) {
56
- var coordinates = new Map();
57
- var x = 0;
58
-
59
- for (var i = 0; i < startCount && i < totalCount; i += 1) {
60
- coordinates.set(i, x);
61
- x += getOrThrow(sizeMap, i);
62
- }
6
+ /* eslint react/destructuring-assignment: "off" */
63
7
 
64
- x = max;
65
-
66
- for (var _i = 0; _i < endCount && totalCount - _i - 1 >= 0; _i += 1) {
67
- x -= getOrThrow(sizeMap, totalCount - _i - 1);
68
- coordinates.set(totalCount - _i - 1, x);
69
- }
70
-
71
- return coordinates;
72
- }
73
8
  /**
74
9
  * Class to calculate all the metrics for drawing a grid.
75
10
  * Call getMetrics() with the state to get the full metrics.
@@ -81,54 +16,67 @@ class GridMetricCalculator {
81
16
 
82
17
  /** The maximum column width as a percentage of the full grid */
83
18
 
84
- /** User set column widths */
19
+ /**
20
+ * Trim the provided map in place. Trims oldest inserted items down to the target size if the cache size is exceeded.
21
+ * Instead of trimming one item on every tick, we trim half the items so there isn't a cache clear on every new item.
22
+ * @param {Map} map The map to trim
23
+ * @param {number} cacheSize The maximum number of elements to cache
24
+ * @param {number} targetSize The number of elements to reduce the cache down to if `cacheSize` is exceeded
25
+ */
26
+ static trimMap(map) {
27
+ var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : GridMetricCalculator.CACHE_SIZE;
28
+ var targetSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Math.floor(cacheSize / 2);
85
29
 
86
- /** User set row heights */
30
+ if (map.size > cacheSize) {
31
+ var iter = map.keys();
87
32
 
88
- /** Calculated column widths based on cell contents */
33
+ while (map.size > targetSize) {
34
+ map.delete(iter.next().value);
35
+ }
36
+ }
37
+ }
38
+ /**
39
+ * Get the coordinates of floating items in one dimension.
40
+ * Can be used for getting the y coordinates of floating rows, or x coordinates of floating columns, calculated using the `sizeMap` passed in.
41
+ * @param {number} startCount The number of floating items at the start (ie. `floatingTopRowCount` for rows, `floatingLeftColumnCount` for columns)
42
+ * @param {number} endCount The number of floating items at the end (ie. `floatingBottomRowCount` for rows, `floatingRightColumnCount` for columns)
43
+ * @param {number} totalCount Total number of items in this dimension (ie. `rowCount` for rows, `columnCount` for columns)
44
+ * @param {number} max The max coordinate value (ie. `maxY` for rows, `maxX` for columns)
45
+ * @param {Map<number, number>} sizeMap Map from index to size of item (ie. `rowHeightMap` for rows, `columnWidthMap` for columns)
46
+ */
89
47
 
90
- /** Calculated row heights based on cell contents */
91
48
 
92
- /** Cache of fonts to estimated width of one char */
49
+ static getFloatingCoordinates(startCount, endCount, totalCount, max, sizeMap) {
50
+ var coordinates = new Map();
51
+ var x = 0;
93
52
 
94
- /** Map from visible index to model index for rows (e.g. reversing movedRows operations) */
53
+ for (var i = 0; i < startCount && i < totalCount; i += 1) {
54
+ coordinates.set(i, x);
55
+ x += sizeMap.get(i);
56
+ }
95
57
 
96
- /** Map from visible index to model index for columns (e.g. reversing movedColumns operations) */
58
+ x = max;
97
59
 
98
- /** List of moved row operations. Need to track the previous value so we know if modelRows needs to be cleared. */
60
+ for (var _i = 0; _i < endCount && totalCount - _i - 1 >= 0; _i += 1) {
61
+ x -= sizeMap.get(totalCount - _i - 1);
62
+ coordinates.set(totalCount - _i - 1, x);
63
+ }
64
+
65
+ return coordinates;
66
+ }
99
67
 
100
- /** List of moved column operations. Need to track the previous value so we know if modelColumns needs to be cleared. */
101
68
  constructor() {
102
69
  var {
103
70
  userColumnWidths = new Map(),
104
71
  userRowHeights = new Map(),
105
- calculatedColumnWidths = new Map(),
106
72
  calculatedRowHeights = new Map(),
73
+ calculatedColumnWidths = new Map(),
107
74
  fontWidths = new Map(),
108
75
  modelRows = new Map(),
109
76
  modelColumns = new Map(),
110
- movedRows = [],
111
- movedColumns = []
77
+ movedRows = null,
78
+ movedColumns = null
112
79
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
113
-
114
- _defineProperty(this, "userColumnWidths", void 0);
115
-
116
- _defineProperty(this, "userRowHeights", void 0);
117
-
118
- _defineProperty(this, "calculatedColumnWidths", void 0);
119
-
120
- _defineProperty(this, "calculatedRowHeights", void 0);
121
-
122
- _defineProperty(this, "fontWidths", void 0);
123
-
124
- _defineProperty(this, "modelRows", void 0);
125
-
126
- _defineProperty(this, "modelColumns", void 0);
127
-
128
- _defineProperty(this, "movedRows", void 0);
129
-
130
- _defineProperty(this, "movedColumns", void 0);
131
-
132
80
  this.userColumnWidths = userColumnWidths;
133
81
  this.userRowHeights = userRowHeights;
134
82
  this.calculatedRowHeights = calculatedRowHeights;
@@ -140,11 +88,7 @@ class GridMetricCalculator {
140
88
  this.movedRows = movedRows;
141
89
  this.movedColumns = movedColumns;
142
90
  }
143
- /**
144
- * Get the metrics for the provided metric state
145
- * @params state The state to get metrics for
146
- * @returns The full metrics
147
- */
91
+ /** update the calculated metrics from the model/canvas that are useful for many functions */
148
92
 
149
93
 
150
94
  getMetrics(state) {
@@ -196,8 +140,8 @@ class GridMetricCalculator {
196
140
  var treePaddingX = model.hasExpandableRows ? this.calculateTreePaddingX(state) : 0;
197
141
  var treePaddingY = 0; // We don't support trees on columns (at least not yet)
198
142
 
199
- var visibleRowHeights = new Map([...this.getVisibleRowHeights(state), ...this.getFloatingRowHeights(state)]);
200
- var visibleColumnWidths = new Map([...this.getVisibleColumnWidths(state, firstColumn, treePaddingX), ...this.getFloatingColumnWidths(state)]); // Calculate the metrics for the main grid
143
+ var visibleRowHeights = this.getVisibleRowHeights(state);
144
+ var visibleColumnWidths = this.getVisibleColumnWidths(state, firstColumn, treePaddingX); // Calculate the metrics for the main grid
201
145
 
202
146
  var visibleRows = Array.from(visibleRowHeights.keys());
203
147
  var visibleColumns = Array.from(visibleColumnWidths.keys());
@@ -211,9 +155,8 @@ class GridMetricCalculator {
211
155
  var rowHeightValues = Array.from(visibleRowHeights.values());
212
156
  var maxX = columnWidthValues.reduce((x, w) => x + w, 0) - leftOffset;
213
157
  var maxY = rowHeightValues.reduce((y, h) => y + h, 0) - topOffset;
214
- var floatingBottomHeight = this.getFloatingBottomHeight(state, visibleRowHeights);
215
158
  var lastLeft = this.getLastLeft(state, null, width - gridX - scrollBarSize - rowFooterWidth);
216
- var lastTop = this.getLastTop(state, null, height - gridY - scrollBarSize - floatingBottomHeight); // Calculate some metrics for the scroll bars
159
+ var lastTop = this.getLastTop(state, null, height - gridY - scrollBarSize); // Calculate some metrics for the scroll bars
217
160
 
218
161
  var hasHorizontalBar = lastLeft > 0;
219
162
  var hasVerticalBar = lastTop > 0;
@@ -223,17 +166,18 @@ class GridMetricCalculator {
223
166
  var barHeight = height - columnHeaderHeight - horizontalBarHeight;
224
167
  var handleWidth = lastLeft > 0 ? Math.min(Math.max(minScrollHandleSize, barWidth * ((columnCount - lastLeft) / columnCount)), barWidth - 1) : 0;
225
168
  var handleHeight = lastTop > 0 ? Math.min(Math.max(minScrollHandleSize, barHeight * ((rowCount - lastTop) / rowCount)), barHeight - 1) : 0;
226
- var leftColumnWidth = getOrThrow(visibleColumnWidths, left, 0);
227
- var topRowHeight = getOrThrow(visibleRowHeights, top, 0);
169
+ var leftColumnWidth = visibleColumnWidths.get(left);
170
+ var topRowHeight = visibleRowHeights.get(top);
228
171
  var leftOffsetPercent = leftColumnWidth > 0 ? leftOffset / leftColumnWidth : 0;
229
172
  var topOffsetPercent = topRowHeight > 0 ? topOffset / topRowHeight : 0;
230
173
  var scrollX = lastLeft > 0 ? (left + leftOffsetPercent) / lastLeft * (barWidth - handleWidth) : 0;
231
- var scrollY = lastTop > 0 ? (top + topOffsetPercent) / lastTop * (barHeight - handleHeight) : 0; // Now add the floating sections positions
174
+ var scrollY = lastTop > 0 ? (top + topOffsetPercent) / lastTop * (barHeight - handleHeight) : 0; // Now add the floating sections
232
175
 
233
176
  var floatingRows = [];
234
177
 
235
178
  if (floatingTopRowCount > 0 || floatingBottomRowCount > 0) {
236
179
  floatingRows = [...Array(floatingTopRowCount).keys(), ...[...Array(floatingBottomRowCount).keys()].map(i => rowCount - i - 1)];
180
+ visibleRowHeights = new Map([...visibleRowHeights, ...this.getFloatingRowHeights(state)]);
237
181
  visibleRowYs = new Map([...visibleRowYs, ...this.getFloatingRowYs(state, visibleRowHeights, Math.floor(height - gridY - horizontalBarHeight))]);
238
182
  }
239
183
 
@@ -241,6 +185,7 @@ class GridMetricCalculator {
241
185
 
242
186
  if (floatingLeftColumnCount > 0 || floatingRightColumnCount > 0) {
243
187
  floatingColumns = [...Array(floatingLeftColumnCount).keys(), ...[...Array(floatingRightColumnCount).keys()].map(i => columnCount - i - 1)];
188
+ visibleColumnWidths = new Map([...visibleColumnWidths, ...this.getFloatingColumnWidths(state)]);
244
189
  visibleColumnXs = new Map([...visibleColumnXs, ...this.getFloatingColumnXs(state, visibleColumnWidths, Math.floor(width - gridX - verticalBarWidth))]);
245
190
  }
246
191
 
@@ -250,11 +195,12 @@ class GridMetricCalculator {
250
195
  var modelColumns = this.getModelColumns(allColumns, state);
251
196
  var visibleRowTreeBoxes = this.getVisibleRowTreeBoxes(visibleRowHeights, modelRows, state); // Calculate the visible viewport based on scroll position and floating sections
252
197
 
253
- var topVisible = this.getTopVisible(state, visibleRowYs, visibleRowHeights, visibleRows);
254
- var leftVisible = this.getLeftVisible(state, visibleColumnXs, visibleColumnWidths, visibleColumns);
198
+ var topVisible = this.getTopVisible(state, visibleRowYs, visibleRowHeights, visibleRows, gridY);
199
+ var leftVisible = this.getLeftVisible(state, visibleColumnXs, visibleColumnWidths, visibleColumns, gridX);
255
200
  var bottomVisible = lastTop > 0 ? this.getBottomVisible(state, visibleRowYs, visibleRowHeights, visibleRows, gridY) : bottom;
256
201
  var rightVisible = lastLeft > 0 ? this.getRightVisible(state, visibleColumnXs, visibleColumnWidths, visibleColumns, gridX) : right;
257
202
  var floatingTopHeight = this.getFloatingTopHeight(state, visibleRowHeights);
203
+ var floatingBottomHeight = this.getFloatingBottomHeight(state, visibleRowHeights);
258
204
  var floatingLeftWidth = this.getFloatingLeftWidth(state, visibleColumnWidths);
259
205
  var floatingRightWidth = this.getFloatingRightWidth(state, visibleColumnWidths);
260
206
  var {
@@ -358,12 +304,6 @@ class GridMetricCalculator {
358
304
  calculatedColumnWidths
359
305
  };
360
306
  }
361
- /**
362
- * The x offset of the grid
363
- * @param state The current grid state
364
- * @returns x value of the left side of the first cell
365
- */
366
-
367
307
 
368
308
  getGridX(state) {
369
309
  var {
@@ -374,12 +314,6 @@ class GridMetricCalculator {
374
314
  } = theme;
375
315
  return rowHeaderWidth;
376
316
  }
377
- /**
378
- * The y offset of the grid
379
- * @param state The current grid state
380
- * @returns y value of the top side of the first cell
381
- */
382
-
383
317
 
384
318
  getGridY(state) {
385
319
  var {
@@ -390,13 +324,6 @@ class GridMetricCalculator {
390
324
  } = theme;
391
325
  return columnHeaderHeight;
392
326
  }
393
- /**
394
- * The height of the "visible" area (excludes floating areas)
395
- * @param state The current grid state
396
- * @param visibleRowHeights All the visible row heights
397
- * @returns The visible height in pixels
398
- */
399
-
400
327
 
401
328
  getVisibleHeight(state) {
402
329
  var visibleRowHeights = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingRowHeights(state);
@@ -412,13 +339,6 @@ class GridMetricCalculator {
412
339
  var floatingTopHeight = this.getFloatingTopHeight(state, visibleRowHeights);
413
340
  return height - floatingBottomHeight - floatingTopHeight - gridY - scrollBarSize;
414
341
  }
415
- /**
416
- * The width of the "visible" area (excludes floating areas)
417
- * @param state The current grid state
418
- * @param visibleColumnWidths All the visible column widths
419
- * @returns The visible width in pixels
420
- */
421
-
422
342
 
423
343
  getVisibleWidth(state) {
424
344
  var visibleColumnWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingColumnWidths(state);
@@ -435,14 +355,6 @@ class GridMetricCalculator {
435
355
  var floatingLeftWidth = this.getFloatingLeftWidth(state, visibleColumnWidths);
436
356
  return width - floatingLeftWidth - floatingRightWidth - gridX - scrollBarSize - rowFooterWidth;
437
357
  }
438
- /**
439
- * Retrieve the index of the first non-hidden item
440
- * @param itemSizes The size of the items in this dimension
441
- * @param getModelIndex A function to map from the Index to the ModelIndex
442
- * @param state The current grid state
443
- * @returns The first item that is not hidden
444
- */
445
-
446
358
 
447
359
  getFirstIndex(itemSizes, getModelIndex, state) {
448
360
  // We only need to check at the very most the number of items the user has hidden + 1
@@ -458,33 +370,21 @@ class GridMetricCalculator {
458
370
 
459
371
  return 0;
460
372
  }
461
- /**
462
- * Get the first column index that isn't hidden
463
- * @param state The current grid state
464
- * @returns The first column that is not hidden
465
- */
373
+ /** Get the first column index that isn't hidden */
466
374
 
467
375
 
468
376
  getFirstColumn(state) {
469
377
  return this.getFirstIndex(this.userColumnWidths, this.getModelColumn.bind(this), state);
470
378
  }
471
- /**
472
- * Get the first row index that isn't hidden
473
- * @param state The current grid state
474
- * @returns The first row that is not hidden
475
- */
379
+ /** Get the first row index that isn't hidden */
476
380
 
477
381
 
478
382
  getFirstRow(state) {
479
383
  return this.getFirstIndex(this.userRowHeights, this.getModelRow.bind(this), state);
480
384
  }
481
385
  /**
482
- * Get the last column that can be the left most column (e.g. scrolled to the right)
386
+ * Get the last column that can be the left most column (eg. scrolled to the right)
483
387
  * If no right column is provided, then the last column is used.
484
- * @param state The current grid state
485
- * @param right The right-most column to be visible, or null to default to last cell
486
- * @param visibleWidth The width of the "visible" area (excluding floating items)
487
- * @returns The index of the last left visible column
488
388
  */
489
389
 
490
390
 
@@ -519,19 +419,10 @@ class GridMetricCalculator {
519
419
  return 0;
520
420
  }
521
421
  /**
522
- * The last row that can be the top row (e.g. scrolled to the bottom)
422
+ * The last row that can be the top row (eg. scrolled to the bottom)
523
423
  * If no bottom row is provided, then the last row that is not floating is used
524
424
  */
525
425
 
526
- /**
527
- * The last row that can be the top row (e.g. scrolled to the bottom)
528
- * If no bottom row is provided, then the last row that is not floating is used
529
- * @param state The current grid state
530
- * @param bottom The bottom-most row to be visible, or null to default to last cell
531
- * @param visibleHeight The height of the "visible" area (excluding floating items)
532
- * @returns The index of the last left visible column
533
- */
534
-
535
426
 
536
427
  getLastTop(state) {
537
428
  var bottom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
@@ -564,15 +455,6 @@ class GridMetricCalculator {
564
455
 
565
456
  return 0;
566
457
  }
567
- /**
568
- * Retrieve the top row to scroll to so the passed in `topVisible` is completely visible, taking the floating rows into account.
569
- * The `top` row is at the top underneath any floating rows, whereas `topVisible` is visible below the floating rows.
570
- * If there are no floating rows, they should be the same value.
571
- * @param state The grid metric state
572
- * @param topVisible The top row to be visible
573
- * @returns The index of the top row to scroll to (under the floating top rows)
574
- */
575
-
576
458
 
577
459
  getTopForTopVisible(state, topVisible) {
578
460
  var floatingTopHeight = this.getFloatingTopHeight(state);
@@ -586,14 +468,6 @@ class GridMetricCalculator {
586
468
 
587
469
  return top;
588
470
  }
589
- /**
590
- * Retrieve the top row to scroll to so the passed in `bottomVisible` is completely visible
591
- * at the bottom of the visible viewport, taking the floating rows into account.
592
- * @param state The grid metric state
593
- * @param bottomVisible The bottom row to be visible
594
- * @returns The index of the top row to scroll to (under the floating top rows)
595
- */
596
-
597
471
 
598
472
  getTopForBottomVisible(state, bottomVisible) {
599
473
  var {
@@ -604,14 +478,6 @@ class GridMetricCalculator {
604
478
  var availableHeight = height - gridY - floatingBottomHeight;
605
479
  return this.getLastTop(state, bottomVisible, availableHeight);
606
480
  }
607
- /**
608
- * Retrieve the left column to scroll to so the passed in `leftVisible` is completely visible
609
- * at the left of the visible viewport, taking the floating columns into account.
610
- * @param state The grid metric state
611
- * @param leftVisible The left column to be visible
612
- * @returns The index of the left column to scroll to (under the floating left columns)
613
- */
614
-
615
481
 
616
482
  getLeftForLeftVisible(state, leftVisible) {
617
483
  var floatingLeftWidth = this.getFloatingLeftWidth(state);
@@ -625,14 +491,6 @@ class GridMetricCalculator {
625
491
 
626
492
  return left;
627
493
  }
628
- /**
629
- * Retrieve the left column to scroll to so the passed in `rightVisible` is completely visible
630
- * at the right of the visible viewport, taking the floating columns into account.
631
- * @param state The grid metric state
632
- * @param rightVisible The right column to be visible
633
- * @returns The index of the left column to scroll to (under the floating left columns)
634
- */
635
-
636
494
 
637
495
  getLeftForRightVisible(state, rightVisible) {
638
496
  var {
@@ -643,12 +501,6 @@ class GridMetricCalculator {
643
501
  var availableWidth = width - gridX - floatingRightWidth;
644
502
  return this.getLastLeft(state, rightVisible, availableWidth);
645
503
  }
646
- /**
647
- * Retrieve a map of the height of each floating row
648
- * @param state The grid metric state
649
- * @returns The heights of all the floating rows
650
- */
651
-
652
504
 
653
505
  getFloatingRowHeights(state) {
654
506
  var {
@@ -672,12 +524,6 @@ class GridMetricCalculator {
672
524
 
673
525
  return rowHeights;
674
526
  }
675
- /**
676
- * Retrieve a map of the height of all the visible rows (non-floating)
677
- * @param state The grid metric state
678
- * @returns The heights of all the visible rows
679
- */
680
-
681
527
 
682
528
  getVisibleRowHeights(state) {
683
529
  var {
@@ -702,14 +548,6 @@ class GridMetricCalculator {
702
548
 
703
549
  return rowHeights;
704
550
  }
705
- /**
706
- * Retrieve a map of the width of each floating column
707
- * @param state The grid metric state
708
- * @param firstColumn The first non-hidden column
709
- * @param treePaddingX The amount of padding taken up for the tree expansion buttons
710
- * @returns The widths of all the floating columns
711
- */
712
-
713
551
 
714
552
  getFloatingColumnWidths(state) {
715
553
  var firstColumn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFirstColumn(state);
@@ -735,12 +573,6 @@ class GridMetricCalculator {
735
573
 
736
574
  return columnWidths;
737
575
  }
738
- /**
739
- * Retrieve a map of the width of all the visible columns (non-floating)
740
- * @param state The grid metric state
741
- * @returns The widths of all the visible columns
742
- */
743
-
744
576
 
745
577
  getVisibleColumnWidths(state) {
746
578
  var firstColumn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFirstColumn(state);
@@ -767,14 +599,6 @@ class GridMetricCalculator {
767
599
 
768
600
  return columnWidths;
769
601
  }
770
- /**
771
- * Retrieve a map of all the floating columns to their x coordinate
772
- * @param state The grid metric state
773
- * @param columnWidthMap Map from visible index to column width
774
- * @param maxX The maximum X size for the grid
775
- * @returns Map of the x coordinate of all floating columns
776
- */
777
-
778
602
 
779
603
  getFloatingColumnXs(state, columnWidthMap, maxX) {
780
604
  var {
@@ -785,18 +609,8 @@ class GridMetricCalculator {
785
609
  floatingLeftColumnCount,
786
610
  floatingRightColumnCount
787
611
  } = model;
788
- return getFloatingCoordinates(floatingLeftColumnCount, floatingRightColumnCount, columnCount, maxX, columnWidthMap);
612
+ return GridMetricCalculator.getFloatingCoordinates(floatingLeftColumnCount, floatingRightColumnCount, columnCount, maxX, columnWidthMap);
789
613
  }
790
- /**
791
- * Retrieve a map of all the visible columns to their x coordinate.
792
- * Starts at leftOffset with the first index in `visibleColumns`, then
793
- * calculates all the coordinates from there
794
- * @param visibleColumnWidths Map of visible column index to widths
795
- * @param visibleColumns All visible columns
796
- * @param leftOffset The left scroll offset
797
- * @returns Map of the x coordinate of all visible columns
798
- */
799
-
800
614
 
801
615
  getVisibleColumnXs(visibleColumnWidths, visibleColumns, leftOffset) {
802
616
  var visibleColumnXs = new Map();
@@ -804,21 +618,13 @@ class GridMetricCalculator {
804
618
 
805
619
  for (var i = 0; i < visibleColumns.length; i += 1) {
806
620
  var column = visibleColumns[i];
807
- var columnWidth = getOrThrow(visibleColumnWidths, column);
621
+ var columnWidth = visibleColumnWidths.get(column);
808
622
  visibleColumnXs.set(column, x);
809
623
  x += columnWidth;
810
624
  }
811
625
 
812
626
  return visibleColumnXs;
813
627
  }
814
- /**
815
- * Retrieve a map of all the floating rows to their y coordinate
816
- * @param state The grid metric state
817
- * @param rowHeightMap Map of visible index to row height
818
- * @param maxY The maximum Y size for the grid
819
- * @returns Map of the y coordinate of all floating rows
820
- */
821
-
822
628
 
823
629
  getFloatingRowYs(state, rowHeightMap, maxY) {
824
630
  var {
@@ -829,18 +635,8 @@ class GridMetricCalculator {
829
635
  floatingBottomRowCount,
830
636
  rowCount
831
637
  } = model;
832
- return getFloatingCoordinates(floatingTopRowCount, floatingBottomRowCount, rowCount, maxY, rowHeightMap);
638
+ return GridMetricCalculator.getFloatingCoordinates(floatingTopRowCount, floatingBottomRowCount, rowCount, maxY, rowHeightMap);
833
639
  }
834
- /**
835
- * Retrieve a map of all the visible rows to their y coordinate.
836
- * Starts at topOffset with the first index in `visibleRows`, then
837
- * calculates all the coordinates from there
838
- * @param visibleRowHeights Map of visible row index to heights
839
- * @param visibleRows All visible rows
840
- * @param topOffset The top scroll offset
841
- * @returns Map of the y coordinate of all visible rows
842
- */
843
-
844
640
 
845
641
  getVisibleRowYs(visibleRowHeights, visibleRows, topOffset) {
846
642
  var visibleRowYs = new Map();
@@ -848,20 +644,14 @@ class GridMetricCalculator {
848
644
 
849
645
  for (var i = 0; i < visibleRows.length; i += 1) {
850
646
  var row = visibleRows[i];
851
- var rowHeight = getOrThrow(visibleRowHeights, row);
647
+ var rowHeight = visibleRowHeights.get(row);
852
648
  visibleRowYs.set(row, y);
853
649
  y += rowHeight;
854
650
  }
855
651
 
856
652
  return visibleRowYs;
857
653
  }
858
- /**
859
- * Calculates the tree box click areas that are visible. In relation to the columnX/rowY
860
- * @param visibleRowHeights Map of visible index to row height
861
- * @param modelRows Map from visible `Index` to `ModelIndex`
862
- * @param state The grid metric state
863
- * @returns Coordinates of tree boxes for each row
864
- */
654
+ /** Calculates the tree box click areas that are visible. In relation to the columnX/rowY */
865
655
 
866
656
 
867
657
  getVisibleRowTreeBoxes(visibleRowHeights, modelRows, state) {
@@ -885,25 +675,13 @@ class GridMetricCalculator {
885
675
  var x2 = (depth + 1) * treeDepthIndent + treeHorizontalPadding;
886
676
  var y1 = 0;
887
677
  var y2 = rowHeight;
888
- visibleRowTreeBoxes.set(row, {
889
- x1,
890
- y1,
891
- x2,
892
- y2
893
- });
678
+ visibleRowTreeBoxes.set(row, [x1, y1, x2, y2]);
894
679
  }
895
680
  });
896
681
  }
897
682
 
898
683
  return visibleRowTreeBoxes;
899
684
  }
900
- /**
901
- * Get the total width of the floating columns on the left
902
- * @param state The grid metric state
903
- * @param columnWidths Map of column index to width
904
- * @returns The total width of the floating left section
905
- */
906
-
907
685
 
908
686
  getFloatingLeftWidth(state) {
909
687
  var columnWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingColumnWidths(state);
@@ -916,18 +694,13 @@ class GridMetricCalculator {
916
694
  var floatingWidth = 0;
917
695
 
918
696
  for (var i = 0; i < floatingLeftColumnCount; i += 1) {
919
- floatingWidth += getOrThrow(columnWidths, i);
697
+ var _columnWidths$get;
698
+
699
+ floatingWidth += (_columnWidths$get = columnWidths.get(i)) !== null && _columnWidths$get !== void 0 ? _columnWidths$get : 0;
920
700
  }
921
701
 
922
702
  return floatingWidth;
923
703
  }
924
- /**
925
- * Get the total width of the floating columns on the right
926
- * @param state The grid metric state
927
- * @param columnWidths Map of column index to width
928
- * @returns The total width of the floating right section
929
- */
930
-
931
704
 
932
705
  getFloatingRightWidth(state) {
933
706
  var columnWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingColumnWidths(state);
@@ -941,18 +714,13 @@ class GridMetricCalculator {
941
714
  var floatingWidth = 0;
942
715
 
943
716
  for (var i = 0; i < floatingRightColumnCount; i += 1) {
944
- floatingWidth += getOrThrow(columnWidths, columnCount - i - 1);
717
+ var _columnWidths$get2;
718
+
719
+ floatingWidth += (_columnWidths$get2 = columnWidths.get(columnCount - i - 1)) !== null && _columnWidths$get2 !== void 0 ? _columnWidths$get2 : 0;
945
720
  }
946
721
 
947
722
  return floatingWidth;
948
723
  }
949
- /**
950
- * Get the total height of the floating rows on the top
951
- * @param state The grid metric state
952
- * @param rowHeights Map of row index to height
953
- * @returns The total height of the floating top section
954
- */
955
-
956
724
 
957
725
  getFloatingTopHeight(state) {
958
726
  var rowHeights = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingRowHeights(state);
@@ -965,18 +733,13 @@ class GridMetricCalculator {
965
733
  var floatingHeight = 0;
966
734
 
967
735
  for (var i = 0; i < floatingTopRowCount; i += 1) {
968
- floatingHeight += getOrThrow(rowHeights, i);
736
+ var _rowHeights$get;
737
+
738
+ floatingHeight += (_rowHeights$get = rowHeights.get(i)) !== null && _rowHeights$get !== void 0 ? _rowHeights$get : 0;
969
739
  }
970
740
 
971
741
  return floatingHeight;
972
742
  }
973
- /**
974
- * Get the total height of the floating rows on the bottom
975
- * @param state The grid metric state
976
- * @param rowHeights Map of row index to height
977
- * @returns The total height of the floating bottom section
978
- */
979
-
980
743
 
981
744
  getFloatingBottomHeight(state) {
982
745
  var rowHeights = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingRowHeights(state);
@@ -990,72 +753,41 @@ class GridMetricCalculator {
990
753
  var floatingHeight = 0;
991
754
 
992
755
  for (var i = 0; i < floatingBottomRowCount; i += 1) {
993
- floatingHeight += getOrThrow(rowHeights, rowCount - i - 1);
756
+ var _rowHeights$get2;
757
+
758
+ floatingHeight += (_rowHeights$get2 = rowHeights.get(rowCount - i - 1)) !== null && _rowHeights$get2 !== void 0 ? _rowHeights$get2 : 0;
994
759
  }
995
760
 
996
761
  return floatingHeight;
997
762
  }
998
- /**
999
- * Retrieve the index of the first fully visible row in the "visible" viewport of the grid.
1000
- * E.g. First row visible after the floating rows, provided the visible rows.
1001
- * @param state The grid metric state
1002
- * @param visibleRowYs Map of row index to y coordinate
1003
- * @param visibleRowHeights Map of row index to height
1004
- * @param visibleRows Array of visible row indexes
1005
- * @returns Index of the top visible row
1006
- */
1007
-
1008
763
 
1009
764
  getTopVisible(state, visibleRowYs, visibleRowHeights, visibleRows) {
1010
765
  var floatingHeight = this.getFloatingTopHeight(state, visibleRowHeights);
1011
766
 
1012
767
  for (var i = 0; i < visibleRows.length; i += 1) {
1013
768
  var row = visibleRows[i];
1014
- var y = getOrThrow(visibleRowYs, row);
1015
769
 
1016
- if (y >= floatingHeight) {
770
+ if (visibleRowYs.get(row) >= floatingHeight) {
1017
771
  return row;
1018
772
  }
1019
773
  }
1020
774
 
1021
775
  return 0;
1022
776
  }
1023
- /**
1024
- * Retrieve the index of the first fully visible column in the "visible" viewport of the grid.
1025
- * E.g. First column visible after the floating columns, provided the visible columns.
1026
- * @param state The grid metric state
1027
- * @param visibleColumnXs Map of column index to x coordinate
1028
- * @param visibleColumnWidths Map of column index to widths
1029
- * @param visibleColumns Array of visible row indexes
1030
- * @returns Index of the left visible column
1031
- */
1032
-
1033
777
 
1034
778
  getLeftVisible(state, visibleColumnXs, visibleColumnWidths, visibleColumns) {
1035
779
  var floatingWidth = this.getFloatingLeftWidth(state, visibleColumnWidths);
1036
780
 
1037
781
  for (var i = 0; i < visibleColumns.length; i += 1) {
1038
782
  var column = visibleColumns[i];
1039
- var x = getOrThrow(visibleColumnXs, column);
1040
783
 
1041
- if (x >= floatingWidth) {
784
+ if (visibleColumnXs.get(column) >= floatingWidth) {
1042
785
  return column;
1043
786
  }
1044
787
  }
1045
788
 
1046
789
  return 0;
1047
790
  }
1048
- /**
1049
- * Retrieve the index of the last fully visible row in the "visible" viewport of the grid.
1050
- * E.g. Last row visible before the bottom floating rows, provided the visible rows.
1051
- * @param state The grid metric state
1052
- * @param visibleRowYs Map of row index to y coordinate
1053
- * @param visibleRowHeights Map of row index to height
1054
- * @param visibleRows Array of visible row indexes
1055
- * @param gridY The starting y coordinate of the grid
1056
- * @returns Index of the bottom visible row
1057
- */
1058
-
1059
791
 
1060
792
  getBottomVisible(state, visibleRowYs, visibleRowHeights, visibleRows, gridY) {
1061
793
  var {
@@ -1070,8 +802,8 @@ class GridMetricCalculator {
1070
802
 
1071
803
  for (var i = visibleRows.length - 1; i >= 0; i -= 1) {
1072
804
  var row = visibleRows[i];
1073
- var rowY = getOrThrow(visibleRowYs, row);
1074
- var rowHeight = getOrThrow(visibleRowHeights, row);
805
+ var rowY = visibleRowYs.get(row);
806
+ var rowHeight = visibleRowHeights.get(row);
1075
807
 
1076
808
  if (rowY + rowHeight <= visibleHeight) {
1077
809
  return row;
@@ -1080,16 +812,6 @@ class GridMetricCalculator {
1080
812
 
1081
813
  return 0;
1082
814
  }
1083
- /**
1084
- * Retrieve the index of the last fully visible column in the "visible" viewport of the grid.
1085
- * E.g. Last column visible before the floating columns, provided the visible columns.
1086
- * @param state The grid metric state
1087
- * @param visibleColumnXs Map of column index to x coordinate
1088
- * @param visibleColumnWidths Map of column index to widths
1089
- * @param visibleColumns Array of visible column indexes
1090
- * @returns Index of the right visible column
1091
- */
1092
-
1093
815
 
1094
816
  getRightVisible(state, visibleColumnXs, visibleColumnWidths, visibleColumns, gridX) {
1095
817
  var {
@@ -1104,8 +826,8 @@ class GridMetricCalculator {
1104
826
 
1105
827
  for (var i = visibleColumns.length - 1; i >= 0; i -= 1) {
1106
828
  var column = visibleColumns[i];
1107
- var columnX = getOrThrow(visibleColumnXs, column);
1108
- var columnWidth = getOrThrow(visibleColumnWidths, column);
829
+ var columnX = visibleColumnXs.get(column);
830
+ var columnWidth = visibleColumnWidths.get(column);
1109
831
 
1110
832
  if (columnX + columnWidth <= visibleWidth) {
1111
833
  return column;
@@ -1114,15 +836,6 @@ class GridMetricCalculator {
1114
836
 
1115
837
  return 0;
1116
838
  }
1117
- /**
1118
- * Retrieve the possible bottom of the visible viewport (not limited by data size)
1119
- * @param state The grid metric state
1120
- * @param visibleRows Array of visible row indexes
1121
- * @param visibleRowYs Map of row index to y coordinate
1122
- * @param visibleRowHeights Map of row index to height
1123
- * @returns The index of the bottom viewport possible
1124
- */
1125
-
1126
839
 
1127
840
  getBottomViewport(state, visibleRows, visibleRowYs, visibleRowHeights) {
1128
841
  var {
@@ -1134,15 +847,6 @@ class GridMetricCalculator {
1134
847
  } = theme;
1135
848
  return this.getLastIndexViewport(visibleRows, visibleRowYs, visibleRowHeights, height, rowHeight);
1136
849
  }
1137
- /**
1138
- * Retrieve the possible right of the visible viewport (not limited by data size)
1139
- * @param state The grid metric state
1140
- * @param visibleColumns Array of visible column indexes
1141
- * @param visibleColumnXs Map of column index to x coordinate
1142
- * @param visibleColumnWidths Map of column index to width
1143
- * @returns The index of the right viewport possible
1144
- */
1145
-
1146
850
 
1147
851
  getRightViewport(state, visibleColumns, visibleColumnXs, visibleColumnWidths) {
1148
852
  var {
@@ -1154,16 +858,6 @@ class GridMetricCalculator {
1154
858
  } = theme;
1155
859
  return this.getLastIndexViewport(visibleColumns, visibleColumnXs, visibleColumnWidths, width, columnWidth);
1156
860
  }
1157
- /**
1158
- * Get the Index of the of the last index visible
1159
- * @param items Array of visible item indexes
1160
- * @param itemXs Map of index to coordinate
1161
- * @param itemSizes Map of index to size
1162
- * @param maxSize Full size of the grid
1163
- * @param defaultItemSize Default size of an item
1164
- * @returns The Index of the last index visible
1165
- */
1166
-
1167
861
 
1168
862
  getLastIndexViewport(items, itemXs, itemSizes, maxSize, defaultItemSize) {
1169
863
  var lastIndex = 0;
@@ -1171,7 +865,7 @@ class GridMetricCalculator {
1171
865
 
1172
866
  if (items.length > 0) {
1173
867
  lastIndex = items[items.length - 1];
1174
- dataSize = getOrThrow(itemXs, lastIndex) + getOrThrow(itemSizes, lastIndex);
868
+ dataSize = itemXs.get(lastIndex) + itemSizes.get(lastIndex);
1175
869
  }
1176
870
 
1177
871
  if (dataSize < maxSize) {
@@ -1180,41 +874,19 @@ class GridMetricCalculator {
1180
874
 
1181
875
  return lastIndex;
1182
876
  }
1183
- /**
1184
- * Get the size from the provided size map of the specified item
1185
- * @param modelIndex The model index to get the size for
1186
- * @param userSizes The user set sizes
1187
- * @param calculateSize Method to calculate the size for this item
1188
- * @returns The size from the provided size map of the specified item
1189
- */
1190
-
1191
877
 
1192
878
  getVisibleItemSize(modelIndex, userSizes, calculateSize) {
1193
- var _userSizes$get;
879
+ if (userSizes.has(modelIndex)) {
880
+ return userSizes.get(modelIndex);
881
+ }
1194
882
 
1195
- return (_userSizes$get = userSizes.get(modelIndex)) !== null && _userSizes$get !== void 0 ? _userSizes$get : calculateSize();
883
+ return calculateSize();
1196
884
  }
1197
- /**
1198
- * Get the height of the specified row
1199
- * @param row Index of the row to get the height of
1200
- * @param state The grid metric state
1201
- * @returns The height of the row specified
1202
- */
1203
-
1204
885
 
1205
886
  getVisibleRowHeight(row, state) {
1206
887
  var modelRow = this.getModelRow(row, state);
1207
888
  return this.getVisibleItemSize(modelRow, this.userRowHeights, () => this.calculateRowHeight(row, modelRow, state));
1208
889
  }
1209
- /**
1210
- * Get the width of the specified column
1211
- * @param column Index of the column to get the width of
1212
- * @param state The grid metric state
1213
- * @param firstColumn Index of first visible column
1214
- * @param treePaddingX The amount of tree padding to add to the first visible column
1215
- * @returns The width of the column
1216
- */
1217
-
1218
890
 
1219
891
  getVisibleColumnWidth(column, state) {
1220
892
  var firstColumn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.getFirstColumn(state);
@@ -1222,13 +894,6 @@ class GridMetricCalculator {
1222
894
  var modelColumn = this.getModelColumn(column, state);
1223
895
  return this.getVisibleItemSize(modelColumn, this.userColumnWidths, () => this.calculateColumnWidth(column, modelColumn, state, firstColumn, treePaddingX));
1224
896
  }
1225
- /**
1226
- * Get a map of ModelIndex to Index
1227
- * @param visibleRows Array of visible row indexes
1228
- * @param state The grid metric state
1229
- * @returns Map of Index to ModelIndex
1230
- */
1231
-
1232
897
 
1233
898
  getModelRows(visibleRows, state) {
1234
899
  var modelRows = new Map();
@@ -1241,17 +906,10 @@ class GridMetricCalculator {
1241
906
 
1242
907
  return modelRows;
1243
908
  }
1244
- /**
1245
- * Get the ModelIndex of the specified row
1246
- * @param visibleRow Index of the row
1247
- * @param state The grid metric state
1248
- * @returns ModelIndex of the row
1249
- */
1250
-
1251
909
 
1252
910
  getModelRow(visibleRow, state) {
1253
911
  if (this.modelRows.has(visibleRow)) {
1254
- return getOrThrow(this.modelRows, visibleRow);
912
+ return this.modelRows.get(visibleRow);
1255
913
  }
1256
914
 
1257
915
  var {
@@ -1261,13 +919,6 @@ class GridMetricCalculator {
1261
919
  this.modelRows.set(visibleRow, modelRow);
1262
920
  return modelRow;
1263
921
  }
1264
- /**
1265
- * Get a map of Index to ModelIndex. Applies the move operations to get the transformation.
1266
- * @param visibleColumns Array of visible column indexes
1267
- * @param state The grid metric state
1268
- * @returns Map of Index to ModelIndex
1269
- */
1270
-
1271
922
 
1272
923
  getModelColumns(visibleColumns, state) {
1273
924
  var modelColumns = new Map();
@@ -1280,17 +931,10 @@ class GridMetricCalculator {
1280
931
 
1281
932
  return modelColumns;
1282
933
  }
1283
- /**
1284
- * Get the ModelIndex of the specified column
1285
- * @param visibleColumn Index of the column
1286
- * @param state The grid metric state
1287
- * @returns ModelIndex of the column
1288
- */
1289
-
1290
934
 
1291
935
  getModelColumn(visibleColumn, state) {
1292
936
  if (this.modelColumns.has(visibleColumn)) {
1293
- return getOrThrow(this.modelColumns, visibleColumn);
937
+ return this.modelColumns.get(visibleColumn);
1294
938
  }
1295
939
 
1296
940
  var {
@@ -1300,14 +944,6 @@ class GridMetricCalculator {
1300
944
  this.modelColumns.set(visibleColumn, modelColumn);
1301
945
  return modelColumn;
1302
946
  }
1303
- /**
1304
- * Calculate the height of the row specified.
1305
- * @param row Index of the row to calculate the height for
1306
- * @param modelRow ModelIndex of the row to calculate the height
1307
- * @param state The grid metric state
1308
- * @returns The height of the row
1309
- */
1310
-
1311
947
 
1312
948
  calculateRowHeight(row, modelRow, state) {
1313
949
  var {
@@ -1330,18 +966,10 @@ class GridMetricCalculator {
1330
966
 
1331
967
 
1332
968
  this.calculatedRowHeights.set(modelRow, Math.ceil(rowHeight));
1333
- trimMap(this.calculatedRowHeights);
969
+ GridMetricCalculator.trimMap(this.calculatedRowHeights);
1334
970
  return rowHeight;
1335
971
  }
1336
- /**
1337
- * Calculates the column width based on the provided column model index
1338
- * @param column Index of the column to calculate the width for
1339
- * @param modelColumn ModelIndex of the column to calculate the width
1340
- * @param state The grid metric state
1341
- * @param firstColumn The first visible column
1342
- * @param treePaddingX Tree padding offset for expandable rows
1343
- * @returns The width of the column
1344
- */
972
+ /** Calculates the column width based on the provided column model index */
1345
973
 
1346
974
 
1347
975
  calculateColumnWidth(column, modelColumn, state) {
@@ -1372,7 +1000,7 @@ class GridMetricCalculator {
1372
1000
  columnWidth = cachedValue;
1373
1001
  } else {
1374
1002
  this.calculatedColumnWidths.set(modelColumn, columnWidth);
1375
- trimMap(this.calculatedColumnWidths);
1003
+ GridMetricCalculator.trimMap(this.calculatedColumnWidths);
1376
1004
  }
1377
1005
 
1378
1006
  if (column === firstColumn) {
@@ -1381,13 +1009,6 @@ class GridMetricCalculator {
1381
1009
 
1382
1010
  return columnWidth;
1383
1011
  }
1384
- /**
1385
- * Calculate the width of the specified column's header
1386
- * @param modelColumn ModelIndex of the column to get the header width for
1387
- * @param state The grid metric state
1388
- * @returns The calculated width of the column header
1389
- */
1390
-
1391
1012
 
1392
1013
  calculateColumnHeaderWidth(modelColumn, state) {
1393
1014
  var {
@@ -1407,13 +1028,6 @@ class GridMetricCalculator {
1407
1028
 
1408
1029
  return headerHorizontalPadding * 2;
1409
1030
  }
1410
- /**
1411
- * Calculate the width of the specified column's data
1412
- * @param modelColumn ModelIndex of the column to get the data width for
1413
- * @param state The grid metric state
1414
- * @returns The calculated width of the column data
1415
- */
1416
-
1417
1031
 
1418
1032
  calculateColumnDataWidth(modelColumn, state) {
1419
1033
  var {
@@ -1452,12 +1066,6 @@ class GridMetricCalculator {
1452
1066
  columnWidth = Math.max(Math.min(columnWidth, (width - rowHeaderWidth - scrollBarSize - rowFooterWidth) * GridMetricCalculator.MAX_COLUMN_WIDTH), cellHorizontalPadding * 2);
1453
1067
  return columnWidth;
1454
1068
  }
1455
- /**
1456
- * The coordinate for where the tree padding should be drawn
1457
- * @param state The grid metric state
1458
- * @returns The coordinate for tree padding
1459
- */
1460
-
1461
1069
 
1462
1070
  calculateTreePaddingX(state) {
1463
1071
  var {
@@ -1487,18 +1095,12 @@ class GridMetricCalculator {
1487
1095
 
1488
1096
  return treePadding;
1489
1097
  }
1490
- /**
1491
- * Get the width of the provided font. Exploits the fact that we're
1492
- * using tabular figures so every character is same width
1493
- * @param font The font to get the width for
1494
- * @param state The grid metric state
1495
- * @returns Width of the char `8` for the specified font
1496
- */
1098
+ /** Get the width of the provided font. Exploits the fact that we're using tabular figures so every character is same width */
1497
1099
 
1498
1100
 
1499
1101
  getWidthForFont(font, state) {
1500
1102
  if (this.fontWidths.has(font)) {
1501
- return getOrThrow(this.fontWidths, font);
1103
+ return this.fontWidths.get(font);
1502
1104
  }
1503
1105
 
1504
1106
  var {
@@ -1508,7 +1110,7 @@ class GridMetricCalculator {
1508
1110
  var textMetrics = context.measureText('8');
1509
1111
  var {
1510
1112
  width
1511
- } = textMetrics; // context.font changes the string a little bit, e.g. '10px Arial, sans serif' => '10px Arial, "sans serif"'
1113
+ } = textMetrics; // context.font changes the string a little bit, eg. '10px Arial, sans serif' => '10px Arial, "sans serif"'
1512
1114
  // Rather than require checking with the correct font def (theme, or context font), just key it to both
1513
1115
 
1514
1116
  this.fontWidths.set(font, width);
@@ -1517,56 +1119,55 @@ class GridMetricCalculator {
1517
1119
  }
1518
1120
  /**
1519
1121
  * Sets the width for the specified column
1520
- * @param column The column model index to set
1521
- * @param size The size to set it to
1122
+ * @param {Number} column The column model index to set
1123
+ * @param {Number} size The size to set it to, or null to reset the column size
1522
1124
  */
1523
1125
 
1524
1126
 
1525
1127
  setColumnWidth(column, size) {
1526
- // Always use a new instance of the map so any consumer of the metrics knows there has been a change
1527
1128
  var userColumnWidths = new Map(this.userColumnWidths);
1528
- userColumnWidths.set(column, Math.ceil(size));
1529
- trimMap(userColumnWidths);
1129
+
1130
+ if (size != null) {
1131
+ userColumnWidths.set(column, Math.ceil(size));
1132
+ GridMetricCalculator.trimMap(userColumnWidths);
1133
+ } else {
1134
+ userColumnWidths.delete(column);
1135
+ }
1136
+
1530
1137
  this.userColumnWidths = userColumnWidths;
1531
1138
  }
1532
1139
  /**
1533
1140
  * Resets the column width for the specified column to the calculated width
1534
- * @param column The column model index to reset
1141
+ * @param {Number} column The column model index to reset
1535
1142
  */
1536
1143
 
1537
1144
 
1538
1145
  resetColumnWidth(column) {
1539
- // Always use a new instance of the map so any consumer of the metrics knows there has been a change
1540
- var userColumnWidths = new Map(this.userColumnWidths);
1541
- userColumnWidths.delete(column);
1542
- this.userColumnWidths = userColumnWidths;
1146
+ this.setColumnWidth(column, null);
1543
1147
  this.calculatedColumnWidths.delete(column);
1544
1148
  }
1545
1149
  /**
1546
1150
  * Sets the width for the specified row
1547
- * @param row The row model index to set
1548
- * @param size The size to set it to
1151
+ * @param {Number} row The row model index to set
1152
+ * @param {Number} size The size to set it to, or null to reset the row size
1549
1153
  */
1550
1154
 
1551
1155
 
1552
1156
  setRowHeight(row, size) {
1553
- // Always use a new instance of the map so any consumer of the metrics knows there has been a change
1554
1157
  var userRowHeights = new Map(this.userRowHeights);
1555
- userRowHeights.set(row, Math.ceil(size));
1556
- trimMap(userRowHeights);
1158
+
1159
+ if (size != null) {
1160
+ userRowHeights.set(row, Math.ceil(size));
1161
+ GridMetricCalculator.trimMap(userRowHeights);
1162
+ } else {
1163
+ userRowHeights.delete(row);
1164
+ }
1165
+
1557
1166
  this.userRowHeights = userRowHeights;
1558
1167
  }
1559
- /**
1560
- * Resets the row height for the specified row to the calculated height
1561
- * @param row The row model index to reset
1562
- */
1563
-
1564
1168
 
1565
1169
  resetRowHeight(row) {
1566
- // Always use a new instance of the map so any consumer of the metrics knows there has been a change
1567
- var userRowHeights = new Map(this.userRowHeights);
1568
- userRowHeights.delete(row);
1569
- this.userRowHeights = userRowHeights;
1170
+ this.setRowHeight(row, null);
1570
1171
  this.calculatedRowHeights.delete(row);
1571
1172
  }
1572
1173