@mui/x-data-grid 5.17.6 → 5.17.7

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 CHANGED
@@ -3,6 +3,21 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 5.17.7
7
+
8
+ _Oct 13, 2022_
9
+
10
+ We'd like to offer a big thanks to the 2 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🐞 Bugfixes
13
+
14
+ ### `@mui/x-data-grid@v5.17.7` / `@mui/x-data-grid-pro@v5.17.7` / `@mui/x-data-grid-premium@v5.17.7`
15
+
16
+ #### Changes
17
+
18
+ - [DataGrid] Fix error when using column grouping with all columns hidden (#6425) @alexfauquette
19
+ - [DataGrid] Fix start edit mode with printable character in React 18 (#6478) @m4theushw
20
+
6
21
  ## 5.17.6
7
22
 
8
23
  _Oct 6, 2022_
@@ -238,7 +238,7 @@ export const useGridColumnHeaders = props => {
238
238
 
239
239
  const columnsToRender = getColumnsToRender(params);
240
240
 
241
- if (columnsToRender == null) {
241
+ if (columnsToRender == null || columnsToRender.renderedColumns.length === 0) {
242
242
  return null;
243
243
  }
244
244
 
@@ -121,7 +121,8 @@ export const useGridCellEditing = (apiRef, props) => {
121
121
 
122
122
  if (reason) {
123
123
  const newParams = _extends({}, params, {
124
- reason
124
+ reason,
125
+ key: event.key
125
126
  });
126
127
 
127
128
  apiRef.current.publishEvent('cellEditStart', newParams, event);
@@ -132,14 +133,21 @@ export const useGridCellEditing = (apiRef, props) => {
132
133
  const {
133
134
  id,
134
135
  field,
135
- reason
136
+ reason,
137
+ key
136
138
  } = params;
137
139
  const startCellEditModeParams = {
138
140
  id,
139
141
  field
140
142
  };
141
143
 
142
- if (reason === GridCellEditStartReasons.deleteKeyDown || reason === GridCellEditStartReasons.printableKeyDown) {
144
+ if (reason === GridCellEditStartReasons.printableKeyDown) {
145
+ if (React.version.startsWith('18')) {
146
+ startCellEditModeParams.initialValue = key; // In React 17, cleaning the input is enough
147
+ } else {
148
+ startCellEditModeParams.deleteValue = true;
149
+ }
150
+ } else if (reason === GridCellEditStartReasons.deleteKeyDown) {
143
151
  startCellEditModeParams.deleteValue = true;
144
152
  }
145
153
 
@@ -270,10 +278,17 @@ export const useGridCellEditing = (apiRef, props) => {
270
278
  const {
271
279
  id,
272
280
  field,
273
- deleteValue
281
+ deleteValue,
282
+ initialValue
274
283
  } = params;
284
+ let newValue = apiRef.current.getCellValue(id, field);
285
+
286
+ if (deleteValue || initialValue) {
287
+ newValue = deleteValue ? '' : initialValue;
288
+ }
289
+
275
290
  const newProps = {
276
- value: deleteValue ? '' : apiRef.current.getCellValue(id, field),
291
+ value: newValue,
277
292
  error: false,
278
293
  isProcessingProps: false
279
294
  };
@@ -181,6 +181,7 @@ export const useGridRowEditing = (apiRef, props) => {
181
181
 
182
182
  const newParams = _extends({}, rowParams, {
183
183
  field: params.field,
184
+ key: event.key,
184
185
  reason
185
186
  });
186
187
 
@@ -192,14 +193,21 @@ export const useGridRowEditing = (apiRef, props) => {
192
193
  const {
193
194
  id,
194
195
  field,
195
- reason
196
+ reason,
197
+ key
196
198
  } = params;
197
199
  const startRowEditModeParams = {
198
200
  id,
199
201
  fieldToFocus: field
200
202
  };
201
203
 
202
- if (reason === GridRowEditStartReasons.deleteKeyDown || reason === GridRowEditStartReasons.printableKeyDown) {
204
+ if (reason === GridRowEditStartReasons.printableKeyDown) {
205
+ if (React.version.startsWith('18')) {
206
+ startRowEditModeParams.initialValue = key; // In React 17, cleaning the input is enough
207
+ } else {
208
+ startRowEditModeParams.deleteValue = !!field;
209
+ }
210
+ } else if (reason === GridRowEditStartReasons.deleteKeyDown) {
203
211
  startRowEditModeParams.deleteValue = !!field;
204
212
  }
205
213
 
@@ -339,7 +347,8 @@ export const useGridRowEditing = (apiRef, props) => {
339
347
  const {
340
348
  id,
341
349
  fieldToFocus,
342
- deleteValue
350
+ deleteValue,
351
+ initialValue
343
352
  } = params;
344
353
  const columnFields = gridColumnFieldsSelector(apiRef);
345
354
  const newProps = columnFields.reduce((acc, field) => {
@@ -349,9 +358,14 @@ export const useGridRowEditing = (apiRef, props) => {
349
358
  return acc;
350
359
  }
351
360
 
352
- const shouldDeleteValue = deleteValue && fieldToFocus === field;
361
+ let newValue = apiRef.current.getCellValue(id, field);
362
+
363
+ if (fieldToFocus === field && (deleteValue || initialValue)) {
364
+ newValue = deleteValue ? '' : initialValue;
365
+ }
366
+
353
367
  acc[field] = {
354
- value: shouldDeleteValue ? '' : apiRef.current.getCellValue(id, field),
368
+ value: newValue,
355
369
  error: false,
356
370
  isProcessingProps: false
357
371
  };
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.17.6
1
+ /** @license MUI v5.17.7
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -283,7 +283,7 @@ export var useGridColumnHeaders = function useGridColumnHeaders(props) {
283
283
 
284
284
  var columnsToRender = getColumnsToRender(params);
285
285
 
286
- if (columnsToRender == null) {
286
+ if (columnsToRender == null || columnsToRender.renderedColumns.length === 0) {
287
287
  return null;
288
288
  }
289
289
 
@@ -129,7 +129,8 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
129
129
 
130
130
  if (_reason) {
131
131
  var _newParams = _extends({}, params, {
132
- reason: _reason
132
+ reason: _reason,
133
+ key: event.key
133
134
  });
134
135
 
135
136
  apiRef.current.publishEvent('cellEditStart', _newParams, event);
@@ -139,13 +140,20 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
139
140
  var handleCellEditStart = React.useCallback(function (params) {
140
141
  var id = params.id,
141
142
  field = params.field,
142
- reason = params.reason;
143
+ reason = params.reason,
144
+ key = params.key;
143
145
  var startCellEditModeParams = {
144
146
  id: id,
145
147
  field: field
146
148
  };
147
149
 
148
- if (reason === GridCellEditStartReasons.deleteKeyDown || reason === GridCellEditStartReasons.printableKeyDown) {
150
+ if (reason === GridCellEditStartReasons.printableKeyDown) {
151
+ if (React.version.startsWith('18')) {
152
+ startCellEditModeParams.initialValue = key; // In React 17, cleaning the input is enough
153
+ } else {
154
+ startCellEditModeParams.deleteValue = true;
155
+ }
156
+ } else if (reason === GridCellEditStartReasons.deleteKeyDown) {
149
157
  startCellEditModeParams.deleteValue = true;
150
158
  }
151
159
 
@@ -268,9 +276,16 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
268
276
  var updateStateToStartCellEditMode = useEventCallback(function (params) {
269
277
  var id = params.id,
270
278
  field = params.field,
271
- deleteValue = params.deleteValue;
279
+ deleteValue = params.deleteValue,
280
+ initialValue = params.initialValue;
281
+ var newValue = apiRef.current.getCellValue(id, field);
282
+
283
+ if (deleteValue || initialValue) {
284
+ newValue = deleteValue ? '' : initialValue;
285
+ }
286
+
272
287
  var newProps = {
273
- value: deleteValue ? '' : apiRef.current.getCellValue(id, field),
288
+ value: newValue,
274
289
  error: false,
275
290
  isProcessingProps: false
276
291
  };
@@ -189,6 +189,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
189
189
 
190
190
  var _newParams = _extends({}, _rowParams, {
191
191
  field: params.field,
192
+ key: event.key,
192
193
  reason: _reason
193
194
  });
194
195
 
@@ -199,13 +200,20 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
199
200
  var handleRowEditStart = React.useCallback(function (params) {
200
201
  var id = params.id,
201
202
  field = params.field,
202
- reason = params.reason;
203
+ reason = params.reason,
204
+ key = params.key;
203
205
  var startRowEditModeParams = {
204
206
  id: id,
205
207
  fieldToFocus: field
206
208
  };
207
209
 
208
- if (reason === GridRowEditStartReasons.deleteKeyDown || reason === GridRowEditStartReasons.printableKeyDown) {
210
+ if (reason === GridRowEditStartReasons.printableKeyDown) {
211
+ if (React.version.startsWith('18')) {
212
+ startRowEditModeParams.initialValue = key; // In React 17, cleaning the input is enough
213
+ } else {
214
+ startRowEditModeParams.deleteValue = !!field;
215
+ }
216
+ } else if (reason === GridRowEditStartReasons.deleteKeyDown) {
209
217
  startRowEditModeParams.deleteValue = !!field;
210
218
  }
211
219
 
@@ -338,7 +346,8 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
338
346
  var updateStateToStartRowEditMode = useEventCallback(function (params) {
339
347
  var id = params.id,
340
348
  fieldToFocus = params.fieldToFocus,
341
- deleteValue = params.deleteValue;
349
+ deleteValue = params.deleteValue,
350
+ initialValue = params.initialValue;
342
351
  var columnFields = gridColumnFieldsSelector(apiRef);
343
352
  var newProps = columnFields.reduce(function (acc, field) {
344
353
  var cellParams = apiRef.current.getCellParams(id, field);
@@ -347,9 +356,14 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
347
356
  return acc;
348
357
  }
349
358
 
350
- var shouldDeleteValue = deleteValue && fieldToFocus === field;
359
+ var newValue = apiRef.current.getCellValue(id, field);
360
+
361
+ if (fieldToFocus === field && (deleteValue || initialValue)) {
362
+ newValue = deleteValue ? '' : initialValue;
363
+ }
364
+
351
365
  acc[field] = {
352
- value: shouldDeleteValue ? '' : apiRef.current.getCellValue(id, field),
366
+ value: newValue,
353
367
  error: false,
354
368
  isProcessingProps: false
355
369
  };
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.17.6
1
+ /** @license MUI v5.17.7
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -183,6 +183,11 @@ export interface GridStartCellEditModeParams {
183
183
  * If `true`, the value will be deleted before entering the edit mode.
184
184
  */
185
185
  deleteValue?: boolean;
186
+ /**
187
+ * The initial value for the field.
188
+ * If `deleteValue` is also true, this value is not used.
189
+ */
190
+ initialValue?: any;
186
191
  }
187
192
  /**
188
193
  * Params passed to `apiRef.current.stopCellEditMode`.
@@ -223,6 +228,11 @@ export interface GridStartRowEditModeParams {
223
228
  * If `true`, the value in `fieldToFocus` will be deleted before entering the edit mode.
224
229
  */
225
230
  deleteValue?: boolean;
231
+ /**
232
+ * The initial value for the given `fieldToFocus`.
233
+ * If `deleteValue` is also true, this value is not used.
234
+ */
235
+ initialValue?: string;
226
236
  }
227
237
  /**
228
238
  * Params passed to `apiRef.current.stopRowEditMode`.
@@ -55,6 +55,10 @@ export interface GridCellEditStartParams<V = any, R extends GridValidRowModel =
55
55
  * Only applied if `props.experimentalFeatures.newEditingApi: true`.
56
56
  */
57
57
  reason?: GridCellEditStartReasons;
58
+ /**
59
+ * If the reason is related to a keyboard event, it contains which key was pressed.
60
+ */
61
+ key?: string;
58
62
  }
59
63
  declare enum GridCellEditStopReasons {
60
64
  cellFocusOut = "cellFocusOut",
@@ -78,6 +78,10 @@ export interface GridRowEditStartParams<R extends GridValidRowModel = any> exten
78
78
  * Only applied if `props.experimentalFeatures.newEditingApi: true`.
79
79
  */
80
80
  reason?: GridRowEditStartReasons;
81
+ /**
82
+ * If the reason is related to a keyboard event, it contains which key was pressed.
83
+ */
84
+ key?: string;
81
85
  }
82
86
  declare enum GridRowEditStopReasons {
83
87
  rowFocusOut = "rowFocusOut",
@@ -236,7 +236,7 @@ export const useGridColumnHeaders = props => {
236
236
 
237
237
  const columnsToRender = getColumnsToRender(params);
238
238
 
239
- if (columnsToRender == null) {
239
+ if (columnsToRender == null || columnsToRender.renderedColumns.length === 0) {
240
240
  return null;
241
241
  }
242
242
 
@@ -121,7 +121,8 @@ export const useGridCellEditing = (apiRef, props) => {
121
121
 
122
122
  if (reason) {
123
123
  const newParams = _extends({}, params, {
124
- reason
124
+ reason,
125
+ key: event.key
125
126
  });
126
127
 
127
128
  apiRef.current.publishEvent('cellEditStart', newParams, event);
@@ -132,14 +133,21 @@ export const useGridCellEditing = (apiRef, props) => {
132
133
  const {
133
134
  id,
134
135
  field,
135
- reason
136
+ reason,
137
+ key
136
138
  } = params;
137
139
  const startCellEditModeParams = {
138
140
  id,
139
141
  field
140
142
  };
141
143
 
142
- if (reason === GridCellEditStartReasons.deleteKeyDown || reason === GridCellEditStartReasons.printableKeyDown) {
144
+ if (reason === GridCellEditStartReasons.printableKeyDown) {
145
+ if (React.version.startsWith('18')) {
146
+ startCellEditModeParams.initialValue = key; // In React 17, cleaning the input is enough
147
+ } else {
148
+ startCellEditModeParams.deleteValue = true;
149
+ }
150
+ } else if (reason === GridCellEditStartReasons.deleteKeyDown) {
143
151
  startCellEditModeParams.deleteValue = true;
144
152
  }
145
153
 
@@ -270,10 +278,17 @@ export const useGridCellEditing = (apiRef, props) => {
270
278
  const {
271
279
  id,
272
280
  field,
273
- deleteValue
281
+ deleteValue,
282
+ initialValue
274
283
  } = params;
284
+ let newValue = apiRef.current.getCellValue(id, field);
285
+
286
+ if (deleteValue || initialValue) {
287
+ newValue = deleteValue ? '' : initialValue;
288
+ }
289
+
275
290
  const newProps = {
276
- value: deleteValue ? '' : apiRef.current.getCellValue(id, field),
291
+ value: newValue,
277
292
  error: false,
278
293
  isProcessingProps: false
279
294
  };
@@ -179,6 +179,7 @@ export const useGridRowEditing = (apiRef, props) => {
179
179
 
180
180
  const newParams = _extends({}, rowParams, {
181
181
  field: params.field,
182
+ key: event.key,
182
183
  reason
183
184
  });
184
185
 
@@ -190,14 +191,21 @@ export const useGridRowEditing = (apiRef, props) => {
190
191
  const {
191
192
  id,
192
193
  field,
193
- reason
194
+ reason,
195
+ key
194
196
  } = params;
195
197
  const startRowEditModeParams = {
196
198
  id,
197
199
  fieldToFocus: field
198
200
  };
199
201
 
200
- if (reason === GridRowEditStartReasons.deleteKeyDown || reason === GridRowEditStartReasons.printableKeyDown) {
202
+ if (reason === GridRowEditStartReasons.printableKeyDown) {
203
+ if (React.version.startsWith('18')) {
204
+ startRowEditModeParams.initialValue = key; // In React 17, cleaning the input is enough
205
+ } else {
206
+ startRowEditModeParams.deleteValue = !!field;
207
+ }
208
+ } else if (reason === GridRowEditStartReasons.deleteKeyDown) {
201
209
  startRowEditModeParams.deleteValue = !!field;
202
210
  }
203
211
 
@@ -337,7 +345,8 @@ export const useGridRowEditing = (apiRef, props) => {
337
345
  const {
338
346
  id,
339
347
  fieldToFocus,
340
- deleteValue
348
+ deleteValue,
349
+ initialValue
341
350
  } = params;
342
351
  const columnFields = gridColumnFieldsSelector(apiRef);
343
352
  const newProps = columnFields.reduce((acc, field) => {
@@ -347,9 +356,14 @@ export const useGridRowEditing = (apiRef, props) => {
347
356
  return acc;
348
357
  }
349
358
 
350
- const shouldDeleteValue = deleteValue && fieldToFocus === field;
359
+ let newValue = apiRef.current.getCellValue(id, field);
360
+
361
+ if (fieldToFocus === field && (deleteValue || initialValue)) {
362
+ newValue = deleteValue ? '' : initialValue;
363
+ }
364
+
351
365
  acc[field] = {
352
- value: shouldDeleteValue ? '' : apiRef.current.getCellValue(id, field),
366
+ value: newValue,
353
367
  error: false,
354
368
  isProcessingProps: false
355
369
  };
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.17.6
1
+ /** @license MUI v5.17.7
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -274,7 +274,7 @@ const useGridColumnHeaders = props => {
274
274
 
275
275
  const columnsToRender = getColumnsToRender(params);
276
276
 
277
- if (columnsToRender == null) {
277
+ if (columnsToRender == null || columnsToRender.renderedColumns.length === 0) {
278
278
  return null;
279
279
  }
280
280
 
@@ -147,7 +147,8 @@ const useGridCellEditing = (apiRef, props) => {
147
147
 
148
148
  if (reason) {
149
149
  const newParams = (0, _extends2.default)({}, params, {
150
- reason
150
+ reason,
151
+ key: event.key
151
152
  });
152
153
  apiRef.current.publishEvent('cellEditStart', newParams, event);
153
154
  }
@@ -157,14 +158,21 @@ const useGridCellEditing = (apiRef, props) => {
157
158
  const {
158
159
  id,
159
160
  field,
160
- reason
161
+ reason,
162
+ key
161
163
  } = params;
162
164
  const startCellEditModeParams = {
163
165
  id,
164
166
  field
165
167
  };
166
168
 
167
- if (reason === _gridEditCellParams.GridCellEditStartReasons.deleteKeyDown || reason === _gridEditCellParams.GridCellEditStartReasons.printableKeyDown) {
169
+ if (reason === _gridEditCellParams.GridCellEditStartReasons.printableKeyDown) {
170
+ if (React.version.startsWith('18')) {
171
+ startCellEditModeParams.initialValue = key; // In React 17, cleaning the input is enough
172
+ } else {
173
+ startCellEditModeParams.deleteValue = true;
174
+ }
175
+ } else if (reason === _gridEditCellParams.GridCellEditStartReasons.deleteKeyDown) {
168
176
  startCellEditModeParams.deleteValue = true;
169
177
  }
170
178
 
@@ -293,10 +301,17 @@ const useGridCellEditing = (apiRef, props) => {
293
301
  const {
294
302
  id,
295
303
  field,
296
- deleteValue
304
+ deleteValue,
305
+ initialValue
297
306
  } = params;
307
+ let newValue = apiRef.current.getCellValue(id, field);
308
+
309
+ if (deleteValue || initialValue) {
310
+ newValue = deleteValue ? '' : initialValue;
311
+ }
312
+
298
313
  const newProps = {
299
- value: deleteValue ? '' : apiRef.current.getCellValue(id, field),
314
+ value: newValue,
300
315
  error: false,
301
316
  isProcessingProps: false
302
317
  };
@@ -204,6 +204,7 @@ const useGridRowEditing = (apiRef, props) => {
204
204
  const rowParams = apiRef.current.getRowParams(params.id);
205
205
  const newParams = (0, _extends2.default)({}, rowParams, {
206
206
  field: params.field,
207
+ key: event.key,
207
208
  reason
208
209
  });
209
210
  apiRef.current.publishEvent('rowEditStart', newParams, event);
@@ -214,14 +215,21 @@ const useGridRowEditing = (apiRef, props) => {
214
215
  const {
215
216
  id,
216
217
  field,
217
- reason
218
+ reason,
219
+ key
218
220
  } = params;
219
221
  const startRowEditModeParams = {
220
222
  id,
221
223
  fieldToFocus: field
222
224
  };
223
225
 
224
- if (reason === _gridRowParams.GridRowEditStartReasons.deleteKeyDown || reason === _gridRowParams.GridRowEditStartReasons.printableKeyDown) {
226
+ if (reason === _gridRowParams.GridRowEditStartReasons.printableKeyDown) {
227
+ if (React.version.startsWith('18')) {
228
+ startRowEditModeParams.initialValue = key; // In React 17, cleaning the input is enough
229
+ } else {
230
+ startRowEditModeParams.deleteValue = !!field;
231
+ }
232
+ } else if (reason === _gridRowParams.GridRowEditStartReasons.deleteKeyDown) {
225
233
  startRowEditModeParams.deleteValue = !!field;
226
234
  }
227
235
 
@@ -360,7 +368,8 @@ const useGridRowEditing = (apiRef, props) => {
360
368
  const {
361
369
  id,
362
370
  fieldToFocus,
363
- deleteValue
371
+ deleteValue,
372
+ initialValue
364
373
  } = params;
365
374
  const columnFields = (0, _gridColumnsSelector.gridColumnFieldsSelector)(apiRef);
366
375
  const newProps = columnFields.reduce((acc, field) => {
@@ -370,9 +379,14 @@ const useGridRowEditing = (apiRef, props) => {
370
379
  return acc;
371
380
  }
372
381
 
373
- const shouldDeleteValue = deleteValue && fieldToFocus === field;
382
+ let newValue = apiRef.current.getCellValue(id, field);
383
+
384
+ if (fieldToFocus === field && (deleteValue || initialValue)) {
385
+ newValue = deleteValue ? '' : initialValue;
386
+ }
387
+
374
388
  acc[field] = {
375
- value: shouldDeleteValue ? '' : apiRef.current.getCellValue(id, field),
389
+ value: newValue,
376
390
  error: false,
377
391
  isProcessingProps: false
378
392
  };
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.17.6
1
+ /** @license MUI v5.17.7
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "5.17.6",
3
+ "version": "5.17.7",
4
4
  "description": "The community edition of the data grid component (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",