UNPKG

ng-zorro-antd

Version:

An enterprise-class UI components based on Ant Design and Angular

1 lines 16.6 kB
{"version":3,"file":"ng-zorro-antd-timeline.mjs","sources":["../../components/timeline/typings.ts","../../components/timeline/timeline.service.ts","../../components/timeline/timeline-item.component.ts","../../components/timeline/timeline.component.ts","../../components/timeline/timeline.module.ts","../../components/timeline/public-api.ts","../../components/timeline/ng-zorro-antd-timeline.ts"],"sourcesContent":["/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nconst TimelineModes = ['left', 'alternate', 'right', 'custom'] as const;\nexport type NzTimelineMode = typeof TimelineModes[number];\n\nconst TimelinePositions = ['left', 'right'] as const;\nexport type NzTimelinePosition = typeof TimelinePositions[number];\n\nexport const TimelineTimeDefaultColors = ['red', 'blue', 'green', 'grey', 'gray'] as const;\nexport type NzTimelineItemColor = typeof TimelineTimeDefaultColors[number];\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { Injectable } from '@angular/core';\nimport { ReplaySubject } from 'rxjs';\n\n@Injectable()\nexport class TimelineService {\n check$ = new ReplaySubject(1);\n markForCheck(): void {\n this.check$.next();\n }\n}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport {\n ChangeDetectionStrategy,\n ChangeDetectorRef,\n Component,\n Input,\n OnChanges,\n SimpleChanges,\n TemplateRef,\n ViewChild,\n ViewEncapsulation\n} from '@angular/core';\n\nimport { TimelineService } from './timeline.service';\nimport { NzTimelineItemColor, NzTimelinePosition, TimelineTimeDefaultColors } from './typings';\n\nfunction isDefaultColor(color?: string): boolean {\n return TimelineTimeDefaultColors.findIndex(i => i === color) !== -1;\n}\n\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n preserveWhitespaces: false,\n selector: 'nz-timeline-item, [nz-timeline-item]',\n exportAs: 'nzTimelineItem',\n template: `\n <ng-template #template>\n <li\n class=\"ant-timeline-item\"\n [class.ant-timeline-item-right]=\"(nzPosition || position) === 'right'\"\n [class.ant-timeline-item-left]=\"(nzPosition || position) === 'left'\"\n [class.ant-timeline-item-last]=\"isLast\"\n >\n <div *ngIf=\"nzLabel\" class=\"ant-timeline-item-label\">\n <ng-container *nzStringTemplateOutlet=\"nzLabel\">{{ nzLabel }}</ng-container>\n </div>\n <div class=\"ant-timeline-item-tail\"></div>\n <div\n class=\"ant-timeline-item-head\"\n [class.ant-timeline-item-head-red]=\"nzColor === 'red'\"\n [class.ant-timeline-item-head-blue]=\"nzColor === 'blue'\"\n [class.ant-timeline-item-head-green]=\"nzColor === 'green'\"\n [class.ant-timeline-item-head-gray]=\"nzColor === 'gray'\"\n [class.ant-timeline-item-head-custom]=\"!!nzDot\"\n [style.border-color]=\"borderColor\"\n >\n <ng-container *nzStringTemplateOutlet=\"nzDot\">{{ nzDot }}</ng-container>\n </div>\n <div class=\"ant-timeline-item-content\">\n <ng-content></ng-content>\n </div>\n </li>\n </ng-template>\n `\n})\nexport class NzTimelineItemComponent implements OnChanges {\n @ViewChild('template', { static: false }) template!: TemplateRef<void>;\n\n @Input() nzPosition?: NzTimelinePosition;\n @Input() nzColor: NzTimelineItemColor = 'blue';\n @Input() nzDot?: string | TemplateRef<void>;\n @Input() nzLabel?: string | TemplateRef<void>;\n\n isLast = false;\n borderColor: string | null = null;\n position?: NzTimelinePosition;\n\n constructor(private cdr: ChangeDetectorRef, private timelineService: TimelineService) {}\n\n ngOnChanges(changes: SimpleChanges): void {\n this.timelineService.markForCheck();\n if (changes.nzColor) {\n this.updateCustomColor();\n }\n }\n\n detectChanges(): void {\n this.cdr.detectChanges();\n }\n\n private updateCustomColor(): void {\n this.borderColor = isDefaultColor(this.nzColor) ? null : this.nzColor;\n }\n}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { Direction, Directionality } from '@angular/cdk/bidi';\nimport {\n AfterContentInit,\n ChangeDetectionStrategy,\n ChangeDetectorRef,\n Component,\n ContentChildren,\n Input,\n OnChanges,\n OnDestroy,\n OnInit,\n Optional,\n QueryList,\n SimpleChange,\n SimpleChanges,\n TemplateRef,\n ViewEncapsulation\n} from '@angular/core';\nimport { Subject } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\n\nimport { NzTimelineItemComponent } from './timeline-item.component';\nimport { TimelineService } from './timeline.service';\nimport { NzTimelineMode, NzTimelinePosition } from './typings';\n\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n preserveWhitespaces: false,\n selector: 'nz-timeline',\n providers: [TimelineService],\n exportAs: 'nzTimeline',\n template: `\n <ul\n class=\"ant-timeline\"\n [class.ant-timeline-label]=\"hasLabelItem\"\n [class.ant-timeline-right]=\"!hasLabelItem && nzMode === 'right'\"\n [class.ant-timeline-alternate]=\"nzMode === 'alternate' || nzMode === 'custom'\"\n [class.ant-timeline-pending]=\"!!nzPending\"\n [class.ant-timeline-reverse]=\"nzReverse\"\n [class.ant-timeline-rtl]=\"dir === 'rtl'\"\n >\n <!-- pending dot (reversed) -->\n <ng-container *ngIf=\"nzReverse\" [ngTemplateOutlet]=\"pendingTemplate\"></ng-container>\n <!-- timeline items -->\n <ng-container *ngFor=\"let item of timelineItems\">\n <ng-template [ngTemplateOutlet]=\"item.template\"></ng-template>\n </ng-container>\n <ng-container *ngIf=\"!nzReverse\" [ngTemplateOutlet]=\"pendingTemplate\"></ng-container>\n <!-- pending dot -->\n </ul>\n <ng-template #pendingTemplate>\n <li *ngIf=\"nzPending\" class=\"ant-timeline-item ant-timeline-item-pending\">\n <div class=\"ant-timeline-item-tail\"></div>\n <div class=\"ant-timeline-item-head ant-timeline-item-head-custom ant-timeline-item-head-blue\">\n <ng-container *nzStringTemplateOutlet=\"nzPendingDot\">\n {{ nzPendingDot }}\n <i *ngIf=\"!nzPendingDot\" nz-icon nzType=\"loading\"></i>\n </ng-container>\n </div>\n <div class=\"ant-timeline-item-content\">\n <ng-container *nzStringTemplateOutlet=\"nzPending\">\n {{ isPendingBoolean ? '' : nzPending }}\n </ng-container>\n </div>\n </li>\n </ng-template>\n <!-- Grasp items -->\n <ng-content></ng-content>\n `\n})\nexport class NzTimelineComponent implements AfterContentInit, OnChanges, OnDestroy, OnInit {\n @ContentChildren(NzTimelineItemComponent) listOfItems!: QueryList<NzTimelineItemComponent>;\n\n @Input() nzMode: NzTimelineMode = 'left';\n @Input() nzPending?: string | boolean | TemplateRef<void>;\n @Input() nzPendingDot?: string | TemplateRef<void>;\n @Input() nzReverse: boolean = false;\n\n isPendingBoolean: boolean = false;\n timelineItems: NzTimelineItemComponent[] = [];\n dir: Direction = 'ltr';\n hasLabelItem = false;\n\n private destroy$ = new Subject<void>();\n\n constructor(\n private cdr: ChangeDetectorRef,\n private timelineService: TimelineService,\n @Optional() private directionality: Directionality\n ) {}\n\n ngOnChanges(changes: SimpleChanges): void {\n const { nzMode, nzReverse, nzPending } = changes;\n\n if (simpleChangeActivated(nzMode) || simpleChangeActivated(nzReverse)) {\n this.updateChildren();\n }\n\n if (nzPending) {\n this.isPendingBoolean = nzPending.currentValue === true;\n }\n }\n\n ngOnInit(): void {\n this.timelineService.check$.pipe(takeUntil(this.destroy$)).subscribe(() => {\n this.cdr.markForCheck();\n });\n\n this.directionality.change?.pipe(takeUntil(this.destroy$)).subscribe((direction: Direction) => {\n this.dir = direction;\n this.cdr.detectChanges();\n });\n\n this.dir = this.directionality.value;\n }\n\n ngAfterContentInit(): void {\n this.updateChildren();\n\n this.listOfItems.changes.pipe(takeUntil(this.destroy$)).subscribe(() => {\n this.updateChildren();\n });\n }\n\n ngOnDestroy(): void {\n this.destroy$.next();\n this.destroy$.complete();\n }\n\n private updateChildren(): void {\n if (this.listOfItems && this.listOfItems.length) {\n const length = this.listOfItems.length;\n let hasLabelItem = false;\n\n this.listOfItems.forEach((item: NzTimelineItemComponent, index: number) => {\n item.isLast = !this.nzReverse ? index === length - 1 : index === 0;\n item.position = getInferredTimelineItemPosition(index, this.nzMode);\n\n if (!hasLabelItem && item.nzLabel) {\n hasLabelItem = true;\n }\n\n item.detectChanges();\n });\n\n this.timelineItems = this.nzReverse ? this.listOfItems.toArray().reverse() : this.listOfItems.toArray();\n this.hasLabelItem = hasLabelItem;\n } else {\n this.timelineItems = [];\n this.hasLabelItem = false;\n }\n\n this.cdr.markForCheck();\n }\n}\n\nfunction simpleChangeActivated(simpleChange?: SimpleChange): boolean {\n return !!(simpleChange && (simpleChange.previousValue !== simpleChange.currentValue || simpleChange.isFirstChange()));\n}\n\nfunction getInferredTimelineItemPosition(index: number, mode: NzTimelineMode): NzTimelinePosition | undefined {\n return mode === 'custom'\n ? undefined\n : mode === 'left'\n ? 'left'\n : mode === 'right'\n ? 'right'\n : mode === 'alternate' && index % 2 === 0\n ? 'left'\n : 'right';\n}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { BidiModule } from '@angular/cdk/bidi';\nimport { PlatformModule } from '@angular/cdk/platform';\nimport { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\n\nimport { NzOutletModule } from 'ng-zorro-antd/core/outlet';\nimport { NzIconModule } from 'ng-zorro-antd/icon';\n\nimport { NzTimelineItemComponent } from './timeline-item.component';\nimport { NzTimelineComponent } from './timeline.component';\n\n@NgModule({\n declarations: [NzTimelineItemComponent, NzTimelineComponent],\n exports: [NzTimelineItemComponent, NzTimelineComponent],\n imports: [BidiModule, CommonModule, PlatformModule, NzIconModule, NzOutletModule]\n})\nexport class NzTimelineModule {}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nexport * from './timeline-item.component';\nexport * from './timeline.component';\nexport * from './timeline.module';\nexport * from './timeline.service';\nexport { NzTimelineMode, NzTimelinePosition, NzTimelineItemColor } from './typings';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;;AAKA,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC;AAGxE,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,OAAO,CAAU,CAAC;AAG9C,MAAM,yBAAyB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAU;;ACX1F;;;;MASa,eAAe;IAD5B;QAEE,WAAM,GAAG,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;KAI/B;IAHC,YAAY;QACV,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;KACpB;;4GAJU,eAAe;gHAAf,eAAe;2FAAf,eAAe;kBAD3B,UAAU;;;ACRX;;;;AAoBA,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,yBAAyB,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AACtE,CAAC;MAsCY,uBAAuB;IAYlC,YAAoB,GAAsB,EAAU,eAAgC;QAAhE,QAAG,GAAH,GAAG,CAAmB;QAAU,oBAAe,GAAf,eAAe,CAAiB;QAR3E,YAAO,GAAwB,MAAM,CAAC;QAI/C,WAAM,GAAG,KAAK,CAAC;QACf,gBAAW,GAAkB,IAAI,CAAC;KAGsD;IAExF,WAAW,CAAC,OAAsB;QAChC,IAAI,CAAC,eAAe,CAAC,YAAY,EAAE,CAAC;QACpC,IAAI,OAAO,CAAC,OAAO,EAAE;YACnB,IAAI,CAAC,iBAAiB,EAAE,CAAC;SAC1B;KACF;IAED,aAA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