@deephaven/grid 0.13.2-beta.0 → 0.13.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.
@@ -4,8 +4,10 @@ import { BoxCoordinates, Coordinate, CoordinateMap, VisibleIndex, IndexModelMap,
4
4
  import type { GridMetrics } from './GridMetrics';
5
5
  import { GridTheme } from './GridTheme';
6
6
  import { GridWheelEvent } from './GridMouseHandler';
7
- export declare type AxisRange = [start: VisibleIndex, end: VisibleIndex];
8
- export declare type GridAxisRange = [start: GridRangeIndex, end: GridRangeIndex];
7
+ declare type Range<T> = [start: T, end: T];
8
+ export declare type AxisRange = Range<VisibleIndex>;
9
+ export declare type BoundedAxisRange = Range<number>;
10
+ export declare type GridAxisRange = Range<GridRangeIndex>;
9
11
  export declare type GridPoint = {
10
12
  x: Coordinate;
11
13
  y: Coordinate;
@@ -219,6 +221,24 @@ export declare class GridUtils {
219
221
  * @returns The model index of the item
220
222
  */
221
223
  static getModelIndex(visibleIndex: VisibleIndex, movedItems?: MoveOperation[]): ModelIndex;
224
+ /**
225
+ * Applies the items moves to the AxisRange
226
+ * @param start The start index of the range
227
+ * @param end The end index of the range
228
+ * @param movedItems The move operations to apply
229
+ * @param reverse If the moved items should be applied in reverse (this reverses the effects of the moves)
230
+ * @returns A list of AxisRanges in the translated space. Possibly multiple non-continuous ranges
231
+ */
232
+ private static applyItemMoves;
233
+ /**
234
+ * Applies the items moves to the givengrid range
235
+ * @param range The grid range to translate
236
+ * @param movedColumns The moved columns
237
+ * @param movedRows The moved rows
238
+ * @param reverse If the moved items should be reversed (i.e. visible to model range)
239
+ * @returns A list of grid ranges in the translated space. Possibly multiple non-continuous ranges
240
+ */
241
+ static translateRange(range: GridRange, movedColumns: MoveOperation[], movedRows: MoveOperation[], reverse: boolean): GridRange[];
222
242
  /**
223
243
  * Translate the provided UI start/end indexes to the model start/end indexes by applying the `movedItems` transformations.
224
244
  * Since moved items can split apart a range, multiple pairs of indexes are returned
@@ -249,6 +269,36 @@ export declare class GridUtils {
249
269
  * @returns The model ranges after translation.
250
270
  */
251
271
  static getModelRanges(uiRanges: GridRange[], movedColumns?: MoveOperation[], movedRows?: MoveOperation[]): GridRange[];
272
+ /**
273
+ * Translate the provided UI start/end indexes to the model start/end indexes by applying the `movedItems` transformations.
274
+ * Since moved items can split apart a range, multiple pairs of indexes are returned
275
+ *
276
+ * @param start Start item in one dimension
277
+ * @param end End item in one dimension
278
+ * @param movedItems Moved item pairs in this dimension
279
+ * @returns Array of start/end pairs of the indexes after transformations applied.
280
+ */
281
+ static getVisibleRangeIndexes(start: GridRangeIndex, end: GridRangeIndex, movedItems: MoveOperation[]): GridAxisRange[];
282
+ /**
283
+ * Translate the provided UI range into model range, using the `movedColumns` and `movedRows` to apply the necessary transforms.
284
+ * `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
285
+ *
286
+ * @param uiRange The currently selected UI ranges
287
+ * @param movedColumns The moved column pairs
288
+ * @param movedRows The moved row pairs
289
+ * @returns The model ranges after translation.
290
+ */
291
+ static getVisibleRange(modelRange: GridRange, movedColumns?: MoveOperation[], movedRows?: MoveOperation[]): GridRange[];
292
+ /**
293
+ * Translate the provided model ranges into visible ranges, using the `movedColumns` and `movedRows` to apply the necessary transforms.
294
+ * `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
295
+ *
296
+ * @param modelRanges The model ranges
297
+ * @param movedColumns The moved column pairs
298
+ * @param movedRows The moved row pairs
299
+ * @returns The model ranges after translation.
300
+ */
301
+ static getVisibleRanges(modelRanges: GridRange[], movedColumns?: MoveOperation[], movedRows?: MoveOperation[]): GridRange[];
252
302
  /**
253
303
  * Retrieve the visible index given the currently moved items
254
304
  * @param modelIndex The model index to get the visible index for
@@ -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,EAA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;;;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
@@ -655,97 +655,89 @@ export class GridUtils {
655
655
 
656
656
  static getModelIndex(visibleIndex) {
657
657
  var movedItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
658
- var modelIndex = visibleIndex;
659
-
660
- for (var i = movedItems.length - 1; i >= 0; i -= 1) {
661
- var movedItem = movedItems[i];
662
-
663
- if (modelIndex === movedItem.to) {
664
- ({
665
- from: modelIndex
666
- } = movedItem);
667
- } else if (movedItem.from <= modelIndex && modelIndex < movedItem.to) {
668
- modelIndex += 1;
669
- } else if (movedItem.to < modelIndex && modelIndex <= movedItem.from) {
670
- modelIndex -= 1;
671
- }
672
- }
673
-
658
+ var modelIndex = GridUtils.applyItemMoves(visibleIndex, visibleIndex, movedItems, true)[0][0];
674
659
  return modelIndex;
675
660
  }
676
661
  /**
677
- * Translate the provided UI start/end indexes to the model start/end indexes by applying the `movedItems` transformations.
678
- * Since moved items can split apart a range, multiple pairs of indexes are returned
679
- *
680
- * @param start Start item in one dimension
681
- * @param end End item in one dimension
682
- * @param movedItems Moved item pairs in this dimension
683
- * @returns Array of start/end pairs of the indexes after transformations applied.
662
+ * Applies the items moves to the AxisRange
663
+ * @param start The start index of the range
664
+ * @param end The end index of the range
665
+ * @param movedItems The move operations to apply
666
+ * @param reverse If the moved items should be applied in reverse (this reverses the effects of the moves)
667
+ * @returns A list of AxisRanges in the translated space. Possibly multiple non-continuous ranges
684
668
  */
685
669
 
686
670
 
687
- static getModelRangeIndexes(start, end, movedItems) {
688
- if (start == null || end == null) {
689
- return [[start, end]];
690
- }
691
-
671
+ static applyItemMoves(start, end, movedItems) {
672
+ var reverse = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
692
673
  var result = [[start, end]];
693
674
 
694
- if (start == null) {
695
- return result;
696
- } // movedItems is built by adding a new item whenever an item in the UI is dragged/moved, transforming a model
697
- // index to the new UI index. We want to find the model index from the UI index here, so we unwind the
698
- // transformations applied - the start/end axis range passed in is the current UI range, so we need to apply
699
- // the transformations starting at the end of the chain backward to find the appropriate model indexes
700
-
701
-
702
- for (var i = movedItems.length - 1; i >= 0; i -= 1) {
675
+ for (var i = reverse ? movedItems.length - 1 : 0; reverse ? i >= 0 : i < movedItems.length; reverse ? i -= 1 : i += 1) {
703
676
  var {
704
- from,
705
- to
677
+ from: fromItem,
678
+ to: toItem
706
679
  } = movedItems[i];
680
+ var from = reverse ? toItem : fromItem;
681
+ var to = reverse ? fromItem : toItem;
707
682
  var nextResult = [];
708
683
 
709
684
  for (var j = 0; j < result.length; j += 1) {
710
- var [currentStart, currentEnd] = result[j];
685
+ var _result$j$, _result$j$2;
686
+
687
+ var currentStart = (_result$j$ = result[j][0]) !== null && _result$j$ !== void 0 ? _result$j$ : Number.NEGATIVE_INFINITY;
688
+ var currentEnd = (_result$j$2 = result[j][1]) !== null && _result$j$2 !== void 0 ? _result$j$2 : Number.POSITIVE_INFINITY;
711
689
  var startLength = nextResult.length;
712
690
 
713
- if (from <= currentStart) {
691
+ if (from < currentStart) {
714
692
  // From before
715
- if (to > currentEnd) {
693
+ if (to >= currentEnd) {
716
694
  // To after
717
- nextResult.push([currentStart + 1, currentEnd + 1]);
695
+ nextResult.push([currentStart - 1, currentEnd - 1]);
718
696
  } else if (to >= currentStart) {
719
697
  // To within
720
- nextResult.push([from, from]);
721
- nextResult.push([currentStart + 1, currentEnd]);
698
+ nextResult.push([currentStart - 1, to - 1]);
699
+ nextResult.push([to + 1, currentEnd]);
722
700
  }
723
701
  } else if (from > currentEnd) {
724
702
  // From after
725
- if (to < currentStart) {
703
+ if (to <= currentStart) {
726
704
  // To before
727
- nextResult.push([currentStart - 1, currentEnd - 1]);
705
+ nextResult.push([currentStart + 1, currentEnd + 1]);
728
706
  } else if (to <= currentEnd) {
729
707
  // To within
730
- nextResult.push([from, from]);
731
- nextResult.push([currentStart, currentEnd - 1]);
708
+ nextResult.push([currentStart, to - 1]);
709
+ nextResult.push([to + 1, currentEnd + 1]);
732
710
  }
733
711
  } else if (to < currentStart) {
734
712
  // From within to before
735
- nextResult.push([currentStart - 1, from - 1]);
736
- nextResult.push([from + 1, currentEnd]);
713
+ if (from > currentStart) {
714
+ nextResult.push([currentStart + 1, from]);
715
+ }
716
+
717
+ nextResult.push([to, to]);
718
+
719
+ if (from < currentEnd) {
720
+ nextResult.push([from + 1, currentEnd]);
721
+ }
737
722
  } else if (to > currentEnd) {
738
723
  // From within to after
739
- nextResult.push([currentStart, from - 1]);
740
- nextResult.push([from + 1, currentEnd + 1]);
724
+ if (from > currentStart) {
725
+ nextResult.push([currentStart, from - 1]);
726
+ }
727
+
728
+ nextResult.push([to, to]);
729
+
730
+ if (from < currentEnd) {
731
+ nextResult.push([from, currentEnd - 1]);
732
+ }
741
733
  } else if (from > to) {
742
734
  // From within after to within before
743
735
  if (to > currentStart) {
744
736
  nextResult.push([currentStart, to - 1]);
745
737
  }
746
738
 
747
- nextResult.push([from, from]);
748
- nextResult.push([to, from - 1]);
739
+ nextResult.push([to + 1, from]);
740
+ nextResult.push([to, to]);
749
741
 
750
742
  if (from < currentEnd) {
751
743
  nextResult.push([from + 1, currentEnd]);
@@ -756,10 +748,10 @@ export class GridUtils {
756
748
  nextResult.push([currentStart, from - 1]);
757
749
  }
758
750
 
759
- nextResult.push([from + 1, to]);
760
- nextResult.push([from, from]);
751
+ nextResult.push([to, to]);
752
+ nextResult.push([from, to - 1]);
761
753
 
762
- if (from < currentEnd) {
754
+ if (to < currentEnd) {
763
755
  nextResult.push([to + 1, currentEnd]);
764
756
  }
765
757
  }
@@ -768,29 +760,30 @@ export class GridUtils {
768
760
  // No modifications were made, add the original range indexes
769
761
  nextResult.push([currentStart, currentEnd]);
770
762
  }
771
- }
763
+ } // Return infinity values back to null
764
+
772
765
 
773
- result = nextResult;
766
+ result = nextResult.map(_ref => {
767
+ var [s, e] = _ref;
768
+ return [Number.isFinite(s) ? s : null, Number.isFinite(e) ? e : null];
769
+ });
774
770
  }
775
771
 
776
772
  return result;
777
773
  }
778
774
  /**
779
- * Translate the provided UI range into model range, using the `movedColumns` and `movedRows` to apply the necessary transforms.
780
- * `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
781
- *
782
- * @param uiRange The currently selected UI ranges
783
- * @param movedColumns The moved column pairs
784
- * @param movedRows The moved row pairs
785
- * @returns The model ranges after translation.
775
+ * Applies the items moves to the givengrid range
776
+ * @param range The grid range to translate
777
+ * @param movedColumns The moved columns
778
+ * @param movedRows The moved rows
779
+ * @param reverse If the moved items should be reversed (i.e. visible to model range)
780
+ * @returns A list of grid ranges in the translated space. Possibly multiple non-continuous ranges
786
781
  */
787
782
 
788
783
 
789
- static getModelRange(uiRange) {
790
- var movedColumns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
791
- var movedRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
792
- var columnRanges = GridUtils.getModelRangeIndexes(uiRange.startColumn, uiRange.endColumn, movedColumns);
793
- var rowRanges = GridUtils.getModelRangeIndexes(uiRange.startRow, uiRange.endRow, movedRows);
784
+ static translateRange(range, movedColumns, movedRows, reverse) {
785
+ var columnRanges = GridUtils.applyItemMoves(range.startColumn, range.endColumn, movedColumns, reverse);
786
+ var rowRanges = GridUtils.applyItemMoves(range.startRow, range.endRow, movedRows, reverse);
794
787
  var ranges = [];
795
788
 
796
789
  for (var i = 0; i < columnRanges.length; i += 1) {
@@ -804,6 +797,36 @@ export class GridUtils {
804
797
 
805
798
  return ranges;
806
799
  }
800
+ /**
801
+ * Translate the provided UI start/end indexes to the model start/end indexes by applying the `movedItems` transformations.
802
+ * Since moved items can split apart a range, multiple pairs of indexes are returned
803
+ *
804
+ * @param start Start item in one dimension
805
+ * @param end End item in one dimension
806
+ * @param movedItems Moved item pairs in this dimension
807
+ * @returns Array of start/end pairs of the indexes after transformations applied.
808
+ */
809
+
810
+
811
+ static getModelRangeIndexes(start, end, movedItems) {
812
+ return GridUtils.applyItemMoves(start, end, movedItems, true);
813
+ }
814
+ /**
815
+ * Translate the provided UI range into model range, using the `movedColumns` and `movedRows` to apply the necessary transforms.
816
+ * `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
817
+ *
818
+ * @param uiRange The currently selected UI ranges
819
+ * @param movedColumns The moved column pairs
820
+ * @param movedRows The moved row pairs
821
+ * @returns The model ranges after translation.
822
+ */
823
+
824
+
825
+ static getModelRange(uiRange) {
826
+ var movedColumns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
827
+ var movedRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
828
+ return GridUtils.translateRange(uiRange, movedColumns, movedRows, true);
829
+ }
807
830
  /**
808
831
  * Translate the provided UI range into model ranges, using the `movedColumns` and `movedRows` to apply the necessary transforms.
809
832
  * `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
@@ -826,6 +849,58 @@ export class GridUtils {
826
849
 
827
850
  return modelRanges;
828
851
  }
852
+ /**
853
+ * Translate the provided UI start/end indexes to the model start/end indexes by applying the `movedItems` transformations.
854
+ * Since moved items can split apart a range, multiple pairs of indexes are returned
855
+ *
856
+ * @param start Start item in one dimension
857
+ * @param end End item in one dimension
858
+ * @param movedItems Moved item pairs in this dimension
859
+ * @returns Array of start/end pairs of the indexes after transformations applied.
860
+ */
861
+
862
+
863
+ static getVisibleRangeIndexes(start, end, movedItems) {
864
+ return GridUtils.applyItemMoves(start, end, movedItems, false);
865
+ }
866
+ /**
867
+ * Translate the provided UI range into model range, using the `movedColumns` and `movedRows` to apply the necessary transforms.
868
+ * `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
869
+ *
870
+ * @param uiRange The currently selected UI ranges
871
+ * @param movedColumns The moved column pairs
872
+ * @param movedRows The moved row pairs
873
+ * @returns The model ranges after translation.
874
+ */
875
+
876
+
877
+ static getVisibleRange(modelRange) {
878
+ var movedColumns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
879
+ var movedRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
880
+ return this.translateRange(modelRange, movedColumns, movedRows, false);
881
+ }
882
+ /**
883
+ * Translate the provided model ranges into visible ranges, using the `movedColumns` and `movedRows` to apply the necessary transforms.
884
+ * `movedColumns` and `movedRows` are array of operations done to the UI indexes to re-order items
885
+ *
886
+ * @param modelRanges The model ranges
887
+ * @param movedColumns The moved column pairs
888
+ * @param movedRows The moved row pairs
889
+ * @returns The model ranges after translation.
890
+ */
891
+
892
+
893
+ static getVisibleRanges(modelRanges) {
894
+ var movedColumns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
895
+ var movedRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
896
+ var visibleRanges = [];
897
+
898
+ for (var i = 0; i < modelRanges.length; i += 1) {
899
+ visibleRanges.push(...GridUtils.getVisibleRange(modelRanges[i], movedColumns, movedRows));
900
+ }
901
+
902
+ return visibleRanges;
903
+ }
829
904
  /**
830
905
  * Retrieve the visible index given the currently moved items
831
906
  * @param modelIndex The model index to get the visible index for
@@ -836,22 +911,7 @@ export class GridUtils {
836
911
 
837
912
  static getVisibleIndex(modelIndex) {
838
913
  var movedItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
839
- var visibleIndex = modelIndex;
840
-
841
- for (var i = 0; i < movedItems.length; i += 1) {
842
- var movedItem = movedItems[i];
843
-
844
- if (visibleIndex === movedItem.from) {
845
- ({
846
- to: visibleIndex
847
- } = movedItem);
848
- } else if (movedItem.from < visibleIndex && visibleIndex <= movedItem.to) {
849
- visibleIndex -= 1;
850
- } else if (movedItem.to <= visibleIndex && visibleIndex < movedItem.from) {
851
- visibleIndex += 1;
852
- }
853
- }
854
-
914
+ var visibleIndex = GridUtils.applyItemMoves(modelIndex, modelIndex, movedItems)[0][0];
855
915
  return visibleIndex;
856
916
  }
857
917
  /**