UNPKG

igniteui-react-core

Version:
57 lines (56 loc) 2.31 kB
import { __extends } from "tslib"; import * as React from 'react'; var IgrComponentRendererContainer = /** @class */ /*@__PURE__*/ (function (_super) { __extends(IgrComponentRendererContainer, _super); function IgrComponentRendererContainer(props) { var _this = _super.call(this, props) || this; _this.listeners = []; _this._currentRoot = null; _this.rootCreated = _this.rootCreated.bind(_this); _this.state = {}; return _this; } IgrComponentRendererContainer.prototype.createObject = function (t, container, context, portalChildren, nameContext) { var C = t; t = new C(); return t; }; IgrComponentRendererContainer.prototype.rootCreated = function (rootRef) { if (!rootRef) { return; } this._currentRoot = rootRef; for (var i = 0; i < this.listeners.length; i++) { this.listeners[i](rootRef); } this.listeners.length = 0; }; IgrComponentRendererContainer.prototype.replaceRootItem = function (t, deferAttach, continueActions) { var act = function (r) { continueActions(true); }; this.listeners.push(act); this.setState({ rootComponentType: t }); }; IgrComponentRendererContainer.prototype.clearContainer = function (continueActions) { var act = function (r) { continueActions(true); }; this.listeners.push(act); this.setState({ rootComponentType: null }); }; IgrComponentRendererContainer.prototype.getRootObject = function () { return this._currentRoot; }; IgrComponentRendererContainer.prototype.render = function () { if (this.state.rootComponentType) { var ele = React.createElement(this.state.rootComponentType, { ref: this.rootCreated, width: "100%", height: "100%" }); return React.createElement("div", { style: this.props.style ? this.props.style : { width: "100%", height: "100%" } }, ele); } else { return React.createElement("div", { style: this.props.style ? this.props.style : { width: "100%", height: "100%" } }); } }; return IgrComponentRendererContainer; }(React.Component)); export { IgrComponentRendererContainer };