virtua 0.4.4 → 0.4.5

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.
@@ -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}
@@ -1,8 +1,17 @@
1
- import { ReactElement, ReactNode } from "react";
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}
@@ -66,5 +79,5 @@ export interface WVListProps extends WindowComponentAttributes {
66
79
  /**
67
80
  * Virtualized list component controlled by the window scrolling. See {@link WVListProps}.
68
81
  */
69
- export declare const WVList: ({ children, overscan, initialItemSize, initialItemCount, horizontal: horizontalProp, element: Window, itemElement, onScrollStop: onScrollStopProp, onRangeChange: onRangeChangeProp, ...windowAttrs }: WVListProps) => ReactElement;
82
+ export declare const WVList: import("react").ForwardRefExoticComponent<WVListProps & import("react").RefAttributes<WVListHandle>>;
70
83
  export {};
@@ -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.4.4",
3
+ "version": "0.4.5",
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,7 +23,7 @@
23
23
  "prepublishOnly": "npm run typedoc && rimraf lib && npm run build"
24
24
  },
25
25
  "devDependencies": {
26
- "@babel/plugin-transform-react-pure-annotations": "7.18.6",
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",
@@ -41,7 +41,7 @@
41
41
  "@storybook/test-runner": "0.11.0",
42
42
  "@tanstack/react-virtual": "3.0.0-alpha.0",
43
43
  "@testing-library/react": "14.0.0",
44
- "@types/react": "18.2.14",
44
+ "@types/react": "18.2.15",
45
45
  "@types/react-virtualized": "9.21.22",
46
46
  "@types/react-window": "1.8.5",
47
47
  "@typescript-eslint/parser": "6.1.0",
@@ -62,17 +62,17 @@
62
62
  "react-virtualized": "9.22.5",
63
63
  "react-virtuoso": "4.4.1",
64
64
  "react-window": "1.8.9",
65
- "rimraf": "5.0.0",
66
- "rollup": "3.23.0",
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
69
  "storybook": "^7.1.0",
70
- "ts-jest": "29.1.0",
70
+ "ts-jest": "29.1.1",
71
71
  "typedoc": "0.24.7",
72
72
  "typedoc-plugin-markdown": "3.15.3",
73
73
  "typescript": "5.1.6",
74
- "virtua": "^0.4.3",
75
- "vite": "4.4.4",
74
+ "virtua": "^0.4.4",
75
+ "vite": "4.4.6",
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",