@mui/x-data-grid-pro 5.6.0 → 5.8.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 +187 -0
- package/DataGridPro/DataGridPro.d.ts +7 -1
- package/DataGridPro/DataGridPro.js +63 -20
- package/DataGridPro/useDataGridProComponent.js +29 -18
- package/DataGridPro/useDataGridProProps.d.ts +2 -1
- package/DataGridPro/useDataGridProProps.js +2 -2
- package/components/DataGridProColumnHeaders.js +10 -10
- package/components/DataGridProVirtualScroller.js +12 -23
- package/components/GridDetailPanelToggleCell.js +4 -3
- package/components/GridGroupingCriteriaCell.d.ts +2 -5
- package/components/GridGroupingCriteriaCell.js +2 -74
- package/components/GridTreeDataGroupingCell.js +4 -3
- package/components/index.d.ts +1 -0
- package/components/index.js +2 -1
- package/hooks/features/columnPinning/useGridColumnPinning.js +6 -6
- package/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +2 -2
- package/hooks/features/columnReorder/useGridColumnReorder.d.ts +2 -0
- package/hooks/features/columnReorder/useGridColumnReorder.js +7 -8
- package/hooks/features/columnResize/useGridColumnResize.d.ts +2 -0
- package/hooks/features/columnResize/useGridColumnResize.js +7 -7
- package/hooks/features/detailPanel/useGridDetailPanel.d.ts +2 -0
- package/hooks/features/detailPanel/useGridDetailPanel.js +10 -10
- package/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +2 -2
- package/hooks/features/infiniteLoader/useGridInfiniteLoader.js +2 -2
- package/hooks/features/rowGrouping/gridRowGroupingInterfaces.d.ts +6 -0
- package/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +5 -2
- package/hooks/features/rowGrouping/gridRowGroupingUtils.js +18 -3
- package/hooks/features/rowGrouping/useGridRowGrouping.js +46 -167
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +1 -1
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +131 -4
- package/hooks/features/treeData/gridTreeDataUtils.d.ts +1 -0
- package/hooks/features/treeData/gridTreeDataUtils.js +2 -0
- package/hooks/features/treeData/useGridTreeData.d.ts +1 -5
- package/hooks/features/treeData/useGridTreeData.js +3 -82
- package/hooks/features/treeData/useGridTreeDataPreProcessors.d.ts +1 -1
- package/hooks/features/treeData/useGridTreeDataPreProcessors.js +73 -4
- package/index.d.ts +2 -1
- package/index.js +3 -2
- package/legacy/DataGridPro/DataGridPro.js +63 -20
- package/legacy/DataGridPro/useDataGridProComponent.js +29 -18
- package/legacy/DataGridPro/useDataGridProProps.js +7 -2
- package/legacy/components/DataGridProColumnHeaders.js +10 -10
- package/legacy/components/DataGridProVirtualScroller.js +12 -22
- package/legacy/components/GridDetailPanelToggleCell.js +4 -3
- package/legacy/components/GridGroupingCriteriaCell.js +2 -74
- package/legacy/components/GridTreeDataGroupingCell.js +4 -3
- package/legacy/components/index.js +2 -1
- package/legacy/hooks/features/columnPinning/useGridColumnPinning.js +6 -6
- package/legacy/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +2 -2
- package/legacy/hooks/features/columnReorder/useGridColumnReorder.js +9 -10
- package/legacy/hooks/features/columnResize/useGridColumnResize.js +9 -9
- package/legacy/hooks/features/detailPanel/useGridDetailPanel.js +10 -10
- package/legacy/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +2 -2
- package/legacy/hooks/features/infiniteLoader/useGridInfiniteLoader.js +2 -2
- package/legacy/hooks/features/rowGrouping/gridRowGroupingUtils.js +19 -2
- package/legacy/hooks/features/rowGrouping/useGridRowGrouping.js +48 -172
- package/legacy/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +138 -4
- package/legacy/hooks/features/treeData/gridTreeDataUtils.js +2 -0
- package/legacy/hooks/features/treeData/useGridTreeData.js +3 -90
- package/legacy/hooks/features/treeData/useGridTreeDataPreProcessors.js +85 -4
- package/legacy/index.js +3 -2
- package/legacy/utils/releaseInfo.js +15 -0
- package/models/dataGridProProps.d.ts +9 -8
- package/models/gridGroupingColDefOverride.d.ts +2 -2
- package/models/gridGroupingValueGetterParams.d.ts +1 -1
- package/modern/DataGridPro/DataGridPro.js +63 -20
- package/modern/DataGridPro/useDataGridProComponent.js +27 -18
- package/modern/DataGridPro/useDataGridProProps.js +2 -2
- package/modern/components/DataGridProColumnHeaders.js +10 -10
- package/modern/components/DataGridProVirtualScroller.js +12 -23
- package/modern/components/GridDetailPanelToggleCell.js +4 -3
- package/modern/components/GridGroupingCriteriaCell.js +2 -74
- package/modern/components/GridTreeDataGroupingCell.js +4 -3
- package/modern/components/index.js +2 -1
- package/modern/hooks/features/columnPinning/useGridColumnPinning.js +6 -6
- package/modern/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +2 -2
- package/modern/hooks/features/columnReorder/useGridColumnReorder.js +7 -8
- package/modern/hooks/features/columnResize/useGridColumnResize.js +7 -7
- package/modern/hooks/features/detailPanel/useGridDetailPanel.js +9 -9
- package/modern/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +2 -2
- package/modern/hooks/features/infiniteLoader/useGridInfiniteLoader.js +2 -2
- package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +18 -3
- package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +46 -167
- package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +131 -4
- package/modern/hooks/features/treeData/gridTreeDataUtils.js +2 -0
- package/modern/hooks/features/treeData/useGridTreeData.js +3 -82
- package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +73 -4
- package/modern/index.js +3 -2
- package/modern/utils/releaseInfo.js +15 -0
- package/node/DataGridPro/DataGridPro.js +61 -19
- package/node/DataGridPro/useDataGridProComponent.js +26 -15
- package/node/DataGridPro/useDataGridProProps.js +2 -2
- package/node/components/DataGridProColumnHeaders.js +10 -10
- package/node/components/DataGridProVirtualScroller.js +11 -22
- package/node/components/GridDetailPanelToggleCell.js +4 -3
- package/node/components/GridGroupingCriteriaCell.js +1 -72
- package/node/components/GridTreeDataGroupingCell.js +4 -3
- package/node/components/index.js +13 -0
- package/node/hooks/features/columnPinning/useGridColumnPinning.js +5 -5
- package/node/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +1 -1
- package/node/hooks/features/columnReorder/useGridColumnReorder.js +10 -9
- package/node/hooks/features/columnResize/useGridColumnResize.js +9 -6
- package/node/hooks/features/detailPanel/useGridDetailPanel.js +13 -10
- package/node/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +1 -1
- package/node/hooks/features/infiniteLoader/useGridInfiniteLoader.js +1 -1
- package/node/hooks/features/rowGrouping/gridRowGroupingUtils.js +24 -5
- package/node/hooks/features/rowGrouping/useGridRowGrouping.js +42 -165
- package/node/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +134 -1
- package/node/hooks/features/treeData/gridTreeDataUtils.js +5 -2
- package/node/hooks/features/treeData/useGridTreeData.js +2 -91
- package/node/hooks/features/treeData/useGridTreeDataPreProcessors.js +75 -3
- package/node/index.js +23 -9
- package/node/utils/releaseInfo.js +25 -0
- package/package.json +5 -4
- package/typeOverloads/modules.d.ts +6 -6
- package/typeOverloads/reexports.d.ts +1 -1
- package/utils/releaseInfo.d.ts +1 -0
- package/utils/releaseInfo.js +15 -0
- package/utils/tree/buildRowTree.d.ts +3 -3
- package/components/Watermark.d.ts +0 -2
- package/components/Watermark.js +0 -43
- package/legacy/components/Watermark.js +0 -43
- package/modern/components/Watermark.js +0 -43
- package/node/components/Watermark.js +0 -56
|
@@ -6,7 +6,7 @@ import { styled, alpha } from '@mui/material/styles';
|
|
|
6
6
|
import Box from '@mui/material/Box';
|
|
7
7
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
8
8
|
import { useGridSelector, getDataGridUtilityClass, gridClasses, gridVisibleColumnFieldsSelector, gridRowsMetaSelector, useGridApiEventHandler, GridEvents } from '@mui/x-data-grid';
|
|
9
|
-
import {
|
|
9
|
+
import { GridVirtualScroller, GridVirtualScrollerContent, GridVirtualScrollerRenderZone, useGridVirtualScroller } from '@mui/x-data-grid/internals';
|
|
10
10
|
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
11
11
|
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
12
12
|
import { gridPinnedColumnsSelector, GridPinnedPosition } from '../hooks/features/columnPinning';
|
|
@@ -113,7 +113,6 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
113
113
|
|
|
114
114
|
const apiRef = useGridApiContext();
|
|
115
115
|
const rootProps = useGridRootProps();
|
|
116
|
-
const currentPage = useCurrentPageRows(apiRef, rootProps);
|
|
117
116
|
const visibleColumnFields = useGridSelector(apiRef, gridVisibleColumnFieldsSelector);
|
|
118
117
|
const expandedRowIds = useGridSelector(apiRef, gridDetailPanelExpandedRowIdsSelector);
|
|
119
118
|
const detailPanelsContent = useGridSelector(apiRef, gridDetailPanelExpandedRowsContentCacheSelector);
|
|
@@ -189,18 +188,6 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
189
188
|
const pinnedColumnsStyle = {
|
|
190
189
|
minHeight: contentProps.style.minHeight
|
|
191
190
|
};
|
|
192
|
-
const rowsLookup = React.useMemo(() => {
|
|
193
|
-
if (rootProps.getDetailPanelContent == null) {
|
|
194
|
-
return null;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return currentPage.rows.reduce((acc, {
|
|
198
|
-
id
|
|
199
|
-
}, index) => {
|
|
200
|
-
acc[id] = index;
|
|
201
|
-
return acc;
|
|
202
|
-
}, {});
|
|
203
|
-
}, [currentPage.rows, rootProps.getDetailPanelContent]);
|
|
204
191
|
|
|
205
192
|
const getDetailPanels = () => {
|
|
206
193
|
const panels = [];
|
|
@@ -216,12 +203,14 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
216
203
|
const id = uniqueExpandedRowIds[i];
|
|
217
204
|
const content = detailPanelsContent[id]; // Check if the id exists in the current page
|
|
218
205
|
|
|
219
|
-
const
|
|
206
|
+
const rowIndex = apiRef.current.getRowIndexRelativeToVisibleRows(id);
|
|
207
|
+
const exists = rowIndex !== undefined;
|
|
220
208
|
|
|
221
209
|
if ( /*#__PURE__*/React.isValidElement(content) && exists) {
|
|
222
210
|
const height = detailPanelsHeights[id];
|
|
223
|
-
const
|
|
224
|
-
const
|
|
211
|
+
const sizes = apiRef.current.unstable_getRowInternalSizes(id);
|
|
212
|
+
const spacingTop = sizes?.spacingTop || 0;
|
|
213
|
+
const top = rowsMeta.positions[rowIndex] + apiRef.current.unstable_getRowHeight(id) + spacingTop;
|
|
225
214
|
panels.push( /*#__PURE__*/_jsx(VirtualScrollerDetailPanel, {
|
|
226
215
|
style: {
|
|
227
216
|
top,
|
|
@@ -252,7 +241,11 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
252
241
|
maxLastColumn: leftRenderContext.lastColumnIndex,
|
|
253
242
|
availableSpace: 0
|
|
254
243
|
})
|
|
255
|
-
}),
|
|
244
|
+
}), /*#__PURE__*/_jsx(GridVirtualScrollerRenderZone, _extends({}, getRenderZoneProps(), {
|
|
245
|
+
children: getRows({
|
|
246
|
+
renderContext
|
|
247
|
+
})
|
|
248
|
+
})), rightRenderContext && /*#__PURE__*/_jsx(VirtualScrollerPinnedColumns, {
|
|
256
249
|
ref: rightColumns,
|
|
257
250
|
ownerState: {
|
|
258
251
|
side: GridPinnedPosition.right
|
|
@@ -265,11 +258,7 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
265
258
|
maxLastColumn: rightRenderContext.lastColumnIndex,
|
|
266
259
|
availableSpace: 0
|
|
267
260
|
})
|
|
268
|
-
}), /*#__PURE__*/_jsx(
|
|
269
|
-
children: getRows({
|
|
270
|
-
renderContext
|
|
271
|
-
})
|
|
272
|
-
})), detailPanels.length > 0 && /*#__PURE__*/_jsx(VirtualScrollerDetailPanels, {
|
|
261
|
+
}), detailPanels.length > 0 && /*#__PURE__*/_jsx(VirtualScrollerDetailPanels, {
|
|
273
262
|
className: classes.detailPanels,
|
|
274
263
|
children: detailPanels
|
|
275
264
|
})]
|
|
@@ -54,8 +54,9 @@ process.env.NODE_ENV !== "production" ? GridDetailPanelToggleCell.propTypes = {
|
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* GridApi that let you manipulate the grid.
|
|
57
|
+
* @deprecated Use the `apiRef` returned by `useGridApiContext` or `useGridApiRef` (only available in `@mui/x-data-grid-pro`)
|
|
57
58
|
*/
|
|
58
|
-
api: PropTypes.
|
|
59
|
+
api: PropTypes.any.isRequired,
|
|
59
60
|
|
|
60
61
|
/**
|
|
61
62
|
* The mode of the cell.
|
|
@@ -81,7 +82,7 @@ process.env.NODE_ENV !== "production" ? GridDetailPanelToggleCell.propTypes = {
|
|
|
81
82
|
* Get the cell value of a row and field.
|
|
82
83
|
* @param {GridRowId} id The row id.
|
|
83
84
|
* @param {string} field The field.
|
|
84
|
-
* @returns {
|
|
85
|
+
* @returns {any} The cell value.
|
|
85
86
|
* @deprecated Use `params.row` to directly access the fields you want instead.
|
|
86
87
|
*/
|
|
87
88
|
getValue: PropTypes.func.isRequired,
|
|
@@ -104,7 +105,7 @@ process.env.NODE_ENV !== "production" ? GridDetailPanelToggleCell.propTypes = {
|
|
|
104
105
|
/**
|
|
105
106
|
* The row model of the row that the current cell belongs to.
|
|
106
107
|
*/
|
|
107
|
-
row: PropTypes.
|
|
108
|
+
row: PropTypes.object.isRequired,
|
|
108
109
|
|
|
109
110
|
/**
|
|
110
111
|
* The node of the row that the current cell belongs to.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
4
3
|
import IconButton from '@mui/material/IconButton';
|
|
5
4
|
import Box from '@mui/material/Box';
|
|
@@ -20,7 +19,7 @@ const useUtilityClasses = ownerState => {
|
|
|
20
19
|
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
21
20
|
};
|
|
22
21
|
|
|
23
|
-
const GridGroupingCriteriaCell = props => {
|
|
22
|
+
export const GridGroupingCriteriaCell = props => {
|
|
24
23
|
const {
|
|
25
24
|
id,
|
|
26
25
|
field,
|
|
@@ -74,75 +73,4 @@ const GridGroupingCriteriaCell = props => {
|
|
|
74
73
|
children: [formattedValue === undefined ? rowNode.groupingKey : formattedValue, !hideDescendantCount && filteredDescendantCount > 0 ? ` (${filteredDescendantCount})` : '']
|
|
75
74
|
})]
|
|
76
75
|
});
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
process.env.NODE_ENV !== "production" ? GridGroupingCriteriaCell.propTypes = {
|
|
80
|
-
// ----------------------------- Warning --------------------------------
|
|
81
|
-
// | These PropTypes are generated from the TypeScript type definitions |
|
|
82
|
-
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
83
|
-
// ----------------------------------------------------------------------
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* GridApi that let you manipulate the grid.
|
|
87
|
-
*/
|
|
88
|
-
api: PropTypes.any.isRequired,
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* The mode of the cell.
|
|
92
|
-
*/
|
|
93
|
-
cellMode: PropTypes.oneOf(['edit', 'view']).isRequired,
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* The column of the row that the current cell belongs to.
|
|
97
|
-
*/
|
|
98
|
-
colDef: PropTypes.object.isRequired,
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* The column field of the cell that triggered the event.
|
|
102
|
-
*/
|
|
103
|
-
field: PropTypes.string.isRequired,
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* The cell value formatted with the column valueFormatter.
|
|
107
|
-
*/
|
|
108
|
-
formattedValue: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.object, PropTypes.string, PropTypes.bool]),
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Get the cell value of a row and field.
|
|
112
|
-
* @param {GridRowId} id The row id.
|
|
113
|
-
* @param {string} field The field.
|
|
114
|
-
* @returns {GridCellValue} The cell value.
|
|
115
|
-
*/
|
|
116
|
-
getValue: PropTypes.func.isRequired,
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* If true, the cell is the active element.
|
|
120
|
-
*/
|
|
121
|
-
hasFocus: PropTypes.bool.isRequired,
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* The grid row id.
|
|
125
|
-
*/
|
|
126
|
-
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* If true, the cell is editable.
|
|
130
|
-
*/
|
|
131
|
-
isEditable: PropTypes.bool,
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* The row model of the row that the current cell belongs to.
|
|
135
|
-
*/
|
|
136
|
-
row: PropTypes.object.isRequired,
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* the tabIndex value.
|
|
140
|
-
*/
|
|
141
|
-
tabIndex: PropTypes.oneOf([-1, 0]).isRequired,
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* The cell value, but if the column has valueGetter, use getValue.
|
|
145
|
-
*/
|
|
146
|
-
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.object, PropTypes.string, PropTypes.bool])
|
|
147
|
-
} : void 0;
|
|
148
|
-
export { GridGroupingCriteriaCell };
|
|
76
|
+
};
|
|
@@ -86,8 +86,9 @@ process.env.NODE_ENV !== "production" ? GridTreeDataGroupingCell.propTypes = {
|
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
88
|
* GridApi that let you manipulate the grid.
|
|
89
|
+
* @deprecated Use the `apiRef` returned by `useGridApiContext` or `useGridApiRef` (only available in `@mui/x-data-grid-pro`)
|
|
89
90
|
*/
|
|
90
|
-
api: PropTypes.
|
|
91
|
+
api: PropTypes.any.isRequired,
|
|
91
92
|
|
|
92
93
|
/**
|
|
93
94
|
* The mode of the cell.
|
|
@@ -113,7 +114,7 @@ process.env.NODE_ENV !== "production" ? GridTreeDataGroupingCell.propTypes = {
|
|
|
113
114
|
* Get the cell value of a row and field.
|
|
114
115
|
* @param {GridRowId} id The row id.
|
|
115
116
|
* @param {string} field The field.
|
|
116
|
-
* @returns {
|
|
117
|
+
* @returns {any} The cell value.
|
|
117
118
|
* @deprecated Use `params.row` to directly access the fields you want instead.
|
|
118
119
|
*/
|
|
119
120
|
getValue: PropTypes.func.isRequired,
|
|
@@ -137,7 +138,7 @@ process.env.NODE_ENV !== "production" ? GridTreeDataGroupingCell.propTypes = {
|
|
|
137
138
|
/**
|
|
138
139
|
* The row model of the row that the current cell belongs to.
|
|
139
140
|
*/
|
|
140
|
-
row: PropTypes.
|
|
141
|
+
row: PropTypes.object.isRequired,
|
|
141
142
|
|
|
142
143
|
/**
|
|
143
144
|
* The node of the row that the current cell belongs to.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
// Only export the variable and types that should be publicly exposed and re-exported from `@mui/x-data-grid-pro`
|
|
2
2
|
export * from './GridTreeDataGroupingCell';
|
|
3
|
-
export * from './GridColumnPinningMenuItems';
|
|
3
|
+
export * from './GridColumnPinningMenuItems';
|
|
4
|
+
export * from './GridDetailPanelToggleCell';
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import MuiDivider from '@mui/material/Divider';
|
|
4
4
|
import { useGridSelector, gridVisibleColumnDefinitionsSelector, gridColumnsTotalWidthSelector, gridColumnPositionsSelector, gridVisibleColumnFieldsSelector, gridClasses, GridEvents, useGridApiMethod, useGridApiEventHandler } from '@mui/x-data-grid';
|
|
5
|
-
import {
|
|
5
|
+
import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
|
|
6
6
|
import { GridColumnPinningMenuItems } from '../../../components/GridColumnPinningMenuItems';
|
|
7
7
|
import { GridPinnedPosition } from './gridColumnPinningInterface';
|
|
8
8
|
import { gridPinnedColumnsSelector } from './gridColumnPinningSelector';
|
|
@@ -175,11 +175,11 @@ export const useGridColumnPinning = (apiRef, props) => {
|
|
|
175
175
|
|
|
176
176
|
return params;
|
|
177
177
|
}, [apiRef]);
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
178
|
+
useGridRegisterPipeProcessor(apiRef, 'scrollToIndexes', calculateScrollLeft);
|
|
179
|
+
useGridRegisterPipeProcessor(apiRef, 'columnMenu', addColumnMenuButtons);
|
|
180
|
+
useGridRegisterPipeProcessor(apiRef, 'canBeReordered', checkIfCanBeReordered);
|
|
181
|
+
useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
182
|
+
useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
183
183
|
apiRef.current.unstable_updateControlState({
|
|
184
184
|
stateId: 'pinnedColumns',
|
|
185
185
|
propModel: props.pinnedColumns,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
|
|
4
4
|
import { gridPinnedColumnsSelector } from './gridColumnPinningSelector';
|
|
5
5
|
import { columnPinningStateInitializer } from './useGridColumnPinning';
|
|
6
6
|
import { filterColumns } from '../../../components/DataGridProVirtualScroller';
|
|
@@ -41,5 +41,5 @@ export const useGridColumnPinningPreProcessors = (apiRef, props) => {
|
|
|
41
41
|
all: [...leftPinnedColumns, ...centerColumns, ...rightPinnedColumns]
|
|
42
42
|
});
|
|
43
43
|
}, [disableColumnPinning, pinnedColumns]);
|
|
44
|
-
|
|
44
|
+
useGridRegisterPipeProcessor(apiRef, 'hydrateColumns', reorderPinnedColumns);
|
|
45
45
|
};
|
|
@@ -2,7 +2,6 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
4
4
|
import { useGridApiEventHandler, getDataGridUtilityClass, GridEvents, useGridLogger } from '@mui/x-data-grid';
|
|
5
|
-
import { useGridStateInit } from '@mui/x-data-grid/internals';
|
|
6
5
|
import { gridColumnReorderDragColSelector } from './columnReorderSelector';
|
|
7
6
|
const CURSOR_MOVE_DIRECTION_LEFT = 'left';
|
|
8
7
|
const CURSOR_MOVE_DIRECTION_RIGHT = 'right';
|
|
@@ -22,19 +21,19 @@ const useUtilityClasses = ownerState => {
|
|
|
22
21
|
};
|
|
23
22
|
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
24
23
|
};
|
|
24
|
+
|
|
25
|
+
export const columnReorderStateInitializer = state => _extends({}, state, {
|
|
26
|
+
columnReorder: {
|
|
27
|
+
dragCol: ''
|
|
28
|
+
}
|
|
29
|
+
});
|
|
25
30
|
/**
|
|
26
31
|
* Only available in DataGridPro
|
|
27
32
|
* @requires useGridColumns (method)
|
|
28
33
|
*/
|
|
29
34
|
|
|
30
|
-
|
|
31
35
|
export const useGridColumnReorder = (apiRef, props) => {
|
|
32
36
|
const logger = useGridLogger(apiRef, 'useGridColumnReorder');
|
|
33
|
-
useGridStateInit(apiRef, state => _extends({}, state, {
|
|
34
|
-
columnReorder: {
|
|
35
|
-
dragCol: ''
|
|
36
|
-
}
|
|
37
|
-
}));
|
|
38
37
|
const dragColNode = React.useRef(null);
|
|
39
38
|
const cursorPosition = React.useRef({
|
|
40
39
|
x: 0,
|
|
@@ -117,7 +116,7 @@ export const useGridColumnReorder = (apiRef, props) => {
|
|
|
117
116
|
canBeReordered = targetColIndex < visibleColumns.length - 1 && !visibleColumns[targetColIndex + 1].disableReorder;
|
|
118
117
|
}
|
|
119
118
|
|
|
120
|
-
const canBeReorderedProcessed = apiRef.current.
|
|
119
|
+
const canBeReorderedProcessed = apiRef.current.unstable_applyPipeProcessors('canBeReordered', canBeReordered, {
|
|
121
120
|
targetIndex: targetColVisibleIndex
|
|
122
121
|
});
|
|
123
122
|
|
|
@@ -2,7 +2,7 @@ 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
4
|
import { GridEvents, gridClasses, GridColumnHeaderSeparatorSides, useGridApiEventHandler, useGridApiOptionHandler, useGridNativeEventListener, useGridLogger } from '@mui/x-data-grid';
|
|
5
|
-
import {
|
|
5
|
+
import { clamp, findParentElementFromClassName } from '@mui/x-data-grid/internals';
|
|
6
6
|
import { findGridCellElementsFromCol, getFieldFromHeaderElem, findHeaderElementFromField } from '../../../utils/domUtils';
|
|
7
7
|
// TODO: remove support for Safari < 13.
|
|
8
8
|
// https://caniuse.com/#search=touch-action
|
|
@@ -73,20 +73,20 @@ function computeOffsetToSeparator(clickX, columnBounds, separatorSide) {
|
|
|
73
73
|
function getSeparatorSide(element) {
|
|
74
74
|
return element.classList.contains(gridClasses['columnSeparator--sideRight']) ? GridColumnHeaderSeparatorSides.Right : GridColumnHeaderSeparatorSides.Left;
|
|
75
75
|
}
|
|
76
|
+
|
|
77
|
+
export const columnResizeStateInitializer = state => _extends({}, state, {
|
|
78
|
+
columnResize: {
|
|
79
|
+
resizingColumnField: ''
|
|
80
|
+
}
|
|
81
|
+
});
|
|
76
82
|
/**
|
|
77
83
|
* Only available in DataGridPro
|
|
78
84
|
* @requires useGridColumns (method, event)
|
|
79
85
|
* TODO: improve experience for last column
|
|
80
86
|
*/
|
|
81
87
|
|
|
82
|
-
|
|
83
88
|
export const useGridColumnResize = (apiRef, props) => {
|
|
84
89
|
const logger = useGridLogger(apiRef, 'useGridColumnResize');
|
|
85
|
-
useGridStateInit(apiRef, state => _extends({}, state, {
|
|
86
|
-
columnResize: {
|
|
87
|
-
resizingColumnField: ''
|
|
88
|
-
}
|
|
89
|
-
}));
|
|
90
90
|
const colDefRef = React.useRef();
|
|
91
91
|
const colElementRef = React.useRef();
|
|
92
92
|
const colCellElementsRef = React.useRef(); // To improve accessibility, the separator has padding on both sides.
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { GridEvents, useGridSelector, useGridApiEventHandler, useGridApiMethod } from '@mui/x-data-grid';
|
|
4
|
-
import {
|
|
4
|
+
import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
|
|
5
5
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from './gridDetailPanelToggleColDef';
|
|
6
6
|
import { gridDetailPanelExpandedRowIdsSelector, gridDetailPanelExpandedRowsContentCacheSelector, gridDetailPanelExpandedRowsHeightCacheSelector } from './gridDetailPanelSelector';
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
});
|
|
7
|
+
export const detailPanelStateInitializer = (state, props) => {
|
|
8
|
+
return _extends({}, state, {
|
|
9
|
+
detailPanel: {
|
|
10
|
+
expandedRowIds: props.detailPanelExpandedRowIds ?? props.initialState?.detailPanel?.expandedRowIds ?? []
|
|
11
|
+
}
|
|
14
12
|
});
|
|
13
|
+
};
|
|
14
|
+
export const useGridDetailPanel = (apiRef, props) => {
|
|
15
15
|
const expandedRowIds = useGridSelector(apiRef, gridDetailPanelExpandedRowIdsSelector);
|
|
16
16
|
const contentCache = useGridSelector(apiRef, gridDetailPanelExpandedRowsContentCacheSelector);
|
|
17
17
|
const handleCellClick = React.useCallback((params, event) => {
|
|
@@ -54,7 +54,7 @@ export const useGridDetailPanel = (apiRef, props) => {
|
|
|
54
54
|
|
|
55
55
|
});
|
|
56
56
|
}, [apiRef, expandedRowIds]);
|
|
57
|
-
|
|
57
|
+
useGridRegisterPipeProcessor(apiRef, 'rowHeight', addDetailHeight);
|
|
58
58
|
apiRef.current.unstable_updateControlState({
|
|
59
59
|
stateId: 'detailPanels',
|
|
60
60
|
propModel: props.detailPanelExpandedRowIds,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
|
|
3
3
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD, GRID_DETAIL_PANEL_TOGGLE_COL_DEF } from './gridDetailPanelToggleColDef';
|
|
4
4
|
export const useGridDetailPanelPreProcessors = (apiRef, props) => {
|
|
5
5
|
const addToggleColumn = React.useCallback(columnsState => {
|
|
@@ -24,5 +24,5 @@ export const useGridDetailPanelPreProcessors = (apiRef, props) => {
|
|
|
24
24
|
columnsState.lookup[GRID_DETAIL_PANEL_TOGGLE_FIELD] = GRID_DETAIL_PANEL_TOGGLE_COL_DEF;
|
|
25
25
|
return columnsState;
|
|
26
26
|
}, [props.getDetailPanelContent]);
|
|
27
|
-
|
|
27
|
+
useGridRegisterPipeProcessor(apiRef, 'hydrateColumns', addToggleColumn);
|
|
28
28
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useGridSelector, GridEvents, useGridApiEventHandler, useGridApiOptionHandler, gridVisibleColumnDefinitionsSelector, gridRowsMetaSelector } from '@mui/x-data-grid';
|
|
3
|
-
import {
|
|
3
|
+
import { useGridVisibleRows } from '@mui/x-data-grid/internals';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Only available in DataGridPro
|
|
@@ -10,7 +10,7 @@ import { useCurrentPageRows } from '@mui/x-data-grid/internals';
|
|
|
10
10
|
*/
|
|
11
11
|
export const useGridInfiniteLoader = (apiRef, props) => {
|
|
12
12
|
const visibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
|
|
13
|
-
const currentPage =
|
|
13
|
+
const currentPage = useGridVisibleRows(apiRef, props);
|
|
14
14
|
const rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
|
|
15
15
|
const contentHeight = Math.max(rowsMeta.currentPageTotalHeight, 1);
|
|
16
16
|
const isInScrollBottomArea = React.useRef(false);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { gridRowGroupingSanitizedModelSelector } from './gridRowGroupingSelector';
|
|
2
3
|
export const GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD = '__row_group_by_columns_group__';
|
|
3
|
-
export const
|
|
4
|
+
export const ROW_GROUPING_STRATEGY = 'grouping-columns';
|
|
4
5
|
export const getRowGroupingFieldFromGroupingCriteria = groupingCriteria => {
|
|
5
6
|
if (groupingCriteria === null) {
|
|
6
7
|
return GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD;
|
|
@@ -108,7 +109,7 @@ export const filterRowTreeFromGroupingColumns = params => {
|
|
|
108
109
|
export const getColDefOverrides = (groupingColDefProp, fields) => {
|
|
109
110
|
if (typeof groupingColDefProp === 'function') {
|
|
110
111
|
return groupingColDefProp({
|
|
111
|
-
groupingName:
|
|
112
|
+
groupingName: ROW_GROUPING_STRATEGY,
|
|
112
113
|
fields
|
|
113
114
|
});
|
|
114
115
|
}
|
|
@@ -119,4 +120,18 @@ export const mergeStateWithRowGroupingModel = rowGroupingModel => state => _exte
|
|
|
119
120
|
rowGrouping: _extends({}, state.rowGrouping, {
|
|
120
121
|
model: rowGroupingModel
|
|
121
122
|
})
|
|
122
|
-
});
|
|
123
|
+
});
|
|
124
|
+
export const setStrategyAvailability = (apiRef, disableRowGrouping) => {
|
|
125
|
+
let isAvailable;
|
|
126
|
+
|
|
127
|
+
if (disableRowGrouping) {
|
|
128
|
+
isAvailable = () => false;
|
|
129
|
+
} else {
|
|
130
|
+
isAvailable = () => {
|
|
131
|
+
const rowGroupingSanitizedModel = gridRowGroupingSanitizedModelSelector(apiRef);
|
|
132
|
+
return rowGroupingSanitizedModel.length > 0;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
apiRef.current.unstable_setStrategyAvailability('rowTree', ROW_GROUPING_STRATEGY, isAvailable);
|
|
137
|
+
};
|