1 |
- import{aP as he,aF as Ce,aQ as Xe,i as P,a0 as Ze,z as Ve,aR as ke,l as Ie,aS as $e,j as Z,t as L,n as Re,ao as N,d as V,aD as Be,O as oe,E as S,aN as _e,A as Ae,aI as Fe,w as B,ak as be,g as y,aE as le,Y as q,D as G,v as W,ay as ge,K as Ke,aj as Ue,ac as Pe,ap as Q,aq as ze,ar as je,aT as qe,o as me,aU as Oe,aV as Ee,y as H,al as Ge,aW as j,am as de,ai as fe,aG as De,G as ye,aX as Qe,aY as Je,aZ as xe,m as pe,p as et,at as tt,a_ as at,ae as Me,aK as nt,x as it,az as lt,$ as ot,aA as st}from"./index-1d4a9afa.js";import{T as rt}from"./use-tab-status-a36febbc.js";function ct(e,r,u){let o=0;const n=e.scrollLeft,t=u===0?1:Math.round(u*1e3/16);function d(){e.scrollLeft+=(r-n)/t,++o<t&&he(d)}d()}function ut(e,r,u,o){let n=Ce(e);const t=n<r,d=u===0?1:Math.round(u*1e3/16),g=(r-n)/d;function f(){n+=g,(t&&n>r||!t&&n<r)&&(n=r),Xe(e,n),t&&n<r||!t&&n>r?he(f):o&&he(o)}f()}function dt(){const e=P([]),r=[];return Ze(()=>{e.value=[]}),[e,o=>(r[o]||(r[o]=n=>{e.value[o]=n}),r[o])]}function Ne(e,r){if(!Ve||!window.IntersectionObserver)return;const u=new IntersectionObserver(t=>{r(t[0].intersectionRatio>0)},{root:document.body}),o=()=>{e.value&&u.observe(e.value)},n=()=>{e.value&&u.unobserve(e.value)};ke(n),Ie(n),$e(o)}const[ft,vt]=Z("sticky"),ht={zIndex:L,position:Re("top"),container:Object,offsetTop:N(0),offsetBottom:N(0)};var gt=V({name:ft,props:ht,emits:["scroll","change"],setup(e,{emit:r,slots:u}){const o=P(),n=Be(o),t=oe({fixed:!1,width:0,height:0,transform:0}),d=S(()=>_e(e.position==="top"?e.offsetTop:e.offsetBottom)),g=S(()=>{const{fixed:c,height:m,width:C}=t;if(c)return{width:`${C}px`,height:`${m}px`}}),f=S(()=>{if(!t.fixed)return;const c=Ae(Fe(e.zIndex),{width:`${t.width}px`,height:`${t.height}px`,[e.position]:`${d.value}px`});return t.transform&&(c.transform=`translate3d(0, ${t.transform}px, 0)`),c}),w=c=>r("scroll",{scrollTop:c,isFixed:t.fixed}),l=()=>{if(!o.value||le(o))return;const{container:c,position:m}=e,C=q(o),b=Ce(window);if(t.width=C.width,t.height=C.height,m==="top")if(c){const I=q(c),v=I.bottom-d.value-t.height;t.fixed=d.value>C.top&&I.bottom>0,t.transform=v<0?v:0}else t.fixed=d.value>C.top;else{const{clientHeight:I}=document.documentElement;if(c){const v=q(c),z=I-v.top-d.value-t.height;t.fixed=I-d.value<C.bottom&&I>v.top,t.transform=z<0?-z:0}else t.fixed=I-d.value<C.bottom}w(b)};return B(()=>t.fixed,c=>r("change",c)),be("scroll",l,{target:n,passive:!0}),Ne(o,l),()=>{var c;return y("div",{ref:o,style:g.value},[y("div",{class:vt({fixed:t.fixed}),style:f.value},[(c=u.default)==null?void 0:c.call(u)])])}}});const bt=G(gt),[mt,Te]=Z("tab");var wt=V({name:mt,props:{id:String,dot:Boolean,type:String,color:String,title:String,badge:L,shrink:Boolean,isActive:Boolean,disabled:Boolean,controls:String,scrollable:Boolean,activeColor:String,inactiveColor:String,showZeroBadge:W},setup(e,{slots:r}){const u=S(()=>{const n={},{type:t,color:d,disabled:g,isActive:f,activeColor:w,inactiveColor:l}=e;d&&t==="card"&&(n.borderColor=d,g||(f?n.backgroundColor=d:n.color=d));const m=f?w:l;return m&&(n.color=m),n}),o=()=>{const n=y("span",{class:Te("text",{ellipsis:!e.scrollable})},[r.title?r.title():e.title]);return e.dot||ge(e.badge)&&e.badge!==""?y(Ke,{dot:e.dot,content:e.badge,showZero:e.showZeroBadge},{default:()=>[n]}):n};return()=>y("div",{id:e.id,role:"tab",class:[Te([e.type,{grow:e.scrollable&&!e.shrink,shrink:e.shrink,active:e.isActive,disabled:e.disabled}])],style:u.value,tabindex:e.disabled?void 0:e.isActive?0:-1,"aria-selected":e.isActive,"aria-disabled":e.disabled||void 0,"aria-controls":e.controls},[o()])}});const[Le,ne]=Z("swipe"),yt={loop:W,width:L,height:L,vertical:Boolean,autoplay:N(0),duration:N(500),touchable:W,lazyRender:Boolean,initialSwipe:N(0),indicatorColor:String,showIndicators:W,stopPropagation:W},He=Symbol(Le);var xt=V({name:Le,props:yt,emits:["change","dragStart","dragEnd"],setup(e,{emit:r,slots:u}){const o=P(),n=P(),t=oe({rect:null,width:0,height:0,offset:0,active:0,swiping:!1});let d=!1;const g=Ue(),{children:f,linkChildren:w}=Pe(He),l=S(()=>f.length),c=S(()=>t[e.vertical?"height":"width"]),m=S(()=>e.vertical?g.deltaY.value:g.deltaX.value),C=S(()=>t.rect?(e.vertical?t.rect.height:t.rect.width)-c.value*l.value:0),b=S(()=>c.value?Math.ceil(Math.abs(C.value)/c.value):l.value),I=S(()=>l.value*c.value),v=S(()=>(t.active+l.value)%l.value),z=S(()=>{const s=e.vertical?"vertical":"horizontal";return g.direction.value===s}),K=S(()=>{const s={transitionDuration:`${t.swiping?0:e.duration}ms`,transform:`translate${e.vertical?"Y":"X"}(${t.offset}px)`};if(c.value){const x=e.vertical?"height":"width",T=e.vertical?"width":"height";s[x]=`${I.value}px`,s[T]=e[T]?`${e[T]}px`:""}return s}),D=s=>{const{active:x}=t;return s?e.loop?de(x+s,-1,l.value):de(x+s,0,b.value):x},U=(s,x=0)=>{let T=s*c.value;e.loop||(T=Math.min(T,-C.value));let a=x-T;return e.loop||(a=de(a,C.value,0)),a},R=({pace:s=0,offset:x=0,emitChange:T})=>{if(l.value<=1)return;const{active:a}=t,i=D(s),h=U(i,x);if(e.loop){if(f[0]&&h!==C.value){const k=h<C.value;f[0].setOffset(k?I.value:0)}if(f[l.value-1]&&h!==0){const k=h>0;f[l.value-1].setOffset(k?-I.value:0)}}t.active=i,t.offset=h,T&&i!==a&&r("change",v.value)},Y=()=>{t.swiping=!0,t.active<=-1?R({pace:l.value}):t.active>=l.value&&R({pace:-l.value})},F=()=>{Y(),g.reset(),j(()=>{t.swiping=!1,R({pace:-1,emitChange:!0})})},_=()=>{Y(),g.reset(),j(()=>{t.swiping=!1,R({pace:1,emitChange:!0})})};let J;const O=()=>clearTimeout(J),E=()=>{O(),+e.autoplay>0&&l.value>1&&(J=setTimeout(()=>{_(),E()},+e.autoplay))},M=(s=+e.initialSwipe)=>{if(!o.value)return;const x=()=>{var T,a;if(!le(o)){const i={width:o.value.offsetWidth,height:o.value.offsetHeight};t.rect=i,t.width=+((T=e.width)!=null?T:i.width),t.height=+((a=e.height)!=null?a:i.height)}l.value&&(s=Math.min(l.value-1,s),s===-1&&(s=l.value-1)),t.active=s,t.swiping=!0,t.offset=U(s),f.forEach(i=>{i.setOffset(0)}),E()};le(o)?H().then(x):x()},p=()=>M(t.active);let ee;const se=s=>{!e.touchable||s.touches.length>1||(g.start(s),d=!1,ee=Date.now(),O(),Y())},re=s=>{e.touchable&&t.swiping&&(g.move(s),z.value&&(!e.loop&&(t.active===0&&m.value>0||t.active===l.value-1&&m.value<0)||(Ge(s,e.stopPropagation),R({offset:m.value}),d||(r("dragStart",{index:v.value}),d=!0))))},te=()=>{if(!e.touchable||!t.swiping)return;const s=Date.now()-ee,x=m.value/s;if((Math.abs(x)>.25||Math.abs(m.value)>c.value/2)&&z.value){const a=e.vertical?g.offsetY.value:g.offsetX.value;let i=0;e.loop?i=a>0?m.value>0?-1:1:0:i=-Math[m.value>0?"ceil":"floor"](m.value/c.value),R({pace:i,emitChange:!0})}else m.value&&R({pace:0});d=!1,t.swiping=!1,r("dragEnd",{index:v.value}),E()},ce=(s,x={})=>{Y(),g.reset(),j(()=>{let T;e.loop&&s===l.value?T=t.active===0?0:s:T=s%l.value,x.immediate?j(()=>{t.swiping=!1}):t.swiping=!1,R({pace:T-t.active,emitChange:!0})})},ue=(s,x)=>{const T=x===v.value,a=T?{backgroundColor:e.indicatorColor}:void 0;return y("i",{style:a,class:ne("indicator",{active:T})},null)},ae=()=>{if(u.indicator)return u.indicator({active:v.value,total:l.value});if(e.showIndicators&&l.value>1)return y("div",{class:ne("indicators",{vertical:e.vertical})},[Array(l.value).fill("").map(ue)])};return Q({prev:F,next:_,state:t,resize:p,swipeTo:ce}),w({size:c,props:e,count:l,activeIndicator:v}),B(()=>e.initialSwipe,s=>M(+s)),B(l,()=>M(t.active)),B(()=>e.autoplay,E),B([ze,je,()=>e.width,()=>e.height],p),B(qe(),s=>{s==="visible"?E():O()}),me(M),Oe(()=>M(t.active)),Ee(()=>M(t.active)),ke(O),Ie(O),be("touchmove",re,{target:n}),()=>{var s;return y("div",{ref:o,class:ne()},[y("div",{ref:n,style:K.value,class:ne("track",{vertical:e.vertical}),onTouchstartPassive:se,onTouchend:te,onTouchcancel:te},[(s=u.default)==null?void 0:s.call(u)]),ae()])}}});const Tt=G(xt),[St,Se]=Z("tabs");var Ct=V({name:St,props:{count:fe(Number),inited:Boolean,animated:Boolean,duration:fe(L),swipeable:Boolean,lazyRender:Boolean,currentIndex:fe(Number)},emits:["change"],setup(e,{emit:r,slots:u}){const o=P(),n=g=>r("change",g),t=()=>{var g;const f=(g=u.default)==null?void 0:g.call(u);return e.animated||e.swipeable?y(Tt,{ref:o,loop:!1,class:Se("track"),duration:+e.duration*1e3,touchable:e.swipeable,lazyRender:e.lazyRender,showIndicators:!1,onChange:n},{default:()=>[f]}):f},d=g=>{const f=o.value;f&&f.state.active!==g&&f.swipeTo(g,{immediate:!e.inited})};return B(()=>e.currentIndex,d),me(()=>{d(e.currentIndex)}),Q({swipeRef:o}),()=>y("div",{class:Se("content",{animated:e.animated||e.swipeable})},[t()])}});const[We,ie]=Z("tabs"),kt={type:Re("line"),color:String,border:Boolean,sticky:Boolean,shrink:Boolean,active:N(0),duration:N(.3),animated:Boolean,ellipsis:W,swipeable:Boolean,scrollspy:Boolean,offsetTop:N(0),background:String,lazyRender:W,lineWidth:L,lineHeight:L,beforeChange:Function,swipeThreshold:N(5),titleActiveColor:String,titleInactiveColor:String},Ye=Symbol(We);var It=V({name:We,props:kt,emits:["change","scroll","rendered","clickTab","update:active"],setup(e,{emit:r,slots:u}){let o,n,t;const d=P(),g=P(),f=P(),w=P(),l=De(),c=Be(d),[m,C]=dt(),{children:b,linkChildren:I}=Pe(Ye),v=oe({inited:!1,position:"",lineStyle:{},currentIndex:-1}),z=S(()=>b.length>+e.swipeThreshold||!e.ellipsis||e.shrink),K=S(()=>({borderColor:e.color,background:e.background})),D=(a,i)=>{var h;return(h=a.name)!=null?h:i},U=S(()=>{const a=b[v.currentIndex];if(a)return D(a,v.currentIndex)}),R=S(()=>_e(e.offsetTop)),Y=S(()=>e.sticky?R.value+o:0),F=a=>{const i=g.value,h=m.value;if(!z.value||!i||!h||!h[v.currentIndex])return;const k=h[v.currentIndex].$el,$=k.offsetLeft-(i.offsetWidth-k.offsetWidth)/2;ct(i,$,a?0:+e.duration)},_=()=>{const a=v.inited;H(()=>{const i=m.value;if(!i||!i[v.currentIndex]||e.type!=="line"||le(d.value))return;const h=i[v.currentIndex].$el,{lineWidth:k,lineHeight:$}=e,A=h.offsetLeft+h.offsetWidth/2,X={width:ye(k),backgroundColor:e.color,transform:`translateX(${A}px) translateX(-50%)`};if(a&&(X.transitionDuration=`${e.duration}s`),ge($)){const we=ye($);X.height=we,X.borderRadius=we}v.lineStyle=X})},J=a=>{const i=a<v.currentIndex?-1:1;for(;a>=0&&a<b.length;){if(!b[a].disabled)return a;a+=i}},O=(a,i)=>{const h=J(a);if(!ge(h))return;const k=b[h],$=D(k,h),A=v.currentIndex!==null;v.currentIndex!==h&&(v.currentIndex=h,i||F(),_()),$!==e.active&&(r("update:active",$),A&&r("change",$,k.title)),t&&!e.scrollspy&&Je(Math.ceil(xe(d.value)-R.value))},E=(a,i)=>{const h=b.find(($,A)=>D($,A)===a),k=h?b.indexOf(h):0;O(k,i)},M=(a=!1)=>{if(e.scrollspy){const i=b[v.currentIndex].$el;if(i&&c.value){const h=xe(i,c.value)-Y.value;n=!0,ut(c.value,h,a?0:+e.duration,()=>{n=!1})}}},p=(a,i,h)=>{const{title:k,disabled:$}=b[i],A=D(b[i],i);$||(tt(e.beforeChange,{args:[A],done:()=>{O(i),M()}}),at(a)),r("clickTab",{name:A,title:k,event:h,disabled:$})},ee=a=>{t=a.isFixed,r("scroll",a)},se=a=>{H(()=>{E(a),M(!0)})},re=()=>{for(let a=0;a<b.length;a++){const{top:i}=q(b[a].$el);if(i>Y.value)return a===0?0:a-1}return b.length-1},te=()=>{if(e.scrollspy&&!n){const a=re();O(a)}},ce=()=>b.map((a,i)=>y(wt,pe({key:a.id,id:`${l}-${i}`,ref:C(i),type:e.type,color:e.color,style:a.titleStyle,class:a.titleClass,shrink:e.shrink,isActive:i===v.currentIndex,controls:a.id,scrollable:z.value,activeColor:e.titleActiveColor,inactiveColor:e.titleInactiveColor,onClick:h=>p(a,i,h)},et(a,["dot","badge","title","disabled","showZeroBadge"])),{title:a.$slots.title})),ue=()=>{if(e.type==="line"&&b.length)return y("div",{class:ie("line"),style:v.lineStyle},null)},ae=()=>{var a,i,h;const{type:k,border:$,sticky:A}=e,X=[y("div",{ref:A?void 0:f,class:[ie("wrap"),{[Qe]:k==="line"&&$}]},[y("div",{ref:g,role:"tablist",class:ie("nav",[k,{shrink:e.shrink,complete:z.value}]),style:K.value,"aria-orientation":"horizontal"},[(a=u["nav-left"])==null?void 0:a.call(u),ce(),ue(),(i=u["nav-right"])==null?void 0:i.call(u)])]),(h=u["nav-bottom"])==null?void 0:h.call(u)];return A?y("div",{ref:f},[X]):X};B([()=>e.color,ze],_),B(()=>e.active,a=>{a!==U.value&&E(a)}),B(()=>b.length,()=>{v.inited&&(E(e.active),_(),H(()=>{F(!0)}))});const s=()=>{E(e.active,!0),H(()=>{v.inited=!0,f.value&&(o=q(f.value).height),F(!0)})},x=(a,i)=>r("rendered",a,i);return Q({resize:()=>{_(),H(()=>{var a,i;return(i=(a=w.value)==null?void 0:a.swipeRef.value)==null?void 0:i.resize()})},scrollTo:se}),Oe(_),Ee(_),$e(s),Ne(d,_),be("scroll",te,{target:c,passive:!0}),I({id:l,props:e,setLine:_,onRendered:x,currentName:U,scrollIntoView:F}),()=>y("div",{ref:d,class:ie([e.type])},[e.sticky?y(bt,{container:d.value,offsetTop:R.value,onScroll:ee},{default:()=>[ae()]}):ae(),y(Ct,{ref:w,count:b.length,inited:v.inited,animated:e.animated,duration:e.duration,swipeable:e.swipeable,lazyRender:e.lazyRender,currentIndex:v.currentIndex,onChange:O},{default:()=>{var a;return[(a=u.default)==null?void 0:a.call(u)]}})])}});const[$t,Rt]=Z("swipe-item");var Bt=V({name:$t,setup(e,{slots:r}){let u;const o=oe({offset:0,inited:!1,mounted:!1}),{parent:n,index:t}=Me(He);if(!n)return;const d=S(()=>{const w={},{vertical:l}=n.props;return n.size.value&&(w[l?"height":"width"]=`${n.size.value}px`),o.offset&&(w.transform=`translate${l?"Y":"X"}(${o.offset}px)`),w}),g=S(()=>{const{loop:w,lazyRender:l}=n.props;if(!l||u)return!0;if(!o.mounted)return!1;const c=n.activeIndicator.value,m=n.count.value-1,C=c===0&&w?m:c-1,b=c===m&&w?0:c+1;return u=t.value===c||t.value===C||t.value===b,u}),f=w=>{o.offset=w};return me(()=>{H(()=>{o.mounted=!0})}),Q({setOffset:f}),()=>{var w;return y("div",{class:Rt(),style:d.value},[g.value?(w=r.default)==null?void 0:w.call(r):null])}}});const _t=G(Bt),[At,ve]=Z("tab"),Pt=Ae({},nt,{dot:Boolean,name:L,badge:L,title:String,disabled:Boolean,titleClass:it,titleStyle:[String,Object],showZeroBadge:W});var zt=V({name:At,props:Pt,setup(e,{slots:r}){const u=De(),o=P(!1),{parent:n,index:t}=Me(Ye);if(!n)return;const d=()=>{var l;return(l=e.name)!=null?l:t.value},g=()=>{o.value=!0,n.props.lazyRender&&H(()=>{n.onRendered(d(),e.title)})},f=S(()=>{const l=d()===n.currentName.value;return l&&!o.value&&g(),l}),w=P(!f.value);return B(f,l=>{l?w.value=!1:j(()=>{w.value=!0})}),B(()=>e.title,()=>{n.setLine(),n.scrollIntoView()}),ot(rt,f),()=>{var l;const c=`${n.id}-${t.value}`,{animated:m,swipeable:C,scrollspy:b,lazyRender:I}=n.props;if(!r.default&&!m)return;const v=b||f.value;if(m||C)return y(_t,{id:u,role:"tabpanel",class:ve("panel-wrapper",{inactive:w.value}),tabindex:f.value?0:-1,"aria-hidden":!f.value,"aria-labelledby":c},{default:()=>{var D;return[y("div",{class:ve("panel")},[(D=r.default)==null?void 0:D.call(r)])]}});const K=o.value||b||!I?(l=r.default)==null?void 0:l.call(r):null;return Q({id:u}),lt(y("div",{id:u,role:"tabpanel",class:ve("panel"),tabindex:v?0:-1,"aria-labelledby":c},[K]),[[st,v]])}}});const Dt=G(zt),Mt=G(It);export{bt as S,Mt as T,Dt as a,Tt as b,_t as c};
|