UNPKG

@delon/abc

Version:

Common business components of ng-alain.

111 lines (105 loc) 7.38 kB
import { Directionality } from '@angular/cdk/bidi'; import { NgTemplateOutlet, CommonModule } from '@angular/common'; import * as i0 from '@angular/core'; import { booleanAttribute, Component, ChangeDetectionStrategy, ViewEncapsulation, ViewChild, Input, inject, ChangeDetectorRef, DestroyRef, ContentChildren, NgModule } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { DomSanitizer } from '@angular/platform-browser'; import { Router, RouterModule } from '@angular/router'; import { WINDOW } from '@delon/util/token'; class GlobalFooterItemComponent { static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: GlobalFooterItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "18.0.5", type: GlobalFooterItemComponent, isStandalone: true, selector: "global-footer-item", inputs: { href: "href", blankTarget: ["blankTarget", "blankTarget", booleanAttribute] }, viewQueries: [{ propertyName: "host", first: true, predicate: ["host"], descendants: true, static: true }], exportAs: ["globalFooterItem"], ngImport: i0, template: ` <ng-template #host><ng-content /></ng-template> `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: GlobalFooterItemComponent, decorators: [{ type: Component, args: [{ selector: 'global-footer-item', exportAs: 'globalFooterItem', template: ` <ng-template #host><ng-content /></ng-template> `, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, standalone: true }] }], propDecorators: { host: [{ type: ViewChild, args: ['host', { static: true }] }], href: [{ type: Input }], blankTarget: [{ type: Input, args: [{ transform: booleanAttribute }] }] } }); class GlobalFooterComponent { constructor() { this.router = inject(Router); this.win = inject(WINDOW); this.dom = inject(DomSanitizer); this.directionality = inject(Directionality); this.cdr = inject(ChangeDetectorRef); this.destroy$ = inject(DestroyRef); this._links = []; this.dir = 'ltr'; } set links(val) { val.forEach(i => (i._title = this.dom.bypassSecurityTrustHtml(i.title))); this._links = val; } get links() { return this._links; } to(item) { if (!item.href) { return; } if (item.blankTarget) { this.win.open(item.href); return; } if (/^https?:\/\//.test(item.href)) { this.win.location.href = item.href; } else { this.router.navigateByUrl(item.href); } } ngOnInit() { this.dir = this.directionality.value; this.directionality.change.pipe(takeUntilDestroyed(this.destroy$)).subscribe(direction => { this.dir = direction; this.cdr.detectChanges(); }); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: GlobalFooterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.0.5", type: GlobalFooterComponent, isStandalone: true, selector: "global-footer", inputs: { links: "links" }, host: { properties: { "class.global-footer": "true", "class.global-footer-rtl": "dir === 'rtl'" } }, queries: [{ propertyName: "items", predicate: GlobalFooterItemComponent }], exportAs: ["globalFooter"], ngImport: i0, template: "@if (links.length > 0 || items.length > 0) {\n <div class=\"global-footer__links\">\n @for (i of links; track $index) {\n <a class=\"global-footer__links-item\" (click)=\"to(i)\" [innerHTML]=\"i._title\"></a>\n }\n @for (i of items; track $index) {\n <a class=\"global-footer__links-item\" (click)=\"to(i)\">\n <ng-container *ngTemplateOutlet=\"i.host\" />\n </a>\n }\n </div>\n}\n<div class=\"global-footer__copyright\">\n <ng-content />\n</div>\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: GlobalFooterComponent, decorators: [{ type: Component, args: [{ selector: 'global-footer', exportAs: 'globalFooter', host: { '[class.global-footer]': 'true', '[class.global-footer-rtl]': `dir === 'rtl'` }, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, standalone: true, imports: [NgTemplateOutlet], template: "@if (links.length > 0 || items.length > 0) {\n <div class=\"global-footer__links\">\n @for (i of links; track $index) {\n <a class=\"global-footer__links-item\" (click)=\"to(i)\" [innerHTML]=\"i._title\"></a>\n }\n @for (i of items; track $index) {\n <a class=\"global-footer__links-item\" (click)=\"to(i)\">\n <ng-container *ngTemplateOutlet=\"i.host\" />\n </a>\n }\n </div>\n}\n<div class=\"global-footer__copyright\">\n <ng-content />\n</div>\n" }] }], propDecorators: { links: [{ type: Input }], items: [{ type: ContentChildren, args: [GlobalFooterItemComponent] }] } }); const COMPONENTS = [GlobalFooterComponent, GlobalFooterItemComponent]; class GlobalFooterModule { static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: GlobalFooterModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); } static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.5", ngImport: i0, type: GlobalFooterModule, imports: [CommonModule, RouterModule, GlobalFooterComponent, GlobalFooterItemComponent], exports: [GlobalFooterComponent, GlobalFooterItemComponent] }); } static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: GlobalFooterModule, imports: [CommonModule, RouterModule] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: GlobalFooterModule, decorators: [{ type: NgModule, args: [{ imports: [CommonModule, RouterModule, ...COMPONENTS], exports: COMPONENTS }] }] }); /** * Generated bundle index. Do not edit. */ export { GlobalFooterComponent, GlobalFooterItemComponent, GlobalFooterModule }; //# sourceMappingURL=global-footer.mjs.map