hrms-manual/dist/assets/QTabs-95f81e84.js

2 lines
8.3 KiB
JavaScript
Raw Normal View History

2023-09-06 14:51:44 +07:00
import{N as Ae,Q as Ie,aI as z,aJ as oe,a as h,c as f,aS as ne,w as R,bI as ke,a1 as Be,aU as Me,aV as Pe,U as _,a3 as De,a4 as ae,bR as $e}from"./index-3a2b6cd5.js";import{Q as xe}from"./QResizeObserver-889eb2e3.js";import{r as Ee}from"./rtl-36dd996b.js";function Fe(o,P,D){const b=D===!0?["left","right"]:["top","bottom"];return`absolute-${P===!0?b[0]:b[1]}${o?` text-${o}`:""}`}const Qe=["left","center","right","justify"],ze=Ae({name:"QTabs",props:{modelValue:[Number,String],align:{type:String,default:"center",validator:o=>Qe.includes(o)},breakpoint:{type:[String,Number],default:600},vertical:Boolean,shrink:Boolean,stretch:Boolean,activeClass:String,activeColor:String,activeBgColor:String,indicatorColor:String,leftIcon:String,rightIcon:String,outsideArrows:Boolean,mobileArrows:Boolean,switchIndicator:Boolean,narrowIndicator:Boolean,inlineLabel:Boolean,noCaps:Boolean,dense:Boolean,contentClass:String,"onUpdate:modelValue":[Function,Array]},setup(o,{slots:P,emit:D}){const{proxy:b}=Ie(),{$q:L}=b,{registerTick:re}=z(),{registerTick:le}=z(),{registerTick:ie}=z(),{registerTimeout:ue,removeTimeout:se}=oe(),{registerTimeout:H,removeTimeout:ce}=oe(),S=h(null),s=h(null),T=h(o.modelValue),y=h(!1),$=h(!0),x=h(!1),j=h(!1),A=f(()=>L.platform.is.desktop===!0||o.mobileArrows===!0),c=[],E=h(0),I=h(!1);let F,O,g,w=A.value===!0?G:ne;const fe=f(()=>({activeClass:o.activeClass,activeColor:o.activeColor,activeBgColor:o.activeBgColor,indicatorClass:Fe(o.indicatorColor,o.switchIndicator,o.vertical),narrowIndicator:o.narrowIndicator,inlineLabel:o.inlineLabel,noCaps:o.noCaps})),ve=f(()=>{const e=E.value,t=T.value;for(let n=0;n<e;n++)if(c[n].name.value===t)return!0;return!1}),de=f(()=>`q-tabs__content--align-${y.value===!0?"left":j.value===!0?"justify":o.align}`),he=f(()=>`q-tabs row no-wrap items-center q-tabs--${y.value===!0?"":"not-"}scrollable q-tabs--${o.vertical===!0?"vertical":"horizontal"} q-tabs__arrows--${A.value===!0&&o.outsideArrows===!0?"outside":"inside"}`+(o.dense===!0?" q-tabs--dense":"")+(o.shrink===!0?" col-shrink":"")+(o.stretch===!0?" self-stretch":"")),ge=f(()=>"q-tabs__content row no-wrap items-center self-stretch hide-scrollbar relative-position "+de.value+(o.contentClass!==void 0?` ${o.contentClass}`:"")+(L.platform.is.mobile===!0?" scroll":"")),k=f(()=>o.vertical===!0?{container:"height",content:"offsetHeight",scroll:"scrollHeight"}:{container:"width",content:"offsetWidth",scroll:"scrollWidth"}),B=f(()=>o.vertical!==!0&&L.lang.rtl===!0),Q=f(()=>Ee===!1&&B.value===!0);R(B,w),R(()=>o.modelValue,e=>{V({name:e,setCurrent:!0,skipEmit:!0})}),R(()=>o.outsideArrows,()=>{q()}),R(A,e=>{w=e===!0?G:ne,q()});function V({name:e,setCurrent:t,skipEmit:n,fromRoute:l}){T.value!==e&&(n!==!0&&o["onUpdate:modelValue"]!==void 0&&D("update:modelValue",e),(t===!0||o["onUpdate:modelValue"]===void 0)&&(me(T.value,e),T.value=e))}function q(){re(()=>{N({width:S.value.offsetWidth,height:S.value.offsetHeight})})}function N(e){if(k.value===void 0||s.value===null)return;const t=e[k.value.container],n=Math.min(s.value[k.value.scroll],Array.prototype.reduce.call(s.value.children,(i,r)=>i+(r[k.value.content]||0),0)),l=t>0&&n>t;y.value=l,l===!0&&le(w),j.value=t<parseInt(o.breakpoint,10)}function me(e,t){const n=e!=null&&e!==""?c.find(i=>i.name.value===e):null,l=t!=null&&t!==""?c.find(i=>i.name.value===t):null;if(n&&l){const i=n.tabIndicatorRef.value,r=l.tabIndicatorRef.value;clearTimeout(F),i.style.transition="none",i.style.transform="none",r.style.transition="none",r.style.transform="none";const a=i.getBoundingClientRect(),u=r.getBoundingClientRect();r.style.transform=o.vertical===!0?`translate3d(0,${a.top-u.top}px,0) scale3d(1,${u.height?a.height/u.height:1},1)`:`translate3d(${a.left-u.left}px,0,0) scale3d(${u.width?a.width/u.width:1},1,1)`,ie(()=>{F=setTimeout(()=>{r.style.transition="transform .25s cubic-bezier(.4, 0, .2, 1)",r.style.transform="none"},70)})}l&&y.value===!0&&C(l.rootRef.value)}function C(e){const{left:t,width:n,top:l,height:i}=s.value.getBoundingClientRect(),r=e.getBoundingClientRect();let a=o.vertical===!0?r.top-l:r.left-t;if(a<0){s.val