UNPKG

ng-zorro-antd

Version:

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

481 lines (474 loc) 15.4 kB
import { TemplateRef, Component, ChangeDetectionStrategy, ViewEncapsulation, ChangeDetectorRef, ViewChild, Input, EventEmitter, ContentChildren, Output, NgModule } from '@angular/core'; import { InputBoolean, toBoolean } from 'ng-zorro-antd/core/util'; import { Subject, merge } from 'rxjs'; import { startWith, takeUntil } from 'rxjs/operators'; import { __decorate, __metadata } from 'tslib'; 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: step.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class NzStepComponent { /** * @param {?} cdr */ constructor(cdr) { this.cdr = cdr; this.nzDisabled = false; this.isCustomStatus = false; this._status = 'wait'; this.oldAPIIcon = true; this.isIconString = true; // Set by parent. this.direction = 'horizontal'; this.index = 0; this.last = false; this.outStatus = 'process'; this.showProcessDot = false; this.clickable = false; this.click$ = new Subject(); this._currentIndex = 0; } /** * @return {?} */ get nzStatus() { return this._status; } /** * @param {?} status * @return {?} */ set nzStatus(status) { this._status = status; this.isCustomStatus = true; } /** * @return {?} */ get nzIcon() { return this._icon; } /** * @param {?} value * @return {?} */ set nzIcon(value) { if (!(value instanceof TemplateRef)) { this.isIconString = true; this.oldAPIIcon = typeof value === 'string' && value.indexOf('anticon') > -1; } else { this.isIconString = false; } this._icon = value; } /** * @return {?} */ get currentIndex() { return this._currentIndex; } /** * @param {?} current * @return {?} */ set currentIndex(current) { this._currentIndex = current; if (!this.isCustomStatus) { this._status = current > this.index ? 'finish' : current === this.index ? this.outStatus || '' : 'wait'; } } /** * @return {?} */ onClick() { if (this.clickable && this.currentIndex !== this.index && !this.nzDisabled) { this.click$.next(this.index); } } /** * @return {?} */ markForCheck() { this.cdr.markForCheck(); } /** * @return {?} */ ngOnDestroy() { this.click$.complete(); } } NzStepComponent.decorators = [ { type: Component, args: [{ changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, selector: 'nz-step', exportAs: 'nzStep', preserveWhitespaces: false, template: ` <div class="ant-steps-item-container" [attr.role]="clickable && !nzDisabled ? 'button' : null" [tabindex]="clickable && !nzDisabled ? 0 : null" (click)="onClick()" > <div class="ant-steps-item-tail" *ngIf="last !== true"></div> <div class="ant-steps-item-icon"> <ng-template [ngIf]="!showProcessDot"> <span class="ant-steps-icon" *ngIf="nzStatus === 'finish' && !nzIcon"><i nz-icon nzType="check"></i></span> <span class="ant-steps-icon" *ngIf="nzStatus === 'error'"><i nz-icon nzType="close"></i></span> <span class="ant-steps-icon" *ngIf="(nzStatus === 'process' || nzStatus === 'wait') && !nzIcon">{{ index + 1 }}</span> <span class="ant-steps-icon" *ngIf="nzIcon"> <ng-container *ngIf="isIconString; else iconTemplate"> <i nz-icon [nzType]="!oldAPIIcon && nzIcon" [ngClass]="oldAPIIcon && nzIcon"></i> </ng-container> <ng-template #iconTemplate> <ng-template [ngTemplateOutlet]="nzIcon"></ng-template> </ng-template> </span> </ng-template> <ng-template [ngIf]="showProcessDot"> <span class="ant-steps-icon"> <ng-template #processDotTemplate> <span class="ant-steps-icon-dot"></span> </ng-template> <ng-template [ngTemplateOutlet]="customProcessTemplate || processDotTemplate" [ngTemplateOutletContext]="{ $implicit: processDotTemplate, status: nzStatus, index: index }" > </ng-template> </span> </ng-template> </div> <div class="ant-steps-item-content"> <div class="ant-steps-item-title"> <ng-container *nzStringTemplateOutlet="nzTitle">{{ nzTitle }}</ng-container> <div *ngIf="nzSubtitle" class="ant-steps-item-subtitle"> <ng-container *nzStringTemplateOutlet="nzSubtitle">{{ nzSubtitle }}</ng-container> </div> </div> <div class="ant-steps-item-description"> <ng-container *nzStringTemplateOutlet="nzDescription">{{ nzDescription }}</ng-container> </div> </div> </div> `, host: { class: 'ant-steps-item', '[class.ant-steps-item-wait]': 'nzStatus === "wait"', '[class.ant-steps-item-process]': 'nzStatus === "process"', '[class.ant-steps-item-finish]': 'nzStatus === "finish"', '[class.ant-steps-item-error]': 'nzStatus === "error"', '[class.ant-steps-item-active]': 'currentIndex === index', '[class.ant-steps-item-disabled]': 'nzDisabled', '[class.ant-steps-item-custom]': '!!nzIcon', '[class.ant-steps-next-error]': '(outStatus === "error") && (currentIndex === index + 1)' } }] } ]; /** @nocollapse */ NzStepComponent.ctorParameters = () => [ { type: ChangeDetectorRef } ]; NzStepComponent.propDecorators = { processDotTemplate: [{ type: ViewChild, args: ['processDotTemplate', { static: false },] }], nzTitle: [{ type: Input }], nzSubtitle: [{ type: Input }], nzDescription: [{ type: Input }], nzDisabled: [{ type: Input }], nzStatus: [{ type: Input }], nzIcon: [{ type: Input }] }; __decorate([ InputBoolean(), __metadata("design:type", Object) ], NzStepComponent.prototype, "nzDisabled", void 0); if (false) { /** @type {?} */ NzStepComponent.ngAcceptInputType_nzDisabled; /** @type {?} */ NzStepComponent.prototype.processDotTemplate; /** @type {?} */ NzStepComponent.prototype.nzTitle; /** @type {?} */ NzStepComponent.prototype.nzSubtitle; /** @type {?} */ NzStepComponent.prototype.nzDescription; /** @type {?} */ NzStepComponent.prototype.nzDisabled; /** @type {?} */ NzStepComponent.prototype.isCustomStatus; /** * @type {?} * @private */ NzStepComponent.prototype._status; /** @type {?} */ NzStepComponent.prototype.oldAPIIcon; /** @type {?} */ NzStepComponent.prototype.isIconString; /** * @type {?} * @private */ NzStepComponent.prototype._icon; /** @type {?} */ NzStepComponent.prototype.customProcessTemplate; /** @type {?} */ NzStepComponent.prototype.direction; /** @type {?} */ NzStepComponent.prototype.index; /** @type {?} */ NzStepComponent.prototype.last; /** @type {?} */ NzStepComponent.prototype.outStatus; /** @type {?} */ NzStepComponent.prototype.showProcessDot; /** @type {?} */ NzStepComponent.prototype.clickable; /** @type {?} */ NzStepComponent.prototype.click$; /** * @type {?} * @private */ NzStepComponent.prototype._currentIndex; /** * @type {?} * @private */ NzStepComponent.prototype.cdr; } /** * @fileoverview added by tsickle * Generated from: steps.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class NzStepsComponent { constructor() { this.nzCurrent = 0; this.nzDirection = 'horizontal'; this.nzLabelPlacement = 'horizontal'; this.nzType = 'default'; this.nzSize = 'default'; this.nzStartIndex = 0; this.nzStatus = 'process'; this.nzIndexChange = new EventEmitter(); this.destroy$ = new Subject(); this.showProcessDot = false; } /** * @param {?} value * @return {?} */ set nzProgressDot(value) { if (value instanceof TemplateRef) { this.showProcessDot = true; this.customProcessDotTemplate = value; } else { this.showProcessDot = toBoolean(value); } this.updateChildrenSteps(); } /** * @param {?} changes * @return {?} */ ngOnChanges(changes) { if (changes.nzStartIndex || changes.nzDirection || changes.nzStatus || changes.nzCurrent) { this.updateChildrenSteps(); } if (changes.nzDirection || changes.nzProgressDot || changes.nzLabelPlacement || changes.nzSize) { this.setClassMap(); } } /** * @return {?} */ ngOnInit() { this.setClassMap(); this.updateChildrenSteps(); } /** * @return {?} */ ngOnDestroy() { this.destroy$.next(); this.destroy$.complete(); if (this.indexChangeSubscription) { this.indexChangeSubscription.unsubscribe(); } } /** * @return {?} */ ngAfterContentInit() { if (this.steps) { this.steps.changes.pipe(startWith(null), takeUntil(this.destroy$)).subscribe((/** * @return {?} */ () => { this.updateChildrenSteps(); })); } } /** * @private * @return {?} */ updateChildrenSteps() { if (this.steps) { /** @type {?} */ const length = this.steps.length; this.steps.toArray().forEach((/** * @param {?} step * @param {?} index * @return {?} */ (step, index) => { Promise.resolve().then((/** * @return {?} */ () => { step.outStatus = this.nzStatus; step.showProcessDot = this.showProcessDot; if (this.customProcessDotTemplate) { step.customProcessTemplate = this.customProcessDotTemplate; } step.clickable = this.nzIndexChange.observers.length > 0; step.direction = this.nzDirection; step.index = index + this.nzStartIndex; step.currentIndex = this.nzCurrent; step.last = length === index + 1; step.markForCheck(); })); })); if (this.indexChangeSubscription) { this.indexChangeSubscription.unsubscribe(); } this.indexChangeSubscription = merge(...this.steps.map((/** * @param {?} step * @return {?} */ step => step.click$))).subscribe((/** * @param {?} index * @return {?} */ index => this.nzIndexChange.emit(index))); } } /** * @private * @return {?} */ setClassMap() { this.classMap = { [`ant-steps-${this.nzDirection}`]: true, [`ant-steps-label-horizontal`]: this.nzDirection === 'horizontal', [`ant-steps-label-vertical`]: (this.showProcessDot || this.nzLabelPlacement === 'vertical') && this.nzDirection === 'horizontal', [`ant-steps-dot`]: this.showProcessDot, ['ant-steps-small']: this.nzSize === 'small', ['ant-steps-navigation']: this.nzType === 'navigation' }; } } NzStepsComponent.decorators = [ { type: Component, args: [{ changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, selector: 'nz-steps', exportAs: 'nzSteps', template: ` <div class="ant-steps" [ngClass]="classMap"> <ng-content></ng-content> </div> ` }] } ]; NzStepsComponent.propDecorators = { steps: [{ type: ContentChildren, args: [NzStepComponent,] }], nzCurrent: [{ type: Input }], nzDirection: [{ type: Input }], nzLabelPlacement: [{ type: Input }], nzType: [{ type: Input }], nzSize: [{ type: Input }], nzStartIndex: [{ type: Input }], nzStatus: [{ type: Input }], nzProgressDot: [{ type: Input }], nzIndexChange: [{ type: Output }] }; if (false) { /** @type {?} */ NzStepsComponent.ngAcceptInputType_nzProgressDot; /** @type {?} */ NzStepsComponent.prototype.steps; /** @type {?} */ NzStepsComponent.prototype.nzCurrent; /** @type {?} */ NzStepsComponent.prototype.nzDirection; /** @type {?} */ NzStepsComponent.prototype.nzLabelPlacement; /** @type {?} */ NzStepsComponent.prototype.nzType; /** @type {?} */ NzStepsComponent.prototype.nzSize; /** @type {?} */ NzStepsComponent.prototype.nzStartIndex; /** @type {?} */ NzStepsComponent.prototype.nzStatus; /** @type {?} */ NzStepsComponent.prototype.nzIndexChange; /** * @type {?} * @private */ NzStepsComponent.prototype.destroy$; /** * @type {?} * @private */ NzStepsComponent.prototype.indexChangeSubscription; /** @type {?} */ NzStepsComponent.prototype.showProcessDot; /** @type {?} */ NzStepsComponent.prototype.customProcessDotTemplate; /** @type {?} */ NzStepsComponent.prototype.classMap; } /** * @fileoverview added by tsickle * Generated from: steps.module.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class NzStepsModule { } NzStepsModule.decorators = [ { type: NgModule, args: [{ imports: [CommonModule, NzIconModule, NzOutletModule], exports: [NzStepsComponent, NzStepComponent], declarations: [NzStepsComponent, NzStepComponent] },] } ]; /** * @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-steps.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ export { NzStepComponent, NzStepsComponent, NzStepsModule }; //# sourceMappingURL=ng-zorro-antd-steps.js.map