1 |
- import{aa as q,aP as ie,bu as $e,r as I,ba as _e,aw as Pe,aD as Ae,av as ze,aR as le,c as L,n as A,m as se,b as O,d as E,aO as re,q as ce,e as k,bs as de,a6 as ue,i as Oe,w as P,Y as fe,a as g,bo as ve,Z as N,k as j,t as M,W as Y,at as Ne,aV as U,x as Le,X as K,bp as be,a4 as Ee,aX as He,y as z,aC as De,aQ as We,o as te,a5 as Ze,bv as Me,bw as ne,h as Ve,ab as Fe,$ as Ue,bx as Xe,aq as qe,a3 as Ye,a7 as je,a9 as Ke,g as Qe,aH as Ge,v as Je}from"./index-a1bf1d15.js";import{T as pe}from"./use-tab-status-a66a826a.js";import{S as et,a as tt}from"./index-32b5aea3.js";function nt(e,i,s){let l=0;const n=e.scrollLeft,a=s===0?1:Math.round(s*1e3/16);function r(){e.scrollLeft+=(i-n)/a,++l<a&&q(r)}r()}function at(e,i,s,l){let n=ie(e);const a=n<i,r=s===0?1:Math.round(s*1e3/16),b=(i-n)/r;function u(){n+=b,(a&&n>i||!a&&n<i)&&(n=i),$e(e,n),a&&n<i||!a&&n>i?q(u):l&&q(l)}u()}function ot(){const e=I([]),i=[];return _e(()=>{e.value=[]}),[e,l=>(i[l]||(i[l]=n=>{e.value[l]=n}),i[l])]}function he(e,i){if(!Pe||!window.IntersectionObserver)return;const s=new IntersectionObserver(a=>{i(a[0].intersectionRatio>0)},{root:document.body}),l=()=>{e.value&&s.observe(e.value)},n=()=>{e.value&&s.unobserve(e.value)};Ae(n),ze(n),le(l)}const[it,lt]=L("sticky"),st={zIndex:A,position:se("top"),container:Object,offsetTop:O(0),offsetBottom:O(0)};var rt=E({name:it,props:st,emits:["scroll","change"],setup(e,{emit:i,slots:s}){const l=I(),n=re(l),a=ce({fixed:!1,width:0,height:0,transform:0}),r=k(()=>de(e.position==="top"?e.offsetTop:e.offsetBottom)),b=k(()=>{const{fixed:f,height:w,width:x}=a;if(f)return{width:`${x}px`,height:`${w}px`}}),u=k(()=>{if(!a.fixed)return;const f=ue(Oe(e.zIndex),{width:`${a.width}px`,height:`${a.height}px`,[e.position]:`${r.value}px`});return a.transform&&(f.transform=`translate3d(0, ${a.transform}px, 0)`),f}),C=f=>i("scroll",{scrollTop:f,isFixed:a.fixed}),h=()=>{if(!l.value||ve(l))return;const{container:f,position:w}=e,x=N(l),v=ie(window);if(a.width=x.width,a.height=x.height,w==="top")if(f){const S=N(f),c=S.bottom-r.value-a.height;a.fixed=r.value>x.top&&S.bottom>0,a.transform=c<0?c:0}else a.fixed=r.value>x.top;else{const{clientHeight:S}=document.documentElement;if(f){const c=N(f),B=S-c.top-r.value-a.height;a.fixed=S-r.value<x.bottom&&S>c.top,a.transform=B<0?-B:0}else a.fixed=S-r.value<x.bottom}C(v)};return P(()=>a.fixed,f=>i("change",f)),fe("scroll",h,{target:n,passive:!0}),he(l,h),()=>{var f;return g("div",{ref:l,style:b.value},[g("div",{class:lt({fixed:a.fixed}),style:u.value},[(f=s.default)==null?void 0:f.call(s)])])}}});const ct=j(rt),[dt,ae]=L("tab");var ut=E({name:dt,props:{id:String,dot:Boolean,type:String,color:String,title:String,badge:A,shrink:Boolean,isActive:Boolean,disabled:Boolean,controls:String,scrollable:Boolean,activeColor:String,inactiveColor:String,showZeroBadge:M},setup(e,{slots:i}){const s=k(()=>{const n={},{type:a,color:r,disabled:b,isActive:u,activeColor:C,inactiveColor:h}=e;r&&a==="card"&&(n.borderColor=r,b||(u?n.backgroundColor=r:n.color=r));const w=u?C:h;return w&&(n.color=w),n}),l=()=>{const n=g("span",{class:ae("text",{ellipsis:!e.scrollable})},[i.title?i.title():e.title]);return e.dot||Y(e.badge)&&e.badge!==""?g(Ne,{dot:e.dot,content:e.badge,showZero:e.showZeroBadge},{default:()=>[n]}):n};return()=>g("div",{id:e.id,role:"tab",class:[ae([e.type,{grow:e.scrollable&&!e.shrink,shrink:e.shrink,active:e.isActive,disabled:e.disabled}])],style:s.value,tabindex:e.disabled?void 0:e.isActive?0:-1,"aria-selected":e.isActive,"aria-disabled":e.disabled||void 0,"aria-controls":e.controls},[l()])}});const[ft,oe]=L("tabs");var vt=E({name:ft,props:{count:U(Number),inited:Boolean,animated:Boolean,duration:U(A),swipeable:Boolean,lazyRender:Boolean,currentIndex:U(Number)},emits:["change"],setup(e,{emit:i,slots:s}){const l=I(),n=b=>i("change",b),a=()=>{var b;const u=(b=s.default)==null?void 0:b.call(s);return e.animated||e.swipeable?g(et,{ref:l,loop:!1,class:oe("track"),duration:+e.duration*1e3,touchable:e.swipeable,lazyRender:e.lazyRender,showIndicators:!1,onChange:n},{default:()=>[u]}):u},r=b=>{const u=l.value;u&&u.state.active!==b&&u.swipeTo(b,{immediate:!e.inited})};return P(()=>e.currentIndex,r),Le(()=>{r(e.currentIndex)}),K({swipeRef:l}),()=>g("div",{class:oe("content",{animated:e.animated||e.swipeable})},[a()])}});const[ge,Z]=L("tabs"),bt={type:se("line"),color:String,border:Boolean,sticky:Boolean,shrink:Boolean,active:O(0),duration:O(.3),animated:Boolean,ellipsis:M,swipeable:Boolean,scrollspy:Boolean,offsetTop:O(0),background:String,lazyRender:M,lineWidth:A,lineHeight:A,beforeChange:Function,swipeThreshold:O(5),titleActiveColor:String,titleInactiveColor:String},me=Symbol(ge);var ht=E({name:ge,props:bt,emits:["change","scroll","rendered","clickTab","update:active"],setup(e,{emit:i,slots:s}){let l,n,a;const r=I(),b=I(),u=I(),C=I(),h=be(),f=re(r),[w,x]=ot(),{children:v,linkChildren:S}=Ee(me),c=ce({inited:!1,position:"",lineStyle:{},currentIndex:-1}),B=k(()=>v.length>+e.swipeThreshold||!e.ellipsis||e.shrink),V=k(()=>({borderColor:e.color,background:e.background})),$=(t,o)=>{var d;return(d=t.name)!=null?d:o},Q=k(()=>{const t=v[c.currentIndex];if(t)return $(t,c.currentIndex)}),F=k(()=>de(e.offsetTop)),G=k(()=>e.sticky?F.value+l:0),H=t=>{const o=b.value,d=w.value;if(!B.value||!o||!d||!d[c.currentIndex])return;const y=d[c.currentIndex].$el,m=y.offsetLeft-(o.offsetWidth-y.offsetWidth)/2;nt(o,m,t?0:+e.duration)},R=()=>{const t=c.inited;z(()=>{const o=w.value;if(!o||!o[c.currentIndex]||e.type!=="line"||ve(r.value))return;const d=o[c.currentIndex].$el,{lineWidth:y,lineHeight:m}=e,T=d.offsetLeft+d.offsetWidth/2,_={width:te(y),backgroundColor:e.color,transform:`translateX(${T}px) translateX(-50%)`};if(t&&(_.transitionDuration=`${e.duration}s`),Y(m)){const ee=te(m);_.height=ee,_.borderRadius=ee}c.lineStyle=_})},ye=t=>{const o=t<c.currentIndex?-1:1;for(;t>=0&&t<v.length;){if(!v[t].disabled)return t;t+=o}},D=(t,o)=>{const d=ye(t);if(!Y(d))return;const y=v[d],m=$(y,d),T=c.currentIndex!==null;c.currentIndex!==d&&(c.currentIndex=d,o||H(),R()),m!==e.active&&(i("update:active",m),T&&i("change",m,y.title)),a&&!e.scrollspy&&Me(Math.ceil(ne(r.value)-F.value))},W=(t,o)=>{const d=v.find((m,T)=>$(m,T)===t),y=d?v.indexOf(d):0;D(y,o)},J=(t=!1)=>{if(e.scrollspy){const o=v[c.currentIndex].$el;if(o&&f.value){const d=ne(o,f.value)-G.value;n=!0,at(f.value,d,t?0:+e.duration,()=>{n=!1})}}},we=(t,o,d)=>{const{title:y,disabled:m}=v[o],T=$(v[o],o);m||(Ue(e.beforeChange,{args:[T],done:()=>{D(o),J()}}),Xe(t)),i("clickTab",{name:T,title:y,event:d,disabled:m})},xe=t=>{a=t.isFixed,i("scroll",t)},Se=t=>{z(()=>{W(t),J(!0)})},Te=()=>{for(let t=0;t<v.length;t++){const{top:o}=N(v[t].$el);if(o>G.value)return t===0?0:t-1}return v.length-1},Ce=()=>{if(e.scrollspy&&!n){const t=Te();D(t)}},ke=()=>v.map((t,o)=>g(ut,Ve({key:t.id,id:`${h}-${o}`,ref:x(o),type:e.type,color:e.color,style:t.titleStyle,class:t.titleClass,shrink:e.shrink,isActive:o===c.currentIndex,controls:t.id,scrollable:B.value,activeColor:e.titleActiveColor,inactiveColor:e.titleInactiveColor,onClick:d=>we(t,o,d)},Fe(t,["dot","badge","title","disabled","showZeroBadge"])),{title:t.$slots.title})),Ie=()=>{if(e.type==="line"&&v.length)return g("div",{class:Z("line"),style:c.lineStyle},null)},p=()=>{var t,o,d;const{type:y,border:m,sticky:T}=e,_=[g("div",{ref:T?void 0:u,class:[Z("wrap"),{[Ze]:y==="line"&&m}]},[g("div",{ref:b,role:"tablist",class:Z("nav",[y,{shrink:e.shrink,complete:B.value}]),style:V.value,"aria-orientation":"horizontal"},[(t=s["nav-left"])==null?void 0:t.call(s),ke(),Ie(),(o=s["nav-right"])==null?void 0:o.call(s)])]),(d=s["nav-bottom"])==null?void 0:d.call(s)];return T?g("div",{ref:u},[_]):_};P([()=>e.color,He],R),P(()=>e.active,t=>{t!==Q.value&&W(t)}),P(()=>v.length,()=>{c.inited&&(W(e.active),R(),z(()=>{H(!0)}))});const Re=()=>{W(e.active,!0),z(()=>{c.inited=!0,u.value&&(l=N(u.value).height),H(!0)})},Be=(t,o)=>i("rendered",t,o);return K({resize:()=>{R(),z(()=>{var t,o;return(o=(t=C.value)==null?void 0:t.swipeRef.value)==null?void 0:o.resize()})},scrollTo:Se}),De(R),We(R),le(Re),he(r,R),fe("scroll",Ce,{target:f,passive:!0}),S({id:h,props:e,setLine:R,onRendered:Be,currentName:Q,scrollIntoView:H}),()=>g("div",{ref:r,class:Z([e.type])},[e.sticky?g(ct,{container:r.value,offsetTop:F.value,onScroll:xe},{default:()=>[p()]}):p(),g(vt,{ref:C,count:v.length,inited:c.inited,animated:e.animated,duration:e.duration,swipeable:e.swipeable,lazyRender:e.lazyRender,currentIndex:c.currentIndex,onChange:D},{default:()=>{var t;return[(t=s.default)==null?void 0:t.call(s)]}})])}});const[gt,X]=L("tab"),mt=ue({},qe,{dot:Boolean,name:A,badge:A,title:String,disabled:Boolean,titleClass:Ye,titleStyle:[String,Object],showZeroBadge:M});var yt=E({name:gt,props:mt,setup(e,{slots:i}){const s=be(),l=I(!1),{parent:n,index:a}=je(me);if(!n)return;const r=()=>{var h;return(h=e.name)!=null?h:a.value},b=()=>{l.value=!0,n.props.lazyRender&&z(()=>{n.onRendered(r(),e.title)})},u=k(()=>{const h=r()===n.currentName.value;return h&&!l.value&&b(),h}),C=I(!u.value);return P(u,h=>{h?C.value=!1:Ke(()=>{C.value=!0})}),P(()=>e.title,()=>{n.setLine(),n.scrollIntoView()}),Ge(pe,u),()=>{var h;const f=`${n.id}-${a.value}`,{animated:w,swipeable:x,scrollspy:v,lazyRender:S}=n.props;if(!i.default&&!w)return;const c=v||u.value;if(w||x)return g(tt,{id:s,role:"tabpanel",class:X("panel-wrapper",{inactive:C.value}),tabindex:u.value?0:-1,"aria-hidden":!u.value,"aria-labelledby":f},{default:()=>{var $;return[g("div",{class:X("panel")},[($=i.default)==null?void 0:$.call(i)])]}});const V=l.value||v||!S?(h=i.default)==null?void 0:h.call(i):null;return K({id:s}),Qe(g("div",{id:s,role:"tabpanel",class:X("panel"),tabindex:c?0:-1,"aria-labelledby":f},[V]),[[Je,c]])}}});const Ct=j(yt),kt=j(ht);export{kt as T,Ct as a};
|