index-legacy-59c9f172.js 10 KB

1
  1. System.register(["./index-legacy-e6be1dcb.js","./use-tab-status-legacy-5a183110.js","./index-legacy-c97c0453.js"],(function(e,t){"use strict";var n,l,o,a,i,r,s,d,c,u,v,f,p,b,h,g,m,x,y,w,I,k,B,S,C,T,$,R,z,A,L,j,O,W,Z,H,N,F,M,V,X,E,Y,D,G,J,K,Q,_,q,P,U,ee,te,ne,le,oe,ae,ie,re,se,de,ce;return{setters:[e=>{n=e.aA,l=e.aB,o=e.bE,a=e.bK,i=e.r,r=e.aG,s=e.aw,d=e.aY,c=e.av,u=e.bL,v=e.c,f=e.n,p=e.m,b=e.b,h=e.d,g=e.by,m=e.x,x=e.e,y=e.bB,w=e.ad,I=e.i,k=e.w,B=e._,S=e.bA,C=e.z,T=e.$,$=e.bH,R=e.bI,z=e.a,A=e.k,L=e.bb,j=e.y,O=e.Z,W=e.t,Z=e.bo,H=e.ab,N=e.aX,F=e.bJ,M=e.o,V=e.Y,X=e.aQ,E=e.bn,Y=e.bM,D=e.a1,G=e.bN,J=e.b8,K=e.b5,Q=e.a6,_=e.ae,q=e.au,P=e.bf,U=e.bO,ee=e.aL,te=e.aS,ne=e.aF,le=e.g,oe=e.v,ae=e.h,ie=e.af,re=e.aV},e=>{se=e.T},e=>{de=e.S,ce=e.a}],execute:function(){function t(e,t){if(!s||!window.IntersectionObserver)return;const n=new IntersectionObserver((e=>{t(e[0].intersectionRatio>0)}),{root:document.body}),l=()=>{e.value&&n.unobserve(e.value)};d(l),c(l),u((()=>{e.value&&n.observe(e.value)}))}const[ue,ve]=v("sticky"),fe={zIndex:f,position:p("top"),container:Object,offsetTop:b(0),offsetBottom:b(0)};var pe=h({name:ue,props:fe,emits:["scroll","change"],setup(e,{emit:n,slots:l}){const a=i(),r=g(a),s=m({fixed:!1,width:0,height:0,transform:0}),d=i(!1),c=x((()=>y("top"===e.position?e.offsetTop:e.offsetBottom))),u=x((()=>{if(d.value)return;const{fixed:e,height:t,width:n}=s;return e?{width:`${n}px`,height:`${t}px`}:void 0})),v=x((()=>{if(!s.fixed||d.value)return;const t=w(I(e.zIndex),{width:`${s.width}px`,height:`${s.height}px`,[e.position]:`${c.value}px`});return s.transform&&(t.transform=`translate3d(0, ${s.transform}px, 0)`),t})),f=()=>{if(!a.value||S(a))return;const{container:t,position:l}=e,i=T(a),r=o(window);if(s.width=i.width,s.height=i.height,"top"===l)if(t){const e=T(t),n=e.bottom-c.value-s.height;s.fixed=c.value>i.top&&e.bottom>0,s.transform=n<0?n:0}else s.fixed=c.value>i.top;else{const{clientHeight:e}=document.documentElement;if(t){const n=T(t),l=e-n.top-c.value-s.height;s.fixed=e-c.value<i.bottom&&e>n.top,s.transform=l<0?-l:0}else s.fixed=e-c.value<i.bottom}(e=>{n("scroll",{scrollTop:e,isFixed:s.fixed})})(r)};return k((()=>s.fixed),(e=>n("change",e))),B("scroll",f,{target:r,passive:!0}),t(a,f),k([$,R],(()=>{a.value&&!S(a)&&s.fixed&&(d.value=!0,C((()=>{const e=T(a);s.width=e.width,s.height=e.height,d.value=!1})))})),()=>{var e;return z("div",{ref:a,style:u.value},[z("div",{class:ve({fixed:s.fixed&&!d.value}),style:v.value},[null==(e=l.default)?void 0:e.call(l)])])}}});const be=A(pe),[he,ge]=v("tabs");var me=h({name:he,props:{count:L(Number),inited:Boolean,animated:Boolean,duration:L(f),swipeable:Boolean,lazyRender:Boolean,currentIndex:L(Number)},emits:["change"],setup(e,{emit:t,slots:n}){const l=i(),o=e=>t("change",e),a=()=>{var t;const a=null==(t=n.default)?void 0:t.call(n);return e.animated||e.swipeable?z(de,{ref:l,loop:!1,class:ge("track"),duration:1e3*+e.duration,touchable:e.swipeable,lazyRender:e.lazyRender,showIndicators:!1,onChange:o},{default:()=>[a]}):a},r=t=>{const n=l.value;n&&n.state.active!==t&&n.swipeTo(t,{immediate:!e.inited})};return k((()=>e.currentIndex),r),j((()=>{r(e.currentIndex)})),O({swipeRef:l}),()=>z("div",{class:ge("content",{animated:e.animated||e.swipeable})},[a()])}});const[xe,ye]=v("tabs"),we={type:p("line"),color:String,border:Boolean,sticky:Boolean,shrink:Boolean,active:b(0),duration:b(.3),animated:Boolean,ellipsis:W,swipeable:Boolean,scrollspy:Boolean,offsetTop:b(0),background:String,lazyRender:W,lineWidth:f,lineHeight:f,beforeChange:Function,swipeThreshold:b(5),titleActiveColor:String,titleInactiveColor:String},Ie=Symbol(xe);var ke=h({name:xe,props:we,emits:["change","scroll","rendered","clickTab","update:active"],setup(e,{emit:s,slots:d}){let c,v,f,p,b;const h=i(),w=i(),I=i(),R=i(),A=Z(),L=g(h),[j,W]=function(){const e=i([]),t=[];return r((()=>{e.value=[]})),[e,n=>(t[n]||(t[n]=t=>{e.value[n]=t}),t[n])]}(),{children:J,linkChildren:K}=H(Ie),Q=m({inited:!1,position:"",lineStyle:{},currentIndex:-1}),_=x((()=>J.length>+e.swipeThreshold||!e.ellipsis||e.shrink)),q=x((()=>({borderColor:e.color,background:e.background}))),P=(e,t)=>{var n;return null!=(n=e.name)?n:t},U=x((()=>{const e=J[Q.currentIndex];if(e)return P(e,Q.currentIndex)})),ee=x((()=>y(e.offsetTop))),te=x((()=>e.sticky?ee.value+c:0)),ne=t=>{const o=w.value,a=j.value;if(!(_.value&&o&&a&&a[Q.currentIndex]))return;const i=a[Q.currentIndex].$el,r=i.offsetLeft-(o.offsetWidth-i.offsetWidth)/2;p&&p(),p=function(e,t,o){let a,i=0;const r=e.scrollLeft,s=0===o?1:Math.round(1e3*o/16);return function n(){e.scrollLeft+=(t-r)/s,++i<s&&(a=l(n))}(),function(){n(a)}}(o,r,t?0:+e.duration)},le=()=>{const t=Q.inited;C((()=>{const n=j.value;if(!n||!n[Q.currentIndex]||"line"!==e.type||S(h.value))return;const l=n[Q.currentIndex].$el,{lineWidth:o,lineHeight:a}=e,i=l.offsetLeft+l.offsetWidth/2,r={width:M(o),backgroundColor:e.color,transform:`translateX(${i}px) translateX(-50%)`};if(t&&(r.transitionDuration=`${e.duration}s`),V(a)){const e=M(a);r.height=e,r.borderRadius=e}Q.lineStyle=r}))},oe=(t,n)=>{const l=(e=>{const t=e<Q.currentIndex?-1:1;for(;e>=0&&e<J.length;){if(!J[e].disabled)return e;e+=t}})(t);if(!V(l))return;const o=J[l],a=P(o,l),i=null!==Q.currentIndex;Q.currentIndex!==l&&(Q.currentIndex=l,n||ne(),le()),a!==e.active&&(s("update:active",a),i&&s("change",a,o.title)),f&&!e.scrollspy&&E(Math.ceil(Y(h.value)-ee.value))},ae=(e,t)=>{const n=J.find(((t,n)=>P(t,n)===e)),l=n?J.indexOf(n):0;oe(l,t)},ie=(t=!1)=>{if(e.scrollspy){const i=J[Q.currentIndex].$el;if(i&&L.value){const r=Y(i,L.value)-te.value;v=!0,b&&b(),b=function(e,t,i,r){let s,d=o(e);const c=d<t,u=0===i?1:Math.round(1e3*i/16),v=(t-d)/u;return function n(){d+=v,(c&&d>t||!c&&d<t)&&(d=t),a(e,d),c&&d<t||!c&&d>t?s=l(n):r&&(s=l(r))}(),function(){n(s)}}(L.value,r,t?0:+e.duration,(()=>{v=!1}))}}},re=(t,n,l)=>{const{title:o,disabled:a}=J[n],i=P(J[n],n);a||(D(e.beforeChange,{args:[i],done:()=>{oe(n),ie()}}),G(t)),s("clickTab",{name:i,title:o,event:l,disabled:a})},se=e=>{f=e.isFixed,s("scroll",e)},de=()=>{if("line"===e.type&&J.length)return z("div",{class:ye("line"),style:Q.lineStyle},null)},ce=()=>{var t,n,l;const{type:o,border:a,sticky:i}=e,r=[z("div",{ref:i?void 0:I,class:[ye("wrap"),{[X]:"line"===o&&a}]},[z("div",{ref:w,role:"tablist",class:ye("nav",[o,{shrink:e.shrink,complete:_.value}]),style:q.value,"aria-orientation":"horizontal"},[null==(t=d["nav-left"])?void 0:t.call(d),J.map((e=>e.renderTitle(re))),de(),null==(n=d["nav-right"])?void 0:n.call(d)])]),null==(l=d["nav-bottom"])?void 0:l.call(d)];return i?z("div",{ref:I},[r]):r},ue=()=>{le(),C((()=>{var e,t;ne(!0),null==(t=null==(e=R.value)?void 0:e.swipeRef.value)||t.resize()}))};return k((()=>[e.color,e.duration,e.lineWidth,e.lineHeight]),le),k($,ue),k((()=>e.active),(e=>{e!==U.value&&ae(e)})),k((()=>J.length),(()=>{Q.inited&&(ae(e.active),le(),C((()=>{ne(!0)})))})),O({resize:ue,scrollTo:e=>{C((()=>{ae(e),ie(!0)}))}}),N(le),F(le),u((()=>{ae(e.active,!0),C((()=>{Q.inited=!0,I.value&&(c=T(I.value).height),ne(!0)}))})),t(h,le),B("scroll",(()=>{if(e.scrollspy&&!v){const e=(()=>{for(let e=0;e<J.length;e++){const{top:t}=T(J[e].$el);if(t>te.value)return 0===e?0:e-1}return J.length-1})();oe(e)}}),{target:L,passive:!0}),K({id:A,props:e,setLine:le,scrollable:_,onRendered:(e,t)=>s("rendered",e,t),currentName:U,setTitleRefs:W,scrollIntoView:ne}),()=>z("div",{ref:h,class:ye([e.type])},[e.sticky?z(be,{container:h.value,offsetTop:ee.value,onScroll:se},{default:()=>[ce()]}):ce(),z(me,{ref:R,count:J.length,inited:Q.inited,animated:e.animated,duration:e.duration,swipeable:e.swipeable,lazyRender:e.lazyRender,currentIndex:Q.currentIndex,onChange:oe},{default:()=>{var e;return[null==(e=d.default)?void 0:e.call(d)]}})])}});const[Be,Se]=v("tab"),Ce=h({name:Be,props:{id:String,dot:Boolean,type:String,color:String,title:String,badge:f,shrink:Boolean,isActive:Boolean,disabled:Boolean,controls:String,scrollable:Boolean,activeColor:String,inactiveColor:String,showZeroBadge:W},setup(e,{slots:t}){const n=x((()=>{const t={},{type:n,color:l,disabled:o,isActive:a,activeColor:i,inactiveColor:r}=e;l&&"card"===n&&(t.borderColor=l,o||(a?t.backgroundColor=l:t.color=l));const s=a?i:r;return s&&(t.color=s),t})),l=()=>{const n=z("span",{class:Se("text",{ellipsis:!e.scrollable})},[t.title?t.title():e.title]);return e.dot||V(e.badge)&&""!==e.badge?z(J,{dot:e.dot,content:e.badge,showZero:e.showZeroBadge},{default:()=>[n]}):n};return()=>z("div",{id:e.id,role:"tab",class:[Se([e.type,{grow:e.scrollable&&!e.shrink,shrink:e.shrink,active:e.isActive,disabled:e.disabled}])],style:n.value,tabindex:e.disabled?void 0:e.isActive?0:-1,"aria-selected":e.isActive,"aria-disabled":e.disabled||void 0,"aria-controls":e.controls},[l()])}}),[Te,$e]=v("tab"),Re=w({},K,{dot:Boolean,name:f,badge:f,title:String,disabled:Boolean,titleClass:Q,titleStyle:[String,Object],showZeroBadge:W});var ze=h({name:Te,props:Re,setup(e,{slots:t}){const n=Z(),l=i(!1),o=re(),{parent:a,index:r}=_(Ie);if(!a)return void console.error("[Vant] <Tab> must be a child component of <Tabs>.");const s=()=>{var t;return null!=(t=e.name)?t:r.value},d=x((()=>{const t=s()===a.currentName.value;return t&&!l.value&&(l.value=!0,a.props.lazyRender&&C((()=>{a.onRendered(s(),e.title)}))),t})),c=i(""),u=i("");q((()=>{const{titleClass:t,titleStyle:n}=e;c.value=t?P(t):"",u.value=n&&"string"!=typeof n?U(ee(n)):n}));const v=i(!d.value);return k(d,(e=>{e?v.value=!1:te((()=>{v.value=!0}))})),k((()=>e.title),(()=>{a.setLine(),a.scrollIntoView()})),ne(se,d),O({id:n,renderTitle:l=>z(Ce,ae({key:n,id:`${a.id}-${r.value}`,ref:a.setTitleRefs(r.value),style:u.value,class:c.value,isActive:d.value,controls:n,scrollable:a.scrollable.value,activeColor:a.props.titleActiveColor,inactiveColor:a.props.titleInactiveColor,onClick:e=>l(o.proxy,r.value,e)},ie(a.props,["type","color","shrink"]),ie(e,["dot","badge","title","disabled","showZeroBadge"])),{title:t.title})}),()=>{var e;const o=`${a.id}-${r.value}`,{animated:i,swipeable:s,scrollspy:c,lazyRender:u}=a.props;if(!t.default&&!i)return;const f=c||d.value;if(i||s)return z(ce,{id:n,role:"tabpanel",class:$e("panel-wrapper",{inactive:v.value}),tabindex:d.value?0:-1,"aria-hidden":!d.value,"aria-labelledby":o},{default:()=>{var e;return[z("div",{class:$e("panel")},[null==(e=t.default)?void 0:e.call(t)])]}});const p=l.value||c||!u?null==(e=t.default)?void 0:e.call(t):null;return le(z("div",{id:n,role:"tabpanel",class:$e("panel"),tabindex:f?0:-1,"aria-labelledby":o},[p]),[[oe,f]])}}});e("a",A(ze)),e("T",A(ke))}}}));