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