@mui/x-data-grid 6.0.4 → 6.2.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 (131) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/components/GridAutoSizer.js +3 -0
  3. package/components/GridPagination.d.ts +6 -6
  4. package/components/GridRow.js +3 -1
  5. package/components/cell/GridActionsCellItem.d.ts +2 -2
  6. package/components/cell/GridEditDateCell.js +37 -16
  7. package/components/columnHeaders/ColumnHeaderMenuIcon.js +20 -16
  8. package/components/panel/GridColumnsPanel.d.ts +8 -0
  9. package/components/panel/GridColumnsPanel.js +18 -6
  10. package/components/panel/GridPanel.d.ts +1 -1
  11. package/components/panel/filterPanel/GridFilterInputBoolean.js +37 -29
  12. package/components/panel/filterPanel/GridFilterInputSingleSelect.js +34 -30
  13. package/components/toolbar/GridToolbarColumnsButton.d.ts +1 -1
  14. package/components/toolbar/GridToolbarDensitySelector.d.ts +1 -1
  15. package/components/toolbar/GridToolbarExportContainer.d.ts +1 -1
  16. package/hooks/core/useGridApiInitialization.js +3 -3
  17. package/hooks/features/columns/gridColumnsSelector.d.ts +3 -3
  18. package/hooks/features/editing/useGridCellEditing.js +5 -1
  19. package/hooks/features/editing/useGridEditing.js +1 -3
  20. package/hooks/features/editing/useGridRowEditing.js +5 -1
  21. package/hooks/features/filter/gridFilterState.js +6 -1
  22. package/hooks/features/filter/useGridFilter.js +5 -0
  23. package/hooks/features/rowSelection/useGridRowSelection.js +5 -26
  24. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +36 -16
  25. package/index.js +9 -1
  26. package/legacy/components/GridAutoSizer.js +3 -0
  27. package/legacy/components/GridRow.js +4 -1
  28. package/legacy/components/cell/GridEditBooleanCell.js +19 -21
  29. package/legacy/components/cell/GridEditDateCell.js +69 -39
  30. package/legacy/components/cell/GridEditInputCell.js +25 -27
  31. package/legacy/components/cell/GridEditSingleSelectCell.js +26 -28
  32. package/legacy/components/columnHeaders/ColumnHeaderMenuIcon.js +20 -16
  33. package/legacy/components/panel/GridColumnsPanel.js +19 -6
  34. package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +37 -29
  35. package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +34 -30
  36. package/legacy/hooks/core/useGridApiInitialization.js +3 -3
  37. package/legacy/hooks/features/columns/gridColumnsUtils.js +2 -2
  38. package/legacy/hooks/features/editing/useGridCellEditing.js +120 -120
  39. package/legacy/hooks/features/editing/useGridEditing.js +17 -21
  40. package/legacy/hooks/features/editing/useGridRowEditing.js +5 -1
  41. package/legacy/hooks/features/export/useGridPrintExport.js +45 -47
  42. package/legacy/hooks/features/filter/gridFilterState.js +6 -1
  43. package/legacy/hooks/features/filter/useGridFilter.js +5 -0
  44. package/legacy/hooks/features/rowSelection/useGridRowSelection.js +5 -24
  45. package/legacy/hooks/features/rows/gridRowsUtils.js +2 -2
  46. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +6 -6
  47. package/legacy/index.js +9 -1
  48. package/legacy/locales/coreLocales.js +0 -1
  49. package/legacy/locales/frFR.js +7 -9
  50. package/legacy/locales/huHU.js +15 -20
  51. package/legacy/locales/jaJP.js +1 -1
  52. package/legacy/locales/nlNL.js +3 -3
  53. package/legacy/locales/ptBR.js +7 -9
  54. package/legacy/locales/ruRU.js +1 -1
  55. package/legacy/locales/urPK.js +6 -6
  56. package/legacy/models/gridColumnGrouping.js +4 -0
  57. package/legacy/models/params/gridRowParams.js +8 -0
  58. package/legacy/utils/createSelector.js +14 -22
  59. package/legacy/utils/utils.js +1 -1
  60. package/locales/coreLocales.js +0 -1
  61. package/locales/frFR.js +7 -9
  62. package/locales/huHU.js +15 -20
  63. package/locales/jaJP.js +1 -1
  64. package/locales/nlNL.js +3 -3
  65. package/locales/ptBR.js +7 -9
  66. package/locales/ruRU.js +1 -1
  67. package/locales/urPK.js +6 -6
  68. package/models/api/gridCoreApi.d.ts +3 -1
  69. package/models/api/gridEditingApi.d.ts +4 -0
  70. package/models/gridColumnGrouping.js +4 -0
  71. package/models/params/gridRowParams.js +8 -0
  72. package/modern/components/GridAutoSizer.js +3 -0
  73. package/modern/components/GridRow.js +3 -1
  74. package/modern/components/cell/GridEditDateCell.js +37 -16
  75. package/modern/components/columnHeaders/ColumnHeaderMenuIcon.js +19 -15
  76. package/modern/components/panel/GridColumnsPanel.js +18 -6
  77. package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +36 -28
  78. package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +33 -29
  79. package/modern/hooks/core/useGridApiInitialization.js +3 -3
  80. package/modern/hooks/features/editing/useGridCellEditing.js +5 -1
  81. package/modern/hooks/features/editing/useGridEditing.js +1 -3
  82. package/modern/hooks/features/editing/useGridRowEditing.js +5 -1
  83. package/modern/hooks/features/filter/gridFilterState.js +6 -1
  84. package/modern/hooks/features/filter/useGridFilter.js +5 -0
  85. package/modern/hooks/features/rowSelection/useGridRowSelection.js +5 -26
  86. package/modern/index.js +9 -1
  87. package/modern/locales/coreLocales.js +0 -1
  88. package/modern/locales/frFR.js +7 -9
  89. package/modern/locales/huHU.js +15 -20
  90. package/modern/locales/jaJP.js +1 -1
  91. package/modern/locales/nlNL.js +3 -3
  92. package/modern/locales/ptBR.js +7 -9
  93. package/modern/locales/ruRU.js +1 -1
  94. package/modern/locales/urPK.js +6 -6
  95. package/modern/models/gridColumnGrouping.js +4 -0
  96. package/modern/models/params/gridRowParams.js +8 -0
  97. package/modern/utils/createSelector.js +12 -22
  98. package/modern/utils/utils.js +1 -1
  99. package/node/components/GridAutoSizer.js +3 -1
  100. package/node/components/GridRow.js +3 -1
  101. package/node/components/cell/GridCell.js +1 -0
  102. package/node/components/cell/GridEditDateCell.js +37 -16
  103. package/node/components/columnHeaders/ColumnHeaderMenuIcon.js +19 -15
  104. package/node/components/panel/GridColumnsPanel.js +18 -6
  105. package/node/components/panel/filterPanel/GridFilterInputBoolean.js +36 -28
  106. package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +32 -29
  107. package/node/hooks/core/useGridApiInitialization.js +3 -3
  108. package/node/hooks/features/editing/useGridCellEditing.js +5 -1
  109. package/node/hooks/features/editing/useGridEditing.js +1 -3
  110. package/node/hooks/features/editing/useGridRowEditing.js +5 -1
  111. package/node/hooks/features/filter/gridFilterState.js +5 -0
  112. package/node/hooks/features/filter/useGridFilter.js +5 -0
  113. package/node/hooks/features/rowSelection/useGridRowSelection.js +4 -25
  114. package/node/index.js +1 -1
  115. package/node/locales/frFR.js +7 -9
  116. package/node/locales/huHU.js +15 -20
  117. package/node/locales/jaJP.js +1 -1
  118. package/node/locales/nlNL.js +3 -3
  119. package/node/locales/ptBR.js +7 -9
  120. package/node/locales/ruRU.js +1 -1
  121. package/node/locales/urPK.js +6 -6
  122. package/node/models/gridColumnGrouping.js +4 -0
  123. package/node/models/params/gridEditCellParams.js +1 -0
  124. package/node/models/params/gridRowParams.js +9 -0
  125. package/node/utils/createSelector.js +12 -22
  126. package/node/utils/utils.js +1 -1
  127. package/package.json +1 -1
  128. package/utils/createSelector.d.ts +4 -4
  129. package/utils/createSelector.js +14 -22
  130. package/utils/utils.d.ts +1 -1
  131. package/utils/utils.js +1 -1
@@ -238,13 +238,17 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
238
238
  deleteValue = params.deleteValue,
239
239
  initialValue = params.initialValue;
240
240
  var newValue = apiRef.current.getCellValue(id, field);
241
+ // eslint-disable-next-line @typescript-eslint/naming-convention
242
+ var unstable_updateValueOnRender = false;
241
243
  if (deleteValue || initialValue) {
242
244
  newValue = deleteValue ? '' : initialValue;
245
+ unstable_updateValueOnRender = true;
243
246
  }
244
247
  var newProps = {
245
248
  value: newValue,
246
249
  error: false,
247
- isProcessingProps: false
250
+ isProcessingProps: false,
251
+ unstable_updateValueOnRender: unstable_updateValueOnRender
248
252
  };
249
253
  updateOrDeleteFieldState(id, field, newProps);
250
254
  apiRef.current.setCellFocus(id, field);
@@ -262,72 +266,70 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
262
266
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
263
267
  var id, field, ignoreModifications, _params$cellToFocusAf, cellToFocusAfter, finishCellEditMode, editingState, _editingState$id$fiel, error, isProcessingProps, rowUpdate, handleError, row;
264
268
  return _regeneratorRuntime.wrap(function _callee$(_context) {
265
- while (1) {
266
- switch (_context.prev = _context.next) {
267
- case 0:
268
- id = params.id, field = params.field, ignoreModifications = params.ignoreModifications, _params$cellToFocusAf = params.cellToFocusAfter, cellToFocusAfter = _params$cellToFocusAf === void 0 ? 'none' : _params$cellToFocusAf;
269
- throwIfNotInMode(id, field, GridCellModes.Edit);
270
- apiRef.current.runPendingEditCellValueMutation(id, field);
271
- finishCellEditMode = function finishCellEditMode() {
272
- updateOrDeleteFieldState(id, field, null);
273
- updateFieldInCellModesModel(id, field, null);
274
- if (cellToFocusAfter !== 'none') {
275
- apiRef.current.moveFocusToRelativeCell(id, field, cellToFocusAfter);
269
+ while (1) switch (_context.prev = _context.next) {
270
+ case 0:
271
+ id = params.id, field = params.field, ignoreModifications = params.ignoreModifications, _params$cellToFocusAf = params.cellToFocusAfter, cellToFocusAfter = _params$cellToFocusAf === void 0 ? 'none' : _params$cellToFocusAf;
272
+ throwIfNotInMode(id, field, GridCellModes.Edit);
273
+ apiRef.current.runPendingEditCellValueMutation(id, field);
274
+ finishCellEditMode = function finishCellEditMode() {
275
+ updateOrDeleteFieldState(id, field, null);
276
+ updateFieldInCellModesModel(id, field, null);
277
+ if (cellToFocusAfter !== 'none') {
278
+ apiRef.current.moveFocusToRelativeCell(id, field, cellToFocusAfter);
279
+ }
280
+ };
281
+ if (!ignoreModifications) {
282
+ _context.next = 7;
283
+ break;
284
+ }
285
+ finishCellEditMode();
286
+ return _context.abrupt("return");
287
+ case 7:
288
+ editingState = gridEditRowsStateSelector(apiRef.current.state);
289
+ _editingState$id$fiel = editingState[id][field], error = _editingState$id$fiel.error, isProcessingProps = _editingState$id$fiel.isProcessingProps;
290
+ if (!(error || isProcessingProps)) {
291
+ _context.next = 13;
292
+ break;
293
+ }
294
+ // Attempt to change cell mode to "view" was not successful
295
+ // Update previous mode to allow another attempt
296
+ prevCellModesModel.current[id][field].mode = GridCellModes.Edit;
297
+ // Revert the mode in the cellModesModel prop back to "edit"
298
+ updateFieldInCellModesModel(id, field, {
299
+ mode: GridCellModes.Edit
300
+ });
301
+ return _context.abrupt("return");
302
+ case 13:
303
+ rowUpdate = apiRef.current.getRowWithUpdatedValuesFromCellEditing(id, field);
304
+ if (processRowUpdate) {
305
+ handleError = function handleError(errorThrown) {
306
+ prevCellModesModel.current[id][field].mode = GridCellModes.Edit;
307
+ // Revert the mode in the cellModesModel prop back to "edit"
308
+ updateFieldInCellModesModel(id, field, {
309
+ mode: GridCellModes.Edit
310
+ });
311
+ if (onProcessRowUpdateError) {
312
+ onProcessRowUpdateError(errorThrown);
313
+ } else {
314
+ missingOnProcessRowUpdateErrorWarning();
276
315
  }
277
316
  };
278
- if (!ignoreModifications) {
279
- _context.next = 7;
280
- break;
317
+ try {
318
+ row = apiRef.current.getRow(id);
319
+ Promise.resolve(processRowUpdate(rowUpdate, row)).then(function (finalRowUpdate) {
320
+ apiRef.current.updateRows([finalRowUpdate]);
321
+ finishCellEditMode();
322
+ }).catch(handleError);
323
+ } catch (errorThrown) {
324
+ handleError(errorThrown);
281
325
  }
326
+ } else {
327
+ apiRef.current.updateRows([rowUpdate]);
282
328
  finishCellEditMode();
283
- return _context.abrupt("return");
284
- case 7:
285
- editingState = gridEditRowsStateSelector(apiRef.current.state);
286
- _editingState$id$fiel = editingState[id][field], error = _editingState$id$fiel.error, isProcessingProps = _editingState$id$fiel.isProcessingProps;
287
- if (!(error || isProcessingProps)) {
288
- _context.next = 13;
289
- break;
290
- }
291
- // Attempt to change cell mode to "view" was not successful
292
- // Update previous mode to allow another attempt
293
- prevCellModesModel.current[id][field].mode = GridCellModes.Edit;
294
- // Revert the mode in the cellModesModel prop back to "edit"
295
- updateFieldInCellModesModel(id, field, {
296
- mode: GridCellModes.Edit
297
- });
298
- return _context.abrupt("return");
299
- case 13:
300
- rowUpdate = apiRef.current.getRowWithUpdatedValuesFromCellEditing(id, field);
301
- if (processRowUpdate) {
302
- handleError = function handleError(errorThrown) {
303
- prevCellModesModel.current[id][field].mode = GridCellModes.Edit;
304
- // Revert the mode in the cellModesModel prop back to "edit"
305
- updateFieldInCellModesModel(id, field, {
306
- mode: GridCellModes.Edit
307
- });
308
- if (onProcessRowUpdateError) {
309
- onProcessRowUpdateError(errorThrown);
310
- } else {
311
- missingOnProcessRowUpdateErrorWarning();
312
- }
313
- };
314
- try {
315
- row = apiRef.current.getRow(id);
316
- Promise.resolve(processRowUpdate(rowUpdate, row)).then(function (finalRowUpdate) {
317
- apiRef.current.updateRows([finalRowUpdate]);
318
- finishCellEditMode();
319
- }).catch(handleError);
320
- } catch (errorThrown) {
321
- handleError(errorThrown);
322
- }
323
- } else {
324
- apiRef.current.updateRows([rowUpdate]);
325
- finishCellEditMode();
326
- }
327
- case 15:
328
- case "end":
329
- return _context.stop();
330
- }
329
+ }
330
+ case 15:
331
+ case "end":
332
+ return _context.stop();
331
333
  }
332
334
  }, _callee);
333
335
  }));
@@ -340,63 +342,61 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
340
342
  var _editingState$id, _editingState$id$fiel2;
341
343
  var id, field, value, debounceMs, skipValueParser, column, row, parsedValue, editingState, newProps, hasChanged;
342
344
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
343
- while (1) {
344
- switch (_context2.prev = _context2.next) {
345
- case 0:
346
- id = params.id, field = params.field, value = params.value, debounceMs = params.debounceMs, skipValueParser = params.unstable_skipValueParser;
347
- throwIfNotEditable(id, field);
348
- throwIfNotInMode(id, field, GridCellModes.Edit);
349
- column = apiRef.current.getColumn(field);
350
- row = apiRef.current.getRow(id);
351
- parsedValue = value;
352
- if (column.valueParser && !skipValueParser) {
353
- parsedValue = column.valueParser(value, apiRef.current.getCellParams(id, field));
354
- }
355
- editingState = gridEditRowsStateSelector(apiRef.current.state);
356
- newProps = _extends({}, editingState[id][field], {
357
- value: parsedValue,
358
- changeReason: debounceMs ? 'debouncedSetEditCellValue' : 'setEditCellValue'
359
- });
360
- if (!column.preProcessEditCellProps) {
361
- _context2.next = 16;
362
- break;
363
- }
364
- hasChanged = value !== editingState[id][field].value;
365
- newProps = _extends({}, newProps, {
366
- isProcessingProps: true
367
- });
368
- updateOrDeleteFieldState(id, field, newProps);
369
- _context2.next = 15;
370
- return Promise.resolve(column.preProcessEditCellProps({
371
- id: id,
372
- row: row,
373
- props: newProps,
374
- hasChanged: hasChanged
375
- }));
376
- case 15:
377
- newProps = _context2.sent;
378
- case 16:
379
- if (!(apiRef.current.getCellMode(id, field) === GridCellModes.View)) {
380
- _context2.next = 18;
381
- break;
382
- }
383
- return _context2.abrupt("return", false);
384
- case 18:
385
- editingState = gridEditRowsStateSelector(apiRef.current.state);
386
- newProps = _extends({}, newProps, {
387
- isProcessingProps: false
388
- });
389
- // We don't update the value with the one coming from the props pre-processing
390
- // because when the promise resolves it may be already outdated. The only
391
- // exception to this rule is when there's no pre-processing.
392
- newProps.value = column.preProcessEditCellProps ? editingState[id][field].value : parsedValue;
393
- updateOrDeleteFieldState(id, field, newProps);
394
- editingState = gridEditRowsStateSelector(apiRef.current.state);
395
- return _context2.abrupt("return", !((_editingState$id = editingState[id]) != null && (_editingState$id$fiel2 = _editingState$id[field]) != null && _editingState$id$fiel2.error));
396
- case 24:
397
- case "end":
398
- return _context2.stop();
399
- }
345
+ while (1) switch (_context2.prev = _context2.next) {
346
+ case 0:
347
+ id = params.id, field = params.field, value = params.value, debounceMs = params.debounceMs, skipValueParser = params.unstable_skipValueParser;
348
+ throwIfNotEditable(id, field);
349
+ throwIfNotInMode(id, field, GridCellModes.Edit);
350
+ column = apiRef.current.getColumn(field);
351
+ row = apiRef.current.getRow(id);
352
+ parsedValue = value;
353
+ if (column.valueParser && !skipValueParser) {
354
+ parsedValue = column.valueParser(value, apiRef.current.getCellParams(id, field));
355
+ }
356
+ editingState = gridEditRowsStateSelector(apiRef.current.state);
357
+ newProps = _extends({}, editingState[id][field], {
358
+ value: parsedValue,
359
+ changeReason: debounceMs ? 'debouncedSetEditCellValue' : 'setEditCellValue'
360
+ });
361
+ if (!column.preProcessEditCellProps) {
362
+ _context2.next = 16;
363
+ break;
364
+ }
365
+ hasChanged = value !== editingState[id][field].value;
366
+ newProps = _extends({}, newProps, {
367
+ isProcessingProps: true
368
+ });
369
+ updateOrDeleteFieldState(id, field, newProps);
370
+ _context2.next = 15;
371
+ return Promise.resolve(column.preProcessEditCellProps({
372
+ id: id,
373
+ row: row,
374
+ props: newProps,
375
+ hasChanged: hasChanged
376
+ }));
377
+ case 15:
378
+ newProps = _context2.sent;
379
+ case 16:
380
+ if (!(apiRef.current.getCellMode(id, field) === GridCellModes.View)) {
381
+ _context2.next = 18;
382
+ break;
383
+ }
384
+ return _context2.abrupt("return", false);
385
+ case 18:
386
+ editingState = gridEditRowsStateSelector(apiRef.current.state);
387
+ newProps = _extends({}, newProps, {
388
+ isProcessingProps: false
389
+ });
390
+ // We don't update the value with the one coming from the props pre-processing
391
+ // because when the promise resolves it may be already outdated. The only
392
+ // exception to this rule is when there's no pre-processing.
393
+ newProps.value = column.preProcessEditCellProps ? editingState[id][field].value : parsedValue;
394
+ updateOrDeleteFieldState(id, field, newProps);
395
+ editingState = gridEditRowsStateSelector(apiRef.current.state);
396
+ return _context2.abrupt("return", !((_editingState$id = editingState[id]) != null && (_editingState$id$fiel2 = _editingState$id[field]) != null && _editingState$id$fiel2.error));
397
+ case 24:
398
+ case "end":
399
+ return _context2.stop();
400
400
  }
401
401
  }, _callee2);
402
402
  }));
@@ -105,24 +105,22 @@ export var useGridEditing = function useGridEditing(apiRef, props) {
105
105
  maybeDebounce(id, field, debounceMs, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
106
106
  var setEditCellValueToCall, result;
107
107
  return _regeneratorRuntime.wrap(function _callee$(_context) {
108
- while (1) {
109
- switch (_context.prev = _context.next) {
110
- case 0:
111
- setEditCellValueToCall = props.editMode === GridEditModes.Row ? apiRef.current.setRowEditingEditCellValue : apiRef.current.setCellEditingEditCellValue; // Check if the cell is in edit mode
112
- // By the time this callback runs the user may have cancelled the editing
113
- if (!(apiRef.current.getCellMode(id, field) === GridCellModes.Edit)) {
114
- _context.next = 6;
115
- break;
116
- }
117
- _context.next = 4;
118
- return setEditCellValueToCall(params);
119
- case 4:
120
- result = _context.sent;
121
- resolve(result);
122
- case 6:
123
- case "end":
124
- return _context.stop();
125
- }
108
+ while (1) switch (_context.prev = _context.next) {
109
+ case 0:
110
+ setEditCellValueToCall = props.editMode === GridEditModes.Row ? apiRef.current.setRowEditingEditCellValue : apiRef.current.setCellEditingEditCellValue; // Check if the cell is in edit mode
111
+ // By the time this callback runs the user may have cancelled the editing
112
+ if (!(apiRef.current.getCellMode(id, field) === GridCellModes.Edit)) {
113
+ _context.next = 6;
114
+ break;
115
+ }
116
+ _context.next = 4;
117
+ return setEditCellValueToCall(params);
118
+ case 4:
119
+ result = _context.sent;
120
+ resolve(result);
121
+ case 6:
122
+ case "end":
123
+ return _context.stop();
126
124
  }
127
125
  }, _callee);
128
126
  })));
@@ -133,9 +131,7 @@ export var useGridEditing = function useGridEditing(apiRef, props) {
133
131
  }, [apiRef, props.editMode]);
134
132
  var getEditCellMeta = React.useCallback(function (id, field) {
135
133
  var editingState = gridEditRowsStateSelector(apiRef.current.state);
136
- return {
137
- changeReason: editingState[id][field].changeReason
138
- };
134
+ return editingState[id][field];
139
135
  }, [apiRef]);
140
136
  var editingSharedApi = {
141
137
  isCellEditable: isCellEditable,
@@ -310,13 +310,17 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
310
310
  return acc;
311
311
  }
312
312
  var newValue = apiRef.current.getCellValue(id, field);
313
+ // eslint-disable-next-line @typescript-eslint/naming-convention
314
+ var unstable_updateValueOnRender = false;
313
315
  if (fieldToFocus === field && (deleteValue || initialValue)) {
314
316
  newValue = deleteValue ? '' : initialValue;
317
+ unstable_updateValueOnRender = true;
315
318
  }
316
319
  acc[field] = {
317
320
  value: newValue,
318
321
  error: false,
319
- isProcessingProps: false
322
+ isProcessingProps: false,
323
+ unstable_updateValueOnRender: unstable_updateValueOnRender
320
324
  };
321
325
  return acc;
322
326
  }, {});
@@ -190,54 +190,52 @@ export var useGridPrintExport = function useGridPrintExport(apiRef, props) {
190
190
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
191
191
  var visibleRowCount, printWindow;
192
192
  return _regeneratorRuntime.wrap(function _callee$(_context) {
193
- while (1) {
194
- switch (_context.prev = _context.next) {
195
- case 0:
196
- logger.debug("Export data as Print");
197
- if (apiRef.current.rootElementRef.current) {
198
- _context.next = 3;
199
- break;
200
- }
201
- throw new Error('MUI: No grid root element available.');
202
- case 3:
203
- previousGridState.current = apiRef.current.exportState();
204
- // It appends that the visibility model is not exported, especially if columnVisibility is not controlled
205
- previousColumnVisibility.current = gridColumnVisibilityModelSelector(apiRef);
206
- if (props.pagination) {
207
- visibleRowCount = gridExpandedRowCountSelector(apiRef);
208
- apiRef.current.setPageSize(visibleRowCount);
209
- }
210
- _context.next = 8;
211
- return updateGridColumnsForPrint(options == null ? void 0 : options.fields, options == null ? void 0 : options.allColumns);
212
- case 8:
213
- apiRef.current.unstable_disableVirtualization();
214
- _context.next = 11;
215
- return raf();
216
- case 11:
217
- // wait for the state changes to take action
218
- printWindow = buildPrintWindow(options == null ? void 0 : options.fileName);
219
- if (process.env.NODE_ENV === 'test') {
220
- doc.current.body.appendChild(printWindow);
221
- // In test env, run the all pipeline without waiting for loading
193
+ while (1) switch (_context.prev = _context.next) {
194
+ case 0:
195
+ logger.debug("Export data as Print");
196
+ if (apiRef.current.rootElementRef.current) {
197
+ _context.next = 3;
198
+ break;
199
+ }
200
+ throw new Error('MUI: No grid root element available.');
201
+ case 3:
202
+ previousGridState.current = apiRef.current.exportState();
203
+ // It appends that the visibility model is not exported, especially if columnVisibility is not controlled
204
+ previousColumnVisibility.current = gridColumnVisibilityModelSelector(apiRef);
205
+ if (props.pagination) {
206
+ visibleRowCount = gridExpandedRowCountSelector(apiRef);
207
+ apiRef.current.setPageSize(visibleRowCount);
208
+ }
209
+ _context.next = 8;
210
+ return updateGridColumnsForPrint(options == null ? void 0 : options.fields, options == null ? void 0 : options.allColumns);
211
+ case 8:
212
+ apiRef.current.unstable_disableVirtualization();
213
+ _context.next = 11;
214
+ return raf();
215
+ case 11:
216
+ // wait for the state changes to take action
217
+ printWindow = buildPrintWindow(options == null ? void 0 : options.fileName);
218
+ if (process.env.NODE_ENV === 'test') {
219
+ doc.current.body.appendChild(printWindow);
220
+ // In test env, run the all pipeline without waiting for loading
221
+ handlePrintWindowLoad(printWindow, options);
222
+ handlePrintWindowAfterPrint(printWindow);
223
+ } else {
224
+ printWindow.onload = function () {
222
225
  handlePrintWindowLoad(printWindow, options);
223
- handlePrintWindowAfterPrint(printWindow);
224
- } else {
225
- printWindow.onload = function () {
226
- handlePrintWindowLoad(printWindow, options);
227
- var mediaQueryList = printWindow.contentWindow.matchMedia('print');
228
- mediaQueryList.addEventListener('change', function (mql) {
229
- var isAfterPrint = mql.matches === false;
230
- if (isAfterPrint) {
231
- handlePrintWindowAfterPrint(printWindow);
232
- }
233
- });
234
- };
235
- doc.current.body.appendChild(printWindow);
236
- }
237
- case 13:
238
- case "end":
239
- return _context.stop();
240
- }
226
+ var mediaQueryList = printWindow.contentWindow.matchMedia('print');
227
+ mediaQueryList.addEventListener('change', function (mql) {
228
+ var isAfterPrint = mql.matches === false;
229
+ if (isAfterPrint) {
230
+ handlePrintWindowAfterPrint(printWindow);
231
+ }
232
+ });
233
+ };
234
+ doc.current.body.appendChild(printWindow);
235
+ }
236
+ case 13:
237
+ case "end":
238
+ return _context.stop();
241
239
  }
242
240
  }, _callee);
243
241
  }));
@@ -6,4 +6,9 @@ export var getDefaultGridFilterModel = function getDefaultGridFilterModel() {
6
6
  quickFilterValues: [],
7
7
  quickFilterLogicOperator: GridLogicOperator.And
8
8
  };
9
- };
9
+ };
10
+
11
+ /**
12
+ * @param {GridRowId} rowId The id of the row we want to filter.
13
+ * @param {(filterItem: GridFilterItem) => boolean} shouldApplyItem An optional callback to allow the filtering engine to only apply some items.
14
+ */
@@ -121,6 +121,11 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
121
121
  var filterItemsWithValue = filterModel.items.filter(function (item) {
122
122
  var _column$filterOperato;
123
123
  if (item.value !== undefined) {
124
+ // Some filters like `isAnyOf` support array as `item.value`.
125
+ // If array is empty, we want to remove it from the filter model.
126
+ if (Array.isArray(item.value) && item.value.length === 0) {
127
+ return false;
128
+ }
124
129
  return true;
125
130
  }
126
131
  var column = apiRef.current.getColumn(item.field);
@@ -12,7 +12,7 @@ import { gridExpandedSortedRowIdsSelector } from '../filter/gridFilterSelector';
12
12
  import { GRID_CHECKBOX_SELECTION_COL_DEF, GRID_ACTIONS_COLUMN_TYPE } from '../../../colDef';
13
13
  import { GridCellModes } from '../../../models/gridEditRowModel';
14
14
  import { isKeyboardEvent, isNavigationKey } from '../../../utils/keyboardUtils';
15
- import { getVisibleRows, useGridVisibleRows } from '../../utils/useGridVisibleRows';
15
+ import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
16
16
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPanelToggleField';
17
17
  import { gridClasses } from '../../../constants/gridClasses';
18
18
  var getSelectionModelPropValue = function getSelectionModelPropValue(selectionModelProp, prevSelectionModel) {
@@ -63,8 +63,6 @@ export var useGridRowSelection = function useGridRowSelection(apiRef, props) {
63
63
  var checkboxSelection = props.checkboxSelection,
64
64
  disableMultipleRowSelection = props.disableMultipleRowSelection,
65
65
  disableRowSelectionOnClick = props.disableRowSelectionOnClick,
66
- pagination = props.pagination,
67
- paginationMode = props.paginationMode,
68
66
  propIsRowSelectable = props.isRowSelectable;
69
67
  var canHaveMultipleSelection = !disableMultipleRowSelection || checkboxSelection;
70
68
  var visibleRows = useGridVisibleRows(apiRef, props);
@@ -408,30 +406,13 @@ export var useGridRowSelection = function useGridRowSelection(apiRef, props) {
408
406
  }
409
407
  }, [apiRef, isRowSelectable, isStateControlled, props.rowSelection]);
410
408
  React.useEffect(function () {
411
- if (!props.rowSelection) {
409
+ if (!props.rowSelection || isStateControlled) {
412
410
  return;
413
411
  }
414
412
  var currentSelection = gridRowSelectionStateSelector(apiRef.current.state);
415
413
  if (!canHaveMultipleSelection && currentSelection.length > 1) {
416
- var _getVisibleRows = getVisibleRows(apiRef, {
417
- pagination: pagination,
418
- paginationMode: paginationMode
419
- }),
420
- currentPageRows = _getVisibleRows.rows;
421
- var currentPageRowsLookup = currentPageRows.reduce(function (acc, _ref4) {
422
- var id = _ref4.id;
423
- acc[id] = true;
424
- return acc;
425
- }, {});
426
- var firstSelectableRow = currentSelection.find(function (id) {
427
- var isSelectable = true;
428
- if (isRowSelectable) {
429
- isSelectable = isRowSelectable(id);
430
- }
431
- return isSelectable && currentPageRowsLookup[id]; // Check if the row is in the current page
432
- });
433
-
434
- apiRef.current.setRowSelectionModel(firstSelectableRow !== undefined ? [firstSelectableRow] : []);
414
+ // See https://github.com/mui/mui-x/issues/8455
415
+ apiRef.current.setRowSelectionModel([]);
435
416
  }
436
- }, [apiRef, canHaveMultipleSelection, checkboxSelection, disableMultipleRowSelection, isRowSelectable, pagination, paginationMode, props.rowSelection]);
417
+ }, [apiRef, canHaveMultipleSelection, checkboxSelection, isStateControlled, props.rowSelection]);
437
418
  };
@@ -247,7 +247,7 @@ export var updateCacheWithNewRows = function updateCacheWithNewRows(_ref4) {
247
247
  dataRowIdToIdLookup[id] = id;
248
248
  });
249
249
  var actionTypeWithActionsToRemove = Object.keys(alreadyAppliedActionsToRemove);
250
- var _loop = function _loop(i) {
250
+ var _loop = function _loop() {
251
251
  var actionType = actionTypeWithActionsToRemove[i];
252
252
  var idsToRemove = alreadyAppliedActionsToRemove[actionType];
253
253
  if (Object.keys(idsToRemove).length > 0) {
@@ -257,7 +257,7 @@ export var updateCacheWithNewRows = function updateCacheWithNewRows(_ref4) {
257
257
  }
258
258
  };
259
259
  for (var i = 0; i < actionTypeWithActionsToRemove.length; i += 1) {
260
- _loop(i);
260
+ _loop();
261
261
  }
262
262
  return {
263
263
  dataRowIdToModelLookup: dataRowIdToModelLookup,
@@ -401,12 +401,12 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
401
401
  rowStyleCache.current = {};
402
402
  }
403
403
  var rows = [];
404
- for (var i = 0; i < renderedRows.length; i += 1) {
404
+ for (var _i = 0; _i < renderedRows.length; _i += 1) {
405
405
  var _currentPage$range5;
406
- var _renderedRows$i = renderedRows[i],
407
- _id = _renderedRows$i.id,
408
- _model = _renderedRows$i.model;
409
- var lastVisibleRowIndex = firstRowToRender + i === currentPage.rows.length - 1;
406
+ var _renderedRows$_i = renderedRows[_i],
407
+ _id = _renderedRows$_i.id,
408
+ _model = _renderedRows$_i.model;
409
+ var lastVisibleRowIndex = firstRowToRender + _i === currentPage.rows.length - 1;
410
410
  var baseRowHeight = !apiRef.current.rowHasAutoHeight(_id) ? apiRef.current.unstable_getRowHeight(_id) : 'auto';
411
411
  var isSelected = void 0;
412
412
  if (selectedRowsLookup[_id] == null) {
@@ -438,7 +438,7 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
438
438
  firstColumnToRender: firstColumnToRender,
439
439
  lastColumnToRender: lastColumnToRender,
440
440
  selected: isSelected,
441
- index: rowIndexOffset + ((currentPage == null ? void 0 : (_currentPage$range5 = currentPage.range) == null ? void 0 : _currentPage$range5.firstRowIndex) || 0) + firstRowToRender + i,
441
+ index: rowIndexOffset + ((currentPage == null ? void 0 : (_currentPage$range5 = currentPage.range) == null ? void 0 : _currentPage$range5.firstRowIndex) || 0) + firstRowToRender + _i,
442
442
  containerWidth: availableSpace,
443
443
  isLastVisible: lastVisibleRowIndex,
444
444
  position: position
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.0.4
2
+ * @mui/x-data-grid v6.2.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -28,4 +28,12 @@ export { GridColumnMenu, GRID_COLUMN_MENU_SLOTS, GRID_COLUMN_MENU_SLOT_PROPS } f
28
28
  * The full grid API.
29
29
  * @demos
30
30
  * - [API object](/x/react-data-grid/api-object/)
31
+ */
32
+
33
+ /**
34
+ * The state of `DataGrid`.
35
+ */
36
+
37
+ /**
38
+ * The initial state of `DataGrid`.
31
39
  */
@@ -3,7 +3,6 @@
3
3
  // This allows not to bump the minimal version of `@mui/material` in peerDependencies which results
4
4
  // in broader compatibility between the packages.
5
5
  // See https://github.com/mui/mui-x/pull/7646#issuecomment-1404605556 for additional context.
6
-
7
6
  export var beBYCore = {
8
7
  components: {
9
8
  MuiTablePagination: {
@@ -123,15 +123,13 @@ var frFRGrid = {
123
123
  expandDetailPanel: 'Afficher',
124
124
  collapseDetailPanel: 'Masquer',
125
125
  // Row reordering text
126
- rowReorderingHeaderName: 'Positionnement des lignes'
127
-
126
+ rowReorderingHeaderName: 'Positionnement des lignes',
128
127
  // Aggregation
129
- // aggregationMenuItemHeader: 'Aggregation',
130
- // aggregationFunctionLabelSum: 'sum',
131
- // aggregationFunctionLabelAvg: 'avg',
132
- // aggregationFunctionLabelMin: 'min',
133
- // aggregationFunctionLabelMax: 'max',
134
- // aggregationFunctionLabelSize: 'size',
128
+ aggregationMenuItemHeader: 'Agrégation',
129
+ aggregationFunctionLabelSum: 'Somme',
130
+ aggregationFunctionLabelAvg: 'Moyenne',
131
+ aggregationFunctionLabelMin: 'Minimum',
132
+ aggregationFunctionLabelMax: 'Maximum',
133
+ aggregationFunctionLabelSize: "Nombre d'éléments"
135
134
  };
136
-
137
135
  export var frFR = getGridLocalization(frFRGrid, frFRCore);