"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),x=require("@vueuse/core"),g=require("./hooks/useTabsWatch.js"),S=require("../../../commons/plugins/datasource/index.js"),C=require("../../../commons/plugins/event/index.js"),a=require("../../../commons/utils/utils.js"),B=require("../../../commons/components/text.vue.js"),j=["onClick"],z=e.defineComponent({name:"shj-tabs"}),E=e.defineComponent({...z,props:{option:{},sources:{},useEvents:{},uuid:{}},emits:["on-change"],setup(p,{expose:d,emit:b}){const t=p,h=b,n=e.ref([]),s=e.ref(t.option.value),r=()=>{S.SHJDatasourceV2.parse({tId:t.uuid,sources:t.sources,callback:({data:o})=>{if(!o){n.value=[];return}n.value=o[0].data,!s.value&&n.value.length>0&&(s.value=n.value[0].value),v()}})};e.onMounted(()=>r());const k=o=>{o.value!==s.value&&(h("on-change",o),C.SHJParseEvent.parseEvents(t.useEvents,"on-change",o)),s.value=o.value};g.useTabsWatch(t,r,s,n),d({refresh:()=>r(),refreshView:()=>{},refreshData:()=>r()});const l=e.ref(null),i=150,u=e.ref(!1),v=()=>{e.nextTick(()=>{if(l.value){const{scrollWidth:o,clientWidth:f}=l.value;u.value=o>f}})},m=()=>{l.value&&(l.value.scrollLeft-=i)},_=()=>{l.value&&(l.value.scrollLeft+=i)};return x.useResizeObserver(l,o=>v()),(o,f)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"tabsContainer",ref:l,class:"height-100 flex overflow-hidden scroll-behavior-smooth",style:e.normalizeStyle(e.unref(a.Utils).json2cssObject(t.option.css.tab))},[u.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"flex-none cursor-pointer position-absolute translate-center-left-active-scale-095 top-50 background-size-cover",style:e.normalizeStyle(e.unref(a.Utils).json2cssObject(t.option.css.nav.left)),onClick:m},null,4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,(c,y)=>(e.openBlock(),e.createElementBlock("div",{key:y,class:e.normalizeClass(["flex flex-none cursor-pointer transition-color-background-color background-size-cover",{selected:c.value===s.value}]),style:e.normalizeStyle(e.unref(a.Utils).json2cssObject(c.value===s.value?t.option.css.item.selected:t.option.css.item)),onClick:e.withModifiers(q=>k(c),["stop"])},[e.createVNode(B.default,{"text-style":c.value===s.value?t.option.css.item.selected.textStyle:t.option.css.item.textStyle,text:c.label},null,8,["text-style","text"])],14,j))),128)),u.value?(e.openBlock(),e.createElementBlock("button",{key:1,class:"flex-none cursor-pointer position-absolute translate-center-right-active-scale-095 top-50 background-size-cover",style:e.normalizeStyle(e.unref(a.Utils).json2cssObject(t.option.css.nav.right)),onClick:_},null,4)):e.createCommentVNode("",!0)],4))}});exports.default=E;
