@mui/x-virtualizer 0.1.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/CHANGELOG.md +10645 -0
- package/README.md +3 -0
- package/esm/features/colspan.d.ts +28 -0
- package/esm/features/colspan.js +88 -0
- package/esm/features/dimensions.d.ts +41 -0
- package/esm/features/dimensions.js +465 -0
- package/esm/features/index.d.ts +5 -0
- package/esm/features/index.js +5 -0
- package/esm/features/keyboard.d.ts +16 -0
- package/esm/features/keyboard.js +35 -0
- package/esm/features/rowspan.d.ts +25 -0
- package/esm/features/rowspan.js +36 -0
- package/esm/features/virtualization.d.ts +103 -0
- package/esm/features/virtualization.js +844 -0
- package/esm/index.d.ts +2 -0
- package/esm/index.js +9 -0
- package/esm/models/colspan.d.ts +13 -0
- package/esm/models/colspan.js +1 -0
- package/esm/models/core.d.ts +72 -0
- package/esm/models/core.js +43 -0
- package/esm/models/dimensions.d.ts +132 -0
- package/esm/models/dimensions.js +1 -0
- package/esm/models/index.d.ts +4 -0
- package/esm/models/index.js +4 -0
- package/esm/models/rowspan.d.ts +17 -0
- package/esm/models/rowspan.js +1 -0
- package/esm/package.json +1 -0
- package/esm/useVirtualizer.d.ts +193 -0
- package/esm/useVirtualizer.js +26 -0
- package/features/colspan.d.ts +28 -0
- package/features/colspan.js +94 -0
- package/features/dimensions.d.ts +41 -0
- package/features/dimensions.js +472 -0
- package/features/index.d.ts +5 -0
- package/features/index.js +60 -0
- package/features/keyboard.d.ts +16 -0
- package/features/keyboard.js +40 -0
- package/features/rowspan.d.ts +25 -0
- package/features/rowspan.js +42 -0
- package/features/virtualization.d.ts +103 -0
- package/features/virtualization.js +853 -0
- package/index.d.ts +2 -0
- package/index.js +34 -0
- package/models/colspan.d.ts +13 -0
- package/models/colspan.js +5 -0
- package/models/core.d.ts +72 -0
- package/models/core.js +49 -0
- package/models/dimensions.d.ts +132 -0
- package/models/dimensions.js +5 -0
- package/models/index.d.ts +4 -0
- package/models/index.js +49 -0
- package/models/rowspan.d.ts +17 -0
- package/models/rowspan.js +5 -0
- package/package.json +67 -0
- package/useVirtualizer.d.ts +193 -0
- package/useVirtualizer.js +33 -0
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mui/x-virtualizer v0.1.0
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
"use strict";
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, "__esModule", {
|
|
11
|
+
value: true
|
|
12
|
+
});
|
|
13
|
+
var _useVirtualizer = require("./useVirtualizer");
|
|
14
|
+
Object.keys(_useVirtualizer).forEach(function (key) {
|
|
15
|
+
if (key === "default" || key === "__esModule") return;
|
|
16
|
+
if (key in exports && exports[key] === _useVirtualizer[key]) return;
|
|
17
|
+
Object.defineProperty(exports, key, {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () {
|
|
20
|
+
return _useVirtualizer[key];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
var _features = require("./features");
|
|
25
|
+
Object.keys(_features).forEach(function (key) {
|
|
26
|
+
if (key === "default" || key === "__esModule") return;
|
|
27
|
+
if (key in exports && exports[key] === _features[key]) return;
|
|
28
|
+
Object.defineProperty(exports, key, {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function () {
|
|
31
|
+
return _features[key];
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { float, integer } from '@mui/x-internals/types';
|
|
2
|
+
export type ColumnIndex = number;
|
|
3
|
+
export type CellColSpanInfo = {
|
|
4
|
+
spannedByColSpan: true;
|
|
5
|
+
rightVisibleCellIndex: ColumnIndex;
|
|
6
|
+
leftVisibleCellIndex: ColumnIndex;
|
|
7
|
+
} | {
|
|
8
|
+
spannedByColSpan: false;
|
|
9
|
+
cellProps: {
|
|
10
|
+
colSpan: integer;
|
|
11
|
+
width: float;
|
|
12
|
+
};
|
|
13
|
+
};
|
package/models/core.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export type Size = {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
};
|
|
5
|
+
export declare namespace Size {
|
|
6
|
+
const EMPTY: {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
10
|
+
function equals(a: Size, b: Size): boolean;
|
|
11
|
+
}
|
|
12
|
+
export type Row = {
|
|
13
|
+
[key: string | symbol]: any;
|
|
14
|
+
};
|
|
15
|
+
export type Column = {
|
|
16
|
+
[key: string | symbol]: any;
|
|
17
|
+
};
|
|
18
|
+
export type ColumnWithWidth = {
|
|
19
|
+
computedWidth: number;
|
|
20
|
+
} & Column;
|
|
21
|
+
export type RowId = any;
|
|
22
|
+
export type RowEntry = {
|
|
23
|
+
id: any;
|
|
24
|
+
model: Row;
|
|
25
|
+
};
|
|
26
|
+
export type PinnedRows = {
|
|
27
|
+
top: RowEntry[];
|
|
28
|
+
bottom: RowEntry[];
|
|
29
|
+
};
|
|
30
|
+
export type PinnedColumns = {
|
|
31
|
+
left: Column[];
|
|
32
|
+
right: Column[];
|
|
33
|
+
};
|
|
34
|
+
export type FocusedCell = {
|
|
35
|
+
rowIndex: number;
|
|
36
|
+
columnIndex: number;
|
|
37
|
+
id?: any;
|
|
38
|
+
field?: string;
|
|
39
|
+
};
|
|
40
|
+
export interface ColumnsRenderContext {
|
|
41
|
+
firstColumnIndex: number;
|
|
42
|
+
lastColumnIndex: number;
|
|
43
|
+
}
|
|
44
|
+
export interface RenderContext extends ColumnsRenderContext {
|
|
45
|
+
firstRowIndex: number;
|
|
46
|
+
lastRowIndex: number;
|
|
47
|
+
}
|
|
48
|
+
export interface GridScrollParams {
|
|
49
|
+
left: number;
|
|
50
|
+
top: number;
|
|
51
|
+
renderContext?: RenderContext;
|
|
52
|
+
}
|
|
53
|
+
export type GridScrollFn = (v: GridScrollParams) => void;
|
|
54
|
+
export type PinnedRowPosition = keyof PinnedRows;
|
|
55
|
+
export type ScrollPosition = {
|
|
56
|
+
top: number;
|
|
57
|
+
left: number;
|
|
58
|
+
};
|
|
59
|
+
export declare enum ScrollDirection {
|
|
60
|
+
NONE = 0,
|
|
61
|
+
UP = 1,
|
|
62
|
+
DOWN = 2,
|
|
63
|
+
LEFT = 3,
|
|
64
|
+
RIGHT = 4,
|
|
65
|
+
}
|
|
66
|
+
export declare namespace ScrollDirection {
|
|
67
|
+
function forDelta(dx: number, dy: number): ScrollDirection;
|
|
68
|
+
}
|
|
69
|
+
export type RowRange = {
|
|
70
|
+
firstRowIndex: number;
|
|
71
|
+
lastRowIndex: number;
|
|
72
|
+
};
|
package/models/core.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Size = exports.ScrollDirection = void 0;
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-redeclare */
|
|
8
|
+
let Size = exports.Size = void 0;
|
|
9
|
+
(function (_Size) {
|
|
10
|
+
const EMPTY = _Size.EMPTY = {
|
|
11
|
+
width: 0,
|
|
12
|
+
height: 0
|
|
13
|
+
};
|
|
14
|
+
function equals(a, b) {
|
|
15
|
+
return a.width === b.width && a.height === b.height;
|
|
16
|
+
}
|
|
17
|
+
_Size.equals = equals;
|
|
18
|
+
})(Size || (exports.Size = Size = {})); // TODO
|
|
19
|
+
let ScrollDirection = exports.ScrollDirection = /*#__PURE__*/function (ScrollDirection) {
|
|
20
|
+
ScrollDirection[ScrollDirection["NONE"] = 0] = "NONE";
|
|
21
|
+
ScrollDirection[ScrollDirection["UP"] = 1] = "UP";
|
|
22
|
+
ScrollDirection[ScrollDirection["DOWN"] = 2] = "DOWN";
|
|
23
|
+
ScrollDirection[ScrollDirection["LEFT"] = 3] = "LEFT";
|
|
24
|
+
ScrollDirection[ScrollDirection["RIGHT"] = 4] = "RIGHT";
|
|
25
|
+
return ScrollDirection;
|
|
26
|
+
}({});
|
|
27
|
+
(function (_ScrollDirection) {
|
|
28
|
+
function forDelta(dx, dy) {
|
|
29
|
+
if (dx === 0 && dy === 0) {
|
|
30
|
+
return ScrollDirection.NONE;
|
|
31
|
+
}
|
|
32
|
+
/* eslint-disable */
|
|
33
|
+
if (Math.abs(dy) >= Math.abs(dx)) {
|
|
34
|
+
if (dy > 0) {
|
|
35
|
+
return ScrollDirection.DOWN;
|
|
36
|
+
} else {
|
|
37
|
+
return ScrollDirection.UP;
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
if (dx > 0) {
|
|
41
|
+
return ScrollDirection.RIGHT;
|
|
42
|
+
} else {
|
|
43
|
+
return ScrollDirection.LEFT;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/* eslint-enable */
|
|
47
|
+
}
|
|
48
|
+
_ScrollDirection.forDelta = forDelta;
|
|
49
|
+
})(ScrollDirection || (exports.ScrollDirection = ScrollDirection = {}));
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { Size } from "./core.js";
|
|
2
|
+
export interface DimensionsState {
|
|
3
|
+
/**
|
|
4
|
+
* Indicates that the dimensions have been initialized.
|
|
5
|
+
*/
|
|
6
|
+
isReady: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The root container size.
|
|
9
|
+
*/
|
|
10
|
+
root: Size;
|
|
11
|
+
/**
|
|
12
|
+
* The viewport size including scrollbars.
|
|
13
|
+
*/
|
|
14
|
+
viewportOuterSize: Size;
|
|
15
|
+
/**
|
|
16
|
+
* The viewport size not including scrollbars.
|
|
17
|
+
*/
|
|
18
|
+
viewportInnerSize: Size;
|
|
19
|
+
/**
|
|
20
|
+
* The size of the main content (unpinned rows & columns).
|
|
21
|
+
*/
|
|
22
|
+
contentSize: Size;
|
|
23
|
+
/**
|
|
24
|
+
* The minimum size to display the grid, including all pinned sections and headers.
|
|
25
|
+
*/
|
|
26
|
+
minimumSize: Size;
|
|
27
|
+
/**
|
|
28
|
+
* Indicates if a scroll is currently needed to go from the beginning of the first column to the end of the last column.
|
|
29
|
+
*/
|
|
30
|
+
hasScrollX: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Indicates if a scroll is currently needed to go from the beginning of the first row to the end of the last row.
|
|
33
|
+
*/
|
|
34
|
+
hasScrollY: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Size of the scrollbar used to scroll the rows in pixel.
|
|
37
|
+
* It is defined even when the scrollbar is currently not needed.
|
|
38
|
+
*/
|
|
39
|
+
scrollbarSize: number;
|
|
40
|
+
/**
|
|
41
|
+
* Width of a row.
|
|
42
|
+
*/
|
|
43
|
+
rowWidth: number;
|
|
44
|
+
/**
|
|
45
|
+
* Height of a row.
|
|
46
|
+
*/
|
|
47
|
+
rowHeight: number;
|
|
48
|
+
/**
|
|
49
|
+
* Size of all the visible columns.
|
|
50
|
+
*/
|
|
51
|
+
columnsTotalWidth: number;
|
|
52
|
+
/**
|
|
53
|
+
* Size of left pinned columns.
|
|
54
|
+
*/
|
|
55
|
+
leftPinnedWidth: number;
|
|
56
|
+
/**
|
|
57
|
+
* Size of right pinned columns.
|
|
58
|
+
*/
|
|
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
|
+
/**
|
|
77
|
+
* Size of the top container.
|
|
78
|
+
*/
|
|
79
|
+
topContainerHeight: number;
|
|
80
|
+
/**
|
|
81
|
+
* Size of the bottom container.
|
|
82
|
+
*/
|
|
83
|
+
bottomContainerHeight: number;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The rows total height and positions.
|
|
87
|
+
*/
|
|
88
|
+
export interface RowsMetaState {
|
|
89
|
+
/**
|
|
90
|
+
* The grid rows positions.
|
|
91
|
+
*/
|
|
92
|
+
positions: number[];
|
|
93
|
+
/**
|
|
94
|
+
* The sum of all visible grid rows in the current rows.
|
|
95
|
+
*/
|
|
96
|
+
currentPageTotalHeight: number;
|
|
97
|
+
/**
|
|
98
|
+
* The total height of the pinned top rows.
|
|
99
|
+
*/
|
|
100
|
+
pinnedTopRowsTotalHeight: number;
|
|
101
|
+
/**
|
|
102
|
+
* The total height of the pinned bottom rows.
|
|
103
|
+
*/
|
|
104
|
+
pinnedBottomRowsTotalHeight: number;
|
|
105
|
+
}
|
|
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
|
+
export interface RowSpacing {
|
|
122
|
+
top?: number;
|
|
123
|
+
bottom?: number;
|
|
124
|
+
}
|
|
125
|
+
export type HeightEntry = {
|
|
126
|
+
content: number;
|
|
127
|
+
spacingTop: number;
|
|
128
|
+
spacingBottom: number;
|
|
129
|
+
detail: number;
|
|
130
|
+
autoHeight: boolean;
|
|
131
|
+
needsFirstMeasurement: boolean;
|
|
132
|
+
};
|
package/models/index.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _core = require("./core");
|
|
7
|
+
Object.keys(_core).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _core[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _core[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _colspan = require("./colspan");
|
|
18
|
+
Object.keys(_colspan).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _colspan[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _colspan[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _dimensions = require("./dimensions");
|
|
29
|
+
Object.keys(_dimensions).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _dimensions[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _dimensions[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _rowspan = require("./rowspan");
|
|
40
|
+
Object.keys(_rowspan).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _rowspan[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _rowspan[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RowId, RowRange } from "./core.js";
|
|
2
|
+
type ColumnIndex = number;
|
|
3
|
+
export interface RowSpanningCaches {
|
|
4
|
+
spannedCells: Record<RowId, Record<ColumnIndex, number>>;
|
|
5
|
+
hiddenCells: Record<RowId, Record<ColumnIndex, boolean>>;
|
|
6
|
+
/**
|
|
7
|
+
* For each hidden cell, it contains the row index corresponding to the cell that is
|
|
8
|
+
* the origin of the hidden cell. i.e. the cell which is spanned.
|
|
9
|
+
* Used by the virtualization to properly keep the spanned cells in view.
|
|
10
|
+
*/
|
|
11
|
+
hiddenCellOriginMap: Record<number, Record<ColumnIndex, number>>;
|
|
12
|
+
}
|
|
13
|
+
export interface RowSpanningState {
|
|
14
|
+
caches: RowSpanningCaches;
|
|
15
|
+
processedRange: RowRange;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mui/x-virtualizer",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"author": "MUI Team",
|
|
5
|
+
"description": "MUI virtualization library",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://github.com/mui/mui-x/issues"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://mui.com",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"funding": {
|
|
13
|
+
"type": "opencollective",
|
|
14
|
+
"url": "https://opencollective.com/mui-org"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"react",
|
|
21
|
+
"react-component",
|
|
22
|
+
"virtualization"
|
|
23
|
+
],
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/mui/mui-x.git",
|
|
27
|
+
"directory": "packages/x-virtualizer"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@babel/runtime": "^7.27.4",
|
|
31
|
+
"@mui/x-internals": "8.9.2"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
35
|
+
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=14.0.0"
|
|
39
|
+
},
|
|
40
|
+
"private": false,
|
|
41
|
+
"exports": {
|
|
42
|
+
"./package.json": "./package.json",
|
|
43
|
+
".": {
|
|
44
|
+
"require": {
|
|
45
|
+
"types": "./index.d.ts",
|
|
46
|
+
"default": "./index.js"
|
|
47
|
+
},
|
|
48
|
+
"import": {
|
|
49
|
+
"types": "./esm/index.d.ts",
|
|
50
|
+
"default": "./esm/index.js"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"./*": {
|
|
54
|
+
"require": {
|
|
55
|
+
"types": "./*/index.d.ts",
|
|
56
|
+
"default": "./*/index.js"
|
|
57
|
+
},
|
|
58
|
+
"import": {
|
|
59
|
+
"types": "./esm/*/index.d.ts",
|
|
60
|
+
"default": "./esm/*/index.js"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"./esm": null,
|
|
64
|
+
"./modern": null
|
|
65
|
+
},
|
|
66
|
+
"types": "./index.d.ts"
|
|
67
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { integer, RefObject } from '@mui/x-internals/types';
|
|
3
|
+
import { Store } from '@mui/x-internals/store';
|
|
4
|
+
import { Colspan } from "./features/colspan.js";
|
|
5
|
+
import { Dimensions } from "./features/dimensions.js";
|
|
6
|
+
import { Rowspan } from "./features/rowspan.js";
|
|
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";
|
|
10
|
+
import { ColumnWithWidth, FocusedCell, Size, PinnedRows, PinnedColumns, RenderContext, Row, RowEntry } from "./models/index.js";
|
|
11
|
+
export type Virtualizer = ReturnType<typeof useVirtualizer>;
|
|
12
|
+
export type VirtualScrollerCompat = Virtualization.State['getters'];
|
|
13
|
+
export type BaseState = Virtualization.State & Dimensions.State;
|
|
14
|
+
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;
|
|
25
|
+
};
|
|
26
|
+
initialState?: {
|
|
27
|
+
scroll?: {
|
|
28
|
+
top: number;
|
|
29
|
+
left: number;
|
|
30
|
+
};
|
|
31
|
+
dimensions?: Partial<Dimensions.State['dimensions']>;
|
|
32
|
+
rowSpanning?: Rowspan.State['rowSpanning'];
|
|
33
|
+
virtualization?: Partial<Virtualization.State['virtualization']>;
|
|
34
|
+
};
|
|
35
|
+
isRtl: boolean;
|
|
36
|
+
/** current page rows */
|
|
37
|
+
rows: RowEntry[];
|
|
38
|
+
/** current page range */
|
|
39
|
+
range: {
|
|
40
|
+
firstRowIndex: integer;
|
|
41
|
+
lastRowIndex: integer;
|
|
42
|
+
} | null;
|
|
43
|
+
rowIdToIndexMap: Map<RowId, number>;
|
|
44
|
+
rowCount: integer;
|
|
45
|
+
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;
|
|
57
|
+
autoHeight: boolean;
|
|
58
|
+
getRowHeight?: (row: RowEntry) => number | null | undefined | 'auto';
|
|
59
|
+
/**
|
|
60
|
+
* Function that returns the estimated height for a row.
|
|
61
|
+
* Only works if dynamic row height is used.
|
|
62
|
+
* Once the row height is measured this value is discarded.
|
|
63
|
+
* @param rowEntry
|
|
64
|
+
* @returns The estimated row height value. If `null` or `undefined` then the default row height, based on the density, is applied.
|
|
65
|
+
*/
|
|
66
|
+
getEstimatedRowHeight?: (rowEntry: RowEntry) => number | null;
|
|
67
|
+
/**
|
|
68
|
+
* Function that allows to specify the spacing between rows.
|
|
69
|
+
* @param rowEntry
|
|
70
|
+
* @param visibility With all properties from [[RowVisibilityParams]].
|
|
71
|
+
* @returns The row spacing values.
|
|
72
|
+
*/
|
|
73
|
+
getRowSpacing?: (rowEntry: RowEntry, visibility: RowVisibilityParams) => RowSpacing;
|
|
74
|
+
/** Update the row height values before they're used.
|
|
75
|
+
* Used to add detail panel heights.
|
|
76
|
+
* @param entry
|
|
77
|
+
* @param rowEntry
|
|
78
|
+
*/
|
|
79
|
+
applyRowHeight?: (entry: HeightEntry, rowEntry: RowEntry) => void;
|
|
80
|
+
virtualizeColumnsWithAutoRowHeight?: boolean;
|
|
81
|
+
resizeThrottleMs: number;
|
|
82
|
+
onResize?: (lastSize: Size) => void;
|
|
83
|
+
onWheel?: (event: React.WheelEvent) => void;
|
|
84
|
+
onTouchMove?: (event: React.TouchEvent) => void;
|
|
85
|
+
onRenderContextChange?: (c: RenderContext) => void;
|
|
86
|
+
onScrollChange?: (scrollPosition: {
|
|
87
|
+
top: number;
|
|
88
|
+
left: number;
|
|
89
|
+
}, nextRenderContext: RenderContext) => void;
|
|
90
|
+
focusedVirtualCell: () => FocusedCell | null;
|
|
91
|
+
rowBufferPx: number;
|
|
92
|
+
columnBufferPx: number;
|
|
93
|
+
scrollReset?: any;
|
|
94
|
+
getColspan: (rowId: RowId, column: ColumnWithWidth, columnIndex: integer) => number;
|
|
95
|
+
renderRow: (params: {
|
|
96
|
+
id: any;
|
|
97
|
+
model: Row;
|
|
98
|
+
rowIndex: number;
|
|
99
|
+
offsetLeft: number;
|
|
100
|
+
columnsTotalWidth: number;
|
|
101
|
+
baseRowHeight: number | 'auto';
|
|
102
|
+
columns: ColumnWithWidth[];
|
|
103
|
+
firstColumnIndex: number;
|
|
104
|
+
lastColumnIndex: number;
|
|
105
|
+
focusedColumnIndex: number | undefined;
|
|
106
|
+
isFirstVisible: boolean;
|
|
107
|
+
isLastVisible: boolean;
|
|
108
|
+
isVirtualFocusRow: boolean;
|
|
109
|
+
showBottomBorder: boolean;
|
|
110
|
+
}) => React.ReactElement;
|
|
111
|
+
renderInfiniteLoadingTrigger: (id: any) => React.ReactElement;
|
|
112
|
+
};
|
|
113
|
+
export declare const useVirtualizer: (params: VirtualizerParams) => {
|
|
114
|
+
store: Store<Dimensions.State & Virtualization.State & Colspan.State & Rowspan.State>;
|
|
115
|
+
api: {
|
|
116
|
+
updateDimensions: () => void;
|
|
117
|
+
debouncedUpdateDimensions: ((() => void) & import("@mui/x-internals/throttle/throttle").Cancelable) | undefined;
|
|
118
|
+
rowsMeta: {
|
|
119
|
+
getRowHeight: (rowId: RowId) => any;
|
|
120
|
+
setLastMeasuredRowIndex: (index: number) => void;
|
|
121
|
+
storeRowHeightMeasurement: (id: RowId, height: number) => void;
|
|
122
|
+
hydrateRowsMeta: () => void;
|
|
123
|
+
observeRowHeight: (element: Element, rowId: RowId) => () => void | undefined;
|
|
124
|
+
rowHasAutoHeight: (id: RowId) => any;
|
|
125
|
+
getRowHeightEntry: (rowId: RowId) => any;
|
|
126
|
+
getLastMeasuredRowIndex: () => number;
|
|
127
|
+
resetRowHeights: () => void;
|
|
128
|
+
};
|
|
129
|
+
} & {
|
|
130
|
+
getters: {
|
|
131
|
+
setPanels: React.Dispatch<React.SetStateAction<Readonly<Map<any, React.ReactNode>>>>;
|
|
132
|
+
getRows: (rowParams: {
|
|
133
|
+
rows?: RowEntry[];
|
|
134
|
+
position?: import("./models/index.js").PinnedRowPosition;
|
|
135
|
+
renderContext?: RenderContext;
|
|
136
|
+
} | undefined, unstable_rowTree: Record<RowId, any>) => React.ReactNode[];
|
|
137
|
+
getContainerProps: () => {
|
|
138
|
+
ref: React.RefObject<HTMLDivElement | null>;
|
|
139
|
+
};
|
|
140
|
+
getScrollerProps: () => {
|
|
141
|
+
ref: React.RefObject<HTMLDivElement | null>;
|
|
142
|
+
onScroll: () => void;
|
|
143
|
+
onWheel: ((event: React.WheelEvent) => void) | undefined;
|
|
144
|
+
onTouchMove: ((event: React.TouchEvent) => void) | undefined;
|
|
145
|
+
style: React.CSSProperties;
|
|
146
|
+
role: string;
|
|
147
|
+
tabIndex: number | undefined;
|
|
148
|
+
};
|
|
149
|
+
getContentProps: () => {
|
|
150
|
+
style: React.CSSProperties;
|
|
151
|
+
role: string;
|
|
152
|
+
ref: (node: HTMLDivElement | null) => void;
|
|
153
|
+
};
|
|
154
|
+
getRenderZoneProps: () => {
|
|
155
|
+
role: string;
|
|
156
|
+
};
|
|
157
|
+
getScrollbarVerticalProps: () => {
|
|
158
|
+
ref: React.RefObject<HTMLDivElement | null>;
|
|
159
|
+
scrollPosition: React.RefObject<{
|
|
160
|
+
top: number;
|
|
161
|
+
left: number;
|
|
162
|
+
}>;
|
|
163
|
+
};
|
|
164
|
+
getScrollbarHorizontalProps: () => {
|
|
165
|
+
ref: React.RefObject<HTMLDivElement | null>;
|
|
166
|
+
scrollPosition: React.RefObject<{
|
|
167
|
+
top: number;
|
|
168
|
+
left: number;
|
|
169
|
+
}>;
|
|
170
|
+
};
|
|
171
|
+
getScrollAreaProps: () => {
|
|
172
|
+
scrollPosition: React.RefObject<{
|
|
173
|
+
top: number;
|
|
174
|
+
left: number;
|
|
175
|
+
}>;
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
useVirtualization: () => BaseState;
|
|
179
|
+
setPanels: React.Dispatch<React.SetStateAction<Readonly<Map<any, React.ReactNode>>>>;
|
|
180
|
+
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>>;
|
|
184
|
+
} & {
|
|
185
|
+
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;
|
|
188
|
+
} & {
|
|
189
|
+
getHiddenCellsOrigin: () => Record<number, Record<number, number>>;
|
|
190
|
+
} & {
|
|
191
|
+
getViewportPageSize: () => number;
|
|
192
|
+
};
|
|
193
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useVirtualizer = void 0;
|
|
8
|
+
var _useLazyRef = _interopRequireDefault(require("@mui/utils/useLazyRef"));
|
|
9
|
+
var _store = require("@mui/x-internals/store");
|
|
10
|
+
var _colspan = require("./features/colspan");
|
|
11
|
+
var _dimensions = require("./features/dimensions");
|
|
12
|
+
var _keyboard = require("./features/keyboard");
|
|
13
|
+
var _rowspan = require("./features/rowspan");
|
|
14
|
+
var _virtualization = require("./features/virtualization");
|
|
15
|
+
/* eslint-disable jsdoc/require-param-type */
|
|
16
|
+
/* eslint-disable jsdoc/require-param-description */
|
|
17
|
+
/* eslint-disable jsdoc/require-returns-type */
|
|
18
|
+
|
|
19
|
+
const FEATURES = [_dimensions.Dimensions, _virtualization.Virtualization, _colspan.Colspan, _rowspan.Rowspan, _keyboard.Keyboard];
|
|
20
|
+
const useVirtualizer = params => {
|
|
21
|
+
const store = (0, _useLazyRef.default)(() => {
|
|
22
|
+
return new _store.Store(FEATURES.map(f => f.initialize(params)).reduce((state, partial) => Object.assign(state, partial), {}));
|
|
23
|
+
}).current;
|
|
24
|
+
const api = {};
|
|
25
|
+
for (const feature of FEATURES) {
|
|
26
|
+
Object.assign(api, feature.use(store, params, api));
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
store,
|
|
30
|
+
api
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
exports.useVirtualizer = useVirtualizer;
|