You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
7.2 KiB
1 lines
7.2 KiB
import{b as M,c as te}from"./CeUmO8rY.js";import{f as B,P as Y,k as m,h as L,J as ae,aa as K,o as P,z as O,w as G,x as se,a as A,n as R,u as g,i as W,O as le,T as oe,c as J,b as F,F as re,l as U,aj as q,K as ne,m as ie,a7 as ce,E as ue,aC as fe,r as ve,ak as de,g as me,aq as pe}from"./Ca9y1zsW.js";import{b as D,_ as $,u as Q,q as Z,h as he,i as k,c as I,w as be,G as ye}from"./BPRC2v3K.js";import{t as ge}from"./Cq9Fpw4b.js";import{u as we}from"./CPNNouYu.js";const C=4,Se={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:a,size:t,bar:s})=>({[s.size]:t,transform:`translate${s.axis}(${a}%)`}),j=Symbol("scrollbarContextKey"),Ee=D({vertical:Boolean,size:String,move:Number,ratio:{type:Number,required:!0},always:Boolean}),_e="Thumb",Te=B({__name:"thumb",props:Ee,setup(a){const t=a,s=Y(j),l=Q("scrollbar");s||ge(_e,"can not inject scrollbar context");const i=m(),c=m(),f=m({}),v=m(!1);let p=!1,b=!1,r=Z?document.onselectstart:null;const o=L(()=>Se[t.vertical?"vertical":"horizontal"]),n=L(()=>ze({size:t.size,move:t.move,bar:o.value})),d=L(()=>i.value[o.value.offset]**2/s.wrapElement[o.value.scrollSize]/t.ratio/c.value[o.value.offset]),h=u=>{var E;if(u.stopPropagation(),u.ctrlKey||[1,2].includes(u.button))return;(E=window.getSelection())==null||E.removeAllRanges(),S(u);const H=u.currentTarget;H&&(f.value[o.value.axis]=H[o.value.offset]-(u[o.value.client]-H.getBoundingClientRect()[o.value.direction]))},T=u=>{if(!c.value||!i.value||!s.wrapElement)return;const E=Math.abs(u.target.getBoundingClientRect()[o.value.direction]-u[o.value.client]),H=c.value[o.value.offset]/2,N=(E-H)*100*d.value/i.value[o.value.offset];s.wrapElement[o.value.scroll]=N*s.wrapElement[o.value.scrollSize]/100},S=u=>{u.stopImmediatePropagation(),p=!0,document.addEventListener("mousemove",w),document.addEventListener("mouseup",y),r=document.onselectstart,document.onselectstart=()=>!1},w=u=>{if(!i.value||!c.value||p===!1)return;const E=f.value[o.value.axis];if(!E)return;const H=(i.value.getBoundingClientRect()[o.value.direction]-u[o.value.client])*-1,N=c.value[o.value.offset]-E,ee=(H-N)*100*d.value/i.value[o.value.offset];s.wrapElement[o.value.scroll]=ee*s.wrapElement[o.value.scrollSize]/100},y=()=>{p=!1,f.value[o.value.axis]=0,document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",y),e(),b&&(v.value=!1)},x=()=>{b=!1,v.value=!!t.size},z=()=>{b=!0,v.value=p};ae(()=>{e(),document.removeEventListener("mouseup",y)});const e=()=>{document.onselectstart!==r&&(document.onselectstart=r)};return M(K(s,"scrollbarElement"),"mousemove",x),M(K(s,"scrollbarElement"),"mouseleave",z),(u,E)=>(P(),O(oe,{name:g(l).b("fade"),persisted:""},{default:G(()=>[se(A("div",{ref_key:"instance",ref:i,class:R([g(l).e("bar"),g(l).is(g(o).key)]),onMousedown:T},[A("div",{ref_key:"thumb",ref:c,class:R(g(l).e("thumb")),style:W(g(n)),onMousedown:h},null,38)],34),[[le,u.always||v.value]])]),_:1},8,["name"]))}});var V=$(Te,[["__file","thumb.vue"]]);const He=D({always:{type:Boolean,default:!0},minSize:{type:Number,required:!0}}),Ce=B({__name:"bar",props:He,setup(a,{expose:t}){const s=a,l=Y(j),i=m(0),c=m(0),f=m(""),v=m(""),p=m(1),b=m(1);return t({handleScroll:n=>{if(n){const d=n.offsetHeight-C,h=n.offsetWidth-C;c.value=n.scrollTop*100/d*p.value,i.value=n.scrollLeft*100/h*b.value}},update:()=>{const n=l==null?void 0:l.wrapElement;if(!n)return;const d=n.offsetHeight-C,h=n.offsetWidth-C,T=d**2/n.scrollHeight,S=h**2/n.scrollWidth,w=Math.max(T,s.minSize),y=Math.max(S,s.minSize);p.value=T/(d-T)/(w/(d-w)),b.value=S/(h-S)/(y/(h-y)),v.value=w+C<d?`${w}px`:"",f.value=y+C<h?`${y}px`:""}}),(n,d)=>(P(),J(re,null,[F(V,{move:i.value,ratio:b.value,size:f.value,always:n.always},null,8,["move","ratio","size","always"]),F(V,{move:c.value,ratio:p.value,size:v.value,vertical:"",always:n.always},null,8,["move","ratio","size","always"])],64))}});var Le=$(Ce,[["__file","bar.vue"]]);const ke=D({height:{type:[String,Number],default:""},maxHeight:{type:[String,Number],default:""},native:{type:Boolean,default:!1},wrapStyle:{type:he([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},id:String,role:String,...we(["ariaLabel","ariaOrientation"])}),Pe={scroll:({scrollTop:a,scrollLeft:t})=>[a,t].every(k)},Re="ElScrollbar",Be=B({name:Re}),xe=B({...Be,props:ke,emits:Pe,setup(a,{expose:t,emit:s}){const l=a,i=Q("scrollbar");let c,f,v=0,p=0;const b=m(),r=m(),o=m(),n=m(),d=L(()=>{const e={};return l.height&&(e.height=I(l.height)),l.maxHeight&&(e.maxHeight=I(l.maxHeight)),[l.wrapStyle,e]}),h=L(()=>[l.wrapClass,i.e("wrap"),{[i.em("wrap","hidden-default")]:!l.native}]),T=L(()=>[i.e("view"),l.viewClass]),S=()=>{var e;r.value&&((e=n.value)==null||e.handleScroll(r.value),v=r.value.scrollTop,p=r.value.scrollLeft,s("scroll",{scrollTop:r.value.scrollTop,scrollLeft:r.value.scrollLeft}))};function w(e,u){pe(e)?r.value.scrollTo(e):k(e)&&k(u)&&r.value.scrollTo(e,u)}const y=e=>{k(e)&&(r.value.scrollTop=e)},x=e=>{k(e)&&(r.value.scrollLeft=e)},z=()=>{var e;(e=n.value)==null||e.update()};return U(()=>l.noresize,e=>{e?(c==null||c(),f==null||f()):({stop:c}=te(o,z),f=M("resize",z))},{immediate:!0}),U(()=>[l.maxHeight,l.height],()=>{l.native||q(()=>{var e;z(),r.value&&((e=n.value)==null||e.handleScroll(r.value))})}),ne(j,ie({scrollbarElement:b,wrapElement:r})),ce(()=>{r.value.scrollTop=v,r.value.scrollLeft=p}),ue(()=>{l.native||q(()=>{z()})}),fe(()=>z()),t({wrapRef:r,update:z,scrollTo:w,setScrollTop:y,setScrollLeft:x,handleScroll:S}),(e,u)=>(P(),J("div",{ref_key:"scrollbarRef",ref:b,class:R(g(i).b())},[A("div",{ref_key:"wrapRef",ref:r,class:R(g(h)),style:W(g(d)),onScroll:S},[(P(),O(de(e.tag),{id:e.id,ref_key:"resizeRef",ref:o,class:R(g(T)),style:W(e.viewStyle),role:e.role,"aria-label":e.ariaLabel,"aria-orientation":e.ariaOrientation},{default:G(()=>[ve(e.$slots,"default")]),_:3},8,["id","class","style","role","aria-label","aria-orientation"]))],38),e.native?me("v-if",!0):(P(),O(Le,{key:0,ref_key:"barRef",ref:n,always:e.always,"min-size":e.minSize},null,8,["always","min-size"]))],2))}});var Ne=$(xe,[["__file","scrollbar.vue"]]);const $e=be(Ne),_=new Map;if(Z){let a;document.addEventListener("mousedown",t=>a=t),document.addEventListener("mouseup",t=>{if(a){for(const s of _.values())for(const{documentHandler:l}of s)l(t,a);a=void 0}})}function X(a,t){let s=[];return Array.isArray(t.arg)?s=t.arg:ye(t.arg)&&s.push(t.arg),function(l,i){const c=t.instance.popperRef,f=l.target,v=i==null?void 0:i.target,p=!t||!t.instance,b=!f||!v,r=a.contains(f)||a.contains(v),o=a===f,n=s.length&&s.some(h=>h==null?void 0:h.contains(f))||s.length&&s.includes(v),d=c&&(c.contains(f)||c.contains(v));p||b||r||o||n||d||t.value(l,i)}}const je={beforeMount(a,t){_.has(a)||_.set(a,[]),_.get(a).push({documentHandler:X(a,t),bindingFn:t.value})},updated(a,t){_.has(a)||_.set(a,[]);const s=_.get(a),l=s.findIndex(c=>c.bindingFn===t.oldValue),i={documentHandler:X(a,t),bindingFn:t.value};l>=0?s.splice(l,1,i):s.push(i)},unmounted(a){_.delete(a)}};export{je as C,$e as E};
|