index.737b20db.js 7.8 KB

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