@duoduo-oba/ng-devui
Version:
DevUI components based on Angular
148 lines (142 loc) • 7.3 kB
JavaScript
import { Component, Input, ContentChild, TemplateRef, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
/**
* @fileoverview added by tsickle
* Generated from: progress.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var ProgressComponent = /** @class */ (function () {
function ProgressComponent() {
this.percentage = 0;
this.height = '20px';
this.strokeWidth = 6; // 设置圈形进度条宽度,进度条与画布宽度的百分比
// 设置圈形进度条宽度,进度条与画布宽度的百分比
this.isCircle = false;
}
/**
* @return {?}
*/
ProgressComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
if (this.isCircle) {
this.setCircleProgress();
}
};
/**
* @param {?} changes
* @return {?}
*/
ProgressComponent.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
if (this.isCircle) {
this.setCircleProgress();
}
};
/**
* @return {?}
*/
ProgressComponent.prototype.setCircleProgress = /**
* @return {?}
*/
function () {
if (!this.isCircle) {
return;
}
/** @type {?} */
var radius = 50 - this.strokeWidth / 2;
/** @type {?} */
var beginPositionY = -radius;
/** @type {?} */
var endPositionY = radius * -2;
this.pathString = "M 50,50 m 0," + beginPositionY + "\n a " + radius + "," + radius + " 0 1 1 0," + -endPositionY + "\n a " + radius + "," + radius + " 0 1 1 0," + endPositionY;
/** @type {?} */
var len = Math.PI * 2 * radius;
this.trailPath = {
strokeDasharray: len + "px " + len + "px",
strokeDashoffset: "0",
transition: 'stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s'
};
this.strokePath = {
stroke: this.barbgcolor || ((/** @type {?} */ (null))),
strokeDasharray: (this.percentage / 100) * len + "px " + len + "px",
strokeDashoffset: "0",
transition: 'stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s'
};
};
ProgressComponent.decorators = [
{ type: Component, args: [{
selector: 'd-progress',
template: "<div *ngIf=\"!isCircle\" class=\"devui-progress\" [ngStyle]=\"{ height: height }\">\r\n <div\r\n class=\"devui-progress-bar\"\r\n role=\"progressbar\"\r\n aria-valuenow=\"60\"\r\n aria-valuemin=\"0\"\r\n aria-valuemax=\"100\"\r\n [style.background-color]=\"barbgcolor\"\r\n [style.width]=\"percentage + '%'\"\r\n ></div>\r\n <span [style.line-height]=\"height\">{{ percentageText }}</span>\r\n</div>\r\n<div *ngIf=\"isCircle\" class=\"devui-progress-circle\">\r\n <svg class=\"devui-progress-circle \" viewBox=\"0 0 100 100\">\r\n <path\r\n class=\"devui-progress-circle-trail\"\r\n fill-opacity=\"0\"\r\n [attr.stroke-width]=\"strokeWidth\"\r\n [ngStyle]=\"trailPath\"\r\n [attr.d]=\"pathString\"\r\n ></path>\r\n <path\r\n class=\"devui-progress-circle-path\"\r\n [attr.d]=\"pathString\"\r\n [attr.stroke-linecap]=\"'round'\"\r\n fill-opacity=\"0\"\r\n [attr.stroke]=\"barbgcolor\"\r\n [attr.stroke-width]=\"percentage ? strokeWidth : 0\"\r\n [ngStyle]=\"strokePath\"\r\n ></path>\r\n </svg>\r\n <ng-template\r\n *ngIf=\"customViewTemplate\"\r\n [ngTemplateOutlet]=\"customViewTemplate\"\r\n [ngTemplateOutletContext]=\"{$implicit: this, percentage:percentage}\"\r\n ></ng-template>\r\n <span *ngIf=\"!customViewTemplate\" class=\"devui-progress-circle-text\">{{ percentage }}%</span>\r\n</div>\r\n",
styles: [":host{display:block}.devui-progress{position:relative;border-radius:100px;background:#dfe1e6}.devui-progress .devui-progress-bar{width:0;height:100%;box-shadow:inset 0 -1px 0 rgba(41,48,64,.2);-webkit-transition:width .6s;transition:width .6s;border-radius:100px;background-color:#5e7ce0}.devui-progress>span{display:block;white-space:nowrap;color:#fff;text-align:center;position:absolute;left:0;top:0;height:100%;width:100%;font-size:12px}.devui-progress-circle{position:relative}.devui-progress-circle-text{position:absolute;top:50%;left:50%;width:100%;margin:0;padding:0;color:#252b3a;line-height:1;white-space:normal;text-align:center;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.devui-progress-circle-trail{stroke:#dfe1e6}.devui-progress-circle-path{stroke:#5e7ce0}"]
}] }
];
/** @nocollapse */
ProgressComponent.ctorParameters = function () { return []; };
ProgressComponent.propDecorators = {
percentage: [{ type: Input }],
percentageText: [{ type: Input }],
barbgcolor: [{ type: Input }],
height: [{ type: Input }],
strokeWidth: [{ type: Input }],
isCircle: [{ type: Input }],
customViewTemplate: [{ type: ContentChild, args: [TemplateRef, { static: false },] }]
};
return ProgressComponent;
}());
if (false) {
/** @type {?} */
ProgressComponent.prototype.percentage;
/** @type {?} */
ProgressComponent.prototype.percentageText;
/** @type {?} */
ProgressComponent.prototype.barbgcolor;
/** @type {?} */
ProgressComponent.prototype.height;
/** @type {?} */
ProgressComponent.prototype.strokeWidth;
/** @type {?} */
ProgressComponent.prototype.isCircle;
/** @type {?} */
ProgressComponent.prototype.customViewTemplate;
/** @type {?} */
ProgressComponent.prototype.trailPath;
/** @type {?} */
ProgressComponent.prototype.strokePath;
/** @type {?} */
ProgressComponent.prototype.pathString;
}
/**
* @fileoverview added by tsickle
* Generated from: progress.module.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var ProgressModule = /** @class */ (function () {
function ProgressModule() {
}
ProgressModule.decorators = [
{ type: NgModule, args: [{
imports: [CommonModule],
exports: [ProgressComponent],
declarations: [ProgressComponent],
providers: [],
},] }
];
return ProgressModule;
}());
/**
* @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-devui-progress.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
export { ProgressComponent, ProgressModule };
//# sourceMappingURL=ng-devui-progress.js.map