var t,e,i,a;import{G as s,H as r,a0 as n,a1 as l,a2 as d,o,c as h,w as c,j as u,n as p,A as m,d as v}from"./index-d76b1e7a.js";import{_ as g}from"./_plugin-vue_export-helper.1b428a4d.js";const f=g({name:"uv-grid-item",mixins:[s,r,{props:{name:{type:[String,Number,null],default:null},bgColor:{type:String,default:"transparent"},...null==(e=null==(t=uni.$uv)?void 0:t.props)?void 0:e.gridItem}}],emits:["$uvGridItem","click"],data:()=>({parentData:{col:3,border:!0},classes:[]}),created(){this.updateParentData()},mounted(){this.init()},computed:{width(){return 100/Number(this.parentData.col)+"%"},itemStyle(){const t={background:this.bgColor,width:this.width};return this.$uv.deepMerge(t,this.$uv.addStyle(this.customStyle))}},methods:{init(){n("$uvGridItem",(()=>{this.gridItemClasses()})),l("$uvGridItem"),this.gridItemClasses()},updateParentData(){this.getParentData("uv-grid")},clickHandler(){var t;let e=this.name;const i=null==(t=this.parent)?void 0:t.children;i&&null===this.name&&(e=i.findIndex((t=>t===this))),this.parent&&this.parent.childClick(e),this.$emit("click",e)},async getItemWidth(){let t=0;if(this.parent){t=await this.getParentWidth()/Number(this.parentData.col)+"px"}this.width=t},getParentWidth(){},gridItemClasses(){if(this.parentData.border){let t=[];this.parent.children.map(((e,i)=>{if(this===e){const e=this.parent.children.length;(i+1)%this.parentData.col!=0&&i+1!==e&&t.push("uv-border-right");i<e-(e%this.parentData.col==0?this.parentData.col:e%this.parentData.col)&&t.push("uv-border-bottom")}})),this.classes=t}}},beforeDestroy(){d("$uvGridItem")}},[["render",function(t,e,i,a,s,r){const n=v;return o(),h(n,{class:p(["uv-grid-item",s.classes]),"hover-class":"uv-grid-item--hover-class","hover-stay-time":200,onClick:r.clickHandler,style:m([r.itemStyle])},{default:c((()=>[u(t.$slots,"default",{},void 0,!0)])),_:3},8,["onClick","class","style"])}],["__scopeId","data-v-0b0660d5"]]);const y=g({name:"uv-grid",mixins:[s,r,{props:{col:{type:[String,Number],default:3},border:{type:Boolean,default:!1},align:{type:String,default:"left"},...null==(a=null==(i=uni.$uv)?void 0:i.props)?void 0:a.grid}}],emits:["click"],data:()=>({index:0,width:0}),watch:{parentData(){this.children.length&&this.children.map((t=>{"function"==typeof t.updateParentData&&t.updateParentData()}))}},created(){this.children=[]},computed:{parentData(){return[this.hoverClass,this.col,this.size,this.border]},gridStyle(){let t={};switch(this.align){case"left":default:t.justifyContent="flex-start";break;case"center":t.justifyContent="center";break;case"right":t.justifyContent="flex-end"}return this.$uv.deepMerge(t,this.$uv.addStyle(this.customStyle))}},methods:{childClick(t){this.$emit("click",t)}}},[["render",function(t,e,i,a,s,r){const n=v;return o(),h(n,{class:"uv-grid",ref:"uv-grid",style:m([r.gridStyle])},{default:c((()=>[u(t.$slots,"default",{},void 0,!0)])),_:3},8,["style"])}],["__scopeId","data-v-992c50cd"]]);export{f as _,y as a};
