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