@deephaven/grid 0.7.0 → 0.7.1-beta.13
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/Grid.css +0 -1
- package/dist/Grid.css.map +1 -1
- package/dist/Grid.d.ts +3 -13
- package/dist/Grid.d.ts.map +1 -1
- package/dist/GridMetricCalculator.d.ts +448 -165
- package/dist/GridMetricCalculator.d.ts.map +1 -1
- package/dist/GridMetricCalculator.js +523 -119
- package/dist/GridMetricCalculator.js.map +1 -1
- package/dist/GridMetrics.d.ts +97 -0
- package/dist/GridMetrics.d.ts.map +1 -0
- package/dist/GridMetrics.js +2 -0
- package/dist/GridMetrics.js.map +1 -0
- package/dist/GridRange.d.ts +186 -111
- package/dist/GridRange.d.ts.map +1 -1
- package/dist/GridRange.js +185 -87
- package/dist/GridRange.js.map +1 -1
- package/dist/GridRenderer.js +6 -1
- package/dist/GridRenderer.js.map +1 -1
- package/dist/GridTheme.d.ts +49 -37
- package/dist/GridTheme.d.ts.map +1 -1
- package/dist/GridTheme.js +8 -0
- package/dist/GridTheme.js.map +1 -1
- package/dist/GridUtils.d.ts +236 -97
- package/dist/GridUtils.d.ts.map +1 -1
- package/dist/GridUtils.js +240 -75
- package/dist/GridUtils.js.map +1 -1
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.d.ts +1 -1
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridSelectionMouseHandler.js +4 -4
- package/dist/mouse-handlers/GridSelectionMouseHandler.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/GridUtils.js
CHANGED
|
@@ -9,6 +9,14 @@ import GridRange from "./GridRange.js";
|
|
|
9
9
|
class GridUtils {
|
|
10
10
|
// use same constant as chrome source for windows
|
|
11
11
|
// https://github.com/chromium/chromium/blob/973af9d461b6b5dc60208c8d3d66adc27e53da78/ui/events/blink/web_input_event_builders_win.cc#L285
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Get the GridPoint for the coordinates provided
|
|
15
|
+
* @param x The grid x coordinate
|
|
16
|
+
* @param y The grid y coordinate
|
|
17
|
+
* @param metrics The grid metrics
|
|
18
|
+
* @returns The GridPoint including the column/row information
|
|
19
|
+
*/
|
|
12
20
|
static getGridPointFromXY(x, y, metrics) {
|
|
13
21
|
var column = GridUtils.getColumnAtX(x, metrics);
|
|
14
22
|
var row = GridUtils.getRowAtY(y, metrics);
|
|
@@ -19,6 +27,14 @@ class GridUtils {
|
|
|
19
27
|
column
|
|
20
28
|
};
|
|
21
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Iterate through each floating item at the start and call a callback, returning the first result
|
|
32
|
+
* @param start The count of floating items at the start
|
|
33
|
+
* @param total The total number of items
|
|
34
|
+
* @param callback Function to call for each item
|
|
35
|
+
* @returns The result from the callback
|
|
36
|
+
*/
|
|
37
|
+
|
|
22
38
|
|
|
23
39
|
static iterateFloatingStart(start, total, callback) {
|
|
24
40
|
for (var i = 0; i < start && i < total; i += 1) {
|
|
@@ -33,6 +49,10 @@ class GridUtils {
|
|
|
33
49
|
}
|
|
34
50
|
/**
|
|
35
51
|
* Iterate through floating items at the end. Iterates in increasing order.
|
|
52
|
+
* @param end The count of floating items at the end
|
|
53
|
+
* @param total The total number of items
|
|
54
|
+
* @param callback Function to call for each item
|
|
55
|
+
* @returns The result from the callback
|
|
36
56
|
*/
|
|
37
57
|
|
|
38
58
|
|
|
@@ -49,10 +69,10 @@ class GridUtils {
|
|
|
49
69
|
}
|
|
50
70
|
/**
|
|
51
71
|
* Iterate through all floating items in increasing order, starting with the top items.
|
|
52
|
-
* @param
|
|
53
|
-
* @param
|
|
54
|
-
* @param
|
|
55
|
-
* @param
|
|
72
|
+
* @param start Count of start floating rows, e.g. floatingTopRowCount
|
|
73
|
+
* @param end Count of end floating rows, e.g. floatingBottomRowCount
|
|
74
|
+
* @param total Total number of items
|
|
75
|
+
* @param callback Callback called for each value, stopping the iterating and returning the value if one is returned
|
|
56
76
|
*/
|
|
57
77
|
|
|
58
78
|
|
|
@@ -65,6 +85,18 @@ class GridUtils {
|
|
|
65
85
|
|
|
66
86
|
return GridUtils.iterateFloatingEnd(end, total, callback);
|
|
67
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Iterate through all items in one dimension on the grid - first floating, then visible.
|
|
90
|
+
* Call the callback for each item, break if a result is returned and return that result.
|
|
91
|
+
* @param visibleStart Index of the start of the visible viewport
|
|
92
|
+
* @param visibleEnd Index of the end of the visible viewport
|
|
93
|
+
* @param floatingStartCount Number of items floating at the start
|
|
94
|
+
* @param floatingEndCount Number of items floating at the end
|
|
95
|
+
* @param totalCount Total number of items
|
|
96
|
+
* @param callback Callback to call for each item
|
|
97
|
+
* @returns The first result from the callback called, or undefined
|
|
98
|
+
*/
|
|
99
|
+
|
|
68
100
|
|
|
69
101
|
static iterateAllItems(visibleStart, visibleEnd, floatingStartCount, floatingEndCount, totalCount, callback) {
|
|
70
102
|
var visibleStartIndex = Math.max(visibleStart, floatingStartCount);
|
|
@@ -85,16 +117,39 @@ class GridUtils {
|
|
|
85
117
|
|
|
86
118
|
return undefined;
|
|
87
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Check if the coordinate is within the item specified in this dimension
|
|
122
|
+
* @param itemIndex Index of the item to check
|
|
123
|
+
* @param itemCoordinatess Coordinate of all items in this dimension
|
|
124
|
+
* @param itemSizes Size of all items in this dimension
|
|
125
|
+
* @param coordinate The coordinate to check
|
|
126
|
+
* @returns True if the coordinate is within the item specified, false otherwise
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
static isInItem(itemIndex, itemCoordinates, itemSizes, coordinate) {
|
|
131
|
+
var _itemCoordinates$get, _itemSizes$get;
|
|
88
132
|
|
|
89
|
-
|
|
90
|
-
var
|
|
91
|
-
|
|
92
|
-
return itemX <= x && x <= itemX + itemSize;
|
|
133
|
+
var itemX = (_itemCoordinates$get = itemCoordinates.get(itemIndex)) !== null && _itemCoordinates$get !== void 0 ? _itemCoordinates$get : 0;
|
|
134
|
+
var itemSize = (_itemSizes$get = itemSizes.get(itemIndex)) !== null && _itemSizes$get !== void 0 ? _itemSizes$get : 0;
|
|
135
|
+
return itemX <= coordinate && coordinate <= itemX + itemSize;
|
|
93
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Get the Index of the item at the provided offset
|
|
139
|
+
* @param offset Coordinate of the offset to get the item of
|
|
140
|
+
* @param itemCount The total count of items
|
|
141
|
+
* @param floatingStart Count of floating items at the start
|
|
142
|
+
* @param floatingEnd Count of floating items at the end
|
|
143
|
+
* @param items Index of all items
|
|
144
|
+
* @param itemCoordinates The coordinate of each item
|
|
145
|
+
* @param itemSizes The size of each item
|
|
146
|
+
* @returns The item index, or null if no item matches
|
|
147
|
+
*/
|
|
94
148
|
|
|
95
|
-
|
|
149
|
+
|
|
150
|
+
static getItemAtOffset(offset, itemCount, floatingStart, floatingEnd, items, itemCoordinates, itemSizes) {
|
|
96
151
|
var floatingItem = GridUtils.iterateFloating(floatingStart, floatingEnd, itemCount, item => {
|
|
97
|
-
if (GridUtils.isInItem(item,
|
|
152
|
+
if (GridUtils.isInItem(item, itemCoordinates, itemSizes, offset)) {
|
|
98
153
|
return item;
|
|
99
154
|
}
|
|
100
155
|
|
|
@@ -108,13 +163,20 @@ class GridUtils {
|
|
|
108
163
|
for (var i = 0; i < items.length; i += 1) {
|
|
109
164
|
var item = items[i];
|
|
110
165
|
|
|
111
|
-
if (GridUtils.isInItem(item,
|
|
166
|
+
if (GridUtils.isInItem(item, itemCoordinates, itemSizes, offset)) {
|
|
112
167
|
return item;
|
|
113
168
|
}
|
|
114
169
|
}
|
|
115
170
|
|
|
116
171
|
return null;
|
|
117
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Get the index of the column at the specified x coordinate
|
|
175
|
+
* @param x Coordinate to get the item of
|
|
176
|
+
* @param metrics Grid metrics
|
|
177
|
+
* @returns Index of the column at that coordinate, or null if no column matches
|
|
178
|
+
*/
|
|
179
|
+
|
|
118
180
|
|
|
119
181
|
static getColumnAtX(x, metrics) {
|
|
120
182
|
var {
|
|
@@ -133,6 +195,13 @@ class GridUtils {
|
|
|
133
195
|
|
|
134
196
|
return this.getItemAtOffset(x - gridX, columnCount, floatingLeftColumnCount, floatingRightColumnCount, visibleColumns, visibleColumnXs, visibleColumnWidths);
|
|
135
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* Get the index of the row at the specified y coordinate
|
|
200
|
+
* @param y Coordinate to get the item of
|
|
201
|
+
* @param metrics Grid metrics
|
|
202
|
+
* @returns Index of the row at that coordinate, or null if no row matches
|
|
203
|
+
*/
|
|
204
|
+
|
|
136
205
|
|
|
137
206
|
static getRowAtY(y, metrics) {
|
|
138
207
|
var {
|
|
@@ -157,6 +226,7 @@ class GridUtils {
|
|
|
157
226
|
* @param {Map} modelIndexes The mapping of model indexes
|
|
158
227
|
* @param {Number[]} visibleItems The visible items
|
|
159
228
|
* @param {Map} userSizes The user set sizes
|
|
229
|
+
* @returns Index of the next visible item, or null if no more are visible
|
|
160
230
|
*/
|
|
161
231
|
|
|
162
232
|
|
|
@@ -168,7 +238,7 @@ class GridUtils {
|
|
|
168
238
|
var item = visibleItems[visibleItemIndex];
|
|
169
239
|
var modelIndex = modelIndexes.get(item);
|
|
170
240
|
|
|
171
|
-
if (userSizes.get(modelIndex) !== 0) {
|
|
241
|
+
if (modelIndex != null && userSizes.get(modelIndex) !== 0) {
|
|
172
242
|
return item;
|
|
173
243
|
}
|
|
174
244
|
|
|
@@ -179,8 +249,9 @@ class GridUtils {
|
|
|
179
249
|
}
|
|
180
250
|
/**
|
|
181
251
|
* Iterate backward through the visible columns until a shown column is hit
|
|
182
|
-
* @param
|
|
183
|
-
* @param
|
|
252
|
+
* @param columnIndex The column index to start iterating backward from
|
|
253
|
+
* @param metrics The GridMetricCalculator metrics
|
|
254
|
+
* @returns Index of the next visible item, or null if no more are visible
|
|
184
255
|
*/
|
|
185
256
|
|
|
186
257
|
|
|
@@ -194,8 +265,9 @@ class GridUtils {
|
|
|
194
265
|
}
|
|
195
266
|
/**
|
|
196
267
|
* Iterate backward through the visible rows until a shown row is hit
|
|
197
|
-
* @param
|
|
198
|
-
* @param
|
|
268
|
+
* @param rowIndex The row index to start iterating backward from
|
|
269
|
+
* @param metrics The GridMetricCalculator metrics
|
|
270
|
+
* @returns Index of the next visible item, or null if no more are visible
|
|
199
271
|
*/
|
|
200
272
|
|
|
201
273
|
|
|
@@ -208,12 +280,12 @@ class GridUtils {
|
|
|
208
280
|
return GridUtils.getNextShownItem(startIndex, modelRows, visibleRows, userRowHeights);
|
|
209
281
|
}
|
|
210
282
|
/**
|
|
211
|
-
* Gets the column index if the x/y
|
|
212
|
-
* @param
|
|
213
|
-
* @param
|
|
214
|
-
* @param
|
|
215
|
-
* @param
|
|
216
|
-
* @returns
|
|
283
|
+
* Gets the column index if the x/y coordinates provided are close enough to the separator, otherwise null
|
|
284
|
+
* @param x Mouse x coordinate
|
|
285
|
+
* @param y Mouse y coordinate
|
|
286
|
+
* @param metrics The grid metrics
|
|
287
|
+
* @param theme The grid theme with potential user overrides
|
|
288
|
+
* @returns Index of the column separator at the coordinates provided, or null if none match
|
|
217
289
|
*/
|
|
218
290
|
|
|
219
291
|
|
|
@@ -222,16 +294,15 @@ class GridUtils {
|
|
|
222
294
|
rowHeaderWidth,
|
|
223
295
|
columnHeaderHeight,
|
|
224
296
|
floatingColumns,
|
|
297
|
+
floatingLeftWidth,
|
|
225
298
|
visibleColumns,
|
|
226
299
|
visibleColumnXs,
|
|
227
|
-
visibleColumnWidths
|
|
228
|
-
floatingLeftColumnCount
|
|
300
|
+
visibleColumnWidths
|
|
229
301
|
} = metrics;
|
|
230
302
|
var {
|
|
231
303
|
allowColumnResize,
|
|
232
304
|
headerSeparatorHandleSize
|
|
233
305
|
} = theme;
|
|
234
|
-
var floatingLeftColumnsWidth = visibleColumnXs.get(floatingLeftColumnCount - 1) + visibleColumnWidths.get(floatingLeftColumnCount - 1);
|
|
235
306
|
|
|
236
307
|
if (columnHeaderHeight < y || !allowColumnResize || headerSeparatorHandleSize <= 0) {
|
|
237
308
|
return null;
|
|
@@ -243,9 +314,11 @@ class GridUtils {
|
|
|
243
314
|
var isPreviousColumnHidden = false;
|
|
244
315
|
|
|
245
316
|
for (var i = floatingColumns.length - 1; i >= 0; i -= 1) {
|
|
317
|
+
var _visibleColumnXs$get, _visibleColumnWidths$;
|
|
318
|
+
|
|
246
319
|
var column = floatingColumns[i];
|
|
247
|
-
var columnX = visibleColumnXs.get(column);
|
|
248
|
-
var columnWidth = visibleColumnWidths.get(column);
|
|
320
|
+
var columnX = (_visibleColumnXs$get = visibleColumnXs.get(column)) !== null && _visibleColumnXs$get !== void 0 ? _visibleColumnXs$get : 0;
|
|
321
|
+
var columnWidth = (_visibleColumnWidths$ = visibleColumnWidths.get(column)) !== null && _visibleColumnWidths$ !== void 0 ? _visibleColumnWidths$ : 0;
|
|
249
322
|
var isColumnHidden = columnWidth === 0;
|
|
250
323
|
|
|
251
324
|
if (!isPreviousColumnHidden || !isColumnHidden) {
|
|
@@ -272,16 +345,18 @@ class GridUtils {
|
|
|
272
345
|
isPreviousColumnHidden = false;
|
|
273
346
|
|
|
274
347
|
for (var _i = visibleColumns.length - 1; _i >= 0; _i -= 1) {
|
|
348
|
+
var _visibleColumnXs$get2, _visibleColumnWidths$2;
|
|
349
|
+
|
|
275
350
|
var _column = visibleColumns[_i];
|
|
276
351
|
|
|
277
|
-
var _columnX = visibleColumnXs.get(_column);
|
|
352
|
+
var _columnX = (_visibleColumnXs$get2 = visibleColumnXs.get(_column)) !== null && _visibleColumnXs$get2 !== void 0 ? _visibleColumnXs$get2 : 0;
|
|
278
353
|
|
|
279
|
-
var _columnWidth = visibleColumnWidths.get(_column);
|
|
354
|
+
var _columnWidth = (_visibleColumnWidths$2 = visibleColumnWidths.get(_column)) !== null && _visibleColumnWidths$2 !== void 0 ? _visibleColumnWidths$2 : 0;
|
|
280
355
|
|
|
281
356
|
var _isColumnHidden = _columnWidth === 0; // If this column is under the floating columns "layer". Terminate early.
|
|
282
357
|
|
|
283
358
|
|
|
284
|
-
if (_columnX <
|
|
359
|
+
if (_columnX < floatingLeftWidth - _columnWidth) {
|
|
285
360
|
return null;
|
|
286
361
|
}
|
|
287
362
|
|
|
@@ -308,10 +383,24 @@ class GridUtils {
|
|
|
308
383
|
|
|
309
384
|
return null;
|
|
310
385
|
}
|
|
386
|
+
/**
|
|
387
|
+
* Check if the item specified is hidden
|
|
388
|
+
* @param itemIndex Index of the item to check
|
|
389
|
+
* @param visibleSizes Sizes of all visible items
|
|
390
|
+
* @returns True if the item is hidden, false otherwise
|
|
391
|
+
*/
|
|
392
|
+
|
|
311
393
|
|
|
312
394
|
static isItemHidden(itemIndex, visibleSizes) {
|
|
313
395
|
return visibleSizes.get(itemIndex) === 0;
|
|
314
396
|
}
|
|
397
|
+
/**
|
|
398
|
+
* Check if the column specified is hidden
|
|
399
|
+
* @param columnIndex Index of the column to check
|
|
400
|
+
* @param metrics Grid metrics
|
|
401
|
+
* @returns True if the column is hidden, false otherwise
|
|
402
|
+
*/
|
|
403
|
+
|
|
315
404
|
|
|
316
405
|
static isColumnHidden(columnIndex, metrics) {
|
|
317
406
|
var {
|
|
@@ -321,8 +410,9 @@ class GridUtils {
|
|
|
321
410
|
}
|
|
322
411
|
/**
|
|
323
412
|
* Check if the provided row is a floating row
|
|
324
|
-
* @param
|
|
325
|
-
* @param
|
|
413
|
+
* @param row The row index to check
|
|
414
|
+
* @param metrics The grid metrics to check against
|
|
415
|
+
* @returns True if it's a floating row, false otherwise
|
|
326
416
|
*/
|
|
327
417
|
|
|
328
418
|
|
|
@@ -340,8 +430,9 @@ class GridUtils {
|
|
|
340
430
|
}
|
|
341
431
|
/**
|
|
342
432
|
* Check if the provided column is a floating column
|
|
343
|
-
* @param
|
|
344
|
-
* @param
|
|
433
|
+
* @param column The column index to check
|
|
434
|
+
* @param metrics The grid metrics to check against
|
|
435
|
+
* @returns True if it's a floating column, false otherwise
|
|
345
436
|
*/
|
|
346
437
|
|
|
347
438
|
|
|
@@ -357,6 +448,15 @@ class GridUtils {
|
|
|
357
448
|
} = metrics;
|
|
358
449
|
return column < floatingLeftColumnCount || column >= columnCount - floatingRightColumnCount;
|
|
359
450
|
}
|
|
451
|
+
/**
|
|
452
|
+
* Get all the items that are hidden under the same Index
|
|
453
|
+
* 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]
|
|
454
|
+
* @param itemIndex Index of the item to start at
|
|
455
|
+
* @param visibleSizes Visible size map
|
|
456
|
+
* @param visibleItems Visible items
|
|
457
|
+
* @returns Array of items that are hidden
|
|
458
|
+
*/
|
|
459
|
+
|
|
360
460
|
|
|
361
461
|
static getHiddenItems(itemIndex, visibleSizes, visibleItems) {
|
|
362
462
|
if (!GridUtils.isItemHidden(itemIndex, visibleSizes)) {
|
|
@@ -378,6 +478,13 @@ class GridUtils {
|
|
|
378
478
|
|
|
379
479
|
return hiddenItems;
|
|
380
480
|
}
|
|
481
|
+
/**
|
|
482
|
+
* Get all the columns that are hidden under the same Index
|
|
483
|
+
* @param columnIndex Index of the item to start at
|
|
484
|
+
* @param metrics Grid metrics
|
|
485
|
+
* @returns Array of items that are hidden
|
|
486
|
+
*/
|
|
487
|
+
|
|
381
488
|
|
|
382
489
|
static getHiddenColumns(columnIndex, metrics) {
|
|
383
490
|
var {
|
|
@@ -385,7 +492,15 @@ class GridUtils {
|
|
|
385
492
|
visibleColumnWidths
|
|
386
493
|
} = metrics;
|
|
387
494
|
return GridUtils.getHiddenItems(columnIndex, visibleColumnWidths, visibleColumns);
|
|
388
|
-
}
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Returns the row index if the x/y coordinates provided are close enough to the separator, otherwise null
|
|
498
|
+
* @param x X coordinate to check
|
|
499
|
+
* @param y Y coordinate to check
|
|
500
|
+
* @param metrics The grid metrics
|
|
501
|
+
* @param theme The grid theme
|
|
502
|
+
* @returns Index of the row separator at the coordinates provided, or null if none match
|
|
503
|
+
*/
|
|
389
504
|
|
|
390
505
|
|
|
391
506
|
static getRowSeparatorIndex(x, y, metrics, theme) {
|
|
@@ -411,9 +526,11 @@ class GridUtils {
|
|
|
411
526
|
var isPreviousRowHidden = false;
|
|
412
527
|
|
|
413
528
|
for (var i = visibleRows.length - 1; i >= 0; i -= 1) {
|
|
529
|
+
var _visibleRowYs$get, _visibleRowHeights$ge;
|
|
530
|
+
|
|
414
531
|
var row = visibleRows[i];
|
|
415
|
-
var rowY = visibleRowYs.get(row);
|
|
416
|
-
var rowHeight = visibleRowHeights.get(row);
|
|
532
|
+
var rowY = (_visibleRowYs$get = visibleRowYs.get(row)) !== null && _visibleRowYs$get !== void 0 ? _visibleRowYs$get : 0;
|
|
533
|
+
var rowHeight = (_visibleRowHeights$ge = visibleRowHeights.get(row)) !== null && _visibleRowHeights$ge !== void 0 ? _visibleRowHeights$ge : 0;
|
|
417
534
|
var isRowHidden = rowHeight === 0;
|
|
418
535
|
|
|
419
536
|
if (!isPreviousRowHidden || !isRowHidden) {
|
|
@@ -438,6 +555,13 @@ class GridUtils {
|
|
|
438
555
|
|
|
439
556
|
return null;
|
|
440
557
|
}
|
|
558
|
+
/**
|
|
559
|
+
* Check if the row specified is hidden
|
|
560
|
+
* @param rowIndex Index of the row to check
|
|
561
|
+
* @param metrics Grid metrics
|
|
562
|
+
* @returns True if the row is hidden, false otherwise
|
|
563
|
+
*/
|
|
564
|
+
|
|
441
565
|
|
|
442
566
|
static isRowHidden(rowIndex, metrics) {
|
|
443
567
|
var {
|
|
@@ -445,6 +569,13 @@ class GridUtils {
|
|
|
445
569
|
} = metrics;
|
|
446
570
|
return GridUtils.isItemHidden(rowIndex, visibleRowHeights);
|
|
447
571
|
}
|
|
572
|
+
/**
|
|
573
|
+
* Get all the rows that are hidden under the same Index
|
|
574
|
+
* @param rowIndex Index of the item to start at
|
|
575
|
+
* @param metrics Grid metrics
|
|
576
|
+
* @returns Array of items that are hidden
|
|
577
|
+
*/
|
|
578
|
+
|
|
448
579
|
|
|
449
580
|
static getHiddenRows(rowIndex, metrics) {
|
|
450
581
|
var {
|
|
@@ -455,10 +586,10 @@ class GridUtils {
|
|
|
455
586
|
}
|
|
456
587
|
/**
|
|
457
588
|
* Set a new order for items in the grid
|
|
458
|
-
* @param
|
|
459
|
-
* @param
|
|
460
|
-
* @param
|
|
461
|
-
* @returns
|
|
589
|
+
* @param from The visible index to move from
|
|
590
|
+
* @param to The visible index to move the itme to
|
|
591
|
+
* @param oldMovedItems The old reordered items
|
|
592
|
+
* @returns The new reordered items
|
|
462
593
|
*/
|
|
463
594
|
|
|
464
595
|
|
|
@@ -469,7 +600,7 @@ class GridUtils {
|
|
|
469
600
|
return oldMovedItems;
|
|
470
601
|
}
|
|
471
602
|
|
|
472
|
-
var movedItems = []
|
|
603
|
+
var movedItems = [...oldMovedItems];
|
|
473
604
|
|
|
474
605
|
if (movedItems.length > 0 && movedItems[movedItems.length - 1].to === from) {
|
|
475
606
|
movedItems[movedItems.length - 1] = _objectSpread(_objectSpread({}, movedItems[movedItems.length - 1]), {}, {
|
|
@@ -486,9 +617,9 @@ class GridUtils {
|
|
|
486
617
|
}
|
|
487
618
|
/**
|
|
488
619
|
* Retrieve the model index given the currently moved items
|
|
489
|
-
* @param
|
|
490
|
-
* @param
|
|
491
|
-
* @returns
|
|
620
|
+
* @param visibleIndex The visible index of the item to get the model index for
|
|
621
|
+
* @param movedItems The moved items
|
|
622
|
+
* @returns The model index of the item
|
|
492
623
|
*/
|
|
493
624
|
|
|
494
625
|
|
|
@@ -516,14 +647,18 @@ class GridUtils {
|
|
|
516
647
|
* Translate the provided UI start/end indexes to the model start/end indexes by applying the `movedItems` transformations.
|
|
517
648
|
* Since moved items can split apart a range, multiple pairs of indexes are returned
|
|
518
649
|
*
|
|
519
|
-
* @param
|
|
520
|
-
* @param
|
|
521
|
-
* @param
|
|
522
|
-
* @returns
|
|
650
|
+
* @param start Start item in one dimension
|
|
651
|
+
* @param end End item in one dimension
|
|
652
|
+
* @param movedItems Moved item pairs in this dimension
|
|
653
|
+
* @returns Array of start/end pairs of the indexes after transformations applied.
|
|
523
654
|
*/
|
|
524
655
|
|
|
525
656
|
|
|
526
657
|
static getModelRangeIndexes(start, end, movedItems) {
|
|
658
|
+
if (start == null || end == null) {
|
|
659
|
+
return [[start, end]];
|
|
660
|
+
}
|
|
661
|
+
|
|
527
662
|
var result = [[start, end]];
|
|
528
663
|
|
|
529
664
|
if (start == null) {
|
|
@@ -614,10 +749,10 @@ class GridUtils {
|
|
|
614
749
|
* Translate the provided UI range into model range, using the `movedColumns` and `movedRows` to apply the necessary transforms.
|
|
615
750
|
* `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
|
|
616
751
|
*
|
|
617
|
-
* @param
|
|
618
|
-
* @param
|
|
619
|
-
* @param
|
|
620
|
-
* @returns
|
|
752
|
+
* @param uiRange The currently selected UI ranges
|
|
753
|
+
* @param movedColumns The moved column pairs
|
|
754
|
+
* @param movedRows The moved row pairs
|
|
755
|
+
* @returns The model ranges after translation.
|
|
621
756
|
*/
|
|
622
757
|
|
|
623
758
|
|
|
@@ -643,10 +778,10 @@ class GridUtils {
|
|
|
643
778
|
* Translate the provided UI range into model ranges, using the `movedColumns` and `movedRows` to apply the necessary transforms.
|
|
644
779
|
* `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
|
|
645
780
|
*
|
|
646
|
-
* @param
|
|
647
|
-
* @param
|
|
648
|
-
* @param
|
|
649
|
-
* @returns
|
|
781
|
+
* @param uiRanges The currently selected UI ranges
|
|
782
|
+
* @param movedColumns The moved column pairs
|
|
783
|
+
* @param movedRows The moved row pairs
|
|
784
|
+
* @returns The model ranges after translation.
|
|
650
785
|
*/
|
|
651
786
|
|
|
652
787
|
|
|
@@ -663,9 +798,9 @@ class GridUtils {
|
|
|
663
798
|
}
|
|
664
799
|
/**
|
|
665
800
|
* Retrieve the visible index given the currently moved items
|
|
666
|
-
* @param
|
|
667
|
-
* @param
|
|
668
|
-
* @returns
|
|
801
|
+
* @param modelIndex The model index to get the visible index for
|
|
802
|
+
* @param movedItems Moved items
|
|
803
|
+
* @returns The visible index of the item
|
|
669
804
|
*/
|
|
670
805
|
|
|
671
806
|
|
|
@@ -689,6 +824,11 @@ class GridUtils {
|
|
|
689
824
|
|
|
690
825
|
return visibleIndex;
|
|
691
826
|
}
|
|
827
|
+
/**
|
|
828
|
+
* Check if the current platform is Mac
|
|
829
|
+
* @returns True if this platform is a Mac, false otherwise
|
|
830
|
+
*/
|
|
831
|
+
|
|
692
832
|
|
|
693
833
|
static isMacPlatform() {
|
|
694
834
|
var {
|
|
@@ -696,6 +836,11 @@ class GridUtils {
|
|
|
696
836
|
} = window.navigator;
|
|
697
837
|
return platform.startsWith('Mac');
|
|
698
838
|
}
|
|
839
|
+
/**
|
|
840
|
+
* Get the modifier key for the current platform
|
|
841
|
+
* @returns The modifier key for the current platform
|
|
842
|
+
*/
|
|
843
|
+
|
|
699
844
|
|
|
700
845
|
static getModifierKey() {
|
|
701
846
|
if (GridUtils.isMacPlatform()) {
|
|
@@ -704,15 +849,35 @@ class GridUtils {
|
|
|
704
849
|
|
|
705
850
|
return 'ctrlKey';
|
|
706
851
|
}
|
|
852
|
+
/**
|
|
853
|
+
* Check if the modifier key is down for the given event
|
|
854
|
+
* @param event The event to check
|
|
855
|
+
* @returns True if the modifier key is down, false otherwise
|
|
856
|
+
*/
|
|
857
|
+
|
|
707
858
|
|
|
708
859
|
static isModifierKeyDown(event) {
|
|
709
860
|
var modifierKey = GridUtils.getModifierKey();
|
|
710
861
|
return event[modifierKey];
|
|
711
862
|
}
|
|
863
|
+
/**
|
|
864
|
+
* Check if the user has hidden the specified column
|
|
865
|
+
* @param modelIndex The model index to check
|
|
866
|
+
* @param userColumnWidths The user set column widths
|
|
867
|
+
* @returns True if the user has hidden the column
|
|
868
|
+
*/
|
|
869
|
+
|
|
712
870
|
|
|
713
871
|
static checkColumnHidden(modelIndex, userColumnWidths) {
|
|
714
872
|
return userColumnWidths.get(modelIndex) === 0;
|
|
715
873
|
}
|
|
874
|
+
/**
|
|
875
|
+
* Check if all the columns specified are hidden
|
|
876
|
+
* @param columns Columns to check
|
|
877
|
+
* @param userColumnWidths The user set column widths
|
|
878
|
+
* @returns True if the user has hidden all of the columns
|
|
879
|
+
*/
|
|
880
|
+
|
|
716
881
|
|
|
717
882
|
static checkAllColumnsHidden(columns, userColumnWidths) {
|
|
718
883
|
if (userColumnWidths.size === 0) {
|
|
@@ -724,9 +889,9 @@ class GridUtils {
|
|
|
724
889
|
/**
|
|
725
890
|
* Get the bounds the mouse needs to be dragged outside of from an initial selection before scrolling occurs.
|
|
726
891
|
* Taking into account any floating rows that may be covering the viewport.
|
|
727
|
-
* @param
|
|
728
|
-
* @param
|
|
729
|
-
* @param
|
|
892
|
+
* @param metrics Grid metrics
|
|
893
|
+
* @param row The row they started dragging in
|
|
894
|
+
* @param column The column they started the drag from
|
|
730
895
|
* @returns Dimensions of the drag area in relation to the canvas they need to drag outside of to start scrolling
|
|
731
896
|
*/
|
|
732
897
|
|
|
@@ -748,14 +913,14 @@ class GridUtils {
|
|
|
748
913
|
columnCount,
|
|
749
914
|
rowCount
|
|
750
915
|
} = metrics;
|
|
751
|
-
var
|
|
752
|
-
var
|
|
916
|
+
var x1 = gridX;
|
|
917
|
+
var y1 = gridY;
|
|
753
918
|
var x2 = width;
|
|
754
919
|
var y2 = height;
|
|
755
920
|
|
|
756
921
|
if (column != null) {
|
|
757
922
|
if (column > floatingLeftColumnCount) {
|
|
758
|
-
|
|
923
|
+
x1 += floatingLeftWidth;
|
|
759
924
|
}
|
|
760
925
|
|
|
761
926
|
if (column < columnCount - floatingRightColumnCount) {
|
|
@@ -765,7 +930,7 @@ class GridUtils {
|
|
|
765
930
|
|
|
766
931
|
if (row != null) {
|
|
767
932
|
if (row > floatingTopRowCount) {
|
|
768
|
-
|
|
933
|
+
y1 += floatingTopHeight;
|
|
769
934
|
}
|
|
770
935
|
|
|
771
936
|
if (row < rowCount - floatingBottomRowCount) {
|
|
@@ -774,8 +939,8 @@ class GridUtils {
|
|
|
774
939
|
}
|
|
775
940
|
|
|
776
941
|
return {
|
|
777
|
-
|
|
778
|
-
|
|
942
|
+
x1,
|
|
943
|
+
y1,
|
|
779
944
|
x2,
|
|
780
945
|
y2
|
|
781
946
|
};
|
|
@@ -783,12 +948,12 @@ class GridUtils {
|
|
|
783
948
|
/**
|
|
784
949
|
* Converts the delta coordinates from the provided wheel event to pixels
|
|
785
950
|
* Different platforms have different ways of providing the delta so this normalizes it
|
|
786
|
-
* @param
|
|
787
|
-
* @param
|
|
788
|
-
* @param
|
|
789
|
-
* @param
|
|
790
|
-
* @param
|
|
791
|
-
* @returns
|
|
951
|
+
* @param wheelEvent The mouse wheel event to get the scrolling delta for
|
|
952
|
+
* @param pageWidth The width of the page that is scrolling
|
|
953
|
+
* @param pageHeight The height of the page that is scrolling
|
|
954
|
+
* @param lineWidth The width of the line scrolling in line mode
|
|
955
|
+
* @param lineHeight The height of the line scrolling in line mode
|
|
956
|
+
* @returns The delta coordinates normalized to pixels
|
|
792
957
|
*/
|
|
793
958
|
|
|
794
959
|
|