@mui/x-data-grid-pro 5.9.0 → 5.11.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 +284 -10
- package/DataGridPro/DataGridPro.d.ts +1 -1
- package/DataGridPro/DataGridPro.js +50 -2
- package/DataGridPro/useDataGridProComponent.js +6 -2
- package/DataGridPro/useDataGridProProps.js +20 -5
- package/LICENSE +4 -4
- package/README.md +5 -4
- package/components/DataGridProColumnHeaders.js +2 -2
- package/components/DataGridProVirtualScroller.js +7 -4
- package/components/GridGroupingCriteriaCell.js +2 -2
- package/components/GridRowReorderCell.d.ts +5 -0
- package/components/GridRowReorderCell.js +72 -0
- package/components/GridTreeDataGroupingCell.js +2 -2
- package/hooks/features/columnPinning/useGridColumnPinning.js +4 -4
- package/hooks/features/columnReorder/useGridColumnReorder.d.ts +0 -1
- package/hooks/features/columnReorder/useGridColumnReorder.js +8 -9
- package/hooks/features/columnResize/useGridColumnResize.d.ts +0 -1
- package/hooks/features/columnResize/useGridColumnResize.js +13 -14
- package/hooks/features/detailPanel/useGridDetailPanel.js +4 -4
- package/hooks/features/detailPanel/useGridDetailPanelCache.js +2 -2
- package/hooks/features/index.d.ts +1 -1
- package/hooks/features/index.js +1 -1
- package/hooks/features/infiniteLoader/useGridInfiniteLoader.d.ts +0 -1
- package/hooks/features/infiniteLoader/useGridInfiniteLoader.js +4 -5
- package/hooks/features/rowGrouping/createGroupingColDef.d.ts +1 -1
- package/hooks/features/rowGrouping/gridRowGroupingInterfaces.d.ts +1 -1
- package/hooks/features/rowGrouping/gridRowGroupingUtils.js +4 -4
- package/hooks/features/rowGrouping/useGridRowGrouping.d.ts +0 -2
- package/hooks/features/rowGrouping/useGridRowGrouping.js +6 -8
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +2 -2
- package/hooks/features/rowReorder/gridRowReorderColDef.d.ts +2 -0
- package/hooks/features/rowReorder/gridRowReorderColDef.js +18 -0
- package/hooks/features/rowReorder/index.d.ts +1 -0
- package/hooks/features/rowReorder/index.js +1 -0
- package/hooks/features/rowReorder/useGridRowReorder.d.ts +8 -0
- package/hooks/features/rowReorder/useGridRowReorder.js +111 -0
- package/hooks/features/rowReorder/useGridRowReorderPreProcessors.d.ts +4 -0
- package/hooks/features/rowReorder/useGridRowReorderPreProcessors.js +51 -0
- package/hooks/features/treeData/useGridTreeData.d.ts +0 -3
- package/hooks/features/treeData/useGridTreeData.js +2 -6
- package/index.d.ts +6 -1
- package/index.js +7 -3
- package/internals/index.d.ts +19 -0
- package/internals/index.js +17 -0
- package/internals/package.json +6 -0
- package/legacy/DataGridPro/DataGridPro.js +50 -2
- package/legacy/DataGridPro/useDataGridProComponent.js +6 -2
- package/legacy/DataGridPro/useDataGridProProps.js +20 -5
- package/legacy/components/DataGridProColumnHeaders.js +2 -2
- package/legacy/components/DataGridProVirtualScroller.js +7 -4
- package/legacy/components/GridGroupingCriteriaCell.js +2 -2
- package/legacy/components/GridRowReorderCell.js +74 -0
- package/legacy/components/GridTreeDataGroupingCell.js +2 -2
- package/legacy/hooks/features/columnPinning/useGridColumnPinning.js +4 -4
- package/legacy/hooks/features/columnReorder/useGridColumnReorder.js +8 -9
- package/legacy/hooks/features/columnResize/useGridColumnResize.js +13 -14
- package/legacy/hooks/features/detailPanel/useGridDetailPanel.js +4 -4
- package/legacy/hooks/features/detailPanel/useGridDetailPanelCache.js +2 -2
- package/legacy/hooks/features/index.js +1 -1
- package/legacy/hooks/features/infiniteLoader/useGridInfiniteLoader.js +4 -5
- package/legacy/hooks/features/rowGrouping/gridRowGroupingUtils.js +5 -5
- package/legacy/hooks/features/rowGrouping/useGridRowGrouping.js +6 -8
- package/legacy/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +2 -2
- package/legacy/hooks/features/rowReorder/gridRowReorderColDef.js +20 -0
- package/legacy/hooks/features/rowReorder/index.js +1 -0
- package/legacy/hooks/features/rowReorder/useGridRowReorder.js +115 -0
- package/legacy/hooks/features/rowReorder/useGridRowReorderPreProcessors.js +52 -0
- package/legacy/hooks/features/treeData/useGridTreeData.js +2 -6
- package/legacy/index.js +7 -3
- package/legacy/internals/index.js +17 -0
- package/legacy/models/gridRowOrderChangeParams.js +1 -0
- package/legacy/models/index.js +1 -2
- package/legacy/typeOverloads/index.js +1 -0
- package/legacy/utils/index.js +1 -0
- package/legacy/utils/releaseInfo.js +1 -1
- package/legacy/utils/tree/buildRowTree.js +11 -4
- package/legacy/utils/tree/index.js +1 -0
- package/models/dataGridProProps.d.ts +36 -24
- package/models/gridApiPro.d.ts +3 -2
- package/models/gridRowOrderChangeParams.d.ts +18 -0
- package/models/gridRowOrderChangeParams.js +1 -0
- package/models/gridStatePro.d.ts +4 -3
- package/models/index.d.ts +1 -2
- package/models/index.js +1 -2
- package/modern/DataGridPro/DataGridPro.js +50 -2
- package/modern/DataGridPro/useDataGridProComponent.js +6 -2
- package/modern/DataGridPro/useDataGridProProps.js +16 -3
- package/modern/components/DataGridProColumnHeaders.js +2 -2
- package/modern/components/DataGridProVirtualScroller.js +7 -4
- package/modern/components/GridGroupingCriteriaCell.js +2 -2
- package/modern/components/GridRowReorderCell.js +72 -0
- package/modern/components/GridTreeDataGroupingCell.js +2 -2
- package/modern/hooks/features/columnPinning/useGridColumnPinning.js +4 -4
- package/modern/hooks/features/columnReorder/useGridColumnReorder.js +8 -9
- package/modern/hooks/features/columnResize/useGridColumnResize.js +13 -14
- package/modern/hooks/features/detailPanel/useGridDetailPanel.js +4 -4
- package/modern/hooks/features/detailPanel/useGridDetailPanelCache.js +2 -2
- package/modern/hooks/features/index.js +1 -1
- package/modern/hooks/features/infiniteLoader/useGridInfiniteLoader.js +4 -5
- package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +4 -4
- package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +6 -8
- package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +2 -2
- package/modern/hooks/features/rowReorder/gridRowReorderColDef.js +18 -0
- package/modern/hooks/features/rowReorder/index.js +1 -0
- package/modern/hooks/features/rowReorder/useGridRowReorder.js +111 -0
- package/modern/hooks/features/rowReorder/useGridRowReorderPreProcessors.js +51 -0
- package/modern/hooks/features/treeData/useGridTreeData.js +2 -6
- package/modern/index.js +7 -3
- package/modern/internals/index.js +17 -0
- package/modern/models/gridRowOrderChangeParams.js +1 -0
- package/modern/models/index.js +1 -2
- package/modern/typeOverloads/index.js +1 -0
- package/modern/utils/index.js +1 -0
- package/modern/utils/releaseInfo.js +1 -1
- package/modern/utils/tree/buildRowTree.js +9 -2
- package/modern/utils/tree/index.js +1 -0
- package/node/DataGridPro/DataGridPro.js +50 -2
- package/node/DataGridPro/useDataGridProComponent.js +10 -4
- package/node/DataGridPro/useDataGridProProps.js +21 -5
- package/node/components/DataGridProColumnHeaders.js +1 -1
- package/node/components/DataGridProVirtualScroller.js +6 -3
- package/node/components/GridGroupingCriteriaCell.js +1 -1
- package/node/components/GridRowReorderCell.js +92 -0
- package/node/components/GridTreeDataGroupingCell.js +1 -1
- package/node/hooks/features/columnPinning/useGridColumnPinning.js +3 -3
- package/node/hooks/features/columnReorder/useGridColumnReorder.js +7 -8
- package/node/hooks/features/columnResize/useGridColumnResize.js +12 -13
- package/node/hooks/features/detailPanel/useGridDetailPanel.js +3 -3
- package/node/hooks/features/detailPanel/useGridDetailPanelCache.js +1 -1
- package/node/hooks/features/index.js +4 -4
- package/node/hooks/features/infiniteLoader/useGridInfiniteLoader.js +3 -4
- package/node/hooks/features/rowGrouping/gridRowGroupingUtils.js +4 -4
- package/node/hooks/features/rowGrouping/useGridRowGrouping.js +5 -7
- package/node/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +4 -4
- package/node/hooks/features/rowReorder/gridRowReorderColDef.js +31 -0
- package/node/hooks/features/rowReorder/index.js +18 -0
- package/node/hooks/features/rowReorder/useGridRowReorder.js +126 -0
- package/node/hooks/features/rowReorder/useGridRowReorderPreProcessors.js +70 -0
- package/node/hooks/features/treeData/useGridTreeData.js +1 -4
- package/node/index.js +45 -3
- package/node/internals/index.js +193 -0
- package/node/models/gridRowOrderChangeParams.js +5 -0
- package/node/models/index.js +4 -4
- package/node/typeOverloads/index.js +18 -0
- package/node/utils/index.js +18 -0
- package/node/utils/releaseInfo.js +1 -1
- package/node/utils/tree/buildRowTree.js +12 -2
- package/node/utils/tree/index.js +13 -0
- package/package.json +6 -5
- package/typeOverloads/index.d.ts +1 -0
- package/typeOverloads/index.js +1 -0
- package/typeOverloads/modules.d.ts +41 -15
- package/typeOverloads/package.json +6 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/package.json +6 -0
- package/utils/releaseInfo.js +1 -1
- package/utils/tree/buildRowTree.d.ts +1 -0
- package/utils/tree/buildRowTree.js +9 -2
- package/utils/tree/index.d.ts +1 -0
- package/utils/tree/index.js +1 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
3
|
+
import { useGridLogger, useGridApiEventHandler, getDataGridUtilityClass, useGridSelector, gridSortModelSelector, gridRowTreeDepthSelector, useGridApiOptionHandler, gridEditRowsStateSelector } from '@mui/x-data-grid';
|
|
4
|
+
|
|
5
|
+
const useUtilityClasses = ownerState => {
|
|
6
|
+
const {
|
|
7
|
+
classes
|
|
8
|
+
} = ownerState;
|
|
9
|
+
const slots = {
|
|
10
|
+
rowDragging: ['row--dragging']
|
|
11
|
+
};
|
|
12
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Only available in DataGridPro
|
|
16
|
+
* @requires useGridRows (method)
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
export const useGridRowReorder = (apiRef, props) => {
|
|
21
|
+
const logger = useGridLogger(apiRef, 'useGridRowReorder');
|
|
22
|
+
const sortModel = useGridSelector(apiRef, gridSortModelSelector);
|
|
23
|
+
const treeDepth = useGridSelector(apiRef, gridRowTreeDepthSelector);
|
|
24
|
+
const dragRowNode = React.useRef(null);
|
|
25
|
+
const originRowIndex = React.useRef(null);
|
|
26
|
+
const removeDnDStylesTimeout = React.useRef();
|
|
27
|
+
const ownerState = {
|
|
28
|
+
classes: props.classes
|
|
29
|
+
};
|
|
30
|
+
const classes = useUtilityClasses(ownerState);
|
|
31
|
+
const [dragRowId, setDragRowId] = React.useState('');
|
|
32
|
+
React.useEffect(() => {
|
|
33
|
+
return () => {
|
|
34
|
+
clearTimeout(removeDnDStylesTimeout.current);
|
|
35
|
+
};
|
|
36
|
+
}, []); // TODO: remove sortModel check once row reorder is sorting compatible
|
|
37
|
+
// remove treeDepth once row reorder is tree compatible
|
|
38
|
+
|
|
39
|
+
const isRowReorderDisabled = React.useMemo(() => {
|
|
40
|
+
return !props.rowReordering || !!sortModel.length || treeDepth !== 1;
|
|
41
|
+
}, [props.rowReordering, sortModel, treeDepth]);
|
|
42
|
+
const handleDragStart = React.useCallback((params, event) => {
|
|
43
|
+
// Call the gridEditRowsStateSelector directly to avoid infnite loop
|
|
44
|
+
const editRowsState = gridEditRowsStateSelector(apiRef.current.state);
|
|
45
|
+
|
|
46
|
+
if (isRowReorderDisabled || Object.keys(editRowsState).length !== 0) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
logger.debug(`Start dragging row ${params.id}`); // Prevent drag events propagation.
|
|
51
|
+
// For more information check here https://github.com/mui/mui-x/issues/2680.
|
|
52
|
+
|
|
53
|
+
event.stopPropagation();
|
|
54
|
+
dragRowNode.current = event.currentTarget;
|
|
55
|
+
dragRowNode.current.classList.add(classes.rowDragging);
|
|
56
|
+
setDragRowId(params.id);
|
|
57
|
+
removeDnDStylesTimeout.current = setTimeout(() => {
|
|
58
|
+
dragRowNode.current.classList.remove(classes.rowDragging);
|
|
59
|
+
});
|
|
60
|
+
originRowIndex.current = apiRef.current.getRowIndex(params.id);
|
|
61
|
+
}, [isRowReorderDisabled, classes.rowDragging, logger, apiRef]);
|
|
62
|
+
const handleDragOver = React.useCallback((params, event) => {
|
|
63
|
+
logger.debug(`Dragging over row ${params.id}`);
|
|
64
|
+
event.preventDefault(); // Prevent drag events propagation.
|
|
65
|
+
// For more information check here https://github.com/mui/mui-x/issues/2680.
|
|
66
|
+
|
|
67
|
+
event.stopPropagation();
|
|
68
|
+
|
|
69
|
+
if (params.id !== dragRowId) {
|
|
70
|
+
const targetRowIndex = apiRef.current.getRowIndex(params.id);
|
|
71
|
+
apiRef.current.setRowIndex(dragRowId, targetRowIndex);
|
|
72
|
+
}
|
|
73
|
+
}, [apiRef, logger, dragRowId]);
|
|
74
|
+
const handleDragEnd = React.useCallback((params, event) => {
|
|
75
|
+
// Call the gridEditRowsStateSelector directly to avoid infnite loop
|
|
76
|
+
const editRowsState = gridEditRowsStateSelector(apiRef.current.state);
|
|
77
|
+
|
|
78
|
+
if (isRowReorderDisabled || Object.keys(editRowsState).length !== 0) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
logger.debug('End dragging row');
|
|
83
|
+
event.preventDefault(); // Prevent drag events propagation.
|
|
84
|
+
// For more information check here https://github.com/mui/mui-x/issues/2680.
|
|
85
|
+
|
|
86
|
+
event.stopPropagation();
|
|
87
|
+
clearTimeout(removeDnDStylesTimeout.current);
|
|
88
|
+
dragRowNode.current = null; // Check if the row was dropped outside the grid.
|
|
89
|
+
|
|
90
|
+
if (event.dataTransfer.dropEffect === 'none') {
|
|
91
|
+
// Accessing params.field may contain the wrong field as header elements are reused
|
|
92
|
+
apiRef.current.setRowIndex(dragRowId, originRowIndex.current);
|
|
93
|
+
originRowIndex.current = null;
|
|
94
|
+
} else {
|
|
95
|
+
// Emit the rowOrderChange event only once when the reordering stops.
|
|
96
|
+
const rowOrderChangeParams = {
|
|
97
|
+
row: apiRef.current.getRow(dragRowId),
|
|
98
|
+
targetIndex: apiRef.current.getRowIndex(params.id),
|
|
99
|
+
oldIndex: originRowIndex.current
|
|
100
|
+
};
|
|
101
|
+
apiRef.current.publishEvent('rowOrderChange', rowOrderChangeParams);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
setDragRowId('');
|
|
105
|
+
}, [isRowReorderDisabled, logger, apiRef, dragRowId]);
|
|
106
|
+
useGridApiEventHandler(apiRef, 'rowDragStart', handleDragStart);
|
|
107
|
+
useGridApiEventHandler(apiRef, 'rowDragOver', handleDragOver);
|
|
108
|
+
useGridApiEventHandler(apiRef, 'rowDragEnd', handleDragEnd);
|
|
109
|
+
useGridApiEventHandler(apiRef, 'cellDragOver', handleDragOver);
|
|
110
|
+
useGridApiOptionHandler(apiRef, 'rowOrderChange', props.onRowOrderChange);
|
|
111
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GridApiCommunity } from '@mui/x-data-grid/internals';
|
|
3
|
+
import { DataGridProProcessedProps } from '../../../models/dataGridProProps';
|
|
4
|
+
export declare const useGridRowReorderPreProcessors: (apiRef: React.MutableRefObject<GridApiCommunity>, props: DataGridProProcessedProps) => void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
4
|
+
import { getDataGridUtilityClass } from '@mui/x-data-grid';
|
|
5
|
+
import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
|
|
6
|
+
import { GRID_REORDER_COL_DEF } from './gridRowReorderColDef';
|
|
7
|
+
|
|
8
|
+
const useUtilityClasses = ownerState => {
|
|
9
|
+
const {
|
|
10
|
+
classes
|
|
11
|
+
} = ownerState;
|
|
12
|
+
return React.useMemo(() => {
|
|
13
|
+
const slots = {
|
|
14
|
+
rowReorderCellContainer: ['rowReorderCellContainer'],
|
|
15
|
+
columnHeaderReorder: ['columnHeaderReorder']
|
|
16
|
+
};
|
|
17
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
18
|
+
}, [classes]);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const useGridRowReorderPreProcessors = (apiRef, props) => {
|
|
22
|
+
const ownerState = {
|
|
23
|
+
classes: props.classes
|
|
24
|
+
};
|
|
25
|
+
const classes = useUtilityClasses(ownerState);
|
|
26
|
+
const updateReorderColumn = React.useCallback(columnsState => {
|
|
27
|
+
const reorderColumn = _extends({}, GRID_REORDER_COL_DEF, {
|
|
28
|
+
cellClassName: classes.rowReorderCellContainer,
|
|
29
|
+
headerClassName: classes.columnHeaderReorder,
|
|
30
|
+
headerName: apiRef.current.getLocaleText('rowReorderingHeaderName')
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const shouldHaveReorderColumn = props.rowReordering;
|
|
34
|
+
const haveReorderColumn = columnsState.lookup[reorderColumn.field] != null;
|
|
35
|
+
|
|
36
|
+
if (shouldHaveReorderColumn && haveReorderColumn) {
|
|
37
|
+
return columnsState;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (shouldHaveReorderColumn && !haveReorderColumn) {
|
|
41
|
+
columnsState.lookup[reorderColumn.field] = reorderColumn;
|
|
42
|
+
columnsState.all = [reorderColumn.field, ...columnsState.all];
|
|
43
|
+
} else if (!shouldHaveReorderColumn && haveReorderColumn) {
|
|
44
|
+
delete columnsState.lookup[reorderColumn.field];
|
|
45
|
+
columnsState.all = columnsState.all.filter(field => field !== reorderColumn.field);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return columnsState;
|
|
49
|
+
}, [apiRef, classes, props.rowReordering]);
|
|
50
|
+
useGridRegisterPipeProcessor(apiRef, 'hydrateColumns', updateReorderColumn);
|
|
51
|
+
};
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useGridApiEventHandler,
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Only available in DataGridPro
|
|
6
|
-
*/
|
|
2
|
+
import { useGridApiEventHandler, gridFilteredDescendantCountLookupSelector } from '@mui/x-data-grid';
|
|
7
3
|
export const useGridTreeData = apiRef => {
|
|
8
4
|
/**
|
|
9
5
|
* EVENTS
|
|
@@ -23,5 +19,5 @@ export const useGridTreeData = apiRef => {
|
|
|
23
19
|
apiRef.current.setRowChildrenExpansion(params.id, !params.rowNode.childrenExpanded);
|
|
24
20
|
}
|
|
25
21
|
}, [apiRef]);
|
|
26
|
-
useGridApiEventHandler(apiRef,
|
|
22
|
+
useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
27
23
|
};
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import './typeOverloads
|
|
1
|
+
import './typeOverloads';
|
|
2
2
|
export { LicenseInfo } from '@mui/x-license-pro';
|
|
3
3
|
export * from '@mui/x-data-grid/components';
|
|
4
4
|
export * from '@mui/x-data-grid/constants';
|
|
@@ -8,9 +8,14 @@ export * from '@mui/x-data-grid/models';
|
|
|
8
8
|
export * from '@mui/x-data-grid/context';
|
|
9
9
|
export * from '@mui/x-data-grid/utils';
|
|
10
10
|
export * from '@mui/x-data-grid/colDef';
|
|
11
|
+
export type { GridExportFormat, GridExportExtension, GridToolbarExportProps, } from '@mui/x-data-grid';
|
|
11
12
|
export * from './DataGridPro';
|
|
12
13
|
export * from './hooks';
|
|
13
14
|
export * from './models';
|
|
14
15
|
export * from './components';
|
|
16
|
+
export * from './utils';
|
|
17
|
+
export type { DataGridProProps, GridExperimentalProFeatures } from './models/dataGridProProps';
|
|
15
18
|
export { useGridApiContext, useGridApiRef, useGridRootProps } from './typeOverloads/reexports';
|
|
16
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,9 +1,9 @@
|
|
|
1
|
-
/** @license MUI v5.
|
|
1
|
+
/** @license MUI v5.11.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.
|
|
5
5
|
*/
|
|
6
|
-
import './typeOverloads
|
|
6
|
+
import './typeOverloads';
|
|
7
7
|
export { LicenseInfo } from '@mui/x-license-pro';
|
|
8
8
|
export * from '@mui/x-data-grid/components';
|
|
9
9
|
export * from '@mui/x-data-grid/constants';
|
|
@@ -17,4 +17,8 @@ export * from './DataGridPro';
|
|
|
17
17
|
export * from './hooks';
|
|
18
18
|
export * from './models';
|
|
19
19
|
export * from './components';
|
|
20
|
-
export
|
|
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';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from '@mui/x-data-grid/internals';
|
|
2
|
+
export { DataGridProVirtualScroller } from '../components/DataGridProVirtualScroller';
|
|
3
|
+
export { DataGridProColumnHeaders } from '../components/DataGridProColumnHeaders';
|
|
4
|
+
export { useGridColumnResize, columnResizeStateInitializer, } from '../hooks/features/columnResize/useGridColumnResize';
|
|
5
|
+
export { useGridColumnPinning, columnPinningStateInitializer, } from '../hooks/features/columnPinning/useGridColumnPinning';
|
|
6
|
+
export { useGridColumnPinningPreProcessors } from '../hooks/features/columnPinning/useGridColumnPinningPreProcessors';
|
|
7
|
+
export { useGridColumnReorder, columnReorderStateInitializer, } from '../hooks/features/columnReorder/useGridColumnReorder';
|
|
8
|
+
export { useGridDetailPanel, detailPanelStateInitializer, } from '../hooks/features/detailPanel/useGridDetailPanel';
|
|
9
|
+
export { useGridDetailPanelCache } from '../hooks/features/detailPanel/useGridDetailPanelCache';
|
|
10
|
+
export { useGridDetailPanelPreProcessors } from '../hooks/features/detailPanel/useGridDetailPanelPreProcessors';
|
|
11
|
+
export { useGridInfiniteLoader } from '../hooks/features/infiniteLoader/useGridInfiniteLoader';
|
|
12
|
+
export { useGridRowReorder } from '../hooks/features/rowReorder/useGridRowReorder';
|
|
13
|
+
export { useGridRowReorderPreProcessors } from '../hooks/features/rowReorder/useGridRowReorderPreProcessors';
|
|
14
|
+
export { useGridTreeData } from '../hooks/features/treeData/useGridTreeData';
|
|
15
|
+
export { useGridTreeDataPreProcessors } from '../hooks/features/treeData/useGridTreeDataPreProcessors';
|
|
16
|
+
export type { GridExperimentalProFeatures, DataGridProPropsWithoutDefaultValue, DataGridProPropsWithDefaultValue, } from '../models/dataGridProProps';
|
|
17
|
+
export { buildRowTree } from '../utils/tree/buildRowTree';
|
|
18
|
+
export type { BuildRowTreeGroupingCriteria } from '../utils/tree/buildRowTree';
|
|
19
|
+
export { sortRowTree } from '../utils/tree/sortRowTree';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from '@mui/x-data-grid/internals';
|
|
2
|
+
export { DataGridProVirtualScroller } from '../components/DataGridProVirtualScroller';
|
|
3
|
+
export { DataGridProColumnHeaders } from '../components/DataGridProColumnHeaders';
|
|
4
|
+
export { useGridColumnResize, columnResizeStateInitializer } from '../hooks/features/columnResize/useGridColumnResize';
|
|
5
|
+
export { useGridColumnPinning, columnPinningStateInitializer } from '../hooks/features/columnPinning/useGridColumnPinning';
|
|
6
|
+
export { useGridColumnPinningPreProcessors } from '../hooks/features/columnPinning/useGridColumnPinningPreProcessors';
|
|
7
|
+
export { useGridColumnReorder, columnReorderStateInitializer } from '../hooks/features/columnReorder/useGridColumnReorder';
|
|
8
|
+
export { useGridDetailPanel, detailPanelStateInitializer } from '../hooks/features/detailPanel/useGridDetailPanel';
|
|
9
|
+
export { useGridDetailPanelCache } from '../hooks/features/detailPanel/useGridDetailPanelCache';
|
|
10
|
+
export { useGridDetailPanelPreProcessors } from '../hooks/features/detailPanel/useGridDetailPanelPreProcessors';
|
|
11
|
+
export { useGridInfiniteLoader } from '../hooks/features/infiniteLoader/useGridInfiniteLoader';
|
|
12
|
+
export { useGridRowReorder } from '../hooks/features/rowReorder/useGridRowReorder';
|
|
13
|
+
export { useGridRowReorderPreProcessors } from '../hooks/features/rowReorder/useGridRowReorderPreProcessors';
|
|
14
|
+
export { useGridTreeData } from '../hooks/features/treeData/useGridTreeData';
|
|
15
|
+
export { useGridTreeDataPreProcessors } from '../hooks/features/treeData/useGridTreeDataPreProcessors';
|
|
16
|
+
export { buildRowTree } from '../utils/tree/buildRowTree';
|
|
17
|
+
export { sortRowTree } from '../utils/tree/sortRowTree';
|
|
@@ -72,6 +72,11 @@ DataGridProRaw.propTypes = {
|
|
|
72
72
|
*/
|
|
73
73
|
autoPageSize: PropTypes.bool,
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Controls the modes of the cells.
|
|
77
|
+
*/
|
|
78
|
+
cellModesModel: PropTypes.object,
|
|
79
|
+
|
|
75
80
|
/**
|
|
76
81
|
* If `true`, the grid get a first column with a checkbox that allows to select rows.
|
|
77
82
|
* @default false
|
|
@@ -225,7 +230,7 @@ DataGridProRaw.propTypes = {
|
|
|
225
230
|
disableMultipleColumnsSorting: PropTypes.bool,
|
|
226
231
|
|
|
227
232
|
/**
|
|
228
|
-
* If `true`, multiple selection using the
|
|
233
|
+
* If `true`, multiple selection using the Ctrl or CMD key is disabled.
|
|
229
234
|
* @default false
|
|
230
235
|
*/
|
|
231
236
|
disableMultipleSelection: PropTypes.bool,
|
|
@@ -298,7 +303,9 @@ DataGridProRaw.propTypes = {
|
|
|
298
303
|
operatorValue: PropTypes.string,
|
|
299
304
|
value: PropTypes.any
|
|
300
305
|
})).isRequired,
|
|
301
|
-
linkOperator: PropTypes.oneOf(['and', 'or'])
|
|
306
|
+
linkOperator: PropTypes.oneOf(['and', 'or']),
|
|
307
|
+
quickFilterLogicOperator: PropTypes.oneOf(['and', 'or']),
|
|
308
|
+
quickFilterValues: PropTypes.array
|
|
302
309
|
}),
|
|
303
310
|
|
|
304
311
|
/**
|
|
@@ -430,6 +437,14 @@ DataGridProRaw.propTypes = {
|
|
|
430
437
|
*/
|
|
431
438
|
isRowSelectable: PropTypes.func,
|
|
432
439
|
|
|
440
|
+
/**
|
|
441
|
+
* If `true`, the selection model will retain selected rows that do not exist.
|
|
442
|
+
* Useful when using server side pagination and row selections need to be retained
|
|
443
|
+
* when changing pages.
|
|
444
|
+
* @default false
|
|
445
|
+
*/
|
|
446
|
+
keepNonExistentRowsSelected: PropTypes.bool,
|
|
447
|
+
|
|
433
448
|
/**
|
|
434
449
|
* If `true`, a loading overlay is displayed.
|
|
435
450
|
*/
|
|
@@ -517,6 +532,13 @@ DataGridProRaw.propTypes = {
|
|
|
517
532
|
*/
|
|
518
533
|
onCellKeyDown: PropTypes.func,
|
|
519
534
|
|
|
535
|
+
/**
|
|
536
|
+
* Callback fired when the `cellModesModel` prop changes.
|
|
537
|
+
* @param {GridCellModesModel} cellModesModel Object containig which cells are in "edit" mode.
|
|
538
|
+
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
539
|
+
*/
|
|
540
|
+
onCellModesModelChange: PropTypes.func,
|
|
541
|
+
|
|
520
542
|
/**
|
|
521
543
|
* Callback fired when a click event comes from a column header element.
|
|
522
544
|
* @param {GridColumnHeaderParams} params With all properties from [[GridColumnHeaderParams]].
|
|
@@ -740,6 +762,21 @@ DataGridProRaw.propTypes = {
|
|
|
740
762
|
*/
|
|
741
763
|
onRowGroupingModelChange: PropTypes.func,
|
|
742
764
|
|
|
765
|
+
/**
|
|
766
|
+
* Callback fired when the `rowModesModel` prop changes.
|
|
767
|
+
* @param {GridRowModesModel} rowModesModel Object containig which rows are in "edit" mode.
|
|
768
|
+
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
769
|
+
*/
|
|
770
|
+
onRowModesModelChange: PropTypes.func,
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* Callback fired when a row is being reordered.
|
|
774
|
+
* @param {GridRowOrderChangeParams} params With all properties from [[GridRowOrderChangeParams]].
|
|
775
|
+
* @param {MuiEvent<{}>} event The event object.
|
|
776
|
+
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
777
|
+
*/
|
|
778
|
+
onRowOrderChange: PropTypes.func,
|
|
779
|
+
|
|
743
780
|
/**
|
|
744
781
|
* Callback fired when scrolling to the bottom of the grid viewport.
|
|
745
782
|
* @param {GridRowScrollEndParams} params With all properties from [[GridRowScrollEndParams]].
|
|
@@ -846,6 +883,17 @@ DataGridProRaw.propTypes = {
|
|
|
846
883
|
*/
|
|
847
884
|
rowHeight: PropTypes.number,
|
|
848
885
|
|
|
886
|
+
/**
|
|
887
|
+
* Controls the modes of the rows.
|
|
888
|
+
*/
|
|
889
|
+
rowModesModel: PropTypes.object,
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* If `true`, the reordering of rows is enabled.
|
|
893
|
+
* @default false
|
|
894
|
+
*/
|
|
895
|
+
rowReordering: PropTypes.bool,
|
|
896
|
+
|
|
849
897
|
/**
|
|
850
898
|
* Set of rows of type [[GridRowsProp]].
|
|
851
899
|
*/
|
|
@@ -5,13 +5,15 @@ import { useGridColumnReorder, columnReorderStateInitializer } from '../hooks/fe
|
|
|
5
5
|
import { useGridColumnResize, columnResizeStateInitializer } from '../hooks/features/columnResize/useGridColumnResize';
|
|
6
6
|
import { useGridTreeData } from '../hooks/features/treeData/useGridTreeData';
|
|
7
7
|
import { useGridTreeDataPreProcessors } from '../hooks/features/treeData/useGridTreeDataPreProcessors';
|
|
8
|
-
import { useGridRowGrouping, rowGroupingStateInitializer } from '../hooks/features/rowGrouping/useGridRowGrouping';
|
|
9
|
-
import { useGridRowGroupingPreProcessors } from '../hooks/features/rowGrouping/useGridRowGroupingPreProcessors';
|
|
10
8
|
import { useGridColumnPinning, columnPinningStateInitializer } from '../hooks/features/columnPinning/useGridColumnPinning';
|
|
11
9
|
import { useGridColumnPinningPreProcessors } from '../hooks/features/columnPinning/useGridColumnPinningPreProcessors';
|
|
12
10
|
import { useGridDetailPanel, detailPanelStateInitializer } from '../hooks/features/detailPanel/useGridDetailPanel';
|
|
13
11
|
import { useGridDetailPanelCache } from '../hooks/features/detailPanel/useGridDetailPanelCache';
|
|
14
12
|
import { useGridDetailPanelPreProcessors } from '../hooks/features/detailPanel/useGridDetailPanelPreProcessors';
|
|
13
|
+
import { useGridRowReorder } from '../hooks/features/rowReorder/useGridRowReorder';
|
|
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';
|
|
15
17
|
export var useDataGridProComponent = function useDataGridProComponent(inputApiRef, props) {
|
|
16
18
|
var _props$experimentalFe, _props$experimentalFe2;
|
|
17
19
|
|
|
@@ -21,6 +23,7 @@ export var useDataGridProComponent = function useDataGridProComponent(inputApiRe
|
|
|
21
23
|
*/
|
|
22
24
|
|
|
23
25
|
useGridSelectionPreProcessors(apiRef, props);
|
|
26
|
+
useGridRowReorderPreProcessors(apiRef, props);
|
|
24
27
|
useGridRowGroupingPreProcessors(apiRef, props);
|
|
25
28
|
useGridTreeDataPreProcessors(apiRef, props);
|
|
26
29
|
useGridDetailPanelPreProcessors(apiRef, props); // The column pinning `hydrateColumns` pre-processor must be after every other `hydrateColumns` pre-processors
|
|
@@ -71,6 +74,7 @@ export var useDataGridProComponent = function useDataGridProComponent(inputApiRe
|
|
|
71
74
|
useGridColumnResize(apiRef, props);
|
|
72
75
|
useGridPagination(apiRef, props);
|
|
73
76
|
useGridRowsMeta(apiRef, props);
|
|
77
|
+
useGridRowReorder(apiRef, props);
|
|
74
78
|
useGridScroll(apiRef, props);
|
|
75
79
|
useGridInfiniteLoader(apiRef, props);
|
|
76
80
|
useGridColumnMenu(apiRef);
|
|
@@ -3,6 +3,7 @@ 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';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* The default values of `DataGridProPropsWithDefaultValue` to inject in the props of DataGridPro.
|
|
@@ -12,14 +13,16 @@ export var DATA_GRID_PRO_PROPS_DEFAULT_VALUES = _extends({}, DATA_GRID_PROPS_DEF
|
|
|
12
13
|
treeData: false,
|
|
13
14
|
defaultGroupingExpansionDepth: 0,
|
|
14
15
|
disableColumnPinning: false,
|
|
15
|
-
disableRowGrouping: false,
|
|
16
16
|
disableChildrenFiltering: false,
|
|
17
17
|
disableChildrenSorting: false,
|
|
18
|
-
|
|
18
|
+
rowReordering: false,
|
|
19
19
|
getDetailPanelHeight: function getDetailPanelHeight() {
|
|
20
20
|
return 500;
|
|
21
|
-
}
|
|
21
|
+
},
|
|
22
|
+
disableRowGrouping: false,
|
|
23
|
+
rowGroupingColumnMode: 'single'
|
|
22
24
|
});
|
|
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');
|
|
23
26
|
export var useDataGridProProps = function useDataGridProProps(inProps) {
|
|
24
27
|
var themedProps = useThemeProps({
|
|
25
28
|
props: inProps,
|
|
@@ -45,11 +48,23 @@ export var useDataGridProProps = function useDataGridProProps(inProps) {
|
|
|
45
48
|
});
|
|
46
49
|
return mergedComponents;
|
|
47
50
|
}, [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
|
+
|
|
48
63
|
return React.useMemo(function () {
|
|
49
|
-
var _themedProps$
|
|
64
|
+
var _themedProps$experime2;
|
|
50
65
|
|
|
51
66
|
return _extends({}, DATA_GRID_PRO_PROPS_DEFAULT_VALUES, themedProps, {
|
|
52
|
-
disableRowGrouping: themedProps.disableRowGrouping || !((_themedProps$
|
|
67
|
+
disableRowGrouping: themedProps.disableRowGrouping || !((_themedProps$experime2 = themedProps.experimentalFeatures) != null && _themedProps$experime2.rowGrouping),
|
|
53
68
|
localeText: localeText,
|
|
54
69
|
components: components,
|
|
55
70
|
signature: 'DataGridPro'
|
|
@@ -6,7 +6,7 @@ var _excluded = ["style", "className", "innerRef"];
|
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
8
8
|
import { styled, alpha } from '@mui/material/styles';
|
|
9
|
-
import { getDataGridUtilityClass, gridClasses, useGridSelector, useGridApiEventHandler, gridVisibleColumnFieldsSelector,
|
|
9
|
+
import { getDataGridUtilityClass, gridClasses, useGridSelector, useGridApiEventHandler, gridVisibleColumnFieldsSelector, GridColumnHeaderSeparatorSides } from '@mui/x-data-grid';
|
|
10
10
|
import { GridColumnHeaders, GridColumnHeadersInner, useGridColumnHeaders } from '@mui/x-data-grid/internals';
|
|
11
11
|
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
12
12
|
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
@@ -90,7 +90,7 @@ export var DataGridProColumnHeaders = /*#__PURE__*/React.forwardRef(function Dat
|
|
|
90
90
|
var newScrollbarSize = apiRef.current.windowRef.current.offsetWidth - apiRef.current.windowRef.current.clientWidth;
|
|
91
91
|
setScrollbarSize(newScrollbarSize);
|
|
92
92
|
}, [apiRef]);
|
|
93
|
-
useGridApiEventHandler(apiRef,
|
|
93
|
+
useGridApiEventHandler(apiRef, 'virtualScrollerContentSizeChange', handleContentSizeChange);
|
|
94
94
|
var pinnedColumns = useGridSelector(apiRef, gridPinnedColumnsSelector);
|
|
95
95
|
|
|
96
96
|
var _filterColumns = filterColumns(pinnedColumns, visibleColumnFields),
|
|
@@ -8,7 +8,7 @@ import * as React from 'react';
|
|
|
8
8
|
import { styled, alpha } from '@mui/material/styles';
|
|
9
9
|
import Box from '@mui/material/Box';
|
|
10
10
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
11
|
-
import { useGridSelector, getDataGridUtilityClass, gridClasses, gridVisibleColumnFieldsSelector, gridRowsMetaSelector, useGridApiEventHandler
|
|
11
|
+
import { useGridSelector, getDataGridUtilityClass, gridClasses, gridVisibleColumnFieldsSelector, gridRowsMetaSelector, useGridApiEventHandler } from '@mui/x-data-grid';
|
|
12
12
|
import { GridVirtualScroller, GridVirtualScrollerContent, GridVirtualScrollerRenderZone, useGridVirtualScroller } from '@mui/x-data-grid/internals';
|
|
13
13
|
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
14
14
|
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
@@ -78,7 +78,9 @@ var VirtualScrollerDetailPanels = styled('div', {
|
|
|
78
78
|
overridesResolver: function overridesResolver(props, styles) {
|
|
79
79
|
return styles.detailPanels;
|
|
80
80
|
}
|
|
81
|
-
})({
|
|
81
|
+
})({
|
|
82
|
+
position: 'relative'
|
|
83
|
+
});
|
|
82
84
|
var VirtualScrollerDetailPanel = styled(Box, {
|
|
83
85
|
name: 'MuiDataGrid',
|
|
84
86
|
slot: 'DetailPanel',
|
|
@@ -190,8 +192,9 @@ var DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGrid
|
|
|
190
192
|
updateRenderZonePosition(renderContext);
|
|
191
193
|
}
|
|
192
194
|
}, [renderContext, updateRenderZonePosition]);
|
|
193
|
-
useGridApiEventHandler(apiRef,
|
|
194
|
-
useGridApiEventHandler(apiRef,
|
|
195
|
+
useGridApiEventHandler(apiRef, 'columnWidthChange', refreshRenderZonePosition);
|
|
196
|
+
useGridApiEventHandler(apiRef, 'columnOrderChange', refreshRenderZonePosition);
|
|
197
|
+
useGridApiEventHandler(apiRef, 'rowOrderChange', refreshRenderZonePosition);
|
|
195
198
|
var leftRenderContext = renderContext && leftPinnedColumns.length > 0 ? _extends({}, renderContext, {
|
|
196
199
|
firstColumnIndex: 0,
|
|
197
200
|
lastColumnIndex: leftPinnedColumns.length
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
3
3
|
import IconButton from '@mui/material/IconButton';
|
|
4
4
|
import Box from '@mui/material/Box';
|
|
5
|
-
import { useGridSelector, gridFilteredDescendantCountLookupSelector, getDataGridUtilityClass
|
|
5
|
+
import { useGridSelector, gridFilteredDescendantCountLookupSelector, getDataGridUtilityClass } from '@mui/x-data-grid';
|
|
6
6
|
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
7
7
|
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -40,7 +40,7 @@ export var GridGroupingCriteriaCell = function GridGroupingCriteriaCell(props) {
|
|
|
40
40
|
event.stopPropagation();
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
apiRef.current.publishEvent(
|
|
43
|
+
apiRef.current.publishEvent('cellKeyDown', props, event);
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
var handleClick = function handleClick(event) {
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
4
|
+
import { gridRowTreeDepthSelector, gridSortModelSelector, useGridApiContext, useGridSelector, getDataGridUtilityClass, gridEditRowsStateSelector } from '@mui/x-data-grid';
|
|
5
|
+
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
|
|
9
|
+
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
10
|
+
var isDraggable = ownerState.isDraggable,
|
|
11
|
+
classes = ownerState.classes;
|
|
12
|
+
var slots = {
|
|
13
|
+
root: ['rowReorderCell', isDraggable && 'rowReorderCell--draggable'],
|
|
14
|
+
placeholder: ['rowReorderCellPlaceholder']
|
|
15
|
+
};
|
|
16
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
var GridRowReorderCell = function GridRowReorderCell(params) {
|
|
20
|
+
var apiRef = useGridApiContext();
|
|
21
|
+
var rootProps = useGridRootProps();
|
|
22
|
+
var sortModel = useGridSelector(apiRef, gridSortModelSelector);
|
|
23
|
+
var treeDepth = useGridSelector(apiRef, gridRowTreeDepthSelector);
|
|
24
|
+
var editRowsState = useGridSelector(apiRef, gridEditRowsStateSelector); // eslint-disable-next-line no-underscore-dangle
|
|
25
|
+
|
|
26
|
+
var cellValue = params.row.__reorder__ || params.id; // TODO: remove sortModel and treeDepth checks once row reorder is compatible
|
|
27
|
+
|
|
28
|
+
var isDraggable = !!rootProps.rowReordering && !sortModel.length && treeDepth === 1 && Object.keys(editRowsState).length === 0;
|
|
29
|
+
var ownerState = {
|
|
30
|
+
isDraggable: isDraggable,
|
|
31
|
+
classes: rootProps.classes
|
|
32
|
+
};
|
|
33
|
+
var classes = useUtilityClasses(ownerState);
|
|
34
|
+
var publish = React.useCallback(function (eventName, propHandler) {
|
|
35
|
+
return function (event) {
|
|
36
|
+
// Ignore portal
|
|
37
|
+
// The target is not an element when triggered by a Select inside the cell
|
|
38
|
+
// See https://github.com/mui/material-ui/issues/10534
|
|
39
|
+
if (event.target.nodeType === 1 && !event.currentTarget.contains(event.target)) {
|
|
40
|
+
return;
|
|
41
|
+
} // The row might have been deleted
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
if (!apiRef.current.getRow(params.row.id)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
apiRef.current.publishEvent(eventName, apiRef.current.getRowParams(params.row.id), event);
|
|
49
|
+
|
|
50
|
+
if (propHandler) {
|
|
51
|
+
propHandler(event);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}, [apiRef, params.row.id]);
|
|
55
|
+
var draggableEventHandlers = {
|
|
56
|
+
onDragStart: publish('rowDragStart'),
|
|
57
|
+
onDragOver: publish('rowDragOver'),
|
|
58
|
+
onDragEnd: publish('rowDragEnd')
|
|
59
|
+
};
|
|
60
|
+
return /*#__PURE__*/_jsxs("div", _extends({
|
|
61
|
+
className: classes.root,
|
|
62
|
+
draggable: isDraggable
|
|
63
|
+
}, draggableEventHandlers, {
|
|
64
|
+
children: [/*#__PURE__*/_jsx(rootProps.components.RowReorderIcon, {}), /*#__PURE__*/_jsx("div", {
|
|
65
|
+
className: classes.placeholder,
|
|
66
|
+
children: cellValue
|
|
67
|
+
})]
|
|
68
|
+
}));
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export { GridRowReorderCell };
|
|
72
|
+
export var renderRowReorderCell = function renderRowReorderCell(params) {
|
|
73
|
+
return /*#__PURE__*/_jsx(GridRowReorderCell, _extends({}, params));
|
|
74
|
+
};
|
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
4
4
|
import IconButton from '@mui/material/IconButton';
|
|
5
5
|
import Box from '@mui/material/Box';
|
|
6
|
-
import { useGridSelector, gridFilteredDescendantCountLookupSelector, getDataGridUtilityClass
|
|
6
|
+
import { useGridSelector, gridFilteredDescendantCountLookupSelector, getDataGridUtilityClass } from '@mui/x-data-grid';
|
|
7
7
|
import { isNavigationKey } from '@mui/x-data-grid/internals';
|
|
8
8
|
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
9
9
|
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
@@ -43,7 +43,7 @@ var GridTreeDataGroupingCell = function GridTreeDataGroupingCell(props) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
if (isNavigationKey(event.key) && !event.shiftKey) {
|
|
46
|
-
apiRef.current.publishEvent(
|
|
46
|
+
apiRef.current.publishEvent('cellNavigationKeyDown', props, event);
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
|