@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
|
@@ -8,7 +8,7 @@ import { unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
|
8
8
|
import { useGridApiEventHandler, useGridApiOptionHandler, GridSignature } from '../../utils/useGridApiEventHandler';
|
|
9
9
|
import { GridEditModes, GridCellModes } from '../../../models/gridEditRowModel';
|
|
10
10
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
11
|
-
import { gridEditRowsStateSelector } from './
|
|
11
|
+
import { gridEditRowsStateSelector } from './gridEditingSelectors';
|
|
12
12
|
import { isPrintableKey } from '../../../utils/keyboardUtils';
|
|
13
13
|
import { buildWarning } from '../../../utils/warning';
|
|
14
14
|
import { gridRowsDataRowIdToIdLookupSelector } from '../rows/gridRowsSelector';
|
|
@@ -121,7 +121,8 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
121
121
|
|
|
122
122
|
if (reason) {
|
|
123
123
|
const newParams = _extends({}, params, {
|
|
124
|
-
reason
|
|
124
|
+
reason,
|
|
125
|
+
key: event.key
|
|
125
126
|
});
|
|
126
127
|
|
|
127
128
|
apiRef.current.publishEvent('cellEditStart', newParams, event);
|
|
@@ -132,14 +133,21 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
132
133
|
const {
|
|
133
134
|
id,
|
|
134
135
|
field,
|
|
135
|
-
reason
|
|
136
|
+
reason,
|
|
137
|
+
key
|
|
136
138
|
} = params;
|
|
137
139
|
const startCellEditModeParams = {
|
|
138
140
|
id,
|
|
139
141
|
field
|
|
140
142
|
};
|
|
141
143
|
|
|
142
|
-
if (reason === GridCellEditStartReasons.
|
|
144
|
+
if (reason === GridCellEditStartReasons.printableKeyDown) {
|
|
145
|
+
if (React.version.startsWith('18')) {
|
|
146
|
+
startCellEditModeParams.initialValue = key; // In React 17, cleaning the input is enough
|
|
147
|
+
} else {
|
|
148
|
+
startCellEditModeParams.deleteValue = true;
|
|
149
|
+
}
|
|
150
|
+
} else if (reason === GridCellEditStartReasons.deleteKeyDown) {
|
|
143
151
|
startCellEditModeParams.deleteValue = true;
|
|
144
152
|
}
|
|
145
153
|
|
|
@@ -270,10 +278,17 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
270
278
|
const {
|
|
271
279
|
id,
|
|
272
280
|
field,
|
|
273
|
-
deleteValue
|
|
281
|
+
deleteValue,
|
|
282
|
+
initialValue
|
|
274
283
|
} = params;
|
|
284
|
+
let newValue = apiRef.current.getCellValue(id, field);
|
|
285
|
+
|
|
286
|
+
if (deleteValue || initialValue) {
|
|
287
|
+
newValue = deleteValue ? '' : initialValue;
|
|
288
|
+
}
|
|
289
|
+
|
|
275
290
|
const newProps = {
|
|
276
|
-
value:
|
|
291
|
+
value: newValue,
|
|
277
292
|
error: false,
|
|
278
293
|
isProcessingProps: false
|
|
279
294
|
};
|
|
File without changes
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
4
|
-
import { useGridCellEditing } from './useGridCellEditing
|
|
4
|
+
import { useGridCellEditing } from './useGridCellEditing';
|
|
5
5
|
import { GridCellModes, GridEditModes } from '../../../models/gridEditRowModel';
|
|
6
|
-
import { useGridRowEditing } from './useGridRowEditing
|
|
7
|
-
import { gridEditRowsStateSelector } from './
|
|
6
|
+
import { useGridRowEditing } from './useGridRowEditing';
|
|
7
|
+
import { gridEditRowsStateSelector } from './gridEditingSelectors';
|
|
8
8
|
import { isAutoGeneratedRow } from '../rows/gridRowsUtils';
|
|
9
9
|
export const editingStateInitializer = state => _extends({}, state, {
|
|
10
10
|
editRows: {}
|
package/hooks/features/{editRows/useGridRowEditing.new.d.ts → editing/useGridRowEditing.d.ts}
RENAMED
|
File without changes
|
|
@@ -8,7 +8,7 @@ import { unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
|
8
8
|
import { useGridApiEventHandler, useGridApiOptionHandler, GridSignature } from '../../utils/useGridApiEventHandler';
|
|
9
9
|
import { GridEditModes, GridRowModes } from '../../../models/gridEditRowModel';
|
|
10
10
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
11
|
-
import { gridEditRowsStateSelector } from './
|
|
11
|
+
import { gridEditRowsStateSelector } from './gridEditingSelectors';
|
|
12
12
|
import { isPrintableKey } from '../../../utils/keyboardUtils';
|
|
13
13
|
import { gridColumnFieldsSelector } from '../columns/gridColumnsSelector';
|
|
14
14
|
import { buildWarning } from '../../../utils/warning';
|
|
@@ -181,6 +181,7 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
181
181
|
|
|
182
182
|
const newParams = _extends({}, rowParams, {
|
|
183
183
|
field: params.field,
|
|
184
|
+
key: event.key,
|
|
184
185
|
reason
|
|
185
186
|
});
|
|
186
187
|
|
|
@@ -192,14 +193,21 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
192
193
|
const {
|
|
193
194
|
id,
|
|
194
195
|
field,
|
|
195
|
-
reason
|
|
196
|
+
reason,
|
|
197
|
+
key
|
|
196
198
|
} = params;
|
|
197
199
|
const startRowEditModeParams = {
|
|
198
200
|
id,
|
|
199
201
|
fieldToFocus: field
|
|
200
202
|
};
|
|
201
203
|
|
|
202
|
-
if (reason === GridRowEditStartReasons.
|
|
204
|
+
if (reason === GridRowEditStartReasons.printableKeyDown) {
|
|
205
|
+
if (React.version.startsWith('18')) {
|
|
206
|
+
startRowEditModeParams.initialValue = key; // In React 17, cleaning the input is enough
|
|
207
|
+
} else {
|
|
208
|
+
startRowEditModeParams.deleteValue = !!field;
|
|
209
|
+
}
|
|
210
|
+
} else if (reason === GridRowEditStartReasons.deleteKeyDown) {
|
|
203
211
|
startRowEditModeParams.deleteValue = !!field;
|
|
204
212
|
}
|
|
205
213
|
|
|
@@ -339,7 +347,8 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
339
347
|
const {
|
|
340
348
|
id,
|
|
341
349
|
fieldToFocus,
|
|
342
|
-
deleteValue
|
|
350
|
+
deleteValue,
|
|
351
|
+
initialValue
|
|
343
352
|
} = params;
|
|
344
353
|
const columnFields = gridColumnFieldsSelector(apiRef);
|
|
345
354
|
const newProps = columnFields.reduce((acc, field) => {
|
|
@@ -349,9 +358,14 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
349
358
|
return acc;
|
|
350
359
|
}
|
|
351
360
|
|
|
352
|
-
|
|
361
|
+
let newValue = apiRef.current.getCellValue(id, field);
|
|
362
|
+
|
|
363
|
+
if (fieldToFocus === field && (deleteValue || initialValue)) {
|
|
364
|
+
newValue = deleteValue ? '' : initialValue;
|
|
365
|
+
}
|
|
366
|
+
|
|
353
367
|
acc[field] = {
|
|
354
|
-
value:
|
|
368
|
+
value: newValue,
|
|
355
369
|
error: false,
|
|
356
370
|
isProcessingProps: false
|
|
357
371
|
};
|
|
@@ -4,7 +4,7 @@ import { ownerDocument } from '@mui/material/utils';
|
|
|
4
4
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
5
5
|
import { gridVisibleRowCountSelector } from '../filter/gridFilterSelector';
|
|
6
6
|
import { gridColumnDefinitionsSelector, gridColumnVisibilityModelSelector } from '../columns/gridColumnsSelector';
|
|
7
|
-
import {
|
|
7
|
+
import { gridTotalHeaderHeightSelector } from '../columnGrouping/gridColumnGroupsSelector';
|
|
8
8
|
import { gridClasses } from '../../../constants/gridClasses';
|
|
9
9
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
10
10
|
import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
|
|
@@ -83,7 +83,7 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
const totalHeaderHeight =
|
|
86
|
+
const totalHeaderHeight = gridTotalHeaderHeightSelector(apiRef);
|
|
87
87
|
const rowsMeta = gridRowsMetaSelector(apiRef.current.state);
|
|
88
88
|
const gridRootElement = apiRef.current.rootElementRef.current;
|
|
89
89
|
const gridClone = gridRootElement.cloneNode(true);
|
|
@@ -6,11 +6,17 @@ export declare type GridCellIdentifier = {
|
|
|
6
6
|
export declare type GridColumnIdentifier = {
|
|
7
7
|
field: string;
|
|
8
8
|
};
|
|
9
|
+
export declare type GridColumnGroupIdentifier = {
|
|
10
|
+
field: string;
|
|
11
|
+
depth: number;
|
|
12
|
+
};
|
|
9
13
|
export interface GridFocusState {
|
|
10
14
|
cell: GridCellIdentifier | null;
|
|
11
15
|
columnHeader: GridColumnIdentifier | null;
|
|
16
|
+
columnGroupHeader: GridColumnGroupIdentifier | null;
|
|
12
17
|
}
|
|
13
18
|
export interface GridTabIndexState {
|
|
14
19
|
cell: GridCellIdentifier | null;
|
|
15
20
|
columnHeader: GridColumnIdentifier | null;
|
|
21
|
+
columnGroupHeader: GridColumnGroupIdentifier | null;
|
|
16
22
|
}
|
|
@@ -3,6 +3,8 @@ import { GridFocusState, GridTabIndexState } from './gridFocusState';
|
|
|
3
3
|
export declare const gridFocusStateSelector: (state: GridStateCommunity) => GridFocusState;
|
|
4
4
|
export declare const gridFocusCellSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridCellIdentifier | null>;
|
|
5
5
|
export declare const gridFocusColumnHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
|
|
6
|
+
export declare const unstable_gridFocusColumnGroupHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnGroupIdentifier | null>;
|
|
6
7
|
export declare const gridTabIndexStateSelector: (state: GridStateCommunity) => GridTabIndexState;
|
|
7
8
|
export declare const gridTabIndexCellSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridCellIdentifier | null>;
|
|
8
9
|
export declare const gridTabIndexColumnHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
|
|
10
|
+
export declare const unstable_gridTabIndexColumnGroupHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnGroupIdentifier | null>;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { createSelector } from '../../../utils/createSelector';
|
|
2
2
|
export const gridFocusStateSelector = state => state.focus;
|
|
3
3
|
export const gridFocusCellSelector = createSelector(gridFocusStateSelector, focusState => focusState.cell);
|
|
4
|
-
export const gridFocusColumnHeaderSelector = createSelector(gridFocusStateSelector, focusState => focusState.columnHeader);
|
|
4
|
+
export const gridFocusColumnHeaderSelector = createSelector(gridFocusStateSelector, focusState => focusState.columnHeader); // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
5
|
+
|
|
6
|
+
export const unstable_gridFocusColumnGroupHeaderSelector = createSelector(gridFocusStateSelector, focusState => focusState.columnGroupHeader);
|
|
5
7
|
export const gridTabIndexStateSelector = state => state.tabIndex;
|
|
6
8
|
export const gridTabIndexCellSelector = createSelector(gridTabIndexStateSelector, state => state.cell);
|
|
7
|
-
export const gridTabIndexColumnHeaderSelector = createSelector(gridTabIndexStateSelector, state => state.columnHeader);
|
|
9
|
+
export const gridTabIndexColumnHeaderSelector = createSelector(gridTabIndexStateSelector, state => state.columnHeader); // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
10
|
+
|
|
11
|
+
export const unstable_gridTabIndexColumnGroupHeaderSelector = createSelector(gridTabIndexStateSelector, state => state.columnGroupHeader);
|
|
@@ -5,18 +5,20 @@ import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
|
5
5
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
6
6
|
import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
7
7
|
import { isNavigationKey } from '../../../utils/keyboardUtils';
|
|
8
|
-
import { gridFocusCellSelector } from './gridFocusStateSelector';
|
|
8
|
+
import { gridFocusCellSelector, unstable_gridFocusColumnGroupHeaderSelector } from './gridFocusStateSelector';
|
|
9
9
|
import { gridVisibleColumnDefinitionsSelector } from '../columns/gridColumnsSelector';
|
|
10
10
|
import { getVisibleRows } from '../../utils/useGridVisibleRows';
|
|
11
11
|
import { clamp } from '../../../utils/utils';
|
|
12
12
|
export const focusStateInitializer = state => _extends({}, state, {
|
|
13
13
|
focus: {
|
|
14
14
|
cell: null,
|
|
15
|
-
columnHeader: null
|
|
15
|
+
columnHeader: null,
|
|
16
|
+
columnGroupHeader: null
|
|
16
17
|
},
|
|
17
18
|
tabIndex: {
|
|
18
19
|
cell: null,
|
|
19
|
-
columnHeader: null
|
|
20
|
+
columnHeader: null,
|
|
21
|
+
columnGroupHeader: null
|
|
20
22
|
}
|
|
21
23
|
});
|
|
22
24
|
/**
|
|
@@ -51,14 +53,16 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
51
53
|
id,
|
|
52
54
|
field
|
|
53
55
|
},
|
|
54
|
-
columnHeader: null
|
|
56
|
+
columnHeader: null,
|
|
57
|
+
columnGroupHeader: null
|
|
55
58
|
},
|
|
56
59
|
focus: {
|
|
57
60
|
cell: {
|
|
58
61
|
id,
|
|
59
62
|
field
|
|
60
63
|
},
|
|
61
|
-
columnHeader: null
|
|
64
|
+
columnHeader: null,
|
|
65
|
+
columnGroupHeader: null
|
|
62
66
|
}
|
|
63
67
|
});
|
|
64
68
|
});
|
|
@@ -86,18 +90,50 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
86
90
|
columnHeader: {
|
|
87
91
|
field
|
|
88
92
|
},
|
|
89
|
-
cell: null
|
|
93
|
+
cell: null,
|
|
94
|
+
columnGroupHeader: null
|
|
90
95
|
},
|
|
91
96
|
focus: {
|
|
92
97
|
columnHeader: {
|
|
93
98
|
field
|
|
94
99
|
},
|
|
95
|
-
cell: null
|
|
100
|
+
cell: null,
|
|
101
|
+
columnGroupHeader: null
|
|
96
102
|
}
|
|
97
103
|
});
|
|
98
104
|
});
|
|
99
105
|
apiRef.current.forceUpdate();
|
|
100
106
|
}, [apiRef, logger, publishCellFocusOut]);
|
|
107
|
+
const setColumnGroupHeaderFocus = React.useCallback((field, depth, event = {}) => {
|
|
108
|
+
const cell = gridFocusCellSelector(apiRef);
|
|
109
|
+
|
|
110
|
+
if (cell) {
|
|
111
|
+
apiRef.current.publishEvent('cellFocusOut', apiRef.current.getCellParams(cell.id, cell.field), event);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
apiRef.current.setState(state => {
|
|
115
|
+
return _extends({}, state, {
|
|
116
|
+
tabIndex: {
|
|
117
|
+
columnGroupHeader: {
|
|
118
|
+
field,
|
|
119
|
+
depth
|
|
120
|
+
},
|
|
121
|
+
columnHeader: null,
|
|
122
|
+
cell: null
|
|
123
|
+
},
|
|
124
|
+
focus: {
|
|
125
|
+
columnGroupHeader: {
|
|
126
|
+
field,
|
|
127
|
+
depth
|
|
128
|
+
},
|
|
129
|
+
columnHeader: null,
|
|
130
|
+
cell: null
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
apiRef.current.forceUpdate();
|
|
135
|
+
}, [apiRef]);
|
|
136
|
+
const getColumnGroupHeaderFocus = React.useCallback(() => unstable_gridFocusColumnGroupHeaderSelector(apiRef), [apiRef]);
|
|
101
137
|
const moveFocusToRelativeCell = React.useCallback((id, field, direction) => {
|
|
102
138
|
let columnIndexToFocus = apiRef.current.getColumnIndex(field);
|
|
103
139
|
let rowIndexToFocus = apiRef.current.getRowIndexRelativeToVisibleRows(id);
|
|
@@ -173,12 +209,29 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
173
209
|
|
|
174
210
|
apiRef.current.setColumnHeaderFocus(field, event);
|
|
175
211
|
}, [apiRef]);
|
|
212
|
+
const focussedColumnGroup = unstable_gridFocusColumnGroupHeaderSelector(apiRef);
|
|
213
|
+
const handleColumnGroupHeaderFocus = React.useCallback(({
|
|
214
|
+
fields,
|
|
215
|
+
depth
|
|
216
|
+
}, event) => {
|
|
217
|
+
if (event.target !== event.currentTarget) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (focussedColumnGroup !== null && focussedColumnGroup.depth === depth && fields.includes(focussedColumnGroup.field)) {
|
|
222
|
+
// This group cell has already been focused
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
apiRef.current.unstable_setColumnGroupHeaderFocus(fields[0], depth, event);
|
|
227
|
+
}, [apiRef, focussedColumnGroup]);
|
|
176
228
|
const handleBlur = React.useCallback(() => {
|
|
177
229
|
logger.debug(`Clearing focus`);
|
|
178
230
|
apiRef.current.setState(state => _extends({}, state, {
|
|
179
231
|
focus: {
|
|
180
232
|
cell: null,
|
|
181
|
-
columnHeader: null
|
|
233
|
+
columnHeader: null,
|
|
234
|
+
columnGroupHeader: null
|
|
182
235
|
}
|
|
183
236
|
}));
|
|
184
237
|
}, [logger, apiRef]);
|
|
@@ -214,7 +267,8 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
214
267
|
apiRef.current.setState(state => _extends({}, state, {
|
|
215
268
|
focus: {
|
|
216
269
|
cell: null,
|
|
217
|
-
columnHeader: null
|
|
270
|
+
columnHeader: null,
|
|
271
|
+
columnGroupHeader: null
|
|
218
272
|
}
|
|
219
273
|
}));
|
|
220
274
|
apiRef.current.forceUpdate(); // There's a focused cell but another element (not a cell) was clicked
|
|
@@ -241,7 +295,8 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
241
295
|
apiRef.current.setState(state => _extends({}, state, {
|
|
242
296
|
focus: {
|
|
243
297
|
cell: null,
|
|
244
|
-
columnHeader: null
|
|
298
|
+
columnHeader: null,
|
|
299
|
+
columnGroupHeader: null
|
|
245
300
|
}
|
|
246
301
|
}));
|
|
247
302
|
}
|
|
@@ -249,7 +304,9 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
249
304
|
useGridApiMethod(apiRef, {
|
|
250
305
|
setCellFocus,
|
|
251
306
|
setColumnHeaderFocus,
|
|
252
|
-
unstable_moveFocusToRelativeCell: moveFocusToRelativeCell
|
|
307
|
+
unstable_moveFocusToRelativeCell: moveFocusToRelativeCell,
|
|
308
|
+
unstable_setColumnGroupHeaderFocus: setColumnGroupHeaderFocus,
|
|
309
|
+
unstable_getColumnGroupHeaderFocus: getColumnGroupHeaderFocus
|
|
253
310
|
}, 'GridFocusApi');
|
|
254
311
|
React.useEffect(() => {
|
|
255
312
|
const doc = ownerDocument(apiRef.current.rootElementRef.current);
|
|
@@ -264,5 +321,6 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
264
321
|
useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
265
322
|
useGridApiEventHandler(apiRef, 'cellModeChange', handleCellModeChange);
|
|
266
323
|
useGridApiEventHandler(apiRef, 'columnHeaderFocus', handleColumnHeaderFocus);
|
|
324
|
+
useGridApiEventHandler(apiRef, 'columnGroupHeaderFocus', handleColumnGroupHeaderFocus);
|
|
267
325
|
useGridApiEventHandler(apiRef, 'rowsSet', handleRowSet);
|
|
268
326
|
};
|
|
@@ -2,13 +2,13 @@ export * from './columnMenu';
|
|
|
2
2
|
export * from './columns';
|
|
3
3
|
export * from './columnGrouping';
|
|
4
4
|
export * from './density';
|
|
5
|
-
export * from './
|
|
5
|
+
export * from './editing';
|
|
6
6
|
export * from './filter';
|
|
7
7
|
export * from './focus';
|
|
8
8
|
export * from './pagination';
|
|
9
9
|
export * from './preferencesPanel';
|
|
10
10
|
export * from './rows';
|
|
11
|
-
export * from './
|
|
11
|
+
export * from './rowSelection';
|
|
12
12
|
export * from './sorting';
|
|
13
13
|
export * from './dimensions';
|
|
14
14
|
export * from './statePersistence';
|
package/hooks/features/index.js
CHANGED
|
@@ -3,13 +3,13 @@ export * from './columnMenu';
|
|
|
3
3
|
export * from './columns';
|
|
4
4
|
export * from './columnGrouping';
|
|
5
5
|
export * from './density';
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './editing';
|
|
7
7
|
export * from './filter';
|
|
8
8
|
export * from './focus';
|
|
9
9
|
export * from './pagination';
|
|
10
10
|
export * from './preferencesPanel';
|
|
11
11
|
export * from './rows';
|
|
12
|
-
export * from './
|
|
12
|
+
export * from './rowSelection';
|
|
13
13
|
export * from './sorting';
|
|
14
14
|
export * from './dimensions';
|
|
15
15
|
export * from './statePersistence';
|
|
@@ -10,6 +10,9 @@ import { GridCellModes } from '../../../models/gridEditRowModel';
|
|
|
10
10
|
import { isNavigationKey } from '../../../utils/keyboardUtils';
|
|
11
11
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPanelToggleField';
|
|
12
12
|
import { gridPinnedRowsSelector } from '../rows/gridRowsSelector';
|
|
13
|
+
import { unstable_gridFocusColumnGroupHeaderSelector } from '../focus';
|
|
14
|
+
import { gridColumnGroupsHeaderMaxDepthSelector } from '../columnGrouping/gridColumnGroupsSelector';
|
|
15
|
+
import { useGridSelector } from '../../utils/useGridSelector';
|
|
13
16
|
|
|
14
17
|
function enrichPageRowsWithPinnedRows(apiRef, rows) {
|
|
15
18
|
const pinnedRows = gridPinnedRowsSelector(apiRef) || {};
|
|
@@ -68,6 +71,16 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
68
71
|
const field = apiRef.current.getVisibleColumns()[colIndex].field;
|
|
69
72
|
apiRef.current.setColumnHeaderFocus(field, event);
|
|
70
73
|
}, [apiRef, logger]);
|
|
74
|
+
const goToGroupHeader = React.useCallback((colIndex, depth, event) => {
|
|
75
|
+
logger.debug(`Navigating to header col ${colIndex}`);
|
|
76
|
+
apiRef.current.scrollToIndexes({
|
|
77
|
+
colIndex
|
|
78
|
+
});
|
|
79
|
+
const {
|
|
80
|
+
field
|
|
81
|
+
} = apiRef.current.getVisibleColumns()[colIndex];
|
|
82
|
+
apiRef.current.unstable_setColumnGroupHeaderFocus(field, depth, event);
|
|
83
|
+
}, [apiRef, logger]);
|
|
71
84
|
const getRowIdFromIndex = React.useCallback(rowIndex => {
|
|
72
85
|
return currentPageRows[rowIndex].id;
|
|
73
86
|
}, [currentPageRows]);
|
|
@@ -239,6 +252,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
239
252
|
const lastRowIndexInPage = currentPageRows.length - 1;
|
|
240
253
|
const firstColIndex = 0;
|
|
241
254
|
const lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
|
|
255
|
+
const columnGroupMaxDepth = gridColumnGroupsHeaderMaxDepthSelector(apiRef);
|
|
242
256
|
let shouldPreventDefault = true;
|
|
243
257
|
|
|
244
258
|
switch (event.key) {
|
|
@@ -269,6 +283,15 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
269
283
|
break;
|
|
270
284
|
}
|
|
271
285
|
|
|
286
|
+
case 'ArrowUp':
|
|
287
|
+
{
|
|
288
|
+
if (columnGroupMaxDepth > 0) {
|
|
289
|
+
goToGroupHeader(colIndexBefore, columnGroupMaxDepth - 1, event);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
|
|
272
295
|
case 'PageDown':
|
|
273
296
|
{
|
|
274
297
|
if (firstRowIndexInPage !== null && lastRowIndexInPage !== null) {
|
|
@@ -314,7 +337,117 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
314
337
|
if (shouldPreventDefault) {
|
|
315
338
|
event.preventDefault();
|
|
316
339
|
}
|
|
317
|
-
}, [apiRef, currentPageRows, goToCell, goToHeader,
|
|
340
|
+
}, [apiRef, currentPageRows.length, goToCell, getRowIdFromIndex, goToHeader, goToGroupHeader]);
|
|
341
|
+
const focusedColumnGroup = useGridSelector(apiRef, unstable_gridFocusColumnGroupHeaderSelector);
|
|
342
|
+
const handleColumnGroupHeaderKeyDown = React.useCallback((params, event) => {
|
|
343
|
+
const dimensions = apiRef.current.getRootDimensions();
|
|
344
|
+
|
|
345
|
+
if (!dimensions) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (focusedColumnGroup === null) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const {
|
|
354
|
+
field: currentField,
|
|
355
|
+
depth: currentDepth
|
|
356
|
+
} = focusedColumnGroup;
|
|
357
|
+
const {
|
|
358
|
+
fields,
|
|
359
|
+
depth,
|
|
360
|
+
maxDepth
|
|
361
|
+
} = params;
|
|
362
|
+
const viewportPageSize = apiRef.current.unstable_getViewportPageSize();
|
|
363
|
+
const currentColIndex = apiRef.current.getColumnIndex(currentField);
|
|
364
|
+
const colIndexBefore = currentField ? apiRef.current.getColumnIndex(currentField) : 0;
|
|
365
|
+
const firstRowIndexInPage = 0;
|
|
366
|
+
const lastRowIndexInPage = currentPageRows.length - 1;
|
|
367
|
+
const firstColIndex = 0;
|
|
368
|
+
const lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
|
|
369
|
+
let shouldPreventDefault = true;
|
|
370
|
+
|
|
371
|
+
switch (event.key) {
|
|
372
|
+
case 'ArrowDown':
|
|
373
|
+
{
|
|
374
|
+
if (depth === maxDepth - 1) {
|
|
375
|
+
goToHeader(currentColIndex, event);
|
|
376
|
+
} else {
|
|
377
|
+
goToGroupHeader(currentColIndex, currentDepth + 1, event);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
case 'ArrowUp':
|
|
384
|
+
{
|
|
385
|
+
if (depth > 0) {
|
|
386
|
+
goToGroupHeader(currentColIndex, currentDepth - 1, event);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
case 'ArrowRight':
|
|
393
|
+
{
|
|
394
|
+
const remainingRightColumns = fields.length - fields.indexOf(currentField) - 1;
|
|
395
|
+
|
|
396
|
+
if (currentColIndex + remainingRightColumns + 1 <= lastColIndex) {
|
|
397
|
+
goToGroupHeader(currentColIndex + remainingRightColumns + 1, currentDepth, event);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
case 'ArrowLeft':
|
|
404
|
+
{
|
|
405
|
+
const remainingLeftColumns = fields.indexOf(currentField);
|
|
406
|
+
|
|
407
|
+
if (currentColIndex - remainingLeftColumns - 1 >= firstColIndex) {
|
|
408
|
+
goToGroupHeader(currentColIndex - remainingLeftColumns - 1, currentDepth, event);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
break;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
case 'PageDown':
|
|
415
|
+
{
|
|
416
|
+
if (firstRowIndexInPage !== null && lastRowIndexInPage !== null) {
|
|
417
|
+
goToCell(colIndexBefore, getRowIdFromIndex(Math.min(firstRowIndexInPage + viewportPageSize, lastRowIndexInPage)));
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
break;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
case 'Home':
|
|
424
|
+
{
|
|
425
|
+
goToGroupHeader(firstColIndex, currentDepth, event);
|
|
426
|
+
break;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
case 'End':
|
|
430
|
+
{
|
|
431
|
+
goToGroupHeader(lastColIndex, currentDepth, event);
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
case ' ':
|
|
436
|
+
{
|
|
437
|
+
// prevent Space event from scrolling
|
|
438
|
+
break;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
default:
|
|
442
|
+
{
|
|
443
|
+
shouldPreventDefault = false;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
if (shouldPreventDefault) {
|
|
448
|
+
event.preventDefault();
|
|
449
|
+
}
|
|
450
|
+
}, [apiRef, focusedColumnGroup, currentPageRows.length, goToHeader, goToGroupHeader, goToCell, getRowIdFromIndex]);
|
|
318
451
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
319
452
|
// Ignore portal
|
|
320
453
|
if (!event.currentTarget.contains(event.target)) {
|
|
@@ -330,5 +463,6 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
330
463
|
}, [apiRef]);
|
|
331
464
|
useGridApiEventHandler(apiRef, 'cellNavigationKeyDown', handleCellNavigationKeyDown);
|
|
332
465
|
useGridApiEventHandler(apiRef, 'columnHeaderKeyDown', handleColumnHeaderKeyDown);
|
|
466
|
+
useGridApiEventHandler(apiRef, 'columnGroupHeaderKeyDown', handleColumnGroupHeaderKeyDown);
|
|
333
467
|
useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
334
468
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GridStateCommunity } from '../../../models/gridStateCommunity';
|
|
2
2
|
import { GridRowId } from '../../../models/gridRows';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const gridRowSelectionStateSelector: (state: GridStateCommunity) => import("../../..").GridRowSelectionModel;
|
|
4
4
|
export declare const selectedGridRowsCountSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
|
|
5
5
|
export declare const selectedGridRowsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Map<GridRowId, import("../../../models/gridRows").GridValidRowModel>>;
|
|
6
6
|
export declare const selectedIdsLookupSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Record<GridRowId, GridRowId>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createSelector } from '../../../utils/createSelector';
|
|
2
|
+
import { gridRowsLookupSelector } from '../rows/gridRowsSelector';
|
|
3
|
+
export const gridRowSelectionStateSelector = state => state.rowSelection;
|
|
4
|
+
export const selectedGridRowsCountSelector = createSelector(gridRowSelectionStateSelector, selection => selection.length);
|
|
5
|
+
export const selectedGridRowsSelector = createSelector(gridRowSelectionStateSelector, gridRowsLookupSelector, (selectedRows, rowsLookup) => new Map(selectedRows.map(id => [id, rowsLookup[id]])));
|
|
6
|
+
export const selectedIdsLookupSelector = createSelector(gridRowSelectionStateSelector, selection => selection.reduce((lookup, rowId) => {
|
|
7
|
+
lookup[rowId] = rowId;
|
|
8
|
+
return lookup;
|
|
9
|
+
}, {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './gridRowSelectionSelector';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './gridRowSelectionSelector';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
3
|
+
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
4
|
+
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
5
|
+
export declare const rowSelectionStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'rowSelectionModel'>>;
|
|
6
|
+
/**
|
|
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)
|
|
11
|
+
*/
|
|
12
|
+
export declare const useGridRowSelection: (apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'checkboxSelection' | 'rowSelectionModel' | 'onRowSelectionModelChange' | 'disableMultipleRowSelection' | 'disableRowSelectionOnClick' | 'isRowSelectable' | 'checkboxSelectionVisibleOnly' | 'pagination' | 'paginationMode' | 'classes' | 'keepNonExistentRowsSelected'>) => void;
|