ngx-bootstrap
Version:
Native Angular Bootstrap Components
2 lines • 5.02 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("ngx-bootstrap/utils"),require("@angular/common")):"function"==typeof define&&define.amd?define("ngx-bootstrap/progressbar",["exports","@angular/core","ngx-bootstrap/utils","@angular/common"],t):t(((e=e||self)["ngx-bootstrap"]=e["ngx-bootstrap"]||{},e["ngx-bootstrap"].progressbar={}),e.ng.core,e.utils,e.ng.common)}(this,(function(e,t,r,n){"use strict";var s=function(){function e(){this.animate=!1,this.max=100}return e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵprov=t["ɵɵdefineInjectable"]({factory:function(){return new e},token:e,providedIn:"root"}),e}();var a=function(){function e(e){this.isStacked=!1,this.addClass=!0,this.bars=[],this._max=100,Object.assign(this,e)}return Object.defineProperty(e.prototype,"animate",{set:function(e){this._animate=e,this.bars.forEach((function(t){t.animate=e}))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"striped",{set:function(e){this._striped=e,this.bars.forEach((function(t){t.striped=e}))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"value",{set:function(e){this.isStacked=Array.isArray(e),this._value=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isBs3",{get:function(){return r.isBs3()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"max",{get:function(){return this._max},set:function(e){this._max=e,this.bars.forEach((function(e){e.recalculatePercentage()}))},enumerable:!0,configurable:!0}),e.prototype.addBar=function(e){e.animate=this._animate,e.striped=this._striped,this.bars.push(e)},e.prototype.removeBar=function(e){this.bars.splice(this.bars.indexOf(e),1)},e.decorators=[{type:t.Component,args:[{selector:"progressbar",template:'<bar [type]="type" [value]="_value" *ngIf="!isStacked">\n <ng-content></ng-content>\n</bar>\n<ng-template [ngIf]="isStacked">\n <bar *ngFor="let item of _value" [type]="item.type" [value]="item.value">{{ item.label }}</bar>\n</ng-template>\n',styles:["\n :host {\n width: 100%;\n display: flex;\n }\n "]}]}],e.ctorParameters=function(){return[{type:s}]},e.propDecorators={animate:[{type:t.Input}],striped:[{type:t.Input}],type:[{type:t.Input}],value:[{type:t.Input}],max:[{type:t.HostBinding,args:["attr.max"]},{type:t.Input}],addClass:[{type:t.HostBinding,args:["class.progress"]}]},e}();var o=function(){function e(e,t,r){this.el=e,this.renderer=r,this.addClass=!0,this.percent=0,this.progress=t}return Object.defineProperty(e.prototype,"type",{get:function(){return this._type},set:function(e){this._type=e,this.applyTypeClasses()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._value},set:function(e){(e||0===e)&&(this._value=e,this.recalculatePercentage())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"setBarWidth",{get:function(){return this.recalculatePercentage(),this.percent},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isBs3",{get:function(){return r.isBs3()},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){this.progress.addBar(this)},e.prototype.ngOnDestroy=function(){this.progress.removeBar(this)},e.prototype.recalculatePercentage=function(){this.percent=+(this.value/this.progress.max*100).toFixed(2);var e=this.progress.bars.reduce((function(e,t){return e+t.percent}),0);e>100&&(this.percent-=e-100)},e.prototype.applyTypeClasses=function(){if(this._prevType){var e="progress-bar-"+this._prevType,t="bg-"+this._prevType;this.renderer.removeClass(this.el.nativeElement,e),this.renderer.removeClass(this.el.nativeElement,t),this._prevType=null}if(this._type){e="progress-bar-"+this._type,t="bg-"+this._type;this.renderer.addClass(this.el.nativeElement,e),this.renderer.addClass(this.el.nativeElement,t),this._prevType=this._type}},e.decorators=[{type:t.Component,args:[{selector:"bar",template:"<ng-content></ng-content>\n",host:{role:"progressbar","aria-valuemin":"0","[class.progress-bar-animated]":"!isBs3 && animate","[class.progress-bar-striped]":"striped","[class.active]":"isBs3 && animate","[attr.aria-valuenow]":"value","[attr.aria-valuetext]":'percent ? percent.toFixed(0) + "%" : ""',"[attr.aria-valuemax]":"max","[style.height.%]":'"100"'}}]}],e.ctorParameters=function(){return[{type:t.ElementRef},{type:a,decorators:[{type:t.Host}]},{type:t.Renderer2}]},e.propDecorators={type:[{type:t.Input}],value:[{type:t.Input}],setBarWidth:[{type:t.HostBinding,args:["style.width.%"]}],addClass:[{type:t.HostBinding,args:["class.progress-bar"]}]},e}();var i=function(){function e(){}return e.forRoot=function(){return{ngModule:e,providers:[]}},e.decorators=[{type:t.NgModule,args:[{imports:[n.CommonModule],declarations:[o,a],exports:[o,a]}]}],e}();e.BarComponent=o,e.ProgressbarComponent=a,e.ProgressbarConfig=s,e.ProgressbarModule=i,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=ngx-bootstrap-progressbar.umd.min.js.map