UNPKG

@ng-doc/ui-kit

Version:

<!-- PROJECT LOGO --> <br /> <div align="center"> <a href="https://github.com/ng-doc/ng-doc"> <img src="https://ng-doc.com/assets/images/ng-doc.svg?raw=true" alt="Logo" height="150px"> </a>

80 lines (76 loc) 3.75 kB
import { __decorate } from 'tslib'; import * as i0 from '@angular/core'; import { inject, Component, ChangeDetectionStrategy, Input, ViewChild, ContentChild } from '@angular/core'; import { Router, ActivatedRoute, RouterOutlet } from '@angular/router'; import { NgDocDialogService } from '@ng-doc/ui-kit/services/dialog'; import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy'; import { Subject, switchMap, NEVER, merge } from 'rxjs'; import { takeUntil, map, startWith } from 'rxjs/operators'; let DialogOutletComponent = class DialogOutletComponent { constructor() { this.router = inject(Router); this.route = inject(ActivatedRoute); this.dialogService = inject(NgDocDialogService); } ngAfterContentInit() { if (this.routerOutlet) { const dialogRef = new Subject(); dialogRef .pipe(switchMap((dialogRef) => dialogRef.beforeClose().pipe(takeUntil(this.routerOutlet?.deactivateEvents ?? NEVER))), untilDestroyed(this)) .subscribe(() => { const url = this.route.pathFromRoot .map((r) => r.snapshot.url) .filter((f) => !!f[0]) .map(([f]) => f.path) .join('/'); this.router.navigateByUrl(url); }); merge(this.routerOutlet.activateEvents.pipe(map(() => true)), this.routerOutlet.deactivateEvents.pipe(map(() => false))) .pipe(startWith(this.routerOutlet.isActivated), untilDestroyed(this)) .subscribe((activated) => { if (activated) { this.dialogRef = this.dialogService.open(this.outletContent, this.config); dialogRef.next(this.dialogRef); } else { this.dialogRef?.close(); } }); } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: DialogOutletComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.3", type: DialogOutletComponent, isStandalone: true, selector: "ng-doc-dialog-outlet", inputs: { config: "config" }, queries: [{ propertyName: "routerOutlet", first: true, predicate: RouterOutlet, descendants: true }], viewQueries: [{ propertyName: "outletContent", first: true, predicate: ["outletContent"], descendants: true, static: true }], ngImport: i0, template: ` <ng-template #outletContent> <ng-content></ng-content> </ng-template> `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); } }; DialogOutletComponent = __decorate([ UntilDestroy() ], DialogOutletComponent); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: DialogOutletComponent, decorators: [{ type: Component, args: [{ selector: 'ng-doc-dialog-outlet', standalone: true, template: ` <ng-template #outletContent> <ng-content></ng-content> </ng-template> `, changeDetection: ChangeDetectionStrategy.OnPush, }] }], propDecorators: { config: [{ type: Input }], outletContent: [{ type: ViewChild, args: ['outletContent', { static: true }] }], routerOutlet: [{ type: ContentChild, args: [RouterOutlet] }] } }); /** * Generated bundle index. Do not edit. */ export { DialogOutletComponent }; //# sourceMappingURL=ng-doc-ui-kit-components-dialog-outlet.mjs.map