@volo/abp.ng.lepton-x.core
Version:
This library was generated with [Nx](https://nx.dev).
238 lines (222 loc) • 14.6 kB
JavaScript
import * as i0 from '@angular/core';
import { inject, ViewContainerRef, TemplateRef, Input, Directive, Component, NgModule, DOCUMENT, Injectable, provideAppInitializer, InjectionToken, makeEnvironmentProviders } from '@angular/core';
import { AsyncPipe, CommonModule } from '@angular/common';
import { ReplaceableComponentsService, ReplaceableTemplateDirective, LocalizationPipe, CoreModule, RoutesService, LocalizationService, PermissionService } from '@abp/ng.core';
import { PageAlertService, ThemeSharedModule, DocumentDirHandlerService, NavItemsService } from '@abp/ng.theme.shared';
import { SafeHtmlPipe, NavbarService, ToolbarService } from '@volo/ngx-lepton-x.core';
import { PageParts, PAGE_RENDER_STRATEGY } from '@abp/ng.components/page';
import { map, switchMap } from 'rxjs/operators';
class IfReplaceableTemplateExistsDirective {
constructor() {
this.view = inject(ViewContainerRef);
this.template = inject(TemplateRef);
this.replaceableComponentsService = inject(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: "21.2.13", ngImport: i0, type: IfReplaceableTemplateExistsDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.13", type: IfReplaceableTemplateExistsDirective, isStandalone: true, selector: "[abpIfReplaceableTemplateExists]", inputs: { abpIfReplaceableTemplateExists: "abpIfReplaceableTemplateExists" }, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: IfReplaceableTemplateExistsDirective, decorators: [{
type: Directive,
args: [{ selector: '[abpIfReplaceableTemplateExists]' }]
}], propDecorators: { abpIfReplaceableTemplateExists: [{
type: Input
}] } });
class PageAlertContainerComponent {
constructor() {
this.service = inject(PageAlertService);
this.replaceableTemplateKey = {
componentKey: 'Theme.PageAlertContainerComponent',
};
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: PageAlertContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.13", type: PageAlertContainerComponent, isStandalone: true, 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 [class.alert-dismissible]=\"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: ReplaceableTemplateDirective, selector: "[abpReplaceableTemplate]", inputs: ["abpReplaceableTemplate"] }, { kind: "pipe", type: LocalizationPipe, name: "abpLocalization" }, { kind: "pipe", type: AsyncPipe, name: "async" }, { kind: "pipe", type: SafeHtmlPipe, name: "lpxSafeHtml" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: PageAlertContainerComponent, decorators: [{
type: Component,
args: [{ selector: 'abp-page-alert-container', imports: [
LocalizationPipe,
ReplaceableTemplateDirective,
AsyncPipe,
SafeHtmlPipe
], 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 [class.alert-dismissible]=\"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" }]
}] });
class PageAlertContainerModule {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: PageAlertContainerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.13", ngImport: i0, type: PageAlertContainerModule, imports: [CoreModule,
ThemeSharedModule,
SafeHtmlPipe,
PageAlertContainerComponent], exports: [PageAlertContainerComponent] }); }
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: PageAlertContainerModule, imports: [CoreModule,
ThemeSharedModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: PageAlertContainerModule, decorators: [{
type: NgModule,
args: [{
imports: [
CoreModule,
ThemeSharedModule,
SafeHtmlPipe,
PageAlertContainerComponent,
],
exports: [PageAlertContainerComponent],
}]
}] });
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: "21.2.13", ngImport: i0, type: DocumentDirService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: DocumentDirService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: DocumentDirService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root',
}]
}] });
const DOCUMENT_DIR_PROVIDER = provideAppInitializer(() => {
listenDirectionChangeFromAbp();
});
function listenDirectionChangeFromAbp() {
const documentDirService = inject(DocumentDirService);
documentDirService.listenDir();
}
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 LeptonXPageRenderService {
shouldRender(type) {
return type !== PageParts.breadcrumb;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: LeptonXPageRenderService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: LeptonXPageRenderService }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: LeptonXPageRenderService, decorators: [{
type: Injectable
}] });
const PAGE_RENDER_PROVIDER = {
provide: PAGE_RENDER_STRATEGY,
useClass: LeptonXPageRenderService,
};
function provideLeptonXAbpCore() {
return makeEnvironmentProviders([
DOCUMENT_DIR_PROVIDER,
MOBILE_NAVBAR_ITEMS_FILTER_PROVIDER,
PAGE_RENDER_PROVIDER,
]);
}
class LeptonXAbpCoreModule {
/**
* @deprecated `LeptonXAbpCoreModule.forRoot()` is deprecated. You can use `provideLeptonXAbpCore` **function** instead.
*/
static forRoot() {
return {
ngModule: LeptonXAbpCoreModule,
providers: [provideLeptonXAbpCore()],
};
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: LeptonXAbpCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.13", ngImport: i0, type: LeptonXAbpCoreModule, imports: [CommonModule,
PageAlertContainerModule,
IfReplaceableTemplateExistsDirective], exports: [IfReplaceableTemplateExistsDirective, PageAlertContainerModule] }); }
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: LeptonXAbpCoreModule, imports: [CommonModule,
PageAlertContainerModule, PageAlertContainerModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: LeptonXAbpCoreModule, decorators: [{
type: NgModule,
args: [{
imports: [
CommonModule,
PageAlertContainerModule,
IfReplaceableTemplateExistsDirective,
],
exports: [IfReplaceableTemplateExistsDirective, PageAlertContainerModule],
}]
}] });
class AbpNavbarService {
constructor() {
this.routes = inject(RoutesService);
this.navbarService = inject(NavbarService);
this.localizationService = inject(LocalizationService);
this.mobileMenuItemFilterFn = inject(MOBILE_NAVBAR_ITEMS_FILTER_TOKEN);
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: "21.2.13", ngImport: i0, type: AbpNavbarService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: AbpNavbarService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: AbpNavbarService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root',
}]
}] });
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: "21.2.13", ngImport: i0, type: AbpToolbarService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: AbpToolbarService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.13", 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, provideLeptonXAbpCore };
//# sourceMappingURL=volo-abp.ng.lepton-x.core.mjs.map