igniteui-react-grids
Version:
Ignite UI React grid components.
222 lines (221 loc) • 8.9 kB
JavaScript
import { __extends, __values } from "tslib";
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';
var IgrGridColumnButtonOptions = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(IgrGridColumnButtonOptions, _super);
function IgrGridColumnButtonOptions(props) {
var _this = _super.call(this, props) || this;
_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();
}
return _this;
}
IgrGridColumnButtonOptions.prototype._getMainRef = function (ref) {
this._elRef = ref;
this.verifyReferences();
};
IgrGridColumnButtonOptions.prototype._getButtonsSectionRef = function (ref) {
this._buttonsSectionRef = ref;
this.verifyReferences();
};
IgrGridColumnButtonOptions.prototype.verifyReferences = function () {
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);
}
};
IgrGridColumnButtonOptions.prototype.render = function () {
var 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" })));
};
IgrGridColumnButtonOptions.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;
};
IgrGridColumnButtonOptions.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
IgrGridColumnButtonOptions.prototype.updateStyle = function () {
this._styling(this._mainDiv, this);
};
IgrGridColumnButtonOptions.prototype.destroy = function () {
this.i.destroy();
this._reactRenderer.destroy();
};
IgrGridColumnButtonOptions.prototype.componentWillUnmount = function () {
};
IgrGridColumnButtonOptions.prototype.componentDidMount = function () {
this._elRef.appendChild(this._mainDiv);
this.initializeContent();
};
IgrGridColumnButtonOptions.prototype.initializeContent = function () {
this._styling(this._mainDiv, this);
this.updateStyle();
};
IgrGridColumnButtonOptions.prototype.createImplementation = function () {
return new GridColumnButtonOptions();
};
Object.defineProperty(IgrGridColumnButtonOptions.prototype, "i", {
get: function () {
return this._implementation;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridColumnButtonOptions.prototype, "applyButtonCaption", {
get: function () {
return this.i.bz;
},
set: function (v) {
this.i.bz = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridColumnButtonOptions.prototype, "cancelButtonCaption", {
get: function () {
return this.i.b3;
},
set: function (v) {
this.i.b3 = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridColumnButtonOptions.prototype, "applyButtonClick", {
get: function () {
return this._applyButtonClick;
},
set: function (ev) {
var _this = this;
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 = function (o, e) {
var 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);
;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrGridColumnButtonOptions.prototype, "cancelButtonClick", {
get: function () {
return this._cancelButtonClick;
},
set: function (ev) {
var _this = this;
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 = function (o, e) {
var 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);
;
},
enumerable: false,
configurable: true
});
return IgrGridColumnButtonOptions;
}(IgrGridColumnOptionsSectionBase));
export { IgrGridColumnButtonOptions };