@mui/x-data-grid 6.0.0-alpha.2 → 6.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +493 -141
- package/DataGrid/DataGrid.js +14 -34
- package/DataGrid/useDataGridComponent.js +8 -14
- package/DataGrid/useDataGridProps.js +3 -3
- package/colDef/gridCheckboxSelectionColDef.js +1 -1
- package/colDef/gridNumericOperators.d.ts +1 -1
- package/colDef/gridSingleSelectOperators.d.ts +1 -1
- package/colDef/gridStringOperators.d.ts +1 -1
- package/components/GridFooter.js +1 -1
- package/components/GridRow.js +2 -2
- package/components/base/GridBody.js +2 -2
- package/components/cell/GridEditInputCell.js +3 -8
- package/components/cell/GridEditSingleSelectCell.js +6 -38
- package/components/columnHeaders/GridColumnGroupHeader.d.ts +2 -0
- package/components/columnHeaders/GridColumnGroupHeader.js +32 -5
- package/components/columnSelection/GridHeaderCheckbox.js +3 -3
- package/components/containers/GridRoot.js +4 -3
- package/components/panel/GridColumnsPanel.d.ts +2 -0
- package/components/panel/GridColumnsPanel.js +10 -4
- package/components/panel/filterPanel/GridFilterForm.d.ts +12 -0
- package/components/panel/filterPanel/GridFilterForm.js +29 -7
- package/components/panel/filterPanel/GridFilterPanel.d.ts +12 -0
- package/components/panel/filterPanel/GridFilterPanel.js +64 -19
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +1 -1
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +1 -1
- package/hooks/core/strategyProcessing/useGridRegisterStrategyProcessor.d.ts +1 -1
- package/hooks/core/useGridInitialization.d.ts +1 -1
- package/hooks/core/useGridStateInitialization.d.ts +1 -1
- package/hooks/features/columnGrouping/gridColumnGroupsInterfaces.d.ts +10 -1
- package/hooks/features/columnGrouping/gridColumnGroupsSelector.d.ts +6 -0
- package/hooks/features/columnGrouping/gridColumnGroupsSelector.js +34 -1
- package/hooks/features/columnGrouping/gridColumnGroupsUtils.d.ts +15 -0
- package/hooks/features/columnGrouping/gridColumnGroupsUtils.js +89 -0
- package/hooks/features/columnGrouping/useGridColumnGrouping.d.ts +1 -15
- package/hooks/features/columnGrouping/useGridColumnGrouping.js +66 -66
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +60 -116
- package/hooks/features/density/densitySelector.d.ts +0 -2
- package/hooks/features/density/densitySelector.js +1 -3
- package/hooks/features/density/densityState.d.ts +0 -1
- package/hooks/features/density/useGridDensity.d.ts +1 -1
- package/hooks/features/density/useGridDensity.js +9 -45
- package/hooks/features/dimensions/useGridDimensions.js +3 -2
- package/hooks/features/{editRows/gridEditRowsSelector.d.ts → editing/gridEditingSelectors.d.ts} +0 -0
- package/hooks/features/{editRows/gridEditRowsSelector.js → editing/gridEditingSelectors.js} +0 -0
- package/hooks/features/editing/index.d.ts +1 -0
- package/hooks/features/editing/index.js +1 -0
- package/hooks/features/{editRows/useGridCellEditing.new.d.ts → editing/useGridCellEditing.d.ts} +0 -0
- package/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js} +21 -6
- package/hooks/features/{editRows/useGridEditing.new.d.ts → editing/useGridEditing.d.ts} +0 -0
- package/hooks/features/{editRows/useGridEditing.new.js → editing/useGridEditing.js} +3 -3
- package/hooks/features/{editRows/useGridRowEditing.new.d.ts → editing/useGridRowEditing.d.ts} +0 -0
- package/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js} +20 -6
- package/hooks/features/export/useGridPrintExport.js +2 -2
- package/hooks/features/focus/gridFocusState.d.ts +6 -0
- package/hooks/features/focus/gridFocusStateSelector.d.ts +2 -0
- package/hooks/features/focus/gridFocusStateSelector.js +6 -2
- package/hooks/features/focus/useGridFocus.js +69 -11
- package/hooks/features/index.d.ts +2 -2
- package/hooks/features/index.js +2 -2
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +135 -1
- package/hooks/features/{selection/gridSelectionSelector.d.ts → rowSelection/gridRowSelectionSelector.d.ts} +1 -1
- package/hooks/features/rowSelection/gridRowSelectionSelector.js +9 -0
- package/hooks/features/rowSelection/index.d.ts +1 -0
- package/hooks/features/rowSelection/index.js +1 -0
- package/hooks/features/rowSelection/useGridRowSelection.d.ts +12 -0
- package/hooks/features/{selection/useGridSelection.js → rowSelection/useGridRowSelection.js} +37 -37
- package/hooks/features/{selection/useGridSelectionPreProcessors.d.ts → rowSelection/useGridRowSelectionPreProcessors.d.ts} +1 -1
- package/hooks/features/{selection/useGridSelectionPreProcessors.js → rowSelection/useGridRowSelectionPreProcessors.js} +1 -1
- package/hooks/features/rows/gridRowsInterfaces.d.ts +4 -0
- package/hooks/features/rows/gridRowsUtils.d.ts +1 -1
- package/hooks/features/rows/gridRowsUtils.js +5 -2
- package/hooks/features/rows/useGridRows.js +23 -7
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +2 -2
- package/hooks/utils/useGridApi.d.ts +1 -1
- package/hooks/utils/useGridApiEventHandler.d.ts +2 -2
- package/hooks/utils/useGridApiRef.d.ts +1 -1
- package/hooks/utils/useGridInitializeState.d.ts +1 -1
- package/hooks/utils/useGridNativeEventListener.d.ts +1 -1
- package/hooks/utils/useGridSelector.d.ts +1 -1
- package/hooks/utils/useGridState.d.ts +1 -1
- package/hooks/utils/useGridVisibleRows.d.ts +2 -2
- package/index.js +1 -1
- package/internals/index.d.ts +3 -5
- package/internals/index.js +3 -5
- package/legacy/DataGrid/DataGrid.js +14 -34
- package/legacy/DataGrid/useDataGridComponent.js +8 -14
- package/legacy/DataGrid/useDataGridProps.js +3 -3
- package/legacy/colDef/gridCheckboxSelectionColDef.js +1 -1
- package/legacy/components/GridFooter.js +1 -1
- package/legacy/components/GridRow.js +2 -2
- package/legacy/components/base/GridBody.js +2 -2
- package/legacy/components/cell/GridEditInputCell.js +3 -8
- package/legacy/components/cell/GridEditSingleSelectCell.js +6 -52
- package/legacy/components/columnHeaders/GridColumnGroupHeader.js +46 -13
- package/legacy/components/columnSelection/GridHeaderCheckbox.js +3 -3
- package/legacy/components/containers/GridRoot.js +4 -3
- package/legacy/components/panel/GridColumnsPanel.js +10 -3
- package/legacy/components/panel/filterPanel/GridFilterForm.js +31 -7
- package/legacy/components/panel/filterPanel/GridFilterPanel.js +67 -18
- package/legacy/hooks/features/columnGrouping/gridColumnGroupsSelector.js +33 -1
- package/legacy/hooks/features/columnGrouping/gridColumnGroupsUtils.js +96 -0
- package/legacy/hooks/features/columnGrouping/useGridColumnGrouping.js +64 -64
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +70 -122
- package/legacy/hooks/features/density/densitySelector.js +0 -6
- package/legacy/hooks/features/density/useGridDensity.js +6 -44
- package/legacy/hooks/features/dimensions/useGridDimensions.js +3 -2
- package/legacy/hooks/features/{editRows/gridEditRowsSelector.js → editing/gridEditingSelectors.js} +0 -0
- package/legacy/hooks/features/editing/index.js +1 -0
- package/legacy/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js} +21 -6
- package/legacy/hooks/features/{editRows/useGridEditing.new.js → editing/useGridEditing.js} +3 -3
- package/legacy/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js} +20 -6
- package/legacy/hooks/features/export/useGridPrintExport.js +2 -2
- package/legacy/hooks/features/focus/gridFocusStateSelector.js +8 -0
- package/legacy/hooks/features/focus/useGridFocus.js +72 -11
- package/legacy/hooks/features/index.js +2 -2
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +129 -1
- package/legacy/hooks/features/rowSelection/gridRowSelectionSelector.js +19 -0
- package/legacy/hooks/features/rowSelection/index.js +1 -0
- package/legacy/hooks/features/{selection/useGridSelection.js → rowSelection/useGridRowSelection.js} +37 -37
- package/legacy/hooks/features/{selection/useGridSelectionPreProcessors.js → rowSelection/useGridRowSelectionPreProcessors.js} +1 -1
- package/legacy/hooks/features/rows/gridRowsUtils.js +5 -2
- package/legacy/hooks/features/rows/useGridRows.js +25 -7
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +2 -2
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +3 -5
- package/legacy/locales/trTR.js +17 -17
- package/legacy/models/api/{gridSelectionApi.js → gridRowSelectionApi.js} +0 -0
- package/legacy/models/api/index.js +1 -1
- package/legacy/models/{gridSelectionModel.js → gridRowSelectionModel.js} +0 -0
- package/legacy/models/index.js +1 -1
- package/{models/api/gridSelectionApi.js → legacy/models/params/gridColumnGroupHeaderParams.js} +0 -0
- package/legacy/models/params/gridEditCellParams.js +0 -4
- package/legacy/models/params/index.js +1 -0
- package/locales/trTR.js +17 -17
- package/models/api/gridApiCommon.d.ts +3 -6
- package/models/api/gridApiCommunity.d.ts +1 -7
- package/models/api/gridEditingApi.d.ts +36 -121
- package/models/api/gridFocusApi.d.ts +13 -0
- package/models/api/{gridSelectionApi.d.ts → gridRowSelectionApi.d.ts} +2 -2
- package/models/{gridSelectionModel.js → api/gridRowSelectionApi.js} +0 -0
- package/models/api/index.d.ts +2 -2
- package/models/api/index.js +1 -1
- package/models/colDef/gridColDef.d.ts +0 -8
- package/models/events/gridEventLookup.d.ts +30 -19
- package/models/gridColumnGrouping.d.ts +1 -26
- package/models/gridRowSelectionModel.d.ts +3 -0
- package/{modern/models/api/gridSelectionApi.js → models/gridRowSelectionModel.js} +0 -0
- package/models/gridStateCommunity.d.ts +2 -2
- package/models/index.d.ts +1 -1
- package/models/index.js +1 -1
- package/models/params/gridColumnGroupHeaderParams.d.ts +30 -0
- package/{modern/models/gridSelectionModel.js → models/params/gridColumnGroupHeaderParams.js} +0 -0
- package/models/params/gridEditCellParams.d.ts +4 -17
- package/models/params/gridEditCellParams.js +0 -4
- package/models/params/gridRowParams.d.ts +4 -4
- package/models/params/index.d.ts +1 -0
- package/models/params/index.js +1 -0
- package/models/props/DataGridProps.d.ts +8 -32
- package/modern/DataGrid/DataGrid.js +14 -34
- package/modern/DataGrid/useDataGridComponent.js +8 -12
- package/modern/DataGrid/useDataGridProps.js +3 -3
- package/modern/colDef/gridCheckboxSelectionColDef.js +1 -1
- package/modern/components/GridFooter.js +1 -1
- package/modern/components/GridRow.js +2 -2
- package/modern/components/base/GridBody.js +2 -2
- package/modern/components/cell/GridEditInputCell.js +3 -4
- package/modern/components/cell/GridEditSingleSelectCell.js +6 -34
- package/modern/components/columnHeaders/GridColumnGroupHeader.js +32 -5
- package/modern/components/columnSelection/GridHeaderCheckbox.js +3 -3
- package/modern/components/containers/GridRoot.js +4 -3
- package/modern/components/panel/GridColumnsPanel.js +10 -4
- package/modern/components/panel/filterPanel/GridFilterForm.js +29 -7
- package/modern/components/panel/filterPanel/GridFilterPanel.js +62 -17
- package/modern/hooks/features/columnGrouping/gridColumnGroupsSelector.js +14 -1
- package/modern/hooks/features/columnGrouping/gridColumnGroupsUtils.js +83 -0
- package/modern/hooks/features/columnGrouping/useGridColumnGrouping.js +50 -62
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +58 -98
- package/modern/hooks/features/density/densitySelector.js +1 -3
- package/modern/hooks/features/density/useGridDensity.js +9 -37
- package/modern/hooks/features/dimensions/useGridDimensions.js +3 -2
- package/modern/hooks/features/{editRows/gridEditRowsSelector.js → editing/gridEditingSelectors.js} +0 -0
- package/modern/hooks/features/editing/index.js +1 -0
- package/modern/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js} +21 -6
- package/modern/hooks/features/{editRows/useGridEditing.new.js → editing/useGridEditing.js} +3 -3
- package/modern/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js} +20 -6
- package/modern/hooks/features/export/useGridPrintExport.js +2 -2
- package/modern/hooks/features/focus/gridFocusStateSelector.js +6 -2
- package/modern/hooks/features/focus/useGridFocus.js +69 -11
- package/modern/hooks/features/index.js +2 -2
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +135 -1
- package/modern/hooks/features/rowSelection/gridRowSelectionSelector.js +9 -0
- package/modern/hooks/features/rowSelection/index.js +1 -0
- package/modern/hooks/features/{selection/useGridSelection.js → rowSelection/useGridRowSelection.js} +37 -37
- package/modern/hooks/features/{selection/useGridSelectionPreProcessors.js → rowSelection/useGridRowSelectionPreProcessors.js} +1 -1
- package/modern/hooks/features/rows/gridRowsUtils.js +5 -2
- package/modern/hooks/features/rows/useGridRows.js +23 -7
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +2 -2
- package/modern/index.js +1 -1
- package/modern/internals/index.js +3 -5
- package/modern/locales/trTR.js +17 -17
- package/modern/models/api/gridRowSelectionApi.js +1 -0
- package/modern/models/api/index.js +1 -1
- package/modern/models/gridRowSelectionModel.js +1 -0
- package/modern/models/index.js +1 -1
- package/modern/models/params/gridColumnGroupHeaderParams.js +1 -0
- package/modern/models/params/gridEditCellParams.js +0 -4
- package/modern/models/params/index.js +1 -0
- package/node/DataGrid/DataGrid.js +14 -34
- package/node/DataGrid/useDataGridComponent.js +9 -17
- package/node/DataGrid/useDataGridProps.js +3 -3
- package/node/colDef/gridCheckboxSelectionColDef.js +2 -2
- package/node/components/GridFooter.js +2 -2
- package/node/components/GridRow.js +2 -2
- package/node/components/base/GridBody.js +2 -2
- package/node/components/cell/GridEditInputCell.js +3 -9
- package/node/components/cell/GridEditSingleSelectCell.js +6 -38
- package/node/components/columnHeaders/GridColumnGroupHeader.js +32 -5
- package/node/components/columnSelection/GridHeaderCheckbox.js +3 -3
- package/node/components/containers/GridRoot.js +4 -2
- package/node/components/panel/GridColumnsPanel.js +10 -4
- package/node/components/panel/filterPanel/GridFilterForm.js +30 -7
- package/node/components/panel/filterPanel/GridFilterPanel.js +63 -19
- package/node/hooks/features/columnGrouping/gridColumnGroupsSelector.js +40 -3
- package/node/hooks/features/columnGrouping/gridColumnGroupsUtils.js +102 -0
- package/node/hooks/features/columnGrouping/useGridColumnGrouping.js +68 -71
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +57 -113
- package/node/hooks/features/density/densitySelector.js +2 -6
- package/node/hooks/features/density/useGridDensity.js +9 -48
- package/node/hooks/features/dimensions/useGridDimensions.js +3 -1
- package/node/hooks/features/{editRows/gridEditRowsSelector.js → editing/gridEditingSelectors.js} +0 -0
- package/node/hooks/features/{editRows → editing}/index.js +4 -4
- package/node/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js} +28 -13
- package/node/hooks/features/{editRows/useGridEditing.new.js → editing/useGridEditing.js} +4 -4
- package/node/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js} +28 -14
- package/node/hooks/features/export/useGridPrintExport.js +2 -2
- package/node/hooks/features/focus/gridFocusStateSelector.js +10 -4
- package/node/hooks/features/focus/useGridFocus.js +68 -10
- package/node/hooks/features/index.js +8 -8
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +138 -1
- package/node/hooks/features/{selection/gridSelectionSelector.js → rowSelection/gridRowSelectionSelector.js} +6 -6
- package/node/hooks/features/rowSelection/index.js +18 -0
- package/node/hooks/features/{selection/useGridSelection.js → rowSelection/useGridRowSelection.js} +43 -43
- package/node/hooks/features/{selection/useGridSelectionPreProcessors.js → rowSelection/useGridRowSelectionPreProcessors.js} +3 -3
- package/node/hooks/features/rows/gridRowsUtils.js +5 -2
- package/node/hooks/features/rows/useGridRows.js +23 -7
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/node/index.js +1 -1
- package/node/internals/index.js +23 -45
- package/node/locales/trTR.js +17 -17
- package/node/models/api/{gridSelectionApi.js → gridRowSelectionApi.js} +0 -0
- package/node/models/api/index.js +4 -4
- package/node/models/{gridSelectionModel.js → gridRowSelectionModel.js} +0 -0
- package/node/models/index.js +4 -4
- package/node/models/params/gridColumnGroupHeaderParams.js +5 -0
- package/node/models/params/gridEditCellParams.js +0 -3
- package/node/models/params/index.js +13 -0
- package/package.json +2 -2
- package/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.d.ts +0 -4
- package/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.js +0 -35
- package/hooks/features/editRows/index.d.ts +0 -1
- package/hooks/features/editRows/index.js +0 -1
- package/hooks/features/editRows/useGridCellEditing.old.d.ts +0 -4
- package/hooks/features/editRows/useGridCellEditing.old.js +0 -359
- package/hooks/features/editRows/useGridEditing.old.d.ts +0 -11
- package/hooks/features/editRows/useGridEditing.old.js +0 -167
- package/hooks/features/editRows/useGridRowEditing.old.d.ts +0 -4
- package/hooks/features/editRows/useGridRowEditing.old.js +0 -334
- package/hooks/features/selection/gridSelectionSelector.js +0 -9
- package/hooks/features/selection/index.d.ts +0 -1
- package/hooks/features/selection/index.js +0 -1
- package/hooks/features/selection/useGridSelection.d.ts +0 -12
- package/legacy/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.js +0 -35
- package/legacy/hooks/features/editRows/index.js +0 -1
- package/legacy/hooks/features/editRows/useGridCellEditing.old.js +0 -411
- package/legacy/hooks/features/editRows/useGridEditing.old.js +0 -184
- package/legacy/hooks/features/editRows/useGridRowEditing.old.js +0 -505
- package/legacy/hooks/features/selection/gridSelectionSelector.js +0 -19
- package/legacy/hooks/features/selection/index.js +0 -1
- package/models/gridSelectionModel.d.ts +0 -3
- package/modern/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.js +0 -29
- package/modern/hooks/features/editRows/index.js +0 -1
- package/modern/hooks/features/editRows/useGridCellEditing.old.js +0 -355
- package/modern/hooks/features/editRows/useGridEditing.old.js +0 -163
- package/modern/hooks/features/editRows/useGridRowEditing.old.js +0 -326
- package/modern/hooks/features/selection/gridSelectionSelector.js +0 -9
- package/modern/hooks/features/selection/index.js +0 -1
- package/node/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.js +0 -55
- package/node/hooks/features/editRows/useGridCellEditing.old.js +0 -380
- package/node/hooks/features/editRows/useGridEditing.old.js +0 -193
- package/node/hooks/features/editRows/useGridRowEditing.old.js +0 -358
- package/node/hooks/features/selection/index.js +0 -18
|
@@ -5,7 +5,7 @@ import { 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';
|
|
@@ -13,11 +13,13 @@ export var focusStateInitializer = function focusStateInitializer(state) {
|
|
|
13
13
|
return _extends({}, state, {
|
|
14
14
|
focus: {
|
|
15
15
|
cell: null,
|
|
16
|
-
columnHeader: null
|
|
16
|
+
columnHeader: null,
|
|
17
|
+
columnGroupHeader: null
|
|
17
18
|
},
|
|
18
19
|
tabIndex: {
|
|
19
20
|
cell: null,
|
|
20
|
-
columnHeader: null
|
|
21
|
+
columnHeader: null,
|
|
22
|
+
columnGroupHeader: null
|
|
21
23
|
}
|
|
22
24
|
});
|
|
23
25
|
};
|
|
@@ -53,14 +55,16 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
53
55
|
id: id,
|
|
54
56
|
field: field
|
|
55
57
|
},
|
|
56
|
-
columnHeader: null
|
|
58
|
+
columnHeader: null,
|
|
59
|
+
columnGroupHeader: null
|
|
57
60
|
},
|
|
58
61
|
focus: {
|
|
59
62
|
cell: {
|
|
60
63
|
id: id,
|
|
61
64
|
field: field
|
|
62
65
|
},
|
|
63
|
-
columnHeader: null
|
|
66
|
+
columnHeader: null,
|
|
67
|
+
columnGroupHeader: null
|
|
64
68
|
}
|
|
65
69
|
});
|
|
66
70
|
});
|
|
@@ -89,18 +93,53 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
89
93
|
columnHeader: {
|
|
90
94
|
field: field
|
|
91
95
|
},
|
|
92
|
-
cell: null
|
|
96
|
+
cell: null,
|
|
97
|
+
columnGroupHeader: null
|
|
93
98
|
},
|
|
94
99
|
focus: {
|
|
95
100
|
columnHeader: {
|
|
96
101
|
field: field
|
|
97
102
|
},
|
|
98
|
-
cell: null
|
|
103
|
+
cell: null,
|
|
104
|
+
columnGroupHeader: null
|
|
99
105
|
}
|
|
100
106
|
});
|
|
101
107
|
});
|
|
102
108
|
apiRef.current.forceUpdate();
|
|
103
109
|
}, [apiRef, logger, publishCellFocusOut]);
|
|
110
|
+
var setColumnGroupHeaderFocus = React.useCallback(function (field, depth) {
|
|
111
|
+
var event = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
112
|
+
var cell = gridFocusCellSelector(apiRef);
|
|
113
|
+
|
|
114
|
+
if (cell) {
|
|
115
|
+
apiRef.current.publishEvent('cellFocusOut', apiRef.current.getCellParams(cell.id, cell.field), event);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
apiRef.current.setState(function (state) {
|
|
119
|
+
return _extends({}, state, {
|
|
120
|
+
tabIndex: {
|
|
121
|
+
columnGroupHeader: {
|
|
122
|
+
field: field,
|
|
123
|
+
depth: depth
|
|
124
|
+
},
|
|
125
|
+
columnHeader: null,
|
|
126
|
+
cell: null
|
|
127
|
+
},
|
|
128
|
+
focus: {
|
|
129
|
+
columnGroupHeader: {
|
|
130
|
+
field: field,
|
|
131
|
+
depth: depth
|
|
132
|
+
},
|
|
133
|
+
columnHeader: null,
|
|
134
|
+
cell: null
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
apiRef.current.forceUpdate();
|
|
139
|
+
}, [apiRef]);
|
|
140
|
+
var getColumnGroupHeaderFocus = React.useCallback(function () {
|
|
141
|
+
return unstable_gridFocusColumnGroupHeaderSelector(apiRef);
|
|
142
|
+
}, [apiRef]);
|
|
104
143
|
var moveFocusToRelativeCell = React.useCallback(function (id, field, direction) {
|
|
105
144
|
var columnIndexToFocus = apiRef.current.getColumnIndex(field);
|
|
106
145
|
var rowIndexToFocus = apiRef.current.getRowIndexRelativeToVisibleRows(id);
|
|
@@ -175,13 +214,30 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
175
214
|
|
|
176
215
|
apiRef.current.setColumnHeaderFocus(field, event);
|
|
177
216
|
}, [apiRef]);
|
|
217
|
+
var focussedColumnGroup = unstable_gridFocusColumnGroupHeaderSelector(apiRef);
|
|
218
|
+
var handleColumnGroupHeaderFocus = React.useCallback(function (_ref3, event) {
|
|
219
|
+
var fields = _ref3.fields,
|
|
220
|
+
depth = _ref3.depth;
|
|
221
|
+
|
|
222
|
+
if (event.target !== event.currentTarget) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (focussedColumnGroup !== null && focussedColumnGroup.depth === depth && fields.includes(focussedColumnGroup.field)) {
|
|
227
|
+
// This group cell has already been focused
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
apiRef.current.unstable_setColumnGroupHeaderFocus(fields[0], depth, event);
|
|
232
|
+
}, [apiRef, focussedColumnGroup]);
|
|
178
233
|
var handleBlur = React.useCallback(function () {
|
|
179
234
|
logger.debug("Clearing focus");
|
|
180
235
|
apiRef.current.setState(function (state) {
|
|
181
236
|
return _extends({}, state, {
|
|
182
237
|
focus: {
|
|
183
238
|
cell: null,
|
|
184
|
-
columnHeader: null
|
|
239
|
+
columnHeader: null,
|
|
240
|
+
columnGroupHeader: null
|
|
185
241
|
}
|
|
186
242
|
});
|
|
187
243
|
});
|
|
@@ -219,7 +275,8 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
219
275
|
return _extends({}, state, {
|
|
220
276
|
focus: {
|
|
221
277
|
cell: null,
|
|
222
|
-
columnHeader: null
|
|
278
|
+
columnHeader: null,
|
|
279
|
+
columnGroupHeader: null
|
|
223
280
|
}
|
|
224
281
|
});
|
|
225
282
|
});
|
|
@@ -248,7 +305,8 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
248
305
|
return _extends({}, state, {
|
|
249
306
|
focus: {
|
|
250
307
|
cell: null,
|
|
251
|
-
columnHeader: null
|
|
308
|
+
columnHeader: null,
|
|
309
|
+
columnGroupHeader: null
|
|
252
310
|
}
|
|
253
311
|
});
|
|
254
312
|
});
|
|
@@ -257,7 +315,9 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
257
315
|
useGridApiMethod(apiRef, {
|
|
258
316
|
setCellFocus: setCellFocus,
|
|
259
317
|
setColumnHeaderFocus: setColumnHeaderFocus,
|
|
260
|
-
unstable_moveFocusToRelativeCell: moveFocusToRelativeCell
|
|
318
|
+
unstable_moveFocusToRelativeCell: moveFocusToRelativeCell,
|
|
319
|
+
unstable_setColumnGroupHeaderFocus: setColumnGroupHeaderFocus,
|
|
320
|
+
unstable_getColumnGroupHeaderFocus: getColumnGroupHeaderFocus
|
|
261
321
|
}, 'GridFocusApi');
|
|
262
322
|
React.useEffect(function () {
|
|
263
323
|
var doc = ownerDocument(apiRef.current.rootElementRef.current);
|
|
@@ -272,5 +332,6 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
272
332
|
useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
273
333
|
useGridApiEventHandler(apiRef, 'cellModeChange', handleCellModeChange);
|
|
274
334
|
useGridApiEventHandler(apiRef, 'columnHeaderFocus', handleColumnHeaderFocus);
|
|
335
|
+
useGridApiEventHandler(apiRef, 'columnGroupHeaderFocus', handleColumnGroupHeaderFocus);
|
|
275
336
|
useGridApiEventHandler(apiRef, 'rowsSet', handleRowSet);
|
|
276
337
|
};
|
|
@@ -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';
|
|
@@ -11,6 +11,9 @@ import { GridCellModes } from '../../../models/gridEditRowModel';
|
|
|
11
11
|
import { isNavigationKey } from '../../../utils/keyboardUtils';
|
|
12
12
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPanelToggleField';
|
|
13
13
|
import { gridPinnedRowsSelector } from '../rows/gridRowsSelector';
|
|
14
|
+
import { unstable_gridFocusColumnGroupHeaderSelector } from '../focus';
|
|
15
|
+
import { gridColumnGroupsHeaderMaxDepthSelector } from '../columnGrouping/gridColumnGroupsSelector';
|
|
16
|
+
import { useGridSelector } from '../../utils/useGridSelector';
|
|
14
17
|
|
|
15
18
|
function enrichPageRowsWithPinnedRows(apiRef, rows) {
|
|
16
19
|
var pinnedRows = gridPinnedRowsSelector(apiRef) || {};
|
|
@@ -74,6 +77,14 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
74
77
|
var field = apiRef.current.getVisibleColumns()[colIndex].field;
|
|
75
78
|
apiRef.current.setColumnHeaderFocus(field, event);
|
|
76
79
|
}, [apiRef, logger]);
|
|
80
|
+
var goToGroupHeader = React.useCallback(function (colIndex, depth, event) {
|
|
81
|
+
logger.debug("Navigating to header col ".concat(colIndex));
|
|
82
|
+
apiRef.current.scrollToIndexes({
|
|
83
|
+
colIndex: colIndex
|
|
84
|
+
});
|
|
85
|
+
var field = apiRef.current.getVisibleColumns()[colIndex].field;
|
|
86
|
+
apiRef.current.unstable_setColumnGroupHeaderFocus(field, depth, event);
|
|
87
|
+
}, [apiRef, logger]);
|
|
77
88
|
var getRowIdFromIndex = React.useCallback(function (rowIndex) {
|
|
78
89
|
return currentPageRows[rowIndex].id;
|
|
79
90
|
}, [currentPageRows]);
|
|
@@ -247,6 +258,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
247
258
|
var lastRowIndexInPage = currentPageRows.length - 1;
|
|
248
259
|
var firstColIndex = 0;
|
|
249
260
|
var lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
|
|
261
|
+
var columnGroupMaxDepth = gridColumnGroupsHeaderMaxDepthSelector(apiRef);
|
|
250
262
|
var shouldPreventDefault = true;
|
|
251
263
|
|
|
252
264
|
switch (event.key) {
|
|
@@ -277,6 +289,15 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
277
289
|
break;
|
|
278
290
|
}
|
|
279
291
|
|
|
292
|
+
case 'ArrowUp':
|
|
293
|
+
{
|
|
294
|
+
if (columnGroupMaxDepth > 0) {
|
|
295
|
+
goToGroupHeader(colIndexBefore, columnGroupMaxDepth - 1, event);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
|
|
280
301
|
case 'PageDown':
|
|
281
302
|
{
|
|
282
303
|
if (firstRowIndexInPage !== null && lastRowIndexInPage !== null) {
|
|
@@ -322,7 +343,113 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
322
343
|
if (shouldPreventDefault) {
|
|
323
344
|
event.preventDefault();
|
|
324
345
|
}
|
|
325
|
-
}, [apiRef, currentPageRows, goToCell, goToHeader,
|
|
346
|
+
}, [apiRef, currentPageRows.length, goToCell, getRowIdFromIndex, goToHeader, goToGroupHeader]);
|
|
347
|
+
var focusedColumnGroup = useGridSelector(apiRef, unstable_gridFocusColumnGroupHeaderSelector);
|
|
348
|
+
var handleColumnGroupHeaderKeyDown = React.useCallback(function (params, event) {
|
|
349
|
+
var dimensions = apiRef.current.getRootDimensions();
|
|
350
|
+
|
|
351
|
+
if (!dimensions) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (focusedColumnGroup === null) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
var currentField = focusedColumnGroup.field,
|
|
360
|
+
currentDepth = focusedColumnGroup.depth;
|
|
361
|
+
var fields = params.fields,
|
|
362
|
+
depth = params.depth,
|
|
363
|
+
maxDepth = params.maxDepth;
|
|
364
|
+
var viewportPageSize = apiRef.current.unstable_getViewportPageSize();
|
|
365
|
+
var currentColIndex = apiRef.current.getColumnIndex(currentField);
|
|
366
|
+
var colIndexBefore = currentField ? apiRef.current.getColumnIndex(currentField) : 0;
|
|
367
|
+
var firstRowIndexInPage = 0;
|
|
368
|
+
var lastRowIndexInPage = currentPageRows.length - 1;
|
|
369
|
+
var firstColIndex = 0;
|
|
370
|
+
var lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
|
|
371
|
+
var shouldPreventDefault = true;
|
|
372
|
+
|
|
373
|
+
switch (event.key) {
|
|
374
|
+
case 'ArrowDown':
|
|
375
|
+
{
|
|
376
|
+
if (depth === maxDepth - 1) {
|
|
377
|
+
goToHeader(currentColIndex, event);
|
|
378
|
+
} else {
|
|
379
|
+
goToGroupHeader(currentColIndex, currentDepth + 1, event);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
break;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
case 'ArrowUp':
|
|
386
|
+
{
|
|
387
|
+
if (depth > 0) {
|
|
388
|
+
goToGroupHeader(currentColIndex, currentDepth - 1, event);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
break;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
case 'ArrowRight':
|
|
395
|
+
{
|
|
396
|
+
var remainingRightColumns = fields.length - fields.indexOf(currentField) - 1;
|
|
397
|
+
|
|
398
|
+
if (currentColIndex + remainingRightColumns + 1 <= lastColIndex) {
|
|
399
|
+
goToGroupHeader(currentColIndex + remainingRightColumns + 1, currentDepth, event);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
case 'ArrowLeft':
|
|
406
|
+
{
|
|
407
|
+
var remainingLeftColumns = fields.indexOf(currentField);
|
|
408
|
+
|
|
409
|
+
if (currentColIndex - remainingLeftColumns - 1 >= firstColIndex) {
|
|
410
|
+
goToGroupHeader(currentColIndex - remainingLeftColumns - 1, currentDepth, event);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
case 'PageDown':
|
|
417
|
+
{
|
|
418
|
+
if (firstRowIndexInPage !== null && lastRowIndexInPage !== null) {
|
|
419
|
+
goToCell(colIndexBefore, getRowIdFromIndex(Math.min(firstRowIndexInPage + viewportPageSize, lastRowIndexInPage)));
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
break;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
case 'Home':
|
|
426
|
+
{
|
|
427
|
+
goToGroupHeader(firstColIndex, currentDepth, event);
|
|
428
|
+
break;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
case 'End':
|
|
432
|
+
{
|
|
433
|
+
goToGroupHeader(lastColIndex, currentDepth, event);
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
case ' ':
|
|
438
|
+
{
|
|
439
|
+
// prevent Space event from scrolling
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
default:
|
|
444
|
+
{
|
|
445
|
+
shouldPreventDefault = false;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
if (shouldPreventDefault) {
|
|
450
|
+
event.preventDefault();
|
|
451
|
+
}
|
|
452
|
+
}, [apiRef, focusedColumnGroup, currentPageRows.length, goToHeader, goToGroupHeader, goToCell, getRowIdFromIndex]);
|
|
326
453
|
var handleCellKeyDown = React.useCallback(function (params, event) {
|
|
327
454
|
// Ignore portal
|
|
328
455
|
if (!event.currentTarget.contains(event.target)) {
|
|
@@ -338,5 +465,6 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
338
465
|
}, [apiRef]);
|
|
339
466
|
useGridApiEventHandler(apiRef, 'cellNavigationKeyDown', handleCellNavigationKeyDown);
|
|
340
467
|
useGridApiEventHandler(apiRef, 'columnHeaderKeyDown', handleColumnHeaderKeyDown);
|
|
468
|
+
useGridApiEventHandler(apiRef, 'columnGroupHeaderKeyDown', handleColumnGroupHeaderKeyDown);
|
|
341
469
|
useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
342
470
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createSelector } from '../../../utils/createSelector';
|
|
2
|
+
import { gridRowsLookupSelector } from '../rows/gridRowsSelector';
|
|
3
|
+
export var gridRowSelectionStateSelector = function gridRowSelectionStateSelector(state) {
|
|
4
|
+
return state.rowSelection;
|
|
5
|
+
};
|
|
6
|
+
export var selectedGridRowsCountSelector = createSelector(gridRowSelectionStateSelector, function (selection) {
|
|
7
|
+
return selection.length;
|
|
8
|
+
});
|
|
9
|
+
export var selectedGridRowsSelector = createSelector(gridRowSelectionStateSelector, gridRowsLookupSelector, function (selectedRows, rowsLookup) {
|
|
10
|
+
return new Map(selectedRows.map(function (id) {
|
|
11
|
+
return [id, rowsLookup[id]];
|
|
12
|
+
}));
|
|
13
|
+
});
|
|
14
|
+
export var selectedIdsLookupSelector = createSelector(gridRowSelectionStateSelector, function (selection) {
|
|
15
|
+
return selection.reduce(function (lookup, rowId) {
|
|
16
|
+
lookup[rowId] = rowId;
|
|
17
|
+
return lookup;
|
|
18
|
+
}, {});
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './gridRowSelectionSelector';
|
package/legacy/hooks/features/{selection/useGridSelection.js → rowSelection/useGridRowSelection.js}
RENAMED
|
@@ -5,7 +5,7 @@ import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
|
5
5
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
6
6
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
7
7
|
import { gridRowsLookupSelector } from '../rows/gridRowsSelector';
|
|
8
|
-
import {
|
|
8
|
+
import { gridRowSelectionStateSelector, selectedGridRowsSelector, selectedIdsLookupSelector } from './gridRowSelectionSelector';
|
|
9
9
|
import { gridPaginatedVisibleSortedGridRowIdsSelector } from '../pagination';
|
|
10
10
|
import { gridFocusCellSelector } from '../focus/gridFocusStateSelector';
|
|
11
11
|
import { gridVisibleSortedRowIdsSelector } from '../filter/gridFilterSelector';
|
|
@@ -31,11 +31,11 @@ var getSelectionModelPropValue = function getSelectionModelPropValue(selectionMo
|
|
|
31
31
|
return [selectionModelProp];
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
export var
|
|
34
|
+
export var rowSelectionStateInitializer = function rowSelectionStateInitializer(state, props) {
|
|
35
35
|
var _getSelectionModelPro;
|
|
36
36
|
|
|
37
37
|
return _extends({}, state, {
|
|
38
|
-
|
|
38
|
+
rowSelection: (_getSelectionModelPro = getSelectionModelPropValue(props.rowSelectionModel)) != null ? _getSelectionModelPro : []
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
41
|
/**
|
|
@@ -45,26 +45,26 @@ export var selectionStateInitializer = function selectionStateInitializer(state,
|
|
|
45
45
|
* @requires useGridKeyboardNavigation (`cellKeyDown` event must first be consumed by it)
|
|
46
46
|
*/
|
|
47
47
|
|
|
48
|
-
export var
|
|
48
|
+
export var useGridRowSelection = function useGridRowSelection(apiRef, props) {
|
|
49
49
|
var logger = useGridLogger(apiRef, 'useGridSelection');
|
|
50
|
-
var
|
|
51
|
-
return getSelectionModelPropValue(props.
|
|
52
|
-
}, [apiRef, props.
|
|
50
|
+
var propRowSelectionModel = React.useMemo(function () {
|
|
51
|
+
return getSelectionModelPropValue(props.rowSelectionModel, gridRowSelectionStateSelector(apiRef.current.state));
|
|
52
|
+
}, [apiRef, props.rowSelectionModel]);
|
|
53
53
|
var lastRowToggled = React.useRef(null);
|
|
54
54
|
apiRef.current.unstable_registerControlState({
|
|
55
|
-
stateId: '
|
|
56
|
-
propModel:
|
|
57
|
-
propOnChange: props.
|
|
58
|
-
stateSelector:
|
|
59
|
-
changeEvent: '
|
|
55
|
+
stateId: 'rowSelection',
|
|
56
|
+
propModel: propRowSelectionModel,
|
|
57
|
+
propOnChange: props.onRowSelectionModelChange,
|
|
58
|
+
stateSelector: gridRowSelectionStateSelector,
|
|
59
|
+
changeEvent: 'rowSelectionChange'
|
|
60
60
|
});
|
|
61
61
|
var checkboxSelection = props.checkboxSelection,
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
disableMultipleRowSelection = props.disableMultipleRowSelection,
|
|
63
|
+
disableRowSelectionOnClick = props.disableRowSelectionOnClick,
|
|
64
64
|
pagination = props.pagination,
|
|
65
65
|
paginationMode = props.paginationMode,
|
|
66
66
|
propIsRowSelectable = props.isRowSelectable;
|
|
67
|
-
var canHaveMultipleSelection = !
|
|
67
|
+
var canHaveMultipleSelection = !disableMultipleRowSelection || checkboxSelection;
|
|
68
68
|
var visibleRows = useGridVisibleRows(apiRef, props);
|
|
69
69
|
var expandMouseRowRangeSelection = React.useCallback(function (id) {
|
|
70
70
|
var _lastRowToggled$curre;
|
|
@@ -103,21 +103,21 @@ export var useGridSelection = function useGridSelection(apiRef, props) {
|
|
|
103
103
|
* API METHODS
|
|
104
104
|
*/
|
|
105
105
|
|
|
106
|
-
var
|
|
107
|
-
var currentModel =
|
|
106
|
+
var setRowSelectionModel = React.useCallback(function (model) {
|
|
107
|
+
var currentModel = gridRowSelectionStateSelector(apiRef.current.state);
|
|
108
108
|
|
|
109
109
|
if (currentModel !== model) {
|
|
110
110
|
logger.debug("Setting selection model");
|
|
111
111
|
apiRef.current.setState(function (state) {
|
|
112
112
|
return _extends({}, state, {
|
|
113
|
-
|
|
113
|
+
rowSelection: model
|
|
114
114
|
});
|
|
115
115
|
});
|
|
116
116
|
apiRef.current.forceUpdate();
|
|
117
117
|
}
|
|
118
118
|
}, [apiRef, logger]);
|
|
119
119
|
var isRowSelected = React.useCallback(function (id) {
|
|
120
|
-
return
|
|
120
|
+
return gridRowSelectionStateSelector(apiRef.current.state).includes(id);
|
|
121
121
|
}, [apiRef]);
|
|
122
122
|
var isRowSelectable = React.useCallback(function (id) {
|
|
123
123
|
if (propIsRowSelectable && !propIsRowSelectable(apiRef.current.getRowParams(id))) {
|
|
@@ -147,10 +147,10 @@ export var useGridSelection = function useGridSelection(apiRef, props) {
|
|
|
147
147
|
|
|
148
148
|
if (resetSelection) {
|
|
149
149
|
logger.debug("Setting selection for row ".concat(id));
|
|
150
|
-
apiRef.current.
|
|
150
|
+
apiRef.current.setRowSelectionModel(isSelected ? [id] : []);
|
|
151
151
|
} else {
|
|
152
152
|
logger.debug("Toggling selection for row ".concat(id));
|
|
153
|
-
var selection =
|
|
153
|
+
var selection = gridRowSelectionStateSelector(apiRef.current.state);
|
|
154
154
|
var newSelection = selection.filter(function (el) {
|
|
155
155
|
return el !== id;
|
|
156
156
|
});
|
|
@@ -162,7 +162,7 @@ export var useGridSelection = function useGridSelection(apiRef, props) {
|
|
|
162
162
|
var isSelectionValid = newSelection.length < 2 || canHaveMultipleSelection;
|
|
163
163
|
|
|
164
164
|
if (isSelectionValid) {
|
|
165
|
-
apiRef.current.
|
|
165
|
+
apiRef.current.setRowSelectionModel(newSelection);
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
}, [apiRef, logger, canHaveMultipleSelection]);
|
|
@@ -194,7 +194,7 @@ export var useGridSelection = function useGridSelection(apiRef, props) {
|
|
|
194
194
|
var isSelectionValid = newSelection.length < 2 || canHaveMultipleSelection;
|
|
195
195
|
|
|
196
196
|
if (isSelectionValid) {
|
|
197
|
-
apiRef.current.
|
|
197
|
+
apiRef.current.setRowSelectionModel(newSelection);
|
|
198
198
|
}
|
|
199
199
|
}, [apiRef, logger, canHaveMultipleSelection]);
|
|
200
200
|
var selectRowRange = React.useCallback(function (_ref) {
|
|
@@ -225,7 +225,7 @@ export var useGridSelection = function useGridSelection(apiRef, props) {
|
|
|
225
225
|
selectRow: selectRow,
|
|
226
226
|
selectRows: selectRows,
|
|
227
227
|
selectRowRange: selectRowRange,
|
|
228
|
-
|
|
228
|
+
setRowSelectionModel: setRowSelectionModel,
|
|
229
229
|
getSelectedRows: getSelectedRows,
|
|
230
230
|
isRowSelected: isRowSelected,
|
|
231
231
|
isRowSelectable: isRowSelectable
|
|
@@ -240,7 +240,7 @@ export var useGridSelection = function useGridSelection(apiRef, props) {
|
|
|
240
240
|
return;
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
var currentSelection =
|
|
243
|
+
var currentSelection = gridRowSelectionStateSelector(apiRef.current.state);
|
|
244
244
|
var rowsLookup = gridRowsLookupSelector(apiRef); // We clone the existing object to avoid mutating the same object returned by the selector to others part of the project
|
|
245
245
|
|
|
246
246
|
var selectionLookup = _extends({}, selectedIdsLookupSelector(apiRef));
|
|
@@ -254,7 +254,7 @@ export var useGridSelection = function useGridSelection(apiRef, props) {
|
|
|
254
254
|
});
|
|
255
255
|
|
|
256
256
|
if (hasChanged) {
|
|
257
|
-
apiRef.current.
|
|
257
|
+
apiRef.current.setRowSelectionModel(Object.values(selectionLookup));
|
|
258
258
|
}
|
|
259
259
|
}, [apiRef, props.keepNonExistentRowsSelected]);
|
|
260
260
|
var handleSingleRowSelection = React.useCallback(function (id, event) {
|
|
@@ -274,7 +274,7 @@ export var useGridSelection = function useGridSelection(apiRef, props) {
|
|
|
274
274
|
}
|
|
275
275
|
}, [apiRef, canHaveMultipleSelection, checkboxSelection]);
|
|
276
276
|
var handleCellClick = React.useCallback(function (params, event) {
|
|
277
|
-
if (
|
|
277
|
+
if (disableRowSelectionOnClick) {
|
|
278
278
|
return;
|
|
279
279
|
}
|
|
280
280
|
|
|
@@ -305,7 +305,7 @@ export var useGridSelection = function useGridSelection(apiRef, props) {
|
|
|
305
305
|
} else {
|
|
306
306
|
handleSingleRowSelection(params.id, event);
|
|
307
307
|
}
|
|
308
|
-
}, [
|
|
308
|
+
}, [disableRowSelectionOnClick, canHaveMultipleSelection, checkboxSelection, apiRef, expandMouseRowRangeSelection, handleSingleRowSelection]);
|
|
309
309
|
var preventSelectionOnShift = React.useCallback(function (params, event) {
|
|
310
310
|
if (canHaveMultipleSelection && event.shiftKey) {
|
|
311
311
|
var _window$getSelection;
|
|
@@ -408,18 +408,18 @@ export var useGridSelection = function useGridSelection(apiRef, props) {
|
|
|
408
408
|
*/
|
|
409
409
|
|
|
410
410
|
React.useEffect(function () {
|
|
411
|
-
if (
|
|
412
|
-
apiRef.current.
|
|
411
|
+
if (propRowSelectionModel !== undefined) {
|
|
412
|
+
apiRef.current.setRowSelectionModel(propRowSelectionModel);
|
|
413
413
|
}
|
|
414
|
-
}, [apiRef,
|
|
415
|
-
var isStateControlled =
|
|
414
|
+
}, [apiRef, propRowSelectionModel]);
|
|
415
|
+
var isStateControlled = propRowSelectionModel != null;
|
|
416
416
|
React.useEffect(function () {
|
|
417
417
|
if (isStateControlled) {
|
|
418
418
|
return;
|
|
419
419
|
} // props.isRowSelectable changed
|
|
420
420
|
|
|
421
421
|
|
|
422
|
-
var currentSelection =
|
|
422
|
+
var currentSelection = gridRowSelectionStateSelector(apiRef.current.state);
|
|
423
423
|
|
|
424
424
|
if (isRowSelectable) {
|
|
425
425
|
var newSelection = currentSelection.filter(function (id) {
|
|
@@ -427,12 +427,12 @@ export var useGridSelection = function useGridSelection(apiRef, props) {
|
|
|
427
427
|
});
|
|
428
428
|
|
|
429
429
|
if (newSelection.length < currentSelection.length) {
|
|
430
|
-
apiRef.current.
|
|
430
|
+
apiRef.current.setRowSelectionModel(newSelection);
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
433
|
}, [apiRef, isRowSelectable, isStateControlled]);
|
|
434
434
|
React.useEffect(function () {
|
|
435
|
-
var currentSelection =
|
|
435
|
+
var currentSelection = gridRowSelectionStateSelector(apiRef.current.state);
|
|
436
436
|
|
|
437
437
|
if (!canHaveMultipleSelection && currentSelection.length > 1) {
|
|
438
438
|
var _getVisibleRows = getVisibleRows(apiRef, {
|
|
@@ -455,7 +455,7 @@ export var useGridSelection = function useGridSelection(apiRef, props) {
|
|
|
455
455
|
|
|
456
456
|
return isSelectable && currentPageRowsLookup[id]; // Check if the row is in the current page
|
|
457
457
|
});
|
|
458
|
-
apiRef.current.
|
|
458
|
+
apiRef.current.setRowSelectionModel(firstSelectableRow !== undefined ? [firstSelectableRow] : []);
|
|
459
459
|
}
|
|
460
|
-
}, [apiRef, canHaveMultipleSelection, checkboxSelection,
|
|
460
|
+
}, [apiRef, canHaveMultipleSelection, checkboxSelection, disableMultipleRowSelection, isRowSelectable, pagination, paginationMode]);
|
|
461
461
|
};
|
|
@@ -17,7 +17,7 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
|
17
17
|
}, [classes]);
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export var
|
|
20
|
+
export var useGridRowSelectionPreProcessors = function useGridRowSelectionPreProcessors(apiRef, props) {
|
|
21
21
|
var ownerState = {
|
|
22
22
|
classes: props.classes
|
|
23
23
|
};
|
|
@@ -39,7 +39,8 @@ export var getRowIdFromRowModel = function getRowIdFromRowModel(rowModel, getRow
|
|
|
39
39
|
export var createRowsInternalCache = function createRowsInternalCache(_ref) {
|
|
40
40
|
var rows = _ref.rows,
|
|
41
41
|
getRowId = _ref.getRowId,
|
|
42
|
-
loading = _ref.loading
|
|
42
|
+
loading = _ref.loading,
|
|
43
|
+
rowCount = _ref.rowCount;
|
|
43
44
|
var updates = {
|
|
44
45
|
type: 'full',
|
|
45
46
|
rows: []
|
|
@@ -60,6 +61,7 @@ export var createRowsInternalCache = function createRowsInternalCache(_ref) {
|
|
|
60
61
|
return {
|
|
61
62
|
rowsBeforePartialUpdates: rows,
|
|
62
63
|
loadingPropBeforePartialUpdates: loading,
|
|
64
|
+
rowCountPropBeforePartialUpdates: rowCount,
|
|
63
65
|
updates: updates,
|
|
64
66
|
dataRowIdToIdLookup: dataRowIdToIdLookup,
|
|
65
67
|
dataRowIdToModelLookup: dataRowIdToModelLookup
|
|
@@ -278,7 +280,8 @@ export var updateCacheWithNewRows = function updateCacheWithNewRows(_ref4) {
|
|
|
278
280
|
dataRowIdToIdLookup: dataRowIdToIdLookup,
|
|
279
281
|
updates: partialUpdates,
|
|
280
282
|
rowsBeforePartialUpdates: previousCache.rowsBeforePartialUpdates,
|
|
281
|
-
loadingPropBeforePartialUpdates: previousCache.loadingPropBeforePartialUpdates
|
|
283
|
+
loadingPropBeforePartialUpdates: previousCache.loadingPropBeforePartialUpdates,
|
|
284
|
+
rowCountPropBeforePartialUpdates: previousCache.rowCountPropBeforePartialUpdates
|
|
282
285
|
};
|
|
283
286
|
};
|
|
284
287
|
export function calculatePinnedRowsHeight(apiRef) {
|