1 |
- import{X as e,Y as t,Z as a,_ as n,H as l,$ as o,a0 as i,a1 as r,a2 as s,a3 as c,x as d,z as u,C as v,D as f,d as p,a4 as h,r as b,c as g,a5 as m,a6 as x,a7 as y,j as w,W as k,a8 as I,K as B,a9 as C,aa as S,ab as T,a as R,w as z,ac as A,o as j,ad as H,E as W,ae as L,af as Z,ag as O,ah as $,y as N,ai as F,aj as M,ak as X,al as D,am as E,an as V,ao as q,ap as G,aq as K,ar as Y,as as _,at as J,au as P,av as Q,aw as U,ax as ee,ay as te,G as ae,az as ne,aA as le,aB as oe}from"./index-d31722d5.js";import{T as ie}from"./use-tab-status-fc601ac5.js";import{S as re,a as se}from"./index-fd20d453.js";function ce(e,t){if(!i||!window.IntersectionObserver)return;const a=new IntersectionObserver((e=>{t(e[0].intersectionRatio>0)}),{root:document.body}),n=()=>{e.value&&a.unobserve(e.value)};r(n),s(n),c((()=>{e.value&&a.observe(e.value)}))}const[de,ue]=d("sticky"),ve=z(p({name:de,props:{zIndex:u,position:v("top"),container:Object,offsetTop:f(0),offsetBottom:f(0)},emits:["scroll","change"],setup(e,{emit:t,slots:n}){const o=l(),i=h(o),r=b({fixed:!1,width:0,height:0,transform:0}),s=l(!1),c=g((()=>m("top"===e.position?e.offsetTop:e.offsetBottom))),d=g((()=>{if(s.value)return;const{fixed:e,height:t,width:a}=r;return e?{width:"".concat(a,"px"),height:"".concat(t,"px")}:void 0})),u=g((()=>{if(!r.fixed||s.value)return;const t=x(y(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(!o.value||I(o))return;const{container:n,position:l}=e,i=C(o),s=a(window);if(r.width=i.width,r.height=i.height,"top"===l)if(n){const e=C(n),t=e.bottom-c.value-r.height;r.fixed=c.value>i.top&&e.bottom>0,r.transform=t<0?t:0}else r.fixed=c.value>i.top;else{const{clientHeight:e}=document.documentElement;if(n){const t=C(n),a=e-t.top-c.value-r.height;r.fixed=e-c.value<i.bottom&&e>t.top,r.transform=a<0?-a:0}else r.fixed=e-c.value<i.bottom}t("scroll",{scrollTop:s,isFixed:r.fixed})};return w((()=>r.fixed),(e=>t("change",e))),k("scroll",v,{target:i,passive:!0}),ce(o,v),w([S,T],(()=>{o.value&&!I(o)&&r.fixed&&(s.value=!0,B((()=>{const e=C(o);r.width=e.width,r.height=e.height,s.value=!1})))})),()=>{var e;return R("div",{ref:o,style:d.value},[R("div",{"class":ue({fixed:r.fixed&&!s.value}),style:u.value},[null==(e=n["default"])?void 0:e.call(n)])])}}})),[fe,pe]=d("tabs");var he=p({name:fe,props:{count:A(Number),inited:Boolean,animated:Boolean,duration:A(u),swipeable:Boolean,lazyRender:Boolean,currentIndex:A(Number)},emits:["change"],setup(e,{emit:t,slots:a}){const n=l(),o=e=>t("change",e),i=()=>{var t;const l=null==(t=a["default"])?void 0:t.call(a);return e.animated||e.swipeable?R(re,{ref:n,loop:!1,"class":pe("track"),duration:1e3*+e.duration,touchable:e.swipeable,lazyRender:e.lazyRender,showIndicators:!1,onChange:o},{"default":()=>[l]}):l},r=t=>{const a=n.value;a&&a.state.active!==t&&a.swipeTo(t,{immediate:!e.inited})};return w((()=>e.currentIndex),r),j((()=>{r(e.currentIndex)})),H({swipeRef:n}),()=>R("div",{"class":pe("content",{animated:e.animated||e.swipeable})},[i()])}});const[be,ge]=d("tabs"),me={type:v("line"),color:String,border:Boolean,sticky:Boolean,shrink:Boolean,active:f(0),duration:f(.3),animated:Boolean,ellipsis:W,swipeable:Boolean,scrollspy:Boolean,offsetTop:f(0),background:String,lazyRender:W,showHeader:W,lineWidth:u,lineHeight:u,beforeChange:Function,swipeThreshold:f(5),titleActiveColor:String,titleInactiveColor:String},xe=Symbol(be);var ye=p({name:be,props:me,emits:["change","scroll","rendered","clickTab","update:active"],setup(i,{emit:r,slots:s}){let d,u,v,f,p;const x=l(),y=l(),T=l(),z=l(),A=L(),j=h(x),[W,q]=function(){const e=l([]),t=[];return o((()=>{e.value=[]})),[e,a=>(t[a]||(t[a]=t=>{e.value[a]=t}),t[a])]}(),{children:G,linkChildren:K}=Z(xe),Y=b({inited:!1,position:"",lineStyle:{},currentIndex:-1}),_=g((()=>G.length>+i.swipeThreshold||!i.ellipsis||i.shrink)),J=g((()=>({borderColor:i.color,background:i.background}))),P=(e,t)=>{var a;return null!=(a=e.name)?a:t},Q=g((()=>{const e=G[Y.currentIndex];if(e)return P(e,Y.currentIndex)})),U=g((()=>m(i.offsetTop))),ee=g((()=>i.sticky?U.value+d:0)),te=a=>{const n=y.value,l=W.value;if(!(_.value&&n&&l&&l[Y.currentIndex]))return;const o=l[Y.currentIndex].$el,r=o.offsetLeft-(n.offsetWidth-o.offsetWidth)/2;f&&f(),f=function(a,n,l){let o,i=0;const r=a.scrollLeft,s=0===l?1:Math.round(1e3*l/16);return function c(){a.scrollLeft+=(n-r)/s,++i<s&&(o=t(c))}(),function(){e(o)}}(n,r,a?0:+i.duration)},ae=()=>{const e=Y.inited;B((()=>{const t=W.value;if(!t||!t[Y.currentIndex]||"line"!==i.type||I(x.value))return;const a=t[Y.currentIndex].$el,{lineWidth:n,lineHeight:l}=i,o=a.offsetLeft+a.offsetWidth/2,r={width:N(n),backgroundColor:i.color,transform:"translateX(".concat(o,"px) translateX(-50%)")};if(e&&(r.transitionDuration="".concat(i.duration,"s")),F(l)){const e=N(l);r.height=e,r.borderRadius=e}Y.lineStyle=r}))},ne=(e,t)=>{const a=(e=>{const t=e<Y.currentIndex?-1:1;for(;e>=0&&e<G.length;){if(!G[e].disabled)return e;e+=t}})(e);if(!F(a))return;const n=G[a],l=P(n,a),o=null!==Y.currentIndex;Y.currentIndex!==a&&(Y.currentIndex=a,t||te(),ae()),l!==i.active&&(r("update:active",l),o&&r("change",l,n.title)),v&&!i.scrollspy&&X(Math.ceil(D(x.value)-U.value))},le=(e,t)=>{const a=G.find(((t,a)=>P(t,a)===e)),n=a?G.indexOf(a):0;ne(n,t)},oe=(l=!1)=>{if(i.scrollspy){const o=G[Y.currentIndex].$el;if(o&&j.value){const r=D(o,j.value)-ee.value;u=!0,p&&p(),p=function(l,o,i,r){let s,c=a(l);const d=c<o,u=0===i?1:Math.round(1e3*i/16),v=(o-c)/u;return function f(){c+=v,(d&&c>o||!d&&c<o)&&(c=o),n(l,c),d&&c<o||!d&&c>o?s=t(f):r&&(s=t(r))}(),function(){e(s)}}(j.value,r,l?0:+i.duration,(()=>{u=!1}))}}},ie=(e,t,a)=>{const{title:n,disabled:l}=G[t],o=P(G[t],t);l||(E(i.beforeChange,{args:[o],done:()=>{ne(t),oe()}}),V(e)),r("clickTab",{name:o,title:n,event:a,disabled:l})},re=e=>{v=e.isFixed,r("scroll",e)},se=()=>{if("line"===i.type&&G.length)return R("div",{"class":ge("line"),style:Y.lineStyle},null)},de=()=>{var e,t,a;const{type:n,border:l,sticky:o}=i,r=[R("div",{ref:o?void 0:T,"class":[ge("wrap"),{[M]:"line"===n&&l}]},[R("div",{ref:y,role:"tablist","class":ge("nav",[n,{shrink:i.shrink,complete:_.value}]),style:J.value,"aria-orientation":"horizontal"},[null==(e=s["nav-left"])?void 0:e.call(s),G.map((e=>e.renderTitle(ie))),se(),null==(t=s["nav-right"])?void 0:t.call(s)])]),null==(a=s["nav-bottom"])?void 0:a.call(s)];return o?R("div",{ref:T},[r]):r},ue=()=>{ae(),B((()=>{var e,t;te(!0),null==(t=null==(e=z.value)?void 0:e.swipeRef.value)||t.resize()}))};return w((()=>[i.color,i.duration,i.lineWidth,i.lineHeight]),ae),w(S,ue),w((()=>i.active),(e=>{e!==Q.value&&le(e)})),w((()=>G.length),(()=>{Y.inited&&(le(i.active),ae(),B((()=>{te(!0)})))})),H({resize:ue,scrollTo:e=>{B((()=>{le(e),oe(!0)}))}}),O(ae),$(ae),c((()=>{le(i.active,!0),B((()=>{Y.inited=!0,T.value&&(d=C(T.value).height),te(!0)}))})),ce(x,ae),k("scroll",(()=>{if(i.scrollspy&&!u){const e=(()=>{for(let e=0;e<G.length;e++){const{top:t}=C(G[e].$el);if(t>ee.value)return 0===e?0:e-1}return G.length-1})();ne(e)}}),{target:j,passive:!0}),K({id:A,props:i,setLine:ae,scrollable:_,onRendered:(e,t)=>r("rendered",e,t),currentName:Q,setTitleRefs:q,scrollIntoView:te}),()=>R("div",{ref:x,"class":ge([i.type])},[i.showHeader?i.sticky?R(ve,{container:x.value,offsetTop:U.value,onScroll:re},{"default":()=>[de()]}):de():null,R(he,{ref:z,count:G.length,inited:Y.inited,animated:i.animated,duration:i.duration,swipeable:i.swipeable,lazyRender:i.lazyRender,currentIndex:Y.currentIndex,onChange:ne},{"default":()=>{var e;return[null==(e=s["default"])?void 0:e.call(s)]}})])}});const[we,ke]=d("tab"),Ie=p({name:we,props:{id:String,dot:Boolean,type:String,color:String,title:String,badge:u,shrink:Boolean,isActive:Boolean,disabled:Boolean,controls:String,scrollable:Boolean,activeColor:String,inactiveColor:String,showZeroBadge:W},setup(e,{slots:t}){const a=g((()=>{const t={},{type:a,color:n,disabled:l,isActive:o,activeColor:i,inactiveColor:r}=e;n&&"card"===a&&(t.borderColor=n,l||(o?t.backgroundColor=n:t.color=n));const s=o?i:r;return s&&(t.color=s),t})),n=()=>{const a=R("span",{"class":ke("text",{ellipsis:!e.scrollable})},[t.title?t.title():e.title]);return e.dot||F(e.badge)&&""!==e.badge?R(q,{dot:e.dot,content:e.badge,showZero:e.showZeroBadge},{"default":()=>[a]}):a};return()=>R("div",{id:e.id,role:"tab","class":[ke([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},[n()])}}),[Be,Ce]=d("tab"),Se=z(p({name:Be,props:x({},G,{dot:Boolean,name:u,badge:u,title:String,disabled:Boolean,titleClass:K,titleStyle:[String,Object],showZeroBadge:W}),setup(e,{slots:t}){const a=L(),n=l(!1),o=le(),{parent:i,index:r}=Y(xe);if(!i)return;const s=()=>{var t;return null!=(t=e.name)?t:r.value},c=g((()=>{const t=s()===i.currentName.value;return t&&!n.value&&(n.value=!0,i.props.lazyRender&&B((()=>{i.onRendered(s(),e.title)}))),t})),d=l(""),u=l("");_((()=>{const{titleClass:t,titleStyle:a}=e;d.value=t?U(t):"",u.value=a&&"string"!=typeof a?ee(te(a)):a}));const v=l(!c.value);return w(c,(e=>{e?v.value=!1:J((()=>{v.value=!0}))})),w((()=>e.title),(()=>{i.setLine(),i.scrollIntoView()})),P(ie,c),H({id:a,renderTitle:n=>R(Ie,ae({key:a,id:"".concat(i.id,"-").concat(r.value),ref:i.setTitleRefs(r.value),style:u.value,"class":d.value,isActive:c.value,controls:a,scrollable:i.scrollable.value,activeColor:i.props.titleActiveColor,inactiveColor:i.props.titleInactiveColor,onClick:e=>n(o.proxy,r.value,e)},ne(i.props,["type","color","shrink"]),ne(e,["dot","badge","title","disabled","showZeroBadge"])),{title:t.title})}),()=>{var e;const l="".concat(i.id,"-").concat(r.value),{animated:o,swipeable:s,scrollspy:d,lazyRender:u}=i.props;if(!t["default"]&&!o)return;const f=d||c.value;if(o||s)return R(se,{id:a,role:"tabpanel","class":Ce("panel-wrapper",{inactive:v.value}),tabindex:c.value?0:-1,"aria-hidden":!c.value,"aria-labelledby":l},{"default":()=>{var e;return[R("div",{"class":Ce("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 Q(R("div",{id:a,role:"tabpanel","class":Ce("panel"),tabindex:f?0:-1,"aria-labelledby":l},[p]),[[oe,f]])}}})),Te=z(ye);export{Te as T,Se as a};
|