igniteui-react-grids
Version:
Ignite UI React grid components.
784 lines (783 loc) • 27.5 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 { Base, runOn, Delegate_$type, markType, INotifyPropertyChanged_$type, PropertyChangedEventArgs, delegateRemove, enumGetBox, typeCast, delegateCombine } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { ControlDisplayDensity_$type } from "igniteui-react-core";
import { Thickness } from "igniteui-react-core";
import { XButton } from "igniteui-react-inputs";
import { BrushUtil } from "igniteui-react-core";
import { ElevationHelper } from "igniteui-react-inputs";
import { BaseDOMEventProxy } from "igniteui-react-core";
import { IDataGridComponent_$type } from "./IDataGridComponent";
import { DataGrid } from "./DataGrid";
import { BaseControlTheme_$type } from "igniteui-react-core";
import { XIcon } from "igniteui-react-inputs";
import { ToolbarVisualModelExport } from "./ToolbarVisualModelExport";
/**
* @hidden
*/
export let DataGridToolbarView = /*@__PURE__*/ (() => {
class DataGridToolbarView extends Base {
constructor() {
super();
this.k = null;
this.f = null;
this.d = null;
this.e = null;
this.h = null;
this.i = null;
this.j = null;
this.g = null;
this.a = null;
this.c = null;
this.b = new List$1(Delegate_$type, 0);
}
s() {
}
p(a) {
if (a == null) {
this.c = null;
return;
}
this.c = a;
let b = Math.round(a.rootWrapper.width());
let c = Math.round(a.rootWrapper.height());
this.c.rootWrapper.setStyleProperty("position", "relative");
this.c.rootWrapper.setStyleProperty("display", "flex");
this.c.rootWrapper.setStyleProperty("justify-content", "space-between");
this.c.rootWrapper.setStyleProperty("align-items", "center");
this.c.rootWrapper.setStyleProperty("padding", "4px 16px 4px 16px");
if (this.a.be != null) {
this.c.rootWrapper.setStyleProperty("background-color", this.a.be._fill);
}
this.aa();
this.c.rootWrapper.setStyleProperty("border-style", "solid");
this.c.rootWrapper.setStyleProperty("box-sizing", "border-box");
this.c.rootWrapper.setStyleProperty("border-color", "rgba(0, 0, 0, 0.2)");
this.c.rootWrapper.setStyleProperty("border-radius", "3px 3px 0px 0px");
this.ad();
this.k = this.c.rootWrapper.getChildAt(0);
this.y();
let d = this.c.rootWrapper.getChildAt(1);
d.setStyleProperty("justify-content", "space-around");
this.v();
this.x();
}
ad() {
if (this.c != null) {
switch (this.a.l) {
case 1:
this.c.rootWrapper.setStyleProperty("height", "52px");
break;
case 2:
this.c.rootWrapper.setStyleProperty("height", "46px");
break;
case 4:
case 3:
this.c.rootWrapper.setStyleProperty("height", "44px");
break;
case 0:
this.c.rootWrapper.setStyleProperty("height", "46px");
break;
}
}
}
z() {
if (this.c != null) {
if (this.a.be != null) {
this.c.rootWrapper.setStyleProperty("background-color", this.a.be._fill);
}
}
}
aa() {
this.c.rootWrapper.setStyleProperty("border-width", this.a.bi.top + "px " + this.a.bi.right + "px " + this.a.bi.bottom + "px " + this.a.bi.left + "px");
}
y() {
if (this.k != null && this.a.ar != null) {
this.k.setText(this.a.ar);
this.k.setStyleProperty("font", "16px Verdana");
}
this.ah();
this.ai();
}
ah() {
if (this.k != null && this.a.bg != null) {
this.k.setStyleProperty("color", this.a.bg._fill);
}
}
ai() {
if (this.k != null && this.a.n != null) {
this.k.setStyleProperty("font", this.a.n.fontString);
}
}
v() {
if (this.c != null) {
let a = this.c.rootWrapper.getChildAt(1);
this.f = a.getChildAt(0);
this.f.setProperty("id", "hideBtn");
this.e = this.c.rootWrapper.getChildAt(2);
this.w(this.e);
this.e.setStyleProperty("height", "400px");
this.e.setStyleProperty("width", "250px");
let b = this.e.getChildAt(0);
b.setStyleProperty("height", "calc(100% - 16px)");
b.setStyleProperty("padding", "4px 16px 4px 16px");
b.setStyleProperty("box-sizing", "border-box");
if (this.a.q == true) {
if (this.a.g == null) {
this.d = this.c.createElement("div");
this.a.a5(this.a, this.c, this.f, this.d, "Hiding");
this.f.listen("click", runOn(this, this.n));
}
else {
this.f.show();
}
}
else {
this.f.hide();
}
}
}
ae() {
if (this.d != null) {
let a = this.d.getChildAt(1);
a.setText(this.a.s.toString());
}
}
ab() {
if (this.d != null) {
if (this.d.getChildCount() > 2) {
let a = this.d.getChildAt(2);
a.setText(this.a.ad.toString());
}
else {
let b = this.c.createElement("span");
b.setStyleProperty("display", "inline-block");
b.setStyleProperty("font-size", "14px");
b.setStyleProperty("font-weight", "600");
b.setText(this.a.ad);
this.d.append(b);
}
}
}
n(a) {
if (this.e != null) {
if (this.g == null || this.g != this.e) {
this.l();
let b = this.f.getOffset();
this.e.setOffset(b.left - this.e.width() + this.f.width(), b.top + this.f.height());
this.g = this.e;
this.t();
}
else {
this.l();
}
}
a.stopPropagation();
}
x() {
if (this.c != null) {
let a = this.c.rootWrapper.getChildAt(1);
this.h = a.getChildAt(1);
this.h.setProperty("id", "pinBtn");
this.j = this.c.rootWrapper.getChildAt(3);
this.w(this.j);
this.j.setStyleProperty("height", "400px");
this.j.setStyleProperty("width", "250px");
let b = this.j.getChildAt(0);
b.setStyleProperty("height", "calc(100% - 16px)");
b.setStyleProperty("padding", "8px 16px 8px 16px");
b.setStyleProperty("box-sizing", "border-box");
if (this.a.r == true) {
if (this.a.h == null) {
this.i = this.c.createElement("div");
this.a.a5(this.a, this.c, this.h, this.i, "Pinning");
this.h.listen("click", runOn(this, this.u));
}
else {
this.h.show();
}
}
else {
this.h.hide();
}
}
}
af() {
if (this.i != null) {
let a = this.i.getChildAt(1);
a.setText(this.a.t.toString());
}
}
ag() {
if (this.i != null) {
if (this.i.getChildCount() > 2) {
let a = this.i.getChildAt(2);
a.setText(this.a.ai);
}
else {
let b = this.c.createElement("span");
b.setStyleProperty("display", "inline-block");
b.setStyleProperty("font-size", "14px");
b.setStyleProperty("font-weight", "600");
b.setText(this.a.ai);
this.i.append(b);
}
}
}
u(a) {
if (this.j != null) {
if (this.g == null || this.g != this.j) {
this.l();
let b = this.h.getOffset();
this.j.setOffset(b.left - this.j.width() + this.h.width(), b.top + this.h.height());
this.g = this.j;
this.t();
}
else {
this.l();
}
}
a.stopPropagation();
}
w(a) {
let b = ElevationHelper.e(12, BrushUtil.h(66, 0, 0, 0), BrushUtil.h(30, 0, 0, 0), BrushUtil.h(20, 0, 0, 0), 1);
a.setStyleProperty("boxShadow", b);
a.setStyleProperty("background-color", this.a.bf._fill);
a.setStyleProperty("position", "absolute");
a.setStyleProperty("z-index", "12000");
a.setStyleProperty("display", "none");
}
ac() {
if (this.j != null) {
this.j.setStyleProperty("background-color", this.a.bf._fill);
}
if (this.e != null) {
this.e.setStyleProperty("background-color", this.a.bf._fill);
}
}
t() {
if (this.g != null) {
this.b.add(this.c.globalListen("document", "keydown", runOn(this, this.q)));
this.b.add(this.c.globalListen("document", "click", runOn(this, this.r)));
this.g.show();
this.g.listen("click", runOn(this, this.m));
}
}
l() {
if (this.g != null) {
for (let a = 0; a < this.b.count; a++) {
this.b._inner[a]();
}
this.b.clear();
this.g.unlistenAll();
this.g.hide();
this.g = null;
}
}
m(a) {
a.stopPropagation();
}
q(a) {
if (BaseDOMEventProxy.c0(a) == 8) {
this.a.av();
}
}
r(a) {
this.a.av();
}
o() {
}
}
DataGridToolbarView.$t = /*@__PURE__*/ markType(DataGridToolbarView, 'DataGridToolbarView');
return DataGridToolbarView;
})();
/**
* @hidden
*/
export let DataGridToolbar = /*@__PURE__*/ (() => {
class DataGridToolbar extends Base {
constructor() {
super();
this.c = null;
this.a = null;
this.b = null;
this.s = 0;
this.t = 0;
this.g = null;
this.h = null;
this.propertyChanged = null;
this.d = null;
this.y = null;
this.m = null;
this.bd = BrushUtil.h(255, 24, 29, 31);
this.bb = BrushUtil.h(255, 248, 248, 248);
this.bc = BrushUtil.h(255, 248, 248, 248);
this.o = false;
this.u = null;
this.v = null;
this.p = false;
this.w = null;
this.x = null;
this.bh = new Thickness(1, 1, 1, 1, 0);
this.k = 2;
this.i = 1;
this.s = 0;
this.t = 0;
let a = new DataGridToolbarView();
a.a = this;
this.c = a;
this.c.s();
}
notifySizeChanged() {
this.c.o();
}
destroy() {
this.provideContainer(null, null, null);
if (this.e != null) {
let a = this.e;
a.columnHiddenChanged = delegateRemove(a.columnHiddenChanged, runOn(this, this.a9));
let b = this.e;
b.columnPinnedChanged = delegateRemove(b.columnPinnedChanged, runOn(this, this.ba));
}
}
provideContainer(a, b, c) {
this.a = b;
this.b = c;
this.a6();
this.a7();
this.c.p(a);
}
get e() {
return this.d;
}
set e(a) {
let b = this.d;
this.d = a;
if (b != this.d) {
this.a0("TargetGrid", b, this.d);
}
}
get ar() {
return this.y;
}
set ar(a) {
let b = this.y;
this.y = a;
if (b != this.y) {
this.a0("ToolbarTitle", b, this.y);
}
}
get n() {
return this.m;
}
set n(a) {
let b = this.m;
this.m = a;
if (b != this.m) {
this.a0("ToolbarTitleStyle", b, this.m);
}
}
get bg() {
return this.bd;
}
set bg(a) {
let b = this.bd;
this.bd = a;
if (b != this.bd) {
this.a0("ToolbarTitleColor", b, this.bd);
}
}
get be() {
return this.bb;
}
set be(a) {
let b = this.bb;
this.bb = a;
if (b != this.bb) {
this.a0("BackgroundColor", b, this.bb);
}
}
get bf() {
return this.bc;
}
set bf(a) {
let b = this.bc;
this.bc = a;
if (b != this.bc) {
this.a0("DialogBackgroundColor", b, this.bc);
}
}
get q() {
return this.o;
}
set q(a) {
let b = this.o;
this.o = a;
if (b != this.o) {
this.a0("ColumnChooser", b, this.o);
}
}
get ad() {
return this.u;
}
set ad(a) {
let b = this.u;
this.u = a;
if (b != this.u) {
this.a0("ColumnChooserText", b, this.u);
}
}
get af() {
return this.v;
}
set af(a) {
let b = this.v;
this.v = a;
if (b != this.v) {
this.a0("ColumnChooserTitle", b, this.v);
}
}
get r() {
return this.p;
}
set r(a) {
let b = this.p;
this.p = a;
if (b != this.p) {
this.a0("ColumnPinning", b, this.p);
}
}
get ai() {
return this.w;
}
set ai(a) {
let b = this.w;
this.w = a;
if (b != this.w) {
this.a0("ColumnPinningText", b, this.w);
}
}
get ak() {
return this.x;
}
set ak(a) {
let b = this.x;
this.x = a;
if (b != this.x) {
this.a0("ColumnPinningTitle", b, this.x);
}
}
get bi() {
return this.bh;
}
set bi(a) {
let b = this.bh;
this.bh = a;
if (b != this.bh) {
this.a0("BorderWidth", b, this.bh);
}
}
get l() {
return this.k;
}
set l(a) {
let b = this.k;
this.k = a;
if (b != this.k) {
this.a0("Density", enumGetBox(ControlDisplayDensity_$type, b), enumGetBox(ControlDisplayDensity_$type, this.k));
}
}
get j() {
return this.i;
}
set j(a) {
let b = this.i;
this.i = a;
if (b != this.i) {
this.a0("BaseTheme", enumGetBox(BaseControlTheme_$type, b), enumGetBox(BaseControlTheme_$type, this.i));
}
}
a0(a, b, c) {
if (this.propertyChanged != null) {
this.propertyChanged(this, new PropertyChangedEventArgs(a));
}
this.a1(a, b, c);
}
a1(a, b, c) {
switch (a) {
case "TargetGrid":
this.a6();
this.a7();
this.a8(typeCast(DataGrid.$, b));
this.c.ad();
break;
case "ToolbarTitle":
this.c.y();
break;
case "ToolbarTitleStyle":
this.c.ai();
break;
case "ToolbarTitleColor":
this.c.ah();
break;
case "BackgroundColor":
this.c.z();
break;
case "DialogBackgroundColor":
this.c.ac();
if (this.a != null) {
this.a.aq = this.bf;
}
if (this.b != null) {
this.b.an = this.bf;
}
break;
case "ColumnChooser":
this.a6();
this.c.v();
break;
case "ColumnChooserText":
this.c.ab();
break;
case "ColumnChooserTitle":
if (this.a != null) {
this.a.v = this.af;
}
break;
case "ColumnPinning":
this.a7();
this.c.x();
break;
case "ColumnPinningText":
this.c.ag();
break;
case "ColumnPinningTitle":
if (this.b != null) {
this.b.v = this.ak;
}
break;
case "Density":
this.a3();
break;
case "BaseTheme":
this.a4();
break;
case "BorderWidth":
this.c.aa();
break;
}
}
az(a, b) {
switch (b.propertyName) {
case "IsToolbarColumnChooserVisible":
this.q = this.e.isToolbarColumnChooserVisible;
break;
case "IsToolbarColumnPinningVisible":
this.r = this.e.isToolbarColumnPinningVisible;
break;
case "ToolbarTitle":
this.ar = this.e.toolbarTitle;
break;
case "ToolbarColumnChooserText":
this.ad = this.e.toolbarColumnChooserText;
break;
case "ToolbarColumnChooserTitle":
this.af = this.e.toolbarColumnChooserTitle;
break;
case "ToolbarColumnPinningText":
this.ai = this.e.toolbarColumnPinningText;
break;
case "ToolbarColumnPinningTitle":
this.ak = this.e.toolbarColumnPinningTitle;
break;
}
}
a4() {
if (this.a != null) {
this.a.f = this.j;
}
if (this.b != null) {
this.b.f = this.j;
}
if (this.g != null) {
this.g.n = this.j;
}
if (this.h != null) {
this.h.n = this.j;
}
}
a3() {
if (this.l == 0) {
if (this.e != null) {
this.l = this.e.density;
}
}
if (this.g != null) {
this.g.r = this.l;
}
if (this.h != null) {
this.h.r = this.l;
}
if (this.a != null) {
this.a.h = this.l;
}
if (this.b != null) {
this.b.h = this.l;
}
this.c.ad();
}
a5(a, b, c, d, e) {
let f = new XButton();
let g = b.getSubRenderer(c);
f.provideContainer(g);
let h = g.getExternal(f, g.rootWrapper, g.getExternal(a, null, null));
f.n = this.j;
f.r = this.l;
let i = null;
let j = null;
let k = null;
switch (e) {
case "Hiding":
this.g = f;
i = DataGridToolbar.ao;
j = this.s.toString();
if (this.ad != null) {
k = this.ad;
}
break;
case "Pinning":
this.h = f;
i = DataGridToolbar.ap;
j = this.t.toString();
if (this.ai != null) {
k = this.ai;
}
break;
}
f.e = 2;
c.setStyleProperty("display", "inline-block");
c.setStyleProperty("margin-left", "10px");
d.setStyleProperty("display", "flex");
d.setStyleProperty("flexDirection", "row");
d.setStyleProperty("flexWrap", "no-wrap");
d.setStyleProperty("align-items", "center");
let l = b.createElement("div");
l.setStyleProperty("display", "inline-block");
l.setStyleProperty("margin-right", "5px");
let m = b.getSubRenderer(l);
let n = new XIcon();
n.provideContainer(m);
let o = m.getExternal(n, m.rootWrapper, m.getExternal(a, null, null));
n.svgPath = i;
d.append(l);
let p = b.createElement("span");
p.setStyleProperty("display", "inline-block");
p.setStyleProperty("font-size", "12px");
p.setStyleProperty("font-weight", "600");
p.setStyleProperty("margin-right", "5px");
p.setText(j);
d.append(p);
if (k != null) {
let q = b.createElement("span");
q.setStyleProperty("display", "inline-block");
q.setStyleProperty("font-size", "12px");
q.setStyleProperty("font-weight", "600");
q.setText(k);
d.append(q);
}
f.appendButtonContent(d);
}
av() {
this.c.l();
}
a6() {
if (this.q && this.a != null && this.e != null) {
if (this.af != null) {
this.a.v = this.af;
}
this.a.c = this.e;
this.a.f = this.j;
this.a.aq = this.bf;
this.a.an(new Thickness(1, -16, 3, -16, 3));
}
}
a7() {
if (this.r && this.b != null && this.e != null) {
if (this.ak != null) {
this.b.v = this.ak;
}
this.b.c = this.e;
this.b.f = this.j;
this.b.an = this.bf;
this.b.ak(new Thickness(1, -16, 3, -16, 3));
}
}
a8(a) {
if (a != null) {
a.columnHiddenChanged = delegateRemove(a.columnHiddenChanged, runOn(this, this.a9));
a.columnPinnedChanged = delegateRemove(a.columnPinnedChanged, runOn(this, this.ba));
a.propertyChanged = delegateRemove(a.propertyChanged, runOn(this, this.az));
}
if (this.e != null) {
let b = this.e;
b.columnHiddenChanged = delegateCombine(b.columnHiddenChanged, runOn(this, this.a9));
let c = this.e;
c.columnPinnedChanged = delegateCombine(c.columnPinnedChanged, runOn(this, this.ba));
let d = this.e;
d.propertyChanged = delegateCombine(d.propertyChanged, runOn(this, this.az));
this.ax();
if (this.e.toolbar != null) {
this.ar = this.e.toolbarTitle;
this.q = this.e.isToolbarColumnChooserVisible;
this.ad = this.e.toolbarColumnChooserText;
this.af = this.e.toolbarColumnChooserTitle;
this.r = this.e.isToolbarColumnPinningVisible;
this.ai = this.e.toolbarColumnPinningText;
this.ak = this.e.toolbarColumnPinningTitle;
}
}
}
ax() {
if (this.e != null) {
let a = this.e.actualColumns.count;
this.s = 0;
this.t = 0;
for (let b = 0; b < a; b++) {
if (this.e.actualColumns._inner[b].jp == true) {
this.s++;
}
if (this.e.actualColumns._inner[b].il == 1) {
this.t++;
}
}
}
this.c.ae();
this.c.af();
}
a9(a, b) {
this.ax();
}
ba(a, b) {
this.ax();
}
exportVisualModel() {
return this.f();
}
exportSerializedVisualModel() {
let a = this.f();
return a.serialize();
}
f() {
return new ToolbarVisualModelExport();
}
}
DataGridToolbar.$t = /*@__PURE__*/ markType(DataGridToolbar, 'DataGridToolbar', Base.$, [INotifyPropertyChanged_$type, IDataGridComponent_$type]);
DataGridToolbar.ao = "M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78l3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z";
DataGridToolbar.ap = "M13.2,3.8l7.1,7.1l-2.8-0.1l-3.4,3.4l0.1,4.2l-3.5-3.5l-5.4,5.4l-1.4,0l0-1.4l5.4-5.4L5.7,9.8l4.2,0.1l3.4-3.4L13.2,3.8z";
return DataGridToolbar;
})();