@mui/x-data-grid 6.0.0-alpha.2 → 6.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +493 -141
- package/DataGrid/DataGrid.js +14 -34
- package/DataGrid/useDataGridComponent.js +8 -14
- package/DataGrid/useDataGridProps.js +3 -3
- package/colDef/gridCheckboxSelectionColDef.js +1 -1
- package/colDef/gridNumericOperators.d.ts +1 -1
- package/colDef/gridSingleSelectOperators.d.ts +1 -1
- package/colDef/gridStringOperators.d.ts +1 -1
- package/components/GridFooter.js +1 -1
- package/components/GridRow.js +2 -2
- package/components/base/GridBody.js +2 -2
- package/components/cell/GridEditInputCell.js +3 -8
- package/components/cell/GridEditSingleSelectCell.js +6 -38
- package/components/columnHeaders/GridColumnGroupHeader.d.ts +2 -0
- package/components/columnHeaders/GridColumnGroupHeader.js +32 -5
- package/components/columnSelection/GridHeaderCheckbox.js +3 -3
- package/components/containers/GridRoot.js +4 -3
- package/components/panel/GridColumnsPanel.d.ts +2 -0
- package/components/panel/GridColumnsPanel.js +10 -4
- package/components/panel/filterPanel/GridFilterForm.d.ts +12 -0
- package/components/panel/filterPanel/GridFilterForm.js +29 -7
- package/components/panel/filterPanel/GridFilterPanel.d.ts +12 -0
- package/components/panel/filterPanel/GridFilterPanel.js +64 -19
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +1 -1
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +1 -1
- package/hooks/core/strategyProcessing/useGridRegisterStrategyProcessor.d.ts +1 -1
- package/hooks/core/useGridInitialization.d.ts +1 -1
- package/hooks/core/useGridStateInitialization.d.ts +1 -1
- package/hooks/features/columnGrouping/gridColumnGroupsInterfaces.d.ts +10 -1
- package/hooks/features/columnGrouping/gridColumnGroupsSelector.d.ts +6 -0
- package/hooks/features/columnGrouping/gridColumnGroupsSelector.js +34 -1
- package/hooks/features/columnGrouping/gridColumnGroupsUtils.d.ts +15 -0
- package/hooks/features/columnGrouping/gridColumnGroupsUtils.js +89 -0
- package/hooks/features/columnGrouping/useGridColumnGrouping.d.ts +1 -15
- package/hooks/features/columnGrouping/useGridColumnGrouping.js +66 -66
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +60 -116
- package/hooks/features/density/densitySelector.d.ts +0 -2
- package/hooks/features/density/densitySelector.js +1 -3
- package/hooks/features/density/densityState.d.ts +0 -1
- package/hooks/features/density/useGridDensity.d.ts +1 -1
- package/hooks/features/density/useGridDensity.js +9 -45
- package/hooks/features/dimensions/useGridDimensions.js +3 -2
- package/hooks/features/{editRows/gridEditRowsSelector.d.ts → editing/gridEditingSelectors.d.ts} +0 -0
- package/hooks/features/{editRows/gridEditRowsSelector.js → editing/gridEditingSelectors.js} +0 -0
- package/hooks/features/editing/index.d.ts +1 -0
- package/hooks/features/editing/index.js +1 -0
- package/hooks/features/{editRows/useGridCellEditing.new.d.ts → editing/useGridCellEditing.d.ts} +0 -0
- package/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js} +21 -6
- package/hooks/features/{editRows/useGridEditing.new.d.ts → editing/useGridEditing.d.ts} +0 -0
- package/hooks/features/{editRows/useGridEditing.new.js → editing/useGridEditing.js} +3 -3
- package/hooks/features/{editRows/useGridRowEditing.new.d.ts → editing/useGridRowEditing.d.ts} +0 -0
- package/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js} +20 -6
- package/hooks/features/export/useGridPrintExport.js +2 -2
- package/hooks/features/focus/gridFocusState.d.ts +6 -0
- package/hooks/features/focus/gridFocusStateSelector.d.ts +2 -0
- package/hooks/features/focus/gridFocusStateSelector.js +6 -2
- package/hooks/features/focus/useGridFocus.js +69 -11
- package/hooks/features/index.d.ts +2 -2
- package/hooks/features/index.js +2 -2
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +135 -1
- package/hooks/features/{selection/gridSelectionSelector.d.ts → rowSelection/gridRowSelectionSelector.d.ts} +1 -1
- package/hooks/features/rowSelection/gridRowSelectionSelector.js +9 -0
- package/hooks/features/rowSelection/index.d.ts +1 -0
- package/hooks/features/rowSelection/index.js +1 -0
- package/hooks/features/rowSelection/useGridRowSelection.d.ts +12 -0
- package/hooks/features/{selection/useGridSelection.js → rowSelection/useGridRowSelection.js} +37 -37
- package/hooks/features/{selection/useGridSelectionPreProcessors.d.ts → rowSelection/useGridRowSelectionPreProcessors.d.ts} +1 -1
- package/hooks/features/{selection/useGridSelectionPreProcessors.js → rowSelection/useGridRowSelectionPreProcessors.js} +1 -1
- package/hooks/features/rows/gridRowsInterfaces.d.ts +4 -0
- package/hooks/features/rows/gridRowsUtils.d.ts +1 -1
- package/hooks/features/rows/gridRowsUtils.js +5 -2
- package/hooks/features/rows/useGridRows.js +23 -7
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +2 -2
- package/hooks/utils/useGridApi.d.ts +1 -1
- package/hooks/utils/useGridApiEventHandler.d.ts +2 -2
- package/hooks/utils/useGridApiRef.d.ts +1 -1
- package/hooks/utils/useGridInitializeState.d.ts +1 -1
- package/hooks/utils/useGridNativeEventListener.d.ts +1 -1
- package/hooks/utils/useGridSelector.d.ts +1 -1
- package/hooks/utils/useGridState.d.ts +1 -1
- package/hooks/utils/useGridVisibleRows.d.ts +2 -2
- package/index.js +1 -1
- package/internals/index.d.ts +3 -5
- package/internals/index.js +3 -5
- package/legacy/DataGrid/DataGrid.js +14 -34
- package/legacy/DataGrid/useDataGridComponent.js +8 -14
- package/legacy/DataGrid/useDataGridProps.js +3 -3
- package/legacy/colDef/gridCheckboxSelectionColDef.js +1 -1
- package/legacy/components/GridFooter.js +1 -1
- package/legacy/components/GridRow.js +2 -2
- package/legacy/components/base/GridBody.js +2 -2
- package/legacy/components/cell/GridEditInputCell.js +3 -8
- package/legacy/components/cell/GridEditSingleSelectCell.js +6 -52
- package/legacy/components/columnHeaders/GridColumnGroupHeader.js +46 -13
- package/legacy/components/columnSelection/GridHeaderCheckbox.js +3 -3
- package/legacy/components/containers/GridRoot.js +4 -3
- package/legacy/components/panel/GridColumnsPanel.js +10 -3
- package/legacy/components/panel/filterPanel/GridFilterForm.js +31 -7
- package/legacy/components/panel/filterPanel/GridFilterPanel.js +67 -18
- package/legacy/hooks/features/columnGrouping/gridColumnGroupsSelector.js +33 -1
- package/legacy/hooks/features/columnGrouping/gridColumnGroupsUtils.js +96 -0
- package/legacy/hooks/features/columnGrouping/useGridColumnGrouping.js +64 -64
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +70 -122
- package/legacy/hooks/features/density/densitySelector.js +0 -6
- package/legacy/hooks/features/density/useGridDensity.js +6 -44
- package/legacy/hooks/features/dimensions/useGridDimensions.js +3 -2
- package/legacy/hooks/features/{editRows/gridEditRowsSelector.js → editing/gridEditingSelectors.js} +0 -0
- package/legacy/hooks/features/editing/index.js +1 -0
- package/legacy/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js} +21 -6
- package/legacy/hooks/features/{editRows/useGridEditing.new.js → editing/useGridEditing.js} +3 -3
- package/legacy/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js} +20 -6
- package/legacy/hooks/features/export/useGridPrintExport.js +2 -2
- package/legacy/hooks/features/focus/gridFocusStateSelector.js +8 -0
- package/legacy/hooks/features/focus/useGridFocus.js +72 -11
- package/legacy/hooks/features/index.js +2 -2
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +129 -1
- package/legacy/hooks/features/rowSelection/gridRowSelectionSelector.js +19 -0
- package/legacy/hooks/features/rowSelection/index.js +1 -0
- package/legacy/hooks/features/{selection/useGridSelection.js → rowSelection/useGridRowSelection.js} +37 -37
- package/legacy/hooks/features/{selection/useGridSelectionPreProcessors.js → rowSelection/useGridRowSelectionPreProcessors.js} +1 -1
- package/legacy/hooks/features/rows/gridRowsUtils.js +5 -2
- package/legacy/hooks/features/rows/useGridRows.js +25 -7
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +2 -2
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +3 -5
- package/legacy/locales/trTR.js +17 -17
- package/legacy/models/api/{gridSelectionApi.js → gridRowSelectionApi.js} +0 -0
- package/legacy/models/api/index.js +1 -1
- package/legacy/models/{gridSelectionModel.js → gridRowSelectionModel.js} +0 -0
- package/legacy/models/index.js +1 -1
- package/{models/api/gridSelectionApi.js → legacy/models/params/gridColumnGroupHeaderParams.js} +0 -0
- package/legacy/models/params/gridEditCellParams.js +0 -4
- package/legacy/models/params/index.js +1 -0
- package/locales/trTR.js +17 -17
- package/models/api/gridApiCommon.d.ts +3 -6
- package/models/api/gridApiCommunity.d.ts +1 -7
- package/models/api/gridEditingApi.d.ts +36 -121
- package/models/api/gridFocusApi.d.ts +13 -0
- package/models/api/{gridSelectionApi.d.ts → gridRowSelectionApi.d.ts} +2 -2
- package/models/{gridSelectionModel.js → api/gridRowSelectionApi.js} +0 -0
- package/models/api/index.d.ts +2 -2
- package/models/api/index.js +1 -1
- package/models/colDef/gridColDef.d.ts +0 -8
- package/models/events/gridEventLookup.d.ts +30 -19
- package/models/gridColumnGrouping.d.ts +1 -26
- package/models/gridRowSelectionModel.d.ts +3 -0
- package/{modern/models/api/gridSelectionApi.js → models/gridRowSelectionModel.js} +0 -0
- package/models/gridStateCommunity.d.ts +2 -2
- package/models/index.d.ts +1 -1
- package/models/index.js +1 -1
- package/models/params/gridColumnGroupHeaderParams.d.ts +30 -0
- package/{modern/models/gridSelectionModel.js → models/params/gridColumnGroupHeaderParams.js} +0 -0
- package/models/params/gridEditCellParams.d.ts +4 -17
- package/models/params/gridEditCellParams.js +0 -4
- package/models/params/gridRowParams.d.ts +4 -4
- package/models/params/index.d.ts +1 -0
- package/models/params/index.js +1 -0
- package/models/props/DataGridProps.d.ts +8 -32
- package/modern/DataGrid/DataGrid.js +14 -34
- package/modern/DataGrid/useDataGridComponent.js +8 -12
- package/modern/DataGrid/useDataGridProps.js +3 -3
- package/modern/colDef/gridCheckboxSelectionColDef.js +1 -1
- package/modern/components/GridFooter.js +1 -1
- package/modern/components/GridRow.js +2 -2
- package/modern/components/base/GridBody.js +2 -2
- package/modern/components/cell/GridEditInputCell.js +3 -4
- package/modern/components/cell/GridEditSingleSelectCell.js +6 -34
- package/modern/components/columnHeaders/GridColumnGroupHeader.js +32 -5
- package/modern/components/columnSelection/GridHeaderCheckbox.js +3 -3
- package/modern/components/containers/GridRoot.js +4 -3
- package/modern/components/panel/GridColumnsPanel.js +10 -4
- package/modern/components/panel/filterPanel/GridFilterForm.js +29 -7
- package/modern/components/panel/filterPanel/GridFilterPanel.js +62 -17
- package/modern/hooks/features/columnGrouping/gridColumnGroupsSelector.js +14 -1
- package/modern/hooks/features/columnGrouping/gridColumnGroupsUtils.js +83 -0
- package/modern/hooks/features/columnGrouping/useGridColumnGrouping.js +50 -62
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +58 -98
- package/modern/hooks/features/density/densitySelector.js +1 -3
- package/modern/hooks/features/density/useGridDensity.js +9 -37
- package/modern/hooks/features/dimensions/useGridDimensions.js +3 -2
- package/modern/hooks/features/{editRows/gridEditRowsSelector.js → editing/gridEditingSelectors.js} +0 -0
- package/modern/hooks/features/editing/index.js +1 -0
- package/modern/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js} +21 -6
- package/modern/hooks/features/{editRows/useGridEditing.new.js → editing/useGridEditing.js} +3 -3
- package/modern/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js} +20 -6
- package/modern/hooks/features/export/useGridPrintExport.js +2 -2
- package/modern/hooks/features/focus/gridFocusStateSelector.js +6 -2
- package/modern/hooks/features/focus/useGridFocus.js +69 -11
- package/modern/hooks/features/index.js +2 -2
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +135 -1
- package/modern/hooks/features/rowSelection/gridRowSelectionSelector.js +9 -0
- package/modern/hooks/features/rowSelection/index.js +1 -0
- package/modern/hooks/features/{selection/useGridSelection.js → rowSelection/useGridRowSelection.js} +37 -37
- package/modern/hooks/features/{selection/useGridSelectionPreProcessors.js → rowSelection/useGridRowSelectionPreProcessors.js} +1 -1
- package/modern/hooks/features/rows/gridRowsUtils.js +5 -2
- package/modern/hooks/features/rows/useGridRows.js +23 -7
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +2 -2
- package/modern/index.js +1 -1
- package/modern/internals/index.js +3 -5
- package/modern/locales/trTR.js +17 -17
- package/modern/models/api/gridRowSelectionApi.js +1 -0
- package/modern/models/api/index.js +1 -1
- package/modern/models/gridRowSelectionModel.js +1 -0
- package/modern/models/index.js +1 -1
- package/modern/models/params/gridColumnGroupHeaderParams.js +1 -0
- package/modern/models/params/gridEditCellParams.js +0 -4
- package/modern/models/params/index.js +1 -0
- package/node/DataGrid/DataGrid.js +14 -34
- package/node/DataGrid/useDataGridComponent.js +9 -17
- package/node/DataGrid/useDataGridProps.js +3 -3
- package/node/colDef/gridCheckboxSelectionColDef.js +2 -2
- package/node/components/GridFooter.js +2 -2
- package/node/components/GridRow.js +2 -2
- package/node/components/base/GridBody.js +2 -2
- package/node/components/cell/GridEditInputCell.js +3 -9
- package/node/components/cell/GridEditSingleSelectCell.js +6 -38
- package/node/components/columnHeaders/GridColumnGroupHeader.js +32 -5
- package/node/components/columnSelection/GridHeaderCheckbox.js +3 -3
- package/node/components/containers/GridRoot.js +4 -2
- package/node/components/panel/GridColumnsPanel.js +10 -4
- package/node/components/panel/filterPanel/GridFilterForm.js +30 -7
- package/node/components/panel/filterPanel/GridFilterPanel.js +63 -19
- package/node/hooks/features/columnGrouping/gridColumnGroupsSelector.js +40 -3
- package/node/hooks/features/columnGrouping/gridColumnGroupsUtils.js +102 -0
- package/node/hooks/features/columnGrouping/useGridColumnGrouping.js +68 -71
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +57 -113
- package/node/hooks/features/density/densitySelector.js +2 -6
- package/node/hooks/features/density/useGridDensity.js +9 -48
- package/node/hooks/features/dimensions/useGridDimensions.js +3 -1
- package/node/hooks/features/{editRows/gridEditRowsSelector.js → editing/gridEditingSelectors.js} +0 -0
- package/node/hooks/features/{editRows → editing}/index.js +4 -4
- package/node/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js} +28 -13
- package/node/hooks/features/{editRows/useGridEditing.new.js → editing/useGridEditing.js} +4 -4
- package/node/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js} +28 -14
- package/node/hooks/features/export/useGridPrintExport.js +2 -2
- package/node/hooks/features/focus/gridFocusStateSelector.js +10 -4
- package/node/hooks/features/focus/useGridFocus.js +68 -10
- package/node/hooks/features/index.js +8 -8
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +138 -1
- package/node/hooks/features/{selection/gridSelectionSelector.js → rowSelection/gridRowSelectionSelector.js} +6 -6
- package/node/hooks/features/rowSelection/index.js +18 -0
- package/node/hooks/features/{selection/useGridSelection.js → rowSelection/useGridRowSelection.js} +43 -43
- package/node/hooks/features/{selection/useGridSelectionPreProcessors.js → rowSelection/useGridRowSelectionPreProcessors.js} +3 -3
- package/node/hooks/features/rows/gridRowsUtils.js +5 -2
- package/node/hooks/features/rows/useGridRows.js +23 -7
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/node/index.js +1 -1
- package/node/internals/index.js +23 -45
- package/node/locales/trTR.js +17 -17
- package/node/models/api/{gridSelectionApi.js → gridRowSelectionApi.js} +0 -0
- package/node/models/api/index.js +4 -4
- package/node/models/{gridSelectionModel.js → gridRowSelectionModel.js} +0 -0
- package/node/models/index.js +4 -4
- package/node/models/params/gridColumnGroupHeaderParams.js +5 -0
- package/node/models/params/gridEditCellParams.js +0 -3
- package/node/models/params/index.js +13 -0
- package/package.json +2 -2
- package/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.d.ts +0 -4
- package/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.js +0 -35
- package/hooks/features/editRows/index.d.ts +0 -1
- package/hooks/features/editRows/index.js +0 -1
- package/hooks/features/editRows/useGridCellEditing.old.d.ts +0 -4
- package/hooks/features/editRows/useGridCellEditing.old.js +0 -359
- package/hooks/features/editRows/useGridEditing.old.d.ts +0 -11
- package/hooks/features/editRows/useGridEditing.old.js +0 -167
- package/hooks/features/editRows/useGridRowEditing.old.d.ts +0 -4
- package/hooks/features/editRows/useGridRowEditing.old.js +0 -334
- package/hooks/features/selection/gridSelectionSelector.js +0 -9
- package/hooks/features/selection/index.d.ts +0 -1
- package/hooks/features/selection/index.js +0 -1
- package/hooks/features/selection/useGridSelection.d.ts +0 -12
- package/legacy/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.js +0 -35
- package/legacy/hooks/features/editRows/index.js +0 -1
- package/legacy/hooks/features/editRows/useGridCellEditing.old.js +0 -411
- package/legacy/hooks/features/editRows/useGridEditing.old.js +0 -184
- package/legacy/hooks/features/editRows/useGridRowEditing.old.js +0 -505
- package/legacy/hooks/features/selection/gridSelectionSelector.js +0 -19
- package/legacy/hooks/features/selection/index.js +0 -1
- package/models/gridSelectionModel.d.ts +0 -3
- package/modern/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.js +0 -29
- package/modern/hooks/features/editRows/index.js +0 -1
- package/modern/hooks/features/editRows/useGridCellEditing.old.js +0 -355
- package/modern/hooks/features/editRows/useGridEditing.old.js +0 -163
- package/modern/hooks/features/editRows/useGridRowEditing.old.js +0 -326
- package/modern/hooks/features/selection/gridSelectionSelector.js +0 -9
- package/modern/hooks/features/selection/index.js +0 -1
- package/node/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.js +0 -55
- package/node/hooks/features/editRows/useGridCellEditing.old.js +0 -380
- package/node/hooks/features/editRows/useGridEditing.old.js +0 -193
- package/node/hooks/features/editRows/useGridRowEditing.old.js +0 -358
- package/node/hooks/features/selection/index.js +0 -18
package/hooks/features/{selection/useGridSelection.js → rowSelection/useGridRowSelection.js}
RENAMED
|
@@ -4,7 +4,7 @@ import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
|
4
4
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
5
5
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
6
6
|
import { gridRowsLookupSelector } from '../rows/gridRowsSelector';
|
|
7
|
-
import {
|
|
7
|
+
import { gridRowSelectionStateSelector, selectedGridRowsSelector, selectedIdsLookupSelector } from './gridRowSelectionSelector';
|
|
8
8
|
import { gridPaginatedVisibleSortedGridRowIdsSelector } from '../pagination';
|
|
9
9
|
import { gridFocusCellSelector } from '../focus/gridFocusStateSelector';
|
|
10
10
|
import { gridVisibleSortedRowIdsSelector } from '../filter/gridFilterSelector';
|
|
@@ -30,11 +30,11 @@ const getSelectionModelPropValue = (selectionModelProp, prevSelectionModel) => {
|
|
|
30
30
|
return [selectionModelProp];
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
export const
|
|
33
|
+
export const rowSelectionStateInitializer = (state, props) => {
|
|
34
34
|
var _getSelectionModelPro;
|
|
35
35
|
|
|
36
36
|
return _extends({}, state, {
|
|
37
|
-
|
|
37
|
+
rowSelection: (_getSelectionModelPro = getSelectionModelPropValue(props.rowSelectionModel)) != null ? _getSelectionModelPro : []
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
40
|
/**
|
|
@@ -44,28 +44,28 @@ export const selectionStateInitializer = (state, props) => {
|
|
|
44
44
|
* @requires useGridKeyboardNavigation (`cellKeyDown` event must first be consumed by it)
|
|
45
45
|
*/
|
|
46
46
|
|
|
47
|
-
export const
|
|
47
|
+
export const useGridRowSelection = (apiRef, props) => {
|
|
48
48
|
const logger = useGridLogger(apiRef, 'useGridSelection');
|
|
49
|
-
const
|
|
50
|
-
return getSelectionModelPropValue(props.
|
|
51
|
-
}, [apiRef, props.
|
|
49
|
+
const propRowSelectionModel = React.useMemo(() => {
|
|
50
|
+
return getSelectionModelPropValue(props.rowSelectionModel, gridRowSelectionStateSelector(apiRef.current.state));
|
|
51
|
+
}, [apiRef, props.rowSelectionModel]);
|
|
52
52
|
const lastRowToggled = React.useRef(null);
|
|
53
53
|
apiRef.current.unstable_registerControlState({
|
|
54
|
-
stateId: '
|
|
55
|
-
propModel:
|
|
56
|
-
propOnChange: props.
|
|
57
|
-
stateSelector:
|
|
58
|
-
changeEvent: '
|
|
54
|
+
stateId: 'rowSelection',
|
|
55
|
+
propModel: propRowSelectionModel,
|
|
56
|
+
propOnChange: props.onRowSelectionModelChange,
|
|
57
|
+
stateSelector: gridRowSelectionStateSelector,
|
|
58
|
+
changeEvent: 'rowSelectionChange'
|
|
59
59
|
});
|
|
60
60
|
const {
|
|
61
61
|
checkboxSelection,
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
disableMultipleRowSelection,
|
|
63
|
+
disableRowSelectionOnClick,
|
|
64
64
|
pagination,
|
|
65
65
|
paginationMode,
|
|
66
66
|
isRowSelectable: propIsRowSelectable
|
|
67
67
|
} = props;
|
|
68
|
-
const canHaveMultipleSelection = !
|
|
68
|
+
const canHaveMultipleSelection = !disableMultipleRowSelection || checkboxSelection;
|
|
69
69
|
const visibleRows = useGridVisibleRows(apiRef, props);
|
|
70
70
|
const expandMouseRowRangeSelection = React.useCallback(id => {
|
|
71
71
|
var _lastRowToggled$curre;
|
|
@@ -100,18 +100,18 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
100
100
|
* API METHODS
|
|
101
101
|
*/
|
|
102
102
|
|
|
103
|
-
const
|
|
104
|
-
const currentModel =
|
|
103
|
+
const setRowSelectionModel = React.useCallback(model => {
|
|
104
|
+
const currentModel = gridRowSelectionStateSelector(apiRef.current.state);
|
|
105
105
|
|
|
106
106
|
if (currentModel !== model) {
|
|
107
107
|
logger.debug(`Setting selection model`);
|
|
108
108
|
apiRef.current.setState(state => _extends({}, state, {
|
|
109
|
-
|
|
109
|
+
rowSelection: model
|
|
110
110
|
}));
|
|
111
111
|
apiRef.current.forceUpdate();
|
|
112
112
|
}
|
|
113
113
|
}, [apiRef, logger]);
|
|
114
|
-
const isRowSelected = React.useCallback(id =>
|
|
114
|
+
const isRowSelected = React.useCallback(id => gridRowSelectionStateSelector(apiRef.current.state).includes(id), [apiRef]);
|
|
115
115
|
const isRowSelectable = React.useCallback(id => {
|
|
116
116
|
if (propIsRowSelectable && !propIsRowSelectable(apiRef.current.getRowParams(id))) {
|
|
117
117
|
return false;
|
|
@@ -135,10 +135,10 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
135
135
|
|
|
136
136
|
if (resetSelection) {
|
|
137
137
|
logger.debug(`Setting selection for row ${id}`);
|
|
138
|
-
apiRef.current.
|
|
138
|
+
apiRef.current.setRowSelectionModel(isSelected ? [id] : []);
|
|
139
139
|
} else {
|
|
140
140
|
logger.debug(`Toggling selection for row ${id}`);
|
|
141
|
-
const selection =
|
|
141
|
+
const selection = gridRowSelectionStateSelector(apiRef.current.state);
|
|
142
142
|
const newSelection = selection.filter(el => el !== id);
|
|
143
143
|
|
|
144
144
|
if (isSelected) {
|
|
@@ -148,7 +148,7 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
148
148
|
const isSelectionValid = newSelection.length < 2 || canHaveMultipleSelection;
|
|
149
149
|
|
|
150
150
|
if (isSelectionValid) {
|
|
151
|
-
apiRef.current.
|
|
151
|
+
apiRef.current.setRowSelectionModel(newSelection);
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
}, [apiRef, logger, canHaveMultipleSelection]);
|
|
@@ -176,7 +176,7 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
176
176
|
const isSelectionValid = newSelection.length < 2 || canHaveMultipleSelection;
|
|
177
177
|
|
|
178
178
|
if (isSelectionValid) {
|
|
179
|
-
apiRef.current.
|
|
179
|
+
apiRef.current.setRowSelectionModel(newSelection);
|
|
180
180
|
}
|
|
181
181
|
}, [apiRef, logger, canHaveMultipleSelection]);
|
|
182
182
|
const selectRowRange = React.useCallback(({
|
|
@@ -200,7 +200,7 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
200
200
|
selectRow,
|
|
201
201
|
selectRows,
|
|
202
202
|
selectRowRange,
|
|
203
|
-
|
|
203
|
+
setRowSelectionModel,
|
|
204
204
|
getSelectedRows,
|
|
205
205
|
isRowSelected,
|
|
206
206
|
isRowSelectable
|
|
@@ -215,7 +215,7 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
215
215
|
return;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
const currentSelection =
|
|
218
|
+
const currentSelection = gridRowSelectionStateSelector(apiRef.current.state);
|
|
219
219
|
const rowsLookup = gridRowsLookupSelector(apiRef); // We clone the existing object to avoid mutating the same object returned by the selector to others part of the project
|
|
220
220
|
|
|
221
221
|
const selectionLookup = _extends({}, selectedIdsLookupSelector(apiRef));
|
|
@@ -229,7 +229,7 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
229
229
|
});
|
|
230
230
|
|
|
231
231
|
if (hasChanged) {
|
|
232
|
-
apiRef.current.
|
|
232
|
+
apiRef.current.setRowSelectionModel(Object.values(selectionLookup));
|
|
233
233
|
}
|
|
234
234
|
}, [apiRef, props.keepNonExistentRowsSelected]);
|
|
235
235
|
const handleSingleRowSelection = React.useCallback((id, event) => {
|
|
@@ -249,7 +249,7 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
249
249
|
}
|
|
250
250
|
}, [apiRef, canHaveMultipleSelection, checkboxSelection]);
|
|
251
251
|
const handleCellClick = React.useCallback((params, event) => {
|
|
252
|
-
if (
|
|
252
|
+
if (disableRowSelectionOnClick) {
|
|
253
253
|
return;
|
|
254
254
|
}
|
|
255
255
|
|
|
@@ -280,7 +280,7 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
280
280
|
} else {
|
|
281
281
|
handleSingleRowSelection(params.id, event);
|
|
282
282
|
}
|
|
283
|
-
}, [
|
|
283
|
+
}, [disableRowSelectionOnClick, canHaveMultipleSelection, checkboxSelection, apiRef, expandMouseRowRangeSelection, handleSingleRowSelection]);
|
|
284
284
|
const preventSelectionOnShift = React.useCallback((params, event) => {
|
|
285
285
|
if (canHaveMultipleSelection && event.shiftKey) {
|
|
286
286
|
var _window$getSelection;
|
|
@@ -381,29 +381,29 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
381
381
|
*/
|
|
382
382
|
|
|
383
383
|
React.useEffect(() => {
|
|
384
|
-
if (
|
|
385
|
-
apiRef.current.
|
|
384
|
+
if (propRowSelectionModel !== undefined) {
|
|
385
|
+
apiRef.current.setRowSelectionModel(propRowSelectionModel);
|
|
386
386
|
}
|
|
387
|
-
}, [apiRef,
|
|
388
|
-
const isStateControlled =
|
|
387
|
+
}, [apiRef, propRowSelectionModel]);
|
|
388
|
+
const isStateControlled = propRowSelectionModel != null;
|
|
389
389
|
React.useEffect(() => {
|
|
390
390
|
if (isStateControlled) {
|
|
391
391
|
return;
|
|
392
392
|
} // props.isRowSelectable changed
|
|
393
393
|
|
|
394
394
|
|
|
395
|
-
const currentSelection =
|
|
395
|
+
const currentSelection = gridRowSelectionStateSelector(apiRef.current.state);
|
|
396
396
|
|
|
397
397
|
if (isRowSelectable) {
|
|
398
398
|
const newSelection = currentSelection.filter(id => isRowSelectable(id));
|
|
399
399
|
|
|
400
400
|
if (newSelection.length < currentSelection.length) {
|
|
401
|
-
apiRef.current.
|
|
401
|
+
apiRef.current.setRowSelectionModel(newSelection);
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
404
|
}, [apiRef, isRowSelectable, isStateControlled]);
|
|
405
405
|
React.useEffect(() => {
|
|
406
|
-
const currentSelection =
|
|
406
|
+
const currentSelection = gridRowSelectionStateSelector(apiRef.current.state);
|
|
407
407
|
|
|
408
408
|
if (!canHaveMultipleSelection && currentSelection.length > 1) {
|
|
409
409
|
const {
|
|
@@ -427,7 +427,7 @@ export const useGridSelection = (apiRef, props) => {
|
|
|
427
427
|
|
|
428
428
|
return isSelectable && currentPageRowsLookup[id]; // Check if the row is in the current page
|
|
429
429
|
});
|
|
430
|
-
apiRef.current.
|
|
430
|
+
apiRef.current.setRowSelectionModel(firstSelectableRow !== undefined ? [firstSelectableRow] : []);
|
|
431
431
|
}
|
|
432
|
-
}, [apiRef, canHaveMultipleSelection, checkboxSelection,
|
|
432
|
+
}, [apiRef, canHaveMultipleSelection, checkboxSelection, disableMultipleRowSelection, isRowSelectable, pagination, paginationMode]);
|
|
433
433
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
3
3
|
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const useGridRowSelectionPreProcessors: (apiRef: React.MutableRefObject<GridApiCommunity>, props: DataGridProcessedProps) => void;
|
|
@@ -18,7 +18,7 @@ const useUtilityClasses = ownerState => {
|
|
|
18
18
|
}, [classes]);
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
export const
|
|
21
|
+
export const useGridRowSelectionPreProcessors = (apiRef, props) => {
|
|
22
22
|
const ownerState = {
|
|
23
23
|
classes: props.classes
|
|
24
24
|
};
|
|
@@ -10,6 +10,10 @@ export interface GridRowsInternalCache {
|
|
|
10
10
|
* The value of the `loading` prop since the last time that the rows state was updated.
|
|
11
11
|
*/
|
|
12
12
|
loadingPropBeforePartialUpdates: DataGridProcessedProps['loading'];
|
|
13
|
+
/**
|
|
14
|
+
* The value of the `rowCount` prop since the last time that the rows state was updated.
|
|
15
|
+
*/
|
|
16
|
+
rowCountPropBeforePartialUpdates: DataGridProcessedProps['rowCount'];
|
|
13
17
|
/**
|
|
14
18
|
* Lookup containing the latest model at all time (even those not stored in the state yet).
|
|
15
19
|
*/
|
|
@@ -13,7 +13,7 @@ export declare const buildRootGroup: () => GridGroupNode;
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function checkGridRowIdIsValid(id: GridRowId, row: GridRowModel | Partial<GridRowModel>, detailErrorMessage?: string): void;
|
|
15
15
|
export declare const getRowIdFromRowModel: (rowModel: GridRowModel, getRowId?: GridRowIdGetter, detailErrorMessage?: string) => GridRowId;
|
|
16
|
-
export declare const createRowsInternalCache: ({ rows, getRowId, loading, }: Pick<DataGridProcessedProps, 'rows' | 'getRowId' | 'loading'>) => GridRowsInternalCache;
|
|
16
|
+
export declare const createRowsInternalCache: ({ rows, getRowId, loading, rowCount, }: Pick<DataGridProcessedProps, 'rows' | 'getRowId' | 'loading' | 'rowCount'>) => GridRowsInternalCache;
|
|
17
17
|
export declare const getTopLevelRowCount: ({ tree, rowCountProp, }: {
|
|
18
18
|
tree: GridRowTreeConfig;
|
|
19
19
|
rowCountProp: DataGridProcessedProps['rowCount'];
|
|
@@ -34,7 +34,8 @@ export const getRowIdFromRowModel = (rowModel, getRowId, detailErrorMessage) =>
|
|
|
34
34
|
export const createRowsInternalCache = ({
|
|
35
35
|
rows,
|
|
36
36
|
getRowId,
|
|
37
|
-
loading
|
|
37
|
+
loading,
|
|
38
|
+
rowCount
|
|
38
39
|
}) => {
|
|
39
40
|
const updates = {
|
|
40
41
|
type: 'full',
|
|
@@ -54,6 +55,7 @@ export const createRowsInternalCache = ({
|
|
|
54
55
|
return {
|
|
55
56
|
rowsBeforePartialUpdates: rows,
|
|
56
57
|
loadingPropBeforePartialUpdates: loading,
|
|
58
|
+
rowCountPropBeforePartialUpdates: rowCount,
|
|
57
59
|
updates,
|
|
58
60
|
dataRowIdToIdLookup,
|
|
59
61
|
dataRowIdToModelLookup
|
|
@@ -264,7 +266,8 @@ export const updateCacheWithNewRows = ({
|
|
|
264
266
|
dataRowIdToIdLookup,
|
|
265
267
|
updates: partialUpdates,
|
|
266
268
|
rowsBeforePartialUpdates: previousCache.rowsBeforePartialUpdates,
|
|
267
|
-
loadingPropBeforePartialUpdates: previousCache.loadingPropBeforePartialUpdates
|
|
269
|
+
loadingPropBeforePartialUpdates: previousCache.loadingPropBeforePartialUpdates,
|
|
270
|
+
rowCountPropBeforePartialUpdates: previousCache.rowCountPropBeforePartialUpdates
|
|
268
271
|
};
|
|
269
272
|
};
|
|
270
273
|
export function calculatePinnedRowsHeight(apiRef) {
|
|
@@ -13,7 +13,8 @@ export const rowsStateInitializer = (state, props, apiRef) => {
|
|
|
13
13
|
apiRef.current.unstable_caches.rows = createRowsInternalCache({
|
|
14
14
|
rows: props.rows,
|
|
15
15
|
getRowId: props.getRowId,
|
|
16
|
-
loading: props.loading
|
|
16
|
+
loading: props.loading,
|
|
17
|
+
rowCount: props.rowCount
|
|
17
18
|
});
|
|
18
19
|
return _extends({}, state, {
|
|
19
20
|
rows: getRowsStateFromCache({
|
|
@@ -111,11 +112,12 @@ export const useGridRows = (apiRef, props) => {
|
|
|
111
112
|
cache: createRowsInternalCache({
|
|
112
113
|
rows,
|
|
113
114
|
getRowId: props.getRowId,
|
|
114
|
-
loading: props.loading
|
|
115
|
+
loading: props.loading,
|
|
116
|
+
rowCount: props.rowCount
|
|
115
117
|
}),
|
|
116
118
|
throttle: true
|
|
117
119
|
});
|
|
118
|
-
}, [logger, props.getRowId, props.loading, throttledRowsChange]);
|
|
120
|
+
}, [logger, props.getRowId, props.loading, props.rowCount, throttledRowsChange]);
|
|
119
121
|
const updateRows = React.useCallback(updates => {
|
|
120
122
|
if (props.signature === GridSignature.DataGrid && updates.length > 1) {
|
|
121
123
|
// TODO: Add test with direct call to `apiRef.current.updateRows` in DataGrid after enabling the `apiRef` on the free plan.
|
|
@@ -349,7 +351,8 @@ export const useGridRows = (apiRef, props) => {
|
|
|
349
351
|
cache = createRowsInternalCache({
|
|
350
352
|
rows: props.rows,
|
|
351
353
|
getRowId: props.getRowId,
|
|
352
|
-
loading: props.loading
|
|
354
|
+
loading: props.loading,
|
|
355
|
+
rowCount: props.rowCount
|
|
353
356
|
});
|
|
354
357
|
}
|
|
355
358
|
|
|
@@ -357,7 +360,7 @@ export const useGridRows = (apiRef, props) => {
|
|
|
357
360
|
cache,
|
|
358
361
|
throttle: false
|
|
359
362
|
});
|
|
360
|
-
}, [logger, apiRef, props.rows, props.getRowId, props.loading, throttledRowsChange]);
|
|
363
|
+
}, [logger, apiRef, props.rows, props.getRowId, props.loading, props.rowCount, throttledRowsChange]);
|
|
361
364
|
const handleStrategyProcessorChange = React.useCallback(methodName => {
|
|
362
365
|
if (methodName === 'rowTreeCreation') {
|
|
363
366
|
groupRows();
|
|
@@ -420,7 +423,8 @@ export const useGridRows = (apiRef, props) => {
|
|
|
420
423
|
}
|
|
421
424
|
|
|
422
425
|
const areNewRowsAlreadyInState = apiRef.current.unstable_caches.rows.rowsBeforePartialUpdates === props.rows;
|
|
423
|
-
const isNewLoadingAlreadyInState = apiRef.current.unstable_caches.rows.loadingPropBeforePartialUpdates === props.loading;
|
|
426
|
+
const isNewLoadingAlreadyInState = apiRef.current.unstable_caches.rows.loadingPropBeforePartialUpdates === props.loading;
|
|
427
|
+
const isNewRowCountAlreadyInState = apiRef.current.unstable_caches.rows.rowCountPropBeforePartialUpdates === props.rowCount; // The new rows have already been applied (most likely in the `'rowGroupsPreProcessingChange'` listener)
|
|
424
428
|
|
|
425
429
|
if (areNewRowsAlreadyInState) {
|
|
426
430
|
// If the loading prop has changed, we need to update its value in the state because it won't be done by `throttledRowsChange`
|
|
@@ -434,6 +438,17 @@ export const useGridRows = (apiRef, props) => {
|
|
|
434
438
|
apiRef.current.forceUpdate();
|
|
435
439
|
}
|
|
436
440
|
|
|
441
|
+
if (!isNewRowCountAlreadyInState) {
|
|
442
|
+
apiRef.current.setState(state => _extends({}, state, {
|
|
443
|
+
rows: _extends({}, state.rows, {
|
|
444
|
+
totalRowCount: Math.max(props.rowCount || 0, state.rows.totalRowCount),
|
|
445
|
+
totalTopLevelRowCount: Math.max(props.rowCount || 0, state.rows.totalTopLevelRowCount)
|
|
446
|
+
})
|
|
447
|
+
}));
|
|
448
|
+
apiRef.current.unstable_caches.rows.rowCountPropBeforePartialUpdates = props.rowCount;
|
|
449
|
+
apiRef.current.forceUpdate();
|
|
450
|
+
}
|
|
451
|
+
|
|
437
452
|
return;
|
|
438
453
|
}
|
|
439
454
|
|
|
@@ -442,7 +457,8 @@ export const useGridRows = (apiRef, props) => {
|
|
|
442
457
|
cache: createRowsInternalCache({
|
|
443
458
|
rows: props.rows,
|
|
444
459
|
getRowId: props.getRowId,
|
|
445
|
-
loading: props.loading
|
|
460
|
+
loading: props.loading,
|
|
461
|
+
rowCount: props.rowCount
|
|
446
462
|
}),
|
|
447
463
|
throttle: false
|
|
448
464
|
});
|
|
@@ -35,7 +35,7 @@ export declare const useGridVirtualScroller: (props: UseGridVirtualScrollerProps
|
|
|
35
35
|
getRootProps: ({ style, ...other }?: {
|
|
36
36
|
style?: {} | undefined;
|
|
37
37
|
}) => {
|
|
38
|
-
ref:
|
|
38
|
+
ref: ((instance: HTMLDivElement | null) => void) | null;
|
|
39
39
|
onScroll: (event: React.UIEvent) => void;
|
|
40
40
|
onWheel: (event: React.WheelEvent) => void;
|
|
41
41
|
onTouchMove: (event: React.TouchEvent) => void;
|
|
@@ -9,11 +9,11 @@ import { useGridRootProps } from '../../utils/useGridRootProps';
|
|
|
9
9
|
import { useGridSelector } from '../../utils/useGridSelector';
|
|
10
10
|
import { gridVisibleColumnDefinitionsSelector, gridColumnsTotalWidthSelector, gridColumnPositionsSelector } from '../columns/gridColumnsSelector';
|
|
11
11
|
import { gridFocusCellSelector, gridTabIndexCellSelector } from '../focus/gridFocusStateSelector';
|
|
12
|
-
import { gridEditRowsStateSelector } from '../
|
|
12
|
+
import { gridEditRowsStateSelector } from '../editing/gridEditingSelectors';
|
|
13
13
|
import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
|
|
14
14
|
import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
15
15
|
import { clamp } from '../../../utils/utils';
|
|
16
|
-
import { selectedIdsLookupSelector } from '../
|
|
16
|
+
import { selectedIdsLookupSelector } from '../rowSelection/gridRowSelectionSelector';
|
|
17
17
|
import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
|
|
18
18
|
import { getFirstNonSpannedColumnToRender } from '../columns/gridColumnsUtils';
|
|
19
19
|
import { getMinimalContentHeight } from '../rows/gridRowsUtils'; // Uses binary search to avoid looping through all possible positions
|
|
@@ -3,4 +3,4 @@ import { GridApiCommon } from '../../models/api/gridApiCommon';
|
|
|
3
3
|
/**
|
|
4
4
|
* @deprecated Use `apiRef.current` instead.
|
|
5
5
|
*/
|
|
6
|
-
export declare const useGridApi: <Api extends GridApiCommon
|
|
6
|
+
export declare const useGridApi: <Api extends GridApiCommon<any, any>>(apiRef: React.MutableRefObject<Api>) => Api;
|
|
@@ -14,8 +14,8 @@ declare enum GridSignature {
|
|
|
14
14
|
interface RegistryContainer {
|
|
15
15
|
registry: CleanupTracking | null;
|
|
16
16
|
}
|
|
17
|
-
export declare function createUseGridApiEventHandler(registryContainer: RegistryContainer): <Api extends GridApiCommon, E extends keyof import("../../models").GridEventLookup>(apiRef: React.MutableRefObject<Api>, eventName: E, handler?: GridEventListener<E> | undefined, options?: EventListenerOptions) => void;
|
|
17
|
+
export declare function createUseGridApiEventHandler(registryContainer: RegistryContainer): <Api extends GridApiCommon<any, any>, E extends keyof import("../../models").GridEventLookup>(apiRef: React.MutableRefObject<Api>, eventName: E, handler?: GridEventListener<E> | undefined, options?: EventListenerOptions) => void;
|
|
18
18
|
export declare const unstable_resetCleanupTracking: () => void;
|
|
19
|
-
export declare const useGridApiEventHandler: <Api extends GridApiCommon, E extends keyof import("../../models").GridEventLookup>(apiRef: React.MutableRefObject<Api>, eventName: E, handler?: GridEventListener<E> | undefined, options?: EventListenerOptions) => void;
|
|
19
|
+
export declare const useGridApiEventHandler: <Api extends GridApiCommon<any, any>, E extends keyof import("../../models").GridEventLookup>(apiRef: React.MutableRefObject<Api>, eventName: E, handler?: GridEventListener<E> | undefined, options?: EventListenerOptions) => void;
|
|
20
20
|
export declare function useGridApiOptionHandler<Api extends GridApiCommon, E extends GridEvents>(apiRef: React.MutableRefObject<Api>, eventName: E, handler?: GridEventListener<E>): void;
|
|
21
21
|
export { GridSignature };
|
|
@@ -4,4 +4,4 @@ import { GridApiCommunity } from '../../models/api/gridApiCommunity';
|
|
|
4
4
|
/**
|
|
5
5
|
* Hook that instantiate a [[GridApiRef]].
|
|
6
6
|
*/
|
|
7
|
-
export declare const useGridApiRef: <Api extends GridApiCommon = GridApiCommunity>() => React.MutableRefObject<Api>;
|
|
7
|
+
export declare const useGridApiRef: <Api extends GridApiCommon<any, any> = GridApiCommunity>() => React.MutableRefObject<Api>;
|
|
@@ -6,5 +6,5 @@ declare type DeepPartial<T> = {
|
|
|
6
6
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
7
7
|
};
|
|
8
8
|
export declare type GridStateInitializer<P extends Partial<DataGridProcessedProps> = DataGridProcessedProps, Api extends GridApiCommon = GridApiCommunity> = (state: DeepPartial<Api['state']>, props: P, apiRef: React.MutableRefObject<Api>) => DeepPartial<Api['state']>;
|
|
9
|
-
export declare const useGridInitializeState: <P extends Partial<DataGridProcessedProps<any>>, Api extends GridApiCommon = GridApiCommunity>(initializer: GridStateInitializer<P, Api>, apiRef: React.MutableRefObject<Api>, props: P) => void;
|
|
9
|
+
export declare const useGridInitializeState: <P extends Partial<DataGridProcessedProps<any>>, Api extends GridApiCommon<any, any> = GridApiCommunity>(initializer: GridStateInitializer<P, Api>, apiRef: React.MutableRefObject<Api>, props: P) => void;
|
|
10
10
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridApiCommon } from '../../models';
|
|
3
|
-
export declare const useGridNativeEventListener: <Api extends GridApiCommon, K extends keyof HTMLElementEventMap>(apiRef: React.MutableRefObject<Api>, ref: React.MutableRefObject<HTMLDivElement | null> | (() => HTMLElement | undefined | null), eventName: K, handler?: ((event: HTMLElementEventMap[K]) => any) | undefined, options?: AddEventListenerOptions) => void;
|
|
3
|
+
export declare const useGridNativeEventListener: <Api extends GridApiCommon<any, any>, K extends keyof HTMLElementEventMap>(apiRef: React.MutableRefObject<Api>, ref: React.MutableRefObject<HTMLDivElement | null> | (() => HTMLElement | undefined | null), eventName: K, handler?: ((event: HTMLElementEventMap[K]) => any) | undefined, options?: AddEventListenerOptions) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridApiCommon } from '../../models/api/gridApiCommon';
|
|
3
3
|
import { OutputSelector } from '../../utils/createSelector';
|
|
4
|
-
export declare const useGridSelector: <Api extends GridApiCommon, T>(apiRef: React.MutableRefObject<Api>, selector: OutputSelector<Api["state"], T> | ((state: Api["state"]) => T)) => T;
|
|
4
|
+
export declare const useGridSelector: <Api extends GridApiCommon<any, any>, T>(apiRef: React.MutableRefObject<Api>, selector: OutputSelector<Api["state"], T> | ((state: Api["state"]) => T)) => T;
|
|
@@ -4,4 +4,4 @@ import { GridApiCommunity } from '../../models/api/gridApiCommunity';
|
|
|
4
4
|
/**
|
|
5
5
|
* @deprecated Use `apiRef.current.state`, `apiRef.current.setState` and `apiRef.current.forceUpdate` instead.
|
|
6
6
|
*/
|
|
7
|
-
export declare const useGridState: <Api extends GridApiCommon = GridApiCommunity>(apiRef: React.MutableRefObject<Api>) => readonly [any, any,
|
|
7
|
+
export declare const useGridState: <Api extends GridApiCommon<any, any> = GridApiCommunity>(apiRef: React.MutableRefObject<Api>) => readonly [any, <S extends any, K extends "filter">(state: S | ((previousState: S) => S), reason?: import("../..").GridControlledStateReasonLookup[K] | undefined) => boolean, () => void];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { DataGridProcessedProps } from '../../models/props/DataGridProps';
|
|
3
3
|
import type { GridApiCommon, GridRowEntry } from '../../models';
|
|
4
|
-
export declare const getVisibleRows: <Api extends GridApiCommon
|
|
4
|
+
export declare const getVisibleRows: <Api extends GridApiCommon<any, any>>(apiRef: React.MutableRefObject<Api>, props: Pick<DataGridProcessedProps, 'pagination' | 'paginationMode'>) => {
|
|
5
5
|
rows: GridRowEntry<import("../../models").GridValidRowModel>[];
|
|
6
6
|
range: {
|
|
7
7
|
firstRowIndex: number;
|
|
@@ -15,7 +15,7 @@ export declare const getVisibleRows: <Api extends GridApiCommon>(apiRef: React.M
|
|
|
15
15
|
* - If the row tree has several layers, it contains up to `state.pageSize` top level rows and all their descendants.
|
|
16
16
|
* - If the row tree is flat, it only contains up to `state.pageSize` rows.
|
|
17
17
|
*/
|
|
18
|
-
export declare const useGridVisibleRows: <Api extends GridApiCommon
|
|
18
|
+
export declare const useGridVisibleRows: <Api extends GridApiCommon<any, any>>(apiRef: React.MutableRefObject<Api>, props: Pick<DataGridProcessedProps, 'pagination' | 'paginationMode'>) => {
|
|
19
19
|
rows: GridRowEntry<import("../../models").GridValidRowModel>[];
|
|
20
20
|
range: {
|
|
21
21
|
firstRowIndex: number;
|
package/index.js
CHANGED
package/internals/index.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ export { useGridColumnMenu, columnMenuStateInitializer, } from '../hooks/feature
|
|
|
14
14
|
export { useGridColumns, columnsStateInitializer } from '../hooks/features/columns/useGridColumns';
|
|
15
15
|
export { useGridColumnSpanning } from '../hooks/features/columns/useGridColumnSpanning';
|
|
16
16
|
export { useGridColumnGrouping, columnGroupsStateInitializer, } from '../hooks/features/columnGrouping/useGridColumnGrouping';
|
|
17
|
-
export { useGridColumnGroupingPreProcessors } from '../hooks/features/columnGrouping/useGridColumnGroupingPreProcessors';
|
|
18
17
|
export type { GridColumnRawLookup, GridColumnsRawState, GridHydrateColumnsValue, } from '../hooks/features/columns/gridColumnsInterfaces';
|
|
19
18
|
export { useGridDensity, densityStateInitializer } from '../hooks/features/density/useGridDensity';
|
|
20
19
|
export { useGridCsvExport } from '../hooks/features/export/useGridCsvExport';
|
|
@@ -26,8 +25,7 @@ export { useGridFocus, focusStateInitializer } from '../hooks/features/focus/use
|
|
|
26
25
|
export { useGridKeyboardNavigation } from '../hooks/features/keyboardNavigation/useGridKeyboardNavigation';
|
|
27
26
|
export { useGridPagination, paginationStateInitializer, } from '../hooks/features/pagination/useGridPagination';
|
|
28
27
|
export { useGridPreferencesPanel, preferencePanelStateInitializer, } from '../hooks/features/preferencesPanel/useGridPreferencesPanel';
|
|
29
|
-
export { useGridEditing
|
|
30
|
-
export { useGridEditing as useGridEditing_old, editingStateInitializer as editingStateInitializer_old, } from '../hooks/features/editRows/useGridEditing.old';
|
|
28
|
+
export { useGridEditing, editingStateInitializer } from '../hooks/features/editing/useGridEditing';
|
|
31
29
|
export { useGridRows, rowsStateInitializer } from '../hooks/features/rows/useGridRows';
|
|
32
30
|
export { useGridRowsPreProcessors } from '../hooks/features/rows/useGridRowsPreProcessors';
|
|
33
31
|
export type { GridRowTreeCreationParams, GridRowTreeCreationValue, GridHydrateRowsValue, GridRowsPartialUpdates, GridRowsPartialUpdateAction, GridTreeDepths, GridRowTreeUpdatedGroupsManager, GridRowTreeUpdateGroupAction, GridPinnedRowsState, } from '../hooks/features/rows/gridRowsInterfaces';
|
|
@@ -37,8 +35,8 @@ export { useGridParamsApi } from '../hooks/features/rows/useGridParamsApi';
|
|
|
37
35
|
export { getRowIdFromRowModel } from '../hooks/features/rows/gridRowsUtils';
|
|
38
36
|
export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector, } from '../hooks/features/rows/gridRowsSelector';
|
|
39
37
|
export { calculatePinnedRowsHeight } from '../hooks/features/rows/gridRowsUtils';
|
|
40
|
-
export {
|
|
41
|
-
export {
|
|
38
|
+
export { useGridRowSelection, rowSelectionStateInitializer, } from '../hooks/features/rowSelection/useGridRowSelection';
|
|
39
|
+
export { useGridRowSelectionPreProcessors } from '../hooks/features/rowSelection/useGridRowSelectionPreProcessors';
|
|
42
40
|
export { useGridSorting, sortingStateInitializer } from '../hooks/features/sorting/useGridSorting';
|
|
43
41
|
export type { GridSortingModelApplier } from '../hooks/features/sorting/gridSortingState';
|
|
44
42
|
export { useGridScroll } from '../hooks/features/scroll/useGridScroll';
|
package/internals/index.js
CHANGED
|
@@ -12,7 +12,6 @@ export { useGridColumnMenu, columnMenuStateInitializer } from '../hooks/features
|
|
|
12
12
|
export { useGridColumns, columnsStateInitializer } from '../hooks/features/columns/useGridColumns';
|
|
13
13
|
export { useGridColumnSpanning } from '../hooks/features/columns/useGridColumnSpanning';
|
|
14
14
|
export { useGridColumnGrouping, columnGroupsStateInitializer } from '../hooks/features/columnGrouping/useGridColumnGrouping';
|
|
15
|
-
export { useGridColumnGroupingPreProcessors } from '../hooks/features/columnGrouping/useGridColumnGroupingPreProcessors';
|
|
16
15
|
export { useGridDensity, densityStateInitializer } from '../hooks/features/density/useGridDensity';
|
|
17
16
|
export { useGridCsvExport } from '../hooks/features/export/useGridCsvExport';
|
|
18
17
|
export { useGridPrintExport } from '../hooks/features/export/useGridPrintExport';
|
|
@@ -22,8 +21,7 @@ export { useGridFocus, focusStateInitializer } from '../hooks/features/focus/use
|
|
|
22
21
|
export { useGridKeyboardNavigation } from '../hooks/features/keyboardNavigation/useGridKeyboardNavigation';
|
|
23
22
|
export { useGridPagination, paginationStateInitializer } from '../hooks/features/pagination/useGridPagination';
|
|
24
23
|
export { useGridPreferencesPanel, preferencePanelStateInitializer } from '../hooks/features/preferencesPanel/useGridPreferencesPanel';
|
|
25
|
-
export { useGridEditing
|
|
26
|
-
export { useGridEditing as useGridEditing_old, editingStateInitializer as editingStateInitializer_old } from '../hooks/features/editRows/useGridEditing.old';
|
|
24
|
+
export { useGridEditing, editingStateInitializer } from '../hooks/features/editing/useGridEditing';
|
|
27
25
|
export { useGridRows, rowsStateInitializer } from '../hooks/features/rows/useGridRows';
|
|
28
26
|
export { useGridRowsPreProcessors } from '../hooks/features/rows/useGridRowsPreProcessors';
|
|
29
27
|
export { getTreeNodeDescendants, buildRootGroup } from '../hooks/features/rows/gridRowsUtils';
|
|
@@ -32,8 +30,8 @@ export { useGridParamsApi } from '../hooks/features/rows/useGridParamsApi';
|
|
|
32
30
|
export { getRowIdFromRowModel } from '../hooks/features/rows/gridRowsUtils';
|
|
33
31
|
export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector } from '../hooks/features/rows/gridRowsSelector';
|
|
34
32
|
export { calculatePinnedRowsHeight } from '../hooks/features/rows/gridRowsUtils';
|
|
35
|
-
export {
|
|
36
|
-
export {
|
|
33
|
+
export { useGridRowSelection, rowSelectionStateInitializer } from '../hooks/features/rowSelection/useGridRowSelection';
|
|
34
|
+
export { useGridRowSelectionPreProcessors } from '../hooks/features/rowSelection/useGridRowSelectionPreProcessors';
|
|
37
35
|
export { useGridSorting, sortingStateInitializer } from '../hooks/features/sorting/useGridSorting';
|
|
38
36
|
export { useGridScroll } from '../hooks/features/scroll/useGridScroll';
|
|
39
37
|
export { useGridEvents } from '../hooks/features/events/useGridEvents';
|
|
@@ -168,7 +168,7 @@ DataGridRaw.propTypes = {
|
|
|
168
168
|
* If `true`, the selection on click on a row or cell is disabled.
|
|
169
169
|
* @default false
|
|
170
170
|
*/
|
|
171
|
-
|
|
171
|
+
disableRowSelectionOnClick: PropTypes.bool,
|
|
172
172
|
|
|
173
173
|
/**
|
|
174
174
|
* If `true`, the virtualization is disabled.
|
|
@@ -198,8 +198,6 @@ DataGridRaw.propTypes = {
|
|
|
198
198
|
*/
|
|
199
199
|
experimentalFeatures: PropTypes.shape({
|
|
200
200
|
columnGrouping: PropTypes.bool,
|
|
201
|
-
newEditingApi: PropTypes.bool,
|
|
202
|
-
preventCommitWhileValidating: PropTypes.bool,
|
|
203
201
|
warnIfFocusStateIsNotSynced: PropTypes.bool
|
|
204
202
|
}),
|
|
205
203
|
|
|
@@ -376,14 +374,6 @@ DataGridRaw.propTypes = {
|
|
|
376
374
|
*/
|
|
377
375
|
onCellDoubleClick: PropTypes.func,
|
|
378
376
|
|
|
379
|
-
/**
|
|
380
|
-
* Callback fired when the cell changes are committed.
|
|
381
|
-
* @param {GridCellEditCommitParams} params With all properties from [[GridCellEditCommitParams]].
|
|
382
|
-
* @param {MuiEvent<MuiBaseEvent>} event The event that caused this prop to be called.
|
|
383
|
-
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
384
|
-
*/
|
|
385
|
-
onCellEditCommit: PropTypes.func,
|
|
386
|
-
|
|
387
377
|
/**
|
|
388
378
|
* Callback fired when the cell turns to edit mode.
|
|
389
379
|
* @param {GridCellParams} params With all properties from [[GridCellParams]].
|
|
@@ -484,15 +474,6 @@ DataGridRaw.propTypes = {
|
|
|
484
474
|
*/
|
|
485
475
|
onColumnVisibilityModelChange: PropTypes.func,
|
|
486
476
|
|
|
487
|
-
/**
|
|
488
|
-
* Callback fired when the edit cell value changes.
|
|
489
|
-
* @param {GridEditCellPropsParams} params With all properties from [[GridEditCellPropsParams]].
|
|
490
|
-
* @param {MuiEvent<React.SyntheticEvent>} event The event that caused this prop to be called.
|
|
491
|
-
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
492
|
-
* @deprecated use `preProcessEditCellProps` from the [`GridColDef`](/x/api/data-grid/grid-col-def/)
|
|
493
|
-
*/
|
|
494
|
-
onEditCellPropsChange: PropTypes.func,
|
|
495
|
-
|
|
496
477
|
/**
|
|
497
478
|
* Callback fired when the `editRowsModel` changes.
|
|
498
479
|
* @param {GridEditRowsModel} editRowsModel With all properties from [[GridEditRowsModel]].
|
|
@@ -622,10 +603,10 @@ DataGridRaw.propTypes = {
|
|
|
622
603
|
|
|
623
604
|
/**
|
|
624
605
|
* Callback fired when the selection state of one or multiple rows changes.
|
|
625
|
-
* @param {
|
|
606
|
+
* @param {GridRowSelectionModel} rowSelectionModel With all the row ids [[GridSelectionModel]].
|
|
626
607
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
627
608
|
*/
|
|
628
|
-
|
|
609
|
+
onRowSelectionModelChange: PropTypes.func,
|
|
629
610
|
|
|
630
611
|
/**
|
|
631
612
|
* Callback fired when the sort model changes before a column is sorted.
|
|
@@ -679,7 +660,6 @@ DataGridRaw.propTypes = {
|
|
|
679
660
|
|
|
680
661
|
/**
|
|
681
662
|
* Callback called before updating a row with new values in the row and cell editing.
|
|
682
|
-
* Only applied if `props.experimentalFeatures.newEditingApi: true`.
|
|
683
663
|
* @template R
|
|
684
664
|
* @param {R} newRow Row object with the new values.
|
|
685
665
|
* @param {R} oldRow Row object with the old values.
|
|
@@ -715,6 +695,17 @@ DataGridRaw.propTypes = {
|
|
|
715
695
|
*/
|
|
716
696
|
rows: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
717
697
|
|
|
698
|
+
/**
|
|
699
|
+
* Sets the row selection model of the grid.
|
|
700
|
+
*/
|
|
701
|
+
rowSelectionModel: chainPropTypes(PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.array]), function (props) {
|
|
702
|
+
if (!props.checkboxSelection && Array.isArray(props.rowSelectionModel) && props.rowSelectionModel.length > 1) {
|
|
703
|
+
return new Error(["MUI: `<DataGrid rowSelectionModel={".concat(JSON.stringify(props.rowSelectionModel), "} />` is not a valid prop."), 'rowSelectionModel can only be of 1 item in DataGrid.', '', 'You need to upgrade to DataGridPro or DataGridPremium component to unlock multiple selection.'].join('\n'));
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
return null;
|
|
707
|
+
}),
|
|
708
|
+
|
|
718
709
|
/**
|
|
719
710
|
* Sets the type of space between rows added by `getRowSpacing`.
|
|
720
711
|
* @default "margin"
|
|
@@ -738,17 +729,6 @@ DataGridRaw.propTypes = {
|
|
|
738
729
|
*/
|
|
739
730
|
scrollbarSize: PropTypes.number,
|
|
740
731
|
|
|
741
|
-
/**
|
|
742
|
-
* Set the selection model of the grid.
|
|
743
|
-
*/
|
|
744
|
-
selectionModel: chainPropTypes(PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.array]), function (props) {
|
|
745
|
-
if (!props.checkboxSelection && Array.isArray(props.selectionModel) && props.selectionModel.length > 1) {
|
|
746
|
-
return new Error(["MUI: `<DataGrid selectionModel={".concat(JSON.stringify(props.selectionModel), "} />` is not a valid prop."), 'selectionModel can only be of 1 item in DataGrid.', '', 'You need to upgrade to DataGridPro or DataGridPremium component to unlock multiple selection.'].join('\n'));
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
return null;
|
|
750
|
-
}),
|
|
751
|
-
|
|
752
732
|
/**
|
|
753
733
|
* If `true`, the right border of the cells are displayed.
|
|
754
734
|
* @default false
|