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