@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
package/node/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js}
RENAMED
|
@@ -23,7 +23,7 @@ var _gridEditRowModel = require("../../../models/gridEditRowModel");
|
|
|
23
23
|
|
|
24
24
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _gridEditingSelectors = require("./gridEditingSelectors");
|
|
27
27
|
|
|
28
28
|
var _keyboardUtils = require("../../../utils/keyboardUtils");
|
|
29
29
|
|
|
@@ -147,7 +147,8 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
147
147
|
|
|
148
148
|
if (reason) {
|
|
149
149
|
const newParams = (0, _extends2.default)({}, params, {
|
|
150
|
-
reason
|
|
150
|
+
reason,
|
|
151
|
+
key: event.key
|
|
151
152
|
});
|
|
152
153
|
apiRef.current.publishEvent('cellEditStart', newParams, event);
|
|
153
154
|
}
|
|
@@ -157,14 +158,21 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
157
158
|
const {
|
|
158
159
|
id,
|
|
159
160
|
field,
|
|
160
|
-
reason
|
|
161
|
+
reason,
|
|
162
|
+
key
|
|
161
163
|
} = params;
|
|
162
164
|
const startCellEditModeParams = {
|
|
163
165
|
id,
|
|
164
166
|
field
|
|
165
167
|
};
|
|
166
168
|
|
|
167
|
-
if (reason === _gridEditCellParams.GridCellEditStartReasons.
|
|
169
|
+
if (reason === _gridEditCellParams.GridCellEditStartReasons.printableKeyDown) {
|
|
170
|
+
if (React.version.startsWith('18')) {
|
|
171
|
+
startCellEditModeParams.initialValue = key; // In React 17, cleaning the input is enough
|
|
172
|
+
} else {
|
|
173
|
+
startCellEditModeParams.deleteValue = true;
|
|
174
|
+
}
|
|
175
|
+
} else if (reason === _gridEditCellParams.GridCellEditStartReasons.deleteKeyDown) {
|
|
168
176
|
startCellEditModeParams.deleteValue = true;
|
|
169
177
|
}
|
|
170
178
|
|
|
@@ -188,7 +196,7 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
188
196
|
}
|
|
189
197
|
|
|
190
198
|
let ignoreModifications = reason === 'escapeKeyDown';
|
|
191
|
-
const editingState = (0,
|
|
199
|
+
const editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
|
|
192
200
|
|
|
193
201
|
if (editingState[id][field].isProcessingProps && !props.disableIgnoreModificationsIfProcessingProps) {
|
|
194
202
|
// The user wants to stop editing the cell but we can't wait for the props to be processed.
|
|
@@ -211,7 +219,7 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
211
219
|
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'cellEditStart', props.onCellEditStart);
|
|
212
220
|
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'cellEditStop', props.onCellEditStop);
|
|
213
221
|
const getCellMode = React.useCallback((id, field) => {
|
|
214
|
-
const editingState = (0,
|
|
222
|
+
const editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
|
|
215
223
|
const isEditing = editingState[id] && editingState[id][field];
|
|
216
224
|
return isEditing ? _gridEditRowModel.GridCellModes.Edit : _gridEditRowModel.GridCellModes.View;
|
|
217
225
|
}, [apiRef]);
|
|
@@ -293,10 +301,17 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
293
301
|
const {
|
|
294
302
|
id,
|
|
295
303
|
field,
|
|
296
|
-
deleteValue
|
|
304
|
+
deleteValue,
|
|
305
|
+
initialValue
|
|
297
306
|
} = params;
|
|
307
|
+
let newValue = apiRef.current.getCellValue(id, field);
|
|
308
|
+
|
|
309
|
+
if (deleteValue || initialValue) {
|
|
310
|
+
newValue = deleteValue ? '' : initialValue;
|
|
311
|
+
}
|
|
312
|
+
|
|
298
313
|
const newProps = {
|
|
299
|
-
value:
|
|
314
|
+
value: newValue,
|
|
300
315
|
error: false,
|
|
301
316
|
isProcessingProps: false
|
|
302
317
|
};
|
|
@@ -338,7 +353,7 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
338
353
|
return;
|
|
339
354
|
}
|
|
340
355
|
|
|
341
|
-
const editingState = (0,
|
|
356
|
+
const editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
|
|
342
357
|
const {
|
|
343
358
|
error,
|
|
344
359
|
isProcessingProps
|
|
@@ -406,7 +421,7 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
406
421
|
parsedValue = column.valueParser(value, apiRef.current.getCellParams(id, field));
|
|
407
422
|
}
|
|
408
423
|
|
|
409
|
-
let editingState = (0,
|
|
424
|
+
let editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
|
|
410
425
|
let newProps = (0, _extends2.default)({}, editingState[id][field], {
|
|
411
426
|
value: parsedValue,
|
|
412
427
|
changeReason: debounceMs ? 'debouncedSetEditCellValue' : 'setEditCellValue'
|
|
@@ -432,7 +447,7 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
432
447
|
return false;
|
|
433
448
|
}
|
|
434
449
|
|
|
435
|
-
editingState = (0,
|
|
450
|
+
editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
|
|
436
451
|
newProps = (0, _extends2.default)({}, newProps, {
|
|
437
452
|
isProcessingProps: false
|
|
438
453
|
}); // We don't update the value with the one coming from the props pre-processing
|
|
@@ -441,12 +456,12 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
441
456
|
|
|
442
457
|
newProps.value = column.preProcessEditCellProps ? editingState[id][field].value : parsedValue;
|
|
443
458
|
updateOrDeleteFieldState(id, field, newProps);
|
|
444
|
-
editingState = (0,
|
|
459
|
+
editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
|
|
445
460
|
return !((_editingState$id = editingState[id]) != null && (_editingState$id$fiel = _editingState$id[field]) != null && _editingState$id$fiel.error);
|
|
446
461
|
}, [apiRef, throwIfNotEditable, throwIfNotInMode, updateOrDeleteFieldState]);
|
|
447
462
|
const getRowWithUpdatedValuesFromCellEditing = React.useCallback((id, field) => {
|
|
448
463
|
const column = apiRef.current.getColumn(field);
|
|
449
|
-
const editingState = (0,
|
|
464
|
+
const editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
|
|
450
465
|
const {
|
|
451
466
|
value
|
|
452
467
|
} = editingState[id][field];
|
|
@@ -13,13 +13,13 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
13
13
|
|
|
14
14
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
15
15
|
|
|
16
|
-
var _useGridCellEditing = require("./useGridCellEditing
|
|
16
|
+
var _useGridCellEditing = require("./useGridCellEditing");
|
|
17
17
|
|
|
18
18
|
var _gridEditRowModel = require("../../../models/gridEditRowModel");
|
|
19
19
|
|
|
20
|
-
var _useGridRowEditing = require("./useGridRowEditing
|
|
20
|
+
var _useGridRowEditing = require("./useGridRowEditing");
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _gridEditingSelectors = require("./gridEditingSelectors");
|
|
23
23
|
|
|
24
24
|
var _gridRowsUtils = require("../rows/gridRowsUtils");
|
|
25
25
|
|
|
@@ -143,7 +143,7 @@ const useGridEditing = (apiRef, props) => {
|
|
|
143
143
|
return props.editMode === _gridEditRowModel.GridEditModes.Cell ? apiRef.current.unstable_getRowWithUpdatedValuesFromCellEditing(id, field) : apiRef.current.unstable_getRowWithUpdatedValuesFromRowEditing(id);
|
|
144
144
|
}, [apiRef, props.editMode]);
|
|
145
145
|
const getEditCellMeta = React.useCallback((id, field) => {
|
|
146
|
-
const editingState = (0,
|
|
146
|
+
const editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
|
|
147
147
|
return {
|
|
148
148
|
changeReason: editingState[id][field].changeReason
|
|
149
149
|
};
|
package/node/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js}
RENAMED
|
@@ -23,7 +23,7 @@ var _gridEditRowModel = require("../../../models/gridEditRowModel");
|
|
|
23
23
|
|
|
24
24
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _gridEditingSelectors = require("./gridEditingSelectors");
|
|
27
27
|
|
|
28
28
|
var _keyboardUtils = require("../../../utils/keyboardUtils");
|
|
29
29
|
|
|
@@ -204,6 +204,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
204
204
|
const rowParams = apiRef.current.getRowParams(params.id);
|
|
205
205
|
const newParams = (0, _extends2.default)({}, rowParams, {
|
|
206
206
|
field: params.field,
|
|
207
|
+
key: event.key,
|
|
207
208
|
reason
|
|
208
209
|
});
|
|
209
210
|
apiRef.current.publishEvent('rowEditStart', newParams, event);
|
|
@@ -214,14 +215,21 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
214
215
|
const {
|
|
215
216
|
id,
|
|
216
217
|
field,
|
|
217
|
-
reason
|
|
218
|
+
reason,
|
|
219
|
+
key
|
|
218
220
|
} = params;
|
|
219
221
|
const startRowEditModeParams = {
|
|
220
222
|
id,
|
|
221
223
|
fieldToFocus: field
|
|
222
224
|
};
|
|
223
225
|
|
|
224
|
-
if (reason === _gridRowParams.GridRowEditStartReasons.
|
|
226
|
+
if (reason === _gridRowParams.GridRowEditStartReasons.printableKeyDown) {
|
|
227
|
+
if (React.version.startsWith('18')) {
|
|
228
|
+
startRowEditModeParams.initialValue = key; // In React 17, cleaning the input is enough
|
|
229
|
+
} else {
|
|
230
|
+
startRowEditModeParams.deleteValue = !!field;
|
|
231
|
+
}
|
|
232
|
+
} else if (reason === _gridRowParams.GridRowEditStartReasons.deleteKeyDown) {
|
|
225
233
|
startRowEditModeParams.deleteValue = !!field;
|
|
226
234
|
}
|
|
227
235
|
|
|
@@ -245,7 +253,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
245
253
|
}
|
|
246
254
|
|
|
247
255
|
let ignoreModifications = reason === 'escapeKeyDown';
|
|
248
|
-
const editingState = (0,
|
|
256
|
+
const editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
|
|
249
257
|
|
|
250
258
|
if (!ignoreModifications && !props.disableIgnoreModificationsIfProcessingProps) {
|
|
251
259
|
// The user wants to stop editing the cell but we can't wait for the props to be processed.
|
|
@@ -275,7 +283,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
275
283
|
return _gridEditRowModel.GridRowModes.View;
|
|
276
284
|
}
|
|
277
285
|
|
|
278
|
-
const editingState = (0,
|
|
286
|
+
const editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
|
|
279
287
|
const isEditing = editingState[id] && Object.keys(editingState[id]).length > 0;
|
|
280
288
|
return isEditing ? _gridEditRowModel.GridRowModes.Edit : _gridEditRowModel.GridRowModes.View;
|
|
281
289
|
}, [apiRef, props.editMode]);
|
|
@@ -360,7 +368,8 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
360
368
|
const {
|
|
361
369
|
id,
|
|
362
370
|
fieldToFocus,
|
|
363
|
-
deleteValue
|
|
371
|
+
deleteValue,
|
|
372
|
+
initialValue
|
|
364
373
|
} = params;
|
|
365
374
|
const columnFields = (0, _gridColumnsSelector.gridColumnFieldsSelector)(apiRef);
|
|
366
375
|
const newProps = columnFields.reduce((acc, field) => {
|
|
@@ -370,9 +379,14 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
370
379
|
return acc;
|
|
371
380
|
}
|
|
372
381
|
|
|
373
|
-
|
|
382
|
+
let newValue = apiRef.current.getCellValue(id, field);
|
|
383
|
+
|
|
384
|
+
if (fieldToFocus === field && (deleteValue || initialValue)) {
|
|
385
|
+
newValue = deleteValue ? '' : initialValue;
|
|
386
|
+
}
|
|
387
|
+
|
|
374
388
|
acc[field] = {
|
|
375
|
-
value:
|
|
389
|
+
value: newValue,
|
|
376
390
|
error: false,
|
|
377
391
|
isProcessingProps: false
|
|
378
392
|
};
|
|
@@ -417,7 +431,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
417
431
|
return;
|
|
418
432
|
}
|
|
419
433
|
|
|
420
|
-
const editingState = (0,
|
|
434
|
+
const editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
|
|
421
435
|
const row = apiRef.current.getRow(id);
|
|
422
436
|
const isSomeFieldProcessingProps = Object.values(editingState[id]).some(fieldProps => fieldProps.isProcessingProps);
|
|
423
437
|
|
|
@@ -484,7 +498,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
484
498
|
parsedValue = column.valueParser(value, apiRef.current.getCellParams(id, field));
|
|
485
499
|
}
|
|
486
500
|
|
|
487
|
-
let editingState = (0,
|
|
501
|
+
let editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
|
|
488
502
|
let newProps = (0, _extends2.default)({}, editingState[id][field], {
|
|
489
503
|
value: parsedValue,
|
|
490
504
|
changeReason: debounceMs ? 'debouncedSetEditCellValue' : 'setEditCellValue'
|
|
@@ -519,7 +533,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
519
533
|
return;
|
|
520
534
|
}
|
|
521
535
|
|
|
522
|
-
editingState = (0,
|
|
536
|
+
editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
|
|
523
537
|
processedProps = (0, _extends2.default)({}, processedProps, {
|
|
524
538
|
isProcessingProps: false
|
|
525
539
|
}); // We don't reuse the value from the props pre-processing because when the
|
|
@@ -547,7 +561,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
547
561
|
isProcessingProps: true
|
|
548
562
|
});
|
|
549
563
|
updateOrDeleteFieldState(id, thisField, fieldProps);
|
|
550
|
-
editingState = (0,
|
|
564
|
+
editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
|
|
551
565
|
const _editingState$id2 = editingState[id],
|
|
552
566
|
otherFieldsProps = (0, _objectWithoutPropertiesLoose2.default)(_editingState$id2, [thisField].map(_toPropertyKey2.default));
|
|
553
567
|
const promise = Promise.resolve(fieldColumn.preProcessEditCellProps({
|
|
@@ -573,7 +587,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
573
587
|
});
|
|
574
588
|
Promise.all(promises).then(() => {
|
|
575
589
|
if (apiRef.current.getRowMode(id) === _gridEditRowModel.GridRowModes.Edit) {
|
|
576
|
-
editingState = (0,
|
|
590
|
+
editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
|
|
577
591
|
resolve(!editingState[id][field].error);
|
|
578
592
|
} else {
|
|
579
593
|
resolve(false);
|
|
@@ -582,7 +596,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
582
596
|
});
|
|
583
597
|
}, [apiRef, throwIfNotEditable, updateOrDeleteFieldState]);
|
|
584
598
|
const getRowWithUpdatedValuesFromRowEditing = React.useCallback(id => {
|
|
585
|
-
const editingState = (0,
|
|
599
|
+
const editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
|
|
586
600
|
const row = apiRef.current.getRow(id);
|
|
587
601
|
let rowUpdate = (0, _extends2.default)({}, row);
|
|
588
602
|
Object.entries(editingState[id]).forEach(([field, fieldProps]) => {
|
|
@@ -19,7 +19,7 @@ var _gridFilterSelector = require("../filter/gridFilterSelector");
|
|
|
19
19
|
|
|
20
20
|
var _gridColumnsSelector = require("../columns/gridColumnsSelector");
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _gridColumnGroupsSelector = require("../columnGrouping/gridColumnGroupsSelector");
|
|
23
23
|
|
|
24
24
|
var _gridClasses = require("../../../constants/gridClasses");
|
|
25
25
|
|
|
@@ -108,7 +108,7 @@ const useGridPrintExport = (apiRef, props) => {
|
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
const totalHeaderHeight = (0,
|
|
111
|
+
const totalHeaderHeight = (0, _gridColumnGroupsSelector.gridTotalHeaderHeightSelector)(apiRef);
|
|
112
112
|
const rowsMeta = (0, _gridRowsMetaSelector.gridRowsMetaSelector)(apiRef.current.state);
|
|
113
113
|
const gridRootElement = apiRef.current.rootElementRef.current;
|
|
114
114
|
const gridClone = gridRootElement.cloneNode(true);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.gridTabIndexStateSelector = exports.gridTabIndexColumnHeaderSelector = exports.gridTabIndexCellSelector = exports.gridFocusStateSelector = exports.gridFocusColumnHeaderSelector = exports.gridFocusCellSelector = void 0;
|
|
6
|
+
exports.unstable_gridTabIndexColumnGroupHeaderSelector = exports.unstable_gridFocusColumnGroupHeaderSelector = exports.gridTabIndexStateSelector = exports.gridTabIndexColumnHeaderSelector = exports.gridTabIndexCellSelector = exports.gridFocusStateSelector = exports.gridFocusColumnHeaderSelector = exports.gridFocusCellSelector = void 0;
|
|
7
7
|
|
|
8
8
|
var _createSelector = require("../../../utils/createSelector");
|
|
9
9
|
|
|
@@ -12,13 +12,19 @@ const gridFocusStateSelector = state => state.focus;
|
|
|
12
12
|
exports.gridFocusStateSelector = gridFocusStateSelector;
|
|
13
13
|
const gridFocusCellSelector = (0, _createSelector.createSelector)(gridFocusStateSelector, focusState => focusState.cell);
|
|
14
14
|
exports.gridFocusCellSelector = gridFocusCellSelector;
|
|
15
|
-
const gridFocusColumnHeaderSelector = (0, _createSelector.createSelector)(gridFocusStateSelector, focusState => focusState.columnHeader);
|
|
15
|
+
const gridFocusColumnHeaderSelector = (0, _createSelector.createSelector)(gridFocusStateSelector, focusState => focusState.columnHeader); // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
16
|
+
|
|
16
17
|
exports.gridFocusColumnHeaderSelector = gridFocusColumnHeaderSelector;
|
|
18
|
+
const unstable_gridFocusColumnGroupHeaderSelector = (0, _createSelector.createSelector)(gridFocusStateSelector, focusState => focusState.columnGroupHeader);
|
|
19
|
+
exports.unstable_gridFocusColumnGroupHeaderSelector = unstable_gridFocusColumnGroupHeaderSelector;
|
|
17
20
|
|
|
18
21
|
const gridTabIndexStateSelector = state => state.tabIndex;
|
|
19
22
|
|
|
20
23
|
exports.gridTabIndexStateSelector = gridTabIndexStateSelector;
|
|
21
24
|
const gridTabIndexCellSelector = (0, _createSelector.createSelector)(gridTabIndexStateSelector, state => state.cell);
|
|
22
25
|
exports.gridTabIndexCellSelector = gridTabIndexCellSelector;
|
|
23
|
-
const gridTabIndexColumnHeaderSelector = (0, _createSelector.createSelector)(gridTabIndexStateSelector, state => state.columnHeader);
|
|
24
|
-
|
|
26
|
+
const gridTabIndexColumnHeaderSelector = (0, _createSelector.createSelector)(gridTabIndexStateSelector, state => state.columnHeader); // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
27
|
+
|
|
28
|
+
exports.gridTabIndexColumnHeaderSelector = gridTabIndexColumnHeaderSelector;
|
|
29
|
+
const unstable_gridTabIndexColumnGroupHeaderSelector = (0, _createSelector.createSelector)(gridTabIndexStateSelector, state => state.columnGroupHeader);
|
|
30
|
+
exports.unstable_gridTabIndexColumnGroupHeaderSelector = unstable_gridTabIndexColumnGroupHeaderSelector;
|
|
@@ -36,11 +36,13 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
36
36
|
const focusStateInitializer = state => (0, _extends2.default)({}, state, {
|
|
37
37
|
focus: {
|
|
38
38
|
cell: null,
|
|
39
|
-
columnHeader: null
|
|
39
|
+
columnHeader: null,
|
|
40
|
+
columnGroupHeader: null
|
|
40
41
|
},
|
|
41
42
|
tabIndex: {
|
|
42
43
|
cell: null,
|
|
43
|
-
columnHeader: null
|
|
44
|
+
columnHeader: null,
|
|
45
|
+
columnGroupHeader: null
|
|
44
46
|
}
|
|
45
47
|
});
|
|
46
48
|
/**
|
|
@@ -78,14 +80,16 @@ const useGridFocus = (apiRef, props) => {
|
|
|
78
80
|
id,
|
|
79
81
|
field
|
|
80
82
|
},
|
|
81
|
-
columnHeader: null
|
|
83
|
+
columnHeader: null,
|
|
84
|
+
columnGroupHeader: null
|
|
82
85
|
},
|
|
83
86
|
focus: {
|
|
84
87
|
cell: {
|
|
85
88
|
id,
|
|
86
89
|
field
|
|
87
90
|
},
|
|
88
|
-
columnHeader: null
|
|
91
|
+
columnHeader: null,
|
|
92
|
+
columnGroupHeader: null
|
|
89
93
|
}
|
|
90
94
|
});
|
|
91
95
|
});
|
|
@@ -113,18 +117,50 @@ const useGridFocus = (apiRef, props) => {
|
|
|
113
117
|
columnHeader: {
|
|
114
118
|
field
|
|
115
119
|
},
|
|
116
|
-
cell: null
|
|
120
|
+
cell: null,
|
|
121
|
+
columnGroupHeader: null
|
|
117
122
|
},
|
|
118
123
|
focus: {
|
|
119
124
|
columnHeader: {
|
|
120
125
|
field
|
|
121
126
|
},
|
|
122
|
-
cell: null
|
|
127
|
+
cell: null,
|
|
128
|
+
columnGroupHeader: null
|
|
123
129
|
}
|
|
124
130
|
});
|
|
125
131
|
});
|
|
126
132
|
apiRef.current.forceUpdate();
|
|
127
133
|
}, [apiRef, logger, publishCellFocusOut]);
|
|
134
|
+
const setColumnGroupHeaderFocus = React.useCallback((field, depth, event = {}) => {
|
|
135
|
+
const cell = (0, _gridFocusStateSelector.gridFocusCellSelector)(apiRef);
|
|
136
|
+
|
|
137
|
+
if (cell) {
|
|
138
|
+
apiRef.current.publishEvent('cellFocusOut', apiRef.current.getCellParams(cell.id, cell.field), event);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
apiRef.current.setState(state => {
|
|
142
|
+
return (0, _extends2.default)({}, state, {
|
|
143
|
+
tabIndex: {
|
|
144
|
+
columnGroupHeader: {
|
|
145
|
+
field,
|
|
146
|
+
depth
|
|
147
|
+
},
|
|
148
|
+
columnHeader: null,
|
|
149
|
+
cell: null
|
|
150
|
+
},
|
|
151
|
+
focus: {
|
|
152
|
+
columnGroupHeader: {
|
|
153
|
+
field,
|
|
154
|
+
depth
|
|
155
|
+
},
|
|
156
|
+
columnHeader: null,
|
|
157
|
+
cell: null
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
apiRef.current.forceUpdate();
|
|
162
|
+
}, [apiRef]);
|
|
163
|
+
const getColumnGroupHeaderFocus = React.useCallback(() => (0, _gridFocusStateSelector.unstable_gridFocusColumnGroupHeaderSelector)(apiRef), [apiRef]);
|
|
128
164
|
const moveFocusToRelativeCell = React.useCallback((id, field, direction) => {
|
|
129
165
|
let columnIndexToFocus = apiRef.current.getColumnIndex(field);
|
|
130
166
|
let rowIndexToFocus = apiRef.current.getRowIndexRelativeToVisibleRows(id);
|
|
@@ -200,12 +236,29 @@ const useGridFocus = (apiRef, props) => {
|
|
|
200
236
|
|
|
201
237
|
apiRef.current.setColumnHeaderFocus(field, event);
|
|
202
238
|
}, [apiRef]);
|
|
239
|
+
const focussedColumnGroup = (0, _gridFocusStateSelector.unstable_gridFocusColumnGroupHeaderSelector)(apiRef);
|
|
240
|
+
const handleColumnGroupHeaderFocus = React.useCallback(({
|
|
241
|
+
fields,
|
|
242
|
+
depth
|
|
243
|
+
}, event) => {
|
|
244
|
+
if (event.target !== event.currentTarget) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (focussedColumnGroup !== null && focussedColumnGroup.depth === depth && fields.includes(focussedColumnGroup.field)) {
|
|
249
|
+
// This group cell has already been focused
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
apiRef.current.unstable_setColumnGroupHeaderFocus(fields[0], depth, event);
|
|
254
|
+
}, [apiRef, focussedColumnGroup]);
|
|
203
255
|
const handleBlur = React.useCallback(() => {
|
|
204
256
|
logger.debug(`Clearing focus`);
|
|
205
257
|
apiRef.current.setState(state => (0, _extends2.default)({}, state, {
|
|
206
258
|
focus: {
|
|
207
259
|
cell: null,
|
|
208
|
-
columnHeader: null
|
|
260
|
+
columnHeader: null,
|
|
261
|
+
columnGroupHeader: null
|
|
209
262
|
}
|
|
210
263
|
}));
|
|
211
264
|
}, [logger, apiRef]);
|
|
@@ -241,7 +294,8 @@ const useGridFocus = (apiRef, props) => {
|
|
|
241
294
|
apiRef.current.setState(state => (0, _extends2.default)({}, state, {
|
|
242
295
|
focus: {
|
|
243
296
|
cell: null,
|
|
244
|
-
columnHeader: null
|
|
297
|
+
columnHeader: null,
|
|
298
|
+
columnGroupHeader: null
|
|
245
299
|
}
|
|
246
300
|
}));
|
|
247
301
|
apiRef.current.forceUpdate(); // There's a focused cell but another element (not a cell) was clicked
|
|
@@ -268,7 +322,8 @@ const useGridFocus = (apiRef, props) => {
|
|
|
268
322
|
apiRef.current.setState(state => (0, _extends2.default)({}, state, {
|
|
269
323
|
focus: {
|
|
270
324
|
cell: null,
|
|
271
|
-
columnHeader: null
|
|
325
|
+
columnHeader: null,
|
|
326
|
+
columnGroupHeader: null
|
|
272
327
|
}
|
|
273
328
|
}));
|
|
274
329
|
}
|
|
@@ -276,7 +331,9 @@ const useGridFocus = (apiRef, props) => {
|
|
|
276
331
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, {
|
|
277
332
|
setCellFocus,
|
|
278
333
|
setColumnHeaderFocus,
|
|
279
|
-
unstable_moveFocusToRelativeCell: moveFocusToRelativeCell
|
|
334
|
+
unstable_moveFocusToRelativeCell: moveFocusToRelativeCell,
|
|
335
|
+
unstable_setColumnGroupHeaderFocus: setColumnGroupHeaderFocus,
|
|
336
|
+
unstable_getColumnGroupHeaderFocus: getColumnGroupHeaderFocus
|
|
280
337
|
}, 'GridFocusApi');
|
|
281
338
|
React.useEffect(() => {
|
|
282
339
|
const doc = (0, _utils.ownerDocument)(apiRef.current.rootElementRef.current);
|
|
@@ -291,6 +348,7 @@ const useGridFocus = (apiRef, props) => {
|
|
|
291
348
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
292
349
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellModeChange', handleCellModeChange);
|
|
293
350
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnHeaderFocus', handleColumnHeaderFocus);
|
|
351
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnGroupHeaderFocus', handleColumnGroupHeaderFocus);
|
|
294
352
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'rowsSet', handleRowSet);
|
|
295
353
|
};
|
|
296
354
|
|
|
@@ -56,15 +56,15 @@ Object.keys(_density).forEach(function (key) {
|
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
var
|
|
59
|
+
var _editing = require("./editing");
|
|
60
60
|
|
|
61
|
-
Object.keys(
|
|
61
|
+
Object.keys(_editing).forEach(function (key) {
|
|
62
62
|
if (key === "default" || key === "__esModule") return;
|
|
63
|
-
if (key in exports && exports[key] ===
|
|
63
|
+
if (key in exports && exports[key] === _editing[key]) return;
|
|
64
64
|
Object.defineProperty(exports, key, {
|
|
65
65
|
enumerable: true,
|
|
66
66
|
get: function () {
|
|
67
|
-
return
|
|
67
|
+
return _editing[key];
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
70
|
});
|
|
@@ -134,15 +134,15 @@ Object.keys(_rows).forEach(function (key) {
|
|
|
134
134
|
});
|
|
135
135
|
});
|
|
136
136
|
|
|
137
|
-
var
|
|
137
|
+
var _rowSelection = require("./rowSelection");
|
|
138
138
|
|
|
139
|
-
Object.keys(
|
|
139
|
+
Object.keys(_rowSelection).forEach(function (key) {
|
|
140
140
|
if (key === "default" || key === "__esModule") return;
|
|
141
|
-
if (key in exports && exports[key] ===
|
|
141
|
+
if (key in exports && exports[key] === _rowSelection[key]) return;
|
|
142
142
|
Object.defineProperty(exports, key, {
|
|
143
143
|
enumerable: true,
|
|
144
144
|
get: function () {
|
|
145
|
-
return
|
|
145
|
+
return _rowSelection[key];
|
|
146
146
|
}
|
|
147
147
|
});
|
|
148
148
|
});
|