@mui/x-data-grid 9.13.0 → 9.15.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 +325 -0
- package/DataGrid/DataGrid.js +8 -0
- package/DataGrid/DataGrid.mjs +9 -1
- package/DataGrid/useDataGridComponent.js +2 -2
- package/DataGrid/useDataGridComponent.mjs +2 -2
- package/DataGrid/useDataGridProps.mjs +1 -1
- package/colDef/gridActionsColDef.mjs +1 -1
- package/colDef/gridBooleanColDef.mjs +1 -1
- package/colDef/gridCheckboxSelectionColDef.mjs +1 -1
- package/colDef/gridDateColDef.mjs +1 -1
- package/colDef/gridDefaultColumnTypes.mjs +1 -1
- package/colDef/gridLongTextColDef.mjs +1 -1
- package/colDef/gridNumericColDef.mjs +1 -1
- package/colDef/gridSingleSelectColDef.mjs +1 -1
- package/components/GridColumnHeaders.mjs +2 -2
- package/components/GridColumnSortButton.mjs +2 -2
- package/components/GridColumnUnsortedIcon.mjs +2 -2
- package/components/GridFooter.mjs +1 -1
- package/components/GridHeader.mjs +1 -1
- package/components/GridHeaders.mjs +1 -1
- package/components/GridLoadingOverlay.mjs +2 -2
- package/components/GridNoColumnsOverlay.mjs +1 -1
- package/components/GridNoResultsOverlay.mjs +1 -1
- package/components/GridNoRowsOverlay.mjs +1 -1
- package/components/GridPagination.js +9 -1
- package/components/GridPagination.mjs +10 -2
- package/components/GridRow.mjs +2 -2
- package/components/GridRowCount.mjs +2 -2
- package/components/GridRowDragAndDropOverlay.mjs +1 -1
- package/components/GridScrollArea.js +20 -7
- package/components/GridScrollArea.mjs +22 -9
- package/components/GridSelectedRowCount.mjs +2 -2
- package/components/GridShadowScrollArea.mjs +2 -2
- package/components/GridSkeletonLoadingOverlay.mjs +2 -2
- package/components/base/GridFooterPlaceholder.mjs +1 -1
- package/components/base/GridOverlays.js +6 -5
- package/components/base/GridOverlays.mjs +7 -6
- package/components/cell/GridActionsCell.js +55 -52
- package/components/cell/GridActionsCell.mjs +58 -55
- package/components/cell/GridActionsCellItem.d.mts +20 -6
- package/components/cell/GridActionsCellItem.d.ts +20 -6
- package/components/cell/GridActionsCellItem.js +30 -8
- package/components/cell/GridActionsCellItem.mjs +32 -10
- package/components/cell/GridBooleanCell.mjs +2 -2
- package/components/cell/GridCell.js +9 -1
- package/components/cell/GridCell.mjs +11 -3
- package/components/cell/GridEditBooleanCell.mjs +2 -2
- package/components/cell/GridEditDateCell.mjs +2 -2
- package/components/cell/GridEditInputCell.mjs +2 -2
- package/components/cell/GridEditLongTextCell.mjs +1 -1
- package/components/cell/GridEditSingleSelectCell.mjs +2 -2
- package/components/cell/GridFooterCell.mjs +2 -2
- package/components/cell/GridLongTextCell.mjs +1 -1
- package/components/cell/GridSkeletonCell.mjs +2 -2
- package/components/columnHeaders/ColumnHeaderMenuIcon.mjs +1 -1
- package/components/columnHeaders/GridBaseColumnHeaders.mjs +2 -2
- package/components/columnHeaders/GridColumnGroupHeader.mjs +1 -1
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.mjs +1 -1
- package/components/columnHeaders/GridColumnHeaderItem.mjs +1 -1
- package/components/columnHeaders/GridColumnHeaderSeparator.d.mts +1 -1
- package/components/columnHeaders/GridColumnHeaderSeparator.d.ts +1 -1
- package/components/columnHeaders/GridColumnHeaderSeparator.mjs +2 -2
- package/components/columnHeaders/GridColumnHeaderSortIcon.js +17 -0
- package/components/columnHeaders/GridColumnHeaderSortIcon.mjs +18 -1
- package/components/columnHeaders/GridColumnHeaderTitle.mjs +2 -2
- package/components/columnHeaders/GridGenericColumnHeaderItem.mjs +2 -2
- package/components/columnHeaders/GridIconButtonContainer.mjs +2 -2
- package/components/columnSelection/GridCellCheckboxRenderer.mjs +2 -2
- package/components/columnSelection/GridHeaderCheckbox.mjs +2 -2
- package/components/columnSelection/GridRowCheckbox.js +1 -3
- package/components/columnSelection/GridRowCheckbox.mjs +3 -5
- package/components/columnsManagement/GridColumnsManagement.mjs +1 -1
- package/components/columnsPanel/ColumnsPanelTrigger.mjs +2 -2
- package/components/containers/GridFooterContainer.mjs +2 -2
- package/components/containers/GridOverlay.mjs +2 -2
- package/components/containers/GridRoot.mjs +2 -2
- package/components/containers/GridRootStyles.js +22 -10
- package/components/containers/GridRootStyles.mjs +22 -10
- package/components/containers/GridToolbarContainer.mjs +2 -2
- package/components/export/ExportCsv.mjs +2 -2
- package/components/export/ExportPrint.js +4 -1
- package/components/export/ExportPrint.mjs +6 -3
- package/components/filterPanel/FilterPanelTrigger.mjs +2 -2
- package/components/menu/GridMenu.mjs +2 -2
- package/components/menu/columnMenu/GridColumnHeaderMenu.mjs +1 -1
- package/components/menu/columnMenu/GridColumnMenu.mjs +2 -2
- package/components/menu/columnMenu/GridColumnMenuContainer.mjs +2 -2
- package/components/menu/columnMenu/menuItems/GridColumnMenuColumnsItem.mjs +1 -1
- package/components/panel/GridColumnsPanel.mjs +1 -1
- package/components/panel/GridPanel.mjs +2 -2
- package/components/panel/GridPanelContent.mjs +2 -2
- package/components/panel/GridPanelContext.mjs +1 -1
- package/components/panel/GridPanelFooter.mjs +2 -2
- package/components/panel/GridPanelHeader.mjs +2 -2
- package/components/panel/GridPanelWrapper.mjs +2 -2
- package/components/panel/GridPreferencesPanel.mjs +1 -1
- package/components/panel/filterPanel/GridFilterForm.mjs +1 -1
- package/components/panel/filterPanel/GridFilterFormBase.mjs +2 -2
- package/components/panel/filterPanel/GridFilterInputBoolean.js +1 -12
- package/components/panel/filterPanel/GridFilterInputBoolean.mjs +3 -14
- package/components/panel/filterPanel/GridFilterInputDate.mjs +2 -2
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.mjs +2 -2
- package/components/panel/filterPanel/GridFilterInputMultipleValue.mjs +2 -2
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -12
- package/components/panel/filterPanel/GridFilterInputSingleSelect.mjs +3 -14
- package/components/panel/filterPanel/GridFilterInputValue.mjs +2 -2
- package/components/panel/filterPanel/GridFilterPanel.mjs +1 -1
- package/components/panel/filterPanel/GridFilterPanelBase.mjs +2 -2
- package/components/panel/filterPanel/filterPanelUtils.mjs +1 -1
- package/components/quickFilter/QuickFilter.js +7 -2
- package/components/quickFilter/QuickFilter.mjs +9 -4
- package/components/quickFilter/QuickFilterClear.js +17 -0
- package/components/quickFilter/QuickFilterClear.mjs +19 -2
- package/components/quickFilter/QuickFilterControl.mjs +2 -2
- package/components/quickFilter/QuickFilterTrigger.mjs +2 -2
- package/components/toolbar/GridToolbar.mjs +2 -2
- package/components/toolbar/GridToolbarColumnsButton.mjs +1 -1
- package/components/toolbar/GridToolbarDensitySelector.mjs +1 -1
- package/components/toolbar/GridToolbarExport.js +4 -1
- package/components/toolbar/GridToolbarExport.mjs +6 -3
- package/components/toolbar/GridToolbarExportContainer.mjs +1 -1
- package/components/toolbar/GridToolbarFilterButton.mjs +1 -1
- package/components/toolbar/GridToolbarQuickFilter.mjs +2 -2
- package/components/toolbarV8/GridToolbar.mjs +2 -2
- package/components/toolbarV8/Toolbar.mjs +2 -2
- package/components/toolbarV8/ToolbarButton.js +17 -0
- package/components/toolbarV8/ToolbarButton.mjs +19 -2
- package/components/virtualization/GridBottomContainer.mjs +1 -1
- package/components/virtualization/GridMainContainer.mjs +1 -1
- package/components/virtualization/GridTopContainer.mjs +1 -1
- package/components/virtualization/GridVirtualScrollbar.js +2 -2
- package/components/virtualization/GridVirtualScrollbar.mjs +2 -2
- package/components/virtualization/GridVirtualScroller.js +5 -2
- package/components/virtualization/GridVirtualScroller.mjs +6 -3
- package/components/virtualization/GridVirtualScrollerContent.mjs +1 -1
- package/components/virtualization/GridVirtualScrollerRenderZone.mjs +1 -1
- package/constants/cssVariables.mjs +1 -1
- package/constants/defaultGridSlotsComponents.mjs +1 -1
- package/constants/signature.d.mts +1 -1
- package/constants/signature.d.ts +1 -1
- package/hooks/core/pipeProcessing/useGridPipeProcessing.mjs +2 -2
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +2 -2
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.mjs +2 -2
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +2 -2
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.mjs +2 -2
- package/hooks/core/strategyProcessing/gridStrategyProcessingApi.d.mts +1 -1
- package/hooks/core/strategyProcessing/gridStrategyProcessingApi.d.ts +1 -1
- package/hooks/core/strategyProcessing/useGridRegisterStrategyProcessor.js +2 -2
- package/hooks/core/strategyProcessing/useGridRegisterStrategyProcessor.mjs +2 -2
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.mjs +2 -2
- package/hooks/core/useGridApiInitialization.js +1 -1
- package/hooks/core/useGridApiInitialization.mjs +1 -1
- package/hooks/core/useGridIsRtl.mjs +1 -1
- package/hooks/core/useGridProps.mjs +1 -1
- package/hooks/core/useGridStateInitialization.mjs +1 -1
- package/hooks/core/useGridVirtualizer.d.mts +2 -2
- package/hooks/core/useGridVirtualizer.d.ts +2 -2
- package/hooks/core/useGridVirtualizer.js +6 -6
- package/hooks/core/useGridVirtualizer.mjs +4 -4
- package/hooks/features/columnGrouping/gridColumnGroupsUtils.mjs +2 -2
- package/hooks/features/columnGrouping/useGridColumnGrouping.mjs +1 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.mjs +1 -1
- package/hooks/features/columnMenu/getColumnMenuItemKeys.mjs +1 -1
- package/hooks/features/columnMenu/useGridColumnMenu.mjs +1 -1
- package/hooks/features/columnMenu/useGridColumnMenuSlots.mjs +2 -2
- package/hooks/features/columnResize/useGridColumnResize.js +4 -1
- package/hooks/features/columnResize/useGridColumnResize.mjs +5 -2
- package/hooks/features/columns/gridColumnsInterfaces.d.mts +1 -1
- package/hooks/features/columns/gridColumnsInterfaces.d.ts +1 -1
- package/hooks/features/columns/gridColumnsUtils.d.mts +1 -1
- package/hooks/features/columns/gridColumnsUtils.d.ts +1 -1
- package/hooks/features/columns/gridColumnsUtils.mjs +1 -1
- package/hooks/features/columns/useGridColumns.js +1 -1
- package/hooks/features/columns/useGridColumns.mjs +2 -2
- package/hooks/features/dataSource/cache.js +1 -1
- package/hooks/features/dataSource/cache.mjs +1 -1
- package/hooks/features/dataSource/useGridDataSourceBase.js +14 -29
- package/hooks/features/dataSource/useGridDataSourceBase.mjs +17 -32
- package/hooks/features/dataSource/useGridDataSourcePolling.d.mts +29 -0
- package/hooks/features/dataSource/useGridDataSourcePolling.d.ts +29 -0
- package/hooks/features/dataSource/useGridDataSourcePolling.js +62 -0
- package/hooks/features/dataSource/useGridDataSourcePolling.mjs +54 -0
- package/hooks/features/dataSource/utils.d.mts +1 -1
- package/hooks/features/dataSource/utils.d.ts +1 -1
- package/hooks/features/dataSource/utils.mjs +1 -1
- package/hooks/features/density/useGridDensity.mjs +1 -1
- package/hooks/features/dimensions/useGridDimensions.d.mts +1 -1
- package/hooks/features/dimensions/useGridDimensions.d.ts +1 -1
- package/hooks/features/dimensions/useGridDimensions.js +3 -3
- package/hooks/features/dimensions/useGridDimensions.mjs +3 -3
- package/hooks/features/editing/useGridCellEditing.js +1 -1
- package/hooks/features/editing/useGridCellEditing.mjs +5 -5
- package/hooks/features/editing/useGridEditing.mjs +1 -1
- package/hooks/features/editing/useGridRowEditing.js +1 -1
- package/hooks/features/editing/useGridRowEditing.mjs +5 -5
- package/hooks/features/export/serializers/csvSerializer.js +5 -5
- package/hooks/features/export/serializers/csvSerializer.mjs +5 -5
- package/hooks/features/export/useGridPrintExport.js +44 -20
- package/hooks/features/export/useGridPrintExport.mjs +45 -21
- package/hooks/features/filter/gridFilterUtils.js +3 -3
- package/hooks/features/filter/gridFilterUtils.mjs +5 -5
- package/hooks/features/filter/useGridFilter.js +2 -2
- package/hooks/features/filter/useGridFilter.mjs +3 -3
- package/hooks/features/focus/useGridFocus.mjs +1 -1
- package/hooks/features/headerFiltering/useGridHeaderFiltering.mjs +1 -1
- package/hooks/features/listView/useGridListView.d.mts +2 -2
- package/hooks/features/listView/useGridListView.d.ts +2 -2
- package/hooks/features/listView/useGridListView.js +1 -1
- package/hooks/features/listView/useGridListView.mjs +2 -2
- package/hooks/features/pagination/useGridPagination.mjs +1 -1
- package/hooks/features/pagination/useGridPaginationMeta.mjs +1 -1
- package/hooks/features/pagination/useGridPaginationModel.mjs +1 -1
- package/hooks/features/pagination/useGridRowCount.js +2 -2
- package/hooks/features/pagination/useGridRowCount.mjs +2 -2
- package/hooks/features/preferencesPanel/gridPreferencePanelsValue.d.mts +1 -1
- package/hooks/features/preferencesPanel/gridPreferencePanelsValue.d.ts +1 -1
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.mjs +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.d.mts +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.d.ts +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +50 -9
- package/hooks/features/rowSelection/useGridRowSelection.mjs +52 -11
- package/hooks/features/rowSelection/useGridRowSelectionPreProcessors.mjs +1 -1
- package/hooks/features/rowSelection/utils.js +5 -0
- package/hooks/features/rowSelection/utils.mjs +5 -0
- package/hooks/features/rows/gridRowsUtils.js +2 -2
- package/hooks/features/rows/gridRowsUtils.mjs +3 -3
- package/hooks/features/rows/useGridRowSpanning.mjs +1 -1
- package/hooks/features/rows/useGridRows.mjs +1 -1
- package/hooks/features/rows/useGridRowsMeta.mjs +1 -1
- package/hooks/features/rows/useGridRowsOverridableMethods.mjs +1 -1
- package/hooks/features/rows/useGridRowsPreProcessors.mjs +1 -1
- package/hooks/features/sorting/gridSortingUtils.js +1 -1
- package/hooks/features/sorting/gridSortingUtils.mjs +3 -3
- package/hooks/features/sorting/useGridSorting.js +2 -2
- package/hooks/features/sorting/useGridSorting.mjs +3 -3
- package/hooks/features/virtualization/gridFocusedVirtualCellSelector.mjs +1 -1
- package/hooks/features/virtualization/useGridVirtualization.mjs +1 -1
- package/hooks/utils/index.d.mts +1 -1
- package/hooks/utils/index.d.ts +1 -1
- package/hooks/utils/index.js +8 -12
- package/hooks/utils/index.mjs +2 -1
- package/hooks/utils/useGridSelector.js +2 -2
- package/hooks/utils/useGridSelector.mjs +2 -2
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/constants.d.mts +1 -1
- package/internals/constants.d.ts +1 -1
- package/internals/index.d.mts +1 -0
- package/internals/index.d.ts +1 -0
- package/internals/index.js +8 -0
- package/internals/index.mjs +1 -0
- package/internals/utils/cache.d.mts +0 -1
- package/internals/utils/cache.d.ts +0 -1
- package/internals/utils/cache.js +1 -3
- package/internals/utils/cache.mjs +1 -3
- package/internals/utils/computeSlots.mjs +1 -1
- package/internals/utils/propValidation.js +2 -2
- package/internals/utils/propValidation.mjs +3 -3
- package/material/index.mjs +2 -2
- package/models/api/gridCoreApi.d.mts +1 -1
- package/models/api/gridCoreApi.d.ts +1 -1
- package/models/api/gridEditingApi.d.mts +6 -6
- package/models/api/gridEditingApi.d.ts +6 -6
- package/models/api/gridPrintExportApi.d.mts +2 -1
- package/models/api/gridPrintExportApi.d.ts +2 -1
- package/models/events/gridEventLookup.d.mts +5 -5
- package/models/events/gridEventLookup.d.ts +5 -5
- package/models/gridBaseSlots.d.mts +18 -1
- package/models/gridBaseSlots.d.ts +18 -1
- package/models/gridEditRowModel.d.mts +3 -3
- package/models/gridEditRowModel.d.ts +3 -3
- package/models/gridExport.d.mts +13 -0
- package/models/gridExport.d.ts +13 -0
- package/models/gridFilterItem.d.mts +2 -2
- package/models/gridFilterItem.d.ts +2 -2
- package/models/index.d.mts +2 -1
- package/models/index.d.ts +2 -1
- package/models/params/gridEditCellParams.d.mts +2 -2
- package/models/params/gridEditCellParams.d.ts +2 -2
- package/models/params/gridRowParams.d.mts +2 -2
- package/models/params/gridRowParams.d.ts +2 -2
- package/models/props/DataGridProps.d.mts +8 -0
- package/models/props/DataGridProps.d.ts +8 -0
- package/package.json +6 -6
- package/utils/createSelector.d.mts +1 -1
- package/utils/createSelector.d.ts +1 -1
- package/utils/createSelector.js +1 -1
- package/utils/createSelector.mjs +1 -1
- package/hooks/utils/useFirstRender.d.mts +0 -1
- package/hooks/utils/useFirstRender.d.ts +0 -1
- package/hooks/utils/useFirstRender.js +0 -16
- package/hooks/utils/useFirstRender.mjs +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
|
|
4
|
-
import _extends from "@babel/runtime/helpers/
|
|
4
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import ownerDocument from '@mui/utils/ownerDocument';
|
|
7
7
|
import { loadStyleSheets } from '@mui/x-internals/export';
|
|
@@ -91,7 +91,7 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
91
91
|
}, []);
|
|
92
92
|
apiRef.current.setRows(newRows);
|
|
93
93
|
}, [apiRef]);
|
|
94
|
-
const handlePrintWindowLoad = React.useCallback((printWindow, options) => {
|
|
94
|
+
const handlePrintWindowLoad = React.useCallback(async (printWindow, options) => {
|
|
95
95
|
const normalizeOptions = _extends({
|
|
96
96
|
copyStyles: true,
|
|
97
97
|
hideToolbar: false,
|
|
@@ -100,7 +100,7 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
100
100
|
}, options);
|
|
101
101
|
const printDoc = printWindow.contentDocument;
|
|
102
102
|
if (!printDoc) {
|
|
103
|
-
return;
|
|
103
|
+
return false;
|
|
104
104
|
}
|
|
105
105
|
const gridRootElement = apiRef.current.rootElementRef.current;
|
|
106
106
|
const gridClone = gridRootElement.cloneNode(true);
|
|
@@ -129,6 +129,8 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
129
129
|
gridFooterElement.remove();
|
|
130
130
|
}
|
|
131
131
|
gridClone.style.height = 'auto';
|
|
132
|
+
gridClone.style.minHeight = '0';
|
|
133
|
+
gridClone.style.maxHeight = 'none';
|
|
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) {
|
|
@@ -159,16 +161,23 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
159
161
|
if (normalizeOptions.copyStyles) {
|
|
160
162
|
const rootCandidate = gridRootElement.getRootNode();
|
|
161
163
|
const root = rootCandidate.constructor.name === 'ShadowRoot' ? rootCandidate : doc.current;
|
|
162
|
-
stylesheetLoadPromises = loadStyleSheets(printDoc, root
|
|
164
|
+
stylesheetLoadPromises = loadStyleSheets(printDoc, root, {
|
|
165
|
+
onStylesheetError: normalizeOptions.onStylesheetError
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// wait for remote stylesheets to load
|
|
170
|
+
const loaded = await Promise.all(stylesheetLoadPromises);
|
|
171
|
+
if (loaded.includes(false)) {
|
|
172
|
+
// `onStylesheetError` cancelled the print
|
|
173
|
+
return false;
|
|
163
174
|
}
|
|
164
175
|
|
|
165
176
|
// Trigger print
|
|
166
177
|
if (process.env.NODE_ENV !== 'test' && !DEBUG_MODE) {
|
|
167
|
-
|
|
168
|
-
Promise.all(stylesheetLoadPromises).then(() => {
|
|
169
|
-
printWindow.contentWindow.print();
|
|
170
|
-
});
|
|
178
|
+
printWindow.contentWindow.print();
|
|
171
179
|
}
|
|
180
|
+
return true;
|
|
172
181
|
}, [apiRef, doc]);
|
|
173
182
|
const handlePrintWindowAfterPrint = React.useCallback(printWindow => {
|
|
174
183
|
// Remove the print iframe
|
|
@@ -221,21 +230,36 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
221
230
|
const printWindow = buildPrintWindow(options?.fileName);
|
|
222
231
|
if (process.env.NODE_ENV === 'test') {
|
|
223
232
|
doc.current.body.appendChild(printWindow);
|
|
224
|
-
// In test env, run the all pipeline without waiting for
|
|
225
|
-
|
|
226
|
-
|
|
233
|
+
// In test env, run the all pipeline without waiting for the iframe to load or the print dialog
|
|
234
|
+
try {
|
|
235
|
+
await handlePrintWindowLoad(printWindow, options);
|
|
236
|
+
} finally {
|
|
237
|
+
handlePrintWindowAfterPrint(printWindow);
|
|
238
|
+
}
|
|
227
239
|
} else {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
240
|
+
await new Promise((resolve, reject) => {
|
|
241
|
+
printWindow.onload = () => {
|
|
242
|
+
const mediaQueryList = printWindow.contentWindow.matchMedia('print');
|
|
243
|
+
mediaQueryList.addEventListener('change', mql => {
|
|
244
|
+
const isAfterPrint = mql.matches === false;
|
|
245
|
+
if (isAfterPrint) {
|
|
246
|
+
handlePrintWindowAfterPrint(printWindow);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
handlePrintWindowLoad(printWindow, options).then(printed => {
|
|
250
|
+
if (!printed) {
|
|
251
|
+
// The print dialog never opens, so restore the grid here
|
|
252
|
+
handlePrintWindowAfterPrint(printWindow);
|
|
253
|
+
}
|
|
254
|
+
resolve();
|
|
255
|
+
}, error => {
|
|
256
|
+
// The print dialog never opens, so restore the grid here
|
|
234
257
|
handlePrintWindowAfterPrint(printWindow);
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
258
|
+
reject(error);
|
|
259
|
+
});
|
|
260
|
+
};
|
|
261
|
+
doc.current.body.appendChild(printWindow);
|
|
262
|
+
});
|
|
239
263
|
}
|
|
240
264
|
}, [props, logger, apiRef, handlePrintWindowLoad, handlePrintWindowAfterPrint, updateGridColumnsForPrint, updateGridRowsForPrint]);
|
|
241
265
|
const printExportApi = {
|
|
@@ -137,7 +137,7 @@ const sanitizeFilterModel = (model, disableMultipleColumnsFiltering, apiRef) =>
|
|
|
137
137
|
let items;
|
|
138
138
|
if (hasSeveralItems && disableMultipleColumnsFiltering) {
|
|
139
139
|
if (process.env.NODE_ENV !== 'production') {
|
|
140
|
-
(0, _warning.
|
|
140
|
+
(0, _warning.errorOnce)(['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`.'].join('\n'));
|
|
141
141
|
}
|
|
142
142
|
items = [model.items[0]];
|
|
143
143
|
} else {
|
|
@@ -146,10 +146,10 @@ const sanitizeFilterModel = (model, disableMultipleColumnsFiltering, apiRef) =>
|
|
|
146
146
|
const hasItemsWithoutIds = hasSeveralItems && items.some(item => item.id == null);
|
|
147
147
|
const hasItemWithoutOperator = items.some(item => item.operator == null);
|
|
148
148
|
if (hasItemsWithoutIds && process.env.NODE_ENV !== 'production') {
|
|
149
|
-
(0, _warning.
|
|
149
|
+
(0, _warning.errorOnce)('MUI X: The `id` field is required on `filterModel.items` when you use multiple filters.');
|
|
150
150
|
}
|
|
151
151
|
if (hasItemWithoutOperator && process.env.NODE_ENV !== 'production') {
|
|
152
|
-
(0, _warning.
|
|
152
|
+
(0, _warning.errorOnce)('MUI X: The `operator` field is required on `filterModel.items`, one or more of your filtering item has no `operator` provided.');
|
|
153
153
|
}
|
|
154
154
|
if (hasItemWithoutOperator || hasItemsWithoutIds) {
|
|
155
155
|
return (0, _extends2.default)({}, model, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
|
|
2
|
-
import _extends from "@babel/runtime/helpers/
|
|
3
|
-
import {
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import { errorOnce } from '@mui/x-internals/warning';
|
|
4
4
|
import { GridLogicOperator } from "../../../models/index.mjs";
|
|
5
5
|
import { getDefaultGridFilterModel } from "./gridFilterState.mjs";
|
|
6
6
|
import { getPublicApiRef } from "../../../utils/getPublicApiRef.mjs";
|
|
@@ -123,7 +123,7 @@ export const sanitizeFilterModel = (model, disableMultipleColumnsFiltering, apiR
|
|
|
123
123
|
let items;
|
|
124
124
|
if (hasSeveralItems && disableMultipleColumnsFiltering) {
|
|
125
125
|
if (process.env.NODE_ENV !== 'production') {
|
|
126
|
-
|
|
126
|
+
errorOnce(['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`.'].join('\n'));
|
|
127
127
|
}
|
|
128
128
|
items = [model.items[0]];
|
|
129
129
|
} else {
|
|
@@ -132,10 +132,10 @@ export const sanitizeFilterModel = (model, disableMultipleColumnsFiltering, apiR
|
|
|
132
132
|
const hasItemsWithoutIds = hasSeveralItems && items.some(item => item.id == null);
|
|
133
133
|
const hasItemWithoutOperator = items.some(item => item.operator == null);
|
|
134
134
|
if (hasItemsWithoutIds && process.env.NODE_ENV !== 'production') {
|
|
135
|
-
|
|
135
|
+
errorOnce('MUI X: The `id` field is required on `filterModel.items` when you use multiple filters.');
|
|
136
136
|
}
|
|
137
137
|
if (hasItemWithoutOperator && process.env.NODE_ENV !== 'production') {
|
|
138
|
-
|
|
138
|
+
errorOnce('MUI X: The `operator` field is required on `filterModel.items`, one or more of your filtering item has no `operator` provided.');
|
|
139
139
|
}
|
|
140
140
|
if (hasItemWithoutOperator || hasItemsWithoutIds) {
|
|
141
141
|
return _extends({}, model, {
|
|
@@ -11,6 +11,7 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
11
11
|
var _lruMemoize = require("@mui/x-internals/lruMemoize");
|
|
12
12
|
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
13
13
|
var _isDeepEqual = require("@mui/x-internals/isDeepEqual");
|
|
14
|
+
var _useOnFirstRender = require("@base-ui/utils/useOnFirstRender");
|
|
14
15
|
var _useLazyRef = require("../../utils/useLazyRef");
|
|
15
16
|
var _useGridEvent = require("../../utils/useGridEvent");
|
|
16
17
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
@@ -19,7 +20,6 @@ var _gridColumnsSelector = require("../columns/gridColumnsSelector");
|
|
|
19
20
|
var _gridPreferencePanelsValue = require("../preferencesPanel/gridPreferencePanelsValue");
|
|
20
21
|
var _gridFilterState = require("./gridFilterState");
|
|
21
22
|
var _gridFilterSelector = require("./gridFilterSelector");
|
|
22
|
-
var _useFirstRender = require("../../utils/useFirstRender");
|
|
23
23
|
var _rows = require("../rows");
|
|
24
24
|
var _pipeProcessing = require("../../core/pipeProcessing");
|
|
25
25
|
var _strategyProcessing = require("../../core/strategyProcessing");
|
|
@@ -311,7 +311,7 @@ const useGridFilter = (apiRef, props, configuration) => {
|
|
|
311
311
|
/**
|
|
312
312
|
* 1ST RENDER
|
|
313
313
|
*/
|
|
314
|
-
(0,
|
|
314
|
+
(0, _useOnFirstRender.useOnFirstRender)(() => {
|
|
315
315
|
if (props.signature === 'DataGrid') {
|
|
316
316
|
updateFilteredRows();
|
|
317
317
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { lruMemoize } from '@mui/x-internals/lruMemoize';
|
|
4
4
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
5
5
|
import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
|
|
6
|
+
import { useOnFirstRender } from '@base-ui/utils/useOnFirstRender';
|
|
6
7
|
import { useLazyRef } from "../../utils/useLazyRef.mjs";
|
|
7
8
|
import { useGridEvent } from "../../utils/useGridEvent.mjs";
|
|
8
9
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.mjs";
|
|
@@ -11,7 +12,6 @@ import { gridColumnLookupSelector } from "../columns/gridColumnsSelector.mjs";
|
|
|
11
12
|
import { GridPreferencePanelsValue } from "../preferencesPanel/gridPreferencePanelsValue.mjs";
|
|
12
13
|
import { defaultGridFilterLookup, getDefaultGridFilterModel } from "./gridFilterState.mjs";
|
|
13
14
|
import { gridFilterModelSelector } from "./gridFilterSelector.mjs";
|
|
14
|
-
import { useFirstRender } from "../../utils/useFirstRender.mjs";
|
|
15
15
|
import { gridRowsLookupSelector } from "../rows/index.mjs";
|
|
16
16
|
import { useGridRegisterPipeProcessor } from "../../core/pipeProcessing/index.mjs";
|
|
17
17
|
import { GRID_DEFAULT_STRATEGY, useGridRegisterStrategyProcessor } from "../../core/strategyProcessing/index.mjs";
|
|
@@ -302,7 +302,7 @@ export const useGridFilter = (apiRef, props, configuration) => {
|
|
|
302
302
|
/**
|
|
303
303
|
* 1ST RENDER
|
|
304
304
|
*/
|
|
305
|
-
|
|
305
|
+
useOnFirstRender(() => {
|
|
306
306
|
if (props.signature === 'DataGrid') {
|
|
307
307
|
updateFilteredRows();
|
|
308
308
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _extends from "@babel/runtime/helpers/
|
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import debounce from '@mui/utils/debounce';
|
|
6
6
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _extends from "@babel/runtime/helpers/
|
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.mjs";
|
|
6
6
|
import { useGridLogger } from "../../utils/index.mjs";
|
|
@@ -3,8 +3,8 @@ import type { GridListViewColDef } from "../../../models/colDef/gridColDef.mjs";
|
|
|
3
3
|
import type { GridStateInitializer } from "../../utils/useGridInitializeState.mjs";
|
|
4
4
|
import type { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.mjs";
|
|
5
5
|
import type { DataGridProcessedProps } from "../../../models/props/DataGridProps.mjs";
|
|
6
|
-
export type GridListViewState =
|
|
6
|
+
export type GridListViewState = GridListViewColDef & {
|
|
7
7
|
computedWidth: number;
|
|
8
|
-
}
|
|
8
|
+
} | undefined;
|
|
9
9
|
export declare const listViewStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'listViewColumn'>>;
|
|
10
10
|
export declare function useGridListView(apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'listView' | 'listViewColumn'>): void;
|
|
@@ -3,8 +3,8 @@ import type { GridListViewColDef } from "../../../models/colDef/gridColDef.js";
|
|
|
3
3
|
import type { GridStateInitializer } from "../../utils/useGridInitializeState.js";
|
|
4
4
|
import type { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
|
|
5
5
|
import type { DataGridProcessedProps } from "../../../models/props/DataGridProps.js";
|
|
6
|
-
export type GridListViewState =
|
|
6
|
+
export type GridListViewState = GridListViewColDef & {
|
|
7
7
|
computedWidth: number;
|
|
8
|
-
}
|
|
8
|
+
} | undefined;
|
|
9
9
|
export declare const listViewStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'listViewColumn'>>;
|
|
10
10
|
export declare function useGridListView(apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'listView' | 'listViewColumn'>): void;
|
|
@@ -63,7 +63,7 @@ function useGridListView(apiRef, props) {
|
|
|
63
63
|
}, [apiRef, props.listViewColumn]);
|
|
64
64
|
React.useEffect(() => {
|
|
65
65
|
if (process.env.NODE_ENV !== 'production' && props.listView && !props.listViewColumn) {
|
|
66
|
-
(0, _warning.warnOnce)(['MUI X: The `listViewColumn` prop must be set if `listView` is enabled.', 'To fix, pass a column definition to the `listViewColumn` prop, e.g. `{ field: "example", renderCell: (params) => <div>{params.row.id}</div> }`.', 'For more details, see https://mui.com/x/react-data-grid/list-view/']);
|
|
66
|
+
(0, _warning.warnOnce)(['MUI X: The `listViewColumn` prop must be set if `listView` is enabled.', 'To fix, pass a column definition to the `listViewColumn` prop, e.g. `{ field: "example", renderCell: (params) => <div>{params.row.id}</div> }`.', 'For more details, see https://mui.com/x/react-data-grid/list-view/'].join('\n'));
|
|
67
67
|
}
|
|
68
68
|
}, [props.listView, props.listViewColumn]);
|
|
69
69
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _extends from "@babel/runtime/helpers/
|
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
6
6
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
@@ -54,7 +54,7 @@ export function useGridListView(apiRef, props) {
|
|
|
54
54
|
}, [apiRef, props.listViewColumn]);
|
|
55
55
|
React.useEffect(() => {
|
|
56
56
|
if (process.env.NODE_ENV !== 'production' && props.listView && !props.listViewColumn) {
|
|
57
|
-
warnOnce(['MUI X: The `listViewColumn` prop must be set if `listView` is enabled.', 'To fix, pass a column definition to the `listViewColumn` prop, e.g. `{ field: "example", renderCell: (params) => <div>{params.row.id}</div> }`.', 'For more details, see https://mui.com/x/react-data-grid/list-view/']);
|
|
57
|
+
warnOnce(['MUI X: The `listViewColumn` prop must be set if `listView` is enabled.', 'To fix, pass a column definition to the `listViewColumn` prop, e.g. `{ field: "example", renderCell: (params) => <div>{params.row.id}</div> }`.', 'For more details, see https://mui.com/x/react-data-grid/list-view/'].join('\n'));
|
|
58
58
|
}
|
|
59
59
|
}, [props.listView, props.listViewColumn]);
|
|
60
60
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import { throwIfPageSizeExceedsTheLimit, getDefaultGridPaginationModel } from "./gridPaginationUtils.mjs";
|
|
3
3
|
import { useGridPaginationModel } from "./useGridPaginationModel.mjs";
|
|
4
4
|
import { useGridRowCount } from "./useGridRowCount.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _extends from "@babel/runtime/helpers/
|
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { useGridLogger, useGridApiMethod } from "../../utils/index.mjs";
|
|
6
6
|
import { useGridRegisterPipeProcessor } from "../../core/pipeProcessing/index.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _extends from "@babel/runtime/helpers/
|
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import debounce from '@mui/utils/debounce';
|
|
6
6
|
import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
|
|
@@ -10,7 +10,7 @@ exports.useGridRowCount = void 0;
|
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _useLazyRef = _interopRequireDefault(require("@mui/utils/useLazyRef"));
|
|
13
|
-
var
|
|
13
|
+
var _useStoreEffect = require("@mui/x-internals/useStoreEffect");
|
|
14
14
|
var _filter = require("../filter");
|
|
15
15
|
var _utils = require("../../utils");
|
|
16
16
|
var _pipeProcessing = require("../../core/pipeProcessing");
|
|
@@ -120,7 +120,7 @@ const useGridRowCount = (apiRef, props) => {
|
|
|
120
120
|
apiRef.current.setRowCount(props.rowCount);
|
|
121
121
|
}
|
|
122
122
|
}, [apiRef, props.paginationMode, props.rowCount]);
|
|
123
|
-
(0,
|
|
123
|
+
(0, _useStoreEffect.useStoreEffect)(
|
|
124
124
|
// typings not supported currently, but methods work
|
|
125
125
|
apiRef.current.store, () => {
|
|
126
126
|
const isLastPage = (0, _gridPaginationSelector.gridPaginationMetaSelector)(apiRef).hasNextPage === false;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _extends from "@babel/runtime/helpers/
|
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import useLazyRef from '@mui/utils/useLazyRef';
|
|
6
|
-
import { useStoreEffect } from '@mui/x-internals/
|
|
6
|
+
import { useStoreEffect } from '@mui/x-internals/useStoreEffect';
|
|
7
7
|
import { gridFilteredTopLevelRowCountSelector } from "../filter/index.mjs";
|
|
8
8
|
import { useGridLogger, useGridApiMethod, useGridEvent } from "../../utils/index.mjs";
|
|
9
9
|
import { useGridRegisterPipeProcessor } from "../../core/pipeProcessing/index.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.mjs";
|
|
4
4
|
import { useGridLogger } from "../../utils/useGridLogger.mjs";
|
|
@@ -9,4 +9,4 @@ export declare const rowSelectionStateInitializer: GridStateInitializer<Pick<Dat
|
|
|
9
9
|
* @requires useGridFocus (state) - can be after
|
|
10
10
|
* @requires useGridKeyboardNavigation (`cellKeyDown` event must first be consumed by it)
|
|
11
11
|
*/
|
|
12
|
-
export declare const useGridRowSelection: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'checkboxSelection' | 'rowSelectionModel' | 'onRowSelectionModelChange' | 'disableMultipleRowSelection' | 'disableRowSelectionOnClick' | 'disableRowSelectionExcludeModel' | 'isRowSelectable' | 'checkboxSelectionVisibleOnly' | 'pagination' | 'paginationMode' | 'filterMode' | 'classes' | 'keepNonExistentRowsSelected' | 'rowSelection' | 'rowSelectionPropagation' | 'signature'>) => void;
|
|
12
|
+
export declare const useGridRowSelection: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'checkboxSelection' | 'rowSelectionModel' | 'onRowSelectionModelChange' | 'disableMultipleRowSelection' | 'disableRowSelectionOnClick' | 'disableRowSelectionExcludeModel' | 'isRowSelectable' | 'checkboxSelectionVisibleOnly' | 'pagination' | 'paginationMode' | 'filterMode' | 'classes' | 'keepNonExistentRowsSelected' | 'rowSelection' | 'rowSelectionPropagation' | 'dataSource' | 'signature'>) => void;
|
|
@@ -9,4 +9,4 @@ export declare const rowSelectionStateInitializer: GridStateInitializer<Pick<Dat
|
|
|
9
9
|
* @requires useGridFocus (state) - can be after
|
|
10
10
|
* @requires useGridKeyboardNavigation (`cellKeyDown` event must first be consumed by it)
|
|
11
11
|
*/
|
|
12
|
-
export declare const useGridRowSelection: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'checkboxSelection' | 'rowSelectionModel' | 'onRowSelectionModelChange' | 'disableMultipleRowSelection' | 'disableRowSelectionOnClick' | 'disableRowSelectionExcludeModel' | 'isRowSelectable' | 'checkboxSelectionVisibleOnly' | 'pagination' | 'paginationMode' | 'filterMode' | 'classes' | 'keepNonExistentRowsSelected' | 'rowSelection' | 'rowSelectionPropagation' | 'signature'>) => void;
|
|
12
|
+
export declare const useGridRowSelection: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'checkboxSelection' | 'rowSelectionModel' | 'onRowSelectionModelChange' | 'disableMultipleRowSelection' | 'disableRowSelectionOnClick' | 'disableRowSelectionExcludeModel' | 'isRowSelectable' | 'checkboxSelectionVisibleOnly' | 'pagination' | 'paginationMode' | 'filterMode' | 'classes' | 'keepNonExistentRowsSelected' | 'rowSelection' | 'rowSelectionPropagation' | 'dataSource' | 'signature'>) => void;
|
|
@@ -17,6 +17,7 @@ var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
|
17
17
|
var _useGridLogger = require("../../utils/useGridLogger");
|
|
18
18
|
var _useGridSelector = require("../../utils/useGridSelector");
|
|
19
19
|
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
20
|
+
var _gridRowsUtils = require("../rows/gridRowsUtils");
|
|
20
21
|
var _gridRowSelectionSelector = require("./gridRowSelectionSelector");
|
|
21
22
|
var _gridFocusStateSelector = require("../focus/gridFocusStateSelector");
|
|
22
23
|
var _gridFilterSelector = require("../filter/gridFilterSelector");
|
|
@@ -127,6 +128,10 @@ You need to upgrade to DataGridPro or DataGridPremium component to unlock multip
|
|
|
127
128
|
if (props.rowSelection === false) {
|
|
128
129
|
return false;
|
|
129
130
|
}
|
|
131
|
+
const rowNode = (0, _gridRowsSelector.gridRowNodeSelector)(apiRef, id);
|
|
132
|
+
if (rowNode?.type === 'footer' || rowNode?.type === 'pinnedRow' || rowNode?.type === 'skeletonRow') {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
130
135
|
|
|
131
136
|
// If `keepNonExistentRowsSelected` is true, we might run in a case where row selectability is checked for a row that does not exist.
|
|
132
137
|
// Since that row was previously selected (otherwise it would not be checked at this point), we return true.
|
|
@@ -136,10 +141,6 @@ You need to upgrade to DataGridPro or DataGridPremium component to unlock multip
|
|
|
136
141
|
if (propIsRowSelectable && !propIsRowSelectable(apiRef.current.getRowParams(id))) {
|
|
137
142
|
return false;
|
|
138
143
|
}
|
|
139
|
-
const rowNode = (0, _gridRowsSelector.gridRowNodeSelector)(apiRef, id);
|
|
140
|
-
if (rowNode?.type === 'footer' || rowNode?.type === 'pinnedRow') {
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
144
|
return true;
|
|
144
145
|
}, [apiRef, props.rowSelection, props.keepNonExistentRowsSelected, propIsRowSelectable]);
|
|
145
146
|
const getSelectedRows = React.useCallback(() => (0, _gridRowSelectionSelector.gridRowSelectionIdsSelector)(apiRef), [apiRef]);
|
|
@@ -315,6 +316,7 @@ You need to upgrade to DataGridPro or DataGridPremium component to unlock multip
|
|
|
315
316
|
* EVENTS
|
|
316
317
|
*/
|
|
317
318
|
const isFirstRender = React.useRef(true);
|
|
319
|
+
const previousRowsLookupRef = React.useRef(null);
|
|
318
320
|
const removeOutdatedSelection = React.useCallback(() => {
|
|
319
321
|
if (isFirstRender.current) {
|
|
320
322
|
return;
|
|
@@ -323,6 +325,11 @@ You need to upgrade to DataGridPro or DataGridPremium component to unlock multip
|
|
|
323
325
|
const rowsLookup = (0, _gridRowsSelector.gridRowsLookupSelector)(apiRef);
|
|
324
326
|
const rowTree = (0, _gridRowsSelector.gridRowTreeSelector)(apiRef);
|
|
325
327
|
const filteredRowsLookup = (0, _gridFilterSelector.gridFilteredRowsLookupSelector)(apiRef);
|
|
328
|
+
const previousRowsLookup = previousRowsLookupRef.current;
|
|
329
|
+
previousRowsLookupRef.current = rowsLookup;
|
|
330
|
+
// Read the depth at call time. The event that runs this callback can fire in the same
|
|
331
|
+
// tick as the state update that changes the depth, before the render-scope value updates.
|
|
332
|
+
const isNested = (0, _gridRowsSelector.gridRowMaximumTreeDepthSelector)(apiRef) > 1;
|
|
326
333
|
const isNonExistent = id => {
|
|
327
334
|
if (props.filterMode === 'server') {
|
|
328
335
|
return !rowsLookup[id];
|
|
@@ -350,6 +357,32 @@ You need to upgrade to DataGridPro or DataGridPremium component to unlock multip
|
|
|
350
357
|
return node.children.some(childId => isOrHasSelectableDescendant(childId));
|
|
351
358
|
};
|
|
352
359
|
let hasChanged = false;
|
|
360
|
+
|
|
361
|
+
// Rows can load after their parent was selected (server-side lazy loading).
|
|
362
|
+
// They arrive unselected, so the parent re-derivation below would drop the parent.
|
|
363
|
+
// With `rowSelectionPropagation.descendants`, the rows that appeared since the last run
|
|
364
|
+
// inherit the selection state of their closest previously known ancestor instead.
|
|
365
|
+
if (isNested && props.rowSelectionPropagation?.descendants && currentSelection.type === 'include' && currentSelection.ids.size > 0 && previousRowsLookup !== null && previousRowsLookup !== rowsLookup) {
|
|
366
|
+
const isNewRow = id => rowsLookup[id] !== undefined && previousRowsLookup[id] === undefined;
|
|
367
|
+
const inheritsSelection = id => {
|
|
368
|
+
const parentId = rowTree[id]?.parent;
|
|
369
|
+
if (parentId == null || parentId === _gridRowsUtils.GRID_ROOT_GROUP_ID) {
|
|
370
|
+
return false;
|
|
371
|
+
}
|
|
372
|
+
if (selectionManager.has(parentId)) {
|
|
373
|
+
return true;
|
|
374
|
+
}
|
|
375
|
+
// A row that appeared together with its parent reads the state further up the chain.
|
|
376
|
+
return isNewRow(parentId) ? inheritsSelection(parentId) : false;
|
|
377
|
+
};
|
|
378
|
+
const dataRowIds = (0, _gridRowsSelector.gridDataRowIdsSelector)(apiRef);
|
|
379
|
+
for (const id of dataRowIds) {
|
|
380
|
+
if (isNewRow(id) && filteredRowsLookup[id] !== false && inheritsSelection(id) && apiRef.current.isRowSelectable(id)) {
|
|
381
|
+
selectionManager.select(id);
|
|
382
|
+
hasChanged = true;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
353
386
|
for (const id of currentSelection.ids) {
|
|
354
387
|
if (isNonExistent(id)) {
|
|
355
388
|
if (props.keepNonExistentRowsSelected) {
|
|
@@ -382,9 +415,10 @@ You need to upgrade to DataGridPro or DataGridPremium component to unlock multip
|
|
|
382
415
|
// For nested data, on row tree updation (filtering, adding rows, etc.) when the selection is
|
|
383
416
|
// not empty, we need to re-run scanning of the tree to propagate the selection changes
|
|
384
417
|
// Example: A parent whose de-selected children are filtered out should now be selected
|
|
385
|
-
|
|
386
|
-
//
|
|
387
|
-
|
|
418
|
+
// With a data source, an `exclude` model is left alone: the grid only knows the loaded
|
|
419
|
+
// subset of the rows, so rewriting the model into an `include` of the known rows would
|
|
420
|
+
// drop the "rows that load later are selected too" semantics of the select-all state.
|
|
421
|
+
const shouldReapplyPropagation = isNested && props.rowSelectionPropagation?.parents && (newSelectionModel.type === 'exclude' ? props.dataSource === undefined : newSelectionModel.ids.size > 0);
|
|
388
422
|
if (hasChanged || shouldReapplyPropagation) {
|
|
389
423
|
if (shouldReapplyPropagation) {
|
|
390
424
|
if (newSelectionModel.type === 'exclude') {
|
|
@@ -398,13 +432,20 @@ You need to upgrade to DataGridPro or DataGridPremium component to unlock multip
|
|
|
398
432
|
}
|
|
399
433
|
apiRef.current.selectRows(selectedRowIds, true, true);
|
|
400
434
|
} else {
|
|
401
|
-
|
|
435
|
+
// `getPropagatedRowSelectionModel` reads the sibling selection state from the model
|
|
436
|
+
// built above, so the rows selected during this run count for the parent derivation.
|
|
437
|
+
// `selectRows` would read the state from before this run instead.
|
|
438
|
+
const propagatedModel = apiRef.current.getPropagatedRowSelectionModel(newSelectionModel);
|
|
439
|
+
const isSelectionValid = propagatedModel.ids.size < 2 || canHaveMultipleSelection;
|
|
440
|
+
if (isSelectionValid && (propagatedModel.type !== currentSelection.type || propagatedModel.ids.size !== currentSelection.ids.size || !Array.from(propagatedModel.ids).every(id => currentSelection.ids.has(id)))) {
|
|
441
|
+
apiRef.current.setRowSelectionModel(propagatedModel, 'multipleRowsSelection');
|
|
442
|
+
}
|
|
402
443
|
}
|
|
403
444
|
} else {
|
|
404
445
|
apiRef.current.setRowSelectionModel(newSelectionModel, 'multipleRowsSelection');
|
|
405
446
|
}
|
|
406
447
|
}
|
|
407
|
-
}, [apiRef,
|
|
448
|
+
}, [apiRef, props.rowSelectionPropagation?.parents, props.rowSelectionPropagation?.descendants, props.keepNonExistentRowsSelected, props.filterMode, props.dataSource, canHaveMultipleSelection, getRowsToBeSelected]);
|
|
408
449
|
const handleSingleRowSelection = React.useCallback((id, event) => {
|
|
409
450
|
const hasCtrlKey = event.metaKey || event.ctrlKey;
|
|
410
451
|
|