igniteui-react-grids
Version:
Ignite UI React grid components.
545 lines (544 loc) • 17.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 { GridCellBase } from "./GridCellBase";
import { ComparisonOperatorSelector } from "./ComparisonOperatorSelector";
import { XIcon } from "igniteui-react-inputs";
import { DataSourceSchemaPropertyType_$type } from "igniteui-react-core";
import { EditorType_$type } from "./EditorType";
import { Base, runOn, delegateCombine, typeCast, delegateRemove, enumGetBox, markType } from "igniteui-react-core";
import { TextEditorView } from "./TextEditorView";
import { NumericEditorView } from "./NumericEditorView";
import { DateEditorView } from "./DateEditorView";
import { ColumnComparisonConditionOperatorType_$type } from "./ColumnComparisonConditionOperatorType";
import { ColumnComparisonFilterCondition } from "./ColumnComparisonFilterCondition";
import { ColumnCustomFilterCondition } from "./ColumnCustomFilterCondition";
import { tryParseNumber } from "igniteui-react-core";
/**
* @hidden
*/
export let FilterCell = /*@__PURE__*/ (() => {
class FilterCell extends GridCellBase {
constructor(a) {
super(a);
this.c7 = null;
this.c9 = null;
this.c5 = null;
this.c6 = null;
this.c8 = null;
this.cy = null;
this.cx = null;
this.cn = null;
this.co = null;
this.cz = null;
this.cv = null;
this.c2 = true;
this.cp = 0;
this.c3 = true;
this.ct = null;
this.c0 = null;
this.da = null;
this.ck = null;
this.d9 = null;
this.c7 = a.createElement("div");
this.c7.setStyleProperty("display", "flex");
this.c7.setStyleProperty("flex-direction", "row");
this.c7.setStyleProperty("align-items", "center");
this.c7.setStyleProperty("height", "100%");
this.ah.append(this.c7);
this.c9 = a.createElement("div");
this.c5 = a.getSubRenderer(this.c9);
this.co = new ComparisonOperatorSelector();
this.co.ej(this.c5);
this.c9.setStyleProperty("width", "24px");
this.c9.setStyleProperty("height", "24px");
this.c7.append(this.c9);
this.c6 = a.createElement("div");
this.c6.setStyleProperty("display", "flex");
this.c6.setStyleProperty("flex", "1");
this.c6.setStyleProperty("margin", "0 4px");
this.c7.append(this.c6);
this.c8 = a.createElement("div");
this.c8.setStyleProperty("transform", "scale(0.75)");
this.cz = new XIcon();
this.cz.provideContainer(a.getSubRenderer(this.c8));
this.c7.append(this.c8);
this.ds();
}
cw(a) {
switch (this.cq) {
case 0:
case 1:
if (this.cy == null) {
this.cy = new TextEditorView(this.ae, this.f.getTheme(), this.b);
}
return this.cy;
case 2:
if (this.cx == null) {
this.cx = new NumericEditorView(this.ae, this.f.getTheme(), this.b);
}
return this.cx;
case 3:
if (this.cn == null) {
this.cn = new DateEditorView(this.ae, this.f.getTheme(), this.b);
}
return this.cn;
default: return null;
}
}
d4() {
this.c6.removeChildren();
}
dq() {
this.c6.append(this.cv.container);
}
dx() {
if (this.ah.getChildCount() == 0) {
this.ah.append(this.c7);
}
}
dv() {
if (this.ah.getChildCount() > 0) {
this.ah.removeChildren();
}
}
bs(a, b, c) {
super.bs(a, b, c);
this.d3(a, b, c);
}
br() {
this.d1();
}
d5(a, b, c, d) {
if (this.d != null) {
let e = this.c9.getNativeElement();
this.d.update("SelectorTop", (e.offsetTop));
this.d.update("SelectorLeft", (e.offsetLeft));
let f = this.c6.getNativeElement();
this.d.update("EditorTop", (f.offsetTop));
this.d.update("EditorLeft", (f.offsetLeft));
let g = this.c8.getNativeElement();
this.d.update("ClearIconTop", (g.offsetTop));
this.d.update("ClearIconLeft", (g.offsetLeft));
}
}
ds() {
let a = this.co;
a.valueChanged = delegateCombine(a.valueChanged, runOn(this, this.d2));
this.cz.svgPath = FilterCell.dc;
this.d7(false);
let b = this.cz;
b.clicked = delegateCombine(b.clicked, runOn(this, this.dr));
}
d1() {
if (this.cv == null) {
this.dw();
}
}
cr() {
let a = 1;
switch (this.cm) {
case 11:
case 2:
case 0:
a = 1;
break;
case 8:
a = 3;
break;
case 10:
case 6:
case 5:
case 1:
case 3:
case 4:
case 7:
a = 2;
break;
}
switch (this.co.b) {
case 6:
case 8:
case 7:
case 9:
a = 2;
break;
case 38:
a = 1;
break;
case 39:
a = 2;
break;
}
if (this.co.b == 44) {
if (this.cu != null && this.cu.count > 0) {
let b = this.cu._inner[this.co.x];
switch (b.b) {
case 0:
case 1:
a = 1;
break;
case 2:
a = 2;
break;
case 3:
a = 3;
break;
}
}
}
return a;
}
d7(a) {
if (this.cz != null) {
this.cz.disabled = !a;
this.cz.an = a ? 1 : 0.3;
}
}
dl(a) {
if (!this.c2) {
return;
}
if (this.co.b == 44) {
if (this.cu != null && this.cu.count > 0) {
this.b.applyCustomFilter(this.co.ae, this.co.x, a);
}
}
else {
this.b.applyFilter(this.co.b, a);
}
}
dm() {
if (!this.c2) {
return;
}
if (this.b != null) {
this.b.clearFilter();
}
}
d3(a, b, c) {
switch (a) {
case "DataType":
this.du();
break;
case "EditorType":
this.dw();
break;
case "FontInfo":
this.d0();
break;
case "Filter":
this.dy();
break;
case "FilterOperands":
this.dt();
break;
case "FilterValue":
this.dz();
break;
case "IsEditorEnabled":
this.cv.isEnabled = this.c4;
break;
case "TextColor":
this.co.eq = this.ea;
this.cz.fill = this.ea;
this.cv.textColor = this.ea;
break;
}
}
dy() {
this.c2 = false;
if (this.cv != null) {
if (this.cl != null) {
if (typeCast(ColumnComparisonFilterCondition.$, this.cl) !== null) {
let a = typeCast(ColumnComparisonFilterCondition.$, this.cl);
this.co.b = a.operator;
let b = this.cv.getEditorValue();
if (b != null) {
if (!Base.equalsStatic(b, a.value)) {
this.cv.value = a.value;
this.db = a.value;
}
}
else {
this.cv.value = a.value;
this.db = a.value;
}
}
else if (typeCast(ColumnCustomFilterCondition.$, this.cl) !== null) {
let c = typeCast(ColumnCustomFilterCondition.$, this.cl);
this.co.ek(c.id, c.index);
let d = this.cv.getEditorValue();
if (d != null) {
if (!Base.equalsStatic(d, c.value)) {
this.cv.value = c.value;
this.db = c.value;
}
}
else {
this.cv.value = c.value;
this.db = c.value;
}
}
else if (!(typeCast(ColumnCustomFilterCondition.$, this.cl) !== null)) {
this.db = null;
this.cv.value = this.db;
this.cv.setEditorValue(this.db);
}
}
else {
this.db = null;
this.cv.value = this.db;
this.cv.setEditorValue(this.db);
if (!this.c4) {
this.co.b = 0;
}
}
}
this.c2 = true;
}
dt() {
this.co.d7();
for (let a = 0; a < this.cu.count; a++) {
this.co.d1(this.cu._inner[a].e, this.cu._inner[a].f, this.cu._inner[a].g, a);
}
}
du() {
if (this.cm == 11) {
this.c4 = false;
}
this.cq = this.cr();
}
dz() {
this.d7(this.db != null);
if (this.db == null || Base.equalsStatic(this.db, "")) {
this.dm();
}
else {
this.dl(this.db);
}
if (this.d != null) {
this.d.update("FilterValue", this.db);
}
}
dw() {
if (this.cv != null) {
this.cv.detachEvents();
let a = this.cv;
a.valueProvided = delegateRemove(a.valueProvided, runOn(this, this.d6));
}
this.d4();
this.cv = this.cw(this.cq);
this.cv.onEditStarted();
if (this.cv != null) {
this.cv.attachEvents();
this.cv.setFont(this.c1);
this.cv.isEnabled = this.c4;
this.cv.focusOnValueChanged = false;
this.cv.showClearButton = false;
let b = this.cv;
b.valueProvided = delegateCombine(b.valueProvided, runOn(this, this.d6));
this.dq();
}
this.dr(null, null);
}
d0() {
if (this.c1 != null) {
if (this.cv != null) {
this.cv.setFont(this.c1);
}
}
}
d2(a, b) {
this.cq = this.cr();
switch (b.newValue) {
case 40:
case 11:
case 43:
case 42:
case 26:
case 29:
case 23:
case 32:
case 24:
case 27:
case 21:
case 30:
case 25:
case 28:
case 22:
case 31:
case 41:
case 34:
case 35:
case 36:
case 37:
case 18:
case 19:
case 10:
case 33:
case 20:
this.c4 = false;
break;
default:
this.c4 = true;
break;
}
if (this.cm == 11) {
this.c4 = false;
}
if (b.newValue == 44) {
if (this.cu != null && this.cu.count > 0) {
let c = this.cu._inner[this.co.x];
this.c4 = c.d;
}
}
if (!this.c4) {
this.dl(null);
this.d7(true);
}
else if (this.db != null && !Base.equalsStatic(this.db, "")) {
this.dl(this.db);
}
else {
this.dm();
this.d7(false);
}
if (this.d != null) {
this.d.update("OperatorType", enumGetBox(ColumnComparisonConditionOperatorType_$type, this.co.b));
}
}
dr(a, b) {
if (b != null) {
if (!this.c4) {
this.co.b = 0;
this.dm();
}
}
this.db = null;
if (this.cv != null) {
this.cv.setEditorValue(null);
this.cv.value = null;
}
}
d6(a, b, c) {
if (this.cq == 2) {
if (typeof b === 'string') {
let d;
if (((() => { let e = tryParseNumber(b, d); d = e.p1; return e.ret; })())) {
b = d;
}
}
}
this.db = b;
}
d8(a, b, c, d) {
this.d5(a, b, c, d);
}
cs(a, b) {
if (a != null) {
for (let c = 0; c < this.cu.count; c++) {
if (this.cu._inner[c].g == a) {
return this.cu._inner[c];
}
}
}
if (b >= 0 && b < this.cu.count) {
return this.cu._inner[b];
}
return null;
}
dp() {
this.dx();
}
dn() {
this.dv();
}
get cm() {
return this.co.d;
}
set cm(a) {
let b = this.co.d;
this.co.d = a;
if (b != a) {
this.bs("DataType", enumGetBox(DataSourceSchemaPropertyType_$type, b), enumGetBox(DataSourceSchemaPropertyType_$type, this.co.d));
}
}
get cq() {
return this.cp;
}
set cq(a) {
let b = this.cp;
this.cp = a;
if (b != a) {
this.bs("EditorType", enumGetBox(EditorType_$type, b), enumGetBox(EditorType_$type, this.cp));
}
}
get c4() {
return this.c3;
}
set c4(a) {
let b = this.c3;
this.c3 = a;
if (b != this.c3) {
this.bs("IsEditorEnabled", b, this.c3);
}
}
get cu() {
return this.ct;
}
set cu(a) {
let b = this.ct;
this.ct = a;
if (this.ct != null) {
this.bs("FilterOperands", b, this.ct);
}
}
get c1() {
return this.c0;
}
set c1(a) {
let b = this.c0;
this.c0 = a;
if (b != this.c0) {
this.bs("FontInfo", b, this.c0);
}
}
get db() {
return this.da;
}
set db(a) {
let b = this.da;
this.da = a;
if (b != this.da) {
this.bs("FilterValue", b, this.da);
}
}
get cl() {
return this.ck;
}
set cl(a) {
let b = this.ck;
this.ck = a;
if (b != a) {
this.bs("Filter", b, this.ck);
}
}
get ea() {
return this.d9;
}
set ea(a) {
let b = this.d9;
this.d9 = a;
if (b != this.d9) {
this.bs("TextColor", b, this.d9);
}
}
}
FilterCell.$t = /*@__PURE__*/ markType(FilterCell, 'FilterCell', GridCellBase.$);
FilterCell.dc = "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z";
return FilterCell;
})();