@mui/x-data-grid-pro 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.
- package/CHANGELOG.md +81 -0
- package/DataGridPro/DataGridPro.js +10 -1
- package/components/headerFiltering/GridHeaderFilterCell.js +2 -1
- package/esm/DataGridPro/DataGridPro.js +10 -1
- package/esm/components/headerFiltering/GridHeaderFilterCell.js +2 -1
- 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/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/modern/DataGridPro/DataGridPro.js +10 -1
- package/modern/components/headerFiltering/GridHeaderFilterCell.js +2 -1
- 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 +4 -4
- 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
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,87 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 7.13.0
|
|
7
|
+
|
|
8
|
+
_Aug 16, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 12 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 💫 Allow to [edit the label](https://mui.com/x/react-tree-view/rich-tree-view/editing/) of Tree View's items.
|
|
13
|
+
|
|
14
|
+
<img width="344" src="https://github.com/user-attachments/assets/1a6cf765-2dc8-4906-bd93-139086eed148" alt="Item label editing" />
|
|
15
|
+
|
|
16
|
+
- 🔧 Improve rows accessibility on the Data Grid features "Tree Data" and "Row Grouping". Certain "Row Grouping" accessibility updates will only be applied if experimental feature flag is enabled. See the [documentation](https://mui.com/x/react-data-grid/row-grouping/#accessibility-changes-in-v8) for more information.
|
|
17
|
+
- 🌍 Improve Vietnamese (vi-VN) locale on the Data Grid
|
|
18
|
+
- 🐞 Bugfixes
|
|
19
|
+
|
|
20
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
21
|
+
|
|
22
|
+
### Data Grid
|
|
23
|
+
|
|
24
|
+
#### `@mui/x-data-grid@7.13.0`
|
|
25
|
+
|
|
26
|
+
- [DataGrid] Fix CSV export for `null` and `undefined` values (#14166) @k-rajat19
|
|
27
|
+
- [DataGrid] Fix error logged during skeleton loading with nested data grid (#14186) @KenanYusuf
|
|
28
|
+
- [DataGrid] Remove needless check in `useGridStateInitialization` (#14181) @k-rajat19
|
|
29
|
+
- [DataGrid] Add recipe for persisting filters in local storage (#14208) @cherniavskii
|
|
30
|
+
- [l10n] Improve Vietnamese (vi-VN) locale (#14216) @hungnd-casso
|
|
31
|
+
|
|
32
|
+
#### `@mui/x-data-grid-pro@7.13.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
33
|
+
|
|
34
|
+
Same changes as in `@mui/x-data-grid@7.13.0`, plus:
|
|
35
|
+
|
|
36
|
+
- [DataGridPro] Fix Tree Data and Row Grouping rows accessibility (#13623) @arminmeh
|
|
37
|
+
|
|
38
|
+
#### `@mui/x-data-grid-premium@7.13.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
39
|
+
|
|
40
|
+
Same changes as in `@mui/x-data-grid-pro@7.13.0`.
|
|
41
|
+
|
|
42
|
+
### Date and Time Pickers
|
|
43
|
+
|
|
44
|
+
#### `@mui/x-date-pickers@7.13.0`
|
|
45
|
+
|
|
46
|
+
- [pickers] Fix date and time merging to retain milliseconds (#14173) @LukasTy
|
|
47
|
+
|
|
48
|
+
#### `@mui/x-date-pickers-pro@7.13.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
49
|
+
|
|
50
|
+
Same changes as in `@mui/x-date-pickers@7.13.0`.
|
|
51
|
+
|
|
52
|
+
### Charts
|
|
53
|
+
|
|
54
|
+
#### `@mui/x-charts@7.13.0`
|
|
55
|
+
|
|
56
|
+
- [charts] Add `baseline` property to the `LineChart` `series` (#14153) @JCQuintas
|
|
57
|
+
- [charts] Fix issue where tooltip would disappear on mouse click (#14187) @alexfauquette
|
|
58
|
+
- [charts] Rename `CartesianContextProvider` to `CartesianProvider` (#14102) @JCQuintas
|
|
59
|
+
- [charts] Support axis with the same value for all data points (#14191) @alexfauquette
|
|
60
|
+
|
|
61
|
+
#### `@mui/x-date-charts-pro@7.0.0-alpha.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
62
|
+
|
|
63
|
+
Same changes as in `@mui/x-charts@7.13.0`.
|
|
64
|
+
|
|
65
|
+
### Tree View
|
|
66
|
+
|
|
67
|
+
#### `@mui/x-tree-view@7.13.0`
|
|
68
|
+
|
|
69
|
+
- [TreeView] Add label editing feature (#13388) @noraleonte
|
|
70
|
+
- [TreeView] Fix the parameters passed for the `canMoveItemToNewPosition` prop (#14176) @flaviendelangle
|
|
71
|
+
|
|
72
|
+
### Docs
|
|
73
|
+
|
|
74
|
+
- [docs] Extract dataset in the Line chart docs (#14034) @alexfauquette
|
|
75
|
+
- [docs] Remove redundant encoding in the mock data source server (#14185) @MBilalShafi
|
|
76
|
+
- [docs] Use Netflix financial results to document bar charts (#13991) @alexfauquette
|
|
77
|
+
- [docs] Remove relience of abbreviations (#14226) @oliviertassinari
|
|
78
|
+
|
|
79
|
+
### Core
|
|
80
|
+
|
|
81
|
+
- [core] Bump monorepo (#14141) @Janpot
|
|
82
|
+
- [core] Fix ESLint issue (#14207) @LukasTy
|
|
83
|
+
- [core] Fix Netlify build cache issue (#14182) @cherniavskii
|
|
84
|
+
- [code-infra] Refactor Netlify `cache-docs` plugin setup (#14105) @LukasTy
|
|
85
|
+
- [internals] Move utils needed for tree view virtualization to shared package (#14202) @flaviendelangle
|
|
86
|
+
|
|
6
87
|
## 7.12.1
|
|
7
88
|
|
|
8
89
|
_Aug 8, 2024_
|
|
@@ -16,9 +16,17 @@ var _useDataGridProComponent = require("./useDataGridProComponent");
|
|
|
16
16
|
var _useDataGridProProps = require("./useDataGridProProps");
|
|
17
17
|
var _releaseInfo = require("../utils/releaseInfo");
|
|
18
18
|
var _propValidation = require("../internals/propValidation");
|
|
19
|
+
var _useGridAriaAttributes = require("../hooks/utils/useGridAriaAttributes");
|
|
20
|
+
var _useGridRowAriaAttributes = require("../hooks/features/rows/useGridRowAriaAttributes");
|
|
19
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
22
|
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); }
|
|
21
23
|
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; }
|
|
24
|
+
const configuration = {
|
|
25
|
+
hooks: {
|
|
26
|
+
useGridAriaAttributes: _useGridAriaAttributes.useGridAriaAttributes,
|
|
27
|
+
useGridRowAriaAttributes: _useGridRowAriaAttributes.useGridRowAriaAttributes
|
|
28
|
+
}
|
|
29
|
+
};
|
|
22
30
|
const releaseInfo = (0, _releaseInfo.getReleaseInfo)();
|
|
23
31
|
const DataGridProRaw = /*#__PURE__*/React.forwardRef(function DataGridPro(inProps, ref) {
|
|
24
32
|
const props = (0, _useDataGridProProps.useDataGridProProps)(inProps);
|
|
@@ -29,6 +37,7 @@ const DataGridProRaw = /*#__PURE__*/React.forwardRef(function DataGridPro(inProp
|
|
|
29
37
|
}
|
|
30
38
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_xDataGrid.GridContextProvider, {
|
|
31
39
|
privateApiRef: privateApiRef,
|
|
40
|
+
configuration: configuration,
|
|
32
41
|
props: props,
|
|
33
42
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_xDataGrid.GridRoot, (0, _extends2.default)({
|
|
34
43
|
className: props.className,
|
|
@@ -420,7 +429,7 @@ DataGridProRaw.propTypes = {
|
|
|
420
429
|
/**
|
|
421
430
|
* Determines if a row can be selected.
|
|
422
431
|
* @param {GridRowParams} params With all properties from [[GridRowParams]].
|
|
423
|
-
* @returns {boolean} A boolean indicating if the
|
|
432
|
+
* @returns {boolean} A boolean indicating if the row is selectable.
|
|
424
433
|
*/
|
|
425
434
|
isRowSelectable: _propTypes.default.func,
|
|
426
435
|
/**
|
|
@@ -11,6 +11,7 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
12
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
13
13
|
var _utils = require("@mui/utils");
|
|
14
|
+
var _fastMemo = require("@mui/x-internals/fastMemo");
|
|
14
15
|
var _xDataGrid = require("@mui/x-data-grid");
|
|
15
16
|
var _internals = require("@mui/x-data-grid/internals");
|
|
16
17
|
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
|
|
@@ -282,4 +283,4 @@ process.env.NODE_ENV !== "production" ? GridHeaderFilterCell.propTypes = {
|
|
|
282
283
|
tabIndex: _propTypes.default.oneOf([-1, 0]).isRequired,
|
|
283
284
|
width: _propTypes.default.number.isRequired
|
|
284
285
|
} : void 0;
|
|
285
|
-
const Memoized = exports.GridHeaderFilterCell = (0,
|
|
286
|
+
const Memoized = exports.GridHeaderFilterCell = (0, _fastMemo.fastMemo)(GridHeaderFilterCell);
|
|
@@ -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
|
/**
|
|
@@ -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';
|
|
@@ -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/esm/internals/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';
|
package/esm/utils/releaseInfo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTcyMzc1NTYwMDAwMA==";
|
|
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,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useGridRowAriaAttributes';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _useGridRowAriaAttributes = require("./useGridRowAriaAttributes");
|
|
7
|
+
Object.keys(_useGridRowAriaAttributes).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _useGridRowAriaAttributes[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _useGridRowAriaAttributes[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -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");
|
|
@@ -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
|
/**
|
|
@@ -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';
|
|
@@ -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 = "MTcyMzc1NTYwMDAwMA==";
|
|
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.13.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",
|
|
@@ -40,9 +40,9 @@
|
|
|
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.13.0",
|
|
44
|
+
"@mui/x-internals": "7.13.0",
|
|
45
|
+
"@mui/x-license": "7.13.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 = "MTcyMzc1NTYwMDAwMA==";
|
|
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) {
|
package/utils/tree/models.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface RowTreeBuilderGroupingCriterion {
|
|
|
6
6
|
export interface RowTreeBuilderNode {
|
|
7
7
|
id: GridRowId;
|
|
8
8
|
path: RowTreeBuilderGroupingCriterion[];
|
|
9
|
-
|
|
9
|
+
serverChildrenCount?: number;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Callback called when trying to insert a data row in the tree in place of an already existing data row.
|
|
@@ -20,7 +20,7 @@ const updateRowTree = params => {
|
|
|
20
20
|
const {
|
|
21
21
|
id,
|
|
22
22
|
path,
|
|
23
|
-
|
|
23
|
+
serverChildrenCount
|
|
24
24
|
} = params.nodes.inserted[i];
|
|
25
25
|
(0, _insertDataRowInTree.insertDataRowInTree)({
|
|
26
26
|
previousTree: params.previousTree,
|
|
@@ -29,7 +29,7 @@ const updateRowTree = params => {
|
|
|
29
29
|
updatedGroupsManager,
|
|
30
30
|
id,
|
|
31
31
|
path,
|
|
32
|
-
|
|
32
|
+
serverChildrenCount,
|
|
33
33
|
onDuplicatePath: params.onDuplicatePath,
|
|
34
34
|
isGroupExpandedByDefault: params.isGroupExpandedByDefault,
|
|
35
35
|
defaultGroupingExpansionDepth: params.defaultGroupingExpansionDepth,
|
|
@@ -49,7 +49,7 @@ const updateRowTree = params => {
|
|
|
49
49
|
const {
|
|
50
50
|
id,
|
|
51
51
|
path,
|
|
52
|
-
|
|
52
|
+
serverChildrenCount
|
|
53
53
|
} = params.nodes.modified[i];
|
|
54
54
|
const pathInPreviousTree = (0, _utils.getNodePathInTree)({
|
|
55
55
|
tree,
|
|
@@ -70,7 +70,7 @@ const updateRowTree = params => {
|
|
|
70
70
|
updatedGroupsManager,
|
|
71
71
|
id,
|
|
72
72
|
path,
|
|
73
|
-
|
|
73
|
+
serverChildrenCount,
|
|
74
74
|
onDuplicatePath: params.onDuplicatePath,
|
|
75
75
|
isGroupExpandedByDefault: params.isGroupExpandedByDefault,
|
|
76
76
|
defaultGroupingExpansionDepth: params.defaultGroupingExpansionDepth,
|