@mui/x-data-grid 9.11.0 → 9.13.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 +317 -0
- package/DataGrid/DataGrid.js +4 -2
- package/DataGrid/DataGrid.mjs +4 -2
- package/DataGrid/useDataGridProps.d.mts +1 -1
- package/DataGrid/useDataGridProps.d.ts +1 -1
- package/components/GridPagination.js +1 -1
- package/components/GridPagination.mjs +1 -1
- package/components/GridRow.d.mts +1 -0
- package/components/GridRow.d.ts +1 -0
- package/components/GridRow.js +41 -6
- package/components/GridRow.mjs +41 -6
- package/components/cell/GridCell.js +21 -5
- package/components/cell/GridCell.mjs +21 -5
- package/components/cell/GridEditBooleanCell.d.mts +1 -1
- package/components/cell/GridEditBooleanCell.d.ts +1 -1
- package/components/cell/GridEditBooleanCell.js +4 -4
- package/components/cell/GridEditBooleanCell.mjs +4 -4
- package/components/cell/GridEditDateCell.d.mts +1 -1
- package/components/cell/GridEditDateCell.d.ts +1 -1
- package/components/cell/GridEditDateCell.js +5 -5
- package/components/cell/GridEditDateCell.mjs +5 -5
- package/components/cell/GridEditInputCell.d.mts +1 -1
- package/components/cell/GridEditInputCell.d.ts +1 -1
- package/components/cell/GridEditInputCell.js +1 -1
- package/components/cell/GridEditInputCell.mjs +1 -1
- package/components/cell/GridEditLongTextCell.d.mts +1 -1
- package/components/cell/GridEditLongTextCell.d.ts +1 -1
- package/components/cell/GridEditLongTextCell.js +2 -2
- package/components/cell/GridEditLongTextCell.mjs +2 -2
- package/components/cell/GridEditSingleSelectCell.d.mts +1 -1
- package/components/cell/GridEditSingleSelectCell.d.ts +1 -1
- package/components/cell/GridEditSingleSelectCell.js +4 -4
- package/components/cell/GridEditSingleSelectCell.mjs +4 -4
- package/components/columnHeaders/GridBaseColumnHeaders.js +1 -1
- package/components/columnHeaders/GridBaseColumnHeaders.mjs +1 -1
- package/components/columnHeaders/GridColumnHeaderItem.js +4 -0
- package/components/columnHeaders/GridColumnHeaderItem.mjs +4 -0
- package/components/columnHeaders/GridGenericColumnHeaderItem.d.mts +7 -0
- package/components/columnHeaders/GridGenericColumnHeaderItem.d.ts +7 -0
- package/components/columnHeaders/GridGenericColumnHeaderItem.js +5 -4
- package/components/columnHeaders/GridGenericColumnHeaderItem.mjs +5 -4
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +18 -6
- package/components/panel/filterPanel/GridFilterInputSingleSelect.mjs +18 -6
- package/components/toolbarV8/Toolbar.d.mts +5 -1
- package/components/toolbarV8/Toolbar.d.ts +5 -1
- package/components/toolbarV8/Toolbar.js +34 -12
- package/components/toolbarV8/Toolbar.mjs +33 -11
- package/constants/gridClasses.d.mts +12 -0
- package/constants/gridClasses.d.ts +12 -0
- package/constants/gridClasses.js +1 -1
- package/constants/gridClasses.mjs +1 -1
- package/constants/localeTextConstants.js +4 -0
- package/constants/localeTextConstants.mjs +4 -0
- package/hooks/core/useGridApiInitialization.js +5 -1
- package/hooks/core/useGridApiInitialization.mjs +5 -1
- package/hooks/core/useGridStateInitialization.js +3 -1
- package/hooks/core/useGridStateInitialization.mjs +3 -1
- package/hooks/core/useGridVirtualizer.js +17 -1
- package/hooks/core/useGridVirtualizer.mjs +17 -1
- package/hooks/features/columnResize/useGridColumnResize.js +5 -0
- package/hooks/features/columnResize/useGridColumnResize.mjs +5 -0
- package/hooks/features/columns/gridColumnsUtils.d.mts +1 -1
- package/hooks/features/columns/gridColumnsUtils.d.ts +1 -1
- package/hooks/features/columns/gridColumnsUtils.js +2 -2
- package/hooks/features/columns/gridColumnsUtils.mjs +2 -2
- package/hooks/features/dataSource/gridDataSourceSelector.js +6 -2
- package/hooks/features/dataSource/gridDataSourceSelector.mjs +6 -2
- package/hooks/features/dataSource/models.d.mts +2 -2
- package/hooks/features/dataSource/models.d.ts +2 -2
- package/hooks/features/dataSource/useGridDataSourceBase.js +25 -8
- package/hooks/features/dataSource/useGridDataSourceBase.mjs +26 -9
- package/hooks/features/dataSource/useGridDataSourceFilterModelChange.d.mts +9 -0
- package/hooks/features/dataSource/useGridDataSourceFilterModelChange.d.ts +9 -0
- package/hooks/features/dataSource/useGridDataSourceFilterModelChange.js +57 -0
- package/hooks/features/dataSource/useGridDataSourceFilterModelChange.mjs +49 -0
- package/hooks/features/editing/useGridCellEditing.js +3 -1
- package/hooks/features/editing/useGridCellEditing.mjs +3 -1
- package/hooks/features/editing/useGridRowEditing.js +3 -1
- package/hooks/features/editing/useGridRowEditing.mjs +3 -1
- package/hooks/features/filter/gridFilterUtils.d.mts +13 -0
- package/hooks/features/filter/gridFilterUtils.d.ts +13 -0
- package/hooks/features/filter/gridFilterUtils.js +32 -1
- package/hooks/features/filter/gridFilterUtils.mjs +29 -1
- package/hooks/features/filter/useGridFilter.js +1 -21
- package/hooks/features/filter/useGridFilter.mjs +2 -22
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +1 -1
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.mjs +1 -1
- package/hooks/features/pivoting/gridPivotingInterfaces.d.mts +2 -2
- package/hooks/features/pivoting/gridPivotingInterfaces.d.ts +2 -2
- package/hooks/features/rowSelection/useGridRowSelection.js +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.mjs +2 -2
- package/hooks/features/rows/gridRowsUtils.d.mts +37 -3
- package/hooks/features/rows/gridRowsUtils.d.ts +37 -3
- package/hooks/features/rows/gridRowsUtils.js +120 -23
- package/hooks/features/rows/gridRowsUtils.mjs +115 -22
- package/hooks/features/rows/useGridRowSpanning.js +5 -0
- package/hooks/features/rows/useGridRowSpanning.mjs +5 -0
- package/hooks/features/rows/useGridRows.js +10 -1
- package/hooks/features/rows/useGridRows.mjs +10 -1
- package/hooks/features/virtualization/gridVirtualizationSelectors.d.mts +1 -1
- package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +1 -1
- package/hooks/utils/useGridEvent.d.mts +2 -2
- package/hooks/utils/useGridEvent.d.ts +2 -2
- package/hooks/utils/useGridEvent.js +2 -0
- package/hooks/utils/useGridEvent.mjs +2 -0
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/index.d.mts +4 -2
- package/internals/index.d.ts +4 -2
- package/internals/index.js +48 -0
- package/internals/index.mjs +4 -2
- package/locales/arSD.js +5 -0
- package/locales/arSD.mjs +5 -0
- package/locales/beBY.js +5 -0
- package/locales/beBY.mjs +5 -0
- package/locales/bgBG.js +5 -0
- package/locales/bgBG.mjs +5 -0
- package/locales/bnBD.js +5 -0
- package/locales/bnBD.mjs +5 -0
- package/locales/caES.js +5 -0
- package/locales/caES.mjs +5 -0
- package/locales/csCZ.js +5 -0
- package/locales/csCZ.mjs +5 -0
- package/locales/daDK.js +5 -0
- package/locales/daDK.mjs +5 -0
- package/locales/deDE.js +5 -0
- package/locales/deDE.mjs +5 -0
- package/locales/elGR.js +5 -0
- package/locales/elGR.mjs +5 -0
- package/locales/esES.js +5 -0
- package/locales/esES.mjs +5 -0
- package/locales/faIR.js +5 -0
- package/locales/faIR.mjs +5 -0
- package/locales/fiFI.js +5 -0
- package/locales/fiFI.mjs +5 -0
- package/locales/frFR.js +5 -0
- package/locales/frFR.mjs +5 -0
- package/locales/heIL.js +5 -0
- package/locales/heIL.mjs +5 -0
- package/locales/hrHR.js +5 -0
- package/locales/hrHR.mjs +5 -0
- package/locales/huHU.js +5 -0
- package/locales/huHU.mjs +5 -0
- package/locales/hyAM.js +5 -0
- package/locales/hyAM.mjs +5 -0
- package/locales/idID.js +5 -0
- package/locales/idID.mjs +5 -0
- package/locales/isIS.js +5 -0
- package/locales/isIS.mjs +5 -0
- package/locales/itIT.js +5 -0
- package/locales/itIT.mjs +5 -0
- package/locales/jaJP.js +5 -0
- package/locales/jaJP.mjs +5 -0
- package/locales/koKR.js +5 -0
- package/locales/koKR.mjs +5 -0
- package/locales/nbNO.js +5 -0
- package/locales/nbNO.mjs +5 -0
- package/locales/nlNL.js +5 -0
- package/locales/nlNL.mjs +5 -0
- package/locales/nnNO.js +5 -0
- package/locales/nnNO.mjs +5 -0
- package/locales/plPL.js +5 -0
- package/locales/plPL.mjs +5 -0
- package/locales/ptBR.js +5 -0
- package/locales/ptBR.mjs +5 -0
- package/locales/ptPT.js +5 -0
- package/locales/ptPT.mjs +5 -0
- package/locales/roRO.js +5 -0
- package/locales/roRO.mjs +5 -0
- package/locales/ruRU.js +5 -0
- package/locales/ruRU.mjs +5 -0
- package/locales/skSK.js +5 -0
- package/locales/skSK.mjs +5 -0
- package/locales/svSE.js +5 -0
- package/locales/svSE.mjs +5 -0
- package/locales/thTH.js +5 -0
- package/locales/thTH.mjs +5 -0
- package/locales/trTR.js +5 -0
- package/locales/trTR.mjs +5 -0
- package/locales/ukUA.js +5 -0
- package/locales/ukUA.mjs +5 -0
- package/locales/urPK.js +5 -0
- package/locales/urPK.mjs +5 -0
- package/locales/viVN.js +5 -0
- package/locales/viVN.mjs +5 -0
- package/locales/zhCN.js +5 -0
- package/locales/zhCN.mjs +5 -0
- package/locales/zhHK.js +5 -0
- package/locales/zhHK.mjs +5 -0
- package/locales/zhTW.js +5 -0
- package/locales/zhTW.mjs +5 -0
- package/material/variables.d.mts +6 -1
- package/material/variables.d.ts +6 -1
- package/material/variables.js +17 -3
- package/material/variables.mjs +14 -4
- package/models/api/gridApiCommon.d.mts +2 -2
- package/models/api/gridApiCommon.d.ts +2 -2
- package/models/api/gridCallbackDetails.d.mts +11 -1
- package/models/api/gridCallbackDetails.d.ts +11 -1
- package/models/api/gridLocaleTextApi.d.mts +3 -0
- package/models/api/gridLocaleTextApi.d.ts +3 -0
- package/models/api/gridRowApi.d.mts +19 -7
- package/models/api/gridRowApi.d.ts +19 -7
- package/models/api/gridStateApi.d.mts +3 -2
- package/models/api/gridStateApi.d.ts +3 -2
- package/models/api/index.d.mts +1 -1
- package/models/api/index.d.ts +1 -1
- package/models/colDef/gridColDef.d.mts +5 -0
- package/models/colDef/gridColDef.d.ts +5 -0
- package/models/configuration/gridConfiguration.d.mts +13 -1
- package/models/configuration/gridConfiguration.d.ts +13 -1
- package/models/controlStateItem.d.mts +3 -2
- package/models/controlStateItem.d.ts +3 -2
- package/models/events/gridEventListener.d.mts +3 -2
- package/models/events/gridEventListener.d.ts +3 -2
- package/models/gridDataSource.d.mts +3 -0
- package/models/gridDataSource.d.ts +3 -0
- package/models/gridRows.d.mts +28 -1
- package/models/gridRows.d.ts +28 -1
- package/models/props/DataGridProps.d.mts +41 -38
- package/models/props/DataGridProps.d.ts +41 -38
- package/package.json +6 -6
- package/utils/domUtils.js +1 -1
- package/utils/domUtils.mjs +1 -1
- package/utils/getPublicApiRef.d.mts +2 -2
- package/utils/getPublicApiRef.d.ts +2 -2
- package/utils/getPublicApiRef.js +15 -3
- package/utils/getPublicApiRef.mjs +15 -3
- package/utils/keyboardUtils.d.mts +1 -0
- package/utils/keyboardUtils.d.ts +1 -0
- package/utils/keyboardUtils.js +6 -0
- package/utils/keyboardUtils.mjs +5 -0
|
@@ -6,7 +6,6 @@ import { GridSignature } from "../../../constants/signature.mjs";
|
|
|
6
6
|
import { gridColumnsStateSelector, gridColumnVisibilityModelSelector } from "./gridColumnsSelector.mjs";
|
|
7
7
|
import { clamp } from "../../../utils/utils.mjs";
|
|
8
8
|
import { gridDensityFactorSelector } from "../density/densitySelector.mjs";
|
|
9
|
-
import { gridHeaderFilteringEnabledSelector } from "../headerFiltering/gridHeaderFilteringSelectors.mjs";
|
|
10
9
|
import { gridColumnGroupsHeaderMaxDepthSelector } from "../columnGrouping/gridColumnGroupsSelector.mjs";
|
|
11
10
|
export const COLUMNS_DIMENSION_PROPERTIES = ['maxWidth', 'minWidth', 'width', 'flex'];
|
|
12
11
|
/**
|
|
@@ -345,7 +344,8 @@ export function getTotalHeaderHeight(apiRef, props) {
|
|
|
345
344
|
}
|
|
346
345
|
const densityFactor = gridDensityFactorSelector(apiRef);
|
|
347
346
|
const maxDepth = gridColumnGroupsHeaderMaxDepthSelector(apiRef);
|
|
348
|
-
|
|
347
|
+
// Not `gridHeaderFilteringEnabledSelector`: that state is synced in an effect, so it lags one render behind `props.headerFilters`.
|
|
348
|
+
const isHeaderFilteringEnabled = props.signature !== 'DataGrid' && (props.headerFilters ?? false);
|
|
349
349
|
const columnHeadersHeight = Math.floor(props.columnHeaderHeight * densityFactor);
|
|
350
350
|
const columnGroupHeadersHeight = Math.floor((props.columnGroupHeaderHeight ?? props.columnHeaderHeight) * densityFactor);
|
|
351
351
|
const filterHeadersHeight = isHeaderFilteringEnabled ? Math.floor((props.headerFilterHeight ?? props.columnHeaderHeight) * densityFactor) : 0;
|
|
@@ -5,14 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.gridGetRowsParamsSelector = void 0;
|
|
7
7
|
var _gridFilterSelector = require("../filter/gridFilterSelector");
|
|
8
|
+
var _gridFilterUtils = require("../filter/gridFilterUtils");
|
|
8
9
|
var _gridSortingSelector = require("../sorting/gridSortingSelector");
|
|
9
10
|
var _gridPaginationSelector = require("../pagination/gridPaginationSelector");
|
|
11
|
+
var _columns = require("../columns");
|
|
10
12
|
var _createSelector = require("../../../utils/createSelector");
|
|
11
|
-
const gridGetRowsParamsSelector = exports.gridGetRowsParamsSelector = (0, _createSelector.createSelector)(_gridFilterSelector.gridFilterModelSelector, _gridSortingSelector.gridSortModelSelector, _gridPaginationSelector.gridPaginationModelSelector, (filterModel, sortModel, paginationModel) => ({
|
|
13
|
+
const gridGetRowsParamsSelector = exports.gridGetRowsParamsSelector = (0, _createSelector.createSelector)(_gridFilterSelector.gridFilterModelSelector, _gridSortingSelector.gridSortModelSelector, _gridPaginationSelector.gridPaginationModelSelector, _columns.gridColumnLookupSelector, (filterModel, sortModel, paginationModel, columnsLookup) => ({
|
|
12
14
|
groupKeys: [],
|
|
13
15
|
paginationModel,
|
|
14
16
|
sortModel,
|
|
15
|
-
|
|
17
|
+
// An item without a value is an incomplete filter, not a constraint. The client-side
|
|
18
|
+
// engine already ignores those, so the server must not be asked to honor them either.
|
|
19
|
+
filterModel: (0, _gridFilterUtils.removeIncompleteFilterItems)(filterModel, columnsLookup),
|
|
16
20
|
start: paginationModel.page * paginationModel.pageSize,
|
|
17
21
|
end: paginationModel.page * paginationModel.pageSize + paginationModel.pageSize - 1
|
|
18
22
|
}));
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { gridFilterModelSelector } from "../filter/gridFilterSelector.mjs";
|
|
2
|
+
import { removeIncompleteFilterItems } from "../filter/gridFilterUtils.mjs";
|
|
2
3
|
import { gridSortModelSelector } from "../sorting/gridSortingSelector.mjs";
|
|
3
4
|
import { gridPaginationModelSelector } from "../pagination/gridPaginationSelector.mjs";
|
|
5
|
+
import { gridColumnLookupSelector } from "../columns/index.mjs";
|
|
4
6
|
import { createSelector } from "../../../utils/createSelector.mjs";
|
|
5
|
-
export const gridGetRowsParamsSelector = createSelector(gridFilterModelSelector, gridSortModelSelector, gridPaginationModelSelector, (filterModel, sortModel, paginationModel) => ({
|
|
7
|
+
export const gridGetRowsParamsSelector = createSelector(gridFilterModelSelector, gridSortModelSelector, gridPaginationModelSelector, gridColumnLookupSelector, (filterModel, sortModel, paginationModel, columnsLookup) => ({
|
|
6
8
|
groupKeys: [],
|
|
7
9
|
paginationModel,
|
|
8
10
|
sortModel,
|
|
9
|
-
|
|
11
|
+
// An item without a value is an incomplete filter, not a constraint. The client-side
|
|
12
|
+
// engine already ignores those, so the server must not be asked to honor them either.
|
|
13
|
+
filterModel: removeIncompleteFilterItems(filterModel, columnsLookup),
|
|
10
14
|
start: paginationModel.page * paginationModel.pageSize,
|
|
11
15
|
end: paginationModel.page * paginationModel.pageSize + paginationModel.pageSize - 1
|
|
12
16
|
}));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GridDataSourceCache, GridGetRowsParams, GridUpdateRowParams, GridGetRowsOptions } from "../../../models/gridDataSource.mjs";
|
|
2
|
-
import type { GridRowId, GridRowModel } from "../../../models/gridRows.mjs";
|
|
2
|
+
import type { GridRowId, GridRowModel, GridRowModelReplace, GridRowModelUpdate } from "../../../models/gridRows.mjs";
|
|
3
3
|
import type { GridDataSourceCacheDefaultConfig } from "./cache.mjs";
|
|
4
4
|
/**
|
|
5
5
|
* The parameters for the `fetchRows` method.
|
|
@@ -43,5 +43,5 @@ export interface GridDataSourceBaseOptions {
|
|
|
43
43
|
cacheOptions?: GridDataSourceCacheDefaultConfig;
|
|
44
44
|
fetchRowChildren?: (parents: GridRowId[], fetchParams: GridGetRowsParams[], showChildrenLoading?: boolean) => void;
|
|
45
45
|
clearDataSourceState?: () => void;
|
|
46
|
-
handleEditRow?: (params: GridUpdateRowParams,
|
|
46
|
+
handleEditRow?: (params: GridUpdateRowParams, rowUpdate: GridRowModelUpdate | GridRowModelReplace) => void;
|
|
47
47
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GridDataSourceCache, GridGetRowsParams, GridUpdateRowParams, GridGetRowsOptions } from "../../../models/gridDataSource.js";
|
|
2
|
-
import type { GridRowId, GridRowModel } from "../../../models/gridRows.js";
|
|
2
|
+
import type { GridRowId, GridRowModel, GridRowModelReplace, GridRowModelUpdate } from "../../../models/gridRows.js";
|
|
3
3
|
import type { GridDataSourceCacheDefaultConfig } from "./cache.js";
|
|
4
4
|
/**
|
|
5
5
|
* The parameters for the `fetchRows` method.
|
|
@@ -43,5 +43,5 @@ export interface GridDataSourceBaseOptions {
|
|
|
43
43
|
cacheOptions?: GridDataSourceCacheDefaultConfig;
|
|
44
44
|
fetchRowChildren?: (parents: GridRowId[], fetchParams: GridGetRowsParams[], showChildrenLoading?: boolean) => void;
|
|
45
45
|
clearDataSourceState?: () => void;
|
|
46
|
-
handleEditRow?: (params: GridUpdateRowParams,
|
|
46
|
+
handleEditRow?: (params: GridUpdateRowParams, rowUpdate: GridRowModelUpdate | GridRowModelReplace) => void;
|
|
47
47
|
}
|
|
@@ -21,7 +21,10 @@ var _strategyProcessing = require("../../core/strategyProcessing");
|
|
|
21
21
|
var _useGridSelector = require("../../utils/useGridSelector");
|
|
22
22
|
var _gridPaginationSelector = require("../pagination/gridPaginationSelector");
|
|
23
23
|
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
24
|
+
var _columns = require("../columns");
|
|
25
|
+
var _gridFilterUtils = require("../filter/gridFilterUtils");
|
|
24
26
|
var _gridDataSourceSelector = require("./gridDataSourceSelector");
|
|
27
|
+
var _useGridDataSourceFilterModelChange = require("./useGridDataSourceFilterModelChange");
|
|
25
28
|
var _utils2 = require("./utils");
|
|
26
29
|
var _cache = require("./cache");
|
|
27
30
|
var _gridDataSourceError = require("./gridDataSourceError");
|
|
@@ -77,6 +80,9 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
77
80
|
} = _ref,
|
|
78
81
|
getRowsParams = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
79
82
|
const fetchParams = (0, _extends2.default)({}, (0, _gridDataSourceSelector.gridGetRowsParamsSelector)(apiRef), apiRef.current.unstable_applyPipeProcessors('getRowsParams', {}), getRowsParams);
|
|
83
|
+
// The selector prunes the incomplete items, but a caller passing its own `filterModel`
|
|
84
|
+
// overrides it, so prune again on the merged params.
|
|
85
|
+
fetchParams.filterModel = (0, _gridFilterUtils.removeIncompleteFilterItems)(fetchParams.filterModel, (0, _columns.gridColumnLookupSelector)(apiRef));
|
|
80
86
|
if (parentId && parentId !== _gridRowsUtils.GRID_ROOT_GROUP_ID && props.signature !== 'DataGrid') {
|
|
81
87
|
options.fetchRowChildren?.([parentId], [fetchParams], showChildrenLoading);
|
|
82
88
|
return;
|
|
@@ -248,16 +254,20 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
248
254
|
}
|
|
249
255
|
try {
|
|
250
256
|
const finalRowUpdate = await dataSourceUpdateRow(params);
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
if (
|
|
257
|
+
// `dataSource.updateRow()` can resolve with a `{ _action: 'replace', row }` update.
|
|
258
|
+
// The row update methods unwrap it themselves, everything else works with the row it
|
|
259
|
+
// holds: comparing the envelope with the previous row would never match.
|
|
260
|
+
const updatedRow = finalRowUpdate && (0, _gridRowsUtils.isReplaceUpdate)(finalRowUpdate) ? (0, _gridRowsUtils.getReplaceRow)(finalRowUpdate) : finalRowUpdate;
|
|
261
|
+
if (updatedRow && !(0, _isDeepEqual.isDeepEqual)(updatedRow, params.previousRow)) {
|
|
256
262
|
// Reset the outdated cache, only if the row is _actually_ updated
|
|
257
263
|
apiRef.current.dataSource.cache.clear();
|
|
258
264
|
}
|
|
259
|
-
|
|
260
|
-
|
|
265
|
+
if (typeof handleEditRowOption === 'function') {
|
|
266
|
+
handleEditRowOption(params, finalRowUpdate);
|
|
267
|
+
} else {
|
|
268
|
+
apiRef.current.updateNestedRows([finalRowUpdate], []);
|
|
269
|
+
}
|
|
270
|
+
return updatedRow;
|
|
261
271
|
} catch (errorThrown) {
|
|
262
272
|
if (typeof onDataSourceErrorProp === 'function') {
|
|
263
273
|
onDataSourceErrorProp(new _gridDataSourceError.GridUpdateRowError({
|
|
@@ -300,6 +310,13 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
300
310
|
stopPolling();
|
|
301
311
|
debouncedFetchRows();
|
|
302
312
|
}, [apiRef, props.dataSourceKeepPreviousData, stopPolling, debouncedFetchRows]);
|
|
313
|
+
const hasFilterModelChanged = (0, _useGridDataSourceFilterModelChange.useGridDataSourceFilterModelChange)(apiRef);
|
|
314
|
+
const handleFetchRowsOnFilterModelChange = React.useCallback(newFilterModel => {
|
|
315
|
+
if (!hasFilterModelChanged(newFilterModel)) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
handleFetchRowsOnParamsChange();
|
|
319
|
+
}, [hasFilterModelChanged, handleFetchRowsOnParamsChange]);
|
|
303
320
|
const isFirstRender = React.useRef(true);
|
|
304
321
|
React.useEffect(() => {
|
|
305
322
|
if (isFirstRender.current) {
|
|
@@ -392,7 +409,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
392
409
|
events: {
|
|
393
410
|
strategyAvailabilityChange: handleStrategyActivityChange,
|
|
394
411
|
sortModelChange: (0, _utils.runIf)(standardRowsUpdateStrategyActive, handleFetchRowsOnParamsChange),
|
|
395
|
-
filterModelChange: (0, _utils.runIf)(standardRowsUpdateStrategyActive,
|
|
412
|
+
filterModelChange: (0, _utils.runIf)(standardRowsUpdateStrategyActive, handleFetchRowsOnFilterModelChange),
|
|
396
413
|
paginationModelChange: (0, _utils.runIf)(standardRowsUpdateStrategyActive, handleFetchRowsOnParamsChange)
|
|
397
414
|
}
|
|
398
415
|
};
|
|
@@ -9,13 +9,16 @@ import useEventCallback from '@mui/utils/useEventCallback';
|
|
|
9
9
|
import debounce from '@mui/utils/debounce';
|
|
10
10
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
11
11
|
import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
|
|
12
|
-
import { GRID_ROOT_GROUP_ID } from "../rows/gridRowsUtils.mjs";
|
|
12
|
+
import { GRID_ROOT_GROUP_ID, getReplaceRow, isReplaceUpdate } from "../rows/gridRowsUtils.mjs";
|
|
13
13
|
import { runIf } from "../../../utils/utils.mjs";
|
|
14
14
|
import { GridStrategyGroup } from "../../core/strategyProcessing/index.mjs";
|
|
15
15
|
import { useGridSelector } from "../../utils/useGridSelector.mjs";
|
|
16
16
|
import { gridPaginationModelSelector, gridVisibleRowsSelector } from "../pagination/gridPaginationSelector.mjs";
|
|
17
17
|
import { gridRowTreeSelector } from "../rows/gridRowsSelector.mjs";
|
|
18
|
+
import { gridColumnLookupSelector } from "../columns/index.mjs";
|
|
19
|
+
import { removeIncompleteFilterItems } from "../filter/gridFilterUtils.mjs";
|
|
18
20
|
import { gridGetRowsParamsSelector } from "./gridDataSourceSelector.mjs";
|
|
21
|
+
import { useGridDataSourceFilterModelChange } from "./useGridDataSourceFilterModelChange.mjs";
|
|
19
22
|
import { CacheChunkManager, DataSourceRowsUpdateStrategy } from "./utils.mjs";
|
|
20
23
|
import { GridDataSourceCacheDefault } from "./cache.mjs";
|
|
21
24
|
import { GridGetRowsError, GridUpdateRowError } from "./gridDataSourceError.mjs";
|
|
@@ -70,6 +73,9 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
70
73
|
} = _ref,
|
|
71
74
|
getRowsParams = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
72
75
|
const fetchParams = _extends({}, gridGetRowsParamsSelector(apiRef), apiRef.current.unstable_applyPipeProcessors('getRowsParams', {}), getRowsParams);
|
|
76
|
+
// The selector prunes the incomplete items, but a caller passing its own `filterModel`
|
|
77
|
+
// overrides it, so prune again on the merged params.
|
|
78
|
+
fetchParams.filterModel = removeIncompleteFilterItems(fetchParams.filterModel, gridColumnLookupSelector(apiRef));
|
|
73
79
|
if (parentId && parentId !== GRID_ROOT_GROUP_ID && props.signature !== 'DataGrid') {
|
|
74
80
|
options.fetchRowChildren?.([parentId], [fetchParams], showChildrenLoading);
|
|
75
81
|
return;
|
|
@@ -241,16 +247,20 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
241
247
|
}
|
|
242
248
|
try {
|
|
243
249
|
const finalRowUpdate = await dataSourceUpdateRow(params);
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
if (
|
|
250
|
+
// `dataSource.updateRow()` can resolve with a `{ _action: 'replace', row }` update.
|
|
251
|
+
// The row update methods unwrap it themselves, everything else works with the row it
|
|
252
|
+
// holds: comparing the envelope with the previous row would never match.
|
|
253
|
+
const updatedRow = finalRowUpdate && isReplaceUpdate(finalRowUpdate) ? getReplaceRow(finalRowUpdate) : finalRowUpdate;
|
|
254
|
+
if (updatedRow && !isDeepEqual(updatedRow, params.previousRow)) {
|
|
249
255
|
// Reset the outdated cache, only if the row is _actually_ updated
|
|
250
256
|
apiRef.current.dataSource.cache.clear();
|
|
251
257
|
}
|
|
252
|
-
|
|
253
|
-
|
|
258
|
+
if (typeof handleEditRowOption === 'function') {
|
|
259
|
+
handleEditRowOption(params, finalRowUpdate);
|
|
260
|
+
} else {
|
|
261
|
+
apiRef.current.updateNestedRows([finalRowUpdate], []);
|
|
262
|
+
}
|
|
263
|
+
return updatedRow;
|
|
254
264
|
} catch (errorThrown) {
|
|
255
265
|
if (typeof onDataSourceErrorProp === 'function') {
|
|
256
266
|
onDataSourceErrorProp(new GridUpdateRowError({
|
|
@@ -293,6 +303,13 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
293
303
|
stopPolling();
|
|
294
304
|
debouncedFetchRows();
|
|
295
305
|
}, [apiRef, props.dataSourceKeepPreviousData, stopPolling, debouncedFetchRows]);
|
|
306
|
+
const hasFilterModelChanged = useGridDataSourceFilterModelChange(apiRef);
|
|
307
|
+
const handleFetchRowsOnFilterModelChange = React.useCallback(newFilterModel => {
|
|
308
|
+
if (!hasFilterModelChanged(newFilterModel)) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
handleFetchRowsOnParamsChange();
|
|
312
|
+
}, [hasFilterModelChanged, handleFetchRowsOnParamsChange]);
|
|
296
313
|
const isFirstRender = React.useRef(true);
|
|
297
314
|
React.useEffect(() => {
|
|
298
315
|
if (isFirstRender.current) {
|
|
@@ -385,7 +402,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
385
402
|
events: {
|
|
386
403
|
strategyAvailabilityChange: handleStrategyActivityChange,
|
|
387
404
|
sortModelChange: runIf(standardRowsUpdateStrategyActive, handleFetchRowsOnParamsChange),
|
|
388
|
-
filterModelChange: runIf(standardRowsUpdateStrategyActive,
|
|
405
|
+
filterModelChange: runIf(standardRowsUpdateStrategyActive, handleFetchRowsOnFilterModelChange),
|
|
389
406
|
paginationModelChange: runIf(standardRowsUpdateStrategyActive, handleFetchRowsOnParamsChange)
|
|
390
407
|
}
|
|
391
408
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RefObject } from '@mui/x-internals/types';
|
|
2
|
+
import type { GridFilterModel } from "../../../models/gridFilterModel.mjs";
|
|
3
|
+
import type { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Tracks the filter model as the data source sees it, the parts that cannot apply excluded.
|
|
6
|
+
* Returns a predicate telling whether a new model would ask for something else: editing an
|
|
7
|
+
* incomplete item, or flipping a logic operator that has nothing to combine, is a no-op.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useGridDataSourceFilterModelChange: (apiRef: RefObject<GridPrivateApiCommunity>) => (filterModel: GridFilterModel) => boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RefObject } from '@mui/x-internals/types';
|
|
2
|
+
import type { GridFilterModel } from "../../../models/gridFilterModel.js";
|
|
3
|
+
import type { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
|
|
4
|
+
/**
|
|
5
|
+
* Tracks the filter model as the data source sees it, the parts that cannot apply excluded.
|
|
6
|
+
* Returns a predicate telling whether a new model would ask for something else: editing an
|
|
7
|
+
* incomplete item, or flipping a logic operator that has nothing to combine, is a no-op.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useGridDataSourceFilterModelChange: (apiRef: RefObject<GridPrivateApiCommunity>) => (filterModel: GridFilterModel) => boolean;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.useGridDataSourceFilterModelChange = void 0;
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _useLazyRef = _interopRequireDefault(require("@mui/utils/useLazyRef"));
|
|
12
|
+
var _isDeepEqual = require("@mui/x-internals/isDeepEqual");
|
|
13
|
+
var _columns = require("../columns");
|
|
14
|
+
var _gridFilterSelector = require("../filter/gridFilterSelector");
|
|
15
|
+
var _gridFilterState = require("../filter/gridFilterState");
|
|
16
|
+
var _gridFilterUtils = require("../filter/gridFilterUtils");
|
|
17
|
+
/**
|
|
18
|
+
* The parts of a filter model that can change the rows the data source returns, so that a
|
|
19
|
+
* change to the rest is not mistaken for a new query. A logic operator needs two operands to
|
|
20
|
+
* mean anything, and quick filter values only apply once one of them is truthy
|
|
21
|
+
* (`buildAggregatedQuickFilterApplier` returns `null` otherwise).
|
|
22
|
+
* Falsy values are kept when another one applies: `passFilterLogic` runs the whole array
|
|
23
|
+
* through its logic operator, so `['a', '']` and `['a']` do not match the same rows.
|
|
24
|
+
*/
|
|
25
|
+
const getApplicableFilterModel = (model, columnsLookup) => {
|
|
26
|
+
const defaultModel = (0, _gridFilterState.getDefaultGridFilterModel)();
|
|
27
|
+
const {
|
|
28
|
+
items
|
|
29
|
+
} = (0, _gridFilterUtils.removeIncompleteFilterItems)(model, columnsLookup);
|
|
30
|
+
const appliesQuickFilter = model.quickFilterValues?.some(Boolean) ?? false;
|
|
31
|
+
const quickFilterValues = appliesQuickFilter ? model.quickFilterValues ?? [] : [];
|
|
32
|
+
return {
|
|
33
|
+
items,
|
|
34
|
+
logicOperator: items.length > 1 ? model.logicOperator ?? defaultModel.logicOperator : null,
|
|
35
|
+
quickFilterValues,
|
|
36
|
+
quickFilterLogicOperator: quickFilterValues.length > 1 ? model.quickFilterLogicOperator ?? defaultModel.quickFilterLogicOperator : null,
|
|
37
|
+
quickFilterExcludeHiddenColumns: appliesQuickFilter ? model.quickFilterExcludeHiddenColumns ?? defaultModel.quickFilterExcludeHiddenColumns : null
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Tracks the filter model as the data source sees it, the parts that cannot apply excluded.
|
|
43
|
+
* Returns a predicate telling whether a new model would ask for something else: editing an
|
|
44
|
+
* incomplete item, or flipping a logic operator that has nothing to combine, is a no-op.
|
|
45
|
+
*/
|
|
46
|
+
const useGridDataSourceFilterModelChange = apiRef => {
|
|
47
|
+
const lastFetchedFilterModel = (0, _useLazyRef.default)(() => getApplicableFilterModel((0, _gridFilterSelector.gridFilterModelSelector)(apiRef), (0, _columns.gridColumnLookupSelector)(apiRef)));
|
|
48
|
+
return React.useCallback(filterModel => {
|
|
49
|
+
const applicableFilterModel = getApplicableFilterModel(filterModel, (0, _columns.gridColumnLookupSelector)(apiRef));
|
|
50
|
+
if ((0, _isDeepEqual.isDeepEqual)(applicableFilterModel, lastFetchedFilterModel.current)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
lastFetchedFilterModel.current = applicableFilterModel;
|
|
54
|
+
return true;
|
|
55
|
+
}, [apiRef, lastFetchedFilterModel]);
|
|
56
|
+
};
|
|
57
|
+
exports.useGridDataSourceFilterModelChange = useGridDataSourceFilterModelChange;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import useLazyRef from '@mui/utils/useLazyRef';
|
|
5
|
+
import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
|
|
6
|
+
import { gridColumnLookupSelector } from "../columns/index.mjs";
|
|
7
|
+
import { gridFilterModelSelector } from "../filter/gridFilterSelector.mjs";
|
|
8
|
+
import { getDefaultGridFilterModel } from "../filter/gridFilterState.mjs";
|
|
9
|
+
import { removeIncompleteFilterItems } from "../filter/gridFilterUtils.mjs";
|
|
10
|
+
/**
|
|
11
|
+
* The parts of a filter model that can change the rows the data source returns, so that a
|
|
12
|
+
* change to the rest is not mistaken for a new query. A logic operator needs two operands to
|
|
13
|
+
* mean anything, and quick filter values only apply once one of them is truthy
|
|
14
|
+
* (`buildAggregatedQuickFilterApplier` returns `null` otherwise).
|
|
15
|
+
* Falsy values are kept when another one applies: `passFilterLogic` runs the whole array
|
|
16
|
+
* through its logic operator, so `['a', '']` and `['a']` do not match the same rows.
|
|
17
|
+
*/
|
|
18
|
+
const getApplicableFilterModel = (model, columnsLookup) => {
|
|
19
|
+
const defaultModel = getDefaultGridFilterModel();
|
|
20
|
+
const {
|
|
21
|
+
items
|
|
22
|
+
} = removeIncompleteFilterItems(model, columnsLookup);
|
|
23
|
+
const appliesQuickFilter = model.quickFilterValues?.some(Boolean) ?? false;
|
|
24
|
+
const quickFilterValues = appliesQuickFilter ? model.quickFilterValues ?? [] : [];
|
|
25
|
+
return {
|
|
26
|
+
items,
|
|
27
|
+
logicOperator: items.length > 1 ? model.logicOperator ?? defaultModel.logicOperator : null,
|
|
28
|
+
quickFilterValues,
|
|
29
|
+
quickFilterLogicOperator: quickFilterValues.length > 1 ? model.quickFilterLogicOperator ?? defaultModel.quickFilterLogicOperator : null,
|
|
30
|
+
quickFilterExcludeHiddenColumns: appliesQuickFilter ? model.quickFilterExcludeHiddenColumns ?? defaultModel.quickFilterExcludeHiddenColumns : null
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Tracks the filter model as the data source sees it, the parts that cannot apply excluded.
|
|
36
|
+
* Returns a predicate telling whether a new model would ask for something else: editing an
|
|
37
|
+
* incomplete item, or flipping a logic operator that has nothing to combine, is a no-op.
|
|
38
|
+
*/
|
|
39
|
+
export const useGridDataSourceFilterModelChange = apiRef => {
|
|
40
|
+
const lastFetchedFilterModel = useLazyRef(() => getApplicableFilterModel(gridFilterModelSelector(apiRef), gridColumnLookupSelector(apiRef)));
|
|
41
|
+
return React.useCallback(filterModel => {
|
|
42
|
+
const applicableFilterModel = getApplicableFilterModel(filterModel, gridColumnLookupSelector(apiRef));
|
|
43
|
+
if (isDeepEqual(applicableFilterModel, lastFetchedFilterModel.current)) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
lastFetchedFilterModel.current = applicableFilterModel;
|
|
47
|
+
return true;
|
|
48
|
+
}, [apiRef, lastFetchedFilterModel]);
|
|
49
|
+
};
|
|
@@ -18,6 +18,7 @@ var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedE
|
|
|
18
18
|
var _isDeepEqual = require("@mui/x-internals/isDeepEqual");
|
|
19
19
|
var _useGridEvent = require("../../utils/useGridEvent");
|
|
20
20
|
var _gridEditRowModel = require("../../../models/gridEditRowModel");
|
|
21
|
+
var _getPublicApiRef = require("../../../utils/getPublicApiRef");
|
|
21
22
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
22
23
|
var _gridEditingSelectors = require("./gridEditingSelectors");
|
|
23
24
|
var _keyboardUtils = require("../../../utils/keyboardUtils");
|
|
@@ -195,7 +196,8 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
195
196
|
const isNewModelDifferentFromProp = newModel !== props.cellModesModel;
|
|
196
197
|
if (onCellModesModelChange && isNewModelDifferentFromProp) {
|
|
197
198
|
onCellModesModelChange(newModel, {
|
|
198
|
-
api: apiRef.current
|
|
199
|
+
api: apiRef.current,
|
|
200
|
+
apiRef: (0, _getPublicApiRef.getPublicApiRef)(apiRef)
|
|
199
201
|
});
|
|
200
202
|
}
|
|
201
203
|
if (props.cellModesModel && isNewModelDifferentFromProp) {
|
|
@@ -13,6 +13,7 @@ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
|
13
13
|
import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
|
|
14
14
|
import { useGridEvent, useGridEventPriority } from "../../utils/useGridEvent.mjs";
|
|
15
15
|
import { GridEditModes, GridCellModes } from "../../../models/gridEditRowModel.mjs";
|
|
16
|
+
import { getPublicApiRef } from "../../../utils/getPublicApiRef.mjs";
|
|
16
17
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.mjs";
|
|
17
18
|
import { gridEditRowsStateSelector } from "./gridEditingSelectors.mjs";
|
|
18
19
|
import { isPrintableKey, isPasteShortcut } from "../../../utils/keyboardUtils.mjs";
|
|
@@ -188,7 +189,8 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
188
189
|
const isNewModelDifferentFromProp = newModel !== props.cellModesModel;
|
|
189
190
|
if (onCellModesModelChange && isNewModelDifferentFromProp) {
|
|
190
191
|
onCellModesModelChange(newModel, {
|
|
191
|
-
api: apiRef.current
|
|
192
|
+
api: apiRef.current,
|
|
193
|
+
apiRef: getPublicApiRef(apiRef)
|
|
192
194
|
});
|
|
193
195
|
}
|
|
194
196
|
if (props.cellModesModel && isNewModelDifferentFromProp) {
|
|
@@ -18,6 +18,7 @@ var _warning = require("@mui/x-internals/warning");
|
|
|
18
18
|
var _isDeepEqual = require("@mui/x-internals/isDeepEqual");
|
|
19
19
|
var _useGridEvent = require("../../utils/useGridEvent");
|
|
20
20
|
var _gridEditRowModel = require("../../../models/gridEditRowModel");
|
|
21
|
+
var _getPublicApiRef = require("../../../utils/getPublicApiRef");
|
|
21
22
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
22
23
|
var _gridEditingSelectors = require("./gridEditingSelectors");
|
|
23
24
|
var _keyboardUtils = require("../../../utils/keyboardUtils");
|
|
@@ -265,7 +266,8 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
265
266
|
const isNewModelDifferentFromProp = newModel !== props.rowModesModel;
|
|
266
267
|
if (onRowModesModelChange && isNewModelDifferentFromProp) {
|
|
267
268
|
onRowModesModelChange(newModel, {
|
|
268
|
-
api: apiRef.current
|
|
269
|
+
api: apiRef.current,
|
|
270
|
+
apiRef: (0, _getPublicApiRef.getPublicApiRef)(apiRef)
|
|
269
271
|
});
|
|
270
272
|
}
|
|
271
273
|
if (props.rowModesModel && isNewModelDifferentFromProp) {
|
|
@@ -13,6 +13,7 @@ import { warnOnce } from '@mui/x-internals/warning';
|
|
|
13
13
|
import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
|
|
14
14
|
import { useGridEvent, useGridEventPriority } from "../../utils/useGridEvent.mjs";
|
|
15
15
|
import { GridEditModes, GridRowModes } from "../../../models/gridEditRowModel.mjs";
|
|
16
|
+
import { getPublicApiRef } from "../../../utils/getPublicApiRef.mjs";
|
|
16
17
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.mjs";
|
|
17
18
|
import { gridEditRowsStateSelector, gridRowIsEditingSelector } from "./gridEditingSelectors.mjs";
|
|
18
19
|
import { isPrintableKey, isPasteShortcut } from "../../../utils/keyboardUtils.mjs";
|
|
@@ -258,7 +259,8 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
258
259
|
const isNewModelDifferentFromProp = newModel !== props.rowModesModel;
|
|
259
260
|
if (onRowModesModelChange && isNewModelDifferentFromProp) {
|
|
260
261
|
onRowModesModelChange(newModel, {
|
|
261
|
-
api: apiRef.current
|
|
262
|
+
api: apiRef.current,
|
|
263
|
+
apiRef: getPublicApiRef(apiRef)
|
|
262
264
|
});
|
|
263
265
|
}
|
|
264
266
|
if (props.rowModesModel && isNewModelDifferentFromProp) {
|
|
@@ -4,6 +4,7 @@ import type { GridColDef, GridFilterItem, GridFilterModel, GridRowModel } from "
|
|
|
4
4
|
import type { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.mjs";
|
|
5
5
|
import type { GridStateCommunity } from "../../../models/gridStateCommunity.mjs";
|
|
6
6
|
import type { GridAggregatedFilterItemApplier, GridFilterItemResult, GridQuickFilterValueResult } from "./gridFilterState.mjs";
|
|
7
|
+
import type { GridColumnLookup } from "../columns/index.mjs";
|
|
7
8
|
/**
|
|
8
9
|
* Pure helpers computing a new filter model from an existing one.
|
|
9
10
|
* Shared by the imperative `apiRef` methods (`useGridFilter`) and the controlled
|
|
@@ -15,6 +16,18 @@ export declare const upsertFilterItemInModel: (model: GridFilterModel, item: Gri
|
|
|
15
16
|
export declare const upsertFilterItemsInModel: (model: GridFilterModel, itemsToUpsert: GridFilterItem[]) => GridFilterModel;
|
|
16
17
|
export declare const deleteFilterItemFromModel: (model: GridFilterModel, itemToDelete: GridFilterItem) => GridFilterModel;
|
|
17
18
|
export declare const setFilterLogicOperatorInModel: (model: GridFilterModel, logicOperator: GridLogicOperator) => GridFilterModel;
|
|
19
|
+
/**
|
|
20
|
+
* Whether a filter item carries everything its operator needs to be applied.
|
|
21
|
+
* Operators declaring `requiresFilterValue: false` (`isEmpty`, `isNotEmpty`) stay complete
|
|
22
|
+
* without a value, see https://github.com/mui/mui-x/issues/5402
|
|
23
|
+
*/
|
|
24
|
+
export declare const isFilterItemComplete: (item: GridFilterItem, column: GridColDef | undefined) => boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Drops the filter items that cannot be applied, so incomplete items never reach a consumer
|
|
27
|
+
* that would treat them as a real constraint (`dataSource` sending them to a server, for one).
|
|
28
|
+
* Returns the same model reference when every item is complete.
|
|
29
|
+
*/
|
|
30
|
+
export declare const removeIncompleteFilterItems: (model: GridFilterModel, columnsLookup: GridColumnLookup) => GridFilterModel;
|
|
18
31
|
/**
|
|
19
32
|
* Adds default values to the optional fields of a filter items.
|
|
20
33
|
* @param {GridFilterItem} item The raw filter item.
|
|
@@ -4,6 +4,7 @@ import type { GridColDef, GridFilterItem, GridFilterModel, GridRowModel } from "
|
|
|
4
4
|
import type { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
|
|
5
5
|
import type { GridStateCommunity } from "../../../models/gridStateCommunity.js";
|
|
6
6
|
import type { GridAggregatedFilterItemApplier, GridFilterItemResult, GridQuickFilterValueResult } from "./gridFilterState.js";
|
|
7
|
+
import type { GridColumnLookup } from "../columns/index.js";
|
|
7
8
|
/**
|
|
8
9
|
* Pure helpers computing a new filter model from an existing one.
|
|
9
10
|
* Shared by the imperative `apiRef` methods (`useGridFilter`) and the controlled
|
|
@@ -15,6 +16,18 @@ export declare const upsertFilterItemInModel: (model: GridFilterModel, item: Gri
|
|
|
15
16
|
export declare const upsertFilterItemsInModel: (model: GridFilterModel, itemsToUpsert: GridFilterItem[]) => GridFilterModel;
|
|
16
17
|
export declare const deleteFilterItemFromModel: (model: GridFilterModel, itemToDelete: GridFilterItem) => GridFilterModel;
|
|
17
18
|
export declare const setFilterLogicOperatorInModel: (model: GridFilterModel, logicOperator: GridLogicOperator) => GridFilterModel;
|
|
19
|
+
/**
|
|
20
|
+
* Whether a filter item carries everything its operator needs to be applied.
|
|
21
|
+
* Operators declaring `requiresFilterValue: false` (`isEmpty`, `isNotEmpty`) stay complete
|
|
22
|
+
* without a value, see https://github.com/mui/mui-x/issues/5402
|
|
23
|
+
*/
|
|
24
|
+
export declare const isFilterItemComplete: (item: GridFilterItem, column: GridColDef | undefined) => boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Drops the filter items that cannot be applied, so incomplete items never reach a consumer
|
|
27
|
+
* that would treat them as a real constraint (`dataSource` sending them to a server, for one).
|
|
28
|
+
* Returns the same model reference when every item is complete.
|
|
29
|
+
*/
|
|
30
|
+
export declare const removeIncompleteFilterItems: (model: GridFilterModel, columnsLookup: GridColumnLookup) => GridFilterModel;
|
|
18
31
|
/**
|
|
19
32
|
* Adds default values to the optional fields of a filter items.
|
|
20
33
|
* @param {GridFilterItem} item The raw filter item.
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.upsertFilterItemsInModel = exports.upsertFilterItemInModel = exports.shouldQuickFilterExcludeHiddenColumns = exports.setFilterLogicOperatorInModel = exports.sanitizeFilterModel = exports.removeDiacritics = exports.passFilterLogic = exports.mergeStateWithFilterModel = exports.deleteFilterItemFromModel = exports.cleanFilterItem = exports.buildAggregatedFilterApplier = void 0;
|
|
7
|
+
exports.upsertFilterItemsInModel = exports.upsertFilterItemInModel = exports.shouldQuickFilterExcludeHiddenColumns = exports.setFilterLogicOperatorInModel = exports.sanitizeFilterModel = exports.removeIncompleteFilterItems = exports.removeDiacritics = exports.passFilterLogic = exports.mergeStateWithFilterModel = exports.isFilterItemComplete = exports.deleteFilterItemFromModel = exports.cleanFilterItem = exports.buildAggregatedFilterApplier = void 0;
|
|
8
8
|
var _formatErrorMessage2 = _interopRequireDefault(require("@mui/x-internals/formatErrorMessage"));
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _warning = require("@mui/x-internals/warning");
|
|
@@ -66,7 +66,38 @@ const setFilterLogicOperatorInModel = (model, logicOperator) => {
|
|
|
66
66
|
logicOperator
|
|
67
67
|
});
|
|
68
68
|
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Whether a filter item carries everything its operator needs to be applied.
|
|
72
|
+
* Operators declaring `requiresFilterValue: false` (`isEmpty`, `isNotEmpty`) stay complete
|
|
73
|
+
* without a value, see https://github.com/mui/mui-x/issues/5402
|
|
74
|
+
*/
|
|
69
75
|
exports.setFilterLogicOperatorInModel = setFilterLogicOperatorInModel;
|
|
76
|
+
const isFilterItemComplete = (item, column) => {
|
|
77
|
+
if (item.value !== undefined) {
|
|
78
|
+
// Some operators like `isAnyOf` take an array as `item.value`. An empty one filters nothing.
|
|
79
|
+
return !(Array.isArray(item.value) && item.value.length === 0);
|
|
80
|
+
}
|
|
81
|
+
const filterOperator = column?.filterOperators?.find(operator => operator.value === item.operator);
|
|
82
|
+
return filterOperator?.requiresFilterValue === false;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Drops the filter items that cannot be applied, so incomplete items never reach a consumer
|
|
87
|
+
* that would treat them as a real constraint (`dataSource` sending them to a server, for one).
|
|
88
|
+
* Returns the same model reference when every item is complete.
|
|
89
|
+
*/
|
|
90
|
+
exports.isFilterItemComplete = isFilterItemComplete;
|
|
91
|
+
const removeIncompleteFilterItems = (model, columnsLookup) => {
|
|
92
|
+
const items = model.items.filter(item => isFilterItemComplete(item, columnsLookup[item.field]));
|
|
93
|
+
if (items.length === model.items.length) {
|
|
94
|
+
return model;
|
|
95
|
+
}
|
|
96
|
+
return (0, _extends2.default)({}, model, {
|
|
97
|
+
items
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
exports.removeIncompleteFilterItems = removeIncompleteFilterItems;
|
|
70
101
|
let hasEval;
|
|
71
102
|
function getHasEval() {
|
|
72
103
|
if (hasEval !== undefined) {
|
|
@@ -5,7 +5,6 @@ import { GridLogicOperator } from "../../../models/index.mjs";
|
|
|
5
5
|
import { getDefaultGridFilterModel } from "./gridFilterState.mjs";
|
|
6
6
|
import { getPublicApiRef } from "../../../utils/getPublicApiRef.mjs";
|
|
7
7
|
import { gridColumnFieldsSelector, gridColumnLookupSelector, gridColumnVisibilityModelSelector } from "../columns/index.mjs";
|
|
8
|
-
|
|
9
8
|
/**
|
|
10
9
|
* Pure helpers computing a new filter model from an existing one.
|
|
11
10
|
* Shared by the imperative `apiRef` methods (`useGridFilter`) and the controlled
|
|
@@ -57,6 +56,35 @@ export const setFilterLogicOperatorInModel = (model, logicOperator) => {
|
|
|
57
56
|
logicOperator
|
|
58
57
|
});
|
|
59
58
|
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Whether a filter item carries everything its operator needs to be applied.
|
|
62
|
+
* Operators declaring `requiresFilterValue: false` (`isEmpty`, `isNotEmpty`) stay complete
|
|
63
|
+
* without a value, see https://github.com/mui/mui-x/issues/5402
|
|
64
|
+
*/
|
|
65
|
+
export const isFilterItemComplete = (item, column) => {
|
|
66
|
+
if (item.value !== undefined) {
|
|
67
|
+
// Some operators like `isAnyOf` take an array as `item.value`. An empty one filters nothing.
|
|
68
|
+
return !(Array.isArray(item.value) && item.value.length === 0);
|
|
69
|
+
}
|
|
70
|
+
const filterOperator = column?.filterOperators?.find(operator => operator.value === item.operator);
|
|
71
|
+
return filterOperator?.requiresFilterValue === false;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Drops the filter items that cannot be applied, so incomplete items never reach a consumer
|
|
76
|
+
* that would treat them as a real constraint (`dataSource` sending them to a server, for one).
|
|
77
|
+
* Returns the same model reference when every item is complete.
|
|
78
|
+
*/
|
|
79
|
+
export const removeIncompleteFilterItems = (model, columnsLookup) => {
|
|
80
|
+
const items = model.items.filter(item => isFilterItemComplete(item, columnsLookup[item.field]));
|
|
81
|
+
if (items.length === model.items.length) {
|
|
82
|
+
return model;
|
|
83
|
+
}
|
|
84
|
+
return _extends({}, model, {
|
|
85
|
+
items
|
|
86
|
+
});
|
|
87
|
+
};
|
|
60
88
|
let hasEval;
|
|
61
89
|
function getHasEval() {
|
|
62
90
|
if (hasEval !== undefined) {
|
|
@@ -103,27 +103,7 @@ const useGridFilter = (apiRef, props, configuration) => {
|
|
|
103
103
|
logger.debug('Displaying filter panel');
|
|
104
104
|
if (targetColumnField) {
|
|
105
105
|
const filterModel = (0, _gridFilterSelector.gridFilterModelSelector)(apiRef);
|
|
106
|
-
const filterItemsWithValue = filterModel.items.filter(item =>
|
|
107
|
-
if (item.value !== undefined) {
|
|
108
|
-
// Some filters like `isAnyOf` support array as `item.value`.
|
|
109
|
-
// If array is empty, we want to remove it from the filter model.
|
|
110
|
-
if (Array.isArray(item.value) && item.value.length === 0) {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
const column = apiRef.current.getColumn(item.field);
|
|
116
|
-
const filterOperator = column?.filterOperators?.find(operator => operator.value === item.operator);
|
|
117
|
-
const requiresFilterValue = typeof filterOperator?.requiresFilterValue === 'undefined' ? true : filterOperator?.requiresFilterValue;
|
|
118
|
-
|
|
119
|
-
// Operators like `isEmpty` don't have and don't require `item.value`.
|
|
120
|
-
// So we don't want to remove them from the filter model if `item.value === undefined`.
|
|
121
|
-
// See https://github.com/mui/mui-x/issues/5402
|
|
122
|
-
if (requiresFilterValue) {
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
return true;
|
|
126
|
-
});
|
|
106
|
+
const filterItemsWithValue = filterModel.items.filter(item => (0, _gridFilterUtils.isFilterItemComplete)(item, apiRef.current.getColumn(item.field)));
|
|
127
107
|
let newFilterItems;
|
|
128
108
|
const filterItemOnTarget = filterItemsWithValue.find(item => item.field === targetColumnField);
|
|
129
109
|
const targetColumn = apiRef.current.getColumn(targetColumnField);
|