@mui/x-data-grid 6.0.0-alpha.2 → 6.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 +493 -141
- package/DataGrid/DataGrid.js +14 -34
- package/DataGrid/useDataGridComponent.js +8 -14
- package/DataGrid/useDataGridProps.js +3 -3
- package/colDef/gridCheckboxSelectionColDef.js +1 -1
- package/colDef/gridNumericOperators.d.ts +1 -1
- package/colDef/gridSingleSelectOperators.d.ts +1 -1
- package/colDef/gridStringOperators.d.ts +1 -1
- package/components/GridFooter.js +1 -1
- package/components/GridRow.js +2 -2
- package/components/base/GridBody.js +2 -2
- package/components/cell/GridEditInputCell.js +3 -8
- package/components/cell/GridEditSingleSelectCell.js +6 -38
- package/components/columnHeaders/GridColumnGroupHeader.d.ts +2 -0
- package/components/columnHeaders/GridColumnGroupHeader.js +32 -5
- package/components/columnSelection/GridHeaderCheckbox.js +3 -3
- package/components/containers/GridRoot.js +4 -3
- package/components/panel/GridColumnsPanel.d.ts +2 -0
- package/components/panel/GridColumnsPanel.js +10 -4
- package/components/panel/filterPanel/GridFilterForm.d.ts +12 -0
- package/components/panel/filterPanel/GridFilterForm.js +29 -7
- package/components/panel/filterPanel/GridFilterPanel.d.ts +12 -0
- package/components/panel/filterPanel/GridFilterPanel.js +64 -19
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +1 -1
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +1 -1
- package/hooks/core/strategyProcessing/useGridRegisterStrategyProcessor.d.ts +1 -1
- package/hooks/core/useGridInitialization.d.ts +1 -1
- package/hooks/core/useGridStateInitialization.d.ts +1 -1
- package/hooks/features/columnGrouping/gridColumnGroupsInterfaces.d.ts +10 -1
- package/hooks/features/columnGrouping/gridColumnGroupsSelector.d.ts +6 -0
- package/hooks/features/columnGrouping/gridColumnGroupsSelector.js +34 -1
- package/hooks/features/columnGrouping/gridColumnGroupsUtils.d.ts +15 -0
- package/hooks/features/columnGrouping/gridColumnGroupsUtils.js +89 -0
- package/hooks/features/columnGrouping/useGridColumnGrouping.d.ts +1 -15
- package/hooks/features/columnGrouping/useGridColumnGrouping.js +66 -66
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +60 -116
- package/hooks/features/density/densitySelector.d.ts +0 -2
- package/hooks/features/density/densitySelector.js +1 -3
- package/hooks/features/density/densityState.d.ts +0 -1
- package/hooks/features/density/useGridDensity.d.ts +1 -1
- package/hooks/features/density/useGridDensity.js +9 -45
- package/hooks/features/dimensions/useGridDimensions.js +3 -2
- package/hooks/features/{editRows/gridEditRowsSelector.d.ts → editing/gridEditingSelectors.d.ts} +0 -0
- package/hooks/features/{editRows/gridEditRowsSelector.js → editing/gridEditingSelectors.js} +0 -0
- package/hooks/features/editing/index.d.ts +1 -0
- package/hooks/features/editing/index.js +1 -0
- package/hooks/features/{editRows/useGridCellEditing.new.d.ts → editing/useGridCellEditing.d.ts} +0 -0
- package/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js} +21 -6
- package/hooks/features/{editRows/useGridEditing.new.d.ts → editing/useGridEditing.d.ts} +0 -0
- package/hooks/features/{editRows/useGridEditing.new.js → editing/useGridEditing.js} +3 -3
- package/hooks/features/{editRows/useGridRowEditing.new.d.ts → editing/useGridRowEditing.d.ts} +0 -0
- package/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js} +20 -6
- package/hooks/features/export/useGridPrintExport.js +2 -2
- package/hooks/features/focus/gridFocusState.d.ts +6 -0
- package/hooks/features/focus/gridFocusStateSelector.d.ts +2 -0
- package/hooks/features/focus/gridFocusStateSelector.js +6 -2
- package/hooks/features/focus/useGridFocus.js +69 -11
- package/hooks/features/index.d.ts +2 -2
- package/hooks/features/index.js +2 -2
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +135 -1
- package/hooks/features/{selection/gridSelectionSelector.d.ts → rowSelection/gridRowSelectionSelector.d.ts} +1 -1
- package/hooks/features/rowSelection/gridRowSelectionSelector.js +9 -0
- package/hooks/features/rowSelection/index.d.ts +1 -0
- package/hooks/features/rowSelection/index.js +1 -0
- package/hooks/features/rowSelection/useGridRowSelection.d.ts +12 -0
- package/hooks/features/{selection/useGridSelection.js → rowSelection/useGridRowSelection.js} +37 -37
- package/hooks/features/{selection/useGridSelectionPreProcessors.d.ts → rowSelection/useGridRowSelectionPreProcessors.d.ts} +1 -1
- package/hooks/features/{selection/useGridSelectionPreProcessors.js → rowSelection/useGridRowSelectionPreProcessors.js} +1 -1
- package/hooks/features/rows/gridRowsInterfaces.d.ts +4 -0
- package/hooks/features/rows/gridRowsUtils.d.ts +1 -1
- package/hooks/features/rows/gridRowsUtils.js +5 -2
- package/hooks/features/rows/useGridRows.js +23 -7
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +2 -2
- package/hooks/utils/useGridApi.d.ts +1 -1
- package/hooks/utils/useGridApiEventHandler.d.ts +2 -2
- package/hooks/utils/useGridApiRef.d.ts +1 -1
- package/hooks/utils/useGridInitializeState.d.ts +1 -1
- package/hooks/utils/useGridNativeEventListener.d.ts +1 -1
- package/hooks/utils/useGridSelector.d.ts +1 -1
- package/hooks/utils/useGridState.d.ts +1 -1
- package/hooks/utils/useGridVisibleRows.d.ts +2 -2
- package/index.js +1 -1
- package/internals/index.d.ts +3 -5
- package/internals/index.js +3 -5
- package/legacy/DataGrid/DataGrid.js +14 -34
- package/legacy/DataGrid/useDataGridComponent.js +8 -14
- package/legacy/DataGrid/useDataGridProps.js +3 -3
- package/legacy/colDef/gridCheckboxSelectionColDef.js +1 -1
- package/legacy/components/GridFooter.js +1 -1
- package/legacy/components/GridRow.js +2 -2
- package/legacy/components/base/GridBody.js +2 -2
- package/legacy/components/cell/GridEditInputCell.js +3 -8
- package/legacy/components/cell/GridEditSingleSelectCell.js +6 -52
- package/legacy/components/columnHeaders/GridColumnGroupHeader.js +46 -13
- package/legacy/components/columnSelection/GridHeaderCheckbox.js +3 -3
- package/legacy/components/containers/GridRoot.js +4 -3
- package/legacy/components/panel/GridColumnsPanel.js +10 -3
- package/legacy/components/panel/filterPanel/GridFilterForm.js +31 -7
- package/legacy/components/panel/filterPanel/GridFilterPanel.js +67 -18
- package/legacy/hooks/features/columnGrouping/gridColumnGroupsSelector.js +33 -1
- package/legacy/hooks/features/columnGrouping/gridColumnGroupsUtils.js +96 -0
- package/legacy/hooks/features/columnGrouping/useGridColumnGrouping.js +64 -64
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +70 -122
- package/legacy/hooks/features/density/densitySelector.js +0 -6
- package/legacy/hooks/features/density/useGridDensity.js +6 -44
- package/legacy/hooks/features/dimensions/useGridDimensions.js +3 -2
- package/legacy/hooks/features/{editRows/gridEditRowsSelector.js → editing/gridEditingSelectors.js} +0 -0
- package/legacy/hooks/features/editing/index.js +1 -0
- package/legacy/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js} +21 -6
- package/legacy/hooks/features/{editRows/useGridEditing.new.js → editing/useGridEditing.js} +3 -3
- package/legacy/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js} +20 -6
- package/legacy/hooks/features/export/useGridPrintExport.js +2 -2
- package/legacy/hooks/features/focus/gridFocusStateSelector.js +8 -0
- package/legacy/hooks/features/focus/useGridFocus.js +72 -11
- package/legacy/hooks/features/index.js +2 -2
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +129 -1
- package/legacy/hooks/features/rowSelection/gridRowSelectionSelector.js +19 -0
- package/legacy/hooks/features/rowSelection/index.js +1 -0
- package/legacy/hooks/features/{selection/useGridSelection.js → rowSelection/useGridRowSelection.js} +37 -37
- package/legacy/hooks/features/{selection/useGridSelectionPreProcessors.js → rowSelection/useGridRowSelectionPreProcessors.js} +1 -1
- package/legacy/hooks/features/rows/gridRowsUtils.js +5 -2
- package/legacy/hooks/features/rows/useGridRows.js +25 -7
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +2 -2
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +3 -5
- package/legacy/locales/trTR.js +17 -17
- package/legacy/models/api/{gridSelectionApi.js → gridRowSelectionApi.js} +0 -0
- package/legacy/models/api/index.js +1 -1
- package/legacy/models/{gridSelectionModel.js → gridRowSelectionModel.js} +0 -0
- package/legacy/models/index.js +1 -1
- package/{models/api/gridSelectionApi.js → legacy/models/params/gridColumnGroupHeaderParams.js} +0 -0
- package/legacy/models/params/gridEditCellParams.js +0 -4
- package/legacy/models/params/index.js +1 -0
- package/locales/trTR.js +17 -17
- package/models/api/gridApiCommon.d.ts +3 -6
- package/models/api/gridApiCommunity.d.ts +1 -7
- package/models/api/gridEditingApi.d.ts +36 -121
- package/models/api/gridFocusApi.d.ts +13 -0
- package/models/api/{gridSelectionApi.d.ts → gridRowSelectionApi.d.ts} +2 -2
- package/models/{gridSelectionModel.js → api/gridRowSelectionApi.js} +0 -0
- package/models/api/index.d.ts +2 -2
- package/models/api/index.js +1 -1
- package/models/colDef/gridColDef.d.ts +0 -8
- package/models/events/gridEventLookup.d.ts +30 -19
- package/models/gridColumnGrouping.d.ts +1 -26
- package/models/gridRowSelectionModel.d.ts +3 -0
- package/{modern/models/api/gridSelectionApi.js → models/gridRowSelectionModel.js} +0 -0
- package/models/gridStateCommunity.d.ts +2 -2
- package/models/index.d.ts +1 -1
- package/models/index.js +1 -1
- package/models/params/gridColumnGroupHeaderParams.d.ts +30 -0
- package/{modern/models/gridSelectionModel.js → models/params/gridColumnGroupHeaderParams.js} +0 -0
- package/models/params/gridEditCellParams.d.ts +4 -17
- package/models/params/gridEditCellParams.js +0 -4
- package/models/params/gridRowParams.d.ts +4 -4
- package/models/params/index.d.ts +1 -0
- package/models/params/index.js +1 -0
- package/models/props/DataGridProps.d.ts +8 -32
- package/modern/DataGrid/DataGrid.js +14 -34
- package/modern/DataGrid/useDataGridComponent.js +8 -12
- package/modern/DataGrid/useDataGridProps.js +3 -3
- package/modern/colDef/gridCheckboxSelectionColDef.js +1 -1
- package/modern/components/GridFooter.js +1 -1
- package/modern/components/GridRow.js +2 -2
- package/modern/components/base/GridBody.js +2 -2
- package/modern/components/cell/GridEditInputCell.js +3 -4
- package/modern/components/cell/GridEditSingleSelectCell.js +6 -34
- package/modern/components/columnHeaders/GridColumnGroupHeader.js +32 -5
- package/modern/components/columnSelection/GridHeaderCheckbox.js +3 -3
- package/modern/components/containers/GridRoot.js +4 -3
- package/modern/components/panel/GridColumnsPanel.js +10 -4
- package/modern/components/panel/filterPanel/GridFilterForm.js +29 -7
- package/modern/components/panel/filterPanel/GridFilterPanel.js +62 -17
- package/modern/hooks/features/columnGrouping/gridColumnGroupsSelector.js +14 -1
- package/modern/hooks/features/columnGrouping/gridColumnGroupsUtils.js +83 -0
- package/modern/hooks/features/columnGrouping/useGridColumnGrouping.js +50 -62
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +58 -98
- package/modern/hooks/features/density/densitySelector.js +1 -3
- package/modern/hooks/features/density/useGridDensity.js +9 -37
- package/modern/hooks/features/dimensions/useGridDimensions.js +3 -2
- package/modern/hooks/features/{editRows/gridEditRowsSelector.js → editing/gridEditingSelectors.js} +0 -0
- package/modern/hooks/features/editing/index.js +1 -0
- package/modern/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js} +21 -6
- package/modern/hooks/features/{editRows/useGridEditing.new.js → editing/useGridEditing.js} +3 -3
- package/modern/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js} +20 -6
- package/modern/hooks/features/export/useGridPrintExport.js +2 -2
- package/modern/hooks/features/focus/gridFocusStateSelector.js +6 -2
- package/modern/hooks/features/focus/useGridFocus.js +69 -11
- package/modern/hooks/features/index.js +2 -2
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +135 -1
- package/modern/hooks/features/rowSelection/gridRowSelectionSelector.js +9 -0
- package/modern/hooks/features/rowSelection/index.js +1 -0
- package/modern/hooks/features/{selection/useGridSelection.js → rowSelection/useGridRowSelection.js} +37 -37
- package/modern/hooks/features/{selection/useGridSelectionPreProcessors.js → rowSelection/useGridRowSelectionPreProcessors.js} +1 -1
- package/modern/hooks/features/rows/gridRowsUtils.js +5 -2
- package/modern/hooks/features/rows/useGridRows.js +23 -7
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +2 -2
- package/modern/index.js +1 -1
- package/modern/internals/index.js +3 -5
- package/modern/locales/trTR.js +17 -17
- package/modern/models/api/gridRowSelectionApi.js +1 -0
- package/modern/models/api/index.js +1 -1
- package/modern/models/gridRowSelectionModel.js +1 -0
- package/modern/models/index.js +1 -1
- package/modern/models/params/gridColumnGroupHeaderParams.js +1 -0
- package/modern/models/params/gridEditCellParams.js +0 -4
- package/modern/models/params/index.js +1 -0
- package/node/DataGrid/DataGrid.js +14 -34
- package/node/DataGrid/useDataGridComponent.js +9 -17
- package/node/DataGrid/useDataGridProps.js +3 -3
- package/node/colDef/gridCheckboxSelectionColDef.js +2 -2
- package/node/components/GridFooter.js +2 -2
- package/node/components/GridRow.js +2 -2
- package/node/components/base/GridBody.js +2 -2
- package/node/components/cell/GridEditInputCell.js +3 -9
- package/node/components/cell/GridEditSingleSelectCell.js +6 -38
- package/node/components/columnHeaders/GridColumnGroupHeader.js +32 -5
- package/node/components/columnSelection/GridHeaderCheckbox.js +3 -3
- package/node/components/containers/GridRoot.js +4 -2
- package/node/components/panel/GridColumnsPanel.js +10 -4
- package/node/components/panel/filterPanel/GridFilterForm.js +30 -7
- package/node/components/panel/filterPanel/GridFilterPanel.js +63 -19
- package/node/hooks/features/columnGrouping/gridColumnGroupsSelector.js +40 -3
- package/node/hooks/features/columnGrouping/gridColumnGroupsUtils.js +102 -0
- package/node/hooks/features/columnGrouping/useGridColumnGrouping.js +68 -71
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +57 -113
- package/node/hooks/features/density/densitySelector.js +2 -6
- package/node/hooks/features/density/useGridDensity.js +9 -48
- package/node/hooks/features/dimensions/useGridDimensions.js +3 -1
- package/node/hooks/features/{editRows/gridEditRowsSelector.js → editing/gridEditingSelectors.js} +0 -0
- package/node/hooks/features/{editRows → editing}/index.js +4 -4
- package/node/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js} +28 -13
- package/node/hooks/features/{editRows/useGridEditing.new.js → editing/useGridEditing.js} +4 -4
- package/node/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js} +28 -14
- package/node/hooks/features/export/useGridPrintExport.js +2 -2
- package/node/hooks/features/focus/gridFocusStateSelector.js +10 -4
- package/node/hooks/features/focus/useGridFocus.js +68 -10
- package/node/hooks/features/index.js +8 -8
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +138 -1
- package/node/hooks/features/{selection/gridSelectionSelector.js → rowSelection/gridRowSelectionSelector.js} +6 -6
- package/node/hooks/features/rowSelection/index.js +18 -0
- package/node/hooks/features/{selection/useGridSelection.js → rowSelection/useGridRowSelection.js} +43 -43
- package/node/hooks/features/{selection/useGridSelectionPreProcessors.js → rowSelection/useGridRowSelectionPreProcessors.js} +3 -3
- package/node/hooks/features/rows/gridRowsUtils.js +5 -2
- package/node/hooks/features/rows/useGridRows.js +23 -7
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/node/index.js +1 -1
- package/node/internals/index.js +23 -45
- package/node/locales/trTR.js +17 -17
- package/node/models/api/{gridSelectionApi.js → gridRowSelectionApi.js} +0 -0
- package/node/models/api/index.js +4 -4
- package/node/models/{gridSelectionModel.js → gridRowSelectionModel.js} +0 -0
- package/node/models/index.js +4 -4
- package/node/models/params/gridColumnGroupHeaderParams.js +5 -0
- package/node/models/params/gridEditCellParams.js +0 -3
- package/node/models/params/index.js +13 -0
- package/package.json +2 -2
- package/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.d.ts +0 -4
- package/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.js +0 -35
- package/hooks/features/editRows/index.d.ts +0 -1
- package/hooks/features/editRows/index.js +0 -1
- package/hooks/features/editRows/useGridCellEditing.old.d.ts +0 -4
- package/hooks/features/editRows/useGridCellEditing.old.js +0 -359
- package/hooks/features/editRows/useGridEditing.old.d.ts +0 -11
- package/hooks/features/editRows/useGridEditing.old.js +0 -167
- package/hooks/features/editRows/useGridRowEditing.old.d.ts +0 -4
- package/hooks/features/editRows/useGridRowEditing.old.js +0 -334
- package/hooks/features/selection/gridSelectionSelector.js +0 -9
- package/hooks/features/selection/index.d.ts +0 -1
- package/hooks/features/selection/index.js +0 -1
- package/hooks/features/selection/useGridSelection.d.ts +0 -12
- package/legacy/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.js +0 -35
- package/legacy/hooks/features/editRows/index.js +0 -1
- package/legacy/hooks/features/editRows/useGridCellEditing.old.js +0 -411
- package/legacy/hooks/features/editRows/useGridEditing.old.js +0 -184
- package/legacy/hooks/features/editRows/useGridRowEditing.old.js +0 -505
- package/legacy/hooks/features/selection/gridSelectionSelector.js +0 -19
- package/legacy/hooks/features/selection/index.js +0 -1
- package/models/gridSelectionModel.d.ts +0 -3
- package/modern/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.js +0 -29
- package/modern/hooks/features/editRows/index.js +0 -1
- package/modern/hooks/features/editRows/useGridCellEditing.old.js +0 -355
- package/modern/hooks/features/editRows/useGridEditing.old.js +0 -163
- package/modern/hooks/features/editRows/useGridRowEditing.old.js +0 -326
- package/modern/hooks/features/selection/gridSelectionSelector.js +0 -9
- package/modern/hooks/features/selection/index.js +0 -1
- package/node/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.js +0 -55
- package/node/hooks/features/editRows/useGridCellEditing.old.js +0 -380
- package/node/hooks/features/editRows/useGridEditing.old.js +0 -193
- package/node/hooks/features/editRows/useGridRowEditing.old.js +0 -358
- package/node/hooks/features/selection/index.js +0 -18
|
@@ -5,7 +5,7 @@ import { GridMainContainer } from '../containers/GridMainContainer';
|
|
|
5
5
|
import { GridAutoSizer } from '../GridAutoSizer';
|
|
6
6
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
7
7
|
import { useGridSelector } from '../../hooks/utils/useGridSelector';
|
|
8
|
-
import {
|
|
8
|
+
import { gridTotalHeaderHeightSelector } from '../../hooks/features/columnGrouping/gridColumnGroupsSelector';
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
|
|
@@ -17,7 +17,7 @@ function GridBody(props) {
|
|
|
17
17
|
} = props;
|
|
18
18
|
const apiRef = useGridApiContext();
|
|
19
19
|
const rootProps = useGridRootProps();
|
|
20
|
-
const totalHeaderHeight = useGridSelector(apiRef,
|
|
20
|
+
const totalHeaderHeight = useGridSelector(apiRef, gridTotalHeaderHeightSelector);
|
|
21
21
|
const [isVirtualizationDisabled, setIsVirtualizationDisabled] = React.useState(rootProps.disableVirtualization);
|
|
22
22
|
const disableVirtualization = React.useCallback(() => {
|
|
23
23
|
setIsVirtualizationDisabled(true);
|
|
@@ -10,7 +10,6 @@ import InputBase from '@mui/material/InputBase';
|
|
|
10
10
|
import { getDataGridUtilityClass } from '../../constants/gridClasses';
|
|
11
11
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
12
12
|
import { GridLoadIcon } from '../icons/index';
|
|
13
|
-
import { SUBMIT_FILTER_STROKE_TIME } from '../panel/filterPanel/GridFilterInputValue';
|
|
14
13
|
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
15
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
15
|
|
|
@@ -46,7 +45,7 @@ const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
46
45
|
field,
|
|
47
46
|
colDef,
|
|
48
47
|
hasFocus,
|
|
49
|
-
debounceMs =
|
|
48
|
+
debounceMs = 200,
|
|
50
49
|
isProcessingProps,
|
|
51
50
|
onValueChange
|
|
52
51
|
} = props,
|
|
@@ -69,7 +68,7 @@ const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
69
68
|
const column = apiRef.current.getColumn(field);
|
|
70
69
|
let parsedValue = newValue;
|
|
71
70
|
|
|
72
|
-
if (column.valueParser
|
|
71
|
+
if (column.valueParser) {
|
|
73
72
|
parsedValue = column.valueParser(newValue, apiRef.current.getCellParams(id, field));
|
|
74
73
|
}
|
|
75
74
|
|
|
@@ -81,7 +80,7 @@ const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
81
80
|
debounceMs,
|
|
82
81
|
unstable_skipValueParser: true
|
|
83
82
|
}, event);
|
|
84
|
-
}, [apiRef, debounceMs, field, id, onValueChange
|
|
83
|
+
}, [apiRef, debounceMs, field, id, onValueChange]);
|
|
85
84
|
const meta = apiRef.current.unstable_getEditCellMeta ? apiRef.current.unstable_getEditCellMeta(id, field) : {};
|
|
86
85
|
React.useEffect(() => {
|
|
87
86
|
if (meta.changeReason !== 'debouncedSetEditCellValue') {
|
|
@@ -90,35 +90,11 @@ function GridEditSingleSelectCell(props) {
|
|
|
90
90
|
await onValueChange(event, formattedTargetValue);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
await apiRef.current.setEditCellValue({
|
|
94
94
|
id,
|
|
95
95
|
field,
|
|
96
96
|
value: formattedTargetValue
|
|
97
97
|
}, event);
|
|
98
|
-
|
|
99
|
-
if (rootProps.experimentalFeatures?.newEditingApi) {
|
|
100
|
-
return;
|
|
101
|
-
} // We use isValid === false because the default return is undefined which evaluates to true with !isValid
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (rootProps.editMode === GridEditModes.Row || isValid === false) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const canCommit = await Promise.resolve(apiRef.current.commitCellChange({
|
|
109
|
-
id,
|
|
110
|
-
field
|
|
111
|
-
}, event));
|
|
112
|
-
|
|
113
|
-
if (canCommit) {
|
|
114
|
-
apiRef.current.setCellMode(id, field, 'view');
|
|
115
|
-
|
|
116
|
-
if (event.key) {
|
|
117
|
-
// TODO v6: remove once we stop ignoring events fired from portals
|
|
118
|
-
const params = apiRef.current.getCellParams(id, field);
|
|
119
|
-
apiRef.current.publishEvent('cellNavigationKeyDown', params, event);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
98
|
};
|
|
123
99
|
|
|
124
100
|
const handleClose = (event, reason) => {
|
|
@@ -128,15 +104,11 @@ function GridEditSingleSelectCell(props) {
|
|
|
128
104
|
}
|
|
129
105
|
|
|
130
106
|
if (reason === 'backdropClick' || isEscapeKey(event.key)) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
});
|
|
137
|
-
} else {
|
|
138
|
-
apiRef.current.setCellMode(id, field, 'view');
|
|
139
|
-
}
|
|
107
|
+
apiRef.current.stopCellEditMode({
|
|
108
|
+
id,
|
|
109
|
+
field,
|
|
110
|
+
ignoreModifications: true
|
|
111
|
+
});
|
|
140
112
|
}
|
|
141
113
|
};
|
|
142
114
|
|
|
@@ -37,10 +37,13 @@ function GridColumnGroupHeader(props) {
|
|
|
37
37
|
fields,
|
|
38
38
|
height,
|
|
39
39
|
colIndex,
|
|
40
|
+
hasFocus,
|
|
41
|
+
tabIndex,
|
|
40
42
|
isLastColumn,
|
|
41
43
|
extendRowFullWidth
|
|
42
44
|
} = props;
|
|
43
45
|
const rootProps = useGridRootProps();
|
|
46
|
+
const headerCellRef = React.useRef(null);
|
|
44
47
|
const apiRef = useGridApiContext();
|
|
45
48
|
const columnGroupsLookup = useGridSelector(apiRef, gridColumnGroupsLookupSelector);
|
|
46
49
|
const {
|
|
@@ -58,7 +61,7 @@ function GridColumnGroupHeader(props) {
|
|
|
58
61
|
} = group;
|
|
59
62
|
let headerComponent;
|
|
60
63
|
const render = groupId && columnGroupsLookup[groupId]?.renderHeaderGroup;
|
|
61
|
-
const renderParams = {
|
|
64
|
+
const renderParams = React.useMemo(() => ({
|
|
62
65
|
groupId,
|
|
63
66
|
headerName,
|
|
64
67
|
description,
|
|
@@ -67,7 +70,7 @@ function GridColumnGroupHeader(props) {
|
|
|
67
70
|
fields,
|
|
68
71
|
colIndex,
|
|
69
72
|
isLastColumn
|
|
70
|
-
};
|
|
73
|
+
}), [groupId, headerName, description, depth, maxDepth, fields, colIndex, isLastColumn]);
|
|
71
74
|
|
|
72
75
|
if (groupId && render) {
|
|
73
76
|
headerComponent = render(renderParams);
|
|
@@ -90,8 +93,32 @@ function GridColumnGroupHeader(props) {
|
|
|
90
93
|
const id = useId();
|
|
91
94
|
const elementId = groupId === null ? `empty-group-cell-${id}` : groupId;
|
|
92
95
|
const classes = useUtilityClasses(ownerState);
|
|
96
|
+
React.useLayoutEffect(() => {
|
|
97
|
+
if (hasFocus) {
|
|
98
|
+
const focusableElement = headerCellRef.current.querySelector('[tabindex="0"]');
|
|
99
|
+
const elementToFocus = focusableElement || headerCellRef.current;
|
|
100
|
+
elementToFocus?.focus();
|
|
101
|
+
}
|
|
102
|
+
}, [apiRef, hasFocus]);
|
|
103
|
+
const publish = React.useCallback(eventName => event => {
|
|
104
|
+
// Ignore portal
|
|
105
|
+
// See https://github.com/mui/mui-x/issues/1721
|
|
106
|
+
if (!event.currentTarget.contains(event.target)) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
apiRef.current.publishEvent(eventName, renderParams, event);
|
|
111
|
+
}, // For now this is stupid, because renderParams change all the time.
|
|
112
|
+
// Need to move it's computation in the api, such that for a given depth+columnField, I can get the group parameters
|
|
113
|
+
[apiRef, renderParams]);
|
|
114
|
+
const mouseEventsHandlers = React.useMemo(() => ({
|
|
115
|
+
onKeyDown: publish('columnGroupHeaderKeyDown'),
|
|
116
|
+
onFocus: publish('columnGroupHeaderFocus'),
|
|
117
|
+
onBlur: publish('columnGroupHeaderBlur')
|
|
118
|
+
}), [publish]);
|
|
93
119
|
const headerClassName = typeof group.headerClassName === 'function' ? group.headerClassName(renderParams) : group.headerClassName;
|
|
94
|
-
return /*#__PURE__*/_jsx(GridGenericColumnHeaderItem, {
|
|
120
|
+
return /*#__PURE__*/_jsx(GridGenericColumnHeaderItem, _extends({
|
|
121
|
+
ref: headerCellRef,
|
|
95
122
|
classes: classes,
|
|
96
123
|
columnMenuOpen: false,
|
|
97
124
|
colIndex: colIndex,
|
|
@@ -99,7 +126,7 @@ function GridColumnGroupHeader(props) {
|
|
|
99
126
|
isResizing: false,
|
|
100
127
|
sortDirection: null,
|
|
101
128
|
hasFocus: false,
|
|
102
|
-
tabIndex:
|
|
129
|
+
tabIndex: tabIndex,
|
|
103
130
|
isDraggable: false,
|
|
104
131
|
headerComponent: headerComponent,
|
|
105
132
|
headerClassName: headerClassName,
|
|
@@ -114,7 +141,7 @@ function GridColumnGroupHeader(props) {
|
|
|
114
141
|
,
|
|
115
142
|
"data-fields": `|-${fields.join('-|-')}-|`,
|
|
116
143
|
disableHeaderSeparator: true
|
|
117
|
-
});
|
|
144
|
+
}, mouseEventsHandlers));
|
|
118
145
|
}
|
|
119
146
|
|
|
120
147
|
export { GridColumnGroupHeader };
|
|
@@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
7
7
|
import { useGridSelector } from '../../hooks/utils/useGridSelector';
|
|
8
8
|
import { gridTabIndexColumnHeaderSelector } from '../../hooks/features/focus/gridFocusStateSelector';
|
|
9
|
-
import {
|
|
9
|
+
import { gridRowSelectionStateSelector } from '../../hooks/features/rowSelection/gridRowSelectionSelector';
|
|
10
10
|
import { isNavigationKey } from '../../utils/keyboardUtils';
|
|
11
11
|
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
12
12
|
import { getDataGridUtilityClass } from '../../constants/gridClasses';
|
|
@@ -36,7 +36,7 @@ const GridHeaderCheckbox = /*#__PURE__*/React.forwardRef(function GridHeaderChec
|
|
|
36
36
|
};
|
|
37
37
|
const classes = useUtilityClasses(ownerState);
|
|
38
38
|
const tabIndexState = useGridSelector(apiRef, gridTabIndexColumnHeaderSelector);
|
|
39
|
-
const selection = useGridSelector(apiRef,
|
|
39
|
+
const selection = useGridSelector(apiRef, gridRowSelectionStateSelector);
|
|
40
40
|
const visibleRowIds = useGridSelector(apiRef, gridVisibleSortedRowIdsSelector);
|
|
41
41
|
const paginatedVisibleRowIds = useGridSelector(apiRef, gridPaginatedVisibleSortedGridRowIdsSelector);
|
|
42
42
|
const filteredSelection = React.useMemo(() => {
|
|
@@ -100,7 +100,7 @@ const GridHeaderCheckbox = /*#__PURE__*/React.forwardRef(function GridHeaderChec
|
|
|
100
100
|
forceUpdate(p => !p);
|
|
101
101
|
}, []);
|
|
102
102
|
React.useEffect(() => {
|
|
103
|
-
return apiRef.current.subscribeEvent('
|
|
103
|
+
return apiRef.current.subscribeEvent('rowSelectionChange', handleSelectionChange);
|
|
104
104
|
}, [apiRef, handleSelectionChange]);
|
|
105
105
|
const label = apiRef.current.getLocaleText(isChecked ? 'checkboxSelectionUnselectAllRows' : 'checkboxSelectionSelectAllRows');
|
|
106
106
|
return /*#__PURE__*/_jsx(rootProps.components.BaseCheckbox, _extends({
|
|
@@ -12,7 +12,8 @@ import { useGridSelector } from '../../hooks/utils/useGridSelector';
|
|
|
12
12
|
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
13
13
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
14
14
|
import { getDataGridUtilityClass } from '../../constants/gridClasses';
|
|
15
|
-
import {
|
|
15
|
+
import { gridDensityValueSelector } from '../../hooks/features/density/densitySelector';
|
|
16
|
+
import { gridColumnGroupsHeaderMaxDepthSelector } from '../../hooks/features/columnGrouping/gridColumnGroupsSelector';
|
|
16
17
|
import { gridPinnedRowsCountSelector, gridRowCountSelector } from '../../hooks/features/rows/gridRowsSelector';
|
|
17
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
19
|
|
|
@@ -41,7 +42,7 @@ const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
|
|
|
41
42
|
const visibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
|
|
42
43
|
const totalRowCount = useGridSelector(apiRef, gridRowCountSelector);
|
|
43
44
|
const densityValue = useGridSelector(apiRef, gridDensityValueSelector);
|
|
44
|
-
const headerGroupingMaxDepth = useGridSelector(apiRef,
|
|
45
|
+
const headerGroupingMaxDepth = useGridSelector(apiRef, gridColumnGroupsHeaderMaxDepthSelector);
|
|
45
46
|
const rootContainerRef = React.useRef(null);
|
|
46
47
|
const handleRef = useForkRef(rootContainerRef, ref);
|
|
47
48
|
const pinnedRowsCount = useGridSelector(apiRef, gridPinnedRowsCountSelector);
|
|
@@ -73,7 +74,7 @@ const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
|
|
|
73
74
|
role: "grid",
|
|
74
75
|
"aria-colcount": visibleColumns.length,
|
|
75
76
|
"aria-rowcount": headerGroupingMaxDepth + 1 + pinnedRowsCount + totalRowCount,
|
|
76
|
-
"aria-multiselectable": !rootProps.
|
|
77
|
+
"aria-multiselectable": !rootProps.disableMultipleRowSelection,
|
|
77
78
|
"aria-label": rootProps['aria-label'],
|
|
78
79
|
"aria-labelledby": rootProps['aria-labelledby']
|
|
79
80
|
}, other, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["sort"];
|
|
3
|
+
const _excluded = ["sort", "searchPredicate"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
@@ -59,6 +59,10 @@ const GridIconButtonRoot = styled(IconButton)({
|
|
|
59
59
|
});
|
|
60
60
|
const collator = new Intl.Collator();
|
|
61
61
|
|
|
62
|
+
const defaultSearchPredicate = (column, searchValue) => {
|
|
63
|
+
return (column.headerName || column.field).toLowerCase().indexOf(searchValue) > -1;
|
|
64
|
+
};
|
|
65
|
+
|
|
62
66
|
function GridColumnsPanel(props) {
|
|
63
67
|
const apiRef = useGridApiContext();
|
|
64
68
|
const searchInputRef = React.useRef(null);
|
|
@@ -72,7 +76,8 @@ function GridColumnsPanel(props) {
|
|
|
72
76
|
const classes = useUtilityClasses(ownerState);
|
|
73
77
|
|
|
74
78
|
const {
|
|
75
|
-
sort
|
|
79
|
+
sort,
|
|
80
|
+
searchPredicate = defaultSearchPredicate
|
|
76
81
|
} = props,
|
|
77
82
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
78
83
|
|
|
@@ -112,8 +117,8 @@ function GridColumnsPanel(props) {
|
|
|
112
117
|
}
|
|
113
118
|
|
|
114
119
|
const searchValueToCheck = searchValue.toLowerCase();
|
|
115
|
-
return sortedColumns.filter(column => (column
|
|
116
|
-
}, [sortedColumns, searchValue]);
|
|
120
|
+
return sortedColumns.filter(column => searchPredicate(column, searchValueToCheck));
|
|
121
|
+
}, [sortedColumns, searchValue, searchPredicate]);
|
|
117
122
|
React.useEffect(() => {
|
|
118
123
|
searchInputRef.current.focus();
|
|
119
124
|
}, []);
|
|
@@ -171,6 +176,7 @@ process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
|
|
|
171
176
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
172
177
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
173
178
|
// ----------------------------------------------------------------------
|
|
179
|
+
searchPredicate: PropTypes.func,
|
|
174
180
|
sort: PropTypes.oneOf(['asc', 'desc'])
|
|
175
181
|
} : void 0;
|
|
176
182
|
export { GridColumnsPanel };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["item", "hasMultipleFilters", "deleteFilter", "applyFilterChanges", "multiFilterOperator", "showMultiFilterOperators", "disableMultiFilterOperator", "applyMultiFilterOperatorChanges", "focusElementRef", "linkOperators", "columnsSort", "deleteIconProps", "linkOperatorInputProps", "operatorInputProps", "columnInputProps", "valueInputProps", "children"],
|
|
3
|
+
const _excluded = ["item", "hasMultipleFilters", "deleteFilter", "applyFilterChanges", "multiFilterOperator", "showMultiFilterOperators", "disableMultiFilterOperator", "applyMultiFilterOperatorChanges", "focusElementRef", "linkOperators", "columnsSort", "filterColumns", "deleteIconProps", "linkOperatorInputProps", "operatorInputProps", "columnInputProps", "valueInputProps", "children"],
|
|
4
4
|
_excluded2 = ["InputComponentProps"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
@@ -13,6 +13,7 @@ import { capitalize, unstable_useId as useId } from '@mui/material/utils';
|
|
|
13
13
|
import { styled } from '@mui/material/styles';
|
|
14
14
|
import clsx from 'clsx';
|
|
15
15
|
import { gridFilterableColumnDefinitionsSelector } from '../../../hooks/features/columns/gridColumnsSelector';
|
|
16
|
+
import { gridFilterModelSelector } from '../../../hooks/features/filter/gridFilterSelector';
|
|
16
17
|
import { useGridSelector } from '../../../hooks/utils/useGridSelector';
|
|
17
18
|
import { GridLinkOperator } from '../../../models/gridFilterItem';
|
|
18
19
|
import { useGridApiContext } from '../../../hooks/utils/useGridApiContext';
|
|
@@ -118,6 +119,7 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
118
119
|
focusElementRef,
|
|
119
120
|
linkOperators = [GridLinkOperator.And, GridLinkOperator.Or],
|
|
120
121
|
columnsSort,
|
|
122
|
+
filterColumns,
|
|
121
123
|
deleteIconProps = {},
|
|
122
124
|
linkOperatorInputProps = {},
|
|
123
125
|
operatorInputProps = {},
|
|
@@ -128,6 +130,7 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
128
130
|
|
|
129
131
|
const apiRef = useGridApiContext();
|
|
130
132
|
const filterableColumns = useGridSelector(apiRef, gridFilterableColumnDefinitionsSelector);
|
|
133
|
+
const filterModel = useGridSelector(apiRef, gridFilterModelSelector);
|
|
131
134
|
const columnSelectId = useId();
|
|
132
135
|
const columnSelectLabelId = useId();
|
|
133
136
|
const operatorSelectId = useId();
|
|
@@ -150,18 +153,30 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
150
153
|
} = valueInputProps,
|
|
151
154
|
valueInputPropsOther = _objectWithoutPropertiesLoose(valueInputProps, _excluded2);
|
|
152
155
|
|
|
153
|
-
const
|
|
156
|
+
const filteredColumns = React.useMemo(() => {
|
|
157
|
+
if (filterColumns === undefined || typeof filterColumns !== 'function') {
|
|
158
|
+
return filterableColumns;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const filteredFields = filterColumns({
|
|
162
|
+
field: item.columnField,
|
|
163
|
+
columns: filterableColumns,
|
|
164
|
+
currentFilters: filterModel?.items || []
|
|
165
|
+
});
|
|
166
|
+
return filterableColumns.filter(column => filteredFields.includes(column.field));
|
|
167
|
+
}, [filterColumns, filterModel?.items, filterableColumns, item.columnField]);
|
|
168
|
+
const sortedFilteredColumns = React.useMemo(() => {
|
|
154
169
|
switch (columnsSort) {
|
|
155
170
|
case 'asc':
|
|
156
|
-
return
|
|
171
|
+
return filteredColumns.sort((a, b) => collator.compare(getColumnLabel(a), getColumnLabel(b)));
|
|
157
172
|
|
|
158
173
|
case 'desc':
|
|
159
|
-
return
|
|
174
|
+
return filteredColumns.sort((a, b) => -collator.compare(getColumnLabel(a), getColumnLabel(b)));
|
|
160
175
|
|
|
161
176
|
default:
|
|
162
|
-
return
|
|
177
|
+
return filteredColumns;
|
|
163
178
|
}
|
|
164
|
-
}, [
|
|
179
|
+
}, [filteredColumns, columnsSort]);
|
|
165
180
|
const currentColumn = item.columnField ? apiRef.current.getColumn(item.columnField) : null;
|
|
166
181
|
const currentOperator = React.useMemo(() => {
|
|
167
182
|
if (!item.operatorValue || !currentColumn) {
|
|
@@ -286,7 +301,7 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
286
301
|
onChange: changeColumn,
|
|
287
302
|
native: isBaseSelectNative
|
|
288
303
|
}, rootProps.componentsProps?.baseSelect, {
|
|
289
|
-
children:
|
|
304
|
+
children: sortedFilteredColumns.map(col => /*#__PURE__*/_jsx(OptionComponent, {
|
|
290
305
|
value: col.field,
|
|
291
306
|
children: getColumnLabel(col)
|
|
292
307
|
}, col.field))
|
|
@@ -380,6 +395,13 @@ process.env.NODE_ENV !== "production" ? GridFilterForm.propTypes = {
|
|
|
380
395
|
*/
|
|
381
396
|
disableMultiFilterOperator: PropTypes.bool,
|
|
382
397
|
|
|
398
|
+
/**
|
|
399
|
+
* Allows to filter the columns displayed in the filter form.
|
|
400
|
+
* @param {FilterColumnsArgs} args The columns of the grid and name of field.
|
|
401
|
+
* @returns {GridColDef['field'][]} The filtered fields array.
|
|
402
|
+
*/
|
|
403
|
+
filterColumns: PropTypes.func,
|
|
404
|
+
|
|
383
405
|
/**
|
|
384
406
|
* A ref allowing to set imperative focus.
|
|
385
407
|
* It can be passed to the el
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["linkOperators", "columnsSort", "filterFormProps", "children"];
|
|
3
|
+
const _excluded = ["linkOperators", "columnsSort", "filterFormProps", "getColumnForNewFilter", "children"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { GridLinkOperator } from '../../../models/gridFilterItem';
|
|
@@ -16,6 +16,13 @@ import { gridFilterModelSelector } from '../../../hooks/features/filter/gridFilt
|
|
|
16
16
|
import { gridFilterableColumnDefinitionsSelector } from '../../../hooks/features/columns/gridColumnsSelector';
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
18
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
+
|
|
20
|
+
const getGridFilter = col => ({
|
|
21
|
+
columnField: col.field,
|
|
22
|
+
operatorValue: col.filterOperators[0].value,
|
|
23
|
+
id: Math.round(Math.random() * 1e5)
|
|
24
|
+
});
|
|
25
|
+
|
|
19
26
|
const GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(props, ref) {
|
|
20
27
|
const apiRef = useGridApiContext();
|
|
21
28
|
const rootProps = useGridRootProps();
|
|
@@ -26,7 +33,8 @@ const GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(p
|
|
|
26
33
|
const {
|
|
27
34
|
linkOperators = [GridLinkOperator.And, GridLinkOperator.Or],
|
|
28
35
|
columnsSort,
|
|
29
|
-
filterFormProps
|
|
36
|
+
filterFormProps,
|
|
37
|
+
getColumnForNewFilter
|
|
30
38
|
} = props,
|
|
31
39
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
32
40
|
|
|
@@ -36,37 +44,67 @@ const GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(p
|
|
|
36
44
|
const applyFilterLinkOperator = React.useCallback(operator => {
|
|
37
45
|
apiRef.current.setFilterLinkOperator(operator);
|
|
38
46
|
}, [apiRef]);
|
|
39
|
-
const
|
|
40
|
-
|
|
47
|
+
const getDefaultFilter = React.useCallback(() => {
|
|
48
|
+
let nextColumnWithOperator;
|
|
49
|
+
|
|
50
|
+
if (getColumnForNewFilter && typeof getColumnForNewFilter === 'function') {
|
|
51
|
+
// To allow override the column for default (first) filter
|
|
52
|
+
const nextColumnFieldName = getColumnForNewFilter({
|
|
53
|
+
currentFilters: filterModel?.items || [],
|
|
54
|
+
columns: filterableColumns
|
|
55
|
+
});
|
|
56
|
+
nextColumnWithOperator = filterableColumns.find(({
|
|
57
|
+
field
|
|
58
|
+
}) => field === nextColumnFieldName);
|
|
59
|
+
} else {
|
|
60
|
+
nextColumnWithOperator = filterableColumns.find(colDef => colDef.filterOperators?.length);
|
|
61
|
+
}
|
|
41
62
|
|
|
42
|
-
if (!
|
|
63
|
+
if (!nextColumnWithOperator) {
|
|
43
64
|
return null;
|
|
44
65
|
}
|
|
45
66
|
|
|
46
|
-
return
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
67
|
+
return getGridFilter(nextColumnWithOperator);
|
|
68
|
+
}, [filterModel?.items, filterableColumns, getColumnForNewFilter]);
|
|
69
|
+
const getNewFilter = React.useCallback(() => {
|
|
70
|
+
if (getColumnForNewFilter === undefined || typeof getColumnForNewFilter !== 'function') {
|
|
71
|
+
return getDefaultFilter();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const currentFilters = filterModel.items.length ? filterModel.items : [getDefaultFilter()].filter(Boolean); // If no items are there in filterModel, we have to pass defaultFilter
|
|
75
|
+
|
|
76
|
+
const nextColumnFieldName = getColumnForNewFilter({
|
|
77
|
+
currentFilters: currentFilters,
|
|
78
|
+
columns: filterableColumns
|
|
79
|
+
});
|
|
80
|
+
const nextColumnWithOperator = filterableColumns.find(({
|
|
81
|
+
field
|
|
82
|
+
}) => field === nextColumnFieldName);
|
|
83
|
+
|
|
84
|
+
if (!nextColumnWithOperator) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return getGridFilter(nextColumnWithOperator);
|
|
89
|
+
}, [filterModel.items, filterableColumns, getColumnForNewFilter, getDefaultFilter]);
|
|
52
90
|
const items = React.useMemo(() => {
|
|
53
91
|
if (filterModel.items.length) {
|
|
54
92
|
return filterModel.items;
|
|
55
93
|
}
|
|
56
94
|
|
|
57
|
-
const
|
|
58
|
-
return
|
|
59
|
-
}, [filterModel.items,
|
|
95
|
+
const defaultFilter = getDefaultFilter();
|
|
96
|
+
return defaultFilter ? [defaultFilter] : [];
|
|
97
|
+
}, [filterModel.items, getDefaultFilter]);
|
|
60
98
|
const hasMultipleFilters = items.length > 1;
|
|
61
99
|
|
|
62
100
|
const addNewFilter = () => {
|
|
63
|
-
const
|
|
101
|
+
const newFilter = getNewFilter();
|
|
64
102
|
|
|
65
|
-
if (!
|
|
103
|
+
if (!newFilter) {
|
|
66
104
|
return;
|
|
67
105
|
}
|
|
68
106
|
|
|
69
|
-
apiRef.current.upsertFilterItems([...items,
|
|
107
|
+
apiRef.current.upsertFilterItems([...items, newFilter]);
|
|
70
108
|
};
|
|
71
109
|
|
|
72
110
|
const deleteFilter = React.useCallback(item => {
|
|
@@ -143,6 +181,13 @@ process.env.NODE_ENV !== "production" ? GridFilterPanel.propTypes = {
|
|
|
143
181
|
valueInputProps: PropTypes.any
|
|
144
182
|
}),
|
|
145
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Function that returns the next filter item to be picked as default filter.
|
|
186
|
+
* @param {GetColumnForNewFilterArgs} args Currently configured filters and columns.
|
|
187
|
+
* @returns {GridColDef['field']} The field to be used for the next filter.
|
|
188
|
+
*/
|
|
189
|
+
getColumnForNewFilter: PropTypes.func,
|
|
190
|
+
|
|
146
191
|
/**
|
|
147
192
|
* Sets the available logic operators.
|
|
148
193
|
* @default [GridLinkOperator.And, GridLinkOperator.Or]
|
|
@@ -5,4 +5,17 @@ import { createSelector } from '../../../utils/createSelector';
|
|
|
5
5
|
* @ignore - do not document.
|
|
6
6
|
*/
|
|
7
7
|
export const gridColumnGroupingSelector = state => state.columnGrouping;
|
|
8
|
-
export const
|
|
8
|
+
export const gridColumnGroupsUnwrappedModelSelector = createSelector(gridColumnGroupingSelector, columnGrouping => columnGrouping?.unwrappedGroupingModel ?? {});
|
|
9
|
+
export const gridColumnGroupsLookupSelector = createSelector(gridColumnGroupingSelector, columnGrouping => columnGrouping?.lookup ?? {});
|
|
10
|
+
export const gridColumnGroupsHeaderStructureSelector = createSelector(gridColumnGroupingSelector, columnGrouping => columnGrouping?.headerStructure ?? []);
|
|
11
|
+
export const gridColumnGroupsHeaderMaxDepthSelector = createSelector(gridColumnGroupingSelector, columnGrouping => columnGrouping?.maxDepth ?? 0);
|
|
12
|
+
|
|
13
|
+
const getGroupingHeader = state => ({
|
|
14
|
+
columnGrouping: state.columnGrouping,
|
|
15
|
+
density: state.density
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const gridTotalHeaderHeightSelector = createSelector(getGroupingHeader, ({
|
|
19
|
+
columnGrouping,
|
|
20
|
+
density
|
|
21
|
+
}) => density.headerHeight * ((columnGrouping?.maxDepth ?? 0) + 1));
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { isLeaf } from '../../../models/gridColumnGrouping';
|
|
2
|
+
import { isDeepEqual } from '../../../utils/utils';
|
|
3
|
+
|
|
4
|
+
// This is the recurrence function that help writing `unwrapGroupingColumnModel()`
|
|
5
|
+
const recurrentUnwrapGroupingColumnModel = (columnGroupNode, parents, unwrappedGroupingModelToComplet) => {
|
|
6
|
+
if (isLeaf(columnGroupNode)) {
|
|
7
|
+
if (unwrappedGroupingModelToComplet[columnGroupNode.field] !== undefined) {
|
|
8
|
+
throw new Error([`MUI: columnGroupingModel contains duplicated field`, `column field ${columnGroupNode.field} occurrs two times in the grouping model:`, `- ${unwrappedGroupingModelToComplet[columnGroupNode.field].join(' > ')}`, `- ${parents.join(' > ')}`].join('\n'));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
unwrappedGroupingModelToComplet[columnGroupNode.field] = parents;
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const {
|
|
16
|
+
groupId,
|
|
17
|
+
children
|
|
18
|
+
} = columnGroupNode;
|
|
19
|
+
children.forEach(child => {
|
|
20
|
+
recurrentUnwrapGroupingColumnModel(child, [...parents, groupId], unwrappedGroupingModelToComplet);
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* This is a function that provide for each column the array of its parents.
|
|
25
|
+
* Parents are ordered from the root to the leaf.
|
|
26
|
+
* @param columnGroupingModel The model such as provided in DataGrid props
|
|
27
|
+
* @returns An object `{[field]: groupIds}` where `groupIds` is the parents of the column `field`
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export const unwrapGroupingColumnModel = columnGroupingModel => {
|
|
32
|
+
if (!columnGroupingModel) {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const unwrappedSubTree = {};
|
|
37
|
+
columnGroupingModel.forEach(columnGroupNode => {
|
|
38
|
+
recurrentUnwrapGroupingColumnModel(columnGroupNode, [], unwrappedSubTree);
|
|
39
|
+
});
|
|
40
|
+
return unwrappedSubTree;
|
|
41
|
+
};
|
|
42
|
+
export const getColumnGroupsHeaderStructure = (orderedColumns, unwrappedGroupingModel) => {
|
|
43
|
+
const getParents = field => unwrappedGroupingModel[field] ?? [];
|
|
44
|
+
|
|
45
|
+
const groupingHeaderStructure = [];
|
|
46
|
+
const maxDepth = Math.max(...orderedColumns.map(field => getParents(field).length));
|
|
47
|
+
|
|
48
|
+
const haveSameParents = (field1, field2, depth) => isDeepEqual(getParents(field1).slice(0, depth + 1), getParents(field2).slice(0, depth + 1));
|
|
49
|
+
|
|
50
|
+
for (let depth = 0; depth < maxDepth; depth += 1) {
|
|
51
|
+
const depthStructure = orderedColumns.reduce((structure, newField) => {
|
|
52
|
+
const groupId = getParents(newField)[depth] ?? null;
|
|
53
|
+
|
|
54
|
+
if (structure.length === 0) {
|
|
55
|
+
return [{
|
|
56
|
+
columnFields: [newField],
|
|
57
|
+
groupId
|
|
58
|
+
}];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const lastGroup = structure[structure.length - 1];
|
|
62
|
+
const prevField = lastGroup.columnFields[lastGroup.columnFields.length - 1];
|
|
63
|
+
const prevGroupId = lastGroup.groupId;
|
|
64
|
+
|
|
65
|
+
if (prevGroupId !== groupId || !haveSameParents(prevField, newField, depth)) {
|
|
66
|
+
// It's a new group
|
|
67
|
+
return [...structure, {
|
|
68
|
+
columnFields: [newField],
|
|
69
|
+
groupId
|
|
70
|
+
}];
|
|
71
|
+
} // It extends the previous group
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
return [...structure.slice(0, structure.length - 1), {
|
|
75
|
+
columnFields: [...lastGroup.columnFields, newField],
|
|
76
|
+
groupId
|
|
77
|
+
}];
|
|
78
|
+
}, []);
|
|
79
|
+
groupingHeaderStructure.push(depthStructure);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return groupingHeaderStructure;
|
|
83
|
+
};
|