@mui/x-data-grid 9.11.0 → 9.12.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 +165 -0
- package/DataGrid/DataGrid.js +3 -1
- package/DataGrid/DataGrid.mjs +3 -1
- package/DataGrid/useDataGridProps.d.mts +1 -1
- package/DataGrid/useDataGridProps.d.ts +1 -1
- package/components/cell/GridCell.js +14 -1
- package/components/cell/GridCell.mjs +14 -1
- 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/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 +3 -0
- package/hooks/core/useGridVirtualizer.mjs +3 -0
- 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/useGridDataSourceBase.js +14 -1
- package/hooks/features/dataSource/useGridDataSourceBase.mjs +14 -1
- 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/rows/useGridRowSpanning.js +5 -0
- package/hooks/features/rows/useGridRowSpanning.mjs +5 -0
- 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 +2 -0
- package/internals/index.d.ts +2 -0
- package/internals/index.js +20 -0
- package/internals/index.mjs +2 -0
- 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/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 +12 -0
- package/models/api/gridRowApi.d.ts +12 -0
- 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/props/DataGridProps.d.mts +38 -35
- package/models/props/DataGridProps.d.ts +38 -35
- package/package.json +3 -3
- 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
|
@@ -47,6 +47,10 @@ const GRID_DEFAULT_LOCALE_TEXT = exports.GRID_DEFAULT_LOCALE_TEXT = {
|
|
|
47
47
|
toolbarCharts: 'Charts',
|
|
48
48
|
// Toolbar AI Assistant button
|
|
49
49
|
toolbarAssistant: 'AI Assistant',
|
|
50
|
+
// Formula bar (Premium formulas)
|
|
51
|
+
formulaBarLabel: 'Formula bar',
|
|
52
|
+
formulaBarInputLabel: 'Formula',
|
|
53
|
+
formulaBarAddressLabel: 'Active cell',
|
|
50
54
|
// Columns management text
|
|
51
55
|
columnsManagementSearchTitle: 'Search',
|
|
52
56
|
columnsManagementNoColumns: 'No columns',
|
|
@@ -41,6 +41,10 @@ export const GRID_DEFAULT_LOCALE_TEXT = {
|
|
|
41
41
|
toolbarCharts: 'Charts',
|
|
42
42
|
// Toolbar AI Assistant button
|
|
43
43
|
toolbarAssistant: 'AI Assistant',
|
|
44
|
+
// Formula bar (Premium formulas)
|
|
45
|
+
formulaBarLabel: 'Formula bar',
|
|
46
|
+
formulaBarInputLabel: 'Formula',
|
|
47
|
+
formulaBarAddressLabel: 'Active cell',
|
|
44
48
|
// Columns management text
|
|
45
49
|
columnsManagementSearchTitle: 'Search',
|
|
46
50
|
columnsManagementNoColumns: 'No columns',
|
|
@@ -12,6 +12,7 @@ var _EventManager = require("@mui/x-internals/EventManager");
|
|
|
12
12
|
var _store = require("@mui/x-internals/store");
|
|
13
13
|
var _useGridApiMethod = require("../utils/useGridApiMethod");
|
|
14
14
|
var _signature = require("../../constants/signature");
|
|
15
|
+
var _getPublicApiRef = require("../../utils/getPublicApiRef");
|
|
15
16
|
const SYMBOL_API_PRIVATE = Symbol('mui.api_private');
|
|
16
17
|
const isSyntheticEvent = event => {
|
|
17
18
|
return event.isPropagationStopped !== undefined;
|
|
@@ -92,8 +93,11 @@ function useGridApiInitialization(inputApiRef, props) {
|
|
|
92
93
|
return;
|
|
93
94
|
}
|
|
94
95
|
const details = props.signature === _signature.GridSignature.DataGridPro || props.signature === _signature.GridSignature.DataGridPremium ? {
|
|
96
|
+
apiRef: (0, _getPublicApiRef.getPublicApiRef)(privateApiRef),
|
|
95
97
|
api: privateApiRef.current.getPublicApi()
|
|
96
|
-
} : {
|
|
98
|
+
} : {
|
|
99
|
+
apiRef: (0, _getPublicApiRef.getPublicApiRef)(privateApiRef)
|
|
100
|
+
};
|
|
97
101
|
privateApiRef.current.eventManager.emit(name, params, event, details);
|
|
98
102
|
}, [privateApiRef, props.signature]);
|
|
99
103
|
const subscribeEvent = React.useCallback((event, handler, options) => {
|
|
@@ -5,6 +5,7 @@ import { EventManager } from '@mui/x-internals/EventManager';
|
|
|
5
5
|
import { Store } from '@mui/x-internals/store';
|
|
6
6
|
import { useGridApiMethod } from "../utils/useGridApiMethod.mjs";
|
|
7
7
|
import { GridSignature } from "../../constants/signature.mjs";
|
|
8
|
+
import { getPublicApiRef } from "../../utils/getPublicApiRef.mjs";
|
|
8
9
|
const SYMBOL_API_PRIVATE = Symbol('mui.api_private');
|
|
9
10
|
const isSyntheticEvent = event => {
|
|
10
11
|
return event.isPropagationStopped !== undefined;
|
|
@@ -85,8 +86,11 @@ export function useGridApiInitialization(inputApiRef, props) {
|
|
|
85
86
|
return;
|
|
86
87
|
}
|
|
87
88
|
const details = props.signature === GridSignature.DataGridPro || props.signature === GridSignature.DataGridPremium ? {
|
|
89
|
+
apiRef: getPublicApiRef(privateApiRef),
|
|
88
90
|
api: privateApiRef.current.getPublicApi()
|
|
89
|
-
} : {
|
|
91
|
+
} : {
|
|
92
|
+
apiRef: getPublicApiRef(privateApiRef)
|
|
93
|
+
};
|
|
90
94
|
privateApiRef.current.eventManager.emit(name, params, event, details);
|
|
91
95
|
}, [privateApiRef, props.signature]);
|
|
92
96
|
const subscribeEvent = React.useCallback((event, handler, options) => {
|
|
@@ -12,6 +12,7 @@ var _formatErrorMessage2 = _interopRequireDefault(require("@mui/x-internals/form
|
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _utils = require("../utils");
|
|
14
14
|
var _utils2 = require("../../utils/utils");
|
|
15
|
+
var _getPublicApiRef = require("../../utils/getPublicApiRef");
|
|
15
16
|
const useGridStateInitialization = apiRef => {
|
|
16
17
|
const controlStateMapRef = React.useRef({});
|
|
17
18
|
const registerControlState = React.useCallback(controlStateItem => {
|
|
@@ -75,7 +76,8 @@ const useGridStateInitialization = apiRef => {
|
|
|
75
76
|
if (controlState.propOnChange && hasPropChanged) {
|
|
76
77
|
controlState.propOnChange(model, {
|
|
77
78
|
reason,
|
|
78
|
-
api: apiRef.current
|
|
79
|
+
api: apiRef.current,
|
|
80
|
+
apiRef: (0, _getPublicApiRef.getPublicApiRef)(apiRef)
|
|
79
81
|
});
|
|
80
82
|
}
|
|
81
83
|
if (!ignoreSetState) {
|
|
@@ -5,6 +5,7 @@ import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
|
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import { useGridApiMethod } from "../utils/index.mjs";
|
|
7
7
|
import { isFunction } from "../../utils/utils.mjs";
|
|
8
|
+
import { getPublicApiRef } from "../../utils/getPublicApiRef.mjs";
|
|
8
9
|
export const useGridStateInitialization = apiRef => {
|
|
9
10
|
const controlStateMapRef = React.useRef({});
|
|
10
11
|
const registerControlState = React.useCallback(controlStateItem => {
|
|
@@ -68,7 +69,8 @@ export const useGridStateInitialization = apiRef => {
|
|
|
68
69
|
if (controlState.propOnChange && hasPropChanged) {
|
|
69
70
|
controlState.propOnChange(model, {
|
|
70
71
|
reason,
|
|
71
|
-
api: apiRef.current
|
|
72
|
+
api: apiRef.current,
|
|
73
|
+
apiRef: getPublicApiRef(apiRef)
|
|
72
74
|
});
|
|
73
75
|
}
|
|
74
76
|
if (!ignoreSetState) {
|
|
@@ -26,6 +26,7 @@ var _useGridVisibleRows = require("../utils/useGridVisibleRows");
|
|
|
26
26
|
var _pagination = require("../features/pagination");
|
|
27
27
|
var _gridFocusedVirtualCellSelector = require("../features/virtualization/gridFocusedVirtualCellSelector");
|
|
28
28
|
var _rowSelection = require("../features/rowSelection");
|
|
29
|
+
var _gridColumnGroupsSelector = require("../features/columnGrouping/gridColumnGroupsSelector");
|
|
29
30
|
var _dataGridPropsDefaultValues = require("../../constants/dataGridPropsDefaultValues");
|
|
30
31
|
var _gridRowsUtils = require("../features/rows/gridRowsUtils");
|
|
31
32
|
var _gridColumnsUtils = require("../features/columns/gridColumnsUtils");
|
|
@@ -87,6 +88,8 @@ function useGridVirtualizer() {
|
|
|
87
88
|
const groupHeaderHeight = Math.floor((rootProps.columnGroupHeaderHeight ?? rootProps.columnHeaderHeight) * density);
|
|
88
89
|
const headerFilterHeight = Math.floor((rootProps.headerFilterHeight ?? rootProps.columnHeaderHeight) * density);
|
|
89
90
|
const columnsTotalWidth = (0, _useGridSelector.useGridSelector)(apiRef, columnsTotalWidthSelector);
|
|
91
|
+
// `getTotalHeaderHeight` reads the group depth imperatively, subscribe so it re-renders when it changes.
|
|
92
|
+
(0, _utils.eslintUseValue)((0, _useGridSelector.useGridSelector)(apiRef, _gridColumnGroupsSelector.gridColumnGroupsHeaderMaxDepthSelector));
|
|
90
93
|
const headersTotalHeight = (0, _gridColumnsUtils.getTotalHeaderHeight)(apiRef, rootProps);
|
|
91
94
|
const leftPinnedWidth = pinnedColumns.left.reduce((w, col) => w + col.computedWidth, 0);
|
|
92
95
|
const rightPinnedWidth = pinnedColumns.right.reduce((w, col) => w + col.computedWidth, 0);
|
|
@@ -18,6 +18,7 @@ import { useGridVisibleRows } from "../utils/useGridVisibleRows.mjs";
|
|
|
18
18
|
import { gridPaginationSelector } from "../features/pagination/index.mjs";
|
|
19
19
|
import { gridFocusedVirtualCellSelector } from "../features/virtualization/gridFocusedVirtualCellSelector.mjs";
|
|
20
20
|
import { gridRowSelectionManagerSelector } from "../features/rowSelection/index.mjs";
|
|
21
|
+
import { gridColumnGroupsHeaderMaxDepthSelector } from "../features/columnGrouping/gridColumnGroupsSelector.mjs";
|
|
21
22
|
import { DATA_GRID_PROPS_DEFAULT_VALUES } from "../../constants/dataGridPropsDefaultValues.mjs";
|
|
22
23
|
import { getValidRowHeight, minimalContentHeight, rowHeightWarning } from "../features/rows/gridRowsUtils.mjs";
|
|
23
24
|
import { getTotalHeaderHeight } from "../features/columns/gridColumnsUtils.mjs";
|
|
@@ -79,6 +80,8 @@ export function useGridVirtualizer() {
|
|
|
79
80
|
const groupHeaderHeight = Math.floor((rootProps.columnGroupHeaderHeight ?? rootProps.columnHeaderHeight) * density);
|
|
80
81
|
const headerFilterHeight = Math.floor((rootProps.headerFilterHeight ?? rootProps.columnHeaderHeight) * density);
|
|
81
82
|
const columnsTotalWidth = useGridSelector(apiRef, columnsTotalWidthSelector);
|
|
83
|
+
// `getTotalHeaderHeight` reads the group depth imperatively, subscribe so it re-renders when it changes.
|
|
84
|
+
eslintUseValue(useGridSelector(apiRef, gridColumnGroupsHeaderMaxDepthSelector));
|
|
82
85
|
const headersTotalHeight = getTotalHeaderHeight(apiRef, rootProps);
|
|
83
86
|
const leftPinnedWidth = pinnedColumns.left.reduce((w, col) => w + col.computedWidth, 0);
|
|
84
87
|
const rightPinnedWidth = pinnedColumns.right.reduce((w, col) => w + col.computedWidth, 0);
|
|
@@ -568,6 +568,11 @@ const useGridColumnResize = (apiRef, props) => {
|
|
|
568
568
|
if (!props.disableVirtualization && options.disableColumnVirtualization) {
|
|
569
569
|
apiRef.current.unstable_setColumnVirtualization(false);
|
|
570
570
|
await columnVirtualizationDisabled();
|
|
571
|
+
|
|
572
|
+
// The grid may have unmounted while awaiting, which nulls the root element ref.
|
|
573
|
+
if (!apiRef.current.rootElementRef?.current) {
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
571
576
|
}
|
|
572
577
|
const widthByField = extractColumnWidths(apiRef, options, columns);
|
|
573
578
|
const newColumns = columns.map(column => (0, _extends2.default)({}, column, {
|
|
@@ -560,6 +560,11 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
560
560
|
if (!props.disableVirtualization && options.disableColumnVirtualization) {
|
|
561
561
|
apiRef.current.unstable_setColumnVirtualization(false);
|
|
562
562
|
await columnVirtualizationDisabled();
|
|
563
|
+
|
|
564
|
+
// The grid may have unmounted while awaiting, which nulls the root element ref.
|
|
565
|
+
if (!apiRef.current.rootElementRef?.current) {
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
563
568
|
}
|
|
564
569
|
const widthByField = extractColumnWidths(apiRef, options, columns);
|
|
565
570
|
const newColumns = columns.map(column => _extends({}, column, {
|
|
@@ -67,4 +67,4 @@ export declare function getFirstNonSpannedColumnToRender({
|
|
|
67
67
|
lastRowToRender: number;
|
|
68
68
|
visibleRows: GridRowEntry[];
|
|
69
69
|
}): number;
|
|
70
|
-
export declare function getTotalHeaderHeight(apiRef: RefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'columnHeaderHeight' | 'headerFilterHeight' | 'listView' | 'columnGroupHeaderHeight'>): number;
|
|
70
|
+
export declare function getTotalHeaderHeight(apiRef: RefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'columnHeaderHeight' | 'headerFilterHeight' | 'listView' | 'columnGroupHeaderHeight' | 'signature' | 'headerFilters'>): number;
|
|
@@ -67,4 +67,4 @@ export declare function getFirstNonSpannedColumnToRender({
|
|
|
67
67
|
lastRowToRender: number;
|
|
68
68
|
visibleRows: GridRowEntry[];
|
|
69
69
|
}): number;
|
|
70
|
-
export declare function getTotalHeaderHeight(apiRef: RefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'columnHeaderHeight' | 'headerFilterHeight' | 'listView' | 'columnGroupHeaderHeight'>): number;
|
|
70
|
+
export declare function getTotalHeaderHeight(apiRef: RefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'columnHeaderHeight' | 'headerFilterHeight' | 'listView' | 'columnGroupHeaderHeight' | 'signature' | 'headerFilters'>): number;
|
|
@@ -19,7 +19,6 @@ var _signature = require("../../../constants/signature");
|
|
|
19
19
|
var _gridColumnsSelector = require("./gridColumnsSelector");
|
|
20
20
|
var _utils = require("../../../utils/utils");
|
|
21
21
|
var _densitySelector = require("../density/densitySelector");
|
|
22
|
-
var _gridHeaderFilteringSelectors = require("../headerFiltering/gridHeaderFilteringSelectors");
|
|
23
22
|
var _gridColumnGroupsSelector = require("../columnGrouping/gridColumnGroupsSelector");
|
|
24
23
|
const COLUMNS_DIMENSION_PROPERTIES = exports.COLUMNS_DIMENSION_PROPERTIES = ['maxWidth', 'minWidth', 'width', 'flex'];
|
|
25
24
|
/**
|
|
@@ -360,7 +359,8 @@ function getTotalHeaderHeight(apiRef, props) {
|
|
|
360
359
|
}
|
|
361
360
|
const densityFactor = (0, _densitySelector.gridDensityFactorSelector)(apiRef);
|
|
362
361
|
const maxDepth = (0, _gridColumnGroupsSelector.gridColumnGroupsHeaderMaxDepthSelector)(apiRef);
|
|
363
|
-
|
|
362
|
+
// Not `gridHeaderFilteringEnabledSelector`: that state is synced in an effect, so it lags one render behind `props.headerFilters`.
|
|
363
|
+
const isHeaderFilteringEnabled = props.signature !== 'DataGrid' && (props.headerFilters ?? false);
|
|
364
364
|
const columnHeadersHeight = Math.floor(props.columnHeaderHeight * densityFactor);
|
|
365
365
|
const columnGroupHeadersHeight = Math.floor((props.columnGroupHeaderHeight ?? props.columnHeaderHeight) * densityFactor);
|
|
366
366
|
const filterHeadersHeight = isHeaderFilteringEnabled ? Math.floor((props.headerFilterHeight ?? props.columnHeaderHeight) * densityFactor) : 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
|
}));
|
|
@@ -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;
|
|
@@ -300,6 +306,13 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
300
306
|
stopPolling();
|
|
301
307
|
debouncedFetchRows();
|
|
302
308
|
}, [apiRef, props.dataSourceKeepPreviousData, stopPolling, debouncedFetchRows]);
|
|
309
|
+
const hasFilterModelChanged = (0, _useGridDataSourceFilterModelChange.useGridDataSourceFilterModelChange)(apiRef);
|
|
310
|
+
const handleFetchRowsOnFilterModelChange = React.useCallback(newFilterModel => {
|
|
311
|
+
if (!hasFilterModelChanged(newFilterModel)) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
handleFetchRowsOnParamsChange();
|
|
315
|
+
}, [hasFilterModelChanged, handleFetchRowsOnParamsChange]);
|
|
303
316
|
const isFirstRender = React.useRef(true);
|
|
304
317
|
React.useEffect(() => {
|
|
305
318
|
if (isFirstRender.current) {
|
|
@@ -392,7 +405,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
392
405
|
events: {
|
|
393
406
|
strategyAvailabilityChange: handleStrategyActivityChange,
|
|
394
407
|
sortModelChange: (0, _utils.runIf)(standardRowsUpdateStrategyActive, handleFetchRowsOnParamsChange),
|
|
395
|
-
filterModelChange: (0, _utils.runIf)(standardRowsUpdateStrategyActive,
|
|
408
|
+
filterModelChange: (0, _utils.runIf)(standardRowsUpdateStrategyActive, handleFetchRowsOnFilterModelChange),
|
|
396
409
|
paginationModelChange: (0, _utils.runIf)(standardRowsUpdateStrategyActive, handleFetchRowsOnParamsChange)
|
|
397
410
|
}
|
|
398
411
|
};
|
|
@@ -15,7 +15,10 @@ 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;
|
|
@@ -293,6 +299,13 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
293
299
|
stopPolling();
|
|
294
300
|
debouncedFetchRows();
|
|
295
301
|
}, [apiRef, props.dataSourceKeepPreviousData, stopPolling, debouncedFetchRows]);
|
|
302
|
+
const hasFilterModelChanged = useGridDataSourceFilterModelChange(apiRef);
|
|
303
|
+
const handleFetchRowsOnFilterModelChange = React.useCallback(newFilterModel => {
|
|
304
|
+
if (!hasFilterModelChanged(newFilterModel)) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
handleFetchRowsOnParamsChange();
|
|
308
|
+
}, [hasFilterModelChanged, handleFetchRowsOnParamsChange]);
|
|
296
309
|
const isFirstRender = React.useRef(true);
|
|
297
310
|
React.useEffect(() => {
|
|
298
311
|
if (isFirstRender.current) {
|
|
@@ -385,7 +398,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
385
398
|
events: {
|
|
386
399
|
strategyAvailabilityChange: handleStrategyActivityChange,
|
|
387
400
|
sortModelChange: runIf(standardRowsUpdateStrategyActive, handleFetchRowsOnParamsChange),
|
|
388
|
-
filterModelChange: runIf(standardRowsUpdateStrategyActive,
|
|
401
|
+
filterModelChange: runIf(standardRowsUpdateStrategyActive, handleFetchRowsOnFilterModelChange),
|
|
389
402
|
paginationModelChange: runIf(standardRowsUpdateStrategyActive, handleFetchRowsOnParamsChange)
|
|
390
403
|
}
|
|
391
404
|
};
|
|
@@ -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.
|