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