@mui/x-data-grid 6.0.0-alpha.0 → 6.0.0-alpha.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 (161) hide show
  1. package/CHANGELOG.md +209 -0
  2. package/DataGrid/useDataGridProps.js +4 -4
  3. package/components/DataGridVirtualScroller.js +5 -3
  4. package/components/GridPagination.d.ts +43 -1
  5. package/components/GridPagination.js +1 -2
  6. package/components/GridRow.d.ts +1 -4
  7. package/components/GridRow.js +9 -8
  8. package/components/base/GridBody.js +1 -2
  9. package/components/base/GridOverlays.js +52 -12
  10. package/components/cell/GridBooleanCell.js +2 -1
  11. package/components/columnSelection/GridCellCheckboxRenderer.d.ts +2 -2
  12. package/components/columnSelection/GridCellCheckboxRenderer.js +1 -6
  13. package/components/containers/GridOverlay.js +0 -5
  14. package/components/panel/filterPanel/GridFilterForm.js +2 -1
  15. package/components/toolbar/GridToolbarFilterButton.js +8 -4
  16. package/constants/gridClasses.d.ts +8 -0
  17. package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +1 -1
  18. package/hooks/core/strategyProcessing/gridStrategyProcessingApi.d.ts +1 -1
  19. package/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
  20. package/hooks/features/editRows/useGridCellEditing.new.js +18 -9
  21. package/hooks/features/editRows/useGridEditing.new.js +3 -2
  22. package/hooks/features/editRows/useGridEditing.old.js +2 -1
  23. package/hooks/features/editRows/useGridRowEditing.new.js +18 -9
  24. package/hooks/features/export/useGridPrintExport.js +31 -17
  25. package/hooks/features/export/utils.js +1 -5
  26. package/hooks/features/filter/gridFilterSelector.js +2 -2
  27. package/hooks/features/filter/useGridFilter.js +6 -6
  28. package/hooks/features/pagination/gridPaginationSelector.js +2 -2
  29. package/hooks/features/rows/gridRowsInterfaces.d.ts +106 -0
  30. package/hooks/features/rows/{gridRowsState.js → gridRowsInterfaces.js} +0 -0
  31. package/hooks/features/rows/gridRowsSelector.d.ts +17 -7
  32. package/hooks/features/rows/gridRowsSelector.js +38 -6
  33. package/hooks/features/rows/gridRowsUtils.d.ts +16 -4
  34. package/hooks/features/rows/gridRowsUtils.js +222 -39
  35. package/hooks/features/rows/index.d.ts +3 -3
  36. package/hooks/features/rows/index.js +2 -2
  37. package/hooks/features/rows/useGridRows.js +161 -124
  38. package/hooks/features/rows/useGridRowsPreProcessors.js +78 -26
  39. package/hooks/features/selection/useGridSelection.js +2 -2
  40. package/hooks/features/sorting/gridSortingSelector.js +9 -4
  41. package/hooks/features/sorting/gridSortingState.d.ts +2 -2
  42. package/hooks/features/sorting/useGridSorting.js +9 -33
  43. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +4 -7
  44. package/hooks/features/virtualization/useGridVirtualScroller.js +11 -17
  45. package/index.js +1 -1
  46. package/internals/index.d.ts +2 -1
  47. package/internals/index.js +1 -0
  48. package/legacy/DataGrid/useDataGridProps.js +4 -4
  49. package/legacy/components/DataGridVirtualScroller.js +5 -3
  50. package/legacy/components/GridPagination.js +1 -2
  51. package/legacy/components/GridRow.js +9 -8
  52. package/legacy/components/base/GridBody.js +1 -2
  53. package/legacy/components/base/GridOverlays.js +54 -12
  54. package/legacy/components/cell/GridBooleanCell.js +2 -1
  55. package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +1 -6
  56. package/legacy/components/containers/GridOverlay.js +0 -5
  57. package/legacy/components/panel/filterPanel/GridFilterForm.js +2 -1
  58. package/legacy/components/toolbar/GridToolbarFilterButton.js +3 -1
  59. package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
  60. package/legacy/hooks/features/editRows/useGridCellEditing.new.js +18 -9
  61. package/legacy/hooks/features/editRows/useGridEditing.new.js +3 -2
  62. package/legacy/hooks/features/editRows/useGridEditing.old.js +2 -1
  63. package/legacy/hooks/features/editRows/useGridRowEditing.new.js +18 -9
  64. package/legacy/hooks/features/export/useGridPrintExport.js +33 -20
  65. package/legacy/hooks/features/export/utils.js +1 -3
  66. package/legacy/hooks/features/filter/gridFilterSelector.js +2 -2
  67. package/legacy/hooks/features/filter/useGridFilter.js +6 -6
  68. package/legacy/hooks/features/pagination/gridPaginationSelector.js +2 -2
  69. package/legacy/hooks/features/rows/{gridRowsState.js → gridRowsInterfaces.js} +0 -0
  70. package/legacy/hooks/features/rows/gridRowsSelector.js +52 -9
  71. package/legacy/hooks/features/rows/gridRowsUtils.js +238 -46
  72. package/legacy/hooks/features/rows/index.js +2 -2
  73. package/legacy/hooks/features/rows/useGridRows.js +163 -134
  74. package/legacy/hooks/features/rows/useGridRowsPreProcessors.js +81 -26
  75. package/legacy/hooks/features/selection/useGridSelection.js +2 -2
  76. package/legacy/hooks/features/sorting/gridSortingSelector.js +5 -2
  77. package/legacy/hooks/features/sorting/useGridSorting.js +11 -33
  78. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +11 -17
  79. package/legacy/index.js +1 -1
  80. package/legacy/internals/index.js +1 -0
  81. package/legacy/models/gridFeatureMode.js +1 -4
  82. package/models/api/gridParamsApi.d.ts +2 -2
  83. package/models/api/gridRowApi.d.ts +7 -5
  84. package/models/events/gridEventLookup.d.ts +3 -3
  85. package/models/gridApiCaches.d.ts +1 -1
  86. package/models/gridFeatureMode.d.ts +0 -4
  87. package/models/gridFeatureMode.js +1 -4
  88. package/models/gridRows.d.ts +100 -30
  89. package/models/gridSortModel.d.ts +2 -2
  90. package/models/params/gridCellParams.d.ts +7 -11
  91. package/modern/DataGrid/useDataGridProps.js +4 -4
  92. package/modern/components/DataGridVirtualScroller.js +5 -3
  93. package/modern/components/GridPagination.js +1 -2
  94. package/modern/components/GridRow.js +9 -8
  95. package/modern/components/base/GridBody.js +1 -2
  96. package/modern/components/base/GridOverlays.js +52 -12
  97. package/modern/components/cell/GridBooleanCell.js +2 -1
  98. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +1 -6
  99. package/modern/components/containers/GridOverlay.js +0 -5
  100. package/modern/components/panel/filterPanel/GridFilterForm.js +2 -1
  101. package/modern/components/toolbar/GridToolbarFilterButton.js +1 -1
  102. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
  103. package/modern/hooks/features/editRows/useGridCellEditing.new.js +18 -9
  104. package/modern/hooks/features/editRows/useGridEditing.new.js +3 -2
  105. package/modern/hooks/features/editRows/useGridEditing.old.js +2 -1
  106. package/modern/hooks/features/editRows/useGridRowEditing.new.js +18 -9
  107. package/modern/hooks/features/export/useGridPrintExport.js +30 -16
  108. package/modern/hooks/features/export/utils.js +1 -1
  109. package/modern/hooks/features/filter/gridFilterSelector.js +2 -2
  110. package/modern/hooks/features/filter/useGridFilter.js +6 -6
  111. package/modern/hooks/features/pagination/gridPaginationSelector.js +2 -2
  112. package/modern/hooks/features/rows/{gridRowsState.js → gridRowsInterfaces.js} +0 -0
  113. package/modern/hooks/features/rows/gridRowsSelector.js +28 -6
  114. package/modern/hooks/features/rows/gridRowsUtils.js +220 -37
  115. package/modern/hooks/features/rows/index.js +2 -2
  116. package/modern/hooks/features/rows/useGridRows.js +158 -121
  117. package/modern/hooks/features/rows/useGridRowsPreProcessors.js +78 -26
  118. package/modern/hooks/features/selection/useGridSelection.js +2 -2
  119. package/modern/hooks/features/sorting/gridSortingSelector.js +3 -2
  120. package/modern/hooks/features/sorting/useGridSorting.js +9 -33
  121. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +10 -16
  122. package/modern/index.js +1 -1
  123. package/modern/internals/index.js +1 -0
  124. package/modern/models/gridFeatureMode.js +1 -4
  125. package/node/DataGrid/useDataGridProps.js +3 -3
  126. package/node/components/DataGridVirtualScroller.js +5 -3
  127. package/node/components/GridPagination.js +1 -2
  128. package/node/components/GridRow.js +9 -7
  129. package/node/components/base/GridBody.js +1 -3
  130. package/node/components/base/GridOverlays.js +57 -12
  131. package/node/components/cell/GridBooleanCell.js +3 -1
  132. package/node/components/columnSelection/GridCellCheckboxRenderer.js +1 -6
  133. package/node/components/containers/GridOverlay.js +0 -5
  134. package/node/components/panel/filterPanel/GridFilterForm.js +2 -1
  135. package/node/components/toolbar/GridToolbarFilterButton.js +8 -4
  136. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
  137. package/node/hooks/features/editRows/useGridCellEditing.new.js +20 -10
  138. package/node/hooks/features/editRows/useGridEditing.new.js +4 -2
  139. package/node/hooks/features/editRows/useGridEditing.old.js +3 -1
  140. package/node/hooks/features/editRows/useGridRowEditing.new.js +20 -10
  141. package/node/hooks/features/export/useGridPrintExport.js +31 -17
  142. package/node/hooks/features/export/utils.js +1 -5
  143. package/node/hooks/features/filter/gridFilterSelector.js +1 -1
  144. package/node/hooks/features/filter/useGridFilter.js +5 -6
  145. package/node/hooks/features/pagination/gridPaginationSelector.js +1 -1
  146. package/node/hooks/features/rows/{gridRowsState.js → gridRowsInterfaces.js} +0 -0
  147. package/node/hooks/features/rows/gridRowsSelector.js +43 -10
  148. package/node/hooks/features/rows/gridRowsUtils.js +239 -40
  149. package/node/hooks/features/rows/index.js +23 -9
  150. package/node/hooks/features/rows/useGridRows.js +161 -122
  151. package/node/hooks/features/rows/useGridRowsPreProcessors.js +81 -26
  152. package/node/hooks/features/selection/useGridSelection.js +2 -2
  153. package/node/hooks/features/sorting/gridSortingSelector.js +9 -4
  154. package/node/hooks/features/sorting/useGridSorting.js +9 -33
  155. package/node/hooks/features/virtualization/useGridVirtualScroller.js +11 -17
  156. package/node/index.js +1 -1
  157. package/node/internals/index.js +14 -2
  158. package/node/models/gridFeatureMode.js +1 -7
  159. package/package.json +1 -1
  160. package/themeAugmentation/props.d.ts +2 -2
  161. package/hooks/features/rows/gridRowsState.d.ts +0 -60
@@ -8,13 +8,14 @@ var _excluded = ["id", "field"],
8
8
  _excluded2 = ["id", "field"];
9
9
  import _regeneratorRuntime from "@babel/runtime/regenerator";
10
10
  import * as React from 'react';
11
+ import { unstable_useEventCallback as useEventCallback } from '@mui/utils';
11
12
  import { useGridApiEventHandler, useGridApiOptionHandler, GridSignature } from '../../utils/useGridApiEventHandler';
12
13
  import { GridEditModes, GridCellModes } from '../../../models/gridEditRowModel';
13
14
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
14
15
  import { gridEditRowsStateSelector } from './gridEditRowsSelector';
15
16
  import { isPrintableKey } from '../../../utils/keyboardUtils';
16
17
  import { buildWarning } from '../../../utils/warning';
17
- import { gridRowsIdToIdLookupSelector } from '../rows/gridRowsSelector';
18
+ import { gridRowsDataRowIdToIdLookupSelector } from '../rows/gridRowsSelector';
18
19
  import { deepClone } from '../../../utils/utils';
19
20
  import { GridCellEditStartReasons, GridCellEditStopReasons } from '../../../models/params/gridEditCellParams';
20
21
  var missingOnProcessRowUpdateErrorWarning = buildWarning(['MUI: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, e.g. `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see http://mui.com/components/data-grid/editing/#persistence.'], 'error');
@@ -111,6 +112,10 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
111
112
  } else if (params.isEditable) {
112
113
  var _reason;
113
114
 
115
+ if (event.key === ' ' && event.shiftKey) {
116
+ return; // Shift + Space is used to select the row
117
+ }
118
+
114
119
  if (isPrintableKey(event)) {
115
120
  _reason = GridCellEditStartReasons.printableKeyDown;
116
121
  } else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
@@ -189,7 +194,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
189
194
  var isEditing = editingState[id] && editingState[id][field];
190
195
  return isEditing ? GridCellModes.Edit : GridCellModes.View;
191
196
  }, [apiRef]);
192
- var updateCellModesModel = React.useCallback(function (newModel) {
197
+ var updateCellModesModel = useEventCallback(function (newModel) {
193
198
  var isNewModelDifferentFromProp = newModel !== props.cellModesModel;
194
199
 
195
200
  if (onCellModesModelChange && isNewModelDifferentFromProp) {
@@ -206,7 +211,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
206
211
  setCellModesModel(newModel);
207
212
  cellModesModelRef.current = newModel;
208
213
  apiRef.current.publishEvent('cellModesModelChange', newModel);
209
- }, [apiRef, onCellModesModelChange, props.cellModesModel, signature]);
214
+ });
210
215
  var updateFieldInCellModesModel = React.useCallback(function (id, field, newProps) {
211
216
  // We use the ref because it always contain the up-to-date value, different from the state
212
217
  // that needs a rerender to reflect the new value
@@ -260,7 +265,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
260
265
  mode: GridCellModes.Edit
261
266
  }, other));
262
267
  }, [throwIfNotEditable, throwIfNotInMode, updateFieldInCellModesModel]);
263
- var updateStateToStartCellEditMode = React.useCallback(function (params) {
268
+ var updateStateToStartCellEditMode = useEventCallback(function (params) {
264
269
  var id = params.id,
265
270
  field = params.field,
266
271
  deleteValue = params.deleteValue;
@@ -271,7 +276,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
271
276
  };
272
277
  updateOrDeleteFieldState(id, field, newProps);
273
278
  apiRef.current.setCellFocus(id, field);
274
- }, [apiRef, updateOrDeleteFieldState]);
279
+ });
275
280
  var stopCellEditMode = React.useCallback(function (params) {
276
281
  var id = params.id,
277
282
  field = params.field,
@@ -282,7 +287,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
282
287
  mode: GridCellModes.View
283
288
  }, other));
284
289
  }, [throwIfNotInMode, updateFieldInCellModesModel]);
285
- var updateStateToStopCellEditMode = React.useCallback( /*#__PURE__*/function () {
290
+ var updateStateToStopCellEditMode = useEventCallback( /*#__PURE__*/function () {
286
291
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
287
292
  var id, field, ignoreModifications, _params$cellToFocusAf, cellToFocusAfter, finishCellEditMode, editingState, _editingState$id$fiel, error, isProcessingProps, rowUpdate, handleError, row;
288
293
 
@@ -334,7 +339,11 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
334
339
 
335
340
  if (processRowUpdate) {
336
341
  handleError = function handleError(errorThrown) {
337
- prevCellModesModel.current[id][field].mode = GridCellModes.Edit;
342
+ prevCellModesModel.current[id][field].mode = GridCellModes.Edit; // Revert the mode in the cellModesModel prop back to "edit"
343
+
344
+ updateFieldInCellModesModel(id, field, {
345
+ mode: GridCellModes.Edit
346
+ });
338
347
 
339
348
  if (onProcessRowUpdateError) {
340
349
  onProcessRowUpdateError(errorThrown);
@@ -368,7 +377,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
368
377
  return function (_x) {
369
378
  return _ref.apply(this, arguments);
370
379
  };
371
- }(), [apiRef, onProcessRowUpdateError, processRowUpdate, throwIfNotInMode, updateFieldInCellModesModel, updateOrDeleteFieldState]);
380
+ }());
372
381
  var setCellEditingEditCellValue = React.useCallback( /*#__PURE__*/function () {
373
382
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
374
383
  var _editingState$id, _editingState$id$fiel2;
@@ -473,7 +482,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
473
482
  }
474
483
  }, [cellModesModelProp, updateCellModesModel]);
475
484
  React.useEffect(function () {
476
- var idToIdLookup = gridRowsIdToIdLookupSelector(apiRef); // Update the ref here because updateStateToStopCellEditMode may change it later
485
+ var idToIdLookup = gridRowsDataRowIdToIdLookupSelector(apiRef); // Update the ref here because updateStateToStopCellEditMode may change it later
477
486
 
478
487
  var copyOfPrevCellModes = prevCellModesModel.current;
479
488
  prevCellModesModel.current = deepClone(cellModesModel); // Do a deep-clone because the attributes might be changed later
@@ -8,6 +8,7 @@ import { useGridCellEditing } from './useGridCellEditing.new';
8
8
  import { GridCellModes, GridEditModes } from '../../../models/gridEditRowModel';
9
9
  import { useGridRowEditing } from './useGridRowEditing.new';
10
10
  import { gridEditRowsStateSelector } from './gridEditRowsSelector';
11
+ import { isAutoGeneratedRow } from '../rows/gridRowsUtils';
11
12
  export var editingStateInitializer = function editingStateInitializer(state) {
12
13
  return _extends({}, state, {
13
14
  editRows: {}
@@ -19,7 +20,7 @@ export var useGridEditing = function useGridEditing(apiRef, props) {
19
20
  var debounceMap = React.useRef({});
20
21
  var isCellEditableProp = props.isCellEditable;
21
22
  var isCellEditable = React.useCallback(function (params) {
22
- if (params.rowNode.isAutoGenerated) {
23
+ if (isAutoGeneratedRow(params.rowNode)) {
23
24
  return false;
24
25
  }
25
26
 
@@ -35,7 +36,7 @@ export var useGridEditing = function useGridEditing(apiRef, props) {
35
36
  return isCellEditableProp(params);
36
37
  }
37
38
 
38
- if (params.rowNode.isPinned) {
39
+ if (params.rowNode.type === 'pinnedRow') {
39
40
  return false;
40
41
  }
41
42
 
@@ -8,6 +8,7 @@ import { useGridLogger } from '../../utils/useGridLogger';
8
8
  import { gridEditRowsStateSelector } from './gridEditRowsSelector';
9
9
  import { useCellEditing } from './useGridCellEditing.old';
10
10
  import { useGridRowEditing } from './useGridRowEditing.old';
11
+ import { isAutoGeneratedRow } from '../rows/gridRowsUtils';
11
12
  export var editingStateInitializer = function editingStateInitializer(state) {
12
13
  return _extends({}, state, {
13
14
  editRows: {}
@@ -34,7 +35,7 @@ export function useGridEditing(apiRef, props) {
34
35
  changeEvent: 'editRowsModelChange'
35
36
  });
36
37
  var isCellEditable = React.useCallback(function (params) {
37
- return !params.rowNode.isAutoGenerated && !params.rowNode.isPinned && !!params.colDef.editable && !!params.colDef.renderEditCell && (!props.isCellEditable || props.isCellEditable(params));
38
+ return !isAutoGeneratedRow(params.rowNode) && params.rowNode.type !== 'pinnedRow' && !!params.colDef.editable && !!params.colDef.renderEditCell && (!props.isCellEditable || props.isCellEditable(params));
38
39
  }, // eslint-disable-next-line react-hooks/exhaustive-deps
39
40
  [props.isCellEditable]);
40
41
 
@@ -6,6 +6,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
6
6
  var _excluded = ["id"],
7
7
  _excluded2 = ["id"];
8
8
  import * as React from 'react';
9
+ import { unstable_useEventCallback as useEventCallback } from '@mui/utils';
9
10
  import { useGridApiEventHandler, useGridApiOptionHandler, GridSignature } from '../../utils/useGridApiEventHandler';
10
11
  import { GridEditModes, GridRowModes } from '../../../models/gridEditRowModel';
11
12
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
@@ -13,7 +14,7 @@ import { gridEditRowsStateSelector } from './gridEditRowsSelector';
13
14
  import { isPrintableKey } from '../../../utils/keyboardUtils';
14
15
  import { gridColumnFieldsSelector } from '../columns/gridColumnsSelector';
15
16
  import { buildWarning } from '../../../utils/warning';
16
- import { gridRowsIdToIdLookupSelector } from '../rows/gridRowsSelector';
17
+ import { gridRowsDataRowIdToIdLookupSelector } from '../rows/gridRowsSelector';
17
18
  import { deepClone } from '../../../utils/utils';
18
19
  import { GridRowEditStopReasons, GridRowEditStartReasons } from '../../../models/params/gridRowParams';
19
20
  var missingOnProcessRowUpdateErrorWarning = buildWarning(['MUI: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, e.g. `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see http://mui.com/components/data-grid/editing/#persistence.'], 'error');
@@ -168,6 +169,10 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
168
169
  } else if (params.isEditable) {
169
170
  var _reason;
170
171
 
172
+ if (event.key === ' ' && event.shiftKey) {
173
+ return; // Shift + Space is used to select the row
174
+ }
175
+
171
176
  if (isPrintableKey(event)) {
172
177
  _reason = GridRowEditStartReasons.printableKeyDown;
173
178
  } else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
@@ -256,7 +261,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
256
261
  var isEditing = editingState[id] && Object.keys(editingState[id]).length > 0;
257
262
  return isEditing ? GridRowModes.Edit : GridRowModes.View;
258
263
  }, [apiRef, props.editMode]);
259
- var updateRowModesModel = React.useCallback(function (newModel) {
264
+ var updateRowModesModel = useEventCallback(function (newModel) {
260
265
  var isNewModelDifferentFromProp = newModel !== props.rowModesModel;
261
266
 
262
267
  if (onRowModesModelChange && isNewModelDifferentFromProp) {
@@ -273,7 +278,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
273
278
  setRowModesModel(newModel);
274
279
  rowModesModelRef.current = newModel;
275
280
  apiRef.current.publishEvent('rowModesModelChange', newModel);
276
- }, [apiRef, onRowModesModelChange, props.rowModesModel, signature]);
281
+ });
277
282
  var updateRowInRowModesModel = React.useCallback(function (id, newProps) {
278
283
  var newModel = _extends({}, rowModesModelRef.current);
279
284
 
@@ -330,7 +335,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
330
335
  mode: GridRowModes.Edit
331
336
  }, other));
332
337
  }, [throwIfNotInMode, updateRowInRowModesModel]);
333
- var updateStateToStartRowEditMode = React.useCallback(function (params) {
338
+ var updateStateToStartRowEditMode = useEventCallback(function (params) {
334
339
  var id = params.id,
335
340
  fieldToFocus = params.fieldToFocus,
336
341
  deleteValue = params.deleteValue;
@@ -355,7 +360,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
355
360
  if (fieldToFocus) {
356
361
  apiRef.current.setCellFocus(id, fieldToFocus);
357
362
  }
358
- }, [apiRef, updateOrDeleteRowState]);
363
+ });
359
364
  var stopRowEditMode = React.useCallback(function (params) {
360
365
  var id = params.id,
361
366
  other = _objectWithoutProperties(params, _excluded2);
@@ -365,7 +370,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
365
370
  mode: GridRowModes.View
366
371
  }, other));
367
372
  }, [throwIfNotInMode, updateRowInRowModesModel]);
368
- var updateStateToStopRowEditMode = React.useCallback(function (params) {
373
+ var updateStateToStopRowEditMode = useEventCallback(function (params) {
369
374
  var id = params.id,
370
375
  ignoreModifications = params.ignoreModifications,
371
376
  focusedField = params.field,
@@ -415,7 +420,11 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
415
420
 
416
421
  if (processRowUpdate) {
417
422
  var handleError = function handleError(errorThrown) {
418
- prevRowModesModel.current[id].mode = GridRowModes.Edit;
423
+ prevRowModesModel.current[id].mode = GridRowModes.Edit; // Revert the mode in the rowModesModel prop back to "edit"
424
+
425
+ updateRowInRowModesModel(id, {
426
+ mode: GridRowModes.Edit
427
+ });
419
428
 
420
429
  if (onProcessRowUpdateError) {
421
430
  onProcessRowUpdateError(errorThrown);
@@ -436,7 +445,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
436
445
  apiRef.current.updateRows([rowUpdate]);
437
446
  finishRowEditMode();
438
447
  }
439
- }, [apiRef, onProcessRowUpdateError, processRowUpdate, updateOrDeleteRowState, updateRowInRowModesModel]);
448
+ });
440
449
  var setRowEditingEditCellValue = React.useCallback(function (params) {
441
450
  var id = params.id,
442
451
  field = params.field,
@@ -598,7 +607,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
598
607
  }
599
608
  }, [rowModesModelProp, updateRowModesModel]);
600
609
  React.useEffect(function () {
601
- var idToIdLookup = gridRowsIdToIdLookupSelector(apiRef); // Update the ref here because updateStateToStopRowEditMode may change it later
610
+ var idToIdLookup = gridRowsDataRowIdToIdLookupSelector(apiRef); // Update the ref here because updateStateToStopRowEditMode may change it later
602
611
 
603
612
  var copyOfPrevRowModesModel = prevRowModesModel.current;
604
613
  prevRowModesModel.current = deepClone(rowModesModel); // Do a deep-clone because the attributes might be changed later
@@ -16,6 +16,14 @@ import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
16
16
  import { GridPrintExportMenuItem } from '../../../components/toolbar/GridToolbarExport';
17
17
  import { jsx as _jsx } from "react/jsx-runtime";
18
18
 
19
+ function raf() {
20
+ return new Promise(function (resolve) {
21
+ requestAnimationFrame(function () {
22
+ resolve();
23
+ });
24
+ });
25
+ }
26
+
19
27
  /**
20
28
  * @requires useGridColumns (state)
21
29
  * @requires useGridFilter (state)
@@ -34,6 +42,7 @@ export var useGridPrintExport = function useGridPrintExport(apiRef, props) {
34
42
 
35
43
  var updateGridColumnsForPrint = React.useCallback(function (fields, allColumns) {
36
44
  return new Promise(function (resolve) {
45
+ // TODO remove unused Promise
37
46
  if (!fields && !allColumns) {
38
47
  resolve();
39
48
  return;
@@ -56,12 +65,10 @@ export var useGridPrintExport = function useGridPrintExport(apiRef, props) {
56
65
  apiRef.current.setColumnVisibilityModel(newColumnVisibilityModel);
57
66
  resolve();
58
67
  });
59
- }, [apiRef]);
68
+ }, [apiRef]); // TODO move outside of this scope and remove React.useCallback
69
+
60
70
  var buildPrintWindow = React.useCallback(function (title) {
61
71
  var iframeEl = document.createElement('iframe');
62
- iframeEl.id = 'grid-print-window'; // Without this 'onload' event won't fire in some browsers
63
-
64
- iframeEl.src = window.location.href;
65
72
  iframeEl.style.position = 'absolute';
66
73
  iframeEl.style.width = '0px';
67
74
  iframeEl.style.height = '0px';
@@ -69,18 +76,15 @@ export var useGridPrintExport = function useGridPrintExport(apiRef, props) {
69
76
  return iframeEl;
70
77
  }, []);
71
78
  var handlePrintWindowLoad = React.useCallback(function (printWindow, options) {
72
- var _printWindow$contentW, _querySelector, _querySelector2;
79
+ var _querySelector, _querySelector2;
73
80
 
74
81
  var normalizeOptions = _extends({
75
82
  copyStyles: true,
76
83
  hideToolbar: false,
77
84
  hideFooter: false
78
- }, options); // Some agents, such as IE11 and Enzyme (as of 2 Jun 2020) continuously call the
79
- // `onload` callback. This ensures that it is only called once.
85
+ }, options);
80
86
 
81
-
82
- printWindow.onload = null;
83
- var printDoc = printWindow.contentDocument || ((_printWindow$contentW = printWindow.contentWindow) == null ? void 0 : _printWindow$contentW.document);
87
+ var printDoc = printWindow.contentDocument;
84
88
 
85
89
  if (!printDoc) {
86
90
  return;
@@ -120,10 +124,12 @@ export var useGridPrintExport = function useGridPrintExport(apiRef, props) {
120
124
  } // Expand container height to accommodate all rows
121
125
 
122
126
 
123
- gridClone.style.height = "".concat(rowsMeta.currentPageTotalHeight + totalHeaderHeight + gridToolbarElementHeight + gridFooterElementHeight, "px"); // Remove all loaded elements from the current host
127
+ gridClone.style.height = "".concat(rowsMeta.currentPageTotalHeight + totalHeaderHeight + gridToolbarElementHeight + gridFooterElementHeight, "px"); // printDoc.body.appendChild(gridClone); should be enough but a clone isolation bug in Safari
128
+ // prevents us to do it
124
129
 
125
- printDoc.body.innerHTML = '';
126
- printDoc.body.appendChild(gridClone);
130
+ var container = document.createElement('div');
131
+ container.appendChild(gridClone);
132
+ printDoc.body.innerHTML = container.innerHTML;
127
133
  var defaultPageStyle = typeof normalizeOptions.pageStyle === 'function' ? normalizeOptions.pageStyle() : normalizeOptions.pageStyle;
128
134
 
129
135
  if (typeof defaultPageStyle === 'string') {
@@ -232,24 +238,31 @@ export var useGridPrintExport = function useGridPrintExport(apiRef, props) {
232
238
 
233
239
  case 8:
234
240
  apiRef.current.unstable_disableVirtualization();
241
+ _context.next = 11;
242
+ return raf();
243
+
244
+ case 11:
245
+ // wait for the state changes to take action
235
246
  printWindow = buildPrintWindow(options == null ? void 0 : options.fileName);
236
- doc.current.body.appendChild(printWindow);
237
247
 
238
248
  if (process.env.NODE_ENV === 'test') {
239
- // In test env, run the all pipeline without waiting for loading
249
+ doc.current.body.appendChild(printWindow); // In test env, run the all pipeline without waiting for loading
250
+
240
251
  handlePrintWindowLoad(printWindow, options);
241
252
  handlePrintWindowAfterPrint(printWindow);
242
253
  } else {
243
254
  printWindow.onload = function () {
244
- return handlePrintWindowLoad(printWindow, options);
245
- };
255
+ handlePrintWindowLoad(printWindow, options);
246
256
 
247
- printWindow.contentWindow.onafterprint = function () {
248
- return handlePrintWindowAfterPrint(printWindow);
257
+ printWindow.contentWindow.onafterprint = function () {
258
+ handlePrintWindowAfterPrint(printWindow);
259
+ };
249
260
  };
261
+
262
+ doc.current.body.appendChild(printWindow);
250
263
  }
251
264
 
252
- case 12:
265
+ case 13:
253
266
  case "end":
254
267
  return _context.stop();
255
268
  }
@@ -30,9 +30,7 @@ export var defaultGetRowsToExport = function defaultGetRowsToExport(_ref2) {
30
30
  var rowTree = gridRowTreeSelector(apiRef);
31
31
  var selectedRows = apiRef.current.getSelectedRows();
32
32
  var bodyRows = filteredSortedRowIds.filter(function (id) {
33
- var _rowTree$id$position;
34
-
35
- return ((_rowTree$id$position = rowTree[id].position) != null ? _rowTree$id$position : 'body') === 'body';
33
+ return rowTree[id].type !== 'footer';
36
34
  });
37
35
  var pinnedRows = gridPinnedRowsSelector(apiRef);
38
36
  var topPinnedRowsIds = (pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.map(function (row) {
@@ -1,7 +1,7 @@
1
1
  import { createSelector } from '../../../utils/createSelector';
2
2
  import { gridSortedRowEntriesSelector } from '../sorting/gridSortingSelector';
3
3
  import { gridColumnLookupSelector } from '../columns/gridColumnsSelector';
4
- import { gridRowTreeDepthSelector, gridRowTreeSelector } from '../rows/gridRowsSelector';
4
+ import { gridRowMaximumTreeDepthSelector, gridRowTreeSelector } from '../rows/gridRowsSelector';
5
5
  /**
6
6
  * @category Filtering
7
7
  */
@@ -106,7 +106,7 @@ export var gridVisibleRowsSelector = gridVisibleSortedRowIdsSelector;
106
106
  * @category Filtering
107
107
  */
108
108
 
109
- export var gridVisibleSortedTopLevelRowEntriesSelector = createSelector(gridVisibleSortedRowEntriesSelector, gridRowTreeSelector, gridRowTreeDepthSelector, function (visibleSortedRows, rowTree, rowTreeDepth) {
109
+ export var gridVisibleSortedTopLevelRowEntriesSelector = createSelector(gridVisibleSortedRowEntriesSelector, gridRowTreeSelector, gridRowMaximumTreeDepthSelector, function (visibleSortedRows, rowTree, rowTreeDepth) {
110
110
  if (rowTreeDepth < 2) {
111
111
  return visibleSortedRows;
112
112
  }
@@ -1,7 +1,6 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  import * as React from 'react';
4
- import { GridFeatureModeConstant } from '../../../models/gridFeatureMode';
5
4
  import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
6
5
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
7
6
  import { useGridLogger } from '../../utils/useGridLogger';
@@ -10,7 +9,7 @@ import { GridPreferencePanelsValue } from '../preferencesPanel/gridPreferencePan
10
9
  import { getDefaultGridFilterModel } from './gridFilterState';
11
10
  import { gridFilterModelSelector, gridVisibleSortedRowEntriesSelector } from './gridFilterSelector';
12
11
  import { useFirstRender } from '../../utils/useFirstRender';
13
- import { gridRowIdsSelector } from '../rows';
12
+ import { GRID_ROOT_GROUP_ID, gridRowTreeSelector } from '../rows';
14
13
  import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
15
14
  import { GRID_DEFAULT_STRATEGY, useGridRegisterStrategyProcessor } from '../../core/strategyProcessing';
16
15
  import { buildAggregatedFilterApplier, sanitizeFilterModel, mergeStateWithFilterModel, cleanFilterItem, passFilterLogic } from './gridFilterUtils';
@@ -48,7 +47,7 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
48
47
  var updateFilteredRows = React.useCallback(function () {
49
48
  apiRef.current.setState(function (state) {
50
49
  var filterModel = gridFilterModelSelector(state, apiRef.current.instanceId);
51
- var isRowMatchingFilters = props.filterMode === GridFeatureModeConstant.client ? buildAggregatedFilterApplier(filterModel, apiRef) : null;
50
+ var isRowMatchingFilters = props.filterMode === 'client' ? buildAggregatedFilterApplier(filterModel, apiRef) : null;
52
51
  var filteringResult = apiRef.current.unstable_applyStrategyProcessor('filtering', {
53
52
  isRowMatchingFilters: isRowMatchingFilters,
54
53
  filterModel: filterModel != null ? filterModel : getDefaultGridFilterModel()
@@ -273,8 +272,9 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
273
272
  return initialValue;
274
273
  }, [props.components.FilterPanel, (_props$componentsProp2 = props.componentsProps) == null ? void 0 : _props$componentsProp2.filterPanel]);
275
274
  var flatFilteringMethod = React.useCallback(function (params) {
276
- if (props.filterMode === GridFeatureModeConstant.client && params.isRowMatchingFilters) {
277
- var rowIds = gridRowIdsSelector(apiRef);
275
+ if (props.filterMode === 'client' && params.isRowMatchingFilters) {
276
+ var tree = gridRowTreeSelector(apiRef);
277
+ var rowIds = tree[GRID_ROOT_GROUP_ID].children;
278
278
  var filteredRowsLookup = {};
279
279
 
280
280
  for (var i = 0; i < rowIds.length; i += 1) {
@@ -296,7 +296,7 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
296
296
 
297
297
  return {
298
298
  filteredRowsLookup: filteredRowsLookup,
299
- // For flat tree, the `visibleRowsLookup` and the `filteredRowsLookup` since no row is collapsed.
299
+ // For flat tree, the `visibleRowsLookup` and the `filteredRowsLookup` are equals since no row is collapsed.
300
300
  visibleRowsLookup: filteredRowsLookup,
301
301
  filteredDescendantCountLookup: {}
302
302
  };
@@ -1,6 +1,6 @@
1
1
  import { createSelector } from '../../../utils/createSelector';
2
2
  import { gridVisibleSortedRowEntriesSelector, gridVisibleSortedRowIdsSelector, gridVisibleSortedTopLevelRowEntriesSelector } from '../filter/gridFilterSelector';
3
- import { gridRowTreeDepthSelector, gridRowTreeSelector } from '../rows/gridRowsSelector';
3
+ import { gridRowMaximumTreeDepthSelector, gridRowTreeSelector } from '../rows/gridRowsSelector';
4
4
  /**
5
5
  * @category Pagination
6
6
  * @ignore - do not document.
@@ -38,7 +38,7 @@ export var gridPageCountSelector = createSelector(gridPaginationSelector, functi
38
38
  * @category Pagination
39
39
  */
40
40
 
41
- export var gridPaginationRowRangeSelector = createSelector(gridPaginationSelector, gridRowTreeSelector, gridRowTreeDepthSelector, gridVisibleSortedRowEntriesSelector, gridVisibleSortedTopLevelRowEntriesSelector, function (pagination, rowTree, rowTreeDepth, visibleSortedRowEntries, visibleSortedTopLevelRowEntries) {
41
+ export var gridPaginationRowRangeSelector = createSelector(gridPaginationSelector, gridRowTreeSelector, gridRowMaximumTreeDepthSelector, gridVisibleSortedRowEntriesSelector, gridVisibleSortedTopLevelRowEntriesSelector, function (pagination, rowTree, rowTreeDepth, visibleSortedRowEntries, visibleSortedTopLevelRowEntries) {
42
42
  var visibleTopLevelRowCount = visibleSortedTopLevelRowEntries.length;
43
43
  var topLevelFirstRowIndex = Math.min(pagination.pageSize * pagination.page, visibleTopLevelRowCount - 1);
44
44
  var topLevelLastRowIndex = Math.min(topLevelFirstRowIndex + pagination.pageSize - 1, visibleTopLevelRowCount - 1); // The range contains no element
@@ -1,3 +1,4 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
1
2
  import { createSelector } from '../../../utils/createSelector';
2
3
  export var gridRowsStateSelector = function gridRowsStateSelector(state) {
3
4
  return state.rows;
@@ -10,12 +11,13 @@ export var gridRowsLoadingSelector = createSelector(gridRowsStateSelector, funct
10
11
  });
11
12
  export var gridTopLevelRowCountSelector = createSelector(gridRowsStateSelector, function (rows) {
12
13
  return rows.totalTopLevelRowCount;
13
- });
14
+ }); // TODO rows v6: Rename
15
+
14
16
  export var gridRowsLookupSelector = createSelector(gridRowsStateSelector, function (rows) {
15
- return rows.idRowsLookup;
17
+ return rows.dataRowIdToModelLookup;
16
18
  });
17
- export var gridRowsIdToIdLookupSelector = createSelector(gridRowsStateSelector, function (rows) {
18
- return rows.idToIdLookup;
19
+ export var gridRowsDataRowIdToIdLookupSelector = createSelector(gridRowsStateSelector, function (rows) {
20
+ return rows.dataRowIdToIdLookup;
19
21
  });
20
22
  export var gridRowTreeSelector = createSelector(gridRowsStateSelector, function (rows) {
21
23
  return rows.tree;
@@ -23,11 +25,32 @@ export var gridRowTreeSelector = createSelector(gridRowsStateSelector, function
23
25
  export var gridRowGroupingNameSelector = createSelector(gridRowsStateSelector, function (rows) {
24
26
  return rows.groupingName;
25
27
  });
26
- export var gridRowTreeDepthSelector = createSelector(gridRowsStateSelector, function (rows) {
27
- return rows.treeDepth;
28
+ export var gridRowTreeDepthsSelector = createSelector(gridRowsStateSelector, function (rows) {
29
+ return rows.treeDepths;
30
+ });
31
+ export var gridRowMaximumTreeDepthSelector = createSelector(gridRowsStateSelector, function (rows) {
32
+ var entries = Object.entries(rows.treeDepths);
33
+
34
+ if (entries.length === 0) {
35
+ return 1;
36
+ }
37
+
38
+ return entries.filter(function (_ref) {
39
+ var _ref2 = _slicedToArray(_ref, 2),
40
+ nodeCount = _ref2[1];
41
+
42
+ return nodeCount > 0;
43
+ }).map(function (_ref3) {
44
+ var _ref4 = _slicedToArray(_ref3, 1),
45
+ depth = _ref4[0];
46
+
47
+ return Number(depth);
48
+ }).sort(function (a, b) {
49
+ return b - a;
50
+ })[0] + 1;
28
51
  });
29
- export var gridRowIdsSelector = createSelector(gridRowsStateSelector, function (rows) {
30
- return rows.ids;
52
+ export var gridDataRowIdsSelector = createSelector(gridRowsStateSelector, function (rows) {
53
+ return rows.dataRowIds;
31
54
  });
32
55
  /**
33
56
  * @ignore - do not document.
@@ -41,7 +64,27 @@ export var gridAdditionalRowGroupsSelector = createSelector(gridRowsStateSelecto
41
64
  */
42
65
 
43
66
  export var gridPinnedRowsSelector = createSelector(gridAdditionalRowGroupsSelector, function (additionalRowGroups) {
44
- return additionalRowGroups == null ? void 0 : additionalRowGroups.pinnedRows;
67
+ var _rawPinnedRows$bottom, _rawPinnedRows$top;
68
+
69
+ var rawPinnedRows = additionalRowGroups == null ? void 0 : additionalRowGroups.pinnedRows;
70
+ return {
71
+ bottom: rawPinnedRows == null ? void 0 : (_rawPinnedRows$bottom = rawPinnedRows.bottom) == null ? void 0 : _rawPinnedRows$bottom.map(function (rowEntry) {
72
+ var _rowEntry$model;
73
+
74
+ return {
75
+ id: rowEntry.id,
76
+ model: (_rowEntry$model = rowEntry.model) != null ? _rowEntry$model : {}
77
+ };
78
+ }),
79
+ top: rawPinnedRows == null ? void 0 : (_rawPinnedRows$top = rawPinnedRows.top) == null ? void 0 : _rawPinnedRows$top.map(function (rowEntry) {
80
+ var _rowEntry$model2;
81
+
82
+ return {
83
+ id: rowEntry.id,
84
+ model: (_rowEntry$model2 = rowEntry.model) != null ? _rowEntry$model2 : {}
85
+ };
86
+ })
87
+ };
45
88
  });
46
89
  /**
47
90
  * @ignore - do not document.