mirror of
https://gitee.com/niucloud-team/niucloud-admin.git
synced 2026-02-18 06:33:49 +00:00
2 lines
6.1 KiB
JavaScript
2 lines
6.1 KiB
JavaScript
import{_ as e}from"./u-icon.0a0d2363.js";import{ac as t,ad as a,ae as o,am as l,an as s,o as r,c as i,w as n,t as d,x as u,M as b,n as c,g as h,S as p,i as f,j as m,b as g,y,F as v,a8 as x,k as S,aB as _,bc as C,L as k}from"./index-c6ad3c68.js";import{_ as w}from"./_plugin-vue_export-helper.1b428a4d.js";import{_ as D}from"./u-safe-bottom.58ab23d9.js";const I=w({name:"u-badge",mixins:[a,{props:{isDot:{type:Boolean,default:()=>t.badge.isDot},value:{type:[Number,String],default:()=>t.badge.value},modelValue:{type:[Number,String],default:()=>t.badge.modelValue},show:{type:Boolean,default:()=>t.badge.show},max:{type:[Number,String],default:()=>t.badge.max},type:{type:String,default:()=>t.badge.type},showZero:{type:Boolean,default:()=>t.badge.showZero},bgColor:{type:[String,null],default:()=>t.badge.bgColor},color:{type:[String,null],default:()=>t.badge.color},shape:{type:String,default:()=>t.badge.shape},numberType:{type:String,default:()=>t.badge.numberType},offset:{type:Array,default:()=>t.badge.offset},inverted:{type:Boolean,default:()=>t.badge.inverted},absolute:{type:Boolean,default:()=>t.badge.absolute}}},o],computed:{boxStyle:()=>({}),badgeStyle(){const e={};if(this.color&&(e.color=this.color),this.bgColor&&!this.inverted&&(e.backgroundColor=this.bgColor),this.absolute&&(e.position="absolute",this.offset.length)){const t=this.offset[0],a=this.offset[1]||t;e.top=l(t),e.right=l(a)}return e},showValue(){switch(this.numberType){case"overflow":return Number(this.value)>Number(this.max)?this.max+"+":this.value;case"ellipsis":return Number(this.value)>Number(this.max)?"...":this.value;case"limit":return Number(this.value)>999?Number(this.value)>=9999?Math.floor(this.value/1e4*100)/100+"w":Math.floor(this.value/1e3*100)/100+"k":this.value;default:return Number(this.value)}}},methods:{addStyle:s}},[["render",function(e,t,a,o,l,s){const f=p;return e.show&&(0!==Number(e.value)||e.showZero||e.isDot)?(r(),i(f,{key:0,class:b([[e.isDot?"u-badge--dot":"u-badge--not-dot",e.inverted&&"u-badge--inverted","horn"===e.shape&&"u-badge--horn",`u-badge--${e.type}${e.inverted?"--inverted":""}`],"u-badge"]),style:c([s.addStyle(e.customStyle),s.badgeStyle])},{default:n((()=>[d(u(e.isDot?"":s.showValue),1)])),_:1},8,["class","style"])):h("v-if",!0)}],["__scopeId","data-v-0e56696e"]]);const N=w({name:"u-tabbar-item",mixins:[a,o,{props:{name:{type:[String,Number,null],default:()=>t.tabbarItem.name},icon:{icon:String,default:()=>t.tabbarItem.icon},badge:{type:[String,Number,null],default:()=>t.tabbarItem.badge},dot:{type:Boolean,default:()=>t.tabbarItem.dot},text:{type:String,default:()=>t.tabbarItem.text},badgeStyle:{type:[Object,String],default:()=>t.tabbarItem.badgeStyle}}}],data:()=>({isActive:!1,parentData:{value:null,activeColor:"",inactiveColor:""}}),options:{virtualHost:!0},created(){this.init()},emits:["click","change"],methods:{addStyle:s,init(){this.updateParentData(),this.parent;const e=this.parent.children.indexOf(this);this.isActive=(this.name||e)===this.parentData.value},updateParentData(){this.getParentData("u-tabbar")},updateFromParent(){this.init()},clickHandler(){this.$nextTick((()=>{const e=this.parent.children.indexOf(this),t=this.name||e;t!==this.parent.value&&this.parent.$emit("change",t),this.$emit("click",t)}))}}},[["render",function(t,a,o,l,s,b){const h=f(m("u-icon"),e),_=f(m("u-badge"),I),C=S,k=p;return r(),i(C,{class:"u-tabbar-item cursor-pointer",style:c([b.addStyle(t.customStyle)]),onClick:b.clickHandler},{default:n((()=>[g(C,{class:"u-tabbar-item__icon"},{default:n((()=>[t.icon?(r(),i(h,{key:0,name:t.icon,color:s.isActive?s.parentData.activeColor:s.parentData.inactiveColor,size:20},null,8,["name","color"])):(r(),y(v,{key:1},[s.isActive?x(t.$slots,"active-icon",{key:0},void 0,!0):x(t.$slots,"inactive-icon",{key:1},void 0,!0)],64)),g(_,{absolute:"",offset:[0,t.dot?"34rpx":t.badge>9?"14rpx":"20rpx"],customStyle:t.badgeStyle,isDot:t.dot,value:t.badge||(t.dot?1:null),show:t.dot||t.badge>0},null,8,["offset","customStyle","isDot","value","show"])])),_:3}),x(t.$slots,"text",{},(()=>[g(k,{class:"u-tabbar-item__text",style:c({color:s.isActive?s.parentData.activeColor:s.parentData.inactiveColor})},{default:n((()=>[d(u(t.text),1)])),_:1},8,["style"])]),!0)])),_:3},8,["style","onClick"])}],["__scopeId","data-v-ed2788ef"]]);const B=w({name:"u-tabbar",mixins:[a,o,{props:{value:{type:[String,Number,null],default:()=>t.tabbar.value},safeAreaInsetBottom:{type:Boolean,default:()=>t.tabbar.safeAreaInsetBottom},border:{type:Boolean,default:()=>t.tabbar.border},zIndex:{type:[String,Number],default:()=>t.tabbar.zIndex},activeColor:{type:String,default:()=>t.tabbar.activeColor},inactiveColor:{type:String,default:()=>t.tabbar.inactiveColor},fixed:{type:Boolean,default:()=>t.tabbar.fixed},placeholder:{type:Boolean,default:()=>t.tabbar.placeholder}}}],data:()=>({placeholderHeight:0}),computed:{tabbarStyle(){const e={zIndex:this.zIndex};return _(e,s(this.customStyle))},updateChild(){return[this.value,this.activeColor,this.inactiveColor]},updatePlaceholder(){return[this.fixed,this.placeholder]}},watch:{updateChild(){this.updateChildren()},updatePlaceholder(){this.setPlaceholderHeight()}},created(){this.children=[]},mounted(){this.setPlaceholderHeight()},methods:{updateChildren(){this.children.length&&this.children.map((e=>e.updateFromParent()))},async setPlaceholderHeight(){this.fixed&&this.placeholder&&(await C(20),this.$uGetRect(".u-tabbar__content").then((({height:e=50})=>{this.placeholderHeight=e})))}}},[["render",function(e,t,a,o,l,s){const d=S,u=f(m("u-safe-bottom"),D);return r(),i(d,{class:"u-tabbar"},{default:n((()=>[g(d,{class:b(["u-tabbar__content",[e.border&&"u-border-top",e.fixed&&"u-tabbar--fixed"]]),ref:"u-tabbar__content",onTouchmove:k(e.noop,["stop","prevent"]),style:c([s.tabbarStyle])},{default:n((()=>[g(d,{class:"u-tabbar__content__item-wrapper"},{default:n((()=>[x(e.$slots,"default",{},void 0,!0)])),_:3}),e.safeAreaInsetBottom?(r(),i(u,{key:0})):h("v-if",!0)])),_:3},8,["onTouchmove","class","style"]),e.placeholder?(r(),i(d,{key:0,class:"u-tabbar__placeholder",style:c({height:l.placeholderHeight+"px"})},null,8,["style"])):h("v-if",!0)])),_:3})}],["__scopeId","data-v-71f6d5da"]]);export{N as _,B as a};
|