UNPKG

@nebular/theme

Version:
63 lines 2.73 kB
/** * @license * Copyright Akveo. All Rights Reserved. * Licensed under the MIT License. See License.txt in the project root for license information. */ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { Component, ElementRef, ViewChild } from '@angular/core'; import { NbPortalOutletDirective } from '../cdk/overlay/mapping'; import { NbFocusTrapFactoryService } from '../cdk/a11y/focus-trap'; import { NbDialogConfig } from './dialog-config'; /** * Container component for each dialog. * All the dialogs will be attached to it. * // TODO add animations * */ let NbDialogContainerComponent = class NbDialogContainerComponent { constructor(config, elementRef, focusTrapFactory) { this.config = config; this.elementRef = elementRef; this.focusTrapFactory = focusTrapFactory; } ngOnInit() { if (this.config.autoFocus) { this.focusTrap = this.focusTrapFactory.create(this.elementRef.nativeElement); this.focusTrap.blurPreviouslyFocusedElement(); this.focusTrap.focusInitialElement(); } } ngOnDestroy() { if (this.config.autoFocus && this.focusTrap) { this.focusTrap.restoreFocus(); } } attachComponentPortal(portal) { return this.portalOutlet.attachComponentPortal(portal); } attachTemplatePortal(portal) { return this.portalOutlet.attachTemplatePortal(portal); } }; __decorate([ ViewChild(NbPortalOutletDirective, { static: true }), __metadata("design:type", NbPortalOutletDirective) ], NbDialogContainerComponent.prototype, "portalOutlet", void 0); NbDialogContainerComponent = __decorate([ Component({ selector: 'nb-dialog-container', template: '<ng-template nbPortalOutlet></ng-template>' }), __metadata("design:paramtypes", [NbDialogConfig, ElementRef, NbFocusTrapFactoryService]) ], NbDialogContainerComponent); export { NbDialogContainerComponent }; //# sourceMappingURL=dialog-container.js.map