@refinitiv-ui/efx-grid 6.0.8 → 6.0.10

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.
package/lib/grid/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  import "./lib/efx-grid.js";
2
- window.EFX_GRID = { version: "6.0.8" };
2
+ window.EFX_GRID = { version: "6.0.10" };
@@ -9826,6 +9826,10 @@ Segment.prototype._collapsed = false;
9826
9826
  * @private
9827
9827
  */
9828
9828
  Segment.prototype._value = 0;
9829
+ /** @type {number}
9830
+ * @private
9831
+ */
9832
+ Segment.prototype._order = 0;
9829
9833
 
9830
9834
 
9831
9835
  /** @public
@@ -9993,6 +9997,18 @@ Segment.prototype.getValue = function() {
9993
9997
  Segment.prototype.setValue = function(val) {
9994
9998
  this._value = val;
9995
9999
  };
10000
+ /** @public
10001
+ * @return {number}
10002
+ */
10003
+ Segment.prototype.getOrder = function() {
10004
+ return this._order;
10005
+ };
10006
+ /** @public
10007
+ * @param {number} val
10008
+ */
10009
+ Segment.prototype.setOrder = function(val) {
10010
+ this._order = val;
10011
+ };
9996
10012
 
9997
10013
 
9998
10014
  /* harmony default export */ var data_Segment = (Segment);
@@ -10039,6 +10055,7 @@ SegmentCollection.prototype.addSegment = function(rid) {
10039
10055
  if(rid && !this._segments[rid]) {
10040
10056
  if(this._childToSegmentId[rid]) {
10041
10057
  console.log("child of a segment cannot be set as a segment separator");
10058
+ return false;
10042
10059
  }
10043
10060
  this._segments[rid] = new data_Segment(rid);
10044
10061
  ++this._segmentCount;
@@ -10369,8 +10386,27 @@ SegmentCollection.prototype.fillSegments = function(rids) {
10369
10386
  return change;
10370
10387
  };
10371
10388
  /** @public
10389
+ * @param {Array.<string>} rids
10390
+ */
10391
+ SegmentCollection.prototype.calcSegmentOrder = function(rids) {
10392
+ var ridCount = rids ? rids.length : 0;
10393
+ var segmentSeparators = this._segments;
10394
+ var segmentCount = this._segmentCount;
10395
+ var order = 0;
10396
+ for(var i = 0; i < ridCount; ++i) {
10397
+ var rid = rids[i];
10398
+ var segment = segmentSeparators[rid];
10399
+ if(segment) {
10400
+ segment.setOrder(++order);
10401
+ if(order >= segmentCount) {
10402
+ break;
10403
+ }
10404
+ }
10405
+ }
10406
+ };
10407
+ /** @public
10372
10408
  * @param {!Array.<string>} rids Array of row ids
10373
- * @return {Array.<number>} Returns Array of segment values, if there are at least two segments, otherwise returns null
10409
+ * @return {Array.<number>} Returns Array of segment values, if there are at least one segment, otherwise returns null
10374
10410
  */
10375
10411
  SegmentCollection.prototype.getSegmentValues = function(rids) {
10376
10412
  var rowCount = rids ? rids.length : 0;
@@ -10380,51 +10416,33 @@ SegmentCollection.prototype.getSegmentValues = function(rids) {
10380
10416
  var segmentSeparators = this._segments;
10381
10417
  var childToSegmentId = this._childToSegmentId;
10382
10418
  var curSegment = null;
10419
+ var prevSegment = null;
10383
10420
  var segmentValues = new Array(rowCount);
10384
- var curSegmentCount = 0;
10385
10421
  var segmentVal = 0;
10386
- var r = 0;
10387
- var childToIndex = {};
10388
- while(r < rowCount) {
10422
+ var offset = 0;
10423
+ for(var r = 0; r < rowCount; ++r) {
10389
10424
  var rid = rids[r];
10390
- if(segmentSeparators[rid]) {
10391
- ++curSegmentCount;
10392
- curSegment = segmentSeparators[rid];
10393
- segmentVal += 100;
10394
- segmentValues[r] = segmentVal;
10395
- curSegment.setValue(segmentVal);
10396
- if(curSegmentCount >= this._segmentCount) {
10397
- ++r;
10398
- break;
10399
- }
10425
+ curSegment = segmentSeparators[rid];
10426
+ if(curSegment) {
10427
+ offset = 0;
10400
10428
  } else {
10401
- if(curSegmentCount) {
10402
- segmentValues[r] = segmentVal + 10;
10429
+ var parentId = childToSegmentId[rid];
10430
+ if(parentId) {
10431
+ curSegment = segmentSeparators[parentId];
10432
+ offset = 1;
10403
10433
  } else {
10404
- segmentValues[r] = 0;
10405
- }
10406
- if(childToSegmentId[rid]) {
10407
- childToIndex[rid] = r;
10408
- }
10409
- }
10410
- ++r;
10411
- }
10412
- if(curSegmentCount) {
10413
- while(r < rowCount) {
10414
- rid = rids[r];
10415
- segmentValues[r] = segmentVal + 10;
10416
- if(childToSegmentId[rid]) {
10417
- childToIndex[rid] = r;
10434
+ offset = prevSegment ? 10 : 0;
10418
10435
  }
10419
- ++r;
10420
10436
  }
10421
- for(var childId in childToIndex) {
10422
- curSegment = segmentSeparators[childToSegmentId[childId]];
10423
- segmentValues[childToIndex[childId]] = curSegment.getValue() + 1;
10437
+
10438
+ if(curSegment && prevSegment !== curSegment) {
10439
+ prevSegment = curSegment;
10440
+ segmentVal = curSegment.getOrder() * 100;
10424
10441
  }
10442
+ segmentValues[r] = segmentVal + offset;
10425
10443
  }
10426
10444
 
10427
- return curSegmentCount ? segmentValues : null;
10445
+ return prevSegment ? segmentValues : null;
10428
10446
  };
10429
10447
 
10430
10448
 
@@ -10996,6 +11014,7 @@ DataTable.prototype.removeRows = function(refs) {
10996
11014
  this._prevData[rid] = this._rows[rid];
10997
11015
  this._removedRows[rid] = 1;
10998
11016
  delete this._rows[rid];
11017
+ // TODO: remove segments
10999
11018
  dirty = true;
11000
11019
  }
11001
11020
  }
@@ -11092,6 +11111,7 @@ DataTable.prototype.moveRow = function(fromIndex, toIndex, suppressEvent) {
11092
11111
 
11093
11112
  if(output) {
11094
11113
  if(this._segments) {
11114
+ this._segments.calcSegmentOrder(this._rids);
11095
11115
  this._sort(null); // Reorder segment members
11096
11116
  }
11097
11117
  this._dispatchPositionChange(suppressEvent);
@@ -11321,12 +11341,19 @@ DataTable.prototype.isFrozen = function() {
11321
11341
  DataTable.prototype.setSegmentSeparator = function(rid, enabled) {
11322
11342
  var change = false;
11323
11343
  var memberCount = 0;
11324
- if(typeof rid === "string") {
11344
+ if(rid && typeof rid === "string") {
11325
11345
  if(enabled !== false) {
11326
11346
  if(!this._segments) {
11327
11347
  this._segments = new data_SegmentCollection();
11328
11348
  }
11349
+ if(this._autoSegmentFilling) {
11350
+ var parentId = this._segments.getParentRowId(rid);
11351
+ if(parentId) {
11352
+ this._segments.removeSegmentChild(parentId, rid);
11353
+ }
11354
+ }
11329
11355
  if(this._segments.addSegment(rid)) {
11356
+ this._segments.calcSegmentOrder(this._rids);
11330
11357
  change = true;
11331
11358
  }
11332
11359
  } else if(this._segments) {
@@ -11628,6 +11655,7 @@ DataTable.prototype.sortSegments = function (compare) {
11628
11655
  }
11629
11656
 
11630
11657
  if(dirty) {
11658
+ this._segments.calcSegmentOrder(rids);
11631
11659
  this._sort(null);
11632
11660
  this._dispatchPositionChange();
11633
11661
  }
@@ -15676,6 +15704,13 @@ CellFloatingPanel.prototype._items = [];
15676
15704
  CellFloatingPanel.prototype.hasItem = function () {
15677
15705
  return !!this._items.length;
15678
15706
  };
15707
+ /** @public
15708
+ * @param {Element} icon Element of item
15709
+ * @returns {boolean}
15710
+ */
15711
+ CellFloatingPanel.prototype.containItem = function (icon) {
15712
+ return this._items.indexOf(icon) > -1;
15713
+ };
15679
15714
  /** @public
15680
15715
  * @param {Element} item
15681
15716
  * @param {number=} opt_order The greater the order, the farther the position to the right
@@ -16160,6 +16195,9 @@ Cell.prototype.updateIcon = function(icon) {
16160
16195
 
16161
16196
  var fi = this._frontIcon;
16162
16197
  if (fi) {
16198
+ if(fi.containItem(icon)) { // Check same icon which duplicate with insertItem in _frontIcon
16199
+ return;
16200
+ }
16163
16201
  fi.clearItems();
16164
16202
  }
16165
16203
  this.insertFrontIcon(icon, 0);
@@ -18904,7 +18942,11 @@ StretchedCells.prototype.setCellCount = function (count) {
18904
18942
  * @return {Cell}
18905
18943
  */
18906
18944
  StretchedCells.prototype.getCell = function (rowIndex) {
18907
- return this._cells[rowIndex] || null;
18945
+ var cell = this._cells[rowIndex];
18946
+ if(cell && cell["getParent"]()) {
18947
+ return cell;
18948
+ }
18949
+ return null;
18908
18950
  };
18909
18951
  /** @public
18910
18952
  * @ignore
@@ -18951,13 +18993,13 @@ StretchedCells.prototype.getColumnIndex = function (cellRef) {
18951
18993
  StretchedCells.prototype.getRowIndex = function (cellRef) {
18952
18994
  if(cellRef) {
18953
18995
  if(cellRef["getElement"]) {
18954
- return this._cells.indexOf(cellRef);
18996
+ return cellRef["getParent"]() ? this._cells.indexOf(cellRef) : -1;
18955
18997
  } else {
18956
18998
  var cells = this._cells;
18957
18999
  var rowCount = cells.length;
18958
19000
  for(var r = 0; r < rowCount; ++r) {
18959
19001
  var cell = cells[r];
18960
- if(cell && cell["getElement"]() === cellRef) {
19002
+ if(cell && cell["getParent"]() && cell["getElement"]() === cellRef) {
18961
19003
  return r;
18962
19004
  }
18963
19005
  }
@@ -33221,7 +33263,7 @@ Core.prototype._rowHeightTimerId = 0;
33221
33263
  * @return {string}
33222
33264
  */
33223
33265
  Core.getVersion = function () {
33224
- return "5.1.15";
33266
+ return "5.1.20";
33225
33267
  };
33226
33268
  /** {@link ElementWrapper#dispose}
33227
33269
  * @override
@@ -43067,6 +43109,32 @@ Grid.prototype.setRowData = function(rowRef, values) {
43067
43109
  rowDef.setRowData(values);
43068
43110
  }
43069
43111
  };
43112
+
43113
+ /**
43114
+ * @public
43115
+ * @param {Grid~RowReference} rowRef
43116
+ * @param {Object} values
43117
+ */
43118
+ Grid.prototype.setStaticRowData = function(rowRef, values) {
43119
+ var rowDef = this._getRowDefinition(rowRef);
43120
+ if(rowDef) {
43121
+ rowDef.setStaticRowData(values);
43122
+ }
43123
+ };
43124
+
43125
+ /**
43126
+ * @public
43127
+ * @param {Grid~RowReference} rowRef
43128
+ * @param {string} field
43129
+ * @param {*} value
43130
+ */
43131
+ Grid.prototype.setStaticData = function(rowRef, field, value) {
43132
+ var rowDef = this._getRowDefinition(rowRef);
43133
+ if(rowDef) {
43134
+ rowDef.setStaticData(field, value);
43135
+ }
43136
+ };
43137
+
43070
43138
  /** @private
43071
43139
  * @param {Grid~RowReference=} rowRef
43072
43140
  * @return {string}
@@ -45296,13 +45364,33 @@ var _joinSubKeys = function(subA, subB) {
45296
45364
  var MockQuotes2 = function() {
45297
45365
 
45298
45366
  };
45367
+ /** @private
45368
+ * @type {*}
45369
+ */
45370
+ MockQuotes2.prototype._lastSub = null;
45371
+ /** @private
45372
+ * @type {Object}
45373
+ */
45374
+ MockQuotes2.prototype._configObj = null;
45299
45375
 
45376
+ /** @public
45377
+ * @param {Object=} options
45378
+ */
45379
+ MockQuotes2.prototype.config = function(options) {
45380
+ if(options) {
45381
+ this._configObj = options;
45382
+ }
45383
+ if(this._lastSub && this._configObj) {
45384
+ this._lastSub.config(this._configObj);
45385
+ }
45386
+ };
45300
45387
  /** @public
45301
45388
  * @param {Object=} options
45302
45389
  * @return {MockSubscriptions}
45303
45390
  */
45304
45391
  MockQuotes2.prototype.create = function(options) {
45305
- return new MockSubscriptions(options);
45392
+ this._lastSub = new MockSubscriptions(options || this._configObj);
45393
+ return this._lastSub;
45306
45394
  };
45307
45395
 
45308
45396
  /** @public
@@ -45312,30 +45400,40 @@ MockQuotes2.prototype.isSkipHeaderSupported = function() {
45312
45400
  return true;
45313
45401
  };
45314
45402
 
45403
+ /** @public
45404
+ * @param {number=} min
45405
+ * @param {number=} max
45406
+ */
45407
+ MockQuotes2.prototype.setUpdateInterval = function(min, max) {
45408
+ if(this._lastSub) {
45409
+ this._lastSub.setUpdateInterval(min, max);
45410
+ } else {
45411
+ if(!this._configObj) {
45412
+ this._configObj = {};
45413
+ }
45414
+ this._configObj.minInterval = min;
45415
+ this._configObj.maxInterval = max;
45416
+ }
45417
+ };
45418
+ /** @public
45419
+ * @param {number=} percent
45420
+ */
45421
+ MockQuotes2.prototype.setPercentageDataUpdate = function(percent) {
45422
+ if(this._lastSub) {
45423
+ this._lastSub.setPercentageDataUpdate(percent);
45424
+ } else {
45425
+ if(!this._configObj) {
45426
+ this._configObj = {};
45427
+ }
45428
+ this._configObj.percentageDataUpdate = percent;
45429
+ }
45430
+ };
45431
+
45315
45432
 
45316
45433
  /** @constructor
45317
45434
  * @param {Object=} options
45318
45435
  */
45319
45436
  var MockSubscriptions = function(options) {
45320
- if(options) {
45321
- if(typeof options.minInterval === "number") {
45322
- this._minInterval = options.minInterval;
45323
- if(this._minInterval > this._maxInterval) {
45324
- this._maxInterval = this._minInterval;
45325
- }
45326
- }
45327
-
45328
- if(typeof options.maxInterval === "number") {
45329
- this._maxInterval = options.maxInterval;
45330
- if(this._minInterval > this._maxInterval) {
45331
- this._minInterval = this._maxInterval;
45332
- }
45333
- }
45334
-
45335
- if(typeof options.percentageDataUpdate === "number") {
45336
- this._percentageDataUpdate = options.percentageDataUpdate / 100;
45337
- }
45338
- }
45339
45437
  this._onSubscriptionResponse = this._onSubscriptionResponse.bind(this);
45340
45438
 
45341
45439
  this._subMap = {};
@@ -45343,21 +45441,51 @@ var MockSubscriptions = function(options) {
45343
45441
  this._fields = {};
45344
45442
  this._events = {};
45345
45443
  this._dataGen = new DataGenerator();
45444
+
45445
+ this.config(options);
45346
45446
  };
45347
45447
 
45348
- /* @private
45448
+ /** @private
45349
45449
  * @type {number}
45350
45450
  */
45351
45451
  MockSubscriptions.prototype._minInterval = 750;
45352
- /* @private
45452
+ /** @private
45353
45453
  * @type {number}
45354
45454
  */
45355
45455
  MockSubscriptions.prototype._maxInterval = 850;
45356
- /* @private
45357
- * @type {float}
45456
+ /** @private
45457
+ * @type {number}
45358
45458
  */
45359
45459
  MockSubscriptions.prototype._percentageDataUpdate = 0.1; // 10% by default
45360
45460
 
45461
+ /** @public
45462
+ * @param {Object=} options
45463
+ */
45464
+ MockSubscriptions.prototype.config = function(options) {
45465
+ if(!options) {
45466
+ return;
45467
+ }
45468
+ var num = options.minInterval;
45469
+ if(typeof num === "number") {
45470
+ this._minInterval = num;
45471
+ if(this._minInterval > this._maxInterval) {
45472
+ this._maxInterval = this._minInterval;
45473
+ }
45474
+ }
45475
+
45476
+ num = options.maxInterval;
45477
+ if(typeof num === "number") {
45478
+ this._maxInterval = num;
45479
+ if(this._minInterval > this._maxInterval) {
45480
+ this._minInterval = this._maxInterval;
45481
+ }
45482
+ }
45483
+
45484
+ num = options.percentageDataUpdate;
45485
+ if(typeof num === "number") {
45486
+ this._percentageDataUpdate = num / 100;
45487
+ }
45488
+ };
45361
45489
  /** @public
45362
45490
  * @param {number=} min
45363
45491
  * @param {number=} max
@@ -46140,20 +46268,28 @@ mockDataAPI.setInvalidFields = setInvalidFields;
46140
46268
 
46141
46269
 
46142
46270
 
46143
- /** @constructor */
46144
- var MockJET = function() {
46271
+ /** @constructor
46272
+ * @param {Object=} options
46273
+ */
46274
+ var MockJET = function(options) {
46145
46275
  this["Quotes"] = new MockQuotes();
46146
46276
  this["Quotes2"] = new MockQuotes2();
46147
46277
  this["Archive"] = new MockArchive();
46148
46278
  this["ContainerDescription"] = true;
46149
46279
  this["Data"] = mockDataAPI;
46280
+ if(options) {
46281
+ this["Quotes2"].config(options);
46282
+ }
46150
46283
  };
46151
46284
 
46152
46285
  /** @public
46153
- * @param {Object=} opt_obj
46286
+ * @param {Object=} options
46154
46287
  * @return {MockJET}
46155
46288
  */
46156
- MockJET.prototype.init = function(opt_obj) {
46289
+ MockJET.prototype.init = function(options) {
46290
+ if(options) {
46291
+ this["Quotes2"].config(options);
46292
+ }
46157
46293
  return this;
46158
46294
  };
46159
46295