"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),p=require("lodash"),l=require("nanoid"),B=require("../../commons/core/datasource/index.js"),I=require("../../commons/utils/json2css.js"),_=["onClick"],C=["src"],z=o.defineComponent({name:"zv-commons-loop-iterator"}),G=o.defineComponent({...z,props:{basicOption:{},sources:{},useEvents:{},uuid:{}},emits:["on-change"],setup(u,{expose:s,emit:h}){const n=u,m=()=>{const r=o.ref(),a=o.ref([]);return{init:()=>{B.SHJDatasourceV2.parse({tId:n.uuid,sources:n.sources,callback:e=>{try{r.value=l.nanoid(),e&&e.data?a.value=p.cloneDeep(e.data[0].data):a.value=[]}catch{window.SHJParseEvent(n.useEvents,"dataListener",null),r.value=l.nanoid(),a.value=[]}}})},key:r,loopData:a,renderItemStyle:e=>({gridTemplateColumns:`repeat(${e.columns}, 1fr)`,alignItems:e.alignItems,rowGap:e.rowGap+"px",columnGap:e.columnGap+"px",borderWidth:e.border.width+"px",borderColor:e.border.color,borderStyle:e.border.style,background:e.background.type==="color"?e.background.color:`no-repeat center/100% url(${e.background.image})`,boxShadow:e.shadow.x+"px "+e.shadow.y+"px "+e.shadow.blur+"px "+e.shadow.diffus+"px "+e.shadow.color}),renderImageStyle:e=>e?{width:e.width+"px",height:e.height+"px",objectFit:e.objectFit,borderWidth:e.border.width+"px",borderColor:e.border.color,borderStyle:e.border.style,boxShadow:e.shadow.x+"px "+e.shadow.y+"px "+e.shadow.blur+"px "+e.shadow.diffus+"px "+e.shadow.color,padding:e.padding[0]+"px "+e.padding[1]+"px "+e.padding[2]+"px "+e.padding[3]+"px"}:{},renderTextStyle:e=>(I.autoInstallFont(e.font),e?{width:e.width+"px",height:e.height+"px",color:e.color,fontSize:e.size+"px",fontFamily:e.font,fontStyle:e.style,boxShadow:e.shadow.x+"px "+e.shadow.y+"px "+e.shadow.blur+"px "+e.shadow.diffus+"px "+e.shadow.color,padding:e.padding[0]+"px "+e.padding[1]+"px "+e.padding[2]+"px "+e.padding[3]+"px"}:{}),renderLoopWrapStyle:e=>({overflow:e.overflow,gridTemplateColumns:`repeat(${e.columns}, 1fr)`,rowGap:e.rowGap+"px",columnGap:e.columnGap+"px",borderWidth:e.border.width+"px",borderColor:e.border.color,borderStyle:e.border.style,background:e.background.type==="color"?e.background.color:`no-repeat center/100% url(${e.background.image})`,boxShadow:e.shadow.x+"px "+e.shadow.y+"px "+e.shadow.blur+"px "+e.shadow.diffus+"px "+e.shadow.color})}},{init:t,key:x,loopData:w,renderImageStyle:b,renderTextStyle:g,renderItemStyle:f,renderLoopWrapStyle:S}=m(),k=h,v=r=>{k("on-change",r),window.SHJParseEvent(n.useEvents,"on-change",{data:r})};return o.onMounted(()=>t()),o.watch(()=>n.basicOption,(r,a)=>{p.isEqual(r,a)||t()},{deep:!0}),o.watch(()=>n.sources,(r,a)=>{p.isEqual(r,a)||t()},{deep:!0}),s({refresh:()=>t(),refreshView:()=>t(),refreshData:()=>t()}),(r,a)=>(o.openBlock(),o.createElementBlock("div",{key:o.unref(x),class:"zerov-widget loop-iterator-wrap",style:o.normalizeStyle(o.unref(S)(n.basicOption))},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(o.unref(w),(i,c)=>(o.openBlock(),o.createElementBlock("div",{key:c,class:"loop-iterator-item",style:o.normalizeStyle(o.unref(f)(n.basicOption.itemStyle)),onClick:o.withModifiers(d=>v(i),["stop"])},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(n.basicOption.itemContent,(d,E)=>(o.openBlock(),o.createElementBlock("div",{key:d.id},[d.type==="image"?(o.openBlock(),o.createElementBlock("div",{key:0,class:"loop-iterator-item-image",style:o.normalizeStyle(o.unref(b)(d.style))},[o.createElementVNode("img",{src:i[d.field],alt:"图片"},null,8,C)],4)):(o.openBlock(),o.createElementBlock("div",{key:1,style:o.normalizeStyle(o.unref(g)(d.style))},o.toDisplayString(i[d.field]),5))]))),128))],12,_))),128))],4))}});exports.default=G;
