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