@refinitiv-ui/efx-grid 6.0.24 → 6.0.26

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -42,7 +42,7 @@ import Engine from "../../tr-grid-util/es6/formula/Engine.js";
42
42
  * @property {string=} headerAlignment="" Text alignment for column header. This will override `textAlign` option for column header.
43
43
  * @property {string=} titleAlignment="" Alias to `headerAlignment`
44
44
  * @property {boolean=} hidden=false
45
- * @property {string=} id Id for unique identifier
45
+ * @property {string=} id A unique identifier for the column
46
46
  * @property {boolean=} textSelect=false If enabled, user can select text in this column
47
47
  * @property {boolean=} keepModel If enabled, initial column's options will be kept
48
48
  * @property {boolean=} stationary=false If enabled, the column order cannot be changed (i.e., this column and any column to its left cannot be moved)
@@ -8,6 +8,8 @@ declare namespace FieldDefinition {
8
8
 
9
9
  function get(field: string): any;
10
10
 
11
+ function hasFieldInfo(field: string): boolean;
12
+
11
13
  function getTimeSeriesChildren(field: string): any;
12
14
 
13
15
  function addTimeSeriesChild(tsDef: string, childDef: any): void;
@@ -214,6 +214,17 @@ FieldDefinition.get = function(field) {
214
214
  }
215
215
  return null;
216
216
  };
217
+
218
+ /** @public
219
+ * @function
220
+ * @param {string} field
221
+ * @return {boolean}
222
+ */
223
+ FieldDefinition.hasFieldInfo = function(field) {
224
+ var val = FieldDefinition.get(field);
225
+ return val && val.field; // Already preventing an error caused by accessing a property on a null value
226
+ };
227
+
217
228
  /** @public
218
229
  * @function
219
230
  * @param {string} field
@@ -376,8 +387,8 @@ FieldDefinition.loadFieldInfo = function (field) {
376
387
  defer.resolve(null);
377
388
  }
378
389
  // already have field definition then return
379
- else if (FieldDefinition._defs[field]) {
380
- defer.resolve(FieldDefinition._defs[field]);
390
+ else if (FieldDefinition.hasFieldInfo(field)) {
391
+ defer.resolve(FieldDefinition.get(field));
381
392
  }
382
393
  // in debug using mock data instead
383
394
  else if (synapse.debug) {
@@ -224,6 +224,8 @@ declare class Grid extends EventDispatcher {
224
224
 
225
225
  public getColumnDefinitionsById(colIds: (string)[]|null): ColumnDefinition|null;
226
226
 
227
+ public getRowType(rowRef: number|string|null): string;
228
+
227
229
  public getRowDefinition(rowRef: number|string|null): RowDefinition|null;
228
230
 
229
231
  public getRowDefinitions(): (RowDefinition)[];
@@ -312,7 +314,7 @@ declare class Grid extends EventDispatcher {
312
314
 
313
315
  declare function borders(gridOptions?: any): any;
314
316
 
315
- declare function colCount(rowRef: number|string|null): RowDefinition|null;
317
+ declare function colCount(rowRef: number|string|null): string;
316
318
 
317
319
  export { Grid };
318
320
  export default Grid;
@@ -1264,7 +1264,9 @@ Grid.prototype._onFieldAdded = function(e) {
1264
1264
  // JET
1265
1265
  if (this._subs) {
1266
1266
  var realtimeFields = addedFields.filter(FieldDefinition.isRealTimeField);
1267
- this._subs["addFields"](realtimeFields);
1267
+ if(realtimeFields.length > 0) {
1268
+ this._subs["addFields"](realtimeFields);
1269
+ }
1268
1270
  }
1269
1271
 
1270
1272
  this._dispatch(e.type, e);
@@ -1556,19 +1558,31 @@ Grid.prototype._setScrollbarParent = function (host) {
1556
1558
  /**
1557
1559
  * @private
1558
1560
  * @param {string} field
1559
- * @param {boolean} isRealTime
1560
1561
  * @returns {boolean}
1561
1562
  */
1562
- Grid.prototype._shouldLoadFieldInfo = function (field, isRealTime) {
1563
- var fieldDef = FieldDefinition.get(field);
1564
- if (!fieldDef &&
1565
- field !== 'X_RIC_NAME' && // ignore X_RIC_NAME
1566
- (isRealTime || FieldDefinition.isAdc(field)) && // realtime field or adc field (Without static field)
1567
- (this._RTK || window["JET"]) // have rtk instance or window jet sub
1568
- ) {
1569
- return true;
1563
+ Grid.prototype._shouldLoadFieldInfo = function (field) {
1564
+
1565
+ var val = this._RTK || window["JET"]; // Fastest checking can be performed by checking the first condition.
1566
+ if(!val) {
1567
+ return false;
1570
1568
  }
1571
- return false;
1569
+
1570
+ // WARNING: If field caching is disabled, it shouldn't load field info
1571
+ if(!this._fieldCaching) {
1572
+ return false;
1573
+ }
1574
+
1575
+ val = FieldDefinition.hasFieldInfo(field);
1576
+ if(val) {
1577
+ return false;
1578
+ }
1579
+
1580
+ val = FieldDefinition.isAdc(field) || FieldDefinition.isRealTimeField(field);
1581
+ if(!val) {
1582
+ return false;
1583
+ }
1584
+
1585
+ return true;
1572
1586
  };
1573
1587
  /** Remove all existing columns and add new columns based on the given objects
1574
1588
  * @public
@@ -1670,11 +1684,10 @@ Grid.prototype._onColumnAdded = function(e) {
1670
1684
  var fields = colDef.getAllFields();
1671
1685
  var referrer = colDef.getId();
1672
1686
  var len = fields.length;
1673
- var field, dataType, prom, isRealTimeField, onLoaded;
1687
+ var field, dataType, prom, onLoaded;
1674
1688
  for(i = 0; i < len; i++) {
1675
1689
  field = fields[i];
1676
- isRealTimeField = FieldDefinition.isRealTimeField(field);
1677
- if(this._shouldLoadFieldInfo(field, isRealTimeField)) {
1690
+ if(this._shouldLoadFieldInfo(field)) {
1678
1691
  if(field === colField) {
1679
1692
  dataType = colDef.getDataType(); // Data-type from user's column options
1680
1693
  } else { // Other required fields
@@ -1843,6 +1856,15 @@ Grid.prototype.moveColumnById = function (srcCol, destCol) {
1843
1856
  if(destIndex < 0) {
1844
1857
  destIndex = colCount;
1845
1858
  }
1859
+ return this._moveColumnByIndex(srcIndex, destIndex);
1860
+ };
1861
+ /** Move column without verification for better performance
1862
+ * @private
1863
+ * @param {number} srcIndex Column index
1864
+ * @param {number} destIndex Column index of the destination
1865
+ * @return {boolean} Return true if there is any change, and false otherwise
1866
+ */
1867
+ Grid.prototype._moveColumnByIndex = function (srcIndex, destIndex) {
1846
1868
  if(srcIndex < destIndex) { // Ensure that the source column is put in front of the destination index
1847
1869
  --destIndex;
1848
1870
  }
@@ -1864,23 +1886,31 @@ Grid.prototype.reorderColumns = function (colRefs, destCol) {
1864
1886
  var srcLen = colRefs.length;
1865
1887
  if(srcLen > 1) {
1866
1888
  var colIds = this.getColumnIds();
1889
+ var colCount = colIds.length;
1867
1890
  var srcIds = [];
1868
1891
  var invalidDest = false;
1869
- var i;
1892
+ var i, srcId, srcIdx;
1870
1893
  for(i = 0; i < srcLen; ++i) {
1871
1894
  var colRef = colRefs[i];
1872
- var srcId = (typeof colRef === "number") ? colIds[colRef] : colRef;
1873
- if(srcId) {
1895
+ if(typeof colRef === "number") {
1896
+ srcIdx = colRef;
1897
+ srcId = colIds[colRef] || "";
1898
+ } else {
1899
+ srcId = colRef;
1900
+ srcIdx = colIds.indexOf(srcId);
1901
+ }
1902
+ if(srcId && srcIdx >= 0) {
1874
1903
  srcIds.push(srcId);
1875
1904
  if(destId === srcId) {
1876
1905
  invalidDest = true; // Destination must not exist in source columns
1877
1906
  }
1878
1907
  }
1879
1908
  }
1909
+
1910
+ var destIdx;
1880
1911
  srcLen = srcIds.length;
1881
1912
  if(invalidDest) { // Find the next valid destination where it is not contained in the source columns
1882
- var colCount = colIds.length;
1883
- var destIdx = this.getColumnIndex(destId);
1913
+ destIdx = this.getColumnIndex(destId);
1884
1914
  if(destIdx >= 0) {
1885
1915
  while(++destIdx < colCount) {
1886
1916
  destId = colIds[destIdx];
@@ -1895,10 +1925,16 @@ Grid.prototype.reorderColumns = function (colRefs, destCol) {
1895
1925
  }
1896
1926
 
1897
1927
  var dirty = 0;
1898
- for(i = 0; i < srcLen; ++i) {
1899
- dirty |= this.moveColumnById(srcIds[i], destId);
1928
+ for(i = srcLen; --i >= 0;) {
1929
+ srcId = srcIds[i]; // Only valid source columns are left at this point
1930
+ srcIdx = this.getColumnIndex(srcId);
1931
+ destIdx = this.getColumnIndex(destId);
1932
+ if(destIdx < 0) { // Insert to the back when id is not found
1933
+ destIdx = colCount;
1934
+ }
1935
+ dirty |= this._moveColumnByIndex(srcIdx, destIdx);
1936
+ destId = srcId;
1900
1937
  }
1901
- // TODO: Handle the case where all columns stay in the same place
1902
1938
  return dirty ? true : false;
1903
1939
  } else {
1904
1940
  return this.moveColumnById(colRefs[0], destId);
@@ -1975,11 +2011,10 @@ Grid.prototype.addDataFields = function(fieldRef, referrer) {
1975
2011
 
1976
2012
  var fields = Array.isArray(fieldRef) ? fieldRef : [fieldRef];
1977
2013
  var len = fields.length;
1978
- var i, field, dataType, prom, isRealTimeField, onLoaded;
2014
+ var i, field, dataType, prom, onLoaded;
1979
2015
  for(i = 0; i < len; i++) {
1980
2016
  field = fields[i];
1981
- isRealTimeField = FieldDefinition.isRealTimeField(field);
1982
- if(this._shouldLoadFieldInfo(field, isRealTimeField)) {
2017
+ if(this._shouldLoadFieldInfo(field)) {
1983
2018
  dataType = ColumnDefinition.getDataType(field);
1984
2019
  prom = FieldDefinition.loadFieldInfo(field)
1985
2020
  .catch(this._onFieldLoadedError);
@@ -2753,7 +2788,14 @@ Grid.prototype._getColumnDefinition = function(colRef) {
2753
2788
  }
2754
2789
  return null;
2755
2790
  };
2756
-
2791
+ /** @public
2792
+ * @param {number|string} rowRef Row index as shown in the view or row id (string)
2793
+ * @return {string}
2794
+ */
2795
+ Grid.prototype.getRowType = function(rowRef) {
2796
+ var rowDef = this.getRowDefinition(rowRef);
2797
+ return rowDef ? rowDef.getType() : "";
2798
+ };
2757
2799
  /** @public
2758
2800
  * @param {number|string} rowRef Row index as shown in the view or row id (string)
2759
2801
  * @return {RowDefinition}
@@ -2943,20 +2985,22 @@ Grid.prototype.getColumnIndex = function(colRef) {
2943
2985
  return colRef;
2944
2986
  }
2945
2987
 
2946
- var colCount = this.getColumnCount();
2947
- var i, colDef;
2948
- if(colRef instanceof ColumnDefinition) {
2949
- for(i = 0; i < colCount; ++i) {
2950
- colDef = this.getColumnDefinition(i);
2951
- if(colDef === colRef) {
2952
- return i;
2988
+ if(colRef) {
2989
+ var colCount = this.getColumnCount();
2990
+ var i, colDef;
2991
+ if(colRef instanceof ColumnDefinition) {
2992
+ for(i = 0; i < colCount; ++i) {
2993
+ colDef = this.getColumnDefinition(i);
2994
+ if(colDef === colRef) {
2995
+ return i;
2996
+ }
2953
2997
  }
2954
- }
2955
- } else if(typeof colRef === "string") {
2956
- for(i = 0; i < colCount; ++i) {
2957
- colDef = this.getColumnDefinition(i);
2958
- if(_hasFieldOrId(colDef, colRef)) {
2959
- return i; // Return the first found field
2998
+ } else if(typeof colRef === "string") {
2999
+ for(i = 0; i < colCount; ++i) {
3000
+ colDef = this.getColumnDefinition(i);
3001
+ if(_hasFieldOrId(colDef, colRef)) {
3002
+ return i; // Return the first found field
3003
+ }
2960
3004
  }
2961
3005
  }
2962
3006
  }
@@ -15,6 +15,15 @@ declare namespace RowDefinition {
15
15
  hidden?: boolean|null
16
16
  };
17
17
 
18
+ type RowTypes = {
19
+ CONTENT: string,
20
+ CHAIN: string,
21
+ CONSTITUENT: string,
22
+ GROUP_HEADER: string,
23
+ SUBGROUP_HEADER: string,
24
+ GROUP_MEMBER: string
25
+ };
26
+
18
27
  }
19
28
 
20
29
  declare class RowDefinition {
@@ -35,6 +44,8 @@ declare class RowDefinition {
35
44
 
36
45
  public getDataId(): string;
37
46
 
47
+ public getType(): string;
48
+
38
49
  public setDataSource(dataSource: DataCache|null): void;
39
50
 
40
51
  public getDataSource(): DataCache|null;
@@ -125,7 +136,9 @@ declare class RowDefinition {
125
136
 
126
137
  declare const ROW_DEF: string;
127
138
 
139
+ declare const ROW_TYPES: RowDefinition.RowTypes|null;
140
+
128
141
  declare function rowData(userInput: string): boolean;
129
142
 
130
- export {RowDefinition, ROW_DEF};
143
+ export {RowDefinition, ROW_DEF, ROW_TYPES};
131
144
  export default RowDefinition;
@@ -16,12 +16,34 @@ import { DataTable } from "../../core/es6/data/DataTable.js";
16
16
  * @property {boolean=} hidden=true When this row is hidden
17
17
  */
18
18
 
19
+ /** @typedef {Object} RowDefinition~RowTypes
20
+ * @property {string} CONTENT="CONTENT"
21
+ * @property {string} CHAIN="CHAIN"
22
+ * @property {string} CONSTITUENT="CONSTITUENT"
23
+ * @property {string} GROUP_HEADER="GROUP_HEADER"
24
+ * @property {string} SUBGROUP_HEADER="SUBGROUP_HEADER"
25
+ * @property {string} GROUP_MEMBER="GROUP_MEMBER"
26
+ */
27
+
19
28
  /** @type {string}
20
29
  * @public
21
30
  * @const
22
31
  */
23
32
  var ROW_DEF = "ROW_DEF";
24
33
 
34
+ /** @type {RowDefinition~RowTypes}
35
+ * @public
36
+ * @const
37
+ */
38
+ var ROW_TYPES = {
39
+ CONTENT: "CONTENT",
40
+ CHAIN: "CHAIN",
41
+ CONSTITUENT: "CONSTITUENT",
42
+ GROUP_HEADER: "GROUP_HEADER",
43
+ SUBGROUP_HEADER: "SUBGROUP_HEADER",
44
+ GROUP_MEMBER: "GROUP_MEMBER"
45
+ };
46
+
25
47
  /** @constructor
26
48
  * @param {RowDefinition~Options=} rowOptions
27
49
  */
@@ -394,7 +416,37 @@ RowDefinition.prototype.getConfigObject = function(rowOptions) {
394
416
  RowDefinition.prototype.getDataId = function() {
395
417
  return this._dataId;
396
418
  };
397
-
419
+ /** @public
420
+ * @return {string}
421
+ */
422
+ RowDefinition.prototype.getType = function() {
423
+ if(this._isChain) {
424
+ return ROW_TYPES.CHAIN;
425
+ } else if(this._parent) {
426
+ return ROW_TYPES.CONSTITUENT;
427
+ } else {
428
+ var dv = this._view;
429
+ if(dv) {
430
+ var rid = this.getRowId();
431
+ var separator = dv.isSegmentSeparator(rid);
432
+ var level = dv.getSegmentLevel(rid);
433
+ if(separator) {
434
+ if(level === 1) {
435
+ return ROW_TYPES.GROUP_HEADER;
436
+ } else {
437
+ return ROW_TYPES.SUBGROUP_HEADER;
438
+ }
439
+ } else {
440
+ if(dv.getSegmentParentRowId(rid)) {
441
+ return ROW_TYPES.GROUP_MEMBER;
442
+ }
443
+ }
444
+ } else {
445
+ return "";
446
+ }
447
+ }
448
+ return ROW_TYPES.CONTENT;
449
+ };
398
450
  /** This method should always be called right after the initialization
399
451
  * @public
400
452
  * @param {DataCache} dataSource
@@ -1079,5 +1131,5 @@ RowDefinition.dispose = function(rowDef) {
1079
1131
  rowDef.dispose();
1080
1132
  };
1081
1133
 
1082
- export {RowDefinition, ROW_DEF};
1134
+ export {RowDefinition, ROW_DEF, ROW_TYPES};
1083
1135
  export default RowDefinition;
@@ -1,6 +1,7 @@
1
1
  import { Ext } from "../../tr-grid-util/es6/Ext.js";
2
2
  import { cloneObject } from "../../tr-grid-util/es6/Util.js";
3
3
  import { GridPlugin } from "../../tr-grid-util/es6/GridPlugin.js";
4
+ import { GroupDefinitions } from "../../tr-grid-util/es6/GroupDefinitions.js";
4
5
  import { injectCss, prettifyCss } from "../../tr-grid-util/es6/Util.js";
5
6
 
6
7
  declare namespace ColumnGroupingPlugin {
@@ -42,7 +43,7 @@ declare class ColumnGroupingPlugin extends GridPlugin {
42
43
 
43
44
  public addColumnGrouping(groupDef: ColumnGroupingPlugin.GroupDefinition|null): void;
44
45
 
45
- public removeGroup(groupId: string): ColumnGroupingPlugin.GroupDefinition|null;
46
+ public removeGroup(groupId: string): boolean;
46
47
 
47
48
  public getGroupDefinition(groupId: string): ColumnGroupingPlugin.GroupDefinition|null;
48
49
 
@@ -52,7 +53,7 @@ declare class ColumnGroupingPlugin extends GridPlugin {
52
53
 
53
54
  public setGroupDefinitions(groupDefs: ColumnGroupingPlugin.GroupDefinitions|null): void;
54
55
 
55
- public setGroupChildren(groupId: string, newChildList: (string)[]|null): void;
56
+ public setGroupChildren(groupId: string, newChildList: (string)[]|null): boolean;
56
57
 
57
58
  public getGroupChildren(groupId: string): (string)[]|null;
58
59