@mui/x-data-grid 9.14.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 +176 -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.mjs +1 -1
- 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.mjs +1 -1
- package/components/cell/GridActionsCell.js +2 -2
- package/components/cell/GridActionsCell.mjs +5 -5
- package/components/cell/GridActionsCellItem.d.mts +20 -6
- package/components/cell/GridActionsCellItem.d.ts +20 -6
- package/components/cell/GridActionsCellItem.js +30 -7
- package/components/cell/GridActionsCellItem.mjs +32 -9
- package/components/cell/GridBooleanCell.mjs +2 -2
- package/components/cell/GridCell.js +1 -1
- package/components/cell/GridCell.mjs +3 -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.mjs +2 -2
- 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 +2 -2
- package/components/virtualization/GridVirtualScroller.mjs +3 -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.mjs +1 -1
- 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 +13 -28
- package/hooks/features/dataSource/useGridDataSourceBase.mjs +16 -31
- 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.mjs +1 -1
- package/hooks/features/rowSelection/useGridRowSelectionPreProcessors.mjs +1 -1
- 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 +5 -5
- 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
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.useGridDataSourcePolling = void 0;
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
12
|
+
/**
|
|
13
|
+
* Calls a revalidation callback at the `revalidateMs` interval.
|
|
14
|
+
* The polling pauses while `<Activity>` hides the grid and stops after the grid unmounts.
|
|
15
|
+
*/
|
|
16
|
+
const useGridDataSourcePolling = ({
|
|
17
|
+
revalidateMs,
|
|
18
|
+
isActive,
|
|
19
|
+
shouldResume = () => true
|
|
20
|
+
}) => {
|
|
21
|
+
const pollingIntervalRef = React.useRef(null);
|
|
22
|
+
const pollingCallbackRef = React.useRef(null);
|
|
23
|
+
// `false` while Activity is hidden or after unmount, so a late response cannot restart polling.
|
|
24
|
+
const isPollingAllowed = React.useRef(true);
|
|
25
|
+
const stopPolling = React.useCallback(() => {
|
|
26
|
+
if (pollingIntervalRef.current !== null) {
|
|
27
|
+
clearInterval(pollingIntervalRef.current);
|
|
28
|
+
pollingIntervalRef.current = null;
|
|
29
|
+
}
|
|
30
|
+
}, []);
|
|
31
|
+
const startPolling = (0, _useEventCallback.default)(callback => {
|
|
32
|
+
stopPolling();
|
|
33
|
+
// Keep the callback while Activity is hidden to resume the polling on show.
|
|
34
|
+
pollingCallbackRef.current = callback;
|
|
35
|
+
if (!isPollingAllowed.current || !isActive || revalidateMs <= 0) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
pollingIntervalRef.current = setInterval(callback, revalidateMs);
|
|
39
|
+
});
|
|
40
|
+
React.useEffect(() => {
|
|
41
|
+
if (!isActive || revalidateMs <= 0) {
|
|
42
|
+
stopPolling();
|
|
43
|
+
}
|
|
44
|
+
}, [isActive, revalidateMs, stopPolling]);
|
|
45
|
+
const canResume = (0, _useEventCallback.default)(shouldResume);
|
|
46
|
+
React.useEffect(() => {
|
|
47
|
+
isPollingAllowed.current = true;
|
|
48
|
+
// Activity runs the effects again when it shows the grid, so resume the paused polling.
|
|
49
|
+
if (pollingCallbackRef.current && canResume()) {
|
|
50
|
+
startPolling(pollingCallbackRef.current);
|
|
51
|
+
}
|
|
52
|
+
return () => {
|
|
53
|
+
isPollingAllowed.current = false;
|
|
54
|
+
stopPolling();
|
|
55
|
+
};
|
|
56
|
+
}, [startPolling, stopPolling, canResume]);
|
|
57
|
+
return {
|
|
58
|
+
startPolling,
|
|
59
|
+
stopPolling
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
exports.useGridDataSourcePolling = useGridDataSourcePolling;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
5
|
+
/**
|
|
6
|
+
* Calls a revalidation callback at the `revalidateMs` interval.
|
|
7
|
+
* The polling pauses while `<Activity>` hides the grid and stops after the grid unmounts.
|
|
8
|
+
*/
|
|
9
|
+
export const useGridDataSourcePolling = ({
|
|
10
|
+
revalidateMs,
|
|
11
|
+
isActive,
|
|
12
|
+
shouldResume = () => true
|
|
13
|
+
}) => {
|
|
14
|
+
const pollingIntervalRef = React.useRef(null);
|
|
15
|
+
const pollingCallbackRef = React.useRef(null);
|
|
16
|
+
// `false` while Activity is hidden or after unmount, so a late response cannot restart polling.
|
|
17
|
+
const isPollingAllowed = React.useRef(true);
|
|
18
|
+
const stopPolling = React.useCallback(() => {
|
|
19
|
+
if (pollingIntervalRef.current !== null) {
|
|
20
|
+
clearInterval(pollingIntervalRef.current);
|
|
21
|
+
pollingIntervalRef.current = null;
|
|
22
|
+
}
|
|
23
|
+
}, []);
|
|
24
|
+
const startPolling = useEventCallback(callback => {
|
|
25
|
+
stopPolling();
|
|
26
|
+
// Keep the callback while Activity is hidden to resume the polling on show.
|
|
27
|
+
pollingCallbackRef.current = callback;
|
|
28
|
+
if (!isPollingAllowed.current || !isActive || revalidateMs <= 0) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
pollingIntervalRef.current = setInterval(callback, revalidateMs);
|
|
32
|
+
});
|
|
33
|
+
React.useEffect(() => {
|
|
34
|
+
if (!isActive || revalidateMs <= 0) {
|
|
35
|
+
stopPolling();
|
|
36
|
+
}
|
|
37
|
+
}, [isActive, revalidateMs, stopPolling]);
|
|
38
|
+
const canResume = useEventCallback(shouldResume);
|
|
39
|
+
React.useEffect(() => {
|
|
40
|
+
isPollingAllowed.current = true;
|
|
41
|
+
// Activity runs the effects again when it shows the grid, so resume the paused polling.
|
|
42
|
+
if (pollingCallbackRef.current && canResume()) {
|
|
43
|
+
startPolling(pollingCallbackRef.current);
|
|
44
|
+
}
|
|
45
|
+
return () => {
|
|
46
|
+
isPollingAllowed.current = false;
|
|
47
|
+
stopPolling();
|
|
48
|
+
};
|
|
49
|
+
}, [startPolling, stopPolling, canResume]);
|
|
50
|
+
return {
|
|
51
|
+
startPolling,
|
|
52
|
+
stopPolling
|
|
53
|
+
};
|
|
54
|
+
};
|
|
@@ -3,7 +3,7 @@ export declare enum DataSourceRowsUpdateStrategy {
|
|
|
3
3
|
Default = "set-flat-rows",
|
|
4
4
|
LazyLoading = "replace-row-range",
|
|
5
5
|
GroupedData = "set-grouped-rows",
|
|
6
|
-
LazyLoadedGroupedData = "replace-grouped-row-range"
|
|
6
|
+
LazyLoadedGroupedData = "replace-grouped-row-range"
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Provides better cache hit rate by:
|
|
@@ -3,7 +3,7 @@ export declare enum DataSourceRowsUpdateStrategy {
|
|
|
3
3
|
Default = "set-flat-rows",
|
|
4
4
|
LazyLoading = "replace-row-range",
|
|
5
5
|
GroupedData = "set-grouped-rows",
|
|
6
|
-
LazyLoadedGroupedData = "replace-grouped-row-range"
|
|
6
|
+
LazyLoadedGroupedData = "replace-grouped-row-range"
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Provides better cache hit rate by:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
export let DataSourceRowsUpdateStrategy = /*#__PURE__*/function (DataSourceRowsUpdateStrategy) {
|
|
3
3
|
DataSourceRowsUpdateStrategy["Default"] = "set-flat-rows";
|
|
4
4
|
DataSourceRowsUpdateStrategy["LazyLoading"] = "replace-row-range";
|
|
@@ -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 useEventCallback from '@mui/utils/useEventCallback';
|
|
6
6
|
import { useGridLogger } from "../../utils/useGridLogger.mjs";
|
|
@@ -3,7 +3,7 @@ import type { GridPrivateApiCommunity } from "../../../models/api/gridApiCommuni
|
|
|
3
3
|
import type { DataGridProcessedProps } from "../../../models/props/DataGridProps.mjs";
|
|
4
4
|
import type { GridDimensions } from "./gridDimensionsApi.mjs";
|
|
5
5
|
import type { GridStateInitializer } from "../../utils/useGridInitializeState.mjs";
|
|
6
|
-
type RootProps = Pick<DataGridProcessedProps, 'onResize' | 'scrollbarSize' | 'pagination' | 'paginationMode' | 'autoHeight' | 'getRowHeight' | 'rowHeight' | 'resizeThrottleMs' | 'columnHeaderHeight' | 'columnGroupHeaderHeight' | 'headerFilterHeight'>;
|
|
6
|
+
type RootProps = Pick<DataGridProcessedProps, 'onResize' | 'scrollbarSize' | 'pagination' | 'paginationMode' | 'autoHeight' | 'height' | 'getRowHeight' | 'rowHeight' | 'resizeThrottleMs' | 'columnHeaderHeight' | 'columnGroupHeaderHeight' | 'headerFilterHeight'>;
|
|
7
7
|
export type GridDimensionsState = GridDimensions;
|
|
8
8
|
export declare const dimensionsStateInitializer: GridStateInitializer<RootProps>;
|
|
9
9
|
export declare function useGridDimensions(apiRef: RefObject<GridPrivateApiCommunity>, props: RootProps): void;
|
|
@@ -3,7 +3,7 @@ import type { GridPrivateApiCommunity } from "../../../models/api/gridApiCommuni
|
|
|
3
3
|
import type { DataGridProcessedProps } from "../../../models/props/DataGridProps.js";
|
|
4
4
|
import type { GridDimensions } from "./gridDimensionsApi.js";
|
|
5
5
|
import type { GridStateInitializer } from "../../utils/useGridInitializeState.js";
|
|
6
|
-
type RootProps = Pick<DataGridProcessedProps, 'onResize' | 'scrollbarSize' | 'pagination' | 'paginationMode' | 'autoHeight' | 'getRowHeight' | 'rowHeight' | 'resizeThrottleMs' | 'columnHeaderHeight' | 'columnGroupHeaderHeight' | 'headerFilterHeight'>;
|
|
6
|
+
type RootProps = Pick<DataGridProcessedProps, 'onResize' | 'scrollbarSize' | 'pagination' | 'paginationMode' | 'autoHeight' | 'height' | 'getRowHeight' | 'rowHeight' | 'resizeThrottleMs' | 'columnHeaderHeight' | 'columnGroupHeaderHeight' | 'headerFilterHeight'>;
|
|
7
7
|
export type GridDimensionsState = GridDimensions;
|
|
8
8
|
export declare const dimensionsStateInitializer: GridStateInitializer<RootProps>;
|
|
9
9
|
export declare function useGridDimensions(apiRef: RefObject<GridPrivateApiCommunity>, props: RootProps): void;
|
|
@@ -11,7 +11,7 @@ exports.useGridDimensions = useGridDimensions;
|
|
|
11
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _platform = require("@base-ui/utils/platform");
|
|
14
|
-
var
|
|
14
|
+
var _useStoreEffect = require("@mui/x-internals/useStoreEffect");
|
|
15
15
|
var _useGridEvent = require("../../utils/useGridEvent");
|
|
16
16
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
17
17
|
var _createSelector = require("../../../utils/createSelector");
|
|
@@ -96,7 +96,7 @@ function useGridDimensions(apiRef, props) {
|
|
|
96
96
|
if (!getRootDimensions().isReady) {
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
|
-
if (size.height === 0 && !errorShown.current && !props.autoHeight && !_platform.platform.env.jsdom) {
|
|
99
|
+
if (size.height === 0 && props.height == null && !errorShown.current && !props.autoHeight && !_platform.platform.env.jsdom) {
|
|
100
100
|
logger.error(['The parent DOM element of the Data Grid has an empty height.', 'Please make sure that this element has an intrinsic height.', 'The grid displays with a height of 0px.', '', 'More details: https://mui.com/r/x-data-grid-no-dimensions.'].join('\n'));
|
|
101
101
|
errorShown.current = true;
|
|
102
102
|
}
|
|
@@ -107,7 +107,7 @@ function useGridDimensions(apiRef, props) {
|
|
|
107
107
|
});
|
|
108
108
|
/* eslint-enable react-hooks/rules-of-hooks */
|
|
109
109
|
}
|
|
110
|
-
(0,
|
|
110
|
+
(0, _useStoreEffect.useStoreEffect)(apiRef.current.store, s => s.dimensions, (previous, next) => {
|
|
111
111
|
if (!next.isReady) {
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
@@ -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 { platform } from '@base-ui/utils/platform';
|
|
6
|
-
import { useStoreEffect } from '@mui/x-internals/
|
|
6
|
+
import { useStoreEffect } from '@mui/x-internals/useStoreEffect';
|
|
7
7
|
import { useGridEventPriority } from "../../utils/useGridEvent.mjs";
|
|
8
8
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.mjs";
|
|
9
9
|
import { createSelector } from "../../../utils/createSelector.mjs";
|
|
@@ -87,7 +87,7 @@ export function useGridDimensions(apiRef, props) {
|
|
|
87
87
|
if (!getRootDimensions().isReady) {
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
|
-
if (size.height === 0 && !errorShown.current && !props.autoHeight && !platform.env.jsdom) {
|
|
90
|
+
if (size.height === 0 && props.height == null && !errorShown.current && !props.autoHeight && !platform.env.jsdom) {
|
|
91
91
|
logger.error(['The parent DOM element of the Data Grid has an empty height.', 'Please make sure that this element has an intrinsic height.', 'The grid displays with a height of 0px.', '', 'More details: https://mui.com/r/x-data-grid-no-dimensions.'].join('\n'));
|
|
92
92
|
errorShown.current = true;
|
|
93
93
|
}
|
|
@@ -382,7 +382,7 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
382
382
|
if (onProcessRowUpdateError) {
|
|
383
383
|
onProcessRowUpdateError(errorThrown);
|
|
384
384
|
} else if (process.env.NODE_ENV !== 'production') {
|
|
385
|
-
(0, _warning.
|
|
385
|
+
(0, _warning.errorOnce)(['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/.'].join('\n'));
|
|
386
386
|
}
|
|
387
387
|
};
|
|
388
388
|
try {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/
|
|
4
|
-
import _toPropertyKey from "@babel/runtime/helpers/
|
|
5
|
-
import _extends from "@babel/runtime/helpers/
|
|
3
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
4
|
+
import _toPropertyKey from "@babel/runtime/helpers/toPropertyKey";
|
|
5
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
6
6
|
import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
|
|
7
7
|
const _excluded = ["id", "field"],
|
|
8
8
|
_excluded2 = ["id", "field"];
|
|
9
9
|
import * as React from 'react';
|
|
10
|
-
import {
|
|
10
|
+
import { errorOnce } from '@mui/x-internals/warning';
|
|
11
11
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
12
12
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
13
13
|
import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
|
|
@@ -375,7 +375,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
375
375
|
if (onProcessRowUpdateError) {
|
|
376
376
|
onProcessRowUpdateError(errorThrown);
|
|
377
377
|
} else if (process.env.NODE_ENV !== 'production') {
|
|
378
|
-
|
|
378
|
+
errorOnce(['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/.'].join('\n'));
|
|
379
379
|
}
|
|
380
380
|
};
|
|
381
381
|
try {
|
|
@@ -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 { useGridCellEditing } from "./useGridCellEditing.mjs";
|
|
@@ -472,7 +472,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
472
472
|
if (onProcessRowUpdateError) {
|
|
473
473
|
onProcessRowUpdateError(errorThrown);
|
|
474
474
|
} else if (process.env.NODE_ENV !== 'production') {
|
|
475
|
-
(0, _warning.
|
|
475
|
+
(0, _warning.errorOnce)(['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/.'].join('\n'));
|
|
476
476
|
}
|
|
477
477
|
};
|
|
478
478
|
try {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _toPropertyKey from "@babel/runtime/helpers/
|
|
4
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/
|
|
5
|
-
import _extends from "@babel/runtime/helpers/
|
|
3
|
+
import _toPropertyKey from "@babel/runtime/helpers/toPropertyKey";
|
|
4
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
5
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
6
6
|
import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
|
|
7
7
|
const _excluded = ["id"],
|
|
8
8
|
_excluded2 = ["id"];
|
|
9
9
|
import * as React from 'react';
|
|
10
10
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
11
11
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
12
|
-
import {
|
|
12
|
+
import { errorOnce } from '@mui/x-internals/warning';
|
|
13
13
|
import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
|
|
14
14
|
import { useGridEvent, useGridEventPriority } from "../../utils/useGridEvent.mjs";
|
|
15
15
|
import { GridEditModes, GridRowModes } from "../../../models/gridEditRowModel.mjs";
|
|
@@ -465,7 +465,7 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
465
465
|
if (onProcessRowUpdateError) {
|
|
466
466
|
onProcessRowUpdateError(errorThrown);
|
|
467
467
|
} else if (process.env.NODE_ENV !== 'production') {
|
|
468
|
-
|
|
468
|
+
errorOnce(['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/.'].join('\n'));
|
|
469
469
|
}
|
|
470
470
|
};
|
|
471
471
|
try {
|
|
@@ -86,7 +86,7 @@ const serializeRow = ({
|
|
|
86
86
|
const cellParams = getCellParams(id, column.field);
|
|
87
87
|
if (String(cellParams.formattedValue) === '[object Object]') {
|
|
88
88
|
if (process.env.NODE_ENV !== 'production') {
|
|
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.']);
|
|
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.'].join('\n'));
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
row.addValue(serializeCellValue(cellParams, {
|
|
@@ -104,13 +104,13 @@ function buildCSV(options) {
|
|
|
104
104
|
ignoreValueFormatter,
|
|
105
105
|
apiRef
|
|
106
106
|
} = options;
|
|
107
|
-
const CSVBody = rowIds.
|
|
107
|
+
const CSVBody = rowIds.map(id => serializeRow({
|
|
108
108
|
id,
|
|
109
109
|
columns,
|
|
110
110
|
getCellParams: apiRef.current.getCellParams,
|
|
111
111
|
ignoreValueFormatter,
|
|
112
112
|
csvOptions
|
|
113
|
-
})
|
|
113
|
+
})).join('\r\n');
|
|
114
114
|
if (!csvOptions.includeHeaders) {
|
|
115
115
|
return CSVBody;
|
|
116
116
|
}
|
|
@@ -146,6 +146,6 @@ function buildCSV(options) {
|
|
|
146
146
|
mainHeaderRow.addValue(column.headerName || column.field);
|
|
147
147
|
});
|
|
148
148
|
headerRows.push(mainHeaderRow);
|
|
149
|
-
const CSVHead =
|
|
150
|
-
return `${CSVHead}${CSVBody}
|
|
149
|
+
const CSVHead = headerRows.map(row => row.getRowString()).join('\r\n');
|
|
150
|
+
return rowIds.length > 0 ? `${CSVHead}\r\n${CSVBody}` : CSVHead;
|
|
151
151
|
}
|
|
@@ -78,7 +78,7 @@ const serializeRow = ({
|
|
|
78
78
|
const cellParams = getCellParams(id, column.field);
|
|
79
79
|
if (String(cellParams.formattedValue) === '[object Object]') {
|
|
80
80
|
if (process.env.NODE_ENV !== 'production') {
|
|
81
|
-
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.']);
|
|
81
|
+
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.'].join('\n'));
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
row.addValue(serializeCellValue(cellParams, {
|
|
@@ -96,13 +96,13 @@ export function buildCSV(options) {
|
|
|
96
96
|
ignoreValueFormatter,
|
|
97
97
|
apiRef
|
|
98
98
|
} = options;
|
|
99
|
-
const CSVBody = rowIds.
|
|
99
|
+
const CSVBody = rowIds.map(id => serializeRow({
|
|
100
100
|
id,
|
|
101
101
|
columns,
|
|
102
102
|
getCellParams: apiRef.current.getCellParams,
|
|
103
103
|
ignoreValueFormatter,
|
|
104
104
|
csvOptions
|
|
105
|
-
})
|
|
105
|
+
})).join('\r\n');
|
|
106
106
|
if (!csvOptions.includeHeaders) {
|
|
107
107
|
return CSVBody;
|
|
108
108
|
}
|
|
@@ -138,6 +138,6 @@ export function buildCSV(options) {
|
|
|
138
138
|
mainHeaderRow.addValue(column.headerName || column.field);
|
|
139
139
|
});
|
|
140
140
|
headerRows.push(mainHeaderRow);
|
|
141
|
-
const CSVHead =
|
|
142
|
-
return `${CSVHead}${CSVBody}
|
|
141
|
+
const CSVHead = headerRows.map(row => row.getRowString()).join('\r\n');
|
|
142
|
+
return rowIds.length > 0 ? `${CSVHead}\r\n${CSVBody}` : CSVHead;
|
|
143
143
|
}
|
|
@@ -98,7 +98,7 @@ const useGridPrintExport = (apiRef, props) => {
|
|
|
98
98
|
}, []);
|
|
99
99
|
apiRef.current.setRows(newRows);
|
|
100
100
|
}, [apiRef]);
|
|
101
|
-
const handlePrintWindowLoad = React.useCallback((printWindow, options) => {
|
|
101
|
+
const handlePrintWindowLoad = React.useCallback(async (printWindow, options) => {
|
|
102
102
|
const normalizeOptions = (0, _extends2.default)({
|
|
103
103
|
copyStyles: true,
|
|
104
104
|
hideToolbar: false,
|
|
@@ -107,7 +107,7 @@ const useGridPrintExport = (apiRef, props) => {
|
|
|
107
107
|
}, options);
|
|
108
108
|
const printDoc = printWindow.contentDocument;
|
|
109
109
|
if (!printDoc) {
|
|
110
|
-
return;
|
|
110
|
+
return false;
|
|
111
111
|
}
|
|
112
112
|
const gridRootElement = apiRef.current.rootElementRef.current;
|
|
113
113
|
const gridClone = gridRootElement.cloneNode(true);
|
|
@@ -136,6 +136,8 @@ const useGridPrintExport = (apiRef, props) => {
|
|
|
136
136
|
gridFooterElement.remove();
|
|
137
137
|
}
|
|
138
138
|
gridClone.style.height = 'auto';
|
|
139
|
+
gridClone.style.minHeight = '0';
|
|
140
|
+
gridClone.style.maxHeight = 'none';
|
|
139
141
|
// The height above does not include grid border width, so we need to exclude it
|
|
140
142
|
gridClone.style.boxSizing = 'content-box';
|
|
141
143
|
if (!normalizeOptions.hideFooter && gridFooterElement) {
|
|
@@ -166,16 +168,23 @@ const useGridPrintExport = (apiRef, props) => {
|
|
|
166
168
|
if (normalizeOptions.copyStyles) {
|
|
167
169
|
const rootCandidate = gridRootElement.getRootNode();
|
|
168
170
|
const root = rootCandidate.constructor.name === 'ShadowRoot' ? rootCandidate : doc.current;
|
|
169
|
-
stylesheetLoadPromises = (0, _export.loadStyleSheets)(printDoc, root
|
|
171
|
+
stylesheetLoadPromises = (0, _export.loadStyleSheets)(printDoc, root, {
|
|
172
|
+
onStylesheetError: normalizeOptions.onStylesheetError
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// wait for remote stylesheets to load
|
|
177
|
+
const loaded = await Promise.all(stylesheetLoadPromises);
|
|
178
|
+
if (loaded.includes(false)) {
|
|
179
|
+
// `onStylesheetError` cancelled the print
|
|
180
|
+
return false;
|
|
170
181
|
}
|
|
171
182
|
|
|
172
183
|
// Trigger print
|
|
173
184
|
if (process.env.NODE_ENV !== 'test' && !DEBUG_MODE) {
|
|
174
|
-
|
|
175
|
-
Promise.all(stylesheetLoadPromises).then(() => {
|
|
176
|
-
printWindow.contentWindow.print();
|
|
177
|
-
});
|
|
185
|
+
printWindow.contentWindow.print();
|
|
178
186
|
}
|
|
187
|
+
return true;
|
|
179
188
|
}, [apiRef, doc]);
|
|
180
189
|
const handlePrintWindowAfterPrint = React.useCallback(printWindow => {
|
|
181
190
|
// Remove the print iframe
|
|
@@ -228,21 +237,36 @@ const useGridPrintExport = (apiRef, props) => {
|
|
|
228
237
|
const printWindow = buildPrintWindow(options?.fileName);
|
|
229
238
|
if (process.env.NODE_ENV === 'test') {
|
|
230
239
|
doc.current.body.appendChild(printWindow);
|
|
231
|
-
// In test env, run the all pipeline without waiting for
|
|
232
|
-
|
|
233
|
-
|
|
240
|
+
// In test env, run the all pipeline without waiting for the iframe to load or the print dialog
|
|
241
|
+
try {
|
|
242
|
+
await handlePrintWindowLoad(printWindow, options);
|
|
243
|
+
} finally {
|
|
244
|
+
handlePrintWindowAfterPrint(printWindow);
|
|
245
|
+
}
|
|
234
246
|
} else {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
247
|
+
await new Promise((resolve, reject) => {
|
|
248
|
+
printWindow.onload = () => {
|
|
249
|
+
const mediaQueryList = printWindow.contentWindow.matchMedia('print');
|
|
250
|
+
mediaQueryList.addEventListener('change', mql => {
|
|
251
|
+
const isAfterPrint = mql.matches === false;
|
|
252
|
+
if (isAfterPrint) {
|
|
253
|
+
handlePrintWindowAfterPrint(printWindow);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
handlePrintWindowLoad(printWindow, options).then(printed => {
|
|
257
|
+
if (!printed) {
|
|
258
|
+
// The print dialog never opens, so restore the grid here
|
|
259
|
+
handlePrintWindowAfterPrint(printWindow);
|
|
260
|
+
}
|
|
261
|
+
resolve();
|
|
262
|
+
}, error => {
|
|
263
|
+
// The print dialog never opens, so restore the grid here
|
|
241
264
|
handlePrintWindowAfterPrint(printWindow);
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
265
|
+
reject(error);
|
|
266
|
+
});
|
|
267
|
+
};
|
|
268
|
+
doc.current.body.appendChild(printWindow);
|
|
269
|
+
});
|
|
246
270
|
}
|
|
247
271
|
}, [props, logger, apiRef, handlePrintWindowLoad, handlePrintWindowAfterPrint, updateGridColumnsForPrint, updateGridRowsForPrint]);
|
|
248
272
|
const printExportApi = {
|
|
@@ -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, {
|