@refinitiv-ui/efx-grid 6.0.59 → 6.0.60

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.
@@ -99,7 +99,7 @@ RowColoringPlugin.prototype.initialize = function (host, options) {
99
99
  return;
100
100
  }
101
101
  this._hosts.push(host);
102
- host.listen("postSectionDataBinding", this._onSectionBinding);
102
+ host.listen("preSectionDataBinding", this._onSectionBinding);
103
103
  this.config(options);
104
104
  this._updateTimer = setTimeout(this._updateRowColor, 100); // For lazy loading
105
105
  };
@@ -111,7 +111,7 @@ RowColoringPlugin.prototype.unload = function (host) {
111
111
  if (at < 0) {
112
112
  return;
113
113
  }
114
- host.unlisten("postSectionDataBinding", this._onSectionBinding);
114
+ host.unlisten("preSectionDataBinding", this._onSectionBinding);
115
115
  this._hosts.splice(at, 1);
116
116
  if (!this._hosts.length) {
117
117
  if (this._updateTimer) {
@@ -422,6 +422,141 @@ RowColoringPlugin.prototype._onSectionBinding = function (e) {
422
422
  }
423
423
  };
424
424
 
425
+ /** @private
426
+ * @param {Object} section
427
+ * @param {number} fromR from row index
428
+ * @param {number} toR to row index
429
+ * @param {boolean=} forceUpdate force update coloring
430
+ */
431
+ RowColoringPlugin.prototype._applyColor = function (section, fromR, toR, forceUpdate) {
432
+ var colCount = section.getColumnCount();
433
+ var dv = this._getDataView();
434
+ var textColor, bgColor, el, cell, stretchedCell;
435
+ var txtEnabled = this._txtEnabled;
436
+ var bgEnabled = this._bgEnabled;
437
+ for (var r = fromR; r < toR; ++r) {
438
+ textColor = bgColor = "";
439
+ var rowData = this._getRow(dv, r);
440
+ if (rowData) {
441
+ if (txtEnabled) {
442
+ textColor = rowData[this._txtColorField] || "";
443
+ }
444
+ if (bgEnabled) {
445
+ bgColor = rowData[this._bgField] || "";
446
+ }
447
+ }
448
+ stretchedCell = section.getStretchedCell(null, r);
449
+ if (stretchedCell) {
450
+ el = stretchedCell.getElement();
451
+ if (textColor || el._textColor) {
452
+ if (el._textColor !== textColor || forceUpdate) {
453
+ stretchedCell.setStyle("color", textColor);
454
+ el._textColor = textColor;
455
+ }
456
+ }
457
+ if (bgColor || el._bgColor) {
458
+ if (el._bgColor !== bgColor || forceUpdate) {
459
+ stretchedCell.setStyle("backgroundColor", bgColor);
460
+ el._bgColor = bgColor;
461
+ }
462
+ }
463
+ }
464
+ for (var c = 0; c < colCount; ++c) {
465
+ cell = section.getCell(c, r, false);
466
+ if (!cell) {
467
+ continue;
468
+ }
469
+ el = cell.getElement();
470
+ if (!el) {
471
+ continue;
472
+ }
473
+ if (textColor || el._textColor) {
474
+ if (el._textColor !== textColor || forceUpdate) {
475
+ cell.setStyle("color", textColor);
476
+ el._textColor = textColor;
477
+ }
478
+ }
479
+ if (bgColor || el._bgColor) {
480
+ if (el._bgColor !== bgColor || forceUpdate) {
481
+ cell.setStyle("backgroundColor", bgColor);
482
+ el._bgColor = bgColor;
483
+ }
484
+ }
485
+ }
486
+ }
487
+ };
488
+
489
+ /** @private
490
+ * @param {Object} section
491
+ * @param {number} fromR from row index
492
+ * @param {number} toR to row index
493
+ */
494
+ RowColoringPlugin.prototype._applyPredefinedColor = function (section, fromR, toR) {
495
+ var colCount = section.getColumnCount();
496
+ var dv = this._getDataView();
497
+ var cssField = this._cssField;
498
+ var altCssField = this._altCssField;
499
+ var rangeField = this._cssRangeField;
500
+ var className, el, start, end, altCssClass, range, colorSelected, stretchedCell, cell;
501
+ for (var r = fromR; r < toR; ++r) {
502
+ className = altCssClass = "";
503
+ start = end = range = null;
504
+ var rowData = this._getRow(dv, r);
505
+ if (rowData) {
506
+ className = rowData[cssField] || "";
507
+ altCssClass = rowData[altCssField] || "";
508
+ range = rowData[rangeField];
509
+ if (Array.isArray(range)) {
510
+ start = range[0];
511
+ end = range[1] ? range[0] + range[1] : colCount; // handled case user provide only the start field (not provide the length of columns)
512
+ }
513
+ }
514
+
515
+ stretchedCell = section.getStretchedCell(null, r);
516
+ if (stretchedCell) {
517
+ el = stretchedCell.getElement();
518
+ if (el._coloringClass !== className) {
519
+ if (el._coloringClass) {
520
+ el.classList.remove(el._coloringClass);
521
+ el._coloringClass = "";
522
+ }
523
+ if (className) {
524
+ el.classList.add(className);
525
+ el._coloringClass = className;
526
+ }
527
+ }
528
+ }
529
+ for (var c = 0; c < colCount; ++c) {
530
+ cell = section.getCell(c, r, false);
531
+ if (!cell) {
532
+ continue;
533
+ }
534
+ el = cell.getElement();
535
+ if (!el) {
536
+ continue;
537
+ }
538
+ if (className && range && (c < start || c > end)) {
539
+ // use alternative color
540
+ colorSelected = altCssClass;
541
+ } else {
542
+ // use normal color
543
+ colorSelected = className;
544
+ }
545
+ if (el._coloringClass === colorSelected) {
546
+ continue;
547
+ }
548
+ if (el._coloringClass) {
549
+ el.classList.remove(el._coloringClass);
550
+ el._coloringClass = "";
551
+ }
552
+ if (colorSelected) {
553
+ el.classList.add(colorSelected);
554
+ el._coloringClass = colorSelected;
555
+ }
556
+ }
557
+ }
558
+ };
559
+
425
560
  /** @private
426
561
  * @param {number=} fromR from row index
427
562
  * @param {number=} toR to row index
@@ -447,124 +582,33 @@ RowColoringPlugin.prototype._updateRowColor = function (fromR, toR) {
447
582
  toR = section.getLastIndexInView() + 1;
448
583
  }
449
584
  // TODO: consolidate the 2 separated flows
450
- var colCount = section.getColumnCount();
451
- var r, c, rowData, cell;
452
585
  if (this._predefinedColoring) {
453
- var cssField = this._cssField;
454
- var altCssField = this._altCssField;
455
- var rangeField = this._cssRangeField;
456
- var className, el, start, end, altCssClass, range, colorSelected, stretchedCell;
457
- for (r = fromR; r < toR; ++r) {
458
- className = altCssClass = "";
459
- start = end = range = null;
460
- rowData = this._getRow(dv, r);
461
- if (rowData) {
462
- className = rowData[cssField] || "";
463
- altCssClass = rowData[altCssField] || "";
464
- range = rowData[rangeField];
465
- if (Array.isArray(range)) {
466
- start = range[0];
467
- end = range[1] ? range[0] + range[1] : colCount; // handled case user provide only the start field (not provide the length of columns)
468
- }
469
- }
470
-
471
- stretchedCell = section.getStretchedCell(null, r);
472
- if (stretchedCell) {
473
- el = stretchedCell.getElement();
474
- if (el._coloringClass !== className) {
475
- if (el._coloringClass) {
476
- el.classList.remove(el._coloringClass);
477
- el._coloringClass = "";
478
- }
479
- if (className) {
480
- el.classList.add(className);
481
- el._coloringClass = className;
482
- }
483
- }
484
- }
485
- for (c = 0; c < colCount; ++c) {
486
- cell = section.getCell(c, r, false);
487
- if (!cell) {
488
- continue;
489
- }
490
- el = cell.getElement();
491
- if (!el) {
492
- continue;
493
- }
494
- if (className && range && (c < start || c > end)) {
495
- // use alternative color
496
- colorSelected = altCssClass;
497
- } else {
498
- // use normal color
499
- colorSelected = className;
500
- }
501
- if (el._coloringClass === colorSelected) {
502
- continue;
503
- }
504
- if (el._coloringClass) {
505
- el.classList.remove(el._coloringClass);
506
- el._coloringClass = "";
507
- }
508
- if (colorSelected) {
509
- el.classList.add(colorSelected);
510
- el._coloringClass = colorSelected;
511
- }
512
- }
513
- }
586
+ this._applyPredefinedColor(section, fromR, toR);
514
587
  } else {
515
- var textColor, bgColor;
516
- var txtEnabled = this._txtEnabled;
517
- var bgEnabled = this._bgEnabled;
518
- for (r = fromR; r < toR; ++r) {
519
- textColor = bgColor = "";
520
- rowData = this._getRow(dv, r);
521
- if (rowData) {
522
- if (txtEnabled) {
523
- textColor = rowData[this._txtColorField] || "";
524
- }
525
- if (bgEnabled) {
526
- bgColor = rowData[this._bgField] || "";
527
- }
528
- }
529
- stretchedCell = section.getStretchedCell(null, r);
530
- if (stretchedCell) {
531
- el = stretchedCell.getElement();
532
- if (textColor || el._textColor) {
533
- if (el._textColor !== textColor) {
534
- stretchedCell.setStyle("color", textColor);
535
- el._textColor = textColor;
536
- }
537
- }
538
- if (bgColor || el._bgColor) {
539
- if (el._bgColor !== bgColor) {
540
- stretchedCell.setStyle("backgroundColor", bgColor);
541
- el._bgColor = bgColor;
542
- }
543
- }
544
- }
545
- for (c = 0; c < colCount; ++c) {
546
- cell = section.getCell(c, r, false);
547
- if (!cell) {
548
- continue;
549
- }
550
- el = cell.getElement();
551
- if (!el) {
552
- continue;
553
- }
554
- if (textColor || el._textColor) {
555
- if (el._textColor !== textColor) {
556
- cell.setStyle("color", textColor);
557
- el._textColor = textColor;
558
- }
559
- }
560
- if (bgColor || el._bgColor) {
561
- if (el._bgColor !== bgColor) {
562
- cell.setStyle("backgroundColor", bgColor);
563
- el._bgColor = bgColor;
564
- }
565
- }
566
- }
567
- }
588
+ this._applyColor(section, fromR, toR);
589
+ }
590
+ };
591
+ /** @public
592
+ */
593
+ RowColoringPlugin.prototype.forceUpdateRowColor = function () {
594
+ if (this._disabled) {
595
+ return;
596
+ }
597
+ var dv = this._getDataView();
598
+ if (!dv) {
599
+ return;
600
+ }
601
+ var host = this._hosts ? this._hosts[0] : null;
602
+ var section = host ? host.getSection("content") : null;
603
+ if (!section) {
604
+ return;
605
+ }
606
+ var fromR = section.getFirstIndexInView();
607
+ var toR = section.getLastIndexInView() + 1;
608
+ if (this._predefinedColoring) {
609
+ this._applyPredefinedColor(section, fromR, toR);
610
+ } else {
611
+ this._applyColor(section, fromR, toR, true);
568
612
  }
569
613
  };
570
614
  export default RowColoringPlugin;
@@ -70,6 +70,10 @@ declare class CellPainter {
70
70
 
71
71
  public getColoringType(): CellPainter.ColoringTypes|null;
72
72
 
73
+ public setEffectiveStyles(mapping: any): void;
74
+
75
+ public getEffectiveStyles(): any;
76
+
73
77
  public setConditions(conditions: (CellPainter.Condition)[]|null): void;
74
78
 
75
79
  public setColumnStats(columnStats: any): void;
@@ -62,6 +62,10 @@ CellPainter.prototype._conditions = null;
62
62
  /** @type {Object}
63
63
  * @private
64
64
  */
65
+ CellPainter.prototype._effectiveStyles = null;
66
+ /** @type {Object}
67
+ * @private
68
+ */
65
69
  CellPainter.prototype._blinkCondition = null;
66
70
  /** @type {!Array}
67
71
  * @private
@@ -185,6 +189,7 @@ CellPainter.prototype.reset = function() {
185
189
  CellPainter.prototype.resetColoring = function() {
186
190
  // reset coloring type to allow other extensions to be able to set their new mode
187
191
  this._setColoringType(0);
192
+ this._effectiveStyles = null;
188
193
  this._conditions.length = 0;
189
194
  };
190
195
 
@@ -284,6 +289,18 @@ CellPainter.prototype._setColoringType = function(enumType) {
284
289
  }
285
290
  };
286
291
  /** @public
292
+ * @param {Object} mapping Effective styles mapping
293
+ */
294
+ CellPainter.prototype.setEffectiveStyles = function(mapping) {
295
+ this._effectiveStyles = mapping;
296
+ };
297
+ /** @public
298
+ * @return {Object}
299
+ */
300
+ CellPainter.prototype.getEffectiveStyles = function() {
301
+ return this._effectiveStyles;
302
+ };
303
+ /** @public
287
304
  * @param {Array.<CellPainter~Condition>} conditions
288
305
  */
289
306
  CellPainter.prototype.setConditions = function(conditions) {
@@ -901,9 +918,17 @@ CellPainter.clearCellStyle = function(cell, styles) {
901
918
  elem.classList.remove(elem._coloringCssClass);
902
919
  }
903
920
 
904
- styles = styles || CellPainter.supportedStyles;
905
- for(var i = styles.length; --i >= 0;) {
906
- elem.style[styles[i]] = ""; // WARNING: Very slow
921
+ if(!styles){
922
+ styles = CellPainter.supportedStyles;
923
+ }
924
+ if(Array.isArray(styles)){
925
+ for(var i = styles.length; --i >= 0;) {
926
+ elem.style[styles[i]] = ""; // WARNING: Very slow
927
+ }
928
+ } else {
929
+ for(var key in styles) {
930
+ elem.style[key] = ""; // WARNING: Very slow
931
+ }
907
932
  }
908
933
  };
909
934
  /** @private
@@ -1025,26 +1050,29 @@ CellPainter.prototype._paintCell = function(cell, rowData, min, max) {
1025
1050
  }
1026
1051
 
1027
1052
  var styles = this._getStyles(rowData, min, max);
1053
+
1054
+ var elStyle = elem.style;
1055
+
1028
1056
  var cssClass = styles["cssClass"]; // Can be an empty string
1057
+ if (elem._coloringCssClass && elem._coloringCssClass !== cssClass) {
1058
+ elem.classList.remove(elem._coloringCssClass);
1059
+ elem._coloringCssClass = null;
1060
+ }
1029
1061
  if (cssClass != null) { // Predefined colors mode
1030
- if (elem._coloringCssClass && elem._coloringCssClass !== cssClass) {
1031
- elem.classList.remove(elem._coloringCssClass);
1032
- elem._coloringCssClass = null;
1033
- }
1034
1062
  if (cssClass) {
1035
1063
  elem.classList.add(cssClass);
1036
1064
  elem._coloringCssClass = cssClass;
1037
1065
  }
1038
1066
  } else {
1039
- if (elem._coloringCssClass) {
1040
- elem.classList.remove(elem._coloringCssClass);
1041
- elem._coloringCssClass = null;
1067
+ if(styles["backgroundColor"]){
1068
+ elStyle.backgroundColor = styles["backgroundColor"];
1069
+ } else if(!this._effectiveStyles || this._effectiveStyles["backgroundColor"]){
1070
+ elStyle.backgroundColor = "";
1042
1071
  }
1043
- var ss = CellPainter.bgStyles;
1044
- var elStyle = elem.style;
1045
- for (var n = ss.length; --n >= 0;) {
1046
- var styleName = ss[n];
1047
- elStyle[styleName] = styles[styleName] || "";
1072
+ if(styles["color"]){
1073
+ elStyle.color = styles["color"];
1074
+ } else if(!this._effectiveStyles || this._effectiveStyles["color"]){
1075
+ elStyle.color = "";
1048
1076
  }
1049
1077
  }
1050
1078
  };
@@ -2,6 +2,18 @@ import { Dom } from "./Dom.js";
2
2
  import { Ext } from "./Ext.js";
3
3
  import { ElementWrapper } from "./ElementWrapper.js";
4
4
 
5
+ /** @private
6
+ * @function
7
+ * @param {Element} parentElem tr element
8
+ * @param {number} count Number of elements to be added
9
+ * @param {string} childTag Tag name of the cells
10
+ */
11
+ var _addElements = function(parentElem, count, childTag) {
12
+ for(var i = count; --i >= 0;) {
13
+ parentElem.appendChild(document.createElement(childTag));
14
+ }
15
+ };
16
+
5
17
  /** SubTable represents a single tbody, thead, or tfoot element within table element
6
18
  * @constructor
7
19
  * @extends {ElementWrapper}
@@ -39,6 +51,12 @@ SubTable.prototype._defaultRowHeight = null;
39
51
  SubTable.prototype._render;
40
52
 
41
53
 
54
+ /** @private
55
+ * @return {string} tagName
56
+ */
57
+ SubTable.prototype._getCellTagName = function() {
58
+ return this._elem.tagName === "THEAD" ? "TH" : "TD";
59
+ };
42
60
  /** @public
43
61
  * @ignore
44
62
  * @param {number=} opt_count
@@ -49,12 +67,10 @@ SubTable.prototype.addColumns = function(opt_count) {
49
67
 
50
68
  this._colCount += opt_count;
51
69
 
70
+ var cellTag = this._getCellTagName();
52
71
  var rows = this._elem.children; // TODO: Must include all suspended rows
53
72
  for(var r = rows.length; --r >= 0;) {
54
- var tr = rows[r];
55
- for(var c = 0; c < opt_count; ++c) {
56
- tr.insertCell(-1);
57
- }
73
+ _addElements(rows[r], opt_count, cellTag);
58
74
  }
59
75
  };
60
76
  /** @public
@@ -100,9 +116,7 @@ SubTable.prototype.setColumnCount = function(val) {
100
116
  */
101
117
  SubTable.prototype.insertRow = function(at) {
102
118
  var row = this._elem.insertRow(at);
103
- for(var i = this._colCount; --i >= 0;) {
104
- row.insertCell();
105
- }
119
+ _addElements(row, this._colCount, this._getCellTagName());
106
120
  return row;
107
121
  };
108
122
 
@@ -58,6 +58,8 @@ declare class Table extends ElementWrapper {
58
58
 
59
59
  public getAllRows(): (Element)[];
60
60
 
61
+ public getRows(): (Element)[];
62
+
61
63
  public getRow(r: number): Element|null;
62
64
 
63
65
  public spanBlock(c1: number, c2: number, r1: number, r2: number): Element|null;
@@ -331,6 +331,7 @@ Table.prototype.getAllCells = function() { return this._tbody.getAllCells(); };
331
331
  */
332
332
  Table.prototype.getAllRows = function() { return this._tbody.getAllRows(); };
333
333
  /** @public
334
+ * @function
334
335
  * @return {!Array<Element>} Array of tr (HTMLTableRowElement) elements
335
336
  */
336
337
  Table.prototype.getRows = Table.prototype.getAllRows;
@@ -56,6 +56,8 @@ declare class RowColoringPlugin extends GridPlugin {
56
56
 
57
57
  public getContrastColor(hexColor: string): string;
58
58
 
59
+ public forceUpdateRowColor(): void;
60
+
59
61
  }
60
62
 
61
63
  export default RowColoringPlugin;
@@ -1,5 +1,6 @@
1
1
  import { GridPrinter } from "../tr-grid-printer/es6/GridPrinter.js";
2
+ import { Table } from "../tr-grid-util/es6/Table.js";
2
3
  import { MultiTableManager } from "../tr-grid-util/es6/MultiTableManager.js";
3
4
  import { DataGenerator } from "../tr-grid-util/es6/jet/DataGenerator.js";
4
5
  import { MockRTK } from "../tr-grid-util/es6/jet/MockRTK.js";
5
- export { GridPrinter, MultiTableManager, DataGenerator, MockRTK };
6
+ export { GridPrinter, Table, MultiTableManager, DataGenerator, MockRTK };
@@ -1,5 +1,6 @@
1
1
  import { GridPrinter } from "../tr-grid-printer/es6/GridPrinter.js";
2
+ import { Table } from "../tr-grid-util/es6/Table.js";
2
3
  import { MultiTableManager } from "../tr-grid-util/es6/MultiTableManager.js";
3
4
  import { DataGenerator } from "../tr-grid-util/es6/jet/DataGenerator.js";
4
5
  import { MockRTK } from "../tr-grid-util/es6/jet/MockRTK.js";
5
- export { GridPrinter, MultiTableManager, DataGenerator, MockRTK };
6
+ export { GridPrinter, Table, MultiTableManager, DataGenerator, MockRTK };
package/lib/versions.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "tr-grid-util": "1.3.120",
2
+ "tr-grid-util": "1.3.124",
3
3
  "tr-grid-printer": "1.0.16",
4
4
  "@grid/column-dragging": "1.0.14",
5
5
  "@grid/row-segmenting": "1.0.24",
@@ -14,7 +14,7 @@
14
14
  "tr-grid-column-resizing": "1.0.28",
15
15
  "tr-grid-column-selection": "1.0.29",
16
16
  "tr-grid-column-stack": "1.0.69",
17
- "tr-grid-conditional-coloring": "1.0.61",
17
+ "tr-grid-conditional-coloring": "1.0.62",
18
18
  "tr-grid-content-wrap": "1.0.20",
19
19
  "tr-grid-contextmenu": "1.0.39",
20
20
  "tr-grid-filter-input": "0.9.33",
@@ -27,7 +27,7 @@
27
27
  "tr-grid-row-filtering": "1.0.57",
28
28
  "tr-grid-row-grouping": "1.0.81",
29
29
  "tr-grid-row-selection": "1.0.23",
30
- "tr-grid-rowcoloring": "1.0.23",
30
+ "tr-grid-rowcoloring": "1.0.24",
31
31
  "tr-grid-textformatting": "1.0.46",
32
32
  "tr-grid-titlewrap": "1.0.19",
33
33
  "@grid/formatters": "1.0.50",
package/package.json CHANGED
@@ -60,11 +60,11 @@
60
60
  "./utils": "./lib/utils/index.js"
61
61
  },
62
62
  "peerDependencies": {
63
- "@refinitiv-ui/core": "^6.2.0",
64
- "@refinitiv-ui/elements": "^6.5.0"
63
+ "@refinitiv-ui/core": "^6.2.0 || ^7.0.0",
64
+ "@refinitiv-ui/elements": "^6.5.0 || ^7.0.0"
65
65
  },
66
66
  "publishConfig": {
67
67
  "access": "public"
68
68
  },
69
- "version": "6.0.59"
69
+ "version": "6.0.60"
70
70
  }