@mui/x-data-grid-pro 5.6.1 → 5.7.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 +71 -1
- package/DataGridPro/DataGridPro.js +20 -15
- package/DataGridPro/useDataGridProComponent.js +12 -10
- package/components/DataGridProColumnHeaders.js +10 -10
- package/components/DataGridProVirtualScroller.js +6 -6
- package/hooks/features/rowGrouping/gridRowGroupingInterfaces.d.ts +6 -0
- package/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +4 -1
- package/hooks/features/rowGrouping/gridRowGroupingUtils.js +18 -3
- package/hooks/features/rowGrouping/useGridRowGrouping.js +44 -165
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +1 -1
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +130 -3
- package/hooks/features/treeData/gridTreeDataUtils.d.ts +1 -0
- package/hooks/features/treeData/gridTreeDataUtils.js +2 -0
- package/hooks/features/treeData/useGridTreeData.d.ts +1 -5
- package/hooks/features/treeData/useGridTreeData.js +3 -82
- package/hooks/features/treeData/useGridTreeDataPreProcessors.d.ts +1 -1
- package/hooks/features/treeData/useGridTreeDataPreProcessors.js +72 -3
- package/index.js +1 -1
- package/legacy/DataGridPro/DataGridPro.js +20 -15
- package/legacy/DataGridPro/useDataGridProComponent.js +12 -10
- package/legacy/components/DataGridProColumnHeaders.js +10 -10
- package/legacy/components/DataGridProVirtualScroller.js +6 -6
- package/legacy/hooks/features/rowGrouping/gridRowGroupingUtils.js +19 -2
- package/legacy/hooks/features/rowGrouping/useGridRowGrouping.js +46 -170
- package/legacy/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +137 -3
- package/legacy/hooks/features/treeData/gridTreeDataUtils.js +2 -0
- package/legacy/hooks/features/treeData/useGridTreeData.js +3 -90
- package/legacy/hooks/features/treeData/useGridTreeDataPreProcessors.js +84 -3
- package/legacy/index.js +1 -1
- package/legacy/utils/releaseInfo.js +15 -0
- package/modern/DataGridPro/DataGridPro.js +20 -15
- package/modern/DataGridPro/useDataGridProComponent.js +10 -10
- package/modern/components/DataGridProColumnHeaders.js +10 -10
- package/modern/components/DataGridProVirtualScroller.js +6 -6
- package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +18 -3
- package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +44 -165
- package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +130 -3
- package/modern/hooks/features/treeData/gridTreeDataUtils.js +2 -0
- package/modern/hooks/features/treeData/useGridTreeData.js +3 -82
- package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +72 -3
- package/modern/index.js +1 -1
- package/modern/utils/releaseInfo.js +15 -0
- package/node/DataGridPro/DataGridPro.js +18 -14
- package/node/DataGridPro/useDataGridProComponent.js +12 -10
- package/node/components/DataGridProColumnHeaders.js +10 -10
- package/node/components/DataGridProVirtualScroller.js +6 -6
- package/node/hooks/features/rowGrouping/gridRowGroupingUtils.js +24 -5
- package/node/hooks/features/rowGrouping/useGridRowGrouping.js +40 -163
- package/node/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +133 -0
- package/node/hooks/features/treeData/gridTreeDataUtils.js +5 -2
- package/node/hooks/features/treeData/useGridTreeData.js +2 -91
- package/node/hooks/features/treeData/useGridTreeDataPreProcessors.js +74 -2
- package/node/index.js +1 -1
- package/node/utils/releaseInfo.js +25 -0
- package/package.json +3 -3
- package/utils/releaseInfo.d.ts +1 -0
- package/utils/releaseInfo.js +15 -0
- package/utils/tree/buildRowTree.d.ts +3 -3
- package/components/Watermark.d.ts +0 -2
- package/components/Watermark.js +0 -43
- package/legacy/components/Watermark.js +0 -43
- package/modern/components/Watermark.js +0 -43
- package/node/components/Watermark.js +0 -56
|
@@ -1,92 +1,13 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import * as React from 'react';
|
|
3
|
-
import { useGridApiEventHandler, GridEvents,
|
|
4
|
-
|
|
5
|
-
import { buildRowTree } from '../../../utils/tree/buildRowTree';
|
|
6
|
-
import { sortRowTree } from '../../../utils/tree/sortRowTree';
|
|
7
|
-
import { filterRowTreeFromTreeData } from './gridTreeDataUtils';
|
|
8
|
-
export const TREE_DATA_GROUPING_NAME = 'tree-data';
|
|
2
|
+
import { useGridApiEventHandler, GridEvents, gridFilteredDescendantCountLookupSelector } from '@mui/x-data-grid';
|
|
3
|
+
|
|
9
4
|
/**
|
|
10
5
|
* Only available in DataGridPro
|
|
11
|
-
* @requires useGridPreProcessing (method)
|
|
12
|
-
* @requires useGridRowGroupsPreProcessing (method)
|
|
13
6
|
*/
|
|
14
|
-
|
|
15
|
-
export const useGridTreeData = (apiRef, props) => {
|
|
16
|
-
/**
|
|
17
|
-
* ROW GROUPING
|
|
18
|
-
*/
|
|
19
|
-
const updateRowGrouping = React.useCallback(() => {
|
|
20
|
-
if (!props.treeData) {
|
|
21
|
-
return apiRef.current.unstable_registerRowGroupsBuilder('treeData', null);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const groupRows = params => {
|
|
25
|
-
if (!props.getTreeDataPath) {
|
|
26
|
-
throw new Error('MUI: No getTreeDataPath given.');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const rows = params.ids.map(rowId => ({
|
|
30
|
-
id: rowId,
|
|
31
|
-
path: props.getTreeDataPath(params.idRowsLookup[rowId]).map(key => ({
|
|
32
|
-
key,
|
|
33
|
-
field: null
|
|
34
|
-
}))
|
|
35
|
-
})).sort((a, b) => a.path.length - b.path.length);
|
|
36
|
-
return buildRowTree(_extends({
|
|
37
|
-
rows
|
|
38
|
-
}, params, {
|
|
39
|
-
defaultGroupingExpansionDepth: props.defaultGroupingExpansionDepth,
|
|
40
|
-
isGroupExpandedByDefault: props.isGroupExpandedByDefault,
|
|
41
|
-
groupingName: TREE_DATA_GROUPING_NAME,
|
|
42
|
-
onDuplicatePath: (firstId, secondId, path) => {
|
|
43
|
-
throw new Error(['MUI: The path returned by `getTreeDataPath` should be unique.', `The rows with id #${firstId} and #${secondId} have the same.`, `Path: ${JSON.stringify(path.map(step => step.key))}.`].join('\n'));
|
|
44
|
-
}
|
|
45
|
-
}));
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
return apiRef.current.unstable_registerRowGroupsBuilder('treeData', groupRows);
|
|
49
|
-
}, [apiRef, props.getTreeDataPath, props.treeData, props.defaultGroupingExpansionDepth, props.isGroupExpandedByDefault]);
|
|
50
|
-
useFirstRender(() => {
|
|
51
|
-
updateRowGrouping();
|
|
52
|
-
});
|
|
53
|
-
const isFirstRender = React.useRef(true);
|
|
54
|
-
React.useEffect(() => {
|
|
55
|
-
if (isFirstRender.current) {
|
|
56
|
-
isFirstRender.current = false;
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
updateRowGrouping();
|
|
61
|
-
}, [updateRowGrouping]);
|
|
62
|
-
/**
|
|
63
|
-
* PRE-PROCESSING
|
|
64
|
-
*/
|
|
65
|
-
|
|
66
|
-
const filteringMethod = React.useCallback(params => {
|
|
67
|
-
const rowTree = gridRowTreeSelector(apiRef);
|
|
68
|
-
return filterRowTreeFromTreeData({
|
|
69
|
-
rowTree,
|
|
70
|
-
isRowMatchingFilters: params.isRowMatchingFilters,
|
|
71
|
-
disableChildrenFiltering: props.disableChildrenFiltering
|
|
72
|
-
});
|
|
73
|
-
}, [apiRef, props.disableChildrenFiltering]);
|
|
74
|
-
const sortingMethod = React.useCallback(params => {
|
|
75
|
-
const rowTree = gridRowTreeSelector(apiRef);
|
|
76
|
-
const rowIds = gridRowIdsSelector(apiRef);
|
|
77
|
-
return sortRowTree({
|
|
78
|
-
rowTree,
|
|
79
|
-
rowIds,
|
|
80
|
-
sortRowList: params.sortRowList,
|
|
81
|
-
disableChildrenSorting: props.disableChildrenSorting
|
|
82
|
-
});
|
|
83
|
-
}, [apiRef, props.disableChildrenSorting]);
|
|
84
|
-
useGridRegisterFilteringMethod(apiRef, TREE_DATA_GROUPING_NAME, filteringMethod);
|
|
85
|
-
useGridRegisterSortingMethod(apiRef, TREE_DATA_GROUPING_NAME, sortingMethod);
|
|
7
|
+
export const useGridTreeData = apiRef => {
|
|
86
8
|
/**
|
|
87
9
|
* EVENTS
|
|
88
10
|
*/
|
|
89
|
-
|
|
90
11
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
91
12
|
const cellParams = apiRef.current.getCellParams(params.id, params.field);
|
|
92
13
|
|
|
@@ -2,19 +2,25 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["hideDescendantCount"];
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { gridRowIdsSelector, gridRowTreeSelector, useFirstRender } from '@mui/x-data-grid';
|
|
6
|
+
import { useGridRegisterPreProcessor, useGridRegisterStrategyProcessor } from '@mui/x-data-grid/internals';
|
|
6
7
|
import { GRID_TREE_DATA_GROUPING_COL_DEF, GRID_TREE_DATA_GROUPING_COL_DEF_FORCED_PROPERTIES } from './gridTreeDataGroupColDef';
|
|
7
|
-
import {
|
|
8
|
+
import { filterRowTreeFromTreeData, TREE_DATA_STRATEGY } from './gridTreeDataUtils';
|
|
8
9
|
import { GridTreeDataGroupingCell } from '../../../components';
|
|
10
|
+
import { buildRowTree } from '../../../utils/tree/buildRowTree';
|
|
11
|
+
import { sortRowTree } from '../../../utils/tree/sortRowTree';
|
|
9
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
13
|
export const useGridTreeDataPreProcessors = (apiRef, props) => {
|
|
14
|
+
const setStrategyAvailability = React.useCallback(() => {
|
|
15
|
+
apiRef.current.unstable_setStrategyAvailability('rowTree', TREE_DATA_STRATEGY, props.treeData ? () => true : () => false);
|
|
16
|
+
}, [apiRef, props.treeData]);
|
|
11
17
|
const getGroupingColDef = React.useCallback(() => {
|
|
12
18
|
const groupingColDefProp = props.groupingColDef;
|
|
13
19
|
let colDefOverride;
|
|
14
20
|
|
|
15
21
|
if (typeof groupingColDefProp === 'function') {
|
|
16
22
|
const params = {
|
|
17
|
-
groupingName:
|
|
23
|
+
groupingName: TREE_DATA_STRATEGY,
|
|
18
24
|
fields: []
|
|
19
25
|
};
|
|
20
26
|
colDefOverride = groupingColDefProp(params);
|
|
@@ -63,5 +69,68 @@ export const useGridTreeDataPreProcessors = (apiRef, props) => {
|
|
|
63
69
|
|
|
64
70
|
return columnsState;
|
|
65
71
|
}, [props.treeData, getGroupingColDef]);
|
|
72
|
+
const createRowTree = React.useCallback(params => {
|
|
73
|
+
if (!props.getTreeDataPath) {
|
|
74
|
+
throw new Error('MUI: No getTreeDataPath given.');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const rows = params.ids.map(rowId => ({
|
|
78
|
+
id: rowId,
|
|
79
|
+
path: props.getTreeDataPath(params.idRowsLookup[rowId]).map(key => ({
|
|
80
|
+
key,
|
|
81
|
+
field: null
|
|
82
|
+
}))
|
|
83
|
+
})).sort((a, b) => a.path.length - b.path.length);
|
|
84
|
+
return buildRowTree(_extends({
|
|
85
|
+
rows
|
|
86
|
+
}, params, {
|
|
87
|
+
defaultGroupingExpansionDepth: props.defaultGroupingExpansionDepth,
|
|
88
|
+
isGroupExpandedByDefault: props.isGroupExpandedByDefault,
|
|
89
|
+
groupingName: TREE_DATA_STRATEGY,
|
|
90
|
+
onDuplicatePath: (firstId, secondId, path) => {
|
|
91
|
+
throw new Error(['MUI: The path returned by `getTreeDataPath` should be unique.', `The rows with id #${firstId} and #${secondId} have the same.`, `Path: ${JSON.stringify(path.map(step => step.key))}.`].join('\n'));
|
|
92
|
+
}
|
|
93
|
+
}));
|
|
94
|
+
}, [props.getTreeDataPath, props.defaultGroupingExpansionDepth, props.isGroupExpandedByDefault]);
|
|
95
|
+
const filterRows = React.useCallback(params => {
|
|
96
|
+
const rowTree = gridRowTreeSelector(apiRef);
|
|
97
|
+
return filterRowTreeFromTreeData({
|
|
98
|
+
rowTree,
|
|
99
|
+
isRowMatchingFilters: params.isRowMatchingFilters,
|
|
100
|
+
disableChildrenFiltering: props.disableChildrenFiltering
|
|
101
|
+
});
|
|
102
|
+
}, [apiRef, props.disableChildrenFiltering]);
|
|
103
|
+
const sortRows = React.useCallback(params => {
|
|
104
|
+
const rowTree = gridRowTreeSelector(apiRef);
|
|
105
|
+
const rowIds = gridRowIdsSelector(apiRef);
|
|
106
|
+
return sortRowTree({
|
|
107
|
+
rowTree,
|
|
108
|
+
rowIds,
|
|
109
|
+
sortRowList: params.sortRowList,
|
|
110
|
+
disableChildrenSorting: props.disableChildrenSorting
|
|
111
|
+
});
|
|
112
|
+
}, [apiRef, props.disableChildrenSorting]);
|
|
66
113
|
useGridRegisterPreProcessor(apiRef, 'hydrateColumns', updateGroupingColumn);
|
|
114
|
+
useGridRegisterStrategyProcessor(apiRef, TREE_DATA_STRATEGY, 'rowTreeCreation', createRowTree);
|
|
115
|
+
useGridRegisterStrategyProcessor(apiRef, TREE_DATA_STRATEGY, 'filtering', filterRows);
|
|
116
|
+
useGridRegisterStrategyProcessor(apiRef, TREE_DATA_STRATEGY, 'sorting', sortRows);
|
|
117
|
+
/**
|
|
118
|
+
* 1ST RENDER
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
useFirstRender(() => {
|
|
122
|
+
setStrategyAvailability();
|
|
123
|
+
});
|
|
124
|
+
/**
|
|
125
|
+
* EFFECTS
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
const isFirstRender = React.useRef(true);
|
|
129
|
+
React.useEffect(() => {
|
|
130
|
+
if (!isFirstRender.current) {
|
|
131
|
+
setStrategyAvailability();
|
|
132
|
+
} else {
|
|
133
|
+
isFirstRender.current = false;
|
|
134
|
+
}
|
|
135
|
+
}, [setStrategyAvailability]);
|
|
67
136
|
};
|
package/modern/index.js
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ponyfillGlobal } from '@mui/utils';
|
|
2
|
+
export const getReleaseInfo = () => {
|
|
3
|
+
const releaseInfo = "MTY0ODA5MDgwMDAwMA==";
|
|
4
|
+
|
|
5
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6
|
+
// A simple hack to set the value in the test environment (has no build step).
|
|
7
|
+
// eslint-disable-next-line no-useless-concat
|
|
8
|
+
if (releaseInfo === '__RELEASE' + '_INFO__') {
|
|
9
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
10
|
+
return ponyfillGlobal.__MUI_RELEASE_INFO__;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return releaseInfo;
|
|
15
|
+
};
|
|
@@ -19,34 +19,25 @@ var _xDataGrid = require("@mui/x-data-grid");
|
|
|
19
19
|
|
|
20
20
|
var _useDataGridProComponent = require("./useDataGridProComponent");
|
|
21
21
|
|
|
22
|
-
var _Watermark = require("../components/Watermark");
|
|
23
|
-
|
|
24
22
|
var _useDataGridProProps = require("./useDataGridProProps");
|
|
25
23
|
|
|
26
24
|
var _DataGridProVirtualScroller = require("../components/DataGridProVirtualScroller");
|
|
27
25
|
|
|
28
26
|
var _DataGridProColumnHeaders = require("../components/DataGridProColumnHeaders");
|
|
29
27
|
|
|
28
|
+
var _releaseInfo = require("../utils/releaseInfo");
|
|
29
|
+
|
|
30
30
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
31
31
|
|
|
32
32
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
33
|
|
|
34
34
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
// automatically when a new version is published on npm.
|
|
38
|
-
let RELEASE_INFO = "MTY0Njg2NjgwMDAwMA=="; // eslint-disable-next-line no-useless-concat
|
|
39
|
-
|
|
40
|
-
if (process.env.NODE_ENV !== 'production' && RELEASE_INFO === '__RELEASE' + '_INFO__') {
|
|
41
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
42
|
-
RELEASE_INFO = _utils.ponyfillGlobal.__MUI_RELEASE_INFO__;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
_xLicensePro.LicenseInfo.setReleaseInfo(RELEASE_INFO);
|
|
46
|
-
|
|
36
|
+
const releaseInfo = (0, _releaseInfo.getReleaseInfo)();
|
|
47
37
|
const DataGridProRaw = /*#__PURE__*/React.forwardRef(function DataGridPro(inProps, ref) {
|
|
48
38
|
const props = (0, _useDataGridProProps.useDataGridProProps)(inProps);
|
|
49
39
|
const apiRef = (0, _useDataGridProComponent.useDataGridProComponent)(props.apiRef, props);
|
|
40
|
+
(0, _xLicensePro.useLicenseVerifier)('x-data-grid-pro', releaseInfo);
|
|
50
41
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_xDataGrid.GridContextProvider, {
|
|
51
42
|
apiRef: apiRef,
|
|
52
43
|
props: props,
|
|
@@ -59,7 +50,10 @@ const DataGridProRaw = /*#__PURE__*/React.forwardRef(function DataGridPro(inProp
|
|
|
59
50
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_xDataGrid.GridHeaderPlaceholder, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_xDataGrid.GridBody, {
|
|
60
51
|
ColumnHeadersComponent: _DataGridProColumnHeaders.DataGridProColumnHeaders,
|
|
61
52
|
VirtualScrollerComponent: _DataGridProVirtualScroller.DataGridProVirtualScroller,
|
|
62
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
53
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_xLicensePro.Watermark, {
|
|
54
|
+
packageName: "x-data-grid-pro",
|
|
55
|
+
releaseInfo: releaseInfo
|
|
56
|
+
})
|
|
63
57
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_xDataGrid.GridFooterPlaceholder, {})]
|
|
64
58
|
})
|
|
65
59
|
})
|
|
@@ -299,6 +293,7 @@ DataGridProRaw.propTypes = {
|
|
|
299
293
|
* For each feature, if the flag is not explicitly set to `true`, the feature will be fully disabled and any property / method call will not have any effect.
|
|
300
294
|
*/
|
|
301
295
|
experimentalFeatures: _propTypes.default.shape({
|
|
296
|
+
newEditingApi: _propTypes.default.bool,
|
|
302
297
|
preventCommitWhileValidating: _propTypes.default.bool,
|
|
303
298
|
rowGrouping: _propTypes.default.bool,
|
|
304
299
|
warnIfFocusStateIsNotSynced: _propTypes.default.bool
|
|
@@ -812,6 +807,15 @@ DataGridProRaw.propTypes = {
|
|
|
812
807
|
right: _propTypes.default.arrayOf(_propTypes.default.string)
|
|
813
808
|
}),
|
|
814
809
|
|
|
810
|
+
/**
|
|
811
|
+
* Callback called before updating a row with new values in the row and cell editing.
|
|
812
|
+
* Only applied if `props.experimentalFeatures.newEditingApi: true`.
|
|
813
|
+
* @param {GridRowModel} newRow Row object with the new values.
|
|
814
|
+
* @param {GridRowModel} oldRow Row object with the old values.
|
|
815
|
+
* @returns {Promise<GridRowModel> | GridRowModel} The final values to update the row.
|
|
816
|
+
*/
|
|
817
|
+
processRowUpdate: _propTypes.default.func,
|
|
818
|
+
|
|
815
819
|
/**
|
|
816
820
|
* Number of extra rows to be rendered before/after the visible slice.
|
|
817
821
|
* @default 3
|
|
@@ -33,6 +33,8 @@ var _useGridDetailPanelPreProcessors = require("../hooks/features/detailPanel/us
|
|
|
33
33
|
|
|
34
34
|
// Pro-only features
|
|
35
35
|
const useDataGridProComponent = (inputApiRef, props) => {
|
|
36
|
+
var _props$experimentalFe, _props$experimentalFe2;
|
|
37
|
+
|
|
36
38
|
const apiRef = (0, _internals.useGridInitialization)(inputApiRef, props);
|
|
37
39
|
/**
|
|
38
40
|
* Register all pre-processors called during state initialization here.
|
|
@@ -41,25 +43,22 @@ const useDataGridProComponent = (inputApiRef, props) => {
|
|
|
41
43
|
(0, _internals.useGridSelectionPreProcessors)(apiRef, props);
|
|
42
44
|
(0, _useGridRowGroupingPreProcessors.useGridRowGroupingPreProcessors)(apiRef, props);
|
|
43
45
|
(0, _useGridTreeDataPreProcessors.useGridTreeDataPreProcessors)(apiRef, props);
|
|
44
|
-
(0, _useGridDetailPanelPreProcessors.useGridDetailPanelPreProcessors)(apiRef, props);
|
|
45
|
-
|
|
46
|
+
(0, _useGridDetailPanelPreProcessors.useGridDetailPanelPreProcessors)(apiRef, props); // The column pinning `hydrateColumns` pre-processor must be after every other `hydrateColumns` pre-processors
|
|
47
|
+
// Because it changes the order of the columns.
|
|
46
48
|
|
|
49
|
+
(0, _useGridColumnPinningPreProcessors.useGridColumnPinningPreProcessors)(apiRef, props);
|
|
50
|
+
(0, _internals.useGridRowsPreProcessors)(apiRef);
|
|
47
51
|
/**
|
|
48
52
|
* Register all state initializers here.
|
|
49
53
|
*/
|
|
50
54
|
|
|
55
|
+
(0, _internals.useGridInitializeState)(_useGridRowGrouping.rowGroupingStateInitializer, apiRef, props);
|
|
51
56
|
(0, _internals.useGridInitializeState)(_internals.selectionStateInitializer, apiRef, props);
|
|
52
57
|
(0, _internals.useGridInitializeState)(_useGridDetailPanel.detailPanelStateInitializer, apiRef, props);
|
|
53
58
|
(0, _internals.useGridInitializeState)(_useGridColumnPinning.columnPinningStateInitializer, apiRef, props);
|
|
54
|
-
(0, _internals.useGridInitializeState)(_useGridRowGrouping.rowGroupingStateInitializer, apiRef, props); // FIXME Call in the same relative position that useGridRowGrouping is called
|
|
55
|
-
|
|
56
59
|
(0, _internals.useGridInitializeState)(_internals.columnsStateInitializer, apiRef, props);
|
|
57
|
-
(0, _useGridRowGrouping.useGridRowGrouping)(apiRef, props); // FIXME Needs to be called before the rows state initialization because it registers a rows group builder
|
|
58
|
-
|
|
59
|
-
(0, _useGridTreeData.useGridTreeData)(apiRef, props); // FIXME Needs to be called before the rows state initialization because it registers a rows group builder
|
|
60
|
-
|
|
61
60
|
(0, _internals.useGridInitializeState)(_internals.rowsStateInitializer, apiRef, props);
|
|
62
|
-
(0, _internals.useGridInitializeState)(_internals.
|
|
61
|
+
(0, _internals.useGridInitializeState)((_props$experimentalFe = props.experimentalFeatures) != null && _props$experimentalFe.newEditingApi ? _internals.editingStateInitializer_new : _internals.editingStateInitializer_old, apiRef, props);
|
|
63
62
|
(0, _internals.useGridInitializeState)(_internals.focusStateInitializer, apiRef, props);
|
|
64
63
|
(0, _internals.useGridInitializeState)(_internals.sortingStateInitializer, apiRef, props);
|
|
65
64
|
(0, _internals.useGridInitializeState)(_internals.preferencePanelStateInitializer, apiRef, props);
|
|
@@ -70,6 +69,8 @@ const useDataGridProComponent = (inputApiRef, props) => {
|
|
|
70
69
|
(0, _internals.useGridInitializeState)(_internals.paginationStateInitializer, apiRef, props);
|
|
71
70
|
(0, _internals.useGridInitializeState)(_internals.rowsMetaStateInitializer, apiRef, props);
|
|
72
71
|
(0, _internals.useGridInitializeState)(_internals.columnMenuStateInitializer, apiRef, props);
|
|
72
|
+
(0, _useGridRowGrouping.useGridRowGrouping)(apiRef, props);
|
|
73
|
+
(0, _useGridTreeData.useGridTreeData)(apiRef);
|
|
73
74
|
(0, _internals.useGridSelection)(apiRef, props);
|
|
74
75
|
(0, _useGridDetailPanel.useGridDetailPanel)(apiRef, props);
|
|
75
76
|
(0, _useGridColumnPinning.useGridColumnPinning)(apiRef, props);
|
|
@@ -77,7 +78,8 @@ const useDataGridProComponent = (inputApiRef, props) => {
|
|
|
77
78
|
(0, _internals.useGridRows)(apiRef, props);
|
|
78
79
|
(0, _internals.useGridParamsApi)(apiRef);
|
|
79
80
|
(0, _useGridDetailPanelCache.useGridDetailPanelCache)(apiRef, props);
|
|
80
|
-
|
|
81
|
+
const useGridEditing = (_props$experimentalFe2 = props.experimentalFeatures) != null && _props$experimentalFe2.newEditingApi ? _internals.useGridEditing_new : _internals.useGridEditing_old;
|
|
82
|
+
useGridEditing(apiRef, props);
|
|
81
83
|
(0, _internals.useGridFocus)(apiRef, props);
|
|
82
84
|
(0, _internals.useGridSorting)(apiRef, props);
|
|
83
85
|
(0, _internals.useGridPreferencesPanel)(apiRef);
|
|
@@ -159,7 +159,15 @@ const DataGridProColumnHeaders = /*#__PURE__*/React.forwardRef(function DataGrid
|
|
|
159
159
|
}, {
|
|
160
160
|
disableReorder: true
|
|
161
161
|
})
|
|
162
|
-
}),
|
|
162
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_internals.GridColumnHeadersInner, (0, _extends2.default)({
|
|
163
|
+
isDragging: isDragging
|
|
164
|
+
}, getInnerProps(), {
|
|
165
|
+
children: getColumns({
|
|
166
|
+
renderContext,
|
|
167
|
+
minFirstColumn: leftPinnedColumns.length,
|
|
168
|
+
maxLastColumn: visibleColumnFields.length - rightPinnedColumns.length
|
|
169
|
+
})
|
|
170
|
+
})), rightRenderContext && /*#__PURE__*/(0, _jsxRuntime.jsx)(GridColumnHeadersPinnedColumnHeaders, {
|
|
163
171
|
ownerState: {
|
|
164
172
|
side: _columnPinning.GridPinnedPosition.right
|
|
165
173
|
},
|
|
@@ -175,15 +183,7 @@ const DataGridProColumnHeaders = /*#__PURE__*/React.forwardRef(function DataGrid
|
|
|
175
183
|
disableReorder: true,
|
|
176
184
|
separatorSide: _xDataGrid.GridColumnHeaderSeparatorSides.Left
|
|
177
185
|
})
|
|
178
|
-
})
|
|
179
|
-
isDragging: isDragging
|
|
180
|
-
}, getInnerProps(), {
|
|
181
|
-
children: getColumns({
|
|
182
|
-
renderContext,
|
|
183
|
-
minFirstColumn: leftPinnedColumns.length,
|
|
184
|
-
maxLastColumn: visibleColumnFields.length - rightPinnedColumns.length
|
|
185
|
-
})
|
|
186
|
-
}))]
|
|
186
|
+
})]
|
|
187
187
|
}));
|
|
188
188
|
});
|
|
189
189
|
exports.DataGridProColumnHeaders = DataGridProColumnHeaders;
|
|
@@ -270,7 +270,11 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
270
270
|
maxLastColumn: leftRenderContext.lastColumnIndex,
|
|
271
271
|
availableSpace: 0
|
|
272
272
|
})
|
|
273
|
-
}),
|
|
273
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_internals.GridVirtualScrollerRenderZone, (0, _extends2.default)({}, getRenderZoneProps(), {
|
|
274
|
+
children: getRows({
|
|
275
|
+
renderContext
|
|
276
|
+
})
|
|
277
|
+
})), rightRenderContext && /*#__PURE__*/(0, _jsxRuntime.jsx)(VirtualScrollerPinnedColumns, {
|
|
274
278
|
ref: rightColumns,
|
|
275
279
|
ownerState: {
|
|
276
280
|
side: _columnPinning.GridPinnedPosition.right
|
|
@@ -283,11 +287,7 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
283
287
|
maxLastColumn: rightRenderContext.lastColumnIndex,
|
|
284
288
|
availableSpace: 0
|
|
285
289
|
})
|
|
286
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
287
|
-
children: getRows({
|
|
288
|
-
renderContext
|
|
289
|
-
})
|
|
290
|
-
})), detailPanels.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(VirtualScrollerDetailPanels, {
|
|
290
|
+
}), detailPanels.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(VirtualScrollerDetailPanels, {
|
|
291
291
|
className: classes.detailPanels,
|
|
292
292
|
children: detailPanels
|
|
293
293
|
})]
|
|
@@ -5,14 +5,16 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.mergeStateWithRowGroupingModel = exports.isGroupingColumn = exports.getRowGroupingFieldFromGroupingCriteria = exports.getRowGroupingCriteriaFromGroupingField = exports.getColDefOverrides = exports.filterRowTreeFromGroupingColumns = exports.
|
|
8
|
+
exports.setStrategyAvailability = exports.mergeStateWithRowGroupingModel = exports.isGroupingColumn = exports.getRowGroupingFieldFromGroupingCriteria = exports.getRowGroupingCriteriaFromGroupingField = exports.getColDefOverrides = exports.filterRowTreeFromGroupingColumns = exports.ROW_GROUPING_STRATEGY = exports.GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD = void 0;
|
|
9
9
|
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
|
|
12
|
+
var _gridRowGroupingSelector = require("./gridRowGroupingSelector");
|
|
13
|
+
|
|
12
14
|
const GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD = '__row_group_by_columns_group__';
|
|
13
15
|
exports.GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD = GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD;
|
|
14
|
-
const
|
|
15
|
-
exports.
|
|
16
|
+
const ROW_GROUPING_STRATEGY = 'grouping-columns';
|
|
17
|
+
exports.ROW_GROUPING_STRATEGY = ROW_GROUPING_STRATEGY;
|
|
16
18
|
|
|
17
19
|
const getRowGroupingFieldFromGroupingCriteria = groupingCriteria => {
|
|
18
20
|
if (groupingCriteria === null) {
|
|
@@ -134,7 +136,7 @@ exports.filterRowTreeFromGroupingColumns = filterRowTreeFromGroupingColumns;
|
|
|
134
136
|
const getColDefOverrides = (groupingColDefProp, fields) => {
|
|
135
137
|
if (typeof groupingColDefProp === 'function') {
|
|
136
138
|
return groupingColDefProp({
|
|
137
|
-
groupingName:
|
|
139
|
+
groupingName: ROW_GROUPING_STRATEGY,
|
|
138
140
|
fields
|
|
139
141
|
});
|
|
140
142
|
}
|
|
@@ -150,4 +152,21 @@ const mergeStateWithRowGroupingModel = rowGroupingModel => state => (0, _extends
|
|
|
150
152
|
})
|
|
151
153
|
});
|
|
152
154
|
|
|
153
|
-
exports.mergeStateWithRowGroupingModel = mergeStateWithRowGroupingModel;
|
|
155
|
+
exports.mergeStateWithRowGroupingModel = mergeStateWithRowGroupingModel;
|
|
156
|
+
|
|
157
|
+
const setStrategyAvailability = (apiRef, disableRowGrouping) => {
|
|
158
|
+
let isAvailable;
|
|
159
|
+
|
|
160
|
+
if (disableRowGrouping) {
|
|
161
|
+
isAvailable = () => false;
|
|
162
|
+
} else {
|
|
163
|
+
isAvailable = () => {
|
|
164
|
+
const rowGroupingSanitizedModel = (0, _gridRowGroupingSelector.gridRowGroupingSanitizedModelSelector)(apiRef);
|
|
165
|
+
return rowGroupingSanitizedModel.length > 0;
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
apiRef.current.unstable_setStrategyAvailability('rowTree', ROW_GROUPING_STRATEGY, isAvailable);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
exports.setStrategyAvailability = setStrategyAvailability;
|