vlist-solidjs 0.1.0 → 0.1.2

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
@@ -1,11 +1,11 @@
1
1
  # vlist-solidjs
2
2
 
3
- SolidJS primitives for [vlist](https://github.com/floor/vlist) - a lightweight, high-performance virtual list.
3
+ SolidJS primitives for [@floor/vlist](https://github.com/floor/vlist) lightweight, zero-dependency virtual scrolling.
4
4
 
5
- ## Installation
5
+ ## Install
6
6
 
7
7
  ```bash
8
- npm install vlist-solidjs @floor/vlist
8
+ npm install @floor/vlist vlist-solidjs
9
9
  ```
10
10
 
11
11
  ## Quick Start
@@ -13,70 +13,36 @@ npm install vlist-solidjs @floor/vlist
13
13
  ```tsx
14
14
  import { createVList } from 'vlist-solidjs';
15
15
  import { createSignal } from 'solid-js';
16
+ import '@floor/vlist/styles';
16
17
 
17
- function MyList() {
18
- const [items] = createSignal(
19
- Array.from({ length: 10000 }, (_, i) => ({
20
- id: i,
21
- name: `Item ${i}`
22
- }))
18
+ function UserList() {
19
+ const [users] = createSignal(
20
+ Array.from({ length: 10000 }, (_, i) => ({ id: i, name: `User ${i + 1}` }))
23
21
  );
24
22
 
25
23
  const { setRef, instance } = createVList(() => ({
26
- items: items(),
24
+ items: users(),
27
25
  item: {
28
26
  height: 48,
29
- template: (item) => `<div>${item.name}</div>`
30
- }
27
+ template: (user) => `<div>${user.name}</div>`,
28
+ },
31
29
  }));
32
30
 
33
- return <div ref={setRef} />;
31
+ return <div ref={setRef} style={{ height: '400px' }} />;
34
32
  }
35
33
  ```
36
34
 
37
35
  ## API
38
36
 
39
- ### `createVList(config)`
37
+ - **`createVList(config)`** — Creates a virtual list. Config is an accessor returning the vlist config. Returns `{ setRef, instance }`.
38
+ - **`createVListEvent(instance, event, handler)`** — Subscribe to vlist events with automatic cleanup.
40
39
 
41
- Creates a virtual list instance.
40
+ Config accepts all [@floor/vlist options](https://vlist.dev/docs/api/reference) minus `container` (handled by the ref). Feature fields like `adapter`, `grid`, `groups`, `selection`, and `scrollbar` are translated into `.use(withX())` calls automatically.
42
41
 
43
- **Parameters:**
44
- - `config` - An accessor returning the vlist configuration (without container)
42
+ ## Documentation
45
43
 
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
44
+ Full usage guide, feature config examples, and TypeScript types: **[Framework Adapters — SolidJS](https://vlist.dev/docs/frameworks#solidjs)**
79
45
 
80
46
  ## License
81
47
 
82
- MIT © Floor IO
48
+ MIT © [Floor IO](https://floor.io)
package/dist/index.d.ts CHANGED
@@ -3,12 +3,12 @@
3
3
  */
4
4
  import type { Accessor } from "solid-js";
5
5
  import type { VListConfig, VListItem, VListEvents, EventHandler } from "@floor/vlist";
6
- import { type BuiltVList } from "@floor/vlist";
6
+ import { type VList } from "@floor/vlist";
7
7
  export type UseVListConfig<T extends VListItem = VListItem> = Omit<VListConfig<T>, "container">;
8
8
  export interface CreateVListReturn<T extends VListItem = VListItem> {
9
9
  setRef: (el: HTMLDivElement) => void;
10
- instance: Accessor<BuiltVList<T> | null>;
10
+ instance: Accessor<VList<T> | null>;
11
11
  }
12
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;
13
+ export declare function createVListEvent<T extends VListItem, K extends keyof VListEvents<T>>(instance: Accessor<VList<T> | null>, event: K, handler: EventHandler<VListEvents<T>[K]>): void;
14
14
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1 +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};
1
+ import{onMount as u,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 a,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 u(()=>{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(a(e.selection));else t=t.use(a({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){u(()=>{let r=o();if(!r)return;let l=r.on(n,i);d(()=>{l()})})}export{H as createVListEvent,C as createVList};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vlist-solidjs",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "SolidJS primitives for vlist - lightweight virtual scrolling",
5
5
  "author": {
6
6
  "name": "Floor IO",
@@ -33,7 +33,7 @@
33
33
  "./package.json": "./package.json"
34
34
  },
35
35
  "peerDependencies": {
36
- "@floor/vlist": "^0.6.0",
36
+ "@floor/vlist": "^1.1.2",
37
37
  "solid-js": ">=1.0.0"
38
38
  },
39
39
  "files": [