@mui/x-data-grid 7.0.0-beta.4 → 7.0.0-beta.6
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 +271 -61
- package/DataGrid/DataGrid.js +2 -0
- package/colDef/gridBooleanOperators.js +1 -1
- package/components/GridPinnedRows.d.ts +1 -2
- package/components/GridRow.d.ts +7 -9
- package/components/GridRow.js +41 -54
- package/components/cell/GridCell.d.ts +2 -3
- package/components/cell/GridCell.js +10 -10
- package/components/cell/GridSkeletonCell.d.ts +3 -2
- package/components/cell/GridSkeletonCell.js +14 -6
- package/components/columnSelection/GridCellCheckboxRenderer.js +6 -4
- package/components/columnsManagement/GridColumnsManagement.js +1 -1
- package/components/containers/GridRootStyles.js +9 -4
- package/components/virtualization/GridBottomContainer.js +1 -1
- package/components/virtualization/GridTopContainer.js +1 -1
- package/components/virtualization/GridVirtualScroller.js +7 -5
- package/components/virtualization/GridVirtualScrollerRenderZone.js +9 -3
- package/hooks/core/pipeProcessing/useGridPipeProcessing.js +22 -20
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +11 -8
- package/hooks/features/columns/gridColumnsSelector.d.ts +6 -0
- package/hooks/features/columns/gridColumnsSelector.js +8 -1
- package/hooks/features/columns/useGridColumns.js +4 -0
- package/hooks/features/dimensions/useGridDimensions.js +1 -0
- package/hooks/features/editing/useGridRowEditing.js +1 -2
- package/hooks/features/filter/useGridFilter.js +2 -2
- package/hooks/features/rows/useGridParamsApi.js +6 -10
- package/hooks/features/rows/useGridRows.js +8 -4
- package/hooks/features/rows/useGridRowsMeta.js +5 -13
- package/hooks/features/sorting/gridSortingUtils.js +9 -1
- package/hooks/features/sorting/useGridSorting.js +2 -2
- package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +0 -9
- package/hooks/features/virtualization/gridVirtualizationSelectors.js +0 -7
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +3 -0
- package/hooks/features/virtualization/useGridVirtualScroller.js +88 -138
- package/hooks/features/virtualization/useGridVirtualization.d.ts +0 -8
- package/hooks/features/virtualization/useGridVirtualization.js +1 -6
- package/hooks/utils/useTimeout.d.ts +5 -3
- package/hooks/utils/useTimeout.js +13 -5
- package/index.js +1 -1
- package/internals/index.d.ts +1 -1
- package/internals/index.js +1 -1
- package/models/api/gridApiCommon.d.ts +2 -1
- package/models/api/gridInfiniteLoaderApi.d.ts +6 -0
- package/models/api/gridInfiniteLoaderApi.js +1 -0
- package/models/colDef/gridColDef.d.ts +7 -0
- package/modern/DataGrid/DataGrid.js +2 -0
- package/modern/colDef/gridBooleanOperators.js +1 -1
- package/modern/components/GridRow.js +40 -53
- package/modern/components/cell/GridCell.js +10 -10
- package/modern/components/cell/GridSkeletonCell.js +14 -6
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +6 -4
- package/modern/components/columnsManagement/GridColumnsManagement.js +1 -1
- package/modern/components/containers/GridRootStyles.js +9 -4
- package/modern/components/virtualization/GridBottomContainer.js +1 -1
- package/modern/components/virtualization/GridTopContainer.js +1 -1
- package/modern/components/virtualization/GridVirtualScroller.js +7 -5
- package/modern/components/virtualization/GridVirtualScrollerRenderZone.js +8 -3
- package/modern/hooks/core/pipeProcessing/useGridPipeProcessing.js +22 -20
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +11 -8
- package/modern/hooks/features/columns/gridColumnsSelector.js +8 -1
- package/modern/hooks/features/columns/useGridColumns.js +2 -0
- package/modern/hooks/features/dimensions/useGridDimensions.js +1 -0
- package/modern/hooks/features/editing/useGridRowEditing.js +1 -2
- package/modern/hooks/features/filter/useGridFilter.js +2 -2
- package/modern/hooks/features/rows/useGridParamsApi.js +6 -10
- package/modern/hooks/features/rows/useGridRows.js +8 -4
- package/modern/hooks/features/rows/useGridRowsMeta.js +5 -13
- package/modern/hooks/features/sorting/gridSortingUtils.js +9 -1
- package/modern/hooks/features/sorting/useGridSorting.js +2 -2
- package/modern/hooks/features/virtualization/gridVirtualizationSelectors.js +0 -7
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +85 -136
- package/modern/hooks/features/virtualization/useGridVirtualization.js +1 -6
- package/modern/hooks/utils/useTimeout.js +13 -5
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -1
- package/modern/models/api/gridInfiniteLoaderApi.js +1 -0
- package/modern/utils/createSelector.js +12 -20
- package/modern/utils/utils.js +9 -0
- package/node/DataGrid/DataGrid.js +1 -0
- package/node/colDef/gridBooleanOperators.js +1 -1
- package/node/components/GridRow.js +40 -53
- package/node/components/cell/GridCell.js +10 -10
- package/node/components/cell/GridSkeletonCell.js +15 -7
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +6 -4
- package/node/components/columnsManagement/GridColumnsManagement.js +1 -1
- package/node/components/containers/GridRootStyles.js +9 -4
- package/node/components/virtualization/GridBottomContainer.js +1 -1
- package/node/components/virtualization/GridTopContainer.js +1 -1
- package/node/components/virtualization/GridVirtualScroller.js +7 -5
- package/node/components/virtualization/GridVirtualScrollerRenderZone.js +7 -2
- package/node/hooks/core/pipeProcessing/useGridPipeProcessing.js +22 -20
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +8 -5
- package/node/hooks/features/columns/gridColumnsSelector.js +9 -2
- package/node/hooks/features/columns/useGridColumns.js +2 -0
- package/node/hooks/features/dimensions/useGridDimensions.js +1 -0
- package/node/hooks/features/editing/useGridRowEditing.js +1 -2
- package/node/hooks/features/filter/useGridFilter.js +2 -2
- package/node/hooks/features/rows/useGridParamsApi.js +6 -10
- package/node/hooks/features/rows/useGridRows.js +8 -4
- package/node/hooks/features/rows/useGridRowsMeta.js +5 -13
- package/node/hooks/features/sorting/gridSortingUtils.js +9 -1
- package/node/hooks/features/sorting/useGridSorting.js +2 -2
- package/node/hooks/features/virtualization/gridVirtualizationSelectors.js +1 -8
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +86 -136
- package/node/hooks/features/virtualization/useGridVirtualization.js +2 -7
- package/node/hooks/utils/useTimeout.js +13 -4
- package/node/index.js +1 -1
- package/node/internals/index.js +0 -7
- package/node/models/api/gridInfiniteLoaderApi.js +5 -0
- package/node/utils/createSelector.js +14 -23
- package/node/utils/utils.js +12 -1
- package/package.json +2 -2
- package/utils/createSelector.d.ts +0 -1
- package/utils/createSelector.js +12 -22
- package/utils/utils.d.ts +4 -0
- package/utils/utils.js +9 -0
|
@@ -32,7 +32,7 @@ import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
|
32
32
|
* * `apiRef.current.requestPipeProcessorsApplication` is called for the given group.
|
|
33
33
|
*/
|
|
34
34
|
export const useGridPipeProcessing = apiRef => {
|
|
35
|
-
const
|
|
35
|
+
const cache = React.useRef({});
|
|
36
36
|
const isRunning = React.useRef(false);
|
|
37
37
|
const runAppliers = React.useCallback(groupCache => {
|
|
38
38
|
if (isRunning.current || !groupCache) {
|
|
@@ -45,52 +45,54 @@ export const useGridPipeProcessing = apiRef => {
|
|
|
45
45
|
isRunning.current = false;
|
|
46
46
|
}, []);
|
|
47
47
|
const registerPipeProcessor = React.useCallback((group, id, processor) => {
|
|
48
|
-
if (!
|
|
49
|
-
|
|
48
|
+
if (!cache.current[group]) {
|
|
49
|
+
cache.current[group] = {
|
|
50
50
|
processors: new Map(),
|
|
51
|
+
processorsAsArray: [],
|
|
51
52
|
appliers: {}
|
|
52
53
|
};
|
|
53
54
|
}
|
|
54
|
-
const groupCache =
|
|
55
|
+
const groupCache = cache.current[group];
|
|
55
56
|
const oldProcessor = groupCache.processors.get(id);
|
|
56
57
|
if (oldProcessor !== processor) {
|
|
57
58
|
groupCache.processors.set(id, processor);
|
|
59
|
+
groupCache.processorsAsArray = Array.from(cache.current[group].processors.values());
|
|
58
60
|
runAppliers(groupCache);
|
|
59
61
|
}
|
|
60
62
|
return () => {
|
|
61
|
-
|
|
63
|
+
cache.current[group].processors.delete(id);
|
|
64
|
+
cache.current[group].processorsAsArray = Array.from(cache.current[group].processors.values());
|
|
62
65
|
};
|
|
63
66
|
}, [runAppliers]);
|
|
64
67
|
const registerPipeApplier = React.useCallback((group, id, applier) => {
|
|
65
|
-
if (!
|
|
66
|
-
|
|
68
|
+
if (!cache.current[group]) {
|
|
69
|
+
cache.current[group] = {
|
|
67
70
|
processors: new Map(),
|
|
71
|
+
processorsAsArray: [],
|
|
68
72
|
appliers: {}
|
|
69
73
|
};
|
|
70
74
|
}
|
|
71
|
-
|
|
75
|
+
cache.current[group].appliers[id] = applier;
|
|
72
76
|
return () => {
|
|
73
|
-
const _appliers =
|
|
77
|
+
const _appliers = cache.current[group].appliers,
|
|
74
78
|
otherAppliers = _objectWithoutPropertiesLoose(_appliers, [id].map(_toPropertyKey));
|
|
75
|
-
|
|
79
|
+
cache.current[group].appliers = otherAppliers;
|
|
76
80
|
};
|
|
77
81
|
}, []);
|
|
78
82
|
const requestPipeProcessorsApplication = React.useCallback(group => {
|
|
79
|
-
|
|
80
|
-
runAppliers(groupCache);
|
|
83
|
+
runAppliers(cache.current[group]);
|
|
81
84
|
}, [runAppliers]);
|
|
82
85
|
const applyPipeProcessors = React.useCallback((...args) => {
|
|
83
86
|
const [group, value, context] = args;
|
|
84
|
-
if (!
|
|
87
|
+
if (!cache.current[group]) {
|
|
85
88
|
return value;
|
|
86
89
|
}
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}, value);
|
|
90
|
+
const processors = cache.current[group].processorsAsArray;
|
|
91
|
+
let result = value;
|
|
92
|
+
for (let i = 0; i < processors.length; i += 1) {
|
|
93
|
+
result = processors[i](result, context);
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
94
96
|
}, []);
|
|
95
97
|
const preProcessingPrivateApi = {
|
|
96
98
|
registerPipeProcessor,
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { unstable_useForkRef as useForkRef } from '@mui/utils';
|
|
4
|
-
import { styled } from '@mui/material/styles';
|
|
4
|
+
import { styled, useTheme } from '@mui/material/styles';
|
|
5
5
|
import { useGridSelector } from '../../utils';
|
|
6
6
|
import { useGridRootProps } from '../../utils/useGridRootProps';
|
|
7
7
|
import { useGridPrivateApiContext } from '../../utils/useGridPrivateApiContext';
|
|
8
8
|
import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
9
9
|
import { GridColumnHeaderItem } from '../../../components/columnHeaders/GridColumnHeaderItem';
|
|
10
10
|
import { gridDimensionsSelector } from '../dimensions';
|
|
11
|
-
import {
|
|
11
|
+
import { gridRenderContextColumnsSelector, gridVirtualizationColumnEnabledSelector } from '../virtualization';
|
|
12
|
+
import { computeOffsetLeft } from '../virtualization/useGridVirtualScroller';
|
|
12
13
|
import { GridColumnGroupHeader } from '../../../components/columnHeaders/GridColumnGroupHeader';
|
|
13
|
-
import { GridPinnedColumnPosition, gridVisiblePinnedColumnDefinitionsSelector } from '../columns';
|
|
14
|
+
import { GridPinnedColumnPosition, gridColumnPositionsSelector, gridVisiblePinnedColumnDefinitionsSelector } from '../columns';
|
|
14
15
|
import { GridScrollbarFillerCell as ScrollbarFiller } from '../../../components/GridScrollbarFillerCell';
|
|
15
16
|
import { gridClasses } from '../../../constants/gridClasses';
|
|
16
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
18
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
19
|
const SpaceFiller = styled('div')({
|
|
19
20
|
/* GridRootStyles conflict */
|
|
20
|
-
'
|
|
21
|
+
'&&&': {
|
|
21
22
|
padding: 0,
|
|
22
23
|
width: 'calc(var(--DataGrid-width) - var(--DataGrid-columnsTotalWidth))'
|
|
23
24
|
}
|
|
@@ -49,14 +50,16 @@ export const useGridColumnHeaders = props => {
|
|
|
49
50
|
const [dragCol, setDragCol] = React.useState('');
|
|
50
51
|
const [resizeCol, setResizeCol] = React.useState('');
|
|
51
52
|
const apiRef = useGridPrivateApiContext();
|
|
53
|
+
const theme = useTheme();
|
|
52
54
|
const rootProps = useGridRootProps();
|
|
53
55
|
const hasVirtualization = useGridSelector(apiRef, gridVirtualizationColumnEnabledSelector);
|
|
54
56
|
const innerRef = React.useRef(null);
|
|
55
57
|
const handleInnerRef = useForkRef(innerRefProp, innerRef);
|
|
56
58
|
const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
|
|
57
|
-
const
|
|
59
|
+
const columnPositions = useGridSelector(apiRef, gridColumnPositionsSelector);
|
|
58
60
|
const renderContext = useGridSelector(apiRef, gridRenderContextColumnsSelector);
|
|
59
|
-
const
|
|
61
|
+
const pinnedColumns = useGridSelector(apiRef, gridVisiblePinnedColumnDefinitionsSelector);
|
|
62
|
+
const offsetLeft = computeOffsetLeft(columnPositions, renderContext, theme.direction, pinnedColumns.left.length);
|
|
60
63
|
React.useEffect(() => {
|
|
61
64
|
apiRef.current.columnHeadersContainerElementRef.current.scrollLeft = 0;
|
|
62
65
|
}, [apiRef]);
|
|
@@ -88,8 +91,8 @@ export const useGridColumnHeaders = props => {
|
|
|
88
91
|
const getFillers = (params, children, leftOverflow, borderTop = false) => {
|
|
89
92
|
const isPinnedRight = (params == null ? void 0 : params.position) === GridPinnedColumnPosition.RIGHT;
|
|
90
93
|
const isNotPinned = (params == null ? void 0 : params.position) === undefined;
|
|
91
|
-
const hasScrollbarFiller =
|
|
92
|
-
const leftOffsetWidth =
|
|
94
|
+
const hasScrollbarFiller = pinnedColumns.right.length > 0 && isPinnedRight || pinnedColumns.right.length === 0 && isNotPinned;
|
|
95
|
+
const leftOffsetWidth = offsetLeft - leftOverflow;
|
|
93
96
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
94
97
|
children: [isNotPinned && /*#__PURE__*/_jsx("div", {
|
|
95
98
|
role: "presentation",
|
|
@@ -69,3 +69,9 @@ export declare const gridFilterableColumnDefinitionsSelector: import("../../../u
|
|
|
69
69
|
* @category Columns
|
|
70
70
|
*/
|
|
71
71
|
export declare const gridFilterableColumnLookupSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, GridColumnLookup>;
|
|
72
|
+
/**
|
|
73
|
+
* Checks if some column has a colSpan field.
|
|
74
|
+
* @category Columns
|
|
75
|
+
* @ignore - Do not document
|
|
76
|
+
*/
|
|
77
|
+
export declare const gridHasColSpanSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, boolean>;
|
|
@@ -135,4 +135,11 @@ export const gridFilterableColumnLookupSelector = createSelectorMemoized(gridCol
|
|
|
135
135
|
acc[col.field] = col;
|
|
136
136
|
}
|
|
137
137
|
return acc;
|
|
138
|
-
}, {}));
|
|
138
|
+
}, {}));
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Checks if some column has a colSpan field.
|
|
142
|
+
* @category Columns
|
|
143
|
+
* @ignore - Do not document
|
|
144
|
+
*/
|
|
145
|
+
export const gridHasColSpanSelector = createSelectorMemoized(gridColumnDefinitionsSelector, columns => columns.some(column => column.colSpan !== undefined));
|
|
@@ -43,9 +43,11 @@ export function useGridColumns(apiRef, props) {
|
|
|
43
43
|
changeEvent: 'columnVisibilityModelChange'
|
|
44
44
|
});
|
|
45
45
|
const setGridColumnsState = React.useCallback(columnsState => {
|
|
46
|
+
var _apiRef$current$updat, _apiRef$current;
|
|
46
47
|
logger.debug('Updating columns state.');
|
|
47
48
|
apiRef.current.setState(mergeColumnsState(columnsState));
|
|
48
49
|
apiRef.current.publishEvent('columnsChange', columnsState.orderedFields);
|
|
50
|
+
(_apiRef$current$updat = (_apiRef$current = apiRef.current).updateRenderContext) == null || _apiRef$current$updat.call(_apiRef$current);
|
|
49
51
|
apiRef.current.forceUpdate();
|
|
50
52
|
}, [logger, apiRef]);
|
|
51
53
|
|
|
@@ -66,6 +68,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
66
68
|
const setColumnVisibilityModel = React.useCallback(model => {
|
|
67
69
|
const currentModel = gridColumnVisibilityModelSelector(apiRef);
|
|
68
70
|
if (currentModel !== model) {
|
|
71
|
+
var _apiRef$current$updat2, _apiRef$current2;
|
|
69
72
|
apiRef.current.setState(state => _extends({}, state, {
|
|
70
73
|
columns: createColumnsState({
|
|
71
74
|
apiRef,
|
|
@@ -75,6 +78,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
75
78
|
keepOnlyColumnsToUpsert: false
|
|
76
79
|
})
|
|
77
80
|
}));
|
|
81
|
+
(_apiRef$current$updat2 = (_apiRef$current2 = apiRef.current).updateRenderContext) == null || _apiRef$current$updat2.call(_apiRef$current2);
|
|
78
82
|
apiRef.current.forceUpdate();
|
|
79
83
|
}
|
|
80
84
|
}, [apiRef]);
|
|
@@ -229,6 +229,7 @@ export function useGridDimensions(apiRef, props) {
|
|
|
229
229
|
set('--DataGrid-headersTotalHeight', `${dimensions.headersTotalHeight}px`);
|
|
230
230
|
set('--DataGrid-topContainerHeight', `${dimensions.topContainerHeight}px`);
|
|
231
231
|
set('--DataGrid-bottomContainerHeight', `${dimensions.bottomContainerHeight}px`);
|
|
232
|
+
set('--height', `${dimensions.rowHeight}px`);
|
|
232
233
|
}, [root, dimensions]);
|
|
233
234
|
const isFirstSizing = React.useRef(true);
|
|
234
235
|
const handleResize = React.useCallback(size => {
|
|
@@ -21,7 +21,7 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
21
21
|
const [rowModesModel, setRowModesModel] = React.useState({});
|
|
22
22
|
const rowModesModelRef = React.useRef(rowModesModel);
|
|
23
23
|
const prevRowModesModel = React.useRef({});
|
|
24
|
-
const focusTimeout = React.useRef(
|
|
24
|
+
const focusTimeout = React.useRef();
|
|
25
25
|
const nextFocusedCell = React.useRef(null);
|
|
26
26
|
const {
|
|
27
27
|
processRowUpdate,
|
|
@@ -77,7 +77,6 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
77
77
|
nextFocusedCell.current = null;
|
|
78
78
|
focusTimeout.current = setTimeout(() => {
|
|
79
79
|
var _nextFocusedCell$curr;
|
|
80
|
-
focusTimeout.current = null;
|
|
81
80
|
if (((_nextFocusedCell$curr = nextFocusedCell.current) == null ? void 0 : _nextFocusedCell$curr.id) !== params.id) {
|
|
82
81
|
// The row might have been deleted during the click
|
|
83
82
|
if (!apiRef.current.getRow(params.id)) {
|
|
@@ -107,7 +107,7 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
107
107
|
const filterModel = gridFilterModelSelector(apiRef);
|
|
108
108
|
const existingItems = [...filterModel.items];
|
|
109
109
|
items.forEach(item => {
|
|
110
|
-
const itemIndex =
|
|
110
|
+
const itemIndex = existingItems.findIndex(filterItem => filterItem.id === item.id);
|
|
111
111
|
if (itemIndex === -1) {
|
|
112
112
|
existingItems.push(item);
|
|
113
113
|
} else {
|
|
@@ -115,7 +115,7 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
115
115
|
}
|
|
116
116
|
});
|
|
117
117
|
apiRef.current.setFilterModel(_extends({}, filterModel, {
|
|
118
|
-
items
|
|
118
|
+
items: existingItems
|
|
119
119
|
}), 'upsertFilterItems');
|
|
120
120
|
}, [apiRef]);
|
|
121
121
|
const deleteFilterItem = React.useCallback(itemToDelete => {
|
|
@@ -31,12 +31,13 @@ export function useGridParamsApi(apiRef) {
|
|
|
31
31
|
}, [apiRef]);
|
|
32
32
|
const getCellParams = React.useCallback((id, field) => {
|
|
33
33
|
const colDef = apiRef.current.getColumn(field);
|
|
34
|
-
const value = apiRef.current.getCellValue(id, field);
|
|
35
34
|
const row = apiRef.current.getRow(id);
|
|
36
35
|
const rowNode = apiRef.current.getRowNode(id);
|
|
37
36
|
if (!row || !rowNode) {
|
|
38
37
|
throw new MissingRowIdError(`No row with id #${id} found`);
|
|
39
38
|
}
|
|
39
|
+
const rawValue = row[field];
|
|
40
|
+
const value = colDef != null && colDef.valueGetter ? colDef.valueGetter(rawValue, row, colDef, apiRef) : rawValue;
|
|
40
41
|
const cellFocus = gridFocusCellSelector(apiRef);
|
|
41
42
|
const cellTabIndex = gridTabIndexCellSelector(apiRef);
|
|
42
43
|
const params = {
|
|
@@ -60,19 +61,14 @@ export function useGridParamsApi(apiRef) {
|
|
|
60
61
|
}, [apiRef]);
|
|
61
62
|
const getCellValue = React.useCallback((id, field) => {
|
|
62
63
|
const colDef = apiRef.current.getColumn(field);
|
|
63
|
-
if (!colDef || !colDef.valueGetter) {
|
|
64
|
-
const rowModel = apiRef.current.getRow(id);
|
|
65
|
-
if (!rowModel) {
|
|
66
|
-
throw new MissingRowIdError(`No row with id #${id} found`);
|
|
67
|
-
}
|
|
68
|
-
return rowModel[field];
|
|
69
|
-
}
|
|
70
64
|
const row = apiRef.current.getRow(id);
|
|
71
65
|
if (!row) {
|
|
72
66
|
throw new MissingRowIdError(`No row with id #${id} found`);
|
|
73
67
|
}
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
if (!colDef || !colDef.valueGetter) {
|
|
69
|
+
return row[field];
|
|
70
|
+
}
|
|
71
|
+
return colDef.valueGetter(row[colDef.field], row, colDef, apiRef);
|
|
76
72
|
}, [apiRef]);
|
|
77
73
|
const getRowValue = React.useCallback((row, colDef) => {
|
|
78
74
|
const field = colDef.field;
|
|
@@ -266,13 +266,16 @@ export const useGridRows = (apiRef, props) => {
|
|
|
266
266
|
const dataRowIdToIdLookup = _extends({}, gridRowsDataRowIdToIdLookupSelector(apiRef));
|
|
267
267
|
const rootGroup = tree[GRID_ROOT_GROUP_ID];
|
|
268
268
|
const rootGroupChildren = [...rootGroup.children];
|
|
269
|
+
const seenIds = new Set();
|
|
269
270
|
for (let i = 0; i < newRows.length; i += 1) {
|
|
270
271
|
const rowModel = newRows[i];
|
|
271
272
|
const rowId = getRowIdFromRowModel(rowModel, props.getRowId, 'A row was provided without id when calling replaceRows().');
|
|
272
|
-
const [
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
273
|
+
const [removedRowId] = rootGroupChildren.splice(firstRowToRender + i, 1, rowId);
|
|
274
|
+
if (!seenIds.has(removedRowId)) {
|
|
275
|
+
delete dataRowIdToModelLookup[removedRowId];
|
|
276
|
+
delete dataRowIdToIdLookup[removedRowId];
|
|
277
|
+
delete tree[removedRowId];
|
|
278
|
+
}
|
|
276
279
|
const rowTreeNodeConfig = {
|
|
277
280
|
id: rowId,
|
|
278
281
|
depth: 0,
|
|
@@ -283,6 +286,7 @@ export const useGridRows = (apiRef, props) => {
|
|
|
283
286
|
dataRowIdToModelLookup[rowId] = rowModel;
|
|
284
287
|
dataRowIdToIdLookup[rowId] = rowId;
|
|
285
288
|
tree[rowId] = rowTreeNodeConfig;
|
|
289
|
+
seenIds.add(rowId);
|
|
286
290
|
}
|
|
287
291
|
tree[GRID_ROOT_GROUP_ID] = _extends({}, rootGroup, {
|
|
288
292
|
children: rootGroupChildren
|
|
@@ -107,14 +107,9 @@ export const useGridRowsMeta = (apiRef, props) => {
|
|
|
107
107
|
} else {
|
|
108
108
|
rowsHeightLookup.current[row.id].needsFirstMeasurement = false;
|
|
109
109
|
}
|
|
110
|
-
const initialHeights = {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (/^base[A-Z]/.test(key)) {
|
|
114
|
-
initialHeights[key] = sizes[key];
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
initialHeights.baseCenter = baseRowHeight;
|
|
110
|
+
const initialHeights = {
|
|
111
|
+
baseCenter: baseRowHeight
|
|
112
|
+
};
|
|
118
113
|
if (getRowSpacing) {
|
|
119
114
|
var _spacing$top, _spacing$bottom;
|
|
120
115
|
const indexRelativeToCurrentPage = apiRef.current.getRowIndexRelativeToVisibleRows(row.id);
|
|
@@ -133,19 +128,16 @@ export const useGridRowsMeta = (apiRef, props) => {
|
|
|
133
128
|
const positions = [];
|
|
134
129
|
const currentPageTotalHeight = currentPage.rows.reduce((acc, row) => {
|
|
135
130
|
positions.push(acc);
|
|
136
|
-
let maximumBaseSize = 0;
|
|
137
131
|
let otherSizes = 0;
|
|
138
132
|
const processedSizes = calculateRowProcessedSizes(row);
|
|
139
133
|
/* eslint-disable-next-line no-restricted-syntax, guard-for-in */
|
|
140
134
|
for (const key in processedSizes) {
|
|
141
135
|
const value = processedSizes[key];
|
|
142
|
-
if (
|
|
143
|
-
maximumBaseSize = value > maximumBaseSize ? value : maximumBaseSize;
|
|
144
|
-
} else {
|
|
136
|
+
if (key !== 'baseCenter') {
|
|
145
137
|
otherSizes += value;
|
|
146
138
|
}
|
|
147
139
|
}
|
|
148
|
-
return acc +
|
|
140
|
+
return acc + processedSizes.baseCenter + otherSizes;
|
|
149
141
|
}, 0);
|
|
150
142
|
pinnedRows == null || (_pinnedRows$top = pinnedRows.top) == null || _pinnedRows$top.forEach(row => {
|
|
151
143
|
calculateRowProcessedSizes(row);
|
|
@@ -28,7 +28,15 @@ const parseSortItem = (sortItem, apiRef) => {
|
|
|
28
28
|
if (!column || sortItem.sort === null) {
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
let comparator;
|
|
32
|
+
if (column.getSortComparator) {
|
|
33
|
+
comparator = column.getSortComparator(sortItem.sort);
|
|
34
|
+
} else {
|
|
35
|
+
comparator = isDesc(sortItem.sort) ? (...args) => -1 * column.sortComparator(...args) : column.sortComparator;
|
|
36
|
+
}
|
|
37
|
+
if (!comparator) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
32
40
|
const getSortCellParams = id => ({
|
|
33
41
|
id,
|
|
34
42
|
field: column.field,
|
|
@@ -42,7 +42,7 @@ export const useGridSorting = (apiRef, props) => {
|
|
|
42
42
|
const existingIdx = sortModel.findIndex(c => c.field === field);
|
|
43
43
|
let newSortModel = [...sortModel];
|
|
44
44
|
if (existingIdx > -1) {
|
|
45
|
-
if (
|
|
45
|
+
if ((sortItem == null ? void 0 : sortItem.sort) == null) {
|
|
46
46
|
newSortModel.splice(existingIdx, 1);
|
|
47
47
|
} else {
|
|
48
48
|
newSortModel.splice(existingIdx, 1, sortItem);
|
|
@@ -120,7 +120,7 @@ export const useGridSorting = (apiRef, props) => {
|
|
|
120
120
|
const sortItem = createSortItem(column, direction);
|
|
121
121
|
let sortModel;
|
|
122
122
|
if (!allowMultipleSorting || props.disableMultipleColumnsSorting) {
|
|
123
|
-
sortModel =
|
|
123
|
+
sortModel = (sortItem == null ? void 0 : sortItem.sort) == null ? [] : [sortItem];
|
|
124
124
|
} else {
|
|
125
125
|
sortModel = upsertSortModel(column.field, sortItem);
|
|
126
126
|
}
|
|
@@ -21,15 +21,6 @@ export declare const gridVirtualizationColumnEnabledSelector: import("../../../u
|
|
|
21
21
|
* @ignore - do not document.
|
|
22
22
|
*/
|
|
23
23
|
export declare const gridRenderContextSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, GridRenderContext>;
|
|
24
|
-
/**
|
|
25
|
-
* Get the offsets
|
|
26
|
-
* @category Virtualization
|
|
27
|
-
* @ignore - do not document.
|
|
28
|
-
*/
|
|
29
|
-
export declare const gridOffsetsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, {
|
|
30
|
-
top: number;
|
|
31
|
-
left: number;
|
|
32
|
-
}>;
|
|
33
24
|
/**
|
|
34
25
|
* Get the render context, with only columns filled in.
|
|
35
26
|
* This is cached, so it can be used to only re-render when the column interval changes.
|
|
@@ -24,13 +24,6 @@ export const gridVirtualizationColumnEnabledSelector = createSelector(gridVirtua
|
|
|
24
24
|
*/
|
|
25
25
|
export const gridRenderContextSelector = createSelector(gridVirtualizationSelector, state => state.renderContext);
|
|
26
26
|
|
|
27
|
-
/**
|
|
28
|
-
* Get the offsets
|
|
29
|
-
* @category Virtualization
|
|
30
|
-
* @ignore - do not document.
|
|
31
|
-
*/
|
|
32
|
-
export const gridOffsetsSelector = createSelector(gridVirtualizationSelector, state => state.offsets);
|
|
33
|
-
|
|
34
27
|
/**
|
|
35
28
|
* Get the render context, with only columns filled in.
|
|
36
29
|
* This is cached, so it can be used to only re-render when the column interval changes.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { Theme } from '@mui/material/styles';
|
|
2
3
|
import { GridPinnedRowsPosition } from '../rows/gridRowsInterfaces';
|
|
3
4
|
import { GridRenderContext, GridRowEntry, GridRowId } from '../../../models';
|
|
4
5
|
export declare const EMPTY_DETAIL_PANELS: Readonly<Map<GridRowId, React.ReactNode>>;
|
|
@@ -9,6 +10,7 @@ export declare const useGridVirtualScroller: () => {
|
|
|
9
10
|
getRows: (params?: {
|
|
10
11
|
rows?: GridRowEntry<import("../../../models").GridValidRowModel>[] | undefined;
|
|
11
12
|
position?: keyof import("../rows/gridRowsInterfaces").GridPinnedRowsState | undefined;
|
|
13
|
+
renderContext?: GridRenderContext | undefined;
|
|
12
14
|
}) => React.ReactNode[];
|
|
13
15
|
getContainerProps: () => {
|
|
14
16
|
ref: React.RefObject<HTMLDivElement>;
|
|
@@ -39,3 +41,4 @@ export declare const useGridVirtualScroller: () => {
|
|
|
39
41
|
};
|
|
40
42
|
};
|
|
41
43
|
export declare function areRenderContextsEqual(context1: GridRenderContext, context2: GridRenderContext): boolean;
|
|
44
|
+
export declare function computeOffsetLeft(columnPositions: number[], renderContext: GridRenderContext, direction: Theme['direction'], pinnedLeftLength: number): number;
|