2 lines
8.9 KiB
JavaScript
2 lines
8.9 KiB
JavaScript
|
import{W as e,aX as a,bR as t,b as l,A as s,h as o,_ as n,d as r,j as i,I as u,a as d,r as c,D as v,aW as b,aw as p,c as f,e as m,$ as h,n as y,g,k as $,bS as P,af as x,bT as C,bU as w,F as k,o as T,bV as R,N,E as S,bW as B,L as E,Y as A,ai as F,y as L,x as _,f as W,bX as K,aS as V,U as q,p as X,aq as Y,bY as j,ad as z,bZ as M,R as U,ag as D,S as H,v as I,s as O}from"./index.BE3jgw84.js";const Z=(l,s)=>{const o={},n=e([]);return{children:n,addChild:e=>{o[e.uid]=e,n.value=((e,l,s)=>a(e.subTree).filter((e=>{var a;return t(e)&&(null==(a=e.type)?void 0:a.name)===l&&!!e.component})).map((e=>e.component.uid)).map((e=>s[e])).filter((e=>!!e)))(l,s,o)},removeChild:e=>{delete o[e],n.value=n.value.filter((a=>a.uid!==e))}}},G=Symbol("tabsRootContextKey"),J=l({tabs:{type:o(Array),default:()=>s([])}}),Q="ElTabBar",ee=r({name:Q});var ae=n(r({...ee,props:J,setup(e,{expose:a}){const t=e,l=$(),s=i(G);s||u(Q,"<el-tabs><el-tab-bar /></el-tabs>");const o=d("tabs"),n=c(),r=c(),C=()=>r.value=(()=>{let e=0,a=0;const o=["top","bottom"].includes(s.props.tabPosition)?"width":"height",n="width"===o?"x":"y",r="x"===n?"left":"top";return t.tabs.every((t=>{var s,n;const i=null==(n=null==(s=l.parent)?void 0:s.refs)?void 0:n[`tab-${t.uid}`];if(!i)return!1;if(!t.active)return!0;e=i[`offset${P(r)}`],a=i[`client${P(o)}`];const u=window.getComputedStyle(i);return"width"===o&&(a-=Number.parseFloat(u.paddingLeft)+Number.parseFloat(u.paddingRight),e+=Number.parseFloat(u.paddingLeft)),!1})),{[o]:`${a}px`,transform:`translate${P(n)}(${e}px)`}})(),w=[];v((()=>t.tabs),(async()=>{await x(),C(),(()=>{var e;w.forEach((e=>e.stop())),w.length=0;const a=null==(e=l.parent)?void 0:e.refs;if(a)for(const t in a)if(t.startsWith("tab-")){const e=a[t];e&&w.push(b(e,C))}})()}),{immediate:!0});const k=b(n,(()=>C()));return p((()=>{w.forEach((e=>e.stop())),w.length=0,k.stop()})),a({ref:n,update:C}),(e,a)=>(m(),f("div",{ref_key:"barRef",ref:n,class:y([g(o).e("active-bar"),g(o).is(g(s).props.tabPosition)]),style:h(r.value)},null,6))}}),[["__file","tab-bar.vue"]]);const te=l({panes:{type:o(Array),default:()=>s([])},currentName:{type:[String,Number],default:""},editable:Boolean,type:{type:String,values:["card","border-card",""],default:""},stretch:Boolean}),le="ElTabNav",se=r({name:le,props:te,emits:{tabClick:(e,a,t)=>t instanceof Event,tabRemove:(e,a)=>a instanceof Event},setup(e,{expose:a,emit:t}){const l=i(G);l||u(le,"<el-tabs><tab-nav /></el-tabs>");const s=d("tabs"),o=C(),n=w(),r=c(),p=c(),f=c(),m=c(),h=c(!1),y=c(0),g=c(!1),$=c(!0),L=k((()=>["top","bottom"].includes(l.props.tabPosition)?"width":"height")),_=k((()=>({transform:`translate${"width"===L.value?"X":"Y"}(-${y.value}px)`}))),W=()=>{if(!r.value)return;const e=r.value[`offset${P(L.value)}`],a=y.value;if(!a)return;const t=a>e?a-e:0;y.value=t},K=()=>{if(!r.value||!p.value)return;const e=p.value[`offset${P(L.value)}`],a=r.value[`offset${P(L.value)}`],t=y.value;if(e-t<=a)return;const l=e-t>2*a?t+a:e-a;y.value=l},V=async()=>{const e=p.value;if(!(h.value&&f.value&&r.value&&e))return;await x();const a=f.value.querySelector(".is-active");if(!a)return;const t=r.value,s=["top","bottom"].includes(l.props.tabPosition),o=a.getBoundingClientRect(),n=t.getBoundingClientRect(),i=s?e.offsetWidth-n.width:e.offsetHeight-n.height,u=y.value;let d=u;s?(o.left<n.left&&(d=u-(n.left-o.left)),o.right>n.right&&(d=u+o.right-n.right)):(o.top<n.top&&(d=u-(n.top-o.top)),o.bottom>n.bottom&&(d=u+(o.bottom-n.bottom))),d=Math.max(d,0),y.value=Math.min(d,i)},q=()=>{var a;if(!p.value||!r.value)return;e.stretch&&(null==(a=m.value)||a.update());const t=p.value[`offset${P(L.value)}`],l=r.value[`offset${P(L.value)}`],s=y.value;l<t?(h.value=h.value||{},h.value.prev=s,h.value.next=s+l<t,t-s<l&&(y.value=t-l)):(h.value=!1,s>0&&(y.value=0))},X=e=>{let a=0;switch(e.code){case A.left:case A.up:a=-1;break;case A.right:case A.down:a=1;break;default:return}const t=Array.from(e.currentTarget.querySelectorAll("[role=tab]:not(.is-disabled)"));let l=t.indexOf(e.target)+a;l<0?l=t.length-1:l>=t.length&&(l=0),t[l].focus({preventScroll:!0}),t[l].click(),Y()},Y=()=>{$.value&&(g.v
|