virtua 0.4.4 → 0.5.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 +18 -11
- package/lib/core/cache.d.ts +2 -1
- package/lib/core/store.d.ts +14 -9
- package/lib/core/types.d.ts +10 -0
- package/lib/core/utils.d.ts +0 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/react/VList.d.ts +18 -14
- package/lib/react/WVList.d.ts +26 -18
- package/lib/react/useSelector.d.ts +6 -1
- package/lib/react/utils.d.ts +3 -0
- package/package.json +20 -19
package/lib/react/VList.d.ts
CHANGED
|
@@ -2,12 +2,17 @@ import { ReactNode } from "react";
|
|
|
2
2
|
import { WindowComponentAttributes } from "..";
|
|
3
3
|
import { CustomWindowComponent } from "./Window";
|
|
4
4
|
import { CustomItemComponent } from "./ListItem";
|
|
5
|
+
import { CacheSnapshot } from "../core/types";
|
|
5
6
|
export type ScrollMode = "reverse" | "rtl";
|
|
6
7
|
type CustomItemComponentOrElement = keyof JSX.IntrinsicElements | CustomItemComponent;
|
|
7
8
|
/**
|
|
8
9
|
* Methods of {@link VList}.
|
|
9
10
|
*/
|
|
10
11
|
export interface VListHandle {
|
|
12
|
+
/**
|
|
13
|
+
* Get current {@link CacheSnapshot}.
|
|
14
|
+
*/
|
|
15
|
+
readonly cache: CacheSnapshot;
|
|
11
16
|
/**
|
|
12
17
|
* Get current scrollTop or scrollLeft.
|
|
13
18
|
*/
|
|
@@ -71,6 +76,10 @@ export interface VListProps extends WindowComponentAttributes {
|
|
|
71
76
|
* - `rtl`: You have to set this mode if you use this component under `direction: rtl` style.
|
|
72
77
|
*/
|
|
73
78
|
mode?: ScrollMode;
|
|
79
|
+
/**
|
|
80
|
+
* You can restore cache by passing a {@link CacheSnapshot} on mount. This is useful when you want to restore scroll position after navigation. The snapshot can be obtained from {@link VListHandle.cache}.
|
|
81
|
+
*/
|
|
82
|
+
cache?: CacheSnapshot;
|
|
74
83
|
/**
|
|
75
84
|
* Customized element type for scrollable element. This element will get {@link CustomWindowComponentProps} as props.
|
|
76
85
|
* @defaultValue {@link Window}
|
|
@@ -93,20 +102,15 @@ export interface VListProps extends WindowComponentAttributes {
|
|
|
93
102
|
/**
|
|
94
103
|
* Callback invoked when visible items range changes.
|
|
95
104
|
*/
|
|
96
|
-
onRangeChange?: (
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* The total count of items.
|
|
107
|
-
*/
|
|
108
|
-
count: number;
|
|
109
|
-
}) => void;
|
|
105
|
+
onRangeChange?: (
|
|
106
|
+
/**
|
|
107
|
+
* The start index of viewable items.
|
|
108
|
+
*/
|
|
109
|
+
startIndex: number,
|
|
110
|
+
/**
|
|
111
|
+
* The end index of viewable items.
|
|
112
|
+
*/
|
|
113
|
+
endIndex: number) => void;
|
|
110
114
|
}
|
|
111
115
|
/**
|
|
112
116
|
* Virtualized list component. See {@link VListProps} and {@link VListHandle}.
|
package/lib/react/WVList.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { WindowComponentAttributes } from "..";
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { CacheSnapshot, WindowComponentAttributes } from "..";
|
|
3
3
|
import { CustomWindowComponent } from "./Window";
|
|
4
4
|
import { CustomItemComponent } from "./ListItem";
|
|
5
5
|
type CustomItemComponentOrElement = keyof JSX.IntrinsicElements | CustomItemComponent;
|
|
6
|
+
/**
|
|
7
|
+
* Methods of {@link WVList}.
|
|
8
|
+
*/
|
|
9
|
+
export interface WVListHandle {
|
|
10
|
+
/**
|
|
11
|
+
* Get current {@link CacheSnapshot}.
|
|
12
|
+
*/
|
|
13
|
+
readonly cache: CacheSnapshot;
|
|
14
|
+
}
|
|
6
15
|
/**
|
|
7
16
|
* Props of {@link WVList}.
|
|
8
17
|
*/
|
|
@@ -31,6 +40,10 @@ export interface WVListProps extends WindowComponentAttributes {
|
|
|
31
40
|
* If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.
|
|
32
41
|
*/
|
|
33
42
|
horizontal?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* You can restore cache by passing a {@link CacheSnapshot} on mount. This is useful when you want to restore scroll position after navigation. The snapshot can be obtained from {@link WVListHandle.cache}.
|
|
45
|
+
*/
|
|
46
|
+
cache?: CacheSnapshot;
|
|
34
47
|
/**
|
|
35
48
|
* Customized element type for scrollable element. This element will get {@link CustomWindowComponentProps} as props.
|
|
36
49
|
* @defaultValue {@link Window}
|
|
@@ -48,23 +61,18 @@ export interface WVListProps extends WindowComponentAttributes {
|
|
|
48
61
|
/**
|
|
49
62
|
* Callback invoked when visible items range changes.
|
|
50
63
|
*/
|
|
51
|
-
onRangeChange?: (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* The total count of items.
|
|
62
|
-
*/
|
|
63
|
-
count: number;
|
|
64
|
-
}) => void;
|
|
64
|
+
onRangeChange?: (
|
|
65
|
+
/**
|
|
66
|
+
* The start index of viewable items.
|
|
67
|
+
*/
|
|
68
|
+
startIndex: number,
|
|
69
|
+
/**
|
|
70
|
+
* The end index of viewable items.
|
|
71
|
+
*/
|
|
72
|
+
endIndex: number) => void;
|
|
65
73
|
}
|
|
66
74
|
/**
|
|
67
|
-
* Virtualized list component controlled by the window scrolling. See {@link WVListProps}.
|
|
75
|
+
* Virtualized list component controlled by the window scrolling. See {@link WVListProps} and {@link WVListHandle}.
|
|
68
76
|
*/
|
|
69
|
-
export declare const WVList: (
|
|
77
|
+
export declare const WVList: import("react").ForwardRefExoticComponent<WVListProps & import("react").RefAttributes<WVListHandle>>;
|
|
70
78
|
export {};
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import { VirtualStore } from "../core/store";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const SELECT_RANGE: number;
|
|
3
|
+
export declare const SELECT_SCROLL_SIZE = 2;
|
|
4
|
+
export declare const SELECT_JUMP_COUNT = 4;
|
|
5
|
+
export declare const SELECT_IS_SCROLLING = 8;
|
|
6
|
+
export declare const SELECT_ITEM = 2;
|
|
7
|
+
export declare const useSelector: <T>(store: VirtualStore, getSnapShot: () => T, target: number, shouldGetLatest?: boolean) => T;
|
package/lib/react/utils.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { ReactElement, ReactFragment, ReactNode } from "react";
|
|
2
2
|
export declare const refKey = "current";
|
|
3
3
|
export declare const flattenChildren: (children: ReactNode) => (string | number | ReactElement<any, string | import("react").JSXElementConstructor<any>> | ReactFragment)[];
|
|
4
|
+
export type MayHaveKey = {
|
|
5
|
+
key?: React.Key;
|
|
6
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "virtua",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "A zero-config, fast and small (~3kB) virtual list and grid component for React.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
@@ -23,28 +23,28 @@
|
|
|
23
23
|
"prepublishOnly": "npm run typedoc && rimraf lib && npm run build"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@babel/plugin-transform-react-pure-annotations": "7.
|
|
26
|
+
"@babel/plugin-transform-react-pure-annotations": "7.22.5",
|
|
27
27
|
"@dnd-kit/core": "6.0.8",
|
|
28
28
|
"@dnd-kit/sortable": "7.0.2",
|
|
29
29
|
"@emotion/react": "11.10.8",
|
|
30
30
|
"@emotion/styled": "11.10.8",
|
|
31
31
|
"@faker-js/faker": "8.0.2",
|
|
32
32
|
"@mui/material": "5.12.3",
|
|
33
|
-
"@playwright/test": "^1.36.
|
|
33
|
+
"@playwright/test": "^1.36.2",
|
|
34
34
|
"@rollup/plugin-babel": "6.0.3",
|
|
35
35
|
"@rollup/plugin-terser": "0.4.3",
|
|
36
36
|
"@rollup/plugin-typescript": "11.1.2",
|
|
37
37
|
"@size-limit/preset-small-lib": "^8.2.6",
|
|
38
|
-
"@storybook/addon-
|
|
39
|
-
"@storybook/react": "7.1.
|
|
40
|
-
"@storybook/react-vite": "^7.1.
|
|
41
|
-
"@storybook/test-runner": "0.
|
|
38
|
+
"@storybook/addon-storysource": "7.1.1",
|
|
39
|
+
"@storybook/react": "7.1.1",
|
|
40
|
+
"@storybook/react-vite": "^7.1.1",
|
|
41
|
+
"@storybook/test-runner": "0.12.0",
|
|
42
42
|
"@tanstack/react-virtual": "3.0.0-alpha.0",
|
|
43
43
|
"@testing-library/react": "14.0.0",
|
|
44
|
-
"@types/react": "18.2.
|
|
44
|
+
"@types/react": "18.2.17",
|
|
45
45
|
"@types/react-virtualized": "9.21.22",
|
|
46
46
|
"@types/react-window": "1.8.5",
|
|
47
|
-
"@typescript-eslint/parser": "6.
|
|
47
|
+
"@typescript-eslint/parser": "6.2.0",
|
|
48
48
|
"concurrently": "8.2.0",
|
|
49
49
|
"eslint": "8.45.0",
|
|
50
50
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
@@ -58,21 +58,21 @@
|
|
|
58
58
|
"react-is": "18.2.0",
|
|
59
59
|
"react-merge-refs": "2.0.2",
|
|
60
60
|
"react-pull-to-refresh": "2.0.1",
|
|
61
|
-
"react-select": "5.7.
|
|
61
|
+
"react-select": "5.7.4",
|
|
62
62
|
"react-virtualized": "9.22.5",
|
|
63
|
-
"react-virtuoso": "4.4.
|
|
63
|
+
"react-virtuoso": "4.4.2",
|
|
64
64
|
"react-window": "1.8.9",
|
|
65
|
-
"rimraf": "5.0.
|
|
66
|
-
"rollup": "3.
|
|
65
|
+
"rimraf": "5.0.1",
|
|
66
|
+
"rollup": "3.26.3",
|
|
67
67
|
"rollup-plugin-banner2": "1.2.2",
|
|
68
68
|
"size-limit": "^8.2.6",
|
|
69
|
-
"storybook": "^7.1.
|
|
70
|
-
"ts-jest": "29.1.
|
|
71
|
-
"typedoc": "0.24.
|
|
72
|
-
"typedoc-plugin-markdown": "3.15.
|
|
69
|
+
"storybook": "^7.1.1",
|
|
70
|
+
"ts-jest": "29.1.1",
|
|
71
|
+
"typedoc": "0.24.8",
|
|
72
|
+
"typedoc-plugin-markdown": "3.15.4",
|
|
73
73
|
"typescript": "5.1.6",
|
|
74
|
-
"virtua": "^0.4.
|
|
75
|
-
"vite": "4.4.
|
|
74
|
+
"virtua": "^0.4.5",
|
|
75
|
+
"vite": "4.4.7",
|
|
76
76
|
"wait-on": "7.0.1"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
@@ -92,6 +92,7 @@
|
|
|
92
92
|
"grid",
|
|
93
93
|
"table",
|
|
94
94
|
"flex",
|
|
95
|
+
"scroller",
|
|
95
96
|
"scrolling",
|
|
96
97
|
"virtual",
|
|
97
98
|
"virtualized",
|