bootstrap-vue
Version:
BootstrapVue, with over 40 plugins and more than 75 custom components, provides one of the most comprehensive implementations of Bootstrap v4 components and grid system for Vue.js. With extensive and automated WAI-ARIA accessibility markup.
152 lines (140 loc) • 4.67 kB
JavaScript
"use strict";
exports.__esModule = true;
exports.default = exports.BProgressBar = void 0;
var _vue = _interopRequireDefault(require("../../utils/vue"));
var _config = require("../../utils/config");
var _html = require("../../utils/html");
var _inspect = require("../../utils/inspect");
var _normalizeSlot = _interopRequireDefault(require("../../mixins/normalize-slot"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var NAME = 'BProgressBar'; // @vue/component
var BProgressBar =
/*#__PURE__*/
_vue.default.extend({
name: NAME,
mixins: [_normalizeSlot.default],
inject: {
bvProgress: {
default: function _default()
/* istanbul ignore next */
{
return {};
}
}
},
props: {
value: {
type: Number,
default: 0
},
label: {
type: String,
default: null
},
labelHtml: {
type: String
},
// $parent (this.bvProgress) prop values may take precedence over the following props
// Which is why they are defaulted to null
max: {
type: Number,
default: null
},
precision: {
type: Number,
default: null
},
variant: {
type: String,
default: function _default() {
return (0, _config.getComponentConfig)(NAME, 'variant');
}
},
striped: {
type: Boolean,
default: null
},
animated: {
type: Boolean,
default: null
},
showProgress: {
type: Boolean,
default: null
},
showValue: {
type: Boolean,
default: null
}
},
computed: {
progressBarClasses: function progressBarClasses() {
return [this.computedVariant ? "bg-".concat(this.computedVariant) : '', this.computedStriped || this.computedAnimated ? 'progress-bar-striped' : '', this.computedAnimated ? 'progress-bar-animated' : ''];
},
progressBarStyles: function progressBarStyles() {
return {
width: 100 * (this.value / this.computedMax) + '%'
};
},
computedProgress: function computedProgress() {
var p = Math.pow(10, this.computedPrecision);
return Math.round(100 * p * this.value / this.computedMax) / p;
},
computedMax: function computedMax() {
// Prefer our max over parent setting
return (0, _inspect.isNumber)(this.max) ? this.max : this.bvProgress.max || 100;
},
computedVariant: function computedVariant() {
// Prefer our variant over parent setting
return this.variant || this.bvProgress.variant;
},
computedPrecision: function computedPrecision() {
// Prefer our precision over parent setting
return (0, _inspect.isNumber)(this.precision) ? this.precision : this.bvProgress.precision || 0;
},
computedStriped: function computedStriped() {
// Prefer our striped over parent setting
return (0, _inspect.isBoolean)(this.striped) ? this.striped : this.bvProgress.striped || false;
},
computedAnimated: function computedAnimated() {
// Prefer our animated over parent setting
return (0, _inspect.isBoolean)(this.animated) ? this.animated : this.bvProgress.animated || false;
},
computedShowProgress: function computedShowProgress() {
// Prefer our showProgress over parent setting
return (0, _inspect.isBoolean)(this.showProgress) ? this.showProgress : this.bvProgress.showProgress || false;
},
computedShowValue: function computedShowValue() {
// Prefer our showValue over parent setting
return (0, _inspect.isBoolean)(this.showValue) ? this.showValue : this.bvProgress.showValue || false;
}
},
render: function render(h) {
var childNodes = h(false);
if (this.hasNormalizedSlot('default')) {
childNodes = this.normalizeSlot('default');
} else if (this.label || this.labelHtml) {
childNodes = h('span', {
domProps: (0, _html.htmlOrText)(this.labelHtml, this.label)
});
} else if (this.computedShowProgress) {
childNodes = this.computedProgress.toFixed(this.computedPrecision);
} else if (this.computedShowValue) {
childNodes = this.value.toFixed(this.computedPrecision);
}
return h('div', {
staticClass: 'progress-bar',
class: this.progressBarClasses,
style: this.progressBarStyles,
attrs: {
role: 'progressbar',
'aria-valuemin': '0',
'aria-valuemax': this.computedMax.toString(),
'aria-valuenow': this.value.toFixed(this.computedPrecision)
}
}, [childNodes]);
}
});
exports.BProgressBar = BProgressBar;
var _default2 = BProgressBar;
exports.default = _default2;