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