@mui/x-data-grid 7.19.0 → 7.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/CHANGELOG.md +224 -43
  2. package/DataGrid/DataGrid.js +8 -0
  3. package/DataGrid/index.d.ts +0 -1
  4. package/DataGrid/index.js +1 -2
  5. package/DataGrid/useDataGridComponent.js +4 -1
  6. package/DataGrid/useDataGridProps.d.ts +1 -5
  7. package/DataGrid/useDataGridProps.js +3 -62
  8. package/components/GridPagination.js +1 -0
  9. package/components/GridRow.js +25 -36
  10. package/components/base/GridOverlays.js +8 -0
  11. package/components/columnHeaders/GridColumnHeaderItem.js +1 -0
  12. package/components/containers/GridRootStyles.js +1 -0
  13. package/components/menu/columnMenu/GridColumnMenu.js +32 -0
  14. package/components/toolbar/GridToolbarExport.d.ts +9 -3
  15. package/components/toolbar/GridToolbarExport.js +55 -3
  16. package/components/virtualization/GridVirtualScrollbar.js +4 -0
  17. package/components/virtualization/GridVirtualScroller.js +2 -2
  18. package/constants/dataGridPropsDefaultValues.d.ts +5 -0
  19. package/constants/dataGridPropsDefaultValues.js +60 -0
  20. package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +2 -1
  21. package/hooks/core/useGridRefs.js +4 -0
  22. package/hooks/features/clipboard/useGridClipboard.js +2 -1
  23. package/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -1
  24. package/hooks/features/columns/gridColumnsUtils.d.ts +1 -1
  25. package/hooks/features/columns/gridColumnsUtils.js +3 -0
  26. package/hooks/features/dimensions/useGridDimensions.js +6 -4
  27. package/hooks/features/editing/useGridCellEditing.js +3 -1
  28. package/hooks/features/editing/useGridRowEditing.js +3 -1
  29. package/hooks/features/events/useGridEvents.d.ts +1 -1
  30. package/hooks/features/events/useGridEvents.js +1 -0
  31. package/hooks/features/filter/gridFilterUtils.js +1 -1
  32. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
  33. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +9 -5
  34. package/hooks/features/listView/gridListViewSelectors.d.ts +5 -0
  35. package/hooks/features/listView/gridListViewSelectors.js +4 -0
  36. package/hooks/features/listView/useGridListView.d.ts +10 -0
  37. package/hooks/features/listView/useGridListView.js +54 -0
  38. package/hooks/features/rowSelection/useGridRowSelection.js +11 -2
  39. package/hooks/features/rowSelection/utils.js +6 -6
  40. package/hooks/features/rows/gridRowsMetaInterfaces.d.ts +16 -0
  41. package/hooks/features/rows/gridRowsMetaInterfaces.js +1 -0
  42. package/hooks/features/rows/gridRowsUtils.d.ts +3 -0
  43. package/hooks/features/rows/gridRowsUtils.js +15 -2
  44. package/hooks/features/rows/useGridParamsApi.d.ts +2 -1
  45. package/hooks/features/rows/useGridParamsApi.js +4 -3
  46. package/hooks/features/rows/useGridRowSpanning.js +1 -1
  47. package/hooks/features/rows/useGridRowsMeta.js +135 -154
  48. package/hooks/features/scroll/useGridScroll.d.ts +1 -1
  49. package/hooks/features/scroll/useGridScroll.js +10 -5
  50. package/hooks/features/sorting/gridSortingUtils.js +1 -1
  51. package/hooks/features/virtualization/useGridVirtualScroller.js +25 -11
  52. package/hooks/utils/useGridApiContext.js +1 -1
  53. package/hooks/utils/useGridApiEventHandler.d.ts +1 -1
  54. package/hooks/utils/useGridApiEventHandler.js +1 -1
  55. package/hooks/utils/useGridApiMethod.js +2 -1
  56. package/hooks/utils/useGridConfiguration.js +1 -1
  57. package/hooks/utils/useGridPrivateApiContext.js +1 -1
  58. package/index.d.ts +3 -2
  59. package/index.js +4 -3
  60. package/internals/index.d.ts +2 -1
  61. package/internals/index.js +2 -1
  62. package/joy/icons.js +0 -1
  63. package/locales/jaJP.js +4 -4
  64. package/models/api/gridApiCommunity.d.ts +1 -1
  65. package/models/api/gridCoreApi.d.ts +9 -1
  66. package/models/api/gridFilterApi.d.ts +1 -1
  67. package/models/api/gridRowsMetaApi.d.ts +15 -14
  68. package/models/colDef/gridColDef.d.ts +6 -0
  69. package/models/colDef/index.d.ts +1 -1
  70. package/models/events/gridEventLookup.d.ts +7 -0
  71. package/models/gridApiCaches.d.ts +2 -0
  72. package/models/gridStateCommunity.d.ts +4 -2
  73. package/models/props/DataGridProps.d.ts +37 -17
  74. package/modern/DataGrid/DataGrid.js +8 -0
  75. package/modern/DataGrid/index.js +1 -2
  76. package/modern/DataGrid/useDataGridComponent.js +4 -1
  77. package/modern/DataGrid/useDataGridProps.js +3 -62
  78. package/modern/components/GridPagination.js +1 -0
  79. package/modern/components/GridRow.js +25 -36
  80. package/modern/components/base/GridOverlays.js +8 -0
  81. package/modern/components/columnHeaders/GridColumnHeaderItem.js +1 -0
  82. package/modern/components/containers/GridRootStyles.js +1 -0
  83. package/modern/components/menu/columnMenu/GridColumnMenu.js +32 -0
  84. package/modern/components/toolbar/GridToolbarExport.js +55 -3
  85. package/modern/components/virtualization/GridVirtualScrollbar.js +4 -0
  86. package/modern/components/virtualization/GridVirtualScroller.js +2 -2
  87. package/modern/constants/dataGridPropsDefaultValues.js +60 -0
  88. package/modern/hooks/core/useGridRefs.js +4 -0
  89. package/modern/hooks/features/clipboard/useGridClipboard.js +2 -1
  90. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -1
  91. package/modern/hooks/features/columns/gridColumnsUtils.js +3 -0
  92. package/modern/hooks/features/dimensions/useGridDimensions.js +6 -4
  93. package/modern/hooks/features/editing/useGridCellEditing.js +3 -1
  94. package/modern/hooks/features/editing/useGridRowEditing.js +3 -1
  95. package/modern/hooks/features/events/useGridEvents.js +1 -0
  96. package/modern/hooks/features/filter/gridFilterUtils.js +1 -1
  97. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +9 -5
  98. package/modern/hooks/features/listView/gridListViewSelectors.js +4 -0
  99. package/modern/hooks/features/listView/useGridListView.js +54 -0
  100. package/modern/hooks/features/rowSelection/useGridRowSelection.js +11 -2
  101. package/modern/hooks/features/rowSelection/utils.js +6 -6
  102. package/modern/hooks/features/rows/gridRowsMetaInterfaces.js +1 -0
  103. package/modern/hooks/features/rows/gridRowsUtils.js +15 -2
  104. package/modern/hooks/features/rows/useGridParamsApi.js +4 -3
  105. package/modern/hooks/features/rows/useGridRowSpanning.js +1 -1
  106. package/modern/hooks/features/rows/useGridRowsMeta.js +135 -154
  107. package/modern/hooks/features/scroll/useGridScroll.js +10 -5
  108. package/modern/hooks/features/sorting/gridSortingUtils.js +1 -1
  109. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +25 -11
  110. package/modern/hooks/utils/useGridApiContext.js +1 -1
  111. package/modern/hooks/utils/useGridApiEventHandler.js +1 -1
  112. package/modern/hooks/utils/useGridApiMethod.js +2 -1
  113. package/modern/hooks/utils/useGridConfiguration.js +1 -1
  114. package/modern/hooks/utils/useGridPrivateApiContext.js +1 -1
  115. package/modern/index.js +4 -3
  116. package/modern/internals/index.js +2 -1
  117. package/modern/joy/icons.js +0 -1
  118. package/modern/locales/jaJP.js +4 -4
  119. package/modern/utils/ResizeObserver.js +10 -0
  120. package/modern/utils/domUtils.js +1 -1
  121. package/modern/utils/keyboardUtils.js +12 -4
  122. package/node/DataGrid/DataGrid.js +8 -0
  123. package/node/DataGrid/index.js +1 -12
  124. package/node/DataGrid/useDataGridComponent.js +4 -1
  125. package/node/DataGrid/useDataGridProps.js +6 -65
  126. package/node/components/GridPagination.js +1 -0
  127. package/node/components/GridRow.js +25 -36
  128. package/node/components/base/GridOverlays.js +8 -0
  129. package/node/components/columnHeaders/GridColumnHeaderItem.js +1 -0
  130. package/node/components/containers/GridRootStyles.js +1 -0
  131. package/node/components/menu/columnMenu/GridColumnMenu.js +32 -0
  132. package/node/components/toolbar/GridToolbarExport.js +52 -0
  133. package/node/components/virtualization/GridVirtualScrollbar.js +4 -0
  134. package/node/components/virtualization/GridVirtualScroller.js +2 -2
  135. package/node/constants/dataGridPropsDefaultValues.js +66 -0
  136. package/node/hooks/core/useGridRefs.js +4 -0
  137. package/node/hooks/features/clipboard/useGridClipboard.js +2 -1
  138. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -1
  139. package/node/hooks/features/columns/gridColumnsUtils.js +3 -0
  140. package/node/hooks/features/dimensions/useGridDimensions.js +5 -3
  141. package/node/hooks/features/editing/useGridCellEditing.js +3 -1
  142. package/node/hooks/features/editing/useGridRowEditing.js +3 -1
  143. package/node/hooks/features/events/useGridEvents.js +1 -0
  144. package/node/hooks/features/filter/gridFilterUtils.js +1 -1
  145. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +9 -5
  146. package/node/hooks/features/listView/gridListViewSelectors.js +11 -0
  147. package/node/hooks/features/listView/useGridListView.js +64 -0
  148. package/node/hooks/features/rowSelection/useGridRowSelection.js +11 -2
  149. package/node/hooks/features/rowSelection/utils.js +6 -6
  150. package/node/hooks/features/rows/gridRowsMetaInterfaces.js +5 -0
  151. package/node/hooks/features/rows/gridRowsUtils.js +17 -3
  152. package/node/hooks/features/rows/useGridParamsApi.js +4 -3
  153. package/node/hooks/features/rows/useGridRowSpanning.js +1 -1
  154. package/node/hooks/features/rows/useGridRowsMeta.js +136 -154
  155. package/node/hooks/features/scroll/useGridScroll.js +10 -5
  156. package/node/hooks/features/sorting/gridSortingUtils.js +1 -1
  157. package/node/hooks/features/virtualization/useGridVirtualScroller.js +25 -11
  158. package/node/hooks/utils/useGridApiContext.js +1 -1
  159. package/node/hooks/utils/useGridApiEventHandler.js +1 -1
  160. package/node/hooks/utils/useGridApiMethod.js +3 -1
  161. package/node/hooks/utils/useGridConfiguration.js +1 -1
  162. package/node/hooks/utils/useGridPrivateApiContext.js +1 -1
  163. package/node/index.js +13 -1
  164. package/node/internals/index.js +22 -0
  165. package/node/joy/icons.js +0 -1
  166. package/node/locales/jaJP.js +4 -4
  167. package/node/utils/ResizeObserver.js +16 -0
  168. package/node/utils/domUtils.js +1 -1
  169. package/node/utils/keyboardUtils.js +15 -5
  170. package/package.json +4 -4
  171. package/utils/ResizeObserver.d.ts +4 -0
  172. package/utils/ResizeObserver.js +10 -0
  173. package/utils/domUtils.js +1 -1
  174. package/utils/keyboardUtils.d.ts +1 -0
  175. package/utils/keyboardUtils.js +12 -4
@@ -5,6 +5,7 @@ import { useGridApiOptionHandler } from "../../utils/useGridApiEventHandler.js";
5
5
  */
6
6
  export function useGridEvents(apiRef, props) {
7
7
  useGridApiOptionHandler(apiRef, 'columnHeaderClick', props.onColumnHeaderClick);
8
+ useGridApiOptionHandler(apiRef, 'columnHeaderContextMenu', props.onColumnHeaderContextMenu);
8
9
  useGridApiOptionHandler(apiRef, 'columnHeaderDoubleClick', props.onColumnHeaderDoubleClick);
9
10
  useGridApiOptionHandler(apiRef, 'columnHeaderOver', props.onColumnHeaderOver);
10
11
  useGridApiOptionHandler(apiRef, 'columnHeaderOut', props.onColumnHeaderOut);
@@ -41,7 +41,7 @@ export const sanitizeFilterModel = (model, disableMultipleColumnsFiltering, apiR
41
41
  let items;
42
42
  if (hasSeveralItems && disableMultipleColumnsFiltering) {
43
43
  if (process.env.NODE_ENV !== 'production') {
44
- warnOnce(['MUI X: The `filterModel` can only contain a single item when the `disableMultipleColumnsFiltering` prop is set to `true`.', 'If you are using the community version of the `DataGrid`, this prop is always `true`.'], 'error');
44
+ warnOnce(['MUI X: The `filterModel` can only contain a single item when the `disableMultipleColumnsFiltering` prop is set to `true`.', 'If you are using the community version of the Data Grid, this prop is always `true`.'], 'error');
45
45
  }
46
46
  items = [model.items[0]];
47
47
  } else {
@@ -10,4 +10,4 @@ import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
10
10
  * @requires useGridScroll (method) - can be after
11
11
  * @requires useGridColumnSpanning (method) - can be after
12
12
  */
13
- export declare const useGridKeyboardNavigation: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "pagination" | "paginationMode" | "getRowId" | "experimentalFeatures" | "signature" | "headerFilters">) => void;
13
+ export declare const useGridKeyboardNavigation: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "pagination" | "paginationMode" | "getRowId" | "experimentalFeatures" | "signature" | "headerFilters" | "unstable_listView">) => void;
@@ -16,6 +16,7 @@ import { gridHeaderFilteringEditFieldSelector, gridHeaderFilteringMenuSelector }
16
16
  import { useGridRegisterPipeProcessor } from "../../core/pipeProcessing/index.js";
17
17
  import { isEventTargetInPortal } from "../../../utils/domUtils.js";
18
18
  import { enrichPageRowsWithPinnedRows, getLeftColumnIndex, getRightColumnIndex, findNonRowSpannedCell } from "./utils.js";
19
+ import { gridListColumnSelector } from "../listView/gridListViewSelectors.js";
19
20
 
20
21
  /**
21
22
  * @requires useGridSorting (method) - can be after
@@ -30,6 +31,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
30
31
  const logger = useGridLogger(apiRef, 'useGridKeyboardNavigation');
31
32
  const initialCurrentPageRows = useGridVisibleRows(apiRef, props).rows;
32
33
  const isRtl = useRtl();
34
+ const listView = props.unstable_listView;
33
35
  const currentPageRows = React.useMemo(() => enrichPageRowsWithPinnedRows(apiRef, initialCurrentPageRows), [apiRef, initialCurrentPageRows]);
34
36
  const headerFilteringEnabled = props.signature !== 'DataGrid' && props.headerFilters;
35
37
 
@@ -50,7 +52,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
50
52
  colIndex = nextCellColSpanInfo.rightVisibleCellIndex;
51
53
  }
52
54
  }
53
- const field = gridVisibleColumnFieldsSelector(apiRef)[colIndex];
55
+ const field = listView ? gridListColumnSelector(apiRef.current.state).field : gridVisibleColumnFieldsSelector(apiRef)[colIndex];
54
56
  const nonRowSpannedRowId = findNonRowSpannedCell(apiRef, rowId, field, rowSpanScanDirection);
55
57
  // `scrollToIndexes` requires a rowIndex relative to all visible rows.
56
58
  // Those rows do not include pinned rows, but pinned rows do not need scroll anyway.
@@ -61,7 +63,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
61
63
  rowIndex: rowIndexRelativeToAllRows
62
64
  });
63
65
  apiRef.current.setCellFocus(nonRowSpannedRowId, field);
64
- }, [apiRef, logger]);
66
+ }, [apiRef, logger, listView]);
65
67
  const goToHeader = React.useCallback((colIndex, event) => {
66
68
  logger.debug(`Navigating to header col ${colIndex}`);
67
69
  apiRef.current.scrollToIndexes({
@@ -384,12 +386,14 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
384
386
  return;
385
387
  }
386
388
  const viewportPageSize = apiRef.current.getViewportPageSize();
387
- const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
389
+ const getColumnIndexFn = listView ? () => 0 : apiRef.current.getColumnIndex;
390
+ const colIndexBefore = params.field ? getColumnIndexFn(params.field) : 0;
388
391
  const rowIndexBefore = currentPageRows.findIndex(row => row.id === params.id);
389
392
  const firstRowIndexInPage = 0;
390
393
  const lastRowIndexInPage = currentPageRows.length - 1;
391
394
  const firstColIndex = 0;
392
- const lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
395
+ const visibleColumns = listView ? [gridListColumnSelector(apiRef.current.state)] : gridVisibleColumnDefinitionsSelector(apiRef);
396
+ const lastColIndex = visibleColumns.length - 1;
393
397
  let shouldPreventDefault = true;
394
398
  switch (event.key) {
395
399
  case 'ArrowDown':
@@ -508,7 +512,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
508
512
  if (shouldPreventDefault) {
509
513
  event.preventDefault();
510
514
  }
511
- }, [apiRef, currentPageRows, isRtl, goToCell, getRowIdFromIndex, headerFilteringEnabled, goToHeaderFilter, goToHeader]);
515
+ }, [apiRef, currentPageRows, isRtl, goToCell, getRowIdFromIndex, headerFilteringEnabled, goToHeaderFilter, goToHeader, listView]);
512
516
  const checkIfCanStartEditing = React.useCallback((initialValue, {
513
517
  event
514
518
  }) => {
@@ -0,0 +1,5 @@
1
+ import { GridStateCommunity } from '../../../models/gridStateCommunity';
2
+ /**
3
+ * Get a list column definition
4
+ */
5
+ export declare const gridListColumnSelector: (state: GridStateCommunity) => import("./useGridListView").GridListViewState;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Get a list column definition
3
+ */
4
+ export const gridListColumnSelector = state => state.listViewColumn;
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import type { GridListColDef } from '../../../models/colDef/gridColDef';
3
+ import { GridStateInitializer } from '../../utils/useGridInitializeState';
4
+ import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
5
+ import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
6
+ export type GridListViewState = (GridListColDef & {
7
+ computedWidth: number;
8
+ }) | undefined;
9
+ export declare const listViewStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'unstable_listColumn'>>;
10
+ export declare function useGridListView(apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'unstable_listColumn'>): void;
@@ -0,0 +1,54 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import { gridDimensionsSelector } from "../dimensions/index.js";
4
+ import { useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
5
+ export const listViewStateInitializer = (state, props, apiRef) => _extends({}, state, {
6
+ listViewColumn: _extends({}, props.unstable_listColumn, {
7
+ computedWidth: getListColumnWidth(apiRef)
8
+ })
9
+ });
10
+ export function useGridListView(apiRef, props) {
11
+ /*
12
+ * EVENTS
13
+ */
14
+ const updateListColumnWidth = () => {
15
+ apiRef.current.setState(state => {
16
+ if (!state.listViewColumn) {
17
+ return state;
18
+ }
19
+ return _extends({}, state, {
20
+ listViewColumn: _extends({}, state.listViewColumn, {
21
+ computedWidth: getListColumnWidth(apiRef)
22
+ })
23
+ });
24
+ });
25
+ };
26
+ const prevInnerWidth = React.useRef(null);
27
+ const handleGridSizeChange = viewportInnerSize => {
28
+ if (prevInnerWidth.current !== viewportInnerSize.width) {
29
+ prevInnerWidth.current = viewportInnerSize.width;
30
+ updateListColumnWidth();
31
+ }
32
+ };
33
+ useGridApiEventHandler(apiRef, 'viewportInnerSizeChange', handleGridSizeChange);
34
+ useGridApiEventHandler(apiRef, 'columnVisibilityModelChange', updateListColumnWidth);
35
+
36
+ /*
37
+ * EFFECTS
38
+ */
39
+ React.useEffect(() => {
40
+ const listColumn = props.unstable_listColumn;
41
+ if (listColumn) {
42
+ apiRef.current.setState(state => {
43
+ return _extends({}, state, {
44
+ listViewColumn: _extends({}, listColumn, {
45
+ computedWidth: getListColumnWidth(apiRef)
46
+ })
47
+ });
48
+ });
49
+ }
50
+ }, [apiRef, props.unstable_listColumn]);
51
+ }
52
+ function getListColumnWidth(apiRef) {
53
+ return gridDimensionsSelector(apiRef.current.state).viewportInnerSize.width;
54
+ }
@@ -246,7 +246,11 @@ export const useGridRowSelection = (apiRef, props) => {
246
246
  /*
247
247
  * EVENTS
248
248
  */
249
+ const isFirstRender = React.useRef(true);
249
250
  const removeOutdatedSelection = React.useCallback((sortModelUpdated = false) => {
251
+ if (isFirstRender.current) {
252
+ return;
253
+ }
250
254
  const currentSelection = gridRowSelectionStateSelector(apiRef.current.state);
251
255
  const filteredRowsLookup = gridFilteredRowsLookupSelector(apiRef);
252
256
 
@@ -254,7 +258,7 @@ export const useGridRowSelection = (apiRef, props) => {
254
258
  const selectionLookup = _extends({}, selectedIdsLookupSelector(apiRef));
255
259
  let hasChanged = false;
256
260
  currentSelection.forEach(id => {
257
- if (filteredRowsLookup[id] === false) {
261
+ if (filteredRowsLookup[id] !== true) {
258
262
  if (props.keepNonExistentRowsSelected) {
259
263
  return;
260
264
  }
@@ -408,7 +412,7 @@ export const useGridRowSelection = (apiRef, props) => {
408
412
  handleSingleRowSelection(params.id, event);
409
413
  return;
410
414
  }
411
- if (event.key === 'a' && (event.ctrlKey || event.metaKey)) {
415
+ if (String.fromCharCode(event.keyCode) === 'A' && (event.ctrlKey || event.metaKey)) {
412
416
  event.preventDefault();
413
417
  selectRows(apiRef.current.getAllRowIds(), true);
414
418
  }
@@ -462,4 +466,9 @@ export const useGridRowSelection = (apiRef, props) => {
462
466
  React.useEffect(() => {
463
467
  runIfRowSelectionIsEnabled(removeOutdatedSelection);
464
468
  }, [removeOutdatedSelection, runIfRowSelectionIsEnabled]);
469
+ React.useEffect(() => {
470
+ if (isFirstRender.current) {
471
+ isFirstRender.current = false;
472
+ }
473
+ }, []);
465
474
  };
@@ -44,21 +44,21 @@ export function getCheckboxPropsSelector(groupId, autoSelectParents) {
44
44
  isChecked: true
45
45
  };
46
46
  }
47
- let selectableDescendentsCount = 0;
48
- let selectedDescendentsCount = 0;
47
+ let selectableDescendantsCount = 0;
48
+ let selectedDescendantsCount = 0;
49
49
  const startIndex = sortedRowIds.findIndex(id => id === groupId) + 1;
50
50
  for (let index = startIndex; index < sortedRowIds.length && rowTree[sortedRowIds[index]]?.depth > groupNode.depth; index += 1) {
51
51
  const id = sortedRowIds[index];
52
52
  if (filteredRowsLookup[id] !== false) {
53
- selectableDescendentsCount += 1;
53
+ selectableDescendantsCount += 1;
54
54
  if (rowSelectionLookup[id] !== undefined) {
55
- selectedDescendentsCount += 1;
55
+ selectedDescendantsCount += 1;
56
56
  }
57
57
  }
58
58
  }
59
59
  return {
60
- isIndeterminate: selectedDescendentsCount > 0 && selectedDescendentsCount < selectableDescendentsCount || selectedDescendentsCount === selectableDescendentsCount && rowSelectionLookup[groupId] === undefined,
61
- isChecked: autoSelectParents ? selectedDescendentsCount > 0 : rowSelectionLookup[groupId] === groupId
60
+ isIndeterminate: selectedDescendantsCount > 0 && (selectedDescendantsCount < selectableDescendantsCount || rowSelectionLookup[groupId] === undefined),
61
+ isChecked: autoSelectParents ? selectedDescendantsCount > 0 : rowSelectionLookup[groupId] === groupId
62
62
  };
63
63
  });
64
64
  }
@@ -0,0 +1,16 @@
1
+ import { GridRowId } from '../../../models/gridRows';
2
+ export type HeightEntry = {
3
+ content: number;
4
+ spacingTop: number;
5
+ spacingBottom: number;
6
+ detail: number;
7
+ autoHeight: boolean;
8
+ needsFirstMeasurement: boolean;
9
+ };
10
+ export type HeightCache = Map<GridRowId, HeightEntry>;
11
+ export interface GridRowsMetaInternalCache {
12
+ /**
13
+ * Map of height cache entries.
14
+ */
15
+ heights: HeightCache;
16
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -39,3 +39,6 @@ export declare function calculatePinnedRowsHeight(apiRef: React.MutableRefObject
39
39
  };
40
40
  export declare function getMinimalContentHeight(apiRef: React.MutableRefObject<GridApiCommunity>): string;
41
41
  export declare function computeRowsUpdates(apiRef: React.MutableRefObject<GridApiCommunity>, updates: GridRowModelUpdate[], getRowId: DataGridProcessedProps['getRowId']): GridRowModelUpdate[];
42
+ export declare const getValidRowHeight: (rowHeightProp: any, defaultRowHeight: number, warningMessage: string) => number;
43
+ export declare const rowHeightWarning: string;
44
+ export declare const getRowHeightWarning: string;
@@ -24,7 +24,7 @@ export const buildRootGroup = () => ({
24
24
  */
25
25
  export function checkGridRowIdIsValid(id, row, detailErrorMessage = 'A row was provided without id in the rows prop:') {
26
26
  if (id == null) {
27
- throw new Error(['MUI X: The data grid component requires all rows to have a unique `id` property.', 'Alternatively, you can use the `getRowId` prop to specify a custom id for each row.', detailErrorMessage, JSON.stringify(row)].join('\n'));
27
+ throw new Error(['MUI X: The Data Grid component requires all rows to have a unique `id` property.', 'Alternatively, you can use the `getRowId` prop to specify a custom id for each row.', detailErrorMessage, JSON.stringify(row)].join('\n'));
28
28
  }
29
29
  }
30
30
  export const getRowIdFromRowModel = (rowModel, getRowId, detailErrorMessage) => {
@@ -306,4 +306,17 @@ export function computeRowsUpdates(apiRef, updates, getRowId) {
306
306
  }
307
307
  });
308
308
  return nonPinnedRowsUpdates;
309
- }
309
+ }
310
+ let warnedOnceInvalidRowHeight = false;
311
+ export const getValidRowHeight = (rowHeightProp, defaultRowHeight, warningMessage) => {
312
+ if (typeof rowHeightProp === 'number' && rowHeightProp > 0) {
313
+ return rowHeightProp;
314
+ }
315
+ if (process.env.NODE_ENV !== 'production' && !warnedOnceInvalidRowHeight && typeof rowHeightProp !== 'undefined' && rowHeightProp !== null) {
316
+ console.warn(warningMessage);
317
+ warnedOnceInvalidRowHeight = true;
318
+ }
319
+ return defaultRowHeight;
320
+ };
321
+ export const rowHeightWarning = [`MUI X: The \`rowHeight\` prop should be a number greater than 0.`, `The default value will be used instead.`].join('\n');
322
+ export const getRowHeightWarning = [`MUI X: The \`getRowHeight\` prop should return a number greater than 0 or 'auto'.`, `The default value will be used instead.`].join('\n');
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
3
+ import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
3
4
  export declare class MissingRowIdError extends Error {
4
5
  }
5
6
  /**
@@ -10,4 +11,4 @@ export declare class MissingRowIdError extends Error {
10
11
  * TODO: Impossible priority - useGridEditing also needs to be after useGridParamsApi
11
12
  * TODO: Impossible priority - useGridFocus also needs to be after useGridParamsApi
12
13
  */
13
- export declare function useGridParamsApi(apiRef: React.MutableRefObject<GridPrivateApiCommunity>): void;
14
+ export declare function useGridParamsApi(apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'unstable_listView'>): void;
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  import { getGridCellElement, getGridColumnHeaderElement, getGridRowElement } from "../../../utils/domUtils.js";
3
3
  import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
4
4
  import { gridFocusCellSelector, gridTabIndexCellSelector } from "../focus/gridFocusStateSelector.js";
5
+ import { gridListColumnSelector } from "../listView/gridListViewSelectors.js";
5
6
  export class MissingRowIdError extends Error {}
6
7
 
7
8
  /**
@@ -12,7 +13,7 @@ export class MissingRowIdError extends Error {}
12
13
  * TODO: Impossible priority - useGridEditing also needs to be after useGridParamsApi
13
14
  * TODO: Impossible priority - useGridFocus also needs to be after useGridParamsApi
14
15
  */
15
- export function useGridParamsApi(apiRef) {
16
+ export function useGridParamsApi(apiRef, props) {
16
17
  const getColumnHeaderParams = React.useCallback(field => ({
17
18
  field,
18
19
  colDef: apiRef.current.getColumn(field)
@@ -30,7 +31,7 @@ export function useGridParamsApi(apiRef) {
30
31
  return params;
31
32
  }, [apiRef]);
32
33
  const getCellParams = React.useCallback((id, field) => {
33
- const colDef = apiRef.current.getColumn(field);
34
+ const colDef = props.unstable_listView ? gridListColumnSelector(apiRef.current.state) : apiRef.current.getColumn(field);
34
35
  const row = apiRef.current.getRow(id);
35
36
  const rowNode = apiRef.current.getRowNode(id);
36
37
  if (!row || !rowNode) {
@@ -59,7 +60,7 @@ export function useGridParamsApi(apiRef) {
59
60
  }
60
61
  params.isEditable = colDef && apiRef.current.isCellEditable(params);
61
62
  return params;
62
- }, [apiRef]);
63
+ }, [apiRef, props.unstable_listView]);
63
64
  const getCellValue = React.useCallback((id, field) => {
64
65
  const colDef = apiRef.current.getColumn(field);
65
66
  const row = apiRef.current.getRow(id);
@@ -202,7 +202,7 @@ export const useGridRowSpanning = (apiRef, props) => {
202
202
  }
203
203
  const rangeToProcess = getUnprocessedRange({
204
204
  firstRowIndex: renderContext.firstRowIndex,
205
- lastRowIndex: renderContext.lastRowIndex - 1
205
+ lastRowIndex: Math.min(renderContext.lastRowIndex - 1, range.lastRowIndex)
206
206
  }, processedRange.current);
207
207
  if (rangeToProcess === null) {
208
208
  return;