"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),x=require("@vueuse/core"),S=require("./hooks/useTabsWatch.js"),C=require("../../../commons/plugins/datasource/index.js"),d=require("../../../commons/plugins/event/index.js"),a=require("../../../commons/utils/utils.js"),E=require("../../../commons/components/text.vue.js"),B=["onClick"],j=e.defineComponent({name:"shj-tabs"}),z=e.defineComponent({...j,props:{option:{},sources:{},useEvents:{},uuid:{}},emits:["on-change"],setup(h,{expose:b,emit:k}){const t=h,i=k,l=e.ref([]),s=e.ref(t.option.value),r=()=>{C.SHJDatasourceV2.parse({tId:t.uuid,sources:t.sources,callback:({data:o})=>{if(!o){l.value=[];return}l.value=o[0].data,t.option.isDefaultSelect&&(s.value=t.option.value,!s.value&&l.value.length>0&&(s.value=l.value[0].value),i("on-change",l.value[0]),d.SHJParseEvent.parseEvents(t.useEvents,"on-change",l.value[0])),f()}})};e.onMounted(()=>r());const m=o=>{o.value!==s.value&&(i("on-change",o),d.SHJParseEvent.parseEvents(t.useEvents,"on-change",o)),s.value=o.value};S.useTabsWatch(t,r,s,l),b({refresh:()=>r(),refreshView:()=>{},refreshData:()=>r()});const n=e.ref(null),v=150,u=e.ref(!1),f=()=>{e.nextTick(()=>{if(n.value){const{scrollWidth:o,clientWidth:p}=n.value;u.value=o>p}})},_=()=>{n.value&&(n.value.scrollLeft-=v)},g=()=>{n.value&&(n.value.scrollLeft+=v)};return x.useResizeObserver(n,o=>f()),(o,p)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"tabsContainer",ref:n,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:_},null,4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.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=>m(c),["stop"])},[e.createVNode(E.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,B))),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:g},null,4)):e.createCommentVNode("",!0)],4))}});exports.default=z;
