You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
9.8 KiB

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