fixed-size-list-c892150f.js 6.0 KB

1
  1. import{H as le,V as he,v as ue,I as ae,b as se,u as me,i as J,R as K,g as oe,c as Se,d as re,e as ge,B as pe,F as ve,f as Q,A as ie,h as we,C as ce,E as xe,S as ye,a as Oe,__tla as Me}from"./el-virtual-list-93a88b40.js";import{db as be,dg as Re,dc as Te,d as ze,al as Ie,ax as Ee,r as F,bd as j,J as w,a as r,k as _e,bh as We,dh as $e,L as ne,bR as N,bj as fe,am as U,di as ke,__tla as De}from"./index-73e02845.js";let de,Z,Fe=Promise.all([(()=>{try{return Me}catch{}})(),(()=>{try{return De}catch{}})()]).then(async()=>{let B;B={[le]:"deltaX",[he]:"deltaY"},Z=({name:d,getOffset:m,getItemSize:S,getItemOffset:E,getEstimatedTotalSize:_,getStartIndexForOffset:R,getStopIndexForStartIndex:T,initCache:g,clearCache:u,validateProps:z})=>ze({name:d??"ElVirtualList",props:ue,emits:[ae,se],setup(t,{emit:h,expose:x}){z(t);const V=Ie(),W=Ee("vl"),y=F(g(t,V)),$=me(),I=F(),L=F(),C=F(),i=F({isScrolling:!1,scrollDir:"forward",scrollOffset:j(t.initScrollOffset)?t.initScrollOffset:0,updateRequested:!1,isScrollbarDragging:!1,scrollbarAlwaysOn:t.scrollbarAlwaysOn}),q=w(()=>{const{total:e,cache:l}=t,{isScrolling:s,scrollDir:c,scrollOffset:a}=r(i);if(e===0)return[0,0,0,0];const o=R(t,a,r(y)),f=T(t,o,a,r(y)),n=s&&c!==pe?1:Math.max(1,l),v=s&&c!==ve?1:Math.max(1,l);return[Math.max(0,o-n),Math.max(0,Math.min(e-1,f+v)),o,f]}),p=w(()=>_(t,r(y))),O=w(()=>J(t.layout)),X=w(()=>[{position:"relative",["overflow-"+(O.value?"x":"y")]:"scroll",WebkitOverflowScrolling:"touch",willChange:"transform"},{direction:t.direction,height:j(t.height)?`${t.height}px`:t.height,width:j(t.width)?`${t.width}px`:t.width},t.style]),Y=w(()=>{const e=r(p),l=r(O);return{height:l?"100%":`${e}px`,pointerEvents:r(i).isScrolling?"none":void 0,width:l?`${e}px`:"100%"}}),M=w(()=>O.value?t.width:t.height),{onWheel:G}=(({atEndEdge:e,atStartEdge:l,layout:s},c)=>{let a,o=0;const f=n=>n<0&&l.value||n>0&&e.value;return{hasReachedEdge:f,onWheel:n=>{be(a);const v=n[B[s.value]];f(o)&&f(o+v)||(o+=v,Re()||n.preventDefault(),a=Te(()=>{c(o),o=0}))}}})({atStartEdge:w(()=>i.value.scrollOffset<=0),atEndEdge:w(()=>i.value.scrollOffset>=p.value),layout:w(()=>t.layout)},e=>{var l,s;(s=(l=C.value).onMouseUp)==null||s.call(l),b(Math.min(i.value.scrollOffset+e,p.value-M.value))}),A=()=>{const{total:e}=t;if(e>0){const[a,o,f,n]=r(q);h(ae,a,o,f,n)}const{scrollDir:l,scrollOffset:s,updateRequested:c}=r(i);h(se,l,s,c)},b=e=>{(e=Math.max(e,0))!==r(i).scrollOffset&&(i.value={...r(i),scrollOffset:e,scrollDir:Q(r(i).scrollOffset,e),updateRequested:!0},U(k))},H=(e,l=ie)=>{const{scrollOffset:s}=r(i);e=Math.max(0,Math.min(e,t.total-1)),b(m(t,e,l,s,r(y)))},k=()=>{i.value.isScrolling=!1,U(()=>{$.value(-1,null,null)})},D=()=>{const e=I.value;e&&(e.scrollTop=0)};_e(()=>{if(!We)return;const{initScrollOffset:e}=t,l=r(I);j(e)&&l&&(r(O)?l.scrollLeft=e:l.scrollTop=e),A()}),$e(()=>{const{direction:e,layout:l}=t,{scrollOffset:s,updateRequested:c}=r(i),a=r(I);if(c&&a)if(l===le)if(e===K)switch(oe()){case re:a.scrollLeft=-s;break;case Se:a.scrollLeft=s;break;default:{const{clientWidth:o,scrollWidth:f}=a;a.scrollLeft=f-o-s;break}}else a.scrollLeft=s;else a.scrollTop=s});const P={ns:W,clientSize:M,estimatedTotalSize:p,windowStyle:X,windowRef:I,innerRef:L,innerStyle:Y,itemsToRender:q,scrollbarRef:C,states:i,getItemStyle:e=>{const{direction:l,itemSize:s,layout:c}=t,a=$.value(u&&s,u&&c,u&&l);let o;if(ke(a,String(e)))o=a[e];else{const f=E(t,e,r(y)),n=S(t,e,r(y)),v=r(O),ee=l===K,te=v?f:0;a[e]=o={position:"absolute",left:ee?void 0:`${te}px`,right:ee?`${te}px`:void 0,top:v?0:`${f}px`,height:v?"100%":`${n}px`,width:v?`${n}px`:"100%"}}return o},onScroll:e=>{r(O)?(l=>{const{clientWidth:s,scrollLeft:c,scrollWidth:a}=l.currentTarget,o=r(i);if(o.scrollOffset===c)return;const{direction:f}=t;let n=c;if(f===K)switch(oe()){case re:n=-c;break;case we:n=a-s-c}n=Math.max(0,Math.min(n,a-s)),i.value={...o,isScrolling:!0,scrollDir:Q(o.scrollOffset,n),scrollOffset:n,updateRequested:!1},U(k)})(e):(l=>{const{clientHeight:s,scrollHeight:c,scrollTop:a}=l.currentTarget,o=r(i);if(o.scrollOffset===a)return;const f=Math.max(0,Math.min(a,c-s));i.value={...o,isScrolling:!0,scrollDir:Q(o.scrollOffset,f),scrollOffset:f,updateRequested:!1},U(k)})(e),A()},onScrollbarScroll:(e,l)=>{const s=(p.value-M.value)/l*e;b(Math.min(p.value-M.value,s))},onWheel:G,scrollTo:b,scrollToItem:H,resetScrollTop:D};return x({windowRef:I,innerRef:L,getItemStyleCache:$,scrollTo:b,scrollToItem:H,resetScrollTop:D,states:i}),P},render(t){var h;const{$slots:x,className:V,clientSize:W,containerElement:y,data:$,getItemStyle:I,innerElement:L,itemsToRender:C,innerStyle:i,layout:q,total:p,onScroll:O,onScrollbarScroll:X,onWheel:Y,states:M,useIsScrolling:G,windowStyle:A,ns:b}=t,[H,k]=C,D=ne(y),P=ne(L),e=[];if(p>0)for(let a=H;a<=k;a++)e.push((h=x.default)==null?void 0:h.call(x,{data:$,key:a,index:a,isScrolling:G?M.isScrolling:void 0,style:I(a)}));const l=[N(P,{style:i,ref:"innerRef"},fe(P)?e:{default:()=>e})],s=N(ge,{ref:"scrollbarRef",clientSize:W,layout:q,onScroll:X,ratio:100*W/this.estimatedTotalSize,scrollFrom:M.scrollOffset/(this.estimatedTotalSize-W),total:p}),c=N(D,{class:[b.e("window"),V],style:A,onScroll:O,onWheel:Y,ref:"windowRef",key:0},fe(D)?[l]:{default:()=>[l]});return N("div",{key:0,class:[b.e("wrapper"),M.scrollbarAlwaysOn?"always-on":""]},[c,s])}}),de=Z({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:_},R,T,g)=>{const u=J(E)?_:d,z=Math.max(0,m*S-u),t=Math.min(z,R*S),h=Math.max(0,(R+1)*S-u);switch(T===Oe&&(T=g>=h-u&&g<=t+u?ie:ce),T){case ye:return t;case xe:return h;case ce:{const x=Math.round(h+(t-h)/2);return x<Math.ceil(u/2)?0:x>z+Math.floor(u/2)?z:x}default:return g>=h&&g<=t?g:g<h?h:t}},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:_},R,T)=>{const g=R*S,u=J(E)?_:d,z=Math.ceil((u+T-g)/S);return Math.max(0,Math.min(m-1,R+z-1))},initCache(){},clearCache:!0,validateProps(){}})});export{de as F,Fe as __tla,Z as c};