tandem-front-end
Version:
Visual editor for web components
48 lines • 2 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var ReactDOM = require("react-dom");
exports.portal = function (_a) {
var didMount = (_a === void 0 ? {} : _a).didMount;
return function (Base) {
return /** @class */ (function (_super) {
__extends(Portal, _super);
function Portal() {
return _super !== null && _super.apply(this, arguments) || this;
}
Portal.prototype.componentDidMount = function () {
var mount = (this._mount = document.createElement("div"));
document.body.appendChild(mount);
this.renderPortal();
if (didMount) {
didMount(this.props)(mount);
}
};
Portal.prototype.componentWillUnmount = function () {
ReactDOM.unmountComponentAtNode(this._mount);
this._mount.remove();
};
Portal.prototype.componentDidUpdate = function () {
this.renderPortal();
};
Portal.prototype.renderPortal = function () {
ReactDOM.render(React.createElement("div", { style: this.props.style }, this.props.children), this._mount);
};
Portal.prototype.render = function () {
return null;
};
return Portal;
}(React.Component));
};
};
//# sourceMappingURL=controller.js.map