Files
cloud-mail/mail-worker/dist/assets/el-scrollbar-CKPMF6AL.js
T
2025-08-28 22:28:00 +08:00

2 lines
6.8 KiB
JavaScript

import{b as D,_ as j,a as x,y as G,u as J,z as u,k as L,J as ee,a5 as O,a1 as X,m as W,o as P,p as Q,N as te,f as A,a7 as le,n as R,g,i as $,O as ae,T as oe,a8 as se,c as Z,ab as V,P as re,aQ as N,d as ne,aV as Y,F as I,W as ie,$ as q,G as ce,D as ue,bN as ve,I as fe,aX as de,e as me,r as pe,a6 as he,U as be,w as ye}from"./index-BtzXKQwE.js";import{t as ge,u as Se}from"./index-DeJUs09x.js";const k=4,we={vertical:{offset:"offsetHeight",scroll:"scrollTop",scrollSize:"scrollHeight",size:"height",key:"vertical",axis:"Y",client:"clientY",direction:"top"},horizontal:{offset:"offsetWidth",scroll:"scrollLeft",scrollSize:"scrollWidth",size:"width",key:"horizontal",axis:"X",client:"clientX",direction:"left"}},ze=({move:m,size:v,bar:s})=>({[s.size]:v,transform:`translate${s.axis}(${m}%)`}),K=Symbol("scrollbarContextKey"),_e=D({vertical:Boolean,size:String,move:Number,ratio:{type:Number,required:!0},always:Boolean}),Ee="Thumb",He=x({__name:"thumb",props:_e,setup(m){const v=m,s=G(K),a=J("scrollbar");s||ge(Ee,"can not inject scrollbar context");const c=u(),f=u(),p=u({}),i=u(!1);let n=!1,d=!1,T=0,l=0,o=se?document.onselectstart:null;const t=L(()=>we[v.vertical?"vertical":"horizontal"]),h=L(()=>ze({size:v.size,move:v.move,bar:t.value})),w=L(()=>c.value[t.value.offset]**2/s.wrapElement[t.value.scrollSize]/v.ratio/f.value[t.value.offset]),E=r=>{var y;if(r.stopPropagation(),r.ctrlKey||[1,2].includes(r.button))return;(y=window.getSelection())==null||y.removeAllRanges(),z(r);const H=r.currentTarget;H&&(p.value[t.value.axis]=H[t.value.offset]-(r[t.value.client]-H.getBoundingClientRect()[t.value.direction]))},S=r=>{if(!f.value||!c.value||!s.wrapElement)return;const y=Math.abs(r.target.getBoundingClientRect()[t.value.direction]-r[t.value.client]),H=f.value[t.value.offset]/2,M=(y-H)*100*w.value/c.value[t.value.offset];s.wrapElement[t.value.scroll]=M*s.wrapElement[t.value.scrollSize]/100},z=r=>{r.stopImmediatePropagation(),n=!0,T=s.wrapElement.scrollHeight,l=s.wrapElement.scrollWidth,document.addEventListener("mousemove",B),document.addEventListener("mouseup",C),o=document.onselectstart,document.onselectstart=()=>!1},B=r=>{if(!c.value||!f.value||n===!1)return;const y=p.value[t.value.axis];if(!y)return;const H=(c.value.getBoundingClientRect()[t.value.direction]-r[t.value.client])*-1,M=f.value[t.value.offset]-y,U=(H-M)*100*w.value/c.value[t.value.offset];t.value.scroll==="scrollLeft"?s.wrapElement[t.value.scroll]=U*l/100:s.wrapElement[t.value.scroll]=U*T/100},C=()=>{n=!1,p.value[t.value.axis]=0,document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",C),b(),d&&(i.value=!1)},_=()=>{d=!1,i.value=!!v.size},e=()=>{d=!0,i.value=n};ee(()=>{b(),document.removeEventListener("mouseup",C)});const b=()=>{document.onselectstart!==o&&(document.onselectstart=o)};return O(X(s,"scrollbarElement"),"mousemove",_),O(X(s,"scrollbarElement"),"mouseleave",e),(r,y)=>(P(),W(oe,{name:g(a).b("fade"),persisted:""},{default:Q(()=>[te(A("div",{ref_key:"instance",ref:c,class:R([g(a).e("bar"),g(a).is(g(t).key)]),onMousedown:S,onClick:le(()=>{},["stop"])},[A("div",{ref_key:"thumb",ref:f,class:R(g(a).e("thumb")),style:$(g(h)),onMousedown:E},null,38)],42,["onClick"]),[[ae,r.always||i.value]])]),_:1},8,["name"]))}});var F=j(He,[["__file","thumb.vue"]]);const Te=D({always:{type:Boolean,default:!0},minSize:{type:Number,required:!0}}),ke=x({__name:"bar",props:Te,setup(m,{expose:v}){const s=m,a=G(K),c=u(0),f=u(0),p=u(""),i=u(""),n=u(1),d=u(1);return v({handleScroll:o=>{if(o){const t=o.offsetHeight-k,h=o.offsetWidth-k;f.value=o.scrollTop*100/t*n.value,c.value=o.scrollLeft*100/h*d.value}},update:()=>{const o=a?.wrapElement;if(!o)return;const t=o.offsetHeight-k,h=o.offsetWidth-k,w=t**2/o.scrollHeight,E=h**2/o.scrollWidth,S=Math.max(w,s.minSize),z=Math.max(E,s.minSize);n.value=w/(t-w)/(S/(t-S)),d.value=E/(h-E)/(z/(h-z)),i.value=S+k<t?`${S}px`:"",p.value=z+k<h?`${z}px`:""}}),(o,t)=>(P(),Z(re,null,[V(F,{move:c.value,ratio:d.value,size:p.value,always:o.always},null,8,["move","ratio","size","always"]),V(F,{move:f.value,ratio:n.value,size:i.value,vertical:"",always:o.always},null,8,["move","ratio","size","always"])],64))}});var Le=j(ke,[["__file","bar.vue"]]);const Ce=D({height:{type:[String,Number],default:""},maxHeight:{type:[String,Number],default:""},native:Boolean,wrapStyle:{type:ne([String,Object,Array]),default:""},wrapClass:{type:[String,Array],default:""},viewClass:{type:[String,Array],default:""},viewStyle:{type:[String,Array,Object],default:""},noresize:Boolean,tag:{type:String,default:"div"},always:Boolean,minSize:{type:Number,default:20},tabindex:{type:[String,Number],default:void 0},id:String,role:String,...Se(["ariaLabel","ariaOrientation"])}),Ne={"end-reached":m=>["left","right","top","bottom"].includes(m),scroll:({scrollTop:m,scrollLeft:v})=>[m,v].every(N)},Pe="ElScrollbar",Re=x({name:Pe}),Be=x({...Re,props:Ce,emits:Ne,setup(m,{expose:v,emit:s}){const a=m,c=J("scrollbar");let f,p,i=0,n=0,d="";const T=u(),l=u(),o=u(),t=u(),h=L(()=>{const e={};return a.height&&(e.height=Y(a.height)),a.maxHeight&&(e.maxHeight=Y(a.maxHeight)),[a.wrapStyle,e]}),w=L(()=>[a.wrapClass,c.e("wrap"),{[c.em("wrap","hidden-default")]:!a.native}]),E=L(()=>[c.e("view"),a.viewClass]),S=()=>{var e;if(l.value){(e=t.value)==null||e.handleScroll(l.value);const b=i,r=n;i=l.value.scrollTop,n=l.value.scrollLeft;const y={bottom:i+l.value.clientHeight>=l.value.scrollHeight,top:i<=0&&b!==0,right:n+l.value.clientWidth>=l.value.scrollWidth&&r!==n,left:n<=0&&r!==0};b!==i&&(d=i>b?"bottom":"top"),r!==n&&(d=n>r?"right":"left"),s("scroll",{scrollTop:i,scrollLeft:n}),y[d]&&s("end-reached",d)}};function z(e,b){be(e)?l.value.scrollTo(e):N(e)&&N(b)&&l.value.scrollTo(e,b)}const B=e=>{N(e)&&(l.value.scrollTop=e)},C=e=>{N(e)&&(l.value.scrollLeft=e)},_=()=>{var e;(e=t.value)==null||e.update()};return I(()=>a.noresize,e=>{e?(f?.(),p?.()):({stop:f}=ie(o,_),p=O("resize",_))},{immediate:!0}),I(()=>[a.maxHeight,a.height],()=>{a.native||q(()=>{var e;_(),l.value&&((e=t.value)==null||e.handleScroll(l.value))})}),ce(K,ue({scrollbarElement:T,wrapElement:l})),ve(()=>{l.value&&(l.value.scrollTop=i,l.value.scrollLeft=n)}),fe(()=>{a.native||q(()=>{_()})}),de(()=>_()),v({wrapRef:l,update:_,scrollTo:z,setScrollTop:B,setScrollLeft:C,handleScroll:S}),(e,b)=>(P(),Z("div",{ref_key:"scrollbarRef",ref:T,class:R(g(c).b())},[A("div",{ref_key:"wrapRef",ref:l,class:R(g(w)),style:$(g(h)),tabindex:e.tabindex,onScroll:S},[(P(),W(he(e.tag),{id:e.id,ref_key:"resizeRef",ref:o,class:R(g(E)),style:$(e.viewStyle),role:e.role,"aria-label":e.ariaLabel,"aria-orientation":e.ariaOrientation},{default:Q(()=>[pe(e.$slots,"default")]),_:3},8,["id","class","style","role","aria-label","aria-orientation"]))],46,["tabindex"]),e.native?me("v-if",!0):(P(),W(Le,{key:0,ref_key:"barRef",ref:t,always:e.always,"min-size":e.minSize},null,8,["always","min-size"]))],2))}});var xe=j(Be,[["__file","scrollbar.vue"]]);const We=ye(xe);export{We as E,Ne as s};