@mui/x-data-grid-generator 9.13.0 → 9.15.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 CHANGED
@@ -1,5 +1,330 @@
1
1
  # Changelog
2
2
 
3
+ ## 9.15.0
4
+
5
+ _Oct 6, 2026_
6
+
7
+ We'd like to extend a big thank you to the 17 contributors who made this release possible. Here are some highlights ✨:
8
+
9
+ - 🌍 Add Russian (ru-RU) locale to the Scheduler
10
+ - 📐 New `height` prop to size the Data Grid without a wrapper
11
+ - 📅 New `onCancel` callback prop on the Date and Time Pickers
12
+ - ⌨️ Home/End, Ctrl+Home/End, and PageUp/PageDown keyboard navigation in the Charts
13
+ - 🔒 Data Grid and Charts exports work under a Content Security Policy
14
+ - 🐞 Bugfixes
15
+ - 📚 Documentation improvements
16
+
17
+ Special thanks go out to these community members for their valuable contributions:
18
+ @Anexus5919, @davidjb, @kwy404, @mixelburg, @Sazuru
19
+
20
+ The following team members contributed to this release:
21
+ @arminmeh, @brijeshb42, @flaviendelangle, @Janpot, @JCQuintas, @LukasTy, @mapache-salvaje, @michelengelen, @noraleonte, @rita-codes, @romgrk, @siriwatknp
22
+
23
+ ### Data Grid
24
+
25
+ #### `@mui/x-data-grid@9.15.0`
26
+
27
+ - [DataGrid] Add `height` prop for sizing without a wrapper (#23628) @michelengelen
28
+ - [DataGrid] Cap the pagination toolbar so the footer height is stable on mount (#23547) @JCQuintas
29
+ - [DataGrid] Document `rowsSet`, `filteredRowsSet` & `sortedRowsSet` events (#23631) @michelengelen
30
+ - [DataGrid] Extract the data source polling into a shared hook (#23714) @LukasTy
31
+ - [DataGrid] Fix `autosizeColumns` with wrapped header text (#23241) @siriwatknp
32
+ - [DataGrid] Fix flex column jump when a detail panel expands (#23576) @michelengelen
33
+ - [DataGrid] Fix stale columns and stalled loading in the demo data generator (#23727) @LukasTy
34
+ - [DataGrid] Fix stale rows and lost edits in `useMockServer` (#23751) @LukasTy
35
+ - [DataGrid] Fix the `height` prop overflowing a narrow flex row parent (#23745) @LukasTy
36
+ - [DataGrid] Fix the `inputRef` prop type warning in select-based filter inputs (#23728) @LukasTy
37
+ - [DataGrid] Keep empty first and last cells when copying rows (#23753) @Anexus5919
38
+ - [DataGrid] Keep pinned cells opaque without `color-mix()` support (#23563) @michelengelen
39
+ - [DataGrid] Let the theme disable the row checkbox ripple (#23703) @siriwatknp
40
+ - [DataGrid] Stop the data source polling after the grid unmounts (#23709) @LukasTy
41
+ - [DataGrid] Stop the lazy loading polling when `lazyLoading` turns off (#23717) @LukasTy
42
+ - [DataGrid] Support `href` on `GridActionsCellItem` (#23630) @michelengelen
43
+
44
+ #### `@mui/x-data-grid-pro@9.15.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
45
+
46
+ Same changes as in `@mui/x-data-grid@9.15.0`.
47
+
48
+ #### `@mui/x-data-grid-premium@9.15.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
49
+
50
+ Same changes as in `@mui/x-data-grid-pro@9.15.0`, plus:
51
+
52
+ - [DataGridPremium] Clear the aggregation from the column menu (#23641) @Anexus5919
53
+ - [DataGridPremium] Fix exports failing or hanging under a Content Security Policy (#23521) @JCQuintas
54
+
55
+ ### Date and Time Pickers
56
+
57
+ #### `@mui/x-date-pickers@9.15.0`
58
+
59
+ - [fields] Focus the section synchronously on `mousedown` (#23642) @michelengelen
60
+ - [pickers] Add `onCancel` callback prop (#23669) @michelengelen
61
+ - [pickers] Fix `TimeClock` `PageUp` and `PageDown` at noon (#23741) @kwy404
62
+ - [pickers] Fix `getDaysInMonth` on dates bound to a timezone before 1970 (#23302) @JCQuintas
63
+ - [pickers] Fix month label jump when switching months fast (#23645) @michelengelen
64
+ - [pickers] Fix singular/plural clock number ARIA labels (#23683) @michelengelen
65
+ - [pickers] Fix the uncontrolled `defaultValue` change warning (#23702) @LukasTy
66
+ - [pickers] Migrate picker hooks to the `manager` pattern (#23684) @michelengelen
67
+ - [pickers] Preserve plain Day.js values across system DST changes (#22278) @LukasTy
68
+
69
+ #### `@mui/x-date-pickers-pro@9.15.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
70
+
71
+ Same changes as in `@mui/x-date-pickers@9.15.0`.
72
+
73
+ ### Charts
74
+
75
+ #### `@mui/x-charts@9.15.0`
76
+
77
+ - [charts] Add Home/End, Ctrl+Home/End, and PageUp/PageDown keyboard navigation (#23146) @JCQuintas
78
+ - [charts] Disable the `SparkLineChart` axis listener when nothing uses it (#23681) @Anexus5919
79
+ - [charts] Fix `Unsupported style property @media` warning with responsive theme typography (#23705) @noraleonte
80
+ - [charts] Pass `SparkLineChart` container props to the data provider (#23690) @mixelburg
81
+
82
+ #### `@mui/x-charts-pro@9.15.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
83
+
84
+ Same changes as in `@mui/x-charts@9.15.0`, plus:
85
+
86
+ - [charts-pro] Fix image export under a CSP when styles come only from `<link>` stylesheets (#23721) @Anexus5919
87
+ - [charts-pro] Fix exports failing or hanging under a Content Security Policy (#23521) @JCQuintas
88
+
89
+ #### `@mui/x-charts-premium@9.15.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
90
+
91
+ Same changes as in `@mui/x-charts-pro@9.15.0`, plus:
92
+
93
+ - [charts-premium] Move the Excel export defaults out of the types file (#23643) @JCQuintas
94
+
95
+ ### Tree View
96
+
97
+ #### `@mui/x-tree-view@9.15.0`
98
+
99
+ - [tree view] Use `aria-selected` instead of `aria-checked` when `checkboxSelection` is disabled (#23679) @michelengelen
100
+
101
+ #### `@mui/x-tree-view-pro@9.15.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
102
+
103
+ Same changes as in `@mui/x-tree-view@9.15.0`.
104
+
105
+ ### Scheduler
106
+
107
+ #### `@mui/x-scheduler@9.0.0-beta.13`
108
+
109
+ - [l10n] Add Russian (ru-RU) locale (#23567) @Sazuru
110
+ - [scheduler] Clamp the placeholder span to the week row (#23734) @rita-codes
111
+ - [scheduler] Fix the agenda view crashing when hiding empty days and no event is in the horizon (#23570) @rita-codes
112
+ - [scheduler] Fix the event dialog moving untouched dates across timezones (#23462) @rita-codes
113
+ - [scheduler] Give events a proper accessible name (#23675) @rita-codes
114
+ - [scheduler] Index events by visible range (#23362) @flaviendelangle
115
+ - [scheduler] Index timeline occurrences by position (#23367) @flaviendelangle
116
+ - [scheduler] Pass the weekday token to the monthly recurrence labels (#23637) @Anexus5919
117
+ - [scheduler] Remove redundant readonly recurrence subscription (#23626) @flaviendelangle
118
+ - [scheduler] Render the event-item recurring icon once (#23621) @flaviendelangle
119
+ - [scheduler] Share custom recurrence draft updates (#23618) @flaviendelangle
120
+ - [scheduler] Share edit and show-details menu item markup (#23627) @flaviendelangle
121
+ - [scheduler] Simplify time-grid event duration checks (#23611) @flaviendelangle
122
+
123
+ #### `@mui/x-scheduler-premium@9.0.0-beta.13` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
124
+
125
+ Same changes as in `@mui/x-scheduler@9.0.0-beta.13`, plus:
126
+
127
+ - [scheduler-premium] Dependencies - SS/FF/SF and lag in the auto-scheduling engine (#23623) @rita-codes
128
+ - [scheduler-premium] Read the RRULE `UNTIL` as a UTC instant (#23739) @rita-codes
129
+ - [scheduler-premium] Read the `body2` font size unit in the timeline row height (#23736) @rita-codes
130
+
131
+ ### Chat
132
+
133
+ #### `@mui/x-chat@9.0.0-alpha.19`
134
+
135
+ - [chat] Cap markdown input length to avoid a render-thread freeze (#23008) @Anexus5919
136
+ - [chat] Distinguish "history not loaded yet" from "empty conversation" (#23607) @JCQuintas
137
+
138
+ #### `@mui/x-chat-headless@9.0.0-alpha.19`
139
+
140
+ - [chat] Distinguish "history not loaded yet" from "empty conversation" (#23607) @JCQuintas
141
+
142
+ ### Codemod
143
+
144
+ #### `@mui/x-codemod@9.15.0`
145
+
146
+ Internal changes.
147
+
148
+ ### Docs
149
+
150
+ - [DataGrid] Make product comparisons more explicit on Overview page (#22696) @mapache-salvaje
151
+ - [tree view] Fix typo on Customization page (#23691) @davidjb
152
+
153
+ ### Core
154
+
155
+ - [code-infra] Cap typecheck concurrency and remove `typescript:ci` (#23731) @Janpot
156
+ - [code-infra] Clear the demo data caches between regression routes (#23747) @Janpot
157
+ - [code-infra] Enable pnpm `autoDedupe` (#23706) @LukasTy
158
+ - [code-infra] Fix the stale `@types/node` entry in the lockfile (#23742) @LukasTy
159
+ - [code-infra] Mark the Argos reference branch for release branch cuts (#23776) @Janpot
160
+ - [code-infra] Only fake timers while a regression test case mounts (#23748) @Janpot
161
+ - [code-infra] Widen `@babel/runtime` range and stop emitting empty class fields (#23707) @brijeshb42
162
+ - [docs-infra] Migrate deploy-succeeded to event-triggered function (#23634) @brijeshb42
163
+ - [docs-infra] Retire the docs service worker (#23674) @Janpot
164
+
165
+ ### Miscellaneous
166
+
167
+ - [ci] Flake-fix caller: follow mui-public's central model default (#23680) @Janpot
168
+ - [internals] Fix `hash` word indexing and buffer sizing (#23494) @romgrk
169
+ - [test] Fix regression flake when an aborted image errors mid-wait (#23708) @JCQuintas
170
+ - [test] Fix the flaky data grid export tests (#23720) @LukasTy
171
+ - [test] Fix the flaky detail panel flex width test on React 18 (#23710) @LukasTy
172
+ - [test] Load the regression fonts from npm instead of Google Fonts (#23775) @Janpot
173
+ - [test] Make regression screenshot rasterization deterministic (#23722) @LukasTy
174
+ - [test] Wait for the Mars texture before the `MarsMap` regression screenshot (#23730) @LukasTy
175
+ - [virtualizer] Do not affect `columnPositions` selector with unrelated state change (#23629) @arminmeh
176
+ - [x-internals] Import Base UI utils directly instead of re-exporting them (#23373) @romgrk
177
+ - [x-internals] Import the store from `@base-ui/utils` directly (#23335) @romgrk
178
+
179
+ ## 9.14.0
180
+
181
+ _Sep 17, 2026_
182
+
183
+ We'd like to extend a big thank you to the 16 contributors who made this release possible. Here are some highlights ✨:
184
+
185
+ - 🌍 Add Hebrew (he-IL) locale to the Scheduler
186
+ - 📅 Scheduler time grid now opens at 7 AM by default, configurable with the new `initialScrollTime` prop
187
+ - 🗓️ Auto-scheduling engine for finish-to-start dependencies in the Premium Event Timeline
188
+ - 🧩 New content slots for the Event Timeline event block and resource title cell
189
+ - ♿️ Charts announce the visible zoom range to screen readers
190
+ - 🐞 Bugfixes
191
+ - 📚 Documentation improvements
192
+
193
+ Special thanks go out to these community members for their valuable contributions:
194
+ @eterry1388, @jamesDin, @kareem-ib, @mateuseap, @mustafajw07
195
+
196
+ The following team members contributed to this release:
197
+ @arminmeh, @bernardobelchior, @brijeshb42, @flaviendelangle, @hasdfa, @Janpot, @JCQuintas, @MBilalShafi, @michelengelen, @noraleonte, @rita-codes
198
+
199
+ ### Data Grid
200
+
201
+ #### `@mui/x-data-grid@9.14.0`
202
+
203
+ - [DataGrid] Do not crash on unmount when the document has no body (#23431) @eterry1388
204
+ - [DataGrid] Fix `MissingRowIdError` on cell `mousedown`/`mouseup` after row removal (#23261) @kareem-ib
205
+ - [DataGrid] Fix quick filter dropping a pending search on parser identity change (#23575) @michelengelen
206
+ - [DataGrid] Keep overlays sticky in RTL mode (#23492) @arminmeh
207
+ - [DataGrid] Prevent scroll area state update before mount (#23478) @michelengelen
208
+ - [DataGrid] Remove `'menu'` role from the actions cell (#23437) @michelengelen
209
+
210
+ #### `@mui/x-data-grid-pro@9.14.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
211
+
212
+ Same changes as in `@mui/x-data-grid@9.14.0`, plus:
213
+
214
+ - [DataGridPro] Fix data integrity issue in nested server data (#23518) @MBilalShafi
215
+ - [DataGridPro] Keep parent selection when lazily loaded children arrive (#23421) @michelengelen
216
+
217
+ #### `@mui/x-data-grid-premium@9.14.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
218
+
219
+ Same changes as in `@mui/x-data-grid-pro@9.14.0`.
220
+
221
+ ### Date and Time Pickers
222
+
223
+ #### `@mui/x-date-pickers@9.14.0`
224
+
225
+ Internal changes.
226
+
227
+ #### `@mui/x-date-pickers-pro@9.14.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
228
+
229
+ Same changes as in `@mui/x-date-pickers@9.14.0`.
230
+
231
+ ### Charts
232
+
233
+ #### `@mui/x-charts@9.14.0`
234
+
235
+ - [charts] Announce the visible zoom range to screen readers (#23371) @JCQuintas
236
+ - [charts] Fix Premium chart zoom props and `apiRef` forwarding (#23590) @bernardobelchior
237
+
238
+ #### `@mui/x-charts-pro@9.14.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
239
+
240
+ Same changes as in `@mui/x-charts@9.14.0`.
241
+
242
+ #### `@mui/x-charts-premium@9.14.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
243
+
244
+ Same changes as in `@mui/x-charts-pro@9.14.0`, plus:
245
+
246
+ - [charts-premium] Add the Excel data extraction layer (#23569) @JCQuintas
247
+ - [charts-premium] Forward `apiRef` on `RadialBarChart` and `RadialLineChart` (#23625) @JCQuintas
248
+
249
+ ### Tree View
250
+
251
+ #### `@mui/x-tree-view@9.14.0`
252
+
253
+ - [tree view] Optimize lazy loading store writes for nested children (#23489) @noraleonte
254
+ - [tree view] Prune stale children when replacing an item's children (#23598) @JCQuintas
255
+
256
+ #### `@mui/x-tree-view-pro@9.14.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
257
+
258
+ Same changes as in `@mui/x-tree-view@9.14.0`.
259
+
260
+ ### Scheduler
261
+
262
+ #### Breaking changes
263
+
264
+ - The `dataSource` prop has been removed from the Community Event Calendar components:
265
+ `EventCalendar`, `StandaloneDayView`, `StandaloneWeekView`, `StandaloneMonthView`,
266
+ `StandaloneAgendaView`, `StandaloneCompactDayView`, `StandaloneCompactThreeDayView` and
267
+ `StandaloneCompactWeekView`.
268
+
269
+ Lazy loading has always been Premium-only, and the prop never had any effect on these
270
+ components: it left the calendar in a permanent loading state. To load events through a data
271
+ source, use `EventCalendarPremium` (or the Premium standalone views) and `EventTimelinePremium`,
272
+ where `dataSource` is unchanged.
273
+
274
+ ```diff
275
+ -import { EventCalendar } from '@mui/x-scheduler/event-calendar';
276
+ +import { EventCalendarPremium } from '@mui/x-scheduler-premium/event-calendar-premium';
277
+
278
+ -<EventCalendar dataSource={dataSource} />
279
+ +<EventCalendarPremium dataSource={dataSource} />
280
+ ```
281
+
282
+ #### `@mui/x-scheduler@9.0.0-beta.12`
283
+
284
+ - [l10n] Add Hebrew (he-IL) locale (#23577) @jamesDin
285
+ - [scheduler] Add content slots for the Event Timeline event block and resource title cell (#23557) @rita-codes
286
+ - [scheduler] Fix `onPreferencesChange` never being called on `EventCalendar` (#23568) @rita-codes
287
+ - [scheduler] Fix flaky timeline observer absorb (#23523) @JCQuintas
288
+ - [scheduler] Open the time grid at 7 AM by default and add `initialScrollTime` (#23594) @rita-codes
289
+ - [scheduler] Pin sibling scheduler packages to exact versions (#23574) @rita-codes
290
+ - [scheduler] Read form initialization settings without subscriptions (#23614) @flaviendelangle
291
+ - [scheduler] Remove `dataSource` from the Community components (#23483) @mustafajw07
292
+ - [scheduler] Remove redundant recurrence subscriptions (#23610) @flaviendelangle
293
+ - [scheduler] Remove unused more-events popover count (#23619) @flaviendelangle
294
+ - [scheduler] Remove unused refs (#23616) @flaviendelangle
295
+ - [scheduler] Reuse precomputed timeline duration (#23620) @flaviendelangle
296
+ - [scheduler] Reuse recurrence option labels (#23609) @flaviendelangle
297
+ - [scheduler] Reuse recurrence presets for form drafts (#23615) @flaviendelangle
298
+ - [scheduler] Simplify month-view overflow counting (#23617) @flaviendelangle
299
+ - [scheduler] Use form store state to guard submissions (#23613) @flaviendelangle
300
+
301
+ #### `@mui/x-scheduler-premium@9.0.0-beta.12` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
302
+
303
+ Same changes as in `@mui/x-scheduler@9.0.0-beta.12`, plus:
304
+
305
+ - [scheduler-premium] Dependencies - Arrows and terminals for SS, FF and SF (#23524) @rita-codes
306
+ - [scheduler-premium] Dependencies - Auto-scheduling engine (FS) (#23439) @rita-codes
307
+
308
+ ### Docs
309
+
310
+ - [DataGrid][docs] Fix "Apply filters on demand" demo (#23602) @mateuseap
311
+ - [docs] Add recipe for getting the tree view's root DOM element via `ref` (#22941) @michelengelen
312
+ - [docs][pickers] Mention `Moment.js` maintenance mode (#23601) @mateuseap
313
+
314
+ ### Core
315
+
316
+ - [code-infra] Gate the `DataGridScrollRestoration` screenshot on the horizontal restore (#23527) @JCQuintas
317
+ - [code-infra] Let the `NoColumnsOverlay` demo settle before screenshotting (#23529) @JCQuintas
318
+ - [code-infra] Pin the only-allow version in the preinstall hook (#23551) @Janpot
319
+ - [code-infra] Remove disabled Discord release announcement workflow (#23554) @Janpot
320
+ - [code-infra] Trial: Claude CI flake-fix caller (#23556) @Janpot
321
+
322
+ ### Miscellaneous
323
+
324
+ - [chat] Add feedback form to the docs (#23403) @hasdfa
325
+ - [ci] Grant actions: read to the flake-fix caller (#23560) @Janpot
326
+ - [ci] Update flake-fix caller to mui-public#1849 (#23571) @Janpot
327
+
3
328
  ## 9.13.0
4
329
 
5
330
  <!-- generated comparing v9.12.0..master -->
@@ -1,5 +1,5 @@
1
1
  import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
2
- import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
3
  import { GridLogicOperator, GRID_AGGREGATION_FUNCTIONS, gridStringOrNumberComparator } from '@mui/x-data-grid-premium';
4
4
  import { randomInt } from "../services/random-generator.mjs";
5
5
  const getAvailableAggregationFunctions = columnType => {
@@ -2,6 +2,7 @@ import type { GridColumnVisibilityModel } from '@mui/x-data-grid-premium';
2
2
  import type { GridDemoData } from "../services/real-data-service.mjs";
3
3
  import type { GridColDefGenerator } from "../services/gridColDefGenerator.mjs";
4
4
  import type { AddPathToDemoDataOptions, DemoTreeDataValue } from "../services/tree-data-generator.mjs";
5
+ export declare function clearDemoDataCache(): void;
5
6
  export type DemoDataReturnType = {
6
7
  data: DemoTreeDataValue;
7
8
  loading: boolean;
@@ -2,6 +2,7 @@ import type { GridColumnVisibilityModel } from '@mui/x-data-grid-premium';
2
2
  import type { GridDemoData } from "../services/real-data-service.js";
3
3
  import type { GridColDefGenerator } from "../services/gridColDefGenerator.js";
4
4
  import type { AddPathToDemoDataOptions, DemoTreeDataValue } from "../services/tree-data-generator.js";
5
+ export declare function clearDemoDataCache(): void;
5
6
  export type DemoDataReturnType = {
6
7
  data: DemoTreeDataValue;
7
8
  loading: boolean;
@@ -6,6 +6,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
6
6
  Object.defineProperty(exports, "__esModule", {
7
7
  value: true
8
8
  });
9
+ exports.clearDemoDataCache = clearDemoDataCache;
9
10
  exports.deepFreeze = void 0;
10
11
  exports.extrapolateSeed = extrapolateSeed;
11
12
  exports.useDemoData = exports.getInitialState = exports.getColumnsFromOptions = void 0;
@@ -21,6 +22,9 @@ const dataCache = new _lruCache.LRUCache({
21
22
  max: 10,
22
23
  ttl: 60 * 5 * 1e3 // 5 minutes
23
24
  });
25
+ function clearDemoDataCache() {
26
+ dataCache.clear();
27
+ }
24
28
  // Generate fake data from a seed.
25
29
  // It's about x20 faster than getRealData.
26
30
  async function extrapolateSeed(rowLength, data) {
@@ -124,7 +128,9 @@ const useDemoData = options => {
124
128
  });
125
129
  React.useEffect(() => {
126
130
  const treeDataKey = (options.treeData?.maxDepth ?? 1) > 1 ? `${options.treeData?.maxDepth}-${options.treeData?.averageChildren ?? 2}-${options.treeData?.groupingField ?? ''}` : 'false';
127
- const cacheKey = `${options.dataSet}-${rowLength}-${index}-${options.maxColumns}-multiSelect:${options.multiSelect ? 'true' : 'false'}-treeData:${treeDataKey}`;
131
+ // The cached data includes `columns` and `initialState`, so every column option must be in the key.
132
+ const visibleFieldsKey = options.visibleFields ? options.visibleFields.join(',') : 'all';
133
+ const cacheKey = `${options.dataSet}-${rowLength}-${index}-${options.maxColumns}-multiSelect:${options.multiSelect ? 'true' : 'false'}-editable:${options.editable ? 'true' : 'false'}-visibleFields:${visibleFieldsKey}-treeData:${treeDataKey}`;
128
134
 
129
135
  // Cache to allow fast switch between the JavaScript and TypeScript version
130
136
  // of the demos.
@@ -164,7 +170,7 @@ const useDemoData = options => {
164
170
  return () => {
165
171
  active = false;
166
172
  };
167
- }, [rowLength, options.dataSet, options.maxColumns, options.treeData?.maxDepth, options.treeData?.groupingField, options.treeData?.averageChildren, options.multiSelect, index, columns]);
173
+ }, [rowLength, options.dataSet, options.maxColumns, options.treeData?.maxDepth, options.treeData?.groupingField, options.treeData?.averageChildren, options.multiSelect, options.editable, options.visibleFields, index, columns]);
168
174
  return {
169
175
  data,
170
176
  loading,
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
4
  import * as React from 'react';
5
5
  import { LRUCache } from 'lru-cache';
6
6
  import { getRealGridData } from "../services/real-data-service.mjs";
@@ -12,6 +12,9 @@ const dataCache = new LRUCache({
12
12
  max: 10,
13
13
  ttl: 60 * 5 * 1e3 // 5 minutes
14
14
  });
15
+ export function clearDemoDataCache() {
16
+ dataCache.clear();
17
+ }
15
18
  // Generate fake data from a seed.
16
19
  // It's about x20 faster than getRealData.
17
20
  export async function extrapolateSeed(rowLength, data) {
@@ -112,7 +115,9 @@ export const useDemoData = options => {
112
115
  });
113
116
  React.useEffect(() => {
114
117
  const treeDataKey = (options.treeData?.maxDepth ?? 1) > 1 ? `${options.treeData?.maxDepth}-${options.treeData?.averageChildren ?? 2}-${options.treeData?.groupingField ?? ''}` : 'false';
115
- const cacheKey = `${options.dataSet}-${rowLength}-${index}-${options.maxColumns}-multiSelect:${options.multiSelect ? 'true' : 'false'}-treeData:${treeDataKey}`;
118
+ // The cached data includes `columns` and `initialState`, so every column option must be in the key.
119
+ const visibleFieldsKey = options.visibleFields ? options.visibleFields.join(',') : 'all';
120
+ const cacheKey = `${options.dataSet}-${rowLength}-${index}-${options.maxColumns}-multiSelect:${options.multiSelect ? 'true' : 'false'}-editable:${options.editable ? 'true' : 'false'}-visibleFields:${visibleFieldsKey}-treeData:${treeDataKey}`;
116
121
 
117
122
  // Cache to allow fast switch between the JavaScript and TypeScript version
118
123
  // of the demos.
@@ -152,7 +157,7 @@ export const useDemoData = options => {
152
157
  return () => {
153
158
  active = false;
154
159
  };
155
- }, [rowLength, options.dataSet, options.maxColumns, options.treeData?.maxDepth, options.treeData?.groupingField, options.treeData?.averageChildren, options.multiSelect, index, columns]);
160
+ }, [rowLength, options.dataSet, options.maxColumns, options.treeData?.maxDepth, options.treeData?.groupingField, options.treeData?.averageChildren, options.multiSelect, options.editable, options.visibleFields, index, columns]);
156
161
  return {
157
162
  data,
158
163
  loading,
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
4
  import * as React from 'react';
5
5
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
6
6
  import { GridCellEditStopReasons, GridEditModes, useGridApiContext, useGridRootProps } from '@mui/x-data-grid-premium';
@@ -1,6 +1,7 @@
1
1
  import type { GridGetRowsResponse, GridRowId, GridRowModel, GridColDef, GridInitialState } from '@mui/x-data-grid-premium';
2
2
  import type { AddPathToDemoDataOptions } from "../services/tree-data-generator.mjs";
3
3
  import type { ServerOptions } from "./serverUtils.mjs";
4
+ export declare function clearMockServerCache(): void;
4
5
  export declare const BASE_URL = "https://mui.com/x/api/data-grid";
5
6
  type UseMockServerResponse<T> = {
6
7
  columns: GridColDef[];
@@ -1,6 +1,7 @@
1
1
  import type { GridGetRowsResponse, GridRowId, GridRowModel, GridColDef, GridInitialState } from '@mui/x-data-grid-premium';
2
2
  import type { AddPathToDemoDataOptions } from "../services/tree-data-generator.js";
3
3
  import type { ServerOptions } from "./serverUtils.js";
4
+ export declare function clearMockServerCache(): void;
4
5
  export declare const BASE_URL = "https://mui.com/x/api/data-grid";
5
6
  type UseMockServerResponse<T> = {
6
7
  columns: GridColDef[];
@@ -6,7 +6,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
6
6
  Object.defineProperty(exports, "__esModule", {
7
7
  value: true
8
8
  });
9
- exports.useMockServer = exports.BASE_URL = void 0;
9
+ exports.BASE_URL = void 0;
10
+ exports.clearMockServerCache = clearMockServerCache;
11
+ exports.useMockServer = void 0;
10
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
13
  var _formatErrorMessage2 = _interopRequireDefault(require("@mui/x-internals/formatErrorMessage"));
12
14
  var React = _interopRequireWildcard(require("react"));
@@ -24,6 +26,9 @@ const dataCache = new _lruCache.LRUCache({
24
26
  max: 10,
25
27
  ttl: 60 * 5 * 1e3 // 5 minutes
26
28
  });
29
+ function clearMockServerCache() {
30
+ dataCache.clear();
31
+ }
27
32
  const BASE_URL = exports.BASE_URL = 'https://mui.com/x/api/data-grid';
28
33
  const GET_DEFAULT_DATASET_OPTIONS = {
29
34
  dataSet: 'Commodity',
@@ -109,6 +114,12 @@ const getInitialState = (columns, groupingField) => {
109
114
  }
110
115
  };
111
116
  };
117
+
118
+ // The key must include every option that changes the generated rows.
119
+ const getCacheKey = (options, index) => {
120
+ const treeDataKey = (options.treeData?.maxDepth ?? 1) > 1 ? `${options.treeData?.maxDepth}-${options.treeData?.averageChildren ?? 2}-${options.treeData?.groupingField ?? ''}` : 'false';
121
+ return JSON.stringify([options.dataSet, options.rowLength, index, options.maxColumns, Boolean(options.multiSelect), Boolean(options.derivedColumns), treeDataKey]);
122
+ };
112
123
  const defaultColDef = (0, _xDataGridPremium.getGridDefaultColumnTypes)();
113
124
  function sendEmptyResponse() {
114
125
  return new Promise(resolve => {
@@ -156,10 +167,8 @@ const useMockServer = (dataSetOptions, serverOptions, shouldRequestsFail, nested
156
167
  }
157
168
  return undefined;
158
169
  }, [isTreeData]);
170
+ const cacheKey = getCacheKey(options, index);
159
171
  React.useEffect(() => {
160
- const treeDataKey = (options.treeData?.maxDepth ?? 1) > 1 ? `${options.treeData?.maxDepth}-${options.treeData?.averageChildren ?? 2}-${options.treeData?.groupingField ?? ''}` : 'false';
161
- const cacheKey = `${options.dataSet}-${options.rowLength}-${index}-${options.maxColumns}-treeData:${treeDataKey}`;
162
-
163
172
  // Cache to allow fast switch between the JavaScript and TypeScript version
164
173
  // of the demos.
165
174
  if (dataCache.has(cacheKey)) {
@@ -208,7 +217,7 @@ const useMockServer = (dataSetOptions, serverOptions, shouldRequestsFail, nested
208
217
  return () => {
209
218
  active = false;
210
219
  };
211
- }, [columns, isTreeData, options.rowLength, options.treeData?.maxDepth, options.treeData?.groupingField, options.treeData?.averageChildren, options.dataSet, options.maxColumns, options.derivedColumns, index]);
220
+ }, [columns, isTreeData, options.rowLength, options.treeData?.maxDepth, options.treeData?.groupingField, options.treeData?.averageChildren, options.dataSet, options.derivedColumns, cacheKey]);
212
221
  const fetchRows = React.useCallback(async requestUrl => {
213
222
  let dataDelay = 0;
214
223
  const waitInterval = 10;
@@ -355,7 +364,6 @@ const useMockServer = (dataSetOptions, serverOptions, shouldRequestsFail, nested
355
364
  const newData = (0, _extends2.default)({}, dataRef.current, {
356
365
  rows: newRows
357
366
  });
358
- const cacheKey = `${options.dataSet}-${options.rowLength}-${index}-${options.maxColumns}`;
359
367
  dataCache.set(cacheKey, newData);
360
368
  setTimeout(() => {
361
369
  if (verbose) {
@@ -368,7 +376,7 @@ const useMockServer = (dataSetOptions, serverOptions, shouldRequestsFail, nested
368
376
  }, delay);
369
377
  dataRef.current = newData;
370
378
  });
371
- }, [index, options.dataSet, options.maxColumns, options.rowLength, serverOptions?.maxDelay, serverOptions?.minDelay, serverOptions?.verbose]);
379
+ }, [cacheKey, serverOptions?.maxDelay, serverOptions?.minDelay, serverOptions?.verbose]);
372
380
  return {
373
381
  columns: columnsWithDefaultColDef,
374
382
  initialState: options.dataSet === 'Movies' ? {} : initialState,
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
4
  import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
5
5
  import * as React from 'react';
6
6
  import { LRUCache } from 'lru-cache';
@@ -17,6 +17,9 @@ const dataCache = new LRUCache({
17
17
  max: 10,
18
18
  ttl: 60 * 5 * 1e3 // 5 minutes
19
19
  });
20
+ export function clearMockServerCache() {
21
+ dataCache.clear();
22
+ }
20
23
  export const BASE_URL = 'https://mui.com/x/api/data-grid';
21
24
  const GET_DEFAULT_DATASET_OPTIONS = {
22
25
  dataSet: 'Commodity',
@@ -102,6 +105,12 @@ const getInitialState = (columns, groupingField) => {
102
105
  }
103
106
  };
104
107
  };
108
+
109
+ // The key must include every option that changes the generated rows.
110
+ const getCacheKey = (options, index) => {
111
+ const treeDataKey = (options.treeData?.maxDepth ?? 1) > 1 ? `${options.treeData?.maxDepth}-${options.treeData?.averageChildren ?? 2}-${options.treeData?.groupingField ?? ''}` : 'false';
112
+ return JSON.stringify([options.dataSet, options.rowLength, index, options.maxColumns, Boolean(options.multiSelect), Boolean(options.derivedColumns), treeDataKey]);
113
+ };
105
114
  const defaultColDef = getGridDefaultColumnTypes();
106
115
  function sendEmptyResponse() {
107
116
  return new Promise(resolve => {
@@ -149,10 +158,8 @@ export const useMockServer = (dataSetOptions, serverOptions, shouldRequestsFail,
149
158
  }
150
159
  return undefined;
151
160
  }, [isTreeData]);
161
+ const cacheKey = getCacheKey(options, index);
152
162
  React.useEffect(() => {
153
- const treeDataKey = (options.treeData?.maxDepth ?? 1) > 1 ? `${options.treeData?.maxDepth}-${options.treeData?.averageChildren ?? 2}-${options.treeData?.groupingField ?? ''}` : 'false';
154
- const cacheKey = `${options.dataSet}-${options.rowLength}-${index}-${options.maxColumns}-treeData:${treeDataKey}`;
155
-
156
163
  // Cache to allow fast switch between the JavaScript and TypeScript version
157
164
  // of the demos.
158
165
  if (dataCache.has(cacheKey)) {
@@ -201,7 +208,7 @@ export const useMockServer = (dataSetOptions, serverOptions, shouldRequestsFail,
201
208
  return () => {
202
209
  active = false;
203
210
  };
204
- }, [columns, isTreeData, options.rowLength, options.treeData?.maxDepth, options.treeData?.groupingField, options.treeData?.averageChildren, options.dataSet, options.maxColumns, options.derivedColumns, index]);
211
+ }, [columns, isTreeData, options.rowLength, options.treeData?.maxDepth, options.treeData?.groupingField, options.treeData?.averageChildren, options.dataSet, options.derivedColumns, cacheKey]);
205
212
  const fetchRows = React.useCallback(async requestUrl => {
206
213
  let dataDelay = 0;
207
214
  const waitInterval = 10;
@@ -348,7 +355,6 @@ export const useMockServer = (dataSetOptions, serverOptions, shouldRequestsFail,
348
355
  const newData = _extends({}, dataRef.current, {
349
356
  rows: newRows
350
357
  });
351
- const cacheKey = `${options.dataSet}-${options.rowLength}-${index}-${options.maxColumns}`;
352
358
  dataCache.set(cacheKey, newData);
353
359
  setTimeout(() => {
354
360
  if (verbose) {
@@ -361,7 +367,7 @@ export const useMockServer = (dataSetOptions, serverOptions, shouldRequestsFail,
361
367
  }, delay);
362
368
  dataRef.current = newData;
363
369
  });
364
- }, [index, options.dataSet, options.maxColumns, options.rowLength, serverOptions?.maxDelay, serverOptions?.minDelay, serverOptions?.verbose]);
370
+ }, [cacheKey, serverOptions?.maxDelay, serverOptions?.minDelay, serverOptions?.verbose]);
365
371
  return {
366
372
  columns: columnsWithDefaultColDef,
367
373
  initialState: options.dataSet === 'Movies' ? {} : initialState,
@@ -238,7 +238,7 @@ export declare const createFakeServer: (dataSetOptions?: Partial<UseDemoDataOpti
238
238
  columnVisibilityModel: import("@mui/x-data-grid").GridColumnVisibilityModel;
239
239
  };
240
240
  };
241
- useQuery: (queryOptions: QueryOptions) => {
241
+ useQuery: (queryOptionsProp: QueryOptions) => {
242
242
  pageInfo: PageInfo;
243
243
  rows: GridRowModel[];
244
244
  isLoading: boolean;
@@ -238,7 +238,7 @@ export declare const createFakeServer: (dataSetOptions?: Partial<UseDemoDataOpti
238
238
  columnVisibilityModel: import("@mui/x-data-grid").GridColumnVisibilityModel;
239
239
  };
240
240
  };
241
- useQuery: (queryOptions: QueryOptions) => {
241
+ useQuery: (queryOptionsProp: QueryOptions) => {
242
242
  pageInfo: PageInfo;
243
243
  rows: GridRowModel[];
244
244
  isLoading: boolean;
package/hooks/useQuery.js CHANGED
@@ -25,7 +25,13 @@ const createFakeServer = (dataSetOptions, serverOptions) => {
25
25
  const initialState = (0, _useDemoData.getInitialState)(dataSetOptionsWithDefault, columns);
26
26
  const defaultColDef = (0, _xDataGridPro.getGridDefaultColumnTypes)();
27
27
  const columnsWithDefaultColDef = columns.map(column => (0, _extends2.default)({}, defaultColDef[column.type || 'string'], column));
28
- const useQuery = queryOptions => {
28
+ const useQuery = queryOptionsProp => {
29
+ // Keep the previous object when the content is the same, so callers can pass a new object
30
+ // on every render (for example `useQuery({})`) without refetching in a loop.
31
+ const [queryOptions, setQueryOptions] = React.useState(queryOptionsProp);
32
+ if (queryOptions !== queryOptionsProp && !(0, _isDeepEqual.isDeepEqual)(queryOptions, queryOptionsProp)) {
33
+ setQueryOptions(queryOptionsProp);
34
+ }
29
35
  const {
30
36
  data: {
31
37
  rows
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
4
  import * as React from 'react';
5
5
  import { getGridDefaultColumnTypes } from '@mui/x-data-grid-pro';
6
6
  import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
@@ -18,7 +18,13 @@ export const createFakeServer = (dataSetOptions, serverOptions) => {
18
18
  const initialState = getInitialState(dataSetOptionsWithDefault, columns);
19
19
  const defaultColDef = getGridDefaultColumnTypes();
20
20
  const columnsWithDefaultColDef = columns.map(column => _extends({}, defaultColDef[column.type || 'string'], column));
21
- const useQuery = queryOptions => {
21
+ const useQuery = queryOptionsProp => {
22
+ // Keep the previous object when the content is the same, so callers can pass a new object
23
+ // on every render (for example `useQuery({})`) without refetching in a loop.
24
+ const [queryOptions, setQueryOptions] = React.useState(queryOptionsProp);
25
+ if (queryOptions !== queryOptionsProp && !isDeepEqual(queryOptions, queryOptionsProp)) {
26
+ setQueryOptions(queryOptionsProp);
27
+ }
22
28
  const {
23
29
  data: {
24
30
  rows
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid-generator v9.13.0
2
+ * @mui/x-data-grid-generator v9.15.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid-generator v9.13.0
2
+ * @mui/x-data-grid-generator v9.15.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid-generator",
3
- "version": "9.13.0",
3
+ "version": "9.15.0",
4
4
  "author": "MUI Team",
5
5
  "description": "Generate fake data for demo purposes only.",
6
6
  "license": "MIT",
@@ -21,14 +21,14 @@
21
21
  "directory": "packages/x-data-grid-generator"
22
22
  },
23
23
  "dependencies": {
24
- "@babel/runtime": "^7.29.7",
25
- "@mui/x-data-grid": "^9.13.0",
26
- "@mui/x-data-grid-premium": "^9.13.0",
27
- "@mui/x-data-grid-pro": "^9.13.0",
28
- "@mui/x-internals": "^9.13.0",
24
+ "@babel/runtime": "^7.29.7 || ^8.0.0",
25
+ "@mui/x-data-grid": "^9.15.0",
26
+ "@mui/x-data-grid-premium": "^9.15.0",
27
+ "@mui/x-data-grid-pro": "^9.15.0",
28
+ "@mui/x-internals": "^9.15.0",
29
29
  "chance": "^1.1.13",
30
30
  "clsx": "^2.1.1",
31
- "lru-cache": "^11.5.2"
31
+ "lru-cache": "^11.5.3"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@emotion/react": "^11.9.0",
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
4
  import * as React from 'react';
5
5
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
6
6
  import { useGridApiContext, useGridRootProps } from '@mui/x-data-grid-premium';
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
4
  import * as React from 'react';
5
5
  import Autocomplete, { autocompleteClasses } from '@mui/material/Autocomplete';
6
6
  import InputBase from '@mui/material/InputBase';
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
4
  import * as React from 'react';
5
5
  import Autocomplete, { autocompleteClasses } from '@mui/material/Autocomplete';
6
6
  import InputBase from '@mui/material/InputBase';
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
4
  import * as React from 'react';
5
5
  import Select from '@mui/material/Select';
6
6
  import MenuItem from '@mui/material/MenuItem';
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
4
  import * as React from 'react';
5
5
  import clsx from 'clsx';
6
6
  import { useGridApiContext } from '@mui/x-data-grid-premium';
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
4
  import * as React from 'react';
5
5
  import Box from '@mui/material/Box';
6
6
  import Rating from '@mui/material/Rating';
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
4
  import * as React from 'react';
5
5
  import Select from '@mui/material/Select';
6
6
  import MenuItem from '@mui/material/MenuItem';
@@ -1,4 +1,4 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
1
+ import _extends from "@babel/runtime/helpers/extends";
2
2
  import * as React from 'react';
3
3
  import clsx from 'clsx';
4
4
  import { styled } from '@mui/material/styles';
@@ -4,18 +4,25 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = asyncWorker;
7
+ // Run the work even when the page never becomes idle, for example while other work keeps the task queue busy.
8
+ const IDLE_TIMEOUT = 100;
9
+ // After a timeout, yield after this many milliseconds so that a busy page gets no long task.
10
+ const TIMEOUT_WORK_BUDGET = 10;
7
11
  function asyncWorker({
8
12
  work,
9
13
  tasks,
10
14
  done
11
15
  }) {
12
16
  const myNonEssentialWork = deadline => {
13
- // If there is a surplus time in the frame, or timeout
14
- while ((deadline.timeRemaining() > 0 || deadline.didTimeout) && tasks.current > 0) {
17
+ const timeoutBudgetEnd = deadline.didTimeout ? performance.now() + TIMEOUT_WORK_BUDGET : 0;
18
+ // If there is a surplus time in the frame, or a timeout budget
19
+ while ((deadline.timeRemaining() > 0 || performance.now() < timeoutBudgetEnd) && tasks.current > 0) {
15
20
  work();
16
21
  }
17
22
  if (tasks.current > 0) {
18
- requestIdleCallback(myNonEssentialWork);
23
+ requestIdleCallback(myNonEssentialWork, {
24
+ timeout: IDLE_TIMEOUT
25
+ });
19
26
  } else {
20
27
  done();
21
28
  }
@@ -23,7 +30,9 @@ function asyncWorker({
23
30
 
24
31
  // Don't use requestIdleCallback if the time is mock, better to run synchronously in such case.
25
32
  if (typeof requestIdleCallback === 'function' && !requestIdleCallback.clock) {
26
- requestIdleCallback(myNonEssentialWork);
33
+ requestIdleCallback(myNonEssentialWork, {
34
+ timeout: IDLE_TIMEOUT
35
+ });
27
36
  } else {
28
37
  while (tasks.current > 0) {
29
38
  work();
@@ -1,15 +1,22 @@
1
+ // Run the work even when the page never becomes idle, for example while other work keeps the task queue busy.
2
+ const IDLE_TIMEOUT = 100;
3
+ // After a timeout, yield after this many milliseconds so that a busy page gets no long task.
4
+ const TIMEOUT_WORK_BUDGET = 10;
1
5
  export default function asyncWorker({
2
6
  work,
3
7
  tasks,
4
8
  done
5
9
  }) {
6
10
  const myNonEssentialWork = deadline => {
7
- // If there is a surplus time in the frame, or timeout
8
- while ((deadline.timeRemaining() > 0 || deadline.didTimeout) && tasks.current > 0) {
11
+ const timeoutBudgetEnd = deadline.didTimeout ? performance.now() + TIMEOUT_WORK_BUDGET : 0;
12
+ // If there is a surplus time in the frame, or a timeout budget
13
+ while ((deadline.timeRemaining() > 0 || performance.now() < timeoutBudgetEnd) && tasks.current > 0) {
9
14
  work();
10
15
  }
11
16
  if (tasks.current > 0) {
12
- requestIdleCallback(myNonEssentialWork);
17
+ requestIdleCallback(myNonEssentialWork, {
18
+ timeout: IDLE_TIMEOUT
19
+ });
13
20
  } else {
14
21
  done();
15
22
  }
@@ -17,7 +24,9 @@ export default function asyncWorker({
17
24
 
18
25
  // Don't use requestIdleCallback if the time is mock, better to run synchronously in such case.
19
26
  if (typeof requestIdleCallback === 'function' && !requestIdleCallback.clock) {
20
- requestIdleCallback(myNonEssentialWork);
27
+ requestIdleCallback(myNonEssentialWork, {
28
+ timeout: IDLE_TIMEOUT
29
+ });
21
30
  } else {
22
31
  while (tasks.current > 0) {
23
32
  work();
@@ -1,4 +1,4 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
1
+ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
3
3
  import { randomArrayItem } from "./random-generator.mjs";
4
4
  export const addTreeDataOptionsToDemoData = (data, options = {}) => {