1 |
- import{ae as q,af as le,ag as $e,S as I,ah as _e,a6 as Pe,ai as Ae,a7 as ze,aj as ie,m as E,w as A,n as se,q as N,d as L,ak as re,R as ce,v as k,al as de,N as ue,am as Ne,C as P,Y as fe,k as g,an as ve,ao as O,y as Y,t as M,Z as X,ap as Oe,aq as j,W as Ee,D as K,Q as he,u as Le,ar as De,as as He,at as We,X as z,U as te,G as Ze,I as Me,au as ne,E as Ue,av as Ve,aw as je,ax as Fe,ay as qe,aa as Xe,O as Ye,x as Ke,V as Ge,a8 as Qe,az as Je,aA as pe}from"./index.520b75b9.js";import{S as et,a as tt}from"./index.c8b7053e.js";function nt(e,l,s){let i=0;const n=e.scrollLeft,a=s===0?1:Math.round(s*1e3/16);function r(){e.scrollLeft+=(l-n)/a,++i<a&&q(r)}r()}function at(e,l,s,i){let n=le(e);const a=n<l,r=s===0?1:Math.round(s*1e3/16),h=(l-n)/r;function u(){n+=h,(a&&n>l||!a&&n<l)&&(n=l),$e(e,n),a&&n<l||!a&&n>l?q(u):i&&q(i)}u()}function ot(){const e=I([]),l=[];return _e(()=>{e.value=[]}),[e,i=>(l[i]||(l[i]=n=>{e.value[i]=n}),l[i])]}function lt(e,l){if(!Pe||!window.IntersectionObserver)return;const s=new IntersectionObserver(a=>{l(a[0].intersectionRatio>0)},{root:document.body}),i=()=>{e.value&&s.observe(e.value)},n=()=>{e.value&&s.unobserve(e.value)};Ae(n),ze(n),ie(i)}const[it,st]=E("sticky"),rt={zIndex:A,position:se("top"),container:Object,offsetTop:N(0),offsetBottom:N(0)};var ct=L({name:it,props:rt,emits:["scroll","change"],setup(e,{emit:l,slots:s}){const i=I(),n=re(i),a=ce({fixed:!1,width:0,height:0,transform:0}),r=k(()=>de(e.position==="top"?e.offsetTop:e.offsetBottom)),h=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]:`${r.value}px`});return a.transform&&(f.transform=`translate3d(0, ${a.transform}px, 0)`),f}),C=f=>l("scroll",{scrollTop:f,isFixed:a.fixed}),b=()=>{if(!i.value||ve(i))return;const{container:f,position:w}=e,x=O(i),v=le(window);if(a.width=x.width,a.height=x.height,w==="top")if(f){const S=O(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=O(f),R=S-c.top-r.value-a.height;a.fixed=S-r.value<x.bottom&&S>c.top,a.transform=R<0?-R:0}else a.fixed=S-r.value<x.bottom}C(v)};return P(()=>a.fixed,f=>l("change",f)),fe("scroll",b,{target:n,passive:!0}),lt(i,b),()=>{var f;return g("div",{ref:i,style:h.value},[g("div",{class:st({fixed:a.fixed}),style:u.value},[(f=s.default)==null?void 0:f.call(s)])])}}});const dt=Y(ct),[ut,ae]=E("tab");var ft=L({name:ut,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:l}){const s=k(()=>{const n={},{type:a,color:r,disabled:h,isActive:u,activeColor:C,inactiveColor:b}=e;r&&a==="card"&&(n.borderColor=r,h||(u?n.backgroundColor=r:n.color=r));const w=u?C:b;return w&&(n.color=w),n}),i=()=>{const n=g("span",{class:ae("text",{ellipsis:!e.scrollable})},[l.title?l.title():e.title]);return e.dot||X(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: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},[i()])}});const[vt,oe]=E("tabs");var ht=L({name:vt,props:{count:j(Number),inited:Boolean,animated:Boolean,duration:j(A),swipeable:Boolean,lazyRender:Boolean,currentIndex:j(Number)},emits:["change"],setup(e,{emit:l,slots:s}){const i=I(),n=h=>l("change",h),a=()=>{var h;const u=(h=s.default)==null?void 0:h.call(s);return e.animated||e.swipeable?g(et,{ref:i,loop:!1,class:oe("track"),duration:+e.duration*1e3,touchable:e.swipeable,lazyRender:e.lazyRender,showIndicators:!1,onChange:n},{default:()=>[u]}):u},r=h=>{const u=i.value;u&&u.state.active!==h&&u.swipeTo(h,{immediate:!e.inited})};return P(()=>e.currentIndex,r),Ee(()=>{r(e.currentIndex)}),K({swipeRef:i}),()=>g("div",{class:oe("content",{animated:e.animated||e.swipeable})},[a()])}});const[be,Z]=E("tabs"),bt={type:se("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},ge=Symbol(be);var gt=L({name:be,props:bt,emits:["change","scroll","rendered","clickTab","update:active"],setup(e,{emit:l,slots:s}){let i,n,a;const r=I(),h=I(),u=I(),C=I(),b=he(),f=re(r),[w,x]=ot(),{children:v,linkChildren:S}=Le(ge),c=ce({inited:!1,position:"",lineStyle:{},currentIndex:-1}),R=k(()=>v.length>e.swipeThreshold||!e.ellipsis||e.shrink),U=k(()=>({borderColor:e.color,background:e.background})),B=(t,o)=>{var d;return(d=t.name)!=null?d:o},G=k(()=>{const t=v[c.currentIndex];if(t)return B(t,c.currentIndex)}),V=k(()=>de(e.offsetTop)),Q=k(()=>e.sticky?V.value+i:0),D=t=>{const o=h.value,d=w.value;if(!R.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)},$=()=>{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`),X(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}},H=(t,o)=>{const d=ye(t);if(!X(d))return;const y=v[d],m=B(y,d),T=c.currentIndex!==null;c.currentIndex!==d&&(c.currentIndex=d,o||D(),$()),m!==e.active&&(l("update:active",m),T&&l("change",m,y.title)),a&&!e.scrollspy&&Me(Math.ceil(ne(r.value)-V.value))},W=(t,o)=>{const d=v.find((m,T)=>B(m,T)===t),y=d?v.indexOf(d):0;H(y,o)},J=(t=!1)=>{if(e.scrollspy){const o=v[c.currentIndex].$el;if(o&&f.value){const d=ne(o,f.value)-Q.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=B(v[o],o);m||(je(e.beforeChange,{args:[T],done:()=>{H(o),J()}}),Fe(t)),l("clickTab",{name:T,title:y,event:d,disabled:m})},xe=t=>{a=t.isFixed,l("scroll",t)},Se=t=>{z(()=>{W(t),J(!0)})},Te=()=>{for(let t=0;t<v.length;t++){const{top:o}=O(v[t].$el);if(o>Q.value)return t===0?0:t-1}return v.length-1},Ce=()=>{if(e.scrollspy&&!n){const t=Te();H(t)}},ke=()=>v.map((t,o)=>g(ft,Ue({key:t.id,id:`${b}-${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:R.value,activeColor:e.titleActiveColor,inactiveColor:e.titleInactiveColor,onClick:d=>we(t,o,d)},Ve(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:h,role:"tablist",class:Z("nav",[y,{shrink:e.shrink,complete:R.value}]),style:U.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,De],$),P(()=>e.active,t=>{t!==G.value&&W(t)}),P(()=>v.length,()=>{c.inited&&(W(e.active),$(),z(()=>{D(!0)}))});const Re=()=>{W(e.active,!0),z(()=>{c.inited=!0,u.value&&(i=O(u.value).height),D(!0)})},Be=(t,o)=>l("rendered",t,o);return K({resize:()=>{$(),z(()=>{var t,o;return(o=(t=C.value)==null?void 0:t.swipeRef.value)==null?void 0:o.resize()})},scrollTo:Se}),He($),We($),ie(Re),fe("scroll",Ce,{target:f,passive:!0}),S({id:b,props:e,setLine:$,onRendered:Be,currentName:G,scrollIntoView:D}),()=>g("div",{ref:r,class:Z([e.type])},[e.sticky?g(dt,{container:r.value,offsetTop:V.value,onScroll:xe},{default:()=>[p()]}):p(),g(ht,{ref:C,count:v.length,inited:c.inited,animated:e.animated,duration:e.duration,swipeable:e.swipeable,lazyRender:e.lazyRender,currentIndex:c.currentIndex,onChange:H},{default:()=>{var t;return[(t=s.default)==null?void 0:t.call(s)]}})])}});const me=Symbol(),Ct=()=>qe(me,null),[mt,F]=E("tab"),yt=ue({},Xe,{dot:Boolean,name:A,badge:A,title:String,disabled:Boolean,titleClass:Ye,titleStyle:[String,Object],showZeroBadge:M});var wt=L({name:mt,props:yt,setup(e,{slots:l}){const s=he(),i=I(!1),{parent:n,index:a}=Ke(ge);if(!n)return;const r=()=>{var b;return(b=e.name)!=null?b:a.value},h=()=>{i.value=!0,n.props.lazyRender&&z(()=>{n.onRendered(r(),e.title)})},u=k(()=>{const b=r()===n.currentName.value;return b&&!i.value&&h(),b}),C=I(!u.value);return P(u,b=>{b?C.value=!1:Je(()=>{C.value=!0})}),P(()=>e.title,()=>{n.setLine(),n.scrollIntoView()}),Ge(me,u),()=>{var b;const f=`${n.id}-${a.value}`,{animated:w,swipeable:x,scrollspy:v,lazyRender:S}=n.props;if(!l.default&&!w)return;const c=v||u.value;if(w||x)return g(tt,{id:s,role:"tabpanel",class:F("panel-wrapper",{inactive:C.value}),tabindex:u.value?0:-1,"aria-hidden":!u.value,"aria-labelledby":f},{default:()=>{var B;return[g("div",{class:F("panel")},[(B=l.default)==null?void 0:B.call(l)])]}});const U=i.value||v||!S?(b=l.default)==null?void 0:b.call(l):null;return K({id:s}),Qe(g("div",{id:s,role:"tabpanel",class:F("panel"),tabindex:c?0:-1,"aria-labelledby":f},[U]),[[pe,c]])}}});const kt=Y(wt),It=Y(gt);export{dt as S,It as T,kt as a,Ct as u};
|