123456 |
- import{b5 as ht,bp as dt,b6 as mt,d as St,am as gt,aD as pt,r as k,bq as V,K as w,a as r,l as vt,br as wt,bs as yt,M as st,aR as K,bt as G,an as N,bu as xt,bv as Ot,__tla as Mt}from"./index-e3afde76.js";import{H as ot,V as bt,v as zt,I as at,S as rt,u as Tt,i as J,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 Wt,C as ft,E as $t,f as Dt,h as Lt,__tla as kt}from"./el-virtual-list-12e94cee.js";let ut,Y,Ft=Promise.all([(()=>{try{return Mt}catch{}})(),(()=>{try{return kt}catch{}})()]).then(async()=>{let tt;tt={[ot]:"deltaX",[bt]:"deltaY"},Y=({name:u,getOffset:m,getItemSize:S,getItemOffset:E,getEstimatedTotalSize:_,getStartIndexForOffset:z,getStopIndexForStartIndex:T,initCache:g,clearCache:h,validateProps:R})=>St({name:u??"ElVirtualList",props:zt,emits:[at,rt],setup(e,{emit:d,expose:y}){R(e);const U=gt(),W=pt("vl"),x=k(g(e,U)),$=Tt(),I=k(),F=k(),q=k(),i=k({isScrolling:!1,scrollDir:"forward",scrollOffset:V(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(()=>J(e.layout)),X=w(()=>[{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]),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: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,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},N(D))},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)))},D=()=>{i.value.isScrolling=!1,N(()=>{$.value(-1,null,null)})},L=()=>{const t=I.value;t&&(t.scrollTop=0)};vt(()=>{if(!wt)return;const{initScrollOffset:t}=e,l=r(I);V(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(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:W,clientSize:M,estimatedTotalSize:p,windowStyle:X,windowRef:I,innerRef:F,innerStyle:j,itemsToRender:C,scrollbarRef:q,states:i,getItemStyle:t=>{const{direction:l,itemSize:o,layout:n}=e,s=$.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 Wt: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},N(D)})(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},N(D)})(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 y({windowRef:I,innerRef:F,getItemStyleCache:$,scrollTo:b,scrollToItem:H,resetScrollTop:L,states:i}),P},render(e){var d;const{$slots:y,className:U,clientSize:W,containerElement:x,data:$,getItemStyle:I,innerElement:F,itemsToRender:q,innerStyle:i,layout:C,total:p,onScroll:O,onScrollbarScroll:X,onWheel:j,states:M,useIsScrolling:B,windowStyle:A,ns:b}=e,[H,D]=q,L=st(x),P=st(F),t=[];if(p>0)for(let s=H;s<=D;s++)t.push((d=y.default)==null?void 0:d.call(y,{data:$,key:s,index:s,isScrolling:B?M.isScrolling:void 0,style:I(s)}));const l=[K(P,{style:i,ref:"innerRef"},G(P)?t:{default:()=>t})],o=K(It,{ref:"scrollbarRef",clientSize:W,layout:C,onScroll:X,ratio:100*W/this.estimatedTotalSize,scrollFrom:M.scrollOffset/(this.estimatedTotalSize-W),total:p}),n=K(L,{class:[b.e("window"),U],style:A,onScroll:O,onWheel:j,ref:"windowRef",key:0},G(L)?[l]:{default:()=>[l]});return K("div",{key:0,class:[b.e("wrapper"),M.scrollbarAlwaysOn?"always-on":""]},[n,o])}}),ut=Y({name:"ElFixedSizeList",getItemOffset:({itemSize:u},m)=>m*u,getItemSize:({itemSize:u})=>u,getEstimatedTotalSize:({total:u,itemSize:m})=>m*u,getOffset:({height:u,total:m,itemSize:S,layout:E,width:_},z,T,g)=>{const h=J(E)?_:u;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),d=Math.max(0,(z+1)*S-h);switch(T===Lt&&(T=g>=d-h&&g<=e+h?ct:ft),T){case Dt:return e;case $t:return d;case ft:{const y=Math.round(d+(e-d)/2);return y<Math.ceil(h/2)?0:y>R+Math.floor(h/2)?R:y}default:return g>=d&&g<=e?g:g<d?d:e}},getStartIndexForOffset:({total:u,itemSize:m},S)=>Math.max(0,Math.min(u-1,Math.floor(S/m))),getStopIndexForStartIndex:({height:u,total:m,itemSize:S,layout:E,width:_},z,T)=>{const g=z*S,h=J(E)?_:u,R=Math.ceil((h+T-g)/S);return Math.max(0,Math.min(m-1,z+R-1))},initCache(){},clearCache:!0,validateProps(){}})});export{ut as F,Ft as __tla,Y as c};
|