@mui/x-data-grid 8.18.0 → 8.20.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 +175 -0
- package/DataGrid/useDataGridComponent.js +4 -3
- package/components/GridRow.js +5 -2
- package/components/GridRowDragAndDropOverlay.d.ts +7 -0
- package/components/GridRowDragAndDropOverlay.js +73 -0
- package/components/cell/GridActionsCell.d.ts +9 -0
- package/components/cell/GridActionsCell.js +54 -34
- package/components/cell/GridBooleanCell.js +0 -10
- package/components/cell/GridCell.js +4 -10
- package/components/columnHeaders/GridColumnHeaderItem.js +2 -2
- package/components/columnSelection/GridCellCheckboxRenderer.js +37 -22
- package/components/containers/GridRootStyles.js +17 -40
- package/components/toolbarV8/Toolbar.js +1 -1
- package/components/virtualization/GridVirtualScrollbar.d.ts +1 -0
- package/components/virtualization/GridVirtualScrollbar.js +13 -8
- package/components/virtualization/GridVirtualScroller.js +2 -1
- package/components/virtualization/GridVirtualScrollerRenderZone.js +1 -1
- package/constants/dataGridPropsDefaultValues.js +2 -1
- package/constants/gridClasses.d.ts +0 -8
- package/constants/gridClasses.js +1 -1
- package/esm/DataGrid/useDataGridComponent.js +5 -4
- package/esm/components/GridRow.js +5 -2
- package/esm/components/GridRowDragAndDropOverlay.d.ts +7 -0
- package/esm/components/GridRowDragAndDropOverlay.js +66 -0
- package/esm/components/cell/GridActionsCell.d.ts +9 -0
- package/esm/components/cell/GridActionsCell.js +55 -34
- package/esm/components/cell/GridBooleanCell.js +0 -10
- package/esm/components/cell/GridCell.js +4 -10
- package/esm/components/columnHeaders/GridColumnHeaderItem.js +2 -2
- package/esm/components/columnSelection/GridCellCheckboxRenderer.js +37 -22
- package/esm/components/containers/GridRootStyles.js +17 -40
- package/esm/components/toolbarV8/Toolbar.js +1 -1
- package/esm/components/virtualization/GridVirtualScrollbar.d.ts +1 -0
- package/esm/components/virtualization/GridVirtualScrollbar.js +12 -7
- package/esm/components/virtualization/GridVirtualScroller.js +2 -1
- package/esm/components/virtualization/GridVirtualScrollerRenderZone.js +1 -1
- package/esm/constants/dataGridPropsDefaultValues.js +2 -1
- package/esm/constants/gridClasses.d.ts +0 -8
- package/esm/constants/gridClasses.js +1 -1
- package/esm/hooks/core/gridPropsSelectors.d.ts +2 -1
- package/esm/hooks/core/gridPropsSelectors.js +3 -0
- package/esm/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +4 -3
- package/esm/hooks/core/useGridProps.js +8 -2
- package/esm/hooks/core/useGridVirtualizer.d.ts +80 -6
- package/esm/hooks/core/useGridVirtualizer.js +27 -12
- package/esm/hooks/features/columnGrouping/useGridColumnGrouping.js +6 -1
- package/esm/hooks/features/columnMenu/useGridColumnMenu.js +14 -4
- package/esm/hooks/features/columns/useGridColumnSpanning.js +9 -4
- package/esm/hooks/features/dataSource/useGridDataSourceBase.js +2 -2
- package/esm/hooks/features/dimensions/useGridDimensions.js +12 -6
- package/esm/hooks/features/editing/useGridCellEditing.js +1 -1
- package/esm/hooks/features/editing/useGridRowEditing.js +1 -1
- package/esm/hooks/features/export/serializers/csvSerializer.js +2 -4
- package/esm/hooks/features/export/useGridPrintExport.js +18 -18
- package/esm/hooks/features/filter/gridFilterUtils.js +5 -11
- package/esm/hooks/features/filter/index.d.ts +1 -1
- package/esm/hooks/features/filter/index.js +1 -1
- package/esm/hooks/features/filter/useGridFilter.d.ts +1 -1
- package/esm/hooks/features/filter/useGridFilter.js +3 -1
- package/esm/hooks/features/focus/useGridFocus.js +0 -1
- package/esm/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
- package/esm/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +189 -25
- package/esm/hooks/features/pagination/useGridPaginationMeta.js +3 -3
- package/esm/hooks/features/pagination/useGridPaginationModel.js +7 -4
- package/esm/hooks/features/pagination/useGridRowCount.js +31 -15
- package/esm/hooks/features/rowReorder/gridRowReorderInterfaces.d.ts +19 -0
- package/esm/hooks/features/rowReorder/gridRowReorderSelector.d.ts +20 -1
- package/esm/hooks/features/rowReorder/gridRowReorderSelector.js +19 -1
- package/esm/hooks/features/rowSelection/useGridRowSelection.js +17 -8
- package/esm/hooks/features/rowSelection/utils.d.ts +1 -0
- package/esm/hooks/features/rowSelection/utils.js +17 -4
- package/esm/hooks/features/rows/useGridRowSpanning.js +23 -60
- package/esm/hooks/features/rows/useGridRows.js +3 -1
- package/esm/hooks/features/rows/useGridRowsOverridableMethods.d.ts +1 -0
- package/esm/hooks/features/rows/useGridRowsOverridableMethods.js +57 -7
- package/esm/hooks/features/scroll/useGridScroll.js +2 -3
- package/esm/hooks/features/sorting/gridSortingUtils.js +1 -3
- package/esm/hooks/features/sorting/useGridSorting.d.ts +1 -1
- package/esm/hooks/features/sorting/useGridSorting.js +3 -1
- package/esm/hooks/features/virtualization/useGridVirtualization.js +24 -5
- package/esm/hooks/utils/useGridEvent.js +6 -2
- package/esm/hooks/utils/useGridSelector.js +2 -4
- package/esm/hooks/utils/useRunOncePerLoop.d.ts +4 -1
- package/esm/hooks/utils/useRunOncePerLoop.js +28 -18
- package/esm/index.js +1 -1
- package/esm/internals/index.d.ts +5 -4
- package/esm/internals/index.js +3 -3
- package/esm/material/index.js +1 -4
- package/esm/models/api/gridRowApi.d.ts +14 -1
- package/esm/models/api/index.d.ts +1 -1
- package/esm/models/api/index.js +0 -1
- package/esm/models/colDef/gridColDef.d.ts +14 -0
- package/esm/models/configuration/gridConfiguration.d.ts +2 -2
- package/esm/models/configuration/gridRowConfiguration.d.ts +6 -5
- package/esm/models/events/gridEventLookup.d.ts +5 -0
- package/esm/models/gridStateCommunity.d.ts +1 -1
- package/esm/models/params/gridCellParams.d.ts +0 -10
- package/esm/models/props/DataGridProps.d.ts +13 -6
- package/esm/utils/keyboardUtils.d.ts +1 -8
- package/esm/utils/keyboardUtils.js +0 -7
- package/hooks/core/gridPropsSelectors.d.ts +2 -1
- package/hooks/core/gridPropsSelectors.js +4 -1
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +4 -3
- package/hooks/core/useGridProps.js +8 -2
- package/hooks/core/useGridVirtualizer.d.ts +80 -6
- package/hooks/core/useGridVirtualizer.js +26 -11
- package/hooks/features/columnGrouping/useGridColumnGrouping.js +6 -1
- package/hooks/features/columnMenu/useGridColumnMenu.js +14 -4
- package/hooks/features/columns/useGridColumnSpanning.js +9 -4
- package/hooks/features/dataSource/useGridDataSourceBase.js +2 -2
- package/hooks/features/dimensions/useGridDimensions.js +12 -6
- package/hooks/features/editing/useGridCellEditing.js +1 -1
- package/hooks/features/editing/useGridRowEditing.js +1 -1
- package/hooks/features/export/serializers/csvSerializer.js +2 -4
- package/hooks/features/export/useGridPrintExport.js +18 -18
- package/hooks/features/filter/gridFilterUtils.js +5 -11
- package/hooks/features/filter/index.d.ts +1 -1
- package/hooks/features/filter/index.js +6 -0
- package/hooks/features/filter/useGridFilter.d.ts +1 -1
- package/hooks/features/filter/useGridFilter.js +3 -1
- package/hooks/features/focus/useGridFocus.js +0 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +189 -25
- package/hooks/features/pagination/useGridPaginationMeta.js +2 -2
- package/hooks/features/pagination/useGridPaginationModel.js +7 -4
- package/hooks/features/pagination/useGridRowCount.js +30 -14
- package/hooks/features/rowReorder/gridRowReorderInterfaces.d.ts +19 -0
- package/hooks/features/rowReorder/gridRowReorderSelector.d.ts +20 -1
- package/hooks/features/rowReorder/gridRowReorderSelector.js +20 -2
- package/hooks/features/rowSelection/useGridRowSelection.js +17 -8
- package/hooks/features/rowSelection/utils.d.ts +1 -0
- package/hooks/features/rowSelection/utils.js +16 -3
- package/hooks/features/rows/useGridRowSpanning.js +23 -60
- package/hooks/features/rows/useGridRows.js +3 -1
- package/hooks/features/rows/useGridRowsOverridableMethods.d.ts +1 -0
- package/hooks/features/rows/useGridRowsOverridableMethods.js +57 -7
- package/hooks/features/scroll/useGridScroll.js +2 -3
- package/hooks/features/sorting/gridSortingUtils.js +1 -3
- package/hooks/features/sorting/useGridSorting.d.ts +1 -1
- package/hooks/features/sorting/useGridSorting.js +3 -1
- package/hooks/features/virtualization/useGridVirtualization.js +24 -5
- package/hooks/utils/useGridEvent.js +6 -2
- package/hooks/utils/useGridSelector.js +2 -4
- package/hooks/utils/useRunOncePerLoop.d.ts +4 -1
- package/hooks/utils/useRunOncePerLoop.js +27 -18
- package/index.js +1 -1
- package/internals/index.d.ts +5 -4
- package/internals/index.js +16 -9
- package/material/index.js +1 -4
- package/models/api/gridRowApi.d.ts +14 -1
- package/models/api/index.d.ts +1 -1
- package/models/api/index.js +0 -11
- package/models/colDef/gridColDef.d.ts +14 -0
- package/models/configuration/gridConfiguration.d.ts +2 -2
- package/models/configuration/gridRowConfiguration.d.ts +6 -5
- package/models/events/gridEventLookup.d.ts +5 -0
- package/models/gridStateCommunity.d.ts +1 -1
- package/models/params/gridCellParams.d.ts +0 -10
- package/models/props/DataGridProps.d.ts +13 -6
- package/package.json +3 -3
- package/utils/keyboardUtils.d.ts +1 -8
- package/utils/keyboardUtils.js +1 -13
|
@@ -24,6 +24,16 @@ const columnMenuStateInitializer = state => (0, _extends2.default)({}, state, {
|
|
|
24
24
|
exports.columnMenuStateInitializer = columnMenuStateInitializer;
|
|
25
25
|
const useGridColumnMenu = apiRef => {
|
|
26
26
|
const logger = (0, _utils.useGridLogger)(apiRef, 'useGridColumnMenu');
|
|
27
|
+
const subscriptionRefs = React.useRef({});
|
|
28
|
+
const unsubscribeFromScrollChange = React.useCallback(() => {
|
|
29
|
+
subscriptionRefs.current.wheel?.();
|
|
30
|
+
subscriptionRefs.current.touchMove?.();
|
|
31
|
+
}, []);
|
|
32
|
+
const subscribeToScrollChange = React.useCallback(() => {
|
|
33
|
+
unsubscribeFromScrollChange();
|
|
34
|
+
subscriptionRefs.current.wheel = apiRef.current.subscribeEvent('virtualScrollerWheel', apiRef.current.hideColumnMenu);
|
|
35
|
+
subscriptionRefs.current.touchMove = apiRef.current.subscribeEvent('virtualScrollerTouchMove', apiRef.current.hideColumnMenu);
|
|
36
|
+
}, [apiRef, unsubscribeFromScrollChange]);
|
|
27
37
|
|
|
28
38
|
/**
|
|
29
39
|
* API METHODS
|
|
@@ -41,6 +51,7 @@ const useGridColumnMenu = apiRef => {
|
|
|
41
51
|
return state;
|
|
42
52
|
}
|
|
43
53
|
logger.debug('Opening Column Menu');
|
|
54
|
+
subscribeToScrollChange();
|
|
44
55
|
return (0, _extends2.default)({}, state, {
|
|
45
56
|
columnMenu: {
|
|
46
57
|
open: true,
|
|
@@ -50,7 +61,7 @@ const useGridColumnMenu = apiRef => {
|
|
|
50
61
|
});
|
|
51
62
|
apiRef.current.hidePreferences();
|
|
52
63
|
}
|
|
53
|
-
}, [apiRef, logger]);
|
|
64
|
+
}, [apiRef, logger, subscribeToScrollChange]);
|
|
54
65
|
const hideColumnMenu = React.useCallback(() => {
|
|
55
66
|
const columnMenuState = (0, _columnMenuSelector.gridColumnMenuSelector)(apiRef);
|
|
56
67
|
if (columnMenuState.field) {
|
|
@@ -86,12 +97,13 @@ const useGridColumnMenu = apiRef => {
|
|
|
86
97
|
if (shouldUpdate) {
|
|
87
98
|
apiRef.current.setState(state => {
|
|
88
99
|
logger.debug('Hiding Column Menu');
|
|
100
|
+
unsubscribeFromScrollChange();
|
|
89
101
|
return (0, _extends2.default)({}, state, {
|
|
90
102
|
columnMenu: newState
|
|
91
103
|
});
|
|
92
104
|
});
|
|
93
105
|
}
|
|
94
|
-
}, [apiRef, logger]);
|
|
106
|
+
}, [apiRef, logger, unsubscribeFromScrollChange]);
|
|
95
107
|
const toggleColumnMenu = React.useCallback(field => {
|
|
96
108
|
logger.debug('Toggle Column Menu');
|
|
97
109
|
const columnMenu = (0, _columnMenuSelector.gridColumnMenuSelector)(apiRef);
|
|
@@ -108,7 +120,5 @@ const useGridColumnMenu = apiRef => {
|
|
|
108
120
|
};
|
|
109
121
|
(0, _utils.useGridApiMethod)(apiRef, columnMenuApi, 'public');
|
|
110
122
|
(0, _utils.useGridEvent)(apiRef, 'columnResizeStart', hideColumnMenu);
|
|
111
|
-
(0, _utils.useGridEvent)(apiRef, 'virtualScrollerWheel', apiRef.current.hideColumnMenu);
|
|
112
|
-
(0, _utils.useGridEvent)(apiRef, 'virtualScrollerTouchMove', apiRef.current.hideColumnMenu);
|
|
113
123
|
};
|
|
114
124
|
exports.useGridColumnMenu = useGridColumnMenu;
|
|
@@ -11,10 +11,15 @@ var _useGridEvent = require("../../utils/useGridEvent");
|
|
|
11
11
|
* @requires useGridParamsApi (method)
|
|
12
12
|
*/
|
|
13
13
|
const useGridColumnSpanning = apiRef => {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
14
|
+
const resetColSpan = () => {
|
|
15
|
+
return apiRef.current.virtualizer.api.resetColSpan();
|
|
16
|
+
};
|
|
17
|
+
const getCellColSpanInfo = (...params) => {
|
|
18
|
+
return apiRef.current.virtualizer.api.getCellColSpanInfo(...params);
|
|
19
|
+
};
|
|
20
|
+
const calculateColSpan = (...params) => {
|
|
21
|
+
apiRef.current.virtualizer.api.calculateColSpan(...params);
|
|
22
|
+
};
|
|
18
23
|
const columnSpanningPublicApi = {
|
|
19
24
|
unstable_getCellColSpanInfo: getCellColSpanInfo
|
|
20
25
|
};
|
|
@@ -122,7 +122,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
122
122
|
params: fetchParams,
|
|
123
123
|
cause: originalError
|
|
124
124
|
}));
|
|
125
|
-
} else
|
|
125
|
+
} else {
|
|
126
126
|
(0, _warning.warnOnce)(['MUI X: A call to `dataSource.getRows()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'], 'error');
|
|
127
127
|
}
|
|
128
128
|
}
|
|
@@ -177,7 +177,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
177
177
|
params,
|
|
178
178
|
cause: errorThrown
|
|
179
179
|
}));
|
|
180
|
-
} else
|
|
180
|
+
} else {
|
|
181
181
|
(0, _warning.warnOnce)(['MUI X: A call to `dataSource.updateRow()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'], 'error');
|
|
182
182
|
}
|
|
183
183
|
throw errorThrown; // Let the caller handle the error further
|
|
@@ -52,8 +52,10 @@ const EMPTY_DIMENSIONS = {
|
|
|
52
52
|
const dimensionsStateInitializer = (state, props, apiRef) => {
|
|
53
53
|
const dimensions = EMPTY_DIMENSIONS;
|
|
54
54
|
const density = (0, _density.gridDensityFactorSelector)(apiRef);
|
|
55
|
+
const dimensionsWithStatic = (0, _extends2.default)({}, dimensions, getStaticDimensions(props, apiRef, density, (0, _columns.gridVisiblePinnedColumnDefinitionsSelector)(apiRef)));
|
|
56
|
+
apiRef.current.store.state.dimensions = dimensionsWithStatic;
|
|
55
57
|
return (0, _extends2.default)({}, state, {
|
|
56
|
-
dimensions:
|
|
58
|
+
dimensions: dimensionsWithStatic
|
|
57
59
|
});
|
|
58
60
|
};
|
|
59
61
|
exports.dimensionsStateInitializer = dimensionsStateInitializer;
|
|
@@ -65,16 +67,17 @@ const columnsTotalWidthSelector = (0, _createSelector.createSelector)(_columns.g
|
|
|
65
67
|
return (0, _roundToDecimalPlaces.roundToDecimalPlaces)(positions[colCount - 1] + visibleColumns[colCount - 1].computedWidth, 1);
|
|
66
68
|
});
|
|
67
69
|
function useGridDimensions(apiRef, props) {
|
|
68
|
-
const virtualizer = apiRef.current.virtualizer;
|
|
69
|
-
const updateDimensions = virtualizer.api.updateDimensions;
|
|
70
|
-
const getViewportPageSize = virtualizer.api.getViewportPageSize;
|
|
71
70
|
const getRootDimensions = React.useCallback(() => (0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef), [apiRef]);
|
|
72
71
|
const apiPublic = {
|
|
73
72
|
getRootDimensions
|
|
74
73
|
};
|
|
75
74
|
const apiPrivate = {
|
|
76
|
-
updateDimensions
|
|
77
|
-
|
|
75
|
+
updateDimensions: () => {
|
|
76
|
+
return apiRef.current.virtualizer.api.updateDimensions();
|
|
77
|
+
},
|
|
78
|
+
getViewportPageSize: () => {
|
|
79
|
+
return apiRef.current.virtualizer.api.getViewportPageSize();
|
|
80
|
+
}
|
|
78
81
|
};
|
|
79
82
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, apiPublic, 'public');
|
|
80
83
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, apiPrivate, 'private');
|
|
@@ -103,6 +106,9 @@ function useGridDimensions(apiRef, props) {
|
|
|
103
106
|
/* eslint-enable react-hooks/rules-of-hooks */
|
|
104
107
|
}
|
|
105
108
|
(0, _store.useStoreEffect)(apiRef.current.store, s => s.dimensions, (previous, next) => {
|
|
109
|
+
if (!next.isReady) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
106
112
|
if (apiRef.current.rootElementRef.current) {
|
|
107
113
|
setCSSVariables(apiRef.current.rootElementRef.current, next);
|
|
108
114
|
}
|
|
@@ -371,7 +371,7 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
371
371
|
});
|
|
372
372
|
if (onProcessRowUpdateError) {
|
|
373
373
|
onProcessRowUpdateError(errorThrown);
|
|
374
|
-
} else
|
|
374
|
+
} else {
|
|
375
375
|
(0, _warning.warnOnce)(['MUI X: A call to `processRowUpdate()` threw an error which was not handled because `onProcessRowUpdateError()` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError()` prop, for example `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/editing/persistence/.'], 'error');
|
|
376
376
|
}
|
|
377
377
|
};
|
|
@@ -455,7 +455,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
455
455
|
}
|
|
456
456
|
if (onProcessRowUpdateError) {
|
|
457
457
|
onProcessRowUpdateError(errorThrown);
|
|
458
|
-
} else
|
|
458
|
+
} else {
|
|
459
459
|
(0, _warning.warnOnce)(['MUI X: A call to `processRowUpdate()` threw an error which was not handled because `onProcessRowUpdateError()` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError()` prop, for example `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/editing/persistence/.'], 'error');
|
|
460
460
|
}
|
|
461
461
|
};
|
|
@@ -84,10 +84,8 @@ const serializeRow = ({
|
|
|
84
84
|
});
|
|
85
85
|
columns.forEach(column => {
|
|
86
86
|
const cellParams = getCellParams(id, column.field);
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
(0, _warning.warnOnce)(['MUI X: When the value of a field is an object or a `renderCell` is provided, the CSV export might not display the value correctly.', 'You can provide a `valueFormatter` with a string representation to be used.']);
|
|
90
|
-
}
|
|
87
|
+
if (String(cellParams.formattedValue) === '[object Object]') {
|
|
88
|
+
(0, _warning.warnOnce)(['MUI X: When the value of a field is an object or a `renderCell` is provided, the CSV export might not display the value correctly.', 'You can provide a `valueFormatter` with a string representation to be used.']);
|
|
91
89
|
}
|
|
92
90
|
row.addValue(serializeCellValue(cellParams, {
|
|
93
91
|
ignoreValueFormatter,
|
|
@@ -16,15 +16,15 @@ var _gridFilterSelector = require("../filter/gridFilterSelector");
|
|
|
16
16
|
var _gridColumnsSelector = require("../columns/gridColumnsSelector");
|
|
17
17
|
var _gridClasses = require("../../../constants/gridClasses");
|
|
18
18
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
19
|
-
var _gridRowsMetaSelector = require("../rows/gridRowsMetaSelector");
|
|
20
19
|
var _gridRowsUtils = require("../rows/gridRowsUtils");
|
|
21
20
|
var _utils = require("./utils");
|
|
22
21
|
var _useGridPaginationModel = require("../pagination/useGridPaginationModel");
|
|
23
22
|
var _pipeProcessing = require("../../core/pipeProcessing");
|
|
24
23
|
var _toolbar = require("../../../components/toolbar");
|
|
25
|
-
var _gridColumnsUtils = require("../columns/gridColumnsUtils");
|
|
26
24
|
var _gridCheckboxSelectionColDef = require("../../../colDef/gridCheckboxSelectionColDef");
|
|
25
|
+
var _GridVirtualScrollbar = require("../../../components/virtualization/GridVirtualScrollbar");
|
|
27
26
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
27
|
+
const DEBUG_MODE = false;
|
|
28
28
|
function raf() {
|
|
29
29
|
return new Promise(resolve => {
|
|
30
30
|
requestAnimationFrame(() => {
|
|
@@ -37,6 +37,10 @@ function buildPrintWindow(title) {
|
|
|
37
37
|
iframeEl.style.position = 'absolute';
|
|
38
38
|
iframeEl.style.width = '0px';
|
|
39
39
|
iframeEl.style.height = '0px';
|
|
40
|
+
if (DEBUG_MODE) {
|
|
41
|
+
iframeEl.style.width = '100%';
|
|
42
|
+
iframeEl.style.height = '10000px';
|
|
43
|
+
}
|
|
40
44
|
iframeEl.title = title || document.title;
|
|
41
45
|
return iframeEl;
|
|
42
46
|
}
|
|
@@ -104,40 +108,36 @@ const useGridPrintExport = (apiRef, props) => {
|
|
|
104
108
|
if (!printDoc) {
|
|
105
109
|
return;
|
|
106
110
|
}
|
|
107
|
-
const rowsMeta = (0, _gridRowsMetaSelector.gridRowsMetaSelector)(apiRef);
|
|
108
111
|
const gridRootElement = apiRef.current.rootElementRef.current;
|
|
109
112
|
const gridClone = gridRootElement.cloneNode(true);
|
|
113
|
+
const virtualScrollerContent = gridClone.querySelector(`.${_gridClasses.gridClasses.virtualScrollerContent}`);
|
|
110
114
|
|
|
111
115
|
// Allow to overflow to not hide the border of the last row
|
|
112
116
|
const gridMain = gridClone.querySelector(`.${_gridClasses.gridClasses.main}`);
|
|
113
117
|
gridMain.style.overflow = 'visible';
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
gridClone.
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
gridClone.querySelector(`.${_gridClasses.gridClasses.virtualScrollerRenderZone}`).style.position = 'static';
|
|
119
|
+
virtualScrollerContent.style.flexBasis = 'auto';
|
|
120
|
+
gridClone.querySelector(`.${_gridClasses.gridClasses['scrollbar--vertical']}`)?.remove();
|
|
121
|
+
if (!(virtualScrollerContent.nextSibling instanceof HTMLElement && virtualScrollerContent.nextSibling.classList.contains(_gridClasses.gridClasses.filler))) {
|
|
122
|
+
const filler = document.createElement('div');
|
|
123
|
+
filler.style.height = _GridVirtualScrollbar.scrollbarSizeCssExpression;
|
|
124
|
+
virtualScrollerContent.insertAdjacentElement('afterend', filler);
|
|
125
|
+
}
|
|
119
126
|
const gridFooterElement = gridClone.querySelector(`.${_gridClasses.gridClasses.footerContainer}`);
|
|
120
127
|
if (normalizeOptions.hideToolbar) {
|
|
121
128
|
gridClone.querySelector(`.${_gridClasses.gridClasses.toolbar}`)?.remove();
|
|
122
|
-
gridToolbarElementHeight = 0;
|
|
123
129
|
}
|
|
124
130
|
if (normalizeOptions.hideFooter && gridFooterElement) {
|
|
125
131
|
gridFooterElement.remove();
|
|
126
|
-
gridFooterElementHeight = 0;
|
|
127
132
|
}
|
|
128
|
-
|
|
129
|
-
// Expand container height to accommodate all rows
|
|
130
|
-
const computedTotalHeight = rowsMeta.currentPageTotalHeight + (0, _gridColumnsUtils.getTotalHeaderHeight)(apiRef, props) + gridToolbarElementHeight + gridFooterElementHeight;
|
|
131
|
-
gridClone.style.height = `${computedTotalHeight}px`;
|
|
133
|
+
gridClone.style.height = 'auto';
|
|
132
134
|
// The height above does not include grid border width, so we need to exclude it
|
|
133
135
|
gridClone.style.boxSizing = 'content-box';
|
|
134
136
|
if (!normalizeOptions.hideFooter && gridFooterElement) {
|
|
135
137
|
// the footer is always being placed at the bottom of the page as if all rows are exported
|
|
136
138
|
// so if getRowsToExport is being used to only export a subset of rows then we need to
|
|
137
139
|
// adjust the footer position to be correctly placed at the bottom of the grid
|
|
138
|
-
gridFooterElement.style.position = 'absolute';
|
|
139
140
|
gridFooterElement.style.width = '100%';
|
|
140
|
-
gridFooterElement.style.top = `${computedTotalHeight - gridFooterElementHeight}px`;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
// printDoc.body.appendChild(gridClone); should be enough but a clone isolation bug in Safari
|
|
@@ -165,13 +165,13 @@ const useGridPrintExport = (apiRef, props) => {
|
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
// Trigger print
|
|
168
|
-
if (process.env.NODE_ENV !== 'test') {
|
|
168
|
+
if (process.env.NODE_ENV !== 'test' && !DEBUG_MODE) {
|
|
169
169
|
// wait for remote stylesheets to load
|
|
170
170
|
Promise.all(stylesheetLoadPromises).then(() => {
|
|
171
171
|
printWindow.contentWindow.print();
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
|
-
}, [apiRef, doc
|
|
174
|
+
}, [apiRef, doc]);
|
|
175
175
|
const handlePrintWindowAfterPrint = React.useCallback(printWindow => {
|
|
176
176
|
// Remove the print iframe
|
|
177
177
|
doc.current.body.removeChild(printWindow);
|
|
@@ -49,24 +49,18 @@ const sanitizeFilterModel = (model, disableMultipleColumnsFiltering, apiRef) =>
|
|
|
49
49
|
const hasSeveralItems = model.items.length > 1;
|
|
50
50
|
let items;
|
|
51
51
|
if (hasSeveralItems && disableMultipleColumnsFiltering) {
|
|
52
|
-
|
|
53
|
-
(0, _warning.warnOnce)(['MUI X: The `filterModel` can only contain a single item when the `disableMultipleColumnsFiltering` prop is set to `true`.', 'If you are using the community version of the Data Grid, this prop is always `true`.'], 'error');
|
|
54
|
-
}
|
|
52
|
+
(0, _warning.warnOnce)(['MUI X: The `filterModel` can only contain a single item when the `disableMultipleColumnsFiltering` prop is set to `true`.', 'If you are using the community version of the Data Grid, this prop is always `true`.'], 'error');
|
|
55
53
|
items = [model.items[0]];
|
|
56
54
|
} else {
|
|
57
55
|
items = model.items;
|
|
58
56
|
}
|
|
59
57
|
const hasItemsWithoutIds = hasSeveralItems && items.some(item => item.id == null);
|
|
60
58
|
const hasItemWithoutOperator = items.some(item => item.operator == null);
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
(0, _warning.warnOnce)('MUI X: The `id` field is required on `filterModel.items` when you use multiple filters.', 'error');
|
|
64
|
-
}
|
|
59
|
+
if (hasItemsWithoutIds) {
|
|
60
|
+
(0, _warning.warnOnce)('MUI X: The `id` field is required on `filterModel.items` when you use multiple filters.', 'error');
|
|
65
61
|
}
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
(0, _warning.warnOnce)('MUI X: The `operator` field is required on `filterModel.items`, one or more of your filtering item has no `operator` provided.', 'error');
|
|
69
|
-
}
|
|
62
|
+
if (hasItemWithoutOperator) {
|
|
63
|
+
(0, _warning.warnOnce)('MUI X: The `operator` field is required on `filterModel.items`, one or more of your filtering item has no `operator` provided.', 'error');
|
|
70
64
|
}
|
|
71
65
|
if (hasItemWithoutOperator || hasItemsWithoutIds) {
|
|
72
66
|
return (0, _extends2.default)({}, model, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export type { GridFilterState, GridFilterInitialState } from "./gridFilterState.js";
|
|
2
2
|
export { getDefaultGridFilterModel } from "./gridFilterState.js";
|
|
3
|
-
export { gridFilterModelSelector, gridQuickFilterValuesSelector, gridVisibleRowsLookupSelector, gridFilteredRowsLookupSelector, gridFilteredDescendantCountLookupSelector, gridExpandedSortedRowEntriesSelector, gridExpandedSortedRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector, gridFilteredSortedTopLevelRowEntriesSelector, gridExpandedRowCountSelector, gridFilteredTopLevelRowCountSelector, gridFilteredRowCountSelector, gridFilteredDescendantRowCountSelector, gridFilterActiveItemsSelector, gridFilterActiveItemsLookupSelector } from "./gridFilterSelector.js";
|
|
3
|
+
export { gridFilterModelSelector, gridQuickFilterValuesSelector, gridVisibleRowsLookupSelector, gridFilteredRowsLookupSelector, gridFilteredDescendantCountLookupSelector, gridExpandedSortedRowEntriesSelector, gridExpandedSortedRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector, gridFilteredSortedTopLevelRowEntriesSelector, gridExpandedRowCountSelector, gridFilteredTopLevelRowCountSelector, gridFilteredRowCountSelector, gridFilteredDescendantRowCountSelector, gridFilterActiveItemsSelector, gridFilterActiveItemsLookupSelector, gridExpandedSortedRowIndexLookupSelector } from "./gridFilterSelector.js";
|
|
4
4
|
export type { GridFilterActiveItemsLookup } from "./gridFilterSelector.js";
|
|
@@ -27,6 +27,12 @@ Object.defineProperty(exports, "gridExpandedSortedRowIdsSelector", {
|
|
|
27
27
|
return _gridFilterSelector.gridExpandedSortedRowIdsSelector;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
+
Object.defineProperty(exports, "gridExpandedSortedRowIndexLookupSelector", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _gridFilterSelector.gridExpandedSortedRowIndexLookupSelector;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
30
36
|
Object.defineProperty(exports, "gridFilterActiveItemsLookupSelector", {
|
|
31
37
|
enumerable: true,
|
|
32
38
|
get: function () {
|
|
@@ -9,4 +9,4 @@ export declare const filterStateInitializer: GridStateInitializer<Pick<DataGridP
|
|
|
9
9
|
* @requires useGridParamsApi (method)
|
|
10
10
|
* @requires useGridRows (event)
|
|
11
11
|
*/
|
|
12
|
-
export declare const useGridFilter: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "rows" | "initialState" | "filterModel" | "getRowId" | "onFilterModelChange" | "filterMode" | "disableMultipleColumnsFiltering" | "slots" | "slotProps" | "disableColumnFilter" | "disableEval" | "ignoreDiacritics">, configuration: GridConfiguration) => void;
|
|
12
|
+
export declare const useGridFilter: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "rows" | "initialState" | "filterModel" | "getRowId" | "onFilterModelChange" | "filterMode" | "disableMultipleColumnsFiltering" | "slots" | "slotProps" | "disableColumnFilter" | "disableEval" | "ignoreDiacritics" | "signature">, configuration: GridConfiguration) => void;
|
|
@@ -363,7 +363,9 @@ const useGridFilter = (apiRef, props, configuration) => {
|
|
|
363
363
|
* 1ST RENDER
|
|
364
364
|
*/
|
|
365
365
|
(0, _useFirstRender.useFirstRender)(() => {
|
|
366
|
-
|
|
366
|
+
if (props.signature === 'DataGrid') {
|
|
367
|
+
updateFilteredRows();
|
|
368
|
+
}
|
|
367
369
|
});
|
|
368
370
|
|
|
369
371
|
/**
|
|
@@ -232,7 +232,6 @@ const useGridFocus = (apiRef, props) => {
|
|
|
232
232
|
apiRef.current.setCellFocus(id, field);
|
|
233
233
|
}, [apiRef]);
|
|
234
234
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
235
|
-
// GRID_CELL_NAVIGATION_KEY_DOWN handles the focus on Enter, Tab and navigation keys
|
|
236
235
|
if (event.key === 'Enter' || event.key === 'Tab' || event.key === 'Shift' || (0, _keyboardUtils.isNavigationKey)(event.key)) {
|
|
237
236
|
return;
|
|
238
237
|
}
|
|
@@ -10,4 +10,4 @@ import { DataGridProcessedProps } from "../../../models/props/DataGridProps.js";
|
|
|
10
10
|
* @requires useGridScroll (method) - can be after
|
|
11
11
|
* @requires useGridColumnSpanning (method) - can be after
|
|
12
12
|
*/
|
|
13
|
-
export declare const useGridKeyboardNavigation: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "pagination" | "paginationMode" | "getRowId" | "signature" | "headerFilters">) => void;
|
|
13
|
+
export declare const useGridKeyboardNavigation: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "pagination" | "paginationMode" | "getRowId" | "signature" | "headerFilters" | "tabNavigation">) => void;
|