virtua 0.35.0 → 0.36.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 +34 -32
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/solid/index.js +1 -1
- package/lib/solid/index.js.map +1 -1
- package/lib/solid/index.mjs +1 -1
- package/lib/solid/index.mjs.map +1 -1
- package/lib/svelte/ListItem.svelte +31 -15
- package/lib/svelte/ListItem.svelte.d.ts +21 -17
- package/lib/svelte/VList.svelte +51 -222
- package/lib/svelte/VList.svelte.d.ts +22 -88
- package/lib/svelte/VList.type.d.ts +13 -0
- package/lib/svelte/VList.type.js +1 -0
- package/lib/svelte/Virtualizer.svelte +192 -0
- package/lib/svelte/Virtualizer.svelte.d.ts +26 -0
- package/lib/svelte/Virtualizer.type.d.ts +114 -0
- package/lib/svelte/Virtualizer.type.js +1 -0
- package/lib/svelte/core.d.ts +20 -14
- package/lib/svelte/core.js +1 -1
- package/lib/svelte/index.d.ts +3 -0
- package/lib/svelte/index.js +1 -0
- package/lib/svelte/types.d.ts +3 -0
- package/lib/svelte/utils.d.ts +0 -7
- package/lib/svelte/utils.js +0 -6
- package/lib/vue/index.js +1 -1
- package/lib/vue/index.js.map +1 -1
- package/lib/vue/index.mjs +1 -1
- package/lib/vue/index.mjs.map +1 -1
- package/package.json +56 -58
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ If you want to check the difference with the alternatives right away, [see compa
|
|
|
13
13
|
This project is a challenge to rethink virtualization. The goals are...
|
|
14
14
|
|
|
15
15
|
- **Zero-config virtualization:** This library is designed to give the best performance without configuration. It also handles common hard things in the real world (dynamic size measurement, scroll position adjustment while reverse scrolling and imperative scrolling, iOS support, etc).
|
|
16
|
-
- **Fast:** Natural virtual scrolling needs optimization in many aspects (eliminate frame drops by reducing CPU usage and GC
|
|
16
|
+
- **Fast:** Natural virtual scrolling needs optimization in many aspects (eliminate frame drops by reducing CPU usage and GC, reduce [synchronous layout recalculation](https://gist.github.com/paulirish/5d52fb081b3570c81e3a), reduce visual jumps on repaint, optimize with CSS, optimize for frameworks, etc). We are trying to combine the best of them.
|
|
17
17
|
- **Small:** Its bundle size should be small as much as possible to be friendly with modern web development. Currently each components are ~3kB gzipped and tree-shakeable. The total size for React is [~5kB gzipped](https://bundlephobia.com/package/virtua).
|
|
18
18
|
- **Flexible:** Aiming to support many usecases - fixed size, dynamic size, horizontal scrolling, reverse scrolling, RTL, mobile, infinite scrolling, scroll restoration, DnD, keyboard navigation, sticky, placeholder and more. See [live demo](#demo).
|
|
19
19
|
- **Framework agnostic:** [React](https://react.dev/), [Vue](https://vuejs.org/), [Solid](https://www.solidjs.com/) and [Svelte](https://svelte.dev/) are supported. We could support other frameworks in the future.
|
|
@@ -252,7 +252,7 @@ export const App = () => {
|
|
|
252
252
|
|
|
253
253
|
### Svelte
|
|
254
254
|
|
|
255
|
-
`svelte >=
|
|
255
|
+
`svelte >= 5.0` is required.
|
|
256
256
|
|
|
257
257
|
```svelte
|
|
258
258
|
<script lang="ts">
|
|
@@ -263,16 +263,18 @@ export const App = () => {
|
|
|
263
263
|
const data = Array.from({ length: 1000 }).map((_, i) => sizes[i % 4] );
|
|
264
264
|
</script>
|
|
265
265
|
|
|
266
|
-
<VList {data}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
266
|
+
<VList {data} style={`height: 100vh;`} getKey={(_, i) => i}>
|
|
267
|
+
{#snippet children(item, index)}
|
|
268
|
+
<div
|
|
269
|
+
style={`
|
|
270
|
+
height: ${item}px;
|
|
271
|
+
background: white;
|
|
272
|
+
border-bottom: solid 1px #ccc;
|
|
273
|
+
`}
|
|
274
|
+
>
|
|
275
|
+
{index}
|
|
276
|
+
</div>
|
|
277
|
+
{/snippet}
|
|
276
278
|
</VList>
|
|
277
279
|
```
|
|
278
280
|
|
|
@@ -339,26 +341,26 @@ This package uses [exports of package.json](https://nodejs.org/api/packages.html
|
|
|
339
341
|
|
|
340
342
|
### Features
|
|
341
343
|
|
|
342
|
-
|
|
|
343
|
-
|
|
|
344
|
-
| Bundle size
|
|
345
|
-
| Vertical scroll
|
|
346
|
-
| Horizontal scroll
|
|
347
|
-
| Horizontal scroll in RTL direction
|
|
348
|
-
| Grid (Virtualization for two dimension)
|
|
349
|
-
| Table
|
|
350
|
-
| Window scroller
|
|
351
|
-
| Dynamic list size
|
|
352
|
-
| Dynamic item size
|
|
353
|
-
| Reverse scroll
|
|
354
|
-
| Reverse scroll in iOS Safari
|
|
355
|
-
| Infinite scroll
|
|
356
|
-
| Reverse (bi-directional) infinite scroll
|
|
357
|
-
| Scroll restoration
|
|
358
|
-
| Smooth scroll
|
|
359
|
-
| SSR support
|
|
360
|
-
| Render React Server Components (RSC) as children
|
|
361
|
-
| Display exceeding browser's max element size limit | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ |
|
|
344
|
+
| | [virtua](https://github.com/inokawa/virtua) | [react-virtuoso](https://github.com/petyosi/react-virtuoso) | [react-window](https://github.com/bvaughn/react-window) | [react-virtualized](https://github.com/bvaughn/react-virtualized) | [@tanstack/react-virtual](https://github.com/TanStack/virtual) | [react-tiny-virtual-list](https://github.com/clauderic/react-tiny-virtual-list) | [react-cool-virtual](https://github.com/wellyshen/react-cool-virtual) |
|
|
345
|
+
| :------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------- |
|
|
346
|
+
| Bundle size | [](https://bundlephobia.com/package/virtua) | [](https://bundlephobia.com/package/react-virtuoso) | [](https://bundlephobia.com/package/react-window) | [](https://bundlephobia.com/package/react-virtualized) | [](https://bundlephobia.com/package/@tanstack/react-virtual) | [](https://bundlephobia.com/package/react-tiny-virtual-list) | [](https://bundlephobia.com/package/react-cool-virtual) |
|
|
347
|
+
| Vertical scroll | ✅ | ✅ | ✅ | ✅ | 🟠 (needs customization) | ✅ | 🟠 (needs customization) |
|
|
348
|
+
| Horizontal scroll | ✅ | ✅ | ✅ ([may be dropped in v2](https://github.com/bvaughn/react-window/issues/302)) | ✅ | 🟠 (needs customization) | ✅ | 🟠 (needs customization) |
|
|
349
|
+
| Horizontal scroll in RTL direction | ✅ | ❌ | ✅ ([may be dropped in v2](https://github.com/bvaughn/react-window/issues/302)) | ❌ | ❌ | ❌ | ❌ |
|
|
350
|
+
| Grid (Virtualization for two dimension) | 🟠 (experimental_VGrid) | ❌ | ✅ (FixedSizeGrid / VariableSizeGrid) | ✅ ([Grid](https://github.com/bvaughn/react-virtualized/blob/master/docs/Grid.md)) | 🟠 (needs customization) | ❌ | 🟠 (needs customization) |
|
|
351
|
+
| Table | 🟠 (needs customization) | ✅ (TableVirtuoso) | 🟠 (needs customization) | 🟠 ([Table](https://github.com/bvaughn/react-virtualized/blob/master/docs/Table.md) but it's built with div) | 🟠 (needs customization) | ❌ | 🟠 (needs customization) |
|
|
352
|
+
| Window scroller | ✅ (WindowVirtualizer) | ✅ | ❌ | ✅ ([WindowScroller](https://github.com/bvaughn/react-virtualized/blob/master/docs/WindowScroller.md)) | ✅ (useWindowVirtualizer) | ❌ | ❌ |
|
|
353
|
+
| Dynamic list size | ✅ | ✅ | 🟠 (needs [AutoSizer](https://github.com/bvaughn/react-virtualized/blob/master/docs/AutoSizer.md)) | 🟠 (needs [AutoSizer](https://github.com/bvaughn/react-virtualized/blob/master/docs/AutoSizer.md)) | ✅ | ❌ | ✅ |
|
|
354
|
+
| Dynamic item size | ✅ | ✅ | 🟠 (needs additional codes and has wrong destination when scrolling to item imperatively) | 🟠 (needs [CellMeasurer](https://github.com/bvaughn/react-virtualized/blob/master/docs/CellMeasurer.md) and has wrong destination when scrolling to item imperatively) | 🟠 (has wrong destination when scrolling to item imperatively) | ❌ | 🟠 (has wrong destination when scrolling to item imperatively) |
|
|
355
|
+
| Reverse scroll | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
356
|
+
| Reverse scroll in iOS Safari | 🟠 ([user must release scroll](https://github.com/inokawa/virtua/issues/473)) | 🟠 ([has glitch with unknown sized items](https://github.com/petyosi/react-virtuoso/issues/945)) | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
357
|
+
| Infinite scroll | ✅ | ✅ | 🟠 (needs [react-window-infinite-loader](https://github.com/bvaughn/react-window-infinite-loader)) | 🟠 (needs [InfiniteLoader](https://github.com/bvaughn/react-virtualized/blob/master/docs/InfiniteLoader.md)) | ✅ | ❌ | ✅ |
|
|
358
|
+
| Reverse (bi-directional) infinite scroll | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | 🟠 (has startItem method but its scroll position can be inaccurate) |
|
|
359
|
+
| Scroll restoration | ✅ | ✅ (getState) | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
360
|
+
| Smooth scroll | ✅ | ✅ | ❌ | ❌ | ✅ | ❌ | ✅ |
|
|
361
|
+
| SSR support | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ |
|
|
362
|
+
| Render React Server Components (RSC) as children | ✅ | ❌ | ❌ | ❌ | 🟠(needs customization) | ❌ | 🟠 (needs customization) |
|
|
363
|
+
| Display exceeding [browser's max element size](https://stackoverflow.com/questions/10882769/do-the-browsers-have-a-maximum-height-for-the-body-document) limit | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ |
|
|
362
364
|
|
|
363
365
|
- ✅ - Built-in supported
|
|
364
366
|
- 🟠 - Supported but partial, limited or requires some user custom code
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e=require("react/jsx-runtime"),t=require("react"),n=require("react-dom");const o=null,{min:r,max:i,abs:s}=Math,l=Array.isArray,c=setTimeout,a=(e,t,n)=>r(n,i(t,e)),u=e=>[...e].sort(((e,t)=>e-t)),d="function"==typeof queueMicrotask?queueMicrotask:e=>{Promise.resolve().then(e)},f=e=>{let t,n;return(...o)=>(t||(t=!0,n=e(...o)),n)},h=-1,_=(e,t,n)=>{const o=n?"unshift":"push";for(let n=0;n<t;n++)e[o](h);return e},p=(e,t)=>{const n=e.t[t];return n===h?e.o:n},v=(e,t,n)=>{const o=e.t[t]===h;return e.t[t]=n,e.i=r(t,e.i),o},g=(e,t)=>{if(!e.l)return 0;if(e.i>=t)return e.u[t];e.i<0&&(e.u[0]=0,e.i=0);let n=e.i,o=e.u[n];for(;n<t;)o+=p(e,n),e.u[++n]=o;return e.i=t,o},m=(e,t,n)=>{for(;n>=0&&n<e.l;){const o=g(e,n);if(o<=t){if(o+p(e,n)>t)break;n++}else n--}return a(n,0,e.l-1)},w=(e,t,n)=>{const o=t-e.l;return e.i=n?-1:r(t-1,e.i),e.l=t,o>0?(_(e.u,o),_(e.t,o,n),e.o*o):(e.u.splice(o),(n?e.t.splice(0,-o):e.t.splice(o)).reduce(((t,n)=>t-(n===h?e.o:n)),0))},S="undefined"!=typeof window,b=()=>document.documentElement,y=e=>e.ownerDocument,x=e=>e.defaultView,z=/*#__PURE__*/f((()=>!!S&&"rtl"===getComputedStyle(b()).direction)),I=/*#__PURE__*/f((()=>/iP(hone|od|ad)/.test(navigator.userAgent))),k=/*#__PURE__*/f((()=>"scrollBehavior"in b().style)),R=e=>i(e.h(),e._()),C=(e,t,n,o,s)=>(1!==o&&(e-=i(0,n)),2!==o&&(t+=i(0,n)),[i(e,0),r(t,s-1)]),T=(e,t=40,n=0,l,c=!1)=>{let a=!!n,d=[],f=0,S=0,b=0,y=0,x=0,z=0,k=0,R=0,C=0,T=a?[0,i(n-1,0)]:o,M=[0,0],H=0;const W=((e,t,n)=>({o:n?n[1]:t,t:n&&n[0]?_(n[0].slice(0,r(e,n[0].length)),i(0,e-n[0].length)):_([],e),l:e,i:-1,u:_([],e)}))(e,t,l),E=new Set,J=()=>b-S,q=e=>((e,t,n,o)=>{const i=m(e,t,r(n,e.l-1));return[i,m(e,t+o,i)]})(W,e,M[0],f),B=()=>(e=>e.l?g(e,e.l-1)+p(e,e.l-1):0)(W),O=e=>g(W,e)-z,D=e=>p(W,e),L=e=>{e&&(I()&&0!==R?z+=e:(x+=e,y++))};return{p:()=>d,v:()=>(e=>[[...e.t],e.o])(W),m:()=>k?M:(M=q(i(0,J()+z+x)),T?[r(M[0],T[0]),i(M[1],T[1])]:M),S:e=>W.t[e]===h,I:()=>!!f,k:()=>!!T&&W.t.slice(i(0,T[0]-1),r(W.l-1,T[1]+1)+1).includes(h),R:O,C:D,T:()=>W.l,M:()=>b,H:()=>R,_:()=>f,W:()=>S,h:B,J:()=>y,q:()=>(k=x,x=0,[k,2===C||J()+f>=B()]),B(e,t){const n=[e,t];return E.add(n),()=>{E.delete(n)}},O(e,t){let n,r,l=0;switch(e){case 1:{const e=k;k=0;const n=t-b,i=s(n);e&&i<s(e)+1||0!==C||(R=n<0?2:1),a&&(T=o,a=!1),b=t,l=4;const c=J();c>=-f&&c<=B()&&(l+=1,r=i>f);break}case 2:l=8,0!==R&&(n=!0,l+=1),R=0,C=0,T=o;break;case 3:{const e=t.filter((([e,t])=>W.t[e]!==t));if(!e.length)break;L(e.reduce(((e,[t,n])=>((2===C||(T?t<T[0]:O(t)+(0===R&&0===C?D(t):0)<J()))&&(e+=n-D(t)),e)),0));for(const[t,n]of e){const e=D(t),o=v(W,t,n);c&&(H+=o?n:n-e)}c&&f&&H>f&&(L(((e,t)=>{let n=0;const o=e.t.filter(((e,o)=>{const r=e!==h;return r&&o<t&&n++,r})),r=e.o;return e.i=-1,((e.o=(e=>{const t=u(e),n=e.length/2|0;return t.length%2==0?(t[n-1]+t[n])/2:t[n]})(o))-r)*i(t-n,0)})(W,M[0])),c=!1),l=3,r=!0;break}case 4:f!==t&&(f=t,l=3);break;case 5:t[1]?(L(w(W,t[0],!0)),C=2,l=1):w(W,t[0]);break;case 6:S=t;break;case 7:C=1;break;case 8:T=q(t),l=1}l&&(d=[],n&&z&&(x+=z,z=0,y++),E.forEach((([e,t])=>{l&e&&t(r)})))}}},M=S?t.useLayoutEffect:t.useEffect,H=(e,t)=>t&&z()?-e:e,W=(e,t,n,r,i,s)=>{const l=Date.now;let a=0,u=!1,d=!1,f=!1,h=!1;const _=(()=>{let t;const n=()=>{t!=o&&clearTimeout(t)},r=()=>{n(),t=c((()=>{t=o,(()=>{if(u||d)return u=!1,void _();f=!1,e.O(2)})()}),150)};return r.D=n,r})(),p=()=>{a=l(),f&&(h=!0),s&&e.O(6,s()),e.O(1,r()),_()},v=t=>{if(u||0===e.H()||t.ctrlKey)return;const o=l()-a;150>o&&50<o&&(n?t.deltaX:t.deltaY)&&(u=!0)},g=()=>{d=!0,f=h=!1},m=()=>{d=!1,I()&&(f=!0)};return t.addEventListener("scroll",p),t.addEventListener("wheel",v,{passive:!0}),t.addEventListener("touchstart",g,{passive:!0}),t.addEventListener("touchend",m,{passive:!0}),{L:()=>{t.removeEventListener("scroll",p),t.removeEventListener("wheel",v),t.removeEventListener("touchstart",g),t.removeEventListener("touchend",m),_.D()},$:()=>{const[t,o]=e.q();t&&(i(H(t,n),o,h),h=!1,o&&e._()>e.h()&&e.O(1,r()))}}},E=(e,t)=>{let n,o,r;const i=t?"scrollLeft":"scrollTop",s=t?"overflowX":"overflowY",l=async(o,s)=>{if(!n)return void d((()=>l(o,s)));r&&r();const a=()=>{let t;return[new Promise(((n,o)=>{t=n,r=o,e.I()&&c(o,150)})),e.B(2,(()=>{t&&t()}))]};if(s&&k()){for(;e.O(8,o()),e.k();){const[e,t]=a();try{await e}catch(e){return}finally{t()}}n.scrollTo({[t?"left":"top"]:H(o(),t),behavior:"smooth"})}else for(;;){const[r,s]=a();try{n[i]=H(o(),t),e.O(7),await r}catch(e){return}finally{s()}}};return{A(l){n=l,o=W(e,l,t,(()=>H(l[i],t)),((t,n,o)=>{if(o){const e=l.style,t=e[s];e[s]="hidden",c((()=>{e[s]=t}))}n?(l[i]=e.M()+t,r&&r()):l[i]+=t}))},L(){o&&o.L()},P(e){l((()=>e))},X(t){t+=e.M(),l((()=>t))},Y(t,{align:n,smooth:o,offset:r=0}={}){if(t=a(t,0,e.T()-1),"nearest"===n){const o=e.R(t),r=e.M();if(o<r)n="start";else{if(!(o+e.C(t)>r+e._()))return;n="end"}}l((()=>r+e.W()+e.R(t)+("end"===n?e.C(t)-e._():"center"===n?(e.C(t)-e._())/2:0)),o)},$:()=>{o&&o.$()}}},J=(e,t)=>{let n;return{A(o){const r=t?"scrollX":"scrollY",i=y(o),s=x(i),l=i.body,c=(e,t,n,o=0)=>{const r=n?"offsetLeft":"offsetTop",i=o+(n&&z()?s.innerWidth-e[r]-e.offsetWidth:e[r]),l=e.offsetParent;return e!==t&&l?c(l,t,n,i):i};n=W(e,s,t,(()=>H(s[r],t)),((n,o)=>{o?s.scroll({[t?"left":"top"]:e.M()+n}):s.scrollBy(t?n:0,t?0:n)}),(()=>c(o,l,t)))},L(){n&&n.L()},$:()=>{n&&n.$()}}},q=(e,t)=>{const n=E(e,!1),o=E(t,!0);return{A(e){n.A(e),o.A(e)},L(){n.L(),o.L()},P(e,t){n.P(t),o.P(e)},X(e,t){n.X(t),o.X(e)},Y(e,t){n.Y(t),o.Y(e)},$(){n.$(),o.$()}}},B="current",O=(e,t)=>{if(l(e))for(const n of e)O(n,t);else e==o||"boolean"==typeof e||t.push(e)},D=(e,t)=>{const n=e.key;return n!=o?n:"_"+t},L=e=>{const n=t.useRef();return n[B]||(n[B]=e())},$=e=>{const n=t.useRef(e);return M((()=>{n[B]=e}),[e]),n},A=e=>{let t;return{A(n){(t||(t=new(x(y(n)).ResizeObserver)(e))).observe(n)},j(e){t.unobserve(e)},L(){t&&t.disconnect()}}},P=(e,t)=>{let n;const r=t?"width":"height",i=new WeakMap,s=A((t=>{const s=[];for(const{target:l,contentRect:c}of t)if(l.offsetParent)if(l===n)e.O(4,c[r]);else{const e=i.get(l);e!=o&&s.push([e,c[r]])}s.length&&e.O(3,s)}));return{U(e){s.A(n=e)},V:(e,t)=>(i.set(e,t),s.A(e),()=>{i.delete(e),s.j(e)}),L:s.L}},X=(e,t)=>{const n=t?"width":"height",r=t?"innerWidth":"innerHeight",i=new WeakMap,s=A((t=>{const r=[];for(const{target:e,contentRect:s}of t){if(!e.offsetParent)continue;const t=i.get(e);t!=o&&r.push([t,s[n]])}r.length&&e.O(3,r)}));let l;return{U(t){const n=x(y(t)),o=()=>{e.O(4,n[r])};n.addEventListener("resize",o),o(),l=()=>{n.removeEventListener("resize",o)}},V:(e,t)=>(i.set(e,t),s.A(e),()=>{i.delete(e),s.j(e)}),L(){l&&l(),s.L()}}},Y=(e,t)=>{let n;const o="height",r="width",s=new WeakMap,l=new Set,c=new Set,a=new Map,u=(e,t)=>`${e}-${t}`,d=A((d=>{const f=new Set,h=new Set;for(const{target:i,contentRect:l}of d)if(i.offsetParent)if(i===n)e.O(4,l[o]),t.O(4,l[r]);else{const e=s.get(i);if(e){const[t,n]=e,i=u(t,n),s=a.get(i),c=[l[o],l[r]];let d,_;s?(s[0]!==c[0]&&(d=!0),s[1]!==c[1]&&(_=!0)):d=_=!0,d&&f.add(t),_&&h.add(n),(d||_)&&a.set(i,c)}}if(f.size){const t=[];f.forEach((e=>{let n=0;c.forEach((t=>{const o=a.get(u(e,t));o&&(n=i(n,o[0]))})),n&&t.push([e,n])})),e.O(3,t)}if(h.size){const e=[];h.forEach((t=>{let n=0;l.forEach((e=>{const o=a.get(u(e,t));o&&(n=i(n,o[1]))})),n&&e.push([t,n])})),t.O(3,e)}}));return{U(e){d.A(n=e)},V:(e,t,n)=>(s.set(e,[t,n]),l.add(t),c.add(n),d.A(e),()=>{s.delete(e),d.j(e)}),L:d.L}},j=t.memo((({F:n,G:r,K:i,N:s,Z:l,ee:c,te:a,ne:u})=>{const d=t.useRef(o);M((()=>r(d[B],i)),[i]);const f=t.useMemo((()=>{const e={position:l&&u?void 0:"absolute",[a?"height":"width"]:"100%",[a?"top":"left"]:0,[a?z()?"right":"left":"top"]:s,visibility:!l||u?"visible":"hidden"};return a&&(e.display="flex"),e}),[s,l,u,a]);return"string"==typeof c?e.jsx(c,{ref:d,style:f,children:n}):e.jsx(c,{ref:d,style:f,index:i,children:n})})),U=e=>t.useReducer(e.p,void 0,e.p)[1],V=(e,n)=>t.useMemo((()=>{if("function"==typeof e)return[e,n||0];const t=(e=>{const t=[];return O(e,t),t})(e);return[e=>t[e],t.length]}),[e,n]),F=t.forwardRef((({children:r,count:i,overscan:s=4,keepMounted:l,itemSize:c,shift:a,horizontal:f,cache:h,startMargin:_=0,ssrCount:p,as:v="div",item:g="div",scrollRef:m,onScroll:w,onScrollEnd:S,onRangeChange:b},y)=>{const[x,z]=V(r,i),I=t.useRef(o),k=t.useRef(!!p),H=$(w),W=$(S),[J,q,O,A]=L((()=>{const e=!!f,t=T(z,c,p,h,!c);return[t,P(t,e),E(t,e),e]}));z!==J.T()&&J.O(5,[z,a]),_!==J.W()&&J.O(6,_);const X=U(J),[Y,F]=J.m(),G=J.H(),K=J.J(),N=J.h(),Q=[],[Z,ee]=C(Y,F,s,G,z),te=t=>{const n=x(t);return e.jsx(j,{G:q.V,K:t,N:J.R(t),Z:J.S(t),ee:g,F:n,te:A,ne:k[B]},D(n,t))};M((()=>{k[B]=!1;const e=J.B(1,(e=>{e?n.flushSync(X):X()})),t=J.B(4,(()=>{H[B]&&H[B](J.M())})),o=J.B(8,(()=>{W[B]&&W[B]()})),r=e=>{q.U(e),O.A(e)};return m?d((()=>r(m[B]))):r(I[B].parentElement),()=>{e(),t(),o(),q.L(),O.L()}}),[]),M((()=>{O.$()}),[K]),t.useEffect((()=>{b&&b(Y,F)}),[Y,F]),t.useImperativeHandle(y,(()=>({get cache(){return J.v()},get scrollOffset(){return J.M()},get scrollSize(){return R(J)},get viewportSize(){return J._()},getItemOffset:J.R,scrollToIndex:O.Y,scrollTo:O.P,scrollBy:O.X})),[]);for(let e=Z,t=ee;e<=t;e++)Q.push(te(e));if(l){const e=[],t=[];u(l).forEach((n=>{n<Z&&e.push(te(n)),n>ee&&t.push(te(n))})),Q.unshift(...e),Q.push(...t)}return e.jsx(v,{ref:I,style:{overflowAnchor:"none",flex:"none",position:"relative",visibility:"hidden",width:A?N:"100%",height:A?"100%":N,pointerEvents:0!==G?"none":void 0},children:Q})})),G=t.forwardRef((({children:n,count:r,overscan:i,keepMounted:s,itemSize:l,shift:c,horizontal:a,reverse:u,cache:d,ssrCount:f,item:h,onScroll:_,onScrollEnd:p,onRangeChange:v,style:g,...m},w)=>{const S=t.useRef(o),b=u&&!a;let y=e.jsx(F,{ref:w,scrollRef:b?S:void 0,count:r,overscan:i,keepMounted:s,itemSize:l,shift:c,horizontal:a,cache:d,ssrCount:f,item:h,onScroll:_,onScrollEnd:p,onRangeChange:v,children:n});return b&&(y=e.jsx("div",{style:{visibility:"hidden",display:"flex",flexDirection:"column",justifyContent:"flex-end",minHeight:"100%"},children:y})),e.jsx("div",{ref:S,...m,style:{display:a?"inline-block":"block",[a?"overflowX":"overflowY"]:"auto",contain:"strict",width:"100%",height:"100%",...g},children:y})})),K=t.forwardRef((({children:r,count:i,overscan:s=4,itemSize:l,shift:c,horizontal:a,cache:u,ssrCount:d,as:f="div",item:h="div",onScrollEnd:_,onRangeChange:p},v)=>{const[g,m]=V(r,i),w=t.useRef(o),S=$(_),b=t.useRef(!!d),[y,x,z,I]=L((()=>{const e=!!a,t=T(m,l,d,u,!l);return[t,X(t,e),J(t,e),e]}));m!==y.T()&&y.O(5,[m,c]);const k=U(y),[R,H]=y.m(),W=y.H(),E=y.J(),q=y.h(),O=[];M((()=>{b[B]=!1;const e=y.B(1,(e=>{e?n.flushSync(k):k()})),t=y.B(8,(()=>{S[B]&&S[B]()})),o=w[B];return x.U(o),z.A(o),()=>{e(),t(),x.L(),z.L()}}),[]),M((()=>{z.$()}),[E]),t.useEffect((()=>{p&&p(R,H)}),[R,H]),t.useImperativeHandle(v,(()=>({get cache(){return y.v()}})),[]);for(let[t,n]=C(R,H,s,W,m);t<=n;t++){const n=g(t);O.push(e.jsx(j,{G:x.V,K:t,N:y.R(t),Z:y.S(t),ee:h,F:n,te:I,ne:b[B]},D(n,t)))}return e.jsx(f,{ref:w,style:{flex:"none",position:"relative",visibility:"hidden",width:I?q:"100%",height:I?"100%":q,pointerEvents:0!==W?"none":void 0},children:O})})),N=(e,t)=>`${e}-${t}`,Q=t.memo((({F:n,G:r,oe:i,re:s,ie:l,se:c,le:a,ce:u,Z:d,ae:f})=>{const h=t.useRef(o);return M((()=>r.V(h[B],i,s)),[s,i]),e.jsx(f,{ref:h,style:t.useMemo((()=>({display:"grid",position:"absolute",top:l,[z()?"right":"left"]:c,visibility:d?"hidden":"visible",minHeight:a,minWidth:u})),[l,c,u,a,d]),children:n})})),Z=t.forwardRef((({children:r,row:i,col:s,cellHeight:l=40,cellWidth:c=100,overscan:a=2,initialRowCount:u,initialColCount:d,item:f="div",style:h,..._},p)=>{const[v,g,m,w]=L((()=>{const e=T(i,l,u),t=T(s,c,d);return[e,t,Y(e,t),q(e,t)]}));i!==v.T()&&v.O(5,[i]),s!==g.T()&&g.O(5,[s]);const S=U(v),b=U(g),[y,x]=v.m(),[z,I]=g.m(),k=v.H(),H=g.H(),W=v.J(),E=g.J(),J=R(v),O=R(g),D=t.useRef(o);M((()=>{const e=D[B],t=v.B(1,(e=>{e?n.flushSync(S):S()})),o=g.B(1,(e=>{e?n.flushSync(b):b()}));return m.U(e),w.A(e),()=>{t(),o(),m.L(),w.L()}}),[]),M((()=>{w.$()}),[W,E]),t.useImperativeHandle(p,(()=>({get scrollTop(){return v.M()},get scrollLeft(){return g.M()},get scrollHeight(){return R(v)},get scrollWidth(){return R(g)},get viewportHeight(){return v._()},get viewportWidth(){return g._()},scrollToIndex:w.Y,scrollTo:w.P,scrollBy:w.X})),[]);const $=t.useMemo((()=>{const e=new Map;return(t,n)=>{let o=e.get(N(t,n));return o||e.set(N(t,n),o=r({rowIndex:t,colIndex:n})),o}}),[r]),[A,P]=C(y,x,a,k,i),[X,j]=C(z,I,a,H,s),V=[];for(let t=A;t<=P;t++)for(let n=X;n<=j;n++)V.push(e.jsx(Q,{G:m,oe:t,re:n,ie:v.R(t),se:g.R(n),le:v.C(t),ce:g.C(n),Z:v.S(t)||g.S(n),ae:f,F:$(t,n)},N(t,n)));return e.jsx("div",{ref:D,..._,style:{overflow:"auto",contain:"strict",width:"100%",height:"100%",...h},children:e.jsx("div",{style:{overflowAnchor:"none",flex:"none",position:"relative",visibility:"hidden",width:O,height:J,pointerEvents:0!==k||0!==H?"none":void 0},children:V})})}));exports.VList=G,exports.Virtualizer=F,exports.WindowVirtualizer=K,exports.experimental_VGrid=Z;
|
|
2
|
+
var e=require("react/jsx-runtime"),t=require("react"),o=require("react-dom");const n=null,{min:r,max:i,abs:s,floor:l}=Math,c=Array.isArray,f=setTimeout,u=(e,t,o)=>r(o,i(t,e)),d=e=>[...e].sort(((e,t)=>e-t)),a="function"==typeof queueMicrotask?queueMicrotask:e=>{Promise.resolve().then(e)},h=e=>{let t,o;return(...n)=>(t||(t=!0,o=e(...n)),o)},_=-1,v=(e,t,o)=>{const n=o?"unshift":"push";for(let o=0;o<t;o++)e[n](_);return e},p=(e,t)=>{const o=e.t[t];return o===_?e.o:o},g=(e,t,o)=>{const n=e.t[t]===_;return e.t[t]=o,e.i=r(t,e.i),n},m=(e,t)=>{if(!e.l)return 0;if(e.i>=t)return e.u[t];e.i<0&&(e.u[0]=0,e.i=0);let o=e.i,n=e.u[o];for(;o<t;)n+=p(e,o),e.u[++o]=n;return e.i=t,n},w=(e,t,o=0,n=e.l-1)=>{for(;o<=n;){const r=l((o+n)/2),i=m(e,r);if(i<=t){if(i+p(e,r)>t)return r;o=r+1}else n=r-1}return u(o,0,e.l-1)},S=(e,t,o)=>{const n=t-e.l;return e.i=o?-1:r(t-1,e.i),e.l=t,n>0?(v(e.u,n),v(e.t,n,o),e.o*n):(e.u.splice(n),(o?e.t.splice(0,-n):e.t.splice(n)).reduce(((t,o)=>t-(o===_?e.o:o)),0))},y="undefined"!=typeof window,b=()=>document.documentElement,x=e=>e.ownerDocument,z=e=>e.defaultView,I=/*#__PURE__*/h((()=>!!y&&"rtl"===getComputedStyle(b()).direction)),k=/*#__PURE__*/h((()=>/iP(hone|od|ad)/.test(navigator.userAgent))),R=/*#__PURE__*/h((()=>"scrollBehavior"in b().style)),C=e=>i(e.h(),e._()),T=(e,t,o,n,s)=>(1!==n&&(e-=i(0,o)),2!==n&&(t+=i(0,o)),[i(e,0),r(t,s-1)]),M=(e,t=40,o=0,l,c=!1)=>{let f=!!o,u=[],a=0,h=0,y=0,b=0,x=0,z=0,I=0,R=0,C=0,T=f?[0,i(o-1,0)]:n,M=[0,0],H=0;const W=((e,t,o)=>({o:o?o[1]:t,t:o&&o[0]?v(o[0].slice(0,r(e,o[0].length)),i(0,e-o[0].length)):v([],e),l:e,i:-1,u:v([],e)}))(e,t,l),E=new Set,J=()=>y-h,q=e=>((e,t,o,n)=>{if(n=r(n,e.l-1),m(e,n)<=t){const r=w(e,t+o,n);return[w(e,t,n,r),r]}{const r=w(e,t,void 0,n);return[r,w(e,t+o,r)]}})(W,e,a,M[0]),B=()=>(e=>e.l?m(e,e.l-1)+p(e,e.l-1):0)(W),O=e=>m(W,e)-z,L=e=>p(W,e),$=e=>{e&&(k()&&0!==R?z+=e:(x+=e,b++))};return{v:()=>u,p:()=>(e=>[e.t.slice(),e.o])(W),m:()=>I?M:(M=q(i(0,J()+z+x)),T?[r(M[0],T[0]),i(M[1],T[1])]:M),S:e=>W.t[e]===_,I:()=>!!T&&W.t.slice(i(0,T[0]-1),r(W.l-1,T[1]+1)+1).includes(_),k:O,R:L,C:()=>W.l,T:()=>y,M:()=>R,_:()=>a,H:()=>h,h:B,W:()=>b,J:()=>(I=x,x=0,[I,2===C||J()+a>=B()]),q(e,t){const o=[e,t];return E.add(o),()=>{E.delete(o)}},B(e,t){let o,r,l=0;switch(e){case 1:{const e=I;I=0;const o=t-y,i=s(o);e&&i<s(e)+1||0!==C||(R=o<0?2:1),f&&(T=n,f=!1),y=t,l=4;const c=J();c>=-a&&c<=B()&&(l+=1,r=i>a);break}case 2:l=8,0!==R&&(o=!0,l+=1),R=0,C=0,T=n;break;case 3:{const e=t.filter((([e,t])=>W.t[e]!==t));if(!e.length)break;$(e.reduce(((e,[t,o])=>((2===C||(T?t<T[0]:O(t)+(0===R&&0===C?L(t):0)<J()))&&(e+=o-L(t)),e)),0));for(const[t,o]of e){const e=L(t),n=g(W,t,o);c&&(H+=n?o:o-e)}c&&a&&H>a&&($(((e,t)=>{let o=0;const n=e.t.filter(((e,n)=>{const r=e!==_;return r&&n<t&&o++,r})),r=e.o;return e.i=-1,((e.o=(e=>{const t=d(e),o=e.length/2|0;return t.length%2==0?(t[o-1]+t[o])/2:t[o]})(n))-r)*i(t-o,0)})(W,M[0])),c=!1),l=3,r=!0;break}case 4:a!==t&&(a=t,l=3);break;case 5:t[1]?($(S(W,t[0],!0)),C=2,l=1):S(W,t[0]);break;case 6:h=t;break;case 7:C=1;break;case 8:T=q(t),l=1}l&&(u=[],o&&z&&(x+=z,z=0,b++),E.forEach((([e,t])=>{l&e&&t(r)})))}}},H=y?t.useLayoutEffect:t.useEffect,W=(e,t)=>t&&I()?-e:e,E=(e,t,o,r,i,s)=>{const l=Date.now;let c=0,u=!1,d=!1,a=!1,h=!1;const _=(()=>{let t;const o=()=>{t!=n&&clearTimeout(t)},r=()=>{o(),t=f((()=>{t=n,(()=>{if(u||d)return u=!1,void _();a=!1,e.B(2)})()}),150)};return r.O=o,r})(),v=()=>{c=l(),a&&(h=!0),s&&e.B(6,s()),e.B(1,r()),_()},p=t=>{if(u||0===e.M()||t.ctrlKey)return;const n=l()-c;150>n&&50<n&&(o?t.deltaX:t.deltaY)&&(u=!0)},g=()=>{d=!0,a=h=!1},m=()=>{d=!1,k()&&(a=!0)};return t.addEventListener("scroll",v),t.addEventListener("wheel",p,{passive:!0}),t.addEventListener("touchstart",g,{passive:!0}),t.addEventListener("touchend",m,{passive:!0}),{L:()=>{t.removeEventListener("scroll",v),t.removeEventListener("wheel",p),t.removeEventListener("touchstart",g),t.removeEventListener("touchend",m),_.O()},$:()=>{const[t,n]=e.J();t&&(i(W(t,o),n,h),h=!1,n&&e._()>e.h()&&e.B(1,r()))}}},J=(e,t)=>{let o,n,r;const i=t?"scrollLeft":"scrollTop",s=t?"overflowX":"overflowY",l=async(n,s)=>{if(!o)return void a((()=>l(n,s)));r&&r();const c=()=>{let t;return[new Promise(((o,n)=>{t=o,r=n,(e=>!!e._())(e)&&f(n,150)})),e.q(2,(()=>{t&&t()}))]};if(s&&R()){for(;e.B(8,n()),e.I();){const[e,t]=c();try{await e}catch(e){return}finally{t()}}o.scrollTo({[t?"left":"top"]:W(n(),t),behavior:"smooth"})}else for(;;){const[r,s]=c();try{o[i]=W(n(),t),e.B(7),await r}catch(e){return}finally{s()}}};return{A(l){o=l,n=E(e,l,t,(()=>W(l[i],t)),((t,o,n)=>{if(n){const e=l.style,t=e[s];e[s]="hidden",f((()=>{e[s]=t}))}o?(l[i]=e.T()+t,r&&r()):l[i]+=t}))},L(){n&&n.L()},D(e){l((()=>e))},P(t){t+=e.T(),l((()=>t))},X(t,{align:o,smooth:n,offset:r=0}={}){if(t=u(t,0,e.C()-1),"nearest"===o){const n=e.k(t),r=e.T();if(n<r)o="start";else{if(!(n+e.R(t)>r+e._()))return;o="end"}}l((()=>r+e.H()+e.k(t)+("end"===o?e.R(t)-e._():"center"===o?(e.R(t)-e._())/2:0)),n)},$:()=>{n&&n.$()}}},q=(e,t)=>{let o;return{A(n){const r=t?"scrollX":"scrollY",i=x(n),s=z(i),l=i.body,c=(e,t,o,n=0)=>{const r=o?"offsetLeft":"offsetTop",i=n+(o&&I()?s.innerWidth-e[r]-e.offsetWidth:e[r]),l=e.offsetParent;return e!==t&&l?c(l,t,o,i):i};o=E(e,s,t,(()=>W(s[r],t)),((o,n)=>{n?s.scroll({[t?"left":"top"]:e.T()+o}):s.scrollBy(t?o:0,t?0:o)}),(()=>c(n,l,t)))},L(){o&&o.L()},$:()=>{o&&o.$()}}},B=(e,t)=>{const o=J(e,!1),n=J(t,!0);return{A(e){o.A(e),n.A(e)},L(){o.L(),n.L()},D(e,t){o.D(t),n.D(e)},P(e,t){o.P(t),n.P(e)},X(e,t){o.X(t),n.X(e)},$(){o.$(),n.$()}}},O="current",L=(e,t)=>{if(c(e))for(const o of e)L(o,t);else e==n||"boolean"==typeof e||t.push(e)},$=(e,t)=>{const o=e.key;return o!=n?o:"_"+t},A=e=>{const o=t.useRef();return o[O]||(o[O]=e())},D=e=>{const o=t.useRef(e);return H((()=>{o[O]=e}),[e]),o},P=e=>{let t;return{A(o){(t||(t=new(z(x(o)).ResizeObserver)(e))).observe(o)},Y(e){t.unobserve(e)},L(){t&&t.disconnect()}}},X=(e,t)=>{let o;const r=t?"width":"height",i=new WeakMap,s=P((t=>{const s=[];for(const{target:l,contentRect:c}of t)if(l.offsetParent)if(l===o)e.B(4,c[r]);else{const e=i.get(l);e!=n&&s.push([e,c[r]])}s.length&&e.B(3,s)}));return{j(e){s.A(o=e)},U:(e,t)=>(i.set(e,t),s.A(e),()=>{i.delete(e),s.Y(e)}),L:s.L}},Y=(e,t)=>{const o=t?"width":"height",r=t?"innerWidth":"innerHeight",i=new WeakMap,s=P((t=>{const r=[];for(const{target:e,contentRect:s}of t){if(!e.offsetParent)continue;const t=i.get(e);t!=n&&r.push([t,s[o]])}r.length&&e.B(3,r)}));let l;return{j(t){const o=z(x(t)),n=()=>{e.B(4,o[r])};o.addEventListener("resize",n),n(),l=()=>{o.removeEventListener("resize",n)}},U:(e,t)=>(i.set(e,t),s.A(e),()=>{i.delete(e),s.Y(e)}),L(){l&&l(),s.L()}}},j=(e,t)=>{let o;const n="height",r="width",s=new WeakMap,l=new Set,c=new Set,f=new Map,u=(e,t)=>`${e}-${t}`,d=P((d=>{const a=new Set,h=new Set;for(const{target:i,contentRect:l}of d)if(i.offsetParent)if(i===o)e.B(4,l[n]),t.B(4,l[r]);else{const e=s.get(i);if(e){const[t,o]=e,i=u(t,o),s=f.get(i),c=[l[n],l[r]];let d,_;s?(s[0]!==c[0]&&(d=!0),s[1]!==c[1]&&(_=!0)):d=_=!0,d&&a.add(t),_&&h.add(o),(d||_)&&f.set(i,c)}}if(a.size){const t=[];a.forEach((e=>{let o=0;c.forEach((t=>{const n=f.get(u(e,t));n&&(o=i(o,n[0]))})),o&&t.push([e,o])})),e.B(3,t)}if(h.size){const e=[];h.forEach((t=>{let o=0;l.forEach((e=>{const n=f.get(u(e,t));n&&(o=i(o,n[1]))})),o&&e.push([t,o])})),t.B(3,e)}}));return{j(e){d.A(o=e)},U:(e,t,o)=>(s.set(e,[t,o]),l.add(t),c.add(o),d.A(e),()=>{s.delete(e),d.Y(e)}),L:d.L}},U=t.memo((({V:o,F:r,G:i,K:s,N:l,Z:c,ee:f,te:u})=>{const d=t.useRef(n);H((()=>r(d[O],i)),[i]);const a=t.useMemo((()=>{const e={position:l&&u?void 0:"absolute",[f?"height":"width"]:"100%",[f?"top":"left"]:0,[f?I()?"right":"left":"top"]:s,visibility:!l||u?"visible":"hidden"};return f&&(e.display="flex"),e}),[s,l,u,f]);return"string"==typeof c?e.jsx(c,{ref:d,style:a,children:o}):e.jsx(c,{ref:d,style:a,index:i,children:o})})),V=e=>t.useReducer(e.v,void 0,e.v)[1],F=(e,o)=>t.useMemo((()=>{if("function"==typeof e)return[e,o||0];const t=(e=>{const t=[];return L(e,t),t})(e);return[e=>t[e],t.length]}),[e,o]),G=t.forwardRef((({children:r,count:i,overscan:s=4,keepMounted:l,itemSize:c,shift:f,horizontal:u,cache:h,startMargin:_=0,ssrCount:v,as:p="div",item:g="div",scrollRef:m,onScroll:w,onScrollEnd:S,onRangeChange:y},b)=>{const[x,z]=F(r,i),I=t.useRef(n),k=t.useRef(!!v),R=D(w),W=D(S),[E,q,B,L]=A((()=>{const e=!!u,t=M(z,c,v,h,!c);return[t,X(t,e),J(t,e),e]}));z!==E.C()&&E.B(5,[z,f]),_!==E.H()&&E.B(6,_);const P=V(E),[Y,j]=E.m(),G=E.M(),K=E.W(),N=E.h(),Q=[],[Z,ee]=T(Y,j,s,G,z),te=t=>{const o=x(t);return e.jsx(U,{F:q.U,G:t,K:E.k(t),N:E.S(t),Z:g,V:o,ee:L,te:k[O]},$(o,t))};H((()=>{k[O]=!1;const e=E.q(1,(e=>{e?o.flushSync(P):P()})),t=E.q(4,(()=>{R[O]&&R[O](E.T())})),n=E.q(8,(()=>{W[O]&&W[O]()})),r=e=>{q.j(e),B.A(e)};return m?a((()=>r(m[O]))):r(I[O].parentElement),()=>{e(),t(),n(),q.L(),B.L()}}),[]),H((()=>{B.$()}),[K]),t.useEffect((()=>{y&&y(Y,j)}),[Y,j]),t.useImperativeHandle(b,(()=>({get cache(){return E.p()},get scrollOffset(){return E.T()},get scrollSize(){return C(E)},get viewportSize(){return E._()},getItemOffset:E.k,scrollToIndex:B.X,scrollTo:B.D,scrollBy:B.P})),[]);for(let e=Z,t=ee;e<=t;e++)Q.push(te(e));if(l){const e=[],t=[];d(l).forEach((o=>{o<Z&&e.push(te(o)),o>ee&&t.push(te(o))})),Q.unshift(...e),Q.push(...t)}return e.jsx(p,{ref:I,style:{overflowAnchor:"none",flex:"none",position:"relative",visibility:"hidden",width:L?N:"100%",height:L?"100%":N,pointerEvents:0!==G?"none":void 0},children:Q})})),K=t.forwardRef((({children:o,count:r,overscan:i,keepMounted:s,itemSize:l,shift:c,horizontal:f,reverse:u,cache:d,ssrCount:a,item:h,onScroll:_,onScrollEnd:v,onRangeChange:p,style:g,...m},w)=>{const S=t.useRef(n),y=u&&!f;let b=e.jsx(G,{ref:w,scrollRef:y?S:void 0,count:r,overscan:i,keepMounted:s,itemSize:l,shift:c,horizontal:f,cache:d,ssrCount:a,item:h,onScroll:_,onScrollEnd:v,onRangeChange:p,children:o});return y&&(b=e.jsx("div",{style:{visibility:"hidden",display:"flex",flexDirection:"column",justifyContent:"flex-end",minHeight:"100%"},children:b})),e.jsx("div",{ref:S,...m,style:{display:f?"inline-block":"block",[f?"overflowX":"overflowY"]:"auto",contain:"strict",width:"100%",height:"100%",...g},children:b})})),N=t.forwardRef((({children:r,count:i,overscan:s=4,itemSize:l,shift:c,horizontal:f,cache:u,ssrCount:d,as:a="div",item:h="div",onScrollEnd:_,onRangeChange:v},p)=>{const[g,m]=F(r,i),w=t.useRef(n),S=D(_),y=t.useRef(!!d),[b,x,z,I]=A((()=>{const e=!!f,t=M(m,l,d,u,!l);return[t,Y(t,e),q(t,e),e]}));m!==b.C()&&b.B(5,[m,c]);const k=V(b),[R,C]=b.m(),W=b.M(),E=b.W(),J=b.h(),B=[];H((()=>{y[O]=!1;const e=b.q(1,(e=>{e?o.flushSync(k):k()})),t=b.q(8,(()=>{S[O]&&S[O]()})),n=w[O];return x.j(n),z.A(n),()=>{e(),t(),x.L(),z.L()}}),[]),H((()=>{z.$()}),[E]),t.useEffect((()=>{v&&v(R,C)}),[R,C]),t.useImperativeHandle(p,(()=>({get cache(){return b.p()}})),[]);for(let[t,o]=T(R,C,s,W,m);t<=o;t++){const o=g(t);B.push(e.jsx(U,{F:x.U,G:t,K:b.k(t),N:b.S(t),Z:h,V:o,ee:I,te:y[O]},$(o,t)))}return e.jsx(a,{ref:w,style:{flex:"none",position:"relative",visibility:"hidden",width:I?J:"100%",height:I?"100%":J,pointerEvents:0!==W?"none":void 0},children:B})})),Q=(e,t)=>`${e}-${t}`,Z=t.memo((({V:o,F:r,oe:i,ne:s,re:l,ie:c,se:f,le:u,N:d,ce:a})=>{const h=t.useRef(n);return H((()=>r.U(h[O],i,s)),[s,i]),e.jsx(a,{ref:h,style:t.useMemo((()=>({display:"grid",position:"absolute",top:l,[I()?"right":"left"]:c,visibility:d?"hidden":"visible",minHeight:f,minWidth:u})),[l,c,u,f,d]),children:o})})),ee=t.forwardRef((({children:r,row:i,col:s,cellHeight:l=40,cellWidth:c=100,overscan:f=2,initialRowCount:u,initialColCount:d,item:a="div",style:h,..._},v)=>{const[p,g,m,w]=A((()=>{const e=M(i,l,u),t=M(s,c,d);return[e,t,j(e,t),B(e,t)]}));i!==p.C()&&p.B(5,[i]),s!==g.C()&&g.B(5,[s]);const S=V(p),y=V(g),[b,x]=p.m(),[z,I]=g.m(),k=p.M(),R=g.M(),W=p.W(),E=g.W(),J=C(p),q=C(g),L=t.useRef(n);H((()=>{const e=L[O],t=p.q(1,(e=>{e?o.flushSync(S):S()})),n=g.q(1,(e=>{e?o.flushSync(y):y()}));return m.j(e),w.A(e),()=>{t(),n(),m.L(),w.L()}}),[]),H((()=>{w.$()}),[W,E]),t.useImperativeHandle(v,(()=>({get scrollTop(){return p.T()},get scrollLeft(){return g.T()},get scrollHeight(){return C(p)},get scrollWidth(){return C(g)},get viewportHeight(){return p._()},get viewportWidth(){return g._()},scrollToIndex:w.X,scrollTo:w.D,scrollBy:w.P})),[]);const $=t.useMemo((()=>{const e=new Map;return(t,o)=>{let n=e.get(Q(t,o));return n||e.set(Q(t,o),n=r({rowIndex:t,colIndex:o})),n}}),[r]),[D,P]=T(b,x,f,k,i),[X,Y]=T(z,I,f,R,s),U=[];for(let t=D;t<=P;t++)for(let o=X;o<=Y;o++)U.push(e.jsx(Z,{F:m,oe:t,ne:o,re:p.k(t),ie:g.k(o),se:p.R(t),le:g.R(o),N:p.S(t)||g.S(o),ce:a,V:$(t,o)},Q(t,o)));return e.jsx("div",{ref:L,..._,style:{overflow:"auto",contain:"strict",width:"100%",height:"100%",...h},children:e.jsx("div",{style:{overflowAnchor:"none",flex:"none",position:"relative",visibility:"hidden",width:q,height:J,pointerEvents:0!==k||0!==R?"none":void 0},children:U})})}));exports.VList=K,exports.Virtualizer=G,exports.WindowVirtualizer=N,exports.experimental_VGrid=ee;
|
|
3
3
|
//# sourceMappingURL=index.js.map
|