UNPKG

@volo/abp.ng.lepton-x.core

Version:

This library was generated with [Nx](https://nx.dev).

218 lines (203 loc) 14.8 kB
import * as i0 from '@angular/core'; import { InjectionToken, inject, Injectable, provideAppInitializer, Input, Directive, Component, NgModule, Inject } from '@angular/core'; import * as i2 from '@angular/common'; import { DOCUMENT, CommonModule } from '@angular/common'; import * as i1$1 from '@abp/ng.theme.shared'; import { DocumentDirHandlerService, ThemeSharedModule, NavItemsService } from '@abp/ng.theme.shared'; import * as i1 from '@abp/ng.core'; import { CoreModule, PermissionService } from '@abp/ng.core'; import * as i2$1 from '@volo/ngx-lepton-x.core'; import { SafeHtmlPipe, ToolbarService } from '@volo/ngx-lepton-x.core'; import { PageParts, PAGE_RENDER_STRATEGY } from '@abp/ng.components/page'; import { map, switchMap } from 'rxjs/operators'; const MOBILE_NAVBAR_ITEMS_FILTER_TOKEN = new InjectionToken('MOBILE_NAVBAR_ITEMS_FILTER_TOKEN'); const MOBILE_NAVBAR_ITEMS_FILTER_PROVIDER = { provide: MOBILE_NAVBAR_ITEMS_FILTER_TOKEN, deps: [], useFactory: mobileMenuItemFilterFnFactory }; function mobileMenuItemFilterFnFactory() { return (route, index) => { return index === 0 || index === 1; }; } class DocumentDirService { constructor() { this.documentDirHandler = inject(DocumentDirHandlerService); this.document = inject(DOCUMENT); } listenDir() { this.documentDirHandler.dir$.subscribe((dir) => { this.document.documentElement.dir = dir; }); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: DocumentDirService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: DocumentDirService, providedIn: 'root' }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: DocumentDirService, decorators: [{ type: Injectable, args: [{ providedIn: 'root', }] }] }); const DOCUMENT_DIR_PROVIDER = provideAppInitializer(() => { listenDirectionChangeFromAbp(); }); function listenDirectionChangeFromAbp() { const documentDirService = inject(DocumentDirService); documentDirService.listenDir(); } class IfReplaceableTemplateExistsDirective { constructor(view, template, replaceableComponentsService) { this.view = view; this.template = template; this.replaceableComponentsService = replaceableComponentsService; } ngAfterViewInit() { const replaceableComponentInstance = this.replaceableComponentsService.get(this.abpIfReplaceableTemplateExists); const isReplaceableComponentInstanceNotExits = !replaceableComponentInstance; if (isReplaceableComponentInstanceNotExits) { return; } this.view.createEmbeddedView(this.template); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: IfReplaceableTemplateExistsDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: i1.ReplaceableComponentsService }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.8", type: IfReplaceableTemplateExistsDirective, isStandalone: false, selector: "[abpIfReplaceableTemplateExists]", inputs: { abpIfReplaceableTemplateExists: "abpIfReplaceableTemplateExists" }, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: IfReplaceableTemplateExistsDirective, decorators: [{ type: Directive, args: [{ standalone: false, selector: '[abpIfReplaceableTemplateExists]', }] }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i1.ReplaceableComponentsService }], propDecorators: { abpIfReplaceableTemplateExists: [{ type: Input }] } }); class PageAlertContainerComponent { constructor(service) { this.service = service; this.replaceableTemplateKey = { componentKey: 'Theme.PageAlertContainerComponent', }; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: PageAlertContainerComponent, deps: [{ token: i1$1.PageAlertService }], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.8", type: PageAlertContainerComponent, isStandalone: false, selector: "abp-page-alert-container", ngImport: i0, template: "<ng-container *abpReplaceableTemplate=\"replaceableTemplateKey\">\r\n @for (alert of service.alerts$ | async; track $index; let i = $index) {\r\n <div\r\n class=\"alert alert-{{ alert.type }} fade show\"\r\n [ngClass]=\"{ 'alert-dismissible fade show': alert.dismissible }\"\r\n role=\"alert\"\r\n >\r\n @if (alert.title) {\r\n <h4\r\n class=\"alert-heading\"\r\n [innerHTML]=\"\r\n alert.title\r\n | lpxSafeHtml\r\n | abpLocalization: alert.titleLocalizationParams\r\n \"\r\n ></h4>\r\n }\r\n <span\r\n [innerHTML]=\"\r\n alert.message\r\n | lpxSafeHtml\r\n | abpLocalization: alert.messageLocalizationParams\r\n \"\r\n ></span>\r\n @if (alert.dismissible) {\r\n <button\r\n type=\"button\"\r\n class=\"btn-close\"\r\n data-dismiss=\"alert\"\r\n aria-label=\"Close\"\r\n (click)=\"service.remove(i)\"\r\n ></button>\r\n }\r\n </div>\r\n }\r\n</ng-container>\r\n", dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.ReplaceableTemplateDirective, selector: "[abpReplaceableTemplate]", inputs: ["abpReplaceableTemplate"] }, { kind: "pipe", type: i2.AsyncPipe, name: "async" }, { kind: "pipe", type: i1.LocalizationPipe, name: "abpLocalization" }, { kind: "pipe", type: i2$1.SafeHtmlPipe, name: "lpxSafeHtml" }] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: PageAlertContainerComponent, decorators: [{ type: Component, args: [{ standalone: false, selector: 'abp-page-alert-container', template: "<ng-container *abpReplaceableTemplate=\"replaceableTemplateKey\">\r\n @for (alert of service.alerts$ | async; track $index; let i = $index) {\r\n <div\r\n class=\"alert alert-{{ alert.type }} fade show\"\r\n [ngClass]=\"{ 'alert-dismissible fade show': alert.dismissible }\"\r\n role=\"alert\"\r\n >\r\n @if (alert.title) {\r\n <h4\r\n class=\"alert-heading\"\r\n [innerHTML]=\"\r\n alert.title\r\n | lpxSafeHtml\r\n | abpLocalization: alert.titleLocalizationParams\r\n \"\r\n ></h4>\r\n }\r\n <span\r\n [innerHTML]=\"\r\n alert.message\r\n | lpxSafeHtml\r\n | abpLocalization: alert.messageLocalizationParams\r\n \"\r\n ></span>\r\n @if (alert.dismissible) {\r\n <button\r\n type=\"button\"\r\n class=\"btn-close\"\r\n data-dismiss=\"alert\"\r\n aria-label=\"Close\"\r\n (click)=\"service.remove(i)\"\r\n ></button>\r\n }\r\n </div>\r\n }\r\n</ng-container>\r\n" }] }], ctorParameters: () => [{ type: i1$1.PageAlertService }] }); class PageAlertContainerModule { static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: PageAlertContainerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); } static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.1.8", ngImport: i0, type: PageAlertContainerModule, declarations: [PageAlertContainerComponent], imports: [CoreModule, ThemeSharedModule, SafeHtmlPipe], exports: [PageAlertContainerComponent] }); } static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: PageAlertContainerModule, imports: [CoreModule, ThemeSharedModule] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: PageAlertContainerModule, decorators: [{ type: NgModule, args: [{ declarations: [PageAlertContainerComponent], imports: [CoreModule, ThemeSharedModule, SafeHtmlPipe], exports: [PageAlertContainerComponent], }] }] }); class LeptonXPageRenderService { shouldRender(type) { return type !== PageParts.breadcrumb; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: LeptonXPageRenderService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: LeptonXPageRenderService }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: LeptonXPageRenderService, decorators: [{ type: Injectable }] }); const PAGE_RENDER_PROVIDER = { provide: PAGE_RENDER_STRATEGY, useClass: LeptonXPageRenderService, }; class LeptonXAbpCoreModule { static forRoot() { return { ngModule: LeptonXAbpCoreModule, providers: [DOCUMENT_DIR_PROVIDER, MOBILE_NAVBAR_ITEMS_FILTER_PROVIDER, PAGE_RENDER_PROVIDER], }; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: LeptonXAbpCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); } static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.1.8", ngImport: i0, type: LeptonXAbpCoreModule, declarations: [IfReplaceableTemplateExistsDirective], imports: [CommonModule, PageAlertContainerModule], exports: [IfReplaceableTemplateExistsDirective, PageAlertContainerModule] }); } static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: LeptonXAbpCoreModule, imports: [CommonModule, PageAlertContainerModule, PageAlertContainerModule] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: LeptonXAbpCoreModule, decorators: [{ type: NgModule, args: [{ imports: [CommonModule, PageAlertContainerModule], declarations: [IfReplaceableTemplateExistsDirective], exports: [IfReplaceableTemplateExistsDirective, PageAlertContainerModule], }] }] }); class AbpNavbarService { constructor(routes, navbarService, localizationService, mobileMenuItemFilterFn) { this.routes = routes; this.navbarService = navbarService; this.localizationService = localizationService; this.mobileMenuItemFilterFn = mobileMenuItemFilterFn; this.mapRouteToNavItem = (route, index) => { const navbarItem = { text: this.localizationService.instant(route.name), link: route.children && route.children.length ? undefined : route.path, icon: route.iconClass, children: this.getRouteChildrenAsNavItems(route.children || []), showOnMobileNavbar: this.mobileMenuItemFilterFn(route, index), group: route.group, }; if (route.breadcrumbText) { navbarItem.breadcrumbText = this.localizationService.instant(route.breadcrumbText); } return navbarItem; }; } initRoutes() { this.routes.visible$ .pipe(map((routes) => routes.filter((route) => route.path || route.children.length))) .subscribe((routes) => { this.navbarService.setNavbarItems(...routes.map(this.mapRouteToNavItem)); }); } getRouteChildrenAsNavItems(children) { return children.map(this.mapRouteToNavItem); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: AbpNavbarService, deps: [{ token: i1.RoutesService }, { token: i2$1.NavbarService }, { token: i1.LocalizationService }, { token: MOBILE_NAVBAR_ITEMS_FILTER_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: AbpNavbarService, providedIn: 'root' }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: AbpNavbarService, decorators: [{ type: Injectable, args: [{ providedIn: 'root', }] }], ctorParameters: () => [{ type: i1.RoutesService }, { type: i2$1.NavbarService }, { type: i1.LocalizationService }, { type: undefined, decorators: [{ type: Inject, args: [MOBILE_NAVBAR_ITEMS_FILTER_TOKEN] }] }] }); class AbpToolbarService { constructor() { this.toolbar = inject(ToolbarService); this.navItems = inject(NavItemsService); this.permissionService = inject(PermissionService); } listenNavItems() { this.navItems.items$ .pipe(switchMap((items) => this.permissionService.filterItemsByPolicy$(items))) .subscribe((items) => this.toolbar.setItems(items)); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: AbpToolbarService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: AbpToolbarService, providedIn: 'root' }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: AbpToolbarService, decorators: [{ type: Injectable, args: [{ providedIn: 'root', }] }] }); /** * Generated bundle index. Do not edit. */ export { AbpNavbarService, AbpToolbarService, DocumentDirService, IfReplaceableTemplateExistsDirective, LeptonXAbpCoreModule, LeptonXPageRenderService, MOBILE_NAVBAR_ITEMS_FILTER_TOKEN, PageAlertContainerComponent, PageAlertContainerModule }; //# sourceMappingURL=volo-abp.ng.lepton-x.core.mjs.map