index-3c2ef0c3.js 15 KB

1
  1. import{ak as e,N as t,al as a,am as l,x as i,an as n,ao as o,ap as r,aq as s,ar as c,z as u,I as d,a2 as v,V as f,d as p,as as h,r as g,b,at as m,H as w,au as x,w as y,k as C,av as I,M as k,a6 as S,aw as B,ax as T,c as z,G as R,E as M,a3 as A,A as H,C as O,ab as L,o as W,ay as D,az as E,L as X,a7 as F,aa as N,aA as Y,aB as Z,W as $,aC as j,D as P,aD as V,aE as G,aF as J,aG as q,$ as K,J as Q,Y as U,aH as _,aI as ee,aJ as te,S as ae,aK as le,aL as ie,aM as ne,R as oe,Q as re,y as se,U as ce}from"./index-7bdeb505.js";function ue(e,t){if(!o||!window.IntersectionObserver)return;const a=new IntersectionObserver((e=>{t(e[0].intersectionRatio>0)}),{root:document.body}),l=()=>{e.value&&a.unobserve(e.value)};r(l),s(l),c((()=>{e.value&&a.observe(e.value)}))}const[de,ve]=u("sticky"),fe=R(p({name:de,props:{zIndex:d,position:v("top"),container:Object,offsetTop:f(0),offsetBottom:f(0)},emits:["scroll","change"],setup(e,{emit:t,slots:l}){const n=i(),o=h(n),r=g({fixed:!1,width:0,height:0,transform:0}),s=i(!1),c=b((()=>m("top"===e.position?e.offsetTop:e.offsetBottom))),u=b((()=>{if(s.value)return;const{fixed:e,height:t,width:a}=r;return e?{width:"".concat(a,"px"),height:"".concat(t,"px")}:void 0})),d=b((()=>{if(!r.fixed||s.value)return;const t=w(x(e.zIndex),{width:"".concat(r.width,"px"),height:"".concat(r.height,"px"),[e.position]:"".concat(c.value,"px")});return r.transform&&(t.transform="translate3d(0, ".concat(r.transform,"px, 0)")),t})),v=()=>{if(!n.value||I(n))return;const{container:l,position:i}=e,o=S(n),s=a(window);if(r.width=o.width,r.height=o.height,"top"===i)if(l){const e=S(l),t=e.bottom-c.value-r.height;r.fixed=c.value>o.top&&e.bottom>0,r.transform=t<0?t:0}else r.fixed=c.value>o.top;else{const{clientHeight:e}=document.documentElement;if(l){const t=S(l),a=e-t.top-c.value-r.height;r.fixed=e-c.value<o.bottom&&e>t.top,r.transform=a<0?-a:0}else r.fixed=e-c.value<o.bottom}t("scroll",{scrollTop:s,isFixed:r.fixed})};return y((()=>r.fixed),(e=>t("change",e))),C("scroll",v,{target:o,passive:!0}),ue(n,v),y([B,T],(()=>{n.value&&!I(n)&&r.fixed&&(s.value=!0,k((()=>{const e=S(n);r.width=e.width,r.height=e.height,s.value=!1})))})),()=>{var e;return z("div",{ref:n,style:u.value},[z("div",{"class":ve({fixed:r.fixed&&!s.value}),style:d.value},[null==(e=l["default"])?void 0:e.call(l)])])}}})),[pe,he]=u("swipe"),ge={loop:M,width:d,height:d,vertical:Boolean,autoplay:f(0),duration:f(500),touchable:M,lazyRender:Boolean,initialSwipe:f(0),indicatorColor:String,showIndicators:M,stopPropagation:M},be=Symbol(pe),me=R(p({name:pe,props:ge,emits:["change","dragStart","dragEnd"],setup(e,{emit:t,slots:a}){const l=i(),n=i(),o=g({rect:null,width:0,height:0,offset:0,active:0,swiping:!1});let c=!1;const u=A(),{children:d,linkChildren:v}=H(be),f=b((()=>d.length)),p=b((()=>o[e.vertical?"height":"width"])),h=b((()=>e.vertical?u.deltaY.value:u.deltaX.value)),m=b((()=>o.rect?(e.vertical?o.rect.height:o.rect.width)-p.value*f.value:0)),w=b((()=>p.value?Math.ceil(Math.abs(m.value)/p.value):f.value)),x=b((()=>f.value*p.value)),S=b((()=>(o.active+f.value)%f.value)),R=b((()=>{const t=e.vertical?"vertical":"horizontal";return u.direction.value===t})),M=b((()=>{const t={transitionDuration:"".concat(o.swiping?0:e.duration,"ms"),transform:"translate".concat(e.vertical?"Y":"X","(").concat(+o.offset.toFixed(2),"px)")};if(p.value){const a=e.vertical?"height":"width",l=e.vertical?"width":"height";t[a]="".concat(x.value,"px"),t[l]=e[l]?"".concat(e[l],"px"):""}return t})),Y=(t,a=0)=>{let l=t*p.value;e.loop||(l=Math.min(l,-m.value));let i=a-l;return e.loop||(i=N(i,m.value,0)),i},Z=({pace:a=0,offset:l=0,emitChange:i})=>{if(f.value<=1)return;const{active:n}=o,r=(t=>{const{active:a}=o;return t?e.loop?N(a+t,-1,f.value):N(a+t,0,w.value):a})(a),s=Y(r,l);if(e.loop){if(d[0]&&s!==m.value){const e=s<m.value;d[0].setOffset(e?x.value:0)}if(d[f.value-1]&&0!==s){const e=s>0;d[f.value-1].setOffset(e?-x.value:0)}}o.active=r,o.offset=s,i&&r!==n&&t("change",S.value)},$=()=>{o.swiping=!0,o.active<=-1?Z({pace:f.value}):o.active>=f.value&&Z({pace:-f.value})},j=()=>{$(),u.reset(),X((()=>{o.swiping=!1,Z({pace:1,emitChange:!0})}))};let P;const V=()=>clearTimeout(P),G=()=>{V(),+e.autoplay>0&&f.value>1&&(P=setTimeout((()=>{j(),G()}),+e.autoplay))},J=(t=+e.initialSwipe)=>{if(!l.value)return;const a=()=>{var a,i;if(!I(l)){const t={width:l.value.offsetWidth,height:l.value.offsetHeight};o.rect=t,o.width=+(null!=(a=e.width)?a:t.width),o.height=+(null!=(i=e.height)?i:t.height)}f.value&&-1===(t=Math.min(f.value-1,t))&&(t=f.value-1),o.active=t,o.swiping=!0,o.offset=Y(t),d.forEach((e=>{e.setOffset(0)})),G()};I(l)?k().then(a):a()},q=()=>J(o.active);let K;const Q=t=>{!e.touchable||t.touches.length>1||(u.start(t),c=!1,K=Date.now(),V(),$())},U=()=>{if(!e.touchable||!o.swiping)return;const a=Date.now()-K,l=h.value/a;if((Math.abs(l)>.25||Math.abs(h.value)>p.value/2)&&R.value){const t=e.vertical?u.offsetY.value:u.offsetX.value;let a=0;a=e.loop?t>0?h.value>0?-1:1:0:-Math[h.value>0?"ceil":"floor"](h.value/p.value),Z({pace:a,emitChange:!0})}else h.value&&Z({pace:0});c=!1,o.swiping=!1,t("dragEnd",{index:S.value}),G()},_=(t,a)=>{const l=a===S.value,i=l?{backgroundColor:e.indicatorColor}:void 0;return z("i",{style:i,"class":he("indicator",{active:l})},null)};return O({prev:()=>{$(),u.reset(),X((()=>{o.swiping=!1,Z({pace:-1,emitChange:!0})}))},next:j,state:o,resize:q,swipeTo:(t,a={})=>{$(),u.reset(),X((()=>{let l;l=e.loop&&t===f.value?0===o.active?0:t:t%f.value,a.immediate?X((()=>{o.swiping=!1})):o.swiping=!1,Z({pace:l-o.active,emitChange:!0})}))}}),v({size:p,props:e,count:f,activeIndicator:S}),y((()=>e.initialSwipe),(e=>J(+e))),y(f,(()=>J(o.active))),y((()=>e.autoplay),G),y([B,T,()=>e.width,()=>e.height],q),y(L(),(e=>{"visible"===e?G():V()})),W(J),D((()=>J(o.active))),E((()=>J(o.active))),r(V),s(V),C("touchmove",(a=>{e.touchable&&o.swiping&&(u.move(a),R.value)&&(!e.loop&&(0===o.active&&h.value>0||o.active===f.value-1&&h.value<0)||(F(a,e.stopPropagation),Z({offset:h.value}),c||(t("dragStart",{index:S.value}),c=!0)))}),{target:n}),()=>{var t;return z("div",{ref:l,"class":he()},[z("div",{ref:n,style:M.value,"class":he("track",{vertical:e.vertical}),onTouchstartPassive:Q,onTouchend:U,onTouchcancel:U},[null==(t=a["default"])?void 0:t.call(a)]),a.indicator?a.indicator({active:S.value,total:f.value}):e.showIndicators&&f.value>1?z("div",{"class":he("indicators",{vertical:e.vertical})},[Array(f.value).fill("").map(_)]):void 0])}}})),[we,xe]=u("tabs");var ye=p({name:we,props:{count:Y(Number),inited:Boolean,animated:Boolean,duration:Y(d),swipeable:Boolean,lazyRender:Boolean,currentIndex:Y(Number)},emits:["change"],setup(e,{emit:t,slots:a}){const l=i(),n=e=>t("change",e),o=()=>{var t;const i=null==(t=a["default"])?void 0:t.call(a);return e.animated||e.swipeable?z(me,{ref:l,loop:!1,"class":xe("track"),duration:1e3*+e.duration,touchable:e.swipeable,lazyRender:e.lazyRender,showIndicators:!1,onChange:n},{"default":()=>[i]}):i},r=t=>{const a=l.value;a&&a.state.active!==t&&a.swipeTo(t,{immediate:!e.inited})};return y((()=>e.currentIndex),r),W((()=>{r(e.currentIndex)})),O({swipeRef:l}),()=>z("div",{"class":xe("content",{animated:e.animated||e.swipeable})},[o()])}});const[Ce,Ie]=u("tabs"),ke={type:v("line"),color:String,border:Boolean,sticky:Boolean,shrink:Boolean,active:f(0),duration:f(.3),animated:Boolean,ellipsis:M,swipeable:Boolean,scrollspy:Boolean,offsetTop:f(0),background:String,lazyRender:M,showHeader:M,lineWidth:d,lineHeight:d,beforeChange:Function,swipeThreshold:f(5),titleActiveColor:String,titleInactiveColor:String},Se=Symbol(Ce);var Be=p({name:Ce,props:ke,emits:["change","scroll","rendered","clickTab","update:active"],setup(o,{emit:r,slots:s}){let u,d,v,f,p;const w=i(),x=i(),T=i(),R=i(),M=Z(),A=h(w),[L,W]=function(){const e=i([]),t=[];return n((()=>{e.value=[]})),[e,a=>(t[a]||(t[a]=t=>{e.value[a]=t}),t[a])]}(),{children:X,linkChildren:F}=H(Se),N=g({inited:!1,position:"",lineStyle:{},currentIndex:-1}),Y=b((()=>X.length>+o.swipeThreshold||!o.ellipsis||o.shrink)),K=b((()=>({borderColor:o.color,background:o.background}))),Q=(e,t)=>{var a;return null!=(a=e.name)?a:t},U=b((()=>{const e=X[N.currentIndex];if(e)return Q(e,N.currentIndex)})),_=b((()=>m(o.offsetTop))),ee=b((()=>o.sticky?_.value+u:0)),te=a=>{const l=x.value,i=L.value;if(!(Y.value&&l&&i&&i[N.currentIndex]))return;const n=i[N.currentIndex].$el,r=n.offsetLeft-(l.offsetWidth-n.offsetWidth)/2;f&&f(),f=function(a,l,i){let n,o=0;const r=a.scrollLeft,s=0===i?1:Math.round(1e3*i/16);return function c(){a.scrollLeft+=(l-r)/s,++o<s&&(n=t(c))}(),function(){e(n)}}(l,r,a?0:+o.duration)},ae=()=>{const e=N.inited;k((()=>{const t=L.value;if(!t||!t[N.currentIndex]||"line"!==o.type||I(w.value))return;const a=t[N.currentIndex].$el,{lineWidth:l,lineHeight:i}=o,n=a.offsetLeft+a.offsetWidth/2,r={width:$(l),backgroundColor:o.color,transform:"translateX(".concat(n,"px) translateX(-50%)")};if(e&&(r.transitionDuration="".concat(o.duration,"s")),j(i)){const e=$(i);r.height=e,r.borderRadius=e}N.lineStyle=r}))},le=(e,t)=>{const a=(e=>{const t=e<N.currentIndex?-1:1;for(;e>=0&&e<X.length;){if(!X[e].disabled)return e;e+=t}})(e);if(!j(a))return;const l=X[a],i=Q(l,a),n=null!==N.currentIndex;N.currentIndex!==a&&(N.currentIndex=a,t||te(),ae()),i!==o.active&&(r("update:active",i),n&&r("change",i,l.title)),v&&!o.scrollspy&&V(Math.ceil(G(w.value)-_.value))},ie=(e,t)=>{const a=X.find(((t,a)=>Q(t,a)===e)),l=a?X.indexOf(a):0;le(l,t)},ne=(i=!1)=>{if(o.scrollspy){const n=X[N.currentIndex].$el;if(n&&A.value){const r=G(n,A.value)-ee.value;d=!0,p&&p(),p=function(i,n,o,r){let s,c=a(i);const u=c<n,d=0===o?1:Math.round(1e3*o/16),v=(n-c)/d;return function f(){c+=v,(u&&c>n||!u&&c<n)&&(c=n),l(i,c),u&&c<n||!u&&c>n?s=t(f):r&&(s=t(r))}(),function(){e(s)}}(A.value,r,i?0:+o.duration,(()=>{d=!1}))}}},oe=(e,t,a)=>{const{title:l,disabled:i}=X[t],n=Q(X[t],t);i||(J(o.beforeChange,{args:[n],done:()=>{le(t),ne()}}),q(e)),r("clickTab",{name:n,title:l,event:a,disabled:i})},re=e=>{v=e.isFixed,r("scroll",e)},se=()=>{if("line"===o.type&&X.length)return z("div",{"class":Ie("line"),style:N.lineStyle},null)},ce=()=>{var e,t,a;const{type:l,border:i,sticky:n}=o,r=[z("div",{ref:n?void 0:T,"class":[Ie("wrap"),{[P]:"line"===l&&i}]},[z("div",{ref:x,role:"tablist","class":Ie("nav",[l,{shrink:o.shrink,complete:Y.value}]),style:K.value,"aria-orientation":"horizontal"},[null==(e=s["nav-left"])?void 0:e.call(s),X.map((e=>e.renderTitle(oe))),se(),null==(t=s["nav-right"])?void 0:t.call(s)])]),null==(a=s["nav-bottom"])?void 0:a.call(s)];return n?z("div",{ref:T},[r]):r},de=()=>{ae(),k((()=>{var e,t;te(!0),null==(t=null==(e=R.value)?void 0:e.swipeRef.value)||t.resize()}))};return y((()=>[o.color,o.duration,o.lineWidth,o.lineHeight]),ae),y(B,de),y((()=>o.active),(e=>{e!==U.value&&ie(e)})),y((()=>X.length),(()=>{N.inited&&(ie(o.active),ae(),k((()=>{te(!0)})))})),O({resize:de,scrollTo:e=>{k((()=>{ie(e),ne(!0)}))}}),D(ae),E(ae),c((()=>{ie(o.active,!0),k((()=>{N.inited=!0,T.value&&(u=S(T.value).height),te(!0)}))})),ue(w,ae),C("scroll",(()=>{if(o.scrollspy&&!d){const e=(()=>{for(let e=0;e<X.length;e++){const{top:t}=S(X[e].$el);if(t>ee.value)return 0===e?0:e-1}return X.length-1})();le(e)}}),{target:A,passive:!0}),F({id:M,props:o,setLine:ae,scrollable:Y,onRendered:(e,t)=>r("rendered",e,t),currentName:U,setTitleRefs:W,scrollIntoView:te}),()=>z("div",{ref:w,"class":Ie([o.type])},[o.showHeader?o.sticky?z(fe,{container:w.value,offsetTop:_.value,onScroll:re},{"default":()=>[ce()]}):ce():null,z(ye,{ref:R,count:X.length,inited:N.inited,animated:o.animated,duration:o.duration,swipeable:o.swipeable,lazyRender:o.lazyRender,currentIndex:N.currentIndex,onChange:le},{"default":()=>{var e;return[null==(e=s["default"])?void 0:e.call(s)]}})])}});const Te=Symbol(),[ze,Re]=u("tab"),Me=p({name:ze,props:{id:String,dot:Boolean,type:String,color:String,title:String,badge:d,shrink:Boolean,isActive:Boolean,disabled:Boolean,controls:String,scrollable:Boolean,activeColor:String,inactiveColor:String,showZeroBadge:M},setup(e,{slots:t}){const a=b((()=>{const t={},{type:a,color:l,disabled:i,isActive:n,activeColor:o,inactiveColor:r}=e;l&&"card"===a&&(t.borderColor=l,i||(n?t.backgroundColor=l:t.color=l));const s=n?o:r;return s&&(t.color=s),t})),l=()=>{const a=z("span",{"class":Re("text",{ellipsis:!e.scrollable})},[t.title?t.title():e.title]);return e.dot||j(e.badge)&&""!==e.badge?z(K,{dot:e.dot,content:e.badge,showZero:e.showZeroBadge},{"default":()=>[a]}):a};return()=>z("div",{id:e.id,role:"tab","class":[Re([e.type,{grow:e.scrollable&&!e.shrink,shrink:e.shrink,active:e.isActive,disabled:e.disabled}])],style:a.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()])}}),[Ae,He]=u("swipe-item"),Oe=R(p({name:Ae,setup(e,{slots:t}){let a;const l=g({offset:0,inited:!1,mounted:!1}),{parent:i,index:n}=Q(be);if(!i)return;const o=b((()=>{const e={},{vertical:t}=i.props;return i.size.value&&(e[t?"height":"width"]="".concat(i.size.value,"px")),l.offset&&(e.transform="translate".concat(t?"Y":"X","(").concat(l.offset,"px)")),e})),r=b((()=>{const{loop:e,lazyRender:t}=i.props;if(!t||a)return!0;if(!l.mounted)return!1;const o=i.activeIndicator.value,r=i.count.value-1,s=0===o&&e?r:o-1,c=o===r&&e?0:o+1;return a=n.value===o||n.value===s||n.value===c,a}));return W((()=>{k((()=>{l.mounted=!0}))})),O({setOffset:e=>{l.offset=e}}),()=>{var e;return z("div",{"class":He(),style:o.value},[r.value?null==(e=t["default"])?void 0:e.call(t):null])}}})),[Le,We]=u("tab"),De=R(p({name:Le,props:w({},U,{dot:Boolean,name:d,badge:d,title:String,disabled:Boolean,titleClass:_,titleStyle:[String,Object],showZeroBadge:M}),setup(e,{slots:t}){const a=Z(),l=i(!1),n=se(),{parent:o,index:r}=Q(Se);if(!o)return;const s=()=>{var t;return null!=(t=e.name)?t:r.value},c=b((()=>{const t=s()===o.currentName.value;return t&&!l.value&&(l.value=!0,o.props.lazyRender&&k((()=>{o.onRendered(s(),e.title)}))),t})),u=i(""),d=i("");ee((()=>{const{titleClass:t,titleStyle:a}=e;u.value=t?le(t):"",d.value=a&&"string"!=typeof a?ie(ne(a)):a}));const v=i(!c.value);return y(c,(e=>{e?v.value=!1:X((()=>{v.value=!0}))})),y((()=>e.title),(()=>{o.setLine(),o.scrollIntoView()})),te(Te,c),O({id:a,renderTitle:l=>z(Me,oe({key:a,id:"".concat(o.id,"-").concat(r.value),ref:o.setTitleRefs(r.value),style:d.value,"class":u.value,isActive:c.value,controls:a,scrollable:o.scrollable.value,activeColor:o.props.titleActiveColor,inactiveColor:o.props.titleInactiveColor,onClick:e=>l(n.proxy,r.value,e)},re(o.props,["type","color","shrink"]),re(e,["dot","badge","title","disabled","showZeroBadge"])),{title:t.title})}),()=>{var e;const i="".concat(o.id,"-").concat(r.value),{animated:n,swipeable:s,scrollspy:u,lazyRender:d}=o.props;if(!t["default"]&&!n)return;const f=u||c.value;if(n||s)return z(Oe,{id:a,role:"tabpanel","class":We("panel-wrapper",{inactive:v.value}),tabindex:c.value?0:-1,"aria-hidden":!c.value,"aria-labelledby":i},{"default":()=>{var e;return[z("div",{"class":We("panel")},[null==(e=t["default"])?void 0:e.call(t)])]}});const p=l.value||u||!d?null==(e=t["default"])?void 0:e.call(t):null;return ae(z("div",{id:a,role:"tabpanel","class":We("panel"),tabindex:f?0:-1,"aria-labelledby":i},[p]),[[ce,f]])}}})),Ee=R(Be);export{Ee as T,De as a};