fixed-size-list-738963d0.js 6.1 KB

123456
  1. import{bd as ut,bv as dt,be as mt,d as St,al as gt,aL as vt,r as D,bw as Y,M as w,a as r,q as pt,bx as wt,by as yt,O as st,aY as P,bz as J,am as N,bA as xt,bB as Ot,__tla as Mt}from"./index-dbf77a14.js";import{H as at,V as bt,v as zt,I as ot,S as rt,u as Tt,i as K,R as Q,g as it,a as Rt,b as nt,c as It,B as Et,F as _t,d as Z,A as ct,e as Lt,C as ft,E as Wt,f as $t,h as kt,__tla as Dt}from"./el-virtual-list-1e0da908.js";let ht,B,Ft=Promise.all([(()=>{try{return Mt}catch{}})(),(()=>{try{return Dt}catch{}})()]).then(async()=>{let tt;tt={[at]:"deltaX",[bt]:"deltaY"},B=({name:h,getOffset:m,getItemSize:S,getItemOffset:E,getEstimatedTotalSize:_,getStartIndexForOffset:z,getStopIndexForStartIndex:T,initCache:g,clearCache:u,validateProps:R})=>St({name:h??"ElVirtualList",props:zt,emits:[ot,rt],setup(e,{emit:d,expose:y}){R(e);const U=gt(),L=vt("vl"),x=D(g(e,U)),W=Tt(),I=D(),F=D(),q=D(),i=D({isScrolling:!1,scrollDir:"forward",scrollOffset:Y(e.initScrollOffset)?e.initScrollOffset:0,updateRequested:!1,isScrollbarDragging:!1,scrollbarAlwaysOn:e.scrollbarAlwaysOn}),C=w(()=>{const{total:t,cache:l}=e,{isScrolling:a,scrollDir:n,scrollOffset:s}=r(i);if(t===0)return[0,0,0,0];const o=z(e,s,r(x)),f=T(e,o,s,r(x)),c=a&&n!==Et?1:Math.max(1,l),p=a&&n!==_t?1:Math.max(1,l);return[Math.max(0,o-c),Math.max(0,Math.min(t-1,f+p)),o,f]}),v=w(()=>_(e,r(x))),O=w(()=>K(e.layout)),X=w(()=>[{position:"relative",["overflow-"+(O.value?"x":"y")]:"scroll",WebkitOverflowScrolling:"touch",willChange:"transform"},{direction:e.direction,height:Y(e.height)?`${e.height}px`:e.height,width:Y(e.width)?`${e.width}px`:e.width},e.style]),j=w(()=>{const t=r(v),l=r(O);return{height:l?"100%":`${t}px`,pointerEvents:r(i).isScrolling?"none":void 0,width:l?`${t}px`:"100%"}}),M=w(()=>O.value?e.width:e.height),{onWheel:G}=(({atEndEdge:t,atStartEdge:l,layout:a},n)=>{let s,o=0;const f=c=>c<0&&l.value||c>0&&t.value;return{hasReachedEdge:f,onWheel:c=>{ut(s);const p=c[tt[a.value]];f(o)&&f(o+p)||(o+=p,dt()||c.preventDefault(),s=mt(()=>{n(o),o=0}))}}})({atStartEdge:w(()=>i.value.scrollOffset<=0),atEndEdge:w(()=>i.value.scrollOffset>=v.value),layout:w(()=>e.layout)},t=>{var l,a;(a=(l=q.value).onMouseUp)==null||a.call(l),b(Math.min(i.value.scrollOffset+t,v.value-M.value))}),A=()=>{const{total:t}=e;if(t>0){const[s,o,f,c]=r(C);d(ot,s,o,f,c)}const{scrollDir:l,scrollOffset:a,updateRequested:n}=r(i);d(rt,l,a,n)},b=t=>{(t=Math.max(t,0))!==r(i).scrollOffset&&(i.value={...r(i),scrollOffset:t,scrollDir:Z(r(i).scrollOffset,t),updateRequested:!0},N($))},H=(t,l=ct)=>{const{scrollOffset:a}=r(i);t=Math.max(0,Math.min(t,e.total-1)),b(m(e,t,l,a,r(x)))},$=()=>{i.value.isScrolling=!1,N(()=>{W.value(-1,null,null)})},k=()=>{const t=I.value;t&&(t.scrollTop=0)};pt(()=>{if(!wt)return;const{initScrollOffset:t}=e,l=r(I);Y(t)&&l&&(r(O)?l.scrollLeft=t:l.scrollTop=t),A()}),yt(()=>{const{direction:t,layout:l}=e,{scrollOffset:a,updateRequested:n}=r(i),s=r(I);if(n&&s)if(l===at)if(t===Q)switch(it()){case nt:s.scrollLeft=-a;break;case Rt:s.scrollLeft=a;break;default:{const{clientWidth:o,scrollWidth:f}=s;s.scrollLeft=f-o-a;break}}else s.scrollLeft=a;else s.scrollTop=a});const V={ns:L,clientSize:M,estimatedTotalSize:v,windowStyle:X,windowRef:I,innerRef:F,innerStyle:j,itemsToRender:C,scrollbarRef:q,states:i,getItemStyle:t=>{const{direction:l,itemSize:a,layout:n}=e,s=W.value(u&&a,u&&n,u&&l);let o;if(xt(s,String(t)))o=s[t];else{const f=E(e,t,r(x)),c=S(e,t,r(x)),p=r(O),et=l===Q,lt=p?f:0;s[t]=o={position:"absolute",left:et?void 0:`${lt}px`,right:et?`${lt}px`:void 0,top:p?0:`${f}px`,height:p?"100%":`${c}px`,width:p?`${c}px`:"100%"}}return o},onScroll:t=>{r(O)?(l=>{const{clientWidth:a,scrollLeft:n,scrollWidth:s}=l.currentTarget,o=r(i);if(o.scrollOffset===n)return;const{direction:f}=e;let c=n;if(f===Q)switch(it()){case nt:c=-n;break;case Lt:c=s-a-n}c=Math.max(0,Math.min(c,s-a)),i.value={...o,isScrolling:!0,scrollDir:Z(o.scrollOffset,c),scrollOffset:c,updateRequested:!1},N($)})(t):(l=>{const{clientHeight:a,scrollHeight:n,scrollTop:s}=l.currentTarget,o=r(i);if(o.scrollOffset===s)return;const f=Math.max(0,Math.min(s,n-a));i.value={...o,isScrolling:!0,scrollDir:Z(o.scrollOffset,f),scrollOffset:f,updateRequested:!1},N($)})(t),A()},onScrollbarScroll:(t,l)=>{const a=(v.value-M.value)/l*t;b(Math.min(v.value-M.value,a))},onWheel:G,scrollTo:b,scrollToItem:H,resetScrollTop:k};return y({windowRef:I,innerRef:F,getItemStyleCache:W,scrollTo:b,scrollToItem:H,resetScrollTop:k,states:i}),V},render(e){var d;const{$slots:y,className:U,clientSize:L,containerElement:x,data:W,getItemStyle:I,innerElement:F,itemsToRender:q,innerStyle:i,layout:C,total:v,onScroll:O,onScrollbarScroll:X,onWheel:j,states:M,useIsScrolling:G,windowStyle:A,ns:b}=e,[H,$]=q,k=st(x),V=st(F),t=[];if(v>0)for(let s=H;s<=$;s++)t.push((d=y.default)==null?void 0:d.call(y,{data:W,key:s,index:s,isScrolling:G?M.isScrolling:void 0,style:I(s)}));const l=[P(V,{style:i,ref:"innerRef"},J(V)?t:{default:()=>t})],a=P(It,{ref:"scrollbarRef",clientSize:L,layout:C,onScroll:X,ratio:100*L/this.estimatedTotalSize,scrollFrom:M.scrollOffset/(this.estimatedTotalSize-L),total:v}),n=P(k,{class:[b.e("window"),U],style:A,onScroll:O,onWheel:j,ref:"windowRef",key:0},J(k)?[l]:{default:()=>[l]});return P("div",{key:0,class:[b.e("wrapper"),M.scrollbarAlwaysOn?"always-on":""]},[n,a])}}),ht=B({name:"ElFixedSizeList",getItemOffset:({itemSize:h},m)=>m*h,getItemSize:({itemSize:h})=>h,getEstimatedTotalSize:({total:h,itemSize:m})=>m*h,getOffset:({height:h,total:m,itemSize:S,layout:E,width:_},z,T,g)=>{const u=K(E)?_:h;J(u)&&Ot("[ElVirtualList]",`
  2. You should set
  3. width/height
  4. to number when your layout is
  5. horizontal/vertical
  6. `);const R=Math.max(0,m*S-u),e=Math.min(R,z*S),d=Math.max(0,(z+1)*S-u);switch(T===kt&&(T=g>=d-u&&g<=e+u?ct:ft),T){case $t:return e;case Wt:return d;case ft:{const y=Math.round(d+(e-d)/2);return y<Math.ceil(u/2)?0:y>R+Math.floor(u/2)?R:y}default:return g>=d&&g<=e?g:g<d?d:e}},getStartIndexForOffset:({total:h,itemSize:m},S)=>Math.max(0,Math.min(h-1,Math.floor(S/m))),getStopIndexForStartIndex:({height:h,total:m,itemSize:S,layout:E,width:_},z,T)=>{const g=z*S,u=K(E)?_:h,R=Math.ceil((u+T-g)/S);return Math.max(0,Math.min(m-1,z+R-1))},initCache(){},clearCache:!0,validateProps(){}})});export{ht as F,Ft as __tla,B as c};