@mui/x-data-grid 6.18.2 → 6.18.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +101 -1
  2. package/components/GridRow.js +2 -4
  3. package/components/cell/GridCell.js +15 -15
  4. package/components/cell/GridEditDateCell.js +1 -20
  5. package/components/columnHeaders/GridColumnGroupHeader.js +2 -1
  6. package/components/columnHeaders/GridColumnHeaderItem.js +2 -1
  7. package/components/panel/filterPanel/GridFilterForm.js +2 -2
  8. package/components/panel/filterPanel/GridFilterInputValue.js +1 -1
  9. package/hooks/features/editing/useGridCellEditing.js +8 -21
  10. package/hooks/features/editing/useGridRowEditing.js +7 -21
  11. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -1
  12. package/hooks/features/rowSelection/useGridRowSelection.js +2 -1
  13. package/index.js +1 -1
  14. package/internals/index.d.ts +1 -1
  15. package/internals/index.js +1 -1
  16. package/legacy/components/GridRow.js +2 -4
  17. package/legacy/components/cell/GridCell.js +14 -14
  18. package/legacy/components/cell/GridEditDateCell.js +1 -20
  19. package/legacy/components/columnHeaders/GridColumnGroupHeader.js +2 -1
  20. package/legacy/components/columnHeaders/GridColumnHeaderItem.js +2 -1
  21. package/legacy/components/panel/filterPanel/GridFilterForm.js +2 -2
  22. package/legacy/components/panel/filterPanel/GridFilterInputValue.js +1 -1
  23. package/legacy/hooks/features/editing/useGridCellEditing.js +8 -21
  24. package/legacy/hooks/features/editing/useGridRowEditing.js +7 -23
  25. package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -1
  26. package/legacy/hooks/features/rowSelection/useGridRowSelection.js +2 -1
  27. package/legacy/index.js +1 -1
  28. package/legacy/internals/index.js +1 -1
  29. package/legacy/locales/bgBG.js +33 -37
  30. package/legacy/locales/daDK.js +37 -39
  31. package/legacy/models/params/gridEditCellParams.js +1 -0
  32. package/legacy/utils/domUtils.js +10 -1
  33. package/locales/bgBG.js +33 -37
  34. package/locales/daDK.js +37 -39
  35. package/models/api/gridEditingApi.d.ts +2 -4
  36. package/models/params/gridEditCellParams.d.ts +3 -1
  37. package/models/params/gridEditCellParams.js +1 -0
  38. package/models/params/gridRowParams.d.ts +1 -0
  39. package/modern/components/GridRow.js +2 -4
  40. package/modern/components/cell/GridCell.js +15 -15
  41. package/modern/components/cell/GridEditDateCell.js +1 -20
  42. package/modern/components/columnHeaders/GridColumnGroupHeader.js +2 -1
  43. package/modern/components/columnHeaders/GridColumnHeaderItem.js +2 -1
  44. package/modern/components/panel/filterPanel/GridFilterForm.js +2 -2
  45. package/modern/components/panel/filterPanel/GridFilterInputValue.js +1 -1
  46. package/modern/hooks/features/editing/useGridCellEditing.js +8 -21
  47. package/modern/hooks/features/editing/useGridRowEditing.js +7 -21
  48. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -1
  49. package/modern/hooks/features/rowSelection/useGridRowSelection.js +2 -1
  50. package/modern/index.js +1 -1
  51. package/modern/internals/index.js +1 -1
  52. package/modern/locales/bgBG.js +33 -37
  53. package/modern/locales/daDK.js +37 -39
  54. package/modern/models/params/gridEditCellParams.js +1 -0
  55. package/modern/utils/domUtils.js +10 -1
  56. package/node/components/GridRow.js +1 -3
  57. package/node/components/cell/GridCell.js +15 -15
  58. package/node/components/cell/GridEditDateCell.js +1 -20
  59. package/node/components/columnHeaders/GridColumnGroupHeader.js +2 -1
  60. package/node/components/columnHeaders/GridColumnHeaderItem.js +2 -1
  61. package/node/components/panel/filterPanel/GridFilterForm.js +2 -2
  62. package/node/components/panel/filterPanel/GridFilterInputValue.js +1 -1
  63. package/node/hooks/features/editing/useGridCellEditing.js +7 -20
  64. package/node/hooks/features/editing/useGridRowEditing.js +6 -20
  65. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -1
  66. package/node/hooks/features/rowSelection/useGridRowSelection.js +2 -1
  67. package/node/index.js +1 -1
  68. package/node/internals/index.js +7 -0
  69. package/node/locales/bgBG.js +33 -37
  70. package/node/locales/daDK.js +37 -39
  71. package/node/models/params/gridEditCellParams.js +1 -0
  72. package/node/utils/domUtils.js +11 -1
  73. package/package.json +1 -1
  74. package/utils/domUtils.d.ts +2 -0
  75. package/utils/domUtils.js +10 -1
package/locales/daDK.js CHANGED
@@ -47,47 +47,45 @@ const daDKGrid = {
47
47
  filterPanelInputLabel: 'Værdi',
48
48
  filterPanelInputPlaceholder: 'Filter værdi',
49
49
  // Filter operators text
50
- filterOperatorContains: 'Indeholder',
51
- filterOperatorEquals: 'Lig med',
52
- filterOperatorStartsWith: 'Begynder med',
53
- filterOperatorEndsWith: 'Ender med',
54
- filterOperatorIs: 'Er lig med',
55
- filterOperatorNot: 'Er ikke lig med',
56
- filterOperatorAfter: 'Efter',
57
- filterOperatorOnOrAfter: ' eller efter',
58
- filterOperatorBefore: 'Før',
59
- filterOperatorOnOrBefore: ' eller før',
60
- filterOperatorIsEmpty: 'Indeholder ikke data',
61
- filterOperatorIsNotEmpty: 'Indeholder data',
50
+ filterOperatorContains: 'indeholder',
51
+ filterOperatorEquals: 'lig med',
52
+ filterOperatorStartsWith: 'begynder med',
53
+ filterOperatorEndsWith: 'ender med',
54
+ filterOperatorIs: 'er lig med',
55
+ filterOperatorNot: 'er ikke lig med',
56
+ filterOperatorAfter: 'efter',
57
+ filterOperatorOnOrAfter: ' eller efter',
58
+ filterOperatorBefore: 'før',
59
+ filterOperatorOnOrBefore: ' eller før',
60
+ filterOperatorIsEmpty: 'indeholder ikke data',
61
+ filterOperatorIsNotEmpty: 'indeholder data',
62
62
  filterOperatorIsAnyOf: 'indeholder en af',
63
- // 'filterOperator=': '=',
64
- // 'filterOperator!=': '!=',
65
- // 'filterOperator>': '>',
66
- // 'filterOperator>=': '>=',
67
- // 'filterOperator<': '<',
68
- // 'filterOperator<=': '<=',
69
-
63
+ 'filterOperator=': '=',
64
+ 'filterOperator!=': '!=',
65
+ 'filterOperator>': '>',
66
+ 'filterOperator>=': '>=',
67
+ 'filterOperator<': '<',
68
+ 'filterOperator<=': '<=',
70
69
  // Header filter operators text
71
- // headerFilterOperatorContains: 'Contains',
72
- // headerFilterOperatorEquals: 'Equals',
73
- // headerFilterOperatorStartsWith: 'Starts with',
74
- // headerFilterOperatorEndsWith: 'Ends with',
75
- // headerFilterOperatorIs: 'Is',
76
- // headerFilterOperatorNot: 'Is not',
77
- // headerFilterOperatorAfter: 'Is after',
78
- // headerFilterOperatorOnOrAfter: 'Is on or after',
79
- // headerFilterOperatorBefore: 'Is before',
80
- // headerFilterOperatorOnOrBefore: 'Is on or before',
81
- // headerFilterOperatorIsEmpty: 'Is empty',
82
- // headerFilterOperatorIsNotEmpty: 'Is not empty',
83
- // headerFilterOperatorIsAnyOf: 'Is any of',
84
- // 'headerFilterOperator=': 'Equals',
85
- // 'headerFilterOperator!=': 'Not equals',
86
- // 'headerFilterOperator>': 'Greater than',
87
- // 'headerFilterOperator>=': 'Greater than or equal to',
88
- // 'headerFilterOperator<': 'Less than',
89
- // 'headerFilterOperator<=': 'Less than or equal to',
90
-
70
+ headerFilterOperatorContains: 'Indeholder',
71
+ headerFilterOperatorEquals: 'Lig med',
72
+ headerFilterOperatorStartsWith: 'Begynder med',
73
+ headerFilterOperatorEndsWith: 'Ender med',
74
+ headerFilterOperatorIs: 'Er lig med',
75
+ headerFilterOperatorNot: 'Er ikke lig med',
76
+ headerFilterOperatorAfter: 'Efter',
77
+ headerFilterOperatorOnOrAfter: ' eller efter',
78
+ headerFilterOperatorBefore: 'Før',
79
+ headerFilterOperatorOnOrBefore: ' eller før',
80
+ headerFilterOperatorIsEmpty: 'Indeholder ikke data',
81
+ headerFilterOperatorIsNotEmpty: 'Indeholder data',
82
+ headerFilterOperatorIsAnyOf: 'Indeholder en af',
83
+ 'headerFilterOperator=': 'Lig med',
84
+ 'headerFilterOperator!=': 'Ikke lig med',
85
+ 'headerFilterOperator>': 'Større end',
86
+ 'headerFilterOperator>=': 'Større end eller lig med',
87
+ 'headerFilterOperator<': 'Mindre end',
88
+ 'headerFilterOperator<=': 'Mindre end eller lig med',
91
89
  // Filter values text
92
90
  filterValueAny: 'hvilken som helst',
93
91
  filterValueTrue: 'positiv',
@@ -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
- // The target is not an element when triggered by a Select inside the cell
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
 
@@ -1,8 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["changeReason", "unstable_updateValueOnRender"],
4
- _excluded2 = ["align", "children", "editCellState", "colIndex", "column", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "isSelected", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "isNotVisible", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
5
- _excluded3 = ["column", "rowId", "editCellState", "align", "children", "colIndex", "height", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "isNotVisible", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
4
+ _excluded2 = ["align", "children", "editCellState", "colIndex", "column", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "isSelected", "rowId", "tabIndex", "style", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "isNotVisible", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
5
+ _excluded3 = ["column", "rowId", "editCellState", "align", "children", "colIndex", "height", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "isNotVisible", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver", "style"],
6
6
  _excluded4 = ["changeReason", "unstable_updateValueOnRender"];
7
7
  import * as React from 'react';
8
8
  import PropTypes from 'prop-types';
@@ -170,6 +170,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
170
170
  isSelected,
171
171
  rowId,
172
172
  tabIndex,
173
+ style: styleProp,
173
174
  value,
174
175
  width,
175
176
  className,
@@ -236,15 +237,14 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
236
237
  border: 0
237
238
  };
238
239
  }
239
- const cellStyle = {
240
+ const cellStyle = _extends({
240
241
  minWidth: width,
241
242
  maxWidth: width,
242
243
  minHeight: height,
243
- maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
244
- };
245
-
244
+ maxHeight: height === 'auto' ? 'none' : height
245
+ }, styleProp);
246
246
  return cellStyle;
247
- }, [width, height, isNotVisible]);
247
+ }, [width, height, isNotVisible, styleProp]);
248
248
  React.useEffect(() => {
249
249
  if (!hasFocus || cellMode === GridCellModes.Edit) {
250
250
  return;
@@ -406,7 +406,8 @@ const GridCellV7 = /*#__PURE__*/React.forwardRef((props, ref) => {
406
406
  onKeyDown,
407
407
  onKeyUp,
408
408
  onDragEnter,
409
- onDragOver
409
+ onDragOver,
410
+ style: styleProp
410
411
  } = props,
411
412
  other = _objectWithoutPropertiesLoose(props, _excluded3);
412
413
  const apiRef = useGridApiContext();
@@ -497,22 +498,21 @@ const GridCellV7 = /*#__PURE__*/React.forwardRef((props, ref) => {
497
498
  }, [apiRef, field, rowId]);
498
499
  const style = React.useMemo(() => {
499
500
  if (isNotVisible) {
500
- return {
501
+ return _extends({
501
502
  padding: 0,
502
503
  opacity: 0,
503
504
  width: 0,
504
505
  border: 0
505
- };
506
+ }, styleProp);
506
507
  }
507
- const cellStyle = {
508
+ const cellStyle = _extends({
508
509
  minWidth: width,
509
510
  maxWidth: width,
510
511
  minHeight: height,
511
- maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
512
- };
513
-
512
+ maxHeight: height === 'auto' ? 'none' : height
513
+ }, styleProp);
514
514
  return cellStyle;
515
- }, [width, height, isNotVisible]);
515
+ }, [width, height, isNotVisible, styleProp]);
516
516
  React.useEffect(() => {
517
517
  if (!hasFocus || cellMode === GridCellModes.Edit) {
518
518
  return;
@@ -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: handleInputRef,
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 (!event.currentTarget.contains(event.target)) {
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 (!event.currentTarget.contains(event.target)) {
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.printableKeyDown;
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
- React.useEffect(() => {
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
@@ -4,7 +4,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  const _excluded = ["id"],
5
5
  _excluded2 = ["id"];
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, GridRowModes } from '../../../models/gridEditRowModel';
10
10
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
@@ -171,7 +171,6 @@ export const useGridRowEditing = (apiRef, props) => {
171
171
  const rowParams = apiRef.current.getRowParams(params.id);
172
172
  const newParams = _extends({}, rowParams, {
173
173
  field: params.field,
174
- key: event.key,
175
174
  reason
176
175
  });
177
176
  apiRef.current.publishEvent('rowEditStart', newParams, event);
@@ -182,24 +181,13 @@ export const useGridRowEditing = (apiRef, props) => {
182
181
  const {
183
182
  id,
184
183
  field,
185
- reason,
186
- key,
187
- columns
184
+ reason
188
185
  } = params;
189
186
  const startRowEditModeParams = {
190
187
  id,
191
188
  fieldToFocus: field
192
189
  };
193
- if (reason === GridRowEditStartReasons.printableKeyDown) {
194
- if (React.version.startsWith('17')) {
195
- // In React 17, cleaning the input is enough.
196
- // The sequence of events makes the key pressed by the end-users update the textbox directly.
197
- startRowEditModeParams.deleteValue = !!field;
198
- } else {
199
- const colDef = columns.find(col => col.field === field);
200
- startRowEditModeParams.initialValue = colDef.valueParser ? colDef.valueParser(key) : key;
201
- }
202
- } else if (reason === GridRowEditStartReasons.deleteKeyDown) {
190
+ if (reason === GridRowEditStartReasons.printableKeyDown || reason === GridRowEditStartReasons.deleteKeyDown) {
203
191
  startRowEditModeParams.deleteValue = !!field;
204
192
  }
205
193
  apiRef.current.startRowEditMode(startRowEditModeParams);
@@ -322,17 +310,13 @@ export const useGridRowEditing = (apiRef, props) => {
322
310
  return acc;
323
311
  }
324
312
  let newValue = apiRef.current.getCellValue(id, field);
325
- // eslint-disable-next-line @typescript-eslint/naming-convention
326
- let unstable_updateValueOnRender = false;
327
313
  if (fieldToFocus === field && (deleteValue || initialValue)) {
328
314
  newValue = deleteValue ? '' : initialValue;
329
- unstable_updateValueOnRender = true;
330
315
  }
331
316
  acc[field] = {
332
317
  value: newValue,
333
318
  error: false,
334
- isProcessingProps: false,
335
- unstable_updateValueOnRender
319
+ isProcessingProps: false
336
320
  };
337
321
  return acc;
338
322
  }, {});
@@ -552,7 +536,9 @@ export const useGridRowEditing = (apiRef, props) => {
552
536
  updateRowModesModel(rowModesModelProp);
553
537
  }
554
538
  }, [rowModesModelProp, updateRowModesModel]);
555
- React.useEffect(() => {
539
+
540
+ // Run this effect synchronously so that the keyboard event can impact the yet-to-be-rendered input.
541
+ useEnhancedEffect(() => {
556
542
  const idToIdLookup = gridRowsDataRowIdToIdLookupSelector(apiRef);
557
543
 
558
544
  // Update the ref here because updateStateToStopRowEditMode may change it later
@@ -15,6 +15,7 @@ import { unstable_gridFocusColumnGroupHeaderSelector } from '../focus';
15
15
  import { gridColumnGroupsHeaderMaxDepthSelector } from '../columnGrouping/gridColumnGroupsSelector';
16
16
  import { unstable_gridHeaderFilteringEditFieldSelector, unstable_gridHeaderFilteringMenuSelector } from '../headerFiltering/gridHeaderFilteringSelectors';
17
17
  import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
18
+ import { isEventTargetInPortal } from '../../../utils/domUtils';
18
19
  function enrichPageRowsWithPinnedRows(apiRef, rows) {
19
20
  const pinnedRows = gridPinnedRowsSelector(apiRef) || {};
20
21
  return [...(pinnedRows.top || []), ...rows, ...(pinnedRows.bottom || [])];
@@ -413,7 +414,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
413
414
  }, [apiRef, currentPageRows.length, goToHeader, goToGroupHeader, goToCell, getRowIdFromIndex]);
414
415
  const handleCellKeyDown = React.useCallback((params, event) => {
415
416
  // Ignore portal
416
- if (!event.currentTarget.contains(event.target)) {
417
+ if (isEventTargetInPortal(event)) {
417
418
  return;
418
419
  }
419
420
 
@@ -14,6 +14,7 @@ import { isKeyboardEvent, isNavigationKey } from '../../../utils/keyboardUtils';
14
14
  import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
15
15
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPanelToggleField';
16
16
  import { gridClasses } from '../../../constants/gridClasses';
17
+ import { isEventTargetInPortal } from '../../../utils/domUtils';
17
18
  const getSelectionModelPropValue = (selectionModelProp, prevSelectionModel) => {
18
19
  if (selectionModelProp == null) {
19
20
  return selectionModelProp;
@@ -283,7 +284,7 @@ export const useGridRowSelection = (apiRef, props) => {
283
284
 
284
285
  // Ignore portal
285
286
  // Do not apply shortcuts if the focus is not on the cell root component
286
- if (!event.currentTarget.contains(event.target)) {
287
+ if (isEventTargetInPortal(event)) {
287
288
  return;
288
289
  }
289
290
  if (isNavigationKey(event.key) && event.shiftKey) {
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.18.2
2
+ * @mui/x-data-grid v6.18.4
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -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';
@@ -60,34 +60,32 @@ const bgBGGrid = {
60
60
  filterOperatorIsEmpty: 'е празен',
61
61
  filterOperatorIsNotEmpty: 'не е празен',
62
62
  filterOperatorIsAnyOf: 'е някой от',
63
- // 'filterOperator=': '=',
64
- // 'filterOperator!=': '!=',
65
- // 'filterOperator>': '>',
66
- // 'filterOperator>=': '>=',
67
- // 'filterOperator<': '<',
68
- // 'filterOperator<=': '<=',
69
-
63
+ 'filterOperator=': '=',
64
+ 'filterOperator!=': '!=',
65
+ 'filterOperator>': '>',
66
+ 'filterOperator>=': '>=',
67
+ 'filterOperator<': '<',
68
+ 'filterOperator<=': '<=',
70
69
  // Header filter operators text
71
- // headerFilterOperatorContains: 'Contains',
72
- // headerFilterOperatorEquals: 'Equals',
73
- // headerFilterOperatorStartsWith: 'Starts with',
74
- // headerFilterOperatorEndsWith: 'Ends with',
75
- // headerFilterOperatorIs: 'Is',
76
- // headerFilterOperatorNot: 'Is not',
77
- // headerFilterOperatorAfter: 'Is after',
78
- // headerFilterOperatorOnOrAfter: 'Is on or after',
79
- // headerFilterOperatorBefore: 'Is before',
80
- // headerFilterOperatorOnOrBefore: 'Is on or before',
81
- // headerFilterOperatorIsEmpty: 'Is empty',
82
- // headerFilterOperatorIsNotEmpty: 'Is not empty',
83
- // headerFilterOperatorIsAnyOf: 'Is any of',
84
- // 'headerFilterOperator=': 'Equals',
85
- // 'headerFilterOperator!=': 'Not equals',
86
- // 'headerFilterOperator>': 'Greater than',
87
- // 'headerFilterOperator>=': 'Greater than or equal to',
88
- // 'headerFilterOperator<': 'Less than',
89
- // 'headerFilterOperator<=': 'Less than or equal to',
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
- // detailPanelToggle: 'Detail panel toggle',
136
+ detailPanelToggle: 'Превключване на панела с детайли',
139
137
  expandDetailPanel: 'Разгъване',
140
138
  collapseDetailPanel: 'Свиване',
141
139
  // Row reordering text
142
- rowReorderingHeaderName: 'Подредба на редове'
143
-
140
+ rowReorderingHeaderName: 'Подредба на редове',
144
141
  // Aggregation
145
- // aggregationMenuItemHeader: 'Aggregation',
146
- // aggregationFunctionLabelSum: 'sum',
147
- // aggregationFunctionLabelAvg: 'avg',
148
- // aggregationFunctionLabelMin: 'min',
149
- // aggregationFunctionLabelMax: 'max',
150
- // aggregationFunctionLabelSize: 'size',
142
+ aggregationMenuItemHeader: 'Агрегиране',
143
+ aggregationFunctionLabelSum: 'сума',
144
+ aggregationFunctionLabelAvg: 'срст',
145
+ aggregationFunctionLabelMin: 'мин',
146
+ aggregationFunctionLabelMax: 'макс',
147
+ aggregationFunctionLabelSize: 'размер'
151
148
  };
152
-
153
149
  export const bgBG = getGridLocalization(bgBGGrid, bgBGCore);