igniteui-react-grids
Version:
Ignite UI React grid components.
561 lines (560 loc) • 19.2 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, __values } from "tslib";
import { GridColumnOptionsViewBase } from "./GridColumnOptionsViewBase";
import { ControlDisplayDensity_$type } from "igniteui-react-core";
import { GridColumnOptionsUtilities } from "./GridColumnOptionsUtilities";
import { EventArgs, runOn, delegateCombine, markType, enumGetBox, fromEnum, toNullable, typeCast } from "igniteui-react-core";
import { Size } from "igniteui-react-core";
import { GridColumnOptionsSectionBase } from "./GridColumnOptionsSectionBase";
import { StringComparer } from "igniteui-react-core";
import { ColumnComparisonConditionOperatorType_$type } from "./ColumnComparisonConditionOperatorType";
import { List$1 } from "igniteui-react-core";
import { ColumnComparisonFilterCondition } from "./ColumnComparisonFilterCondition";
import { PrimaryKeyValue } from "./PrimaryKeyValue";
import { ColumnFilterConditionGroup } from "./ColumnFilterConditionGroup";
import { SortDescription } from "igniteui-react-core";
import { Thickness } from "igniteui-react-core";
import { nullableEquals } from "igniteui-react-core";
/**
* @hidden
*/
var GridColumnFilterOptionsView = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(GridColumnFilterOptionsView, _super);
function GridColumnFilterOptionsView() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.y = null;
_this.z = null;
_this.u = null;
_this.x = null;
_this.aa = null;
_this.t = null;
_this.v = null;
_this.w = null;
_this.q = null;
_this.o = null;
_this.p = null;
_this.applyButtonClick = null;
_this.cancelButtonClick = null;
return _this;
}
GridColumnFilterOptionsView.prototype.m = function () {
_super.prototype.m.call(this);
var a = this.n;
a.bh(this.q);
a.bh(this.o);
a.bh(this.p);
if (null != this.w && null != this.x) {
this.w.setStyleProperty("padding-bottom", "5px");
this.w.setStyleProperty("margin", "0 -8px");
switch (this.q.q) {
case 2:
this.x.setStyleProperty("margin", "0 -.25rem");
break;
case 1:
case 4:
case 3:
this.x.setStyleProperty("margin", "0 -.5rem");
break;
}
this.x.setRawText(a.b7);
this.x.setStyleProperty("font", a.aa.fontString);
}
if (null != this.aa) {
this.aa.setRawText(a.cg);
this.aa.setStyleProperty("font", a.aa.fontString);
GridColumnOptionsUtilities.j(this.aa, false);
}
};
Object.defineProperty(GridColumnFilterOptionsView.prototype, "n", {
get: function () {
return this.b;
},
enumerable: false,
configurable: true
});
GridColumnFilterOptionsView.prototype.al = function (a) {
if (this.o != null) {
this.o.disabled = !a;
}
};
GridColumnFilterOptionsView.prototype.am = function (a) {
if (null != this.q) {
this.q.disabled = !a;
}
};
GridColumnFilterOptionsView.prototype.ah = function (a) {
var _this = this;
var b = this.e;
var c = this.n;
this.y = a;
var d;
var e;
this.w = ((function () { var f = GridColumnOptionsUtilities.f(_this.n, b, GridColumnFilterOptionsView.ab, 1, c.p, c.j, new Size(1, 24, 24), _this.q, d, _this.x, e, false, true); _this.q = f.p7; d = f.p8; _this.x = f.p9; e = f.p10; return f.ret; })());
var f = this.q;
f.clicked = delegateCombine(f.clicked, runOn(this, this.ae));
this.y.append(this.w);
};
GridColumnFilterOptionsView.prototype.aj = function (a) {
var b = this.e;
this.z = a;
this.aa = b.createElement("span");
this.aa.setRawText(this.n.cg);
this.z.append(this.aa);
};
GridColumnFilterOptionsView.prototype.ai = function (a) {
};
GridColumnFilterOptionsView.prototype.ak = function (a) {
this.h(a);
};
GridColumnFilterOptionsView.prototype.af = function () {
if (null != this.applyButtonClick) {
this.applyButtonClick(this, EventArgs.empty);
}
};
GridColumnFilterOptionsView.prototype.ag = function () {
if (null != this.cancelButtonClick) {
this.cancelButtonClick(this, EventArgs.empty);
}
};
GridColumnFilterOptionsView.prototype.ac = function (a, b) {
this.af();
};
GridColumnFilterOptionsView.prototype.ad = function (a, b) {
this.ag();
};
GridColumnFilterOptionsView.prototype.ae = function (a, b) {
this.n.cl();
};
GridColumnFilterOptionsView.$t = markType(GridColumnFilterOptionsView, 'GridColumnFilterOptionsView', GridColumnOptionsViewBase.$);
GridColumnFilterOptionsView.ab = "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 GridColumnFilterOptionsView;
}(GridColumnOptionsViewBase));
export { GridColumnFilterOptionsView };
/**
* @hidden
*/
var GridColumnFilterOptions = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(GridColumnFilterOptions, _super);
function GridColumnFilterOptions() {
var _this = _super.call(this) || this;
_this.bx = null;
_this.b6 = "Clear column filters";
_this.cb = "Search";
_this.bz = 0;
_this.by = 0;
_this.cf = "Text filter";
return _this;
}
GridColumnFilterOptions.prototype.f = function () {
return new GridColumnFilterOptionsView();
};
GridColumnFilterOptions.prototype.bs = function () {
if (null == this.column) {
return false;
}
if (this.c != null && this.c.filterUIType != 0) {
return false;
}
if (!this.column.jm) {
return false;
}
if (this.c == null || this.c.actualDataSource == null || !this.c.actualDataSource.isGroupingSupported || !this.c.actualDataSource.isFilteringSupported) {
return false;
}
if (this.c.isPagerVisible && this.c.pager != null) {
var a = this.c.pager.actualDataSource;
if (a == null || !a.isGroupingSupported || !a.isFilteringSupported) {
return false;
}
}
return true;
};
GridColumnFilterOptions.prototype.a6 = function () {
_super.prototype.a6.call(this);
this.co();
this.cu();
};
GridColumnFilterOptions.prototype.a7 = function (a, b) {
_super.prototype.a7.call(this, a, b);
switch (b.propertyName) {
case "Filter":
this.cu();
break;
}
};
GridColumnFilterOptions.prototype.onViewInitialized = function () {
_super.prototype.onViewInitialized.call(this);
};
GridColumnFilterOptions.prototype.be = function (a, b, c) {
_super.prototype.be.call(this, a, b, c);
switch (a) {
case "ClearColumnFiltersCaption":
case "TextFilterCaption":
this.bw.m();
break;
case "ActualBaseTheme":
case "ActualDensity":
case "ActualFilterListDensity":
case "FilterListPlaceholderText":
case "BackgroundColor":
case "TextColor":
this.cw();
break;
case "FilterListDensity":
this.b0 = this.b2 == 0 ? this.q : this.b2;
break;
}
};
GridColumnFilterOptions.prototype.bt = function () {
this.cj();
};
Object.defineProperty(GridColumnFilterOptions.prototype, "bw", {
get: function () {
return this.e;
},
enumerable: false,
configurable: true
});
Object.defineProperty(GridColumnFilterOptions.prototype, "b7", {
get: function () {
return this.b6;
},
set: function (a) {
if (0 == StringComparer.b.compare(a, this.b6)) {
return;
}
var b = this.b6;
this.b6 = a;
this.bc("ClearColumnFiltersCaption", b, this.b6);
},
enumerable: false,
configurable: true
});
Object.defineProperty(GridColumnFilterOptions.prototype, "cc", {
get: function () {
return this.cb;
},
set: function (a) {
if (0 == StringComparer.b.compare(a, this.cb)) {
return;
}
var b = this.cb;
this.cb = a;
this.bc("FilterListPlaceholderText", b, this.cb);
},
enumerable: false,
configurable: true
});
Object.defineProperty(GridColumnFilterOptions.prototype, "b2", {
get: function () {
return this.bz;
},
set: function (a) {
var b = this.bz;
this.bz = a;
if (b != this.bz) {
this.bc("FilterListDensity", enumGetBox(ControlDisplayDensity_$type, b), enumGetBox(ControlDisplayDensity_$type, a));
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(GridColumnFilterOptions.prototype, "b0", {
get: function () {
return this.by;
},
set: function (a) {
var b = this.by;
this.by = a;
if (b != this.by) {
this.bc("ActualFilterListDensity", enumGetBox(ControlDisplayDensity_$type, b), enumGetBox(ControlDisplayDensity_$type, a));
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(GridColumnFilterOptions.prototype, "cg", {
get: function () {
return this.cf;
},
set: function (a) {
if (0 == StringComparer.b.compare(a, this.cf)) {
return;
}
var b = this.cf;
this.cf = a;
this.bc("TextFilterCaption", b, this.cf);
},
enumerable: false,
configurable: true
});
GridColumnFilterOptions.prototype.cu = function () {
var a = this.bx.ax();
this.bw.al(!a);
var b = this.b3();
this.bw.am(b);
};
GridColumnFilterOptions.prototype.cj = function () {
var e_1, _a;
if (0 == this.bx.keys.count) {
this.cl();
return;
}
var a;
var b;
if (this.bx.indexType == 0) {
b = false;
a = 1;
}
else {
b = true;
a = 0;
}
var c = new List$1(ColumnComparisonFilterCondition.$, 0);
var d = this.bx.keys;
for (var e = 0; e < d.count; e++) {
var f = d._inner[e];
var g = f.value[0];
var h = GridColumnFilterOptions.bv(a, g);
c.add(h);
}
if (c.count == 1) {
this.column.g1 = c._inner[0];
}
else {
var i = new ColumnFilterConditionGroup();
i.usesOrOperator = b;
try {
for (var _b = __values(fromEnum(c)), _c = _b.next(); !_c.done; _c = _b.next()) {
var j = _c.value;
i.add(j);
}
}
catch (e_1_1) {
e_1 = { error: e_1_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_1)
throw e_1.error;
}
}
this.column.g1 = i;
}
this.column.m0("Filtered");
};
GridColumnFilterOptions.prototype.provideClearFiltersSection = function (a) {
this.bw.ah(a);
};
GridColumnFilterOptions.prototype.provideFilterSection = function (a) {
this.bw.aj(a);
};
GridColumnFilterOptions.prototype.provideFilterCheckboxListSection = function (a) {
this.bx = a;
this.cw();
var b = this.bx;
b.selectAllCheckboxChanged = delegateCombine(b.selectAllCheckboxChanged, runOn(this, this.ck));
var c = this.bx;
c.checkedChanged = delegateCombine(c.checkedChanged, runOn(this, this.cn));
};
GridColumnFilterOptions.prototype.provideFilterButtonSection = function (a) {
this.bw.ai(a);
};
GridColumnFilterOptions.prototype.provideMainDiv = function (a) {
this.bw.ak(a);
};
GridColumnFilterOptions.prototype.cl = function () {
this.column.g1 = null;
this.cv();
};
GridColumnFilterOptions.bv = function (a, b) {
var c = new ColumnComparisonFilterCondition();
c.operator = a;
c.value = b;
return c;
};
GridColumnFilterOptions.prototype.b3 = function () {
var a = this.column;
if (null == a) {
return false;
}
return null != a.g1;
};
GridColumnFilterOptions.prototype.co = function () {
var a = this.column;
var b = this.c;
var c = (null != a) ? a.lo : null;
var d = null;
var e = null;
if (b != null) {
if (b.isPagerVisible && b.pager != null && b.pager.actualDataSource != null) {
d = b.pager.actualDataSource;
e = b.pager.actualDataSource.clone();
}
else {
d = b.actualDataSource;
e = b.actualDataSource.clone();
}
}
if (null != e) {
this.cx(d, e);
e.summaryDescriptions.clear();
e.sortDescriptions.clear();
e.groupDescriptions.clear();
var f = new SortDescription();
f.propertyName = c;
f.direction = 0;
e.groupDescriptions.add(f);
var g = b.z(a);
var h = e.filterExpressions;
for (var i = h.k.count - 1; i >= 0; i--) {
var j = h.k.item(i);
if (j.isAutoGenerated) {
if (null != g) {
h.k.item(i, g);
}
else {
e.filterExpressions.removeAt(i);
}
break;
}
}
this.bx.itemsSource = e;
this.bx.dataMemberPath = c;
this.bx.primaryKey = [c];
e.shouldEmitSectionHeaders = true;
e.isSectionHeaderNormalRow = true;
e.isSectionExpandedDefault = false;
e.isSectionCollapsable = true;
e.isSectionContentVisible = false;
this.cv();
}
};
GridColumnFilterOptions.prototype.cx = function (a, b) {
if (a != null && a.actualSchema != null && b != null && b.actualSchema != null) {
var c = b.actualSchema.propertyTypes;
var d = a.actualSchema.propertyTypes;
for (var e = 0; e < c.length; e++) {
if (c[e] != d[e]) {
c[e] = d[e];
}
}
}
};
GridColumnFilterOptions.prototype.cv = function () {
var e_2, _a;
var a = this.column;
var b = (null != a) ? a.lo : null;
var c = true;
var d = toNullable(ColumnComparisonConditionOperatorType_$type, null);
var e = this.b4();
for (var f = e.count - 1; f >= 0; f--) {
var g = e._inner[f];
switch (g.operator) {
case 0:
case 1: break;
default:
e.removeAt(f);
continue;
}
if (nullableEquals(d, null)) {
d = toNullable(ColumnComparisonConditionOperatorType_$type, g.operator);
}
else if (d.value != g.operator) {
c = false;
break;
}
}
if (e.count == 0 || !c) {
this.bx.d3();
return;
}
switch (d.value) {
case 0:
this.bx.c5();
break;
case 1:
this.bx.d3();
break;
}
var h = this.bx.keys;
try {
for (var _b = __values(fromEnum(e)), _c = _b.next(); !_c.done; _c = _b.next()) {
var i = _c.value;
h.add(new PrimaryKeyValue([b], [i.value]));
}
}
catch (e_2_1) {
e_2 = { error: e_2_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_2)
throw e_2.error;
}
}
this.cu();
};
GridColumnFilterOptions.prototype.b4 = function () {
var a = new List$1(ColumnComparisonFilterCondition.$, 0);
var b = this.column;
if (null == b) {
return a;
}
if (null != b.g1) {
var c = GridColumnFilterOptions.cm(b.g1, a);
a = c.p1;
}
return a;
};
GridColumnFilterOptions.cm = function (a, b) {
var c = typeCast(ColumnFilterConditionGroup.$, a);
if (null != c) {
for (var d = 0; d < c.count; d++) {
var e = c.item(d);
var f = GridColumnFilterOptions.cm(e, b);
b = f.p1;
}
}
else if (null != a) {
if (typeCast(ColumnComparisonFilterCondition.$, a) !== null) {
b.add(a);
}
}
return {
p1: b
};
};
GridColumnFilterOptions.prototype.cw = function () {
if (null != this.bx) {
this.bx.density = this.b0;
this.bx.b4 = this.cc;
this.bx.backgroundColor = this.bo;
this.bx.e7 = this.br;
this.bx.baseTheme = this.i;
this.bx.updateHrMargin(new Thickness(1, -7, 3, -7, 3));
}
};
GridColumnFilterOptions.prototype.ck = function (a, b) {
this.cu();
};
GridColumnFilterOptions.prototype.cn = function (a, b) {
this.cu();
};
GridColumnFilterOptions.$t = markType(GridColumnFilterOptions, 'GridColumnFilterOptions', GridColumnOptionsSectionBase.$);
return GridColumnFilterOptions;
}(GridColumnOptionsSectionBase));
export { GridColumnFilterOptions };