igniteui-react-grids
Version:
Ignite UI React grid components.
579 lines (578 loc) • 18.3 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 { 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
*/
var FilterCell = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(FilterCell, _super);
function FilterCell(a) {
var _this = _super.call(this, a) || this;
_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();
return _this;
}
FilterCell.prototype.cw = function (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;
}
};
FilterCell.prototype.d4 = function () {
this.c6.removeChildren();
};
FilterCell.prototype.dq = function () {
this.c6.append(this.cv.container);
};
FilterCell.prototype.dx = function () {
if (this.ah.getChildCount() == 0) {
this.ah.append(this.c7);
}
};
FilterCell.prototype.dv = function () {
if (this.ah.getChildCount() > 0) {
this.ah.removeChildren();
}
};
FilterCell.prototype.bs = function (a, b, c) {
_super.prototype.bs.call(this, a, b, c);
this.d3(a, b, c);
};
FilterCell.prototype.br = function () {
this.d1();
};
FilterCell.prototype.d5 = function (a, b, c, d) {
if (this.d != null) {
var e = this.c9.getNativeElement();
this.d.update("SelectorTop", (e.offsetTop));
this.d.update("SelectorLeft", (e.offsetLeft));
var f = this.c6.getNativeElement();
this.d.update("EditorTop", (f.offsetTop));
this.d.update("EditorLeft", (f.offsetLeft));
var g = this.c8.getNativeElement();
this.d.update("ClearIconTop", (g.offsetTop));
this.d.update("ClearIconLeft", (g.offsetLeft));
}
};
FilterCell.prototype.ds = function () {
var a = this.co;
a.valueChanged = delegateCombine(a.valueChanged, runOn(this, this.d2));
this.cz.svgPath = FilterCell.dc;
this.d7(false);
var b = this.cz;
b.clicked = delegateCombine(b.clicked, runOn(this, this.dr));
};
FilterCell.prototype.d1 = function () {
if (this.cv == null) {
this.dw();
}
};
FilterCell.prototype.cr = function () {
var 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) {
var 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;
};
FilterCell.prototype.d7 = function (a) {
if (this.cz != null) {
this.cz.disabled = !a;
this.cz.an = a ? 1 : 0.3;
}
};
FilterCell.prototype.dl = function (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);
}
};
FilterCell.prototype.dm = function () {
if (!this.c2) {
return;
}
if (this.b != null) {
this.b.clearFilter();
}
};
FilterCell.prototype.d3 = function (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;
}
};
FilterCell.prototype.dy = function () {
this.c2 = false;
if (this.cv != null) {
if (this.cl != null) {
if (typeCast(ColumnComparisonFilterCondition.$, this.cl) !== null) {
var a = typeCast(ColumnComparisonFilterCondition.$, this.cl);
this.co.b = a.operator;
var 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) {
var c = typeCast(ColumnCustomFilterCondition.$, this.cl);
this.co.ek(c.id, c.index);
var 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;
};
FilterCell.prototype.dt = function () {
this.co.d7();
for (var 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);
}
};
FilterCell.prototype.du = function () {
if (this.cm == 11) {
this.c4 = false;
}
this.cq = this.cr();
};
FilterCell.prototype.dz = function () {
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);
}
};
FilterCell.prototype.dw = function () {
if (this.cv != null) {
this.cv.detachEvents();
var 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;
var b = this.cv;
b.valueProvided = delegateCombine(b.valueProvided, runOn(this, this.d6));
this.dq();
}
this.dr(null, null);
};
FilterCell.prototype.d0 = function () {
if (this.c1 != null) {
if (this.cv != null) {
this.cv.setFont(this.c1);
}
}
};
FilterCell.prototype.d2 = function (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) {
var 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));
}
};
FilterCell.prototype.dr = function (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;
}
};
FilterCell.prototype.d6 = function (a, b, c) {
if (this.cq == 2) {
if (typeof b === 'string') {
var d_1;
if (((function () { var e = tryParseNumber(b, d_1); d_1 = e.p1; return e.ret; })())) {
b = d_1;
}
}
}
this.db = b;
};
FilterCell.prototype.d8 = function (a, b, c, d) {
this.d5(a, b, c, d);
};
FilterCell.prototype.cs = function (a, b) {
if (a != null) {
for (var 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;
};
FilterCell.prototype.dp = function () {
this.dx();
};
FilterCell.prototype.dn = function () {
this.dv();
};
Object.defineProperty(FilterCell.prototype, "cm", {
get: function () {
return this.co.d;
},
set: function (a) {
var b = this.co.d;
this.co.d = a;
if (b != a) {
this.bs("DataType", enumGetBox(DataSourceSchemaPropertyType_$type, b), enumGetBox(DataSourceSchemaPropertyType_$type, this.co.d));
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(FilterCell.prototype, "cq", {
get: function () {
return this.cp;
},
set: function (a) {
var b = this.cp;
this.cp = a;
if (b != a) {
this.bs("EditorType", enumGetBox(EditorType_$type, b), enumGetBox(EditorType_$type, this.cp));
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(FilterCell.prototype, "c4", {
get: function () {
return this.c3;
},
set: function (a) {
var b = this.c3;
this.c3 = a;
if (b != this.c3) {
this.bs("IsEditorEnabled", b, this.c3);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(FilterCell.prototype, "cu", {
get: function () {
return this.ct;
},
set: function (a) {
var b = this.ct;
this.ct = a;
if (this.ct != null) {
this.bs("FilterOperands", b, this.ct);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(FilterCell.prototype, "c1", {
get: function () {
return this.c0;
},
set: function (a) {
var b = this.c0;
this.c0 = a;
if (b != this.c0) {
this.bs("FontInfo", b, this.c0);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(FilterCell.prototype, "db", {
get: function () {
return this.da;
},
set: function (a) {
var b = this.da;
this.da = a;
if (b != this.da) {
this.bs("FilterValue", b, this.da);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(FilterCell.prototype, "cl", {
get: function () {
return this.ck;
},
set: function (a) {
var b = this.ck;
this.ck = a;
if (b != a) {
this.bs("Filter", b, this.ck);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(FilterCell.prototype, "ea", {
get: function () {
return this.d9;
},
set: function (a) {
var b = this.d9;
this.d9 = a;
if (b != this.d9) {
this.bs("TextColor", b, this.d9);
}
},
enumerable: false,
configurable: true
});
FilterCell.$t = 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;
}(GridCellBase));
export { FilterCell };