UNPKG

ng-zorro-antd

Version:

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

321 lines (314 loc) 10.4 kB
import { Component, ChangeDetectionStrategy, ViewEncapsulation, ChangeDetectorRef, ViewChild, Input, ContentChildren, NgModule } from '@angular/core'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { PlatformModule } from '@angular/cdk/platform'; import { CommonModule } from '@angular/common'; import { NzOutletModule } from 'ng-zorro-antd/core/outlet'; import { NzIconModule } from 'ng-zorro-antd/icon'; /** * @fileoverview added by tsickle * Generated from: timeline-item.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const TimelineTimeDefaultColors = (/** @type {?} */ (['red', 'blue', 'green', 'grey', 'gray'])); /** * @param {?=} color * @return {?} */ function isDefaultColor(color) { return TimelineTimeDefaultColors.findIndex((/** * @param {?} i * @return {?} */ i => i === color)) !== -1; } class NzTimelineItemComponent { /** * @param {?} cdr */ constructor(cdr) { this.cdr = cdr; this.nzColor = 'blue'; this.isLast = false; this.borderColor = null; } /** * @param {?} changes * @return {?} */ ngOnChanges(changes) { if (changes.nzColor) { this.updateCustomColor(); } } /** * @return {?} */ detectChanges() { this.cdr.detectChanges(); } /** * @private * @return {?} */ updateCustomColor() { this.borderColor = isDefaultColor(this.nzColor) ? null : this.nzColor; } } NzTimelineItemComponent.decorators = [ { type: Component, args: [{ changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, selector: 'nz-timeline-item, [nz-timeline-item]', exportAs: 'nzTimelineItem', template: ` <ng-template #template> <li class="ant-timeline-item" [class.ant-timeline-item-right]="position === 'right'" [class.ant-timeline-item-left]="position === 'left'" [class.ant-timeline-item-last]="isLast" > <div class="ant-timeline-item-tail"></div> <div class="ant-timeline-item-head" [class.ant-timeline-item-head-red]="nzColor === 'red'" [class.ant-timeline-item-head-blue]="nzColor === 'blue'" [class.ant-timeline-item-head-green]="nzColor === 'green'" [class.ant-timeline-item-head-gray]="nzColor === 'gray'" [class.ant-timeline-item-head-custom]="!!nzDot" [style.border-color]="borderColor" > <ng-container *nzStringTemplateOutlet="nzDot">{{ nzDot }}</ng-container> </div> <div class="ant-timeline-item-content"> <ng-content></ng-content> </div> </li> </ng-template> ` }] } ]; /** @nocollapse */ NzTimelineItemComponent.ctorParameters = () => [ { type: ChangeDetectorRef } ]; NzTimelineItemComponent.propDecorators = { template: [{ type: ViewChild, args: ['template', { static: false },] }], nzColor: [{ type: Input }], nzDot: [{ type: Input }] }; if (false) { /** @type {?} */ NzTimelineItemComponent.prototype.template; /** @type {?} */ NzTimelineItemComponent.prototype.nzColor; /** @type {?} */ NzTimelineItemComponent.prototype.nzDot; /** @type {?} */ NzTimelineItemComponent.prototype.isLast; /** @type {?} */ NzTimelineItemComponent.prototype.borderColor; /** @type {?} */ NzTimelineItemComponent.prototype.position; /** * @type {?} * @private */ NzTimelineItemComponent.prototype.cdr; } /** * @fileoverview added by tsickle * Generated from: timeline.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const TimelineModes = (/** @type {?} */ (['left', 'alternate', 'right'])); class NzTimelineComponent { /** * @param {?} cdr */ constructor(cdr) { this.cdr = cdr; this.nzReverse = false; this.isPendingBoolean = false; this.timelineItems = []; this.destroy$ = new Subject(); } /** * @param {?} changes * @return {?} */ ngOnChanges(changes) { const { nzMode, nzReverse, nzPending } = changes; if (simpleChangeActivated(nzMode) || simpleChangeActivated(nzReverse)) { this.updateChildren(); } if (nzPending) { this.isPendingBoolean = nzPending.currentValue === true; } } /** * @return {?} */ ngAfterContentInit() { this.updateChildren(); this.listOfItems.changes.pipe(takeUntil(this.destroy$)).subscribe((/** * @return {?} */ () => { this.updateChildren(); })); } /** * @return {?} */ ngOnDestroy() { this.destroy$.next(); this.destroy$.complete(); } /** * @private * @return {?} */ updateChildren() { if (this.listOfItems && this.listOfItems.length) { /** @type {?} */ const length = this.listOfItems.length; this.listOfItems.forEach((/** * @param {?} item * @param {?} index * @return {?} */ (item, index) => { item.isLast = !this.nzReverse ? index === length - 1 : index === 0; item.position = this.nzMode === 'left' || !this.nzMode ? undefined : this.nzMode === 'right' ? 'right' : this.nzMode === 'alternate' && index % 2 === 0 ? 'left' : 'right'; item.detectChanges(); })); this.timelineItems = this.nzReverse ? this.listOfItems.toArray().reverse() : this.listOfItems.toArray(); } this.cdr.markForCheck(); } } NzTimelineComponent.decorators = [ { type: Component, args: [{ changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, selector: 'nz-timeline', exportAs: 'nzTimeline', template: ` <ul class="ant-timeline" [class.ant-timeline-right]="nzMode === 'right'" [class.ant-timeline-alternate]="nzMode === 'alternate'" [class.ant-timeline-pending]="!!nzPending" [class.ant-timeline-reverse]="nzReverse" > <!-- User inserted timeline dots. --> <ng-container *ngIf="nzReverse" [ngTemplateOutlet]="pendingTemplate"></ng-container> <ng-container *ngFor="let item of timelineItems"> <ng-template [ngTemplateOutlet]="item.template"></ng-template> </ng-container> <ng-container *ngIf="!nzReverse" [ngTemplateOutlet]="pendingTemplate"></ng-container> <!-- Pending dot. --> </ul> <ng-template #pendingTemplate> <li *ngIf="nzPending" class="ant-timeline-item ant-timeline-item-pending"> <div class="ant-timeline-item-tail"></div> <div class="ant-timeline-item-head ant-timeline-item-head-custom ant-timeline-item-head-blue"> <ng-container *nzStringTemplateOutlet="nzPendingDot"> {{ nzPendingDot }}<i *ngIf="!nzPendingDot" nz-icon nzType="loading"></i> </ng-container> </div> <div class="ant-timeline-item-content"> <ng-container *nzStringTemplateOutlet="nzPending"> {{ isPendingBoolean ? '' : nzPending }} </ng-container> </div> </li> </ng-template> <!-- Grasp items --> <ng-content></ng-content> ` }] } ]; /** @nocollapse */ NzTimelineComponent.ctorParameters = () => [ { type: ChangeDetectorRef } ]; NzTimelineComponent.propDecorators = { listOfItems: [{ type: ContentChildren, args: [NzTimelineItemComponent,] }], nzMode: [{ type: Input }], nzPending: [{ type: Input }], nzPendingDot: [{ type: Input }], nzReverse: [{ type: Input }] }; if (false) { /** @type {?} */ NzTimelineComponent.prototype.listOfItems; /** @type {?} */ NzTimelineComponent.prototype.nzMode; /** @type {?} */ NzTimelineComponent.prototype.nzPending; /** @type {?} */ NzTimelineComponent.prototype.nzPendingDot; /** @type {?} */ NzTimelineComponent.prototype.nzReverse; /** @type {?} */ NzTimelineComponent.prototype.isPendingBoolean; /** @type {?} */ NzTimelineComponent.prototype.timelineItems; /** * @type {?} * @private */ NzTimelineComponent.prototype.destroy$; /** * @type {?} * @private */ NzTimelineComponent.prototype.cdr; } /** * @param {?=} simpleChange * @return {?} */ function simpleChangeActivated(simpleChange) { return !!(simpleChange && (simpleChange.previousValue !== simpleChange.currentValue || simpleChange.isFirstChange())); } /** * @fileoverview added by tsickle * Generated from: timeline.module.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class NzTimelineModule { } NzTimelineModule.decorators = [ { type: NgModule, args: [{ declarations: [NzTimelineItemComponent, NzTimelineComponent], exports: [NzTimelineItemComponent, NzTimelineComponent], imports: [CommonModule, PlatformModule, NzIconModule, NzOutletModule] },] } ]; /** * @fileoverview added by tsickle * Generated from: public-api.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * Generated from: ng-zorro-antd-timeline.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ export { NzTimelineComponent, NzTimelineItemComponent, NzTimelineModule }; //# sourceMappingURL=ng-zorro-antd-timeline.js.map