@refinitiv-ui/efx-grid 6.0.24 → 6.0.25

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
 
@@ -426,7 +426,6 @@ ColumnStackPlugin.prototype._transformStackConfig = function(stackConfig) {
426
426
  stackConfig.colRefs = [];
427
427
  var children = stackConfig.children;
428
428
  var fields = stackConfig.fields;
429
- var activeColumn = stackConfig.activeColumn;
430
429
  var field;
431
430
  if(children){
432
431
  var childLen = stackConfig.children.length;
@@ -440,12 +439,13 @@ ColumnStackPlugin.prototype._transformStackConfig = function(stackConfig) {
440
439
  } else if(fields) {
441
440
  stackConfig.colRefs = fields;
442
441
  }
442
+ var activeColumn = stackConfig.activeColumn;
443
443
  if(activeColumn && !this._autoStacking){
444
444
  var activeColIndex = this.getColumnIndex(activeColumn);
445
445
  if(activeColIndex !== -1){
446
446
  field = this._getField(colIndex);
447
447
  if(field){
448
- stackConfig.activeColumn;
448
+ stackConfig.activeColumn = field;
449
449
  }
450
450
  }
451
451
  }
@@ -929,6 +929,7 @@ ColumnStackPlugin.prototype.stackColumns = function(colRefs, stackId, options) {
929
929
  if(colRefs.length) {
930
930
  if(typeof colRefs[0] === "string") {
931
931
  fields = colRefs.slice();
932
+ colRefs = this.getColumnIndices(colRefs);
932
933
  } else {
933
934
  colRefs.sort(function(a, b) { return a - b; }); // Only sort in the case of column index stack
934
935
  for(i = 0; i < colRefs.length; i++){
@@ -936,7 +937,6 @@ ColumnStackPlugin.prototype.stackColumns = function(colRefs, stackId, options) {
936
937
  fields.push(field);
937
938
  }
938
939
  }
939
- colRefs = this.getColumnIndices(colRefs);
940
940
  }
941
941
 
942
942
  // Save stack fields for
@@ -954,13 +954,14 @@ ColumnStackPlugin.prototype.stackColumns = function(colRefs, stackId, options) {
954
954
  return false;
955
955
  }
956
956
 
957
- var activeIndex = options.activeColumn ? this.getColumnIndices(options.activeColumn) : colRefs[0];
958
- if (activeIndex.length){
959
- activeIndex = activeIndex[0];
960
- }
961
- if(activeIndex == null || colRefs.indexOf(activeIndex) == -1){
962
- activeIndex = colRefs[0];
957
+ var activeIndex = colRefs[0];
958
+ if(options.activeColumn != null) {
959
+ var idx = this.getColumnIndex(options.activeColumn);
960
+ if(idx > -1 && colRefs.indexOf(idx) > -1) {
961
+ activeIndex = idx;
962
+ }
963
963
  }
964
+
964
965
  // Collecting data
965
966
  var stack = {};
966
967
  stack.stackId = sid;
@@ -1486,19 +1487,17 @@ ColumnStackPlugin.prototype.getStackMemberIds = function(stackId) {
1486
1487
 
1487
1488
  /** @public
1488
1489
  * @description Get column id by column index or indices
1489
- * @param {number|Array<number>} columnIndex
1490
+ * @param {number|Array<number>} colIndices
1490
1491
  * @return {!Array.<string>} Column ids
1491
1492
  */
1492
- ColumnStackPlugin.prototype.getColumnIdsByIndex = function(columnIndex) {
1493
- var colIndices = [];
1494
- var colIds = [];
1495
- if(Array.isArray(columnIndex)){
1496
- colIndices = columnIndex;
1497
- } else {
1498
- colIndices.push(colIds);
1493
+ ColumnStackPlugin.prototype.getColumnIdsByIndex = function(colIndices) {
1494
+ if(!Array.isArray(colIndices)){
1495
+ colIndices = [colIndices];
1499
1496
  }
1497
+ var colIds = [];
1498
+ var colId;
1500
1499
  for(var i = 0; i < colIndices.length; ++i) {
1501
- var colId = this.getColumnId(colIndices[i]);
1500
+ colId = this.getColumnId(colIndices[i]);
1502
1501
  colIds.push(colId);
1503
1502
  }
1504
1503
  return colIds;
@@ -1506,39 +1505,33 @@ ColumnStackPlugin.prototype.getColumnIdsByIndex = function(columnIndex) {
1506
1505
 
1507
1506
  /** @public
1508
1507
  * @description Get column indices by column ids
1509
- * @param {string|Array<string>} columnId
1508
+ * @param {string|Array<string>} colIds
1510
1509
  * @return {!Array.<string>} Column indices
1511
1510
  */
1512
- ColumnStackPlugin.prototype.getColumnIndicesByColumnIds = function(columnId) {
1513
- var colIndices = [];
1514
- var colIds = [];
1515
- if(Array.isArray(columnId)){
1516
- colIds = columnId;
1517
- } else {
1518
- colIds.push(colIds);
1511
+ ColumnStackPlugin.prototype.getColumnIndicesByColumnIds = function(colIds) {
1512
+ if(!Array.isArray(colIds)){
1513
+ colIds = [colIds];
1519
1514
  }
1515
+ var colIndices = [];
1516
+ var colIndex;
1520
1517
  for(var i = 0; i < colIds.length; ++i) {
1521
- var colId = this.getColumnIndex(colIds[i]);
1522
- colIndices.push(colId);
1518
+ colIndex = this.getColumnIndex(colIds[i]);
1519
+ colIndices.push(colIndex);
1523
1520
  }
1524
1521
  return colIndices;
1525
1522
  };
1526
1523
 
1527
1524
  /** @public
1528
1525
  * @description Get column ids by fields
1529
- * @param {string|Array<string>} field
1526
+ * @param {string|Array<string>} fields
1530
1527
  * @return {!Array.<string>} Column indices
1531
1528
  */
1532
- ColumnStackPlugin.prototype.getColumnIdsByFields = function(field) {
1533
- var colIndices = [];
1534
- var fields = [];
1535
- if(Array.isArray(field)){
1536
- fields = field;
1537
- } else {
1538
- fields.push(field);
1529
+ ColumnStackPlugin.prototype.getColumnIdsByFields = function(fields) {
1530
+ if(!Array.isArray(fields)){
1531
+ fields = [fields];
1539
1532
  }
1540
1533
 
1541
- colIndices = this.getColumnIndices(field);
1534
+ var colIndices = this.getColumnIndices(fields);
1542
1535
 
1543
1536
  return this.getColumnIdsByIndex(colIndices);
1544
1537
  };
@@ -1550,9 +1543,9 @@ ColumnStackPlugin.prototype.getColumnIdsByFields = function(field) {
1550
1543
  */
1551
1544
  ColumnStackPlugin.prototype.addColumnToStack = function(colRef, stackId) {
1552
1545
  if(typeof colRef === "string") {
1553
- var colIndices = this.getColumnIndices([colRef]);
1554
- if(colIndices.length){
1555
- colRef = colIndices[0];
1546
+ colRef = this.getColumnIndex(colRef);
1547
+ if(colRef < 0) {
1548
+ return;
1556
1549
  }
1557
1550
  }
1558
1551
 
@@ -1570,7 +1563,7 @@ ColumnStackPlugin.prototype.addColumnToStack = function(colRef, stackId) {
1570
1563
  }
1571
1564
 
1572
1565
  // Prevent from flashing in stack mode
1573
- if(colRef !== activeIndex && stack.collapsed !== false) {
1566
+ if(stack.collapsed !== false) {
1574
1567
  this._setColumnVisibility(colRef, false);
1575
1568
  }
1576
1569
 
@@ -1585,8 +1578,6 @@ ColumnStackPlugin.prototype.addColumnToStack = function(colRef, stackId) {
1585
1578
  stack.activeColumn = stack.stackRefs[0];
1586
1579
  }
1587
1580
 
1588
- var activeIndex = this._getColumnIndex(stack.activeColumn);
1589
-
1590
1581
  // Pack stacked columns together
1591
1582
  this._moveStackedColumns(stack.stackRefs);
1592
1583
 
@@ -1599,16 +1590,16 @@ ColumnStackPlugin.prototype.addColumnToStack = function(colRef, stackId) {
1599
1590
  */
1600
1591
  ColumnStackPlugin.prototype.removeColumnFromStack = function(colRef) {
1601
1592
  if(typeof colRef === "string") {
1602
- var colIndices = this.getColumnIndices([colRef]);
1603
- if(colIndices.length){
1604
- colRef = colIndices[0];
1593
+ colRef = this.getColumnIndex(colRef);
1594
+ if(colRef < 0) {
1595
+ return;
1605
1596
  }
1606
1597
  }
1607
1598
 
1608
1599
  var stackId = this.getStackId(colRef);
1609
1600
  var stack = this._stacks[stackId];
1610
- if(!stack || colRef == -1) {
1611
- return; // Invalid column index or stackId
1601
+ if(!stack) {
1602
+ return;
1612
1603
  }
1613
1604
 
1614
1605
  var stackMembers = this.getStackMemberIndices(stackId);
@@ -1669,17 +1660,18 @@ ColumnStackPlugin.prototype.reorderStackColumns = function(colRefs, stackId) {
1669
1660
  }
1670
1661
 
1671
1662
  var newStackMembers = [];
1672
- for(var i = 0; i < len; i++ ){
1673
- var colIndex = colRefs[i];
1663
+ var i, colIndex;
1664
+ for(i = 0; i < len; i++ ){
1665
+ colIndex = colRefs[i];
1674
1666
  if(stackMemberIndices.indexOf(colIndex) !== -1){
1675
1667
  newStackMembers.push(colIndex);
1676
1668
  }
1677
1669
  }
1678
1670
  if(newStackMembers.length !== stackMemberCount){
1679
1671
  for(i = 0; i < stackMemberCount; i++ ){
1680
- var columnIndex = stackMemberIndices[i];
1681
- if(newStackMembers.indexOf(columnIndex) === -1){
1682
- newStackMembers.push(columnIndex);
1672
+ colIndex = stackMemberIndices[i];
1673
+ if(newStackMembers.indexOf(colIndex) === -1){
1674
+ newStackMembers.push(colIndex);
1683
1675
  if(newStackMembers.length === stackMemberCount){
1684
1676
  break;
1685
1677
  }
@@ -350,7 +350,7 @@ InCellEditingPlugin._primaryColor = "";
350
350
  /** @type {string}
351
351
  * @private
352
352
  */
353
- InCellEditingPlugin._styles = prettifyCss([":host .cell.editing input[type=text]", ["border-style: solid;"]]);
353
+ InCellEditingPlugin._styles = prettifyCss([":host .cell.editing input[type=text]", ["border-style: solid;"], ":host .cell.editing", ["z-index: 2;"]]);
354
354
 
355
355
  /** @private
356
356
  */
@@ -1911,11 +1911,18 @@ InCellEditingPlugin.prototype._onUpdateEditorPopup = function () {
1911
1911
  if (this._compositeGrid || this._realTimeGrid) {
1912
1912
  parentElement = grid.getElement().parentElement;
1913
1913
  }
1914
+ var rowIndex, colIndex;
1914
1915
  if (this._activeInCellCache) {
1915
1916
  var activePos = this._activePos;
1916
1917
  if (activePos) {
1918
+ rowIndex = activePos["rowIndex"];
1919
+ colIndex = activePos["colIndex"];
1917
1920
  var section = grid.getSection(activePos["sectionType"]);
1918
- var cell = section.getCell(activePos["colIndex"], activePos["rowIndex"]);
1921
+ var cell = section.getCell(colIndex, rowIndex);
1922
+ var stretchedCell = section.getStretchedCell(cell, rowIndex);
1923
+ if (stretchedCell) {
1924
+ cell = stretchedCell;
1925
+ }
1919
1926
  if (cell) {
1920
1927
  var popup = this._activeInCellCache["balloonPopup"];
1921
1928
  popup.attachTo(cell.getElement());
@@ -1925,7 +1932,7 @@ InCellEditingPlugin.prototype._onUpdateEditorPopup = function () {
1925
1932
  }
1926
1933
  } else if (this._activeRowId) {
1927
1934
  var sectionContent = grid.getSection("content");
1928
- var rowIndex = this._getRowIndex(this._activeRowId);
1935
+ rowIndex = this._getRowIndex(this._activeRowId);
1929
1936
  if (sectionContent.isRowVisible(rowIndex)) {
1930
1937
  var lastIndex = (sectionContent.getColumnCount() || 0) - 1;
1931
1938
  for (var columnIndex = 0; columnIndex <= lastIndex; columnIndex++) {
@@ -1942,7 +1949,6 @@ InCellEditingPlugin.prototype._onUpdateEditorPopup = function () {
1942
1949
  }
1943
1950
  }
1944
1951
  }
1945
- grid.focus();
1946
1952
  };
1947
1953
  /** Update editor popup position and styles
1948
1954
  * @private
@@ -1953,6 +1959,7 @@ InCellEditingPlugin.prototype._onUpdateEditorPopup = function () {
1953
1959
  InCellEditingPlugin.prototype._updateEditorPopup = function (contentEditor, cell, grid) {
1954
1960
  var popup = contentEditor["balloonPopup"];
1955
1961
  var editor = contentEditor["editor"];
1962
+ var inputElement = contentEditor["inputElement"];
1956
1963
  var popupElem = popup.getElement();
1957
1964
  var pos = grid.getRelativePosition(cell);
1958
1965
  var width = cell.getWidth();
@@ -1992,12 +1999,16 @@ InCellEditingPlugin.prototype._updateEditorPopup = function (contentEditor, cell
1992
1999
  } else {
1993
2000
  var acquiredWidth = pos["x"] + newWidth;
1994
2001
  var acquiredHeight = pos["y"] - offsetTop + newHeight;
1995
-
1996
- // Left overflow
1997
- if (pos["x"] < offsetLeft) {
1998
- newWidth = newWidth - (offsetLeft - pos["x"]);
1999
- marginLeft = marginLeft + Math.abs(pos["x"] - offsetLeft);
2002
+ var isPinned = grid.isPinnedColumn(pos["colIndex"]);
2003
+ // if column is pinned, doesn't need to calculate left overflow
2004
+ if (!isPinned) {
2005
+ // Left overflow
2006
+ if (pos["x"] < offsetLeft) {
2007
+ newWidth = newWidth - (offsetLeft - pos["x"]);
2008
+ marginLeft = marginLeft + Math.abs(pos["x"] - offsetLeft);
2009
+ }
2000
2010
  }
2011
+
2001
2012
  // Right overflow
2002
2013
  if (acquiredWidth > offsetWidth) {
2003
2014
  newWidth = newWidth - (acquiredWidth - offsetWidth);
@@ -2020,6 +2031,7 @@ InCellEditingPlugin.prototype._updateEditorPopup = function (contentEditor, cell
2020
2031
  editor.style.height = newHeight ? newHeight + "px" : "";
2021
2032
  editor.style.marginLeft = marginLeft ? marginLeft + "px" : 0;
2022
2033
  editor.style.marginTop = marginTop ? marginTop + "px" : 0;
2034
+ inputElement.focus();
2023
2035
  };
2024
2036
  export default InCellEditingPlugin;
2025
2037
  export { InCellEditingPlugin, InCellEditingPlugin as InCellEditing, InCellEditingPlugin as InCellEditingExtension };
@@ -28,7 +28,7 @@ declare class GridPlugin extends EventDispatcher {
28
28
 
29
29
  public getColumnName(colRef: number|string|null): string;
30
30
 
31
- public getColumnIndex(colId: number|string|null): number;
31
+ public getColumnIndex(colRef: number|string|null): number;
32
32
 
33
33
  public getColumnIndices(colRefs: (number|string)[]|null): (number)[]|null;
34
34
 
@@ -234,29 +234,27 @@ GridPlugin.prototype.getColumnName = function (colRef) {
234
234
  return "";
235
235
  };
236
236
  /** @public
237
- * @param {number|string} colId Column index or column Id
237
+ * @param {number|string} colRef Column id, field name or column index
238
238
  * @return {number}
239
239
  */
240
- GridPlugin.prototype.getColumnIndex = function (colId) {
241
- if(typeof colId === "number") {
242
- return colId;
240
+ GridPlugin.prototype.getColumnIndex = function (colRef) {
241
+ if(typeof colRef === "number") {
242
+ return colRef;
243
243
  }
244
244
  if(this._compositeGrid) {
245
- return this._compositeGrid.getColumnIndex(colId);
246
- } else {
247
- var rtGrid = this._realTimeGrid;
248
- var colCount = rtGrid.getColumnCount();
249
- for(var i = 0; i < colCount; ++i) {
250
- var colDef = rtGrid.getColumnDefinition(i);
251
- if(colDef && colDef.getId() === colId) {
252
- return i;
253
- }
245
+ var allFields = this._compositeGrid.getColumnFields();
246
+ var colIndex = allFields.indexOf(colRef);
247
+ if(colIndex > -1) {
248
+ return colIndex;
249
+ } else {
250
+ return this._compositeGrid.getColumnIndex(colRef);
254
251
  }
252
+ } else {
253
+ return this._realTimeGrid.getColumnIndex(colRef);
255
254
  }
256
- return -1;
257
255
  };
258
256
  /** @public
259
- * @param {Array.<number|string>} colRefs column references field name or column index
257
+ * @param {Array.<number|string>} colRefs A collection of column ids, field names or column indices
260
258
  * @return {Array.<number>} column indices
261
259
  */
262
260
  GridPlugin.prototype.getColumnIndices = function (colRefs) {
@@ -0,0 +1,58 @@
1
+ import { cloneObject } from "./Util.js";
2
+
3
+ declare class GroupDefinitions {
4
+
5
+ constructor();
6
+
7
+ public static getGroupId(groupDef: any): string;
8
+
9
+ public static calcTreeDepth(groupMap: { [key: string]: any }|null, groupDef: any): number;
10
+
11
+ public static getLeafDescendants(groupMap: { [key: string]: any }|null, groupId: string): (string)[]|null;
12
+
13
+ public toString(): string;
14
+
15
+ public getGroup(groupId: string): any;
16
+
17
+ public getDefinition(groupId: string): any;
18
+
19
+ public getGroups(): (any)[];
20
+
21
+ public getGroupMap(): { [key: string]: any };
22
+
23
+ public cloneGroupMap(): { [key: string]: any };
24
+
25
+ public getGroupChildren(groupId: string): (string)[]|null;
26
+
27
+ public getLeafDescendants(groupId: string): (string)[]|null;
28
+
29
+ public getGroupLevel(groupId: string): number;
30
+
31
+ public getRootGroup(groupId: string): any;
32
+
33
+ public getParentGroup(childId: string): any;
34
+
35
+ public getParentIds(childId: string): (string)[]|null;
36
+
37
+ public getParentId(childId: string, groupLevel?: number|null): string;
38
+
39
+ public setGroups(groupDefs?: (any)[]|null): void;
40
+
41
+ public addGroup(groupDef: any): string;
42
+
43
+ public removeGroup(groupId: string): boolean;
44
+
45
+ public setGroup(groupId: string, groupDef?: (string)[]|any|null): string;
46
+
47
+ public addGroupChild(parentId: string, childId: string): boolean;
48
+
49
+ public removeGroupChild(childId: string): boolean;
50
+
51
+ public removeAllChildren(groupId: string): boolean;
52
+
53
+ public setGroupChildren(groupId: string, newChildList: (string)[]|null): boolean;
54
+
55
+ }
56
+
57
+ export default GroupDefinitions;
58
+ export { GroupDefinitions };