ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
268 lines (262 loc) • 11.8 kB
JavaScript
import { CommonModule } from '@angular/common';
import { NzIconModule } from 'ng-zorro-antd/icon';
import { __decorate, __metadata } from 'tslib';
import { ChangeDetectionStrategy, Component, Input, ViewEncapsulation, NgModule } from '@angular/core';
import { isNotNil, InputNumber } from 'ng-zorro-antd/core';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzProgressComponent = /** @class */ (function () {
function NzProgressComponent() {
this.nzShowInfo = true;
this.nzWidth = 132;
this.nzType = 'line';
this.nzStrokeLinecap = 'round';
this.statusColorMap = {
normal: '#108ee9',
exception: '#ff5500',
success: '#87d068'
};
this.cachedStatus = 'normal';
this.inferredStatus = 'normal';
this.inferredStrokeWidth = 8;
}
Object.defineProperty(NzProgressComponent.prototype, "formatter", {
get: /**
* @return {?}
*/
function () {
return this.nzFormat || ((/**
* @param {?} p
* @return {?}
*/
function (p) { return p + "%"; }));
},
enumerable: true,
configurable: true
});
Object.defineProperty(NzProgressComponent.prototype, "status", {
get: /**
* @return {?}
*/
function () {
return this.nzStatus || this.inferredStatus;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NzProgressComponent.prototype, "strokeWidth", {
get: /**
* @return {?}
*/
function () {
return this.nzStrokeWidth || this.inferredStrokeWidth;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NzProgressComponent.prototype, "isCircleStyle", {
get: /**
* @return {?}
*/
function () {
return this.nzType === 'circle' || this.nzType === 'dashboard';
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
NzProgressComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
this.updatePathStyles();
this.updateIcon();
};
/**
* @param {?} changes
* @return {?}
*/
NzProgressComponent.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
var nzGapPosition = changes.nzGapPosition, nzStrokeLinecap = changes.nzStrokeLinecap, nzGapDegree = changes.nzGapDegree, nzType = changes.nzType, nzSize = changes.nzSize, nzStatus = changes.nzStatus, nzPercent = changes.nzPercent, nzSuccessPercent = changes.nzSuccessPercent;
if (nzGapPosition || nzStrokeLinecap || nzGapDegree || nzType || nzPercent) {
this.updatePathStyles();
}
if (nzSize) {
if (this.nzSize === 'small') {
this.inferredStrokeWidth = 6;
}
}
if (nzStatus) {
this.cachedStatus = this.nzStatus || this.cachedStatus;
this.updateIcon();
}
if (nzPercent || nzSuccessPercent) {
/** @type {?} */
var fillAll = parseInt(this.nzPercent.toString(), 10) >= 100;
if (fillAll) {
if ((isNotNil(this.nzSuccessPercent) && (/** @type {?} */ (this.nzSuccessPercent)) >= 100) || this.nzSuccessPercent === undefined) {
this.inferredStatus = 'success';
}
}
else {
this.inferredStatus = this.cachedStatus;
}
this.updateIcon();
}
if (nzType) {
if (this.nzType !== 'line') {
this.inferredStrokeWidth = 6;
}
if (this.nzType === 'dashboard') {
this.inferredGapPosition = 'bottom';
this.inferredGapDegree = 75;
}
if (this.nzType === 'circle') {
this.inferredGapDegree = 0;
}
}
};
/**
* @return {?}
*/
NzProgressComponent.prototype.updatePathStyles = /**
* @return {?}
*/
function () {
/** @type {?} */
var radius = 50 - this.strokeWidth / 2;
/** @type {?} */
var gapPosition = this.nzGapPosition || this.inferredGapPosition;
/** @type {?} */
var beginPositionX = 0;
/** @type {?} */
var beginPositionY = -radius;
/** @type {?} */
var endPositionX = 0;
/** @type {?} */
var endPositionY = radius * -2;
switch (gapPosition) {
case 'left':
beginPositionX = -radius;
beginPositionY = 0;
endPositionX = radius * 2;
endPositionY = 0;
break;
case 'right':
beginPositionX = radius;
beginPositionY = 0;
endPositionX = radius * -2;
endPositionY = 0;
break;
case 'bottom':
beginPositionY = radius;
endPositionY = radius * 2;
break;
default:
}
this.pathString = "M 50,50 m " + beginPositionX + "," + beginPositionY + "\n a " + radius + "," + radius + " 0 1 1 " + endPositionX + "," + -endPositionY + "\n a " + radius + "," + radius + " 0 1 1 " + -endPositionX + "," + endPositionY;
/** @type {?} */
var len = Math.PI * 2 * radius;
/** @type {?} */
var gapDegree = this.nzGapDegree || this.inferredGapDegree;
this.trailPathStyle = {
strokeDasharray: len - gapDegree + "px " + len + "px",
strokeDashoffset: "-" + gapDegree / 2 + "px",
transition: 'stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s'
};
this.strokePathStyle = {
strokeDasharray: (this.nzPercent / 100) * (len - gapDegree) + "px " + len + "px",
strokeDashoffset: "-" + gapDegree / 2 + "px",
transition: 'stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s' // eslint-disable-line
};
};
/**
* @return {?}
*/
NzProgressComponent.prototype.updateIcon = /**
* @return {?}
*/
function () {
/** @type {?} */
var isCircle = this.nzType === 'circle' || this.nzType === 'dashboard';
/** @type {?} */
var ret = this.status === 'success' ? 'check' : this.status === 'exception' ? 'close' : '';
this.icon = ret ? ret + (isCircle ? '-o' : '-circle-fill') : '';
};
NzProgressComponent.decorators = [
{ type: Component, args: [{
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
selector: 'nz-progress',
exportAs: 'nzProgress',
preserveWhitespaces: false,
template: "<ng-template #progressInfoTemplate>\n <span class=\"ant-progress-text\" *ngIf=\"nzShowInfo\">\n <ng-container *ngIf=\"status === 'exception' || (status === 'success' && !nzFormat); else formatTemplate\">\n <i nz-icon [nzType]=\"icon\"></i>\n </ng-container>\n <ng-template #formatTemplate>\n {{ formatter(nzPercent) }}\n </ng-template>\n </span>\n</ng-template>\n<div\n [ngClass]=\"'ant-progress ant-progress-status-' + status\"\n [class.ant-progress-line]=\"nzType == 'line'\"\n [class.ant-progress-small]=\"nzSize == 'small'\"\n [class.ant-progress-show-info]=\"nzShowInfo\"\n [class.ant-progress-circle]=\"isCircleStyle\"\n>\n <!-- Line progress -->\n <div *ngIf=\"nzType === 'line'\">\n <div class=\"ant-progress-outer\">\n <div class=\"ant-progress-inner\">\n <div\n class=\"ant-progress-bg\"\n [style.width.%]=\"nzPercent\"\n [style.border-radius]=\"nzStrokeLinecap === 'round' ? '100px' : '0'\"\n [style.background]=\"nzStrokeColor\"\n [style.height.px]=\"strokeWidth\"\n ></div>\n <div\n class=\"ant-progress-success-bg\"\n [style.width.%]=\"nzSuccessPercent\"\n [style.border-radius]=\"nzStrokeLinecap === 'round' ? '100px' : '0'\"\n [style.height.px]=\"strokeWidth\"\n ></div>\n </div>\n </div>\n <ng-template [ngTemplateOutlet]=\"progressInfoTemplate\"></ng-template>\n </div>\n <!-- Circle/Dashboard progress -->\n <div\n [style.width.px]=\"this.nzWidth\"\n [style.height.px]=\"this.nzWidth\"\n [style.fontSize.px]=\"this.nzWidth * 0.15 + 6\"\n class=\"ant-progress-inner\"\n *ngIf=\"isCircleStyle\"\n >\n <svg class=\"ant-progress-circle \" viewBox=\"0 0 100 100\">\n <path\n class=\"ant-progress-circle-trail\"\n stroke=\"#f3f3f3\"\n fill-opacity=\"0\"\n [attr.stroke-width]=\"strokeWidth\"\n [ngStyle]=\"trailPathStyle\"\n [attr.d]=\"pathString\"\n ></path>\n <path\n class=\"ant-progress-circle-path\"\n [attr.d]=\"pathString\"\n [attr.stroke-linecap]=\"nzStrokeLinecap\"\n fill-opacity=\"0\"\n [attr.stroke]=\"nzStrokeColor || statusColorMap[status]\"\n [attr.stroke-width]=\"nzPercent ? strokeWidth : 0\"\n [ngStyle]=\"strokePathStyle\"\n ></path>\n </svg>\n <ng-template [ngTemplateOutlet]=\"progressInfoTemplate\"></ng-template>\n </div>\n</div>\n"
}] }
];
NzProgressComponent.propDecorators = {
nzShowInfo: [{ type: Input }],
nzWidth: [{ type: Input }],
nzStrokeColor: [{ type: Input }],
nzSize: [{ type: Input }],
nzFormat: [{ type: Input }],
nzSuccessPercent: [{ type: Input }],
nzPercent: [{ type: Input }],
nzStrokeWidth: [{ type: Input }],
nzGapDegree: [{ type: Input }],
nzStatus: [{ type: Input }],
nzType: [{ type: Input }],
nzGapPosition: [{ type: Input }],
nzStrokeLinecap: [{ type: Input }]
};
__decorate([
InputNumber(),
__metadata("design:type", Number)
], NzProgressComponent.prototype, "nzSuccessPercent", void 0);
__decorate([
InputNumber(),
__metadata("design:type", Number)
], NzProgressComponent.prototype, "nzPercent", void 0);
__decorate([
InputNumber(),
__metadata("design:type", Number)
], NzProgressComponent.prototype, "nzStrokeWidth", void 0);
__decorate([
InputNumber(),
__metadata("design:type", Number)
], NzProgressComponent.prototype, "nzGapDegree", void 0);
return NzProgressComponent;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzProgressModule = /** @class */ (function () {
function NzProgressModule() {
}
NzProgressModule.decorators = [
{ type: NgModule, args: [{
exports: [NzProgressComponent],
declarations: [NzProgressComponent],
imports: [CommonModule, NzIconModule]
},] }
];
return NzProgressModule;
}());
/**
* @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
*/
export { NzProgressModule, NzProgressComponent };
//# sourceMappingURL=ng-zorro-antd-progress.js.map