@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.
- package/CHANGELOG.md +217 -6
- package/esm/features/colspan.d.ts +4 -0
- package/esm/features/colspan.js +4 -3
- package/esm/features/dimensions.d.ts +10 -0
- package/esm/features/dimensions.js +30 -49
- package/esm/features/virtualization.d.ts +17 -10
- package/esm/features/virtualization.js +55 -74
- package/esm/index.js +1 -1
- package/esm/models/core.d.ts +10 -4
- package/esm/models/core.js +20 -8
- package/esm/models/dimensions.d.ts +2 -33
- package/esm/useVirtualizer.d.ts +34 -53
- package/features/colspan.d.ts +4 -0
- package/features/colspan.js +4 -3
- package/features/dimensions.d.ts +10 -0
- package/features/dimensions.js +28 -48
- package/features/virtualization.d.ts +17 -10
- package/features/virtualization.js +55 -74
- package/index.js +1 -1
- package/models/core.d.ts +10 -4
- package/models/core.js +21 -9
- package/models/dimensions.d.ts +2 -33
- package/package.json +26 -15
- package/useVirtualizer.d.ts +34 -53
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,217 @@
|
|
|
5
5
|
All notable changes to this project will be documented in this file.
|
|
6
6
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
7
7
|
|
|
8
|
+
## 8.10.1
|
|
9
|
+
|
|
10
|
+
_Aug 15, 2025_
|
|
11
|
+
|
|
12
|
+
We'd like to extend a big thank you to the 8 contributors who made this release possible. Here are some highlights ✨:
|
|
13
|
+
|
|
14
|
+
- 📊 Y-axes can now be grouped by category when using `band` and `point` scales.
|
|
15
|
+
- 📚 Documentation improvements
|
|
16
|
+
|
|
17
|
+
The following are all team members who have contributed to this release:
|
|
18
|
+
@alexfauquette, @bernardobelchior, @Janpot, @JCQuintas, @mnajdova, @oliviertassinari, @prakhargupta1, @romgrk
|
|
19
|
+
|
|
20
|
+
### Data Grid
|
|
21
|
+
|
|
22
|
+
#### `@mui/x-data-grid@8.10.1`
|
|
23
|
+
|
|
24
|
+
- [DataGrid] Fix scroll jumping (#19156) @romgrk
|
|
25
|
+
- [DataGrid] Fix scroll restoration (#19182) @romgrk
|
|
26
|
+
- [DataGrid] Fix "no row with id" error (#19193) @romgrk
|
|
27
|
+
|
|
28
|
+
#### `@mui/x-data-grid-pro@8.10.1` [](https://mui.com/r/x-pro-svg-link "Pro plan")
|
|
29
|
+
|
|
30
|
+
Same changes as in `@mui/x-data-grid@8.10.1`.
|
|
31
|
+
|
|
32
|
+
#### `@mui/x-data-grid-premium@8.10.1` [](https://mui.com/r/x-premium-svg-link "Premium plan")
|
|
33
|
+
|
|
34
|
+
Same changes as in `@mui/x-data-grid-pro@8.10.1`.
|
|
35
|
+
|
|
36
|
+
### Date and Time Pickers
|
|
37
|
+
|
|
38
|
+
#### `@mui/x-date-pickers@8.10.0`
|
|
39
|
+
|
|
40
|
+
Internal changes.
|
|
41
|
+
|
|
42
|
+
#### `@mui/x-date-pickers-pro@8.10.0` [](https://mui.com/r/x-pro-svg-link "Pro plan")
|
|
43
|
+
|
|
44
|
+
Same changes as in `@mui/x-date-pickers@8.10.0`.
|
|
45
|
+
|
|
46
|
+
### Charts
|
|
47
|
+
|
|
48
|
+
- Axes can now be grouped by category when using `band` and `point` scales
|
|
49
|
+
|
|
50
|
+
<img width="643" height="455" alt="Bar chart with y-axis grouped per categories" src="https://github.com/user-attachments/assets/59044afe-bcc5-4152-8bf1-225db0635025" />
|
|
51
|
+
|
|
52
|
+
#### `@mui/x-charts@8.10.1`
|
|
53
|
+
|
|
54
|
+
- [charts] Allow y-axis to be grouped (#19081) @JCQuintas
|
|
55
|
+
- [charts] Fix default axis highlight for axes without data attribute (#18985) @alexfauquette
|
|
56
|
+
- [charts] Fix tooltip mark unexpected wrapping in mobile (#19122) @bernardobelchior
|
|
57
|
+
- [charts] Prevent overflow on charts tooltip (#19123) @bernardobelchior
|
|
58
|
+
|
|
59
|
+
#### `@mui/x-charts-pro@8.10.1` [](https://mui.com/r/x-pro-svg-link "Pro plan")
|
|
60
|
+
|
|
61
|
+
Same changes as in `@mui/x-charts@8.10.1`.
|
|
62
|
+
|
|
63
|
+
### Tree View
|
|
64
|
+
|
|
65
|
+
#### `@mui/x-tree-view@8.10.1`
|
|
66
|
+
|
|
67
|
+
Internal changes.
|
|
68
|
+
|
|
69
|
+
#### `@mui/x-tree-view-pro@8.10.1` [](https://mui.com/r/x-pro-svg-link "Pro plan")
|
|
70
|
+
|
|
71
|
+
Same changes as in `@mui/x-tree-view@8.10.1`.
|
|
72
|
+
|
|
73
|
+
### Codemod
|
|
74
|
+
|
|
75
|
+
#### `@mui/x-codemod@8.10.1`
|
|
76
|
+
|
|
77
|
+
Internal changes.
|
|
78
|
+
|
|
79
|
+
### Docs
|
|
80
|
+
|
|
81
|
+
- [docs] Add all planned charts on the overview page (#19077) @prakhargupta1
|
|
82
|
+
- [docs] Add future charts components link in the sidebar (#19140) @prakhargupta1
|
|
83
|
+
- [docs] Fix Heatmap docs duplicate text (#19138) @JCQuintas
|
|
84
|
+
- [docs] Remove preview from Toolbar & Funnel (#19131) @mnajdova
|
|
85
|
+
- [docs] Reproduce npm sparkline (#19089) @alexfauquette
|
|
86
|
+
|
|
87
|
+
### Core
|
|
88
|
+
|
|
89
|
+
- [core] Fix licensing model name (#19025) @oliviertassinari
|
|
90
|
+
- [core] Fix usage of `:catalog` for `@babel/runtime` (#19028) @oliviertassinari
|
|
91
|
+
- [core] Refactor virtualizer API (#18995) @romgrk
|
|
92
|
+
|
|
93
|
+
### Miscellaneous
|
|
94
|
+
|
|
95
|
+
- [code-infra] Remove namespaces (#19071) @Janpot
|
|
96
|
+
- [code-infra] Fix `fs-extra` removal from `formattedTSDemos` script (#19132) @bernardobelchior
|
|
97
|
+
- [code-infra] Remove unused code and dependency (#19139) @bernardobelchior
|
|
98
|
+
- [code-infra] Replace `fs-extra` with `node:fs` where possible (#19127) @bernardobelchior
|
|
99
|
+
- [internal] Edit, keep `lockFileMaintenance` simple @oliviertassinari
|
|
100
|
+
- [internal] Fix writing style action name @oliviertassinari
|
|
101
|
+
- [internal] Make it clear that `lockFileMaintenance` is enabled @oliviertassinari
|
|
102
|
+
- [support-infra] Remove default issue label (#19104) @oliviertassinari
|
|
103
|
+
|
|
104
|
+
## 8.10.0
|
|
105
|
+
|
|
106
|
+
_Aug 8, 2025_
|
|
107
|
+
|
|
108
|
+
We'd like to extend a big thank you to the 17 contributors who made this release possible. Here are some highlights ✨:
|
|
109
|
+
|
|
110
|
+
- 📊 [`FunnelChart`](https://mui.com/x/react-charts/funnel/) marked as stable
|
|
111
|
+
- 📈 [Zoom slider](https://mui.com/x/react-charts/zoom-and-pan/#zoom-slider) and [Preview](https://mui.com/x/react-charts/zoom-and-pan/#preview) marked as stable
|
|
112
|
+
- 📈 Supporting [label groups](https://mui.com/x/react-charts/axis/#grouped-axes) in band and point axis
|
|
113
|
+
- 🌎 Improve Norwegian Nynorsk (nn-NO) locale on the Data Grid
|
|
114
|
+
- 🐞 Bugfixes
|
|
115
|
+
- 📚 Documentation improvements
|
|
116
|
+
|
|
117
|
+
Special thanks go out to the community members for their valuable contributions:
|
|
118
|
+
@AnderzL7, @aqeelat, @dwrth, @noobyogi0010, @nusr, @sai6855
|
|
119
|
+
|
|
120
|
+
The following are all team members who have contributed to this release:
|
|
121
|
+
@arminmeh, @bernardobelchior, @cherniavskii, @flaviendelangle, @Janpot, @JCQuintas, @mapache-salvaje, @MBilalShafi, @oliviertassinari, @rita-codes, @romgrk
|
|
122
|
+
|
|
123
|
+
### Data Grid
|
|
124
|
+
|
|
125
|
+
#### `@mui/x-data-grid@8.10.0`
|
|
126
|
+
|
|
127
|
+
- [DataGrid] Move spread operator in `BaseSelect` to allow `variant` change (#19026) @dwrth
|
|
128
|
+
- [DataGrid] Use `use-sync-external-store` shim (#19063) @romgrk
|
|
129
|
+
- [DataGrid] Allow skipping cache in `dataSource.fetchRows()` API method (#18904) @MBilalShafi
|
|
130
|
+
- [DataGrid] Do not call `preProcessEditCellProps()` if cell is not editable based on `isCellEditable()` (#18405) @nusr
|
|
131
|
+
- [DataGrid] Fix `renderCountry` throwing an error when used in tree data (#19068) @cherniavskii
|
|
132
|
+
- [DataGrid] Fix performance issue for root level "select all" (#19015) @MBilalShafi
|
|
133
|
+
- [DataGrid] Fix pagination `slotProps` being ignored by the grid (#19095) @romgrk
|
|
134
|
+
- [l10n] Improve Norwegian Nynorsk (nn-NO) locale (#19076) @AnderzL7
|
|
135
|
+
|
|
136
|
+
#### `@mui/x-data-grid-pro@8.10.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
137
|
+
|
|
138
|
+
Same changes as in `@mui/x-data-grid@8.10.0`, plus:
|
|
139
|
+
|
|
140
|
+
- [DataGridPro] Fix row reorder not working with column reorder disabled (#19016) @MBilalShafi
|
|
141
|
+
- [DataGridPro] Fix header filters cache sharing issue (#19090) @MBilalShafi
|
|
142
|
+
|
|
143
|
+
#### `@mui/x-data-grid-premium@8.10.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
144
|
+
|
|
145
|
+
Same changes as in `@mui/x-data-grid-pro@8.10.0`, plus:
|
|
146
|
+
|
|
147
|
+
- [DataGridPremium] Allow additional derived columns customization via `valueFormatter` (#18982) @arminmeh
|
|
148
|
+
- [DataGridPremium] Fix complex `singleSelect` columns not working in pivot model (#18971) @cherniavskii
|
|
149
|
+
|
|
150
|
+
### Date and Time Pickers
|
|
151
|
+
|
|
152
|
+
#### `@mui/x-date-pickers@8.10.0`
|
|
153
|
+
|
|
154
|
+
- [pickers] `MuiPickersLayout-toolbar` is overlapping the Calendar in RTL `MobileDatePicker` variant (#18981) @rita-codes
|
|
155
|
+
|
|
156
|
+
#### `@mui/x-date-pickers-pro@8.10.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
157
|
+
|
|
158
|
+
Same changes as in `@mui/x-date-pickers@8.10.0`.
|
|
159
|
+
|
|
160
|
+
### Charts
|
|
161
|
+
|
|
162
|
+
#### `@mui/x-charts@8.10.0`
|
|
163
|
+
|
|
164
|
+
- [charts] Add `groups` to `band` and `point` axis config (#18766) @JCQuintas
|
|
165
|
+
- [charts] Animation example using `motion` library (#18993) @JCQuintas
|
|
166
|
+
- [charts] Deprecate `Unstable_` radar exports (#19079) @JCQuintas
|
|
167
|
+
- [charts] Improve grouped axis logic (#19069) @JCQuintas
|
|
168
|
+
- [charts] Fix type assertion in axis highlight components (#19060) @sai6855
|
|
169
|
+
- [charts] Remove unnecessary type assertion in tooltip `valueFormatter` in heatmap (#19047) @sai6855
|
|
170
|
+
|
|
171
|
+
#### `@mui/x-charts-pro@8.10.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
172
|
+
|
|
173
|
+
Same changes as in `@mui/x-charts@8.10.0`, plus:
|
|
174
|
+
|
|
175
|
+
- [charts-pro] Fix `slotProps.tooltip.trigger` not respected in `ScatterChartPro` and `FunnelChart` (#18902) @bernardobelchior
|
|
176
|
+
- [charts-pro] Fix zoom filtering adjusting axis too soon (#18992) @bernardobelchior
|
|
177
|
+
- [charts-pro] Mark `FunnelChart` as stable (#19048) @JCQuintas
|
|
178
|
+
- [charts-pro] Mark zoom slider and preview as stable (#19049) @JCQuintas
|
|
179
|
+
- [charts-pro] Refactor `createAxisFilterMapper` (#18998) @bernardobelchior
|
|
180
|
+
|
|
181
|
+
### Tree View
|
|
182
|
+
|
|
183
|
+
#### `@mui/x-tree-view@8.10.0`
|
|
184
|
+
|
|
185
|
+
Internal changes.
|
|
186
|
+
|
|
187
|
+
#### `@mui/x-tree-view-pro@8.10.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
188
|
+
|
|
189
|
+
Same changes as in `@mui/x-tree-view@8.10.0`.
|
|
190
|
+
|
|
191
|
+
### Codemod
|
|
192
|
+
|
|
193
|
+
#### `@mui/x-codemod@8.10.0`
|
|
194
|
+
|
|
195
|
+
Internal changes.
|
|
196
|
+
|
|
197
|
+
### Docs
|
|
198
|
+
|
|
199
|
+
- [docs] Add CSS bundler breaking change to migration guide (#17436) @romgrk
|
|
200
|
+
- [docs] `RichTreeViewPro` demo for dragging via custom drag-handle is not working properly (#19008) @rita-codes
|
|
201
|
+
- [docs] Fix broken link to D3 in Charts (#19020) @oliviertassinari
|
|
202
|
+
- [docs] Revise the Charts Animation doc (#18990) @mapache-salvaje
|
|
203
|
+
- [docs] Fix incorrect code in line chart preview (#19023) @noobyogi0010
|
|
204
|
+
- [docs] Improve bundling instructions for the Data Grid (#19065) @romgrk
|
|
205
|
+
- [docs] Reduce image size in the inventory grid demo (#19004) @arminmeh
|
|
206
|
+
|
|
207
|
+
### Core
|
|
208
|
+
|
|
209
|
+
- [core] Fix ESLint reference name @oliviertassinari
|
|
210
|
+
|
|
211
|
+
### Miscellaneous
|
|
212
|
+
|
|
213
|
+
- [infra] Remove bundle size tracking for subpaths (#19072) @Janpot
|
|
214
|
+
- [infra] Accept `PORT` env on `docs:dev` script (#19014) @JCQuintas
|
|
215
|
+
- [infra] Skip codesandbox iframe demos in regressions tests (#18970) @cherniavskii
|
|
216
|
+
- [infra] Remove package.json `module` field (#18961) @Janpot
|
|
217
|
+
- [internal] Remove peer dependency on `@mui/system` (#19062) @aqeelat
|
|
218
|
+
|
|
8
219
|
## 8.9.2
|
|
9
220
|
|
|
10
221
|
_Jul 31, 2025_
|
|
@@ -418,8 +629,8 @@ Same changes as in `@mui/x-tree-view@8.7.0`, plus:
|
|
|
418
629
|
|
|
419
630
|
- [code-infra] Bump code-infra version and fix breaking changes (#18653) @brijeshb42
|
|
420
631
|
- [code-infra] Ensure `material-ui/disallow-react-api-in-server-components` ESLint rule is applied (#18570) @LukasTy
|
|
421
|
-
- [code-infra] Migrate to flat
|
|
422
|
-
- [code-infra] Refactor
|
|
632
|
+
- [code-infra] Migrate to flat ESLint config (#18562) @brijeshb42
|
|
633
|
+
- [code-infra] Refactor ESLint config (#18643) @LukasTy
|
|
423
634
|
- [infra] Add renovatebot rule for latest infra packages (#18609) @Janpot
|
|
424
635
|
- [infra] Move pushArgos script to code-infra (#18667) @Janpot
|
|
425
636
|
- [infra] Updates release script to fetch latest major version from upstream (#18552) @michelengelen
|
|
@@ -1333,7 +1544,7 @@ Same changes as in `@mui/x-tree-view@8.2.0`.
|
|
|
1333
1544
|
- [core] Fix all Vale errors @oliviertassinari
|
|
1334
1545
|
- [core] Move `loadStyleSheets` to internals and use it in data grid and charts (#17548) @bernardobelchior
|
|
1335
1546
|
- [core] Remove empty version (#17582) @oliviertassinari
|
|
1336
|
-
- [core] Remove
|
|
1547
|
+
- [core] Remove ESLint from codemod spec files (#17443) @alexfauquette
|
|
1337
1548
|
- [core] Remove unnecessary versions (#17597) @oliviertassinari
|
|
1338
1549
|
- [code-infra] Allow postinstall scripts for packages requesting it (#17635) @LukasTy
|
|
1339
1550
|
- [code-infra] Data Grid `vitest` changes (#17619) @JCQuintas
|
|
@@ -6827,7 +7038,7 @@ Same changes as in `@mui/x-date-pickers@7.8.0`.
|
|
|
6827
7038
|
|
|
6828
7039
|
### Core
|
|
6829
7040
|
|
|
6830
|
-
- [core] Add
|
|
7041
|
+
- [core] Add ESLint rule to restrict import from `../internals` root (#13633) @JCQuintas
|
|
6831
7042
|
- [docs-infra] Sync `\_app` folder with monorepo (#13582) @Janpot
|
|
6832
7043
|
- [license] Allow usage of Charts and Tree View Pro package for old premium licenses (#13619) @flaviendelangle
|
|
6833
7044
|
|
|
@@ -6965,7 +7176,7 @@ Same changes as in `@mui/x-date-pickers@7.7.0`.
|
|
|
6965
7176
|
|
|
6966
7177
|
- [charts] Add watermark on the pro `ResponsiveChartContainer` (#13398) @alexfauquette
|
|
6967
7178
|
- [charts] Allow to specify y-axis configuration (#13438) @alexfauquette
|
|
6968
|
-
- [charts] Fix
|
|
7179
|
+
- [charts] Fix ESLint for react compiler (#13444) @alexfauquette
|
|
6969
7180
|
- [charts] Improve themeAugmentation typing (#13433) @noraleonte
|
|
6970
7181
|
- [charts] Move the `ZAxisContextProvider` by default in the `ChartContainer` (#13465) @alexfauquette
|
|
6971
7182
|
- [charts] Use plugins to define series extremum and colors (#13397) @alexfauquette
|
|
@@ -7512,7 +7723,7 @@ Same changes as in `@mui/x-date-pickers@7.3.1`.
|
|
|
7512
7723
|
- [core] Use `describeTreeView` for focus tests (#12698) @flaviendelangle
|
|
7513
7724
|
- [core] Use `describeTreeView` for type-ahead tests (#12811) @flaviendelangle
|
|
7514
7725
|
- [code-infra] Change package manager to `pnpm` (#11875) @LukasTy
|
|
7515
|
-
- [code-infra] Closer sync with
|
|
7726
|
+
- [code-infra] Closer sync with ESLint config of codebase (#12864) @oliviertassinari
|
|
7516
7727
|
- [support-infra] Add release announcement to GitHub workflows (#11867) (#12843) @michelengelen
|
|
7517
7728
|
|
|
7518
7729
|
## 7.3.0
|
|
@@ -6,6 +6,10 @@ import type { CellColSpanInfo } from "../models/colspan.js";
|
|
|
6
6
|
import { Virtualization } from "./virtualization.js";
|
|
7
7
|
type ColumnIndex = number;
|
|
8
8
|
type ColspanMap = Map<RowId, Record<ColumnIndex, CellColSpanInfo>>;
|
|
9
|
+
export type ColspanParams = {
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
getColspan: (rowId: RowId, column: ColumnWithWidth, columnIndex: integer) => integer;
|
|
12
|
+
};
|
|
9
13
|
export declare const Colspan: {
|
|
10
14
|
initialize: typeof initializeState;
|
|
11
15
|
use: typeof useColspan;
|
package/esm/features/colspan.js
CHANGED
|
@@ -14,6 +14,7 @@ function initializeState(_params) {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
function useColspan(store, params, api) {
|
|
17
|
+
const getColspan = params.colspan?.getColspan;
|
|
17
18
|
const resetColSpan = () => {
|
|
18
19
|
store.state.colspanMap = new Map();
|
|
19
20
|
};
|
|
@@ -22,14 +23,14 @@ function useColspan(store, params, api) {
|
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
// Calculate `colSpan` for each cell in the row
|
|
25
|
-
const calculateColSpan = useEventCallback((rowId, minFirstColumn, maxLastColumn, columns) => {
|
|
26
|
+
const calculateColSpan = useEventCallback(getColspan ? (rowId, minFirstColumn, maxLastColumn, columns) => {
|
|
26
27
|
for (let i = minFirstColumn; i < maxLastColumn; i += 1) {
|
|
27
|
-
const cellProps = calculateCellColSpan(store.state.colspanMap, i, rowId, minFirstColumn, maxLastColumn, columns,
|
|
28
|
+
const cellProps = calculateCellColSpan(store.state.colspanMap, i, rowId, minFirstColumn, maxLastColumn, columns, getColspan);
|
|
28
29
|
if (cellProps.colSpan > 1) {
|
|
29
30
|
i += cellProps.colSpan - 1;
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
|
-
});
|
|
33
|
+
} : () => {});
|
|
33
34
|
api.calculateColSpan = calculateColSpan;
|
|
34
35
|
return {
|
|
35
36
|
resetColSpan,
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { Store } from '@mui/x-internals/store';
|
|
2
2
|
import { ColumnWithWidth, DimensionsState, RowId, RowsMetaState, Size } from "../models/index.js";
|
|
3
3
|
import type { BaseState, VirtualizerParams } from "../useVirtualizer.js";
|
|
4
|
+
export type DimensionsParams = {
|
|
5
|
+
rowHeight: number;
|
|
6
|
+
columnsTotalWidth: number;
|
|
7
|
+
leftPinnedWidth: number;
|
|
8
|
+
rightPinnedWidth: number;
|
|
9
|
+
topPinnedHeight: number;
|
|
10
|
+
bottomPinnedHeight: number;
|
|
11
|
+
scrollbarSize?: number;
|
|
12
|
+
};
|
|
4
13
|
export declare const Dimensions: {
|
|
5
14
|
initialize: typeof initializeState;
|
|
6
15
|
use: typeof useDimensions;
|
|
@@ -8,6 +17,7 @@ export declare const Dimensions: {
|
|
|
8
17
|
rootSize: (state: BaseState) => Size;
|
|
9
18
|
dimensions: (state: BaseState) => DimensionsState;
|
|
10
19
|
rowHeight: (state: BaseState) => number;
|
|
20
|
+
contentHeight: (state: BaseState) => number;
|
|
11
21
|
rowsMeta: (state: BaseState) => RowsMetaState;
|
|
12
22
|
columnPositions: (_: any, columns: ColumnWithWidth[]) => number[];
|
|
13
23
|
needsHorizontalScrollbar: (state: BaseState) => boolean;
|
|
@@ -9,8 +9,9 @@ import useEventCallback from '@mui/utils/useEventCallback';
|
|
|
9
9
|
import { throttle } from '@mui/x-internals/throttle';
|
|
10
10
|
import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
|
|
11
11
|
import { roundToDecimalPlaces } from '@mui/x-internals/math';
|
|
12
|
-
import { useStore,
|
|
12
|
+
import { useStore, createSelectorMemoized } from '@mui/x-internals/store';
|
|
13
13
|
import { Size } from "../models/index.js";
|
|
14
|
+
|
|
14
15
|
/* eslint-disable import/export, @typescript-eslint/no-redeclare */
|
|
15
16
|
/* eslint-disable no-underscore-dangle */
|
|
16
17
|
|
|
@@ -24,15 +25,11 @@ const EMPTY_DIMENSIONS = {
|
|
|
24
25
|
hasScrollX: false,
|
|
25
26
|
hasScrollY: false,
|
|
26
27
|
scrollbarSize: 0,
|
|
27
|
-
headerHeight: 0,
|
|
28
|
-
groupHeaderHeight: 0,
|
|
29
|
-
headerFilterHeight: 0,
|
|
30
28
|
rowWidth: 0,
|
|
31
29
|
rowHeight: 0,
|
|
32
30
|
columnsTotalWidth: 0,
|
|
33
31
|
leftPinnedWidth: 0,
|
|
34
32
|
rightPinnedWidth: 0,
|
|
35
|
-
headersTotalHeight: 0,
|
|
36
33
|
topContainerHeight: 0,
|
|
37
34
|
bottomContainerHeight: 0
|
|
38
35
|
};
|
|
@@ -40,6 +37,7 @@ const selectors = {
|
|
|
40
37
|
rootSize: state => state.rootSize,
|
|
41
38
|
dimensions: state => state.dimensions,
|
|
42
39
|
rowHeight: state => state.dimensions.rowHeight,
|
|
40
|
+
contentHeight: state => state.dimensions.contentSize.height,
|
|
43
41
|
rowsMeta: state => state.rowsMeta,
|
|
44
42
|
columnPositions: createSelectorMemoized((_, columns) => {
|
|
45
43
|
const positions = [];
|
|
@@ -87,15 +85,15 @@ function useDimensions(store, params, _api) {
|
|
|
87
85
|
refs,
|
|
88
86
|
dimensions: {
|
|
89
87
|
rowHeight,
|
|
90
|
-
headerHeight,
|
|
91
88
|
columnsTotalWidth,
|
|
92
|
-
groupHeaderHeight,
|
|
93
|
-
headerFilterHeight,
|
|
94
|
-
headersTotalHeight,
|
|
95
89
|
leftPinnedWidth,
|
|
96
|
-
rightPinnedWidth
|
|
97
|
-
|
|
90
|
+
rightPinnedWidth,
|
|
91
|
+
topPinnedHeight,
|
|
92
|
+
bottomPinnedHeight
|
|
93
|
+
},
|
|
94
|
+
onResize
|
|
98
95
|
} = params;
|
|
96
|
+
const containerNode = refs.container.current;
|
|
99
97
|
const updateDimensions = React.useCallback(() => {
|
|
100
98
|
if (isFirstSizing.current) {
|
|
101
99
|
return;
|
|
@@ -106,9 +104,9 @@ function useDimensions(store, params, _api) {
|
|
|
106
104
|
// All the floating point dimensions should be rounded to .1 decimal places to avoid subpixel rendering issues
|
|
107
105
|
// https://github.com/mui/mui-x/issues/9550#issuecomment-1619020477
|
|
108
106
|
// https://github.com/mui/mui-x/issues/15721
|
|
109
|
-
const scrollbarSize = measureScrollbarSize(
|
|
110
|
-
const topContainerHeight =
|
|
111
|
-
const bottomContainerHeight = rowsMeta.pinnedBottomRowsTotalHeight;
|
|
107
|
+
const scrollbarSize = measureScrollbarSize(containerNode, params.dimensions.scrollbarSize);
|
|
108
|
+
const topContainerHeight = topPinnedHeight + rowsMeta.pinnedTopRowsTotalHeight;
|
|
109
|
+
const bottomContainerHeight = bottomPinnedHeight + rowsMeta.pinnedBottomRowsTotalHeight;
|
|
112
110
|
const contentSize = {
|
|
113
111
|
width: columnsTotalWidth,
|
|
114
112
|
height: roundToDecimalPlaces(rowsMeta.currentPageTotalHeight, 1)
|
|
@@ -172,15 +170,11 @@ function useDimensions(store, params, _api) {
|
|
|
172
170
|
hasScrollX,
|
|
173
171
|
hasScrollY,
|
|
174
172
|
scrollbarSize,
|
|
175
|
-
headerHeight,
|
|
176
|
-
groupHeaderHeight,
|
|
177
|
-
headerFilterHeight,
|
|
178
173
|
rowWidth,
|
|
179
174
|
rowHeight,
|
|
180
175
|
columnsTotalWidth,
|
|
181
176
|
leftPinnedWidth,
|
|
182
177
|
rightPinnedWidth,
|
|
183
|
-
headersTotalHeight,
|
|
184
178
|
topContainerHeight,
|
|
185
179
|
bottomContainerHeight
|
|
186
180
|
};
|
|
@@ -191,21 +185,16 @@ function useDimensions(store, params, _api) {
|
|
|
191
185
|
store.update({
|
|
192
186
|
dimensions: newDimensions
|
|
193
187
|
});
|
|
194
|
-
|
|
188
|
+
onResize?.(newDimensions.root);
|
|
189
|
+
}, [store, containerNode, params.dimensions.scrollbarSize, params.autoHeight, onResize, rowHeight, columnsTotalWidth, leftPinnedWidth, rightPinnedWidth, topPinnedHeight, bottomPinnedHeight]);
|
|
195
190
|
const {
|
|
196
|
-
resizeThrottleMs
|
|
197
|
-
onResize
|
|
191
|
+
resizeThrottleMs
|
|
198
192
|
} = params;
|
|
199
193
|
const updateDimensionCallback = useEventCallback(updateDimensions);
|
|
200
|
-
const debouncedUpdateDimensions = React.useMemo(() => resizeThrottleMs > 0 ? throttle(
|
|
201
|
-
updateDimensionCallback();
|
|
202
|
-
onResize?.(store.state.rootSize);
|
|
203
|
-
}, resizeThrottleMs) : undefined, [resizeThrottleMs, onResize, store, updateDimensionCallback]);
|
|
194
|
+
const debouncedUpdateDimensions = React.useMemo(() => resizeThrottleMs > 0 ? throttle(updateDimensionCallback, resizeThrottleMs) : undefined, [resizeThrottleMs, updateDimensionCallback]);
|
|
204
195
|
React.useEffect(() => debouncedUpdateDimensions?.clear, [debouncedUpdateDimensions]);
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
useStoreEffect(store, selectors.rootSize, (_, size) => {
|
|
208
|
-
params.onResize?.(size);
|
|
196
|
+
const setRootSize = useEventCallback(rootSize => {
|
|
197
|
+
store.state.rootSize = rootSize;
|
|
209
198
|
if (isFirstSizing.current || !debouncedUpdateDimensions) {
|
|
210
199
|
// We want to initialize the grid dimensions as soon as possible to avoid flickering
|
|
211
200
|
isFirstSizing.current = false;
|
|
@@ -214,6 +203,8 @@ function useDimensions(store, params, _api) {
|
|
|
214
203
|
debouncedUpdateDimensions();
|
|
215
204
|
}
|
|
216
205
|
});
|
|
206
|
+
useLayoutEffect(() => observeRootNode(containerNode, store, setRootSize), [containerNode, store, setRootSize]);
|
|
207
|
+
useLayoutEffect(updateDimensions, [updateDimensions]);
|
|
217
208
|
const rowsMeta = useRowsMeta(store, params, updateDimensions);
|
|
218
209
|
return {
|
|
219
210
|
updateDimensions,
|
|
@@ -250,7 +241,6 @@ function useRowsMeta(store, params, updateDimensions) {
|
|
|
250
241
|
return entry;
|
|
251
242
|
});
|
|
252
243
|
const {
|
|
253
|
-
rowIdToIndexMap,
|
|
254
244
|
applyRowHeight
|
|
255
245
|
} = params;
|
|
256
246
|
const processHeightEntry = React.useCallback(row => {
|
|
@@ -282,12 +272,7 @@ function useRowsMeta(store, params, updateDimensions) {
|
|
|
282
272
|
}
|
|
283
273
|
}
|
|
284
274
|
if (getRowSpacing) {
|
|
285
|
-
const
|
|
286
|
-
const spacing = getRowSpacing(row, {
|
|
287
|
-
isFirstVisible: indexRelativeToCurrentPage === 0,
|
|
288
|
-
isLastVisible: indexRelativeToCurrentPage === rows.length - 1,
|
|
289
|
-
indexRelativeToCurrentPage
|
|
290
|
-
});
|
|
275
|
+
const spacing = getRowSpacing(row);
|
|
291
276
|
entry.spacingTop = spacing.top ?? 0;
|
|
292
277
|
entry.spacingBottom = spacing.bottom ?? 0;
|
|
293
278
|
} else {
|
|
@@ -296,17 +281,17 @@ function useRowsMeta(store, params, updateDimensions) {
|
|
|
296
281
|
}
|
|
297
282
|
applyRowHeight?.(entry, row);
|
|
298
283
|
return entry;
|
|
299
|
-
}, [store,
|
|
284
|
+
}, [store, getRowHeightProp, getRowHeightEntry, getEstimatedRowHeight, rowHeight, getRowSpacing, applyRowHeight]);
|
|
300
285
|
const hydrateRowsMeta = React.useCallback(() => {
|
|
301
286
|
hasRowWithAutoHeight.current = false;
|
|
302
|
-
const pinnedTopRowsTotalHeight = pinnedRows
|
|
287
|
+
const pinnedTopRowsTotalHeight = pinnedRows?.top.reduce((acc, row) => {
|
|
303
288
|
const entry = processHeightEntry(row);
|
|
304
289
|
return acc + entry.content + entry.spacingTop + entry.spacingBottom + entry.detail;
|
|
305
|
-
}, 0);
|
|
306
|
-
const pinnedBottomRowsTotalHeight = pinnedRows
|
|
290
|
+
}, 0) ?? 0;
|
|
291
|
+
const pinnedBottomRowsTotalHeight = pinnedRows?.bottom.reduce((acc, row) => {
|
|
307
292
|
const entry = processHeightEntry(row);
|
|
308
293
|
return acc + entry.content + entry.spacingTop + entry.spacingBottom + entry.detail;
|
|
309
|
-
}, 0);
|
|
294
|
+
}, 0) ?? 0;
|
|
310
295
|
const positions = [];
|
|
311
296
|
const currentPageTotalHeight = rows.reduce((acc, row) => {
|
|
312
297
|
positions.push(acc);
|
|
@@ -362,7 +347,7 @@ function useRowsMeta(store, params, updateDimensions) {
|
|
|
362
347
|
const entry = entries[i];
|
|
363
348
|
const height = entry.borderBoxSize && entry.borderBoxSize.length > 0 ? entry.borderBoxSize[0].blockSize : entry.contentRect.height;
|
|
364
349
|
const rowId = entry.target.__mui_id;
|
|
365
|
-
const focusedVirtualRowId = params.focusedVirtualCell()?.id;
|
|
350
|
+
const focusedVirtualRowId = params.focusedVirtualCell?.()?.id;
|
|
366
351
|
if (focusedVirtualRowId === rowId && height === 0) {
|
|
367
352
|
// Focused virtual row has 0 height.
|
|
368
353
|
// We don't want to store it to avoid scroll jumping.
|
|
@@ -401,7 +386,7 @@ function useRowsMeta(store, params, updateDimensions) {
|
|
|
401
386
|
resetRowHeights
|
|
402
387
|
};
|
|
403
388
|
}
|
|
404
|
-
function observeRootNode(node, store) {
|
|
389
|
+
function observeRootNode(node, store, setRootSize) {
|
|
405
390
|
if (!node) {
|
|
406
391
|
return undefined;
|
|
407
392
|
}
|
|
@@ -411,9 +396,7 @@ function observeRootNode(node, store) {
|
|
|
411
396
|
height: roundToDecimalPlaces(bounds.height, 1)
|
|
412
397
|
};
|
|
413
398
|
if (store.state.rootSize === Size.EMPTY || !Size.equals(initialSize, store.state.rootSize)) {
|
|
414
|
-
|
|
415
|
-
rootSize: initialSize
|
|
416
|
-
});
|
|
399
|
+
setRootSize(initialSize);
|
|
417
400
|
}
|
|
418
401
|
if (typeof ResizeObserver === 'undefined') {
|
|
419
402
|
return undefined;
|
|
@@ -427,9 +410,7 @@ function observeRootNode(node, store) {
|
|
|
427
410
|
height: roundToDecimalPlaces(entry.contentRect.height, 1)
|
|
428
411
|
};
|
|
429
412
|
if (!Size.equals(rootSize, store.state.rootSize)) {
|
|
430
|
-
|
|
431
|
-
rootSize
|
|
432
|
-
});
|
|
413
|
+
setRootSize(rootSize);
|
|
433
414
|
}
|
|
434
415
|
});
|
|
435
416
|
observer.observe(node);
|
|
@@ -5,6 +5,16 @@ import type { CellColSpanInfo } from "../models/colspan.js";
|
|
|
5
5
|
import { Dimensions } from "./dimensions.js";
|
|
6
6
|
import type { BaseState, VirtualizerParams } from "../useVirtualizer.js";
|
|
7
7
|
import { PinnedRowPosition, RenderContext, ColumnsRenderContext, ColumnWithWidth, RowId, RowEntry } from "../models/index.js";
|
|
8
|
+
export type VirtualizationParams = {
|
|
9
|
+
/** @default false */
|
|
10
|
+
isRtl?: boolean;
|
|
11
|
+
/** The row buffer in pixels to render before and after the viewport.
|
|
12
|
+
* @default 150 */
|
|
13
|
+
rowBufferPx?: number;
|
|
14
|
+
/** The column buffer in pixels to render before and after the viewport.
|
|
15
|
+
* @default 150 */
|
|
16
|
+
columnBufferPx?: number;
|
|
17
|
+
};
|
|
8
18
|
export type VirtualizationState = {
|
|
9
19
|
enabled: boolean;
|
|
10
20
|
enabledForRows: boolean;
|
|
@@ -44,16 +54,16 @@ type RequiredAPI = Dimensions.API & AbstractAPI;
|
|
|
44
54
|
declare function useVirtualization(store: Store<BaseState>, params: VirtualizerParams, api: RequiredAPI): {
|
|
45
55
|
getters: {
|
|
46
56
|
setPanels: React.Dispatch<React.SetStateAction<Readonly<Map<any, React.ReactNode>>>>;
|
|
47
|
-
getRows: (rowParams
|
|
57
|
+
getRows: (rowParams?: {
|
|
48
58
|
rows?: RowEntry[];
|
|
49
59
|
position?: PinnedRowPosition;
|
|
50
60
|
renderContext?: RenderContext;
|
|
51
|
-
}
|
|
61
|
+
}, unstable_rowTree?: Record<RowId, any>) => React.ReactNode[];
|
|
52
62
|
getContainerProps: () => {
|
|
53
|
-
ref:
|
|
63
|
+
ref: (node: HTMLDivElement | null) => void;
|
|
54
64
|
};
|
|
55
65
|
getScrollerProps: () => {
|
|
56
|
-
ref:
|
|
66
|
+
ref: (node: HTMLDivElement | null) => void;
|
|
57
67
|
onScroll: () => void;
|
|
58
68
|
onWheel: ((event: React.WheelEvent) => void) | undefined;
|
|
59
69
|
onTouchMove: ((event: React.TouchEvent) => void) | undefined;
|
|
@@ -62,22 +72,19 @@ declare function useVirtualization(store: Store<BaseState>, params: VirtualizerP
|
|
|
62
72
|
tabIndex: number | undefined;
|
|
63
73
|
};
|
|
64
74
|
getContentProps: () => {
|
|
65
|
-
style: React.CSSProperties;
|
|
66
|
-
role: string;
|
|
67
75
|
ref: (node: HTMLDivElement | null) => void;
|
|
68
|
-
|
|
69
|
-
getRenderZoneProps: () => {
|
|
76
|
+
style: React.CSSProperties;
|
|
70
77
|
role: string;
|
|
71
78
|
};
|
|
72
79
|
getScrollbarVerticalProps: () => {
|
|
73
|
-
ref:
|
|
80
|
+
ref: (node: HTMLDivElement | null) => void;
|
|
74
81
|
scrollPosition: React.RefObject<{
|
|
75
82
|
top: number;
|
|
76
83
|
left: number;
|
|
77
84
|
}>;
|
|
78
85
|
};
|
|
79
86
|
getScrollbarHorizontalProps: () => {
|
|
80
|
-
ref:
|
|
87
|
+
ref: (node: HTMLDivElement | null) => void;
|
|
81
88
|
scrollPosition: React.RefObject<{
|
|
82
89
|
top: number;
|
|
83
90
|
left: number;
|