@mui/x-data-grid-pro 5.14.0 → 5.15.2

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 (78) hide show
  1. package/CHANGELOG.md +147 -5
  2. package/DataGridPro/DataGridPro.js +16 -1
  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/hooks/features/treeData/gridTreeDataUtils.d.ts +2 -1
  21. package/hooks/features/treeData/gridTreeDataUtils.js +7 -2
  22. package/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -1
  23. package/index.js +1 -1
  24. package/internals/index.d.ts +2 -0
  25. package/internals/index.js +2 -0
  26. package/legacy/DataGridPro/DataGridPro.js +16 -1
  27. package/legacy/DataGridPro/useDataGridProComponent.js +5 -0
  28. package/legacy/components/DataGridProVirtualScroller.js +187 -25
  29. package/legacy/components/GridRowReorderCell.js +4 -0
  30. package/legacy/hooks/features/index.js +2 -1
  31. package/legacy/hooks/features/rowPinning/gridRowPinningInterface.js +1 -0
  32. package/legacy/hooks/features/rowPinning/gridRowPinningSelector.js +1 -0
  33. package/legacy/hooks/features/rowPinning/index.js +1 -0
  34. package/legacy/hooks/features/rowPinning/useGridRowPinning.js +71 -0
  35. package/legacy/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +89 -0
  36. package/legacy/hooks/features/rowReorder/useGridRowReorder.js +6 -0
  37. package/legacy/hooks/features/treeData/gridTreeDataUtils.js +7 -2
  38. package/legacy/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -1
  39. package/legacy/index.js +1 -1
  40. package/legacy/internals/index.js +2 -0
  41. package/legacy/utils/releaseInfo.js +1 -1
  42. package/models/dataGridProProps.d.ts +11 -5
  43. package/models/gridApiPro.d.ts +2 -2
  44. package/modern/DataGridPro/DataGridPro.js +16 -1
  45. package/modern/DataGridPro/useDataGridProComponent.js +5 -0
  46. package/modern/components/DataGridProVirtualScroller.js +198 -35
  47. package/modern/components/GridRowReorderCell.js +7 -1
  48. package/modern/hooks/features/index.js +2 -1
  49. package/modern/hooks/features/rowPinning/gridRowPinningInterface.js +1 -0
  50. package/modern/hooks/features/rowPinning/gridRowPinningSelector.js +1 -0
  51. package/modern/hooks/features/rowPinning/index.js +1 -0
  52. package/modern/hooks/features/rowPinning/useGridRowPinning.js +63 -0
  53. package/modern/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +85 -0
  54. package/modern/hooks/features/rowReorder/useGridRowReorder.js +4 -0
  55. package/modern/hooks/features/treeData/gridTreeDataUtils.js +7 -2
  56. package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -1
  57. package/modern/index.js +1 -1
  58. package/modern/internals/index.js +2 -0
  59. package/modern/utils/releaseInfo.js +1 -1
  60. package/node/DataGridPro/DataGridPro.js +16 -1
  61. package/node/DataGridPro/useDataGridProComponent.js +7 -0
  62. package/node/components/DataGridProVirtualScroller.js +198 -34
  63. package/node/components/GridRowReorderCell.js +7 -1
  64. package/node/hooks/features/index.js +13 -0
  65. package/node/hooks/features/rowPinning/gridRowPinningInterface.js +5 -0
  66. package/node/hooks/features/rowPinning/gridRowPinningSelector.js +19 -0
  67. package/node/hooks/features/rowPinning/index.js +18 -0
  68. package/node/hooks/features/rowPinning/useGridRowPinning.js +92 -0
  69. package/node/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +105 -0
  70. package/node/hooks/features/rowReorder/useGridRowReorder.js +6 -0
  71. package/node/hooks/features/treeData/gridTreeDataUtils.js +9 -2
  72. package/node/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -1
  73. package/node/index.js +1 -1
  74. package/node/internals/index.js +32 -0
  75. package/node/utils/releaseInfo.js +1 -1
  76. package/package.json +3 -3
  77. package/typeOverloads/modules.d.ts +2 -0
  78. package/utils/releaseInfo.js +1 -1
@@ -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
 
@@ -839,7 +846,7 @@ DataGridProRaw.propTypes = {
839
846
  * @param {GridState} state The new state.
840
847
  * @param {MuiEvent<{}>} event The event object.
841
848
  * @param {GridCallbackDetails} details Additional details for this callback.
842
- * @internal
849
+ * @ignore - do not document.
843
850
  */
844
851
  onStateChange: _propTypes.default.func,
845
852
 
@@ -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
+ });
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.useGridRowPinning = exports.rowPinningStateInitializer = void 0;
9
+
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+
12
+ var React = _interopRequireWildcard(require("react"));
13
+
14
+ var _xDataGrid = require("@mui/x-data-grid");
15
+
16
+ var _internals = require("@mui/x-data-grid/internals");
17
+
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
+
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+
22
+ function createPinnedRowsInternalCache(pinnedRows, getRowId) {
23
+ var _pinnedRows$top, _pinnedRows$bottom;
24
+
25
+ const cache = {
26
+ topIds: [],
27
+ bottomIds: [],
28
+ idLookup: {}
29
+ };
30
+ pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.forEach(rowModel => {
31
+ const id = (0, _internals.getRowIdFromRowModel)(rowModel, getRowId);
32
+ cache.topIds.push(id);
33
+ cache.idLookup[id] = rowModel;
34
+ });
35
+ pinnedRows == null ? void 0 : (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.forEach(rowModel => {
36
+ const id = (0, _internals.getRowIdFromRowModel)(rowModel, getRowId);
37
+ cache.bottomIds.push(id);
38
+ cache.idLookup[id] = rowModel;
39
+ });
40
+ return cache;
41
+ }
42
+
43
+ const rowPinningStateInitializer = (state, props, apiRef) => {
44
+ var _props$experimentalFe, _state$rows;
45
+
46
+ if (!((_props$experimentalFe = props.experimentalFeatures) != null && _props$experimentalFe.rowPinning)) {
47
+ return state;
48
+ }
49
+
50
+ apiRef.current.unstable_caches.pinnedRows = createPinnedRowsInternalCache(props.pinnedRows, props.getRowId);
51
+ return (0, _extends2.default)({}, state, {
52
+ rows: (0, _extends2.default)({}, state.rows, {
53
+ additionalRowGroups: (0, _extends2.default)({}, (_state$rows = state.rows) == null ? void 0 : _state$rows.additionalRowGroups, {
54
+ pinnedRows: {
55
+ top: [],
56
+ bottom: []
57
+ }
58
+ })
59
+ })
60
+ });
61
+ };
62
+
63
+ exports.rowPinningStateInitializer = rowPinningStateInitializer;
64
+
65
+ const useGridRowPinning = (apiRef, props) => {
66
+ var _props$experimentalFe3;
67
+
68
+ const setPinnedRows = React.useCallback(newPinnedRows => {
69
+ var _props$experimentalFe2;
70
+
71
+ if (!((_props$experimentalFe2 = props.experimentalFeatures) != null && _props$experimentalFe2.rowPinning)) {
72
+ return;
73
+ }
74
+
75
+ apiRef.current.unstable_caches.pinnedRows = createPinnedRowsInternalCache(newPinnedRows, props.getRowId);
76
+ apiRef.current.unstable_requestPipeProcessorsApplication('hydrateRows');
77
+ }, [apiRef, (_props$experimentalFe3 = props.experimentalFeatures) == null ? void 0 : _props$experimentalFe3.rowPinning, props.getRowId]);
78
+ (0, _xDataGrid.useGridApiMethod)(apiRef, {
79
+ unstable_setPinnedRows: setPinnedRows
80
+ }, 'rowPinningApi');
81
+ const isFirstRender = React.useRef(true);
82
+ React.useEffect(() => {
83
+ if (isFirstRender.current) {
84
+ isFirstRender.current = false;
85
+ return;
86
+ }
87
+
88
+ apiRef.current.unstable_setPinnedRows(props.pinnedRows);
89
+ }, [apiRef, props.pinnedRows]);
90
+ };
91
+
92
+ exports.useGridRowPinning = useGridRowPinning;