mirror of
https://gitee.com/niucloud-team/niucloud-admin.git
synced 2026-01-04 04:08:13 +00:00
2 lines
7.2 KiB
JavaScript
2 lines
7.2 KiB
JavaScript
import{t as ae,c as D,v as oe,T as le,e as re}from"./event-4977bef7.js";import{b as Y,g as L,U as ne,h as Q,r as m,j as _,$ as ie,aH as U,m as T,D as W,E as Z,a1 as ce,q as $,v as C,u as d,x as X,_ as j,i as ee,n as te,F,I as ue,d as fe,e as k,l as I,w as K,P as V,V as ve,a4 as me,o as de,ax as pe,t as he,am as ye,T as ge,A as be,y as we,bM as Se}from"./base-45eb5090.js";const se=Symbol("scrollbarContextKey"),E=4,ze={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"}},Ee=({move:a,size:t,bar:s})=>({[s.size]:t,transform:`translate${s.axis}(${a}%)`}),_e=Y({vertical:Boolean,size:String,move:Number,ratio:{type:Number,required:!0},always:Boolean}),He="Thumb",ke=L({__name:"thumb",props:_e,setup(a){const t=a,s=ne(se),o=Q("scrollbar");s||ae(He,"can not inject scrollbar context");const i=m(),u=m(),n=m({}),v=m(!1);let r=!1,p=!1,h=ee?document.onselectstart:null;const l=_(()=>ze[t.vertical?"vertical":"horizontal"]),g=_(()=>Ee({size:t.size,move:t.move,bar:l.value})),b=_(()=>i.value[l.value.offset]**2/s.wrapElement[l.value.scrollSize]/t.ratio/u.value[l.value.offset]),w=c=>{var e;if(c.stopPropagation(),c.ctrlKey||[1,2].includes(c.button))return;(e=window.getSelection())==null||e.removeAllRanges(),M(c);const f=c.currentTarget;f&&(n.value[l.value.axis]=f[l.value.offset]-(c[l.value.client]-f.getBoundingClientRect()[l.value.direction]))},N=c=>{if(!u.value||!i.value||!s.wrapElement)return;const e=Math.abs(c.target.getBoundingClientRect()[l.value.direction]-c[l.value.client]),f=u.value[l.value.offset]/2,S=(e-f)*100*b.value/i.value[l.value.offset];s.wrapElement[l.value.scroll]=S*s.wrapElement[l.value.scrollSize]/100},M=c=>{c.stopImmediatePropagation(),r=!0,document.addEventListener("mousemove",x),document.addEventListener("mouseup",z),h=document.onselectstart,document.onselectstart=()=>!1},x=c=>{if(!i.value||!u.value||r===!1)return;const e=n.value[l.value.axis];if(!e)return;const f=(i.value.getBoundingClientRect()[l.value.direction]-c[l.value.client])*-1,S=u.value[l.value.offset]-e,H=(f-S)*100*b.value/i.value[l.value.offset];s.wrapElement[l.value.scroll]=H*s.wrapElement[l.value.scrollSize]/100},z=()=>{r=!1,n.value[l.value.axis]=0,document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",z),B(),p&&(v.value=!1)},A=()=>{p=!1,v.value=!!t.size},O=()=>{p=!0,v.value=r};ie(()=>{B(),document.removeEventListener("mouseup",z)});const B=()=>{document.onselectstart!==h&&(document.onselectstart=h)};return D(U(s,"scrollbarElement"),"mousemove",A),D(U(s,"scrollbarElement"),"mouseleave",O),(c,e)=>(T(),W(le,{name:d(o).b("fade"),persisted:""},{default:Z(()=>[ce($("div",{ref_key:"instance",ref:i,class:C([d(o).e("bar"),d(o).is(d(l).key)]),onMousedown:N},[$("div",{ref_key:"thumb",ref:u,class:C(d(o).e("thumb")),style:X(d(g)),onMousedown:w},null,38)],34),[[oe,c.always||v.value]])]),_:1},8,["name"]))}});var q=j(ke,[["__file","/home/runner/work/element-plus/element-plus/packages/components/scrollbar/src/thumb.vue"]]);const Te=Y({always:{type:Boolean,default:!0},width:String,height:String,ratioX:{type:Number,default:1},ratioY:{type:Number,default:1}}),Ce=L({__name:"bar",props:Te,setup(a,{expose:t}){const s=a,o=m(0),i=m(0);return t({handleScroll:n=>{if(n){const v=n.offsetHeight-E,r=n.offsetWidth-E;i.value=n.scrollTop*100/v*s.ratioY,o.value=n.scrollLeft*100/r*s.ratioX}}}),(n,v)=>(T(),te(ue,null,[F(q,{move:o.value,ratio:n.ratioX,size:n.width,always:n.always},null,8,["move","ratio","size","always"]),F(q,{move:i.value,ratio:n.ratioY,size:n.height,vertical:"",always:n.always},null,8,["move","ratio","size","always"])],64))}});var xe=j(Ce,[["__file","/home/runner/work/element-plus/element-plus/packages/components/scrollbar/src/bar.vue"]]);const Be=Y({height:{type:[String,Number],default:""},maxHeight:{type:[String,Number],default:""},native:{type:Boolean,default:!1},wrapStyle:{type:fe([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}}),Re={scroll:({scrollTop:a,scrollLeft:t})=>[a,t].every(k)},Pe="ElScrollbar",Le=L({name:Pe}),Ne=L({...Le,props:Be,emits:Re,setup(a,{expose:t,emit:s}){const o=a,i=Q("scrollbar");let u,n;const v=m(),r=m(),p=m(),h=m("0"),l=m("0"),g=m(),b=m(1),w=m(1),N=_(()=>{const e={};return o.height&&(e.height=I(o.height)),o.maxHeight&&(e.maxHeight=I(o.maxHeight)),[o.wrapStyle,e]}),M=_(()=>[o.wrapClass,i.e("wrap"),{[i.em("wrap","hidden-default")]:!o.native}]),x=_(()=>[i.e("view"),o.viewClass]),z=()=>{var e;r.value&&((e=g.value)==null||e.handleScroll(r.value),s("scroll",{scrollTop:r.value.scrollTop,scrollLeft:r.value.scrollLeft}))};function A(e,f){be(e)?r.value.scrollTo(e):k(e)&&k(f)&&r.value.scrollTo(e,f)}const O=e=>{k(e)&&(r.value.scrollTop=e)},B=e=>{k(e)&&(r.value.scrollLeft=e)},c=()=>{if(!r.value)return;const e=r.value.offsetHeight-E,f=r.value.offsetWidth-E,S=e**2/r.value.scrollHeight,H=f**2/r.value.scrollWidth,R=Math.max(S,o.minSize),P=Math.max(H,o.minSize);b.value=S/(e-S)/(R/(e-R)),w.value=H/(f-H)/(P/(f-P)),l.value=R+E<e?`${R}px`:"",h.value=P+E<f?`${P}px`:""};return K(()=>o.noresize,e=>{e?(u==null||u(),n==null||n()):({stop:u}=re(p,c),n=D("resize",c))},{immediate:!0}),K(()=>[o.maxHeight,o.height],()=>{o.native||V(()=>{var e;c(),r.value&&((e=g.value)==null||e.handleScroll(r.value))})}),ve(se,me({scrollbarElement:v,wrapElement:r})),de(()=>{o.native||V(()=>{c()})}),pe(()=>c()),t({wrapRef:r,update:c,scrollTo:A,setScrollTop:O,setScrollLeft:B,handleScroll:z}),(e,f)=>(T(),te("div",{ref_key:"scrollbarRef",ref:v,class:C(d(i).b())},[$("div",{ref_key:"wrapRef",ref:r,class:C(d(M)),style:X(d(N)),onScroll:z},[(T(),W(ye(e.tag),{ref_key:"resizeRef",ref:p,class:C(d(x)),style:X(e.viewStyle)},{default:Z(()=>[he(e.$slots,"default")]),_:3},8,["class","style"]))],38),e.native?ge("v-if",!0):(T(),W(xe,{key:0,ref_key:"barRef",ref:g,height:l.value,width:h.value,always:e.always,"ratio-x":w.value,"ratio-y":b.value},null,8,["height","width","always","ratio-x","ratio-y"]))],2))}});var Me=j(Ne,[["__file","/home/runner/work/element-plus/element-plus/packages/components/scrollbar/src/scrollbar.vue"]]);const De=we(Me),y=new Map;let G;ee&&(document.addEventListener("mousedown",a=>G=a),document.addEventListener("mouseup",a=>{for(const t of y.values())for(const{documentHandler:s}of t)s(a,G)}));function J(a,t){let s=[];return Array.isArray(t.arg)?s=t.arg:Se(t.arg)&&s.push(t.arg),function(o,i){const u=t.instance.popperRef,n=o.target,v=i==null?void 0:i.target,r=!t||!t.instance,p=!n||!v,h=a.contains(n)||a.contains(v),l=a===n,g=s.length&&s.some(w=>w==null?void 0:w.contains(n))||s.length&&s.includes(v),b=u&&(u.contains(n)||u.contains(v));r||p||h||l||g||b||t.value(o,i)}}const We={beforeMount(a,t){y.has(a)||y.set(a,[]),y.get(a).push({documentHandler:J(a,t),bindingFn:t.value})},updated(a,t){y.has(a)||y.set(a,[]);const s=y.get(a),o=s.findIndex(u=>u.bindingFn===t.oldValue),i={documentHandler:J(a,t),bindingFn:t.value};o>=0?s.splice(o,1,i):s.push(i)},unmounted(a){y.delete(a)}};export{ze as B,We as C,De as E};
|