ngx-bootstrap
Version:
Angular Bootstrap
57 lines • 2.33 kB
JavaScript
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { ProgressbarConfig } from './progressbar.config';
export class ProgressbarComponent {
constructor(config) {
/** maximum total value of progress element */
this.max = 100;
/** if `true` changing value of progress bar will be animated */
this.animate = false;
/** If `true`, striped classes are applied */
this.striped = false;
this.isStacked = false;
this._value = 0;
Object.assign(this, config);
}
/** current value of progress bar. Could be a number or array of objects
* like {"value":15,"type":"info","label":"15 %"}
*/
set value(value) {
this.isStacked = Array.isArray(value);
if (typeof value === 'number') {
this._value = value;
this._values = void 0;
}
else {
this._value = void 0;
this._values = value;
}
}
}
ProgressbarComponent.decorators = [
{ type: Component, args: [{
selector: 'progressbar',
template: "<ng-container *ngIf=\"!isStacked then NotStacked else Stacked\"></ng-container>\n\n<ng-template #NotStacked>\n <bar [type]=\"type\" [value]=\"_value\" [max]=\"max\" [animate]=\"animate\" [striped]=\"striped\">\n <ng-content></ng-content>\n </bar>\n</ng-template>\n\n<ng-template #Stacked>\n <bar *ngFor=\"let item of _values\"\n [type]=\"item.type\" [value]=\"item.value\" [max]=\"item.max\" [animate]=\"animate\" [striped]=\"striped\">{{ item.label }}</bar>\n</ng-template>\n",
changeDetection: ChangeDetectionStrategy.OnPush,
// eslint-disable-next-line @angular-eslint/no-host-metadata-property
host: {
'[class.progress]': 'true',
'[attr.max]': 'max'
},
styles: [`
:host {
width: 100%;
display: flex;
} `]
},] }
];
ProgressbarComponent.ctorParameters = () => [
{ type: ProgressbarConfig }
];
ProgressbarComponent.propDecorators = {
max: [{ type: Input }],
animate: [{ type: Input }],
striped: [{ type: Input }],
type: [{ type: Input }],
value: [{ type: Input }]
};
//# sourceMappingURL=progressbar.component.js.map