@deephaven/grid 0.15.1 → 0.15.2
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/ColumnHeaderGroup.d.ts +9 -0
- package/dist/ColumnHeaderGroup.d.ts.map +1 -0
- package/dist/ColumnHeaderGroup.js +2 -0
- package/dist/ColumnHeaderGroup.js.map +1 -0
- package/dist/Grid.d.ts +5 -4
- package/dist/Grid.d.ts.map +1 -1
- package/dist/Grid.js +5 -6
- package/dist/Grid.js.map +1 -1
- package/dist/GridAxisRange.d.ts +10 -0
- package/dist/GridAxisRange.d.ts.map +1 -0
- package/dist/GridAxisRange.js +17 -0
- package/dist/GridAxisRange.js.map +1 -0
- package/dist/GridMetricCalculator.d.ts +10 -8
- package/dist/GridMetricCalculator.d.ts.map +1 -1
- package/dist/GridMetricCalculator.js +38 -16
- package/dist/GridMetricCalculator.js.map +1 -1
- package/dist/GridMetrics.d.ts +8 -4
- package/dist/GridMetrics.d.ts.map +1 -1
- package/dist/GridModel.d.ts +20 -2
- package/dist/GridModel.d.ts.map +1 -1
- package/dist/GridModel.js +30 -2
- package/dist/GridModel.js.map +1 -1
- package/dist/GridMouseHandler.d.ts +0 -1
- package/dist/GridMouseHandler.d.ts.map +1 -1
- package/dist/GridRenderer.d.ts +33 -6
- package/dist/GridRenderer.d.ts.map +1 -1
- package/dist/GridRenderer.js +428 -179
- package/dist/GridRenderer.js.map +1 -1
- package/dist/GridUtils.d.ts +34 -24
- package/dist/GridUtils.d.ts.map +1 -1
- package/dist/GridUtils.js +99 -61
- package/dist/GridUtils.js.map +1 -1
- package/dist/MockGridModel.d.ts +1 -1
- package/dist/MockGridModel.d.ts.map +1 -1
- package/dist/MockGridModel.js +1 -0
- package/dist/MockGridModel.js.map +1 -1
- package/dist/MockTreeGridModel.d.ts +0 -1
- package/dist/MockTreeGridModel.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/mouse-handlers/GridColumnMoveMouseHandler.d.ts +44 -4
- package/dist/mouse-handlers/GridColumnMoveMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridColumnMoveMouseHandler.js +486 -80
- package/dist/mouse-handlers/GridColumnMoveMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.d.ts +7 -5
- package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.js +26 -14
- package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.d.ts +7 -5
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.js +11 -14
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridSeparatorMouseHandler.d.ts +11 -4
- package/dist/mouse-handlers/GridSeparatorMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridSeparatorMouseHandler.js +41 -31
- package/dist/mouse-handlers/GridSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/index.d.ts +1 -0
- package/dist/mouse-handlers/index.js +1 -0
- package/dist/mouse-handlers/index.js.map +1 -1
- package/package.json +3 -3
package/dist/GridUtils.d.ts
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import GridRange, { GridRangeIndex } from './GridRange';
|
|
3
|
-
import { BoxCoordinates, Coordinate, CoordinateMap, VisibleIndex,
|
|
3
|
+
import { BoxCoordinates, Coordinate, CoordinateMap, VisibleIndex, VisibleToModelMap, ModelIndex, ModelSizeMap, MoveOperation, SizeMap } from './GridMetrics';
|
|
4
4
|
import type { GridMetrics } from './GridMetrics';
|
|
5
5
|
import { GridTheme } from './GridTheme';
|
|
6
6
|
import { GridWheelEvent } from './GridMouseHandler';
|
|
7
|
-
|
|
8
|
-
export declare type AxisRange = Range<GridRangeIndex>;
|
|
9
|
-
export declare type BoundedAxisRange = Range<VisibleIndex>;
|
|
10
|
-
export declare function isAxisRange(range: unknown): range is AxisRange;
|
|
11
|
-
export declare function assertAxisRange(range: unknown): asserts range is AxisRange;
|
|
12
|
-
export declare function isBoundedAxisRange(range: unknown): range is BoundedAxisRange;
|
|
13
|
-
export declare function assertBoundedAxisRange(range: unknown): asserts range is BoundedAxisRange;
|
|
7
|
+
import { AxisRange, BoundedAxisRange, Range } from './GridAxisRange';
|
|
14
8
|
export declare type GridPoint = {
|
|
15
9
|
x: Coordinate;
|
|
16
10
|
y: Coordinate;
|
|
17
11
|
column: GridRangeIndex;
|
|
18
12
|
row: GridRangeIndex;
|
|
13
|
+
columnHeaderDepth?: number;
|
|
19
14
|
};
|
|
20
15
|
export interface CellInfo {
|
|
21
16
|
row: VisibleIndex | null;
|
|
@@ -39,6 +34,7 @@ export declare class GridUtils {
|
|
|
39
34
|
*/
|
|
40
35
|
static getGridPointFromXY(x: Coordinate, y: Coordinate, metrics: GridMetrics): GridPoint;
|
|
41
36
|
static getCellInfoFromXY(x: Coordinate, y: Coordinate, metrics: GridMetrics): CellInfo;
|
|
37
|
+
static getColumnHeaderDepthAtY(y: Coordinate, metrics: GridMetrics): number | undefined;
|
|
42
38
|
/**
|
|
43
39
|
* Iterate through each floating item at the start and call a callback, returning the first result
|
|
44
40
|
* @param start The count of floating items at the start
|
|
@@ -95,14 +91,14 @@ export declare class GridUtils {
|
|
|
95
91
|
* @param itemSizes The size of each item
|
|
96
92
|
* @returns The item index, or null if no item matches
|
|
97
93
|
*/
|
|
98
|
-
static getItemAtOffset(offset: Coordinate, itemCount: number, floatingStart: number, floatingEnd: number, items: VisibleIndex[], itemCoordinates: CoordinateMap, itemSizes: SizeMap): VisibleIndex | null;
|
|
94
|
+
static getItemAtOffset(offset: Coordinate, itemCount: number, floatingStart: number, floatingEnd: number, items: VisibleIndex[], itemCoordinates: CoordinateMap, itemSizes: SizeMap, ignoreFloating?: boolean): VisibleIndex | null;
|
|
99
95
|
/**
|
|
100
96
|
* Get the index of the column at the specified x coordinate
|
|
101
97
|
* @param x Coordinate to get the item of
|
|
102
98
|
* @param metrics Grid metrics
|
|
103
99
|
* @returns Index of the column at that coordinate, or null if no column matches
|
|
104
100
|
*/
|
|
105
|
-
static getColumnAtX(x: Coordinate, metrics: GridMetrics): VisibleIndex | null;
|
|
101
|
+
static getColumnAtX(x: Coordinate, metrics: GridMetrics, ignoreFloating?: boolean): VisibleIndex | null;
|
|
106
102
|
/**
|
|
107
103
|
* Get the index of the row at the specified y coordinate
|
|
108
104
|
* @param y Coordinate to get the item of
|
|
@@ -118,7 +114,7 @@ export declare class GridUtils {
|
|
|
118
114
|
* @param userSizes The user set sizes
|
|
119
115
|
* @returns Index of the next visible item, or null if no more are visible
|
|
120
116
|
*/
|
|
121
|
-
static getNextShownItem(startIndex: VisibleIndex, modelIndexes:
|
|
117
|
+
static getNextShownItem(startIndex: VisibleIndex, modelIndexes: VisibleToModelMap, visibleItems: VisibleIndex[], userSizes: ModelSizeMap): VisibleIndex | null;
|
|
122
118
|
/**
|
|
123
119
|
* Iterate backward through the visible columns until a shown column is hit
|
|
124
120
|
* @param columnIndex The column index to start iterating backward from
|
|
@@ -212,11 +208,11 @@ export declare class GridUtils {
|
|
|
212
208
|
/**
|
|
213
209
|
* Set a new order for items in the grid
|
|
214
210
|
* @param from The visible index to move from
|
|
215
|
-
* @param to The visible index to move the
|
|
211
|
+
* @param to The visible index to move the item to
|
|
216
212
|
* @param oldMovedItems The old reordered items
|
|
217
213
|
* @returns The new reordered items
|
|
218
214
|
*/
|
|
219
|
-
static moveItem(from: VisibleIndex, to: VisibleIndex, oldMovedItems
|
|
215
|
+
static moveItem(from: VisibleIndex, to: VisibleIndex, oldMovedItems: MoveOperation[]): MoveOperation[];
|
|
220
216
|
/**
|
|
221
217
|
* Move a visible range in the grid
|
|
222
218
|
*
|
|
@@ -229,14 +225,7 @@ export declare class GridUtils {
|
|
|
229
225
|
* @param oldMovedItems The old reordered items
|
|
230
226
|
* @returns The new reordered items
|
|
231
227
|
*/
|
|
232
|
-
static moveRange(from: BoundedAxisRange, to: VisibleIndex, oldMovedItems
|
|
233
|
-
/**
|
|
234
|
-
* Retrieve the model index given the currently moved items
|
|
235
|
-
* @param visibleIndex The visible index of the item to get the model index for
|
|
236
|
-
* @param movedItems The moved items
|
|
237
|
-
* @returns The model index of the item
|
|
238
|
-
*/
|
|
239
|
-
static getModelIndex(visibleIndex: VisibleIndex, movedItems?: MoveOperation[]): ModelIndex;
|
|
228
|
+
static moveRange(from: BoundedAxisRange, to: VisibleIndex, oldMovedItems: MoveOperation[]): MoveOperation[];
|
|
240
229
|
/**
|
|
241
230
|
* Applies the items moves to the AxisRange
|
|
242
231
|
* @param start The start index of the range
|
|
@@ -245,7 +234,7 @@ export declare class GridUtils {
|
|
|
245
234
|
* @param reverse If the moved items should be applied in reverse (this reverses the effects of the moves)
|
|
246
235
|
* @returns A list of AxisRanges in the translated space. Possibly multiple non-continuous ranges
|
|
247
236
|
*/
|
|
248
|
-
|
|
237
|
+
static applyItemMoves<T extends number | GridRangeIndex>(start: T, end: T, movedItems: MoveOperation[], reverse?: boolean): Range<T>[];
|
|
249
238
|
/**
|
|
250
239
|
* Applies the items moves to the givengrid range
|
|
251
240
|
* @param range The grid range to translate
|
|
@@ -255,6 +244,20 @@ export declare class GridUtils {
|
|
|
255
244
|
* @returns A list of grid ranges in the translated space. Possibly multiple non-continuous ranges
|
|
256
245
|
*/
|
|
257
246
|
static translateRange(range: GridRange, movedColumns: MoveOperation[], movedRows: MoveOperation[], reverse: boolean): GridRange[];
|
|
247
|
+
/**
|
|
248
|
+
* Retrieve the model index given the currently moved items
|
|
249
|
+
* @param visibleIndex The visible index of the item to get the model index for
|
|
250
|
+
* @param movedItems The moved items
|
|
251
|
+
* @returns The model index of the item
|
|
252
|
+
*/
|
|
253
|
+
static getModelIndex(visibleIndex: VisibleIndex, movedItems: MoveOperation[]): ModelIndex;
|
|
254
|
+
/**
|
|
255
|
+
* Retrieve the model indexes given the currently moved items
|
|
256
|
+
* @param visibleIndexes The visible indexes of the item to get the model indexes for
|
|
257
|
+
* @param movedItems The moved items
|
|
258
|
+
* @returns The model indexes of the item
|
|
259
|
+
*/
|
|
260
|
+
static getModelIndexes(visibleIndexes: ModelIndex[], movedItems: MoveOperation[]): VisibleIndex[];
|
|
258
261
|
/**
|
|
259
262
|
* Translate the provided UI start/end indexes to the model start/end indexes by applying the `movedItems` transformations.
|
|
260
263
|
* Since moved items can split apart a range, multiple pairs of indexes are returned
|
|
@@ -296,7 +299,7 @@ export declare class GridUtils {
|
|
|
296
299
|
*/
|
|
297
300
|
static getVisibleRangeIndexes(start: GridRangeIndex, end: GridRangeIndex, movedItems: MoveOperation[]): AxisRange[];
|
|
298
301
|
/**
|
|
299
|
-
* Translate the provided UI range into
|
|
302
|
+
* Translate the provided UI range into visible range, using the `movedColumns` and `movedRows` to apply the necessary transforms.
|
|
300
303
|
* `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
|
|
301
304
|
*
|
|
302
305
|
* @param uiRange The currently selected UI ranges
|
|
@@ -321,7 +324,14 @@ export declare class GridUtils {
|
|
|
321
324
|
* @param movedItems Moved items
|
|
322
325
|
* @returns The visible index of the item
|
|
323
326
|
*/
|
|
324
|
-
static getVisibleIndex(modelIndex: ModelIndex, movedItems
|
|
327
|
+
static getVisibleIndex(modelIndex: ModelIndex, movedItems: MoveOperation[]): VisibleIndex;
|
|
328
|
+
/**
|
|
329
|
+
* Retrieve the visible indexes given the currently moved items
|
|
330
|
+
* @param modelIndexes The model indexes to get the visible indexes for
|
|
331
|
+
* @param movedItems Moved items
|
|
332
|
+
* @returns The visible indexes of the item
|
|
333
|
+
*/
|
|
334
|
+
static getVisibleIndexes(modelIndexes: ModelIndex[], movedItems: MoveOperation[]): VisibleIndex[];
|
|
325
335
|
/**
|
|
326
336
|
* Check if the current platform is Mac
|
|
327
337
|
* @returns True if this platform is a Mac, false otherwise
|
package/dist/GridUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridUtils.d.ts","sourceRoot":"","sources":["../src/GridUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"GridUtils.d.ts","sourceRoot":"","sources":["../src/GridUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,SAAS,EAAE,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EACL,cAAc,EACd,UAAU,EACV,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,aAAa,EACb,OAAO,EACR,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACL,SAAS,EACT,gBAAgB,EAEhB,KAAK,EACN,MAAM,iBAAiB,CAAC;AAEzB,oBAAY,SAAS,GAAG;IACtB,CAAC,EAAE,UAAU,CAAC;IACd,CAAC,EAAE,UAAU,CAAC;IACd,MAAM,EAAE,cAAc,CAAC;IACvB,GAAG,EAAE,cAAc,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,YAAY,GAAG,IAAI,CAAC;IACzB,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,QAAQ,EAAE,UAAU,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,UAAU,GAAG,IAAI,CAAC;IAC/B,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC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;;;;;;;OAOG;IACH,MAAM,CAAC,mBAAmB,CACxB,OAAO,EAAE,WAAW,EACpB,GAAG,EAAE,cAAc,EACnB,MAAM,EAAE,cAAc,GACrB,cAAc;IAyCjB;;;;;;;;;OASG;IACH,MAAM,CAAC,cAAc,CACnB,UAAU,EAAE,cAAc,EAC1B,SAAS,SAAO,EAChB,UAAU,SAAM,EAChB,SAAS,SAAK,EACd,UAAU,SAAK,GACd;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IA8CrC,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM;IAclE,MAAM,CAAC,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,gBAAgB,EAAE;CAoBzE;AAED,eAAe,SAAS,CAAC"}
|
package/dist/GridUtils.js
CHANGED
|
@@ -4,23 +4,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
7
|
+
import clamp from 'lodash.clamp';
|
|
7
8
|
import GridRange from "./GridRange.js";
|
|
8
|
-
|
|
9
|
-
return Array.isArray(range) && range.length === 2 && (range[0] === null || typeof range[0] === 'number') && (range[1] === null || typeof range[1] === 'number');
|
|
10
|
-
}
|
|
11
|
-
export function assertAxisRange(range) {
|
|
12
|
-
if (!isAxisRange(range)) {
|
|
13
|
-
throw new Error("Expected axis range. Received: ".concat(range));
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export function isBoundedAxisRange(range) {
|
|
17
|
-
return isAxisRange(range) && range[0] != null && range[1] != null;
|
|
18
|
-
}
|
|
19
|
-
export function assertBoundedAxisRange(range) {
|
|
20
|
-
if (!isBoundedAxisRange(range)) {
|
|
21
|
-
throw new Error("Expected bounded axis range. Received: ".concat(range));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
9
|
+
import { isBoundedAxisRange } from "./GridAxisRange.js";
|
|
24
10
|
export class GridUtils {
|
|
25
11
|
// use same constant as chrome source for windows
|
|
26
12
|
// https://github.com/chromium/chromium/blob/973af9d461b6b5dc60208c8d3d66adc27e53da78/ui/events/blink/web_input_event_builders_win.cc#L285
|
|
@@ -35,11 +21,13 @@ export class GridUtils {
|
|
|
35
21
|
static getGridPointFromXY(x, y, metrics) {
|
|
36
22
|
var column = GridUtils.getColumnAtX(x, metrics);
|
|
37
23
|
var row = GridUtils.getRowAtY(y, metrics);
|
|
24
|
+
var columnHeaderDepth = GridUtils.getColumnHeaderDepthAtY(y, metrics);
|
|
38
25
|
return {
|
|
39
26
|
x,
|
|
40
27
|
y,
|
|
41
28
|
row,
|
|
42
|
-
column
|
|
29
|
+
column,
|
|
30
|
+
columnHeaderDepth
|
|
43
31
|
};
|
|
44
32
|
}
|
|
45
33
|
|
|
@@ -73,6 +61,20 @@ export class GridUtils {
|
|
|
73
61
|
rowHeight: rowHeight !== null && rowHeight !== void 0 ? rowHeight : null
|
|
74
62
|
};
|
|
75
63
|
}
|
|
64
|
+
|
|
65
|
+
static getColumnHeaderDepthAtY(y, metrics) {
|
|
66
|
+
var row = GridUtils.getRowAtY(y, metrics);
|
|
67
|
+
var {
|
|
68
|
+
columnHeaderHeight,
|
|
69
|
+
columnHeaderMaxDepth
|
|
70
|
+
} = metrics;
|
|
71
|
+
|
|
72
|
+
if (row === null && y <= columnHeaderHeight * columnHeaderMaxDepth) {
|
|
73
|
+
return clamp(columnHeaderMaxDepth - Math.ceil(y / columnHeaderHeight), 0, columnHeaderMaxDepth - 1);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
76
78
|
/**
|
|
77
79
|
* Iterate through each floating item at the start and call a callback, returning the first result
|
|
78
80
|
* @param start The count of floating items at the start
|
|
@@ -194,7 +196,8 @@ export class GridUtils {
|
|
|
194
196
|
|
|
195
197
|
|
|
196
198
|
static getItemAtOffset(offset, itemCount, floatingStart, floatingEnd, items, itemCoordinates, itemSizes) {
|
|
197
|
-
var
|
|
199
|
+
var ignoreFloating = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
200
|
+
var floatingItem = ignoreFloating ? undefined : GridUtils.iterateFloating(floatingStart, floatingEnd, itemCount, item => {
|
|
198
201
|
if (GridUtils.isInItem(item, itemCoordinates, itemSizes, offset)) {
|
|
199
202
|
return item;
|
|
200
203
|
}
|
|
@@ -202,7 +205,7 @@ export class GridUtils {
|
|
|
202
205
|
return undefined;
|
|
203
206
|
});
|
|
204
207
|
|
|
205
|
-
if (floatingItem !== undefined) {
|
|
208
|
+
if (!ignoreFloating && floatingItem !== undefined) {
|
|
206
209
|
return floatingItem;
|
|
207
210
|
}
|
|
208
211
|
|
|
@@ -225,6 +228,7 @@ export class GridUtils {
|
|
|
225
228
|
|
|
226
229
|
|
|
227
230
|
static getColumnAtX(x, metrics) {
|
|
231
|
+
var ignoreFloating = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
228
232
|
var {
|
|
229
233
|
columnCount,
|
|
230
234
|
floatingLeftColumnCount,
|
|
@@ -239,7 +243,7 @@ export class GridUtils {
|
|
|
239
243
|
return null;
|
|
240
244
|
}
|
|
241
245
|
|
|
242
|
-
return this.getItemAtOffset(x - gridX, columnCount, floatingLeftColumnCount, floatingRightColumnCount, visibleColumns, visibleColumnXs, visibleColumnWidths);
|
|
246
|
+
return this.getItemAtOffset(x - gridX, columnCount, floatingLeftColumnCount, floatingRightColumnCount, visibleColumns, visibleColumnXs, visibleColumnWidths, ignoreFloating);
|
|
243
247
|
}
|
|
244
248
|
/**
|
|
245
249
|
* Get the index of the row at the specified y coordinate
|
|
@@ -343,14 +347,15 @@ export class GridUtils {
|
|
|
343
347
|
floatingLeftWidth,
|
|
344
348
|
visibleColumns,
|
|
345
349
|
visibleColumnXs,
|
|
346
|
-
visibleColumnWidths
|
|
350
|
+
visibleColumnWidths,
|
|
351
|
+
columnHeaderMaxDepth
|
|
347
352
|
} = metrics;
|
|
348
353
|
var {
|
|
349
354
|
allowColumnResize,
|
|
350
355
|
headerSeparatorHandleSize
|
|
351
356
|
} = theme;
|
|
352
357
|
|
|
353
|
-
if (columnHeaderHeight < y || !allowColumnResize || headerSeparatorHandleSize <= 0) {
|
|
358
|
+
if (columnHeaderMaxDepth * columnHeaderHeight < y || !allowColumnResize || headerSeparatorHandleSize <= 0) {
|
|
354
359
|
return null;
|
|
355
360
|
}
|
|
356
361
|
|
|
@@ -633,25 +638,30 @@ export class GridUtils {
|
|
|
633
638
|
/**
|
|
634
639
|
* Set a new order for items in the grid
|
|
635
640
|
* @param from The visible index to move from
|
|
636
|
-
* @param to The visible index to move the
|
|
641
|
+
* @param to The visible index to move the item to
|
|
637
642
|
* @param oldMovedItems The old reordered items
|
|
638
643
|
* @returns The new reordered items
|
|
639
644
|
*/
|
|
640
645
|
|
|
641
646
|
|
|
642
|
-
static moveItem(from, to) {
|
|
643
|
-
var oldMovedItems = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
644
|
-
|
|
647
|
+
static moveItem(from, to, oldMovedItems) {
|
|
645
648
|
if (from === to) {
|
|
646
649
|
return oldMovedItems;
|
|
647
650
|
}
|
|
648
651
|
|
|
649
652
|
var movedItems = [...oldMovedItems];
|
|
653
|
+
var lastMovedItem = movedItems[movedItems.length - 1]; // Check if we should combine with the previous move
|
|
654
|
+
// E.g. 1 -> 2, 2 -> 3 can just be 1 -> 3
|
|
650
655
|
|
|
651
|
-
if (
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
656
|
+
if (lastMovedItem && !isBoundedAxisRange(lastMovedItem.from) && lastMovedItem.to === from) {
|
|
657
|
+
// Remove the move if it is now a no-op
|
|
658
|
+
if (lastMovedItem.from === to) {
|
|
659
|
+
movedItems.pop();
|
|
660
|
+
} else {
|
|
661
|
+
movedItems[movedItems.length - 1] = _objectSpread(_objectSpread({}, lastMovedItem), {}, {
|
|
662
|
+
to
|
|
663
|
+
});
|
|
664
|
+
}
|
|
655
665
|
} else {
|
|
656
666
|
movedItems.push({
|
|
657
667
|
from,
|
|
@@ -675,42 +685,37 @@ export class GridUtils {
|
|
|
675
685
|
*/
|
|
676
686
|
|
|
677
687
|
|
|
678
|
-
static moveRange(from, to) {
|
|
679
|
-
var oldMovedItems = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
680
|
-
|
|
688
|
+
static moveRange(from, to, oldMovedItems) {
|
|
681
689
|
if (from[0] === to) {
|
|
682
690
|
return oldMovedItems;
|
|
683
691
|
}
|
|
684
692
|
|
|
685
693
|
var movedItems = [...oldMovedItems];
|
|
686
|
-
var lastMovedItem = movedItems[movedItems.length - 1];
|
|
694
|
+
var lastMovedItem = movedItems[movedItems.length - 1]; // Check if we should combine with the previous move
|
|
695
|
+
// E.g. [1, 2] -> 2, [2, 3] -> 3 can just be [1, 2] -> 3
|
|
687
696
|
|
|
688
697
|
if (lastMovedItem && isBoundedAxisRange(lastMovedItem.from) && lastMovedItem.from[1] - lastMovedItem.from[0] === from[1] - from[0] && lastMovedItem.to === from[0]) {
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
698
|
+
// Remove the move if it is now a no-op
|
|
699
|
+
if (lastMovedItem.from[0] === to) {
|
|
700
|
+
movedItems.pop();
|
|
701
|
+
} else {
|
|
702
|
+
movedItems[movedItems.length - 1] = _objectSpread(_objectSpread({}, lastMovedItem), {}, {
|
|
703
|
+
to
|
|
704
|
+
});
|
|
705
|
+
}
|
|
692
706
|
} else {
|
|
693
|
-
// TODO #620
|
|
694
707
|
movedItems.push({
|
|
695
|
-
from
|
|
708
|
+
from,
|
|
696
709
|
to
|
|
697
710
|
});
|
|
698
|
-
}
|
|
711
|
+
} // Remove the move if it is now a no-op
|
|
699
712
|
|
|
700
|
-
return movedItems;
|
|
701
|
-
}
|
|
702
|
-
/**
|
|
703
|
-
* Retrieve the model index given the currently moved items
|
|
704
|
-
* @param visibleIndex The visible index of the item to get the model index for
|
|
705
|
-
* @param movedItems The moved items
|
|
706
|
-
* @returns The model index of the item
|
|
707
|
-
*/
|
|
708
713
|
|
|
714
|
+
if (movedItems[movedItems.length - 1].from === movedItems[movedItems.length - 1].to) {
|
|
715
|
+
movedItems.pop();
|
|
716
|
+
}
|
|
709
717
|
|
|
710
|
-
|
|
711
|
-
var movedItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
712
|
-
var modelIndex = GridUtils.applyItemMoves(visibleIndex, visibleIndex, movedItems, true)[0][0];
|
|
713
|
-
return modelIndex;
|
|
718
|
+
return movedItems;
|
|
714
719
|
}
|
|
715
720
|
/**
|
|
716
721
|
* Applies the items moves to the AxisRange
|
|
@@ -843,6 +848,29 @@ export class GridUtils {
|
|
|
843
848
|
|
|
844
849
|
return ranges;
|
|
845
850
|
}
|
|
851
|
+
/**
|
|
852
|
+
* Retrieve the model index given the currently moved items
|
|
853
|
+
* @param visibleIndex The visible index of the item to get the model index for
|
|
854
|
+
* @param movedItems The moved items
|
|
855
|
+
* @returns The model index of the item
|
|
856
|
+
*/
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
static getModelIndex(visibleIndex, movedItems) {
|
|
860
|
+
var modelIndex = GridUtils.applyItemMoves(visibleIndex, visibleIndex, movedItems, true)[0][0];
|
|
861
|
+
return modelIndex;
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Retrieve the model indexes given the currently moved items
|
|
865
|
+
* @param visibleIndexes The visible indexes of the item to get the model indexes for
|
|
866
|
+
* @param movedItems The moved items
|
|
867
|
+
* @returns The model indexes of the item
|
|
868
|
+
*/
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
static getModelIndexes(visibleIndexes, movedItems) {
|
|
872
|
+
return visibleIndexes.map(i => GridUtils.getModelIndex(i, movedItems));
|
|
873
|
+
}
|
|
846
874
|
/**
|
|
847
875
|
* Translate the provided UI start/end indexes to the model start/end indexes by applying the `movedItems` transformations.
|
|
848
876
|
* Since moved items can split apart a range, multiple pairs of indexes are returned
|
|
@@ -910,7 +938,7 @@ export class GridUtils {
|
|
|
910
938
|
return GridUtils.applyItemMoves(start, end, movedItems, false);
|
|
911
939
|
}
|
|
912
940
|
/**
|
|
913
|
-
* Translate the provided UI range into
|
|
941
|
+
* Translate the provided UI range into visible range, using the `movedColumns` and `movedRows` to apply the necessary transforms.
|
|
914
942
|
* `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
|
|
915
943
|
*
|
|
916
944
|
* @param uiRange The currently selected UI ranges
|
|
@@ -955,11 +983,21 @@ export class GridUtils {
|
|
|
955
983
|
*/
|
|
956
984
|
|
|
957
985
|
|
|
958
|
-
static getVisibleIndex(modelIndex) {
|
|
959
|
-
var movedItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
986
|
+
static getVisibleIndex(modelIndex, movedItems) {
|
|
960
987
|
var visibleIndex = GridUtils.applyItemMoves(modelIndex, modelIndex, movedItems)[0][0];
|
|
961
988
|
return visibleIndex;
|
|
962
989
|
}
|
|
990
|
+
/**
|
|
991
|
+
* Retrieve the visible indexes given the currently moved items
|
|
992
|
+
* @param modelIndexes The model indexes to get the visible indexes for
|
|
993
|
+
* @param movedItems Moved items
|
|
994
|
+
* @returns The visible indexes of the item
|
|
995
|
+
*/
|
|
996
|
+
|
|
997
|
+
|
|
998
|
+
static getVisibleIndexes(modelIndexes, movedItems) {
|
|
999
|
+
return modelIndexes.map(i => GridUtils.getVisibleIndex(i, movedItems));
|
|
1000
|
+
}
|
|
963
1001
|
/**
|
|
964
1002
|
* Check if the current platform is Mac
|
|
965
1003
|
* @returns True if this platform is a Mac, false otherwise
|
|
@@ -1156,15 +1194,15 @@ export class GridUtils {
|
|
|
1156
1194
|
|
|
1157
1195
|
for (var i = 0; i < ranges.length; i += 1) {
|
|
1158
1196
|
var range = ranges[i];
|
|
1159
|
-
var
|
|
1160
|
-
var
|
|
1197
|
+
var start = range[0];
|
|
1198
|
+
var end = range[1];
|
|
1161
1199
|
|
|
1162
1200
|
if (i === 0) {
|
|
1163
|
-
mergedRanges.push([
|
|
1164
|
-
} else if (
|
|
1165
|
-
mergedRanges[mergedRanges.length - 1][1] = Math.max(mergedRanges[mergedRanges.length - 1][1],
|
|
1201
|
+
mergedRanges.push([start, end]);
|
|
1202
|
+
} else if (start - 1 <= mergedRanges[mergedRanges.length - 1][1]) {
|
|
1203
|
+
mergedRanges[mergedRanges.length - 1][1] = Math.max(mergedRanges[mergedRanges.length - 1][1], end);
|
|
1166
1204
|
} else {
|
|
1167
|
-
mergedRanges.push([
|
|
1205
|
+
mergedRanges.push([start, end]);
|
|
1168
1206
|
}
|
|
1169
1207
|
}
|
|
1170
1208
|
|