virtua 0.30.5 → 0.31.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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ![npm](https://img.shields.io/npm/v/virtua) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/virtua) ![npm](https://img.shields.io/npm/dw/virtua) [![Best of JS](https://img.shields.io/endpoint?url=https://bestofjs-serverless.now.sh/api/project-badge?fullName=inokawa%2Fvirtua%26since=daily)](https://bestofjs.org/projects/virtua) [![check](https://github.com/inokawa/virtua/actions/workflows/check.yml/badge.svg)](https://github.com/inokawa/virtua/actions/workflows/check.yml) [![demo](https://github.com/inokawa/virtua/actions/workflows/demo.yml/badge.svg)](https://github.com/inokawa/virtua/actions/workflows/demo.yml)
4
4
 
5
- > A zero-config, fast and small (~3kB) virtual list (and grid) component for [React](https://github.com/facebook/react), [Vue](https://vuejs.org/) and [Solid](https://www.solidjs.com/).
5
+ > A zero-config, fast and small (~3kB) virtual list (and grid) component for [React](https://github.com/facebook/react), [Vue](https://vuejs.org/), [Solid](https://www.solidjs.com/) and [Svelte](https://svelte.dev/).
6
6
 
7
7
  ![example](./example.gif)
8
8
 
@@ -16,7 +16,7 @@ This project is a challenge to rethink virtualization. The goals are...
16
16
  - **Fast:** Natural virtual scrolling needs optimization in many aspects (eliminate frame drops by reducing CPU usage and GC and [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
- - **Framework agnostic:** [React](https://react.dev/), [Vue](https://vuejs.org/) and [Solid](https://www.solidjs.com/) are supported. We could support other frameworks in the future.
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.
20
20
 
21
21
  ## Demo
22
22
 
@@ -253,6 +253,32 @@ export const App = () => {
253
253
  };
254
254
  ```
255
255
 
256
+ ### Svelte
257
+
258
+ `svelte >= 4.0` is required.
259
+
260
+ ```svelte
261
+ <script lang="ts">
262
+ import { VList } from "virtua/svelte";
263
+
264
+ const sizes = [20, 40, 180, 77];
265
+
266
+ const data = Array.from({ length: 1000 }).map((_, i) => ({ id: i, size: sizes[i % 4] + "px" }));
267
+ </script>
268
+
269
+ <VList {data} let:item style={`height: 100vh;`} getKey={(d) => d.id}>
270
+ <div
271
+ style={`
272
+ height: ${item.size};
273
+ background: white;
274
+ border-bottom: solid 1px #ccc;
275
+ `}
276
+ >
277
+ {item.id}
278
+ </div>
279
+ </VList>
280
+ ```
281
+
256
282
  ## Documentation
257
283
 
258
284
  - [API reference](./docs/API.md)
@@ -308,9 +334,9 @@ Especially for `webpack-dev-server`, [you can filter out the specific error with
308
334
 
309
335
  `viewportSize` will be calculated by ResizeObserver so it's 0 until the first measurement.
310
336
 
311
- #### What is `Cannot find module 'virtua/vue(solid)' or its corresponding type declarations` error?
337
+ #### What is `Cannot find module 'virtua/vue(solid|svelte)' or its corresponding type declarations` error?
312
338
 
313
- This package uses [exports of package.json](https://nodejs.org/api/packages.html#package-entry-points) for entry point of Vue/Solid adapter. This field can't be resolved in TypeScript with `moduleResolution: node`. Try `moduleResolution: bundler` or `moduleResolution: nodenext` instead.
339
+ This package uses [exports of package.json](https://nodejs.org/api/packages.html#package-entry-points) for entry point of Vue/Solid/Svelte adapter. This field can't be resolved in TypeScript with `moduleResolution: node`. Try `moduleResolution: bundler` or `moduleResolution: nodenext` instead.
314
340
 
315
341
  ## Comparison
316
342