@mui/x-data-grid 8.0.0-alpha.12 → 8.0.0-alpha.13
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 +299 -0
- package/DataGrid/DataGrid.js +31 -22
- package/DataGrid/useDataGridProps.js +1 -1
- package/colDef/gridCheckboxSelectionColDef.js +1 -3
- package/components/GridFooter.js +1 -1
- package/components/GridHeader.js +1 -1
- package/components/GridPagination.js +5 -6
- package/components/GridRowCount.js +4 -5
- package/components/GridScrollArea.js +4 -3
- package/components/GridSelectedRowCount.js +5 -6
- package/components/GridShadowScrollArea.d.ts +8 -0
- package/components/GridShadowScrollArea.js +82 -0
- package/components/cell/GridEditInputCell.js +2 -3
- package/components/columnSelection/GridHeaderCheckbox.js +51 -17
- package/components/columnsManagement/GridColumnsManagement.js +59 -61
- package/components/containers/GridOverlay.js +6 -8
- package/components/containers/GridRoot.js +4 -2
- package/components/containers/GridRootStyles.d.ts +1 -2
- package/components/containers/GridRootStyles.js +77 -100
- package/components/containers/GridToolbarContainer.js +5 -6
- package/components/menu/GridMenu.js +7 -6
- package/components/menu/columnMenu/GridColumnHeaderMenu.js +4 -3
- package/components/panel/GridPanel.js +18 -20
- package/components/panel/GridPanelContent.js +6 -8
- package/components/panel/GridPanelFooter.js +5 -6
- package/components/panel/GridPanelHeader.js +4 -5
- package/components/panel/filterPanel/GridFilterForm.js +13 -20
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.ts +2 -2
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +10 -39
- package/components/panel/filterPanel/GridFilterInputMultipleValue.d.ts +2 -2
- package/components/panel/filterPanel/GridFilterInputMultipleValue.js +20 -45
- package/components/panel/filterPanel/GridFilterInputValue.js +3 -6
- package/components/toolbar/GridToolbarFilterButton.js +5 -6
- package/components/toolbar/GridToolbarQuickFilter.js +23 -30
- package/components/virtualization/GridVirtualScrollbar.js +8 -5
- package/components/virtualization/GridVirtualScrollerFiller.js +2 -1
- package/constants/cssVariables.d.ts +294 -0
- package/constants/cssVariables.js +168 -0
- package/constants/dataGridPropsDefaultValues.js +1 -0
- package/constants/defaultGridSlotsComponents.js +1 -1
- package/constants/gridClasses.d.ts +13 -0
- package/constants/gridClasses.js +1 -1
- package/context/GridContextProvider.js +4 -1
- package/esm/DataGrid/DataGrid.js +31 -22
- package/esm/DataGrid/useDataGridProps.js +1 -1
- package/esm/colDef/gridCheckboxSelectionColDef.js +1 -3
- package/esm/components/GridFooter.js +2 -2
- package/esm/components/GridHeader.js +1 -1
- package/esm/components/GridPagination.js +5 -6
- package/esm/components/GridRowCount.js +4 -5
- package/esm/components/GridScrollArea.js +2 -1
- package/esm/components/GridSelectedRowCount.js +5 -6
- package/esm/components/GridShadowScrollArea.d.ts +8 -0
- package/esm/components/GridShadowScrollArea.js +74 -0
- package/esm/components/cell/GridEditInputCell.js +2 -3
- package/esm/components/columnSelection/GridHeaderCheckbox.js +51 -17
- package/esm/components/columnsManagement/GridColumnsManagement.js +60 -62
- package/esm/components/containers/GridOverlay.js +6 -8
- package/esm/components/containers/GridRoot.js +4 -2
- package/esm/components/containers/GridRootStyles.d.ts +1 -2
- package/esm/components/containers/GridRootStyles.js +78 -101
- package/esm/components/containers/GridToolbarContainer.js +5 -6
- package/esm/components/menu/GridMenu.js +7 -6
- package/esm/components/menu/columnMenu/GridColumnHeaderMenu.js +2 -1
- package/esm/components/panel/GridPanel.js +18 -20
- package/esm/components/panel/GridPanelContent.js +6 -8
- package/esm/components/panel/GridPanelFooter.js +5 -6
- package/esm/components/panel/GridPanelHeader.js +4 -5
- package/esm/components/panel/filterPanel/GridFilterForm.js +13 -20
- package/esm/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.ts +2 -2
- package/esm/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +10 -39
- package/esm/components/panel/filterPanel/GridFilterInputMultipleValue.d.ts +2 -2
- package/esm/components/panel/filterPanel/GridFilterInputMultipleValue.js +19 -44
- package/esm/components/panel/filterPanel/GridFilterInputValue.js +3 -6
- package/esm/components/toolbar/GridToolbarFilterButton.js +5 -6
- package/esm/components/toolbar/GridToolbarQuickFilter.js +23 -30
- package/esm/components/virtualization/GridVirtualScrollbar.js +3 -1
- package/esm/components/virtualization/GridVirtualScrollerFiller.js +2 -1
- package/esm/constants/cssVariables.d.ts +294 -0
- package/esm/constants/cssVariables.js +161 -0
- package/esm/constants/dataGridPropsDefaultValues.js +1 -0
- package/esm/constants/defaultGridSlotsComponents.js +2 -2
- package/esm/constants/gridClasses.d.ts +13 -0
- package/esm/constants/gridClasses.js +1 -1
- package/esm/context/GridContextProvider.js +4 -1
- package/esm/hooks/features/clipboard/useGridClipboard.js +3 -2
- package/esm/hooks/features/columnHeaders/useGridColumnHeaders.js +2 -2
- package/esm/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/esm/hooks/features/columns/gridColumnsInterfaces.d.ts +1 -0
- package/esm/hooks/features/columns/gridColumnsSelector.d.ts +7 -0
- package/esm/hooks/features/columns/gridColumnsSelector.js +8 -0
- package/esm/hooks/features/columns/gridColumnsUtils.d.ts +3 -1
- package/esm/hooks/features/columns/gridColumnsUtils.js +6 -3
- package/esm/hooks/features/columns/index.d.ts +1 -1
- package/esm/hooks/features/columns/index.js +1 -1
- package/esm/hooks/features/columns/useGridColumns.js +4 -2
- package/esm/hooks/features/dataSource/gridDataSourceError.d.ts +31 -0
- package/esm/hooks/features/dataSource/gridDataSourceError.js +32 -0
- package/esm/hooks/features/dataSource/index.d.ts +2 -0
- package/esm/hooks/features/dataSource/index.js +2 -0
- package/esm/hooks/features/dataSource/models.d.ts +1 -1
- package/esm/hooks/features/dataSource/useGridDataSourceBase.d.ts +1 -1
- package/esm/hooks/features/dataSource/useGridDataSourceBase.js +27 -17
- package/esm/hooks/features/dimensions/useGridDimensions.js +11 -10
- package/esm/hooks/features/editing/useGridCellEditing.js +2 -1
- package/esm/hooks/features/editing/useGridRowEditing.js +2 -1
- package/esm/hooks/features/export/utils.js +4 -2
- package/esm/hooks/features/focus/useGridFocus.js +3 -2
- package/esm/hooks/features/index.d.ts +1 -1
- package/esm/hooks/features/index.js +1 -1
- package/esm/hooks/features/rowSelection/gridRowSelectionSelector.d.ts +3 -3
- package/esm/hooks/features/rowSelection/gridRowSelectionSelector.js +27 -7
- package/esm/hooks/features/rowSelection/useGridRowSelection.js +148 -81
- package/esm/hooks/features/rowSelection/utils.d.ts +2 -2
- package/esm/hooks/features/rowSelection/utils.js +11 -11
- package/esm/hooks/features/rows/gridRowsInterfaces.d.ts +1 -1
- package/esm/hooks/features/rows/gridRowsUtils.d.ts +2 -1
- package/esm/hooks/features/rows/gridRowsUtils.js +8 -0
- package/esm/hooks/features/rows/useGridParamsApi.js +2 -8
- package/esm/hooks/features/rows/useGridRowAriaAttributes.js +2 -4
- package/esm/hooks/features/rows/useGridRows.d.ts +2 -2
- package/esm/hooks/features/rows/useGridRows.js +7 -7
- package/esm/hooks/features/virtualization/useGridVirtualScroller.js +5 -9
- package/esm/hooks/utils/useGridSelector.js +4 -1
- package/esm/hooks/utils/useIsSSR.js +4 -1
- package/esm/index.js +1 -1
- package/esm/internals/index.d.ts +2 -1
- package/esm/internals/index.js +2 -1
- package/esm/internals/utils/propValidation.js +1 -1
- package/esm/locales/bnBD.d.ts +2 -0
- package/esm/locales/bnBD.js +167 -0
- package/esm/locales/deDE.js +3 -5
- package/esm/locales/huHU.js +10 -13
- package/esm/locales/index.d.ts +1 -0
- package/esm/locales/index.js +1 -0
- package/esm/locales/ruRU.js +17 -21
- package/esm/material/index.d.ts +1 -0
- package/esm/material/index.js +164 -49
- package/esm/material/variables.d.ts +5 -0
- package/esm/material/variables.js +89 -0
- package/esm/models/api/gridRowSelectionApi.d.ts +4 -2
- package/esm/models/api/gridSortApi.d.ts +1 -1
- package/esm/models/configuration/gridConfiguration.d.ts +7 -1
- package/esm/models/gridBaseSlots.d.ts +56 -6
- package/esm/models/gridDataSource.d.ts +9 -4
- package/esm/models/gridRowSelectionManager.d.ts +9 -0
- package/esm/models/gridRowSelectionManager.js +36 -0
- package/esm/models/gridRowSelectionModel.d.ts +4 -2
- package/esm/models/gridSlotsComponent.d.ts +7 -27
- package/esm/models/gridSlotsComponentsProps.d.ts +3 -11
- package/esm/models/gridSortModel.d.ts +1 -1
- package/esm/models/index.d.ts +2 -1
- package/esm/models/index.js +2 -3
- package/esm/models/props/DataGridProps.d.ts +22 -17
- package/esm/utils/css/context.d.ts +14 -0
- package/esm/utils/css/context.js +54 -0
- package/esm/utils/index.d.ts +2 -1
- package/esm/utils/index.js +1 -1
- package/hooks/features/clipboard/useGridClipboard.js +3 -2
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +2 -2
- package/hooks/features/columnResize/useGridColumnResize.js +28 -27
- package/hooks/features/columns/gridColumnsInterfaces.d.ts +1 -0
- package/hooks/features/columns/gridColumnsSelector.d.ts +7 -0
- package/hooks/features/columns/gridColumnsSelector.js +9 -1
- package/hooks/features/columns/gridColumnsUtils.d.ts +3 -1
- package/hooks/features/columns/gridColumnsUtils.js +6 -3
- package/hooks/features/columns/index.d.ts +1 -1
- package/hooks/features/columns/index.js +94 -10
- package/hooks/features/columns/useGridColumns.js +4 -2
- package/hooks/features/dataSource/gridDataSourceError.d.ts +31 -0
- package/hooks/features/dataSource/gridDataSourceError.js +40 -0
- package/hooks/features/dataSource/index.d.ts +2 -0
- package/hooks/features/dataSource/index.js +25 -0
- package/hooks/features/dataSource/models.d.ts +1 -1
- package/hooks/features/dataSource/useGridDataSourceBase.d.ts +1 -1
- package/hooks/features/dataSource/useGridDataSourceBase.js +27 -17
- package/hooks/features/dimensions/useGridDimensions.js +19 -18
- package/hooks/features/editing/useGridCellEditing.js +10 -9
- package/hooks/features/editing/useGridRowEditing.js +11 -10
- package/hooks/features/export/utils.js +4 -2
- package/hooks/features/focus/useGridFocus.js +8 -7
- package/hooks/features/index.d.ts +1 -1
- package/hooks/features/index.js +11 -28
- package/hooks/features/rowSelection/gridRowSelectionSelector.d.ts +3 -3
- package/hooks/features/rowSelection/gridRowSelectionSelector.js +27 -7
- package/hooks/features/rowSelection/useGridRowSelection.js +146 -79
- package/hooks/features/rowSelection/utils.d.ts +2 -2
- package/hooks/features/rowSelection/utils.js +10 -10
- package/hooks/features/rows/gridRowsInterfaces.d.ts +1 -1
- package/hooks/features/rows/gridRowsUtils.d.ts +2 -1
- package/hooks/features/rows/gridRowsUtils.js +10 -1
- package/hooks/features/rows/useGridParamsApi.js +2 -8
- package/hooks/features/rows/useGridRowAriaAttributes.js +2 -4
- package/hooks/features/rows/useGridRows.d.ts +2 -2
- package/hooks/features/rows/useGridRows.js +7 -7
- package/hooks/features/virtualization/useGridVirtualScroller.js +21 -25
- package/hooks/utils/useGridSelector.js +6 -2
- package/hooks/utils/useIsSSR.js +6 -2
- package/index.js +1 -1
- package/internals/index.d.ts +2 -1
- package/internals/index.js +15 -0
- package/internals/utils/propValidation.js +1 -1
- package/locales/bnBD.d.ts +2 -0
- package/locales/bnBD.js +173 -0
- package/locales/deDE.js +3 -5
- package/locales/huHU.js +10 -13
- package/locales/index.d.ts +1 -0
- package/locales/index.js +11 -0
- package/locales/ruRU.js +17 -21
- package/material/index.d.ts +1 -0
- package/material/index.js +170 -49
- package/material/variables.d.ts +5 -0
- package/material/variables.js +95 -0
- package/models/api/gridRowSelectionApi.d.ts +4 -2
- package/models/api/gridSortApi.d.ts +1 -1
- package/models/configuration/gridConfiguration.d.ts +7 -1
- package/models/gridBaseSlots.d.ts +56 -6
- package/models/gridDataSource.d.ts +9 -4
- package/models/gridRowSelectionManager.d.ts +9 -0
- package/models/gridRowSelectionManager.js +43 -0
- package/models/gridRowSelectionModel.d.ts +4 -2
- package/models/gridSlotsComponent.d.ts +7 -27
- package/models/gridSlotsComponentsProps.d.ts +3 -11
- package/models/gridSortModel.d.ts +1 -1
- package/models/index.d.ts +2 -1
- package/models/index.js +34 -11
- package/models/props/DataGridProps.d.ts +22 -17
- package/modern/DataGrid/DataGrid.js +31 -22
- package/modern/DataGrid/useDataGridProps.js +1 -1
- package/modern/colDef/gridCheckboxSelectionColDef.js +1 -3
- package/modern/components/GridFooter.js +2 -2
- package/modern/components/GridHeader.js +1 -1
- package/modern/components/GridPagination.js +5 -6
- package/modern/components/GridRowCount.js +4 -5
- package/modern/components/GridScrollArea.js +2 -1
- package/modern/components/GridSelectedRowCount.js +5 -6
- package/modern/components/GridShadowScrollArea.d.ts +8 -0
- package/modern/components/GridShadowScrollArea.js +74 -0
- package/modern/components/cell/GridEditInputCell.js +2 -3
- package/modern/components/columnSelection/GridHeaderCheckbox.js +51 -17
- package/modern/components/columnsManagement/GridColumnsManagement.js +60 -62
- package/modern/components/containers/GridOverlay.js +6 -8
- package/modern/components/containers/GridRoot.js +4 -2
- package/modern/components/containers/GridRootStyles.d.ts +1 -2
- package/modern/components/containers/GridRootStyles.js +78 -101
- package/modern/components/containers/GridToolbarContainer.js +5 -6
- package/modern/components/menu/GridMenu.js +7 -6
- package/modern/components/menu/columnMenu/GridColumnHeaderMenu.js +2 -1
- package/modern/components/panel/GridPanel.js +18 -20
- package/modern/components/panel/GridPanelContent.js +6 -8
- package/modern/components/panel/GridPanelFooter.js +5 -6
- package/modern/components/panel/GridPanelHeader.js +4 -5
- package/modern/components/panel/filterPanel/GridFilterForm.js +13 -20
- package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.ts +2 -2
- package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +10 -39
- package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.d.ts +2 -2
- package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.js +19 -44
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +3 -6
- package/modern/components/toolbar/GridToolbarFilterButton.js +5 -6
- package/modern/components/toolbar/GridToolbarQuickFilter.js +23 -30
- package/modern/components/virtualization/GridVirtualScrollbar.js +3 -1
- package/modern/components/virtualization/GridVirtualScrollerFiller.js +2 -1
- package/modern/constants/cssVariables.d.ts +294 -0
- package/modern/constants/cssVariables.js +161 -0
- package/modern/constants/dataGridPropsDefaultValues.js +1 -0
- package/modern/constants/defaultGridSlotsComponents.js +2 -2
- package/modern/constants/gridClasses.d.ts +13 -0
- package/modern/constants/gridClasses.js +1 -1
- package/modern/context/GridContextProvider.js +4 -1
- package/modern/hooks/features/clipboard/useGridClipboard.js +3 -2
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +2 -2
- package/modern/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/modern/hooks/features/columns/gridColumnsInterfaces.d.ts +1 -0
- package/modern/hooks/features/columns/gridColumnsSelector.d.ts +7 -0
- package/modern/hooks/features/columns/gridColumnsSelector.js +8 -0
- package/modern/hooks/features/columns/gridColumnsUtils.d.ts +3 -1
- package/modern/hooks/features/columns/gridColumnsUtils.js +6 -3
- package/modern/hooks/features/columns/index.d.ts +1 -1
- package/modern/hooks/features/columns/index.js +1 -1
- package/modern/hooks/features/columns/useGridColumns.js +4 -2
- package/modern/hooks/features/dataSource/gridDataSourceError.d.ts +31 -0
- package/modern/hooks/features/dataSource/gridDataSourceError.js +32 -0
- package/modern/hooks/features/dataSource/index.d.ts +2 -0
- package/modern/hooks/features/dataSource/index.js +2 -0
- package/modern/hooks/features/dataSource/models.d.ts +1 -1
- package/modern/hooks/features/dataSource/useGridDataSourceBase.d.ts +1 -1
- package/modern/hooks/features/dataSource/useGridDataSourceBase.js +27 -17
- package/modern/hooks/features/dimensions/useGridDimensions.js +11 -10
- package/modern/hooks/features/editing/useGridCellEditing.js +2 -1
- package/modern/hooks/features/editing/useGridRowEditing.js +2 -1
- package/modern/hooks/features/export/utils.js +4 -2
- package/modern/hooks/features/focus/useGridFocus.js +3 -2
- package/modern/hooks/features/index.d.ts +1 -1
- package/modern/hooks/features/index.js +1 -1
- package/modern/hooks/features/rowSelection/gridRowSelectionSelector.d.ts +3 -3
- package/modern/hooks/features/rowSelection/gridRowSelectionSelector.js +27 -7
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +148 -81
- package/modern/hooks/features/rowSelection/utils.d.ts +2 -2
- package/modern/hooks/features/rowSelection/utils.js +11 -11
- package/modern/hooks/features/rows/gridRowsInterfaces.d.ts +1 -1
- package/modern/hooks/features/rows/gridRowsUtils.d.ts +2 -1
- package/modern/hooks/features/rows/gridRowsUtils.js +8 -0
- package/modern/hooks/features/rows/useGridParamsApi.js +2 -8
- package/modern/hooks/features/rows/useGridRowAriaAttributes.js +2 -4
- package/modern/hooks/features/rows/useGridRows.d.ts +2 -2
- package/modern/hooks/features/rows/useGridRows.js +7 -7
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +5 -9
- package/modern/hooks/utils/useGridSelector.js +4 -1
- package/modern/hooks/utils/useIsSSR.js +4 -1
- package/modern/index.js +1 -1
- package/modern/internals/index.d.ts +2 -1
- package/modern/internals/index.js +2 -1
- package/modern/internals/utils/propValidation.js +1 -1
- package/modern/locales/bnBD.d.ts +2 -0
- package/modern/locales/bnBD.js +167 -0
- package/modern/locales/deDE.js +3 -5
- package/modern/locales/huHU.js +10 -13
- package/modern/locales/index.d.ts +1 -0
- package/modern/locales/index.js +1 -0
- package/modern/locales/ruRU.js +17 -21
- package/modern/material/index.d.ts +1 -0
- package/modern/material/index.js +164 -49
- package/modern/material/variables.d.ts +5 -0
- package/modern/material/variables.js +89 -0
- package/modern/models/api/gridRowSelectionApi.d.ts +4 -2
- package/modern/models/api/gridSortApi.d.ts +1 -1
- package/modern/models/configuration/gridConfiguration.d.ts +7 -1
- package/modern/models/gridBaseSlots.d.ts +56 -6
- package/modern/models/gridDataSource.d.ts +9 -4
- package/modern/models/gridRowSelectionManager.d.ts +9 -0
- package/modern/models/gridRowSelectionManager.js +36 -0
- package/modern/models/gridRowSelectionModel.d.ts +4 -2
- package/modern/models/gridSlotsComponent.d.ts +7 -27
- package/modern/models/gridSlotsComponentsProps.d.ts +3 -11
- package/modern/models/gridSortModel.d.ts +1 -1
- package/modern/models/index.d.ts +2 -1
- package/modern/models/index.js +2 -3
- package/modern/models/props/DataGridProps.d.ts +22 -17
- package/modern/utils/css/context.d.ts +14 -0
- package/modern/utils/css/context.js +54 -0
- package/modern/utils/index.d.ts +2 -1
- package/modern/utils/index.js +1 -1
- package/package.json +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/utils/css/context.d.ts +14 -0
- package/utils/css/context.js +64 -0
- package/utils/index.d.ts +2 -1
- package/utils/index.js +8 -1
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.useGridRowSelection = exports.rowSelectionStateInitializer = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
11
12
|
var _signature = require("../../../constants/signature");
|
|
12
13
|
var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
|
|
13
14
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
@@ -15,7 +16,6 @@ var _useGridLogger = require("../../utils/useGridLogger");
|
|
|
15
16
|
var _useGridSelector = require("../../utils/useGridSelector");
|
|
16
17
|
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
17
18
|
var _gridRowSelectionSelector = require("./gridRowSelectionSelector");
|
|
18
|
-
var _pagination = require("../pagination");
|
|
19
19
|
var _gridFocusStateSelector = require("../focus/gridFocusStateSelector");
|
|
20
20
|
var _gridFilterSelector = require("../filter/gridFilterSelector");
|
|
21
21
|
var _colDef = require("../../../colDef");
|
|
@@ -26,20 +26,14 @@ var _constants = require("../../../internals/constants");
|
|
|
26
26
|
var _gridClasses = require("../../../constants/gridClasses");
|
|
27
27
|
var _domUtils = require("../../../utils/domUtils");
|
|
28
28
|
var _utils = require("./utils");
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return selectionModelProp;
|
|
35
|
-
}
|
|
36
|
-
if (prevSelectionModel && prevSelectionModel[0] === selectionModelProp) {
|
|
37
|
-
return prevSelectionModel;
|
|
38
|
-
}
|
|
39
|
-
return [selectionModelProp];
|
|
29
|
+
var _gridRowSelectionManager = require("../../../models/gridRowSelectionManager");
|
|
30
|
+
var _pagination = require("../pagination");
|
|
31
|
+
const emptyModel = {
|
|
32
|
+
type: 'include',
|
|
33
|
+
ids: new Set()
|
|
40
34
|
};
|
|
41
35
|
const rowSelectionStateInitializer = (state, props) => (0, _extends2.default)({}, state, {
|
|
42
|
-
rowSelection: props.rowSelection ?
|
|
36
|
+
rowSelection: props.rowSelection ? props.rowSelectionModel ?? emptyModel : emptyModel
|
|
43
37
|
});
|
|
44
38
|
|
|
45
39
|
/**
|
|
@@ -58,8 +52,8 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
58
52
|
}, [props.rowSelection]);
|
|
59
53
|
const applyAutoSelection = props.signature !== _signature.GridSignature.DataGrid && (props.rowSelectionPropagation?.parents || props.rowSelectionPropagation?.descendants);
|
|
60
54
|
const propRowSelectionModel = React.useMemo(() => {
|
|
61
|
-
return
|
|
62
|
-
}, [
|
|
55
|
+
return props.rowSelectionModel;
|
|
56
|
+
}, [props.rowSelectionModel]);
|
|
63
57
|
const lastRowToggled = React.useRef(null);
|
|
64
58
|
apiRef.current.registerControlState({
|
|
65
59
|
stateId: 'rowSelection',
|
|
@@ -99,23 +93,30 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
99
93
|
endId
|
|
100
94
|
}, !isSelected);
|
|
101
95
|
}, [apiRef]);
|
|
96
|
+
const getRowsToBeSelected = (0, _useEventCallback.default)(() => {
|
|
97
|
+
const rowsToBeSelected = props.pagination && props.checkboxSelectionVisibleOnly && props.paginationMode === 'client' ? (0, _pagination.gridPaginatedVisibleSortedGridRowIdsSelector)(apiRef) : (0, _gridFilterSelector.gridExpandedSortedRowIdsSelector)(apiRef);
|
|
98
|
+
return rowsToBeSelected;
|
|
99
|
+
});
|
|
102
100
|
|
|
103
101
|
/*
|
|
104
102
|
* API METHODS
|
|
105
103
|
*/
|
|
106
104
|
const setRowSelectionModel = React.useCallback(model => {
|
|
107
|
-
if (props.signature === _signature.GridSignature.DataGrid && !canHaveMultipleSelection &&
|
|
105
|
+
if (props.signature === _signature.GridSignature.DataGrid && !canHaveMultipleSelection && (model.type !== 'include' || model.ids.size > 1)) {
|
|
108
106
|
throw new Error(['MUI X: `rowSelectionModel` can only contain 1 item in DataGrid.', 'You need to upgrade to DataGridPro or DataGridPremium component to unlock multiple selection.'].join('\n'));
|
|
109
107
|
}
|
|
110
108
|
const currentModel = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef);
|
|
111
109
|
if (currentModel !== model) {
|
|
112
110
|
logger.debug(`Setting selection model`);
|
|
113
111
|
apiRef.current.setState(state => (0, _extends2.default)({}, state, {
|
|
114
|
-
rowSelection: props.rowSelection ? model :
|
|
112
|
+
rowSelection: props.rowSelection ? model : emptyModel
|
|
115
113
|
}));
|
|
116
114
|
}
|
|
117
115
|
}, [apiRef, logger, props.rowSelection, props.signature, canHaveMultipleSelection]);
|
|
118
|
-
const isRowSelected = React.useCallback(id =>
|
|
116
|
+
const isRowSelected = React.useCallback(id => {
|
|
117
|
+
const selectionManager = (0, _gridRowSelectionSelector.gridRowSelectionManagerSelector)(apiRef);
|
|
118
|
+
return selectionManager.has(id);
|
|
119
|
+
}, [apiRef]);
|
|
119
120
|
const isRowSelectable = React.useCallback(id => {
|
|
120
121
|
if (props.rowSelection === false) {
|
|
121
122
|
return false;
|
|
@@ -129,7 +130,7 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
129
130
|
}
|
|
130
131
|
return true;
|
|
131
132
|
}, [apiRef, props.rowSelection, propIsRowSelectable]);
|
|
132
|
-
const getSelectedRows = React.useCallback(() => (0, _gridRowSelectionSelector.
|
|
133
|
+
const getSelectedRows = React.useCallback(() => (0, _gridRowSelectionSelector.gridRowSelectionIdsSelector)(apiRef), [apiRef]);
|
|
133
134
|
const selectRow = React.useCallback((id, isSelected = true, resetSelection = false) => {
|
|
134
135
|
if (!apiRef.current.isRowSelectable(id)) {
|
|
135
136
|
return;
|
|
@@ -137,9 +138,12 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
137
138
|
lastRowToggled.current = id;
|
|
138
139
|
if (resetSelection) {
|
|
139
140
|
logger.debug(`Setting selection for row ${id}`);
|
|
140
|
-
const
|
|
141
|
+
const newSelectionModel = {
|
|
142
|
+
type: 'include',
|
|
143
|
+
ids: new Set()
|
|
144
|
+
};
|
|
141
145
|
const addRow = rowId => {
|
|
142
|
-
|
|
146
|
+
newSelectionModel.ids.add(rowId);
|
|
143
147
|
};
|
|
144
148
|
if (isSelected) {
|
|
145
149
|
addRow(id);
|
|
@@ -147,17 +151,21 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
147
151
|
(0, _utils.findRowsToSelect)(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, addRow);
|
|
148
152
|
}
|
|
149
153
|
}
|
|
150
|
-
apiRef.current.setRowSelectionModel(
|
|
154
|
+
apiRef.current.setRowSelectionModel(newSelectionModel);
|
|
151
155
|
} else {
|
|
152
156
|
logger.debug(`Toggling selection for row ${id}`);
|
|
153
|
-
const
|
|
154
|
-
const
|
|
155
|
-
|
|
157
|
+
const selectionModel = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef);
|
|
158
|
+
const newSelectionModel = {
|
|
159
|
+
type: selectionModel.type,
|
|
160
|
+
ids: new Set(selectionModel.ids)
|
|
161
|
+
};
|
|
162
|
+
const selectionManager = (0, _gridRowSelectionManager.createRowSelectionManager)(newSelectionModel);
|
|
163
|
+
selectionManager.unselect(id);
|
|
156
164
|
const addRow = rowId => {
|
|
157
|
-
|
|
165
|
+
selectionManager.select(rowId);
|
|
158
166
|
};
|
|
159
167
|
const removeRow = rowId => {
|
|
160
|
-
|
|
168
|
+
selectionManager.unselect(rowId);
|
|
161
169
|
};
|
|
162
170
|
if (isSelected) {
|
|
163
171
|
addRow(id);
|
|
@@ -167,45 +175,62 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
167
175
|
} else if (applyAutoSelection) {
|
|
168
176
|
(0, _utils.findRowsToDeselect)(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, removeRow);
|
|
169
177
|
}
|
|
170
|
-
const isSelectionValid =
|
|
178
|
+
const isSelectionValid = newSelectionModel.type === 'include' && newSelectionModel.ids.size < 2 || canHaveMultipleSelection;
|
|
171
179
|
if (isSelectionValid) {
|
|
172
|
-
apiRef.current.setRowSelectionModel(
|
|
180
|
+
apiRef.current.setRowSelectionModel(newSelectionModel);
|
|
173
181
|
}
|
|
174
182
|
}
|
|
175
183
|
}, [apiRef, logger, applyAutoSelection, tree, props.rowSelectionPropagation?.descendants, props.rowSelectionPropagation?.parents, canHaveMultipleSelection]);
|
|
176
184
|
const selectRows = React.useCallback((ids, isSelected = true, resetSelection = false) => {
|
|
177
185
|
logger.debug(`Setting selection for several rows`);
|
|
178
|
-
|
|
179
|
-
|
|
186
|
+
if (props.rowSelection === false) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const selectableIds = new Set();
|
|
190
|
+
for (let i = 0; i < ids.length; i += 1) {
|
|
191
|
+
const id = ids[i];
|
|
192
|
+
if (apiRef.current.isRowSelectable(id)) {
|
|
193
|
+
selectableIds.add(id);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
const currentSelectionModel = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef);
|
|
197
|
+
let newSelectionModel;
|
|
180
198
|
if (resetSelection) {
|
|
199
|
+
newSelectionModel = {
|
|
200
|
+
type: 'include',
|
|
201
|
+
ids: selectableIds
|
|
202
|
+
};
|
|
181
203
|
if (isSelected) {
|
|
182
|
-
|
|
204
|
+
const selectionManager = (0, _gridRowSelectionManager.createRowSelectionManager)(newSelectionModel);
|
|
183
205
|
if (applyAutoSelection) {
|
|
184
206
|
const addRow = rowId => {
|
|
185
|
-
|
|
207
|
+
selectionManager.select(rowId);
|
|
186
208
|
};
|
|
187
|
-
|
|
209
|
+
for (const id of selectableIds) {
|
|
188
210
|
(0, _utils.findRowsToSelect)(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, addRow);
|
|
189
|
-
}
|
|
211
|
+
}
|
|
190
212
|
}
|
|
191
213
|
} else {
|
|
192
|
-
|
|
214
|
+
newSelectionModel.ids = new Set();
|
|
193
215
|
}
|
|
194
|
-
|
|
195
|
-
if (newSelection.size === Object.keys(currentLookup).length && Array.from(newSelection).every(id => currentLookup[id] === id)) {
|
|
216
|
+
if (currentSelectionModel.type === newSelectionModel.type && newSelectionModel.ids.size === currentSelectionModel.ids.size && Array.from(newSelectionModel.ids).every(id => currentSelectionModel.ids.has(id))) {
|
|
196
217
|
return;
|
|
197
218
|
}
|
|
198
219
|
} else {
|
|
199
|
-
|
|
220
|
+
newSelectionModel = {
|
|
221
|
+
type: currentSelectionModel.type,
|
|
222
|
+
ids: new Set(currentSelectionModel.ids)
|
|
223
|
+
};
|
|
224
|
+
const selectionManager = (0, _gridRowSelectionManager.createRowSelectionManager)(newSelectionModel);
|
|
200
225
|
const addRow = rowId => {
|
|
201
|
-
|
|
226
|
+
selectionManager.select(rowId);
|
|
202
227
|
};
|
|
203
228
|
const removeRow = rowId => {
|
|
204
|
-
|
|
229
|
+
selectionManager.unselect(rowId);
|
|
205
230
|
};
|
|
206
|
-
|
|
231
|
+
for (const id of selectableIds) {
|
|
207
232
|
if (isSelected) {
|
|
208
|
-
|
|
233
|
+
selectionManager.select(id);
|
|
209
234
|
if (applyAutoSelection) {
|
|
210
235
|
(0, _utils.findRowsToSelect)(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, addRow);
|
|
211
236
|
}
|
|
@@ -215,13 +240,13 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
215
240
|
(0, _utils.findRowsToDeselect)(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, removeRow);
|
|
216
241
|
}
|
|
217
242
|
}
|
|
218
|
-
}
|
|
243
|
+
}
|
|
219
244
|
}
|
|
220
|
-
const isSelectionValid =
|
|
245
|
+
const isSelectionValid = newSelectionModel.type === 'include' && newSelectionModel.ids.size < 2 || canHaveMultipleSelection;
|
|
221
246
|
if (isSelectionValid) {
|
|
222
|
-
apiRef.current.setRowSelectionModel(
|
|
247
|
+
apiRef.current.setRowSelectionModel(newSelectionModel);
|
|
223
248
|
}
|
|
224
|
-
}, [logger, applyAutoSelection, canHaveMultipleSelection, apiRef, tree, props.rowSelectionPropagation?.descendants, props.rowSelectionPropagation?.parents]);
|
|
249
|
+
}, [logger, applyAutoSelection, canHaveMultipleSelection, apiRef, tree, props.rowSelectionPropagation?.descendants, props.rowSelectionPropagation?.parents, props.rowSelection]);
|
|
225
250
|
const selectRowRange = React.useCallback(({
|
|
226
251
|
startId,
|
|
227
252
|
endId
|
|
@@ -260,57 +285,72 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
260
285
|
const currentSelection = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef);
|
|
261
286
|
const rowsLookup = (0, _gridRowsSelector.gridRowsLookupSelector)(apiRef);
|
|
262
287
|
const filteredRowsLookup = (0, _gridFilterSelector.gridFilteredRowsLookupSelector)(apiRef);
|
|
263
|
-
|
|
264
|
-
// We clone the existing object to avoid mutating the same object returned by the selector to others part of the project
|
|
265
|
-
const selectionLookup = (0, _extends2.default)({}, (0, _gridRowSelectionSelector.selectedIdsLookupSelector)(apiRef));
|
|
266
288
|
const isNonExistent = id => {
|
|
267
289
|
if (props.filterMode === 'server') {
|
|
268
290
|
return !rowsLookup[id];
|
|
269
291
|
}
|
|
270
292
|
return !rowsLookup[id] || filteredRowsLookup[id] === false;
|
|
271
293
|
};
|
|
294
|
+
const newSelectionModel = {
|
|
295
|
+
type: currentSelection.type,
|
|
296
|
+
ids: new Set(currentSelection.ids)
|
|
297
|
+
};
|
|
298
|
+
const selectionManager = (0, _gridRowSelectionManager.createRowSelectionManager)(newSelectionModel);
|
|
272
299
|
let hasChanged = false;
|
|
273
|
-
|
|
300
|
+
for (const id of currentSelection.ids) {
|
|
274
301
|
if (isNonExistent(id)) {
|
|
275
302
|
if (props.keepNonExistentRowsSelected) {
|
|
276
|
-
|
|
303
|
+
continue;
|
|
277
304
|
}
|
|
278
|
-
|
|
305
|
+
selectionManager.unselect(id);
|
|
279
306
|
hasChanged = true;
|
|
280
|
-
|
|
307
|
+
continue;
|
|
281
308
|
}
|
|
282
309
|
if (!props.rowSelectionPropagation?.parents) {
|
|
283
|
-
|
|
310
|
+
continue;
|
|
284
311
|
}
|
|
285
312
|
const node = tree[id];
|
|
286
|
-
if (node
|
|
313
|
+
if (node?.type === 'group') {
|
|
287
314
|
const isAutoGenerated = node.isAutoGenerated;
|
|
288
315
|
if (isAutoGenerated) {
|
|
289
|
-
|
|
316
|
+
selectionManager.unselect(id);
|
|
290
317
|
hasChanged = true;
|
|
291
|
-
|
|
318
|
+
continue;
|
|
292
319
|
}
|
|
293
320
|
// Keep previously selected tree data parents selected if all their children are filtered out
|
|
294
321
|
if (!node.children.every(childId => filteredRowsLookup[childId] === false)) {
|
|
295
|
-
|
|
322
|
+
selectionManager.unselect(id);
|
|
296
323
|
hasChanged = true;
|
|
297
324
|
}
|
|
298
325
|
}
|
|
299
|
-
}
|
|
326
|
+
}
|
|
300
327
|
|
|
301
328
|
// For nested data, on row tree updation (filtering, adding rows, etc.) when the selection is
|
|
302
329
|
// not empty, we need to re-run scanning of the tree to propagate the selection changes
|
|
303
330
|
// Example: A parent whose de-selected children are filtered out should now be selected
|
|
304
|
-
const shouldReapplyPropagation = isNestedData && props.rowSelectionPropagation?.parents &&
|
|
331
|
+
const shouldReapplyPropagation = isNestedData && props.rowSelectionPropagation?.parents && (newSelectionModel.ids.size > 0 ||
|
|
332
|
+
// In case of exclude selection, newSelectionModel.ids.size === 0 means all rows are selected
|
|
333
|
+
newSelectionModel.type === 'exclude');
|
|
305
334
|
if (hasChanged || shouldReapplyPropagation && !sortModelUpdated) {
|
|
306
|
-
const newSelection = Object.values(selectionLookup);
|
|
307
335
|
if (shouldReapplyPropagation) {
|
|
308
|
-
|
|
336
|
+
if (newSelectionModel.type === 'exclude') {
|
|
337
|
+
const unfilteredSelectedRowIds = getRowsToBeSelected();
|
|
338
|
+
const selectedRowIds = [];
|
|
339
|
+
for (let i = 0; i < unfilteredSelectedRowIds.length; i += 1) {
|
|
340
|
+
const rowId = unfilteredSelectedRowIds[i];
|
|
341
|
+
if ((props.keepNonExistentRowsSelected || !isNonExistent(rowId)) && selectionManager.has(rowId)) {
|
|
342
|
+
selectedRowIds.push(rowId);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
apiRef.current.selectRows(selectedRowIds, true, true);
|
|
346
|
+
} else {
|
|
347
|
+
apiRef.current.selectRows(Array.from(newSelectionModel.ids), true, true);
|
|
348
|
+
}
|
|
309
349
|
} else {
|
|
310
|
-
apiRef.current.setRowSelectionModel(
|
|
350
|
+
apiRef.current.setRowSelectionModel(newSelectionModel);
|
|
311
351
|
}
|
|
312
352
|
}
|
|
313
|
-
}, [apiRef, isNestedData, props.rowSelectionPropagation?.parents, props.keepNonExistentRowsSelected, props.filterMode, tree]);
|
|
353
|
+
}, [apiRef, isNestedData, props.rowSelectionPropagation?.parents, props.keepNonExistentRowsSelected, props.filterMode, tree, getRowsToBeSelected]);
|
|
314
354
|
const handleSingleRowSelection = React.useCallback((id, event) => {
|
|
315
355
|
const hasCtrlKey = event.metaKey || event.ctrlKey;
|
|
316
356
|
|
|
@@ -321,7 +361,7 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
321
361
|
|
|
322
362
|
const isMultipleSelectionDisabled = !checkboxSelection && !hasCtrlKey && !(0, _keyboardUtils.isKeyboardEvent)(event);
|
|
323
363
|
const resetSelection = !canHaveMultipleSelection || isMultipleSelectionDisabled;
|
|
324
|
-
const selectedRowsCount =
|
|
364
|
+
const selectedRowsCount = (0, _gridRowSelectionSelector.gridRowSelectionCountSelector)(apiRef);
|
|
325
365
|
if (canHaveMultipleSelection && selectedRowsCount > 1 && !hasCtrlKey) {
|
|
326
366
|
apiRef.current.selectRow(id, true, resetSelection);
|
|
327
367
|
} else {
|
|
@@ -370,10 +410,22 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
370
410
|
apiRef.current.selectRow(params.id, params.value, !canHaveMultipleSelection);
|
|
371
411
|
}
|
|
372
412
|
}, [apiRef, expandMouseRowRangeSelection, canHaveMultipleSelection]);
|
|
413
|
+
const toggleAllRows = React.useCallback(value => {
|
|
414
|
+
const filterModel = (0, _gridFilterSelector.gridFilterModelSelector)(apiRef);
|
|
415
|
+
const quickFilterModel = (0, _gridFilterSelector.gridQuickFilterValuesSelector)(apiRef);
|
|
416
|
+
const hasFilters = filterModel.items.length > 0 || (quickFilterModel?.length || 0) > 0;
|
|
417
|
+
if (!props.isRowSelectable && !props.checkboxSelectionVisibleOnly && applyAutoSelection && !hasFilters) {
|
|
418
|
+
apiRef.current.setRowSelectionModel({
|
|
419
|
+
type: value ? 'exclude' : 'include',
|
|
420
|
+
ids: new Set()
|
|
421
|
+
});
|
|
422
|
+
} else {
|
|
423
|
+
apiRef.current.selectRows(getRowsToBeSelected(), value);
|
|
424
|
+
}
|
|
425
|
+
}, [apiRef, applyAutoSelection, getRowsToBeSelected, props.checkboxSelectionVisibleOnly, props.isRowSelectable]);
|
|
373
426
|
const handleHeaderSelectionCheckboxChange = React.useCallback(params => {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
}, [apiRef, props.checkboxSelectionVisibleOnly, props.pagination, props.paginationMode]);
|
|
427
|
+
toggleAllRows(params.value);
|
|
428
|
+
}, [toggleAllRows]);
|
|
377
429
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
378
430
|
// Get the most recent cell mode because it may have been changed by another listener
|
|
379
431
|
if (apiRef.current.getCellMode(params.id, params.field) === _gridEditRowModel.GridCellModes.Edit) {
|
|
@@ -422,7 +474,10 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
422
474
|
}
|
|
423
475
|
}
|
|
424
476
|
const visibleRows = (0, _useGridVisibleRows.getVisibleRows)(apiRef);
|
|
425
|
-
const rowsBetweenStartAndEnd =
|
|
477
|
+
const rowsBetweenStartAndEnd = [];
|
|
478
|
+
for (let i = start; i <= end; i += 1) {
|
|
479
|
+
rowsBetweenStartAndEnd.push(visibleRows.rows[i].id);
|
|
480
|
+
}
|
|
426
481
|
apiRef.current.selectRows(rowsBetweenStartAndEnd, !isNextRowSelected);
|
|
427
482
|
return;
|
|
428
483
|
}
|
|
@@ -434,9 +489,9 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
434
489
|
}
|
|
435
490
|
if (String.fromCharCode(event.keyCode) === 'A' && (event.ctrlKey || event.metaKey)) {
|
|
436
491
|
event.preventDefault();
|
|
437
|
-
|
|
492
|
+
toggleAllRows(true);
|
|
438
493
|
}
|
|
439
|
-
}, [apiRef,
|
|
494
|
+
}, [apiRef, canHaveMultipleSelection, handleSingleRowSelection, toggleAllRows]);
|
|
440
495
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'sortedRowsSet', runIfRowSelectionIsEnabled(() => removeOutdatedSelection(true)));
|
|
441
496
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'filteredRowsSet', runIfRowSelectionIsEnabled(removeOutdatedSelection));
|
|
442
497
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'rowClick', runIfRowSelectionIsEnabled(handleRowClick));
|
|
@@ -455,7 +510,7 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
455
510
|
}, [apiRef, propRowSelectionModel, props.rowSelection]);
|
|
456
511
|
React.useEffect(() => {
|
|
457
512
|
if (!props.rowSelection) {
|
|
458
|
-
apiRef.current.setRowSelectionModel(
|
|
513
|
+
apiRef.current.setRowSelectionModel(emptyModel);
|
|
459
514
|
}
|
|
460
515
|
}, [apiRef, props.rowSelection]);
|
|
461
516
|
const isStateControlled = propRowSelectionModel != null;
|
|
@@ -466,10 +521,22 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
466
521
|
|
|
467
522
|
// props.isRowSelectable changed
|
|
468
523
|
const currentSelection = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef);
|
|
469
|
-
if (isRowSelectable) {
|
|
470
|
-
|
|
471
|
-
if (
|
|
472
|
-
|
|
524
|
+
if (typeof isRowSelectable === 'function') {
|
|
525
|
+
let selectableIds = new Set();
|
|
526
|
+
if (currentSelection.type === 'include') {
|
|
527
|
+
for (const id of currentSelection.ids) {
|
|
528
|
+
if (isRowSelectable(id)) {
|
|
529
|
+
selectableIds.add(id);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
} else {
|
|
533
|
+
selectableIds = new Set(currentSelection.ids);
|
|
534
|
+
}
|
|
535
|
+
if (currentSelection.type === 'include' && selectableIds.size < currentSelection.ids.size) {
|
|
536
|
+
apiRef.current.setRowSelectionModel({
|
|
537
|
+
type: currentSelection.type,
|
|
538
|
+
ids: selectableIds
|
|
539
|
+
});
|
|
473
540
|
}
|
|
474
541
|
}
|
|
475
542
|
}, [apiRef, isRowSelectable, isStateControlled, props.rowSelection]);
|
|
@@ -478,9 +545,9 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
478
545
|
return;
|
|
479
546
|
}
|
|
480
547
|
const currentSelection = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef);
|
|
481
|
-
if (!canHaveMultipleSelection && currentSelection.
|
|
548
|
+
if (!canHaveMultipleSelection && (currentSelection.type === 'include' && currentSelection.ids.size > 1 || currentSelection.type === 'exclude')) {
|
|
482
549
|
// See https://github.com/mui/mui-x/issues/8455
|
|
483
|
-
apiRef.current.setRowSelectionModel(
|
|
550
|
+
apiRef.current.setRowSelectionModel(emptyModel);
|
|
484
551
|
}
|
|
485
552
|
}, [apiRef, canHaveMultipleSelection, checkboxSelection, isStateControlled, props.rowSelection]);
|
|
486
553
|
React.useEffect(() => {
|
|
@@ -2,9 +2,9 @@ import { RefObject } from '@mui/x-internals/types';
|
|
|
2
2
|
import type { GridRowId, GridRowTreeConfig } from '../../../models/gridRows';
|
|
3
3
|
import type { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
4
|
import type { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
5
|
-
import type
|
|
5
|
+
import { type GridRowSelectionPropagation } from "../../../models/gridRowSelectionModel.js";
|
|
6
6
|
export declare const ROW_SELECTION_PROPAGATION_DEFAULT: GridRowSelectionPropagation;
|
|
7
|
-
export declare function getCheckboxPropsSelector(groupId: GridRowId, autoSelectParents: boolean): import("../../..").OutputSelector<import("../../../models/gridStateCommunity").GridStateCommunity,
|
|
7
|
+
export declare function getCheckboxPropsSelector(groupId: GridRowId, autoSelectParents: boolean): import("../../..").OutputSelector<import("../../../models/gridStateCommunity").GridStateCommunity, import("../../../models/gridRowSelectionManager").RowSelectionManager, {
|
|
8
8
|
isIndeterminate: boolean;
|
|
9
9
|
isChecked: boolean;
|
|
10
10
|
}>;
|
|
@@ -38,15 +38,15 @@ function getGridRowGroupSelectableDescendants(apiRef, groupId) {
|
|
|
38
38
|
|
|
39
39
|
// TODO v8: Use `createSelectorV8`
|
|
40
40
|
function getCheckboxPropsSelector(groupId, autoSelectParents) {
|
|
41
|
-
return (0, _createSelector.createSelector)(_gridRowsSelector.gridRowTreeSelector, _gridSortingSelector.gridSortedRowIdsSelector, _gridFilterSelector.gridFilteredRowsLookupSelector, _gridRowSelectionSelector.
|
|
41
|
+
return (0, _createSelector.createSelector)(_gridRowsSelector.gridRowTreeSelector, _gridSortingSelector.gridSortedRowIdsSelector, _gridFilterSelector.gridFilteredRowsLookupSelector, _gridRowSelectionSelector.gridRowSelectionManagerSelector, (rowTree, sortedRowIds, filteredRowsLookup, rowSelectionManager) => {
|
|
42
42
|
const groupNode = rowTree[groupId];
|
|
43
43
|
if (!groupNode || groupNode.type !== 'group') {
|
|
44
44
|
return {
|
|
45
45
|
isIndeterminate: false,
|
|
46
|
-
isChecked:
|
|
46
|
+
isChecked: rowSelectionManager.has(groupId)
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
if (
|
|
49
|
+
if (rowSelectionManager.has(groupId)) {
|
|
50
50
|
return {
|
|
51
51
|
isIndeterminate: false,
|
|
52
52
|
isChecked: true
|
|
@@ -59,14 +59,14 @@ function getCheckboxPropsSelector(groupId, autoSelectParents) {
|
|
|
59
59
|
const id = sortedRowIds[index];
|
|
60
60
|
if (filteredRowsLookup[id] !== false) {
|
|
61
61
|
selectableDescendantsCount += 1;
|
|
62
|
-
if (
|
|
62
|
+
if (rowSelectionManager.has(id)) {
|
|
63
63
|
selectedDescendantsCount += 1;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
return {
|
|
68
|
-
isIndeterminate: selectedDescendantsCount > 0 && (selectedDescendantsCount < selectableDescendantsCount ||
|
|
69
|
-
isChecked: autoSelectParents ? selectedDescendantsCount > 0 :
|
|
68
|
+
isIndeterminate: selectedDescendantsCount > 0 && (selectedDescendantsCount < selectableDescendantsCount || !rowSelectionManager.has(groupId)),
|
|
69
|
+
isChecked: autoSelectParents ? selectedDescendantsCount > 0 : rowSelectionManager.has(groupId)
|
|
70
70
|
};
|
|
71
71
|
});
|
|
72
72
|
}
|
|
@@ -104,7 +104,7 @@ const getFilteredRowNodeSiblings = (tree, filteredRows, id) => {
|
|
|
104
104
|
};
|
|
105
105
|
const findRowsToSelect = (apiRef, tree, selectedRow, autoSelectDescendants, autoSelectParents, addRow) => {
|
|
106
106
|
const filteredRows = (0, _gridFilterSelector.gridFilteredRowsLookupSelector)(apiRef);
|
|
107
|
-
const
|
|
107
|
+
const rowSelectionManager = (0, _gridRowSelectionSelector.gridRowSelectionManagerSelector)(apiRef);
|
|
108
108
|
const selectedDescendants = new Set([]);
|
|
109
109
|
if (!autoSelectDescendants && !autoSelectParents) {
|
|
110
110
|
return;
|
|
@@ -121,7 +121,7 @@ const findRowsToSelect = (apiRef, tree, selectedRow, autoSelectDescendants, auto
|
|
|
121
121
|
}
|
|
122
122
|
if (autoSelectParents) {
|
|
123
123
|
const checkAllDescendantsSelected = rowId => {
|
|
124
|
-
if (
|
|
124
|
+
if (!rowSelectionManager.has(rowId) && !selectedDescendants.has(rowId)) {
|
|
125
125
|
return false;
|
|
126
126
|
}
|
|
127
127
|
const node = tree[rowId];
|
|
@@ -147,14 +147,14 @@ const findRowsToSelect = (apiRef, tree, selectedRow, autoSelectDescendants, auto
|
|
|
147
147
|
};
|
|
148
148
|
exports.findRowsToSelect = findRowsToSelect;
|
|
149
149
|
const findRowsToDeselect = (apiRef, tree, deselectedRow, autoSelectDescendants, autoSelectParents, removeRow) => {
|
|
150
|
-
const
|
|
150
|
+
const rowSelectionManager = (0, _gridRowSelectionSelector.gridRowSelectionManagerSelector)(apiRef);
|
|
151
151
|
if (!autoSelectParents && !autoSelectDescendants) {
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
154
|
if (autoSelectParents) {
|
|
155
155
|
const allParents = getRowNodeParents(tree, deselectedRow);
|
|
156
156
|
allParents.forEach(parent => {
|
|
157
|
-
const isSelected =
|
|
157
|
+
const isSelected = rowSelectionManager.has(parent);
|
|
158
158
|
if (isSelected) {
|
|
159
159
|
removeRow(parent);
|
|
160
160
|
}
|
|
@@ -61,7 +61,7 @@ export interface GridRowsState {
|
|
|
61
61
|
/**
|
|
62
62
|
* Contains some values of type `GridRowId` that have been requested to be fetched
|
|
63
63
|
* either by `defaultGroupingExpansionDepth` or `isGroupExpandedByDefault` props.
|
|
64
|
-
* Applicable with server-side grouped data and `
|
|
64
|
+
* Applicable with server-side grouped data and `dataSource` only.
|
|
65
65
|
*/
|
|
66
66
|
groupsToFetch?: GridRowId[];
|
|
67
67
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
-
import { GridAutoGeneratedGroupNode, GridAutoGeneratedPinnedRowNode, GridFooterNode, GridGroupNode, GridRowId, GridRowIdGetter, GridRowModel, GridRowModelUpdate, GridRowTreeConfig, GridSkeletonRowNode, GridTreeNode } from "../../../models/index.js";
|
|
2
|
+
import { GridAutoGeneratedGroupNode, GridAutoGeneratedPinnedRowNode, GridColDef, GridFooterNode, GridGroupNode, GridRowId, GridRowIdGetter, GridRowModel, GridRowModelUpdate, GridRowTreeConfig, GridSkeletonRowNode, GridTreeNode, GridValidRowModel } from "../../../models/index.js";
|
|
3
3
|
import { DataGridProcessedProps } from "../../../models/props/DataGridProps.js";
|
|
4
4
|
import { GridApiCommunity, GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
|
|
5
5
|
import { GridRowsInternalCache, GridRowsState, GridRowTreeCreationParams } from "./gridRowsInterfaces.js";
|
|
@@ -14,6 +14,7 @@ export declare const buildRootGroup: () => GridGroupNode;
|
|
|
14
14
|
*/
|
|
15
15
|
export declare function checkGridRowIdIsValid(id: GridRowId, row: GridRowModel | Partial<GridRowModel>, detailErrorMessage?: string): void;
|
|
16
16
|
export declare const getRowIdFromRowModel: (rowModel: GridRowModel, getRowId?: GridRowIdGetter, detailErrorMessage?: string) => GridRowId;
|
|
17
|
+
export declare const getRowValue: (row: GridValidRowModel, colDef: GridColDef, apiRef: RefObject<GridApiCommunity>) => any;
|
|
17
18
|
export declare const createRowsInternalCache: ({
|
|
18
19
|
rows,
|
|
19
20
|
getRowId,
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.buildRootGroup = exports.GRID_ROOT_GROUP_ID = exports.GRID_ID_AUTOGENERATED = void 0;
|
|
8
8
|
exports.checkGridRowIdIsValid = checkGridRowIdIsValid;
|
|
9
9
|
exports.computeRowsUpdates = computeRowsUpdates;
|
|
10
|
-
exports.updateCacheWithNewRows = exports.rowHeightWarning = exports.minimalContentHeight = exports.isAutogeneratedRowNode = exports.isAutogeneratedRow = exports.getValidRowHeight = exports.getTreeNodeDescendants = exports.getTopLevelRowCount = exports.getRowsStateFromCache = exports.getRowIdFromRowModel = exports.getRowHeightWarning = exports.createRowsInternalCache = void 0;
|
|
10
|
+
exports.updateCacheWithNewRows = exports.rowHeightWarning = exports.minimalContentHeight = exports.isAutogeneratedRowNode = exports.isAutogeneratedRow = exports.getValidRowHeight = exports.getTreeNodeDescendants = exports.getTopLevelRowCount = exports.getRowsStateFromCache = exports.getRowValue = exports.getRowIdFromRowModel = exports.getRowHeightWarning = exports.createRowsInternalCache = void 0;
|
|
11
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
12
|
var _gridRowsSelector = require("./gridRowsSelector");
|
|
13
13
|
const GRID_ROOT_GROUP_ID = exports.GRID_ROOT_GROUP_ID = `auto-generated-group-node-root`;
|
|
@@ -43,6 +43,15 @@ const getRowIdFromRowModel = (rowModel, getRowId, detailErrorMessage) => {
|
|
|
43
43
|
return id;
|
|
44
44
|
};
|
|
45
45
|
exports.getRowIdFromRowModel = getRowIdFromRowModel;
|
|
46
|
+
const getRowValue = (row, colDef, apiRef) => {
|
|
47
|
+
const field = colDef.field;
|
|
48
|
+
if (!colDef || !colDef.valueGetter) {
|
|
49
|
+
return row[field];
|
|
50
|
+
}
|
|
51
|
+
const value = row[colDef.field];
|
|
52
|
+
return colDef.valueGetter(value, row, colDef, apiRef);
|
|
53
|
+
};
|
|
54
|
+
exports.getRowValue = getRowValue;
|
|
46
55
|
const createRowsInternalCache = ({
|
|
47
56
|
rows,
|
|
48
57
|
getRowId,
|
|
@@ -12,6 +12,7 @@ var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
|
12
12
|
var _gridFocusStateSelector = require("../focus/gridFocusStateSelector");
|
|
13
13
|
var _gridListViewSelectors = require("../listView/gridListViewSelectors");
|
|
14
14
|
var _gridRowsSelector = require("./gridRowsSelector");
|
|
15
|
+
var _gridRowsUtils = require("./gridRowsUtils");
|
|
15
16
|
class MissingRowIdError extends Error {}
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -97,14 +98,7 @@ function useGridParamsApi(apiRef, props) {
|
|
|
97
98
|
}
|
|
98
99
|
return colDef.valueGetter(row[colDef.field], row, colDef, apiRef);
|
|
99
100
|
}, [apiRef]);
|
|
100
|
-
const getRowValue = React.useCallback((row, colDef) =>
|
|
101
|
-
const field = colDef.field;
|
|
102
|
-
if (!colDef || !colDef.valueGetter) {
|
|
103
|
-
return row[field];
|
|
104
|
-
}
|
|
105
|
-
const value = row[colDef.field];
|
|
106
|
-
return colDef.valueGetter(value, row, colDef, apiRef);
|
|
107
|
-
}, [apiRef]);
|
|
101
|
+
const getRowValue = React.useCallback((row, colDef) => (0, _gridRowsUtils.getRowValue)(row, colDef, apiRef), [apiRef]);
|
|
108
102
|
const getRowFormattedValue = React.useCallback((row, colDef) => {
|
|
109
103
|
const value = getRowValue(row, colDef);
|
|
110
104
|
if (!colDef || !colDef.valueFormatter) {
|
|
@@ -6,22 +6,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.useGridRowAriaAttributes = void 0;
|
|
8
8
|
var React = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _rowSelection = require("../rowSelection");
|
|
10
9
|
var _useGridSelector = require("../../utils/useGridSelector");
|
|
11
10
|
var _gridColumnGroupsSelector = require("../columnGrouping/gridColumnGroupsSelector");
|
|
12
11
|
var _useGridPrivateApiContext = require("../../utils/useGridPrivateApiContext");
|
|
13
12
|
const useGridRowAriaAttributes = () => {
|
|
14
13
|
const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
|
|
15
|
-
const selectedIdsLookup = (0, _useGridSelector.useGridSelector)(apiRef, _rowSelection.selectedIdsLookupSelector);
|
|
16
14
|
const headerGroupingMaxDepth = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnGroupsSelector.gridColumnGroupsHeaderMaxDepthSelector);
|
|
17
15
|
return React.useCallback((rowNode, index) => {
|
|
18
16
|
const ariaAttributes = {};
|
|
19
17
|
const ariaRowIndex = index + headerGroupingMaxDepth + 2; // 1 for the header row and 1 as it's 1-based
|
|
20
18
|
ariaAttributes['aria-rowindex'] = ariaRowIndex;
|
|
21
19
|
if (apiRef.current.isRowSelectable(rowNode.id)) {
|
|
22
|
-
ariaAttributes['aria-selected'] =
|
|
20
|
+
ariaAttributes['aria-selected'] = apiRef.current.isRowSelected(rowNode.id);
|
|
23
21
|
}
|
|
24
22
|
return ariaAttributes;
|
|
25
|
-
}, [apiRef,
|
|
23
|
+
}, [apiRef, headerGroupingMaxDepth]);
|
|
26
24
|
};
|
|
27
25
|
exports.useGridRowAriaAttributes = useGridRowAriaAttributes;
|
|
@@ -2,5 +2,5 @@ import { RefObject } from '@mui/x-internals/types';
|
|
|
2
2
|
import { DataGridProcessedProps } from "../../../models/props/DataGridProps.js";
|
|
3
3
|
import { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
|
|
4
4
|
import { GridStateInitializer } from "../../utils/useGridInitializeState.js";
|
|
5
|
-
export declare const rowsStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, '
|
|
6
|
-
export declare const useGridRows: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "rows" | "getRowId" | "rowCount" | "throttleRowsMs" | "signature" | "pagination" | "paginationMode" | "loading" | "
|
|
5
|
+
export declare const rowsStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'dataSource' | 'rows' | 'rowCount' | 'getRowId' | 'loading'>>;
|
|
6
|
+
export declare const useGridRows: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "rows" | "getRowId" | "rowCount" | "throttleRowsMs" | "signature" | "pagination" | "paginationMode" | "loading" | "dataSource">) => void;
|