@mui/x-virtualizer 0.1.0 → 0.1.2

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.
@@ -38,7 +38,7 @@ export interface DimensionsState {
38
38
  */
39
39
  scrollbarSize: number;
40
40
  /**
41
- * Width of a row.
41
+ * Width of a row. At least as wide as `viewportOuterSize.width`.
42
42
  */
43
43
  rowWidth: number;
44
44
  /**
@@ -46,7 +46,7 @@ export interface DimensionsState {
46
46
  */
47
47
  rowHeight: number;
48
48
  /**
49
- * Size of all the visible columns.
49
+ * Size of all the columns.
50
50
  */
51
51
  columnsTotalWidth: number;
52
52
  /**
@@ -57,22 +57,6 @@ export interface DimensionsState {
57
57
  * Size of right pinned columns.
58
58
  */
59
59
  rightPinnedWidth: number;
60
- /**
61
- * Height of one column header.
62
- */
63
- headerHeight: number;
64
- /**
65
- * Height of one column group header.
66
- */
67
- groupHeaderHeight: number;
68
- /**
69
- * Height of header filters.
70
- */
71
- headerFilterHeight: number;
72
- /**
73
- * Height of all the column headers.
74
- */
75
- headersTotalHeight: number;
76
60
  /**
77
61
  * Size of the top container.
78
62
  */
@@ -103,21 +87,6 @@ export interface RowsMetaState {
103
87
  */
104
88
  pinnedBottomRowsTotalHeight: number;
105
89
  }
106
- export interface RowVisibilityParams {
107
- /**
108
- * Whether this row is the first visible or not.
109
- */
110
- isFirstVisible: boolean;
111
- /**
112
- * Whether this row is the last visible or not.
113
- */
114
- isLastVisible: boolean;
115
- /**
116
- * Index of the row in the current page.
117
- * If the pagination is disabled, it will be the index relative to all filtered rows.
118
- */
119
- indexRelativeToCurrentPage: number;
120
- }
121
90
  export interface RowSpacing {
122
91
  top?: number;
123
92
  bottom?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-virtualizer",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "author": "MUI Team",
5
5
  "description": "MUI virtualization library",
6
6
  "license": "MIT",
@@ -27,8 +27,9 @@
27
27
  "directory": "packages/x-virtualizer"
28
28
  },
29
29
  "dependencies": {
30
- "@babel/runtime": "^7.27.4",
31
- "@mui/x-internals": "8.9.2"
30
+ "@babel/runtime": "^7.28.2",
31
+ "@mui/utils": "^7.3.1",
32
+ "@mui/x-internals": "8.10.0"
32
33
  },
33
34
  "peerDependencies": {
34
35
  "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
@@ -37,31 +38,41 @@
37
38
  "engines": {
38
39
  "node": ">=14.0.0"
39
40
  },
40
- "private": false,
41
+ "type": "commonjs",
42
+ "main": "./index.js",
43
+ "types": "./index.d.ts",
41
44
  "exports": {
42
45
  "./package.json": "./package.json",
43
46
  ".": {
47
+ "import": {
48
+ "types": "./esm/index.d.ts",
49
+ "default": "./esm/index.js"
50
+ },
44
51
  "require": {
45
52
  "types": "./index.d.ts",
46
53
  "default": "./index.js"
47
- },
54
+ }
55
+ },
56
+ "./useVirtualizer": {
48
57
  "import": {
49
- "types": "./esm/index.d.ts",
50
- "default": "./esm/index.js"
58
+ "types": "./esm/useVirtualizer.d.ts",
59
+ "default": "./esm/useVirtualizer.js"
60
+ },
61
+ "require": {
62
+ "types": "./useVirtualizer.d.ts",
63
+ "default": "./useVirtualizer.js"
51
64
  }
52
65
  },
53
66
  "./*": {
54
- "require": {
55
- "types": "./*/index.d.ts",
56
- "default": "./*/index.js"
57
- },
58
67
  "import": {
59
68
  "types": "./esm/*/index.d.ts",
60
69
  "default": "./esm/*/index.js"
70
+ },
71
+ "require": {
72
+ "types": "./*/index.d.ts",
73
+ "default": "./*/index.js"
61
74
  }
62
75
  },
63
- "./esm": null,
64
- "./modern": null
65
- },
66
- "types": "./index.d.ts"
76
+ "./esm": null
77
+ }
67
78
  }
@@ -5,34 +5,32 @@ import { Colspan } from "./features/colspan.js";
5
5
  import { Dimensions } from "./features/dimensions.js";
6
6
  import { Rowspan } from "./features/rowspan.js";
7
7
  import { Virtualization } from "./features/virtualization.js";
8
- import type { RowId } from "./models/core.js";
9
- import type { HeightEntry, RowSpacing, RowVisibilityParams } from "./models/dimensions.js";
8
+ import type { HeightEntry, RowSpacing } from "./models/dimensions.js";
9
+ import type { ColspanParams } from "./features/colspan.js";
10
+ import type { DimensionsParams } from "./features/dimensions.js";
11
+ import type { VirtualizationParams } from "./features/virtualization.js";
10
12
  import { ColumnWithWidth, FocusedCell, Size, PinnedRows, PinnedColumns, RenderContext, Row, RowEntry } from "./models/index.js";
11
13
  export type Virtualizer = ReturnType<typeof useVirtualizer>;
12
14
  export type VirtualScrollerCompat = Virtualization.State['getters'];
13
15
  export type BaseState = Virtualization.State & Dimensions.State;
14
16
  export type VirtualizerParams = {
15
- scrollbarSize?: number;
16
- dimensions: {
17
- rowHeight: number;
18
- headerHeight: number;
19
- groupHeaderHeight: number;
20
- headerFilterHeight: number;
21
- columnsTotalWidth: number;
22
- headersTotalHeight: number;
23
- leftPinnedWidth: number;
24
- rightPinnedWidth: number;
17
+ refs: {
18
+ container: RefObject<HTMLDivElement | null>;
19
+ scroller: RefObject<HTMLDivElement | null>;
20
+ scrollbarVertical: RefObject<HTMLDivElement | null>;
21
+ scrollbarHorizontal: RefObject<HTMLDivElement | null>;
25
22
  };
23
+ dimensions: DimensionsParams;
24
+ virtualization: VirtualizationParams;
25
+ colspan?: ColspanParams;
26
26
  initialState?: {
27
27
  scroll?: {
28
28
  top: number;
29
29
  left: number;
30
30
  };
31
- dimensions?: Partial<Dimensions.State['dimensions']>;
32
31
  rowSpanning?: Rowspan.State['rowSpanning'];
33
32
  virtualization?: Partial<Virtualization.State['virtualization']>;
34
33
  };
35
- isRtl: boolean;
36
34
  /** current page rows */
37
35
  rows: RowEntry[];
38
36
  /** current page range */
@@ -40,21 +38,12 @@ export type VirtualizerParams = {
40
38
  firstRowIndex: integer;
41
39
  lastRowIndex: integer;
42
40
  } | null;
43
- rowIdToIndexMap: Map<RowId, number>;
44
41
  rowCount: integer;
45
42
  columns: ColumnWithWidth[];
46
- pinnedRows: PinnedRows;
47
- pinnedColumns: PinnedColumns;
48
- refs: {
49
- container: RefObject<HTMLDivElement | null>;
50
- scroller: RefObject<HTMLDivElement | null>;
51
- scrollbarVertical: RefObject<HTMLDivElement | null>;
52
- scrollbarHorizontal: RefObject<HTMLDivElement | null>;
53
- };
54
- hasColSpan: boolean;
55
- contentHeight: number;
56
- minimalContentHeight: number | string;
43
+ pinnedRows?: PinnedRows;
44
+ pinnedColumns?: PinnedColumns;
57
45
  autoHeight: boolean;
46
+ minimalContentHeight?: number | string;
58
47
  getRowHeight?: (row: RowEntry) => number | null | undefined | 'auto';
59
48
  /**
60
49
  * Function that returns the estimated height for a row.
@@ -67,10 +56,9 @@ export type VirtualizerParams = {
67
56
  /**
68
57
  * Function that allows to specify the spacing between rows.
69
58
  * @param rowEntry
70
- * @param visibility With all properties from [[RowVisibilityParams]].
71
59
  * @returns The row spacing values.
72
60
  */
73
- getRowSpacing?: (rowEntry: RowEntry, visibility: RowVisibilityParams) => RowSpacing;
61
+ getRowSpacing?: (rowEntry: RowEntry) => RowSpacing;
74
62
  /** Update the row height values before they're used.
75
63
  * Used to add detail panel heights.
76
64
  * @param entry
@@ -87,11 +75,8 @@ export type VirtualizerParams = {
87
75
  top: number;
88
76
  left: number;
89
77
  }, nextRenderContext: RenderContext) => void;
90
- focusedVirtualCell: () => FocusedCell | null;
91
- rowBufferPx: number;
92
- columnBufferPx: number;
78
+ focusedVirtualCell?: () => FocusedCell | null;
93
79
  scrollReset?: any;
94
- getColspan: (rowId: RowId, column: ColumnWithWidth, columnIndex: integer) => number;
95
80
  renderRow: (params: {
96
81
  id: any;
97
82
  model: Row;
@@ -99,7 +84,6 @@ export type VirtualizerParams = {
99
84
  offsetLeft: number;
100
85
  columnsTotalWidth: number;
101
86
  baseRowHeight: number | 'auto';
102
- columns: ColumnWithWidth[];
103
87
  firstColumnIndex: number;
104
88
  lastColumnIndex: number;
105
89
  focusedColumnIndex: number | undefined;
@@ -116,29 +100,29 @@ export declare const useVirtualizer: (params: VirtualizerParams) => {
116
100
  updateDimensions: () => void;
117
101
  debouncedUpdateDimensions: ((() => void) & import("@mui/x-internals/throttle/throttle").Cancelable) | undefined;
118
102
  rowsMeta: {
119
- getRowHeight: (rowId: RowId) => any;
103
+ getRowHeight: (rowId: import("./models/index.js").RowId) => any;
120
104
  setLastMeasuredRowIndex: (index: number) => void;
121
- storeRowHeightMeasurement: (id: RowId, height: number) => void;
105
+ storeRowHeightMeasurement: (id: import("./models/index.js").RowId, height: number) => void;
122
106
  hydrateRowsMeta: () => void;
123
- observeRowHeight: (element: Element, rowId: RowId) => () => void | undefined;
124
- rowHasAutoHeight: (id: RowId) => any;
125
- getRowHeightEntry: (rowId: RowId) => any;
107
+ observeRowHeight: (element: Element, rowId: import("./models/index.js").RowId) => () => void | undefined;
108
+ rowHasAutoHeight: (id: import("./models/index.js").RowId) => any;
109
+ getRowHeightEntry: (rowId: import("./models/index.js").RowId) => any;
126
110
  getLastMeasuredRowIndex: () => number;
127
111
  resetRowHeights: () => void;
128
112
  };
129
113
  } & {
130
114
  getters: {
131
115
  setPanels: React.Dispatch<React.SetStateAction<Readonly<Map<any, React.ReactNode>>>>;
132
- getRows: (rowParams: {
116
+ getRows: (rowParams?: {
133
117
  rows?: RowEntry[];
134
118
  position?: import("./models/index.js").PinnedRowPosition;
135
119
  renderContext?: RenderContext;
136
- } | undefined, unstable_rowTree: Record<RowId, any>) => React.ReactNode[];
120
+ }, unstable_rowTree?: Record<import("./models/index.js").RowId, any>) => React.ReactNode[];
137
121
  getContainerProps: () => {
138
- ref: React.RefObject<HTMLDivElement | null>;
122
+ ref: (node: HTMLDivElement | null) => void;
139
123
  };
140
124
  getScrollerProps: () => {
141
- ref: React.RefObject<HTMLDivElement | null>;
125
+ ref: (node: HTMLDivElement | null) => void;
142
126
  onScroll: () => void;
143
127
  onWheel: ((event: React.WheelEvent) => void) | undefined;
144
128
  onTouchMove: ((event: React.TouchEvent) => void) | undefined;
@@ -147,22 +131,19 @@ export declare const useVirtualizer: (params: VirtualizerParams) => {
147
131
  tabIndex: number | undefined;
148
132
  };
149
133
  getContentProps: () => {
150
- style: React.CSSProperties;
151
- role: string;
152
134
  ref: (node: HTMLDivElement | null) => void;
153
- };
154
- getRenderZoneProps: () => {
135
+ style: React.CSSProperties;
155
136
  role: string;
156
137
  };
157
138
  getScrollbarVerticalProps: () => {
158
- ref: React.RefObject<HTMLDivElement | null>;
139
+ ref: (node: HTMLDivElement | null) => void;
159
140
  scrollPosition: React.RefObject<{
160
141
  top: number;
161
142
  left: number;
162
143
  }>;
163
144
  };
164
145
  getScrollbarHorizontalProps: () => {
165
- ref: React.RefObject<HTMLDivElement | null>;
146
+ ref: (node: HTMLDivElement | null) => void;
166
147
  scrollPosition: React.RefObject<{
167
148
  top: number;
168
149
  left: number;
@@ -178,13 +159,13 @@ export declare const useVirtualizer: (params: VirtualizerParams) => {
178
159
  useVirtualization: () => BaseState;
179
160
  setPanels: React.Dispatch<React.SetStateAction<Readonly<Map<any, React.ReactNode>>>>;
180
161
  forceUpdateRenderContext: () => void;
181
- getCellColSpanInfo: (rowId: RowId, columnIndex: integer) => import("./models/index.js").CellColSpanInfo;
182
- calculateColSpan: (rowId: RowId, minFirstColumn: integer, maxLastColumn: integer, columns: ColumnWithWidth[]) => void;
183
- getHiddenCellsOrigin: () => Record<RowId, Record<number, number>>;
162
+ getCellColSpanInfo: (rowId: import("./models/index.js").RowId, columnIndex: integer) => import("./models/index.js").CellColSpanInfo;
163
+ calculateColSpan: (rowId: import("./models/index.js").RowId, minFirstColumn: integer, maxLastColumn: integer, columns: ColumnWithWidth[]) => void;
164
+ getHiddenCellsOrigin: () => Record<import("./models/index.js").RowId, Record<number, number>>;
184
165
  } & {
185
166
  resetColSpan: () => void;
186
- getCellColSpanInfo: (rowId: RowId, columnIndex: integer) => import("./models/index.js").CellColSpanInfo | undefined;
187
- calculateColSpan: (rowId: RowId, minFirstColumn: integer, maxLastColumn: integer, columns: ColumnWithWidth[]) => void;
167
+ getCellColSpanInfo: (rowId: import("./models/index.js").RowId, columnIndex: integer) => import("./models/index.js").CellColSpanInfo | undefined;
168
+ calculateColSpan: (rowId: import("./models/index.js").RowId, minFirstColumn: integer, maxLastColumn: integer, columns: ColumnWithWidth[]) => void;
188
169
  } & {
189
170
  getHiddenCellsOrigin: () => Record<number, Record<number, number>>;
190
171
  } & {