"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),u=require("lodash"),m=require("nanoid"),B={class:"table-body"},z=["onClick","onMouseenter","onMouseout"],M=["onClick"],D={key:1},H=o.defineComponent({name:"zv-text-table-basic"}),J=o.defineComponent({...H,props:{basicOption:{},useEvents:{},sources:{},uuid:{}},emits:["on-click-item","on-click-row","on-mouseenter-row","on-mouseout-row"],setup(k,{expose:w,emit:v}){o.useCssVars(e=>({"5d5333b0":e.basicOption.css.table.borderWidth+"px","5810d628":e.basicOption.css.table.borderStyle,"572ce7da":e.basicOption.css.table.borderColor,"7fbfe732":e.basicOption.css.table.paddingLeft+"px",ad7433d0:e.basicOption.css.table.alignItems,"63a6d3a6":e.basicOption.css.table.justifyContent,"0301cadc":e.basicOption.css.header.background,"0cda44bc":e.basicOption.css.header.height+"px","6d6b9b7f":e.basicOption.css.header.color,"014a92b9":e.basicOption.css.header.fontSize+"px","2220490b":e.basicOption.css.header.fontWeight,"7cc778be":e.basicOption.css.header.fontStyle,"5e71f737":e.basicOption.css.body.height+"px","24111dc6":e.basicOption.css.body.background,"45704ca0":e.basicOption.css.oddBackground,"8057cbd8":e.basicOption.css.body.color,aa6cc9e4:e.basicOption.css.body.fontSize+"px","11989f96":e.basicOption.css.body.fontWeight,"52f4a4d3":e.basicOption.css.body.fontStyle}));const d=v,p=o.ref(m.nanoid()),i=o.ref([]),s=k,l=()=>{window.SHJDatasourceV2({tId:s.uuid,sources:s.sources,callback:e=>{try{window.SHJParseEvent(s.useEvents,"dataListener",i),p.value=m.nanoid(),i.value=u.cloneDeep(e.data[0].data)||[]}catch{window.SHJParseEvent(s.useEvents,"dataListener",null),p.value=m.nanoid(),i.value=[]}}})},y=e=>{const t=[];for(const n in e)t.push(e[n]);return t};o.onMounted(()=>l()),o.watch(()=>u.cloneDeep(s.sources),(e,t)=>{u.isEqual(e,t)||l()},{deep:!0}),o.watch(()=>u.cloneDeep(s.basicOption),(e,t)=>{u.isEqual(e,t)||l()},{deep:!0}),w({refresh:()=>l(),refreshView:()=>l(),refreshData:()=>l()});const O=e=>{if(!s.basicOption.columns)return!0;const t=s.basicOption.columns.find(n=>n.index===e);return t?t.font.auto:!0},b=e=>{if(!s.basicOption.columns)return null;const t=s.basicOption.columns.find(n=>n.index===e);return t&&t.font.auto===!1?t.font:null},f=e=>{if(!s.basicOption.columns)return!0;const t=s.basicOption.columns.find(n=>n.index===e);return t?t.width.auto:!0},h=e=>{if(!s.basicOption.columns)return null;const t=s.basicOption.columns.find(n=>n.index===e);return t&&t.width.auto===!1?t.width.width:null},g=(e,t)=>{const n={row:e,rowIndex:t};d("on-click-row",n),window.SHJParseEvent(s.useEvents,"on-click-row",n)},E=(e,t)=>{const n={row:e,rowIndex:t};d("on-mouseenter-row",n),window.SHJParseEvent(s.useEvents,"on-mouseenter-row",n)},C=(e,t)=>{const n={row:e,rowIndex:t};d("on-mouseout-row",n),window.SHJParseEvent(s.useEvents,"on-mouseout-row",n)},S=(e,t,n,r)=>{const c={row:e,item:t,rowIndex:n,columnIndex:r};d("on-click-item",c),window.SHJParseEvent(s.useEvents,"on-click-item",c)};return(e,t)=>i.value.length>0?(o.openBlock(),o.createElementBlock("div",{key:p.value,class:"table-scroll"},[e.basicOption.css.header.show?(o.openBlock(),o.createElementBlock("div",{key:0,class:"table-header",style:o.normalizeStyle({"--header-background-image":`url(${e.basicOption.css.header.backgroundImage})`})},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(Object.keys(i.value[0]),(n,r)=>(o.openBlock(),o.createElementBlock("div",{key:n,class:o.normalizeClass(["th",{customWidth:!f(r+1)}]),style:o.normalizeStyle({"--width":h(r+1)+"px"})},[o.createElementVNode("p",null,o.toDisplayString(n),1)],6))),128))],4)):o.createCommentVNode("",!0),o.createElementVNode("div",B,[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(i.value,(n,r)=>(o.openBlock(),o.createElementBlock("div",{key:n,class:"tr",style:o.normalizeStyle({"--row-hover":e.basicOption.css.hoverColor}),onClick:c=>g(n,r),onMouseenter:c=>E(n,r),onMouseout:c=>C(n,r)},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(y(n),(c,a)=>(o.openBlock(),o.createElementBlock("div",{key:c,class:o.normalizeClass(["td",{customWidth:!f(a+1)}]),style:o.normalizeStyle({"--width":h(a+1)+"px"}),onClick:P=>S(n,c,r,a)},[O(a+1)?(o.openBlock(),o.createElementBlock("p",D,o.toDisplayString(c),1)):(o.openBlock(),o.createElementBlock("p",{key:0,class:"customFont",style:o.normalizeStyle({"--text-color":b(a+1).color,"--text-font-size":b(a+1).fontSize+"px","--text-font-style":b(a+1).fontStyle})},o.toDisplayString(c),5))],14,M))),128))],44,z))),128))])])):o.createCommentVNode("",!0)}});exports.default=J;
