@mui/x-data-grid 5.7.0 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +74 -0
- package/DataGrid/DataGrid.d.ts +8 -3
- package/DataGrid/DataGrid.js +27 -4
- package/DataGrid/useDataGridComponent.js +2 -4
- package/DataGrid/useDataGridProps.d.ts +2 -1
- package/colDef/gridBooleanColDef.d.ts +1 -1
- package/colDef/gridBooleanOperators.d.ts +1 -1
- package/colDef/gridDateColDef.d.ts +5 -9
- package/colDef/gridDateColDef.js +2 -2
- package/colDef/gridDateOperators.d.ts +1 -1
- package/{models/colDef → colDef}/gridDefaultColumnTypes.d.ts +1 -1
- package/{models/colDef → colDef}/gridDefaultColumnTypes.js +6 -6
- package/colDef/gridNumericColDef.d.ts +1 -1
- package/colDef/gridNumericOperators.d.ts +2 -2
- package/colDef/gridStringColDef.d.ts +1 -1
- package/colDef/gridStringOperators.d.ts +1 -1
- package/colDef/index.d.ts +1 -0
- package/colDef/index.js +2 -1
- package/components/GridRow.js +1 -1
- package/components/cell/GridCell.d.ts +4 -4
- package/components/cell/GridCell.js +2 -2
- package/components/cell/GridEditInputCell.js +2 -2
- package/components/cell/GridEditSingleSelectCell.js +2 -2
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.d.ts +12 -0
- package/components/columnHeaders/{ColumnHeaderFilterIcon.js → GridColumnHeaderFilterIconButton.js} +22 -4
- package/components/columnHeaders/GridColumnHeaderItem.js +5 -5
- package/components/columnHeaders/index.d.ts +1 -0
- package/components/columnHeaders/index.js +1 -0
- package/components/columnSelection/GridCellCheckboxRenderer.js +2 -2
- package/components/columnSelection/GridHeaderCheckbox.d.ts +1 -1
- package/components/containers/GridRoot.js +29 -17
- package/components/menu/columnMenu/GridColumnMenu.js +1 -1
- package/components/panel/GridPanel.d.ts +2 -2
- package/components/panel/GridPreferencesPanel.js +1 -1
- package/constants/defaultGridSlotsComponents.js +2 -1
- package/constants/gridClasses.d.ts +15 -3
- package/hooks/core/index.d.ts +1 -1
- package/hooks/core/{preProcessing/gridPreProcessingApi.d.ts → pipeProcessing/gridPipeProcessingApi.d.ts} +19 -18
- package/hooks/core/{preProcessing/gridPreProcessingApi.js → pipeProcessing/gridPipeProcessingApi.js} +0 -0
- package/hooks/core/pipeProcessing/index.d.ts +3 -0
- package/hooks/core/pipeProcessing/index.js +3 -0
- package/hooks/core/pipeProcessing/useGridPipeProcessing.d.ts +27 -0
- package/hooks/core/pipeProcessing/useGridPipeProcessing.js +74 -0
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +7 -0
- package/hooks/core/{preProcessing/useGridRegisterPreProcessor.js → pipeProcessing/useGridRegisterPipeProcessor.js} +2 -2
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.d.ts +27 -16
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.js +26 -15
- package/hooks/core/useGridInitialization.js +2 -2
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/hooks/features/columns/gridColumnsSelector.d.ts +6 -6
- package/hooks/features/columns/gridColumnsUtils.d.ts +3 -3
- package/hooks/features/columns/gridColumnsUtils.js +49 -17
- package/hooks/features/columns/useGridColumns.js +36 -27
- package/hooks/features/dimensions/gridDimensionsApi.d.ts +5 -0
- package/hooks/features/dimensions/useGridDimensions.js +2 -1
- package/hooks/features/editRows/useGridCellEditing.new.d.ts +1 -1
- package/hooks/features/editRows/useGridCellEditing.new.js +22 -7
- package/hooks/features/editRows/useGridRowEditing.new.d.ts +1 -1
- package/hooks/features/editRows/useGridRowEditing.new.js +22 -7
- package/hooks/features/events/useGridEvents.d.ts +1 -1
- package/hooks/features/events/useGridEvents.js +2 -0
- package/hooks/features/filter/gridFilterSelector.d.ts +3 -9
- package/hooks/features/filter/useGridFilter.js +4 -4
- package/hooks/features/{keyboard → keyboardNavigation}/useGridKeyboardNavigation.d.ts +2 -5
- package/hooks/features/{keyboard → keyboardNavigation}/useGridKeyboardNavigation.js +27 -6
- package/hooks/features/pagination/gridPaginationSelector.d.ts +1 -3
- package/hooks/features/pagination/useGridPage.js +9 -4
- package/hooks/features/pagination/useGridPageSize.js +3 -3
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +18 -5
- package/hooks/features/rows/gridRowsSelector.d.ts +1 -1
- package/hooks/features/rows/gridRowsUtils.d.ts +8 -0
- package/hooks/features/rows/gridRowsUtils.js +11 -0
- package/hooks/features/rows/index.d.ts +1 -0
- package/hooks/features/rows/index.js +1 -1
- package/hooks/features/rows/useGridRows.js +3 -3
- package/hooks/features/rows/useGridRowsMeta.js +3 -3
- package/hooks/features/scroll/useGridScroll.js +4 -13
- package/hooks/features/selection/gridSelectionSelector.d.ts +1 -3
- package/hooks/features/selection/useGridSelection.d.ts +4 -2
- package/hooks/features/selection/useGridSelection.js +72 -25
- package/hooks/features/selection/useGridSelectionPreProcessors.js +2 -2
- package/hooks/features/sorting/gridSortingSelector.d.ts +1 -3
- package/hooks/features/sorting/gridSortingUtils.d.ts +1 -2
- package/hooks/features/sorting/useGridSorting.js +3 -3
- package/hooks/features/statePersistence/useGridStatePersistence.js +2 -2
- package/hooks/utils/useGridRootProps.d.ts +1 -1
- package/hooks/utils/useGridVisibleRows.d.ts +2 -2
- package/index.js +1 -1
- package/internals/index.d.ts +3 -6
- package/internals/index.js +2 -3
- package/legacy/DataGrid/DataGrid.js +27 -4
- package/legacy/DataGrid/useDataGridComponent.js +2 -4
- package/legacy/colDef/gridDateColDef.js +2 -2
- package/legacy/{models/colDef → colDef}/gridDefaultColumnTypes.js +6 -6
- package/legacy/colDef/index.js +2 -1
- package/legacy/components/GridRow.js +1 -1
- package/legacy/components/cell/GridCell.js +2 -2
- package/legacy/components/cell/GridEditInputCell.js +2 -2
- package/legacy/components/cell/GridEditSingleSelectCell.js +2 -2
- package/legacy/components/columnHeaders/{ColumnHeaderFilterIcon.js → GridColumnHeaderFilterIconButton.js} +22 -4
- package/legacy/components/columnHeaders/GridColumnHeaderItem.js +5 -5
- package/legacy/components/columnHeaders/index.js +1 -0
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +2 -2
- package/legacy/components/containers/GridRoot.js +34 -17
- package/legacy/components/menu/columnMenu/GridColumnMenu.js +1 -1
- package/legacy/components/panel/GridPreferencesPanel.js +1 -1
- package/legacy/constants/defaultGridSlotsComponents.js +2 -1
- package/legacy/hooks/core/{preProcessing/gridPreProcessingApi.js → pipeProcessing/gridPipeProcessingApi.js} +0 -0
- package/legacy/hooks/core/pipeProcessing/index.js +3 -0
- package/legacy/hooks/core/pipeProcessing/useGridPipeProcessing.js +83 -0
- package/legacy/hooks/core/{preProcessing/useGridRegisterPreProcessor.js → pipeProcessing/useGridRegisterPipeProcessor.js} +2 -2
- package/legacy/hooks/core/strategyProcessing/useGridStrategyProcessing.js +26 -15
- package/legacy/hooks/core/useGridInitialization.js +2 -2
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/legacy/hooks/features/columns/gridColumnsUtils.js +49 -18
- package/legacy/hooks/features/columns/useGridColumns.js +36 -27
- package/legacy/hooks/features/dimensions/useGridDimensions.js +2 -1
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +22 -7
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +22 -7
- package/legacy/hooks/features/events/useGridEvents.js +2 -0
- package/legacy/hooks/features/filter/useGridFilter.js +4 -4
- package/legacy/hooks/features/{keyboard → keyboardNavigation}/useGridKeyboardNavigation.js +27 -6
- package/legacy/hooks/features/pagination/useGridPage.js +11 -4
- package/legacy/hooks/features/pagination/useGridPageSize.js +3 -3
- package/legacy/hooks/features/preferencesPanel/useGridPreferencesPanel.js +18 -5
- package/legacy/hooks/features/rows/gridRowsUtils.js +13 -0
- package/legacy/hooks/features/rows/index.js +1 -1
- package/legacy/hooks/features/rows/useGridRows.js +5 -5
- package/legacy/hooks/features/rows/useGridRowsMeta.js +3 -3
- package/legacy/hooks/features/scroll/useGridScroll.js +4 -13
- package/legacy/hooks/features/selection/useGridSelection.js +74 -25
- package/legacy/hooks/features/selection/useGridSelectionPreProcessors.js +2 -2
- package/legacy/hooks/features/sorting/useGridSorting.js +3 -3
- package/legacy/hooks/features/statePersistence/useGridStatePersistence.js +2 -2
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +2 -3
- package/legacy/locales/daDK.js +36 -32
- package/legacy/models/colDef/index.js +1 -2
- package/legacy/models/events/gridEvents.js +4 -2
- package/legacy/models/gridRows.js +1 -33
- package/legacy/models/index.js +2 -2
- package/{modern/hooks/core/preProcessing/gridPreProcessingApi.js → legacy/models/params/gridPreferencePanelParams.js} +0 -0
- package/legacy/models/params/index.js +2 -1
- package/locales/daDK.js +32 -32
- package/models/api/gridApiCommon.d.ts +2 -2
- package/models/api/gridEditingApi.d.ts +2 -2
- package/models/api/gridParamsApi.d.ts +5 -5
- package/models/api/gridRowApi.d.ts +2 -2
- package/models/colDef/gridColDef.d.ts +33 -28
- package/models/colDef/index.d.ts +0 -1
- package/models/colDef/index.js +1 -2
- package/models/events/gridEventLookup.d.ts +12 -6
- package/models/events/gridEvents.d.ts +11 -5
- package/models/events/gridEvents.js +4 -2
- package/models/gridCell.d.ts +1 -0
- package/models/gridEditRowModel.d.ts +1 -1
- package/models/gridFilterOperator.d.ts +3 -2
- package/models/gridRows.d.ts +10 -18
- package/models/gridRows.js +1 -31
- package/models/gridSlotsComponent.d.ts +5 -0
- package/models/gridSlotsComponentsProps.d.ts +1 -0
- package/models/gridSortModel.d.ts +3 -4
- package/models/index.d.ts +1 -1
- package/models/index.js +2 -2
- package/models/params/gridCellParams.d.ts +14 -14
- package/models/params/gridColumnHeaderParams.d.ts +3 -2
- package/models/params/gridEditCellParams.d.ts +2 -3
- package/models/params/gridPreferencePanelParams.d.ts +3 -0
- package/models/params/gridPreferencePanelParams.js +1 -0
- package/models/params/gridRowParams.d.ts +7 -8
- package/models/params/gridValueOptionsParams.d.ts +3 -3
- package/models/params/index.d.ts +1 -0
- package/models/params/index.js +2 -1
- package/models/props/DataGridProps.d.ts +36 -16
- package/modern/DataGrid/DataGrid.js +27 -4
- package/modern/DataGrid/useDataGridComponent.js +2 -4
- package/modern/colDef/gridDateColDef.js +2 -2
- package/modern/{models/colDef → colDef}/gridDefaultColumnTypes.js +6 -6
- package/modern/colDef/index.js +2 -1
- package/modern/components/GridRow.js +1 -1
- package/modern/components/cell/GridCell.js +2 -2
- package/modern/components/cell/GridEditInputCell.js +2 -2
- package/modern/components/cell/GridEditSingleSelectCell.js +2 -2
- package/modern/components/columnHeaders/{ColumnHeaderFilterIcon.js → GridColumnHeaderFilterIconButton.js} +22 -4
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +3 -3
- package/modern/components/columnHeaders/index.js +1 -0
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +2 -2
- package/modern/components/containers/GridRoot.js +29 -17
- package/modern/components/menu/columnMenu/GridColumnMenu.js +1 -1
- package/modern/components/panel/GridPreferencesPanel.js +1 -1
- package/modern/constants/defaultGridSlotsComponents.js +2 -1
- package/modern/hooks/core/pipeProcessing/gridPipeProcessingApi.js +1 -0
- package/modern/hooks/core/pipeProcessing/index.js +3 -0
- package/modern/hooks/core/pipeProcessing/useGridPipeProcessing.js +74 -0
- package/modern/hooks/core/{preProcessing/useGridRegisterPreProcessor.js → pipeProcessing/useGridRegisterPipeProcessor.js} +2 -2
- package/modern/hooks/core/strategyProcessing/useGridStrategyProcessing.js +26 -15
- package/modern/hooks/core/useGridInitialization.js +2 -2
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/modern/hooks/features/columns/gridColumnsUtils.js +49 -17
- package/modern/hooks/features/columns/useGridColumns.js +36 -27
- package/modern/hooks/features/dimensions/useGridDimensions.js +2 -1
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +22 -7
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +22 -7
- package/modern/hooks/features/events/useGridEvents.js +2 -0
- package/modern/hooks/features/filter/useGridFilter.js +4 -4
- package/modern/hooks/features/{keyboard → keyboardNavigation}/useGridKeyboardNavigation.js +27 -6
- package/modern/hooks/features/pagination/useGridPage.js +9 -4
- package/modern/hooks/features/pagination/useGridPageSize.js +3 -3
- package/modern/hooks/features/preferencesPanel/useGridPreferencesPanel.js +18 -5
- package/modern/hooks/features/rows/gridRowsUtils.js +11 -0
- package/modern/hooks/features/rows/index.js +1 -1
- package/modern/hooks/features/rows/useGridRows.js +1 -1
- package/modern/hooks/features/rows/useGridRowsMeta.js +3 -3
- package/modern/hooks/features/scroll/useGridScroll.js +4 -9
- package/modern/hooks/features/selection/useGridSelection.js +72 -25
- package/modern/hooks/features/selection/useGridSelectionPreProcessors.js +2 -2
- package/modern/hooks/features/sorting/useGridSorting.js +3 -3
- package/modern/hooks/features/statePersistence/useGridStatePersistence.js +2 -2
- package/modern/index.js +1 -1
- package/modern/internals/index.js +2 -3
- package/modern/locales/daDK.js +32 -32
- package/modern/models/colDef/index.js +1 -2
- package/modern/models/events/gridEvents.js +4 -2
- package/modern/models/gridRows.js +1 -31
- package/modern/models/index.js +2 -2
- package/modern/models/params/gridPreferencePanelParams.js +1 -0
- package/modern/models/params/index.js +2 -1
- package/node/DataGrid/DataGrid.js +27 -4
- package/node/DataGrid/useDataGridComponent.js +2 -5
- package/node/colDef/gridDateColDef.js +2 -2
- package/node/{models/colDef → colDef}/gridDefaultColumnTypes.js +6 -6
- package/node/colDef/index.js +13 -0
- package/node/components/GridRow.js +1 -1
- package/node/components/cell/GridCell.js +2 -2
- package/node/components/cell/GridEditInputCell.js +2 -2
- package/node/components/cell/GridEditSingleSelectCell.js +2 -2
- package/node/components/columnHeaders/{ColumnHeaderFilterIcon.js → GridColumnHeaderFilterIconButton.js} +23 -5
- package/node/components/columnHeaders/GridColumnHeaderItem.js +5 -6
- package/node/components/columnHeaders/index.js +13 -0
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +2 -2
- package/node/components/containers/GridRoot.js +28 -17
- package/node/components/menu/columnMenu/GridColumnMenu.js +1 -1
- package/node/components/panel/GridPreferencesPanel.js +1 -1
- package/node/constants/defaultGridSlotsComponents.js +1 -0
- package/node/hooks/core/{preProcessing/gridPreProcessingApi.js → pipeProcessing/gridPipeProcessingApi.js} +0 -0
- package/node/hooks/core/pipeProcessing/index.js +44 -0
- package/node/hooks/core/pipeProcessing/useGridPipeProcessing.js +93 -0
- package/node/hooks/core/{preProcessing/useGridRegisterPreProcessor.js → pipeProcessing/useGridRegisterPipeProcessor.js} +4 -4
- package/node/hooks/core/strategyProcessing/useGridStrategyProcessing.js +26 -15
- package/node/hooks/core/useGridInitialization.js +2 -2
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/node/hooks/features/columns/gridColumnsUtils.js +54 -21
- package/node/hooks/features/columns/useGridColumns.js +36 -27
- package/node/hooks/features/dimensions/useGridDimensions.js +2 -1
- package/node/hooks/features/editRows/useGridCellEditing.new.js +24 -7
- package/node/hooks/features/editRows/useGridRowEditing.new.js +24 -7
- package/node/hooks/features/events/useGridEvents.js +2 -0
- package/node/hooks/features/filter/useGridFilter.js +4 -4
- package/node/hooks/features/{keyboard → keyboardNavigation}/useGridKeyboardNavigation.js +29 -6
- package/node/hooks/features/pagination/useGridPage.js +8 -3
- package/node/hooks/features/pagination/useGridPageSize.js +3 -3
- package/node/hooks/features/preferencesPanel/useGridPreferencesPanel.js +20 -5
- package/node/hooks/features/rows/gridRowsUtils.js +18 -0
- package/node/hooks/features/rows/index.js +15 -1
- package/node/hooks/features/rows/useGridRows.js +5 -5
- package/node/hooks/features/rows/useGridRowsMeta.js +3 -3
- package/node/hooks/features/scroll/useGridScroll.js +3 -13
- package/node/hooks/features/selection/useGridSelection.js +71 -24
- package/node/hooks/features/selection/useGridSelectionPreProcessors.js +2 -2
- package/node/hooks/features/sorting/useGridSorting.js +3 -3
- package/node/hooks/features/statePersistence/useGridStatePersistence.js +2 -2
- package/node/index.js +1 -1
- package/node/internals/index.js +4 -12
- package/node/locales/daDK.js +32 -32
- package/node/models/colDef/index.js +0 -13
- package/node/models/events/gridEvents.js +4 -2
- package/node/models/gridRows.js +1 -34
- package/node/models/index.js +13 -13
- package/node/models/params/gridPreferencePanelParams.js +5 -0
- package/node/models/params/index.js +13 -0
- package/package.json +1 -1
- package/components/columnHeaders/ColumnHeaderFilterIcon.d.ts +0 -5
- package/hooks/core/preProcessing/index.d.ts +0 -3
- package/hooks/core/preProcessing/index.js +0 -3
- package/hooks/core/preProcessing/useGridPreProcessing.d.ts +0 -6
- package/hooks/core/preProcessing/useGridPreProcessing.js +0 -53
- package/hooks/core/preProcessing/useGridRegisterPreProcessor.d.ts +0 -7
- package/hooks/features/keyboard/useGridKeyboard.d.ts +0 -10
- package/hooks/features/keyboard/useGridKeyboard.js +0 -70
- package/legacy/hooks/core/preProcessing/index.js +0 -3
- package/legacy/hooks/core/preProcessing/useGridPreProcessing.js +0 -62
- package/legacy/hooks/features/keyboard/useGridKeyboard.js +0 -70
- package/modern/hooks/core/preProcessing/index.js +0 -3
- package/modern/hooks/core/preProcessing/useGridPreProcessing.js +0 -53
- package/modern/hooks/features/keyboard/useGridKeyboard.js +0 -70
- package/node/hooks/core/preProcessing/index.js +0 -44
- package/node/hooks/core/preProcessing/useGridPreProcessing.js +0 -72
- package/node/hooks/features/keyboard/useGridKeyboard.js +0 -91
|
@@ -4,7 +4,7 @@ import { GridEvents } from '../../../models/events';
|
|
|
4
4
|
import { useGridLogger, useGridApiMethod, useGridApiEventHandler, useGridSelector } from '../../utils';
|
|
5
5
|
import { gridPageSizeSelector } from './gridPaginationSelector';
|
|
6
6
|
import { gridDensityRowHeightSelector } from '../density';
|
|
7
|
-
import {
|
|
7
|
+
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
8
8
|
export const defaultPageSize = autoPageSize => autoPageSize ? 0 : 100;
|
|
9
9
|
|
|
10
10
|
const mergeStateWithPageSize = pageSize => state => _extends({}, state, {
|
|
@@ -84,8 +84,8 @@ export const useGridPageSize = (apiRef, props) => {
|
|
|
84
84
|
|
|
85
85
|
return params;
|
|
86
86
|
}, [apiRef]);
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
88
|
+
useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
89
89
|
/**
|
|
90
90
|
* EVENTS
|
|
91
91
|
*/
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { GridEvents } from '../../../models/events';
|
|
3
4
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
4
5
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
5
|
-
import {
|
|
6
|
+
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
6
7
|
import { gridPreferencePanelStateSelector } from './gridPreferencePanelSelector';
|
|
8
|
+
import { useGridSelector } from '../../utils/useGridSelector';
|
|
7
9
|
export const preferencePanelStateInitializer = (state, props) => {
|
|
8
10
|
var _props$initialState$p, _props$initialState;
|
|
9
11
|
|
|
@@ -19,6 +21,7 @@ export const preferencePanelStateInitializer = (state, props) => {
|
|
|
19
21
|
|
|
20
22
|
export const useGridPreferencesPanel = apiRef => {
|
|
21
23
|
const logger = useGridLogger(apiRef, 'useGridPreferencesPanel');
|
|
24
|
+
const preferencePanelState = useGridSelector(apiRef, gridPreferencePanelStateSelector);
|
|
22
25
|
const hideTimeout = React.useRef();
|
|
23
26
|
const immediateTimeout = React.useRef();
|
|
24
27
|
/**
|
|
@@ -27,13 +30,20 @@ export const useGridPreferencesPanel = apiRef => {
|
|
|
27
30
|
|
|
28
31
|
const hidePreferences = React.useCallback(() => {
|
|
29
32
|
logger.debug('Hiding Preferences Panel');
|
|
33
|
+
|
|
34
|
+
if (preferencePanelState.openedPanelValue) {
|
|
35
|
+
apiRef.current.publishEvent(GridEvents.preferencePanelClose, {
|
|
36
|
+
openedPanelValue: preferencePanelState.openedPanelValue
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
30
40
|
apiRef.current.setState(state => _extends({}, state, {
|
|
31
41
|
preferencePanel: {
|
|
32
42
|
open: false
|
|
33
43
|
}
|
|
34
44
|
}));
|
|
35
45
|
apiRef.current.forceUpdate();
|
|
36
|
-
}, [apiRef, logger]); // This is to prevent the preferences from closing when you open a select box or another panel,
|
|
46
|
+
}, [apiRef, logger, preferencePanelState.openedPanelValue]); // This is to prevent the preferences from closing when you open a select box or another panel,
|
|
37
47
|
// The issue is in MUI core V4 => Fixed in V5
|
|
38
48
|
|
|
39
49
|
const doNotHidePanel = React.useCallback(() => {
|
|
@@ -53,8 +63,11 @@ export const useGridPreferencesPanel = apiRef => {
|
|
|
53
63
|
openedPanelValue: newValue
|
|
54
64
|
})
|
|
55
65
|
}));
|
|
66
|
+
apiRef.current.publishEvent(GridEvents.preferencePanelOpen, {
|
|
67
|
+
openedPanelValue: newValue
|
|
68
|
+
});
|
|
56
69
|
apiRef.current.forceUpdate();
|
|
57
|
-
}, [doNotHidePanel, apiRef
|
|
70
|
+
}, [logger, doNotHidePanel, apiRef]);
|
|
58
71
|
useGridApiMethod(apiRef, {
|
|
59
72
|
showPreferences,
|
|
60
73
|
hidePreferences: hidePreferencesDelayed
|
|
@@ -85,8 +98,8 @@ export const useGridPreferencesPanel = apiRef => {
|
|
|
85
98
|
|
|
86
99
|
return params;
|
|
87
100
|
}, [apiRef]);
|
|
88
|
-
|
|
89
|
-
|
|
101
|
+
useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
102
|
+
useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
90
103
|
/**
|
|
91
104
|
* EFFECTS
|
|
92
105
|
*/
|
|
@@ -2,7 +2,7 @@ import { GridStateCommunity } from '../../../models/gridStateCommunity';
|
|
|
2
2
|
export declare const gridRowsStateSelector: (state: GridStateCommunity) => import("./gridRowsState").GridRowsState;
|
|
3
3
|
export declare const gridRowCountSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
|
|
4
4
|
export declare const gridTopLevelRowCountSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
|
|
5
|
-
export declare const gridRowsLookupSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridRowsLookup
|
|
5
|
+
export declare const gridRowsLookupSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridRowsLookup<any>>;
|
|
6
6
|
export declare const gridRowTreeSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridRowTreeConfig>;
|
|
7
7
|
export declare const gridRowGroupingNameSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, string>;
|
|
8
8
|
export declare const gridRowTreeDepthSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GridRowId, GridRowModel } from '../../../models';
|
|
2
|
+
/**
|
|
3
|
+
* A helper function to check if the id provided is valid.
|
|
4
|
+
* @param {GridRowId} id Id as [[GridRowId]].
|
|
5
|
+
* @param {GridRowModel | Partial<GridRowModel>} row Row as [[GridRowModel]].
|
|
6
|
+
* @param {string} detailErrorMessage A custom error message to display for invalid IDs
|
|
7
|
+
*/
|
|
8
|
+
export declare function checkGridRowIdIsValid(id: GridRowId, row: GridRowModel | Partial<GridRowModel>, detailErrorMessage?: string): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A helper function to check if the id provided is valid.
|
|
3
|
+
* @param {GridRowId} id Id as [[GridRowId]].
|
|
4
|
+
* @param {GridRowModel | Partial<GridRowModel>} row Row as [[GridRowModel]].
|
|
5
|
+
* @param {string} detailErrorMessage A custom error message to display for invalid IDs
|
|
6
|
+
*/
|
|
7
|
+
export function checkGridRowIdIsValid(id, row, detailErrorMessage = 'A row was provided without id in the rows prop:') {
|
|
8
|
+
if (id == null) {
|
|
9
|
+
throw new Error(['MUI: The data grid component requires all rows to have a unique `id` property.', 'Alternatively, you can use the `getRowId` prop to specify a custom id for each row.', detailErrorMessage, JSON.stringify(row)].join('\n'));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { GridEvents } from '../../../models/events';
|
|
4
|
-
import { checkGridRowIdIsValid } from '../../../models/gridRows';
|
|
5
4
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
6
5
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
7
6
|
import { gridRowCountSelector, gridRowsLookupSelector, gridRowTreeSelector, gridRowIdsSelector, gridRowGroupingNameSelector } from './gridRowsSelector';
|
|
8
7
|
import { GridSignature, useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
9
8
|
import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
|
|
9
|
+
import { checkGridRowIdIsValid } from './gridRowsUtils';
|
|
10
10
|
|
|
11
11
|
function getGridRowId(rowModel, getRowId, detailErrorMessage) {
|
|
12
12
|
const id = getRowId ? getRowId(rowModel) : rowModel.id;
|
|
@@ -91,9 +91,9 @@ export const useGridRows = (apiRef, props) => {
|
|
|
91
91
|
|
|
92
92
|
const currentPage = useGridVisibleRows(apiRef, props);
|
|
93
93
|
const getRow = React.useCallback(id => {
|
|
94
|
-
var
|
|
94
|
+
var _ref;
|
|
95
95
|
|
|
96
|
-
return (
|
|
96
|
+
return (_ref = gridRowsLookupSelector(apiRef)[id]) != null ? _ref : null;
|
|
97
97
|
}, [apiRef]);
|
|
98
98
|
const lookup = React.useMemo(() => currentPage.rows.reduce((acc, {
|
|
99
99
|
id
|
|
@@ -74,7 +74,7 @@ export const useGridRowsMeta = (apiRef, props) => {
|
|
|
74
74
|
initialHeights.spacingBottom = (_spacing$bottom = spacing.bottom) != null ? _spacing$bottom : 0;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
const sizes = apiRef.current.
|
|
77
|
+
const sizes = apiRef.current.unstable_applyPipeProcessors('rowHeight', initialHeights, row);
|
|
78
78
|
const finalRowHeight = Object.values(sizes).reduce((acc2, value) => acc2 + value, 0);
|
|
79
79
|
rowsHeightLookup.current[row.id] = {
|
|
80
80
|
value: baseRowHeight,
|
|
@@ -120,14 +120,14 @@ export const useGridRowsMeta = (apiRef, props) => {
|
|
|
120
120
|
React.useEffect(() => {
|
|
121
121
|
hydrateRowsMeta();
|
|
122
122
|
}, [rowHeight, filterState, paginationState, sortingState, hydrateRowsMeta]);
|
|
123
|
-
const
|
|
123
|
+
const handlepipeProcessorRegister = React.useCallback(name => {
|
|
124
124
|
if (name !== 'rowHeight') {
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
hydrateRowsMeta();
|
|
129
129
|
}, [hydrateRowsMeta]);
|
|
130
|
-
useGridApiEventHandler(apiRef, GridEvents.
|
|
130
|
+
useGridApiEventHandler(apiRef, GridEvents.pipeProcessorRegister, handlepipeProcessorRegister);
|
|
131
131
|
const rowsMetaApi = {
|
|
132
132
|
unstable_getRowHeight: getTargetRowHeight,
|
|
133
133
|
unstable_getRowInternalSizes: getRowInternalSizes,
|
|
@@ -4,8 +4,7 @@ import { gridColumnPositionsSelector, gridVisibleColumnDefinitionsSelector } fro
|
|
|
4
4
|
import { gridPageSelector, gridPageSizeSelector } from '../pagination/gridPaginationSelector';
|
|
5
5
|
import { gridRowCountSelector } from '../rows/gridRowsSelector';
|
|
6
6
|
import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
|
|
7
|
-
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
8
|
-
import { useGridNativeEventListener } from '../../utils/useGridNativeEventListener'; // Logic copied from https://www.w3.org/TR/wai-aria-practices/examples/listbox/js/listbox.js
|
|
7
|
+
import { useGridApiMethod } from '../../utils/useGridApiMethod'; // Logic copied from https://www.w3.org/TR/wai-aria-practices/examples/listbox/js/listbox.js
|
|
9
8
|
// Similar to https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
|
|
10
9
|
|
|
11
10
|
function scrollIntoView(dimensions) {
|
|
@@ -42,8 +41,9 @@ export const useGridScroll = (apiRef, props) => {
|
|
|
42
41
|
const scrollToIndexes = React.useCallback(params => {
|
|
43
42
|
const totalRowCount = gridRowCountSelector(apiRef);
|
|
44
43
|
const visibleColumns = gridVisibleColumnDefinitionsSelector(apiRef);
|
|
44
|
+
const scrollToHeader = params.rowIndex == null;
|
|
45
45
|
|
|
46
|
-
if (totalRowCount === 0 || visibleColumns.length === 0) {
|
|
46
|
+
if (!scrollToHeader && totalRowCount === 0 || visibleColumns.length === 0) {
|
|
47
47
|
return false;
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -74,7 +74,7 @@ export const useGridScroll = (apiRef, props) => {
|
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
scrollCoordinates = apiRef.current.
|
|
77
|
+
scrollCoordinates = apiRef.current.unstable_applyPipeProcessors('scrollToIndexes', scrollCoordinates, params);
|
|
78
78
|
|
|
79
79
|
if (typeof scrollCoordinates.left !== undefined || typeof scrollCoordinates.top !== undefined) {
|
|
80
80
|
apiRef.current.scroll(scrollCoordinates);
|
|
@@ -116,13 +116,4 @@ export const useGridScroll = (apiRef, props) => {
|
|
|
116
116
|
getScrollPosition
|
|
117
117
|
};
|
|
118
118
|
useGridApiMethod(apiRef, scrollApi, 'GridScrollApi');
|
|
119
|
-
const preventScroll = React.useCallback(event => {
|
|
120
|
-
event.target.scrollLeft = 0;
|
|
121
|
-
event.target.scrollTop = 0;
|
|
122
|
-
}, []);
|
|
123
|
-
useGridNativeEventListener(apiRef, () => {
|
|
124
|
-
var _apiRef$current, _apiRef$current$rende, _apiRef$current$rende2;
|
|
125
|
-
|
|
126
|
-
return (_apiRef$current = apiRef.current) == null ? void 0 : (_apiRef$current$rende = _apiRef$current.renderingZoneRef) == null ? void 0 : (_apiRef$current$rende2 = _apiRef$current$rende.current) == null ? void 0 : _apiRef$current$rende2.parentElement;
|
|
127
|
-
}, 'scroll', preventScroll);
|
|
128
119
|
};
|
|
@@ -2,7 +2,5 @@ import { GridStateCommunity } from '../../../models/gridStateCommunity';
|
|
|
2
2
|
import { GridRowId } from '../../../models/gridRows';
|
|
3
3
|
export declare const gridSelectionStateSelector: (state: GridStateCommunity) => import("../../..").GridSelectionModel;
|
|
4
4
|
export declare const selectedGridRowsCountSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
|
|
5
|
-
export declare const selectedGridRowsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Map<GridRowId,
|
|
6
|
-
[key: string]: any;
|
|
7
|
-
}>>;
|
|
5
|
+
export declare const selectedGridRowsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Map<GridRowId, any>>;
|
|
8
6
|
export declare const selectedIdsLookupSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Record<GridRowId, GridRowId>>;
|
|
@@ -4,7 +4,9 @@ import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
|
4
4
|
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
5
5
|
export declare const selectionStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'selectionModel'>>;
|
|
6
6
|
/**
|
|
7
|
-
* @requires useGridRows (state, method)
|
|
8
|
-
* @requires useGridParamsApi (method)
|
|
7
|
+
* @requires useGridRows (state, method) - can be after
|
|
8
|
+
* @requires useGridParamsApi (method) - can be after
|
|
9
|
+
* @requires useGridFocus (state) - can be after
|
|
10
|
+
* @requires useGridKeyboardNavigation (`cellKeyDown` event must first be consumed by it)
|
|
9
11
|
*/
|
|
10
12
|
export declare const useGridSelection: (apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'checkboxSelection' | 'selectionModel' | 'onSelectionModelChange' | 'disableMultipleSelection' | 'disableSelectionOnClick' | 'isRowSelectable' | 'checkboxSelectionVisibleOnly' | 'pagination' | 'paginationMode' | 'classes'>) => void;
|
|
@@ -5,14 +5,14 @@ import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
|
5
5
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
6
6
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
7
7
|
import { gridRowsLookupSelector } from '../rows/gridRowsSelector';
|
|
8
|
-
import { isGridCellRoot } from '../../../utils/domUtils';
|
|
9
8
|
import { gridSelectionStateSelector, selectedGridRowsSelector, selectedIdsLookupSelector } from './gridSelectionSelector';
|
|
10
9
|
import { gridPaginatedVisibleSortedGridRowIdsSelector } from '../pagination';
|
|
10
|
+
import { gridFocusCellSelector } from '../focus/gridFocusStateSelector';
|
|
11
11
|
import { gridVisibleSortedRowIdsSelector } from '../filter/gridFilterSelector';
|
|
12
12
|
import { GRID_CHECKBOX_SELECTION_COL_DEF, GRID_ACTIONS_COLUMN_TYPE } from '../../../colDef';
|
|
13
13
|
import { GridCellModes } from '../../../models/gridEditRowModel';
|
|
14
|
-
import { isKeyboardEvent } from '../../../utils/keyboardUtils';
|
|
15
|
-
import { getVisibleRows } from '../../utils/useGridVisibleRows';
|
|
14
|
+
import { isKeyboardEvent, isNavigationKey } from '../../../utils/keyboardUtils';
|
|
15
|
+
import { getVisibleRows, useGridVisibleRows } from '../../utils/useGridVisibleRows';
|
|
16
16
|
|
|
17
17
|
const getSelectionModelPropValue = (selectionModelProp, prevSelectionModel) => {
|
|
18
18
|
if (selectionModelProp == null) {
|
|
@@ -38,8 +38,10 @@ export const selectionStateInitializer = (state, props) => {
|
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
40
|
/**
|
|
41
|
-
* @requires useGridRows (state, method)
|
|
42
|
-
* @requires useGridParamsApi (method)
|
|
41
|
+
* @requires useGridRows (state, method) - can be after
|
|
42
|
+
* @requires useGridParamsApi (method) - can be after
|
|
43
|
+
* @requires useGridFocus (state) - can be after
|
|
44
|
+
* @requires useGridKeyboardNavigation (`cellKeyDown` event must first be consumed by it)
|
|
43
45
|
*/
|
|
44
46
|
|
|
45
47
|
export const useGridSelection = (apiRef, props) => {
|
|
@@ -64,7 +66,8 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
64
66
|
paginationMode
|
|
65
67
|
} = props;
|
|
66
68
|
const canHaveMultipleSelection = !disableMultipleSelection || checkboxSelection;
|
|
67
|
-
const
|
|
69
|
+
const visibleRows = useGridVisibleRows(apiRef, props);
|
|
70
|
+
const expandMouseRowRangeSelection = React.useCallback(id => {
|
|
68
71
|
var _lastRowToggled$curre;
|
|
69
72
|
|
|
70
73
|
let endId = id;
|
|
@@ -171,12 +174,13 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
171
174
|
return;
|
|
172
175
|
}
|
|
173
176
|
|
|
174
|
-
logger.debug(`Expanding selection from row ${startId} to row ${endId}`);
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
const
|
|
177
|
+
logger.debug(`Expanding selection from row ${startId} to row ${endId}`); // Using rows from all pages allow to select a range across several pages
|
|
178
|
+
|
|
179
|
+
const allPagesRowIds = gridVisibleSortedRowIdsSelector(apiRef);
|
|
180
|
+
const startIndex = allPagesRowIds.indexOf(startId);
|
|
181
|
+
const endIndex = allPagesRowIds.indexOf(endId);
|
|
178
182
|
const [start, end] = startIndex > endIndex ? [endIndex, startIndex] : [startIndex, endIndex];
|
|
179
|
-
const rowsBetweenStartAndEnd =
|
|
183
|
+
const rowsBetweenStartAndEnd = allPagesRowIds.slice(start, end + 1);
|
|
180
184
|
apiRef.current.selectRows(rowsBetweenStartAndEnd, isSelected, resetSelection);
|
|
181
185
|
}, [apiRef, logger]);
|
|
182
186
|
const selectionApi = {
|
|
@@ -250,11 +254,11 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
250
254
|
}
|
|
251
255
|
|
|
252
256
|
if (event.shiftKey && (canHaveMultipleSelection || checkboxSelection)) {
|
|
253
|
-
|
|
257
|
+
expandMouseRowRangeSelection(params.id);
|
|
254
258
|
} else {
|
|
255
259
|
handleSingleRowSelection(params.id, event);
|
|
256
260
|
}
|
|
257
|
-
}, [disableSelectionOnClick, canHaveMultipleSelection, checkboxSelection, apiRef,
|
|
261
|
+
}, [disableSelectionOnClick, canHaveMultipleSelection, checkboxSelection, apiRef, expandMouseRowRangeSelection, handleSingleRowSelection]);
|
|
258
262
|
const preventSelectionOnShift = React.useCallback((params, event) => {
|
|
259
263
|
if (canHaveMultipleSelection && event.shiftKey) {
|
|
260
264
|
var _window$getSelection;
|
|
@@ -264,35 +268,78 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
264
268
|
}, [canHaveMultipleSelection]);
|
|
265
269
|
const handleRowSelectionCheckboxChange = React.useCallback((params, event) => {
|
|
266
270
|
if (event.nativeEvent.shiftKey) {
|
|
267
|
-
|
|
271
|
+
expandMouseRowRangeSelection(params.id);
|
|
268
272
|
} else {
|
|
269
273
|
apiRef.current.selectRow(params.id, params.value);
|
|
270
274
|
}
|
|
271
|
-
}, [apiRef,
|
|
275
|
+
}, [apiRef, expandMouseRowRangeSelection]);
|
|
272
276
|
const handleHeaderSelectionCheckboxChange = React.useCallback(params => {
|
|
273
277
|
const shouldLimitSelectionToCurrentPage = props.checkboxSelectionVisibleOnly && props.pagination;
|
|
274
278
|
const rowsToBeSelected = shouldLimitSelectionToCurrentPage ? gridPaginatedVisibleSortedGridRowIdsSelector(apiRef) : gridVisibleSortedRowIdsSelector(apiRef);
|
|
275
279
|
apiRef.current.selectRows(rowsToBeSelected, params.value);
|
|
276
280
|
}, [apiRef, props.checkboxSelectionVisibleOnly, props.pagination]);
|
|
277
281
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
278
|
-
//
|
|
282
|
+
// Get the most recent cell mode because it may have been changed by another listener
|
|
283
|
+
if (apiRef.current.getCellMode(params.id, params.field) === GridCellModes.Edit) {
|
|
284
|
+
return;
|
|
285
|
+
} // Ignore portal
|
|
279
286
|
// Do not apply shortcuts if the focus is not on the cell root component
|
|
280
|
-
|
|
281
|
-
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
if (!event.currentTarget.contains(event.target)) {
|
|
282
290
|
return;
|
|
283
|
-
}
|
|
291
|
+
}
|
|
284
292
|
|
|
293
|
+
if (isNavigationKey(event.key) && event.shiftKey) {
|
|
294
|
+
// The cell that has focus after the keyboard navigation
|
|
295
|
+
const focusCell = gridFocusCellSelector(apiRef);
|
|
285
296
|
|
|
286
|
-
|
|
287
|
-
|
|
297
|
+
if (focusCell && focusCell.id !== params.id) {
|
|
298
|
+
event.preventDefault();
|
|
299
|
+
const isNextRowSelected = apiRef.current.isRowSelected(focusCell.id);
|
|
288
300
|
|
|
289
|
-
|
|
290
|
-
|
|
301
|
+
if (!canHaveMultipleSelection) {
|
|
302
|
+
apiRef.current.selectRow(focusCell.id, !isNextRowSelected, true);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const newRowIndex = apiRef.current.getRowIndexRelativeToVisibleRows(focusCell.id);
|
|
307
|
+
const previousRowIndex = apiRef.current.getRowIndexRelativeToVisibleRows(params.id);
|
|
308
|
+
let start;
|
|
309
|
+
let end;
|
|
310
|
+
|
|
311
|
+
if (newRowIndex > previousRowIndex) {
|
|
312
|
+
if (isNextRowSelected) {
|
|
313
|
+
// We are navigating to the bottom of the page and adding selected rows
|
|
314
|
+
start = previousRowIndex;
|
|
315
|
+
end = newRowIndex - 1;
|
|
316
|
+
} else {
|
|
317
|
+
// We are navigating to the bottom of the page and removing selected rows
|
|
318
|
+
start = previousRowIndex;
|
|
319
|
+
end = newRowIndex;
|
|
320
|
+
}
|
|
321
|
+
} else {
|
|
322
|
+
// eslint-disable-next-line no-lonely-if
|
|
323
|
+
if (isNextRowSelected) {
|
|
324
|
+
// We are navigating to the top of the page and removing selected rows
|
|
325
|
+
start = newRowIndex + 1;
|
|
326
|
+
end = previousRowIndex;
|
|
327
|
+
} else {
|
|
328
|
+
// We are navigating to the top of the page and adding selected rows
|
|
329
|
+
start = newRowIndex;
|
|
330
|
+
end = previousRowIndex;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const rowsBetweenStartAndEnd = visibleRows.rows.slice(start, end + 1).map(row => row.id);
|
|
335
|
+
apiRef.current.selectRows(rowsBetweenStartAndEnd, !isNextRowSelected);
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
291
338
|
}
|
|
292
339
|
|
|
293
340
|
if (event.key === ' ' && event.shiftKey) {
|
|
294
341
|
event.preventDefault();
|
|
295
|
-
handleSingleRowSelection(
|
|
342
|
+
handleSingleRowSelection(params.id, event);
|
|
296
343
|
return;
|
|
297
344
|
}
|
|
298
345
|
|
|
@@ -300,7 +347,7 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
300
347
|
event.preventDefault();
|
|
301
348
|
selectRows(apiRef.current.getAllRowIds(), true);
|
|
302
349
|
}
|
|
303
|
-
}, [apiRef, handleSingleRowSelection, selectRows]);
|
|
350
|
+
}, [apiRef, handleSingleRowSelection, selectRows, visibleRows.rows, canHaveMultipleSelection]);
|
|
304
351
|
useGridApiEventHandler(apiRef, GridEvents.visibleRowsSet, removeOutdatedSelection);
|
|
305
352
|
useGridApiEventHandler(apiRef, GridEvents.cellClick, handleCellClick);
|
|
306
353
|
useGridApiEventHandler(apiRef, GridEvents.rowSelectionCheckboxChange, handleRowSelectionCheckboxChange);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
4
|
-
import {
|
|
4
|
+
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
5
5
|
import { getDataGridUtilityClass } from '../../../constants';
|
|
6
6
|
import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../../../colDef';
|
|
7
7
|
|
|
@@ -43,5 +43,5 @@ export const useGridSelectionPreProcessors = (apiRef, props) => {
|
|
|
43
43
|
|
|
44
44
|
return columnsState;
|
|
45
45
|
}, [apiRef, classes, props.checkboxSelection]);
|
|
46
|
-
|
|
46
|
+
useGridRegisterPipeProcessor(apiRef, 'hydrateColumns', updateSelectionColumn);
|
|
47
47
|
};
|
|
@@ -16,9 +16,7 @@ export declare const gridSortedRowIdsSelector: import("../../../utils/createSele
|
|
|
16
16
|
*/
|
|
17
17
|
export declare const gridSortedRowEntriesSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, {
|
|
18
18
|
id: import("../../..").GridRowId;
|
|
19
|
-
model:
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
};
|
|
19
|
+
model: any;
|
|
22
20
|
}[]>;
|
|
23
21
|
/**
|
|
24
22
|
* Get the current sorting model.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { GridSortingModelApplier } from './gridSortingState';
|
|
2
|
-
import type { GridCellValue } from '../../../models';
|
|
3
2
|
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
4
3
|
import { GridStateCommunity } from '../../../models/gridStateCommunity';
|
|
5
4
|
import { GridComparatorFn, GridSortDirection, GridSortModel } from '../../../models/gridSortModel';
|
|
@@ -15,4 +14,4 @@ export declare const buildAggregatedSortingApplier: (sortModel: GridSortModel, a
|
|
|
15
14
|
export declare const getNextGridSortDirection: (sortingOrder: GridSortDirection[], current?: GridSortDirection) => GridSortDirection;
|
|
16
15
|
export declare const gridStringOrNumberComparator: GridComparatorFn;
|
|
17
16
|
export declare const gridNumberComparator: GridComparatorFn;
|
|
18
|
-
export declare const gridDateComparator:
|
|
17
|
+
export declare const gridDateComparator: GridComparatorFn;
|
|
@@ -12,7 +12,7 @@ import { gridRowIdsSelector, gridRowTreeSelector } from '../rows';
|
|
|
12
12
|
import { useFirstRender } from '../../utils/useFirstRender';
|
|
13
13
|
import { useGridRegisterStrategyProcessor, GRID_DEFAULT_STRATEGY } from '../../core/strategyProcessing';
|
|
14
14
|
import { buildAggregatedSortingApplier, mergeStateWithSortModel, getNextGridSortDirection, sanitizeSortModel } from './gridSortingUtils';
|
|
15
|
-
import {
|
|
15
|
+
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
16
16
|
export const sortingStateInitializer = (state, props) => {
|
|
17
17
|
var _ref, _props$sortModel, _props$initialState, _props$initialState$s;
|
|
18
18
|
|
|
@@ -188,8 +188,8 @@ export const useGridSorting = (apiRef, props) => {
|
|
|
188
188
|
const rowTree = gridRowTreeSelector(apiRef);
|
|
189
189
|
return params.sortRowList(Object.values(rowTree));
|
|
190
190
|
}, [apiRef]);
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
192
|
+
useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
193
193
|
useGridRegisterStrategyProcessor(apiRef, GRID_DEFAULT_STRATEGY, 'sorting', flatSortingMethod);
|
|
194
194
|
/**
|
|
195
195
|
* EVENTS
|
|
@@ -2,11 +2,11 @@ import * as React from 'react';
|
|
|
2
2
|
import { useGridApiMethod } from '../../utils';
|
|
3
3
|
export const useGridStatePersistence = apiRef => {
|
|
4
4
|
const exportState = React.useCallback(() => {
|
|
5
|
-
const stateToExport = apiRef.current.
|
|
5
|
+
const stateToExport = apiRef.current.unstable_applyPipeProcessors('exportState', {});
|
|
6
6
|
return stateToExport;
|
|
7
7
|
}, [apiRef]);
|
|
8
8
|
const restoreState = React.useCallback(stateToRestore => {
|
|
9
|
-
const response = apiRef.current.
|
|
9
|
+
const response = apiRef.current.unstable_applyPipeProcessors('restoreState', {
|
|
10
10
|
callbacks: []
|
|
11
11
|
}, {
|
|
12
12
|
stateToRestore
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DataGridProcessedProps } from '../../models/props/DataGridProps';
|
|
2
|
-
export declare const useGridRootProps: () => DataGridProcessedProps
|
|
2
|
+
export declare const useGridRootProps: () => DataGridProcessedProps<any>;
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { DataGridProcessedProps } from '../../models/props/DataGridProps';
|
|
3
3
|
import type { GridApiCommon, GridRowEntry } from '../../models';
|
|
4
4
|
export declare const getVisibleRows: <Api extends GridApiCommon>(apiRef: React.MutableRefObject<Api>, props: Pick<DataGridProcessedProps, 'pagination' | 'paginationMode'>) => {
|
|
5
|
-
rows: GridRowEntry[];
|
|
5
|
+
rows: GridRowEntry<any>[];
|
|
6
6
|
range: {
|
|
7
7
|
firstRowIndex: number;
|
|
8
8
|
lastRowIndex: number;
|
|
@@ -16,7 +16,7 @@ export declare const getVisibleRows: <Api extends GridApiCommon>(apiRef: React.M
|
|
|
16
16
|
* - If the row tree is flat, it only contains up to `state.pageSize` rows.
|
|
17
17
|
*/
|
|
18
18
|
export declare const useGridVisibleRows: <Api extends GridApiCommon>(apiRef: React.MutableRefObject<Api>, props: Pick<DataGridProcessedProps, 'pagination' | 'paginationMode'>) => {
|
|
19
|
-
rows: GridRowEntry[];
|
|
19
|
+
rows: GridRowEntry<any>[];
|
|
20
20
|
range: {
|
|
21
21
|
firstRowIndex: number;
|
|
22
22
|
lastRowIndex: number;
|
package/index.js
CHANGED
package/internals/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export { GridVirtualScrollerContent } from '../components/virtualization/GridVir
|
|
|
3
3
|
export { GridVirtualScrollerRenderZone } from '../components/virtualization/GridVirtualScrollerRenderZone';
|
|
4
4
|
export { GridColumnHeaders } from '../components/columnHeaders/GridColumnHeaders';
|
|
5
5
|
export { GridColumnHeadersInner } from '../components/columnHeaders/GridColumnHeadersInner';
|
|
6
|
-
export {
|
|
7
|
-
export type {
|
|
6
|
+
export { useGridRegisterPipeProcessor } from '../hooks/core/pipeProcessing';
|
|
7
|
+
export type { GridPipeProcessor } from '../hooks/core/pipeProcessing';
|
|
8
8
|
export { useGridRegisterStrategyProcessor } from '../hooks/core/strategyProcessing';
|
|
9
9
|
export type { GridStrategyProcessor } from '../hooks/core/strategyProcessing';
|
|
10
10
|
export { useGridInitialization } from '../hooks/core/useGridInitialization';
|
|
@@ -19,8 +19,7 @@ export { useGridPrintExport } from '../hooks/features/export/useGridPrintExport'
|
|
|
19
19
|
export { useGridFilter, filterStateInitializer } from '../hooks/features/filter/useGridFilter';
|
|
20
20
|
export type { GridAggregatedFilterItemApplier } from '../hooks/features/filter/gridFilterState';
|
|
21
21
|
export { useGridFocus, focusStateInitializer } from '../hooks/features/focus/useGridFocus';
|
|
22
|
-
export {
|
|
23
|
-
export { useGridKeyboardNavigation } from '../hooks/features/keyboard/useGridKeyboardNavigation';
|
|
22
|
+
export { useGridKeyboardNavigation } from '../hooks/features/keyboardNavigation/useGridKeyboardNavigation';
|
|
24
23
|
export { useGridPagination, paginationStateInitializer, } from '../hooks/features/pagination/useGridPagination';
|
|
25
24
|
export { useGridPreferencesPanel, preferencePanelStateInitializer, } from '../hooks/features/preferencesPanel/useGridPreferencesPanel';
|
|
26
25
|
export { useGridEditing as useGridEditing_new, editingStateInitializer as editingStateInitializer_new, } from '../hooks/features/editRows/useGridEditing.new';
|
|
@@ -43,8 +42,6 @@ export { useGridVirtualScroller } from '../hooks/features/virtualization/useGrid
|
|
|
43
42
|
export { useGridVisibleRows } from '../hooks/utils/useGridVisibleRows';
|
|
44
43
|
export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
|
|
45
44
|
export type { GridStateInitializer } from '../hooks/utils/useGridInitializeState';
|
|
46
|
-
export type { GridComparatorFn, GridSortCellParams } from '../models/gridSortModel';
|
|
47
|
-
export type { GridSortModelParams } from '../models/params/gridSortModelParams';
|
|
48
45
|
export type { GridExperimentalFeatures, DataGridPropsWithoutDefaultValue, DataGridPropsWithDefaultValues, DataGridPropsWithComplexDefaultValueAfterProcessing, DataGridPropsWithComplexDefaultValueBeforeProcessing, } from '../models/props/DataGridProps';
|
|
49
46
|
export { createSelector } from '../utils/createSelector';
|
|
50
47
|
export { findParentElementFromClassName } from '../utils/domUtils';
|
package/internals/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export { GridVirtualScrollerContent } from '../components/virtualization/GridVir
|
|
|
3
3
|
export { GridVirtualScrollerRenderZone } from '../components/virtualization/GridVirtualScrollerRenderZone';
|
|
4
4
|
export { GridColumnHeaders } from '../components/columnHeaders/GridColumnHeaders';
|
|
5
5
|
export { GridColumnHeadersInner } from '../components/columnHeaders/GridColumnHeadersInner';
|
|
6
|
-
export {
|
|
6
|
+
export { useGridRegisterPipeProcessor } from '../hooks/core/pipeProcessing';
|
|
7
7
|
export { useGridRegisterStrategyProcessor } from '../hooks/core/strategyProcessing';
|
|
8
8
|
export { useGridInitialization } from '../hooks/core/useGridInitialization';
|
|
9
9
|
export { useGridClipboard } from '../hooks/features/clipboard/useGridClipboard';
|
|
@@ -15,8 +15,7 @@ export { useGridCsvExport } from '../hooks/features/export/useGridCsvExport';
|
|
|
15
15
|
export { useGridPrintExport } from '../hooks/features/export/useGridPrintExport';
|
|
16
16
|
export { useGridFilter, filterStateInitializer } from '../hooks/features/filter/useGridFilter';
|
|
17
17
|
export { useGridFocus, focusStateInitializer } from '../hooks/features/focus/useGridFocus';
|
|
18
|
-
export {
|
|
19
|
-
export { useGridKeyboardNavigation } from '../hooks/features/keyboard/useGridKeyboardNavigation';
|
|
18
|
+
export { useGridKeyboardNavigation } from '../hooks/features/keyboardNavigation/useGridKeyboardNavigation';
|
|
20
19
|
export { useGridPagination, paginationStateInitializer } from '../hooks/features/pagination/useGridPagination';
|
|
21
20
|
export { useGridPreferencesPanel, preferencePanelStateInitializer } from '../hooks/features/preferencesPanel/useGridPreferencesPanel';
|
|
22
21
|
export { useGridEditing as useGridEditing_new, editingStateInitializer as editingStateInitializer_new } from '../hooks/features/editRows/useGridEditing.new';
|