/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import * as tslib_1 from "tslib";
import * as React from 'react';
var IgrTemplateView = /** @class */ (function (_super) {
    tslib_1.__extends(IgrTemplateView, _super);
    function IgrTemplateView(props) {
        return _super.call(this, props) || this;
    }
    IgrTemplateView.prototype.render = function () {
        if (!this.props.template) {
            return null;
        }
        var ele = React.createElement(this.props.template, { dataContext: this.props.dataContext });
        return ele;
    };
    return IgrTemplateView;
}(React.Component));
export { IgrTemplateView };
var IgrTemplateContainer = /** @class */ (function (_super) {
    tslib_1.__extends(IgrTemplateContainer, _super);
    function IgrTemplateContainer(props) {
        var _this = _super.call(this, props) || this;
        _this._template = null;
        _this._containerTemplate = null;
        _this._dataContext = null;
        if (props.owner) {
            _this._currentOwner = props.owner;
        }
        return _this;
    }
    IgrTemplateContainer.prototype.componentDidUpdate = function () {
        if (this.contentReady) {
            this.contentReady();
        }
    };
    IgrTemplateContainer.prototype.render = function () {
        if (!this._template) {
            return null;
        }
        var ele = React.createElement(IgrTemplateView, { dataContext: this._dataContext, template: this._template });
        if (this._containerTemplate !== null) {
        }
        else {
            if (this.props.omitContainer) {
                return (React.createElement(React.Fragment, null, ele));
            }
            else {
                return (React.createElement("div", { className: 'ui-template-container' }, ele));
            }
        }
        return ele;
    };
    Object.defineProperty(IgrTemplateContainer.prototype, "currentOwner", {
        get: function () {
            return this._currentOwner;
        },
        enumerable: true,
        configurable: true
    });
    IgrTemplateContainer.prototype.shouldComponentUpdate = function (nextProps, nextState) {
        if (nextProps.owner !== undefined) {
            this._currentOwner = nextProps.owner;
        }
        return true;
    };
    Object.defineProperty(IgrTemplateContainer.prototype, "template", {
        get: function () {
            return this._template;
        },
        set: function (value) {
            this._template = value;
            this.setState({ template: this._template });
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgrTemplateContainer.prototype, "containerTemplate", {
        get: function () {
            return this._containerTemplate;
        },
        set: function (value) {
            this._containerTemplate = value;
            this.setState({ containerTemplate: this._containerTemplate });
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgrTemplateContainer.prototype, "dataContext", {
        get: function () {
            return this._dataContext;
        },
        set: function (value) {
            if (this._dataContext == null && value == null) {
                return;
            }
            this._dataContext = value;
            this.setState({ dataContext: this._dataContext });
        },
        enumerable: true,
        configurable: true
    });
    return IgrTemplateContainer;
}(React.Component));
export { IgrTemplateContainer };
