@pdanpdan/virtual-scroll 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +268 -275
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1497 -192
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2219 -896
- package/dist/index.mjs.map +1 -1
- package/dist/virtual-scroll.css +1 -2
- package/package.json +5 -1
- package/src/components/VirtualScroll.test.ts +1979 -627
- package/src/components/VirtualScroll.vue +951 -349
- package/src/components/VirtualScrollbar.test.ts +174 -0
- package/src/components/VirtualScrollbar.vue +102 -0
- package/src/composables/useVirtualScroll.test.ts +1160 -1521
- package/src/composables/useVirtualScroll.ts +1135 -791
- package/src/composables/useVirtualScrollbar.test.ts +526 -0
- package/src/composables/useVirtualScrollbar.ts +239 -0
- package/src/index.ts +4 -0
- package/src/types.ts +816 -0
- package/src/utils/fenwick-tree.test.ts +39 -39
- package/src/utils/fenwick-tree.ts +38 -18
- package/src/utils/scroll.test.ts +174 -0
- package/src/utils/scroll.ts +50 -13
- package/src/utils/virtual-scroll-logic.test.ts +2850 -0
- package/src/utils/virtual-scroll-logic.ts +901 -0
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`vue`)):typeof define==`function`&&define.amd?define([`exports`,`vue`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.VirtualScroll={},e.Vue))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n=class{tree;values;constructor(e){this.tree=new Float64Array(e+1),this.values=new Float64Array(e)}update(e,t){if(!(e<0||e>=this.values.length))for(this.values[e]=this.values[e]+t,e++;e<this.tree.length;)this.tree[e]=this.tree[e]+t,e+=e&-e}query(e){let t=0;for(;e>0;)t+=this.tree[e]||0,e-=e&-e;return t}set(e,t){e<0||e>=this.values.length||(this.values[e]=t)}get length(){return this.values.length}get(e){return this.values[e]||0}getValues(){return this.values}findLowerBound(e){let t=0,n=this.tree.length,r=1<<Math.floor(Math.log2(n-1));for(;r>0;){let i=t+r;if(i<n){let n=this.tree[i]||0;n<=e&&(t=i,e-=n)}r>>=1}return t}rebuild(){this.tree.fill(0);for(let e=0;e<this.values.length;e++)this.tree[e+1]=this.values[e]||0;for(let e=1;e<this.tree.length;e++){let t=e+(e&-e);t<this.tree.length&&(this.tree[t]=this.tree[t]+this.tree[e])}}resize(e){if(e===this.values.length)return;let t=new Float64Array(e);t.set(this.values.subarray(0,Math.min(e,this.values.length))),this.values=t,this.tree=new Float64Array(e+1),this.rebuild()}shift(e){if(e===0)return;let t=this.values.length,n=new Float64Array(t);e>0?n.set(this.values.subarray(0,Math.min(t-e,this.values.length)),e):n.set(this.values.subarray(-e)),this.values=n,this.rebuild()}};function r(e){return!!e&&`getBoundingClientRect`in e}function i(e){return!!e&&`scrollLeft`in e}function a(e){return typeof e==`object`&&!!e&&(`align`in e||`behavior`in e||`isCorrection`in e)}function o(e,t){return typeof e==`object`&&e?e.x||0:t===`horizontal`&&e||0}function s(e,t){return typeof e==`object`&&e?e.y||0:(t===`vertical`||t===`both`)&&e||0}function c(e){let c=(0,t.ref)(0),l=(0,t.ref)(0),u=(0,t.ref)(!1),d=(0,t.ref)(!1),f=(0,t.ref)(!1),p=(0,t.ref)(!1),m=(0,t.ref)(0),h=(0,t.ref)(0),g=(0,t.reactive)({x:0,y:0}),_,v=(0,t.ref)(!1),y=new n(e.value.items.length),b=new n(e.value.items.length),x=new n(e.value.columnCount||0),S=(0,t.ref)(0),C=new Uint8Array,w=new Uint8Array,T=new Uint8Array,E=(0,t.ref)(null),D=(0,t.ref)(!1),O=[],k=(0,t.computed)(()=>e.value.itemSize===void 0||e.value.itemSize===null||e.value.itemSize===0),A=(0,t.computed)(()=>e.value.columnWidth===void 0||e.value.columnWidth===null||e.value.columnWidth===0),j=(0,t.computed)(()=>typeof e.value.itemSize==`number`&&e.value.itemSize>0?e.value.itemSize:null),M=(0,t.computed)(()=>e.value.defaultItemSize||j.value||40),N=(0,t.computed)(()=>[...e.value.stickyIndices||[]].sort((e,t)=>e-t)),P=(0,t.computed)(()=>{if(S.value,!d.value&&e.value.ssrRange&&!p.value){let{start:t=0,end:n=0,colStart:r=0,colEnd:i=0}=e.value.ssrRange,a=e.value.columnCount||0;if(e.value.direction===`both`){if(a<=0)return 0;let t=i||a,n=x.query(t)-x.query(r);return Math.max(0,n-(t>r&&e.value.columnGap||0))}if(e.value.direction===`horizontal`){if(j.value!==null){let r=n-t;return Math.max(0,r*(j.value+(e.value.columnGap||0))-(r>0&&e.value.columnGap||0))}let r=y.query(n)-y.query(t);return Math.max(0,r-(n>t&&e.value.columnGap||0))}}if(e.value.direction===`both`){let t=e.value.columnCount||0;if(t<=0)return 0;let n=x.query(t);return Math.max(0,n-(e.value.columnGap||0))}if(e.value.direction===`vertical`)return 0;if(j.value!==null){let t=e.value.items.length;return Math.max(0,t*(j.value+(e.value.columnGap||0))-(t>0&&e.value.columnGap||0))}let t=y.query(e.value.items.length);return Math.max(0,t-(e.value.items.length>0&&e.value.columnGap||0))}),F=(0,t.computed)(()=>{if(S.value,!d.value&&e.value.ssrRange&&!p.value){let{start:t,end:n}=e.value.ssrRange;if(e.value.direction===`vertical`||e.value.direction===`both`){if(j.value!==null){let r=n-t;return Math.max(0,r*(j.value+(e.value.gap||0))-(r>0&&e.value.gap||0))}let r=b.query(n)-b.query(t);return Math.max(0,r-(n>t&&e.value.gap||0))}}if(e.value.direction===`horizontal`)return 0;if(j.value!==null){let t=e.value.items.length;return Math.max(0,t*(j.value+(e.value.gap||0))-(t>0&&e.value.gap||0))}let t=b.query(e.value.items.length);return Math.max(0,t-(e.value.items.length>0&&e.value.gap||0))}),I=(0,t.computed)(()=>{let t=e.value.direction===`horizontal`||e.value.direction===`both`?o(e.value.scrollPaddingStart,e.value.direction):0;return Math.max(0,c.value+t-g.x)}),L=(0,t.computed)(()=>{let t=e.value.direction===`vertical`||e.value.direction===`both`?s(e.value.scrollPaddingStart,e.value.direction):0;return Math.max(0,l.value+t-g.y)}),R=t=>{S.value;let n=e.value.columnWidth;if(typeof n==`number`&&n>0)return n;if(Array.isArray(n)&&n.length>0){let r=n[t%n.length];return r!=null&&r>0?r:e.value.defaultColumnWidth||100}return typeof n==`function`?n(t):x.get(t)||e.value.defaultColumnWidth||100},z=(t,n,d)=>{let f=typeof d==`object`&&d&&`isCorrection`in d?d.isCorrection:!1;f||(E.value={rowIndex:t,colIndex:n,options:d});let p=e.value.container||window,_=j.value,S=e.value.gap||0,C=e.value.columnGap||0,w,T;a(d)?(w=d.align,T=d.behavior):w=d;let D=(typeof w==`object`?w.x:w)||`auto`,O=(typeof w==`object`?w.y:w)||`auto`,k=o(e.value.scrollPaddingStart,e.value.direction),A=o(e.value.scrollPaddingEnd,e.value.direction),M=s(e.value.scrollPaddingStart,e.value.direction),N=s(e.value.scrollPaddingEnd,e.value.direction),R=e.value.direction===`vertical`||e.value.direction===`both`,z=e.value.direction===`horizontal`||e.value.direction===`both`,B=m.value-(z?k+A:0),V=h.value-(R?M+N:0),H=I.value,U=L.value,W=0,G=0;if(t!=null&&(t>=e.value.items.length?(U=F.value,G=0):(U=_===null?b.query(t):t*(_+S),G=_===null?b.get(t)-S:_),O===`start`||(O===`center`?U-=(V-G)/2:O===`end`?U-=V-G:U>=L.value&&U+G<=L.value+V||U<L.value||(U-=V-G))),n!=null){let t=e.value.columnCount||0;n>=t&&t>0?(H=P.value,W=0):e.value.direction===`horizontal`?(H=_===null?y.query(n):n*(_+C),W=_===null?y.get(n)-C:_):(H=x.query(n),W=x.get(n)-C),D===`start`||(D===`center`?H-=(B-W)/2:D===`end`?H-=B-W:H>=I.value&&H+W<=I.value+B||H<I.value||(H-=B-W))}H=Math.max(0,Math.min(H,Math.max(0,P.value-B))),U=Math.max(0,Math.min(U,Math.max(0,F.value-V)));let K=H+g.x-(z?k:0),q=U+g.y-(R?M:0),J=n==null||Math.abs(I.value-H)<1,Y=t==null||Math.abs(L.value-U)<1;if(!J||!Y){let e=0,i=0,a=0,o=0,s=0,c=0;if(typeof window<`u`){if(p===window?(e=window.scrollX,i=window.scrollY,a=document.documentElement.scrollWidth,o=document.documentElement.scrollHeight,s=window.innerWidth,c=window.innerHeight):r(p)&&(e=p.scrollLeft,i=p.scrollTop,a=p.scrollWidth,o=p.scrollHeight,s=p.clientWidth,c=p.clientHeight),!J&&n!=null){let t=e<=1&&K<=1,n=e>=a-s-1&&K>=a-s-1;(t||n)&&(J=!0)}if(!Y&&t!=null){let e=i<=1&&q<=1,t=i>=o-c-1&&q>=o-c-1;(e||t)&&(Y=!0)}}}let X=f?`auto`:T||`smooth`;if(v.value=!0,typeof window<`u`&&p===window)window.scrollTo({left:n==null?void 0:Math.max(0,K),top:t==null?void 0:Math.max(0,q),behavior:X});else if(i(p)){let e={behavior:X};n!=null&&(e.left=Math.max(0,K)),t!=null&&(e.top=Math.max(0,q)),typeof p.scrollTo==`function`?p.scrollTo(e):(e.left!==void 0&&(p.scrollLeft=e.left),e.top!==void 0&&(p.scrollTop=e.top))}(X===`auto`||X===void 0)&&(n!=null&&(c.value=Math.max(0,K)),t!=null&&(l.value=Math.max(0,q))),J&&Y&&!u.value&&(E.value=null)},B=(t,n,r)=>{let a=e.value.container||window;v.value=!0;let u=e.value.direction===`vertical`||e.value.direction===`both`,d=e.value.direction===`horizontal`||e.value.direction===`both`,f=o(e.value.scrollPaddingStart,e.value.direction),p=s(e.value.scrollPaddingStart,e.value.direction),_=o(e.value.scrollPaddingEnd,e.value.direction),y=s(e.value.scrollPaddingEnd,e.value.direction),b=m.value-(d?f+_:0),x=h.value-(u?p+y:0),S=t==null?null:d?Math.max(0,Math.min(t,Math.max(0,P.value-b))):Math.max(0,t),C=n==null?null:u?Math.max(0,Math.min(n,Math.max(0,F.value-x))):Math.max(0,n),w=typeof window<`u`&&a===window?window.scrollX:a.scrollLeft,T=typeof window<`u`&&a===window?window.scrollY:a.scrollTop,E=S===null?w:S+g.x-(d?f:0),D=C===null?T:C+g.y-(u?p:0);if(typeof window<`u`&&a===window)window.scrollTo({left:t==null?void 0:E,top:n==null?void 0:D,behavior:r?.behavior||`auto`});else if(i(a)){let e={behavior:r?.behavior||`auto`};t!=null&&(e.left=E),n!=null&&(e.top=D),typeof a.scrollTo==`function`?a.scrollTo(e):(e.left!==void 0&&(a.scrollLeft=e.left),e.top!==void 0&&(a.scrollTop=e.top))}(r?.behavior===`auto`||r?.behavior===void 0)&&(t!=null&&(c.value=E),n!=null&&(l.value=D))},V=()=>{let n=e.value.items,r=n.length,i=e.value.columnCount||0;if(y.resize(r),b.resize(r),x.resize(i),w.length!==r){let e=new Uint8Array(r);e.set(w.subarray(0,Math.min(r,w.length))),w=e}if(T.length!==r){let e=new Uint8Array(r);e.set(T.subarray(0,Math.min(r,T.length))),T=e}if(C.length!==i){let e=new Uint8Array(i);e.set(C.subarray(0,Math.min(i,C.length))),C=e}let a=0;if(e.value.restoreScrollOnPrepend&&O.length>0&&r>O.length){let e=O[0];if(e!==void 0){for(let t=1;t<=r-O.length;t++)if(n[t]===e){a=t;break}}}if(a>0){y.shift(a),b.shift(a),E.value&&E.value.rowIndex!==null&&E.value.rowIndex!==void 0&&(E.value.rowIndex+=a);let i=new Uint8Array(r),o=new Uint8Array(r);i.set(w.subarray(0,Math.min(r-a,w.length)),a),o.set(T.subarray(0,Math.min(r-a,T.length)),a),w=i,T=o;let s=e.value.gap||0,c=e.value.columnGap||0,l=0,u=0;for(let t=0;t<a;t++){let r=typeof e.value.itemSize==`function`?e.value.itemSize(n[t],t):M.value;e.value.direction===`horizontal`?l+=r+c:u+=r+s}(l>0||u>0)&&(0,t.nextTick)(()=>{B(l>0?I.value+l:null,u>0?L.value+u:null,{behavior:`auto`})})}if(i>0){let t=e.value.columnGap||0,n=!1;for(let e=0;e<i;e++){let r=R(e),i=x.get(e),a=C[e]===1;if(!A.value||!a||i===0){let a=r+t;Math.abs(i-a)>.5?(x.set(e,a),C[e]=A.value?0:1,n=!0):A.value||(C[e]=1)}}n&&x.rebuild()}let o=e.value.gap||0,s=e.value.columnGap||0,c=!1;for(let t=0;t<r;t++){let n=e.value.items[t],r=y.get(t),i=b.get(t),a=typeof e.value.itemSize==`function`?e.value.itemSize(n,t):M.value,l=e.value.direction===`vertical`,u=e.value.direction===`horizontal`,d=e.value.direction===`both`,f=u?a+s:0,p=l||d?a+o:0,m=w[t]===1,h=T[t]===1;u?(!k.value||!m||r===0)&&(Math.abs(r-f)>.5?(y.set(t,f),w[t]=k.value?0:1,c=!0):k.value||(w[t]=1)):r!==0&&(y.set(t,0),w[t]=0,c=!0),l||d?(!k.value||!h||i===0)&&(Math.abs(i-p)>.5?(b.set(t,p),T[t]=k.value?0:1,c=!0):k.value||(T[t]=1)):i!==0&&(b.set(t,0),T[t]=0,c=!0)}c&&(y.rebuild(),b.rebuild()),O=[...n],D.value=!0,S.value++},H=()=>{if(e.value.hostElement&&typeof window<`u`){let t=e.value.hostElement.getBoundingClientRect(),n=e.value.container||window,i=0,a=0;if(n===window)i=t.left+window.scrollX,a=t.top+window.scrollY;else if(n===e.value.hostElement)i=0,a=0;else if(r(n)){let e=n.getBoundingClientRect();i=t.left-e.left+n.scrollLeft,a=t.top-e.top+n.scrollTop}(Math.abs(g.x-i)>.1||Math.abs(g.y-a)>.1)&&(g.x=i,g.y=a)}};(0,t.watch)([()=>e.value.items,()=>e.value.direction,()=>e.value.columnCount,()=>e.value.columnWidth,()=>e.value.itemSize,()=>e.value.gap,()=>e.value.columnGap,()=>e.value.defaultItemSize,()=>e.value.defaultColumnWidth],V,{immediate:!0}),(0,t.watch)(()=>[e.value.container,e.value.hostElement],()=>{H()});let U=(0,t.computed)(()=>{if(S.value,(!d.value||f.value)&&e.value.ssrRange)return{start:e.value.ssrRange.start,end:e.value.ssrRange.end};let t=e.value.direction||`vertical`,n=e.value.ssrRange&&!u.value?0:e.value.bufferBefore??5,r=e.value.bufferAfter??5,i=e.value.gap||0,a=e.value.columnGap||0,c=j.value,l=o(e.value.scrollPaddingStart,t),p=o(e.value.scrollPaddingEnd,t),g=s(e.value.scrollPaddingStart,t),_=s(e.value.scrollPaddingEnd,t),v=t===`vertical`||t===`both`,x=t===`horizontal`||t===`both`,C=m.value-(x?l+p:0),w=h.value-(v?g+_:0),T=0,E=e.value.items.length;if(v)if(c!==null)T=Math.floor(L.value/(c+i)),E=Math.ceil((L.value+w)/(c+i));else{T=b.findLowerBound(L.value);let t=b.query(T),n=T;for(;n<e.value.items.length&&t<L.value+w;)t=b.query(++n);E=n}else if(c!==null)T=Math.floor(I.value/(c+a)),E=Math.ceil((I.value+C)/(c+a));else{T=y.findLowerBound(I.value);let t=y.query(T),n=T;for(;n<e.value.items.length&&t<I.value+C;)t=y.query(++n);E=n}return{start:Math.max(0,T-n),end:Math.min(e.value.items.length,E+r)}}),W=(0,t.computed)(()=>{S.value;let t=j.value,n=e.value.gap||0,r=e.value.columnGap||0;return e.value.direction===`horizontal`?t===null?y.findLowerBound(I.value):Math.floor(I.value/(t+r)):t===null?b.findLowerBound(L.value):Math.floor(L.value/(t+n))}),G=(0,t.computed)(()=>{S.value;let{start:t,end:n}=U.value,r=[],i=j.value,a=e.value.gap||0,o=e.value.columnGap||0,s=N.value,c=new Set;for(let e=t;e<n;e++)c.add(e);if(d.value||!e.value.ssrRange){let e=W.value,r,i=0,a=s.length-1;for(;i<=a;){let t=i+a>>>1;s[t]<e?(r=s[t],i=t+1):a=t-1}r!==void 0&&c.add(r);for(let e of s)e>=t&&e<n&&c.add(e)}let l=Array.from(c).sort((e,t)=>e-t),u=e.value.ssrRange?.start||0,f=e.value.ssrRange?.colStart||0,p=0,g=0;!d.value&&e.value.ssrRange&&(g=e.value.direction===`vertical`||e.value.direction===`both`?i===null?b.query(u):u*(i+a):0,e.value.direction===`horizontal`?p=i===null?y.query(f):f*(i+o):e.value.direction===`both`&&(p=x.query(f)));for(let t of l){let n=e.value.items[t];if(n===void 0)continue;let c=0,l=0,u=0,d=0;e.value.direction===`horizontal`?(c=i===null?y.query(t):t*(i+o),u=i===null?y.get(t)-o:i,d=h.value):(l=(e.value.direction===`vertical`||e.value.direction===`both`)&&i!==null?t*(i+a):b.query(t),d=i===null?b.get(t)-a:i,u=e.value.direction===`both`?P.value:m.value);let f=s.includes(t),_=c,v=l,x=!1,S={x:0,y:0};if(f){if(e.value.direction===`vertical`||e.value.direction===`both`){if(L.value>v){x=!0;let e,n=0,r=s.length-1;for(;n<=r;){let i=n+r>>>1;s[i]>t?(e=s[i],r=i-1):n=i+1}if(e!==void 0){let t=(i===null?b.query(e):e*(i+a))-L.value;t<d&&(S.y=-(d-t))}}}else if(e.value.direction===`horizontal`&&I.value>_){x=!0;let e,n=0,r=s.length-1;for(;n<=r;){let i=n+r>>>1;s[i]>t?(e=s[i],r=i-1):n=i+1}if(e!==void 0){let t=(i===null?y.query(e):e*(i+o))-I.value;t<u&&(S.x=-(u-t))}}}r.push({item:n,index:t,offset:{x:_-p,y:v-g},size:{width:u,height:d},originalX:_,originalY:v,isSticky:f,isStickyActive:x,stickyOffset:S})}return r}),K=(0,t.computed)(()=>{S.value;let t=e.value.columnCount||0;if(!t)return{start:0,end:0,padStart:0,padEnd:0};if((!d.value||f.value)&&e.value.ssrRange){let{colStart:n=0,colEnd:r=0}=e.value.ssrRange;return{start:Math.max(0,n),end:Math.min(t,r||t),padStart:0,padEnd:0}}let n=x.findLowerBound(I.value),r=x.query(n),i=n;for(;i<t&&r<I.value+m.value;)r=x.query(++i);let a=e.value.ssrRange&&!u.value?0:2,o=Math.max(0,n-a),s=Math.min(t,i+a);return{start:o,end:s,padStart:x.query(o),padEnd:x.query(t)-x.query(s)}}),q=(0,t.computed)(()=>{S.value;let t=j.value,n=e.value.columnGap||0,r=0;return(e.value.direction===`horizontal`||e.value.direction===`both`)&&(r=t===null?y.findLowerBound(I.value):Math.floor(I.value/(t+n))),{items:G.value,currentIndex:W.value,currentColIndex:r,scrollOffset:{x:I.value,y:L.value},viewportSize:{width:m.value,height:h.value},totalSize:{width:P.value,height:F.value},isScrolling:u.value,isProgrammaticScroll:v.value,range:U.value,columnRange:K.value}}),J=()=>{v.value=!1,E.value=null},Y=e=>{let t=e.target;typeof window>`u`||(t===window||t===document?(c.value=window.scrollX,l.value=window.scrollY):i(t)&&(c.value=t.scrollLeft,l.value=t.scrollTop),u.value||=(v.value||(E.value=null),!0),clearTimeout(_),_=setTimeout(()=>{u.value=!1,v.value=!1},250))},X=t=>{let n=!1,r=e.value.gap||0,i=e.value.columnGap||0;for(let{index:a,inlineSize:o,blockSize:s,element:c}of t){if((k.value||typeof e.value.itemSize==`function`)&&a>=0){if(e.value.direction===`horizontal`){let e=y.get(a),t=o+i;(!w[a]||Math.abs(t-e)>.5)&&(y.update(a,t-e),w[a]=1,n=!0)}if(e.value.direction===`vertical`||e.value.direction===`both`){let t=b.get(a),i=s+r;e.value.direction,(!T[a]||Math.abs(i-t)>.5)&&(b.update(a,i-t),T[a]=1,n=!0)}}let t=A.value||typeof e.value.columnWidth==`function`;if(e.value.direction===`both`&&c&&e.value.columnCount&&t){let t=c.dataset.colIndex===void 0?Array.from(c.querySelectorAll(`[data-col-index]`)):[c];for(let r of t){let t=Number.parseInt(r.dataset.colIndex,10);if(t>=0&&t<(e.value.columnCount||0)){let e=r.offsetWidth,a=x.get(t),o=e+i;Math.abs(a-o)>.5&&(x.update(t,o-a),C[t]=1,n=!0)}}}}n&&S.value++},ee=(e,t,n,r)=>{X([{index:e,inlineSize:t,blockSize:n,element:r}])},Z=()=>{if(E.value&&!f.value){let{rowIndex:e,colIndex:t,options:n}=E.value;z(e,t,a(n)?{...n,isCorrection:!0}:{align:n,isCorrection:!0})}};(0,t.watch)(S,Z),(0,t.watch)(u,e=>{e||Z()});let Q=null,te=e=>{if(!e||typeof window>`u`)return;let t=e===window?document:e;if(t.addEventListener(`scroll`,Y,{passive:!0}),e===window){m.value=window.innerWidth,h.value=window.innerHeight,c.value=window.scrollX,l.value=window.scrollY;let e=()=>{m.value=window.innerWidth,h.value=window.innerHeight,H()};return window.addEventListener(`resize`,e),()=>{t.removeEventListener(`scroll`,Y),window.removeEventListener(`resize`,e)}}else return m.value=e.clientWidth,h.value=e.clientHeight,c.value=e.scrollLeft,l.value=e.scrollTop,Q=new ResizeObserver(t=>{for(let n of t)n.target===e&&(m.value=e.clientWidth,h.value=e.clientHeight,H())}),Q.observe(e),()=>{t.removeEventListener(`scroll`,Y),Q?.disconnect()}},$;return(0,t.getCurrentInstance)()&&((0,t.onMounted)(()=>{p.value=!0,(0,t.watch)(()=>e.value.container,e=>{$?.(),$=te(e||null)},{immediate:!0}),H(),e.value.ssrRange||e.value.initialScrollIndex!==void 0?(0,t.nextTick)(()=>{H();let n=e.value.initialScrollIndex===void 0?e.value.ssrRange?.start:e.value.initialScrollIndex,r=e.value.initialScrollAlign||`start`;n!=null&&z(n,e.value.ssrRange?.colStart,{align:r,behavior:`auto`}),d.value=!0,f.value=!0,(0,t.nextTick)(()=>{f.value=!1})}):d.value=!0}),(0,t.onUnmounted)(()=>{$?.()})),{renderedItems:G,totalWidth:P,totalHeight:F,scrollDetails:q,scrollToIndex:z,scrollToOffset:B,stopProgrammaticScroll:J,updateItemSize:ee,updateItemSizes:X,updateHostOffset:H,columnRange:K,getColumnWidth:R,refresh:()=>{y.resize(0),b.resize(0),x.resize(0),C.fill(0),w.fill(0),T.fill(0),V()},isHydrated:d}}var l={key:0,class:`virtual-scroll-debug-info`},u=((e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n})((0,t.defineComponent)({__name:`VirtualScroll`,props:{items:{},itemSize:{},direction:{default:`vertical`},bufferBefore:{default:5},bufferAfter:{default:5},container:{},ssrRange:{},columnCount:{default:0},columnWidth:{},containerTag:{default:`div`},wrapperTag:{default:`div`},itemTag:{default:`div`},scrollPaddingStart:{default:0},scrollPaddingEnd:{default:0},stickyHeader:{type:Boolean,default:!1},stickyFooter:{type:Boolean,default:!1},gap:{default:0},columnGap:{default:0},stickyIndices:{default:()=>[]},loadDistance:{default:200},loading:{type:Boolean,default:!1},restoreScrollOnPrepend:{type:Boolean,default:!1},initialScrollIndex:{},initialScrollAlign:{},defaultItemSize:{},defaultColumnWidth:{},debug:{type:Boolean,default:!1}},emits:[`scroll`,`load`,`visibleRangeChange`],setup(e,{expose:n,emit:r}){let i=e,a=r,u=(0,t.useSlots)(),d=(0,t.ref)(null),f=(0,t.ref)(null),p=(0,t.ref)(null),m=(0,t.ref)(null),h=new Map,g=(0,t.ref)(0),_=(0,t.ref)(0),v=(0,t.computed)(()=>{let e=i.container===void 0?d.value:i.container;return e===d.value||typeof window<`u`&&(e===window||e===null)}),{isHydrated:y,columnRange:b,renderedItems:x,scrollDetails:S,totalHeight:C,totalWidth:w,getColumnWidth:T,scrollToIndex:E,scrollToOffset:D,updateHostOffset:O,updateItemSizes:k,refresh:A,stopProgrammaticScroll:j}=c((0,t.computed)(()=>{let e=i.scrollPaddingStart,t=i.scrollPaddingEnd,n=typeof e==`object`?e.x||0:i.direction===`horizontal`&&e||0,r=typeof e==`object`?e.y||0:i.direction===`horizontal`?0:e||0,a=typeof t==`object`?t.x||0:i.direction===`horizontal`&&t||0,o=typeof t==`object`?t.y||0:i.direction===`horizontal`?0:t||0;return{items:i.items,itemSize:i.itemSize,direction:i.direction,bufferBefore:i.bufferBefore,bufferAfter:i.bufferAfter,container:i.container===void 0?d.value:i.container,hostElement:f.value,ssrRange:i.ssrRange,columnCount:i.columnCount,columnWidth:i.columnWidth,scrollPaddingStart:{x:n,y:r+(i.stickyHeader&&v.value?g.value:0)},scrollPaddingEnd:{x:a,y:o+(i.stickyFooter&&v.value?_.value:0)},gap:i.gap,columnGap:i.columnGap,stickyIndices:i.stickyIndices,loadDistance:i.loadDistance,loading:i.loading,restoreScrollOnPrepend:i.restoreScrollOnPrepend,initialScrollIndex:i.initialScrollIndex,initialScrollAlign:i.initialScrollAlign,defaultItemSize:i.defaultItemSize,defaultColumnWidth:i.defaultColumnWidth,debug:i.debug}}));function M(){A(),(0,t.nextTick)(()=>{let e=[];for(let[t,n]of h.entries())n&&e.push({index:t,inlineSize:n.offsetWidth,blockSize:n.offsetHeight,element:n});e.length>0&&k(e)})}(0,t.watch)(S,(e,t)=>{y.value&&(a(`scroll`,e),(!t||e.range.start!==t.range.start||e.range.end!==t.range.end||e.columnRange.start!==t.columnRange.start||e.columnRange.end!==t.columnRange.end)&&a(`visibleRangeChange`,{start:e.range.start,end:e.range.end,colStart:e.columnRange.start,colEnd:e.columnRange.end}),!i.loading&&(i.direction!==`horizontal`&&e.totalSize.height-(e.scrollOffset.y+e.viewportSize.height)<=i.loadDistance&&a(`load`,`vertical`),i.direction!==`vertical`&&e.totalSize.width-(e.scrollOffset.x+e.viewportSize.width)<=i.loadDistance&&a(`load`,`horizontal`)))}),(0,t.watch)(y,e=>{e&&a(`visibleRangeChange`,{start:S.value.range.start,end:S.value.range.end,colStart:S.value.columnRange.start,colEnd:S.value.columnRange.end})},{once:!0});let N=typeof window>`u`?null:new ResizeObserver(O),P=typeof window>`u`?null:new ResizeObserver(e=>{let t=[];for(let n of e){let e=n.target,r=Number(e.dataset.index);if(e.dataset.colIndex!==void 0)t.push({index:-1,inlineSize:0,blockSize:0,element:e});else if(!Number.isNaN(r)){let i=n.contentRect.width,a=n.contentRect.height;n.borderBoxSize&&n.borderBoxSize.length>0?(i=n.borderBoxSize[0].inlineSize,a=n.borderBoxSize[0].blockSize):(i=e.offsetWidth,a=e.offsetHeight),t.push({index:r,inlineSize:i,blockSize:a,element:e})}}t.length>0&&k(t)}),F=typeof window>`u`?null:new ResizeObserver(()=>{g.value=p.value?.offsetHeight||0,_.value=m.value?.offsetHeight||0,O()});(0,t.watch)(p,(e,t)=>{t&&F?.unobserve(t),e&&F?.observe(e)},{immediate:!0}),(0,t.watch)(m,(e,t)=>{t&&F?.unobserve(t),e&&F?.observe(e)},{immediate:!0});let I=(0,t.computed)(()=>x.value[0]?.index);(0,t.watch)(I,(e,t)=>{if(i.direction===`both`){if(t!==void 0){let e=h.get(t);e&&e.querySelectorAll(`[data-col-index]`).forEach(e=>P?.unobserve(e))}if(e!==void 0){let t=h.get(e);t&&t.querySelectorAll(`[data-col-index]`).forEach(e=>P?.observe(e))}}},{flush:`post`}),(0,t.onMounted)(()=>{d.value&&N?.observe(d.value);for(let e of h.values())P?.observe(e);if(I.value!==void 0){let e=h.get(I.value);e&&e.querySelectorAll(`[data-col-index]`).forEach(e=>P?.observe(e))}}),(0,t.watch)([d,f],([e],[t])=>{t&&N?.unobserve(t),e&&N?.observe(e)});function L(e,t){if(e)h.set(t,e),P?.observe(e);else{let e=h.get(t);e&&(P?.unobserve(e),h.delete(t))}}function R(e){j();let{viewportSize:t,scrollOffset:n}=S.value,r=i.direction!==`vertical`,a=i.direction!==`horizontal`;if(e.key===`Home`){e.preventDefault(),E(0,0,`start`);return}if(e.key===`End`){e.preventDefault();let t=i.items.length-1,n=(i.columnCount||0)>0?i.columnCount-1:0;r?a?E(t,n,`end`):E(0,t,`end`):E(t,0,`end`);return}if(e.key===`ArrowUp`){e.preventDefault(),D(null,n.y-40);return}if(e.key===`ArrowDown`){e.preventDefault(),D(null,n.y+40);return}if(e.key===`ArrowLeft`){e.preventDefault(),D(n.x-40,null);return}if(e.key===`ArrowRight`){e.preventDefault(),D(n.x+40,null);return}if(e.key===`PageUp`){e.preventDefault(),D(!a&&r?n.x-t.width:null,a?n.y-t.height:null);return}e.key===`PageDown`&&(e.preventDefault(),D(!a&&r?n.x+t.width:null,a?n.y+t.height:null))}(0,t.onUnmounted)(()=>{N?.disconnect(),P?.disconnect(),F?.disconnect()});let z=(0,t.computed)(()=>{let e=i.container;return e===null||typeof window<`u`&&e===window?!0:e&&typeof e==`object`&&`tagName`in e?e.tagName===`BODY`:!1}),B=(0,t.computed)(()=>z.value?{...i.direction===`vertical`?{}:{whiteSpace:`nowrap`}}:i.containerTag===`table`?{minInlineSize:i.direction===`vertical`?`100%`:`auto`}:{...i.direction===`vertical`?{}:{whiteSpace:`nowrap`}}),V=(0,t.computed)(()=>({inlineSize:i.direction===`vertical`?`100%`:`${w.value}px`,blockSize:i.direction===`horizontal`?`100%`:`${C.value}px`})),H=(0,t.computed)(()=>{let e=i.direction===`horizontal`;return{display:e?`inline-block`:`block`,...e?{blockSize:`100%`,verticalAlign:`top`}:{inlineSize:`100%`}}}),U=(0,t.computed)(()=>({inlineSize:i.direction===`vertical`?`1px`:`${w.value}px`,blockSize:i.direction===`horizontal`?`1px`:`${C.value}px`}));function W(e){let t=i.direction===`vertical`,n=i.direction===`horizontal`,r=i.direction===`both`,a=i.itemSize===void 0||i.itemSize===null||i.itemSize===0,c={blockSize:n?`100%`:a?`auto`:`${e.size.height}px`};return t&&i.containerTag===`table`?c.minInlineSize=`100%`:c.inlineSize=t?`100%`:a?`auto`:`${e.size.width}px`,a&&(t||(c.minInlineSize=`1px`),n||(c.minBlockSize=`1px`)),y.value&&(e.isStickyActive?((t||r)&&(c.insetBlockStart=`${s(i.scrollPaddingStart,i.direction)}px`),(n||r)&&(c.insetInlineStart=`${o(i.scrollPaddingStart,i.direction)}px`),c.transform=`translate(${e.stickyOffset.x}px, ${e.stickyOffset.y}px)`):c.transform=`translate(${e.offset.x}px, ${e.offset.y}px)`),c}let G=(0,t.computed)(()=>i.debug),K=(0,t.computed)(()=>i.containerTag===`table`),q=(0,t.computed)(()=>K.value?`thead`:`div`),J=(0,t.computed)(()=>K.value?`tfoot`:`div`);return n({scrollDetails:S,columnRange:b,getColumnWidth:T,scrollToIndex:E,scrollToOffset:D,refresh:M,stopProgrammaticScroll:j}),(n,r)=>((0,t.openBlock)(),(0,t.createBlock)((0,t.resolveDynamicComponent)(e.containerTag),{ref_key:`hostRef`,ref:d,class:(0,t.normalizeClass)([`virtual-scroll-container`,[`virtual-scroll--${e.direction}`,{"virtual-scroll--hydrated":(0,t.unref)(y),"virtual-scroll--window":z.value,"virtual-scroll--table":K.value}]]),style:(0,t.normalizeStyle)(B.value),tabindex:`0`,onKeydown:R,onWheelPassive:(0,t.unref)(j),onPointerdownPassive:(0,t.unref)(j),onTouchstartPassive:(0,t.unref)(j)},{default:(0,t.withCtx)(()=>[u.header?((0,t.openBlock)(),(0,t.createBlock)((0,t.resolveDynamicComponent)(q.value),{key:0,ref_key:`headerRef`,ref:p,class:(0,t.normalizeClass)([`virtual-scroll-header`,{"virtual-scroll--sticky":e.stickyHeader}])},{default:(0,t.withCtx)(()=>[(0,t.renderSlot)(n.$slots,`header`,{},void 0,!0)]),_:3},8,[`class`])):(0,t.createCommentVNode)(``,!0),((0,t.openBlock)(),(0,t.createBlock)((0,t.resolveDynamicComponent)(e.wrapperTag),{ref_key:`wrapperRef`,ref:f,class:`virtual-scroll-wrapper`,style:(0,t.normalizeStyle)(V.value)},{default:(0,t.withCtx)(()=>[K.value?((0,t.openBlock)(),(0,t.createBlock)((0,t.resolveDynamicComponent)(e.itemTag),{key:0,class:`virtual-scroll-spacer`,style:(0,t.normalizeStyle)(U.value)},{default:(0,t.withCtx)(()=>[...r[0]||=[(0,t.createElementVNode)(`td`,{style:{padding:`0`,border:`none`,"block-size":`inherit`}},null,-1)]]),_:1},8,[`style`])):(0,t.createCommentVNode)(``,!0),((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)((0,t.unref)(x),r=>((0,t.openBlock)(),(0,t.createBlock)((0,t.resolveDynamicComponent)(e.itemTag),{key:r.index,ref_for:!0,ref:e=>L(e,r.index),"data-index":r.index,class:(0,t.normalizeClass)([`virtual-scroll-item`,{"virtual-scroll--sticky":r.isStickyActive,"virtual-scroll--debug":G.value}]),style:(0,t.normalizeStyle)(W(r))},{default:(0,t.withCtx)(()=>[(0,t.renderSlot)(n.$slots,`item`,{item:r.item,index:r.index,columnRange:(0,t.unref)(b),getColumnWidth:(0,t.unref)(T),isSticky:r.isSticky,isStickyActive:r.isStickyActive},void 0,!0),G.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,l,` #`+(0,t.toDisplayString)(r.index)+` (`+(0,t.toDisplayString)(Math.round(r.offset.x))+`, `+(0,t.toDisplayString)(Math.round(r.offset.y))+`) `,1)):(0,t.createCommentVNode)(``,!0)]),_:2},1032,[`data-index`,`class`,`style`]))),128))]),_:3},8,[`style`])),e.loading&&u.loading?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:1,class:`virtual-scroll-loading`,style:(0,t.normalizeStyle)(H.value)},[(0,t.renderSlot)(n.$slots,`loading`,{},void 0,!0)],4)):(0,t.createCommentVNode)(``,!0),u.footer?((0,t.openBlock)(),(0,t.createBlock)((0,t.resolveDynamicComponent)(J.value),{key:2,ref_key:`footerRef`,ref:m,class:(0,t.normalizeClass)([`virtual-scroll-footer`,{"virtual-scroll--sticky":e.stickyFooter}])},{default:(0,t.withCtx)(()=>[(0,t.renderSlot)(n.$slots,`footer`,{},void 0,!0)]),_:3},8,[`class`])):(0,t.createCommentVNode)(``,!0)]),_:3},40,[`class`,`style`,`onWheelPassive`,`onPointerdownPassive`,`onTouchstartPassive`]))}}),[[`__scopeId`,`data-v-d61a0f1d`]]);e.DEFAULT_BUFFER=5,e.DEFAULT_COLUMN_WIDTH=100,e.DEFAULT_ITEM_SIZE=40,e.FenwickTree=n,e.VirtualScroll=u,e.getPaddingX=o,e.getPaddingY=s,e.isElement=r,e.isScrollToIndexOptions=a,e.isScrollableElement=i,e.useVirtualScroll=c});
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
(function(B,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(B=typeof globalThis<"u"?globalThis:B||self,t(B.VirtualScroll={},B.Vue))})(this,(function(B,t){"use strict";class St{tree;values;constructor(e){this.tree=new Float64Array(e+1),this.values=new Float64Array(e)}update(e,r){if(!(e<0||e>=this.values.length))for(this.values[e]=this.values[e]+r,e++;e<this.tree.length;)this.tree[e]=this.tree[e]+r,e+=e&-e}query(e){let r=0;for(;e>0;)r+=this.tree[e]||0,e-=e&-e;return r}set(e,r){e<0||e>=this.values.length||(this.values[e]=r)}get length(){return this.values.length}get(e){return this.values[e]||0}getValues(){return this.values}findLowerBound(e){let r=0;const l=this.tree.length;let s=1<<Math.floor(Math.log2(l-1));for(;s>0;){const f=r+s;if(f<l){const S=this.tree[f]||0;S<=e&&(r=f,e-=S)}s>>=1}return r}rebuild(){this.tree.fill(0);for(let e=0;e<this.values.length;e++)this.tree[e+1]=this.values[e]||0;for(let e=1;e<this.tree.length;e++){const r=e+(e&-e);r<this.tree.length&&(this.tree[r]=this.tree[r]+this.tree[e])}}resize(e){if(e===this.values.length)return;const r=new Float64Array(e);r.set(this.values.subarray(0,Math.min(e,this.values.length))),this.values=r,this.tree=new Float64Array(e+1),this.rebuild()}shift(e){if(e===0)return;const r=this.values.length,l=new Float64Array(r);e>0?l.set(this.values.subarray(0,Math.min(r-e,this.values.length)),e):l.set(this.values.subarray(-e)),this.values=l,this.rebuild()}}const et=1e7;function Lt(n){return n===null||n===document.documentElement||typeof window<"u"&&n===window}function Gt(n){return n!=null&&typeof n=="object"&&"tagName"in n&&n.tagName==="BODY"}function $t(n){return Lt(n)||Gt(n)}function wt(n){return n!=null&&"getBoundingClientRect"in n}function bt(n){return n!=null&&"scrollLeft"in n}function tt(n){return typeof n=="object"&&n!=null&&("align"in n||"behavior"in n||"isCorrection"in n)}function Ne(n,e){return typeof n=="object"&&n!==null?n.x||0:(e==="horizontal"||e==="both")&&n||0}function Ue(n,e){return typeof n=="object"&&n!==null?n.y||0:(e==="vertical"||e==="both")&&n||0}function Ft({scrollPos:n,containerSize:e,count:r,bufferBefore:l,bufferAfter:s,gap:f,fixedSize:S,findLowerBound:b,query:g}){let x=0,h=r;const T=n+e;if(S!==null){const w=S+f;x=Math.floor(n/w),h=Math.ceil(T/w)}else x=b(n),h=b(T),h<r&&g(h)<T&&h++;return{start:Math.max(0,x-l),end:Math.min(r,h+s)}}function Nt(n,e){let r=0,l=n.length-1,s;for(;r<=l;){const f=r+l>>>1;n[f]>e?(s=n[f],l=f-1):r=f+1}return s}function Yt(n,e){let r=0,l=n.length-1,s;for(;r<=l;){const f=r+l>>>1;n[f]<e?(s=n[f],r=f+1):l=f-1}return s}function il({align:n,targetPos:e,itemSize:r,scrollPos:l,viewSize:s,stickyOffsetStart:f,stickyOffsetEnd:S}){const b=e-f,g=e-(s-S-r);if(n==="start")return{target:b,effectiveAlign:"start"};if(n==="center")return{target:e-f-(s-f-S-r)/2,effectiveAlign:"center"};if(n==="end")return{target:g,effectiveAlign:"end"};if(_t(e,r,l,s,f,S))return{target:l,effectiveAlign:"auto"};const x=s-f-S;return r<=x?e<l+f?{target:b,effectiveAlign:"start"}:{target:g,effectiveAlign:"end"}:Math.abs(b-l)<Math.abs(g-l)?{target:b,effectiveAlign:"start"}:{target:g,effectiveAlign:"end"}}function ct(n,e,r,l){return n<=0?0:e!==null?Math.max(0,n*(e+r)-r):Math.max(0,l(n)-r)}function Ut({index:n,align:e,viewSize:r,scrollPos:l,fixedSize:s,gap:f,query:S,getSize:b,stickyIndices:g,stickyStart:x,stickyEnd:h=0}){let T=x;if(g&&g.length>0){const Y=Yt(g,n);Y!==void 0&&(T+=ct(1,s,0,()=>b(Y)))}const w=s!==null?n*(s+f):S(n),D=s!==null?s:b(n)-f,{target:R,effectiveAlign:C}=il({align:e,targetPos:w,itemSize:D,scrollPos:l,viewSize:r,stickyOffsetStart:T,stickyOffsetEnd:h});return{target:R,itemSize:D,effectiveAlign:C}}function _t(n,e,r,l,s=0,f=0){const S=r+s,b=r+l-f,g=l-s-f;return e<=g?n>=S-.5&&n+e<=b+.5:n<=S+.5&&n+e>=b-.5}function Qe(n,e,r){return(n-e)*r}function dt(n,e,r){return n/r+e}function Ot({rowIndex:n,colIndex:e,options:r,direction:l,viewportWidth:s,viewportHeight:f,totalWidth:S,totalHeight:b,gap:g,columnGap:x,fixedSize:h,fixedWidth:T,relativeScrollX:w,relativeScrollY:D,getItemSizeY:R,getItemSizeX:C,getItemQueryY:Y,getItemQueryX:F,getColumnSize:G,getColumnQuery:M,scaleX:E,scaleY:V,hostOffsetX:P,hostOffsetY:z,stickyIndices:W,stickyStartX:H=0,stickyStartY:K=0,stickyEndX:Z=0,stickyEndY:J=0,flowPaddingStartX:X=0,flowPaddingStartY:re=0,paddingStartX:fe=0,paddingStartY:$=0,paddingEndX:le=0,paddingEndY:Be=0}){let ue;tt(r)?ue=r.align:ue=r;const ht=(ue&&typeof ue=="object"?ue.x:ue)||"auto",te=(ue&&typeof ue=="object"?ue.y:ue)||"auto";let ke=w,ce=D,De=0,ae=0,Xe="auto",ie="auto";const Pe=E===1?S:et,ve=V===1?b:et,_e=Math.max(0,P+Pe-s),pe=Math.max(0,z+ve-f),we=(_e-P)*E,ye=(pe-z)*V,He=X+H+fe,lt=re+K+$;if(n!=null){const ne=Ut({index:n,align:te,viewSize:f,scrollPos:D,fixedSize:h,gap:g,query:Y,getSize:R,stickyIndices:W,stickyStart:K+$,stickyEnd:J+Be});ce=ne.target+lt,ae=ne.itemSize,ie=ne.effectiveAlign}if(e!=null){const ne=l==="both",Me=Ut({index:e,align:ht,viewSize:s,scrollPos:w,fixedSize:ne?T:h,gap:ne||l==="horizontal"?x:g,query:ne?M:F,getSize:ne?G:C,stickyIndices:W,stickyStart:H+fe,stickyEnd:Z+le});ke=Me.target+He,De=Me.itemSize,Xe=Me.effectiveAlign}return ke=Math.max(0,Math.min(ke,we)),ce=Math.max(0,Math.min(ce,ye)),{targetX:ke,targetY:ce,itemWidth:De,itemHeight:ae,effectiveAlignX:Xe,effectiveAlignY:ie}}function jt({direction:n,relativeScrollX:e,relativeScrollY:r,usableWidth:l,usableHeight:s,itemsLength:f,bufferBefore:S,bufferAfter:b,gap:g,columnGap:x,fixedSize:h,findLowerBoundY:T,findLowerBoundX:w,queryY:D,queryX:R}){const C=n==="vertical"||n==="both";return Ft({scrollPos:C?r:e,containerSize:C?s:l,count:f,bufferBefore:S,bufferAfter:b,gap:C?g:x,fixedSize:h,findLowerBound:C?T:w,query:C?D:R})}function Qt({columnCount:n,relativeScrollX:e,usableWidth:r,colBuffer:l,fixedWidth:s,columnGap:f,findLowerBound:S,query:b,totalColsQuery:g}){if(!n)return{start:0,end:0,padStart:0,padEnd:0};const{start:x,end:h}=Ft({scrollPos:e,containerSize:r,count:n,bufferBefore:l,bufferAfter:l,gap:f,fixedSize:s,findLowerBound:S,query:b}),T=x,w=h,D=s!==null?T*(s+f):b(T),R=s!==null?n*(s+f)-f:Math.max(0,g()-f),C=s!==null?w*(s+f)-(w>0?f:0):b(w)-(w>0?f:0);return{start:T,end:w,padStart:D,padEnd:Math.max(0,R-C)}}function Zt({index:n,isSticky:e,direction:r,relativeScrollX:l,relativeScrollY:s,originalX:f,originalY:S,width:b,height:g,stickyIndices:x,fixedSize:h,fixedWidth:T,gap:w,columnGap:D,getItemQueryY:R,getItemQueryX:C}){let Y=!1;const F={x:0,y:0};if(!e)return{isStickyActive:Y,stickyOffset:F};if((r==="vertical"||r==="both")&&s>S){const G=Nt(x,n);if(G!==void 0){const M=h!==null?G*(h+w):R(G);s>=M?Y=!1:(Y=!0,F.y=Math.max(0,Math.min(g,M-s))-g)}else Y=!0}if((r==="horizontal"||r==="both"&&!Y)&&l>f){const G=Nt(x,n);if(G!==void 0){const M=r==="horizontal"?h!==null?G*(h+D):C(G):T!==null?G*(T+D):C(G);l>=M?Y=!1:(Y=!0,F.x=Math.max(0,Math.min(b,M-l))-b)}else Y=!0}return{isStickyActive:Y,stickyOffset:F}}function Kt({index:n,direction:e,fixedSize:r,gap:l,columnGap:s,usableWidth:f,usableHeight:S,totalWidth:b,queryY:g,queryX:x,getSizeY:h,getSizeX:T,columnRange:w}){let D=0,R=0,C=0,Y=0;return e==="horizontal"?(D=r!==null?n*(r+s):x(n),C=r!==null?r:T(n)-s,Y=S):e==="both"&&w?(R=r!==null?n*(r+l):g(n),Y=r!==null?r:h(n)-l,D=w.padStart,C=Math.max(0,b-w.padStart-w.padEnd)):(R=r!==null?n*(r+l):g(n),Y=r!==null?r:h(n)-l,C=e==="both"?b:f),{height:Y,width:C,x:D,y:R}}function Jt({item:n,direction:e,itemSize:r,containerTag:l,paddingStartX:s,paddingStartY:f,isHydrated:S,isRtl:b}){const g=e==="vertical",x=e==="horizontal",h=e==="both",T=r==null||r===0,w={blockSize:x?"100%":T?"auto":`${n.size.height}px`};if(g&&l==="table"?w.minInlineSize="100%":w.inlineSize=g?"100%":T?"auto":`${n.size.width}px`,T&&(g||(w.minInlineSize="1px"),x||(w.minBlockSize="1px")),S){const D=b?-(n.isStickyActive?n.stickyOffset.x:n.offset.x):n.isStickyActive?n.stickyOffset.x:n.offset.x;n.isStickyActive?((g||h)&&(w.insetBlockStart=`${f}px`),(x||h)&&(w.insetInlineStart=`${s}px`),w.transform=`translate(${D}px, ${n.stickyOffset.y}px)`):w.transform=`translate(${D}px, ${n.offset.y}px)`}return w}function el({direction:n,itemsLength:e,columnCount:r,fixedSize:l,fixedWidth:s,gap:f,columnGap:S,usableWidth:b,usableHeight:g,queryY:x,queryX:h,queryColumn:T}){const w=n==="both",D=n==="horizontal";let R=0,C=0;return w?(R=ct(r,s,S,T),C=ct(e,l,f,x)):D?(R=ct(e,l,S,h),C=g):(R=b,C=ct(e,l,f,x)),{width:w?Math.max(R,b):R,height:w?Math.max(C,g):C}}const ft=40,vt=100,At=5;function tl(n){const e=t.computed(()=>t.toValue(n)),r=t.ref(0),l=t.ref(0),s=t.ref(!1),f=t.ref(!1),S=t.ref(!1),b=t.ref(!1),g=t.ref(!1),x=t.ref(0),h=t.ref(0),T=t.reactive({x:0,y:0}),w=t.reactive({x:0,y:0});let D;const R=t.ref(!1),C=t.ref(0),Y=t.ref(0);let F=null;const G=()=>{if(typeof window>"u")return;const a=e.value.container||e.value.hostRef||window,u=wt(a)?a:document.documentElement;(!F||!("direction"in F))&&(F=window.getComputedStyle(u));const i=F.direction==="rtl";g.value!==i&&(g.value=i)},M=new St(e.value.items?.length||0),E=new St(e.value.items?.length||0),V=new St(e.value.columnCount||0),P=t.ref(0);let z=new Uint8Array(0),W=new Uint8Array(0),H=new Uint8Array(0);const K=t.ref(null),Z=t.ref(!1);let J=[];const X=t.computed(()=>["vertical","horizontal","both"].includes(e.value.direction)?e.value.direction:"vertical"),re=t.computed(()=>e.value.itemSize===void 0||e.value.itemSize===null||e.value.itemSize===0),fe=t.computed(()=>e.value.columnWidth===void 0||e.value.columnWidth===null||e.value.columnWidth===0),$=t.computed(()=>typeof e.value.itemSize=="number"&&e.value.itemSize>0?e.value.itemSize:null),le=t.computed(()=>typeof e.value.columnWidth=="number"&&e.value.columnWidth>0?e.value.columnWidth:null),Be=t.computed(()=>e.value.defaultItemSize||$.value||ft),ue=t.computed(()=>[...e.value.stickyIndices||[]].sort((a,u)=>a-u)),ht=t.computed(()=>new Set(ue.value)),te=t.computed(()=>Ne(e.value.scrollPaddingStart,e.value.direction)),ke=t.computed(()=>Ne(e.value.scrollPaddingEnd,e.value.direction)),ce=t.computed(()=>Ue(e.value.scrollPaddingStart,e.value.direction)),De=t.computed(()=>Ue(e.value.scrollPaddingEnd,e.value.direction)),ae=t.computed(()=>Ne(e.value.stickyStart,e.value.direction)),Xe=t.computed(()=>Ne(e.value.stickyEnd,e.value.direction)),ie=t.computed(()=>Ue(e.value.stickyStart,e.value.direction)),Pe=t.computed(()=>Ue(e.value.stickyEnd,e.value.direction)),ve=t.computed(()=>Ne(e.value.flowPaddingStart,e.value.direction)),_e=t.computed(()=>Ne(e.value.flowPaddingEnd,e.value.direction)),pe=t.computed(()=>Ue(e.value.flowPaddingStart,e.value.direction)),we=t.computed(()=>Ue(e.value.flowPaddingEnd,e.value.direction)),ye=t.computed(()=>x.value-(X.value!=="vertical"?ae.value+Xe.value:0)),He=t.computed(()=>h.value-(X.value!=="horizontal"?ie.value+Pe.value:0)),lt=t.computed(()=>{if(P.value,!f.value&&e.value.ssrRange&&!b.value){const{start:a=0,end:u=0,colStart:i=0,colEnd:v=0}=e.value.ssrRange,p=e.value.columnCount||0,y=e.value.gap||0,q=e.value.columnGap||0;let N=0,m=0;if(X.value==="both"){if(p>0){const I=v||p,U=V.query(I)-V.query(i);N=Math.max(0,U-(I>i?q:0))}if($.value!==null){const I=u-a;m=Math.max(0,I*($.value+y)-(I>0?y:0))}else{const I=E.query(u)-E.query(a);m=Math.max(0,I-(u>a?y:0))}}else if(X.value==="horizontal"){if($.value!==null){const I=u-a;N=Math.max(0,I*($.value+q)-(I>0?q:0))}else{const I=M.query(u)-M.query(a);N=Math.max(0,I-(u>a?q:0))}m=He.value}else if(N=ye.value,$.value!==null){const I=u-a;m=Math.max(0,I*($.value+y)-(I>0?y:0))}else{const I=E.query(u)-E.query(a);m=Math.max(0,I-(u>a?y:0))}return{width:Math.max(N,ye.value),height:Math.max(m,He.value)}}return el({direction:X.value,itemsLength:e.value.items.length,columnCount:e.value.columnCount||0,fixedSize:$.value,fixedWidth:le.value,gap:e.value.gap||0,columnGap:e.value.columnGap||0,usableWidth:ye.value,usableHeight:He.value,queryY:a=>E.query(a),queryX:a=>M.query(a),queryColumn:a=>V.query(a)})}),ne=t.computed(()=>$t(e.value.container)),Te=t.computed(()=>lt.value.width+te.value+ke.value),Me=t.computed(()=>lt.value.height+ce.value+De.value),Ve=t.computed(()=>ve.value+ae.value+Xe.value+_e.value+Te.value),be=t.computed(()=>pe.value+ie.value+Pe.value+we.value+Me.value),Se=t.reactive({x:t.computed(()=>Math.max(0,T.x-(ve.value+ae.value))),y:t.computed(()=>Math.max(0,T.y-(pe.value+ie.value)))}),at=t.computed(()=>ne.value?Ve.value:Math.min(Ve.value,et)),Ze=t.computed(()=>ne.value?be.value:Math.min(be.value,et)),mt=t.computed(()=>ne.value?Te.value:Math.max(0,at.value-(ve.value+ae.value+Xe.value+_e.value))),oe=t.computed(()=>ne.value?Me.value:Math.max(0,Ze.value-(pe.value+ie.value+Pe.value+we.value))),he=t.computed(()=>{if(ne.value||Ve.value<=et)return 1;const a=Ve.value-x.value,u=at.value-x.value;return u>0?a/u:1}),Ye=t.computed(()=>{if(ne.value||be.value<=et)return 1;const a=be.value-h.value,u=Ze.value-h.value;return u>0?a/u:1}),Ie=t.computed(()=>{if(X.value==="vertical")return 0;const a=ve.value+ae.value+te.value;return C.value-a}),Le=t.computed(()=>{if(X.value==="horizontal")return 0;const a=pe.value+ie.value+ce.value;return Y.value-a}),Vt=a=>{P.value;const u=e.value.columnGap||0,i=e.value.columnWidth;if(typeof i=="number"&&i>0)return i;if(Array.isArray(i)&&i.length>0){const p=i[a%i.length];return p!=null&&p>0?p:e.value.defaultColumnWidth||vt}if(typeof i=="function")return i(a);const v=V.get(a);return v>0?v-u:e.value.defaultColumnWidth||vt},kt=a=>{if(P.value,X.value==="horizontal")return He.value;const u=e.value.gap||0,i=e.value.itemSize;if(typeof i=="number"&&i>0)return i;if(typeof i=="function"){const p=e.value.items[a];return p!==void 0?i(p,a):e.value.defaultItemSize||ft}const v=E.get(a);return v>0?v-u:e.value.defaultItemSize||ft};function rt(a,u,i){const v=typeof i=="object"&&i!==null&&"isCorrection"in i?i.isCorrection:!1,p=e.value.container||window,{targetX:y,targetY:q,effectiveAlignX:N,effectiveAlignY:m}=Ot({rowIndex:a,colIndex:u,options:i,direction:X.value,viewportWidth:x.value,viewportHeight:h.value,totalWidth:Ve.value,totalHeight:be.value,gap:e.value.gap||0,columnGap:e.value.columnGap||0,fixedSize:$.value,fixedWidth:le.value,relativeScrollX:Ie.value,relativeScrollY:Le.value,getItemSizeY:k=>E.get(k),getItemSizeX:k=>M.get(k),getItemQueryY:k=>E.query(k),getItemQueryX:k=>M.query(k),getColumnSize:k=>V.get(k),getColumnQuery:k=>V.query(k),scaleX:he.value,scaleY:Ye.value,hostOffsetX:Se.x,hostOffsetY:Se.y,stickyIndices:ue.value,stickyStartX:ae.value,stickyStartY:ie.value,stickyEndX:Xe.value,stickyEndY:Pe.value,flowPaddingStartX:ve.value,flowPaddingStartY:pe.value,flowPaddingEndX:_e.value,flowPaddingEndY:we.value,paddingStartX:te.value,paddingStartY:ce.value,paddingEndX:ke.value,paddingEndY:De.value});if(!v){const k=tt(i)?i.behavior:void 0;K.value={rowIndex:a,colIndex:u,options:{align:{x:N,y:m},...k!=null?{behavior:k}:{}}}}const I=dt(y,Se.x,he.value),U=dt(q,Se.y,Ye.value),L=g.value?-I:I,ee=U;let Ce;tt(i)&&(Ce=i.behavior);const _=v?"auto":Ce||"smooth";if(R.value=!0,typeof window<"u"&&p===window)window.scrollTo({left:u==null?void 0:g.value?L:Math.max(0,L),top:a==null?void 0:Math.max(0,ee),behavior:_});else if(bt(p)){const k={behavior:_};u!=null&&(k.left=g.value?L:Math.max(0,L)),a!=null&&(k.top=Math.max(0,ee)),typeof p.scrollTo=="function"?p.scrollTo(k):(k.left!==void 0&&(p.scrollLeft=k.left),k.top!==void 0&&(p.scrollTop=k.top))}if((_==="auto"||_===void 0)&&(u!=null&&(r.value=g.value?L:Math.max(0,L),C.value=y),a!=null&&(l.value=Math.max(0,ee),Y.value=q),K.value)){const k=K.value.options;tt(k)?k.behavior="auto":K.value.options={align:k,behavior:"auto"}}}const je=(a,u,i)=>{const v=e.value.container||window;R.value=!0,K.value=null;const p=a!=null?Math.max(0,Math.min(a,Ve.value-x.value)):null,y=u!=null?Math.max(0,Math.min(u,be.value-h.value)):null;p!==null&&(C.value=p),y!==null&&(Y.value=y);const q=typeof window<"u"&&v===window?window.scrollX:v.scrollLeft,N=typeof window<"u"&&v===window?window.scrollY:v.scrollTop,m=p!==null?dt(p,Se.x,he.value):null,I=y!==null?dt(y,Se.y,Ye.value):null,U=m!==null?g.value?-m:m:q,L=I!==null?I:N;if(typeof window<"u"&&v===window)window.scrollTo({left:a!=null?U:void 0,top:u!=null?L:void 0,behavior:i?.behavior||"auto"});else if(bt(v)){const ee={behavior:i?.behavior||"auto"};a!=null&&(ee.left=U),u!=null&&(ee.top=L),typeof v.scrollTo=="function"?v.scrollTo(ee):(ee.left!==void 0&&(v.scrollLeft=ee.left),ee.top!==void 0&&(v.scrollTop=ee.top))}(i?.behavior==="auto"||i?.behavior===void 0)&&(a!=null&&(r.value=U),u!=null&&(l.value=L))},Wt=(a,u)=>{if(M.resize(a),E.resize(a),V.resize(u),W.length!==a){const i=new Uint8Array(a);i.set(W.subarray(0,Math.min(a,W.length))),W=i}if(H.length!==a){const i=new Uint8Array(a);i.set(H.subarray(0,Math.min(a,H.length))),H=i}if(z.length!==u){const i=new Uint8Array(u);i.set(z.subarray(0,Math.min(u,z.length))),z=i}},nt=()=>{const u=e.value.items.length,i=e.value.columnCount||0,v=e.value.gap||0,p=e.value.columnGap||0,y=e.value.columnWidth;let q=!1,N=!1;if(i>0)for(let m=0;m<i;m++){const I=V.get(m),U=z[m]===1;if(!fe.value||!U&&I===0){let L=0;typeof y=="number"&&y>0?L=y:Array.isArray(y)&&y.length>0?L=y[m%y.length]||e.value.defaultColumnWidth||vt:typeof y=="function"?L=y(m):L=e.value.defaultColumnWidth||vt;const ee=L+p;Math.abs(I-ee)>.5?(V.set(m,ee),z[m]=fe.value?0:1,q=!0):fe.value||(z[m]=1)}}for(let m=0;m<u;m++){const I=e.value.items[m],U=M.get(m),L=E.get(m),ee=W[m]===1,Ce=H[m]===1;if(X.value==="horizontal"){if(!re.value||!ee&&U===0){const k=(typeof e.value.itemSize=="function"?e.value.itemSize(I,m):Be.value)+p;Math.abs(U-k)>.5?(M.set(m,k),W[m]=re.value?0:1,N=!0):re.value||(W[m]=1)}}else U!==0&&(M.set(m,0),W[m]=0,N=!0);if(X.value!=="horizontal"){if(!re.value||!Ce&&L===0){const k=(typeof e.value.itemSize=="function"?e.value.itemSize(I,m):Be.value)+v;Math.abs(L-k)>.5?(E.set(m,k),H[m]=re.value?0:1,N=!0):re.value||(H[m]=1)}}else L!==0&&(E.set(m,0),H[m]=0,N=!0)}q&&V.rebuild(),N&&(M.rebuild(),E.rebuild())},Ke=()=>{const a=e.value.items,u=a.length,i=e.value.columnCount||0;Wt(u,i);let v=0;if(e.value.restoreScrollOnPrepend&&J.length>0&&u>J.length){const p=J[0];if(p!==void 0){for(let y=1;y<=u-J.length;y++)if(a[y]===p){v=y;break}}}if(v>0){M.shift(v),E.shift(v),K.value&&K.value.rowIndex!==null&&K.value.rowIndex!==void 0&&(K.value.rowIndex+=v);const p=new Uint8Array(u),y=new Uint8Array(u);p.set(W.subarray(0,Math.min(u-v,W.length)),v),y.set(H.subarray(0,Math.min(u-v,H.length)),v),W=p,H=y;const q=e.value.gap||0,N=e.value.columnGap||0;let m=0,I=0;for(let U=0;U<v;U++){const L=typeof e.value.itemSize=="function"?e.value.itemSize(a[U],U):Be.value;X.value==="horizontal"?m+=L+N:I+=L+q}(m>0||I>0)&&t.nextTick(()=>{je(m>0?Ie.value+m:null,I>0?Le.value+I:null,{behavior:"auto"})})}nt(),J=[...a],Z.value=!0,P.value++},We=()=>{if(typeof window>"u")return;const a=e.value.container||window,u=i=>{const v=i.getBoundingClientRect();if(a===window)return{x:g.value?document.documentElement.clientWidth-v.right-window.scrollX:v.left+window.scrollX,y:v.top+window.scrollY};if(a===i)return{x:0,y:0};if(wt(a)){const p=a.getBoundingClientRect();return{x:g.value?p.right-v.right-a.scrollLeft:v.left-p.left+a.scrollLeft,y:v.top-p.top+a.scrollTop}}return{x:0,y:0}};if(e.value.hostElement){const i=u(e.value.hostElement);(Math.abs(T.x-i.x)>.1||Math.abs(T.y-i.y)>.1)&&(T.x=i.x,T.y=i.y)}if(e.value.hostRef){const i=u(e.value.hostRef);(Math.abs(w.x-i.x)>.1||Math.abs(w.y-i.y)>.1)&&(w.x=i.x,w.y=i.y)}};t.watch([()=>e.value.items,()=>e.value.items.length,()=>e.value.direction,()=>e.value.columnCount,()=>e.value.columnWidth,()=>e.value.itemSize,()=>e.value.gap,()=>e.value.columnGap,()=>e.value.defaultItemSize,()=>e.value.defaultColumnWidth],Ke,{immediate:!0}),t.watch(()=>[e.value.container,e.value.hostElement],()=>{We()}),t.watch(g,(a,u)=>{if(u===void 0||a===u||!b.value)return;if(X.value==="vertical"){We();return}const i=u?Math.abs(r.value):r.value,v=Qe(i,T.x,he.value);We(),je(v,null,{behavior:"auto"})},{flush:"sync"}),t.watch([he,Ye],()=>{!b.value||s.value||R.value||je(C.value,Y.value,{behavior:"auto"})}),t.watch([()=>e.value.items.length,()=>e.value.columnCount],([a,u],[i,v])=>{t.nextTick(()=>{const p=Math.max(0,Ve.value-x.value),y=Math.max(0,be.value-h.value);C.value>p||Y.value>y?je(Math.min(C.value,p),Math.min(Y.value,y),{behavior:"auto"}):(a!==i&&Ye.value!==1||u!==v&&he.value!==1)&&je(C.value,Y.value,{behavior:"auto"}),We()})});const ot=a=>{const u=e.value.gap||0,i=e.value.columnGap||0,v=$.value;if(X.value==="horizontal"){const y=(v||0)+i;return v!==null&&y>0?Math.floor(a/y):M.findLowerBound(a)}const p=(v||0)+u;return v!==null&&p>0?Math.floor(a/p):E.findLowerBound(a)},gt=a=>X.value==="both"?V.findLowerBound(a):X.value==="horizontal"?ot(a):0,Pt=t.computed(()=>{if(P.value,(!f.value||S.value)&&e.value.ssrRange)return{start:e.value.ssrRange.start,end:e.value.ssrRange.end};const a=e.value.ssrRange&&!s.value?0:e.value.bufferBefore??At,u=e.value.bufferAfter??At;return jt({direction:X.value,relativeScrollX:Ie.value,relativeScrollY:Le.value,usableWidth:ye.value,usableHeight:He.value,itemsLength:e.value.items.length,bufferBefore:a,bufferAfter:u,gap:e.value.gap||0,columnGap:e.value.columnGap||0,fixedSize:$.value,findLowerBoundY:i=>E.findLowerBound(i),findLowerBoundX:i=>M.findLowerBound(i),queryY:i=>E.query(i),queryX:i=>M.query(i)})}),Mt=t.computed(()=>{P.value;const a=Ie.value+ae.value,u=Le.value+ie.value,i=X.value==="horizontal"?a:u;return ot(i)}),Je=t.computed(()=>{P.value;const a=e.value.columnCount||0;if(!a)return{start:0,end:0,padStart:0,padEnd:0};if((!f.value||S.value)&&e.value.ssrRange){const{colStart:i=0,colEnd:v=0}=e.value.ssrRange,p=Math.max(0,i),y=Math.min(a,v||a),q=e.value.columnGap||0,N=le.value!==null?p*(le.value+q):V.query(p),m=le.value!==null?a*(le.value+q)-q:Math.max(0,V.query(a)-q),I=le.value!==null?y*(le.value+q)-(y>0?q:0):V.query(y)-(y>0?q:0);return{start:p,end:y,padStart:N,padEnd:Math.max(0,m-I)}}const u=e.value.ssrRange&&!s.value?0:2;return Qt({columnCount:a,relativeScrollX:Ie.value,usableWidth:ye.value,colBuffer:u,fixedWidth:le.value,columnGap:e.value.columnGap||0,findLowerBound:i=>V.findLowerBound(i),query:i=>V.query(i),totalColsQuery:()=>V.query(a)})});let It=[];const Ct=t.computed(()=>{P.value;const{start:a,end:u}=Pt.value,i=[],v=$.value,p=e.value.gap||0,y=e.value.columnGap||0,q=ue.value,N=ht.value,m=[];if(f.value||!e.value.ssrRange){const Q=Mt.value,Fe=Yt(q,Q);Fe!==void 0&&Fe<a&&m.push(Fe)}for(let Q=a;Q<u;Q++)m.push(Q);const I=e.value.ssrRange?.start||0,U=e.value.ssrRange?.colStart||0;let L=0,ee=0;!f.value&&e.value.ssrRange&&(ee=X.value!=="horizontal"?v!==null?I*(v+p):E.query(I):0,X.value==="horizontal"?L=v!==null?U*(v+y):M.query(U):X.value==="both"&&(L=V.query(U)));const Ce=new Map(It.map(Q=>[Q.index,Q]));let _=-1,k=0,Ae=-1,Re=0;const pt=Q=>Q===_+1?(k+=M.get(_),_=Q,k):(k=M.query(Q),_=Q,k),ge=Q=>Q===Ae+1?(Re+=E.get(Ae),Ae=Q,Re):(Re=E.query(Q),Ae=Q,Re),$e=ve.value+ae.value+te.value,se=pe.value+ie.value+ce.value,Ee=ve.value+ae.value,xe=pe.value+ie.value,st=Je.value;for(const Q of m){const Fe=e.value.items[Q];if(Fe===void 0)continue;const{x:Rt,y:yt,width:qt,height:Dt}=Kt({index:Q,direction:X.value,fixedSize:$.value,gap:e.value.gap||0,columnGap:e.value.columnGap||0,usableWidth:ye.value,usableHeight:He.value,totalWidth:lt.value.width,queryY:ge,queryX:pt,getSizeY:it=>E.get(it),getSizeX:it=>M.get(it),columnRange:st}),Ht=N.has(Q),Et=Rt,Xt=yt,{isStickyActive:al,stickyOffset:Tt}=Zt({index:Q,isSticky:Ht,direction:X.value,relativeScrollX:Ie.value,relativeScrollY:Le.value,originalX:Et,originalY:Xt,width:qt,height:Dt,stickyIndices:q,fixedSize:$.value,fixedWidth:le.value,gap:e.value.gap||0,columnGap:e.value.columnGap||0,getItemQueryY:it=>E.query(it),getItemQueryX:it=>M.query(it)}),nl=f.value?C.value/he.value+(Et+$e-C.value)-Ee:Et-L,ol=f.value?Y.value/Ye.value+(Xt+se-Y.value)-xe:Xt-ee,qe=Ce.get(Q);qe&&qe.item===Fe&&qe.offset.x===nl&&qe.offset.y===ol&&qe.size.width===qt&&qe.size.height===Dt&&qe.isSticky===Ht&&qe.isStickyActive===al&&qe.stickyOffset.x===Tt.x&&qe.stickyOffset.y===Tt.y?i.push(qe):i.push({item:Fe,index:Q,offset:{x:nl,y:ol},size:{width:qt,height:Dt},originalX:Et,originalY:Xt,isSticky:Ht,isStickyActive:al,stickyOffset:{x:Tt.x,y:Tt.y}})}return It=i,i}),o=t.computed(()=>{P.value;const a=Ie.value+ae.value,u=Le.value+ie.value,i=Ie.value+(x.value-Xe.value)-1,v=Le.value+(h.value-Pe.value)-1,p=gt(a),y=ot(u),q=ot(X.value==="horizontal"?i:v),N=gt(i);return{items:Ct.value,currentIndex:y,currentColIndex:p,currentEndIndex:q,currentEndColIndex:N,scrollOffset:{x:C.value,y:Y.value},displayScrollOffset:{x:g.value?Math.abs(r.value+w.x):Math.max(0,r.value-w.x),y:Math.max(0,l.value-w.y)},viewportSize:{width:x.value,height:h.value},displayViewportSize:{width:x.value,height:h.value},totalSize:{width:Ve.value,height:be.value},isScrolling:s.value,isProgrammaticScroll:R.value,range:Pt.value,columnRange:Je.value}}),d=()=>{R.value=!1,K.value=null},c=a=>{const u=a.target;if(typeof window>"u")return;G(),u===window||u===document?(r.value=window.scrollX,l.value=window.scrollY,x.value=document.documentElement.clientWidth,h.value=document.documentElement.clientHeight):bt(u)&&(r.value=u.scrollLeft,l.value=u.scrollTop,x.value=u.clientWidth,h.value=u.clientHeight);const i=g.value?Math.abs(r.value):r.value;C.value=Qe(i,Se.x,he.value),Y.value=Qe(l.value,Se.y,Ye.value),s.value||(R.value||(K.value=null),s.value=!0),clearTimeout(D),D=setTimeout(()=>{s.value=!1,R.value=!1},250)},A=a=>{let u=!1,i=0,v=0;const p=e.value.gap||0,y=e.value.columnGap||0,q=Ie.value,N=Le.value,m=ot(X.value==="horizontal"?q:N),I=gt(q),U=X.value==="horizontal",L=X.value==="both",ee=new Set,Ce=new Set;for(const{index:_,inlineSize:k,blockSize:Ae,element:Re}of a){if(k<=0&&Ae<=0)continue;const pt=re.value||typeof e.value.itemSize=="function";if(_>=0&&!ee.has(_)&&pt&&Ae>0){if(ee.add(_),U&&k>0){const $e=M.get(_),se=k+y;if(!W[_]||Math.abs(se-$e)>.1){const Ee=se-$e;M.update(_,Ee),W[_]=1,u=!0,_<m&&(i+=Ee)}}if(!U){const $e=E.get(_),se=Ae+p;if(!H[_]||Math.abs(se-$e)>.1){const Ee=se-$e;E.update(_,Ee),H[_]=1,u=!0,_<m&&(v+=Ee)}}}const ge=fe.value||typeof e.value.columnWidth=="function";if(L&&Re&&e.value.columnCount&&ge&&(k>0||Re.dataset.colIndex===void 0)){const $e=Re.dataset.colIndex;if($e!=null){const se=Number.parseInt($e,10);if(se>=0&&se<(e.value.columnCount||0)&&!Ce.has(se)){Ce.add(se);const Ee=V.get(se),xe=k+y;if(!z[se]||Math.abs(Ee-xe)>.1){const st=xe-Ee;Math.abs(st)>.1&&(V.update(se,st),u=!0,se<I&&(i+=st)),z[se]=1}}}else{const se=Re.dataset.colIndex!==void 0?[Re]:Array.from(Re.querySelectorAll("[data-col-index]"));for(const Ee of se){const xe=Number.parseInt(Ee.dataset.colIndex,10);if(xe>=0&&xe<(e.value.columnCount||0)&&!Ce.has(xe)){Ce.add(xe);const Q=Ee.getBoundingClientRect().width,Fe=V.get(xe),Rt=Q+y;if(!z[xe]||Math.abs(Fe-Rt)>.1){const yt=Rt-Fe;Math.abs(yt)>.1&&(V.update(xe,yt),u=!0,xe<I&&(i+=yt)),z[xe]=1}}}}}}if(u&&(P.value++,!(K.value!==null||R.value)&&(i!==0||v!==0))){const k=ve.value+ae.value+te.value,Ae=pe.value+ie.value+ce.value;je(i!==0?q+i+k:null,v!==0?N+v+Ae:null,{behavior:"auto"})}},de=(a,u,i,v)=>{A([{index:a,inlineSize:u,blockSize:i,element:v}])};function Oe(){if(K.value&&!S.value){const{rowIndex:a,colIndex:u,options:i}=K.value;if(tt(i)&&i.behavior==="smooth"&&s.value)return;const p=e.value.container||window,y=typeof window<"u"&&p===window?window.scrollX:p.scrollLeft,q=typeof window<"u"&&p===window?window.scrollY:p.scrollTop,N=g.value?Math.abs(y):y,m=q,I=Qe(N,0,he.value),U=Qe(m,0,Ye.value),{targetX:L,targetY:ee}=Ot({rowIndex:a,colIndex:u,options:i,direction:X.value,viewportWidth:x.value,viewportHeight:h.value,totalWidth:Te.value,totalHeight:Me.value,gap:e.value.gap||0,columnGap:e.value.columnGap||0,fixedSize:$.value,fixedWidth:le.value,relativeScrollX:I,relativeScrollY:U,getItemSizeY:ge=>E.get(ge),getItemSizeX:ge=>M.get(ge),getItemQueryY:ge=>E.query(ge),getItemQueryX:ge=>M.query(ge),getColumnSize:ge=>V.get(ge),getColumnQuery:ge=>V.query(ge),scaleX:he.value,scaleY:Ye.value,hostOffsetX:Se.x,hostOffsetY:Se.y,stickyIndices:ue.value,stickyStartX:ae.value,stickyStartY:ie.value,stickyEndX:Xe.value,stickyEndY:Pe.value,flowPaddingStartX:ve.value,flowPaddingStartY:pe.value,flowPaddingEndX:_e.value,flowPaddingEndY:we.value,paddingStartX:te.value,paddingStartY:ce.value,paddingEndX:ke.value,paddingEndY:De.value}),Ce=2,_=2,k=u==null||Math.abs(I-L)<Ce,Ae=a==null||Math.abs(U-ee)<_,Re=u==null||u===void 0||z[u]===1,pt=a==null||a===void 0||H[a]===1;if(k&&Ae)Re&&pt&&!s.value&&!R.value&&(K.value=null);else{const ge=tt(i)?{...i,isCorrection:!0}:{align:i,isCorrection:!0};rt(a,u,ge)}}}t.watch([P,x,h],Oe),t.watch(s,a=>{a||Oe()});let ze=null,O=null,j;const me=a=>{if(!a||typeof window>"u")return;const u=a===window?document:a;if(u.addEventListener("scroll",c,{passive:!0}),F=null,G(),wt(a)&&(O=new MutationObserver(()=>G()),O.observe(a,{attributes:!0,attributeFilter:["dir","style"]})),j=setInterval(G,1e3),a===window){x.value=document.documentElement.clientWidth,h.value=document.documentElement.clientHeight,r.value=window.scrollX,l.value=window.scrollY;const i=()=>{G(),x.value=document.documentElement.clientWidth,h.value=document.documentElement.clientHeight,We()};return window.addEventListener("resize",i),()=>{u.removeEventListener("scroll",c),window.removeEventListener("resize",i),clearInterval(j),F=null}}else return x.value=a.clientWidth,h.value=a.clientHeight,r.value=a.scrollLeft,l.value=a.scrollTop,ze=new ResizeObserver(i=>{G();for(const v of i)v.target===a&&(x.value=a.clientWidth,h.value=a.clientHeight,We())}),ze.observe(a),()=>{u.removeEventListener("scroll",c),ze?.disconnect(),O?.disconnect(),clearInterval(j),F=null}};let Ge;return t.getCurrentInstance()&&(t.onMounted(()=>{b.value=!0,G(),t.watch(()=>e.value.container,a=>{Ge?.(),Ge=me(a||null)},{immediate:!0}),We(),t.nextTick(()=>{if(We(),e.value.ssrRange||e.value.initialScrollIndex!==void 0){const a=e.value.initialScrollIndex!==void 0?e.value.initialScrollIndex:e.value.ssrRange?.start,u=e.value.initialScrollAlign||"start";a!=null&&rt(a,e.value.ssrRange?.colStart,{align:u,behavior:"auto"}),f.value=!0,S.value=!0,t.nextTick(()=>{S.value=!1})}else f.value=!0})}),t.onUnmounted(()=>{Ge?.()})),{renderedItems:Ct,totalWidth:Ve,totalHeight:be,renderedWidth:at,renderedHeight:Ze,scrollDetails:o,getRowHeight:kt,getColumnWidth:Vt,getRowOffset:a=>pe.value+ie.value+ce.value+E.query(a),getColumnOffset:a=>ve.value+ae.value+te.value+V.query(a),getItemOffset:a=>X.value==="horizontal"?ve.value+ae.value+te.value+M.query(a):pe.value+ie.value+ce.value+E.query(a),getItemSize:a=>{if(X.value==="horizontal")return Math.max(0,M.get(a)-(e.value.columnGap||0));const u=e.value.itemSize;if(typeof u=="number"&&u>0)return u;if(typeof u=="function"){const i=e.value.items[a];return i!==void 0?u(i,a):e.value.defaultItemSize||ft}return Math.max(0,E.get(a)-(e.value.gap||0))},scrollToIndex:rt,scrollToOffset:je,stopProgrammaticScroll:d,updateItemSize:de,updateItemSizes:A,updateHostOffset:We,updateDirection:G,columnRange:Je,refresh:()=>{M.resize(0),E.resize(0),V.resize(0),z.fill(0),W.fill(0),H.fill(0),Ke()},isHydrated:f,isWindowContainer:ne,isRtl:g,scaleX:he,scaleY:Ye,componentOffset:Se,renderedVirtualWidth:mt,renderedVirtualHeight:oe}}function zt(n){const e=t.computed(()=>t.toValue(n.axis)),r=t.computed(()=>t.toValue(n.totalSize)),l=t.computed(()=>t.toValue(n.position)),s=t.computed(()=>t.toValue(n.viewportSize)),f=t.computed(()=>t.toValue(n.containerId)),S=t.computed(()=>!!t.toValue(n.isRtl)),b=t.computed(()=>e.value==="horizontal"),g=t.computed(()=>r.value<=0?0:Math.min(1,s.value/r.value)),x=t.computed(()=>{const z=r.value-s.value;return z<=0?0:Math.max(0,Math.min(1,l.value/z))}),h=t.computed(()=>{const W=s.value>0?32/s.value:.1;return Math.max(Math.min(W,.1),g.value)*100}),T=t.computed(()=>x.value*(100-h.value)),w=t.computed(()=>b.value?{inlineSize:`${h.value}%`,insetInlineStart:`${T.value}%`}:{blockSize:`${h.value}%`,insetBlockStart:`${T.value}%`}),D=t.computed(()=>{const z=s.value,W="var(--vs-scrollbar-has-cross-gap, var(--vsi-scrollbar-has-cross-gap, 0)) * var(--vs-scrollbar-cross-gap, var(--vsi-scrollbar-size, 8px))";return b.value?{inlineSize:`calc(${Math.max(0,z-4)}px - ${W})`}:{blockSize:`calc(${Math.max(0,z-4)}px - ${W})`}}),R=t.ref(!1);let C=0,Y=0;function F(z){const W=z.currentTarget;if(z.target!==W)return;const H=W.getBoundingClientRect(),K=b.value?H.width:H.height;let Z=0;b.value?Z=S.value?H.right-z.clientX:z.clientX-H.left:Z=z.clientY-H.top;const J=h.value/100*K,X=(Z-J/2)/(K-J),re=r.value-s.value;let fe=X*re;fe>re-1&&(fe=re),n.scrollToOffset(Math.max(0,Math.min(re,fe)))}function G(z){R.value=!0,C=b.value?S.value?-z.clientX:z.clientX:z.clientY,Y=l.value,z.currentTarget.setPointerCapture(z.pointerId),z.preventDefault(),z.stopPropagation()}function M(z){if(!R.value)return;const H=z.currentTarget.parentElement;if(!H)return;const Z=(b.value?S.value?-z.clientX:z.clientX:z.clientY)-C,J=H.getBoundingClientRect(),X=b.value?J.width:J.height,re=h.value/100*X,fe=X-re;if(fe<=0)return;const $=r.value-s.value;let le=Y+Z/fe*$;le>$-1&&(le=$),n.scrollToOffset(Math.max(0,Math.min($,le)))}function E(z){R.value&&(R.value=!1,z.currentTarget.releasePointerCapture(z.pointerId))}t.getCurrentInstance()&&t.onUnmounted(()=>{R.value=!1});const V=t.computed(()=>({class:["virtual-scrollbar-track",`virtual-scrollbar-track--${b.value?"horizontal":"vertical"}`],style:D.value,role:"scrollbar","aria-orientation":e.value,"aria-valuenow":Math.round(l.value),"aria-valuemin":0,"aria-valuemax":Math.round(r.value-s.value),"aria-controls":f.value,tabindex:-1,onMousedown:F})),P=t.computed(()=>({class:["virtual-scrollbar-thumb",`virtual-scrollbar-thumb--${b.value?"horizontal":"vertical"}`,{"virtual-scrollbar-thumb--active":R.value}],style:w.value,onPointerdown:G,onPointermove:M,onPointerup:E,onPointercancel:E}));return{viewportPercent:g,positionPercent:x,thumbSizePercent:h,thumbPositionPercent:T,trackStyle:D,thumbStyle:w,trackProps:V,thumbProps:P,isDragging:R}}const Bt=t.defineComponent({__name:"VirtualScrollbar",props:{axis:{default:"vertical"},totalSize:{},position:{},viewportSize:{},scrollToOffset:{},containerId:{},isRtl:{type:Boolean,default:!1}},emits:["scrollToOffset"],setup(n,{emit:e}){const r=n,l=e,{trackProps:s,thumbProps:f}=zt({axis:()=>r.axis,totalSize:()=>r.totalSize,position:()=>r.position,viewportSize:()=>r.viewportSize,containerId:()=>r.containerId,isRtl:()=>r.isRtl,scrollToOffset:S=>{r.scrollToOffset?.(S),l("scrollToOffset",S)}});return(S,b)=>(t.openBlock(),t.createElementBlock("div",t.normalizeProps(t.guardReactiveProps(t.unref(s))),[t.createElementVNode("div",t.normalizeProps(t.guardReactiveProps(t.unref(f))),null,16)],16))}}),rl={key:0,class:"virtual-scroll-scrollbar-container"},ul={key:0,class:"virtual-scroll-debug-info"},ll=.95,xt=.1,sl=((n,e)=>{const r=n.__vccOpts||n;for(const[l,s]of e)r[l]=s;return r})(t.defineComponent({__name:"VirtualScroll",props:{items:{},itemSize:{},direction:{default:"vertical"},bufferBefore:{default:5},bufferAfter:{default:5},container:{},ssrRange:{},columnCount:{default:0},columnWidth:{},containerTag:{default:"div"},wrapperTag:{default:"div"},itemTag:{default:"div"},scrollPaddingStart:{default:0},scrollPaddingEnd:{default:0},stickyHeader:{type:Boolean,default:!1},stickyFooter:{type:Boolean,default:!1},gap:{default:0},columnGap:{default:0},stickyIndices:{default:()=>[]},loadDistance:{default:200},loading:{type:Boolean,default:!1},restoreScrollOnPrepend:{type:Boolean,default:!1},initialScrollIndex:{},initialScrollAlign:{},defaultItemSize:{},defaultColumnWidth:{},debug:{type:Boolean,default:!1},virtualScrollbar:{type:Boolean,default:!1}},emits:["scroll","load","visibleRangeChange"],setup(n,{expose:e,emit:r}){const l=n,s=r,f=t.useSlots(),S=t.ref(null),b=t.ref(null),g=t.ref(null),x=t.ref(null),h=new Map,T=t.useId(),w=t.computed(()=>`vs-container-${T}`),D=t.ref(0),R=t.ref(0),C=t.computed(()=>l.container===void 0?S.value:l.container),Y=t.computed(()=>{const o=C.value;return o===S.value||typeof window<"u"&&(o===window||o===null)}),F=t.computed(()=>(l.items.length,{items:l.items,itemSize:l.itemSize,direction:l.direction,bufferBefore:l.bufferBefore,bufferAfter:l.bufferAfter,container:C.value,hostElement:b.value,hostRef:S.value,ssrRange:l.ssrRange,columnCount:l.columnCount,columnWidth:l.columnWidth,scrollPaddingStart:{x:Ne(l.scrollPaddingStart,l.direction),y:Ue(l.scrollPaddingStart,l.direction)},scrollPaddingEnd:{x:Ne(l.scrollPaddingEnd,l.direction),y:Ue(l.scrollPaddingEnd,l.direction)},flowPaddingStart:{x:0,y:l.stickyHeader?0:D.value},flowPaddingEnd:{x:0,y:l.stickyFooter?0:R.value},stickyStart:{x:0,y:l.stickyHeader&&Y.value?D.value:0},stickyEnd:{x:0,y:l.stickyFooter&&Y.value?R.value:0},gap:l.gap,columnGap:l.columnGap,stickyIndices:l.stickyIndices,loadDistance:l.loadDistance,loading:l.loading,restoreScrollOnPrepend:l.restoreScrollOnPrepend,initialScrollIndex:l.initialScrollIndex,initialScrollAlign:l.initialScrollAlign,defaultItemSize:l.defaultItemSize,defaultColumnWidth:l.defaultColumnWidth,debug:l.debug})),{isHydrated:G,isRtl:M,columnRange:E,renderedItems:V,scrollDetails:P,renderedHeight:z,renderedWidth:W,getColumnWidth:H,getRowHeight:K,scrollToIndex:Z,scrollToOffset:J,updateHostOffset:X,updateItemSizes:re,updateDirection:fe,getItemOffset:$,getRowOffset:le,getColumnOffset:Be,getItemSize:ue,refresh:ht,stopProgrammaticScroll:te,scaleX:ke,scaleY:ce,isWindowContainer:De,componentOffset:ae,renderedVirtualWidth:Xe,renderedVirtualHeight:ie}=tl(F),Pe=t.computed(()=>ke.value!==1||ce.value!==1),ve=t.computed(()=>De.value?!1:l.virtualScrollbar===!0||ke.value!==1||ce.value!==1);function _e(o){const{displayViewportSize:d}=P.value,c=z.value-d.height;if(o>=c-.5)J(null,Number.POSITIVE_INFINITY);else{const A=Qe(o,ae.y,ce.value);J(null,A)}}function pe(o){const{displayViewportSize:d}=P.value,c=W.value-d.width;if(o>=c-.5)J(Number.POSITIVE_INFINITY,null);else{const A=Qe(o,ae.x,ke.value);J(A,null)}}const we=zt({axis:"vertical",totalSize:z,position:t.computed(()=>P.value.displayScrollOffset.y),viewportSize:t.computed(()=>P.value.displayViewportSize.height),scrollToOffset:_e,containerId:w,isRtl:M}),ye=zt({axis:"horizontal",totalSize:W,position:t.computed(()=>P.value.displayScrollOffset.x),viewportSize:t.computed(()=>P.value.displayViewportSize.width),scrollToOffset:pe,containerId:w,isRtl:M}),He=t.computed(()=>l.direction!=="both"?E.value:{...E.value,padStart:0,padEnd:0});function lt(){ht(),fe(),t.nextTick(()=>{const o=[];for(const[d,c]of h.entries())c&&o.push({index:d,inlineSize:c.offsetWidth,blockSize:c.offsetHeight,element:c});o.length>0&&re(o)})}t.watch(P,(o,d)=>{!G.value||!o||(s("scroll",o),(!d||!d.range||!d.columnRange||o.range.start!==d.range.start||o.range.end!==d.range.end||o.columnRange.start!==d.columnRange.start||o.columnRange.end!==d.columnRange.end)&&s("visibleRangeChange",{start:o.range.start,end:o.range.end,colStart:o.columnRange.start,colEnd:o.columnRange.end}),!l.loading&&(l.direction!=="horizontal"&&o.totalSize&&o.totalSize.height-(o.scrollOffset.y+o.viewportSize.height)<=l.loadDistance&&s("load","vertical"),l.direction!=="vertical"&&o.totalSize&&o.totalSize.width-(o.scrollOffset.x+o.viewportSize.width)<=l.loadDistance&&s("load","horizontal")))}),t.watch(G,o=>{o&&P.value?.range&&P.value?.columnRange&&s("visibleRangeChange",{start:P.value.range.start,end:P.value.range.end,colStart:P.value.columnRange.start,colEnd:P.value.columnRange.end})},{once:!0});const ne=typeof window>"u"?null:new ResizeObserver(X),Te=typeof window>"u"?null:new ResizeObserver(o=>{const d=[];for(const c of o){const A=c.target,de=Number(A.dataset.index),Oe=A.dataset.colIndex;let ze=c.contentRect.width,O=c.contentRect.height;c.borderBoxSize&&c.borderBoxSize.length>0?(ze=c.borderBoxSize[0].inlineSize,O=c.borderBoxSize[0].blockSize):(ze=A.offsetWidth,O=A.offsetHeight),Oe!==void 0?d.push({index:-1,inlineSize:ze,blockSize:O,element:A}):Number.isNaN(de)||d.push({index:de,inlineSize:ze,blockSize:O,element:A})}d.length>0&&re(d)}),Me=typeof window>"u"?null:new ResizeObserver(()=>{D.value=g.value?.offsetHeight||0,R.value=x.value?.offsetHeight||0,X()});t.watch(g,(o,d)=>{d&&Me?.unobserve(d),o?Me?.observe(o):D.value=0},{immediate:!0}),t.watch(x,(o,d)=>{d&&Me?.unobserve(d),o?Me?.observe(o):R.value=0},{immediate:!0}),t.onMounted(()=>{S.value&&ne?.observe(S.value);for(const o of h.values())Te?.observe(o),l.direction==="both"&&o.querySelectorAll("[data-col-index]").forEach(d=>Te?.observe(d))}),t.watch([S,b],([o],[d])=>{d&&ne?.unobserve(d),o&&ne?.observe(o)}),t.watch([S,Pe],([o,d],[c,A])=>{const de=o!==c||d!==A;c&&de&&c.removeEventListener("wheel",rt),o&&de&&o.addEventListener("wheel",rt,{passive:!d})},{immediate:!0});function Ve(o,d){if(o)h.set(d,o),Te?.observe(o),l.direction==="both"&&o.querySelectorAll("[data-col-index]").forEach(c=>Te?.observe(c));else{const c=h.get(d);c&&(Te?.unobserve(c),l.direction==="both"&&c.querySelectorAll("[data-col-index]").forEach(A=>Te?.unobserve(A)),h.delete(d))}}const be=t.ref(!1);let Se={x:0,y:0},at={x:0,y:0},Ze={x:0,y:0},mt=0,oe={x:0,y:0},he=null;function Ye(){const o=()=>{oe.x*=ll,oe.y*=ll;const d=P.value.scrollOffset.x,c=P.value.scrollOffset.y;J(d+oe.x*16,c+oe.y*16,{behavior:"auto"}),Math.abs(oe.x)>xt||Math.abs(oe.y)>xt?he=requestAnimationFrame(o):Ie()};he=requestAnimationFrame(o)}function Ie(){he!==null&&(cancelAnimationFrame(he),he=null),oe={x:0,y:0}}function Le(o){te(),Ie(),Pe.value&&(o.pointerType==="mouse"&&o.button!==0||(be.value=!0,Se={x:o.clientX,y:o.clientY},Ze={x:o.clientX,y:o.clientY},mt=performance.now(),at={x:P.value.scrollOffset.x,y:P.value.scrollOffset.y},o.currentTarget.setPointerCapture(o.pointerId)))}function Vt(o){if(!be.value)return;const d=performance.now(),c=d-mt;if(c>0){const Oe=(Ze.x-o.clientX)/c,ze=(Ze.y-o.clientY)/c;oe.x=oe.x*.2+Oe*.8,oe.y=oe.y*.2+ze*.8}Ze={x:o.clientX,y:o.clientY},mt=d;const A=Se.x-o.clientX,de=Se.y-o.clientY;requestAnimationFrame(()=>{J(at.x+A,at.y+de,{behavior:"auto"})})}function kt(o){be.value&&(be.value=!1,o.currentTarget.releasePointerCapture(o.pointerId),(Math.abs(oe.x)>xt||Math.abs(oe.y)>xt)&&(Math.abs(oe.x)>4*Math.abs(oe.y)?oe.y=0:Math.abs(oe.y)>4*Math.abs(oe.x)&&(oe.x=0),Ye()))}function rt(o){const{scrollOffset:d}=P.value;if(te(),Pe.value){o.preventDefault();let c=o.deltaX,A=o.deltaY;o.shiftKey&&c===0&&(c=A,A=0);const de=d.x+c,Oe=d.y+A;J(de,Oe,{behavior:"auto"})}}function je(o){const{viewportSize:d,scrollOffset:c}=P.value,A=l.direction!=="vertical",de=l.direction!=="horizontal",Oe=F.value.stickyStart,ze=F.value.stickyEnd;switch(o.key){case"Home":{o.preventDefault(),te();const O=Math.max(c.x,c.y),j=l.direction==="horizontal"?d.width:d.height,me=O>10*j?"auto":"smooth";Z(0,0,{behavior:me,align:"start"});break}case"End":{o.preventDefault(),te();const O=l.items.length-1,j=(l.columnCount||0)>0?l.columnCount-1:0,{totalSize:me}=P.value,Ge=Math.max(me.width-c.x-d.width,me.height-c.y-d.height),ut=l.direction==="horizontal"?d.width:d.height,a=Ge>10*ut?"auto":"smooth";l.direction==="both"?Z(O,j,{behavior:a,align:"end"}):Z(l.direction==="vertical"?O:0,l.direction==="horizontal"?O:0,{behavior:a,align:"end"});break}case"ArrowUp":{if(o.preventDefault(),te(),!de)return;const{currentIndex:O,scrollOffset:j}=P.value,me=j.y+Oe.y+F.value.scrollPaddingStart.y;le(O)<me-1?Z(O,null,{align:"start"}):O>0&&Z(O-1,null,{align:"start"});break}case"ArrowDown":{if(o.preventDefault(),te(),!de)return;const{currentEndIndex:O}=P.value,j=c.y+d.height-(ze.y+F.value.scrollPaddingEnd.y);le(O)+K(O)>j+1?Z(O,null,{align:"end"}):O<l.items.length-1&&Z(O+1,null,{align:"end"});break}case"ArrowLeft":{if(o.preventDefault(),te(),!A)return;const{currentColIndex:O,currentEndColIndex:j}=P.value;if(M.value){const me=c.x+d.width-(ze.x+F.value.scrollPaddingEnd.x);if((l.columnCount?Be(j)+H(j):$(j)+ue(j))>me+1)Z(null,j,{align:"end"});else{const ut=l.columnCount?l.columnCount-1:l.items.length-1;j<ut&&Z(null,j+1,{align:"end"})}}else{const me=c.x+Oe.x+F.value.scrollPaddingStart.x;(l.columnCount?Be(O):$(O))<me-1?Z(null,O,{align:"start"}):O>0&&Z(null,O-1,{align:"start"})}break}case"ArrowRight":{if(o.preventDefault(),te(),!A)return;const{currentColIndex:O,currentEndColIndex:j}=P.value;if(M.value){const me=c.x+Oe.x+F.value.scrollPaddingStart.x;(l.columnCount?Be(O):$(O))<me-1?Z(null,O,{align:"start"}):O>0&&Z(null,O-1,{align:"start"})}else{const me=c.x+d.width-(ze.x+F.value.scrollPaddingEnd.x);if((l.columnCount?Be(j)+H(j):$(j)+ue(j))>me+1)Z(null,j,{align:"end"});else{const ut=l.columnCount?l.columnCount-1:l.items.length-1;j<ut&&Z(null,j+1,{align:"end"})}}break}case"PageUp":o.preventDefault(),te(),J(!de&&A?c.x-d.width:null,de?c.y-d.height:null);break;case"PageDown":o.preventDefault(),te(),J(!de&&A?c.x+d.width:null,de?c.y+d.height:null);break}}t.onUnmounted(()=>{ne?.disconnect(),Te?.disconnect(),Me?.disconnect()});const Wt=t.computed(()=>{const o={...l.direction!=="vertical"?{whiteSpace:"nowrap"}:{}};return ve.value&&(o.overflow="auto"),Pe.value&&(o.touchAction="none"),De.value?o:l.containerTag==="table"?{...o,minInlineSize:l.direction==="vertical"?"100%":"auto"}:o}),nt=t.computed(()=>{if(l.direction==="horizontal")return null;const{displayViewportSize:o,displayScrollOffset:d}=P.value;if(z.value<=o.height)return null;const c={axis:"vertical",totalSize:z.value,position:d.y,viewportSize:o.height,scrollToOffset:_e,containerId:w.value,isRtl:M.value};return{positionPercent:we.positionPercent.value,viewportPercent:we.viewportPercent.value,thumbSizePercent:we.thumbSizePercent.value,thumbPositionPercent:we.thumbPositionPercent.value,trackProps:we.trackProps.value,thumbProps:we.thumbProps.value,scrollbarProps:c,isDragging:we.isDragging.value}}),Ke=t.computed(()=>{if(l.direction==="vertical")return null;const{displayViewportSize:o,displayScrollOffset:d}=P.value;if(W.value<=o.width)return null;const c={axis:"horizontal",totalSize:W.value,position:d.x,viewportSize:o.width,scrollToOffset:pe,containerId:w.value,isRtl:M.value};return{positionPercent:ye.positionPercent.value,viewportPercent:ye.viewportPercent.value,thumbSizePercent:ye.thumbSizePercent.value,thumbPositionPercent:ye.thumbPositionPercent.value,trackProps:ye.trackProps.value,thumbProps:ye.thumbProps.value,scrollbarProps:c,isDragging:ye.isDragging.value}}),We=t.computed(()=>{const o=l.direction==="horizontal",d=l.direction==="vertical",c=l.direction==="both",A={inlineSize:d?"100%":`${Xe.value}px`,blockSize:o?"100%":`${ie.value}px`};return G.value||(A.display="flex",A.flexDirection=o?"row":"column",(o||c)&&l.columnGap&&(A.columnGap=`${l.columnGap}px`),(d||c)&&l.gap&&(A.rowGap=`${l.gap}px`)),A}),ot=t.computed(()=>{const o=l.direction==="horizontal";return{display:o?"inline-block":"block",...o?{blockSize:"100%",verticalAlign:"top"}:{inlineSize:"100%"}}}),gt=t.computed(()=>({inlineSize:l.direction==="vertical"?"1px":`${Xe.value}px`,blockSize:l.direction==="horizontal"?"1px":`${ie.value}px`}));function Pt(o){const d=Jt({containerTag:l.containerTag,direction:l.direction,isHydrated:G.value,item:o,itemSize:l.itemSize,paddingStartX:F.value.scrollPaddingStart.x,paddingStartY:F.value.scrollPaddingStart.y,isRtl:M.value});return!G.value&&l.direction==="both"&&(d.display="flex",l.columnGap&&(d.columnGap=`${l.columnGap}px`)),d}const Mt=t.computed(()=>l.debug),Je=t.computed(()=>l.containerTag==="table"),It=t.computed(()=>Je.value?"thead":"div"),Ct=t.computed(()=>Je.value?"tfoot":"div");return e({...t.toRefs(l),scrollDetails:P,columnRange:E,getColumnWidth:H,getRowHeight:K,getRowOffset:le,getColumnOffset:Be,getItemOffset:$,getItemSize:ue,scrollToIndex:Z,scrollToOffset:J,refresh:lt,stopProgrammaticScroll:()=>{te(),Ie()},updateDirection:fe,isRtl:M,isHydrated:G,scaleX:ke,scaleY:ce,renderedWidth:W,renderedHeight:z,componentOffset:ae,scrollbarPropsVertical:nt,scrollbarPropsHorizontal:Ke}),(o,d)=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(n.containerTag),{id:w.value,ref_key:"hostRef",ref:S,class:t.normalizeClass(["virtual-scroll-container",[`virtual-scroll--${n.direction}`,{"virtual-scroll--hydrated":t.unref(G),"virtual-scroll--window":t.unref(De),"virtual-scroll--table":Je.value,"virtual-scroll--hide-scrollbar":ve.value}]]),style:t.normalizeStyle(Wt.value),tabindex:"0",onKeydown:je,onPointerdown:Le,onPointermove:Vt,onPointerup:kt,onPointercancel:kt},{default:t.withCtx(()=>[ve.value?(t.openBlock(),t.createElementBlock("div",rl,[t.createElementVNode("div",{class:"virtual-scroll-scrollbar-viewport",style:t.normalizeStyle({inlineSize:`${t.unref(P).displayViewportSize.width}px`,blockSize:`${t.unref(P).displayViewportSize.height}px`,"--vsi-scrollbar-has-cross-gap":n.direction==="both"?1:0})},[f.scrollbar&&nt.value?t.renderSlot(o.$slots,"scrollbar",t.normalizeProps(t.mergeProps({key:0},nt.value)),void 0,!0):nt.value?(t.openBlock(),t.createBlock(Bt,t.normalizeProps(t.mergeProps({key:1},nt.value.scrollbarProps)),null,16)):t.createCommentVNode("",!0),f.scrollbar&&Ke.value?t.renderSlot(o.$slots,"scrollbar",t.normalizeProps(t.mergeProps({key:2},Ke.value)),void 0,!0):Ke.value?(t.openBlock(),t.createBlock(Bt,t.normalizeProps(t.mergeProps({key:3},Ke.value.scrollbarProps)),null,16)):t.createCommentVNode("",!0)],4)])):t.createCommentVNode("",!0),f.header?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(It.value),{key:1,ref_key:"headerRef",ref:g,class:t.normalizeClass(["virtual-scroll-header",{"virtual-scroll--sticky":n.stickyHeader}])},{default:t.withCtx(()=>[t.renderSlot(o.$slots,"header",{},void 0,!0)]),_:3},8,["class"])):t.createCommentVNode("",!0),(t.openBlock(),t.createBlock(t.resolveDynamicComponent(n.wrapperTag),{ref_key:"wrapperRef",ref:b,class:"virtual-scroll-wrapper",style:t.normalizeStyle(We.value)},{default:t.withCtx(()=>[Je.value?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(n.itemTag),{key:0,class:"virtual-scroll-spacer",style:t.normalizeStyle(gt.value)},{default:t.withCtx(()=>[...d[0]||(d[0]=[t.createElementVNode("td",{style:{padding:"0",border:"none","block-size":"inherit"}},null,-1)])]),_:1},8,["style"])):t.createCommentVNode("",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(V),c=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(n.itemTag),{key:c.index,ref_for:!0,ref:A=>Ve(A,c.index),"data-index":c.index,class:t.normalizeClass(["virtual-scroll-item",{"virtual-scroll--sticky":c.isStickyActive,"virtual-scroll--debug":Mt.value}]),style:t.normalizeStyle(Pt(c))},{default:t.withCtx(()=>[t.renderSlot(o.$slots,"item",{item:c.item,index:c.index,columnRange:He.value,getColumnWidth:t.unref(H),gap:l.gap,columnGap:l.columnGap,isSticky:c.isSticky,isStickyActive:c.isStickyActive},void 0,!0),Mt.value?(t.openBlock(),t.createElementBlock("div",ul," #"+t.toDisplayString(c.index)+" ("+t.toDisplayString(Math.round(c.offset.x))+", "+t.toDisplayString(Math.round(c.offset.y))+") ",1)):t.createCommentVNode("",!0)]),_:2},1032,["data-index","class","style"]))),128))]),_:3},8,["style"])),n.loading&&f.loading?(t.openBlock(),t.createElementBlock("div",{key:2,class:"virtual-scroll-loading",style:t.normalizeStyle(ot.value)},[t.renderSlot(o.$slots,"loading",{},void 0,!0)],4)):t.createCommentVNode("",!0),f.footer?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(Ct.value),{key:3,ref_key:"footerRef",ref:x,class:t.normalizeClass(["virtual-scroll-footer",{"virtual-scroll--sticky":n.stickyFooter}])},{default:t.withCtx(()=>[t.renderSlot(o.$slots,"footer",{},void 0,!0)]),_:3},8,["class"])):t.createCommentVNode("",!0)]),_:3},40,["id","class","style"]))}}),[["__scopeId","data-v-91b6ab6c"]]);B.BROWSER_MAX_SIZE=et,B.DEFAULT_BUFFER=At,B.DEFAULT_COLUMN_WIDTH=vt,B.DEFAULT_ITEM_SIZE=ft,B.FenwickTree=St,B.VirtualScroll=sl,B.VirtualScrollbar=Bt,B.calculateColumnRange=Qt,B.calculateItemPosition=Kt,B.calculateItemStyle=Jt,B.calculateRange=jt,B.calculateScrollTarget=Ot,B.calculateStickyItem=Zt,B.calculateTotalSize=el,B.displayToVirtual=Qe,B.findPrevStickyIndex=Yt,B.getPaddingX=Ne,B.getPaddingY=Ue,B.isBody=Gt,B.isElement=wt,B.isItemVisible=_t,B.isScrollToIndexOptions=tt,B.isScrollableElement=bt,B.isWindow=Lt,B.isWindowLike=$t,B.useVirtualScroll=tl,B.useVirtualScrollbar=zt,B.virtualToDisplay=dt,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})}));
|
|
2
|
+
//# sourceMappingURL=index.js.map
|