@mui/x-data-grid 7.0.0-alpha.2 → 7.0.0-alpha.4
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 +364 -0
- package/DataGrid/DataGrid.d.ts +0 -10
- package/DataGrid/DataGrid.js +11 -23
- package/DataGrid/useDataGridProps.js +1 -1
- package/README.md +0 -1
- package/colDef/gridCheckboxSelectionColDef.js +1 -1
- package/colDef/gridDefaultColumnTypes.d.ts +2 -2
- package/colDef/gridDefaultColumnTypes.js +2 -2
- package/components/GridHeader.js +3 -2
- package/components/GridRow.js +9 -6
- package/components/base/GridOverlays.js +0 -2
- package/components/cell/GridActionsCell.js +0 -1
- package/components/cell/GridCell.js +3 -5
- package/components/cell/GridEditDateCell.js +1 -20
- package/components/columnHeaders/GridColumnGroupHeader.js +2 -1
- package/components/columnHeaders/GridColumnHeaderItem.js +2 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +1 -1
- package/components/panel/filterPanel/GridFilterForm.js +2 -2
- package/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/components/panel/index.d.ts +0 -1
- package/components/panel/index.js +0 -1
- package/components/virtualization/GridVirtualScroller.js +0 -1
- package/constants/defaultGridSlotsComponents.js +1 -2
- package/hooks/features/clipboard/useGridClipboard.d.ts +1 -1
- package/hooks/features/clipboard/useGridClipboard.js +1 -1
- package/hooks/features/editing/useGridCellEditing.js +8 -23
- package/hooks/features/editing/useGridRowEditing.js +7 -22
- package/hooks/features/export/useGridCsvExport.d.ts +1 -1
- package/hooks/features/export/useGridCsvExport.js +1 -1
- package/hooks/features/filter/gridFilterUtils.d.ts +1 -0
- package/hooks/features/filter/gridFilterUtils.js +7 -4
- package/hooks/features/filter/useGridFilter.js +2 -2
- package/hooks/features/focus/gridFocusStateSelector.d.ts +2 -2
- package/hooks/features/focus/gridFocusStateSelector.js +2 -6
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.d.ts +3 -3
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +3 -4
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +9 -6
- package/hooks/features/rowSelection/useGridRowSelection.js +2 -1
- package/hooks/features/rows/useGridRowsMeta.js +0 -1
- package/hooks/features/sorting/useGridSorting.js +6 -5
- package/hooks/features/virtualization/useGridVirtualScroller.js +0 -1
- package/index.js +1 -1
- package/internals/index.d.ts +2 -2
- package/internals/index.js +2 -2
- package/legacy/DataGrid/DataGrid.js +11 -23
- package/legacy/DataGrid/useDataGridProps.js +1 -1
- package/legacy/colDef/gridCheckboxSelectionColDef.js +1 -1
- package/legacy/colDef/gridDefaultColumnTypes.js +2 -2
- package/legacy/components/GridHeader.js +3 -2
- package/legacy/components/GridRow.js +9 -6
- package/legacy/components/base/GridOverlays.js +0 -2
- package/legacy/components/cell/GridActionsCell.js +0 -1
- package/legacy/components/cell/GridCell.js +3 -5
- package/legacy/components/cell/GridEditDateCell.js +1 -20
- package/legacy/components/columnHeaders/GridColumnGroupHeader.js +2 -1
- package/legacy/components/columnHeaders/GridColumnHeaderItem.js +2 -1
- package/legacy/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +1 -1
- package/legacy/components/panel/filterPanel/GridFilterForm.js +2 -2
- package/legacy/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/legacy/components/panel/index.js +0 -1
- package/legacy/components/virtualization/GridVirtualScroller.js +0 -1
- package/legacy/constants/defaultGridSlotsComponents.js +1 -2
- package/legacy/hooks/features/clipboard/useGridClipboard.js +1 -1
- package/legacy/hooks/features/editing/useGridCellEditing.js +8 -23
- package/legacy/hooks/features/editing/useGridRowEditing.js +7 -24
- package/legacy/hooks/features/export/useGridCsvExport.js +1 -1
- package/legacy/hooks/features/filter/gridFilterUtils.js +7 -4
- package/legacy/hooks/features/filter/useGridFilter.js +2 -2
- package/legacy/hooks/features/focus/gridFocusStateSelector.js +2 -6
- package/legacy/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +3 -4
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +9 -6
- package/legacy/hooks/features/rowSelection/useGridRowSelection.js +2 -1
- package/legacy/hooks/features/rows/useGridRowsMeta.js +0 -1
- package/legacy/hooks/features/sorting/useGridSorting.js +6 -5
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +0 -1
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +2 -2
- package/legacy/locales/bgBG.js +33 -37
- package/legacy/locales/coreLocales.js +1 -0
- package/legacy/locales/daDK.js +37 -39
- package/legacy/locales/plPL.js +0 -1
- package/legacy/models/params/gridEditCellParams.js +1 -0
- package/legacy/utils/domUtils.js +10 -1
- package/legacy/utils/utils.js +0 -1
- package/locales/bgBG.js +33 -37
- package/locales/coreLocales.js +1 -0
- package/locales/daDK.js +37 -39
- package/locales/plPL.js +0 -1
- package/models/api/gridEditingApi.d.ts +2 -4
- package/models/api/gridSortApi.d.ts +2 -2
- package/models/colDef/gridColType.d.ts +2 -4
- package/models/gridFilterModel.d.ts +2 -2
- package/models/gridSlotsComponent.d.ts +0 -5
- package/models/gridSlotsComponentsProps.d.ts +0 -3
- package/models/params/gridEditCellParams.d.ts +3 -1
- package/models/params/gridEditCellParams.js +1 -0
- package/models/params/gridRowParams.d.ts +1 -0
- package/models/props/DataGridProps.d.ts +1 -1
- package/modern/DataGrid/DataGrid.js +11 -23
- package/modern/DataGrid/useDataGridProps.js +1 -1
- package/modern/colDef/gridCheckboxSelectionColDef.js +1 -1
- package/modern/colDef/gridDefaultColumnTypes.js +2 -2
- package/modern/components/GridHeader.js +2 -1
- package/modern/components/GridRow.js +9 -6
- package/modern/components/base/GridOverlays.js +0 -2
- package/modern/components/cell/GridActionsCell.js +0 -1
- package/modern/components/cell/GridCell.js +2 -4
- package/modern/components/cell/GridEditDateCell.js +1 -20
- package/modern/components/columnHeaders/GridColumnGroupHeader.js +2 -1
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +2 -1
- package/modern/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterForm.js +2 -2
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/modern/components/panel/index.js +0 -1
- package/modern/components/virtualization/GridVirtualScroller.js +0 -1
- package/modern/constants/defaultGridSlotsComponents.js +1 -2
- package/modern/hooks/features/clipboard/useGridClipboard.js +1 -1
- package/modern/hooks/features/editing/useGridCellEditing.js +8 -23
- package/modern/hooks/features/editing/useGridRowEditing.js +7 -22
- package/modern/hooks/features/export/useGridCsvExport.js +1 -1
- package/modern/hooks/features/filter/gridFilterUtils.js +4 -2
- package/modern/hooks/features/filter/useGridFilter.js +2 -2
- package/modern/hooks/features/focus/gridFocusStateSelector.js +2 -6
- package/modern/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +3 -4
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +9 -6
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +2 -1
- package/modern/hooks/features/rows/useGridRowsMeta.js +0 -1
- package/modern/hooks/features/sorting/useGridSorting.js +6 -5
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +0 -1
- package/modern/index.js +1 -1
- package/modern/internals/index.js +2 -2
- package/modern/locales/bgBG.js +33 -37
- package/modern/locales/coreLocales.js +1 -0
- package/modern/locales/daDK.js +37 -39
- package/modern/locales/plPL.js +0 -1
- package/modern/models/params/gridEditCellParams.js +1 -0
- package/modern/utils/domUtils.js +10 -1
- package/modern/utils/utils.js +0 -1
- package/node/DataGrid/DataGrid.js +11 -23
- package/node/DataGrid/useDataGridProps.js +1 -1
- package/node/colDef/gridCheckboxSelectionColDef.js +1 -1
- package/node/colDef/gridDefaultColumnTypes.js +2 -2
- package/node/components/GridHeader.js +2 -1
- package/node/components/GridRow.js +8 -5
- package/node/components/base/GridOverlays.js +0 -2
- package/node/components/cell/GridActionsCell.js +0 -1
- package/node/components/cell/GridCell.js +2 -4
- package/node/components/cell/GridEditDateCell.js +1 -20
- package/node/components/columnHeaders/GridColumnGroupHeader.js +2 -1
- package/node/components/columnHeaders/GridColumnHeaderItem.js +2 -1
- package/node/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +1 -1
- package/node/components/panel/filterPanel/GridFilterForm.js +2 -2
- package/node/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/node/components/panel/index.js +0 -11
- package/node/components/virtualization/GridVirtualScroller.js +0 -1
- package/node/constants/defaultGridSlotsComponents.js +0 -1
- package/node/hooks/features/clipboard/useGridClipboard.js +1 -1
- package/node/hooks/features/editing/useGridCellEditing.js +7 -22
- package/node/hooks/features/editing/useGridRowEditing.js +6 -21
- package/node/hooks/features/export/useGridCsvExport.js +1 -1
- package/node/hooks/features/filter/gridFilterUtils.js +6 -3
- package/node/hooks/features/filter/useGridFilter.js +1 -1
- package/node/hooks/features/focus/gridFocusStateSelector.js +3 -7
- package/node/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +5 -7
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +8 -5
- package/node/hooks/features/rowSelection/useGridRowSelection.js +2 -1
- package/node/hooks/features/rows/useGridRowsMeta.js +0 -1
- package/node/hooks/features/sorting/useGridSorting.js +6 -5
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +0 -1
- package/node/index.js +1 -1
- package/node/internals/index.js +21 -14
- package/node/locales/bgBG.js +33 -37
- package/node/locales/daDK.js +37 -39
- package/node/locales/plPL.js +0 -1
- package/node/models/params/gridEditCellParams.js +1 -0
- package/node/utils/domUtils.js +11 -1
- package/node/utils/utils.js +0 -1
- package/package.json +4 -4
- package/utils/domUtils.d.ts +2 -0
- package/utils/domUtils.js +10 -1
- package/utils/utils.js +0 -1
|
@@ -7,6 +7,7 @@ import { gridColumnGroupsLookupSelector } from '../../hooks/features/columnGroup
|
|
|
7
7
|
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
8
8
|
import { useGridSelector } from '../../hooks/utils/useGridSelector';
|
|
9
9
|
import { GridGenericColumnHeaderItem } from './GridGenericColumnHeaderItem';
|
|
10
|
+
import { isEventTargetInPortal } from '../../utils/domUtils';
|
|
10
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
12
|
const useUtilityClasses = ownerState => {
|
|
12
13
|
const {
|
|
@@ -85,7 +86,7 @@ function GridColumnGroupHeader(props) {
|
|
|
85
86
|
const publish = React.useCallback(eventName => event => {
|
|
86
87
|
// Ignore portal
|
|
87
88
|
// See https://github.com/mui/mui-x/issues/1721
|
|
88
|
-
if (
|
|
89
|
+
if (isEventTargetInPortal(event)) {
|
|
89
90
|
return;
|
|
90
91
|
}
|
|
91
92
|
apiRef.current.publishEvent(eventName, renderParams, event);
|
|
@@ -9,6 +9,7 @@ import { GridColumnHeaderMenu } from '../menu/columnMenu/GridColumnHeaderMenu';
|
|
|
9
9
|
import { getDataGridUtilityClass } from '../../constants/gridClasses';
|
|
10
10
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
11
11
|
import { GridGenericColumnHeaderItem } from './GridGenericColumnHeaderItem';
|
|
12
|
+
import { isEventTargetInPortal } from '../../utils/domUtils';
|
|
12
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
15
|
const useUtilityClasses = ownerState => {
|
|
@@ -68,7 +69,7 @@ function GridColumnHeaderItem(props) {
|
|
|
68
69
|
const publish = React.useCallback(eventName => event => {
|
|
69
70
|
// Ignore portal
|
|
70
71
|
// See https://github.com/mui/mui-x/issues/1721
|
|
71
|
-
if (
|
|
72
|
+
if (isEventTargetInPortal(event)) {
|
|
72
73
|
return;
|
|
73
74
|
}
|
|
74
75
|
apiRef.current.publishEvent(eventName, apiRef.current.getColumnHeaderParams(colDef.field), event);
|
|
@@ -29,7 +29,7 @@ function GridColumnMenuSortItem(props) {
|
|
|
29
29
|
const onSortMenuItemClick = React.useCallback(event => {
|
|
30
30
|
onClick(event);
|
|
31
31
|
const direction = event.currentTarget.getAttribute('data-value') || null;
|
|
32
|
-
apiRef.current.sortColumn(colDef, direction === sortDirection ? null : direction);
|
|
32
|
+
apiRef.current.sortColumn(colDef.field, direction === sortDirection ? null : direction);
|
|
33
33
|
}, [apiRef, colDef, onClick, sortDirection]);
|
|
34
34
|
if (!colDef || !colDef.sortable || !sortingOrder.some(item => !!item)) {
|
|
35
35
|
return null;
|
|
@@ -178,8 +178,8 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
178
178
|
// try to keep the same operator when column change
|
|
179
179
|
const newOperator = column.filterOperators.find(operator => operator.value === item.operator) || column.filterOperators[0];
|
|
180
180
|
|
|
181
|
-
// Erase filter value if the input component is modified
|
|
182
|
-
const eraseItemValue = !newOperator.InputComponent || newOperator.InputComponent !== (currentOperator == null ? void 0 : currentOperator.InputComponent);
|
|
181
|
+
// Erase filter value if the input component or filtered column type is modified
|
|
182
|
+
const eraseItemValue = !newOperator.InputComponent || newOperator.InputComponent !== (currentOperator == null ? void 0 : currentOperator.InputComponent) || column.type !== currentColumn.type;
|
|
183
183
|
applyFilterChanges(_extends({}, item, {
|
|
184
184
|
field,
|
|
185
185
|
operator: newOperator.value,
|
|
@@ -43,7 +43,7 @@ function GridFilterInputValue(props) {
|
|
|
43
43
|
}, [id, applyValue, item, rootProps.filterDebounceMs, filterTimeout]);
|
|
44
44
|
React.useEffect(() => {
|
|
45
45
|
const itemPlusTag = item;
|
|
46
|
-
if (itemPlusTag.fromInput !== id) {
|
|
46
|
+
if (itemPlusTag.fromInput !== id || item.value === undefined) {
|
|
47
47
|
var _item$value2;
|
|
48
48
|
setFilterValueState(String((_item$value2 = item.value) != null ? _item$value2 : ''));
|
|
49
49
|
}
|
|
@@ -29,7 +29,6 @@ const VirtualScrollerRoot = styled('div', {
|
|
|
29
29
|
},
|
|
30
30
|
zIndex: 0 // See https://github.com/mui/mui-x/issues/10547
|
|
31
31
|
});
|
|
32
|
-
|
|
33
32
|
const GridVirtualScroller = /*#__PURE__*/React.forwardRef(function GridVirtualScroller(props, ref) {
|
|
34
33
|
const rootProps = useGridRootProps();
|
|
35
34
|
const classes = useUtilityClasses(rootProps);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { GridSkeletonCell, GridColumnsPanel, GridFilterPanel, GridFooter, GridLoadingOverlay, GridNoRowsOverlay, GridPagination, GridPanel,
|
|
2
|
+
import { GridSkeletonCell, GridColumnsPanel, GridFilterPanel, GridFooter, GridLoadingOverlay, GridNoRowsOverlay, GridPagination, GridPanel, GridRow, GridColumnHeaderFilterIconButton, GridRowCount } from '../components';
|
|
3
3
|
import { GridCellV7 } from '../components/cell/GridCell';
|
|
4
4
|
import { GridColumnHeaders } from '../components/GridColumnHeaders';
|
|
5
5
|
import { GridColumnMenu } from '../components/menu/columnMenu/GridColumnMenu';
|
|
@@ -17,7 +17,6 @@ export const DATA_GRID_DEFAULT_SLOTS_COMPONENTS = _extends({}, materialSlots, {
|
|
|
17
17
|
footer: GridFooter,
|
|
18
18
|
footerRowCount: GridRowCount,
|
|
19
19
|
toolbar: null,
|
|
20
|
-
preferencesPanel: GridPreferencesPanel,
|
|
21
20
|
loadingOverlay: GridLoadingOverlay,
|
|
22
21
|
noResultsOverlay: GridNoResultsOverlay,
|
|
23
22
|
noRowsOverlay: GridNoRowsOverlay,
|
|
@@ -5,4 +5,4 @@ import type { DataGridProcessedProps } from '../../../models/props/DataGridProps
|
|
|
5
5
|
* @requires useGridCsvExport (method)
|
|
6
6
|
* @requires useGridSelection (method)
|
|
7
7
|
*/
|
|
8
|
-
export declare const useGridClipboard: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, '
|
|
8
|
+
export declare const useGridClipboard: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'ignoreValueFormatterDuringExport' | 'onClipboardCopy' | 'clipboardCopyCellDelimiter'>) => void;
|
|
@@ -50,7 +50,7 @@ function hasNativeSelection(element) {
|
|
|
50
50
|
* @requires useGridSelection (method)
|
|
51
51
|
*/
|
|
52
52
|
export const useGridClipboard = (apiRef, props) => {
|
|
53
|
-
const ignoreValueFormatterProp = props.
|
|
53
|
+
const ignoreValueFormatterProp = props.ignoreValueFormatterDuringExport;
|
|
54
54
|
const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp == null ? void 0 : ignoreValueFormatterProp.clipboardExport : ignoreValueFormatterProp) || false;
|
|
55
55
|
const clipboardCopyCellDelimiter = props.clipboardCopyCellDelimiter;
|
|
56
56
|
const handleCopy = React.useCallback(event => {
|
|
@@ -4,7 +4,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
4
4
|
const _excluded = ["id", "field"],
|
|
5
5
|
_excluded2 = ["id", "field"];
|
|
6
6
|
import * as React from 'react';
|
|
7
|
-
import { unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
7
|
+
import { unstable_useEventCallback as useEventCallback, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
8
8
|
import { useGridApiEventHandler, useGridApiOptionHandler } from '../../utils/useGridApiEventHandler';
|
|
9
9
|
import { GridEditModes, GridCellModes } from '../../../models/gridEditRowModel';
|
|
10
10
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
@@ -81,7 +81,6 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
81
81
|
reason = event.shiftKey ? GridCellEditStopReasons.shiftTabKeyDown : GridCellEditStopReasons.tabKeyDown;
|
|
82
82
|
event.preventDefault(); // Prevent going to the next element in the tab sequence
|
|
83
83
|
}
|
|
84
|
-
|
|
85
84
|
if (reason) {
|
|
86
85
|
const newParams = _extends({}, params, {
|
|
87
86
|
reason
|
|
@@ -101,7 +100,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
101
100
|
if (isPrintableKey(event)) {
|
|
102
101
|
reason = GridCellEditStartReasons.printableKeyDown;
|
|
103
102
|
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
|
|
104
|
-
reason = GridCellEditStartReasons.
|
|
103
|
+
reason = GridCellEditStartReasons.pasteKeyDown;
|
|
105
104
|
} else if (event.key === 'Enter') {
|
|
106
105
|
reason = GridCellEditStartReasons.enterKeyDown;
|
|
107
106
|
} else if (event.key === 'Delete' || event.key === 'Backspace') {
|
|
@@ -121,24 +120,13 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
121
120
|
const {
|
|
122
121
|
id,
|
|
123
122
|
field,
|
|
124
|
-
reason
|
|
125
|
-
key,
|
|
126
|
-
colDef
|
|
123
|
+
reason
|
|
127
124
|
} = params;
|
|
128
125
|
const startCellEditModeParams = {
|
|
129
126
|
id,
|
|
130
127
|
field
|
|
131
128
|
};
|
|
132
|
-
if (reason === GridCellEditStartReasons.printableKeyDown) {
|
|
133
|
-
if (React.version.startsWith('17')) {
|
|
134
|
-
// In React 17, cleaning the input is enough.
|
|
135
|
-
// The sequence of events makes the key pressed by the end-users update the textbox directly.
|
|
136
|
-
startCellEditModeParams.deleteValue = true;
|
|
137
|
-
} else {
|
|
138
|
-
const initialValue = colDef.valueParser ? colDef.valueParser(key) : key;
|
|
139
|
-
startCellEditModeParams.initialValue = initialValue;
|
|
140
|
-
}
|
|
141
|
-
} else if (reason === GridCellEditStartReasons.deleteKeyDown) {
|
|
129
|
+
if (reason === GridCellEditStartReasons.printableKeyDown || reason === GridCellEditStartReasons.deleteKeyDown || reason === GridCellEditStartReasons.pasteKeyDown) {
|
|
142
130
|
startCellEditModeParams.deleteValue = true;
|
|
143
131
|
}
|
|
144
132
|
apiRef.current.startCellEditMode(startCellEditModeParams);
|
|
@@ -186,7 +174,6 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
186
174
|
if (props.cellModesModel && isNewModelDifferentFromProp) {
|
|
187
175
|
return; // The prop always win
|
|
188
176
|
}
|
|
189
|
-
|
|
190
177
|
setCellModesModel(newModel);
|
|
191
178
|
cellModesModelRef.current = newModel;
|
|
192
179
|
apiRef.current.publishEvent('cellModesModelChange', newModel);
|
|
@@ -248,17 +235,13 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
248
235
|
initialValue
|
|
249
236
|
} = params;
|
|
250
237
|
let newValue = apiRef.current.getCellValue(id, field);
|
|
251
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
252
|
-
let unstable_updateValueOnRender = false;
|
|
253
238
|
if (deleteValue || initialValue) {
|
|
254
239
|
newValue = deleteValue ? '' : initialValue;
|
|
255
|
-
unstable_updateValueOnRender = true;
|
|
256
240
|
}
|
|
257
241
|
const newProps = {
|
|
258
242
|
value: newValue,
|
|
259
243
|
error: false,
|
|
260
|
-
isProcessingProps: false
|
|
261
|
-
unstable_updateValueOnRender
|
|
244
|
+
isProcessingProps: false
|
|
262
245
|
};
|
|
263
246
|
updateOrDeleteFieldState(id, field, newProps);
|
|
264
247
|
apiRef.current.setCellFocus(id, field);
|
|
@@ -423,7 +406,9 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
423
406
|
updateCellModesModel(cellModesModelProp);
|
|
424
407
|
}
|
|
425
408
|
}, [cellModesModelProp, updateCellModesModel]);
|
|
426
|
-
|
|
409
|
+
|
|
410
|
+
// Run this effect synchronously so that the keyboard event can impact the yet-to-be-rendered input.
|
|
411
|
+
useEnhancedEffect(() => {
|
|
427
412
|
const idToIdLookup = gridRowsDataRowIdToIdLookupSelector(apiRef);
|
|
428
413
|
|
|
429
414
|
// Update the ref here because updateStateToStopCellEditMode may change it later
|
|
@@ -4,7 +4,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
4
4
|
const _excluded = ["id"],
|
|
5
5
|
_excluded2 = ["id"];
|
|
6
6
|
import * as React from 'react';
|
|
7
|
-
import { unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
7
|
+
import { unstable_useEventCallback as useEventCallback, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
8
8
|
import { useGridApiEventHandler, useGridApiOptionHandler } from '../../utils/useGridApiEventHandler';
|
|
9
9
|
import { GridEditModes, GridRowModes } from '../../../models/gridEditRowModel';
|
|
10
10
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
@@ -172,7 +172,6 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
172
172
|
const rowParams = apiRef.current.getRowParams(params.id);
|
|
173
173
|
const newParams = _extends({}, rowParams, {
|
|
174
174
|
field: params.field,
|
|
175
|
-
key: event.key,
|
|
176
175
|
reason
|
|
177
176
|
});
|
|
178
177
|
apiRef.current.publishEvent('rowEditStart', newParams, event);
|
|
@@ -183,24 +182,13 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
183
182
|
const {
|
|
184
183
|
id,
|
|
185
184
|
field,
|
|
186
|
-
reason
|
|
187
|
-
key,
|
|
188
|
-
columns
|
|
185
|
+
reason
|
|
189
186
|
} = params;
|
|
190
187
|
const startRowEditModeParams = {
|
|
191
188
|
id,
|
|
192
189
|
fieldToFocus: field
|
|
193
190
|
};
|
|
194
|
-
if (reason === GridRowEditStartReasons.printableKeyDown) {
|
|
195
|
-
if (React.version.startsWith('17')) {
|
|
196
|
-
// In React 17, cleaning the input is enough.
|
|
197
|
-
// The sequence of events makes the key pressed by the end-users update the textbox directly.
|
|
198
|
-
startRowEditModeParams.deleteValue = !!field;
|
|
199
|
-
} else {
|
|
200
|
-
const colDef = columns.find(col => col.field === field);
|
|
201
|
-
startRowEditModeParams.initialValue = colDef.valueParser ? colDef.valueParser(key) : key;
|
|
202
|
-
}
|
|
203
|
-
} else if (reason === GridRowEditStartReasons.deleteKeyDown) {
|
|
191
|
+
if (reason === GridRowEditStartReasons.printableKeyDown || reason === GridRowEditStartReasons.deleteKeyDown) {
|
|
204
192
|
startRowEditModeParams.deleteValue = !!field;
|
|
205
193
|
}
|
|
206
194
|
apiRef.current.startRowEditMode(startRowEditModeParams);
|
|
@@ -252,7 +240,6 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
252
240
|
if (props.rowModesModel && isNewModelDifferentFromProp) {
|
|
253
241
|
return; // The prop always win
|
|
254
242
|
}
|
|
255
|
-
|
|
256
243
|
setRowModesModel(newModel);
|
|
257
244
|
rowModesModelRef.current = newModel;
|
|
258
245
|
apiRef.current.publishEvent('rowModesModelChange', newModel);
|
|
@@ -323,17 +310,13 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
323
310
|
return acc;
|
|
324
311
|
}
|
|
325
312
|
let newValue = apiRef.current.getCellValue(id, field);
|
|
326
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
327
|
-
let unstable_updateValueOnRender = false;
|
|
328
313
|
if (fieldToFocus === field && (deleteValue || initialValue)) {
|
|
329
314
|
newValue = deleteValue ? '' : initialValue;
|
|
330
|
-
unstable_updateValueOnRender = true;
|
|
331
315
|
}
|
|
332
316
|
acc[field] = {
|
|
333
317
|
value: newValue,
|
|
334
318
|
error: false,
|
|
335
|
-
isProcessingProps: false
|
|
336
|
-
unstable_updateValueOnRender
|
|
319
|
+
isProcessingProps: false
|
|
337
320
|
};
|
|
338
321
|
return acc;
|
|
339
322
|
}, {});
|
|
@@ -553,7 +536,9 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
553
536
|
updateRowModesModel(rowModesModelProp);
|
|
554
537
|
}
|
|
555
538
|
}, [rowModesModelProp, updateRowModesModel]);
|
|
556
|
-
|
|
539
|
+
|
|
540
|
+
// Run this effect synchronously so that the keyboard event can impact the yet-to-be-rendered input.
|
|
541
|
+
useEnhancedEffect(() => {
|
|
557
542
|
const idToIdLookup = gridRowsDataRowIdToIdLookupSelector(apiRef);
|
|
558
543
|
|
|
559
544
|
// Update the ref here because updateStateToStopRowEditMode may change it later
|
|
@@ -8,4 +8,4 @@ import type { DataGridProcessedProps } from '../../../models/props/DataGridProps
|
|
|
8
8
|
* @requires useGridSelection (state)
|
|
9
9
|
* @requires useGridParamsApi (method)
|
|
10
10
|
*/
|
|
11
|
-
export declare const useGridCsvExport: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, '
|
|
11
|
+
export declare const useGridCsvExport: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'ignoreValueFormatterDuringExport'>) => void;
|
|
@@ -16,7 +16,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
16
16
|
*/
|
|
17
17
|
export const useGridCsvExport = (apiRef, props) => {
|
|
18
18
|
const logger = useGridLogger(apiRef, 'useGridCsvExport');
|
|
19
|
-
const ignoreValueFormatterProp = props.
|
|
19
|
+
const ignoreValueFormatterProp = props.ignoreValueFormatterDuringExport;
|
|
20
20
|
const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp == null ? void 0 : ignoreValueFormatterProp.csvExport : ignoreValueFormatterProp) || false;
|
|
21
21
|
const getDataAsCsv = React.useCallback((options = {}) => {
|
|
22
22
|
var _options$getRowsToExp, _options$includeHeade, _options$includeColum;
|
|
@@ -14,6 +14,7 @@ export declare const cleanFilterItem: (item: GridFilterItem, apiRef: React.Mutab
|
|
|
14
14
|
export declare const sanitizeFilterModel: (model: GridFilterModel, disableMultipleColumnsFiltering: boolean, apiRef: React.MutableRefObject<GridPrivateApiCommunity>) => GridFilterModel;
|
|
15
15
|
export declare const mergeStateWithFilterModel: (filterModel: GridFilterModel, disableMultipleColumnsFiltering: boolean, apiRef: React.MutableRefObject<GridPrivateApiCommunity>) => (filteringState: GridStateCommunity['filter']) => GridStateCommunity['filter'];
|
|
16
16
|
export declare const removeDiacritics: (value: unknown) => unknown;
|
|
17
|
+
export declare const shouldQuickFilterExcludeHiddenColumns: (filterModel: GridFilterModel) => boolean;
|
|
17
18
|
export declare const buildAggregatedFilterApplier: (filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridPrivateApiCommunity>, disableEval: boolean) => GridAggregatedFilterItemApplier;
|
|
18
19
|
type FilterCache = {
|
|
19
20
|
cleanedFilterItems?: GridFilterItem[];
|
|
@@ -175,6 +175,10 @@ const buildAggregatedFilterItemsApplier = (filterModel, apiRef, disableEval) =>
|
|
|
175
175
|
filterItemsApplierId += 1;
|
|
176
176
|
return filterItem;
|
|
177
177
|
};
|
|
178
|
+
export const shouldQuickFilterExcludeHiddenColumns = filterModel => {
|
|
179
|
+
var _filterModel$quickFil;
|
|
180
|
+
return (_filterModel$quickFil = filterModel.quickFilterExcludeHiddenColumns) != null ? _filterModel$quickFil : true;
|
|
181
|
+
};
|
|
178
182
|
|
|
179
183
|
/**
|
|
180
184
|
* Generates a method to easily check if a row is matching the current quick filter.
|
|
@@ -183,13 +187,12 @@ const buildAggregatedFilterItemsApplier = (filterModel, apiRef, disableEval) =>
|
|
|
183
187
|
* @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
|
|
184
188
|
*/
|
|
185
189
|
const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
|
|
186
|
-
var _filterModel$
|
|
187
|
-
const quickFilterValues = (_filterModel$
|
|
190
|
+
var _filterModel$quickFil2, _filterModel$quickFil3;
|
|
191
|
+
const quickFilterValues = (_filterModel$quickFil2 = (_filterModel$quickFil3 = filterModel.quickFilterValues) == null ? void 0 : _filterModel$quickFil3.filter(Boolean)) != null ? _filterModel$quickFil2 : [];
|
|
188
192
|
if (quickFilterValues.length === 0) {
|
|
189
193
|
return null;
|
|
190
194
|
}
|
|
191
|
-
const
|
|
192
|
-
const columnFields = quickFilterExcludeHiddenColumns ? gridVisibleColumnFieldsSelector(apiRef) : gridColumnFieldsSelector(apiRef);
|
|
195
|
+
const columnFields = shouldQuickFilterExcludeHiddenColumns(filterModel) ? gridVisibleColumnFieldsSelector(apiRef) : gridColumnFieldsSelector(apiRef);
|
|
193
196
|
const appliersPerField = [];
|
|
194
197
|
const {
|
|
195
198
|
ignoreDiacritics
|
|
@@ -14,7 +14,7 @@ import { useFirstRender } from '../../utils/useFirstRender';
|
|
|
14
14
|
import { gridRowsLookupSelector } from '../rows';
|
|
15
15
|
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
16
16
|
import { GRID_DEFAULT_STRATEGY, useGridRegisterStrategyProcessor } from '../../core/strategyProcessing';
|
|
17
|
-
import { buildAggregatedFilterApplier, sanitizeFilterModel, mergeStateWithFilterModel, cleanFilterItem, passFilterLogic } from './gridFilterUtils';
|
|
17
|
+
import { buildAggregatedFilterApplier, sanitizeFilterModel, mergeStateWithFilterModel, cleanFilterItem, passFilterLogic, shouldQuickFilterExcludeHiddenColumns } from './gridFilterUtils';
|
|
18
18
|
import { isDeepEqual } from '../../../utils/utils';
|
|
19
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
20
|
export const filterStateInitializer = (state, props, apiRef) => {
|
|
@@ -345,7 +345,7 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
345
345
|
useGridApiEventHandler(apiRef, 'rowExpansionChange', updateVisibleRowsLookupState);
|
|
346
346
|
useGridApiEventHandler(apiRef, 'columnVisibilityModelChange', () => {
|
|
347
347
|
const filterModel = gridFilterModelSelector(apiRef);
|
|
348
|
-
if (filterModel.quickFilterValues && filterModel
|
|
348
|
+
if (filterModel.quickFilterValues && shouldQuickFilterExcludeHiddenColumns(filterModel)) {
|
|
349
349
|
// re-apply filters because the quick filter results may have changed
|
|
350
350
|
apiRef.current.unstable_applyFilters();
|
|
351
351
|
}
|
|
@@ -3,10 +3,10 @@ import { GridFocusState, GridTabIndexState } from './gridFocusState';
|
|
|
3
3
|
export declare const gridFocusStateSelector: (state: GridStateCommunity) => GridFocusState;
|
|
4
4
|
export declare const gridFocusCellSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridCellCoordinates | null>;
|
|
5
5
|
export declare const gridFocusColumnHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const gridFocusColumnHeaderFilterSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
|
|
7
7
|
export declare const unstable_gridFocusColumnGroupHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnGroupIdentifier | null>;
|
|
8
8
|
export declare const gridTabIndexStateSelector: (state: GridStateCommunity) => GridTabIndexState;
|
|
9
9
|
export declare const gridTabIndexCellSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridCellCoordinates | null>;
|
|
10
10
|
export declare const gridTabIndexColumnHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
|
|
11
|
-
export declare const
|
|
11
|
+
export declare const gridTabIndexColumnHeaderFilterSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
|
|
12
12
|
export declare const unstable_gridTabIndexColumnGroupHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnGroupIdentifier | null>;
|
|
@@ -2,18 +2,14 @@ import { createSelector } from '../../../utils/createSelector';
|
|
|
2
2
|
export const gridFocusStateSelector = state => state.focus;
|
|
3
3
|
export const gridFocusCellSelector = createSelector(gridFocusStateSelector, focusState => focusState.cell);
|
|
4
4
|
export const gridFocusColumnHeaderSelector = createSelector(gridFocusStateSelector, focusState => focusState.columnHeader);
|
|
5
|
-
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
|
-
export const unstable_gridFocusColumnHeaderFilterSelector = createSelector(gridFocusStateSelector, focusState => focusState.columnHeaderFilter);
|
|
5
|
+
export const gridFocusColumnHeaderFilterSelector = createSelector(gridFocusStateSelector, focusState => focusState.columnHeaderFilter);
|
|
8
6
|
|
|
9
7
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
10
8
|
export const unstable_gridFocusColumnGroupHeaderSelector = createSelector(gridFocusStateSelector, focusState => focusState.columnGroupHeader);
|
|
11
9
|
export const gridTabIndexStateSelector = state => state.tabIndex;
|
|
12
10
|
export const gridTabIndexCellSelector = createSelector(gridTabIndexStateSelector, state => state.cell);
|
|
13
11
|
export const gridTabIndexColumnHeaderSelector = createSelector(gridTabIndexStateSelector, state => state.columnHeader);
|
|
14
|
-
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
16
|
-
export const unstable_gridTabIndexColumnHeaderFilterSelector = createSelector(gridTabIndexStateSelector, state => state.columnHeaderFilter);
|
|
12
|
+
export const gridTabIndexColumnHeaderFilterSelector = createSelector(gridTabIndexStateSelector, state => state.columnHeaderFilter);
|
|
17
13
|
|
|
18
14
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
19
15
|
export const unstable_gridTabIndexColumnGroupHeaderSelector = createSelector(gridTabIndexStateSelector, state => state.columnGroupHeader);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { GridStateCommunity } from '../../../models/gridStateCommunity';
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
2
|
+
export declare const gridHeaderFilteringStateSelector: (state: GridStateCommunity) => import("../../../models/gridHeaderFilteringModel").GridHeaderFilteringState;
|
|
3
|
+
export declare const gridHeaderFilteringEditFieldSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, string | null>;
|
|
4
|
+
export declare const gridHeaderFilteringMenuSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, string | null>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
1
|
import { createSelector } from '../../../utils/createSelector';
|
|
3
|
-
export const
|
|
4
|
-
export const
|
|
5
|
-
export const
|
|
2
|
+
export const gridHeaderFilteringStateSelector = state => state.headerFiltering;
|
|
3
|
+
export const gridHeaderFilteringEditFieldSelector = createSelector(gridHeaderFilteringStateSelector, headerFilteringState => headerFilteringState.editing);
|
|
4
|
+
export const gridHeaderFilteringMenuSelector = createSelector(gridHeaderFilteringStateSelector, headerFilteringState => headerFilteringState.menuOpen);
|
|
@@ -13,8 +13,9 @@ import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPan
|
|
|
13
13
|
import { gridPinnedRowsSelector } from '../rows/gridRowsSelector';
|
|
14
14
|
import { unstable_gridFocusColumnGroupHeaderSelector } from '../focus';
|
|
15
15
|
import { gridColumnGroupsHeaderMaxDepthSelector } from '../columnGrouping/gridColumnGroupsSelector';
|
|
16
|
-
import {
|
|
16
|
+
import { gridHeaderFilteringEditFieldSelector, gridHeaderFilteringMenuSelector } from '../headerFiltering/gridHeaderFilteringSelectors';
|
|
17
17
|
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
18
|
+
import { isEventTargetInPortal } from '../../../utils/domUtils';
|
|
18
19
|
function enrichPageRowsWithPinnedRows(apiRef, rows) {
|
|
19
20
|
const pinnedRows = gridPinnedRowsSelector(apiRef) || {};
|
|
20
21
|
return [...(pinnedRows.top || []), ...rows, ...(pinnedRows.bottom || [])];
|
|
@@ -70,7 +71,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
70
71
|
const currentPageRows = React.useMemo(() => enrichPageRowsWithPinnedRows(apiRef, initialCurrentPageRows), [apiRef, initialCurrentPageRows]);
|
|
71
72
|
const headerFilteringEnabled =
|
|
72
73
|
// @ts-expect-error // TODO move relevant code to the `DataGridPro`
|
|
73
|
-
props.signature !== 'DataGrid' && props.
|
|
74
|
+
props.signature !== 'DataGrid' && props.headerFilters;
|
|
74
75
|
|
|
75
76
|
/**
|
|
76
77
|
* @param {number} colIndex Index of the column to focus
|
|
@@ -237,8 +238,8 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
237
238
|
if (!dimensions) {
|
|
238
239
|
return;
|
|
239
240
|
}
|
|
240
|
-
const isEditing =
|
|
241
|
-
const isHeaderMenuOpen =
|
|
241
|
+
const isEditing = gridHeaderFilteringEditFieldSelector(apiRef) === params.field;
|
|
242
|
+
const isHeaderMenuOpen = gridHeaderFilteringMenuSelector(apiRef) === params.field;
|
|
242
243
|
if (isEditing || isHeaderMenuOpen || !isNavigationKey(event.key)) {
|
|
243
244
|
return;
|
|
244
245
|
}
|
|
@@ -414,7 +415,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
414
415
|
}, [apiRef, currentPageRows.length, goToHeader, goToGroupHeader, goToCell, getRowIdFromIndex]);
|
|
415
416
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
416
417
|
// Ignore portal
|
|
417
|
-
if (
|
|
418
|
+
if (isEventTargetInPortal(event)) {
|
|
418
419
|
return;
|
|
419
420
|
}
|
|
420
421
|
|
|
@@ -506,7 +507,9 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
506
507
|
break;
|
|
507
508
|
}
|
|
508
509
|
const colDef = params.colDef;
|
|
509
|
-
if (colDef &&
|
|
510
|
+
if (colDef &&
|
|
511
|
+
// `GRID_TREE_DATA_GROUPING_FIELD` from the Pro package
|
|
512
|
+
colDef.field === '__tree_data_group__') {
|
|
510
513
|
break;
|
|
511
514
|
}
|
|
512
515
|
if (!event.shiftKey && rowIndexBefore < lastRowIndexInPage) {
|
|
@@ -14,6 +14,7 @@ import { isKeyboardEvent, isNavigationKey } from '../../../utils/keyboardUtils';
|
|
|
14
14
|
import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
|
|
15
15
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPanelToggleField';
|
|
16
16
|
import { gridClasses } from '../../../constants/gridClasses';
|
|
17
|
+
import { isEventTargetInPortal } from '../../../utils/domUtils';
|
|
17
18
|
const getSelectionModelPropValue = (selectionModelProp, prevSelectionModel) => {
|
|
18
19
|
if (selectionModelProp == null) {
|
|
19
20
|
return selectionModelProp;
|
|
@@ -289,7 +290,7 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
289
290
|
|
|
290
291
|
// Ignore portal
|
|
291
292
|
// Do not apply shortcuts if the focus is not on the cell root component
|
|
292
|
-
if (
|
|
293
|
+
if (isEventTargetInPortal(event)) {
|
|
293
294
|
return;
|
|
294
295
|
}
|
|
295
296
|
if (isNavigationKey(event.key) && event.shiftKey) {
|
|
@@ -116,7 +116,8 @@ export const useGridSorting = (apiRef, props) => {
|
|
|
116
116
|
apiRef.current.applySorting();
|
|
117
117
|
}
|
|
118
118
|
}, [apiRef, logger, props.disableMultipleColumnsSorting]);
|
|
119
|
-
const sortColumn = React.useCallback((
|
|
119
|
+
const sortColumn = React.useCallback((field, direction, allowMultipleSorting) => {
|
|
120
|
+
const column = apiRef.current.getColumn(field);
|
|
120
121
|
if (!column.sortable) {
|
|
121
122
|
return;
|
|
122
123
|
}
|
|
@@ -199,17 +200,17 @@ export const useGridSorting = (apiRef, props) => {
|
|
|
199
200
|
* EVENTS
|
|
200
201
|
*/
|
|
201
202
|
const handleColumnHeaderClick = React.useCallback(({
|
|
202
|
-
|
|
203
|
+
field
|
|
203
204
|
}, event) => {
|
|
204
205
|
const allowMultipleSorting = event.shiftKey || event.metaKey || event.ctrlKey;
|
|
205
|
-
sortColumn(
|
|
206
|
+
sortColumn(field, undefined, allowMultipleSorting);
|
|
206
207
|
}, [sortColumn]);
|
|
207
208
|
const handleColumnHeaderKeyDown = React.useCallback(({
|
|
208
|
-
|
|
209
|
+
field
|
|
209
210
|
}, event) => {
|
|
210
211
|
// Ctrl + Enter opens the column menu
|
|
211
212
|
if (isEnterKey(event.key) && !event.ctrlKey && !event.metaKey) {
|
|
212
|
-
sortColumn(
|
|
213
|
+
sortColumn(field, undefined, event.shiftKey);
|
|
213
214
|
}
|
|
214
215
|
}, [sortColumn]);
|
|
215
216
|
const handleColumnsChange = React.useCallback(() => {
|
|
@@ -555,7 +555,6 @@ export const useGridVirtualScroller = props => {
|
|
|
555
555
|
if (rootProps.autoHeight && currentPage.rows.length === 0) {
|
|
556
556
|
size.height = getMinimalContentHeight(apiRef, rootProps.rowHeight); // Give room to show the overlay when there no rows.
|
|
557
557
|
}
|
|
558
|
-
|
|
559
558
|
return size;
|
|
560
559
|
}, [apiRef, rootRef, columnsTotalWidth, rowsMeta.currentPageTotalHeight, needsHorizontalScrollbar, rootProps.autoHeight, rootProps.rowHeight, currentPage.rows.length]);
|
|
561
560
|
React.useEffect(() => {
|
package/index.js
CHANGED
package/internals/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export { useGridInitialization } from '../hooks/core/useGridInitialization';
|
|
|
14
14
|
export { unwrapPrivateAPI } from '../hooks/core/useGridApiInitialization';
|
|
15
15
|
export { useGridClipboard } from '../hooks/features/clipboard/useGridClipboard';
|
|
16
16
|
export { useGridColumnHeaders } from '../hooks/features/columnHeaders/useGridColumnHeaders';
|
|
17
|
-
export {
|
|
17
|
+
export { gridHeaderFilteringEditFieldSelector, gridHeaderFilteringMenuSelector, } from '../hooks/features/headerFiltering/gridHeaderFilteringSelectors';
|
|
18
18
|
export type { GridSlotsComponentsProps } from '../models/gridSlotsComponentsProps';
|
|
19
19
|
export type { UseGridColumnHeadersProps, GetHeadersParams, } from '../hooks/features/columnHeaders/useGridColumnHeaders';
|
|
20
20
|
export { useGridColumnMenu, columnMenuStateInitializer, } from '../hooks/features/columnMenu/useGridColumnMenu';
|
|
@@ -67,7 +67,7 @@ export type { GridExperimentalFeatures, DataGridPropsWithoutDefaultValue, DataGr
|
|
|
67
67
|
export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
|
|
68
68
|
export * from '../utils/createControllablePromise';
|
|
69
69
|
export { createSelector, createSelectorMemoized, unstable_resetCreateSelectorCache, } from '../utils/createSelector';
|
|
70
|
-
export { findParentElementFromClassName, getActiveElement } from '../utils/domUtils';
|
|
70
|
+
export { findParentElementFromClassName, getActiveElement, isEventTargetInPortal, } from '../utils/domUtils';
|
|
71
71
|
export { isNavigationKey } from '../utils/keyboardUtils';
|
|
72
72
|
export { clamp, isDeepEqual, isNumber, isFunction, isObject } from '../utils/utils';
|
|
73
73
|
export { buildWarning } from '../utils/warning';
|
package/internals/index.js
CHANGED
|
@@ -11,7 +11,7 @@ export { useGridInitialization } from '../hooks/core/useGridInitialization';
|
|
|
11
11
|
export { unwrapPrivateAPI } from '../hooks/core/useGridApiInitialization';
|
|
12
12
|
export { useGridClipboard } from '../hooks/features/clipboard/useGridClipboard';
|
|
13
13
|
export { useGridColumnHeaders } from '../hooks/features/columnHeaders/useGridColumnHeaders';
|
|
14
|
-
export {
|
|
14
|
+
export { gridHeaderFilteringEditFieldSelector, gridHeaderFilteringMenuSelector } from '../hooks/features/headerFiltering/gridHeaderFilteringSelectors';
|
|
15
15
|
export { useGridColumnMenu, columnMenuStateInitializer } from '../hooks/features/columnMenu/useGridColumnMenu';
|
|
16
16
|
export { useGridColumns, columnsStateInitializer } from '../hooks/features/columns/useGridColumns';
|
|
17
17
|
export { getTotalHeaderHeight } from '../hooks/features/columns/gridColumnsUtils';
|
|
@@ -54,7 +54,7 @@ export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
|
|
|
54
54
|
export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
|
|
55
55
|
export * from '../utils/createControllablePromise';
|
|
56
56
|
export { createSelector, createSelectorMemoized, unstable_resetCreateSelectorCache } from '../utils/createSelector';
|
|
57
|
-
export { findParentElementFromClassName, getActiveElement } from '../utils/domUtils';
|
|
57
|
+
export { findParentElementFromClassName, getActiveElement, isEventTargetInPortal } from '../utils/domUtils';
|
|
58
58
|
export { isNavigationKey } from '../utils/keyboardUtils';
|
|
59
59
|
export { clamp, isDeepEqual, isNumber, isFunction, isObject } from '../utils/utils';
|
|
60
60
|
export { buildWarning } from '../utils/warning';
|