@mui/x-data-grid 9.3.0 → 9.5.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 +296 -0
- package/colDef/gridColumnTypesRegistry.d.mts +8 -0
- package/colDef/gridColumnTypesRegistry.d.ts +8 -0
- package/colDef/gridColumnTypesRegistry.js +44 -0
- package/colDef/gridColumnTypesRegistry.mjs +34 -0
- package/colDef/gridDefaultColumnTypes.d.mts +1 -1
- package/colDef/gridDefaultColumnTypes.d.ts +1 -1
- package/colDef/gridDefaultColumnTypes.js +11 -23
- package/colDef/gridDefaultColumnTypes.mjs +4 -22
- package/components/GridRow.js +9 -1
- package/components/GridRow.mjs +9 -1
- package/components/cell/GridActionsCell.js +1 -1
- package/components/cell/GridActionsCell.mjs +1 -1
- package/components/cell/GridActionsCellItem.js +1 -1
- package/components/cell/GridActionsCellItem.mjs +1 -1
- package/components/cell/GridLongTextCell.js +2 -0
- package/components/cell/GridLongTextCell.mjs +2 -0
- package/components/cell/GridSkeletonCell.d.mts +2 -1
- package/components/cell/GridSkeletonCell.d.ts +2 -1
- package/components/cell/GridSkeletonCell.js +8 -3
- package/components/cell/GridSkeletonCell.mjs +8 -3
- package/components/containers/GridRootStyles.js +29 -0
- package/components/containers/GridRootStyles.mjs +29 -0
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +2 -4
- package/components/panel/filterPanel/GridFilterInputSingleSelect.mjs +2 -4
- package/components/panel/filterPanel/filterPanelUtils.d.mts +3 -2
- package/components/panel/filterPanel/filterPanelUtils.d.ts +3 -2
- package/components/panel/filterPanel/filterPanelUtils.js +4 -0
- package/components/panel/filterPanel/filterPanelUtils.mjs +3 -0
- package/constants/cssVariables.d.mts +3 -0
- package/constants/cssVariables.d.ts +3 -0
- package/constants/cssVariables.js +2 -1
- package/constants/cssVariables.mjs +2 -1
- package/constants/gridClasses.d.mts +48 -0
- package/constants/gridClasses.d.ts +48 -0
- package/constants/gridClasses.js +1 -1
- package/constants/gridClasses.mjs +1 -1
- package/hooks/core/strategyProcessing/gridStrategyProcessingApi.d.mts +17 -1
- package/hooks/core/strategyProcessing/gridStrategyProcessingApi.d.ts +17 -1
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.js +2 -1
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.mjs +2 -1
- package/hooks/core/useGridProps.js +5 -3
- package/hooks/core/useGridProps.mjs +5 -3
- package/hooks/core/useGridVirtualizer.d.mts +10 -10
- package/hooks/core/useGridVirtualizer.d.ts +10 -10
- package/hooks/features/columns/gridColumnsUtils.js +18 -10
- package/hooks/features/columns/gridColumnsUtils.mjs +19 -11
- package/hooks/features/columns/useGridColumns.js +11 -0
- package/hooks/features/columns/useGridColumns.mjs +11 -0
- package/hooks/features/dataSource/models.d.mts +1 -1
- package/hooks/features/dataSource/models.d.ts +1 -1
- package/hooks/features/dataSource/useGridDataSourceBase.d.mts +2 -2
- package/hooks/features/dataSource/useGridDataSourceBase.d.ts +2 -2
- package/hooks/features/dataSource/useGridDataSourceBase.js +31 -19
- package/hooks/features/dataSource/useGridDataSourceBase.mjs +31 -19
- package/hooks/features/dataSource/utils.d.mts +1 -0
- package/hooks/features/dataSource/utils.d.ts +1 -0
- package/hooks/features/dataSource/utils.js +1 -0
- package/hooks/features/dataSource/utils.mjs +1 -0
- package/hooks/features/editing/useGridCellEditing.js +1 -1
- package/hooks/features/editing/useGridCellEditing.mjs +1 -1
- package/hooks/features/editing/useGridRowEditing.js +1 -1
- package/hooks/features/editing/useGridRowEditing.mjs +1 -1
- package/hooks/features/export/serializers/csvSerializer.js +3 -1
- package/hooks/features/export/serializers/csvSerializer.mjs +3 -1
- package/hooks/features/filter/gridFilterUtils.js +5 -3
- package/hooks/features/filter/gridFilterUtils.mjs +5 -3
- package/hooks/features/listView/useGridListView.js +1 -1
- package/hooks/features/listView/useGridListView.mjs +1 -1
- package/hooks/features/sorting/gridSortingUtils.js +3 -1
- package/hooks/features/sorting/gridSortingUtils.mjs +3 -1
- package/hooks/features/virtualization/gridVirtualizationSelectors.d.mts +1 -1
- package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +1 -1
- package/hooks/utils/useGridSelector.js +26 -23
- package/hooks/utils/useGridSelector.mjs +25 -23
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/index.d.mts +9 -4
- package/internals/index.d.ts +9 -4
- package/internals/index.js +62 -2
- package/internals/index.mjs +8 -4
- package/internals/utils/propValidation.js +3 -0
- package/internals/utils/propValidation.mjs +3 -0
- package/material/augmentation.d.mts +4 -0
- package/material/augmentation.d.ts +4 -0
- package/material/index.js +38 -24
- package/material/index.mjs +38 -24
- package/material/variables.js +2 -1
- package/material/variables.mjs +2 -1
- package/models/colDef/gridColDef.d.mts +35 -3
- package/models/colDef/gridColDef.d.ts +35 -3
- package/models/colDef/gridColType.d.mts +1 -0
- package/models/colDef/gridColType.d.ts +1 -0
- package/models/colDef/gridColumnTypesRecord.d.mts +1 -1
- package/models/colDef/gridColumnTypesRecord.d.ts +1 -1
- package/models/colDef/index.d.mts +1 -1
- package/models/colDef/index.d.ts +1 -1
- package/models/gridBaseSlots.d.mts +46 -0
- package/models/gridBaseSlots.d.ts +46 -0
- package/models/gridDataSource.d.mts +6 -0
- package/models/gridDataSource.d.ts +6 -0
- package/models/gridRows.d.mts +0 -1
- package/models/gridRows.d.ts +0 -1
- package/models/gridSlotsComponent.d.mts +5 -0
- package/models/gridSlotsComponent.d.ts +5 -0
- package/models/gridSlotsComponentsProps.d.mts +3 -1
- package/models/gridSlotsComponentsProps.d.ts +3 -1
- package/models/gridStateCommunity.d.mts +1 -1
- package/models/gridStateCommunity.d.ts +1 -1
- package/package.json +4 -4
|
@@ -9,28 +9,28 @@ export declare function useGridVirtualizer(): {
|
|
|
9
9
|
updateDimensions: (firstUpdate?: boolean) => void;
|
|
10
10
|
debouncedUpdateDimensions: (((firstUpdate?: boolean) => void) & import("@mui/x-internals/throttle").Cancelable) | undefined;
|
|
11
11
|
rowsMeta: {
|
|
12
|
-
getRowHeight: (rowId: import("@mui/x-virtualizer
|
|
12
|
+
getRowHeight: (rowId: import("@mui/x-virtualizer").RowId) => any;
|
|
13
13
|
setLastMeasuredRowIndex: (index: number) => void;
|
|
14
|
-
storeRowHeightMeasurement: (id: import("@mui/x-virtualizer
|
|
14
|
+
storeRowHeightMeasurement: (id: import("@mui/x-virtualizer").RowId, height: number) => void;
|
|
15
15
|
hydrateRowsMeta: () => void;
|
|
16
|
-
observeRowHeight: (element: Element, rowId: import("@mui/x-virtualizer
|
|
17
|
-
rowHasAutoHeight: (id: import("@mui/x-virtualizer
|
|
18
|
-
getRowHeightEntry: (rowId: import("@mui/x-virtualizer
|
|
16
|
+
observeRowHeight: (element: Element, rowId: import("@mui/x-virtualizer").RowId) => () => void | undefined;
|
|
17
|
+
rowHasAutoHeight: (id: import("@mui/x-virtualizer").RowId) => any;
|
|
18
|
+
getRowHeightEntry: (rowId: import("@mui/x-virtualizer").RowId) => any;
|
|
19
19
|
getLastMeasuredRowIndex: () => number;
|
|
20
20
|
resetRowHeights: () => void;
|
|
21
21
|
};
|
|
22
22
|
} & {
|
|
23
|
-
getCellColSpanInfo: (rowId: import("@mui/x-virtualizer
|
|
24
|
-
calculateColSpan: (rowId: import("@mui/x-virtualizer
|
|
25
|
-
getHiddenCellsOrigin: () => Record<import("@mui/x-virtualizer
|
|
23
|
+
getCellColSpanInfo: (rowId: import("@mui/x-virtualizer").RowId, columnIndex: import("@mui/x-internals/types").integer) => import("@mui/x-virtualizer").CellColSpanInfo;
|
|
24
|
+
calculateColSpan: (rowId: import("@mui/x-virtualizer").RowId, minFirstColumn: import("@mui/x-internals/types").integer, maxLastColumn: import("@mui/x-internals/types").integer, columns: import("@mui/x-virtualizer").ColumnWithWidth[]) => void;
|
|
25
|
+
getHiddenCellsOrigin: () => Record<import("@mui/x-virtualizer").RowId, Record<number, number>>;
|
|
26
26
|
getters: any;
|
|
27
27
|
setPanels: React.Dispatch<React.SetStateAction<Readonly<Map<any, React.ReactNode>>>>;
|
|
28
28
|
forceUpdateRenderContext: () => void;
|
|
29
29
|
scheduleUpdateRenderContext: () => void;
|
|
30
30
|
} & {
|
|
31
31
|
resetColSpan: () => void;
|
|
32
|
-
getCellColSpanInfo: (rowId: import("@mui/x-virtualizer
|
|
33
|
-
calculateColSpan: (rowId: import("@mui/x-virtualizer
|
|
32
|
+
getCellColSpanInfo: (rowId: import("@mui/x-virtualizer").RowId, columnIndex: import("@mui/x-internals/types").integer) => import("@mui/x-virtualizer").CellColSpanInfo | undefined;
|
|
33
|
+
calculateColSpan: (rowId: import("@mui/x-virtualizer").RowId, minFirstColumn: import("@mui/x-internals/types").integer, maxLastColumn: import("@mui/x-internals/types").integer, columns: import("@mui/x-virtualizer").ColumnWithWidth[]) => void;
|
|
34
34
|
} & {
|
|
35
35
|
getHiddenCellsOrigin: () => Record<number, Record<number, number>>;
|
|
36
36
|
} & {
|
|
@@ -9,28 +9,28 @@ export declare function useGridVirtualizer(): {
|
|
|
9
9
|
updateDimensions: (firstUpdate?: boolean) => void;
|
|
10
10
|
debouncedUpdateDimensions: (((firstUpdate?: boolean) => void) & import("@mui/x-internals/throttle").Cancelable) | undefined;
|
|
11
11
|
rowsMeta: {
|
|
12
|
-
getRowHeight: (rowId: import("@mui/x-virtualizer
|
|
12
|
+
getRowHeight: (rowId: import("@mui/x-virtualizer").RowId) => any;
|
|
13
13
|
setLastMeasuredRowIndex: (index: number) => void;
|
|
14
|
-
storeRowHeightMeasurement: (id: import("@mui/x-virtualizer
|
|
14
|
+
storeRowHeightMeasurement: (id: import("@mui/x-virtualizer").RowId, height: number) => void;
|
|
15
15
|
hydrateRowsMeta: () => void;
|
|
16
|
-
observeRowHeight: (element: Element, rowId: import("@mui/x-virtualizer
|
|
17
|
-
rowHasAutoHeight: (id: import("@mui/x-virtualizer
|
|
18
|
-
getRowHeightEntry: (rowId: import("@mui/x-virtualizer
|
|
16
|
+
observeRowHeight: (element: Element, rowId: import("@mui/x-virtualizer").RowId) => () => void | undefined;
|
|
17
|
+
rowHasAutoHeight: (id: import("@mui/x-virtualizer").RowId) => any;
|
|
18
|
+
getRowHeightEntry: (rowId: import("@mui/x-virtualizer").RowId) => any;
|
|
19
19
|
getLastMeasuredRowIndex: () => number;
|
|
20
20
|
resetRowHeights: () => void;
|
|
21
21
|
};
|
|
22
22
|
} & {
|
|
23
|
-
getCellColSpanInfo: (rowId: import("@mui/x-virtualizer
|
|
24
|
-
calculateColSpan: (rowId: import("@mui/x-virtualizer
|
|
25
|
-
getHiddenCellsOrigin: () => Record<import("@mui/x-virtualizer
|
|
23
|
+
getCellColSpanInfo: (rowId: import("@mui/x-virtualizer").RowId, columnIndex: import("@mui/x-internals/types").integer) => import("@mui/x-virtualizer").CellColSpanInfo;
|
|
24
|
+
calculateColSpan: (rowId: import("@mui/x-virtualizer").RowId, minFirstColumn: import("@mui/x-internals/types").integer, maxLastColumn: import("@mui/x-internals/types").integer, columns: import("@mui/x-virtualizer").ColumnWithWidth[]) => void;
|
|
25
|
+
getHiddenCellsOrigin: () => Record<import("@mui/x-virtualizer").RowId, Record<number, number>>;
|
|
26
26
|
getters: any;
|
|
27
27
|
setPanels: React.Dispatch<React.SetStateAction<Readonly<Map<any, React.ReactNode>>>>;
|
|
28
28
|
forceUpdateRenderContext: () => void;
|
|
29
29
|
scheduleUpdateRenderContext: () => void;
|
|
30
30
|
} & {
|
|
31
31
|
resetColSpan: () => void;
|
|
32
|
-
getCellColSpanInfo: (rowId: import("@mui/x-virtualizer
|
|
33
|
-
calculateColSpan: (rowId: import("@mui/x-virtualizer
|
|
32
|
+
getCellColSpanInfo: (rowId: import("@mui/x-virtualizer").RowId, columnIndex: import("@mui/x-internals/types").integer) => import("@mui/x-virtualizer").CellColSpanInfo | undefined;
|
|
33
|
+
calculateColSpan: (rowId: import("@mui/x-virtualizer").RowId, minFirstColumn: import("@mui/x-internals/types").integer, maxLastColumn: import("@mui/x-internals/types").integer, columns: import("@mui/x-virtualizer").ColumnWithWidth[]) => void;
|
|
34
34
|
} & {
|
|
35
35
|
getHiddenCellsOrigin: () => Record<number, Record<number, number>>;
|
|
36
36
|
} & {
|
|
@@ -14,14 +14,14 @@ exports.hydrateColumnsWidth = void 0;
|
|
|
14
14
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
15
15
|
var _resolveProps = _interopRequireDefault(require("@mui/utils/resolveProps"));
|
|
16
16
|
var _colDef = require("../../../colDef");
|
|
17
|
+
var _gridColumnTypesRegistry = require("../../../colDef/gridColumnTypesRegistry");
|
|
18
|
+
var _signature = require("../../../constants/signature");
|
|
17
19
|
var _gridColumnsSelector = require("./gridColumnsSelector");
|
|
18
20
|
var _utils = require("../../../utils/utils");
|
|
19
21
|
var _densitySelector = require("../density/densitySelector");
|
|
20
22
|
var _gridHeaderFilteringSelectors = require("../headerFiltering/gridHeaderFilteringSelectors");
|
|
21
23
|
var _gridColumnGroupsSelector = require("../columnGrouping/gridColumnGroupsSelector");
|
|
22
24
|
const COLUMNS_DIMENSION_PROPERTIES = exports.COLUMNS_DIMENSION_PROPERTIES = ['maxWidth', 'minWidth', 'width', 'flex'];
|
|
23
|
-
const COLUMN_TYPES = (0, _colDef.getGridDefaultColumnTypes)();
|
|
24
|
-
|
|
25
25
|
/**
|
|
26
26
|
* Computes width for flex columns.
|
|
27
27
|
* Based on CSS Flexbox specification:
|
|
@@ -223,11 +223,7 @@ const applyInitialState = (columnsState, initialState) => {
|
|
|
223
223
|
return newColumnsState;
|
|
224
224
|
};
|
|
225
225
|
function getDefaultColTypeDef(type) {
|
|
226
|
-
|
|
227
|
-
if (type && COLUMN_TYPES[type]) {
|
|
228
|
-
colDef = COLUMN_TYPES[type];
|
|
229
|
-
}
|
|
230
|
-
return colDef;
|
|
226
|
+
return (0, _gridColumnTypesRegistry.getRegisteredColumnTypeDef)(type);
|
|
231
227
|
}
|
|
232
228
|
const createColumnsState = ({
|
|
233
229
|
apiRef,
|
|
@@ -238,6 +234,18 @@ const createColumnsState = ({
|
|
|
238
234
|
updateInitialVisibilityModel = false
|
|
239
235
|
}) => {
|
|
240
236
|
const isInsideStateInitializer = !apiRef.current.state.columns;
|
|
237
|
+
|
|
238
|
+
// A community `DataGrid` must not resolve a Pro/Premium-only column type even if a Pro grid
|
|
239
|
+
// registered it globally in the same bundle (shared module registry). Fall back to the default
|
|
240
|
+
// type def in that case, so the column behaves like a plain column.
|
|
241
|
+
// NOTE: this is a community-vs-paid gate only — it does not distinguish Pro from Premium. It is
|
|
242
|
+
// enough today because the only registered type (`multiSelect`) is available in both Pro and
|
|
243
|
+
// Premium. If a Pro-only or Premium-only column type is added later, make this plan-aware:
|
|
244
|
+
// track each type's minimum plan in the registry and compare it against the grid signature
|
|
245
|
+
// (DataGrid < DataGridPro < DataGridPremium), so e.g. a Premium-only type also falls back in
|
|
246
|
+
// `DataGridPro`.
|
|
247
|
+
const isCommunity = apiRef.current.state.props?.signature === _signature.GridSignature.DataGrid;
|
|
248
|
+
const getColTypeDef = type => isCommunity && !(0, _gridColumnTypesRegistry.isCommunityColumnType)(type) ? getDefaultColTypeDef(undefined) : getDefaultColTypeDef(type);
|
|
241
249
|
let columnsState;
|
|
242
250
|
if (isInsideStateInitializer) {
|
|
243
251
|
columnsState = {
|
|
@@ -270,7 +278,7 @@ const createColumnsState = ({
|
|
|
270
278
|
columnsToKeep[field] = true;
|
|
271
279
|
let existingState = columnsState.lookup[field];
|
|
272
280
|
if (existingState == null) {
|
|
273
|
-
existingState = (0, _extends2.default)({},
|
|
281
|
+
existingState = (0, _extends2.default)({}, getColTypeDef(newColumn.type), {
|
|
274
282
|
field,
|
|
275
283
|
hasBeenResized: false
|
|
276
284
|
});
|
|
@@ -281,7 +289,7 @@ const createColumnsState = ({
|
|
|
281
289
|
|
|
282
290
|
// If the column type has changed - merge the existing state with the default column type definition
|
|
283
291
|
if (existingState && existingState.type !== newColumn.type) {
|
|
284
|
-
existingState = (0, _extends2.default)({},
|
|
292
|
+
existingState = (0, _extends2.default)({}, getColTypeDef(newColumn.type), {
|
|
285
293
|
field
|
|
286
294
|
});
|
|
287
295
|
}
|
|
@@ -294,7 +302,7 @@ const createColumnsState = ({
|
|
|
294
302
|
}
|
|
295
303
|
}
|
|
296
304
|
});
|
|
297
|
-
const mergedProps = (0, _extends2.default)({},
|
|
305
|
+
const mergedProps = (0, _extends2.default)({}, getColTypeDef(newColumn.type), {
|
|
298
306
|
hasBeenResized,
|
|
299
307
|
field
|
|
300
308
|
});
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import resolveProps from '@mui/utils/resolveProps';
|
|
3
|
-
import {
|
|
3
|
+
import { GRID_STRING_COL_DEF } from "../../../colDef/index.mjs";
|
|
4
|
+
import { getRegisteredColumnTypeDef, isCommunityColumnType } from "../../../colDef/gridColumnTypesRegistry.mjs";
|
|
5
|
+
import { GridSignature } from "../../../constants/signature.mjs";
|
|
4
6
|
import { gridColumnsStateSelector, gridColumnVisibilityModelSelector } from "./gridColumnsSelector.mjs";
|
|
5
7
|
import { clamp } from "../../../utils/utils.mjs";
|
|
6
8
|
import { gridDensityFactorSelector } from "../density/densitySelector.mjs";
|
|
7
9
|
import { gridHeaderFilteringEnabledSelector } from "../headerFiltering/gridHeaderFilteringSelectors.mjs";
|
|
8
10
|
import { gridColumnGroupsHeaderMaxDepthSelector } from "../columnGrouping/gridColumnGroupsSelector.mjs";
|
|
9
11
|
export const COLUMNS_DIMENSION_PROPERTIES = ['maxWidth', 'minWidth', 'width', 'flex'];
|
|
10
|
-
const COLUMN_TYPES = getGridDefaultColumnTypes();
|
|
11
|
-
|
|
12
12
|
/**
|
|
13
13
|
* Computes width for flex columns.
|
|
14
14
|
* Based on CSS Flexbox specification:
|
|
@@ -209,11 +209,7 @@ const applyInitialState = (columnsState, initialState) => {
|
|
|
209
209
|
return newColumnsState;
|
|
210
210
|
};
|
|
211
211
|
export function getDefaultColTypeDef(type) {
|
|
212
|
-
|
|
213
|
-
if (type && COLUMN_TYPES[type]) {
|
|
214
|
-
colDef = COLUMN_TYPES[type];
|
|
215
|
-
}
|
|
216
|
-
return colDef;
|
|
212
|
+
return getRegisteredColumnTypeDef(type);
|
|
217
213
|
}
|
|
218
214
|
export const createColumnsState = ({
|
|
219
215
|
apiRef,
|
|
@@ -224,6 +220,18 @@ export const createColumnsState = ({
|
|
|
224
220
|
updateInitialVisibilityModel = false
|
|
225
221
|
}) => {
|
|
226
222
|
const isInsideStateInitializer = !apiRef.current.state.columns;
|
|
223
|
+
|
|
224
|
+
// A community `DataGrid` must not resolve a Pro/Premium-only column type even if a Pro grid
|
|
225
|
+
// registered it globally in the same bundle (shared module registry). Fall back to the default
|
|
226
|
+
// type def in that case, so the column behaves like a plain column.
|
|
227
|
+
// NOTE: this is a community-vs-paid gate only — it does not distinguish Pro from Premium. It is
|
|
228
|
+
// enough today because the only registered type (`multiSelect`) is available in both Pro and
|
|
229
|
+
// Premium. If a Pro-only or Premium-only column type is added later, make this plan-aware:
|
|
230
|
+
// track each type's minimum plan in the registry and compare it against the grid signature
|
|
231
|
+
// (DataGrid < DataGridPro < DataGridPremium), so e.g. a Premium-only type also falls back in
|
|
232
|
+
// `DataGridPro`.
|
|
233
|
+
const isCommunity = apiRef.current.state.props?.signature === GridSignature.DataGrid;
|
|
234
|
+
const getColTypeDef = type => isCommunity && !isCommunityColumnType(type) ? getDefaultColTypeDef(undefined) : getDefaultColTypeDef(type);
|
|
227
235
|
let columnsState;
|
|
228
236
|
if (isInsideStateInitializer) {
|
|
229
237
|
columnsState = {
|
|
@@ -256,7 +264,7 @@ export const createColumnsState = ({
|
|
|
256
264
|
columnsToKeep[field] = true;
|
|
257
265
|
let existingState = columnsState.lookup[field];
|
|
258
266
|
if (existingState == null) {
|
|
259
|
-
existingState = _extends({},
|
|
267
|
+
existingState = _extends({}, getColTypeDef(newColumn.type), {
|
|
260
268
|
field,
|
|
261
269
|
hasBeenResized: false
|
|
262
270
|
});
|
|
@@ -267,7 +275,7 @@ export const createColumnsState = ({
|
|
|
267
275
|
|
|
268
276
|
// If the column type has changed - merge the existing state with the default column type definition
|
|
269
277
|
if (existingState && existingState.type !== newColumn.type) {
|
|
270
|
-
existingState = _extends({},
|
|
278
|
+
existingState = _extends({}, getColTypeDef(newColumn.type), {
|
|
271
279
|
field
|
|
272
280
|
});
|
|
273
281
|
}
|
|
@@ -280,7 +288,7 @@ export const createColumnsState = ({
|
|
|
280
288
|
}
|
|
281
289
|
}
|
|
282
290
|
});
|
|
283
|
-
const mergedProps = _extends({},
|
|
291
|
+
const mergedProps = _extends({}, getColTypeDef(newColumn.type), {
|
|
284
292
|
hasBeenResized,
|
|
285
293
|
field
|
|
286
294
|
});
|
|
@@ -10,6 +10,7 @@ exports.columnsStateInitializer = void 0;
|
|
|
10
10
|
exports.useGridColumns = useGridColumns;
|
|
11
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
|
+
var _warning = require("@mui/x-internals/warning");
|
|
13
14
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
14
15
|
var _useGridLogger = require("../../utils/useGridLogger");
|
|
15
16
|
var _gridColumnsSelector = require("./gridColumnsSelector");
|
|
@@ -349,6 +350,16 @@ function useGridColumns(apiRef, props) {
|
|
|
349
350
|
apiRef.current.setColumnVisibilityModel(props.columnVisibilityModel);
|
|
350
351
|
}
|
|
351
352
|
}, [apiRef, logger, props.columnVisibilityModel]);
|
|
353
|
+
const checkMultiSelectColumns = React.useCallback(orderedFields => {
|
|
354
|
+
if (props.signature !== _signature.GridSignature.DataGrid) {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
const lookup = (0, _gridColumnsSelector.gridColumnLookupSelector)(apiRef);
|
|
358
|
+
if (orderedFields.some(field => lookup[field]?.type === 'multiSelect')) {
|
|
359
|
+
(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']);
|
|
360
|
+
}
|
|
361
|
+
}, [apiRef, props.signature]);
|
|
362
|
+
(0, _useGridEvent.useGridEvent)(apiRef, 'columnsChange', checkMultiSelectColumns);
|
|
352
363
|
}
|
|
353
364
|
function mergeColumnsState(columnsState) {
|
|
354
365
|
return state => (0, _extends2.default)({}, state, {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
|
+
import { warnOnce } from '@mui/x-internals/warning';
|
|
5
6
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.mjs";
|
|
6
7
|
import { useGridLogger } from "../../utils/useGridLogger.mjs";
|
|
7
8
|
import { gridColumnFieldsSelector, gridColumnDefinitionsSelector, gridColumnLookupSelector, gridColumnsStateSelector, gridColumnVisibilityModelSelector, gridVisibleColumnDefinitionsSelector, gridColumnPositionsSelector } from "./gridColumnsSelector.mjs";
|
|
@@ -340,6 +341,16 @@ export function useGridColumns(apiRef, props) {
|
|
|
340
341
|
apiRef.current.setColumnVisibilityModel(props.columnVisibilityModel);
|
|
341
342
|
}
|
|
342
343
|
}, [apiRef, logger, props.columnVisibilityModel]);
|
|
344
|
+
const checkMultiSelectColumns = React.useCallback(orderedFields => {
|
|
345
|
+
if (props.signature !== GridSignature.DataGrid) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
const lookup = gridColumnLookupSelector(apiRef);
|
|
349
|
+
if (orderedFields.some(field => lookup[field]?.type === 'multiSelect')) {
|
|
350
|
+
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']);
|
|
351
|
+
}
|
|
352
|
+
}, [apiRef, props.signature]);
|
|
353
|
+
useGridEvent(apiRef, 'columnsChange', checkMultiSelectColumns);
|
|
343
354
|
}
|
|
344
355
|
function mergeColumnsState(columnsState) {
|
|
345
356
|
return state => _extends({}, state, {
|
|
@@ -41,7 +41,7 @@ export interface GridDataSourceApiBase {
|
|
|
41
41
|
}
|
|
42
42
|
export interface GridDataSourceBaseOptions {
|
|
43
43
|
cacheOptions?: GridDataSourceCacheDefaultConfig;
|
|
44
|
-
fetchRowChildren?: (parents: GridRowId[],
|
|
44
|
+
fetchRowChildren?: (parents: GridRowId[], fetchParams: GridGetRowsParams[], showChildrenLoading?: boolean) => void;
|
|
45
45
|
clearDataSourceState?: () => void;
|
|
46
46
|
handleEditRow?: (params: GridUpdateRowParams, updatedRow: GridRowModel) => void;
|
|
47
47
|
}
|
|
@@ -41,7 +41,7 @@ export interface GridDataSourceApiBase {
|
|
|
41
41
|
}
|
|
42
42
|
export interface GridDataSourceBaseOptions {
|
|
43
43
|
cacheOptions?: GridDataSourceCacheDefaultConfig;
|
|
44
|
-
fetchRowChildren?: (parents: GridRowId[],
|
|
44
|
+
fetchRowChildren?: (parents: GridRowId[], fetchParams: GridGetRowsParams[], showChildrenLoading?: boolean) => void;
|
|
45
45
|
clearDataSourceState?: () => void;
|
|
46
46
|
handleEditRow?: (params: GridUpdateRowParams, updatedRow: GridRowModel) => void;
|
|
47
47
|
}
|
|
@@ -14,8 +14,8 @@ export declare const useGridDataSourceBase: <Api extends GridPrivateApiCommunity
|
|
|
14
14
|
debouncedFetchRows: ((parentId?: GridRowId, params?: import("./models.mjs").GridDataSourceFetchRowsParams<import("@mui/x-data-grid").GridGetRowsParams>) => Promise<void>) & import("@mui/utils/debounce").Cancelable;
|
|
15
15
|
strategyProcessor: {
|
|
16
16
|
strategyName: DataSourceRowsUpdateStrategy;
|
|
17
|
-
group: "
|
|
18
|
-
processor: GridStrategyProcessor<"
|
|
17
|
+
group: "dataSourceRootRowsUpdate";
|
|
18
|
+
processor: GridStrategyProcessor<"dataSourceRootRowsUpdate">;
|
|
19
19
|
};
|
|
20
20
|
setStrategyAvailability: () => void;
|
|
21
21
|
startPolling: () => void;
|
|
@@ -14,8 +14,8 @@ export declare const useGridDataSourceBase: <Api extends GridPrivateApiCommunity
|
|
|
14
14
|
debouncedFetchRows: ((parentId?: GridRowId, params?: import("./models.js").GridDataSourceFetchRowsParams<import("@mui/x-data-grid").GridGetRowsParams>) => Promise<void>) & import("@mui/utils/debounce").Cancelable;
|
|
15
15
|
strategyProcessor: {
|
|
16
16
|
strategyName: DataSourceRowsUpdateStrategy;
|
|
17
|
-
group: "
|
|
18
|
-
processor: GridStrategyProcessor<"
|
|
17
|
+
group: "dataSourceRootRowsUpdate";
|
|
18
|
+
processor: GridStrategyProcessor<"dataSourceRootRowsUpdate">;
|
|
19
19
|
};
|
|
20
20
|
setStrategyAvailability: () => void;
|
|
21
21
|
startPolling: () => void;
|
|
@@ -25,7 +25,7 @@ var _gridDataSourceSelector = require("./gridDataSourceSelector");
|
|
|
25
25
|
var _utils2 = require("./utils");
|
|
26
26
|
var _cache = require("./cache");
|
|
27
27
|
var _gridDataSourceError = require("./gridDataSourceError");
|
|
28
|
-
const _excluded = ["skipCache", "keepChildrenExpanded"];
|
|
28
|
+
const _excluded = ["skipCache", "keepChildrenExpanded", "showChildrenLoading"];
|
|
29
29
|
const noopCache = {
|
|
30
30
|
clear: () => {},
|
|
31
31
|
get: () => undefined,
|
|
@@ -64,22 +64,26 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
64
64
|
if (!getRows) {
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
|
-
if (parentId && parentId !== _gridRowsUtils.GRID_ROOT_GROUP_ID && props.signature !== 'DataGrid') {
|
|
68
|
-
options.fetchRowChildren?.([parentId]);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
options.clearDataSourceState?.();
|
|
72
67
|
const _ref = params || {},
|
|
73
68
|
{
|
|
74
69
|
skipCache,
|
|
75
|
-
keepChildrenExpanded
|
|
70
|
+
keepChildrenExpanded,
|
|
71
|
+
showChildrenLoading
|
|
76
72
|
} = _ref,
|
|
77
73
|
getRowsParams = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
78
74
|
const fetchParams = (0, _extends2.default)({}, (0, _gridDataSourceSelector.gridGetRowsParamsSelector)(apiRef), apiRef.current.unstable_applyPipeProcessors('getRowsParams', {}), getRowsParams);
|
|
75
|
+
if (parentId && parentId !== _gridRowsUtils.GRID_ROOT_GROUP_ID && props.signature !== 'DataGrid') {
|
|
76
|
+
options.fetchRowChildren?.([parentId], [fetchParams], showChildrenLoading);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
options.clearDataSourceState?.();
|
|
79
80
|
const cacheKeys = cacheChunkManager.getCacheKeys(fetchParams);
|
|
80
81
|
const responses = cacheKeys.map(cacheKey => cache.get(cacheKey));
|
|
81
82
|
if (!skipCache && responses.every(response => response !== undefined)) {
|
|
82
|
-
|
|
83
|
+
// Bump the request id so any cache-miss request still in flight is treated as
|
|
84
|
+
// stale and won't override the cached data we're about to apply.
|
|
85
|
+
lastRequestId.current += 1;
|
|
86
|
+
apiRef.current.applyStrategyProcessor('dataSourceRootRowsUpdate', {
|
|
83
87
|
response: _utils2.CacheChunkManager.mergeResponses(responses),
|
|
84
88
|
fetchParams,
|
|
85
89
|
options: {
|
|
@@ -87,6 +91,9 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
87
91
|
keepChildrenExpanded
|
|
88
92
|
}
|
|
89
93
|
});
|
|
94
|
+
if (standardRowsUpdateStrategyActive) {
|
|
95
|
+
apiRef.current.setLoading(false);
|
|
96
|
+
}
|
|
90
97
|
return;
|
|
91
98
|
}
|
|
92
99
|
|
|
@@ -101,7 +108,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
101
108
|
const cacheResponses = cacheChunkManager.splitResponse(fetchParams, getRowsResponse);
|
|
102
109
|
cacheResponses.forEach((response, key) => cache.set(key, response));
|
|
103
110
|
if (lastRequestId.current === requestId) {
|
|
104
|
-
apiRef.current.applyStrategyProcessor('
|
|
111
|
+
apiRef.current.applyStrategyProcessor('dataSourceRootRowsUpdate', {
|
|
105
112
|
response: getRowsResponse,
|
|
106
113
|
fetchParams,
|
|
107
114
|
options: {
|
|
@@ -112,7 +119,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
112
119
|
}
|
|
113
120
|
} catch (originalError) {
|
|
114
121
|
if (lastRequestId.current === requestId) {
|
|
115
|
-
apiRef.current.applyStrategyProcessor('
|
|
122
|
+
apiRef.current.applyStrategyProcessor('dataSourceRootRowsUpdate', {
|
|
116
123
|
error: originalError,
|
|
117
124
|
fetchParams,
|
|
118
125
|
options: {
|
|
@@ -126,7 +133,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
126
133
|
params: fetchParams,
|
|
127
134
|
cause: originalError
|
|
128
135
|
}));
|
|
129
|
-
} else {
|
|
136
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
|
130
137
|
(0, _warning.warnOnce)(['MUI X: A call to `dataSource.getRows()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'], 'error');
|
|
131
138
|
}
|
|
132
139
|
}
|
|
@@ -159,9 +166,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
159
166
|
return acc;
|
|
160
167
|
}, []);
|
|
161
168
|
if (expandedGroupIds.length > 0) {
|
|
162
|
-
fetchRowChildrenOption(expandedGroupIds,
|
|
163
|
-
showChildrenLoading: false
|
|
164
|
-
});
|
|
169
|
+
fetchRowChildrenOption(expandedGroupIds, [], false);
|
|
165
170
|
}
|
|
166
171
|
};
|
|
167
172
|
const fetchParams = (0, _extends2.default)({}, (0, _gridDataSourceSelector.gridGetRowsParamsSelector)(apiRef), apiRef.current.unstable_applyPipeProcessors('getRowsParams', {}));
|
|
@@ -179,7 +184,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
179
184
|
}
|
|
180
185
|
const cacheResponses = cacheChunkManager.splitResponse(fetchParams, response);
|
|
181
186
|
cacheResponses.forEach((cacheResponse, key) => cache.set(key, cacheResponse));
|
|
182
|
-
apiRef.current.applyStrategyProcessor('
|
|
187
|
+
apiRef.current.applyStrategyProcessor('dataSourceRootRowsUpdate', {
|
|
183
188
|
response,
|
|
184
189
|
fetchParams,
|
|
185
190
|
options: {}
|
|
@@ -245,7 +250,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
245
250
|
params,
|
|
246
251
|
cause: errorThrown
|
|
247
252
|
}));
|
|
248
|
-
} else {
|
|
253
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
|
249
254
|
(0, _warning.warnOnce)(['MUI X: A call to `dataSource.updateRow()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'], 'error');
|
|
250
255
|
}
|
|
251
256
|
throw errorThrown; // Let the caller handle the error further
|
|
@@ -260,10 +265,17 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
260
265
|
};
|
|
261
266
|
const debouncedFetchRows = React.useMemo(() => (0, _debounce.default)(fetchRows, 0), [fetchRows]);
|
|
262
267
|
const handleFetchRowsOnParamsChange = React.useCallback(() => {
|
|
268
|
+
// Clear the rows first and immediately mark the grid as loading so the overlay
|
|
269
|
+
// selector never observes the intermediate `rows=[] && loading=false` state that
|
|
270
|
+
// would otherwise pick `noRowsOverlay`. Order matters: `setRows([])` rebuilds
|
|
271
|
+
// `state.rows` from `props.loading`, so the `setLoading(true)` call must come after
|
|
272
|
+
// it to survive the rebuild. This handler is only wired up when a standard strategy
|
|
273
|
+
// is active via the `runIf` guards on the returned `events` object.
|
|
263
274
|
apiRef.current.setRows([]);
|
|
275
|
+
apiRef.current.setLoading(true);
|
|
264
276
|
stopPolling();
|
|
265
277
|
debouncedFetchRows();
|
|
266
|
-
}, [stopPolling, debouncedFetchRows
|
|
278
|
+
}, [apiRef, stopPolling, debouncedFetchRows]);
|
|
267
279
|
const isFirstRender = React.useRef(true);
|
|
268
280
|
React.useEffect(() => {
|
|
269
281
|
if (isFirstRender.current) {
|
|
@@ -290,7 +302,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
290
302
|
React.useEffect(() => {
|
|
291
303
|
// Return early if the proper strategy isn't set yet
|
|
292
304
|
// Context: https://github.com/mui/mui-x/issues/19650
|
|
293
|
-
if (currentStrategy !== _utils2.DataSourceRowsUpdateStrategy.Default && currentStrategy !== _utils2.DataSourceRowsUpdateStrategy.LazyLoading && currentStrategy !== _utils2.DataSourceRowsUpdateStrategy.GroupedData) {
|
|
305
|
+
if (currentStrategy !== _utils2.DataSourceRowsUpdateStrategy.Default && currentStrategy !== _utils2.DataSourceRowsUpdateStrategy.LazyLoading && currentStrategy !== _utils2.DataSourceRowsUpdateStrategy.GroupedData && currentStrategy !== _utils2.DataSourceRowsUpdateStrategy.LazyLoadedGroupedData) {
|
|
294
306
|
return undefined;
|
|
295
307
|
}
|
|
296
308
|
if (props.dataSource) {
|
|
@@ -311,7 +323,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
311
323
|
debouncedFetchRows,
|
|
312
324
|
strategyProcessor: {
|
|
313
325
|
strategyName: _utils2.DataSourceRowsUpdateStrategy.Default,
|
|
314
|
-
group: '
|
|
326
|
+
group: 'dataSourceRootRowsUpdate',
|
|
315
327
|
processor: handleDataUpdate
|
|
316
328
|
},
|
|
317
329
|
setStrategyAvailability,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["skipCache", "keepChildrenExpanded"];
|
|
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';
|
|
@@ -57,22 +57,26 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
57
57
|
if (!getRows) {
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
-
if (parentId && parentId !== GRID_ROOT_GROUP_ID && props.signature !== 'DataGrid') {
|
|
61
|
-
options.fetchRowChildren?.([parentId]);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
options.clearDataSourceState?.();
|
|
65
60
|
const _ref = params || {},
|
|
66
61
|
{
|
|
67
62
|
skipCache,
|
|
68
|
-
keepChildrenExpanded
|
|
63
|
+
keepChildrenExpanded,
|
|
64
|
+
showChildrenLoading
|
|
69
65
|
} = _ref,
|
|
70
66
|
getRowsParams = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
71
67
|
const fetchParams = _extends({}, gridGetRowsParamsSelector(apiRef), apiRef.current.unstable_applyPipeProcessors('getRowsParams', {}), getRowsParams);
|
|
68
|
+
if (parentId && parentId !== GRID_ROOT_GROUP_ID && props.signature !== 'DataGrid') {
|
|
69
|
+
options.fetchRowChildren?.([parentId], [fetchParams], showChildrenLoading);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
options.clearDataSourceState?.();
|
|
72
73
|
const cacheKeys = cacheChunkManager.getCacheKeys(fetchParams);
|
|
73
74
|
const responses = cacheKeys.map(cacheKey => cache.get(cacheKey));
|
|
74
75
|
if (!skipCache && responses.every(response => response !== undefined)) {
|
|
75
|
-
|
|
76
|
+
// Bump the request id so any cache-miss request still in flight is treated as
|
|
77
|
+
// stale and won't override the cached data we're about to apply.
|
|
78
|
+
lastRequestId.current += 1;
|
|
79
|
+
apiRef.current.applyStrategyProcessor('dataSourceRootRowsUpdate', {
|
|
76
80
|
response: CacheChunkManager.mergeResponses(responses),
|
|
77
81
|
fetchParams,
|
|
78
82
|
options: {
|
|
@@ -80,6 +84,9 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
80
84
|
keepChildrenExpanded
|
|
81
85
|
}
|
|
82
86
|
});
|
|
87
|
+
if (standardRowsUpdateStrategyActive) {
|
|
88
|
+
apiRef.current.setLoading(false);
|
|
89
|
+
}
|
|
83
90
|
return;
|
|
84
91
|
}
|
|
85
92
|
|
|
@@ -94,7 +101,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
94
101
|
const cacheResponses = cacheChunkManager.splitResponse(fetchParams, getRowsResponse);
|
|
95
102
|
cacheResponses.forEach((response, key) => cache.set(key, response));
|
|
96
103
|
if (lastRequestId.current === requestId) {
|
|
97
|
-
apiRef.current.applyStrategyProcessor('
|
|
104
|
+
apiRef.current.applyStrategyProcessor('dataSourceRootRowsUpdate', {
|
|
98
105
|
response: getRowsResponse,
|
|
99
106
|
fetchParams,
|
|
100
107
|
options: {
|
|
@@ -105,7 +112,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
105
112
|
}
|
|
106
113
|
} catch (originalError) {
|
|
107
114
|
if (lastRequestId.current === requestId) {
|
|
108
|
-
apiRef.current.applyStrategyProcessor('
|
|
115
|
+
apiRef.current.applyStrategyProcessor('dataSourceRootRowsUpdate', {
|
|
109
116
|
error: originalError,
|
|
110
117
|
fetchParams,
|
|
111
118
|
options: {
|
|
@@ -119,7 +126,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
119
126
|
params: fetchParams,
|
|
120
127
|
cause: originalError
|
|
121
128
|
}));
|
|
122
|
-
} else {
|
|
129
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
|
123
130
|
warnOnce(['MUI X: A call to `dataSource.getRows()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'], 'error');
|
|
124
131
|
}
|
|
125
132
|
}
|
|
@@ -152,9 +159,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
152
159
|
return acc;
|
|
153
160
|
}, []);
|
|
154
161
|
if (expandedGroupIds.length > 0) {
|
|
155
|
-
fetchRowChildrenOption(expandedGroupIds,
|
|
156
|
-
showChildrenLoading: false
|
|
157
|
-
});
|
|
162
|
+
fetchRowChildrenOption(expandedGroupIds, [], false);
|
|
158
163
|
}
|
|
159
164
|
};
|
|
160
165
|
const fetchParams = _extends({}, gridGetRowsParamsSelector(apiRef), apiRef.current.unstable_applyPipeProcessors('getRowsParams', {}));
|
|
@@ -172,7 +177,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
172
177
|
}
|
|
173
178
|
const cacheResponses = cacheChunkManager.splitResponse(fetchParams, response);
|
|
174
179
|
cacheResponses.forEach((cacheResponse, key) => cache.set(key, cacheResponse));
|
|
175
|
-
apiRef.current.applyStrategyProcessor('
|
|
180
|
+
apiRef.current.applyStrategyProcessor('dataSourceRootRowsUpdate', {
|
|
176
181
|
response,
|
|
177
182
|
fetchParams,
|
|
178
183
|
options: {}
|
|
@@ -238,7 +243,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
238
243
|
params,
|
|
239
244
|
cause: errorThrown
|
|
240
245
|
}));
|
|
241
|
-
} else {
|
|
246
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
|
242
247
|
warnOnce(['MUI X: A call to `dataSource.updateRow()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'], 'error');
|
|
243
248
|
}
|
|
244
249
|
throw errorThrown; // Let the caller handle the error further
|
|
@@ -253,10 +258,17 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
253
258
|
};
|
|
254
259
|
const debouncedFetchRows = React.useMemo(() => debounce(fetchRows, 0), [fetchRows]);
|
|
255
260
|
const handleFetchRowsOnParamsChange = React.useCallback(() => {
|
|
261
|
+
// Clear the rows first and immediately mark the grid as loading so the overlay
|
|
262
|
+
// selector never observes the intermediate `rows=[] && loading=false` state that
|
|
263
|
+
// would otherwise pick `noRowsOverlay`. Order matters: `setRows([])` rebuilds
|
|
264
|
+
// `state.rows` from `props.loading`, so the `setLoading(true)` call must come after
|
|
265
|
+
// it to survive the rebuild. This handler is only wired up when a standard strategy
|
|
266
|
+
// is active via the `runIf` guards on the returned `events` object.
|
|
256
267
|
apiRef.current.setRows([]);
|
|
268
|
+
apiRef.current.setLoading(true);
|
|
257
269
|
stopPolling();
|
|
258
270
|
debouncedFetchRows();
|
|
259
|
-
}, [stopPolling, debouncedFetchRows
|
|
271
|
+
}, [apiRef, stopPolling, debouncedFetchRows]);
|
|
260
272
|
const isFirstRender = React.useRef(true);
|
|
261
273
|
React.useEffect(() => {
|
|
262
274
|
if (isFirstRender.current) {
|
|
@@ -283,7 +295,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
283
295
|
React.useEffect(() => {
|
|
284
296
|
// Return early if the proper strategy isn't set yet
|
|
285
297
|
// Context: https://github.com/mui/mui-x/issues/19650
|
|
286
|
-
if (currentStrategy !== DataSourceRowsUpdateStrategy.Default && currentStrategy !== DataSourceRowsUpdateStrategy.LazyLoading && currentStrategy !== DataSourceRowsUpdateStrategy.GroupedData) {
|
|
298
|
+
if (currentStrategy !== DataSourceRowsUpdateStrategy.Default && currentStrategy !== DataSourceRowsUpdateStrategy.LazyLoading && currentStrategy !== DataSourceRowsUpdateStrategy.GroupedData && currentStrategy !== DataSourceRowsUpdateStrategy.LazyLoadedGroupedData) {
|
|
287
299
|
return undefined;
|
|
288
300
|
}
|
|
289
301
|
if (props.dataSource) {
|
|
@@ -304,7 +316,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
304
316
|
debouncedFetchRows,
|
|
305
317
|
strategyProcessor: {
|
|
306
318
|
strategyName: DataSourceRowsUpdateStrategy.Default,
|
|
307
|
-
group: '
|
|
319
|
+
group: 'dataSourceRootRowsUpdate',
|
|
308
320
|
processor: handleDataUpdate
|
|
309
321
|
},
|
|
310
322
|
setStrategyAvailability,
|