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