@mui/x-data-grid 5.17.5 → 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 +45 -0
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/hooks/features/editRows/useGridCellEditing.new.js +24 -5
- package/hooks/features/editRows/useGridRowEditing.new.js +23 -5
- package/index.js +1 -1
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +24 -5
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +23 -5
- package/legacy/index.js +1 -1
- package/models/api/gridEditingApi.d.ts +10 -0
- package/models/params/gridEditCellParams.d.ts +4 -0
- package/models/params/gridRowParams.d.ts +4 -0
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +24 -5
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +23 -5
- package/modern/index.js +1 -1
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/node/hooks/features/editRows/useGridCellEditing.new.js +24 -5
- package/node/hooks/features/editRows/useGridRowEditing.new.js +23 -5
- package/node/index.js +1 -1
- package/package.json +1 -1
- package/themeAugmentation/props.d.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,51 @@
|
|
|
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
|
+
|
|
21
|
+
## 5.17.6
|
|
22
|
+
|
|
23
|
+
_Oct 6, 2022_
|
|
24
|
+
|
|
25
|
+
We'd like to offer a big thanks to the 7 contributors who made this release possible. Here are some highlights ✨:
|
|
26
|
+
|
|
27
|
+
- 🌍 Add Japanese (ja-JP) locale to pickers (#6365) @sho918
|
|
28
|
+
- 🎁 Improve support for theme augmentation in the DataGrid (#6406) @cherniavskii
|
|
29
|
+
- 🐞 Bugfixes
|
|
30
|
+
|
|
31
|
+
### `@mui/x-data-grid@v5.17.6` / `@mui/x-data-grid-pro@v5.17.6` / `@mui/x-data-grid-premium@v5.17.6`
|
|
32
|
+
|
|
33
|
+
#### Changes
|
|
34
|
+
|
|
35
|
+
- [DataGrid] Add missing `valueOptions` (#6400) @DanailH
|
|
36
|
+
- [DataGrid] Don't start edit mode when pressing <kbd>Shift</kbd> + <kbd>Space</kbd> (#6380) @m4theushw
|
|
37
|
+
- [DataGrid] Pass generics to the components in the theme augmentation (#6406) @cherniavskii
|
|
38
|
+
|
|
39
|
+
### `@mui/x-date-pickers@v5.0.4` / `@mui/x-date-pickers-pro@v5.0.4`
|
|
40
|
+
|
|
41
|
+
#### Changes
|
|
42
|
+
|
|
43
|
+
- [l10n] Add Japanese (ja-JP) locale to pickers (#6365) (#6382) @sho918
|
|
44
|
+
- [pickers] Prevent `CalendarPicker` getting focus when `autoFocus=false` (#6304) (#6362) @alexfauquette
|
|
45
|
+
- [pickers] Fix git repository location @oliviertassinari
|
|
46
|
+
|
|
47
|
+
### Docs
|
|
48
|
+
|
|
49
|
+
- [docs] Fix customized day rendering demo style (#6342) @Ambrish-git
|
|
50
|
+
|
|
6
51
|
## 5.17.5
|
|
7
52
|
|
|
8
53
|
_Sep 29, 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
|
|
|
@@ -104,6 +104,10 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
104
104
|
} else if (params.isEditable) {
|
|
105
105
|
let reason;
|
|
106
106
|
|
|
107
|
+
if (event.key === ' ' && event.shiftKey) {
|
|
108
|
+
return; // Shift + Space is used to select the row
|
|
109
|
+
}
|
|
110
|
+
|
|
107
111
|
if (isPrintableKey(event)) {
|
|
108
112
|
reason = GridCellEditStartReasons.printableKeyDown;
|
|
109
113
|
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
|
|
@@ -117,7 +121,8 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
117
121
|
|
|
118
122
|
if (reason) {
|
|
119
123
|
const newParams = _extends({}, params, {
|
|
120
|
-
reason
|
|
124
|
+
reason,
|
|
125
|
+
key: event.key
|
|
121
126
|
});
|
|
122
127
|
|
|
123
128
|
apiRef.current.publishEvent('cellEditStart', newParams, event);
|
|
@@ -128,14 +133,21 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
128
133
|
const {
|
|
129
134
|
id,
|
|
130
135
|
field,
|
|
131
|
-
reason
|
|
136
|
+
reason,
|
|
137
|
+
key
|
|
132
138
|
} = params;
|
|
133
139
|
const startCellEditModeParams = {
|
|
134
140
|
id,
|
|
135
141
|
field
|
|
136
142
|
};
|
|
137
143
|
|
|
138
|
-
if (reason === GridCellEditStartReasons.
|
|
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) {
|
|
139
151
|
startCellEditModeParams.deleteValue = true;
|
|
140
152
|
}
|
|
141
153
|
|
|
@@ -266,10 +278,17 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
266
278
|
const {
|
|
267
279
|
id,
|
|
268
280
|
field,
|
|
269
|
-
deleteValue
|
|
281
|
+
deleteValue,
|
|
282
|
+
initialValue
|
|
270
283
|
} = params;
|
|
284
|
+
let newValue = apiRef.current.getCellValue(id, field);
|
|
285
|
+
|
|
286
|
+
if (deleteValue || initialValue) {
|
|
287
|
+
newValue = deleteValue ? '' : initialValue;
|
|
288
|
+
}
|
|
289
|
+
|
|
271
290
|
const newProps = {
|
|
272
|
-
value:
|
|
291
|
+
value: newValue,
|
|
273
292
|
error: false,
|
|
274
293
|
isProcessingProps: false
|
|
275
294
|
};
|
|
@@ -161,6 +161,10 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
161
161
|
} else if (params.isEditable) {
|
|
162
162
|
let reason;
|
|
163
163
|
|
|
164
|
+
if (event.key === ' ' && event.shiftKey) {
|
|
165
|
+
return; // Shift + Space is used to select the row
|
|
166
|
+
}
|
|
167
|
+
|
|
164
168
|
if (isPrintableKey(event)) {
|
|
165
169
|
reason = GridRowEditStartReasons.printableKeyDown;
|
|
166
170
|
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
|
|
@@ -177,6 +181,7 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
177
181
|
|
|
178
182
|
const newParams = _extends({}, rowParams, {
|
|
179
183
|
field: params.field,
|
|
184
|
+
key: event.key,
|
|
180
185
|
reason
|
|
181
186
|
});
|
|
182
187
|
|
|
@@ -188,14 +193,21 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
188
193
|
const {
|
|
189
194
|
id,
|
|
190
195
|
field,
|
|
191
|
-
reason
|
|
196
|
+
reason,
|
|
197
|
+
key
|
|
192
198
|
} = params;
|
|
193
199
|
const startRowEditModeParams = {
|
|
194
200
|
id,
|
|
195
201
|
fieldToFocus: field
|
|
196
202
|
};
|
|
197
203
|
|
|
198
|
-
if (reason === GridRowEditStartReasons.
|
|
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) {
|
|
199
211
|
startRowEditModeParams.deleteValue = !!field;
|
|
200
212
|
}
|
|
201
213
|
|
|
@@ -335,7 +347,8 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
335
347
|
const {
|
|
336
348
|
id,
|
|
337
349
|
fieldToFocus,
|
|
338
|
-
deleteValue
|
|
350
|
+
deleteValue,
|
|
351
|
+
initialValue
|
|
339
352
|
} = params;
|
|
340
353
|
const columnFields = gridColumnFieldsSelector(apiRef);
|
|
341
354
|
const newProps = columnFields.reduce((acc, field) => {
|
|
@@ -345,9 +358,14 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
345
358
|
return acc;
|
|
346
359
|
}
|
|
347
360
|
|
|
348
|
-
|
|
361
|
+
let newValue = apiRef.current.getCellValue(id, field);
|
|
362
|
+
|
|
363
|
+
if (fieldToFocus === field && (deleteValue || initialValue)) {
|
|
364
|
+
newValue = deleteValue ? '' : initialValue;
|
|
365
|
+
}
|
|
366
|
+
|
|
349
367
|
acc[field] = {
|
|
350
|
-
value:
|
|
368
|
+
value: newValue,
|
|
351
369
|
error: false,
|
|
352
370
|
isProcessingProps: false
|
|
353
371
|
};
|
package/index.js
CHANGED
|
@@ -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
|
|
|
@@ -112,6 +112,10 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
112
112
|
} else if (params.isEditable) {
|
|
113
113
|
var _reason;
|
|
114
114
|
|
|
115
|
+
if (event.key === ' ' && event.shiftKey) {
|
|
116
|
+
return; // Shift + Space is used to select the row
|
|
117
|
+
}
|
|
118
|
+
|
|
115
119
|
if (isPrintableKey(event)) {
|
|
116
120
|
_reason = GridCellEditStartReasons.printableKeyDown;
|
|
117
121
|
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
|
|
@@ -125,7 +129,8 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
125
129
|
|
|
126
130
|
if (_reason) {
|
|
127
131
|
var _newParams = _extends({}, params, {
|
|
128
|
-
reason: _reason
|
|
132
|
+
reason: _reason,
|
|
133
|
+
key: event.key
|
|
129
134
|
});
|
|
130
135
|
|
|
131
136
|
apiRef.current.publishEvent('cellEditStart', _newParams, event);
|
|
@@ -135,13 +140,20 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
135
140
|
var handleCellEditStart = React.useCallback(function (params) {
|
|
136
141
|
var id = params.id,
|
|
137
142
|
field = params.field,
|
|
138
|
-
reason = params.reason
|
|
143
|
+
reason = params.reason,
|
|
144
|
+
key = params.key;
|
|
139
145
|
var startCellEditModeParams = {
|
|
140
146
|
id: id,
|
|
141
147
|
field: field
|
|
142
148
|
};
|
|
143
149
|
|
|
144
|
-
if (reason === GridCellEditStartReasons.
|
|
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) {
|
|
145
157
|
startCellEditModeParams.deleteValue = true;
|
|
146
158
|
}
|
|
147
159
|
|
|
@@ -264,9 +276,16 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
264
276
|
var updateStateToStartCellEditMode = useEventCallback(function (params) {
|
|
265
277
|
var id = params.id,
|
|
266
278
|
field = params.field,
|
|
267
|
-
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
|
+
|
|
268
287
|
var newProps = {
|
|
269
|
-
value:
|
|
288
|
+
value: newValue,
|
|
270
289
|
error: false,
|
|
271
290
|
isProcessingProps: false
|
|
272
291
|
};
|
|
@@ -169,6 +169,10 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
169
169
|
} else if (params.isEditable) {
|
|
170
170
|
var _reason;
|
|
171
171
|
|
|
172
|
+
if (event.key === ' ' && event.shiftKey) {
|
|
173
|
+
return; // Shift + Space is used to select the row
|
|
174
|
+
}
|
|
175
|
+
|
|
172
176
|
if (isPrintableKey(event)) {
|
|
173
177
|
_reason = GridRowEditStartReasons.printableKeyDown;
|
|
174
178
|
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
|
|
@@ -185,6 +189,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
185
189
|
|
|
186
190
|
var _newParams = _extends({}, _rowParams, {
|
|
187
191
|
field: params.field,
|
|
192
|
+
key: event.key,
|
|
188
193
|
reason: _reason
|
|
189
194
|
});
|
|
190
195
|
|
|
@@ -195,13 +200,20 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
195
200
|
var handleRowEditStart = React.useCallback(function (params) {
|
|
196
201
|
var id = params.id,
|
|
197
202
|
field = params.field,
|
|
198
|
-
reason = params.reason
|
|
203
|
+
reason = params.reason,
|
|
204
|
+
key = params.key;
|
|
199
205
|
var startRowEditModeParams = {
|
|
200
206
|
id: id,
|
|
201
207
|
fieldToFocus: field
|
|
202
208
|
};
|
|
203
209
|
|
|
204
|
-
if (reason === GridRowEditStartReasons.
|
|
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) {
|
|
205
217
|
startRowEditModeParams.deleteValue = !!field;
|
|
206
218
|
}
|
|
207
219
|
|
|
@@ -334,7 +346,8 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
334
346
|
var updateStateToStartRowEditMode = useEventCallback(function (params) {
|
|
335
347
|
var id = params.id,
|
|
336
348
|
fieldToFocus = params.fieldToFocus,
|
|
337
|
-
deleteValue = params.deleteValue
|
|
349
|
+
deleteValue = params.deleteValue,
|
|
350
|
+
initialValue = params.initialValue;
|
|
338
351
|
var columnFields = gridColumnFieldsSelector(apiRef);
|
|
339
352
|
var newProps = columnFields.reduce(function (acc, field) {
|
|
340
353
|
var cellParams = apiRef.current.getCellParams(id, field);
|
|
@@ -343,9 +356,14 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
343
356
|
return acc;
|
|
344
357
|
}
|
|
345
358
|
|
|
346
|
-
var
|
|
359
|
+
var newValue = apiRef.current.getCellValue(id, field);
|
|
360
|
+
|
|
361
|
+
if (fieldToFocus === field && (deleteValue || initialValue)) {
|
|
362
|
+
newValue = deleteValue ? '' : initialValue;
|
|
363
|
+
}
|
|
364
|
+
|
|
347
365
|
acc[field] = {
|
|
348
|
-
value:
|
|
366
|
+
value: newValue,
|
|
349
367
|
error: false,
|
|
350
368
|
isProcessingProps: false
|
|
351
369
|
};
|
package/legacy/index.js
CHANGED
|
@@ -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
|
|
|
@@ -104,6 +104,10 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
104
104
|
} else if (params.isEditable) {
|
|
105
105
|
let reason;
|
|
106
106
|
|
|
107
|
+
if (event.key === ' ' && event.shiftKey) {
|
|
108
|
+
return; // Shift + Space is used to select the row
|
|
109
|
+
}
|
|
110
|
+
|
|
107
111
|
if (isPrintableKey(event)) {
|
|
108
112
|
reason = GridCellEditStartReasons.printableKeyDown;
|
|
109
113
|
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
|
|
@@ -117,7 +121,8 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
117
121
|
|
|
118
122
|
if (reason) {
|
|
119
123
|
const newParams = _extends({}, params, {
|
|
120
|
-
reason
|
|
124
|
+
reason,
|
|
125
|
+
key: event.key
|
|
121
126
|
});
|
|
122
127
|
|
|
123
128
|
apiRef.current.publishEvent('cellEditStart', newParams, event);
|
|
@@ -128,14 +133,21 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
128
133
|
const {
|
|
129
134
|
id,
|
|
130
135
|
field,
|
|
131
|
-
reason
|
|
136
|
+
reason,
|
|
137
|
+
key
|
|
132
138
|
} = params;
|
|
133
139
|
const startCellEditModeParams = {
|
|
134
140
|
id,
|
|
135
141
|
field
|
|
136
142
|
};
|
|
137
143
|
|
|
138
|
-
if (reason === GridCellEditStartReasons.
|
|
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) {
|
|
139
151
|
startCellEditModeParams.deleteValue = true;
|
|
140
152
|
}
|
|
141
153
|
|
|
@@ -266,10 +278,17 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
266
278
|
const {
|
|
267
279
|
id,
|
|
268
280
|
field,
|
|
269
|
-
deleteValue
|
|
281
|
+
deleteValue,
|
|
282
|
+
initialValue
|
|
270
283
|
} = params;
|
|
284
|
+
let newValue = apiRef.current.getCellValue(id, field);
|
|
285
|
+
|
|
286
|
+
if (deleteValue || initialValue) {
|
|
287
|
+
newValue = deleteValue ? '' : initialValue;
|
|
288
|
+
}
|
|
289
|
+
|
|
271
290
|
const newProps = {
|
|
272
|
-
value:
|
|
291
|
+
value: newValue,
|
|
273
292
|
error: false,
|
|
274
293
|
isProcessingProps: false
|
|
275
294
|
};
|
|
@@ -159,6 +159,10 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
159
159
|
} else if (params.isEditable) {
|
|
160
160
|
let reason;
|
|
161
161
|
|
|
162
|
+
if (event.key === ' ' && event.shiftKey) {
|
|
163
|
+
return; // Shift + Space is used to select the row
|
|
164
|
+
}
|
|
165
|
+
|
|
162
166
|
if (isPrintableKey(event)) {
|
|
163
167
|
reason = GridRowEditStartReasons.printableKeyDown;
|
|
164
168
|
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
|
|
@@ -175,6 +179,7 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
175
179
|
|
|
176
180
|
const newParams = _extends({}, rowParams, {
|
|
177
181
|
field: params.field,
|
|
182
|
+
key: event.key,
|
|
178
183
|
reason
|
|
179
184
|
});
|
|
180
185
|
|
|
@@ -186,14 +191,21 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
186
191
|
const {
|
|
187
192
|
id,
|
|
188
193
|
field,
|
|
189
|
-
reason
|
|
194
|
+
reason,
|
|
195
|
+
key
|
|
190
196
|
} = params;
|
|
191
197
|
const startRowEditModeParams = {
|
|
192
198
|
id,
|
|
193
199
|
fieldToFocus: field
|
|
194
200
|
};
|
|
195
201
|
|
|
196
|
-
if (reason === GridRowEditStartReasons.
|
|
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) {
|
|
197
209
|
startRowEditModeParams.deleteValue = !!field;
|
|
198
210
|
}
|
|
199
211
|
|
|
@@ -333,7 +345,8 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
333
345
|
const {
|
|
334
346
|
id,
|
|
335
347
|
fieldToFocus,
|
|
336
|
-
deleteValue
|
|
348
|
+
deleteValue,
|
|
349
|
+
initialValue
|
|
337
350
|
} = params;
|
|
338
351
|
const columnFields = gridColumnFieldsSelector(apiRef);
|
|
339
352
|
const newProps = columnFields.reduce((acc, field) => {
|
|
@@ -343,9 +356,14 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
343
356
|
return acc;
|
|
344
357
|
}
|
|
345
358
|
|
|
346
|
-
|
|
359
|
+
let newValue = apiRef.current.getCellValue(id, field);
|
|
360
|
+
|
|
361
|
+
if (fieldToFocus === field && (deleteValue || initialValue)) {
|
|
362
|
+
newValue = deleteValue ? '' : initialValue;
|
|
363
|
+
}
|
|
364
|
+
|
|
347
365
|
acc[field] = {
|
|
348
|
-
value:
|
|
366
|
+
value: newValue,
|
|
349
367
|
error: false,
|
|
350
368
|
isProcessingProps: false
|
|
351
369
|
};
|
package/modern/index.js
CHANGED
|
@@ -130,6 +130,10 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
130
130
|
} else if (params.isEditable) {
|
|
131
131
|
let reason;
|
|
132
132
|
|
|
133
|
+
if (event.key === ' ' && event.shiftKey) {
|
|
134
|
+
return; // Shift + Space is used to select the row
|
|
135
|
+
}
|
|
136
|
+
|
|
133
137
|
if ((0, _keyboardUtils.isPrintableKey)(event)) {
|
|
134
138
|
reason = _gridEditCellParams.GridCellEditStartReasons.printableKeyDown;
|
|
135
139
|
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
|
|
@@ -143,7 +147,8 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
143
147
|
|
|
144
148
|
if (reason) {
|
|
145
149
|
const newParams = (0, _extends2.default)({}, params, {
|
|
146
|
-
reason
|
|
150
|
+
reason,
|
|
151
|
+
key: event.key
|
|
147
152
|
});
|
|
148
153
|
apiRef.current.publishEvent('cellEditStart', newParams, event);
|
|
149
154
|
}
|
|
@@ -153,14 +158,21 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
153
158
|
const {
|
|
154
159
|
id,
|
|
155
160
|
field,
|
|
156
|
-
reason
|
|
161
|
+
reason,
|
|
162
|
+
key
|
|
157
163
|
} = params;
|
|
158
164
|
const startCellEditModeParams = {
|
|
159
165
|
id,
|
|
160
166
|
field
|
|
161
167
|
};
|
|
162
168
|
|
|
163
|
-
if (reason === _gridEditCellParams.GridCellEditStartReasons.
|
|
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) {
|
|
164
176
|
startCellEditModeParams.deleteValue = true;
|
|
165
177
|
}
|
|
166
178
|
|
|
@@ -289,10 +301,17 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
289
301
|
const {
|
|
290
302
|
id,
|
|
291
303
|
field,
|
|
292
|
-
deleteValue
|
|
304
|
+
deleteValue,
|
|
305
|
+
initialValue
|
|
293
306
|
} = params;
|
|
307
|
+
let newValue = apiRef.current.getCellValue(id, field);
|
|
308
|
+
|
|
309
|
+
if (deleteValue || initialValue) {
|
|
310
|
+
newValue = deleteValue ? '' : initialValue;
|
|
311
|
+
}
|
|
312
|
+
|
|
294
313
|
const newProps = {
|
|
295
|
-
value:
|
|
314
|
+
value: newValue,
|
|
296
315
|
error: false,
|
|
297
316
|
isProcessingProps: false
|
|
298
317
|
};
|
|
@@ -185,6 +185,10 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
185
185
|
} else if (params.isEditable) {
|
|
186
186
|
let reason;
|
|
187
187
|
|
|
188
|
+
if (event.key === ' ' && event.shiftKey) {
|
|
189
|
+
return; // Shift + Space is used to select the row
|
|
190
|
+
}
|
|
191
|
+
|
|
188
192
|
if ((0, _keyboardUtils.isPrintableKey)(event)) {
|
|
189
193
|
reason = _gridRowParams.GridRowEditStartReasons.printableKeyDown;
|
|
190
194
|
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
|
|
@@ -200,6 +204,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
200
204
|
const rowParams = apiRef.current.getRowParams(params.id);
|
|
201
205
|
const newParams = (0, _extends2.default)({}, rowParams, {
|
|
202
206
|
field: params.field,
|
|
207
|
+
key: event.key,
|
|
203
208
|
reason
|
|
204
209
|
});
|
|
205
210
|
apiRef.current.publishEvent('rowEditStart', newParams, event);
|
|
@@ -210,14 +215,21 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
210
215
|
const {
|
|
211
216
|
id,
|
|
212
217
|
field,
|
|
213
|
-
reason
|
|
218
|
+
reason,
|
|
219
|
+
key
|
|
214
220
|
} = params;
|
|
215
221
|
const startRowEditModeParams = {
|
|
216
222
|
id,
|
|
217
223
|
fieldToFocus: field
|
|
218
224
|
};
|
|
219
225
|
|
|
220
|
-
if (reason === _gridRowParams.GridRowEditStartReasons.
|
|
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) {
|
|
221
233
|
startRowEditModeParams.deleteValue = !!field;
|
|
222
234
|
}
|
|
223
235
|
|
|
@@ -356,7 +368,8 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
356
368
|
const {
|
|
357
369
|
id,
|
|
358
370
|
fieldToFocus,
|
|
359
|
-
deleteValue
|
|
371
|
+
deleteValue,
|
|
372
|
+
initialValue
|
|
360
373
|
} = params;
|
|
361
374
|
const columnFields = (0, _gridColumnsSelector.gridColumnFieldsSelector)(apiRef);
|
|
362
375
|
const newProps = columnFields.reduce((acc, field) => {
|
|
@@ -366,9 +379,14 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
366
379
|
return acc;
|
|
367
380
|
}
|
|
368
381
|
|
|
369
|
-
|
|
382
|
+
let newValue = apiRef.current.getCellValue(id, field);
|
|
383
|
+
|
|
384
|
+
if (fieldToFocus === field && (deleteValue || initialValue)) {
|
|
385
|
+
newValue = deleteValue ? '' : initialValue;
|
|
386
|
+
}
|
|
387
|
+
|
|
370
388
|
acc[field] = {
|
|
371
|
-
value:
|
|
389
|
+
value: newValue,
|
|
372
390
|
error: false,
|
|
373
391
|
isProcessingProps: false
|
|
374
392
|
};
|
package/node/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentsOverrides, ComponentsProps } from '@mui/material/styles';
|
|
1
|
+
import { ComponentsOverrides, ComponentsProps, Theme } from '@mui/material/styles';
|
|
2
2
|
import { DataGridProps } from '../models/props/DataGridProps';
|
|
3
3
|
export interface DataGridComponentsPropsList {
|
|
4
4
|
MuiDataGrid: DataGridProps;
|
|
@@ -6,7 +6,7 @@ export interface DataGridComponentsPropsList {
|
|
|
6
6
|
export interface DataGridComponents {
|
|
7
7
|
MuiDataGrid?: {
|
|
8
8
|
defaultProps?: ComponentsProps['MuiDataGrid'];
|
|
9
|
-
styleOverrides?: ComponentsOverrides['MuiDataGrid'];
|
|
9
|
+
styleOverrides?: ComponentsOverrides<Theme>['MuiDataGrid'];
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
declare module '@mui/material/styles' {
|