@mui/x-data-grid-pro 5.6.0 → 5.6.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 (55) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/DataGridPro/DataGridPro.js +18 -4
  3. package/DataGridPro/useDataGridProComponent.js +20 -10
  4. package/DataGridPro/useDataGridProProps.js +2 -2
  5. package/components/DataGridProVirtualScroller.js +6 -17
  6. package/components/GridDetailPanelToggleCell.js +2 -1
  7. package/components/GridTreeDataGroupingCell.js +2 -1
  8. package/components/index.d.ts +1 -0
  9. package/components/index.js +2 -1
  10. package/hooks/features/columnReorder/useGridColumnReorder.d.ts +2 -0
  11. package/hooks/features/columnReorder/useGridColumnReorder.js +6 -7
  12. package/hooks/features/columnResize/useGridColumnResize.d.ts +2 -0
  13. package/hooks/features/columnResize/useGridColumnResize.js +7 -7
  14. package/hooks/features/detailPanel/useGridDetailPanel.d.ts +2 -0
  15. package/hooks/features/detailPanel/useGridDetailPanel.js +9 -9
  16. package/hooks/features/infiniteLoader/useGridInfiniteLoader.js +2 -2
  17. package/index.d.ts +1 -0
  18. package/index.js +2 -1
  19. package/legacy/DataGridPro/DataGridPro.js +18 -4
  20. package/legacy/DataGridPro/useDataGridProComponent.js +20 -10
  21. package/legacy/DataGridPro/useDataGridProProps.js +7 -2
  22. package/legacy/components/DataGridProVirtualScroller.js +6 -16
  23. package/legacy/components/GridDetailPanelToggleCell.js +2 -1
  24. package/legacy/components/GridTreeDataGroupingCell.js +2 -1
  25. package/legacy/components/index.js +2 -1
  26. package/legacy/hooks/features/columnReorder/useGridColumnReorder.js +8 -9
  27. package/legacy/hooks/features/columnResize/useGridColumnResize.js +9 -9
  28. package/legacy/hooks/features/detailPanel/useGridDetailPanel.js +9 -9
  29. package/legacy/hooks/features/infiniteLoader/useGridInfiniteLoader.js +2 -2
  30. package/legacy/index.js +2 -1
  31. package/modern/DataGridPro/DataGridPro.js +18 -4
  32. package/modern/DataGridPro/useDataGridProComponent.js +20 -10
  33. package/modern/DataGridPro/useDataGridProProps.js +2 -2
  34. package/modern/components/DataGridProVirtualScroller.js +6 -17
  35. package/modern/components/GridDetailPanelToggleCell.js +2 -1
  36. package/modern/components/GridTreeDataGroupingCell.js +2 -1
  37. package/modern/components/index.js +2 -1
  38. package/modern/hooks/features/columnReorder/useGridColumnReorder.js +6 -7
  39. package/modern/hooks/features/columnResize/useGridColumnResize.js +7 -7
  40. package/modern/hooks/features/detailPanel/useGridDetailPanel.js +8 -8
  41. package/modern/hooks/features/infiniteLoader/useGridInfiniteLoader.js +2 -2
  42. package/modern/index.js +2 -1
  43. package/node/DataGridPro/DataGridPro.js +18 -4
  44. package/node/DataGridPro/useDataGridProComponent.js +16 -6
  45. package/node/DataGridPro/useDataGridProProps.js +2 -2
  46. package/node/components/DataGridProVirtualScroller.js +5 -16
  47. package/node/components/GridDetailPanelToggleCell.js +2 -1
  48. package/node/components/GridTreeDataGroupingCell.js +2 -1
  49. package/node/components/index.js +13 -0
  50. package/node/hooks/features/columnReorder/useGridColumnReorder.js +9 -8
  51. package/node/hooks/features/columnResize/useGridColumnResize.js +9 -6
  52. package/node/hooks/features/detailPanel/useGridDetailPanel.js +12 -9
  53. package/node/hooks/features/infiniteLoader/useGridInfiniteLoader.js +1 -1
  54. package/node/index.js +15 -1
  55. package/package.json +5 -4
@@ -9,7 +9,7 @@ import { styled, alpha } from '@mui/material/styles';
9
9
  import Box from '@mui/material/Box';
10
10
  import { unstable_composeClasses as composeClasses } from '@mui/material';
11
11
  import { useGridSelector, getDataGridUtilityClass, gridClasses, gridVisibleColumnFieldsSelector, gridRowsMetaSelector, useGridApiEventHandler, GridEvents } from '@mui/x-data-grid';
12
- import { useCurrentPageRows, GridVirtualScroller, GridVirtualScrollerContent, GridVirtualScrollerRenderZone, useGridVirtualScroller } from '@mui/x-data-grid/internals';
12
+ import { GridVirtualScroller, GridVirtualScrollerContent, GridVirtualScrollerRenderZone, useGridVirtualScroller } from '@mui/x-data-grid/internals';
13
13
  import { useGridApiContext } from '../hooks/utils/useGridApiContext';
14
14
  import { useGridRootProps } from '../hooks/utils/useGridRootProps';
15
15
  import { gridPinnedColumnsSelector, GridPinnedPosition } from '../hooks/features/columnPinning';
@@ -126,7 +126,6 @@ var DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGrid
126
126
 
127
127
  var apiRef = useGridApiContext();
128
128
  var rootProps = useGridRootProps();
129
- var currentPage = useCurrentPageRows(apiRef, rootProps);
130
129
  var visibleColumnFields = useGridSelector(apiRef, gridVisibleColumnFieldsSelector);
131
130
  var expandedRowIds = useGridSelector(apiRef, gridDetailPanelExpandedRowIdsSelector);
132
131
  var detailPanelsContent = useGridSelector(apiRef, gridDetailPanelExpandedRowsContentCacheSelector);
@@ -208,17 +207,6 @@ var DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGrid
208
207
  var pinnedColumnsStyle = {
209
208
  minHeight: contentProps.style.minHeight
210
209
  };
211
- var rowsLookup = React.useMemo(function () {
212
- if (rootProps.getDetailPanelContent == null) {
213
- return null;
214
- }
215
-
216
- return currentPage.rows.reduce(function (acc, _ref6, index) {
217
- var id = _ref6.id;
218
- acc[id] = index;
219
- return acc;
220
- }, {});
221
- }, [currentPage.rows, rootProps.getDetailPanelContent]);
222
210
 
223
211
  var getDetailPanels = function getDetailPanels() {
224
212
  var panels = [];
@@ -234,12 +222,14 @@ var DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGrid
234
222
  var id = uniqueExpandedRowIds[i];
235
223
  var content = detailPanelsContent[id]; // Check if the id exists in the current page
236
224
 
237
- var exists = rowsLookup[id] !== undefined;
225
+ var rowIndex = apiRef.current.getRowIndexRelativeToVisibleRows(id);
226
+ var exists = rowIndex !== undefined;
238
227
 
239
228
  if ( /*#__PURE__*/React.isValidElement(content) && exists) {
240
229
  var height = detailPanelsHeights[id];
241
- var rowIndex = rowsLookup[id];
242
- var top = rowsMeta.positions[rowIndex] + apiRef.current.unstable_getRowHeight(id);
230
+ var sizes = apiRef.current.unstable_getRowInternalSizes(id);
231
+ var spacingTop = (sizes == null ? void 0 : sizes.spacingTop) || 0;
232
+ var top = rowsMeta.positions[rowIndex] + apiRef.current.unstable_getRowHeight(id) + spacingTop;
243
233
  panels.push( /*#__PURE__*/_jsx(VirtualScrollerDetailPanel, {
244
234
  style: {
245
235
  top: top,
@@ -50,8 +50,9 @@ process.env.NODE_ENV !== "production" ? GridDetailPanelToggleCell.propTypes = {
50
50
 
51
51
  /**
52
52
  * GridApi that let you manipulate the grid.
53
+ * @deprecated Use the `apiRef` returned by `useGridApiContext` or `useGridApiRef` (only available in `@mui/x-data-grid-pro`)
53
54
  */
54
- api: PropTypes.object.isRequired,
55
+ api: PropTypes.any.isRequired,
55
56
 
56
57
  /**
57
58
  * The mode of the cell.
@@ -84,8 +84,9 @@ process.env.NODE_ENV !== "production" ? GridTreeDataGroupingCell.propTypes = {
84
84
 
85
85
  /**
86
86
  * GridApi that let you manipulate the grid.
87
+ * @deprecated Use the `apiRef` returned by `useGridApiContext` or `useGridApiRef` (only available in `@mui/x-data-grid-pro`)
87
88
  */
88
- api: PropTypes.object.isRequired,
89
+ api: PropTypes.any.isRequired,
89
90
 
90
91
  /**
91
92
  * The mode of the cell.
@@ -1,3 +1,4 @@
1
1
  // Only export the variable and types that should be publicly exposed and re-exported from `@mui/x-data-grid-pro`
2
2
  export * from './GridTreeDataGroupingCell';
3
- export * from './GridColumnPinningMenuItems';
3
+ export * from './GridColumnPinningMenuItems';
4
+ export * from './GridDetailPanelToggleCell';
@@ -2,7 +2,6 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { unstable_composeClasses as composeClasses } from '@mui/material';
4
4
  import { useGridApiEventHandler, getDataGridUtilityClass, GridEvents, useGridLogger } from '@mui/x-data-grid';
5
- import { useGridStateInit } from '@mui/x-data-grid/internals';
6
5
  import { gridColumnReorderDragColSelector } from './columnReorderSelector';
7
6
  var CURSOR_MOVE_DIRECTION_LEFT = 'left';
8
7
  var CURSOR_MOVE_DIRECTION_RIGHT = 'right';
@@ -22,21 +21,21 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
22
21
  };
23
22
  return composeClasses(slots, getDataGridUtilityClass, classes);
24
23
  };
24
+
25
+ export var columnReorderStateInitializer = function columnReorderStateInitializer(state) {
26
+ return _extends({}, state, {
27
+ columnReorder: {
28
+ dragCol: ''
29
+ }
30
+ });
31
+ };
25
32
  /**
26
33
  * Only available in DataGridPro
27
34
  * @requires useGridColumns (method)
28
35
  */
29
36
 
30
-
31
37
  export var useGridColumnReorder = function useGridColumnReorder(apiRef, props) {
32
38
  var logger = useGridLogger(apiRef, 'useGridColumnReorder');
33
- useGridStateInit(apiRef, function (state) {
34
- return _extends({}, state, {
35
- columnReorder: {
36
- dragCol: ''
37
- }
38
- });
39
- });
40
39
  var dragColNode = React.useRef(null);
41
40
  var cursorPosition = React.useRef({
42
41
  x: 0,
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { ownerDocument, useEventCallback } from '@mui/material/utils';
4
4
  import { GridEvents, gridClasses, GridColumnHeaderSeparatorSides, useGridApiEventHandler, useGridApiOptionHandler, useGridNativeEventListener, useGridLogger } from '@mui/x-data-grid';
5
- import { useGridStateInit, clamp, findParentElementFromClassName } from '@mui/x-data-grid/internals';
5
+ import { clamp, findParentElementFromClassName } from '@mui/x-data-grid/internals';
6
6
  import { findGridCellElementsFromCol, getFieldFromHeaderElem, findHeaderElementFromField } from '../../../utils/domUtils';
7
7
  // TODO: remove support for Safari < 13.
8
8
  // https://caniuse.com/#search=touch-action
@@ -73,22 +73,22 @@ function computeOffsetToSeparator(clickX, columnBounds, separatorSide) {
73
73
  function getSeparatorSide(element) {
74
74
  return element.classList.contains(gridClasses['columnSeparator--sideRight']) ? GridColumnHeaderSeparatorSides.Right : GridColumnHeaderSeparatorSides.Left;
75
75
  }
76
+
77
+ export var columnResizeStateInitializer = function columnResizeStateInitializer(state) {
78
+ return _extends({}, state, {
79
+ columnResize: {
80
+ resizingColumnField: ''
81
+ }
82
+ });
83
+ };
76
84
  /**
77
85
  * Only available in DataGridPro
78
86
  * @requires useGridColumns (method, event)
79
87
  * TODO: improve experience for last column
80
88
  */
81
89
 
82
-
83
90
  export var useGridColumnResize = function useGridColumnResize(apiRef, props) {
84
91
  var logger = useGridLogger(apiRef, 'useGridColumnResize');
85
- useGridStateInit(apiRef, function (state) {
86
- return _extends({}, state, {
87
- columnResize: {
88
- resizingColumnField: ''
89
- }
90
- });
91
- });
92
92
  var colDefRef = React.useRef();
93
93
  var colElementRef = React.useRef();
94
94
  var colCellElementsRef = React.useRef(); // To improve accessibility, the separator has padding on both sides.
@@ -2,19 +2,19 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  import * as React from 'react';
4
4
  import { GridEvents, useGridSelector, useGridApiEventHandler, useGridApiMethod } from '@mui/x-data-grid';
5
- import { useGridStateInit, useGridRegisterPreProcessor } from '@mui/x-data-grid/internals';
5
+ import { useGridRegisterPreProcessor } from '@mui/x-data-grid/internals';
6
6
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from './gridDetailPanelToggleColDef';
7
7
  import { gridDetailPanelExpandedRowIdsSelector, gridDetailPanelExpandedRowsContentCacheSelector, gridDetailPanelExpandedRowsHeightCacheSelector } from './gridDetailPanelSelector';
8
- export var useGridDetailPanel = function useGridDetailPanel(apiRef, props) {
9
- useGridStateInit(apiRef, function (state) {
10
- var _ref, _props$detailPanelExp, _props$initialState, _props$initialState$d;
8
+ export var detailPanelStateInitializer = function detailPanelStateInitializer(state, props) {
9
+ var _ref, _props$detailPanelExp, _props$initialState, _props$initialState$d;
11
10
 
12
- return _extends({}, state, {
13
- detailPanel: {
14
- expandedRowIds: (_ref = (_props$detailPanelExp = props.detailPanelExpandedRowIds) != null ? _props$detailPanelExp : (_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$d = _props$initialState.detailPanel) == null ? void 0 : _props$initialState$d.expandedRowIds) != null ? _ref : []
15
- }
16
- });
11
+ return _extends({}, state, {
12
+ detailPanel: {
13
+ expandedRowIds: (_ref = (_props$detailPanelExp = props.detailPanelExpandedRowIds) != null ? _props$detailPanelExp : (_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$d = _props$initialState.detailPanel) == null ? void 0 : _props$initialState$d.expandedRowIds) != null ? _ref : []
14
+ }
17
15
  });
16
+ };
17
+ export var useGridDetailPanel = function useGridDetailPanel(apiRef, props) {
18
18
  var expandedRowIds = useGridSelector(apiRef, gridDetailPanelExpandedRowIdsSelector);
19
19
  var contentCache = useGridSelector(apiRef, gridDetailPanelExpandedRowsContentCacheSelector);
20
20
  var handleCellClick = React.useCallback(function (params, event) {
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { useGridSelector, GridEvents, useGridApiEventHandler, useGridApiOptionHandler, gridVisibleColumnDefinitionsSelector, gridRowsMetaSelector } from '@mui/x-data-grid';
3
- import { useCurrentPageRows } from '@mui/x-data-grid/internals';
3
+ import { useGridVisibleRows } from '@mui/x-data-grid/internals';
4
4
 
5
5
  /**
6
6
  * Only available in DataGridPro
@@ -10,7 +10,7 @@ import { useCurrentPageRows } from '@mui/x-data-grid/internals';
10
10
  */
11
11
  export var useGridInfiniteLoader = function useGridInfiniteLoader(apiRef, props) {
12
12
  var visibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
13
- var currentPage = useCurrentPageRows(apiRef, props);
13
+ var currentPage = useGridVisibleRows(apiRef, props);
14
14
  var rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
15
15
  var contentHeight = Math.max(rowsMeta.currentPageTotalHeight, 1);
16
16
  var isInScrollBottomArea = React.useRef(false);
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.6.0
1
+ /** @license MUI v5.6.1
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -16,4 +16,5 @@ export * from '@mui/x-data-grid/utils';
16
16
  export * from './DataGridPro';
17
17
  export * from './hooks';
18
18
  export * from './models';
19
+ export * from './components';
19
20
  export { useGridApiContext, useGridApiRef, useGridRootProps } from './typeOverloads/reexports';
@@ -12,7 +12,7 @@ import { DataGridProColumnHeaders } from '../components/DataGridProColumnHeaders
12
12
 
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
15
- let RELEASE_INFO = "MTY0NjM0ODQwMDAwMA=="; // eslint-disable-next-line no-useless-concat
15
+ let RELEASE_INFO = "MTY0Njg2NjgwMDAwMA=="; // eslint-disable-next-line no-useless-concat
16
16
 
17
17
  if (process.env.NODE_ENV !== 'production' && RELEASE_INFO === '__RELEASE' + '_INFO__') {
18
18
  // eslint-disable-next-line no-underscore-dangle
@@ -275,7 +275,8 @@ DataGridProRaw.propTypes = {
275
275
  */
276
276
  experimentalFeatures: PropTypes.shape({
277
277
  preventCommitWhileValidating: PropTypes.bool,
278
- rowGrouping: PropTypes.bool
278
+ rowGrouping: PropTypes.bool,
279
+ warnIfFocusStateIsNotSynced: PropTypes.bool
279
280
  }),
280
281
 
281
282
  /**
@@ -328,7 +329,7 @@ DataGridProRaw.propTypes = {
328
329
 
329
330
  /**
330
331
  * Function that applies CSS classes dynamically on rows.
331
- * @param {GridRowParams} params With all properties from [[GridRowParams]].
332
+ * @param {GridRowClassNameParams} params With all properties from [[GridRowClassNameParams]].
332
333
  * @returns {string} The CSS class to apply to the row.
333
334
  */
334
335
  getRowClassName: PropTypes.func,
@@ -345,6 +346,13 @@ DataGridProRaw.propTypes = {
345
346
  */
346
347
  getRowId: PropTypes.func,
347
348
 
349
+ /**
350
+ * Function that allows to specify the spacing between rows.
351
+ * @param {GridRowSpacingParams} params With all properties from [[GridRowSpacingParams]].
352
+ * @returns {GridRowSpacing} The row spacing values.
353
+ */
354
+ getRowSpacing: PropTypes.func,
355
+
348
356
  /**
349
357
  * Determines the path of a row in the tree data.
350
358
  * For instance, a row with the path ["A", "B"] is the child of the row with the path ["A"].
@@ -432,7 +440,7 @@ DataGridProRaw.propTypes = {
432
440
 
433
441
  /**
434
442
  * Set the locale text of the grid.
435
- * You can find all the translation keys supported in [the source](https://github.com/mui/mui-x/blob/HEAD/packages/grid/x-data-grid/src/internals/constants/localeTextConstants.ts) in the GitHub repository.
443
+ * You can find all the translation keys supported in [the source](https://github.com/mui/mui-x/blob/HEAD/packages/grid/x-data-grid/src/constants/localeTextConstants.ts) in the GitHub repository.
436
444
  */
437
445
  localeText: PropTypes.object,
438
446
 
@@ -814,6 +822,12 @@ DataGridProRaw.propTypes = {
814
822
  */
815
823
  rows: PropTypes.arrayOf(PropTypes.object).isRequired,
816
824
 
825
+ /**
826
+ * Sets the type of space between rows added by `getRowSpacing`.
827
+ * @default "margin"
828
+ */
829
+ rowSpacingType: PropTypes.oneOf(['border', 'margin']),
830
+
817
831
  /**
818
832
  * Select the pageSize dynamically using the component UI.
819
833
  * @default [25, 50, 100]
@@ -1,15 +1,15 @@
1
- import { useGridInitialization, useGridInitializeState, useGridClipboard, useGridColumnMenu, useGridColumns, columnsStateInitializer, useGridDensity, useGridCsvExport, useGridPrintExport, useGridFilter, filterStateInitializer, useGridFocus, useGridKeyboard, useGridKeyboardNavigation, useGridPagination, pageStateInitializer, pageSizeStateInitializer, useGridPreferencesPanel, useGridEditing, useGridRows, rowsStateInitializer, useGridRowsMeta, useGridParamsApi, useGridSelection, useGridSorting, sortingStateInitializer, useGridScroll, useGridEvents, useGridDimensions, useGridStatePersistence, useGridSelectionPreProcessors } from '@mui/x-data-grid/internals';
1
+ import { useGridInitialization, useGridInitializeState, useGridClipboard, useGridColumnMenu, useGridColumns, columnsStateInitializer, useGridDensity, useGridCsvExport, useGridPrintExport, useGridFilter, filterStateInitializer, useGridFocus, useGridKeyboard, useGridKeyboardNavigation, useGridPagination, paginationStateInitializer, useGridPreferencesPanel, useGridEditing, useGridRows, rowsStateInitializer, useGridRowsMeta, useGridParamsApi, useGridSelection, useGridSorting, sortingStateInitializer, useGridScroll, useGridEvents, useGridDimensions, useGridStatePersistence, useGridSelectionPreProcessors, columnMenuStateInitializer, densityStateInitializer, editingStateInitializer, focusStateInitializer, preferencePanelStateInitializer, rowsMetaStateInitializer, selectionStateInitializer } from '@mui/x-data-grid/internals';
2
2
  // Pro-only features
3
3
  import { useGridInfiniteLoader } from '../hooks/features/infiniteLoader/useGridInfiniteLoader';
4
- import { useGridColumnReorder } from '../hooks/features/columnReorder/useGridColumnReorder';
5
- import { useGridColumnResize } from '../hooks/features/columnResize/useGridColumnResize';
4
+ import { useGridColumnReorder, columnReorderStateInitializer } from '../hooks/features/columnReorder/useGridColumnReorder';
5
+ import { useGridColumnResize, columnResizeStateInitializer } from '../hooks/features/columnResize/useGridColumnResize';
6
6
  import { useGridTreeData } from '../hooks/features/treeData/useGridTreeData';
7
7
  import { useGridTreeDataPreProcessors } from '../hooks/features/treeData/useGridTreeDataPreProcessors';
8
8
  import { useGridRowGrouping, rowGroupingStateInitializer } from '../hooks/features/rowGrouping/useGridRowGrouping';
9
9
  import { useGridRowGroupingPreProcessors } from '../hooks/features/rowGrouping/useGridRowGroupingPreProcessors';
10
10
  import { useGridColumnPinning, columnPinningStateInitializer } from '../hooks/features/columnPinning/useGridColumnPinning';
11
11
  import { useGridColumnPinningPreProcessors } from '../hooks/features/columnPinning/useGridColumnPinningPreProcessors';
12
- import { useGridDetailPanel } from '../hooks/features/detailPanel/useGridDetailPanel';
12
+ import { useGridDetailPanel, detailPanelStateInitializer } from '../hooks/features/detailPanel/useGridDetailPanel';
13
13
  import { useGridDetailPanelCache } from '../hooks/features/detailPanel/useGridDetailPanelCache';
14
14
  import { useGridDetailPanelPreProcessors } from '../hooks/features/detailPanel/useGridDetailPanelPreProcessors';
15
15
  export const useDataGridProComponent = (inputApiRef, props) => {
@@ -28,18 +28,28 @@ export const useDataGridProComponent = (inputApiRef, props) => {
28
28
  * Register all state initializers here.
29
29
  */
30
30
 
31
- useGridInitializeState(filterStateInitializer, apiRef, props);
32
- useGridInitializeState(pageSizeStateInitializer, apiRef, props);
33
- useGridInitializeState(pageStateInitializer, apiRef, props);
34
- useGridInitializeState(sortingStateInitializer, apiRef, props);
31
+ useGridInitializeState(selectionStateInitializer, apiRef, props);
32
+ useGridInitializeState(detailPanelStateInitializer, apiRef, props);
35
33
  useGridInitializeState(columnPinningStateInitializer, apiRef, props);
36
- useGridInitializeState(rowGroupingStateInitializer, apiRef, props);
34
+ useGridInitializeState(rowGroupingStateInitializer, apiRef, props); // FIXME Call in the same relative position that useGridRowGrouping is called
35
+
37
36
  useGridInitializeState(columnsStateInitializer, apiRef, props);
38
37
  useGridRowGrouping(apiRef, props); // FIXME Needs to be called before the rows state initialization because it registers a rows group builder
39
38
 
40
39
  useGridTreeData(apiRef, props); // FIXME Needs to be called before the rows state initialization because it registers a rows group builder
41
40
 
42
41
  useGridInitializeState(rowsStateInitializer, apiRef, props);
42
+ useGridInitializeState(editingStateInitializer, apiRef, props);
43
+ useGridInitializeState(focusStateInitializer, apiRef, props);
44
+ useGridInitializeState(sortingStateInitializer, apiRef, props);
45
+ useGridInitializeState(preferencePanelStateInitializer, apiRef, props);
46
+ useGridInitializeState(filterStateInitializer, apiRef, props);
47
+ useGridInitializeState(densityStateInitializer, apiRef, props);
48
+ useGridInitializeState(columnReorderStateInitializer, apiRef, props);
49
+ useGridInitializeState(columnResizeStateInitializer, apiRef, props);
50
+ useGridInitializeState(paginationStateInitializer, apiRef, props);
51
+ useGridInitializeState(rowsMetaStateInitializer, apiRef, props);
52
+ useGridInitializeState(columnMenuStateInitializer, apiRef, props);
43
53
  useGridSelection(apiRef, props);
44
54
  useGridDetailPanel(apiRef, props);
45
55
  useGridColumnPinning(apiRef, props);
@@ -50,7 +60,7 @@ export const useDataGridProComponent = (inputApiRef, props) => {
50
60
  useGridEditing(apiRef, props);
51
61
  useGridFocus(apiRef, props);
52
62
  useGridSorting(apiRef, props);
53
- useGridPreferencesPanel(apiRef, props);
63
+ useGridPreferencesPanel(apiRef);
54
64
  useGridFilter(apiRef, props);
55
65
  useGridDensity(apiRef, props);
56
66
  useGridColumnReorder(apiRef, props);
@@ -31,8 +31,8 @@ export const useDataGridProProps = inProps => {
31
31
  }
32
32
 
33
33
  const mergedComponents = {};
34
- Object.keys(DATA_GRID_DEFAULT_SLOTS_COMPONENTS).forEach(key => {
35
- mergedComponents[key] = overrides[key] === undefined ? DATA_GRID_DEFAULT_SLOTS_COMPONENTS[key] : overrides[key];
34
+ Object.entries(DATA_GRID_DEFAULT_SLOTS_COMPONENTS).forEach(([key, defaultComponent]) => {
35
+ mergedComponents[key] = overrides[key] === undefined ? defaultComponent : overrides[key];
36
36
  });
37
37
  return mergedComponents;
38
38
  }, [themedProps.components]);
@@ -6,7 +6,7 @@ import { styled, alpha } from '@mui/material/styles';
6
6
  import Box from '@mui/material/Box';
7
7
  import { unstable_composeClasses as composeClasses } from '@mui/material';
8
8
  import { useGridSelector, getDataGridUtilityClass, gridClasses, gridVisibleColumnFieldsSelector, gridRowsMetaSelector, useGridApiEventHandler, GridEvents } from '@mui/x-data-grid';
9
- import { useCurrentPageRows, GridVirtualScroller, GridVirtualScrollerContent, GridVirtualScrollerRenderZone, useGridVirtualScroller } from '@mui/x-data-grid/internals';
9
+ import { GridVirtualScroller, GridVirtualScrollerContent, GridVirtualScrollerRenderZone, useGridVirtualScroller } from '@mui/x-data-grid/internals';
10
10
  import { useGridApiContext } from '../hooks/utils/useGridApiContext';
11
11
  import { useGridRootProps } from '../hooks/utils/useGridRootProps';
12
12
  import { gridPinnedColumnsSelector, GridPinnedPosition } from '../hooks/features/columnPinning';
@@ -113,7 +113,6 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
113
113
 
114
114
  const apiRef = useGridApiContext();
115
115
  const rootProps = useGridRootProps();
116
- const currentPage = useCurrentPageRows(apiRef, rootProps);
117
116
  const visibleColumnFields = useGridSelector(apiRef, gridVisibleColumnFieldsSelector);
118
117
  const expandedRowIds = useGridSelector(apiRef, gridDetailPanelExpandedRowIdsSelector);
119
118
  const detailPanelsContent = useGridSelector(apiRef, gridDetailPanelExpandedRowsContentCacheSelector);
@@ -189,18 +188,6 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
189
188
  const pinnedColumnsStyle = {
190
189
  minHeight: contentProps.style.minHeight
191
190
  };
192
- const rowsLookup = React.useMemo(() => {
193
- if (rootProps.getDetailPanelContent == null) {
194
- return null;
195
- }
196
-
197
- return currentPage.rows.reduce((acc, {
198
- id
199
- }, index) => {
200
- acc[id] = index;
201
- return acc;
202
- }, {});
203
- }, [currentPage.rows, rootProps.getDetailPanelContent]);
204
191
 
205
192
  const getDetailPanels = () => {
206
193
  const panels = [];
@@ -216,12 +203,14 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
216
203
  const id = uniqueExpandedRowIds[i];
217
204
  const content = detailPanelsContent[id]; // Check if the id exists in the current page
218
205
 
219
- const exists = rowsLookup[id] !== undefined;
206
+ const rowIndex = apiRef.current.getRowIndexRelativeToVisibleRows(id);
207
+ const exists = rowIndex !== undefined;
220
208
 
221
209
  if ( /*#__PURE__*/React.isValidElement(content) && exists) {
222
210
  const height = detailPanelsHeights[id];
223
- const rowIndex = rowsLookup[id];
224
- const top = rowsMeta.positions[rowIndex] + apiRef.current.unstable_getRowHeight(id);
211
+ const sizes = apiRef.current.unstable_getRowInternalSizes(id);
212
+ const spacingTop = sizes?.spacingTop || 0;
213
+ const top = rowsMeta.positions[rowIndex] + apiRef.current.unstable_getRowHeight(id) + spacingTop;
225
214
  panels.push( /*#__PURE__*/_jsx(VirtualScrollerDetailPanel, {
226
215
  style: {
227
216
  top,
@@ -54,8 +54,9 @@ process.env.NODE_ENV !== "production" ? GridDetailPanelToggleCell.propTypes = {
54
54
 
55
55
  /**
56
56
  * GridApi that let you manipulate the grid.
57
+ * @deprecated Use the `apiRef` returned by `useGridApiContext` or `useGridApiRef` (only available in `@mui/x-data-grid-pro`)
57
58
  */
58
- api: PropTypes.object.isRequired,
59
+ api: PropTypes.any.isRequired,
59
60
 
60
61
  /**
61
62
  * The mode of the cell.
@@ -86,8 +86,9 @@ process.env.NODE_ENV !== "production" ? GridTreeDataGroupingCell.propTypes = {
86
86
 
87
87
  /**
88
88
  * GridApi that let you manipulate the grid.
89
+ * @deprecated Use the `apiRef` returned by `useGridApiContext` or `useGridApiRef` (only available in `@mui/x-data-grid-pro`)
89
90
  */
90
- api: PropTypes.object.isRequired,
91
+ api: PropTypes.any.isRequired,
91
92
 
92
93
  /**
93
94
  * The mode of the cell.
@@ -1,3 +1,4 @@
1
1
  // Only export the variable and types that should be publicly exposed and re-exported from `@mui/x-data-grid-pro`
2
2
  export * from './GridTreeDataGroupingCell';
3
- export * from './GridColumnPinningMenuItems';
3
+ export * from './GridColumnPinningMenuItems';
4
+ export * from './GridDetailPanelToggleCell';
@@ -2,7 +2,6 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { unstable_composeClasses as composeClasses } from '@mui/material';
4
4
  import { useGridApiEventHandler, getDataGridUtilityClass, GridEvents, useGridLogger } from '@mui/x-data-grid';
5
- import { useGridStateInit } from '@mui/x-data-grid/internals';
6
5
  import { gridColumnReorderDragColSelector } from './columnReorderSelector';
7
6
  const CURSOR_MOVE_DIRECTION_LEFT = 'left';
8
7
  const CURSOR_MOVE_DIRECTION_RIGHT = 'right';
@@ -22,19 +21,19 @@ const useUtilityClasses = ownerState => {
22
21
  };
23
22
  return composeClasses(slots, getDataGridUtilityClass, classes);
24
23
  };
24
+
25
+ export const columnReorderStateInitializer = state => _extends({}, state, {
26
+ columnReorder: {
27
+ dragCol: ''
28
+ }
29
+ });
25
30
  /**
26
31
  * Only available in DataGridPro
27
32
  * @requires useGridColumns (method)
28
33
  */
29
34
 
30
-
31
35
  export const useGridColumnReorder = (apiRef, props) => {
32
36
  const logger = useGridLogger(apiRef, 'useGridColumnReorder');
33
- useGridStateInit(apiRef, state => _extends({}, state, {
34
- columnReorder: {
35
- dragCol: ''
36
- }
37
- }));
38
37
  const dragColNode = React.useRef(null);
39
38
  const cursorPosition = React.useRef({
40
39
  x: 0,
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { ownerDocument, useEventCallback } from '@mui/material/utils';
4
4
  import { GridEvents, gridClasses, GridColumnHeaderSeparatorSides, useGridApiEventHandler, useGridApiOptionHandler, useGridNativeEventListener, useGridLogger } from '@mui/x-data-grid';
5
- import { useGridStateInit, clamp, findParentElementFromClassName } from '@mui/x-data-grid/internals';
5
+ import { clamp, findParentElementFromClassName } from '@mui/x-data-grid/internals';
6
6
  import { findGridCellElementsFromCol, getFieldFromHeaderElem, findHeaderElementFromField } from '../../../utils/domUtils';
7
7
  // TODO: remove support for Safari < 13.
8
8
  // https://caniuse.com/#search=touch-action
@@ -73,20 +73,20 @@ function computeOffsetToSeparator(clickX, columnBounds, separatorSide) {
73
73
  function getSeparatorSide(element) {
74
74
  return element.classList.contains(gridClasses['columnSeparator--sideRight']) ? GridColumnHeaderSeparatorSides.Right : GridColumnHeaderSeparatorSides.Left;
75
75
  }
76
+
77
+ export const columnResizeStateInitializer = state => _extends({}, state, {
78
+ columnResize: {
79
+ resizingColumnField: ''
80
+ }
81
+ });
76
82
  /**
77
83
  * Only available in DataGridPro
78
84
  * @requires useGridColumns (method, event)
79
85
  * TODO: improve experience for last column
80
86
  */
81
87
 
82
-
83
88
  export const useGridColumnResize = (apiRef, props) => {
84
89
  const logger = useGridLogger(apiRef, 'useGridColumnResize');
85
- useGridStateInit(apiRef, state => _extends({}, state, {
86
- columnResize: {
87
- resizingColumnField: ''
88
- }
89
- }));
90
90
  const colDefRef = React.useRef();
91
91
  const colElementRef = React.useRef();
92
92
  const colCellElementsRef = React.useRef(); // To improve accessibility, the separator has padding on both sides.
@@ -1,17 +1,17 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { GridEvents, useGridSelector, useGridApiEventHandler, useGridApiMethod } from '@mui/x-data-grid';
4
- import { useGridStateInit, useGridRegisterPreProcessor } from '@mui/x-data-grid/internals';
4
+ import { useGridRegisterPreProcessor } from '@mui/x-data-grid/internals';
5
5
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from './gridDetailPanelToggleColDef';
6
6
  import { gridDetailPanelExpandedRowIdsSelector, gridDetailPanelExpandedRowsContentCacheSelector, gridDetailPanelExpandedRowsHeightCacheSelector } from './gridDetailPanelSelector';
7
- export const useGridDetailPanel = (apiRef, props) => {
8
- useGridStateInit(apiRef, state => {
9
- return _extends({}, state, {
10
- detailPanel: {
11
- expandedRowIds: props.detailPanelExpandedRowIds ?? props.initialState?.detailPanel?.expandedRowIds ?? []
12
- }
13
- });
7
+ export const detailPanelStateInitializer = (state, props) => {
8
+ return _extends({}, state, {
9
+ detailPanel: {
10
+ expandedRowIds: props.detailPanelExpandedRowIds ?? props.initialState?.detailPanel?.expandedRowIds ?? []
11
+ }
14
12
  });
13
+ };
14
+ export const useGridDetailPanel = (apiRef, props) => {
15
15
  const expandedRowIds = useGridSelector(apiRef, gridDetailPanelExpandedRowIdsSelector);
16
16
  const contentCache = useGridSelector(apiRef, gridDetailPanelExpandedRowsContentCacheSelector);
17
17
  const handleCellClick = React.useCallback((params, event) => {
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { useGridSelector, GridEvents, useGridApiEventHandler, useGridApiOptionHandler, gridVisibleColumnDefinitionsSelector, gridRowsMetaSelector } from '@mui/x-data-grid';
3
- import { useCurrentPageRows } from '@mui/x-data-grid/internals';
3
+ import { useGridVisibleRows } from '@mui/x-data-grid/internals';
4
4
 
5
5
  /**
6
6
  * Only available in DataGridPro
@@ -10,7 +10,7 @@ import { useCurrentPageRows } from '@mui/x-data-grid/internals';
10
10
  */
11
11
  export const useGridInfiniteLoader = (apiRef, props) => {
12
12
  const visibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
13
- const currentPage = useCurrentPageRows(apiRef, props);
13
+ const currentPage = useGridVisibleRows(apiRef, props);
14
14
  const rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
15
15
  const contentHeight = Math.max(rowsMeta.currentPageTotalHeight, 1);
16
16
  const isInScrollBottomArea = React.useRef(false);
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.6.0
1
+ /** @license MUI v5.6.1
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -16,4 +16,5 @@ export * from '@mui/x-data-grid/utils';
16
16
  export * from './DataGridPro';
17
17
  export * from './hooks';
18
18
  export * from './models';
19
+ export * from './components';
19
20
  export { useGridApiContext, useGridApiRef, useGridRootProps } from './typeOverloads/reexports';
@@ -35,7 +35,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
35
35
 
36
36
  // This is the package release date. Each package version should update this const
37
37
  // automatically when a new version is published on npm.
38
- let RELEASE_INFO = "MTY0NjM0ODQwMDAwMA=="; // eslint-disable-next-line no-useless-concat
38
+ let RELEASE_INFO = "MTY0Njg2NjgwMDAwMA=="; // eslint-disable-next-line no-useless-concat
39
39
 
40
40
  if (process.env.NODE_ENV !== 'production' && RELEASE_INFO === '__RELEASE' + '_INFO__') {
41
41
  // eslint-disable-next-line no-underscore-dangle
@@ -300,7 +300,8 @@ DataGridProRaw.propTypes = {
300
300
  */
301
301
  experimentalFeatures: _propTypes.default.shape({
302
302
  preventCommitWhileValidating: _propTypes.default.bool,
303
- rowGrouping: _propTypes.default.bool
303
+ rowGrouping: _propTypes.default.bool,
304
+ warnIfFocusStateIsNotSynced: _propTypes.default.bool
304
305
  }),
305
306
 
306
307
  /**
@@ -353,7 +354,7 @@ DataGridProRaw.propTypes = {
353
354
 
354
355
  /**
355
356
  * Function that applies CSS classes dynamically on rows.
356
- * @param {GridRowParams} params With all properties from [[GridRowParams]].
357
+ * @param {GridRowClassNameParams} params With all properties from [[GridRowClassNameParams]].
357
358
  * @returns {string} The CSS class to apply to the row.
358
359
  */
359
360
  getRowClassName: _propTypes.default.func,
@@ -370,6 +371,13 @@ DataGridProRaw.propTypes = {
370
371
  */
371
372
  getRowId: _propTypes.default.func,
372
373
 
374
+ /**
375
+ * Function that allows to specify the spacing between rows.
376
+ * @param {GridRowSpacingParams} params With all properties from [[GridRowSpacingParams]].
377
+ * @returns {GridRowSpacing} The row spacing values.
378
+ */
379
+ getRowSpacing: _propTypes.default.func,
380
+
373
381
  /**
374
382
  * Determines the path of a row in the tree data.
375
383
  * For instance, a row with the path ["A", "B"] is the child of the row with the path ["A"].
@@ -457,7 +465,7 @@ DataGridProRaw.propTypes = {
457
465
 
458
466
  /**
459
467
  * Set the locale text of the grid.
460
- * You can find all the translation keys supported in [the source](https://github.com/mui/mui-x/blob/HEAD/packages/grid/x-data-grid/src/internals/constants/localeTextConstants.ts) in the GitHub repository.
468
+ * You can find all the translation keys supported in [the source](https://github.com/mui/mui-x/blob/HEAD/packages/grid/x-data-grid/src/constants/localeTextConstants.ts) in the GitHub repository.
461
469
  */
462
470
  localeText: _propTypes.default.object,
463
471
 
@@ -839,6 +847,12 @@ DataGridProRaw.propTypes = {
839
847
  */
840
848
  rows: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
841
849
 
850
+ /**
851
+ * Sets the type of space between rows added by `getRowSpacing`.
852
+ * @default "margin"
853
+ */
854
+ rowSpacingType: _propTypes.default.oneOf(['border', 'margin']),
855
+
842
856
  /**
843
857
  * Select the pageSize dynamically using the component UI.
844
858
  * @default [25, 50, 100]