UNPKG

@duoduo-oba/ng-devui

Version:

DevUI components based on Angular

125 lines (119 loc) 3.86 kB
import { Component, ApplicationRef, ViewChild, NgModule } from '@angular/core'; import { forEach } from 'lodash-es'; import { CommonModule } from '@angular/common'; /** * @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); 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: Component, args: [{ selector: 'd-portal', template: "\n <ng-template #templateRef>\n <ng-content></ng-content>\n </ng-template>" }] } ]; /** @nocollapse */ PortalComponent.ctorParameters = function () { return [ { type: ApplicationRef } ]; }; PortalComponent.propDecorators = { templateRef: [{ type: 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: NgModule, args: [{ imports: [ CommonModule, ], declarations: [ PortalComponent, ], exports: [ PortalComponent, ], },] } ]; return PortalModule; }()); /** * @fileoverview added by tsickle * Generated from: public-api.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * Generated from: ng-devui-portal.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ export { PortalComponent, PortalModule }; //# sourceMappingURL=ng-devui-portal.js.map