@mui/x-virtualizer 0.2.10 → 0.2.11

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/constants.d.ts +22 -0
  3. package/constants.js +26 -0
  4. package/esm/constants.d.ts +22 -0
  5. package/esm/constants.js +20 -0
  6. package/esm/features/colspan.d.ts +4 -4
  7. package/esm/features/dimensions.d.ts +14 -8
  8. package/esm/features/dimensions.js +26 -7
  9. package/esm/features/index.d.ts +1 -1
  10. package/esm/features/index.js +1 -1
  11. package/esm/features/keyboard.d.ts +3 -3
  12. package/esm/features/keyboard.js +1 -1
  13. package/esm/features/rowspan.d.ts +4 -4
  14. package/esm/features/virtualization/index.d.ts +2 -0
  15. package/esm/features/virtualization/index.js +2 -0
  16. package/esm/features/virtualization/layout.d.ts +129 -0
  17. package/esm/features/virtualization/layout.js +152 -0
  18. package/esm/features/{virtualization.d.ts → virtualization/virtualization.d.ts} +35 -58
  19. package/esm/features/{virtualization.js → virtualization/virtualization.js} +97 -134
  20. package/esm/index.d.ts +2 -1
  21. package/esm/index.js +3 -2
  22. package/esm/models/core.d.ts +7 -0
  23. package/esm/models/core.js +7 -0
  24. package/esm/models/dimensions.d.ts +8 -0
  25. package/esm/useVirtualizer.d.ts +25 -69
  26. package/esm/useVirtualizer.js +21 -4
  27. package/features/colspan.d.ts +4 -4
  28. package/features/dimensions.d.ts +14 -8
  29. package/features/dimensions.js +26 -7
  30. package/features/index.d.ts +1 -1
  31. package/features/keyboard.d.ts +3 -3
  32. package/features/rowspan.d.ts +4 -4
  33. package/features/virtualization/index.d.ts +2 -0
  34. package/features/virtualization/index.js +27 -0
  35. package/features/virtualization/layout.d.ts +129 -0
  36. package/features/virtualization/layout.js +163 -0
  37. package/features/{virtualization.d.ts → virtualization/virtualization.d.ts} +35 -58
  38. package/features/{virtualization.js → virtualization/virtualization.js} +97 -134
  39. package/index.d.ts +2 -1
  40. package/index.js +12 -1
  41. package/models/core.d.ts +7 -0
  42. package/models/core.js +8 -1
  43. package/models/dimensions.d.ts +8 -0
  44. package/package.json +2 -2
  45. package/useVirtualizer.d.ts +25 -69
  46. package/useVirtualizer.js +20 -3
@@ -62,6 +62,13 @@ export type ScrollPosition = {
62
62
  top: number;
63
63
  left: number;
64
64
  };
65
+ export declare const ScrollPosition: {
66
+ EMPTY: {
67
+ top: number;
68
+ left: number;
69
+ };
70
+ equals: (a: ScrollPosition, b: ScrollPosition) => boolean;
71
+ };
65
72
  export declare enum ScrollDirection {
66
73
  NONE = 0,
67
74
  UP = 1,
@@ -22,6 +22,13 @@ export const PinnedColumns = {
22
22
  right: []
23
23
  }
24
24
  };
25
+ export const ScrollPosition = {
26
+ EMPTY: {
27
+ top: 0,
28
+ left: 0
29
+ },
30
+ equals: (a, b) => a.top === b.top && a.left === b.left
31
+ };
25
32
  export let ScrollDirection = /*#__PURE__*/function (ScrollDirection) {
26
33
  ScrollDirection[ScrollDirection["NONE"] = 0] = "NONE";
27
34
  ScrollDirection[ScrollDirection["UP"] = 1] = "UP";
@@ -65,6 +65,14 @@ export interface DimensionsState {
65
65
  * Size of the bottom container.
66
66
  */
67
67
  bottomContainerHeight: number;
68
+ /**
69
+ * Indicates that the container takes the height of its content.
70
+ */
71
+ autoHeight: boolean;
72
+ /**
73
+ * Minimal height to display the content area.
74
+ */
75
+ minimalContentHeight: string | number | undefined;
68
76
  }
69
77
  /**
70
78
  * The rows total height and positions.
@@ -1,25 +1,21 @@
1
1
  import * as React from 'react';
2
- import { integer, RefObject } from '@mui/x-internals/types';
2
+ import { integer } from '@mui/x-internals/types';
3
3
  import { Store } from '@mui/x-internals/store';
4
4
  import { Colspan } from "./features/colspan.js";
5
5
  import { Dimensions } from "./features/dimensions.js";
6
6
  import { Rowspan } from "./features/rowspan.js";
7
- import { Virtualization } from "./features/virtualization.js";
7
+ import { Virtualization } from "./features/virtualization/index.js";
8
+ import type { Layout } from "./features/virtualization/layout.js";
8
9
  import type { HeightEntry, RowSpacing } from "./models/dimensions.js";
9
10
  import type { ColspanParams } from "./features/colspan.js";
10
11
  import type { DimensionsParams } from "./features/dimensions.js";
11
- import type { VirtualizationParams } from "./features/virtualization.js";
12
+ import type { VirtualizationParams } from "./features/virtualization/index.js";
12
13
  import { ColumnWithWidth, FocusedCell, Size, PinnedRows, PinnedColumns, RenderContext, Row, RowEntry } from "./models/index.js";
13
14
  export type Virtualizer = ReturnType<typeof useVirtualizer>;
14
- export type VirtualScrollerCompat = Virtualization.State['getters'];
15
- export type BaseState = Virtualization.State & Dimensions.State;
16
- export type VirtualizerParams = {
17
- refs: {
18
- container: RefObject<HTMLDivElement | null>;
19
- scroller: RefObject<HTMLDivElement | null>;
20
- scrollbarVertical: RefObject<HTMLDivElement | null>;
21
- scrollbarHorizontal: RefObject<HTMLDivElement | null>;
22
- };
15
+ export type VirtualScrollerCompat<L extends Layout = Layout> = Virtualization.State<L>['getters'];
16
+ export type BaseState<L extends Layout = Layout> = Virtualization.State<L> & Dimensions.State;
17
+ export type VirtualizerParams<L extends Layout = Layout> = {
18
+ layout: L;
23
19
  dimensions: DimensionsParams;
24
20
  virtualization: VirtualizationParams;
25
21
  colspan?: ColspanParams;
@@ -29,7 +25,7 @@ export type VirtualizerParams = {
29
25
  left: number;
30
26
  };
31
27
  rowSpanning?: Rowspan.State['rowSpanning'];
32
- virtualization?: Partial<Virtualization.State['virtualization']>;
28
+ virtualization?: Partial<Virtualization.State<L>['virtualization']>;
33
29
  };
34
30
  /** current page rows */
35
31
  rows: RowEntry[];
@@ -39,13 +35,11 @@ export type VirtualizerParams = {
39
35
  lastRowIndex: integer;
40
36
  } | null;
41
37
  rowCount: integer;
42
- columns: ColumnWithWidth[];
38
+ columns?: ColumnWithWidth[];
43
39
  pinnedRows?: PinnedRows;
44
40
  pinnedColumns?: PinnedColumns;
45
- autoHeight: boolean;
46
41
  disableHorizontalScroll?: boolean;
47
42
  disableVerticalScroll?: boolean;
48
- minimalContentHeight?: number | string;
49
43
  getRowHeight?: (row: RowEntry) => number | null | undefined | 'auto';
50
44
  /**
51
45
  * Function that returns the estimated height for a row.
@@ -68,7 +62,7 @@ export type VirtualizerParams = {
68
62
  */
69
63
  applyRowHeight?: (entry: HeightEntry, rowEntry: RowEntry) => void;
70
64
  virtualizeColumnsWithAutoRowHeight?: boolean;
71
- resizeThrottleMs: number;
65
+ resizeThrottleMs?: number;
72
66
  onResize?: (lastSize: Size) => void;
73
67
  onWheel?: (event: React.WheelEvent) => void;
74
68
  onTouchMove?: (event: React.TouchEvent) => void;
@@ -94,10 +88,15 @@ export type VirtualizerParams = {
94
88
  isVirtualFocusRow: boolean;
95
89
  showBottomBorder: boolean;
96
90
  }) => React.ReactElement;
97
- renderInfiniteLoadingTrigger: (id: any) => React.ReactElement;
91
+ renderInfiniteLoadingTrigger?: (id: any) => React.ReactElement;
92
+ };
93
+ type RequiredFields<T, K extends keyof T> = T & Required<Pick<T, K>>;
94
+ export type ParamsWithDefaults = RequiredFields<VirtualizerParams, 'resizeThrottleMs' | 'columns'> & {
95
+ dimensions: RequiredFields<VirtualizerParams['dimensions'], 'columnsTotalWidth' | 'leftPinnedWidth' | 'rightPinnedWidth' | 'topPinnedHeight' | 'bottomPinnedHeight' | 'autoHeight'>;
96
+ virtualization: RequiredFields<VirtualizerParams['virtualization'], 'isRtl' | 'rowBufferPx' | 'columnBufferPx'>;
98
97
  };
99
- export declare const useVirtualizer: (params: VirtualizerParams) => {
100
- store: Store<Dimensions.State & Virtualization.State & Colspan.State & Rowspan.State>;
98
+ export declare const useVirtualizer: <L extends Layout = Layout>(params: VirtualizerParams<L>) => {
99
+ store: Store<Dimensions.State & Virtualization.State<L> & Colspan.State & Rowspan.State>;
101
100
  api: {
102
101
  updateDimensions: (firstUpdate?: boolean) => void;
103
102
  debouncedUpdateDimensions: (((firstUpdate?: boolean) => void) & import("@mui/x-internals/throttle").Cancelable) | undefined;
@@ -113,57 +112,13 @@ export declare const useVirtualizer: (params: VirtualizerParams) => {
113
112
  resetRowHeights: () => void;
114
113
  };
115
114
  } & {
116
- getters: {
117
- setPanels: React.Dispatch<React.SetStateAction<Readonly<Map<any, React.ReactNode>>>>;
118
- getOffsetTop: () => number;
119
- getRows: (rowParams?: {
120
- rows?: RowEntry[];
121
- position?: import("./models/index.js").PinnedRowPosition;
122
- renderContext?: RenderContext;
123
- }, unstable_rowTree?: Record<import("./models/index.js").RowId, any>) => React.ReactNode[];
124
- rows: RowEntry[];
125
- getContainerProps: () => {
126
- ref: (node: HTMLDivElement | null) => (() => void | undefined) | undefined;
127
- };
128
- getScrollerProps: () => {
129
- ref: (node: HTMLDivElement | null) => (() => void | undefined) | undefined;
130
- style: React.CSSProperties;
131
- role: string;
132
- tabIndex: number | undefined;
133
- };
134
- getContentProps: () => {
135
- ref: (node: HTMLDivElement | null) => void;
136
- style: React.CSSProperties;
137
- role: string;
138
- };
139
- getScrollbarVerticalProps: () => {
140
- ref: (node: HTMLDivElement | null) => void;
141
- scrollPosition: React.RefObject<{
142
- top: number;
143
- left: number;
144
- }>;
145
- };
146
- getScrollbarHorizontalProps: () => {
147
- ref: (node: HTMLDivElement | null) => void;
148
- scrollPosition: React.RefObject<{
149
- top: number;
150
- left: number;
151
- }>;
152
- };
153
- getScrollAreaProps: () => {
154
- scrollPosition: React.RefObject<{
155
- top: number;
156
- left: number;
157
- }>;
158
- };
159
- };
160
- useVirtualization: () => BaseState;
161
- setPanels: React.Dispatch<React.SetStateAction<Readonly<Map<any, React.ReactNode>>>>;
162
- forceUpdateRenderContext: () => void;
163
- scheduleUpdateRenderContext: () => void;
164
115
  getCellColSpanInfo: (rowId: import("./models/index.js").RowId, columnIndex: integer) => import("./models/index.js").CellColSpanInfo;
165
116
  calculateColSpan: (rowId: import("./models/index.js").RowId, minFirstColumn: integer, maxLastColumn: integer, columns: ColumnWithWidth[]) => void;
166
117
  getHiddenCellsOrigin: () => Record<import("./models/index.js").RowId, Record<number, number>>;
118
+ getters: any;
119
+ setPanels: React.Dispatch<React.SetStateAction<Readonly<Map<any, React.ReactNode>>>>;
120
+ forceUpdateRenderContext: () => void;
121
+ scheduleUpdateRenderContext: () => void;
167
122
  } & {
168
123
  resetColSpan: () => void;
169
124
  getCellColSpanInfo: (rowId: import("./models/index.js").RowId, columnIndex: integer) => import("./models/index.js").CellColSpanInfo | undefined;
@@ -173,4 +128,5 @@ export declare const useVirtualizer: (params: VirtualizerParams) => {
173
128
  } & {
174
129
  getViewportPageSize: () => number;
175
130
  };
176
- };
131
+ };
132
+ export {};
@@ -1,10 +1,12 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import useLazyRef from '@mui/utils/useLazyRef';
2
3
  import { Store } from '@mui/x-internals/store';
3
4
  import { Colspan } from "./features/colspan.js";
4
5
  import { Dimensions } from "./features/dimensions.js";
5
6
  import { Keyboard } from "./features/keyboard.js";
6
7
  import { Rowspan } from "./features/rowspan.js";
7
- import { Virtualization } from "./features/virtualization.js";
8
+ import { Virtualization } from "./features/virtualization/index.js";
9
+ import { DEFAULT_PARAMS } from "./constants.js";
8
10
 
9
11
  /* eslint-disable jsdoc/require-param-type */
10
12
  /* eslint-disable jsdoc/require-param-description */
@@ -12,15 +14,30 @@ import { Virtualization } from "./features/virtualization.js";
12
14
 
13
15
  const FEATURES = [Dimensions, Virtualization, Colspan, Rowspan, Keyboard];
14
16
  export const useVirtualizer = params => {
17
+ const paramsWithDefault = mergeDefaults(params, DEFAULT_PARAMS);
15
18
  const store = useLazyRef(() => {
16
- return new Store(FEATURES.map(f => f.initialize(params)).reduce((state, partial) => Object.assign(state, partial), {}));
19
+ return new Store(FEATURES.map(f => f.initialize(paramsWithDefault)).reduce((state, partial) => Object.assign(state, partial), {}));
17
20
  }).current;
18
21
  const api = {};
19
22
  for (const feature of FEATURES) {
20
- Object.assign(api, feature.use(store, params, api));
23
+ Object.assign(api, feature.use(store, paramsWithDefault, api));
21
24
  }
22
25
  return {
23
26
  store,
24
27
  api
25
28
  };
26
- };
29
+ };
30
+ function mergeDefaults(params, defaults) {
31
+ const result = _extends({}, params);
32
+ for (const key in defaults) {
33
+ if (Object.hasOwn(defaults, key)) {
34
+ const value = defaults[key];
35
+ if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
36
+ result[key] = mergeDefaults(params[key] ?? {}, value);
37
+ } else {
38
+ result[key] = params[key] ?? value;
39
+ }
40
+ }
41
+ }
42
+ return result;
43
+ }
@@ -1,9 +1,9 @@
1
1
  import { Store } from '@mui/x-internals/store';
2
2
  import type { integer } from '@mui/x-internals/types';
3
- import type { BaseState, VirtualizerParams } from "../useVirtualizer.js";
3
+ import type { BaseState, ParamsWithDefaults } from "../useVirtualizer.js";
4
4
  import type { ColumnWithWidth, RowId } from "../models/index.js";
5
5
  import type { CellColSpanInfo } from "../models/colspan.js";
6
- import { Virtualization } from "./virtualization.js";
6
+ import { Virtualization } from "./virtualization/index.js";
7
7
  type ColumnIndex = number;
8
8
  type ColspanMap = Map<RowId, Record<ColumnIndex, CellColSpanInfo>>;
9
9
  export type ColspanParams = {
@@ -21,10 +21,10 @@ export declare namespace Colspan {
21
21
  };
22
22
  type API = ReturnType<typeof useColspan>;
23
23
  }
24
- declare function initializeState(_params: VirtualizerParams): {
24
+ declare function initializeState(_params: ParamsWithDefaults): {
25
25
  colspanMap: Map<any, any>;
26
26
  };
27
- declare function useColspan(store: Store<BaseState & Colspan.State>, params: VirtualizerParams, api: Virtualization.API): {
27
+ declare function useColspan(store: Store<BaseState & Colspan.State>, params: ParamsWithDefaults, api: Virtualization.API): {
28
28
  resetColSpan: () => void;
29
29
  getCellColSpanInfo: (rowId: RowId, columnIndex: integer) => CellColSpanInfo | undefined;
30
30
  calculateColSpan: (rowId: RowId, minFirstColumn: integer, maxLastColumn: integer, columns: ColumnWithWidth[]) => void;
@@ -1,13 +1,15 @@
1
1
  import { Store } from '@mui/x-internals/store';
2
2
  import { ColumnWithWidth, DimensionsState, RowId, RowsMetaState, Size } from "../models/index.js";
3
- import type { BaseState, VirtualizerParams } from "../useVirtualizer.js";
3
+ import type { BaseState, ParamsWithDefaults } from "../useVirtualizer.js";
4
4
  export type DimensionsParams = {
5
5
  rowHeight: number;
6
- columnsTotalWidth: number;
7
- leftPinnedWidth: number;
8
- rightPinnedWidth: number;
9
- topPinnedHeight: number;
10
- bottomPinnedHeight: number;
6
+ columnsTotalWidth?: number;
7
+ leftPinnedWidth?: number;
8
+ rightPinnedWidth?: number;
9
+ topPinnedHeight?: number;
10
+ bottomPinnedHeight?: number;
11
+ autoHeight?: boolean;
12
+ minimalContentHeight?: number | string;
11
13
  scrollbarSize?: number;
12
14
  };
13
15
  export declare const Dimensions: {
@@ -17,8 +19,12 @@ export declare const Dimensions: {
17
19
  rootSize: (state: BaseState) => Size;
18
20
  dimensions: (state: BaseState) => DimensionsState;
19
21
  rowHeight: (state: BaseState) => number;
22
+ columnsTotalWidth: (state: BaseState) => number;
20
23
  contentHeight: (state: BaseState) => number;
24
+ autoHeight: (state: BaseState) => boolean;
25
+ minimalContentHeight: (state: BaseState) => string | number | undefined;
21
26
  rowsMeta: (state: BaseState) => RowsMetaState;
27
+ rowPositions: (state: BaseState) => number[];
22
28
  columnPositions: (_: any, columns: ColumnWithWidth[]) => number[];
23
29
  needsHorizontalScrollbar: (state: BaseState) => boolean;
24
30
  };
@@ -32,8 +38,8 @@ export declare namespace Dimensions {
32
38
  };
33
39
  type API = ReturnType<typeof useDimensions>;
34
40
  }
35
- declare function initializeState(params: VirtualizerParams): Dimensions.State;
36
- declare function useDimensions(store: Store<BaseState>, params: VirtualizerParams, _api: {}): {
41
+ declare function initializeState(params: ParamsWithDefaults): Dimensions.State;
42
+ declare function useDimensions(store: Store<BaseState>, params: ParamsWithDefaults, _api: {}): {
37
43
  updateDimensions: (firstUpdate?: boolean) => void;
38
44
  debouncedUpdateDimensions: (((firstUpdate?: boolean) => void) & import("@mui/x-internals/throttle").Cancelable) | undefined;
39
45
  rowsMeta: {
@@ -38,14 +38,20 @@ const EMPTY_DIMENSIONS = {
38
38
  leftPinnedWidth: 0,
39
39
  rightPinnedWidth: 0,
40
40
  topContainerHeight: 0,
41
- bottomContainerHeight: 0
41
+ bottomContainerHeight: 0,
42
+ autoHeight: false,
43
+ minimalContentHeight: undefined
42
44
  };
43
45
  const selectors = {
44
46
  rootSize: state => state.rootSize,
45
47
  dimensions: state => state.dimensions,
46
48
  rowHeight: state => state.dimensions.rowHeight,
49
+ columnsTotalWidth: state => state.dimensions.columnsTotalWidth,
47
50
  contentHeight: state => state.dimensions.contentSize.height,
51
+ autoHeight: state => state.dimensions.autoHeight,
52
+ minimalContentHeight: state => state.dimensions.minimalContentHeight,
48
53
  rowsMeta: state => state.rowsMeta,
54
+ rowPositions: state => state.rowsMeta.positions,
49
55
  columnPositions: (0, _store.createSelectorMemoized)((_, columns) => {
50
56
  const positions = [];
51
57
  let currentPosition = 0;
@@ -63,7 +69,10 @@ const Dimensions = exports.Dimensions = {
63
69
  selectors
64
70
  };
65
71
  function initializeState(params) {
66
- const dimensions = (0, _extends2.default)({}, EMPTY_DIMENSIONS, params.dimensions);
72
+ const dimensions = (0, _extends2.default)({}, EMPTY_DIMENSIONS, params.dimensions, {
73
+ autoHeight: params.dimensions.autoHeight,
74
+ minimalContentHeight: params.dimensions.minimalContentHeight
75
+ });
67
76
  const {
68
77
  rowCount
69
78
  } = params;
@@ -89,7 +98,7 @@ function initializeState(params) {
89
98
  function useDimensions(store, params, _api) {
90
99
  const isFirstSizing = React.useRef(true);
91
100
  const {
92
- refs,
101
+ layout,
93
102
  dimensions: {
94
103
  rowHeight,
95
104
  columnsTotalWidth,
@@ -107,7 +116,7 @@ function useDimensions(store, params, _api) {
107
116
  if (isFirstSizing.current) {
108
117
  return;
109
118
  }
110
- const containerNode = refs.container.current;
119
+ const containerNode = layout.refs.container.current;
111
120
  const rootSize = selectors.rootSize(store.state);
112
121
  const rowsMeta = selectors.rowsMeta(store.state);
113
122
 
@@ -125,7 +134,7 @@ function useDimensions(store, params, _api) {
125
134
  let viewportInnerSize;
126
135
  let hasScrollX = false;
127
136
  let hasScrollY = false;
128
- if (params.autoHeight) {
137
+ if (params.dimensions.autoHeight) {
129
138
  hasScrollY = false;
130
139
  hasScrollX = Math.round(columnsTotalWidth) > Math.round(rootSize.width);
131
140
  viewportOuterSize = {
@@ -192,7 +201,9 @@ function useDimensions(store, params, _api) {
192
201
  leftPinnedWidth,
193
202
  rightPinnedWidth,
194
203
  topContainerHeight,
195
- bottomContainerHeight
204
+ bottomContainerHeight,
205
+ autoHeight: params.dimensions.autoHeight,
206
+ minimalContentHeight: params.dimensions.minimalContentHeight
196
207
  };
197
208
  const prevDimensions = store.state.dimensions;
198
209
  if ((0, _isDeepEqual.isDeepEqual)(prevDimensions, newDimensions)) {
@@ -202,7 +213,7 @@ function useDimensions(store, params, _api) {
202
213
  dimensions: newDimensions
203
214
  });
204
215
  onResize?.(newDimensions.root);
205
- }, [store, refs.container, params.dimensions.scrollbarSize, params.autoHeight, params.disableHorizontalScroll, params.disableVerticalScroll, onResize, rowHeight, columnsTotalWidth, leftPinnedWidth, rightPinnedWidth, topPinnedHeight, bottomPinnedHeight]);
216
+ }, [store, layout.refs.container, params.dimensions.scrollbarSize, params.dimensions.autoHeight, params.dimensions.minimalContentHeight, params.disableHorizontalScroll, params.disableVerticalScroll, onResize, rowHeight, columnsTotalWidth, leftPinnedWidth, rightPinnedWidth, topPinnedHeight, bottomPinnedHeight]);
206
217
  const {
207
218
  resizeThrottleMs
208
219
  } = params;
@@ -210,6 +221,14 @@ function useDimensions(store, params, _api) {
210
221
  const debouncedUpdateDimensions = React.useMemo(() => resizeThrottleMs > 0 ? (0, _throttle.throttle)(updateDimensionCallback, resizeThrottleMs) : undefined, [resizeThrottleMs, updateDimensionCallback]);
211
222
  React.useEffect(() => debouncedUpdateDimensions?.clear, [debouncedUpdateDimensions]);
212
223
  (0, _useEnhancedEffect.default)(updateDimensions, [updateDimensions]);
224
+ (0, _useEnhancedEffect.default)(() => {
225
+ store.update({
226
+ dimensions: (0, _extends2.default)({}, store.state.dimensions, {
227
+ autoHeight: params.dimensions.autoHeight,
228
+ minimalContentHeight: params.dimensions.minimalContentHeight
229
+ })
230
+ });
231
+ }, [store, params.dimensions.autoHeight, params.dimensions.minimalContentHeight]);
213
232
  const rowsMeta = useRowsMeta(store, params, updateDimensions);
214
233
  return {
215
234
  updateDimensions,
@@ -2,4 +2,4 @@ export * from "./colspan.js";
2
2
  export * from "./dimensions.js";
3
3
  export * from "./keyboard.js";
4
4
  export * from "./rowspan.js";
5
- export * from "./virtualization.js";
5
+ export * from "./virtualization/index.js";
@@ -1,5 +1,5 @@
1
1
  import { Store } from '@mui/x-internals/store';
2
- import type { BaseState, VirtualizerParams } from "../useVirtualizer.js";
2
+ import type { BaseState, ParamsWithDefaults } from "../useVirtualizer.js";
3
3
  export declare const Keyboard: {
4
4
  initialize: typeof initializeState;
5
5
  use: typeof useKeyboard;
@@ -9,8 +9,8 @@ export declare namespace Keyboard {
9
9
  type State = {};
10
10
  type API = ReturnType<typeof useKeyboard>;
11
11
  }
12
- declare function initializeState(_params: VirtualizerParams): Keyboard.State;
13
- declare function useKeyboard(store: Store<BaseState & Keyboard.State>, params: VirtualizerParams, _api: {}): {
12
+ declare function initializeState(_params: ParamsWithDefaults): Keyboard.State;
13
+ declare function useKeyboard(store: Store<BaseState & Keyboard.State>, params: ParamsWithDefaults, _api: {}): {
14
14
  getViewportPageSize: () => number;
15
15
  };
16
16
  export {};
@@ -1,7 +1,7 @@
1
1
  import { Store } from '@mui/x-internals/store';
2
- import type { BaseState, VirtualizerParams } from "../useVirtualizer.js";
2
+ import type { BaseState, ParamsWithDefaults } from "../useVirtualizer.js";
3
3
  import type { RowSpanningState } from "../models/rowspan.js";
4
- import { Virtualization } from "./virtualization.js";
4
+ import { Virtualization } from "./virtualization/index.js";
5
5
  export declare const Rowspan: {
6
6
  initialize: typeof initializeState;
7
7
  use: typeof useRowspan;
@@ -18,8 +18,8 @@ export declare namespace Rowspan {
18
18
  };
19
19
  type API = ReturnType<typeof useRowspan>;
20
20
  }
21
- declare function initializeState(params: VirtualizerParams): Rowspan.State;
22
- declare function useRowspan(store: Store<BaseState & Rowspan.State>, _params: VirtualizerParams, _api: Virtualization.API): {
21
+ declare function initializeState(params: ParamsWithDefaults): Rowspan.State;
22
+ declare function useRowspan(store: Store<BaseState & Rowspan.State>, _params: ParamsWithDefaults, _api: Virtualization.API): {
23
23
  getHiddenCellsOrigin: () => Record<number, Record<number, number>>;
24
24
  };
25
25
  export {};
@@ -0,0 +1,2 @@
1
+ export * from "./layout.js";
2
+ export * from "./virtualization.js";
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _layout = require("./layout");
7
+ Object.keys(_layout).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _layout[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _layout[key];
14
+ }
15
+ });
16
+ });
17
+ var _virtualization = require("./virtualization");
18
+ Object.keys(_virtualization).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _virtualization[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _virtualization[key];
25
+ }
26
+ });
27
+ });
@@ -0,0 +1,129 @@
1
+ import * as React from 'react';
2
+ import { Store } from '@mui/x-internals/store';
3
+ import { Dimensions } from "../dimensions.js";
4
+ import { Virtualization, type VirtualizationLayoutParams } from "./virtualization.js";
5
+ import type { BaseState, ParamsWithDefaults } from "../../useVirtualizer.js";
6
+ type RequiredAPI = Dimensions.API;
7
+ type BaseElements = {
8
+ scroller: React.RefObject<HTMLElement | null>;
9
+ container: React.RefObject<HTMLElement | null>;
10
+ };
11
+ type AnyElements = BaseElements & Record<string, React.RefObject<HTMLElement | null>>;
12
+ export declare abstract class Layout<E extends AnyElements = AnyElements> {
13
+ static elements: readonly (keyof AnyElements)[];
14
+ refs: E;
15
+ constructor(refs: E);
16
+ abstract use(store: Store<BaseState>, params: ParamsWithDefaults, api: RequiredAPI, layoutParams: VirtualizationLayoutParams): any;
17
+ refSetter(name: keyof E): (node: HTMLDivElement | null) => void;
18
+ }
19
+ type DataGridElements = BaseElements & {
20
+ scrollbarVertical: React.RefObject<HTMLElement | null>;
21
+ scrollbarHorizontal: React.RefObject<HTMLElement | null>;
22
+ };
23
+ export declare class LayoutDataGrid extends Layout<DataGridElements> {
24
+ static elements: readonly ["scroller", "container", "content", "positioner", "scrollbarVertical", "scrollbarHorizontal"];
25
+ use(store: Store<BaseState>, _params: ParamsWithDefaults, _api: RequiredAPI, layoutParams: VirtualizationLayoutParams): void;
26
+ static selectors: {
27
+ containerProps: (args_0: Virtualization.State<Layout<AnyElements>> & Dimensions.State) => {
28
+ ref: any;
29
+ };
30
+ scrollerProps: (args_0: Virtualization.State<Layout<AnyElements>> & Dimensions.State) => {
31
+ ref: any;
32
+ style: {
33
+ overflowX: string | undefined;
34
+ overflowY: string | undefined;
35
+ };
36
+ role: string;
37
+ tabIndex: number | undefined;
38
+ };
39
+ contentProps: (args_0: Virtualization.State<Layout<AnyElements>> & Dimensions.State) => {
40
+ style: React.CSSProperties;
41
+ role: string;
42
+ };
43
+ positionerProps: (args_0: Virtualization.State<Layout<AnyElements>> & Dimensions.State) => {
44
+ style: {
45
+ transform: string;
46
+ };
47
+ };
48
+ scrollbarHorizontalProps: (args_0: Virtualization.State<Layout<AnyElements>> & Dimensions.State) => {
49
+ ref: any;
50
+ scrollPosition: {
51
+ current: import("../../models/index.js").ScrollPosition;
52
+ };
53
+ };
54
+ scrollbarVerticalProps: (args_0: Virtualization.State<Layout<AnyElements>> & Dimensions.State) => {
55
+ ref: any;
56
+ scrollPosition: {
57
+ current: import("../../models/index.js").ScrollPosition;
58
+ };
59
+ };
60
+ scrollAreaProps: (args_0: Virtualization.State<Layout<AnyElements>> & Dimensions.State) => {
61
+ scrollPosition: {
62
+ current: import("../../models/index.js").ScrollPosition;
63
+ };
64
+ };
65
+ };
66
+ }
67
+ export declare class LayoutDataGridLegacy extends LayoutDataGrid {
68
+ use(store: Store<BaseState>, _params: ParamsWithDefaults, _api: RequiredAPI, layoutParams: VirtualizationLayoutParams): {
69
+ getContainerProps: () => {
70
+ ref: any;
71
+ };
72
+ getScrollerProps: () => {
73
+ ref: any;
74
+ style: {
75
+ overflowX: string | undefined;
76
+ overflowY: string | undefined;
77
+ };
78
+ role: string;
79
+ tabIndex: number | undefined;
80
+ };
81
+ getContentProps: () => {
82
+ style: React.CSSProperties;
83
+ role: string;
84
+ };
85
+ getPositionerProps: () => {
86
+ style: {
87
+ transform: string;
88
+ };
89
+ };
90
+ getScrollbarVerticalProps: () => {
91
+ ref: any;
92
+ scrollPosition: {
93
+ current: import("../../models/index.js").ScrollPosition;
94
+ };
95
+ };
96
+ getScrollbarHorizontalProps: () => {
97
+ ref: any;
98
+ scrollPosition: {
99
+ current: import("../../models/index.js").ScrollPosition;
100
+ };
101
+ };
102
+ getScrollAreaProps: () => {
103
+ scrollPosition: {
104
+ current: import("../../models/index.js").ScrollPosition;
105
+ };
106
+ };
107
+ };
108
+ }
109
+ type ListElements = BaseElements;
110
+ export declare class LayoutList extends Layout<ListElements> {
111
+ static elements: readonly ["scroller", "container", "content", "positioner"];
112
+ use(store: Store<BaseState>, _params: ParamsWithDefaults, _api: RequiredAPI, layoutParams: VirtualizationLayoutParams): void;
113
+ static selectors: {
114
+ containerProps: (args_0: Virtualization.State<Layout<AnyElements>> & Dimensions.State) => {
115
+ ref: any;
116
+ style: React.CSSProperties;
117
+ role: string;
118
+ tabIndex: number | undefined;
119
+ };
120
+ contentProps: (args_0: Virtualization.State<Layout<AnyElements>> & Dimensions.State) => {
121
+ style: React.CSSProperties;
122
+ role: string;
123
+ };
124
+ positionerProps: (args_0: Virtualization.State<Layout<AnyElements>> & Dimensions.State) => {
125
+ style: React.CSSProperties;
126
+ };
127
+ };
128
+ }
129
+ export {};