@mui/x-data-grid 7.18.0 → 7.19.0
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 +110 -0
- package/DataGrid/DataGrid.js +5 -0
- package/components/cell/GridCell.js +7 -8
- package/components/columnHeaders/GridBaseColumnHeaders.js +1 -1
- package/components/columnSelection/GridCellCheckboxRenderer.js +12 -4
- package/components/columnSelection/GridHeaderCheckbox.d.ts +1 -1
- package/components/containers/GridRoot.js +1 -1
- package/components/containers/GridRootStyles.js +32 -23
- package/components/containers/GridToolbarContainer.js +1 -1
- package/components/menu/GridMenu.js +1 -1
- package/components/panel/GridPanel.d.ts +1 -1
- package/components/panel/GridPanel.js +1 -1
- package/components/panel/GridPanelContent.js +1 -1
- package/components/panel/GridPanelFooter.js +1 -1
- package/components/panel/GridPanelHeader.js +1 -1
- package/components/panel/GridPanelWrapper.js +1 -1
- package/components/panel/filterPanel/filterPanelUtils.d.ts +1 -1
- package/components/toolbar/GridToolbarQuickFilter.js +1 -1
- package/components/virtualization/GridBottomContainer.d.ts +1 -1
- package/components/virtualization/GridBottomContainer.js +18 -1
- package/components/virtualization/GridMainContainer.js +3 -1
- package/components/virtualization/GridTopContainer.d.ts +1 -1
- package/components/virtualization/GridTopContainer.js +1 -1
- package/components/virtualization/GridVirtualScrollbar.js +1 -7
- package/components/virtualization/GridVirtualScroller.js +1 -0
- package/components/virtualization/GridVirtualScrollerFiller.js +3 -4
- package/hooks/features/columnGrouping/gridColumnGroupsSelector.d.ts +4 -4
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
- package/hooks/features/columnResize/columnResizeSelector.d.ts +1 -1
- package/hooks/features/columns/gridColumnsSelector.d.ts +12 -12
- package/hooks/features/columns/gridColumnsUtils.js +3 -2
- package/hooks/features/density/densitySelector.d.ts +1 -1
- package/hooks/features/editing/useGridCellEditing.js +1 -1
- package/hooks/features/editing/useGridRowEditing.js +1 -1
- package/hooks/features/filter/gridFilterSelector.d.ts +17 -17
- package/hooks/features/focus/gridFocusStateSelector.d.ts +8 -8
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.d.ts +3 -3
- package/hooks/features/keyboardNavigation/utils.d.ts +1 -1
- package/hooks/features/pagination/gridPaginationSelector.d.ts +9 -9
- package/hooks/features/rowSelection/gridRowSelectionSelector.d.ts +3 -3
- package/hooks/features/rowSelection/useGridRowSelection.d.ts +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +105 -29
- package/hooks/features/rowSelection/utils.d.ts +10 -0
- package/hooks/features/rowSelection/utils.js +156 -1
- package/hooks/features/rows/gridRowSpanningSelectors.d.ts +3 -3
- package/hooks/features/rows/gridRowsSelector.d.ts +14 -14
- package/hooks/features/rows/useGridRows.d.ts +1 -1
- package/hooks/features/rows/useGridRows.js +7 -1
- package/hooks/features/scroll/useGridScroll.js +19 -19
- package/hooks/features/sorting/gridSortingSelector.d.ts +4 -4
- package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +5 -5
- package/hooks/utils/useGridVisibleRows.d.ts +2 -2
- package/index.js +1 -1
- package/internals/index.d.ts +1 -0
- package/internals/index.js +1 -0
- package/locales/bgBG.js +8 -9
- package/locales/deDE.js +4 -4
- package/locales/frFR.js +4 -4
- package/locales/hrHR.d.ts +1 -1
- package/locales/hrHR.js +69 -46
- package/locales/jaJP.js +1 -2
- package/locales/ptPT.d.ts +1 -1
- package/locales/ptPT.js +4 -4
- package/locales/viVN.js +20 -20
- package/locales/zhHK.d.ts +1 -1
- package/models/gridRowSelectionModel.d.ts +4 -0
- package/models/props/DataGridProps.d.ts +20 -1
- package/modern/DataGrid/DataGrid.js +5 -0
- package/modern/components/cell/GridCell.js +7 -8
- package/modern/components/columnHeaders/GridBaseColumnHeaders.js +1 -1
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +12 -4
- package/modern/components/containers/GridRoot.js +1 -1
- package/modern/components/containers/GridRootStyles.js +32 -23
- package/modern/components/containers/GridToolbarContainer.js +1 -1
- package/modern/components/menu/GridMenu.js +1 -1
- package/modern/components/panel/GridPanel.js +1 -1
- package/modern/components/panel/GridPanelContent.js +1 -1
- package/modern/components/panel/GridPanelFooter.js +1 -1
- package/modern/components/panel/GridPanelHeader.js +1 -1
- package/modern/components/panel/GridPanelWrapper.js +1 -1
- package/modern/components/toolbar/GridToolbarQuickFilter.js +1 -1
- package/modern/components/virtualization/GridBottomContainer.js +18 -1
- package/modern/components/virtualization/GridMainContainer.js +3 -1
- package/modern/components/virtualization/GridTopContainer.js +1 -1
- package/modern/components/virtualization/GridVirtualScrollbar.js +1 -7
- package/modern/components/virtualization/GridVirtualScroller.js +1 -0
- package/modern/components/virtualization/GridVirtualScrollerFiller.js +3 -4
- package/modern/hooks/features/columns/gridColumnsUtils.js +3 -2
- package/modern/hooks/features/editing/useGridCellEditing.js +1 -1
- package/modern/hooks/features/editing/useGridRowEditing.js +1 -1
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +105 -29
- package/modern/hooks/features/rowSelection/utils.js +156 -1
- package/modern/hooks/features/rows/useGridRows.js +7 -1
- package/modern/hooks/features/scroll/useGridScroll.js +19 -19
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -0
- package/modern/locales/bgBG.js +8 -9
- package/modern/locales/deDE.js +4 -4
- package/modern/locales/frFR.js +4 -4
- package/modern/locales/hrHR.js +69 -46
- package/modern/locales/jaJP.js +1 -2
- package/modern/locales/ptPT.js +4 -4
- package/modern/locales/viVN.js +20 -20
- package/modern/utils/createSelector.js +6 -0
- package/node/DataGrid/DataGrid.js +5 -0
- package/node/components/cell/GridCell.js +7 -8
- package/node/components/columnHeaders/GridBaseColumnHeaders.js +1 -1
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +12 -4
- package/node/components/containers/GridRoot.js +1 -1
- package/node/components/containers/GridRootStyles.js +32 -23
- package/node/components/containers/GridToolbarContainer.js +1 -1
- package/node/components/menu/GridMenu.js +1 -1
- package/node/components/panel/GridPanel.js +1 -1
- package/node/components/panel/GridPanelContent.js +1 -1
- package/node/components/panel/GridPanelFooter.js +1 -1
- package/node/components/panel/GridPanelHeader.js +1 -1
- package/node/components/panel/GridPanelWrapper.js +1 -1
- package/node/components/toolbar/GridToolbarQuickFilter.js +1 -1
- package/node/components/virtualization/GridBottomContainer.js +18 -1
- package/node/components/virtualization/GridMainContainer.js +3 -1
- package/node/components/virtualization/GridTopContainer.js +1 -1
- package/node/components/virtualization/GridVirtualScrollbar.js +1 -7
- package/node/components/virtualization/GridVirtualScroller.js +1 -0
- package/node/components/virtualization/GridVirtualScrollerFiller.js +3 -4
- package/node/hooks/features/columns/gridColumnsUtils.js +3 -2
- package/node/hooks/features/editing/useGridCellEditing.js +1 -1
- package/node/hooks/features/editing/useGridRowEditing.js +1 -1
- package/node/hooks/features/rowSelection/useGridRowSelection.js +102 -26
- package/node/hooks/features/rowSelection/utils.js +160 -1
- package/node/hooks/features/rows/useGridRows.js +7 -1
- package/node/hooks/features/scroll/useGridScroll.js +19 -19
- package/node/index.js +1 -1
- package/node/internals/index.js +23 -15
- package/node/locales/bgBG.js +8 -9
- package/node/locales/deDE.js +4 -4
- package/node/locales/frFR.js +4 -4
- package/node/locales/hrHR.js +69 -46
- package/node/locales/jaJP.js +1 -2
- package/node/locales/ptPT.js +4 -4
- package/node/locales/viVN.js +20 -20
- package/node/utils/createSelector.js +6 -0
- package/package.json +1 -1
- package/utils/createSelector.js +6 -0
|
@@ -9,33 +9,33 @@ export declare const gridColumnsStateSelector: (state: GridStateCommunity) => im
|
|
|
9
9
|
* Get an array of column fields in the order rendered on screen.
|
|
10
10
|
* @category Columns
|
|
11
11
|
*/
|
|
12
|
-
export declare const gridColumnFieldsSelector: import("
|
|
12
|
+
export declare const gridColumnFieldsSelector: import("../../..").OutputSelector<GridStateCommunity, string[]>;
|
|
13
13
|
/**
|
|
14
14
|
* Get the columns as a lookup (an object containing the field for keys and the definition for values).
|
|
15
15
|
* @category Columns
|
|
16
16
|
*/
|
|
17
|
-
export declare const gridColumnLookupSelector: import("
|
|
17
|
+
export declare const gridColumnLookupSelector: import("../../..").OutputSelector<GridStateCommunity, GridColumnLookup>;
|
|
18
18
|
/**
|
|
19
19
|
* Get an array of column definitions in the order rendered on screen..
|
|
20
20
|
* @category Columns
|
|
21
21
|
*/
|
|
22
|
-
export declare const gridColumnDefinitionsSelector: import("
|
|
22
|
+
export declare const gridColumnDefinitionsSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../../internals").GridStateColDef[]>;
|
|
23
23
|
/**
|
|
24
24
|
* Get the column visibility model, containing the visibility status of each column.
|
|
25
25
|
* If a column is not registered in the model, it is visible.
|
|
26
26
|
* @category Visible Columns
|
|
27
27
|
*/
|
|
28
|
-
export declare const gridColumnVisibilityModelSelector: import("
|
|
28
|
+
export declare const gridColumnVisibilityModelSelector: import("../../..").OutputSelector<GridStateCommunity, import("./gridColumnsInterfaces").GridColumnVisibilityModel>;
|
|
29
29
|
/**
|
|
30
30
|
* Get the visible columns as a lookup (an object containing the field for keys and the definition for values).
|
|
31
31
|
* @category Visible Columns
|
|
32
32
|
*/
|
|
33
|
-
export declare const gridVisibleColumnDefinitionsSelector: import("
|
|
33
|
+
export declare const gridVisibleColumnDefinitionsSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../../internals").GridStateColDef[]>;
|
|
34
34
|
/**
|
|
35
35
|
* Get the field of each visible column.
|
|
36
36
|
* @category Visible Columns
|
|
37
37
|
*/
|
|
38
|
-
export declare const gridVisibleColumnFieldsSelector: import("
|
|
38
|
+
export declare const gridVisibleColumnFieldsSelector: import("../../..").OutputSelector<GridStateCommunity, string[]>;
|
|
39
39
|
/**
|
|
40
40
|
* Get the visible pinned columns model.
|
|
41
41
|
* @category Visible Columns
|
|
@@ -45,7 +45,7 @@ export declare const gridPinnedColumnsSelector: (state: GridStateCommunity) => G
|
|
|
45
45
|
* Get the visible pinned columns.
|
|
46
46
|
* @category Visible Columns
|
|
47
47
|
*/
|
|
48
|
-
export declare const gridVisiblePinnedColumnDefinitionsSelector: import("
|
|
48
|
+
export declare const gridVisiblePinnedColumnDefinitionsSelector: import("../../..").OutputSelector<GridStateCommunity, {
|
|
49
49
|
left: import("../../../internals").GridStateColDef[];
|
|
50
50
|
right: import("../../../internals").GridStateColDef[];
|
|
51
51
|
}>;
|
|
@@ -53,25 +53,25 @@ export declare const gridVisiblePinnedColumnDefinitionsSelector: import("../../.
|
|
|
53
53
|
* Get the left position in pixel of each visible columns relative to the left of the first column.
|
|
54
54
|
* @category Visible Columns
|
|
55
55
|
*/
|
|
56
|
-
export declare const gridColumnPositionsSelector: import("
|
|
56
|
+
export declare const gridColumnPositionsSelector: import("../../..").OutputSelector<GridStateCommunity, number[]>;
|
|
57
57
|
/**
|
|
58
58
|
* Get the summed width of all the visible columns.
|
|
59
59
|
* @category Visible Columns
|
|
60
60
|
*/
|
|
61
|
-
export declare const gridColumnsTotalWidthSelector: import("
|
|
61
|
+
export declare const gridColumnsTotalWidthSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
|
|
62
62
|
/**
|
|
63
63
|
* Get the filterable columns as an array.
|
|
64
64
|
* @category Columns
|
|
65
65
|
*/
|
|
66
|
-
export declare const gridFilterableColumnDefinitionsSelector: import("
|
|
66
|
+
export declare const gridFilterableColumnDefinitionsSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../../internals").GridStateColDef[]>;
|
|
67
67
|
/**
|
|
68
68
|
* Get the filterable columns as a lookup (an object containing the field for keys and the definition for values).
|
|
69
69
|
* @category Columns
|
|
70
70
|
*/
|
|
71
|
-
export declare const gridFilterableColumnLookupSelector: import("
|
|
71
|
+
export declare const gridFilterableColumnLookupSelector: import("../../..").OutputSelector<GridStateCommunity, GridColumnLookup>;
|
|
72
72
|
/**
|
|
73
73
|
* Checks if some column has a colSpan field.
|
|
74
74
|
* @category Columns
|
|
75
75
|
* @ignore - Do not document
|
|
76
76
|
*/
|
|
77
|
-
export declare const gridHasColSpanSelector: import("
|
|
77
|
+
export declare const gridHasColSpanSelector: import("../../..").OutputSelector<GridStateCommunity, boolean>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import resolveProps from '@mui/utils/resolveProps';
|
|
2
3
|
import { DEFAULT_GRID_COL_TYPE_KEY, GRID_STRING_COL_DEF, getGridDefaultColumnTypes } from "../../../colDef/index.js";
|
|
3
4
|
import { gridColumnsStateSelector, gridColumnVisibilityModelSelector } from "./gridColumnsSelector.js";
|
|
4
5
|
import { clamp } from "../../../utils/utils.js";
|
|
@@ -275,9 +276,9 @@ export const createColumnsState = ({
|
|
|
275
276
|
}
|
|
276
277
|
}
|
|
277
278
|
});
|
|
278
|
-
columnsState.lookup[field] = _extends({},
|
|
279
|
+
columnsState.lookup[field] = resolveProps(existingState, _extends({}, newColumn, {
|
|
279
280
|
hasBeenResized
|
|
280
|
-
});
|
|
281
|
+
}));
|
|
281
282
|
});
|
|
282
283
|
if (keepOnlyColumnsToUpsert && !isInsideStateInitializer) {
|
|
283
284
|
Object.keys(columnsState.lookup).forEach(field => {
|
|
@@ -3,4 +3,4 @@ import { GridDensity } from '../../../models/gridDensity';
|
|
|
3
3
|
export declare const COMPACT_DENSITY_FACTOR = 0.7;
|
|
4
4
|
export declare const COMFORTABLE_DENSITY_FACTOR = 1.3;
|
|
5
5
|
export declare const gridDensitySelector: (state: GridStateCommunity) => GridDensity;
|
|
6
|
-
export declare const gridDensityFactorSelector: import("
|
|
6
|
+
export declare const gridDensityFactorSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
|
|
@@ -68,7 +68,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
68
68
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
69
69
|
if (params.cellMode === GridCellModes.Edit) {
|
|
70
70
|
// Wait until IME is settled for Asian languages like Japanese and Chinese
|
|
71
|
-
// TODO:
|
|
71
|
+
// TODO: to replace at one point. See https://github.com/mui/material-ui/pull/39713#discussion_r1381678957.
|
|
72
72
|
if (event.which === 229) {
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
@@ -110,7 +110,7 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
110
110
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
111
111
|
if (params.cellMode === GridRowModes.Edit) {
|
|
112
112
|
// Wait until IME is settled for Asian languages like Japanese and Chinese
|
|
113
|
-
// TODO:
|
|
113
|
+
// TODO: to replace at one point. See https://github.com/mui/material-ui/pull/39713#discussion_r1381678957.
|
|
114
114
|
if (event.which === 229) {
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
@@ -5,12 +5,12 @@ import { GridStateCommunity } from '../../../models/gridStateCommunity';
|
|
|
5
5
|
* Get the current filter model.
|
|
6
6
|
* @category Filtering
|
|
7
7
|
*/
|
|
8
|
-
export declare const gridFilterModelSelector: import("
|
|
8
|
+
export declare const gridFilterModelSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridFilterModel>;
|
|
9
9
|
/**
|
|
10
10
|
* Get the current quick filter values.
|
|
11
11
|
* @category Filtering
|
|
12
12
|
*/
|
|
13
|
-
export declare const gridQuickFilterValuesSelector: import("
|
|
13
|
+
export declare const gridQuickFilterValuesSelector: import("../../..").OutputSelector<GridStateCommunity, any[] | undefined>;
|
|
14
14
|
/**
|
|
15
15
|
* @category Visible rows
|
|
16
16
|
* @ignore - do not document.
|
|
@@ -20,79 +20,79 @@ export declare const gridVisibleRowsLookupSelector: (state: GridStateCommunity)
|
|
|
20
20
|
* @category Filtering
|
|
21
21
|
* @ignore - do not document.
|
|
22
22
|
*/
|
|
23
|
-
export declare const gridFilteredRowsLookupSelector: import("
|
|
23
|
+
export declare const gridFilteredRowsLookupSelector: import("../../..").OutputSelector<GridStateCommunity, Record<GridRowId, boolean>>;
|
|
24
24
|
/**
|
|
25
25
|
* @category Filtering
|
|
26
26
|
* @ignore - do not document.
|
|
27
27
|
*/
|
|
28
|
-
export declare const gridFilteredChildrenCountLookupSelector: import("
|
|
28
|
+
export declare const gridFilteredChildrenCountLookupSelector: import("../../..").OutputSelector<GridStateCommunity, Record<GridRowId, number>>;
|
|
29
29
|
/**
|
|
30
30
|
* @category Filtering
|
|
31
31
|
* @ignore - do not document.
|
|
32
32
|
*/
|
|
33
|
-
export declare const gridFilteredDescendantCountLookupSelector: import("
|
|
33
|
+
export declare const gridFilteredDescendantCountLookupSelector: import("../../..").OutputSelector<GridStateCommunity, Record<GridRowId, number>>;
|
|
34
34
|
/**
|
|
35
35
|
* Get the id and the model of the rows accessible after the filtering process.
|
|
36
36
|
* Does not contain the collapsed children.
|
|
37
37
|
* @category Filtering
|
|
38
38
|
*/
|
|
39
|
-
export declare const gridExpandedSortedRowEntriesSelector: import("
|
|
39
|
+
export declare const gridExpandedSortedRowEntriesSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridRowEntry<import("../../..").GridValidRowModel>[]>;
|
|
40
40
|
/**
|
|
41
41
|
* Get the id of the rows accessible after the filtering process.
|
|
42
42
|
* Does not contain the collapsed children.
|
|
43
43
|
* @category Filtering
|
|
44
44
|
*/
|
|
45
|
-
export declare const gridExpandedSortedRowIdsSelector: import("
|
|
45
|
+
export declare const gridExpandedSortedRowIdsSelector: import("../../..").OutputSelector<GridStateCommunity, GridRowId[]>;
|
|
46
46
|
/**
|
|
47
47
|
* Get the id and the model of the rows accessible after the filtering process.
|
|
48
48
|
* Contains the collapsed children.
|
|
49
49
|
* @category Filtering
|
|
50
50
|
*/
|
|
51
|
-
export declare const gridFilteredSortedRowEntriesSelector: import("
|
|
51
|
+
export declare const gridFilteredSortedRowEntriesSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridRowEntry<import("../../..").GridValidRowModel>[]>;
|
|
52
52
|
/**
|
|
53
53
|
* Get the id of the rows accessible after the filtering process.
|
|
54
54
|
* Contains the collapsed children.
|
|
55
55
|
* @category Filtering
|
|
56
56
|
*/
|
|
57
|
-
export declare const gridFilteredSortedRowIdsSelector: import("
|
|
57
|
+
export declare const gridFilteredSortedRowIdsSelector: import("../../..").OutputSelector<GridStateCommunity, GridRowId[]>;
|
|
58
58
|
/**
|
|
59
59
|
* Get the ids to position in the current tree level lookup of the rows accessible after the filtering process.
|
|
60
60
|
* Does not contain the collapsed children.
|
|
61
61
|
* @category Filtering
|
|
62
62
|
* @ignore - do not document.
|
|
63
63
|
*/
|
|
64
|
-
export declare const gridExpandedSortedRowTreeLevelPositionLookupSelector: import("
|
|
64
|
+
export declare const gridExpandedSortedRowTreeLevelPositionLookupSelector: import("../../..").OutputSelector<GridStateCommunity, Record<GridRowId, number>>;
|
|
65
65
|
/**
|
|
66
66
|
* Get the id and the model of the top level rows accessible after the filtering process.
|
|
67
67
|
* @category Filtering
|
|
68
68
|
*/
|
|
69
|
-
export declare const gridFilteredSortedTopLevelRowEntriesSelector: import("
|
|
69
|
+
export declare const gridFilteredSortedTopLevelRowEntriesSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridRowEntry<import("../../..").GridValidRowModel>[]>;
|
|
70
70
|
/**
|
|
71
71
|
* Get the amount of rows accessible after the filtering process.
|
|
72
72
|
* @category Filtering
|
|
73
73
|
*/
|
|
74
|
-
export declare const gridExpandedRowCountSelector: import("
|
|
74
|
+
export declare const gridExpandedRowCountSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
|
|
75
75
|
/**
|
|
76
76
|
* Get the amount of top level rows accessible after the filtering process.
|
|
77
77
|
* @category Filtering
|
|
78
78
|
*/
|
|
79
|
-
export declare const gridFilteredTopLevelRowCountSelector: import("
|
|
79
|
+
export declare const gridFilteredTopLevelRowCountSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
|
|
80
80
|
/**
|
|
81
81
|
* Get the amount of rows accessible after the filtering process.
|
|
82
82
|
* Includes top level and descendant rows.
|
|
83
83
|
* @category Filtering
|
|
84
84
|
*/
|
|
85
|
-
export declare const gridFilteredRowCountSelector: import("
|
|
85
|
+
export declare const gridFilteredRowCountSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
|
|
86
86
|
/**
|
|
87
87
|
* Get the amount of descendant rows accessible after the filtering process.
|
|
88
88
|
* @category Filtering
|
|
89
89
|
*/
|
|
90
|
-
export declare const gridFilteredDescendantRowCountSelector: import("
|
|
90
|
+
export declare const gridFilteredDescendantRowCountSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
|
|
91
91
|
/**
|
|
92
92
|
* @category Filtering
|
|
93
93
|
* @ignore - do not document.
|
|
94
94
|
*/
|
|
95
|
-
export declare const gridFilterActiveItemsSelector: import("
|
|
95
|
+
export declare const gridFilterActiveItemsSelector: import("../../..").OutputSelector<GridStateCommunity, GridFilterItem[]>;
|
|
96
96
|
export type GridFilterActiveItemsLookup = {
|
|
97
97
|
[field: string]: GridFilterItem[];
|
|
98
98
|
};
|
|
@@ -100,4 +100,4 @@ export type GridFilterActiveItemsLookup = {
|
|
|
100
100
|
* @category Filtering
|
|
101
101
|
* @ignore - do not document.
|
|
102
102
|
*/
|
|
103
|
-
export declare const gridFilterActiveItemsLookupSelector: import("
|
|
103
|
+
export declare const gridFilterActiveItemsLookupSelector: import("../../..").OutputSelector<GridStateCommunity, GridFilterActiveItemsLookup>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { GridStateCommunity } from '../../../models/gridStateCommunity';
|
|
2
2
|
import { GridFocusState, GridTabIndexState } from './gridFocusState';
|
|
3
3
|
export declare const gridFocusStateSelector: (state: GridStateCommunity) => GridFocusState;
|
|
4
|
-
export declare const gridFocusCellSelector: import("
|
|
5
|
-
export declare const gridFocusColumnHeaderSelector: import("
|
|
6
|
-
export declare const gridFocusColumnHeaderFilterSelector: import("
|
|
7
|
-
export declare const gridFocusColumnGroupHeaderSelector: import("
|
|
4
|
+
export declare const gridFocusCellSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridCellCoordinates | null>;
|
|
5
|
+
export declare const gridFocusColumnHeaderSelector: import("../../..").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
|
|
6
|
+
export declare const gridFocusColumnHeaderFilterSelector: import("../../..").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
|
|
7
|
+
export declare const gridFocusColumnGroupHeaderSelector: import("../../..").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnGroupIdentifier | null>;
|
|
8
8
|
export declare const gridTabIndexStateSelector: (state: GridStateCommunity) => GridTabIndexState;
|
|
9
|
-
export declare const gridTabIndexCellSelector: import("
|
|
10
|
-
export declare const gridTabIndexColumnHeaderSelector: import("
|
|
11
|
-
export declare const gridTabIndexColumnHeaderFilterSelector: import("
|
|
12
|
-
export declare const gridTabIndexColumnGroupHeaderSelector: import("
|
|
9
|
+
export declare const gridTabIndexCellSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridCellCoordinates | null>;
|
|
10
|
+
export declare const gridTabIndexColumnHeaderSelector: import("../../..").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
|
|
11
|
+
export declare const gridTabIndexColumnHeaderFilterSelector: import("../../..").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
|
|
12
|
+
export declare const gridTabIndexColumnGroupHeaderSelector: import("../../..").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnGroupIdentifier | null>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GridStateCommunity } from '../../../models/gridStateCommunity';
|
|
2
2
|
export declare const gridHeaderFilteringStateSelector: (state: GridStateCommunity) => import("../../../models/gridHeaderFilteringModel").GridHeaderFilteringState;
|
|
3
|
-
export declare const gridHeaderFilteringEnabledSelector: import("
|
|
4
|
-
export declare const gridHeaderFilteringEditFieldSelector: import("
|
|
5
|
-
export declare const gridHeaderFilteringMenuSelector: import("
|
|
3
|
+
export declare const gridHeaderFilteringEnabledSelector: import("../../..").OutputSelector<GridStateCommunity, boolean>;
|
|
4
|
+
export declare const gridHeaderFilteringEditFieldSelector: import("../../..").OutputSelector<GridStateCommunity, string | null>;
|
|
5
|
+
export declare const gridHeaderFilteringMenuSelector: import("../../..").OutputSelector<GridStateCommunity, string | null>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridColDef, GridRowEntry, GridRowId } from '../../../models';
|
|
3
3
|
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
4
|
-
export declare function enrichPageRowsWithPinnedRows(apiRef: React.MutableRefObject<GridApiCommunity>, rows: GridRowEntry[]): GridRowEntry<import("
|
|
4
|
+
export declare function enrichPageRowsWithPinnedRows(apiRef: React.MutableRefObject<GridApiCommunity>, rows: GridRowEntry[]): GridRowEntry<import("../../..").GridValidRowModel>[];
|
|
5
5
|
export declare const getLeftColumnIndex: ({ currentColIndex, firstColIndex, lastColIndex, isRtl, }: {
|
|
6
6
|
currentColIndex: number;
|
|
7
7
|
firstColIndex: number;
|
|
@@ -8,37 +8,37 @@ export declare const gridPaginationSelector: (state: GridStateCommunity) => impo
|
|
|
8
8
|
* Get the pagination model
|
|
9
9
|
* @category Pagination
|
|
10
10
|
*/
|
|
11
|
-
export declare const gridPaginationModelSelector: import("
|
|
11
|
+
export declare const gridPaginationModelSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridPaginationModel>;
|
|
12
12
|
/**
|
|
13
13
|
* Get the row count
|
|
14
14
|
* @category Pagination
|
|
15
15
|
*/
|
|
16
|
-
export declare const gridPaginationRowCountSelector: import("
|
|
16
|
+
export declare const gridPaginationRowCountSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
|
|
17
17
|
/**
|
|
18
18
|
* Get the pagination meta
|
|
19
19
|
* @category Pagination
|
|
20
20
|
*/
|
|
21
|
-
export declare const gridPaginationMetaSelector: import("
|
|
21
|
+
export declare const gridPaginationMetaSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridPaginationMeta>;
|
|
22
22
|
/**
|
|
23
23
|
* Get the index of the page to render if the pagination is enabled
|
|
24
24
|
* @category Pagination
|
|
25
25
|
*/
|
|
26
|
-
export declare const gridPageSelector: import("
|
|
26
|
+
export declare const gridPageSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
|
|
27
27
|
/**
|
|
28
28
|
* Get the maximum amount of rows to display on a single page if the pagination is enabled
|
|
29
29
|
* @category Pagination
|
|
30
30
|
*/
|
|
31
|
-
export declare const gridPageSizeSelector: import("
|
|
31
|
+
export declare const gridPageSizeSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
|
|
32
32
|
/**
|
|
33
33
|
* Get the amount of pages needed to display all the rows if the pagination is enabled
|
|
34
34
|
* @category Pagination
|
|
35
35
|
*/
|
|
36
|
-
export declare const gridPageCountSelector: import("
|
|
36
|
+
export declare const gridPageCountSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
|
|
37
37
|
/**
|
|
38
38
|
* Get the index of the first and the last row to include in the current page if the pagination is enabled.
|
|
39
39
|
* @category Pagination
|
|
40
40
|
*/
|
|
41
|
-
export declare const gridPaginationRowRangeSelector: import("
|
|
41
|
+
export declare const gridPaginationRowRangeSelector: import("../../..").OutputSelector<GridStateCommunity, {
|
|
42
42
|
firstRowIndex: number;
|
|
43
43
|
lastRowIndex: number;
|
|
44
44
|
} | null>;
|
|
@@ -46,9 +46,9 @@ export declare const gridPaginationRowRangeSelector: import("../../../utils/crea
|
|
|
46
46
|
* Get the id and the model of each row to include in the current page if the pagination is enabled.
|
|
47
47
|
* @category Pagination
|
|
48
48
|
*/
|
|
49
|
-
export declare const gridPaginatedVisibleSortedGridRowEntriesSelector: import("
|
|
49
|
+
export declare const gridPaginatedVisibleSortedGridRowEntriesSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridRowEntry<import("../../..").GridValidRowModel>[]>;
|
|
50
50
|
/**
|
|
51
51
|
* Get the id of each row to include in the current page if the pagination is enabled.
|
|
52
52
|
* @category Pagination
|
|
53
53
|
*/
|
|
54
|
-
export declare const gridPaginatedVisibleSortedGridRowIdsSelector: import("
|
|
54
|
+
export declare const gridPaginatedVisibleSortedGridRowIdsSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridRowId[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GridStateCommunity } from '../../../models/gridStateCommunity';
|
|
2
2
|
import { GridRowId } from '../../../models/gridRows';
|
|
3
3
|
export declare const gridRowSelectionStateSelector: (state: GridStateCommunity) => import("../../..").GridRowSelectionModel;
|
|
4
|
-
export declare const selectedGridRowsCountSelector: import("
|
|
5
|
-
export declare const selectedGridRowsSelector: import("
|
|
6
|
-
export declare const selectedIdsLookupSelector: import("
|
|
4
|
+
export declare const selectedGridRowsCountSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
|
|
5
|
+
export declare const selectedGridRowsSelector: import("../../..").OutputSelector<GridStateCommunity, Map<GridRowId, import("../../..").GridValidRowModel>>;
|
|
6
|
+
export declare const selectedIdsLookupSelector: import("../../..").OutputSelector<GridStateCommunity, Record<GridRowId, GridRowId>>;
|
|
@@ -9,4 +9,4 @@ export declare const rowSelectionStateInitializer: GridStateInitializer<Pick<Dat
|
|
|
9
9
|
* @requires useGridFocus (state) - can be after
|
|
10
10
|
* @requires useGridKeyboardNavigation (`cellKeyDown` event must first be consumed by it)
|
|
11
11
|
*/
|
|
12
|
-
export declare const useGridRowSelection: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "checkboxSelection" | "rowSelectionModel" | "onRowSelectionModelChange" | "disableMultipleRowSelection" | "disableRowSelectionOnClick" | "isRowSelectable" | "checkboxSelectionVisibleOnly" | "pagination" | "paginationMode" | "classes" | "keepNonExistentRowsSelected" | "rowSelection" | "signature">) => void;
|
|
12
|
+
export declare const useGridRowSelection: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "checkboxSelection" | "rowSelectionModel" | "onRowSelectionModelChange" | "disableMultipleRowSelection" | "disableRowSelectionOnClick" | "isRowSelectable" | "checkboxSelectionVisibleOnly" | "pagination" | "paginationMode" | "classes" | "keepNonExistentRowsSelected" | "rowSelection" | "rowSelectionPropagation" | "signature">) => void;
|
|
@@ -3,11 +3,12 @@ import * as React from 'react';
|
|
|
3
3
|
import { GridSignature, useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
|
|
4
4
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
|
|
5
5
|
import { useGridLogger } from "../../utils/useGridLogger.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useGridSelector } from "../../utils/useGridSelector.js";
|
|
7
|
+
import { gridRowMaximumTreeDepthSelector, gridRowTreeSelector } from "../rows/gridRowsSelector.js";
|
|
7
8
|
import { gridRowSelectionStateSelector, selectedGridRowsSelector, selectedIdsLookupSelector } from "./gridRowSelectionSelector.js";
|
|
8
9
|
import { gridPaginatedVisibleSortedGridRowIdsSelector } from "../pagination/index.js";
|
|
9
10
|
import { gridFocusCellSelector } from "../focus/gridFocusStateSelector.js";
|
|
10
|
-
import { gridExpandedSortedRowIdsSelector,
|
|
11
|
+
import { gridExpandedSortedRowIdsSelector, gridFilteredRowsLookupSelector } from "../filter/gridFilterSelector.js";
|
|
11
12
|
import { GRID_CHECKBOX_SELECTION_COL_DEF, GRID_ACTIONS_COLUMN_TYPE } from "../../../colDef/index.js";
|
|
12
13
|
import { GridCellModes } from "../../../models/gridEditRowModel.js";
|
|
13
14
|
import { isKeyboardEvent, isNavigationKey } from "../../../utils/keyboardUtils.js";
|
|
@@ -15,7 +16,7 @@ import { useGridVisibleRows } from "../../utils/useGridVisibleRows.js";
|
|
|
15
16
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../constants/gridDetailPanelToggleField.js";
|
|
16
17
|
import { gridClasses } from "../../../constants/gridClasses.js";
|
|
17
18
|
import { isEventTargetInPortal } from "../../../utils/domUtils.js";
|
|
18
|
-
import { isMultipleRowSelectionEnabled } from "./utils.js";
|
|
19
|
+
import { isMultipleRowSelectionEnabled, findRowsToSelect, findRowsToDeselect } from "./utils.js";
|
|
19
20
|
const getSelectionModelPropValue = (selectionModelProp, prevSelectionModel) => {
|
|
20
21
|
if (selectionModelProp == null) {
|
|
21
22
|
return selectionModelProp;
|
|
@@ -40,11 +41,12 @@ export const rowSelectionStateInitializer = (state, props) => _extends({}, state
|
|
|
40
41
|
*/
|
|
41
42
|
export const useGridRowSelection = (apiRef, props) => {
|
|
42
43
|
const logger = useGridLogger(apiRef, 'useGridSelection');
|
|
43
|
-
const runIfRowSelectionIsEnabled = callback => (...args) => {
|
|
44
|
+
const runIfRowSelectionIsEnabled = React.useCallback(callback => (...args) => {
|
|
44
45
|
if (props.rowSelection) {
|
|
45
46
|
callback(...args);
|
|
46
47
|
}
|
|
47
|
-
};
|
|
48
|
+
}, [props.rowSelection]);
|
|
49
|
+
const applyAutoSelection = props.signature !== GridSignature.DataGrid && (props.rowSelectionPropagation?.parents || props.rowSelectionPropagation?.descendants);
|
|
48
50
|
const propRowSelectionModel = React.useMemo(() => {
|
|
49
51
|
return getSelectionModelPropValue(props.rowSelectionModel, gridRowSelectionStateSelector(apiRef.current.state));
|
|
50
52
|
}, [apiRef, props.rowSelectionModel]);
|
|
@@ -63,6 +65,8 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
63
65
|
} = props;
|
|
64
66
|
const canHaveMultipleSelection = isMultipleRowSelectionEnabled(props);
|
|
65
67
|
const visibleRows = useGridVisibleRows(apiRef, props);
|
|
68
|
+
const tree = useGridSelector(apiRef, gridRowTreeSelector);
|
|
69
|
+
const isNestedData = useGridSelector(apiRef, gridRowMaximumTreeDepthSelector) > 1;
|
|
66
70
|
const expandMouseRowRangeSelection = React.useCallback(id => {
|
|
67
71
|
let endId = id;
|
|
68
72
|
const startId = lastRowToggled.current ?? id;
|
|
@@ -87,7 +91,7 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
87
91
|
}, !isSelected);
|
|
88
92
|
}, [apiRef]);
|
|
89
93
|
|
|
90
|
-
|
|
94
|
+
/*
|
|
91
95
|
* API METHODS
|
|
92
96
|
*/
|
|
93
97
|
const setRowSelectionModel = React.useCallback(model => {
|
|
@@ -125,34 +129,80 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
125
129
|
lastRowToggled.current = id;
|
|
126
130
|
if (resetSelection) {
|
|
127
131
|
logger.debug(`Setting selection for row ${id}`);
|
|
128
|
-
|
|
132
|
+
const newSelection = [];
|
|
133
|
+
const addRow = rowId => {
|
|
134
|
+
newSelection.push(rowId);
|
|
135
|
+
};
|
|
136
|
+
if (isSelected) {
|
|
137
|
+
addRow(id);
|
|
138
|
+
if (applyAutoSelection) {
|
|
139
|
+
findRowsToSelect(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, addRow);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
apiRef.current.setRowSelectionModel(newSelection);
|
|
129
143
|
} else {
|
|
130
144
|
logger.debug(`Toggling selection for row ${id}`);
|
|
131
145
|
const selection = gridRowSelectionStateSelector(apiRef.current.state);
|
|
132
|
-
const newSelection = selection
|
|
146
|
+
const newSelection = new Set(selection);
|
|
147
|
+
newSelection.delete(id);
|
|
148
|
+
const addRow = rowId => {
|
|
149
|
+
newSelection.add(rowId);
|
|
150
|
+
};
|
|
151
|
+
const removeRow = rowId => {
|
|
152
|
+
newSelection.delete(rowId);
|
|
153
|
+
};
|
|
133
154
|
if (isSelected) {
|
|
134
|
-
|
|
155
|
+
addRow(id);
|
|
156
|
+
if (applyAutoSelection) {
|
|
157
|
+
findRowsToSelect(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, addRow);
|
|
158
|
+
}
|
|
159
|
+
} else if (applyAutoSelection) {
|
|
160
|
+
findRowsToDeselect(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, removeRow);
|
|
135
161
|
}
|
|
136
|
-
const isSelectionValid = newSelection.
|
|
162
|
+
const isSelectionValid = newSelection.size < 2 || canHaveMultipleSelection;
|
|
137
163
|
if (isSelectionValid) {
|
|
138
|
-
apiRef.current.setRowSelectionModel(newSelection);
|
|
164
|
+
apiRef.current.setRowSelectionModel(Array.from(newSelection));
|
|
139
165
|
}
|
|
140
166
|
}
|
|
141
|
-
}, [apiRef, logger, canHaveMultipleSelection]);
|
|
167
|
+
}, [apiRef, logger, applyAutoSelection, tree, props.rowSelectionPropagation?.descendants, props.rowSelectionPropagation?.parents, canHaveMultipleSelection]);
|
|
142
168
|
const selectRows = React.useCallback((ids, isSelected = true, resetSelection = false) => {
|
|
143
169
|
logger.debug(`Setting selection for several rows`);
|
|
144
170
|
const selectableIds = ids.filter(id => apiRef.current.isRowSelectable(id));
|
|
145
171
|
let newSelection;
|
|
146
172
|
if (resetSelection) {
|
|
147
|
-
|
|
173
|
+
if (isSelected) {
|
|
174
|
+
newSelection = selectableIds;
|
|
175
|
+
if (applyAutoSelection) {
|
|
176
|
+
const addRow = rowId => {
|
|
177
|
+
newSelection.push(rowId);
|
|
178
|
+
};
|
|
179
|
+
selectableIds.forEach(id => {
|
|
180
|
+
findRowsToSelect(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, addRow);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
} else {
|
|
184
|
+
newSelection = [];
|
|
185
|
+
}
|
|
148
186
|
} else {
|
|
149
187
|
// We clone the existing object to avoid mutating the same object returned by the selector to others part of the project
|
|
150
188
|
const selectionLookup = _extends({}, selectedIdsLookupSelector(apiRef));
|
|
189
|
+
const addRow = rowId => {
|
|
190
|
+
selectionLookup[rowId] = rowId;
|
|
191
|
+
};
|
|
192
|
+
const removeRow = rowId => {
|
|
193
|
+
delete selectionLookup[rowId];
|
|
194
|
+
};
|
|
151
195
|
selectableIds.forEach(id => {
|
|
152
196
|
if (isSelected) {
|
|
153
197
|
selectionLookup[id] = id;
|
|
198
|
+
if (applyAutoSelection) {
|
|
199
|
+
findRowsToSelect(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, addRow);
|
|
200
|
+
}
|
|
154
201
|
} else {
|
|
155
|
-
|
|
202
|
+
removeRow(id);
|
|
203
|
+
if (applyAutoSelection) {
|
|
204
|
+
findRowsToDeselect(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, removeRow);
|
|
205
|
+
}
|
|
156
206
|
}
|
|
157
207
|
});
|
|
158
208
|
newSelection = Object.values(selectionLookup);
|
|
@@ -161,7 +211,7 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
161
211
|
if (isSelectionValid) {
|
|
162
212
|
apiRef.current.setRowSelectionModel(newSelection);
|
|
163
213
|
}
|
|
164
|
-
}, [apiRef,
|
|
214
|
+
}, [logger, applyAutoSelection, canHaveMultipleSelection, apiRef, tree, props.rowSelectionPropagation?.descendants, props.rowSelectionPropagation?.parents]);
|
|
165
215
|
const selectRowRange = React.useCallback(({
|
|
166
216
|
startId,
|
|
167
217
|
endId
|
|
@@ -193,29 +243,52 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
193
243
|
useGridApiMethod(apiRef, selectionPublicApi, 'public');
|
|
194
244
|
useGridApiMethod(apiRef, selectionPrivateApi, props.signature === GridSignature.DataGrid ? 'private' : 'public');
|
|
195
245
|
|
|
196
|
-
|
|
246
|
+
/*
|
|
197
247
|
* EVENTS
|
|
198
248
|
*/
|
|
199
|
-
const removeOutdatedSelection = React.useCallback(() => {
|
|
200
|
-
if (props.keepNonExistentRowsSelected) {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
249
|
+
const removeOutdatedSelection = React.useCallback((sortModelUpdated = false) => {
|
|
203
250
|
const currentSelection = gridRowSelectionStateSelector(apiRef.current.state);
|
|
204
|
-
const
|
|
251
|
+
const filteredRowsLookup = gridFilteredRowsLookupSelector(apiRef);
|
|
205
252
|
|
|
206
253
|
// We clone the existing object to avoid mutating the same object returned by the selector to others part of the project
|
|
207
254
|
const selectionLookup = _extends({}, selectedIdsLookupSelector(apiRef));
|
|
208
255
|
let hasChanged = false;
|
|
209
256
|
currentSelection.forEach(id => {
|
|
210
|
-
if (
|
|
257
|
+
if (filteredRowsLookup[id] === false) {
|
|
258
|
+
if (props.keepNonExistentRowsSelected) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
211
261
|
delete selectionLookup[id];
|
|
212
262
|
hasChanged = true;
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (!props.rowSelectionPropagation?.parents) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const node = tree[id];
|
|
269
|
+
if (node.type === 'group') {
|
|
270
|
+
const isAutoGenerated = node.isAutoGenerated;
|
|
271
|
+
if (isAutoGenerated) {
|
|
272
|
+
delete selectionLookup[id];
|
|
273
|
+
hasChanged = true;
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
// Keep previously selected tree data parents selected if all their children are filtered out
|
|
277
|
+
if (!node.children.every(childId => filteredRowsLookup[childId] === false)) {
|
|
278
|
+
delete selectionLookup[id];
|
|
279
|
+
hasChanged = true;
|
|
280
|
+
}
|
|
213
281
|
}
|
|
214
282
|
});
|
|
215
|
-
if (hasChanged) {
|
|
216
|
-
|
|
283
|
+
if (hasChanged || isNestedData && !sortModelUpdated) {
|
|
284
|
+
const newSelection = Object.values(selectionLookup);
|
|
285
|
+
if (isNestedData) {
|
|
286
|
+
apiRef.current.selectRows(newSelection, true, true);
|
|
287
|
+
} else {
|
|
288
|
+
apiRef.current.setRowSelectionModel(newSelection);
|
|
289
|
+
}
|
|
217
290
|
}
|
|
218
|
-
}, [apiRef, props.keepNonExistentRowsSelected]);
|
|
291
|
+
}, [apiRef, isNestedData, props.rowSelectionPropagation?.parents, props.keepNonExistentRowsSelected, tree]);
|
|
219
292
|
const handleSingleRowSelection = React.useCallback((id, event) => {
|
|
220
293
|
const hasCtrlKey = event.metaKey || event.ctrlKey;
|
|
221
294
|
|
|
@@ -276,8 +349,7 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
276
349
|
}, [apiRef, expandMouseRowRangeSelection, canHaveMultipleSelection]);
|
|
277
350
|
const handleHeaderSelectionCheckboxChange = React.useCallback(params => {
|
|
278
351
|
const rowsToBeSelected = props.pagination && props.checkboxSelectionVisibleOnly && props.paginationMode === 'client' ? gridPaginatedVisibleSortedGridRowIdsSelector(apiRef) : gridExpandedSortedRowIdsSelector(apiRef);
|
|
279
|
-
|
|
280
|
-
apiRef.current.selectRows(rowsToBeSelected, params.value, filterModel?.items.length > 0);
|
|
352
|
+
apiRef.current.selectRows(rowsToBeSelected, params.value);
|
|
281
353
|
}, [apiRef, props.checkboxSelectionVisibleOnly, props.pagination, props.paginationMode]);
|
|
282
354
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
283
355
|
// Get the most recent cell mode because it may have been changed by another listener
|
|
@@ -341,14 +413,15 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
341
413
|
selectRows(apiRef.current.getAllRowIds(), true);
|
|
342
414
|
}
|
|
343
415
|
}, [apiRef, handleSingleRowSelection, selectRows, visibleRows.rows, canHaveMultipleSelection]);
|
|
344
|
-
useGridApiEventHandler(apiRef, 'sortedRowsSet', runIfRowSelectionIsEnabled(removeOutdatedSelection));
|
|
416
|
+
useGridApiEventHandler(apiRef, 'sortedRowsSet', runIfRowSelectionIsEnabled(() => removeOutdatedSelection(true)));
|
|
417
|
+
useGridApiEventHandler(apiRef, 'filteredRowsSet', runIfRowSelectionIsEnabled(removeOutdatedSelection));
|
|
345
418
|
useGridApiEventHandler(apiRef, 'rowClick', runIfRowSelectionIsEnabled(handleRowClick));
|
|
346
419
|
useGridApiEventHandler(apiRef, 'rowSelectionCheckboxChange', runIfRowSelectionIsEnabled(handleRowSelectionCheckboxChange));
|
|
347
420
|
useGridApiEventHandler(apiRef, 'headerSelectionCheckboxChange', handleHeaderSelectionCheckboxChange);
|
|
348
421
|
useGridApiEventHandler(apiRef, 'cellMouseDown', runIfRowSelectionIsEnabled(preventSelectionOnShift));
|
|
349
422
|
useGridApiEventHandler(apiRef, 'cellKeyDown', runIfRowSelectionIsEnabled(handleCellKeyDown));
|
|
350
423
|
|
|
351
|
-
|
|
424
|
+
/*
|
|
352
425
|
* EFFECTS
|
|
353
426
|
*/
|
|
354
427
|
React.useEffect(() => {
|
|
@@ -386,4 +459,7 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
386
459
|
apiRef.current.setRowSelectionModel([]);
|
|
387
460
|
}
|
|
388
461
|
}, [apiRef, canHaveMultipleSelection, checkboxSelection, isStateControlled, props.rowSelection]);
|
|
462
|
+
React.useEffect(() => {
|
|
463
|
+
runIfRowSelectionIsEnabled(removeOutdatedSelection);
|
|
464
|
+
}, [removeOutdatedSelection, runIfRowSelectionIsEnabled]);
|
|
389
465
|
};
|