@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,34 @@
1
+ import * as React from 'react';
2
+ import { GridHydrateRowsValue } from '@mui/x-data-grid/internals';
3
+ import { GridRowEntry, GridRowId, GridRowModel } from '@mui/x-data-grid';
4
+ import { GridApiPro } from '../../../models/gridApiPro';
5
+ import { GridPinnedRowsProp } from './gridRowPinningInterface';
6
+ declare type GridPinnedRowPosition = keyof GridPinnedRowsProp;
7
+ export declare function addPinnedRow({ groupingParams, rowModel, rowId, position, apiRef, }: {
8
+ groupingParams: GridHydrateRowsValue;
9
+ rowModel: GridRowModel;
10
+ rowId: GridRowId;
11
+ position: GridPinnedRowPosition;
12
+ apiRef: React.MutableRefObject<GridApiPro>;
13
+ }): {
14
+ idRowsLookup: {
15
+ [x: string]: any;
16
+ [x: number]: any;
17
+ };
18
+ tree: {
19
+ [x: string]: import("@mui/x-data-grid").GridRowTreeNodeConfig;
20
+ [x: number]: import("@mui/x-data-grid").GridRowTreeNodeConfig;
21
+ };
22
+ additionalRowGroups: {
23
+ pinnedRows: {
24
+ top?: GridRowEntry<any>[] | undefined;
25
+ bottom?: GridRowEntry<any>[] | undefined;
26
+ };
27
+ };
28
+ groupingName: string;
29
+ treeDepth: number;
30
+ ids: GridRowId[];
31
+ idToIdLookup: Record<string, GridRowId>;
32
+ };
33
+ export declare const useGridRowPinningPreProcessors: (apiRef: React.MutableRefObject<GridApiPro>) => void;
34
+ export {};
@@ -0,0 +1,89 @@
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
+ var _groupingParams$addit;
12
+
13
+ const idRowsLookup = _extends({}, groupingParams.idRowsLookup);
14
+
15
+ const tree = _extends({}, groupingParams.tree); // TODO: warn if id is already present in `props.rows`
16
+
17
+
18
+ idRowsLookup[rowId] = rowModel; // Do not push it to ids list so that pagination is not affected by pinned rows
19
+ // ids.push(rowId);
20
+
21
+ tree[rowId] = {
22
+ id: rowId,
23
+ isAutoGenerated: false,
24
+ parent: null,
25
+ depth: 0,
26
+ groupingKey: null,
27
+ groupingField: null,
28
+ isPinned: true
29
+ };
30
+ apiRef.current.unstable_caches.rows.idRowsLookup[rowId] = _extends({}, rowModel);
31
+ apiRef.current.unstable_caches.rows.idToIdLookup[rowId] = rowId;
32
+ const previousPinnedRows = ((_groupingParams$addit = groupingParams.additionalRowGroups) == null ? void 0 : _groupingParams$addit.pinnedRows) || {};
33
+ const newPinnedRow = {
34
+ id: rowId,
35
+ model: rowModel
36
+ };
37
+ return _extends({}, groupingParams, {
38
+ idRowsLookup,
39
+ tree,
40
+ additionalRowGroups: _extends({}, groupingParams.additionalRowGroups, {
41
+ pinnedRows: _extends({}, previousPinnedRows, {
42
+ [position]: [...(previousPinnedRows[position] || []), newPinnedRow]
43
+ })
44
+ })
45
+ });
46
+ }
47
+ export const useGridRowPinningPreProcessors = apiRef => {
48
+ const addPinnedRows = React.useCallback(groupingParams => {
49
+ var _pinnedRowsCache$topI, _pinnedRowsCache$bott;
50
+
51
+ const pinnedRowsCache = apiRef.current.unstable_caches.pinnedRows || {};
52
+
53
+ let 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(rowId => {
61
+ newGroupingParams = addPinnedRow({
62
+ groupingParams: newGroupingParams,
63
+ rowModel: pinnedRowsCache.idLookup[rowId],
64
+ rowId,
65
+ position: 'top',
66
+ apiRef
67
+ });
68
+ });
69
+ (_pinnedRowsCache$bott = pinnedRowsCache.bottomIds) == null ? void 0 : _pinnedRowsCache$bott.forEach(rowId => {
70
+ newGroupingParams = addPinnedRow({
71
+ groupingParams: newGroupingParams,
72
+ rowModel: pinnedRowsCache.idLookup[rowId],
73
+ rowId,
74
+ position: 'bottom',
75
+ 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(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
+ };
@@ -60,10 +60,16 @@ export const useGridRowReorder = (apiRef, props) => {
60
60
  originRowIndex.current = apiRef.current.getRowIndex(params.id);
61
61
  }, [isRowReorderDisabled, classes.rowDragging, logger, apiRef]);
62
62
  const handleDragOver = React.useCallback((params, event) => {
63
+ var _apiRef$current$getRo;
64
+
63
65
  if (dragRowId === '') {
64
66
  return;
65
67
  }
66
68
 
69
+ if ((_apiRef$current$getRo = apiRef.current.getRowNode(params.id)) != null && _apiRef$current$getRo.isPinned) {
70
+ return;
71
+ }
72
+
67
73
  logger.debug(`Dragging over row ${params.id}`);
68
74
  event.preventDefault(); // Prevent drag events propagation.
69
75
  // For more information check here https://github.com/mui/mui-x/issues/2680.
package/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,6 +13,8 @@ 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 type { GridExperimentalProFeatures, DataGridProPropsWithoutDefaultValue, DataGridProPropsWithDefaultValue, } from '../models/dataGridProProps';
17
19
  export { buildRowTree } from '../utils/tree/buildRowTree';
18
20
  export type { BuildRowTreeGroupingCriteria } from '../utils/tree/buildRowTree';
@@ -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';
@@ -217,6 +217,12 @@ DataGridProRaw.propTypes = {
217
217
  */
218
218
  disableExtendRowFullWidth: PropTypes.bool,
219
219
 
220
+ /**
221
+ * If `true`, modification to a cell will not be discarded if the mode is changed from "edit" to "view" while processing props.
222
+ * @default false
223
+ */
224
+ disableIgnoreModificationsIfProcessingProps: PropTypes.bool,
225
+
220
226
  /**
221
227
  * If `true`, filtering with multiple columns is disabled.
222
228
  * @default false
@@ -270,6 +276,7 @@ DataGridProRaw.propTypes = {
270
276
  experimentalFeatures: PropTypes.shape({
271
277
  newEditingApi: PropTypes.bool,
272
278
  preventCommitWhileValidating: PropTypes.bool,
279
+ rowPinning: PropTypes.bool,
273
280
  warnIfFocusStateIsNotSynced: PropTypes.bool
274
281
  }),
275
282
 
@@ -854,6 +861,14 @@ DataGridProRaw.propTypes = {
854
861
  right: PropTypes.arrayOf(PropTypes.string)
855
862
  }),
856
863
 
864
+ /**
865
+ * Rows data to pin on top or bottom.
866
+ */
867
+ pinnedRows: PropTypes.shape({
868
+ bottom: PropTypes.array,
869
+ top: PropTypes.array
870
+ }),
871
+
857
872
  /**
858
873
  * Callback called before updating a row with new values in the row and cell editing.
859
874
  * Only applied if `props.experimentalFeatures.newEditingApi: true`.
@@ -11,6 +11,8 @@ import { useGridDetailPanel, detailPanelStateInitializer } from '../hooks/featur
11
11
  import { useGridDetailPanelPreProcessors } from '../hooks/features/detailPanel/useGridDetailPanelPreProcessors';
12
12
  import { useGridRowReorder } from '../hooks/features/rowReorder/useGridRowReorder';
13
13
  import { useGridRowReorderPreProcessors } from '../hooks/features/rowReorder/useGridRowReorderPreProcessors';
14
+ import { useGridRowPinning, rowPinningStateInitializer } from '../hooks/features/rowPinning/useGridRowPinning';
15
+ import { useGridRowPinningPreProcessors } from '../hooks/features/rowPinning/useGridRowPinningPreProcessors';
14
16
  export var useDataGridProComponent = function useDataGridProComponent(inputApiRef, props) {
15
17
  var _props$experimentalFe, _props$experimentalFe2;
16
18
 
@@ -22,6 +24,7 @@ export var useDataGridProComponent = function useDataGridProComponent(inputApiRe
22
24
  useGridSelectionPreProcessors(apiRef, props);
23
25
  useGridRowReorderPreProcessors(apiRef, props);
24
26
  useGridTreeDataPreProcessors(apiRef, props);
27
+ useGridRowPinningPreProcessors(apiRef);
25
28
  useGridDetailPanelPreProcessors(apiRef, props); // The column pinning `hydrateColumns` pre-processor must be after every other `hydrateColumns` pre-processors
26
29
  // Because it changes the order of the columns.
27
30
 
@@ -35,6 +38,7 @@ export var useDataGridProComponent = function useDataGridProComponent(inputApiRe
35
38
  useGridInitializeState(detailPanelStateInitializer, apiRef, props);
36
39
  useGridInitializeState(columnPinningStateInitializer, apiRef, props);
37
40
  useGridInitializeState(columnsStateInitializer, apiRef, props);
41
+ useGridInitializeState(rowPinningStateInitializer, apiRef, props);
38
42
  useGridInitializeState(rowsStateInitializer, apiRef, props);
39
43
  useGridInitializeState((_props$experimentalFe = props.experimentalFeatures) != null && _props$experimentalFe.newEditingApi ? editingStateInitializer_new : editingStateInitializer_old, apiRef, props);
40
44
  useGridInitializeState(focusStateInitializer, apiRef, props);
@@ -51,6 +55,7 @@ export var useDataGridProComponent = function useDataGridProComponent(inputApiRe
51
55
  useGridKeyboardNavigation(apiRef, props);
52
56
  useGridSelection(apiRef, props);
53
57
  useGridColumnPinning(apiRef, props);
58
+ useGridRowPinning(apiRef, props);
54
59
  useGridColumns(apiRef, props);
55
60
  useGridRows(apiRef, props);
56
61
  useGridParamsApi(apiRef);
@@ -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 };
@@ -79,5 +79,9 @@ var GridRowReorderCell = function GridRowReorderCell(params) {
79
79
 
80
80
  export { GridRowReorderCell };
81
81
  export var renderRowReorderCell = function renderRowReorderCell(params) {
82
+ if (params.rowNode.isPinned) {
83
+ return null;
84
+ }
85
+
82
86
  return /*#__PURE__*/_jsx(GridRowReorderCell, _extends({}, params));
83
87
  };
@@ -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
+ };