@refinitiv-ui/efx-grid 6.0.47 → 6.0.48

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,6 +31,7 @@ import VirtualizedLayoutGrid from "./VirtualizedLayoutGrid.js";
31
31
  * @property {string} rowId
32
32
  * @property {number} rowIndex
33
33
  */
34
+ /** @event Core#beforeContentBinding */
34
35
  /** @event Core#postSectionDataBinding */
35
36
  /** @event Core#rowHighlighted */
36
37
 
@@ -81,6 +82,7 @@ var Core = function (opt_initializer) {
81
82
 
82
83
  _t._onMouseMove = _t._onMouseMove.bind(_t);
83
84
  _t._onRowHightlighted = _t._onRowHightlighted.bind(_t);
85
+ _t._onGridClicked = _t._onGridClicked.bind(_t);
84
86
 
85
87
  _t._onWindowResize = _t._onWindowResize.bind(_t);
86
88
  _t._onSectionDataChanged = _t._onSectionDataChanged.bind(_t);
@@ -166,11 +168,16 @@ var Core = function (opt_initializer) {
166
168
  _t._hscrollbar.setOtherScrollbar(_t._vscrollbar);
167
169
  _t._vscrollbar.setOtherScrollbar(_t._hscrollbar);
168
170
 
169
- if (Util.isMobile) {
171
+ if (Util.isMobile || Util.isTouchDevice) {
170
172
  _t._element.addEventListener("touchmove", this._onMouseMove, false);
171
173
  } else {
172
174
  _t._element.addEventListener("mousemove", this._onMouseMove, false);
173
175
  }
176
+
177
+ if(Util.isSafari){
178
+ _t._element.addEventListener("click", this._onGridClicked);
179
+ }
180
+
174
181
  window.addEventListener("resize", _t._onWindowResize, false); // Should be unlistened after destroyed
175
182
  _t._rowVirtualizer.listen("indexChanged", _t._onRowInViewChanged);
176
183
  _t._colVirtualizer.listen("indexChanged", _t._onColInViewChanged);
@@ -193,6 +200,7 @@ var Core = function (opt_initializer) {
193
200
  "postDataSourceChanged",
194
201
  "preSectionRender",
195
202
  "postSectionRender",
203
+ "beforeContentBinding",
196
204
  "preSectionDataBinding",
197
205
  "postSectionDataBinding",
198
206
  "rowExpansionBinding",
@@ -554,7 +562,7 @@ Core.prototype._batches = null;
554
562
  * @return {string}
555
563
  */
556
564
  Core.getVersion = function () {
557
- return "5.1.66";
565
+ return "5.1.67";
558
566
  };
559
567
  /** {@link ElementWrapper#dispose}
560
568
  * @override
@@ -1356,6 +1364,7 @@ Core.prototype.getColumnCount = function () {
1356
1364
  * @fires Core#columnAdded
1357
1365
  * @fires Core#preSectionRender
1358
1366
  * @fires Core#columnRender
1367
+ * @fires Core#beforeContentBinding
1359
1368
  * @fires Core#preSectionDataBinding
1360
1369
  * @fires Core#columnDataBinding
1361
1370
  * @fires Core#postSectionDataBinding
@@ -1383,6 +1392,7 @@ Core.prototype.setColumnCount = function(num) {
1383
1392
  * @fires Core#columnAdded
1384
1393
  * @fires Core#preSectionRender
1385
1394
  * @fires Core#columnRender
1395
+ * @fires Core#beforeContentBinding
1386
1396
  * @fires Core#preSectionDataBinding
1387
1397
  * @fires Core#columnDataBinding
1388
1398
  * @fires Core#postSectionDataBinding
@@ -1499,16 +1509,12 @@ Core.prototype.removeColumnAt = function (index) {
1499
1509
 
1500
1510
  if (this._hasListener("columnRemoved")) {
1501
1511
  var e = {};
1502
- var batches = this._batches;
1503
- if(batches){
1504
- e["batches"] = batches;
1505
- }
1506
1512
  e["atTheMiddle"] = true;
1507
1513
  e["colIndex"] = index;
1508
1514
  e["columns"] = "deprecated";
1509
1515
  e["columnData"] = colDef["columnData"];
1510
1516
  e["colId"] = colDef["id"] || "";
1511
- this._dispatch("columnRemoved", e);
1517
+ this._dispatchColumnEvent("columnRemoved", e);
1512
1518
  }
1513
1519
 
1514
1520
  // Last index in view here might be different from before moving column if columns have different width.
@@ -1761,7 +1767,7 @@ Core.prototype._moveColumn = function (fromCol, destCol) {
1761
1767
  e["fromColIndex"] = fromCol;
1762
1768
  e["toColIndex"] = destCol;
1763
1769
  e["colId"] = colId; // TODO: Id may not needed
1764
- this._dispatch("columnMoved", e);
1770
+ this._dispatchColumnEvent("columnMoved", e); // add remove move
1765
1771
  }
1766
1772
 
1767
1773
  // Last index in view here might be different from before moving column if columns have different width.
@@ -1831,6 +1837,9 @@ Core.prototype.reorderColumns = function (colRefs, destCol) {
1831
1837
  destId = destCol;
1832
1838
  }
1833
1839
 
1840
+ this.startBatch("move");
1841
+
1842
+ var dirty = 0;
1834
1843
  if(Array.isArray(colRefs)) {
1835
1844
  var srcLen = colRefs.length;
1836
1845
  if(srcLen > 1) {
@@ -1873,7 +1882,6 @@ Core.prototype.reorderColumns = function (colRefs, destCol) {
1873
1882
  }
1874
1883
  }
1875
1884
 
1876
- var dirty = 0;
1877
1885
  for(i = srcLen; --i >= 0;) {
1878
1886
  srcId = srcIds[i]; // Only valid source columns are left at this point
1879
1887
  srcIdx = this.getColumnIndex(srcId);
@@ -1884,17 +1892,15 @@ Core.prototype.reorderColumns = function (colRefs, destCol) {
1884
1892
  dirty |= this._moveColumnByIndex(srcIdx, destIdx);
1885
1893
  destId = srcId;
1886
1894
  }
1887
- return dirty ? true : false;
1888
1895
  } else {
1889
- return this.moveColumnById(colRefs[0], destId);
1896
+ dirty = this.moveColumnById(colRefs[0], destId);
1890
1897
  }
1891
- }
1892
-
1893
- if(colRefs != null) {
1898
+ } else if(colRefs != null) {
1894
1899
  // colRefs will be a number or string
1895
- return this.moveColumnById(colRefs, destId);
1900
+ dirty = this.moveColumnById(colRefs, destId);
1896
1901
  }
1897
- return false;
1902
+ this.stopBatch("move");
1903
+ return dirty ? true : false;
1898
1904
  };
1899
1905
 
1900
1906
  /** @public
@@ -2001,6 +2007,7 @@ Core.prototype._deserializeColumn = function (index, jsonObj) {
2001
2007
  * @param {number=} opt_num Default is one row
2002
2008
  * @fires Core#preSectionRender
2003
2009
  * @fires Core#columnRender
2010
+ * @fires Core#beforeContentBinding
2004
2011
  * @fires Core#preSectionDataBinding
2005
2012
  * @fires Core#columnDataBinding
2006
2013
  * @fires Core#postSectionDataBinding
@@ -3804,6 +3811,7 @@ Core.prototype.synchronizeHScrollbar = function (subGrid) {
3804
3811
  * @param {number=} fromRowIndex INCLUSIVE If the value is undefined, the first row index will be used
3805
3812
  * @param {number=} lastRowIndex INCLUSIVE If the value is undefined, the last row index will be used
3806
3813
  * @param {Object=} userParam Addtional parameters to be fired with the event
3814
+ * @fires Core#beforeContentBinding
3807
3815
  * @fires Core#preSectionDataBinding
3808
3816
  * @fires Core#columnDataBinding
3809
3817
  * @fires Core#postSectionDataBinding
@@ -4409,6 +4417,53 @@ Core.prototype.getColumnGroupChildIds = function (groupId) {
4409
4417
  return null;
4410
4418
  };
4411
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
+
4412
4467
  /** @public
4413
4468
  * @param {string} batchType
4414
4469
  * @return {boolean}
@@ -4446,6 +4501,17 @@ Core.prototype.stopBatch = function (batchType) {
4446
4501
 
4447
4502
  //#region Private Methods
4448
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
4449
4515
  */
4450
4516
  Core.prototype._dispatchColumnPositionChanged = function () {
4451
4517
  if(this._columnPositionConflator.conflate()) {
@@ -4685,20 +4751,16 @@ Core.prototype._dispatchColumnAddedEvent = function (at, count, atTheMiddle, ctx
4685
4751
  if (this._hasListener("columnAdded")) {
4686
4752
  var e = {};
4687
4753
  e["atTheMiddle"] = atTheMiddle;
4688
- var batches = this._batches;
4689
- if(batches){
4690
- e["batches"] = batches;
4691
- }
4692
4754
  if(count === 1) {
4693
4755
  e["colIndex"] = at;
4694
4756
  e["context"] = ctx;
4695
- this._dispatch("columnAdded", e);
4757
+ this._dispatchColumnEvent("columnAdded", e);
4696
4758
  } else {
4697
4759
  var ary = Array.isArray(ctx) ? ctx : [];
4698
4760
  for (var i = 0; i < count; ++i) {
4699
4761
  e["colIndex"] = at + i;
4700
4762
  e["context"] = ary[i];
4701
- this._dispatch("columnAdded", e);
4763
+ this._dispatchColumnEvent("columnAdded", e);
4702
4764
  }
4703
4765
  }
4704
4766
  }
@@ -4840,15 +4902,11 @@ Core.prototype._removeColumn = function (num) { // TODO: change the logic to us
4840
4902
 
4841
4903
  if (this._hasListener("columnRemoved")) {
4842
4904
  var e = {};
4843
- var batches = this._batches;
4844
- if(batches){
4845
- e["batches"] = batches;
4846
- }
4847
4905
  for (var c = colCount; --c >= newCount; ) {
4848
4906
  var colDef = removedCols[c - newCount];
4849
4907
  e["colIndex"] = c;
4850
4908
  e["columnData"] = colDef ? colDef["columnData"] : null;
4851
- this._dispatch("columnRemoved", e);
4909
+ this._dispatchColumnEvent("columnRemoved", e);
4852
4910
  }
4853
4911
  }
4854
4912
  };
@@ -4881,6 +4939,9 @@ Core.prototype._onSectionDataChanged = function (e) {
4881
4939
  rowDataCollection = dataView.getMultipleRowData(rids, fromR, toR);
4882
4940
  e["dataRows"] = rowDataCollection;
4883
4941
  }
4942
+ if(e["sectionType"] === "content"){
4943
+ this._dispatch("beforeContentBinding", e);
4944
+ }
4884
4945
  this._dispatch("preSectionDataBinding", e);
4885
4946
 
4886
4947
  var dataMap = this.getDataColumnMap();
@@ -4895,9 +4956,13 @@ Core.prototype._onSectionDataChanged = function (e) {
4895
4956
  for (var r = fromR; r < toR; ++r) {
4896
4957
  if(hasDataView) {
4897
4958
  var rowData = rowDataCollection[r];
4959
+ if(!rowData) { // This is a header row
4960
+ continue;
4961
+ }
4962
+
4898
4963
  e["rowData"] = rowData;
4899
4964
  e["rowId"] = rids[r];
4900
- e["dataValue"] = rowData ? rowData[cid] : null;
4965
+ e["dataValue"] = rowData[cid];
4901
4966
  }
4902
4967
  e["rowIndex"] = r;
4903
4968
  e["cell"] = section["getCell"](c, r, false); // Accessing cell by using bracket allows extenal object to mock Section
@@ -5238,6 +5303,18 @@ Core.prototype._onMouseMove = function () {
5238
5303
  this._vscrollbar.flash();
5239
5304
  this._hscrollbar.flash();
5240
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
+ };
5241
5318
 
5242
5319
  /** @private
5243
5320
  * @param {Object} e
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.47" };
3
+ window.EFX_GRID = { version: "6.0.48" };
package/package.json CHANGED
@@ -66,5 +66,5 @@
66
66
  "publishConfig": {
67
67
  "access": "public"
68
68
  },
69
- "version": "6.0.47"
69
+ "version": "6.0.48"
70
70
  }