virtua 0.5.0 → 0.6.1

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.
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, ReactNode } from "react";
2
- import { CustomWindowComponent, WindowComponentAttributes } from "..";
2
+ import { CustomViewportComponent, ViewportComponentAttributes } from "..";
3
3
  /**
4
4
  * Props of customized cell component for {@link VGrid}.
5
5
  */
@@ -47,7 +47,7 @@ export interface VGridHandle {
47
47
  /**
48
48
  * Props of {@link VGrid}.
49
49
  */
50
- export interface VGridProps extends WindowComponentAttributes {
50
+ export interface VGridProps extends ViewportComponentAttributes {
51
51
  /**
52
52
  * A function to create elements rendered by this component.
53
53
  */
@@ -97,15 +97,20 @@ export interface VGridProps extends WindowComponentAttributes {
97
97
  */
98
98
  rtl?: boolean;
99
99
  /**
100
- * Customized element type for scrollable element. This element will get {@link CustomWindowComponentProps} as props.
101
- * @defaultValue {@link Window}
100
+ * Customized components for advanced usage.
102
101
  */
103
- element?: CustomWindowComponent;
104
- /**
105
- * Customized element type for cell element. This element will get {@link CustomCellComponentProps} as props.
106
- * @defaultValue "div"
107
- */
108
- cellElement?: CustomCellComponentOrElement;
102
+ components?: {
103
+ /**
104
+ * Component for scrollable element. This component will get {@link CustomViewportComponentProps} as props.
105
+ * @defaultValue {@link DefaultViewport}
106
+ */
107
+ Root?: CustomViewportComponent;
108
+ /**
109
+ * Component or element type for cell element. This component will get {@link CustomCellComponentProps} as props.
110
+ * @defaultValue "div"
111
+ */
112
+ Cell?: CustomCellComponentOrElement;
113
+ };
109
114
  }
110
115
  /**
111
116
  * Virtualized grid component. See {@link VGridProps} and {@link VGridHandle}.
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from "react";
2
- import { WindowComponentAttributes } from "..";
3
- import { CustomWindowComponent } from "./Window";
2
+ import { ViewportComponentAttributes } from "..";
3
+ import { CustomViewportComponent } from "./Viewport";
4
4
  import { CustomItemComponent } from "./ListItem";
5
5
  import { CacheSnapshot } from "../core/types";
6
6
  export type ScrollMode = "reverse" | "rtl";
@@ -44,7 +44,7 @@ export interface VListHandle {
44
44
  /**
45
45
  * Props of {@link VList}.
46
46
  */
47
- export interface VListProps extends WindowComponentAttributes {
47
+ export interface VListProps extends ViewportComponentAttributes {
48
48
  /**
49
49
  * Elements rendered by this component.
50
50
  */
@@ -81,15 +81,20 @@ export interface VListProps extends WindowComponentAttributes {
81
81
  */
82
82
  cache?: CacheSnapshot;
83
83
  /**
84
- * Customized element type for scrollable element. This element will get {@link CustomWindowComponentProps} as props.
85
- * @defaultValue {@link Window}
86
- */
87
- element?: CustomWindowComponent;
88
- /**
89
- * Customized element type for item element. This element will get {@link CustomItemComponentProps} as props.
90
- * @defaultValue "div"
91
- */
92
- itemElement?: CustomItemComponentOrElement;
84
+ * Customized components for advanced usage.
85
+ */
86
+ components?: {
87
+ /**
88
+ * Component for scrollable element. This component will get {@link CustomViewportComponentProps} as props.
89
+ * @defaultValue {@link DefaultViewport}
90
+ */
91
+ Root?: CustomViewportComponent;
92
+ /**
93
+ * Component or element type for item element. This component will get {@link CustomItemComponentProps} as props.
94
+ * @defaultValue "div"
95
+ */
96
+ Item?: CustomItemComponentOrElement;
97
+ };
93
98
  /**
94
99
  * Callback invoked whenever scroll offset changes.
95
100
  * @param offset Current scrollTop or scrollLeft.
@@ -1,9 +1,9 @@
1
1
  import { ReactNode } from "react";
2
- export type WindowComponentAttributes = Pick<React.HTMLAttributes<HTMLElement>, "className" | "style" | "id" | "role" | "tabIndex"> & React.AriaAttributes;
2
+ export type ViewportComponentAttributes = Pick<React.HTMLAttributes<HTMLElement>, "className" | "style" | "id" | "role" | "tabIndex"> & React.AriaAttributes;
3
3
  /**
4
4
  * Props of customized scrollable component.
5
5
  */
6
- export interface CustomWindowComponentProps {
6
+ export interface CustomViewportComponentProps {
7
7
  /**
8
8
  * Renderable item elements.
9
9
  */
@@ -11,7 +11,7 @@ export interface CustomWindowComponentProps {
11
11
  /**
12
12
  * Attributes that should be passed to the scrollable element.
13
13
  */
14
- attrs: WindowComponentAttributes;
14
+ attrs: ViewportComponentAttributes;
15
15
  /**
16
16
  * Total height of items. It's undefined if component is not vertically scrollable.
17
17
  */
@@ -25,5 +25,5 @@ export interface CustomWindowComponentProps {
25
25
  */
26
26
  scrolling: boolean;
27
27
  }
28
- export declare const Window: import("react").ForwardRefExoticComponent<CustomWindowComponentProps & import("react").RefAttributes<any>>;
29
- export type CustomWindowComponent = typeof Window;
28
+ export declare const Viewport: import("react").ForwardRefExoticComponent<CustomViewportComponentProps & import("react").RefAttributes<any>>;
29
+ export type CustomViewportComponent = typeof Viewport;
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from "react";
2
- import { CacheSnapshot, WindowComponentAttributes } from "..";
3
- import { CustomWindowComponent } from "./Window";
2
+ import { CacheSnapshot, ViewportComponentAttributes } from "..";
3
+ import { CustomViewportComponent } from "./Viewport";
4
4
  import { CustomItemComponent } from "./ListItem";
5
5
  type CustomItemComponentOrElement = keyof JSX.IntrinsicElements | CustomItemComponent;
6
6
  /**
@@ -15,7 +15,7 @@ export interface WVListHandle {
15
15
  /**
16
16
  * Props of {@link WVList}.
17
17
  */
18
- export interface WVListProps extends WindowComponentAttributes {
18
+ export interface WVListProps extends ViewportComponentAttributes {
19
19
  /**
20
20
  * Elements rendered by this component.
21
21
  */
@@ -45,15 +45,20 @@ export interface WVListProps extends WindowComponentAttributes {
45
45
  */
46
46
  cache?: CacheSnapshot;
47
47
  /**
48
- * Customized element type for scrollable element. This element will get {@link CustomWindowComponentProps} as props.
49
- * @defaultValue {@link Window}
48
+ * Customized components for advanced usage.
50
49
  */
51
- element?: CustomWindowComponent;
52
- /**
53
- * Customized element type for item element. This element will get {@link CustomItemComponentProps} as props.
54
- * @defaultValue "div"
55
- */
56
- itemElement?: CustomItemComponentOrElement;
50
+ components?: {
51
+ /**
52
+ * Component for scrollable element. This component will get {@link CustomViewportComponentProps} as props.
53
+ * @defaultValue {@link DefaultViewport}
54
+ */
55
+ Root?: CustomViewportComponent;
56
+ /**
57
+ * Component or element type for item element. This component will get {@link CustomItemComponentProps} as props.
58
+ * @defaultValue "div"
59
+ */
60
+ Item?: CustomItemComponentOrElement;
61
+ };
57
62
  /**
58
63
  * Callback invoked when scrolling stops.
59
64
  */
@@ -0,0 +1,8 @@
1
+ export { VList } from "./VList";
2
+ export type { VListProps, VListHandle, ScrollMode } from "./VList";
3
+ export { VGrid } from "./VGrid";
4
+ export type { VGridProps, VGridHandle, CustomCellComponent, CustomCellComponentProps, } from "./VGrid";
5
+ export { WVList } from "./WVList";
6
+ export type { WVListProps, WVListHandle } from "./WVList";
7
+ export type { ViewportComponentAttributes, CustomViewportComponent, CustomViewportComponentProps, } from "./Viewport";
8
+ export type { CustomItemComponent, CustomItemComponentProps } from "./ListItem";
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const useLatestRef: <T>(value: T) => import("react").MutableRefObject<T>;
@@ -1,5 +1,6 @@
1
1
  import { ReactElement, ReactFragment, ReactNode } from "react";
2
2
  export declare const refKey = "current";
3
+ export declare const emptyComponents: {};
3
4
  export declare const flattenChildren: (children: ReactNode) => (string | number | ReactElement<any, string | import("react").JSXElementConstructor<any>> | ReactFragment)[];
4
5
  export type MayHaveKey = {
5
6
  key?: React.Key;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "virtua",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
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",
@@ -29,24 +29,24 @@
29
29
  "@emotion/react": "11.10.8",
30
30
  "@emotion/styled": "11.10.8",
31
31
  "@faker-js/faker": "8.0.2",
32
- "@mui/material": "5.12.3",
32
+ "@mui/material": "5.14.2",
33
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-storysource": "7.1.1",
39
- "@storybook/react": "7.1.1",
40
- "@storybook/react-vite": "^7.1.1",
38
+ "@storybook/addon-storysource": "7.2.0",
39
+ "@storybook/react": "7.2.0",
40
+ "@storybook/react-vite": "^7.2.0",
41
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.17",
44
+ "@types/react": "18.2.18",
45
45
  "@types/react-virtualized": "9.21.22",
46
46
  "@types/react-window": "1.8.5",
47
47
  "@typescript-eslint/parser": "6.2.0",
48
48
  "concurrently": "8.2.0",
49
- "eslint": "8.45.0",
49
+ "eslint": "8.46.0",
50
50
  "eslint-plugin-react-hooks": "4.6.0",
51
51
  "jest": "29.6.1",
52
52
  "jest-environment-jsdom": "29.6.1",
@@ -63,16 +63,16 @@
63
63
  "react-virtuoso": "4.4.2",
64
64
  "react-window": "1.8.9",
65
65
  "rimraf": "5.0.1",
66
- "rollup": "3.26.3",
66
+ "rollup": "3.27.0",
67
67
  "rollup-plugin-banner2": "1.2.2",
68
68
  "size-limit": "^8.2.6",
69
- "storybook": "^7.1.1",
69
+ "storybook": "^7.2.0",
70
70
  "ts-jest": "29.1.1",
71
71
  "typedoc": "0.24.8",
72
72
  "typedoc-plugin-markdown": "3.15.4",
73
73
  "typescript": "5.1.6",
74
- "virtua": "^0.4.5",
75
- "vite": "4.4.7",
74
+ "virtua": "^0.6.0",
75
+ "vite": "4.4.8",
76
76
  "wait-on": "7.0.1"
77
77
  },
78
78
  "peerDependencies": {
@@ -1,2 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const useRefWithUpdate: <T>(value: T) => import("react").MutableRefObject<T>;