@mui/x-data-grid 7.12.1 → 7.14.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 (157) hide show
  1. package/CHANGELOG.md +162 -1
  2. package/DataGrid/DataGrid.js +10 -1
  3. package/components/GridColumnHeaders.js +1 -1
  4. package/components/GridConfigurationContext.d.ts +2 -0
  5. package/components/GridConfigurationContext.js +5 -0
  6. package/components/GridHeaders.js +1 -1
  7. package/components/GridRow.js +6 -8
  8. package/components/GridScrollArea.js +1 -1
  9. package/components/GridSkeletonLoadingOverlay.js +1 -1
  10. package/components/cell/GridCell.js +12 -13
  11. package/components/cell/GridEditSingleSelectCell.js +2 -3
  12. package/components/cell/GridSkeletonCell.js +2 -2
  13. package/components/columnHeaders/GridColumnHeaderItem.js +1 -1
  14. package/components/containers/GridRootStyles.js +9 -2
  15. package/components/menu/columnMenu/GridColumnMenuContainer.js +2 -2
  16. package/components/panel/GridPanel.js +1 -2
  17. package/components/panel/filterPanel/GridFilterForm.js +9 -4
  18. package/components/toolbar/GridToolbarDensitySelector.js +2 -2
  19. package/components/toolbar/GridToolbarExportContainer.js +2 -2
  20. package/components/toolbar/GridToolbarQuickFilter.js +5 -3
  21. package/components/virtualization/GridMainContainer.js +3 -2
  22. package/components/virtualization/GridVirtualScrollerFiller.js +1 -1
  23. package/context/GridContextProvider.d.ts +3 -1
  24. package/context/GridContextProvider.js +12 -7
  25. package/hooks/core/useGridStateInitialization.js +1 -3
  26. package/hooks/features/dimensions/useGridDimensions.js +1 -1
  27. package/hooks/features/export/serializers/csvSerializer.js +4 -3
  28. package/hooks/features/filter/gridFilterSelector.d.ts +20 -7
  29. package/hooks/features/filter/gridFilterSelector.js +34 -0
  30. package/hooks/features/filter/gridFilterState.d.ts +6 -0
  31. package/hooks/features/filter/index.d.ts +2 -1
  32. package/hooks/features/filter/index.js +1 -1
  33. package/hooks/features/filter/useGridFilter.js +3 -0
  34. package/hooks/features/rowSelection/useGridRowSelection.js +4 -1
  35. package/hooks/features/rows/useGridParamsApi.js +2 -1
  36. package/hooks/features/rows/useGridRowAriaAttributes.d.ts +2 -0
  37. package/hooks/features/rows/useGridRowAriaAttributes.js +19 -0
  38. package/hooks/utils/useGridAriaAttributes.d.ts +2 -6
  39. package/hooks/utils/useGridAriaAttributes.js +5 -8
  40. package/hooks/utils/useGridConfiguration.d.ts +2 -0
  41. package/hooks/utils/useGridConfiguration.js +9 -0
  42. package/hooks/utils/useGridSelector.d.ts +5 -2
  43. package/hooks/utils/useGridSelector.js +39 -1
  44. package/index.js +1 -1
  45. package/internals/index.d.ts +5 -2
  46. package/internals/index.js +5 -2
  47. package/locales/csCZ.js +4 -5
  48. package/locales/heIL.js +4 -5
  49. package/locales/viVN.js +4 -5
  50. package/models/configuration/gridConfiguration.d.ts +10 -0
  51. package/models/configuration/gridConfiguration.js +1 -0
  52. package/models/configuration/gridRowConfiguration.d.ts +12 -0
  53. package/models/configuration/gridRowConfiguration.js +1 -0
  54. package/models/gridDataSource.d.ts +8 -7
  55. package/models/gridRows.d.ts +2 -2
  56. package/models/params/gridCellParams.d.ts +4 -0
  57. package/models/props/DataGridProps.d.ts +1 -1
  58. package/modern/DataGrid/DataGrid.js +10 -1
  59. package/modern/components/GridColumnHeaders.js +1 -1
  60. package/modern/components/GridConfigurationContext.js +5 -0
  61. package/modern/components/GridHeaders.js +1 -1
  62. package/modern/components/GridRow.js +6 -8
  63. package/modern/components/GridScrollArea.js +1 -1
  64. package/modern/components/GridSkeletonLoadingOverlay.js +1 -1
  65. package/modern/components/cell/GridCell.js +12 -13
  66. package/modern/components/cell/GridEditSingleSelectCell.js +2 -3
  67. package/modern/components/cell/GridSkeletonCell.js +2 -2
  68. package/modern/components/columnHeaders/GridColumnHeaderItem.js +1 -1
  69. package/modern/components/containers/GridRootStyles.js +9 -2
  70. package/modern/components/menu/columnMenu/GridColumnMenuContainer.js +2 -2
  71. package/modern/components/panel/GridPanel.js +1 -2
  72. package/modern/components/panel/filterPanel/GridFilterForm.js +9 -4
  73. package/modern/components/toolbar/GridToolbarDensitySelector.js +2 -2
  74. package/modern/components/toolbar/GridToolbarExportContainer.js +2 -2
  75. package/modern/components/toolbar/GridToolbarQuickFilter.js +5 -3
  76. package/modern/components/virtualization/GridMainContainer.js +3 -2
  77. package/modern/components/virtualization/GridVirtualScrollerFiller.js +1 -1
  78. package/modern/context/GridContextProvider.js +12 -7
  79. package/modern/hooks/core/useGridStateInitialization.js +1 -3
  80. package/modern/hooks/features/dimensions/useGridDimensions.js +1 -1
  81. package/modern/hooks/features/export/serializers/csvSerializer.js +4 -3
  82. package/modern/hooks/features/filter/gridFilterSelector.js +34 -0
  83. package/modern/hooks/features/filter/index.js +1 -1
  84. package/modern/hooks/features/filter/useGridFilter.js +3 -0
  85. package/modern/hooks/features/rowSelection/useGridRowSelection.js +4 -1
  86. package/modern/hooks/features/rows/useGridParamsApi.js +2 -1
  87. package/modern/hooks/features/rows/useGridRowAriaAttributes.js +19 -0
  88. package/modern/hooks/utils/useGridAriaAttributes.js +5 -8
  89. package/modern/hooks/utils/useGridConfiguration.js +9 -0
  90. package/modern/hooks/utils/useGridSelector.js +39 -1
  91. package/modern/index.js +1 -1
  92. package/modern/internals/index.js +5 -2
  93. package/modern/locales/csCZ.js +4 -5
  94. package/modern/locales/heIL.js +4 -5
  95. package/modern/locales/viVN.js +4 -5
  96. package/modern/models/configuration/gridConfiguration.js +1 -0
  97. package/modern/models/configuration/gridRowConfiguration.js +1 -0
  98. package/modern/utils/createSelector.js +116 -0
  99. package/modern/utils/keyboardUtils.js +1 -11
  100. package/node/DataGrid/DataGrid.js +10 -1
  101. package/node/components/GridColumnHeaders.js +1 -1
  102. package/node/{utils/fastMemo.js → components/GridConfigurationContext.js} +4 -4
  103. package/node/components/GridHeaders.js +1 -1
  104. package/node/components/GridRow.js +6 -8
  105. package/node/components/GridScrollArea.js +1 -1
  106. package/node/components/GridSkeletonLoadingOverlay.js +1 -1
  107. package/node/components/cell/GridCell.js +12 -13
  108. package/node/components/cell/GridEditSingleSelectCell.js +2 -3
  109. package/node/components/cell/GridSkeletonCell.js +2 -2
  110. package/node/components/columnHeaders/GridColumnHeaderItem.js +1 -1
  111. package/node/components/containers/GridRootStyles.js +9 -2
  112. package/node/components/menu/columnMenu/GridColumnMenuContainer.js +1 -1
  113. package/node/components/panel/GridPanel.js +1 -2
  114. package/node/components/panel/filterPanel/GridFilterForm.js +9 -4
  115. package/node/components/toolbar/GridToolbarDensitySelector.js +1 -1
  116. package/node/components/toolbar/GridToolbarExportContainer.js +1 -1
  117. package/node/components/toolbar/GridToolbarQuickFilter.js +5 -3
  118. package/node/components/virtualization/GridMainContainer.js +3 -2
  119. package/node/components/virtualization/GridVirtualScrollerFiller.js +1 -1
  120. package/node/context/GridContextProvider.js +12 -7
  121. package/node/hooks/core/useGridStateInitialization.js +1 -3
  122. package/node/hooks/features/dimensions/useGridDimensions.js +1 -1
  123. package/node/hooks/features/export/serializers/csvSerializer.js +4 -3
  124. package/node/hooks/features/filter/gridFilterSelector.js +35 -1
  125. package/node/hooks/features/filter/index.js +97 -15
  126. package/node/hooks/features/filter/useGridFilter.js +3 -0
  127. package/node/hooks/features/rowSelection/useGridRowSelection.js +4 -1
  128. package/node/hooks/features/rows/useGridParamsApi.js +2 -1
  129. package/node/hooks/features/rows/useGridRowAriaAttributes.js +28 -0
  130. package/node/hooks/utils/useGridAriaAttributes.js +4 -7
  131. package/node/hooks/utils/useGridConfiguration.js +18 -0
  132. package/node/hooks/utils/useGridSelector.js +42 -3
  133. package/node/index.js +1 -1
  134. package/node/internals/index.js +53 -12
  135. package/node/locales/csCZ.js +4 -5
  136. package/node/locales/heIL.js +4 -5
  137. package/node/locales/viVN.js +4 -5
  138. package/node/models/configuration/gridConfiguration.js +5 -0
  139. package/node/models/configuration/gridRowConfiguration.js +5 -0
  140. package/node/utils/createSelector.js +119 -2
  141. package/node/utils/keyboardUtils.js +2 -15
  142. package/package.json +4 -4
  143. package/utils/createSelector.d.ts +19 -0
  144. package/utils/createSelector.js +116 -0
  145. package/utils/keyboardUtils.d.ts +1 -9
  146. package/utils/keyboardUtils.js +1 -11
  147. package/modern/utils/fastMemo.js +0 -5
  148. package/modern/utils/fastObjectShallowCompare.js +0 -28
  149. package/modern/utils/throttle.js +0 -19
  150. package/node/utils/fastObjectShallowCompare.js +0 -34
  151. package/node/utils/throttle.js +0 -25
  152. package/utils/fastMemo.d.ts +0 -1
  153. package/utils/fastMemo.js +0 -5
  154. package/utils/fastObjectShallowCompare.d.ts +0 -1
  155. package/utils/fastObjectShallowCompare.js +0 -28
  156. package/utils/throttle.d.ts +0 -4
  157. package/utils/throttle.js +0 -19
@@ -43,19 +43,19 @@ export interface GridGetRowsResponse {
43
43
  }
44
44
  export interface GridDataSource {
45
45
  /**
46
- * This method will be called when the grid needs to fetch some rows
46
+ * This method will be called when the grid needs to fetch some rows.
47
47
  * @param {GridGetRowsParams} params The parameters required to fetch the rows
48
48
  * @returns {Promise<GridGetRowsResponse>} A promise that resolves to the data of type [GridGetRowsResponse]
49
49
  */
50
50
  getRows(params: GridGetRowsParams): Promise<GridGetRowsResponse>;
51
51
  /**
52
- * This method will be called when the user updates a row [Not yet implemented]
52
+ * This method will be called when the user updates a row [Not yet implemented].
53
53
  * @param {GridRowModel} updatedRow The updated row
54
54
  * @returns {Promise<any>} If resolved (synced on the backend), the grid will update the row and mutate the cache
55
55
  */
56
56
  updateRow?(updatedRow: GridRowModel): Promise<any>;
57
57
  /**
58
- * Used to group rows by their parent group. Replaces `getTreeDataPath` used in client side tree-data .
58
+ * Used to group rows by their parent group. Replaces `getTreeDataPath` used in client side tree-data.
59
59
  * @param {GridRowModel} row The row to get the group key of
60
60
  * @returns {string} The group key for the row
61
61
  */
@@ -63,25 +63,26 @@ export interface GridDataSource {
63
63
  /**
64
64
  * Used to determine the number of children a row has on server.
65
65
  * @param {GridRowModel} row The row to check the number of children
66
- * @returns {number} The number of children the row has
66
+ * @returns {number} The number of children the row has.
67
+ * If the children count is not available for some reason, but there are some children, `getChildrenCount` should return `-1`.
67
68
  */
68
69
  getChildrenCount?: (row: GridRowModel) => number;
69
70
  }
70
71
  export interface GridDataSourceCache {
71
72
  /**
72
- * Set the cache entry for the given key
73
+ * Set the cache entry for the given key.
73
74
  * @param {GridGetRowsParams} key The key of type `GridGetRowsParams`
74
75
  * @param {GridGetRowsResponse} value The value to be stored in the cache
75
76
  */
76
77
  set: (key: GridGetRowsParams, value: GridGetRowsResponse) => void;
77
78
  /**
78
- * Get the cache entry for the given key
79
+ * Get the cache entry for the given key.
79
80
  * @param {GridGetRowsParams} key The key of type `GridGetRowsParams`
80
81
  * @returns {GridGetRowsResponse} The value stored in the cache
81
82
  */
82
83
  get: (key: GridGetRowsParams) => GridGetRowsResponse | undefined;
83
84
  /**
84
- * Clear the cache
85
+ * Clear the cache.
85
86
  */
86
87
  clear: () => void;
87
88
  }
@@ -104,9 +104,9 @@ export interface GridDataGroupNode extends GridBasicGroupNode {
104
104
  }
105
105
  export interface GridDataSourceGroupNode extends GridDataGroupNode {
106
106
  /**
107
- * If true, this node has children on server.
107
+ * Number of children this node has on the server. Equals to `-1` if there are some children but the count is unknown.
108
108
  */
109
- hasServerChildren: boolean;
109
+ serverChildrenCount: number;
110
110
  /**
111
111
  * The cached path to be passed on as `groupKey` to the server.
112
112
  */
@@ -53,6 +53,10 @@ export interface GridCellParams<R extends GridValidRowModel = any, V = unknown,
53
53
  * the tabIndex value.
54
54
  */
55
55
  tabIndex: 0 | -1;
56
+ /**
57
+ * GridApi that let you manipulate the grid.
58
+ */
59
+ api: GridApiCommunity;
56
60
  }
57
61
  export interface FocusElement {
58
62
  focus(): void;
@@ -441,7 +441,7 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
441
441
  /**
442
442
  * Determines if a row can be selected.
443
443
  * @param {GridRowParams} params With all properties from [[GridRowParams]].
444
- * @returns {boolean} A boolean indicating if the cell is selectable.
444
+ * @returns {boolean} A boolean indicating if the row is selectable.
445
445
  */
446
446
  isRowSelectable?: (params: GridRowParams<R>) => boolean;
447
447
  /**
@@ -4,11 +4,19 @@ import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { GridBody, GridFooterPlaceholder, GridHeader, GridRoot } from '../components';
7
+ import { useGridAriaAttributes } from '../hooks/utils/useGridAriaAttributes';
8
+ import { useGridRowAriaAttributes } from '../hooks/features/rows/useGridRowAriaAttributes';
7
9
  import { GridContextProvider } from '../context/GridContextProvider';
8
10
  import { useDataGridComponent } from './useDataGridComponent';
9
11
  import { useDataGridProps } from './useDataGridProps';
10
12
  import { propValidatorsDataGrid, validateProps } from '../internals/utils/propValidation';
11
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ const configuration = {
15
+ hooks: {
16
+ useGridAriaAttributes,
17
+ useGridRowAriaAttributes
18
+ }
19
+ };
12
20
  let propValidators;
13
21
  if (process.env.NODE_ENV !== 'production') {
14
22
  propValidators = [...propValidatorsDataGrid,
@@ -23,6 +31,7 @@ const DataGridRaw = /*#__PURE__*/React.forwardRef(function DataGrid(inProps, ref
23
31
  }
24
32
  return /*#__PURE__*/_jsx(GridContextProvider, {
25
33
  privateApiRef: privateApiRef,
34
+ configuration: configuration,
26
35
  props: props,
27
36
  children: /*#__PURE__*/_jsxs(GridRoot, _extends({
28
37
  className: props.className,
@@ -321,7 +330,7 @@ DataGridRaw.propTypes = {
321
330
  /**
322
331
  * Determines if a row can be selected.
323
332
  * @param {GridRowParams} params With all properties from [[GridRowParams]].
324
- * @returns {boolean} A boolean indicating if the cell is selectable.
333
+ * @returns {boolean} A boolean indicating if the row is selectable.
325
334
  */
326
335
  isRowSelectable: PropTypes.func,
327
336
  /**
@@ -3,7 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["className", "visibleColumns", "sortColumnLookup", "filterColumnLookup", "columnHeaderTabIndexState", "columnGroupHeaderTabIndexState", "columnHeaderFocus", "columnGroupHeaderFocus", "headerGroupingMaxDepth", "columnMenuState", "columnVisibility", "columnGroupsHeaderStructure", "hasOtherElementInTabSequence"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
- import { fastMemo } from '../utils/fastMemo';
6
+ import { fastMemo } from '@mui/x-internals/fastMemo';
7
7
  import { useGridColumnHeaders } from '../hooks/features/columnHeaders/useGridColumnHeaders';
8
8
  import { GridBaseColumnHeaders } from './columnHeaders/GridBaseColumnHeaders';
9
9
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export const GridConfigurationContext = /*#__PURE__*/React.createContext(undefined);
3
+ if (process.env.NODE_ENV !== 'production') {
4
+ GridConfigurationContext.displayName = 'GridConfigurationContext';
5
+ }
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import { fastMemo } from '../utils/fastMemo';
3
+ import { fastMemo } from '@mui/x-internals/fastMemo';
4
4
  import { useGridPrivateApiContext } from '../hooks/utils/useGridPrivateApiContext';
5
5
  import { useGridSelector } from '../hooks/utils/useGridSelector';
6
6
  import { useGridRootProps } from '../hooks/utils/useGridRootProps';
@@ -5,7 +5,7 @@ import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import clsx from 'clsx';
7
7
  import { unstable_useForkRef as useForkRef } from '@mui/utils';
8
- import { fastMemo } from '../utils/fastMemo';
8
+ import { fastMemo } from '@mui/x-internals/fastMemo';
9
9
  import { GridEditModes, GridRowModes, GridCellModes } from '../models/gridEditRowModel';
10
10
  import { useGridApiContext } from '../hooks/utils/useGridApiContext';
11
11
  import { gridClasses } from '../constants/gridClasses';
@@ -20,11 +20,11 @@ import { GRID_ACTIONS_COLUMN_TYPE } from '../colDef/gridActionsColDef';
20
20
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../constants/gridDetailPanelToggleField';
21
21
  import { gridSortModelSelector } from '../hooks/features/sorting/gridSortingSelector';
22
22
  import { gridRowMaximumTreeDepthSelector } from '../hooks/features/rows/gridRowsSelector';
23
- import { gridColumnGroupsHeaderMaxDepthSelector } from '../hooks/features/columnGrouping/gridColumnGroupsSelector';
24
23
  import { gridEditRowsStateSelector } from '../hooks/features/editing/gridEditingSelectors';
25
24
  import { PinnedPosition, gridPinnedColumnPositionLookup } from './cell/GridCell';
26
25
  import { GridScrollbarFillerCell as ScrollbarFiller } from './GridScrollbarFillerCell';
27
26
  import { getPinnedCellOffset } from '../internals/utils/getPinnedCellOffset';
27
+ import { useGridConfiguration } from '../hooks/utils/useGridConfiguration';
28
28
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
29
29
  function EmptyCell({
30
30
  width
@@ -68,12 +68,12 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
68
68
  } = props,
69
69
  other = _objectWithoutPropertiesLoose(props, _excluded);
70
70
  const apiRef = useGridApiContext();
71
+ const configuration = useGridConfiguration();
71
72
  const ref = React.useRef(null);
72
73
  const rootProps = useGridRootProps();
73
74
  const currentPage = useGridVisibleRows(apiRef, rootProps);
74
75
  const sortModel = useGridSelector(apiRef, gridSortModelSelector);
75
76
  const treeDepth = useGridSelector(apiRef, gridRowMaximumTreeDepthSelector);
76
- const headerGroupingMaxDepth = useGridSelector(apiRef, gridColumnGroupsHeaderMaxDepthSelector);
77
77
  const columnPositions = useGridSelector(apiRef, gridColumnPositionsSelector);
78
78
  const editRowsState = useGridSelector(apiRef, gridEditRowsStateSelector);
79
79
  const handleRef = useForkRef(ref, refProp);
@@ -85,11 +85,10 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
85
85
  const hasFocusCell = focusedColumnIndex !== undefined;
86
86
  const hasVirtualFocusCellLeft = hasFocusCell && focusedColumnIndex >= pinnedColumns.left.length && focusedColumnIndex < renderContext.firstColumnIndex;
87
87
  const hasVirtualFocusCellRight = hasFocusCell && focusedColumnIndex < visibleColumns.length - pinnedColumns.right.length && focusedColumnIndex >= renderContext.lastColumnIndex;
88
- const ariaRowIndex = index + headerGroupingMaxDepth + 2; // 1 for the header row and 1 as it's 1-based
89
-
90
88
  const classes = composeGridClasses(rootProps.classes, {
91
89
  root: ['row', selected && 'selected', editable && 'row--editable', editing && 'row--editing', isFirstVisible && 'row--firstVisible', isLastVisible && 'row--lastVisible', showBottomBorder && 'row--borderBottom', rowHeight === 'auto' && 'row--dynamicHeight']
92
90
  });
91
+ const getRowAriaAttributes = configuration.hooks.useGridRowAriaAttributes();
93
92
  React.useLayoutEffect(() => {
94
93
  if (currentPage.range) {
95
94
  // The index prop is relative to the rows from all pages. As example, the index prop of the
@@ -212,6 +211,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
212
211
  return rowStyle;
213
212
  }, [isNotVisible, rowHeight, styleProp, minHeight, sizes, rootProps.rowSpacingType]);
214
213
  const rowClassNames = apiRef.current.unstable_applyPipeProcessors('rowClassName', [], rowId);
214
+ const ariaAttributes = rowNode ? getRowAriaAttributes(rowNode, index) : undefined;
215
215
  if (typeof rootProps.getRowClassName === 'function') {
216
216
  const indexRelativeToCurrentPage = index - (currentPage.range?.firstRowIndex || 0);
217
217
  const rowParams = _extends({}, apiRef.current.getRowParams(rowId), {
@@ -308,10 +308,8 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
308
308
  "data-rowindex": index,
309
309
  role: "row",
310
310
  className: clsx(...rowClassNames, classes.root, className),
311
- "aria-rowindex": ariaRowIndex,
312
- "aria-selected": selected,
313
311
  style: style
314
- }, eventHandlers, other, {
312
+ }, ariaAttributes, eventHandlers, other, {
315
313
  children: [leftCells, /*#__PURE__*/_jsx("div", {
316
314
  role: "presentation",
317
315
  className: gridClasses.cellOffsetLeft,
@@ -3,6 +3,7 @@ import * as React from 'react';
3
3
  import clsx from 'clsx';
4
4
  import { unstable_composeClasses as composeClasses, unstable_useEventCallback as useEventCallback } from '@mui/utils';
5
5
  import { styled } from '@mui/system';
6
+ import { fastMemo } from '@mui/x-internals/fastMemo';
6
7
  import { useGridRootProps } from '../hooks/utils/useGridRootProps';
7
8
  import { getDataGridUtilityClass, gridClasses } from '../constants';
8
9
  import { useGridApiContext } from '../hooks/utils/useGridApiContext';
@@ -13,7 +14,6 @@ import { gridDensityFactorSelector } from '../hooks/features/density/densitySele
13
14
  import { gridColumnsTotalWidthSelector } from '../hooks/features/columns/gridColumnsSelector';
14
15
  import { useTimeout } from '../hooks/utils/useTimeout';
15
16
  import { getTotalHeaderHeight } from '../hooks/features/columns/gridColumnsUtils';
16
- import { fastMemo } from '../utils/fastMemo';
17
17
  import { jsx as _jsx } from "react/jsx-runtime";
18
18
  const CLIFF = 1;
19
19
  const SLOP = 1.5;
@@ -119,7 +119,7 @@ const GridSkeletonLoadingOverlay = /*#__PURE__*/React.forwardRef(function GridSk
119
119
  if (hasScrollbarFiller) {
120
120
  rowCells.push( /*#__PURE__*/_jsx(GridScrollbarFillerCell, {
121
121
  pinnedRight: pinnedColumns.right.length > 0
122
- }));
122
+ }, `skeleton-scrollbar-filler-${i}`));
123
123
  }
124
124
  }
125
125
  array.push( /*#__PURE__*/_jsx("div", {
@@ -6,7 +6,7 @@ import * as React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import clsx from 'clsx';
8
8
  import { unstable_useForkRef as useForkRef, unstable_composeClasses as composeClasses, unstable_ownerDocument as ownerDocument, unstable_capitalize as capitalize } from '@mui/utils';
9
- import { fastMemo } from '../../utils/fastMemo';
9
+ import { fastMemo } from '@mui/x-internals/fastMemo';
10
10
  import { doesSupportPreventScroll } from '../../utils/doesSupportPreventScroll';
11
11
  import { getDataGridUtilityClass, gridClasses } from '../../constants/gridClasses';
12
12
  import { GridCellModes } from '../../models';
@@ -107,13 +107,12 @@ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
107
107
  const apiRef = useGridApiContext();
108
108
  const rootProps = useGridRootProps();
109
109
  const field = column.field;
110
- const cellParamsWithAPI = useGridSelector(apiRef, () => {
110
+ const cellParams = useGridSelector(apiRef, () => {
111
111
  // This is required because `.getCellParams` tries to get the `state.rows.tree` entry
112
112
  // associated with `rowId`/`fieldId`, but this selector runs after the state has been
113
113
  // updated, while `rowId`/`fieldId` reference an entry in the old state.
114
114
  try {
115
- const cellParams = apiRef.current.getCellParams(rowId, field);
116
- const result = cellParams;
115
+ const result = apiRef.current.getCellParams(rowId, field);
117
116
  result.api = apiRef.current;
118
117
  return result;
119
118
  } catch (e) {
@@ -132,9 +131,9 @@ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
132
131
  hasFocus,
133
132
  isEditable = false,
134
133
  value
135
- } = cellParamsWithAPI;
134
+ } = cellParams;
136
135
  const canManageOwnFocus = column.type === 'actions' && column.getActions?.(apiRef.current.getRowParams(rowId)).some(action => !action.props.disabled);
137
- const tabIndex = (cellMode === 'view' || !isEditable) && !canManageOwnFocus ? cellParamsWithAPI.tabIndex : -1;
136
+ const tabIndex = (cellMode === 'view' || !isEditable) && !canManageOwnFocus ? cellParams.tabIndex : -1;
138
137
  const {
139
138
  classes: rootClasses,
140
139
  getCellClassName
@@ -147,15 +146,15 @@ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
147
146
  }).filter(Boolean).join(' '));
148
147
  const classNames = [pipesClassName];
149
148
  if (column.cellClassName) {
150
- classNames.push(typeof column.cellClassName === 'function' ? column.cellClassName(cellParamsWithAPI) : column.cellClassName);
149
+ classNames.push(typeof column.cellClassName === 'function' ? column.cellClassName(cellParams) : column.cellClassName);
151
150
  }
152
151
  if (column.display === 'flex') {
153
152
  classNames.push(gridClasses['cell--flex']);
154
153
  }
155
154
  if (getCellClassName) {
156
- classNames.push(getCellClassName(cellParamsWithAPI));
155
+ classNames.push(getCellClassName(cellParams));
157
156
  }
158
- const valueToRender = cellParamsWithAPI.formattedValue ?? value;
157
+ const valueToRender = cellParams.formattedValue ?? value;
159
158
  const cellRef = React.useRef(null);
160
159
  const handleRef = useForkRef(ref, cellRef);
161
160
  const focusElementRef = React.useRef(null);
@@ -238,7 +237,7 @@ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
238
237
  }
239
238
  }
240
239
  }, [hasFocus, cellMode, apiRef]);
241
- if (cellParamsWithAPI === EMPTY_CELL_PARAMS) {
240
+ if (cellParams === EMPTY_CELL_PARAMS) {
242
241
  return null;
243
242
  }
244
243
  let handleFocus = other.onFocus;
@@ -260,15 +259,15 @@ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
260
259
  let children;
261
260
  let title;
262
261
  if (editCellState === null && column.renderCell) {
263
- children = column.renderCell(cellParamsWithAPI);
262
+ children = column.renderCell(cellParams);
264
263
  }
265
264
  if (editCellState !== null && column.renderEditCell) {
266
265
  const updatedRow = apiRef.current.getRowWithUpdatedValues(rowId, column.field);
267
266
 
268
267
  // eslint-disable-next-line @typescript-eslint/naming-convention
269
268
  const editCellStateRest = _objectWithoutPropertiesLoose(editCellState, _excluded2);
270
- const formattedValue = column.valueFormatter ? column.valueFormatter(editCellState.value, updatedRow, column, apiRef) : cellParamsWithAPI.formattedValue;
271
- const params = _extends({}, cellParamsWithAPI, {
269
+ const formattedValue = column.valueFormatter ? column.valueFormatter(editCellState.value, updatedRow, column, apiRef) : cellParams.formattedValue;
270
+ const params = _extends({}, cellParams, {
272
271
  row: updatedRow,
273
272
  formattedValue
274
273
  }, editCellStateRest);
@@ -6,7 +6,6 @@ import * as React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
8
8
  import { GridCellEditStopReasons } from '../../models/params/gridEditCellParams';
9
- import { isEscapeKey } from '../../utils/keyboardUtils';
10
9
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
11
10
  import { GridEditModes } from '../../models/gridEditRowModel';
12
11
  import { getValueFromValueOptions, getValueOptions, isSingleSelectColDef } from '../panel/filterPanel/filterPanelUtils';
@@ -80,10 +79,10 @@ function GridEditSingleSelectCell(props) {
80
79
  setOpen(false);
81
80
  return;
82
81
  }
83
- if (reason === 'backdropClick' || isEscapeKey(event.key)) {
82
+ if (reason === 'backdropClick' || event.key === 'Escape') {
84
83
  const params = apiRef.current.getCellParams(id, field);
85
84
  apiRef.current.publishEvent('cellEditStop', _extends({}, params, {
86
- reason: isEscapeKey(event.key) ? GridCellEditStopReasons.escapeKeyDown : GridCellEditStopReasons.cellFocusOut
85
+ reason: event.key === 'Escape' ? GridCellEditStopReasons.escapeKeyDown : GridCellEditStopReasons.cellFocusOut
87
86
  }));
88
87
  }
89
88
  };
@@ -3,10 +3,10 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["field", "type", "align", "width", "height", "empty", "style", "className"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
+ import clsx from 'clsx';
6
7
  import Skeleton from '@mui/material/Skeleton';
7
8
  import { unstable_composeClasses as composeClasses, unstable_capitalize as capitalize } from '@mui/utils';
8
- import clsx from 'clsx';
9
- import { fastMemo } from '../../utils/fastMemo';
9
+ import { fastMemo } from '@mui/x-internals/fastMemo';
10
10
  import { createRandomNumberGenerator } from '../../utils/utils';
11
11
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
12
12
  import { getDataGridUtilityClass } from '../../constants/gridClasses';
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import clsx from 'clsx';
5
5
  import { unstable_composeClasses as composeClasses, unstable_useId as useId } from '@mui/utils';
6
- import { fastMemo } from '../../utils/fastMemo';
6
+ import { fastMemo } from '@mui/x-internals/fastMemo';
7
7
  import { useGridPrivateApiContext } from '../../hooks/utils/useGridPrivateApiContext';
8
8
  import { ColumnHeaderMenuIcon } from './ColumnHeaderMenuIcon';
9
9
  import { GridColumnHeaderMenu } from '../menu/columnMenu/GridColumnHeaderMenu';
@@ -668,9 +668,16 @@ export const GridRootStyles = styled('div', {
668
668
  [`& .${c['filler--borderTop']}`]: {
669
669
  borderTop: '1px solid var(--DataGrid-rowBorderColor)'
670
670
  },
671
- /* Hide grid rows and vertical scrollbar when skeleton overlay is visible */
671
+ /* Hide grid rows, row filler, and vertical scrollbar when skeleton overlay is visible */
672
672
  [`& .${c['main--hasSkeletonLoadingOverlay']}`]: {
673
- [`& .${c.virtualScrollerContent}, & .${c['scrollbar--vertical']}, & .${c.pinnedRows}`]: {
673
+ [`& .${c.virtualScrollerContent}`]: {
674
+ // We use visibility hidden so that the virtual scroller content retains its height.
675
+ // Position fixed is used to remove the virtual scroller content from the flow.
676
+ // https://github.com/mui/mui-x/issues/14061
677
+ position: 'fixed',
678
+ visibility: 'hidden'
679
+ },
680
+ [`& .${c['scrollbar--vertical']}, & .${c.pinnedRows}, & .${c.virtualScroller} > .${c.filler}`]: {
674
681
  display: 'none'
675
682
  }
676
683
  }
@@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
6
6
  import * as React from 'react';
7
7
  import MenuList from '@mui/material/MenuList';
8
8
  import { styled } from '@mui/material/styles';
9
- import { isHideMenuKey, isTabKey } from '../../../utils/keyboardUtils';
9
+ import { isHideMenuKey } from '../../../utils/keyboardUtils';
10
10
  import { gridClasses } from '../../../constants/gridClasses';
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
12
  const StyledMenuList = styled(MenuList)(() => ({
@@ -23,7 +23,7 @@ const GridColumnMenuContainer = /*#__PURE__*/React.forwardRef(function GridColum
23
23
  } = props,
24
24
  other = _objectWithoutPropertiesLoose(props, _excluded);
25
25
  const handleListKeyDown = React.useCallback(event => {
26
- if (isTabKey(event.key)) {
26
+ if (event.key === 'Tab') {
27
27
  event.preventDefault();
28
28
  }
29
29
  if (isHideMenuKey(event.key)) {
@@ -10,7 +10,6 @@ import ClickAwayListener from '@mui/material/ClickAwayListener';
10
10
  import Paper from '@mui/material/Paper';
11
11
  import Popper from '@mui/material/Popper';
12
12
  import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
13
- import { isEscapeKey } from '../../utils/keyboardUtils';
14
13
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
15
14
  import { jsx as _jsx } from "react/jsx-runtime";
16
15
  export const gridPanelClasses = generateUtilityClasses('MuiDataGrid', ['panel', 'paper']);
@@ -51,7 +50,7 @@ const GridPanel = /*#__PURE__*/React.forwardRef((props, ref) => {
51
50
  apiRef.current.hidePreferences();
52
51
  }, [apiRef]);
53
52
  const handleKeyDown = React.useCallback(event => {
54
- if (isEscapeKey(event.key)) {
53
+ if (event.key === 'Escape') {
55
54
  apiRef.current.hidePreferences();
56
55
  }
57
56
  }, [apiRef]);
@@ -281,10 +281,15 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
281
281
  variant: "standard",
282
282
  as: rootProps.slots.baseFormControl
283
283
  }, baseFormControlProps, logicOperatorInputProps, {
284
- sx: _extends({
285
- display: hasLogicOperatorColumn ? 'flex' : 'none',
286
- visibility: showMultiFilterOperators ? 'visible' : 'hidden'
287
- }, baseFormControlProps.sx || {}, logicOperatorInputProps.sx || {}),
284
+ sx: [hasLogicOperatorColumn ? {
285
+ display: 'flex'
286
+ } : {
287
+ display: 'none'
288
+ }, showMultiFilterOperators ? {
289
+ visibility: 'visible'
290
+ } : {
291
+ visibility: 'hidden'
292
+ }, baseFormControlProps.sx, logicOperatorInputProps.sx],
288
293
  className: clsx(classes.logicOperatorInput, baseFormControlProps.className, logicOperatorInputProps.className),
289
294
  ownerState: rootProps,
290
295
  children: /*#__PURE__*/_jsx(rootProps.slots.baseSelect, _extends({
@@ -6,7 +6,7 @@ import MenuList from '@mui/material/MenuList';
6
6
  import MenuItem from '@mui/material/MenuItem';
7
7
  import ListItemIcon from '@mui/material/ListItemIcon';
8
8
  import { gridDensitySelector } from '../../hooks/features/density/densitySelector';
9
- import { isHideMenuKey, isTabKey } from '../../utils/keyboardUtils';
9
+ import { isHideMenuKey } from '../../utils/keyboardUtils';
10
10
  import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
11
11
  import { useGridSelector } from '../../hooks/utils/useGridSelector';
12
12
  import { GridMenu } from '../menu/GridMenu';
@@ -62,7 +62,7 @@ const GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function GridTo
62
62
  setOpen(false);
63
63
  };
64
64
  const handleListKeyDown = event => {
65
- if (isTabKey(event.key)) {
65
+ if (event.key === 'Tab') {
66
66
  event.preventDefault();
67
67
  }
68
68
  if (isHideMenuKey(event.key)) {
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { unstable_useId as useId, unstable_useForkRef as useForkRef } from '@mui/utils';
5
5
  import MenuList from '@mui/material/MenuList';
6
- import { isHideMenuKey, isTabKey } from '../../utils/keyboardUtils';
6
+ import { isHideMenuKey } from '../../utils/keyboardUtils';
7
7
  import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
8
8
  import { GridMenu } from '../menu/GridMenu';
9
9
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
@@ -29,7 +29,7 @@ const GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function GridTo
29
29
  };
30
30
  const handleMenuClose = () => setOpen(false);
31
31
  const handleListKeyDown = event => {
32
- if (isTabKey(event.key)) {
32
+ if (event.key === 'Tab') {
33
33
  event.preventDefault();
34
34
  }
35
35
  if (isHideMenuKey(event.key)) {
@@ -105,9 +105,11 @@ function GridToolbarQuickFilter(props) {
105
105
  endAdornment: /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
106
106
  "aria-label": apiRef.current.getLocaleText('toolbarQuickFilterDeleteIconLabel'),
107
107
  size: "small",
108
- sx: {
109
- visibility: searchValue ? 'visible' : 'hidden'
110
- },
108
+ sx: [searchValue ? {
109
+ visibility: 'visible'
110
+ } : {
111
+ visibility: 'hidden'
112
+ }],
111
113
  onClick: handleSearchReset
112
114
  }, rootProps.slotProps?.baseIconButton, {
113
115
  children: /*#__PURE__*/_jsx(rootProps.slots.quickFilterClearIcon, {
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { styled } from '@mui/system';
4
4
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
5
- import { useGridAriaAttributes } from '../../hooks/utils/useGridAriaAttributes';
5
+ import { useGridConfiguration } from '../../hooks/utils/useGridConfiguration';
6
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
7
  const GridPanelAnchor = styled('div')({
8
8
  position: 'absolute',
@@ -19,8 +19,9 @@ const Element = styled('div', {
19
19
  overflow: 'hidden'
20
20
  });
21
21
  export const GridMainContainer = /*#__PURE__*/React.forwardRef((props, ref) => {
22
- const ariaAttributes = useGridAriaAttributes();
23
22
  const rootProps = useGridRootProps();
23
+ const configuration = useGridConfiguration();
24
+ const ariaAttributes = configuration.hooks.useGridAriaAttributes();
24
25
  return /*#__PURE__*/_jsxs(Element, _extends({
25
26
  ref: ref,
26
27
  ownerState: rootProps,
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { styled } from '@mui/system';
3
- import { fastMemo } from '../../utils/fastMemo';
3
+ import { fastMemo } from '@mui/x-internals/fastMemo';
4
4
  import { useGridSelector } from '../../hooks/utils/useGridSelector';
5
5
  import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
6
6
  import { gridDimensionsSelector } from '../../hooks/features/dimensions';
@@ -2,20 +2,25 @@ import * as React from 'react';
2
2
  import { GridApiContext } from '../components/GridApiContext';
3
3
  import { GridPrivateApiContext } from '../hooks/utils/useGridPrivateApiContext';
4
4
  import { GridRootPropsContext } from './GridRootPropsContext';
5
+ import { GridConfigurationContext } from '../components/GridConfigurationContext';
5
6
  import { jsx as _jsx } from "react/jsx-runtime";
6
7
  export function GridContextProvider({
7
8
  privateApiRef,
9
+ configuration,
8
10
  props,
9
11
  children
10
12
  }) {
11
13
  const apiRef = React.useRef(privateApiRef.current.getPublicApi());
12
- return /*#__PURE__*/_jsx(GridRootPropsContext.Provider, {
13
- value: props,
14
- children: /*#__PURE__*/_jsx(GridPrivateApiContext.Provider, {
15
- value: privateApiRef,
16
- children: /*#__PURE__*/_jsx(GridApiContext.Provider, {
17
- value: apiRef,
18
- children: children
14
+ return /*#__PURE__*/_jsx(GridConfigurationContext.Provider, {
15
+ value: configuration,
16
+ children: /*#__PURE__*/_jsx(GridRootPropsContext.Provider, {
17
+ value: props,
18
+ children: /*#__PURE__*/_jsx(GridPrivateApiContext.Provider, {
19
+ value: privateApiRef,
20
+ children: /*#__PURE__*/_jsx(GridApiContext.Provider, {
21
+ value: apiRef,
22
+ children: children
23
+ })
19
24
  })
20
25
  })
21
26
  });
@@ -48,9 +48,7 @@ export const useGridStateInitialization = apiRef => {
48
48
  if (!ignoreSetState) {
49
49
  // We always assign it as we mutate rows for perf reason.
50
50
  apiRef.current.state = newState;
51
- if (apiRef.current.publishEvent) {
52
- apiRef.current.publishEvent('stateChange', newState);
53
- }
51
+ apiRef.current.publishEvent('stateChange', newState);
54
52
  apiRef.current.store.update(newState);
55
53
  }
56
54
  if (updatedControlStateIds.length === 1) {
@@ -1,9 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { unstable_ownerDocument as ownerDocument, unstable_useEnhancedEffect as useEnhancedEffect, unstable_useEventCallback as useEventCallback, unstable_ownerWindow as ownerWindow } from '@mui/utils';
4
+ import { throttle } from '@mui/x-internals/throttle';
4
5
  import { useGridApiEventHandler, useGridApiOptionHandler } from '../../utils/useGridApiEventHandler';
5
6
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
6
- import { throttle } from '../../../utils/throttle';
7
7
  import { useGridLogger } from '../../utils/useGridLogger';
8
8
  import { gridColumnsTotalWidthSelector, gridVisiblePinnedColumnDefinitionsSelector } from '../columns';
9
9
  import { gridDimensionsSelector } from './gridDimensionsSelectors';
@@ -1,6 +1,9 @@
1
1
  import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../../../../colDef';
2
2
  import { warnOnce } from '../../../../internals/utils/warning';
3
3
  function sanitizeCellValue(value, csvOptions) {
4
+ if (value === null || value === undefined) {
5
+ return '';
6
+ }
4
7
  const valueStr = typeof value === 'string' ? value : `${value}`;
5
8
  if (csvOptions.shouldAppendQuotes || csvOptions.escapeFormulas) {
6
9
  const escapedValue = valueStr.replace(/"/g, '""');
@@ -51,9 +54,7 @@ class CSVRow {
51
54
  if (!this.isEmpty) {
52
55
  this.rowString += this.options.csvOptions.delimiter;
53
56
  }
54
- if (value === null || value === undefined) {
55
- this.rowString += '';
56
- } else if (typeof this.options.sanitizeCellValue === 'function') {
57
+ if (typeof this.options.sanitizeCellValue === 'function') {
57
58
  this.rowString += this.options.sanitizeCellValue(value, this.options.csvOptions);
58
59
  } else {
59
60
  this.rowString += value;