1 |
- import{ad as q,aQ as ie,bC as $e,r as I,bc as _e,ax as Pe,aE as Ae,aw as ze,aS as le,c as E,n as A,m as re,b as N,d as L,aP as se,q as ce,e as k,bA as de,a9 as ue,i as Ne,w as P,Y as fe,a as g,bz as ve,Z as O,k as j,t as M,W as Y,au as Oe,aX as V,x as Ee,X as K,bu as be,a7 as Le,aZ as De,y as z,aD as Ze,aR as He,o as te,a8 as We,bq as Me,bD as ne,h as Fe,ae as Ue,$ as Ve,bE as Xe,ar as qe,a3 as Ye,aa as je,ac as Ke,aI as Qe,g as Ge,v as Je}from"./index-f79163ea.js";import{T as pe}from"./use-tab-status-b43be300.js";import{S as et,a as tt}from"./index-40eb7c2d.js";function nt(e,i,r){let l=0;const n=e.scrollLeft,a=r===0?1:Math.round(r*1e3/16);function s(){e.scrollLeft+=(i-n)/a,++l<a&&q(s)}s()}function at(e,i,r,l){let n=ie(e);const a=n<i,s=r===0?1:Math.round(r*1e3/16),b=(i-n)/s;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 r=new IntersectionObserver(a=>{i(a[0].intersectionRatio>0)},{root:document.body}),l=()=>{e.value&&r.observe(e.value)},n=()=>{e.value&&r.unobserve(e.value)};Ae(n),ze(n),le(l)}const[it,lt]=E("sticky"),rt={zIndex:A,position:re("top"),container:Object,offsetTop:N(0),offsetBottom:N(0)};var st=L({name:it,props:rt,emits:["scroll","change"],setup(e,{emit:i,slots:r}){const l=I(),n=se(l),a=ce({fixed:!1,width:0,height:0,transform:0}),s=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(Ne(e.zIndex),{width:`${a.width}px`,height:`${a.height}px`,[e.position]:`${s.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=O(l),v=ie(window);if(a.width=x.width,a.height=x.height,w==="top")if(f){const S=O(f),c=S.bottom-s.value-a.height;a.fixed=s.value>x.top&&S.bottom>0,a.transform=c<0?c:0}else a.fixed=s.value>x.top;else{const{clientHeight:S}=document.documentElement;if(f){const c=O(f),B=S-c.top-s.value-a.height;a.fixed=S-s.value<x.bottom&&S>c.top,a.transform=B<0?-B:0}else a.fixed=S-s.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=r.default)==null?void 0:f.call(r)])])}}});const ct=j(st),[dt,ae]=E("tab");var ut=L({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 r=k(()=>{const n={},{type:a,color:s,disabled:b,isActive:u,activeColor:C,inactiveColor:h}=e;s&&a==="card"&&(n.borderColor=s,b||(u?n.backgroundColor=s:n.color=s));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(Oe,{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:r.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]=E("tabs");var vt=L({name:ft,props:{count:V(Number),inited:Boolean,animated:Boolean,duration:V(A),swipeable:Boolean,lazyRender:Boolean,currentIndex:V(Number)},emits:["change"],setup(e,{emit:i,slots:r}){const l=I(),n=b=>i("change",b),a=()=>{var b;const u=(b=r.default)==null?void 0:b.call(r);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},s=b=>{const u=l.value;u&&u.state.active!==b&&u.swipeTo(b,{immediate:!e.inited})};return P(()=>e.currentIndex,s),Ee(()=>{s(e.currentIndex)}),K({swipeRef:l}),()=>g("div",{class:oe("content",{animated:e.animated||e.swipeable})},[a()])}});const[ge,W]=E("tabs"),bt={type:re("line"),color:String,border:Boolean,sticky:Boolean,shrink:Boolean,active:N(0),duration:N(.3),animated:Boolean,ellipsis:M,swipeable:Boolean,scrollspy:Boolean,offsetTop:N(0),background:String,lazyRender:M,lineWidth:A,lineHeight:A,beforeChange:Function,swipeThreshold:N(5),titleActiveColor:String,titleInactiveColor:String},me=Symbol(ge);var ht=L({name:ge,props:bt,emits:["change","scroll","rendered","clickTab","update:active"],setup(e,{emit:i,slots:r}){let l,n,a;const s=I(),b=I(),u=I(),C=I(),h=be(),f=se(s),[w,x]=ot(),{children:v,linkChildren:S}=Le(me),c=ce({inited:!1,position:"",lineStyle:{},currentIndex:-1}),B=k(()=>v.length>+e.swipeThreshold||!e.ellipsis||e.shrink),F=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)}),U=k(()=>de(e.offsetTop)),G=k(()=>e.sticky?U.value+l:0),D=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(s.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}},Z=(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||D(),R()),m!==e.active&&(i("update:active",m),T&&i("change",m,y.title)),a&&!e.scrollspy&&Me(Math.ceil(ne(s.value)-U.value))},H=(t,o)=>{const d=v.find((m,T)=>$(m,T)===t),y=d?v.indexOf(d):0;Z(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||(Ve(e.beforeChange,{args:[T],done:()=>{Z(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(()=>{H(t),J(!0)})},Te=()=>{for(let t=0;t<v.length;t++){const{top:o}=O(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();Z(t)}},ke=()=>v.map((t,o)=>g(ut,Fe({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)},Ue(t,["dot","badge","title","disabled","showZeroBadge"])),{title:t.$slots.title})),Ie=()=>{if(e.type==="line"&&v.length)return g("div",{class:W("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:[W("wrap"),{[We]:y==="line"&&m}]},[g("div",{ref:b,role:"tablist",class:W("nav",[y,{shrink:e.shrink,complete:B.value}]),style:F.value,"aria-orientation":"horizontal"},[(t=r["nav-left"])==null?void 0:t.call(r),ke(),Ie(),(o=r["nav-right"])==null?void 0:o.call(r)])]),(d=r["nav-bottom"])==null?void 0:d.call(r)];return T?g("div",{ref:u},[_]):_};P([()=>e.color,De],R),P(()=>e.active,t=>{t!==Q.value&&H(t)}),P(()=>v.length,()=>{c.inited&&(H(e.active),R(),z(()=>{D(!0)}))});const Re=()=>{H(e.active,!0),z(()=>{c.inited=!0,u.value&&(l=O(u.value).height),D(!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}),Ze(R),He(R),le(Re),he(s,R),fe("scroll",Ce,{target:f,passive:!0}),S({id:h,props:e,setLine:R,onRendered:Be,currentName:Q,scrollIntoView:D}),()=>g("div",{ref:s,class:W([e.type])},[e.sticky?g(ct,{container:s.value,offsetTop:U.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:Z},{default:()=>{var t;return[(t=r.default)==null?void 0:t.call(r)]}})])}});const[gt,X]=E("tab"),mt=ue({},qe,{dot:Boolean,name:A,badge:A,title:String,disabled:Boolean,titleClass:Ye,titleStyle:[String,Object],showZeroBadge:M});var yt=L({name:gt,props:mt,setup(e,{slots:i}){const r=be(),l=I(!1),{parent:n,index:a}=je(me);if(!n)return;const s=()=>{var h;return(h=e.name)!=null?h:a.value},b=()=>{l.value=!0,n.props.lazyRender&&z(()=>{n.onRendered(s(),e.title)})},u=k(()=>{const h=s()===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()}),Qe(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:r,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 F=l.value||v||!S?(h=i.default)==null?void 0:h.call(i):null;return K({id:r}),Ge(g("div",{id:r,role:"tabpanel",class:X("panel"),tabindex:c?0:-1,"aria-labelledby":f},[F]),[[Je,c]])}}});const Ct=j(yt),kt=j(ht);export{kt as T,Ct as a};
|