index-80468eb1.js 10 KB

1
  1. import{b as C,at as Oe,au as Ne,as as He,d as W,l as de,k as R,w as $,n as A,$ as m,j as Ee,aq as Le,h as Me,bf as De,aB as We,bl as Ze,bc as Fe,an as je,bq as Ue,ap as Ve,am as qe}from"./@vue-cb50a1c4.js";import{aY as ue,aJ as X,g as fe,aZ as Ke,ar as Ye,a_ as ve,c as Z,n as z,a2 as he,m as N,u as be,a$ as me,J as ge,aT as Je,b as we,b0 as G,f as H,aM as ye,aN as Xe,w as p,a5 as Y,d as ee,aO as Ge,D,E as Qe,b1 as pe,F as ie,i as Q,b2 as et,ax as tt,b3 as oe,j as nt,b4 as at,B as lt,K as it,a4 as ot,M as st,b5 as rt,aI as ct,a8 as se}from"./index-ae60edf9.js";import{u as xe}from"./use-id-22cfdfcf.js";function dt(e,a,o){let l,r=0;const t=e.scrollLeft,s=o===0?1:Math.round(o*1e3/16);function c(){ue(l)}function v(){e.scrollLeft+=(a-t)/s,++r<s&&(l=X(v))}return v(),c}function ut(e,a,o,l){let r,t=fe(e);const s=t<a,c=o===0?1:Math.round(o*1e3/16),v=(a-t)/c;function g(){ue(r)}function y(){t+=v,(s&&t>a||!s&&t<a)&&(t=a),Ke(e,t),s&&t<a||!s&&t>a?r=X(y):l&&(r=X(l))}return y(),g}function ft(){const e=C([]),a=[];return Oe(()=>{e.value=[]}),[e,l=>(a[l]||(a[l]=r=>{e.value[l]=r}),a[l])]}function Te(e,a){if(!Ye||!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)};Ne(r),He(r),ve(l)}const[vt,ht]=Z("sticky"),bt={zIndex:z,position:he("top"),container:Object,offsetTop:N(0),offsetBottom:N(0)};var mt=W({name:vt,props:bt,emits:["scroll","change"],setup(e,{emit:a,slots:o}){const l=C(),r=be(l),t=de({fixed:!1,width:0,height:0,transform:0}),s=C(!1),c=R(()=>me(e.position==="top"?e.offsetTop:e.offsetBottom)),v=R(()=>{if(s.value)return;const{fixed:f,height:S,width:u}=t;if(f)return{width:`${u}px`,height:`${S}px`}}),g=R(()=>{if(!t.fixed||s.value)return;const f=ge(Je(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}),y=f=>a("scroll",{scrollTop:f,isFixed:t.fixed}),k=()=>{if(!l.value||G(l))return;const{container:f,position:S}=e,u=H(l),T=fe(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}y(T)};return $(()=>t.fixed,f=>a("change",f)),we("scroll",k,{target:r,passive:!0}),Te(l,k),$([ye,Xe],()=>{!l.value||G(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 m("div",{ref:l,style:v.value},[m("div",{class:ht({fixed:t.fixed&&!s.value}),style:g.value},[(f=o.default)==null?void 0:f.call(o)])])}}});const gt=p(mt),[wt,re]=Z("tabs");var yt=W({name:wt,props:{count:Y(Number),inited:Boolean,animated:Boolean,duration:Y(z),swipeable:Boolean,lazyRender:Boolean,currentIndex:Y(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?m(Ge,{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),Ee(()=>{s(e.currentIndex)}),ee({swipeRef:l}),()=>m("div",{class:re("content",{animated:e.animated||e.swipeable})},[t()])}});const[Se,K]=Z("tabs"),xt={type:he("line"),color:String,border:Boolean,sticky:Boolean,shrink:Boolean,active:N(0),duration:N(.3),animated:Boolean,ellipsis:D,swipeable:Boolean,scrollspy:Boolean,offsetTop:N(0),background:String,lazyRender:D,showHeader:D,lineWidth:z,lineHeight:z,beforeChange:Function,swipeThreshold:N(5),titleActiveColor:String,titleInactiveColor:String},Ce=Symbol(Se);var Tt=W({name:Se,props:xt,emits:["change","scroll","rendered","clickTab","update:active"],setup(e,{emit:a,slots:o}){let l,r,t,s,c;const v=C(),g=C(),y=C(),k=C(),f=xe(),S=be(v),[u,T]=ft(),{children:d,linkChildren:B}=Qe(Ce),b=de({inited:!1,position:"",lineStyle:{},currentIndex:-1}),E=R(()=>d.length>+e.swipeThreshold||!e.ellipsis||e.shrink),F=R(()=>({borderColor:e.color,background:e.background})),L=(n,i)=>{var h;return(h=n.name)!=null?h:i},j=R(()=>{const n=d[b.currentIndex];if(n)return L(n,b.currentIndex)}),O=R(()=>me(e.offsetTop)),te=R(()=>e.sticky?O.value+l:0),M=n=>{const i=g.value,h=u.value;if(!E.value||!i||!h||!h[b.currentIndex])return;const x=h[b.currentIndex].$el,w=x.offsetLeft-(i.offsetWidth-x.offsetWidth)/2;s&&s(),s=dt(i,w,n?0:+e.duration)},_=()=>{const n=b.inited;A(()=>{const i=u.value;if(!i||!i[b.currentIndex]||e.type!=="line"||G(v.value))return;const h=i[b.currentIndex].$el,{lineWidth:x,lineHeight:w}=e,I=h.offsetLeft+h.offsetWidth/2,P={width:ie(x),backgroundColor:e.color,transform:`translateX(${I}px) translateX(-50%)`};if(n&&(P.transitionDuration=`${e.duration}s`),Q(w)){const q=ie(w);P.height=q,P.borderRadius=q}b.lineStyle=P})},Ie=n=>{const i=n<b.currentIndex?-1:1;for(;n>=0&&n<d.length;){if(!d[n].disabled)return n;n+=i}},U=(n,i)=>{const h=Ie(n);if(!Q(h))return;const x=d[h],w=L(x,h),I=b.currentIndex!==null;b.currentIndex!==h&&(b.currentIndex=h,i||M(),_()),w!==e.active&&(a("update:active",w),I&&a("change",w,x.title)),t&&!e.scrollspy&&tt(Math.ceil(oe(v.value)-O.value))},V=(n,i)=>{const h=d.find((w,I)=>L(w,I)===n),x=h?d.indexOf(h):0;U(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=ut(S.value,h,n?0:+e.duration,()=>{r=!1})}}},Re=(n,i,h)=>{const{title:x,disabled:w}=d[i],I=L(d[i],i);w||(nt(e.beforeChange,{args:[I],done:()=>{U(i),ne()}}),at(n)),a("clickTab",{name:I,title:x,event:h,disabled:w})},ke=n=>{t=n.isFixed,a("scroll",n)},Be=n=>{A(()=>{V(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();U(n)}},Pe=()=>{if(e.type==="line"&&d.length)return m("div",{class:K("line"),style:b.lineStyle},null)},ae=()=>{var n,i,h;const{type:x,border:w,sticky:I}=e,P=[m("div",{ref:I?void 0:y,class:[K("wrap"),{[et]:x==="line"&&w}]},[m("div",{ref:g,role:"tablist",class:K("nav",[x,{shrink:e.shrink,complete:E.value}]),style:F.value,"aria-orientation":"horizontal"},[(n=o["nav-left"])==null?void 0:n.call(o),d.map(q=>q.renderTitle(Re)),Pe(),(i=o["nav-right"])==null?void 0:i.call(o)])]),(h=o["nav-bottom"])==null?void 0:h.call(o)];return I?m("div",{ref:y},[P]):P},le=()=>{_(),A(()=>{var n,i;M(!0),(i=(n=k.value)==null?void 0:n.swipeRef.value)==null||i.resize()})};$(()=>[e.color,e.duration,e.lineWidth,e.lineHeight],_),$(ye,le),$(()=>e.active,n=>{n!==j.value&&V(n)}),$(()=>d.length,()=>{b.inited&&(V(e.active),_(),A(()=>{M(!0)}))});const Ae=()=>{V(e.active,!0),A(()=>{b.inited=!0,y.value&&(l=H(y.value).height),M(!0)})},ze=(n,i)=>a("rendered",n,i);return ee({resize:le,scrollTo:Be}),Le(_),pe(_),ve(Ae),Te(v,_),we("scroll",_e,{target:S,passive:!0}),B({id:f,props:e,setLine:_,scrollable:E,onRendered:ze,currentName:j,setTitleRefs:T,scrollIntoView:M}),()=>m("div",{ref:v,class:K([e.type])},[e.showHeader?e.sticky?m(gt,{container:v.value,offsetTop:O.value,onScroll:ke},{default:()=>[ae()]}):ae():null,m(yt,{ref:k,count:d.length,inited:b.inited,animated:e.animated,duration:e.duration,swipeable:e.swipeable,lazyRender:e.lazyRender,currentIndex:b.currentIndex,onChange:U},{default:()=>{var n;return[(n=o.default)==null?void 0:n.call(o)]}})])}});const St=Symbol(),[Ct,ce]=Z("tab"),It=W({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:D},setup(e,{slots:a}){const o=R(()=>{const r={},{type:t,color:s,disabled:c,isActive:v,activeColor:g,inactiveColor:y}=e;s&&t==="card"&&(r.borderColor=s,c||(v?r.backgroundColor=s:r.color=s));const f=v?g:y;return f&&(r.color=f),r}),l=()=>{const r=m("span",{class:ce("text",{ellipsis:!e.scrollable})},[a.title?a.title():e.title]);return e.dot||Q(e.badge)&&e.badge!==""?m(lt,{dot:e.dot,content:e.badge,showZero:e.showZeroBadge},{default:()=>[r]}):r};return()=>m("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()])}}),[Rt,J]=Z("tab"),kt=ge({},it,{dot:Boolean,name:z,badge:z,title:String,disabled:Boolean,titleClass:ot,titleStyle:[String,Object],showZeroBadge:D});var Bt=W({name:Rt,props:kt,setup(e,{slots:a}){const o=xe(),l=C(!1),r=Me(),{parent:t,index:s}=st(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)})},g=R(()=>{const u=c()===t.currentName.value;return u&&!l.value&&v(),u}),y=C(""),k=C("");De(()=>{const{titleClass:u,titleStyle:T}=e;y.value=u?je(u):"",k.value=T&&typeof T!="string"?Ue(Ve(T)):T});const f=u=>m(It,qe({key:o,id:`${t.id}-${s.value}`,ref:t.setTitleRefs(s.value),style:k.value,class:y.value,isActive:g.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(!g.value);return $(g,u=>{u?S.value=!1:rt(()=>{S.value=!0})}),$(()=>e.title,()=>{t.setLine(),t.scrollIntoView()}),We(St,g),ee({id:o,renderTitle:f}),()=>{var u;const T=`${t.id}-${s.value}`,{animated:d,swipeable:B,scrollspy:b,lazyRender:E}=t.props;if(!a.default&&!d)return;const F=b||g.value;if(d||B)return m(ct,{id:o,role:"tabpanel",class:J("panel-wrapper",{inactive:S.value}),tabindex:g.value?0:-1,"aria-hidden":!g.value,"aria-labelledby":T},{default:()=>{var O;return[m("div",{class:J("panel")},[(O=a.default)==null?void 0:O.call(a)])]}});const j=l.value||b||!E?(u=a.default)==null?void 0:u.call(a):null;return Ze(m("div",{id:o,role:"tabpanel",class:J("panel"),tabindex:F?0:-1,"aria-labelledby":T},[j]),[[Fe,F]])}}});const At=p(Bt),zt=p(Tt);export{At as T,zt as a};