@mui/x-data-grid-pro 5.11.0 → 5.12.1
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 +237 -16
- package/DataGridPro/DataGridPro.js +26 -27
- package/DataGridPro/useDataGridProComponent.js +0 -5
- package/DataGridPro/useDataGridProProps.js +6 -27
- package/LICENSE +3 -3
- package/README.md +3 -4
- 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.js +73 -28
- package/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +67 -4
- package/hooks/features/columnResize/useGridColumnResize.js +32 -15
- package/hooks/features/detailPanel/useGridDetailPanel.js +1 -1
- package/hooks/features/rowReorder/useGridRowReorder.js +5 -1
- package/hooks/features/rowReorder/useGridRowReorderPreProcessors.d.ts +2 -2
- 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 +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/useGridDetailPanel.js +1 -1
- 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 +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/useGridDetailPanel.js +1 -1
- 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 +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/useGridDetailPanel.js +1 -1
- 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 +9 -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/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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import MuiDivider from '@mui/material/Divider';
|
|
4
|
-
import { useGridSelector, gridVisibleColumnDefinitionsSelector, gridColumnsTotalWidthSelector, gridColumnPositionsSelector, gridVisibleColumnFieldsSelector, gridClasses, useGridApiMethod, useGridApiEventHandler } from '@mui/x-data-grid';
|
|
4
|
+
import { useGridSelector, gridVisibleColumnDefinitionsSelector, gridColumnsTotalWidthSelector, gridColumnPositionsSelector, gridVisibleColumnFieldsSelector, gridClasses, useGridApiMethod, useGridApiEventHandler, gridColumnFieldsSelector } from '@mui/x-data-grid';
|
|
5
5
|
import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
|
|
6
6
|
import { GridColumnPinningMenuItems } from '../../../components/GridColumnPinningMenuItems';
|
|
7
7
|
import { GridPinnedPosition } from './gridColumnPinningInterface';
|
|
@@ -13,9 +13,12 @@ const Divider = () => /*#__PURE__*/_jsx(MuiDivider, {
|
|
|
13
13
|
onClick: event => event.stopPropagation()
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
export const columnPinningStateInitializer = (state, props) => {
|
|
16
|
+
export const columnPinningStateInitializer = (state, props, apiRef) => {
|
|
17
17
|
var _props$initialState;
|
|
18
18
|
|
|
19
|
+
apiRef.current.unstable_caches.columnPinning = {
|
|
20
|
+
orderedFieldsBeforePinningColumns: null
|
|
21
|
+
};
|
|
19
22
|
let model;
|
|
20
23
|
|
|
21
24
|
if (props.disableColumnPinning) {
|
|
@@ -186,7 +189,7 @@ export const useGridColumnPinning = (apiRef, props) => {
|
|
|
186
189
|
useGridRegisterPipeProcessor(apiRef, 'canBeReordered', checkIfCanBeReordered);
|
|
187
190
|
useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
188
191
|
useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
189
|
-
apiRef.current.
|
|
192
|
+
apiRef.current.unstable_registerControlState({
|
|
190
193
|
stateId: 'pinnedColumns',
|
|
191
194
|
propModel: props.pinnedColumns,
|
|
192
195
|
propOnChange: props.onPinnedColumnsChange,
|
|
@@ -205,34 +208,20 @@ export const useGridColumnPinning = (apiRef, props) => {
|
|
|
205
208
|
return;
|
|
206
209
|
}
|
|
207
210
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
return _extends({}, state, {
|
|
217
|
-
pinnedColumns: newPinnedColumns
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
apiRef.current.forceUpdate();
|
|
221
|
-
}, [apiRef, checkIfEnabled]);
|
|
211
|
+
const otherSide = side === GridPinnedPosition.right ? GridPinnedPosition.left : GridPinnedPosition.right;
|
|
212
|
+
const newPinnedColumns = {
|
|
213
|
+
[side]: [...(pinnedColumns[side] || []), field],
|
|
214
|
+
[otherSide]: (pinnedColumns[otherSide] || []).filter(column => column !== field)
|
|
215
|
+
};
|
|
216
|
+
apiRef.current.setPinnedColumns(newPinnedColumns);
|
|
217
|
+
}, [apiRef, checkIfEnabled, pinnedColumns]);
|
|
222
218
|
const unpinColumn = React.useCallback(field => {
|
|
223
219
|
checkIfEnabled('unpinColumn');
|
|
224
|
-
apiRef.current.
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
right: (state.pinnedColumns.right || []).filter(column => column !== field)
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
return _extends({}, state, {
|
|
231
|
-
pinnedColumns: newPinnedColumns
|
|
232
|
-
});
|
|
220
|
+
apiRef.current.setPinnedColumns({
|
|
221
|
+
left: (pinnedColumns.left || []).filter(column => column !== field),
|
|
222
|
+
right: (pinnedColumns.right || []).filter(column => column !== field)
|
|
233
223
|
});
|
|
234
|
-
|
|
235
|
-
}, [apiRef, checkIfEnabled]);
|
|
224
|
+
}, [apiRef, checkIfEnabled, pinnedColumns.left, pinnedColumns.right]);
|
|
236
225
|
const getPinnedColumns = React.useCallback(() => {
|
|
237
226
|
checkIfEnabled('getPinnedColumns');
|
|
238
227
|
return gridPinnedColumnsSelector(apiRef.current.state);
|
|
@@ -266,6 +255,62 @@ export const useGridColumnPinning = (apiRef, props) => {
|
|
|
266
255
|
isColumnPinned
|
|
267
256
|
};
|
|
268
257
|
useGridApiMethod(apiRef, columnPinningApi, 'columnPinningApi');
|
|
258
|
+
const handleColumnOrderChange = React.useCallback(params => {
|
|
259
|
+
if (!apiRef.current.unstable_caches.columnPinning.orderedFieldsBeforePinningColumns) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const {
|
|
264
|
+
field,
|
|
265
|
+
targetIndex,
|
|
266
|
+
oldIndex
|
|
267
|
+
} = params;
|
|
268
|
+
const delta = targetIndex > oldIndex ? 1 : -1;
|
|
269
|
+
const latestColumnFields = gridColumnFieldsSelector(apiRef);
|
|
270
|
+
/**
|
|
271
|
+
* When a column X is reordered to somewhere else, the position where this column X is dropped
|
|
272
|
+
* on must be moved to left or right to make room for it. The ^^^ below represents the column
|
|
273
|
+
* which gave space to receive X.
|
|
274
|
+
*
|
|
275
|
+
* | X | B | C | D | -> | B | C | D | X | (e.g. X moved to after D, so delta=1)
|
|
276
|
+
* ^^^ ^^^
|
|
277
|
+
*
|
|
278
|
+
* | A | B | C | X | -> | X | A | B | C | (e.g. X moved before A, so delta=-1)
|
|
279
|
+
* ^^^ ^^^
|
|
280
|
+
*
|
|
281
|
+
* If column P is pinned, it will not move to provide space. However, it will jump to the next
|
|
282
|
+
* non-pinned column.
|
|
283
|
+
*
|
|
284
|
+
* | X | B | P | D | -> | B | D | P | X | (e.g. X moved to after D, with P pinned)
|
|
285
|
+
* ^^^ ^^^
|
|
286
|
+
*/
|
|
287
|
+
|
|
288
|
+
const siblingField = latestColumnFields[targetIndex - delta];
|
|
289
|
+
const newOrderedFieldsBeforePinningColumns = [...apiRef.current.unstable_caches.columnPinning.orderedFieldsBeforePinningColumns]; // The index to start swapping fields
|
|
290
|
+
|
|
291
|
+
let i = newOrderedFieldsBeforePinningColumns.findIndex(column => column === field); // The index of the field to swap with
|
|
292
|
+
|
|
293
|
+
let j = i + delta; // When to stop swapping fields.
|
|
294
|
+
// We stop one field before because the swap is done with i + 1 (if delta=1)
|
|
295
|
+
|
|
296
|
+
const stop = newOrderedFieldsBeforePinningColumns.findIndex(column => column === siblingField);
|
|
297
|
+
|
|
298
|
+
while (delta > 0 ? i < stop : i > stop) {
|
|
299
|
+
// If the field to swap with is a pinned column, jump to the next
|
|
300
|
+
while (apiRef.current.isColumnPinned(newOrderedFieldsBeforePinningColumns[j])) {
|
|
301
|
+
j += delta;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const temp = newOrderedFieldsBeforePinningColumns[i];
|
|
305
|
+
newOrderedFieldsBeforePinningColumns[i] = newOrderedFieldsBeforePinningColumns[j];
|
|
306
|
+
newOrderedFieldsBeforePinningColumns[j] = temp;
|
|
307
|
+
i = j;
|
|
308
|
+
j = i + delta;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
apiRef.current.unstable_caches.columnPinning.orderedFieldsBeforePinningColumns = newOrderedFieldsBeforePinningColumns;
|
|
312
|
+
}, [apiRef]);
|
|
313
|
+
useGridApiEventHandler(apiRef, 'columnOrderChange', handleColumnOrderChange);
|
|
269
314
|
React.useEffect(() => {
|
|
270
315
|
if (props.pinnedColumns) {
|
|
271
316
|
apiRef.current.setPinnedColumns(props.pinnedColumns);
|
|
@@ -23,23 +23,86 @@ export const useGridColumnPinningPreProcessors = (apiRef, props) => {
|
|
|
23
23
|
pinnedColumns = gridPinnedColumnsSelector(initializedState);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
const prevAllPinnedColumns = React.useRef();
|
|
26
27
|
const reorderPinnedColumns = React.useCallback(columnsState => {
|
|
27
28
|
if (columnsState.all.length === 0 || disableColumnPinning) {
|
|
28
29
|
return columnsState;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
const [leftPinnedColumns, rightPinnedColumns] = filterColumns(pinnedColumns, columnsState.all);
|
|
33
|
+
let newOrderedFields;
|
|
34
|
+
const allPinnedColumns = [...leftPinnedColumns, ...rightPinnedColumns];
|
|
35
|
+
const {
|
|
36
|
+
orderedFieldsBeforePinningColumns
|
|
37
|
+
} = apiRef.current.unstable_caches.columnPinning;
|
|
32
38
|
|
|
33
|
-
if (
|
|
34
|
-
|
|
39
|
+
if (orderedFieldsBeforePinningColumns) {
|
|
40
|
+
newOrderedFields = new Array(columnsState.all.length).fill(null);
|
|
41
|
+
const newOrderedFieldsBeforePinningColumns = [...newOrderedFields]; // Contains the fields not added to the orderedFields array yet
|
|
42
|
+
|
|
43
|
+
const remainingFields = [...columnsState.all]; // First, we check if the column was unpinned since the last processing.
|
|
44
|
+
// If yes and it still exists, we move it back to the same position it was before pinning
|
|
45
|
+
|
|
46
|
+
prevAllPinnedColumns.current.forEach(field => {
|
|
47
|
+
if (!allPinnedColumns.includes(field) && columnsState.lookup[field]) {
|
|
48
|
+
// Get the position before pinning
|
|
49
|
+
const index = orderedFieldsBeforePinningColumns.indexOf(field);
|
|
50
|
+
newOrderedFields[index] = field;
|
|
51
|
+
newOrderedFieldsBeforePinningColumns[index] = field; // This field was already consumed so we prevent from being added again
|
|
52
|
+
|
|
53
|
+
remainingFields.splice(remainingFields.indexOf(field), 1);
|
|
54
|
+
}
|
|
55
|
+
}); // For columns still pinned, we keep stored their original positions
|
|
56
|
+
|
|
57
|
+
allPinnedColumns.forEach(field => {
|
|
58
|
+
let index = orderedFieldsBeforePinningColumns.indexOf(field); // If index = -1, the pinned field didn't exist in the last processing, it's possibly being added now
|
|
59
|
+
// If index >= newOrderedFieldsBeforePinningColumns.length, then one or more columns were removed
|
|
60
|
+
// In both cases, use the position from the columns array
|
|
61
|
+
// TODO: detect removed columns and decrease the positions after it
|
|
62
|
+
|
|
63
|
+
if (index === -1 || index >= newOrderedFieldsBeforePinningColumns.length) {
|
|
64
|
+
index = columnsState.all.indexOf(field);
|
|
65
|
+
} // The fallback above may make the column to be inserted in a position already occupied
|
|
66
|
+
// In this case, put it in any empty slot available
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
if (newOrderedFieldsBeforePinningColumns[index] !== null) {
|
|
70
|
+
index = 0;
|
|
71
|
+
|
|
72
|
+
while (newOrderedFieldsBeforePinningColumns[index] !== null) {
|
|
73
|
+
index += 1;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
newOrderedFields[index] = field;
|
|
78
|
+
newOrderedFieldsBeforePinningColumns[index] = field; // This field was already consumed so we prevent from being added again
|
|
79
|
+
|
|
80
|
+
remainingFields.splice(remainingFields.indexOf(field), 1);
|
|
81
|
+
}); // The fields remaining are those that're neither pinnned nor were unpinned
|
|
82
|
+
// For these, we spread them across both arrays making sure to not override existing values
|
|
83
|
+
|
|
84
|
+
let i = 0;
|
|
85
|
+
remainingFields.forEach(field => {
|
|
86
|
+
while (newOrderedFieldsBeforePinningColumns[i] !== null) {
|
|
87
|
+
i += 1;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
newOrderedFieldsBeforePinningColumns[i] = field;
|
|
91
|
+
newOrderedFields[i] = field;
|
|
92
|
+
});
|
|
93
|
+
apiRef.current.unstable_caches.columnPinning.orderedFieldsBeforePinningColumns = newOrderedFieldsBeforePinningColumns;
|
|
94
|
+
} else {
|
|
95
|
+
newOrderedFields = [...columnsState.all];
|
|
96
|
+
apiRef.current.unstable_caches.columnPinning.orderedFieldsBeforePinningColumns = [...columnsState.all];
|
|
35
97
|
}
|
|
36
98
|
|
|
37
|
-
|
|
99
|
+
prevAllPinnedColumns.current = allPinnedColumns;
|
|
100
|
+
const centerColumns = newOrderedFields.filter(field => {
|
|
38
101
|
return !leftPinnedColumns.includes(field) && !rightPinnedColumns.includes(field);
|
|
39
102
|
});
|
|
40
103
|
return _extends({}, columnsState, {
|
|
41
104
|
all: [...leftPinnedColumns, ...centerColumns, ...rightPinnedColumns]
|
|
42
105
|
});
|
|
43
|
-
}, [disableColumnPinning, pinnedColumns]);
|
|
106
|
+
}, [apiRef, disableColumnPinning, pinnedColumns]);
|
|
44
107
|
useGridRegisterPipeProcessor(apiRef, 'hydrateColumns', reorderPinnedColumns);
|
|
45
108
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { ownerDocument, useEventCallback } from '@mui/material/utils';
|
|
4
|
-
import { gridClasses,
|
|
4
|
+
import { gridClasses, useGridApiEventHandler, useGridApiOptionHandler, useGridNativeEventListener, useGridLogger } from '@mui/x-data-grid';
|
|
5
5
|
import { clamp, findParentElementFromClassName } from '@mui/x-data-grid/internals';
|
|
6
|
+
import { useTheme } from '@mui/material/styles';
|
|
6
7
|
import { findGridCellElementsFromCol, getFieldFromHeaderElem, findHeaderElementFromField } from '../../../utils/domUtils';
|
|
7
8
|
// TODO: remove support for Safari < 13.
|
|
8
9
|
// https://caniuse.com/#search=touch-action
|
|
@@ -50,10 +51,10 @@ function trackFinger(event, currentTouchId) {
|
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
function computeNewWidth(initialOffsetToSeparator, clickX, columnBounds,
|
|
54
|
+
function computeNewWidth(initialOffsetToSeparator, clickX, columnBounds, resizeDirection) {
|
|
54
55
|
let newWidth = initialOffsetToSeparator;
|
|
55
56
|
|
|
56
|
-
if (
|
|
57
|
+
if (resizeDirection === 'Right') {
|
|
57
58
|
newWidth += clickX - columnBounds.left;
|
|
58
59
|
} else {
|
|
59
60
|
newWidth += columnBounds.right - clickX;
|
|
@@ -62,16 +63,31 @@ function computeNewWidth(initialOffsetToSeparator, clickX, columnBounds, separat
|
|
|
62
63
|
return newWidth;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
function computeOffsetToSeparator(clickX, columnBounds,
|
|
66
|
-
if (
|
|
66
|
+
function computeOffsetToSeparator(clickX, columnBounds, resizeDirection) {
|
|
67
|
+
if (resizeDirection === 'Left') {
|
|
67
68
|
return clickX - columnBounds.left;
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
return columnBounds.right - clickX;
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
function
|
|
74
|
-
|
|
74
|
+
function flipResizeDirection(side) {
|
|
75
|
+
if (side === 'Right') {
|
|
76
|
+
return 'Left';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return 'Right';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function getResizeDirection(element, direction) {
|
|
83
|
+
const side = element.classList.contains(gridClasses['columnSeparator--sideRight']) ? 'Right' : 'Left';
|
|
84
|
+
|
|
85
|
+
if (direction === 'rtl') {
|
|
86
|
+
// Resizing logic should be mirrored in the RTL case
|
|
87
|
+
return flipResizeDirection(side);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return side;
|
|
75
91
|
}
|
|
76
92
|
|
|
77
93
|
export const columnResizeStateInitializer = state => _extends({}, state, {
|
|
@@ -88,12 +104,13 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
88
104
|
const logger = useGridLogger(apiRef, 'useGridColumnResize');
|
|
89
105
|
const colDefRef = React.useRef();
|
|
90
106
|
const colElementRef = React.useRef();
|
|
91
|
-
const colCellElementsRef = React.useRef();
|
|
107
|
+
const colCellElementsRef = React.useRef();
|
|
108
|
+
const theme = useTheme(); // To improve accessibility, the separator has padding on both sides.
|
|
92
109
|
// Clicking inside the padding area should be treated as a click in the separator.
|
|
93
110
|
// This ref stores the offset between the click and the separator.
|
|
94
111
|
|
|
95
112
|
const initialOffsetToSeparator = React.useRef();
|
|
96
|
-
const
|
|
113
|
+
const resizeDirection = React.useRef();
|
|
97
114
|
const stopResizeEventTimeout = React.useRef();
|
|
98
115
|
const touchId = React.useRef();
|
|
99
116
|
|
|
@@ -152,7 +169,7 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
152
169
|
return;
|
|
153
170
|
}
|
|
154
171
|
|
|
155
|
-
let newWidth = computeNewWidth(initialOffsetToSeparator.current, nativeEvent.clientX, colElementRef.current.getBoundingClientRect(),
|
|
172
|
+
let newWidth = computeNewWidth(initialOffsetToSeparator.current, nativeEvent.clientX, colElementRef.current.getBoundingClientRect(), resizeDirection.current);
|
|
156
173
|
newWidth = clamp(newWidth, colDefRef.current.minWidth, colDefRef.current.maxWidth);
|
|
157
174
|
updateWidth(newWidth);
|
|
158
175
|
const params = {
|
|
@@ -188,8 +205,8 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
188
205
|
colCellElementsRef.current = findGridCellElementsFromCol(colElementRef.current, apiRef.current);
|
|
189
206
|
const doc = ownerDocument(apiRef.current.rootElementRef.current);
|
|
190
207
|
doc.body.style.cursor = 'col-resize';
|
|
191
|
-
|
|
192
|
-
initialOffsetToSeparator.current = computeOffsetToSeparator(event.clientX, colElementRef.current.getBoundingClientRect(),
|
|
208
|
+
resizeDirection.current = getResizeDirection(event.currentTarget, theme.direction);
|
|
209
|
+
initialOffsetToSeparator.current = computeOffsetToSeparator(event.clientX, colElementRef.current.getBoundingClientRect(), resizeDirection.current);
|
|
193
210
|
doc.addEventListener('mousemove', handleResizeMouseMove);
|
|
194
211
|
doc.addEventListener('mouseup', handleResizeMouseUp);
|
|
195
212
|
});
|
|
@@ -222,7 +239,7 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
222
239
|
return;
|
|
223
240
|
}
|
|
224
241
|
|
|
225
|
-
let newWidth = computeNewWidth(initialOffsetToSeparator.current, finger.x, colElementRef.current.getBoundingClientRect(),
|
|
242
|
+
let newWidth = computeNewWidth(initialOffsetToSeparator.current, finger.x, colElementRef.current.getBoundingClientRect(), resizeDirection.current);
|
|
226
243
|
newWidth = clamp(newWidth, colDefRef.current.minWidth, colDefRef.current.maxWidth);
|
|
227
244
|
updateWidth(newWidth);
|
|
228
245
|
const params = {
|
|
@@ -263,8 +280,8 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
263
280
|
colDefRef.current = colDef;
|
|
264
281
|
colElementRef.current = findHeaderElementFromField((_apiRef$current$colum2 = apiRef.current.columnHeadersElementRef) == null ? void 0 : _apiRef$current$colum2.current, colDef.field);
|
|
265
282
|
colCellElementsRef.current = findGridCellElementsFromCol(colElementRef.current, apiRef.current);
|
|
266
|
-
|
|
267
|
-
initialOffsetToSeparator.current = computeOffsetToSeparator(touch.clientX, colElementRef.current.getBoundingClientRect(),
|
|
283
|
+
resizeDirection.current = getResizeDirection(event.target, theme.direction);
|
|
284
|
+
initialOffsetToSeparator.current = computeOffsetToSeparator(touch.clientX, colElementRef.current.getBoundingClientRect(), resizeDirection.current);
|
|
268
285
|
const doc = ownerDocument(event.currentTarget);
|
|
269
286
|
doc.addEventListener('touchmove', handleTouchMove);
|
|
270
287
|
doc.addEventListener('touchend', handleTouchEnd);
|
|
@@ -67,7 +67,7 @@ export const useGridDetailPanel = (apiRef, props) => {
|
|
|
67
67
|
});
|
|
68
68
|
}, [apiRef, expandedRowIds]);
|
|
69
69
|
useGridRegisterPipeProcessor(apiRef, 'rowHeight', addDetailHeight);
|
|
70
|
-
apiRef.current.
|
|
70
|
+
apiRef.current.unstable_registerControlState({
|
|
71
71
|
stateId: 'detailPanels',
|
|
72
72
|
propModel: props.detailPanelExpandedRowIds,
|
|
73
73
|
propOnChange: props.onDetailPanelExpandedRowIdsChange,
|
|
@@ -60,6 +60,10 @@ export const useGridRowReorder = (apiRef, props) => {
|
|
|
60
60
|
originRowIndex.current = apiRef.current.getRowIndex(params.id);
|
|
61
61
|
}, [isRowReorderDisabled, classes.rowDragging, logger, apiRef]);
|
|
62
62
|
const handleDragOver = React.useCallback((params, event) => {
|
|
63
|
+
if (dragRowId === '') {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
63
67
|
logger.debug(`Dragging over row ${params.id}`);
|
|
64
68
|
event.preventDefault(); // Prevent drag events propagation.
|
|
65
69
|
// For more information check here https://github.com/mui/mui-x/issues/2680.
|
|
@@ -75,7 +79,7 @@ export const useGridRowReorder = (apiRef, props) => {
|
|
|
75
79
|
// Call the gridEditRowsStateSelector directly to avoid infnite loop
|
|
76
80
|
const editRowsState = gridEditRowsStateSelector(apiRef.current.state);
|
|
77
81
|
|
|
78
|
-
if (isRowReorderDisabled || Object.keys(editRowsState).length !== 0) {
|
|
82
|
+
if (dragRowId === '' || isRowReorderDisabled || Object.keys(editRowsState).length !== 0) {
|
|
79
83
|
return;
|
|
80
84
|
}
|
|
81
85
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { GridApiCommunity } from '@mui/x-data-grid/internals';
|
|
3
2
|
import { DataGridProProcessedProps } from '../../../models/dataGridProProps';
|
|
4
|
-
|
|
3
|
+
import { GridApiPro } from '../../../models/gridApiPro';
|
|
4
|
+
export declare const useGridRowReorderPreProcessors: (apiRef: React.MutableRefObject<GridApiPro>, props: DataGridProProcessedProps) => void;
|
package/index.d.ts
CHANGED
|
@@ -17,5 +17,3 @@ export * from './utils';
|
|
|
17
17
|
export type { DataGridProProps, GridExperimentalProFeatures } from './models/dataGridProProps';
|
|
18
18
|
export { useGridApiContext, useGridApiRef, useGridRootProps } from './typeOverloads/reexports';
|
|
19
19
|
export type { GridApiRef, GridApi, GridInitialState, GridState } from './typeOverloads/reexports';
|
|
20
|
-
export * from './hooks/features/rowGrouping';
|
|
21
|
-
export * from './models/gridGroupingValueGetterParams';
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MUI v5.
|
|
1
|
+
/** @license MUI v5.12.1
|
|
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.
|
|
@@ -18,7 +18,4 @@ export * from './hooks';
|
|
|
18
18
|
export * from './models';
|
|
19
19
|
export * from './components';
|
|
20
20
|
export * from './utils';
|
|
21
|
-
export { useGridApiContext, useGridApiRef, useGridRootProps } from './typeOverloads/reexports';
|
|
22
|
-
// We export them from here to avoid export duplication between pro and premium
|
|
23
|
-
export * from './hooks/features/rowGrouping';
|
|
24
|
-
export * from './models/gridGroupingValueGetterParams';
|
|
21
|
+
export { useGridApiContext, useGridApiRef, useGridRootProps } from './typeOverloads/reexports';
|
|
@@ -235,12 +235,6 @@ DataGridProRaw.propTypes = {
|
|
|
235
235
|
*/
|
|
236
236
|
disableMultipleSelection: PropTypes.bool,
|
|
237
237
|
|
|
238
|
-
/**
|
|
239
|
-
* If `true`, the row grouping is disabled.
|
|
240
|
-
* @default false
|
|
241
|
-
*/
|
|
242
|
-
disableRowGrouping: PropTypes.bool,
|
|
243
|
-
|
|
244
238
|
/**
|
|
245
239
|
* If `true`, the selection on click on a row or cell is disabled.
|
|
246
240
|
* @default false
|
|
@@ -276,7 +270,6 @@ DataGridProRaw.propTypes = {
|
|
|
276
270
|
experimentalFeatures: PropTypes.shape({
|
|
277
271
|
newEditingApi: PropTypes.bool,
|
|
278
272
|
preventCommitWhileValidating: PropTypes.bool,
|
|
279
|
-
rowGrouping: PropTypes.bool,
|
|
280
273
|
warnIfFocusStateIsNotSynced: PropTypes.bool
|
|
281
274
|
}),
|
|
282
275
|
|
|
@@ -330,6 +323,15 @@ DataGridProRaw.propTypes = {
|
|
|
330
323
|
*/
|
|
331
324
|
getDetailPanelHeight: PropTypes.func,
|
|
332
325
|
|
|
326
|
+
/**
|
|
327
|
+
* Function that returns the estimated height for a row.
|
|
328
|
+
* Only works if dynamic row height is used.
|
|
329
|
+
* Once the row height is measured this value is discarded.
|
|
330
|
+
* @param {GridRowHeightParams} params With all properties from [[GridRowHeightParams]].
|
|
331
|
+
* @returns {number | null} The estimated row height value. If `null` or `undefined` then the default row height, based on the density, is applied.
|
|
332
|
+
*/
|
|
333
|
+
getEstimatedRowHeight: PropTypes.func,
|
|
334
|
+
|
|
333
335
|
/**
|
|
334
336
|
* Function that applies CSS classes dynamically on rows.
|
|
335
337
|
* @param {GridRowClassNameParams} params With all properties from [[GridRowClassNameParams]].
|
|
@@ -340,7 +342,7 @@ DataGridProRaw.propTypes = {
|
|
|
340
342
|
/**
|
|
341
343
|
* Function that sets the row height per row.
|
|
342
344
|
* @param {GridRowHeightParams} params With all properties from [[GridRowHeightParams]].
|
|
343
|
-
* @returns {GridRowHeightReturnValue} The row height value. If `null` or `undefined` then the default row height is applied.
|
|
345
|
+
* @returns {GridRowHeightReturnValue} The row height value. If `null` or `undefined` then the default row height is applied. If "auto" then the row height is calculated based on the content.
|
|
344
346
|
*/
|
|
345
347
|
getRowHeight: PropTypes.func,
|
|
346
348
|
|
|
@@ -666,6 +668,22 @@ DataGridProRaw.propTypes = {
|
|
|
666
668
|
*/
|
|
667
669
|
onFilterModelChange: PropTypes.func,
|
|
668
670
|
|
|
671
|
+
/**
|
|
672
|
+
* Callback fired when the menu is closed.
|
|
673
|
+
* @param {GridMenuParams} params With all properties from [[GridMenuParams]].
|
|
674
|
+
* @param {MuiEvent<{}>} event The event object.
|
|
675
|
+
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
676
|
+
*/
|
|
677
|
+
onMenuClose: PropTypes.func,
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Callback fired when the menu is opened.
|
|
681
|
+
* @param {GridMenuParams} params With all properties from [[GridMenuParams]].
|
|
682
|
+
* @param {MuiEvent<{}>} event The event object.
|
|
683
|
+
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
684
|
+
*/
|
|
685
|
+
onMenuOpen: PropTypes.func,
|
|
686
|
+
|
|
669
687
|
/**
|
|
670
688
|
* Callback fired when the current page has changed.
|
|
671
689
|
* @param {number} page Index of the page displayed on the Grid.
|
|
@@ -755,13 +773,6 @@ DataGridProRaw.propTypes = {
|
|
|
755
773
|
*/
|
|
756
774
|
onRowEditStop: PropTypes.func,
|
|
757
775
|
|
|
758
|
-
/**
|
|
759
|
-
* Callback fired when the row grouping model changes.
|
|
760
|
-
* @param {GridRowGroupingModel} model Columns used as grouping criteria.
|
|
761
|
-
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
762
|
-
*/
|
|
763
|
-
onRowGroupingModelChange: PropTypes.func,
|
|
764
|
-
|
|
765
776
|
/**
|
|
766
777
|
* Callback fired when the `rowModesModel` prop changes.
|
|
767
778
|
* @param {GridRowModesModel} rowModesModel Object containig which rows are in "edit" mode.
|
|
@@ -865,18 +876,6 @@ DataGridProRaw.propTypes = {
|
|
|
865
876
|
*/
|
|
866
877
|
rowCount: PropTypes.number,
|
|
867
878
|
|
|
868
|
-
/**
|
|
869
|
-
* If `single`, all column we are grouping by will be represented in the same grouping the same column.
|
|
870
|
-
* If `multiple`, each column we are grouping by will be represented in its own column.
|
|
871
|
-
* @default 'single'
|
|
872
|
-
*/
|
|
873
|
-
rowGroupingColumnMode: PropTypes.oneOf(['multiple', 'single']),
|
|
874
|
-
|
|
875
|
-
/**
|
|
876
|
-
* Set the row grouping model of the grid.
|
|
877
|
-
*/
|
|
878
|
-
rowGroupingModel: PropTypes.arrayOf(PropTypes.string),
|
|
879
|
-
|
|
880
879
|
/**
|
|
881
880
|
* Set the height in pixel of a row in the grid.
|
|
882
881
|
* @default 52
|
|
@@ -12,8 +12,6 @@ import { useGridDetailPanelCache } from '../hooks/features/detailPanel/useGridDe
|
|
|
12
12
|
import { useGridDetailPanelPreProcessors } from '../hooks/features/detailPanel/useGridDetailPanelPreProcessors';
|
|
13
13
|
import { useGridRowReorder } from '../hooks/features/rowReorder/useGridRowReorder';
|
|
14
14
|
import { useGridRowReorderPreProcessors } from '../hooks/features/rowReorder/useGridRowReorderPreProcessors';
|
|
15
|
-
import { useGridRowGrouping, rowGroupingStateInitializer } from '../hooks/features/rowGrouping/useGridRowGrouping';
|
|
16
|
-
import { useGridRowGroupingPreProcessors } from '../hooks/features/rowGrouping/useGridRowGroupingPreProcessors';
|
|
17
15
|
export var useDataGridProComponent = function useDataGridProComponent(inputApiRef, props) {
|
|
18
16
|
var _props$experimentalFe, _props$experimentalFe2;
|
|
19
17
|
|
|
@@ -24,7 +22,6 @@ export var useDataGridProComponent = function useDataGridProComponent(inputApiRe
|
|
|
24
22
|
|
|
25
23
|
useGridSelectionPreProcessors(apiRef, props);
|
|
26
24
|
useGridRowReorderPreProcessors(apiRef, props);
|
|
27
|
-
useGridRowGroupingPreProcessors(apiRef, props);
|
|
28
25
|
useGridTreeDataPreProcessors(apiRef, props);
|
|
29
26
|
useGridDetailPanelPreProcessors(apiRef, props); // The column pinning `hydrateColumns` pre-processor must be after every other `hydrateColumns` pre-processors
|
|
30
27
|
// Because it changes the order of the columns.
|
|
@@ -35,7 +32,6 @@ export var useDataGridProComponent = function useDataGridProComponent(inputApiRe
|
|
|
35
32
|
* Register all state initializers here.
|
|
36
33
|
*/
|
|
37
34
|
|
|
38
|
-
useGridInitializeState(rowGroupingStateInitializer, apiRef, props);
|
|
39
35
|
useGridInitializeState(selectionStateInitializer, apiRef, props);
|
|
40
36
|
useGridInitializeState(detailPanelStateInitializer, apiRef, props);
|
|
41
37
|
useGridInitializeState(columnPinningStateInitializer, apiRef, props);
|
|
@@ -52,7 +48,6 @@ export var useDataGridProComponent = function useDataGridProComponent(inputApiRe
|
|
|
52
48
|
useGridInitializeState(paginationStateInitializer, apiRef, props);
|
|
53
49
|
useGridInitializeState(rowsMetaStateInitializer, apiRef, props);
|
|
54
50
|
useGridInitializeState(columnMenuStateInitializer, apiRef, props);
|
|
55
|
-
useGridRowGrouping(apiRef, props);
|
|
56
51
|
useGridTreeData(apiRef);
|
|
57
52
|
useGridKeyboardNavigation(apiRef, props);
|
|
58
53
|
useGridSelection(apiRef, props);
|
|
@@ -3,7 +3,6 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { useThemeProps } from '@mui/material/styles';
|
|
5
5
|
import { DATA_GRID_DEFAULT_SLOTS_COMPONENTS, GRID_DEFAULT_LOCALE_TEXT, DATA_GRID_PROPS_DEFAULT_VALUES } from '@mui/x-data-grid';
|
|
6
|
-
import { buildWarning } from '@mui/x-data-grid/internals';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* The default values of `DataGridProPropsWithDefaultValue` to inject in the props of DataGridPro.
|
|
@@ -18,11 +17,8 @@ export var DATA_GRID_PRO_PROPS_DEFAULT_VALUES = _extends({}, DATA_GRID_PROPS_DEF
|
|
|
18
17
|
rowReordering: false,
|
|
19
18
|
getDetailPanelHeight: function getDetailPanelHeight() {
|
|
20
19
|
return 500;
|
|
21
|
-
}
|
|
22
|
-
disableRowGrouping: false,
|
|
23
|
-
rowGroupingColumnMode: 'single'
|
|
20
|
+
}
|
|
24
21
|
});
|
|
25
|
-
var rowGroupingWarning = 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');
|
|
26
22
|
export var useDataGridProProps = function useDataGridProProps(inProps) {
|
|
27
23
|
var themedProps = useThemeProps({
|
|
28
24
|
props: inProps,
|
|
@@ -48,23 +44,8 @@ export var useDataGridProProps = function useDataGridProProps(inProps) {
|
|
|
48
44
|
});
|
|
49
45
|
return mergedComponents;
|
|
50
46
|
}, [themedProps.components]);
|
|
51
|
-
|
|
52
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
53
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
54
|
-
React.useEffect(function () {
|
|
55
|
-
var _themedProps$experime;
|
|
56
|
-
|
|
57
|
-
if ((_themedProps$experime = themedProps.experimentalFeatures) != null && _themedProps$experime.rowGrouping) {
|
|
58
|
-
rowGroupingWarning();
|
|
59
|
-
}
|
|
60
|
-
}, [themedProps.experimentalFeatures]);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
47
|
return React.useMemo(function () {
|
|
64
|
-
var _themedProps$experime2;
|
|
65
|
-
|
|
66
48
|
return _extends({}, DATA_GRID_PRO_PROPS_DEFAULT_VALUES, themedProps, {
|
|
67
|
-
disableRowGrouping: themedProps.disableRowGrouping || !((_themedProps$experime2 = themedProps.experimentalFeatures) != null && _themedProps$experime2.rowGrouping),
|
|
68
49
|
localeText: localeText,
|
|
69
50
|
components: components,
|
|
70
51
|
signature: 'DataGridPro'
|
|
@@ -93,7 +93,8 @@ var VirtualScrollerDetailPanel = styled(Box, {
|
|
|
93
93
|
zIndex: 2,
|
|
94
94
|
width: '100%',
|
|
95
95
|
position: 'absolute',
|
|
96
|
-
backgroundColor: theme.palette.background.default
|
|
96
|
+
backgroundColor: theme.palette.background.default,
|
|
97
|
+
overflow: 'auto'
|
|
97
98
|
};
|
|
98
99
|
});
|
|
99
100
|
var VirtualScrollerPinnedColumns = styled('div', {
|
|
@@ -258,7 +259,8 @@ var DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGrid
|
|
|
258
259
|
renderContext: leftRenderContext,
|
|
259
260
|
minFirstColumn: leftRenderContext.firstColumnIndex,
|
|
260
261
|
maxLastColumn: leftRenderContext.lastColumnIndex,
|
|
261
|
-
availableSpace: 0
|
|
262
|
+
availableSpace: 0,
|
|
263
|
+
ignoreAutoHeight: true
|
|
262
264
|
})
|
|
263
265
|
}), /*#__PURE__*/_jsx(GridVirtualScrollerRenderZone, _extends({}, getRenderZoneProps(), {
|
|
264
266
|
children: getRows({
|
|
@@ -275,7 +277,8 @@ var DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGrid
|
|
|
275
277
|
renderContext: rightRenderContext,
|
|
276
278
|
minFirstColumn: rightRenderContext.firstColumnIndex,
|
|
277
279
|
maxLastColumn: rightRenderContext.lastColumnIndex,
|
|
278
|
-
availableSpace: 0
|
|
280
|
+
availableSpace: 0,
|
|
281
|
+
ignoreAutoHeight: true
|
|
279
282
|
})
|
|
280
283
|
}), detailPanels.length > 0 && /*#__PURE__*/_jsx(VirtualScrollerDetailPanels, {
|
|
281
284
|
className: classes.detailPanels,
|
|
@@ -25,7 +25,9 @@ var GridRowReorderCell = function GridRowReorderCell(params) {
|
|
|
25
25
|
|
|
26
26
|
var cellValue = params.row.__reorder__ || params.id; // TODO: remove sortModel and treeDepth checks once row reorder is compatible
|
|
27
27
|
|
|
28
|
-
var isDraggable =
|
|
28
|
+
var isDraggable = React.useMemo(function () {
|
|
29
|
+
return !!rootProps.rowReordering && !sortModel.length && treeDepth === 1 && Object.keys(editRowsState).length === 0;
|
|
30
|
+
}, [rootProps.rowReordering, sortModel, treeDepth, editRowsState]);
|
|
29
31
|
var ownerState = {
|
|
30
32
|
isDraggable: isDraggable,
|
|
31
33
|
classes: rootProps.classes
|
|
@@ -41,22 +43,22 @@ var GridRowReorderCell = function GridRowReorderCell(params) {
|
|
|
41
43
|
} // The row might have been deleted
|
|
42
44
|
|
|
43
45
|
|
|
44
|
-
if (!apiRef.current.getRow(params.
|
|
46
|
+
if (!apiRef.current.getRow(params.id)) {
|
|
45
47
|
return;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
apiRef.current.publishEvent(eventName, apiRef.current.getRowParams(params.
|
|
50
|
+
apiRef.current.publishEvent(eventName, apiRef.current.getRowParams(params.id), event);
|
|
49
51
|
|
|
50
52
|
if (propHandler) {
|
|
51
53
|
propHandler(event);
|
|
52
54
|
}
|
|
53
55
|
};
|
|
54
|
-
}, [apiRef, params.
|
|
55
|
-
var draggableEventHandlers = {
|
|
56
|
+
}, [apiRef, params.id]);
|
|
57
|
+
var draggableEventHandlers = isDraggable ? {
|
|
56
58
|
onDragStart: publish('rowDragStart'),
|
|
57
59
|
onDragOver: publish('rowDragOver'),
|
|
58
60
|
onDragEnd: publish('rowDragEnd')
|
|
59
|
-
};
|
|
61
|
+
} : null;
|
|
60
62
|
return /*#__PURE__*/_jsxs("div", _extends({
|
|
61
63
|
className: classes.root,
|
|
62
64
|
draggable: isDraggable
|