@refinitiv-ui/efx-grid 6.0.58 → 6.0.60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. package/lib/core/dist/core.js +4 -4
  2. package/lib/core/dist/core.min.js +1 -1
  3. package/lib/core/es6/grid/Core.js +1 -1
  4. package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +3 -3
  5. package/lib/grid/index.js +1 -1
  6. package/lib/grid/lib/efx-grid.d.ts +0 -1
  7. package/lib/grid/lib/efx-grid.js +8 -5
  8. package/lib/grid/themes/base.less +1 -1
  9. package/lib/grid/themes/halo/dark/efx-grid.js +1 -1
  10. package/lib/grid/themes/halo/dark/es5/all-elements.js +1 -1
  11. package/lib/grid/themes/halo/light/efx-grid.js +1 -1
  12. package/lib/grid/themes/halo/light/es5/all-elements.js +1 -1
  13. package/lib/grid/themes/solar/charcoal/efx-grid.js +1 -1
  14. package/lib/grid/themes/solar/charcoal/es5/all-elements.js +1 -1
  15. package/lib/grid/themes/solar/pearl/efx-grid.js +1 -1
  16. package/lib/grid/themes/solar/pearl/es5/all-elements.js +1 -1
  17. package/lib/rt-grid/dist/rt-grid.js +8 -8
  18. package/lib/rt-grid/dist/rt-grid.min.js +1 -1
  19. package/lib/rt-grid/es6/Grid.d.ts +3 -3
  20. package/lib/rt-grid/es6/Grid.js +8 -8
  21. package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +3 -1
  22. package/lib/tr-grid-column-stack/es6/ColumnStack.js +64 -8
  23. package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.js +65 -14
  24. package/lib/tr-grid-rowcoloring/es6/RowColoring.d.ts +2 -0
  25. package/lib/tr-grid-rowcoloring/es6/RowColoring.js +162 -118
  26. package/lib/tr-grid-util/es6/CellPainter.d.ts +4 -0
  27. package/lib/tr-grid-util/es6/CellPainter.js +43 -15
  28. package/lib/tr-grid-util/es6/ElementObserver.js +4 -2
  29. package/lib/tr-grid-util/es6/ElementWrapper.js +3 -2
  30. package/lib/tr-grid-util/es6/GridPlugin.js +5 -0
  31. package/lib/tr-grid-util/es6/SubTable.d.ts +4 -2
  32. package/lib/tr-grid-util/es6/SubTable.js +157 -79
  33. package/lib/tr-grid-util/es6/Table.d.ts +27 -10
  34. package/lib/tr-grid-util/es6/Table.js +104 -78
  35. package/lib/tr-grid-util/es6/formula/AdFinSubscription.js +1 -1
  36. package/lib/types/es6/ColumnStack.d.ts +3 -1
  37. package/lib/types/es6/RealtimeGrid/Grid.d.ts +3 -3
  38. package/lib/types/es6/RowColoring.d.ts +2 -0
  39. package/lib/types/es6/TextFormatting.d.ts +1 -1
  40. package/lib/utils/index.d.ts +2 -1
  41. package/lib/utils/index.js +2 -1
  42. package/lib/versions.json +4 -4
  43. package/package.json +3 -3
@@ -181,9 +181,9 @@ declare class Grid extends EventDispatcher {
181
181
 
182
182
  public _initDuplicateRicData(rowDef: RowDefinition|null): void;
183
183
 
184
- public insertRow(rowOption?: any, rowRef?: Grid.RowReference|null): any;
184
+ public insertRow(rowOption?: (RowDefinition.Options|string)|null, rowRef?: Grid.RowReference|null): RowDefinition|null;
185
185
 
186
- public insertRows(rowOptions: (any)[]|null, rowRef?: Grid.RowReference|null, opt_fields?: (string)[]|null): void;
186
+ public insertRows(rowOptions: (RowDefinition.Options|string)[]|null, rowRef?: Grid.RowReference|null, opt_fields?: (string)[]|null): void;
187
187
 
188
188
  public addStaticDataRows(dataRows: any[]|null, fields?: (string)[]|null): void;
189
189
 
@@ -323,7 +323,7 @@ declare class Grid extends EventDispatcher {
323
323
 
324
324
  public logDV(opt_options?: any): void;
325
325
 
326
- public replaceRow(rowRef: Grid.RowReference|null, rowOption?: any): any;
326
+ public replaceRow(rowRef: Grid.RowReference|null, rowOption?: (RowDefinition.Options|string)|null): RowDefinition|null;
327
327
 
328
328
  public scrollToColumn(colIndex: number, leftOfView?: boolean|null): boolean;
329
329
 
@@ -1581,16 +1581,16 @@ Grid.prototype.replaceColumn = function (columnOption, colRef) {
1581
1581
  }
1582
1582
 
1583
1583
  var colDef = this.getColumnDefinition(colIndex);
1584
- if(colDef.getChildren()) { // Parent time series field doesn't provide hidden property
1584
+ if(colDef && colDef.getChildren().length > 0) { // Parent time series field doesn't provide hidden property
1585
1585
  colConfig["hidden"] = false;
1586
1586
  }
1587
1587
 
1588
- if(colConfig.id == null) {
1588
+ if(colDef && colConfig.id == null) {
1589
1589
  colConfig.id = colDef.getId(); // retain ID
1590
1590
  }
1591
1591
  this._grid.startBatch("reset");
1592
+ this.removeColumn(colIndex);
1592
1593
  this.insertColumn(colConfig, colIndex);
1593
- this.removeColumn(colIndex + 1); // remove existing column after insert
1594
1594
  this._grid.stopBatch("reset");
1595
1595
  };
1596
1596
 
@@ -2295,9 +2295,9 @@ Grid.prototype._initDuplicateRicData = function(rowDef) {
2295
2295
  }
2296
2296
  };
2297
2297
  /** @public
2298
- * @param {Object=} rowOption
2298
+ * @param {(RowDefinition~Options|string)=} rowOption
2299
2299
  * @param {Grid~RowReference=} rowRef Reference (i.e. row index, row id, or row definition) of the insert position
2300
- * @returns {Object}
2300
+ * @returns {RowDefinition}
2301
2301
  * @example
2302
2302
  * var grid = new rt.Grid(grid_div, options);
2303
2303
  * grid.insertRow({"ric": "RIC"}, 0); // A new row is added at the top
@@ -2328,7 +2328,7 @@ Grid.prototype.insertRow = function(rowOption, rowRef) {
2328
2328
  return rowDef;
2329
2329
  };
2330
2330
  /** @public
2331
- * @param {Array.<Object>} rowOptions Array of row option object
2331
+ * @param {Array.<RowDefinition~Options|string>} rowOptions Array of row option object
2332
2332
  * @param {Grid~RowReference=} rowRef Reference (i.e. row index, row id, or row definition) of the insert position
2333
2333
  * @param {Array.<string>=} opt_fields
2334
2334
  * @example
@@ -3978,8 +3978,8 @@ Grid.prototype._logData = function(rowDefs, options) {
3978
3978
  /** @public
3979
3979
  * @description Replace existing row with a new row. Row ID would be changed, after row is replaced.
3980
3980
  * @param {Grid~RowReference} rowRef Reference (i.e. row index, row id, or row definition) of the insert position
3981
- * @param {Object=} rowOption
3982
- * @returns {Object}
3981
+ * @param {(RowDefinition~Options|string)=} rowOption
3982
+ * @returns {RowDefinition}
3983
3983
  */
3984
3984
  Grid.prototype.replaceRow = function(rowRef, rowOption) {
3985
3985
  var rowId = this._getRowId(rowRef);
@@ -14,7 +14,9 @@ declare namespace ColumnStackPlugin {
14
14
  fields: (string)[]|null,
15
15
  stacks: (ColumnStackPlugin.StackDefinition)[]|null,
16
16
  autoStacking?: boolean|null,
17
- clicked?: ((...params: any[]) => any)|null
17
+ clicked?: ((...params: any[]) => any)|null,
18
+ menuElement?: Element|null,
19
+ menuItemClicked?: ((...params: any[]) => any)|null
18
20
  };
19
21
 
20
22
  type ColumnOptions = {
@@ -10,10 +10,12 @@ import { preventDefault } from "../../tr-grid-util/es6/EventDispatcher.js";
10
10
 
11
11
  /** @typedef {Object} ColumnStackPlugin~Options
12
12
  * @description Available options describing `columnStack` object specified in grid's option
13
- * @property {Array.<string>} fields Fields for stacking. The minimum is 2 fields.
13
+ * @property {Array.<string>} fields Fields for stacking. The minimum is 2 fields
14
14
  * @property {Array.<ColumnStackPlugin~StackDefinition>} stacks List of stacking configuration
15
15
  * @property {boolean=} autoStacking Deprecated. Stacks are automatically maintained as long as its members exist
16
16
  * @property {Function=} clicked=null Event handler when user clicks on stack/expanding icon
17
+ * @property {Element=} menuElement Element used to display a column selection list
18
+ * @property {Function=} menuItemClicked When the menuElement is specified and menu item is clicked, an event handler is called
17
19
  */
18
20
 
19
21
  /** @typedef {Object} ColumnStackPlugin~ColumnOptions
@@ -122,6 +124,7 @@ var ColumnStackPlugin = function () {
122
124
  this._onBeforeBatchOperation = this._onBeforeBatchOperation.bind(this);
123
125
  this._onAfterBatchOperation = this._onAfterBatchOperation.bind(this);
124
126
  this._onPinningChanged = this._onPinningChanged.bind(this);
127
+ this._onMenuItemClicked = this._onMenuItemClicked.bind(this);
125
128
 
126
129
  this._onStackButtonClicked = this._onStackButtonClicked.bind(this);
127
130
  this._updateUI = this._updateUI.bind(this);
@@ -165,6 +168,14 @@ ColumnStackPlugin.prototype._inResetting = false;
165
168
  * @private
166
169
  */
167
170
  ColumnStackPlugin.prototype._inPinning = false;
171
+ /** @type {Element}
172
+ * @private
173
+ */
174
+ ColumnStackPlugin.prototype._menuElement = null;
175
+ /** @type {Function}
176
+ * @private
177
+ */
178
+ ColumnStackPlugin.prototype._menuItemClicked = null;
168
179
 
169
180
  /** @type {number}
170
181
  * @private
@@ -201,12 +212,28 @@ ColumnStackPlugin.prototype.initialize = function (host, options) {
201
212
  if(this._hosts.indexOf(host) >= 0) { return; }
202
213
  this._hosts.push(host);
203
214
 
204
- if(options && options["icons"]) {
205
- var icons = options["icons"]["columnStack"];
206
- if(icons) {
207
- this._stackIconName = icons["stack"];
208
- this._expandIconName = icons["expand"];
209
- this._collapseIconName = icons["collapse"];
215
+ if(options) {
216
+ if(options["icons"]) {
217
+ var icons = options["icons"]["columnStack"];
218
+ if(icons) {
219
+ this._stackIconName = icons["stack"];
220
+ this._expandIconName = icons["expand"];
221
+ this._collapseIconName = icons["collapse"];
222
+ }
223
+ }
224
+
225
+ var opt = options["columnStack"];
226
+ if(opt && this._hosts.length === 1) {
227
+ var menuElement = opt["menuElement"];
228
+ if(menuElement && typeof menuElement === "object" && menuElement.nodeType === 1) {
229
+ menuElement.addEventListener("item-trigger", this._onMenuItemClicked);
230
+ this._menuElement = menuElement;
231
+ }
232
+
233
+ var menuItemClicked = opt["menuItemClicked"];
234
+ if(typeof menuItemClicked === "function") {
235
+ this._menuItemClicked = menuItemClicked;
236
+ }
210
237
  }
211
238
  }
212
239
 
@@ -242,6 +269,10 @@ ColumnStackPlugin.prototype.unload = function (host) {
242
269
  host.unlisten("preSectionRender", this._onPreSectionRender);
243
270
  host.unlisten("pinningChanged", this._onPinningChanged);
244
271
 
272
+ if(this._menuElement) {
273
+ this._menuElement.removeEventListener("item-trigger", this._onMenuItemClicked);
274
+ }
275
+
245
276
  if(this._hosts.length <= 0) {
246
277
  this._conflator.reset();
247
278
  this._groupDefs.removeAllGroups();
@@ -1608,7 +1639,8 @@ ColumnStackPlugin.prototype._onStackButtonClicked = function(e) {
1608
1639
  value: i,
1609
1640
  selected: i === activeIndex,
1610
1641
  label: this.getColumnName(colIndices[i]),
1611
- field: this.getColumnField(colIndices[i])
1642
+ field: this.getColumnField(colIndices[i]),
1643
+ colId: children[i]
1612
1644
  };
1613
1645
  }
1614
1646
  pos["menuData"] = menuData;
@@ -1622,9 +1654,33 @@ ColumnStackPlugin.prototype._onStackButtonClicked = function(e) {
1622
1654
  pos["stackId"] = colData.id;
1623
1655
 
1624
1656
  elem.focus();
1657
+
1658
+ if(this._menuElement && !colData.spreading) {
1659
+ // Populate stack member
1660
+ var button = pos.event.srcElement;
1661
+ var el = this._menuElement;
1662
+ el.data = pos["menuData"];
1663
+ el.positionTarget = button;
1664
+ el.opened = true;
1665
+ }
1625
1666
  this._dispatch("clicked", pos);
1626
1667
  };
1668
+ /** @private
1669
+ * @param {Object} e
1670
+ */
1671
+ ColumnStackPlugin.prototype._onMenuItemClicked = function(e) {
1672
+ if(e.detail) {
1673
+ var selectedIndex = parseInt(e.detail.value, 0);
1674
+ var menuData = this._menuElement.data[selectedIndex];
1675
+ var colId = menuData.colId;
1676
+ this.setActiveColumn(colId);
1677
+ }
1678
+ this._menuElement.opened = false;
1627
1679
 
1680
+ if(this._menuItemClicked) {
1681
+ this._menuItemClicked(e);
1682
+ }
1683
+ };
1628
1684
  /** @public
1629
1685
  * @description Get member column indices in a stack
1630
1686
  * @param {string} stackId
@@ -56,6 +56,16 @@ import {ElfUtil} from '../../tr-grid-util/es6/ElfUtil.js';
56
56
 
57
57
  var COLORING_TYPE = "coloring";
58
58
  var BLINKING_TYPE = "blinking";
59
+ var CLEARING_BG = {
60
+ "backgroundColor": 1
61
+ };
62
+ var CLEARING_TEXT = {
63
+ "color": 1
64
+ };
65
+ var CLEARING_ALL = {
66
+ "backgroundColor": 1,
67
+ "color": 1
68
+ };
59
69
 
60
70
  var _bracketExp = /\[[^\[\]]*\]/g;
61
71
 
@@ -186,6 +196,7 @@ ConditionalColoringPlugin.prototype.initialize = function (host, options) {
186
196
  };
187
197
 
188
198
  /** @override
199
+ * @ignore
189
200
  */
190
201
  ConditionalColoringPlugin.prototype._afterInit = function () {
191
202
  var pendingFields = this._pendingFields;
@@ -382,8 +393,9 @@ ConditionalColoringPlugin.prototype._isValidPainter = function(painter) {
382
393
 
383
394
  /** @private
384
395
  * @param {number} colIndex
396
+ * @param {Object=} styleMapping
385
397
  */
386
- ConditionalColoringPlugin.prototype._clearCellStyles = function(colIndex) {
398
+ ConditionalColoringPlugin.prototype._clearCellStyles = function(colIndex, styleMapping) {
387
399
  var i, grid, sect, rowCount, r, cell;
388
400
  var hosts = this._hosts;
389
401
  for(i = hosts.length; --i >= 0;) {
@@ -393,7 +405,7 @@ ConditionalColoringPlugin.prototype._clearCellStyles = function(colIndex) {
393
405
  for(r = 0; r < rowCount; ++r) {
394
406
  cell = sect.getCell(colIndex, r, false);
395
407
  if (cell) {
396
- CellPainter.clearCellStyle(cell);
408
+ CellPainter.clearCellStyle(cell, styleMapping);
397
409
  }
398
410
  }
399
411
  }
@@ -561,6 +573,15 @@ ConditionalColoringPlugin.prototype.setConditionalColoring = function (colIndex,
561
573
  var painter = colData["painter"];
562
574
  var prevFields = colData["coloringFields"] ? Object.keys(colData["coloringFields"]) : null;
563
575
  var colorOptions = this._prepareColorOptions(colIndex, coloringOptions);
576
+
577
+ if (this._isValidPainter(painter)) {
578
+ if (prevFields) {
579
+ var effectiveStyles = painter.getEffectiveStyles();
580
+ this._clearCellStyles(colIndex, effectiveStyles); // Need to clear the existing previous coloring styles here
581
+ }
582
+ painter.resetColoring(); // Release any used memory
583
+ }
584
+
564
585
  if(colorOptions.hasColor) { // Set new coloring
565
586
  var newFieldsMap = colorOptions.fields;
566
587
  if (!painter) {
@@ -581,9 +602,10 @@ ConditionalColoringPlugin.prototype.setConditionalColoring = function (colIndex,
581
602
  }
582
603
 
583
604
  if(colorOptions.condColoring) {
584
- painter.setConditions(colorOptions.condColoring.conditions);
605
+ var conditions = colorOptions.condColoring.conditions;
606
+ painter.setConditions(conditions);
607
+ this._setEffectiveStyles(painter, conditions);
585
608
  } else if(colorOptions.colorText) {
586
- painter.resetColoring(); //Clear conditions before add new color
587
609
  var options = colorOptions.colorText;
588
610
  if (options.useThemeColors) {
589
611
  if (!ConditionalColoringPlugin._colorTextStyles) {
@@ -621,17 +643,7 @@ ConditionalColoringPlugin.prototype.setConditionalColoring = function (colIndex,
621
643
  this._enableColumnStyle(colIndex, true); // Remove the background image
622
644
  painter["inputField"] = colorOptions.inputField; // Used in ColumnFormatting extension for restoring the user's selected field in column format dialog
623
645
  colData["coloringFields"] = newFieldsMap;
624
- if (this._initializedGrid) { // Force rendering, the new coloring will be applied in the binding
625
- this._requestRowRefresh();
626
- }
627
646
  } else {
628
- if (this._isValidPainter(painter)) {
629
- painter.resetColoring(); // Release any used memory
630
- if (prevFields) {
631
- this._clearCellStyles(colIndex); // Need to clear the existing previous coloring styles here
632
- }
633
- }
634
-
635
647
  if (prevFields) {
636
648
  this._removeFieldReferrer(colIndex, COLORING_TYPE);
637
649
  }
@@ -639,6 +651,16 @@ ConditionalColoringPlugin.prototype.setConditionalColoring = function (colIndex,
639
651
  colData["coloringFields"] = null;
640
652
  this._enableColumnStyle(colIndex, false);
641
653
  }
654
+ if (this._initializedGrid) {
655
+ var core = this._hosts[0];
656
+ if(core){
657
+ var rowColoring = core.getPlugin('RowColoringPlugin');
658
+ if(rowColoring && rowColoring.forceUpdateRowColor){
659
+ rowColoring.forceUpdateRowColor();
660
+ }
661
+ }
662
+ this._requestRowRefresh();
663
+ }
642
664
  };
643
665
 
644
666
  /** @public
@@ -1216,6 +1238,35 @@ ConditionalColoringPlugin.prototype._clearPainter = function (colData) {
1216
1238
  return false;
1217
1239
  };
1218
1240
 
1241
+ /** @private
1242
+ * @param {CellPainter} painter
1243
+ * @param {Array<ConditionalColoringPlugin~Condition>} conditions
1244
+ */
1245
+ ConditionalColoringPlugin.prototype._setEffectiveStyles = function(painter, conditions) {
1246
+ var effectiveStyles = null;
1247
+ var hasColor = false;
1248
+ var hasBackgroundColor = false;
1249
+ var condCount = conditions ? conditions.length : 0;
1250
+ for(var i = 0; i < condCount; i++){
1251
+ var cond = conditions[i];
1252
+ if(cond["color"]){
1253
+ hasColor = true;
1254
+ }
1255
+ if(cond["backgroundColor"]){
1256
+ hasBackgroundColor = true;
1257
+ }
1258
+ }
1259
+ if(hasColor && hasBackgroundColor){
1260
+ effectiveStyles = CLEARING_ALL;
1261
+ } else if(hasColor){
1262
+ effectiveStyles = CLEARING_TEXT;
1263
+ } else if(hasBackgroundColor){
1264
+ effectiveStyles = CLEARING_BG;
1265
+ }
1266
+
1267
+ painter.setEffectiveStyles(effectiveStyles);
1268
+ };
1269
+
1219
1270
  /** @private
1220
1271
  */
1221
1272
  ConditionalColoringPlugin._cleanUpPrevFields = function() {
@@ -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;
@@ -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;