igniteui-react-grids
Version:
Ignite UI React grid components.
381 lines (380 loc) • 13.2 kB
JavaScript
import { __extends, __values } from "tslib";
import * as React from 'react';
import { ensureEnum, brushToString, stringToBrush, initializePropertiesFromCss, NamePatcher, isValidProp, toSpinal, getModifiedProps } from "igniteui-react-core";
import { FontInfo } from "igniteui-react-core";
import { ReactRenderer } from "igniteui-react-core";
import { ColumnChooser } from './ColumnChooser';
import { IgrCheckboxList } from "./igr-checkbox-list";
import { IgrDataGrid } from "./igr-data-grid";
import { BaseControlTheme_$type } from "igniteui-react-core";
import { ControlDisplayDensity_$type } from "igniteui-react-core";
var IgrColumnChooser = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(IgrColumnChooser, _super);
function IgrColumnChooser(props) {
var _this = _super.call(this, props) || this;
_this._wrapper = null;
_this._implementation = null;
_this.__p = null;
_this._hasUserValues = new Set();
_this._stylingContainer = null;
_this._stylingParent = null;
_this._inStyling = false;
if (_this._styling) {
NamePatcher.ensureStylablePatched(Object.getPrototypeOf(_this));
}
_this._getMainRef = _this._getMainRef.bind(_this);
_this._getCheckboxListRef = _this._getCheckboxListRef.bind(_this);
/*this._getShowAllRef = this._getShowAllRef.bind(this);
this._getHideAllRef = this._getHideAllRef.bind(this);*/
_this._implementation = _this.createImplementation();
var columnChooser = _this.i;
_this._columnChooser = columnChooser;
columnChooser.notifySizeChanged();
if (props) {
_this.initializeProperties();
}
return _this;
}
Object.defineProperty(IgrColumnChooser.prototype, "height", {
get: function () {
return this._height;
},
set: function (value) {
this._height = value;
if (this._elRef) {
this._elRef.style.height = value;
this._columnChooser.notifySizeChanged();
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrColumnChooser.prototype, "width", {
get: function () {
return this._width;
},
set: function (value) {
this._width = value;
if (this._elRef) {
this._elRef.style.height = value;
this._columnChooser.notifySizeChanged();
}
},
enumerable: false,
configurable: true
});
IgrColumnChooser.prototype._getMainRef = function (ref) {
this._elRef = ref;
if (this._elRef != null && this._checkboxListRef != null) {
this._renderer = new ReactRenderer(this._elRef, document, false, null);
this._columnChooser.provideContainer(this._renderer, this._checkboxListRef.i);
}
};
IgrColumnChooser.prototype._getCheckboxListRef = function (ref) {
this._checkboxListRef = ref;
if (this._elRef != null && this._checkboxListRef != null) {
this._renderer = new ReactRenderer(this._elRef, document, false, null);
this._columnChooser.provideContainer(this._renderer, this._checkboxListRef.i);
}
};
IgrColumnChooser.prototype.render = function () {
var children = [];
var title = React.createElement("span", {
key: "titleSpan"
});
children.push(title);
var checkboxList = React.createElement(IgrCheckboxList, {
ref: this._getCheckboxListRef,
key: "checkboxList"
});
children.push(checkboxList);
var div = React.createElement("div", {
className: "ig-column-chooser igr-column-chooser",
ref: this._getMainRef,
children: children
});
return div;
};
IgrColumnChooser.prototype.shouldComponentUpdate = function (nextProps, nextState) {
var e_1, _a;
var mod = getModifiedProps(this.props, nextProps);
try {
for (var _b = __values(Object.keys(mod)), _c = _b.next(); !_c.done; _c = _b.next()) {
var p = _c.value;
if (isValidProp(this, p)) {
this[p] = mod[p];
}
}
}
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;
}
}
return true;
};
IgrColumnChooser.prototype.initializeProperties = function () {
var e_2, _a;
try {
for (var _b = __values(Object.keys(this.props)), _c = _b.next(); !_c.done; _c = _b.next()) {
var p = _c.value;
if (isValidProp(this, p)) {
this[p] = this.props[p];
}
}
}
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;
}
}
};
// supports angular themes or custom properties set in CSS
IgrColumnChooser.prototype.updateStyle = function () {
this._styling(this._elRef, this);
};
IgrColumnChooser.prototype.destroy = function () {
this._columnChooser.destroy();
if (this._renderer) {
this._renderer.destroy();
}
};
IgrColumnChooser.prototype.componentWillUnmount = function () {
};
IgrColumnChooser.prototype.componentDidMount = function () {
this._elRef.style.width = this._width ? this._width : "";
this._elRef.style.height = this._height ? this._height : "";
this._columnChooser.notifySizeChanged();
this.initializeContent();
};
IgrColumnChooser.prototype.initializeContent = function () {
this.updateStyle();
this.i.notifySizeChanged();
};
IgrColumnChooser.prototype.createImplementation = function () {
return new ColumnChooser();
};
Object.defineProperty(IgrColumnChooser.prototype, "i", {
get: function () {
return this._implementation;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrColumnChooser.prototype, "targetGrid", {
/**
* Gets or Sets the property name that contains the values.
*/
get: function () {
var r = this.i.c;
if (r == null) {
return null;
}
if (!r.externalObject) {
var e = new IgrDataGrid({});
if (r.$type) {
e._implementation = r;
}
else {
if (e.i.setNativeElement) {
e.i.setNativeElement(r);
}
}
r.externalObject = e;
}
return r.externalObject;
},
set: function (v) {
if (v != null && this._stylingContainer && v._styling)
v._styling(this._stylingContainer, this, this);
v == null ? this.i.c = null : this.i.c = v.i;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrColumnChooser.prototype, "title", {
/**
* Gets or Sets the property name that contains the values.
*/
get: function () {
return this.i.v;
},
set: function (v) {
this.i.v = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrColumnChooser.prototype, "titleStyle", {
/**
* Gets or Sets the property name that contains the values.
*/
get: function () {
if (this.i.j == null) {
return null;
}
return this.i.j.fontString;
},
set: function (v) {
var fi = new FontInfo();
fi.fontString = v;
this.i.j = fi;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrColumnChooser.prototype, "titleColor", {
/**
* Gets or Sets the property name that contains the values.
*/
get: function () {
return brushToString(this.i.ar);
},
set: function (v) {
this.i.ar = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrColumnChooser.prototype, "filterPlaceholderText", {
/**
* Gets or Sets the property name that contains the values.
*/
get: function () {
return this.i.s;
},
set: function (v) {
this.i.s = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrColumnChooser.prototype, "baseTheme", {
/**
* Gets or Sets the property name that contains the values.
*/
get: function () {
return this.i.f;
},
set: function (v) {
this.i.f = ensureEnum(BaseControlTheme_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrColumnChooser.prototype, "density", {
/**
* Gets or Sets the property name that contains the values.
*/
get: function () {
return this.i.h;
},
set: function (v) {
this.i.h = ensureEnum(ControlDisplayDensity_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrColumnChooser.prototype, "backgroundColor", {
/**
* Gets or Sets the property name that contains the values.
*/
get: function () {
return brushToString(this.i.aq);
},
set: function (v) {
this.i.aq = stringToBrush(v);
},
enumerable: false,
configurable: true
});
IgrColumnChooser.prototype.findByName = function (name) {
if (this.findEphemera) {
if (name && name.indexOf("@@e:") == 0) {
return this.findEphemera(name);
}
}
if (this.targetGrid && this.targetGrid.name && this.targetGrid.name == name) {
return this.targetGrid;
}
return null;
};
Object.defineProperty(IgrColumnChooser.prototype, "hasUserValues", {
get: function () {
return this._hasUserValues;
},
enumerable: false,
configurable: true
});
IgrColumnChooser.prototype.__m = function (propertyName) {
if (!this._inStyling) {
this._hasUserValues.add(propertyName);
}
};
IgrColumnChooser.prototype._styling = function (container, component, parent) {
if (this._inStyling) {
return;
}
this._inStyling = true;
this._stylingContainer = container;
this._stylingParent = component;
var genericPrefix = "";
var typeName = this.i.$type.name;
if (typeName.indexOf("Xam") === 0) {
typeName = typeName.substring(3);
}
genericPrefix = toSpinal("ColumnChooser");
var additionalPrefixes = [];
var prefix = toSpinal(typeName);
additionalPrefixes.push(prefix + "-");
var b = this.i.$type.baseType;
while (b && b.name != "Object" &&
b.name != "Base" &&
b.name != "Control" &&
b.Name != "DependencyObject" &&
b.Name != "FrameworkElement") {
typeName = b.name;
if (typeName.indexOf("Xam") === 0) {
typeName = typeName.substring(3);
}
var basePrefix = toSpinal(typeName);
additionalPrefixes.push(basePrefix + "-");
b = b.baseType;
}
if (parent) {
var parentTypeName = parent.i.$type.name;
if (parentTypeName.indexOf("Xam") === 0) {
parentTypeName = parentTypeName.substring(3);
}
var parentPrefix = toSpinal(parentTypeName);
additionalPrefixes.push(parentPrefix + "-" + genericPrefix + "-");
additionalPrefixes.push(parentPrefix + "-" + prefix + "-");
}
initializePropertiesFromCss(container, this, genericPrefix + "-", this.hasUserValues, false, additionalPrefixes);
if (this.targetGrid && this.targetGrid._styling) {
this.targetGrid._styling(container, component, this);
}
if (this._otherStyling) {
this._otherStyling(container, component, parent);
}
this._inStyling = false;
};
return IgrColumnChooser;
}(React.Component));
export { IgrColumnChooser };