@mui/x-data-grid 8.9.1 → 8.10.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 +217 -8
- package/DataGrid/DataGrid.js +5 -0
- package/DataGrid/useDataGridComponent.js +2 -0
- package/colDef/gridCheckboxSelectionColDef.js +1 -0
- package/components/GridDetailPanels.d.ts +2 -2
- package/components/GridFooter.js +1 -1
- package/components/GridPagination.js +4 -3
- package/components/GridPinnedRows.d.ts +2 -2
- package/components/GridRow.js +8 -1
- package/components/cell/GridCell.js +7 -5
- package/components/cell/GridEditSingleSelectCell.js +1 -1
- package/components/columnsManagement/GridColumnsManagement.d.ts +6 -0
- package/components/columnsManagement/GridColumnsManagement.js +17 -5
- package/components/containers/GridRootStyles.d.ts +1 -1
- package/components/toolbarV8/Toolbar.d.ts +1 -1
- package/components/virtualization/GridVirtualScroller.js +5 -5
- package/constants/dataGridPropsDefaultValues.js +1 -0
- package/esm/DataGrid/DataGrid.js +5 -0
- package/esm/DataGrid/useDataGridComponent.js +2 -0
- package/esm/colDef/gridCheckboxSelectionColDef.js +1 -0
- package/esm/components/GridDetailPanels.d.ts +2 -2
- package/esm/components/GridFooter.js +1 -1
- package/esm/components/GridPagination.js +3 -2
- package/esm/components/GridPinnedRows.d.ts +2 -2
- package/esm/components/GridRow.js +8 -1
- package/esm/components/cell/GridCell.js +7 -5
- package/esm/components/cell/GridEditSingleSelectCell.js +1 -1
- package/esm/components/columnsManagement/GridColumnsManagement.d.ts +6 -0
- package/esm/components/columnsManagement/GridColumnsManagement.js +17 -5
- package/esm/components/containers/GridRootStyles.d.ts +1 -1
- package/esm/components/toolbarV8/Toolbar.d.ts +1 -1
- package/esm/components/virtualization/GridVirtualScroller.js +5 -5
- package/esm/constants/dataGridPropsDefaultValues.js +1 -0
- package/esm/hooks/core/useGridVirtualizer.d.ts +9 -0
- package/esm/hooks/core/useGridVirtualizer.js +223 -0
- package/esm/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
- package/esm/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -2
- package/esm/hooks/features/columns/useGridColumnSpanning.js +5 -90
- package/esm/hooks/features/dataSource/models.d.ts +11 -2
- package/esm/hooks/features/dataSource/useGridDataSourceBase.d.ts +1 -1
- package/esm/hooks/features/dataSource/useGridDataSourceBase.js +9 -2
- package/esm/hooks/features/dimensions/useGridDimensions.js +18 -188
- package/esm/hooks/features/editing/useGridRowEditing.js +4 -1
- package/esm/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -1
- package/esm/hooks/features/keyboardNavigation/utils.d.ts +3 -3
- package/esm/hooks/features/keyboardNavigation/utils.js +5 -5
- package/esm/hooks/features/pivoting/gridPivotingInterfaces.d.ts +0 -1
- package/esm/hooks/features/pivoting/gridPivotingSelectors.d.ts +1 -4
- package/esm/hooks/features/pivoting/gridPivotingSelectors.js +1 -2
- package/esm/hooks/features/rowReorder/gridRowReorderInterfaces.d.ts +9 -0
- package/esm/hooks/features/rowReorder/gridRowReorderInterfaces.js +1 -0
- package/esm/hooks/features/rowReorder/gridRowReorderSelector.d.ts +5 -0
- package/esm/hooks/features/rowReorder/gridRowReorderSelector.js +3 -0
- package/esm/hooks/features/rowSelection/useGridRowSelection.js +2 -2
- package/esm/hooks/features/rowSelection/utils.js +5 -0
- package/esm/hooks/features/rows/gridRowsMetaInterfaces.d.ts +2 -8
- package/esm/hooks/features/rows/gridRowsMetaState.d.ts +2 -18
- package/esm/hooks/features/rows/useGridRowAriaAttributes.js +3 -1
- package/esm/hooks/features/rows/useGridRowSpanning.d.ts +2 -12
- package/esm/hooks/features/rows/useGridRowSpanning.js +54 -85
- package/esm/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
- package/esm/hooks/features/rows/useGridRowsMeta.js +17 -187
- package/esm/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +1 -1
- package/esm/hooks/features/virtualization/index.d.ts +1 -0
- package/esm/hooks/features/virtualization/index.js +1 -0
- package/esm/hooks/features/virtualization/useGridVirtualization.d.ts +5 -16
- package/esm/hooks/features/virtualization/useGridVirtualization.js +41 -22
- package/esm/hooks/utils/index.d.ts +1 -1
- package/esm/hooks/utils/index.js +1 -1
- package/esm/hooks/utils/useFirstRender.d.ts +1 -1
- package/esm/hooks/utils/useFirstRender.js +1 -8
- package/esm/index.js +1 -1
- package/esm/internals/index.d.ts +3 -1
- package/esm/internals/index.js +2 -1
- package/esm/internals/utils/getPinnedCellOffset.js +5 -0
- package/esm/locales/frFR.js +18 -21
- package/esm/locales/heIL.js +12 -12
- package/esm/locales/nnNO.js +96 -107
- package/esm/locales/plPL.js +22 -24
- package/esm/material/index.js +2 -2
- package/esm/models/api/gridApiCommon.d.ts +4 -1
- package/esm/models/api/gridColumnSpanning.d.ts +5 -11
- package/esm/models/gridStateCommunity.d.ts +2 -0
- package/esm/models/props/DataGridProps.d.ts +5 -0
- package/esm/utils/roundToDecimalPlaces.d.ts +1 -1
- package/esm/utils/roundToDecimalPlaces.js +1 -3
- package/hooks/core/useGridVirtualizer.d.ts +9 -0
- package/hooks/core/useGridVirtualizer.js +231 -0
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -3
- package/hooks/features/columns/useGridColumnSpanning.js +5 -91
- package/hooks/features/dataSource/models.d.ts +11 -2
- package/hooks/features/dataSource/useGridDataSourceBase.d.ts +1 -1
- package/hooks/features/dataSource/useGridDataSourceBase.js +10 -3
- package/hooks/features/dimensions/useGridDimensions.js +18 -188
- package/hooks/features/editing/useGridRowEditing.js +4 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -1
- package/hooks/features/keyboardNavigation/utils.d.ts +3 -3
- package/hooks/features/keyboardNavigation/utils.js +5 -5
- package/hooks/features/pivoting/gridPivotingInterfaces.d.ts +0 -1
- package/hooks/features/pivoting/gridPivotingSelectors.d.ts +1 -4
- package/hooks/features/pivoting/gridPivotingSelectors.js +2 -3
- package/hooks/features/rowReorder/gridRowReorderInterfaces.d.ts +9 -0
- package/hooks/features/rowReorder/gridRowReorderInterfaces.js +5 -0
- package/hooks/features/rowReorder/gridRowReorderSelector.d.ts +5 -0
- package/hooks/features/rowReorder/gridRowReorderSelector.js +9 -0
- package/hooks/features/rowSelection/useGridRowSelection.js +2 -2
- package/hooks/features/rowSelection/utils.js +5 -0
- package/hooks/features/rows/gridRowsMetaInterfaces.d.ts +2 -8
- package/hooks/features/rows/gridRowsMetaState.d.ts +2 -18
- package/hooks/features/rows/useGridRowAriaAttributes.js +3 -1
- package/hooks/features/rows/useGridRowSpanning.d.ts +2 -12
- package/hooks/features/rows/useGridRowSpanning.js +54 -85
- package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
- package/hooks/features/rows/useGridRowsMeta.js +15 -186
- package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +1 -1
- package/hooks/features/virtualization/index.d.ts +1 -0
- package/hooks/features/virtualization/index.js +12 -0
- package/hooks/features/virtualization/useGridVirtualization.d.ts +5 -16
- package/hooks/features/virtualization/useGridVirtualization.js +42 -24
- package/hooks/utils/index.d.ts +1 -1
- package/hooks/utils/index.js +12 -12
- package/hooks/utils/useFirstRender.d.ts +1 -1
- package/hooks/utils/useFirstRender.js +11 -11
- package/index.js +1 -1
- package/internals/index.d.ts +3 -1
- package/internals/index.js +12 -11
- package/internals/utils/getPinnedCellOffset.js +5 -0
- package/locales/frFR.js +18 -21
- package/locales/heIL.js +12 -12
- package/locales/nnNO.js +96 -107
- package/locales/plPL.js +22 -24
- package/material/index.js +2 -2
- package/models/api/gridApiCommon.d.ts +4 -1
- package/models/api/gridColumnSpanning.d.ts +5 -11
- package/models/gridStateCommunity.d.ts +2 -0
- package/models/props/DataGridProps.d.ts +5 -0
- package/package.json +5 -6
- package/utils/roundToDecimalPlaces.d.ts +1 -1
- package/utils/roundToDecimalPlaces.js +7 -4
- package/esm/hooks/features/rows/gridRowSpanningSelectors.d.ts +0 -10
- package/esm/hooks/features/rows/gridRowSpanningSelectors.js +0 -5
- package/esm/hooks/features/virtualization/useGridVirtualScroller.d.ts +0 -56
- package/esm/hooks/features/virtualization/useGridVirtualScroller.js +0 -843
- package/esm/hooks/utils/useRunOnce.d.ts +0 -5
- package/esm/hooks/utils/useRunOnce.js +0 -18
- package/esm/utils/platform.d.ts +0 -1
- package/esm/utils/platform.js +0 -2
- package/hooks/features/rows/gridRowSpanningSelectors.d.ts +0 -10
- package/hooks/features/rows/gridRowSpanningSelectors.js +0 -11
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +0 -56
- package/hooks/features/virtualization/useGridVirtualScroller.js +0 -854
- package/hooks/utils/useRunOnce.d.ts +0 -5
- package/hooks/utils/useRunOnce.js +0 -27
- package/utils/platform.d.ts +0 -1
- package/utils/platform.js +0 -8
|
@@ -24,6 +24,7 @@ export const GRID_CHECKBOX_SELECTION_COL_DEF = _extends({}, GRID_BOOLEAN_COL_DEF
|
|
|
24
24
|
const rowId = gridRowIdSelector(apiRef, row);
|
|
25
25
|
return apiRef.current.isRowSelected(rowId);
|
|
26
26
|
},
|
|
27
|
+
rowSpanValueGetter: (_, row, column, apiRef) => gridRowIdSelector(apiRef, row),
|
|
27
28
|
renderHeader: params => /*#__PURE__*/_jsx(GridHeaderCheckbox, _extends({}, params)),
|
|
28
29
|
renderCell: params => /*#__PURE__*/_jsx(GridCellCheckboxRenderer, _extends({}, params))
|
|
29
30
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { VirtualScrollerCompat } from '@mui/x-virtualizer';
|
|
2
2
|
export interface GridDetailPanelsProps {
|
|
3
|
-
virtualScroller:
|
|
3
|
+
virtualScroller: VirtualScrollerCompat;
|
|
4
4
|
}
|
|
5
5
|
export declare function GridDetailPanels(_: GridDetailPanelsProps): null;
|
|
@@ -24,7 +24,7 @@ const GridFooter = forwardRef(function GridFooter(props, ref) {
|
|
|
24
24
|
rowCount: totalTopLevelRowCount,
|
|
25
25
|
visibleRowCount: visibleTopLevelRowCount
|
|
26
26
|
})) : null;
|
|
27
|
-
const paginationElement = rootProps.pagination && !rootProps.hideFooterPagination && rootProps.slots.pagination && /*#__PURE__*/_jsx(rootProps.slots.pagination, {});
|
|
27
|
+
const paginationElement = rootProps.pagination && !rootProps.hideFooterPagination && rootProps.slots.pagination && /*#__PURE__*/_jsx(rootProps.slots.pagination, _extends({}, rootProps.slotProps?.pagination));
|
|
28
28
|
return /*#__PURE__*/_jsxs(GridFooterContainer, _extends({}, props, {
|
|
29
29
|
ref: ref,
|
|
30
30
|
children: [selectedRowCountElement, rowCountElement, paginationElement]
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import { styled } from '@mui/material/styles';
|
|
3
4
|
import PropTypes from 'prop-types';
|
|
@@ -59,7 +60,7 @@ function GridPagination() {
|
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
const pageSizeOptions = isPageSizeIncludedInPageSizeOptions(paginationModel.pageSize) ? rootProps.pageSizeOptions : [];
|
|
62
|
-
return /*#__PURE__*/_jsx(GridPaginationRoot, {
|
|
63
|
+
return /*#__PURE__*/_jsx(GridPaginationRoot, _extends({
|
|
63
64
|
as: rootProps.slots.basePagination,
|
|
64
65
|
count: rowCount,
|
|
65
66
|
page: computedPage,
|
|
@@ -68,7 +69,7 @@ function GridPagination() {
|
|
|
68
69
|
onPageChange: handlePageChange,
|
|
69
70
|
onRowsPerPageChange: handlePageSizeChange,
|
|
70
71
|
disabled: disabled
|
|
71
|
-
});
|
|
72
|
+
}, rootProps.slotProps?.basePagination));
|
|
72
73
|
}
|
|
73
74
|
process.env.NODE_ENV !== "production" ? GridPagination.propTypes = {
|
|
74
75
|
// ----------------------------- Warning --------------------------------
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { VirtualScrollerCompat } from '@mui/x-virtualizer';
|
|
2
2
|
export interface GridPinnedRowsProps {
|
|
3
3
|
position: 'top' | 'bottom';
|
|
4
|
-
virtualScroller:
|
|
4
|
+
virtualScroller: VirtualScrollerCompat;
|
|
5
5
|
}
|
|
6
6
|
export declare function GridPinnedRows(_: GridPinnedRowsProps): null;
|
|
@@ -25,6 +25,7 @@ import { GRID_DETAIL_PANEL_TOGGLE_FIELD, PinnedColumnPosition } from "../interna
|
|
|
25
25
|
import { gridSortModelSelector } from "../hooks/features/sorting/gridSortingSelector.js";
|
|
26
26
|
import { gridRowMaximumTreeDepthSelector, gridRowNodeSelector } from "../hooks/features/rows/gridRowsSelector.js";
|
|
27
27
|
import { gridEditRowsStateSelector, gridRowIsEditingSelector } from "../hooks/features/editing/gridEditingSelectors.js";
|
|
28
|
+
import { gridIsRowDragActiveSelector } from "../hooks/features/rowReorder/gridRowReorderSelector.js";
|
|
28
29
|
import { GridScrollbarFillerCell as ScrollbarFiller } from "./GridScrollbarFillerCell.js";
|
|
29
30
|
import { getPinnedCellOffset } from "../internals/utils/getPinnedCellOffset.js";
|
|
30
31
|
import { useGridConfiguration } from "../hooks/utils/useGridConfiguration.js";
|
|
@@ -78,6 +79,7 @@ const GridRow = forwardRef(function GridRow(props, refProp) {
|
|
|
78
79
|
const columnPositions = useGridSelector(apiRef, gridColumnPositionsSelector);
|
|
79
80
|
const rowReordering = rootProps.rowReordering;
|
|
80
81
|
const isRowReorderingEnabled = useGridSelector(apiRef, isRowReorderingEnabledSelector, rowReordering);
|
|
82
|
+
const isRowDragActive = useGridSelector(apiRef, gridIsRowDragActiveSelector);
|
|
81
83
|
const handleRef = useForkRef(ref, refProp);
|
|
82
84
|
const rowNode = gridRowNodeSelector(apiRef, rowId);
|
|
83
85
|
const editing = useGridSelector(apiRef, gridRowIsEditingSelector, {
|
|
@@ -202,6 +204,11 @@ const GridRow = forwardRef(function GridRow(props, refProp) {
|
|
|
202
204
|
});
|
|
203
205
|
rowClassNames.push(rootProps.getRowClassName(rowParams));
|
|
204
206
|
}
|
|
207
|
+
|
|
208
|
+
// XXX: fix this properly
|
|
209
|
+
if (!rowNode) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
205
212
|
const getCell = (column, indexInSection, indexRelativeToAllColumns, sectionLength, pinnedPosition = PinnedColumnPosition.NONE) => {
|
|
206
213
|
const cellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, indexRelativeToAllColumns);
|
|
207
214
|
if (cellColSpanInfo?.spannedByColSpan) {
|
|
@@ -225,7 +232,7 @@ const GridRow = forwardRef(function GridRow(props, refProp) {
|
|
|
225
232
|
const isReorderCell = column.field === '__reorder__';
|
|
226
233
|
const canReorderColumn = !(disableColumnReorder || column.disableReorder);
|
|
227
234
|
const canReorderRow = isRowReorderingEnabled && !sortModel.length && treeDepth <= 1;
|
|
228
|
-
const disableDragEvents = !(canReorderColumn || isReorderCell && canReorderRow);
|
|
235
|
+
const disableDragEvents = !(canReorderColumn || isReorderCell && canReorderRow || isRowDragActive);
|
|
229
236
|
const cellIsNotVisible = pinnedPosition === PinnedColumnPosition.VIRTUAL;
|
|
230
237
|
const showLeftBorder = shouldCellShowLeftBorder(pinnedPosition, indexInSection);
|
|
231
238
|
const showRightBorder = shouldCellShowRightBorder(pinnedPosition, indexInSection, sectionLength, rootProps.showCellVerticalBorder, gridHasFiller);
|
|
@@ -14,6 +14,8 @@ import capitalize from '@mui/utils/capitalize';
|
|
|
14
14
|
import { fastMemo } from '@mui/x-internals/fastMemo';
|
|
15
15
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
16
16
|
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
17
|
+
import { useStore } from '@mui/x-internals/store';
|
|
18
|
+
import { Rowspan } from '@mui/x-virtualizer';
|
|
17
19
|
import { doesSupportPreventScroll } from "../../utils/doesSupportPreventScroll.js";
|
|
18
20
|
import { getDataGridUtilityClass, gridClasses } from "../../constants/gridClasses.js";
|
|
19
21
|
import { GridCellModes } from "../../models/index.js";
|
|
@@ -22,7 +24,6 @@ import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
|
22
24
|
import { gridFocusCellSelector, gridTabIndexCellSelector } from "../../hooks/features/focus/gridFocusStateSelector.js";
|
|
23
25
|
import { GridPinnedColumnPosition } from "../../hooks/features/columns/gridColumnsInterfaces.js";
|
|
24
26
|
import { PinnedColumnPosition } from "../../internals/constants.js";
|
|
25
|
-
import { gridRowSpanningHiddenCellsSelector, gridRowSpanningSpannedCellsSelector } from "../../hooks/features/rows/gridRowSpanningSelectors.js";
|
|
26
27
|
import { useGridPrivateApiContext } from "../../hooks/utils/useGridPrivateApiContext.js";
|
|
27
28
|
import { gridEditCellStateSelector } from "../../hooks/features/editing/gridEditingSelectors.js";
|
|
28
29
|
import { attachPinnedStyle } from "../../internals/utils/index.js";
|
|
@@ -116,8 +117,9 @@ const GridCell = forwardRef(function GridCell(props, ref) {
|
|
|
116
117
|
id: rowId,
|
|
117
118
|
field
|
|
118
119
|
}));
|
|
119
|
-
const
|
|
120
|
-
const
|
|
120
|
+
const store = apiRef.current.virtualizer.store;
|
|
121
|
+
const hiddenCells = useStore(store, Rowspan.selectors.hiddenCells);
|
|
122
|
+
const spannedCells = useStore(store, Rowspan.selectors.spannedCells);
|
|
121
123
|
const {
|
|
122
124
|
hasFocus,
|
|
123
125
|
isEditable = false,
|
|
@@ -186,8 +188,8 @@ const GridCell = forwardRef(function GridCell(props, ref) {
|
|
|
186
188
|
propHandler(event);
|
|
187
189
|
}
|
|
188
190
|
}, [apiRef, field, rowId]);
|
|
189
|
-
const isCellRowSpanned = hiddenCells[rowId]?.[
|
|
190
|
-
const rowSpan = spannedCells[rowId]?.[
|
|
191
|
+
const isCellRowSpanned = hiddenCells[rowId]?.[colIndex] ?? false;
|
|
192
|
+
const rowSpan = spannedCells[rowId]?.[colIndex] ?? 1;
|
|
191
193
|
const style = React.useMemo(() => {
|
|
192
194
|
if (isNotVisible) {
|
|
193
195
|
return {
|
|
@@ -14,7 +14,7 @@ import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
|
14
14
|
import { createElement as _createElement } from "react";
|
|
15
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
16
|
function isKeyboardEvent(event) {
|
|
17
|
-
return !!event.key;
|
|
17
|
+
return 'key' in event && !!event.key;
|
|
18
18
|
}
|
|
19
19
|
function GridEditSingleSelectCell(props) {
|
|
20
20
|
const rootProps = useGridRootProps();
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { TextFieldProps } from "../../models/gridBaseSlots.js";
|
|
3
|
+
import type { DataGridProcessedProps } from "../../models/props/DataGridProps.js";
|
|
3
4
|
import type { GridColDef } from "../../models/colDef/gridColDef.js";
|
|
4
5
|
export interface GridColumnsManagementProps {
|
|
5
6
|
sort?: 'asc' | 'desc';
|
|
6
7
|
searchPredicate?: (column: GridColDef, searchValue: string) => boolean;
|
|
7
8
|
searchInputProps?: Partial<TextFieldProps>;
|
|
9
|
+
/**
|
|
10
|
+
* The milliseconds delay to wait after a keystroke before triggering filtering in the columns menu.
|
|
11
|
+
* @default 150
|
|
12
|
+
*/
|
|
13
|
+
searchDebounceMs?: DataGridProcessedProps['columnFilterDebounceMs'];
|
|
8
14
|
/**
|
|
9
15
|
* If `true`, the column search field will be focused automatically.
|
|
10
16
|
* If `false`, the first column switch input will be focused automatically.
|
|
@@ -5,6 +5,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import composeClasses from '@mui/utils/composeClasses';
|
|
8
|
+
import debounce from '@mui/utils/debounce';
|
|
8
9
|
import { styled } from '@mui/material/styles';
|
|
9
10
|
import { inputBaseClasses } from '@mui/material/InputBase';
|
|
10
11
|
import { vars } from "../../constants/cssVariables.js";
|
|
@@ -52,8 +53,12 @@ function GridColumnsManagement(props) {
|
|
|
52
53
|
disableResetButton = false,
|
|
53
54
|
toggleAllMode = 'all',
|
|
54
55
|
getTogglableColumns,
|
|
55
|
-
searchInputProps
|
|
56
|
+
searchInputProps,
|
|
57
|
+
searchDebounceMs = rootProps.columnFilterDebounceMs
|
|
56
58
|
} = props;
|
|
59
|
+
const debouncedFilter = React.useMemo(() => debounce(value => {
|
|
60
|
+
setSearchValue(value);
|
|
61
|
+
}, searchDebounceMs ?? 150), [searchDebounceMs]);
|
|
57
62
|
const isResetDisabled = React.useMemo(() => checkColumnVisibilityModelsSame(columnVisibilityModel, initialColumnVisibilityModel), [columnVisibilityModel, initialColumnVisibilityModel]);
|
|
58
63
|
const sortedColumns = React.useMemo(() => {
|
|
59
64
|
switch (sort) {
|
|
@@ -98,8 +103,8 @@ function GridColumnsManagement(props) {
|
|
|
98
103
|
return apiRef.current.setColumnVisibilityModel(newModel);
|
|
99
104
|
}, [apiRef, columns, getTogglableColumns, toggleAllMode, currentColumns]);
|
|
100
105
|
const handleSearchValueChange = React.useCallback(event => {
|
|
101
|
-
|
|
102
|
-
}, []);
|
|
106
|
+
debouncedFilter(event.target.value);
|
|
107
|
+
}, [debouncedFilter]);
|
|
103
108
|
const hideableColumns = React.useMemo(() => currentColumns.filter(col => col.hideable), [currentColumns]);
|
|
104
109
|
const allHideableColumnsVisible = React.useMemo(() => hideableColumns.every(column => columnVisibilityModel[column.field] == null || columnVisibilityModel[column.field] !== false), [columnVisibilityModel, hideableColumns]);
|
|
105
110
|
const allHideableColumnsHidden = React.useMemo(() => hideableColumns.every(column => columnVisibilityModel[column.field] === false), [columnVisibilityModel, hideableColumns]);
|
|
@@ -121,7 +126,10 @@ function GridColumnsManagement(props) {
|
|
|
121
126
|
};
|
|
122
127
|
const handleSearchReset = React.useCallback(() => {
|
|
123
128
|
setSearchValue('');
|
|
124
|
-
searchInputRef.current
|
|
129
|
+
if (searchInputRef.current) {
|
|
130
|
+
searchInputRef.current.value = '';
|
|
131
|
+
searchInputRef.current.focus();
|
|
132
|
+
}
|
|
125
133
|
}, []);
|
|
126
134
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
127
135
|
children: [/*#__PURE__*/_jsx(GridColumnsManagementHeader, {
|
|
@@ -133,7 +141,6 @@ function GridColumnsManagement(props) {
|
|
|
133
141
|
placeholder: apiRef.current.getLocaleText('columnsManagementSearchTitle'),
|
|
134
142
|
inputRef: searchInputRef,
|
|
135
143
|
className: classes.searchInput,
|
|
136
|
-
value: searchValue,
|
|
137
144
|
onChange: handleSearchValueChange,
|
|
138
145
|
size: "small",
|
|
139
146
|
type: "search",
|
|
@@ -236,6 +243,11 @@ process.env.NODE_ENV !== "production" ? GridColumnsManagement.propTypes = {
|
|
|
236
243
|
* @returns {GridColDef['field'][]} The list of togglable columns' field names.
|
|
237
244
|
*/
|
|
238
245
|
getTogglableColumns: PropTypes.func,
|
|
246
|
+
/**
|
|
247
|
+
* The milliseconds delay to wait after a keystroke before triggering filtering in the columns menu.
|
|
248
|
+
* @default 150
|
|
249
|
+
*/
|
|
250
|
+
searchDebounceMs: PropTypes.number,
|
|
239
251
|
searchInputProps: PropTypes.object,
|
|
240
252
|
searchPredicate: PropTypes.func,
|
|
241
253
|
sort: PropTypes.oneOf(['asc', 'desc']),
|
|
@@ -2,4 +2,4 @@ import { DataGridProcessedProps } from "../../models/props/DataGridProps.js";
|
|
|
2
2
|
export type OwnerState = DataGridProcessedProps;
|
|
3
3
|
export declare const GridRootStyles: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
4
4
|
ownerState: OwnerState;
|
|
5
|
-
}, Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("react").
|
|
5
|
+
}, Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("react").ClassAttributes<HTMLDivElement> | keyof import("react").HTMLAttributes<HTMLDivElement>>, {}>;
|
|
@@ -6,7 +6,7 @@ export type ToolbarProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
6
6
|
*/
|
|
7
7
|
render?: RenderProp<React.ComponentProps<typeof ToolbarRoot>>;
|
|
8
8
|
};
|
|
9
|
-
declare const ToolbarRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/system").Theme>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.
|
|
9
|
+
declare const ToolbarRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/system").Theme>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
10
10
|
/**
|
|
11
11
|
* The top level Toolbar component that provides context to child components.
|
|
12
12
|
* It renders a styled `<div />` element.
|
|
@@ -3,12 +3,12 @@ import * as React from 'react';
|
|
|
3
3
|
import { styled } from '@mui/system';
|
|
4
4
|
import composeClasses from '@mui/utils/composeClasses';
|
|
5
5
|
import { gridHasBottomFillerSelector, gridHasScrollXSelector, gridHasScrollYSelector } from "../../hooks/features/dimensions/gridDimensionsSelectors.js";
|
|
6
|
+
import { gridRowTreeSelector } from "../../hooks/features/rows/index.js";
|
|
6
7
|
import { GridScrollArea } from "../GridScrollArea.js";
|
|
7
8
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
8
|
-
import {
|
|
9
|
+
import { useGridPrivateApiContext } from "../../hooks/utils/useGridPrivateApiContext.js";
|
|
9
10
|
import { useGridSelector } from "../../hooks/utils/useGridSelector.js";
|
|
10
11
|
import { getDataGridUtilityClass } from "../../constants/gridClasses.js";
|
|
11
|
-
import { useGridVirtualScroller } from "../../hooks/features/virtualization/useGridVirtualScroller.js";
|
|
12
12
|
import { useGridOverlays } from "../../hooks/features/overlays/useGridOverlays.js";
|
|
13
13
|
import { GridHeaders } from "../GridHeaders.js";
|
|
14
14
|
import { GridMainContainer as Container } from "./GridMainContainer.js";
|
|
@@ -61,7 +61,7 @@ const Scroller = styled('div', {
|
|
|
61
61
|
});
|
|
62
62
|
const hasPinnedRightSelector = apiRef => apiRef.current.state.dimensions.rightPinnedWidth > 0;
|
|
63
63
|
function GridVirtualScroller(props) {
|
|
64
|
-
const apiRef =
|
|
64
|
+
const apiRef = useGridPrivateApiContext();
|
|
65
65
|
const rootProps = useGridRootProps();
|
|
66
66
|
const hasScrollY = useGridSelector(apiRef, gridHasScrollYSelector);
|
|
67
67
|
const hasScrollX = useGridSelector(apiRef, gridHasScrollXSelector);
|
|
@@ -77,7 +77,7 @@ function GridVirtualScroller(props) {
|
|
|
77
77
|
hasPinnedRight
|
|
78
78
|
}, overlaysProps);
|
|
79
79
|
const classes = useUtilityClasses(ownerState);
|
|
80
|
-
const virtualScroller =
|
|
80
|
+
const virtualScroller = apiRef.current.virtualizer.api.useVirtualization().getters;
|
|
81
81
|
const {
|
|
82
82
|
getContainerProps,
|
|
83
83
|
getScrollerProps,
|
|
@@ -88,7 +88,7 @@ function GridVirtualScroller(props) {
|
|
|
88
88
|
getRows,
|
|
89
89
|
getScrollAreaProps
|
|
90
90
|
} = virtualScroller;
|
|
91
|
-
const rows = getRows();
|
|
91
|
+
const rows = getRows(undefined, gridRowTreeSelector(apiRef));
|
|
92
92
|
return /*#__PURE__*/_jsxs(Container, _extends({
|
|
93
93
|
className: classes.root
|
|
94
94
|
}, getContainerProps(), {
|
|
@@ -10,6 +10,7 @@ export const DATA_GRID_PROPS_DEFAULT_VALUES = {
|
|
|
10
10
|
checkboxSelectionVisibleOnly: false,
|
|
11
11
|
clipboardCopyCellDelimiter: '\t',
|
|
12
12
|
columnBufferPx: 150,
|
|
13
|
+
columnFilterDebounceMs: 150,
|
|
13
14
|
columnHeaderHeight: 56,
|
|
14
15
|
disableAutosize: false,
|
|
15
16
|
disableColumnFilter: false,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
+
import { GridPrivateApiCommunity } from "../../models/api/gridApiCommunity.js";
|
|
3
|
+
import { DataGridProcessedProps } from "../../models/props/DataGridProps.js";
|
|
4
|
+
type RootProps = DataGridProcessedProps;
|
|
5
|
+
/**
|
|
6
|
+
* Virtualizer setup
|
|
7
|
+
*/
|
|
8
|
+
export declare function useGridVirtualizer(apiRef: RefObject<GridPrivateApiCommunity>, rootProps: RootProps): void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
4
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
5
|
+
import { roundToDecimalPlaces } from '@mui/x-internals/math';
|
|
6
|
+
import { useStoreEffect } from '@mui/x-internals/store';
|
|
7
|
+
import { useVirtualizer } from '@mui/x-virtualizer';
|
|
8
|
+
import { useFirstRender } from "../utils/useFirstRender.js";
|
|
9
|
+
import { createSelector } from "../../utils/createSelector.js";
|
|
10
|
+
import { useGridSelector } from "../utils/useGridSelector.js";
|
|
11
|
+
import { gridContentHeightSelector, gridHasFillerSelector, gridVerticalScrollbarWidthSelector } from "../features/dimensions/gridDimensionsSelectors.js";
|
|
12
|
+
import { gridDensityFactorSelector } from "../features/density/index.js";
|
|
13
|
+
import { gridVisibleColumnDefinitionsSelector, gridVisiblePinnedColumnDefinitionsSelector, gridColumnPositionsSelector, gridHasColSpanSelector } from "../features/columns/gridColumnsSelector.js";
|
|
14
|
+
import { gridPinnedRowsSelector, gridRowCountSelector } from "../features/rows/gridRowsSelector.js";
|
|
15
|
+
import { useGridVisibleRows } from "../utils/useGridVisibleRows.js";
|
|
16
|
+
import { gridPaginationSelector } from "../features/pagination/index.js";
|
|
17
|
+
import { gridFocusedVirtualCellSelector } from "../features/virtualization/gridFocusedVirtualCellSelector.js";
|
|
18
|
+
import { gridRowSelectionManagerSelector } from "../features/rowSelection/index.js";
|
|
19
|
+
import { DATA_GRID_PROPS_DEFAULT_VALUES } from "../../constants/dataGridPropsDefaultValues.js";
|
|
20
|
+
import { getValidRowHeight, minimalContentHeight, rowHeightWarning } from "../features/rows/gridRowsUtils.js";
|
|
21
|
+
import { getTotalHeaderHeight } from "../features/columns/gridColumnsUtils.js";
|
|
22
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
+
function identity(x) {
|
|
24
|
+
return x;
|
|
25
|
+
}
|
|
26
|
+
const columnsTotalWidthSelector = createSelector(gridVisibleColumnDefinitionsSelector, gridColumnPositionsSelector, (visibleColumns, positions) => {
|
|
27
|
+
const colCount = visibleColumns.length;
|
|
28
|
+
if (colCount === 0) {
|
|
29
|
+
return 0;
|
|
30
|
+
}
|
|
31
|
+
return roundToDecimalPlaces(positions[colCount - 1] + visibleColumns[colCount - 1].computedWidth, 1);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Virtualizer setup
|
|
36
|
+
*/
|
|
37
|
+
export function useGridVirtualizer(apiRef, rootProps) {
|
|
38
|
+
const isRtl = useRtl();
|
|
39
|
+
const {
|
|
40
|
+
listView
|
|
41
|
+
} = rootProps;
|
|
42
|
+
const visibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
|
|
43
|
+
const pinnedRows = useGridSelector(apiRef, gridPinnedRowsSelector);
|
|
44
|
+
const pinnedColumns = gridVisiblePinnedColumnDefinitionsSelector(apiRef);
|
|
45
|
+
const rowSelectionManager = useGridSelector(apiRef, gridRowSelectionManagerSelector);
|
|
46
|
+
const isRowSelected = id => rowSelectionManager.has(id) && apiRef.current.isRowSelectable(id);
|
|
47
|
+
const currentPage = useGridVisibleRows(apiRef);
|
|
48
|
+
const hasColSpan = useGridSelector(apiRef, gridHasColSpanSelector);
|
|
49
|
+
|
|
50
|
+
/* TODO: extract dimensions code */
|
|
51
|
+
const contentHeight = useGridSelector(apiRef, gridContentHeightSelector);
|
|
52
|
+
const verticalScrollbarWidth = useGridSelector(apiRef, gridVerticalScrollbarWidthSelector);
|
|
53
|
+
const hasFiller = useGridSelector(apiRef, gridHasFillerSelector);
|
|
54
|
+
const {
|
|
55
|
+
autoHeight
|
|
56
|
+
} = rootProps;
|
|
57
|
+
const scrollReset = listView;
|
|
58
|
+
|
|
59
|
+
// <DIMENSIONS>
|
|
60
|
+
const density = useGridSelector(apiRef, gridDensityFactorSelector);
|
|
61
|
+
const baseRowHeight = getValidRowHeight(rootProps.rowHeight, DATA_GRID_PROPS_DEFAULT_VALUES.rowHeight, rowHeightWarning);
|
|
62
|
+
const rowHeight = Math.floor(baseRowHeight * density);
|
|
63
|
+
const headerHeight = Math.floor(rootProps.columnHeaderHeight * density);
|
|
64
|
+
const groupHeaderHeight = Math.floor((rootProps.columnGroupHeaderHeight ?? rootProps.columnHeaderHeight) * density);
|
|
65
|
+
const headerFilterHeight = Math.floor((rootProps.headerFilterHeight ?? rootProps.columnHeaderHeight) * density);
|
|
66
|
+
const columnsTotalWidth = useGridSelector(apiRef, columnsTotalWidthSelector);
|
|
67
|
+
const headersTotalHeight = getTotalHeaderHeight(apiRef, rootProps);
|
|
68
|
+
const leftPinnedWidth = pinnedColumns.left.reduce((w, col) => w + col.computedWidth, 0);
|
|
69
|
+
const rightPinnedWidth = pinnedColumns.right.reduce((w, col) => w + col.computedWidth, 0);
|
|
70
|
+
const dimensions = {
|
|
71
|
+
rowHeight,
|
|
72
|
+
headerHeight,
|
|
73
|
+
groupHeaderHeight,
|
|
74
|
+
headerFilterHeight,
|
|
75
|
+
columnsTotalWidth,
|
|
76
|
+
headersTotalHeight,
|
|
77
|
+
leftPinnedWidth,
|
|
78
|
+
rightPinnedWidth
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// </DIMENSIONS>
|
|
82
|
+
|
|
83
|
+
// <ROWS_META>
|
|
84
|
+
const dataRowCount = useGridSelector(apiRef, gridRowCountSelector);
|
|
85
|
+
const pagination = useGridSelector(apiRef, gridPaginationSelector);
|
|
86
|
+
const rowCount = Math.min(pagination.enabled ? pagination.paginationModel.pageSize : dataRowCount, dataRowCount);
|
|
87
|
+
const {
|
|
88
|
+
getRowHeight,
|
|
89
|
+
getEstimatedRowHeight,
|
|
90
|
+
getRowSpacing
|
|
91
|
+
} = rootProps;
|
|
92
|
+
// </ROWS_META>
|
|
93
|
+
|
|
94
|
+
const focusedVirtualCell = useGridSelector(apiRef, gridFocusedVirtualCellSelector);
|
|
95
|
+
const virtualizer = useVirtualizer({
|
|
96
|
+
scrollbarSize: rootProps.scrollbarSize,
|
|
97
|
+
dimensions,
|
|
98
|
+
initialState: {
|
|
99
|
+
scroll: rootProps.initialState?.scroll,
|
|
100
|
+
dimensions: apiRef.current.state.dimensions,
|
|
101
|
+
rowSpanning: apiRef.current.state.rowSpanning,
|
|
102
|
+
virtualization: apiRef.current.state.virtualization
|
|
103
|
+
},
|
|
104
|
+
isRtl,
|
|
105
|
+
rows: currentPage.rows,
|
|
106
|
+
range: currentPage.range,
|
|
107
|
+
rowIdToIndexMap: currentPage.rowIdToIndexMap,
|
|
108
|
+
rowCount,
|
|
109
|
+
columns: visibleColumns,
|
|
110
|
+
pinnedRows,
|
|
111
|
+
pinnedColumns,
|
|
112
|
+
refs: {
|
|
113
|
+
container: apiRef.current.mainElementRef,
|
|
114
|
+
scroller: apiRef.current.virtualScrollerRef,
|
|
115
|
+
scrollbarVertical: apiRef.current.virtualScrollbarVerticalRef,
|
|
116
|
+
scrollbarHorizontal: apiRef.current.virtualScrollbarHorizontalRef
|
|
117
|
+
},
|
|
118
|
+
hasColSpan,
|
|
119
|
+
contentHeight,
|
|
120
|
+
minimalContentHeight,
|
|
121
|
+
autoHeight,
|
|
122
|
+
getRowHeight: React.useMemo(() => {
|
|
123
|
+
if (!getRowHeight) {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
return rowEntry => getRowHeight(_extends({}, rowEntry, {
|
|
127
|
+
densityFactor: density
|
|
128
|
+
}));
|
|
129
|
+
}, [getRowHeight, density]),
|
|
130
|
+
getEstimatedRowHeight: React.useMemo(() => getEstimatedRowHeight ? rowEntry => getEstimatedRowHeight(_extends({}, rowEntry, {
|
|
131
|
+
densityFactor: density
|
|
132
|
+
})) : undefined, [getEstimatedRowHeight, density]),
|
|
133
|
+
getRowSpacing: React.useMemo(() => getRowSpacing ? (rowEntry, visibility) => getRowSpacing(_extends({}, rowEntry, visibility, {
|
|
134
|
+
indexRelativeToCurrentPage: apiRef.current.getRowIndexRelativeToVisibleRows(rowEntry.id)
|
|
135
|
+
})) : undefined, [apiRef, getRowSpacing]),
|
|
136
|
+
applyRowHeight: useEventCallback((entry, row) => apiRef.current.unstable_applyPipeProcessors('rowHeight', entry, row)),
|
|
137
|
+
virtualizeColumnsWithAutoRowHeight: rootProps.virtualizeColumnsWithAutoRowHeight,
|
|
138
|
+
focusedVirtualCell: useEventCallback(() => focusedVirtualCell),
|
|
139
|
+
rowBufferPx: rootProps.rowBufferPx,
|
|
140
|
+
columnBufferPx: rootProps.columnBufferPx,
|
|
141
|
+
resizeThrottleMs: rootProps.resizeThrottleMs,
|
|
142
|
+
onResize: useEventCallback(size => apiRef.current.publishEvent('resize', size)),
|
|
143
|
+
onWheel: useEventCallback(event => {
|
|
144
|
+
apiRef.current.publishEvent('virtualScrollerWheel', {}, event);
|
|
145
|
+
}),
|
|
146
|
+
onTouchMove: useEventCallback(event => {
|
|
147
|
+
apiRef.current.publishEvent('virtualScrollerTouchMove', {}, event);
|
|
148
|
+
}),
|
|
149
|
+
onRenderContextChange: useEventCallback(nextRenderContext => {
|
|
150
|
+
apiRef.current.publishEvent('renderedRowsIntervalChange', nextRenderContext);
|
|
151
|
+
}),
|
|
152
|
+
onScrollChange: (scrollPosition, nextRenderContext) => {
|
|
153
|
+
apiRef.current.publishEvent('scrollPositionChange', {
|
|
154
|
+
top: scrollPosition.top,
|
|
155
|
+
left: scrollPosition.left,
|
|
156
|
+
renderContext: nextRenderContext
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
scrollReset,
|
|
160
|
+
getColspan: (rowId, column) => {
|
|
161
|
+
if (typeof column.colSpan === 'function') {
|
|
162
|
+
const row = apiRef.current.getRow(rowId);
|
|
163
|
+
const value = apiRef.current.getRowValue(row, column);
|
|
164
|
+
return column.colSpan(value, row, column, apiRef) ?? 0;
|
|
165
|
+
}
|
|
166
|
+
return column.colSpan ?? 0;
|
|
167
|
+
},
|
|
168
|
+
renderRow: params => /*#__PURE__*/_jsx(rootProps.slots.row, _extends({
|
|
169
|
+
row: params.model,
|
|
170
|
+
rowId: params.id,
|
|
171
|
+
index: params.rowIndex,
|
|
172
|
+
selected: isRowSelected(params.id),
|
|
173
|
+
offsetLeft: params.offsetLeft,
|
|
174
|
+
columnsTotalWidth: columnsTotalWidth,
|
|
175
|
+
rowHeight: params.baseRowHeight,
|
|
176
|
+
pinnedColumns: pinnedColumns,
|
|
177
|
+
visibleColumns: params.columns,
|
|
178
|
+
firstColumnIndex: params.firstColumnIndex,
|
|
179
|
+
lastColumnIndex: params.lastColumnIndex,
|
|
180
|
+
focusedColumnIndex: params.focusedColumnIndex,
|
|
181
|
+
isFirstVisible: params.isFirstVisible,
|
|
182
|
+
isLastVisible: params.isLastVisible,
|
|
183
|
+
isNotVisible: params.isVirtualFocusRow,
|
|
184
|
+
showBottomBorder: params.showBottomBorder,
|
|
185
|
+
scrollbarWidth: verticalScrollbarWidth,
|
|
186
|
+
gridHasFiller: hasFiller
|
|
187
|
+
}, rootProps.slotProps?.row), params.id),
|
|
188
|
+
renderInfiniteLoadingTrigger: id => apiRef.current.getInfiniteLoadingTriggerElement?.({
|
|
189
|
+
lastRowId: id
|
|
190
|
+
})
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// HACK: Keep the grid's store in sync with the virtualizer store. We set up the
|
|
194
|
+
// subscription in the render phase rather than in an effect because other grid
|
|
195
|
+
// initialization code runs between those two moments.
|
|
196
|
+
//
|
|
197
|
+
// TODO(v9): Remove this
|
|
198
|
+
useFirstRender(() => {
|
|
199
|
+
apiRef.current.store.state.dimensions = virtualizer.store.state.dimensions;
|
|
200
|
+
apiRef.current.store.state.rowsMeta = virtualizer.store.state.rowsMeta;
|
|
201
|
+
apiRef.current.store.state.virtualization = virtualizer.store.state.virtualization;
|
|
202
|
+
});
|
|
203
|
+
useStoreEffect(virtualizer.store, identity, (_, state) => {
|
|
204
|
+
if (state.dimensions !== apiRef.current.state.dimensions) {
|
|
205
|
+
apiRef.current.setState(gridState => _extends({}, gridState, {
|
|
206
|
+
dimensions: state.dimensions
|
|
207
|
+
}));
|
|
208
|
+
}
|
|
209
|
+
if (state.rowsMeta !== apiRef.current.state.rowsMeta) {
|
|
210
|
+
apiRef.current.setState(gridState => _extends({}, gridState, {
|
|
211
|
+
rowsMeta: state.rowsMeta
|
|
212
|
+
}));
|
|
213
|
+
}
|
|
214
|
+
if (state.virtualization !== apiRef.current.state.virtualization) {
|
|
215
|
+
apiRef.current.setState(gridState => _extends({}, gridState, {
|
|
216
|
+
virtualization: state.virtualization
|
|
217
|
+
}));
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
apiRef.current.register('private', {
|
|
221
|
+
virtualizer
|
|
222
|
+
});
|
|
223
|
+
}
|
|
@@ -31,7 +31,7 @@ export interface GetHeadersParams {
|
|
|
31
31
|
type OwnerState = DataGridProcessedProps;
|
|
32
32
|
export declare const GridColumnHeaderRow: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
33
33
|
ownerState: OwnerState;
|
|
34
|
-
}, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.
|
|
34
|
+
}, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
35
35
|
export declare const useGridColumnHeaders: (props: UseGridColumnHeadersProps) => {
|
|
36
36
|
renderContext: GridColumnsRenderContext;
|
|
37
37
|
leftRenderContext: {
|
|
@@ -4,6 +4,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import { styled } from '@mui/material/styles';
|
|
7
|
+
import { computeOffsetLeft } from '@mui/x-virtualizer';
|
|
7
8
|
import { useGridSelector } from "../../utils/index.js";
|
|
8
9
|
import { useGridRootProps } from "../../utils/useGridRootProps.js";
|
|
9
10
|
import { useGridPrivateApiContext } from "../../utils/useGridPrivateApiContext.js";
|
|
@@ -11,7 +12,6 @@ import { useGridEvent } from "../../utils/useGridEvent.js";
|
|
|
11
12
|
import { GridColumnHeaderItem } from "../../../components/columnHeaders/GridColumnHeaderItem.js";
|
|
12
13
|
import { gridColumnsTotalWidthSelector, gridGroupHeaderHeightSelector, gridHasFillerSelector, gridHeaderHeightSelector, gridVerticalScrollbarWidthSelector } from "../dimensions/gridDimensionsSelectors.js";
|
|
13
14
|
import { gridRenderContextColumnsSelector } from "../virtualization/index.js";
|
|
14
|
-
import { computeOffsetLeft } from "../virtualization/useGridVirtualScroller.js";
|
|
15
15
|
import { GridColumnGroupHeader } from "../../../components/columnHeaders/GridColumnGroupHeader.js";
|
|
16
16
|
import { gridColumnPositionsSelector, gridVisiblePinnedColumnDefinitionsSelector, gridColumnLookupSelector } from "../columns/index.js";
|
|
17
17
|
import { gridColumnGroupsUnwrappedModelSelector } from "../columnGrouping/gridColumnGroupsSelector.js";
|
|
@@ -85,7 +85,8 @@ export const useGridColumnHeaders = props => {
|
|
|
85
85
|
renderContext: currentContext = renderContext
|
|
86
86
|
} = params || {};
|
|
87
87
|
const firstColumnToRender = currentContext.firstColumnIndex;
|
|
88
|
-
|
|
88
|
+
// HACK: renderContext ins't always synchronized, this should be handled properly.
|
|
89
|
+
const lastColumnToRender = Math.min(currentContext.lastColumnIndex, visibleColumns.length);
|
|
89
90
|
const renderedColumns = visibleColumns.slice(firstColumnToRender, lastColumnToRender);
|
|
90
91
|
return {
|
|
91
92
|
renderedColumns,
|