var t,e,a,i;import{Y as s,Z as r,o as n,j as l,w as d,a0 as o,y as h,B as c,ap as u,aq as p,ar as m,m as v}from"./index-90c12cc1.js";import{_ as g}from"./_plugin-vue_export-helper.1b428a4d.js";const f=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==(e=null==(t=uni.$uv)?void 0:t.props)?void 0:e.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,a,i,s,r){const u=c;return n(),l(u,{class:"uv-grid",ref:"uv-grid",style:h([r.gridStyle])},{default:d((()=>[o(t.$slots,"default",{},void 0,!0)])),_:3},8,["style"])}],["__scopeId","data-v-acf1a89f"]]);const y=g({name:"uv-grid-item",mixins:[s,r,{props:{name:{type:[String,Number,null],default:null},bgColor:{type:String,default:"transparent"},...null==(i=null==(a=uni.$uv)?void 0:a.props)?void 0:i.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(){u("$uvGridItem",(()=>{this.gridItemClasses()})),p("$uvGridItem"),this.gridItemClasses()},updateParentData(){this.getParentData("uv-grid")},clickHandler(){var t;let e=this.name;const a=null==(t=this.parent)?void 0:t.children;a&&null===this.name&&(e=a.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,a)=>{if(this===e){const e=this.parent.children.length;(a+1)%this.parentData.col!=0&&a+1!==e&&t.push("uv-border-right");a<e-(e%this.parentData.col==0?this.parentData.col:e%this.parentData.col)&&t.push("uv-border-bottom")}})),this.classes=t}}},beforeDestroy(){m("$uvGridItem")}},[["render",function(t,e,a,i,s,r){const u=c;return n(),l(u,{class:v(["uv-grid-item",s.classes]),"hover-class":"uv-grid-item--hover-class","hover-stay-time":200,onClick:r.clickHandler,style:h([r.itemStyle])},{default:d((()=>[o(t.$slots,"default",{},void 0,!0)])),_:3},8,["onClick","class","style"])}],["__scopeId","data-v-800b7737"]]);export{f as _,y as a};
