@refinitiv-ui/efx-grid 6.0.130 → 6.0.132

Sign up to get free protection for your applications and to get access to all the features.
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.130" };
3
+ window.EFX_GRID = { version: "6.0.132" };
@@ -2,7 +2,10 @@ import { Ext } from "../../tr-grid-util/es6/Ext.js";
2
2
  import { GridPlugin } from "../../tr-grid-util/es6/GridPlugin.js";
3
3
  import { Conflator } from "../../tr-grid-util/es6/Conflator.js";
4
4
 
5
- var isSafari = navigator.vendor &&
5
+ /** @private
6
+ * @type {boolean}
7
+ */
8
+ let isSafari = navigator.vendor &&
6
9
  navigator.vendor.indexOf('Apple') > -1 &&
7
10
  navigator.userAgent &&
8
11
  navigator.userAgent.indexOf('CriOS') == -1 &&
@@ -26,7 +29,7 @@ var isSafari = navigator.vendor &&
26
29
  * @param {AutoTooltipPlugin~Options=} options
27
30
  * @extends {GridPlugin}
28
31
  */
29
- var AutoTooltipPlugin = function (options) {
32
+ let AutoTooltipPlugin = function (options) {
30
33
  this.applyTooltipToAllColumns = this.applyTooltipToAllColumns.bind(this);
31
34
  this._onPreSectionDataBinding = this._onPreSectionDataBinding.bind(this);
32
35
  this._onPostSectionDataBinding = this._onPostSectionDataBinding.bind(this);
@@ -62,7 +65,7 @@ AutoTooltipPlugin._isColumnVisible = function(column) {
62
65
  return false;
63
66
  }
64
67
 
65
- var colElem = column.getElement();
68
+ let colElem = column.getElement();
66
69
  if(!colElem) {
67
70
  return false;
68
71
  }
@@ -75,7 +78,7 @@ AutoTooltipPlugin._isColumnVisible = function(column) {
75
78
  * @return {boolean}
76
79
  */
77
80
  AutoTooltipPlugin._isUpdateRequired = function(hosts) {
78
- var len = hosts.length;
81
+ let len = hosts.length;
79
82
  if(len <= 0 || isSafari) {
80
83
  return false;
81
84
  }
@@ -147,7 +150,7 @@ AutoTooltipPlugin.prototype.initialize = function (host, options) {
147
150
  * @param {Object} host core grid
148
151
  */
149
152
  AutoTooltipPlugin.prototype.unload = function (host) {
150
- var at = this._hosts.indexOf(host);
153
+ let at = this._hosts.indexOf(host);
151
154
  if (at < 0) { return; }
152
155
  this._hosts.splice(at, 1);
153
156
 
@@ -170,10 +173,10 @@ AutoTooltipPlugin.prototype.unload = function (host) {
170
173
  AutoTooltipPlugin.prototype.config = function (options) {
171
174
  if (!options) { return; }
172
175
 
173
- var extOptions = options.autoTooltip;
176
+ let extOptions = options.autoTooltip;
174
177
  if(extOptions) {
175
178
  // header is alias of title
176
- var val = extOptions["title"] || extOptions["header"];
179
+ let val = extOptions["title"] || extOptions["header"];
177
180
  if (val != null) {
178
181
  this._title = val ? true : false;
179
182
  }
@@ -189,10 +192,10 @@ AutoTooltipPlugin.prototype.config = function (options) {
189
192
  }
190
193
 
191
194
  // Retrive auto tooltip data from columns
192
- var columns = options["columns"];
195
+ let columns = options["columns"];
193
196
  if (columns) {
194
- var len = columns.length;
195
- for (var c = 0; c < len; ++c) {
197
+ let len = columns.length;
198
+ for (let c = 0; c < len; ++c) {
196
199
  this._configColumn(c, columns[c]);
197
200
  }
198
201
  }
@@ -203,27 +206,27 @@ AutoTooltipPlugin.prototype.config = function (options) {
203
206
  * @return {!Object}
204
207
  */
205
208
  AutoTooltipPlugin.prototype.getConfigObject = function (gridOptions) {
206
- var obj = gridOptions || {};
209
+ let obj = gridOptions || {};
207
210
 
208
- var columns = obj.columns;
211
+ let columns = obj.columns;
209
212
  if(!columns) {
210
213
  columns = obj.columns = [];
211
214
  }
212
215
 
213
- var len = this.getColumnCount();
214
- for(var i = 0; i < len; ++i) {
215
- var column = columns[i];
216
+ let len = this.getColumnCount();
217
+ for(let i = 0; i < len; ++i) {
218
+ let column = columns[i];
216
219
  if(!column) {
217
220
  column = columns[i] = {};
218
221
  }
219
222
 
220
- var colOptions = this._getColumnOption(i, "autoTooltip");
223
+ let colOptions = this._getColumnOption(i, "autoTooltip");
221
224
  if(colOptions === true) {
222
225
  column.autoTooltip = true;
223
226
  }
224
227
  }
225
228
 
226
- var extOptions = obj.autoTooltip;
229
+ let extOptions = obj.autoTooltip;
227
230
  if(!extOptions) {
228
231
  extOptions = obj.autoTooltip = {};
229
232
  }
@@ -249,7 +252,7 @@ AutoTooltipPlugin.prototype.getConfigObject = function (gridOptions) {
249
252
  */
250
253
  AutoTooltipPlugin.prototype._configColumn = function(colIndex, columnConfig) {
251
254
  if(columnConfig) {
252
- var val = columnConfig["autoTooltip"];
255
+ let val = columnConfig["autoTooltip"];
253
256
  if (val != null) {
254
257
  this._newColumnData(colIndex)["autoTooltip"] = val ? true : false;
255
258
  }
@@ -263,22 +266,22 @@ AutoTooltipPlugin.prototype._configColumn = function(colIndex, columnConfig) {
263
266
  * @param {number=} toR End row index
264
267
  */
265
268
  AutoTooltipPlugin.prototype.applyTooltip = function (colIndex, fromR, toR) {
266
- var hosts = this._hosts;
269
+ let hosts = this._hosts;
267
270
  if(!AutoTooltipPlugin._isUpdateRequired(hosts)) {
268
271
  return;
269
272
  }
270
273
 
271
- for (var i = 0; i < hosts.length; ++i) {
272
- var host = this._hosts[i];
274
+ for (let i = 0; i < hosts.length; ++i) {
275
+ let host = this._hosts[i];
273
276
  if (this._title) {
274
- var titles = host.getAllSections("title");
275
- for (var t = titles.length; --t >= 0;) {
277
+ let titles = host.getAllSections("title");
278
+ for (let t = titles.length; --t >= 0;) {
276
279
  this._updateNonContentSection(titles[t], colIndex);
277
280
  }
278
281
  }
279
282
  if (this._footer) {
280
- var footers = host.getAllSections("footer");
281
- for (var j = footers.length; --j >= 0;) {
283
+ let footers = host.getAllSections("footer");
284
+ for (let j = footers.length; --j >= 0;) {
282
285
  this._updateNonContentSection(footers[j], colIndex);
283
286
  }
284
287
  }
@@ -294,10 +297,10 @@ AutoTooltipPlugin.prototype.applyTooltip = function (colIndex, fromR, toR) {
294
297
  * @param {Array.<number>=} colIndices Column indices
295
298
  */
296
299
  AutoTooltipPlugin.prototype.applyTooltipToColumns = function (colIndices) {
297
- var host = this._hosts ? this._hosts[0] : null;
300
+ let host = this._hosts ? this._hosts[0] : null;
298
301
  if (host && host.getElement()) {
299
- var len = colIndices ? colIndices.length : 0;
300
- for (var i = 0; i < len; ++i) {
302
+ let len = colIndices ? colIndices.length : 0;
303
+ for (let i = 0; i < len; ++i) {
301
304
  this.applyTooltip(colIndices[i]);
302
305
  }
303
306
  }
@@ -308,8 +311,8 @@ AutoTooltipPlugin.prototype.applyTooltipToColumns = function (colIndices) {
308
311
  */
309
312
  AutoTooltipPlugin.prototype.applyTooltipToAllColumns = function () {
310
313
  this._applyTimer = 0;
311
- var colCount = this.getColumnCount();
312
- for (var c = 0; c < colCount; ++c) {
314
+ let colCount = this.getColumnCount();
315
+ for (let c = 0; c < colCount; ++c) {
313
316
  this.applyTooltip(c);
314
317
  }
315
318
  };
@@ -343,17 +346,17 @@ AutoTooltipPlugin.prototype._requestNonContentSectionUpdate = function () {
343
346
  return;
344
347
  }
345
348
 
346
- var hosts = this._hosts;
349
+ let hosts = this._hosts;
347
350
  if(!AutoTooltipPlugin._isUpdateRequired(hosts)) {
348
351
  return;
349
352
  }
350
353
 
351
354
  this._nonContentSectionUpdated = true;
352
355
 
353
- var colCount = this.getColumnCount();
354
- var sections, s, c;
355
- for(var i = 0; i < hosts.length; ++i) {
356
- var host = hosts[i];
356
+ let colCount = this.getColumnCount();
357
+ let sections, s, c;
358
+ for(let i = 0; i < hosts.length; ++i) {
359
+ let host = hosts[i];
357
360
 
358
361
  sections = host.getAllSections("title");
359
362
  for(s = 0; s < sections.length; s++) {
@@ -379,15 +382,15 @@ AutoTooltipPlugin.prototype._requestContentSectionUpdate = function () {
379
382
  return;
380
383
  }
381
384
 
382
- var hosts = this._hosts;
385
+ let hosts = this._hosts;
383
386
  if(!AutoTooltipPlugin._isUpdateRequired(hosts)) {
384
387
  return;
385
388
  }
386
389
 
387
- var colCount = this.getColumnCount();
388
- for(var i = 0; i < hosts.length; ++i) {
389
- var section = hosts[i].getSection("content");
390
- for(var c = 0; c < colCount; c++) {
390
+ let colCount = this.getColumnCount();
391
+ for(let i = 0; i < hosts.length; ++i) {
392
+ let section = hosts[i].getSection("content");
393
+ for(let c = 0; c < colCount; c++) {
391
394
  if(this._isTooltipCandidate(c)) {
392
395
  this._updateContentSection(section, c);
393
396
  }
@@ -404,20 +407,20 @@ AutoTooltipPlugin.prototype._requestContentSectionUpdate = function () {
404
407
  AutoTooltipPlugin.prototype._updateNonContentSection = function (section, colIndex) {
405
408
  if(!section) { return false; }
406
409
 
407
- var column = section.getColumn(colIndex);
410
+ let column = section.getColumn(colIndex);
408
411
  if(!AutoTooltipPlugin._isColumnVisible(column)) {
409
412
  return false;
410
413
  }
411
414
 
412
- var rowCount = section.getRowCount();
413
- for(var r = 0; r < rowCount; ++r) {
414
- var cell = section.getCell(colIndex, r, false); // Ignore cell span
415
+ let rowCount = section.getRowCount();
416
+ for(let r = 0; r < rowCount; ++r) {
417
+ let cell = section.getCell(colIndex, r, false); // Ignore cell span
415
418
  if(!cell || !cell.isVisible()) { return false; }
416
419
 
417
- var elem = cell.getContent();
420
+ let elem = cell.getContent();
418
421
  if(!elem) { return false; }
419
422
 
420
- var tooltipInfo = cell.getTooltipInfo();
423
+ let tooltipInfo = cell.getTooltipInfo();
421
424
  if(tooltipInfo) {
422
425
  if(tooltipInfo["userTooltip"] != null ||
423
426
  tooltipInfo["groupHeaderDefault"] != null ||
@@ -430,11 +433,11 @@ AutoTooltipPlugin.prototype._updateNonContentSection = function (section, colInd
430
433
  }
431
434
 
432
435
  // Set tooltip only if text's length is longer than column width.
433
- var sw = elem.scrollWidth;
436
+ let sw = elem.scrollWidth;
434
437
  if(sw && sw > elem.offsetWidth) {
435
438
  cell.setTooltipInfo("clippedText", true);
436
439
 
437
- var tooltip = cell.getTextContent();
440
+ let tooltip = cell.getTextContent();
438
441
  cell.setTooltipInfo("clippedTextTooltip", tooltip);
439
442
  cell.setAttribute("ef-title", tooltip);
440
443
  } else {
@@ -471,7 +474,7 @@ AutoTooltipPlugin.prototype._updateContentSection = function (section, colIndex,
471
474
  return false;
472
475
  }
473
476
 
474
- var columnObj = section.getColumn(colIndex);
477
+ let columnObj = section.getColumn(colIndex);
475
478
  if (!columnObj) {
476
479
  return false;
477
480
  }
@@ -480,24 +483,24 @@ AutoTooltipPlugin.prototype._updateContentSection = function (section, colIndex,
480
483
  return false;
481
484
  }
482
485
 
483
- var colElem = columnObj.getElement();
486
+ let colElem = columnObj.getElement();
484
487
  if (!colElem) {
485
488
  return false;
486
489
  }
487
490
 
488
- for (var r = fromR; r < toR; ++r) {
489
- var cell = section.getCell(colIndex, r, false); // Ignore cell span
491
+ for (let r = fromR; r < toR; ++r) {
492
+ let cell = section.getCell(colIndex, r, false); // Ignore cell span
490
493
  if (cell && cell.isVisible()) {
491
494
 
492
495
  if (cell._userDefinedTooltip == null) {
493
- var tooltipProp = cell.getTooltip() || cell.getAttribute('ef-title');
496
+ let tooltipProp = cell.getTooltip() || cell.getAttribute('ef-title');
494
497
  cell._userDefinedTooltip = tooltipProp || '';
495
498
  }
496
499
 
497
- var elem = cell.getContent();
498
- var tooltip = "";
500
+ let elem = cell.getContent();
501
+ let tooltip = "";
499
502
  if (elem) {
500
- var sw = elem.scrollWidth;
503
+ let sw = elem.scrollWidth;
501
504
 
502
505
  // Set tooltip only if text's length is longer than column width.
503
506
  if (sw && sw > elem.offsetWidth) {
@@ -533,8 +536,8 @@ AutoTooltipPlugin.prototype._clearTooltipCache = function (section, colIndex, fr
533
536
  return;
534
537
  }
535
538
 
536
- for (var rowIndex = fromRowIndex; rowIndex < toRowIndex; rowIndex++) {
537
- var cell = section.getCell(colIndex, rowIndex);
539
+ for (let rowIndex = fromRowIndex; rowIndex < toRowIndex; rowIndex++) {
540
+ let cell = section.getCell(colIndex, rowIndex);
538
541
  // if isDataChange = true
539
542
  if (isDataChange || (cell && cell._userDefinedTooltip != null)) {
540
543
  cell._userDefinedTooltip = null;
@@ -549,7 +552,7 @@ AutoTooltipPlugin.prototype._clearTooltipCache = function (section, colIndex, fr
549
552
  if (cell._previousPos === rowIndex + '-' + colIndex
550
553
  && !isDataChange // in case isDataChange be true then we need to clear all tooltip cache in else block
551
554
  ) {
552
- var tooltip = cell.getTooltip() || cell.getAttribute('ef-title');
555
+ let tooltip = cell.getTooltip() || cell.getAttribute('ef-title');
553
556
  if (tooltip) {
554
557
  cell.removeAttribute('ef-title');
555
558
  cell.setTooltip(tooltip);
@@ -565,27 +568,27 @@ AutoTooltipPlugin.prototype._clearTooltipCache = function (section, colIndex, fr
565
568
  };
566
569
 
567
570
  /** @private
568
- * @param {Event} e event from preSectionDataBinding
571
+ * @param {Object} e event from preSectionDataBinding
569
572
  */
570
573
  AutoTooltipPlugin.prototype._onPreSectionDataBinding = function (e) {
571
574
  if (e && e.sectionType === "content") {
572
- var colCount = this.getColumnCount();
573
- var isDataChange = e.actualUpdate === true;
574
- for (var c = 0; c < colCount; ++c) {
575
+ let colCount = this.getColumnCount();
576
+ let isDataChange = e.actualUpdate === true;
577
+ for (let c = 0; c < colCount; ++c) {
575
578
  this._clearTooltipCache(e.section, c, e.fromRowIndex, e.toRowIndex, isDataChange);
576
579
  }
577
580
  }
578
581
  };
579
582
 
580
583
  /** @private
581
- * @param {Event} e event from preSectionDataBinding
584
+ * @param {Object} e event from preSectionDataBinding
582
585
  */
583
586
  AutoTooltipPlugin.prototype._onPostSectionDataBinding = function (e) {
584
587
  this._requestAllSectionsUpdate();
585
588
  };
586
589
 
587
590
  /** @private
588
- * @param {Event|Element} e
591
+ * @param {Object} e
589
592
  */
590
593
  AutoTooltipPlugin.prototype._onColumnAdded = function(e) {
591
594
  if(e.context && e.colIndex != null) {
@@ -601,7 +604,7 @@ AutoTooltipPlugin.prototype._onColumnAdded = function(e) {
601
604
  * @return {boolean}
602
605
  */
603
606
  AutoTooltipPlugin.prototype._isTooltipCandidate = function (colIndex) {
604
- var bool = this._getColumnOption(colIndex, "autoTooltip");
607
+ let bool = this._getColumnOption(colIndex, "autoTooltip");
605
608
  if(bool != null) {
606
609
  return bool ? true : false;
607
610
  }
@@ -1,11 +1,14 @@
1
1
  import { Ext } from "../../tr-grid-util/es6/Ext.js";
2
2
  import { GridPlugin } from "../../tr-grid-util/es6/GridPlugin.js";
3
3
  import { GroupDefinitions } from "../../tr-grid-util/es6/GroupDefinitions.js";
4
- import { cloneObject, injectCss, prettifyCss, deepEqual } from "../../tr-grid-util/es6/Util.js";
4
+ import { cloneObject, injectCss, prettifyCss, deepEqual, isEmptyObject } from "../../tr-grid-util/es6/Util.js";
5
5
 
6
6
  declare namespace ColumnGroupingPlugin {
7
7
 
8
- type Options = (ColumnGroupingPlugin.GroupDefinition)[]|null;
8
+ type Options = {
9
+ groupDefinitions: ColumnGroupingPlugin.GroupDefinitions|null,
10
+ minChildCount?: number|null
11
+ };
9
12
 
10
13
  type GroupDefinitions = (ColumnGroupingPlugin.GroupDefinition)[]|null;
11
14
 
@@ -1,10 +1,12 @@
1
1
  import { Ext } from "../../tr-grid-util/es6/Ext.js";
2
2
  import { GridPlugin } from "../../tr-grid-util/es6/GridPlugin.js";
3
3
  import { GroupDefinitions } from "../../tr-grid-util/es6/GroupDefinitions.js";
4
- import { cloneObject, injectCss, prettifyCss, deepEqual } from "../../tr-grid-util/es6/Util.js";
4
+ import { cloneObject, injectCss, prettifyCss, deepEqual, isEmptyObject } from "../../tr-grid-util/es6/Util.js";
5
5
 
6
- /** @typedef {Array<ColumnGroupingPlugin~GroupDefinition>} ColumnGroupingPlugin~Options
6
+ /** @typedef {Object} ColumnGroupingPlugin~Options
7
7
  * @description This options can be specified by `columnGrouping` property of the main grid's options or extension options.
8
+ * @property {ColumnGroupingPlugin~GroupDefinitions} groupDefinitions A collection of group definition objects
9
+ * @property {number=} minChildCount=2 The minimum number of child columns required for group to be visible
8
10
  */
9
11
 
10
12
  /** @typedef {Array<ColumnGroupingPlugin~GroupDefinition>} ColumnGroupingPlugin~GroupDefinitions
@@ -89,6 +91,10 @@ ColumnGroupingPlugin.prototype._legacyColumnGroups = null;
89
91
  * @private
90
92
  */
91
93
  ColumnGroupingPlugin.prototype._selectedColMap;
94
+ /** @type {number}
95
+ * @private
96
+ */
97
+ ColumnGroupingPlugin.prototype._minChildCount = 2;
92
98
 
93
99
  /** @private
94
100
  * @param {number} a
@@ -334,7 +340,17 @@ ColumnGroupingPlugin.prototype.config = function (options) {
334
340
  let extOptions = options["columnGrouping"];
335
341
  let groupDefs = null;
336
342
  if(Array.isArray(extOptions)) {
337
- groupDefs = extOptions.filter(ColumnGroupingPlugin._hasGroupId);
343
+ groupDefs = extOptions;
344
+ } else if(typeof extOptions === "object") {
345
+ groupDefs = extOptions["groupDefinitions"];
346
+ let minChildCount = extOptions["minChildCount"];
347
+ if(typeof minChildCount === "number" && minChildCount > 0) {
348
+ this._minChildCount = minChildCount;
349
+ }
350
+ }
351
+
352
+ if(groupDefs) {
353
+ groupDefs = groupDefs.filter(ColumnGroupingPlugin._hasGroupId);
338
354
  groupDefs = groupDefs.map(ColumnGroupingPlugin._cloneObject);
339
355
  }
340
356
 
@@ -355,11 +371,26 @@ ColumnGroupingPlugin.prototype.config = function (options) {
355
371
  ColumnGroupingPlugin.prototype.getConfigObject = function (gridOptions) {
356
372
  let obj = gridOptions || {};
357
373
 
374
+ let extOptions = {};
375
+
358
376
  // TODO: Handle legacyRender method that has been migrated
359
377
  let groupDefs = this.getGroupDefinitions();
360
378
  groupDefs = groupDefs.filter(ColumnGroupingPlugin._isNotTimeSeriesGroup);
361
379
  if(groupDefs.length) {
362
- obj.columnGrouping = groupDefs;
380
+ extOptions.groupDefinitions = groupDefs;
381
+ }
382
+
383
+ if(this._minChildCount !== 2) {
384
+ extOptions.minChildCount = this._minChildCount;
385
+ }
386
+
387
+ if(!isEmptyObject(extOptions)) {
388
+ let extUserOptions = obj.columnGrouping;
389
+ if(extUserOptions != null && typeof extUserOptions === "object") {
390
+ Object.assign(extUserOptions, extOptions);
391
+ } else {
392
+ obj.columnGrouping = extOptions;
393
+ }
363
394
  }
364
395
 
365
396
  return obj;
@@ -669,6 +700,7 @@ ColumnGroupingPlugin.prototype._verifySingleChild = function(groupMap) {
669
700
  validIds[groupIds[i]] = 1;
670
701
  }
671
702
 
703
+ let minChildCount = this._minChildCount;
672
704
  let removable = true;
673
705
  while(removable){
674
706
  removable = false;
@@ -689,7 +721,7 @@ ColumnGroupingPlugin.prototype._verifySingleChild = function(groupMap) {
689
721
  }
690
722
  }
691
723
 
692
- if(validChildren.length < 2) {
724
+ if(validChildren.length < minChildCount) {
693
725
  delete groupMap[groupId];
694
726
  validIds[groupId] = 0;
695
727
  removable = true;
@@ -0,0 +1,39 @@
1
+
2
+
3
+ declare namespace LEDGuage {
4
+
5
+ type RangeValues = {
6
+ low?: number|null,
7
+ last?: number|null,
8
+ high?: number|null,
9
+ close?: number|null,
10
+ vwap?: number|null,
11
+ tick?: number|null
12
+ };
13
+
14
+ }
15
+
16
+ declare class LEDGuage {
17
+
18
+ constructor();
19
+
20
+ public static createElementWithText(text?: string|null): Element|null;
21
+
22
+ public setPriceGraph(priceGraph?: boolean|null): void;
23
+
24
+ public setRangeValue(rangeBarData: LEDGuage.RangeValues|null): void;
25
+
26
+ public isNoRangeValue(): boolean;
27
+
28
+ public isHighLowEqual(): boolean;
29
+
30
+ public isInvalidRangeValue(): boolean;
31
+
32
+ public getEqualRangeElement(): Element|null;
33
+
34
+ public getLEDGuageElement(): Element|null;
35
+
36
+ }
37
+
38
+ export default LEDGuage;
39
+ export { LEDGuage };