import * as tslib_1 from "tslib";
import * as React from 'react';
var IgrComponentRendererContainer = /** @class */ (function (_super) {
    tslib_1.__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.rootCreated = function (rootRef) {
        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, 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 };
