@mui/x-data-grid-pro 5.13.1 → 5.15.1

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 (90) hide show
  1. package/CHANGELOG.md +147 -6
  2. package/DataGridPro/DataGridPro.js +15 -0
  3. package/DataGridPro/useDataGridProComponent.js +6 -1
  4. package/components/DataGridProVirtualScroller.js +198 -35
  5. package/components/GridRowReorderCell.d.ts +2 -2
  6. package/components/GridRowReorderCell.js +14 -1
  7. package/hooks/features/columnPinning/useGridColumnPinning.d.ts +1 -1
  8. package/hooks/features/columnPinning/useGridColumnPinning.js +12 -3
  9. package/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +2 -0
  10. package/hooks/features/index.d.ts +1 -0
  11. package/hooks/features/index.js +2 -1
  12. package/hooks/features/rowPinning/gridRowPinningInterface.d.ts +17 -0
  13. package/hooks/features/rowPinning/gridRowPinningInterface.js +1 -0
  14. package/hooks/features/rowPinning/gridRowPinningSelector.d.ts +1 -0
  15. package/hooks/features/rowPinning/gridRowPinningSelector.js +1 -0
  16. package/hooks/features/rowPinning/index.d.ts +1 -0
  17. package/hooks/features/rowPinning/index.js +1 -0
  18. package/hooks/features/rowPinning/useGridRowPinning.d.ts +6 -0
  19. package/hooks/features/rowPinning/useGridRowPinning.js +71 -0
  20. package/hooks/features/rowPinning/useGridRowPinningPreProcessors.d.ts +34 -0
  21. package/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +89 -0
  22. package/hooks/features/rowReorder/gridRowReorderColDef.js +2 -0
  23. package/hooks/features/rowReorder/useGridRowReorder.js +6 -0
  24. package/hooks/features/treeData/gridTreeDataUtils.js +9 -0
  25. package/index.js +1 -1
  26. package/internals/index.d.ts +3 -0
  27. package/internals/index.js +3 -0
  28. package/legacy/DataGridPro/DataGridPro.js +15 -0
  29. package/legacy/DataGridPro/useDataGridProComponent.js +6 -1
  30. package/legacy/components/DataGridProVirtualScroller.js +187 -25
  31. package/legacy/components/GridRowReorderCell.js +11 -0
  32. package/legacy/hooks/features/columnPinning/useGridColumnPinning.js +12 -3
  33. package/legacy/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +2 -0
  34. package/legacy/hooks/features/index.js +2 -1
  35. package/legacy/hooks/features/rowPinning/gridRowPinningInterface.js +1 -0
  36. package/legacy/hooks/features/rowPinning/gridRowPinningSelector.js +1 -0
  37. package/legacy/hooks/features/rowPinning/index.js +1 -0
  38. package/legacy/hooks/features/rowPinning/useGridRowPinning.js +71 -0
  39. package/legacy/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +89 -0
  40. package/legacy/hooks/features/rowReorder/gridRowReorderColDef.js +2 -0
  41. package/legacy/hooks/features/rowReorder/useGridRowReorder.js +6 -0
  42. package/legacy/hooks/features/treeData/gridTreeDataUtils.js +9 -0
  43. package/legacy/index.js +1 -1
  44. package/legacy/internals/index.js +3 -0
  45. package/legacy/utils/releaseInfo.js +1 -1
  46. package/legacy/utils/tree/sortRowTree.js +27 -14
  47. package/models/dataGridProProps.d.ts +11 -5
  48. package/models/gridApiPro.d.ts +2 -2
  49. package/modern/DataGridPro/DataGridPro.js +15 -0
  50. package/modern/DataGridPro/useDataGridProComponent.js +6 -1
  51. package/modern/components/DataGridProVirtualScroller.js +198 -35
  52. package/modern/components/GridRowReorderCell.js +12 -1
  53. package/modern/hooks/features/columnPinning/useGridColumnPinning.js +8 -3
  54. package/modern/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +2 -0
  55. package/modern/hooks/features/index.js +2 -1
  56. package/modern/hooks/features/rowPinning/gridRowPinningInterface.js +1 -0
  57. package/modern/hooks/features/rowPinning/gridRowPinningSelector.js +1 -0
  58. package/modern/hooks/features/rowPinning/index.js +1 -0
  59. package/modern/hooks/features/rowPinning/useGridRowPinning.js +63 -0
  60. package/modern/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +85 -0
  61. package/modern/hooks/features/rowReorder/gridRowReorderColDef.js +2 -0
  62. package/modern/hooks/features/rowReorder/useGridRowReorder.js +4 -0
  63. package/modern/hooks/features/treeData/gridTreeDataUtils.js +9 -0
  64. package/modern/index.js +1 -1
  65. package/modern/internals/index.js +3 -0
  66. package/modern/utils/releaseInfo.js +1 -1
  67. package/modern/utils/tree/sortRowTree.js +26 -11
  68. package/node/DataGridPro/DataGridPro.js +15 -0
  69. package/node/DataGridPro/useDataGridProComponent.js +8 -1
  70. package/node/components/DataGridProVirtualScroller.js +198 -34
  71. package/node/components/GridRowReorderCell.js +14 -1
  72. package/node/hooks/features/columnPinning/useGridColumnPinning.js +12 -3
  73. package/node/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +2 -0
  74. package/node/hooks/features/index.js +13 -0
  75. package/node/hooks/features/rowPinning/gridRowPinningInterface.js +5 -0
  76. package/node/hooks/features/rowPinning/gridRowPinningSelector.js +19 -0
  77. package/node/hooks/features/rowPinning/index.js +18 -0
  78. package/node/hooks/features/rowPinning/useGridRowPinning.js +92 -0
  79. package/node/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +105 -0
  80. package/node/hooks/features/rowReorder/gridRowReorderColDef.js +2 -0
  81. package/node/hooks/features/rowReorder/useGridRowReorder.js +6 -0
  82. package/node/hooks/features/treeData/gridTreeDataUtils.js +9 -0
  83. package/node/index.js +1 -1
  84. package/node/internals/index.js +41 -0
  85. package/node/utils/releaseInfo.js +1 -1
  86. package/node/utils/tree/sortRowTree.js +26 -11
  87. package/package.json +3 -3
  88. package/typeOverloads/modules.d.ts +2 -0
  89. package/utils/releaseInfo.js +1 -1
  90. package/utils/tree/sortRowTree.js +26 -11
@@ -8,12 +8,13 @@ import * as React from 'react';
8
8
  import { styled, alpha } from '@mui/material/styles';
9
9
  import { unstable_composeClasses as composeClasses } from '@mui/material';
10
10
  import { useGridSelector, getDataGridUtilityClass, gridClasses, gridVisibleColumnFieldsSelector, gridRowsMetaSelector, useGridApiEventHandler } from '@mui/x-data-grid';
11
- import { GridVirtualScroller, GridVirtualScrollerContent, GridVirtualScrollerRenderZone, useGridVirtualScroller } from '@mui/x-data-grid/internals';
11
+ import { GridVirtualScroller, GridVirtualScrollerContent, GridVirtualScrollerRenderZone, useGridVirtualScroller, calculatePinnedRowsHeight } from '@mui/x-data-grid/internals';
12
12
  import { useGridApiContext } from '../hooks/utils/useGridApiContext';
13
13
  import { useGridRootProps } from '../hooks/utils/useGridRootProps';
14
14
  import { gridPinnedColumnsSelector, GridPinnedPosition } from '../hooks/features/columnPinning';
15
15
  import { gridDetailPanelExpandedRowsContentCacheSelector, gridDetailPanelExpandedRowsHeightCacheSelector, gridDetailPanelExpandedRowIdsSelector } from '../hooks/features/detailPanel';
16
16
  import { GridDetailPanel } from './GridDetailPanel';
17
+ import { gridPinnedRowsSelector } from '../hooks/features/rowPinning/gridRowPinningSelector';
17
18
  import { jsx as _jsx } from "react/jsx-runtime";
18
19
  import { jsxs as _jsxs } from "react/jsx-runtime";
19
20
  export var filterColumns = function filterColumns(pinnedColumns, columns) {
@@ -47,12 +48,13 @@ export var filterColumns = function filterColumns(pinnedColumns, columns) {
47
48
  };
48
49
 
49
50
  var useUtilityClasses = function useUtilityClasses(ownerState) {
50
- var classes = ownerState.classes,
51
- leftPinnedColumns = ownerState.leftPinnedColumns,
52
- rightPinnedColumns = ownerState.rightPinnedColumns;
51
+ var classes = ownerState.classes;
53
52
  var slots = {
54
- leftPinnedColumns: ['pinnedColumns', leftPinnedColumns && leftPinnedColumns.length > 0 && 'pinnedColumns--left'],
55
- rightPinnedColumns: ['pinnedColumns', rightPinnedColumns && rightPinnedColumns.length > 0 && 'pinnedColumns--right'],
53
+ leftPinnedColumns: ['pinnedColumns', 'pinnedColumns--left'],
54
+ rightPinnedColumns: ['pinnedColumns', 'pinnedColumns--right'],
55
+ topPinnedRows: ['pinnedRows', 'pinnedRows--top'],
56
+ bottomPinnedRows: ['pinnedRows', 'pinnedRows--bottom'],
57
+ pinnedRowsRenderZone: ['pinnedRowsRenderZone'],
56
58
  detailPanels: ['detailPanels'],
57
59
  detailPanel: ['detailPanel']
58
60
  };
@@ -72,6 +74,10 @@ var getOverlayAlpha = function getOverlayAlpha(elevation) {
72
74
  return alphaValue / 100;
73
75
  };
74
76
 
77
+ var getBoxShadowColor = function getBoxShadowColor(theme) {
78
+ return alpha(theme.palette.common.black, 0.21);
79
+ };
80
+
75
81
  var VirtualScrollerDetailPanels = styled('div', {
76
82
  name: 'MuiDataGrid',
77
83
  slot: 'DetailPanels',
@@ -81,6 +87,7 @@ var VirtualScrollerDetailPanels = styled('div', {
81
87
  })({
82
88
  position: 'relative'
83
89
  });
90
+ var darkModeBackgroundImage = "linear-gradient(".concat(alpha('#fff', getOverlayAlpha(2)), ", ").concat(alpha('#fff', getOverlayAlpha(2)), ")");
84
91
  var VirtualScrollerPinnedColumns = styled('div', {
85
92
  name: 'MuiDataGrid',
86
93
  slot: 'PinnedColumns',
@@ -90,22 +97,52 @@ var VirtualScrollerPinnedColumns = styled('div', {
90
97
  })(function (_ref3) {
91
98
  var theme = _ref3.theme,
92
99
  ownerState = _ref3.ownerState;
100
+ var boxShadowColor = getBoxShadowColor(theme);
93
101
  return _extends({
94
102
  position: 'sticky',
95
103
  overflow: 'hidden',
96
104
  zIndex: 1,
97
- boxShadow: theme.shadows[2],
98
105
  backgroundColor: theme.palette.background.default
99
106
  }, theme.palette.mode === 'dark' && {
100
- backgroundImage: "linear-gradient(".concat(alpha('#fff', getOverlayAlpha(2)), ", ").concat(alpha('#fff', getOverlayAlpha(2)), ")")
107
+ backgroundImage: darkModeBackgroundImage
101
108
  }, ownerState.side === GridPinnedPosition.left && {
102
109
  left: 0,
103
- float: 'left'
110
+ float: 'left',
111
+ boxShadow: "2px 0px 4px -2px ".concat(boxShadowColor)
104
112
  }, ownerState.side === GridPinnedPosition.right && {
105
113
  right: 0,
106
- float: 'right'
114
+ float: 'right',
115
+ boxShadow: "-2px 0px 4px -2px ".concat(boxShadowColor)
116
+ });
117
+ });
118
+ var VirtualScrollerPinnedRows = styled('div', {
119
+ name: 'MuiDataGrid',
120
+ slot: 'PinnedRows',
121
+ overridesResolver: function overridesResolver(props, styles) {
122
+ return [_defineProperty({}, "&.".concat(gridClasses['pinnedRows--top']), styles['pinnedRows--top']), _defineProperty({}, "&.".concat(gridClasses['pinnedRows--bottom']), styles['pinnedRows--bottom']), styles.pinnedRows];
123
+ }
124
+ })(function (_ref6) {
125
+ var theme = _ref6.theme,
126
+ ownerState = _ref6.ownerState;
127
+ var boxShadowColor = getBoxShadowColor(theme);
128
+ return _extends({
129
+ position: 'sticky',
130
+ // should be above the detail panel
131
+ zIndex: 3,
132
+ backgroundColor: theme.palette.background.default
133
+ }, theme.palette.mode === 'dark' && {
134
+ backgroundImage: darkModeBackgroundImage
135
+ }, ownerState.position === 'top' && {
136
+ top: 0,
137
+ boxShadow: "0px 3px 4px -2px ".concat(boxShadowColor)
138
+ }, ownerState.position === 'bottom' && {
139
+ boxShadow: "0px -3px 4px -2px ".concat(boxShadowColor),
140
+ bottom: 0
107
141
  });
108
142
  });
143
+ var VirtualScrollerPinnedRowsRenderZone = styled('div')({
144
+ position: 'absolute'
145
+ });
109
146
  var DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGridProVirtualScroller(props, ref) {
110
147
  var className = props.className,
111
148
  disableVirtualization = props.disableVirtualization,
@@ -119,8 +156,11 @@ var DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGrid
119
156
  var detailPanelsHeights = useGridSelector(apiRef, gridDetailPanelExpandedRowsHeightCacheSelector);
120
157
  var leftColumns = React.useRef(null);
121
158
  var rightColumns = React.useRef(null);
122
- var handleRenderZonePositioning = React.useCallback(function (_ref4) {
123
- var top = _ref4.top;
159
+ var topPinnedRowsRenderZoneRef = React.useRef(null);
160
+ var bottomPinnedRowsRenderZoneRef = React.useRef(null);
161
+ var handleRenderZonePositioning = React.useCallback(function (_ref7) {
162
+ var top = _ref7.top,
163
+ left = _ref7.left;
124
164
 
125
165
  if (leftColumns.current) {
126
166
  leftColumns.current.style.transform = "translate3d(0px, ".concat(top, "px, 0px)");
@@ -129,6 +169,14 @@ var DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGrid
129
169
  if (rightColumns.current) {
130
170
  rightColumns.current.style.transform = "translate3d(0px, ".concat(top, "px, 0px)");
131
171
  }
172
+
173
+ if (topPinnedRowsRenderZoneRef.current) {
174
+ topPinnedRowsRenderZoneRef.current.style.transform = "translate3d(".concat(left, "px, 0px, 0px)");
175
+ }
176
+
177
+ if (bottomPinnedRowsRenderZoneRef.current) {
178
+ bottomPinnedRowsRenderZoneRef.current.style.transform = "translate3d(".concat(left, "px, 0px, 0px)");
179
+ }
132
180
  }, []);
133
181
 
134
182
  var getRowProps = function getRowProps(id) {
@@ -151,10 +199,19 @@ var DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGrid
151
199
  leftPinnedColumns = _filterColumns2[0],
152
200
  rightPinnedColumns = _filterColumns2[1];
153
201
 
202
+ var pinnedRows = useGridSelector(apiRef, gridPinnedRowsSelector);
203
+ var topPinnedRowsData = React.useMemo(function () {
204
+ return (pinnedRows == null ? void 0 : pinnedRows.top) || [];
205
+ }, [pinnedRows == null ? void 0 : pinnedRows.top]);
206
+ var bottomPinnedRowsData = React.useMemo(function () {
207
+ return (pinnedRows == null ? void 0 : pinnedRows.bottom) || [];
208
+ }, [pinnedRows == null ? void 0 : pinnedRows.bottom]);
154
209
  var ownerState = {
155
210
  classes: rootProps.classes,
156
211
  leftPinnedColumns: leftPinnedColumns,
157
- rightPinnedColumns: rightPinnedColumns
212
+ rightPinnedColumns: rightPinnedColumns,
213
+ topPinnedRowsCount: topPinnedRowsData.length,
214
+ bottomPinnedRowsCount: bottomPinnedRowsData.length
158
215
  };
159
216
  var classes = useUtilityClasses(ownerState);
160
217
 
@@ -188,10 +245,6 @@ var DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGrid
188
245
  firstColumnIndex: visibleColumnFields.length - rightPinnedColumns.length,
189
246
  lastColumnIndex: visibleColumnFields.length
190
247
  }) : null;
191
- var contentProps = getContentProps();
192
- var pinnedColumnsStyle = {
193
- minHeight: contentProps.style.minHeight
194
- };
195
248
 
196
249
  var getDetailPanels = function getDetailPanels() {
197
250
  var panels = [];
@@ -232,8 +285,73 @@ var DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGrid
232
285
  };
233
286
 
234
287
  var detailPanels = getDetailPanels();
235
- return /*#__PURE__*/_jsx(GridVirtualScroller, _extends({}, getRootProps(other), {
236
- children: /*#__PURE__*/_jsxs(GridVirtualScrollerContent, _extends({}, contentProps, {
288
+ var topPinnedRows = getRows({
289
+ renderContext: renderContext,
290
+ rows: topPinnedRowsData
291
+ });
292
+ var pinnedRowsHeight = calculatePinnedRowsHeight(apiRef);
293
+ var mainRows = getRows({
294
+ renderContext: renderContext,
295
+ rowIndexOffset: topPinnedRowsData.length
296
+ });
297
+ var bottomPinnedRows = getRows({
298
+ renderContext: renderContext,
299
+ rows: bottomPinnedRowsData,
300
+ rowIndexOffset: topPinnedRowsData.length + (mainRows ? mainRows.length : 0)
301
+ });
302
+ var contentProps = getContentProps();
303
+ var pinnedColumnsStyle = {
304
+ minHeight: contentProps.style.minHeight
305
+ };
306
+
307
+ if (contentProps.style.minHeight && contentProps.style.minHeight === '100%') {
308
+ contentProps.style.minHeight = "calc(100% - ".concat(pinnedRowsHeight.top, "px - ").concat(pinnedRowsHeight.bottom, "px)");
309
+ }
310
+
311
+ return /*#__PURE__*/_jsxs(GridVirtualScroller, _extends({}, getRootProps(other), {
312
+ children: [topPinnedRowsData.length > 0 ? /*#__PURE__*/_jsxs(VirtualScrollerPinnedRows, {
313
+ className: classes.topPinnedRows,
314
+ ownerState: {
315
+ position: 'top'
316
+ },
317
+ style: {
318
+ width: contentProps.style.width,
319
+ height: pinnedRowsHeight.top
320
+ },
321
+ role: "rowgroup",
322
+ children: [leftRenderContext && /*#__PURE__*/_jsx(VirtualScrollerPinnedColumns, {
323
+ className: classes.leftPinnedColumns,
324
+ ownerState: {
325
+ side: GridPinnedPosition.left
326
+ },
327
+ children: getRows({
328
+ renderContext: leftRenderContext,
329
+ minFirstColumn: leftRenderContext.firstColumnIndex,
330
+ maxLastColumn: leftRenderContext.lastColumnIndex,
331
+ availableSpace: 0,
332
+ ignoreAutoHeight: true,
333
+ rows: topPinnedRowsData
334
+ })
335
+ }), /*#__PURE__*/_jsx(VirtualScrollerPinnedRowsRenderZone, {
336
+ className: classes.pinnedRowsRenderZone,
337
+ ref: topPinnedRowsRenderZoneRef,
338
+ role: "presentation",
339
+ children: topPinnedRows
340
+ }), rightRenderContext && /*#__PURE__*/_jsx(VirtualScrollerPinnedColumns, {
341
+ className: classes.rightPinnedColumns,
342
+ ownerState: {
343
+ side: GridPinnedPosition.right
344
+ },
345
+ children: getRows({
346
+ renderContext: rightRenderContext,
347
+ minFirstColumn: rightRenderContext.firstColumnIndex,
348
+ maxLastColumn: rightRenderContext.lastColumnIndex,
349
+ ignoreAutoHeight: true,
350
+ availableSpace: 0,
351
+ rows: topPinnedRowsData
352
+ })
353
+ })]
354
+ }) : null, /*#__PURE__*/_jsxs(GridVirtualScrollerContent, _extends({}, contentProps, {
237
355
  children: [leftRenderContext && /*#__PURE__*/_jsx(VirtualScrollerPinnedColumns, {
238
356
  ref: leftColumns,
239
357
  className: classes.leftPinnedColumns,
@@ -246,12 +364,11 @@ var DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGrid
246
364
  minFirstColumn: leftRenderContext.firstColumnIndex,
247
365
  maxLastColumn: leftRenderContext.lastColumnIndex,
248
366
  availableSpace: 0,
249
- ignoreAutoHeight: true
367
+ ignoreAutoHeight: true,
368
+ rowIndexOffset: topPinnedRowsData.length
250
369
  })
251
370
  }), /*#__PURE__*/_jsx(GridVirtualScrollerRenderZone, _extends({}, getRenderZoneProps(), {
252
- children: getRows({
253
- renderContext: renderContext
254
- })
371
+ children: mainRows
255
372
  })), rightRenderContext && /*#__PURE__*/_jsx(VirtualScrollerPinnedColumns, {
256
373
  ref: rightColumns,
257
374
  ownerState: {
@@ -264,13 +381,58 @@ var DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGrid
264
381
  minFirstColumn: rightRenderContext.firstColumnIndex,
265
382
  maxLastColumn: rightRenderContext.lastColumnIndex,
266
383
  availableSpace: 0,
267
- ignoreAutoHeight: true
384
+ ignoreAutoHeight: true,
385
+ rowIndexOffset: topPinnedRowsData.length
268
386
  })
269
387
  }), detailPanels.length > 0 && /*#__PURE__*/_jsx(VirtualScrollerDetailPanels, {
270
388
  className: classes.detailPanels,
271
389
  children: detailPanels
272
390
  })]
273
- }))
391
+ })), bottomPinnedRowsData.length > 0 ? /*#__PURE__*/_jsxs(VirtualScrollerPinnedRows, {
392
+ className: classes.bottomPinnedRows,
393
+ ownerState: {
394
+ position: 'bottom'
395
+ },
396
+ style: {
397
+ width: contentProps.style.width,
398
+ height: pinnedRowsHeight.bottom
399
+ },
400
+ role: "rowgroup",
401
+ children: [leftRenderContext && /*#__PURE__*/_jsx(VirtualScrollerPinnedColumns, {
402
+ className: classes.leftPinnedColumns,
403
+ ownerState: {
404
+ side: GridPinnedPosition.left
405
+ },
406
+ children: getRows({
407
+ renderContext: leftRenderContext,
408
+ minFirstColumn: leftRenderContext.firstColumnIndex,
409
+ maxLastColumn: leftRenderContext.lastColumnIndex,
410
+ availableSpace: 0,
411
+ ignoreAutoHeight: true,
412
+ rows: bottomPinnedRowsData,
413
+ rowIndexOffset: topPinnedRowsData.length + (mainRows ? mainRows.length : 0)
414
+ })
415
+ }), /*#__PURE__*/_jsx(VirtualScrollerPinnedRowsRenderZone, {
416
+ className: classes.pinnedRowsRenderZone,
417
+ ref: bottomPinnedRowsRenderZoneRef,
418
+ role: "presentation",
419
+ children: bottomPinnedRows
420
+ }), rightRenderContext && /*#__PURE__*/_jsx(VirtualScrollerPinnedColumns, {
421
+ className: classes.rightPinnedColumns,
422
+ ownerState: {
423
+ side: GridPinnedPosition.right
424
+ },
425
+ children: getRows({
426
+ renderContext: rightRenderContext,
427
+ minFirstColumn: rightRenderContext.firstColumnIndex,
428
+ maxLastColumn: rightRenderContext.lastColumnIndex,
429
+ availableSpace: 0,
430
+ ignoreAutoHeight: true,
431
+ rows: bottomPinnedRowsData,
432
+ rowIndexOffset: topPinnedRowsData.length + (mainRows ? mainRows.length : 0)
433
+ })
434
+ })]
435
+ }) : null]
274
436
  }));
275
437
  });
276
438
  export { DataGridProVirtualScroller };
@@ -17,6 +17,8 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
17
17
  };
18
18
 
19
19
  var GridRowReorderCell = function GridRowReorderCell(params) {
20
+ var _params$rowNode$posit;
21
+
20
22
  var apiRef = useGridApiContext();
21
23
  var rootProps = useGridRootProps();
22
24
  var sortModel = useGridSelector(apiRef, gridSortModelSelector);
@@ -59,6 +61,11 @@ var GridRowReorderCell = function GridRowReorderCell(params) {
59
61
  onDragOver: publish('rowDragOver'),
60
62
  onDragEnd: publish('rowDragEnd')
61
63
  } : null;
64
+
65
+ if (((_params$rowNode$posit = params.rowNode.position) != null ? _params$rowNode$posit : 'body') !== 'body') {
66
+ return null;
67
+ }
68
+
62
69
  return /*#__PURE__*/_jsxs("div", _extends({
63
70
  className: classes.root,
64
71
  draggable: isDraggable
@@ -72,5 +79,9 @@ var GridRowReorderCell = function GridRowReorderCell(params) {
72
79
 
73
80
  export { GridRowReorderCell };
74
81
  export var renderRowReorderCell = function renderRowReorderCell(params) {
82
+ if (params.rowNode.isPinned) {
83
+ return null;
84
+ }
85
+
75
86
  return /*#__PURE__*/_jsx(GridRowReorderCell, _extends({}, params));
76
87
  };
@@ -54,6 +54,8 @@ var mergeStateWithPinnedColumns = function mergeStateWithPinnedColumns(pinnedCol
54
54
  };
55
55
 
56
56
  export var useGridColumnPinning = function useGridColumnPinning(apiRef, props) {
57
+ var _props$initialState4;
58
+
57
59
  var pinnedColumns = useGridSelector(apiRef, gridPinnedColumnsSelector); // Each visible row (not to be confused with a filter result) is composed of a central .MuiDataGrid-row element
58
60
  // and up to two additional .MuiDataGrid-row's, one for the columns pinned to the left and another
59
61
  // for those on the right side. When hovering any of these elements, the :hover styles are applied only to
@@ -183,17 +185,24 @@ export var useGridColumnPinning = function useGridColumnPinning(apiRef, props) {
183
185
 
184
186
  return initialValue;
185
187
  }, [apiRef, pinnedColumns]);
186
- var stateExportPreProcessing = React.useCallback(function (prevState) {
188
+ var stateExportPreProcessing = React.useCallback(function (prevState, context) {
189
+ var _props$initialState3, _pinnedColumnsToExpor, _pinnedColumnsToExpor2;
190
+
187
191
  var pinnedColumnsToExport = gridPinnedColumnsSelector(apiRef.current.state);
192
+ var shouldExportPinnedColumns = // Always export if the `exportOnlyDirtyModels` property is activated
193
+ !context.exportOnlyDirtyModels || // Always export if the model is controlled
194
+ props.pinnedColumns != null || // Always export if the model has been initialized
195
+ ((_props$initialState3 = props.initialState) == null ? void 0 : _props$initialState3.pinnedColumns) != null || // Export if the model is not empty
196
+ ((_pinnedColumnsToExpor = pinnedColumnsToExport.left) != null ? _pinnedColumnsToExpor : []).length > 0 || ((_pinnedColumnsToExpor2 = pinnedColumnsToExport.right) != null ? _pinnedColumnsToExpor2 : []).length > 0;
188
197
 
189
- if ((!pinnedColumnsToExport.left || pinnedColumnsToExport.left.length === 0) && (!pinnedColumnsToExport.right || pinnedColumnsToExport.right.length === 0)) {
198
+ if (!shouldExportPinnedColumns) {
190
199
  return prevState;
191
200
  }
192
201
 
193
202
  return _extends({}, prevState, {
194
203
  pinnedColumns: pinnedColumnsToExport
195
204
  });
196
- }, [apiRef]);
205
+ }, [apiRef, props.pinnedColumns, (_props$initialState4 = props.initialState) == null ? void 0 : _props$initialState4.pinnedColumns]);
197
206
  var stateRestorePreProcessing = React.useCallback(function (params, context) {
198
207
  var newPinnedColumns = context.stateToRestore.pinnedColumns;
199
208
 
@@ -12,6 +12,8 @@ export var GRID_DETAIL_PANEL_TOGGLE_COL_DEF = _extends({}, GRID_STRING_COL_DEF,
12
12
  sortable: false,
13
13
  filterable: false,
14
14
  resizable: false,
15
+ // @ts-ignore
16
+ aggregable: false,
15
17
  disableColumnMenu: true,
16
18
  disableReorder: true,
17
19
  disableExport: true,
@@ -4,4 +4,5 @@ export * from './columnReorder';
4
4
  export * from './columnResize';
5
5
  export * from './rowReorder';
6
6
  export * from './treeData';
7
- export * from './detailPanel';
7
+ export * from './detailPanel';
8
+ export * from './rowPinning';
@@ -0,0 +1 @@
1
+ export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector } from '@mui/x-data-grid/internals';
@@ -0,0 +1 @@
1
+ export * from './gridRowPinningInterface';
@@ -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
+ var cache = {
10
+ topIds: [],
11
+ bottomIds: [],
12
+ idLookup: {}
13
+ };
14
+ pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.forEach(function (rowModel) {
15
+ var 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(function (rowModel) {
20
+ var id = getRowIdFromRowModel(rowModel, getRowId);
21
+ cache.bottomIds.push(id);
22
+ cache.idLookup[id] = rowModel;
23
+ });
24
+ return cache;
25
+ }
26
+
27
+ export var rowPinningStateInitializer = function 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 var useGridRowPinning = function useGridRowPinning(apiRef, props) {
47
+ var _props$experimentalFe3;
48
+
49
+ var setPinnedRows = React.useCallback(function (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
+ var isFirstRender = React.useRef(true);
63
+ React.useEffect(function () {
64
+ if (isFirstRender.current) {
65
+ isFirstRender.current = false;
66
+ return;
67
+ }
68
+
69
+ apiRef.current.unstable_setPinnedRows(props.pinnedRows);
70
+ }, [apiRef, props.pinnedRows]);
71
+ };
@@ -0,0 +1,89 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import * as React from 'react';
5
+ import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
6
+ export function addPinnedRow(_ref) {
7
+ var _groupingParams$addit;
8
+
9
+ var groupingParams = _ref.groupingParams,
10
+ rowModel = _ref.rowModel,
11
+ rowId = _ref.rowId,
12
+ position = _ref.position,
13
+ apiRef = _ref.apiRef;
14
+
15
+ var idRowsLookup = _extends({}, groupingParams.idRowsLookup);
16
+
17
+ var tree = _extends({}, groupingParams.tree); // TODO: warn if id is already present in `props.rows`
18
+
19
+
20
+ idRowsLookup[rowId] = rowModel; // Do not push it to ids list so that pagination is not affected by pinned rows
21
+ // ids.push(rowId);
22
+
23
+ tree[rowId] = {
24
+ id: rowId,
25
+ isAutoGenerated: false,
26
+ parent: null,
27
+ depth: 0,
28
+ groupingKey: null,
29
+ groupingField: null,
30
+ isPinned: true
31
+ };
32
+ apiRef.current.unstable_caches.rows.idRowsLookup[rowId] = _extends({}, rowModel);
33
+ apiRef.current.unstable_caches.rows.idToIdLookup[rowId] = rowId;
34
+ var previousPinnedRows = ((_groupingParams$addit = groupingParams.additionalRowGroups) == null ? void 0 : _groupingParams$addit.pinnedRows) || {};
35
+ var newPinnedRow = {
36
+ id: rowId,
37
+ model: rowModel
38
+ };
39
+ return _extends({}, groupingParams, {
40
+ idRowsLookup: idRowsLookup,
41
+ tree: tree,
42
+ additionalRowGroups: _extends({}, groupingParams.additionalRowGroups, {
43
+ pinnedRows: _extends({}, previousPinnedRows, _defineProperty({}, position, [].concat(_toConsumableArray(previousPinnedRows[position] || []), [newPinnedRow])))
44
+ })
45
+ });
46
+ }
47
+ export var useGridRowPinningPreProcessors = function useGridRowPinningPreProcessors(apiRef) {
48
+ var addPinnedRows = React.useCallback(function (groupingParams) {
49
+ var _pinnedRowsCache$topI, _pinnedRowsCache$bott;
50
+
51
+ var pinnedRowsCache = apiRef.current.unstable_caches.pinnedRows || {};
52
+
53
+ var newGroupingParams = _extends({}, groupingParams, {
54
+ additionalRowGroups: _extends({}, groupingParams.additionalRowGroups, {
55
+ // reset pinned rows state
56
+ pinnedRows: {}
57
+ })
58
+ });
59
+
60
+ (_pinnedRowsCache$topI = pinnedRowsCache.topIds) == null ? void 0 : _pinnedRowsCache$topI.forEach(function (rowId) {
61
+ newGroupingParams = addPinnedRow({
62
+ groupingParams: newGroupingParams,
63
+ rowModel: pinnedRowsCache.idLookup[rowId],
64
+ rowId: rowId,
65
+ position: 'top',
66
+ apiRef: apiRef
67
+ });
68
+ });
69
+ (_pinnedRowsCache$bott = pinnedRowsCache.bottomIds) == null ? void 0 : _pinnedRowsCache$bott.forEach(function (rowId) {
70
+ newGroupingParams = addPinnedRow({
71
+ groupingParams: newGroupingParams,
72
+ rowModel: pinnedRowsCache.idLookup[rowId],
73
+ rowId: rowId,
74
+ position: 'bottom',
75
+ apiRef: apiRef
76
+ });
77
+ }); // If row with the same `id` is present both in `rows` and `pinnedRows` - remove it from `ids`
78
+
79
+ newGroupingParams.ids = newGroupingParams.ids.filter(function (rowId) {
80
+ if (newGroupingParams.tree[rowId] && newGroupingParams.tree[rowId].isPinned) {
81
+ return false;
82
+ }
83
+
84
+ return true;
85
+ });
86
+ return newGroupingParams;
87
+ }, [apiRef]);
88
+ useGridRegisterPipeProcessor(apiRef, 'hydrateRows', addPinnedRows);
89
+ };
@@ -13,6 +13,8 @@ export var GRID_REORDER_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
13
13
  disableExport: true,
14
14
  disableReorder: true,
15
15
  resizable: false,
16
+ // @ts-ignore
17
+ aggregable: false,
16
18
  renderHeader: function renderHeader() {
17
19
  return ' ';
18
20
  },
@@ -64,10 +64,16 @@ export var useGridRowReorder = function useGridRowReorder(apiRef, props) {
64
64
  originRowIndex.current = apiRef.current.getRowIndex(params.id);
65
65
  }, [isRowReorderDisabled, classes.rowDragging, logger, apiRef]);
66
66
  var handleDragOver = React.useCallback(function (params, event) {
67
+ var _apiRef$current$getRo;
68
+
67
69
  if (dragRowId === '') {
68
70
  return;
69
71
  }
70
72
 
73
+ if ((_apiRef$current$getRo = apiRef.current.getRowNode(params.id)) != null && _apiRef$current$getRo.isPinned) {
74
+ return;
75
+ }
76
+
71
77
  logger.debug("Dragging over row ".concat(params.id));
72
78
  event.preventDefault(); // Prevent drag events propagation.
73
79
  // For more information check here https://github.com/mui/mui-x/issues/2680.
@@ -60,11 +60,20 @@ export var filterRowTreeFromTreeData = function filterRowTreeFromTreeData(params
60
60
  visibleRowsLookup[node.id] = shouldPassFilters && areAncestorsExpanded;
61
61
  filteredRowsLookup[node.id] = shouldPassFilters;
62
62
 
63
+ if (node.footerId != null) {
64
+ visibleRowsLookup[node.footerId] = shouldPassFilters && areAncestorsExpanded && !!node.childrenExpanded;
65
+ }
66
+
63
67
  if (!shouldPassFilters) {
64
68
  return 0;
65
69
  }
66
70
 
67
71
  filteredDescendantCountLookup[node.id] = filteredDescendantCount;
72
+
73
+ if (node.position === 'footer') {
74
+ return filteredDescendantCount;
75
+ }
76
+
68
77
  return filteredDescendantCount + 1;
69
78
  };
70
79
 
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.13.1
1
+ /** @license MUI v5.15.1
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.
@@ -12,5 +12,8 @@ export { useGridRowReorder } from '../hooks/features/rowReorder/useGridRowReorde
12
12
  export { useGridRowReorderPreProcessors } from '../hooks/features/rowReorder/useGridRowReorderPreProcessors';
13
13
  export { useGridTreeData } from '../hooks/features/treeData/useGridTreeData';
14
14
  export { useGridTreeDataPreProcessors } from '../hooks/features/treeData/useGridTreeDataPreProcessors';
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';
15
18
  export { buildRowTree } from '../utils/tree/buildRowTree';
16
19
  export { sortRowTree } from '../utils/tree/sortRowTree';
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export var getReleaseInfo = function getReleaseInfo() {
3
- var releaseInfo = "MTY1Nzg1NDAwMDAwMA==";
3
+ var releaseInfo = "MTY1OTU2NDAwMDAwMA==";
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).