el-virtual-list-382d146b.js 5.8 KB

1
  1. import{am as Ne,e as c,dc as ze,dd as v,aE as w,aD as B,bj as Ee,d as Me,aF as Z,r as ee,f as Le,de as Ce,a as R,O as Ie,aA as Be,bQ as te,ba as Re,cF as Fe,cH as Te,__tla as Oe}from"./index-20ebf448.js";let ae,G,re,le,ne,j,h,oe,F,se,T,H,P,ie,ue,k,ce,de,me,ve,pe,fe,V,ge,he,De=Promise.all([(()=>{try{return Oe}catch{}})()]).then(async()=>{var K=Number.isNaN||function(e){return typeof e=="number"&&e!=e};function ye(e,a){if(e.length!==a.length)return!1;for(var l=0;l<e.length;l++)if(n=e[l],r=a[l],!(n===r||K(n)&&K(r)))return!1;var n,r;return!0}let W,x,N,z,Q,E,y,O,D,M,_,$;ge=()=>{const e=Ne().proxy.$props;return c(()=>{const a=(l,n,r)=>({});return e.perfMode?ze(a):function(l,n){n===void 0&&(n=ye);var r=null;function p(){for(var u=[],d=0;d<arguments.length;d++)u[d]=arguments[d];if(r&&r.lastThis===this&&n(u,r.lastArgs))return r.lastResult;var f=l.apply(this,u);return r={lastResult:f,lastArgs:u,lastThis:this},f}return p.clear=function(){r=null},p}(a)})},le=50,oe="itemRendered",se="scroll",j="forward",G="backward",ae="auto",me="smart",ce="start",re="center",ne="end",h="horizontal",T="vertical",F="rtl",P="negative",H="positive-ascending",k="positive-descending",W={[h]:"left",[T]:"top"},x=v({type:w([Number,Function]),required:!0}),N=v({type:Number}),z=v({type:Number,default:2}),Q=v({type:String,values:["ltr","rtl"],default:"ltr"}),E=v({type:Number,default:0}),y=v({type:Number,required:!0}),O=v({type:String,values:["horizontal","vertical"],default:T}),D=B({className:{type:String,default:""},containerElement:{type:w([String,Object]),default:"div"},data:{type:w(Array),default:()=>Ee([])},direction:Q,height:{type:[String,Number],required:!0},innerElement:{type:[String,Object],default:"div"},style:{type:w([Object,String,Array])},useIsScrolling:{type:Boolean,default:!1},width:{type:[Number,String],required:!1},perfMode:{type:Boolean,default:!0},scrollbarAlwaysOn:{type:Boolean,default:!1}}),he=B({cache:z,estimatedItemSize:N,layout:O,initScrollOffset:E,total:y,itemSize:x,...D}),M={type:Number,default:6},_={type:Number,default:0},$={type:Number,default:2},pe=B({columnCache:z,columnWidth:x,estimatedColumnWidth:N,estimatedRowHeight:N,initScrollLeft:E,initScrollTop:E,itemKey:{type:w(Function),default:({columnIndex:e,rowIndex:a})=>`${a}:${e}`},rowCache:z,rowHeight:x,totalColumn:y,totalRow:y,hScrollbarSize:M,vScrollbarSize:M,scrollbarStartGap:_,scrollbarEndGap:$,role:String,...D}),V=B({alwaysOn:Boolean,class:String,layout:O,total:y,ratio:{type:Number,required:!0},clientSize:{type:Number,required:!0},scrollFrom:{type:Number,required:!0},scrollbarSize:M,startGap:_,endGap:$,visible:Boolean}),ue=(e,a)=>e<a?j:G,ve=e=>e==="ltr"||e===F||e===h,fe=e=>e===F;let b=null;de=function(e=!1){if(b===null||e){const a=document.createElement("div"),l=a.style;l.width="50px",l.height="50px",l.overflow="scroll",l.direction="rtl";const n=document.createElement("div"),r=n.style;return r.width="100px",r.height="100px",a.appendChild(n),document.body.appendChild(a),a.scrollLeft>0?b=k:(a.scrollLeft=1,b=a.scrollLeft===0?P:H),document.body.removeChild(a),b}return b},ie=Me({name:"ElVirtualScrollBar",props:V,emits:["scroll","start-move","stop-move"],setup(e,{emit:a}){const l=c(()=>e.startGap+e.endGap),n=Z("virtual-scrollbar"),r=Z("scrollbar"),p=ee(),u=ee();let d=null,f=null;const i=Le({isDragging:!1,traveled:0}),o=c(()=>Ce[e.layout]),Y=c(()=>e.clientSize-R(l)),be=c(()=>({position:"absolute",width:`${h===e.layout?Y.value:e.scrollbarSize}px`,height:`${h===e.layout?e.scrollbarSize:Y.value}px`,[W[e.layout]]:"2px",right:"2px",bottom:"2px",borderRadius:"4px"})),q=c(()=>{const t=e.ratio,s=e.clientSize;if(t>=100)return Number.POSITIVE_INFINITY;if(t>=50)return t*s/100;const g=s/3;return Math.floor(Math.min(Math.max(t*s,20),g))}),Se=c(()=>{if(!Number.isFinite(q.value))return{display:"none"};const t=`${q.value}px`;return function({move:g,size:I,bar:X},xe){const m={},A=`translate${X.axis}(${g}px)`;return m[X.size]=I,m.transform=A,m.msTransform=A,m.webkitTransform=A,xe==="horizontal"?m.height="100%":m.width="100%",m}({bar:o.value,size:t,move:i.traveled},e.layout)}),S=c(()=>Math.floor(e.clientSize-q.value-R(l))),J=()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",L),document.onselectstart=f,f=null;const t=R(u);t&&(t.removeEventListener("touchmove",C),t.removeEventListener("touchend",L))},U=t=>{t.stopImmediatePropagation(),t.ctrlKey||[1,2].includes(t.button)||(i.isDragging=!0,i[o.value.axis]=t.currentTarget[o.value.offset]-(t[o.value.client]-t.currentTarget.getBoundingClientRect()[o.value.direction]),a("start-move"),(()=>{window.addEventListener("mousemove",C),window.addEventListener("mouseup",L);const s=R(u);s&&(f=document.onselectstart,document.onselectstart=()=>!1,s.addEventListener("touchmove",C),s.addEventListener("touchend",L))})())},L=()=>{i.isDragging=!1,i[o.value.axis]=0,a("stop-move"),J()},C=t=>{const{isDragging:s}=i;if(!s||!u.value||!p.value)return;const g=i[o.value.axis];if(!g)return;Fe(d);const I=-1*(p.value.getBoundingClientRect()[o.value.direction]-t[o.value.client])-(u.value[o.value.offset]-g);d=Te(()=>{i.traveled=Math.max(e.startGap,Math.min(I,S.value)),a("scroll",I,S.value)})},we=t=>{const s=Math.abs(t.target.getBoundingClientRect()[o.value.direction]-t[o.value.client])-u.value[o.value.offset]/2;i.traveled=Math.max(0,Math.min(s,S.value)),a("scroll",s,S.value)};return Ie(()=>e.scrollFrom,t=>{i.isDragging||(i.traveled=Math.ceil(t*S.value))}),Be(()=>{J()}),()=>te("div",{role:"presentation",ref:p,class:[n.b(),e.class,(e.alwaysOn||i.isDragging)&&"always-on"],style:be.value,onMousedown:Re(we,["stop","prevent"]),onTouchstartPrevent:U},te("div",{ref:u,class:r.e("thumb"),style:Se.value,onMousedown:U},[]))}})});export{ae as A,G as B,re as C,le as D,ne as E,j as F,h as H,oe as I,F as R,se as S,T as V,De as __tla,H as a,P as b,ie as c,ue as d,k as e,ce as f,de as g,me as h,ve as i,pe as j,fe as k,V as l,ge as u,he as v};