@deephaven/grid 0.22.3-beta.18 → 0.22.3-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CellInputField.d.ts +5 -5
- package/dist/CellInputField.d.ts.map +1 -1
- package/dist/CellInputField.js +6 -23
- package/dist/CellInputField.js.map +1 -1
- package/dist/EditableGridModel.js +1 -0
- package/dist/EditableGridModel.js.map +1 -1
- package/dist/ExpandableGridModel.js +1 -0
- package/dist/ExpandableGridModel.js.map +1 -1
- package/dist/Grid.js +77 -315
- package/dist/Grid.js.map +1 -1
- package/dist/GridAxisRange.js.map +1 -1
- package/dist/GridColorUtils.js +1 -2
- package/dist/GridColorUtils.js.map +1 -1
- package/dist/GridMetricCalculator.js +83 -240
- package/dist/GridMetricCalculator.js.map +1 -1
- package/dist/GridModel.js +13 -31
- package/dist/GridModel.js.map +1 -1
- package/dist/GridMouseHandler.js +2 -15
- package/dist/GridMouseHandler.js.map +1 -1
- package/dist/GridRange.js +46 -160
- package/dist/GridRange.js.map +1 -1
- package/dist/GridRenderer.js +126 -407
- package/dist/GridRenderer.js.map +1 -1
- package/dist/GridTestUtils.js +0 -5
- package/dist/GridTestUtils.js.map +1 -1
- package/dist/GridTheme.js.map +1 -1
- package/dist/GridUtils.js +68 -217
- package/dist/GridUtils.js.map +1 -1
- package/dist/KeyHandler.js +2 -8
- package/dist/KeyHandler.js.map +1 -1
- package/dist/MockGridData.js.map +1 -1
- package/dist/MockGridModel.js +0 -42
- package/dist/MockGridModel.js.map +1 -1
- package/dist/MockTreeGridModel.js +6 -55
- package/dist/MockTreeGridModel.js.map +1 -1
- package/dist/StaticDataGridModel.js +0 -15
- package/dist/StaticDataGridModel.js.map +1 -1
- package/dist/ThemeContext.js.map +1 -1
- package/dist/ViewportDataGridModel.js +0 -14
- package/dist/ViewportDataGridModel.js.map +1 -1
- package/dist/errors/AssertionError.js +0 -3
- package/dist/errors/AssertionError.js.map +1 -1
- package/dist/errors/PasteError.js +0 -3
- package/dist/errors/PasteError.js.map +1 -1
- package/dist/errors/assertIsDefined.js.map +1 -1
- package/dist/errors/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/key-handlers/EditKeyHandler.js +0 -12
- package/dist/key-handlers/EditKeyHandler.js.map +1 -1
- package/dist/key-handlers/PasteKeyHandler.js +15 -33
- package/dist/key-handlers/PasteKeyHandler.js.map +1 -1
- package/dist/key-handlers/SelectionKeyHandler.js +6 -53
- package/dist/key-handlers/SelectionKeyHandler.js.map +1 -1
- package/dist/key-handlers/TreeKeyHandler.js +0 -11
- package/dist/key-handlers/TreeKeyHandler.js.map +1 -1
- package/dist/key-handlers/index.js.map +1 -1
- package/dist/memoizeClear.js +1 -4
- package/dist/memoizeClear.js.map +1 -1
- package/dist/mouse-handlers/EditMouseHandler.js +0 -5
- package/dist/mouse-handlers/EditMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridColumnMoveMouseHandler.js +35 -123
- package/dist/mouse-handlers/GridColumnMoveMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.js +2 -27
- package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridHorizontalScrollBarMouseHandler.js +0 -28
- package/dist/mouse-handlers/GridHorizontalScrollBarMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowMoveMouseHandler.js +0 -27
- package/dist/mouse-handlers/GridRowMoveMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.js +0 -23
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowTreeMouseHandler.js +0 -10
- package/dist/mouse-handlers/GridRowTreeMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridScrollBarCornerMouseHandler.js +0 -6
- package/dist/mouse-handlers/GridScrollBarCornerMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridSelectionMouseHandler.js +8 -38
- package/dist/mouse-handlers/GridSelectionMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridSeparatorMouseHandler.js +5 -54
- package/dist/mouse-handlers/GridSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridVerticalScrollBarMouseHandler.js +0 -28
- package/dist/mouse-handlers/GridVerticalScrollBarMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/index.js.map +1 -1
- package/package.json +4 -4
package/dist/GridUtils.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
2
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
3
|
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; }
|
|
6
|
-
|
|
7
4
|
import clamp from 'lodash.clamp';
|
|
8
5
|
import GridRange from "./GridRange.js";
|
|
9
6
|
import { isBoundedAxisRange } from "./GridAxisRange.js";
|
|
@@ -30,7 +27,6 @@ export class GridUtils {
|
|
|
30
27
|
columnHeaderDepth
|
|
31
28
|
};
|
|
32
29
|
}
|
|
33
|
-
|
|
34
30
|
static getCellInfoFromXY(x, y, metrics) {
|
|
35
31
|
var {
|
|
36
32
|
row,
|
|
@@ -61,20 +57,18 @@ export class GridUtils {
|
|
|
61
57
|
rowHeight: rowHeight !== null && rowHeight !== void 0 ? rowHeight : null
|
|
62
58
|
};
|
|
63
59
|
}
|
|
64
|
-
|
|
65
60
|
static getColumnHeaderDepthAtY(y, metrics) {
|
|
66
61
|
var row = GridUtils.getRowAtY(y, metrics);
|
|
67
62
|
var {
|
|
68
63
|
columnHeaderHeight,
|
|
69
64
|
columnHeaderMaxDepth
|
|
70
65
|
} = metrics;
|
|
71
|
-
|
|
72
66
|
if (row === null && y <= columnHeaderHeight * columnHeaderMaxDepth) {
|
|
73
67
|
return clamp(columnHeaderMaxDepth - Math.ceil(y / columnHeaderHeight), 0, columnHeaderMaxDepth - 1);
|
|
74
68
|
}
|
|
75
|
-
|
|
76
69
|
return undefined;
|
|
77
70
|
}
|
|
71
|
+
|
|
78
72
|
/**
|
|
79
73
|
* Iterate through each floating item at the start and call a callback, returning the first result
|
|
80
74
|
* @param start The count of floating items at the start
|
|
@@ -82,19 +76,16 @@ export class GridUtils {
|
|
|
82
76
|
* @param callback Function to call for each item
|
|
83
77
|
* @returns The result from the callback
|
|
84
78
|
*/
|
|
85
|
-
|
|
86
|
-
|
|
87
79
|
static iterateFloatingStart(start, total, callback) {
|
|
88
80
|
for (var i = 0; i < start && i < total; i += 1) {
|
|
89
81
|
var result = callback(i);
|
|
90
|
-
|
|
91
82
|
if (result !== undefined) {
|
|
92
83
|
return result;
|
|
93
84
|
}
|
|
94
85
|
}
|
|
95
|
-
|
|
96
86
|
return undefined;
|
|
97
87
|
}
|
|
88
|
+
|
|
98
89
|
/**
|
|
99
90
|
* Iterate through floating items at the end. Iterates in increasing order.
|
|
100
91
|
* @param end The count of floating items at the end
|
|
@@ -102,19 +93,16 @@ export class GridUtils {
|
|
|
102
93
|
* @param callback Function to call for each item
|
|
103
94
|
* @returns The result from the callback
|
|
104
95
|
*/
|
|
105
|
-
|
|
106
|
-
|
|
107
96
|
static iterateFloatingEnd(end, total, callback) {
|
|
108
97
|
for (var i = 0; i < end && total - (end - i) >= 0; i += 1) {
|
|
109
98
|
var result = callback(total - (end - i));
|
|
110
|
-
|
|
111
99
|
if (result !== undefined) {
|
|
112
100
|
return result;
|
|
113
101
|
}
|
|
114
102
|
}
|
|
115
|
-
|
|
116
103
|
return undefined;
|
|
117
104
|
}
|
|
105
|
+
|
|
118
106
|
/**
|
|
119
107
|
* Iterate through all floating items in increasing order, starting with the top items.
|
|
120
108
|
* @param start Count of start floating rows, e.g. floatingTopRowCount
|
|
@@ -122,17 +110,14 @@ export class GridUtils {
|
|
|
122
110
|
* @param total Total number of items
|
|
123
111
|
* @param callback Callback called for each value, stopping the iterating and returning the value if one is returned
|
|
124
112
|
*/
|
|
125
|
-
|
|
126
|
-
|
|
127
113
|
static iterateFloating(start, end, total, callback) {
|
|
128
114
|
var result = GridUtils.iterateFloatingStart(start, total, callback);
|
|
129
|
-
|
|
130
115
|
if (result !== undefined) {
|
|
131
116
|
return result;
|
|
132
117
|
}
|
|
133
|
-
|
|
134
118
|
return GridUtils.iterateFloatingEnd(end, total, callback);
|
|
135
119
|
}
|
|
120
|
+
|
|
136
121
|
/**
|
|
137
122
|
* Iterate through all items in one dimension on the grid - first floating, then visible.
|
|
138
123
|
* Call the callback for each item, break if a result is returned and return that result.
|
|
@@ -144,27 +129,22 @@ export class GridUtils {
|
|
|
144
129
|
* @param callback Callback to call for each item
|
|
145
130
|
* @returns The first result from the callback called, or undefined
|
|
146
131
|
*/
|
|
147
|
-
|
|
148
|
-
|
|
149
132
|
static iterateAllItems(visibleStart, visibleEnd, floatingStartCount, floatingEndCount, totalCount, callback) {
|
|
150
133
|
var visibleStartIndex = Math.max(visibleStart, floatingStartCount);
|
|
151
134
|
var visibleEndIndex = Math.min(visibleEnd, totalCount - floatingEndCount - 1);
|
|
152
135
|
var result = GridUtils.iterateFloating(floatingStartCount, floatingEndCount, totalCount, callback);
|
|
153
|
-
|
|
154
136
|
if (result !== undefined) {
|
|
155
137
|
return result;
|
|
156
138
|
}
|
|
157
|
-
|
|
158
139
|
for (var i = visibleStartIndex; i <= visibleEndIndex; i += 1) {
|
|
159
140
|
result = callback(i);
|
|
160
|
-
|
|
161
141
|
if (result !== undefined) {
|
|
162
142
|
return result;
|
|
163
143
|
}
|
|
164
144
|
}
|
|
165
|
-
|
|
166
145
|
return undefined;
|
|
167
146
|
}
|
|
147
|
+
|
|
168
148
|
/**
|
|
169
149
|
* Check if the coordinate is within the item specified in this dimension
|
|
170
150
|
* @param itemIndex Index of the item to check
|
|
@@ -173,15 +153,13 @@ export class GridUtils {
|
|
|
173
153
|
* @param coordinate The coordinate to check
|
|
174
154
|
* @returns True if the coordinate is within the item specified, false otherwise
|
|
175
155
|
*/
|
|
176
|
-
|
|
177
|
-
|
|
178
156
|
static isInItem(itemIndex, itemCoordinates, itemSizes, coordinate) {
|
|
179
157
|
var _itemCoordinates$get, _itemSizes$get;
|
|
180
|
-
|
|
181
158
|
var itemX = (_itemCoordinates$get = itemCoordinates.get(itemIndex)) !== null && _itemCoordinates$get !== void 0 ? _itemCoordinates$get : 0;
|
|
182
159
|
var itemSize = (_itemSizes$get = itemSizes.get(itemIndex)) !== null && _itemSizes$get !== void 0 ? _itemSizes$get : 0;
|
|
183
160
|
return itemX <= coordinate && coordinate <= itemX + itemSize;
|
|
184
161
|
}
|
|
162
|
+
|
|
185
163
|
/**
|
|
186
164
|
* Get the Index of the item at the provided offset
|
|
187
165
|
* @param offset Coordinate of the offset to get the item of
|
|
@@ -193,40 +171,32 @@ export class GridUtils {
|
|
|
193
171
|
* @param itemSizes The size of each item
|
|
194
172
|
* @returns The item index, or null if no item matches
|
|
195
173
|
*/
|
|
196
|
-
|
|
197
|
-
|
|
198
174
|
static getItemAtOffset(offset, itemCount, floatingStart, floatingEnd, items, itemCoordinates, itemSizes) {
|
|
199
175
|
var ignoreFloating = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
200
176
|
var floatingItem = ignoreFloating ? undefined : GridUtils.iterateFloating(floatingStart, floatingEnd, itemCount, item => {
|
|
201
177
|
if (GridUtils.isInItem(item, itemCoordinates, itemSizes, offset)) {
|
|
202
178
|
return item;
|
|
203
179
|
}
|
|
204
|
-
|
|
205
180
|
return undefined;
|
|
206
181
|
});
|
|
207
|
-
|
|
208
182
|
if (!ignoreFloating && floatingItem !== undefined) {
|
|
209
183
|
return floatingItem;
|
|
210
184
|
}
|
|
211
|
-
|
|
212
185
|
for (var i = 0; i < items.length; i += 1) {
|
|
213
186
|
var item = items[i];
|
|
214
|
-
|
|
215
187
|
if (GridUtils.isInItem(item, itemCoordinates, itemSizes, offset)) {
|
|
216
188
|
return item;
|
|
217
189
|
}
|
|
218
190
|
}
|
|
219
|
-
|
|
220
191
|
return null;
|
|
221
192
|
}
|
|
193
|
+
|
|
222
194
|
/**
|
|
223
195
|
* Get the index of the column at the specified x coordinate
|
|
224
196
|
* @param x Coordinate to get the item of
|
|
225
197
|
* @param metrics Grid metrics
|
|
226
198
|
* @returns Index of the column at that coordinate, or null if no column matches
|
|
227
199
|
*/
|
|
228
|
-
|
|
229
|
-
|
|
230
200
|
static getColumnAtX(x, metrics) {
|
|
231
201
|
var ignoreFloating = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
232
202
|
var {
|
|
@@ -238,21 +208,18 @@ export class GridUtils {
|
|
|
238
208
|
visibleColumnWidths,
|
|
239
209
|
gridX
|
|
240
210
|
} = metrics;
|
|
241
|
-
|
|
242
211
|
if (x < gridX) {
|
|
243
212
|
return null;
|
|
244
213
|
}
|
|
245
|
-
|
|
246
214
|
return this.getItemAtOffset(x - gridX, columnCount, floatingLeftColumnCount, floatingRightColumnCount, visibleColumns, visibleColumnXs, visibleColumnWidths, ignoreFloating);
|
|
247
215
|
}
|
|
216
|
+
|
|
248
217
|
/**
|
|
249
218
|
* Get the index of the row at the specified y coordinate
|
|
250
219
|
* @param y Coordinate to get the item of
|
|
251
220
|
* @param metrics Grid metrics
|
|
252
221
|
* @returns Index of the row at that coordinate, or null if no row matches
|
|
253
222
|
*/
|
|
254
|
-
|
|
255
|
-
|
|
256
223
|
static getRowAtY(y, metrics) {
|
|
257
224
|
var {
|
|
258
225
|
floatingTopRowCount,
|
|
@@ -263,13 +230,12 @@ export class GridUtils {
|
|
|
263
230
|
visibleRowHeights,
|
|
264
231
|
gridY
|
|
265
232
|
} = metrics;
|
|
266
|
-
|
|
267
233
|
if (y < gridY) {
|
|
268
234
|
return null;
|
|
269
235
|
}
|
|
270
|
-
|
|
271
236
|
return this.getItemAtOffset(y - gridY, rowCount, floatingTopRowCount, floatingBottomRowCount, visibleRows, visibleRowYs, visibleRowHeights);
|
|
272
237
|
}
|
|
238
|
+
|
|
273
239
|
/**
|
|
274
240
|
* Iterate backward through the visible items until a shown item is hit
|
|
275
241
|
* @param startIndex The index to start from
|
|
@@ -278,33 +244,26 @@ export class GridUtils {
|
|
|
278
244
|
* @param userSizes The user set sizes
|
|
279
245
|
* @returns Index of the next visible item, or null if no more are visible
|
|
280
246
|
*/
|
|
281
|
-
|
|
282
|
-
|
|
283
247
|
static getNextShownItem(startIndex, modelIndexes, visibleItems, userSizes) {
|
|
284
248
|
var visibleItemIndex = visibleItems.findIndex(value => value === startIndex) || 0;
|
|
285
249
|
visibleItemIndex -= 1;
|
|
286
|
-
|
|
287
250
|
while (visibleItemIndex != null && visibleItemIndex >= 0) {
|
|
288
251
|
var item = visibleItems[visibleItemIndex];
|
|
289
252
|
var modelIndex = modelIndexes.get(item);
|
|
290
|
-
|
|
291
253
|
if (modelIndex != null && userSizes.get(modelIndex) !== 0) {
|
|
292
254
|
return item;
|
|
293
255
|
}
|
|
294
|
-
|
|
295
256
|
visibleItemIndex -= 1;
|
|
296
257
|
}
|
|
297
|
-
|
|
298
258
|
return null;
|
|
299
259
|
}
|
|
260
|
+
|
|
300
261
|
/**
|
|
301
262
|
* Iterate backward through the visible columns until a shown column is hit
|
|
302
263
|
* @param columnIndex The column index to start iterating backward from
|
|
303
264
|
* @param metrics The GridMetricCalculator metrics
|
|
304
265
|
* @returns Index of the next visible item, or null if no more are visible
|
|
305
266
|
*/
|
|
306
|
-
|
|
307
|
-
|
|
308
267
|
static getNextShownColumn(startIndex, metrics) {
|
|
309
268
|
var {
|
|
310
269
|
modelColumns,
|
|
@@ -313,14 +272,13 @@ export class GridUtils {
|
|
|
313
272
|
} = metrics;
|
|
314
273
|
return GridUtils.getNextShownItem(startIndex, modelColumns, visibleColumns, userColumnWidths);
|
|
315
274
|
}
|
|
275
|
+
|
|
316
276
|
/**
|
|
317
277
|
* Iterate backward through the visible rows until a shown row is hit
|
|
318
278
|
* @param rowIndex The row index to start iterating backward from
|
|
319
279
|
* @param metrics The GridMetricCalculator metrics
|
|
320
280
|
* @returns Index of the next visible item, or null if no more are visible
|
|
321
281
|
*/
|
|
322
|
-
|
|
323
|
-
|
|
324
282
|
static getNextShownRow(startIndex, metrics) {
|
|
325
283
|
var {
|
|
326
284
|
modelRows,
|
|
@@ -329,6 +287,7 @@ export class GridUtils {
|
|
|
329
287
|
} = metrics;
|
|
330
288
|
return GridUtils.getNextShownItem(startIndex, modelRows, visibleRows, userRowHeights);
|
|
331
289
|
}
|
|
290
|
+
|
|
332
291
|
/**
|
|
333
292
|
* Gets the column index if the x/y coordinates provided are close enough to the separator, otherwise null
|
|
334
293
|
* @param x Mouse x coordinate
|
|
@@ -337,8 +296,6 @@ export class GridUtils {
|
|
|
337
296
|
* @param theme The grid theme with potential user overrides
|
|
338
297
|
* @returns Index of the column separator at the coordinates provided, or null if none match
|
|
339
298
|
*/
|
|
340
|
-
|
|
341
|
-
|
|
342
299
|
static getColumnSeparatorIndex(x, y, metrics, theme) {
|
|
343
300
|
var {
|
|
344
301
|
rowHeaderWidth,
|
|
@@ -354,124 +311,100 @@ export class GridUtils {
|
|
|
354
311
|
allowColumnResize,
|
|
355
312
|
headerSeparatorHandleSize
|
|
356
313
|
} = theme;
|
|
357
|
-
|
|
358
314
|
if (columnHeaderMaxDepth * columnHeaderHeight < y || !allowColumnResize || headerSeparatorHandleSize <= 0) {
|
|
359
315
|
return null;
|
|
360
316
|
}
|
|
361
|
-
|
|
362
317
|
var gridX = x - rowHeaderWidth;
|
|
363
|
-
var halfSeparatorSize = headerSeparatorHandleSize * 0.5;
|
|
318
|
+
var halfSeparatorSize = headerSeparatorHandleSize * 0.5;
|
|
364
319
|
|
|
320
|
+
// Iterate through the floating columns first since they're on top
|
|
365
321
|
var isPreviousColumnHidden = false;
|
|
366
|
-
|
|
367
322
|
for (var i = floatingColumns.length - 1; i >= 0; i -= 1) {
|
|
368
323
|
var _visibleColumnXs$get, _visibleColumnWidths$;
|
|
369
|
-
|
|
370
324
|
var column = floatingColumns[i];
|
|
371
325
|
var columnX = (_visibleColumnXs$get = visibleColumnXs.get(column)) !== null && _visibleColumnXs$get !== void 0 ? _visibleColumnXs$get : 0;
|
|
372
326
|
var columnWidth = (_visibleColumnWidths$ = visibleColumnWidths.get(column)) !== null && _visibleColumnWidths$ !== void 0 ? _visibleColumnWidths$ : 0;
|
|
373
327
|
var isColumnHidden = columnWidth === 0;
|
|
374
|
-
|
|
375
328
|
if (!isPreviousColumnHidden || !isColumnHidden) {
|
|
376
329
|
var midX = columnX + columnWidth;
|
|
377
|
-
|
|
378
330
|
if (isColumnHidden) {
|
|
379
331
|
midX += halfSeparatorSize;
|
|
380
332
|
} else if (isPreviousColumnHidden) {
|
|
381
333
|
midX -= halfSeparatorSize;
|
|
382
334
|
}
|
|
383
|
-
|
|
384
335
|
var minX = midX - halfSeparatorSize;
|
|
385
336
|
var maxX = midX + halfSeparatorSize;
|
|
386
|
-
|
|
387
337
|
if (minX <= gridX && gridX <= maxX) {
|
|
388
338
|
return column;
|
|
389
339
|
}
|
|
390
|
-
|
|
391
340
|
isPreviousColumnHidden = isColumnHidden;
|
|
392
341
|
}
|
|
393
|
-
}
|
|
394
|
-
|
|
342
|
+
}
|
|
395
343
|
|
|
344
|
+
// Iterate backward so that you can reveal hidden columns properly
|
|
396
345
|
isPreviousColumnHidden = false;
|
|
397
|
-
|
|
398
346
|
for (var _i = visibleColumns.length - 1; _i >= 0; _i -= 1) {
|
|
399
347
|
var _visibleColumnXs$get2, _visibleColumnWidths$2;
|
|
400
|
-
|
|
401
348
|
var _column = visibleColumns[_i];
|
|
402
|
-
|
|
403
349
|
var _columnX = (_visibleColumnXs$get2 = visibleColumnXs.get(_column)) !== null && _visibleColumnXs$get2 !== void 0 ? _visibleColumnXs$get2 : 0;
|
|
404
|
-
|
|
405
350
|
var _columnWidth = (_visibleColumnWidths$2 = visibleColumnWidths.get(_column)) !== null && _visibleColumnWidths$2 !== void 0 ? _visibleColumnWidths$2 : 0;
|
|
351
|
+
var _isColumnHidden = _columnWidth === 0;
|
|
406
352
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
353
|
+
// If this column is under the floating columns "layer". Terminate early.
|
|
410
354
|
if (_columnX < floatingLeftWidth - _columnWidth) {
|
|
411
355
|
return null;
|
|
412
356
|
}
|
|
413
|
-
|
|
414
357
|
if (!isPreviousColumnHidden || !_isColumnHidden) {
|
|
415
358
|
var _midX = _columnX + _columnWidth;
|
|
416
|
-
|
|
417
359
|
if (_isColumnHidden) {
|
|
418
360
|
_midX += halfSeparatorSize;
|
|
419
361
|
} else if (isPreviousColumnHidden) {
|
|
420
362
|
_midX -= halfSeparatorSize;
|
|
421
363
|
}
|
|
422
|
-
|
|
423
364
|
var _minX = _midX - halfSeparatorSize;
|
|
424
|
-
|
|
425
365
|
var _maxX = _midX + halfSeparatorSize;
|
|
426
|
-
|
|
427
366
|
if (_minX <= gridX && gridX <= _maxX) {
|
|
428
367
|
return _column;
|
|
429
368
|
}
|
|
430
|
-
|
|
431
369
|
isPreviousColumnHidden = _isColumnHidden;
|
|
432
370
|
}
|
|
433
371
|
}
|
|
434
|
-
|
|
435
372
|
return null;
|
|
436
373
|
}
|
|
374
|
+
|
|
437
375
|
/**
|
|
438
376
|
* Check if the item specified is hidden
|
|
439
377
|
* @param itemIndex Index of the item to check
|
|
440
378
|
* @param visibleSizes Sizes of all visible items
|
|
441
379
|
* @returns True if the item is hidden, false otherwise
|
|
442
380
|
*/
|
|
443
|
-
|
|
444
|
-
|
|
445
381
|
static isItemHidden(itemIndex, visibleSizes) {
|
|
446
382
|
return visibleSizes.get(itemIndex) === 0;
|
|
447
383
|
}
|
|
384
|
+
|
|
448
385
|
/**
|
|
449
386
|
* Check if the column specified is hidden
|
|
450
387
|
* @param columnIndex Index of the column to check
|
|
451
388
|
* @param metrics Grid metrics
|
|
452
389
|
* @returns True if the column is hidden, false otherwise
|
|
453
390
|
*/
|
|
454
|
-
|
|
455
|
-
|
|
456
391
|
static isColumnHidden(columnIndex, metrics) {
|
|
457
392
|
var {
|
|
458
393
|
visibleColumnWidths
|
|
459
394
|
} = metrics;
|
|
460
395
|
return GridUtils.isItemHidden(columnIndex, visibleColumnWidths);
|
|
461
396
|
}
|
|
397
|
+
|
|
462
398
|
/**
|
|
463
399
|
* Check if the provided row is a floating row
|
|
464
400
|
* @param row The row index to check
|
|
465
401
|
* @param metrics The grid metrics to check against
|
|
466
402
|
* @returns True if it's a floating row, false otherwise
|
|
467
403
|
*/
|
|
468
|
-
|
|
469
|
-
|
|
470
404
|
static isFloatingRow(row, metrics) {
|
|
471
405
|
if (row == null) {
|
|
472
406
|
return false;
|
|
473
407
|
}
|
|
474
|
-
|
|
475
408
|
var {
|
|
476
409
|
floatingTopRowCount,
|
|
477
410
|
floatingBottomRowCount,
|
|
@@ -479,19 +412,17 @@ export class GridUtils {
|
|
|
479
412
|
} = metrics;
|
|
480
413
|
return row < floatingTopRowCount || row >= rowCount - floatingBottomRowCount;
|
|
481
414
|
}
|
|
415
|
+
|
|
482
416
|
/**
|
|
483
417
|
* Check if the provided column is a floating column
|
|
484
418
|
* @param column The column index to check
|
|
485
419
|
* @param metrics The grid metrics to check against
|
|
486
420
|
* @returns True if it's a floating column, false otherwise
|
|
487
421
|
*/
|
|
488
|
-
|
|
489
|
-
|
|
490
422
|
static isFloatingColumn(column, metrics) {
|
|
491
423
|
if (column == null) {
|
|
492
424
|
return false;
|
|
493
425
|
}
|
|
494
|
-
|
|
495
426
|
var {
|
|
496
427
|
floatingLeftColumnCount,
|
|
497
428
|
floatingRightColumnCount,
|
|
@@ -499,6 +430,7 @@ export class GridUtils {
|
|
|
499
430
|
} = metrics;
|
|
500
431
|
return column < floatingLeftColumnCount || column >= columnCount - floatingRightColumnCount;
|
|
501
432
|
}
|
|
433
|
+
|
|
502
434
|
/**
|
|
503
435
|
* Get all the items that are hidden under the same Index
|
|
504
436
|
* E.g. If columns are 1, 2, 3, 4, 5, and column 2, 3, 4 are hidden, and we check for item 4, the return will be [2, 3, 4]
|
|
@@ -507,36 +439,28 @@ export class GridUtils {
|
|
|
507
439
|
* @param visibleItems Visible items
|
|
508
440
|
* @returns Array of items that are hidden
|
|
509
441
|
*/
|
|
510
|
-
|
|
511
|
-
|
|
512
442
|
static getHiddenItems(itemIndex, visibleSizes, visibleItems) {
|
|
513
443
|
if (!GridUtils.isItemHidden(itemIndex, visibleSizes)) {
|
|
514
444
|
return [];
|
|
515
445
|
}
|
|
516
|
-
|
|
517
446
|
var hiddenItems = [itemIndex];
|
|
518
447
|
var visibleItemIndex = visibleItems.findIndex(value => value === itemIndex);
|
|
519
|
-
|
|
520
448
|
for (var i = visibleItemIndex - 1; i >= 0; i -= 1) {
|
|
521
449
|
var item = visibleItems[i];
|
|
522
|
-
|
|
523
450
|
if (!GridUtils.isItemHidden(item, visibleSizes)) {
|
|
524
451
|
break;
|
|
525
452
|
}
|
|
526
|
-
|
|
527
453
|
hiddenItems.push(item);
|
|
528
454
|
}
|
|
529
|
-
|
|
530
455
|
return hiddenItems;
|
|
531
456
|
}
|
|
457
|
+
|
|
532
458
|
/**
|
|
533
459
|
* Get all the columns that are hidden under the same Index
|
|
534
460
|
* @param columnIndex Index of the item to start at
|
|
535
461
|
* @param metrics Grid metrics
|
|
536
462
|
* @returns Array of items that are hidden
|
|
537
463
|
*/
|
|
538
|
-
|
|
539
|
-
|
|
540
464
|
static getHiddenColumns(columnIndex, metrics) {
|
|
541
465
|
var {
|
|
542
466
|
visibleColumns,
|
|
@@ -544,6 +468,7 @@ export class GridUtils {
|
|
|
544
468
|
} = metrics;
|
|
545
469
|
return GridUtils.getHiddenItems(columnIndex, visibleColumnWidths, visibleColumns);
|
|
546
470
|
}
|
|
471
|
+
|
|
547
472
|
/**
|
|
548
473
|
* Returns the row index if the x/y coordinates provided are close enough to the separator, otherwise null
|
|
549
474
|
* @param x X coordinate to check
|
|
@@ -552,8 +477,6 @@ export class GridUtils {
|
|
|
552
477
|
* @param theme The grid theme
|
|
553
478
|
* @returns Index of the row separator at the coordinates provided, or null if none match
|
|
554
479
|
*/
|
|
555
|
-
|
|
556
|
-
|
|
557
480
|
static getRowSeparatorIndex(x, y, metrics, theme) {
|
|
558
481
|
var {
|
|
559
482
|
rowHeaderWidth,
|
|
@@ -566,68 +489,57 @@ export class GridUtils {
|
|
|
566
489
|
allowRowResize,
|
|
567
490
|
headerSeparatorHandleSize
|
|
568
491
|
} = theme;
|
|
569
|
-
|
|
570
492
|
if (rowHeaderWidth < x || !allowRowResize || headerSeparatorHandleSize <= 0) {
|
|
571
493
|
return null;
|
|
572
494
|
}
|
|
573
|
-
|
|
574
495
|
var gridY = y - columnHeaderHeight;
|
|
575
|
-
var halfSeparatorSize = headerSeparatorHandleSize * 0.5;
|
|
496
|
+
var halfSeparatorSize = headerSeparatorHandleSize * 0.5;
|
|
576
497
|
|
|
498
|
+
// Iterate backward so you can reveal hidden rows properly
|
|
577
499
|
var isPreviousRowHidden = false;
|
|
578
|
-
|
|
579
500
|
for (var i = visibleRows.length - 1; i >= 0; i -= 1) {
|
|
580
501
|
var _visibleRowYs$get, _visibleRowHeights$ge;
|
|
581
|
-
|
|
582
502
|
var row = visibleRows[i];
|
|
583
503
|
var rowY = (_visibleRowYs$get = visibleRowYs.get(row)) !== null && _visibleRowYs$get !== void 0 ? _visibleRowYs$get : 0;
|
|
584
504
|
var rowHeight = (_visibleRowHeights$ge = visibleRowHeights.get(row)) !== null && _visibleRowHeights$ge !== void 0 ? _visibleRowHeights$ge : 0;
|
|
585
505
|
var isRowHidden = rowHeight === 0;
|
|
586
|
-
|
|
587
506
|
if (!isPreviousRowHidden || !isRowHidden) {
|
|
588
507
|
var midY = rowY + rowHeight;
|
|
589
|
-
|
|
590
508
|
if (isRowHidden) {
|
|
591
509
|
midY += halfSeparatorSize;
|
|
592
510
|
} else if (isPreviousRowHidden) {
|
|
593
511
|
midY -= halfSeparatorSize;
|
|
594
512
|
}
|
|
595
|
-
|
|
596
513
|
var minY = midY - halfSeparatorSize;
|
|
597
514
|
var maxY = midY + halfSeparatorSize;
|
|
598
|
-
|
|
599
515
|
if (minY <= gridY && gridY <= maxY) {
|
|
600
516
|
return row;
|
|
601
517
|
}
|
|
602
|
-
|
|
603
518
|
isPreviousRowHidden = isRowHidden;
|
|
604
519
|
}
|
|
605
520
|
}
|
|
606
|
-
|
|
607
521
|
return null;
|
|
608
522
|
}
|
|
523
|
+
|
|
609
524
|
/**
|
|
610
525
|
* Check if the row specified is hidden
|
|
611
526
|
* @param rowIndex Index of the row to check
|
|
612
527
|
* @param metrics Grid metrics
|
|
613
528
|
* @returns True if the row is hidden, false otherwise
|
|
614
529
|
*/
|
|
615
|
-
|
|
616
|
-
|
|
617
530
|
static isRowHidden(rowIndex, metrics) {
|
|
618
531
|
var {
|
|
619
532
|
visibleRowHeights
|
|
620
533
|
} = metrics;
|
|
621
534
|
return GridUtils.isItemHidden(rowIndex, visibleRowHeights);
|
|
622
535
|
}
|
|
536
|
+
|
|
623
537
|
/**
|
|
624
538
|
* Get all the rows that are hidden under the same Index
|
|
625
539
|
* @param rowIndex Index of the item to start at
|
|
626
540
|
* @param metrics Grid metrics
|
|
627
541
|
* @returns Array of items that are hidden
|
|
628
542
|
*/
|
|
629
|
-
|
|
630
|
-
|
|
631
543
|
static getHiddenRows(rowIndex, metrics) {
|
|
632
544
|
var {
|
|
633
545
|
visibleRows,
|
|
@@ -635,6 +547,7 @@ export class GridUtils {
|
|
|
635
547
|
} = metrics;
|
|
636
548
|
return GridUtils.getHiddenItems(rowIndex, visibleRowHeights, visibleRows);
|
|
637
549
|
}
|
|
550
|
+
|
|
638
551
|
/**
|
|
639
552
|
* Set a new order for items in the grid
|
|
640
553
|
* @param from The visible index to move from
|
|
@@ -642,17 +555,15 @@ export class GridUtils {
|
|
|
642
555
|
* @param oldMovedItems The old reordered items
|
|
643
556
|
* @returns The new reordered items
|
|
644
557
|
*/
|
|
645
|
-
|
|
646
|
-
|
|
647
558
|
static moveItem(from, to, oldMovedItems) {
|
|
648
559
|
if (from === to) {
|
|
649
560
|
return oldMovedItems;
|
|
650
561
|
}
|
|
651
|
-
|
|
652
562
|
var movedItems = [...oldMovedItems];
|
|
653
|
-
var lastMovedItem = movedItems[movedItems.length - 1];
|
|
654
|
-
// E.g. 1 -> 2, 2 -> 3 can just be 1 -> 3
|
|
563
|
+
var lastMovedItem = movedItems[movedItems.length - 1];
|
|
655
564
|
|
|
565
|
+
// Check if we should combine with the previous move
|
|
566
|
+
// E.g. 1 -> 2, 2 -> 3 can just be 1 -> 3
|
|
656
567
|
if (lastMovedItem != null && !isBoundedAxisRange(lastMovedItem.from) && lastMovedItem.to === from) {
|
|
657
568
|
// Remove the move if it is now a no-op
|
|
658
569
|
if (lastMovedItem.from === to) {
|
|
@@ -668,9 +579,9 @@ export class GridUtils {
|
|
|
668
579
|
to
|
|
669
580
|
});
|
|
670
581
|
}
|
|
671
|
-
|
|
672
582
|
return movedItems;
|
|
673
583
|
}
|
|
584
|
+
|
|
674
585
|
/**
|
|
675
586
|
* Move a visible range in the grid
|
|
676
587
|
*
|
|
@@ -683,17 +594,15 @@ export class GridUtils {
|
|
|
683
594
|
* @param oldMovedItems The old reordered items
|
|
684
595
|
* @returns The new reordered items
|
|
685
596
|
*/
|
|
686
|
-
|
|
687
|
-
|
|
688
597
|
static moveRange(from, to, oldMovedItems) {
|
|
689
598
|
if (from[0] === to) {
|
|
690
599
|
return oldMovedItems;
|
|
691
600
|
}
|
|
692
|
-
|
|
693
601
|
var movedItems = [...oldMovedItems];
|
|
694
|
-
var lastMovedItem = movedItems[movedItems.length - 1];
|
|
695
|
-
// E.g. [1, 2] -> 2, [2, 3] -> 3 can just be [1, 2] -> 3
|
|
602
|
+
var lastMovedItem = movedItems[movedItems.length - 1];
|
|
696
603
|
|
|
604
|
+
// Check if we should combine with the previous move
|
|
605
|
+
// E.g. [1, 2] -> 2, [2, 3] -> 3 can just be [1, 2] -> 3
|
|
697
606
|
if (lastMovedItem != null && isBoundedAxisRange(lastMovedItem.from) && lastMovedItem.from[1] - lastMovedItem.from[0] === from[1] - from[0] && lastMovedItem.to === from[0]) {
|
|
698
607
|
// Remove the move if it is now a no-op
|
|
699
608
|
if (lastMovedItem.from[0] === to) {
|
|
@@ -708,15 +617,15 @@ export class GridUtils {
|
|
|
708
617
|
from,
|
|
709
618
|
to
|
|
710
619
|
});
|
|
711
|
-
}
|
|
712
|
-
|
|
620
|
+
}
|
|
713
621
|
|
|
622
|
+
// Remove the move if it is now a no-op
|
|
714
623
|
if (movedItems[movedItems.length - 1].from === movedItems[movedItems.length - 1].to) {
|
|
715
624
|
movedItems.pop();
|
|
716
625
|
}
|
|
717
|
-
|
|
718
626
|
return movedItems;
|
|
719
627
|
}
|
|
628
|
+
|
|
720
629
|
/**
|
|
721
630
|
* Applies the items moves to the AxisRange
|
|
722
631
|
* @param start The start index of the range
|
|
@@ -725,12 +634,9 @@ export class GridUtils {
|
|
|
725
634
|
* @param reverse If the moved items should be applied in reverse (this reverses the effects of the moves)
|
|
726
635
|
* @returns A list of AxisRanges in the translated space. Possibly multiple non-continuous ranges
|
|
727
636
|
*/
|
|
728
|
-
|
|
729
|
-
|
|
730
637
|
static applyItemMoves(start, end, movedItems) {
|
|
731
638
|
var reverse = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
732
639
|
var result = [[start, end]];
|
|
733
|
-
|
|
734
640
|
var _loop = function _loop(i) {
|
|
735
641
|
var {
|
|
736
642
|
from: fromItemOrRange,
|
|
@@ -738,30 +644,26 @@ export class GridUtils {
|
|
|
738
644
|
} = movedItems[i];
|
|
739
645
|
var length = 1;
|
|
740
646
|
var fromItem = void 0;
|
|
741
|
-
|
|
742
647
|
if (isBoundedAxisRange(fromItemOrRange)) {
|
|
743
648
|
length = fromItemOrRange[1] - fromItemOrRange[0] + 1; // Ranges are inclusive
|
|
744
|
-
|
|
745
649
|
[fromItem] = fromItemOrRange;
|
|
746
650
|
} else {
|
|
747
651
|
fromItem = fromItemOrRange;
|
|
748
652
|
}
|
|
749
|
-
|
|
750
653
|
var fromStart = reverse ? toItem : fromItem;
|
|
751
654
|
var fromEnd = fromStart + length - 1;
|
|
752
655
|
var toStart = reverse ? fromItem : toItem;
|
|
753
656
|
var moveDistance = toStart - fromStart;
|
|
754
657
|
var nextResult = [];
|
|
755
|
-
|
|
756
658
|
var _loop2 = function _loop2(j) {
|
|
757
659
|
var _result$j$, _result$j$2;
|
|
758
|
-
|
|
759
660
|
var currentStart = (_result$j$ = result[j][0]) !== null && _result$j$ !== void 0 ? _result$j$ : Number.NEGATIVE_INFINITY;
|
|
760
661
|
var currentEnd = (_result$j$2 = result[j][1]) !== null && _result$j$2 !== void 0 ? _result$j$2 : Number.POSITIVE_INFINITY;
|
|
761
662
|
var movedRange = void 0;
|
|
762
663
|
var currentResult = [[currentStart, fromStart - 1], [fromStart, fromEnd], [fromEnd + 1, currentEnd]].map(_ref2 => {
|
|
763
664
|
var [s, e] = _ref2;
|
|
764
|
-
return [
|
|
665
|
+
return [
|
|
666
|
+
// Cap the ranges to within the current range bounds
|
|
765
667
|
Math.max(s, currentStart), Math.min(e, currentEnd)];
|
|
766
668
|
}).filter(_ref3 => {
|
|
767
669
|
var [s, e] = _ref3;
|
|
@@ -769,59 +671,50 @@ export class GridUtils {
|
|
|
769
671
|
}) // Remove invalid ranges
|
|
770
672
|
.map(range => {
|
|
771
673
|
var [s, e] = range;
|
|
772
|
-
|
|
773
674
|
if (fromStart <= s && fromEnd >= e) {
|
|
774
675
|
// Current range in moved range
|
|
775
676
|
movedRange = [s + moveDistance, e + moveDistance];
|
|
776
677
|
return movedRange;
|
|
777
678
|
}
|
|
778
|
-
|
|
779
679
|
if (fromEnd < s) {
|
|
780
680
|
// Current range is after moved range
|
|
781
681
|
return [s - length, e - length];
|
|
782
682
|
}
|
|
783
|
-
|
|
784
683
|
return range;
|
|
785
684
|
}).map(range => {
|
|
786
685
|
var [s, e] = range;
|
|
787
|
-
|
|
788
686
|
if (toStart > s && toStart <= e) {
|
|
789
687
|
// Moved range splits this range
|
|
790
688
|
return [[s, toStart - 1], [toStart + length, e + length]];
|
|
791
689
|
}
|
|
792
|
-
|
|
793
690
|
if (range === movedRange) {
|
|
794
691
|
// Moved range has already been shifted
|
|
795
692
|
return [range];
|
|
796
693
|
}
|
|
797
|
-
|
|
798
694
|
if (toStart <= s) {
|
|
799
695
|
// Moved range shifts this range right
|
|
800
696
|
return [[s + length, e + length]];
|
|
801
697
|
}
|
|
802
|
-
|
|
803
698
|
return [range];
|
|
804
699
|
}).flat();
|
|
805
700
|
nextResult.push(...currentResult);
|
|
806
701
|
};
|
|
807
|
-
|
|
808
702
|
for (var j = 0; j < result.length; j += 1) {
|
|
809
703
|
_loop2(j);
|
|
810
|
-
}
|
|
811
|
-
|
|
704
|
+
}
|
|
812
705
|
|
|
706
|
+
// Return infinity values back to null
|
|
813
707
|
result = nextResult.map(_ref => {
|
|
814
708
|
var [s, e] = _ref;
|
|
815
709
|
return [Number.isFinite(s) ? s : null, Number.isFinite(e) ? e : null];
|
|
816
710
|
});
|
|
817
711
|
};
|
|
818
|
-
|
|
819
712
|
for (var i = reverse ? movedItems.length - 1 : 0; reverse ? i >= 0 : i < movedItems.length; reverse ? i -= 1 : i += 1) {
|
|
820
713
|
_loop(i);
|
|
821
714
|
}
|
|
822
|
-
|
|
823
715
|
return result;
|
|
824
716
|
}
|
|
717
|
+
|
|
825
718
|
/**
|
|
826
719
|
* Applies the items moves to the givengrid range
|
|
827
720
|
* @param range The grid range to translate
|
|
@@ -830,47 +723,41 @@ export class GridUtils {
|
|
|
830
723
|
* @param reverse If the moved items should be reversed (i.e. visible to model range)
|
|
831
724
|
* @returns A list of grid ranges in the translated space. Possibly multiple non-continuous ranges
|
|
832
725
|
*/
|
|
833
|
-
|
|
834
|
-
|
|
835
726
|
static translateRange(range, movedColumns, movedRows, reverse) {
|
|
836
727
|
var columnRanges = GridUtils.applyItemMoves(range.startColumn, range.endColumn, movedColumns, reverse);
|
|
837
728
|
var rowRanges = GridUtils.applyItemMoves(range.startRow, range.endRow, movedRows, reverse);
|
|
838
729
|
var ranges = [];
|
|
839
|
-
|
|
840
730
|
for (var i = 0; i < columnRanges.length; i += 1) {
|
|
841
731
|
var c = columnRanges[i];
|
|
842
|
-
|
|
843
732
|
for (var j = 0; j < rowRanges.length; j += 1) {
|
|
844
733
|
var r = rowRanges[j];
|
|
845
734
|
ranges.push(new GridRange(c[0], r[0], c[1], r[1]));
|
|
846
735
|
}
|
|
847
736
|
}
|
|
848
|
-
|
|
849
737
|
return ranges;
|
|
850
738
|
}
|
|
739
|
+
|
|
851
740
|
/**
|
|
852
741
|
* Retrieve the model index given the currently moved items
|
|
853
742
|
* @param visibleIndex The visible index of the item to get the model index for
|
|
854
743
|
* @param movedItems The moved items
|
|
855
744
|
* @returns The model index of the item
|
|
856
745
|
*/
|
|
857
|
-
|
|
858
|
-
|
|
859
746
|
static getModelIndex(visibleIndex, movedItems) {
|
|
860
747
|
var modelIndex = GridUtils.applyItemMoves(visibleIndex, visibleIndex, movedItems, true)[0][0];
|
|
861
748
|
return modelIndex;
|
|
862
749
|
}
|
|
750
|
+
|
|
863
751
|
/**
|
|
864
752
|
* Retrieve the model indexes given the currently moved items
|
|
865
753
|
* @param visibleIndexes The visible indexes of the item to get the model indexes for
|
|
866
754
|
* @param movedItems The moved items
|
|
867
755
|
* @returns The model indexes of the item
|
|
868
756
|
*/
|
|
869
|
-
|
|
870
|
-
|
|
871
757
|
static getModelIndexes(visibleIndexes, movedItems) {
|
|
872
758
|
return visibleIndexes.map(i => GridUtils.getModelIndex(i, movedItems));
|
|
873
759
|
}
|
|
760
|
+
|
|
874
761
|
/**
|
|
875
762
|
* Translate the provided UI start/end indexes to the model start/end indexes by applying the `movedItems` transformations.
|
|
876
763
|
* Since moved items can split apart a range, multiple pairs of indexes are returned
|
|
@@ -880,11 +767,10 @@ export class GridUtils {
|
|
|
880
767
|
* @param movedItems Moved item pairs in this dimension
|
|
881
768
|
* @returns Array of start/end pairs of the indexes after transformations applied.
|
|
882
769
|
*/
|
|
883
|
-
|
|
884
|
-
|
|
885
770
|
static getModelRangeIndexes(start, end, movedItems) {
|
|
886
771
|
return GridUtils.applyItemMoves(start, end, movedItems, true);
|
|
887
772
|
}
|
|
773
|
+
|
|
888
774
|
/**
|
|
889
775
|
* Translate the provided UI range into model range, using the `movedColumns` and `movedRows` to apply the necessary transforms.
|
|
890
776
|
* `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
|
|
@@ -894,13 +780,12 @@ export class GridUtils {
|
|
|
894
780
|
* @param movedRows The moved row pairs
|
|
895
781
|
* @returns The model ranges after translation.
|
|
896
782
|
*/
|
|
897
|
-
|
|
898
|
-
|
|
899
783
|
static getModelRange(uiRange) {
|
|
900
784
|
var movedColumns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
901
785
|
var movedRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
902
786
|
return GridUtils.translateRange(uiRange, movedColumns, movedRows, true);
|
|
903
787
|
}
|
|
788
|
+
|
|
904
789
|
/**
|
|
905
790
|
* Translate the provided UI range into model ranges, using the `movedColumns` and `movedRows` to apply the necessary transforms.
|
|
906
791
|
* `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
|
|
@@ -910,19 +795,16 @@ export class GridUtils {
|
|
|
910
795
|
* @param movedRows The moved row pairs
|
|
911
796
|
* @returns The model ranges after translation.
|
|
912
797
|
*/
|
|
913
|
-
|
|
914
|
-
|
|
915
798
|
static getModelRanges(uiRanges) {
|
|
916
799
|
var movedColumns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
917
800
|
var movedRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
918
801
|
var modelRanges = [];
|
|
919
|
-
|
|
920
802
|
for (var i = 0; i < uiRanges.length; i += 1) {
|
|
921
803
|
modelRanges.push(...GridUtils.getModelRange(uiRanges[i], movedColumns, movedRows));
|
|
922
804
|
}
|
|
923
|
-
|
|
924
805
|
return modelRanges;
|
|
925
806
|
}
|
|
807
|
+
|
|
926
808
|
/**
|
|
927
809
|
* Translate the provided UI start/end indexes to the model start/end indexes by applying the `movedItems` transformations.
|
|
928
810
|
* Since moved items can split apart a range, multiple pairs of indexes are returned
|
|
@@ -932,11 +814,10 @@ export class GridUtils {
|
|
|
932
814
|
* @param movedItems Moved item pairs in this dimension
|
|
933
815
|
* @returns Array of start/end pairs of the indexes after transformations applied.
|
|
934
816
|
*/
|
|
935
|
-
|
|
936
|
-
|
|
937
817
|
static getVisibleRangeIndexes(start, end, movedItems) {
|
|
938
818
|
return GridUtils.applyItemMoves(start, end, movedItems, false);
|
|
939
819
|
}
|
|
820
|
+
|
|
940
821
|
/**
|
|
941
822
|
* Translate the provided UI range into visible range, using the `movedColumns` and `movedRows` to apply the necessary transforms.
|
|
942
823
|
* `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
|
|
@@ -946,13 +827,12 @@ export class GridUtils {
|
|
|
946
827
|
* @param movedRows The moved row pairs
|
|
947
828
|
* @returns The model ranges after translation.
|
|
948
829
|
*/
|
|
949
|
-
|
|
950
|
-
|
|
951
830
|
static getVisibleRange(modelRange) {
|
|
952
831
|
var movedColumns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
953
832
|
var movedRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
954
833
|
return this.translateRange(modelRange, movedColumns, movedRows, false);
|
|
955
834
|
}
|
|
835
|
+
|
|
956
836
|
/**
|
|
957
837
|
* Translate the provided model ranges into visible ranges, using the `movedColumns` and `movedRows` to apply the necessary transforms.
|
|
958
838
|
* `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
|
|
@@ -962,104 +842,92 @@ export class GridUtils {
|
|
|
962
842
|
* @param movedRows The moved row pairs
|
|
963
843
|
* @returns The model ranges after translation.
|
|
964
844
|
*/
|
|
965
|
-
|
|
966
|
-
|
|
967
845
|
static getVisibleRanges(modelRanges) {
|
|
968
846
|
var movedColumns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
969
847
|
var movedRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
970
848
|
var visibleRanges = [];
|
|
971
|
-
|
|
972
849
|
for (var i = 0; i < modelRanges.length; i += 1) {
|
|
973
850
|
visibleRanges.push(...GridUtils.getVisibleRange(modelRanges[i], movedColumns, movedRows));
|
|
974
851
|
}
|
|
975
|
-
|
|
976
852
|
return visibleRanges;
|
|
977
853
|
}
|
|
854
|
+
|
|
978
855
|
/**
|
|
979
856
|
* Retrieve the visible index given the currently moved items
|
|
980
857
|
* @param modelIndex The model index to get the visible index for
|
|
981
858
|
* @param movedItems Moved items
|
|
982
859
|
* @returns The visible index of the item
|
|
983
860
|
*/
|
|
984
|
-
|
|
985
|
-
|
|
986
861
|
static getVisibleIndex(modelIndex, movedItems) {
|
|
987
862
|
var visibleIndex = GridUtils.applyItemMoves(modelIndex, modelIndex, movedItems)[0][0];
|
|
988
863
|
return visibleIndex;
|
|
989
864
|
}
|
|
865
|
+
|
|
990
866
|
/**
|
|
991
867
|
* Retrieve the visible indexes given the currently moved items
|
|
992
868
|
* @param modelIndexes The model indexes to get the visible indexes for
|
|
993
869
|
* @param movedItems Moved items
|
|
994
870
|
* @returns The visible indexes of the item
|
|
995
871
|
*/
|
|
996
|
-
|
|
997
|
-
|
|
998
872
|
static getVisibleIndexes(modelIndexes, movedItems) {
|
|
999
873
|
return modelIndexes.map(i => GridUtils.getVisibleIndex(i, movedItems));
|
|
1000
874
|
}
|
|
875
|
+
|
|
1001
876
|
/**
|
|
1002
877
|
* Check if the current platform is Mac
|
|
1003
878
|
* @returns True if this platform is a Mac, false otherwise
|
|
1004
879
|
*/
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
880
|
static isMacPlatform() {
|
|
1008
881
|
var {
|
|
1009
882
|
platform
|
|
1010
883
|
} = window.navigator;
|
|
1011
884
|
return platform.startsWith('Mac');
|
|
1012
885
|
}
|
|
886
|
+
|
|
1013
887
|
/**
|
|
1014
888
|
* Get the modifier key for the current platform
|
|
1015
889
|
* @returns The modifier key for the current platform
|
|
1016
890
|
*/
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
891
|
static getModifierKey() {
|
|
1020
892
|
if (GridUtils.isMacPlatform()) {
|
|
1021
893
|
return 'metaKey';
|
|
1022
894
|
}
|
|
1023
|
-
|
|
1024
895
|
return 'ctrlKey';
|
|
1025
896
|
}
|
|
897
|
+
|
|
1026
898
|
/**
|
|
1027
899
|
* Check if the modifier key is down for the given event
|
|
1028
900
|
* @param event The event to check
|
|
1029
901
|
* @returns True if the modifier key is down, false otherwise
|
|
1030
902
|
*/
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
903
|
static isModifierKeyDown(event) {
|
|
1034
904
|
var modifierKey = GridUtils.getModifierKey();
|
|
1035
905
|
return event[modifierKey];
|
|
1036
906
|
}
|
|
907
|
+
|
|
1037
908
|
/**
|
|
1038
909
|
* Check if the user has hidden the specified column
|
|
1039
910
|
* @param modelIndex The model index to check
|
|
1040
911
|
* @param userColumnWidths The user set column widths
|
|
1041
912
|
* @returns True if the user has hidden the column
|
|
1042
913
|
*/
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
914
|
static checkColumnHidden(modelIndex, userColumnWidths) {
|
|
1046
915
|
return userColumnWidths.get(modelIndex) === 0;
|
|
1047
916
|
}
|
|
917
|
+
|
|
1048
918
|
/**
|
|
1049
919
|
* Check if all the columns specified are hidden
|
|
1050
920
|
* @param columns Columns to check
|
|
1051
921
|
* @param userColumnWidths The user set column widths
|
|
1052
922
|
* @returns True if the user has hidden all of the columns
|
|
1053
923
|
*/
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
924
|
static checkAllColumnsHidden(columns, userColumnWidths) {
|
|
1057
925
|
if (userColumnWidths.size === 0) {
|
|
1058
926
|
return false;
|
|
1059
927
|
}
|
|
1060
|
-
|
|
1061
928
|
return columns.every(column => userColumnWidths.get(column) === 0);
|
|
1062
929
|
}
|
|
930
|
+
|
|
1063
931
|
/**
|
|
1064
932
|
* Get the bounds the mouse needs to be dragged outside of from an initial selection before scrolling occurs.
|
|
1065
933
|
* Taking into account any floating rows that may be covering the viewport.
|
|
@@ -1068,8 +936,6 @@ export class GridUtils {
|
|
|
1068
936
|
* @param column The column they started the drag from
|
|
1069
937
|
* @returns Dimensions of the drag area in relation to the canvas they need to drag outside of to start scrolling
|
|
1070
938
|
*/
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
939
|
static getScrollDragBounds(metrics, row, column) {
|
|
1074
940
|
var {
|
|
1075
941
|
gridX,
|
|
@@ -1091,27 +957,22 @@ export class GridUtils {
|
|
|
1091
957
|
var y1 = gridY;
|
|
1092
958
|
var x2 = width;
|
|
1093
959
|
var y2 = height;
|
|
1094
|
-
|
|
1095
960
|
if (column != null) {
|
|
1096
961
|
if (column > floatingLeftColumnCount) {
|
|
1097
962
|
x1 += floatingLeftWidth;
|
|
1098
963
|
}
|
|
1099
|
-
|
|
1100
964
|
if (column < columnCount - floatingRightColumnCount) {
|
|
1101
965
|
x2 -= floatingRightWidth;
|
|
1102
966
|
}
|
|
1103
967
|
}
|
|
1104
|
-
|
|
1105
968
|
if (row != null) {
|
|
1106
969
|
if (row > floatingTopRowCount) {
|
|
1107
970
|
y1 += floatingTopHeight;
|
|
1108
971
|
}
|
|
1109
|
-
|
|
1110
972
|
if (row < rowCount - floatingBottomRowCount) {
|
|
1111
973
|
y2 -= floatingBottomHeight;
|
|
1112
974
|
}
|
|
1113
975
|
}
|
|
1114
|
-
|
|
1115
976
|
return {
|
|
1116
977
|
x1,
|
|
1117
978
|
y1,
|
|
@@ -1119,6 +980,7 @@ export class GridUtils {
|
|
|
1119
980
|
y2
|
|
1120
981
|
};
|
|
1121
982
|
}
|
|
983
|
+
|
|
1122
984
|
/**
|
|
1123
985
|
* Converts the delta coordinates from the provided wheel event to pixels
|
|
1124
986
|
* Different platforms have different ways of providing the delta so this normalizes it
|
|
@@ -1129,8 +991,6 @@ export class GridUtils {
|
|
|
1129
991
|
* @param lineHeight The height of the line scrolling in line mode
|
|
1130
992
|
* @returns The delta coordinates normalized to pixels
|
|
1131
993
|
*/
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
994
|
static getScrollDelta(wheelEvent) {
|
|
1135
995
|
var pageWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1024;
|
|
1136
996
|
var pageHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 768;
|
|
@@ -1139,19 +999,20 @@ export class GridUtils {
|
|
|
1139
999
|
var {
|
|
1140
1000
|
deltaX,
|
|
1141
1001
|
deltaY
|
|
1142
|
-
} = wheelEvent;
|
|
1002
|
+
} = wheelEvent;
|
|
1003
|
+
|
|
1004
|
+
// Flip scroll direction if shiftKey is held on windows/linux.
|
|
1143
1005
|
// On mac, deltaX/Y values are switched at the event level when shiftKey=true.
|
|
1144
1006
|
// Guard on strictly Y only changing, to ignore trackpad diagonal motion,
|
|
1145
1007
|
// through that guard may not be necessary, but it is difficult to determine for
|
|
1146
1008
|
// all platforms/browser/scroll method combos.
|
|
1147
|
-
|
|
1148
1009
|
if (!GridUtils.isMacPlatform() && wheelEvent.shiftKey && wheelEvent.deltaX === 0 && wheelEvent.deltaY !== 0) {
|
|
1149
1010
|
deltaX = wheelEvent.deltaY;
|
|
1150
1011
|
deltaY = wheelEvent.deltaX;
|
|
1151
|
-
}
|
|
1152
|
-
// deltaMode 0, is already in pixel units
|
|
1153
|
-
|
|
1012
|
+
}
|
|
1154
1013
|
|
|
1014
|
+
// Normalize other deltaMode values to pixel units
|
|
1015
|
+
// deltaMode 0, is already in pixel units
|
|
1155
1016
|
if ((wheelEvent === null || wheelEvent === void 0 ? void 0 : wheelEvent.deltaMode) === WheelEvent.DOM_DELTA_PAGE) {
|
|
1156
1017
|
// Users can set OS to be in deltaMode page
|
|
1157
1018
|
// scrolly by page units as pixels
|
|
@@ -1174,29 +1035,23 @@ export class GridUtils {
|
|
|
1174
1035
|
deltaY = Math.round(deltaY * this.PIXELS_PER_LINE);
|
|
1175
1036
|
}
|
|
1176
1037
|
}
|
|
1177
|
-
|
|
1178
1038
|
return {
|
|
1179
1039
|
deltaX,
|
|
1180
1040
|
deltaY
|
|
1181
1041
|
};
|
|
1182
1042
|
}
|
|
1183
|
-
|
|
1184
1043
|
static compareRanges(range1, range2) {
|
|
1185
1044
|
if (range1[0] == null || range1[1] == null || range2[0] == null || range2[1] == null) {
|
|
1186
1045
|
return 0;
|
|
1187
1046
|
}
|
|
1188
|
-
|
|
1189
1047
|
return range1[0] !== range2[0] ? range1[0] - range2[0] : range1[1] - range2[1];
|
|
1190
1048
|
}
|
|
1191
|
-
|
|
1192
1049
|
static mergeSortedRanges(ranges) {
|
|
1193
1050
|
var mergedRanges = [];
|
|
1194
|
-
|
|
1195
1051
|
for (var i = 0; i < ranges.length; i += 1) {
|
|
1196
1052
|
var range = ranges[i];
|
|
1197
1053
|
var start = range[0];
|
|
1198
1054
|
var end = range[1];
|
|
1199
|
-
|
|
1200
1055
|
if (i === 0) {
|
|
1201
1056
|
mergedRanges.push([start, end]);
|
|
1202
1057
|
} else if (start - 1 <= mergedRanges[mergedRanges.length - 1][1]) {
|
|
@@ -1205,13 +1060,9 @@ export class GridUtils {
|
|
|
1205
1060
|
mergedRanges.push([start, end]);
|
|
1206
1061
|
}
|
|
1207
1062
|
}
|
|
1208
|
-
|
|
1209
1063
|
return mergedRanges;
|
|
1210
1064
|
}
|
|
1211
|
-
|
|
1212
1065
|
}
|
|
1213
|
-
|
|
1214
1066
|
_defineProperty(GridUtils, "PIXELS_PER_LINE", 100 / 3);
|
|
1215
|
-
|
|
1216
1067
|
export default GridUtils;
|
|
1217
1068
|
//# sourceMappingURL=GridUtils.js.map
|