@mui/x-data-grid 7.22.0 → 7.22.1
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 +62 -0
- package/components/GridRow.js +1 -1
- package/components/cell/GridBooleanCell.js +2 -1
- package/components/virtualization/GridVirtualScrollbar.js +1 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -2
- package/hooks/features/focus/useGridFocus.js +1 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +3 -4
- package/hooks/features/listView/useGridListView.d.ts +1 -1
- package/hooks/features/listView/useGridListView.js +8 -2
- package/hooks/features/rowSelection/useGridRowSelection.js +1 -1
- package/hooks/features/rows/useGridRowSpanning.js +3 -1
- package/hooks/features/scroll/useGridScroll.js +3 -7
- package/hooks/features/virtualization/useGridVirtualScroller.js +1 -1
- package/index.js +1 -1
- package/internals/constants.d.ts +3 -0
- package/internals/constants.js +3 -0
- package/internals/index.d.ts +1 -0
- package/internals/index.js +2 -1
- package/internals/utils/gridRowGroupingUtils.d.ts +2 -0
- package/internals/utils/gridRowGroupingUtils.js +9 -0
- package/internals/utils/index.d.ts +1 -0
- package/internals/utils/index.js +2 -1
- package/modern/components/GridRow.js +1 -1
- package/modern/components/cell/GridBooleanCell.js +2 -1
- package/modern/components/virtualization/GridVirtualScrollbar.js +1 -1
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -2
- package/modern/hooks/features/focus/useGridFocus.js +1 -1
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +3 -4
- package/modern/hooks/features/listView/useGridListView.js +8 -2
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +1 -1
- package/modern/hooks/features/rows/useGridRowSpanning.js +3 -1
- package/modern/hooks/features/scroll/useGridScroll.js +3 -7
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/constants.js +3 -0
- package/modern/internals/index.js +2 -1
- package/modern/internals/utils/gridRowGroupingUtils.js +9 -0
- package/modern/internals/utils/index.js +2 -1
- package/node/components/GridRow.js +2 -2
- package/node/components/cell/GridBooleanCell.js +2 -1
- package/node/components/virtualization/GridVirtualScrollbar.js +1 -1
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -2
- package/node/hooks/features/focus/useGridFocus.js +1 -1
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +4 -5
- package/node/hooks/features/listView/useGridListView.js +8 -2
- package/node/hooks/features/rowSelection/useGridRowSelection.js +2 -2
- package/node/hooks/features/rows/useGridRowSpanning.js +3 -1
- package/node/hooks/features/scroll/useGridScroll.js +3 -7
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/constants.js +9 -0
- package/node/internals/index.js +12 -0
- package/node/internals/utils/gridRowGroupingUtils.js +17 -0
- package/node/internals/utils/index.js +11 -0
- package/package.json +1 -1
- package/constants/gridDetailPanelToggleField.d.ts +0 -1
- package/constants/gridDetailPanelToggleField.js +0 -2
- package/modern/constants/gridDetailPanelToggleField.js +0 -2
- package/node/constants/gridDetailPanelToggleField.js +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,68 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 7.22.1
|
|
7
|
+
|
|
8
|
+
_Nov 1, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 7 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🐞 Bugfixes
|
|
13
|
+
- 📚 Documentation improvements
|
|
14
|
+
- 🌍 Improve Polish (pl-PL) locale on the Date Pickers
|
|
15
|
+
|
|
16
|
+
Special thanks go out to the community contributors who have helped make this release possible:
|
|
17
|
+
@wojtkolos, @dpak-maurya, @k-rajat19.
|
|
18
|
+
Following are all team members who have contributed to this release:
|
|
19
|
+
@LukasTy, @arminmeh, @MBilalShafi, @KenanYusuf, @flaviendelangle.
|
|
20
|
+
|
|
21
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
22
|
+
|
|
23
|
+
### Data Grid
|
|
24
|
+
|
|
25
|
+
#### `@mui/x-data-grid@7.22.1`
|
|
26
|
+
|
|
27
|
+
- [DataGrid] Fix right column group header border (#15152) @KenanYusuf
|
|
28
|
+
- [DataGrid] Fix scroll jump when holding down arrow keys (#15167) @arminmeh
|
|
29
|
+
- [DataGrid] Move `rowGroupingModelChange` handler to respective hook (#15127) @MBilalShafi
|
|
30
|
+
- [DataGrid] Prevent error when deleting the last row (#15153) @dpak-maurya
|
|
31
|
+
- [DataGrid] Fix overlay height in autoHeight mode (#15205) @cherniavskii
|
|
32
|
+
|
|
33
|
+
#### `@mui/x-data-grid-pro@7.22.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
34
|
+
|
|
35
|
+
Same changes as in `@mui/x-data-grid@7.22.1`, plus:
|
|
36
|
+
|
|
37
|
+
- [DataGridPro] Add list view tests (#15166) @KenanYusuf
|
|
38
|
+
|
|
39
|
+
#### `@mui/x-data-grid-premium@7.22.1` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
40
|
+
|
|
41
|
+
- [DataGridPremium] Keep focus on the grouping cell on space bar press #15155 @k-rajat19
|
|
42
|
+
|
|
43
|
+
### Date and Time Pickers
|
|
44
|
+
|
|
45
|
+
#### `@mui/x-date-pickers@7.22.1`
|
|
46
|
+
|
|
47
|
+
- [l10n] Improve Polish (pl-PL) locale (#15177) @wojtkolos
|
|
48
|
+
|
|
49
|
+
#### `@mui/x-date-pickers-pro@7.22.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
50
|
+
|
|
51
|
+
Same changes as in `@mui/x-date-pickers@7.22.1`.
|
|
52
|
+
|
|
53
|
+
### Tree View
|
|
54
|
+
|
|
55
|
+
#### `@mui/x-tree-view@7.22.1`
|
|
56
|
+
|
|
57
|
+
- [TreeView] Export `TreeItem2DragAndDropOverlay` and `TreeItem2LabelInput` from the root of each package (#15208) @flaviendelangle
|
|
58
|
+
- [TreeView] Fix drag and drop color usage (#15149) @LukasTy
|
|
59
|
+
|
|
60
|
+
#### `@mui/x-tree-view-pro@7.22.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
61
|
+
|
|
62
|
+
Same changes as in `@mui/x-tree-view@7.22.1`.
|
|
63
|
+
|
|
64
|
+
### Docs
|
|
65
|
+
|
|
66
|
+
- [docs] Add section explaining how to keep the selection while filtering in Data grid docs (#15199) @arminmeh
|
|
67
|
+
|
|
6
68
|
## 7.22.0
|
|
7
69
|
|
|
8
70
|
_Oct 25, 2024_
|
package/components/GridRow.js
CHANGED
|
@@ -16,7 +16,7 @@ import { useGridVisibleRows } from "../hooks/utils/useGridVisibleRows.js";
|
|
|
16
16
|
import { findParentElementFromClassName, isEventTargetInPortal } from "../utils/domUtils.js";
|
|
17
17
|
import { GRID_CHECKBOX_SELECTION_COL_DEF } from "../colDef/gridCheckboxSelectionColDef.js";
|
|
18
18
|
import { GRID_ACTIONS_COLUMN_TYPE } from "../colDef/gridActionsColDef.js";
|
|
19
|
-
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../constants
|
|
19
|
+
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../internals/constants.js";
|
|
20
20
|
import { gridSortModelSelector } from "../hooks/features/sorting/gridSortingSelector.js";
|
|
21
21
|
import { gridRowMaximumTreeDepthSelector } from "../hooks/features/rows/gridRowsSelector.js";
|
|
22
22
|
import { gridEditRowsStateSelector } from "../hooks/features/editing/gridEditingSelectors.js";
|
|
@@ -10,6 +10,7 @@ import { getDataGridUtilityClass } from "../../constants/gridClasses.js";
|
|
|
10
10
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
11
11
|
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
12
12
|
import { isAutogeneratedRowNode } from "../../hooks/features/rows/gridRowsUtils.js";
|
|
13
|
+
import { GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD } from "../../internals/constants.js";
|
|
13
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
15
|
const useUtilityClasses = ownerState => {
|
|
15
16
|
const {
|
|
@@ -116,7 +117,7 @@ process.env.NODE_ENV !== "production" ? GridBooleanCellRaw.propTypes = {
|
|
|
116
117
|
const GridBooleanCell = /*#__PURE__*/React.memo(GridBooleanCellRaw);
|
|
117
118
|
export { GridBooleanCell };
|
|
118
119
|
export const renderBooleanCell = params => {
|
|
119
|
-
if (params.field !==
|
|
120
|
+
if (params.field !== GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD && isAutogeneratedRowNode(params.rowNode)) {
|
|
120
121
|
return '';
|
|
121
122
|
}
|
|
122
123
|
return /*#__PURE__*/_jsx(GridBooleanCell, _extends({}, params));
|
|
@@ -73,6 +73,7 @@ const GridVirtualScrollbar = /*#__PURE__*/React.forwardRef(function GridVirtualS
|
|
|
73
73
|
if (scroller[propertyScroll] === lastPosition.current) {
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
|
+
lastPosition.current = scroller[propertyScroll];
|
|
76
77
|
if (isLocked.current) {
|
|
77
78
|
isLocked.current = false;
|
|
78
79
|
return;
|
|
@@ -80,7 +81,6 @@ const GridVirtualScrollbar = /*#__PURE__*/React.forwardRef(function GridVirtualS
|
|
|
80
81
|
isLocked.current = true;
|
|
81
82
|
const value = scroller[propertyScroll] / contentSize;
|
|
82
83
|
scrollbar[propertyScroll] = value * scrollbarInnerSize;
|
|
83
|
-
lastPosition.current = scroller[propertyScroll];
|
|
84
84
|
});
|
|
85
85
|
const onScrollbarScroll = useEventCallback(() => {
|
|
86
86
|
const scroller = apiRef.current.virtualScrollerRef.current;
|
|
@@ -223,7 +223,6 @@ export const useGridColumnHeaders = props => {
|
|
|
223
223
|
return null;
|
|
224
224
|
}
|
|
225
225
|
const {
|
|
226
|
-
renderedColumns,
|
|
227
226
|
firstColumnToRender,
|
|
228
227
|
lastColumnToRender
|
|
229
228
|
} = columnsToRender;
|
|
@@ -292,7 +291,7 @@ export const useGridColumnHeaders = props => {
|
|
|
292
291
|
pinnedPosition: pinnedPosition,
|
|
293
292
|
style: style,
|
|
294
293
|
indexInSection: indexInSection,
|
|
295
|
-
sectionLength:
|
|
294
|
+
sectionLength: rowStructure.length,
|
|
296
295
|
gridHasFiller: gridHasFiller
|
|
297
296
|
}, index);
|
|
298
297
|
});
|
|
@@ -335,7 +335,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
335
335
|
paginationMode: props.paginationMode
|
|
336
336
|
});
|
|
337
337
|
const nextRow = currentPage.rows[clamp(lastFocusedRowIndex, 0, currentPage.rows.length - 1)];
|
|
338
|
-
nextRowId = nextRow
|
|
338
|
+
nextRowId = nextRow?.id ?? null;
|
|
339
339
|
}
|
|
340
340
|
apiRef.current.setState(state => _extends({}, state, {
|
|
341
341
|
focus: {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
3
|
+
import { GRID_TREE_DATA_GROUPING_FIELD, GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../internals/constants.js";
|
|
4
|
+
import { isGroupingColumn } from "../../../internals/utils/gridRowGroupingUtils.js";
|
|
3
5
|
import { gridVisibleColumnDefinitionsSelector, gridVisibleColumnFieldsSelector } from "../columns/gridColumnsSelector.js";
|
|
4
6
|
import { useGridLogger } from "../../utils/useGridLogger.js";
|
|
5
7
|
import { useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
|
|
@@ -9,7 +11,6 @@ import { GRID_CHECKBOX_SELECTION_COL_DEF } from "../../../colDef/gridCheckboxSel
|
|
|
9
11
|
import { gridClasses } from "../../../constants/gridClasses.js";
|
|
10
12
|
import { GridCellModes } from "../../../models/gridEditRowModel.js";
|
|
11
13
|
import { isNavigationKey } from "../../../utils/keyboardUtils.js";
|
|
12
|
-
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../constants/gridDetailPanelToggleField.js";
|
|
13
14
|
import { gridFocusColumnGroupHeaderSelector } from "../focus/index.js";
|
|
14
15
|
import { gridColumnGroupsHeaderMaxDepthSelector } from "../columnGrouping/gridColumnGroupsSelector.js";
|
|
15
16
|
import { gridHeaderFilteringEditFieldSelector, gridHeaderFilteringMenuSelector } from "../headerFiltering/gridHeaderFilteringSelectors.js";
|
|
@@ -458,9 +459,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
458
459
|
break;
|
|
459
460
|
}
|
|
460
461
|
const colDef = params.colDef;
|
|
461
|
-
if (colDef &&
|
|
462
|
-
// `GRID_TREE_DATA_GROUPING_FIELD` from the Pro package
|
|
463
|
-
colDef.field === '__tree_data_group__') {
|
|
462
|
+
if (colDef && (colDef.field === GRID_TREE_DATA_GROUPING_FIELD || isGroupingColumn(colDef.field))) {
|
|
464
463
|
break;
|
|
465
464
|
}
|
|
466
465
|
if (!event.shiftKey && rowIndexBefore < lastRowIndexInPage) {
|
|
@@ -7,4 +7,4 @@ export type GridListViewState = (GridListColDef & {
|
|
|
7
7
|
computedWidth: number;
|
|
8
8
|
}) | undefined;
|
|
9
9
|
export declare const listViewStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'unstable_listColumn'>>;
|
|
10
|
-
export declare function useGridListView(apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'unstable_listColumn'>): void;
|
|
10
|
+
export declare function useGridListView(apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'unstable_listView' | 'unstable_listColumn'>): void;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { warnOnce } from '@mui/x-internals/warning';
|
|
3
4
|
import { gridDimensionsSelector } from "../dimensions/index.js";
|
|
4
5
|
import { useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
|
|
5
6
|
export const listViewStateInitializer = (state, props, apiRef) => _extends({}, state, {
|
|
6
|
-
listViewColumn: _extends({}, props.unstable_listColumn, {
|
|
7
|
+
listViewColumn: props.unstable_listColumn ? _extends({}, props.unstable_listColumn, {
|
|
7
8
|
computedWidth: getListColumnWidth(apiRef)
|
|
8
|
-
})
|
|
9
|
+
}) : undefined
|
|
9
10
|
});
|
|
10
11
|
export function useGridListView(apiRef, props) {
|
|
11
12
|
/*
|
|
@@ -48,6 +49,11 @@ export function useGridListView(apiRef, props) {
|
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
}, [apiRef, props.unstable_listColumn]);
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
if (props.unstable_listView && !props.unstable_listColumn) {
|
|
54
|
+
warnOnce(['MUI X: The `unstable_listColumn` prop must be set if `unstable_listView` is enabled.', 'To fix, pass a column definition to the `unstable_listColumn` prop, e.g. `{ field: "example", renderCell: (params) => <div>{params.row.id}</div> }`.', 'For more details, see https://mui.com/x/react-data-grid/list-view/']);
|
|
55
|
+
}
|
|
56
|
+
}, [props.unstable_listView, props.unstable_listColumn]);
|
|
51
57
|
}
|
|
52
58
|
function getListColumnWidth(apiRef) {
|
|
53
59
|
return gridDimensionsSelector(apiRef.current.state).viewportInnerSize.width;
|
|
@@ -13,7 +13,7 @@ import { GRID_CHECKBOX_SELECTION_COL_DEF, GRID_ACTIONS_COLUMN_TYPE } from "../..
|
|
|
13
13
|
import { GridCellModes } from "../../../models/gridEditRowModel.js";
|
|
14
14
|
import { isKeyboardEvent, isNavigationKey } from "../../../utils/keyboardUtils.js";
|
|
15
15
|
import { useGridVisibleRows } from "../../utils/useGridVisibleRows.js";
|
|
16
|
-
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../constants
|
|
16
|
+
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../internals/constants.js";
|
|
17
17
|
import { gridClasses } from "../../../constants/gridClasses.js";
|
|
18
18
|
import { isEventTargetInPortal } from "../../../utils/domUtils.js";
|
|
19
19
|
import { isMultipleRowSelectionEnabled, findRowsToSelect, findRowsToDeselect } from "./utils.js";
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import useLazyRef from '@mui/utils/useLazyRef';
|
|
4
|
+
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../internals/constants.js";
|
|
4
5
|
import { gridVisibleColumnDefinitionsSelector } from "../columns/gridColumnsSelector.js";
|
|
5
6
|
import { useGridVisibleRows } from "../../utils/useGridVisibleRows.js";
|
|
6
7
|
import { gridRenderContextSelector } from "../virtualization/gridVirtualizationSelectors.js";
|
|
7
8
|
import { useGridSelector } from "../../utils/useGridSelector.js";
|
|
8
9
|
import { getUnprocessedRange, isRowRangeUpdated, isRowContextInitialized, getCellValue } from "./gridRowSpanningUtils.js";
|
|
10
|
+
import { GRID_CHECKBOX_SELECTION_FIELD } from "../../../colDef/gridCheckboxSelectionColDef.js";
|
|
9
11
|
const EMPTY_STATE = {
|
|
10
12
|
spannedCells: {},
|
|
11
13
|
hiddenCells: {},
|
|
@@ -15,7 +17,7 @@ const EMPTY_RANGE = {
|
|
|
15
17
|
firstRowIndex: 0,
|
|
16
18
|
lastRowIndex: 0
|
|
17
19
|
};
|
|
18
|
-
const skippedFields = new Set([
|
|
20
|
+
const skippedFields = new Set([GRID_CHECKBOX_SELECTION_FIELD, '__reorder__', GRID_DETAIL_PANEL_TOGGLE_FIELD]);
|
|
19
21
|
/**
|
|
20
22
|
* Default number of rows to process during state initialization to avoid flickering.
|
|
21
23
|
* Number `20` is arbitrarily chosen to be large enough to cover most of the cases without
|
|
@@ -48,8 +48,6 @@ export const useGridScroll = (apiRef, props) => {
|
|
|
48
48
|
const logger = useGridLogger(apiRef, 'useGridScroll');
|
|
49
49
|
const colRef = apiRef.current.columnHeadersContainerRef;
|
|
50
50
|
const virtualScrollerRef = apiRef.current.virtualScrollerRef;
|
|
51
|
-
const virtualScrollbarHorizontalRef = apiRef.current.virtualScrollbarHorizontalRef;
|
|
52
|
-
const virtualScrollbarVerticalRef = apiRef.current.virtualScrollbarVerticalRef;
|
|
53
51
|
const visibleSortedRows = useGridSelector(apiRef, gridExpandedSortedRowEntriesSelector);
|
|
54
52
|
const scrollToIndexes = React.useCallback(params => {
|
|
55
53
|
const dimensions = gridDimensionsSelector(apiRef.current.state);
|
|
@@ -103,20 +101,18 @@ export const useGridScroll = (apiRef, props) => {
|
|
|
103
101
|
return false;
|
|
104
102
|
}, [logger, apiRef, virtualScrollerRef, props.pagination, visibleSortedRows, props.unstable_listView]);
|
|
105
103
|
const scroll = React.useCallback(params => {
|
|
106
|
-
if (virtualScrollerRef.current &&
|
|
104
|
+
if (virtualScrollerRef.current && params.left !== undefined && colRef.current) {
|
|
107
105
|
const direction = isRtl ? -1 : 1;
|
|
108
106
|
colRef.current.scrollLeft = params.left;
|
|
109
107
|
virtualScrollerRef.current.scrollLeft = direction * params.left;
|
|
110
|
-
virtualScrollbarHorizontalRef.current.scrollLeft = direction * params.left;
|
|
111
108
|
logger.debug(`Scrolling left: ${params.left}`);
|
|
112
109
|
}
|
|
113
|
-
if (virtualScrollerRef.current &&
|
|
110
|
+
if (virtualScrollerRef.current && params.top !== undefined) {
|
|
114
111
|
virtualScrollerRef.current.scrollTop = params.top;
|
|
115
|
-
virtualScrollbarVerticalRef.current.scrollTop = params.top;
|
|
116
112
|
logger.debug(`Scrolling top: ${params.top}`);
|
|
117
113
|
}
|
|
118
114
|
logger.debug(`Scrolling, updating container, and viewport`);
|
|
119
|
-
}, [virtualScrollerRef,
|
|
115
|
+
}, [virtualScrollerRef, isRtl, colRef, logger]);
|
|
120
116
|
const getScrollPosition = React.useCallback(() => {
|
|
121
117
|
if (!virtualScrollerRef?.current) {
|
|
122
118
|
return {
|
|
@@ -382,7 +382,7 @@ export const useGridVirtualScroller = () => {
|
|
|
382
382
|
flexShrink: 0
|
|
383
383
|
};
|
|
384
384
|
if (rootProps.autoHeight && currentPage.rows.length === 0) {
|
|
385
|
-
size.
|
|
385
|
+
size.flexBasis = getMinimalContentHeight(apiRef); // Give room to show the overlay when there no rows.
|
|
386
386
|
}
|
|
387
387
|
return size;
|
|
388
388
|
}, [apiRef, columnsTotalWidth, contentHeight, needsHorizontalScrollbar, rootProps.autoHeight, currentPage.rows.length]);
|
package/index.js
CHANGED
package/internals/index.d.ts
CHANGED
|
@@ -92,4 +92,5 @@ export type { GridApiCommunity } from '../models/api/gridApiCommunity';
|
|
|
92
92
|
export type { GridApiCaches } from '../models/gridApiCaches';
|
|
93
93
|
export { serializeCellValue } from '../hooks/features/export/serializers/csvSerializer';
|
|
94
94
|
export * from './utils';
|
|
95
|
+
export * from './constants';
|
|
95
96
|
export type { Localization } from '../utils/getGridLocalization';
|
package/internals/index.js
CHANGED
|
@@ -72,4 +72,5 @@ export * from "../utils/cellBorderUtils.js";
|
|
|
72
72
|
export { useGridPrivateApiContext } from "../hooks/utils/useGridPrivateApiContext.js";
|
|
73
73
|
export * from "../hooks/utils/index.js";
|
|
74
74
|
export { serializeCellValue } from "../hooks/features/export/serializers/csvSerializer.js";
|
|
75
|
-
export * from "./utils/index.js";
|
|
75
|
+
export * from "./utils/index.js";
|
|
76
|
+
export * from "./constants.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD } from "../constants.js";
|
|
2
|
+
export const getRowGroupingCriteriaFromGroupingField = groupingColDefField => {
|
|
3
|
+
const match = groupingColDefField.match(/^__row_group_by_columns_group_(.*)__$/);
|
|
4
|
+
if (!match) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return match[1];
|
|
8
|
+
};
|
|
9
|
+
export const isGroupingColumn = field => field === GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD || getRowGroupingCriteriaFromGroupingField(field) !== null;
|
package/internals/utils/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import { useGridVisibleRows } from "../hooks/utils/useGridVisibleRows.js";
|
|
|
16
16
|
import { findParentElementFromClassName, isEventTargetInPortal } from "../utils/domUtils.js";
|
|
17
17
|
import { GRID_CHECKBOX_SELECTION_COL_DEF } from "../colDef/gridCheckboxSelectionColDef.js";
|
|
18
18
|
import { GRID_ACTIONS_COLUMN_TYPE } from "../colDef/gridActionsColDef.js";
|
|
19
|
-
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../constants
|
|
19
|
+
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../internals/constants.js";
|
|
20
20
|
import { gridSortModelSelector } from "../hooks/features/sorting/gridSortingSelector.js";
|
|
21
21
|
import { gridRowMaximumTreeDepthSelector } from "../hooks/features/rows/gridRowsSelector.js";
|
|
22
22
|
import { gridEditRowsStateSelector } from "../hooks/features/editing/gridEditingSelectors.js";
|
|
@@ -10,6 +10,7 @@ import { getDataGridUtilityClass } from "../../constants/gridClasses.js";
|
|
|
10
10
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
11
11
|
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
12
12
|
import { isAutogeneratedRowNode } from "../../hooks/features/rows/gridRowsUtils.js";
|
|
13
|
+
import { GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD } from "../../internals/constants.js";
|
|
13
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
15
|
const useUtilityClasses = ownerState => {
|
|
15
16
|
const {
|
|
@@ -116,7 +117,7 @@ process.env.NODE_ENV !== "production" ? GridBooleanCellRaw.propTypes = {
|
|
|
116
117
|
const GridBooleanCell = /*#__PURE__*/React.memo(GridBooleanCellRaw);
|
|
117
118
|
export { GridBooleanCell };
|
|
118
119
|
export const renderBooleanCell = params => {
|
|
119
|
-
if (params.field !==
|
|
120
|
+
if (params.field !== GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD && isAutogeneratedRowNode(params.rowNode)) {
|
|
120
121
|
return '';
|
|
121
122
|
}
|
|
122
123
|
return /*#__PURE__*/_jsx(GridBooleanCell, _extends({}, params));
|
|
@@ -73,6 +73,7 @@ const GridVirtualScrollbar = /*#__PURE__*/React.forwardRef(function GridVirtualS
|
|
|
73
73
|
if (scroller[propertyScroll] === lastPosition.current) {
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
|
+
lastPosition.current = scroller[propertyScroll];
|
|
76
77
|
if (isLocked.current) {
|
|
77
78
|
isLocked.current = false;
|
|
78
79
|
return;
|
|
@@ -80,7 +81,6 @@ const GridVirtualScrollbar = /*#__PURE__*/React.forwardRef(function GridVirtualS
|
|
|
80
81
|
isLocked.current = true;
|
|
81
82
|
const value = scroller[propertyScroll] / contentSize;
|
|
82
83
|
scrollbar[propertyScroll] = value * scrollbarInnerSize;
|
|
83
|
-
lastPosition.current = scroller[propertyScroll];
|
|
84
84
|
});
|
|
85
85
|
const onScrollbarScroll = useEventCallback(() => {
|
|
86
86
|
const scroller = apiRef.current.virtualScrollerRef.current;
|
|
@@ -223,7 +223,6 @@ export const useGridColumnHeaders = props => {
|
|
|
223
223
|
return null;
|
|
224
224
|
}
|
|
225
225
|
const {
|
|
226
|
-
renderedColumns,
|
|
227
226
|
firstColumnToRender,
|
|
228
227
|
lastColumnToRender
|
|
229
228
|
} = columnsToRender;
|
|
@@ -292,7 +291,7 @@ export const useGridColumnHeaders = props => {
|
|
|
292
291
|
pinnedPosition: pinnedPosition,
|
|
293
292
|
style: style,
|
|
294
293
|
indexInSection: indexInSection,
|
|
295
|
-
sectionLength:
|
|
294
|
+
sectionLength: rowStructure.length,
|
|
296
295
|
gridHasFiller: gridHasFiller
|
|
297
296
|
}, index);
|
|
298
297
|
});
|
|
@@ -335,7 +335,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
335
335
|
paginationMode: props.paginationMode
|
|
336
336
|
});
|
|
337
337
|
const nextRow = currentPage.rows[clamp(lastFocusedRowIndex, 0, currentPage.rows.length - 1)];
|
|
338
|
-
nextRowId = nextRow
|
|
338
|
+
nextRowId = nextRow?.id ?? null;
|
|
339
339
|
}
|
|
340
340
|
apiRef.current.setState(state => _extends({}, state, {
|
|
341
341
|
focus: {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
3
|
+
import { GRID_TREE_DATA_GROUPING_FIELD, GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../internals/constants.js";
|
|
4
|
+
import { isGroupingColumn } from "../../../internals/utils/gridRowGroupingUtils.js";
|
|
3
5
|
import { gridVisibleColumnDefinitionsSelector, gridVisibleColumnFieldsSelector } from "../columns/gridColumnsSelector.js";
|
|
4
6
|
import { useGridLogger } from "../../utils/useGridLogger.js";
|
|
5
7
|
import { useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
|
|
@@ -9,7 +11,6 @@ import { GRID_CHECKBOX_SELECTION_COL_DEF } from "../../../colDef/gridCheckboxSel
|
|
|
9
11
|
import { gridClasses } from "../../../constants/gridClasses.js";
|
|
10
12
|
import { GridCellModes } from "../../../models/gridEditRowModel.js";
|
|
11
13
|
import { isNavigationKey } from "../../../utils/keyboardUtils.js";
|
|
12
|
-
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../constants/gridDetailPanelToggleField.js";
|
|
13
14
|
import { gridFocusColumnGroupHeaderSelector } from "../focus/index.js";
|
|
14
15
|
import { gridColumnGroupsHeaderMaxDepthSelector } from "../columnGrouping/gridColumnGroupsSelector.js";
|
|
15
16
|
import { gridHeaderFilteringEditFieldSelector, gridHeaderFilteringMenuSelector } from "../headerFiltering/gridHeaderFilteringSelectors.js";
|
|
@@ -458,9 +459,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
458
459
|
break;
|
|
459
460
|
}
|
|
460
461
|
const colDef = params.colDef;
|
|
461
|
-
if (colDef &&
|
|
462
|
-
// `GRID_TREE_DATA_GROUPING_FIELD` from the Pro package
|
|
463
|
-
colDef.field === '__tree_data_group__') {
|
|
462
|
+
if (colDef && (colDef.field === GRID_TREE_DATA_GROUPING_FIELD || isGroupingColumn(colDef.field))) {
|
|
464
463
|
break;
|
|
465
464
|
}
|
|
466
465
|
if (!event.shiftKey && rowIndexBefore < lastRowIndexInPage) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { warnOnce } from '@mui/x-internals/warning';
|
|
3
4
|
import { gridDimensionsSelector } from "../dimensions/index.js";
|
|
4
5
|
import { useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
|
|
5
6
|
export const listViewStateInitializer = (state, props, apiRef) => _extends({}, state, {
|
|
6
|
-
listViewColumn: _extends({}, props.unstable_listColumn, {
|
|
7
|
+
listViewColumn: props.unstable_listColumn ? _extends({}, props.unstable_listColumn, {
|
|
7
8
|
computedWidth: getListColumnWidth(apiRef)
|
|
8
|
-
})
|
|
9
|
+
}) : undefined
|
|
9
10
|
});
|
|
10
11
|
export function useGridListView(apiRef, props) {
|
|
11
12
|
/*
|
|
@@ -48,6 +49,11 @@ export function useGridListView(apiRef, props) {
|
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
}, [apiRef, props.unstable_listColumn]);
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
if (props.unstable_listView && !props.unstable_listColumn) {
|
|
54
|
+
warnOnce(['MUI X: The `unstable_listColumn` prop must be set if `unstable_listView` is enabled.', 'To fix, pass a column definition to the `unstable_listColumn` prop, e.g. `{ field: "example", renderCell: (params) => <div>{params.row.id}</div> }`.', 'For more details, see https://mui.com/x/react-data-grid/list-view/']);
|
|
55
|
+
}
|
|
56
|
+
}, [props.unstable_listView, props.unstable_listColumn]);
|
|
51
57
|
}
|
|
52
58
|
function getListColumnWidth(apiRef) {
|
|
53
59
|
return gridDimensionsSelector(apiRef.current.state).viewportInnerSize.width;
|
|
@@ -13,7 +13,7 @@ import { GRID_CHECKBOX_SELECTION_COL_DEF, GRID_ACTIONS_COLUMN_TYPE } from "../..
|
|
|
13
13
|
import { GridCellModes } from "../../../models/gridEditRowModel.js";
|
|
14
14
|
import { isKeyboardEvent, isNavigationKey } from "../../../utils/keyboardUtils.js";
|
|
15
15
|
import { useGridVisibleRows } from "../../utils/useGridVisibleRows.js";
|
|
16
|
-
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../constants
|
|
16
|
+
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../internals/constants.js";
|
|
17
17
|
import { gridClasses } from "../../../constants/gridClasses.js";
|
|
18
18
|
import { isEventTargetInPortal } from "../../../utils/domUtils.js";
|
|
19
19
|
import { isMultipleRowSelectionEnabled, findRowsToSelect, findRowsToDeselect } from "./utils.js";
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import useLazyRef from '@mui/utils/useLazyRef';
|
|
4
|
+
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../internals/constants.js";
|
|
4
5
|
import { gridVisibleColumnDefinitionsSelector } from "../columns/gridColumnsSelector.js";
|
|
5
6
|
import { useGridVisibleRows } from "../../utils/useGridVisibleRows.js";
|
|
6
7
|
import { gridRenderContextSelector } from "../virtualization/gridVirtualizationSelectors.js";
|
|
7
8
|
import { useGridSelector } from "../../utils/useGridSelector.js";
|
|
8
9
|
import { getUnprocessedRange, isRowRangeUpdated, isRowContextInitialized, getCellValue } from "./gridRowSpanningUtils.js";
|
|
10
|
+
import { GRID_CHECKBOX_SELECTION_FIELD } from "../../../colDef/gridCheckboxSelectionColDef.js";
|
|
9
11
|
const EMPTY_STATE = {
|
|
10
12
|
spannedCells: {},
|
|
11
13
|
hiddenCells: {},
|
|
@@ -15,7 +17,7 @@ const EMPTY_RANGE = {
|
|
|
15
17
|
firstRowIndex: 0,
|
|
16
18
|
lastRowIndex: 0
|
|
17
19
|
};
|
|
18
|
-
const skippedFields = new Set([
|
|
20
|
+
const skippedFields = new Set([GRID_CHECKBOX_SELECTION_FIELD, '__reorder__', GRID_DETAIL_PANEL_TOGGLE_FIELD]);
|
|
19
21
|
/**
|
|
20
22
|
* Default number of rows to process during state initialization to avoid flickering.
|
|
21
23
|
* Number `20` is arbitrarily chosen to be large enough to cover most of the cases without
|
|
@@ -48,8 +48,6 @@ export const useGridScroll = (apiRef, props) => {
|
|
|
48
48
|
const logger = useGridLogger(apiRef, 'useGridScroll');
|
|
49
49
|
const colRef = apiRef.current.columnHeadersContainerRef;
|
|
50
50
|
const virtualScrollerRef = apiRef.current.virtualScrollerRef;
|
|
51
|
-
const virtualScrollbarHorizontalRef = apiRef.current.virtualScrollbarHorizontalRef;
|
|
52
|
-
const virtualScrollbarVerticalRef = apiRef.current.virtualScrollbarVerticalRef;
|
|
53
51
|
const visibleSortedRows = useGridSelector(apiRef, gridExpandedSortedRowEntriesSelector);
|
|
54
52
|
const scrollToIndexes = React.useCallback(params => {
|
|
55
53
|
const dimensions = gridDimensionsSelector(apiRef.current.state);
|
|
@@ -103,20 +101,18 @@ export const useGridScroll = (apiRef, props) => {
|
|
|
103
101
|
return false;
|
|
104
102
|
}, [logger, apiRef, virtualScrollerRef, props.pagination, visibleSortedRows, props.unstable_listView]);
|
|
105
103
|
const scroll = React.useCallback(params => {
|
|
106
|
-
if (virtualScrollerRef.current &&
|
|
104
|
+
if (virtualScrollerRef.current && params.left !== undefined && colRef.current) {
|
|
107
105
|
const direction = isRtl ? -1 : 1;
|
|
108
106
|
colRef.current.scrollLeft = params.left;
|
|
109
107
|
virtualScrollerRef.current.scrollLeft = direction * params.left;
|
|
110
|
-
virtualScrollbarHorizontalRef.current.scrollLeft = direction * params.left;
|
|
111
108
|
logger.debug(`Scrolling left: ${params.left}`);
|
|
112
109
|
}
|
|
113
|
-
if (virtualScrollerRef.current &&
|
|
110
|
+
if (virtualScrollerRef.current && params.top !== undefined) {
|
|
114
111
|
virtualScrollerRef.current.scrollTop = params.top;
|
|
115
|
-
virtualScrollbarVerticalRef.current.scrollTop = params.top;
|
|
116
112
|
logger.debug(`Scrolling top: ${params.top}`);
|
|
117
113
|
}
|
|
118
114
|
logger.debug(`Scrolling, updating container, and viewport`);
|
|
119
|
-
}, [virtualScrollerRef,
|
|
115
|
+
}, [virtualScrollerRef, isRtl, colRef, logger]);
|
|
120
116
|
const getScrollPosition = React.useCallback(() => {
|
|
121
117
|
if (!virtualScrollerRef?.current) {
|
|
122
118
|
return {
|
|
@@ -382,7 +382,7 @@ export const useGridVirtualScroller = () => {
|
|
|
382
382
|
flexShrink: 0
|
|
383
383
|
};
|
|
384
384
|
if (rootProps.autoHeight && currentPage.rows.length === 0) {
|
|
385
|
-
size.
|
|
385
|
+
size.flexBasis = getMinimalContentHeight(apiRef); // Give room to show the overlay when there no rows.
|
|
386
386
|
}
|
|
387
387
|
return size;
|
|
388
388
|
}, [apiRef, columnsTotalWidth, contentHeight, needsHorizontalScrollbar, rootProps.autoHeight, currentPage.rows.length]);
|
package/modern/index.js
CHANGED
|
@@ -72,4 +72,5 @@ export * from "../utils/cellBorderUtils.js";
|
|
|
72
72
|
export { useGridPrivateApiContext } from "../hooks/utils/useGridPrivateApiContext.js";
|
|
73
73
|
export * from "../hooks/utils/index.js";
|
|
74
74
|
export { serializeCellValue } from "../hooks/features/export/serializers/csvSerializer.js";
|
|
75
|
-
export * from "./utils/index.js";
|
|
75
|
+
export * from "./utils/index.js";
|
|
76
|
+
export * from "./constants.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD } from "../constants.js";
|
|
2
|
+
export const getRowGroupingCriteriaFromGroupingField = groupingColDefField => {
|
|
3
|
+
const match = groupingColDefField.match(/^__row_group_by_columns_group_(.*)__$/);
|
|
4
|
+
if (!match) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return match[1];
|
|
8
|
+
};
|
|
9
|
+
export const isGroupingColumn = field => field === GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD || getRowGroupingCriteriaFromGroupingField(field) !== null;
|
|
@@ -23,7 +23,7 @@ var _useGridVisibleRows = require("../hooks/utils/useGridVisibleRows");
|
|
|
23
23
|
var _domUtils = require("../utils/domUtils");
|
|
24
24
|
var _gridCheckboxSelectionColDef = require("../colDef/gridCheckboxSelectionColDef");
|
|
25
25
|
var _gridActionsColDef = require("../colDef/gridActionsColDef");
|
|
26
|
-
var
|
|
26
|
+
var _constants = require("../internals/constants");
|
|
27
27
|
var _gridSortingSelector = require("../hooks/features/sorting/gridSortingSelector");
|
|
28
28
|
var _gridRowsSelector = require("../hooks/features/rows/gridRowsSelector");
|
|
29
29
|
var _gridEditingSelectors = require("../hooks/features/editing/gridEditingSelectors");
|
|
@@ -145,7 +145,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
// User opened a detail panel
|
|
148
|
-
if (field ===
|
|
148
|
+
if (field === _constants.GRID_DETAIL_PANEL_TOGGLE_FIELD) {
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -17,6 +17,7 @@ var _gridClasses = require("../../constants/gridClasses");
|
|
|
17
17
|
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
|
|
18
18
|
var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
|
|
19
19
|
var _gridRowsUtils = require("../../hooks/features/rows/gridRowsUtils");
|
|
20
|
+
var _constants = require("../../internals/constants");
|
|
20
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
22
|
const _excluded = ["id", "value", "formattedValue", "api", "field", "row", "rowNode", "colDef", "cellMode", "isEditable", "hasFocus", "tabIndex", "hideDescendantCount"];
|
|
22
23
|
const useUtilityClasses = ownerState => {
|
|
@@ -123,7 +124,7 @@ process.env.NODE_ENV !== "production" ? GridBooleanCellRaw.propTypes = {
|
|
|
123
124
|
} : void 0;
|
|
124
125
|
const GridBooleanCell = exports.GridBooleanCell = /*#__PURE__*/React.memo(GridBooleanCellRaw);
|
|
125
126
|
const renderBooleanCell = params => {
|
|
126
|
-
if (params.field !==
|
|
127
|
+
if (params.field !== _constants.GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD && (0, _gridRowsUtils.isAutogeneratedRowNode)(params.rowNode)) {
|
|
127
128
|
return '';
|
|
128
129
|
}
|
|
129
130
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridBooleanCell, (0, _extends2.default)({}, params));
|
|
@@ -80,6 +80,7 @@ const GridVirtualScrollbar = exports.GridVirtualScrollbar = /*#__PURE__*/React.f
|
|
|
80
80
|
if (scroller[propertyScroll] === lastPosition.current) {
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
|
+
lastPosition.current = scroller[propertyScroll];
|
|
83
84
|
if (isLocked.current) {
|
|
84
85
|
isLocked.current = false;
|
|
85
86
|
return;
|
|
@@ -87,7 +88,6 @@ const GridVirtualScrollbar = exports.GridVirtualScrollbar = /*#__PURE__*/React.f
|
|
|
87
88
|
isLocked.current = true;
|
|
88
89
|
const value = scroller[propertyScroll] / contentSize;
|
|
89
90
|
scrollbar[propertyScroll] = value * scrollbarInnerSize;
|
|
90
|
-
lastPosition.current = scroller[propertyScroll];
|
|
91
91
|
});
|
|
92
92
|
const onScrollbarScroll = (0, _utils.unstable_useEventCallback)(() => {
|
|
93
93
|
const scroller = apiRef.current.virtualScrollerRef.current;
|
|
@@ -231,7 +231,6 @@ const useGridColumnHeaders = props => {
|
|
|
231
231
|
return null;
|
|
232
232
|
}
|
|
233
233
|
const {
|
|
234
|
-
renderedColumns,
|
|
235
234
|
firstColumnToRender,
|
|
236
235
|
lastColumnToRender
|
|
237
236
|
} = columnsToRender;
|
|
@@ -300,7 +299,7 @@ const useGridColumnHeaders = props => {
|
|
|
300
299
|
pinnedPosition: pinnedPosition,
|
|
301
300
|
style: style,
|
|
302
301
|
indexInSection: indexInSection,
|
|
303
|
-
sectionLength:
|
|
302
|
+
sectionLength: rowStructure.length,
|
|
304
303
|
gridHasFiller: gridHasFiller
|
|
305
304
|
}, index);
|
|
306
305
|
});
|
|
@@ -344,7 +344,7 @@ const useGridFocus = (apiRef, props) => {
|
|
|
344
344
|
paginationMode: props.paginationMode
|
|
345
345
|
});
|
|
346
346
|
const nextRow = currentPage.rows[(0, _utils2.clamp)(lastFocusedRowIndex, 0, currentPage.rows.length - 1)];
|
|
347
|
-
nextRowId = nextRow
|
|
347
|
+
nextRowId = nextRow?.id ?? null;
|
|
348
348
|
}
|
|
349
349
|
apiRef.current.setState(state => (0, _extends2.default)({}, state, {
|
|
350
350
|
focus: {
|
|
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.useGridKeyboardNavigation = void 0;
|
|
8
8
|
var React = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _RtlProvider = require("@mui/system/RtlProvider");
|
|
10
|
+
var _constants = require("../../../internals/constants");
|
|
11
|
+
var _gridRowGroupingUtils = require("../../../internals/utils/gridRowGroupingUtils");
|
|
10
12
|
var _gridColumnsSelector = require("../columns/gridColumnsSelector");
|
|
11
13
|
var _useGridLogger = require("../../utils/useGridLogger");
|
|
12
14
|
var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
|
|
@@ -16,7 +18,6 @@ var _gridCheckboxSelectionColDef = require("../../../colDef/gridCheckboxSelectio
|
|
|
16
18
|
var _gridClasses = require("../../../constants/gridClasses");
|
|
17
19
|
var _gridEditRowModel = require("../../../models/gridEditRowModel");
|
|
18
20
|
var _keyboardUtils = require("../../../utils/keyboardUtils");
|
|
19
|
-
var _gridDetailPanelToggleField = require("../../../constants/gridDetailPanelToggleField");
|
|
20
21
|
var _focus = require("../focus");
|
|
21
22
|
var _gridColumnGroupsSelector = require("../columnGrouping/gridColumnGroupsSelector");
|
|
22
23
|
var _gridHeaderFilteringSelectors = require("../headerFiltering/gridHeaderFilteringSelectors");
|
|
@@ -460,13 +461,11 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
460
461
|
case ' ':
|
|
461
462
|
{
|
|
462
463
|
const field = params.field;
|
|
463
|
-
if (field ===
|
|
464
|
+
if (field === _constants.GRID_DETAIL_PANEL_TOGGLE_FIELD) {
|
|
464
465
|
break;
|
|
465
466
|
}
|
|
466
467
|
const colDef = params.colDef;
|
|
467
|
-
if (colDef &&
|
|
468
|
-
// `GRID_TREE_DATA_GROUPING_FIELD` from the Pro package
|
|
469
|
-
colDef.field === '__tree_data_group__') {
|
|
468
|
+
if (colDef && (colDef.field === _constants.GRID_TREE_DATA_GROUPING_FIELD || (0, _gridRowGroupingUtils.isGroupingColumn)(colDef.field))) {
|
|
470
469
|
break;
|
|
471
470
|
}
|
|
472
471
|
if (!event.shiftKey && rowIndexBefore < lastRowIndexInPage) {
|
|
@@ -9,12 +9,13 @@ exports.listViewStateInitializer = void 0;
|
|
|
9
9
|
exports.useGridListView = useGridListView;
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _warning = require("@mui/x-internals/warning");
|
|
12
13
|
var _dimensions = require("../dimensions");
|
|
13
14
|
var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
|
|
14
15
|
const listViewStateInitializer = (state, props, apiRef) => (0, _extends2.default)({}, state, {
|
|
15
|
-
listViewColumn: (0, _extends2.default)({}, props.unstable_listColumn, {
|
|
16
|
+
listViewColumn: props.unstable_listColumn ? (0, _extends2.default)({}, props.unstable_listColumn, {
|
|
16
17
|
computedWidth: getListColumnWidth(apiRef)
|
|
17
|
-
})
|
|
18
|
+
}) : undefined
|
|
18
19
|
});
|
|
19
20
|
exports.listViewStateInitializer = listViewStateInitializer;
|
|
20
21
|
function useGridListView(apiRef, props) {
|
|
@@ -58,6 +59,11 @@ function useGridListView(apiRef, props) {
|
|
|
58
59
|
});
|
|
59
60
|
}
|
|
60
61
|
}, [apiRef, props.unstable_listColumn]);
|
|
62
|
+
React.useEffect(() => {
|
|
63
|
+
if (props.unstable_listView && !props.unstable_listColumn) {
|
|
64
|
+
(0, _warning.warnOnce)(['MUI X: The `unstable_listColumn` prop must be set if `unstable_listView` is enabled.', 'To fix, pass a column definition to the `unstable_listColumn` prop, e.g. `{ field: "example", renderCell: (params) => <div>{params.row.id}</div> }`.', 'For more details, see https://mui.com/x/react-data-grid/list-view/']);
|
|
65
|
+
}
|
|
66
|
+
}, [props.unstable_listView, props.unstable_listColumn]);
|
|
61
67
|
}
|
|
62
68
|
function getListColumnWidth(apiRef) {
|
|
63
69
|
return (0, _dimensions.gridDimensionsSelector)(apiRef.current.state).viewportInnerSize.width;
|
|
@@ -21,7 +21,7 @@ var _colDef = require("../../../colDef");
|
|
|
21
21
|
var _gridEditRowModel = require("../../../models/gridEditRowModel");
|
|
22
22
|
var _keyboardUtils = require("../../../utils/keyboardUtils");
|
|
23
23
|
var _useGridVisibleRows = require("../../utils/useGridVisibleRows");
|
|
24
|
-
var
|
|
24
|
+
var _constants = require("../../../internals/constants");
|
|
25
25
|
var _gridClasses = require("../../../constants/gridClasses");
|
|
26
26
|
var _domUtils = require("../../../utils/domUtils");
|
|
27
27
|
var _utils = require("./utils");
|
|
@@ -328,7 +328,7 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
328
328
|
// click on checkbox should not trigger row selection
|
|
329
329
|
return;
|
|
330
330
|
}
|
|
331
|
-
if (field ===
|
|
331
|
+
if (field === _constants.GRID_DETAIL_PANEL_TOGGLE_FIELD) {
|
|
332
332
|
// click to open the detail panel should not select the row
|
|
333
333
|
return;
|
|
334
334
|
}
|
|
@@ -9,11 +9,13 @@ exports.useGridRowSpanning = exports.rowSpanningStateInitializer = void 0;
|
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _useLazyRef = _interopRequireDefault(require("@mui/utils/useLazyRef"));
|
|
12
|
+
var _constants = require("../../../internals/constants");
|
|
12
13
|
var _gridColumnsSelector = require("../columns/gridColumnsSelector");
|
|
13
14
|
var _useGridVisibleRows = require("../../utils/useGridVisibleRows");
|
|
14
15
|
var _gridVirtualizationSelectors = require("../virtualization/gridVirtualizationSelectors");
|
|
15
16
|
var _useGridSelector = require("../../utils/useGridSelector");
|
|
16
17
|
var _gridRowSpanningUtils = require("./gridRowSpanningUtils");
|
|
18
|
+
var _gridCheckboxSelectionColDef = require("../../../colDef/gridCheckboxSelectionColDef");
|
|
17
19
|
const EMPTY_STATE = {
|
|
18
20
|
spannedCells: {},
|
|
19
21
|
hiddenCells: {},
|
|
@@ -23,7 +25,7 @@ const EMPTY_RANGE = {
|
|
|
23
25
|
firstRowIndex: 0,
|
|
24
26
|
lastRowIndex: 0
|
|
25
27
|
};
|
|
26
|
-
const skippedFields = new Set([
|
|
28
|
+
const skippedFields = new Set([_gridCheckboxSelectionColDef.GRID_CHECKBOX_SELECTION_FIELD, '__reorder__', _constants.GRID_DETAIL_PANEL_TOGGLE_FIELD]);
|
|
27
29
|
/**
|
|
28
30
|
* Default number of rows to process during state initialization to avoid flickering.
|
|
29
31
|
* Number `20` is arbitrarily chosen to be large enough to cover most of the cases without
|
|
@@ -54,8 +54,6 @@ const useGridScroll = (apiRef, props) => {
|
|
|
54
54
|
const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridScroll');
|
|
55
55
|
const colRef = apiRef.current.columnHeadersContainerRef;
|
|
56
56
|
const virtualScrollerRef = apiRef.current.virtualScrollerRef;
|
|
57
|
-
const virtualScrollbarHorizontalRef = apiRef.current.virtualScrollbarHorizontalRef;
|
|
58
|
-
const virtualScrollbarVerticalRef = apiRef.current.virtualScrollbarVerticalRef;
|
|
59
57
|
const visibleSortedRows = (0, _useGridSelector.useGridSelector)(apiRef, _gridFilterSelector.gridExpandedSortedRowEntriesSelector);
|
|
60
58
|
const scrollToIndexes = React.useCallback(params => {
|
|
61
59
|
const dimensions = (0, _dimensions.gridDimensionsSelector)(apiRef.current.state);
|
|
@@ -109,20 +107,18 @@ const useGridScroll = (apiRef, props) => {
|
|
|
109
107
|
return false;
|
|
110
108
|
}, [logger, apiRef, virtualScrollerRef, props.pagination, visibleSortedRows, props.unstable_listView]);
|
|
111
109
|
const scroll = React.useCallback(params => {
|
|
112
|
-
if (virtualScrollerRef.current &&
|
|
110
|
+
if (virtualScrollerRef.current && params.left !== undefined && colRef.current) {
|
|
113
111
|
const direction = isRtl ? -1 : 1;
|
|
114
112
|
colRef.current.scrollLeft = params.left;
|
|
115
113
|
virtualScrollerRef.current.scrollLeft = direction * params.left;
|
|
116
|
-
virtualScrollbarHorizontalRef.current.scrollLeft = direction * params.left;
|
|
117
114
|
logger.debug(`Scrolling left: ${params.left}`);
|
|
118
115
|
}
|
|
119
|
-
if (virtualScrollerRef.current &&
|
|
116
|
+
if (virtualScrollerRef.current && params.top !== undefined) {
|
|
120
117
|
virtualScrollerRef.current.scrollTop = params.top;
|
|
121
|
-
virtualScrollbarVerticalRef.current.scrollTop = params.top;
|
|
122
118
|
logger.debug(`Scrolling top: ${params.top}`);
|
|
123
119
|
}
|
|
124
120
|
logger.debug(`Scrolling, updating container, and viewport`);
|
|
125
|
-
}, [virtualScrollerRef,
|
|
121
|
+
}, [virtualScrollerRef, isRtl, colRef, logger]);
|
|
126
122
|
const getScrollPosition = React.useCallback(() => {
|
|
127
123
|
if (!virtualScrollerRef?.current) {
|
|
128
124
|
return {
|
|
@@ -393,7 +393,7 @@ const useGridVirtualScroller = () => {
|
|
|
393
393
|
flexShrink: 0
|
|
394
394
|
};
|
|
395
395
|
if (rootProps.autoHeight && currentPage.rows.length === 0) {
|
|
396
|
-
size.
|
|
396
|
+
size.flexBasis = (0, _gridRowsUtils.getMinimalContentHeight)(apiRef); // Give room to show the overlay when there no rows.
|
|
397
397
|
}
|
|
398
398
|
return size;
|
|
399
399
|
}, [apiRef, columnsTotalWidth, contentHeight, needsHorizontalScrollbar, rootProps.autoHeight, currentPage.rows.length]);
|
package/node/index.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GRID_TREE_DATA_GROUPING_FIELD = exports.GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD = exports.GRID_DETAIL_PANEL_TOGGLE_FIELD = void 0;
|
|
7
|
+
const GRID_TREE_DATA_GROUPING_FIELD = exports.GRID_TREE_DATA_GROUPING_FIELD = '__tree_data_group__';
|
|
8
|
+
const GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD = exports.GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD = '__row_group_by_columns_group__';
|
|
9
|
+
const GRID_DETAIL_PANEL_TOGGLE_FIELD = exports.GRID_DETAIL_PANEL_TOGGLE_FIELD = '__detail_panel_toggle__';
|
package/node/internals/index.js
CHANGED
|
@@ -879,4 +879,16 @@ Object.keys(_utils5).forEach(function (key) {
|
|
|
879
879
|
return _utils5[key];
|
|
880
880
|
}
|
|
881
881
|
});
|
|
882
|
+
});
|
|
883
|
+
var _constants = require("./constants");
|
|
884
|
+
Object.keys(_constants).forEach(function (key) {
|
|
885
|
+
if (key === "default" || key === "__esModule") return;
|
|
886
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
887
|
+
if (key in exports && exports[key] === _constants[key]) return;
|
|
888
|
+
Object.defineProperty(exports, key, {
|
|
889
|
+
enumerable: true,
|
|
890
|
+
get: function () {
|
|
891
|
+
return _constants[key];
|
|
892
|
+
}
|
|
893
|
+
});
|
|
882
894
|
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isGroupingColumn = exports.getRowGroupingCriteriaFromGroupingField = void 0;
|
|
7
|
+
var _constants = require("../constants");
|
|
8
|
+
const getRowGroupingCriteriaFromGroupingField = groupingColDefField => {
|
|
9
|
+
const match = groupingColDefField.match(/^__row_group_by_columns_group_(.*)__$/);
|
|
10
|
+
if (!match) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return match[1];
|
|
14
|
+
};
|
|
15
|
+
exports.getRowGroupingCriteriaFromGroupingField = getRowGroupingCriteriaFromGroupingField;
|
|
16
|
+
const isGroupingColumn = field => field === _constants.GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD || getRowGroupingCriteriaFromGroupingField(field) !== null;
|
|
17
|
+
exports.isGroupingColumn = isGroupingColumn;
|
|
@@ -35,4 +35,15 @@ Object.keys(_propValidation).forEach(function (key) {
|
|
|
35
35
|
return _propValidation[key];
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
+
});
|
|
39
|
+
var _gridRowGroupingUtils = require("./gridRowGroupingUtils");
|
|
40
|
+
Object.keys(_gridRowGroupingUtils).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _gridRowGroupingUtils[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _gridRowGroupingUtils[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
38
49
|
});
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const GRID_DETAIL_PANEL_TOGGLE_FIELD = "__detail_panel_toggle__";
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.GRID_DETAIL_PANEL_TOGGLE_FIELD = void 0;
|
|
7
|
-
// Can't import from pro package - hence duplication
|
|
8
|
-
const GRID_DETAIL_PANEL_TOGGLE_FIELD = exports.GRID_DETAIL_PANEL_TOGGLE_FIELD = '__detail_panel_toggle__';
|