igniteui-webcomponents-grids
Version:
Ignite UI Web Components grid components.
485 lines (484 loc) • 16.8 kB
JavaScript
/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { __extends } from "tslib";
import { GridColumnOptionsViewBase } from "./GridColumnOptionsViewBase";
import { SummaryChooser } from "./SummaryChooser";
import { Popup } from "igniteui-webcomponents-core";
import { Size } from "igniteui-webcomponents-core";
import { GridColumnOptionsUtilities } from "./GridColumnOptionsUtilities";
import { runOn, markType, enumGetBox, delegateRemove, delegateCombine } from "igniteui-webcomponents-core";
import { ControlDisplayDensity_$type } from "igniteui-webcomponents-core";
import { Rect } from "igniteui-webcomponents-core";
import { GridColumnOptionsSectionBase } from "./GridColumnOptionsSectionBase";
import { BrushUtil } from "igniteui-webcomponents-core";
import { ColumnSummaryDescription } from "./ColumnSummaryDescription";
import { stringFormat } from "igniteui-webcomponents-core";
import { stringIsNullOrWhiteSpace } from "igniteui-webcomponents-core";
/**
* @hidden
*/
var GridColumnSummaryOptionsView = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(GridColumnSummaryOptionsView, _super);
function GridColumnSummaryOptionsView() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.o = null;
_this.p = null;
return _this;
}
Object.defineProperty(GridColumnSummaryOptionsView.prototype, "n", {
get: function () {
return this.b;
},
enumerable: false,
configurable: true
});
GridColumnSummaryOptionsView.prototype.k = function () {
var _this = this;
_super.prototype.k.call(this);
if (null == this.g || null == this.e) {
return;
}
if (this.n.bz == null) {
var a_1;
var b_1;
var c_1;
this.o = ((function () { var d = GridColumnOptionsUtilities.f(_this.n, _this.e, GridColumnSummaryOptionsView.r, 1, _this.n.p, _this.n.j, new Size(1, 24, 24), a_1, b_1, _this.p, c_1, false, true); a_1 = d.p7; b_1 = d.p8; _this.p = d.p9; c_1 = d.p10; return d.ret; })());
c_1.setStyleProperty("transform", "rotate(-90deg)");
this.g.append(this.o);
this.n.ck(a_1);
}
if (this.n.bx == null) {
var d = new SummaryChooser();
d.a2(this.e);
this.n.co(d);
var e = this.e.createElement("div");
var f = this.e.getSubRenderer(e);
var g = new Popup();
g.provideRenderer(f);
g.appendPopupContent(d.c.container);
this.n.cl(g);
}
document.addEventListener("mousedown", runOn(this, this.s), false);
};
GridColumnSummaryOptionsView.prototype.m = function () {
_super.prototype.m.call(this);
this.n.bh(this.n.bz);
if (this.o != null) {
this.o.setStyleProperty("margin", "0 -8px");
switch (this.n.bz.q) {
case 2:
this.p.setStyleProperty("margin", "0 -.25rem");
break;
case 1:
case 4:
case 3:
this.p.setStyleProperty("margin", "0 -.5rem");
break;
}
this.p.setRawText(this.n.cb);
this.p.setStyleProperty("font", this.n.aa.fontString);
}
};
GridColumnSummaryOptionsView.prototype.t = function () {
if (this.o != null) {
var a = this.o.getNativeElement().getBoundingClientRect();
var b = new Rect(4);
b.left = (a.left);
b.top = (a.top);
b.width = (a.width);
b.height = (a.height);
return b;
}
return Rect.empty;
};
GridColumnSummaryOptionsView.prototype.u = function () {
var a = this.t();
a.x += window.pageXOffset;
a.y += window.pageYOffset;
return a;
};
GridColumnSummaryOptionsView.prototype.q = function () {
return (window.innerWidth);
};
GridColumnSummaryOptionsView.prototype.s = function (e_) {
this.n.cj();
};
GridColumnSummaryOptionsView.$t = markType(GridColumnSummaryOptionsView, 'GridColumnSummaryOptionsView', GridColumnOptionsViewBase.$);
GridColumnSummaryOptionsView.r = "M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z";
return GridColumnSummaryOptionsView;
}(GridColumnOptionsViewBase));
export { GridColumnSummaryOptionsView };
/**
* @hidden
*/
var GridColumnSummaryOptions = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(GridColumnSummaryOptions, _super);
function GridColumnSummaryOptions() {
var _this = _super.call(this) || this;
_this.by = null;
_this.b0 = null;
_this.bw = null;
_this.b8 = null;
_this.b2 = 0;
_this.b1 = 0;
_this.b6 = 0;
_this.ct = BrushUtil.h(255, 24, 29, 31);
_this.cs = BrushUtil.h(255, 248, 248, 248);
return _this;
}
GridColumnSummaryOptions.prototype.f = function () {
return new GridColumnSummaryOptionsView();
};
GridColumnSummaryOptions.prototype.bs = function () {
if (this.c == null || this.column == null) {
return false;
}
return this.column.jc && this.c.summaryScope != 3;
};
GridColumnSummaryOptions.prototype.be = function (a, b, c) {
_super.prototype.be.call(this, a, b, c);
switch (a) {
case "ActualBaseTheme":
case "ActualDensity":
case "ActualSummaryListDensity":
case "BackgroundColor":
case "TextColor":
case "SummaryListTextColor":
case "SummaryListBackground":
this.cq();
this.cp();
this.cr();
break;
case "SummaryListDensity":
this.b3 = this.b5 == 0 ? this.q : this.b5;
break;
case "SummaryCaption":
case "ActualLabelTextStyle":
case "ActiveCount":
this.bv.m();
break;
}
};
GridColumnSummaryOptions.prototype.bt = function () {
if (this.bw != null) {
var a = this.bw.a();
for (var b = 0; b < a.length; b++) {
var c = new ColumnSummaryDescription(1, this.column.lo);
switch (a[b]) {
case "avg":
c.i = 3;
break;
case "count":
c.i = 4;
break;
case "max":
c.i = 1;
break;
case "min":
c.i = 0;
break;
case "sum":
c.i = 2;
break;
}
for (var d = 0; d < this.c.summaryDescriptions.j.count; d++) {
var e = this.c.summaryDescriptions.j.item(d);
if (e.ah == this.column.lo && e.i == c.i) {
this.c.summaryDescriptions.j.removeAt(d);
d--;
}
}
}
var f = this.bw.b();
for (var g = 0; g < f.length; g++) {
var h = new ColumnSummaryDescription(1, this.column.lo);
switch (f[g]) {
case "avg":
h.i = 3;
break;
case "count":
h.i = 4;
break;
case "max":
h.i = 1;
break;
case "min":
h.i = 0;
break;
case "sum":
h.i = 2;
break;
}
var i = false;
for (var j = 0; j < this.c.summaryDescriptions.j.count; j++) {
var k = this.c.summaryDescriptions.j.item(j);
if (k.ah == this.column.lo && k.i == h.i) {
i = true;
break;
}
}
if (!i) {
this.c.summaryDescriptions.j.add(h);
this.column.m0("Summed");
}
}
}
if (this.b0 != null && this.b0.ax) {
this.b0.b6();
}
};
GridColumnSummaryOptions.prototype.bu = function () {
if (this.b0 != null && this.b0.ax) {
this.b0.b6();
}
};
GridColumnSummaryOptions.prototype.a6 = function () {
_super.prototype.a6.call(this);
if (this.column != null) {
this.b7 = 0;
for (var a = 0; a < this.c.summaryDescriptions.j.count; a++) {
var b = this.c.summaryDescriptions.j.item(a);
if (b.ah == this.column.lo) {
switch (b.i) {
case 3:
this.bw.a4("avg", true);
this.b7++;
break;
case 4:
this.bw.a4("count", true);
this.b7++;
break;
case 1:
this.bw.a4("max", true);
this.b7++;
break;
case 0:
this.bw.a4("min", true);
this.b7++;
break;
case 2:
this.bw.a4("sum", true);
this.b7++;
break;
}
}
}
}
};
Object.defineProperty(GridColumnSummaryOptions.prototype, "cb", {
get: function () {
if (this.b7 > 0) {
return stringFormat("{0} ({1})", this.cd, this.b7);
}
else {
return this.cd;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(GridColumnSummaryOptions.prototype, "bz", {
get: function () {
return this.by;
},
enumerable: false,
configurable: true
});
Object.defineProperty(GridColumnSummaryOptions.prototype, "bx", {
get: function () {
return this.bw;
},
enumerable: false,
configurable: true
});
Object.defineProperty(GridColumnSummaryOptions.prototype, "bv", {
get: function () {
return this.e;
},
enumerable: false,
configurable: true
});
Object.defineProperty(GridColumnSummaryOptions.prototype, "cd", {
get: function () {
if (this.b8 == null) {
var a = this.ai.b1("Column_Options_Summaries");
return !stringIsNullOrWhiteSpace(a) ? a : "Summaries";
}
else {
return this.b8;
}
},
set: function (a) {
var b = this.b8;
this.b8 = a;
if (b != this.b8) {
this.bc("SummaryCaption", b, this.b8);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(GridColumnSummaryOptions.prototype, "b5", {
get: function () {
return this.b2;
},
set: function (a) {
var b = this.b2;
this.b2 = a;
if (b != this.b2) {
this.bc("SummaryListDensity", enumGetBox(ControlDisplayDensity_$type, b), enumGetBox(ControlDisplayDensity_$type, this.b2));
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(GridColumnSummaryOptions.prototype, "b3", {
get: function () {
return this.b1;
},
set: function (a) {
var b = this.b1;
this.b1 = a;
if (b != this.b1) {
this.bc("ActualSummaryListDensity", enumGetBox(ControlDisplayDensity_$type, b), enumGetBox(ControlDisplayDensity_$type, this.b1));
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(GridColumnSummaryOptions.prototype, "b7", {
get: function () {
return this.b6;
},
set: function (a) {
var b = this.b6;
this.b6 = a;
if (b != this.b6) {
this.bc("ActiveCount", b, this.b6);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(GridColumnSummaryOptions.prototype, "cv", {
get: function () {
return this.ct;
},
set: function (a) {
var b = this.ct;
this.ct = a;
if (b != this.ct) {
this.bc("SummaryListTextColor", b, this.ct);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(GridColumnSummaryOptions.prototype, "cu", {
get: function () {
return this.cs;
},
set: function (a) {
var b = this.cs;
this.cs = a;
if (b != this.cs) {
this.bc("SummaryListBackground", b, this.cs);
}
},
enumerable: false,
configurable: true
});
GridColumnSummaryOptions.prototype.cj = function () {
if (this.b0 != null && this.b0.ax) {
this.b0.b6();
}
};
GridColumnSummaryOptions.prototype.ck = function (a) {
if (this.by != null) {
var b = this.by;
b.clicked = delegateRemove(b.clicked, runOn(this, this.cm));
}
this.by = a;
if (this.by != null) {
var c = this.by;
c.clicked = delegateCombine(c.clicked, runOn(this, this.cm));
}
this.cp();
};
GridColumnSummaryOptions.prototype.cl = function (a) {
this.b0 = a;
this.cr();
};
GridColumnSummaryOptions.prototype.co = function (a) {
if (this.bw != null) {
var b = this.bw;
b.summaryChanged = delegateRemove(b.summaryChanged, runOn(this, this.cn));
}
this.bw = a;
if (this.bw != null) {
var c = this.bw;
c.summaryChanged = delegateCombine(c.summaryChanged, runOn(this, this.cn));
}
this.cq();
};
GridColumnSummaryOptions.prototype.cq = function () {
if (this.bw != null) {
this.bw.j = this.i;
this.bw.n = this.b3;
this.bw.ba = this.cv;
this.bw.a9 = this.cu;
}
};
GridColumnSummaryOptions.prototype.cp = function () {
if (this.by != null) {
this.by.ds = 0;
this.by.a2 = false;
this.by.rg = this.br;
this.bh(this.by);
}
};
GridColumnSummaryOptions.prototype.cr = function () {
if (this.b0 != null) {
this.b0.c0 = this.bo;
this.b0.am = false;
}
};
GridColumnSummaryOptions.prototype.cm = function (a, b) {
if (this.b0 == null) {
return;
}
if (this.b0.ax) {
this.b0.b6();
}
else {
var c = this.bv.t();
var d = this.bv.u();
var e = this.bv.q();
var f = 150;
if (c.right > e - f - 10) {
d.x -= f;
d.y -= d.height;
}
else {
d.x += d.width;
d.y -= d.height;
}
this.b0.showRelativeToExclusionRect(d, 1, 0);
}
};
GridColumnSummaryOptions.prototype.cn = function (a, b) {
if (b.a) {
this.b7++;
}
else {
this.b7--;
}
};
GridColumnSummaryOptions.$t = markType(GridColumnSummaryOptions, 'GridColumnSummaryOptions', GridColumnOptionsSectionBase.$);
return GridColumnSummaryOptions;
}(GridColumnOptionsSectionBase));
export { GridColumnSummaryOptions };