@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.
Files changed (69) hide show
  1. package/CHANGELOG.md +62 -5
  2. package/DataGridPro/DataGridPro.js +15 -0
  3. package/DataGridPro/useDataGridProComponent.js +5 -0
  4. package/components/DataGridProVirtualScroller.js +198 -35
  5. package/components/GridRowReorderCell.d.ts +1 -1
  6. package/components/GridRowReorderCell.js +7 -1
  7. package/hooks/features/index.d.ts +1 -0
  8. package/hooks/features/index.js +2 -1
  9. package/hooks/features/rowPinning/gridRowPinningInterface.d.ts +17 -0
  10. package/hooks/features/rowPinning/gridRowPinningInterface.js +1 -0
  11. package/hooks/features/rowPinning/gridRowPinningSelector.d.ts +1 -0
  12. package/hooks/features/rowPinning/gridRowPinningSelector.js +1 -0
  13. package/hooks/features/rowPinning/index.d.ts +1 -0
  14. package/hooks/features/rowPinning/index.js +1 -0
  15. package/hooks/features/rowPinning/useGridRowPinning.d.ts +6 -0
  16. package/hooks/features/rowPinning/useGridRowPinning.js +71 -0
  17. package/hooks/features/rowPinning/useGridRowPinningPreProcessors.d.ts +34 -0
  18. package/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +89 -0
  19. package/hooks/features/rowReorder/useGridRowReorder.js +6 -0
  20. package/index.js +1 -1
  21. package/internals/index.d.ts +2 -0
  22. package/internals/index.js +2 -0
  23. package/legacy/DataGridPro/DataGridPro.js +15 -0
  24. package/legacy/DataGridPro/useDataGridProComponent.js +5 -0
  25. package/legacy/components/DataGridProVirtualScroller.js +187 -25
  26. package/legacy/components/GridRowReorderCell.js +4 -0
  27. package/legacy/hooks/features/index.js +2 -1
  28. package/legacy/hooks/features/rowPinning/gridRowPinningInterface.js +1 -0
  29. package/legacy/hooks/features/rowPinning/gridRowPinningSelector.js +1 -0
  30. package/legacy/hooks/features/rowPinning/index.js +1 -0
  31. package/legacy/hooks/features/rowPinning/useGridRowPinning.js +71 -0
  32. package/legacy/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +89 -0
  33. package/legacy/hooks/features/rowReorder/useGridRowReorder.js +6 -0
  34. package/legacy/index.js +1 -1
  35. package/legacy/internals/index.js +2 -0
  36. package/legacy/utils/releaseInfo.js +1 -1
  37. package/models/dataGridProProps.d.ts +11 -5
  38. package/models/gridApiPro.d.ts +2 -2
  39. package/modern/DataGridPro/DataGridPro.js +15 -0
  40. package/modern/DataGridPro/useDataGridProComponent.js +5 -0
  41. package/modern/components/DataGridProVirtualScroller.js +198 -35
  42. package/modern/components/GridRowReorderCell.js +7 -1
  43. package/modern/hooks/features/index.js +2 -1
  44. package/modern/hooks/features/rowPinning/gridRowPinningInterface.js +1 -0
  45. package/modern/hooks/features/rowPinning/gridRowPinningSelector.js +1 -0
  46. package/modern/hooks/features/rowPinning/index.js +1 -0
  47. package/modern/hooks/features/rowPinning/useGridRowPinning.js +63 -0
  48. package/modern/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +85 -0
  49. package/modern/hooks/features/rowReorder/useGridRowReorder.js +4 -0
  50. package/modern/index.js +1 -1
  51. package/modern/internals/index.js +2 -0
  52. package/modern/utils/releaseInfo.js +1 -1
  53. package/node/DataGridPro/DataGridPro.js +15 -0
  54. package/node/DataGridPro/useDataGridProComponent.js +7 -0
  55. package/node/components/DataGridProVirtualScroller.js +198 -34
  56. package/node/components/GridRowReorderCell.js +7 -1
  57. package/node/hooks/features/index.js +13 -0
  58. package/node/hooks/features/rowPinning/gridRowPinningInterface.js +5 -0
  59. package/node/hooks/features/rowPinning/gridRowPinningSelector.js +19 -0
  60. package/node/hooks/features/rowPinning/index.js +18 -0
  61. package/node/hooks/features/rowPinning/useGridRowPinning.js +92 -0
  62. package/node/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +105 -0
  63. package/node/hooks/features/rowReorder/useGridRowReorder.js +6 -0
  64. package/node/index.js +1 -1
  65. package/node/internals/index.js +32 -0
  66. package/node/utils/releaseInfo.js +1 -1
  67. package/package.json +3 -3
  68. package/typeOverloads/modules.d.ts +2 -0
  69. package/utils/releaseInfo.js +1 -1
@@ -0,0 +1,63 @@
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
+ const cache = {
8
+ topIds: [],
9
+ bottomIds: [],
10
+ idLookup: {}
11
+ };
12
+ pinnedRows?.top?.forEach(rowModel => {
13
+ const id = getRowIdFromRowModel(rowModel, getRowId);
14
+ cache.topIds.push(id);
15
+ cache.idLookup[id] = rowModel;
16
+ });
17
+ pinnedRows?.bottom?.forEach(rowModel => {
18
+ const id = getRowIdFromRowModel(rowModel, getRowId);
19
+ cache.bottomIds.push(id);
20
+ cache.idLookup[id] = rowModel;
21
+ });
22
+ return cache;
23
+ }
24
+
25
+ export const rowPinningStateInitializer = (state, props, apiRef) => {
26
+ if (!props.experimentalFeatures?.rowPinning) {
27
+ return state;
28
+ }
29
+
30
+ apiRef.current.unstable_caches.pinnedRows = createPinnedRowsInternalCache(props.pinnedRows, props.getRowId);
31
+ return _extends({}, state, {
32
+ rows: _extends({}, state.rows, {
33
+ additionalRowGroups: _extends({}, state.rows?.additionalRowGroups, {
34
+ pinnedRows: {
35
+ top: [],
36
+ bottom: []
37
+ }
38
+ })
39
+ })
40
+ });
41
+ };
42
+ export const useGridRowPinning = (apiRef, props) => {
43
+ const setPinnedRows = React.useCallback(newPinnedRows => {
44
+ if (!props.experimentalFeatures?.rowPinning) {
45
+ return;
46
+ }
47
+
48
+ apiRef.current.unstable_caches.pinnedRows = createPinnedRowsInternalCache(newPinnedRows, props.getRowId);
49
+ apiRef.current.unstable_requestPipeProcessorsApplication('hydrateRows');
50
+ }, [apiRef, props.experimentalFeatures?.rowPinning, props.getRowId]);
51
+ useGridApiMethod(apiRef, {
52
+ unstable_setPinnedRows: setPinnedRows
53
+ }, 'rowPinningApi');
54
+ const isFirstRender = React.useRef(true);
55
+ React.useEffect(() => {
56
+ if (isFirstRender.current) {
57
+ isFirstRender.current = false;
58
+ return;
59
+ }
60
+
61
+ apiRef.current.unstable_setPinnedRows(props.pinnedRows);
62
+ }, [apiRef, props.pinnedRows]);
63
+ };
@@ -0,0 +1,85 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
4
+ export function addPinnedRow({
5
+ groupingParams,
6
+ rowModel,
7
+ rowId,
8
+ position,
9
+ apiRef
10
+ }) {
11
+ const idRowsLookup = _extends({}, groupingParams.idRowsLookup);
12
+
13
+ const tree = _extends({}, groupingParams.tree); // TODO: warn if id is already present in `props.rows`
14
+
15
+
16
+ idRowsLookup[rowId] = rowModel; // Do not push it to ids list so that pagination is not affected by pinned rows
17
+ // ids.push(rowId);
18
+
19
+ tree[rowId] = {
20
+ id: rowId,
21
+ isAutoGenerated: false,
22
+ parent: null,
23
+ depth: 0,
24
+ groupingKey: null,
25
+ groupingField: null,
26
+ isPinned: true
27
+ };
28
+ apiRef.current.unstable_caches.rows.idRowsLookup[rowId] = _extends({}, rowModel);
29
+ apiRef.current.unstable_caches.rows.idToIdLookup[rowId] = rowId;
30
+ const previousPinnedRows = groupingParams.additionalRowGroups?.pinnedRows || {};
31
+ const newPinnedRow = {
32
+ id: rowId,
33
+ model: rowModel
34
+ };
35
+ return _extends({}, groupingParams, {
36
+ idRowsLookup,
37
+ tree,
38
+ additionalRowGroups: _extends({}, groupingParams.additionalRowGroups, {
39
+ pinnedRows: _extends({}, previousPinnedRows, {
40
+ [position]: [...(previousPinnedRows[position] || []), newPinnedRow]
41
+ })
42
+ })
43
+ });
44
+ }
45
+ export const useGridRowPinningPreProcessors = apiRef => {
46
+ const addPinnedRows = React.useCallback(groupingParams => {
47
+ const pinnedRowsCache = apiRef.current.unstable_caches.pinnedRows || {};
48
+
49
+ let newGroupingParams = _extends({}, groupingParams, {
50
+ additionalRowGroups: _extends({}, groupingParams.additionalRowGroups, {
51
+ // reset pinned rows state
52
+ pinnedRows: {}
53
+ })
54
+ });
55
+
56
+ pinnedRowsCache.topIds?.forEach(rowId => {
57
+ newGroupingParams = addPinnedRow({
58
+ groupingParams: newGroupingParams,
59
+ rowModel: pinnedRowsCache.idLookup[rowId],
60
+ rowId,
61
+ position: 'top',
62
+ apiRef
63
+ });
64
+ });
65
+ pinnedRowsCache.bottomIds?.forEach(rowId => {
66
+ newGroupingParams = addPinnedRow({
67
+ groupingParams: newGroupingParams,
68
+ rowModel: pinnedRowsCache.idLookup[rowId],
69
+ rowId,
70
+ position: 'bottom',
71
+ apiRef
72
+ });
73
+ }); // If row with the same `id` is present both in `rows` and `pinnedRows` - remove it from `ids`
74
+
75
+ newGroupingParams.ids = newGroupingParams.ids.filter(rowId => {
76
+ if (newGroupingParams.tree[rowId] && newGroupingParams.tree[rowId].isPinned) {
77
+ return false;
78
+ }
79
+
80
+ return true;
81
+ });
82
+ return newGroupingParams;
83
+ }, [apiRef]);
84
+ useGridRegisterPipeProcessor(apiRef, 'hydrateRows', addPinnedRows);
85
+ };
@@ -64,6 +64,10 @@ export const useGridRowReorder = (apiRef, props) => {
64
64
  return;
65
65
  }
66
66
 
67
+ if (apiRef.current.getRowNode(params.id)?.isPinned) {
68
+ return;
69
+ }
70
+
67
71
  logger.debug(`Dragging over row ${params.id}`);
68
72
  event.preventDefault(); // Prevent drag events propagation.
69
73
  // For more information check here https://github.com/mui/mui-x/issues/2680.
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.14.0
1
+ /** @license MUI v5.15.0
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -13,5 +13,7 @@ export { useGridRowReorderPreProcessors } from '../hooks/features/rowReorder/use
13
13
  export { useGridTreeData } from '../hooks/features/treeData/useGridTreeData';
14
14
  export { useGridTreeDataPreProcessors } from '../hooks/features/treeData/useGridTreeDataPreProcessors';
15
15
  export { TREE_DATA_STRATEGY } from '../hooks/features/treeData/gridTreeDataUtils';
16
+ export { useGridRowPinning, rowPinningStateInitializer } from '../hooks/features/rowPinning/useGridRowPinning';
17
+ export { useGridRowPinningPreProcessors, addPinnedRow } from '../hooks/features/rowPinning/useGridRowPinningPreProcessors';
16
18
  export { buildRowTree } from '../utils/tree/buildRowTree';
17
19
  export { sortRowTree } from '../utils/tree/sortRowTree';
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTY1ODQ0MDgwMDAwMA==";
3
+ const releaseInfo = "MTY1OTA0NTYwMDAwMA==";
4
4
 
5
5
  if (process.env.NODE_ENV !== 'production') {
6
6
  // A simple hack to set the value in the test environment (has no build step).
@@ -241,6 +241,12 @@ DataGridProRaw.propTypes = {
241
241
  */
242
242
  disableExtendRowFullWidth: _propTypes.default.bool,
243
243
 
244
+ /**
245
+ * If `true`, modification to a cell will not be discarded if the mode is changed from "edit" to "view" while processing props.
246
+ * @default false
247
+ */
248
+ disableIgnoreModificationsIfProcessingProps: _propTypes.default.bool,
249
+
244
250
  /**
245
251
  * If `true`, filtering with multiple columns is disabled.
246
252
  * @default false
@@ -294,6 +300,7 @@ DataGridProRaw.propTypes = {
294
300
  experimentalFeatures: _propTypes.default.shape({
295
301
  newEditingApi: _propTypes.default.bool,
296
302
  preventCommitWhileValidating: _propTypes.default.bool,
303
+ rowPinning: _propTypes.default.bool,
297
304
  warnIfFocusStateIsNotSynced: _propTypes.default.bool
298
305
  }),
299
306
 
@@ -878,6 +885,14 @@ DataGridProRaw.propTypes = {
878
885
  right: _propTypes.default.arrayOf(_propTypes.default.string)
879
886
  }),
880
887
 
888
+ /**
889
+ * Rows data to pin on top or bottom.
890
+ */
891
+ pinnedRows: _propTypes.default.shape({
892
+ bottom: _propTypes.default.array,
893
+ top: _propTypes.default.array
894
+ }),
895
+
881
896
  /**
882
897
  * Callback called before updating a row with new values in the row and cell editing.
883
898
  * Only applied if `props.experimentalFeatures.newEditingApi: true`.
@@ -29,6 +29,10 @@ var _useGridRowReorder = require("../hooks/features/rowReorder/useGridRowReorder
29
29
 
30
30
  var _useGridRowReorderPreProcessors = require("../hooks/features/rowReorder/useGridRowReorderPreProcessors");
31
31
 
32
+ var _useGridRowPinning = require("../hooks/features/rowPinning/useGridRowPinning");
33
+
34
+ var _useGridRowPinningPreProcessors = require("../hooks/features/rowPinning/useGridRowPinningPreProcessors");
35
+
32
36
  // Pro-only features
33
37
  const useDataGridProComponent = (inputApiRef, props) => {
34
38
  var _props$experimentalFe, _props$experimentalFe2;
@@ -41,6 +45,7 @@ const useDataGridProComponent = (inputApiRef, props) => {
41
45
  (0, _internals.useGridSelectionPreProcessors)(apiRef, props);
42
46
  (0, _useGridRowReorderPreProcessors.useGridRowReorderPreProcessors)(apiRef, props);
43
47
  (0, _useGridTreeDataPreProcessors.useGridTreeDataPreProcessors)(apiRef, props);
48
+ (0, _useGridRowPinningPreProcessors.useGridRowPinningPreProcessors)(apiRef);
44
49
  (0, _useGridDetailPanelPreProcessors.useGridDetailPanelPreProcessors)(apiRef, props); // The column pinning `hydrateColumns` pre-processor must be after every other `hydrateColumns` pre-processors
45
50
  // Because it changes the order of the columns.
46
51
 
@@ -54,6 +59,7 @@ const useDataGridProComponent = (inputApiRef, props) => {
54
59
  (0, _internals.useGridInitializeState)(_useGridDetailPanel.detailPanelStateInitializer, apiRef, props);
55
60
  (0, _internals.useGridInitializeState)(_useGridColumnPinning.columnPinningStateInitializer, apiRef, props);
56
61
  (0, _internals.useGridInitializeState)(_internals.columnsStateInitializer, apiRef, props);
62
+ (0, _internals.useGridInitializeState)(_useGridRowPinning.rowPinningStateInitializer, apiRef, props);
57
63
  (0, _internals.useGridInitializeState)(_internals.rowsStateInitializer, apiRef, props);
58
64
  (0, _internals.useGridInitializeState)((_props$experimentalFe = props.experimentalFeatures) != null && _props$experimentalFe.newEditingApi ? _internals.editingStateInitializer_new : _internals.editingStateInitializer_old, apiRef, props);
59
65
  (0, _internals.useGridInitializeState)(_internals.focusStateInitializer, apiRef, props);
@@ -70,6 +76,7 @@ const useDataGridProComponent = (inputApiRef, props) => {
70
76
  (0, _internals.useGridKeyboardNavigation)(apiRef, props);
71
77
  (0, _internals.useGridSelection)(apiRef, props);
72
78
  (0, _useGridColumnPinning.useGridColumnPinning)(apiRef, props);
79
+ (0, _useGridRowPinning.useGridRowPinning)(apiRef, props);
73
80
  (0, _internals.useGridColumns)(apiRef, props);
74
81
  (0, _internals.useGridRows)(apiRef, props);
75
82
  (0, _internals.useGridParamsApi)(apiRef);
@@ -31,6 +31,8 @@ var _detailPanel = require("../hooks/features/detailPanel");
31
31
 
32
32
  var _GridDetailPanel = require("./GridDetailPanel");
33
33
 
34
+ var _gridRowPinningSelector = require("../hooks/features/rowPinning/gridRowPinningSelector");
35
+
34
36
  var _jsxRuntime = require("react/jsx-runtime");
35
37
 
36
38
  const _excluded = ["className", "disableVirtualization"];
@@ -69,13 +71,14 @@ exports.filterColumns = filterColumns;
69
71
 
70
72
  const useUtilityClasses = ownerState => {
71
73
  const {
72
- classes,
73
- leftPinnedColumns,
74
- rightPinnedColumns
74
+ classes
75
75
  } = ownerState;
76
76
  const slots = {
77
- leftPinnedColumns: ['pinnedColumns', leftPinnedColumns && leftPinnedColumns.length > 0 && 'pinnedColumns--left'],
78
- rightPinnedColumns: ['pinnedColumns', rightPinnedColumns && rightPinnedColumns.length > 0 && 'pinnedColumns--right'],
77
+ leftPinnedColumns: ['pinnedColumns', 'pinnedColumns--left'],
78
+ rightPinnedColumns: ['pinnedColumns', 'pinnedColumns--right'],
79
+ topPinnedRows: ['pinnedRows', 'pinnedRows--top'],
80
+ bottomPinnedRows: ['pinnedRows', 'pinnedRows--bottom'],
81
+ pinnedRowsRenderZone: ['pinnedRowsRenderZone'],
79
82
  detailPanels: ['detailPanels'],
80
83
  detailPanel: ['detailPanel']
81
84
  };
@@ -95,6 +98,10 @@ const getOverlayAlpha = elevation => {
95
98
  return alphaValue / 100;
96
99
  };
97
100
 
101
+ const getBoxShadowColor = theme => {
102
+ return (0, _styles.alpha)(theme.palette.common.black, 0.21);
103
+ };
104
+
98
105
  const VirtualScrollerDetailPanels = (0, _styles.styled)('div', {
99
106
  name: 'MuiDataGrid',
100
107
  slot: 'DetailPanels',
@@ -102,6 +109,7 @@ const VirtualScrollerDetailPanels = (0, _styles.styled)('div', {
102
109
  })({
103
110
  position: 'relative'
104
111
  });
112
+ const darkModeBackgroundImage = `linear-gradient(${(0, _styles.alpha)('#fff', getOverlayAlpha(2))}, ${(0, _styles.alpha)('#fff', getOverlayAlpha(2))})`;
105
113
  const VirtualScrollerPinnedColumns = (0, _styles.styled)('div', {
106
114
  name: 'MuiDataGrid',
107
115
  slot: 'PinnedColumns',
@@ -113,21 +121,56 @@ const VirtualScrollerPinnedColumns = (0, _styles.styled)('div', {
113
121
  })(({
114
122
  theme,
115
123
  ownerState
116
- }) => (0, _extends2.default)({
117
- position: 'sticky',
118
- overflow: 'hidden',
119
- zIndex: 1,
120
- boxShadow: theme.shadows[2],
121
- backgroundColor: theme.palette.background.default
122
- }, theme.palette.mode === 'dark' && {
123
- backgroundImage: `linear-gradient(${(0, _styles.alpha)('#fff', getOverlayAlpha(2))}, ${(0, _styles.alpha)('#fff', getOverlayAlpha(2))})`
124
- }, ownerState.side === _columnPinning.GridPinnedPosition.left && {
125
- left: 0,
126
- float: 'left'
127
- }, ownerState.side === _columnPinning.GridPinnedPosition.right && {
128
- right: 0,
129
- float: 'right'
130
- }));
124
+ }) => {
125
+ const boxShadowColor = getBoxShadowColor(theme);
126
+ return (0, _extends2.default)({
127
+ position: 'sticky',
128
+ overflow: 'hidden',
129
+ zIndex: 1,
130
+ backgroundColor: theme.palette.background.default
131
+ }, theme.palette.mode === 'dark' && {
132
+ backgroundImage: darkModeBackgroundImage
133
+ }, ownerState.side === _columnPinning.GridPinnedPosition.left && {
134
+ left: 0,
135
+ float: 'left',
136
+ boxShadow: `2px 0px 4px -2px ${boxShadowColor}`
137
+ }, ownerState.side === _columnPinning.GridPinnedPosition.right && {
138
+ right: 0,
139
+ float: 'right',
140
+ boxShadow: `-2px 0px 4px -2px ${boxShadowColor}`
141
+ });
142
+ });
143
+ const VirtualScrollerPinnedRows = (0, _styles.styled)('div', {
144
+ name: 'MuiDataGrid',
145
+ slot: 'PinnedRows',
146
+ overridesResolver: (props, styles) => [{
147
+ [`&.${_xDataGrid.gridClasses['pinnedRows--top']}`]: styles['pinnedRows--top']
148
+ }, {
149
+ [`&.${_xDataGrid.gridClasses['pinnedRows--bottom']}`]: styles['pinnedRows--bottom']
150
+ }, styles.pinnedRows]
151
+ })(({
152
+ theme,
153
+ ownerState
154
+ }) => {
155
+ const boxShadowColor = getBoxShadowColor(theme);
156
+ return (0, _extends2.default)({
157
+ position: 'sticky',
158
+ // should be above the detail panel
159
+ zIndex: 3,
160
+ backgroundColor: theme.palette.background.default
161
+ }, theme.palette.mode === 'dark' && {
162
+ backgroundImage: darkModeBackgroundImage
163
+ }, ownerState.position === 'top' && {
164
+ top: 0,
165
+ boxShadow: `0px 3px 4px -2px ${boxShadowColor}`
166
+ }, ownerState.position === 'bottom' && {
167
+ boxShadow: `0px -3px 4px -2px ${boxShadowColor}`,
168
+ bottom: 0
169
+ });
170
+ });
171
+ const VirtualScrollerPinnedRowsRenderZone = (0, _styles.styled)('div')({
172
+ position: 'absolute'
173
+ });
131
174
  const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGridProVirtualScroller(props, ref) {
132
175
  const other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
133
176
  const apiRef = (0, _useGridApiContext.useGridApiContext)();
@@ -138,8 +181,11 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
138
181
  const detailPanelsHeights = (0, _xDataGrid.useGridSelector)(apiRef, _detailPanel.gridDetailPanelExpandedRowsHeightCacheSelector);
139
182
  const leftColumns = React.useRef(null);
140
183
  const rightColumns = React.useRef(null);
184
+ const topPinnedRowsRenderZoneRef = React.useRef(null);
185
+ const bottomPinnedRowsRenderZoneRef = React.useRef(null);
141
186
  const handleRenderZonePositioning = React.useCallback(({
142
- top
187
+ top,
188
+ left
143
189
  }) => {
144
190
  if (leftColumns.current) {
145
191
  leftColumns.current.style.transform = `translate3d(0px, ${top}px, 0px)`;
@@ -148,6 +194,14 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
148
194
  if (rightColumns.current) {
149
195
  rightColumns.current.style.transform = `translate3d(0px, ${top}px, 0px)`;
150
196
  }
197
+
198
+ if (topPinnedRowsRenderZoneRef.current) {
199
+ topPinnedRowsRenderZoneRef.current.style.transform = `translate3d(${left}px, 0px, 0px)`;
200
+ }
201
+
202
+ if (bottomPinnedRowsRenderZoneRef.current) {
203
+ bottomPinnedRowsRenderZoneRef.current.style.transform = `translate3d(${left}px, 0px, 0px)`;
204
+ }
151
205
  }, []);
152
206
 
153
207
  const getRowProps = id => {
@@ -165,10 +219,15 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
165
219
 
166
220
  const pinnedColumns = (0, _xDataGrid.useGridSelector)(apiRef, _columnPinning.gridPinnedColumnsSelector);
167
221
  const [leftPinnedColumns, rightPinnedColumns] = filterColumns(pinnedColumns, visibleColumnFields);
222
+ const pinnedRows = (0, _xDataGrid.useGridSelector)(apiRef, _gridRowPinningSelector.gridPinnedRowsSelector);
223
+ const topPinnedRowsData = React.useMemo(() => (pinnedRows == null ? void 0 : pinnedRows.top) || [], [pinnedRows == null ? void 0 : pinnedRows.top]);
224
+ const bottomPinnedRowsData = React.useMemo(() => (pinnedRows == null ? void 0 : pinnedRows.bottom) || [], [pinnedRows == null ? void 0 : pinnedRows.bottom]);
168
225
  const ownerState = {
169
226
  classes: rootProps.classes,
170
227
  leftPinnedColumns,
171
- rightPinnedColumns
228
+ rightPinnedColumns,
229
+ topPinnedRowsCount: topPinnedRowsData.length,
230
+ bottomPinnedRowsCount: bottomPinnedRowsData.length
172
231
  };
173
232
  const classes = useUtilityClasses(ownerState);
174
233
  const {
@@ -201,10 +260,6 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
201
260
  firstColumnIndex: visibleColumnFields.length - rightPinnedColumns.length,
202
261
  lastColumnIndex: visibleColumnFields.length
203
262
  }) : null;
204
- const contentProps = getContentProps();
205
- const pinnedColumnsStyle = {
206
- minHeight: contentProps.style.minHeight
207
- };
208
263
 
209
264
  const getDetailPanels = () => {
210
265
  const panels = [];
@@ -245,8 +300,73 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
245
300
  };
246
301
 
247
302
  const detailPanels = getDetailPanels();
248
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_internals.GridVirtualScroller, (0, _extends2.default)({}, getRootProps(other), {
249
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_internals.GridVirtualScrollerContent, (0, _extends2.default)({}, contentProps, {
303
+ const topPinnedRows = getRows({
304
+ renderContext,
305
+ rows: topPinnedRowsData
306
+ });
307
+ const pinnedRowsHeight = (0, _internals.calculatePinnedRowsHeight)(apiRef);
308
+ const mainRows = getRows({
309
+ renderContext,
310
+ rowIndexOffset: topPinnedRowsData.length
311
+ });
312
+ const bottomPinnedRows = getRows({
313
+ renderContext,
314
+ rows: bottomPinnedRowsData,
315
+ rowIndexOffset: topPinnedRowsData.length + (mainRows ? mainRows.length : 0)
316
+ });
317
+ const contentProps = getContentProps();
318
+ const pinnedColumnsStyle = {
319
+ minHeight: contentProps.style.minHeight
320
+ };
321
+
322
+ if (contentProps.style.minHeight && contentProps.style.minHeight === '100%') {
323
+ contentProps.style.minHeight = `calc(100% - ${pinnedRowsHeight.top}px - ${pinnedRowsHeight.bottom}px)`;
324
+ }
325
+
326
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_internals.GridVirtualScroller, (0, _extends2.default)({}, getRootProps(other), {
327
+ children: [topPinnedRowsData.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(VirtualScrollerPinnedRows, {
328
+ className: classes.topPinnedRows,
329
+ ownerState: {
330
+ position: 'top'
331
+ },
332
+ style: {
333
+ width: contentProps.style.width,
334
+ height: pinnedRowsHeight.top
335
+ },
336
+ role: "rowgroup",
337
+ children: [leftRenderContext && /*#__PURE__*/(0, _jsxRuntime.jsx)(VirtualScrollerPinnedColumns, {
338
+ className: classes.leftPinnedColumns,
339
+ ownerState: {
340
+ side: _columnPinning.GridPinnedPosition.left
341
+ },
342
+ children: getRows({
343
+ renderContext: leftRenderContext,
344
+ minFirstColumn: leftRenderContext.firstColumnIndex,
345
+ maxLastColumn: leftRenderContext.lastColumnIndex,
346
+ availableSpace: 0,
347
+ ignoreAutoHeight: true,
348
+ rows: topPinnedRowsData
349
+ })
350
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(VirtualScrollerPinnedRowsRenderZone, {
351
+ className: classes.pinnedRowsRenderZone,
352
+ ref: topPinnedRowsRenderZoneRef,
353
+ role: "presentation",
354
+ children: topPinnedRows
355
+ }), rightRenderContext && /*#__PURE__*/(0, _jsxRuntime.jsx)(VirtualScrollerPinnedColumns, {
356
+ className: classes.rightPinnedColumns,
357
+ ownerState: {
358
+ side: _columnPinning.GridPinnedPosition.right
359
+ },
360
+ children: getRows({
361
+ renderContext: rightRenderContext,
362
+ minFirstColumn: rightRenderContext.firstColumnIndex,
363
+ maxLastColumn: rightRenderContext.lastColumnIndex,
364
+ ignoreAutoHeight: true,
365
+ availableSpace: 0,
366
+ rows: topPinnedRowsData
367
+ })
368
+ })]
369
+ }) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_internals.GridVirtualScrollerContent, (0, _extends2.default)({}, contentProps, {
250
370
  children: [leftRenderContext && /*#__PURE__*/(0, _jsxRuntime.jsx)(VirtualScrollerPinnedColumns, {
251
371
  ref: leftColumns,
252
372
  className: classes.leftPinnedColumns,
@@ -259,12 +379,11 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
259
379
  minFirstColumn: leftRenderContext.firstColumnIndex,
260
380
  maxLastColumn: leftRenderContext.lastColumnIndex,
261
381
  availableSpace: 0,
262
- ignoreAutoHeight: true
382
+ ignoreAutoHeight: true,
383
+ rowIndexOffset: topPinnedRowsData.length
263
384
  })
264
385
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_internals.GridVirtualScrollerRenderZone, (0, _extends2.default)({}, getRenderZoneProps(), {
265
- children: getRows({
266
- renderContext
267
- })
386
+ children: mainRows
268
387
  })), rightRenderContext && /*#__PURE__*/(0, _jsxRuntime.jsx)(VirtualScrollerPinnedColumns, {
269
388
  ref: rightColumns,
270
389
  ownerState: {
@@ -277,13 +396,58 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
277
396
  minFirstColumn: rightRenderContext.firstColumnIndex,
278
397
  maxLastColumn: rightRenderContext.lastColumnIndex,
279
398
  availableSpace: 0,
280
- ignoreAutoHeight: true
399
+ ignoreAutoHeight: true,
400
+ rowIndexOffset: topPinnedRowsData.length
281
401
  })
282
402
  }), detailPanels.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(VirtualScrollerDetailPanels, {
283
403
  className: classes.detailPanels,
284
404
  children: detailPanels
285
405
  })]
286
- }))
406
+ })), bottomPinnedRowsData.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(VirtualScrollerPinnedRows, {
407
+ className: classes.bottomPinnedRows,
408
+ ownerState: {
409
+ position: 'bottom'
410
+ },
411
+ style: {
412
+ width: contentProps.style.width,
413
+ height: pinnedRowsHeight.bottom
414
+ },
415
+ role: "rowgroup",
416
+ children: [leftRenderContext && /*#__PURE__*/(0, _jsxRuntime.jsx)(VirtualScrollerPinnedColumns, {
417
+ className: classes.leftPinnedColumns,
418
+ ownerState: {
419
+ side: _columnPinning.GridPinnedPosition.left
420
+ },
421
+ children: getRows({
422
+ renderContext: leftRenderContext,
423
+ minFirstColumn: leftRenderContext.firstColumnIndex,
424
+ maxLastColumn: leftRenderContext.lastColumnIndex,
425
+ availableSpace: 0,
426
+ ignoreAutoHeight: true,
427
+ rows: bottomPinnedRowsData,
428
+ rowIndexOffset: topPinnedRowsData.length + (mainRows ? mainRows.length : 0)
429
+ })
430
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(VirtualScrollerPinnedRowsRenderZone, {
431
+ className: classes.pinnedRowsRenderZone,
432
+ ref: bottomPinnedRowsRenderZoneRef,
433
+ role: "presentation",
434
+ children: bottomPinnedRows
435
+ }), rightRenderContext && /*#__PURE__*/(0, _jsxRuntime.jsx)(VirtualScrollerPinnedColumns, {
436
+ className: classes.rightPinnedColumns,
437
+ ownerState: {
438
+ side: _columnPinning.GridPinnedPosition.right
439
+ },
440
+ children: getRows({
441
+ renderContext: rightRenderContext,
442
+ minFirstColumn: rightRenderContext.firstColumnIndex,
443
+ maxLastColumn: rightRenderContext.lastColumnIndex,
444
+ availableSpace: 0,
445
+ ignoreAutoHeight: true,
446
+ rows: bottomPinnedRowsData,
447
+ rowIndexOffset: topPinnedRowsData.length + (mainRows ? mainRows.length : 0)
448
+ })
449
+ })]
450
+ }) : null]
287
451
  }));
288
452
  });
289
453
  exports.DataGridProVirtualScroller = DataGridProVirtualScroller;
@@ -94,6 +94,12 @@ const GridRowReorderCell = params => {
94
94
 
95
95
  exports.GridRowReorderCell = GridRowReorderCell;
96
96
 
97
- const renderRowReorderCell = params => /*#__PURE__*/(0, _jsxRuntime.jsx)(GridRowReorderCell, (0, _extends2.default)({}, params));
97
+ const renderRowReorderCell = params => {
98
+ if (params.rowNode.isPinned) {
99
+ return null;
100
+ }
101
+
102
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridRowReorderCell, (0, _extends2.default)({}, params));
103
+ };
98
104
 
99
105
  exports.renderRowReorderCell = renderRowReorderCell;
@@ -80,4 +80,17 @@ Object.keys(_detailPanel).forEach(function (key) {
80
80
  return _detailPanel[key];
81
81
  }
82
82
  });
83
+ });
84
+
85
+ var _rowPinning = require("./rowPinning");
86
+
87
+ Object.keys(_rowPinning).forEach(function (key) {
88
+ if (key === "default" || key === "__esModule") return;
89
+ if (key in exports && exports[key] === _rowPinning[key]) return;
90
+ Object.defineProperty(exports, key, {
91
+ enumerable: true,
92
+ get: function () {
93
+ return _rowPinning[key];
94
+ }
95
+ });
83
96
  });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "gridAdditionalRowGroupsSelector", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _internals.gridAdditionalRowGroupsSelector;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "gridPinnedRowsSelector", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _internals.gridPinnedRowsSelector;
16
+ }
17
+ });
18
+
19
+ var _internals = require("@mui/x-data-grid/internals");
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _gridRowPinningInterface = require("./gridRowPinningInterface");
8
+
9
+ Object.keys(_gridRowPinningInterface).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _gridRowPinningInterface[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _gridRowPinningInterface[key];
16
+ }
17
+ });
18
+ });