@mui/x-data-grid 8.8.0 → 8.9.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 (84) hide show
  1. package/CHANGELOG.md +131 -24
  2. package/DataGrid/index.d.ts +0 -1
  3. package/DataGrid/useDataGridComponent.js +8 -0
  4. package/components/GridScrollArea.js +1 -1
  5. package/components/containers/GridRootStyles.js +39 -0
  6. package/constants/gridClasses.d.ts +12 -0
  7. package/constants/gridClasses.js +3 -1
  8. package/esm/DataGrid/index.d.ts +0 -1
  9. package/esm/DataGrid/useDataGridComponent.js +8 -0
  10. package/esm/components/GridScrollArea.js +1 -1
  11. package/esm/components/containers/GridRootStyles.js +39 -0
  12. package/esm/constants/gridClasses.d.ts +12 -0
  13. package/esm/constants/gridClasses.js +3 -1
  14. package/esm/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +5 -0
  15. package/esm/hooks/core/pipeProcessing/useGridPipeProcessing.js +20 -5
  16. package/esm/hooks/core/useGridProps.d.ts +2 -2
  17. package/esm/hooks/core/useGridProps.js +3 -1
  18. package/esm/hooks/features/columnGrouping/gridColumnGroupsInterfaces.d.ts +4 -1
  19. package/esm/hooks/features/columnGrouping/gridColumnGroupsUtils.js +35 -32
  20. package/esm/hooks/features/columnGrouping/useGridColumnGrouping.js +18 -13
  21. package/esm/hooks/features/columns/gridColumnsInterfaces.d.ts +3 -3
  22. package/esm/hooks/features/columns/gridColumnsSelector.js +6 -2
  23. package/esm/hooks/features/columns/gridColumnsUtils.js +6 -4
  24. package/esm/hooks/features/columns/useGridColumns.js +8 -10
  25. package/esm/hooks/features/export/utils.js +1 -1
  26. package/esm/hooks/features/filter/useGridFilter.js +3 -3
  27. package/esm/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
  28. package/esm/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +5 -9
  29. package/esm/hooks/features/listView/gridListViewSelectors.d.ts +8 -1
  30. package/esm/hooks/features/listView/gridListViewSelectors.js +7 -0
  31. package/esm/hooks/features/rowSelection/useGridRowSelection.js +5 -4
  32. package/esm/hooks/features/rows/gridRowsUtils.d.ts +1 -1
  33. package/esm/hooks/features/rows/gridRowsUtils.js +5 -2
  34. package/esm/hooks/features/rows/useGridRows.js +4 -3
  35. package/esm/hooks/features/scroll/useGridScroll.d.ts +1 -1
  36. package/esm/hooks/features/scroll/useGridScroll.js +2 -3
  37. package/esm/hooks/features/virtualization/useGridVirtualScroller.js +3 -6
  38. package/esm/hooks/utils/index.d.ts +1 -0
  39. package/esm/hooks/utils/index.js +2 -1
  40. package/esm/hooks/utils/useGridInitializeState.d.ts +1 -1
  41. package/esm/hooks/utils/useGridInitializeState.js +6 -1
  42. package/esm/hooks/utils/useRunOncePerLoop.d.ts +1 -0
  43. package/esm/hooks/utils/useRunOncePerLoop.js +26 -0
  44. package/esm/index.js +1 -1
  45. package/esm/models/api/gridRowApi.d.ts +5 -0
  46. package/esm/models/events/gridEventLookup.d.ts +2 -1
  47. package/esm/models/gridApiCaches.d.ts +8 -2
  48. package/esm/models/gridStateCommunity.d.ts +2 -2
  49. package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +5 -0
  50. package/hooks/core/pipeProcessing/useGridPipeProcessing.js +20 -5
  51. package/hooks/core/useGridProps.d.ts +2 -2
  52. package/hooks/core/useGridProps.js +3 -1
  53. package/hooks/features/columnGrouping/gridColumnGroupsInterfaces.d.ts +4 -1
  54. package/hooks/features/columnGrouping/gridColumnGroupsUtils.js +35 -32
  55. package/hooks/features/columnGrouping/useGridColumnGrouping.js +18 -13
  56. package/hooks/features/columns/gridColumnsInterfaces.d.ts +3 -3
  57. package/hooks/features/columns/gridColumnsSelector.js +6 -2
  58. package/hooks/features/columns/gridColumnsUtils.js +6 -4
  59. package/hooks/features/columns/useGridColumns.js +8 -10
  60. package/hooks/features/export/utils.js +1 -1
  61. package/hooks/features/filter/useGridFilter.js +3 -3
  62. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
  63. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +5 -9
  64. package/hooks/features/listView/gridListViewSelectors.d.ts +8 -1
  65. package/hooks/features/listView/gridListViewSelectors.js +8 -1
  66. package/hooks/features/rowSelection/useGridRowSelection.js +5 -4
  67. package/hooks/features/rows/gridRowsUtils.d.ts +1 -1
  68. package/hooks/features/rows/gridRowsUtils.js +5 -2
  69. package/hooks/features/rows/useGridRows.js +4 -3
  70. package/hooks/features/scroll/useGridScroll.d.ts +1 -1
  71. package/hooks/features/scroll/useGridScroll.js +2 -3
  72. package/hooks/features/virtualization/useGridVirtualScroller.js +3 -6
  73. package/hooks/utils/index.d.ts +1 -0
  74. package/hooks/utils/index.js +12 -0
  75. package/hooks/utils/useGridInitializeState.d.ts +1 -1
  76. package/hooks/utils/useGridInitializeState.js +6 -1
  77. package/hooks/utils/useRunOncePerLoop.d.ts +1 -0
  78. package/hooks/utils/useRunOncePerLoop.js +33 -0
  79. package/index.js +1 -1
  80. package/models/api/gridRowApi.d.ts +5 -0
  81. package/models/events/gridEventLookup.d.ts +2 -1
  82. package/models/gridApiCaches.d.ts +8 -2
  83. package/models/gridStateCommunity.d.ts +2 -2
  84. package/package.json +1 -1
@@ -23,7 +23,6 @@ var _gridHeaderFilteringSelectors = require("../headerFiltering/gridHeaderFilter
23
23
  var _pipeProcessing = require("../../core/pipeProcessing");
24
24
  var _domUtils = require("../../../utils/domUtils");
25
25
  var _utils = require("./utils");
26
- var _gridListViewSelectors = require("../listView/gridListViewSelectors");
27
26
  var _createSelector = require("../../../utils/createSelector");
28
27
  var _pagination = require("../pagination");
29
28
  var _gridRowsSelector = require("../rows/gridRowsSelector");
@@ -43,7 +42,6 @@ const gridVisibleRowsWithPinnedRowsSelector = (0, _createSelector.createSelector
43
42
  const useGridKeyboardNavigation = (apiRef, props) => {
44
43
  const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridKeyboardNavigation');
45
44
  const isRtl = (0, _RtlProvider.useRtl)();
46
- const listView = props.listView;
47
45
  const getCurrentPageRows = React.useCallback(() => {
48
46
  return gridVisibleRowsWithPinnedRowsSelector(apiRef);
49
47
  }, [apiRef]);
@@ -66,7 +64,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
66
64
  colIndex = nextCellColSpanInfo.rightVisibleCellIndex;
67
65
  }
68
66
  }
69
- const field = listView ? (0, _gridListViewSelectors.gridListColumnSelector)(apiRef).field : (0, _gridColumnsSelector.gridVisibleColumnFieldsSelector)(apiRef)[colIndex];
67
+ const field = (0, _gridColumnsSelector.gridVisibleColumnFieldsSelector)(apiRef)[colIndex];
70
68
  const nonRowSpannedRowId = (0, _utils.findNonRowSpannedCell)(apiRef, rowId, field, rowSpanScanDirection);
71
69
  // `scrollToIndexes` requires a rowIndex relative to all visible rows.
72
70
  // Those rows do not include pinned rows, but pinned rows do not need scroll anyway.
@@ -77,7 +75,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
77
75
  rowIndex: rowIndexRelativeToAllRows
78
76
  });
79
77
  apiRef.current.setCellFocus(nonRowSpannedRowId, field);
80
- }, [apiRef, logger, listView]);
78
+ }, [apiRef, logger]);
81
79
  const goToHeader = React.useCallback((colIndex, event) => {
82
80
  logger.debug(`Navigating to header col ${colIndex}`);
83
81
  apiRef.current.scrollToIndexes({
@@ -402,14 +400,12 @@ const useGridKeyboardNavigation = (apiRef, props) => {
402
400
  return;
403
401
  }
404
402
  const viewportPageSize = apiRef.current.getViewportPageSize();
405
- const getColumnIndexFn = listView ? () => 0 : apiRef.current.getColumnIndex;
406
- const colIndexBefore = params.field ? getColumnIndexFn(params.field) : 0;
403
+ const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
407
404
  const rowIndexBefore = currentPageRows.findIndex(row => row.id === params.id);
408
405
  const firstRowIndexInPage = 0;
409
406
  const lastRowIndexInPage = currentPageRows.length - 1;
410
407
  const firstColIndex = 0;
411
- const visibleColumns = listView ? [(0, _gridListViewSelectors.gridListColumnSelector)(apiRef)] : (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef);
412
- const lastColIndex = visibleColumns.length - 1;
408
+ const lastColIndex = (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef).length - 1;
413
409
  let shouldPreventDefault = true;
414
410
  switch (event.key) {
415
411
  case 'ArrowDown':
@@ -526,7 +522,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
526
522
  if (shouldPreventDefault) {
527
523
  event.preventDefault();
528
524
  }
529
- }, [apiRef, getCurrentPageRows, isRtl, goToCell, getRowIdFromIndex, headerFilteringEnabled, goToHeaderFilter, goToHeader, listView]);
525
+ }, [apiRef, getCurrentPageRows, isRtl, goToCell, getRowIdFromIndex, headerFilteringEnabled, goToHeaderFilter, goToHeader]);
530
526
  const checkIfCanStartEditing = React.useCallback((initialValue, {
531
527
  event
532
528
  }) => {
@@ -1,7 +1,14 @@
1
1
  import { GridStateCommunity } from "../../../models/gridStateCommunity.js";
2
+ import type { GridStateColDef } from "../../../models/colDef/gridColDef.js";
3
+ /**
4
+ * Get the list view state
5
+ * @category List View
6
+ * @ignore - Do not document
7
+ */
8
+ export declare const gridListViewSelector: import("@mui/x-data-grid").OutputSelector<GridStateCommunity, unknown, boolean>;
2
9
  /**
3
10
  * Get the list column definition
4
11
  * @category List View
5
12
  * @ignore - Do not document
6
13
  */
7
- export declare const gridListColumnSelector: import("@mui/x-data-grid").OutputSelector<GridStateCommunity, unknown, import("./useGridListView.js").GridListViewState>;
14
+ export declare const gridListColumnSelector: import("@mui/x-data-grid").OutputSelector<GridStateCommunity, unknown, GridStateColDef>;
@@ -3,8 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.gridListColumnSelector = void 0;
6
+ exports.gridListViewSelector = exports.gridListColumnSelector = void 0;
7
7
  var _createSelector = require("../../../utils/createSelector");
8
+ /**
9
+ * Get the list view state
10
+ * @category List View
11
+ * @ignore - Do not document
12
+ */
13
+ const gridListViewSelector = exports.gridListViewSelector = (0, _createSelector.createRootSelector)(state => state.props.listView ?? false);
14
+
8
15
  /**
9
16
  * Get the list column definition
10
17
  * @category List View
@@ -307,12 +307,13 @@ const useGridRowSelection = (apiRef, props) => {
307
307
  }
308
308
  const currentSelection = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef);
309
309
  const rowsLookup = (0, _gridRowsSelector.gridRowsLookupSelector)(apiRef);
310
+ const rowTree = (0, _gridRowsSelector.gridRowTreeSelector)(apiRef);
310
311
  const filteredRowsLookup = (0, _gridFilterSelector.gridFilteredRowsLookupSelector)(apiRef);
311
312
  const isNonExistent = id => {
312
313
  if (props.filterMode === 'server') {
313
314
  return !rowsLookup[id];
314
315
  }
315
- return !rowsLookup[id] || filteredRowsLookup[id] === false;
316
+ return !rowTree[id] || filteredRowsLookup[id] === false;
316
317
  };
317
318
  const newSelectionModel = {
318
319
  type: currentSelection.type,
@@ -438,15 +439,15 @@ const useGridRowSelection = (apiRef, props) => {
438
439
  const filterModel = (0, _gridFilterSelector.gridFilterModelSelector)(apiRef);
439
440
  const quickFilterModel = (0, _gridFilterSelector.gridQuickFilterValuesSelector)(apiRef);
440
441
  const hasFilters = filterModel.items.length > 0 || quickFilterModel?.some(val => val.length);
441
- if (!props.isRowSelectable && !props.checkboxSelectionVisibleOnly && applyAutoSelection && !hasFilters) {
442
+ if (!props.isRowSelectable && !props.checkboxSelectionVisibleOnly && (!isNestedData || props.rowSelectionPropagation?.descendants) && !hasFilters) {
442
443
  apiRef.current.setRowSelectionModel({
443
444
  type: value ? 'exclude' : 'include',
444
445
  ids: new Set()
445
- });
446
+ }, 'multipleRowsSelection');
446
447
  } else {
447
448
  apiRef.current.selectRows(getRowsToBeSelected(), value);
448
449
  }
449
- }, [apiRef, applyAutoSelection, getRowsToBeSelected, props.checkboxSelectionVisibleOnly, props.isRowSelectable]);
450
+ }, [apiRef, getRowsToBeSelected, props.checkboxSelectionVisibleOnly, props.isRowSelectable, props.rowSelectionPropagation?.descendants, isNestedData]);
450
451
  const handleHeaderSelectionCheckboxChange = React.useCallback(params => {
451
452
  toggleAllRows(params.value);
452
453
  }, [toggleAllRows]);
@@ -42,7 +42,7 @@ export declare const getRowsStateFromCache: ({
42
42
  }) => GridRowsState;
43
43
  export declare const isAutogeneratedRow: (row: GridRowModel) => boolean;
44
44
  export declare const isAutogeneratedRowNode: (rowNode: GridTreeNode) => rowNode is GridFooterNode | GridSkeletonRowNode | GridAutoGeneratedGroupNode | GridAutoGeneratedPinnedRowNode;
45
- export declare const getTreeNodeDescendants: (tree: GridRowTreeConfig, parentId: GridRowId, skipAutoGeneratedRows: boolean) => GridRowId[];
45
+ export declare const getTreeNodeDescendants: (tree: GridRowTreeConfig, parentId: GridRowId, skipAutoGeneratedRows: boolean, directChildrenOnly?: boolean) => GridRowId[];
46
46
  export declare const updateCacheWithNewRows: ({
47
47
  previousCache,
48
48
  getRowId,
@@ -145,7 +145,7 @@ const isAutogeneratedRow = row => GRID_ID_AUTOGENERATED in row;
145
145
  exports.isAutogeneratedRow = isAutogeneratedRow;
146
146
  const isAutogeneratedRowNode = rowNode => rowNode.type === 'skeletonRow' || rowNode.type === 'footer' || rowNode.type === 'group' && rowNode.isAutoGenerated || rowNode.type === 'pinnedRow' && rowNode.isAutoGenerated;
147
147
  exports.isAutogeneratedRowNode = isAutogeneratedRowNode;
148
- const getTreeNodeDescendants = (tree, parentId, skipAutoGeneratedRows) => {
148
+ const getTreeNodeDescendants = (tree, parentId, skipAutoGeneratedRows, directChildrenOnly) => {
149
149
  const node = tree[parentId];
150
150
  if (node.type !== 'group') {
151
151
  return [];
@@ -156,7 +156,10 @@ const getTreeNodeDescendants = (tree, parentId, skipAutoGeneratedRows) => {
156
156
  if (!skipAutoGeneratedRows || !isAutogeneratedRowNode(tree[child])) {
157
157
  validDescendants.push(child);
158
158
  }
159
- const childDescendants = getTreeNodeDescendants(tree, child, skipAutoGeneratedRows);
159
+ if (directChildrenOnly) {
160
+ continue;
161
+ }
162
+ const childDescendants = getTreeNodeDescendants(tree, child, skipAutoGeneratedRows, directChildrenOnly);
160
163
  for (let j = 0; j < childDescendants.length; j += 1) {
161
164
  validDescendants.push(childDescendants[j]);
162
165
  }
@@ -206,7 +206,8 @@ const useGridRows = (apiRef, props) => {
206
206
  skipAutoGeneratedRows = true,
207
207
  groupId,
208
208
  applySorting,
209
- applyFiltering
209
+ applyFiltering,
210
+ directChildrenOnly = false
210
211
  }) => {
211
212
  const tree = (0, _gridRowsSelector.gridRowTreeSelector)(apiRef);
212
213
  let children;
@@ -218,14 +219,14 @@ const useGridRows = (apiRef, props) => {
218
219
  const sortedRowIds = (0, _gridSortingSelector.gridSortedRowIdsSelector)(apiRef);
219
220
  children = [];
220
221
  const startIndex = sortedRowIds.findIndex(id => id === groupId) + 1;
221
- for (let index = startIndex; index < sortedRowIds.length && tree[sortedRowIds[index]].depth > groupNode.depth; index += 1) {
222
+ for (let index = startIndex; index < sortedRowIds.length && (directChildrenOnly ? tree[sortedRowIds[index]].depth === groupNode.depth + 1 : tree[sortedRowIds[index]].depth > groupNode.depth); index += 1) {
222
223
  const id = sortedRowIds[index];
223
224
  if (!skipAutoGeneratedRows || !(0, _gridRowsUtils.isAutogeneratedRowNode)(tree[id])) {
224
225
  children.push(id);
225
226
  }
226
227
  }
227
228
  } else {
228
- children = (0, _gridRowsUtils.getTreeNodeDescendants)(tree, groupId, skipAutoGeneratedRows);
229
+ children = (0, _gridRowsUtils.getTreeNodeDescendants)(tree, groupId, skipAutoGeneratedRows, directChildrenOnly);
229
230
  }
230
231
  if (applyFiltering) {
231
232
  const filteredRowsLookup = (0, _gridFilterSelector.gridFilteredRowsLookupSelector)(apiRef);
@@ -9,4 +9,4 @@ import { DataGridProcessedProps } from "../../../models/props/DataGridProps.js";
9
9
  * @requires useGridFilter (state)
10
10
  * @requires useGridColumnSpanning (method)
11
11
  */
12
- export declare const useGridScroll: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "pagination" | "listView">) => void;
12
+ export declare const useGridScroll: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "pagination">) => void;
@@ -16,7 +16,6 @@ var _gridRowsMetaSelector = require("../rows/gridRowsMetaSelector");
16
16
  var _useGridApiMethod = require("../../utils/useGridApiMethod");
17
17
  var _gridFilterSelector = require("../filter/gridFilterSelector");
18
18
  var _dimensions = require("../dimensions");
19
- var _gridListViewSelectors = require("../listView/gridListViewSelectors");
20
19
  // Logic copied from https://www.w3.org/TR/wai-aria-practices/examples/listbox/js/listbox.js
21
20
  // Similar to https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
22
21
  function scrollIntoView(dimensions) {
@@ -58,7 +57,7 @@ const useGridScroll = (apiRef, props) => {
58
57
  const scrollToIndexes = React.useCallback(params => {
59
58
  const dimensions = (0, _dimensions.gridDimensionsSelector)(apiRef);
60
59
  const totalRowCount = (0, _gridRowsSelector.gridRowCountSelector)(apiRef);
61
- const visibleColumns = props.listView ? [(0, _gridListViewSelectors.gridListColumnSelector)(apiRef)] : (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef);
60
+ const visibleColumns = (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef);
62
61
  const scrollToHeader = params.rowIndex == null;
63
62
  if (!scrollToHeader && totalRowCount === 0 || visibleColumns.length === 0) {
64
63
  return false;
@@ -105,7 +104,7 @@ const useGridScroll = (apiRef, props) => {
105
104
  return true;
106
105
  }
107
106
  return false;
108
- }, [logger, apiRef, virtualScrollerRef, props.pagination, visibleSortedRows, props.listView]);
107
+ }, [logger, apiRef, virtualScrollerRef, props.pagination, visibleSortedRows]);
109
108
  const scroll = React.useCallback(params => {
110
109
  if (virtualScrollerRef.current && params.left !== undefined && colRef.current) {
111
110
  const direction = isRtl ? -1 : 1;
@@ -35,9 +35,7 @@ var _gridColumnsUtils = require("../columns/gridColumnsUtils");
35
35
  var _gridVirtualizationSelectors = require("./gridVirtualizationSelectors");
36
36
  var _useGridVirtualization = require("./useGridVirtualization");
37
37
  var _gridRowSpanningSelectors = require("../rows/gridRowSpanningSelectors");
38
- var _gridListViewSelectors = require("../listView/gridListViewSelectors");
39
38
  var _gridRowsUtils = require("../rows/gridRowsUtils");
40
- var _columns = require("../columns");
41
39
  var _gridFocusedVirtualCellSelector = require("./gridFocusedVirtualCellSelector");
42
40
  var _roundToDecimalPlaces = require("../../../utils/roundToDecimalPlaces");
43
41
  var _isJSDOM = require("../../../utils/isJSDOM");
@@ -67,12 +65,11 @@ const useGridVirtualScroller = () => {
67
65
  const {
68
66
  listView
69
67
  } = rootProps;
70
- const visibleColumns = (0, _useGridSelector.useGridSelector)(apiRef, () => listView ? [(0, _gridListViewSelectors.gridListColumnSelector)(apiRef)] : (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef));
68
+ const visibleColumns = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector);
71
69
  const enabledForRows = (0, _useGridSelector.useGridSelector)(apiRef, _gridVirtualizationSelectors.gridVirtualizationRowEnabledSelector) && !_isJSDOM.isJSDOM;
72
70
  const enabledForColumns = (0, _useGridSelector.useGridSelector)(apiRef, _gridVirtualizationSelectors.gridVirtualizationColumnEnabledSelector) && !_isJSDOM.isJSDOM;
73
71
  const pinnedRows = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridPinnedRowsSelector);
74
- const pinnedColumnDefinitions = (0, _gridColumnsSelector.gridVisiblePinnedColumnDefinitionsSelector)(apiRef);
75
- const pinnedColumns = listView ? _columns.EMPTY_PINNED_COLUMN_FIELDS : pinnedColumnDefinitions;
72
+ const pinnedColumns = (0, _gridColumnsSelector.gridVisiblePinnedColumnDefinitionsSelector)(apiRef);
76
73
  const hasBottomPinnedRows = pinnedRows.bottom.length > 0;
77
74
  const [panels, setPanels] = React.useState(EMPTY_DETAIL_PANELS);
78
75
  const isRtl = (0, _RtlProvider.useRtl)();
@@ -563,7 +560,7 @@ function needsHorizontalScrollbarSelector(apiRef) {
563
560
  function inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns) {
564
561
  const dimensions = (0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef);
565
562
  const currentPage = (0, _useGridVisibleRows.getVisibleRows)(apiRef, rootProps);
566
- const visibleColumns = rootProps.listView ? [(0, _gridListViewSelectors.gridListColumnSelector)(apiRef)] : (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef);
563
+ const visibleColumns = (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef);
567
564
  const hiddenCellsOriginMap = (0, _gridRowSpanningSelectors.gridRowSpanningHiddenCellsOriginMapSelector)(apiRef);
568
565
  const lastRowId = apiRef.current.state.rows.dataRowIds.at(-1);
569
566
  const lastColumn = visibleColumns.at(-1);
@@ -6,4 +6,5 @@ export * from "./useGridNativeEventListener.js";
6
6
  export * from "./useFirstRender.js";
7
7
  export * from "./useOnMount.js";
8
8
  export * from "./useRunOnce.js";
9
+ export * from "./useRunOncePerLoop.js";
9
10
  export type { RenderProp } from '@mui/x-internals/useComponentRenderer';
@@ -106,4 +106,16 @@ Object.keys(_useRunOnce).forEach(function (key) {
106
106
  return _useRunOnce[key];
107
107
  }
108
108
  });
109
+ });
110
+ var _useRunOncePerLoop = require("./useRunOncePerLoop");
111
+ Object.keys(_useRunOncePerLoop).forEach(function (key) {
112
+ if (key === "default" || key === "__esModule") return;
113
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
114
+ if (key in exports && exports[key] === _useRunOncePerLoop[key]) return;
115
+ Object.defineProperty(exports, key, {
116
+ enumerable: true,
117
+ get: function () {
118
+ return _useRunOncePerLoop[key];
119
+ }
120
+ });
109
121
  });
@@ -4,5 +4,5 @@ import { GridPrivateApiCommunity } from "../../models/api/gridApiCommunity.js";
4
4
  import { DataGridProcessedProps } from "../../models/props/DataGridProps.js";
5
5
  type DeepPartial<T> = { [P in keyof T]?: DeepPartial<T[P]> };
6
6
  export type GridStateInitializer<P extends Partial<DataGridProcessedProps> = DataGridProcessedProps, PrivateApi extends GridPrivateApiCommon = GridPrivateApiCommunity> = (state: DeepPartial<PrivateApi['state']>, props: P, privateApiRef: RefObject<PrivateApi>) => DeepPartial<PrivateApi['state']>;
7
- export declare const useGridInitializeState: <P extends Partial<DataGridProcessedProps>, PrivateApi extends GridPrivateApiCommon = GridPrivateApiCommunity>(initializer: GridStateInitializer<P, PrivateApi>, privateApiRef: RefObject<PrivateApi>, props: P) => void;
7
+ export declare const useGridInitializeState: <P extends Partial<DataGridProcessedProps>, PrivateApi extends GridPrivateApiCommon = GridPrivateApiCommunity>(initializer: GridStateInitializer<P, PrivateApi>, privateApiRef: RefObject<PrivateApi>, props: P, key?: string) => void;
8
8
  export {};
@@ -6,8 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.useGridInitializeState = void 0;
8
8
  var React = _interopRequireWildcard(require("react"));
9
- const useGridInitializeState = (initializer, privateApiRef, props) => {
9
+ const useGridInitializeState = (initializer, privateApiRef, props, key) => {
10
+ const previousKey = React.useRef(key);
10
11
  const isInitialized = React.useRef(false);
12
+ if (key !== previousKey.current) {
13
+ isInitialized.current = false;
14
+ previousKey.current = key;
15
+ }
11
16
  if (!isInitialized.current) {
12
17
  privateApiRef.current.state = initializer(privateApiRef.current.state, props, privateApiRef);
13
18
  isInitialized.current = true;
@@ -0,0 +1 @@
1
+ export declare function useRunOncePerLoop<T extends (...args: any[]) => void>(callback: T, nextFrame?: boolean): (...args: Parameters<T>) => void;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useRunOncePerLoop = useRunOncePerLoop;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ function useRunOncePerLoop(callback, nextFrame = false) {
10
+ const scheduledRef = React.useRef(false);
11
+ const schedule = React.useCallback((...args) => {
12
+ if (scheduledRef.current) {
13
+ return;
14
+ }
15
+ scheduledRef.current = true;
16
+ const runner = () => {
17
+ scheduledRef.current = false;
18
+ callback(...args);
19
+ };
20
+ if (nextFrame) {
21
+ if (typeof requestAnimationFrame === 'function') {
22
+ requestAnimationFrame(runner);
23
+ }
24
+ return;
25
+ }
26
+ if (typeof queueMicrotask === 'function') {
27
+ queueMicrotask(runner);
28
+ } else {
29
+ Promise.resolve().then(runner);
30
+ }
31
+ }, [callback, nextFrame]);
32
+ return schedule;
33
+ }
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v8.8.0
2
+ * @mui/x-data-grid v8.9.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -19,6 +19,11 @@ export interface GridRowGroupChildrenGetterParams {
19
19
  * @default false
20
20
  */
21
21
  applySorting?: boolean;
22
+ /**
23
+ * If `true`, the method will only return the direct leaf children of the group
24
+ * @default false
25
+ */
26
+ directChildrenOnly?: boolean;
22
27
  }
23
28
  /**
24
29
  * The Row API interface that is available in the grid `apiRef`.
@@ -77,11 +77,12 @@ export interface GridRowEventLookup {
77
77
  };
78
78
  /**
79
79
  * Fired when the dragging of a row ends.
80
+ * It's mapped to the `dragend` DOM event.
80
81
  * @ignore - do not document.
81
82
  */
82
83
  rowDragEnd: {
83
84
  params: GridRowParams;
84
- event: React.DragEvent<HTMLElement>;
85
+ event: DragEvent;
85
86
  };
86
87
  }
87
88
  export interface GridColumnHeaderEventLookup {
@@ -1,6 +1,12 @@
1
- import { GridRowsInternalCache } from "../hooks/features/rows/gridRowsInterfaces.js";
2
- import { GridRowsMetaInternalCache } from "../hooks/features/rows/gridRowsMetaInterfaces.js";
1
+ import type { GridRowsInternalCache } from "../hooks/features/rows/gridRowsInterfaces.js";
2
+ import type { GridRowsMetaInternalCache } from "../hooks/features/rows/gridRowsMetaInterfaces.js";
3
+ import type { GridColumnGroupingInternalCache } from "../hooks/features/columnGrouping/gridColumnGroupsInterfaces.js";
4
+ import type { GridColDef } from "./colDef/index.js";
3
5
  export interface GridApiCaches {
6
+ columns: {
7
+ lastColumnsProp: readonly GridColDef[];
8
+ };
9
+ columnGrouping: GridColumnGroupingInternalCache;
4
10
  rows: GridRowsInternalCache;
5
11
  rowsMeta: GridRowsMetaInternalCache;
6
12
  }
@@ -1,5 +1,5 @@
1
1
  import type { GridColumnMenuState, GridColumnsInitialState, GridColumnsState, GridColumnsGroupingState, GridColumnPinningState, GridDensityState, GridDimensionsState, GridFilterInitialState, GridFilterState, GridFocusState, GridPaginationInitialState, GridPaginationState, GridPreferencePanelInitialState, GridPreferencePanelState, GridRowsState, GridSortingInitialState, GridSortingState, GridTabIndexState, GridVirtualizationState } from "../hooks/index.js";
2
- import type { DataGridProps } from "./props/DataGridProps.js";
2
+ import type { DataGridProcessedProps } from "./props/DataGridProps.js";
3
3
  import type { GridRowsMetaState } from "../hooks/features/rows/gridRowsMetaState.js";
4
4
  import type { GridEditingState } from "./gridEditRowModel.js";
5
5
  import { GridHeaderFilteringState } from "./gridHeaderFilteringModel.js";
@@ -12,7 +12,7 @@ import type { GridListViewState } from "../hooks/features/listView/useGridListVi
12
12
  * Some props are passed on the state to enable grid selectors to select
13
13
  * and react to them.
14
14
  */
15
- type GridStateProps = Pick<DataGridProps, 'getRowId'>;
15
+ type GridStateProps = Pick<DataGridProcessedProps, 'getRowId' | 'listView'>;
16
16
  /**
17
17
  * The state of Data Grid.
18
18
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "8.8.0",
3
+ "version": "8.9.1",
4
4
  "author": "MUI Team",
5
5
  "description": "The Community plan edition of the MUI X Data Grid components.",
6
6
  "main": "./index.js",