buefy
Version:
Lightweight UI components for Vue.js (v3) based on Bulma
3 lines (2 loc) • 4.02 kB
JavaScript
/*! Buefy v3.0.2 | MIT License | github.com/buefy/buefy */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Progress={},e.Vue)}(this,(function(e,t){"use strict";let r;const s=Symbol("bprogress"),a=t.defineComponent({name:"BProgress",provide(){return{[s]:this}},props:{type:{type:[String,Object],default:"is-darkgrey"},size:{type:String},rounded:{type:Boolean,default:!0},value:{type:Number,default:void 0},max:{type:Number,default:100},showValue:{type:Boolean,default:!1},format:{type:String,default:"raw",validator:e=>["raw","percent"].indexOf(e)>=0},precision:{type:Number,default:2},keepTrailingZeroes:{type:Boolean,default:!1},locale:{type:[String,Array],default:()=>r,validator:e=>Array.isArray(e)?e.every((e=>"string"==typeof e)):"string"==typeof e}},computed:{isIndeterminate(){return void 0===this.value||null===this.value},newType(){return[this.size,this.type,{"is-more-than-half":this.value&&this.value>this.max/2}]},newValue(){return this.calculateValue(this.value)},isNative(){return void 0===this.$slots.bar},wrapperClasses(){return{"is-not-native":!this.isNative,[void 0===this.size?"":this.size]:"string"==typeof this.size&&!this.isNative}}},watch:{isIndeterminate(e){this.$nextTick((()=>{this.$refs.progress&&(e?this.$refs.progress.removeAttribute("value"):this.$refs.progress.setAttribute("value",this.value.toString()))}))}},methods:{calculateValue(e){if(null==e||isNaN(e))return;const t=this.keepTrailingZeroes?this.precision:0,r=this.precision;return"percent"===this.format?new Intl.NumberFormat(this.locale,{style:"percent",minimumFractionDigits:t,maximumFractionDigits:r}).format(e/this.max):new Intl.NumberFormat(this.locale,{minimumFractionDigits:t,maximumFractionDigits:r}).format(e)}}});var i=(e,t)=>{const r=e.__vccOpts||e;for(const[e,s]of t)r[e]=s;return r};const o=["max","value"],n={key:2,class:"progress-value"};var l=i(a,[["render",function(e,r,s,a,i,l){return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["progress-wrapper",[e.wrapperClasses,{"is-squared":!e.rounded}]])},[e.isNative?(t.openBlock(),t.createElementBlock("progress",{key:0,ref:"progress",class:t.normalizeClass(["progress",[e.newType,{"is-squared":!e.rounded}]]),max:e.max,value:e.value},t.toDisplayString(e.newValue),11,o)):t.renderSlot(e.$slots,"bar",{key:1}),e.isNative&&e.showValue?(t.openBlock(),t.createElementBlock("p",n,[t.renderSlot(e.$slots,"default",{},(()=>[t.createTextVNode(t.toDisplayString(e.newValue),1)]))])):t.createCommentVNode("v-if",!0)],2)}]]);const u=t.defineComponent({name:"BProgressBar",inject:{parent:{from:s,default:void 0}},props:{type:{type:[String],default:void 0},value:{type:Number,default:void 0},showValue:{type:Boolean,default:!1}},computed:{parentProgress(){return this.parent},newType(){return[this.parentProgress.size,this.type||this.parentProgress.type]},newShowValue(){return this.showValue||this.parentProgress.showValue},newValue(){return this.parentProgress.calculateValue(this.value)},barWidth(){return 100*(void 0===this.value?0:this.value)/this.parentProgress.max+"%"}}}),p=["aria-valuenow","aria-valuemax"],c={key:0,class:"progress-value"};var d=i(u,[["render",function(e,r,s,a,i,o){return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["progress-bar",e.newType]),role:"progressbar","aria-valuenow":e.value,"aria-valuemax":e.parentProgress.max,"aria-valuemin":"0",style:t.normalizeStyle({width:e.barWidth})},[e.newShowValue?(t.openBlock(),t.createElementBlock("p",c,[t.renderSlot(e.$slots,"default",{},(()=>[t.createTextVNode(t.toDisplayString(e.newValue),1)]))])):t.createCommentVNode("v-if",!0)],14,p)}]]);const m=(e,t,r)=>{const s=t.name;if(null==s)throw new Error("Buefy.registerComponent: missing component name");e.component(s,t)},h={install(e){m(e,l),m(e,d)}};e.BProgress=l,e.BProgressBar=d,e.default=h,Object.defineProperty(e,"__esModule",{value:!0})}));