1 |
- import{e as t,d as e,w as s,al as i,L as a,n as o,g as l,j as r,z as d,l as u,i as n}from"./index-DNuNVpwk.js";import{_ as p}from"./_plugin-vue_export-helper.BCo6x5W8.js";const h=p({name:"UniBadge",emits:["click"],props:{type:{type:String,default:"error"},inverted:{type:Boolean,default:!1},isDot:{type:Boolean,default:!1},maxNum:{type:Number,default:99},absolute:{type:String,default:""},offset:{type:Array,default:()=>[0,0]},text:{type:[String,Number],default:""},size:{type:String,default:"small"},customStyle:{type:Object,default:()=>({})}},data:()=>({}),computed:{width(){return 8*String(this.text).length+12},classNames(){const{inverted:t,type:e,size:s,absolute:i}=this;return[t?"uni-badge--"+e+"-inverted":"","uni-badge--"+e,"uni-badge--"+s,i?"uni-badge--absolute":""].join(" ")},positionStyle(){if(!this.absolute)return{};let t=this.width/2,e=10;this.isDot&&(t=5,e=5);const s=`${-t+this.offset[0]}px`,i=`${-e+this.offset[1]}px`,a={rightTop:{right:s,top:i},rightBottom:{right:s,bottom:i},leftBottom:{left:s,bottom:i},leftTop:{left:s,top:i}},o=a[this.absolute];return o||a.rightTop},badgeWidth(){return{width:`${this.width}px`}},dotStyle(){return this.isDot?{width:"10px",height:"10px",borderRadius:"10px"}:{}},displayValue(){const{isDot:t,text:e,maxNum:s}=this;return t?"":Number(e)>s?`${s}+`:e}},methods:{onClick(){this.$emit("click")}}},[["render",function(p,h,f,m,c,g){const y=u,b=n;return t(),e(b,{class:"uni-badge--x"},{default:s((()=>[i(p.$slots,"default",{},void 0,!0),f.text?(t(),e(y,{key:0,class:a([g.classNames,"uni-badge"]),style:o([g.badgeWidth,g.positionStyle,f.customStyle,g.dotStyle]),onClick:h[0]||(h[0]=t=>g.onClick())},{default:s((()=>[l(r(g.displayValue),1)])),_:1},8,["class","style"])):d("",!0)])),_:3})}],["__scopeId","data-v-963b7042"]]);export{h as _};
|