igniteui-react-grids
Version:
Ignite UI React grid components.
143 lines (142 loc) • 4.29 kB
JavaScript
import * as React from 'react';
import { ensureEnum, brushToString, stringToBrush, NamePatcher, isValidProp, getModifiedProps } from "igniteui-react-core";
import { ReactRenderer, PortalManager } from "igniteui-react-core";
import { DataGridStylingDefaults } from './DataGridStylingDefaults';
import { GridColumnSummaryOptions } from './GridColumnSummaryOptions';
import { IgrGridColumnOptionsSectionBase } from "./igr-grid-column-options-section-base";
import { ControlDisplayDensity_$type } from "igniteui-react-core";
export class IgrGridColumnSummaryOptions extends IgrGridColumnOptionsSectionBase {
_getMainRef(ref) {
this._elRef = ref;
}
render() {
let children = [];
if (this._portalManager)
this._portalManager.onRender(children);
let div = React.createElement("div", {
className: "ig-grid-column-summary-options igr-grid-column-summary-options",
ref: this._getMainRef,
children: children
});
return div;
}
constructor(props) {
super(props);
this._reactRenderer = null;
if (this._styling) {
NamePatcher.ensureStylablePatched(Object.getPrototypeOf(this));
}
this._getMainRef = this._getMainRef.bind(this);
if (document) {
this._mainDiv = document.createElement("div");
this._mainDiv.style.display = "block";
this._mainDiv.style.width = "100%";
this._mainDiv.style.height = "100%";
}
this._portalManager = new PortalManager("summarySubMenu", this.requestRender);
var ren = new ReactRenderer(this._mainDiv, document, true, DataGridStylingDefaults, this._portalManager);
this._reactRenderer = ren;
this.i.provideRenderer(ren);
if (props) {
this.initializeProperties();
}
}
requestRender() {
if (this._initialized)
this.setState({});
}
shouldComponentUpdate(nextProps, nextState) {
const mod = getModifiedProps(this.props, nextProps);
for (const p of Object.keys(mod)) {
if (isValidProp(this, p)) {
this[p] = mod[p];
}
}
return true;
}
initializeProperties() {
for (const p of Object.keys(this.props)) {
if (isValidProp(this, p)) {
this[p] = this.props[p];
}
}
}
// supports angular themes or custom properties set in CSS
updateStyle() {
this._styling(this._mainDiv, this);
}
destroy() {
this.i.destroy();
this._reactRenderer.destroy();
}
componentWillUnmount() {
}
componentDidMount() {
this._elRef.appendChild(this._mainDiv);
this.initializeContent();
}
initializeContent() {
this._styling(this._mainDiv, this);
this.updateStyle();
}
createImplementation() {
return new GridColumnSummaryOptions();
}
get i() {
return this._implementation;
}
/**
* Gets or sets the text inside the summary button.
*/
get summaryCaption() {
return this.i.cd;
}
set summaryCaption(v) {
this.i.cd = v;
}
/**
* Gets or sets the display density used for the summary list.
*/
get summaryListDensity() {
return this.i.b5;
}
set summaryListDensity(v) {
this.i.b5 = ensureEnum(ControlDisplayDensity_$type, v);
}
/**
* Gets the actual display density used for the summary list.
*/
get actualSummaryListDensity() {
return this.i.b3;
}
set actualSummaryListDensity(v) {
this.i.b3 = ensureEnum(ControlDisplayDensity_$type, v);
}
get activeCount() {
return this.i.b7;
}
set activeCount(v) {
this.i.b7 = +v;
}
get summaryListTextColor() {
return brushToString(this.i.cv);
}
set summaryListTextColor(v) {
this.i.cv = stringToBrush(v);
}
get summaryListBackground() {
return brushToString(this.i.cu);
}
set summaryListBackground(v) {
this.i.cu = stringToBrush(v);
}
onApply() {
this.i.bt();
}
onCancel() {
this.i.bu();
}
closeMenu() {
this.i.cj();
}
}