@mui/x-data-grid-pro 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.
- package/CHANGELOG.md +162 -1
- package/DataGridPro/DataGridPro.js +10 -1
- package/components/GridDataSourceTreeDataGroupingCell.js +4 -4
- package/components/headerFiltering/GridHeaderFilterCell.js +2 -1
- package/esm/DataGridPro/DataGridPro.js +10 -1
- package/esm/components/GridDataSourceTreeDataGroupingCell.js +4 -4
- package/esm/components/headerFiltering/GridHeaderFilterCell.js +2 -1
- package/esm/hooks/features/dataSource/gridDataSourceSelector.js +4 -2
- package/esm/hooks/features/rows/index.js +1 -0
- package/esm/hooks/features/rows/useGridRowAriaAttributes.js +37 -0
- package/esm/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.js +1 -1
- package/esm/hooks/features/serverSideTreeData/utils.js +3 -0
- package/esm/hooks/features/treeData/gridTreeDataUtils.js +7 -0
- package/esm/hooks/utils/useGridAriaAttributes.js +11 -0
- package/esm/internals/index.js +7 -1
- package/esm/utils/releaseInfo.js +1 -1
- package/esm/utils/tree/createRowTree.js +1 -1
- package/esm/utils/tree/insertDataRowInTree.js +3 -3
- package/esm/utils/tree/updateRowTree.js +4 -4
- package/hooks/features/dataSource/gridDataSourceSelector.d.ts +5 -3
- package/hooks/features/dataSource/gridDataSourceSelector.js +4 -2
- package/hooks/features/rows/index.d.ts +1 -0
- package/hooks/features/rows/index.js +16 -0
- package/hooks/features/rows/useGridRowAriaAttributes.d.ts +3 -0
- package/hooks/features/rows/useGridRowAriaAttributes.js +46 -0
- package/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.js +1 -1
- package/hooks/features/serverSideTreeData/utils.d.ts +1 -0
- package/hooks/features/serverSideTreeData/utils.js +3 -0
- package/hooks/features/treeData/gridTreeDataUtils.js +7 -0
- package/hooks/utils/useGridAriaAttributes.d.ts +2 -0
- package/hooks/utils/useGridAriaAttributes.js +19 -0
- package/index.js +1 -1
- package/internals/index.d.ts +2 -0
- package/internals/index.js +16 -0
- package/models/dataGridProProps.d.ts +1 -1
- package/modern/DataGridPro/DataGridPro.js +10 -1
- package/modern/components/GridDataSourceTreeDataGroupingCell.js +4 -4
- package/modern/components/headerFiltering/GridHeaderFilterCell.js +2 -1
- package/modern/hooks/features/dataSource/gridDataSourceSelector.js +4 -2
- package/modern/hooks/features/rows/index.js +1 -0
- package/modern/hooks/features/rows/useGridRowAriaAttributes.js +37 -0
- package/modern/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.js +1 -1
- package/modern/hooks/features/serverSideTreeData/utils.js +3 -0
- package/modern/hooks/features/treeData/gridTreeDataUtils.js +7 -0
- package/modern/hooks/utils/useGridAriaAttributes.js +11 -0
- package/modern/index.js +1 -1
- package/modern/internals/index.js +7 -1
- package/modern/utils/releaseInfo.js +1 -1
- package/modern/utils/tree/createRowTree.js +1 -1
- package/modern/utils/tree/insertDataRowInTree.js +3 -3
- package/modern/utils/tree/updateRowTree.js +4 -4
- package/package.json +6 -6
- package/utils/releaseInfo.js +1 -1
- package/utils/tree/createRowTree.js +1 -1
- package/utils/tree/insertDataRowInTree.d.ts +2 -2
- package/utils/tree/insertDataRowInTree.js +3 -3
- package/utils/tree/models.d.ts +1 -1
- package/utils/tree/updateRowTree.js +4 -4
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useGridRowAriaAttributes = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _xDataGrid = require("@mui/x-data-grid");
|
|
9
|
+
var _internals = require("@mui/x-data-grid/internals");
|
|
10
|
+
var _useGridPrivateApiContext = require("../../utils/useGridPrivateApiContext");
|
|
11
|
+
var _useGridRootProps = require("../../utils/useGridRootProps");
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
|
+
const useGridRowAriaAttributes = addTreeDataAttributes => {
|
|
15
|
+
const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
|
|
16
|
+
const props = (0, _useGridRootProps.useGridRootProps)();
|
|
17
|
+
const getRowAriaAttributesCommunity = (0, _internals.useGridRowAriaAttributes)();
|
|
18
|
+
const filteredTopLevelRowCount = (0, _xDataGrid.useGridSelector)(apiRef, _xDataGrid.gridFilteredTopLevelRowCountSelector);
|
|
19
|
+
const filteredChildrenCountLookup = (0, _xDataGrid.useGridSelector)(apiRef, _internals.gridFilteredChildrenCountLookupSelector);
|
|
20
|
+
const sortedVisibleRowPositionsLookup = (0, _xDataGrid.useGridSelector)(apiRef, _internals.gridExpandedSortedRowTreeLevelPositionLookupSelector);
|
|
21
|
+
return React.useCallback((rowNode, index) => {
|
|
22
|
+
const ariaAttributes = getRowAriaAttributesCommunity(rowNode, index);
|
|
23
|
+
if (rowNode === null || !(props.treeData || addTreeDataAttributes)) {
|
|
24
|
+
return ariaAttributes;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// pinned and footer rows are not part of the rowgroup and should not get the set specific aria attributes
|
|
28
|
+
if (rowNode.type === 'footer' || rowNode.type === 'pinnedRow') {
|
|
29
|
+
return ariaAttributes;
|
|
30
|
+
}
|
|
31
|
+
ariaAttributes['aria-level'] = rowNode.depth + 1;
|
|
32
|
+
const filteredChildrenCount = filteredChildrenCountLookup[rowNode.id] ?? 0;
|
|
33
|
+
// aria-expanded should only be added to the rows that contain children
|
|
34
|
+
if (rowNode.type === 'group' && filteredChildrenCount > 0) {
|
|
35
|
+
ariaAttributes['aria-expanded'] = Boolean(rowNode.childrenExpanded);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// if the parent is null, set size and position cannot be determined
|
|
39
|
+
if (rowNode.parent !== null) {
|
|
40
|
+
ariaAttributes['aria-setsize'] = rowNode.parent === _xDataGrid.GRID_ROOT_GROUP_ID ? filteredTopLevelRowCount : filteredChildrenCountLookup[rowNode.parent];
|
|
41
|
+
ariaAttributes['aria-posinset'] = sortedVisibleRowPositionsLookup[rowNode.id];
|
|
42
|
+
}
|
|
43
|
+
return ariaAttributes;
|
|
44
|
+
}, [props.treeData, addTreeDataAttributes, filteredTopLevelRowCount, filteredChildrenCountLookup, sortedVisibleRowPositionsLookup, getRowAriaAttributesCommunity]);
|
|
45
|
+
};
|
|
46
|
+
exports.useGridRowAriaAttributes = useGridRowAriaAttributes;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { GridRowId, GridRowTreeConfig } from '@mui/x-data-grid';
|
|
2
2
|
export declare function skipFiltering(rowTree: GridRowTreeConfig): {
|
|
3
3
|
filteredRowsLookup: Record<GridRowId, boolean>;
|
|
4
|
+
filteredChildrenCountLookup: Record<GridRowId, number>;
|
|
4
5
|
filteredDescendantCountLookup: Record<GridRowId, number>;
|
|
5
6
|
};
|
|
6
7
|
export declare function skipSorting(rowTree: GridRowTreeConfig): GridRowId[];
|
|
@@ -9,14 +9,17 @@ var _xDataGrid = require("@mui/x-data-grid");
|
|
|
9
9
|
var _internals = require("@mui/x-data-grid/internals");
|
|
10
10
|
function skipFiltering(rowTree) {
|
|
11
11
|
const filteredRowsLookup = {};
|
|
12
|
+
const filteredChildrenCountLookup = {};
|
|
12
13
|
const filteredDescendantCountLookup = {};
|
|
13
14
|
const nodes = Object.values(rowTree);
|
|
14
15
|
for (let i = 0; i < nodes.length; i += 1) {
|
|
15
16
|
const node = nodes[i];
|
|
16
17
|
filteredRowsLookup[node.id] = true;
|
|
18
|
+
filteredChildrenCountLookup[node.id] = node.serverChildrenCount ?? 0;
|
|
17
19
|
}
|
|
18
20
|
return {
|
|
19
21
|
filteredRowsLookup,
|
|
22
|
+
filteredChildrenCountLookup,
|
|
20
23
|
filteredDescendantCountLookup
|
|
21
24
|
};
|
|
22
25
|
}
|
|
@@ -20,6 +20,7 @@ const filterRowTreeFromTreeData = params => {
|
|
|
20
20
|
isRowMatchingFilters
|
|
21
21
|
} = params;
|
|
22
22
|
const filteredRowsLookup = {};
|
|
23
|
+
const filteredChildrenCountLookup = {};
|
|
23
24
|
const filteredDescendantCountLookup = {};
|
|
24
25
|
const filterCache = {};
|
|
25
26
|
const filterResults = {
|
|
@@ -38,12 +39,16 @@ const filterRowTreeFromTreeData = params => {
|
|
|
38
39
|
isRowMatchingFilters(row, undefined, filterResults);
|
|
39
40
|
isMatchingFilters = (0, _internals.passFilterLogic)([filterResults.passingFilterItems], [filterResults.passingQuickFilterValues], params.filterModel, params.apiRef, filterCache);
|
|
40
41
|
}
|
|
42
|
+
let filteredChildrenCount = 0;
|
|
41
43
|
let filteredDescendantCount = 0;
|
|
42
44
|
if (node.type === 'group') {
|
|
43
45
|
node.children.forEach(childId => {
|
|
44
46
|
const childNode = rowTree[childId];
|
|
45
47
|
const childSubTreeSize = filterTreeNode(childNode, isMatchingFilters ?? isParentMatchingFilters, areAncestorsExpanded && !!node.childrenExpanded);
|
|
46
48
|
filteredDescendantCount += childSubTreeSize;
|
|
49
|
+
if (childSubTreeSize > 0) {
|
|
50
|
+
filteredChildrenCount += 1;
|
|
51
|
+
}
|
|
47
52
|
});
|
|
48
53
|
}
|
|
49
54
|
let shouldPassFilters;
|
|
@@ -68,6 +73,7 @@ const filterRowTreeFromTreeData = params => {
|
|
|
68
73
|
if (!shouldPassFilters) {
|
|
69
74
|
return 0;
|
|
70
75
|
}
|
|
76
|
+
filteredChildrenCountLookup[node.id] = filteredChildrenCount;
|
|
71
77
|
filteredDescendantCountLookup[node.id] = filteredDescendantCount;
|
|
72
78
|
if (node.type === 'footer') {
|
|
73
79
|
return filteredDescendantCount;
|
|
@@ -83,6 +89,7 @@ const filterRowTreeFromTreeData = params => {
|
|
|
83
89
|
}
|
|
84
90
|
return {
|
|
85
91
|
filteredRowsLookup,
|
|
92
|
+
filteredChildrenCountLookup,
|
|
86
93
|
filteredDescendantCountLookup
|
|
87
94
|
};
|
|
88
95
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useGridAriaAttributes = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _internals = require("@mui/x-data-grid/internals");
|
|
10
|
+
var _useGridRootProps = require("./useGridRootProps");
|
|
11
|
+
const useGridAriaAttributes = () => {
|
|
12
|
+
const ariaAttributesCommunity = (0, _internals.useGridAriaAttributes)();
|
|
13
|
+
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
14
|
+
const ariaAttributesPro = rootProps.treeData ? {
|
|
15
|
+
role: 'treegrid'
|
|
16
|
+
} : {};
|
|
17
|
+
return (0, _extends2.default)({}, ariaAttributesCommunity, ariaAttributesPro);
|
|
18
|
+
};
|
|
19
|
+
exports.useGridAriaAttributes = useGridAriaAttributes;
|
package/index.js
CHANGED
package/internals/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export * from '@mui/x-data-grid/internals';
|
|
|
2
2
|
export { GridColumnHeaders } from '../components/GridColumnHeaders';
|
|
3
3
|
export { DATA_GRID_PRO_DEFAULT_SLOTS_COMPONENTS } from '../constants/dataGridProDefaultSlotsComponents';
|
|
4
4
|
export { useGridColumnHeaders } from '../hooks/features/columnHeaders/useGridColumnHeaders';
|
|
5
|
+
export { useGridAriaAttributes } from '../hooks/utils/useGridAriaAttributes';
|
|
6
|
+
export { useGridRowAriaAttributes } from '../hooks/features/rows/useGridRowAriaAttributes';
|
|
5
7
|
export { useGridColumnPinning, columnPinningStateInitializer, } from '../hooks/features/columnPinning/useGridColumnPinning';
|
|
6
8
|
export { useGridColumnPinningPreProcessors } from '../hooks/features/columnPinning/useGridColumnPinningPreProcessors';
|
|
7
9
|
export { useGridColumnReorder, columnReorderStateInitializer, } from '../hooks/features/columnReorder/useGridColumnReorder';
|
package/internals/index.js
CHANGED
|
@@ -7,6 +7,8 @@ var _exportNames = {
|
|
|
7
7
|
GridColumnHeaders: true,
|
|
8
8
|
DATA_GRID_PRO_DEFAULT_SLOTS_COMPONENTS: true,
|
|
9
9
|
useGridColumnHeaders: true,
|
|
10
|
+
useGridAriaAttributes: true,
|
|
11
|
+
useGridRowAriaAttributes: true,
|
|
10
12
|
useGridColumnPinning: true,
|
|
11
13
|
columnPinningStateInitializer: true,
|
|
12
14
|
useGridColumnPinningPreProcessors: true,
|
|
@@ -127,6 +129,12 @@ Object.defineProperty(exports, "updateRowTree", {
|
|
|
127
129
|
return _updateRowTree.updateRowTree;
|
|
128
130
|
}
|
|
129
131
|
});
|
|
132
|
+
Object.defineProperty(exports, "useGridAriaAttributes", {
|
|
133
|
+
enumerable: true,
|
|
134
|
+
get: function () {
|
|
135
|
+
return _useGridAriaAttributes.useGridAriaAttributes;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
130
138
|
Object.defineProperty(exports, "useGridColumnHeaders", {
|
|
131
139
|
enumerable: true,
|
|
132
140
|
get: function () {
|
|
@@ -193,6 +201,12 @@ Object.defineProperty(exports, "useGridLazyLoaderPreProcessors", {
|
|
|
193
201
|
return _useGridLazyLoaderPreProcessors.useGridLazyLoaderPreProcessors;
|
|
194
202
|
}
|
|
195
203
|
});
|
|
204
|
+
Object.defineProperty(exports, "useGridRowAriaAttributes", {
|
|
205
|
+
enumerable: true,
|
|
206
|
+
get: function () {
|
|
207
|
+
return _useGridRowAriaAttributes.useGridRowAriaAttributes;
|
|
208
|
+
}
|
|
209
|
+
});
|
|
196
210
|
Object.defineProperty(exports, "useGridRowPinning", {
|
|
197
211
|
enumerable: true,
|
|
198
212
|
get: function () {
|
|
@@ -244,6 +258,8 @@ Object.keys(_internals).forEach(function (key) {
|
|
|
244
258
|
var _GridColumnHeaders = require("../components/GridColumnHeaders");
|
|
245
259
|
var _dataGridProDefaultSlotsComponents = require("../constants/dataGridProDefaultSlotsComponents");
|
|
246
260
|
var _useGridColumnHeaders = require("../hooks/features/columnHeaders/useGridColumnHeaders");
|
|
261
|
+
var _useGridAriaAttributes = require("../hooks/utils/useGridAriaAttributes");
|
|
262
|
+
var _useGridRowAriaAttributes = require("../hooks/features/rows/useGridRowAriaAttributes");
|
|
247
263
|
var _useGridColumnPinning = require("../hooks/features/columnPinning/useGridColumnPinning");
|
|
248
264
|
var _useGridColumnPinningPreProcessors = require("../hooks/features/columnPinning/useGridColumnPinningPreProcessors");
|
|
249
265
|
var _useGridColumnReorder = require("../hooks/features/columnReorder/useGridColumnReorder");
|
|
@@ -112,7 +112,7 @@ interface DataGridProRegularProps<R extends GridValidRowModel> {
|
|
|
112
112
|
* @param {R} row The row from which we want the path.
|
|
113
113
|
* @returns {string[]} The path to the row.
|
|
114
114
|
*/
|
|
115
|
-
getTreeDataPath?: (row: R) => string[];
|
|
115
|
+
getTreeDataPath?: (row: R) => readonly string[];
|
|
116
116
|
}
|
|
117
117
|
export interface DataGridProPropsWithoutDefaultValue<R extends GridValidRowModel = any> extends Omit<DataGridPropsWithoutDefaultValue<R>, 'initialState' | 'componentsProps' | 'slotProps'>, DataGridProRegularProps<R>, DataGridProDataSourceProps, DataGridProSharedPropsWithoutDefaultValue {
|
|
118
118
|
/**
|
|
@@ -10,7 +10,15 @@ import { useDataGridProComponent } from './useDataGridProComponent';
|
|
|
10
10
|
import { useDataGridProProps } from './useDataGridProProps';
|
|
11
11
|
import { getReleaseInfo } from '../utils/releaseInfo';
|
|
12
12
|
import { propValidatorsDataGridPro } from '../internals/propValidation';
|
|
13
|
+
import { useGridAriaAttributes } from '../hooks/utils/useGridAriaAttributes';
|
|
14
|
+
import { useGridRowAriaAttributes } from '../hooks/features/rows/useGridRowAriaAttributes';
|
|
13
15
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
+
const configuration = {
|
|
17
|
+
hooks: {
|
|
18
|
+
useGridAriaAttributes,
|
|
19
|
+
useGridRowAriaAttributes
|
|
20
|
+
}
|
|
21
|
+
};
|
|
14
22
|
const releaseInfo = getReleaseInfo();
|
|
15
23
|
const DataGridProRaw = /*#__PURE__*/React.forwardRef(function DataGridPro(inProps, ref) {
|
|
16
24
|
const props = useDataGridProProps(inProps);
|
|
@@ -21,6 +29,7 @@ const DataGridProRaw = /*#__PURE__*/React.forwardRef(function DataGridPro(inProp
|
|
|
21
29
|
}
|
|
22
30
|
return /*#__PURE__*/_jsx(GridContextProvider, {
|
|
23
31
|
privateApiRef: privateApiRef,
|
|
32
|
+
configuration: configuration,
|
|
24
33
|
props: props,
|
|
25
34
|
children: /*#__PURE__*/_jsxs(GridRoot, _extends({
|
|
26
35
|
className: props.className,
|
|
@@ -412,7 +421,7 @@ DataGridProRaw.propTypes = {
|
|
|
412
421
|
/**
|
|
413
422
|
* Determines if a row can be selected.
|
|
414
423
|
* @param {GridRowParams} params With all properties from [[GridRowParams]].
|
|
415
|
-
* @returns {boolean} A boolean indicating if the
|
|
424
|
+
* @returns {boolean} A boolean indicating if the row is selectable.
|
|
416
425
|
*/
|
|
417
426
|
isRowSelectable: PropTypes.func,
|
|
418
427
|
/**
|
|
@@ -4,9 +4,11 @@ import composeClasses from '@mui/utils/composeClasses';
|
|
|
4
4
|
import Box from '@mui/material/Box';
|
|
5
5
|
import Badge from '@mui/material/Badge';
|
|
6
6
|
import { getDataGridUtilityClass, useGridSelector } from '@mui/x-data-grid';
|
|
7
|
+
import { useGridSelectorV8 } from '@mui/x-data-grid/internals';
|
|
7
8
|
import CircularProgress from '@mui/material/CircularProgress';
|
|
8
9
|
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
9
10
|
import { useGridPrivateApiContext } from '../hooks/utils/useGridPrivateApiContext';
|
|
11
|
+
import { gridDataSourceErrorSelector, gridDataSourceLoadingIdSelector } from '../hooks/features/dataSource/gridDataSourceSelector';
|
|
10
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
13
|
const useUtilityClasses = ownerState => {
|
|
12
14
|
const {
|
|
@@ -29,10 +31,8 @@ function GridTreeDataGroupingCellIcon(props) {
|
|
|
29
31
|
field,
|
|
30
32
|
descendantCount
|
|
31
33
|
} = props;
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const isDataLoading = useGridSelector(apiRef, loadingSelector);
|
|
35
|
-
const error = useGridSelector(apiRef, errorSelector);
|
|
34
|
+
const isDataLoading = useGridSelectorV8(apiRef, gridDataSourceLoadingIdSelector, id);
|
|
35
|
+
const error = useGridSelectorV8(apiRef, gridDataSourceErrorSelector, id);
|
|
36
36
|
const handleClick = event => {
|
|
37
37
|
if (!rowNode.childrenExpanded) {
|
|
38
38
|
// always fetch/get from cache the children when the node is expanded
|
|
@@ -5,8 +5,9 @@ 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, unstable_composeClasses as composeClasses, unstable_capitalize as capitalize } from '@mui/utils';
|
|
8
|
+
import { fastMemo } from '@mui/x-internals/fastMemo';
|
|
8
9
|
import { gridVisibleColumnFieldsSelector, getDataGridUtilityClass, useGridSelector, gridFilterModelSelector, gridFilterableColumnLookupSelector } from '@mui/x-data-grid';
|
|
9
|
-
import {
|
|
10
|
+
import { useGridPrivateApiContext, gridHeaderFilteringEditFieldSelector, gridHeaderFilteringMenuSelector, isNavigationKey, shouldCellShowLeftBorder, shouldCellShowRightBorder } from '@mui/x-data-grid/internals';
|
|
10
11
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
11
12
|
import { GridHeaderFilterMenuContainer } from './GridHeaderFilterMenuContainer';
|
|
12
13
|
import { GridHeaderFilterClearButton } from './GridHeaderFilterClearButton';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { gridFilterModelSelector, gridSortModelSelector, gridPaginationModelSelector } from '@mui/x-data-grid';
|
|
3
|
-
import { createSelector } from '@mui/x-data-grid/internals';
|
|
3
|
+
import { createSelector, createSelectorV8 } from '@mui/x-data-grid/internals';
|
|
4
4
|
const computeStartEnd = paginationModel => {
|
|
5
5
|
const start = paginationModel.page * paginationModel.pageSize;
|
|
6
6
|
const end = start + paginationModel.pageSize - 1;
|
|
@@ -21,4 +21,6 @@ export const gridGetRowsParamsSelector = createSelector(gridFilterModelSelector,
|
|
|
21
21
|
});
|
|
22
22
|
export const gridDataSourceStateSelector = state => state.dataSource;
|
|
23
23
|
export const gridDataSourceLoadingSelector = createSelector(gridDataSourceStateSelector, dataSource => dataSource.loading);
|
|
24
|
-
export const
|
|
24
|
+
export const gridDataSourceLoadingIdSelector = createSelectorV8(gridDataSourceStateSelector, (dataSource, id) => dataSource.loading[id] ?? false);
|
|
25
|
+
export const gridDataSourceErrorsSelector = createSelector(gridDataSourceStateSelector, dataSource => dataSource.errors);
|
|
26
|
+
export const gridDataSourceErrorSelector = createSelectorV8(gridDataSourceStateSelector, (dataSource, id) => dataSource.errors[id]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useGridRowAriaAttributes';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useGridSelector, gridFilteredTopLevelRowCountSelector, GRID_ROOT_GROUP_ID } from '@mui/x-data-grid';
|
|
3
|
+
import { useGridRowAriaAttributes as useGridRowAriaAttributesCommunity, gridFilteredChildrenCountLookupSelector, gridExpandedSortedRowTreeLevelPositionLookupSelector } from '@mui/x-data-grid/internals';
|
|
4
|
+
import { useGridPrivateApiContext } from '../../utils/useGridPrivateApiContext';
|
|
5
|
+
import { useGridRootProps } from '../../utils/useGridRootProps';
|
|
6
|
+
export const useGridRowAriaAttributes = addTreeDataAttributes => {
|
|
7
|
+
const apiRef = useGridPrivateApiContext();
|
|
8
|
+
const props = useGridRootProps();
|
|
9
|
+
const getRowAriaAttributesCommunity = useGridRowAriaAttributesCommunity();
|
|
10
|
+
const filteredTopLevelRowCount = useGridSelector(apiRef, gridFilteredTopLevelRowCountSelector);
|
|
11
|
+
const filteredChildrenCountLookup = useGridSelector(apiRef, gridFilteredChildrenCountLookupSelector);
|
|
12
|
+
const sortedVisibleRowPositionsLookup = useGridSelector(apiRef, gridExpandedSortedRowTreeLevelPositionLookupSelector);
|
|
13
|
+
return React.useCallback((rowNode, index) => {
|
|
14
|
+
const ariaAttributes = getRowAriaAttributesCommunity(rowNode, index);
|
|
15
|
+
if (rowNode === null || !(props.treeData || addTreeDataAttributes)) {
|
|
16
|
+
return ariaAttributes;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// pinned and footer rows are not part of the rowgroup and should not get the set specific aria attributes
|
|
20
|
+
if (rowNode.type === 'footer' || rowNode.type === 'pinnedRow') {
|
|
21
|
+
return ariaAttributes;
|
|
22
|
+
}
|
|
23
|
+
ariaAttributes['aria-level'] = rowNode.depth + 1;
|
|
24
|
+
const filteredChildrenCount = filteredChildrenCountLookup[rowNode.id] ?? 0;
|
|
25
|
+
// aria-expanded should only be added to the rows that contain children
|
|
26
|
+
if (rowNode.type === 'group' && filteredChildrenCount > 0) {
|
|
27
|
+
ariaAttributes['aria-expanded'] = Boolean(rowNode.childrenExpanded);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// if the parent is null, set size and position cannot be determined
|
|
31
|
+
if (rowNode.parent !== null) {
|
|
32
|
+
ariaAttributes['aria-setsize'] = rowNode.parent === GRID_ROOT_GROUP_ID ? filteredTopLevelRowCount : filteredChildrenCountLookup[rowNode.parent];
|
|
33
|
+
ariaAttributes['aria-posinset'] = sortedVisibleRowPositionsLookup[rowNode.id];
|
|
34
|
+
}
|
|
35
|
+
return ariaAttributes;
|
|
36
|
+
}, [props.treeData, addTreeDataAttributes, filteredTopLevelRowCount, filteredChildrenCountLookup, sortedVisibleRowPositionsLookup, getRowAriaAttributesCommunity]);
|
|
37
|
+
};
|
|
@@ -2,14 +2,17 @@ import { GRID_ROOT_GROUP_ID } from '@mui/x-data-grid';
|
|
|
2
2
|
import { getTreeNodeDescendants } from '@mui/x-data-grid/internals';
|
|
3
3
|
export function skipFiltering(rowTree) {
|
|
4
4
|
const filteredRowsLookup = {};
|
|
5
|
+
const filteredChildrenCountLookup = {};
|
|
5
6
|
const filteredDescendantCountLookup = {};
|
|
6
7
|
const nodes = Object.values(rowTree);
|
|
7
8
|
for (let i = 0; i < nodes.length; i += 1) {
|
|
8
9
|
const node = nodes[i];
|
|
9
10
|
filteredRowsLookup[node.id] = true;
|
|
11
|
+
filteredChildrenCountLookup[node.id] = node.serverChildrenCount ?? 0;
|
|
10
12
|
}
|
|
11
13
|
return {
|
|
12
14
|
filteredRowsLookup,
|
|
15
|
+
filteredChildrenCountLookup,
|
|
13
16
|
filteredDescendantCountLookup
|
|
14
17
|
};
|
|
15
18
|
}
|
|
@@ -14,6 +14,7 @@ export const filterRowTreeFromTreeData = params => {
|
|
|
14
14
|
isRowMatchingFilters
|
|
15
15
|
} = params;
|
|
16
16
|
const filteredRowsLookup = {};
|
|
17
|
+
const filteredChildrenCountLookup = {};
|
|
17
18
|
const filteredDescendantCountLookup = {};
|
|
18
19
|
const filterCache = {};
|
|
19
20
|
const filterResults = {
|
|
@@ -32,12 +33,16 @@ export const filterRowTreeFromTreeData = params => {
|
|
|
32
33
|
isRowMatchingFilters(row, undefined, filterResults);
|
|
33
34
|
isMatchingFilters = passFilterLogic([filterResults.passingFilterItems], [filterResults.passingQuickFilterValues], params.filterModel, params.apiRef, filterCache);
|
|
34
35
|
}
|
|
36
|
+
let filteredChildrenCount = 0;
|
|
35
37
|
let filteredDescendantCount = 0;
|
|
36
38
|
if (node.type === 'group') {
|
|
37
39
|
node.children.forEach(childId => {
|
|
38
40
|
const childNode = rowTree[childId];
|
|
39
41
|
const childSubTreeSize = filterTreeNode(childNode, isMatchingFilters ?? isParentMatchingFilters, areAncestorsExpanded && !!node.childrenExpanded);
|
|
40
42
|
filteredDescendantCount += childSubTreeSize;
|
|
43
|
+
if (childSubTreeSize > 0) {
|
|
44
|
+
filteredChildrenCount += 1;
|
|
45
|
+
}
|
|
41
46
|
});
|
|
42
47
|
}
|
|
43
48
|
let shouldPassFilters;
|
|
@@ -62,6 +67,7 @@ export const filterRowTreeFromTreeData = params => {
|
|
|
62
67
|
if (!shouldPassFilters) {
|
|
63
68
|
return 0;
|
|
64
69
|
}
|
|
70
|
+
filteredChildrenCountLookup[node.id] = filteredChildrenCount;
|
|
65
71
|
filteredDescendantCountLookup[node.id] = filteredDescendantCount;
|
|
66
72
|
if (node.type === 'footer') {
|
|
67
73
|
return filteredDescendantCount;
|
|
@@ -77,6 +83,7 @@ export const filterRowTreeFromTreeData = params => {
|
|
|
77
83
|
}
|
|
78
84
|
return {
|
|
79
85
|
filteredRowsLookup,
|
|
86
|
+
filteredChildrenCountLookup,
|
|
80
87
|
filteredDescendantCountLookup
|
|
81
88
|
};
|
|
82
89
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { useGridAriaAttributes as useGridAriaAttributesCommunity } from '@mui/x-data-grid/internals';
|
|
3
|
+
import { useGridRootProps } from './useGridRootProps';
|
|
4
|
+
export const useGridAriaAttributes = () => {
|
|
5
|
+
const ariaAttributesCommunity = useGridAriaAttributesCommunity();
|
|
6
|
+
const rootProps = useGridRootProps();
|
|
7
|
+
const ariaAttributesPro = rootProps.treeData ? {
|
|
8
|
+
role: 'treegrid'
|
|
9
|
+
} : {};
|
|
10
|
+
return _extends({}, ariaAttributesCommunity, ariaAttributesPro);
|
|
11
|
+
};
|
package/modern/index.js
CHANGED
|
@@ -3,8 +3,14 @@ export * from '@mui/x-data-grid/internals';
|
|
|
3
3
|
export { GridColumnHeaders } from '../components/GridColumnHeaders';
|
|
4
4
|
export { DATA_GRID_PRO_DEFAULT_SLOTS_COMPONENTS } from '../constants/dataGridProDefaultSlotsComponents';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/* eslint-disable import/export --
|
|
7
|
+
* x-data-grid-pro internals that are overriding the x-data-grid internals
|
|
8
|
+
*/
|
|
7
9
|
export { useGridColumnHeaders } from '../hooks/features/columnHeaders/useGridColumnHeaders';
|
|
10
|
+
export { useGridAriaAttributes } from '../hooks/utils/useGridAriaAttributes';
|
|
11
|
+
export { useGridRowAriaAttributes } from '../hooks/features/rows/useGridRowAriaAttributes';
|
|
12
|
+
// eslint-enable import/export
|
|
13
|
+
|
|
8
14
|
export { useGridColumnPinning, columnPinningStateInitializer } from '../hooks/features/columnPinning/useGridColumnPinning';
|
|
9
15
|
export { useGridColumnPinningPreProcessors } from '../hooks/features/columnPinning/useGridColumnPinningPreProcessors';
|
|
10
16
|
export { useGridColumnReorder, columnReorderStateInitializer } from '../hooks/features/columnReorder/useGridColumnReorder';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTcyNDM2MDQwMDAwMA==";
|
|
4
4
|
if (process.env.NODE_ENV !== 'production') {
|
|
5
5
|
// A simple hack to set the value in the test environment (has no build step).
|
|
6
6
|
// eslint-disable-next-line no-useless-concat
|
|
@@ -19,7 +19,7 @@ export const createRowTree = params => {
|
|
|
19
19
|
previousTree: params.previousTree,
|
|
20
20
|
id: node.id,
|
|
21
21
|
path: node.path,
|
|
22
|
-
|
|
22
|
+
serverChildrenCount: node.serverChildrenCount,
|
|
23
23
|
onDuplicatePath: params.onDuplicatePath,
|
|
24
24
|
treeDepths,
|
|
25
25
|
isGroupExpandedByDefault: params.isGroupExpandedByDefault,
|
|
@@ -16,7 +16,7 @@ export const insertDataRowInTree = ({
|
|
|
16
16
|
onDuplicatePath,
|
|
17
17
|
isGroupExpandedByDefault,
|
|
18
18
|
defaultGroupingExpansionDepth,
|
|
19
|
-
|
|
19
|
+
serverChildrenCount,
|
|
20
20
|
groupsToFetch
|
|
21
21
|
}) => {
|
|
22
22
|
let parentNodeId = GRID_ROOT_GROUP_ID;
|
|
@@ -36,7 +36,7 @@ export const insertDataRowInTree = ({
|
|
|
36
36
|
// We create a leaf node for the data row.
|
|
37
37
|
if (existingNodeIdWithPartialPath == null) {
|
|
38
38
|
let node;
|
|
39
|
-
if (
|
|
39
|
+
if (serverChildrenCount !== undefined && serverChildrenCount !== 0) {
|
|
40
40
|
node = {
|
|
41
41
|
type: 'group',
|
|
42
42
|
id,
|
|
@@ -49,7 +49,7 @@ export const insertDataRowInTree = ({
|
|
|
49
49
|
children: [],
|
|
50
50
|
childrenFromPath: {},
|
|
51
51
|
childrenExpanded: false,
|
|
52
|
-
|
|
52
|
+
serverChildrenCount
|
|
53
53
|
};
|
|
54
54
|
const shouldFetchChildren = checkGroupChildrenExpansion(node, defaultGroupingExpansionDepth, isGroupExpandedByDefault);
|
|
55
55
|
if (shouldFetchChildren) {
|
|
@@ -13,7 +13,7 @@ export const updateRowTree = params => {
|
|
|
13
13
|
const {
|
|
14
14
|
id,
|
|
15
15
|
path,
|
|
16
|
-
|
|
16
|
+
serverChildrenCount
|
|
17
17
|
} = params.nodes.inserted[i];
|
|
18
18
|
insertDataRowInTree({
|
|
19
19
|
previousTree: params.previousTree,
|
|
@@ -22,7 +22,7 @@ export const updateRowTree = params => {
|
|
|
22
22
|
updatedGroupsManager,
|
|
23
23
|
id,
|
|
24
24
|
path,
|
|
25
|
-
|
|
25
|
+
serverChildrenCount,
|
|
26
26
|
onDuplicatePath: params.onDuplicatePath,
|
|
27
27
|
isGroupExpandedByDefault: params.isGroupExpandedByDefault,
|
|
28
28
|
defaultGroupingExpansionDepth: params.defaultGroupingExpansionDepth,
|
|
@@ -42,7 +42,7 @@ export const updateRowTree = params => {
|
|
|
42
42
|
const {
|
|
43
43
|
id,
|
|
44
44
|
path,
|
|
45
|
-
|
|
45
|
+
serverChildrenCount
|
|
46
46
|
} = params.nodes.modified[i];
|
|
47
47
|
const pathInPreviousTree = getNodePathInTree({
|
|
48
48
|
tree,
|
|
@@ -63,7 +63,7 @@ export const updateRowTree = params => {
|
|
|
63
63
|
updatedGroupsManager,
|
|
64
64
|
id,
|
|
65
65
|
path,
|
|
66
|
-
|
|
66
|
+
serverChildrenCount,
|
|
67
67
|
onDuplicatePath: params.onDuplicatePath,
|
|
68
68
|
isGroupExpandedByDefault: params.isGroupExpandedByDefault,
|
|
69
69
|
defaultGroupingExpansionDepth: params.defaultGroupingExpansionDepth,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-data-grid-pro",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.14.0",
|
|
4
4
|
"description": "The Pro plan edition of the Data Grid components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@babel/runtime": "^7.25.0",
|
|
37
|
-
"@mui/system": "^5.16.
|
|
38
|
-
"@mui/utils": "^5.16.
|
|
37
|
+
"@mui/system": "^5.16.7",
|
|
38
|
+
"@mui/utils": "^5.16.6",
|
|
39
39
|
"@types/format-util": "^1.0.4",
|
|
40
40
|
"clsx": "^2.1.1",
|
|
41
41
|
"prop-types": "^15.8.1",
|
|
42
42
|
"reselect": "^4.1.8",
|
|
43
|
-
"@mui/x-data-grid": "7.
|
|
44
|
-
"@mui/x-internals": "7.
|
|
45
|
-
"@mui/x-license": "7.
|
|
43
|
+
"@mui/x-data-grid": "7.14.0",
|
|
44
|
+
"@mui/x-internals": "7.14.0",
|
|
45
|
+
"@mui/x-license": "7.14.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@emotion/react": "^11.9.0",
|
package/utils/releaseInfo.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getReleaseInfo = void 0;
|
|
7
7
|
var _utils = require("@mui/utils");
|
|
8
8
|
const getReleaseInfo = () => {
|
|
9
|
-
const releaseInfo = "
|
|
9
|
+
const releaseInfo = "MTcyNDM2MDQwMDAwMA==";
|
|
10
10
|
if (process.env.NODE_ENV !== 'production') {
|
|
11
11
|
// A simple hack to set the value in the test environment (has no build step).
|
|
12
12
|
// eslint-disable-next-line no-useless-concat
|
|
@@ -25,7 +25,7 @@ const createRowTree = params => {
|
|
|
25
25
|
previousTree: params.previousTree,
|
|
26
26
|
id: node.id,
|
|
27
27
|
path: node.path,
|
|
28
|
-
|
|
28
|
+
serverChildrenCount: node.serverChildrenCount,
|
|
29
29
|
onDuplicatePath: params.onDuplicatePath,
|
|
30
30
|
treeDepths,
|
|
31
31
|
isGroupExpandedByDefault: params.isGroupExpandedByDefault,
|
|
@@ -44,7 +44,7 @@ interface InsertDataRowInTreeParams {
|
|
|
44
44
|
onDuplicatePath?: GridTreePathDuplicateHandler;
|
|
45
45
|
isGroupExpandedByDefault?: DataGridProProps['isGroupExpandedByDefault'];
|
|
46
46
|
defaultGroupingExpansionDepth: number;
|
|
47
|
-
|
|
47
|
+
serverChildrenCount?: number;
|
|
48
48
|
groupsToFetch?: Set<GridRowId>;
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
@@ -53,5 +53,5 @@ interface InsertDataRowInTreeParams {
|
|
|
53
53
|
* - if a node exists with the same partial path, it will register this node as the ancestor of the data row.
|
|
54
54
|
* - if not, it will create an auto-generated node and register it as ancestor of the data row.
|
|
55
55
|
*/
|
|
56
|
-
export declare const insertDataRowInTree: ({ id, path, updatedGroupsManager, previousTree, tree, treeDepths, onDuplicatePath, isGroupExpandedByDefault, defaultGroupingExpansionDepth,
|
|
56
|
+
export declare const insertDataRowInTree: ({ id, path, updatedGroupsManager, previousTree, tree, treeDepths, onDuplicatePath, isGroupExpandedByDefault, defaultGroupingExpansionDepth, serverChildrenCount, groupsToFetch, }: InsertDataRowInTreeParams) => void;
|
|
57
57
|
export {};
|
|
@@ -22,7 +22,7 @@ const insertDataRowInTree = ({
|
|
|
22
22
|
onDuplicatePath,
|
|
23
23
|
isGroupExpandedByDefault,
|
|
24
24
|
defaultGroupingExpansionDepth,
|
|
25
|
-
|
|
25
|
+
serverChildrenCount,
|
|
26
26
|
groupsToFetch
|
|
27
27
|
}) => {
|
|
28
28
|
let parentNodeId = _xDataGrid.GRID_ROOT_GROUP_ID;
|
|
@@ -42,7 +42,7 @@ const insertDataRowInTree = ({
|
|
|
42
42
|
// We create a leaf node for the data row.
|
|
43
43
|
if (existingNodeIdWithPartialPath == null) {
|
|
44
44
|
let node;
|
|
45
|
-
if (
|
|
45
|
+
if (serverChildrenCount !== undefined && serverChildrenCount !== 0) {
|
|
46
46
|
node = {
|
|
47
47
|
type: 'group',
|
|
48
48
|
id,
|
|
@@ -55,7 +55,7 @@ const insertDataRowInTree = ({
|
|
|
55
55
|
children: [],
|
|
56
56
|
childrenFromPath: {},
|
|
57
57
|
childrenExpanded: false,
|
|
58
|
-
|
|
58
|
+
serverChildrenCount
|
|
59
59
|
};
|
|
60
60
|
const shouldFetchChildren = (0, _utils.checkGroupChildrenExpansion)(node, defaultGroupingExpansionDepth, isGroupExpandedByDefault);
|
|
61
61
|
if (shouldFetchChildren) {
|