igniteui-react-grids
Version:
Ignite UI React grid components.
437 lines (436 loc) • 14.9 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 { GridColumnOptionsViewBase } from "./GridColumnOptionsViewBase";
import { SummaryChooser } from "./SummaryChooser";
import { Popup } from "igniteui-react-core";
import { Size } from "igniteui-react-core";
import { GridColumnOptionsUtilities } from "./GridColumnOptionsUtilities";
import { runOn, markType, enumGetBox, delegateRemove, delegateCombine } from "igniteui-react-core";
import { ControlDisplayDensity_$type } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
import { GridColumnOptionsSectionBase } from "./GridColumnOptionsSectionBase";
import { BrushUtil } from "igniteui-react-core";
import { ColumnSummaryDescription } from "./ColumnSummaryDescription";
import { stringFormat } from "igniteui-react-core";
import { stringIsNullOrWhiteSpace } from "igniteui-react-core";
/**
* @hidden
*/
export let GridColumnSummaryOptionsView = /*@__PURE__*/ (() => {
class GridColumnSummaryOptionsView extends GridColumnOptionsViewBase {
constructor() {
super(...arguments);
this.o = null;
this.p = null;
}
get n() {
return this.b;
}
k() {
super.k();
if (null == this.g || null == this.e) {
return;
}
if (this.n.bz == null) {
let a;
let b;
let c;
this.o = ((() => { let d = GridColumnOptionsUtilities.f(this.n, this.e, GridColumnSummaryOptionsView.r, 1, this.n.p, this.n.j, new Size(1, 24, 24), a, b, this.p, c, false, true); a = d.p7; b = d.p8; this.p = d.p9; c = d.p10; return d.ret; })());
c.setStyleProperty("transform", "rotate(-90deg)");
this.g.append(this.o);
this.n.ck(a);
}
if (this.n.bx == null) {
let d = new SummaryChooser();
d.a2(this.e);
this.n.co(d);
let e = this.e.createElement("div");
let f = this.e.getSubRenderer(e);
let g = new Popup();
g.provideRenderer(f);
g.appendPopupContent(d.c.container);
this.n.cl(g);
}
document.addEventListener("mousedown", runOn(this, this.s), false);
}
m() {
super.m();
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);
}
}
t() {
if (this.o != null) {
let a = this.o.getNativeElement().getBoundingClientRect();
let 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;
}
u() {
let a = this.t();
a.x += window.pageXOffset;
a.y += window.pageYOffset;
return a;
}
q() {
return (window.innerWidth);
}
s(e_) {
this.n.cj();
}
}
GridColumnSummaryOptionsView.$t = /*@__PURE__*/ markType(GridColumnSummaryOptionsView, 'GridColumnSummaryOptionsView', GridColumnOptionsViewBase.$);
GridColumnSummaryOptionsView.r = "M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z";
return GridColumnSummaryOptionsView;
})();
/**
* @hidden
*/
export let GridColumnSummaryOptions = /*@__PURE__*/ (() => {
class GridColumnSummaryOptions extends GridColumnOptionsSectionBase {
constructor() {
super();
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);
}
f() {
return new GridColumnSummaryOptionsView();
}
bs() {
if (this.c == null || this.column == null) {
return false;
}
return this.column.jd && this.c.summaryScope != 3;
}
be(a, b, c) {
super.be(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;
}
}
bt() {
if (this.bw != null) {
let a = this.bw.a();
for (let b = 0; b < a.length; b++) {
let 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 (let d = 0; d < this.c.summaryDescriptions.j.count; d++) {
let e = this.c.summaryDescriptions.j.item(d);
if (e.ah == this.column.lo && e.i == c.i) {
this.c.summaryDescriptions.j.removeAt(d);
d--;
}
}
}
let f = this.bw.b();
for (let g = 0; g < f.length; g++) {
let 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;
}
let i = false;
for (let j = 0; j < this.c.summaryDescriptions.j.count; j++) {
let 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.mz("Summed");
}
}
}
if (this.b0 != null && this.b0.ax) {
this.b0.b6();
}
}
bu() {
if (this.b0 != null && this.b0.ax) {
this.b0.b6();
}
}
a6() {
super.a6();
if (this.column != null) {
this.b7 = 0;
for (let a = 0; a < this.c.summaryDescriptions.j.count; a++) {
let 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;
}
}
}
}
}
get cb() {
if (this.b7 > 0) {
return stringFormat("{0} ({1})", this.cd, this.b7);
}
else {
return this.cd;
}
}
get bz() {
return this.by;
}
get bx() {
return this.bw;
}
get bv() {
return this.e;
}
get cd() {
if (this.b8 == null) {
let a = this.ai.b1("Column_Options_Summaries");
return !stringIsNullOrWhiteSpace(a) ? a : "Summaries";
}
else {
return this.b8;
}
}
set cd(a) {
let b = this.b8;
this.b8 = a;
if (b != this.b8) {
this.bc("SummaryCaption", b, this.b8);
}
}
get b5() {
return this.b2;
}
set b5(a) {
let b = this.b2;
this.b2 = a;
if (b != this.b2) {
this.bc("SummaryListDensity", enumGetBox(ControlDisplayDensity_$type, b), enumGetBox(ControlDisplayDensity_$type, this.b2));
}
}
get b3() {
return this.b1;
}
set b3(a) {
let b = this.b1;
this.b1 = a;
if (b != this.b1) {
this.bc("ActualSummaryListDensity", enumGetBox(ControlDisplayDensity_$type, b), enumGetBox(ControlDisplayDensity_$type, this.b1));
}
}
get b7() {
return this.b6;
}
set b7(a) {
let b = this.b6;
this.b6 = a;
if (b != this.b6) {
this.bc("ActiveCount", b, this.b6);
}
}
get cv() {
return this.ct;
}
set cv(a) {
let b = this.ct;
this.ct = a;
if (b != this.ct) {
this.bc("SummaryListTextColor", b, this.ct);
}
}
get cu() {
return this.cs;
}
set cu(a) {
let b = this.cs;
this.cs = a;
if (b != this.cs) {
this.bc("SummaryListBackground", b, this.cs);
}
}
cj() {
if (this.b0 != null && this.b0.ax) {
this.b0.b6();
}
}
ck(a) {
if (this.by != null) {
let b = this.by;
b.clicked = delegateRemove(b.clicked, runOn(this, this.cm));
}
this.by = a;
if (this.by != null) {
let c = this.by;
c.clicked = delegateCombine(c.clicked, runOn(this, this.cm));
}
this.cp();
}
cl(a) {
this.b0 = a;
this.cr();
}
co(a) {
if (this.bw != null) {
let b = this.bw;
b.summaryChanged = delegateRemove(b.summaryChanged, runOn(this, this.cn));
}
this.bw = a;
if (this.bw != null) {
let c = this.bw;
c.summaryChanged = delegateCombine(c.summaryChanged, runOn(this, this.cn));
}
this.cq();
}
cq() {
if (this.bw != null) {
this.bw.j = this.i;
this.bw.n = this.b3;
this.bw.ba = this.cv;
this.bw.a9 = this.cu;
}
}
cp() {
if (this.by != null) {
this.by.ds = 0;
this.by.a2 = false;
this.by.rg = this.br;
this.bh(this.by);
}
}
cr() {
if (this.b0 != null) {
this.b0.c0 = this.bo;
this.b0.am = false;
}
}
cm(a, b) {
if (this.b0 == null) {
return;
}
if (this.b0.ax) {
this.b0.b6();
}
else {
let c = this.bv.t();
let d = this.bv.u();
let e = this.bv.q();
let 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);
}
}
cn(a, b) {
if (b.a) {
this.b7++;
}
else {
this.b7--;
}
}
}
GridColumnSummaryOptions.$t = /*@__PURE__*/ markType(GridColumnSummaryOptions, 'GridColumnSummaryOptions', GridColumnOptionsSectionBase.$);
return GridColumnSummaryOptions;
})();