fixed-size-list-ffef33f2.js 6.1 KB

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