@mui/x-data-grid 8.22.0 → 8.23.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 +202 -0
- package/colDef/gridBooleanColDef.js +0 -1
- package/colDef/gridDateOperators.js +6 -6
- package/components/cell/GridBooleanCell.js +9 -1
- package/components/cell/GridFooterCell.d.ts +9 -0
- package/components/cell/GridFooterCell.js +54 -0
- package/components/columnSelection/GridCellCheckboxRenderer.js +4 -3
- package/components/containers/GridRootStyles.js +4 -0
- package/esm/colDef/gridBooleanColDef.js +0 -1
- package/esm/colDef/gridDateOperators.js +6 -6
- package/esm/components/cell/GridBooleanCell.js +9 -1
- package/esm/components/cell/GridFooterCell.d.ts +9 -0
- package/esm/components/cell/GridFooterCell.js +48 -0
- package/esm/components/columnSelection/GridCellCheckboxRenderer.js +4 -3
- package/esm/components/containers/GridRootStyles.js +4 -0
- package/esm/hooks/core/useGridProps.js +2 -1
- package/esm/hooks/features/columnResize/gridColumnResizeApi.d.ts +7 -0
- package/esm/hooks/features/columnResize/gridColumnResizeApi.js +1 -0
- package/esm/hooks/features/columnResize/useGridColumnResize.js +29 -2
- package/esm/hooks/features/columns/gridColumnsUtils.js +12 -7
- package/esm/hooks/features/dataSource/useGridDataSourceBase.d.ts +3 -3
- package/esm/hooks/features/editing/useGridCellEditing.js +1 -0
- package/esm/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -1
- package/esm/hooks/features/pagination/gridPaginationSelector.js +3 -0
- package/esm/hooks/features/rowSelection/useGridRowSelection.js +17 -15
- package/esm/hooks/features/rowSelection/utils.js +36 -9
- package/esm/hooks/features/rows/useGridRowSpanning.js +1 -0
- package/esm/index.js +1 -1
- package/esm/internals/index.d.ts +2 -0
- package/esm/internals/index.js +1 -0
- package/esm/locales/ptPT.d.ts +2 -1
- package/esm/locales/ptPT.js +114 -125
- package/esm/locales/svSE.js +2 -2
- package/esm/models/gridAggregation.d.ts +18 -0
- package/esm/models/gridAggregation.js +1 -0
- package/esm/utils/domUtils.d.ts +1 -0
- package/esm/utils/domUtils.js +4 -0
- package/esm/utils/utils.d.ts +1 -1
- package/esm/utils/utils.js +2 -2
- package/hooks/core/useGridProps.js +2 -1
- package/hooks/features/columnResize/gridColumnResizeApi.d.ts +7 -0
- package/hooks/features/columnResize/gridColumnResizeApi.js +1 -0
- package/hooks/features/columnResize/useGridColumnResize.js +28 -1
- package/hooks/features/columns/gridColumnsUtils.js +12 -7
- package/hooks/features/dataSource/useGridDataSourceBase.d.ts +3 -3
- package/hooks/features/editing/useGridCellEditing.js +1 -0
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -1
- package/hooks/features/pagination/gridPaginationSelector.js +3 -0
- package/hooks/features/rowSelection/useGridRowSelection.js +17 -15
- package/hooks/features/rowSelection/utils.js +36 -9
- package/hooks/features/rows/useGridRowSpanning.js +1 -0
- package/index.js +1 -1
- package/internals/index.d.ts +2 -0
- package/internals/index.js +8 -0
- package/locales/ptPT.d.ts +2 -1
- package/locales/ptPT.js +114 -125
- package/locales/svSE.js +2 -2
- package/models/gridAggregation.d.ts +18 -0
- package/models/gridAggregation.js +5 -0
- package/package.json +3 -3
- package/utils/domUtils.d.ts +1 -0
- package/utils/domUtils.js +5 -0
- package/utils/utils.d.ts +1 -1
- package/utils/utils.js +2 -2
|
@@ -6,7 +6,7 @@ import useEventCallback from '@mui/utils/useEventCallback';
|
|
|
6
6
|
import ownerDocument from '@mui/utils/ownerDocument';
|
|
7
7
|
import useLazyRef from '@mui/utils/useLazyRef';
|
|
8
8
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
9
|
-
import { findGridCellElementsFromCol, findGridElement, findLeftPinnedCellsAfterCol, findRightPinnedCellsBeforeCol, getFieldFromHeaderElem, findHeaderElementFromField, getFieldsFromGroupHeaderElem, findGroupHeaderElementsFromField, findGridHeader, findGridCells, findParentElementFromClassName, findLeftPinnedHeadersAfterCol, findRightPinnedHeadersBeforeCol, escapeOperandAttributeSelector } from "../../../utils/domUtils.js";
|
|
9
|
+
import { findGridCellElementsFromCol, findGridElement, findLeftPinnedCellsAfterCol, findRightPinnedCellsBeforeCol, getFieldFromHeaderElem, findHeaderElementFromField, getFieldsFromGroupHeaderElem, findGroupHeaderElementsFromField, findGridHeader, findGridHeaderFilter, findGridCells, findParentElementFromClassName, findLeftPinnedHeadersAfterCol, findRightPinnedHeadersBeforeCol, escapeOperandAttributeSelector } from "../../../utils/domUtils.js";
|
|
10
10
|
import { DEFAULT_GRID_AUTOSIZE_OPTIONS } from "./gridColumnResizeApi.js";
|
|
11
11
|
import { gridClasses } from "../../../constants/gridClasses.js";
|
|
12
12
|
import { useGridEvent, useGridApiMethod, useGridEventPriority, useGridLogger, useGridNativeEventListener, useGridSelector, useOnMount } from "../../utils/index.js";
|
|
@@ -17,6 +17,8 @@ import { useTimeout } from "../../utils/useTimeout.js";
|
|
|
17
17
|
import { GridPinnedColumnPosition } from "../columns/gridColumnsInterfaces.js";
|
|
18
18
|
import { gridColumnsStateSelector } from "../columns/index.js";
|
|
19
19
|
import { gridDimensionsSelector } from "../dimensions/index.js";
|
|
20
|
+
import { gridHeaderFilteringEnabledSelector } from "../headerFiltering/index.js";
|
|
21
|
+
import { gridResizingColumnFieldSelector } from "./columnResizeSelector.js";
|
|
20
22
|
function trackFinger(event, currentTouchId) {
|
|
21
23
|
if (currentTouchId !== undefined && event.changedTouches) {
|
|
22
24
|
for (let i = 0; i < event.changedTouches.length; i += 1) {
|
|
@@ -133,6 +135,7 @@ function extractColumnWidths(apiRef, options, columns) {
|
|
|
133
135
|
const widthByField = {};
|
|
134
136
|
const root = apiRef.current.rootElementRef.current;
|
|
135
137
|
root.classList.add(gridClasses.autosizing);
|
|
138
|
+
const includeHeaderFilters = options.includeHeaderFilters && gridHeaderFilteringEnabledSelector(apiRef);
|
|
136
139
|
columns.forEach(column => {
|
|
137
140
|
const cells = findGridCells(apiRef.current, column.field);
|
|
138
141
|
const widths = cells.map(cell => {
|
|
@@ -163,6 +166,16 @@ function extractColumnWidths(apiRef, options, columns) {
|
|
|
163
166
|
filteredWidths.push(width);
|
|
164
167
|
}
|
|
165
168
|
}
|
|
169
|
+
if (includeHeaderFilters) {
|
|
170
|
+
const headerFilter = findGridHeaderFilter(apiRef.current, column.field);
|
|
171
|
+
if (headerFilter) {
|
|
172
|
+
const style = window.getComputedStyle(headerFilter, null);
|
|
173
|
+
const paddingWidth = parseInt(style.paddingLeft, 10) + parseInt(style.paddingRight, 10);
|
|
174
|
+
const contentWidth = headerFilter.scrollWidth;
|
|
175
|
+
const width = contentWidth + paddingWidth;
|
|
176
|
+
filteredWidths.push(width);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
166
179
|
const hasColumnMin = column.minWidth !== -Infinity && column.minWidth !== undefined;
|
|
167
180
|
const hasColumnMax = column.maxWidth !== Infinity && column.maxWidth !== undefined;
|
|
168
181
|
const min = hasColumnMin ? column.minWidth : 0;
|
|
@@ -320,6 +333,11 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
320
333
|
apiRef.current.publishEvent('columnResizeStop', null, nativeEvent);
|
|
321
334
|
});
|
|
322
335
|
};
|
|
336
|
+
const setCellElementsRef = () => {
|
|
337
|
+
if (refs.columnHeaderElement) {
|
|
338
|
+
refs.cellElements = findGridCellElementsFromCol(refs.columnHeaderElement, apiRef.current);
|
|
339
|
+
}
|
|
340
|
+
};
|
|
323
341
|
const storeReferences = (colDef, separator, xStart) => {
|
|
324
342
|
const root = apiRef.current.rootElementRef.current;
|
|
325
343
|
refs.initialColWidth = colDef.computedWidth;
|
|
@@ -331,7 +349,7 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
331
349
|
refs.headerFilterElement = headerFilterElement;
|
|
332
350
|
}
|
|
333
351
|
refs.groupHeaderElements = findGroupHeaderElementsFromField(apiRef.current.columnHeadersContainerRef?.current, colDef.field);
|
|
334
|
-
|
|
352
|
+
setCellElementsRef();
|
|
335
353
|
refs.fillerLeft = findGridElement(apiRef.current, isRtl ? 'filler--pinnedRight' : 'filler--pinnedLeft');
|
|
336
354
|
refs.fillerRight = findGridElement(apiRef.current, isRtl ? 'filler--pinnedLeft' : 'filler--pinnedRight');
|
|
337
355
|
const pinnedPosition = apiRef.current.unstable_applyPipeProcessors('isColumnPinned', false, refs.colDef.field);
|
|
@@ -578,6 +596,15 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
578
596
|
useGridEvent(apiRef, 'columnResizeStart', handleResizeStart);
|
|
579
597
|
useGridEvent(apiRef, 'columnSeparatorMouseDown', handleColumnResizeMouseDown);
|
|
580
598
|
useGridEvent(apiRef, 'columnSeparatorDoubleClick', handleColumnSeparatorDoubleClick);
|
|
599
|
+
useGridEvent(apiRef, 'rowsSet', () => {
|
|
600
|
+
// if the user is still resizing the column, update the cell references included in the resize action
|
|
601
|
+
if (gridResizingColumnFieldSelector(apiRef) !== '') {
|
|
602
|
+
// wait until the rows are in the DOM
|
|
603
|
+
requestAnimationFrame(() => {
|
|
604
|
+
setCellElementsRef();
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
});
|
|
581
608
|
useGridEventPriority(apiRef, 'columnResize', props.onColumnResize);
|
|
582
609
|
useGridEventPriority(apiRef, 'columnWidthChange', props.onColumnWidthChange);
|
|
583
610
|
};
|
|
@@ -236,8 +236,7 @@ export const createColumnsState = ({
|
|
|
236
236
|
const currentState = gridColumnsStateSelector(apiRef);
|
|
237
237
|
columnsState = {
|
|
238
238
|
orderedFields: keepOnlyColumnsToUpsert ? [] : [...currentState.orderedFields],
|
|
239
|
-
lookup: _extends({}, currentState.lookup),
|
|
240
|
-
// Will be cleaned later if keepOnlyColumnsToUpsert=true
|
|
239
|
+
lookup: keepOnlyColumnsToUpsert ? {} : _extends({}, currentState.lookup),
|
|
241
240
|
columnVisibilityModel,
|
|
242
241
|
initialColumnVisibilityModel: updateInitialVisibilityModel ? columnVisibilityModel : currentState.initialColumnVisibilityModel
|
|
243
242
|
};
|
|
@@ -250,12 +249,10 @@ export const createColumnsState = ({
|
|
|
250
249
|
}
|
|
251
250
|
}
|
|
252
251
|
}
|
|
253
|
-
const columnsToUpsertLookup = {};
|
|
254
252
|
columnsToUpsert.forEach(newColumn => {
|
|
255
253
|
const {
|
|
256
254
|
field
|
|
257
255
|
} = newColumn;
|
|
258
|
-
columnsToUpsertLookup[field] = true;
|
|
259
256
|
columnsToKeep[field] = true;
|
|
260
257
|
let existingState = columnsState.lookup[field];
|
|
261
258
|
if (existingState == null) {
|
|
@@ -283,9 +280,17 @@ export const createColumnsState = ({
|
|
|
283
280
|
}
|
|
284
281
|
}
|
|
285
282
|
});
|
|
286
|
-
|
|
287
|
-
hasBeenResized
|
|
288
|
-
|
|
283
|
+
const mergedProps = _extends({}, getDefaultColTypeDef(newColumn.type), {
|
|
284
|
+
hasBeenResized,
|
|
285
|
+
field
|
|
286
|
+
});
|
|
287
|
+
let key;
|
|
288
|
+
for (key in newColumn) {
|
|
289
|
+
if (newColumn[key] !== undefined && key !== 'field') {
|
|
290
|
+
mergedProps[key] = newColumn[key];
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
columnsState.lookup[field] = resolveProps(existingState, mergedProps);
|
|
289
294
|
});
|
|
290
295
|
if (keepOnlyColumnsToUpsert && !isInsideStateInitializer) {
|
|
291
296
|
Object.keys(columnsState.lookup).forEach(field => {
|
|
@@ -21,8 +21,8 @@ export declare const useGridDataSourceBase: <Api extends GridPrivateApiCommunity
|
|
|
21
21
|
cache: GridDataSourceCache;
|
|
22
22
|
events: {
|
|
23
23
|
strategyAvailabilityChange: GridEventListener<"strategyAvailabilityChange">;
|
|
24
|
-
sortModelChange: (params: unknown) => void;
|
|
25
|
-
filterModelChange: (params: unknown) => void;
|
|
26
|
-
paginationModelChange: (params: unknown) => void;
|
|
24
|
+
sortModelChange: (...params: unknown[]) => void;
|
|
25
|
+
filterModelChange: (...params: unknown[]) => void;
|
|
26
|
+
paginationModelChange: (...params: unknown[]) => void;
|
|
27
27
|
};
|
|
28
28
|
};
|
|
@@ -107,6 +107,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
107
107
|
reason = GridCellEditStartReasons.pasteKeyDown;
|
|
108
108
|
} else if (event.key === 'Enter') {
|
|
109
109
|
reason = GridCellEditStartReasons.enterKeyDown;
|
|
110
|
+
event.preventDefault();
|
|
110
111
|
} else if (event.key === 'Backspace' || event.key === 'Delete') {
|
|
111
112
|
reason = GridCellEditStartReasons.deleteKeyDown;
|
|
112
113
|
}
|
|
@@ -106,7 +106,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
106
106
|
// There is one exception for the checkBoxHeader
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
|
-
if (!isNavigationKey(event.key) && event.key !== 'Tab') {
|
|
109
|
+
if (!isNavigationKey(event.key) && event.key !== 'Tab' && event.key !== 'Enter') {
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -60,6 +60,9 @@ export const gridPaginationRowRangeSelector = createSelectorMemoized(gridPaginat
|
|
|
60
60
|
if (!clientSidePaginationEnabled) {
|
|
61
61
|
return null;
|
|
62
62
|
}
|
|
63
|
+
if (!visibleSortedRowEntries || visibleSortedRowEntries.length === 0) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
63
66
|
const visibleTopLevelRowCount = visibleSortedTopLevelRowEntries.length;
|
|
64
67
|
const topLevelFirstRowIndex = Math.min(paginationModel.pageSize * paginationModel.page, visibleTopLevelRowCount - 1);
|
|
65
68
|
const topLevelLastRowIndex = paginationModel.pageSize === ALL_RESULTS_PAGE_VALUE ? visibleTopLevelRowCount - 1 : Math.min(topLevelFirstRowIndex + paginationModel.pageSize - 1, visibleTopLevelRowCount - 1);
|
|
@@ -20,6 +20,7 @@ import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../internals/constants.js"
|
|
|
20
20
|
import { gridClasses } from "../../../constants/gridClasses.js";
|
|
21
21
|
import { isEventTargetInPortal } from "../../../utils/domUtils.js";
|
|
22
22
|
import { isMultipleRowSelectionEnabled, findRowsToSelect, findRowsToDeselect } from "./utils.js";
|
|
23
|
+
import { runIf } from "../../../utils/utils.js";
|
|
23
24
|
import { createRowSelectionManager } from "../../../models/gridRowSelectionManager.js";
|
|
24
25
|
import { gridPaginatedVisibleSortedGridRowIdsSelector } from "../pagination/index.js";
|
|
25
26
|
const emptyModel = {
|
|
@@ -38,11 +39,6 @@ export const rowSelectionStateInitializer = (state, props) => _extends({}, state
|
|
|
38
39
|
*/
|
|
39
40
|
export const useGridRowSelection = (apiRef, props) => {
|
|
40
41
|
const logger = useGridLogger(apiRef, 'useGridSelection');
|
|
41
|
-
const runIfRowSelectionIsEnabled = React.useCallback(callback => (...args) => {
|
|
42
|
-
if (props.rowSelection) {
|
|
43
|
-
callback(...args);
|
|
44
|
-
}
|
|
45
|
-
}, [props.rowSelection]);
|
|
46
42
|
const isNestedData = useGridSelector(apiRef, gridRowMaximumTreeDepthSelector) > 1;
|
|
47
43
|
const applyAutoSelection = props.signature !== GridSignature.DataGrid && (props.rowSelectionPropagation?.parents || props.rowSelectionPropagation?.descendants) && isNestedData;
|
|
48
44
|
const propRowSelectionModel = React.useMemo(() => {
|
|
@@ -121,6 +117,12 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
121
117
|
if (props.rowSelection === false) {
|
|
122
118
|
return false;
|
|
123
119
|
}
|
|
120
|
+
|
|
121
|
+
// If `keepNonExistentRowsSelected` is true, we might run in a case where row selectability is checked for a row that does not exist.
|
|
122
|
+
// Since that row was previously selected (otherwise it would not be checked at this point), we return true.
|
|
123
|
+
if (props.keepNonExistentRowsSelected && !apiRef.current.getRow(id)) {
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
124
126
|
if (propIsRowSelectable && !propIsRowSelectable(apiRef.current.getRowParams(id))) {
|
|
125
127
|
return false;
|
|
126
128
|
}
|
|
@@ -129,7 +131,7 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
129
131
|
return false;
|
|
130
132
|
}
|
|
131
133
|
return true;
|
|
132
|
-
}, [apiRef, props.rowSelection, propIsRowSelectable]);
|
|
134
|
+
}, [apiRef, props.rowSelection, props.keepNonExistentRowsSelected, propIsRowSelectable]);
|
|
133
135
|
const getSelectedRows = React.useCallback(() => gridRowSelectionIdsSelector(apiRef), [apiRef]);
|
|
134
136
|
const selectRow = React.useCallback((id, isSelected = true, resetSelection = false) => {
|
|
135
137
|
if (!apiRef.current.isRowSelectable(id)) {
|
|
@@ -303,7 +305,7 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
303
305
|
* EVENTS
|
|
304
306
|
*/
|
|
305
307
|
const isFirstRender = React.useRef(true);
|
|
306
|
-
const removeOutdatedSelection = React.useCallback((
|
|
308
|
+
const removeOutdatedSelection = React.useCallback(() => {
|
|
307
309
|
if (isFirstRender.current) {
|
|
308
310
|
return;
|
|
309
311
|
}
|
|
@@ -357,7 +359,7 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
357
359
|
const shouldReapplyPropagation = isNestedData && props.rowSelectionPropagation?.parents && (newSelectionModel.ids.size > 0 ||
|
|
358
360
|
// In case of exclude selection, newSelectionModel.ids.size === 0 means all rows are selected
|
|
359
361
|
newSelectionModel.type === 'exclude');
|
|
360
|
-
if (hasChanged || shouldReapplyPropagation
|
|
362
|
+
if (hasChanged || shouldReapplyPropagation) {
|
|
361
363
|
if (shouldReapplyPropagation) {
|
|
362
364
|
if (newSelectionModel.type === 'exclude') {
|
|
363
365
|
const unfilteredSelectedRowIds = getRowsToBeSelected();
|
|
@@ -540,12 +542,12 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
540
542
|
}
|
|
541
543
|
apiRef.current.setRowSelectionModel(propRowSelectionModel);
|
|
542
544
|
});
|
|
543
|
-
useGridEvent(apiRef, 'filteredRowsSet',
|
|
544
|
-
useGridEvent(apiRef, 'rowClick',
|
|
545
|
-
useGridEvent(apiRef, 'rowSelectionCheckboxChange',
|
|
545
|
+
useGridEvent(apiRef, 'filteredRowsSet', runIf(props.rowSelection, removeOutdatedSelection));
|
|
546
|
+
useGridEvent(apiRef, 'rowClick', runIf(props.rowSelection, handleRowClick));
|
|
547
|
+
useGridEvent(apiRef, 'rowSelectionCheckboxChange', runIf(props.rowSelection, handleRowSelectionCheckboxChange));
|
|
546
548
|
useGridEvent(apiRef, 'headerSelectionCheckboxChange', handleHeaderSelectionCheckboxChange);
|
|
547
|
-
useGridEvent(apiRef, 'cellMouseDown',
|
|
548
|
-
useGridEvent(apiRef, 'cellKeyDown',
|
|
549
|
+
useGridEvent(apiRef, 'cellMouseDown', runIf(props.rowSelection, preventSelectionOnShift));
|
|
550
|
+
useGridEvent(apiRef, 'cellKeyDown', runIf(props.rowSelection, handleCellKeyDown));
|
|
549
551
|
|
|
550
552
|
/*
|
|
551
553
|
* EFFECTS
|
|
@@ -588,8 +590,8 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
588
590
|
}
|
|
589
591
|
}, [apiRef, canHaveMultipleSelection, checkboxSelection, isStateControlled, props.rowSelection]);
|
|
590
592
|
React.useEffect(() => {
|
|
591
|
-
|
|
592
|
-
}, [
|
|
593
|
+
runIf(props.rowSelection, removeOutdatedSelection);
|
|
594
|
+
}, [props.rowSelection, removeOutdatedSelection]);
|
|
593
595
|
React.useEffect(() => {
|
|
594
596
|
if (isFirstRender.current) {
|
|
595
597
|
isFirstRender.current = false;
|
|
@@ -40,7 +40,7 @@ export const checkboxPropsSelector = createSelector(gridColumnDefinitionsSelecto
|
|
|
40
40
|
columns
|
|
41
41
|
};
|
|
42
42
|
let isSelectable = true;
|
|
43
|
-
if (typeof isRowSelectable === 'function') {
|
|
43
|
+
if (typeof isRowSelectable === 'function' && rowsLookup[groupId]) {
|
|
44
44
|
isSelectable = isRowSelectable(rowParams);
|
|
45
45
|
}
|
|
46
46
|
if (!groupNode || groupNode.type !== 'group' || rowSelectionManager.has(groupId)) {
|
|
@@ -63,10 +63,21 @@ export const checkboxPropsSelector = createSelector(gridColumnDefinitionsSelecto
|
|
|
63
63
|
if (node?.type === 'group') {
|
|
64
64
|
node.children.forEach(traverseDescendants);
|
|
65
65
|
}
|
|
66
|
-
if
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
// Check if row is selectable before considering it for parent selection state
|
|
67
|
+
const descendantRowParams = {
|
|
68
|
+
id: itemToTraverseId,
|
|
69
|
+
row: rowsLookup[itemToTraverseId],
|
|
70
|
+
columns
|
|
71
|
+
};
|
|
72
|
+
const rowIsSelectable = typeof isRowSelectable === 'function' && rowsLookup[itemToTraverseId] ? isRowSelectable(descendantRowParams) : true;
|
|
73
|
+
|
|
74
|
+
// Only consider selectable rows when determining parent selection state
|
|
75
|
+
if (rowIsSelectable) {
|
|
76
|
+
if (rowSelectionManager.has(itemToTraverseId)) {
|
|
77
|
+
hasSelectedDescendant = true;
|
|
78
|
+
} else {
|
|
79
|
+
hasUnSelectedDescendant = true;
|
|
80
|
+
}
|
|
70
81
|
}
|
|
71
82
|
};
|
|
72
83
|
traverseDescendants(groupId);
|
|
@@ -126,21 +137,37 @@ export const findRowsToSelect = (apiRef, tree, selectedRow, autoSelectDescendant
|
|
|
126
137
|
}
|
|
127
138
|
if (autoSelectParents) {
|
|
128
139
|
const checkAllDescendantsSelected = rowId => {
|
|
129
|
-
if (!rowSelectionManager.has(rowId) && !selectedDescendants.has(rowId)) {
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
140
|
const node = tree[rowId];
|
|
133
141
|
if (!node) {
|
|
134
142
|
return false;
|
|
135
143
|
}
|
|
144
|
+
// For non-group nodes, check if it's selected or if it's non-selectable
|
|
136
145
|
if (node.type !== 'group') {
|
|
146
|
+
// If the row is selectable, it must be selected
|
|
147
|
+
if (apiRef.current.isRowSelectable(rowId)) {
|
|
148
|
+
return rowSelectionManager.has(rowId) || selectedDescendants.has(rowId);
|
|
149
|
+
}
|
|
150
|
+
// Non-selectable rows don't affect parent selection
|
|
137
151
|
return true;
|
|
138
152
|
}
|
|
153
|
+
// For group nodes, check if it's selected or all its children are selected
|
|
154
|
+
if (rowSelectionManager.has(rowId) || selectedDescendants.has(rowId)) {
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
// Recursively check all children
|
|
139
158
|
return node.children.every(checkAllDescendantsSelected);
|
|
140
159
|
};
|
|
141
160
|
const traverseParents = rowId => {
|
|
142
161
|
const siblings = getFilteredRowNodeSiblings(tree, filteredRows, rowId);
|
|
143
|
-
|
|
162
|
+
// Check if all selectable siblings are selected
|
|
163
|
+
const allSelectableSiblingsSelected = siblings.every(siblingId => {
|
|
164
|
+
// Non-selectable siblings don't affect parent selection
|
|
165
|
+
if (!apiRef.current.isRowSelectable(siblingId)) {
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
return checkAllDescendantsSelected(siblingId);
|
|
169
|
+
});
|
|
170
|
+
if (siblings.length === 0 || allSelectableSiblingsSelected) {
|
|
144
171
|
const rowNode = tree[rowId];
|
|
145
172
|
const parent = rowNode?.parent;
|
|
146
173
|
if (parent != null && parent !== GRID_ROOT_GROUP_ID && apiRef.current.isRowSelectable(parent)) {
|
|
@@ -191,6 +191,7 @@ export const useGridRowSpanning = (apiRef, props) => {
|
|
|
191
191
|
useGridEvent(apiRef, 'paginationModelChange', runIf(props.rowSpanning, resetRowSpanningState));
|
|
192
192
|
useGridEvent(apiRef, 'filteredRowsSet', runIf(props.rowSpanning, resetRowSpanningState));
|
|
193
193
|
useGridEvent(apiRef, 'columnsChange', runIf(props.rowSpanning, resetRowSpanningState));
|
|
194
|
+
useGridEvent(apiRef, 'rowExpansionChange', runIf(props.rowSpanning, resetRowSpanningState));
|
|
194
195
|
React.useEffect(() => {
|
|
195
196
|
const store = apiRef.current.virtualizer?.store;
|
|
196
197
|
if (!store) {
|
package/esm/index.js
CHANGED
package/esm/internals/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { GridHeaders } from "../components/GridHeaders.js";
|
|
|
8
8
|
export { GridToolbar, GridToolbarDivider } from "../components/toolbarV8/GridToolbar.js";
|
|
9
9
|
export type { GridToolbarProps } from "../components/toolbarV8/GridToolbar.js";
|
|
10
10
|
export { GridColumnSortButton } from "../components/GridColumnSortButton.js";
|
|
11
|
+
export { GridFooterCell } from "../components/cell/GridFooterCell.js";
|
|
11
12
|
export { GridBaseColumnHeaders } from "../components/columnHeaders/GridBaseColumnHeaders.js";
|
|
12
13
|
export { DATA_GRID_DEFAULT_SLOTS_COMPONENTS } from "../constants/defaultGridSlotsComponents.js";
|
|
13
14
|
export * from "../constants/signature.js";
|
|
@@ -88,6 +89,7 @@ export { useGridInitializeState } from "../hooks/utils/useGridInitializeState.js
|
|
|
88
89
|
export type { GridStateInitializer } from "../hooks/utils/useGridInitializeState.js";
|
|
89
90
|
export type * as BaseSlots from "../models/gridBaseSlots.js";
|
|
90
91
|
export type * from "../models/props/DataGridProps.js";
|
|
92
|
+
export type { GridAggregationPosition, GridAggregationCellMeta } from "../models/gridAggregation.js";
|
|
91
93
|
export type { GridDataSourceApiBase, GridDataSourceApi, GridDataSourceBaseOptions, GridDataSourceFetchRowsParams } from "../hooks/features/dataSource/models.js";
|
|
92
94
|
export { DataSourceRowsUpdateStrategy } from "../hooks/features/dataSource/utils.js";
|
|
93
95
|
export { useGridDataSourceBase } from "../hooks/features/dataSource/useGridDataSourceBase.js";
|
package/esm/internals/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { GridVirtualScrollerRenderZone } from "../components/virtualization/Grid
|
|
|
4
4
|
export { GridHeaders } from "../components/GridHeaders.js";
|
|
5
5
|
export { GridToolbar, GridToolbarDivider } from "../components/toolbarV8/GridToolbar.js";
|
|
6
6
|
export { GridColumnSortButton } from "../components/GridColumnSortButton.js";
|
|
7
|
+
export { GridFooterCell } from "../components/cell/GridFooterCell.js";
|
|
7
8
|
export { GridBaseColumnHeaders } from "../components/columnHeaders/GridBaseColumnHeaders.js";
|
|
8
9
|
export { DATA_GRID_DEFAULT_SLOTS_COMPONENTS } from "../constants/defaultGridSlotsComponents.js";
|
|
9
10
|
export * from "../constants/signature.js";
|
package/esm/locales/ptPT.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Localization } from "../utils/getGridLocalization.js";
|
|
2
|
+
export declare const ptPT: Localization;
|