virtua 0.50.3 → 0.50.4
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/lib/angular/WindowVirtualizer.d.ts +5 -1
- package/lib/angular/index.js +373 -345
- package/lib/angular/index.js.map +1 -1
- package/lib/core/index.cjs +269 -265
- package/lib/core/index.cjs.map +1 -1
- package/lib/core/index.d.ts +2 -0
- package/lib/core/index.js +269 -265
- package/lib/core/index.js.map +1 -1
- package/lib/core/layouts/list.d.ts +1 -0
- package/lib/core/layouts/types.d.ts +1 -0
- package/lib/index.cjs +505 -501
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +410 -406
- package/lib/index.js.map +1 -1
- package/lib/solid/VList.d.ts +1 -1
- package/lib/solid/Virtualizer.d.ts +4 -0
- package/lib/solid/WindowVirtualizer.d.ts +4 -0
- package/lib/solid/index.cjs +315 -301
- package/lib/solid/index.cjs.map +1 -1
- package/lib/solid/index.js +329 -316
- package/lib/solid/index.js.map +1 -1
- package/lib/solid/index.jsx +156 -148
- package/lib/solid/index.jsx.map +1 -1
- package/lib/svelte/Virtualizer.svelte +4 -8
- package/lib/svelte/WindowVirtualizer.svelte +10 -8
- package/lib/svelte/WindowVirtualizer.type.d.ts +4 -0
- package/lib/svelte/utils.js.map +1 -1
- package/lib/vue/WindowVirtualizer.d.ts +4 -0
- package/lib/vue/index.cjs +306 -298
- package/lib/vue/index.cjs.map +1 -1
- package/lib/vue/index.js +300 -292
- package/lib/vue/index.js.map +1 -1
- package/package.json +30 -29
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
UPDATE_SCROLL_EVENT,
|
|
8
8
|
UPDATE_VIRTUAL_STATE,
|
|
9
9
|
createVirtualStore,
|
|
10
|
+
createListLayout,
|
|
10
11
|
getScrollSize as _getScrollSize,
|
|
11
12
|
createWindowDriver,
|
|
12
13
|
scrollToIndex as _scrollToIndex,
|
|
@@ -25,6 +26,7 @@
|
|
|
25
26
|
getKey = defaultGetKey,
|
|
26
27
|
bufferSize,
|
|
27
28
|
itemSize,
|
|
29
|
+
ssrCount,
|
|
28
30
|
shift = false,
|
|
29
31
|
horizontal = false,
|
|
30
32
|
cache,
|
|
@@ -33,13 +35,8 @@
|
|
|
33
35
|
onscrollend,
|
|
34
36
|
}: Props = $props();
|
|
35
37
|
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
itemSize,
|
|
39
|
-
undefined,
|
|
40
|
-
cache,
|
|
41
|
-
!itemSize,
|
|
42
|
-
);
|
|
38
|
+
const layout = createListLayout(data.length, itemSize, cache);
|
|
39
|
+
const store = createVirtualStore(layout, ssrCount);
|
|
43
40
|
const driver = createWindowDriver(store, horizontal);
|
|
44
41
|
store.$subscribe(UPDATE_VIRTUAL_STATE, () => {
|
|
45
42
|
stateVersion = store.$getStateVersion();
|
|
@@ -52,6 +49,8 @@
|
|
|
52
49
|
onscrollend && onscrollend();
|
|
53
50
|
});
|
|
54
51
|
|
|
52
|
+
let isSSR = $state(!!ssrCount);
|
|
53
|
+
|
|
55
54
|
let containerRef: HTMLDivElement | undefined = $state();
|
|
56
55
|
|
|
57
56
|
let stateVersion: StateVersion = $state(store.$getStateVersion());
|
|
@@ -76,6 +75,8 @@
|
|
|
76
75
|
});
|
|
77
76
|
|
|
78
77
|
onMount(() => {
|
|
78
|
+
isSSR = false;
|
|
79
|
+
|
|
79
80
|
driver.$observe(containerRef!);
|
|
80
81
|
});
|
|
81
82
|
onDestroy(() => {
|
|
@@ -97,7 +98,7 @@
|
|
|
97
98
|
});
|
|
98
99
|
|
|
99
100
|
export const getCache =
|
|
100
|
-
|
|
101
|
+
layout.$snapshot satisfies WindowVirtualizerHandle["getCache"] as WindowVirtualizerHandle["getCache"];
|
|
101
102
|
export const getScrollOffset =
|
|
102
103
|
store.$getScrollOffset satisfies WindowVirtualizerHandle["getScrollOffset"] as WindowVirtualizerHandle["getScrollOffset"];
|
|
103
104
|
export const getViewportSize =
|
|
@@ -141,6 +142,7 @@
|
|
|
141
142
|
offset={stateVersion && store.$getItemOffset(index, negative)}
|
|
142
143
|
hide={stateVersion && store.$isUnmeasuredItem(index)}
|
|
143
144
|
{horizontal}
|
|
145
|
+
{isSSR}
|
|
144
146
|
resizer={driver.$observeItem}
|
|
145
147
|
/>
|
|
146
148
|
{/each}
|
|
@@ -29,6 +29,10 @@ export interface WindowVirtualizerProps<T> {
|
|
|
29
29
|
* - If set, you can opt out estimation and use the value as initial item size.
|
|
30
30
|
*/
|
|
31
31
|
itemSize?: number;
|
|
32
|
+
/**
|
|
33
|
+
* A prop for SSR. If set, the specified amount of items will be mounted in the initial rendering regardless of the container size until hydrated. The minimum value is 0.
|
|
34
|
+
*/
|
|
35
|
+
ssrCount?: number;
|
|
32
36
|
/**
|
|
33
37
|
* While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.
|
|
34
38
|
*/
|
package/lib/svelte/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../src/svelte/utils.ts"],"sourcesContent":["export const styleToString = (\n obj: Record<string, string | undefined>,\n): string => {\n return Object.keys(obj).reduce((acc, k) => {\n const value = obj[k];\n if (value == null) {\n return acc;\n }\n return acc + `${k}:${value};`;\n }, \"\");\n};\n\nexport const defaultGetKey = (_data: unknown, i: number) => \"_\" + i;\n\n/**\n * @internal\n */\nexport type ItemAttrs = {\n [key: string]: any;\n style?: Record<string, string | undefined>;\n class?: string;\n};\n\n/**\n * A function that provides properties/attributes for item element\n */\nexport type ItemProps<T = unknown> = (payload: {\n item: T;\n index: number;\n}) => ItemAttrs | undefined;\n"],"mappings":";AAAA,IAAa,iBACX,QACW;CACX,OAAO,OAAO,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../src/svelte/utils.ts"],"sourcesContent":["export const styleToString = (\n obj: Record<string, string | undefined>,\n): string => {\n return Object.keys(obj).reduce((acc, k) => {\n const value = obj[k];\n if (value == null) {\n return acc;\n }\n return acc + `${k}:${value};`;\n }, \"\");\n};\n\nexport const defaultGetKey = (_data: unknown, i: number) => \"_\" + i;\n\n/**\n * @internal\n */\nexport type ItemAttrs = {\n [key: string]: any;\n style?: Record<string, string | undefined>;\n class?: string;\n};\n\n/**\n * A function that provides properties/attributes for item element\n */\nexport type ItemProps<T = unknown> = (payload: {\n item: T;\n index: number;\n}) => ItemAttrs | undefined;\n"],"mappings":";AAAA,IAAa,iBACX,QACW;CACX,OAAO,OAAO,KAAK,GAAG,CAAC,CAAC,QAAQ,KAAK,MAAM;EACzC,MAAM,QAAQ,IAAI;EAClB,IAAI,SAAS,MACX,OAAO;EAET,OAAO,MAAM,GAAG,EAAE,GAAG,MAAM;CAC7B,GAAG,EAAE;AACP;AAEA,IAAa,iBAAiB,OAAgB,MAAc,MAAM"}
|
|
@@ -20,6 +20,10 @@ export interface WindowVirtualizerProps<T = unknown> extends PublicProps {
|
|
|
20
20
|
* - If set, you can opt out estimation and use the value as initial item size.
|
|
21
21
|
*/
|
|
22
22
|
itemSize?: number;
|
|
23
|
+
/**
|
|
24
|
+
* A prop for SSR. If set, the specified amount of items will be mounted in the initial rendering regardless of the container size until hydrated. The minimum value is 0.
|
|
25
|
+
*/
|
|
26
|
+
ssrCount?: number;
|
|
23
27
|
/**
|
|
24
28
|
* While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.
|
|
25
29
|
*/
|