@mui/x-data-grid 6.18.2 → 6.18.3
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 +59 -0
- package/components/GridRow.js +2 -4
- package/components/cell/GridEditDateCell.js +1 -20
- package/components/columnHeaders/GridColumnGroupHeader.js +2 -1
- package/components/columnHeaders/GridColumnHeaderItem.js +2 -1
- package/components/panel/filterPanel/GridFilterForm.js +2 -2
- package/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/hooks/features/editing/useGridCellEditing.js +8 -21
- package/hooks/features/editing/useGridRowEditing.js +7 -21
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +2 -1
- package/index.js +1 -1
- package/internals/index.d.ts +1 -1
- package/internals/index.js +1 -1
- package/legacy/components/GridRow.js +2 -4
- package/legacy/components/cell/GridEditDateCell.js +1 -20
- package/legacy/components/columnHeaders/GridColumnGroupHeader.js +2 -1
- package/legacy/components/columnHeaders/GridColumnHeaderItem.js +2 -1
- package/legacy/components/panel/filterPanel/GridFilterForm.js +2 -2
- package/legacy/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/legacy/hooks/features/editing/useGridCellEditing.js +8 -21
- package/legacy/hooks/features/editing/useGridRowEditing.js +7 -23
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -1
- package/legacy/hooks/features/rowSelection/useGridRowSelection.js +2 -1
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +1 -1
- package/legacy/locales/bgBG.js +33 -37
- package/legacy/models/params/gridEditCellParams.js +1 -0
- package/legacy/utils/domUtils.js +10 -1
- package/locales/bgBG.js +33 -37
- package/models/api/gridEditingApi.d.ts +2 -4
- package/models/params/gridEditCellParams.d.ts +3 -1
- package/models/params/gridEditCellParams.js +1 -0
- package/models/params/gridRowParams.d.ts +1 -0
- package/modern/components/GridRow.js +2 -4
- package/modern/components/cell/GridEditDateCell.js +1 -20
- package/modern/components/columnHeaders/GridColumnGroupHeader.js +2 -1
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +2 -1
- package/modern/components/panel/filterPanel/GridFilterForm.js +2 -2
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/modern/hooks/features/editing/useGridCellEditing.js +8 -21
- package/modern/hooks/features/editing/useGridRowEditing.js +7 -21
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -1
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +2 -1
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -1
- package/modern/locales/bgBG.js +33 -37
- package/modern/models/params/gridEditCellParams.js +1 -0
- package/modern/utils/domUtils.js +10 -1
- package/node/components/GridRow.js +1 -3
- package/node/components/cell/GridEditDateCell.js +1 -20
- package/node/components/columnHeaders/GridColumnGroupHeader.js +2 -1
- package/node/components/columnHeaders/GridColumnHeaderItem.js +2 -1
- package/node/components/panel/filterPanel/GridFilterForm.js +2 -2
- package/node/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/node/hooks/features/editing/useGridCellEditing.js +7 -20
- package/node/hooks/features/editing/useGridRowEditing.js +6 -20
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -1
- package/node/hooks/features/rowSelection/useGridRowSelection.js +2 -1
- package/node/index.js +1 -1
- package/node/internals/index.js +7 -0
- package/node/locales/bgBG.js +33 -37
- package/node/models/params/gridEditCellParams.js +1 -0
- package/node/utils/domUtils.js +11 -1
- package/package.json +1 -1
- package/utils/domUtils.d.ts +2 -0
- package/utils/domUtils.js +10 -1
|
@@ -6,7 +6,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
6
6
|
var _excluded = ["id"],
|
|
7
7
|
_excluded2 = ["id"];
|
|
8
8
|
import * as React from 'react';
|
|
9
|
-
import { unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
9
|
+
import { unstable_useEventCallback as useEventCallback, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
10
10
|
import { useGridApiEventHandler, useGridApiOptionHandler } from '../../utils/useGridApiEventHandler';
|
|
11
11
|
import { GridEditModes, GridRowModes } from '../../../models/gridEditRowModel';
|
|
12
12
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
@@ -179,7 +179,6 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
179
179
|
var rowParams = apiRef.current.getRowParams(params.id);
|
|
180
180
|
var _newParams = _extends({}, rowParams, {
|
|
181
181
|
field: params.field,
|
|
182
|
-
key: event.key,
|
|
183
182
|
reason: _reason
|
|
184
183
|
});
|
|
185
184
|
apiRef.current.publishEvent('rowEditStart', _newParams, event);
|
|
@@ -189,25 +188,12 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
189
188
|
var handleRowEditStart = React.useCallback(function (params) {
|
|
190
189
|
var id = params.id,
|
|
191
190
|
field = params.field,
|
|
192
|
-
reason = params.reason
|
|
193
|
-
key = params.key,
|
|
194
|
-
columns = params.columns;
|
|
191
|
+
reason = params.reason;
|
|
195
192
|
var startRowEditModeParams = {
|
|
196
193
|
id: id,
|
|
197
194
|
fieldToFocus: field
|
|
198
195
|
};
|
|
199
|
-
if (reason === GridRowEditStartReasons.printableKeyDown) {
|
|
200
|
-
if (React.version.startsWith('17')) {
|
|
201
|
-
// In React 17, cleaning the input is enough.
|
|
202
|
-
// The sequence of events makes the key pressed by the end-users update the textbox directly.
|
|
203
|
-
startRowEditModeParams.deleteValue = !!field;
|
|
204
|
-
} else {
|
|
205
|
-
var colDef = columns.find(function (col) {
|
|
206
|
-
return col.field === field;
|
|
207
|
-
});
|
|
208
|
-
startRowEditModeParams.initialValue = colDef.valueParser ? colDef.valueParser(key) : key;
|
|
209
|
-
}
|
|
210
|
-
} else if (reason === GridRowEditStartReasons.deleteKeyDown) {
|
|
196
|
+
if (reason === GridRowEditStartReasons.printableKeyDown || reason === GridRowEditStartReasons.deleteKeyDown) {
|
|
211
197
|
startRowEditModeParams.deleteValue = !!field;
|
|
212
198
|
}
|
|
213
199
|
apiRef.current.startRowEditMode(startRowEditModeParams);
|
|
@@ -322,17 +308,13 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
322
308
|
return acc;
|
|
323
309
|
}
|
|
324
310
|
var newValue = apiRef.current.getCellValue(id, field);
|
|
325
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
326
|
-
var unstable_updateValueOnRender = false;
|
|
327
311
|
if (fieldToFocus === field && (deleteValue || initialValue)) {
|
|
328
312
|
newValue = deleteValue ? '' : initialValue;
|
|
329
|
-
unstable_updateValueOnRender = true;
|
|
330
313
|
}
|
|
331
314
|
acc[field] = {
|
|
332
315
|
value: newValue,
|
|
333
316
|
error: false,
|
|
334
|
-
isProcessingProps: false
|
|
335
|
-
unstable_updateValueOnRender: unstable_updateValueOnRender
|
|
317
|
+
isProcessingProps: false
|
|
336
318
|
};
|
|
337
319
|
return acc;
|
|
338
320
|
}, {});
|
|
@@ -559,7 +541,9 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
559
541
|
updateRowModesModel(rowModesModelProp);
|
|
560
542
|
}
|
|
561
543
|
}, [rowModesModelProp, updateRowModesModel]);
|
|
562
|
-
|
|
544
|
+
|
|
545
|
+
// Run this effect synchronously so that the keyboard event can impact the yet-to-be-rendered input.
|
|
546
|
+
useEnhancedEffect(function () {
|
|
563
547
|
var idToIdLookup = gridRowsDataRowIdToIdLookupSelector(apiRef);
|
|
564
548
|
|
|
565
549
|
// Update the ref here because updateStateToStopRowEditMode may change it later
|
|
@@ -16,6 +16,7 @@ import { unstable_gridFocusColumnGroupHeaderSelector } from '../focus';
|
|
|
16
16
|
import { gridColumnGroupsHeaderMaxDepthSelector } from '../columnGrouping/gridColumnGroupsSelector';
|
|
17
17
|
import { unstable_gridHeaderFilteringEditFieldSelector, unstable_gridHeaderFilteringMenuSelector } from '../headerFiltering/gridHeaderFilteringSelectors';
|
|
18
18
|
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
19
|
+
import { isEventTargetInPortal } from '../../../utils/domUtils';
|
|
19
20
|
function enrichPageRowsWithPinnedRows(apiRef, rows) {
|
|
20
21
|
var pinnedRows = gridPinnedRowsSelector(apiRef) || {};
|
|
21
22
|
return [].concat(_toConsumableArray(pinnedRows.top || []), _toConsumableArray(rows), _toConsumableArray(pinnedRows.bottom || []));
|
|
@@ -412,7 +413,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
412
413
|
}, [apiRef, currentPageRows.length, goToHeader, goToGroupHeader, goToCell, getRowIdFromIndex]);
|
|
413
414
|
var handleCellKeyDown = React.useCallback(function (params, event) {
|
|
414
415
|
// Ignore portal
|
|
415
|
-
if (
|
|
416
|
+
if (isEventTargetInPortal(event)) {
|
|
416
417
|
return;
|
|
417
418
|
}
|
|
418
419
|
|
|
@@ -15,6 +15,7 @@ import { isKeyboardEvent, isNavigationKey } from '../../../utils/keyboardUtils';
|
|
|
15
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
|
+
import { isEventTargetInPortal } from '../../../utils/domUtils';
|
|
18
19
|
var getSelectionModelPropValue = function getSelectionModelPropValue(selectionModelProp, prevSelectionModel) {
|
|
19
20
|
if (selectionModelProp == null) {
|
|
20
21
|
return selectionModelProp;
|
|
@@ -312,7 +313,7 @@ export var useGridRowSelection = function useGridRowSelection(apiRef, props) {
|
|
|
312
313
|
|
|
313
314
|
// Ignore portal
|
|
314
315
|
// Do not apply shortcuts if the focus is not on the cell root component
|
|
315
|
-
if (
|
|
316
|
+
if (isEventTargetInPortal(event)) {
|
|
316
317
|
return;
|
|
317
318
|
}
|
|
318
319
|
if (isNavigationKey(event.key) && event.shiftKey) {
|
package/legacy/index.js
CHANGED
|
@@ -54,7 +54,7 @@ export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
|
|
|
54
54
|
export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
|
|
55
55
|
export * from '../utils/createControllablePromise';
|
|
56
56
|
export { createSelector, createSelectorMemoized, unstable_resetCreateSelectorCache } from '../utils/createSelector';
|
|
57
|
-
export { findParentElementFromClassName, getActiveElement } from '../utils/domUtils';
|
|
57
|
+
export { findParentElementFromClassName, getActiveElement, isEventTargetInPortal } from '../utils/domUtils';
|
|
58
58
|
export { isNavigationKey } from '../utils/keyboardUtils';
|
|
59
59
|
export { clamp, isDeepEqual, isNumber, isFunction, isObject } from '../utils/utils';
|
|
60
60
|
export { buildWarning } from '../utils/warning';
|
package/legacy/locales/bgBG.js
CHANGED
|
@@ -62,34 +62,32 @@ var bgBGGrid = {
|
|
|
62
62
|
filterOperatorIsEmpty: 'е празен',
|
|
63
63
|
filterOperatorIsNotEmpty: 'не е празен',
|
|
64
64
|
filterOperatorIsAnyOf: 'е някой от',
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
'filterOperator=': '=',
|
|
66
|
+
'filterOperator!=': '!=',
|
|
67
|
+
'filterOperator>': '>',
|
|
68
|
+
'filterOperator>=': '>=',
|
|
69
|
+
'filterOperator<': '<',
|
|
70
|
+
'filterOperator<=': '<=',
|
|
72
71
|
// Header filter operators text
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
72
|
+
headerFilterOperatorContains: 'Съдържа',
|
|
73
|
+
headerFilterOperatorEquals: 'Равнo',
|
|
74
|
+
headerFilterOperatorStartsWith: 'Започва с',
|
|
75
|
+
headerFilterOperatorEndsWith: 'Завършва с',
|
|
76
|
+
headerFilterOperatorIs: 'Равно е на',
|
|
77
|
+
headerFilterOperatorNot: 'Не се равнява на',
|
|
78
|
+
headerFilterOperatorAfter: 'След',
|
|
79
|
+
headerFilterOperatorOnOrAfter: 'След (включително)',
|
|
80
|
+
headerFilterOperatorBefore: 'Преди',
|
|
81
|
+
headerFilterOperatorOnOrBefore: 'Преди (включително)',
|
|
82
|
+
headerFilterOperatorIsEmpty: 'Празен',
|
|
83
|
+
headerFilterOperatorIsNotEmpty: 'Не е празен',
|
|
84
|
+
headerFilterOperatorIsAnyOf: 'Всичко от',
|
|
85
|
+
'headerFilterOperator=': 'Равно',
|
|
86
|
+
'headerFilterOperator!=': 'Различно',
|
|
87
|
+
'headerFilterOperator>': 'По-голямо от',
|
|
88
|
+
'headerFilterOperator>=': 'По-голямо или равно на',
|
|
89
|
+
'headerFilterOperator<': 'По-малко от',
|
|
90
|
+
'headerFilterOperator<=': 'По-малко или равно на',
|
|
93
91
|
// Filter values text
|
|
94
92
|
filterValueAny: 'всякакви',
|
|
95
93
|
filterValueTrue: 'вярно',
|
|
@@ -147,19 +145,17 @@ var bgBGGrid = {
|
|
|
147
145
|
return "\u0421\u043F\u0440\u0438 \u0433\u0440\u0443\u043F\u0438\u0440\u0430\u043D\u0435 \u043F\u043E ".concat(name);
|
|
148
146
|
},
|
|
149
147
|
// Master/detail
|
|
150
|
-
|
|
148
|
+
detailPanelToggle: 'Превключване на панела с детайли',
|
|
151
149
|
expandDetailPanel: 'Разгъване',
|
|
152
150
|
collapseDetailPanel: 'Свиване',
|
|
153
151
|
// Row reordering text
|
|
154
|
-
rowReorderingHeaderName: 'Подредба на редове'
|
|
155
|
-
|
|
152
|
+
rowReorderingHeaderName: 'Подредба на редове',
|
|
156
153
|
// Aggregation
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
154
|
+
aggregationMenuItemHeader: 'Агрегиране',
|
|
155
|
+
aggregationFunctionLabelSum: 'сума',
|
|
156
|
+
aggregationFunctionLabelAvg: 'срст',
|
|
157
|
+
aggregationFunctionLabelMin: 'мин',
|
|
158
|
+
aggregationFunctionLabelMax: 'макс',
|
|
159
|
+
aggregationFunctionLabelSize: 'размер'
|
|
163
160
|
};
|
|
164
|
-
|
|
165
161
|
export var bgBG = getGridLocalization(bgBGGrid, bgBGCore);
|
|
@@ -6,6 +6,7 @@ var GridCellEditStartReasons = /*#__PURE__*/function (GridCellEditStartReasons)
|
|
|
6
6
|
GridCellEditStartReasons["cellDoubleClick"] = "cellDoubleClick";
|
|
7
7
|
GridCellEditStartReasons["printableKeyDown"] = "printableKeyDown";
|
|
8
8
|
GridCellEditStartReasons["deleteKeyDown"] = "deleteKeyDown";
|
|
9
|
+
GridCellEditStartReasons["pasteKeyDown"] = "pasteKeyDown";
|
|
9
10
|
return GridCellEditStartReasons;
|
|
10
11
|
}(GridCellEditStartReasons || {});
|
|
11
12
|
/**
|
package/legacy/utils/domUtils.js
CHANGED
|
@@ -51,4 +51,13 @@ export var getActiveElement = function getActiveElement() {
|
|
|
51
51
|
return getActiveElement(activeEl.shadowRoot);
|
|
52
52
|
}
|
|
53
53
|
return activeEl;
|
|
54
|
-
};
|
|
54
|
+
};
|
|
55
|
+
export function isEventTargetInPortal(event) {
|
|
56
|
+
if (
|
|
57
|
+
// The target is not an element when triggered by a Select inside the cell
|
|
58
|
+
// See https://github.com/mui/material-ui/issues/10534
|
|
59
|
+
event.target.nodeType === 1 && !event.currentTarget.contains(event.target)) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
package/locales/bgBG.js
CHANGED
|
@@ -60,34 +60,32 @@ const bgBGGrid = {
|
|
|
60
60
|
filterOperatorIsEmpty: 'е празен',
|
|
61
61
|
filterOperatorIsNotEmpty: 'не е празен',
|
|
62
62
|
filterOperatorIsAnyOf: 'е някой от',
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
'filterOperator=': '=',
|
|
64
|
+
'filterOperator!=': '!=',
|
|
65
|
+
'filterOperator>': '>',
|
|
66
|
+
'filterOperator>=': '>=',
|
|
67
|
+
'filterOperator<': '<',
|
|
68
|
+
'filterOperator<=': '<=',
|
|
70
69
|
// Header filter operators text
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
70
|
+
headerFilterOperatorContains: 'Съдържа',
|
|
71
|
+
headerFilterOperatorEquals: 'Равнo',
|
|
72
|
+
headerFilterOperatorStartsWith: 'Започва с',
|
|
73
|
+
headerFilterOperatorEndsWith: 'Завършва с',
|
|
74
|
+
headerFilterOperatorIs: 'Равно е на',
|
|
75
|
+
headerFilterOperatorNot: 'Не се равнява на',
|
|
76
|
+
headerFilterOperatorAfter: 'След',
|
|
77
|
+
headerFilterOperatorOnOrAfter: 'След (включително)',
|
|
78
|
+
headerFilterOperatorBefore: 'Преди',
|
|
79
|
+
headerFilterOperatorOnOrBefore: 'Преди (включително)',
|
|
80
|
+
headerFilterOperatorIsEmpty: 'Празен',
|
|
81
|
+
headerFilterOperatorIsNotEmpty: 'Не е празен',
|
|
82
|
+
headerFilterOperatorIsAnyOf: 'Всичко от',
|
|
83
|
+
'headerFilterOperator=': 'Равно',
|
|
84
|
+
'headerFilterOperator!=': 'Различно',
|
|
85
|
+
'headerFilterOperator>': 'По-голямо от',
|
|
86
|
+
'headerFilterOperator>=': 'По-голямо или равно на',
|
|
87
|
+
'headerFilterOperator<': 'По-малко от',
|
|
88
|
+
'headerFilterOperator<=': 'По-малко или равно на',
|
|
91
89
|
// Filter values text
|
|
92
90
|
filterValueAny: 'всякакви',
|
|
93
91
|
filterValueTrue: 'вярно',
|
|
@@ -135,19 +133,17 @@ const bgBGGrid = {
|
|
|
135
133
|
groupColumn: name => `Групирай по ${name}`,
|
|
136
134
|
unGroupColumn: name => `Спри групиране по ${name}`,
|
|
137
135
|
// Master/detail
|
|
138
|
-
|
|
136
|
+
detailPanelToggle: 'Превключване на панела с детайли',
|
|
139
137
|
expandDetailPanel: 'Разгъване',
|
|
140
138
|
collapseDetailPanel: 'Свиване',
|
|
141
139
|
// Row reordering text
|
|
142
|
-
rowReorderingHeaderName: 'Подредба на редове'
|
|
143
|
-
|
|
140
|
+
rowReorderingHeaderName: 'Подредба на редове',
|
|
144
141
|
// Aggregation
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
142
|
+
aggregationMenuItemHeader: 'Агрегиране',
|
|
143
|
+
aggregationFunctionLabelSum: 'сума',
|
|
144
|
+
aggregationFunctionLabelAvg: 'срст',
|
|
145
|
+
aggregationFunctionLabelMin: 'мин',
|
|
146
|
+
aggregationFunctionLabelMax: 'макс',
|
|
147
|
+
aggregationFunctionLabelSize: 'размер'
|
|
151
148
|
};
|
|
152
|
-
|
|
153
149
|
export const bgBG = getGridLocalization(bgBGGrid, bgBGCore);
|
|
@@ -18,10 +18,6 @@ export type GridRowModesModelProps = ({
|
|
|
18
18
|
export type GridRowModesModel = Record<GridRowId, GridRowModesModelProps>;
|
|
19
19
|
export interface GridEditCellMeta {
|
|
20
20
|
changeReason?: 'debouncedSetEditCellValue' | 'setEditCellValue';
|
|
21
|
-
/**
|
|
22
|
-
* Determines if `setEditCellValue` should be called on the first render to sync the value.
|
|
23
|
-
*/
|
|
24
|
-
unstable_updateValueOnRender?: boolean;
|
|
25
21
|
}
|
|
26
22
|
export interface GridEditingSharedApi {
|
|
27
23
|
/**
|
|
@@ -81,6 +77,7 @@ export interface GridStartCellEditModeParams {
|
|
|
81
77
|
/**
|
|
82
78
|
* The initial value for the field.
|
|
83
79
|
* If `deleteValue` is also true, this value is not used.
|
|
80
|
+
* @deprecated No longer needed.
|
|
84
81
|
*/
|
|
85
82
|
initialValue?: any;
|
|
86
83
|
}
|
|
@@ -126,6 +123,7 @@ export interface GridStartRowEditModeParams {
|
|
|
126
123
|
/**
|
|
127
124
|
* The initial value for the given `fieldToFocus`.
|
|
128
125
|
* If `deleteValue` is also true, this value is not used.
|
|
126
|
+
* @deprecated No longer needed.
|
|
129
127
|
*/
|
|
130
128
|
initialValue?: string;
|
|
131
129
|
}
|
|
@@ -29,7 +29,8 @@ declare enum GridCellEditStartReasons {
|
|
|
29
29
|
enterKeyDown = "enterKeyDown",
|
|
30
30
|
cellDoubleClick = "cellDoubleClick",
|
|
31
31
|
printableKeyDown = "printableKeyDown",
|
|
32
|
-
deleteKeyDown = "deleteKeyDown"
|
|
32
|
+
deleteKeyDown = "deleteKeyDown",
|
|
33
|
+
pasteKeyDown = "pasteKeyDown"
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
36
|
* Params passed to the `cellEditStart` event.
|
|
@@ -41,6 +42,7 @@ export interface GridCellEditStartParams<R extends GridValidRowModel = any, V =
|
|
|
41
42
|
reason?: GridCellEditStartReasons;
|
|
42
43
|
/**
|
|
43
44
|
* If the reason is related to a keyboard event, it contains which key was pressed.
|
|
45
|
+
* @deprecated No longer needed.
|
|
44
46
|
*/
|
|
45
47
|
key?: string;
|
|
46
48
|
}
|
|
@@ -6,6 +6,7 @@ var GridCellEditStartReasons = /*#__PURE__*/function (GridCellEditStartReasons)
|
|
|
6
6
|
GridCellEditStartReasons["cellDoubleClick"] = "cellDoubleClick";
|
|
7
7
|
GridCellEditStartReasons["printableKeyDown"] = "printableKeyDown";
|
|
8
8
|
GridCellEditStartReasons["deleteKeyDown"] = "deleteKeyDown";
|
|
9
|
+
GridCellEditStartReasons["pasteKeyDown"] = "pasteKeyDown";
|
|
9
10
|
return GridCellEditStartReasons;
|
|
10
11
|
}(GridCellEditStartReasons || {});
|
|
11
12
|
/**
|
|
@@ -74,6 +74,7 @@ export interface GridRowEditStartParams<R extends GridValidRowModel = any> exten
|
|
|
74
74
|
reason?: GridRowEditStartReasons;
|
|
75
75
|
/**
|
|
76
76
|
* If the reason is related to a keyboard event, it contains which key was pressed.
|
|
77
|
+
* @deprecated No longer needed.
|
|
77
78
|
*/
|
|
78
79
|
key?: string;
|
|
79
80
|
}
|
|
@@ -13,7 +13,7 @@ import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
|
13
13
|
import { gridColumnsTotalWidthSelector } from '../hooks/features/columns/gridColumnsSelector';
|
|
14
14
|
import { useGridSelector, objectShallowCompare } from '../hooks/utils/useGridSelector';
|
|
15
15
|
import { useGridVisibleRows } from '../hooks/utils/useGridVisibleRows';
|
|
16
|
-
import { findParentElementFromClassName } from '../utils/domUtils';
|
|
16
|
+
import { findParentElementFromClassName, isEventTargetInPortal } from '../utils/domUtils';
|
|
17
17
|
import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../colDef/gridCheckboxSelectionColDef';
|
|
18
18
|
import { GRID_ACTIONS_COLUMN_TYPE } from '../colDef/gridActionsColDef';
|
|
19
19
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../constants/gridDetailPanelToggleField';
|
|
@@ -137,9 +137,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
137
137
|
}, [apiRef, currentPage.range, index, rowHeight, rowId, position]);
|
|
138
138
|
const publish = React.useCallback((eventName, propHandler) => event => {
|
|
139
139
|
// Ignore portal
|
|
140
|
-
|
|
141
|
-
// See https://github.com/mui/material-ui/issues/10534
|
|
142
|
-
if (event.target.nodeType === 1 && !event.currentTarget.contains(event.target)) {
|
|
140
|
+
if (isEventTargetInPortal(event)) {
|
|
143
141
|
return;
|
|
144
142
|
}
|
|
145
143
|
|
|
@@ -63,7 +63,6 @@ function GridEditDateCell(props) {
|
|
|
63
63
|
classes: rootProps.classes
|
|
64
64
|
};
|
|
65
65
|
const classes = useUtilityClasses(ownerState);
|
|
66
|
-
const hasUpdatedEditValueOnMount = React.useRef(false);
|
|
67
66
|
const parseValueToDate = React.useCallback(value => {
|
|
68
67
|
if (value === '') {
|
|
69
68
|
return null;
|
|
@@ -108,26 +107,8 @@ function GridEditDateCell(props) {
|
|
|
108
107
|
inputRef.current.focus();
|
|
109
108
|
}
|
|
110
109
|
}, [hasFocus]);
|
|
111
|
-
const meta = apiRef.current.unstable_getEditCellMeta(id, field);
|
|
112
|
-
const handleInputRef = el => {
|
|
113
|
-
inputRef.current = el;
|
|
114
|
-
if (meta?.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
|
|
115
|
-
const inputValue = inputRef.current.value;
|
|
116
|
-
const parsedDate = parseValueToDate(inputValue);
|
|
117
|
-
setValueState({
|
|
118
|
-
parsed: parsedDate,
|
|
119
|
-
formatted: inputValue
|
|
120
|
-
});
|
|
121
|
-
apiRef.current.setEditCellValue({
|
|
122
|
-
id,
|
|
123
|
-
field,
|
|
124
|
-
value: parsedDate
|
|
125
|
-
});
|
|
126
|
-
hasUpdatedEditValueOnMount.current = true;
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
110
|
return /*#__PURE__*/_jsx(StyledInputBase, _extends({
|
|
130
|
-
inputRef:
|
|
111
|
+
inputRef: inputRef,
|
|
131
112
|
fullWidth: true,
|
|
132
113
|
className: classes.root,
|
|
133
114
|
type: isDateTime ? 'datetime-local' : 'date',
|
|
@@ -7,6 +7,7 @@ import { gridColumnGroupsLookupSelector } from '../../hooks/features/columnGroup
|
|
|
7
7
|
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
8
8
|
import { useGridSelector } from '../../hooks/utils/useGridSelector';
|
|
9
9
|
import { GridGenericColumnHeaderItem } from './GridGenericColumnHeaderItem';
|
|
10
|
+
import { isEventTargetInPortal } from '../../utils/domUtils';
|
|
10
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
12
|
const useUtilityClasses = ownerState => {
|
|
12
13
|
const {
|
|
@@ -84,7 +85,7 @@ function GridColumnGroupHeader(props) {
|
|
|
84
85
|
const publish = React.useCallback(eventName => event => {
|
|
85
86
|
// Ignore portal
|
|
86
87
|
// See https://github.com/mui/mui-x/issues/1721
|
|
87
|
-
if (
|
|
88
|
+
if (isEventTargetInPortal(event)) {
|
|
88
89
|
return;
|
|
89
90
|
}
|
|
90
91
|
apiRef.current.publishEvent(eventName, renderParams, event);
|
|
@@ -9,6 +9,7 @@ import { GridColumnHeaderMenu } from '../menu/columnMenu/GridColumnHeaderMenu';
|
|
|
9
9
|
import { getDataGridUtilityClass } from '../../constants/gridClasses';
|
|
10
10
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
11
11
|
import { GridGenericColumnHeaderItem } from './GridGenericColumnHeaderItem';
|
|
12
|
+
import { isEventTargetInPortal } from '../../utils/domUtils';
|
|
12
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
15
|
const useUtilityClasses = ownerState => {
|
|
@@ -67,7 +68,7 @@ function GridColumnHeaderItem(props) {
|
|
|
67
68
|
const publish = React.useCallback(eventName => event => {
|
|
68
69
|
// Ignore portal
|
|
69
70
|
// See https://github.com/mui/mui-x/issues/1721
|
|
70
|
-
if (
|
|
71
|
+
if (isEventTargetInPortal(event)) {
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
74
|
apiRef.current.publishEvent(eventName, apiRef.current.getColumnHeaderParams(colDef.field), event);
|
|
@@ -176,8 +176,8 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
176
176
|
// try to keep the same operator when column change
|
|
177
177
|
const newOperator = column.filterOperators.find(operator => operator.value === item.operator) || column.filterOperators[0];
|
|
178
178
|
|
|
179
|
-
// Erase filter value if the input component is modified
|
|
180
|
-
const eraseItemValue = !newOperator.InputComponent || newOperator.InputComponent !== currentOperator?.InputComponent;
|
|
179
|
+
// Erase filter value if the input component or filtered column type is modified
|
|
180
|
+
const eraseItemValue = !newOperator.InputComponent || newOperator.InputComponent !== currentOperator?.InputComponent || column.type !== currentColumn.type;
|
|
181
181
|
applyFilterChanges(_extends({}, item, {
|
|
182
182
|
field,
|
|
183
183
|
operator: newOperator.value,
|
|
@@ -42,7 +42,7 @@ function GridFilterInputValue(props) {
|
|
|
42
42
|
}, [id, applyValue, item, rootProps.filterDebounceMs, filterTimeout]);
|
|
43
43
|
React.useEffect(() => {
|
|
44
44
|
const itemPlusTag = item;
|
|
45
|
-
if (itemPlusTag.fromInput !== id) {
|
|
45
|
+
if (itemPlusTag.fromInput !== id || item.value === undefined) {
|
|
46
46
|
setFilterValueState(String(item.value ?? ''));
|
|
47
47
|
}
|
|
48
48
|
}, [id, item]);
|
|
@@ -4,7 +4,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
4
4
|
const _excluded = ["id", "field"],
|
|
5
5
|
_excluded2 = ["id", "field"];
|
|
6
6
|
import * as React from 'react';
|
|
7
|
-
import { unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
7
|
+
import { unstable_useEventCallback as useEventCallback, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
8
8
|
import { useGridApiEventHandler, useGridApiOptionHandler } from '../../utils/useGridApiEventHandler';
|
|
9
9
|
import { GridEditModes, GridCellModes } from '../../../models/gridEditRowModel';
|
|
10
10
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
@@ -101,7 +101,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
101
101
|
if (isPrintableKey(event)) {
|
|
102
102
|
reason = GridCellEditStartReasons.printableKeyDown;
|
|
103
103
|
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
|
|
104
|
-
reason = GridCellEditStartReasons.
|
|
104
|
+
reason = GridCellEditStartReasons.pasteKeyDown;
|
|
105
105
|
} else if (event.key === 'Enter') {
|
|
106
106
|
reason = GridCellEditStartReasons.enterKeyDown;
|
|
107
107
|
} else if (event.key === 'Delete' || event.key === 'Backspace') {
|
|
@@ -121,24 +121,13 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
121
121
|
const {
|
|
122
122
|
id,
|
|
123
123
|
field,
|
|
124
|
-
reason
|
|
125
|
-
key,
|
|
126
|
-
colDef
|
|
124
|
+
reason
|
|
127
125
|
} = params;
|
|
128
126
|
const startCellEditModeParams = {
|
|
129
127
|
id,
|
|
130
128
|
field
|
|
131
129
|
};
|
|
132
|
-
if (reason === GridCellEditStartReasons.printableKeyDown) {
|
|
133
|
-
if (React.version.startsWith('17')) {
|
|
134
|
-
// In React 17, cleaning the input is enough.
|
|
135
|
-
// The sequence of events makes the key pressed by the end-users update the textbox directly.
|
|
136
|
-
startCellEditModeParams.deleteValue = true;
|
|
137
|
-
} else {
|
|
138
|
-
const initialValue = colDef.valueParser ? colDef.valueParser(key) : key;
|
|
139
|
-
startCellEditModeParams.initialValue = initialValue;
|
|
140
|
-
}
|
|
141
|
-
} else if (reason === GridCellEditStartReasons.deleteKeyDown) {
|
|
130
|
+
if (reason === GridCellEditStartReasons.printableKeyDown || reason === GridCellEditStartReasons.deleteKeyDown || reason === GridCellEditStartReasons.pasteKeyDown) {
|
|
142
131
|
startCellEditModeParams.deleteValue = true;
|
|
143
132
|
}
|
|
144
133
|
apiRef.current.startCellEditMode(startCellEditModeParams);
|
|
@@ -248,17 +237,13 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
248
237
|
initialValue
|
|
249
238
|
} = params;
|
|
250
239
|
let newValue = apiRef.current.getCellValue(id, field);
|
|
251
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
252
|
-
let unstable_updateValueOnRender = false;
|
|
253
240
|
if (deleteValue || initialValue) {
|
|
254
241
|
newValue = deleteValue ? '' : initialValue;
|
|
255
|
-
unstable_updateValueOnRender = true;
|
|
256
242
|
}
|
|
257
243
|
const newProps = {
|
|
258
244
|
value: newValue,
|
|
259
245
|
error: false,
|
|
260
|
-
isProcessingProps: false
|
|
261
|
-
unstable_updateValueOnRender
|
|
246
|
+
isProcessingProps: false
|
|
262
247
|
};
|
|
263
248
|
updateOrDeleteFieldState(id, field, newProps);
|
|
264
249
|
apiRef.current.setCellFocus(id, field);
|
|
@@ -422,7 +407,9 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
422
407
|
updateCellModesModel(cellModesModelProp);
|
|
423
408
|
}
|
|
424
409
|
}, [cellModesModelProp, updateCellModesModel]);
|
|
425
|
-
|
|
410
|
+
|
|
411
|
+
// Run this effect synchronously so that the keyboard event can impact the yet-to-be-rendered input.
|
|
412
|
+
useEnhancedEffect(() => {
|
|
426
413
|
const idToIdLookup = gridRowsDataRowIdToIdLookupSelector(apiRef);
|
|
427
414
|
|
|
428
415
|
// Update the ref here because updateStateToStopCellEditMode may change it later
|