@mui/x-data-grid-pro 5.12.1 → 5.13.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 +155 -8
- package/DataGridPro/DataGridPro.js +1 -1
- package/DataGridPro/useDataGridProComponent.js +1 -3
- package/components/DataGridProColumnHeaders.js +10 -7
- package/components/DataGridProVirtualScroller.js +7 -18
- package/components/GridDetailPanel.d.ts +19 -0
- package/components/GridDetailPanel.js +65 -0
- package/hooks/features/columnPinning/useGridColumnPinning.d.ts +1 -1
- package/hooks/features/detailPanel/gridDetailPanelInterface.d.ts +20 -1
- package/hooks/features/detailPanel/gridDetailPanelSelector.d.ts +14 -3
- package/hooks/features/detailPanel/gridDetailPanelSelector.js +9 -1
- package/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +2 -2
- package/hooks/features/detailPanel/index.d.ts +1 -1
- package/hooks/features/detailPanel/index.js +1 -1
- package/hooks/features/detailPanel/useGridDetailPanel.d.ts +1 -1
- package/hooks/features/detailPanel/useGridDetailPanel.js +113 -19
- package/hooks/features/detailPanel/useGridDetailPanelCache.js +10 -3
- package/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +5 -2
- package/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -2
- package/index.js +1 -1
- package/internals/index.d.ts +0 -1
- package/internals/index.js +0 -1
- package/legacy/DataGridPro/DataGridPro.js +1 -1
- package/legacy/DataGridPro/useDataGridProComponent.js +1 -3
- package/legacy/components/DataGridProColumnHeaders.js +10 -7
- package/legacy/components/DataGridProVirtualScroller.js +12 -26
- package/legacy/components/GridDetailPanel.js +72 -0
- package/legacy/hooks/features/detailPanel/gridDetailPanelSelector.js +15 -2
- package/legacy/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +3 -1
- package/legacy/hooks/features/detailPanel/index.js +1 -1
- package/legacy/hooks/features/detailPanel/useGridDetailPanel.js +112 -19
- package/legacy/hooks/features/detailPanel/useGridDetailPanelCache.js +10 -3
- package/legacy/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +5 -2
- package/legacy/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -2
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +0 -1
- package/legacy/utils/releaseInfo.js +1 -1
- package/models/dataGridProProps.d.ts +2 -2
- package/modern/DataGridPro/DataGridPro.js +1 -1
- package/modern/DataGridPro/useDataGridProComponent.js +1 -3
- package/modern/components/DataGridProColumnHeaders.js +11 -6
- package/modern/components/DataGridProVirtualScroller.js +7 -18
- package/modern/components/GridDetailPanel.js +65 -0
- package/modern/hooks/features/detailPanel/gridDetailPanelSelector.js +9 -1
- package/modern/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +2 -2
- package/modern/hooks/features/detailPanel/index.js +1 -1
- package/modern/hooks/features/detailPanel/useGridDetailPanel.js +109 -17
- package/modern/hooks/features/detailPanel/useGridDetailPanelCache.js +8 -3
- package/modern/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +5 -2
- package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -2
- package/modern/index.js +1 -1
- package/modern/internals/index.js +0 -1
- package/modern/utils/releaseInfo.js +1 -1
- package/node/DataGridPro/DataGridPro.js +1 -1
- package/node/DataGridPro/useDataGridProComponent.js +1 -4
- package/node/components/DataGridProColumnHeaders.js +11 -7
- package/node/components/DataGridProVirtualScroller.js +8 -19
- package/node/components/GridDetailPanel.js +83 -0
- package/node/hooks/features/detailPanel/gridDetailPanelSelector.js +12 -2
- package/node/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +2 -2
- package/node/hooks/features/detailPanel/index.js +25 -11
- package/node/hooks/features/detailPanel/useGridDetailPanel.js +110 -17
- package/node/hooks/features/detailPanel/useGridDetailPanelCache.js +10 -3
- package/node/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +8 -2
- package/node/hooks/features/treeData/useGridTreeDataPreProcessors.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/index.js +0 -9
- package/node/utils/releaseInfo.js +1 -1
- package/package.json +5 -5
- package/utils/releaseInfo.js +1 -1
|
@@ -1,18 +1,55 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { useGridSelector, useGridApiEventHandler, useGridApiMethod } from '@mui/x-data-grid';
|
|
3
|
+
import { useGridSelector, useGridApiEventHandler, useGridApiMethod, gridRowIdsSelector } from '@mui/x-data-grid';
|
|
4
4
|
import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
|
|
5
5
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from './gridDetailPanelToggleColDef';
|
|
6
|
-
import { gridDetailPanelExpandedRowIdsSelector, gridDetailPanelExpandedRowsContentCacheSelector, gridDetailPanelExpandedRowsHeightCacheSelector } from './gridDetailPanelSelector';
|
|
6
|
+
import { gridDetailPanelExpandedRowIdsSelector, gridDetailPanelExpandedRowsContentCacheSelector, gridDetailPanelExpandedRowsHeightCacheSelector, gridDetailPanelRawHeightCacheSelector } from './gridDetailPanelSelector';
|
|
7
7
|
export const detailPanelStateInitializer = (state, props) => {
|
|
8
8
|
var _ref, _props$detailPanelExp, _props$initialState, _props$initialState$d;
|
|
9
9
|
|
|
10
10
|
return _extends({}, state, {
|
|
11
11
|
detailPanel: {
|
|
12
|
+
heightCache: {},
|
|
12
13
|
expandedRowIds: (_ref = (_props$detailPanelExp = props.detailPanelExpandedRowIds) != null ? _props$detailPanelExp : (_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$d = _props$initialState.detailPanel) == null ? void 0 : _props$initialState$d.expandedRowIds) != null ? _ref : []
|
|
13
14
|
}
|
|
14
15
|
});
|
|
15
16
|
};
|
|
17
|
+
|
|
18
|
+
function cacheContentAndHeight(apiRef, getDetailPanelContent, getDetailPanelHeight, previousHeightCache) {
|
|
19
|
+
if (typeof getDetailPanelContent !== 'function') {
|
|
20
|
+
return {};
|
|
21
|
+
} // TODO change to lazy approach using a Proxy
|
|
22
|
+
// only call getDetailPanelContent when asked for an id
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const rowIds = gridRowIdsSelector(apiRef);
|
|
26
|
+
const contentCache = rowIds.reduce((acc, id) => {
|
|
27
|
+
const params = apiRef.current.getRowParams(id);
|
|
28
|
+
acc[id] = getDetailPanelContent(params);
|
|
29
|
+
return acc;
|
|
30
|
+
}, {});
|
|
31
|
+
const heightCache = rowIds.reduce((acc, id) => {
|
|
32
|
+
var _previousHeightCache$;
|
|
33
|
+
|
|
34
|
+
if (contentCache[id] == null) {
|
|
35
|
+
return acc;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const params = apiRef.current.getRowParams(id);
|
|
39
|
+
const height = getDetailPanelHeight(params);
|
|
40
|
+
const autoHeight = height === 'auto';
|
|
41
|
+
acc[id] = {
|
|
42
|
+
autoHeight,
|
|
43
|
+
height: autoHeight ? (_previousHeightCache$ = previousHeightCache[id]) == null ? void 0 : _previousHeightCache$.height : height
|
|
44
|
+
};
|
|
45
|
+
return acc;
|
|
46
|
+
}, {});
|
|
47
|
+
return {
|
|
48
|
+
contentCache,
|
|
49
|
+
heightCache
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
16
53
|
export const useGridDetailPanel = (apiRef, props) => {
|
|
17
54
|
const expandedRowIds = useGridSelector(apiRef, gridDetailPanelExpandedRowIdsSelector);
|
|
18
55
|
const contentCache = useGridSelector(apiRef, gridDetailPanelExpandedRowsContentCacheSelector);
|
|
@@ -51,22 +88,6 @@ export const useGridDetailPanel = (apiRef, props) => {
|
|
|
51
88
|
}, [apiRef, props.getDetailPanelContent]);
|
|
52
89
|
useGridApiEventHandler(apiRef, 'cellClick', handleCellClick);
|
|
53
90
|
useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
54
|
-
const addDetailHeight = React.useCallback((initialValue, row) => {
|
|
55
|
-
var _heightCache$row$id;
|
|
56
|
-
|
|
57
|
-
if (expandedRowIds.length === 0 || !expandedRowIds.includes(row.id)) {
|
|
58
|
-
return _extends({}, initialValue, {
|
|
59
|
-
detail: 0
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const heightCache = gridDetailPanelExpandedRowsHeightCacheSelector(apiRef.current.state);
|
|
64
|
-
return _extends({}, initialValue, {
|
|
65
|
-
detail: (_heightCache$row$id = heightCache[row.id]) != null ? _heightCache$row$id : 0 // Fallback to zero because the cache might not be ready yet (e.g. page was changed)
|
|
66
|
-
|
|
67
|
-
});
|
|
68
|
-
}, [apiRef, expandedRowIds]);
|
|
69
|
-
useGridRegisterPipeProcessor(apiRef, 'rowHeight', addDetailHeight);
|
|
70
91
|
apiRef.current.unstable_registerControlState({
|
|
71
92
|
stateId: 'detailPanels',
|
|
72
93
|
propModel: props.detailPanelExpandedRowIds,
|
|
@@ -99,10 +120,36 @@ export const useGridDetailPanel = (apiRef, props) => {
|
|
|
99
120
|
});
|
|
100
121
|
apiRef.current.forceUpdate();
|
|
101
122
|
}, [apiRef]);
|
|
123
|
+
const storeDetailPanelHeight = React.useCallback((id, height) => {
|
|
124
|
+
const heightCache = gridDetailPanelRawHeightCacheSelector(apiRef.current.state);
|
|
125
|
+
|
|
126
|
+
if (!heightCache[id] || heightCache[id].height === height) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
apiRef.current.setState(state => {
|
|
131
|
+
return _extends({}, state, {
|
|
132
|
+
detailPanel: _extends({}, state.detailPanel, {
|
|
133
|
+
heightCache: _extends({}, heightCache, {
|
|
134
|
+
[id]: _extends({}, heightCache[id], {
|
|
135
|
+
height
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
apiRef.current.unstable_requestPipeProcessorsApplication('rowHeight');
|
|
142
|
+
}, [apiRef]);
|
|
143
|
+
const detailPanelHasAutoHeight = React.useCallback(id => {
|
|
144
|
+
const heightCache = gridDetailPanelRawHeightCacheSelector(apiRef.current.state);
|
|
145
|
+
return heightCache[id] ? heightCache[id].autoHeight : false;
|
|
146
|
+
}, [apiRef]);
|
|
102
147
|
const detailPanelApi = {
|
|
103
148
|
toggleDetailPanel,
|
|
104
149
|
getExpandedDetailPanels,
|
|
105
|
-
setExpandedDetailPanels
|
|
150
|
+
setExpandedDetailPanels,
|
|
151
|
+
unstable_storeDetailPanelHeight: storeDetailPanelHeight,
|
|
152
|
+
unstable_detailPanelHasAutoHeight: detailPanelHasAutoHeight
|
|
106
153
|
};
|
|
107
154
|
useGridApiMethod(apiRef, detailPanelApi, 'detailPanelApi');
|
|
108
155
|
React.useEffect(() => {
|
|
@@ -114,4 +161,51 @@ export const useGridDetailPanel = (apiRef, props) => {
|
|
|
114
161
|
}
|
|
115
162
|
}
|
|
116
163
|
}, [apiRef, props.detailPanelExpandedRowIds]);
|
|
164
|
+
const updateCachesAndForceUpdate = React.useCallback(() => {
|
|
165
|
+
apiRef.current.setState(state => {
|
|
166
|
+
return _extends({}, state, {
|
|
167
|
+
detailPanel: _extends({}, state.detailPanel, cacheContentAndHeight(apiRef, props.getDetailPanelContent, props.getDetailPanelHeight, state.detailPanel.heightCache))
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
apiRef.current.forceUpdate();
|
|
171
|
+
}, [apiRef, props.getDetailPanelContent, props.getDetailPanelHeight]);
|
|
172
|
+
useGridApiEventHandler(apiRef, 'sortedRowsSet', updateCachesAndForceUpdate);
|
|
173
|
+
const previousGetDetailPanelContentProp = React.useRef();
|
|
174
|
+
const previousGetDetailPanelHeightProp = React.useRef();
|
|
175
|
+
const updateCachesIfNeeded = React.useCallback(() => {
|
|
176
|
+
if (props.getDetailPanelContent === previousGetDetailPanelContentProp.current && props.getDetailPanelHeight === previousGetDetailPanelHeightProp.current) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
apiRef.current.setState(state => {
|
|
181
|
+
return _extends({}, state, {
|
|
182
|
+
detailPanel: _extends({}, state.detailPanel, cacheContentAndHeight(apiRef, props.getDetailPanelContent, props.getDetailPanelHeight, state.detailPanel.heightCache))
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
previousGetDetailPanelContentProp.current = props.getDetailPanelContent;
|
|
186
|
+
previousGetDetailPanelHeightProp.current = props.getDetailPanelHeight;
|
|
187
|
+
}, [apiRef, props.getDetailPanelContent, props.getDetailPanelHeight]);
|
|
188
|
+
const addDetailHeight = React.useCallback((initialValue, row) => {
|
|
189
|
+
var _heightCache$row$id;
|
|
190
|
+
|
|
191
|
+
if (!expandedRowIds || expandedRowIds.length === 0 || !expandedRowIds.includes(row.id)) {
|
|
192
|
+
return _extends({}, initialValue, {
|
|
193
|
+
detail: 0
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
updateCachesIfNeeded();
|
|
198
|
+
const heightCache = gridDetailPanelExpandedRowsHeightCacheSelector(apiRef);
|
|
199
|
+
return _extends({}, initialValue, {
|
|
200
|
+
detail: (_heightCache$row$id = heightCache[row.id]) != null ? _heightCache$row$id : 0 // Fallback to zero because the cache might not be ready yet (e.g. page was changed)
|
|
201
|
+
|
|
202
|
+
});
|
|
203
|
+
}, [apiRef, expandedRowIds, updateCachesIfNeeded]);
|
|
204
|
+
useGridRegisterPipeProcessor(apiRef, 'rowHeight', addDetailHeight);
|
|
205
|
+
const isFirstRender = React.useRef(true);
|
|
206
|
+
|
|
207
|
+
if (isFirstRender.current) {
|
|
208
|
+
isFirstRender.current = false;
|
|
209
|
+
updateCachesIfNeeded();
|
|
210
|
+
}
|
|
117
211
|
};
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useGridApiEventHandler, gridRowIdsSelector } from '@mui/x-data-grid';
|
|
4
4
|
|
|
5
|
-
function cacheContentAndHeight(apiRef, getDetailPanelContent, getDetailPanelHeight) {
|
|
5
|
+
function cacheContentAndHeight(apiRef, getDetailPanelContent, getDetailPanelHeight, previousHeightCache) {
|
|
6
6
|
if (typeof getDetailPanelContent !== 'function') {
|
|
7
7
|
return {};
|
|
8
8
|
} // TODO change to lazy approach using a Proxy
|
|
@@ -16,12 +16,19 @@ function cacheContentAndHeight(apiRef, getDetailPanelContent, getDetailPanelHeig
|
|
|
16
16
|
return acc;
|
|
17
17
|
}, {});
|
|
18
18
|
const heightCache = rowIds.reduce((acc, id) => {
|
|
19
|
+
var _previousHeightCache$;
|
|
20
|
+
|
|
19
21
|
if (contentCache[id] == null) {
|
|
20
22
|
return acc;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
const params = apiRef.current.getRowParams(id);
|
|
24
|
-
|
|
26
|
+
const height = getDetailPanelHeight(params);
|
|
27
|
+
const autoHeight = height === 'auto';
|
|
28
|
+
acc[id] = {
|
|
29
|
+
autoHeight,
|
|
30
|
+
height: !autoHeight ? height : (_previousHeightCache$ = previousHeightCache[id]) == null ? void 0 : _previousHeightCache$.height
|
|
31
|
+
};
|
|
25
32
|
return acc;
|
|
26
33
|
}, {});
|
|
27
34
|
return {
|
|
@@ -34,7 +41,7 @@ export const useGridDetailPanelCache = (apiRef, props) => {
|
|
|
34
41
|
const updateCaches = React.useCallback(() => {
|
|
35
42
|
apiRef.current.setState(state => {
|
|
36
43
|
return _extends({}, state, {
|
|
37
|
-
detailPanel: _extends({}, state.detailPanel, cacheContentAndHeight(apiRef, props.getDetailPanelContent, props.getDetailPanelHeight))
|
|
44
|
+
detailPanel: _extends({}, state.detailPanel, cacheContentAndHeight(apiRef, props.getDetailPanelContent, props.getDetailPanelHeight, state.detailPanel.heightCache))
|
|
38
45
|
});
|
|
39
46
|
});
|
|
40
47
|
apiRef.current.forceUpdate();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
|
|
3
4
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD, GRID_DETAIL_PANEL_TOGGLE_COL_DEF } from './gridDetailPanelToggleColDef';
|
|
@@ -21,8 +22,10 @@ export const useGridDetailPanelPreProcessors = (apiRef, props) => {
|
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
columnsState.all = [GRID_DETAIL_PANEL_TOGGLE_FIELD, ...columnsState.all];
|
|
24
|
-
columnsState.lookup[GRID_DETAIL_PANEL_TOGGLE_FIELD] = GRID_DETAIL_PANEL_TOGGLE_COL_DEF
|
|
25
|
+
columnsState.lookup[GRID_DETAIL_PANEL_TOGGLE_FIELD] = _extends({}, GRID_DETAIL_PANEL_TOGGLE_COL_DEF, {
|
|
26
|
+
headerName: apiRef.current.getLocaleText('detailPanelToggle')
|
|
27
|
+
});
|
|
25
28
|
return columnsState;
|
|
26
|
-
}, [props.getDetailPanelContent]);
|
|
29
|
+
}, [apiRef, props.getDetailPanelContent]);
|
|
27
30
|
useGridRegisterPipeProcessor(apiRef, 'hydrateColumns', addToggleColumn);
|
|
28
31
|
};
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["hideDescendantCount"];
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import { gridRowIdsSelector, gridRowTreeSelector, useFirstRender } from '@mui/x-data-grid';
|
|
5
|
+
import { gridRowIdsSelector, gridRowTreeSelector, useFirstRender, GRID_CHECKBOX_SELECTION_FIELD } from '@mui/x-data-grid';
|
|
6
6
|
import { useGridRegisterPipeProcessor, useGridRegisterStrategyProcessor } from '@mui/x-data-grid/internals';
|
|
7
7
|
import { GRID_TREE_DATA_GROUPING_COL_DEF, GRID_TREE_DATA_GROUPING_COL_DEF_FORCED_PROPERTIES } from './gridTreeDataGroupColDef';
|
|
8
8
|
import { filterRowTreeFromTreeData, TREE_DATA_STRATEGY } from './gridTreeDataUtils';
|
|
@@ -61,7 +61,7 @@ export const useGridTreeDataPreProcessors = (apiRef, props) => {
|
|
|
61
61
|
columnsState.lookup[groupingColDefField] = newGroupingColumn;
|
|
62
62
|
|
|
63
63
|
if (prevGroupingColumn == null) {
|
|
64
|
-
const index = columnsState.all[0] ===
|
|
64
|
+
const index = columnsState.all[0] === GRID_CHECKBOX_SELECTION_FIELD ? 1 : 0;
|
|
65
65
|
columnsState.all = [...columnsState.all.slice(0, index), groupingColDefField, ...columnsState.all.slice(index)];
|
|
66
66
|
}
|
|
67
67
|
} else if (!shouldHaveGroupingColumn && prevGroupingColumn) {
|
package/index.js
CHANGED
package/internals/index.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export { useGridColumnPinning, columnPinningStateInitializer, } from '../hooks/f
|
|
|
6
6
|
export { useGridColumnPinningPreProcessors } from '../hooks/features/columnPinning/useGridColumnPinningPreProcessors';
|
|
7
7
|
export { useGridColumnReorder, columnReorderStateInitializer, } from '../hooks/features/columnReorder/useGridColumnReorder';
|
|
8
8
|
export { useGridDetailPanel, detailPanelStateInitializer, } from '../hooks/features/detailPanel/useGridDetailPanel';
|
|
9
|
-
export { useGridDetailPanelCache } from '../hooks/features/detailPanel/useGridDetailPanelCache';
|
|
10
9
|
export { useGridDetailPanelPreProcessors } from '../hooks/features/detailPanel/useGridDetailPanelPreProcessors';
|
|
11
10
|
export { useGridInfiniteLoader } from '../hooks/features/infiniteLoader/useGridInfiniteLoader';
|
|
12
11
|
export { useGridRowReorder } from '../hooks/features/rowReorder/useGridRowReorder';
|
package/internals/index.js
CHANGED
|
@@ -6,7 +6,6 @@ export { useGridColumnPinning, columnPinningStateInitializer } from '../hooks/fe
|
|
|
6
6
|
export { useGridColumnPinningPreProcessors } from '../hooks/features/columnPinning/useGridColumnPinningPreProcessors';
|
|
7
7
|
export { useGridColumnReorder, columnReorderStateInitializer } from '../hooks/features/columnReorder/useGridColumnReorder';
|
|
8
8
|
export { useGridDetailPanel, detailPanelStateInitializer } from '../hooks/features/detailPanel/useGridDetailPanel';
|
|
9
|
-
export { useGridDetailPanelCache } from '../hooks/features/detailPanel/useGridDetailPanelCache';
|
|
10
9
|
export { useGridDetailPanelPreProcessors } from '../hooks/features/detailPanel/useGridDetailPanelPreProcessors';
|
|
11
10
|
export { useGridInfiniteLoader } from '../hooks/features/infiniteLoader/useGridInfiniteLoader';
|
|
12
11
|
export { useGridRowReorder } from '../hooks/features/rowReorder/useGridRowReorder';
|
|
@@ -318,7 +318,7 @@ DataGridProRaw.propTypes = {
|
|
|
318
318
|
/**
|
|
319
319
|
* Function that returns the height of the row detail panel.
|
|
320
320
|
* @param {GridRowParams} params With all properties from [[GridRowParams]].
|
|
321
|
-
* @returns {number} The height in pixels.
|
|
321
|
+
* @returns {number | string} The height in pixels or "auto" to use the content height.
|
|
322
322
|
* @default "() => 500"
|
|
323
323
|
*/
|
|
324
324
|
getDetailPanelHeight: PropTypes.func,
|
|
@@ -8,7 +8,6 @@ import { useGridTreeDataPreProcessors } from '../hooks/features/treeData/useGrid
|
|
|
8
8
|
import { useGridColumnPinning, columnPinningStateInitializer } from '../hooks/features/columnPinning/useGridColumnPinning';
|
|
9
9
|
import { useGridColumnPinningPreProcessors } from '../hooks/features/columnPinning/useGridColumnPinningPreProcessors';
|
|
10
10
|
import { useGridDetailPanel, detailPanelStateInitializer } from '../hooks/features/detailPanel/useGridDetailPanel';
|
|
11
|
-
import { useGridDetailPanelCache } from '../hooks/features/detailPanel/useGridDetailPanelCache';
|
|
12
11
|
import { useGridDetailPanelPreProcessors } from '../hooks/features/detailPanel/useGridDetailPanelPreProcessors';
|
|
13
12
|
import { useGridRowReorder } from '../hooks/features/rowReorder/useGridRowReorder';
|
|
14
13
|
import { useGridRowReorderPreProcessors } from '../hooks/features/rowReorder/useGridRowReorderPreProcessors';
|
|
@@ -51,13 +50,12 @@ export var useDataGridProComponent = function useDataGridProComponent(inputApiRe
|
|
|
51
50
|
useGridTreeData(apiRef);
|
|
52
51
|
useGridKeyboardNavigation(apiRef, props);
|
|
53
52
|
useGridSelection(apiRef, props);
|
|
54
|
-
useGridDetailPanel(apiRef, props);
|
|
55
53
|
useGridColumnPinning(apiRef, props);
|
|
56
54
|
useGridColumns(apiRef, props);
|
|
57
55
|
useGridRows(apiRef, props);
|
|
58
56
|
useGridParamsApi(apiRef);
|
|
57
|
+
useGridDetailPanel(apiRef, props);
|
|
59
58
|
useGridColumnSpanning(apiRef);
|
|
60
|
-
useGridDetailPanelCache(apiRef, props);
|
|
61
59
|
var useGridEditing = (_props$experimentalFe2 = props.experimentalFeatures) != null && _props$experimentalFe2.newEditingApi ? useGridEditing_new : useGridEditing_old;
|
|
62
60
|
useGridEditing(apiRef, props);
|
|
63
61
|
useGridFocus(apiRef, props);
|
|
@@ -6,6 +6,7 @@ var _excluded = ["style", "className", "innerRef"];
|
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
8
8
|
import { styled, alpha } from '@mui/material/styles';
|
|
9
|
+
import { useEventCallback } from '@mui/material/utils';
|
|
9
10
|
import { getDataGridUtilityClass, gridClasses, useGridSelector, useGridApiEventHandler, gridVisibleColumnFieldsSelector, GridColumnHeaderSeparatorSides } from '@mui/x-data-grid';
|
|
10
11
|
import { GridColumnHeaders, GridColumnHeadersInner, useGridColumnHeaders } from '@mui/x-data-grid/internals';
|
|
11
12
|
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
@@ -79,17 +80,19 @@ export var DataGridProColumnHeaders = /*#__PURE__*/React.forwardRef(function Dat
|
|
|
79
80
|
scrollbarSize = _React$useState2[0],
|
|
80
81
|
setScrollbarSize = _React$useState2[1];
|
|
81
82
|
|
|
82
|
-
var handleContentSizeChange =
|
|
83
|
-
var
|
|
83
|
+
var handleContentSizeChange = useEventCallback(function () {
|
|
84
|
+
var rootDimensions = apiRef.current.getRootDimensions();
|
|
84
85
|
|
|
85
|
-
if (!
|
|
86
|
+
if (!rootDimensions) {
|
|
86
87
|
return;
|
|
87
|
-
}
|
|
88
|
+
}
|
|
88
89
|
|
|
90
|
+
var newScrollbarSize = rootDimensions.hasScrollY ? rootDimensions.scrollBarSize : 0;
|
|
89
91
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
if (scrollbarSize !== newScrollbarSize) {
|
|
93
|
+
setScrollbarSize(newScrollbarSize);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
93
96
|
useGridApiEventHandler(apiRef, 'virtualScrollerContentSizeChange', handleContentSizeChange);
|
|
94
97
|
var pinnedColumns = useGridSelector(apiRef, gridPinnedColumnsSelector);
|
|
95
98
|
|
|
@@ -6,7 +6,6 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
6
6
|
var _excluded = ["className", "disableVirtualization"];
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import { styled, alpha } from '@mui/material/styles';
|
|
9
|
-
import Box from '@mui/material/Box';
|
|
10
9
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
11
10
|
import { useGridSelector, getDataGridUtilityClass, gridClasses, gridVisibleColumnFieldsSelector, gridRowsMetaSelector, useGridApiEventHandler } from '@mui/x-data-grid';
|
|
12
11
|
import { GridVirtualScroller, GridVirtualScrollerContent, GridVirtualScrollerRenderZone, useGridVirtualScroller } from '@mui/x-data-grid/internals';
|
|
@@ -14,6 +13,7 @@ import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
|
14
13
|
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
15
14
|
import { gridPinnedColumnsSelector, GridPinnedPosition } from '../hooks/features/columnPinning';
|
|
16
15
|
import { gridDetailPanelExpandedRowsContentCacheSelector, gridDetailPanelExpandedRowsHeightCacheSelector, gridDetailPanelExpandedRowIdsSelector } from '../hooks/features/detailPanel';
|
|
16
|
+
import { GridDetailPanel } from './GridDetailPanel';
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
18
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
19
|
export var filterColumns = function filterColumns(pinnedColumns, columns) {
|
|
@@ -81,31 +81,15 @@ var VirtualScrollerDetailPanels = styled('div', {
|
|
|
81
81
|
})({
|
|
82
82
|
position: 'relative'
|
|
83
83
|
});
|
|
84
|
-
var VirtualScrollerDetailPanel = styled(Box, {
|
|
85
|
-
name: 'MuiDataGrid',
|
|
86
|
-
slot: 'DetailPanel',
|
|
87
|
-
overridesResolver: function overridesResolver(props, styles) {
|
|
88
|
-
return styles.detailPanel;
|
|
89
|
-
}
|
|
90
|
-
})(function (_ref) {
|
|
91
|
-
var theme = _ref.theme;
|
|
92
|
-
return {
|
|
93
|
-
zIndex: 2,
|
|
94
|
-
width: '100%',
|
|
95
|
-
position: 'absolute',
|
|
96
|
-
backgroundColor: theme.palette.background.default,
|
|
97
|
-
overflow: 'auto'
|
|
98
|
-
};
|
|
99
|
-
});
|
|
100
84
|
var VirtualScrollerPinnedColumns = styled('div', {
|
|
101
85
|
name: 'MuiDataGrid',
|
|
102
86
|
slot: 'PinnedColumns',
|
|
103
87
|
overridesResolver: function overridesResolver(props, styles) {
|
|
104
88
|
return [_defineProperty({}, "&.".concat(gridClasses['pinnedColumns--left']), styles['pinnedColumns--left']), _defineProperty({}, "&.".concat(gridClasses['pinnedColumns--right']), styles['pinnedColumns--right']), styles.pinnedColumns];
|
|
105
89
|
}
|
|
106
|
-
})(function (
|
|
107
|
-
var theme =
|
|
108
|
-
ownerState =
|
|
90
|
+
})(function (_ref3) {
|
|
91
|
+
var theme = _ref3.theme,
|
|
92
|
+
ownerState = _ref3.ownerState;
|
|
109
93
|
return _extends({
|
|
110
94
|
position: 'sticky',
|
|
111
95
|
overflow: 'hidden',
|
|
@@ -135,8 +119,8 @@ var DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGrid
|
|
|
135
119
|
var detailPanelsHeights = useGridSelector(apiRef, gridDetailPanelExpandedRowsHeightCacheSelector);
|
|
136
120
|
var leftColumns = React.useRef(null);
|
|
137
121
|
var rightColumns = React.useRef(null);
|
|
138
|
-
var handleRenderZonePositioning = React.useCallback(function (
|
|
139
|
-
var top =
|
|
122
|
+
var handleRenderZonePositioning = React.useCallback(function (_ref4) {
|
|
123
|
+
var top = _ref4.top;
|
|
140
124
|
|
|
141
125
|
if (leftColumns.current) {
|
|
142
126
|
leftColumns.current.style.transform = "translate3d(0px, ".concat(top, "px, 0px)");
|
|
@@ -227,15 +211,17 @@ var DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGrid
|
|
|
227
211
|
var exists = rowIndex !== undefined;
|
|
228
212
|
|
|
229
213
|
if ( /*#__PURE__*/React.isValidElement(content) && exists) {
|
|
230
|
-
var
|
|
214
|
+
var hasAutoHeight = apiRef.current.unstable_detailPanelHasAutoHeight(id);
|
|
215
|
+
var height = hasAutoHeight ? 'auto' : detailPanelsHeights[id];
|
|
231
216
|
var sizes = apiRef.current.unstable_getRowInternalSizes(id);
|
|
232
217
|
var spacingTop = (sizes == null ? void 0 : sizes.spacingTop) || 0;
|
|
233
218
|
var top = rowsMeta.positions[rowIndex] + apiRef.current.unstable_getRowHeight(id) + spacingTop;
|
|
234
|
-
panels.push( /*#__PURE__*/_jsx(
|
|
219
|
+
panels.push( /*#__PURE__*/_jsx(GridDetailPanel, {
|
|
220
|
+
rowId: id,
|
|
235
221
|
style: {
|
|
236
|
-
top: top
|
|
237
|
-
height: height
|
|
222
|
+
top: top
|
|
238
223
|
},
|
|
224
|
+
height: height,
|
|
239
225
|
className: classes.detailPanel,
|
|
240
226
|
children: content
|
|
241
227
|
}, i));
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["rowId", "height", "style"];
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import Box from '@mui/material/Box';
|
|
7
|
+
import { styled } from '@mui/material/styles';
|
|
8
|
+
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
var DetailPanel = styled(Box, {
|
|
11
|
+
name: 'MuiDataGrid',
|
|
12
|
+
slot: 'DetailPanel',
|
|
13
|
+
overridesResolver: function overridesResolver(props, styles) {
|
|
14
|
+
return styles.detailPanel;
|
|
15
|
+
}
|
|
16
|
+
})(function (_ref) {
|
|
17
|
+
var theme = _ref.theme;
|
|
18
|
+
return {
|
|
19
|
+
zIndex: 2,
|
|
20
|
+
width: '100%',
|
|
21
|
+
position: 'absolute',
|
|
22
|
+
backgroundColor: theme.palette.background.default,
|
|
23
|
+
overflow: 'auto'
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
var GridDetailPanel = function GridDetailPanel(props) {
|
|
28
|
+
var rowId = props.rowId,
|
|
29
|
+
height = props.height,
|
|
30
|
+
_props$style = props.style,
|
|
31
|
+
styleProp = _props$style === void 0 ? {} : _props$style,
|
|
32
|
+
other = _objectWithoutProperties(props, _excluded);
|
|
33
|
+
|
|
34
|
+
var apiRef = useGridApiContext();
|
|
35
|
+
var ref = React.useRef();
|
|
36
|
+
React.useLayoutEffect(function () {
|
|
37
|
+
if (height === 'auto' && ref.current && typeof ResizeObserver === 'undefined') {
|
|
38
|
+
// Fallback for IE
|
|
39
|
+
apiRef.current.unstable_storeDetailPanelHeight(rowId, ref.current.clientHeight);
|
|
40
|
+
}
|
|
41
|
+
}, [apiRef, height, rowId]);
|
|
42
|
+
React.useLayoutEffect(function () {
|
|
43
|
+
var hasFixedHeight = height !== 'auto';
|
|
44
|
+
|
|
45
|
+
if (!ref.current || hasFixedHeight || typeof ResizeObserver === 'undefined') {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
var resizeObserver = new ResizeObserver(function (entries) {
|
|
50
|
+
var _entries = _slicedToArray(entries, 1),
|
|
51
|
+
entry = _entries[0];
|
|
52
|
+
|
|
53
|
+
var observedHeight = entry.borderBoxSize && entry.borderBoxSize.length > 0 ? entry.borderBoxSize[0].blockSize : entry.contentRect.height;
|
|
54
|
+
apiRef.current.unstable_storeDetailPanelHeight(rowId, observedHeight);
|
|
55
|
+
});
|
|
56
|
+
resizeObserver.observe(ref.current);
|
|
57
|
+
return function () {
|
|
58
|
+
return resizeObserver.disconnect();
|
|
59
|
+
};
|
|
60
|
+
}, [apiRef, height, rowId]);
|
|
61
|
+
|
|
62
|
+
var style = _extends({}, styleProp, {
|
|
63
|
+
height: height
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return /*#__PURE__*/_jsx(DetailPanel, _extends({
|
|
67
|
+
ref: ref,
|
|
68
|
+
style: style
|
|
69
|
+
}, other));
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export { GridDetailPanel };
|
|
@@ -1,9 +1,22 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { createSelector } from '@mui/x-data-grid/internals';
|
|
1
3
|
export var gridDetailPanelExpandedRowIdsSelector = function gridDetailPanelExpandedRowIdsSelector(state) {
|
|
2
4
|
return state.detailPanel.expandedRowIds;
|
|
3
5
|
};
|
|
4
6
|
export var gridDetailPanelExpandedRowsContentCacheSelector = function gridDetailPanelExpandedRowsContentCacheSelector(state) {
|
|
5
7
|
return state.detailPanel.contentCache;
|
|
6
8
|
};
|
|
7
|
-
export var
|
|
9
|
+
export var gridDetailPanelRawHeightCacheSelector = function gridDetailPanelRawHeightCacheSelector(state) {
|
|
8
10
|
return state.detailPanel.heightCache;
|
|
9
|
-
};
|
|
11
|
+
}; // TODO v6: Make this selector return the full object, including the autoHeight flag
|
|
12
|
+
|
|
13
|
+
export var gridDetailPanelExpandedRowsHeightCacheSelector = createSelector(gridDetailPanelRawHeightCacheSelector, function (heightCache) {
|
|
14
|
+
return Object.entries(heightCache).reduce(function (acc, _ref) {
|
|
15
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
16
|
+
id = _ref2[0],
|
|
17
|
+
height = _ref2[1].height;
|
|
18
|
+
|
|
19
|
+
acc[id] = height || 0;
|
|
20
|
+
return acc;
|
|
21
|
+
}, {});
|
|
22
|
+
});
|
|
@@ -7,7 +7,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
7
7
|
export var GRID_DETAIL_PANEL_TOGGLE_FIELD = '__detail_panel_toggle__';
|
|
8
8
|
export var GRID_DETAIL_PANEL_TOGGLE_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
9
9
|
field: GRID_DETAIL_PANEL_TOGGLE_FIELD,
|
|
10
|
-
headerName: '',
|
|
11
10
|
type: 'detailPanelToggle',
|
|
12
11
|
editable: false,
|
|
13
12
|
sortable: false,
|
|
@@ -24,5 +23,8 @@ export var GRID_DETAIL_PANEL_TOGGLE_COL_DEF = _extends({}, GRID_STRING_COL_DEF,
|
|
|
24
23
|
},
|
|
25
24
|
renderCell: function renderCell(params) {
|
|
26
25
|
return /*#__PURE__*/_jsx(GridDetailPanelToggleCell, _extends({}, params));
|
|
26
|
+
},
|
|
27
|
+
renderHeader: function renderHeader() {
|
|
28
|
+
return null;
|
|
27
29
|
}
|
|
28
30
|
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from './gridDetailPanelToggleColDef';
|
|
2
|
-
export
|
|
2
|
+
export { gridDetailPanelExpandedRowIdsSelector, gridDetailPanelExpandedRowsContentCacheSelector, gridDetailPanelExpandedRowsHeightCacheSelector } from './gridDetailPanelSelector';
|
|
3
3
|
export * from './gridDetailPanelInterface';
|