@deephaven/grid 0.4.1-modules.0 → 0.5.2-beta.0

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