vlist-solidjs 0.1.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/LICENSE +21 -0
- package/README.md +82 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Floor IO
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# vlist-solidjs
|
|
2
|
+
|
|
3
|
+
SolidJS primitives for [vlist](https://github.com/floor/vlist) - a lightweight, high-performance virtual list.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install vlist-solidjs @floor/vlist
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { createVList } from 'vlist-solidjs';
|
|
15
|
+
import { createSignal } from 'solid-js';
|
|
16
|
+
|
|
17
|
+
function MyList() {
|
|
18
|
+
const [items] = createSignal(
|
|
19
|
+
Array.from({ length: 10000 }, (_, i) => ({
|
|
20
|
+
id: i,
|
|
21
|
+
name: `Item ${i}`
|
|
22
|
+
}))
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const { setRef, instance } = createVList(() => ({
|
|
26
|
+
items: items(),
|
|
27
|
+
item: {
|
|
28
|
+
height: 48,
|
|
29
|
+
template: (item) => `<div>${item.name}</div>`
|
|
30
|
+
}
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
return <div ref={setRef} />;
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## API
|
|
38
|
+
|
|
39
|
+
### `createVList(config)`
|
|
40
|
+
|
|
41
|
+
Creates a virtual list instance.
|
|
42
|
+
|
|
43
|
+
**Parameters:**
|
|
44
|
+
- `config` - An accessor returning the vlist configuration (without container)
|
|
45
|
+
|
|
46
|
+
**Returns:**
|
|
47
|
+
- `setRef` - Ref callback to attach to the container element
|
|
48
|
+
- `instance` - Accessor to the vlist instance
|
|
49
|
+
|
|
50
|
+
### `createVListEvent(instance, event, handler)`
|
|
51
|
+
|
|
52
|
+
Subscribe to vlist events.
|
|
53
|
+
|
|
54
|
+
**Parameters:**
|
|
55
|
+
- `instance` - The vlist instance accessor
|
|
56
|
+
- `event` - Event name
|
|
57
|
+
- `handler` - Event handler function
|
|
58
|
+
|
|
59
|
+
**Example:**
|
|
60
|
+
```tsx
|
|
61
|
+
import { createVListEvent } from 'vlist-solidjs';
|
|
62
|
+
|
|
63
|
+
createVListEvent(instance, 'item:click', ({ item, index }) => {
|
|
64
|
+
console.log('Clicked:', item, 'at index:', index);
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Features
|
|
69
|
+
|
|
70
|
+
All vlist features are supported:
|
|
71
|
+
|
|
72
|
+
- **Selection** - Single and multiple selection modes
|
|
73
|
+
- **Grid layout** - Multi-column grid virtualization
|
|
74
|
+
- **Sections** - Grouped lists with sticky headers
|
|
75
|
+
- **Infinite scroll** - Async data loading
|
|
76
|
+
- **Horizontal** - Horizontal scrolling support
|
|
77
|
+
- **Scale** - Handle 1M+ items with compression
|
|
78
|
+
- **Scrollbar** - Custom scrollbar with auto-hide
|
|
79
|
+
|
|
80
|
+
## License
|
|
81
|
+
|
|
82
|
+
MIT © Floor IO
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SolidJS primitives for vlist - lightweight virtual scrolling
|
|
3
|
+
*/
|
|
4
|
+
import type { Accessor } from "solid-js";
|
|
5
|
+
import type { VListConfig, VListItem, VListEvents, EventHandler } from "@floor/vlist";
|
|
6
|
+
import { type BuiltVList } from "@floor/vlist";
|
|
7
|
+
export type UseVListConfig<T extends VListItem = VListItem> = Omit<VListConfig<T>, "container">;
|
|
8
|
+
export interface CreateVListReturn<T extends VListItem = VListItem> {
|
|
9
|
+
setRef: (el: HTMLDivElement) => void;
|
|
10
|
+
instance: Accessor<BuiltVList<T> | null>;
|
|
11
|
+
}
|
|
12
|
+
export declare function createVList<T extends VListItem = VListItem>(config: Accessor<UseVListConfig<T>>): CreateVListReturn<T>;
|
|
13
|
+
export declare function createVListEvent<T extends VListItem, K extends keyof VListEvents<T>>(instance: Accessor<BuiltVList<T> | null>, event: K, handler: EventHandler<VListEvents<T>[K]>): void;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{onMount as a,onCleanup as d,createEffect as m,on as p}from"solid-js";import{vlist as L}from"@floor/vlist";import{withAsync as g,withGrid as V,withSections as h,withSelection as u,withScrollbar as T,withScale as v,withSnapshots as b,withPage as y}from"@floor/vlist";function C(o){let n=null,i=null,r=(e)=>{n=e},l=()=>i;return a(()=>{if(!n)return;let e=o(),t=L({...e,container:n});if(e.scroll?.element===window)t=t.use(y());if(e.adapter)t=t.use(g({adapter:e.adapter,...e.loading&&{loading:e.loading}}));if(e.layout==="grid"&&e.grid)t=t.use(V(e.grid));if(e.groups){let s=e.groups,f=typeof s.headerHeight==="function"?s.headerHeight("",0):s.headerHeight;t=t.use(h({getGroupForIndex:s.getGroupForIndex,headerHeight:f,headerTemplate:s.headerTemplate,...s.sticky!==void 0&&{sticky:s.sticky}}))}if((e.selection?.mode||"none")!=="none")t=t.use(u(e.selection));else t=t.use(u({mode:"none"}));t=t.use(v());let c=e.scroll?.scrollbar||e.scrollbar;if(c!=="none"){let s=typeof c==="object"?c:{};t=t.use(T(s))}t=t.use(b()),i=t.build()}),m(p(()=>o().items,(e)=>{if(i&&e)i.setItems(e)})),d(()=>{if(i)i.destroy(),i=null}),{setRef:r,instance:l}}function H(o,n,i){a(()=>{let r=o();if(!r)return;let l=r.on(n,i);d(()=>{l()})})}export{H as createVListEvent,C as createVList};
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vlist-solidjs",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "SolidJS primitives for vlist - lightweight virtual scrolling",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Floor IO",
|
|
7
|
+
"url": "https://floor.io"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/floor/vlist-solidjs.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"vlist",
|
|
15
|
+
"virtual-list",
|
|
16
|
+
"solidjs",
|
|
17
|
+
"solid",
|
|
18
|
+
"primitives",
|
|
19
|
+
"virtual-scrolling",
|
|
20
|
+
"typescript"
|
|
21
|
+
],
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"module": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./package.json": "./package.json"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@floor/vlist": "^0.6.0",
|
|
37
|
+
"solid-js": ">=1.0.0"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist/**/*.js",
|
|
41
|
+
"dist/**/*.d.ts",
|
|
42
|
+
"!dist/**/*.d.ts.map"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "bun run build.ts",
|
|
46
|
+
"dev": "bun run build.ts --watch",
|
|
47
|
+
"typecheck": "tsc --noEmit",
|
|
48
|
+
"prepublishOnly": "bun run build"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@floor/vlist": "link:../vlist",
|
|
52
|
+
"@types/bun": "^1.0.0",
|
|
53
|
+
"bun": "^1.0.0",
|
|
54
|
+
"solid-js": "^1.9.3",
|
|
55
|
+
"typescript": "^5.0.0"
|
|
56
|
+
}
|
|
57
|
+
}
|