igniteui-react-grids
Version:
Ignite UI React grid components.
160 lines (159 loc) • 6.23 kB
JavaScript
import * as React from 'react';
import { ensureEnum, NamePatcher, isValidProp, getModifiedProps } from "igniteui-react-core";
import { ReactRenderer } from "igniteui-react-core";
import { DataGridStylingDefaults } from './DataGridStylingDefaults';
import { GridColumnFilterOptions } from './GridColumnFilterOptions';
import { IgrGridColumnOptionsSectionBase } from "./igr-grid-column-options-section-base";
import { IgrCheckboxList } from "./igr-checkbox-list";
import { ControlDisplayDensity_$type } from "igniteui-react-core";
export class IgrGridColumnFilterOptions extends IgrGridColumnOptionsSectionBase {
_getMainRef(ref) {
this._elRef = ref;
this.verifyReferences();
}
_getClearFiltersSectionRef(ref) {
this._clearFiltersSectionRef = ref;
this.verifyReferences();
}
_getFilterSectionRef(ref) {
this._filterSectionRef = ref;
this.verifyReferences();
}
_getFilterCheckboxListSectionRef(ref) {
this._filterCheckboxListSectionRef = ref;
this.verifyReferences();
}
_getFilterButtonsSectionRef(ref) {
this._filterButtonsSectionRef = ref;
this.verifyReferences();
}
verifyReferences() {
if (this._reactRenderer &&
this._elRef &&
this._clearFiltersSectionRef &&
this._filterSectionRef &&
this._filterCheckboxListSectionRef &&
this._filterButtonsSectionRef) {
var gridColumnFilterOptions = this.i;
var mainRef = this._reactRenderer.getWrapper(this._elRef);
gridColumnFilterOptions.provideMainDiv(mainRef);
var clearFiltersSectionWrapper = this._reactRenderer.getWrapper(this._clearFiltersSectionRef);
gridColumnFilterOptions.provideClearFiltersSection(clearFiltersSectionWrapper);
var filtersSectionWrapper = this._reactRenderer.getWrapper(this._filterSectionRef);
gridColumnFilterOptions.provideFilterSection(filtersSectionWrapper);
gridColumnFilterOptions.provideFilterCheckboxListSection(this._filterCheckboxListSectionRef.i);
var filterButtonsSectionWrapper = this._reactRenderer.getWrapper(this._filterButtonsSectionRef);
gridColumnFilterOptions.provideFilterButtonSection(filterButtonsSectionWrapper);
}
}
render() {
const divStyle = {
height: "195px"
};
return (React.createElement("div", { className: "ig-grid-column-filter-options igr-grid-column-filter-options", ref: this._getMainRef }, React.createElement("div", { ref: this._getClearFiltersSectionRef, key: "clearFiltersSection" }), React.createElement("div", { ref: this._getFilterSectionRef, key: "filtersSection" }), React.createElement("div", { style: divStyle }, React.createElement(IgrCheckboxList, { height: "100%", ref: this._getFilterCheckboxListSectionRef, key: "filterCheckboxListSection" })), React.createElement("div", { ref: this._getFilterButtonsSectionRef, key: "filterButtonsSection" })));
}
constructor(props) {
super(props);
this._reactRenderer = null;
if (this._styling) {
NamePatcher.ensureStylablePatched(Object.getPrototypeOf(this));
}
this._getMainRef = this._getMainRef.bind(this);
this._getClearFiltersSectionRef = this._getClearFiltersSectionRef.bind(this);
this._getFilterSectionRef = this._getFilterSectionRef.bind(this);
this._getFilterCheckboxListSectionRef = this._getFilterCheckboxListSectionRef.bind(this);
this._getFilterButtonsSectionRef = this._getFilterButtonsSectionRef.bind(this);
if (document) {
this._mainDiv = document.createElement("div");
this._mainDiv.style.display = "block";
this._mainDiv.style.width = "100%";
this._mainDiv.style.height = "100%";
}
var ren = new ReactRenderer(this._mainDiv, document, true, DataGridStylingDefaults);
this._reactRenderer = ren;
var gridColumnFilterOptions = this.i;
gridColumnFilterOptions.provideRenderer(ren);
if (props) {
this.initializeProperties();
}
}
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 GridColumnFilterOptions();
}
get i() {
return this._implementation;
}
get clearColumnFiltersCaption() {
return this.i.b7;
}
set clearColumnFiltersCaption(v) {
this.i.b7 = v;
}
get filterListPlaceholderText() {
return this.i.cc;
}
set filterListPlaceholderText(v) {
this.i.cc = v;
}
/**
* Gets or sets the display Density to use for the buttons in the component.
*/
get filterListDensity() {
return this.i.b2;
}
set filterListDensity(v) {
this.i.b2 = ensureEnum(ControlDisplayDensity_$type, v);
}
/**
* Gets the actual display filterListDensity to use for the component.
*/
get actualFilterListDensity() {
return this.i.b0;
}
set actualFilterListDensity(v) {
this.i.b0 = ensureEnum(ControlDisplayDensity_$type, v);
}
get textFilterCaption() {
return this.i.cg;
}
set textFilterCaption(v) {
this.i.cg = v;
}
onApply() {
this.i.bt();
}
}