import{_ as i,o as t,p as e,w as r,f as o,a4 as d,B as s,aq as h,v as l,i as n,a9 as a}from"./index-2PZN6pGH.js";const c=i({name:"UniGridItem",inject:["grid"],props:{index:{type:Number,default:0}},data:()=>({column:0,showBorder:!0,square:!0,highlight:!0,left:0,top:0,openNum:2,width:0,borderColor:"#e5e5e5"}),created(){this.column=this.grid.column,this.showBorder=this.grid.showBorder,this.square=this.grid.square,this.highlight=this.grid.highlight,this.top=0===this.hor?this.grid.hor:this.hor,this.left=0===this.ver?this.grid.ver:this.ver,this.borderColor=this.grid.borderColor,this.grid.children.push(this),this.width=this.grid.width},beforeDestroy(){this.grid.children.forEach(((i,t)=>{i===this&&this.grid.children.splice(t,1)}))},methods:{_onClick(){this.grid.change({detail:{index:this.index}})}}},[["render",function(i,a,c,g,u,m){const p=n;return u.width?(t(),e(p,{key:0,style:s("width:"+u.width+";"+(u.square?"height:"+u.width:"")),class:"uni-grid-item"},{default:r((()=>[o(p,{class:d([{"uni-grid-item--border":u.showBorder,"uni-grid-item--border-top":u.showBorder&&c.index<u.column,"uni-highlight":u.highlight},"uni-grid-item__box"]),style:s({"border-right-color":u.borderColor,"border-bottom-color":u.borderColor,"border-top-color":u.borderColor}),onClick:m._onClick},{default:r((()=>[h(i.$slots,"default",{},void 0,!0)])),_:3},8,["class","style","onClick"])])),_:3},8,["style"])):l("",!0)}],["__scopeId","data-v-1f1eb9ce"]]);const g=i({name:"UniGrid",emits:["change"],props:{column:{type:Number,default:3},showBorder:{type:Boolean,default:!0},borderColor:{type:String,default:"#D2D2D2"},square:{type:Boolean,default:!0},highlight:{type:Boolean,default:!0}},provide(){return{grid:this}},data:()=>({elId:`Uni_${Math.ceil(1e6*Math.random()).toString(36)}`,width:0}),created(){this.children=[]},mounted(){this.$nextTick((()=>{this.init()}))},methods:{init(){setTimeout((()=>{this._getSize((i=>{this.children.forEach(((t,e)=>{t.width=i}))}))}),50)},change(i){this.$emit("change",i)},_getSize(i){a().in(this).select(`#${this.elId}`).boundingClientRect().exec((t=>{this.width=parseInt((t[0].width-1)/this.column)+"px",i(this.width)}))}}},[["render",function(i,l,a,c,g,u){const m=n;return t(),e(m,{class:"uni-grid-wrap"},{default:r((()=>[o(m,{id:g.elId,ref:"uni-grid",class:d(["uni-grid",{"uni-grid--border":a.showBorder}]),style:s({"border-left-color":a.borderColor})},{default:r((()=>[h(i.$slots,"default",{},void 0,!0)])),_:3},8,["id","class","style"])])),_:3})}],["__scopeId","data-v-551d9659"]]);export{c as _,g as a};
