@mui/x-data-grid 7.12.1 → 7.13.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 (118) hide show
  1. package/CHANGELOG.md +81 -0
  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 +1 -1
  11. package/components/cell/GridSkeletonCell.js +2 -2
  12. package/components/columnHeaders/GridColumnHeaderItem.js +1 -1
  13. package/components/containers/GridRootStyles.js +9 -2
  14. package/components/virtualization/GridMainContainer.js +3 -2
  15. package/components/virtualization/GridVirtualScrollerFiller.js +1 -1
  16. package/context/GridContextProvider.d.ts +3 -1
  17. package/context/GridContextProvider.js +12 -7
  18. package/hooks/core/useGridStateInitialization.js +1 -3
  19. package/hooks/features/dimensions/useGridDimensions.js +1 -1
  20. package/hooks/features/export/serializers/csvSerializer.js +4 -3
  21. package/hooks/features/filter/gridFilterSelector.d.ts +20 -7
  22. package/hooks/features/filter/gridFilterSelector.js +34 -0
  23. package/hooks/features/filter/gridFilterState.d.ts +6 -0
  24. package/hooks/features/filter/index.d.ts +2 -1
  25. package/hooks/features/filter/index.js +1 -1
  26. package/hooks/features/filter/useGridFilter.js +3 -0
  27. package/hooks/features/rowSelection/useGridRowSelection.js +4 -1
  28. package/hooks/features/rows/useGridRowAriaAttributes.d.ts +2 -0
  29. package/hooks/features/rows/useGridRowAriaAttributes.js +19 -0
  30. package/hooks/utils/useGridAriaAttributes.d.ts +2 -6
  31. package/hooks/utils/useGridAriaAttributes.js +5 -8
  32. package/hooks/utils/useGridConfiguration.d.ts +2 -0
  33. package/hooks/utils/useGridConfiguration.js +9 -0
  34. package/hooks/utils/useGridSelector.d.ts +1 -1
  35. package/hooks/utils/useGridSelector.js +1 -1
  36. package/index.js +1 -1
  37. package/internals/index.d.ts +3 -1
  38. package/internals/index.js +3 -1
  39. package/locales/viVN.js +4 -5
  40. package/models/configuration/gridConfiguration.d.ts +10 -0
  41. package/models/configuration/gridConfiguration.js +1 -0
  42. package/models/configuration/gridRowConfiguration.d.ts +12 -0
  43. package/models/configuration/gridRowConfiguration.js +1 -0
  44. package/models/gridDataSource.d.ts +2 -1
  45. package/models/gridRows.d.ts +2 -2
  46. package/models/props/DataGridProps.d.ts +1 -1
  47. package/modern/DataGrid/DataGrid.js +10 -1
  48. package/modern/components/GridColumnHeaders.js +1 -1
  49. package/modern/components/GridConfigurationContext.js +5 -0
  50. package/modern/components/GridHeaders.js +1 -1
  51. package/modern/components/GridRow.js +6 -8
  52. package/modern/components/GridScrollArea.js +1 -1
  53. package/modern/components/GridSkeletonLoadingOverlay.js +1 -1
  54. package/modern/components/cell/GridCell.js +1 -1
  55. package/modern/components/cell/GridSkeletonCell.js +2 -2
  56. package/modern/components/columnHeaders/GridColumnHeaderItem.js +1 -1
  57. package/modern/components/containers/GridRootStyles.js +9 -2
  58. package/modern/components/virtualization/GridMainContainer.js +3 -2
  59. package/modern/components/virtualization/GridVirtualScrollerFiller.js +1 -1
  60. package/modern/context/GridContextProvider.js +12 -7
  61. package/modern/hooks/core/useGridStateInitialization.js +1 -3
  62. package/modern/hooks/features/dimensions/useGridDimensions.js +1 -1
  63. package/modern/hooks/features/export/serializers/csvSerializer.js +4 -3
  64. package/modern/hooks/features/filter/gridFilterSelector.js +34 -0
  65. package/modern/hooks/features/filter/index.js +1 -1
  66. package/modern/hooks/features/filter/useGridFilter.js +3 -0
  67. package/modern/hooks/features/rowSelection/useGridRowSelection.js +4 -1
  68. package/modern/hooks/features/rows/useGridRowAriaAttributes.js +19 -0
  69. package/modern/hooks/utils/useGridAriaAttributes.js +5 -8
  70. package/modern/hooks/utils/useGridConfiguration.js +9 -0
  71. package/modern/hooks/utils/useGridSelector.js +1 -1
  72. package/modern/index.js +1 -1
  73. package/modern/internals/index.js +3 -1
  74. package/modern/locales/viVN.js +4 -5
  75. package/modern/models/configuration/gridConfiguration.js +1 -0
  76. package/modern/models/configuration/gridRowConfiguration.js +1 -0
  77. package/node/DataGrid/DataGrid.js +10 -1
  78. package/node/components/GridColumnHeaders.js +1 -1
  79. package/node/{utils/fastMemo.js → components/GridConfigurationContext.js} +4 -4
  80. package/node/components/GridHeaders.js +1 -1
  81. package/node/components/GridRow.js +6 -8
  82. package/node/components/GridScrollArea.js +1 -1
  83. package/node/components/GridSkeletonLoadingOverlay.js +1 -1
  84. package/node/components/cell/GridCell.js +1 -1
  85. package/node/components/cell/GridSkeletonCell.js +2 -2
  86. package/node/components/columnHeaders/GridColumnHeaderItem.js +1 -1
  87. package/node/components/containers/GridRootStyles.js +9 -2
  88. package/node/components/virtualization/GridMainContainer.js +3 -2
  89. package/node/components/virtualization/GridVirtualScrollerFiller.js +1 -1
  90. package/node/context/GridContextProvider.js +12 -7
  91. package/node/hooks/core/useGridStateInitialization.js +1 -3
  92. package/node/hooks/features/dimensions/useGridDimensions.js +1 -1
  93. package/node/hooks/features/export/serializers/csvSerializer.js +4 -3
  94. package/node/hooks/features/filter/gridFilterSelector.js +35 -1
  95. package/node/hooks/features/filter/index.js +97 -15
  96. package/node/hooks/features/filter/useGridFilter.js +3 -0
  97. package/node/hooks/features/rowSelection/useGridRowSelection.js +4 -1
  98. package/node/hooks/features/rows/useGridRowAriaAttributes.js +28 -0
  99. package/node/hooks/utils/useGridAriaAttributes.js +4 -7
  100. package/node/hooks/utils/useGridConfiguration.js +18 -0
  101. package/node/hooks/utils/useGridSelector.js +1 -1
  102. package/node/index.js +1 -1
  103. package/node/internals/index.js +31 -12
  104. package/node/locales/viVN.js +4 -5
  105. package/node/models/configuration/gridConfiguration.js +5 -0
  106. package/node/models/configuration/gridRowConfiguration.js +5 -0
  107. package/package.json +2 -2
  108. package/modern/utils/fastMemo.js +0 -5
  109. package/modern/utils/fastObjectShallowCompare.js +0 -28
  110. package/modern/utils/throttle.js +0 -19
  111. package/node/utils/fastObjectShallowCompare.js +0 -34
  112. package/node/utils/throttle.js +0 -25
  113. package/utils/fastMemo.d.ts +0 -1
  114. package/utils/fastMemo.js +0 -5
  115. package/utils/fastObjectShallowCompare.d.ts +0 -1
  116. package/utils/fastObjectShallowCompare.js +0 -28
  117. package/utils/throttle.d.ts +0 -4
  118. package/utils/throttle.js +0 -19
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+ import { selectedIdsLookupSelector } from '../rowSelection';
3
+ import { useGridSelector } from '../../utils/useGridSelector';
4
+ import { gridColumnGroupsHeaderMaxDepthSelector } from '../columnGrouping/gridColumnGroupsSelector';
5
+ import { useGridPrivateApiContext } from '../../utils/useGridPrivateApiContext';
6
+ export const useGridRowAriaAttributes = () => {
7
+ const apiRef = useGridPrivateApiContext();
8
+ const selectedIdsLookup = useGridSelector(apiRef, selectedIdsLookupSelector);
9
+ const headerGroupingMaxDepth = useGridSelector(apiRef, gridColumnGroupsHeaderMaxDepthSelector);
10
+ return React.useCallback((rowNode, index) => {
11
+ const ariaAttributes = {};
12
+ const ariaRowIndex = index + headerGroupingMaxDepth + 2; // 1 for the header row and 1 as it's 1-based
13
+ ariaAttributes['aria-rowindex'] = ariaRowIndex;
14
+ if (apiRef.current.isRowSelectable(rowNode.id)) {
15
+ ariaAttributes['aria-selected'] = selectedIdsLookup[rowNode.id] !== undefined;
16
+ }
17
+ return ariaAttributes;
18
+ }, [apiRef, selectedIdsLookup, headerGroupingMaxDepth]);
19
+ };
@@ -1,6 +1,2 @@
1
- export declare const useGridAriaAttributes: () => {
2
- role: string;
3
- 'aria-colcount': number;
4
- 'aria-rowcount': number;
5
- 'aria-multiselectable': boolean;
6
- };
1
+ import * as React from 'react';
2
+ export declare const useGridAriaAttributes: () => React.HTMLAttributes<HTMLElement>;
@@ -2,24 +2,21 @@ import { gridVisibleColumnDefinitionsSelector } from '../features/columns/gridCo
2
2
  import { useGridSelector } from './useGridSelector';
3
3
  import { useGridRootProps } from './useGridRootProps';
4
4
  import { gridColumnGroupsHeaderMaxDepthSelector } from '../features/columnGrouping/gridColumnGroupsSelector';
5
- import { gridPinnedRowsCountSelector, gridRowCountSelector } from '../features/rows/gridRowsSelector';
5
+ import { gridPinnedRowsCountSelector } from '../features/rows/gridRowsSelector';
6
6
  import { useGridPrivateApiContext } from './useGridPrivateApiContext';
7
7
  import { isMultipleRowSelectionEnabled } from '../features/rowSelection/utils';
8
+ import { gridExpandedRowCountSelector } from '../features/filter/gridFilterSelector';
8
9
  export const useGridAriaAttributes = () => {
9
10
  const apiRef = useGridPrivateApiContext();
10
11
  const rootProps = useGridRootProps();
11
12
  const visibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
12
- const totalRowCount = useGridSelector(apiRef, gridRowCountSelector);
13
+ const accessibleRowCount = useGridSelector(apiRef, gridExpandedRowCountSelector);
13
14
  const headerGroupingMaxDepth = useGridSelector(apiRef, gridColumnGroupsHeaderMaxDepthSelector);
14
15
  const pinnedRowsCount = useGridSelector(apiRef, gridPinnedRowsCountSelector);
15
- let role = 'grid';
16
- if (rootProps.treeData) {
17
- role = 'treegrid';
18
- }
19
16
  return {
20
- role,
17
+ role: 'grid',
21
18
  'aria-colcount': visibleColumns.length,
22
- 'aria-rowcount': headerGroupingMaxDepth + 1 + pinnedRowsCount + totalRowCount,
19
+ 'aria-rowcount': headerGroupingMaxDepth + 1 + pinnedRowsCount + accessibleRowCount,
23
20
  'aria-multiselectable': isMultipleRowSelectionEnabled(rootProps)
24
21
  };
25
22
  };
@@ -0,0 +1,2 @@
1
+ import { GridConfiguration } from '../../models/configuration/gridConfiguration';
2
+ export declare const useGridConfiguration: () => GridConfiguration;
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ import { GridConfigurationContext } from '../../components/GridConfigurationContext';
3
+ export const useGridConfiguration = () => {
4
+ const configuration = React.useContext(GridConfigurationContext);
5
+ if (configuration === undefined) {
6
+ throw new Error(['MUI X: Could not find the data grid configuration context.', 'It looks like you rendered your component outside of a DataGrid, DataGridPro or DataGridPremium parent component.', 'This can also happen if you are bundling multiple versions of the data grid.'].join('\n'));
7
+ }
8
+ return configuration;
9
+ };
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
+ import { fastObjectShallowCompare } from '@mui/x-internals/fastObjectShallowCompare';
2
3
  import type { GridApiCommon } from '../../models/api/gridApiCommon';
3
4
  import { OutputSelector } from '../../utils/createSelector';
4
- import { fastObjectShallowCompare } from '../../utils/fastObjectShallowCompare';
5
5
  export declare const objectShallowCompare: typeof fastObjectShallowCompare;
6
6
  export declare const useGridSelector: <Api extends GridApiCommon, T>(apiRef: React.MutableRefObject<Api>, selector: ((state: Api["state"]) => T) | OutputSelector<Api["state"], T>, equals?: (a: T, b: T) => boolean) => T;
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
+ import { fastObjectShallowCompare } from '@mui/x-internals/fastObjectShallowCompare';
2
3
  import { useLazyRef } from './useLazyRef';
3
4
  import { useOnMount } from './useOnMount';
4
5
  import { warnOnce } from '../../internals/utils/warning';
5
- import { fastObjectShallowCompare } from '../../utils/fastObjectShallowCompare';
6
6
  function isOutputSelector(selector) {
7
7
  return selector.acceptsApiRef;
8
8
  }
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.12.1
2
+ * @mui/x-data-grid v7.13.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -31,6 +31,7 @@ export { useGridCsvExport } from '../hooks/features/export/useGridCsvExport';
31
31
  export { useGridPrintExport } from '../hooks/features/export/useGridPrintExport';
32
32
  export { useGridFilter, filterStateInitializer } from '../hooks/features/filter/useGridFilter';
33
33
  export { passFilterLogic } from '../hooks/features/filter/gridFilterUtils';
34
+ export { gridFilteredChildrenCountLookupSelector, gridExpandedSortedRowTreeLevelPositionLookupSelector, } from '../hooks/features/filter/gridFilterSelector';
34
35
  export { isSingleSelectColDef } from '../components/panel/filterPanel/filterPanelUtils';
35
36
  export type { GridAggregatedFilterItemApplier, GridAggregatedFilterItemApplierResult, } from '../hooks/features/filter/gridFilterState';
36
37
  export { useGridFocus, focusStateInitializer } from '../hooks/features/focus/useGridFocus';
@@ -40,6 +41,8 @@ export { useGridPreferencesPanel, preferencePanelStateInitializer, } from '../ho
40
41
  export { useGridEditing, editingStateInitializer } from '../hooks/features/editing/useGridEditing';
41
42
  export { gridEditRowsStateSelector } from '../hooks/features/editing/gridEditingSelectors';
42
43
  export { useGridRows, rowsStateInitializer } from '../hooks/features/rows/useGridRows';
44
+ export { useGridAriaAttributes } from '../hooks/utils/useGridAriaAttributes';
45
+ export { useGridRowAriaAttributes } from '../hooks/features/rows/useGridRowAriaAttributes';
43
46
  export { useGridRowsPreProcessors } from '../hooks/features/rows/useGridRowsPreProcessors';
44
47
  export type { GridRowTreeCreationParams, GridRowTreeCreationValue, GridHydrateRowsValue, GridRowsPartialUpdates, GridRowsPartialUpdateAction, GridTreeDepths, GridRowTreeUpdatedGroupsManager, GridRowTreeUpdateGroupAction, GridPinnedRowsState, } from '../hooks/features/rows/gridRowsInterfaces';
45
48
  export { getTreeNodeDescendants, buildRootGroup } from '../hooks/features/rows/gridRowsUtils';
@@ -74,7 +77,6 @@ export { gridRowGroupsToFetchSelector } from '../hooks/features/rows/gridRowsSel
74
77
  export { findParentElementFromClassName, getActiveElement, isEventTargetInPortal, } from '../utils/domUtils';
75
78
  export { isNavigationKey, isPasteShortcut } from '../utils/keyboardUtils';
76
79
  export * from '../utils/utils';
77
- export * from '../utils/fastMemo';
78
80
  export { exportAs } from '../utils/exportAs';
79
81
  export * from '../utils/getPublicApiRef';
80
82
  export * from '../utils/cellBorderUtils';
@@ -23,6 +23,7 @@ export { useGridCsvExport } from '../hooks/features/export/useGridCsvExport';
23
23
  export { useGridPrintExport } from '../hooks/features/export/useGridPrintExport';
24
24
  export { useGridFilter, filterStateInitializer } from '../hooks/features/filter/useGridFilter';
25
25
  export { passFilterLogic } from '../hooks/features/filter/gridFilterUtils';
26
+ export { gridFilteredChildrenCountLookupSelector, gridExpandedSortedRowTreeLevelPositionLookupSelector } from '../hooks/features/filter/gridFilterSelector';
26
27
  export { isSingleSelectColDef } from '../components/panel/filterPanel/filterPanelUtils';
27
28
  export { useGridFocus, focusStateInitializer } from '../hooks/features/focus/useGridFocus';
28
29
  export { useGridKeyboardNavigation } from '../hooks/features/keyboardNavigation/useGridKeyboardNavigation';
@@ -31,6 +32,8 @@ export { useGridPreferencesPanel, preferencePanelStateInitializer } from '../hoo
31
32
  export { useGridEditing, editingStateInitializer } from '../hooks/features/editing/useGridEditing';
32
33
  export { gridEditRowsStateSelector } from '../hooks/features/editing/gridEditingSelectors';
33
34
  export { useGridRows, rowsStateInitializer } from '../hooks/features/rows/useGridRows';
35
+ export { useGridAriaAttributes } from '../hooks/utils/useGridAriaAttributes';
36
+ export { useGridRowAriaAttributes } from '../hooks/features/rows/useGridRowAriaAttributes';
34
37
  export { useGridRowsPreProcessors } from '../hooks/features/rows/useGridRowsPreProcessors';
35
38
  export { getTreeNodeDescendants, buildRootGroup } from '../hooks/features/rows/gridRowsUtils';
36
39
  export { useGridRowsMeta, rowsMetaStateInitializer } from '../hooks/features/rows/useGridRowsMeta';
@@ -59,7 +62,6 @@ export { gridRowGroupsToFetchSelector } from '../hooks/features/rows/gridRowsSel
59
62
  export { findParentElementFromClassName, getActiveElement, isEventTargetInPortal } from '../utils/domUtils';
60
63
  export { isNavigationKey, isPasteShortcut } from '../utils/keyboardUtils';
61
64
  export * from '../utils/utils';
62
- export * from '../utils/fastMemo';
63
65
  export { exportAs } from '../utils/exportAs';
64
66
  export * from '../utils/getPublicApiRef';
65
67
  export * from '../utils/cellBorderUtils';
package/locales/viVN.js CHANGED
@@ -30,11 +30,10 @@ const viVNGrid = {
30
30
  toolbarExportPrint: 'In',
31
31
  toolbarExportExcel: 'Xuất Excel',
32
32
  // Columns management text
33
- // columnsManagementSearchTitle: 'Search',
34
- // columnsManagementNoColumns: 'No columns',
35
- // columnsManagementShowHideAllText: 'Show/Hide All',
36
- // columnsManagementReset: 'Reset',
37
-
33
+ columnsManagementSearchTitle: 'Tìm kiếm',
34
+ columnsManagementNoColumns: 'Không có cột',
35
+ columnsManagementShowHideAllText: 'Hiện/Ẩn Tất cả',
36
+ columnsManagementReset: 'Đặt lại',
38
37
  // Filter panel text
39
38
  filterPanelAddFilter: 'Thêm bộ lọc',
40
39
  filterPanelRemoveAll: 'Xóa tất cả',
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { GridRowAriaAttributesInternalHook } from './gridRowConfiguration';
3
+ export interface GridAriaAttributesInternalHook {
4
+ useGridAriaAttributes: () => React.HTMLAttributes<HTMLElement>;
5
+ }
6
+ export interface GridInternalHook extends GridAriaAttributesInternalHook, GridRowAriaAttributesInternalHook {
7
+ }
8
+ export interface GridConfiguration {
9
+ hooks: GridInternalHook;
10
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { GridTreeNode } from '../gridRows';
3
+ /**
4
+ * Get the ARIA attributes for a row
5
+ * @param {GridTreeNode} rowNode The row node
6
+ * @param {number} index The position index of the row
7
+ * @returns {React.HTMLAttributes<HTMLElement>} The ARIA attributes
8
+ */
9
+ export type GetRowAriaAttributesFn = (rowNode: GridTreeNode, index: number) => React.HTMLAttributes<HTMLElement>;
10
+ export interface GridRowAriaAttributesInternalHook {
11
+ useGridRowAriaAttributes: () => GetRowAriaAttributesFn;
12
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -63,7 +63,8 @@ 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
  }
@@ -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
  */
@@ -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';
@@ -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
  }
@@ -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;
@@ -32,6 +32,12 @@ export const gridVisibleRowsLookupSelector = state => state.visibleRowsLookup;
32
32
  */
33
33
  export const gridFilteredRowsLookupSelector = createSelector(gridFilterStateSelector, filterState => filterState.filteredRowsLookup);
34
34
 
35
+ /**
36
+ * @category Filtering
37
+ * @ignore - do not document.
38
+ */
39
+ export const gridFilteredChildrenCountLookupSelector = createSelector(gridFilterStateSelector, filterState => filterState.filteredChildrenCountLookup);
40
+
35
41
  /**
36
42
  * @category Filtering
37
43
  * @ignore - do not document.
@@ -66,6 +72,34 @@ export const gridFilteredSortedRowEntriesSelector = createSelectorMemoized(gridF
66
72
  */
67
73
  export const gridFilteredSortedRowIdsSelector = createSelectorMemoized(gridFilteredSortedRowEntriesSelector, filteredSortedRowEntries => filteredSortedRowEntries.map(row => row.id));
68
74
 
75
+ /**
76
+ * Get the ids to position in the current tree level lookup of the rows accessible after the filtering process.
77
+ * Does not contain the collapsed children.
78
+ * @category Filtering
79
+ * @ignore - do not document.
80
+ */
81
+ export const gridExpandedSortedRowTreeLevelPositionLookupSelector = createSelectorMemoized(gridExpandedSortedRowIdsSelector, gridRowTreeSelector, (visibleSortedRowIds, rowTree) => {
82
+ const depthPositionCounter = {};
83
+ let lastDepth = 0;
84
+ return visibleSortedRowIds.reduce((acc, rowId) => {
85
+ const rowNode = rowTree[rowId];
86
+ if (!depthPositionCounter[rowNode.depth]) {
87
+ depthPositionCounter[rowNode.depth] = 0;
88
+ }
89
+
90
+ // going deeper in the tree should reset the counter
91
+ // since it might have been used in some other branch at the same level, up in the tree
92
+ // going back up should keep the counter and continue where it left off
93
+ if (rowNode.depth > lastDepth) {
94
+ depthPositionCounter[rowNode.depth] = 0;
95
+ }
96
+ lastDepth = rowNode.depth;
97
+ depthPositionCounter[rowNode.depth] += 1;
98
+ acc[rowId] = depthPositionCounter[rowNode.depth];
99
+ return acc;
100
+ }, {});
101
+ });
102
+
69
103
  /**
70
104
  * Get the id and the model of the top level rows accessible after the filtering process.
71
105
  * @category Filtering
@@ -1,2 +1,2 @@
1
1
  export { getDefaultGridFilterModel } from './gridFilterState';
2
- export * from './gridFilterSelector';
2
+ export { gridFilterModelSelector, gridQuickFilterValuesSelector, gridVisibleRowsLookupSelector, gridFilteredRowsLookupSelector, gridFilteredDescendantCountLookupSelector, gridExpandedSortedRowEntriesSelector, gridExpandedSortedRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector, gridFilteredSortedTopLevelRowEntriesSelector, gridExpandedRowCountSelector, gridFilteredTopLevelRowCountSelector, gridFilteredRowCountSelector, gridFilteredDescendantRowCountSelector, gridFilterActiveItemsSelector, gridFilterActiveItemsLookupSelector } from './gridFilterSelector';