index-legacy-96a0e62f.js 8.5 KB

1
  1. System.register(["./index-legacy-95a64e8f.js","./use-tab-status-legacy-d383fc07.js","./index-legacy-22038836.js","./use-refs-legacy-eadbb988.js","./index-legacy-0055ae6c.js"],(function(e,t){"use strict";var l,n,a,r,i,o,s,d,c,u,v,b,p,f,g,h,y,m,x,k,w,S,C,I,B,T,R,z,$,A,L,j,N,W,M,Z,H,V,F,O,E,X,D,J,Q,Y,q,G,K,P,U,_,ee,te,le,ne,ae,re,ie,oe;return{setters:[e=>{l=e.az,n=e.aA,a=e.bl,r=e.bi,i=e.c,o=e.d,s=e.b7,d=e.r,c=e.w,u=e.y,v=e.a2,b=e.a,p=e.n,f=e.m,g=e.b,h=e.t,y=e.bo,m=e.bC,x=e.ag,k=e.x,w=e.e,S=e.bF,C=e.bJ,I=e.z,B=e.aS,T=e.bL,R=e.bk,z=e.a3,$=e.bE,A=e.o,L=e.a1,j=e.aL,N=e.a4,W=e.bn,M=e.bM,Z=e.a6,H=e.bN,V=e.b4,F=e.ai,O=e.b1,E=e.ab,X=e.aj,D=e.aV,J=e.bd,Q=e.bO,Y=e.aY,q=e.aN,G=e.aE,K=e.g,P=e.v,U=e.h,_=e.ak,ee=e.aQ,te=e.k},e=>{le=e.T},e=>{ne=e.S,ae=e.a},e=>{re=e.u},e=>{ie=e.u,oe=e.S}],execute:function(){const[t,se]=i("tabs");var de=o({name:t,props:{count:s(Number),inited:Boolean,animated:Boolean,duration:s(p),swipeable:Boolean,lazyRender:Boolean,currentIndex:s(Number)},emits:["change"],setup(e,{emit:t,slots:l}){const n=d(),a=e=>t("change",e),r=()=>{var t;const r=null==(t=l.default)?void 0:t.call(l);return e.animated||e.swipeable?b(ne,{ref:n,loop:!1,class:se("track"),duration:1e3*+e.duration,touchable:e.swipeable,lazyRender:e.lazyRender,showIndicators:!1,onChange:a},{default:()=>[r]}):r},i=t=>{const l=n.value;l&&l.state.active!==t&&l.swipeTo(t,{immediate:!e.inited})};return c((()=>e.currentIndex),i),u((()=>{i(e.currentIndex)})),v({swipeRef:n}),()=>b("div",{class:se("content",{animated:e.animated||e.swipeable})},[r()])}});const[ce,ue]=i("tabs"),ve={type:f("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},be=Symbol(ce);var pe=o({name:ce,props:ve,emits:["change","scroll","rendered","clickTab","update:active"],setup(e,{emit:t,slots:i}){let o,s,u,p,f;const g=d(),h=d(),V=d(),F=d(),O=y(),E=m(g),[X,D]=re(),{children:J,linkChildren:Q}=x(be),Y=k({inited:!1,position:"",lineStyle:{},currentIndex:-1}),q=w((()=>J.length>+e.swipeThreshold||!e.ellipsis||e.shrink)),G=w((()=>({borderColor:e.color,background:e.background}))),K=(e,t)=>{var l;return null!=(l=e.name)?l:t},P=w((()=>{const e=J[Y.currentIndex];if(e)return K(e,Y.currentIndex)})),U=w((()=>S(e.offsetTop))),_=w((()=>e.sticky?U.value+o:0)),ee=t=>{const a=h.value,r=X.value;if(!(q.value&&a&&r&&r[Y.currentIndex]))return;const i=r[Y.currentIndex].$el,o=i.offsetLeft-(a.offsetWidth-i.offsetWidth)/2;p&&p(),p=function(e,t,a){let r,i=0;const o=e.scrollLeft,s=0===a?1:Math.round(1e3*a/16);return function l(){e.scrollLeft+=(t-o)/s,++i<s&&(r=n(l))}(),function(){l(r)}}(a,o,t?0:+e.duration)},te=()=>{const t=Y.inited;I((()=>{const l=X.value;if(!l||!l[Y.currentIndex]||"line"!==e.type||$(g.value))return;const n=l[Y.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`),L(r)){const e=A(r);o.height=e,o.borderRadius=e}Y.lineStyle=o}))},le=(l,n)=>{const a=(e=>{const t=e<Y.currentIndex?-1:1;for(;e>=0&&e<J.length;){if(!J[e].disabled)return e;e+=t}})(l);if(!L(a))return;const r=J[a],i=K(r,a),o=null!==Y.currentIndex;Y.currentIndex!==a&&(Y.currentIndex=a,n||ee(),te()),i!==e.active&&(t("update:active",i),o&&t("change",i,r.title)),u&&!e.scrollspy&&W(Math.ceil(M(g.value)-U.value))},ne=(e,t)=>{const l=J.find(((t,l)=>K(t,l)===e)),n=l?J.indexOf(l):0;le(n,t)},ae=(t=!1)=>{if(e.scrollspy){const i=J[Y.currentIndex].$el;if(i&&E.value){const o=M(i,E.value)-_.value;s=!0,f&&f(),f=function(e,t,i,o){let s,d=a(e);const c=d<t,u=0===i?1:Math.round(1e3*i/16),v=(t-d)/u;return function l(){d+=v,(c&&d>t||!c&&d<t)&&(d=t),r(e,d),c&&d<t||!c&&d>t?s=n(l):o&&(s=n(o))}(),function(){l(s)}}(E.value,o,t?0:+e.duration,(()=>{s=!1}))}}},se=(l,n,a)=>{const{title:r,disabled:i}=J[n],o=K(J[n],n);i||(Z(e.beforeChange,{args:[o],done:()=>{le(n),ae()}}),H(l)),t("clickTab",{name:o,title:r,event:a,disabled:i})},ce=e=>{u=e.isFixed,t("scroll",e)},ve=()=>{if("line"===e.type&&J.length)return b("div",{class:ue("line"),style:Y.lineStyle},null)},pe=()=>{var t,l,n;const{type:a,border:r,sticky:o}=e,s=[b("div",{ref:o?void 0:V,class:[ue("wrap"),{[j]:"line"===a&&r}]},[b("div",{ref:h,role:"tablist",class:ue("nav",[a,{shrink:e.shrink,complete:q.value}]),style:G.value,"aria-orientation":"horizontal"},[null==(t=i["nav-left"])?void 0:t.call(i),J.map((e=>e.renderTitle(se))),ve(),null==(l=i["nav-right"])?void 0:l.call(i)])]),null==(n=i["nav-bottom"])?void 0:n.call(i)];return o?b("div",{ref:V},[s]):s},fe=()=>{te(),I((()=>{var e,t;ee(!0),null==(t=null==(e=F.value)?void 0:e.swipeRef.value)||t.resize()}))};return c((()=>[e.color,e.duration,e.lineWidth,e.lineHeight]),te),c(C,fe),c((()=>e.active),(e=>{e!==P.value&&ne(e)})),c((()=>J.length),(()=>{Y.inited&&(ne(e.active),te(),I((()=>{ee(!0)})))})),v({resize:fe,scrollTo:e=>{I((()=>{ne(e),ae(!0)}))}}),B(te),T(te),R((()=>{ne(e.active,!0),I((()=>{Y.inited=!0,V.value&&(o=N(V.value).height),ee(!0)}))})),ie(g,te),z("scroll",(()=>{if(e.scrollspy&&!s){const e=(()=>{for(let e=0;e<J.length;e++){const{top:t}=N(J[e].$el);if(t>_.value)return 0===e?0:e-1}return J.length-1})();le(e)}}),{target:E,passive:!0}),Q({id:O,props:e,setLine:te,scrollable:q,onRendered:(e,l)=>t("rendered",e,l),currentName:P,setTitleRefs:D,scrollIntoView:ee}),()=>b("div",{ref:g,class:ue([e.type])},[e.sticky?b(oe,{container:g.value,offsetTop:U.value,onScroll:ce},{default:()=>[pe()]}):pe(),b(de,{ref:F,count:J.length,inited:Y.inited,animated:e.animated,duration:e.duration,swipeable:e.swipeable,lazyRender:e.lazyRender,currentIndex:Y.currentIndex,onChange:le},{default:()=>{var e;return[null==(e=i.default)?void 0:e.call(i)]}})])}});const[fe,ge]=i("tab"),he=o({name:fe,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=w((()=>{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=b("span",{class:ge("text",{ellipsis:!e.scrollable})},[t.title?t.title():e.title]);return e.dot||L(e.badge)&&""!==e.badge?b(V,{dot:e.dot,content:e.badge,showZero:e.showZeroBadge},{default:()=>[l]}):l};return()=>b("div",{id:e.id,role:"tab",class:[ge([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()])}}),[ye,me]=i("tab"),xe=F({},O,{dot:Boolean,name:p,badge:p,title:String,disabled:Boolean,titleClass:E,titleStyle:[String,Object],showZeroBadge:h});var ke=o({name:ye,props:xe,setup(e,{slots:t}){const l=y(),n=d(!1),a=ee(),{parent:r,index:i}=X(be);if(!r)return void console.error("[Vant] <Tab> must be a child component of <Tabs>.");const o=()=>{var t;return null!=(t=e.name)?t:i.value},s=w((()=>{const t=o()===r.currentName.value;return t&&!n.value&&(n.value=!0,r.props.lazyRender&&I((()=>{r.onRendered(o(),e.title)}))),t})),u=d(""),p=d("");D((()=>{const{titleClass:t,titleStyle:l}=e;u.value=t?J(t):"",p.value=l&&"string"!=typeof l?Q(Y(l)):l}));const f=d(!s.value);return c(s,(e=>{e?f.value=!1:q((()=>{f.value=!0}))})),c((()=>e.title),(()=>{r.setLine(),r.scrollIntoView()})),G(le,s),v({id:l,renderTitle:n=>b(he,U({key:l,id:`${r.id}-${i.value}`,ref:r.setTitleRefs(i.value),style:p.value,class:u.value,isActive:s.value,controls:l,scrollable:r.scrollable.value,activeColor:r.props.titleActiveColor,inactiveColor:r.props.titleInactiveColor,onClick:e=>n(a.proxy,i.value,e)},_(r.props,["type","color","shrink"]),_(e,["dot","badge","title","disabled","showZeroBadge"])),{title:t.title})}),()=>{var e;const a=`${r.id}-${i.value}`,{animated:o,swipeable:d,scrollspy:c,lazyRender:u}=r.props;if(!t.default&&!o)return;const v=c||s.value;if(o||d)return b(ae,{id:l,role:"tabpanel",class:me("panel-wrapper",{inactive:f.value}),tabindex:s.value?0:-1,"aria-hidden":!s.value,"aria-labelledby":a},{default:()=>{var e;return[b("div",{class:me("panel")},[null==(e=t.default)?void 0:e.call(t)])]}});const p=n.value||c||!u?null==(e=t.default)?void 0:e.call(t):null;return K(b("div",{id:l,role:"tabpanel",class:me("panel"),tabindex:v?0:-1,"aria-labelledby":a},[p]),[[P,v]])}}});e("a",te(ke)),e("T",te(pe))}}}));