UNPKG

@duoduo-oba/ng-devui

Version:

DevUI components based on Angular

117 lines (111 loc) 3.35 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 */ class PortalComponent { /** * @param {?} appRef */ constructor(appRef) { this.appRef = appRef; } /** * @return {?} */ addContent() { this.portalContainer = document.createElement('div'); this.viewRef = this.templateRef.createEmbeddedView(this); forEach(this.viewRef.rootNodes, (/** * @param {?} node * @return {?} */ (node) => { this.portalContainer.appendChild(node); })); this.appRef.attachView(this.viewRef); document.body.appendChild(this.portalContainer); } /** * @return {?} */ open() { this.close(); this.addContent(); } /** * @return {?} */ close() { 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: ` <ng-template #templateRef> <ng-content></ng-content> </ng-template>` }] } ]; /** @nocollapse */ PortalComponent.ctorParameters = () => [ { type: ApplicationRef } ]; PortalComponent.propDecorators = { templateRef: [{ type: ViewChild, args: ['templateRef', { static: true },] }] }; 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 */ class PortalModule { } PortalModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, ], declarations: [ PortalComponent, ], exports: [ PortalComponent, ], },] } ]; /** * @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