igniteui-react-grids
Version:
Ignite UI React grid components.
466 lines (465 loc) • 15.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 { __extends, __values } from "tslib";
import { Base, markType, INotifyPropertyChanged_$type, PropertyChangedEventArgs, runOn, delegateRemove, delegateCombine, enumGetBox, fromEnum } from "igniteui-react-core";
import { SRProvider } from "igniteui-react-core";
import { BaseControlTheme_$type } from "igniteui-react-core";
import { ControlDisplayDensity_$type } from "igniteui-react-core";
import { BrushUtil } from "igniteui-react-core";
import { ObservableCollection$1 } from "igniteui-react-core";
import { ColumnChooserInfo } from "./ColumnChooserInfo";
import { stringIsNullOrWhiteSpace } from "igniteui-react-core";
/**
* @hidden
*/
var ColumnChooserView = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(ColumnChooserView, _super);
function ColumnChooserView() {
var _this = _super.call(this) || this;
_this.d = null;
_this.c = null;
_this.e = null;
_this.a = null;
_this.b = null;
return _this;
}
ColumnChooserView.prototype.h = function () {
};
ColumnChooserView.prototype.g = function (a) {
if (a == null) {
this.b = null;
return;
}
this.b = a;
this.e = this.b.rootWrapper.getChildAt(0);
this.e.setStyleProperty("margin", "4px 0px 4px 0px");
this.k();
this.j();
var b = Math.round(a.rootWrapper.width());
var c = Math.round(a.rootWrapper.height());
this.b.rootWrapper.setStyleProperty("position", "relative");
this.i();
};
ColumnChooserView.prototype.i = function () {
if (this.b != null) {
this.b.rootWrapper.setStyleProperty("background-color", this.a.aq._fill);
}
};
ColumnChooserView.prototype.j = function () {
if (this.b != null) {
var a = this.b.rootWrapper.getChildAt(1);
a.setStyleProperty("width", "100%");
if (this.a.v != null) {
a.setStyleProperty("height", "calc(100% - 25px");
}
else {
a.setStyleProperty("height", "calc(100% - 5px");
}
}
};
ColumnChooserView.prototype.k = function () {
if (this.e != null && this.a.v != null) {
this.e.setText(this.a.v);
this.e.setStyleProperty("font", "16px Verdana");
}
this.l();
this.m();
this.j();
};
ColumnChooserView.prototype.l = function () {
if (this.e != null && this.a.ar != null) {
this.e.setStyleProperty("color", this.a.ar._fill);
}
};
ColumnChooserView.prototype.m = function () {
if (this.e != null && this.a.j != null) {
this.e.setStyleProperty("font", this.a.j.fontString);
}
};
ColumnChooserView.prototype.f = function () {
};
ColumnChooserView.$t = markType(ColumnChooserView, 'ColumnChooserView');
return ColumnChooserView;
}(Base));
export { ColumnChooserView };
/**
* @hidden
*/
var ColumnChooser = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(ColumnChooser, _super);
function ColumnChooser() {
var _this = _super.call(this) || this;
_this.a = null;
_this.d = null;
_this.propertyChanged = null;
_this.m = false;
_this.k = null;
_this.b = null;
_this.o = null;
_this.i = null;
_this.ap = BrushUtil.h(255, 0, 153, 255);
_this.n = null;
_this.e = 1;
_this.g = 2;
_this.ao = BrushUtil.h(255, 248, 248, 248);
_this.m = false;
var a = new ColumnChooserView();
a.a = _this;
_this.a = a;
_this.a.h();
return _this;
}
ColumnChooser.prototype.notifySizeChanged = function () {
this.a.f();
};
ColumnChooser.prototype.destroy = function () {
if (this.d != null) {
var a = this.d;
a.checkedChanged = delegateRemove(a.checkedChanged, runOn(this, this.ac));
var b = this.d;
b.selectAllCheckboxChanged = delegateRemove(b.selectAllCheckboxChanged, runOn(this, this.ad));
}
this.provideContainer(null, null);
if (this.b != null) {
var c = this.b.actualColumns;
c.collectionChanged = delegateRemove(c.collectionChanged, runOn(this, this.z));
var d = this.b;
d.columnHiddenChanged = delegateRemove(d.columnHiddenChanged, runOn(this, this.am));
}
};
ColumnChooser.prototype.provideContainer = function (a, b) {
this.d = b;
if (this.d != null) {
var c = this.d;
c.checkedChanged = delegateCombine(c.checkedChanged, runOn(this, this.ac));
var d = this.d;
d.selectAllCheckboxChanged = delegateCombine(d.selectAllCheckboxChanged, runOn(this, this.ad));
}
this.aa();
this.a.g(a);
};
Object.defineProperty(ColumnChooser.prototype, "l", {
get: function () {
if (this.k == null) {
this.k = new SRProvider(this.a.b);
this.k.cb("DataGrid");
}
return this.k;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ColumnChooser.prototype, "c", {
get: function () {
return this.b;
},
set: function (a) {
var b = this.b;
this.b = a;
if (b != this.b) {
this.ag("TargetGrid", b, this.b);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(ColumnChooser.prototype, "v", {
get: function () {
return this.o;
},
set: function (a) {
var b = this.o;
this.o = a;
if (b != this.o) {
this.ag("Title", b, this.o);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(ColumnChooser.prototype, "j", {
get: function () {
return this.i;
},
set: function (a) {
var b = this.i;
this.i = a;
if (b != this.i) {
this.ag("TitleStyle", b, this.i);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(ColumnChooser.prototype, "ar", {
get: function () {
return this.ap;
},
set: function (a) {
var b = this.ap;
this.ap = a;
if (b != this.ap) {
this.ag("TitleColor", b, this.ap);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(ColumnChooser.prototype, "s", {
get: function () {
return this.n != null ? this.n : !stringIsNullOrWhiteSpace(this.l.b1("Filter_Columns_List")) ? this.l.b1("Filter_Columns_List") : "Filter columns list ...";
},
set: function (a) {
var b = this.n;
this.n = a;
if (b != this.n) {
this.ag("FilterPlaceholderText", b, this.n);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(ColumnChooser.prototype, "f", {
get: function () {
return this.e;
},
set: function (a) {
var b = this.e;
this.e = a;
if (b != this.e) {
this.ag("BaseTheme", enumGetBox(BaseControlTheme_$type, b), enumGetBox(BaseControlTheme_$type, this.e));
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(ColumnChooser.prototype, "h", {
get: function () {
return this.g;
},
set: function (a) {
var b = this.g;
this.g = a;
if (b != this.g) {
this.ag("Density", enumGetBox(ControlDisplayDensity_$type, b), enumGetBox(ControlDisplayDensity_$type, this.g));
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(ColumnChooser.prototype, "aq", {
get: function () {
return this.ao;
},
set: function (a) {
var b = this.ao;
this.ao = a;
if (b != this.ao) {
this.ag("BackgroundColor", b, this.ao);
}
},
enumerable: false,
configurable: true
});
ColumnChooser.prototype.ag = function (a, b, c) {
if (this.propertyChanged != null) {
this.propertyChanged(this, new PropertyChangedEventArgs(a));
}
this.ah(a, b, c);
};
ColumnChooser.prototype.ah = function (a, b, c) {
switch (a) {
case "TargetGrid":
if (b != null) {
var d = b.actualColumns;
d.collectionChanged = delegateRemove(d.collectionChanged, runOn(this, this.z));
var e = b;
e.columnHiddenChanged = delegateRemove(e.columnHiddenChanged, runOn(this, this.am));
}
if (this.b != null) {
var f = this.b.actualColumns;
f.collectionChanged = delegateCombine(f.collectionChanged, runOn(this, this.z));
var g = this.b;
g.columnHiddenChanged = delegateCombine(g.columnHiddenChanged, runOn(this, this.am));
}
this.aa();
break;
case "Title":
this.a.k();
break;
case "TitleStyle":
this.a.m();
break;
case "TitleColor":
this.a.l();
break;
case "FilterPlaceholderText":
if (this.d != null) {
this.d.b4 = this.s;
}
break;
case "BaseTheme":
this.ak();
break;
case "Density":
this.aj();
break;
case "BackgroundColor":
if (this.d != null) {
this.d.backgroundColor = this.aq;
}
this.a.i();
break;
}
};
ColumnChooser.prototype.ak = function () {
if (this.d != null) {
this.d.baseTheme = this.f;
}
};
ColumnChooser.prototype.aj = function () {
if (this.d != null) {
this.d.density = this.h;
}
};
ColumnChooser.prototype.am = function (a, b) {
if (this.m == false) {
this.aa();
}
this.m = false;
};
ColumnChooser.prototype.z = function (a, b) {
this.aa();
};
ColumnChooser.prototype.aa = function () {
var e_1, _a;
if (this.b != null && this.d != null) {
this.d.baseTheme = this.f;
this.d.density = this.h;
this.d.backgroundColor = this.aq;
var a = void 0;
var b = new ObservableCollection$1(ColumnChooserInfo.$, 0);
try {
for (var _b = __values(fromEnum(this.b.actualColumns)), _c = _b.next(); !_c.done; _c = _b.next()) {
var c = _c.value;
a = new ColumnChooserInfo();
var d = c.lo;
if (c.lv != null) {
d = c.lv;
}
a.columnName = d;
a.isNotHidden = !c.jo;
b.add(a);
}
}
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;
}
}
if (this.s != null) {
this.d.b4 = this.s;
}
this.d.itemsSource = b;
var e = "";
var f = "";
e = "columnName";
f = "isNotHidden";
this.d.selectedMemberPath = f;
this.d.dataMemberPath = e;
this.d.showSelectAll = true;
}
};
ColumnChooser.prototype.an = function (a) {
if (this.d != null) {
this.d.updateHrMargin(a);
}
};
ColumnChooser.prototype.al = function () {
var e_2, _a;
this.d.d3();
if (this.b != null) {
try {
for (var _b = __values(fromEnum(this.b.actualColumns)), _c = _b.next(); !_c.done; _c = _b.next()) {
var a = _c.value;
this.m = true;
a.jo = false;
}
}
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;
}
}
}
};
ColumnChooser.prototype.ae = function () {
var e_3, _a;
this.d.c5();
if (this.b != null) {
try {
for (var _b = __values(fromEnum(this.b.actualColumns)), _c = _b.next(); !_c.done; _c = _b.next()) {
var a = _c.value;
this.m = true;
a.jo = true;
}
}
catch (e_3_1) {
e_3 = { error: e_3_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_3)
throw e_3.error;
}
}
}
};
ColumnChooser.prototype.ad = function (a, b) {
this.m = true;
if (b.a) {
this.al();
}
else {
this.ae();
}
};
ColumnChooser.prototype.ac = function (a, b) {
this.m = true;
var c = this.d.f.actualDataSource.getItemAtIndex(b.c);
var d = this.b.actualColumns.count;
for (var e = 0; e < d; e++) {
if (this.b.actualColumns._inner[e].lo == c.columnName || this.b.actualColumns._inner[e].mf == c.columnName || this.b.actualColumns._inner[e].lv == c.columnName) {
this.b.actualColumns._inner[e].jo = !b.b;
this.b.actualColumns._inner[e].m0("Hidden");
}
}
};
ColumnChooser.$t = markType(ColumnChooser, 'ColumnChooser', Base.$, [INotifyPropertyChanged_$type]);
return ColumnChooser;
}(Base));
export { ColumnChooser };