index.be0e74d4.js 9.5 KB

1
  1. import{q as Be,r as B,L as $e,M as j,h as Re,y as _e,z as Pe,x as ae,d as O,N as oe,k as le,s as k,p as ie,A as I,F as re,c as b,b as N,f as q,G as Ae,O as ze,E as z,H as Ne,w as Oe,P as Le,Q as Ee,t as De,C as He,D as Me}from"./index.641e320a.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 K,t as Z,B as Fe,d as U,e as Ue,f as fe,o as Ve,h as p,j as je,k as qe,l as ee,p as Ke,r as Xe,q as Ye,v as Ge}from"./index.ab3fe1a3.js";import{T as Qe}from"./use-tab-status.d5a54b07.js";import{S as Je,a as pe}from"./index.0ddc9cec.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&&j(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?j(u):r&&j(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=O({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=k(()=>ce(e.position==="top"?e.offsetTop:e.offsetBottom)),h=k(()=>{const{fixed:f,height:x,width:d}=l;if(f)return{width:`${d}px`,height:`${x}px`}}),u=k(()=>{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=N(r),A=se(window);if(l.width=d.width,l.height=d.height,x==="top")if(f){const s=N(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=N(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=K(st),[dt,te]=L("tab");var ut=O({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=k(()=>{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||q(e.badge)&&e.badge!==""?b(Fe,{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=O({name:ft,props:{count:U(Number),inited:Boolean,animated:Boolean,duration:U($),swipeable:Boolean,lazyRender:Boolean,currentIndex:U(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(Je,{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=O({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=k(()=>d.length>e.swipeThreshold||!e.ellipsis||e.shrink),R=k(()=>({borderColor:e.color,background:e.background})),C=(t,n)=>{var v;return(v=t.name)!=null?v:n},X=k(()=>{const t=d[s.currentIndex];if(t)return C(t,s.currentIndex)}),F=k(()=>ce(e.offsetTop)),Y=k(()=>e.sticky?F.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)},T=()=>{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`),q(w)){const J=p(w);M.height=J,M.borderRadius=J}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(!q(n))return;const v=d[n],m=C(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)=>C(m,w)===t),v=n?d.indexOf(n):0;D(v)},G=(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],_=C(d[n],n);w?o("disabled",_,m):(Ke(e.beforeChange,{args:[_],done:()=>{D(n),G()}}),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),G(!0)})},xe=()=>{for(let t=0;t<d.length;t++){const{top:n}=N(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)}},ke=()=>d.map((t,n)=>b(ut,Oe({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})),Ce=()=>{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"),{[je]: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),ke(),Ce(),(n=i["nav-right"])==null?void 0:n.call(i)])])};I([()=>e.color,Ue],T),I(()=>e.active,t=>{t!==X.value&&H(t)}),I(()=>d.length,()=>{s.inited&&(H(e.active),T(),z(()=>{E(!0)}))}),I(()=>s.currentIndex,()=>{E(),T(),l&&!e.scrollspy&&qe(Math.ceil(ee(c.value)-F.value))});const Te=()=>{H(e.active),z(()=>{s.inited=!0,u.value&&(r=N(u.value).height),E(!0)})},Ie=(t,n)=>o("rendered",t,n);return fe({resize:T,scrollTo:we}),Ne(T),Ve(T),ae(Te),re("scroll",Se,{target:y}),A({id:g,props:e,setLine:T,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:F.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,V]=L("tab"),gt=ie({},Ye,{dot:Boolean,name:$,badge:$,title:String,disabled:Boolean,titleClass:Ge,titleStyle:[String,Object],showZeroBadge:Z});var yt=O({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=k(()=>{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:V("panel-wrapper",{inactive:!u.value}),tabindex:u.value?0:-1,"aria-hidden":!u.value,"aria-labelledby":y},{default:()=>{var C;return[b("div",{class:V("panel")},[(C=o.default)==null?void 0:C.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:V("panel"),tabindex:s?0:-1,"aria-labelledby":y},[R]),[[Me,s]])}}});const Ct=K(yt),Tt=K(bt);export{Tt as T,Ct as a,ve as u};