@refinitiv-ui/efx-grid 6.0.38 → 6.0.39

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.
@@ -805,10 +805,11 @@ ColumnDefinition.prototype.getConfigObject = function(colOptions) {
805
805
  obj["minWidth"] = value;
806
806
  }
807
807
 
808
- value = core.isColumnVisible(colIndex);
809
808
  // If "hidden" property already available from core/extensions, don't override this property
810
- if(!value && obj["hidden"] == null) {
811
- obj["hidden"] = true;
809
+ if(obj["hidden"] == null) {
810
+ if(!core.getColumnVisibility(colIndex, 0)) {
811
+ obj["hidden"] = true;
812
+ }
812
813
  }
813
814
 
814
815
  value = core.getColumnAlignment(colIndex);
@@ -89,6 +89,10 @@ declare class ColumnGroupingPlugin extends GridPlugin {
89
89
 
90
90
  public moveColumnById(srcCol: number|string|null, destCol?: (number|string)|null): boolean;
91
91
 
92
+ public pinGroup(groupId: string, side?: string|null): void;
93
+
94
+ public unpinGroup(groupId: string, dest?: (number|string)|null): void;
95
+
92
96
  }
93
97
 
94
98
  export default ColumnGroupingPlugin;
@@ -36,6 +36,7 @@ var ColumnGroupingPlugin = function ColumnGroupingPlugin(options) {
36
36
  t._requestApplyAddChildGroup = t._requestApplyAddChildGroup.bind(this);
37
37
  t._onPostSectionRender = t._onPostSectionRender.bind(t);
38
38
  t._onBeforeColumnBoundUpdate = t._onBeforeColumnBoundUpdate.bind(t);
39
+ t._onPinningChanged = t._onPinningChanged.bind(this);
39
40
  t._groupDefs = new GroupDefinitions();
40
41
  if (options) {
41
42
  t.config({
@@ -83,6 +84,10 @@ ColumnGroupingPlugin.prototype._addingEvents = null;
83
84
  * @private
84
85
  */
85
86
  ColumnGroupingPlugin.prototype._legacyColumnGroups = null;
87
+ /** @type {boolean}
88
+ * @private
89
+ */
90
+ ColumnGroupingPlugin.prototype._inPinning = false;
86
91
 
87
92
  /** @private
88
93
  * @param {number} a
@@ -237,6 +242,7 @@ ColumnGroupingPlugin.prototype.initialize = function (host, options) {
237
242
  host.listen("columnVisibilityChanged", this._onColumnChanged);
238
243
  host.listen("postSectionRender", this._onPostSectionRender);
239
244
  host.listen("beforeColumnBoundUpdate", this._onBeforeColumnBoundUpdate);
245
+ host.listen("pinningChanged", this._onPinningChanged);
240
246
  }
241
247
  this.config(options);
242
248
  this._legacyColumnGroups = null;
@@ -290,6 +296,7 @@ ColumnGroupingPlugin.prototype.unload = function (host) {
290
296
  host.unlisten("columnRemoved", this._onColumnRemoved);
291
297
  host.unlisten("postSectionRender", this._onPostSectionRender);
292
298
  host.unlisten("beforeColumnBoundUpdate", this._onBeforeColumnBoundUpdate);
299
+ host.unlisten("pinningChanged", this._onPinningChanged);
293
300
  if (!this._hosts.length) {
294
301
  if (this._rerenderTimerId) {
295
302
  clearTimeout(this._rerenderTimerId);
@@ -408,7 +415,50 @@ ColumnGroupingPlugin.prototype._migrateLegacyStructure = function (groupDefs, co
408
415
  }
409
416
  return groupDefs.filter(ColumnGroupingPlugin._hasGroupId);
410
417
  };
411
-
418
+ /** @private
419
+ * @param {number} frozenColIndex
420
+ * @param {number=} numRightColumn
421
+ */
422
+ ColumnGroupingPlugin.prototype._freezeColumn = function (frozenColIndex, numRightColumn) {
423
+ this._inPinning = true;
424
+ var hosts = this._hosts;
425
+ for (var i = 0; i < hosts.length; i++) {
426
+ hosts[i].freezeColumn(frozenColIndex, numRightColumn);
427
+ }
428
+ this._inPinning = false;
429
+ };
430
+ /** @private
431
+ */
432
+ ColumnGroupingPlugin.prototype._applyPinning = function () {
433
+ var colCount = this.getColumnCount();
434
+ var columnIds = this.getColumnIds();
435
+ var leftPinnedIndex = this._hosts[0].getFrozenColumnCount() - 1;
436
+ var rightPinnedIndex = this._hosts[0].getFirstPinnedRightIndex();
437
+ var i, groupId, groupDef;
438
+ var dirty = false;
439
+ for (i = colCount; i > leftPinnedIndex; i--) {
440
+ groupId = this._groupDefs.getParentId(columnIds[i]);
441
+ groupDef = this._visibleGroupMap[groupId];
442
+ if (groupDef && groupDef.leftPinned) {
443
+ leftPinnedIndex = i;
444
+ dirty = true;
445
+ break;
446
+ }
447
+ }
448
+ for (i = leftPinnedIndex; i < rightPinnedIndex; i++) {
449
+ groupId = this._groupDefs.getParentId(columnIds[i]);
450
+ groupDef = this._visibleGroupMap[groupId];
451
+ if (groupDef && groupDef.rightPinned) {
452
+ rightPinnedIndex = i;
453
+ dirty = true;
454
+ break;
455
+ }
456
+ }
457
+ if (dirty) {
458
+ var rightPinnedCount = colCount - rightPinnedIndex;
459
+ this._freezeColumn(leftPinnedIndex, rightPinnedCount);
460
+ }
461
+ };
412
462
  /** Consolidate and process configuration. Force rerendering on column adding, removing, moving, initializaing, and run-time API execution.
413
463
  * @private
414
464
  */
@@ -419,6 +469,9 @@ ColumnGroupingPlugin.prototype._applyGrouping = function () {
419
469
  }
420
470
  this._restructuring = true;
421
471
  this._evaluateGroupStructure();
472
+
473
+ // Apply column pinning
474
+ this._applyPinning();
422
475
  var i, c, r, cell, section, colCount;
423
476
  var rowCount = this._maxDepth + 1;
424
477
  var hostCount = this._hosts.length;
@@ -462,6 +515,7 @@ ColumnGroupingPlugin.prototype._evaluateGroupStructure = function () {
462
515
  // Clone group definitions for rendering
463
516
  var visibleGroupMap = this._visibleGroupMap = this._groupDefs.cloneGroupMap();
464
517
  this._verifySingleChild(visibleGroupMap);
518
+ this._verifyColumnPinning(visibleGroupMap);
465
519
 
466
520
  // Update depth (onRow) and parentId
467
521
  var maxDepth = this._maxDepth = -1;
@@ -483,6 +537,65 @@ ColumnGroupingPlugin.prototype._evaluateGroupStructure = function () {
483
537
  this._maxDepth = maxDepth + 1; // Column header depth = maximum group depth + 1
484
538
  };
485
539
 
540
+ /** @private Add pinning state to group definition for further verification.
541
+ * @param {Object} groupDef
542
+ * @param {string} side
543
+ */
544
+ ColumnGroupingPlugin.prototype._setGroupPinning = function (groupDef, side) {
545
+ if (!groupDef || groupDef.leftPinned || groupDef.rightPinned) {
546
+ return;
547
+ }
548
+ if (side === "left") {
549
+ groupDef.leftPinned = true;
550
+ } else {
551
+ groupDef.rightPinned = true;
552
+ }
553
+ var children = groupDef["children"];
554
+ for (var i = 0; i < children.length; i++) {
555
+ var child = children[i];
556
+ var group = this._visibleGroupMap[child];
557
+ if (group) {
558
+ this._setGroupPinning(group, side);
559
+ }
560
+ }
561
+ };
562
+
563
+ /** @private
564
+ * @param {Object} groupMap
565
+ */
566
+ ColumnGroupingPlugin.prototype._verifyColumnPinning = function (groupMap) {
567
+ var host = this._hosts[0];
568
+ var leftPinnedIndex = host.getFrozenColumnCount() - 1;
569
+ var rightPinnedIndex = host.getFirstPinnedRightIndex();
570
+ var colCount = this.getColumnCount();
571
+ var i, groupId, rootGroup, colId;
572
+ var groupDefs = this._groupDefs;
573
+ var visibleGroupMap = this._visibleGroupMap;
574
+ if (leftPinnedIndex >= 0) {
575
+ for (i = leftPinnedIndex; i >= 0; i--) {
576
+ colId = this.getColumnId(i);
577
+ groupId = groupDefs.getParentId(colId);
578
+ if (groupId && visibleGroupMap[groupId]) {
579
+ rootGroup = groupDefs.getRootGroup(groupId);
580
+ if (rootGroup) {
581
+ this._setGroupPinning(visibleGroupMap[rootGroup["id"]], "left");
582
+ }
583
+ }
584
+ }
585
+ }
586
+ if (rightPinnedIndex < colCount) {
587
+ for (i = rightPinnedIndex; i < colCount; i++) {
588
+ colId = this.getColumnId(i);
589
+ groupId = groupDefs.getParentId(colId);
590
+ if (groupId && visibleGroupMap[groupId]) {
591
+ rootGroup = groupDefs.getRootGroup(groupId);
592
+ if (rootGroup) {
593
+ this._setGroupPinning(visibleGroupMap[rootGroup["id"]], "right");
594
+ }
595
+ }
596
+ }
597
+ }
598
+ };
486
599
  /** @private
487
600
  * @param {Object} groupMap
488
601
  */
@@ -814,6 +927,22 @@ ColumnGroupingPlugin.prototype._onColumnRemoved = function (e) {
814
927
  /** @private
815
928
  * @param {Object} e
816
929
  */
930
+ ColumnGroupingPlugin.prototype._onPinningChanged = function (e) {
931
+ if (!this._inPinning) {
932
+ // Clear current pinning states
933
+ var groupMap = this._visibleGroupMap;
934
+ for (var groupId in groupMap) {
935
+ var groupDef = groupMap[groupId];
936
+ groupDef.leftPinned = false;
937
+ groupDef.rightPinned = false;
938
+ }
939
+ this._verifyColumnPinning();
940
+ this._applyPinning();
941
+ }
942
+ };
943
+ /** @private
944
+ * @param {Object} e
945
+ */
817
946
  ColumnGroupingPlugin.prototype._onBeforeColumnBoundUpdate = function (e) {
818
947
  var selectedColumns = e.selectedColumns; // Hidden columns are included
819
948
 
@@ -1362,7 +1491,12 @@ ColumnGroupingPlugin.prototype.removeGroupChild = function (parentId, childRef)
1362
1491
  if (!colId) {
1363
1492
  return false;
1364
1493
  }
1365
- var leafIndices = this.getChildColumnIndices(parentId);
1494
+ var rootId = parentId;
1495
+ var group = this._visibleGroupMap[parentId];
1496
+ if (group.onRow !== 0) {
1497
+ rootId = this._groupDefs.getParentId(parentId, 0);
1498
+ }
1499
+ var leafIndices = this.getChildColumnIndices(rootId);
1366
1500
  if (this._groupDefs.removeGroupChild(parentId, colId)) {
1367
1501
  if (leafIndices && leafIndices.length > 1) {
1368
1502
  if (this.moveColumnById(colId, leafIndices[leafIndices.length - 1] + 1)) {
@@ -1510,5 +1644,90 @@ ColumnGroupingPlugin.prototype.moveColumnById = function (srcCol, destCol) {
1510
1644
  this._autoGrouping = true;
1511
1645
  return dirty;
1512
1646
  };
1647
+ /** @public
1648
+ * @param {string} groupId
1649
+ * @param {string=} side Available values are: left|right. If no value is supplied, all columns will be pinned to the left.
1650
+ */
1651
+ ColumnGroupingPlugin.prototype.pinGroup = function (groupId, side) {
1652
+ if (!groupId) {
1653
+ return;
1654
+ }
1655
+ var groupDef = this._visibleGroupMap[groupId];
1656
+ if (!groupDef) {
1657
+ return;
1658
+ }
1659
+ var host = this._hosts[0];
1660
+ var leftPinnedIndex = host.getFrozenColumnCount() - 1;
1661
+ var rightPinnedCount = host.getPinnedRightColumnCount();
1662
+ var colCount = this.getColumnCount();
1663
+ var colList = this.getChildColumnIndices(groupId);
1664
+ var len = colList.length;
1665
+ var dest;
1666
+ if (side === "right") {
1667
+ if (groupDef.rightPinned) {
1668
+ return;
1669
+ }
1670
+ if (groupDef.leftPinned) {
1671
+ this.unpinGroup(groupId);
1672
+ leftPinnedIndex = host.getFrozenColumnCount() - 1;
1673
+ }
1674
+ groupDef.rightPinned = true;
1675
+ dest = colCount - rightPinnedCount;
1676
+ rightPinnedCount = rightPinnedCount + len;
1677
+ } else {
1678
+ if (groupDef.leftPinned) {
1679
+ return;
1680
+ }
1681
+ if (groupDef.rightPinned) {
1682
+ this.unpinGroup(groupId);
1683
+ rightPinnedCount = host.getPinnedRightColumnCount();
1684
+ }
1685
+ groupDef.leftPinned = true;
1686
+ dest = leftPinnedIndex === -1 ? 0 : leftPinnedIndex + 1;
1687
+ leftPinnedIndex = leftPinnedIndex + len;
1688
+ }
1689
+ this.moveGroup(groupId, dest);
1690
+ this._freezeColumn(leftPinnedIndex, rightPinnedCount);
1691
+ };
1692
+ /** @public
1693
+ * @param {string} groupId
1694
+ * @param {(number|string)=} dest The unpinned group will be placed before the destination position after the operation
1695
+ */
1696
+ ColumnGroupingPlugin.prototype.unpinGroup = function (groupId, dest) {
1697
+ if (!groupId) {
1698
+ return;
1699
+ }
1700
+ var groupDef = this._visibleGroupMap[groupId];
1701
+ if (!groupDef) {
1702
+ return;
1703
+ }
1704
+ if (!groupDef.leftPinned && !groupDef.rightPinned) {
1705
+ return;
1706
+ }
1707
+ var host = this._hosts[0];
1708
+ var leftPinnedCount = host.getFrozenColumnCount();
1709
+ var rightPinnedCount = host.getPinnedRightColumnCount();
1710
+ var colCount = this.getColumnCount();
1711
+ var firstRightPinnedIndex = colCount - rightPinnedCount;
1712
+ var colList = this.getChildColumnIndices(groupId);
1713
+ var len = colList.length;
1714
+ var destId = null;
1715
+ if (dest != null) {
1716
+ var destIdx = this.getColumnIndex(dest);
1717
+ destId = this.getColumnId(destIdx);
1718
+ }
1719
+ if (groupDef.leftPinned) {
1720
+ groupDef.leftPinned = false;
1721
+ this.moveGroup(groupId, leftPinnedCount);
1722
+ this._freezeColumn(leftPinnedCount - (1 + len));
1723
+ } else if (groupDef.rightPinned) {
1724
+ groupDef.rightPinned = false;
1725
+ this.moveGroup(groupId, firstRightPinnedIndex);
1726
+ this._freezeColumn(leftPinnedCount - 1, rightPinnedCount - len);
1727
+ }
1728
+ if (destId != null) {
1729
+ this.moveGroup(groupId, destId);
1730
+ }
1731
+ };
1513
1732
  export default ColumnGroupingPlugin;
1514
1733
  export { ColumnGroupingPlugin, ColumnGroupingPlugin as ColumnGrouping, ColumnGroupingPlugin as ColumnGroupingExtension };
@@ -84,7 +84,7 @@ declare class ColumnStackPlugin extends GridPlugin {
84
84
 
85
85
  public isColumnActive(colIndex: number): boolean;
86
86
 
87
- public getStackId(colIndex: number): string;
87
+ public getStackId(colRef: number|string|null): string;
88
88
 
89
89
  public stackColumns(colRefs?: (number|string)[]|null, stackId?: string|null, options?: ColumnStackPlugin.StackConfiguration|null): boolean;
90
90
 
@@ -96,6 +96,8 @@ declare class ColumnStackPlugin extends GridPlugin {
96
96
 
97
97
  public removeAllStacks(enableUpdateUI?: boolean|null): boolean;
98
98
 
99
+ public setActiveColumn(activeColumn: number|string|null): boolean;
100
+
99
101
  public swapColumn(colRef: number|Event|null, swappingIndex: number): boolean;
100
102
 
101
103
  public getStackMemberIndices(stackId: string): (number)[];
@@ -140,6 +142,10 @@ declare class ColumnStackPlugin extends GridPlugin {
140
142
 
141
143
  public moveStack(stackId: string, destCol?: (number|string)|null): boolean;
142
144
 
145
+ public pinStack(stackId: string, side?: string|null): void;
146
+
147
+ public unpinStack(stackId: string, dest?: (number|string)|null): void;
148
+
143
149
  }
144
150
 
145
151
  export default ColumnStackPlugin;