UNPKG

ng-zorro-antd

Version:

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

324 lines (315 loc) 14.4 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs'), require('rxjs/operators'), require('@angular/common'), require('@angular/core'), require('ng-zorro-antd/core'), require('ng-zorro-antd/icon')) : typeof define === 'function' && define.amd ? define('ng-zorro-antd/steps', ['exports', 'rxjs', 'rxjs/operators', '@angular/common', '@angular/core', 'ng-zorro-antd/core', 'ng-zorro-antd/icon'], factory) : (factory((global['ng-zorro-antd'] = global['ng-zorro-antd'] || {}, global['ng-zorro-antd'].steps = {}),global.rxjs,global.rxjs.operators,global.ng.common,global.ng.core,global['ng-zorro-antd'].core,global['ng-zorro-antd'].icon)); }(this, (function (exports,rxjs,operators,common,core,core$1,icon) { 'use strict'; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var NzStepComponent = /** @class */ (function () { function NzStepComponent(cdr, renderer, elementRef) { this.cdr = cdr; 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._currentIndex = 0; renderer.addClass(elementRef.nativeElement, 'ant-steps-item'); } Object.defineProperty(NzStepComponent.prototype, "nzStatus", { get: /** * @return {?} */ function () { return this._status; }, set: /** * @param {?} status * @return {?} */ function (status) { this._status = status; this.isCustomStatus = true; }, enumerable: true, configurable: true }); Object.defineProperty(NzStepComponent.prototype, "nzIcon", { get: /** * @return {?} */ function () { return this._icon; }, set: /** * @param {?} value * @return {?} */ function (value) { if (!(value instanceof core.TemplateRef)) { this.isIconString = true; this.oldAPIIcon = typeof value === 'string' && value.indexOf('anticon') > -1; } else { this.isIconString = false; } this._icon = value; }, enumerable: true, configurable: true }); Object.defineProperty(NzStepComponent.prototype, "currentIndex", { get: /** * @return {?} */ function () { return this._currentIndex; }, set: /** * @param {?} current * @return {?} */ function (current) { this._currentIndex = current; if (!this.isCustomStatus) { this._status = current > this.index ? 'finish' : current === this.index ? this.outStatus || '' : 'wait'; } }, enumerable: true, configurable: true }); /** * @return {?} */ NzStepComponent.prototype.markForCheck = /** * @return {?} */ function () { this.cdr.markForCheck(); }; NzStepComponent.decorators = [ { type: core.Component, args: [{ changeDetection: core.ChangeDetectionStrategy.OnPush, encapsulation: core.ViewEncapsulation.None, selector: 'nz-step', exportAs: 'nzStep', preserveWhitespaces: false, template: "<div class=\"ant-steps-item-tail\" *ngIf=\"last !== true\"></div>\n<div class=\"ant-steps-item-icon\">\n <ng-template [ngIf]=\"!showProcessDot\">\n <span class=\"ant-steps-icon\" *ngIf=\"nzStatus === 'finish' && !nzIcon\"><i nz-icon type=\"check\"></i></span>\n <span class=\"ant-steps-icon\" *ngIf=\"nzStatus === 'error'\"><i nz-icon type=\"close\"></i></span>\n <span class=\"ant-steps-icon\" *ngIf=\"(nzStatus === 'process' || nzStatus === 'wait') && !nzIcon\">{{ index + 1 }}</span>\n <span class=\"ant-steps-icon\" *ngIf=\"nzIcon\">\n <ng-container *ngIf=\"isIconString; else iconTemplate\">\n <i nz-icon [type]=\"!oldAPIIcon && nzIcon\" [ngClass]=\"oldAPIIcon && nzIcon\"></i>\n </ng-container>\n <ng-template #iconTemplate>\n <ng-template [ngTemplateOutlet]=\"nzIcon\"></ng-template>\n </ng-template>\n </span>\n </ng-template>\n <ng-template [ngIf]=\"showProcessDot\">\n <span class=\"ant-steps-icon\">\n <ng-template #processDotTemplate>\n <span class=\"ant-steps-icon-dot\"></span>\n </ng-template>\n <ng-template\n [ngTemplateOutlet]=\"customProcessTemplate||processDotTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: processDotTemplate, status:nzStatus, index:index }\">\n </ng-template>\n </span>\n </ng-template>\n</div>\n<div class=\"ant-steps-item-content\">\n <div class=\"ant-steps-item-title\">\n <ng-container *nzStringTemplateOutlet=\"nzTitle\">{{ nzTitle }}</ng-container>\n </div>\n <div class=\"ant-steps-item-description\">\n <ng-container *nzStringTemplateOutlet=\"nzDescription\">{{ nzDescription }}</ng-container>\n </div>\n</div>\n", host: { '[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-custom]': '!!nzIcon', '[class.ant-steps-next-error]': '(outStatus === "error") && (currentIndex === index + 1)' } }] } ]; /** @nocollapse */ NzStepComponent.ctorParameters = function () { return [ { type: core.ChangeDetectorRef }, { type: core.Renderer2 }, { type: core.ElementRef } ]; }; NzStepComponent.propDecorators = { processDotTemplate: [{ type: core.ViewChild, args: ['processDotTemplate',] }], nzTitle: [{ type: core.Input }], nzDescription: [{ type: core.Input }], nzStatus: [{ type: core.Input }], nzIcon: [{ type: core.Input }] }; return NzStepComponent; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var NzStepsComponent = /** @class */ (function () { function NzStepsComponent() { this.nzCurrent = 0; this.nzDirection = 'horizontal'; this.nzLabelPlacement = 'horizontal'; this.nzSize = 'default'; this.nzStartIndex = 0; this.nzStatus = 'process'; this.showProcessDot = false; this.destroy$ = new rxjs.Subject(); } Object.defineProperty(NzStepsComponent.prototype, "nzProgressDot", { set: /** * @param {?} value * @return {?} */ function (value) { if (value instanceof core.TemplateRef) { this.showProcessDot = true; this.customProcessDotTemplate = value; } else { this.showProcessDot = core$1.toBoolean(value); } this.updateChildrenSteps(); }, enumerable: true, configurable: true }); /** * @param {?} changes * @return {?} */ NzStepsComponent.prototype.ngOnChanges = /** * @param {?} changes * @return {?} */ function (changes) { if (changes.nzStartIndex || changes.nzDirection || changes.nzStatus || changes.nzCurrent) { this.updateChildrenSteps(); } if (changes.nzDirection || changes.nzProgressDot || changes.nzLabelPlacement || changes.nzSize) { this.setClassMap(); } }; /** * @return {?} */ NzStepsComponent.prototype.ngOnInit = /** * @return {?} */ function () { this.setClassMap(); this.updateChildrenSteps(); }; /** * @return {?} */ NzStepsComponent.prototype.ngOnDestroy = /** * @return {?} */ function () { this.destroy$.next(); this.destroy$.complete(); }; /** * @return {?} */ NzStepsComponent.prototype.ngAfterContentInit = /** * @return {?} */ function () { var _this = this; this.updateChildrenSteps(); if (this.steps) { this.steps.changes.pipe(operators.takeUntil(this.destroy$)).subscribe(( /** * @return {?} */function () { _this.updateChildrenSteps(); })); } }; /** * @private * @return {?} */ NzStepsComponent.prototype.updateChildrenSteps = /** * @private * @return {?} */ function () { var _this = this; if (this.steps) { /** @type {?} */ var length_1 = this.steps.length; this.steps.toArray().forEach(( /** * @param {?} step * @param {?} index * @return {?} */function (step, index) { Promise.resolve().then(( /** * @return {?} */function () { step.outStatus = _this.nzStatus; step.showProcessDot = _this.showProcessDot; if (_this.customProcessDotTemplate) { step.customProcessTemplate = _this.customProcessDotTemplate; } step.direction = _this.nzDirection; step.index = index + _this.nzStartIndex; step.currentIndex = _this.nzCurrent; step.last = length_1 === index + 1; step.markForCheck(); })); })); } }; /** * @private * @return {?} */ NzStepsComponent.prototype.setClassMap = /** * @private * @return {?} */ function () { var _a; this.classMap = (_a = {}, _a["ant-steps-" + this.nzDirection] = true, _a["ant-steps-label-horizontal"] = this.nzDirection === 'horizontal', _a["ant-steps-label-vertical"] = (this.showProcessDot || this.nzLabelPlacement === 'vertical') && this.nzDirection === 'horizontal', _a["ant-steps-dot"] = this.showProcessDot, _a['ant-steps-small'] = this.nzSize === 'small', _a); }; NzStepsComponent.decorators = [ { type: core.Component, args: [{ changeDetection: core.ChangeDetectionStrategy.OnPush, encapsulation: core.ViewEncapsulation.None, preserveWhitespaces: false, selector: 'nz-steps', exportAs: 'nzSteps', template: "<div class=\"ant-steps\" [ngClass]=\"classMap\">\n <ng-content></ng-content>\n</div>" }] } ]; NzStepsComponent.propDecorators = { steps: [{ type: core.ContentChildren, args: [NzStepComponent,] }], nzCurrent: [{ type: core.Input }], nzDirection: [{ type: core.Input }], nzLabelPlacement: [{ type: core.Input }], nzSize: [{ type: core.Input }], nzStartIndex: [{ type: core.Input }], nzStatus: [{ type: core.Input }], nzProgressDot: [{ type: core.Input }] }; return NzStepsComponent; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var NzStepsModule = /** @class */ (function () { function NzStepsModule() { } NzStepsModule.decorators = [ { type: core.NgModule, args: [{ imports: [common.CommonModule, icon.NzIconModule, core$1.NzAddOnModule], exports: [NzStepsComponent, NzStepComponent], declarations: [NzStepsComponent, NzStepComponent] },] } ]; return NzStepsModule; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ exports.NzStepsComponent = NzStepsComponent; exports.NzStepComponent = NzStepComponent; exports.NzStepsModule = NzStepsModule; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=ng-zorro-antd-steps.umd.js.map