@mui/x-data-grid-premium 5.11.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 +4052 -0
- package/DataGridPremium/DataGridPremium.d.ts +9 -0
- package/DataGridPremium/DataGridPremium.js +986 -0
- package/DataGridPremium/index.d.ts +2 -0
- package/DataGridPremium/index.js +2 -0
- package/DataGridPremium/package.json +6 -0
- package/DataGridPremium/useDataGridPremiumComponent.d.ts +4 -0
- package/DataGridPremium/useDataGridPremiumComponent.js +78 -0
- package/DataGridPremium/useDataGridPremiumProps.d.ts +6 -0
- package/DataGridPremium/useDataGridPremiumProps.js +37 -0
- package/LICENSE +12 -0
- package/README.md +31 -0
- package/components/GridExcelExportMenuItem.d.ts +9 -0
- package/components/GridExcelExportMenuItem.js +32 -0
- package/components/GridGroupingColumnLeafCell.d.ts +4 -0
- package/components/GridGroupingColumnLeafCell.js +22 -0
- package/components/GridGroupingCriteriaCell.d.ts +7 -0
- package/components/GridGroupingCriteriaCell.js +78 -0
- package/components/GridRowGroupableColumnMenuItems.d.ts +11 -0
- package/components/GridRowGroupableColumnMenuItems.js +63 -0
- package/components/GridRowGroupingColumnMenuItems.d.ts +11 -0
- package/components/GridRowGroupingColumnMenuItems.js +58 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +1 -0
- package/components/package.json +6 -0
- package/hooks/features/export/gridExcelExportInterface.d.ts +58 -0
- package/hooks/features/export/gridExcelExportInterface.js +1 -0
- package/hooks/features/export/index.d.ts +1 -0
- package/hooks/features/export/index.js +1 -0
- package/hooks/features/export/serializer/excelSerializer.d.ts +14 -0
- package/hooks/features/export/serializer/excelSerializer.js +218 -0
- package/hooks/features/export/useGridExcelExport.d.ts +10 -0
- package/hooks/features/export/useGridExcelExport.js +77 -0
- package/hooks/features/index.d.ts +2 -0
- package/hooks/features/index.js +3 -0
- package/hooks/features/rowGrouping/createGroupingColDef.d.ts +42 -0
- package/hooks/features/rowGrouping/createGroupingColDef.js +318 -0
- package/hooks/features/rowGrouping/gridRowGroupingInterfaces.d.ts +37 -0
- package/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +1 -0
- package/hooks/features/rowGrouping/gridRowGroupingSelector.d.ts +4 -0
- package/hooks/features/rowGrouping/gridRowGroupingSelector.js +5 -0
- package/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +27 -0
- package/hooks/features/rowGrouping/gridRowGroupingUtils.js +139 -0
- package/hooks/features/rowGrouping/index.d.ts +3 -0
- package/hooks/features/rowGrouping/index.js +3 -0
- package/hooks/features/rowGrouping/useGridRowGrouping.d.ts +11 -0
- package/hooks/features/rowGrouping/useGridRowGrouping.js +200 -0
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +4 -0
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +201 -0
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +3 -0
- package/hooks/package.json +6 -0
- package/hooks/utils/index.d.ts +1 -0
- package/hooks/utils/index.js +1 -0
- package/hooks/utils/useGridApiContext.d.ts +4 -0
- package/hooks/utils/useGridApiContext.js +2 -0
- package/hooks/utils/useGridApiRef.d.ts +4 -0
- package/hooks/utils/useGridApiRef.js +2 -0
- package/hooks/utils/useGridRootProps.d.ts +2 -0
- package/hooks/utils/useGridRootProps.js +2 -0
- package/hooks/utils/useKeepGroupedColumnsHidden.d.ts +12 -0
- package/hooks/utils/useKeepGroupedColumnsHidden.js +50 -0
- package/index.d.ts +22 -0
- package/index.js +25 -0
- package/legacy/DataGridPremium/DataGridPremium.js +986 -0
- package/legacy/DataGridPremium/index.js +2 -0
- package/legacy/DataGridPremium/useDataGridPremiumComponent.js +78 -0
- package/legacy/DataGridPremium/useDataGridPremiumProps.js +46 -0
- package/legacy/components/GridExcelExportMenuItem.js +30 -0
- package/legacy/components/GridGroupingColumnLeafCell.js +20 -0
- package/legacy/components/GridGroupingCriteriaCell.js +74 -0
- package/legacy/components/GridRowGroupableColumnMenuItems.js +61 -0
- package/legacy/components/GridRowGroupingColumnMenuItems.js +56 -0
- package/legacy/components/index.js +1 -0
- package/legacy/hooks/features/export/gridExcelExportInterface.js +1 -0
- package/legacy/hooks/features/export/index.js +1 -0
- package/legacy/hooks/features/export/serializer/excelSerializer.js +260 -0
- package/legacy/hooks/features/export/useGridExcelExport.js +111 -0
- package/legacy/hooks/features/index.js +3 -0
- package/legacy/hooks/features/rowGrouping/createGroupingColDef.js +319 -0
- package/legacy/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +1 -0
- package/legacy/hooks/features/rowGrouping/gridRowGroupingSelector.js +13 -0
- package/legacy/hooks/features/rowGrouping/gridRowGroupingUtils.js +147 -0
- package/legacy/hooks/features/rowGrouping/index.js +3 -0
- package/legacy/hooks/features/rowGrouping/useGridRowGrouping.js +206 -0
- package/legacy/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +215 -0
- package/legacy/hooks/index.js +3 -0
- package/legacy/hooks/utils/index.js +1 -0
- package/legacy/hooks/utils/useGridApiContext.js +2 -0
- package/legacy/hooks/utils/useGridApiRef.js +2 -0
- package/legacy/hooks/utils/useGridRootProps.js +2 -0
- package/legacy/hooks/utils/useKeepGroupedColumnsHidden.js +50 -0
- package/legacy/index.js +25 -0
- package/legacy/models/dataGridPremiumProps.js +1 -0
- package/legacy/models/gridApiPremium.js +1 -0
- package/legacy/models/gridGroupingValueGetterParams.js +1 -0
- package/legacy/models/gridStatePremium.js +1 -0
- package/legacy/models/index.js +1 -0
- package/legacy/typeOverloads/index.js +1 -0
- package/legacy/typeOverloads/modules.js +33 -0
- package/legacy/typeOverloads/reexports.js +6 -0
- package/legacy/utils/releaseInfo.js +15 -0
- package/models/dataGridPremiumProps.d.ts +64 -0
- package/models/dataGridPremiumProps.js +1 -0
- package/models/gridApiPremium.d.ts +13 -0
- package/models/gridApiPremium.js +1 -0
- package/models/gridGroupingValueGetterParams.d.ts +31 -0
- package/models/gridGroupingValueGetterParams.js +1 -0
- package/models/gridStatePremium.d.ts +14 -0
- package/models/gridStatePremium.js +1 -0
- package/models/index.d.ts +1 -0
- package/models/index.js +1 -0
- package/models/package.json +6 -0
- package/modern/DataGridPremium/DataGridPremium.js +986 -0
- package/modern/DataGridPremium/index.js +2 -0
- package/modern/DataGridPremium/useDataGridPremiumComponent.js +76 -0
- package/modern/DataGridPremium/useDataGridPremiumProps.js +37 -0
- package/modern/components/GridExcelExportMenuItem.js +32 -0
- package/modern/components/GridGroupingColumnLeafCell.js +20 -0
- package/modern/components/GridGroupingCriteriaCell.js +76 -0
- package/modern/components/GridRowGroupableColumnMenuItems.js +61 -0
- package/modern/components/GridRowGroupingColumnMenuItems.js +56 -0
- package/modern/components/index.js +1 -0
- package/modern/hooks/features/export/gridExcelExportInterface.js +1 -0
- package/modern/hooks/features/export/index.js +1 -0
- package/modern/hooks/features/export/serializer/excelSerializer.js +216 -0
- package/modern/hooks/features/export/useGridExcelExport.js +73 -0
- package/modern/hooks/features/index.js +3 -0
- package/modern/hooks/features/rowGrouping/createGroupingColDef.js +302 -0
- package/modern/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +1 -0
- package/modern/hooks/features/rowGrouping/gridRowGroupingSelector.js +5 -0
- package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +137 -0
- package/modern/hooks/features/rowGrouping/index.js +3 -0
- package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +192 -0
- package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +201 -0
- package/modern/hooks/index.js +3 -0
- package/modern/hooks/utils/index.js +1 -0
- package/modern/hooks/utils/useGridApiContext.js +2 -0
- package/modern/hooks/utils/useGridApiRef.js +2 -0
- package/modern/hooks/utils/useGridRootProps.js +2 -0
- package/modern/hooks/utils/useKeepGroupedColumnsHidden.js +46 -0
- package/modern/index.js +25 -0
- package/modern/models/dataGridPremiumProps.js +1 -0
- package/modern/models/gridApiPremium.js +1 -0
- package/modern/models/gridGroupingValueGetterParams.js +1 -0
- package/modern/models/gridStatePremium.js +1 -0
- package/modern/models/index.js +1 -0
- package/modern/typeOverloads/index.js +1 -0
- package/modern/typeOverloads/modules.js +33 -0
- package/modern/typeOverloads/reexports.js +6 -0
- package/modern/utils/releaseInfo.js +15 -0
- package/node/DataGridPremium/DataGridPremium.js +1009 -0
- package/node/DataGridPremium/index.js +30 -0
- package/node/DataGridPremium/useDataGridPremiumComponent.js +91 -0
- package/node/DataGridPremium/useDataGridPremiumProps.js +57 -0
- package/node/components/GridExcelExportMenuItem.js +49 -0
- package/node/components/GridGroupingColumnLeafCell.js +38 -0
- package/node/components/GridGroupingCriteriaCell.js +99 -0
- package/node/components/GridRowGroupableColumnMenuItems.js +82 -0
- package/node/components/GridRowGroupingColumnMenuItems.js +78 -0
- package/node/components/index.js +18 -0
- package/node/hooks/features/export/gridExcelExportInterface.js +5 -0
- package/node/hooks/features/export/index.js +18 -0
- package/node/hooks/features/export/serializer/excelSerializer.js +233 -0
- package/node/hooks/features/export/useGridExcelExport.js +95 -0
- package/node/hooks/features/index.js +31 -0
- package/node/hooks/features/rowGrouping/createGroupingColDef.js +341 -0
- package/node/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +5 -0
- package/node/hooks/features/rowGrouping/gridRowGroupingSelector.js +18 -0
- package/node/hooks/features/rowGrouping/gridRowGroupingUtils.js +172 -0
- package/node/hooks/features/rowGrouping/index.js +51 -0
- package/node/hooks/features/rowGrouping/useGridRowGrouping.js +228 -0
- package/node/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +223 -0
- package/node/hooks/index.js +31 -0
- package/node/hooks/utils/index.js +18 -0
- package/node/hooks/utils/useGridApiContext.js +11 -0
- package/node/hooks/utils/useGridApiRef.js +11 -0
- package/node/hooks/utils/useGridRootProps.js +11 -0
- package/node/hooks/utils/useKeepGroupedColumnsHidden.js +66 -0
- package/node/index.js +272 -0
- package/node/models/dataGridPremiumProps.js +5 -0
- package/node/models/gridApiPremium.js +5 -0
- package/node/models/gridGroupingValueGetterParams.js +5 -0
- package/node/models/gridStatePremium.js +5 -0
- package/node/models/index.js +18 -0
- package/node/typeOverloads/index.js +3 -0
- package/node/typeOverloads/modules.js +34 -0
- package/node/typeOverloads/reexports.js +29 -0
- package/node/utils/releaseInfo.js +25 -0
- package/package.json +63 -0
- package/typeOverloads/index.d.ts +1 -0
- package/typeOverloads/index.js +1 -0
- package/typeOverloads/modules.d.ts +0 -0
- package/typeOverloads/modules.js +33 -0
- package/typeOverloads/package.json +6 -0
- package/typeOverloads/reexports.d.ts +22 -0
- package/typeOverloads/reexports.js +6 -0
- package/utils/releaseInfo.d.ts +1 -0
- package/utils/releaseInfo.js +15 -0
|
@@ -0,0 +1,201 @@
|
|
|
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-pro';
|
|
4
|
+
import { useGridRegisterPipeProcessor, useGridRegisterStrategyProcessor, sortRowTree, buildRowTree } from '@mui/x-data-grid-pro/internals';
|
|
5
|
+
import { gridRowGroupingModelSelector, gridRowGroupingSanitizedModelSelector } from './gridRowGroupingSelector';
|
|
6
|
+
import { createGroupingColDefForAllGroupingCriteria, createGroupingColDefForOneGroupingCriteria } from './createGroupingColDef';
|
|
7
|
+
import { filterRowTreeFromGroupingColumns, getColDefOverrides, ROW_GROUPING_STRATEGY, isGroupingColumn, setStrategyAvailability } from './gridRowGroupingUtils';
|
|
8
|
+
export const useGridRowGroupingPreProcessors = (apiRef, props) => {
|
|
9
|
+
const getGroupingColDefs = React.useCallback(columnsState => {
|
|
10
|
+
if (props.disableRowGrouping) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const groupingColDefProp = props.groupingColDef; // We can't use `gridGroupingRowsSanitizedModelSelector` here because the new columns are not in the state yet
|
|
15
|
+
|
|
16
|
+
const rowGroupingModel = gridRowGroupingModelSelector(apiRef).filter(field => !!columnsState.lookup[field]);
|
|
17
|
+
|
|
18
|
+
if (rowGroupingModel.length === 0) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
switch (props.rowGroupingColumnMode) {
|
|
23
|
+
case 'single':
|
|
24
|
+
{
|
|
25
|
+
return [createGroupingColDefForAllGroupingCriteria({
|
|
26
|
+
apiRef,
|
|
27
|
+
rowGroupingModel,
|
|
28
|
+
colDefOverride: getColDefOverrides(groupingColDefProp, rowGroupingModel),
|
|
29
|
+
columnsLookup: columnsState.lookup
|
|
30
|
+
})];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
case 'multiple':
|
|
34
|
+
{
|
|
35
|
+
return rowGroupingModel.map(groupingCriteria => createGroupingColDefForOneGroupingCriteria({
|
|
36
|
+
groupingCriteria,
|
|
37
|
+
colDefOverride: getColDefOverrides(groupingColDefProp, [groupingCriteria]),
|
|
38
|
+
groupedByColDef: columnsState.lookup[groupingCriteria],
|
|
39
|
+
columnsLookup: columnsState.lookup
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
default:
|
|
44
|
+
{
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}, [apiRef, props.groupingColDef, props.rowGroupingColumnMode, props.disableRowGrouping]);
|
|
49
|
+
const updateGroupingColumn = React.useCallback(columnsState => {
|
|
50
|
+
const groupingColDefs = getGroupingColDefs(columnsState);
|
|
51
|
+
let newColumnFields = [];
|
|
52
|
+
const newColumnsLookup = {}; // We only keep the non-grouping columns
|
|
53
|
+
|
|
54
|
+
columnsState.all.forEach(field => {
|
|
55
|
+
if (!isGroupingColumn(field)) {
|
|
56
|
+
newColumnFields.push(field);
|
|
57
|
+
newColumnsLookup[field] = columnsState.lookup[field];
|
|
58
|
+
}
|
|
59
|
+
}); // We add the grouping column
|
|
60
|
+
|
|
61
|
+
groupingColDefs.forEach(groupingColDef => {
|
|
62
|
+
const matchingGroupingColDef = columnsState.lookup[groupingColDef.field];
|
|
63
|
+
|
|
64
|
+
if (matchingGroupingColDef) {
|
|
65
|
+
groupingColDef.width = matchingGroupingColDef.width;
|
|
66
|
+
groupingColDef.flex = matchingGroupingColDef.flex;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
newColumnsLookup[groupingColDef.field] = groupingColDef;
|
|
70
|
+
});
|
|
71
|
+
const startIndex = newColumnFields[0] === '__check__' ? 1 : 0;
|
|
72
|
+
newColumnFields = [...newColumnFields.slice(0, startIndex), ...groupingColDefs.map(colDef => colDef.field), ...newColumnFields.slice(startIndex)];
|
|
73
|
+
columnsState.all = newColumnFields;
|
|
74
|
+
columnsState.lookup = newColumnsLookup;
|
|
75
|
+
return columnsState;
|
|
76
|
+
}, [getGroupingColDefs]);
|
|
77
|
+
const createRowTree = React.useCallback(params => {
|
|
78
|
+
const rowGroupingModel = gridRowGroupingSanitizedModelSelector(apiRef);
|
|
79
|
+
const columnsLookup = gridColumnLookupSelector(apiRef);
|
|
80
|
+
apiRef.current.setState(state => _extends({}, state, {
|
|
81
|
+
rowGrouping: _extends({}, state.rowGrouping, {
|
|
82
|
+
unstable_sanitizedModelOnLastRowTreeCreation: rowGroupingModel
|
|
83
|
+
})
|
|
84
|
+
}));
|
|
85
|
+
const distinctValues = Object.fromEntries(rowGroupingModel.map(groupingField => [groupingField, {
|
|
86
|
+
lookup: {},
|
|
87
|
+
list: []
|
|
88
|
+
}]));
|
|
89
|
+
|
|
90
|
+
const getCellGroupingCriteria = ({
|
|
91
|
+
row,
|
|
92
|
+
id,
|
|
93
|
+
colDef
|
|
94
|
+
}) => {
|
|
95
|
+
let key;
|
|
96
|
+
|
|
97
|
+
if (colDef.groupingValueGetter) {
|
|
98
|
+
const groupingValueGetterParams = {
|
|
99
|
+
colDef,
|
|
100
|
+
field: colDef.field,
|
|
101
|
+
value: row[colDef.field],
|
|
102
|
+
id,
|
|
103
|
+
row,
|
|
104
|
+
rowNode: {
|
|
105
|
+
isAutoGenerated: false,
|
|
106
|
+
id
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
key = colDef.groupingValueGetter(groupingValueGetterParams);
|
|
110
|
+
} else {
|
|
111
|
+
key = row[colDef.field];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
key,
|
|
116
|
+
field: colDef.field
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
params.ids.forEach(rowId => {
|
|
121
|
+
const row = params.idRowsLookup[rowId];
|
|
122
|
+
rowGroupingModel.forEach(groupingCriteria => {
|
|
123
|
+
const {
|
|
124
|
+
key
|
|
125
|
+
} = getCellGroupingCriteria({
|
|
126
|
+
row,
|
|
127
|
+
id: rowId,
|
|
128
|
+
colDef: columnsLookup[groupingCriteria]
|
|
129
|
+
});
|
|
130
|
+
const groupingFieldsDistinctKeys = distinctValues[groupingCriteria];
|
|
131
|
+
|
|
132
|
+
if (key != null && !groupingFieldsDistinctKeys.lookup[key.toString()]) {
|
|
133
|
+
groupingFieldsDistinctKeys.lookup[key.toString()] = true;
|
|
134
|
+
groupingFieldsDistinctKeys.list.push(key);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
const rows = params.ids.map(rowId => {
|
|
139
|
+
const row = params.idRowsLookup[rowId];
|
|
140
|
+
const parentPath = rowGroupingModel.map(groupingField => getCellGroupingCriteria({
|
|
141
|
+
row,
|
|
142
|
+
id: rowId,
|
|
143
|
+
colDef: columnsLookup[groupingField]
|
|
144
|
+
})).filter(cell => cell.key != null);
|
|
145
|
+
const leafGroupingCriteria = {
|
|
146
|
+
key: rowId.toString(),
|
|
147
|
+
field: null
|
|
148
|
+
};
|
|
149
|
+
return {
|
|
150
|
+
path: [...parentPath, leafGroupingCriteria],
|
|
151
|
+
id: rowId
|
|
152
|
+
};
|
|
153
|
+
});
|
|
154
|
+
return buildRowTree(_extends({}, params, {
|
|
155
|
+
rows,
|
|
156
|
+
defaultGroupingExpansionDepth: props.defaultGroupingExpansionDepth,
|
|
157
|
+
isGroupExpandedByDefault: props.isGroupExpandedByDefault,
|
|
158
|
+
groupingName: ROW_GROUPING_STRATEGY
|
|
159
|
+
}));
|
|
160
|
+
}, [apiRef, props.defaultGroupingExpansionDepth, props.isGroupExpandedByDefault]);
|
|
161
|
+
const filterRows = React.useCallback(params => {
|
|
162
|
+
const rowTree = gridRowTreeSelector(apiRef);
|
|
163
|
+
return filterRowTreeFromGroupingColumns({
|
|
164
|
+
rowTree,
|
|
165
|
+
isRowMatchingFilters: params.isRowMatchingFilters
|
|
166
|
+
});
|
|
167
|
+
}, [apiRef]);
|
|
168
|
+
const sortRows = React.useCallback(params => {
|
|
169
|
+
const rowTree = gridRowTreeSelector(apiRef);
|
|
170
|
+
const rowIds = gridRowIdsSelector(apiRef);
|
|
171
|
+
return sortRowTree({
|
|
172
|
+
rowTree,
|
|
173
|
+
rowIds,
|
|
174
|
+
sortRowList: params.sortRowList,
|
|
175
|
+
disableChildrenSorting: false
|
|
176
|
+
});
|
|
177
|
+
}, [apiRef]);
|
|
178
|
+
useGridRegisterPipeProcessor(apiRef, 'hydrateColumns', updateGroupingColumn);
|
|
179
|
+
useGridRegisterStrategyProcessor(apiRef, ROW_GROUPING_STRATEGY, 'rowTreeCreation', createRowTree);
|
|
180
|
+
useGridRegisterStrategyProcessor(apiRef, ROW_GROUPING_STRATEGY, 'filtering', filterRows);
|
|
181
|
+
useGridRegisterStrategyProcessor(apiRef, ROW_GROUPING_STRATEGY, 'sorting', sortRows);
|
|
182
|
+
/**
|
|
183
|
+
* 1ST RENDER
|
|
184
|
+
*/
|
|
185
|
+
|
|
186
|
+
useFirstRender(() => {
|
|
187
|
+
setStrategyAvailability(apiRef, props.disableRowGrouping);
|
|
188
|
+
});
|
|
189
|
+
/**
|
|
190
|
+
* EFFECTS
|
|
191
|
+
*/
|
|
192
|
+
|
|
193
|
+
const isFirstRender = React.useRef(true);
|
|
194
|
+
React.useEffect(() => {
|
|
195
|
+
if (!isFirstRender.current) {
|
|
196
|
+
setStrategyAvailability(apiRef, props.disableRowGrouping);
|
|
197
|
+
} else {
|
|
198
|
+
isFirstRender.current = false;
|
|
199
|
+
}
|
|
200
|
+
}, [apiRef, props.disableRowGrouping]);
|
|
201
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useKeepGroupedColumnsHidden';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { gridColumnVisibilityModelSelector, GridEvents } from '@mui/x-data-grid-pro';
|
|
4
|
+
|
|
5
|
+
const updateColumnVisibilityModel = (columnVisibilityModel, rowGroupingModel, prevRowGroupingModel) => {
|
|
6
|
+
const newColumnVisibilityModel = _extends({}, columnVisibilityModel);
|
|
7
|
+
|
|
8
|
+
rowGroupingModel?.forEach(field => {
|
|
9
|
+
if (!prevRowGroupingModel?.includes(field)) {
|
|
10
|
+
newColumnVisibilityModel[field] = false;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
prevRowGroupingModel?.forEach(field => {
|
|
14
|
+
if (!rowGroupingModel?.includes(field)) {
|
|
15
|
+
newColumnVisibilityModel[field] = true;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return newColumnVisibilityModel;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Automatically hide columns when added to the row grouping model and stop hiding them when they are removed.
|
|
22
|
+
* Handles both the `props.initialState.rowGrouping.model` and `props.rowGroupingModel`
|
|
23
|
+
* Does not work when used with the `hide` property of `GridColDef`
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
export const useKeepGroupedColumnsHidden = props => {
|
|
28
|
+
const initialProps = React.useRef(props);
|
|
29
|
+
const rowGroupingModel = React.useRef(props.rowGroupingModel ?? props.initialState?.rowGrouping?.model);
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
props.apiRef.current.subscribeEvent(GridEvents.rowGroupingModelChange, newModel => {
|
|
32
|
+
const columnVisibilityModel = updateColumnVisibilityModel(gridColumnVisibilityModelSelector(props.apiRef), newModel, rowGroupingModel.current);
|
|
33
|
+
props.apiRef.current.setColumnVisibilityModel(columnVisibilityModel);
|
|
34
|
+
rowGroupingModel.current = newModel;
|
|
35
|
+
});
|
|
36
|
+
}, [props.apiRef]);
|
|
37
|
+
return React.useMemo(() => {
|
|
38
|
+
const invariantInitialState = initialProps.current.initialState;
|
|
39
|
+
const columnVisibilityModel = updateColumnVisibilityModel(invariantInitialState?.columns?.columnVisibilityModel, rowGroupingModel.current, undefined);
|
|
40
|
+
return _extends({}, invariantInitialState, {
|
|
41
|
+
columns: _extends({}, invariantInitialState?.columns, {
|
|
42
|
+
columnVisibilityModel
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
}, []);
|
|
46
|
+
};
|
package/modern/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** @license MUI v5.11.0
|
|
2
|
+
*
|
|
3
|
+
* This source code is licensed under the MIT license found in the
|
|
4
|
+
* LICENSE file in the root directory of this source tree.
|
|
5
|
+
*/
|
|
6
|
+
import './typeOverloads';
|
|
7
|
+
import '@mui/x-data-grid-pro/typeOverloads';
|
|
8
|
+
export { LicenseInfo } from '@mui/x-license-pro';
|
|
9
|
+
export * from '@mui/x-data-grid/components';
|
|
10
|
+
export * from '@mui/x-data-grid-pro/components';
|
|
11
|
+
export * from '@mui/x-data-grid/constants';
|
|
12
|
+
export * from '@mui/x-data-grid/hooks';
|
|
13
|
+
export * from '@mui/x-data-grid-pro/hooks';
|
|
14
|
+
export * from '@mui/x-data-grid/locales';
|
|
15
|
+
export * from '@mui/x-data-grid/models';
|
|
16
|
+
export * from '@mui/x-data-grid-pro/models';
|
|
17
|
+
export * from '@mui/x-data-grid/context';
|
|
18
|
+
export * from '@mui/x-data-grid/colDef';
|
|
19
|
+
export * from '@mui/x-data-grid/utils';
|
|
20
|
+
export * from '@mui/x-data-grid-pro/utils';
|
|
21
|
+
export * from './DataGridPremium';
|
|
22
|
+
export * from './hooks';
|
|
23
|
+
export * from './models';
|
|
24
|
+
export * from './components';
|
|
25
|
+
export { useGridApiContext, useGridApiRef, useGridRootProps } from './typeOverloads/reexports';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './gridGroupingValueGetterParams';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@mui/x-data-grid-pro/typeOverloads';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// import { GridKeyValue, GridValidRowModel } from '@mui/x-data-grid-pro';
|
|
2
|
+
// import type { GridControlledStateEventLookupPro } from '@mui/x-data-grid-pro/typeOverloads';
|
|
3
|
+
// import type { GridGroupingValueGetterParams } from '../models';
|
|
4
|
+
// import type { GridRowGroupingModel } from '../hooks';
|
|
5
|
+
//
|
|
6
|
+
// export interface GridControlledStateEventLookupPremium {
|
|
7
|
+
// /**
|
|
8
|
+
// * Fired when the row grouping model changes.
|
|
9
|
+
// */
|
|
10
|
+
// rowGroupingModelChange: { params: GridRowGroupingModel };
|
|
11
|
+
// }
|
|
12
|
+
//
|
|
13
|
+
// // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
|
+
// export interface GridColDefPremium<R extends GridValidRowModel = any, V = any, F = V> {
|
|
15
|
+
// /**
|
|
16
|
+
// * Function that transforms a complex cell value into a key that be used for grouping the rows.
|
|
17
|
+
// * @param {GridGroupingValueGetterParams} params Object containing parameters for the getter.
|
|
18
|
+
// * @returns {GridKeyValue | null | undefined} The cell key.
|
|
19
|
+
// */
|
|
20
|
+
// groupingValueGetter?: (
|
|
21
|
+
// params: GridGroupingValueGetterParams<V, R>,
|
|
22
|
+
// ) => GridKeyValue | null | undefined;
|
|
23
|
+
// }
|
|
24
|
+
//
|
|
25
|
+
// declare module '@mui/x-data-grid-pro' {
|
|
26
|
+
// export interface GridColDef<R extends GridValidRowModel = any, V = any, F = V>
|
|
27
|
+
// extends GridColDefPremium<R, V, F> {}
|
|
28
|
+
//
|
|
29
|
+
// // TODO: Remove explicit augmentation of pro package
|
|
30
|
+
// interface GridControlledStateEventLookup
|
|
31
|
+
// extends GridControlledStateEventLookupPro,
|
|
32
|
+
// GridControlledStateEventLookupPremium {}
|
|
33
|
+
// }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ponyfillGlobal } from '@mui/utils';
|
|
2
|
+
export const getReleaseInfo = () => {
|
|
3
|
+
const releaseInfo = "MTY1MjM5MjgwMDAwMA==";
|
|
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
|
+
};
|