@mui/x-data-grid 6.11.2 → 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.
Files changed (75) hide show
  1. package/CHANGELOG.md +158 -33
  2. package/README.md +1 -1
  3. package/components/cell/GridActionsCell.js +1 -1
  4. package/components/cell/GridEditSingleSelectCell.js +1 -1
  5. package/components/columnHeaders/GridColumnGroupHeader.js +1 -1
  6. package/components/columnHeaders/GridColumnHeaderItem.js +1 -1
  7. package/components/columnHeaders/GridGenericColumnHeaderItem.js +1 -1
  8. package/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  9. package/components/panel/filterPanel/GridFilterForm.js +1 -1
  10. package/components/toolbar/GridToolbarColumnsButton.js +1 -1
  11. package/components/toolbar/GridToolbarDensitySelector.js +1 -1
  12. package/components/toolbar/GridToolbarExport.js +2 -2
  13. package/components/toolbar/GridToolbarExportContainer.js +1 -1
  14. package/components/toolbar/GridToolbarFilterButton.js +1 -1
  15. package/hooks/features/columns/gridColumnsUtils.js +1 -1
  16. package/hooks/features/export/useGridPrintExport.js +11 -3
  17. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +3 -2
  18. package/hooks/features/pagination/useGridPagination.d.ts +5 -0
  19. package/hooks/features/pagination/useGridPagination.js +1 -1
  20. package/hooks/features/rowSelection/useGridRowSelection.js +1 -1
  21. package/hooks/features/rows/useGridRows.js +5 -19
  22. package/hooks/features/rows/useGridRowsMeta.js +2 -2
  23. package/hooks/utils/useGridApiEventHandler.js +5 -5
  24. package/hooks/utils/useLazyRef.js +2 -0
  25. package/index.js +1 -1
  26. package/internals/index.d.ts +1 -0
  27. package/internals/index.js +1 -0
  28. package/joy/joySlots.js +2 -2
  29. package/legacy/components/cell/GridActionsCell.js +1 -1
  30. package/legacy/components/cell/GridEditSingleSelectCell.js +1 -1
  31. package/legacy/components/columnHeaders/GridColumnGroupHeader.js +1 -1
  32. package/legacy/components/columnHeaders/GridColumnHeaderItem.js +1 -1
  33. package/legacy/components/columnHeaders/GridGenericColumnHeaderItem.js +1 -1
  34. package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  35. package/legacy/components/panel/filterPanel/GridFilterForm.js +1 -1
  36. package/legacy/components/toolbar/GridToolbarColumnsButton.js +1 -1
  37. package/legacy/components/toolbar/GridToolbarDensitySelector.js +1 -1
  38. package/legacy/components/toolbar/GridToolbarExport.js +2 -2
  39. package/legacy/components/toolbar/GridToolbarExportContainer.js +1 -1
  40. package/legacy/components/toolbar/GridToolbarFilterButton.js +1 -1
  41. package/legacy/hooks/features/columns/gridColumnsUtils.js +1 -1
  42. package/legacy/hooks/features/export/useGridPrintExport.js +12 -4
  43. package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +3 -2
  44. package/legacy/hooks/features/pagination/useGridPagination.js +1 -1
  45. package/legacy/hooks/features/rowSelection/useGridRowSelection.js +1 -1
  46. package/legacy/hooks/features/rows/useGridRows.js +5 -19
  47. package/legacy/hooks/features/rows/useGridRowsMeta.js +2 -2
  48. package/legacy/hooks/utils/useGridApiEventHandler.js +5 -5
  49. package/legacy/hooks/utils/useLazyRef.js +2 -0
  50. package/legacy/index.js +1 -1
  51. package/legacy/internals/index.js +1 -0
  52. package/legacy/joy/joySlots.js +2 -2
  53. package/legacy/locales/ukUA.js +25 -27
  54. package/legacy/utils/createSelector.js +1 -1
  55. package/locales/ukUA.js +25 -27
  56. package/modern/hooks/features/columns/gridColumnsUtils.js +1 -1
  57. package/modern/hooks/features/export/useGridPrintExport.js +9 -1
  58. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -2
  59. package/modern/hooks/features/pagination/useGridPagination.js +1 -1
  60. package/modern/hooks/features/rows/useGridRows.js +5 -19
  61. package/modern/hooks/utils/useLazyRef.js +2 -0
  62. package/modern/index.js +1 -1
  63. package/modern/internals/index.js +1 -0
  64. package/modern/locales/ukUA.js +25 -27
  65. package/node/hooks/features/columns/gridColumnsUtils.js +1 -1
  66. package/node/hooks/features/export/useGridPrintExport.js +9 -1
  67. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -2
  68. package/node/hooks/features/pagination/useGridPagination.js +2 -1
  69. package/node/hooks/features/rows/useGridRows.js +5 -19
  70. package/node/hooks/utils/useLazyRef.js +2 -0
  71. package/node/index.js +1 -1
  72. package/node/internals/index.js +8 -0
  73. package/node/locales/ukUA.js +25 -27
  74. package/package.json +3 -3
  75. package/utils/createSelector.js +1 -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);
@@ -145,10 +145,10 @@ export const useGridRowsMeta = (apiRef, props) => {
145
145
  }
146
146
  return acc + maximumBaseSize + otherSizes;
147
147
  }, 0);
148
- pinnedRows == null || (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.forEach(row => {
148
+ pinnedRows == null || (_pinnedRows$top = pinnedRows.top) == null || _pinnedRows$top.forEach(row => {
149
149
  calculateRowProcessedSizes(row);
150
150
  });
151
- pinnedRows == null || (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.forEach(row => {
151
+ pinnedRows == null || (_pinnedRows$bottom = pinnedRows.bottom) == null || _pinnedRows$bottom.forEach(row => {
152
152
  calculateRowProcessedSizes(row);
153
153
  });
154
154
  apiRef.current.setState(state => {
@@ -30,7 +30,7 @@ export function createUseGridApiEventHandler(registryContainer) {
30
30
  const enhancedHandler = (params, event, details) => {
31
31
  if (!event.defaultMuiPrevented) {
32
32
  var _handlerRef$current;
33
- (_handlerRef$current = handlerRef.current) == null ? void 0 : _handlerRef$current.call(handlerRef, params, event, details);
33
+ (_handlerRef$current = handlerRef.current) == null || _handlerRef$current.call(handlerRef, params, event, details);
34
34
  }
35
35
  };
36
36
  subscription.current = apiRef.current.subscribeEvent(eventName, enhancedHandler, options);
@@ -42,7 +42,7 @@ export function createUseGridApiEventHandler(registryContainer) {
42
42
  // The callback below will be called once this reference stops being retained
43
43
  () => {
44
44
  var _subscription$current;
45
- (_subscription$current = subscription.current) == null ? void 0 : _subscription$current.call(subscription);
45
+ (_subscription$current = subscription.current) == null || _subscription$current.call(subscription);
46
46
  subscription.current = null;
47
47
  cleanupTokenRef.current = null;
48
48
  }, cleanupTokenRef.current);
@@ -59,7 +59,7 @@ export function createUseGridApiEventHandler(registryContainer) {
59
59
  const enhancedHandler = (params, event, details) => {
60
60
  if (!event.defaultMuiPrevented) {
61
61
  var _handlerRef$current2;
62
- (_handlerRef$current2 = handlerRef.current) == null ? void 0 : _handlerRef$current2.call(handlerRef, params, event, details);
62
+ (_handlerRef$current2 = handlerRef.current) == null || _handlerRef$current2.call(handlerRef, params, event, details);
63
63
  }
64
64
  };
65
65
  subscription.current = apiRef.current.subscribeEvent(eventName, enhancedHandler, options);
@@ -72,7 +72,7 @@ export function createUseGridApiEventHandler(registryContainer) {
72
72
  }
73
73
  return () => {
74
74
  var _subscription$current2;
75
- (_subscription$current2 = subscription.current) == null ? void 0 : _subscription$current2.call(subscription);
75
+ (_subscription$current2 = subscription.current) == null || _subscription$current2.call(subscription);
76
76
  subscription.current = null;
77
77
  };
78
78
  }, [apiRef, eventName, options]);
@@ -86,7 +86,7 @@ const registryContainer = {
86
86
  // eslint-disable-next-line @typescript-eslint/naming-convention
87
87
  export const unstable_resetCleanupTracking = () => {
88
88
  var _registryContainer$re;
89
- (_registryContainer$re = registryContainer.registry) == null ? void 0 : _registryContainer$re.reset();
89
+ (_registryContainer$re = registryContainer.registry) == null || _registryContainer$re.reset();
90
90
  registryContainer.registry = null;
91
91
  };
92
92
  export const useGridApiEventHandler = createUseGridApiEventHandler(registryContainer);
@@ -1,5 +1,7 @@
1
1
  import * as React from 'react';
2
2
  const UNINITIALIZED = {};
3
+
4
+ // See https://github.com/facebook/react/issues/14490 for when to use this.
3
5
  export function useLazyRef(init, initArg) {
4
6
  const ref = React.useRef(UNINITIALIZED);
5
7
  if (ref.current === UNINITIALIZED) {
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.11.2
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';
package/joy/joySlots.js CHANGED
@@ -231,10 +231,10 @@ const Select = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
231
231
  listboxOpen: open,
232
232
  onListboxOpenChange: isOpen => {
233
233
  if (isOpen) {
234
- onOpen == null ? void 0 : onOpen({});
234
+ onOpen == null || onOpen({});
235
235
  } else {
236
236
  var _MenuProps$onClose;
237
- MenuProps == null || (_MenuProps$onClose = MenuProps.onClose) == null ? void 0 : _MenuProps$onClose.call(MenuProps, {}, undefined);
237
+ MenuProps == null || (_MenuProps$onClose = MenuProps.onClose) == null || _MenuProps$onClose.call(MenuProps, {}, undefined);
238
238
  }
239
239
  },
240
240
  size: convertSize(size),
@@ -68,7 +68,7 @@ function GridActionsCell(props) {
68
68
  var _ref2 = _slicedToArray(_ref, 2),
69
69
  index = _ref2[0],
70
70
  ref = _ref2[1];
71
- ref == null ? void 0 : ref.stop({}, function () {
71
+ ref == null || ref.stop({}, function () {
72
72
  delete touchRippleRefs.current[index];
73
73
  });
74
74
  });
@@ -59,7 +59,7 @@ function GridEditSingleSelectCell(props) {
59
59
  useEnhancedEffect(function () {
60
60
  if (hasFocus) {
61
61
  var _inputRef$current;
62
- (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
62
+ (_inputRef$current = inputRef.current) == null || _inputRef$current.focus();
63
63
  }
64
64
  }, [hasFocus]);
65
65
  if (!isSingleSelectColDef(colDef)) {
@@ -78,7 +78,7 @@ function GridColumnGroupHeader(props) {
78
78
  if (hasFocus) {
79
79
  var focusableElement = headerCellRef.current.querySelector('[tabindex="0"]');
80
80
  var elementToFocus = focusableElement || headerCellRef.current;
81
- elementToFocus == null ? void 0 : elementToFocus.focus();
81
+ elementToFocus == null || elementToFocus.focus();
82
82
  }
83
83
  }, [apiRef, hasFocus]);
84
84
  var publish = React.useCallback(function (eventName) {
@@ -148,7 +148,7 @@ function GridColumnHeaderItem(props) {
148
148
  if (hasFocus && !columnMenuState.open) {
149
149
  var focusableElement = headerCellRef.current.querySelector('[tabindex="0"]');
150
150
  var elementToFocus = focusableElement || headerCellRef.current;
151
- elementToFocus == null ? void 0 : elementToFocus.focus();
151
+ elementToFocus == null || elementToFocus.focus();
152
152
  apiRef.current.columnHeadersContainerElementRef.current.scrollLeft = 0;
153
153
  }
154
154
  }, [apiRef, hasFocus]);
@@ -60,7 +60,7 @@ var GridGenericColumnHeaderItem = /*#__PURE__*/React.forwardRef(function GridGen
60
60
  if (hasFocus && !columnMenuState.open) {
61
61
  var focusableElement = headerCellRef.current.querySelector('[tabindex="0"]');
62
62
  var elementToFocus = focusableElement || headerCellRef.current;
63
- elementToFocus == null ? void 0 : elementToFocus.focus();
63
+ elementToFocus == null || elementToFocus.focus();
64
64
  apiRef.current.columnHeadersContainerElementRef.current.scrollLeft = 0;
65
65
  }
66
66
  }, [apiRef, hasFocus]);
@@ -57,7 +57,7 @@ var GridCellCheckboxForwardRef = /*#__PURE__*/React.forwardRef(function GridCell
57
57
  if (hasFocus) {
58
58
  var _checkboxElement$curr;
59
59
  var input = (_checkboxElement$curr = checkboxElement.current) == null ? void 0 : _checkboxElement$curr.querySelector('input');
60
- input == null ? void 0 : input.focus({
60
+ input == null || input.focus({
61
61
  preventScroll: true
62
62
  });
63
63
  } else if (rippleRef.current) {
@@ -247,7 +247,7 @@ var GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(props
247
247
  focus: function focus() {
248
248
  if (currentOperator != null && currentOperator.InputComponent) {
249
249
  var _valueRef$current;
250
- valueRef == null || (_valueRef$current = valueRef.current) == null ? void 0 : _valueRef$current.focus();
250
+ valueRef == null || (_valueRef$current = valueRef.current) == null || _valueRef$current.focus();
251
251
  } else {
252
252
  filterSelectorRef.current.focus();
253
253
  }
@@ -24,7 +24,7 @@ export var GridToolbarColumnsButton = /*#__PURE__*/React.forwardRef(function Gri
24
24
  } else {
25
25
  apiRef.current.showPreferences(GridPreferencePanelsValue.columns, columnPanelId, columnButtonId);
26
26
  }
27
- onClick == null ? void 0 : onClick(event);
27
+ onClick == null || onClick(event);
28
28
  };
29
29
 
30
30
  // Disable the button if the corresponding is disabled
@@ -58,7 +58,7 @@ export var GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function G
58
58
  setOpen(function (prevOpen) {
59
59
  return !prevOpen;
60
60
  });
61
- onClick == null ? void 0 : onClick(event);
61
+ onClick == null || onClick(event);
62
62
  };
63
63
  var handleDensitySelectorClickAway = function handleDensitySelectorClickAway(event) {
64
64
  var _buttonRef$current;
@@ -17,7 +17,7 @@ export function GridCsvExportMenuItem(props) {
17
17
  return /*#__PURE__*/_jsx(MenuItem, _extends({
18
18
  onClick: function onClick() {
19
19
  apiRef.current.exportDataAsCsv(options);
20
- hideMenu == null ? void 0 : hideMenu();
20
+ hideMenu == null || hideMenu();
21
21
  }
22
22
  }, other, {
23
23
  children: apiRef.current.getLocaleText('toolbarExportCSV')
@@ -31,7 +31,7 @@ export function GridPrintExportMenuItem(props) {
31
31
  return /*#__PURE__*/_jsx(MenuItem, _extends({
32
32
  onClick: function onClick() {
33
33
  apiRef.current.exportDataAsPrint(options);
34
- hideMenu == null ? void 0 : hideMenu();
34
+ hideMenu == null || hideMenu();
35
35
  }
36
36
  }, other, {
37
37
  children: apiRef.current.getLocaleText('toolbarExportPrint')
@@ -31,7 +31,7 @@ export var GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function G
31
31
  setOpen(function (prevOpen) {
32
32
  return !prevOpen;
33
33
  });
34
- onClick == null ? void 0 : onClick(event);
34
+ onClick == null || onClick(event);
35
35
  };
36
36
  var handleMenuClose = function handleMenuClose() {
37
37
  return setOpen(false);
@@ -92,7 +92,7 @@ var GridToolbarFilterButton = /*#__PURE__*/React.forwardRef(function GridToolbar
92
92
  } else {
93
93
  apiRef.current.showPreferences(GridPreferencePanelsValue.filters, filterPanelId, filterButtonId);
94
94
  }
95
- (_buttonProps$onClick = buttonProps.onClick) == null ? void 0 : _buttonProps$onClick.call(buttonProps, event);
95
+ (_buttonProps$onClick = buttonProps.onClick) == null || _buttonProps$onClick.call(buttonProps, event);
96
96
  };
97
97
 
98
98
  // Disable the button if the corresponding is disabled
@@ -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
  }
@@ -11,6 +11,7 @@ import { gridClasses } from '../../../constants/gridClasses';
11
11
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
12
12
  import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
13
13
  import { getColumnsToExport } from './utils';
14
+ import { mergeStateWithPaginationModel } from '../pagination/useGridPagination';
14
15
  import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
15
16
  import { GridPrintExportMenuItem } from '../../../components/toolbar/GridToolbarExport';
16
17
  import { getTotalHeaderHeight } from '../columns/gridColumnsUtils';
@@ -96,12 +97,12 @@ export var useGridPrintExport = function useGridPrintExport(apiRef, props) {
96
97
  var gridFooterElementHeight = ((_querySelector2 = gridRootElement.querySelector(".".concat(gridClasses.footerContainer))) == null ? void 0 : _querySelector2.offsetHeight) || 0;
97
98
  if (normalizeOptions.hideToolbar) {
98
99
  var _gridClone$querySelec;
99
- (_gridClone$querySelec = gridClone.querySelector(".".concat(gridClasses.toolbarContainer))) == null ? void 0 : _gridClone$querySelec.remove();
100
+ (_gridClone$querySelec = gridClone.querySelector(".".concat(gridClasses.toolbarContainer))) == null || _gridClone$querySelec.remove();
100
101
  gridToolbarElementHeight = 0;
101
102
  }
102
103
  if (normalizeOptions.hideFooter) {
103
104
  var _gridClone$querySelec2;
104
- (_gridClone$querySelec2 = gridClone.querySelector(".".concat(gridClasses.footerContainer))) == null ? void 0 : _gridClone$querySelec2.remove();
105
+ (_gridClone$querySelec2 = gridClone.querySelector(".".concat(gridClasses.footerContainer))) == null || _gridClone$querySelec2.remove();
105
106
  gridFooterElementHeight = 0;
106
107
  }
107
108
 
@@ -197,7 +198,7 @@ export var useGridPrintExport = function useGridPrintExport(apiRef, props) {
197
198
  }, [apiRef]);
198
199
  var exportDataAsPrint = React.useCallback( /*#__PURE__*/function () {
199
200
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
200
- var visibleRowCount, printWindow;
201
+ var visibleRowCount, paginationModel, printWindow;
201
202
  return _regeneratorRuntime.wrap(function _callee$(_context) {
202
203
  while (1) switch (_context.prev = _context.next) {
203
204
  case 0:
@@ -213,7 +214,14 @@ export var useGridPrintExport = function useGridPrintExport(apiRef, props) {
213
214
  previousColumnVisibility.current = gridColumnVisibilityModelSelector(apiRef);
214
215
  if (props.pagination) {
215
216
  visibleRowCount = gridExpandedRowCountSelector(apiRef);
216
- apiRef.current.setPageSize(visibleRowCount);
217
+ paginationModel = {
218
+ page: 0,
219
+ pageSize: visibleRowCount
220
+ };
221
+ apiRef.current.updateControlState('pagination',
222
+ // Using signature `DataGridPro` to allow more than 100 rows in the print export
223
+ mergeStateWithPaginationModel(visibleRowCount, 'DataGridPro', paginationModel));
224
+ apiRef.current.forceUpdate();
217
225
  }
218
226
  _context.next = 8;
219
227
  return updateGridColumnsForPrint(options == null ? void 0 : options.fields, options == null ? void 0 : options.allColumns);
@@ -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;
@@ -17,7 +17,7 @@ export var paginationStateInitializer = function paginationStateInitializer(stat
17
17
  }
18
18
  });
19
19
  };
20
- var mergeStateWithPaginationModel = function mergeStateWithPaginationModel(rowCount, signature, paginationModelProp) {
20
+ export var mergeStateWithPaginationModel = function mergeStateWithPaginationModel(rowCount, signature, paginationModelProp) {
21
21
  return function (paginationState) {
22
22
  var _paginationModelProp$;
23
23
  var paginationModel = paginationState.paginationModel;
@@ -289,7 +289,7 @@ export var useGridRowSelection = function useGridRowSelection(apiRef, props) {
289
289
  var preventSelectionOnShift = React.useCallback(function (params, event) {
290
290
  if (canHaveMultipleSelection && event.shiftKey) {
291
291
  var _window$getSelection;
292
- (_window$getSelection = window.getSelection()) == null ? void 0 : _window$getSelection.removeAllRanges();
292
+ (_window$getSelection = window.getSelection()) == null || _window$getSelection.removeAllRanges();
293
293
  }
294
294
  }, [canHaveMultipleSelection]);
295
295
  var handleRowSelectionCheckboxChange = React.useCallback(function (params, event) {
@@ -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);
@@ -144,10 +144,10 @@ export var useGridRowsMeta = function useGridRowsMeta(apiRef, props) {
144
144
  }
145
145
  return acc + maximumBaseSize + otherSizes;
146
146
  }, 0);
147
- pinnedRows == null || (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.forEach(function (row) {
147
+ pinnedRows == null || (_pinnedRows$top = pinnedRows.top) == null || _pinnedRows$top.forEach(function (row) {
148
148
  calculateRowProcessedSizes(row);
149
149
  });
150
- pinnedRows == null || (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.forEach(function (row) {
150
+ pinnedRows == null || (_pinnedRows$bottom = pinnedRows.bottom) == null || _pinnedRows$bottom.forEach(function (row) {
151
151
  calculateRowProcessedSizes(row);
152
152
  });
153
153
  apiRef.current.setState(function (state) {
@@ -35,7 +35,7 @@ export function createUseGridApiEventHandler(registryContainer) {
35
35
  var enhancedHandler = function enhancedHandler(params, event, details) {
36
36
  if (!event.defaultMuiPrevented) {
37
37
  var _handlerRef$current;
38
- (_handlerRef$current = handlerRef.current) == null ? void 0 : _handlerRef$current.call(handlerRef, params, event, details);
38
+ (_handlerRef$current = handlerRef.current) == null || _handlerRef$current.call(handlerRef, params, event, details);
39
39
  }
40
40
  };
41
41
  subscription.current = apiRef.current.subscribeEvent(eventName, enhancedHandler, options);
@@ -47,7 +47,7 @@ export function createUseGridApiEventHandler(registryContainer) {
47
47
  // The callback below will be called once this reference stops being retained
48
48
  function () {
49
49
  var _subscription$current;
50
- (_subscription$current = subscription.current) == null ? void 0 : _subscription$current.call(subscription);
50
+ (_subscription$current = subscription.current) == null || _subscription$current.call(subscription);
51
51
  subscription.current = null;
52
52
  cleanupTokenRef.current = null;
53
53
  }, cleanupTokenRef.current);
@@ -64,7 +64,7 @@ export function createUseGridApiEventHandler(registryContainer) {
64
64
  var _enhancedHandler = function _enhancedHandler(params, event, details) {
65
65
  if (!event.defaultMuiPrevented) {
66
66
  var _handlerRef$current2;
67
- (_handlerRef$current2 = handlerRef.current) == null ? void 0 : _handlerRef$current2.call(handlerRef, params, event, details);
67
+ (_handlerRef$current2 = handlerRef.current) == null || _handlerRef$current2.call(handlerRef, params, event, details);
68
68
  }
69
69
  };
70
70
  subscription.current = apiRef.current.subscribeEvent(eventName, _enhancedHandler, options);
@@ -77,7 +77,7 @@ export function createUseGridApiEventHandler(registryContainer) {
77
77
  }
78
78
  return function () {
79
79
  var _subscription$current2;
80
- (_subscription$current2 = subscription.current) == null ? void 0 : _subscription$current2.call(subscription);
80
+ (_subscription$current2 = subscription.current) == null || _subscription$current2.call(subscription);
81
81
  subscription.current = null;
82
82
  };
83
83
  }, [apiRef, eventName, options]);
@@ -91,7 +91,7 @@ var registryContainer = {
91
91
  // eslint-disable-next-line @typescript-eslint/naming-convention
92
92
  export var unstable_resetCleanupTracking = function unstable_resetCleanupTracking() {
93
93
  var _registryContainer$re;
94
- (_registryContainer$re = registryContainer.registry) == null ? void 0 : _registryContainer$re.reset();
94
+ (_registryContainer$re = registryContainer.registry) == null || _registryContainer$re.reset();
95
95
  registryContainer.registry = null;
96
96
  };
97
97
  export var useGridApiEventHandler = createUseGridApiEventHandler(registryContainer);
@@ -1,5 +1,7 @@
1
1
  import * as React from 'react';
2
2
  var UNINITIALIZED = {};
3
+
4
+ // See https://github.com/facebook/react/issues/14490 for when to use this.
3
5
  export function useLazyRef(init, initArg) {
4
6
  var ref = React.useRef(UNINITIALIZED);
5
7
  if (ref.current === UNINITIALIZED) {
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.11.2
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';
@@ -234,10 +234,10 @@ var Select = /*#__PURE__*/React.forwardRef(function (_ref7, ref) {
234
234
  listboxOpen: open,
235
235
  onListboxOpenChange: function onListboxOpenChange(isOpen) {
236
236
  if (isOpen) {
237
- onOpen == null ? void 0 : onOpen({});
237
+ onOpen == null || onOpen({});
238
238
  } else {
239
239
  var _MenuProps$onClose;
240
- MenuProps == null || (_MenuProps$onClose = MenuProps.onClose) == null ? void 0 : _MenuProps$onClose.call(MenuProps, {}, undefined);
240
+ MenuProps == null || (_MenuProps$onClose = MenuProps.onClose) == null || _MenuProps$onClose.call(MenuProps, {}, undefined);
241
241
  }
242
242
  },
243
243
  size: convertSize(size),