@refinitiv-ui/efx-grid 6.0.40 → 6.0.42

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 (44) hide show
  1. package/lib/column-selection-dialog/lib/column-selection-dialog.d.ts +2 -1
  2. package/lib/column-selection-dialog/lib/column-selection-dialog.js +23 -7
  3. package/lib/core/dist/core.js +846 -881
  4. package/lib/core/dist/core.min.js +1 -1
  5. package/lib/core/es6/grid/Core.d.ts +4 -0
  6. package/lib/core/es6/grid/Core.js +91 -27
  7. package/lib/core/es6/grid/plugins/SortableTitlePlugin.d.ts +3 -2
  8. package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +26 -26
  9. package/lib/core/es6/grid/util/util.js +25 -9
  10. package/lib/grid/index.js +1 -1
  11. package/lib/rt-grid/dist/rt-grid.js +2253 -1755
  12. package/lib/rt-grid/dist/rt-grid.min.js +1 -1
  13. package/lib/rt-grid/es6/Grid.d.ts +22 -0
  14. package/lib/rt-grid/es6/Grid.js +146 -11
  15. package/lib/rt-grid/es6/RowDefinition.d.ts +2 -2
  16. package/lib/rt-grid/es6/RowDefinition.js +37 -18
  17. package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +4 -0
  18. package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +60 -59
  19. package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +9 -3
  20. package/lib/tr-grid-column-stack/es6/ColumnStack.js +290 -364
  21. package/lib/tr-grid-util/es6/CellPainter.d.ts +2 -1
  22. package/lib/tr-grid-util/es6/CellPainter.js +6 -4
  23. package/lib/tr-grid-util/es6/DateTime.js +3 -3
  24. package/lib/tr-grid-util/es6/ExpressionParser.d.ts +10 -0
  25. package/lib/tr-grid-util/es6/ExpressionParser.js +366 -0
  26. package/lib/tr-grid-util/es6/FilterBuilder.d.ts +10 -6
  27. package/lib/tr-grid-util/es6/FilterBuilder.js +264 -234
  28. package/lib/tr-grid-util/es6/FilterOperators.d.ts +3 -1
  29. package/lib/tr-grid-util/es6/FilterOperators.js +51 -2
  30. package/lib/tr-grid-util/es6/GridPlugin.js +1 -1
  31. package/lib/tr-grid-util/es6/Util.d.ts +0 -3
  32. package/lib/tr-grid-util/es6/Util.js +0 -53
  33. package/lib/tr-grid-util/es6/formula/Formula.js +3 -3
  34. package/lib/types/es6/ColumnDragging.d.ts +51 -0
  35. package/lib/types/es6/ColumnGrouping.d.ts +4 -0
  36. package/lib/types/es6/ColumnStack.d.ts +9 -3
  37. package/lib/types/es6/Core/grid/Core.d.ts +4 -0
  38. package/lib/types/es6/Core/grid/plugins/SortableTitlePlugin.d.ts +3 -2
  39. package/lib/types/es6/ExtensionOptions.d.ts +2 -0
  40. package/lib/types/es6/Extensions.d.ts +3 -1
  41. package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +2 -2
  42. package/lib/types/es6/index.d.ts +1 -0
  43. package/lib/versions.json +4 -4
  44. package/package.json +1 -1
@@ -405,6 +405,10 @@ declare class Core extends ElementWrapper {
405
405
 
406
406
  public getColumnGroupChildIds(groupId: string): (string)[]|null;
407
407
 
408
+ public getValidColumnList(colIds: (string)[]|null, columnMap?: any): (string)[];
409
+
410
+ public createColumnMap(colIds?: (string)[]|null): any;
411
+
408
412
  public startBatch(batchType: string): boolean;
409
413
 
410
414
  public stopBatch(batchType: string): boolean;
@@ -82,6 +82,7 @@ var Core = function (opt_initializer) {
82
82
 
83
83
  _t._onMouseMove = _t._onMouseMove.bind(_t);
84
84
  _t._onRowHightlighted = _t._onRowHightlighted.bind(_t);
85
+ _t._onGridClicked = _t._onGridClicked.bind(_t);
85
86
 
86
87
  _t._onWindowResize = _t._onWindowResize.bind(_t);
87
88
  _t._onSectionDataChanged = _t._onSectionDataChanged.bind(_t);
@@ -167,11 +168,16 @@ var Core = function (opt_initializer) {
167
168
  _t._hscrollbar.setOtherScrollbar(_t._vscrollbar);
168
169
  _t._vscrollbar.setOtherScrollbar(_t._hscrollbar);
169
170
 
170
- if (Util.isMobile) {
171
+ if (Util.isMobile || Util.isTouchDevice) {
171
172
  _t._element.addEventListener("touchmove", this._onMouseMove, false);
172
173
  } else {
173
174
  _t._element.addEventListener("mousemove", this._onMouseMove, false);
174
175
  }
176
+
177
+ if(Util.isSafari){
178
+ _t._element.addEventListener("click", this._onGridClicked);
179
+ }
180
+
175
181
  window.addEventListener("resize", _t._onWindowResize, false); // Should be unlistened after destroyed
176
182
  _t._rowVirtualizer.listen("indexChanged", _t._onRowInViewChanged);
177
183
  _t._colVirtualizer.listen("indexChanged", _t._onColInViewChanged);
@@ -556,7 +562,7 @@ Core.prototype._batches = null;
556
562
  * @return {string}
557
563
  */
558
564
  Core.getVersion = function () {
559
- return "5.1.57";
565
+ return "5.1.63";
560
566
  };
561
567
  /** {@link ElementWrapper#dispose}
562
568
  * @override
@@ -1503,16 +1509,12 @@ Core.prototype.removeColumnAt = function (index) {
1503
1509
 
1504
1510
  if (this._hasListener("columnRemoved")) {
1505
1511
  var e = {};
1506
- var batches = this._batches;
1507
- if(batches){
1508
- e["batches"] = batches;
1509
- }
1510
1512
  e["atTheMiddle"] = true;
1511
1513
  e["colIndex"] = index;
1512
1514
  e["columns"] = "deprecated";
1513
1515
  e["columnData"] = colDef["columnData"];
1514
1516
  e["colId"] = colDef["id"] || "";
1515
- this._dispatch("columnRemoved", e);
1517
+ this._dispatchColumnEvent("columnRemoved", e);
1516
1518
  }
1517
1519
 
1518
1520
  // Last index in view here might be different from before moving column if columns have different width.
@@ -1765,7 +1767,7 @@ Core.prototype._moveColumn = function (fromCol, destCol) {
1765
1767
  e["fromColIndex"] = fromCol;
1766
1768
  e["toColIndex"] = destCol;
1767
1769
  e["colId"] = colId; // TODO: Id may not needed
1768
- this._dispatch("columnMoved", e);
1770
+ this._dispatchColumnEvent("columnMoved", e); // add remove move
1769
1771
  }
1770
1772
 
1771
1773
  // Last index in view here might be different from before moving column if columns have different width.
@@ -1835,6 +1837,9 @@ Core.prototype.reorderColumns = function (colRefs, destCol) {
1835
1837
  destId = destCol;
1836
1838
  }
1837
1839
 
1840
+ this.startBatch("move");
1841
+
1842
+ var dirty = 0;
1838
1843
  if(Array.isArray(colRefs)) {
1839
1844
  var srcLen = colRefs.length;
1840
1845
  if(srcLen > 1) {
@@ -1877,7 +1882,6 @@ Core.prototype.reorderColumns = function (colRefs, destCol) {
1877
1882
  }
1878
1883
  }
1879
1884
 
1880
- var dirty = 0;
1881
1885
  for(i = srcLen; --i >= 0;) {
1882
1886
  srcId = srcIds[i]; // Only valid source columns are left at this point
1883
1887
  srcIdx = this.getColumnIndex(srcId);
@@ -1888,17 +1892,15 @@ Core.prototype.reorderColumns = function (colRefs, destCol) {
1888
1892
  dirty |= this._moveColumnByIndex(srcIdx, destIdx);
1889
1893
  destId = srcId;
1890
1894
  }
1891
- return dirty ? true : false;
1892
1895
  } else {
1893
- return this.moveColumnById(colRefs[0], destId);
1896
+ dirty = this.moveColumnById(colRefs[0], destId);
1894
1897
  }
1895
- }
1896
-
1897
- if(colRefs != null) {
1898
+ } else if(colRefs != null) {
1898
1899
  // colRefs will be a number or string
1899
- return this.moveColumnById(colRefs, destId);
1900
+ dirty = this.moveColumnById(colRefs, destId);
1900
1901
  }
1901
- return false;
1902
+ this.stopBatch("move");
1903
+ return dirty ? true : false;
1902
1904
  };
1903
1905
 
1904
1906
  /** @public
@@ -4415,6 +4417,53 @@ Core.prototype.getColumnGroupChildIds = function (groupId) {
4415
4417
  return null;
4416
4418
  };
4417
4419
 
4420
+ /** @public
4421
+ * @description Get a list of objects with column id and column index in sorted order
4422
+ * @param {Array.<string>} colIds
4423
+ * @param {Object=} columnMap
4424
+ * @return {!Array.<string>} Return column array with corresponding order to UI
4425
+ * @example
4426
+ * core.getValidColumnList(["c1","c2","c5"]); // Get list of valid columns
4427
+ * core.getValidColumnList(["c1","c2","c5"],{ "c2":true, "c5":true }); // Get list of valid columns from specific mapping
4428
+ */
4429
+ Core.prototype.getValidColumnList = function (colIds, columnMap) {
4430
+ var colList = [];
4431
+ if(!colIds){
4432
+ return colList;
4433
+ }
4434
+ if(!columnMap){
4435
+ columnMap = this.createColumnMap(colIds);
4436
+ }
4437
+ var colCount = this.getColumnCount();
4438
+ for(var c = 0; c < colCount; ++c) {
4439
+ var id = this._getColumnDef(c)["id"];
4440
+ if(columnMap[id] != null){
4441
+ colList.push({"index": c, "id": id});
4442
+ }
4443
+ }
4444
+ return colList;
4445
+ };
4446
+
4447
+ /** @public
4448
+ * @description Create mapping object from an array of strings
4449
+ * @param {Array.<string>=} colIds
4450
+ * @return {!Object} Column mapping object
4451
+ */
4452
+ Core.prototype.createColumnMap = function (colIds) {
4453
+ if(!colIds){
4454
+ colIds = this.getColumnIds();
4455
+ }
4456
+ var mappingObj = {};
4457
+ var count = colIds.length;
4458
+ for(var i = 0; i < count; i++){
4459
+ var colId = colIds[i];
4460
+ if(colId){
4461
+ mappingObj[colId] = true;
4462
+ }
4463
+ }
4464
+ return mappingObj;
4465
+ };
4466
+
4418
4467
  /** @public
4419
4468
  * @param {string} batchType
4420
4469
  * @return {boolean}
@@ -4452,6 +4501,17 @@ Core.prototype.stopBatch = function (batchType) {
4452
4501
 
4453
4502
  //#region Private Methods
4454
4503
  /** @private
4504
+ * @param {string} type
4505
+ * @param {!Object} eventArg
4506
+ */
4507
+ Core.prototype._dispatchColumnEvent = function (type, eventArg) {
4508
+ var batches = this._batches;
4509
+ if(batches){
4510
+ eventArg["batches"] = batches;
4511
+ }
4512
+ this._dispatch(type, eventArg);
4513
+ };
4514
+ /** @private
4455
4515
  */
4456
4516
  Core.prototype._dispatchColumnPositionChanged = function () {
4457
4517
  if(this._columnPositionConflator.conflate()) {
@@ -4691,20 +4751,16 @@ Core.prototype._dispatchColumnAddedEvent = function (at, count, atTheMiddle, ctx
4691
4751
  if (this._hasListener("columnAdded")) {
4692
4752
  var e = {};
4693
4753
  e["atTheMiddle"] = atTheMiddle;
4694
- var batches = this._batches;
4695
- if(batches){
4696
- e["batches"] = batches;
4697
- }
4698
4754
  if(count === 1) {
4699
4755
  e["colIndex"] = at;
4700
4756
  e["context"] = ctx;
4701
- this._dispatch("columnAdded", e);
4757
+ this._dispatchColumnEvent("columnAdded", e);
4702
4758
  } else {
4703
4759
  var ary = Array.isArray(ctx) ? ctx : [];
4704
4760
  for (var i = 0; i < count; ++i) {
4705
4761
  e["colIndex"] = at + i;
4706
4762
  e["context"] = ary[i];
4707
- this._dispatch("columnAdded", e);
4763
+ this._dispatchColumnEvent("columnAdded", e);
4708
4764
  }
4709
4765
  }
4710
4766
  }
@@ -4846,15 +4902,11 @@ Core.prototype._removeColumn = function (num) { // TODO: change the logic to us
4846
4902
 
4847
4903
  if (this._hasListener("columnRemoved")) {
4848
4904
  var e = {};
4849
- var batches = this._batches;
4850
- if(batches){
4851
- e["batches"] = batches;
4852
- }
4853
4905
  for (var c = colCount; --c >= newCount; ) {
4854
4906
  var colDef = removedCols[c - newCount];
4855
4907
  e["colIndex"] = c;
4856
4908
  e["columnData"] = colDef ? colDef["columnData"] : null;
4857
- this._dispatch("columnRemoved", e);
4909
+ this._dispatchColumnEvent("columnRemoved", e);
4858
4910
  }
4859
4911
  }
4860
4912
  };
@@ -5251,6 +5303,18 @@ Core.prototype._onMouseMove = function () {
5251
5303
  this._vscrollbar.flash();
5252
5304
  this._hscrollbar.flash();
5253
5305
  };
5306
+ /** @private */
5307
+ Core.prototype._onGridClicked = function () {
5308
+ // research for dragging
5309
+ var selection = window.getSelection();
5310
+ if(selection.toString()){
5311
+ return;
5312
+ }
5313
+ var activeElem = document.activeElement;
5314
+ if(!this._element.contains(activeElem)){
5315
+ this.focus();
5316
+ }
5317
+ };
5254
5318
 
5255
5319
  /** @private
5256
5320
  * @param {Object} e
@@ -11,8 +11,9 @@ declare namespace SortableTitlePlugin {
11
11
  type SortOrder = "a" | "ascending" | "d" | "descending" | "n" | null|null;
12
12
 
13
13
  type InitialSort = {
14
- colIndex: number,
15
- field: string,
14
+ colIndex?: number|null,
15
+ colId?: string|null,
16
+ field?: string|null,
16
17
  sortOrder?: SortableTitlePlugin.SortOrder|null,
17
18
  order?: SortableTitlePlugin.SortOrder|null
18
19
  };
@@ -81,8 +81,9 @@ Ext.inherits(SortableTitlePlugin, EventDispatcher);
81
81
 
82
82
  /** The sorting object which will be used for initialSort config.
83
83
  * @typedef {Object} SortableTitlePlugin~InitialSort
84
- * @property {number} colIndex Index of the column
85
- * @property {string} field field of the column
84
+ * @property {number=} colIndex Index of the column
85
+ * @property {string=} colId column id of the column
86
+ * @property {string=} field field of the column
86
87
  * @property {SortableTitlePlugin~SortOrder=} sortOrder=null Set to "d" for descending order and "a" for ascending order
87
88
  * @property {SortableTitlePlugin~SortOrder=} order Alias of sortOrder
88
89
  */
@@ -740,6 +741,7 @@ SortableTitlePlugin.prototype.getSortedColumns = function () {
740
741
  var state = this._sortStates[i];
741
742
  arr[i] = {
742
743
  "colIndex": colIndex,
744
+ "colId": this._getColumnId(colIndex),
743
745
  "field": state["field"] || "",
744
746
  "sortOrder": state["sortOrder"] || "n"
745
747
  };
@@ -781,7 +783,7 @@ SortableTitlePlugin.prototype.sortColumns = function (sortOptions, opt_arg) {
781
783
  var opt = sortOptions[i];
782
784
  var colRef = opt["colIndex"];
783
785
  if(colRef < 0 || colRef == null) {
784
- colRef = opt["field"];
786
+ colRef = opt["colId"] || opt["field"];
785
787
  }
786
788
  var state = this._prepareSorting(
787
789
  colRef,
@@ -1368,19 +1370,9 @@ SortableTitlePlugin.prototype._prepareSorting = function (colRef, sortOrder) {
1368
1370
  return null;
1369
1371
  }
1370
1372
 
1371
- var colIndex = -1;
1372
- var field = "";
1373
- var priority = -1;
1374
- if(typeof colRef === "number") {
1375
- colIndex = colRef;
1376
- field = this.getColumnSortingField(colIndex);
1377
- priority = this.getSortPriority(colIndex);
1378
- } else if(typeof colRef === "string") {
1379
- field = colRef;
1380
- colIndex = this._getColumnIndexByField(field);
1381
- var fields = this.getColumnSortingFields();
1382
- priority = fields.indexOf(field);
1383
- }
1373
+ var colIndex = this._getColumnIndex(colRef);
1374
+ var priority = this.getSortPriority(colIndex);
1375
+ var field = this.getColumnSortingField(colIndex);
1384
1376
 
1385
1377
  var curState = (priority >= 0) ? this._sortStates[priority] : null;
1386
1378
  var curOrder = curState ? curState["sortOrder"] : "n";
@@ -1764,21 +1756,29 @@ SortableTitlePlugin.prototype._getColumnIndexByOptions = function (sortOptions)
1764
1756
  return -1;
1765
1757
  };
1766
1758
  /** @private
1767
- * @param {string} field
1759
+ * @param {string|number} colRef
1768
1760
  * @return {number}
1769
1761
  */
1770
- SortableTitlePlugin.prototype._getColumnIndexByField = function (field) {
1771
- if(field) {
1772
- var host = this._hosts[0];
1773
- var colCount = host ? host.getColumnCount() : 0;
1774
- for (var c = 0; c < colCount; ++c) {
1775
- if(field === this.getColumnSortingField(c)) {
1776
- return c;
1777
- }
1778
- }
1762
+ SortableTitlePlugin.prototype._getColumnIndex = function (colRef) {
1763
+ var host = this._hosts[0];
1764
+ if(host && colRef != null) {
1765
+ return host.getColumnIndex(colRef);
1779
1766
  }
1780
1767
  return -1;
1781
1768
  };
1769
+
1770
+ /** @private
1771
+ * @param {string|number} colRef
1772
+ * @return {string} column id or empty string for not found
1773
+ */
1774
+ SortableTitlePlugin.prototype._getColumnId = function (colRef) {
1775
+ var host = this._hosts[0];
1776
+ if(host && colRef != null) {
1777
+ return host.getColumnId(colRef);
1778
+ }
1779
+ return "";
1780
+ };
1781
+
1782
1782
  /** @private
1783
1783
  * @param {number} colIndex
1784
1784
  * @return {Object}
@@ -2,23 +2,46 @@
2
2
  * @namespace
3
3
  */
4
4
  var Util = {};
5
+
6
+ // TODO: move to tr-grid-util
7
+
5
8
  /** @const
6
9
  * @type {boolean}
7
10
  */
8
- Util.isIE = Util.isIE || (function () {
11
+ Util.isIE = (function () {
9
12
  var ua = window.navigator.userAgent;
10
13
  return (ua.indexOf('MSIE ') > 0) || (ua.indexOf('Trident/') > 0) || (ua.indexOf('Edge/') > 0);
11
14
  }());
12
15
  /** @const
13
16
  * @type {boolean}
14
17
  */
15
- Util.isTouchDevice = Util.isTouchDevice || (function () {
18
+ Util.isTouchDevice = (function () {
16
19
  if ((navigator["maxTouchPoints"] && navigator["maxTouchPoints"] < 256) ||
17
20
  (navigator["msMaxTouchPoints"] && navigator["msMaxTouchPoints"] < 256)) {
18
21
  return true;
19
22
  }
20
23
  return false;
21
24
  }());
25
+ /** @const
26
+ * @type {boolean}
27
+ */
28
+ Util.isSafari = (function () {
29
+ var rejectedExpression = /Chrome|Android|CriOS|FxiOS|EdgiOS/i;
30
+ var safariExpression = /Safari/i;
31
+ var agent = navigator.userAgent;
32
+ if (rejectedExpression.test(agent)) {
33
+ return false;
34
+ }
35
+ return safariExpression.test(agent);
36
+ }());
37
+
38
+ /** @public
39
+ * @type {boolean}
40
+ */
41
+ Util.isMobile = (function () {
42
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
43
+ }());
44
+
22
45
  /** Retrieve an element from Novakit control or any object that has "getElement" method.
23
46
  * @public
24
47
  * @ignore
@@ -364,12 +387,5 @@ Util._preventDefault = function (e) {
364
387
  e.stopPropagation();
365
388
  };
366
389
 
367
- /** @public
368
- * @type {boolean}
369
- */
370
- Util.isMobile = Util.isMobile || (function () {
371
- return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
372
- }());
373
-
374
390
  export default Util;
375
391
  export { Util };
package/lib/grid/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import {Grid} from "./lib/efx-grid.js";
2
2
  export {Grid}
3
- window.EFX_GRID = { version: "6.0.40" };
3
+ window.EFX_GRID = { version: "6.0.42" };