@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.
- package/CHANGELOG.md +110 -0
- package/components/GridAutoSizer.js +3 -0
- package/components/GridPagination.d.ts +6 -6
- package/components/GridRow.js +3 -1
- package/components/cell/GridActionsCellItem.d.ts +2 -2
- package/components/cell/GridEditDateCell.js +37 -16
- package/components/columnHeaders/ColumnHeaderMenuIcon.js +20 -16
- package/components/panel/GridColumnsPanel.d.ts +8 -0
- package/components/panel/GridColumnsPanel.js +18 -6
- package/components/panel/GridPanel.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.js +37 -29
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +34 -30
- package/components/toolbar/GridToolbarColumnsButton.d.ts +1 -1
- package/components/toolbar/GridToolbarDensitySelector.d.ts +1 -1
- package/components/toolbar/GridToolbarExportContainer.d.ts +1 -1
- package/hooks/core/useGridApiInitialization.js +3 -3
- package/hooks/features/columns/gridColumnsSelector.d.ts +3 -3
- package/hooks/features/editing/useGridCellEditing.js +5 -1
- package/hooks/features/editing/useGridEditing.js +1 -3
- package/hooks/features/editing/useGridRowEditing.js +5 -1
- package/hooks/features/filter/gridFilterState.js +6 -1
- package/hooks/features/filter/useGridFilter.js +5 -0
- package/hooks/features/rowSelection/useGridRowSelection.js +5 -26
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +36 -16
- package/index.js +9 -1
- package/legacy/components/GridAutoSizer.js +3 -0
- package/legacy/components/GridRow.js +4 -1
- package/legacy/components/cell/GridEditBooleanCell.js +19 -21
- package/legacy/components/cell/GridEditDateCell.js +69 -39
- package/legacy/components/cell/GridEditInputCell.js +25 -27
- package/legacy/components/cell/GridEditSingleSelectCell.js +26 -28
- package/legacy/components/columnHeaders/ColumnHeaderMenuIcon.js +20 -16
- package/legacy/components/panel/GridColumnsPanel.js +19 -6
- package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +37 -29
- package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +34 -30
- package/legacy/hooks/core/useGridApiInitialization.js +3 -3
- package/legacy/hooks/features/columns/gridColumnsUtils.js +2 -2
- package/legacy/hooks/features/editing/useGridCellEditing.js +120 -120
- package/legacy/hooks/features/editing/useGridEditing.js +17 -21
- package/legacy/hooks/features/editing/useGridRowEditing.js +5 -1
- package/legacy/hooks/features/export/useGridPrintExport.js +45 -47
- package/legacy/hooks/features/filter/gridFilterState.js +6 -1
- package/legacy/hooks/features/filter/useGridFilter.js +5 -0
- package/legacy/hooks/features/rowSelection/useGridRowSelection.js +5 -24
- package/legacy/hooks/features/rows/gridRowsUtils.js +2 -2
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +6 -6
- package/legacy/index.js +9 -1
- package/legacy/locales/coreLocales.js +0 -1
- package/legacy/locales/frFR.js +7 -9
- package/legacy/locales/huHU.js +15 -20
- package/legacy/locales/jaJP.js +1 -1
- package/legacy/locales/nlNL.js +3 -3
- package/legacy/locales/ptBR.js +7 -9
- package/legacy/locales/ruRU.js +1 -1
- package/legacy/locales/urPK.js +6 -6
- package/legacy/models/gridColumnGrouping.js +4 -0
- package/legacy/models/params/gridRowParams.js +8 -0
- package/legacy/utils/createSelector.js +14 -22
- package/legacy/utils/utils.js +1 -1
- package/locales/coreLocales.js +0 -1
- package/locales/frFR.js +7 -9
- package/locales/huHU.js +15 -20
- package/locales/jaJP.js +1 -1
- package/locales/nlNL.js +3 -3
- package/locales/ptBR.js +7 -9
- package/locales/ruRU.js +1 -1
- package/locales/urPK.js +6 -6
- package/models/api/gridCoreApi.d.ts +3 -1
- package/models/api/gridEditingApi.d.ts +4 -0
- package/models/gridColumnGrouping.js +4 -0
- package/models/params/gridRowParams.js +8 -0
- package/modern/components/GridAutoSizer.js +3 -0
- package/modern/components/GridRow.js +3 -1
- package/modern/components/cell/GridEditDateCell.js +37 -16
- package/modern/components/columnHeaders/ColumnHeaderMenuIcon.js +19 -15
- package/modern/components/panel/GridColumnsPanel.js +18 -6
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +36 -28
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +33 -29
- package/modern/hooks/core/useGridApiInitialization.js +3 -3
- package/modern/hooks/features/editing/useGridCellEditing.js +5 -1
- package/modern/hooks/features/editing/useGridEditing.js +1 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +5 -1
- package/modern/hooks/features/filter/gridFilterState.js +6 -1
- package/modern/hooks/features/filter/useGridFilter.js +5 -0
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +5 -26
- package/modern/index.js +9 -1
- package/modern/locales/coreLocales.js +0 -1
- package/modern/locales/frFR.js +7 -9
- package/modern/locales/huHU.js +15 -20
- package/modern/locales/jaJP.js +1 -1
- package/modern/locales/nlNL.js +3 -3
- package/modern/locales/ptBR.js +7 -9
- package/modern/locales/ruRU.js +1 -1
- package/modern/locales/urPK.js +6 -6
- package/modern/models/gridColumnGrouping.js +4 -0
- package/modern/models/params/gridRowParams.js +8 -0
- package/modern/utils/createSelector.js +12 -22
- package/modern/utils/utils.js +1 -1
- package/node/components/GridAutoSizer.js +3 -1
- package/node/components/GridRow.js +3 -1
- package/node/components/cell/GridCell.js +1 -0
- package/node/components/cell/GridEditDateCell.js +37 -16
- package/node/components/columnHeaders/ColumnHeaderMenuIcon.js +19 -15
- package/node/components/panel/GridColumnsPanel.js +18 -6
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +36 -28
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +32 -29
- package/node/hooks/core/useGridApiInitialization.js +3 -3
- package/node/hooks/features/editing/useGridCellEditing.js +5 -1
- package/node/hooks/features/editing/useGridEditing.js +1 -3
- package/node/hooks/features/editing/useGridRowEditing.js +5 -1
- package/node/hooks/features/filter/gridFilterState.js +5 -0
- package/node/hooks/features/filter/useGridFilter.js +5 -0
- package/node/hooks/features/rowSelection/useGridRowSelection.js +4 -25
- package/node/index.js +1 -1
- package/node/locales/frFR.js +7 -9
- package/node/locales/huHU.js +15 -20
- package/node/locales/jaJP.js +1 -1
- package/node/locales/nlNL.js +3 -3
- package/node/locales/ptBR.js +7 -9
- package/node/locales/ruRU.js +1 -1
- package/node/locales/urPK.js +6 -6
- package/node/models/gridColumnGrouping.js +4 -0
- package/node/models/params/gridEditCellParams.js +1 -0
- package/node/models/params/gridRowParams.js +9 -0
- package/node/utils/createSelector.js +12 -22
- package/node/utils/utils.js +1 -1
- package/package.json +1 -1
- package/utils/createSelector.d.ts +4 -4
- package/utils/createSelector.js +14 -22
- package/utils/utils.d.ts +1 -1
- 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
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
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
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
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
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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 {
|
|
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
|
-
|
|
417
|
-
|
|
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,
|
|
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(
|
|
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(
|
|
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
|
|
404
|
+
for (var _i = 0; _i < renderedRows.length; _i += 1) {
|
|
405
405
|
var _currentPage$range5;
|
|
406
|
-
var _renderedRows$
|
|
407
|
-
_id = _renderedRows$
|
|
408
|
-
_model = _renderedRows$
|
|
409
|
-
var lastVisibleRowIndex = firstRowToRender +
|
|
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 +
|
|
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
|
|
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: {
|
package/legacy/locales/frFR.js
CHANGED
|
@@ -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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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);
|