@mui/x-data-grid-pro 5.11.1 → 5.12.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 +95 -18
- package/DataGridPro/DataGridPro.js +26 -27
- package/DataGridPro/useDataGridProComponent.js +0 -5
- package/DataGridPro/useDataGridProProps.js +6 -27
- package/README.md +2 -2
- package/components/DataGridProVirtualScroller.d.ts +1 -1
- package/components/DataGridProVirtualScroller.js +6 -3
- package/components/GridRowReorderCell.js +3 -3
- package/hooks/features/columnPinning/gridColumnPinningInterface.d.ts +6 -0
- package/hooks/features/columnPinning/useGridColumnPinning.js +72 -27
- package/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +67 -4
- package/hooks/features/rowReorder/useGridRowReorder.js +5 -1
- package/index.d.ts +0 -2
- package/index.js +2 -5
- package/legacy/DataGridPro/DataGridPro.js +26 -27
- package/legacy/DataGridPro/useDataGridProComponent.js +0 -5
- package/legacy/DataGridPro/useDataGridProProps.js +1 -20
- package/legacy/components/DataGridProVirtualScroller.js +6 -3
- package/legacy/components/GridRowReorderCell.js +5 -3
- package/legacy/hooks/features/columnPinning/useGridColumnPinning.js +81 -32
- package/legacy/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +70 -5
- package/legacy/hooks/features/rowReorder/useGridRowReorder.js +5 -1
- package/legacy/index.js +2 -5
- 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 +0 -5
- package/modern/DataGridPro/useDataGridProProps.js +1 -16
- package/modern/components/DataGridProVirtualScroller.js +6 -3
- package/modern/components/GridRowReorderCell.js +3 -3
- package/modern/hooks/features/columnPinning/useGridColumnPinning.js +72 -27
- package/modern/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +67 -4
- package/modern/hooks/features/rowReorder/useGridRowReorder.js +5 -1
- package/modern/index.js +2 -5
- package/modern/utils/releaseInfo.js +1 -1
- package/node/DataGridPro/DataGridPro.js +26 -27
- package/node/DataGridPro/useDataGridProComponent.js +0 -7
- package/node/DataGridPro/useDataGridProProps.js +6 -28
- package/node/components/DataGridProVirtualScroller.js +6 -3
- package/node/components/GridRowReorderCell.js +3 -3
- package/node/hooks/features/columnPinning/useGridColumnPinning.js +71 -23
- package/node/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +68 -5
- package/node/hooks/features/rowReorder/useGridRowReorder.js +5 -1
- package/node/index.js +2 -30
- package/node/utils/releaseInfo.js +1 -1
- package/package.json +6 -6
- 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/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/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/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/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
|
@@ -15,8 +15,6 @@ var _styles = require("@mui/material/styles");
|
|
|
15
15
|
|
|
16
16
|
var _xDataGrid = require("@mui/x-data-grid");
|
|
17
17
|
|
|
18
|
-
var _internals = require("@mui/x-data-grid/internals");
|
|
19
|
-
|
|
20
18
|
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); }
|
|
21
19
|
|
|
22
20
|
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; }
|
|
@@ -32,12 +30,9 @@ const DATA_GRID_PRO_PROPS_DEFAULT_VALUES = (0, _extends2.default)({}, _xDataGrid
|
|
|
32
30
|
disableChildrenFiltering: false,
|
|
33
31
|
disableChildrenSorting: false,
|
|
34
32
|
rowReordering: false,
|
|
35
|
-
getDetailPanelHeight: () => 500
|
|
36
|
-
disableRowGrouping: false,
|
|
37
|
-
rowGroupingColumnMode: 'single'
|
|
33
|
+
getDetailPanelHeight: () => 500
|
|
38
34
|
});
|
|
39
35
|
exports.DATA_GRID_PRO_PROPS_DEFAULT_VALUES = DATA_GRID_PRO_PROPS_DEFAULT_VALUES;
|
|
40
|
-
const rowGroupingWarning = (0, _internals.buildWarning)(['MUI: The row grouping has been moved to the new `@mui/x-data-grid-premium` package.', 'The feature is deprecated in `@mui/x-data-grid-pro`, and it will soon be removed from this package.'], 'error');
|
|
41
36
|
|
|
42
37
|
const useDataGridProProps = inProps => {
|
|
43
38
|
const themedProps = (0, _styles.useThemeProps)({
|
|
@@ -58,28 +53,11 @@ const useDataGridProProps = inProps => {
|
|
|
58
53
|
});
|
|
59
54
|
return mergedComponents;
|
|
60
55
|
}, [themedProps.components]);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if ((_themedProps$experime = themedProps.experimentalFeatures) != null && _themedProps$experime.rowGrouping) {
|
|
68
|
-
rowGroupingWarning();
|
|
69
|
-
}
|
|
70
|
-
}, [themedProps.experimentalFeatures]);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return React.useMemo(() => {
|
|
74
|
-
var _themedProps$experime2;
|
|
75
|
-
|
|
76
|
-
return (0, _extends2.default)({}, DATA_GRID_PRO_PROPS_DEFAULT_VALUES, themedProps, {
|
|
77
|
-
disableRowGrouping: themedProps.disableRowGrouping || !((_themedProps$experime2 = themedProps.experimentalFeatures) != null && _themedProps$experime2.rowGrouping),
|
|
78
|
-
localeText,
|
|
79
|
-
components,
|
|
80
|
-
signature: 'DataGridPro'
|
|
81
|
-
});
|
|
82
|
-
}, [themedProps, localeText, components]);
|
|
56
|
+
return React.useMemo(() => (0, _extends2.default)({}, DATA_GRID_PRO_PROPS_DEFAULT_VALUES, themedProps, {
|
|
57
|
+
localeText,
|
|
58
|
+
components,
|
|
59
|
+
signature: 'DataGridPro'
|
|
60
|
+
}), [themedProps, localeText, components]);
|
|
83
61
|
};
|
|
84
62
|
|
|
85
63
|
exports.useDataGridProProps = useDataGridProProps;
|
|
@@ -112,7 +112,8 @@ const VirtualScrollerDetailPanel = (0, _styles.styled)(_Box.default, {
|
|
|
112
112
|
zIndex: 2,
|
|
113
113
|
width: '100%',
|
|
114
114
|
position: 'absolute',
|
|
115
|
-
backgroundColor: theme.palette.background.default
|
|
115
|
+
backgroundColor: theme.palette.background.default,
|
|
116
|
+
overflow: 'auto'
|
|
116
117
|
}));
|
|
117
118
|
const VirtualScrollerPinnedColumns = (0, _styles.styled)('div', {
|
|
118
119
|
name: 'MuiDataGrid',
|
|
@@ -268,7 +269,8 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
268
269
|
renderContext: leftRenderContext,
|
|
269
270
|
minFirstColumn: leftRenderContext.firstColumnIndex,
|
|
270
271
|
maxLastColumn: leftRenderContext.lastColumnIndex,
|
|
271
|
-
availableSpace: 0
|
|
272
|
+
availableSpace: 0,
|
|
273
|
+
ignoreAutoHeight: true
|
|
272
274
|
})
|
|
273
275
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_internals.GridVirtualScrollerRenderZone, (0, _extends2.default)({}, getRenderZoneProps(), {
|
|
274
276
|
children: getRows({
|
|
@@ -285,7 +287,8 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
285
287
|
renderContext: rightRenderContext,
|
|
286
288
|
minFirstColumn: rightRenderContext.firstColumnIndex,
|
|
287
289
|
maxLastColumn: rightRenderContext.lastColumnIndex,
|
|
288
|
-
availableSpace: 0
|
|
290
|
+
availableSpace: 0,
|
|
291
|
+
ignoreAutoHeight: true
|
|
289
292
|
})
|
|
290
293
|
}), detailPanels.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(VirtualScrollerDetailPanels, {
|
|
291
294
|
className: classes.detailPanels,
|
|
@@ -44,7 +44,7 @@ const GridRowReorderCell = params => {
|
|
|
44
44
|
|
|
45
45
|
const cellValue = params.row.__reorder__ || params.id; // TODO: remove sortModel and treeDepth checks once row reorder is compatible
|
|
46
46
|
|
|
47
|
-
const isDraggable = !!rootProps.rowReordering && !sortModel.length && treeDepth === 1 && Object.keys(editRowsState).length === 0;
|
|
47
|
+
const isDraggable = React.useMemo(() => !!rootProps.rowReordering && !sortModel.length && treeDepth === 1 && Object.keys(editRowsState).length === 0, [rootProps.rowReordering, sortModel, treeDepth, editRowsState]);
|
|
48
48
|
const ownerState = {
|
|
49
49
|
isDraggable,
|
|
50
50
|
classes: rootProps.classes
|
|
@@ -69,11 +69,11 @@ const GridRowReorderCell = params => {
|
|
|
69
69
|
propHandler(event);
|
|
70
70
|
}
|
|
71
71
|
}, [apiRef, params.row.id]);
|
|
72
|
-
const draggableEventHandlers = {
|
|
72
|
+
const draggableEventHandlers = isDraggable ? {
|
|
73
73
|
onDragStart: publish('rowDragStart'),
|
|
74
74
|
onDragOver: publish('rowDragOver'),
|
|
75
75
|
onDragEnd: publish('rowDragEnd')
|
|
76
|
-
};
|
|
76
|
+
} : null;
|
|
77
77
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", (0, _extends2.default)({
|
|
78
78
|
className: classes.root,
|
|
79
79
|
draggable: isDraggable
|
|
@@ -35,9 +35,12 @@ const Divider = () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_Divider.default, {
|
|
|
35
35
|
onClick: event => event.stopPropagation()
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
const columnPinningStateInitializer = (state, props) => {
|
|
38
|
+
const columnPinningStateInitializer = (state, props, apiRef) => {
|
|
39
39
|
var _props$initialState;
|
|
40
40
|
|
|
41
|
+
apiRef.current.unstable_caches.columnPinning = {
|
|
42
|
+
orderedFieldsBeforePinningColumns: null
|
|
43
|
+
};
|
|
41
44
|
let model;
|
|
42
45
|
|
|
43
46
|
if (props.disableColumnPinning) {
|
|
@@ -229,31 +232,20 @@ const useGridColumnPinning = (apiRef, props) => {
|
|
|
229
232
|
return;
|
|
230
233
|
}
|
|
231
234
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
pinnedColumns: newPinnedColumns
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
apiRef.current.forceUpdate();
|
|
243
|
-
}, [apiRef, checkIfEnabled]);
|
|
235
|
+
const otherSide = side === _gridColumnPinningInterface.GridPinnedPosition.right ? _gridColumnPinningInterface.GridPinnedPosition.left : _gridColumnPinningInterface.GridPinnedPosition.right;
|
|
236
|
+
const newPinnedColumns = {
|
|
237
|
+
[side]: [...(pinnedColumns[side] || []), field],
|
|
238
|
+
[otherSide]: (pinnedColumns[otherSide] || []).filter(column => column !== field)
|
|
239
|
+
};
|
|
240
|
+
apiRef.current.setPinnedColumns(newPinnedColumns);
|
|
241
|
+
}, [apiRef, checkIfEnabled, pinnedColumns]);
|
|
244
242
|
const unpinColumn = React.useCallback(field => {
|
|
245
243
|
checkIfEnabled('unpinColumn');
|
|
246
|
-
apiRef.current.
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
right: (state.pinnedColumns.right || []).filter(column => column !== field)
|
|
250
|
-
});
|
|
251
|
-
return (0, _extends2.default)({}, state, {
|
|
252
|
-
pinnedColumns: newPinnedColumns
|
|
253
|
-
});
|
|
244
|
+
apiRef.current.setPinnedColumns({
|
|
245
|
+
left: (pinnedColumns.left || []).filter(column => column !== field),
|
|
246
|
+
right: (pinnedColumns.right || []).filter(column => column !== field)
|
|
254
247
|
});
|
|
255
|
-
|
|
256
|
-
}, [apiRef, checkIfEnabled]);
|
|
248
|
+
}, [apiRef, checkIfEnabled, pinnedColumns.left, pinnedColumns.right]);
|
|
257
249
|
const getPinnedColumns = React.useCallback(() => {
|
|
258
250
|
checkIfEnabled('getPinnedColumns');
|
|
259
251
|
return (0, _gridColumnPinningSelector.gridPinnedColumnsSelector)(apiRef.current.state);
|
|
@@ -287,6 +279,62 @@ const useGridColumnPinning = (apiRef, props) => {
|
|
|
287
279
|
isColumnPinned
|
|
288
280
|
};
|
|
289
281
|
(0, _xDataGrid.useGridApiMethod)(apiRef, columnPinningApi, 'columnPinningApi');
|
|
282
|
+
const handleColumnOrderChange = React.useCallback(params => {
|
|
283
|
+
if (!apiRef.current.unstable_caches.columnPinning.orderedFieldsBeforePinningColumns) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const {
|
|
288
|
+
field,
|
|
289
|
+
targetIndex,
|
|
290
|
+
oldIndex
|
|
291
|
+
} = params;
|
|
292
|
+
const delta = targetIndex > oldIndex ? 1 : -1;
|
|
293
|
+
const latestColumnFields = (0, _xDataGrid.gridColumnFieldsSelector)(apiRef);
|
|
294
|
+
/**
|
|
295
|
+
* When a column X is reordered to somewhere else, the position where this column X is dropped
|
|
296
|
+
* on must be moved to left or right to make room for it. The ^^^ below represents the column
|
|
297
|
+
* which gave space to receive X.
|
|
298
|
+
*
|
|
299
|
+
* | X | B | C | D | -> | B | C | D | X | (e.g. X moved to after D, so delta=1)
|
|
300
|
+
* ^^^ ^^^
|
|
301
|
+
*
|
|
302
|
+
* | A | B | C | X | -> | X | A | B | C | (e.g. X moved before A, so delta=-1)
|
|
303
|
+
* ^^^ ^^^
|
|
304
|
+
*
|
|
305
|
+
* If column P is pinned, it will not move to provide space. However, it will jump to the next
|
|
306
|
+
* non-pinned column.
|
|
307
|
+
*
|
|
308
|
+
* | X | B | P | D | -> | B | D | P | X | (e.g. X moved to after D, with P pinned)
|
|
309
|
+
* ^^^ ^^^
|
|
310
|
+
*/
|
|
311
|
+
|
|
312
|
+
const siblingField = latestColumnFields[targetIndex - delta];
|
|
313
|
+
const newOrderedFieldsBeforePinningColumns = [...apiRef.current.unstable_caches.columnPinning.orderedFieldsBeforePinningColumns]; // The index to start swapping fields
|
|
314
|
+
|
|
315
|
+
let i = newOrderedFieldsBeforePinningColumns.findIndex(column => column === field); // The index of the field to swap with
|
|
316
|
+
|
|
317
|
+
let j = i + delta; // When to stop swapping fields.
|
|
318
|
+
// We stop one field before because the swap is done with i + 1 (if delta=1)
|
|
319
|
+
|
|
320
|
+
const stop = newOrderedFieldsBeforePinningColumns.findIndex(column => column === siblingField);
|
|
321
|
+
|
|
322
|
+
while (delta > 0 ? i < stop : i > stop) {
|
|
323
|
+
// If the field to swap with is a pinned column, jump to the next
|
|
324
|
+
while (apiRef.current.isColumnPinned(newOrderedFieldsBeforePinningColumns[j])) {
|
|
325
|
+
j += delta;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
const temp = newOrderedFieldsBeforePinningColumns[i];
|
|
329
|
+
newOrderedFieldsBeforePinningColumns[i] = newOrderedFieldsBeforePinningColumns[j];
|
|
330
|
+
newOrderedFieldsBeforePinningColumns[j] = temp;
|
|
331
|
+
i = j;
|
|
332
|
+
j = i + delta;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
apiRef.current.unstable_caches.columnPinning.orderedFieldsBeforePinningColumns = newOrderedFieldsBeforePinningColumns;
|
|
336
|
+
}, [apiRef]);
|
|
337
|
+
(0, _xDataGrid.useGridApiEventHandler)(apiRef, 'columnOrderChange', handleColumnOrderChange);
|
|
290
338
|
React.useEffect(() => {
|
|
291
339
|
if (props.pinnedColumns) {
|
|
292
340
|
apiRef.current.setPinnedColumns(props.pinnedColumns);
|
|
@@ -42,24 +42,87 @@ const useGridColumnPinningPreProcessors = (apiRef, props) => {
|
|
|
42
42
|
pinnedColumns = (0, _gridColumnPinningSelector.gridPinnedColumnsSelector)(initializedState);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
const prevAllPinnedColumns = React.useRef();
|
|
45
46
|
const reorderPinnedColumns = React.useCallback(columnsState => {
|
|
46
47
|
if (columnsState.all.length === 0 || disableColumnPinning) {
|
|
47
48
|
return columnsState;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
const [leftPinnedColumns, rightPinnedColumns] = (0, _DataGridProVirtualScroller.filterColumns)(pinnedColumns, columnsState.all);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
let newOrderedFields;
|
|
53
|
+
const allPinnedColumns = [...leftPinnedColumns, ...rightPinnedColumns];
|
|
54
|
+
const {
|
|
55
|
+
orderedFieldsBeforePinningColumns
|
|
56
|
+
} = apiRef.current.unstable_caches.columnPinning;
|
|
57
|
+
|
|
58
|
+
if (orderedFieldsBeforePinningColumns) {
|
|
59
|
+
newOrderedFields = new Array(columnsState.all.length).fill(null);
|
|
60
|
+
const newOrderedFieldsBeforePinningColumns = [...newOrderedFields]; // Contains the fields not added to the orderedFields array yet
|
|
61
|
+
|
|
62
|
+
const remainingFields = [...columnsState.all]; // First, we check if the column was unpinned since the last processing.
|
|
63
|
+
// If yes and it still exists, we move it back to the same position it was before pinning
|
|
64
|
+
|
|
65
|
+
prevAllPinnedColumns.current.forEach(field => {
|
|
66
|
+
if (!allPinnedColumns.includes(field) && columnsState.lookup[field]) {
|
|
67
|
+
// Get the position before pinning
|
|
68
|
+
const index = orderedFieldsBeforePinningColumns.indexOf(field);
|
|
69
|
+
newOrderedFields[index] = field;
|
|
70
|
+
newOrderedFieldsBeforePinningColumns[index] = field; // This field was already consumed so we prevent from being added again
|
|
71
|
+
|
|
72
|
+
remainingFields.splice(remainingFields.indexOf(field), 1);
|
|
73
|
+
}
|
|
74
|
+
}); // For columns still pinned, we keep stored their original positions
|
|
75
|
+
|
|
76
|
+
allPinnedColumns.forEach(field => {
|
|
77
|
+
let index = orderedFieldsBeforePinningColumns.indexOf(field); // If index = -1, the pinned field didn't exist in the last processing, it's possibly being added now
|
|
78
|
+
// If index >= newOrderedFieldsBeforePinningColumns.length, then one or more columns were removed
|
|
79
|
+
// In both cases, use the position from the columns array
|
|
80
|
+
// TODO: detect removed columns and decrease the positions after it
|
|
81
|
+
|
|
82
|
+
if (index === -1 || index >= newOrderedFieldsBeforePinningColumns.length) {
|
|
83
|
+
index = columnsState.all.indexOf(field);
|
|
84
|
+
} // The fallback above may make the column to be inserted in a position already occupied
|
|
85
|
+
// In this case, put it in any empty slot available
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
if (newOrderedFieldsBeforePinningColumns[index] !== null) {
|
|
89
|
+
index = 0;
|
|
90
|
+
|
|
91
|
+
while (newOrderedFieldsBeforePinningColumns[index] !== null) {
|
|
92
|
+
index += 1;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
newOrderedFields[index] = field;
|
|
97
|
+
newOrderedFieldsBeforePinningColumns[index] = field; // This field was already consumed so we prevent from being added again
|
|
98
|
+
|
|
99
|
+
remainingFields.splice(remainingFields.indexOf(field), 1);
|
|
100
|
+
}); // The fields remaining are those that're neither pinnned nor were unpinned
|
|
101
|
+
// For these, we spread them across both arrays making sure to not override existing values
|
|
102
|
+
|
|
103
|
+
let i = 0;
|
|
104
|
+
remainingFields.forEach(field => {
|
|
105
|
+
while (newOrderedFieldsBeforePinningColumns[i] !== null) {
|
|
106
|
+
i += 1;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
newOrderedFieldsBeforePinningColumns[i] = field;
|
|
110
|
+
newOrderedFields[i] = field;
|
|
111
|
+
});
|
|
112
|
+
apiRef.current.unstable_caches.columnPinning.orderedFieldsBeforePinningColumns = newOrderedFieldsBeforePinningColumns;
|
|
113
|
+
} else {
|
|
114
|
+
newOrderedFields = [...columnsState.all];
|
|
115
|
+
apiRef.current.unstable_caches.columnPinning.orderedFieldsBeforePinningColumns = [...columnsState.all];
|
|
54
116
|
}
|
|
55
117
|
|
|
56
|
-
|
|
118
|
+
prevAllPinnedColumns.current = allPinnedColumns;
|
|
119
|
+
const centerColumns = newOrderedFields.filter(field => {
|
|
57
120
|
return !leftPinnedColumns.includes(field) && !rightPinnedColumns.includes(field);
|
|
58
121
|
});
|
|
59
122
|
return (0, _extends2.default)({}, columnsState, {
|
|
60
123
|
all: [...leftPinnedColumns, ...centerColumns, ...rightPinnedColumns]
|
|
61
124
|
});
|
|
62
|
-
}, [disableColumnPinning, pinnedColumns]);
|
|
125
|
+
}, [apiRef, disableColumnPinning, pinnedColumns]);
|
|
63
126
|
(0, _internals.useGridRegisterPipeProcessor)(apiRef, 'hydrateColumns', reorderPinnedColumns);
|
|
64
127
|
};
|
|
65
128
|
|
|
@@ -73,6 +73,10 @@ const useGridRowReorder = (apiRef, props) => {
|
|
|
73
73
|
originRowIndex.current = apiRef.current.getRowIndex(params.id);
|
|
74
74
|
}, [isRowReorderDisabled, classes.rowDragging, logger, apiRef]);
|
|
75
75
|
const handleDragOver = React.useCallback((params, event) => {
|
|
76
|
+
if (dragRowId === '') {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
76
80
|
logger.debug(`Dragging over row ${params.id}`);
|
|
77
81
|
event.preventDefault(); // Prevent drag events propagation.
|
|
78
82
|
// For more information check here https://github.com/mui/mui-x/issues/2680.
|
|
@@ -88,7 +92,7 @@ const useGridRowReorder = (apiRef, props) => {
|
|
|
88
92
|
// Call the gridEditRowsStateSelector directly to avoid infnite loop
|
|
89
93
|
const editRowsState = (0, _xDataGrid.gridEditRowsStateSelector)(apiRef.current.state);
|
|
90
94
|
|
|
91
|
-
if (isRowReorderDisabled || Object.keys(editRowsState).length !== 0) {
|
|
95
|
+
if (dragRowId === '' || isRowReorderDisabled || Object.keys(editRowsState).length !== 0) {
|
|
92
96
|
return;
|
|
93
97
|
}
|
|
94
98
|
|
package/node/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MUI v5.
|
|
1
|
+
/** @license MUI v5.12.0
|
|
2
2
|
*
|
|
3
3
|
* This source code is licensed under the MIT license found in the
|
|
4
4
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -225,32 +225,4 @@ Object.keys(_utils2).forEach(function (key) {
|
|
|
225
225
|
});
|
|
226
226
|
});
|
|
227
227
|
|
|
228
|
-
var _reexports = require("./typeOverloads/reexports");
|
|
229
|
-
|
|
230
|
-
var _rowGrouping = require("./hooks/features/rowGrouping");
|
|
231
|
-
|
|
232
|
-
Object.keys(_rowGrouping).forEach(function (key) {
|
|
233
|
-
if (key === "default" || key === "__esModule") return;
|
|
234
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
235
|
-
if (key in exports && exports[key] === _rowGrouping[key]) return;
|
|
236
|
-
Object.defineProperty(exports, key, {
|
|
237
|
-
enumerable: true,
|
|
238
|
-
get: function () {
|
|
239
|
-
return _rowGrouping[key];
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
var _gridGroupingValueGetterParams = require("./models/gridGroupingValueGetterParams");
|
|
245
|
-
|
|
246
|
-
Object.keys(_gridGroupingValueGetterParams).forEach(function (key) {
|
|
247
|
-
if (key === "default" || key === "__esModule") return;
|
|
248
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
249
|
-
if (key in exports && exports[key] === _gridGroupingValueGetterParams[key]) return;
|
|
250
|
-
Object.defineProperty(exports, key, {
|
|
251
|
-
enumerable: true,
|
|
252
|
-
get: function () {
|
|
253
|
-
return _gridGroupingValueGetterParams[key];
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
});
|
|
228
|
+
var _reexports = require("./typeOverloads/reexports");
|
|
@@ -8,7 +8,7 @@ exports.getReleaseInfo = void 0;
|
|
|
8
8
|
var _utils = require("@mui/utils");
|
|
9
9
|
|
|
10
10
|
const getReleaseInfo = () => {
|
|
11
|
-
const releaseInfo = "
|
|
11
|
+
const releaseInfo = "MTY1Mzk0ODAwMDAwMA==";
|
|
12
12
|
|
|
13
13
|
if (process.env.NODE_ENV !== 'production') {
|
|
14
14
|
// A simple hack to set the value in the test environment (has no build step).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-data-grid-pro",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.12.0",
|
|
4
4
|
"description": "The Pro plan edition of the data grid component (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./node/index.js",
|
|
@@ -32,17 +32,17 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.17.2",
|
|
35
|
-
"@mui/utils": "^5.
|
|
36
|
-
"@mui/x-data-grid": "5.
|
|
37
|
-
"@mui/x-license-pro": "5.
|
|
35
|
+
"@mui/utils": "^5.4.1",
|
|
36
|
+
"@mui/x-data-grid": "5.12.0",
|
|
37
|
+
"@mui/x-license-pro": "5.12.0",
|
|
38
38
|
"@types/format-util": "^1.0.2",
|
|
39
39
|
"clsx": "^1.0.4",
|
|
40
40
|
"prop-types": "^15.8.1",
|
|
41
41
|
"reselect": "^4.1.5"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@mui/material": "^5.
|
|
45
|
-
"@mui/system": "^5.
|
|
44
|
+
"@mui/material": "^5.4.1",
|
|
45
|
+
"@mui/system": "^5.4.1",
|
|
46
46
|
"react": "^17.0.2 || ^18.0.0"
|
|
47
47
|
},
|
|
48
48
|
"setupFiles": [
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GridRowId } from '@mui/x-data-grid';
|
|
2
2
|
import type { GridRowScrollEndParams, GridRowOrderChangeParams } from '../models';
|
|
3
|
-
import type { GridPinnedColumns } from '../hooks';
|
|
3
|
+
import type { GridColumnPinningInternalCache, GridPinnedColumns } from '../hooks/features/columnPinning/gridColumnPinningInterface';
|
|
4
4
|
import type { GridCanBeReorderedPreProcessingContext } from '../hooks/features/columnReorder/columnReorderInterfaces';
|
|
5
|
-
import { GridGroupingValueGetterParams } from '../models/gridGroupingValueGetterParams';
|
|
6
|
-
import { GridRowGroupingModel } from '../hooks/features/rowGrouping';
|
|
7
5
|
export interface GridControlledStateEventLookupPro {
|
|
8
6
|
/**
|
|
9
7
|
* Fired when the open detail panels are changed.
|
|
@@ -19,21 +17,6 @@ export interface GridControlledStateEventLookupPro {
|
|
|
19
17
|
pinnedColumnsChange: {
|
|
20
18
|
params: GridPinnedColumns;
|
|
21
19
|
};
|
|
22
|
-
/**
|
|
23
|
-
* Fired when the row grouping model changes.
|
|
24
|
-
* TODO: Add back on premium when removing it from pro
|
|
25
|
-
*/
|
|
26
|
-
rowGroupingModelChange: {
|
|
27
|
-
params: GridRowGroupingModel;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
export interface GridColDefPro<R extends GridValidRowModel = any, V = any, F = V> {
|
|
31
|
-
/**
|
|
32
|
-
* Function that transforms a complex cell value into a key that be used for grouping the rows.
|
|
33
|
-
* @param {GridGroupingValueGetterParams} params Object containing parameters for the getter.
|
|
34
|
-
* @returns {GridKeyValue | null | undefined} The cell key.
|
|
35
|
-
*/
|
|
36
|
-
groupingValueGetter?: (params: GridGroupingValueGetterParams<V, R>) => GridKeyValue | null | undefined;
|
|
37
20
|
}
|
|
38
21
|
export interface GridEventLookupPro {
|
|
39
22
|
/**
|
|
@@ -55,13 +38,18 @@ export interface GridPipeProcessingLookupPro {
|
|
|
55
38
|
context: GridCanBeReorderedPreProcessingContext;
|
|
56
39
|
};
|
|
57
40
|
}
|
|
41
|
+
export interface GridApiCachesPro {
|
|
42
|
+
columnPinning: GridColumnPinningInternalCache;
|
|
43
|
+
}
|
|
58
44
|
declare module '@mui/x-data-grid' {
|
|
59
45
|
interface GridEventLookup extends GridEventLookupPro {
|
|
60
46
|
}
|
|
61
|
-
interface GridColDef<R extends GridValidRowModel = any, V = any, F = V> extends GridColDefPro<R, V, F> {
|
|
62
|
-
}
|
|
63
47
|
interface GridControlledStateEventLookup extends GridControlledStateEventLookupPro {
|
|
64
48
|
}
|
|
65
49
|
interface GridPipeProcessingLookup extends GridPipeProcessingLookupPro {
|
|
66
50
|
}
|
|
67
51
|
}
|
|
52
|
+
declare module '@mui/x-data-grid/internals' {
|
|
53
|
+
interface GridApiCaches extends GridApiCachesPro {
|
|
54
|
+
}
|
|
55
|
+
}
|
package/utils/releaseInfo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTY1Mzk0ODAwMDAwMA==";
|
|
4
4
|
|
|
5
5
|
if (process.env.NODE_ENV !== 'production') {
|
|
6
6
|
// A simple hack to set the value in the test environment (has no build step).
|
|
@@ -1,22 +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
|
-
const GridGroupingColumnLeafCell = props => {
|
|
7
|
-
var _props$formattedValue;
|
|
8
|
-
|
|
9
|
-
const {
|
|
10
|
-
rowNode
|
|
11
|
-
} = props;
|
|
12
|
-
const rootProps = useGridRootProps();
|
|
13
|
-
const marginLeft = rootProps.rowGroupingColumnMode === 'multiple' ? 1 : rowNode.depth * 2;
|
|
14
|
-
return /*#__PURE__*/_jsx(Box, {
|
|
15
|
-
sx: {
|
|
16
|
-
ml: marginLeft
|
|
17
|
-
},
|
|
18
|
-
children: (_props$formattedValue = props.formattedValue) != null ? _props$formattedValue : props.value
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export { GridGroupingColumnLeafCell };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { GridRenderCellParams } from '@mui/x-data-grid';
|
|
3
|
-
interface GridGroupingCriteriaCellProps extends GridRenderCellParams {
|
|
4
|
-
hideDescendantCount?: boolean;
|
|
5
|
-
}
|
|
6
|
-
export declare const GridGroupingCriteriaCell: (props: GridGroupingCriteriaCellProps) => JSX.Element;
|
|
7
|
-
export {};
|
|
@@ -1,78 +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
|
-
const useUtilityClasses = ownerState => {
|
|
12
|
-
const {
|
|
13
|
-
classes
|
|
14
|
-
} = ownerState;
|
|
15
|
-
const slots = {
|
|
16
|
-
root: ['groupingCriteriaCell'],
|
|
17
|
-
toggle: ['groupingCriteriaCellToggle']
|
|
18
|
-
};
|
|
19
|
-
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const GridGroupingCriteriaCell = props => {
|
|
23
|
-
var _filteredDescendantCo;
|
|
24
|
-
|
|
25
|
-
const {
|
|
26
|
-
id,
|
|
27
|
-
field,
|
|
28
|
-
rowNode,
|
|
29
|
-
hideDescendantCount,
|
|
30
|
-
formattedValue
|
|
31
|
-
} = props;
|
|
32
|
-
const rootProps = useGridRootProps();
|
|
33
|
-
const apiRef = useGridApiContext();
|
|
34
|
-
const ownerState = {
|
|
35
|
-
classes: rootProps.classes
|
|
36
|
-
};
|
|
37
|
-
const classes = useUtilityClasses(ownerState);
|
|
38
|
-
const filteredDescendantCountLookup = useGridSelector(apiRef, gridFilteredDescendantCountLookupSelector);
|
|
39
|
-
const filteredDescendantCount = (_filteredDescendantCo = filteredDescendantCountLookup[rowNode.id]) != null ? _filteredDescendantCo : 0;
|
|
40
|
-
const Icon = rowNode.childrenExpanded ? rootProps.components.GroupingCriteriaCollapseIcon : rootProps.components.GroupingCriteriaExpandIcon;
|
|
41
|
-
|
|
42
|
-
const handleKeyDown = event => {
|
|
43
|
-
if (event.key === ' ') {
|
|
44
|
-
event.stopPropagation();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
apiRef.current.publishEvent('cellKeyDown', props, event);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const handleClick = event => {
|
|
51
|
-
apiRef.current.setRowChildrenExpansion(id, !rowNode.childrenExpanded);
|
|
52
|
-
apiRef.current.setCellFocus(id, field);
|
|
53
|
-
event.stopPropagation();
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const marginLeft = rootProps.rowGroupingColumnMode === 'multiple' ? 0 : rowNode.depth * 2;
|
|
57
|
-
return /*#__PURE__*/_jsxs(Box, {
|
|
58
|
-
className: classes.root,
|
|
59
|
-
sx: {
|
|
60
|
-
ml: marginLeft
|
|
61
|
-
},
|
|
62
|
-
children: [/*#__PURE__*/_jsx("div", {
|
|
63
|
-
className: classes.toggle,
|
|
64
|
-
children: filteredDescendantCount > 0 && /*#__PURE__*/_jsx(IconButton, {
|
|
65
|
-
size: "small",
|
|
66
|
-
onClick: handleClick,
|
|
67
|
-
onKeyDown: handleKeyDown,
|
|
68
|
-
tabIndex: -1,
|
|
69
|
-
"aria-label": rowNode.childrenExpanded ? apiRef.current.getLocaleText('treeDataCollapse') : apiRef.current.getLocaleText('treeDataExpand'),
|
|
70
|
-
children: /*#__PURE__*/_jsx(Icon, {
|
|
71
|
-
fontSize: "inherit"
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
}), /*#__PURE__*/_jsxs("span", {
|
|
75
|
-
children: [formattedValue === undefined ? rowNode.groupingKey : formattedValue, !hideDescendantCount && filteredDescendantCount > 0 ? ` (${filteredDescendantCount})` : '']
|
|
76
|
-
})]
|
|
77
|
-
});
|
|
78
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { GridColDef } from '@mui/x-data-grid';
|
|
3
|
-
interface GridRowGroupableColumnMenuItemsProps {
|
|
4
|
-
column?: GridColDef;
|
|
5
|
-
onClick?: (event: React.MouseEvent<any>) => void;
|
|
6
|
-
}
|
|
7
|
-
declare const GridRowGroupableColumnMenuItems: {
|
|
8
|
-
(props: GridRowGroupableColumnMenuItemsProps): JSX.Element | null;
|
|
9
|
-
propTypes: any;
|
|
10
|
-
};
|
|
11
|
-
export { GridRowGroupableColumnMenuItems };
|