UNPKG

@delon/abc

Version:

Common business components of ng-alain.

125 lines (119 loc) 9.11 kB
import * as i0 from '@angular/core'; import { Component, ChangeDetectionStrategy, ViewEncapsulation, Input, inject, ChangeDetectorRef, DestroyRef, numberAttribute, ContentChildren, NgModule } from '@angular/core'; import { Directionality } from '@angular/cdk/bidi'; import { NgStyle, NgClass, CommonModule } from '@angular/common'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { NzAvatarComponent, NzAvatarModule } from 'ng-zorro-antd/avatar'; import { NzTooltipDirective, NzToolTipModule } from 'ng-zorro-antd/tooltip'; class AvatarListItemComponent { static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: AvatarListItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.0.5", type: AvatarListItemComponent, isStandalone: true, selector: "avatar-list-item, [avatar-list-item]", inputs: { src: "src", text: "text", icon: "icon", tips: "tips" }, exportAs: ["avatarListItem"], ngImport: i0, template: `<ng-content />`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: AvatarListItemComponent, decorators: [{ type: Component, args: [{ selector: 'avatar-list-item, [avatar-list-item]', exportAs: 'avatarListItem', template: `<ng-content />`, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, standalone: true }] }], propDecorators: { src: [{ type: Input }], text: [{ type: Input }], icon: [{ type: Input }], tips: [{ type: Input }] } }); class AvatarListComponent { constructor() { this.cdr = inject(ChangeDetectorRef); this.directionality = inject(Directionality); this.destroy$ = inject(DestroyRef); this.inited = false; this.items = []; this.exceedCount = 0; this.dir = 'ltr'; this.cls = ''; this.avatarSize = 'default'; this.maxLength = 0; this.excessItemsStyle = null; } set size(value) { this.cls = `avatar-list__item${value === 'default' ? '' : ` avatar-list__${value}`}`; switch (value) { case 'large': case 'small': case 'default': this.avatarSize = value; break; default: this.avatarSize = 'small'; break; } } gen() { const { _items } = this; const maxLength = this.maxLength > 0 ? this.maxLength : _items.length; const numOfChildren = _items.length; const numToShow = maxLength > 0 && maxLength >= numOfChildren ? numOfChildren : maxLength; this.items = _items.toArray().slice(0, numToShow); this.exceedCount = numToShow < numOfChildren ? numOfChildren - maxLength : 0; this.cdr.detectChanges(); } ngAfterViewInit() { this.dir = this.directionality.value; this.directionality.change.pipe(takeUntilDestroyed(this.destroy$)).subscribe(direction => { this.dir = direction; this.cdr.detectChanges(); }); this.gen(); this.inited = true; } ngOnChanges() { if (this.inited) { this.gen(); } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: AvatarListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.0.5", type: AvatarListComponent, isStandalone: true, selector: "avatar-list", inputs: { size: "size", maxLength: ["maxLength", "maxLength", numberAttribute], excessItemsStyle: "excessItemsStyle" }, host: { properties: { "class.avatar-list": "true", "class.avatar-list-rtl": "dir === 'rtl'" } }, queries: [{ propertyName: "_items", predicate: AvatarListItemComponent }], exportAs: ["avatarList"], usesOnChanges: true, ngImport: i0, template: "<ul class=\"avatar-list__wrap\">\n @for (i of items; track $index) {\n <li [ngClass]=\"cls\">\n @if (i.tips) {\n <nz-avatar\n nz-tooltip\n [nzTooltipTitle]=\"i.tips\"\n [nzSrc]=\"i.src\"\n [nzText]=\"i.text\"\n [nzIcon]=\"i.icon\"\n [nzSize]=\"avatarSize\"\n />\n } @else {\n <nz-avatar [nzSrc]=\"i.src\" [nzText]=\"i.text\" [nzIcon]=\"i.icon\" [nzSize]=\"avatarSize\" />\n }\n </li>\n }\n @if (exceedCount > 0) {\n <li [ngClass]=\"cls\">\n <nz-avatar [nzSize]=\"avatarSize\" style=\"cursor: auto\" [ngStyle]=\"excessItemsStyle\" [nzText]=\"'+' + exceedCount\" />\n </li>\n }\n</ul>\n", dependencies: [{ kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: NzAvatarComponent, selector: "nz-avatar", inputs: ["nzShape", "nzSize", "nzGap", "nzText", "nzSrc", "nzSrcSet", "nzAlt", "nzIcon"], outputs: ["nzError"], exportAs: ["nzAvatar"] }, { kind: "directive", type: NzTooltipDirective, selector: "[nz-tooltip]", inputs: ["nzTooltipTitle", "nzTooltipTitleContext", "nz-tooltip", "nzTooltipTrigger", "nzTooltipPlacement", "nzTooltipOrigin", "nzTooltipVisible", "nzTooltipMouseEnterDelay", "nzTooltipMouseLeaveDelay", "nzTooltipOverlayClassName", "nzTooltipOverlayStyle", "nzTooltipArrowPointAtCenter", "cdkConnectedOverlayPush", "nzTooltipColor"], outputs: ["nzTooltipVisibleChange"], exportAs: ["nzTooltip"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: AvatarListComponent, decorators: [{ type: Component, args: [{ selector: 'avatar-list', exportAs: 'avatarList', host: { '[class.avatar-list]': 'true', '[class.avatar-list-rtl]': `dir === 'rtl'` }, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, standalone: true, imports: [NgStyle, NgClass, NzAvatarComponent, NzTooltipDirective], template: "<ul class=\"avatar-list__wrap\">\n @for (i of items; track $index) {\n <li [ngClass]=\"cls\">\n @if (i.tips) {\n <nz-avatar\n nz-tooltip\n [nzTooltipTitle]=\"i.tips\"\n [nzSrc]=\"i.src\"\n [nzText]=\"i.text\"\n [nzIcon]=\"i.icon\"\n [nzSize]=\"avatarSize\"\n />\n } @else {\n <nz-avatar [nzSrc]=\"i.src\" [nzText]=\"i.text\" [nzIcon]=\"i.icon\" [nzSize]=\"avatarSize\" />\n }\n </li>\n }\n @if (exceedCount > 0) {\n <li [ngClass]=\"cls\">\n <nz-avatar [nzSize]=\"avatarSize\" style=\"cursor: auto\" [ngStyle]=\"excessItemsStyle\" [nzText]=\"'+' + exceedCount\" />\n </li>\n }\n</ul>\n" }] }], propDecorators: { _items: [{ type: ContentChildren, args: [AvatarListItemComponent, { descendants: false }] }], size: [{ type: Input }], maxLength: [{ type: Input, args: [{ transform: numberAttribute }] }], excessItemsStyle: [{ type: Input }] } }); const COMPONENTS = [AvatarListComponent, AvatarListItemComponent]; class AvatarListModule { static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: AvatarListModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); } static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.5", ngImport: i0, type: AvatarListModule, imports: [CommonModule, NzAvatarModule, NzToolTipModule, AvatarListComponent, AvatarListItemComponent], exports: [AvatarListComponent, AvatarListItemComponent] }); } static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: AvatarListModule, imports: [CommonModule, NzAvatarModule, NzToolTipModule, AvatarListComponent] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: AvatarListModule, decorators: [{ type: NgModule, args: [{ imports: [CommonModule, NzAvatarModule, NzToolTipModule, ...COMPONENTS], exports: COMPONENTS }] }] }); /** * Generated bundle index. Do not edit. */ export { AvatarListComponent, AvatarListItemComponent, AvatarListModule }; //# sourceMappingURL=avatar-list.mjs.map