vlist-vue 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 +74 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.js +1 -0
- package/package.json +56 -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,74 @@
|
|
|
1
|
+
# vlist-vue
|
|
2
|
+
|
|
3
|
+
Vue composable for [vlist](https://github.com/floor/vlist) - lightweight, zero-dependency virtual scrolling.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @floor/vlist vlist-vue
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Composition API
|
|
14
|
+
|
|
15
|
+
```vue
|
|
16
|
+
<script setup>
|
|
17
|
+
import { useVList } from 'vlist-vue';
|
|
18
|
+
import '@floor/vlist/styles';
|
|
19
|
+
|
|
20
|
+
const users = ref([...]);
|
|
21
|
+
|
|
22
|
+
const { containerRef, instance } = useVList({
|
|
23
|
+
item: {
|
|
24
|
+
height: 48,
|
|
25
|
+
template: (user) => `<div class="user">${user.name}</div>`,
|
|
26
|
+
},
|
|
27
|
+
items: users,
|
|
28
|
+
});
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<template>
|
|
32
|
+
<div ref="containerRef" style="height: 400px" />
|
|
33
|
+
</template>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Options API
|
|
37
|
+
|
|
38
|
+
```vue
|
|
39
|
+
<script>
|
|
40
|
+
import { useVList } from 'vlist-vue';
|
|
41
|
+
|
|
42
|
+
export default {
|
|
43
|
+
setup() {
|
|
44
|
+
return useVList({
|
|
45
|
+
item: {
|
|
46
|
+
height: 48,
|
|
47
|
+
template: (user) => `<div>${user.name}</div>`,
|
|
48
|
+
},
|
|
49
|
+
items: [],
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
</script>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## API
|
|
57
|
+
|
|
58
|
+
### `useVList(config)`
|
|
59
|
+
|
|
60
|
+
**Parameters:**
|
|
61
|
+
- `config` - VList configuration (same as core vlist, minus `container`)
|
|
62
|
+
- Can be a reactive `Ref` for automatic updates
|
|
63
|
+
|
|
64
|
+
**Returns:**
|
|
65
|
+
- `containerRef` - Template ref for the container
|
|
66
|
+
- `instance` - Reactive ref to the vlist instance
|
|
67
|
+
|
|
68
|
+
## Documentation
|
|
69
|
+
|
|
70
|
+
For full documentation, see [vlist.dev](https://vlist.dev)
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
MIT © [Floor IO](https://floor.io)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue composable for vlist - lightweight virtual scrolling
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import { type Ref, type ShallowRef } from "vue";
|
|
7
|
+
import type { VListConfig, VListItem, VList, VListEvents, EventHandler } from "@floor/vlist";
|
|
8
|
+
/** Configuration for useVList (VListConfig without container) */
|
|
9
|
+
export type UseVListConfig<T extends VListItem = VListItem> = Omit<VListConfig<T>, "container">;
|
|
10
|
+
/** Return value from the useVList composable */
|
|
11
|
+
export interface UseVListReturn<T extends VListItem = VListItem> {
|
|
12
|
+
/** Template ref to attach to your container element */
|
|
13
|
+
containerRef: Ref<HTMLDivElement | null>;
|
|
14
|
+
/** Reactive ref to the vlist instance */
|
|
15
|
+
instance: ShallowRef<VList<T> | null>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Vue composable for vlist integration.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```vue
|
|
22
|
+
* <script setup>
|
|
23
|
+
* import { useVList } from 'vlist-vue';
|
|
24
|
+
* import { ref } from 'vue';
|
|
25
|
+
*
|
|
26
|
+
* const users = ref([...]);
|
|
27
|
+
*
|
|
28
|
+
* const { containerRef, instance } = useVList({
|
|
29
|
+
* item: {
|
|
30
|
+
* height: 48,
|
|
31
|
+
* template: (user) => `<div>${user.name}</div>`,
|
|
32
|
+
* },
|
|
33
|
+
* items: users,
|
|
34
|
+
* });
|
|
35
|
+
* </script>
|
|
36
|
+
*
|
|
37
|
+
* <template>
|
|
38
|
+
* <div ref="containerRef" style="height: 400px" />
|
|
39
|
+
* </template>
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function useVList<T extends VListItem = VListItem>(configInput: UseVListConfig<T> | Ref<UseVListConfig<T>>): UseVListReturn<T>;
|
|
43
|
+
/**
|
|
44
|
+
* Subscribe to vlist events within Vue lifecycle
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```vue
|
|
48
|
+
* <script setup>
|
|
49
|
+
* const { instance } = useVList(config);
|
|
50
|
+
*
|
|
51
|
+
* useVListEvent(instance, 'selection:change', ({ selected }) => {
|
|
52
|
+
* console.log('Selected:', selected);
|
|
53
|
+
* });
|
|
54
|
+
* </script>
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function useVListEvent<T extends VListItem, K extends keyof VListEvents<T>>(instanceRef: Ref<VList<T> | null> | ShallowRef<VList<T> | null>, event: K, handler: EventHandler<VListEvents<T>[K]>): void;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ref as K,shallowRef as T,onMounted as V,onBeforeUnmount as L,watch as N,isRef as W,unref as X}from"vue";import{vlist as Y}from"@floor/vlist";import{withAsync as Z,withGrid as _,withSections as $,withSelection as J,withScrollbar as A,withScale as G,withSnapshots as H,withPage as M}from"@floor/vlist";function U(z){let E=K(null),q=T(null);if(V(()=>{let x=E.value;if(!x)return;let k=X(z),j=Y({...k,container:x});if(k.scroll?.element===window)j=j.use(M());if(k.adapter)j=j.use(Z({adapter:k.adapter,...k.loading&&{loading:k.loading}}));if(k.layout==="grid"&&k.grid)j=j.use(_(k.grid));if(k.groups)j=j.use($(k.groups));if((k.selection?.mode||"none")!=="none")j=j.use(J(k.selection));else j=j.use(J({mode:"none"}));j=j.use(G());let D=k.scroll?.scrollbar||k.scrollbar;if(D!=="none"){let Q=typeof D==="object"?D:{};j=j.use(A(Q))}j=j.use(H()),q.value=j.build()}),L(()=>{q.value?.destroy(),q.value=null}),W(z))N(()=>z.value.items,(x)=>{if(q.value&&x)q.value.setItems(x)});return{containerRef:E,instance:q}}function y(z,E,q){let x=K(q);N(()=>z.value,(k)=>{if(!k)return;let j=(D)=>{x.value(D)},F=k.on(E,j);L(()=>{F()})},{immediate:!0})}export{y as useVListEvent,U as useVList};
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vlist-vue",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Vue composable 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-vue.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"vlist",
|
|
15
|
+
"virtual-list",
|
|
16
|
+
"vue",
|
|
17
|
+
"composable",
|
|
18
|
+
"virtual-scrolling",
|
|
19
|
+
"typescript"
|
|
20
|
+
],
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"type": "module",
|
|
23
|
+
"main": "./dist/index.js",
|
|
24
|
+
"module": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js",
|
|
30
|
+
"default": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./package.json": "./package.json"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@floor/vlist": "^0.6.0",
|
|
36
|
+
"vue": ">=3.0.0"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist/**/*.js",
|
|
40
|
+
"dist/**/*.d.ts",
|
|
41
|
+
"!dist/**/*.d.ts.map"
|
|
42
|
+
],
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "bun run build.ts",
|
|
45
|
+
"dev": "bun run build.ts --watch",
|
|
46
|
+
"typecheck": "tsc --noEmit",
|
|
47
|
+
"prepublishOnly": "bun run build"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@floor/vlist": "link:../vlist",
|
|
51
|
+
"@types/bun": "^1.0.0",
|
|
52
|
+
"bun": "^1.0.0",
|
|
53
|
+
"typescript": "^5.0.0",
|
|
54
|
+
"vue": "^3.5.28"
|
|
55
|
+
}
|
|
56
|
+
}
|