@refinitiv-ui/efx-grid 6.0.59 → 6.0.61
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/column-selection-dialog/lib/column-selection-dialog.d.ts +1 -1
- package/lib/column-selection-dialog/lib/column-selection-dialog.js +1 -41
- package/lib/column-selection-dialog/themes/base.less +32 -0
- package/lib/column-selection-dialog/themes/elemental/dark/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/elemental/dark/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/elemental/light/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/elemental/light/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/halo/dark/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/halo/dark/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/halo/light/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/halo/light/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/solar/charcoal/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/solar/charcoal/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/solar/pearl/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/solar/pearl/es5/all-elements.js +1 -1
- package/lib/core/dist/core.js +2 -6
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/grid/Core.js +2 -6
- package/lib/grid/index.js +1 -1
- package/lib/grid/lib/efx-grid.d.ts +0 -1
- package/lib/grid/lib/efx-grid.js +8 -5
- package/lib/grid/themes/base.less +1 -1
- package/lib/grid/themes/halo/dark/efx-grid.js +1 -1
- package/lib/grid/themes/halo/dark/es5/all-elements.js +1 -1
- package/lib/grid/themes/halo/light/efx-grid.js +1 -1
- package/lib/grid/themes/halo/light/es5/all-elements.js +1 -1
- package/lib/grid/themes/solar/charcoal/efx-grid.js +1 -1
- package/lib/grid/themes/solar/charcoal/es5/all-elements.js +1 -1
- package/lib/grid/themes/solar/pearl/efx-grid.js +1 -1
- package/lib/grid/themes/solar/pearl/es5/all-elements.js +1 -1
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +1 -0
- package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.js +65 -14
- package/lib/tr-grid-rowcoloring/es6/RowColoring.d.ts +2 -0
- package/lib/tr-grid-rowcoloring/es6/RowColoring.js +162 -118
- package/lib/tr-grid-util/es6/CellPainter.d.ts +4 -0
- package/lib/tr-grid-util/es6/CellPainter.js +43 -15
- package/lib/tr-grid-util/es6/ElementObserver.js +2 -1
- package/lib/tr-grid-util/es6/ExpressionParser.js +55 -13
- package/lib/tr-grid-util/es6/SubTable.js +21 -7
- package/lib/tr-grid-util/es6/Table.d.ts +2 -0
- package/lib/tr-grid-util/es6/Table.js +1 -0
- package/lib/tr-grid-util/es6/jet/DataGenerator.d.ts +35 -13
- package/lib/tr-grid-util/es6/jet/DataGenerator.js +42 -17
- package/lib/types/es6/RowColoring.d.ts +2 -0
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +2 -1
- package/lib/versions.json +5 -5
- package/package.json +3 -3
@@ -99,7 +99,7 @@ RowColoringPlugin.prototype.initialize = function (host, options) {
|
|
99
99
|
return;
|
100
100
|
}
|
101
101
|
this._hosts.push(host);
|
102
|
-
host.listen("
|
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("
|
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
|
-
|
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
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
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
|
905
|
-
|
906
|
-
|
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
|
1040
|
-
|
1041
|
-
|
1067
|
+
if(styles["backgroundColor"]){
|
1068
|
+
elStyle.backgroundColor = styles["backgroundColor"];
|
1069
|
+
} else if(!this._effectiveStyles || this._effectiveStyles["backgroundColor"]){
|
1070
|
+
elStyle.backgroundColor = "";
|
1042
1071
|
}
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
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
|
};
|
@@ -91,7 +91,8 @@ ElementObserver._addListener = function(elem, fn) {
|
|
91
91
|
}
|
92
92
|
};
|
93
93
|
|
94
|
-
/**
|
94
|
+
/** Add a listener to a html lang attribute
|
95
|
+
* @public
|
95
96
|
* @param {Element} element An element within the DOM tree to watch for changes
|
96
97
|
*/
|
97
98
|
ElementObserver.addLanguageListener = function(element) {
|
@@ -17,7 +17,9 @@ var OperatorPrecedences = {
|
|
17
17
|
"-": 4,
|
18
18
|
"*": 5,
|
19
19
|
"%": 6,
|
20
|
-
"/": 6
|
20
|
+
"/": 6,
|
21
|
+
"!": 7,
|
22
|
+
"!!": 7
|
21
23
|
};
|
22
24
|
/** @type {Object.<string, Function>}
|
23
25
|
* @private
|
@@ -36,10 +38,32 @@ var OperatorFunctions = {
|
|
36
38
|
"==": function(lhs, rhs){ return lhs == rhs; },
|
37
39
|
"!=": function(lhs, rhs){ return lhs != rhs; },
|
38
40
|
"&&": function(lhs, rhs){ return lhs && rhs; },
|
39
|
-
"||": function(lhs, rhs){ return lhs || rhs; }
|
41
|
+
"||": function(lhs, rhs){ return lhs || rhs; },
|
42
|
+
"!": function(lhs, rhs){ return !lhs; },
|
43
|
+
"!!": function(lhs, rhs){ return !!lhs; }
|
40
44
|
};
|
41
45
|
/** @type {Object.<string, Function>}
|
42
46
|
* @private
|
47
|
+
* @const
|
48
|
+
*/
|
49
|
+
var OperandRequirements = {
|
50
|
+
"+": 2,
|
51
|
+
"-": 2,
|
52
|
+
"*": 2,
|
53
|
+
"/": 2,
|
54
|
+
"%": 2,
|
55
|
+
"<": 2,
|
56
|
+
">": 2,
|
57
|
+
"<=": 2,
|
58
|
+
">=": 2,
|
59
|
+
"==": 2,
|
60
|
+
"!=": 2,
|
61
|
+
"&&": 2,
|
62
|
+
"||": 2,
|
63
|
+
"!": 1,
|
64
|
+
"!!": 1
|
65
|
+
};
|
66
|
+
/** @private
|
43
67
|
* @function
|
44
68
|
* @param {Array.<Object>} ary
|
45
69
|
* @param {string|number} value
|
@@ -57,10 +81,20 @@ var _addToken = function(ary, value, type, dataType) {
|
|
57
81
|
}
|
58
82
|
if(type === "operator") {
|
59
83
|
tok.precedence = OperatorPrecedences[value];
|
84
|
+
} else if(type === "parenthesis") {
|
85
|
+
tok.precedence = 0;
|
60
86
|
}
|
61
87
|
ary.push(tok);
|
62
88
|
return ary.length - 1;
|
63
89
|
};
|
90
|
+
/** @private
|
91
|
+
* @function
|
92
|
+
* @param {Object} obj
|
93
|
+
* @returns {*}
|
94
|
+
*/
|
95
|
+
var _toValue = function(obj) { // eslint-disable-line
|
96
|
+
return obj.value;
|
97
|
+
};
|
64
98
|
|
65
99
|
/** @public
|
66
100
|
* @namespace
|
@@ -174,8 +208,9 @@ ExpressionParser._tester = function(ctx) {
|
|
174
208
|
for(var i = 0; i < inputCount; ++i) {
|
175
209
|
var tok = rpn[i];
|
176
210
|
if(tok.type !== "literal") {
|
177
|
-
|
178
|
-
|
211
|
+
var requiredCount = OperandRequirements[tok.value];
|
212
|
+
if(operandCount >= requiredCount) {
|
213
|
+
operandCount -= requiredCount;
|
179
214
|
} else {
|
180
215
|
console.warn("Cannot parse an expression with insufficient number of operands");
|
181
216
|
return true;
|
@@ -216,11 +251,18 @@ ExpressionParser._filter = function(ctx, rowData) {
|
|
216
251
|
curRes = rowData ? rowData[tokValue] : null;
|
217
252
|
}
|
218
253
|
} else { // operator
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
254
|
+
if(OperandRequirements[tokValue] === 1) {
|
255
|
+
curRes = OperatorFunctions[tokValue](
|
256
|
+
results[operandCount - 1]
|
257
|
+
);
|
258
|
+
operandCount -= 1;
|
259
|
+
} else { // 2
|
260
|
+
curRes = OperatorFunctions[tokValue](
|
261
|
+
results[operandCount - 2],
|
262
|
+
results[operandCount - 1]
|
263
|
+
);
|
264
|
+
operandCount -= 2;
|
265
|
+
}
|
224
266
|
}
|
225
267
|
results[operandCount++] = curRes;
|
226
268
|
}
|
@@ -289,7 +331,6 @@ ExpressionParser.parse = function(expression) {
|
|
289
331
|
}
|
290
332
|
infixTokens.push(tok);
|
291
333
|
}
|
292
|
-
// TODO: Handle the case where subtraction operator is in front of a variable
|
293
334
|
ExpressionParser._tokens.length = 0;
|
294
335
|
|
295
336
|
// Convert Infix notation to Reverse Polish Notation (Postfix)
|
@@ -324,9 +365,10 @@ ExpressionParser.parse = function(expression) {
|
|
324
365
|
}
|
325
366
|
}
|
326
367
|
} else { // operator
|
327
|
-
|
328
|
-
|
329
|
-
|
368
|
+
while(operators.length) {
|
369
|
+
if(tok.precedence > operators[operators.length - 1].precedence) {
|
370
|
+
break;
|
371
|
+
}
|
330
372
|
rpn.push(operators.pop());
|
331
373
|
}
|
332
374
|
operators.push(tok);
|
@@ -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
|
-
|
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
|
-
|
104
|
-
row.insertCell();
|
105
|
-
}
|
119
|
+
_addElements(row, this._colCount, this._getCellTagName());
|
106
120
|
return row;
|
107
121
|
};
|
108
122
|
|
@@ -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;
|