Files
YG_FT/frontend/dist/assets/el-scrollbar-D_ynOLJk.js
2026-07-27 09:12:03 +08:00

2 lines
7.2 KiB
JavaScript

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