@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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
|
|
4
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/
|
|
5
|
-
import _toPropertyKey from "@babel/runtime/helpers/
|
|
4
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
5
|
+
import _toPropertyKey from "@babel/runtime/helpers/toPropertyKey";
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { GridStrategyGroup } from "./gridStrategyProcessingApi.mjs";
|
|
8
8
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.mjs";
|
|
@@ -9,7 +9,7 @@ exports.unwrapPrivateAPI = unwrapPrivateAPI;
|
|
|
9
9
|
exports.useGridApiInitialization = useGridApiInitialization;
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _EventManager = require("@mui/x-internals/EventManager");
|
|
12
|
-
var _store = require("@
|
|
12
|
+
var _store = require("@base-ui/utils/store");
|
|
13
13
|
var _useGridApiMethod = require("../utils/useGridApiMethod");
|
|
14
14
|
var _signature = require("../../constants/signature");
|
|
15
15
|
var _getPublicApiRef = require("../../utils/getPublicApiRef");
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { EventManager } from '@mui/x-internals/EventManager';
|
|
5
|
-
import { Store } from '@
|
|
5
|
+
import { Store } from '@base-ui/utils/store';
|
|
6
6
|
import { useGridApiMethod } from "../utils/useGridApiMethod.mjs";
|
|
7
7
|
import { GridSignature } from "../../constants/signature.mjs";
|
|
8
8
|
import { getPublicApiRef } from "../../utils/getPublicApiRef.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 _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import { useGridApiMethod } from "../utils/index.mjs";
|
|
@@ -4,10 +4,10 @@ import { Dimensions, LayoutDataGrid, Virtualization } from '@mui/x-virtualizer';
|
|
|
4
4
|
* Virtualizer setup
|
|
5
5
|
*/
|
|
6
6
|
export declare function useGridVirtualizer(): {
|
|
7
|
-
store: import("@
|
|
7
|
+
store: import("@base-ui/utils/store").Store<Dimensions.State & Virtualization.State<LayoutDataGrid> & import("@mui/x-virtualizer").Colspan.State & import("@mui/x-virtualizer").Rowspan.State>;
|
|
8
8
|
api: {
|
|
9
9
|
updateDimensions: (firstUpdate?: boolean) => void;
|
|
10
|
-
debouncedUpdateDimensions: ((
|
|
10
|
+
debouncedUpdateDimensions: ((firstUpdate?: boolean) => void) & import("@mui/x-internals/throttle").Cancelable | undefined;
|
|
11
11
|
rowsMeta: {
|
|
12
12
|
getRowHeight: (rowId: import("@mui/x-virtualizer").RowId) => any;
|
|
13
13
|
setLastMeasuredRowIndex: (index: number) => void;
|
|
@@ -4,10 +4,10 @@ import { Dimensions, LayoutDataGrid, Virtualization } from '@mui/x-virtualizer';
|
|
|
4
4
|
* Virtualizer setup
|
|
5
5
|
*/
|
|
6
6
|
export declare function useGridVirtualizer(): {
|
|
7
|
-
store: import("@
|
|
7
|
+
store: import("@base-ui/utils/store").Store<Dimensions.State & Virtualization.State<LayoutDataGrid> & import("@mui/x-virtualizer").Colspan.State & import("@mui/x-virtualizer").Rowspan.State>;
|
|
8
8
|
api: {
|
|
9
9
|
updateDimensions: (firstUpdate?: boolean) => void;
|
|
10
|
-
debouncedUpdateDimensions: ((
|
|
10
|
+
debouncedUpdateDimensions: ((firstUpdate?: boolean) => void) & import("@mui/x-internals/throttle").Cancelable | undefined;
|
|
11
11
|
rowsMeta: {
|
|
12
12
|
getRowHeight: (rowId: import("@mui/x-virtualizer").RowId) => any;
|
|
13
13
|
setLastMeasuredRowIndex: (index: number) => void;
|
|
@@ -13,9 +13,9 @@ var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallb
|
|
|
13
13
|
var _RtlProvider = require("@mui/system/RtlProvider");
|
|
14
14
|
var _math = require("@mui/x-internals/math");
|
|
15
15
|
var _lruMemoize = require("@mui/x-internals/lruMemoize");
|
|
16
|
-
var
|
|
16
|
+
var _useStoreEffect = require("@mui/x-internals/useStoreEffect");
|
|
17
17
|
var _xVirtualizer = require("@mui/x-virtualizer");
|
|
18
|
-
var
|
|
18
|
+
var _useOnFirstRender = require("@base-ui/utils/useOnFirstRender");
|
|
19
19
|
var _createSelector = require("../../utils/createSelector");
|
|
20
20
|
var _useGridSelector = require("../utils/useGridSelector");
|
|
21
21
|
var _gridDimensionsSelectors = require("../features/dimensions/gridDimensionsSelectors");
|
|
@@ -252,12 +252,12 @@ function useGridVirtualizer() {
|
|
|
252
252
|
// initialization code runs between those two moments.
|
|
253
253
|
//
|
|
254
254
|
// TODO(v9): Remove this
|
|
255
|
-
(0,
|
|
255
|
+
(0, _useOnFirstRender.useOnFirstRender)(() => {
|
|
256
256
|
apiRef.current.store.state.dimensions = addGridDimensions(virtualizer.store.state.dimensions, headerHeight, groupHeaderHeight, headerFilterHeight, headersTotalHeight);
|
|
257
257
|
apiRef.current.store.state.rowsMeta = virtualizer.store.state.rowsMeta;
|
|
258
258
|
apiRef.current.store.state.virtualization = virtualizer.store.state.virtualization;
|
|
259
259
|
});
|
|
260
|
-
(0,
|
|
260
|
+
(0, _useStoreEffect.useStoreEffect)(virtualizer.store, _xVirtualizer.Dimensions.selectors.dimensions, (_, dimensions) => {
|
|
261
261
|
if (!dimensions.isReady) {
|
|
262
262
|
return;
|
|
263
263
|
}
|
|
@@ -265,14 +265,14 @@ function useGridVirtualizer() {
|
|
|
265
265
|
dimensions: addGridDimensions(dimensions, headerHeight, groupHeaderHeight, headerFilterHeight, headersTotalHeight)
|
|
266
266
|
}));
|
|
267
267
|
});
|
|
268
|
-
(0,
|
|
268
|
+
(0, _useStoreEffect.useStoreEffect)(virtualizer.store, _xVirtualizer.Dimensions.selectors.rowsMeta, (_, rowsMeta) => {
|
|
269
269
|
if (rowsMeta !== apiRef.current.state.rowsMeta) {
|
|
270
270
|
apiRef.current.setState(gridState => (0, _extends2.default)({}, gridState, {
|
|
271
271
|
rowsMeta
|
|
272
272
|
}));
|
|
273
273
|
}
|
|
274
274
|
});
|
|
275
|
-
(0,
|
|
275
|
+
(0, _useStoreEffect.useStoreEffect)(virtualizer.store, _xVirtualizer.Virtualization.selectors.store, (_, virtualization) => {
|
|
276
276
|
if (virtualization.renderContext === _xVirtualizer.EMPTY_RENDER_CONTEXT) {
|
|
277
277
|
return;
|
|
278
278
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
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 useLazyRef from '@mui/utils/useLazyRef';
|
|
4
4
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
5
5
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
6
6
|
import { roundToDecimalPlaces } from '@mui/x-internals/math';
|
|
7
7
|
import { lruMemoize } from '@mui/x-internals/lruMemoize';
|
|
8
|
-
import { useStoreEffect } from '@mui/x-internals/
|
|
8
|
+
import { useStoreEffect } from '@mui/x-internals/useStoreEffect';
|
|
9
9
|
import { useVirtualizer, Dimensions, LayoutDataGrid, Virtualization, EMPTY_RENDER_CONTEXT } from '@mui/x-virtualizer';
|
|
10
|
-
import {
|
|
10
|
+
import { useOnFirstRender } from '@base-ui/utils/useOnFirstRender';
|
|
11
11
|
import { createSelector } from "../../utils/createSelector.mjs";
|
|
12
12
|
import { useGridSelector } from "../utils/useGridSelector.mjs";
|
|
13
13
|
import { gridHasFillerSelector, gridVerticalScrollbarWidthSelector } from "../features/dimensions/gridDimensionsSelectors.mjs";
|
|
@@ -244,7 +244,7 @@ export function useGridVirtualizer() {
|
|
|
244
244
|
// initialization code runs between those two moments.
|
|
245
245
|
//
|
|
246
246
|
// TODO(v9): Remove this
|
|
247
|
-
|
|
247
|
+
useOnFirstRender(() => {
|
|
248
248
|
apiRef.current.store.state.dimensions = addGridDimensions(virtualizer.store.state.dimensions, headerHeight, groupHeaderHeight, headerFilterHeight, headersTotalHeight);
|
|
249
249
|
apiRef.current.store.state.rowsMeta = virtualizer.store.state.rowsMeta;
|
|
250
250
|
apiRef.current.store.state.virtualization = virtualizer.store.state.virtualization;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
|
|
3
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/
|
|
3
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
4
4
|
const _excluded = ["groupId", "children"];
|
|
5
5
|
import { isLeaf } from "../../../models/gridColumnGrouping.mjs";
|
|
6
6
|
export const createGroupLookup = columnGroupingModel => {
|
|
@@ -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 { gridColumnGroupsLookupSelector, gridColumnGroupsUnwrappedModelSelector } from "./gridColumnGroupsSelector.mjs";
|
|
6
6
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
/**
|
|
3
3
|
* Returns the list of column menu item keys (sorted by `displayOrder`) that should be rendered for a given column.
|
|
4
4
|
* This is shared between the column header (to know if menu is empty) and the menu itself (to render items).
|
|
@@ -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, useGridEvent } from "../../utils/index.mjs";
|
|
6
6
|
import { gridColumnMenuSelector } from "./columnMenuSelector.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/
|
|
2
|
-
import _extends from "@babel/runtime/helpers/
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
const _excluded = ["displayOrder"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { useGridRootProps } from "../../utils/useGridRootProps.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 useEventCallback from '@mui/utils/useEventCallback';
|
|
6
6
|
import ownerDocument from '@mui/utils/ownerDocument';
|
|
@@ -2,7 +2,7 @@ import type { GridColDef, GridStateColDef } from "../../../models/colDef/gridCol
|
|
|
2
2
|
import type { GridColumnDimensionProperties } from "./gridColumnsUtils.mjs";
|
|
3
3
|
export declare enum GridPinnedColumnPosition {
|
|
4
4
|
LEFT = "left",
|
|
5
|
-
RIGHT = "right"
|
|
5
|
+
RIGHT = "right"
|
|
6
6
|
}
|
|
7
7
|
export type GridColumnLookup = {
|
|
8
8
|
[field: string]: GridStateColDef;
|
|
@@ -2,7 +2,7 @@ import type { GridColDef, GridStateColDef } from "../../../models/colDef/gridCol
|
|
|
2
2
|
import type { GridColumnDimensionProperties } from "./gridColumnsUtils.js";
|
|
3
3
|
export declare enum GridPinnedColumnPosition {
|
|
4
4
|
LEFT = "left",
|
|
5
|
-
RIGHT = "right"
|
|
5
|
+
RIGHT = "right"
|
|
6
6
|
}
|
|
7
7
|
export type GridColumnLookup = {
|
|
8
8
|
[field: string]: GridStateColDef;
|
|
@@ -7,7 +7,7 @@ import type { GridApiCommon } from "../../../models/api/gridApiCommon.mjs";
|
|
|
7
7
|
import type { GridRowEntry } from "../../../models/gridRows.mjs";
|
|
8
8
|
import type { GridDimensions } from "../dimensions/gridDimensionsApi.mjs";
|
|
9
9
|
export declare const COLUMNS_DIMENSION_PROPERTIES: readonly ['maxWidth', 'minWidth', 'width', 'flex'];
|
|
10
|
-
export type GridColumnDimensionProperties =
|
|
10
|
+
export type GridColumnDimensionProperties = typeof COLUMNS_DIMENSION_PROPERTIES[number];
|
|
11
11
|
/**
|
|
12
12
|
* Computes width for flex columns.
|
|
13
13
|
* Based on CSS Flexbox specification:
|
|
@@ -7,7 +7,7 @@ import type { GridApiCommon } from "../../../models/api/gridApiCommon.js";
|
|
|
7
7
|
import type { GridRowEntry } from "../../../models/gridRows.js";
|
|
8
8
|
import type { GridDimensions } from "../dimensions/gridDimensionsApi.js";
|
|
9
9
|
export declare const COLUMNS_DIMENSION_PROPERTIES: readonly ['maxWidth', 'minWidth', 'width', 'flex'];
|
|
10
|
-
export type GridColumnDimensionProperties =
|
|
10
|
+
export type GridColumnDimensionProperties = typeof COLUMNS_DIMENSION_PROPERTIES[number];
|
|
11
11
|
/**
|
|
12
12
|
* Computes width for flex columns.
|
|
13
13
|
* Based on CSS Flexbox specification:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import resolveProps from '@mui/utils/resolveProps';
|
|
3
3
|
import { GRID_STRING_COL_DEF } from "../../../colDef/index.mjs";
|
|
4
4
|
import { getRegisteredColumnTypeDef, isCommunityColumnType } from "../../../colDef/gridColumnTypesRegistry.mjs";
|
|
@@ -360,7 +360,7 @@ function useGridColumns(apiRef, props) {
|
|
|
360
360
|
}
|
|
361
361
|
const lookup = (0, _gridColumnsSelector.gridColumnLookupSelector)(apiRef);
|
|
362
362
|
if (orderedFields.some(field => lookup[field]?.type === 'multiSelect')) {
|
|
363
|
-
(0, _warning.warnOnce)(['MUI X: The `multiSelect` column type is available in Pro and Premium versions', 'Use `<DataGridPro />` or `<DataGridPremium />` to render it correctly.', 'For more details, see https://mui.com/x/react-data-grid/column-definition/#multi-select-keyboard-interactions']);
|
|
363
|
+
(0, _warning.warnOnce)(['MUI X: The `multiSelect` column type is available in Pro and Premium versions', 'Use `<DataGridPro />` or `<DataGridPremium />` to render it correctly.', 'For more details, see https://mui.com/x/react-data-grid/column-definition/#multi-select-keyboard-interactions'].join('\n'));
|
|
364
364
|
}
|
|
365
365
|
}, [apiRef, props.signature]);
|
|
366
366
|
(0, _useGridEvent.useGridEvent)(apiRef, 'columnsChange', checkMultiSelectColumns);
|
|
@@ -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 { warnOnce } from '@mui/x-internals/warning';
|
|
6
6
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.mjs";
|
|
@@ -351,7 +351,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
351
351
|
}
|
|
352
352
|
const lookup = gridColumnLookupSelector(apiRef);
|
|
353
353
|
if (orderedFields.some(field => lookup[field]?.type === 'multiSelect')) {
|
|
354
|
-
warnOnce(['MUI X: The `multiSelect` column type is available in Pro and Premium versions', 'Use `<DataGridPro />` or `<DataGridPremium />` to render it correctly.', 'For more details, see https://mui.com/x/react-data-grid/column-definition/#multi-select-keyboard-interactions']);
|
|
354
|
+
warnOnce(['MUI X: The `multiSelect` column type is available in Pro and Premium versions', 'Use `<DataGridPro />` or `<DataGridPremium />` to render it correctly.', 'For more details, see https://mui.com/x/react-data-grid/column-definition/#multi-select-keyboard-interactions'].join('\n'));
|
|
355
355
|
}
|
|
356
356
|
}, [apiRef, props.signature]);
|
|
357
357
|
useGridEvent(apiRef, 'columnsChange', checkMultiSelectColumns);
|
|
@@ -9,11 +9,11 @@ function getKeyDefault(params) {
|
|
|
9
9
|
return JSON.stringify([params.filterModel, params.sortModel, params.start, params.end]);
|
|
10
10
|
}
|
|
11
11
|
class GridDataSourceCacheDefault {
|
|
12
|
+
cache = {};
|
|
12
13
|
constructor({
|
|
13
14
|
ttl = 300_000,
|
|
14
15
|
getKey = getKeyDefault
|
|
15
16
|
}) {
|
|
16
|
-
this.cache = {};
|
|
17
17
|
this.ttl = ttl;
|
|
18
18
|
this.getKey = getKey;
|
|
19
19
|
}
|
|
@@ -2,11 +2,11 @@ export function getKeyDefault(params) {
|
|
|
2
2
|
return JSON.stringify([params.filterModel, params.sortModel, params.start, params.end]);
|
|
3
3
|
}
|
|
4
4
|
export class GridDataSourceCacheDefault {
|
|
5
|
+
cache = {};
|
|
5
6
|
constructor({
|
|
6
7
|
ttl = 300_000,
|
|
7
8
|
getKey = getKeyDefault
|
|
8
9
|
}) {
|
|
9
|
-
this.cache = {};
|
|
10
10
|
this.ttl = ttl;
|
|
11
11
|
this.getKey = getKey;
|
|
12
12
|
}
|
|
@@ -25,6 +25,7 @@ var _columns = require("../columns");
|
|
|
25
25
|
var _gridFilterUtils = require("../filter/gridFilterUtils");
|
|
26
26
|
var _gridDataSourceSelector = require("./gridDataSourceSelector");
|
|
27
27
|
var _useGridDataSourceFilterModelChange = require("./useGridDataSourceFilterModelChange");
|
|
28
|
+
var _useGridDataSourcePolling = require("./useGridDataSourcePolling");
|
|
28
29
|
var _utils2 = require("./utils");
|
|
29
30
|
var _cache = require("./cache");
|
|
30
31
|
var _gridDataSourceError = require("./gridDataSourceError");
|
|
@@ -55,9 +56,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
55
56
|
const rowsAreUpToDate = React.useRef(false);
|
|
56
57
|
// Requests that are still running and will apply their response when they settle.
|
|
57
58
|
const pendingRequestCount = React.useRef(0);
|
|
58
|
-
const pollingIntervalRef = React.useRef(null);
|
|
59
59
|
const onDataSourceErrorProp = props.onDataSourceError;
|
|
60
|
-
const revalidateMs = props.dataSourceRevalidateMs;
|
|
61
60
|
const cacheChunkManager = (0, _useLazyRef.default)(() => {
|
|
62
61
|
if (!props.pagination) {
|
|
63
62
|
return new _utils2.CacheChunkManager(paginationModel.pageSize);
|
|
@@ -149,7 +148,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
149
148
|
cause: originalError
|
|
150
149
|
}));
|
|
151
150
|
} else if (process.env.NODE_ENV !== 'production') {
|
|
152
|
-
(0, _warning.
|
|
151
|
+
(0, _warning.errorOnce)(['MUI X: A call to `dataSource.getRows()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'].join('\n'));
|
|
153
152
|
}
|
|
154
153
|
}
|
|
155
154
|
} finally {
|
|
@@ -210,19 +209,16 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
210
209
|
// Ignore background revalidation errors.
|
|
211
210
|
}
|
|
212
211
|
});
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
if (revalidateMs <= 0 || !standardRowsUpdateStrategyActive) {
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
pollingIntervalRef.current = setInterval(revalidate, revalidateMs);
|
|
212
|
+
const {
|
|
213
|
+
startPolling: startPollingWith,
|
|
214
|
+
stopPolling
|
|
215
|
+
} = (0, _useGridDataSourcePolling.useGridDataSourcePolling)({
|
|
216
|
+
revalidateMs: props.dataSourceRevalidateMs,
|
|
217
|
+
isActive: standardRowsUpdateStrategyActive,
|
|
218
|
+
// Rows that are still loading start the polling when they arrive.
|
|
219
|
+
shouldResume: () => rowsAreUpToDate.current
|
|
225
220
|
});
|
|
221
|
+
const startPolling = React.useCallback(() => startPollingWith(revalidate), [startPollingWith, revalidate]);
|
|
226
222
|
const handleDataUpdate = React.useCallback(params => {
|
|
227
223
|
if ('error' in params) {
|
|
228
224
|
// Reset the rows on error, even with `dataSourceKeepPreviousData`. The previous
|
|
@@ -276,7 +272,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
276
272
|
cause: errorThrown
|
|
277
273
|
}));
|
|
278
274
|
} else if (process.env.NODE_ENV !== 'production') {
|
|
279
|
-
(0, _warning.
|
|
275
|
+
(0, _warning.errorOnce)(['MUI X: A call to `dataSource.updateRow()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'].join('\n'));
|
|
280
276
|
}
|
|
281
277
|
throw errorThrown; // Let the caller handle the error further
|
|
282
278
|
}
|
|
@@ -329,17 +325,6 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
329
325
|
const newCache = getCache(props.dataSourceCache, options.cacheOptions);
|
|
330
326
|
setCache(prevCache => prevCache !== newCache ? newCache : prevCache);
|
|
331
327
|
}, [props.dataSourceCache, options.cacheOptions]);
|
|
332
|
-
React.useEffect(() => {
|
|
333
|
-
if (!standardRowsUpdateStrategyActive) {
|
|
334
|
-
stopPolling();
|
|
335
|
-
}
|
|
336
|
-
}, [standardRowsUpdateStrategyActive, stopPolling]);
|
|
337
|
-
React.useEffect(() => {
|
|
338
|
-
if (revalidateMs <= 0) {
|
|
339
|
-
stopPolling();
|
|
340
|
-
}
|
|
341
|
-
}, [revalidateMs, stopPolling]);
|
|
342
|
-
React.useEffect(() => stopPolling, [stopPolling]);
|
|
343
328
|
const lastApiRef = React.useRef(apiRef);
|
|
344
329
|
const lastStrategy = React.useRef(currentStrategy);
|
|
345
330
|
const lastDataSource = React.useRef(props.dataSource);
|
|
@@ -388,7 +373,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
388
373
|
// strategies always reset the rows on refetch to keep their order consistent with the
|
|
389
374
|
// response. Warn so the limitation is discoverable at runtime, not only in the docs.
|
|
390
375
|
if (process.env.NODE_ENV !== 'production' && props.dataSourceKeepPreviousData && (currentStrategy === _utils2.DataSourceRowsUpdateStrategy.GroupedData || currentStrategy === _utils2.DataSourceRowsUpdateStrategy.LazyLoadedGroupedData)) {
|
|
391
|
-
(0, _warning.warnOnce)(['MUI X: The `dataSourceKeepPreviousData` prop only applies to flat data.', 'It is ignored when tree data or row grouping is enabled, because the rows are always reset on refetch to keep their order consistent with the response.', 'For more details, see https://mui.com/x/react-data-grid/server-side-data/#keep-previous-data-while-fetching.']);
|
|
376
|
+
(0, _warning.warnOnce)(['MUI X: The `dataSourceKeepPreviousData` prop only applies to flat data.', 'It is ignored when tree data or row grouping is enabled, because the rows are always reset on refetch to keep their order consistent with the response.', 'For more details, see https://mui.com/x/react-data-grid/server-side-data/#keep-previous-data-while-fetching.'].join('\n'));
|
|
392
377
|
}
|
|
393
378
|
}, [props.dataSourceKeepPreviousData, currentStrategy]);
|
|
394
379
|
return {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _extends from "@babel/runtime/helpers/
|
|
4
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/
|
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
4
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
5
5
|
const _excluded = ["skipCache", "keepChildrenExpanded", "showChildrenLoading"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import useLazyRef from '@mui/utils/useLazyRef';
|
|
8
8
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
9
9
|
import debounce from '@mui/utils/debounce';
|
|
10
|
-
import { warnOnce } from '@mui/x-internals/warning';
|
|
10
|
+
import { errorOnce, warnOnce } from '@mui/x-internals/warning';
|
|
11
11
|
import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
|
|
12
12
|
import { GRID_ROOT_GROUP_ID, getReplaceRow, isReplaceUpdate } from "../rows/gridRowsUtils.mjs";
|
|
13
13
|
import { runIf } from "../../../utils/utils.mjs";
|
|
@@ -19,6 +19,7 @@ import { gridColumnLookupSelector } from "../columns/index.mjs";
|
|
|
19
19
|
import { removeIncompleteFilterItems } from "../filter/gridFilterUtils.mjs";
|
|
20
20
|
import { gridGetRowsParamsSelector } from "./gridDataSourceSelector.mjs";
|
|
21
21
|
import { useGridDataSourceFilterModelChange } from "./useGridDataSourceFilterModelChange.mjs";
|
|
22
|
+
import { useGridDataSourcePolling } from "./useGridDataSourcePolling.mjs";
|
|
22
23
|
import { CacheChunkManager, DataSourceRowsUpdateStrategy } from "./utils.mjs";
|
|
23
24
|
import { GridDataSourceCacheDefault } from "./cache.mjs";
|
|
24
25
|
import { GridGetRowsError, GridUpdateRowError } from "./gridDataSourceError.mjs";
|
|
@@ -48,9 +49,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
48
49
|
const rowsAreUpToDate = React.useRef(false);
|
|
49
50
|
// Requests that are still running and will apply their response when they settle.
|
|
50
51
|
const pendingRequestCount = React.useRef(0);
|
|
51
|
-
const pollingIntervalRef = React.useRef(null);
|
|
52
52
|
const onDataSourceErrorProp = props.onDataSourceError;
|
|
53
|
-
const revalidateMs = props.dataSourceRevalidateMs;
|
|
54
53
|
const cacheChunkManager = useLazyRef(() => {
|
|
55
54
|
if (!props.pagination) {
|
|
56
55
|
return new CacheChunkManager(paginationModel.pageSize);
|
|
@@ -142,7 +141,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
142
141
|
cause: originalError
|
|
143
142
|
}));
|
|
144
143
|
} else if (process.env.NODE_ENV !== 'production') {
|
|
145
|
-
|
|
144
|
+
errorOnce(['MUI X: A call to `dataSource.getRows()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'].join('\n'));
|
|
146
145
|
}
|
|
147
146
|
}
|
|
148
147
|
} finally {
|
|
@@ -203,19 +202,16 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
203
202
|
// Ignore background revalidation errors.
|
|
204
203
|
}
|
|
205
204
|
});
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
if (revalidateMs <= 0 || !standardRowsUpdateStrategyActive) {
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
pollingIntervalRef.current = setInterval(revalidate, revalidateMs);
|
|
205
|
+
const {
|
|
206
|
+
startPolling: startPollingWith,
|
|
207
|
+
stopPolling
|
|
208
|
+
} = useGridDataSourcePolling({
|
|
209
|
+
revalidateMs: props.dataSourceRevalidateMs,
|
|
210
|
+
isActive: standardRowsUpdateStrategyActive,
|
|
211
|
+
// Rows that are still loading start the polling when they arrive.
|
|
212
|
+
shouldResume: () => rowsAreUpToDate.current
|
|
218
213
|
});
|
|
214
|
+
const startPolling = React.useCallback(() => startPollingWith(revalidate), [startPollingWith, revalidate]);
|
|
219
215
|
const handleDataUpdate = React.useCallback(params => {
|
|
220
216
|
if ('error' in params) {
|
|
221
217
|
// Reset the rows on error, even with `dataSourceKeepPreviousData`. The previous
|
|
@@ -269,7 +265,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
269
265
|
cause: errorThrown
|
|
270
266
|
}));
|
|
271
267
|
} else if (process.env.NODE_ENV !== 'production') {
|
|
272
|
-
|
|
268
|
+
errorOnce(['MUI X: A call to `dataSource.updateRow()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'].join('\n'));
|
|
273
269
|
}
|
|
274
270
|
throw errorThrown; // Let the caller handle the error further
|
|
275
271
|
}
|
|
@@ -322,17 +318,6 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
322
318
|
const newCache = getCache(props.dataSourceCache, options.cacheOptions);
|
|
323
319
|
setCache(prevCache => prevCache !== newCache ? newCache : prevCache);
|
|
324
320
|
}, [props.dataSourceCache, options.cacheOptions]);
|
|
325
|
-
React.useEffect(() => {
|
|
326
|
-
if (!standardRowsUpdateStrategyActive) {
|
|
327
|
-
stopPolling();
|
|
328
|
-
}
|
|
329
|
-
}, [standardRowsUpdateStrategyActive, stopPolling]);
|
|
330
|
-
React.useEffect(() => {
|
|
331
|
-
if (revalidateMs <= 0) {
|
|
332
|
-
stopPolling();
|
|
333
|
-
}
|
|
334
|
-
}, [revalidateMs, stopPolling]);
|
|
335
|
-
React.useEffect(() => stopPolling, [stopPolling]);
|
|
336
321
|
const lastApiRef = React.useRef(apiRef);
|
|
337
322
|
const lastStrategy = React.useRef(currentStrategy);
|
|
338
323
|
const lastDataSource = React.useRef(props.dataSource);
|
|
@@ -381,7 +366,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
381
366
|
// strategies always reset the rows on refetch to keep their order consistent with the
|
|
382
367
|
// response. Warn so the limitation is discoverable at runtime, not only in the docs.
|
|
383
368
|
if (process.env.NODE_ENV !== 'production' && props.dataSourceKeepPreviousData && (currentStrategy === DataSourceRowsUpdateStrategy.GroupedData || currentStrategy === DataSourceRowsUpdateStrategy.LazyLoadedGroupedData)) {
|
|
384
|
-
warnOnce(['MUI X: The `dataSourceKeepPreviousData` prop only applies to flat data.', 'It is ignored when tree data or row grouping is enabled, because the rows are always reset on refetch to keep their order consistent with the response.', 'For more details, see https://mui.com/x/react-data-grid/server-side-data/#keep-previous-data-while-fetching.']);
|
|
369
|
+
warnOnce(['MUI X: The `dataSourceKeepPreviousData` prop only applies to flat data.', 'It is ignored when tree data or row grouping is enabled, because the rows are always reset on refetch to keep their order consistent with the response.', 'For more details, see https://mui.com/x/react-data-grid/server-side-data/#keep-previous-data-while-fetching.'].join('\n'));
|
|
385
370
|
}
|
|
386
371
|
}, [props.dataSourceKeepPreviousData, currentStrategy]);
|
|
387
372
|
return {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
interface UseGridDataSourcePollingOptions {
|
|
2
|
+
/**
|
|
3
|
+
* The polling interval in milliseconds. The polling is off when it is `0` or less.
|
|
4
|
+
*/
|
|
5
|
+
revalidateMs: number;
|
|
6
|
+
/**
|
|
7
|
+
* The polling is off when it is `false`.
|
|
8
|
+
*/
|
|
9
|
+
isActive: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Runs when `<Activity>` shows the grid again, if the polling started before.
|
|
12
|
+
* @returns {boolean} `true` to resume the polling.
|
|
13
|
+
* @default () => true
|
|
14
|
+
*/
|
|
15
|
+
shouldResume?: () => boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Calls a revalidation callback at the `revalidateMs` interval.
|
|
19
|
+
* The polling pauses while `<Activity>` hides the grid and stops after the grid unmounts.
|
|
20
|
+
*/
|
|
21
|
+
export declare const useGridDataSourcePolling: ({
|
|
22
|
+
revalidateMs,
|
|
23
|
+
isActive,
|
|
24
|
+
shouldResume
|
|
25
|
+
}: UseGridDataSourcePollingOptions) => {
|
|
26
|
+
startPolling: (callback: () => void) => void;
|
|
27
|
+
stopPolling: () => void;
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
interface UseGridDataSourcePollingOptions {
|
|
2
|
+
/**
|
|
3
|
+
* The polling interval in milliseconds. The polling is off when it is `0` or less.
|
|
4
|
+
*/
|
|
5
|
+
revalidateMs: number;
|
|
6
|
+
/**
|
|
7
|
+
* The polling is off when it is `false`.
|
|
8
|
+
*/
|
|
9
|
+
isActive: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Runs when `<Activity>` shows the grid again, if the polling started before.
|
|
12
|
+
* @returns {boolean} `true` to resume the polling.
|
|
13
|
+
* @default () => true
|
|
14
|
+
*/
|
|
15
|
+
shouldResume?: () => boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Calls a revalidation callback at the `revalidateMs` interval.
|
|
19
|
+
* The polling pauses while `<Activity>` hides the grid and stops after the grid unmounts.
|
|
20
|
+
*/
|
|
21
|
+
export declare const useGridDataSourcePolling: ({
|
|
22
|
+
revalidateMs,
|
|
23
|
+
isActive,
|
|
24
|
+
shouldResume
|
|
25
|
+
}: UseGridDataSourcePollingOptions) => {
|
|
26
|
+
startPolling: (callback: () => void) => void;
|
|
27
|
+
stopPolling: () => void;
|
|
28
|
+
};
|
|
29
|
+
export {};
|