@mui/x-data-grid-pro 5.11.1 → 5.12.2
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 +199 -20
- package/DataGridPro/DataGridPro.js +26 -27
- package/DataGridPro/useDataGridProComponent.js +1 -8
- package/DataGridPro/useDataGridProProps.js +6 -27
- package/README.md +2 -2
- package/components/DataGridProColumnHeaders.js +10 -7
- package/components/DataGridProVirtualScroller.d.ts +1 -1
- package/components/DataGridProVirtualScroller.js +6 -3
- package/components/GridRowReorderCell.js +6 -6
- package/hooks/features/columnPinning/gridColumnPinningInterface.d.ts +6 -0
- package/hooks/features/columnPinning/useGridColumnPinning.d.ts +1 -1
- package/hooks/features/columnPinning/useGridColumnPinning.js +73 -28
- package/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +67 -4
- package/hooks/features/columnResize/useGridColumnResize.js +32 -15
- package/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +2 -2
- package/hooks/features/detailPanel/useGridDetailPanel.d.ts +1 -1
- package/hooks/features/detailPanel/useGridDetailPanel.js +78 -18
- package/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +5 -2
- package/hooks/features/rowReorder/useGridRowReorder.js +5 -1
- package/hooks/features/rowReorder/useGridRowReorderPreProcessors.d.ts +2 -2
- package/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -2
- package/index.d.ts +0 -2
- package/index.js +2 -5
- package/internals/index.d.ts +0 -1
- package/internals/index.js +0 -1
- package/legacy/DataGridPro/DataGridPro.js +26 -27
- package/legacy/DataGridPro/useDataGridProComponent.js +1 -8
- package/legacy/DataGridPro/useDataGridProProps.js +1 -20
- package/legacy/components/DataGridProColumnHeaders.js +10 -7
- package/legacy/components/DataGridProVirtualScroller.js +6 -3
- package/legacy/components/GridRowReorderCell.js +8 -6
- package/legacy/hooks/features/columnPinning/useGridColumnPinning.js +82 -33
- package/legacy/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +70 -5
- package/legacy/hooks/features/columnResize/useGridColumnResize.js +32 -15
- package/legacy/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +3 -1
- package/legacy/hooks/features/detailPanel/useGridDetailPanel.js +78 -18
- package/legacy/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +5 -2
- package/legacy/hooks/features/rowReorder/useGridRowReorder.js +5 -1
- package/legacy/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -2
- package/legacy/index.js +2 -5
- package/legacy/internals/index.js +0 -1
- package/legacy/utils/releaseInfo.js +1 -1
- package/models/dataGridProProps.d.ts +0 -26
- package/models/gridApiPro.d.ts +1 -2
- package/models/gridStatePro.d.ts +0 -3
- package/modern/DataGridPro/DataGridPro.js +26 -27
- package/modern/DataGridPro/useDataGridProComponent.js +1 -8
- package/modern/DataGridPro/useDataGridProProps.js +1 -16
- package/modern/components/DataGridProColumnHeaders.js +11 -6
- package/modern/components/DataGridProVirtualScroller.js +6 -3
- package/modern/components/GridRowReorderCell.js +6 -6
- package/modern/hooks/features/columnPinning/useGridColumnPinning.js +73 -28
- package/modern/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +67 -4
- package/modern/hooks/features/columnResize/useGridColumnResize.js +32 -15
- package/modern/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +2 -2
- package/modern/hooks/features/detailPanel/useGridDetailPanel.js +76 -16
- package/modern/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +5 -2
- package/modern/hooks/features/rowReorder/useGridRowReorder.js +5 -1
- package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -2
- package/modern/index.js +2 -5
- package/modern/internals/index.js +0 -1
- package/modern/utils/releaseInfo.js +1 -1
- package/node/DataGridPro/DataGridPro.js +26 -27
- package/node/DataGridPro/useDataGridProComponent.js +1 -11
- package/node/DataGridPro/useDataGridProProps.js +6 -28
- package/node/components/DataGridProColumnHeaders.js +11 -7
- package/node/components/DataGridProVirtualScroller.js +6 -3
- package/node/components/GridRowReorderCell.js +6 -6
- package/node/hooks/features/columnPinning/useGridColumnPinning.js +72 -24
- package/node/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +68 -5
- package/node/hooks/features/columnResize/useGridColumnResize.js +32 -14
- package/node/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +2 -2
- package/node/hooks/features/detailPanel/useGridDetailPanel.js +76 -17
- package/node/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +8 -2
- package/node/hooks/features/rowReorder/useGridRowReorder.js +5 -1
- package/node/hooks/features/treeData/useGridTreeDataPreProcessors.js +1 -1
- package/node/index.js +2 -30
- package/node/internals/index.js +0 -9
- package/node/utils/releaseInfo.js +1 -1
- package/package.json +8 -7
- package/typeOverloads/modules.d.ts +9 -21
- package/utils/releaseInfo.js +1 -1
- package/components/GridGroupingColumnLeafCell.d.ts +0 -4
- package/components/GridGroupingColumnLeafCell.js +0 -22
- package/components/GridGroupingCriteriaCell.d.ts +0 -7
- package/components/GridGroupingCriteriaCell.js +0 -78
- package/components/GridRowGroupableColumnMenuItems.d.ts +0 -11
- package/components/GridRowGroupableColumnMenuItems.js +0 -63
- package/components/GridRowGroupingColumnMenuItems.d.ts +0 -11
- package/components/GridRowGroupingColumnMenuItems.js +0 -58
- package/hooks/features/detailPanel/useGridDetailPanelCache.d.ts +0 -4
- package/hooks/features/detailPanel/useGridDetailPanelCache.js +0 -57
- package/hooks/features/rowGrouping/createGroupingColDef.d.ts +0 -43
- package/hooks/features/rowGrouping/createGroupingColDef.js +0 -318
- package/hooks/features/rowGrouping/gridRowGroupingInterfaces.d.ts +0 -37
- package/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +0 -1
- package/hooks/features/rowGrouping/gridRowGroupingSelector.d.ts +0 -4
- package/hooks/features/rowGrouping/gridRowGroupingSelector.js +0 -5
- package/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +0 -27
- package/hooks/features/rowGrouping/gridRowGroupingUtils.js +0 -139
- package/hooks/features/rowGrouping/index.d.ts +0 -3
- package/hooks/features/rowGrouping/index.js +0 -3
- package/hooks/features/rowGrouping/useGridRowGrouping.d.ts +0 -11
- package/hooks/features/rowGrouping/useGridRowGrouping.js +0 -200
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +0 -4
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +0 -203
- package/legacy/components/GridGroupingColumnLeafCell.js +0 -20
- package/legacy/components/GridGroupingCriteriaCell.js +0 -74
- package/legacy/components/GridRowGroupableColumnMenuItems.js +0 -61
- package/legacy/components/GridRowGroupingColumnMenuItems.js +0 -56
- package/legacy/hooks/features/detailPanel/useGridDetailPanelCache.js +0 -57
- package/legacy/hooks/features/rowGrouping/createGroupingColDef.js +0 -319
- package/legacy/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +0 -1
- package/legacy/hooks/features/rowGrouping/gridRowGroupingSelector.js +0 -13
- package/legacy/hooks/features/rowGrouping/gridRowGroupingUtils.js +0 -147
- package/legacy/hooks/features/rowGrouping/index.js +0 -3
- package/legacy/hooks/features/rowGrouping/useGridRowGrouping.js +0 -206
- package/legacy/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +0 -217
- package/legacy/models/gridGroupingValueGetterParams.js +0 -1
- package/models/gridGroupingValueGetterParams.d.ts +0 -31
- package/models/gridGroupingValueGetterParams.js +0 -1
- package/modern/components/GridGroupingColumnLeafCell.js +0 -20
- package/modern/components/GridGroupingCriteriaCell.js +0 -76
- package/modern/components/GridRowGroupableColumnMenuItems.js +0 -61
- package/modern/components/GridRowGroupingColumnMenuItems.js +0 -56
- package/modern/hooks/features/detailPanel/useGridDetailPanelCache.js +0 -57
- package/modern/hooks/features/rowGrouping/createGroupingColDef.js +0 -302
- package/modern/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +0 -1
- package/modern/hooks/features/rowGrouping/gridRowGroupingSelector.js +0 -5
- package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +0 -137
- package/modern/hooks/features/rowGrouping/index.js +0 -3
- package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +0 -192
- package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +0 -203
- package/modern/models/gridGroupingValueGetterParams.js +0 -1
- package/node/components/GridGroupingColumnLeafCell.js +0 -38
- package/node/components/GridGroupingCriteriaCell.js +0 -99
- package/node/components/GridRowGroupableColumnMenuItems.js +0 -82
- package/node/components/GridRowGroupingColumnMenuItems.js +0 -78
- package/node/hooks/features/detailPanel/useGridDetailPanelCache.js +0 -74
- package/node/hooks/features/rowGrouping/createGroupingColDef.js +0 -341
- package/node/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +0 -5
- package/node/hooks/features/rowGrouping/gridRowGroupingSelector.js +0 -18
- package/node/hooks/features/rowGrouping/gridRowGroupingUtils.js +0 -172
- package/node/hooks/features/rowGrouping/index.js +0 -51
- package/node/hooks/features/rowGrouping/useGridRowGrouping.js +0 -228
- package/node/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +0 -227
- package/node/models/gridGroupingValueGetterParams.js +0 -5
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import Divider from '@mui/material/Divider';
|
|
4
|
-
import { useGridApiEventHandler, useGridApiMethod, gridFilteredDescendantCountLookupSelector } from '@mui/x-data-grid';
|
|
5
|
-
import { useGridRegisterPipeProcessor, isDeepEqual } from '@mui/x-data-grid/internals';
|
|
6
|
-
import { gridRowGroupingModelSelector, gridRowGroupingSanitizedModelSelector, gridRowGroupingStateSelector } from './gridRowGroupingSelector';
|
|
7
|
-
import { getRowGroupingFieldFromGroupingCriteria, ROW_GROUPING_STRATEGY, isGroupingColumn, mergeStateWithRowGroupingModel, setStrategyAvailability } from './gridRowGroupingUtils';
|
|
8
|
-
import { GridRowGroupableColumnMenuItems } from '../../../components/GridRowGroupableColumnMenuItems';
|
|
9
|
-
import { GridRowGroupingColumnMenuItems } from '../../../components/GridRowGroupingColumnMenuItems';
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
export const rowGroupingStateInitializer = (state, props) => {
|
|
12
|
-
var _ref, _props$rowGroupingMod, _props$initialState, _props$initialState$r;
|
|
13
|
-
|
|
14
|
-
return _extends({}, state, {
|
|
15
|
-
rowGrouping: {
|
|
16
|
-
model: (_ref = (_props$rowGroupingMod = props.rowGroupingModel) != null ? _props$rowGroupingMod : (_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$r = _props$initialState.rowGrouping) == null ? void 0 : _props$initialState$r.model) != null ? _ref : [],
|
|
17
|
-
unstable_sanitizedModelOnLastRowTreeCreation: []
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* @requires useGridColumns (state, method) - can be after, async only
|
|
23
|
-
* @requires useGridRows (state, method) - can be after, async only
|
|
24
|
-
* @requires useGridParamsApi (method) - can be after, async only
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
export const useGridRowGrouping = (apiRef, props) => {
|
|
28
|
-
apiRef.current.unstable_updateControlState({
|
|
29
|
-
stateId: 'rowGrouping',
|
|
30
|
-
propModel: props.rowGroupingModel,
|
|
31
|
-
propOnChange: props.onRowGroupingModelChange,
|
|
32
|
-
stateSelector: gridRowGroupingModelSelector,
|
|
33
|
-
changeEvent: 'rowGroupingModelChange'
|
|
34
|
-
});
|
|
35
|
-
/**
|
|
36
|
-
* API METHODS
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
const setRowGroupingModel = React.useCallback(model => {
|
|
40
|
-
const currentModel = gridRowGroupingModelSelector(apiRef);
|
|
41
|
-
|
|
42
|
-
if (currentModel !== model) {
|
|
43
|
-
apiRef.current.setState(mergeStateWithRowGroupingModel(model));
|
|
44
|
-
setStrategyAvailability(apiRef, props.disableRowGrouping);
|
|
45
|
-
apiRef.current.forceUpdate();
|
|
46
|
-
}
|
|
47
|
-
}, [apiRef, props.disableRowGrouping]);
|
|
48
|
-
const addRowGroupingCriteria = React.useCallback((field, groupingIndex) => {
|
|
49
|
-
const currentModel = gridRowGroupingModelSelector(apiRef);
|
|
50
|
-
|
|
51
|
-
if (currentModel.includes(field)) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const cleanGroupingIndex = groupingIndex != null ? groupingIndex : currentModel.length;
|
|
56
|
-
const updatedModel = [...currentModel.slice(0, cleanGroupingIndex), field, ...currentModel.slice(cleanGroupingIndex)];
|
|
57
|
-
apiRef.current.setRowGroupingModel(updatedModel);
|
|
58
|
-
}, [apiRef]);
|
|
59
|
-
const removeRowGroupingCriteria = React.useCallback(field => {
|
|
60
|
-
const currentModel = gridRowGroupingModelSelector(apiRef);
|
|
61
|
-
|
|
62
|
-
if (!currentModel.includes(field)) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
apiRef.current.setRowGroupingModel(currentModel.filter(el => el !== field));
|
|
67
|
-
}, [apiRef]);
|
|
68
|
-
const setRowGroupingCriteriaIndex = React.useCallback((field, targetIndex) => {
|
|
69
|
-
const currentModel = gridRowGroupingModelSelector(apiRef);
|
|
70
|
-
const currentTargetIndex = currentModel.indexOf(field);
|
|
71
|
-
|
|
72
|
-
if (currentTargetIndex === -1) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const updatedModel = [...currentModel];
|
|
77
|
-
updatedModel.splice(targetIndex, 0, updatedModel.splice(currentTargetIndex, 1)[0]);
|
|
78
|
-
apiRef.current.setRowGroupingModel(updatedModel);
|
|
79
|
-
}, [apiRef]);
|
|
80
|
-
const rowGroupingApi = {
|
|
81
|
-
setRowGroupingModel,
|
|
82
|
-
addRowGroupingCriteria,
|
|
83
|
-
removeRowGroupingCriteria,
|
|
84
|
-
setRowGroupingCriteriaIndex
|
|
85
|
-
};
|
|
86
|
-
useGridApiMethod(apiRef, rowGroupingApi, 'GridRowGroupingApi');
|
|
87
|
-
/**
|
|
88
|
-
* PRE-PROCESSING
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
const addColumnMenuButtons = React.useCallback((initialValue, columns) => {
|
|
92
|
-
if (props.disableRowGrouping) {
|
|
93
|
-
return initialValue;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
let menuItems;
|
|
97
|
-
|
|
98
|
-
if (isGroupingColumn(columns.field)) {
|
|
99
|
-
menuItems = /*#__PURE__*/_jsx(GridRowGroupingColumnMenuItems, {});
|
|
100
|
-
} else if (columns.groupable) {
|
|
101
|
-
menuItems = /*#__PURE__*/_jsx(GridRowGroupableColumnMenuItems, {});
|
|
102
|
-
} else {
|
|
103
|
-
menuItems = null;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (menuItems == null) {
|
|
107
|
-
return initialValue;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return [...initialValue, /*#__PURE__*/_jsx(Divider, {}), menuItems];
|
|
111
|
-
}, [props.disableRowGrouping]);
|
|
112
|
-
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
113
|
-
if (props.disableRowGrouping) {
|
|
114
|
-
return prevState;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const rowGroupingModelToExport = gridRowGroupingModelSelector(apiRef);
|
|
118
|
-
|
|
119
|
-
if (rowGroupingModelToExport.length === 0) {
|
|
120
|
-
return prevState;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return _extends({}, prevState, {
|
|
124
|
-
rowGrouping: {
|
|
125
|
-
model: rowGroupingModelToExport
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}, [apiRef, props.disableRowGrouping]);
|
|
129
|
-
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
130
|
-
var _context$stateToResto;
|
|
131
|
-
|
|
132
|
-
if (props.disableRowGrouping) {
|
|
133
|
-
return params;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const rowGroupingModel = (_context$stateToResto = context.stateToRestore.rowGrouping) == null ? void 0 : _context$stateToResto.model;
|
|
137
|
-
|
|
138
|
-
if (rowGroupingModel != null) {
|
|
139
|
-
apiRef.current.setState(mergeStateWithRowGroupingModel(rowGroupingModel));
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return params;
|
|
143
|
-
}, [apiRef, props.disableRowGrouping]);
|
|
144
|
-
useGridRegisterPipeProcessor(apiRef, 'columnMenu', addColumnMenuButtons);
|
|
145
|
-
useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
146
|
-
useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
147
|
-
/**
|
|
148
|
-
* EVENTS
|
|
149
|
-
*/
|
|
150
|
-
|
|
151
|
-
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
152
|
-
const cellParams = apiRef.current.getCellParams(params.id, params.field);
|
|
153
|
-
|
|
154
|
-
if (isGroupingColumn(cellParams.field) && event.key === ' ' && !event.shiftKey) {
|
|
155
|
-
var _gridFilteredDescenda;
|
|
156
|
-
|
|
157
|
-
event.stopPropagation();
|
|
158
|
-
event.preventDefault();
|
|
159
|
-
const filteredDescendantCount = (_gridFilteredDescenda = gridFilteredDescendantCountLookupSelector(apiRef)[params.id]) != null ? _gridFilteredDescenda : 0;
|
|
160
|
-
const isOnGroupingCell = props.rowGroupingColumnMode === 'single' || getRowGroupingFieldFromGroupingCriteria(params.rowNode.groupingField) === params.field;
|
|
161
|
-
|
|
162
|
-
if (!isOnGroupingCell || filteredDescendantCount === 0) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
apiRef.current.setRowChildrenExpansion(params.id, !params.rowNode.childrenExpanded);
|
|
167
|
-
}
|
|
168
|
-
}, [apiRef, props.rowGroupingColumnMode]);
|
|
169
|
-
const checkGroupingColumnsModelDiff = React.useCallback(() => {
|
|
170
|
-
const rowGroupingModel = gridRowGroupingSanitizedModelSelector(apiRef);
|
|
171
|
-
const lastGroupingColumnsModelApplied = gridRowGroupingStateSelector(apiRef.current.state).unstable_sanitizedModelOnLastRowTreeCreation;
|
|
172
|
-
|
|
173
|
-
if (!isDeepEqual(lastGroupingColumnsModelApplied, rowGroupingModel)) {
|
|
174
|
-
apiRef.current.setState(state => _extends({}, state, {
|
|
175
|
-
rowGrouping: _extends({}, state.rowGrouping, {
|
|
176
|
-
unstable_sanitizedModelOnLastRowTreeCreation: rowGroupingModel
|
|
177
|
-
})
|
|
178
|
-
}));
|
|
179
|
-
apiRef.current.unstable_requestPipeProcessorsApplication('hydrateColumns');
|
|
180
|
-
setStrategyAvailability(apiRef, props.disableRowGrouping); // Refresh the row tree creation strategy processing
|
|
181
|
-
// TODO: Add a clean way to re-run a strategy processing without publishing a private event
|
|
182
|
-
|
|
183
|
-
if (apiRef.current.unstable_getActiveStrategy('rowTree') === ROW_GROUPING_STRATEGY) {
|
|
184
|
-
apiRef.current.publishEvent('activeStrategyProcessorChange', 'rowTreeCreation');
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}, [apiRef, props.disableRowGrouping]);
|
|
188
|
-
useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
189
|
-
useGridApiEventHandler(apiRef, 'columnsChange', checkGroupingColumnsModelDiff);
|
|
190
|
-
useGridApiEventHandler(apiRef, 'rowGroupingModelChange', checkGroupingColumnsModelDiff);
|
|
191
|
-
/**
|
|
192
|
-
* EFFECTS
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
|
-
React.useEffect(() => {
|
|
196
|
-
if (props.rowGroupingModel !== undefined) {
|
|
197
|
-
apiRef.current.setRowGroupingModel(props.rowGroupingModel);
|
|
198
|
-
}
|
|
199
|
-
}, [apiRef, props.rowGroupingModel]);
|
|
200
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { DataGridProProcessedProps } from '../../../models/dataGridProProps';
|
|
3
|
-
import { GridApiPro } from '../../../models/gridApiPro';
|
|
4
|
-
export declare const useGridRowGroupingPreProcessors: (apiRef: React.MutableRefObject<GridApiPro>, props: Pick<DataGridProProcessedProps, 'disableRowGrouping' | 'groupingColDef' | 'rowGroupingColumnMode' | 'defaultGroupingExpansionDepth' | 'isGroupExpandedByDefault'>) => void;
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { gridColumnLookupSelector, gridRowIdsSelector, gridRowTreeSelector, useFirstRender } from '@mui/x-data-grid';
|
|
4
|
-
import { useGridRegisterPipeProcessor, useGridRegisterStrategyProcessor } from '@mui/x-data-grid/internals';
|
|
5
|
-
import { sortRowTree } from '../../../utils/tree/sortRowTree';
|
|
6
|
-
import { buildRowTree } from '../../../utils/tree/buildRowTree';
|
|
7
|
-
import { gridRowGroupingModelSelector, gridRowGroupingSanitizedModelSelector } from './gridRowGroupingSelector';
|
|
8
|
-
import { createGroupingColDefForAllGroupingCriteria, createGroupingColDefForOneGroupingCriteria } from './createGroupingColDef';
|
|
9
|
-
import { filterRowTreeFromGroupingColumns, getColDefOverrides, ROW_GROUPING_STRATEGY, isGroupingColumn, setStrategyAvailability } from './gridRowGroupingUtils';
|
|
10
|
-
export const useGridRowGroupingPreProcessors = (apiRef, props) => {
|
|
11
|
-
const getGroupingColDefs = React.useCallback(columnsState => {
|
|
12
|
-
if (props.disableRowGrouping) {
|
|
13
|
-
return [];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const groupingColDefProp = props.groupingColDef; // We can't use `gridGroupingRowsSanitizedModelSelector` here because the new columns are not in the state yet
|
|
17
|
-
|
|
18
|
-
const rowGroupingModel = gridRowGroupingModelSelector(apiRef).filter(field => !!columnsState.lookup[field]);
|
|
19
|
-
|
|
20
|
-
if (rowGroupingModel.length === 0) {
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
switch (props.rowGroupingColumnMode) {
|
|
25
|
-
case 'single':
|
|
26
|
-
{
|
|
27
|
-
return [createGroupingColDefForAllGroupingCriteria({
|
|
28
|
-
apiRef,
|
|
29
|
-
rowGroupingModel,
|
|
30
|
-
colDefOverride: getColDefOverrides(groupingColDefProp, rowGroupingModel),
|
|
31
|
-
columnsLookup: columnsState.lookup
|
|
32
|
-
})];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
case 'multiple':
|
|
36
|
-
{
|
|
37
|
-
return rowGroupingModel.map(groupingCriteria => createGroupingColDefForOneGroupingCriteria({
|
|
38
|
-
groupingCriteria,
|
|
39
|
-
colDefOverride: getColDefOverrides(groupingColDefProp, [groupingCriteria]),
|
|
40
|
-
groupedByColDef: columnsState.lookup[groupingCriteria],
|
|
41
|
-
columnsLookup: columnsState.lookup
|
|
42
|
-
}));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
default:
|
|
46
|
-
{
|
|
47
|
-
return [];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}, [apiRef, props.groupingColDef, props.rowGroupingColumnMode, props.disableRowGrouping]);
|
|
51
|
-
const updateGroupingColumn = React.useCallback(columnsState => {
|
|
52
|
-
const groupingColDefs = getGroupingColDefs(columnsState);
|
|
53
|
-
let newColumnFields = [];
|
|
54
|
-
const newColumnsLookup = {}; // We only keep the non-grouping columns
|
|
55
|
-
|
|
56
|
-
columnsState.all.forEach(field => {
|
|
57
|
-
if (!isGroupingColumn(field)) {
|
|
58
|
-
newColumnFields.push(field);
|
|
59
|
-
newColumnsLookup[field] = columnsState.lookup[field];
|
|
60
|
-
}
|
|
61
|
-
}); // We add the grouping column
|
|
62
|
-
|
|
63
|
-
groupingColDefs.forEach(groupingColDef => {
|
|
64
|
-
const matchingGroupingColDef = columnsState.lookup[groupingColDef.field];
|
|
65
|
-
|
|
66
|
-
if (matchingGroupingColDef) {
|
|
67
|
-
groupingColDef.width = matchingGroupingColDef.width;
|
|
68
|
-
groupingColDef.flex = matchingGroupingColDef.flex;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
newColumnsLookup[groupingColDef.field] = groupingColDef;
|
|
72
|
-
});
|
|
73
|
-
const startIndex = newColumnFields[0] === '__check__' ? 1 : 0;
|
|
74
|
-
newColumnFields = [...newColumnFields.slice(0, startIndex), ...groupingColDefs.map(colDef => colDef.field), ...newColumnFields.slice(startIndex)];
|
|
75
|
-
columnsState.all = newColumnFields;
|
|
76
|
-
columnsState.lookup = newColumnsLookup;
|
|
77
|
-
return columnsState;
|
|
78
|
-
}, [getGroupingColDefs]);
|
|
79
|
-
const createRowTree = React.useCallback(params => {
|
|
80
|
-
const rowGroupingModel = gridRowGroupingSanitizedModelSelector(apiRef);
|
|
81
|
-
const columnsLookup = gridColumnLookupSelector(apiRef);
|
|
82
|
-
apiRef.current.setState(state => _extends({}, state, {
|
|
83
|
-
rowGrouping: _extends({}, state.rowGrouping, {
|
|
84
|
-
unstable_sanitizedModelOnLastRowTreeCreation: rowGroupingModel
|
|
85
|
-
})
|
|
86
|
-
}));
|
|
87
|
-
const distinctValues = Object.fromEntries(rowGroupingModel.map(groupingField => [groupingField, {
|
|
88
|
-
lookup: {},
|
|
89
|
-
list: []
|
|
90
|
-
}]));
|
|
91
|
-
|
|
92
|
-
const getCellGroupingCriteria = ({
|
|
93
|
-
row,
|
|
94
|
-
id,
|
|
95
|
-
colDef
|
|
96
|
-
}) => {
|
|
97
|
-
let key;
|
|
98
|
-
|
|
99
|
-
if (colDef.groupingValueGetter) {
|
|
100
|
-
const groupingValueGetterParams = {
|
|
101
|
-
colDef,
|
|
102
|
-
field: colDef.field,
|
|
103
|
-
value: row[colDef.field],
|
|
104
|
-
id,
|
|
105
|
-
row,
|
|
106
|
-
rowNode: {
|
|
107
|
-
isAutoGenerated: false,
|
|
108
|
-
id
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
key = colDef.groupingValueGetter(groupingValueGetterParams);
|
|
112
|
-
} else {
|
|
113
|
-
key = row[colDef.field];
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return {
|
|
117
|
-
key,
|
|
118
|
-
field: colDef.field
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
params.ids.forEach(rowId => {
|
|
123
|
-
const row = params.idRowsLookup[rowId];
|
|
124
|
-
rowGroupingModel.forEach(groupingCriteria => {
|
|
125
|
-
const {
|
|
126
|
-
key
|
|
127
|
-
} = getCellGroupingCriteria({
|
|
128
|
-
row,
|
|
129
|
-
id: rowId,
|
|
130
|
-
colDef: columnsLookup[groupingCriteria]
|
|
131
|
-
});
|
|
132
|
-
const groupingFieldsDistinctKeys = distinctValues[groupingCriteria];
|
|
133
|
-
|
|
134
|
-
if (key != null && !groupingFieldsDistinctKeys.lookup[key.toString()]) {
|
|
135
|
-
groupingFieldsDistinctKeys.lookup[key.toString()] = true;
|
|
136
|
-
groupingFieldsDistinctKeys.list.push(key);
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
const rows = params.ids.map(rowId => {
|
|
141
|
-
const row = params.idRowsLookup[rowId];
|
|
142
|
-
const parentPath = rowGroupingModel.map(groupingField => getCellGroupingCriteria({
|
|
143
|
-
row,
|
|
144
|
-
id: rowId,
|
|
145
|
-
colDef: columnsLookup[groupingField]
|
|
146
|
-
})).filter(cell => cell.key != null);
|
|
147
|
-
const leafGroupingCriteria = {
|
|
148
|
-
key: rowId.toString(),
|
|
149
|
-
field: null
|
|
150
|
-
};
|
|
151
|
-
return {
|
|
152
|
-
path: [...parentPath, leafGroupingCriteria],
|
|
153
|
-
id: rowId
|
|
154
|
-
};
|
|
155
|
-
});
|
|
156
|
-
return buildRowTree(_extends({}, params, {
|
|
157
|
-
rows,
|
|
158
|
-
defaultGroupingExpansionDepth: props.defaultGroupingExpansionDepth,
|
|
159
|
-
isGroupExpandedByDefault: props.isGroupExpandedByDefault,
|
|
160
|
-
groupingName: ROW_GROUPING_STRATEGY
|
|
161
|
-
}));
|
|
162
|
-
}, [apiRef, props.defaultGroupingExpansionDepth, props.isGroupExpandedByDefault]);
|
|
163
|
-
const filterRows = React.useCallback(params => {
|
|
164
|
-
const rowTree = gridRowTreeSelector(apiRef);
|
|
165
|
-
return filterRowTreeFromGroupingColumns({
|
|
166
|
-
rowTree,
|
|
167
|
-
isRowMatchingFilters: params.isRowMatchingFilters
|
|
168
|
-
});
|
|
169
|
-
}, [apiRef]);
|
|
170
|
-
const sortRows = React.useCallback(params => {
|
|
171
|
-
const rowTree = gridRowTreeSelector(apiRef);
|
|
172
|
-
const rowIds = gridRowIdsSelector(apiRef);
|
|
173
|
-
return sortRowTree({
|
|
174
|
-
rowTree,
|
|
175
|
-
rowIds,
|
|
176
|
-
sortRowList: params.sortRowList,
|
|
177
|
-
disableChildrenSorting: false
|
|
178
|
-
});
|
|
179
|
-
}, [apiRef]);
|
|
180
|
-
useGridRegisterPipeProcessor(apiRef, 'hydrateColumns', updateGroupingColumn);
|
|
181
|
-
useGridRegisterStrategyProcessor(apiRef, ROW_GROUPING_STRATEGY, 'rowTreeCreation', createRowTree);
|
|
182
|
-
useGridRegisterStrategyProcessor(apiRef, ROW_GROUPING_STRATEGY, 'filtering', filterRows);
|
|
183
|
-
useGridRegisterStrategyProcessor(apiRef, ROW_GROUPING_STRATEGY, 'sorting', sortRows);
|
|
184
|
-
/**
|
|
185
|
-
* 1ST RENDER
|
|
186
|
-
*/
|
|
187
|
-
|
|
188
|
-
useFirstRender(() => {
|
|
189
|
-
setStrategyAvailability(apiRef, props.disableRowGrouping);
|
|
190
|
-
});
|
|
191
|
-
/**
|
|
192
|
-
* EFFECTS
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
|
-
const isFirstRender = React.useRef(true);
|
|
196
|
-
React.useEffect(() => {
|
|
197
|
-
if (!isFirstRender.current) {
|
|
198
|
-
setStrategyAvailability(apiRef, props.disableRowGrouping);
|
|
199
|
-
} else {
|
|
200
|
-
isFirstRender.current = false;
|
|
201
|
-
}
|
|
202
|
-
}, [apiRef, props.disableRowGrouping]);
|
|
203
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import Box from '@mui/material/Box';
|
|
3
|
-
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
|
|
6
|
-
var GridGroupingColumnLeafCell = function GridGroupingColumnLeafCell(props) {
|
|
7
|
-
var _props$formattedValue;
|
|
8
|
-
|
|
9
|
-
var rowNode = props.rowNode;
|
|
10
|
-
var rootProps = useGridRootProps();
|
|
11
|
-
var marginLeft = rootProps.rowGroupingColumnMode === 'multiple' ? 1 : rowNode.depth * 2;
|
|
12
|
-
return /*#__PURE__*/_jsx(Box, {
|
|
13
|
-
sx: {
|
|
14
|
-
ml: marginLeft
|
|
15
|
-
},
|
|
16
|
-
children: (_props$formattedValue = props.formattedValue) != null ? _props$formattedValue : props.value
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export { GridGroupingColumnLeafCell };
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
3
|
-
import IconButton from '@mui/material/IconButton';
|
|
4
|
-
import Box from '@mui/material/Box';
|
|
5
|
-
import { useGridSelector, gridFilteredDescendantCountLookupSelector, getDataGridUtilityClass } from '@mui/x-data-grid';
|
|
6
|
-
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
7
|
-
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
8
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
-
|
|
11
|
-
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
12
|
-
var classes = ownerState.classes;
|
|
13
|
-
var slots = {
|
|
14
|
-
root: ['groupingCriteriaCell'],
|
|
15
|
-
toggle: ['groupingCriteriaCellToggle']
|
|
16
|
-
};
|
|
17
|
-
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export var GridGroupingCriteriaCell = function GridGroupingCriteriaCell(props) {
|
|
21
|
-
var _filteredDescendantCo;
|
|
22
|
-
|
|
23
|
-
var id = props.id,
|
|
24
|
-
field = props.field,
|
|
25
|
-
rowNode = props.rowNode,
|
|
26
|
-
hideDescendantCount = props.hideDescendantCount,
|
|
27
|
-
formattedValue = props.formattedValue;
|
|
28
|
-
var rootProps = useGridRootProps();
|
|
29
|
-
var apiRef = useGridApiContext();
|
|
30
|
-
var ownerState = {
|
|
31
|
-
classes: rootProps.classes
|
|
32
|
-
};
|
|
33
|
-
var classes = useUtilityClasses(ownerState);
|
|
34
|
-
var filteredDescendantCountLookup = useGridSelector(apiRef, gridFilteredDescendantCountLookupSelector);
|
|
35
|
-
var filteredDescendantCount = (_filteredDescendantCo = filteredDescendantCountLookup[rowNode.id]) != null ? _filteredDescendantCo : 0;
|
|
36
|
-
var Icon = rowNode.childrenExpanded ? rootProps.components.GroupingCriteriaCollapseIcon : rootProps.components.GroupingCriteriaExpandIcon;
|
|
37
|
-
|
|
38
|
-
var handleKeyDown = function handleKeyDown(event) {
|
|
39
|
-
if (event.key === ' ') {
|
|
40
|
-
event.stopPropagation();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
apiRef.current.publishEvent('cellKeyDown', props, event);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
var handleClick = function handleClick(event) {
|
|
47
|
-
apiRef.current.setRowChildrenExpansion(id, !rowNode.childrenExpanded);
|
|
48
|
-
apiRef.current.setCellFocus(id, field);
|
|
49
|
-
event.stopPropagation();
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
var marginLeft = rootProps.rowGroupingColumnMode === 'multiple' ? 0 : rowNode.depth * 2;
|
|
53
|
-
return /*#__PURE__*/_jsxs(Box, {
|
|
54
|
-
className: classes.root,
|
|
55
|
-
sx: {
|
|
56
|
-
ml: marginLeft
|
|
57
|
-
},
|
|
58
|
-
children: [/*#__PURE__*/_jsx("div", {
|
|
59
|
-
className: classes.toggle,
|
|
60
|
-
children: filteredDescendantCount > 0 && /*#__PURE__*/_jsx(IconButton, {
|
|
61
|
-
size: "small",
|
|
62
|
-
onClick: handleClick,
|
|
63
|
-
onKeyDown: handleKeyDown,
|
|
64
|
-
tabIndex: -1,
|
|
65
|
-
"aria-label": rowNode.childrenExpanded ? apiRef.current.getLocaleText('treeDataCollapse') : apiRef.current.getLocaleText('treeDataExpand'),
|
|
66
|
-
children: /*#__PURE__*/_jsx(Icon, {
|
|
67
|
-
fontSize: "inherit"
|
|
68
|
-
})
|
|
69
|
-
})
|
|
70
|
-
}), /*#__PURE__*/_jsxs("span", {
|
|
71
|
-
children: [formattedValue === undefined ? rowNode.groupingKey : formattedValue, !hideDescendantCount && filteredDescendantCount > 0 ? " (".concat(filteredDescendantCount, ")") : '']
|
|
72
|
-
})]
|
|
73
|
-
});
|
|
74
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import MenuItem from '@mui/material/MenuItem';
|
|
4
|
-
import { gridColumnLookupSelector, useGridSelector } from '@mui/x-data-grid';
|
|
5
|
-
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
6
|
-
import { gridRowGroupingSanitizedModelSelector } from '../hooks/features/rowGrouping/gridRowGroupingSelector';
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
|
|
9
|
-
var GridRowGroupableColumnMenuItems = function GridRowGroupableColumnMenuItems(props) {
|
|
10
|
-
var _columnsLookup$column;
|
|
11
|
-
|
|
12
|
-
var column = props.column,
|
|
13
|
-
onClick = props.onClick;
|
|
14
|
-
var apiRef = useGridApiContext();
|
|
15
|
-
var rowGroupingModel = useGridSelector(apiRef, gridRowGroupingSanitizedModelSelector);
|
|
16
|
-
var columnsLookup = useGridSelector(apiRef, gridColumnLookupSelector);
|
|
17
|
-
|
|
18
|
-
if (!(column != null && column.groupable)) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
var ungroupColumn = function ungroupColumn(event) {
|
|
23
|
-
apiRef.current.removeRowGroupingCriteria(column.field);
|
|
24
|
-
|
|
25
|
-
if (onClick) {
|
|
26
|
-
onClick(event);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
var groupColumn = function groupColumn(event) {
|
|
31
|
-
apiRef.current.addRowGroupingCriteria(column.field);
|
|
32
|
-
|
|
33
|
-
if (onClick) {
|
|
34
|
-
onClick(event);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
var name = (_columnsLookup$column = columnsLookup[column.field].headerName) != null ? _columnsLookup$column : column.field;
|
|
39
|
-
|
|
40
|
-
if (rowGroupingModel.includes(column.field)) {
|
|
41
|
-
return /*#__PURE__*/_jsx(MenuItem, {
|
|
42
|
-
onClick: ungroupColumn,
|
|
43
|
-
children: apiRef.current.getLocaleText('unGroupColumn')(name)
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return /*#__PURE__*/_jsx(MenuItem, {
|
|
48
|
-
onClick: groupColumn,
|
|
49
|
-
children: apiRef.current.getLocaleText('groupColumn')(name)
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
process.env.NODE_ENV !== "production" ? GridRowGroupableColumnMenuItems.propTypes = {
|
|
54
|
-
// ----------------------------- Warning --------------------------------
|
|
55
|
-
// | These PropTypes are generated from the TypeScript type definitions |
|
|
56
|
-
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
57
|
-
// ----------------------------------------------------------------------
|
|
58
|
-
column: PropTypes.object,
|
|
59
|
-
onClick: PropTypes.func
|
|
60
|
-
} : void 0;
|
|
61
|
-
export { GridRowGroupableColumnMenuItems };
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import MenuItem from '@mui/material/MenuItem';
|
|
4
|
-
import { useGridSelector, gridColumnLookupSelector } from '@mui/x-data-grid';
|
|
5
|
-
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
6
|
-
import { gridRowGroupingSanitizedModelSelector } from '../hooks/features/rowGrouping/gridRowGroupingSelector';
|
|
7
|
-
import { getRowGroupingCriteriaFromGroupingField, GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD, isGroupingColumn } from '../hooks/features/rowGrouping/gridRowGroupingUtils';
|
|
8
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
|
|
10
|
-
var GridRowGroupingColumnMenuItems = function GridRowGroupingColumnMenuItems(props) {
|
|
11
|
-
var column = props.column,
|
|
12
|
-
onClick = props.onClick;
|
|
13
|
-
var apiRef = useGridApiContext();
|
|
14
|
-
var rowGroupingModel = useGridSelector(apiRef, gridRowGroupingSanitizedModelSelector);
|
|
15
|
-
var columnsLookup = useGridSelector(apiRef, gridColumnLookupSelector);
|
|
16
|
-
|
|
17
|
-
var renderUnGroupingMenuItem = function renderUnGroupingMenuItem(field) {
|
|
18
|
-
var _columnsLookup$field$;
|
|
19
|
-
|
|
20
|
-
var ungroupColumn = function ungroupColumn(event) {
|
|
21
|
-
apiRef.current.removeRowGroupingCriteria(field);
|
|
22
|
-
|
|
23
|
-
if (onClick) {
|
|
24
|
-
onClick(event);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
var name = (_columnsLookup$field$ = columnsLookup[field].headerName) != null ? _columnsLookup$field$ : field;
|
|
29
|
-
return /*#__PURE__*/_jsx(MenuItem, {
|
|
30
|
-
onClick: ungroupColumn,
|
|
31
|
-
children: apiRef.current.getLocaleText('unGroupColumn')(name)
|
|
32
|
-
}, field);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
if (!column || !isGroupingColumn(column.field)) {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (column.field === GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD) {
|
|
40
|
-
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
41
|
-
children: rowGroupingModel.map(renderUnGroupingMenuItem)
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return renderUnGroupingMenuItem(getRowGroupingCriteriaFromGroupingField(column.field));
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
process.env.NODE_ENV !== "production" ? GridRowGroupingColumnMenuItems.propTypes = {
|
|
49
|
-
// ----------------------------- Warning --------------------------------
|
|
50
|
-
// | These PropTypes are generated from the TypeScript type definitions |
|
|
51
|
-
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
52
|
-
// ----------------------------------------------------------------------
|
|
53
|
-
column: PropTypes.object,
|
|
54
|
-
onClick: PropTypes.func
|
|
55
|
-
} : void 0;
|
|
56
|
-
export { GridRowGroupingColumnMenuItems };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { useGridApiEventHandler, gridRowIdsSelector } from '@mui/x-data-grid';
|
|
4
|
-
|
|
5
|
-
function cacheContentAndHeight(apiRef, getDetailPanelContent, getDetailPanelHeight) {
|
|
6
|
-
if (typeof getDetailPanelContent !== 'function') {
|
|
7
|
-
return {};
|
|
8
|
-
} // TODO change to lazy approach using a Proxy
|
|
9
|
-
// only call getDetailPanelContent when asked for an id
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var rowIds = gridRowIdsSelector(apiRef);
|
|
13
|
-
var contentCache = rowIds.reduce(function (acc, id) {
|
|
14
|
-
var params = apiRef.current.getRowParams(id);
|
|
15
|
-
acc[id] = getDetailPanelContent(params);
|
|
16
|
-
return acc;
|
|
17
|
-
}, {});
|
|
18
|
-
var heightCache = rowIds.reduce(function (acc, id) {
|
|
19
|
-
if (contentCache[id] == null) {
|
|
20
|
-
return acc;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
var params = apiRef.current.getRowParams(id);
|
|
24
|
-
acc[id] = getDetailPanelHeight(params);
|
|
25
|
-
return acc;
|
|
26
|
-
}, {});
|
|
27
|
-
return {
|
|
28
|
-
contentCache: contentCache,
|
|
29
|
-
heightCache: heightCache
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export var useGridDetailPanelCache = function useGridDetailPanelCache(apiRef, props) {
|
|
34
|
-
var updateCaches = React.useCallback(function () {
|
|
35
|
-
apiRef.current.setState(function (state) {
|
|
36
|
-
return _extends({}, state, {
|
|
37
|
-
detailPanel: _extends({}, state.detailPanel, cacheContentAndHeight(apiRef, props.getDetailPanelContent, props.getDetailPanelHeight))
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
apiRef.current.forceUpdate();
|
|
41
|
-
}, [apiRef, props.getDetailPanelContent, props.getDetailPanelHeight]);
|
|
42
|
-
useGridApiEventHandler(apiRef, 'sortedRowsSet', updateCaches);
|
|
43
|
-
var isFirstRender = React.useRef(true);
|
|
44
|
-
|
|
45
|
-
if (isFirstRender.current) {
|
|
46
|
-
isFirstRender.current = false;
|
|
47
|
-
updateCaches();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
React.useEffect(function () {
|
|
51
|
-
if (isFirstRender.current) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
updateCaches();
|
|
56
|
-
}, [updateCaches]);
|
|
57
|
-
};
|