@mui/x-data-grid 6.12.0 → 6.12.1

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
@@ -3,6 +3,64 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 6.12.1
7
+
8
+ _Aug 31, 2023_
9
+
10
+ We'd like to offer a big thanks to the 7 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🏎️ Perf improvement for line charts
13
+ - 🎁 Add `referenceDate` prop on pickers (#9991) @flaviendelangle
14
+ Find out more about this feature in the [documentation section](https://mui.com/x/react-date-pickers/base-concepts/#reference-date-when-no-value-is-defined).
15
+ - 🐞 Bugfixes
16
+ - 📚 Documentation improvements
17
+
18
+ ### Data Grid
19
+
20
+ #### `@mui/x-data-grid@v6.12.1`
21
+
22
+ - [DataGrid] Add a recipe showing how to render components outside of the grid (#10121) @DanailH
23
+ - [DataGrid] Fix `valueFormatter` being persisted on column type change (#10041) @cherniavskii
24
+ - [DataGrid] Fix error when keyboard navigating an empty grid (#10081) @romgrk
25
+ - [DataGrid] Replace timeout with `useTimeout` (#10179) @romgrk
26
+
27
+ #### `@mui/x-data-grid-pro@v6.12.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
28
+
29
+ Same changes as in `@mui/x-data-grid@v6.12.1`.
30
+
31
+ #### `@mui/x-data-grid-premium@v6.12.1` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
32
+
33
+ Same changes as in `@mui/x-data-grid-pro@v6.12.1`.
34
+
35
+ ### Date Pickers
36
+
37
+ #### `@mui/x-date-pickers@v6.12.1`
38
+
39
+ - [pickers] Add `referenceDate` on picker components (and `DateRangeCalendar`) (#9991) @flaviendelangle
40
+
41
+ #### `@mui/x-date-pickers-pro@v6.12.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
42
+
43
+ Same changes as in `@mui/x-date-pickers@v6.12.1`.
44
+
45
+ ### Charts / `@mui/x-charts@6.0.0-alpha.9`
46
+
47
+ - [charts] Move the line item highligh into a dedicated component (#10117) @alexfauquette
48
+
49
+ ### Docs
50
+
51
+ - [docs] Add `DemoContainer` and `DemoItem` JSDoc (#10186) @LukasTy
52
+ - [docs] Add link to `custom layout` page (#10184) @LukasTy
53
+ - [docs] Add tree view nav item (#10181) @LukasTy
54
+ - [docs] Fix wrong chart tooltip reference (#10169) @oliviertassinari
55
+ - [docs] Improve chart SEO (#10170) @oliviertassinari
56
+ - [docs] Precise expired license key condition (#10165) @oliviertassinari
57
+ - [docs] Reorganize the page menu (#10139) @alexfauquette
58
+
59
+ ### Core
60
+
61
+ - [core] Update babel configs (#9713) @romgrk
62
+ - [test] Disable false positive e2e test on webkit (#10187) @LukasTy
63
+
6
64
  ## 6.12.0
7
65
 
8
66
  _Aug 25, 2023_
@@ -46,7 +104,7 @@ Same changes as in `@mui/x-data-grid-pro@v6.12.0`.
46
104
 
47
105
  Same changes as in `@mui/x-date-pickers@v6.12.0`.
48
106
 
49
- ### Charts / `@mui/x-charts@6.12.0`
107
+ ### Charts / `@mui/x-charts@6.0.0-alpha.8`
50
108
 
51
109
  - [charts] Fix import issue (#10111) @alexfauquette
52
110
  - [charts] Fix `slotProps` propagation (#10105) @alexfauquette
@@ -256,7 +256,7 @@ export const createColumnsState = ({
256
256
 
257
257
  // If the column type has changed - merge the existing state with the default column type definition
258
258
  if (existingState && existingState.type !== newColumn.type) {
259
- existingState = _extends({}, existingState, getDefaultColTypeDef(columnTypes, newColumn.type), {
259
+ existingState = _extends({}, getDefaultColTypeDef(columnTypes, newColumn.type), {
260
260
  field
261
261
  });
262
262
  }
@@ -126,7 +126,8 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
126
126
  apiRef.current.setColumnGroupHeaderFocus(field, depth, event);
127
127
  }, [apiRef, logger]);
128
128
  const getRowIdFromIndex = React.useCallback(rowIndex => {
129
- return currentPageRows == null ? void 0 : currentPageRows[rowIndex].id;
129
+ var _currentPageRows$rowI;
130
+ return (_currentPageRows$rowI = currentPageRows[rowIndex]) == null ? void 0 : _currentPageRows$rowI.id;
130
131
  }, [currentPageRows]);
131
132
  const handleColumnHeaderKeyDown = React.useCallback((params, event) => {
132
133
  const headerTitleNode = event.currentTarget.querySelector(`.${gridClasses.columnHeaderTitleContainerContent}`);
@@ -142,7 +143,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
142
143
  }
143
144
  const viewportPageSize = apiRef.current.getViewportPageSize();
144
145
  const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
145
- const firstRowIndexInPage = 0;
146
+ const firstRowIndexInPage = currentPageRows.length > 0 ? 0 : null;
146
147
  const lastRowIndexInPage = currentPageRows.length - 1;
147
148
  const firstColIndex = 0;
148
149
  const lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
@@ -3,6 +3,7 @@ import * as React from 'react';
3
3
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
4
4
  import { useGridLogger } from '../../utils/useGridLogger';
5
5
  import { gridRowCountSelector, gridRowsLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthsSelector, gridDataRowIdsSelector, gridRowsDataRowIdToIdLookupSelector, gridRowMaximumTreeDepthSelector } from './gridRowsSelector';
6
+ import { useTimeout } from '../../utils/useTimeout';
6
7
  import { GridSignature, useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
7
8
  import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
8
9
  import { gridSortedRowIdsSelector } from '../sorting/gridSortingSelector';
@@ -38,7 +39,7 @@ export const useGridRows = (apiRef, props) => {
38
39
  const logger = useGridLogger(apiRef, 'useGridRows');
39
40
  const currentPage = useGridVisibleRows(apiRef, props);
40
41
  const lastUpdateMs = React.useRef(Date.now());
41
- const timeout = React.useRef(null);
42
+ const timeout = useTimeout();
42
43
  const getRow = React.useCallback(id => {
43
44
  const model = gridRowsLookupSelector(apiRef)[id];
44
45
  if (model) {
@@ -73,7 +74,6 @@ export const useGridRows = (apiRef, props) => {
73
74
  throttle
74
75
  }) => {
75
76
  const run = () => {
76
- timeout.current = null;
77
77
  lastUpdateMs.current = Date.now();
78
78
  apiRef.current.setState(state => _extends({}, state, {
79
79
  rows: getRowsStateFromCache({
@@ -87,10 +87,7 @@ export const useGridRows = (apiRef, props) => {
87
87
  apiRef.current.publishEvent('rowsSet');
88
88
  apiRef.current.forceUpdate();
89
89
  };
90
- if (timeout.current) {
91
- clearTimeout(timeout.current);
92
- timeout.current = null;
93
- }
90
+ timeout.clear();
94
91
  apiRef.current.caches.rows = cache;
95
92
  if (!throttle) {
96
93
  run();
@@ -98,11 +95,11 @@ export const useGridRows = (apiRef, props) => {
98
95
  }
99
96
  const throttleRemainingTimeMs = props.throttleRowsMs - (Date.now() - lastUpdateMs.current);
100
97
  if (throttleRemainingTimeMs > 0) {
101
- timeout.current = setTimeout(run, throttleRemainingTimeMs);
98
+ timeout.start(throttleRemainingTimeMs, run);
102
99
  return;
103
100
  }
104
101
  run();
105
- }, [props.throttleRowsMs, props.rowCount, props.loading, apiRef]);
102
+ }, [props.throttleRowsMs, props.rowCount, props.loading, apiRef, timeout]);
106
103
 
107
104
  /**
108
105
  * API METHODS
@@ -397,17 +394,6 @@ export const useGridRows = (apiRef, props) => {
397
394
  useGridApiMethod(apiRef, rowApi, 'public');
398
395
  useGridApiMethod(apiRef, rowProApi, props.signature === GridSignature.DataGrid ? 'private' : 'public');
399
396
 
400
- /**
401
- * EFFECTS
402
- */
403
- React.useEffect(() => {
404
- return () => {
405
- if (timeout.current !== null) {
406
- clearTimeout(timeout.current);
407
- }
408
- };
409
- }, []);
410
-
411
397
  // The effect do not track any value defined synchronously during the 1st render by hooks called after `useGridRows`
412
398
  // As a consequence, the state generated by the 1st run of this useEffect will always be equal to the initialization one
413
399
  const isFirstRender = React.useRef(true);
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.12.0
2
+ * @mui/x-data-grid v6.12.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -57,6 +57,7 @@ export { useGridDimensions } from '../hooks/features/dimensions/useGridDimension
57
57
  export { useGridStatePersistence } from '../hooks/features/statePersistence/useGridStatePersistence';
58
58
  export type { GridRestoreStatePreProcessingContext } from '../hooks/features/statePersistence/gridStatePersistenceInterface';
59
59
  export { useGridVirtualScroller, getRenderableIndexes, } from '../hooks/features/virtualization/useGridVirtualScroller';
60
+ export { useTimeout } from '../hooks/utils/useTimeout';
60
61
  export { useGridVisibleRows, getVisibleRows } from '../hooks/utils/useGridVisibleRows';
61
62
  export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
62
63
  export type { GridStateInitializer } from '../hooks/utils/useGridInitializeState';
@@ -46,6 +46,7 @@ export { useGridEvents } from '../hooks/features/events/useGridEvents';
46
46
  export { useGridDimensions } from '../hooks/features/dimensions/useGridDimensions';
47
47
  export { useGridStatePersistence } from '../hooks/features/statePersistence/useGridStatePersistence';
48
48
  export { useGridVirtualScroller, getRenderableIndexes } from '../hooks/features/virtualization/useGridVirtualScroller';
49
+ export { useTimeout } from '../hooks/utils/useTimeout';
49
50
  export { useGridVisibleRows, getVisibleRows } from '../hooks/utils/useGridVisibleRows';
50
51
  export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
51
52
  export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
@@ -266,7 +266,7 @@ export var createColumnsState = function createColumnsState(_ref5) {
266
266
 
267
267
  // If the column type has changed - merge the existing state with the default column type definition
268
268
  if (existingState && existingState.type !== newColumn.type) {
269
- existingState = _extends({}, existingState, getDefaultColTypeDef(columnTypes, newColumn.type), {
269
+ existingState = _extends({}, getDefaultColTypeDef(columnTypes, newColumn.type), {
270
270
  field: field
271
271
  });
272
272
  }
@@ -128,7 +128,8 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
128
128
  apiRef.current.setColumnGroupHeaderFocus(field, depth, event);
129
129
  }, [apiRef, logger]);
130
130
  var getRowIdFromIndex = React.useCallback(function (rowIndex) {
131
- return currentPageRows == null ? void 0 : currentPageRows[rowIndex].id;
131
+ var _currentPageRows$rowI;
132
+ return (_currentPageRows$rowI = currentPageRows[rowIndex]) == null ? void 0 : _currentPageRows$rowI.id;
132
133
  }, [currentPageRows]);
133
134
  var handleColumnHeaderKeyDown = React.useCallback(function (params, event) {
134
135
  var headerTitleNode = event.currentTarget.querySelector(".".concat(gridClasses.columnHeaderTitleContainerContent));
@@ -144,7 +145,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
144
145
  }
145
146
  var viewportPageSize = apiRef.current.getViewportPageSize();
146
147
  var colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
147
- var firstRowIndexInPage = 0;
148
+ var firstRowIndexInPage = currentPageRows.length > 0 ? 0 : null;
148
149
  var lastRowIndexInPage = currentPageRows.length - 1;
149
150
  var firstColIndex = 0;
150
151
  var lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
@@ -6,6 +6,7 @@ import * as React from 'react';
6
6
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
7
7
  import { useGridLogger } from '../../utils/useGridLogger';
8
8
  import { gridRowCountSelector, gridRowsLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthsSelector, gridDataRowIdsSelector, gridRowsDataRowIdToIdLookupSelector, gridRowMaximumTreeDepthSelector } from './gridRowsSelector';
9
+ import { useTimeout } from '../../utils/useTimeout';
9
10
  import { GridSignature, useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
10
11
  import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
11
12
  import { gridSortedRowIdsSelector } from '../sorting/gridSortingSelector';
@@ -41,7 +42,7 @@ export var useGridRows = function useGridRows(apiRef, props) {
41
42
  var logger = useGridLogger(apiRef, 'useGridRows');
42
43
  var currentPage = useGridVisibleRows(apiRef, props);
43
44
  var lastUpdateMs = React.useRef(Date.now());
44
- var timeout = React.useRef(null);
45
+ var timeout = useTimeout();
45
46
  var getRow = React.useCallback(function (id) {
46
47
  var model = gridRowsLookupSelector(apiRef)[id];
47
48
  if (model) {
@@ -74,7 +75,6 @@ export var useGridRows = function useGridRows(apiRef, props) {
74
75
  var cache = _ref3.cache,
75
76
  throttle = _ref3.throttle;
76
77
  var run = function run() {
77
- timeout.current = null;
78
78
  lastUpdateMs.current = Date.now();
79
79
  apiRef.current.setState(function (state) {
80
80
  return _extends({}, state, {
@@ -90,10 +90,7 @@ export var useGridRows = function useGridRows(apiRef, props) {
90
90
  apiRef.current.publishEvent('rowsSet');
91
91
  apiRef.current.forceUpdate();
92
92
  };
93
- if (timeout.current) {
94
- clearTimeout(timeout.current);
95
- timeout.current = null;
96
- }
93
+ timeout.clear();
97
94
  apiRef.current.caches.rows = cache;
98
95
  if (!throttle) {
99
96
  run();
@@ -101,11 +98,11 @@ export var useGridRows = function useGridRows(apiRef, props) {
101
98
  }
102
99
  var throttleRemainingTimeMs = props.throttleRowsMs - (Date.now() - lastUpdateMs.current);
103
100
  if (throttleRemainingTimeMs > 0) {
104
- timeout.current = setTimeout(run, throttleRemainingTimeMs);
101
+ timeout.start(throttleRemainingTimeMs, run);
105
102
  return;
106
103
  }
107
104
  run();
108
- }, [props.throttleRowsMs, props.rowCount, props.loading, apiRef]);
105
+ }, [props.throttleRowsMs, props.rowCount, props.loading, apiRef, timeout]);
109
106
 
110
107
  /**
111
108
  * API METHODS
@@ -414,17 +411,6 @@ export var useGridRows = function useGridRows(apiRef, props) {
414
411
  useGridApiMethod(apiRef, rowApi, 'public');
415
412
  useGridApiMethod(apiRef, rowProApi, props.signature === GridSignature.DataGrid ? 'private' : 'public');
416
413
 
417
- /**
418
- * EFFECTS
419
- */
420
- React.useEffect(function () {
421
- return function () {
422
- if (timeout.current !== null) {
423
- clearTimeout(timeout.current);
424
- }
425
- };
426
- }, []);
427
-
428
414
  // The effect do not track any value defined synchronously during the 1st render by hooks called after `useGridRows`
429
415
  // As a consequence, the state generated by the 1st run of this useEffect will always be equal to the initialization one
430
416
  var isFirstRender = React.useRef(true);
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.12.0
2
+ * @mui/x-data-grid v6.12.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -46,6 +46,7 @@ export { useGridEvents } from '../hooks/features/events/useGridEvents';
46
46
  export { useGridDimensions } from '../hooks/features/dimensions/useGridDimensions';
47
47
  export { useGridStatePersistence } from '../hooks/features/statePersistence/useGridStatePersistence';
48
48
  export { useGridVirtualScroller, getRenderableIndexes } from '../hooks/features/virtualization/useGridVirtualScroller';
49
+ export { useTimeout } from '../hooks/utils/useTimeout';
49
50
  export { useGridVisibleRows, getVisibleRows } from '../hooks/utils/useGridVisibleRows';
50
51
  export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
51
52
  export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
@@ -255,7 +255,7 @@ export const createColumnsState = ({
255
255
 
256
256
  // If the column type has changed - merge the existing state with the default column type definition
257
257
  if (existingState && existingState.type !== newColumn.type) {
258
- existingState = _extends({}, existingState, getDefaultColTypeDef(columnTypes, newColumn.type), {
258
+ existingState = _extends({}, getDefaultColTypeDef(columnTypes, newColumn.type), {
259
259
  field
260
260
  });
261
261
  }
@@ -126,7 +126,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
126
126
  apiRef.current.setColumnGroupHeaderFocus(field, depth, event);
127
127
  }, [apiRef, logger]);
128
128
  const getRowIdFromIndex = React.useCallback(rowIndex => {
129
- return currentPageRows?.[rowIndex].id;
129
+ return currentPageRows[rowIndex]?.id;
130
130
  }, [currentPageRows]);
131
131
  const handleColumnHeaderKeyDown = React.useCallback((params, event) => {
132
132
  const headerTitleNode = event.currentTarget.querySelector(`.${gridClasses.columnHeaderTitleContainerContent}`);
@@ -142,7 +142,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
142
142
  }
143
143
  const viewportPageSize = apiRef.current.getViewportPageSize();
144
144
  const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
145
- const firstRowIndexInPage = 0;
145
+ const firstRowIndexInPage = currentPageRows.length > 0 ? 0 : null;
146
146
  const lastRowIndexInPage = currentPageRows.length - 1;
147
147
  const firstColIndex = 0;
148
148
  const lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
@@ -3,6 +3,7 @@ import * as React from 'react';
3
3
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
4
4
  import { useGridLogger } from '../../utils/useGridLogger';
5
5
  import { gridRowCountSelector, gridRowsLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthsSelector, gridDataRowIdsSelector, gridRowsDataRowIdToIdLookupSelector, gridRowMaximumTreeDepthSelector } from './gridRowsSelector';
6
+ import { useTimeout } from '../../utils/useTimeout';
6
7
  import { GridSignature, useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
7
8
  import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
8
9
  import { gridSortedRowIdsSelector } from '../sorting/gridSortingSelector';
@@ -38,7 +39,7 @@ export const useGridRows = (apiRef, props) => {
38
39
  const logger = useGridLogger(apiRef, 'useGridRows');
39
40
  const currentPage = useGridVisibleRows(apiRef, props);
40
41
  const lastUpdateMs = React.useRef(Date.now());
41
- const timeout = React.useRef(null);
42
+ const timeout = useTimeout();
42
43
  const getRow = React.useCallback(id => {
43
44
  const model = gridRowsLookupSelector(apiRef)[id];
44
45
  if (model) {
@@ -73,7 +74,6 @@ export const useGridRows = (apiRef, props) => {
73
74
  throttle
74
75
  }) => {
75
76
  const run = () => {
76
- timeout.current = null;
77
77
  lastUpdateMs.current = Date.now();
78
78
  apiRef.current.setState(state => _extends({}, state, {
79
79
  rows: getRowsStateFromCache({
@@ -87,10 +87,7 @@ export const useGridRows = (apiRef, props) => {
87
87
  apiRef.current.publishEvent('rowsSet');
88
88
  apiRef.current.forceUpdate();
89
89
  };
90
- if (timeout.current) {
91
- clearTimeout(timeout.current);
92
- timeout.current = null;
93
- }
90
+ timeout.clear();
94
91
  apiRef.current.caches.rows = cache;
95
92
  if (!throttle) {
96
93
  run();
@@ -98,11 +95,11 @@ export const useGridRows = (apiRef, props) => {
98
95
  }
99
96
  const throttleRemainingTimeMs = props.throttleRowsMs - (Date.now() - lastUpdateMs.current);
100
97
  if (throttleRemainingTimeMs > 0) {
101
- timeout.current = setTimeout(run, throttleRemainingTimeMs);
98
+ timeout.start(throttleRemainingTimeMs, run);
102
99
  return;
103
100
  }
104
101
  run();
105
- }, [props.throttleRowsMs, props.rowCount, props.loading, apiRef]);
102
+ }, [props.throttleRowsMs, props.rowCount, props.loading, apiRef, timeout]);
106
103
 
107
104
  /**
108
105
  * API METHODS
@@ -391,17 +388,6 @@ export const useGridRows = (apiRef, props) => {
391
388
  useGridApiMethod(apiRef, rowApi, 'public');
392
389
  useGridApiMethod(apiRef, rowProApi, props.signature === GridSignature.DataGrid ? 'private' : 'public');
393
390
 
394
- /**
395
- * EFFECTS
396
- */
397
- React.useEffect(() => {
398
- return () => {
399
- if (timeout.current !== null) {
400
- clearTimeout(timeout.current);
401
- }
402
- };
403
- }, []);
404
-
405
391
  // The effect do not track any value defined synchronously during the 1st render by hooks called after `useGridRows`
406
392
  // As a consequence, the state generated by the 1st run of this useEffect will always be equal to the initialization one
407
393
  const isFirstRender = React.useRef(true);
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.12.0
2
+ * @mui/x-data-grid v6.12.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -46,6 +46,7 @@ export { useGridEvents } from '../hooks/features/events/useGridEvents';
46
46
  export { useGridDimensions } from '../hooks/features/dimensions/useGridDimensions';
47
47
  export { useGridStatePersistence } from '../hooks/features/statePersistence/useGridStatePersistence';
48
48
  export { useGridVirtualScroller, getRenderableIndexes } from '../hooks/features/virtualization/useGridVirtualScroller';
49
+ export { useTimeout } from '../hooks/utils/useTimeout';
49
50
  export { useGridVisibleRows, getVisibleRows } from '../hooks/utils/useGridVisibleRows';
50
51
  export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
51
52
  export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
@@ -271,7 +271,7 @@ const createColumnsState = ({
271
271
 
272
272
  // If the column type has changed - merge the existing state with the default column type definition
273
273
  if (existingState && existingState.type !== newColumn.type) {
274
- existingState = (0, _extends2.default)({}, existingState, getDefaultColTypeDef(columnTypes, newColumn.type), {
274
+ existingState = (0, _extends2.default)({}, getDefaultColTypeDef(columnTypes, newColumn.type), {
275
275
  field
276
276
  });
277
277
  }
@@ -134,7 +134,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
134
134
  apiRef.current.setColumnGroupHeaderFocus(field, depth, event);
135
135
  }, [apiRef, logger]);
136
136
  const getRowIdFromIndex = React.useCallback(rowIndex => {
137
- return currentPageRows?.[rowIndex].id;
137
+ return currentPageRows[rowIndex]?.id;
138
138
  }, [currentPageRows]);
139
139
  const handleColumnHeaderKeyDown = React.useCallback((params, event) => {
140
140
  const headerTitleNode = event.currentTarget.querySelector(`.${_gridClasses.gridClasses.columnHeaderTitleContainerContent}`);
@@ -150,7 +150,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
150
150
  }
151
151
  const viewportPageSize = apiRef.current.getViewportPageSize();
152
152
  const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
153
- const firstRowIndexInPage = 0;
153
+ const firstRowIndexInPage = currentPageRows.length > 0 ? 0 : null;
154
154
  const lastRowIndexInPage = currentPageRows.length - 1;
155
155
  const firstColIndex = 0;
156
156
  const lastColIndex = (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef).length - 1;
@@ -10,6 +10,7 @@ var React = _interopRequireWildcard(require("react"));
10
10
  var _useGridApiMethod = require("../../utils/useGridApiMethod");
11
11
  var _useGridLogger = require("../../utils/useGridLogger");
12
12
  var _gridRowsSelector = require("./gridRowsSelector");
13
+ var _useTimeout = require("../../utils/useTimeout");
13
14
  var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
14
15
  var _useGridVisibleRows = require("../../utils/useGridVisibleRows");
15
16
  var _gridSortingSelector = require("../sorting/gridSortingSelector");
@@ -48,7 +49,7 @@ const useGridRows = (apiRef, props) => {
48
49
  const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridRows');
49
50
  const currentPage = (0, _useGridVisibleRows.useGridVisibleRows)(apiRef, props);
50
51
  const lastUpdateMs = React.useRef(Date.now());
51
- const timeout = React.useRef(null);
52
+ const timeout = (0, _useTimeout.useTimeout)();
52
53
  const getRow = React.useCallback(id => {
53
54
  const model = (0, _gridRowsSelector.gridRowsLookupSelector)(apiRef)[id];
54
55
  if (model) {
@@ -83,7 +84,6 @@ const useGridRows = (apiRef, props) => {
83
84
  throttle
84
85
  }) => {
85
86
  const run = () => {
86
- timeout.current = null;
87
87
  lastUpdateMs.current = Date.now();
88
88
  apiRef.current.setState(state => (0, _extends2.default)({}, state, {
89
89
  rows: (0, _gridRowsUtils.getRowsStateFromCache)({
@@ -97,10 +97,7 @@ const useGridRows = (apiRef, props) => {
97
97
  apiRef.current.publishEvent('rowsSet');
98
98
  apiRef.current.forceUpdate();
99
99
  };
100
- if (timeout.current) {
101
- clearTimeout(timeout.current);
102
- timeout.current = null;
103
- }
100
+ timeout.clear();
104
101
  apiRef.current.caches.rows = cache;
105
102
  if (!throttle) {
106
103
  run();
@@ -108,11 +105,11 @@ const useGridRows = (apiRef, props) => {
108
105
  }
109
106
  const throttleRemainingTimeMs = props.throttleRowsMs - (Date.now() - lastUpdateMs.current);
110
107
  if (throttleRemainingTimeMs > 0) {
111
- timeout.current = setTimeout(run, throttleRemainingTimeMs);
108
+ timeout.start(throttleRemainingTimeMs, run);
112
109
  return;
113
110
  }
114
111
  run();
115
- }, [props.throttleRowsMs, props.rowCount, props.loading, apiRef]);
112
+ }, [props.throttleRowsMs, props.rowCount, props.loading, apiRef, timeout]);
116
113
 
117
114
  /**
118
115
  * API METHODS
@@ -401,17 +398,6 @@ const useGridRows = (apiRef, props) => {
401
398
  (0, _useGridApiMethod.useGridApiMethod)(apiRef, rowApi, 'public');
402
399
  (0, _useGridApiMethod.useGridApiMethod)(apiRef, rowProApi, props.signature === _useGridApiEventHandler.GridSignature.DataGrid ? 'private' : 'public');
403
400
 
404
- /**
405
- * EFFECTS
406
- */
407
- React.useEffect(() => {
408
- return () => {
409
- if (timeout.current !== null) {
410
- clearTimeout(timeout.current);
411
- }
412
- };
413
- }, []);
414
-
415
401
  // The effect do not track any value defined synchronously during the 1st render by hooks called after `useGridRows`
416
402
  // As a consequence, the state generated by the 1st run of this useEffect will always be equal to the initialization one
417
403
  const isFirstRender = React.useRef(true);
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.12.0
2
+ * @mui/x-data-grid v6.12.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -72,6 +72,7 @@ var _exportNames = {
72
72
  useGridStatePersistence: true,
73
73
  useGridVirtualScroller: true,
74
74
  getRenderableIndexes: true,
75
+ useTimeout: true,
75
76
  useGridVisibleRows: true,
76
77
  getVisibleRows: true,
77
78
  useGridInitializeState: true,
@@ -621,6 +622,12 @@ Object.defineProperty(exports, "useGridVisibleRows", {
621
622
  return _useGridVisibleRows.useGridVisibleRows;
622
623
  }
623
624
  });
625
+ Object.defineProperty(exports, "useTimeout", {
626
+ enumerable: true,
627
+ get: function () {
628
+ return _useTimeout.useTimeout;
629
+ }
630
+ });
624
631
  var _GridVirtualScroller = require("../components/virtualization/GridVirtualScroller");
625
632
  var _GridVirtualScrollerContent = require("../components/virtualization/GridVirtualScrollerContent");
626
633
  var _GridVirtualScrollerRenderZone = require("../components/virtualization/GridVirtualScrollerRenderZone");
@@ -667,6 +674,7 @@ var _useGridEvents = require("../hooks/features/events/useGridEvents");
667
674
  var _useGridDimensions = require("../hooks/features/dimensions/useGridDimensions");
668
675
  var _useGridStatePersistence = require("../hooks/features/statePersistence/useGridStatePersistence");
669
676
  var _useGridVirtualScroller = require("../hooks/features/virtualization/useGridVirtualScroller");
677
+ var _useTimeout = require("../hooks/utils/useTimeout");
670
678
  var _useGridVisibleRows = require("../hooks/utils/useGridVisibleRows");
671
679
  var _useGridInitializeState = require("../hooks/utils/useGridInitializeState");
672
680
  var _utils = require("../hooks/features/export/utils");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "6.12.0",
3
+ "version": "6.12.1",
4
4
  "description": "The community edition of the data grid component (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@babel/runtime": "^7.22.11",
39
- "@mui/utils": "^5.14.5",
39
+ "@mui/utils": "^5.14.7",
40
40
  "clsx": "^2.0.0",
41
41
  "prop-types": "^15.8.1",
42
42
  "reselect": "^4.1.8"