UNPKG

@duoduo-oba/ng-devui

Version:

DevUI components based on Angular

120 lines (114 loc) 4.42 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('lodash-es'), require('@angular/common')) : typeof define === 'function' && define.amd ? define('ng-devui/portal', ['exports', '@angular/core', 'lodash-es', '@angular/common'], factory) : (global = global || self, factory((global['ng-devui'] = global['ng-devui'] || {}, global['ng-devui'].portal = {}), global.ng.core, global.lodashEs, global.ng.common)); }(this, (function (exports, core, lodashEs, common) { 'use strict'; /** * @fileoverview added by tsickle * Generated from: portal.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var PortalComponent = /** @class */ (function () { function PortalComponent(appRef) { this.appRef = appRef; } /** * @return {?} */ PortalComponent.prototype.addContent = /** * @return {?} */ function () { var _this = this; this.portalContainer = document.createElement('div'); this.viewRef = this.templateRef.createEmbeddedView(this); lodashEs.forEach(this.viewRef.rootNodes, (/** * @param {?} node * @return {?} */ function (node) { _this.portalContainer.appendChild(node); })); this.appRef.attachView(this.viewRef); document.body.appendChild(this.portalContainer); }; /** * @return {?} */ PortalComponent.prototype.open = /** * @return {?} */ function () { this.close(); this.addContent(); }; /** * @return {?} */ PortalComponent.prototype.close = /** * @return {?} */ function () { if (this.viewRef && this.portalContainer) { document.body.removeChild(this.portalContainer); this.viewRef.destroy(); this.viewRef = null; this.portalContainer = null; } }; PortalComponent.decorators = [ { type: core.Component, args: [{ selector: 'd-portal', template: "\n <ng-template #templateRef>\n <ng-content></ng-content>\n </ng-template>" }] } ]; /** @nocollapse */ PortalComponent.ctorParameters = function () { return [ { type: core.ApplicationRef } ]; }; PortalComponent.propDecorators = { templateRef: [{ type: core.ViewChild, args: ['templateRef', { static: true },] }] }; return PortalComponent; }()); if (false) { /** @type {?} */ PortalComponent.prototype.viewRef; /** @type {?} */ PortalComponent.prototype.portalContainer; /** @type {?} */ PortalComponent.prototype.templateRef; /** * @type {?} * @private */ PortalComponent.prototype.appRef; } /** * @fileoverview added by tsickle * Generated from: portal.module.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var PortalModule = /** @class */ (function () { function PortalModule() { } PortalModule.decorators = [ { type: core.NgModule, args: [{ imports: [ common.CommonModule, ], declarations: [ PortalComponent, ], exports: [ PortalComponent, ], },] } ]; return PortalModule; }()); exports.PortalComponent = PortalComponent; exports.PortalModule = PortalModule; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=ng-devui-portal.umd.js.map