@mui/x-data-grid 7.0.0-beta.7 → 7.0.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 +195 -12
- package/DataGrid/DataGrid.js +13 -17
- package/DataGrid/useDataGridProps.js +3 -5
- package/README.md +1 -1
- package/components/GridFooter.js +2 -3
- package/components/GridHeader.js +1 -2
- package/components/GridPagination.d.ts +6 -5
- package/components/GridPagination.js +12 -4
- package/components/GridRow.js +13 -17
- package/components/base/GridFooterPlaceholder.js +1 -2
- package/components/base/GridOverlays.js +3 -6
- package/components/cell/GridActionsCell.js +4 -6
- package/components/cell/GridActionsCellItem.d.ts +8 -25
- package/components/cell/GridActionsCellItem.js +8 -5
- package/components/cell/GridBooleanCell.d.ts +1 -0
- package/components/cell/GridBooleanCell.js +3 -2
- package/components/cell/GridCell.js +7 -8
- package/components/cell/GridEditBooleanCell.js +1 -2
- package/components/cell/GridEditDateCell.js +2 -3
- package/components/cell/GridEditInputCell.js +2 -2
- package/components/cell/GridEditSingleSelectCell.js +5 -8
- package/components/columnHeaders/ColumnHeaderMenuIcon.js +2 -3
- package/components/columnHeaders/GridColumnGroupHeader.js +4 -5
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.js +2 -3
- package/components/columnHeaders/GridColumnHeaderItem.js +5 -6
- package/components/columnHeaders/GridColumnHeaderSortIcon.js +1 -2
- package/components/columnHeaders/GridColumnHeaderTitle.js +2 -3
- package/components/columnHeaders/GridGenericColumnHeaderItem.js +1 -1
- package/components/columnSelection/GridCellCheckboxRenderer.js +3 -5
- package/components/columnSelection/GridHeaderCheckbox.js +1 -2
- package/components/columnsManagement/GridColumnsManagement.js +17 -21
- package/components/containers/GridRoot.js +3 -3
- package/components/menu/GridMenu.js +4 -6
- package/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +2 -3
- package/components/panel/GridColumnsPanel.js +1 -2
- package/components/panel/GridPanel.d.ts +1 -10
- package/components/panel/GridPanel.js +1 -2
- package/components/panel/GridPreferencesPanel.js +2 -3
- package/components/panel/filterPanel/GridFilterForm.js +24 -27
- package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.js +6 -7
- package/components/panel/filterPanel/GridFilterInputDate.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputDate.js +3 -4
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +11 -15
- package/components/panel/filterPanel/GridFilterInputMultipleValue.js +10 -14
- package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +10 -11
- package/components/panel/filterPanel/GridFilterInputValue.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputValue.js +5 -7
- package/components/panel/filterPanel/GridFilterPanel.js +5 -9
- package/components/panel/filterPanel/filterPanelUtils.js +1 -1
- package/components/toolbar/GridToolbarColumnsButton.js +3 -5
- package/components/toolbar/GridToolbarDensitySelector.js +8 -10
- package/components/toolbar/GridToolbarExport.js +2 -2
- package/components/toolbar/GridToolbarExportContainer.js +3 -5
- package/components/toolbar/GridToolbarFilterButton.js +3 -5
- package/components/toolbar/GridToolbarQuickFilter.js +4 -5
- package/components/virtualization/GridVirtualScrollerContent.js +1 -2
- package/components/virtualization/GridVirtualScrollerRenderZone.js +1 -2
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.js +1 -2
- package/hooks/core/useGridApiInitialization.js +4 -6
- package/hooks/features/clipboard/useGridClipboard.js +6 -5
- package/hooks/features/columnGrouping/gridColumnGroupsSelector.js +4 -16
- package/hooks/features/columnGrouping/gridColumnGroupsUtils.js +4 -8
- package/hooks/features/columnGrouping/useGridColumnGrouping.js +12 -23
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +6 -8
- package/hooks/features/columnMenu/useGridColumnMenuSlots.js +2 -2
- package/hooks/features/columnResize/useGridColumnResize.js +9 -19
- package/hooks/features/columns/gridColumnsSelector.js +1 -2
- package/hooks/features/columns/gridColumnsUtils.d.ts +0 -9
- package/hooks/features/columns/gridColumnsUtils.js +2 -22
- package/hooks/features/columns/useGridColumnSpanning.js +1 -2
- package/hooks/features/columns/useGridColumns.js +11 -19
- package/hooks/features/density/densitySelector.d.ts +4 -2
- package/hooks/features/density/densitySelector.js +8 -2
- package/hooks/features/density/densityState.d.ts +1 -4
- package/hooks/features/density/useGridDensity.d.ts +2 -4
- package/hooks/features/density/useGridDensity.js +21 -29
- package/hooks/features/dimensions/useGridDimensions.js +3 -5
- package/hooks/features/editing/useGridCellEditing.js +4 -6
- package/hooks/features/editing/useGridEditing.js +1 -2
- package/hooks/features/editing/useGridRowEditing.js +4 -6
- package/hooks/features/export/serializers/csvSerializer.d.ts +2 -0
- package/hooks/features/export/serializers/csvSerializer.js +25 -16
- package/hooks/features/export/useGridCsvExport.js +9 -10
- package/hooks/features/export/useGridPrintExport.js +9 -15
- package/hooks/features/export/utils.js +2 -3
- package/hooks/features/filter/gridFilterSelector.js +15 -22
- package/hooks/features/filter/gridFilterUtils.js +10 -16
- package/hooks/features/filter/useGridFilter.js +9 -15
- package/hooks/features/focus/useGridFocus.js +5 -6
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +1 -4
- package/hooks/features/headerFiltering/useGridHeaderFiltering.js +12 -17
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -2
- package/hooks/features/pagination/gridPaginationSelector.js +1 -2
- package/hooks/features/pagination/useGridPagination.js +2 -3
- package/hooks/features/pagination/useGridPaginationModel.js +6 -11
- package/hooks/features/pagination/useGridRowCount.js +3 -6
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +7 -12
- package/hooks/features/rowSelection/useGridRowSelection.js +11 -16
- package/hooks/features/rows/gridRowsSelector.js +11 -19
- package/hooks/features/rows/gridRowsUtils.js +7 -9
- package/hooks/features/rows/useGridParamsApi.js +1 -1
- package/hooks/features/rows/useGridRows.js +4 -13
- package/hooks/features/rows/useGridRowsMeta.js +7 -13
- package/hooks/features/scroll/useGridScroll.js +2 -3
- package/hooks/features/sorting/gridSortingSelector.js +4 -7
- package/hooks/features/sorting/useGridSorting.js +8 -14
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +220 -71
- package/hooks/utils/useGridApiEventHandler.js +5 -10
- package/hooks/utils/useGridNativeEventListener.js +1 -2
- package/index.js +1 -1
- package/internals/index.d.ts +2 -0
- package/internals/index.js +1 -0
- package/internals/utils/useProps.js +1 -2
- package/joy/joySlots.js +7 -13
- package/models/api/gridRowsMetaApi.d.ts +1 -1
- package/models/api/index.d.ts +1 -1
- package/models/api/index.js +0 -1
- package/models/events/gridEventLookup.d.ts +7 -0
- package/models/gridExport.d.ts +6 -0
- package/models/gridStateCommunity.d.ts +1 -0
- package/models/props/DataGridProps.d.ts +23 -27
- package/modern/DataGrid/DataGrid.js +13 -17
- package/modern/DataGrid/useDataGridProps.js +3 -5
- package/modern/components/GridPagination.js +11 -2
- package/modern/components/cell/GridActionsCell.js +1 -1
- package/modern/components/cell/GridActionsCellItem.js +4 -0
- package/modern/components/cell/GridBooleanCell.js +3 -2
- package/modern/components/containers/GridRoot.js +3 -3
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputDate.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/modern/components/toolbar/GridToolbarDensitySelector.js +5 -5
- package/modern/hooks/features/clipboard/useGridClipboard.js +4 -2
- package/modern/hooks/features/columnResize/useGridColumnResize.js +1 -1
- package/modern/hooks/features/columns/gridColumnsUtils.js +0 -19
- package/modern/hooks/features/density/densitySelector.js +8 -2
- package/modern/hooks/features/density/useGridDensity.js +21 -29
- package/modern/hooks/features/editing/useGridCellEditing.js +1 -1
- package/modern/hooks/features/editing/useGridRowEditing.js +1 -1
- package/modern/hooks/features/export/serializers/csvSerializer.js +23 -12
- package/modern/hooks/features/export/useGridCsvExport.js +2 -1
- package/modern/hooks/features/filter/gridFilterUtils.js +1 -1
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +3 -2
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +211 -57
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -0
- package/modern/models/api/index.js +0 -1
- package/modern/utils/createSelector.js +1 -1
- package/modern/utils/domUtils.js +1 -1
- package/modern/utils/keyboardUtils.js +1 -1
- package/node/DataGrid/DataGrid.js +13 -17
- package/node/DataGrid/useDataGridProps.js +3 -5
- package/node/components/GridPagination.js +9 -1
- package/node/components/cell/GridActionsCell.js +1 -1
- package/node/components/cell/GridActionsCellItem.js +4 -0
- package/node/components/cell/GridBooleanCell.js +3 -2
- package/node/components/containers/GridRoot.js +2 -2
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputDate.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/node/components/toolbar/GridToolbarDensitySelector.js +4 -4
- package/node/hooks/features/clipboard/useGridClipboard.js +4 -2
- package/node/hooks/features/columnResize/useGridColumnResize.js +1 -1
- package/node/hooks/features/columns/gridColumnsUtils.js +0 -20
- package/node/hooks/features/density/densitySelector.js +9 -3
- package/node/hooks/features/density/useGridDensity.js +22 -30
- package/node/hooks/features/editing/useGridCellEditing.js +1 -1
- package/node/hooks/features/editing/useGridRowEditing.js +1 -1
- package/node/hooks/features/export/serializers/csvSerializer.js +23 -12
- package/node/hooks/features/export/useGridCsvExport.js +2 -1
- package/node/hooks/features/filter/gridFilterUtils.js +1 -1
- package/node/hooks/features/rowSelection/useGridRowSelection.js +2 -1
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +211 -57
- package/node/index.js +1 -1
- package/node/internals/index.js +12 -0
- package/node/models/api/index.js +0 -11
- package/node/utils/createSelector.js +1 -1
- package/node/utils/domUtils.js +1 -1
- package/node/utils/keyboardUtils.js +1 -1
- package/package.json +4 -4
- package/utils/createSelector.js +9 -9
- package/utils/domUtils.js +4 -7
- package/utils/getGridLocalization.js +9 -12
- package/utils/keyboardUtils.js +1 -1
|
@@ -2,6 +2,8 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import * as ReactDOM from 'react-dom';
|
|
4
4
|
import { unstable_useEnhancedEffect as useEnhancedEffect, unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
5
|
+
import useLazyRef from '@mui/utils/useLazyRef';
|
|
6
|
+
import useTimeout from '@mui/utils/useTimeout';
|
|
5
7
|
import { useTheme } from '@mui/material/styles';
|
|
6
8
|
import { useGridPrivateApiContext } from '../../utils/useGridPrivateApiContext';
|
|
7
9
|
import { useGridRootProps } from '../../utils/useGridRootProps';
|
|
@@ -22,13 +24,31 @@ import { getMinimalContentHeight } from '../rows/gridRowsUtils';
|
|
|
22
24
|
import { gridRenderContextSelector, gridVirtualizationEnabledSelector, gridVirtualizationColumnEnabledSelector } from './gridVirtualizationSelectors';
|
|
23
25
|
import { EMPTY_RENDER_CONTEXT } from './useGridVirtualization';
|
|
24
26
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
|
+
const MINIMUM_COLUMN_WIDTH = 50;
|
|
28
|
+
var ScrollDirection = /*#__PURE__*/function (ScrollDirection) {
|
|
29
|
+
ScrollDirection[ScrollDirection["NONE"] = 0] = "NONE";
|
|
30
|
+
ScrollDirection[ScrollDirection["UP"] = 1] = "UP";
|
|
31
|
+
ScrollDirection[ScrollDirection["DOWN"] = 2] = "DOWN";
|
|
32
|
+
ScrollDirection[ScrollDirection["LEFT"] = 3] = "LEFT";
|
|
33
|
+
ScrollDirection[ScrollDirection["RIGHT"] = 4] = "RIGHT";
|
|
34
|
+
return ScrollDirection;
|
|
35
|
+
}(ScrollDirection || {});
|
|
36
|
+
const EMPTY_SCROLL_POSITION = {
|
|
37
|
+
top: 0,
|
|
38
|
+
left: 0
|
|
39
|
+
};
|
|
25
40
|
export const EMPTY_DETAIL_PANELS = Object.freeze(new Map());
|
|
41
|
+
const createScrollCache = (rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer) => ({
|
|
42
|
+
direction: ScrollDirection.NONE,
|
|
43
|
+
buffer: bufferForDirection(ScrollDirection.NONE, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer)
|
|
44
|
+
});
|
|
45
|
+
const isJSDOM = typeof window !== 'undefined' ? /jsdom/.test(window.navigator.userAgent) : false;
|
|
26
46
|
export const useGridVirtualScroller = () => {
|
|
27
47
|
const apiRef = useGridPrivateApiContext();
|
|
28
48
|
const rootProps = useGridRootProps();
|
|
29
49
|
const visibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
|
|
30
|
-
const enabled = useGridSelector(apiRef, gridVirtualizationEnabledSelector);
|
|
31
|
-
const enabledForColumns = useGridSelector(apiRef, gridVirtualizationColumnEnabledSelector);
|
|
50
|
+
const enabled = useGridSelector(apiRef, gridVirtualizationEnabledSelector) && !isJSDOM;
|
|
51
|
+
const enabledForColumns = useGridSelector(apiRef, gridVirtualizationColumnEnabledSelector) && !isJSDOM;
|
|
32
52
|
const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
|
|
33
53
|
const outerSize = dimensions.viewportOuterSize;
|
|
34
54
|
const pinnedRows = useGridSelector(apiRef, gridPinnedRowsSelector);
|
|
@@ -50,19 +70,34 @@ export const useGridVirtualScroller = () => {
|
|
|
50
70
|
const columnsTotalWidth = dimensions.columnsTotalWidth;
|
|
51
71
|
const hasColSpan = useGridSelector(apiRef, gridHasColSpanSelector);
|
|
52
72
|
useResizeObserver(mainRef, () => apiRef.current.resize());
|
|
53
|
-
|
|
73
|
+
|
|
74
|
+
/*
|
|
75
|
+
* Scroll context logic
|
|
76
|
+
* ====================
|
|
77
|
+
* We only render the cells contained in the `renderContext`. However, when the user starts scrolling the grid
|
|
78
|
+
* in a direction, we want to render as many cells as possible in that direction, as to avoid presenting white
|
|
79
|
+
* areas if the user scrolls too fast/far and the viewport ends up in a region we haven't rendered yet. To render
|
|
80
|
+
* more cells, we store some offsets to add to the viewport in `scrollCache.buffer`. Those offsets make the render
|
|
81
|
+
* context wider in the direction the user is going, but also makes the buffer around the viewport `0` for the
|
|
82
|
+
* dimension (horizontal or vertical) in which the user is not scrolling. So if the normal viewport is 8 columns
|
|
83
|
+
* wide, with a 1 column buffer (10 columns total), then we want it to be exactly 8 columns wide during vertical
|
|
84
|
+
* scroll.
|
|
85
|
+
* However, we don't want the rows in the old context to re-render from e.g. 10 columns to 8 columns, because that's
|
|
86
|
+
* work that's not necessary. Thus we store the context at the start of the scroll in `frozenContext`, and the rows
|
|
87
|
+
* that are part of this old context will keep their same render context as to avoid re-rendering.
|
|
88
|
+
*/
|
|
89
|
+
const scrollPosition = React.useRef(EMPTY_SCROLL_POSITION);
|
|
90
|
+
const previousContextScrollPosition = React.useRef(EMPTY_SCROLL_POSITION);
|
|
54
91
|
const previousRowContext = React.useRef(EMPTY_RENDER_CONTEXT);
|
|
55
92
|
const renderContext = useGridSelector(apiRef, gridRenderContextSelector);
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}).current;
|
|
60
|
-
const prevTotalWidth = React.useRef(columnsTotalWidth);
|
|
93
|
+
const scrollTimeout = useTimeout();
|
|
94
|
+
const frozenContext = React.useRef(undefined);
|
|
95
|
+
const scrollCache = useLazyRef(() => createScrollCache(rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6)).current;
|
|
61
96
|
const focusedCell = {
|
|
62
97
|
rowIndex: React.useMemo(() => cellFocus ? currentPage.rows.findIndex(row => row.id === cellFocus.id) : -1, [cellFocus, currentPage.rows]),
|
|
63
98
|
columnIndex: React.useMemo(() => cellFocus ? visibleColumns.findIndex(column => column.field === cellFocus.field) : -1, [cellFocus, visibleColumns])
|
|
64
99
|
};
|
|
65
|
-
const updateRenderContext = React.useCallback(
|
|
100
|
+
const updateRenderContext = React.useCallback(nextRenderContext => {
|
|
66
101
|
if (areRenderContextsEqual(nextRenderContext, apiRef.current.state.virtualization.renderContext)) {
|
|
67
102
|
return;
|
|
68
103
|
}
|
|
@@ -82,41 +117,67 @@ export const useGridVirtualScroller = () => {
|
|
|
82
117
|
previousRowContext.current = nextRenderContext;
|
|
83
118
|
apiRef.current.publishEvent('renderedRowsIntervalChange', nextRenderContext);
|
|
84
119
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}, [apiRef, dimensions.isReady, dimensions.columnsTotalWidth]);
|
|
120
|
+
previousContextScrollPosition.current = scrollPosition.current;
|
|
121
|
+
}, [apiRef, dimensions.isReady]);
|
|
88
122
|
const triggerUpdateRenderContext = () => {
|
|
89
|
-
const
|
|
90
|
-
|
|
123
|
+
const newScroll = {
|
|
124
|
+
top: scrollerRef.current.scrollTop,
|
|
125
|
+
left: scrollerRef.current.scrollLeft
|
|
126
|
+
};
|
|
127
|
+
const dx = newScroll.left - scrollPosition.current.left;
|
|
128
|
+
const dy = newScroll.top - scrollPosition.current.top;
|
|
129
|
+
const isScrolling = dx !== 0 || dy !== 0;
|
|
130
|
+
scrollPosition.current = newScroll;
|
|
131
|
+
const direction = isScrolling ? directionForDelta(dx, dy) : ScrollDirection.NONE;
|
|
91
132
|
|
|
92
133
|
// Since previous render, we have scrolled...
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
134
|
+
const rowScroll = Math.abs(scrollPosition.current.top - previousContextScrollPosition.current.top);
|
|
135
|
+
const columnScroll = Math.abs(scrollPosition.current.left - previousContextScrollPosition.current.left);
|
|
136
|
+
|
|
137
|
+
// PERF: use the computed minimum column width instead of a static one
|
|
138
|
+
const didCrossThreshold = rowScroll >= dimensions.rowHeight || columnScroll >= MINIMUM_COLUMN_WIDTH;
|
|
139
|
+
const didChangeDirection = scrollCache.direction !== direction;
|
|
140
|
+
const shouldUpdate = didCrossThreshold || didChangeDirection;
|
|
98
141
|
if (!shouldUpdate) {
|
|
99
|
-
return
|
|
142
|
+
return renderContext;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Render a new context
|
|
146
|
+
|
|
147
|
+
if (didChangeDirection) {
|
|
148
|
+
switch (direction) {
|
|
149
|
+
case ScrollDirection.NONE:
|
|
150
|
+
case ScrollDirection.LEFT:
|
|
151
|
+
case ScrollDirection.RIGHT:
|
|
152
|
+
frozenContext.current = undefined;
|
|
153
|
+
break;
|
|
154
|
+
default:
|
|
155
|
+
frozenContext.current = renderContext;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
100
158
|
}
|
|
159
|
+
scrollCache.direction = direction;
|
|
160
|
+
scrollCache.buffer = bufferForDirection(direction, rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6);
|
|
161
|
+
const inputs = inputsSelector(apiRef, rootProps, enabled, enabledForColumns);
|
|
162
|
+
const nextRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
|
|
101
163
|
|
|
102
164
|
// Prevents batching render context changes
|
|
103
165
|
ReactDOM.flushSync(() => {
|
|
104
|
-
updateRenderContext(nextRenderContext
|
|
166
|
+
updateRenderContext(nextRenderContext);
|
|
105
167
|
});
|
|
168
|
+
scrollTimeout.start(1000, triggerUpdateRenderContext);
|
|
106
169
|
return nextRenderContext;
|
|
107
170
|
};
|
|
108
171
|
const forceUpdateRenderContext = () => {
|
|
109
172
|
const inputs = inputsSelector(apiRef, rootProps, enabled, enabledForColumns);
|
|
110
|
-
const
|
|
111
|
-
updateRenderContext(nextRenderContext
|
|
173
|
+
const nextRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
|
|
174
|
+
updateRenderContext(nextRenderContext);
|
|
112
175
|
};
|
|
113
176
|
const handleScroll = useEventCallback(event => {
|
|
114
177
|
const {
|
|
115
178
|
scrollTop,
|
|
116
179
|
scrollLeft
|
|
117
180
|
} = event.currentTarget;
|
|
118
|
-
scrollPosition.top = scrollTop;
|
|
119
|
-
scrollPosition.left = scrollLeft;
|
|
120
181
|
|
|
121
182
|
// On iOS and macOS, negative offsets are possible when swiping past the start
|
|
122
183
|
if (scrollTop < 0) {
|
|
@@ -149,8 +210,7 @@ export const useGridVirtualScroller = () => {
|
|
|
149
210
|
if (!params.rows && !currentPage.range) {
|
|
150
211
|
return [];
|
|
151
212
|
}
|
|
152
|
-
const
|
|
153
|
-
const currentRenderContext = params.renderContext ?? renderContext;
|
|
213
|
+
const baseRenderContext = params.renderContext ?? renderContext;
|
|
154
214
|
const isLastSection = !hasBottomPinnedRows && params.position === undefined || hasBottomPinnedRows && params.position === 'bottom';
|
|
155
215
|
const isPinnedSection = params.position !== undefined;
|
|
156
216
|
let rowIndexOffset;
|
|
@@ -168,8 +228,8 @@ export const useGridVirtualScroller = () => {
|
|
|
168
228
|
break;
|
|
169
229
|
}
|
|
170
230
|
const rowModels = params.rows ?? currentPage.rows;
|
|
171
|
-
const firstRowToRender =
|
|
172
|
-
const lastRowToRender = Math.min(
|
|
231
|
+
const firstRowToRender = baseRenderContext.firstRowIndex;
|
|
232
|
+
const lastRowToRender = Math.min(baseRenderContext.lastRowIndex, rowModels.length);
|
|
173
233
|
const rowIndexes = params.rows ? range(0, params.rows.length) : range(firstRowToRender, lastRowToRender);
|
|
174
234
|
let virtualRowIndex = -1;
|
|
175
235
|
if (!isPinnedSection && focusedCell.rowIndex !== -1) {
|
|
@@ -184,6 +244,7 @@ export const useGridVirtualScroller = () => {
|
|
|
184
244
|
}
|
|
185
245
|
const rows = [];
|
|
186
246
|
const rowProps = rootProps.slotProps?.row;
|
|
247
|
+
const columnPositions = gridColumnPositionsSelector(apiRef);
|
|
187
248
|
rowIndexes.forEach(rowIndexInPage => {
|
|
188
249
|
const {
|
|
189
250
|
id,
|
|
@@ -248,6 +309,10 @@ export const useGridVirtualScroller = () => {
|
|
|
248
309
|
const cellParams = apiRef.current.getCellParams(id, cellTabIndex.field);
|
|
249
310
|
tabbableCell = cellParams.cellMode === 'view' ? cellTabIndex.field : null;
|
|
250
311
|
}
|
|
312
|
+
let currentRenderContext = baseRenderContext;
|
|
313
|
+
if (!isPinnedSection && frozenContext.current && rowIndexInPage >= frozenContext.current.firstRowIndex && rowIndexInPage < frozenContext.current.lastRowIndex) {
|
|
314
|
+
currentRenderContext = frozenContext.current;
|
|
315
|
+
}
|
|
251
316
|
const offsetLeft = computeOffsetLeft(columnPositions, currentRenderContext, theme.direction, pinnedColumns.left.length);
|
|
252
317
|
const rowIndex = (currentPage?.range?.firstRowIndex || 0) + rowIndexOffset + rowIndexInPage;
|
|
253
318
|
rows.push( /*#__PURE__*/_jsx(rootProps.slots.row, _extends({
|
|
@@ -319,11 +384,11 @@ export const useGridVirtualScroller = () => {
|
|
|
319
384
|
}, [enabled, gridRootRef, scrollerRef]);
|
|
320
385
|
useRunOnce(outerSize.width !== 0, () => {
|
|
321
386
|
const inputs = inputsSelector(apiRef, rootProps, enabled, enabledForColumns);
|
|
322
|
-
const
|
|
323
|
-
updateRenderContext(initialRenderContext
|
|
387
|
+
const initialRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
|
|
388
|
+
updateRenderContext(initialRenderContext);
|
|
324
389
|
apiRef.current.publishEvent('scrollPositionChange', {
|
|
325
|
-
top: scrollPosition.top,
|
|
326
|
-
left: scrollPosition.left,
|
|
390
|
+
top: scrollPosition.current.top,
|
|
391
|
+
left: scrollPosition.current.left,
|
|
327
392
|
renderContext: initialRenderContext
|
|
328
393
|
});
|
|
329
394
|
});
|
|
@@ -369,26 +434,31 @@ export const useGridVirtualScroller = () => {
|
|
|
369
434
|
function inputsSelector(apiRef, rootProps, enabled, enabledForColumns) {
|
|
370
435
|
const dimensions = gridDimensionsSelector(apiRef.current.state);
|
|
371
436
|
const currentPage = getVisibleRows(apiRef, rootProps);
|
|
437
|
+
const visibleColumns = gridVisibleColumnDefinitionsSelector(apiRef);
|
|
438
|
+
const lastRowId = apiRef.current.state.rows.dataRowIds.at(-1);
|
|
439
|
+
const lastColumn = visibleColumns.at(-1);
|
|
372
440
|
return {
|
|
373
441
|
enabled,
|
|
374
442
|
enabledForColumns,
|
|
375
443
|
apiRef,
|
|
376
444
|
autoHeight: rootProps.autoHeight,
|
|
377
|
-
|
|
378
|
-
|
|
445
|
+
rowBufferPx: rootProps.rowBufferPx,
|
|
446
|
+
columnBufferPx: rootProps.columnBufferPx,
|
|
379
447
|
leftPinnedWidth: dimensions.leftPinnedWidth,
|
|
380
448
|
columnsTotalWidth: dimensions.columnsTotalWidth,
|
|
381
449
|
viewportInnerWidth: dimensions.viewportInnerSize.width,
|
|
382
450
|
viewportInnerHeight: dimensions.viewportInnerSize.height,
|
|
451
|
+
lastRowHeight: lastRowId !== undefined ? apiRef.current.unstable_getRowHeight(lastRowId) : 0,
|
|
452
|
+
lastColumnWidth: lastColumn?.computedWidth ?? 0,
|
|
383
453
|
rowsMeta: gridRowsMetaSelector(apiRef.current.state),
|
|
384
454
|
columnPositions: gridColumnPositionsSelector(apiRef),
|
|
385
455
|
rows: currentPage.rows,
|
|
386
456
|
range: currentPage.range,
|
|
387
457
|
pinnedColumns: gridVisiblePinnedColumnDefinitionsSelector(apiRef),
|
|
388
|
-
visibleColumns
|
|
458
|
+
visibleColumns
|
|
389
459
|
};
|
|
390
460
|
}
|
|
391
|
-
function computeRenderContext(inputs, scrollPosition) {
|
|
461
|
+
function computeRenderContext(inputs, scrollPosition, scrollCache) {
|
|
392
462
|
let renderContext;
|
|
393
463
|
if (!inputs.enabled) {
|
|
394
464
|
renderContext = {
|
|
@@ -406,7 +476,10 @@ function computeRenderContext(inputs, scrollPosition) {
|
|
|
406
476
|
|
|
407
477
|
// Clamp the value because the search may return an index out of bounds.
|
|
408
478
|
// In the last index, this is not needed because Array.slice doesn't include it.
|
|
409
|
-
const firstRowIndex = Math.min(getNearestIndexToRender(inputs, top
|
|
479
|
+
const firstRowIndex = Math.min(getNearestIndexToRender(inputs, top, {
|
|
480
|
+
atStart: true,
|
|
481
|
+
lastPosition: inputs.rowsMeta.positions[inputs.rowsMeta.positions.length - 1] + inputs.lastRowHeight
|
|
482
|
+
}), inputs.rowsMeta.positions.length - 1);
|
|
410
483
|
const lastRowIndex = inputs.autoHeight ? firstRowIndex + inputs.rows.length : getNearestIndexToRender(inputs, top + inputs.viewportInnerHeight);
|
|
411
484
|
let firstColumnIndex = 0;
|
|
412
485
|
let lastColumnIndex = inputs.columnPositions.length;
|
|
@@ -417,7 +490,10 @@ function computeRenderContext(inputs, scrollPosition) {
|
|
|
417
490
|
lastIndex: lastRowIndex,
|
|
418
491
|
minFirstIndex: 0,
|
|
419
492
|
maxLastIndex: inputs.rows.length,
|
|
420
|
-
|
|
493
|
+
bufferBefore: scrollCache.buffer.rowBefore,
|
|
494
|
+
bufferAfter: scrollCache.buffer.rowAfter,
|
|
495
|
+
positions: inputs.rowsMeta.positions,
|
|
496
|
+
lastSize: inputs.lastRowHeight
|
|
421
497
|
});
|
|
422
498
|
for (let i = firstRowToRender; i < lastRowToRender && !hasRowWithAutoHeight; i += 1) {
|
|
423
499
|
const row = inputs.rows[i];
|
|
@@ -438,10 +514,10 @@ function computeRenderContext(inputs, scrollPosition) {
|
|
|
438
514
|
lastColumnIndex
|
|
439
515
|
};
|
|
440
516
|
}
|
|
441
|
-
const actualRenderContext = deriveRenderContext(inputs
|
|
442
|
-
return
|
|
517
|
+
const actualRenderContext = deriveRenderContext(inputs, renderContext, scrollCache);
|
|
518
|
+
return actualRenderContext;
|
|
443
519
|
}
|
|
444
|
-
function getNearestIndexToRender(inputs, offset) {
|
|
520
|
+
function getNearestIndexToRender(inputs, offset, options) {
|
|
445
521
|
const lastMeasuredIndexRelativeToAllRows = inputs.apiRef.current.getLastMeasuredRowIndex();
|
|
446
522
|
let allRowsMeasured = lastMeasuredIndexRelativeToAllRows === Infinity;
|
|
447
523
|
if (inputs.range?.lastRowIndex && !allRowsMeasured) {
|
|
@@ -452,14 +528,14 @@ function getNearestIndexToRender(inputs, offset) {
|
|
|
452
528
|
if (allRowsMeasured || inputs.rowsMeta.positions[lastMeasuredIndexRelativeToCurrentPage] >= offset) {
|
|
453
529
|
// If all rows were measured (when no row has "auto" as height) or all rows before the offset
|
|
454
530
|
// were measured, then use a binary search because it's faster.
|
|
455
|
-
return binarySearch(offset, inputs.rowsMeta.positions);
|
|
531
|
+
return binarySearch(offset, inputs.rowsMeta.positions, options);
|
|
456
532
|
}
|
|
457
533
|
|
|
458
534
|
// Otherwise, use an exponential search.
|
|
459
535
|
// If rows have "auto" as height, their positions will be based on estimated heights.
|
|
460
536
|
// In this case, we can skip several steps until we find a position higher than the offset.
|
|
461
537
|
// Inspired by https://github.com/bvaughn/react-virtualized/blob/master/source/Grid/utils/CellSizeAndPositionManager.js
|
|
462
|
-
return exponentialSearch(offset, inputs.rowsMeta.positions, lastMeasuredIndexRelativeToCurrentPage);
|
|
538
|
+
return exponentialSearch(offset, inputs.rowsMeta.positions, lastMeasuredIndexRelativeToCurrentPage, options);
|
|
463
539
|
}
|
|
464
540
|
|
|
465
541
|
/**
|
|
@@ -467,27 +543,33 @@ function getNearestIndexToRender(inputs, offset) {
|
|
|
467
543
|
* computes the actual render context based on pinned elements, buffer dimensions and
|
|
468
544
|
* spanning.
|
|
469
545
|
*/
|
|
470
|
-
function deriveRenderContext(
|
|
546
|
+
function deriveRenderContext(inputs, nextRenderContext, scrollCache) {
|
|
471
547
|
const [firstRowToRender, lastRowToRender] = getIndexesToRender({
|
|
472
548
|
firstIndex: nextRenderContext.firstRowIndex,
|
|
473
549
|
lastIndex: nextRenderContext.lastRowIndex,
|
|
474
550
|
minFirstIndex: 0,
|
|
475
|
-
maxLastIndex: rows.length,
|
|
476
|
-
|
|
551
|
+
maxLastIndex: inputs.rows.length,
|
|
552
|
+
bufferBefore: scrollCache.buffer.rowBefore,
|
|
553
|
+
bufferAfter: scrollCache.buffer.rowAfter,
|
|
554
|
+
positions: inputs.rowsMeta.positions,
|
|
555
|
+
lastSize: inputs.lastRowHeight
|
|
477
556
|
});
|
|
478
557
|
const [initialFirstColumnToRender, lastColumnToRender] = getIndexesToRender({
|
|
479
558
|
firstIndex: nextRenderContext.firstColumnIndex,
|
|
480
559
|
lastIndex: nextRenderContext.lastColumnIndex,
|
|
481
|
-
minFirstIndex: pinnedColumns.left.length,
|
|
482
|
-
maxLastIndex: visibleColumns.length - pinnedColumns.right.length,
|
|
483
|
-
|
|
560
|
+
minFirstIndex: inputs.pinnedColumns.left.length,
|
|
561
|
+
maxLastIndex: inputs.visibleColumns.length - inputs.pinnedColumns.right.length,
|
|
562
|
+
bufferBefore: scrollCache.buffer.columnBefore,
|
|
563
|
+
bufferAfter: scrollCache.buffer.columnAfter,
|
|
564
|
+
positions: inputs.columnPositions,
|
|
565
|
+
lastSize: inputs.lastColumnWidth
|
|
484
566
|
});
|
|
485
567
|
const firstColumnToRender = getFirstNonSpannedColumnToRender({
|
|
486
568
|
firstColumnToRender: initialFirstColumnToRender,
|
|
487
|
-
apiRef,
|
|
569
|
+
apiRef: inputs.apiRef,
|
|
488
570
|
firstRowToRender,
|
|
489
571
|
lastRowToRender,
|
|
490
|
-
visibleRows: rows
|
|
572
|
+
visibleRows: inputs.rows
|
|
491
573
|
});
|
|
492
574
|
return {
|
|
493
575
|
firstRowIndex: firstRowToRender,
|
|
@@ -520,22 +602,32 @@ function binarySearch(offset, positions, options = undefined, sliceStart = 0, sl
|
|
|
520
602
|
}
|
|
521
603
|
return isBefore ? binarySearch(offset, positions, options, sliceStart, pivot) : binarySearch(offset, positions, options, pivot + 1, sliceEnd);
|
|
522
604
|
}
|
|
523
|
-
function exponentialSearch(offset, positions, index) {
|
|
605
|
+
function exponentialSearch(offset, positions, index, options = undefined) {
|
|
524
606
|
let interval = 1;
|
|
525
607
|
while (index < positions.length && Math.abs(positions[index]) < offset) {
|
|
526
608
|
index += interval;
|
|
527
609
|
interval *= 2;
|
|
528
610
|
}
|
|
529
|
-
return binarySearch(offset, positions,
|
|
611
|
+
return binarySearch(offset, positions, options, Math.floor(index / 2), Math.min(index, positions.length));
|
|
530
612
|
}
|
|
531
613
|
function getIndexesToRender({
|
|
532
614
|
firstIndex,
|
|
533
615
|
lastIndex,
|
|
534
|
-
|
|
616
|
+
bufferBefore,
|
|
617
|
+
bufferAfter,
|
|
535
618
|
minFirstIndex,
|
|
536
|
-
maxLastIndex
|
|
619
|
+
maxLastIndex,
|
|
620
|
+
positions,
|
|
621
|
+
lastSize
|
|
537
622
|
}) {
|
|
538
|
-
|
|
623
|
+
const firstPosition = positions[firstIndex] - bufferBefore;
|
|
624
|
+
const lastPosition = positions[lastIndex] + bufferAfter;
|
|
625
|
+
const firstIndexPadded = binarySearch(firstPosition, positions, {
|
|
626
|
+
atStart: true,
|
|
627
|
+
lastPosition: positions[positions.length - 1] + lastSize
|
|
628
|
+
});
|
|
629
|
+
const lastIndexPadded = binarySearch(lastPosition, positions);
|
|
630
|
+
return [clamp(firstIndexPadded, minFirstIndex, maxLastIndex), clamp(lastIndexPadded, minFirstIndex, maxLastIndex)];
|
|
539
631
|
}
|
|
540
632
|
export function areRenderContextsEqual(context1, context2) {
|
|
541
633
|
if (context1 === context2) {
|
|
@@ -547,4 +639,66 @@ export function computeOffsetLeft(columnPositions, renderContext, direction, pin
|
|
|
547
639
|
const factor = direction === 'ltr' ? 1 : -1;
|
|
548
640
|
const left = factor * (columnPositions[renderContext.firstColumnIndex] ?? 0) - (columnPositions[pinnedLeftLength] ?? 0);
|
|
549
641
|
return left;
|
|
642
|
+
}
|
|
643
|
+
function directionForDelta(dx, dy) {
|
|
644
|
+
if (dx === 0 && dy === 0) {
|
|
645
|
+
return ScrollDirection.NONE;
|
|
646
|
+
}
|
|
647
|
+
/* eslint-disable */
|
|
648
|
+
if (Math.abs(dy) >= Math.abs(dx)) {
|
|
649
|
+
if (dy > 0) {
|
|
650
|
+
return ScrollDirection.DOWN;
|
|
651
|
+
} else {
|
|
652
|
+
return ScrollDirection.UP;
|
|
653
|
+
}
|
|
654
|
+
} else {
|
|
655
|
+
if (dx > 0) {
|
|
656
|
+
return ScrollDirection.RIGHT;
|
|
657
|
+
} else {
|
|
658
|
+
return ScrollDirection.LEFT;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
/* eslint-enable */
|
|
662
|
+
}
|
|
663
|
+
function bufferForDirection(direction, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer) {
|
|
664
|
+
switch (direction) {
|
|
665
|
+
case ScrollDirection.NONE:
|
|
666
|
+
return {
|
|
667
|
+
rowAfter: rowBufferPx,
|
|
668
|
+
rowBefore: rowBufferPx,
|
|
669
|
+
columnAfter: columnBufferPx,
|
|
670
|
+
columnBefore: columnBufferPx
|
|
671
|
+
};
|
|
672
|
+
case ScrollDirection.LEFT:
|
|
673
|
+
return {
|
|
674
|
+
rowAfter: 0,
|
|
675
|
+
rowBefore: 0,
|
|
676
|
+
columnAfter: 0,
|
|
677
|
+
columnBefore: horizontalBuffer
|
|
678
|
+
};
|
|
679
|
+
case ScrollDirection.RIGHT:
|
|
680
|
+
return {
|
|
681
|
+
rowAfter: 0,
|
|
682
|
+
rowBefore: 0,
|
|
683
|
+
columnAfter: horizontalBuffer,
|
|
684
|
+
columnBefore: 0
|
|
685
|
+
};
|
|
686
|
+
case ScrollDirection.UP:
|
|
687
|
+
return {
|
|
688
|
+
rowAfter: 0,
|
|
689
|
+
rowBefore: verticalBuffer,
|
|
690
|
+
columnAfter: 0,
|
|
691
|
+
columnBefore: 0
|
|
692
|
+
};
|
|
693
|
+
case ScrollDirection.DOWN:
|
|
694
|
+
return {
|
|
695
|
+
rowAfter: verticalBuffer,
|
|
696
|
+
rowBefore: 0,
|
|
697
|
+
columnAfter: 0,
|
|
698
|
+
columnBefore: 0
|
|
699
|
+
};
|
|
700
|
+
default:
|
|
701
|
+
// eslint unable to figure out enum exhaustiveness
|
|
702
|
+
throw new Error('unreachable');
|
|
703
|
+
}
|
|
550
704
|
}
|
package/modern/index.js
CHANGED
|
@@ -62,6 +62,7 @@ export * from '../utils/fastMemo';
|
|
|
62
62
|
export { buildWarning } from '../utils/warning';
|
|
63
63
|
export { exportAs } from '../utils/exportAs';
|
|
64
64
|
export * from '../utils/getPublicApiRef';
|
|
65
|
+
export * from '../utils/cellBorderUtils';
|
|
65
66
|
export { useGridPrivateApiContext } from '../hooks/utils/useGridPrivateApiContext';
|
|
66
67
|
export * from '../hooks/utils';
|
|
67
68
|
export { serializeCellValue } from '../hooks/features/export/serializers/csvSerializer';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createSelector as reselectCreateSelector } from 'reselect';
|
|
2
2
|
import { buildWarning } from './warning';
|
|
3
3
|
const cache = new WeakMap();
|
|
4
|
-
const missingInstanceIdWarning = buildWarning(['MUI X: A selector was called without passing the instance ID, which may impact the performance of the grid.', 'To fix, call it with `apiRef`,
|
|
4
|
+
const missingInstanceIdWarning = buildWarning(['MUI X: A selector was called without passing the instance ID, which may impact the performance of the grid.', 'To fix, call it with `apiRef`, for example `mySelector(apiRef)`, or pass the instance ID explicitly, for example `mySelector(state, apiRef.current.instanceId)`.']);
|
|
5
5
|
function checkIsAPIRef(value) {
|
|
6
6
|
return 'current' in value && 'instanceId' in value.current;
|
|
7
7
|
}
|
package/modern/utils/domUtils.js
CHANGED
|
@@ -181,7 +181,7 @@ export function findGridCells(api, field) {
|
|
|
181
181
|
}
|
|
182
182
|
function queryRows(api) {
|
|
183
183
|
return api.virtualScrollerRef.current.querySelectorAll(
|
|
184
|
-
// Use > to ignore rows from nested data grids (
|
|
184
|
+
// Use > to ignore rows from nested data grids (for example in detail panel)
|
|
185
185
|
`:scope > div > div > .${gridClasses.row}`);
|
|
186
186
|
}
|
|
187
187
|
function parseCellColIndex(col) {
|
|
@@ -8,7 +8,7 @@ export const isEscapeKey = key => key === 'Escape';
|
|
|
8
8
|
*/
|
|
9
9
|
export const isTabKey = key => key === 'Tab';
|
|
10
10
|
|
|
11
|
-
// Non printable keys have a name,
|
|
11
|
+
// Non printable keys have a name, for example "ArrowRight", see the whole list:
|
|
12
12
|
// https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values
|
|
13
13
|
// So event.key.length === 1 is often enough.
|
|
14
14
|
//
|
|
@@ -108,10 +108,10 @@ DataGridRaw.propTypes = {
|
|
|
108
108
|
*/
|
|
109
109
|
clipboardCopyCellDelimiter: _propTypes.default.string,
|
|
110
110
|
/**
|
|
111
|
-
*
|
|
112
|
-
* @default
|
|
111
|
+
* Column region in pixels to render before/after the viewport
|
|
112
|
+
* @default 150
|
|
113
113
|
*/
|
|
114
|
-
|
|
114
|
+
columnBufferPx: _propTypes.default.number,
|
|
115
115
|
columnGroupingModel: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
116
116
|
/**
|
|
117
117
|
* Sets the height in pixel of the column headers in the Data Grid.
|
|
@@ -122,11 +122,6 @@ DataGridRaw.propTypes = {
|
|
|
122
122
|
* Set of columns of type [[GridColDef]][].
|
|
123
123
|
*/
|
|
124
124
|
columns: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
|
|
125
|
-
/**
|
|
126
|
-
* Number of rows from the `columnBuffer` that can be visible before a new slice is rendered.
|
|
127
|
-
* @default 3
|
|
128
|
-
*/
|
|
129
|
-
columnThreshold: _propTypes.default.number,
|
|
130
125
|
/**
|
|
131
126
|
* Set the column visibility model of the Data Grid.
|
|
132
127
|
* If defined, the Data Grid will ignore the `hide` property in [[GridColDef]].
|
|
@@ -474,6 +469,11 @@ DataGridRaw.propTypes = {
|
|
|
474
469
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
475
470
|
*/
|
|
476
471
|
onColumnWidthChange: _propTypes.default.func,
|
|
472
|
+
/**
|
|
473
|
+
* Callback fired when the density changes.
|
|
474
|
+
* @param {GridDensity} density New density value.
|
|
475
|
+
*/
|
|
476
|
+
onDensityChange: _propTypes.default.func,
|
|
477
477
|
/**
|
|
478
478
|
* Callback fired when the Filter model changes before the filters are applied.
|
|
479
479
|
* @param {GridFilterModel} model With all properties from [[GridFilterModel]].
|
|
@@ -616,10 +616,10 @@ DataGridRaw.propTypes = {
|
|
|
616
616
|
*/
|
|
617
617
|
processRowUpdate: _propTypes.default.func,
|
|
618
618
|
/**
|
|
619
|
-
*
|
|
620
|
-
* @default
|
|
619
|
+
* Row region in pixels to render before/after the viewport
|
|
620
|
+
* @default 150
|
|
621
621
|
*/
|
|
622
|
-
|
|
622
|
+
rowBufferPx: _propTypes.default.number,
|
|
623
623
|
/**
|
|
624
624
|
* Set the total number of rows, if it is different from the length of the value `rows` prop.
|
|
625
625
|
* If some rows have children (for instance in the tree data), this number represents the amount of top level rows.
|
|
@@ -643,8 +643,9 @@ DataGridRaw.propTypes = {
|
|
|
643
643
|
rowPositionsDebounceMs: _propTypes.default.number,
|
|
644
644
|
/**
|
|
645
645
|
* Set of rows of type [[GridRowsProp]].
|
|
646
|
+
* @default []
|
|
646
647
|
*/
|
|
647
|
-
rows: _propTypes.default.arrayOf(_propTypes.default.object)
|
|
648
|
+
rows: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
648
649
|
/**
|
|
649
650
|
* If `false`, the row selection mode is disabled.
|
|
650
651
|
* @default true
|
|
@@ -659,11 +660,6 @@ DataGridRaw.propTypes = {
|
|
|
659
660
|
* @default "margin"
|
|
660
661
|
*/
|
|
661
662
|
rowSpacingType: _propTypes.default.oneOf(['border', 'margin']),
|
|
662
|
-
/**
|
|
663
|
-
* Number of rows from the `rowBuffer` that can be visible before a new slice is rendered.
|
|
664
|
-
* @default 3
|
|
665
|
-
*/
|
|
666
|
-
rowThreshold: _propTypes.default.number,
|
|
667
663
|
/**
|
|
668
664
|
* Override the height/width of the Data Grid inner scrollbar.
|
|
669
665
|
*/
|
|
@@ -34,12 +34,10 @@ const DATA_GRID_PROPS_DEFAULT_VALUES = exports.DATA_GRID_PROPS_DEFAULT_VALUES =
|
|
|
34
34
|
autoPageSize: false,
|
|
35
35
|
checkboxSelection: false,
|
|
36
36
|
checkboxSelectionVisibleOnly: false,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
rowThreshold: 3,
|
|
37
|
+
columnBufferPx: 150,
|
|
38
|
+
rowBufferPx: 150,
|
|
39
|
+
rows: [],
|
|
41
40
|
rowSelection: true,
|
|
42
|
-
density: 'standard',
|
|
43
41
|
disableColumnFilter: false,
|
|
44
42
|
disableColumnMenu: false,
|
|
45
43
|
disableColumnSelector: false,
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.GridPagination = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
11
|
var _TablePagination = _interopRequireWildcard(require("@mui/material/TablePagination"));
|
|
11
12
|
var _styles = require("@mui/material/styles");
|
|
12
13
|
var _useGridSelector = require("../hooks/utils/useGridSelector");
|
|
@@ -88,4 +89,11 @@ const GridPagination = exports.GridPagination = /*#__PURE__*/React.forwardRef(fu
|
|
|
88
89
|
onPageChange: handlePageChange,
|
|
89
90
|
onRowsPerPageChange: handlePageSizeChange
|
|
90
91
|
}, apiRef.current.getLocaleText('MuiTablePagination'), props));
|
|
91
|
-
});
|
|
92
|
+
});
|
|
93
|
+
process.env.NODE_ENV !== "production" ? GridPagination.propTypes = {
|
|
94
|
+
// ----------------------------- Warning --------------------------------
|
|
95
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
96
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
97
|
+
// ----------------------------------------------------------------------
|
|
98
|
+
component: _propTypes.default.elementType
|
|
99
|
+
} : void 0;
|
|
@@ -137,7 +137,7 @@ function GridActionsCell(props) {
|
|
|
137
137
|
}
|
|
138
138
|
if (newIndex !== focusedButtonIndex) {
|
|
139
139
|
event.preventDefault(); // Prevent scrolling
|
|
140
|
-
event.stopPropagation(); // Don't stop propagation for other keys,
|
|
140
|
+
event.stopPropagation(); // Don't stop propagation for other keys, for example ArrowUp
|
|
141
141
|
setFocusedButtonIndex(newIndex);
|
|
142
142
|
}
|
|
143
143
|
};
|
|
@@ -70,6 +70,10 @@ process.env.NODE_ENV !== "production" ? GridActionsCellItem.propTypes = {
|
|
|
70
70
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
71
71
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
72
72
|
// ----------------------------------------------------------------------
|
|
73
|
+
/**
|
|
74
|
+
* from https://mui.com/material-ui/api/button-base/#ButtonBase-prop-component
|
|
75
|
+
*/
|
|
76
|
+
component: _propTypes.default.elementType,
|
|
73
77
|
icon: _propTypes.default.element,
|
|
74
78
|
label: _propTypes.default.string.isRequired,
|
|
75
79
|
showInMenu: _propTypes.default.bool
|