index-legacy-8f98bf2e.js 10 KB

1
  1. System.register(["./index-legacy-e5f315bc.js","./use-tab-status-legacy-a7e6a1bd.js","./index-legacy-21793ce9.js"],(function(e,t){"use strict";var l,n,o,a,i,r,s,d,c,u,v,f,p,b,h,g,m,x,y,w,k,I,B,S,C,T,R,$,z,A,H,L,N,W,Z,j,O,F,M,V,X,D,E,U,q,G,J,K,Q,Y,_,P,ee,te,le,ne,oe,ae,ie,re,se,de,ce;return{setters:[e=>{l=e.bQ,n=e.aH,o=e.bN,a=e.bR,i=e.r,r=e.aN,s=e.aI,d=e.av,c=e.ar,u=e.aF,v=e.c,f=e.n,p=e.m,b=e.b,h=e.d,g=e.bH,m=e.x,x=e.e,y=e.bK,w=e.ac,k=e.i,I=e.w,B=e.Z,S=e.bJ,C=e.z,T=e._,R=e.bk,$=e.bl,z=e.a,A=e.k,H=e.b7,L=e.y,N=e.Y,W=e.t,Z=e.bz,j=e.aa,O=e.au,F=e.aE,M=e.o,V=e.X,X=e.aU,D=e.bx,E=e.bS,U=e.a0,q=e.bT,G=e.b4,J=e.b1,K=e.a4,Q=e.ad,Y=e.ay,_=e.bb,P=e.bU,ee=e.aD,te=e.aG,le=e.aA,ne=e.g,oe=e.v,ae=e.h,ie=e.ae,re=e.aq},e=>{se=e.T},e=>{de=e.S,ce=e.a}],execute:function(){function t(e,t){if(!s||!window.IntersectionObserver)return;const l=new IntersectionObserver((e=>{t(e[0].intersectionRatio>0)}),{root:document.body}),n=()=>{e.value&&l.unobserve(e.value)};d(n),c(n),u((()=>{e.value&&l.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:l,slots:n}){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:l}=s;return e?{width:`${l}px`,height:`${t}px`}:void 0})),v=x((()=>{if(!s.fixed||d.value)return;const t=w(k(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:n}=e,i=T(a),r=o(window);if(s.width=i.width,s.height=i.height,"top"===n)if(t){const e=T(t),l=e.bottom-c.value-s.height;s.fixed=c.value>i.top&&e.bottom>0,s.transform=l<0?l:0}else s.fixed=c.value>i.top;else{const{clientHeight:e}=document.documentElement;if(t){const l=T(t),n=e-l.top-c.value-s.height;s.fixed=e-c.value<i.bottom&&e>l.top,s.transform=n<0?-n:0}else s.fixed=e-c.value<i.bottom}(e=>{l("scroll",{scrollTop:e,isFixed:s.fixed})})(r)};return I((()=>s.fixed),(e=>l("change",e))),B("scroll",f,{target:r,passive:!0}),t(a,f),I([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=n.default)?void 0:e.call(n)])])}}});const be=A(pe),[he,ge]=v("tabs");var me=h({name:he,props:{count:H(Number),inited:Boolean,animated:Boolean,duration:H(f),swipeable:Boolean,lazyRender:Boolean,currentIndex:H(Number)},emits:["change"],setup(e,{emit:t,slots:l}){const n=i(),o=e=>t("change",e),a=()=>{var t;const a=null==(t=l.default)?void 0:t.call(l);return e.animated||e.swipeable?z(de,{ref:n,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 l=n.value;l&&l.state.active!==t&&l.swipeTo(t,{immediate:!e.inited})};return I((()=>e.currentIndex),r),L((()=>{r(e.currentIndex)})),N({swipeRef:n}),()=>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},ke=Symbol(xe);var Ie=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(),k=i(),$=i(),A=Z(),H=g(h),[L,W]=function(){const e=i([]),t=[];return r((()=>{e.value=[]})),[e,l=>(t[l]||(t[l]=t=>{e.value[l]=t}),t[l])]}(),{children:G,linkChildren:J}=j(ke),K=m({inited:!1,position:"",lineStyle:{},currentIndex:-1}),Q=x((()=>G.length>+e.swipeThreshold||!e.ellipsis||e.shrink)),Y=x((()=>({borderColor:e.color,background:e.background}))),_=(e,t)=>{var l;return null!=(l=e.name)?l:t},P=x((()=>{const e=G[K.currentIndex];if(e)return _(e,K.currentIndex)})),ee=x((()=>y(e.offsetTop))),te=x((()=>e.sticky?ee.value+c:0)),le=t=>{const o=w.value,a=L.value;if(!(Q.value&&o&&a&&a[K.currentIndex]))return;const i=a[K.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 l(){e.scrollLeft+=(t-r)/s,++i<s&&(a=n(l))}(),function(){l(a)}}(o,r,t?0:+e.duration)},ne=()=>{const t=K.inited;C((()=>{const l=L.value;if(!l||!l[K.currentIndex]||"line"!==e.type||S(h.value))return;const n=l[K.currentIndex].$el,{lineWidth:o,lineHeight:a}=e,i=n.offsetLeft+n.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}K.lineStyle=r}))},oe=(t,l)=>{const n=(e=>{const t=e<K.currentIndex?-1:1;for(;e>=0&&e<G.length;){if(!G[e].disabled)return e;e+=t}})(t);if(!V(n))return;const o=G[n],a=_(o,n),i=null!==K.currentIndex;K.currentIndex!==n&&(K.currentIndex=n,l||le(),ne()),a!==e.active&&(s("update:active",a),i&&s("change",a,o.title)),f&&!e.scrollspy&&D(Math.ceil(E(h.value)-ee.value))},ae=(e,t)=>{const l=G.find(((t,l)=>_(t,l)===e)),n=l?G.indexOf(l):0;oe(n,t)},ie=(t=!1)=>{if(e.scrollspy){const i=G[K.currentIndex].$el;if(i&&H.value){const r=E(i,H.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 l(){d+=v,(c&&d>t||!c&&d<t)&&(d=t),a(e,d),c&&d<t||!c&&d>t?s=n(l):r&&(s=n(r))}(),function(){l(s)}}(H.value,r,t?0:+e.duration,(()=>{v=!1}))}}},re=(t,l,n)=>{const{title:o,disabled:a}=G[l],i=_(G[l],l);a||(U(e.beforeChange,{args:[i],done:()=>{oe(l),ie()}}),q(t)),s("clickTab",{name:i,title:o,event:n,disabled:a})},se=e=>{f=e.isFixed,s("scroll",e)},de=()=>{if("line"===e.type&&G.length)return z("div",{class:ye("line"),style:K.lineStyle},null)},ce=()=>{var t,l,n;const{type:o,border:a,sticky:i}=e,r=[z("div",{ref:i?void 0:k,class:[ye("wrap"),{[X]:"line"===o&&a}]},[z("div",{ref:w,role:"tablist",class:ye("nav",[o,{shrink:e.shrink,complete:Q.value}]),style:Y.value,"aria-orientation":"horizontal"},[null==(t=d["nav-left"])?void 0:t.call(d),G.map((e=>e.renderTitle(re))),de(),null==(l=d["nav-right"])?void 0:l.call(d)])]),null==(n=d["nav-bottom"])?void 0:n.call(d)];return i?z("div",{ref:k},[r]):r},ue=()=>{ne(),C((()=>{var e,t;le(!0),null==(t=null==(e=$.value)?void 0:e.swipeRef.value)||t.resize()}))};return I((()=>[e.color,e.duration,e.lineWidth,e.lineHeight]),ne),I(R,ue),I((()=>e.active),(e=>{e!==P.value&&ae(e)})),I((()=>G.length),(()=>{K.inited&&(ae(e.active),ne(),C((()=>{le(!0)})))})),N({resize:ue,scrollTo:e=>{C((()=>{ae(e),ie(!0)}))}}),O(ne),F(ne),u((()=>{ae(e.active,!0),C((()=>{K.inited=!0,k.value&&(c=T(k.value).height),le(!0)}))})),t(h,ne),B("scroll",(()=>{if(e.scrollspy&&!v){const e=(()=>{for(let e=0;e<G.length;e++){const{top:t}=T(G[e].$el);if(t>te.value)return 0===e?0:e-1}return G.length-1})();oe(e)}}),{target:H,passive:!0}),J({id:A,props:e,setLine:ne,scrollable:Q,onRendered:(e,t)=>s("rendered",e,t),currentName:P,setTitleRefs:W,scrollIntoView:le}),()=>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:$,count:G.length,inited:K.inited,animated:e.animated,duration:e.duration,swipeable:e.swipeable,lazyRender:e.lazyRender,currentIndex:K.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 l=x((()=>{const t={},{type:l,color:n,disabled:o,isActive:a,activeColor:i,inactiveColor:r}=e;n&&"card"===l&&(t.borderColor=n,o||(a?t.backgroundColor=n:t.color=n));const s=a?i:r;return s&&(t.color=s),t})),n=()=>{const l=z("span",{class:Se("text",{ellipsis:!e.scrollable})},[t.title?t.title():e.title]);return e.dot||V(e.badge)&&""!==e.badge?z(G,{dot:e.dot,content:e.badge,showZero:e.showZeroBadge},{default:()=>[l]}):l};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: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()])}}),[Te,Re]=v("tab"),$e=w({},J,{dot:Boolean,name:f,badge:f,title:String,disabled:Boolean,titleClass:K,titleStyle:[String,Object],showZeroBadge:W});var ze=h({name:Te,props:$e,setup(e,{slots:t}){const l=Z(),n=i(!1),o=re(),{parent:a,index:r}=Q(ke);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&&!n.value&&(n.value=!0,a.props.lazyRender&&C((()=>{a.onRendered(s(),e.title)}))),t})),c=i(""),u=i("");Y((()=>{const{titleClass:t,titleStyle:l}=e;c.value=t?_(t):"",u.value=l&&"string"!=typeof l?P(ee(l)):l}));const v=i(!d.value);return I(d,(e=>{e?v.value=!1:te((()=>{v.value=!0}))})),I((()=>e.title),(()=>{a.setLine(),a.scrollIntoView()})),le(se,d),N({id:l,renderTitle:n=>z(Ce,ae({key:l,id:`${a.id}-${r.value}`,ref:a.setTitleRefs(r.value),style:u.value,class:c.value,isActive:d.value,controls:l,scrollable:a.scrollable.value,activeColor:a.props.titleActiveColor,inactiveColor:a.props.titleInactiveColor,onClick:e=>n(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:l,role:"tabpanel",class:Re("panel-wrapper",{inactive:v.value}),tabindex:d.value?0:-1,"aria-hidden":!d.value,"aria-labelledby":o},{default:()=>{var e;return[z("div",{class:Re("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 ne(z("div",{id:l,role:"tabpanel",class:Re("panel"),tabindex:f?0:-1,"aria-labelledby":o},[p]),[[oe,f]])}}});e("a",A(ze)),e("T",A(Ie))}}}));