@mui/x-data-grid-pro 5.14.0 → 5.15.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 +62 -5
- package/DataGridPro/DataGridPro.js +15 -0
- package/DataGridPro/useDataGridProComponent.js +5 -0
- package/components/DataGridProVirtualScroller.js +198 -35
- package/components/GridRowReorderCell.d.ts +1 -1
- package/components/GridRowReorderCell.js +7 -1
- package/hooks/features/index.d.ts +1 -0
- package/hooks/features/index.js +2 -1
- package/hooks/features/rowPinning/gridRowPinningInterface.d.ts +17 -0
- package/hooks/features/rowPinning/gridRowPinningInterface.js +1 -0
- package/hooks/features/rowPinning/gridRowPinningSelector.d.ts +1 -0
- package/hooks/features/rowPinning/gridRowPinningSelector.js +1 -0
- package/hooks/features/rowPinning/index.d.ts +1 -0
- package/hooks/features/rowPinning/index.js +1 -0
- package/hooks/features/rowPinning/useGridRowPinning.d.ts +6 -0
- package/hooks/features/rowPinning/useGridRowPinning.js +71 -0
- package/hooks/features/rowPinning/useGridRowPinningPreProcessors.d.ts +34 -0
- package/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +89 -0
- package/hooks/features/rowReorder/useGridRowReorder.js +6 -0
- package/index.js +1 -1
- package/internals/index.d.ts +2 -0
- package/internals/index.js +2 -0
- package/legacy/DataGridPro/DataGridPro.js +15 -0
- package/legacy/DataGridPro/useDataGridProComponent.js +5 -0
- package/legacy/components/DataGridProVirtualScroller.js +187 -25
- package/legacy/components/GridRowReorderCell.js +4 -0
- package/legacy/hooks/features/index.js +2 -1
- package/legacy/hooks/features/rowPinning/gridRowPinningInterface.js +1 -0
- package/legacy/hooks/features/rowPinning/gridRowPinningSelector.js +1 -0
- package/legacy/hooks/features/rowPinning/index.js +1 -0
- package/legacy/hooks/features/rowPinning/useGridRowPinning.js +71 -0
- package/legacy/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +89 -0
- package/legacy/hooks/features/rowReorder/useGridRowReorder.js +6 -0
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +2 -0
- package/legacy/utils/releaseInfo.js +1 -1
- package/models/dataGridProProps.d.ts +11 -5
- package/models/gridApiPro.d.ts +2 -2
- package/modern/DataGridPro/DataGridPro.js +15 -0
- package/modern/DataGridPro/useDataGridProComponent.js +5 -0
- package/modern/components/DataGridProVirtualScroller.js +198 -35
- package/modern/components/GridRowReorderCell.js +7 -1
- package/modern/hooks/features/index.js +2 -1
- package/modern/hooks/features/rowPinning/gridRowPinningInterface.js +1 -0
- package/modern/hooks/features/rowPinning/gridRowPinningSelector.js +1 -0
- package/modern/hooks/features/rowPinning/index.js +1 -0
- package/modern/hooks/features/rowPinning/useGridRowPinning.js +63 -0
- package/modern/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +85 -0
- package/modern/hooks/features/rowReorder/useGridRowReorder.js +4 -0
- package/modern/index.js +1 -1
- package/modern/internals/index.js +2 -0
- package/modern/utils/releaseInfo.js +1 -1
- package/node/DataGridPro/DataGridPro.js +15 -0
- package/node/DataGridPro/useDataGridProComponent.js +7 -0
- package/node/components/DataGridProVirtualScroller.js +198 -34
- package/node/components/GridRowReorderCell.js +7 -1
- package/node/hooks/features/index.js +13 -0
- package/node/hooks/features/rowPinning/gridRowPinningInterface.js +5 -0
- package/node/hooks/features/rowPinning/gridRowPinningSelector.js +19 -0
- package/node/hooks/features/rowPinning/index.js +18 -0
- package/node/hooks/features/rowPinning/useGridRowPinning.js +92 -0
- package/node/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +105 -0
- package/node/hooks/features/rowReorder/useGridRowReorder.js +6 -0
- package/node/index.js +1 -1
- package/node/internals/index.js +32 -0
- package/node/utils/releaseInfo.js +1 -1
- package/package.json +3 -3
- package/typeOverloads/modules.d.ts +2 -0
- package/utils/releaseInfo.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,63 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 5.15.0
|
|
7
|
+
|
|
8
|
+
_Jul 29, 2022_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 6 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🎁 Introduce aggregation (#5592) @flaviendelangle
|
|
13
|
+
|
|
14
|
+
Premium users can now aggregate data in the grid.
|
|
15
|
+
Extract information like sum, average, count, and others with a couple of clicks.
|
|
16
|
+
|
|
17
|
+
https://user-images.githubusercontent.com/45398769/181581503-77cc412e-9d9e-4de1-8bc3-c3bccc54cdaa.mp4
|
|
18
|
+
|
|
19
|
+
To enable this feature, add `experimentalFeatures={{ aggregation: true }}`.
|
|
20
|
+
Aggregation functions are customizable and they combine well with row grouping.
|
|
21
|
+
See the [documentation](https://mui.com/x/react-data-grid/aggregation/) to explore everything it has to offer.
|
|
22
|
+
|
|
23
|
+
- 🚀 Introduce row pinning (#4863) @cherniavskii
|
|
24
|
+
|
|
25
|
+
Pro users can now pin rows on top or bottom of the grid.
|
|
26
|
+
|
|
27
|
+
https://user-images.githubusercontent.com/45398769/181581493-56c733a3-6dd5-4546-bf8d-3f2dff72b14a.mp4
|
|
28
|
+
|
|
29
|
+
To do so, enable the feature with `experimentalFeatures={{ rowPinning: true }}` and provide the pinned rows data to the `pinnedRows` prop.
|
|
30
|
+
For more details, see the [documentation](https://mui.com/x/react-data-grid/row-pinning/).
|
|
31
|
+
|
|
32
|
+
- 🌍 Add simplified Chinese (zh-CN) locale to pickers (#5584) @gamecss
|
|
33
|
+
- 📚 Documentation improvements
|
|
34
|
+
|
|
35
|
+
### `@mui/x-data-grid@v5.15.0` / `@mui/x-data-grid-pro@v5.15.0` / `@mui/x-data-grid-premium@v5.15.0`
|
|
36
|
+
|
|
37
|
+
#### Changes
|
|
38
|
+
|
|
39
|
+
- [DataGrid] Add prop to keep modifications while processing props (#5309) @m4theushw
|
|
40
|
+
- [DataGrid] Fix container width change on React 18 (#5566) @m4theushw
|
|
41
|
+
- [DataGrid] Fix ellipsis style convention (#5587) @oliviertassinari
|
|
42
|
+
- [DataGridPro] Implement row pinning (#4863) @cherniavskii
|
|
43
|
+
- [DataGridPremium] Make aggregation public (#5592) @cherniavskii
|
|
44
|
+
- [l10n] Improve simplified Chinese (zh-CN) locale (#5584) @gamecss
|
|
45
|
+
|
|
46
|
+
### `@mui/x-date-pickers@v5.0.0-beta.3` / `@mui/x-date-picker-pro@5.0.0-beta.3`
|
|
47
|
+
|
|
48
|
+
#### Changes
|
|
49
|
+
|
|
50
|
+
- [l10n] Add simplified Chinese (zh-CN) locale (#5584) @gamecss
|
|
51
|
+
|
|
52
|
+
### Docs
|
|
53
|
+
|
|
54
|
+
- [docs] Split docs page about rows (#5195) @flaviendelangle
|
|
55
|
+
- [docs] Add warning clarifications (#5399) @alexfauquette
|
|
56
|
+
- [docs] Correct slot CSS classes for Pro and Premium components (#5452) @alexfauquette
|
|
57
|
+
- [docs] Fix internal link to `valueParser` (#5450) @alexfauquette
|
|
58
|
+
|
|
59
|
+
### Core
|
|
60
|
+
|
|
61
|
+
- [core] Upgrade monorepo (#5560) @m4theushw
|
|
62
|
+
|
|
6
63
|
## 5.14.0
|
|
7
64
|
|
|
8
65
|
_Jul 21, 2022_
|
|
@@ -306,7 +363,7 @@ _May 31, 2022_
|
|
|
306
363
|
|
|
307
364
|
We'd like to offer a big thanks to the 15 contributors who made this release possible. Here are some highlights ✨:
|
|
308
365
|
|
|
309
|
-
- 🎁 Introduce support for [dynamic row height](https://mui.com/x/react-data-grid/
|
|
366
|
+
- 🎁 Introduce support for [dynamic row height](https://mui.com/x/react-data-grid/row-height/#dynamic-row-height) (#4859) @m4theushw
|
|
310
367
|
|
|
311
368
|
<img src="https://user-images.githubusercontent.com/42154031/171183167-718d7bcd-ec0f-459e-97fe-0f650abb4a99.gif" width="800">
|
|
312
369
|
|
|
@@ -623,7 +680,7 @@ _Apr 25, 2022_
|
|
|
623
680
|
|
|
624
681
|
We'd like to offer a big thanks to the 6 contributors who made this release possible. Here are some highlights ✨:
|
|
625
682
|
|
|
626
|
-
- 🎁 Introduce [Row reorder](https://mui.com/x/react-data-grid/
|
|
683
|
+
- 🎁 Introduce [Row reorder](https://mui.com/x/react-data-grid/row-ordering/) (#4034) @DanailH
|
|
627
684
|
|
|
628
685
|
<img src="https://user-images.githubusercontent.com/5858539/165091263-23472fbb-a989-44b8-849a-d2185adfe13b.gif" width="800">
|
|
629
686
|
|
|
@@ -887,7 +944,7 @@ We'd like to offer a big thanks to the 8 contributors who made this release poss
|
|
|
887
944
|
<DataGrid getRowSpacing={() => ({ top: 10, bottom: 10 })} />
|
|
888
945
|
```
|
|
889
946
|
|
|
890
|
-
Check the [documentation](https://mui.com/x/react-data-grid/
|
|
947
|
+
Check the [documentation](https://mui.com/x/react-data-grid/row-height/#row-spacing) for more information.
|
|
891
948
|
|
|
892
949
|
### `@mui/x-data-grid@v5.6.1` / `@mui/x-data-grid-pro@v5.6.1`
|
|
893
950
|
|
|
@@ -1141,7 +1198,7 @@ _Jan 28, 2022_
|
|
|
1141
1198
|
|
|
1142
1199
|
A big thanks to the 9 contributors who made this release possible. Here are some highlights ✨:
|
|
1143
1200
|
|
|
1144
|
-
- 🚣 Introduce [variable row height](https://mui.com/x/react-data-grid/
|
|
1201
|
+
- 🚣 Introduce [variable row height](https://mui.com/x/react-data-grid/row-height/#variable-row-height) (#438) @DanailH
|
|
1145
1202
|
|
|
1146
1203
|
Allows for setting a row-specific height.
|
|
1147
1204
|
By default, all rows have the same height, but now you can set the height on a per-row basis.
|
|
@@ -3793,7 +3850,7 @@ Big thanks to the 7 contributors who made this release possible. Here are some h
|
|
|
3793
3850
|
- 🎁 Add `onRowsScrollEnd` to support infinite loading (#1199) @DanailH
|
|
3794
3851
|
This is an XGrid feature. Provides the ability to tap into the `onRowsScrollEnd` which is called when the scroll reaches the bottom of the grid viewport allowing developers to load additional data. It can be used with a combination of `scrollBottomThreshold` to control the area in which the `onRowsScrollEnd` is called.
|
|
3795
3852
|
|
|
3796
|
-
See the documentation for [more details](https://mui.com/x/react-data-grid/
|
|
3853
|
+
See the documentation for [more details](https://mui.com/x/react-data-grid/row-updates/#infinite-loading).
|
|
3797
3854
|
|
|
3798
3855
|
- 🕹 Provide the ability to sort by multiple columns using Shift+click (#1203) @dtassone
|
|
3799
3856
|
- 🇵🇱 Added pl-PL locale (#1117) @LarsKumbier
|
|
@@ -217,6 +217,12 @@ DataGridProRaw.propTypes = {
|
|
|
217
217
|
*/
|
|
218
218
|
disableExtendRowFullWidth: PropTypes.bool,
|
|
219
219
|
|
|
220
|
+
/**
|
|
221
|
+
* If `true`, modification to a cell will not be discarded if the mode is changed from "edit" to "view" while processing props.
|
|
222
|
+
* @default false
|
|
223
|
+
*/
|
|
224
|
+
disableIgnoreModificationsIfProcessingProps: PropTypes.bool,
|
|
225
|
+
|
|
220
226
|
/**
|
|
221
227
|
* If `true`, filtering with multiple columns is disabled.
|
|
222
228
|
* @default false
|
|
@@ -270,6 +276,7 @@ DataGridProRaw.propTypes = {
|
|
|
270
276
|
experimentalFeatures: PropTypes.shape({
|
|
271
277
|
newEditingApi: PropTypes.bool,
|
|
272
278
|
preventCommitWhileValidating: PropTypes.bool,
|
|
279
|
+
rowPinning: PropTypes.bool,
|
|
273
280
|
warnIfFocusStateIsNotSynced: PropTypes.bool
|
|
274
281
|
}),
|
|
275
282
|
|
|
@@ -854,6 +861,14 @@ DataGridProRaw.propTypes = {
|
|
|
854
861
|
right: PropTypes.arrayOf(PropTypes.string)
|
|
855
862
|
}),
|
|
856
863
|
|
|
864
|
+
/**
|
|
865
|
+
* Rows data to pin on top or bottom.
|
|
866
|
+
*/
|
|
867
|
+
pinnedRows: PropTypes.shape({
|
|
868
|
+
bottom: PropTypes.array,
|
|
869
|
+
top: PropTypes.array
|
|
870
|
+
}),
|
|
871
|
+
|
|
857
872
|
/**
|
|
858
873
|
* Callback called before updating a row with new values in the row and cell editing.
|
|
859
874
|
* Only applied if `props.experimentalFeatures.newEditingApi: true`.
|
|
@@ -11,6 +11,8 @@ import { useGridDetailPanel, detailPanelStateInitializer } from '../hooks/featur
|
|
|
11
11
|
import { useGridDetailPanelPreProcessors } from '../hooks/features/detailPanel/useGridDetailPanelPreProcessors';
|
|
12
12
|
import { useGridRowReorder } from '../hooks/features/rowReorder/useGridRowReorder';
|
|
13
13
|
import { useGridRowReorderPreProcessors } from '../hooks/features/rowReorder/useGridRowReorderPreProcessors';
|
|
14
|
+
import { useGridRowPinning, rowPinningStateInitializer } from '../hooks/features/rowPinning/useGridRowPinning';
|
|
15
|
+
import { useGridRowPinningPreProcessors } from '../hooks/features/rowPinning/useGridRowPinningPreProcessors';
|
|
14
16
|
export const useDataGridProComponent = (inputApiRef, props) => {
|
|
15
17
|
var _props$experimentalFe, _props$experimentalFe2;
|
|
16
18
|
|
|
@@ -22,6 +24,7 @@ export const useDataGridProComponent = (inputApiRef, props) => {
|
|
|
22
24
|
useGridSelectionPreProcessors(apiRef, props);
|
|
23
25
|
useGridRowReorderPreProcessors(apiRef, props);
|
|
24
26
|
useGridTreeDataPreProcessors(apiRef, props);
|
|
27
|
+
useGridRowPinningPreProcessors(apiRef);
|
|
25
28
|
useGridDetailPanelPreProcessors(apiRef, props); // The column pinning `hydrateColumns` pre-processor must be after every other `hydrateColumns` pre-processors
|
|
26
29
|
// Because it changes the order of the columns.
|
|
27
30
|
|
|
@@ -35,6 +38,7 @@ export const useDataGridProComponent = (inputApiRef, props) => {
|
|
|
35
38
|
useGridInitializeState(detailPanelStateInitializer, apiRef, props);
|
|
36
39
|
useGridInitializeState(columnPinningStateInitializer, apiRef, props);
|
|
37
40
|
useGridInitializeState(columnsStateInitializer, apiRef, props);
|
|
41
|
+
useGridInitializeState(rowPinningStateInitializer, apiRef, props);
|
|
38
42
|
useGridInitializeState(rowsStateInitializer, apiRef, props);
|
|
39
43
|
useGridInitializeState((_props$experimentalFe = props.experimentalFeatures) != null && _props$experimentalFe.newEditingApi ? editingStateInitializer_new : editingStateInitializer_old, apiRef, props);
|
|
40
44
|
useGridInitializeState(focusStateInitializer, apiRef, props);
|
|
@@ -51,6 +55,7 @@ export const useDataGridProComponent = (inputApiRef, props) => {
|
|
|
51
55
|
useGridKeyboardNavigation(apiRef, props);
|
|
52
56
|
useGridSelection(apiRef, props);
|
|
53
57
|
useGridColumnPinning(apiRef, props);
|
|
58
|
+
useGridRowPinning(apiRef, props);
|
|
54
59
|
useGridColumns(apiRef, props);
|
|
55
60
|
useGridRows(apiRef, props);
|
|
56
61
|
useGridParamsApi(apiRef);
|
|
@@ -5,12 +5,13 @@ import * as React from 'react';
|
|
|
5
5
|
import { styled, alpha } from '@mui/material/styles';
|
|
6
6
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
7
7
|
import { useGridSelector, getDataGridUtilityClass, gridClasses, gridVisibleColumnFieldsSelector, gridRowsMetaSelector, useGridApiEventHandler } from '@mui/x-data-grid';
|
|
8
|
-
import { GridVirtualScroller, GridVirtualScrollerContent, GridVirtualScrollerRenderZone, useGridVirtualScroller } from '@mui/x-data-grid/internals';
|
|
8
|
+
import { GridVirtualScroller, GridVirtualScrollerContent, GridVirtualScrollerRenderZone, useGridVirtualScroller, calculatePinnedRowsHeight } from '@mui/x-data-grid/internals';
|
|
9
9
|
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
10
10
|
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
11
11
|
import { gridPinnedColumnsSelector, GridPinnedPosition } from '../hooks/features/columnPinning';
|
|
12
12
|
import { gridDetailPanelExpandedRowsContentCacheSelector, gridDetailPanelExpandedRowsHeightCacheSelector, gridDetailPanelExpandedRowIdsSelector } from '../hooks/features/detailPanel';
|
|
13
13
|
import { GridDetailPanel } from './GridDetailPanel';
|
|
14
|
+
import { gridPinnedRowsSelector } from '../hooks/features/rowPinning/gridRowPinningSelector';
|
|
14
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
16
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
17
|
export const filterColumns = (pinnedColumns, columns) => {
|
|
@@ -41,13 +42,14 @@ export const filterColumns = (pinnedColumns, columns) => {
|
|
|
41
42
|
|
|
42
43
|
const useUtilityClasses = ownerState => {
|
|
43
44
|
const {
|
|
44
|
-
classes
|
|
45
|
-
leftPinnedColumns,
|
|
46
|
-
rightPinnedColumns
|
|
45
|
+
classes
|
|
47
46
|
} = ownerState;
|
|
48
47
|
const slots = {
|
|
49
|
-
leftPinnedColumns: ['pinnedColumns',
|
|
50
|
-
rightPinnedColumns: ['pinnedColumns',
|
|
48
|
+
leftPinnedColumns: ['pinnedColumns', 'pinnedColumns--left'],
|
|
49
|
+
rightPinnedColumns: ['pinnedColumns', 'pinnedColumns--right'],
|
|
50
|
+
topPinnedRows: ['pinnedRows', 'pinnedRows--top'],
|
|
51
|
+
bottomPinnedRows: ['pinnedRows', 'pinnedRows--bottom'],
|
|
52
|
+
pinnedRowsRenderZone: ['pinnedRowsRenderZone'],
|
|
51
53
|
detailPanels: ['detailPanels'],
|
|
52
54
|
detailPanel: ['detailPanel']
|
|
53
55
|
};
|
|
@@ -67,6 +69,10 @@ const getOverlayAlpha = elevation => {
|
|
|
67
69
|
return alphaValue / 100;
|
|
68
70
|
};
|
|
69
71
|
|
|
72
|
+
const getBoxShadowColor = theme => {
|
|
73
|
+
return alpha(theme.palette.common.black, 0.21);
|
|
74
|
+
};
|
|
75
|
+
|
|
70
76
|
const VirtualScrollerDetailPanels = styled('div', {
|
|
71
77
|
name: 'MuiDataGrid',
|
|
72
78
|
slot: 'DetailPanels',
|
|
@@ -74,6 +80,7 @@ const VirtualScrollerDetailPanels = styled('div', {
|
|
|
74
80
|
})({
|
|
75
81
|
position: 'relative'
|
|
76
82
|
});
|
|
83
|
+
const darkModeBackgroundImage = `linear-gradient(${alpha('#fff', getOverlayAlpha(2))}, ${alpha('#fff', getOverlayAlpha(2))})`;
|
|
77
84
|
const VirtualScrollerPinnedColumns = styled('div', {
|
|
78
85
|
name: 'MuiDataGrid',
|
|
79
86
|
slot: 'PinnedColumns',
|
|
@@ -85,21 +92,56 @@ const VirtualScrollerPinnedColumns = styled('div', {
|
|
|
85
92
|
})(({
|
|
86
93
|
theme,
|
|
87
94
|
ownerState
|
|
88
|
-
}) =>
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
left
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
}) => {
|
|
96
|
+
const boxShadowColor = getBoxShadowColor(theme);
|
|
97
|
+
return _extends({
|
|
98
|
+
position: 'sticky',
|
|
99
|
+
overflow: 'hidden',
|
|
100
|
+
zIndex: 1,
|
|
101
|
+
backgroundColor: theme.palette.background.default
|
|
102
|
+
}, theme.palette.mode === 'dark' && {
|
|
103
|
+
backgroundImage: darkModeBackgroundImage
|
|
104
|
+
}, ownerState.side === GridPinnedPosition.left && {
|
|
105
|
+
left: 0,
|
|
106
|
+
float: 'left',
|
|
107
|
+
boxShadow: `2px 0px 4px -2px ${boxShadowColor}`
|
|
108
|
+
}, ownerState.side === GridPinnedPosition.right && {
|
|
109
|
+
right: 0,
|
|
110
|
+
float: 'right',
|
|
111
|
+
boxShadow: `-2px 0px 4px -2px ${boxShadowColor}`
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
const VirtualScrollerPinnedRows = styled('div', {
|
|
115
|
+
name: 'MuiDataGrid',
|
|
116
|
+
slot: 'PinnedRows',
|
|
117
|
+
overridesResolver: (props, styles) => [{
|
|
118
|
+
[`&.${gridClasses['pinnedRows--top']}`]: styles['pinnedRows--top']
|
|
119
|
+
}, {
|
|
120
|
+
[`&.${gridClasses['pinnedRows--bottom']}`]: styles['pinnedRows--bottom']
|
|
121
|
+
}, styles.pinnedRows]
|
|
122
|
+
})(({
|
|
123
|
+
theme,
|
|
124
|
+
ownerState
|
|
125
|
+
}) => {
|
|
126
|
+
const boxShadowColor = getBoxShadowColor(theme);
|
|
127
|
+
return _extends({
|
|
128
|
+
position: 'sticky',
|
|
129
|
+
// should be above the detail panel
|
|
130
|
+
zIndex: 3,
|
|
131
|
+
backgroundColor: theme.palette.background.default
|
|
132
|
+
}, theme.palette.mode === 'dark' && {
|
|
133
|
+
backgroundImage: darkModeBackgroundImage
|
|
134
|
+
}, ownerState.position === 'top' && {
|
|
135
|
+
top: 0,
|
|
136
|
+
boxShadow: `0px 3px 4px -2px ${boxShadowColor}`
|
|
137
|
+
}, ownerState.position === 'bottom' && {
|
|
138
|
+
boxShadow: `0px -3px 4px -2px ${boxShadowColor}`,
|
|
139
|
+
bottom: 0
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
const VirtualScrollerPinnedRowsRenderZone = styled('div')({
|
|
143
|
+
position: 'absolute'
|
|
144
|
+
});
|
|
103
145
|
const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGridProVirtualScroller(props, ref) {
|
|
104
146
|
const other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
105
147
|
|
|
@@ -111,8 +153,11 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
111
153
|
const detailPanelsHeights = useGridSelector(apiRef, gridDetailPanelExpandedRowsHeightCacheSelector);
|
|
112
154
|
const leftColumns = React.useRef(null);
|
|
113
155
|
const rightColumns = React.useRef(null);
|
|
156
|
+
const topPinnedRowsRenderZoneRef = React.useRef(null);
|
|
157
|
+
const bottomPinnedRowsRenderZoneRef = React.useRef(null);
|
|
114
158
|
const handleRenderZonePositioning = React.useCallback(({
|
|
115
|
-
top
|
|
159
|
+
top,
|
|
160
|
+
left
|
|
116
161
|
}) => {
|
|
117
162
|
if (leftColumns.current) {
|
|
118
163
|
leftColumns.current.style.transform = `translate3d(0px, ${top}px, 0px)`;
|
|
@@ -121,6 +166,14 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
121
166
|
if (rightColumns.current) {
|
|
122
167
|
rightColumns.current.style.transform = `translate3d(0px, ${top}px, 0px)`;
|
|
123
168
|
}
|
|
169
|
+
|
|
170
|
+
if (topPinnedRowsRenderZoneRef.current) {
|
|
171
|
+
topPinnedRowsRenderZoneRef.current.style.transform = `translate3d(${left}px, 0px, 0px)`;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (bottomPinnedRowsRenderZoneRef.current) {
|
|
175
|
+
bottomPinnedRowsRenderZoneRef.current.style.transform = `translate3d(${left}px, 0px, 0px)`;
|
|
176
|
+
}
|
|
124
177
|
}, []);
|
|
125
178
|
|
|
126
179
|
const getRowProps = id => {
|
|
@@ -138,10 +191,15 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
138
191
|
|
|
139
192
|
const pinnedColumns = useGridSelector(apiRef, gridPinnedColumnsSelector);
|
|
140
193
|
const [leftPinnedColumns, rightPinnedColumns] = filterColumns(pinnedColumns, visibleColumnFields);
|
|
194
|
+
const pinnedRows = useGridSelector(apiRef, gridPinnedRowsSelector);
|
|
195
|
+
const topPinnedRowsData = React.useMemo(() => (pinnedRows == null ? void 0 : pinnedRows.top) || [], [pinnedRows == null ? void 0 : pinnedRows.top]);
|
|
196
|
+
const bottomPinnedRowsData = React.useMemo(() => (pinnedRows == null ? void 0 : pinnedRows.bottom) || [], [pinnedRows == null ? void 0 : pinnedRows.bottom]);
|
|
141
197
|
const ownerState = {
|
|
142
198
|
classes: rootProps.classes,
|
|
143
199
|
leftPinnedColumns,
|
|
144
|
-
rightPinnedColumns
|
|
200
|
+
rightPinnedColumns,
|
|
201
|
+
topPinnedRowsCount: topPinnedRowsData.length,
|
|
202
|
+
bottomPinnedRowsCount: bottomPinnedRowsData.length
|
|
145
203
|
};
|
|
146
204
|
const classes = useUtilityClasses(ownerState);
|
|
147
205
|
const {
|
|
@@ -174,10 +232,6 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
174
232
|
firstColumnIndex: visibleColumnFields.length - rightPinnedColumns.length,
|
|
175
233
|
lastColumnIndex: visibleColumnFields.length
|
|
176
234
|
}) : null;
|
|
177
|
-
const contentProps = getContentProps();
|
|
178
|
-
const pinnedColumnsStyle = {
|
|
179
|
-
minHeight: contentProps.style.minHeight
|
|
180
|
-
};
|
|
181
235
|
|
|
182
236
|
const getDetailPanels = () => {
|
|
183
237
|
const panels = [];
|
|
@@ -218,8 +272,73 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
218
272
|
};
|
|
219
273
|
|
|
220
274
|
const detailPanels = getDetailPanels();
|
|
221
|
-
|
|
222
|
-
|
|
275
|
+
const topPinnedRows = getRows({
|
|
276
|
+
renderContext,
|
|
277
|
+
rows: topPinnedRowsData
|
|
278
|
+
});
|
|
279
|
+
const pinnedRowsHeight = calculatePinnedRowsHeight(apiRef);
|
|
280
|
+
const mainRows = getRows({
|
|
281
|
+
renderContext,
|
|
282
|
+
rowIndexOffset: topPinnedRowsData.length
|
|
283
|
+
});
|
|
284
|
+
const bottomPinnedRows = getRows({
|
|
285
|
+
renderContext,
|
|
286
|
+
rows: bottomPinnedRowsData,
|
|
287
|
+
rowIndexOffset: topPinnedRowsData.length + (mainRows ? mainRows.length : 0)
|
|
288
|
+
});
|
|
289
|
+
const contentProps = getContentProps();
|
|
290
|
+
const pinnedColumnsStyle = {
|
|
291
|
+
minHeight: contentProps.style.minHeight
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
if (contentProps.style.minHeight && contentProps.style.minHeight === '100%') {
|
|
295
|
+
contentProps.style.minHeight = `calc(100% - ${pinnedRowsHeight.top}px - ${pinnedRowsHeight.bottom}px)`;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return /*#__PURE__*/_jsxs(GridVirtualScroller, _extends({}, getRootProps(other), {
|
|
299
|
+
children: [topPinnedRowsData.length > 0 ? /*#__PURE__*/_jsxs(VirtualScrollerPinnedRows, {
|
|
300
|
+
className: classes.topPinnedRows,
|
|
301
|
+
ownerState: {
|
|
302
|
+
position: 'top'
|
|
303
|
+
},
|
|
304
|
+
style: {
|
|
305
|
+
width: contentProps.style.width,
|
|
306
|
+
height: pinnedRowsHeight.top
|
|
307
|
+
},
|
|
308
|
+
role: "rowgroup",
|
|
309
|
+
children: [leftRenderContext && /*#__PURE__*/_jsx(VirtualScrollerPinnedColumns, {
|
|
310
|
+
className: classes.leftPinnedColumns,
|
|
311
|
+
ownerState: {
|
|
312
|
+
side: GridPinnedPosition.left
|
|
313
|
+
},
|
|
314
|
+
children: getRows({
|
|
315
|
+
renderContext: leftRenderContext,
|
|
316
|
+
minFirstColumn: leftRenderContext.firstColumnIndex,
|
|
317
|
+
maxLastColumn: leftRenderContext.lastColumnIndex,
|
|
318
|
+
availableSpace: 0,
|
|
319
|
+
ignoreAutoHeight: true,
|
|
320
|
+
rows: topPinnedRowsData
|
|
321
|
+
})
|
|
322
|
+
}), /*#__PURE__*/_jsx(VirtualScrollerPinnedRowsRenderZone, {
|
|
323
|
+
className: classes.pinnedRowsRenderZone,
|
|
324
|
+
ref: topPinnedRowsRenderZoneRef,
|
|
325
|
+
role: "presentation",
|
|
326
|
+
children: topPinnedRows
|
|
327
|
+
}), rightRenderContext && /*#__PURE__*/_jsx(VirtualScrollerPinnedColumns, {
|
|
328
|
+
className: classes.rightPinnedColumns,
|
|
329
|
+
ownerState: {
|
|
330
|
+
side: GridPinnedPosition.right
|
|
331
|
+
},
|
|
332
|
+
children: getRows({
|
|
333
|
+
renderContext: rightRenderContext,
|
|
334
|
+
minFirstColumn: rightRenderContext.firstColumnIndex,
|
|
335
|
+
maxLastColumn: rightRenderContext.lastColumnIndex,
|
|
336
|
+
ignoreAutoHeight: true,
|
|
337
|
+
availableSpace: 0,
|
|
338
|
+
rows: topPinnedRowsData
|
|
339
|
+
})
|
|
340
|
+
})]
|
|
341
|
+
}) : null, /*#__PURE__*/_jsxs(GridVirtualScrollerContent, _extends({}, contentProps, {
|
|
223
342
|
children: [leftRenderContext && /*#__PURE__*/_jsx(VirtualScrollerPinnedColumns, {
|
|
224
343
|
ref: leftColumns,
|
|
225
344
|
className: classes.leftPinnedColumns,
|
|
@@ -232,12 +351,11 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
232
351
|
minFirstColumn: leftRenderContext.firstColumnIndex,
|
|
233
352
|
maxLastColumn: leftRenderContext.lastColumnIndex,
|
|
234
353
|
availableSpace: 0,
|
|
235
|
-
ignoreAutoHeight: true
|
|
354
|
+
ignoreAutoHeight: true,
|
|
355
|
+
rowIndexOffset: topPinnedRowsData.length
|
|
236
356
|
})
|
|
237
357
|
}), /*#__PURE__*/_jsx(GridVirtualScrollerRenderZone, _extends({}, getRenderZoneProps(), {
|
|
238
|
-
children:
|
|
239
|
-
renderContext
|
|
240
|
-
})
|
|
358
|
+
children: mainRows
|
|
241
359
|
})), rightRenderContext && /*#__PURE__*/_jsx(VirtualScrollerPinnedColumns, {
|
|
242
360
|
ref: rightColumns,
|
|
243
361
|
ownerState: {
|
|
@@ -250,13 +368,58 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
250
368
|
minFirstColumn: rightRenderContext.firstColumnIndex,
|
|
251
369
|
maxLastColumn: rightRenderContext.lastColumnIndex,
|
|
252
370
|
availableSpace: 0,
|
|
253
|
-
ignoreAutoHeight: true
|
|
371
|
+
ignoreAutoHeight: true,
|
|
372
|
+
rowIndexOffset: topPinnedRowsData.length
|
|
254
373
|
})
|
|
255
374
|
}), detailPanels.length > 0 && /*#__PURE__*/_jsx(VirtualScrollerDetailPanels, {
|
|
256
375
|
className: classes.detailPanels,
|
|
257
376
|
children: detailPanels
|
|
258
377
|
})]
|
|
259
|
-
}))
|
|
378
|
+
})), bottomPinnedRowsData.length > 0 ? /*#__PURE__*/_jsxs(VirtualScrollerPinnedRows, {
|
|
379
|
+
className: classes.bottomPinnedRows,
|
|
380
|
+
ownerState: {
|
|
381
|
+
position: 'bottom'
|
|
382
|
+
},
|
|
383
|
+
style: {
|
|
384
|
+
width: contentProps.style.width,
|
|
385
|
+
height: pinnedRowsHeight.bottom
|
|
386
|
+
},
|
|
387
|
+
role: "rowgroup",
|
|
388
|
+
children: [leftRenderContext && /*#__PURE__*/_jsx(VirtualScrollerPinnedColumns, {
|
|
389
|
+
className: classes.leftPinnedColumns,
|
|
390
|
+
ownerState: {
|
|
391
|
+
side: GridPinnedPosition.left
|
|
392
|
+
},
|
|
393
|
+
children: getRows({
|
|
394
|
+
renderContext: leftRenderContext,
|
|
395
|
+
minFirstColumn: leftRenderContext.firstColumnIndex,
|
|
396
|
+
maxLastColumn: leftRenderContext.lastColumnIndex,
|
|
397
|
+
availableSpace: 0,
|
|
398
|
+
ignoreAutoHeight: true,
|
|
399
|
+
rows: bottomPinnedRowsData,
|
|
400
|
+
rowIndexOffset: topPinnedRowsData.length + (mainRows ? mainRows.length : 0)
|
|
401
|
+
})
|
|
402
|
+
}), /*#__PURE__*/_jsx(VirtualScrollerPinnedRowsRenderZone, {
|
|
403
|
+
className: classes.pinnedRowsRenderZone,
|
|
404
|
+
ref: bottomPinnedRowsRenderZoneRef,
|
|
405
|
+
role: "presentation",
|
|
406
|
+
children: bottomPinnedRows
|
|
407
|
+
}), rightRenderContext && /*#__PURE__*/_jsx(VirtualScrollerPinnedColumns, {
|
|
408
|
+
className: classes.rightPinnedColumns,
|
|
409
|
+
ownerState: {
|
|
410
|
+
side: GridPinnedPosition.right
|
|
411
|
+
},
|
|
412
|
+
children: getRows({
|
|
413
|
+
renderContext: rightRenderContext,
|
|
414
|
+
minFirstColumn: rightRenderContext.firstColumnIndex,
|
|
415
|
+
maxLastColumn: rightRenderContext.lastColumnIndex,
|
|
416
|
+
availableSpace: 0,
|
|
417
|
+
ignoreAutoHeight: true,
|
|
418
|
+
rows: bottomPinnedRowsData,
|
|
419
|
+
rowIndexOffset: topPinnedRowsData.length + (mainRows ? mainRows.length : 0)
|
|
420
|
+
})
|
|
421
|
+
})]
|
|
422
|
+
}) : null]
|
|
260
423
|
}));
|
|
261
424
|
});
|
|
262
425
|
export { DataGridProVirtualScroller };
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { GridRenderCellParams } from '@mui/x-data-grid';
|
|
3
3
|
declare const GridRowReorderCell: (params: GridRenderCellParams) => JSX.Element | null;
|
|
4
4
|
export { GridRowReorderCell };
|
|
5
|
-
export declare const renderRowReorderCell: (params: GridRenderCellParams) => JSX.Element;
|
|
5
|
+
export declare const renderRowReorderCell: (params: GridRenderCellParams) => JSX.Element | null;
|
|
@@ -76,4 +76,10 @@ const GridRowReorderCell = params => {
|
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
export { GridRowReorderCell };
|
|
79
|
-
export const renderRowReorderCell = params =>
|
|
79
|
+
export const renderRowReorderCell = params => {
|
|
80
|
+
if (params.rowNode.isPinned) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return /*#__PURE__*/_jsx(GridRowReorderCell, _extends({}, params));
|
|
85
|
+
};
|
package/hooks/features/index.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GridRowId, GridRowsLookup, GridRowsProp } from '@mui/x-data-grid';
|
|
2
|
+
export interface GridPinnedRowsProp<R = any> {
|
|
3
|
+
top?: GridRowsProp<R>;
|
|
4
|
+
bottom?: GridRowsProp<R>;
|
|
5
|
+
}
|
|
6
|
+
export interface GridRowPinningApi {
|
|
7
|
+
/**
|
|
8
|
+
* Changes the pinned rows.
|
|
9
|
+
* @param {GridPinnedRowsProp} pinnedRows An object containing the rows to pin.
|
|
10
|
+
*/
|
|
11
|
+
unstable_setPinnedRows: (pinnedRows?: GridPinnedRowsProp) => void;
|
|
12
|
+
}
|
|
13
|
+
export interface GridRowPinningInternalCache {
|
|
14
|
+
topIds: GridRowId[];
|
|
15
|
+
bottomIds: GridRowId[];
|
|
16
|
+
idLookup: GridRowsLookup;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector, } from '@mui/x-data-grid/internals';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector } from '@mui/x-data-grid/internals';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './gridRowPinningInterface';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './gridRowPinningInterface';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GridStateInitializer } from '@mui/x-data-grid/internals';
|
|
3
|
+
import { GridApiPro } from '../../../models/gridApiPro';
|
|
4
|
+
import { DataGridProProcessedProps } from '../../../models/dataGridProProps';
|
|
5
|
+
export declare const rowPinningStateInitializer: GridStateInitializer<Pick<DataGridProProcessedProps, 'pinnedRows' | 'getRowId' | 'experimentalFeatures'>>;
|
|
6
|
+
export declare const useGridRowPinning: (apiRef: React.MutableRefObject<GridApiPro>, props: Pick<DataGridProProcessedProps, 'pinnedRows' | 'getRowId' | 'experimentalFeatures'>) => void;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useGridApiMethod } from '@mui/x-data-grid';
|
|
4
|
+
import { getRowIdFromRowModel } from '@mui/x-data-grid/internals';
|
|
5
|
+
|
|
6
|
+
function createPinnedRowsInternalCache(pinnedRows, getRowId) {
|
|
7
|
+
var _pinnedRows$top, _pinnedRows$bottom;
|
|
8
|
+
|
|
9
|
+
const cache = {
|
|
10
|
+
topIds: [],
|
|
11
|
+
bottomIds: [],
|
|
12
|
+
idLookup: {}
|
|
13
|
+
};
|
|
14
|
+
pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.forEach(rowModel => {
|
|
15
|
+
const id = getRowIdFromRowModel(rowModel, getRowId);
|
|
16
|
+
cache.topIds.push(id);
|
|
17
|
+
cache.idLookup[id] = rowModel;
|
|
18
|
+
});
|
|
19
|
+
pinnedRows == null ? void 0 : (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.forEach(rowModel => {
|
|
20
|
+
const id = getRowIdFromRowModel(rowModel, getRowId);
|
|
21
|
+
cache.bottomIds.push(id);
|
|
22
|
+
cache.idLookup[id] = rowModel;
|
|
23
|
+
});
|
|
24
|
+
return cache;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const rowPinningStateInitializer = (state, props, apiRef) => {
|
|
28
|
+
var _props$experimentalFe, _state$rows;
|
|
29
|
+
|
|
30
|
+
if (!((_props$experimentalFe = props.experimentalFeatures) != null && _props$experimentalFe.rowPinning)) {
|
|
31
|
+
return state;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
apiRef.current.unstable_caches.pinnedRows = createPinnedRowsInternalCache(props.pinnedRows, props.getRowId);
|
|
35
|
+
return _extends({}, state, {
|
|
36
|
+
rows: _extends({}, state.rows, {
|
|
37
|
+
additionalRowGroups: _extends({}, (_state$rows = state.rows) == null ? void 0 : _state$rows.additionalRowGroups, {
|
|
38
|
+
pinnedRows: {
|
|
39
|
+
top: [],
|
|
40
|
+
bottom: []
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
export const useGridRowPinning = (apiRef, props) => {
|
|
47
|
+
var _props$experimentalFe3;
|
|
48
|
+
|
|
49
|
+
const setPinnedRows = React.useCallback(newPinnedRows => {
|
|
50
|
+
var _props$experimentalFe2;
|
|
51
|
+
|
|
52
|
+
if (!((_props$experimentalFe2 = props.experimentalFeatures) != null && _props$experimentalFe2.rowPinning)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
apiRef.current.unstable_caches.pinnedRows = createPinnedRowsInternalCache(newPinnedRows, props.getRowId);
|
|
57
|
+
apiRef.current.unstable_requestPipeProcessorsApplication('hydrateRows');
|
|
58
|
+
}, [apiRef, (_props$experimentalFe3 = props.experimentalFeatures) == null ? void 0 : _props$experimentalFe3.rowPinning, props.getRowId]);
|
|
59
|
+
useGridApiMethod(apiRef, {
|
|
60
|
+
unstable_setPinnedRows: setPinnedRows
|
|
61
|
+
}, 'rowPinningApi');
|
|
62
|
+
const isFirstRender = React.useRef(true);
|
|
63
|
+
React.useEffect(() => {
|
|
64
|
+
if (isFirstRender.current) {
|
|
65
|
+
isFirstRender.current = false;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
apiRef.current.unstable_setPinnedRows(props.pinnedRows);
|
|
70
|
+
}, [apiRef, props.pinnedRows]);
|
|
71
|
+
};
|