1 |
- import{au as K,ah as me,av as ye,E as M,d as W,G as B,H as L,W as C,i as h,M as U,aw as we,ax as F,U as $,a3 as I,V as Se,a0 as Ce,ab as O,ac as Te,aj as ke,S as xe,ad as Ie,al as Be,X as R,ak as ne,ao as Re,ap as $e,aa as _e,af as Ae,ag as Pe,a2 as J,ay as Ne,az as ze,aA as Q,a8 as Oe,aB as Ee,Y as p,aC as Le,aD as Me,J as We,K as De,I as He,at as Ze,aE as Fe,a6 as Ve,aF as Ke,O as ae}from"./index.7994470a.js";import{u as le}from"./use-id.117b75b2.js";import{T as Ue}from"./use-tab-status.00d7316c.js";import{S as Xe,a as Ye}from"./index.889feca1.js";import{u as je}from"./use-refs.ad5f4144.js";import{S as qe}from"./index.6449f9de.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&&K(c)}c()}function Je(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?K(r):f&&K(f)}r()}const[Qe,ee]=M("tab");var pe=W({name:Qe,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:L},setup(e,{slots:l}){const i=C(()=>{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||U(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]=M("tabs");var tt=W({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(Xe,{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,E]=M("tabs"),nt={type:Ce("line"),color:String,border:Boolean,sticky:Boolean,shrink:Boolean,active:O(0),duration:O(.3),animated:Boolean,ellipsis:L,swipeable:Boolean,scrollspy:Boolean,offsetTop:O(0),background:String,lazyRender:L,lineWidth:B,lineHeight:B,beforeChange:Function,swipeThreshold:O(5),titleActiveColor:String,titleInactiveColor:String},oe=Symbol(ie);var at=W({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=Te(c),[T,k]=je(),{children:d,linkChildren:D}=ke(oe),s=xe({inited:!1,position:"",lineStyle:{},currentIndex:-1}),_=C(()=>d.length>e.swipeThreshold||!e.ellipsis||e.shrink),H=C(()=>({borderColor:e.color,background:e.background})),w=(t,n)=>{var o;return(o=t.name)!=null?o:n},X=C(()=>{const t=d[s.currentIndex];if(t)return w(t,s.currentIndex)}),Z=C(()=>Ie(e.offsetTop)),Y=C(()=>e.sticky?Z.value+f:0),A=t=>{const n=v.value,o=T.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=T.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:J(b),backgroundColor:e.color,transform:`translateX(${x}px) translateX(-50%)`};if(t&&(z.transitionDuration=`${e.duration}s`),U(m)){const G=J(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(!U(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)},j=(t=!1)=>{if(e.scrollspy){const n=d[s.currentIndex].$el;if(n&&y.value){const o=Q(n,y.value)-Y.value;a=!0,Je(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):(Le(e.beforeChange,{args:[x],done:()=>{P(n),j()}}),l("click",x,b),Me(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),j(!0)})},ue=()=>{for(let t=0;t<d.length;t++){const{top:n}=p(d[t].$el);if(n>Y.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)},Ee(t,["dot","badge","title","disabled","showZeroBadge"])),{title:t.$slots.title})),be=()=>{if(e.type==="line"&&d.length)return h("div",{class:E("line"),style:s.lineStyle},null)},q=()=>{var t,n;const{type:o,border:b}=e;return h("div",{ref:r,class:[E("wrap"),{[Ne]:o==="line"&&b}]},[h("div",{ref:v,role:"tablist",class:E("nav",[o,{shrink:e.shrink,complete:_.value}]),style:H.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!==X.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(Q(c.value)-Z.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}),D({id:g,props:e,setLine:S,onRendered:ge,currentName:X,scrollIntoView:A}),()=>{var t;return h("div",{ref:c,class:E([e.type])},[e.sticky?h(qe,{container:c.value,offsetTop:Z.value,onScroll:ce},{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)],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,V]=M("tab"),it=We({},De,{dot:Boolean,name:B,badge:B,title:String,disabled:Boolean,titleClass:He,titleStyle:[String,Object],showZeroBadge:L});var ot=W({name:lt,props:it,setup(e,{slots:l}){const i=le(),f=$(!1),{parent:a,index:u}=Ze(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=C(()=>{const g=c()===a.currentName.value;return g&&!f.value&&v(),g});return I(()=>e.title,()=>{a.setLine(),a.scrollIntoView()}),Fe(Ue,r),()=>{var g;const y=`${a.id}-${u.value}`,{animated:T,swipeable:k,scrollspy:d,lazyRender:D}=a.props;if(!l.default&&!T)return;const s=d||r.value;if(T||k)return h(Ye,{id:i,role:"tabpanel",class:V("panel-wrapper",{inactive:!r.value}),tabindex:r.value?0:-1,"aria-hidden":!r.value,"aria-labelledby":y},{default:()=>{var w;return[h("div",{class:V("panel")},[(w=l.default)==null?void 0:w.call(l)])]}});const H=f.value||d||!D?(g=l.default)==null?void 0:g.call(l):null;return ne({id:i}),Ve(h("div",{id:i,role:"tabpanel",class:V("panel"),tabindex:s?0:-1,"aria-labelledby":y},[H]),[[Ke,s]])}}});const vt=ae(ot),bt=ae(at);export{bt as T,vt as a};
|