index-legacy.ac7c51db.js 8.6 KB

1
  1. System.register(["./index-legacy.eb062188.js","./use-tab-status-legacy.91417466.js","./index-legacy.fab451f1.js","./index-legacy.10d8486a.js"],(function(e){"use strict";var t,l,n,a,r,i,o,s,c,d,u,v,f,p,b,g,h,y,m,x,w,k,I,S,C,B,T,R,z,$,A,W,L,N,Z,j,H,M,O,V,X,F,D,Q,U,E,G,K,P,Y,_,q,J,ee,te,le,ne,ae,re,ie;return{setters:[function(e){t=e.aK,l=e.aI,n=e.ar,a=e.aF,r=e.R,i=e.aL,o=e.t,s=e.d,c=e.aB,d=e.Z,u=e.$,v=e.W,f=e.c,p=e.z,b=e.u,g=e.w,h=e.v,y=e.Q,m=e.ap,x=e.x,w=e.r,k=e.y,I=e.aM,S=e.aN,C=e._,B=e.aO,T=e.aP,R=e.aH,z=e.a0,$=e.aA,A=e.U,W=e.a1,L=e.G,N=e.I,Z=e.aQ,j=e.aR,H=e.aS,M=e.an,O=e.aT,V=e.N,X=e.ae,F=e.O,D=e.C,Q=e.aU,U=e.aV,E=e.X,G=e.ac,K=e.aW,P=e.aX,Y=e.aY,_=e.E,q=e.am,J=e.ay,ee=e.a9,te=e.D},function(e){le=e.T},function(e){ne=e.S,ae=e.a},function(e){re=e.u,ie=e.S}],execute:function(){function oe(){const e=r([]),t=[];return i((()=>{e.value=[]})),[e,l=>(t[l]||(t[l]=t=>{e.value[l]=t}),t[l])]}e("u",oe);const[se,ce]=o("tabs");var de=s({name:se,props:{count:c(Number),inited:Boolean,animated:Boolean,duration:c(p),swipeable:Boolean,lazyRender:Boolean,currentIndex:c(Number)},emits:["change"],setup(e,{emit:t,slots:l}){const n=r(),a=e=>t("change",e),i=()=>{var t;const r=null==(t=l.default)?void 0:t.call(l);return e.animated||e.swipeable?f(ne,{ref:n,loop:!1,class:ce("track"),duration:1e3*+e.duration,touchable:e.swipeable,lazyRender:e.lazyRender,showIndicators:!1,onChange:a},{default:()=>[r]}):r},o=t=>{const l=n.value;l&&l.state.active!==t&&l.swipeTo(t,{immediate:!e.inited})};return d((()=>e.currentIndex),o),u((()=>{o(e.currentIndex)})),v({swipeRef:n}),()=>f("div",{class:ce("content",{animated:e.animated||e.swipeable})},[i()])}});const[ue,ve]=o("tabs"),fe={type:b("line"),color:String,border:Boolean,sticky:Boolean,shrink:Boolean,active:g(0),duration:g(.3),animated:Boolean,ellipsis:h,swipeable:Boolean,scrollspy:Boolean,offsetTop:g(0),background:String,lazyRender:h,lineWidth:p,lineHeight:p,beforeChange:Function,swipeThreshold:g(5),titleActiveColor:String,titleInactiveColor:String},pe=Symbol(ue);var be=s({name:ue,props:fe,emits:["change","scroll","rendered","clickTab","update:active"],setup(e,{emit:i,slots:o}){let s,c,u,p,b;const g=r(),h=r(),O=r(),V=r(),X=y(),F=m(g),[D,Q]=oe(),{children:U,linkChildren:E}=x(pe),G=w({inited:!1,position:"",lineStyle:{},currentIndex:-1}),K=k((()=>U.length>+e.swipeThreshold||!e.ellipsis||e.shrink)),P=k((()=>({borderColor:e.color,background:e.background}))),Y=(e,t)=>{var l;return null!=(l=e.name)?l:t},_=k((()=>{const e=U[G.currentIndex];if(e)return Y(e,G.currentIndex)})),q=k((()=>I(e.offsetTop))),J=k((()=>e.sticky?q.value+s:0)),ee=n=>{const a=h.value,r=D.value;if(!(K.value&&a&&r&&r[G.currentIndex]))return;const i=r[G.currentIndex].$el,o=i.offsetLeft-(a.offsetWidth-i.offsetWidth)/2;p&&p(),p=function(e,n,a){let r,i=0;const o=e.scrollLeft,s=0===a?1:Math.round(1e3*a/16);return function t(){e.scrollLeft+=(n-o)/s,++i<s&&(r=l(t))}(),function(){t(r)}}(a,o,n?0:+e.duration)},te=()=>{const t=G.inited;C((()=>{const l=D.value;if(!l||!l[G.currentIndex]||"line"!==e.type||$(g.value))return;const n=l[G.currentIndex].$el,{lineWidth:a,lineHeight:r}=e,i=n.offsetLeft+n.offsetWidth/2,o={width:A(a),backgroundColor:e.color,transform:`translateX(${i}px) translateX(-50%)`};if(t&&(o.transitionDuration=`${e.duration}s`),W(r)){const e=A(r);o.height=e,o.borderRadius=e}G.lineStyle=o}))},le=(t,l)=>{const n=(e=>{const t=e<G.currentIndex?-1:1;for(;e>=0&&e<U.length;){if(!U[e].disabled)return e;e+=t}})(t);if(!W(n))return;const a=U[n],r=Y(a,n),o=null!==G.currentIndex;G.currentIndex!==n&&(G.currentIndex=n,l||ee(),te()),r!==e.active&&(i("update:active",r),o&&i("change",r,a.title)),u&&!e.scrollspy&&N(Math.ceil(Z(g.value)-q.value))},ne=(e,t)=>{const l=U.find(((t,l)=>Y(t,l)===e)),n=l?U.indexOf(l):0;le(n,t)},ae=(r=!1)=>{if(e.scrollspy){const i=U[G.currentIndex].$el;if(i&&F.value){const o=Z(i,F.value)-J.value;c=!0,b&&b(),b=function(e,r,i,o){let s,c=n(e);const d=c<r,u=0===i?1:Math.round(1e3*i/16),v=(r-c)/u;return function t(){c+=v,(d&&c>r||!d&&c<r)&&(c=r),a(e,c),d&&c<r||!d&&c>r?s=l(t):o&&(s=l(o))}(),function(){t(s)}}(F.value,o,r?0:+e.duration,(()=>{c=!1}))}}},se=(t,l,n)=>{const{title:a,disabled:r}=U[l],o=Y(U[l],l);r||(j(e.beforeChange,{args:[o],done:()=>{le(l),ae()}}),H(t)),i("clickTab",{name:o,title:a,event:n,disabled:r})},ce=e=>{u=e.isFixed,i("scroll",e)},ue=()=>{if("line"===e.type&&U.length)return f("div",{class:ve("line"),style:G.lineStyle},null)},fe=()=>{var t,l,n;const{type:a,border:r,sticky:i}=e,s=[f("div",{ref:i?void 0:O,class:[ve("wrap"),{[L]:"line"===a&&r}]},[f("div",{ref:h,role:"tablist",class:ve("nav",[a,{shrink:e.shrink,complete:K.value}]),style:P.value,"aria-orientation":"horizontal"},[null==(t=o["nav-left"])?void 0:t.call(o),U.map((e=>e.renderTitle(se))),ue(),null==(l=o["nav-right"])?void 0:l.call(o)])]),null==(n=o["nav-bottom"])?void 0:n.call(o)];return i?f("div",{ref:O},[s]):s},be=()=>{te(),C((()=>{var e,t;ee(!0),null==(t=null==(e=V.value)?void 0:e.swipeRef.value)||t.resize()}))};return d((()=>[e.color,e.duration,e.lineWidth,e.lineHeight]),te),d(S,be),d((()=>e.active),(e=>{e!==_.value&&ne(e)})),d((()=>U.length),(()=>{G.inited&&(ne(e.active),te(),C((()=>{ee(!0)})))})),v({resize:be,scrollTo:e=>{C((()=>{ne(e),ae(!0)}))}}),B(te),T(te),R((()=>{ne(e.active,!0),C((()=>{G.inited=!0,O.value&&(s=M(O.value).height),ee(!0)}))})),re(g,te),z("scroll",(()=>{if(e.scrollspy&&!c){const e=(()=>{for(let e=0;e<U.length;e++){const{top:t}=M(U[e].$el);if(t>J.value)return 0===e?0:e-1}return U.length-1})();le(e)}}),{target:F,passive:!0}),E({id:X,props:e,setLine:te,scrollable:K,onRendered:(e,t)=>i("rendered",e,t),currentName:_,setTitleRefs:Q,scrollIntoView:ee}),()=>f("div",{ref:g,class:ve([e.type])},[e.sticky?f(ie,{container:g.value,offsetTop:q.value,onScroll:ce},{default:()=>[fe()]}):fe(),f(de,{ref:V,count:U.length,inited:G.inited,animated:e.animated,duration:e.duration,swipeable:e.swipeable,lazyRender:e.lazyRender,currentIndex:G.currentIndex,onChange:le},{default:()=>{var e;return[null==(e=o.default)?void 0:e.call(o)]}})])}});const[ge,he]=o("tab"),ye=s({name:ge,props:{id:String,dot:Boolean,type:String,color:String,title:String,badge:p,shrink:Boolean,isActive:Boolean,disabled:Boolean,controls:String,scrollable:Boolean,activeColor:String,inactiveColor:String,showZeroBadge:h},setup(e,{slots:t}){const l=k((()=>{const t={},{type:l,color:n,disabled:a,isActive:r,activeColor:i,inactiveColor:o}=e;n&&"card"===l&&(t.borderColor=n,a||(r?t.backgroundColor=n:t.color=n));const s=r?i:o;return s&&(t.color=s),t})),n=()=>{const l=f("span",{class:he("text",{ellipsis:!e.scrollable})},[t.title?t.title():e.title]);return e.dot||W(e.badge)&&""!==e.badge?f(O,{dot:e.dot,content:e.badge,showZero:e.showZeroBadge},{default:()=>[l]}):l};return()=>f("div",{id:e.id,role:"tab",class:[he([e.type,{grow:e.scrollable&&!e.shrink,shrink:e.shrink,active:e.isActive,disabled:e.disabled}])],style:l.value,tabindex:e.disabled?void 0:e.isActive?0:-1,"aria-selected":e.isActive,"aria-disabled":e.disabled||void 0,"aria-controls":e.controls},[n()])}}),[me,xe]=o("tab"),we=V({},X,{dot:Boolean,name:p,badge:p,title:String,disabled:Boolean,titleClass:F,titleStyle:[String,Object],showZeroBadge:h});var ke=s({name:me,props:we,setup(e,{slots:t}){const l=y(),n=r(!1),a=ee(),{parent:i,index:o}=D(pe);if(!i)return void console.error("[Vant] <Tab> must be a child component of <Tabs>.");const s=()=>{var t;return null!=(t=e.name)?t:o.value},c=k((()=>{const t=s()===i.currentName.value;return t&&!n.value&&(n.value=!0,i.props.lazyRender&&C((()=>{i.onRendered(s(),e.title)}))),t})),u=r(""),p=r("");Q((()=>{const{titleClass:t,titleStyle:l}=e;u.value=t?K(t):"",p.value=l&&"string"!=typeof l?P(Y(l)):l}));const b=r(!c.value);return d(c,(e=>{e?b.value=!1:U((()=>{b.value=!0}))})),d((()=>e.title),(()=>{i.setLine(),i.scrollIntoView()})),E(le,c),v({id:l,renderTitle:n=>f(ye,_({key:l,id:`${i.id}-${o.value}`,ref:i.setTitleRefs(o.value),style:p.value,class:u.value,isActive:c.value,controls:l,scrollable:i.scrollable.value,activeColor:i.props.titleActiveColor,inactiveColor:i.props.titleInactiveColor,onClick:e=>n(a.proxy,o.value,e)},q(i.props,["type","color","shrink"]),q(e,["dot","badge","title","disabled","showZeroBadge"])),{title:t.title})}),()=>{var e;const a=`${i.id}-${o.value}`,{animated:r,swipeable:s,scrollspy:d,lazyRender:u}=i.props;if(!t.default&&!r)return;const v=d||c.value;if(r||s)return f(ae,{id:l,role:"tabpanel",class:xe("panel-wrapper",{inactive:b.value}),tabindex:c.value?0:-1,"aria-hidden":!c.value,"aria-labelledby":a},{default:()=>{var e;return[f("div",{class:xe("panel")},[null==(e=t.default)?void 0:e.call(t)])]}});const p=n.value||d||!u?null==(e=t.default)?void 0:e.call(t):null;return G(f("div",{id:l,role:"tabpanel",class:xe("panel"),tabindex:v?0:-1,"aria-labelledby":a},[p]),[[J,v]])}}});e("a",te(ke)),e("T",te(be))}}}));