@deephaven/grid 0.13.3-beta.0 → 0.14.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 +1 -1
- package/dist/Grid.d.ts.map +1 -1
- package/dist/Grid.js +1 -1
- package/dist/Grid.js.map +1 -1
- package/dist/GridMetricCalculator.d.ts +2 -2
- package/dist/GridMetricCalculator.d.ts.map +1 -1
- package/dist/GridMetricCalculator.js.map +1 -1
- package/dist/GridMetrics.d.ts.map +1 -1
- package/dist/GridRenderer.d.ts +2 -2
- package/dist/GridRenderer.d.ts.map +1 -1
- package/dist/GridRenderer.js.map +1 -1
- package/dist/GridUtils.d.ts +21 -5
- package/dist/GridUtils.d.ts.map +1 -1
- package/dist/GridUtils.js +114 -68
- package/dist/GridUtils.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/GridUtils.d.ts
CHANGED
|
@@ -5,9 +5,12 @@ import type { GridMetrics } from './GridMetrics';
|
|
|
5
5
|
import { GridTheme } from './GridTheme';
|
|
6
6
|
import { GridWheelEvent } from './GridMouseHandler';
|
|
7
7
|
declare type Range<T> = [start: T, end: T];
|
|
8
|
-
export declare type AxisRange = Range<
|
|
9
|
-
export declare type BoundedAxisRange = Range<
|
|
10
|
-
export declare
|
|
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;
|
|
11
14
|
export declare type GridPoint = {
|
|
12
15
|
x: Coordinate;
|
|
13
16
|
y: Coordinate;
|
|
@@ -214,6 +217,19 @@ export declare class GridUtils {
|
|
|
214
217
|
* @returns The new reordered items
|
|
215
218
|
*/
|
|
216
219
|
static moveItem(from: VisibleIndex, to: VisibleIndex, oldMovedItems?: MoveOperation[]): MoveOperation[];
|
|
220
|
+
/**
|
|
221
|
+
* Move a visible range in the grid
|
|
222
|
+
*
|
|
223
|
+
* This will effectively slice the range out of the grid,
|
|
224
|
+
* re-index the remaining columns,
|
|
225
|
+
* then insert the range with the first element at the provided index
|
|
226
|
+
*
|
|
227
|
+
* @param from The visible axis range to move
|
|
228
|
+
* @param to The visible index to move the start of the range to
|
|
229
|
+
* @param oldMovedItems The old reordered items
|
|
230
|
+
* @returns The new reordered items
|
|
231
|
+
*/
|
|
232
|
+
static moveRange(from: BoundedAxisRange, to: VisibleIndex, oldMovedItems?: MoveOperation[]): MoveOperation[];
|
|
217
233
|
/**
|
|
218
234
|
* Retrieve the model index given the currently moved items
|
|
219
235
|
* @param visibleIndex The visible index of the item to get the model index for
|
|
@@ -248,7 +264,7 @@ export declare class GridUtils {
|
|
|
248
264
|
* @param movedItems Moved item pairs in this dimension
|
|
249
265
|
* @returns Array of start/end pairs of the indexes after transformations applied.
|
|
250
266
|
*/
|
|
251
|
-
static getModelRangeIndexes(start: GridRangeIndex, end: GridRangeIndex, movedItems: MoveOperation[]):
|
|
267
|
+
static getModelRangeIndexes(start: GridRangeIndex, end: GridRangeIndex, movedItems: MoveOperation[]): AxisRange[];
|
|
252
268
|
/**
|
|
253
269
|
* Translate the provided UI range into model range, using the `movedColumns` and `movedRows` to apply the necessary transforms.
|
|
254
270
|
* `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
|
|
@@ -278,7 +294,7 @@ export declare class GridUtils {
|
|
|
278
294
|
* @param movedItems Moved item pairs in this dimension
|
|
279
295
|
* @returns Array of start/end pairs of the indexes after transformations applied.
|
|
280
296
|
*/
|
|
281
|
-
static getVisibleRangeIndexes(start: GridRangeIndex, end: GridRangeIndex, movedItems: MoveOperation[]):
|
|
297
|
+
static getVisibleRangeIndexes(start: GridRangeIndex, end: GridRangeIndex, movedItems: MoveOperation[]): AxisRange[];
|
|
282
298
|
/**
|
|
283
299
|
* Translate the provided UI range into model range, using the `movedColumns` and `movedRows` to apply the necessary transforms.
|
|
284
300
|
* `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
|
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;AAC1B,OAAO,SAAS,EAAE,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EACL,cAAc,EACd,UAAU,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,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;AAEpD,aAAK,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;AAEnC,oBAAY,SAAS,GAAG,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"GridUtils.d.ts","sourceRoot":"","sources":["../src/GridUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,EAAE,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EACL,cAAc,EACd,UAAU,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,UAAU,EACV,YAAY,EACZ,aAAa,EACb,OAAO,EACR,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,WAAW,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,EACtB,UAAU,GAAE,aAAa,EAAO,GAC/B,YAAY;IAUf;;;OAGG;IACH,MAAM,CAAC,aAAa,IAAI,OAAO;IAK/B;;;OAGG;IACH,MAAM,CAAC,cAAc,IAAI,SAAS,GAAG,SAAS;IAQ9C;;;;OAIG;IACH,MAAM,CAAC,iBAAiB,CACtB,KAAK,EAAE,UAAU,GAAG,aAAa,GAAG,KAAK,CAAC,aAAa,GAAG,KAAK,CAAC,UAAU,GACzE,OAAO;IAKV;;;;;OAKG;IACH,MAAM,CAAC,iBAAiB,CACtB,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,YAAY,GAC7B,OAAO;IAIV;;;;;OAKG;IACH,MAAM,CAAC,qBAAqB,CAC1B,OAAO,EAAE,UAAU,EAAE,EACrB,gBAAgB,EAAE,YAAY,GAC7B,OAAO;IAOV;;;;;;;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;CA6CtC;AAED,eAAe,SAAS,CAAC"}
|
package/dist/GridUtils.js
CHANGED
|
@@ -5,6 +5,22 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
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
7
|
import GridRange from "./GridRange.js";
|
|
8
|
+
export function isAxisRange(range) {
|
|
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
|
+
}
|
|
8
24
|
export class GridUtils {
|
|
9
25
|
// use same constant as chrome source for windows
|
|
10
26
|
// https://github.com/chromium/chromium/blob/973af9d461b6b5dc60208c8d3d66adc27e53da78/ui/events/blink/web_input_event_builders_win.cc#L285
|
|
@@ -645,6 +661,44 @@ export class GridUtils {
|
|
|
645
661
|
|
|
646
662
|
return movedItems;
|
|
647
663
|
}
|
|
664
|
+
/**
|
|
665
|
+
* Move a visible range in the grid
|
|
666
|
+
*
|
|
667
|
+
* This will effectively slice the range out of the grid,
|
|
668
|
+
* re-index the remaining columns,
|
|
669
|
+
* then insert the range with the first element at the provided index
|
|
670
|
+
*
|
|
671
|
+
* @param from The visible axis range to move
|
|
672
|
+
* @param to The visible index to move the start of the range to
|
|
673
|
+
* @param oldMovedItems The old reordered items
|
|
674
|
+
* @returns The new reordered items
|
|
675
|
+
*/
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
static moveRange(from, to) {
|
|
679
|
+
var oldMovedItems = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
680
|
+
|
|
681
|
+
if (from[0] === to) {
|
|
682
|
+
return oldMovedItems;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
var movedItems = [...oldMovedItems];
|
|
686
|
+
var lastMovedItem = movedItems[movedItems.length - 1];
|
|
687
|
+
|
|
688
|
+
if (lastMovedItem && isBoundedAxisRange(lastMovedItem.from) && lastMovedItem.from[1] - lastMovedItem.from[0] === from[1] - from[0] && lastMovedItem.to === from[0]) {
|
|
689
|
+
movedItems[movedItems.length - 1] = _objectSpread(_objectSpread({}, movedItems[movedItems.length - 1]), {}, {
|
|
690
|
+
to
|
|
691
|
+
});
|
|
692
|
+
} else {
|
|
693
|
+
// TODO #620
|
|
694
|
+
movedItems.push({
|
|
695
|
+
from: from,
|
|
696
|
+
to
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
return movedItems;
|
|
701
|
+
}
|
|
648
702
|
/**
|
|
649
703
|
* Retrieve the model index given the currently moved items
|
|
650
704
|
* @param visibleIndex The visible index of the item to get the model index for
|
|
@@ -672,94 +726,82 @@ export class GridUtils {
|
|
|
672
726
|
var reverse = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
673
727
|
var result = [[start, end]];
|
|
674
728
|
|
|
675
|
-
|
|
729
|
+
var _loop = function _loop(i) {
|
|
676
730
|
var {
|
|
677
|
-
from:
|
|
731
|
+
from: fromItemOrRange,
|
|
678
732
|
to: toItem
|
|
679
733
|
} = movedItems[i];
|
|
680
|
-
var
|
|
681
|
-
var
|
|
734
|
+
var length = 1;
|
|
735
|
+
var fromItem = void 0;
|
|
736
|
+
|
|
737
|
+
if (isBoundedAxisRange(fromItemOrRange)) {
|
|
738
|
+
length = fromItemOrRange[1] - fromItemOrRange[0] + 1; // Ranges are inclusive
|
|
739
|
+
|
|
740
|
+
[fromItem] = fromItemOrRange;
|
|
741
|
+
} else {
|
|
742
|
+
fromItem = fromItemOrRange;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
var fromStart = reverse ? toItem : fromItem;
|
|
746
|
+
var fromEnd = fromStart + length - 1;
|
|
747
|
+
var toStart = reverse ? fromItem : toItem;
|
|
748
|
+
var moveDistance = toStart - fromStart;
|
|
682
749
|
var nextResult = [];
|
|
683
750
|
|
|
684
|
-
|
|
751
|
+
var _loop2 = function _loop2(j) {
|
|
685
752
|
var _result$j$, _result$j$2;
|
|
686
753
|
|
|
687
754
|
var currentStart = (_result$j$ = result[j][0]) !== null && _result$j$ !== void 0 ? _result$j$ : Number.NEGATIVE_INFINITY;
|
|
688
755
|
var currentEnd = (_result$j$2 = result[j][1]) !== null && _result$j$2 !== void 0 ? _result$j$2 : Number.POSITIVE_INFINITY;
|
|
689
|
-
var
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
//
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
nextResult.push([currentStart + 1, currentEnd + 1]);
|
|
706
|
-
} else if (to <= currentEnd) {
|
|
707
|
-
// To within
|
|
708
|
-
nextResult.push([currentStart, to - 1]);
|
|
709
|
-
nextResult.push([to + 1, currentEnd + 1]);
|
|
710
|
-
}
|
|
711
|
-
} else if (to < currentStart) {
|
|
712
|
-
// From within to before
|
|
713
|
-
if (from > currentStart) {
|
|
714
|
-
nextResult.push([currentStart + 1, from]);
|
|
756
|
+
var movedRange = void 0;
|
|
757
|
+
var currentResult = [[currentStart, fromStart - 1], [fromStart, fromEnd], [fromEnd + 1, currentEnd]].map(_ref2 => {
|
|
758
|
+
var [s, e] = _ref2;
|
|
759
|
+
return [// Cap the ranges to within the current range bounds
|
|
760
|
+
Math.max(s, currentStart), Math.min(e, currentEnd)];
|
|
761
|
+
}).filter(_ref3 => {
|
|
762
|
+
var [s, e] = _ref3;
|
|
763
|
+
return s <= e;
|
|
764
|
+
}) // Remove invalid ranges
|
|
765
|
+
.map(range => {
|
|
766
|
+
var [s, e] = range;
|
|
767
|
+
|
|
768
|
+
if (fromStart <= s && fromEnd >= e) {
|
|
769
|
+
// Current range in moved range
|
|
770
|
+
movedRange = [s + moveDistance, e + moveDistance];
|
|
771
|
+
return movedRange;
|
|
715
772
|
}
|
|
716
773
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
nextResult.push([from + 1, currentEnd]);
|
|
721
|
-
}
|
|
722
|
-
} else if (to > currentEnd) {
|
|
723
|
-
// From within to after
|
|
724
|
-
if (from > currentStart) {
|
|
725
|
-
nextResult.push([currentStart, from - 1]);
|
|
774
|
+
if (fromEnd < s) {
|
|
775
|
+
// Current range is after moved range
|
|
776
|
+
return [s - length, e - length];
|
|
726
777
|
}
|
|
727
778
|
|
|
728
|
-
|
|
779
|
+
return range;
|
|
780
|
+
}).map(range => {
|
|
781
|
+
var [s, e] = range;
|
|
729
782
|
|
|
730
|
-
if (
|
|
731
|
-
|
|
783
|
+
if (toStart > s && toStart <= e) {
|
|
784
|
+
// Moved range splits this range
|
|
785
|
+
return [[s, toStart - 1], [toStart + length, e + length]];
|
|
732
786
|
}
|
|
733
|
-
} else if (from > to) {
|
|
734
|
-
// From within after to within before
|
|
735
|
-
if (to > currentStart) {
|
|
736
|
-
nextResult.push([currentStart, to - 1]);
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
nextResult.push([to + 1, from]);
|
|
740
|
-
nextResult.push([to, to]);
|
|
741
787
|
|
|
742
|
-
if (
|
|
743
|
-
|
|
788
|
+
if (range === movedRange) {
|
|
789
|
+
// Moved range has already been shifted
|
|
790
|
+
return [range];
|
|
744
791
|
}
|
|
745
|
-
} else if (from < to) {
|
|
746
|
-
// From within before to within after
|
|
747
|
-
if (from > currentStart) {
|
|
748
|
-
nextResult.push([currentStart, from - 1]);
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
nextResult.push([to, to]);
|
|
752
|
-
nextResult.push([from, to - 1]);
|
|
753
792
|
|
|
754
|
-
if (
|
|
755
|
-
|
|
793
|
+
if (toStart <= s) {
|
|
794
|
+
// Moved range shifts this range right
|
|
795
|
+
return [[s + length, e + length]];
|
|
756
796
|
}
|
|
757
|
-
}
|
|
758
797
|
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
798
|
+
return [range];
|
|
799
|
+
}).flat();
|
|
800
|
+
nextResult.push(...currentResult);
|
|
801
|
+
};
|
|
802
|
+
|
|
803
|
+
for (var j = 0; j < result.length; j += 1) {
|
|
804
|
+
_loop2(j);
|
|
763
805
|
} // Return infinity values back to null
|
|
764
806
|
|
|
765
807
|
|
|
@@ -767,6 +809,10 @@ export class GridUtils {
|
|
|
767
809
|
var [s, e] = _ref;
|
|
768
810
|
return [Number.isFinite(s) ? s : null, Number.isFinite(e) ? e : null];
|
|
769
811
|
});
|
|
812
|
+
};
|
|
813
|
+
|
|
814
|
+
for (var i = reverse ? movedItems.length - 1 : 0; reverse ? i >= 0 : i < movedItems.length; reverse ? i -= 1 : i += 1) {
|
|
815
|
+
_loop(i);
|
|
770
816
|
}
|
|
771
817
|
|
|
772
818
|
return result;
|