@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
package/dist/GridUtils.js CHANGED
@@ -1,799 +1,837 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
2
 
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
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
4
 
5
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
6
6
 
7
- import GridRange from "./GridRange.js";
8
-
9
- class GridUtils {
10
- // use same constant as chrome source for windows
11
- // https://github.com/chromium/chromium/blob/973af9d461b6b5dc60208c8d3d66adc27e53da78/ui/events/blink/web_input_event_builders_win.cc#L285
12
- static getGridPointFromXY(x, y, metrics) {
13
- var column = GridUtils.getColumnAtX(x, metrics);
14
- var row = GridUtils.getRowAtY(y, metrics);
15
- return {
16
- x,
17
- y,
18
- row,
19
- column
20
- };
21
- }
7
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
22
8
 
23
- static iterateFloatingStart(start, total, callback) {
24
- for (var i = 0; i < start && i < total; i += 1) {
25
- var result = callback(i);
9
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
26
10
 
27
- if (result !== undefined) {
28
- return result;
29
- }
30
- }
11
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
31
12
 
32
- return undefined;
33
- }
34
- /**
35
- * Iterate through floating items at the end. Iterates in increasing order.
36
- */
13
+ 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); }
37
14
 
15
+ 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; }
38
16
 
39
- static iterateFloatingEnd(end, total, callback) {
40
- for (var i = 0; i < end && total - (end - i) >= 0; i += 1) {
41
- var result = callback(total - (end - i));
17
+ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
42
18
 
43
- if (result !== undefined) {
44
- return result;
45
- }
46
- }
19
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
47
20
 
48
- return undefined;
49
- }
50
- /**
51
- * Iterate through all floating items in increasing order, starting with the top items.
52
- * @param {number} start Count of start floating rows, eg. floatingTopRowCount
53
- * @param {number} end Count of end floating rows, eg. floatingBottomRowCount
54
- * @param {number} total Total number of items
55
- * @param {(itemIndex:number) => any | undefined} callback Callback called for each value, stopping the iterating and returning the value if one is returned
56
- */
21
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
57
22
 
23
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
58
24
 
59
- static iterateFloating(start, end, total, callback) {
60
- var result = GridUtils.iterateFloatingStart(start, total, callback);
25
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
61
26
 
62
- if (result !== undefined) {
63
- return result;
64
- }
27
+ 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); } }
65
28
 
66
- return GridUtils.iterateFloatingEnd(end, total, callback);
67
- }
29
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
68
30
 
69
- static iterateAllItems(visibleStart, visibleEnd, floatingStartCount, floatingEndCount, totalCount, callback) {
70
- var visibleStartIndex = Math.max(visibleStart, floatingStartCount);
71
- var visibleEndIndex = Math.min(visibleEnd, totalCount - floatingEndCount - 1);
72
- var result = GridUtils.iterateFloating(floatingStartCount, floatingEndCount, totalCount, callback);
31
+ 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; }
73
32
 
74
- if (result !== undefined) {
75
- return result;
33
+ import GridRange from './GridRange';
34
+
35
+ var GridUtils = /*#__PURE__*/function () {
36
+ function GridUtils() {
37
+ _classCallCheck(this, GridUtils);
38
+ }
39
+
40
+ _createClass(GridUtils, null, [{
41
+ key: "getGridPointFromXY",
42
+ value: // use same constant as chrome source for windows
43
+ // https://github.com/chromium/chromium/blob/973af9d461b6b5dc60208c8d3d66adc27e53da78/ui/events/blink/web_input_event_builders_win.cc#L285
44
+ function getGridPointFromXY(x, y, metrics) {
45
+ var column = GridUtils.getColumnAtX(x, metrics);
46
+ var row = GridUtils.getRowAtY(y, metrics);
47
+ return {
48
+ x: x,
49
+ y: y,
50
+ row: row,
51
+ column: column
52
+ };
76
53
  }
54
+ }, {
55
+ key: "iterateFloatingStart",
56
+ value: function iterateFloatingStart(start, total, callback) {
57
+ for (var i = 0; i < start && i < total; i += 1) {
58
+ var result = callback(i);
59
+
60
+ if (result !== undefined) {
61
+ return result;
62
+ }
63
+ }
77
64
 
78
- for (var i = visibleStartIndex; i <= visibleEndIndex; i += 1) {
79
- result = callback(i);
65
+ return undefined;
66
+ }
67
+ /**
68
+ * Iterate through floating items at the end. Iterates in increasing order.
69
+ */
70
+
71
+ }, {
72
+ key: "iterateFloatingEnd",
73
+ value: function iterateFloatingEnd(end, total, callback) {
74
+ for (var i = 0; i < end && total - (end - i) >= 0; i += 1) {
75
+ var result = callback(total - (end - i));
76
+
77
+ if (result !== undefined) {
78
+ return result;
79
+ }
80
+ }
81
+
82
+ return undefined;
83
+ }
84
+ /**
85
+ * Iterate through all floating items in increasing order, starting with the top items.
86
+ * @param {number} start Count of start floating rows, eg. floatingTopRowCount
87
+ * @param {number} end Count of end floating rows, eg. floatingBottomRowCount
88
+ * @param {number} total Total number of items
89
+ * @param {(itemIndex:number) => any | undefined} callback Callback called for each value, stopping the iterating and returning the value if one is returned
90
+ */
91
+
92
+ }, {
93
+ key: "iterateFloating",
94
+ value: function iterateFloating(start, end, total, callback) {
95
+ var result = GridUtils.iterateFloatingStart(start, total, callback);
80
96
 
81
97
  if (result !== undefined) {
82
98
  return result;
83
99
  }
100
+
101
+ return GridUtils.iterateFloatingEnd(end, total, callback);
84
102
  }
103
+ }, {
104
+ key: "iterateAllItems",
105
+ value: function iterateAllItems(visibleStart, visibleEnd, floatingStartCount, floatingEndCount, totalCount, callback) {
106
+ var visibleStartIndex = Math.max(visibleStart, floatingStartCount);
107
+ var visibleEndIndex = Math.min(visibleEnd, totalCount - floatingEndCount - 1);
108
+ var result = GridUtils.iterateFloating(floatingStartCount, floatingEndCount, totalCount, callback);
85
109
 
86
- return undefined;
87
- }
110
+ if (result !== undefined) {
111
+ return result;
112
+ }
88
113
 
89
- static isInItem(itemIndex, itemXs, itemSizes, x) {
90
- var itemX = itemXs.get(itemIndex);
91
- var itemSize = itemSizes.get(itemIndex);
92
- return itemX <= x && x <= itemX + itemSize;
93
- }
114
+ for (var i = visibleStartIndex; i <= visibleEndIndex; i += 1) {
115
+ result = callback(i);
94
116
 
95
- static getItemAtOffset(offset, itemCount, floatingStart, floatingEnd, items, itemXs, itemSizes) {
96
- var floatingItem = GridUtils.iterateFloating(floatingStart, floatingEnd, itemCount, item => {
97
- if (GridUtils.isInItem(item, itemXs, itemSizes, offset)) {
98
- return item;
117
+ if (result !== undefined) {
118
+ return result;
119
+ }
99
120
  }
100
121
 
101
122
  return undefined;
102
- });
103
-
104
- if (floatingItem !== undefined) {
105
- return floatingItem;
106
123
  }
124
+ }, {
125
+ key: "isInItem",
126
+ value: function isInItem(itemIndex, itemXs, itemSizes, x) {
127
+ var itemX = itemXs.get(itemIndex);
128
+ var itemSize = itemSizes.get(itemIndex);
129
+ return itemX <= x && x <= itemX + itemSize;
130
+ }
131
+ }, {
132
+ key: "getItemAtOffset",
133
+ value: function getItemAtOffset(offset, itemCount, floatingStart, floatingEnd, items, itemXs, itemSizes) {
134
+ var floatingItem = GridUtils.iterateFloating(floatingStart, floatingEnd, itemCount, function (item) {
135
+ if (GridUtils.isInItem(item, itemXs, itemSizes, offset)) {
136
+ return item;
137
+ }
107
138
 
108
- for (var i = 0; i < items.length; i += 1) {
109
- var item = items[i];
139
+ return undefined;
140
+ });
110
141
 
111
- if (GridUtils.isInItem(item, itemXs, itemSizes, offset)) {
112
- return item;
142
+ if (floatingItem !== undefined) {
143
+ return floatingItem;
113
144
  }
114
- }
115
145
 
116
- return null;
117
- }
146
+ for (var i = 0; i < items.length; i += 1) {
147
+ var item = items[i];
118
148
 
119
- static getColumnAtX(x, metrics) {
120
- var {
121
- columnCount,
122
- floatingLeftColumnCount,
123
- floatingRightColumnCount,
124
- visibleColumns,
125
- visibleColumnXs,
126
- visibleColumnWidths,
127
- gridX
128
- } = metrics;
129
-
130
- if (x < gridX) {
131
- return null;
132
- }
133
-
134
- return this.getItemAtOffset(x - gridX, columnCount, floatingLeftColumnCount, floatingRightColumnCount, visibleColumns, visibleColumnXs, visibleColumnWidths);
135
- }
149
+ if (GridUtils.isInItem(item, itemXs, itemSizes, offset)) {
150
+ return item;
151
+ }
152
+ }
136
153
 
137
- static getRowAtY(y, metrics) {
138
- var {
139
- floatingTopRowCount,
140
- floatingBottomRowCount,
141
- rowCount,
142
- visibleRows,
143
- visibleRowYs,
144
- visibleRowHeights,
145
- gridY
146
- } = metrics;
147
-
148
- if (y < gridY) {
149
154
  return null;
150
155
  }
156
+ }, {
157
+ key: "getColumnAtX",
158
+ value: function getColumnAtX(x, metrics) {
159
+ var columnCount = metrics.columnCount,
160
+ floatingLeftColumnCount = metrics.floatingLeftColumnCount,
161
+ floatingRightColumnCount = metrics.floatingRightColumnCount,
162
+ visibleColumns = metrics.visibleColumns,
163
+ visibleColumnXs = metrics.visibleColumnXs,
164
+ visibleColumnWidths = metrics.visibleColumnWidths,
165
+ gridX = metrics.gridX;
166
+
167
+ if (x < gridX) {
168
+ return null;
169
+ }
151
170
 
152
- return this.getItemAtOffset(y - gridY, rowCount, floatingTopRowCount, floatingBottomRowCount, visibleRows, visibleRowYs, visibleRowHeights);
153
- }
154
- /**
155
- * Iterate backward through the visible items until a shown item is hit
156
- * @param {Number} startIndex The index to start from
157
- * @param {Map} modelIndexes The mapping of model indexes
158
- * @param {Number[]} visibleItems The visible items
159
- * @param {Map} userSizes The user set sizes
160
- */
171
+ return this.getItemAtOffset(x - gridX, columnCount, floatingLeftColumnCount, floatingRightColumnCount, visibleColumns, visibleColumnXs, visibleColumnWidths);
172
+ }
173
+ }, {
174
+ key: "getRowAtY",
175
+ value: function getRowAtY(y, metrics) {
176
+ var floatingTopRowCount = metrics.floatingTopRowCount,
177
+ floatingBottomRowCount = metrics.floatingBottomRowCount,
178
+ rowCount = metrics.rowCount,
179
+ visibleRows = metrics.visibleRows,
180
+ visibleRowYs = metrics.visibleRowYs,
181
+ visibleRowHeights = metrics.visibleRowHeights,
182
+ gridY = metrics.gridY;
183
+
184
+ if (y < gridY) {
185
+ return null;
186
+ }
161
187
 
188
+ return this.getItemAtOffset(y - gridY, rowCount, floatingTopRowCount, floatingBottomRowCount, visibleRows, visibleRowYs, visibleRowHeights);
189
+ }
190
+ /**
191
+ * Iterate backward through the visible items until a shown item is hit
192
+ * @param {Number} startIndex The index to start from
193
+ * @param {Map} modelIndexes The mapping of model indexes
194
+ * @param {Number[]} visibleItems The visible items
195
+ * @param {Map} userSizes The user set sizes
196
+ */
197
+
198
+ }, {
199
+ key: "getNextShownItem",
200
+ value: function getNextShownItem(startIndex, modelIndexes, visibleItems, userSizes) {
201
+ var visibleItemIndex = visibleItems.findIndex(function (value) {
202
+ return value === startIndex;
203
+ }) || 0;
204
+ visibleItemIndex -= 1;
162
205
 
163
- static getNextShownItem(startIndex, modelIndexes, visibleItems, userSizes) {
164
- var visibleItemIndex = visibleItems.findIndex(value => value === startIndex) || 0;
165
- visibleItemIndex -= 1;
206
+ while (visibleItemIndex != null && visibleItemIndex >= 0) {
207
+ var item = visibleItems[visibleItemIndex];
208
+ var modelIndex = modelIndexes.get(item);
166
209
 
167
- while (visibleItemIndex != null && visibleItemIndex >= 0) {
168
- var item = visibleItems[visibleItemIndex];
169
- var modelIndex = modelIndexes.get(item);
210
+ if (userSizes.get(modelIndex) !== 0) {
211
+ return item;
212
+ }
170
213
 
171
- if (userSizes.get(modelIndex) !== 0) {
172
- return item;
214
+ visibleItemIndex -= 1;
173
215
  }
174
216
 
175
- visibleItemIndex -= 1;
176
- }
177
-
178
- return null;
179
- }
180
- /**
181
- * Iterate backward through the visible columns until a shown column is hit
182
- * @param {Number} columnIndex The column index to start iterating backward from
183
- * @param {GridMetrics} metrics The GridMetricCalculator metrics
184
- */
185
-
186
-
187
- static getNextShownColumn(startIndex, metrics) {
188
- var {
189
- modelColumns,
190
- visibleColumns,
191
- userColumnWidths
192
- } = metrics;
193
- return GridUtils.getNextShownItem(startIndex, modelColumns, visibleColumns, userColumnWidths);
194
- }
195
- /**
196
- * Iterate backward through the visible rows until a shown row is hit
197
- * @param {Number} rowIndex The row index to start iterating backward from
198
- * @param {GridMetrics} metrics The GridMetricCalculator metrics
199
- */
200
-
201
-
202
- static getNextShownRow(startIndex, metrics) {
203
- var {
204
- modelRows,
205
- visibleRows,
206
- userRowHeights
207
- } = metrics;
208
- return GridUtils.getNextShownItem(startIndex, modelRows, visibleRows, userRowHeights);
209
- } // Returns the column index if the x/y coordinates provided are close enough to the separator, otherwise false
210
-
211
-
212
- static getColumnSeparatorIndex(x, y, metrics, theme) {
213
- var {
214
- rowHeaderWidth,
215
- columnHeaderHeight,
216
- visibleColumns,
217
- visibleColumnXs,
218
- visibleColumnWidths
219
- } = metrics;
220
- var {
221
- allowColumnResize,
222
- headerSeparatorHandleSize
223
- } = theme;
224
-
225
- if (columnHeaderHeight < y || !allowColumnResize || headerSeparatorHandleSize <= 0) {
226
217
  return null;
227
218
  }
219
+ /**
220
+ * Iterate backward through the visible columns until a shown column is hit
221
+ * @param {Number} columnIndex The column index to start iterating backward from
222
+ * @param {GridMetrics} metrics The GridMetricCalculator metrics
223
+ */
224
+
225
+ }, {
226
+ key: "getNextShownColumn",
227
+ value: function getNextShownColumn(startIndex, metrics) {
228
+ var modelColumns = metrics.modelColumns,
229
+ visibleColumns = metrics.visibleColumns,
230
+ userColumnWidths = metrics.userColumnWidths;
231
+ return GridUtils.getNextShownItem(startIndex, modelColumns, visibleColumns, userColumnWidths);
232
+ }
233
+ /**
234
+ * Iterate backward through the visible rows until a shown row is hit
235
+ * @param {Number} rowIndex The row index to start iterating backward from
236
+ * @param {GridMetrics} metrics The GridMetricCalculator metrics
237
+ */
238
+
239
+ }, {
240
+ key: "getNextShownRow",
241
+ value: function getNextShownRow(startIndex, metrics) {
242
+ var modelRows = metrics.modelRows,
243
+ visibleRows = metrics.visibleRows,
244
+ userRowHeights = metrics.userRowHeights;
245
+ return GridUtils.getNextShownItem(startIndex, modelRows, visibleRows, userRowHeights);
246
+ } // Returns the column index if the x/y coordinates provided are close enough to the separator, otherwise false
247
+
248
+ }, {
249
+ key: "getColumnSeparatorIndex",
250
+ value: function getColumnSeparatorIndex(x, y, metrics, theme) {
251
+ var rowHeaderWidth = metrics.rowHeaderWidth,
252
+ columnHeaderHeight = metrics.columnHeaderHeight,
253
+ visibleColumns = metrics.visibleColumns,
254
+ visibleColumnXs = metrics.visibleColumnXs,
255
+ visibleColumnWidths = metrics.visibleColumnWidths;
256
+ var allowColumnResize = theme.allowColumnResize,
257
+ headerSeparatorHandleSize = theme.headerSeparatorHandleSize;
258
+
259
+ if (columnHeaderHeight < y || !allowColumnResize || headerSeparatorHandleSize <= 0) {
260
+ return null;
261
+ }
228
262
 
229
- var gridX = x - rowHeaderWidth;
230
- var halfSeparatorSize = headerSeparatorHandleSize * 0.5; // Iterate backward so that you can reveal hidden columns properly
263
+ var gridX = x - rowHeaderWidth;
264
+ var halfSeparatorSize = headerSeparatorHandleSize * 0.5; // Iterate backward so that you can reveal hidden columns properly
231
265
 
232
- var isPreviousColumnHidden = false;
266
+ var isPreviousColumnHidden = false;
233
267
 
234
- for (var i = visibleColumns.length - 1; i >= 0; i -= 1) {
235
- var column = visibleColumns[i];
236
- var columnX = visibleColumnXs.get(column);
237
- var columnWidth = visibleColumnWidths.get(column);
238
- var isColumnHidden = columnWidth === 0;
268
+ for (var i = visibleColumns.length - 1; i >= 0; i -= 1) {
269
+ var column = visibleColumns[i];
270
+ var columnX = visibleColumnXs.get(column);
271
+ var columnWidth = visibleColumnWidths.get(column);
272
+ var isColumnHidden = columnWidth === 0;
239
273
 
240
- if (!isPreviousColumnHidden || !isColumnHidden) {
241
- var midX = columnX + columnWidth;
274
+ if (!isPreviousColumnHidden || !isColumnHidden) {
275
+ var midX = columnX + columnWidth;
242
276
 
243
- if (isColumnHidden) {
244
- midX += halfSeparatorSize;
245
- } else if (isPreviousColumnHidden) {
246
- midX -= halfSeparatorSize;
247
- }
277
+ if (isColumnHidden) {
278
+ midX += halfSeparatorSize;
279
+ } else if (isPreviousColumnHidden) {
280
+ midX -= halfSeparatorSize;
281
+ }
248
282
 
249
- var minX = midX - halfSeparatorSize;
250
- var maxX = midX + halfSeparatorSize;
283
+ var minX = midX - halfSeparatorSize;
284
+ var maxX = midX + halfSeparatorSize;
251
285
 
252
- if (minX <= gridX && gridX <= maxX) {
253
- return column;
254
- }
286
+ if (minX <= gridX && gridX <= maxX) {
287
+ return column;
288
+ }
255
289
 
256
- isPreviousColumnHidden = isColumnHidden;
290
+ isPreviousColumnHidden = isColumnHidden;
291
+ }
257
292
  }
258
- }
259
-
260
- return null;
261
- }
262
-
263
- static isItemHidden(itemIndex, visibleSizes) {
264
- return visibleSizes.get(itemIndex) === 0;
265
- }
266
-
267
- static isColumnHidden(columnIndex, metrics) {
268
- var {
269
- visibleColumnWidths
270
- } = metrics;
271
- return GridUtils.isItemHidden(columnIndex, visibleColumnWidths);
272
- }
273
- /**
274
- * Check if the provided row is a floating row
275
- * @param {number} row The row index to check
276
- * @param {GridMetrics} metrics The grid metrics to check against
277
- */
278
-
279
293
 
280
- static isFloatingRow(row, metrics) {
281
- if (row == null) {
282
- return false;
294
+ return null;
283
295
  }
284
-
285
- var {
286
- floatingTopRowCount,
287
- floatingBottomRowCount,
288
- rowCount
289
- } = metrics;
290
- return row < floatingTopRowCount || row >= rowCount - floatingBottomRowCount;
291
- }
292
- /**
293
- * Check if the provided column is a floating column
294
- * @param {number} column The column index to check
295
- * @param {GridMetrics} metrics The grid metrics to check against
296
- */
297
-
298
-
299
- static isFloatingColumn(column, metrics) {
300
- if (column == null) {
301
- return false;
296
+ }, {
297
+ key: "isItemHidden",
298
+ value: function isItemHidden(itemIndex, visibleSizes) {
299
+ return visibleSizes.get(itemIndex) === 0;
302
300
  }
303
-
304
- var {
305
- floatingLeftColumnCount,
306
- floatingRightColumnCount,
307
- columnCount
308
- } = metrics;
309
- return column < floatingLeftColumnCount || column >= columnCount - floatingRightColumnCount;
310
- }
311
-
312
- static getHiddenItems(itemIndex, visibleSizes, visibleItems) {
313
- if (!GridUtils.isItemHidden(itemIndex, visibleSizes)) {
314
- return [];
301
+ }, {
302
+ key: "isColumnHidden",
303
+ value: function isColumnHidden(columnIndex, metrics) {
304
+ var visibleColumnWidths = metrics.visibleColumnWidths;
305
+ return GridUtils.isItemHidden(columnIndex, visibleColumnWidths);
315
306
  }
316
-
317
- var hiddenItems = [itemIndex];
318
- var visibleItemIndex = visibleItems.findIndex(value => value === itemIndex);
319
-
320
- for (var i = visibleItemIndex - 1; i >= 0; i -= 1) {
321
- var item = visibleItems[i];
322
-
323
- if (!GridUtils.isItemHidden(item, visibleSizes)) {
324
- break;
307
+ /**
308
+ * Check if the provided row is a floating row
309
+ * @param {number} row The row index to check
310
+ * @param {GridMetrics} metrics The grid metrics to check against
311
+ */
312
+
313
+ }, {
314
+ key: "isFloatingRow",
315
+ value: function isFloatingRow(row, metrics) {
316
+ if (row == null) {
317
+ return false;
325
318
  }
326
319
 
327
- hiddenItems.push(item);
320
+ var floatingTopRowCount = metrics.floatingTopRowCount,
321
+ floatingBottomRowCount = metrics.floatingBottomRowCount,
322
+ rowCount = metrics.rowCount;
323
+ return row < floatingTopRowCount || row >= rowCount - floatingBottomRowCount;
328
324
  }
325
+ /**
326
+ * Check if the provided column is a floating column
327
+ * @param {number} column The column index to check
328
+ * @param {GridMetrics} metrics The grid metrics to check against
329
+ */
330
+
331
+ }, {
332
+ key: "isFloatingColumn",
333
+ value: function isFloatingColumn(column, metrics) {
334
+ if (column == null) {
335
+ return false;
336
+ }
329
337
 
330
- return hiddenItems;
331
- }
332
-
333
- static getHiddenColumns(columnIndex, metrics) {
334
- var {
335
- visibleColumns,
336
- visibleColumnWidths
337
- } = metrics;
338
- return GridUtils.getHiddenItems(columnIndex, visibleColumnWidths, visibleColumns);
339
- } // Returns the row index if the x/y coordinates provided are close enough to the separator, otherwise false
340
-
341
-
342
- static getRowSeparatorIndex(x, y, metrics, theme) {
343
- var {
344
- rowHeaderWidth,
345
- columnHeaderHeight,
346
- visibleRows,
347
- visibleRowYs,
348
- visibleRowHeights
349
- } = metrics;
350
- var {
351
- allowRowResize,
352
- headerSeparatorHandleSize
353
- } = theme;
354
-
355
- if (rowHeaderWidth < x || !allowRowResize || headerSeparatorHandleSize <= 0) {
356
- return null;
338
+ var floatingLeftColumnCount = metrics.floatingLeftColumnCount,
339
+ floatingRightColumnCount = metrics.floatingRightColumnCount,
340
+ columnCount = metrics.columnCount;
341
+ return column < floatingLeftColumnCount || column >= columnCount - floatingRightColumnCount;
357
342
  }
343
+ }, {
344
+ key: "getHiddenItems",
345
+ value: function getHiddenItems(itemIndex, visibleSizes, visibleItems) {
346
+ if (!GridUtils.isItemHidden(itemIndex, visibleSizes)) {
347
+ return [];
348
+ }
358
349
 
359
- var gridY = y - columnHeaderHeight;
360
- var halfSeparatorSize = headerSeparatorHandleSize * 0.5; // Iterate backward so you can reveal hidden rows properly
361
-
362
- var isPreviousRowHidden = false;
363
-
364
- for (var i = visibleRows.length - 1; i >= 0; i -= 1) {
365
- var row = visibleRows[i];
366
- var rowY = visibleRowYs.get(row);
367
- var rowHeight = visibleRowHeights.get(row);
368
- var isRowHidden = rowHeight === 0;
369
-
370
- if (!isPreviousRowHidden || !isRowHidden) {
371
- var midY = rowY + rowHeight;
372
-
373
- if (isRowHidden) {
374
- midY += halfSeparatorSize;
375
- } else if (isPreviousRowHidden) {
376
- midY -= halfSeparatorSize;
377
- }
350
+ var hiddenItems = [itemIndex];
351
+ var visibleItemIndex = visibleItems.findIndex(function (value) {
352
+ return value === itemIndex;
353
+ });
378
354
 
379
- var minY = midY - halfSeparatorSize;
380
- var maxY = midY + halfSeparatorSize;
355
+ for (var i = visibleItemIndex - 1; i >= 0; i -= 1) {
356
+ var item = visibleItems[i];
381
357
 
382
- if (minY <= gridY && gridY <= maxY) {
383
- return row;
358
+ if (!GridUtils.isItemHidden(item, visibleSizes)) {
359
+ break;
384
360
  }
385
361
 
386
- isPreviousRowHidden = isRowHidden;
362
+ hiddenItems.push(item);
387
363
  }
388
- }
389
364
 
390
- return null;
391
- }
365
+ return hiddenItems;
366
+ }
367
+ }, {
368
+ key: "getHiddenColumns",
369
+ value: function getHiddenColumns(columnIndex, metrics) {
370
+ var visibleColumns = metrics.visibleColumns,
371
+ visibleColumnWidths = metrics.visibleColumnWidths;
372
+ return GridUtils.getHiddenItems(columnIndex, visibleColumnWidths, visibleColumns);
373
+ } // Returns the row index if the x/y coordinates provided are close enough to the separator, otherwise false
374
+
375
+ }, {
376
+ key: "getRowSeparatorIndex",
377
+ value: function getRowSeparatorIndex(x, y, metrics, theme) {
378
+ var rowHeaderWidth = metrics.rowHeaderWidth,
379
+ columnHeaderHeight = metrics.columnHeaderHeight,
380
+ visibleRows = metrics.visibleRows,
381
+ visibleRowYs = metrics.visibleRowYs,
382
+ visibleRowHeights = metrics.visibleRowHeights;
383
+ var allowRowResize = theme.allowRowResize,
384
+ headerSeparatorHandleSize = theme.headerSeparatorHandleSize;
385
+
386
+ if (rowHeaderWidth < x || !allowRowResize || headerSeparatorHandleSize <= 0) {
387
+ return null;
388
+ }
392
389
 
393
- static isRowHidden(rowIndex, metrics) {
394
- var {
395
- visibleRowHeights
396
- } = metrics;
397
- return GridUtils.isItemHidden(rowIndex, visibleRowHeights);
398
- }
390
+ var gridY = y - columnHeaderHeight;
391
+ var halfSeparatorSize = headerSeparatorHandleSize * 0.5; // Iterate backward so you can reveal hidden rows properly
399
392
 
400
- static getHiddenRows(rowIndex, metrics) {
401
- var {
402
- visibleRows,
403
- visibleRowHeights
404
- } = metrics;
405
- return GridUtils.getHiddenItems(rowIndex, visibleRowHeights, visibleRows);
406
- }
407
- /**
408
- * Set a new order for items in the grid
409
- * @param {Number} from The visible index to move from
410
- * @param {Number} to The visible index to move the itme to
411
- * @param {Array} oldMovedItems The old reordered items
412
- * @returns {Number} The new reordered items
413
- */
393
+ var isPreviousRowHidden = false;
414
394
 
395
+ for (var i = visibleRows.length - 1; i >= 0; i -= 1) {
396
+ var row = visibleRows[i];
397
+ var rowY = visibleRowYs.get(row);
398
+ var rowHeight = visibleRowHeights.get(row);
399
+ var isRowHidden = rowHeight === 0;
415
400
 
416
- static moveItem(from, to) {
417
- var oldMovedItems = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
401
+ if (!isPreviousRowHidden || !isRowHidden) {
402
+ var midY = rowY + rowHeight;
418
403
 
419
- if (from === to) {
420
- return oldMovedItems;
421
- }
404
+ if (isRowHidden) {
405
+ midY += halfSeparatorSize;
406
+ } else if (isPreviousRowHidden) {
407
+ midY -= halfSeparatorSize;
408
+ }
422
409
 
423
- var movedItems = [].concat(oldMovedItems);
410
+ var minY = midY - halfSeparatorSize;
411
+ var maxY = midY + halfSeparatorSize;
424
412
 
425
- if (movedItems.length > 0 && movedItems[movedItems.length - 1].to === from) {
426
- movedItems[movedItems.length - 1] = _objectSpread(_objectSpread({}, movedItems[movedItems.length - 1]), {}, {
427
- to
428
- });
429
- } else {
430
- movedItems.push({
431
- from,
432
- to
433
- });
434
- }
413
+ if (minY <= gridY && gridY <= maxY) {
414
+ return row;
415
+ }
435
416
 
436
- return movedItems;
437
- }
438
- /**
439
- * Retrieve the model index given the currently moved items
440
- * @param {Number} visibleIndex The visible index of the item to get the model index for
441
- * @param {Array} movedItems The moved items
442
- * @returns {Number} The model index of the item
443
- */
444
-
445
-
446
- static getModelIndex(visibleIndex) {
447
- var movedItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
448
- var modelIndex = visibleIndex;
449
-
450
- for (var i = movedItems.length - 1; i >= 0; i -= 1) {
451
- var movedItem = movedItems[i];
452
-
453
- if (modelIndex === movedItem.to) {
454
- ({
455
- from: modelIndex
456
- } = movedItem);
457
- } else if (movedItem.from <= modelIndex && modelIndex < movedItem.to) {
458
- modelIndex += 1;
459
- } else if (movedItem.to < modelIndex && modelIndex <= movedItem.from) {
460
- modelIndex -= 1;
417
+ isPreviousRowHidden = isRowHidden;
418
+ }
461
419
  }
420
+
421
+ return null;
422
+ }
423
+ }, {
424
+ key: "isRowHidden",
425
+ value: function isRowHidden(rowIndex, metrics) {
426
+ var visibleRowHeights = metrics.visibleRowHeights;
427
+ return GridUtils.isItemHidden(rowIndex, visibleRowHeights);
428
+ }
429
+ }, {
430
+ key: "getHiddenRows",
431
+ value: function getHiddenRows(rowIndex, metrics) {
432
+ var visibleRows = metrics.visibleRows,
433
+ visibleRowHeights = metrics.visibleRowHeights;
434
+ return GridUtils.getHiddenItems(rowIndex, visibleRowHeights, visibleRows);
462
435
  }
436
+ /**
437
+ * Set a new order for items in the grid
438
+ * @param {Number} from The visible index to move from
439
+ * @param {Number} to The visible index to move the itme to
440
+ * @param {Array} oldMovedItems The old reordered items
441
+ * @returns {Number} The new reordered items
442
+ */
443
+
444
+ }, {
445
+ key: "moveItem",
446
+ value: function moveItem(from, to) {
447
+ var oldMovedItems = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
448
+
449
+ if (from === to) {
450
+ return oldMovedItems;
451
+ }
463
452
 
464
- return modelIndex;
465
- }
466
- /**
467
- * Translate the provided UI start/end indexes to the model start/end indexes by applying the `movedItems` transformations.
468
- * Since moved items can split apart a range, multiple pairs of indexes are returned
469
- *
470
- * @param {number} start Start item in one dimension
471
- * @param {number} end End item in one dimension
472
- * @param {MovedItem[]} movedItems Moved item pairs in this dimension
473
- * @returns {AxisRange[]} Array of start/end pairs of the indexes after transformations applied.
474
- */
453
+ var movedItems = [].concat(oldMovedItems);
475
454
 
455
+ if (movedItems.length > 0 && movedItems[movedItems.length - 1].to === from) {
456
+ movedItems[movedItems.length - 1] = _objectSpread(_objectSpread({}, movedItems[movedItems.length - 1]), {}, {
457
+ to: to
458
+ });
459
+ } else {
460
+ movedItems.push({
461
+ from: from,
462
+ to: to
463
+ });
464
+ }
476
465
 
477
- static getModelRangeIndexes(start, end, movedItems) {
478
- var result = [[start, end]];
466
+ return movedItems;
467
+ }
468
+ /**
469
+ * Retrieve the model index given the currently moved items
470
+ * @param {Number} visibleIndex The visible index of the item to get the model index for
471
+ * @param {Array} movedItems The moved items
472
+ * @returns {Number} The model index of the item
473
+ */
474
+
475
+ }, {
476
+ key: "getModelIndex",
477
+ value: function getModelIndex(visibleIndex) {
478
+ var movedItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
479
+ var modelIndex = visibleIndex;
480
+
481
+ for (var i = movedItems.length - 1; i >= 0; i -= 1) {
482
+ var movedItem = movedItems[i];
483
+
484
+ if (modelIndex === movedItem.to) {
485
+ modelIndex = movedItem.from;
486
+ } else if (movedItem.from <= modelIndex && modelIndex < movedItem.to) {
487
+ modelIndex += 1;
488
+ } else if (movedItem.to < modelIndex && modelIndex <= movedItem.from) {
489
+ modelIndex -= 1;
490
+ }
491
+ }
492
+
493
+ return modelIndex;
494
+ }
495
+ /**
496
+ * Translate the provided UI start/end indexes to the model start/end indexes by applying the `movedItems` transformations.
497
+ * Since moved items can split apart a range, multiple pairs of indexes are returned
498
+ *
499
+ * @param {number} start Start item in one dimension
500
+ * @param {number} end End item in one dimension
501
+ * @param {MovedItem[]} movedItems Moved item pairs in this dimension
502
+ * @returns {AxisRange[]} Array of start/end pairs of the indexes after transformations applied.
503
+ */
504
+
505
+ }, {
506
+ key: "getModelRangeIndexes",
507
+ value: function getModelRangeIndexes(start, end, movedItems) {
508
+ var result = [[start, end]];
509
+
510
+ if (start == null) {
511
+ return result;
512
+ } // movedItems is built by adding a new item whenever an item in the UI is dragged/moved, transforming a model
513
+ // index to the new UI index. We want to find the model index from the UI index here, so we unwind the
514
+ // transformations applied - the start/end axis range passed in is the current UI range, so we need to apply
515
+ // the transformations starting at the end of the chain backward to find the appropriate model indexes
516
+
517
+
518
+ for (var i = movedItems.length - 1; i >= 0; i -= 1) {
519
+ var _movedItems$i = movedItems[i],
520
+ from = _movedItems$i.from,
521
+ to = _movedItems$i.to;
522
+ var nextResult = [];
523
+
524
+ for (var j = 0; j < result.length; j += 1) {
525
+ var _result$j = _slicedToArray(result[j], 2),
526
+ currentStart = _result$j[0],
527
+ currentEnd = _result$j[1];
528
+
529
+ var startLength = nextResult.length;
530
+
531
+ if (from <= currentStart) {
532
+ // From before
533
+ if (to > currentEnd) {
534
+ // To after
535
+ nextResult.push([currentStart + 1, currentEnd + 1]);
536
+ } else if (to >= currentStart) {
537
+ // To within
538
+ nextResult.push([from, from]);
539
+ nextResult.push([currentStart + 1, currentEnd]);
540
+ }
541
+ } else if (from > currentEnd) {
542
+ // From after
543
+ if (to < currentStart) {
544
+ // To before
545
+ nextResult.push([currentStart - 1, currentEnd - 1]);
546
+ } else if (to <= currentEnd) {
547
+ // To within
548
+ nextResult.push([from, from]);
549
+ nextResult.push([currentStart, currentEnd - 1]);
550
+ }
551
+ } else if (to < currentStart) {
552
+ // From within to before
553
+ nextResult.push([currentStart - 1, from - 1]);
554
+ nextResult.push([from + 1, currentEnd]);
555
+ } else if (to > currentEnd) {
556
+ // From within to after
557
+ nextResult.push([currentStart, from - 1]);
558
+ nextResult.push([from + 1, currentEnd + 1]);
559
+ } else if (from > to) {
560
+ // From within after to within before
561
+ if (to > currentStart) {
562
+ nextResult.push([currentStart, to - 1]);
563
+ }
479
564
 
480
- if (start == null) {
481
- return result;
482
- } // movedItems is built by adding a new item whenever an item in the UI is dragged/moved, transforming a model
483
- // index to the new UI index. We want to find the model index from the UI index here, so we unwind the
484
- // transformations applied - the start/end axis range passed in is the current UI range, so we need to apply
485
- // the transformations starting at the end of the chain backward to find the appropriate model indexes
486
-
487
-
488
- for (var i = movedItems.length - 1; i >= 0; i -= 1) {
489
- var {
490
- from,
491
- to
492
- } = movedItems[i];
493
- var nextResult = [];
494
-
495
- for (var j = 0; j < result.length; j += 1) {
496
- var [currentStart, currentEnd] = result[j];
497
- var startLength = nextResult.length;
498
-
499
- if (from <= currentStart) {
500
- // From before
501
- if (to > currentEnd) {
502
- // To after
503
- nextResult.push([currentStart + 1, currentEnd + 1]);
504
- } else if (to >= currentStart) {
505
- // To within
506
565
  nextResult.push([from, from]);
507
- nextResult.push([currentStart + 1, currentEnd]);
508
- }
509
- } else if (from > currentEnd) {
510
- // From after
511
- if (to < currentStart) {
512
- // To before
513
- nextResult.push([currentStart - 1, currentEnd - 1]);
514
- } else if (to <= currentEnd) {
515
- // To within
566
+ nextResult.push([to, from - 1]);
567
+
568
+ if (from < currentEnd) {
569
+ nextResult.push([from + 1, currentEnd]);
570
+ }
571
+ } else if (from < to) {
572
+ // From within before to within after
573
+ if (from > currentStart) {
574
+ nextResult.push([currentStart, from - 1]);
575
+ }
576
+
577
+ nextResult.push([from + 1, to]);
516
578
  nextResult.push([from, from]);
517
- nextResult.push([currentStart, currentEnd - 1]);
518
- }
519
- } else if (to < currentStart) {
520
- // From within to before
521
- nextResult.push([currentStart - 1, from - 1]);
522
- nextResult.push([from + 1, currentEnd]);
523
- } else if (to > currentEnd) {
524
- // From within to after
525
- nextResult.push([currentStart, from - 1]);
526
- nextResult.push([from + 1, currentEnd + 1]);
527
- } else if (from > to) {
528
- // From within after to within before
529
- if (to > currentStart) {
530
- nextResult.push([currentStart, to - 1]);
531
- }
532
-
533
- nextResult.push([from, from]);
534
- nextResult.push([to, from - 1]);
535
579
 
536
- if (from < currentEnd) {
537
- nextResult.push([from + 1, currentEnd]);
580
+ if (from < currentEnd) {
581
+ nextResult.push([to + 1, currentEnd]);
582
+ }
538
583
  }
539
- } else if (from < to) {
540
- // From within before to within after
541
- if (from > currentStart) {
542
- nextResult.push([currentStart, from - 1]);
543
- }
544
-
545
- nextResult.push([from + 1, to]);
546
- nextResult.push([from, from]);
547
584
 
548
- if (from < currentEnd) {
549
- nextResult.push([to + 1, currentEnd]);
585
+ if (startLength === nextResult.length) {
586
+ // No modifications were made, add the original range indexes
587
+ nextResult.push([currentStart, currentEnd]);
550
588
  }
551
589
  }
552
590
 
553
- if (startLength === nextResult.length) {
554
- // No modifications were made, add the original range indexes
555
- nextResult.push([currentStart, currentEnd]);
556
- }
591
+ result = nextResult;
557
592
  }
558
593
 
559
- result = nextResult;
594
+ return result;
560
595
  }
561
-
562
- return result;
563
- }
564
- /**
565
- * Translate the provided UI range into model range, using the `movedColumns` and `movedRows` to apply the necessary transforms.
566
- * `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
567
- *
568
- * @param {GridRange} uiRange The currently selected UI ranges
569
- * @param {Array} movedColumns The moved column pairs
570
- * @param {Array} movedRows The moved row pairs
571
- * @returns {GridRange[]} The model ranges after translation.
572
- */
573
-
574
-
575
- static getModelRange(uiRange) {
576
- var movedColumns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
577
- var movedRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
578
- var columnRanges = GridUtils.getModelRangeIndexes(uiRange.startColumn, uiRange.endColumn, movedColumns);
579
- var rowRanges = GridUtils.getModelRangeIndexes(uiRange.startRow, uiRange.endRow, movedRows);
580
- var ranges = [];
581
-
582
- for (var i = 0; i < columnRanges.length; i += 1) {
583
- var c = columnRanges[i];
584
-
585
- for (var j = 0; j < rowRanges.length; j += 1) {
586
- var r = rowRanges[j];
587
- ranges.push(new GridRange(c[0], r[0], c[1], r[1]));
596
+ /**
597
+ * Translate the provided UI range into model range, using the `movedColumns` and `movedRows` to apply the necessary transforms.
598
+ * `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
599
+ *
600
+ * @param {GridRange} uiRange The currently selected UI ranges
601
+ * @param {Array} movedColumns The moved column pairs
602
+ * @param {Array} movedRows The moved row pairs
603
+ * @returns {GridRange[]} The model ranges after translation.
604
+ */
605
+
606
+ }, {
607
+ key: "getModelRange",
608
+ value: function getModelRange(uiRange) {
609
+ var movedColumns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
610
+ var movedRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
611
+ var columnRanges = GridUtils.getModelRangeIndexes(uiRange.startColumn, uiRange.endColumn, movedColumns);
612
+ var rowRanges = GridUtils.getModelRangeIndexes(uiRange.startRow, uiRange.endRow, movedRows);
613
+ var ranges = [];
614
+
615
+ for (var i = 0; i < columnRanges.length; i += 1) {
616
+ var c = columnRanges[i];
617
+
618
+ for (var j = 0; j < rowRanges.length; j += 1) {
619
+ var r = rowRanges[j];
620
+ ranges.push(new GridRange(c[0], r[0], c[1], r[1]));
621
+ }
588
622
  }
589
- }
590
-
591
- return ranges;
592
- }
593
- /**
594
- * Translate the provided UI range into model ranges, using the `movedColumns` and `movedRows` to apply the necessary transforms.
595
- * `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
596
- *
597
- * @param {GridRange[]} uiRanges The currently selected UI ranges
598
- * @param {Array} movedColumns The moved column pairs
599
- * @param {Array} movedRows The moved row pairs
600
- * @returns {GridRange[]} The model ranges after translation.
601
- */
602
623
 
603
-
604
- static getModelRanges(uiRanges) {
605
- var movedColumns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
606
- var movedRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
607
- var modelRanges = [];
608
-
609
- for (var i = 0; i < uiRanges.length; i += 1) {
610
- modelRanges.push(...GridUtils.getModelRange(uiRanges[i], movedColumns, movedRows));
624
+ return ranges;
611
625
  }
612
-
613
- return modelRanges;
614
- }
615
- /**
616
- * Retrieve the visible index given the currently moved items
617
- * @param {Number} modelIndex The model index to get the visible index for
618
- * @param {Array} movedItems Moved items
619
- * @returns {Number} The visible index of the item
620
- */
621
-
622
-
623
- static getVisibleIndex(modelIndex) {
624
- var movedItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
625
- var visibleIndex = modelIndex;
626
-
627
- for (var i = 0; i < movedItems.length; i += 1) {
628
- var movedItem = movedItems[i];
629
-
630
- if (visibleIndex === movedItem.from) {
631
- ({
632
- to: visibleIndex
633
- } = movedItem);
634
- } else if (movedItem.from < visibleIndex && visibleIndex <= movedItem.to) {
635
- visibleIndex -= 1;
636
- } else if (movedItem.to <= visibleIndex && visibleIndex < movedItem.from) {
637
- visibleIndex += 1;
626
+ /**
627
+ * Translate the provided UI range into model ranges, using the `movedColumns` and `movedRows` to apply the necessary transforms.
628
+ * `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
629
+ *
630
+ * @param {GridRange[]} uiRanges The currently selected UI ranges
631
+ * @param {Array} movedColumns The moved column pairs
632
+ * @param {Array} movedRows The moved row pairs
633
+ * @returns {GridRange[]} The model ranges after translation.
634
+ */
635
+
636
+ }, {
637
+ key: "getModelRanges",
638
+ value: function getModelRanges(uiRanges) {
639
+ var movedColumns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
640
+ var movedRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
641
+ var modelRanges = [];
642
+
643
+ for (var i = 0; i < uiRanges.length; i += 1) {
644
+ modelRanges.push.apply(modelRanges, _toConsumableArray(GridUtils.getModelRange(uiRanges[i], movedColumns, movedRows)));
638
645
  }
639
- }
640
646
 
641
- return visibleIndex;
642
- }
643
-
644
- static isMacPlatform() {
645
- var {
646
- platform
647
- } = window.navigator;
648
- return platform.startsWith('Mac');
649
- }
650
-
651
- static getModifierKey() {
652
- if (GridUtils.isMacPlatform()) {
653
- return 'metaKey';
647
+ return modelRanges;
654
648
  }
649
+ /**
650
+ * Retrieve the visible index given the currently moved items
651
+ * @param {Number} modelIndex The model index to get the visible index for
652
+ * @param {Array} movedItems Moved items
653
+ * @returns {Number} The visible index of the item
654
+ */
655
+
656
+ }, {
657
+ key: "getVisibleIndex",
658
+ value: function getVisibleIndex(modelIndex) {
659
+ var movedItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
660
+ var visibleIndex = modelIndex;
661
+
662
+ for (var i = 0; i < movedItems.length; i += 1) {
663
+ var movedItem = movedItems[i];
664
+
665
+ if (visibleIndex === movedItem.from) {
666
+ visibleIndex = movedItem.to;
667
+ } else if (movedItem.from < visibleIndex && visibleIndex <= movedItem.to) {
668
+ visibleIndex -= 1;
669
+ } else if (movedItem.to <= visibleIndex && visibleIndex < movedItem.from) {
670
+ visibleIndex += 1;
671
+ }
672
+ }
655
673
 
656
- return 'ctrlKey';
657
- }
658
-
659
- static isModifierKeyDown(event) {
660
- var modifierKey = GridUtils.getModifierKey();
661
- return event[modifierKey];
662
- }
663
-
664
- static checkColumnHidden(modelIndex, userColumnWidths) {
665
- return userColumnWidths.get(modelIndex) === 0;
666
- }
667
-
668
- static checkAllColumnsHidden(columns, userColumnWidths) {
669
- if (userColumnWidths.size === 0) {
670
- return false;
674
+ return visibleIndex;
671
675
  }
672
-
673
- return columns.every(column => userColumnWidths.get(column) === 0);
674
- }
675
- /**
676
- * Get the bounds the mouse needs to be dragged outside of from an initial selection before scrolling occurs.
677
- * Taking into account any floating rows that may be covering the viewport.
678
- * @param {GridMetrics} metrics Grid metrics
679
- * @param {number} row The row they started dragging in
680
- * @param {number} column The column they started the drag from
681
- * @returns Dimensions of the drag area in relation to the canvas they need to drag outside of to start scrolling
682
- */
683
-
684
-
685
- static getScrollDragBounds(metrics, row, column) {
686
- var {
687
- gridX,
688
- gridY,
689
- width,
690
- height,
691
- floatingTopRowCount,
692
- floatingBottomRowCount,
693
- floatingLeftColumnCount,
694
- floatingRightColumnCount,
695
- floatingLeftWidth,
696
- floatingRightWidth,
697
- floatingTopHeight,
698
- floatingBottomHeight,
699
- columnCount,
700
- rowCount
701
- } = metrics;
702
- var x = gridX;
703
- var y = gridY;
704
- var x2 = width;
705
- var y2 = height;
706
-
707
- if (column != null) {
708
- if (column > floatingLeftColumnCount) {
709
- x += floatingLeftWidth;
676
+ }, {
677
+ key: "isMacPlatform",
678
+ value: function isMacPlatform() {
679
+ var platform = window.navigator.platform;
680
+ return platform.startsWith('Mac');
681
+ }
682
+ }, {
683
+ key: "getModifierKey",
684
+ value: function getModifierKey() {
685
+ if (GridUtils.isMacPlatform()) {
686
+ return 'metaKey';
710
687
  }
711
688
 
712
- if (column < columnCount - floatingRightColumnCount) {
713
- x2 -= floatingRightWidth;
689
+ return 'ctrlKey';
690
+ }
691
+ }, {
692
+ key: "isModifierKeyDown",
693
+ value: function isModifierKeyDown(event) {
694
+ var modifierKey = GridUtils.getModifierKey();
695
+ return event[modifierKey];
696
+ }
697
+ }, {
698
+ key: "checkColumnHidden",
699
+ value: function checkColumnHidden(modelIndex, userColumnWidths) {
700
+ return userColumnWidths.get(modelIndex) === 0;
701
+ }
702
+ }, {
703
+ key: "checkAllColumnsHidden",
704
+ value: function checkAllColumnsHidden(columns, userColumnWidths) {
705
+ if (userColumnWidths.size === 0) {
706
+ return false;
714
707
  }
708
+
709
+ return columns.every(function (column) {
710
+ return userColumnWidths.get(column) === 0;
711
+ });
715
712
  }
713
+ /**
714
+ * Get the bounds the mouse needs to be dragged outside of from an initial selection before scrolling occurs.
715
+ * Taking into account any floating rows that may be covering the viewport.
716
+ * @param {GridMetrics} metrics Grid metrics
717
+ * @param {number} row The row they started dragging in
718
+ * @param {number} column The column they started the drag from
719
+ * @returns Dimensions of the drag area in relation to the canvas they need to drag outside of to start scrolling
720
+ */
721
+
722
+ }, {
723
+ key: "getScrollDragBounds",
724
+ value: function getScrollDragBounds(metrics, row, column) {
725
+ var gridX = metrics.gridX,
726
+ gridY = metrics.gridY,
727
+ width = metrics.width,
728
+ height = metrics.height,
729
+ floatingTopRowCount = metrics.floatingTopRowCount,
730
+ floatingBottomRowCount = metrics.floatingBottomRowCount,
731
+ floatingLeftColumnCount = metrics.floatingLeftColumnCount,
732
+ floatingRightColumnCount = metrics.floatingRightColumnCount,
733
+ floatingLeftWidth = metrics.floatingLeftWidth,
734
+ floatingRightWidth = metrics.floatingRightWidth,
735
+ floatingTopHeight = metrics.floatingTopHeight,
736
+ floatingBottomHeight = metrics.floatingBottomHeight,
737
+ columnCount = metrics.columnCount,
738
+ rowCount = metrics.rowCount;
739
+ var x = gridX;
740
+ var y = gridY;
741
+ var x2 = width;
742
+ var y2 = height;
743
+
744
+ if (column != null) {
745
+ if (column > floatingLeftColumnCount) {
746
+ x += floatingLeftWidth;
747
+ }
716
748
 
717
- if (row != null) {
718
- if (row > floatingTopRowCount) {
719
- y += floatingTopHeight;
749
+ if (column < columnCount - floatingRightColumnCount) {
750
+ x2 -= floatingRightWidth;
751
+ }
720
752
  }
721
753
 
722
- if (row < rowCount - floatingBottomRowCount) {
723
- y2 -= floatingBottomHeight;
724
- }
725
- }
754
+ if (row != null) {
755
+ if (row > floatingTopRowCount) {
756
+ y += floatingTopHeight;
757
+ }
726
758
 
727
- return {
728
- x,
729
- y,
730
- x2,
731
- y2
732
- };
733
- }
734
- /**
735
- * Converts the delta coordinates from the provided wheel event to pixels
736
- * Different platforms have different ways of providing the delta so this normalizes it
737
- * @param {WheelEvent} wheelEvent The mouse wheel event to get the scrolling delta for
738
- * @param {number?} pageWidth The width of the page that is scrolling
739
- * @param {number?} pageHeight The height of the page that is scrolling
740
- * @param {number?} lineWidth The width of the line scrolling in line mode
741
- * @param {number?} lineHeight The height of the line scrolling in line mode
742
- * @returns {{deltaX:number, deltaY: number}} The delta coordinates normalized to pixels
743
- */
744
-
745
-
746
- static getScrollDelta(wheelEvent) {
747
- var pageWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1024;
748
- var pageHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 768;
749
- var lineWidth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 20;
750
- var lineHeight = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 20;
751
- var {
752
- deltaX,
753
- deltaY
754
- } = wheelEvent; // Flip scroll direction if shiftKey is held on windows/linux.
755
- // On mac, deltaX/Y values are switched at the event level when shiftKey=true.
756
- // Guard on strictly Y only changing, to ignore trackpad diagonal motion,
757
- // through that guard may not be necessary, but it is difficult to determine for
758
- // all platforms/browser/scroll method combos.
759
-
760
- if (!GridUtils.isMacPlatform() && wheelEvent.shiftKey && wheelEvent.deltaX === 0 && wheelEvent.deltaY !== 0) {
761
- deltaX = wheelEvent.deltaY;
762
- deltaY = wheelEvent.deltaX;
763
- } // Normalize other deltaMode values to pixel units
764
- // deltaMode 0, is already in pixel units
765
-
766
-
767
- if ((wheelEvent === null || wheelEvent === void 0 ? void 0 : wheelEvent.deltaMode) === WheelEvent.DOM_DELTA_PAGE) {
768
- // Users can set OS to be in deltaMode page
769
- // scrolly by page units as pixels
770
- deltaX *= pageWidth;
771
- deltaY *= pageHeight;
772
- } else if ((wheelEvent === null || wheelEvent === void 0 ? void 0 : wheelEvent.deltaMode) === WheelEvent.DOM_DELTA_LINE) {
773
- // Firefox reports deltaMode line
774
- // Normalize distance travelled between browsers
775
- // but remain ~platform/browser combo consistent
776
- if (GridUtils.isMacPlatform()) {
777
- // for mac treat lines as a standard row height
778
- // on mac, firefox travels less distance then chrome per tick
779
- deltaX = Math.round(deltaX * lineWidth);
780
- deltaY = Math.round(deltaY * lineHeight);
781
- } else {
782
- // for windows convert to pixels using the same method as chrome
783
- // chrome goes 100 per 3 lines, and firefox would go 102 per 3 (17 lineheight * 3 lines * 2)
784
- // make the behaviour the same between as it's close enough
785
- deltaX = Math.round(deltaX * this.PIXELS_PER_LINE);
786
- deltaY = Math.round(deltaY * this.PIXELS_PER_LINE);
759
+ if (row < rowCount - floatingBottomRowCount) {
760
+ y2 -= floatingBottomHeight;
761
+ }
787
762
  }
763
+
764
+ return {
765
+ x: x,
766
+ y: y,
767
+ x2: x2,
768
+ y2: y2
769
+ };
788
770
  }
771
+ /**
772
+ * Converts the delta coordinates from the provided wheel event to pixels
773
+ * Different platforms have different ways of providing the delta so this normalizes it
774
+ * @param {WheelEvent} wheelEvent The mouse wheel event to get the scrolling delta for
775
+ * @param {number?} pageWidth The width of the page that is scrolling
776
+ * @param {number?} pageHeight The height of the page that is scrolling
777
+ * @param {number?} lineWidth The width of the line scrolling in line mode
778
+ * @param {number?} lineHeight The height of the line scrolling in line mode
779
+ * @returns {{deltaX:number, deltaY: number}} The delta coordinates normalized to pixels
780
+ */
781
+
782
+ }, {
783
+ key: "getScrollDelta",
784
+ value: function getScrollDelta(wheelEvent) {
785
+ var pageWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1024;
786
+ var pageHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 768;
787
+ var lineWidth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 20;
788
+ var lineHeight = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 20;
789
+ var deltaX = wheelEvent.deltaX,
790
+ deltaY = wheelEvent.deltaY; // Flip scroll direction if shiftKey is held on windows/linux.
791
+ // On mac, deltaX/Y values are switched at the event level when shiftKey=true.
792
+ // Guard on strictly Y only changing, to ignore trackpad diagonal motion,
793
+ // through that guard may not be necessary, but it is difficult to determine for
794
+ // all platforms/browser/scroll method combos.
795
+
796
+ if (!GridUtils.isMacPlatform() && wheelEvent.shiftKey && wheelEvent.deltaX === 0 && wheelEvent.deltaY !== 0) {
797
+ deltaX = wheelEvent.deltaY;
798
+ deltaY = wheelEvent.deltaX;
799
+ } // Normalize other deltaMode values to pixel units
800
+ // deltaMode 0, is already in pixel units
801
+
802
+
803
+ if ((wheelEvent === null || wheelEvent === void 0 ? void 0 : wheelEvent.deltaMode) === WheelEvent.DOM_DELTA_PAGE) {
804
+ // Users can set OS to be in deltaMode page
805
+ // scrolly by page units as pixels
806
+ deltaX *= pageWidth;
807
+ deltaY *= pageHeight;
808
+ } else if ((wheelEvent === null || wheelEvent === void 0 ? void 0 : wheelEvent.deltaMode) === WheelEvent.DOM_DELTA_LINE) {
809
+ // Firefox reports deltaMode line
810
+ // Normalize distance travelled between browsers
811
+ // but remain ~platform/browser combo consistent
812
+ if (GridUtils.isMacPlatform()) {
813
+ // for mac treat lines as a standard row height
814
+ // on mac, firefox travels less distance then chrome per tick
815
+ deltaX = Math.round(deltaX * lineWidth);
816
+ deltaY = Math.round(deltaY * lineHeight);
817
+ } else {
818
+ // for windows convert to pixels using the same method as chrome
819
+ // chrome goes 100 per 3 lines, and firefox would go 102 per 3 (17 lineheight * 3 lines * 2)
820
+ // make the behaviour the same between as it's close enough
821
+ deltaX = Math.round(deltaX * this.PIXELS_PER_LINE);
822
+ deltaY = Math.round(deltaY * this.PIXELS_PER_LINE);
823
+ }
824
+ }
789
825
 
790
- return {
791
- deltaX,
792
- deltaY
793
- };
794
- }
826
+ return {
827
+ deltaX: deltaX,
828
+ deltaY: deltaY
829
+ };
830
+ }
831
+ }]);
795
832
 
796
- }
833
+ return GridUtils;
834
+ }();
797
835
 
798
836
  _defineProperty(GridUtils, "PIXELS_PER_LINE", 100 / 3);
799
837