@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
|
@@ -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';
|
|
@@ -120,6 +121,7 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
120
121
|
focusElementRef,
|
|
121
122
|
linkOperators = [GridLinkOperator.And, GridLinkOperator.Or],
|
|
122
123
|
columnsSort,
|
|
124
|
+
filterColumns,
|
|
123
125
|
deleteIconProps = {},
|
|
124
126
|
linkOperatorInputProps = {},
|
|
125
127
|
operatorInputProps = {},
|
|
@@ -130,6 +132,7 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
130
132
|
|
|
131
133
|
const apiRef = useGridApiContext();
|
|
132
134
|
const filterableColumns = useGridSelector(apiRef, gridFilterableColumnDefinitionsSelector);
|
|
135
|
+
const filterModel = useGridSelector(apiRef, gridFilterModelSelector);
|
|
133
136
|
const columnSelectId = useId();
|
|
134
137
|
const columnSelectLabelId = useId();
|
|
135
138
|
const operatorSelectId = useId();
|
|
@@ -152,18 +155,30 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
152
155
|
} = valueInputProps,
|
|
153
156
|
valueInputPropsOther = _objectWithoutPropertiesLoose(valueInputProps, _excluded2);
|
|
154
157
|
|
|
155
|
-
const
|
|
158
|
+
const filteredColumns = React.useMemo(() => {
|
|
159
|
+
if (filterColumns === undefined || typeof filterColumns !== 'function') {
|
|
160
|
+
return filterableColumns;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const filteredFields = filterColumns({
|
|
164
|
+
field: item.columnField,
|
|
165
|
+
columns: filterableColumns,
|
|
166
|
+
currentFilters: (filterModel == null ? void 0 : filterModel.items) || []
|
|
167
|
+
});
|
|
168
|
+
return filterableColumns.filter(column => filteredFields.includes(column.field));
|
|
169
|
+
}, [filterColumns, filterModel == null ? void 0 : filterModel.items, filterableColumns, item.columnField]);
|
|
170
|
+
const sortedFilteredColumns = React.useMemo(() => {
|
|
156
171
|
switch (columnsSort) {
|
|
157
172
|
case 'asc':
|
|
158
|
-
return
|
|
173
|
+
return filteredColumns.sort((a, b) => collator.compare(getColumnLabel(a), getColumnLabel(b)));
|
|
159
174
|
|
|
160
175
|
case 'desc':
|
|
161
|
-
return
|
|
176
|
+
return filteredColumns.sort((a, b) => -collator.compare(getColumnLabel(a), getColumnLabel(b)));
|
|
162
177
|
|
|
163
178
|
default:
|
|
164
|
-
return
|
|
179
|
+
return filteredColumns;
|
|
165
180
|
}
|
|
166
|
-
}, [
|
|
181
|
+
}, [filteredColumns, columnsSort]);
|
|
167
182
|
const currentColumn = item.columnField ? apiRef.current.getColumn(item.columnField) : null;
|
|
168
183
|
const currentOperator = React.useMemo(() => {
|
|
169
184
|
var _currentColumn$filter;
|
|
@@ -292,7 +307,7 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
292
307
|
onChange: changeColumn,
|
|
293
308
|
native: isBaseSelectNative
|
|
294
309
|
}, (_rootProps$components4 = rootProps.componentsProps) == null ? void 0 : _rootProps$components4.baseSelect, {
|
|
295
|
-
children:
|
|
310
|
+
children: sortedFilteredColumns.map(col => /*#__PURE__*/_jsx(OptionComponent, {
|
|
296
311
|
value: col.field,
|
|
297
312
|
children: getColumnLabel(col)
|
|
298
313
|
}, col.field))
|
|
@@ -386,6 +401,13 @@ process.env.NODE_ENV !== "production" ? GridFilterForm.propTypes = {
|
|
|
386
401
|
*/
|
|
387
402
|
disableMultiFilterOperator: PropTypes.bool,
|
|
388
403
|
|
|
404
|
+
/**
|
|
405
|
+
* Allows to filter the columns displayed in the filter form.
|
|
406
|
+
* @param {FilterColumnsArgs} args The columns of the grid and name of field.
|
|
407
|
+
* @returns {GridColDef['field'][]} The filtered fields array.
|
|
408
|
+
*/
|
|
409
|
+
filterColumns: PropTypes.func,
|
|
410
|
+
|
|
389
411
|
/**
|
|
390
412
|
* A ref allowing to set imperative focus.
|
|
391
413
|
* It can be passed to the el
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { SxProps, Theme } from '@mui/material/styles';
|
|
3
|
+
import { GridFilterItem } from '../../../models/gridFilterItem';
|
|
3
4
|
import { GridFilterFormProps } from './GridFilterForm';
|
|
5
|
+
import { GridColDef, GridStateColDef } from '../../../models/colDef/gridColDef';
|
|
6
|
+
export interface GetColumnForNewFilterArgs {
|
|
7
|
+
currentFilters: GridFilterItem[];
|
|
8
|
+
columns: GridStateColDef[];
|
|
9
|
+
}
|
|
4
10
|
export interface GridFilterPanelProps extends Pick<GridFilterFormProps, 'linkOperators' | 'columnsSort'> {
|
|
5
11
|
/**
|
|
6
12
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
7
13
|
*/
|
|
8
14
|
sx?: SxProps<Theme>;
|
|
15
|
+
/**
|
|
16
|
+
* Function that returns the next filter item to be picked as default filter.
|
|
17
|
+
* @param {GetColumnForNewFilterArgs} args Currently configured filters and columns.
|
|
18
|
+
* @returns {GridColDef['field']} The field to be used for the next filter.
|
|
19
|
+
*/
|
|
20
|
+
getColumnForNewFilter?: (args: GetColumnForNewFilterArgs) => GridColDef['field'];
|
|
9
21
|
/**
|
|
10
22
|
* Props passed to each filter form.
|
|
11
23
|
*/
|
|
@@ -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
|
var _rootProps$components;
|
|
21
28
|
|
|
@@ -28,7 +35,8 @@ const GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(p
|
|
|
28
35
|
const {
|
|
29
36
|
linkOperators = [GridLinkOperator.And, GridLinkOperator.Or],
|
|
30
37
|
columnsSort,
|
|
31
|
-
filterFormProps
|
|
38
|
+
filterFormProps,
|
|
39
|
+
getColumnForNewFilter
|
|
32
40
|
} = props,
|
|
33
41
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
34
42
|
|
|
@@ -38,41 +46,71 @@ const GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(p
|
|
|
38
46
|
const applyFilterLinkOperator = React.useCallback(operator => {
|
|
39
47
|
apiRef.current.setFilterLinkOperator(operator);
|
|
40
48
|
}, [apiRef]);
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
const getDefaultFilter = React.useCallback(() => {
|
|
50
|
+
let nextColumnWithOperator;
|
|
51
|
+
|
|
52
|
+
if (getColumnForNewFilter && typeof getColumnForNewFilter === 'function') {
|
|
53
|
+
// To allow override the column for default (first) filter
|
|
54
|
+
const nextColumnFieldName = getColumnForNewFilter({
|
|
55
|
+
currentFilters: (filterModel == null ? void 0 : filterModel.items) || [],
|
|
56
|
+
columns: filterableColumns
|
|
57
|
+
});
|
|
58
|
+
nextColumnWithOperator = filterableColumns.find(({
|
|
59
|
+
field
|
|
60
|
+
}) => field === nextColumnFieldName);
|
|
61
|
+
} else {
|
|
62
|
+
nextColumnWithOperator = filterableColumns.find(colDef => {
|
|
63
|
+
var _colDef$filterOperato;
|
|
64
|
+
|
|
65
|
+
return (_colDef$filterOperato = colDef.filterOperators) == null ? void 0 : _colDef$filterOperato.length;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!nextColumnWithOperator) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
44
72
|
|
|
45
|
-
|
|
73
|
+
return getGridFilter(nextColumnWithOperator);
|
|
74
|
+
}, [filterModel == null ? void 0 : filterModel.items, filterableColumns, getColumnForNewFilter]);
|
|
75
|
+
const getNewFilter = React.useCallback(() => {
|
|
76
|
+
if (getColumnForNewFilter === undefined || typeof getColumnForNewFilter !== 'function') {
|
|
77
|
+
return getDefaultFilter();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const currentFilters = filterModel.items.length ? filterModel.items : [getDefaultFilter()].filter(Boolean); // If no items are there in filterModel, we have to pass defaultFilter
|
|
81
|
+
|
|
82
|
+
const nextColumnFieldName = getColumnForNewFilter({
|
|
83
|
+
currentFilters: currentFilters,
|
|
84
|
+
columns: filterableColumns
|
|
46
85
|
});
|
|
86
|
+
const nextColumnWithOperator = filterableColumns.find(({
|
|
87
|
+
field
|
|
88
|
+
}) => field === nextColumnFieldName);
|
|
47
89
|
|
|
48
|
-
if (!
|
|
90
|
+
if (!nextColumnWithOperator) {
|
|
49
91
|
return null;
|
|
50
92
|
}
|
|
51
93
|
|
|
52
|
-
return
|
|
53
|
-
|
|
54
|
-
operatorValue: firstColumnWithOperator.filterOperators[0].value,
|
|
55
|
-
id: Math.round(Math.random() * 1e5)
|
|
56
|
-
};
|
|
57
|
-
}, [filterableColumns]);
|
|
94
|
+
return getGridFilter(nextColumnWithOperator);
|
|
95
|
+
}, [filterModel.items, filterableColumns, getColumnForNewFilter, getDefaultFilter]);
|
|
58
96
|
const items = React.useMemo(() => {
|
|
59
97
|
if (filterModel.items.length) {
|
|
60
98
|
return filterModel.items;
|
|
61
99
|
}
|
|
62
100
|
|
|
63
|
-
const
|
|
64
|
-
return
|
|
65
|
-
}, [filterModel.items,
|
|
101
|
+
const defaultFilter = getDefaultFilter();
|
|
102
|
+
return defaultFilter ? [defaultFilter] : [];
|
|
103
|
+
}, [filterModel.items, getDefaultFilter]);
|
|
66
104
|
const hasMultipleFilters = items.length > 1;
|
|
67
105
|
|
|
68
106
|
const addNewFilter = () => {
|
|
69
|
-
const
|
|
107
|
+
const newFilter = getNewFilter();
|
|
70
108
|
|
|
71
|
-
if (!
|
|
109
|
+
if (!newFilter) {
|
|
72
110
|
return;
|
|
73
111
|
}
|
|
74
112
|
|
|
75
|
-
apiRef.current.upsertFilterItems([...items,
|
|
113
|
+
apiRef.current.upsertFilterItems([...items, newFilter]);
|
|
76
114
|
};
|
|
77
115
|
|
|
78
116
|
const deleteFilter = React.useCallback(item => {
|
|
@@ -149,6 +187,13 @@ process.env.NODE_ENV !== "production" ? GridFilterPanel.propTypes = {
|
|
|
149
187
|
valueInputProps: PropTypes.any
|
|
150
188
|
}),
|
|
151
189
|
|
|
190
|
+
/**
|
|
191
|
+
* Function that returns the next filter item to be picked as default filter.
|
|
192
|
+
* @param {GetColumnForNewFilterArgs} args Currently configured filters and columns.
|
|
193
|
+
* @returns {GridColDef['field']} The field to be used for the next filter.
|
|
194
|
+
*/
|
|
195
|
+
getColumnForNewFilter: PropTypes.func,
|
|
196
|
+
|
|
152
197
|
/**
|
|
153
198
|
* Sets the available logic operators.
|
|
154
199
|
* @default [GridLinkOperator.And, GridLinkOperator.Or]
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridApiCommon } from '../../../models/api/gridApiCommon';
|
|
3
|
-
export declare const useGridRegisterPipeApplier: <Api extends GridApiCommon, G extends keyof import("./gridPipeProcessingApi").GridPipeProcessingLookup>(apiRef: React.MutableRefObject<Api>, group: G, callback: () => void) => void;
|
|
3
|
+
export declare const useGridRegisterPipeApplier: <Api extends GridApiCommon<any, any>, G extends keyof import("./gridPipeProcessingApi").GridPipeProcessingLookup>(apiRef: React.MutableRefObject<Api>, group: G, callback: () => void) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridApiCommon } from '../../../models/api/gridApiCommon';
|
|
3
3
|
import { GridPipeProcessor } from './gridPipeProcessingApi';
|
|
4
|
-
export declare const useGridRegisterPipeProcessor: <Api extends GridApiCommon, G extends keyof import("./gridPipeProcessingApi").GridPipeProcessingLookup>(apiRef: React.MutableRefObject<Api>, group: G, callback: GridPipeProcessor<G>) => void;
|
|
4
|
+
export declare const useGridRegisterPipeProcessor: <Api extends GridApiCommon<any, any>, G extends keyof import("./gridPipeProcessingApi").GridPipeProcessingLookup>(apiRef: React.MutableRefObject<Api>, group: G, callback: GridPipeProcessor<G>) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridApiCommon } from '../../../models/api/gridApiCommon';
|
|
3
3
|
import { GridStrategyProcessor } from './gridStrategyProcessingApi';
|
|
4
|
-
export declare const useGridRegisterStrategyProcessor: <Api extends GridApiCommon, G extends keyof import("./gridStrategyProcessingApi").GridStrategyProcessingLookup>(apiRef: React.MutableRefObject<Api>, strategyName: string, group: G, processor: GridStrategyProcessor<G>) => void;
|
|
4
|
+
export declare const useGridRegisterStrategyProcessor: <Api extends GridApiCommon<any, any>, G extends keyof import("./gridStrategyProcessingApi").GridStrategyProcessingLookup>(apiRef: React.MutableRefObject<Api>, strategyName: string, group: G, processor: GridStrategyProcessor<G>) => void;
|
|
@@ -4,4 +4,4 @@ import { DataGridProcessedProps } from '../../models/props/DataGridProps';
|
|
|
4
4
|
/**
|
|
5
5
|
* Initialize the technical pieces of the DataGrid (logger, state, ...) that any DataGrid implementation needs
|
|
6
6
|
*/
|
|
7
|
-
export declare const useGridInitialization: <Api extends GridApiCommon
|
|
7
|
+
export declare const useGridInitialization: <Api extends GridApiCommon<any, any>>(inputApiRef: React.MutableRefObject<Api> | undefined, props: Pick<DataGridProcessedProps, 'signature' | 'logger' | 'logLevel' | 'error' | 'localeText'>) => React.MutableRefObject<Api>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { DataGridProcessedProps } from '../../models/props/DataGridProps';
|
|
3
3
|
import { GridApiCommon } from '../../models/api/gridApiCommon';
|
|
4
|
-
export declare const useGridStateInitialization: <Api extends GridApiCommon
|
|
4
|
+
export declare const useGridStateInitialization: <Api extends GridApiCommon<any, any>>(apiRef: React.MutableRefObject<Api>, props: Pick<DataGridProcessedProps, 'signature'>) => void;
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { GridColumnGroup } from '../../../models/gridColumnGrouping';
|
|
2
2
|
export declare type GridColumnGroupLookup = {
|
|
3
|
-
[
|
|
3
|
+
[groupId: string]: Omit<GridColumnGroup, 'children'>;
|
|
4
|
+
};
|
|
5
|
+
export declare type GridGroupingStructure = {
|
|
6
|
+
groupId: null | string;
|
|
7
|
+
columnFields: string[];
|
|
4
8
|
};
|
|
5
9
|
export interface GridColumnsGroupingState {
|
|
6
10
|
lookup: GridColumnGroupLookup;
|
|
11
|
+
headerStructure: GridGroupingStructure[][];
|
|
12
|
+
unwrappedGroupingModel: {
|
|
13
|
+
[columnField: string]: GridColumnGroup['groupId'][];
|
|
14
|
+
};
|
|
15
|
+
maxDepth: number;
|
|
7
16
|
}
|
|
@@ -4,4 +4,10 @@ import { GridStateCommunity } from '../../../models/gridStateCommunity';
|
|
|
4
4
|
* @ignore - do not document.
|
|
5
5
|
*/
|
|
6
6
|
export declare const gridColumnGroupingSelector: (state: GridStateCommunity) => import("./gridColumnGroupsInterfaces").GridColumnsGroupingState;
|
|
7
|
+
export declare const gridColumnGroupsUnwrappedModelSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, {
|
|
8
|
+
[columnField: string]: string[];
|
|
9
|
+
}>;
|
|
7
10
|
export declare const gridColumnGroupsLookupSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridColumnGroupsInterfaces").GridColumnGroupLookup>;
|
|
11
|
+
export declare const gridColumnGroupsHeaderStructureSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridColumnGroupsInterfaces").GridGroupingStructure[][]>;
|
|
12
|
+
export declare const gridColumnGroupsHeaderMaxDepthSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
|
|
13
|
+
export declare const gridTotalHeaderHeightSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
|
|
@@ -5,4 +5,37 @@ 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 => {
|
|
9
|
+
var _columnGrouping$unwra;
|
|
10
|
+
|
|
11
|
+
return (_columnGrouping$unwra = columnGrouping == null ? void 0 : columnGrouping.unwrappedGroupingModel) != null ? _columnGrouping$unwra : {};
|
|
12
|
+
});
|
|
13
|
+
export const gridColumnGroupsLookupSelector = createSelector(gridColumnGroupingSelector, columnGrouping => {
|
|
14
|
+
var _columnGrouping$looku;
|
|
15
|
+
|
|
16
|
+
return (_columnGrouping$looku = columnGrouping == null ? void 0 : columnGrouping.lookup) != null ? _columnGrouping$looku : {};
|
|
17
|
+
});
|
|
18
|
+
export const gridColumnGroupsHeaderStructureSelector = createSelector(gridColumnGroupingSelector, columnGrouping => {
|
|
19
|
+
var _columnGrouping$heade;
|
|
20
|
+
|
|
21
|
+
return (_columnGrouping$heade = columnGrouping == null ? void 0 : columnGrouping.headerStructure) != null ? _columnGrouping$heade : [];
|
|
22
|
+
});
|
|
23
|
+
export const gridColumnGroupsHeaderMaxDepthSelector = createSelector(gridColumnGroupingSelector, columnGrouping => {
|
|
24
|
+
var _columnGrouping$maxDe;
|
|
25
|
+
|
|
26
|
+
return (_columnGrouping$maxDe = columnGrouping == null ? void 0 : columnGrouping.maxDepth) != null ? _columnGrouping$maxDe : 0;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const getGroupingHeader = state => ({
|
|
30
|
+
columnGrouping: state.columnGrouping,
|
|
31
|
+
density: state.density
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const gridTotalHeaderHeightSelector = createSelector(getGroupingHeader, ({
|
|
35
|
+
columnGrouping,
|
|
36
|
+
density
|
|
37
|
+
}) => {
|
|
38
|
+
var _columnGrouping$maxDe2;
|
|
39
|
+
|
|
40
|
+
return density.headerHeight * (((_columnGrouping$maxDe2 = columnGrouping == null ? void 0 : columnGrouping.maxDepth) != null ? _columnGrouping$maxDe2 : 0) + 1);
|
|
41
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GridColumnGroupingModel, GridColumnGroup } from '../../../models/gridColumnGrouping';
|
|
2
|
+
import { GridColDef } from '../../../models/colDef';
|
|
3
|
+
import { GridGroupingStructure } from './gridColumnGroupsInterfaces';
|
|
4
|
+
declare type UnwrappedGroupingModel = {
|
|
5
|
+
[key: GridColDef['field']]: GridColumnGroup['groupId'][];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* This is a function that provide for each column the array of its parents.
|
|
9
|
+
* Parents are ordered from the root to the leaf.
|
|
10
|
+
* @param columnGroupingModel The model such as provided in DataGrid props
|
|
11
|
+
* @returns An object `{[field]: groupIds}` where `groupIds` is the parents of the column `field`
|
|
12
|
+
*/
|
|
13
|
+
export declare const unwrapGroupingColumnModel: (columnGroupingModel?: GridColumnGroupingModel) => UnwrappedGroupingModel;
|
|
14
|
+
export declare const getColumnGroupsHeaderStructure: (orderedColumns: string[], unwrappedGroupingModel: UnwrappedGroupingModel) => GridGroupingStructure[][];
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
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 => {
|
|
44
|
+
var _unwrappedGroupingMod;
|
|
45
|
+
|
|
46
|
+
return (_unwrappedGroupingMod = unwrappedGroupingModel[field]) != null ? _unwrappedGroupingMod : [];
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const groupingHeaderStructure = [];
|
|
50
|
+
const maxDepth = Math.max(...orderedColumns.map(field => getParents(field).length));
|
|
51
|
+
|
|
52
|
+
const haveSameParents = (field1, field2, depth) => isDeepEqual(getParents(field1).slice(0, depth + 1), getParents(field2).slice(0, depth + 1));
|
|
53
|
+
|
|
54
|
+
for (let depth = 0; depth < maxDepth; depth += 1) {
|
|
55
|
+
const depthStructure = orderedColumns.reduce((structure, newField) => {
|
|
56
|
+
var _getParents$depth;
|
|
57
|
+
|
|
58
|
+
const groupId = (_getParents$depth = getParents(newField)[depth]) != null ? _getParents$depth : null;
|
|
59
|
+
|
|
60
|
+
if (structure.length === 0) {
|
|
61
|
+
return [{
|
|
62
|
+
columnFields: [newField],
|
|
63
|
+
groupId
|
|
64
|
+
}];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const lastGroup = structure[structure.length - 1];
|
|
68
|
+
const prevField = lastGroup.columnFields[lastGroup.columnFields.length - 1];
|
|
69
|
+
const prevGroupId = lastGroup.groupId;
|
|
70
|
+
|
|
71
|
+
if (prevGroupId !== groupId || !haveSameParents(prevField, newField, depth)) {
|
|
72
|
+
// It's a new group
|
|
73
|
+
return [...structure, {
|
|
74
|
+
columnFields: [newField],
|
|
75
|
+
groupId
|
|
76
|
+
}];
|
|
77
|
+
} // It extends the previous group
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
return [...structure.slice(0, structure.length - 1), {
|
|
81
|
+
columnFields: [...lastGroup.columnFields, newField],
|
|
82
|
+
groupId
|
|
83
|
+
}];
|
|
84
|
+
}, []);
|
|
85
|
+
groupingHeaderStructure.push(depthStructure);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return groupingHeaderStructure;
|
|
89
|
+
};
|
|
@@ -2,23 +2,9 @@ import * as React from 'react';
|
|
|
2
2
|
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
4
|
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
5
|
-
|
|
6
|
-
import { GridStateColDef, GridColDef } from '../../../models/colDef';
|
|
7
|
-
export declare function hasGroupPath(lookupElement: GridColDef | GridStateColDef): lookupElement is GridStateColDef;
|
|
8
|
-
declare type UnwrappedGroupingModel = {
|
|
9
|
-
[key: GridColDef['field']]: GridColumnGroup['groupId'][];
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* This is a function that provide for each column the array of its parents.
|
|
13
|
-
* Parents are ordered from the root to the leaf.
|
|
14
|
-
* @param columnGroupingModel The model such as provided in DataGrid props
|
|
15
|
-
* @returns An object `{[field]: groupIds}` where `groupIds` is the parents of the column `field`
|
|
16
|
-
*/
|
|
17
|
-
export declare const unwrapGroupingColumnModel: (columnGroupingModel?: GridColumnGroupingModel) => UnwrappedGroupingModel;
|
|
18
|
-
export declare const columnGroupsStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'columnGroupingModel'>>;
|
|
5
|
+
export declare const columnGroupsStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'columnGroupingModel' | 'experimentalFeatures'>>;
|
|
19
6
|
/**
|
|
20
7
|
* @requires useGridColumns (method, event)
|
|
21
8
|
* @requires useGridParamsApi (method)
|
|
22
9
|
*/
|
|
23
10
|
export declare const useGridColumnGrouping: (apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'columnGroupingModel' | 'experimentalFeatures'>) => void;
|
|
24
|
-
export {};
|