UNPKG

primevue

Version:

PrimeVue is an open source UI library for Vue featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBloc

2 lines (1 loc) 3.86 kB
import e from"primevue/basecomponent";import t from"primevue/metergroup/style";import{openBlock as l,createElementBlock as n,mergeProps as a,Fragment as r,renderList as o,renderSlot as i,normalizeClass as u,createElementVNode as s,toDisplayString as c,resolveComponent as p,createVNode as m,createCommentVNode as v}from"vue";var b={name:"MeterGroup",extends:e,props:{value:{type:Array,default:null},min:{type:Number,default:0},max:{type:Number,default:100},orientation:{type:String,default:"horizontal"},labelPosition:{type:String,default:"end"},labelOrientation:{type:String,default:"horizontal"}},style:t,provide:function(){return{$parentInstance:this}}},d={name:"MeterGroupLabel",hostName:"MeterGroup",extends:e,inheritAttrs:!1,props:{value:{type:Array,default:null},labelPosition:{type:String,default:"end"},labelOrientation:{type:String,default:"horizontal"}}};d.render=function(e,t,p,m,v,b){return l(),n("ol",a({class:e.cx("labellist")},e.ptm("labellist")),[(l(!0),n(r,null,o(p.value,(function(t,r){return l(),n("li",a({key:r+"_label",class:e.cx("labellistitem")},e.ptm("labellistitem")),[i(e.$slots,"icon",{value:t,class:u(e.cx("labelicon"))},(function(){return[t.icon?(l(),n("i",a({key:0,class:[t.icon,e.cx("labelicon")],style:{color:t.color}},e.ptm("labelicon")),null,16)):(l(),n("span",a({key:1,class:e.cx("labellisttype"),style:{backgroundColor:t.color}},e.ptm("labellisttype")),null,16))]})),s("span",a({class:e.cx("label")},e.ptm("label")),c(t.label)+" ("+c(e.$parentInstance.percentValue(t.value))+")",17)],16)})),128))],16)};var f={name:"MeterGroup",extends:b,methods:{getPTOptions:function(e,t,l){return this.ptm(e,{context:{value:t,index:l}})},percent:function(){return Math.round(Math.max(0,Math.min(100,((arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)-this.min)/(this.max-this.min)*100)))},percentValue:function(e){return this.percent(e)+"%"},meterSize:function(e){return{backgroundColor:e.color,width:"horizontal"===this.orientation&&this.percentValue(e.value),height:"vertical"===this.orientation&&this.percentValue(e.value)}}},computed:{totalPercent:function(){return this.percent(this.value.reduce((function(e,t){return e+t.value}),0))},percentages:function(){var e=0,t=[];return this.value.forEach((function(l){t.push(e+=l.value)})),t}},components:{MeterGroupLabel:d}},y=["aria-valuemin","aria-valuemax","aria-valuenow"];f.render=function(e,t,c,b,d,f){var h=p("MeterGroupLabel");return l(),n("div",a({class:e.cx("root"),role:"meter","aria-valuemin":e.min,"aria-valuemax":e.max,"aria-valuenow":f.totalPercent},e.ptm("root"),{"data-pc-name":"metergroup"}),["start"===e.labelPosition?i(e.$slots,"label",{key:0,value:e.value,totalPercent:f.totalPercent,percentages:f.percentages},(function(){return[m(h,{value:e.value,labelPosition:e.labelPosition,labelOrientation:e.labelOrientation,unstyled:e.unstyled,pt:e.pt},null,8,["value","labelPosition","labelOrientation","unstyled","pt"])]})):v("",!0),i(e.$slots,"start",{value:e.value,totalPercent:f.totalPercent,percentages:f.percentages}),s("div",a({class:e.cx("metercontainer")},e.ptm("metercontainer")),[(l(!0),n(r,null,o(e.value,(function(t,l){return i(e.$slots,"meter",{key:l,value:t,index:l,class:u(e.cx("meter")),orientation:e.orientation,size:f.percentValue(t.value),totalPercent:f.totalPercent},(function(){return[s("span",a({class:e.cx("meter"),style:f.meterSize(t)},f.getPTOptions("meter",t,l)),null,16)]}))})),128))],16),i(e.$slots,"end",{value:e.value,totalPercent:f.totalPercent,percentages:f.percentages}),"end"===e.labelPosition?i(e.$slots,"label",{key:1,value:e.value,totalPercent:f.totalPercent,percentages:f.percentages},(function(){return[m(h,{value:e.value,labelPosition:e.labelPosition,labelOrientation:e.labelOrientation,unstyled:e.unstyled,pt:e.pt},null,8,["value","labelPosition","labelOrientation","unstyled","pt"])]})):v("",!0)],16,y)};export{f as default};