UNPKG

igniteui-react-grids

Version:

Ignite UI React grid components.

161 lines (160 loc) 6.04 kB
import * as React from 'react'; import { NamePatcher, isValidProp, getModifiedProps } from "igniteui-react-core"; import { ReactRenderer } from "igniteui-react-core"; import { delegateCombine, delegateRemove } from "igniteui-react-core"; import { DataGridStylingDefaults } from './DataGridStylingDefaults'; import { GridColumnButtonOptions } from './GridColumnButtonOptions'; import { IgrGridColumnOptionsSectionBase } from "./igr-grid-column-options-section-base"; import { IgrApplyButtonClickEventArgs } from './igr-apply-button-click-event-args'; import { IgrCancelButtonClickEventArgs } from './igr-cancel-button-click-event-args'; export class IgrGridColumnButtonOptions extends IgrGridColumnOptionsSectionBase { _getMainRef(ref) { this._elRef = ref; this.verifyReferences(); } _getButtonsSectionRef(ref) { this._buttonsSectionRef = ref; this.verifyReferences(); } verifyReferences() { if (this._reactRenderer && this._elRef && this._buttonsSectionRef) { var gridColumnButtonOptions = this.i; var mainRef = this._reactRenderer.getWrapper(this._elRef); gridColumnButtonOptions.provideMainDiv(mainRef); var buttonsSectionWrapper = this._reactRenderer.getWrapper(this._buttonsSectionRef); gridColumnButtonOptions.provideButtonSection(buttonsSectionWrapper); } } render() { const divStyle = { height: "195px" }; return (React.createElement("div", { className: "ig-grid-column-button-options igr-grid-column-button-options", ref: this._getMainRef }, React.createElement("div", { ref: this._getButtonsSectionRef, key: "buttonsSection" }))); } constructor(props) { super(props); this._reactRenderer = null; this._applyButtonClick = null; this._applyButtonClick_wrapped = null; this._cancelButtonClick = null; this._cancelButtonClick_wrapped = null; if (this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(this)); } this._getMainRef = this._getMainRef.bind(this); this._getButtonsSectionRef = this._getButtonsSectionRef.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 gridColumnButtonOptions = this.i; gridColumnButtonOptions.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 GridColumnButtonOptions(); } get i() { return this._implementation; } get applyButtonCaption() { return this.i.bz; } set applyButtonCaption(v) { this.i.bz = v; } get cancelButtonCaption() { return this.i.b3; } set cancelButtonCaption(v) { this.i.b3 = v; } get applyButtonClick() { return this._applyButtonClick; } set applyButtonClick(ev) { if (this._applyButtonClick_wrapped !== null) { this.i.applyButtonClick = delegateRemove(this.i.applyButtonClick, this._applyButtonClick_wrapped); this._applyButtonClick_wrapped = null; this._applyButtonClick = null; } this._applyButtonClick = ev; this._applyButtonClick_wrapped = (o, e) => { let outerArgs = new IgrApplyButtonClickEventArgs(); outerArgs._provideImplementation(e); if (this.beforeApplyButtonClick) { this.beforeApplyButtonClick(this, outerArgs); } if (this._applyButtonClick) { this._applyButtonClick(this, outerArgs); } }; this.i.applyButtonClick = delegateCombine(this.i.applyButtonClick, this._applyButtonClick_wrapped); ; } get cancelButtonClick() { return this._cancelButtonClick; } set cancelButtonClick(ev) { if (this._cancelButtonClick_wrapped !== null) { this.i.cancelButtonClick = delegateRemove(this.i.cancelButtonClick, this._cancelButtonClick_wrapped); this._cancelButtonClick_wrapped = null; this._cancelButtonClick = null; } this._cancelButtonClick = ev; this._cancelButtonClick_wrapped = (o, e) => { let outerArgs = new IgrCancelButtonClickEventArgs(); outerArgs._provideImplementation(e); if (this.beforeCancelButtonClick) { this.beforeCancelButtonClick(this, outerArgs); } if (this._cancelButtonClick) { this._cancelButtonClick(this, outerArgs); } }; this.i.cancelButtonClick = delegateCombine(this.i.cancelButtonClick, this._cancelButtonClick_wrapped); ; } }