@refinitiv-ui/efx-grid 6.0.6 → 6.0.7

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.
@@ -562,6 +562,7 @@ DataTable.prototype.removeRows = function(refs) {
562
562
  this._prevData[rid] = this._rows[rid];
563
563
  this._removedRows[rid] = 1;
564
564
  delete this._rows[rid];
565
+ // TODO: remove segments
565
566
  dirty = true;
566
567
  }
567
568
  }
@@ -658,6 +659,7 @@ DataTable.prototype.moveRow = function(fromIndex, toIndex, suppressEvent) {
658
659
 
659
660
  if(output) {
660
661
  if(this._segments) {
662
+ this._segments.calcSegmentOrder(this._rids);
661
663
  this._sort(null); // Reorder segment members
662
664
  }
663
665
  this._dispatchPositionChange(suppressEvent);
@@ -887,12 +889,19 @@ DataTable.prototype.isFrozen = function() {
887
889
  DataTable.prototype.setSegmentSeparator = function(rid, enabled) {
888
890
  var change = false;
889
891
  var memberCount = 0;
890
- if(typeof rid === "string") {
892
+ if(rid && typeof rid === "string") {
891
893
  if(enabled !== false) {
892
894
  if(!this._segments) {
893
895
  this._segments = new SegmentCollection();
894
896
  }
897
+ if(this._autoSegmentFilling) {
898
+ var parentId = this._segments.getParentRowId(rid);
899
+ if(parentId) {
900
+ this._segments.removeSegmentChild(parentId, rid);
901
+ }
902
+ }
895
903
  if(this._segments.addSegment(rid)) {
904
+ this._segments.calcSegmentOrder(this._rids);
896
905
  change = true;
897
906
  }
898
907
  } else if(this._segments) {
@@ -1194,6 +1203,7 @@ DataTable.prototype.sortSegments = function (compare) {
1194
1203
  }
1195
1204
 
1196
1205
  if(dirty) {
1206
+ this._segments.calcSegmentOrder(rids);
1197
1207
  this._sort(null);
1198
1208
  this._dispatchPositionChange();
1199
1209
  }
@@ -34,6 +34,10 @@ declare class Segment {
34
34
 
35
35
  public setValue(val: number): void;
36
36
 
37
+ public getOrder(): number;
38
+
39
+ public setOrder(val: number): void;
40
+
37
41
  }
38
42
 
39
43
  export default Segment;
@@ -27,6 +27,10 @@ Segment.prototype._collapsed = false;
27
27
  * @private
28
28
  */
29
29
  Segment.prototype._value = 0;
30
+ /** @type {number}
31
+ * @private
32
+ */
33
+ Segment.prototype._order = 0;
30
34
 
31
35
 
32
36
  /** @public
@@ -194,6 +198,18 @@ Segment.prototype.getValue = function() {
194
198
  Segment.prototype.setValue = function(val) {
195
199
  this._value = val;
196
200
  };
201
+ /** @public
202
+ * @return {number}
203
+ */
204
+ Segment.prototype.getOrder = function() {
205
+ return this._order;
206
+ };
207
+ /** @public
208
+ * @param {number} val
209
+ */
210
+ Segment.prototype.setOrder = function(val) {
211
+ this._order = val;
212
+ };
197
213
 
198
214
 
199
215
  export default Segment;
@@ -50,6 +50,8 @@ declare class SegmentCollection {
50
50
 
51
51
  public fillSegments(rids: (string)[]|null): boolean;
52
52
 
53
+ public calcSegmentOrder(rids: (string)[]|null): void;
54
+
53
55
  public getSegmentValues(rids: (string)[]): (number)[]|null;
54
56
 
55
57
  }
@@ -38,6 +38,7 @@ SegmentCollection.prototype.addSegment = function(rid) {
38
38
  if(rid && !this._segments[rid]) {
39
39
  if(this._childToSegmentId[rid]) {
40
40
  console.log("child of a segment cannot be set as a segment separator");
41
+ return false;
41
42
  }
42
43
  this._segments[rid] = new Segment(rid);
43
44
  ++this._segmentCount;
@@ -368,8 +369,27 @@ SegmentCollection.prototype.fillSegments = function(rids) {
368
369
  return change;
369
370
  };
370
371
  /** @public
372
+ * @param {Array.<string>} rids
373
+ */
374
+ SegmentCollection.prototype.calcSegmentOrder = function(rids) {
375
+ var ridCount = rids ? rids.length : 0;
376
+ var segmentSeparators = this._segments;
377
+ var segmentCount = this._segmentCount;
378
+ var order = 0;
379
+ for(var i = 0; i < ridCount; ++i) {
380
+ var rid = rids[i];
381
+ var segment = segmentSeparators[rid];
382
+ if(segment) {
383
+ segment.setOrder(++order);
384
+ if(order >= segmentCount) {
385
+ break;
386
+ }
387
+ }
388
+ }
389
+ };
390
+ /** @public
371
391
  * @param {!Array.<string>} rids Array of row ids
372
- * @return {Array.<number>} Returns Array of segment values, if there are at least two segments, otherwise returns null
392
+ * @return {Array.<number>} Returns Array of segment values, if there are at least one segment, otherwise returns null
373
393
  */
374
394
  SegmentCollection.prototype.getSegmentValues = function(rids) {
375
395
  var rowCount = rids ? rids.length : 0;
@@ -379,51 +399,33 @@ SegmentCollection.prototype.getSegmentValues = function(rids) {
379
399
  var segmentSeparators = this._segments;
380
400
  var childToSegmentId = this._childToSegmentId;
381
401
  var curSegment = null;
402
+ var prevSegment = null;
382
403
  var segmentValues = new Array(rowCount);
383
- var curSegmentCount = 0;
384
404
  var segmentVal = 0;
385
- var r = 0;
386
- var childToIndex = {};
387
- while(r < rowCount) {
405
+ var offset = 0;
406
+ for(var r = 0; r < rowCount; ++r) {
388
407
  var rid = rids[r];
389
- if(segmentSeparators[rid]) {
390
- ++curSegmentCount;
391
- curSegment = segmentSeparators[rid];
392
- segmentVal += 100;
393
- segmentValues[r] = segmentVal;
394
- curSegment.setValue(segmentVal);
395
- if(curSegmentCount >= this._segmentCount) {
396
- ++r;
397
- break;
398
- }
408
+ curSegment = segmentSeparators[rid];
409
+ if(curSegment) {
410
+ offset = 0;
399
411
  } else {
400
- if(curSegmentCount) {
401
- segmentValues[r] = segmentVal + 10;
412
+ var parentId = childToSegmentId[rid];
413
+ if(parentId) {
414
+ curSegment = segmentSeparators[parentId];
415
+ offset = 1;
402
416
  } else {
403
- segmentValues[r] = 0;
404
- }
405
- if(childToSegmentId[rid]) {
406
- childToIndex[rid] = r;
417
+ offset = prevSegment ? 10 : 0;
407
418
  }
408
419
  }
409
- ++r;
410
- }
411
- if(curSegmentCount) {
412
- while(r < rowCount) {
413
- rid = rids[r];
414
- segmentValues[r] = segmentVal + 10;
415
- if(childToSegmentId[rid]) {
416
- childToIndex[rid] = r;
417
- }
418
- ++r;
419
- }
420
- for(var childId in childToIndex) {
421
- curSegment = segmentSeparators[childToSegmentId[childId]];
422
- segmentValues[childToIndex[childId]] = curSegment.getValue() + 1;
420
+
421
+ if(curSegment && prevSegment !== curSegment) {
422
+ prevSegment = curSegment;
423
+ segmentVal = curSegment.getOrder() * 100;
423
424
  }
425
+ segmentValues[r] = segmentVal + offset;
424
426
  }
425
427
 
426
- return curSegmentCount ? segmentValues : null;
428
+ return prevSegment ? segmentValues : null;
427
429
  };
428
430
 
429
431
 
@@ -528,7 +528,7 @@ Core.prototype._rowHeightTimerId = 0;
528
528
  * @return {string}
529
529
  */
530
530
  Core.getVersion = function () {
531
- return "5.1.17";
531
+ return "5.1.20";
532
532
  };
533
533
  /** {@link ElementWrapper#dispose}
534
534
  * @override
@@ -382,6 +382,9 @@ Cell.prototype.updateIcon = function(icon) {
382
382
 
383
383
  var fi = this._frontIcon;
384
384
  if (fi) {
385
+ if(fi.containItem(icon)) { // Check same icon which duplicate with insertItem in _frontIcon
386
+ return;
387
+ }
385
388
  fi.clearItems();
386
389
  }
387
390
  this.insertFrontIcon(icon, 0);
@@ -7,6 +7,8 @@ declare class CellFloatingPanel extends ElementWrapper {
7
7
 
8
8
  public hasItem(): boolean;
9
9
 
10
+ public containItem(icon: Element|null): boolean;
11
+
10
12
  public insertItem(item: Element|null, opt_order?: number|null): void;
11
13
 
12
14
  public removeItem(elemRef?: (Element|string)|null): Element|null|null;
@@ -23,6 +23,13 @@ CellFloatingPanel.prototype._items = [];
23
23
  CellFloatingPanel.prototype.hasItem = function () {
24
24
  return !!this._items.length;
25
25
  };
26
+ /** @public
27
+ * @param {Element} icon Element of item
28
+ * @returns {boolean}
29
+ */
30
+ CellFloatingPanel.prototype.containItem = function (icon) {
31
+ return this._items.indexOf(icon) > -1;
32
+ };
26
33
  /** @public
27
34
  * @param {Element} item
28
35
  * @param {number=} opt_order The greater the order, the farther the position to the right
@@ -129,7 +129,11 @@ StretchedCells.prototype.setCellCount = function (count) {
129
129
  * @return {Cell}
130
130
  */
131
131
  StretchedCells.prototype.getCell = function (rowIndex) {
132
- return this._cells[rowIndex] || null;
132
+ var cell = this._cells[rowIndex];
133
+ if(cell && cell["getParent"]()) {
134
+ return cell;
135
+ }
136
+ return null;
133
137
  };
134
138
  /** @public
135
139
  * @ignore
@@ -176,13 +180,13 @@ StretchedCells.prototype.getColumnIndex = function (cellRef) {
176
180
  StretchedCells.prototype.getRowIndex = function (cellRef) {
177
181
  if(cellRef) {
178
182
  if(cellRef["getElement"]) {
179
- return this._cells.indexOf(cellRef);
183
+ return cellRef["getParent"]() ? this._cells.indexOf(cellRef) : -1;
180
184
  } else {
181
185
  var cells = this._cells;
182
186
  var rowCount = cells.length;
183
187
  for(var r = 0; r < rowCount; ++r) {
184
188
  var cell = cells[r];
185
- if(cell && cell["getElement"]() === cellRef) {
189
+ if(cell && cell["getParent"]() && cell["getElement"]() === cellRef) {
186
190
  return r;
187
191
  }
188
192
  }
@@ -36,6 +36,7 @@ import ColumnStats from "./data/ColumnStats.js";
36
36
  import DataCache from "./data/DataCache.js";
37
37
  import DataTable from "./data/DataTable.js";
38
38
  import DataView from "./data/DataView.js";
39
+ import SegmentCollection from "./data/SegmentCollection.js";
39
40
 
40
41
 
41
42
 
@@ -36,6 +36,7 @@ import ColumnStats from "./data/ColumnStats.js";
36
36
  import DataCache from "./data/DataCache.js";
37
37
  import DataTable from "./data/DataTable.js";
38
38
  import DataView from "./data/DataView.js";
39
+ import SegmentCollection from "./data/SegmentCollection.js";
39
40
 
40
41
  // tsd-disable
41
42
  var tr = window["tr"];
@@ -60,6 +61,7 @@ tr.ColumnStats = ColumnStats;
60
61
  tr.DataCache = DataCache;
61
62
  tr.DataTable = DataTable;
62
63
  tr.DataView = DataView;
64
+ tr.SegmentCollection = SegmentCollection;
63
65
 
64
66
  // Components
65
67
  grid.CellFloatingPanel = CellFloatingPanel;
@@ -5,7 +5,7 @@ import CoralCheckboxFormatter from "./CoralCheckboxFormatter.js";
5
5
  import CoralComboBoxFormatter from "./CoralComboBoxFormatter.js";
6
6
  import CoralIconFormatter from "./CoralIconFormatter.js";
7
7
  import CoralInputFormatter from "./CoralInputFormatter.js";
8
- import CoralRadioButtonFormatter from "./CoralRadioButtonFormatter";
8
+ import CoralRadioButtonFormatter from "./CoralRadioButtonFormatter.js";
9
9
  import CoralSelectFormatter from "./CoralSelectFormatter.js";
10
10
  import CoralToggleFormatter from "./CoralToggleFormatter.js";
11
11
  import DuplexEmeraldDateTimePickerFormatter from "./DuplexEmeraldDateTimePickerFormatter.js";
@@ -5,7 +5,7 @@ import CoralCheckboxFormatter from "./CoralCheckboxFormatter.js";
5
5
  import CoralComboBoxFormatter from "./CoralComboBoxFormatter.js";
6
6
  import CoralIconFormatter from "./CoralIconFormatter.js";
7
7
  import CoralInputFormatter from "./CoralInputFormatter.js";
8
- import CoralRadioButtonFormatter from "./CoralRadioButtonFormatter";
8
+ import CoralRadioButtonFormatter from "./CoralRadioButtonFormatter.js";
9
9
  import CoralSelectFormatter from "./CoralSelectFormatter.js";
10
10
  import CoralToggleFormatter from "./CoralToggleFormatter.js";
11
11
  import DuplexEmeraldDateTimePickerFormatter from "./DuplexEmeraldDateTimePickerFormatter.js";
package/lib/grid/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  import "./lib/efx-grid.js";
2
- window.EFX_GRID = { version: "6.0.6" };
2
+ window.EFX_GRID = { version: "6.0.7" };
@@ -628,33 +628,39 @@ CellSelectionPlugin.prototype._setScrollInterval = function (dirVectors) {
628
628
  // updates scroll position
629
629
  this._hosts[0].setScrollTop(scrollToTop);
630
630
 
631
- var vScrollView = this._hosts[0].getVScrollView();
631
+ var vScrollbar = this._hosts[0].getVScrollbar();
632
+
633
+ var rowVirtualizer = this._hosts[0].getRowVirtualizer();
632
634
 
633
635
  var isEndOfVerticalScroll = this._isEndOfVerticalScroll();
634
636
 
637
+ var vTrackHeight = vScrollbar.getHeight();
638
+ var scrollViewOffset = rowVirtualizer.getViewOffset(); // scrolling down
639
+
635
640
  if (isYPositive) {
636
- var nextBottomVal = vScrollView.lastFullRow;
637
-
638
- if (!!(this._prevRect && this._prevRect.bottom > nextBottomVal) && !isEndOfVerticalScroll) {
639
- tgtRect.top = nextBottomVal;
640
- } else {
641
- if (isEndOfVerticalScroll) {
642
- tgtRect.bottom = this._hosts[0].getRowCount();
643
- } else {
644
- tgtRect.bottom = nextBottomVal;
641
+ var nextBottomRowEndPos = rowVirtualizer.getContentStart(tgtRect.bottom + 1) - scrollViewOffset; //end position of next bottom row
642
+
643
+ if (nextBottomRowEndPos <= vTrackHeight) {
644
+ // while next row is in scroll view, extend to next bottom row
645
+ while (nextBottomRowEndPos <= vTrackHeight) {
646
+ tgtRect.bottom += 1;
647
+ nextBottomRowEndPos = rowVirtualizer.getContentStart(tgtRect.bottom + 1) - scrollViewOffset;
645
648
  }
649
+ } else if (isEndOfVerticalScroll) {
650
+ tgtRect.bottom = this._hosts[0].getRowCount();
646
651
  }
647
- } else {
648
- var nextTopVal = vScrollView.firstFullRow + 2;
649
-
650
- if (!!(this._prevRect && this._prevRect.top < nextTopVal) && !isEndOfVerticalScroll) {
651
- tgtRect.bottom = nextTopVal + 1;
652
- } else {
653
- if (isEndOfVerticalScroll) {
654
- tgtRect.top = 1;
655
- } else {
656
- tgtRect.top = nextTopVal;
652
+ } // scrolling up
653
+ else {
654
+ var nextTopRowStartPos = rowVirtualizer.getContentStart(tgtRect.top - 1) - scrollViewOffset; //start position of next top row
655
+
656
+ if (nextTopRowStartPos >= 0) {
657
+ // while next row is in scroll view, extend to next top row
658
+ while (nextTopRowStartPos >= 0) {
659
+ tgtRect.top -= 1;
660
+ nextTopRowStartPos = rowVirtualizer.getContentStart(tgtRect.top - 1) - scrollViewOffset;
657
661
  }
662
+ } else if (isEndOfVerticalScroll) {
663
+ tgtRect.top = 1;
658
664
  }
659
665
  }
660
666
  }
@@ -667,28 +673,33 @@ CellSelectionPlugin.prototype._setScrollInterval = function (dirVectors) {
667
673
 
668
674
  var hScrollbar = this._hosts[0].getHScrollbar();
669
675
 
670
- var hTrackWidth = hScrollbar.getTrackSize();
676
+ var hTrackWidth = hScrollbar.getTrackSize(); // scrolling right
671
677
 
672
678
  if (isXPositive) {
673
679
  var leftPinnedWidth = 0;
674
680
 
675
- var leftPinnedCount = this._hosts[0].getPinnedLeftColumnCount();
681
+ var leftPinnedCount = this._hosts[0].getPinnedLeftColumnCount(); // getting width of left pinned columns
682
+
676
683
 
677
684
  if (leftPinnedCount) {
678
685
  leftPinnedWidth = this._hosts[0].getContentWidth() - hScrollbar.getContentWidth();
679
686
  }
680
687
 
681
- var nextRightColEndPos = this._hosts[0].getColumnRight(tgtRect.right) - leftPinnedWidth;
688
+ var nextRightColEndPos = this._hosts[0].getColumnRight(tgtRect.right) - leftPinnedWidth; //end position of next right column
689
+ // if next column is in scroll view, extend to next right column
682
690
 
683
691
  if (nextRightColEndPos <= hTrackWidth) {
684
692
  tgtRect.right += 1;
685
693
  } else if (isEndOfHorizontalScroll) {
686
694
  tgtRect.right = this._hosts[0].getColumnCount();
687
695
  }
688
- } else {
689
- var nextLeftColEndPos = this._hosts[0].getColumnLeft(tgtRect.left - 1);
696
+ } // scrolling left
697
+ else {
698
+ var nextLeftColStartPos = this._hosts[0].getColumnLeft(tgtRect.left - 1); //start position of next left column
699
+ // if next column is in scroll view, extend to next left column
700
+
690
701
 
691
- if (nextLeftColEndPos >= 0) {
702
+ if (nextLeftColStartPos >= 0) {
692
703
  tgtRect.left -= 1;
693
704
  } else if (isEndOfHorizontalScroll) {
694
705
  tgtRect.left = 0;
@@ -7,14 +7,14 @@ import { isIE, cloneObject, prepareTSVContent } from "../../tr-grid-util/es6/Uti
7
7
  declare namespace CellSelectionPlugin {
8
8
 
9
9
  type Options = {
10
- mode?: string,
11
- multipleSelection?: boolean,
12
- autoDeselecting?: boolean,
13
- tabToSelect?: boolean,
14
- selectionChanged?: ((...params: any[]) => any),
15
- copy?: ((...params: any[]) => any),
16
- beforeMouseDown?: ((...params: any[]) => any),
17
- selectableSections?: any[]
10
+ mode?: string|null,
11
+ multipleSelection?: boolean|null,
12
+ autoDeselecting?: boolean|null,
13
+ tabToSelect?: boolean|null,
14
+ selectionChanged?: ((...params: any[]) => any)|null,
15
+ copy?: ((...params: any[]) => any)|null,
16
+ beforeMouseDown?: ((...params: any[]) => any)|null,
17
+ selectableSections?: any[]|null
18
18
  };
19
19
 
20
20
  }
@@ -41,7 +41,7 @@ declare class CellSelectionPlugin extends GridPlugin {
41
41
 
42
42
  public getLastSelectionBounds(opt_ret?: any): any;
43
43
 
44
- public setSelectableSections(types?: (string|(string)[]|null)): void;
44
+ public setSelectableSections(types?: (string|(string)[]|null)|null): void;
45
45
 
46
46
  public selectSingleCell(anchor: any): void;
47
47
 
@@ -53,9 +53,9 @@ declare class CellSelectionPlugin extends GridPlugin {
53
53
 
54
54
  public getAnchorInfo(): any;
55
55
 
56
- public getSelectedCells(): (any[])[];
56
+ public getSelectedCells(): (any[])[]|null;
57
57
 
58
- public disableSelection(opt_disable?: boolean): void;
58
+ public disableSelection(opt_disable?: boolean|null): void;
59
59
 
60
60
  public setAutoDeselectingOnBlur(bool: boolean): void;
61
61
 
@@ -34,6 +34,10 @@ declare class Segment {
34
34
 
35
35
  public setValue(val: number): void;
36
36
 
37
+ public getOrder(): number;
38
+
39
+ public setOrder(val: number): void;
40
+
37
41
  }
38
42
 
39
43
  export default Segment;
@@ -50,6 +50,8 @@ declare class SegmentCollection {
50
50
 
51
51
  public fillSegments(rids: (string)[]|null): boolean;
52
52
 
53
+ public calcSegmentOrder(rids: (string)[]|null): void;
54
+
53
55
  public getSegmentValues(rids: (string)[]): (number)[]|null;
54
56
 
55
57
  }
@@ -36,6 +36,7 @@ import ColumnStats from "./data/ColumnStats.js";
36
36
  import DataCache from "./data/DataCache.js";
37
37
  import DataTable from "./data/DataTable.js";
38
38
  import DataView from "./data/DataView.js";
39
+ import SegmentCollection from "./data/SegmentCollection.js";
39
40
 
40
41
 
41
42
 
package/lib/versions.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "@grid/statistics-row": "1.0.13",
6
6
  "@grid/zoom": "1.0.11",
7
7
  "tr-grid-auto-tooltip": "1.1.5",
8
- "tr-grid-cell-selection": "1.0.31",
8
+ "tr-grid-cell-selection": "1.0.32",
9
9
  "tr-grid-checkbox": "1.0.59",
10
10
  "tr-grid-column-fitter": "1.0.39",
11
11
  "tr-grid-column-formatting": "0.9.34",
@@ -30,7 +30,7 @@
30
30
  "tr-grid-rowcoloring": "1.0.20",
31
31
  "tr-grid-textformatting": "1.0.44",
32
32
  "tr-grid-titlewrap": "1.0.19",
33
- "@grid/formatters": "1.0.48",
33
+ "@grid/formatters": "1.0.49",
34
34
  "@grid/column-selection-dialog": "4.0.44",
35
35
  "@grid/filter-dialog": "4.0.52",
36
36
  "@grid/column-format-dialog": "4.0.42"
package/package.json CHANGED
@@ -45,5 +45,5 @@
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  },
48
- "version": "6.0.6"
48
+ "version": "6.0.7"
49
49
  }