@deephaven/grid 0.5.2-beta.0 → 0.6.1-demo.8

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 (76) hide show
  1. package/dist/CellInputField.js +40 -88
  2. package/dist/CellInputField.js.map +1 -1
  3. package/dist/Grid.js +1449 -1484
  4. package/dist/Grid.js.map +1 -1
  5. package/dist/GridColorUtils.js +18 -51
  6. package/dist/GridColorUtils.js.map +1 -1
  7. package/dist/GridMetricCalculator.d.ts +8 -1
  8. package/dist/GridMetricCalculator.d.ts.map +1 -1
  9. package/dist/GridMetricCalculator.js +1031 -994
  10. package/dist/GridMetricCalculator.js.map +1 -1
  11. package/dist/GridModel.d.ts +4 -1
  12. package/dist/GridModel.d.ts.map +1 -1
  13. package/dist/GridModel.js +175 -286
  14. package/dist/GridModel.js.map +1 -1
  15. package/dist/GridMouseHandler.js +39 -59
  16. package/dist/GridMouseHandler.js.map +1 -1
  17. package/dist/GridRange.js +572 -630
  18. package/dist/GridRange.js.map +1 -1
  19. package/dist/GridRenderer.js +1650 -1564
  20. package/dist/GridRenderer.js.map +1 -1
  21. package/dist/GridTestUtils.js +15 -29
  22. package/dist/GridTestUtils.js.map +1 -1
  23. package/dist/GridUtils.js +679 -717
  24. package/dist/GridUtils.js.map +1 -1
  25. package/dist/KeyHandler.js +6 -18
  26. package/dist/KeyHandler.js.map +1 -1
  27. package/dist/MockGridModel.js +105 -210
  28. package/dist/MockGridModel.js.map +1 -1
  29. package/dist/MockTreeGridModel.js +113 -183
  30. package/dist/MockTreeGridModel.js.map +1 -1
  31. package/dist/errors/PasteError.js +5 -44
  32. package/dist/errors/PasteError.js.map +1 -1
  33. package/dist/errors/index.js +1 -1
  34. package/dist/errors/index.js.map +1 -1
  35. package/dist/index.js +15 -15
  36. package/dist/index.js.map +1 -1
  37. package/dist/key-handlers/EditKeyHandler.js +42 -75
  38. package/dist/key-handlers/EditKeyHandler.js.map +1 -1
  39. package/dist/key-handlers/PasteKeyHandler.js +42 -78
  40. package/dist/key-handlers/PasteKeyHandler.js.map +1 -1
  41. package/dist/key-handlers/SelectionKeyHandler.d.ts.map +1 -1
  42. package/dist/key-handlers/SelectionKeyHandler.js +239 -229
  43. package/dist/key-handlers/SelectionKeyHandler.js.map +1 -1
  44. package/dist/key-handlers/TreeKeyHandler.js +42 -72
  45. package/dist/key-handlers/TreeKeyHandler.js.map +1 -1
  46. package/dist/key-handlers/index.js +4 -4
  47. package/dist/key-handlers/index.js.map +1 -1
  48. package/dist/memoizeClear.js +1 -1
  49. package/dist/memoizeClear.js.map +1 -1
  50. package/dist/mouse-handlers/EditMouseHandler.js +18 -50
  51. package/dist/mouse-handlers/EditMouseHandler.js.map +1 -1
  52. package/dist/mouse-handlers/GridColumnMoveMouseHandler.d.ts.map +1 -1
  53. package/dist/mouse-handlers/GridColumnMoveMouseHandler.js +141 -163
  54. package/dist/mouse-handlers/GridColumnMoveMouseHandler.js.map +1 -1
  55. package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.js +47 -86
  56. package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.js.map +1 -1
  57. package/dist/mouse-handlers/GridHorizontalScrollBarMouseHandler.js +145 -171
  58. package/dist/mouse-handlers/GridHorizontalScrollBarMouseHandler.js.map +1 -1
  59. package/dist/mouse-handlers/GridRowMoveMouseHandler.js +125 -147
  60. package/dist/mouse-handlers/GridRowMoveMouseHandler.js.map +1 -1
  61. package/dist/mouse-handlers/GridRowSeparatorMouseHandler.js +47 -86
  62. package/dist/mouse-handlers/GridRowSeparatorMouseHandler.js.map +1 -1
  63. package/dist/mouse-handlers/GridRowTreeMouseHandler.js +46 -76
  64. package/dist/mouse-handlers/GridRowTreeMouseHandler.js.map +1 -1
  65. package/dist/mouse-handlers/GridScrollBarCornerMouseHandler.js +31 -62
  66. package/dist/mouse-handlers/GridScrollBarCornerMouseHandler.js.map +1 -1
  67. package/dist/mouse-handlers/GridSelectionMouseHandler.js +200 -222
  68. package/dist/mouse-handlers/GridSelectionMouseHandler.js.map +1 -1
  69. package/dist/mouse-handlers/GridSeparatorMouseHandler.js +206 -253
  70. package/dist/mouse-handlers/GridSeparatorMouseHandler.js.map +1 -1
  71. package/dist/mouse-handlers/GridVerticalScrollBarMouseHandler.js +146 -172
  72. package/dist/mouse-handlers/GridVerticalScrollBarMouseHandler.js.map +1 -1
  73. package/dist/mouse-handlers/index.js +10 -10
  74. package/dist/mouse-handlers/index.js.map +1 -1
  75. package/dist/tsconfig.tsbuildinfo +1 -1
  76. package/package.json +6 -10
@@ -1,24 +1,6 @@
1
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
-
3
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
-
5
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
-
7
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
8
-
9
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
-
11
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
12
-
13
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
-
15
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
16
-
17
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
18
-
19
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; }
20
2
 
21
- import GridUtils from './GridUtils';
3
+ import GridUtils from "./GridUtils.js";
22
4
  /* eslint class-methods-use-this: "off" */
23
5
 
24
6
  /* eslint react/destructuring-assignment: "off" */
@@ -29,30 +11,72 @@ import GridUtils from './GridUtils';
29
11
  * Override this class and override the individual methods to provide additional functionality.
30
12
  */
31
13
 
32
- var GridMetricCalculator = /*#__PURE__*/function () {
33
- function GridMetricCalculator() {
34
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
35
- _ref$userColumnWidths = _ref.userColumnWidths,
36
- userColumnWidths = _ref$userColumnWidths === void 0 ? new Map() : _ref$userColumnWidths,
37
- _ref$userRowHeights = _ref.userRowHeights,
38
- userRowHeights = _ref$userRowHeights === void 0 ? new Map() : _ref$userRowHeights,
39
- _ref$calculatedRowHei = _ref.calculatedRowHeights,
40
- calculatedRowHeights = _ref$calculatedRowHei === void 0 ? new Map() : _ref$calculatedRowHei,
41
- _ref$calculatedColumn = _ref.calculatedColumnWidths,
42
- calculatedColumnWidths = _ref$calculatedColumn === void 0 ? new Map() : _ref$calculatedColumn,
43
- _ref$fontWidths = _ref.fontWidths,
44
- fontWidths = _ref$fontWidths === void 0 ? new Map() : _ref$fontWidths,
45
- _ref$modelRows = _ref.modelRows,
46
- modelRows = _ref$modelRows === void 0 ? new Map() : _ref$modelRows,
47
- _ref$modelColumns = _ref.modelColumns,
48
- modelColumns = _ref$modelColumns === void 0 ? new Map() : _ref$modelColumns,
49
- _ref$movedRows = _ref.movedRows,
50
- movedRows = _ref$movedRows === void 0 ? null : _ref$movedRows,
51
- _ref$movedColumns = _ref.movedColumns,
52
- movedColumns = _ref$movedColumns === void 0 ? null : _ref$movedColumns;
53
-
54
- _classCallCheck(this, GridMetricCalculator);
14
+ class GridMetricCalculator {
15
+ /** The size of the caches this calculator stores */
16
+
17
+ /** The maximum column width as a percentage of the full grid */
18
+
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);
29
+
30
+ if (map.size > cacheSize) {
31
+ var iter = map.keys();
32
+
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
+ */
47
+
48
+
49
+ static getFloatingCoordinates(startCount, endCount, totalCount, max, sizeMap) {
50
+ var coordinates = new Map();
51
+ var x = 0;
52
+
53
+ for (var i = 0; i < startCount && i < totalCount; i += 1) {
54
+ coordinates.set(i, x);
55
+ x += sizeMap.get(i);
56
+ }
57
+
58
+ x = max;
59
+
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
+ }
55
67
 
68
+ constructor() {
69
+ var {
70
+ userColumnWidths = new Map(),
71
+ userRowHeights = new Map(),
72
+ calculatedRowHeights = new Map(),
73
+ calculatedColumnWidths = new Map(),
74
+ fontWidths = new Map(),
75
+ modelRows = new Map(),
76
+ modelColumns = new Map(),
77
+ movedRows = null,
78
+ movedColumns = null
79
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
56
80
  this.userColumnWidths = userColumnWidths;
57
81
  this.userRowHeights = userRowHeights;
58
82
  this.calculatedRowHeights = calculatedRowHeights;
@@ -67,1069 +91,1082 @@ var GridMetricCalculator = /*#__PURE__*/function () {
67
91
  /** update the calculated metrics from the model/canvas that are useful for many functions */
68
92
 
69
93
 
70
- _createClass(GridMetricCalculator, [{
71
- key: "getMetrics",
72
- value: function getMetrics(state) {
73
- var left = state.left,
74
- top = state.top,
75
- leftOffset = state.leftOffset,
76
- topOffset = state.topOffset,
77
- width = state.width,
78
- height = state.height,
79
- theme = state.theme,
80
- model = state.model,
81
- movedRows = state.movedRows,
82
- movedColumns = state.movedColumns;
83
- var rowHeight = theme.rowHeight,
84
- rowHeaderWidth = theme.rowHeaderWidth,
85
- rowFooterWidth = theme.rowFooterWidth,
86
- columnWidth = theme.columnWidth,
87
- columnHeaderHeight = theme.columnHeaderHeight,
88
- minScrollHandleSize = theme.minScrollHandleSize,
89
- scrollBarSize = theme.scrollBarSize;
90
-
91
- if (movedRows !== this.movedRows) {
92
- this.movedRows = movedRows;
93
- this.modelRows.clear();
94
- }
95
-
96
- if (movedColumns !== this.movedColumns) {
97
- this.movedColumns = movedColumns;
98
- this.modelColumns.clear();
99
- }
94
+ getMetrics(state) {
95
+ var {
96
+ left,
97
+ top,
98
+ leftOffset,
99
+ topOffset,
100
+ width,
101
+ height,
102
+ theme,
103
+ model,
104
+ movedRows,
105
+ movedColumns
106
+ } = state;
107
+ var {
108
+ rowHeight,
109
+ rowHeaderWidth,
110
+ rowFooterWidth,
111
+ columnWidth,
112
+ columnHeaderHeight,
113
+ minScrollHandleSize,
114
+ scrollBarSize
115
+ } = theme;
116
+
117
+ if (movedRows !== this.movedRows) {
118
+ this.movedRows = movedRows;
119
+ this.modelRows.clear();
120
+ }
100
121
 
101
- var columnCount = model.columnCount,
102
- rowCount = model.rowCount,
103
- floatingTopRowCount = model.floatingTopRowCount,
104
- floatingBottomRowCount = model.floatingBottomRowCount,
105
- floatingLeftColumnCount = model.floatingLeftColumnCount,
106
- floatingRightColumnCount = model.floatingRightColumnCount; // Get some basic metrics
107
-
108
- var firstRow = this.getFirstRow(state);
109
- var firstColumn = this.getFirstColumn(state);
110
- var gridX = this.getGridX(state);
111
- var gridY = this.getGridY(state);
112
- var treePaddingX = model.hasExpandableRows ? this.calculateTreePaddingX(state) : 0;
113
- var treePaddingY = 0; // We don't support trees on columns (at least not yet)
114
-
115
- var visibleRowHeights = this.getVisibleRowHeights(state);
116
- var visibleColumnWidths = this.getVisibleColumnWidths(state, firstColumn, treePaddingX); // Calculate the metrics for the main grid
117
-
118
- var visibleRows = Array.from(visibleRowHeights.keys());
119
- var visibleColumns = Array.from(visibleColumnWidths.keys());
120
- var visibleColumnXs = this.getVisibleColumnXs(visibleColumnWidths, visibleColumns, leftOffset);
121
- var visibleRowYs = this.getVisibleRowYs(visibleRowHeights, visibleRows, topOffset);
122
- var bottom = visibleRows.length > 0 ? visibleRows[visibleRows.length - 1] : top;
123
- var right = visibleColumns.length > 0 ? visibleColumns[visibleColumns.length - 1] : left;
124
- var bottomViewport = this.getBottomViewport(state, visibleRows, visibleRowYs, visibleRowHeights);
125
- var rightViewport = this.getRightViewport(state, visibleColumns, visibleColumnXs, visibleColumnWidths);
126
- var columnWidthValues = Array.from(visibleColumnWidths.values());
127
- var rowHeightValues = Array.from(visibleRowHeights.values());
128
- var maxX = columnWidthValues.reduce(function (x, w) {
129
- return x + w;
130
- }, 0) - leftOffset;
131
- var maxY = rowHeightValues.reduce(function (y, h) {
132
- return y + h;
133
- }, 0) - topOffset;
134
- var lastLeft = this.getLastLeft(state, null, width - gridX - scrollBarSize - rowFooterWidth);
135
- var lastTop = this.getLastTop(state, null, height - gridY - scrollBarSize); // Calculate some metrics for the scroll bars
136
-
137
- var hasHorizontalBar = lastLeft > 0;
138
- var hasVerticalBar = lastTop > 0;
139
- var horizontalBarHeight = hasHorizontalBar ? scrollBarSize : 0;
140
- var verticalBarWidth = hasVerticalBar ? scrollBarSize : 0;
141
- var barWidth = width - rowHeaderWidth - verticalBarWidth;
142
- var barHeight = height - columnHeaderHeight - horizontalBarHeight;
143
- var handleWidth = lastLeft > 0 ? Math.min(Math.max(minScrollHandleSize, barWidth * ((columnCount - lastLeft) / columnCount)), barWidth - 1) : 0;
144
- var handleHeight = lastTop > 0 ? Math.min(Math.max(minScrollHandleSize, barHeight * ((rowCount - lastTop) / rowCount)), barHeight - 1) : 0;
145
- var leftColumnWidth = visibleColumnWidths.get(left);
146
- var topRowHeight = visibleRowHeights.get(top);
147
- var leftOffsetPercent = leftColumnWidth > 0 ? leftOffset / leftColumnWidth : 0;
148
- var topOffsetPercent = topRowHeight > 0 ? topOffset / topRowHeight : 0;
149
- var scrollX = lastLeft > 0 ? (left + leftOffsetPercent) / lastLeft * (barWidth - handleWidth) : 0;
150
- var scrollY = lastTop > 0 ? (top + topOffsetPercent) / lastTop * (barHeight - handleHeight) : 0; // Now add the floating sections
151
-
152
- var floatingRows = [];
153
-
154
- if (floatingTopRowCount > 0 || floatingBottomRowCount > 0) {
155
- floatingRows = [].concat(_toConsumableArray(Array(floatingTopRowCount).keys()), _toConsumableArray(_toConsumableArray(Array(floatingBottomRowCount).keys()).map(function (i) {
156
- return rowCount - i - 1;
157
- })));
158
- visibleRowHeights = new Map([].concat(_toConsumableArray(visibleRowHeights), _toConsumableArray(this.getFloatingRowHeights(state))));
159
- visibleRowYs = new Map([].concat(_toConsumableArray(visibleRowYs), _toConsumableArray(this.getFloatingRowYs(state, visibleRowHeights, Math.floor(height - gridY - horizontalBarHeight)))));
160
- }
122
+ if (movedColumns !== this.movedColumns) {
123
+ this.movedColumns = movedColumns;
124
+ this.modelColumns.clear();
125
+ }
161
126
 
162
- var floatingColumns = [];
127
+ var {
128
+ columnCount,
129
+ rowCount,
130
+ floatingTopRowCount,
131
+ floatingBottomRowCount,
132
+ floatingLeftColumnCount,
133
+ floatingRightColumnCount
134
+ } = model; // Get some basic metrics
135
+
136
+ var firstRow = this.getFirstRow(state);
137
+ var firstColumn = this.getFirstColumn(state);
138
+ var gridX = this.getGridX(state);
139
+ var gridY = this.getGridY(state);
140
+ var treePaddingX = model.hasExpandableRows ? this.calculateTreePaddingX(state) : 0;
141
+ var treePaddingY = 0; // We don't support trees on columns (at least not yet)
142
+
143
+ var visibleRowHeights = this.getVisibleRowHeights(state);
144
+ var visibleColumnWidths = this.getVisibleColumnWidths(state, firstColumn, treePaddingX); // Calculate the metrics for the main grid
145
+
146
+ var visibleRows = Array.from(visibleRowHeights.keys());
147
+ var visibleColumns = Array.from(visibleColumnWidths.keys());
148
+ var visibleColumnXs = this.getVisibleColumnXs(visibleColumnWidths, visibleColumns, leftOffset);
149
+ var visibleRowYs = this.getVisibleRowYs(visibleRowHeights, visibleRows, topOffset);
150
+ var bottom = visibleRows.length > 0 ? visibleRows[visibleRows.length - 1] : top;
151
+ var right = visibleColumns.length > 0 ? visibleColumns[visibleColumns.length - 1] : left;
152
+ var bottomViewport = this.getBottomViewport(state, visibleRows, visibleRowYs, visibleRowHeights);
153
+ var rightViewport = this.getRightViewport(state, visibleColumns, visibleColumnXs, visibleColumnWidths);
154
+ var columnWidthValues = Array.from(visibleColumnWidths.values());
155
+ var rowHeightValues = Array.from(visibleRowHeights.values());
156
+ var maxX = columnWidthValues.reduce((x, w) => x + w, 0) - leftOffset;
157
+ var maxY = rowHeightValues.reduce((y, h) => y + h, 0) - topOffset;
158
+ var lastLeft = this.getLastLeft(state, null, width - gridX - scrollBarSize - rowFooterWidth);
159
+ var lastTop = this.getLastTop(state, null, height - gridY - scrollBarSize); // Calculate some metrics for the scroll bars
160
+
161
+ var hasHorizontalBar = lastLeft > 0;
162
+ var hasVerticalBar = lastTop > 0;
163
+ var horizontalBarHeight = hasHorizontalBar ? scrollBarSize : 0;
164
+ var verticalBarWidth = hasVerticalBar ? scrollBarSize : 0;
165
+ var barWidth = width - rowHeaderWidth - verticalBarWidth;
166
+ var barHeight = height - columnHeaderHeight - horizontalBarHeight;
167
+ var handleWidth = lastLeft > 0 ? Math.min(Math.max(minScrollHandleSize, barWidth * ((columnCount - lastLeft) / columnCount)), barWidth - 1) : 0;
168
+ var handleHeight = lastTop > 0 ? Math.min(Math.max(minScrollHandleSize, barHeight * ((rowCount - lastTop) / rowCount)), barHeight - 1) : 0;
169
+ var leftColumnWidth = visibleColumnWidths.get(left);
170
+ var topRowHeight = visibleRowHeights.get(top);
171
+ var leftOffsetPercent = leftColumnWidth > 0 ? leftOffset / leftColumnWidth : 0;
172
+ var topOffsetPercent = topRowHeight > 0 ? topOffset / topRowHeight : 0;
173
+ var scrollX = lastLeft > 0 ? (left + leftOffsetPercent) / lastLeft * (barWidth - handleWidth) : 0;
174
+ var scrollY = lastTop > 0 ? (top + topOffsetPercent) / lastTop * (barHeight - handleHeight) : 0; // Now add the floating sections
175
+
176
+ var floatingRows = [];
177
+
178
+ if (floatingTopRowCount > 0 || floatingBottomRowCount > 0) {
179
+ floatingRows = [...Array(floatingTopRowCount).keys(), ...[...Array(floatingBottomRowCount).keys()].map(i => rowCount - i - 1)];
180
+ visibleRowHeights = new Map([...visibleRowHeights, ...this.getFloatingRowHeights(state)]);
181
+ visibleRowYs = new Map([...visibleRowYs, ...this.getFloatingRowYs(state, visibleRowHeights, Math.floor(height - gridY - horizontalBarHeight))]);
182
+ }
163
183
 
164
- if (floatingLeftColumnCount > 0 || floatingRightColumnCount > 0) {
165
- floatingColumns = [].concat(_toConsumableArray(Array(floatingLeftColumnCount).keys()), _toConsumableArray(_toConsumableArray(Array(floatingRightColumnCount).keys()).map(function (i) {
166
- return columnCount - i - 1;
167
- })));
168
- visibleColumnWidths = new Map([].concat(_toConsumableArray(visibleColumnWidths), _toConsumableArray(this.getFloatingColumnWidths(state))));
169
- visibleColumnXs = new Map([].concat(_toConsumableArray(visibleColumnXs), _toConsumableArray(this.getFloatingColumnXs(state, visibleColumnWidths, Math.floor(width - gridX - verticalBarWidth)))));
170
- }
184
+ var floatingColumns = [];
171
185
 
172
- var allRows = visibleRows.concat(floatingRows);
173
- var allColumns = visibleColumns.concat(floatingColumns);
174
- var modelRows = this.getModelRows(allRows, state);
175
- var modelColumns = this.getModelColumns(allColumns, state);
176
- var visibleRowTreeBoxes = this.getVisibleRowTreeBoxes(visibleRowHeights, modelRows, state); // Calculate the visible viewport based on scroll position and floating sections
177
-
178
- var topVisible = this.getTopVisible(state, visibleRowYs, visibleRowHeights, visibleRows, gridY);
179
- var leftVisible = this.getLeftVisible(state, visibleColumnXs, visibleColumnWidths, visibleColumns, gridX);
180
- var bottomVisible = lastTop > 0 ? this.getBottomVisible(state, visibleRowYs, visibleRowHeights, visibleRows, gridY) : bottom;
181
- var rightVisible = lastLeft > 0 ? this.getRightVisible(state, visibleColumnXs, visibleColumnWidths, visibleColumns, gridX) : right;
182
- var floatingTopHeight = this.getFloatingTopHeight(state, visibleRowHeights);
183
- var floatingBottomHeight = this.getFloatingBottomHeight(state, visibleRowHeights);
184
- var floatingLeftWidth = this.getFloatingLeftWidth(state, visibleColumnWidths);
185
- var floatingRightWidth = this.getFloatingRightWidth(state, visibleColumnWidths);
186
- var fontWidths = this.fontWidths,
187
- userColumnWidths = this.userColumnWidths,
188
- userRowHeights = this.userRowHeights,
189
- calculatedRowHeights = this.calculatedRowHeights,
190
- calculatedColumnWidths = this.calculatedColumnWidths;
191
- return {
192
- // Row/Column metrics from model
193
- rowHeight: rowHeight,
194
- rowHeaderWidth: rowHeaderWidth,
195
- rowFooterWidth: rowFooterWidth,
196
- rowCount: rowCount,
197
- columnWidth: columnWidth,
198
- columnCount: columnCount,
199
- columnHeaderHeight: columnHeaderHeight,
200
- // Floating row and column counts
201
- floatingTopRowCount: floatingTopRowCount,
202
- floatingBottomRowCount: floatingBottomRowCount,
203
- floatingLeftColumnCount: floatingLeftColumnCount,
204
- floatingRightColumnCount: floatingRightColumnCount,
205
- // The grid offset from the top left
206
- gridX: gridX,
207
- gridY: gridY,
208
- // Index of non-hidden row/columns
209
- firstRow: firstRow,
210
- firstColumn: firstColumn,
211
- // The amount of padding for tree (if applicable)
212
- treePaddingX: treePaddingX,
213
- treePaddingY: treePaddingY,
214
- // What viewport is currently visible, limited by data size
215
- left: left,
216
- top: top,
217
- bottom: bottom,
218
- right: right,
219
- topOffset: topOffset,
220
- leftOffset: leftOffset,
221
- // Bottom and right that are fully visible, not overlapped by scroll bars or anything
222
- topVisible: topVisible,
223
- leftVisible: leftVisible,
224
- bottomVisible: bottomVisible,
225
- rightVisible: rightVisible,
226
- // Bottom and right of the viewport, not limited by data size
227
- bottomViewport: bottomViewport,
228
- rightViewport: rightViewport,
229
- // Canvas width/height
230
- width: width,
231
- height: height,
232
- // Max x/y coordinate of the grid (does not include headers)
233
- maxX: maxX,
234
- maxY: maxY,
235
- // Last valid column/row that can be the left/top of the grid
236
- lastLeft: lastLeft,
237
- lastTop: lastTop,
238
- // Scroll bar metrics
239
- barHeight: barHeight,
240
- barWidth: barWidth,
241
- handleHeight: handleHeight,
242
- handleWidth: handleWidth,
243
- hasHorizontalBar: hasHorizontalBar,
244
- hasVerticalBar: hasVerticalBar,
245
- verticalBarWidth: verticalBarWidth,
246
- horizontalBarHeight: horizontalBarHeight,
247
- // The vertical x/y scroll amount
248
- scrollX: scrollX,
249
- scrollY: scrollY,
250
- // Array of visible rows/columns, by grid index
251
- visibleRows: visibleRows,
252
- visibleColumns: visibleColumns,
253
- // Array of floating rows/columns, by grid index
254
- floatingRows: floatingRows,
255
- floatingColumns: floatingColumns,
256
- // Array of all rows/columns, visible and floating, by grid index
257
- allRows: allRows,
258
- allColumns: allColumns,
259
- // Map of the height/width of visible rows/columns
260
- visibleRowHeights: visibleRowHeights,
261
- visibleColumnWidths: visibleColumnWidths,
262
- // Floating metrics
263
- floatingTopHeight: floatingTopHeight,
264
- floatingBottomHeight: floatingBottomHeight,
265
- floatingLeftWidth: floatingLeftWidth,
266
- floatingRightWidth: floatingRightWidth,
267
- // Map of the X/Y coordinates of the rows/columns, from the top left of the grid
268
- visibleRowYs: visibleRowYs,
269
- visibleColumnXs: visibleColumnXs,
270
- // The boxes user can click on for expanding/collapsing tree rows
271
- visibleRowTreeBoxes: visibleRowTreeBoxes,
272
- // Mapping from visible row indexes to the model row/columns they pull from
273
- modelRows: modelRows,
274
- modelColumns: modelColumns,
275
- // Map of the width of the fonts
276
- fontWidths: fontWidths,
277
- // Map of user set column/row width/height
278
- userColumnWidths: userColumnWidths,
279
- userRowHeights: userRowHeights,
280
- // Map of calculated row/column height/width
281
- calculatedRowHeights: calculatedRowHeights,
282
- calculatedColumnWidths: calculatedColumnWidths
283
- };
284
- }
285
- }, {
286
- key: "getGridX",
287
- value: function getGridX(state) {
288
- var theme = state.theme;
289
- var rowHeaderWidth = theme.rowHeaderWidth;
290
- return rowHeaderWidth;
291
- }
292
- }, {
293
- key: "getGridY",
294
- value: function getGridY(state) {
295
- var theme = state.theme;
296
- var columnHeaderHeight = theme.columnHeaderHeight;
297
- return columnHeaderHeight;
186
+ if (floatingLeftColumnCount > 0 || floatingRightColumnCount > 0) {
187
+ floatingColumns = [...Array(floatingLeftColumnCount).keys(), ...[...Array(floatingRightColumnCount).keys()].map(i => columnCount - i - 1)];
188
+ visibleColumnWidths = new Map([...visibleColumnWidths, ...this.getFloatingColumnWidths(state)]);
189
+ visibleColumnXs = new Map([...visibleColumnXs, ...this.getFloatingColumnXs(state, visibleColumnWidths, Math.floor(width - gridX - verticalBarWidth))]);
298
190
  }
299
- }, {
300
- key: "getVisibleHeight",
301
- value: function getVisibleHeight(state) {
302
- var visibleRowHeights = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingRowHeights(state);
303
- var height = state.height,
304
- theme = state.theme;
305
- var scrollBarSize = theme.scrollBarSize;
306
- var gridY = this.getGridY(state);
307
- var floatingBottomHeight = this.getFloatingBottomHeight(state, visibleRowHeights);
308
- var floatingTopHeight = this.getFloatingTopHeight(state, visibleRowHeights);
309
- return height - floatingBottomHeight - floatingTopHeight - gridY - scrollBarSize;
310
- }
311
- }, {
312
- key: "getVisibleWidth",
313
- value: function getVisibleWidth(state) {
314
- var visibleColumnWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingColumnWidths(state);
315
- var width = state.width,
316
- theme = state.theme;
317
- var scrollBarSize = theme.scrollBarSize,
318
- rowFooterWidth = theme.rowFooterWidth;
319
- var gridX = this.getGridX(state);
320
- var floatingRightWidth = this.getFloatingRightWidth(state, visibleColumnWidths);
321
- var floatingLeftWidth = this.getFloatingLeftWidth(state, visibleColumnWidths);
322
- return width - floatingLeftWidth - floatingRightWidth - gridX - scrollBarSize - rowFooterWidth;
323
- }
324
- }, {
325
- key: "getFirstIndex",
326
- value: function getFirstIndex(itemSizes, getModelIndex, state) {
327
- // We only need to check at the very most the number of items the user has hidden + 1
328
- var max = itemSizes.size + 1;
329
-
330
- for (var i = 0; i < max; i += 1) {
331
- var modelIndex = getModelIndex(i, state);
332
191
 
333
- if (itemSizes.get(modelIndex) !== 0) {
334
- return i;
335
- }
336
- }
192
+ var allRows = visibleRows.concat(floatingRows);
193
+ var allColumns = visibleColumns.concat(floatingColumns);
194
+ var modelRows = this.getModelRows(allRows, state);
195
+ var modelColumns = this.getModelColumns(allColumns, state);
196
+ var visibleRowTreeBoxes = this.getVisibleRowTreeBoxes(visibleRowHeights, modelRows, state); // Calculate the visible viewport based on scroll position and floating sections
197
+
198
+ var topVisible = this.getTopVisible(state, visibleRowYs, visibleRowHeights, visibleRows, gridY);
199
+ var leftVisible = this.getLeftVisible(state, visibleColumnXs, visibleColumnWidths, visibleColumns, gridX);
200
+ var bottomVisible = lastTop > 0 ? this.getBottomVisible(state, visibleRowYs, visibleRowHeights, visibleRows, gridY) : bottom;
201
+ var rightVisible = lastLeft > 0 ? this.getRightVisible(state, visibleColumnXs, visibleColumnWidths, visibleColumns, gridX) : right;
202
+ var floatingTopHeight = this.getFloatingTopHeight(state, visibleRowHeights);
203
+ var floatingBottomHeight = this.getFloatingBottomHeight(state, visibleRowHeights);
204
+ var floatingLeftWidth = this.getFloatingLeftWidth(state, visibleColumnWidths);
205
+ var floatingRightWidth = this.getFloatingRightWidth(state, visibleColumnWidths);
206
+ var {
207
+ fontWidths,
208
+ userColumnWidths,
209
+ userRowHeights,
210
+ calculatedRowHeights,
211
+ calculatedColumnWidths
212
+ } = this;
213
+ return {
214
+ // Row/Column metrics from model
215
+ rowHeight,
216
+ rowHeaderWidth,
217
+ rowFooterWidth,
218
+ rowCount,
219
+ columnWidth,
220
+ columnCount,
221
+ columnHeaderHeight,
222
+ // Floating row and column counts
223
+ floatingTopRowCount,
224
+ floatingBottomRowCount,
225
+ floatingLeftColumnCount,
226
+ floatingRightColumnCount,
227
+ // The grid offset from the top left
228
+ gridX,
229
+ gridY,
230
+ // Index of non-hidden row/columns
231
+ firstRow,
232
+ firstColumn,
233
+ // The amount of padding for tree (if applicable)
234
+ treePaddingX,
235
+ treePaddingY,
236
+ // What viewport is currently visible, limited by data size
237
+ left,
238
+ top,
239
+ bottom,
240
+ right,
241
+ topOffset,
242
+ leftOffset,
243
+ // Bottom and right that are fully visible, not overlapped by scroll bars or anything
244
+ topVisible,
245
+ leftVisible,
246
+ bottomVisible,
247
+ rightVisible,
248
+ // Bottom and right of the viewport, not limited by data size
249
+ bottomViewport,
250
+ rightViewport,
251
+ // Canvas width/height
252
+ width,
253
+ height,
254
+ // Max x/y coordinate of the grid (does not include headers)
255
+ maxX,
256
+ maxY,
257
+ // Last valid column/row that can be the left/top of the grid
258
+ lastLeft,
259
+ lastTop,
260
+ // Scroll bar metrics
261
+ barHeight,
262
+ barWidth,
263
+ handleHeight,
264
+ handleWidth,
265
+ hasHorizontalBar,
266
+ hasVerticalBar,
267
+ verticalBarWidth,
268
+ horizontalBarHeight,
269
+ // The vertical x/y scroll amount
270
+ scrollX,
271
+ scrollY,
272
+ // Array of visible rows/columns, by grid index
273
+ visibleRows,
274
+ visibleColumns,
275
+ // Array of floating rows/columns, by grid index
276
+ floatingRows,
277
+ floatingColumns,
278
+ // Array of all rows/columns, visible and floating, by grid index
279
+ allRows,
280
+ allColumns,
281
+ // Map of the height/width of visible rows/columns
282
+ visibleRowHeights,
283
+ visibleColumnWidths,
284
+ // Floating metrics
285
+ floatingTopHeight,
286
+ floatingBottomHeight,
287
+ floatingLeftWidth,
288
+ floatingRightWidth,
289
+ // Map of the X/Y coordinates of the rows/columns, from the top left of the grid
290
+ visibleRowYs,
291
+ visibleColumnXs,
292
+ // The boxes user can click on for expanding/collapsing tree rows
293
+ visibleRowTreeBoxes,
294
+ // Mapping from visible row indexes to the model row/columns they pull from
295
+ modelRows,
296
+ modelColumns,
297
+ // Map of the width of the fonts
298
+ fontWidths,
299
+ // Map of user set column/row width/height
300
+ userColumnWidths,
301
+ userRowHeights,
302
+ // Map of calculated row/column height/width
303
+ calculatedRowHeights,
304
+ calculatedColumnWidths
305
+ };
306
+ }
337
307
 
338
- return 0;
339
- }
340
- /** Get the first column index that isn't hidden */
308
+ getGridX(state) {
309
+ var {
310
+ theme
311
+ } = state;
312
+ var {
313
+ rowHeaderWidth
314
+ } = theme;
315
+ return rowHeaderWidth;
316
+ }
341
317
 
342
- }, {
343
- key: "getFirstColumn",
344
- value: function getFirstColumn(state) {
345
- return this.getFirstIndex(this.userColumnWidths, this.getModelColumn.bind(this), state);
346
- }
347
- /** Get the first row index that isn't hidden */
318
+ getGridY(state) {
319
+ var {
320
+ theme
321
+ } = state;
322
+ var {
323
+ columnHeaderHeight
324
+ } = theme;
325
+ return columnHeaderHeight;
326
+ }
348
327
 
349
- }, {
350
- key: "getFirstRow",
351
- value: function getFirstRow(state) {
352
- return this.getFirstIndex(this.userRowHeights, this.getModelRow.bind(this), state);
353
- }
354
- /**
355
- * Get the last column that can be the left most column (eg. scrolled to the right)
356
- * If no right column is provided, then the last column is used.
357
- */
358
-
359
- }, {
360
- key: "getLastLeft",
361
- value: function getLastLeft(state) {
362
- var right = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
363
- var visibleWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.getVisibleWidth(state);
364
- var model = state.model;
365
- var columnCount = model.columnCount;
366
- var lastLeft = columnCount - 1;
367
-
368
- if (right != null) {
369
- lastLeft = right;
370
- }
328
+ getVisibleHeight(state) {
329
+ var visibleRowHeights = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingRowHeights(state);
330
+ var {
331
+ height,
332
+ theme
333
+ } = state;
334
+ var {
335
+ scrollBarSize
336
+ } = theme;
337
+ var gridY = this.getGridY(state);
338
+ var floatingBottomHeight = this.getFloatingBottomHeight(state, visibleRowHeights);
339
+ var floatingTopHeight = this.getFloatingTopHeight(state, visibleRowHeights);
340
+ return height - floatingBottomHeight - floatingTopHeight - gridY - scrollBarSize;
341
+ }
371
342
 
372
- var x = 0;
343
+ getVisibleWidth(state) {
344
+ var visibleColumnWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingColumnWidths(state);
345
+ var {
346
+ width,
347
+ theme
348
+ } = state;
349
+ var {
350
+ scrollBarSize,
351
+ rowFooterWidth
352
+ } = theme;
353
+ var gridX = this.getGridX(state);
354
+ var floatingRightWidth = this.getFloatingRightWidth(state, visibleColumnWidths);
355
+ var floatingLeftWidth = this.getFloatingLeftWidth(state, visibleColumnWidths);
356
+ return width - floatingLeftWidth - floatingRightWidth - gridX - scrollBarSize - rowFooterWidth;
357
+ }
373
358
 
374
- while (lastLeft >= 0) {
375
- var columnWidth = this.getVisibleColumnWidth(lastLeft, state);
376
- x += columnWidth;
359
+ getFirstIndex(itemSizes, getModelIndex, state) {
360
+ // We only need to check at the very most the number of items the user has hidden + 1
361
+ var max = itemSizes.size + 1;
377
362
 
378
- if (x >= visibleWidth) {
379
- return Math.min(lastLeft + 1, columnCount - 1);
380
- }
363
+ for (var i = 0; i < max; i += 1) {
364
+ var modelIndex = getModelIndex(i, state);
381
365
 
382
- lastLeft -= 1;
366
+ if (itemSizes.get(modelIndex) !== 0) {
367
+ return i;
383
368
  }
384
-
385
- return 0;
386
369
  }
387
- /**
388
- * The last row that can be the top row (eg. scrolled to the bottom)
389
- * If no bottom row is provided, then the last row that is not floating is used
390
- */
391
-
392
- }, {
393
- key: "getLastTop",
394
- value: function getLastTop(state) {
395
- var bottom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
396
- var visibleHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.getVisibleHeight(state);
397
- var model = state.model;
398
- var rowCount = model.rowCount,
399
- floatingBottomRowCount = model.floatingBottomRowCount;
400
- var lastTop = Math.max(0, rowCount - floatingBottomRowCount - 1);
401
-
402
- if (bottom != null) {
403
- lastTop = bottom;
404
- }
405
370
 
406
- var y = 0;
371
+ return 0;
372
+ }
373
+ /** Get the first column index that isn't hidden */
407
374
 
408
- while (lastTop > 0) {
409
- var rowHeight = this.getVisibleRowHeight(lastTop, state);
410
- y += rowHeight;
411
375
 
412
- if (y >= visibleHeight) {
413
- return Math.min(lastTop + 1, rowCount - 1);
414
- }
376
+ getFirstColumn(state) {
377
+ return this.getFirstIndex(this.userColumnWidths, this.getModelColumn.bind(this), state);
378
+ }
379
+ /** Get the first row index that isn't hidden */
415
380
 
416
- lastTop -= 1;
417
- }
418
381
 
419
- return 0;
382
+ getFirstRow(state) {
383
+ return this.getFirstIndex(this.userRowHeights, this.getModelRow.bind(this), state);
384
+ }
385
+ /**
386
+ * Get the last column that can be the left most column (eg. scrolled to the right)
387
+ * If no right column is provided, then the last column is used.
388
+ */
389
+
390
+
391
+ getLastLeft(state) {
392
+ var right = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
393
+ var visibleWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.getVisibleWidth(state);
394
+ var {
395
+ model
396
+ } = state;
397
+ var {
398
+ columnCount
399
+ } = model;
400
+ var lastLeft = columnCount - 1;
401
+
402
+ if (right != null) {
403
+ lastLeft = right;
420
404
  }
421
- }, {
422
- key: "getTopForTopVisible",
423
- value: function getTopForTopVisible(state, topVisible) {
424
- var floatingTopHeight = this.getFloatingTopHeight(state);
425
- var top = topVisible;
426
- var y = 0;
427
-
428
- while (top > 0 && y < floatingTopHeight) {
429
- top -= 1;
430
- y += this.getVisibleRowHeight(top, state);
431
- }
432
405
 
433
- return top;
434
- }
435
- }, {
436
- key: "getTopForBottomVisible",
437
- value: function getTopForBottomVisible(state, bottomVisible) {
438
- var height = state.height;
439
- var gridY = this.getGridY(state);
440
- var floatingBottomHeight = this.getFloatingBottomHeight(state);
441
- var availableHeight = height - gridY - floatingBottomHeight;
442
- return this.getLastTop(state, bottomVisible, availableHeight);
443
- }
444
- }, {
445
- key: "getLeftForLeftVisible",
446
- value: function getLeftForLeftVisible(state, leftVisible) {
447
- var floatingLeftWidth = this.getFloatingLeftWidth(state);
448
- var left = leftVisible;
449
- var x = 0;
450
-
451
- while (left > 0 && x < floatingLeftWidth) {
452
- left -= 1;
453
- x += this.getVisibleColumnWidth(left, state);
454
- }
406
+ var x = 0;
455
407
 
456
- return left;
457
- }
458
- }, {
459
- key: "getLeftForRightVisible",
460
- value: function getLeftForRightVisible(state, rightVisible) {
461
- var width = state.width;
462
- var gridX = this.getGridX(state);
463
- var floatingRightWidth = this.getFloatingRightWidth(state);
464
- var availableWidth = width - gridX - floatingRightWidth;
465
- return this.getLastLeft(state, rightVisible, availableWidth);
466
- }
467
- }, {
468
- key: "getFloatingRowHeights",
469
- value: function getFloatingRowHeights(state) {
470
- var model = state.model;
471
- var floatingTopRowCount = model.floatingTopRowCount,
472
- floatingBottomRowCount = model.floatingBottomRowCount,
473
- rowCount = model.rowCount;
474
- var rowHeights = new Map();
475
-
476
- for (var i = 0; i < floatingTopRowCount && i < rowCount; i += 1) {
477
- rowHeights.set(i, this.getVisibleRowHeight(i, state));
478
- }
408
+ while (lastLeft >= 0) {
409
+ var columnWidth = this.getVisibleColumnWidth(lastLeft, state);
410
+ x += columnWidth;
479
411
 
480
- for (var _i = 0; _i < floatingBottomRowCount && rowCount - _i - 1 >= 0; _i += 1) {
481
- var row = rowCount - _i - 1;
482
- rowHeights.set(row, this.getVisibleRowHeight(row, state));
412
+ if (x >= visibleWidth) {
413
+ return Math.min(lastLeft + 1, columnCount - 1);
483
414
  }
484
415
 
485
- return rowHeights;
416
+ lastLeft -= 1;
486
417
  }
487
- }, {
488
- key: "getVisibleRowHeights",
489
- value: function getVisibleRowHeights(state) {
490
- var top = state.top,
491
- topOffset = state.topOffset,
492
- height = state.height,
493
- model = state.model;
494
- var y = 0;
495
- var row = top;
496
- var rowHeights = new Map();
497
- var rowCount = model.rowCount;
498
-
499
- while (y < height + topOffset && row < rowCount) {
500
- var rowHeight = this.getVisibleRowHeight(row, state);
501
- rowHeights.set(row, rowHeight);
502
- y += rowHeight;
503
- row += 1;
504
- }
505
418
 
506
- return rowHeights;
419
+ return 0;
420
+ }
421
+ /**
422
+ * The last row that can be the top row (eg. scrolled to the bottom)
423
+ * If no bottom row is provided, then the last row that is not floating is used
424
+ */
425
+
426
+
427
+ getLastTop(state) {
428
+ var bottom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
429
+ var visibleHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.getVisibleHeight(state);
430
+ var {
431
+ model
432
+ } = state;
433
+ var {
434
+ rowCount,
435
+ floatingBottomRowCount
436
+ } = model;
437
+ var lastTop = Math.max(0, rowCount - floatingBottomRowCount - 1);
438
+
439
+ if (bottom != null) {
440
+ lastTop = bottom;
507
441
  }
508
- }, {
509
- key: "getFloatingColumnWidths",
510
- value: function getFloatingColumnWidths(state) {
511
- var firstColumn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFirstColumn(state);
512
- var treePaddingX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.calculateTreePaddingX(state);
513
- var model = state.model;
514
- var columnCount = model.columnCount,
515
- floatingLeftColumnCount = model.floatingLeftColumnCount,
516
- floatingRightColumnCount = model.floatingRightColumnCount;
517
- var columnWidths = new Map();
518
-
519
- for (var i = 0; i < floatingLeftColumnCount && i < columnCount; i += 1) {
520
- columnWidths.set(i, this.getVisibleColumnWidth(i, state, firstColumn, treePaddingX));
521
- }
522
442
 
523
- for (var _i2 = 0; _i2 < floatingRightColumnCount && columnCount - _i2 - 1 >= 0; _i2 += 1) {
524
- var column = columnCount - _i2 - 1;
525
- columnWidths.set(column, this.getVisibleColumnWidth(column, state, firstColumn, treePaddingX));
526
- }
443
+ var y = 0;
527
444
 
528
- return columnWidths;
529
- }
530
- }, {
531
- key: "getVisibleColumnWidths",
532
- value: function getVisibleColumnWidths(state) {
533
- var firstColumn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFirstColumn(state);
534
- var treePaddingX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.calculateTreePaddingX(state);
535
- var left = state.left,
536
- leftOffset = state.leftOffset,
537
- width = state.width,
538
- model = state.model;
539
- var x = 0;
540
- var column = left;
541
- var columnWidths = new Map();
542
- var columnCount = model.columnCount;
543
-
544
- while (x < width + leftOffset && column < columnCount) {
545
- var columnWidth = this.getVisibleColumnWidth(column, state, firstColumn, treePaddingX);
546
- columnWidths.set(column, columnWidth);
547
- x += columnWidth;
548
- column += 1;
445
+ while (lastTop > 0) {
446
+ var rowHeight = this.getVisibleRowHeight(lastTop, state);
447
+ y += rowHeight;
448
+
449
+ if (y >= visibleHeight) {
450
+ return Math.min(lastTop + 1, rowCount - 1);
549
451
  }
550
452
 
551
- return columnWidths;
552
- }
553
- }, {
554
- key: "getFloatingColumnXs",
555
- value: function getFloatingColumnXs(state, columnWidthMap, maxX) {
556
- var model = state.model;
557
- var columnCount = model.columnCount,
558
- floatingLeftColumnCount = model.floatingLeftColumnCount,
559
- floatingRightColumnCount = model.floatingRightColumnCount;
560
- return GridMetricCalculator.getFloatingCoordinates(floatingLeftColumnCount, floatingRightColumnCount, columnCount, maxX, columnWidthMap);
453
+ lastTop -= 1;
561
454
  }
562
- }, {
563
- key: "getVisibleColumnXs",
564
- value: function getVisibleColumnXs(visibleColumnWidths, visibleColumns, leftOffset) {
565
- var visibleColumnXs = new Map();
566
- var x = -leftOffset;
567
-
568
- for (var i = 0; i < visibleColumns.length; i += 1) {
569
- var column = visibleColumns[i];
570
- var columnWidth = visibleColumnWidths.get(column);
571
- visibleColumnXs.set(column, x);
572
- x += columnWidth;
573
- }
574
455
 
575
- return visibleColumnXs;
456
+ return 0;
457
+ }
458
+
459
+ getTopForTopVisible(state, topVisible) {
460
+ var floatingTopHeight = this.getFloatingTopHeight(state);
461
+ var top = topVisible;
462
+ var y = 0;
463
+
464
+ while (top > 0 && y < floatingTopHeight) {
465
+ top -= 1;
466
+ y += this.getVisibleRowHeight(top, state);
576
467
  }
577
- }, {
578
- key: "getFloatingRowYs",
579
- value: function getFloatingRowYs(state, rowHeightMap, maxY) {
580
- var model = state.model;
581
- var floatingTopRowCount = model.floatingTopRowCount,
582
- floatingBottomRowCount = model.floatingBottomRowCount,
583
- rowCount = model.rowCount;
584
- return GridMetricCalculator.getFloatingCoordinates(floatingTopRowCount, floatingBottomRowCount, rowCount, maxY, rowHeightMap);
468
+
469
+ return top;
470
+ }
471
+
472
+ getTopForBottomVisible(state, bottomVisible) {
473
+ var {
474
+ height
475
+ } = state;
476
+ var gridY = this.getGridY(state);
477
+ var floatingBottomHeight = this.getFloatingBottomHeight(state);
478
+ var availableHeight = height - gridY - floatingBottomHeight;
479
+ return this.getLastTop(state, bottomVisible, availableHeight);
480
+ }
481
+
482
+ getLeftForLeftVisible(state, leftVisible) {
483
+ var floatingLeftWidth = this.getFloatingLeftWidth(state);
484
+ var left = leftVisible;
485
+ var x = 0;
486
+
487
+ while (left > 0 && x < floatingLeftWidth) {
488
+ left -= 1;
489
+ x += this.getVisibleColumnWidth(left, state);
585
490
  }
586
- }, {
587
- key: "getVisibleRowYs",
588
- value: function getVisibleRowYs(visibleRowHeights, visibleRows, topOffset) {
589
- var visibleRowYs = new Map();
590
- var y = -topOffset;
591
-
592
- for (var i = 0; i < visibleRows.length; i += 1) {
593
- var row = visibleRows[i];
594
- var rowHeight = visibleRowHeights.get(row);
595
- visibleRowYs.set(row, y);
596
- y += rowHeight;
597
- }
598
491
 
599
- return visibleRowYs;
492
+ return left;
493
+ }
494
+
495
+ getLeftForRightVisible(state, rightVisible) {
496
+ var {
497
+ width
498
+ } = state;
499
+ var gridX = this.getGridX(state);
500
+ var floatingRightWidth = this.getFloatingRightWidth(state);
501
+ var availableWidth = width - gridX - floatingRightWidth;
502
+ return this.getLastLeft(state, rightVisible, availableWidth);
503
+ }
504
+
505
+ getFloatingRowHeights(state) {
506
+ var {
507
+ model
508
+ } = state;
509
+ var {
510
+ floatingTopRowCount,
511
+ floatingBottomRowCount,
512
+ rowCount
513
+ } = model;
514
+ var rowHeights = new Map();
515
+
516
+ for (var i = 0; i < floatingTopRowCount && i < rowCount; i += 1) {
517
+ rowHeights.set(i, this.getVisibleRowHeight(i, state));
600
518
  }
601
- /** Calculates the tree box click areas that are visible. In relation to the columnX/rowY */
602
-
603
- }, {
604
- key: "getVisibleRowTreeBoxes",
605
- value: function getVisibleRowTreeBoxes(visibleRowHeights, modelRows, state) {
606
- var visibleRowTreeBoxes = new Map();
607
- var model = state.model,
608
- theme = state.theme;
609
- var treeDepthIndent = theme.treeDepthIndent,
610
- treeHorizontalPadding = theme.treeHorizontalPadding;
611
-
612
- if (model.hasExpandableRows) {
613
- visibleRowHeights.forEach(function (rowHeight, row) {
614
- var modelRow = modelRows.get(row);
615
-
616
- if (model.isRowExpandable(modelRow)) {
617
- var depth = model.depthForRow(modelRow);
618
- var x1 = depth * treeDepthIndent + treeHorizontalPadding;
619
- var x2 = (depth + 1) * treeDepthIndent + treeHorizontalPadding;
620
- var y1 = 0;
621
- var y2 = rowHeight;
622
- visibleRowTreeBoxes.set(row, [x1, y1, x2, y2]);
623
- }
624
- });
625
- }
626
519
 
627
- return visibleRowTreeBoxes;
520
+ for (var _i2 = 0; _i2 < floatingBottomRowCount && rowCount - _i2 - 1 >= 0; _i2 += 1) {
521
+ var row = rowCount - _i2 - 1;
522
+ rowHeights.set(row, this.getVisibleRowHeight(row, state));
628
523
  }
629
- }, {
630
- key: "getFloatingLeftWidth",
631
- value: function getFloatingLeftWidth(state) {
632
- var columnWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingColumnWidths(state);
633
- var model = state.model;
634
- var floatingLeftColumnCount = model.floatingLeftColumnCount;
635
- var floatingWidth = 0;
636
-
637
- for (var i = 0; i < floatingLeftColumnCount; i += 1) {
638
- var _columnWidths$get;
639
-
640
- floatingWidth += (_columnWidths$get = columnWidths.get(i)) !== null && _columnWidths$get !== void 0 ? _columnWidths$get : 0;
641
- }
642
524
 
643
- return floatingWidth;
525
+ return rowHeights;
526
+ }
527
+
528
+ getVisibleRowHeights(state) {
529
+ var {
530
+ top,
531
+ topOffset,
532
+ height,
533
+ model
534
+ } = state;
535
+ var y = 0;
536
+ var row = top;
537
+ var rowHeights = new Map();
538
+ var {
539
+ rowCount
540
+ } = model;
541
+
542
+ while (y < height + topOffset && row < rowCount) {
543
+ var rowHeight = this.getVisibleRowHeight(row, state);
544
+ rowHeights.set(row, rowHeight);
545
+ y += rowHeight;
546
+ row += 1;
644
547
  }
645
- }, {
646
- key: "getFloatingRightWidth",
647
- value: function getFloatingRightWidth(state) {
648
- var columnWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingColumnWidths(state);
649
- var model = state.model;
650
- var floatingRightColumnCount = model.floatingRightColumnCount,
651
- columnCount = model.columnCount;
652
- var floatingWidth = 0;
653
-
654
- for (var i = 0; i < floatingRightColumnCount; i += 1) {
655
- var _columnWidths$get2;
656
-
657
- floatingWidth += (_columnWidths$get2 = columnWidths.get(columnCount - i - 1)) !== null && _columnWidths$get2 !== void 0 ? _columnWidths$get2 : 0;
658
- }
659
548
 
660
- return floatingWidth;
549
+ return rowHeights;
550
+ }
551
+
552
+ getFloatingColumnWidths(state) {
553
+ var firstColumn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFirstColumn(state);
554
+ var treePaddingX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.calculateTreePaddingX(state);
555
+ var {
556
+ model
557
+ } = state;
558
+ var {
559
+ columnCount,
560
+ floatingLeftColumnCount,
561
+ floatingRightColumnCount
562
+ } = model;
563
+ var columnWidths = new Map();
564
+
565
+ for (var i = 0; i < floatingLeftColumnCount && i < columnCount; i += 1) {
566
+ columnWidths.set(i, this.getVisibleColumnWidth(i, state, firstColumn, treePaddingX));
661
567
  }
662
- }, {
663
- key: "getFloatingTopHeight",
664
- value: function getFloatingTopHeight(state) {
665
- var rowHeights = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingRowHeights(state);
666
- var model = state.model;
667
- var floatingTopRowCount = model.floatingTopRowCount;
668
- var floatingHeight = 0;
669
-
670
- for (var i = 0; i < floatingTopRowCount; i += 1) {
671
- var _rowHeights$get;
672
-
673
- floatingHeight += (_rowHeights$get = rowHeights.get(i)) !== null && _rowHeights$get !== void 0 ? _rowHeights$get : 0;
674
- }
675
568
 
676
- return floatingHeight;
569
+ for (var _i3 = 0; _i3 < floatingRightColumnCount && columnCount - _i3 - 1 >= 0; _i3 += 1) {
570
+ var column = columnCount - _i3 - 1;
571
+ columnWidths.set(column, this.getVisibleColumnWidth(column, state, firstColumn, treePaddingX));
677
572
  }
678
- }, {
679
- key: "getFloatingBottomHeight",
680
- value: function getFloatingBottomHeight(state) {
681
- var rowHeights = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingRowHeights(state);
682
- var model = state.model;
683
- var floatingBottomRowCount = model.floatingBottomRowCount,
684
- rowCount = model.rowCount;
685
- var floatingHeight = 0;
686
-
687
- for (var i = 0; i < floatingBottomRowCount; i += 1) {
688
- var _rowHeights$get2;
689
-
690
- floatingHeight += (_rowHeights$get2 = rowHeights.get(rowCount - i - 1)) !== null && _rowHeights$get2 !== void 0 ? _rowHeights$get2 : 0;
691
- }
692
573
 
693
- return floatingHeight;
574
+ return columnWidths;
575
+ }
576
+
577
+ getVisibleColumnWidths(state) {
578
+ var firstColumn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFirstColumn(state);
579
+ var treePaddingX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.calculateTreePaddingX(state);
580
+ var {
581
+ left,
582
+ leftOffset,
583
+ width,
584
+ model
585
+ } = state;
586
+ var x = 0;
587
+ var column = left;
588
+ var columnWidths = new Map();
589
+ var {
590
+ columnCount
591
+ } = model;
592
+
593
+ while (x < width + leftOffset && column < columnCount) {
594
+ var columnWidth = this.getVisibleColumnWidth(column, state, firstColumn, treePaddingX);
595
+ columnWidths.set(column, columnWidth);
596
+ x += columnWidth;
597
+ column += 1;
694
598
  }
695
- }, {
696
- key: "getTopVisible",
697
- value: function getTopVisible(state, visibleRowYs, visibleRowHeights, visibleRows) {
698
- var floatingHeight = this.getFloatingTopHeight(state, visibleRowHeights);
699
599
 
700
- for (var i = 0; i < visibleRows.length; i += 1) {
701
- var row = visibleRows[i];
600
+ return columnWidths;
601
+ }
702
602
 
703
- if (visibleRowYs.get(row) >= floatingHeight) {
704
- return row;
705
- }
706
- }
603
+ getFloatingColumnXs(state, columnWidthMap, maxX) {
604
+ var {
605
+ model
606
+ } = state;
607
+ var {
608
+ columnCount,
609
+ floatingLeftColumnCount,
610
+ floatingRightColumnCount
611
+ } = model;
612
+ return GridMetricCalculator.getFloatingCoordinates(floatingLeftColumnCount, floatingRightColumnCount, columnCount, maxX, columnWidthMap);
613
+ }
614
+
615
+ getVisibleColumnXs(visibleColumnWidths, visibleColumns, leftOffset) {
616
+ var visibleColumnXs = new Map();
617
+ var x = -leftOffset;
707
618
 
708
- return 0;
619
+ for (var i = 0; i < visibleColumns.length; i += 1) {
620
+ var column = visibleColumns[i];
621
+ var columnWidth = visibleColumnWidths.get(column);
622
+ visibleColumnXs.set(column, x);
623
+ x += columnWidth;
709
624
  }
710
- }, {
711
- key: "getLeftVisible",
712
- value: function getLeftVisible(state, visibleColumnXs, visibleColumnWidths, visibleColumns) {
713
- var floatingWidth = this.getFloatingLeftWidth(state, visibleColumnWidths);
714
625
 
715
- for (var i = 0; i < visibleColumns.length; i += 1) {
716
- var column = visibleColumns[i];
626
+ return visibleColumnXs;
627
+ }
717
628
 
718
- if (visibleColumnXs.get(column) >= floatingWidth) {
719
- return column;
720
- }
721
- }
629
+ getFloatingRowYs(state, rowHeightMap, maxY) {
630
+ var {
631
+ model
632
+ } = state;
633
+ var {
634
+ floatingTopRowCount,
635
+ floatingBottomRowCount,
636
+ rowCount
637
+ } = model;
638
+ return GridMetricCalculator.getFloatingCoordinates(floatingTopRowCount, floatingBottomRowCount, rowCount, maxY, rowHeightMap);
639
+ }
640
+
641
+ getVisibleRowYs(visibleRowHeights, visibleRows, topOffset) {
642
+ var visibleRowYs = new Map();
643
+ var y = -topOffset;
722
644
 
723
- return 0;
645
+ for (var i = 0; i < visibleRows.length; i += 1) {
646
+ var row = visibleRows[i];
647
+ var rowHeight = visibleRowHeights.get(row);
648
+ visibleRowYs.set(row, y);
649
+ y += rowHeight;
724
650
  }
725
- }, {
726
- key: "getBottomVisible",
727
- value: function getBottomVisible(state, visibleRowYs, visibleRowHeights, visibleRows, gridY) {
728
- var height = state.height,
729
- theme = state.theme;
730
- var scrollBarSize = theme.scrollBarSize;
731
- var floatingHeight = this.getFloatingBottomHeight(state, visibleRowHeights);
732
- var visibleHeight = height - gridY - scrollBarSize - floatingHeight;
733
-
734
- for (var i = visibleRows.length - 1; i >= 0; i -= 1) {
735
- var row = visibleRows[i];
736
- var rowY = visibleRowYs.get(row);
737
- var rowHeight = visibleRowHeights.get(row);
738
-
739
- if (rowY + rowHeight <= visibleHeight) {
740
- return row;
651
+
652
+ return visibleRowYs;
653
+ }
654
+ /** Calculates the tree box click areas that are visible. In relation to the columnX/rowY */
655
+
656
+
657
+ getVisibleRowTreeBoxes(visibleRowHeights, modelRows, state) {
658
+ var visibleRowTreeBoxes = new Map();
659
+ var {
660
+ model,
661
+ theme
662
+ } = state;
663
+ var {
664
+ treeDepthIndent,
665
+ treeHorizontalPadding
666
+ } = theme;
667
+
668
+ if (model.hasExpandableRows) {
669
+ visibleRowHeights.forEach((rowHeight, row) => {
670
+ var modelRow = modelRows.get(row);
671
+
672
+ if (model.isRowExpandable(modelRow)) {
673
+ var depth = model.depthForRow(modelRow);
674
+ var x1 = depth * treeDepthIndent + treeHorizontalPadding;
675
+ var x2 = (depth + 1) * treeDepthIndent + treeHorizontalPadding;
676
+ var y1 = 0;
677
+ var y2 = rowHeight;
678
+ visibleRowTreeBoxes.set(row, [x1, y1, x2, y2]);
741
679
  }
742
- }
680
+ });
681
+ }
682
+
683
+ return visibleRowTreeBoxes;
684
+ }
685
+
686
+ getFloatingLeftWidth(state) {
687
+ var columnWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingColumnWidths(state);
688
+ var {
689
+ model
690
+ } = state;
691
+ var {
692
+ floatingLeftColumnCount
693
+ } = model;
694
+ var floatingWidth = 0;
743
695
 
744
- return 0;
696
+ for (var i = 0; i < floatingLeftColumnCount; i += 1) {
697
+ var _columnWidths$get;
698
+
699
+ floatingWidth += (_columnWidths$get = columnWidths.get(i)) !== null && _columnWidths$get !== void 0 ? _columnWidths$get : 0;
745
700
  }
746
- }, {
747
- key: "getRightVisible",
748
- value: function getRightVisible(state, visibleColumnXs, visibleColumnWidths, visibleColumns, gridX) {
749
- var width = state.width,
750
- theme = state.theme;
751
- var scrollBarSize = theme.scrollBarSize;
752
- var floatingWidth = this.getFloatingRightWidth(state, visibleColumnWidths);
753
- var visibleWidth = width - gridX - scrollBarSize - floatingWidth;
754
-
755
- for (var i = visibleColumns.length - 1; i >= 0; i -= 1) {
756
- var column = visibleColumns[i];
757
- var columnX = visibleColumnXs.get(column);
758
- var columnWidth = visibleColumnWidths.get(column);
759
-
760
- if (columnX + columnWidth <= visibleWidth) {
761
- return column;
762
- }
763
- }
764
701
 
765
- return 0;
702
+ return floatingWidth;
703
+ }
704
+
705
+ getFloatingRightWidth(state) {
706
+ var columnWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingColumnWidths(state);
707
+ var {
708
+ model
709
+ } = state;
710
+ var {
711
+ floatingRightColumnCount,
712
+ columnCount
713
+ } = model;
714
+ var floatingWidth = 0;
715
+
716
+ for (var i = 0; i < floatingRightColumnCount; i += 1) {
717
+ var _columnWidths$get2;
718
+
719
+ floatingWidth += (_columnWidths$get2 = columnWidths.get(columnCount - i - 1)) !== null && _columnWidths$get2 !== void 0 ? _columnWidths$get2 : 0;
766
720
  }
767
- }, {
768
- key: "getBottomViewport",
769
- value: function getBottomViewport(state, visibleRows, visibleRowYs, visibleRowHeights) {
770
- var height = state.height,
771
- theme = state.theme;
772
- var rowHeight = theme.rowHeight;
773
- return this.getLastIndexViewport(visibleRows, visibleRowYs, visibleRowHeights, height, rowHeight);
721
+
722
+ return floatingWidth;
723
+ }
724
+
725
+ getFloatingTopHeight(state) {
726
+ var rowHeights = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingRowHeights(state);
727
+ var {
728
+ model
729
+ } = state;
730
+ var {
731
+ floatingTopRowCount
732
+ } = model;
733
+ var floatingHeight = 0;
734
+
735
+ for (var i = 0; i < floatingTopRowCount; i += 1) {
736
+ var _rowHeights$get;
737
+
738
+ floatingHeight += (_rowHeights$get = rowHeights.get(i)) !== null && _rowHeights$get !== void 0 ? _rowHeights$get : 0;
774
739
  }
775
- }, {
776
- key: "getRightViewport",
777
- value: function getRightViewport(state, visibleColumns, visibleColumnXs, visibleColumnWidths) {
778
- var width = state.width,
779
- theme = state.theme;
780
- var columnWidth = theme.columnWidth;
781
- return this.getLastIndexViewport(visibleColumns, visibleColumnXs, visibleColumnWidths, width, columnWidth);
740
+
741
+ return floatingHeight;
742
+ }
743
+
744
+ getFloatingBottomHeight(state) {
745
+ var rowHeights = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getFloatingRowHeights(state);
746
+ var {
747
+ model
748
+ } = state;
749
+ var {
750
+ floatingBottomRowCount,
751
+ rowCount
752
+ } = model;
753
+ var floatingHeight = 0;
754
+
755
+ for (var i = 0; i < floatingBottomRowCount; i += 1) {
756
+ var _rowHeights$get2;
757
+
758
+ floatingHeight += (_rowHeights$get2 = rowHeights.get(rowCount - i - 1)) !== null && _rowHeights$get2 !== void 0 ? _rowHeights$get2 : 0;
782
759
  }
783
- }, {
784
- key: "getLastIndexViewport",
785
- value: function getLastIndexViewport(items, itemXs, itemSizes, maxSize, defaultItemSize) {
786
- var lastIndex = 0;
787
- var dataSize = 0;
788
-
789
- if (items.length > 0) {
790
- lastIndex = items[items.length - 1];
791
- dataSize = itemXs.get(lastIndex) + itemSizes.get(lastIndex);
792
- }
793
760
 
794
- if (dataSize < maxSize) {
795
- lastIndex += Math.ceil((maxSize - dataSize) / defaultItemSize);
761
+ return floatingHeight;
762
+ }
763
+
764
+ getTopVisible(state, visibleRowYs, visibleRowHeights, visibleRows) {
765
+ var floatingHeight = this.getFloatingTopHeight(state, visibleRowHeights);
766
+
767
+ for (var i = 0; i < visibleRows.length; i += 1) {
768
+ var row = visibleRows[i];
769
+
770
+ if (visibleRowYs.get(row) >= floatingHeight) {
771
+ return row;
796
772
  }
773
+ }
797
774
 
798
- return lastIndex;
775
+ return 0;
776
+ }
777
+
778
+ getLeftVisible(state, visibleColumnXs, visibleColumnWidths, visibleColumns) {
779
+ var floatingWidth = this.getFloatingLeftWidth(state, visibleColumnWidths);
780
+
781
+ for (var i = 0; i < visibleColumns.length; i += 1) {
782
+ var column = visibleColumns[i];
783
+
784
+ if (visibleColumnXs.get(column) >= floatingWidth) {
785
+ return column;
786
+ }
799
787
  }
800
- }, {
801
- key: "getVisibleItemSize",
802
- value: function getVisibleItemSize(modelIndex, userSizes, calculateSize) {
803
- if (userSizes.has(modelIndex)) {
804
- return userSizes.get(modelIndex);
788
+
789
+ return 0;
790
+ }
791
+
792
+ getBottomVisible(state, visibleRowYs, visibleRowHeights, visibleRows, gridY) {
793
+ var {
794
+ height,
795
+ theme
796
+ } = state;
797
+ var {
798
+ scrollBarSize
799
+ } = theme;
800
+ var floatingHeight = this.getFloatingBottomHeight(state, visibleRowHeights);
801
+ var visibleHeight = height - gridY - scrollBarSize - floatingHeight;
802
+
803
+ for (var i = visibleRows.length - 1; i >= 0; i -= 1) {
804
+ var row = visibleRows[i];
805
+ var rowY = visibleRowYs.get(row);
806
+ var rowHeight = visibleRowHeights.get(row);
807
+
808
+ if (rowY + rowHeight <= visibleHeight) {
809
+ return row;
805
810
  }
811
+ }
812
+
813
+ return 0;
814
+ }
806
815
 
807
- return calculateSize();
816
+ getRightVisible(state, visibleColumnXs, visibleColumnWidths, visibleColumns, gridX) {
817
+ var {
818
+ width,
819
+ theme
820
+ } = state;
821
+ var {
822
+ scrollBarSize
823
+ } = theme;
824
+ var floatingWidth = this.getFloatingRightWidth(state, visibleColumnWidths);
825
+ var visibleWidth = width - gridX - scrollBarSize - floatingWidth;
826
+
827
+ for (var i = visibleColumns.length - 1; i >= 0; i -= 1) {
828
+ var column = visibleColumns[i];
829
+ var columnX = visibleColumnXs.get(column);
830
+ var columnWidth = visibleColumnWidths.get(column);
831
+
832
+ if (columnX + columnWidth <= visibleWidth) {
833
+ return column;
834
+ }
808
835
  }
809
- }, {
810
- key: "getVisibleRowHeight",
811
- value: function getVisibleRowHeight(row, state) {
812
- var _this = this;
813
836
 
814
- var modelRow = this.getModelRow(row, state);
815
- return this.getVisibleItemSize(modelRow, this.userRowHeights, function () {
816
- return _this.calculateRowHeight(row, modelRow, state);
817
- });
837
+ return 0;
838
+ }
839
+
840
+ getBottomViewport(state, visibleRows, visibleRowYs, visibleRowHeights) {
841
+ var {
842
+ height,
843
+ theme
844
+ } = state;
845
+ var {
846
+ rowHeight
847
+ } = theme;
848
+ return this.getLastIndexViewport(visibleRows, visibleRowYs, visibleRowHeights, height, rowHeight);
849
+ }
850
+
851
+ getRightViewport(state, visibleColumns, visibleColumnXs, visibleColumnWidths) {
852
+ var {
853
+ width,
854
+ theme
855
+ } = state;
856
+ var {
857
+ columnWidth
858
+ } = theme;
859
+ return this.getLastIndexViewport(visibleColumns, visibleColumnXs, visibleColumnWidths, width, columnWidth);
860
+ }
861
+
862
+ getLastIndexViewport(items, itemXs, itemSizes, maxSize, defaultItemSize) {
863
+ var lastIndex = 0;
864
+ var dataSize = 0;
865
+
866
+ if (items.length > 0) {
867
+ lastIndex = items[items.length - 1];
868
+ dataSize = itemXs.get(lastIndex) + itemSizes.get(lastIndex);
818
869
  }
819
- }, {
820
- key: "getVisibleColumnWidth",
821
- value: function getVisibleColumnWidth(column, state) {
822
- var _this2 = this;
823
-
824
- var firstColumn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.getFirstColumn(state);
825
- var treePaddingX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : this.calculateTreePaddingX(state);
826
- var modelColumn = this.getModelColumn(column, state);
827
- return this.getVisibleItemSize(modelColumn, this.userColumnWidths, function () {
828
- return _this2.calculateColumnWidth(column, modelColumn, state, firstColumn, treePaddingX);
829
- });
870
+
871
+ if (dataSize < maxSize) {
872
+ lastIndex += Math.ceil((maxSize - dataSize) / defaultItemSize);
830
873
  }
831
- }, {
832
- key: "getModelRows",
833
- value: function getModelRows(visibleRows, state) {
834
- var modelRows = new Map();
835
-
836
- for (var i = 0; i < visibleRows.length; i += 1) {
837
- var visibleRow = visibleRows[i];
838
- var modelRow = this.getModelRow(visibleRow, state);
839
- modelRows.set(visibleRow, modelRow);
840
- }
841
874
 
842
- return modelRows;
875
+ return lastIndex;
876
+ }
877
+
878
+ getVisibleItemSize(modelIndex, userSizes, calculateSize) {
879
+ if (userSizes.has(modelIndex)) {
880
+ return userSizes.get(modelIndex);
843
881
  }
844
- }, {
845
- key: "getModelRow",
846
- value: function getModelRow(visibleRow, state) {
847
- if (this.modelRows.has(visibleRow)) {
848
- return this.modelRows.get(visibleRow);
849
- }
850
882
 
851
- var movedRows = state.movedRows;
852
- var modelRow = GridUtils.getModelIndex(visibleRow, movedRows);
853
- this.modelRows.set(visibleRow, modelRow);
854
- return modelRow;
883
+ return calculateSize();
884
+ }
885
+
886
+ getVisibleRowHeight(row, state) {
887
+ var modelRow = this.getModelRow(row, state);
888
+ return this.getVisibleItemSize(modelRow, this.userRowHeights, () => this.calculateRowHeight(row, modelRow, state));
889
+ }
890
+
891
+ getVisibleColumnWidth(column, state) {
892
+ var firstColumn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.getFirstColumn(state);
893
+ var treePaddingX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : this.calculateTreePaddingX(state);
894
+ var modelColumn = this.getModelColumn(column, state);
895
+ return this.getVisibleItemSize(modelColumn, this.userColumnWidths, () => this.calculateColumnWidth(column, modelColumn, state, firstColumn, treePaddingX));
896
+ }
897
+
898
+ getModelRows(visibleRows, state) {
899
+ var modelRows = new Map();
900
+
901
+ for (var i = 0; i < visibleRows.length; i += 1) {
902
+ var visibleRow = visibleRows[i];
903
+ var modelRow = this.getModelRow(visibleRow, state);
904
+ modelRows.set(visibleRow, modelRow);
855
905
  }
856
- }, {
857
- key: "getModelColumns",
858
- value: function getModelColumns(visibleColumns, state) {
859
- var modelColumns = new Map();
860
-
861
- for (var i = 0; i < visibleColumns.length; i += 1) {
862
- var visibleColumn = visibleColumns[i];
863
- var modelColumn = this.getModelColumn(visibleColumn, state);
864
- modelColumns.set(visibleColumn, modelColumn);
865
- }
866
906
 
867
- return modelColumns;
907
+ return modelRows;
908
+ }
909
+
910
+ getModelRow(visibleRow, state) {
911
+ if (this.modelRows.has(visibleRow)) {
912
+ return this.modelRows.get(visibleRow);
868
913
  }
869
- }, {
870
- key: "getModelColumn",
871
- value: function getModelColumn(visibleColumn, state) {
872
- if (this.modelColumns.has(visibleColumn)) {
873
- return this.modelColumns.get(visibleColumn);
874
- }
875
914
 
876
- var movedColumns = state.movedColumns;
877
- var modelColumn = GridUtils.getModelIndex(visibleColumn, movedColumns);
878
- this.modelColumns.set(visibleColumn, modelColumn);
879
- return modelColumn;
915
+ var {
916
+ movedRows
917
+ } = state;
918
+ var modelRow = GridUtils.getModelIndex(visibleRow, movedRows);
919
+ this.modelRows.set(visibleRow, modelRow);
920
+ return modelRow;
921
+ }
922
+
923
+ getModelColumns(visibleColumns, state) {
924
+ var modelColumns = new Map();
925
+
926
+ for (var i = 0; i < visibleColumns.length; i += 1) {
927
+ var visibleColumn = visibleColumns[i];
928
+ var modelColumn = this.getModelColumn(visibleColumn, state);
929
+ modelColumns.set(visibleColumn, modelColumn);
880
930
  }
881
- }, {
882
- key: "calculateRowHeight",
883
- value: function calculateRowHeight(row, modelRow, state) {
884
- var theme = state.theme;
885
- var autoSizeRows = theme.autoSizeRows,
886
- rowHeight = theme.rowHeight;
887
-
888
- if (!autoSizeRows) {
889
- return rowHeight;
890
- }
891
931
 
892
- var cachedValue = this.calculatedRowHeights.get(modelRow);
932
+ return modelColumns;
933
+ }
893
934
 
894
- if (cachedValue != null) {
895
- return cachedValue;
896
- } // Not sure how to accurately get the height of text. For now just return the theme height.
935
+ getModelColumn(visibleColumn, state) {
936
+ if (this.modelColumns.has(visibleColumn)) {
937
+ return this.modelColumns.get(visibleColumn);
938
+ }
897
939
 
940
+ var {
941
+ movedColumns
942
+ } = state;
943
+ var modelColumn = GridUtils.getModelIndex(visibleColumn, movedColumns);
944
+ this.modelColumns.set(visibleColumn, modelColumn);
945
+ return modelColumn;
946
+ }
898
947
 
899
- this.calculatedRowHeights.set(modelRow, Math.ceil(rowHeight));
900
- GridMetricCalculator.trimMap(this.calculatedRowHeights);
948
+ calculateRowHeight(row, modelRow, state) {
949
+ var {
950
+ theme
951
+ } = state;
952
+ var {
953
+ autoSizeRows,
954
+ rowHeight
955
+ } = theme;
956
+
957
+ if (!autoSizeRows) {
901
958
  return rowHeight;
902
959
  }
903
- /** Calculates the column width based on the provided column model index */
904
-
905
- }, {
906
- key: "calculateColumnWidth",
907
- value: function calculateColumnWidth(column, modelColumn, state) {
908
- var firstColumn = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : this.getFirstColumn(state);
909
- var treePaddingX = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.calculateTreePaddingX(state);
910
- var theme = state.theme;
911
- var autoSizeColumns = theme.autoSizeColumns,
912
- minColumnWidth = theme.minColumnWidth;
913
-
914
- if (!autoSizeColumns) {
915
- var _columnWidth = theme.columnWidth;
916
- return _columnWidth;
917
- }
918
960
 
919
- var headerWidth = this.calculateColumnHeaderWidth(modelColumn, state);
920
- var dataWidth = this.calculateColumnDataWidth(modelColumn, state);
921
- var cachedValue = this.calculatedColumnWidths.get(modelColumn);
922
- var columnWidth = Math.ceil(Math.max(headerWidth, dataWidth));
923
- columnWidth = Math.max(minColumnWidth, columnWidth);
924
-
925
- if (cachedValue != null && cachedValue > columnWidth) {
926
- columnWidth = cachedValue;
927
- } else {
928
- this.calculatedColumnWidths.set(modelColumn, columnWidth);
929
- GridMetricCalculator.trimMap(this.calculatedColumnWidths);
930
- }
961
+ var cachedValue = this.calculatedRowHeights.get(modelRow);
962
+
963
+ if (cachedValue != null) {
964
+ return cachedValue;
965
+ } // Not sure how to accurately get the height of text. For now just return the theme height.
931
966
 
932
- if (column === firstColumn) {
933
- columnWidth += treePaddingX;
934
- }
935
967
 
936
- return columnWidth;
968
+ this.calculatedRowHeights.set(modelRow, Math.ceil(rowHeight));
969
+ GridMetricCalculator.trimMap(this.calculatedRowHeights);
970
+ return rowHeight;
971
+ }
972
+ /** Calculates the column width based on the provided column model index */
973
+
974
+
975
+ calculateColumnWidth(column, modelColumn, state) {
976
+ var firstColumn = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : this.getFirstColumn(state);
977
+ var treePaddingX = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.calculateTreePaddingX(state);
978
+ var {
979
+ theme
980
+ } = state;
981
+ var {
982
+ autoSizeColumns,
983
+ minColumnWidth
984
+ } = theme;
985
+
986
+ if (!autoSizeColumns) {
987
+ var {
988
+ columnWidth: _columnWidth
989
+ } = theme;
990
+ return _columnWidth;
937
991
  }
938
- }, {
939
- key: "calculateColumnHeaderWidth",
940
- value: function calculateColumnHeaderWidth(modelColumn, state) {
941
- var model = state.model,
942
- theme = state.theme;
943
- var headerFont = theme.headerFont,
944
- headerHorizontalPadding = theme.headerHorizontalPadding;
945
- var headerText = model.textForColumnHeader(modelColumn);
946
-
947
- if (headerText) {
948
- var headerFontWidth = this.getWidthForFont(headerFont, state);
949
- return headerText.length * headerFontWidth + headerHorizontalPadding * 2;
950
- }
951
992
 
952
- return headerHorizontalPadding * 2;
993
+ var headerWidth = this.calculateColumnHeaderWidth(modelColumn, state);
994
+ var dataWidth = this.calculateColumnDataWidth(modelColumn, state);
995
+ var cachedValue = this.calculatedColumnWidths.get(modelColumn);
996
+ var columnWidth = Math.ceil(Math.max(headerWidth, dataWidth));
997
+ columnWidth = Math.max(minColumnWidth, columnWidth);
998
+
999
+ if (cachedValue != null && cachedValue > columnWidth) {
1000
+ columnWidth = cachedValue;
1001
+ } else {
1002
+ this.calculatedColumnWidths.set(modelColumn, columnWidth);
1003
+ GridMetricCalculator.trimMap(this.calculatedColumnWidths);
953
1004
  }
954
- }, {
955
- key: "calculateColumnDataWidth",
956
- value: function calculateColumnDataWidth(modelColumn, state) {
957
- var _this3 = this;
958
-
959
- var top = state.top,
960
- height = state.height,
961
- width = state.width,
962
- model = state.model,
963
- theme = state.theme;
964
- var floatingTopRowCount = model.floatingTopRowCount,
965
- floatingBottomRowCount = model.floatingBottomRowCount,
966
- rowCount = model.rowCount;
967
- var font = theme.font,
968
- cellHorizontalPadding = theme.cellHorizontalPadding,
969
- rowHeight = theme.rowHeight,
970
- rowHeaderWidth = theme.rowHeaderWidth,
971
- rowFooterWidth = theme.rowFooterWidth,
972
- scrollBarSize = theme.scrollBarSize;
973
- var columnWidth = 0;
974
- var fontWidth = this.getWidthForFont(font, state);
975
- var rowsPerPage = height / rowHeight;
976
- var bottom = Math.ceil(top + rowsPerPage);
977
- GridUtils.iterateAllItems(top, bottom, floatingTopRowCount, floatingBottomRowCount, rowCount, function (row) {
978
- var modelRow = _this3.getModelRow(row, state);
979
-
980
- var text = model.textForCell(modelColumn, modelRow);
981
-
982
- if (text) {
983
- var cellPadding = cellHorizontalPadding * 2;
984
- columnWidth = Math.max(columnWidth, text.length * fontWidth + cellPadding);
985
- }
986
- });
987
- columnWidth = Math.max(Math.min(columnWidth, (width - rowHeaderWidth - scrollBarSize - rowFooterWidth) * GridMetricCalculator.MAX_COLUMN_WIDTH), cellHorizontalPadding * 2);
988
- return columnWidth;
1005
+
1006
+ if (column === firstColumn) {
1007
+ columnWidth += treePaddingX;
989
1008
  }
990
- }, {
991
- key: "calculateTreePaddingX",
992
- value: function calculateTreePaddingX(state) {
993
- var top = state.top,
994
- height = state.height,
995
- model = state.model,
996
- theme = state.theme;
997
- var rowHeight = theme.rowHeight,
998
- treeDepthIndent = theme.treeDepthIndent;
999
- var treePadding = 0;
1000
- var rowsPerPage = height / rowHeight;
1001
- var bottom = Math.ceil(top + rowsPerPage);
1002
-
1003
- for (var row = top; row <= bottom; row += 1) {
1004
- var modelRow = this.getModelRow(row, state);
1005
- var depth = model.depthForRow(modelRow);
1006
- treePadding = Math.max(treePadding, treeDepthIndent * (depth + 1));
1007
- }
1008
1009
 
1009
- return treePadding;
1010
+ return columnWidth;
1011
+ }
1012
+
1013
+ calculateColumnHeaderWidth(modelColumn, state) {
1014
+ var {
1015
+ model,
1016
+ theme
1017
+ } = state;
1018
+ var {
1019
+ headerFont,
1020
+ headerHorizontalPadding
1021
+ } = theme;
1022
+ var headerText = model.textForColumnHeader(modelColumn);
1023
+
1024
+ if (headerText) {
1025
+ var headerFontWidth = this.getWidthForFont(headerFont, state);
1026
+ return headerText.length * headerFontWidth + headerHorizontalPadding * 2;
1010
1027
  }
1011
- /** Get the width of the provided font. Exploits the fact that we're using tabular figures so every character is same width */
1012
1028
 
1013
- }, {
1014
- key: "getWidthForFont",
1015
- value: function getWidthForFont(font, state) {
1016
- if (this.fontWidths.has(font)) {
1017
- return this.fontWidths.get(font);
1018
- }
1029
+ return headerHorizontalPadding * 2;
1030
+ }
1019
1031
 
1020
- var context = state.context;
1021
- context.font = font;
1022
- var textMetrics = context.measureText('8');
1023
- var width = textMetrics.width; // context.font changes the string a little bit, eg. '10px Arial, sans serif' => '10px Arial, "sans serif"'
1024
- // Rather than require checking with the correct font def (theme, or context font), just key it to both
1032
+ calculateColumnDataWidth(modelColumn, state) {
1033
+ var {
1034
+ top,
1035
+ height,
1036
+ width,
1037
+ model,
1038
+ theme
1039
+ } = state;
1040
+ var {
1041
+ floatingTopRowCount,
1042
+ floatingBottomRowCount,
1043
+ rowCount
1044
+ } = model;
1045
+ var {
1046
+ font,
1047
+ cellHorizontalPadding,
1048
+ rowHeight,
1049
+ rowHeaderWidth,
1050
+ rowFooterWidth,
1051
+ scrollBarSize
1052
+ } = theme;
1053
+ var columnWidth = 0;
1054
+ var fontWidth = this.getWidthForFont(font, state);
1055
+ var rowsPerPage = height / rowHeight;
1056
+ var bottom = Math.ceil(top + rowsPerPage);
1057
+ GridUtils.iterateAllItems(top, bottom, floatingTopRowCount, floatingBottomRowCount, rowCount, row => {
1058
+ var modelRow = this.getModelRow(row, state);
1059
+ var text = model.textForCell(modelColumn, modelRow);
1025
1060
 
1026
- this.fontWidths.set(font, width);
1027
- this.fontWidths.set(context.font, width);
1028
- return width;
1029
- }
1030
- /**
1031
- * Sets the width for the specified column
1032
- * @param {Number} column The column model index to set
1033
- * @param {Number} size The size to set it to, or null to reset the column size
1034
- */
1035
-
1036
- }, {
1037
- key: "setColumnWidth",
1038
- value: function setColumnWidth(column, size) {
1039
- var userColumnWidths = new Map(this.userColumnWidths);
1040
-
1041
- if (size != null) {
1042
- userColumnWidths.set(column, Math.ceil(size));
1043
- GridMetricCalculator.trimMap(userColumnWidths);
1044
- } else {
1045
- userColumnWidths["delete"](column);
1061
+ if (text) {
1062
+ var cellPadding = cellHorizontalPadding * 2;
1063
+ columnWidth = Math.max(columnWidth, text.length * fontWidth + cellPadding);
1046
1064
  }
1065
+ });
1066
+ columnWidth = Math.max(Math.min(columnWidth, (width - rowHeaderWidth - scrollBarSize - rowFooterWidth) * GridMetricCalculator.MAX_COLUMN_WIDTH), cellHorizontalPadding * 2);
1067
+ return columnWidth;
1068
+ }
1047
1069
 
1048
- this.userColumnWidths = userColumnWidths;
1049
- }
1050
- /**
1051
- * Resets the column width for the specified column to the calculated width
1052
- * @param {Number} column The column model index to reset
1053
- */
1054
-
1055
- }, {
1056
- key: "resetColumnWidth",
1057
- value: function resetColumnWidth(column) {
1058
- this.setColumnWidth(column, null);
1059
- this.calculatedColumnWidths["delete"](column);
1070
+ calculateTreePaddingX(state) {
1071
+ var {
1072
+ top,
1073
+ height,
1074
+ model,
1075
+ theme
1076
+ } = state;
1077
+ var {
1078
+ rowHeight,
1079
+ treeDepthIndent
1080
+ } = theme;
1081
+ var treePadding = 0;
1082
+ var rowsPerPage = height / rowHeight;
1083
+ var bottom = Math.ceil(top + rowsPerPage);
1084
+
1085
+ for (var row = top; row <= bottom; row += 1) {
1086
+ var modelRow = this.getModelRow(row, state);
1087
+ var depth = model.depthForRow(modelRow);
1088
+ treePadding = Math.max(treePadding, treeDepthIndent * (depth + 1));
1060
1089
  }
1061
- /**
1062
- * Sets the width for the specified row
1063
- * @param {Number} row The row model index to set
1064
- * @param {Number} size The size to set it to, or null to reset the row size
1065
- */
1066
-
1067
- }, {
1068
- key: "setRowHeight",
1069
- value: function setRowHeight(row, size) {
1070
- var userRowHeights = new Map(this.userRowHeights);
1071
-
1072
- if (size != null) {
1073
- userRowHeights.set(row, Math.ceil(size));
1074
- GridMetricCalculator.trimMap(userRowHeights);
1075
- } else {
1076
- userRowHeights["delete"](row);
1077
- }
1078
1090
 
1079
- this.userRowHeights = userRowHeights;
1080
- }
1081
- }, {
1082
- key: "resetRowHeight",
1083
- value: function resetRowHeight(row) {
1084
- this.setRowHeight(row, null);
1085
- this.calculatedRowHeights["delete"](row);
1091
+ return treePadding;
1092
+ }
1093
+ /** Get the width of the provided font. Exploits the fact that we're using tabular figures so every character is same width */
1094
+
1095
+
1096
+ getWidthForFont(font, state) {
1097
+ if (this.fontWidths.has(font)) {
1098
+ return this.fontWidths.get(font);
1086
1099
  }
1087
- }], [{
1088
- key: "trimMap",
1089
- value:
1090
- /** The size of the caches this calculator stores */
1091
-
1092
- /** The maximum column width as a percentage of the full grid */
1093
- function trimMap(map) {
1094
- if (map.size > GridMetricCalculator.CACHE_SIZE) {
1095
- var keys = map.keys();
1096
- map["delete"](keys[0]);
1097
- }
1100
+
1101
+ var {
1102
+ context
1103
+ } = state;
1104
+ context.font = font;
1105
+ var textMetrics = context.measureText('8');
1106
+ var {
1107
+ width
1108
+ } = textMetrics; // context.font changes the string a little bit, eg. '10px Arial, sans serif' => '10px Arial, "sans serif"'
1109
+ // Rather than require checking with the correct font def (theme, or context font), just key it to both
1110
+
1111
+ this.fontWidths.set(font, width);
1112
+ this.fontWidths.set(context.font, width);
1113
+ return width;
1114
+ }
1115
+ /**
1116
+ * Sets the width for the specified column
1117
+ * @param {Number} column The column model index to set
1118
+ * @param {Number} size The size to set it to, or null to reset the column size
1119
+ */
1120
+
1121
+
1122
+ setColumnWidth(column, size) {
1123
+ var userColumnWidths = new Map(this.userColumnWidths);
1124
+
1125
+ if (size != null) {
1126
+ userColumnWidths.set(column, Math.ceil(size));
1127
+ GridMetricCalculator.trimMap(userColumnWidths);
1128
+ } else {
1129
+ userColumnWidths.delete(column);
1098
1130
  }
1099
- /**
1100
- * Get the coordinates of floating items in one dimension.
1101
- * Can be used for getting the y coordinates of floating rows, or x coordinates of floating columns, calculated using the `sizeMap` passed in.
1102
- * @param {number} startCount The number of floating items at the start (ie. `floatingTopRowCount` for rows, `floatingLeftColumnCount` for columns)
1103
- * @param {number} endCount The number of floating items at the end (ie. `floatingBottomRowCount` for rows, `floatingRightColumnCount` for columns)
1104
- * @param {number} totalCount Total number of items in this dimension (ie. `rowCount` for rows, `columnCount` for columns)
1105
- * @param {number} max The max coordinate value (ie. `maxY` for rows, `maxX` for columns)
1106
- * @param {Map<number, number>} sizeMap Map from index to size of item (ie. `rowHeightMap` for rows, `columnWidthMap` for columns)
1107
- */
1108
-
1109
- }, {
1110
- key: "getFloatingCoordinates",
1111
- value: function getFloatingCoordinates(startCount, endCount, totalCount, max, sizeMap) {
1112
- var coordinates = new Map();
1113
- var x = 0;
1114
-
1115
- for (var i = 0; i < startCount && i < totalCount; i += 1) {
1116
- coordinates.set(i, x);
1117
- x += sizeMap.get(i);
1118
- }
1119
1131
 
1120
- x = max;
1132
+ this.userColumnWidths = userColumnWidths;
1133
+ }
1134
+ /**
1135
+ * Resets the column width for the specified column to the calculated width
1136
+ * @param {Number} column The column model index to reset
1137
+ */
1138
+
1139
+
1140
+ resetColumnWidth(column) {
1141
+ this.setColumnWidth(column, null);
1142
+ this.calculatedColumnWidths.delete(column);
1143
+ }
1144
+ /**
1145
+ * Sets the width for the specified row
1146
+ * @param {Number} row The row model index to set
1147
+ * @param {Number} size The size to set it to, or null to reset the row size
1148
+ */
1121
1149
 
1122
- for (var _i3 = 0; _i3 < endCount && totalCount - _i3 - 1 >= 0; _i3 += 1) {
1123
- x -= sizeMap.get(totalCount - _i3 - 1);
1124
- coordinates.set(totalCount - _i3 - 1, x);
1125
- }
1126
1150
 
1127
- return coordinates;
1151
+ setRowHeight(row, size) {
1152
+ var userRowHeights = new Map(this.userRowHeights);
1153
+
1154
+ if (size != null) {
1155
+ userRowHeights.set(row, Math.ceil(size));
1156
+ GridMetricCalculator.trimMap(userRowHeights);
1157
+ } else {
1158
+ userRowHeights.delete(row);
1128
1159
  }
1129
- }]);
1130
1160
 
1131
- return GridMetricCalculator;
1132
- }();
1161
+ this.userRowHeights = userRowHeights;
1162
+ }
1163
+
1164
+ resetRowHeight(row) {
1165
+ this.setRowHeight(row, null);
1166
+ this.calculatedRowHeights.delete(row);
1167
+ }
1168
+
1169
+ }
1133
1170
 
1134
1171
  _defineProperty(GridMetricCalculator, "CACHE_SIZE", 10000);
1135
1172