@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
|
@@ -29,6 +29,12 @@ var _gridDetailPanelToggleField = require("../../../constants/gridDetailPanelTog
|
|
|
29
29
|
|
|
30
30
|
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
31
31
|
|
|
32
|
+
var _focus = require("../focus");
|
|
33
|
+
|
|
34
|
+
var _gridColumnGroupsSelector = require("../columnGrouping/gridColumnGroupsSelector");
|
|
35
|
+
|
|
36
|
+
var _useGridSelector = require("../../utils/useGridSelector");
|
|
37
|
+
|
|
32
38
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
39
|
|
|
34
40
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -90,6 +96,16 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
90
96
|
const field = apiRef.current.getVisibleColumns()[colIndex].field;
|
|
91
97
|
apiRef.current.setColumnHeaderFocus(field, event);
|
|
92
98
|
}, [apiRef, logger]);
|
|
99
|
+
const goToGroupHeader = React.useCallback((colIndex, depth, event) => {
|
|
100
|
+
logger.debug(`Navigating to header col ${colIndex}`);
|
|
101
|
+
apiRef.current.scrollToIndexes({
|
|
102
|
+
colIndex
|
|
103
|
+
});
|
|
104
|
+
const {
|
|
105
|
+
field
|
|
106
|
+
} = apiRef.current.getVisibleColumns()[colIndex];
|
|
107
|
+
apiRef.current.unstable_setColumnGroupHeaderFocus(field, depth, event);
|
|
108
|
+
}, [apiRef, logger]);
|
|
93
109
|
const getRowIdFromIndex = React.useCallback(rowIndex => {
|
|
94
110
|
return currentPageRows[rowIndex].id;
|
|
95
111
|
}, [currentPageRows]);
|
|
@@ -261,6 +277,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
261
277
|
const lastRowIndexInPage = currentPageRows.length - 1;
|
|
262
278
|
const firstColIndex = 0;
|
|
263
279
|
const lastColIndex = (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef).length - 1;
|
|
280
|
+
const columnGroupMaxDepth = (0, _gridColumnGroupsSelector.gridColumnGroupsHeaderMaxDepthSelector)(apiRef);
|
|
264
281
|
let shouldPreventDefault = true;
|
|
265
282
|
|
|
266
283
|
switch (event.key) {
|
|
@@ -291,6 +308,15 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
291
308
|
break;
|
|
292
309
|
}
|
|
293
310
|
|
|
311
|
+
case 'ArrowUp':
|
|
312
|
+
{
|
|
313
|
+
if (columnGroupMaxDepth > 0) {
|
|
314
|
+
goToGroupHeader(colIndexBefore, columnGroupMaxDepth - 1, event);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
|
|
294
320
|
case 'PageDown':
|
|
295
321
|
{
|
|
296
322
|
if (firstRowIndexInPage !== null && lastRowIndexInPage !== null) {
|
|
@@ -336,7 +362,117 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
336
362
|
if (shouldPreventDefault) {
|
|
337
363
|
event.preventDefault();
|
|
338
364
|
}
|
|
339
|
-
}, [apiRef, currentPageRows, goToCell, goToHeader,
|
|
365
|
+
}, [apiRef, currentPageRows.length, goToCell, getRowIdFromIndex, goToHeader, goToGroupHeader]);
|
|
366
|
+
const focusedColumnGroup = (0, _useGridSelector.useGridSelector)(apiRef, _focus.unstable_gridFocusColumnGroupHeaderSelector);
|
|
367
|
+
const handleColumnGroupHeaderKeyDown = React.useCallback((params, event) => {
|
|
368
|
+
const dimensions = apiRef.current.getRootDimensions();
|
|
369
|
+
|
|
370
|
+
if (!dimensions) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (focusedColumnGroup === null) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
const {
|
|
379
|
+
field: currentField,
|
|
380
|
+
depth: currentDepth
|
|
381
|
+
} = focusedColumnGroup;
|
|
382
|
+
const {
|
|
383
|
+
fields,
|
|
384
|
+
depth,
|
|
385
|
+
maxDepth
|
|
386
|
+
} = params;
|
|
387
|
+
const viewportPageSize = apiRef.current.unstable_getViewportPageSize();
|
|
388
|
+
const currentColIndex = apiRef.current.getColumnIndex(currentField);
|
|
389
|
+
const colIndexBefore = currentField ? apiRef.current.getColumnIndex(currentField) : 0;
|
|
390
|
+
const firstRowIndexInPage = 0;
|
|
391
|
+
const lastRowIndexInPage = currentPageRows.length - 1;
|
|
392
|
+
const firstColIndex = 0;
|
|
393
|
+
const lastColIndex = (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef).length - 1;
|
|
394
|
+
let shouldPreventDefault = true;
|
|
395
|
+
|
|
396
|
+
switch (event.key) {
|
|
397
|
+
case 'ArrowDown':
|
|
398
|
+
{
|
|
399
|
+
if (depth === maxDepth - 1) {
|
|
400
|
+
goToHeader(currentColIndex, event);
|
|
401
|
+
} else {
|
|
402
|
+
goToGroupHeader(currentColIndex, currentDepth + 1, event);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
case 'ArrowUp':
|
|
409
|
+
{
|
|
410
|
+
if (depth > 0) {
|
|
411
|
+
goToGroupHeader(currentColIndex, currentDepth - 1, event);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
case 'ArrowRight':
|
|
418
|
+
{
|
|
419
|
+
const remainingRightColumns = fields.length - fields.indexOf(currentField) - 1;
|
|
420
|
+
|
|
421
|
+
if (currentColIndex + remainingRightColumns + 1 <= lastColIndex) {
|
|
422
|
+
goToGroupHeader(currentColIndex + remainingRightColumns + 1, currentDepth, event);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
case 'ArrowLeft':
|
|
429
|
+
{
|
|
430
|
+
const remainingLeftColumns = fields.indexOf(currentField);
|
|
431
|
+
|
|
432
|
+
if (currentColIndex - remainingLeftColumns - 1 >= firstColIndex) {
|
|
433
|
+
goToGroupHeader(currentColIndex - remainingLeftColumns - 1, currentDepth, event);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
case 'PageDown':
|
|
440
|
+
{
|
|
441
|
+
if (firstRowIndexInPage !== null && lastRowIndexInPage !== null) {
|
|
442
|
+
goToCell(colIndexBefore, getRowIdFromIndex(Math.min(firstRowIndexInPage + viewportPageSize, lastRowIndexInPage)));
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
case 'Home':
|
|
449
|
+
{
|
|
450
|
+
goToGroupHeader(firstColIndex, currentDepth, event);
|
|
451
|
+
break;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
case 'End':
|
|
455
|
+
{
|
|
456
|
+
goToGroupHeader(lastColIndex, currentDepth, event);
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
case ' ':
|
|
461
|
+
{
|
|
462
|
+
// prevent Space event from scrolling
|
|
463
|
+
break;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
default:
|
|
467
|
+
{
|
|
468
|
+
shouldPreventDefault = false;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
if (shouldPreventDefault) {
|
|
473
|
+
event.preventDefault();
|
|
474
|
+
}
|
|
475
|
+
}, [apiRef, focusedColumnGroup, currentPageRows.length, goToHeader, goToGroupHeader, goToCell, getRowIdFromIndex]);
|
|
340
476
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
341
477
|
// Ignore portal
|
|
342
478
|
if (!event.currentTarget.contains(event.target)) {
|
|
@@ -352,6 +488,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
352
488
|
}, [apiRef]);
|
|
353
489
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellNavigationKeyDown', handleCellNavigationKeyDown);
|
|
354
490
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnHeaderKeyDown', handleColumnHeaderKeyDown);
|
|
491
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnGroupHeaderKeyDown', handleColumnGroupHeaderKeyDown);
|
|
355
492
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
356
493
|
};
|
|
357
494
|
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.selectedIdsLookupSelector = exports.selectedGridRowsSelector = exports.selectedGridRowsCountSelector = exports.
|
|
6
|
+
exports.selectedIdsLookupSelector = exports.selectedGridRowsSelector = exports.selectedGridRowsCountSelector = exports.gridRowSelectionStateSelector = void 0;
|
|
7
7
|
|
|
8
8
|
var _createSelector = require("../../../utils/createSelector");
|
|
9
9
|
|
|
10
10
|
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const gridRowSelectionStateSelector = state => state.rowSelection;
|
|
13
13
|
|
|
14
|
-
exports.
|
|
15
|
-
const selectedGridRowsCountSelector = (0, _createSelector.createSelector)(
|
|
14
|
+
exports.gridRowSelectionStateSelector = gridRowSelectionStateSelector;
|
|
15
|
+
const selectedGridRowsCountSelector = (0, _createSelector.createSelector)(gridRowSelectionStateSelector, selection => selection.length);
|
|
16
16
|
exports.selectedGridRowsCountSelector = selectedGridRowsCountSelector;
|
|
17
|
-
const selectedGridRowsSelector = (0, _createSelector.createSelector)(
|
|
17
|
+
const selectedGridRowsSelector = (0, _createSelector.createSelector)(gridRowSelectionStateSelector, _gridRowsSelector.gridRowsLookupSelector, (selectedRows, rowsLookup) => new Map(selectedRows.map(id => [id, rowsLookup[id]])));
|
|
18
18
|
exports.selectedGridRowsSelector = selectedGridRowsSelector;
|
|
19
|
-
const selectedIdsLookupSelector = (0, _createSelector.createSelector)(
|
|
19
|
+
const selectedIdsLookupSelector = (0, _createSelector.createSelector)(gridRowSelectionStateSelector, selection => selection.reduce((lookup, rowId) => {
|
|
20
20
|
lookup[rowId] = rowId;
|
|
21
21
|
return lookup;
|
|
22
22
|
}, {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _gridRowSelectionSelector = require("./gridRowSelectionSelector");
|
|
8
|
+
|
|
9
|
+
Object.keys(_gridRowSelectionSelector).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _gridRowSelectionSelector[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _gridRowSelectionSelector[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
package/node/hooks/features/{selection/useGridSelection.js → rowSelection/useGridRowSelection.js}
RENAMED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.useGridRowSelection = exports.rowSelectionStateInitializer = void 0;
|
|
9
9
|
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
|
|
@@ -19,7 +19,7 @@ var _useGridLogger = require("../../utils/useGridLogger");
|
|
|
19
19
|
|
|
20
20
|
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _gridRowSelectionSelector = require("./gridRowSelectionSelector");
|
|
23
23
|
|
|
24
24
|
var _pagination = require("../pagination");
|
|
25
25
|
|
|
@@ -57,11 +57,11 @@ const getSelectionModelPropValue = (selectionModelProp, prevSelectionModel) => {
|
|
|
57
57
|
return [selectionModelProp];
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
const
|
|
60
|
+
const rowSelectionStateInitializer = (state, props) => {
|
|
61
61
|
var _getSelectionModelPro;
|
|
62
62
|
|
|
63
63
|
return (0, _extends2.default)({}, state, {
|
|
64
|
-
|
|
64
|
+
rowSelection: (_getSelectionModelPro = getSelectionModelPropValue(props.rowSelectionModel)) != null ? _getSelectionModelPro : []
|
|
65
65
|
});
|
|
66
66
|
};
|
|
67
67
|
/**
|
|
@@ -72,30 +72,30 @@ const selectionStateInitializer = (state, props) => {
|
|
|
72
72
|
*/
|
|
73
73
|
|
|
74
74
|
|
|
75
|
-
exports.
|
|
75
|
+
exports.rowSelectionStateInitializer = rowSelectionStateInitializer;
|
|
76
76
|
|
|
77
|
-
const
|
|
77
|
+
const useGridRowSelection = (apiRef, props) => {
|
|
78
78
|
const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridSelection');
|
|
79
|
-
const
|
|
80
|
-
return getSelectionModelPropValue(props.
|
|
81
|
-
}, [apiRef, props.
|
|
79
|
+
const propRowSelectionModel = React.useMemo(() => {
|
|
80
|
+
return getSelectionModelPropValue(props.rowSelectionModel, (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef.current.state));
|
|
81
|
+
}, [apiRef, props.rowSelectionModel]);
|
|
82
82
|
const lastRowToggled = React.useRef(null);
|
|
83
83
|
apiRef.current.unstable_registerControlState({
|
|
84
|
-
stateId: '
|
|
85
|
-
propModel:
|
|
86
|
-
propOnChange: props.
|
|
87
|
-
stateSelector:
|
|
88
|
-
changeEvent: '
|
|
84
|
+
stateId: 'rowSelection',
|
|
85
|
+
propModel: propRowSelectionModel,
|
|
86
|
+
propOnChange: props.onRowSelectionModelChange,
|
|
87
|
+
stateSelector: _gridRowSelectionSelector.gridRowSelectionStateSelector,
|
|
88
|
+
changeEvent: 'rowSelectionChange'
|
|
89
89
|
});
|
|
90
90
|
const {
|
|
91
91
|
checkboxSelection,
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
disableMultipleRowSelection,
|
|
93
|
+
disableRowSelectionOnClick,
|
|
94
94
|
pagination,
|
|
95
95
|
paginationMode,
|
|
96
96
|
isRowSelectable: propIsRowSelectable
|
|
97
97
|
} = props;
|
|
98
|
-
const canHaveMultipleSelection = !
|
|
98
|
+
const canHaveMultipleSelection = !disableMultipleRowSelection || checkboxSelection;
|
|
99
99
|
const visibleRows = (0, _useGridVisibleRows.useGridVisibleRows)(apiRef, props);
|
|
100
100
|
const expandMouseRowRangeSelection = React.useCallback(id => {
|
|
101
101
|
var _lastRowToggled$curre;
|
|
@@ -130,18 +130,18 @@ const useGridSelection = (apiRef, props) => {
|
|
|
130
130
|
* API METHODS
|
|
131
131
|
*/
|
|
132
132
|
|
|
133
|
-
const
|
|
134
|
-
const currentModel = (0,
|
|
133
|
+
const setRowSelectionModel = React.useCallback(model => {
|
|
134
|
+
const currentModel = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef.current.state);
|
|
135
135
|
|
|
136
136
|
if (currentModel !== model) {
|
|
137
137
|
logger.debug(`Setting selection model`);
|
|
138
138
|
apiRef.current.setState(state => (0, _extends2.default)({}, state, {
|
|
139
|
-
|
|
139
|
+
rowSelection: model
|
|
140
140
|
}));
|
|
141
141
|
apiRef.current.forceUpdate();
|
|
142
142
|
}
|
|
143
143
|
}, [apiRef, logger]);
|
|
144
|
-
const isRowSelected = React.useCallback(id => (0,
|
|
144
|
+
const isRowSelected = React.useCallback(id => (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef.current.state).includes(id), [apiRef]);
|
|
145
145
|
const isRowSelectable = React.useCallback(id => {
|
|
146
146
|
if (propIsRowSelectable && !propIsRowSelectable(apiRef.current.getRowParams(id))) {
|
|
147
147
|
return false;
|
|
@@ -155,7 +155,7 @@ const useGridSelection = (apiRef, props) => {
|
|
|
155
155
|
|
|
156
156
|
return true;
|
|
157
157
|
}, [apiRef, propIsRowSelectable]);
|
|
158
|
-
const getSelectedRows = React.useCallback(() => (0,
|
|
158
|
+
const getSelectedRows = React.useCallback(() => (0, _gridRowSelectionSelector.selectedGridRowsSelector)(apiRef), [apiRef]);
|
|
159
159
|
const selectRow = React.useCallback((id, isSelected = true, resetSelection = false) => {
|
|
160
160
|
if (!apiRef.current.isRowSelectable(id)) {
|
|
161
161
|
return;
|
|
@@ -165,10 +165,10 @@ const useGridSelection = (apiRef, props) => {
|
|
|
165
165
|
|
|
166
166
|
if (resetSelection) {
|
|
167
167
|
logger.debug(`Setting selection for row ${id}`);
|
|
168
|
-
apiRef.current.
|
|
168
|
+
apiRef.current.setRowSelectionModel(isSelected ? [id] : []);
|
|
169
169
|
} else {
|
|
170
170
|
logger.debug(`Toggling selection for row ${id}`);
|
|
171
|
-
const selection = (0,
|
|
171
|
+
const selection = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef.current.state);
|
|
172
172
|
const newSelection = selection.filter(el => el !== id);
|
|
173
173
|
|
|
174
174
|
if (isSelected) {
|
|
@@ -178,7 +178,7 @@ const useGridSelection = (apiRef, props) => {
|
|
|
178
178
|
const isSelectionValid = newSelection.length < 2 || canHaveMultipleSelection;
|
|
179
179
|
|
|
180
180
|
if (isSelectionValid) {
|
|
181
|
-
apiRef.current.
|
|
181
|
+
apiRef.current.setRowSelectionModel(newSelection);
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
}, [apiRef, logger, canHaveMultipleSelection]);
|
|
@@ -191,7 +191,7 @@ const useGridSelection = (apiRef, props) => {
|
|
|
191
191
|
newSelection = isSelected ? selectableIds : [];
|
|
192
192
|
} else {
|
|
193
193
|
// We clone the existing object to avoid mutating the same object returned by the selector to others part of the project
|
|
194
|
-
const selectionLookup = (0, _extends2.default)({}, (0,
|
|
194
|
+
const selectionLookup = (0, _extends2.default)({}, (0, _gridRowSelectionSelector.selectedIdsLookupSelector)(apiRef));
|
|
195
195
|
selectableIds.forEach(id => {
|
|
196
196
|
if (isSelected) {
|
|
197
197
|
selectionLookup[id] = id;
|
|
@@ -205,7 +205,7 @@ const useGridSelection = (apiRef, props) => {
|
|
|
205
205
|
const isSelectionValid = newSelection.length < 2 || canHaveMultipleSelection;
|
|
206
206
|
|
|
207
207
|
if (isSelectionValid) {
|
|
208
|
-
apiRef.current.
|
|
208
|
+
apiRef.current.setRowSelectionModel(newSelection);
|
|
209
209
|
}
|
|
210
210
|
}, [apiRef, logger, canHaveMultipleSelection]);
|
|
211
211
|
const selectRowRange = React.useCallback(({
|
|
@@ -229,7 +229,7 @@ const useGridSelection = (apiRef, props) => {
|
|
|
229
229
|
selectRow,
|
|
230
230
|
selectRows,
|
|
231
231
|
selectRowRange,
|
|
232
|
-
|
|
232
|
+
setRowSelectionModel,
|
|
233
233
|
getSelectedRows,
|
|
234
234
|
isRowSelected,
|
|
235
235
|
isRowSelectable
|
|
@@ -244,10 +244,10 @@ const useGridSelection = (apiRef, props) => {
|
|
|
244
244
|
return;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
const currentSelection = (0,
|
|
247
|
+
const currentSelection = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef.current.state);
|
|
248
248
|
const rowsLookup = (0, _gridRowsSelector.gridRowsLookupSelector)(apiRef); // We clone the existing object to avoid mutating the same object returned by the selector to others part of the project
|
|
249
249
|
|
|
250
|
-
const selectionLookup = (0, _extends2.default)({}, (0,
|
|
250
|
+
const selectionLookup = (0, _extends2.default)({}, (0, _gridRowSelectionSelector.selectedIdsLookupSelector)(apiRef));
|
|
251
251
|
let hasChanged = false;
|
|
252
252
|
currentSelection.forEach(id => {
|
|
253
253
|
if (!rowsLookup[id]) {
|
|
@@ -257,7 +257,7 @@ const useGridSelection = (apiRef, props) => {
|
|
|
257
257
|
});
|
|
258
258
|
|
|
259
259
|
if (hasChanged) {
|
|
260
|
-
apiRef.current.
|
|
260
|
+
apiRef.current.setRowSelectionModel(Object.values(selectionLookup));
|
|
261
261
|
}
|
|
262
262
|
}, [apiRef, props.keepNonExistentRowsSelected]);
|
|
263
263
|
const handleSingleRowSelection = React.useCallback((id, event) => {
|
|
@@ -277,7 +277,7 @@ const useGridSelection = (apiRef, props) => {
|
|
|
277
277
|
}
|
|
278
278
|
}, [apiRef, canHaveMultipleSelection, checkboxSelection]);
|
|
279
279
|
const handleCellClick = React.useCallback((params, event) => {
|
|
280
|
-
if (
|
|
280
|
+
if (disableRowSelectionOnClick) {
|
|
281
281
|
return;
|
|
282
282
|
}
|
|
283
283
|
|
|
@@ -308,7 +308,7 @@ const useGridSelection = (apiRef, props) => {
|
|
|
308
308
|
} else {
|
|
309
309
|
handleSingleRowSelection(params.id, event);
|
|
310
310
|
}
|
|
311
|
-
}, [
|
|
311
|
+
}, [disableRowSelectionOnClick, canHaveMultipleSelection, checkboxSelection, apiRef, expandMouseRowRangeSelection, handleSingleRowSelection]);
|
|
312
312
|
const preventSelectionOnShift = React.useCallback((params, event) => {
|
|
313
313
|
if (canHaveMultipleSelection && event.shiftKey) {
|
|
314
314
|
var _window$getSelection;
|
|
@@ -409,29 +409,29 @@ const useGridSelection = (apiRef, props) => {
|
|
|
409
409
|
*/
|
|
410
410
|
|
|
411
411
|
React.useEffect(() => {
|
|
412
|
-
if (
|
|
413
|
-
apiRef.current.
|
|
412
|
+
if (propRowSelectionModel !== undefined) {
|
|
413
|
+
apiRef.current.setRowSelectionModel(propRowSelectionModel);
|
|
414
414
|
}
|
|
415
|
-
}, [apiRef,
|
|
416
|
-
const isStateControlled =
|
|
415
|
+
}, [apiRef, propRowSelectionModel]);
|
|
416
|
+
const isStateControlled = propRowSelectionModel != null;
|
|
417
417
|
React.useEffect(() => {
|
|
418
418
|
if (isStateControlled) {
|
|
419
419
|
return;
|
|
420
420
|
} // props.isRowSelectable changed
|
|
421
421
|
|
|
422
422
|
|
|
423
|
-
const currentSelection = (0,
|
|
423
|
+
const currentSelection = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef.current.state);
|
|
424
424
|
|
|
425
425
|
if (isRowSelectable) {
|
|
426
426
|
const newSelection = currentSelection.filter(id => isRowSelectable(id));
|
|
427
427
|
|
|
428
428
|
if (newSelection.length < currentSelection.length) {
|
|
429
|
-
apiRef.current.
|
|
429
|
+
apiRef.current.setRowSelectionModel(newSelection);
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
432
|
}, [apiRef, isRowSelectable, isStateControlled]);
|
|
433
433
|
React.useEffect(() => {
|
|
434
|
-
const currentSelection = (0,
|
|
434
|
+
const currentSelection = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef.current.state);
|
|
435
435
|
|
|
436
436
|
if (!canHaveMultipleSelection && currentSelection.length > 1) {
|
|
437
437
|
const {
|
|
@@ -455,9 +455,9 @@ const 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
|
};
|
|
462
462
|
|
|
463
|
-
exports.
|
|
463
|
+
exports.useGridRowSelection = useGridRowSelection;
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.useGridRowSelectionPreProcessors = void 0;
|
|
9
9
|
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
|
|
@@ -36,7 +36,7 @@ const useUtilityClasses = ownerState => {
|
|
|
36
36
|
}, [classes]);
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
const
|
|
39
|
+
const useGridRowSelectionPreProcessors = (apiRef, props) => {
|
|
40
40
|
const ownerState = {
|
|
41
41
|
classes: props.classes
|
|
42
42
|
};
|
|
@@ -65,4 +65,4 @@ const useGridSelectionPreProcessors = (apiRef, props) => {
|
|
|
65
65
|
(0, _pipeProcessing.useGridRegisterPipeProcessor)(apiRef, 'hydrateColumns', updateSelectionColumn);
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
exports.
|
|
68
|
+
exports.useGridRowSelectionPreProcessors = useGridRowSelectionPreProcessors;
|
|
@@ -60,7 +60,8 @@ exports.getRowIdFromRowModel = getRowIdFromRowModel;
|
|
|
60
60
|
const createRowsInternalCache = ({
|
|
61
61
|
rows,
|
|
62
62
|
getRowId,
|
|
63
|
-
loading
|
|
63
|
+
loading,
|
|
64
|
+
rowCount
|
|
64
65
|
}) => {
|
|
65
66
|
const updates = {
|
|
66
67
|
type: 'full',
|
|
@@ -80,6 +81,7 @@ const createRowsInternalCache = ({
|
|
|
80
81
|
return {
|
|
81
82
|
rowsBeforePartialUpdates: rows,
|
|
82
83
|
loadingPropBeforePartialUpdates: loading,
|
|
84
|
+
rowCountPropBeforePartialUpdates: rowCount,
|
|
83
85
|
updates,
|
|
84
86
|
dataRowIdToIdLookup,
|
|
85
87
|
dataRowIdToModelLookup
|
|
@@ -302,7 +304,8 @@ const updateCacheWithNewRows = ({
|
|
|
302
304
|
dataRowIdToIdLookup,
|
|
303
305
|
updates: partialUpdates,
|
|
304
306
|
rowsBeforePartialUpdates: previousCache.rowsBeforePartialUpdates,
|
|
305
|
-
loadingPropBeforePartialUpdates: previousCache.loadingPropBeforePartialUpdates
|
|
307
|
+
loadingPropBeforePartialUpdates: previousCache.loadingPropBeforePartialUpdates,
|
|
308
|
+
rowCountPropBeforePartialUpdates: previousCache.rowCountPropBeforePartialUpdates
|
|
306
309
|
};
|
|
307
310
|
};
|
|
308
311
|
|
|
@@ -37,7 +37,8 @@ const rowsStateInitializer = (state, props, apiRef) => {
|
|
|
37
37
|
apiRef.current.unstable_caches.rows = (0, _gridRowsUtils.createRowsInternalCache)({
|
|
38
38
|
rows: props.rows,
|
|
39
39
|
getRowId: props.getRowId,
|
|
40
|
-
loading: props.loading
|
|
40
|
+
loading: props.loading,
|
|
41
|
+
rowCount: props.rowCount
|
|
41
42
|
});
|
|
42
43
|
return (0, _extends2.default)({}, state, {
|
|
43
44
|
rows: (0, _gridRowsUtils.getRowsStateFromCache)({
|
|
@@ -138,11 +139,12 @@ const useGridRows = (apiRef, props) => {
|
|
|
138
139
|
cache: (0, _gridRowsUtils.createRowsInternalCache)({
|
|
139
140
|
rows,
|
|
140
141
|
getRowId: props.getRowId,
|
|
141
|
-
loading: props.loading
|
|
142
|
+
loading: props.loading,
|
|
143
|
+
rowCount: props.rowCount
|
|
142
144
|
}),
|
|
143
145
|
throttle: true
|
|
144
146
|
});
|
|
145
|
-
}, [logger, props.getRowId, props.loading, throttledRowsChange]);
|
|
147
|
+
}, [logger, props.getRowId, props.loading, props.rowCount, throttledRowsChange]);
|
|
146
148
|
const updateRows = React.useCallback(updates => {
|
|
147
149
|
if (props.signature === _useGridApiEventHandler.GridSignature.DataGrid && updates.length > 1) {
|
|
148
150
|
// TODO: Add test with direct call to `apiRef.current.updateRows` in DataGrid after enabling the `apiRef` on the free plan.
|
|
@@ -373,7 +375,8 @@ const useGridRows = (apiRef, props) => {
|
|
|
373
375
|
cache = (0, _gridRowsUtils.createRowsInternalCache)({
|
|
374
376
|
rows: props.rows,
|
|
375
377
|
getRowId: props.getRowId,
|
|
376
|
-
loading: props.loading
|
|
378
|
+
loading: props.loading,
|
|
379
|
+
rowCount: props.rowCount
|
|
377
380
|
});
|
|
378
381
|
}
|
|
379
382
|
|
|
@@ -381,7 +384,7 @@ const useGridRows = (apiRef, props) => {
|
|
|
381
384
|
cache,
|
|
382
385
|
throttle: false
|
|
383
386
|
});
|
|
384
|
-
}, [logger, apiRef, props.rows, props.getRowId, props.loading, throttledRowsChange]);
|
|
387
|
+
}, [logger, apiRef, props.rows, props.getRowId, props.loading, props.rowCount, throttledRowsChange]);
|
|
385
388
|
const handleStrategyProcessorChange = React.useCallback(methodName => {
|
|
386
389
|
if (methodName === 'rowTreeCreation') {
|
|
387
390
|
groupRows();
|
|
@@ -444,7 +447,8 @@ const useGridRows = (apiRef, props) => {
|
|
|
444
447
|
}
|
|
445
448
|
|
|
446
449
|
const areNewRowsAlreadyInState = apiRef.current.unstable_caches.rows.rowsBeforePartialUpdates === props.rows;
|
|
447
|
-
const isNewLoadingAlreadyInState = apiRef.current.unstable_caches.rows.loadingPropBeforePartialUpdates === props.loading;
|
|
450
|
+
const isNewLoadingAlreadyInState = apiRef.current.unstable_caches.rows.loadingPropBeforePartialUpdates === props.loading;
|
|
451
|
+
const isNewRowCountAlreadyInState = apiRef.current.unstable_caches.rows.rowCountPropBeforePartialUpdates === props.rowCount; // The new rows have already been applied (most likely in the `'rowGroupsPreProcessingChange'` listener)
|
|
448
452
|
|
|
449
453
|
if (areNewRowsAlreadyInState) {
|
|
450
454
|
// If the loading prop has changed, we need to update its value in the state because it won't be done by `throttledRowsChange`
|
|
@@ -458,6 +462,17 @@ const useGridRows = (apiRef, props) => {
|
|
|
458
462
|
apiRef.current.forceUpdate();
|
|
459
463
|
}
|
|
460
464
|
|
|
465
|
+
if (!isNewRowCountAlreadyInState) {
|
|
466
|
+
apiRef.current.setState(state => (0, _extends2.default)({}, state, {
|
|
467
|
+
rows: (0, _extends2.default)({}, state.rows, {
|
|
468
|
+
totalRowCount: Math.max(props.rowCount || 0, state.rows.totalRowCount),
|
|
469
|
+
totalTopLevelRowCount: Math.max(props.rowCount || 0, state.rows.totalTopLevelRowCount)
|
|
470
|
+
})
|
|
471
|
+
}));
|
|
472
|
+
apiRef.current.unstable_caches.rows.rowCountPropBeforePartialUpdates = props.rowCount;
|
|
473
|
+
apiRef.current.forceUpdate();
|
|
474
|
+
}
|
|
475
|
+
|
|
461
476
|
return;
|
|
462
477
|
}
|
|
463
478
|
|
|
@@ -466,7 +481,8 @@ const useGridRows = (apiRef, props) => {
|
|
|
466
481
|
cache: (0, _gridRowsUtils.createRowsInternalCache)({
|
|
467
482
|
rows: props.rows,
|
|
468
483
|
getRowId: props.getRowId,
|
|
469
|
-
loading: props.loading
|
|
484
|
+
loading: props.loading,
|
|
485
|
+
rowCount: props.rowCount
|
|
470
486
|
}),
|
|
471
487
|
throttle: false
|
|
472
488
|
});
|
|
@@ -28,7 +28,7 @@ var _gridColumnsSelector = require("../columns/gridColumnsSelector");
|
|
|
28
28
|
|
|
29
29
|
var _gridFocusStateSelector = require("../focus/gridFocusStateSelector");
|
|
30
30
|
|
|
31
|
-
var
|
|
31
|
+
var _gridEditingSelectors = require("../editing/gridEditingSelectors");
|
|
32
32
|
|
|
33
33
|
var _useGridVisibleRows = require("../../utils/useGridVisibleRows");
|
|
34
34
|
|
|
@@ -36,7 +36,7 @@ var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
|
|
|
36
36
|
|
|
37
37
|
var _utils2 = require("../../../utils/utils");
|
|
38
38
|
|
|
39
|
-
var
|
|
39
|
+
var _gridRowSelectionSelector = require("../rowSelection/gridRowSelectionSelector");
|
|
40
40
|
|
|
41
41
|
var _gridRowsMetaSelector = require("../rows/gridRowsMetaSelector");
|
|
42
42
|
|
|
@@ -109,8 +109,8 @@ const useGridVirtualScroller = props => {
|
|
|
109
109
|
const cellFocus = (0, _useGridSelector.useGridSelector)(apiRef, _gridFocusStateSelector.gridFocusCellSelector);
|
|
110
110
|
const cellTabIndex = (0, _useGridSelector.useGridSelector)(apiRef, _gridFocusStateSelector.gridTabIndexCellSelector);
|
|
111
111
|
const rowsMeta = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsMetaSelector.gridRowsMetaSelector);
|
|
112
|
-
const editRowsState = (0, _useGridSelector.useGridSelector)(apiRef,
|
|
113
|
-
const selectedRowsLookup = (0, _useGridSelector.useGridSelector)(apiRef,
|
|
112
|
+
const editRowsState = (0, _useGridSelector.useGridSelector)(apiRef, _gridEditingSelectors.gridEditRowsStateSelector);
|
|
113
|
+
const selectedRowsLookup = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowSelectionSelector.selectedIdsLookupSelector);
|
|
114
114
|
const currentPage = (0, _useGridVisibleRows.useGridVisibleRows)(apiRef, rootProps);
|
|
115
115
|
const renderZoneRef = React.useRef(null);
|
|
116
116
|
const rootRef = React.useRef(null);
|
package/node/index.js
CHANGED