@refinitiv-ui/efx-grid 6.0.24 → 6.0.26

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.
Files changed (43) hide show
  1. package/lib/core/dist/core.css +1 -1
  2. package/lib/core/dist/core.js +1331 -145
  3. package/lib/core/dist/core.min.js +1 -1
  4. package/lib/core/es6/grid/Core.d.ts +11 -0
  5. package/lib/core/es6/grid/Core.js +81 -10
  6. package/lib/core/es6/grid/util/ElementFrameWork.js +1 -1
  7. package/lib/core/es6/tr-grid-theme.js +1 -1
  8. package/lib/grid/index.js +1 -1
  9. package/lib/rt-grid/dist/rt-grid.js +768 -53
  10. package/lib/rt-grid/dist/rt-grid.min.js +1 -1
  11. package/lib/rt-grid/es6/ColumnDefinition.js +1 -1
  12. package/lib/rt-grid/es6/FieldDefinition.d.ts +2 -0
  13. package/lib/rt-grid/es6/FieldDefinition.js +13 -2
  14. package/lib/rt-grid/es6/Grid.d.ts +3 -1
  15. package/lib/rt-grid/es6/Grid.js +83 -39
  16. package/lib/rt-grid/es6/RowDefinition.d.ts +14 -1
  17. package/lib/rt-grid/es6/RowDefinition.js +54 -2
  18. package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +3 -2
  19. package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +314 -566
  20. package/lib/tr-grid-column-selection/es6/ColumnSelection.d.ts +13 -11
  21. package/lib/tr-grid-column-selection/es6/ColumnSelection.js +233 -81
  22. package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +3 -3
  23. package/lib/tr-grid-column-stack/es6/ColumnStack.js +50 -56
  24. package/lib/tr-grid-in-cell-editing/es6/InCellEditing.js +21 -9
  25. package/lib/tr-grid-range-bar/es6/RangeBar.d.ts +18 -9
  26. package/lib/tr-grid-range-bar/es6/RangeBar.js +318 -139
  27. package/lib/tr-grid-util/es6/GridPlugin.d.ts +1 -1
  28. package/lib/tr-grid-util/es6/GridPlugin.js +13 -15
  29. package/lib/tr-grid-util/es6/GroupDefinitions.d.ts +58 -0
  30. package/lib/tr-grid-util/es6/GroupDefinitions.js +538 -0
  31. package/lib/tr-grid-util/es6/Popup.js +1 -1
  32. package/lib/tr-grid-util/es6/index.d.ts +2 -0
  33. package/lib/tr-grid-util/es6/index.js +3 -0
  34. package/lib/types/es6/ColumnGrouping.d.ts +3 -2
  35. package/lib/types/es6/ColumnSelection.d.ts +13 -11
  36. package/lib/types/es6/ColumnStack.d.ts +3 -3
  37. package/lib/types/es6/Core/grid/Core.d.ts +11 -0
  38. package/lib/types/es6/RealtimeGrid/FieldDefinition.d.ts +2 -0
  39. package/lib/types/es6/RealtimeGrid/Grid.d.ts +3 -1
  40. package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +14 -1
  41. package/lib/types/es6/index.d.ts +1 -1
  42. package/lib/versions.json +6 -6
  43. package/package.json +1 -1
@@ -7,22 +7,22 @@ import { injectCss, prettifyCss } from "../../tr-grid-util/es6/Util.js";
7
7
  declare namespace ColumnSelectionPlugin {
8
8
 
9
9
  type Options = {
10
- singleSelection?: boolean,
11
- clickToggle?: boolean,
12
- selectionChanged?: ((...params: any[]) => any),
13
- menuClicked?: ((...params: any[]) => any),
14
- menuPosition?: string
10
+ singleSelection?: boolean|null,
11
+ clickToggle?: boolean|null,
12
+ selectionChanged?: ((...params: any[]) => any)|null,
13
+ menuClicked?: ((...params: any[]) => any)|null,
14
+ menuPosition?: string|null
15
15
  };
16
16
 
17
17
  type ColumnOptions = {
18
- unselectable?: boolean
18
+ unselectable?: boolean|null
19
19
  };
20
20
 
21
21
  }
22
22
 
23
23
  declare class ColumnSelectionPlugin extends GridPlugin {
24
24
 
25
- constructor(options?: ColumnSelectionPlugin.Options);
25
+ constructor(options?: ColumnSelectionPlugin.Options|null);
26
26
 
27
27
  public getName(): string;
28
28
 
@@ -34,7 +34,7 @@ declare class ColumnSelectionPlugin extends GridPlugin {
34
34
 
35
35
  public getConfigObject(gridOptions?: any): any;
36
36
 
37
- public disable(opt_bool?: boolean): void;
37
+ public disable(opt_bool?: boolean|null): void;
38
38
 
39
39
  public isEnabled(): boolean;
40
40
 
@@ -46,9 +46,11 @@ declare class ColumnSelectionPlugin extends GridPlugin {
46
46
 
47
47
  public getLastSelectedColumn(): number;
48
48
 
49
- public setSelectedColumn(colIndex: number, opt_select?: boolean, opt_grid?: any): boolean;
49
+ public setSelectedColumn(colIndex: number, opt_select?: boolean|null, opt_grid?: any): boolean;
50
50
 
51
- public selectSingleColumn(opt_colIndex?: (number|null), opt_grid?: any): void;
51
+ public selectSingleColumn(opt_colIndex?: (number|null)|null, opt_grid?: any): void;
52
+
53
+ public selectSingleGroup(groupId: string, opt_grid?: any): void;
52
54
 
53
55
  public selectRange(anchorIndex: number, len: number, opt_grid?: any): void;
54
56
 
@@ -58,7 +60,7 @@ declare class ColumnSelectionPlugin extends GridPlugin {
58
60
 
59
61
  public clearSelectedColumns(): void;
60
62
 
61
- public clearSelection(cols?: (number|(number)[])): void;
63
+ public clearSelection(cols?: (number|(number)[])|null): void;
62
64
 
63
65
  public selectAll(): void;
64
66
 
@@ -115,6 +115,12 @@ ColumnSelectionPlugin.prototype._menuButton = null;
115
115
  */
116
116
 
117
117
  ColumnSelectionPlugin.prototype._menuPosition = "outside";
118
+ /** @type {Object}
119
+ * @private
120
+ */
121
+
122
+ ColumnSelectionPlugin.prototype._cgp = null; // Column grouping extension
123
+
118
124
  /** @public
119
125
  * @return {string}
120
126
  */
@@ -152,15 +158,12 @@ ColumnSelectionPlugin.prototype.initialize = function (host, options) {
152
158
  host.listen("columnPositionChanged", this._onColumnPositionChanged);
153
159
  this.config(options);
154
160
 
155
- if (this._onMenuClicked) {
156
- // use styles menu icon only when want to use icon menu
157
- if (ColumnSelectionPlugin._stylePromise) {
158
- ColumnSelectionPlugin._applyThemeColor(host);
159
- } else {
160
- ColumnSelectionPlugin._stylePromise = ElfUtil.getThemeColors();
161
+ if (ColumnSelectionPlugin._stylePromise) {
162
+ ColumnSelectionPlugin._applyThemeColor(host);
163
+ } else {
164
+ ColumnSelectionPlugin._stylePromise = ElfUtil.getThemeColors();
161
165
 
162
- ColumnSelectionPlugin._stylePromise.then(this._onThemeLoaded)["catch"](this._onThemeLoaded);
163
- }
166
+ ColumnSelectionPlugin._stylePromise.then(this._onThemeLoaded)["catch"](this._onThemeLoaded);
164
167
  }
165
168
  };
166
169
  /** @private
@@ -170,7 +173,7 @@ ColumnSelectionPlugin.prototype.initialize = function (host, options) {
170
173
  ColumnSelectionPlugin.prototype._onThemeLoaded = function () {
171
174
  if (!ColumnSelectionPlugin._styles) {
172
175
  var styles = [".column-selection-menu", ["position: absolute;", "background-color: var(--grid-column-menu-icon-bgcolor);", "color: var(--grid-column-menu-icon-color);", "z-index: 1;", "cursor: pointer;", "text-align: center;", "width: 16px;", "height: 16px;", "padding: 6px;"], ".column-selection-menu:hover", ["background-color: var(--grid-column-menu-icon-hover-bgcolor);"], ".column-selection-menu-inside", ["padding: 4px;" // if not outside icon, move to inside
173
- ]];
176
+ ], ".selected-column .cell.selected-group", ["background-color: var(--grid-selection-bgcolor);"]];
174
177
  ColumnSelectionPlugin._styles = prettifyCss(styles);
175
178
  }
176
179
 
@@ -194,6 +197,15 @@ ColumnSelectionPlugin._applyThemeColor = function (grid) {
194
197
  injectCss(ColumnSelectionPlugin._styles, grid.getParent());
195
198
  }
196
199
  };
200
+ /**
201
+ * @protected
202
+ * @ignore
203
+ */
204
+
205
+
206
+ ColumnSelectionPlugin.prototype._afterInit = function () {
207
+ this._cgp = this._getPlugin("ColumnGroupingPlugin");
208
+ };
197
209
  /** @public
198
210
  * @param {Object=} host core grid object
199
211
  */
@@ -436,48 +448,13 @@ ColumnSelectionPlugin.prototype.getLastSelectedColumn = function () {
436
448
 
437
449
 
438
450
  ColumnSelectionPlugin.prototype.setSelectedColumn = function (colIndex, opt_select, opt_grid) {
439
- if (!(colIndex >= 0)) {
440
- return false;
441
- }
442
-
443
- if (opt_grid) {
444
- if (opt_grid !== this._activeGrid) {
445
- this._activeGrid = opt_grid; // TODO: Check if the grid is one of the hosts
446
- }
447
- }
448
-
449
- if (!this._activeGrid) {
450
- this._activeGrid = this._hosts[0]; // Select the first grid
451
-
452
- if (!this._activeGrid) {
453
- return false;
454
- }
455
- }
456
-
457
- if (colIndex >= this.getColumnCount()) {
458
- return false;
459
- }
460
-
461
- var selection = opt_select ? true : false;
462
-
463
- if (selection && this._getColumnOption(colIndex, "unselectable")) {
464
- return false;
465
- }
466
-
467
- this._hasSelection = selection ? true : null;
468
- this._pendingSelectionOnAdded = -1; // New selection happens before resolving the pending selection
451
+ var dirty = this._setSelectedColumn(colIndex, opt_select, opt_grid);
469
452
 
470
- this._pendingSelectionOnRemoved = -1; // New selection happens before resolving the pending selection
471
-
472
- var len = this._hosts.length;
473
-
474
- for (var i = 0; i < len; ++i) {
475
- this._hosts[i].selectColumn(colIndex, selection);
453
+ if (dirty) {
454
+ this._updateGroupSelection();
476
455
  }
477
456
 
478
- this._updateMenuIcon();
479
-
480
- return true;
457
+ return dirty;
481
458
  };
482
459
  /** Select the specified column on an active grid, and clear all other column selections
483
460
  * @public
@@ -499,9 +476,42 @@ ColumnSelectionPlugin.prototype.selectSingleColumn = function (opt_colIndex, opt
499
476
  var activeGrid = opt_grid || this._activeGrid;
500
477
  this.clearAllSelections();
501
478
 
502
- if (this.setSelectedColumn(opt_colIndex, true, activeGrid)) {
479
+ if (this._setSelectedColumn(opt_colIndex, true, activeGrid)) {
503
480
  this._anchorCol = opt_colIndex; // Update the anchor
504
481
  }
482
+
483
+ this._updateGroupSelection();
484
+ };
485
+ /**
486
+ * Select the columns in a group on an active grid, and clear all other column selections
487
+ * This does not working with single selection mode
488
+ * @public
489
+ * @param {string} groupId
490
+ * @param {Object=} opt_grid core grid object
491
+ */
492
+
493
+
494
+ ColumnSelectionPlugin.prototype.selectSingleGroup = function (groupId, opt_grid) {
495
+ var activeGrid = opt_grid || this._activeGrid;
496
+ var cgp = this._cgp;
497
+
498
+ if (!cgp || !groupId) {
499
+ return;
500
+ }
501
+
502
+ var childIndices = cgp.getChildColumnIndices(groupId);
503
+ var dirty = false;
504
+ this.clearAllSelections();
505
+
506
+ for (var i = 0; i <= childIndices.length; i++) {
507
+ dirty |= this._setSelectedColumn(childIndices[i], true, activeGrid);
508
+ }
509
+
510
+ if (dirty) {
511
+ this._anchorCol = childIndices[0];
512
+ }
513
+
514
+ this._updateGroupSelection();
505
515
  };
506
516
  /** Select from the anchorIndex to the target by length
507
517
  * @public
@@ -724,6 +734,116 @@ ColumnSelectionPlugin.prototype.isSelectedColumn = function (colIndex) {
724
734
  ColumnSelectionPlugin.prototype.getActiveGrid = function () {
725
735
  return this._activeGrid;
726
736
  };
737
+ /** Select or deselect a column on the active grid
738
+ * @private
739
+ * @param {number} colIndex
740
+ * @param {boolean=} opt_select=false Null or undefined value will be treated as false value
741
+ * @param {Object=} opt_grid core grid object
742
+ * @return {boolean} Return true for successful selection, otherwise false
743
+ */
744
+
745
+
746
+ ColumnSelectionPlugin.prototype._setSelectedColumn = function (colIndex, opt_select, opt_grid) {
747
+ if (!(colIndex >= 0)) {
748
+ return false;
749
+ }
750
+
751
+ if (opt_grid) {
752
+ if (opt_grid !== this._activeGrid) {
753
+ this._activeGrid = opt_grid; // TODO: Check if the grid is one of the hosts
754
+ }
755
+ }
756
+
757
+ if (!this._activeGrid) {
758
+ this._activeGrid = this._hosts[0]; // Select the first grid
759
+
760
+ if (!this._activeGrid) {
761
+ return false;
762
+ }
763
+ }
764
+
765
+ if (colIndex >= this.getColumnCount()) {
766
+ return false;
767
+ }
768
+
769
+ var selection = opt_select ? true : false;
770
+
771
+ if (selection && this._getColumnOption(colIndex, "unselectable")) {
772
+ return false;
773
+ }
774
+
775
+ this._hasSelection = selection ? true : null;
776
+ this._pendingSelectionOnAdded = -1; // New selection happens before resolving the pending selection
777
+
778
+ this._pendingSelectionOnRemoved = -1; // New selection happens before resolving the pending selection
779
+
780
+ var len = this._hosts.length;
781
+
782
+ for (var i = 0; i < len; ++i) {
783
+ this._hosts[i].selectColumn(colIndex, selection);
784
+ }
785
+
786
+ this._updateMenuIcon();
787
+
788
+ return true;
789
+ };
790
+ /**
791
+ * @private
792
+ * @param {Array<number>} colIndices
793
+ * @return {boolean}
794
+ */
795
+
796
+
797
+ ColumnSelectionPlugin.prototype._isSelectedColumns = function (colIndices) {
798
+ var isAllSelected = false;
799
+ var count = colIndices.length;
800
+
801
+ if (this._activeGrid) {
802
+ for (var i = 0; i < count; i++) {
803
+ var colIndex = colIndices[i];
804
+ isAllSelected = this._activeGrid.isSelectedColumn(colIndex);
805
+
806
+ if (!isAllSelected) {
807
+ break;
808
+ }
809
+ }
810
+ }
811
+
812
+ return isAllSelected;
813
+ };
814
+ /**
815
+ * @private
816
+ * @param {Array<number>} colIndices
817
+ */
818
+
819
+
820
+ ColumnSelectionPlugin.prototype._updateGroupSelection = function () {
821
+ var cgp = this._cgp;
822
+ var grid = this._activeGrid;
823
+
824
+ if (!cgp || !grid) {
825
+ return;
826
+ }
827
+
828
+ var section = grid.getSection("title");
829
+ var groupDefs = cgp.getGroupDefinitions();
830
+ var count = groupDefs.length;
831
+
832
+ for (var i = 0; i < count; i++) {
833
+ var groupDef = groupDefs[i];
834
+ var groupId = groupDef["id"];
835
+ var childIndices = cgp.getChildColumnIndices(groupId);
836
+ var rowIndex = cgp.getGroupLevel(groupId);
837
+ var colIndex = childIndices[0];
838
+ var cell = section.getCell(colIndex, rowIndex);
839
+
840
+ if (this._isSelectedColumns(childIndices)) {
841
+ cell.addClass("selected-group");
842
+ } else {
843
+ cell.removeClass("selected-group");
844
+ }
845
+ }
846
+ };
727
847
  /** Left click on title causes selection change. <br>
728
848
  * Ctrl/Shift left click on title causes multi selection. <br>
729
849
  * Left click anywhere, not title, causes deselection.
@@ -743,7 +863,8 @@ ColumnSelectionPlugin.prototype._onClick = function (e) {
743
863
  return;
744
864
  }
745
865
 
746
- var info = host.getRelativePosition(e);
866
+ var cgp = this._cgp;
867
+ var info = cgp ? cgp.getCellInfo(e) : host.getRelativePosition(e);
747
868
 
748
869
  if (!info["hit"] || info["sectionType"] !== "title") {
749
870
  return;
@@ -763,43 +884,72 @@ ColumnSelectionPlugin.prototype._onClick = function (e) {
763
884
  }
764
885
 
765
886
  var cIndex = info["colIndex"];
766
- var singleSelection = !this._activeGrid || this._activeGrid !== host; // New grid is clicked
887
+ var isNewGridClicked = !this._activeGrid || this._activeGrid !== host;
888
+ var groupId = info["groupId"];
889
+ var childIndices, childCount;
890
+
891
+ if (groupId) {
892
+ childIndices = cgp.getChildColumnIndices(groupId);
893
+ childCount = childIndices.length;
894
+ }
767
895
 
768
- if (singleSelection || this._singleSelMode) {
896
+ if (isNewGridClicked) {
769
897
  this.clearAllSelections();
770
898
  this._activeGrid = host;
771
- this.setSelectedColumn(cIndex, true);
772
- this._anchorCol = cIndex;
773
- } else {
774
- // The same active grid case
775
- if (e.ctrlKey) {
776
- var newState = !this.isSelectedColumn(cIndex); // toggle
899
+ this._anchorCol = -1;
900
+ }
777
901
 
778
- this.setSelectedColumn(cIndex, newState);
902
+ if (e.ctrlKey || e.metaKey) {
903
+ if (!groupId && (!this._singleSelMode || this.isSelectedColumn(cIndex))) {
904
+ this.setSelectedColumn(cIndex, !this.isSelectedColumn(cIndex));
905
+ this._anchorCol = this.isSelectedColumn(cIndex) ? cIndex : this.getFirstSelectedColumn();
906
+ } else {
907
+ var newState = !this._isSelectedColumns(childIndices);
779
908
 
780
- if (newState) {
781
- this._anchorCol = cIndex;
782
- } else if (this._anchorCol === cIndex) {
783
- this._anchorCol = this.getFirstSelectedColumn();
909
+ for (var i = 0; i < childCount; i++) {
910
+ this.setSelectedColumn(childIndices[i], newState, host);
784
911
  }
912
+
913
+ this._anchorCol = newState ? childIndices[0] : this.getFirstSelectedColumn();
914
+ }
915
+ } else if (e.shiftKey && !this._singleSelMode) {
916
+ if (groupId) {
917
+ var firstGroupCol = childIndices[0];
918
+ var lastGroupCol = childIndices[childCount - 1];
919
+
920
+ if (this._anchorCol >= firstGroupCol && this._anchorCol <= lastGroupCol) {
921
+ this._anchorCol = firstGroupCol;
922
+ cIndex = lastGroupCol;
923
+ } else if (this._anchorCol > firstGroupCol) {
924
+ cIndex = firstGroupCol;
925
+ } else if (this._anchorCol < lastGroupCol) {
926
+ cIndex = lastGroupCol;
927
+ }
928
+ }
929
+
930
+ this._selectFromAnchorToTarget(cIndex);
931
+ } else if (this._clickToggleMode) {
932
+ var cols = this.getSelectedColumns();
933
+
934
+ if (cols.length === 1 && cols[0] === cIndex) {
935
+ this.setSelectedColumn(cIndex, false); // toggle
936
+
937
+ this._anchorCol = -1;
938
+ } else if (childIndices && cols.length == childCount && this._isSelectedColumns(childIndices)) {
939
+ this.clearAllSelections();
940
+ this._anchorCol = -1;
785
941
  } else {
786
- if (e.shiftKey) {
787
- this._selectFromAnchorToTarget(cIndex);
788
- } else {
789
- if (this._clickToggleMode) {
790
- var cols = this.getSelectedColumns();
791
-
792
- if (cols.length === 1 && cols[0] === cIndex) {
793
- this.setSelectedColumn(cIndex, false); // toggle
794
-
795
- this._anchorCol = -1;
796
- } else {
797
- this.selectSingleColumn(cIndex);
798
- }
799
- } else {
800
- this.selectSingleColumn(cIndex);
801
- }
942
+ groupId ? this.selectSingleGroup(groupId) : this.selectSingleColumn(cIndex);
943
+ }
944
+ } else {
945
+ if (this._singleSelMode) {
946
+ if (groupId) {
947
+ return;
802
948
  }
949
+
950
+ this.selectSingleColumn(cIndex);
951
+ } else {
952
+ groupId ? this.selectSingleGroup(groupId) : this.selectSingleColumn(cIndex);
803
953
  }
804
954
  }
805
955
 
@@ -1139,13 +1289,15 @@ ColumnSelectionPlugin.prototype._selectFromAnchorToTarget = function (targetInde
1139
1289
 
1140
1290
  if (targetIndex <= this._anchorCol) {
1141
1291
  for (i = targetIndex; i <= this._anchorCol; ++i) {
1142
- this.setSelectedColumn(i, true, grid);
1292
+ this._setSelectedColumn(i, true, grid);
1143
1293
  }
1144
1294
  } else {
1145
1295
  for (i = this._anchorCol; i <= targetIndex; ++i) {
1146
- this.setSelectedColumn(i, true, grid);
1296
+ this._setSelectedColumn(i, true, grid);
1147
1297
  }
1148
1298
  }
1299
+
1300
+ this._updateGroupSelection();
1149
1301
  };
1150
1302
  /** @private
1151
1303
  * @param {Event} e
@@ -98,11 +98,11 @@ declare class ColumnStackPlugin extends GridPlugin {
98
98
 
99
99
  public getStackMemberIds(stackId: string): (string)[];
100
100
 
101
- public getColumnIdsByIndex(columnIndex: number|(number)[]|null): (string)[];
101
+ public getColumnIdsByIndex(colIndices: number|(number)[]|null): (string)[];
102
102
 
103
- public getColumnIndicesByColumnIds(columnId: string|(string)[]|null): (string)[];
103
+ public getColumnIndicesByColumnIds(colIds: string|(string)[]|null): (string)[];
104
104
 
105
- public getColumnIdsByFields(field: string|(string)[]|null): (string)[];
105
+ public getColumnIdsByFields(fields: string|(string)[]|null): (string)[];
106
106
 
107
107
  public addColumnToStack(colRef: number|string|null, stackId: string): void;
108
108