@mui/x-data-grid 5.15.0 → 5.15.1

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 (58) hide show
  1. package/CHANGELOG.md +42 -1
  2. package/components/cell/GridEditInputCell.d.ts +2 -5
  3. package/components/cell/GridEditInputCell.js +13 -14
  4. package/components/cell/GridEditSingleSelectCell.d.ts +4 -0
  5. package/components/cell/GridEditSingleSelectCell.js +11 -4
  6. package/components/toolbar/GridToolbarDensitySelector.js +13 -4
  7. package/components/toolbar/GridToolbarExportContainer.js +13 -2
  8. package/constants/envConstants.d.ts +1 -1
  9. package/constants/envConstants.js +2 -11
  10. package/hooks/features/editRows/useGridCellEditing.new.js +5 -6
  11. package/hooks/features/editRows/useGridCellEditing.old.js +2 -2
  12. package/hooks/features/editRows/useGridRowEditing.new.js +5 -6
  13. package/index.js +1 -1
  14. package/legacy/components/cell/GridEditInputCell.js +13 -14
  15. package/legacy/components/cell/GridEditSingleSelectCell.js +11 -3
  16. package/legacy/components/toolbar/GridToolbarDensitySelector.js +14 -5
  17. package/legacy/components/toolbar/GridToolbarExportContainer.js +15 -2
  18. package/legacy/constants/envConstants.js +2 -11
  19. package/legacy/hooks/features/editRows/useGridCellEditing.new.js +5 -6
  20. package/legacy/hooks/features/editRows/useGridCellEditing.old.js +2 -2
  21. package/legacy/hooks/features/editRows/useGridRowEditing.new.js +5 -6
  22. package/legacy/index.js +1 -1
  23. package/legacy/locales/deDE.js +8 -8
  24. package/legacy/locales/itIT.js +15 -15
  25. package/legacy/locales/koKR.js +34 -30
  26. package/legacy/utils/keyboardUtils.js +8 -5
  27. package/locales/deDE.js +8 -8
  28. package/locales/itIT.js +15 -15
  29. package/locales/koKR.js +30 -30
  30. package/modern/components/cell/GridEditInputCell.js +13 -14
  31. package/modern/components/cell/GridEditSingleSelectCell.js +11 -4
  32. package/modern/components/toolbar/GridToolbarDensitySelector.js +11 -4
  33. package/modern/components/toolbar/GridToolbarExportContainer.js +11 -2
  34. package/modern/constants/envConstants.js +2 -11
  35. package/modern/hooks/features/editRows/useGridCellEditing.new.js +5 -6
  36. package/modern/hooks/features/editRows/useGridCellEditing.old.js +2 -2
  37. package/modern/hooks/features/editRows/useGridRowEditing.new.js +5 -6
  38. package/modern/index.js +1 -1
  39. package/modern/locales/deDE.js +8 -8
  40. package/modern/locales/itIT.js +15 -15
  41. package/modern/locales/koKR.js +30 -30
  42. package/modern/utils/keyboardUtils.js +7 -2
  43. package/node/components/cell/GridEditInputCell.js +15 -16
  44. package/node/components/cell/GridEditSingleSelectCell.js +10 -4
  45. package/node/components/toolbar/GridToolbarDensitySelector.js +13 -4
  46. package/node/components/toolbar/GridToolbarExportContainer.js +13 -2
  47. package/node/constants/envConstants.js +2 -13
  48. package/node/hooks/features/editRows/useGridCellEditing.new.js +5 -6
  49. package/node/hooks/features/editRows/useGridCellEditing.old.js +2 -2
  50. package/node/hooks/features/editRows/useGridRowEditing.new.js +5 -6
  51. package/node/index.js +1 -1
  52. package/node/locales/deDE.js +8 -8
  53. package/node/locales/itIT.js +15 -15
  54. package/node/locales/koKR.js +30 -30
  55. package/node/utils/keyboardUtils.js +10 -4
  56. package/package.json +1 -1
  57. package/utils/keyboardUtils.d.ts +2 -2
  58. package/utils/keyboardUtils.js +7 -2
@@ -57,11 +57,18 @@ export const GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function
57
57
  }, [densityValue, rootProps]);
58
58
 
59
59
  const handleDensitySelectorOpen = event => {
60
- setOpen(true);
60
+ setOpen(prevOpen => !prevOpen);
61
61
  onClick?.(event);
62
62
  };
63
63
 
64
- const handleDensitySelectorClose = () => setOpen(false);
64
+ const handleDensitySelectorClickAway = event => {
65
+ if (buttonRef.current === event.target || // if user clicked on the icon
66
+ buttonRef.current?.contains(event.target)) {
67
+ return;
68
+ }
69
+
70
+ setOpen(false);
71
+ };
65
72
 
66
73
  const handleDensityUpdate = newDensity => {
67
74
  apiRef.current.setDensity(newDensity);
@@ -74,7 +81,7 @@ export const GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function
74
81
  }
75
82
 
76
83
  if (isHideMenuKey(event.key)) {
77
- handleDensitySelectorClose();
84
+ setOpen(false);
78
85
  }
79
86
  }; // Disable the button if the corresponding is disabled
80
87
 
@@ -107,7 +114,7 @@ export const GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function
107
114
  })), /*#__PURE__*/_jsx(GridMenu, {
108
115
  open: open,
109
116
  target: buttonRef.current,
110
- onClickAway: handleDensitySelectorClose,
117
+ onClickAway: handleDensitySelectorClickAway,
111
118
  position: "bottom-start",
112
119
  children: /*#__PURE__*/_jsx(MenuList, {
113
120
  id: densityMenuId,
@@ -27,7 +27,7 @@ export const GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function
27
27
  const handleRef = useForkRef(ref, buttonRef);
28
28
 
29
29
  const handleMenuOpen = event => {
30
- setOpen(true);
30
+ setOpen(prevOpen => !prevOpen);
31
31
  onClick?.(event);
32
32
  };
33
33
 
@@ -43,6 +43,15 @@ export const GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function
43
43
  }
44
44
  };
45
45
 
46
+ const handleMenuClickAway = event => {
47
+ if (buttonRef.current === event.target || // if user clicked on the icon
48
+ buttonRef.current?.contains(event.target)) {
49
+ return;
50
+ }
51
+
52
+ setOpen(false);
53
+ };
54
+
46
55
  if (children == null) {
47
56
  return null;
48
57
  }
@@ -64,7 +73,7 @@ export const GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function
64
73
  })), /*#__PURE__*/_jsx(GridMenu, {
65
74
  open: open,
66
75
  target: buttonRef.current,
67
- onClickAway: handleMenuClose,
76
+ onClickAway: handleMenuClickAway,
68
77
  position: "bottom-start",
69
78
  children: /*#__PURE__*/_jsx(MenuList, {
70
79
  id: menuId,
@@ -1,4 +1,4 @@
1
- import { localStorageAvailable } from '../utils/utils'; // A guide to feature toggling.
1
+ // A guide to feature toggling (deprecated)
2
2
  //
3
3
  // The feature toggle is:
4
4
  // - independent from the NODE_ENV
@@ -15,13 +15,4 @@ import { localStorageAvailable } from '../utils/utils'; // A guide to feature to
15
15
  //
16
16
  // Developers (users) are discouraged to enable the experimental feature by setting the GRID_EXPERIMENTAL_ENABLED env.
17
17
  // Instead, prefer exposing experimental APIs, for instance, a prop or a new `unstable_` module.
18
-
19
- let experimentalEnabled = false;
20
-
21
- if (typeof process !== 'undefined' && process.env.GRID_EXPERIMENTAL_ENABLED !== undefined && localStorageAvailable() && window.localStorage.getItem('GRID_EXPERIMENTAL_ENABLED')) {
22
- experimentalEnabled = window.localStorage.getItem('GRID_EXPERIMENTAL_ENABLED') === 'true';
23
- } else if (typeof process !== 'undefined') {
24
- experimentalEnabled = process.env.GRID_EXPERIMENTAL_ENABLED === 'true';
25
- }
26
-
27
- export const GRID_EXPERIMENTAL_ENABLED = experimentalEnabled;
18
+ export const GRID_EXPERIMENTAL_ENABLED = false;
@@ -97,15 +97,14 @@ export const useGridCellEditing = (apiRef, props) => {
97
97
  } else if (params.isEditable) {
98
98
  let reason;
99
99
 
100
- if (isPrintableKey(event.key)) {
101
- if (event.ctrlKey && event.key !== 'v' || event.metaKey && event.key !== 'v' || event.altKey) {
102
- return;
103
- }
104
-
100
+ if (isPrintableKey(event)) {
101
+ reason = GridCellEditStartReasons.printableKeyDown;
102
+ } else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
105
103
  reason = GridCellEditStartReasons.printableKeyDown;
106
104
  } else if (event.key === 'Enter') {
107
105
  reason = GridCellEditStartReasons.enterKeyDown;
108
- } else if (event.key === 'Delete') {
106
+ } else if (event.key === 'Delete' || event.key === 'Backspace') {
107
+ // Delete on Windows, Backspace on macOS
109
108
  reason = GridCellEditStartReasons.deleteKeyDown;
110
109
  }
111
110
 
@@ -195,7 +195,7 @@ export const useCellEditing = (apiRef, props) => {
195
195
  const isEditMode = cellMode === GridCellModes.Edit;
196
196
  const isModifierKeyPressed = event.ctrlKey || event.metaKey || event.altKey;
197
197
 
198
- if (!isEditMode && isCellEnterEditModeKeys(event.key) && !isModifierKeyPressed && !(event.key === ' ' && event.shiftKey)) {
198
+ if (!isEditMode && isCellEnterEditModeKeys(event) && !isModifierKeyPressed && !(event.key === ' ' && event.shiftKey)) {
199
199
  apiRef.current.publishEvent('cellEditStart', params, event);
200
200
  }
201
201
 
@@ -265,7 +265,7 @@ export const useCellEditing = (apiRef, props) => {
265
265
 
266
266
  apiRef.current.setCellMode(params.id, params.field, GridCellModes.Edit);
267
267
 
268
- if (isKeyboardEvent(event) && isPrintableKey(event.key)) {
268
+ if (isKeyboardEvent(event) && isPrintableKey(event)) {
269
269
  apiRef.current.unstable_setEditCellProps({
270
270
  id: params.id,
271
271
  field: params.field,
@@ -151,15 +151,14 @@ export const useGridRowEditing = (apiRef, props) => {
151
151
  } else if (params.isEditable) {
152
152
  let reason;
153
153
 
154
- if (isPrintableKey(event.key)) {
155
- if (event.ctrlKey && event.key !== 'v' || event.metaKey && event.key !== 'v' || event.altKey) {
156
- return;
157
- }
158
-
154
+ if (isPrintableKey(event)) {
155
+ reason = GridRowEditStartReasons.printableKeyDown;
156
+ } else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
159
157
  reason = GridRowEditStartReasons.printableKeyDown;
160
158
  } else if (event.key === 'Enter') {
161
159
  reason = GridRowEditStartReasons.enterKeyDown;
162
- } else if (event.key === 'Delete') {
160
+ } else if (event.key === 'Delete' || event.key === 'Backspace') {
161
+ // Delete on Windows, Backspace on macOS
163
162
  reason = GridRowEditStartReasons.deleteKeyDown;
164
163
  }
165
164
 
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.15.0
1
+ /** @license MUI v5.15.1
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -111,13 +111,13 @@ const deDEGrid = {
111
111
  expandDetailPanel: 'Aufklappen',
112
112
  collapseDetailPanel: 'Zuklappen',
113
113
  // Row reordering text
114
- rowReorderingHeaderName: 'Reihen neu ordnen' // Aggregation
115
- // aggregationMenuItemHeader: 'Aggregation',
116
- // aggregationFunctionLabelSum: 'sum',
117
- // aggregationFunctionLabelAvg: 'avg',
118
- // aggregationFunctionLabelMin: 'min',
119
- // aggregationFunctionLabelMax: 'max',
120
- // aggregationFunctionLabelSize: 'size',
121
-
114
+ rowReorderingHeaderName: 'Reihen neu ordnen',
115
+ // Aggregation
116
+ aggregationMenuItemHeader: 'Aggregation',
117
+ aggregationFunctionLabelSum: 'Summe',
118
+ aggregationFunctionLabelAvg: 'Mittelwert',
119
+ aggregationFunctionLabelMin: 'Minimum',
120
+ aggregationFunctionLabelMax: 'Maximum',
121
+ aggregationFunctionLabelSize: 'Anzahl'
122
122
  };
123
123
  export const deDE = getGridLocalization(deDEGrid, deDECore);
@@ -21,15 +21,15 @@ const itITGrid = {
21
21
  toolbarFiltersTooltipShow: 'Mostra i filtri',
22
22
  toolbarFiltersTooltipActive: count => count > 1 ? `${count} filtri attivi` : `${count} filtro attivo`,
23
23
  // Quick filter toolbar field
24
- // toolbarQuickFilterPlaceholder: 'Search…',
25
- // toolbarQuickFilterLabel: 'Search',
26
- // toolbarQuickFilterDeleteIconLabel: 'Clear',
24
+ toolbarQuickFilterPlaceholder: 'Cerca…',
25
+ toolbarQuickFilterLabel: 'Cerca',
26
+ toolbarQuickFilterDeleteIconLabel: 'Resetta',
27
27
  // Export selector toolbar button text
28
28
  toolbarExport: 'Esporta',
29
29
  toolbarExportLabel: 'Esporta',
30
30
  toolbarExportCSV: 'Esporta in CSV',
31
31
  toolbarExportPrint: 'Stampa',
32
- // toolbarExportExcel: 'Download as Excel',
32
+ toolbarExportExcel: 'Scarica come Excel',
33
33
  // Columns panel text
34
34
  columnsPanelTextFieldLabel: 'Cerca colonna',
35
35
  columnsPanelTextFieldPlaceholder: 'Titolo della colonna',
@@ -39,7 +39,7 @@ const itITGrid = {
39
39
  // Filter panel text
40
40
  filterPanelAddFilter: 'Aggiungi un filtro',
41
41
  filterPanelDeleteIconLabel: 'Rimuovi',
42
- // filterPanelLinkOperator: 'Logic operator',
42
+ filterPanelLinkOperator: 'Operatore logico',
43
43
  filterPanelOperators: 'Operatori',
44
44
  // TODO v6: rename to filterPanelOperator
45
45
  filterPanelOperatorAnd: 'E (and)',
@@ -85,10 +85,10 @@ const itITGrid = {
85
85
  footerTotalVisibleRows: (visibleCount, totalCount) => `${visibleCount.toLocaleString()} di ${totalCount.toLocaleString()}`,
86
86
  // Checkbox selection text
87
87
  checkboxSelectionHeaderName: 'Seleziona',
88
- // checkboxSelectionSelectAllRows: 'Select all rows',
89
- // checkboxSelectionUnselectAllRows: 'Unselect all rows',
90
- // checkboxSelectionSelectRow: 'Select row',
91
- // checkboxSelectionUnselectRow: 'Unselect row',
88
+ checkboxSelectionSelectAllRows: 'Seleziona tutte le righe',
89
+ checkboxSelectionUnselectAllRows: 'Deseleziona tutte le righe',
90
+ checkboxSelectionSelectRow: 'Seleziona riga',
91
+ checkboxSelectionUnselectRow: 'Deseleziona riga',
92
92
  // Boolean cell text
93
93
  booleanCellTrueLabel: 'vero',
94
94
  booleanCellFalseLabel: 'falso',
@@ -105,13 +105,13 @@ const itITGrid = {
105
105
  // Grouping columns
106
106
  groupingColumnHeaderName: 'Gruppo',
107
107
  groupColumn: name => `Raggruppa per ${name}`,
108
- unGroupColumn: name => `Annulla raggruppamento per ${name}` // Master/detail
109
- // detailPanelToggle: 'Detail panel toggle',
110
- // expandDetailPanel: 'Expand',
111
- // collapseDetailPanel: 'Collapse',
108
+ unGroupColumn: name => `Annulla raggruppamento per ${name}`,
109
+ // Master/detail
110
+ detailPanelToggle: 'Abilita pannello dettagli',
111
+ expandDetailPanel: 'Espandi',
112
+ collapseDetailPanel: 'Comprimi',
112
113
  // Row reordering text
113
- // rowReorderingHeaderName: 'Row reordering',
114
- // Aggregation
114
+ rowReorderingHeaderName: 'Riordinamento righe' // Aggregation
115
115
  // aggregationMenuItemHeader: 'Aggregation',
116
116
  // aggregationFunctionLabelSum: 'sum',
117
117
  // aggregationFunctionLabelAvg: 'avg',
@@ -6,8 +6,8 @@ const koKRGrid = {
6
6
  noResultsOverlayLabel: '결과값이 없습니다.',
7
7
  errorOverlayDefaultLabel: '오류가 발생했습니다.',
8
8
  // Density selector toolbar button text
9
- toolbarDensity: '라인 간격',
10
- toolbarDensityLabel: '라인 간격',
9
+ toolbarDensity: ' 간격',
10
+ toolbarDensityLabel: ' 간격',
11
11
  toolbarDensityCompact: '좁게',
12
12
  toolbarDensityStandard: '기본',
13
13
  toolbarDensityComfortable: '넓게',
@@ -21,15 +21,15 @@ const koKRGrid = {
21
21
  toolbarFiltersTooltipShow: '필터 표시',
22
22
  toolbarFiltersTooltipActive: count => `${count}건의 필터를 적용중`,
23
23
  // Quick filter toolbar field
24
- // toolbarQuickFilterPlaceholder: 'Search…',
25
- // toolbarQuickFilterLabel: 'Search',
26
- // toolbarQuickFilterDeleteIconLabel: 'Clear',
24
+ toolbarQuickFilterPlaceholder: '검색…',
25
+ toolbarQuickFilterLabel: '검색',
26
+ toolbarQuickFilterDeleteIconLabel: '초기화',
27
27
  // Export selector toolbar button text
28
28
  toolbarExport: '내보내기',
29
29
  toolbarExportLabel: '내보내기',
30
- toolbarExportCSV: 'CSV다운로드',
30
+ toolbarExportCSV: 'CSV로 내보내기',
31
31
  toolbarExportPrint: '프린트',
32
- // toolbarExportExcel: 'Download as Excel',
32
+ toolbarExportExcel: 'Excel로 내보내기',
33
33
  // Columns panel text
34
34
  columnsPanelTextFieldLabel: '열 검색',
35
35
  columnsPanelTextFieldPlaceholder: '열 이름',
@@ -39,7 +39,7 @@ const koKRGrid = {
39
39
  // Filter panel text
40
40
  filterPanelAddFilter: '필터 추가',
41
41
  filterPanelDeleteIconLabel: '삭제',
42
- // filterPanelLinkOperator: 'Logic operator',
42
+ filterPanelLinkOperator: '논리 연산자',
43
43
  filterPanelOperators: '연산자',
44
44
  // TODO v6: rename to filterPanelOperator
45
45
  filterPanelOperatorAnd: '그리고',
@@ -85,39 +85,39 @@ const koKRGrid = {
85
85
  footerTotalVisibleRows: (visibleCount, totalCount) => `${visibleCount.toLocaleString()} / ${totalCount.toLocaleString()}`,
86
86
  // Checkbox selection text
87
87
  checkboxSelectionHeaderName: '선택',
88
- // checkboxSelectionSelectAllRows: 'Select all rows',
89
- // checkboxSelectionUnselectAllRows: 'Unselect all rows',
90
- // checkboxSelectionSelectRow: 'Select row',
91
- // checkboxSelectionUnselectRow: 'Unselect row',
88
+ checkboxSelectionSelectAllRows: '모든 선택',
89
+ checkboxSelectionUnselectAllRows: '모든 선택 해제',
90
+ checkboxSelectionSelectRow: ' 선택',
91
+ checkboxSelectionUnselectRow: ' 선택 해제',
92
92
  // Boolean cell text
93
93
  booleanCellTrueLabel: '참',
94
94
  booleanCellFalseLabel: '거짓',
95
95
  // Actions cell more text
96
96
  actionsCellMore: '더보기',
97
97
  // Column pinning text
98
- // pinToLeft: 'Pin to left',
99
- // pinToRight: 'Pin to right',
100
- // unpin: 'Unpin',
98
+ pinToLeft: '왼쪽에 고정',
99
+ pinToRight: '오른쪽에 고정',
100
+ unpin: '고정 해제',
101
101
  // Tree Data
102
102
  treeDataGroupingHeaderName: '그룹',
103
103
  treeDataExpand: '하위노드 펼치기',
104
- treeDataCollapse: '하위노드 접기' // Grouping columns
105
- // groupingColumnHeaderName: 'Group',
106
- // groupColumn: name => `Group by ${name}`,
107
- // unGroupColumn: name => `Stop grouping by ${name}`,
104
+ treeDataCollapse: '하위노드 접기',
105
+ // Grouping columns
106
+ groupingColumnHeaderName: '그룹',
107
+ groupColumn: name => `${name} 값으로 그룹 생성`,
108
+ unGroupColumn: name => `${name} 값으로 그룹 해제`,
108
109
  // Master/detail
109
- // detailPanelToggle: 'Detail panel toggle',
110
- // expandDetailPanel: 'Expand',
111
- // collapseDetailPanel: 'Collapse',
110
+ detailPanelToggle: '상세 패널 토글',
111
+ expandDetailPanel: '열기',
112
+ collapseDetailPanel: '접기',
112
113
  // Row reordering text
113
- // rowReorderingHeaderName: 'Row reordering',
114
+ rowReorderingHeaderName: ' 재배치',
114
115
  // Aggregation
115
- // aggregationMenuItemHeader: 'Aggregation',
116
- // aggregationFunctionLabelSum: 'sum',
117
- // aggregationFunctionLabelAvg: 'avg',
118
- // aggregationFunctionLabelMin: 'min',
119
- // aggregationFunctionLabelMax: 'max',
120
- // aggregationFunctionLabelSize: 'size',
121
-
116
+ aggregationMenuItemHeader: '총계',
117
+ aggregationFunctionLabelSum: '',
118
+ aggregationFunctionLabelAvg: '평균',
119
+ aggregationFunctionLabelMin: '최소값',
120
+ aggregationFunctionLabelMax: '최대값',
121
+ aggregationFunctionLabelSize: '크기'
122
122
  };
123
123
  export const koKR = getGridLocalization(koKRGrid, koKRCore);
@@ -10,13 +10,18 @@ export const isHomeOrEndKeys = key => key === 'Home' || key === 'End';
10
10
  export const isPageKeys = key => key.indexOf('Page') === 0;
11
11
  export const isDeleteKeys = key => key === 'Delete' || key === 'Backspace'; // Non printable keys have a name, e.g. "ArrowRight", see the whole list:
12
12
  // https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values
13
+ // We need to ignore shortcuts, for example: select all:
14
+ // - Windows: Ctrl+A, event.ctrlKey is true
15
+ // - macOS: ⌘ Command+A, event.metaKey is true
13
16
 
14
- export const isPrintableKey = key => key.length === 1;
17
+ export function isPrintableKey(event) {
18
+ return event.key.length === 1 && event.ctrlKey === false && event.metaKey === false;
19
+ }
15
20
  export const GRID_MULTIPLE_SELECTION_KEYS = ['Meta', 'Control', 'Shift'];
16
21
  export const GRID_CELL_EXIT_EDIT_MODE_KEYS = ['Enter', 'Escape', 'Tab'];
17
22
  export const GRID_CELL_EDIT_COMMIT_KEYS = ['Enter', 'Tab'];
18
23
  export const isMultipleKey = key => GRID_MULTIPLE_SELECTION_KEYS.indexOf(key) > -1;
19
- export const isCellEnterEditModeKeys = key => isEnterKey(key) || isDeleteKeys(key) || isPrintableKey(key);
24
+ export const isCellEnterEditModeKeys = event => isEnterKey(event.key) || isDeleteKeys(event.key) || isPrintableKey(event);
20
25
  export const isCellExitEditModeKeys = key => GRID_CELL_EXIT_EDIT_MODE_KEYS.indexOf(key) > -1;
21
26
  export const isCellEditCommitKeys = key => GRID_CELL_EDIT_COMMIT_KEYS.indexOf(key) > -1;
22
27
  export const isNavigationKey = key => isHomeOrEndKeys(key) || isArrowKeys(key) || isPageKeys(key) || isSpaceKey(key);
@@ -5,8 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.GridEditInputCell = GridEditInputCell;
9
- exports.renderEditInputCell = void 0;
8
+ exports.renderEditInputCell = exports.GridEditInputCell = void 0;
10
9
 
11
10
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
12
11
 
@@ -65,8 +64,7 @@ const GridEditInputCellRoot = (0, _styles.styled)(_InputBase.default, {
65
64
  height: '100%'
66
65
  }
67
66
  }));
68
-
69
- function GridEditInputCell(props) {
67
+ const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
70
68
  var _rootProps$experiment;
71
69
 
72
70
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
@@ -112,6 +110,7 @@ function GridEditInputCell(props) {
112
110
  }
113
111
  }, [hasFocus]);
114
112
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridEditInputCellRoot, (0, _extends2.default)({
113
+ ref: ref,
115
114
  inputRef: inputRef,
116
115
  className: classes.root,
117
116
  fullWidth: true,
@@ -120,8 +119,8 @@ function GridEditInputCell(props) {
120
119
  onChange: handleChange,
121
120
  endAdornment: isProcessingProps ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.GridLoadIcon, {}) : undefined
122
121
  }, other));
123
- }
124
-
122
+ });
123
+ exports.GridEditInputCell = GridEditInputCell;
125
124
  process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
126
125
  // ----------------------------- Warning --------------------------------
127
126
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -132,23 +131,23 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
132
131
  * GridApi that let you manipulate the grid.
133
132
  * @deprecated Use the `apiRef` returned by `useGridApiContext` or `useGridApiRef` (only available in `@mui/x-data-grid-pro`)
134
133
  */
135
- api: _propTypes.default.any.isRequired,
134
+ api: _propTypes.default.any,
136
135
 
137
136
  /**
138
137
  * The mode of the cell.
139
138
  */
140
- cellMode: _propTypes.default.oneOf(['edit', 'view']).isRequired,
139
+ cellMode: _propTypes.default.oneOf(['edit', 'view']),
141
140
 
142
141
  /**
143
142
  * The column of the row that the current cell belongs to.
144
143
  */
145
- colDef: _propTypes.default.object.isRequired,
144
+ colDef: _propTypes.default.object,
146
145
  debounceMs: _propTypes.default.number,
147
146
 
148
147
  /**
149
148
  * The column field of the cell that triggered the event.
150
149
  */
151
- field: _propTypes.default.string.isRequired,
150
+ field: _propTypes.default.string,
152
151
 
153
152
  /**
154
153
  * The cell value formatted with the column valueFormatter.
@@ -162,17 +161,17 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
162
161
  * @returns {any} The cell value.
163
162
  * @deprecated Use `params.row` to directly access the fields you want instead.
164
163
  */
165
- getValue: _propTypes.default.func.isRequired,
164
+ getValue: _propTypes.default.func,
166
165
 
167
166
  /**
168
167
  * If true, the cell is the active element.
169
168
  */
170
- hasFocus: _propTypes.default.bool.isRequired,
169
+ hasFocus: _propTypes.default.bool,
171
170
 
172
171
  /**
173
172
  * The grid row id.
174
173
  */
175
- id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
174
+ id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
176
175
 
177
176
  /**
178
177
  * If true, the cell is editable.
@@ -192,17 +191,17 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
192
191
  /**
193
192
  * The row model of the row that the current cell belongs to.
194
193
  */
195
- row: _propTypes.default.object.isRequired,
194
+ row: _propTypes.default.object,
196
195
 
197
196
  /**
198
197
  * The node of the row that the current cell belongs to.
199
198
  */
200
- rowNode: _propTypes.default.object.isRequired,
199
+ rowNode: _propTypes.default.object,
201
200
 
202
201
  /**
203
202
  * the tabIndex value.
204
203
  */
205
- tabIndex: _propTypes.default.oneOf([-1, 0]).isRequired,
204
+ tabIndex: _propTypes.default.oneOf([-1, 0]),
206
205
 
207
206
  /**
208
207
  * The cell value, but if the column has valueGetter, use getValue.
@@ -32,7 +32,7 @@ var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
32
32
 
33
33
  var _jsxRuntime = require("react/jsx-runtime");
34
34
 
35
- const _excluded = ["id", "value", "formattedValue", "api", "field", "row", "rowNode", "colDef", "cellMode", "isEditable", "tabIndex", "className", "getValue", "hasFocus", "isValidating", "isProcessingProps", "error", "onValueChange"];
35
+ const _excluded = ["id", "value", "formattedValue", "api", "field", "row", "rowNode", "colDef", "cellMode", "isEditable", "tabIndex", "className", "getValue", "hasFocus", "isValidating", "isProcessingProps", "error", "onValueChange", "initialOpen"];
36
36
 
37
37
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
38
38
 
@@ -52,6 +52,7 @@ const renderSingleSelectOptions = (option, OptionComponent) => {
52
52
  function GridEditSingleSelectCell(props) {
53
53
  var _rootProps$components, _baseSelectProps$nati, _rootProps$components2;
54
54
 
55
+ const rootProps = (0, _useGridRootProps.useGridRootProps)();
55
56
  const {
56
57
  id,
57
58
  value,
@@ -61,14 +62,14 @@ function GridEditSingleSelectCell(props) {
61
62
  colDef,
62
63
  hasFocus,
63
64
  error,
64
- onValueChange
65
+ onValueChange,
66
+ initialOpen = rootProps.editMode === _gridEditRowModel.GridEditModes.Cell
65
67
  } = props,
66
68
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
67
69
  const apiRef = (0, _useGridApiContext.useGridApiContext)();
68
70
  const ref = React.useRef();
69
71
  const inputRef = React.useRef();
70
- const rootProps = (0, _useGridRootProps.useGridRootProps)();
71
- const [open, setOpen] = React.useState(rootProps.editMode === 'cell');
72
+ const [open, setOpen] = React.useState(initialOpen);
72
73
  const baseSelectProps = ((_rootProps$components = rootProps.componentsProps) == null ? void 0 : _rootProps$components.baseSelect) || {};
73
74
  const isSelectNative = (_baseSelectProps$nati = baseSelectProps.native) != null ? _baseSelectProps$nati : false;
74
75
  let valueOptionsFormatted;
@@ -243,6 +244,11 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
243
244
  */
244
245
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
245
246
 
247
+ /**
248
+ * If true, the select opens by default.
249
+ */
250
+ initialOpen: _propTypes.default.bool,
251
+
246
252
  /**
247
253
  * If true, the cell is editable.
248
254
  */
@@ -87,11 +87,20 @@ const GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function GridTo
87
87
  }, [densityValue, rootProps]);
88
88
 
89
89
  const handleDensitySelectorOpen = event => {
90
- setOpen(true);
90
+ setOpen(prevOpen => !prevOpen);
91
91
  onClick == null ? void 0 : onClick(event);
92
92
  };
93
93
 
94
- const handleDensitySelectorClose = () => setOpen(false);
94
+ const handleDensitySelectorClickAway = event => {
95
+ var _buttonRef$current;
96
+
97
+ if (buttonRef.current === event.target || // if user clicked on the icon
98
+ (_buttonRef$current = buttonRef.current) != null && _buttonRef$current.contains(event.target)) {
99
+ return;
100
+ }
101
+
102
+ setOpen(false);
103
+ };
95
104
 
96
105
  const handleDensityUpdate = newDensity => {
97
106
  apiRef.current.setDensity(newDensity);
@@ -104,7 +113,7 @@ const GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function GridTo
104
113
  }
105
114
 
106
115
  if ((0, _keyboardUtils.isHideMenuKey)(event.key)) {
107
- handleDensitySelectorClose();
116
+ setOpen(false);
108
117
  }
109
118
  }; // Disable the button if the corresponding is disabled
110
119
 
@@ -137,7 +146,7 @@ const GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function GridTo
137
146
  })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridMenu.GridMenu, {
138
147
  open: open,
139
148
  target: buttonRef.current,
140
- onClickAway: handleDensitySelectorClose,
149
+ onClickAway: handleDensitySelectorClickAway,
141
150
  position: "bottom-start",
142
151
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_MenuList.default, {
143
152
  id: densityMenuId,
@@ -52,7 +52,7 @@ const GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function GridTo
52
52
  const handleRef = (0, _utils.useForkRef)(ref, buttonRef);
53
53
 
54
54
  const handleMenuOpen = event => {
55
- setOpen(true);
55
+ setOpen(prevOpen => !prevOpen);
56
56
  onClick == null ? void 0 : onClick(event);
57
57
  };
58
58
 
@@ -68,6 +68,17 @@ const GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function GridTo
68
68
  }
69
69
  };
70
70
 
71
+ const handleMenuClickAway = event => {
72
+ var _buttonRef$current;
73
+
74
+ if (buttonRef.current === event.target || // if user clicked on the icon
75
+ (_buttonRef$current = buttonRef.current) != null && _buttonRef$current.contains(event.target)) {
76
+ return;
77
+ }
78
+
79
+ setOpen(false);
80
+ };
81
+
71
82
  if (children == null) {
72
83
  return null;
73
84
  }
@@ -89,7 +100,7 @@ const GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function GridTo
89
100
  })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridMenu.GridMenu, {
90
101
  open: open,
91
102
  target: buttonRef.current,
92
- onClickAway: handleMenuClose,
103
+ onClickAway: handleMenuClickAway,
93
104
  position: "bottom-start",
94
105
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_MenuList.default, {
95
106
  id: menuId,
@@ -4,10 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.GRID_EXPERIMENTAL_ENABLED = void 0;
7
-
8
- var _utils = require("../utils/utils");
9
-
10
- // A guide to feature toggling.
7
+ // A guide to feature toggling (deprecated)
11
8
  //
12
9
  // The feature toggle is:
13
10
  // - independent from the NODE_ENV
@@ -24,13 +21,5 @@ var _utils = require("../utils/utils");
24
21
  //
25
22
  // Developers (users) are discouraged to enable the experimental feature by setting the GRID_EXPERIMENTAL_ENABLED env.
26
23
  // Instead, prefer exposing experimental APIs, for instance, a prop or a new `unstable_` module.
27
- let experimentalEnabled = false;
28
-
29
- if (typeof process !== 'undefined' && process.env.GRID_EXPERIMENTAL_ENABLED !== undefined && (0, _utils.localStorageAvailable)() && window.localStorage.getItem('GRID_EXPERIMENTAL_ENABLED')) {
30
- experimentalEnabled = window.localStorage.getItem('GRID_EXPERIMENTAL_ENABLED') === 'true';
31
- } else if (typeof process !== 'undefined') {
32
- experimentalEnabled = process.env.GRID_EXPERIMENTAL_ENABLED === 'true';
33
- }
34
-
35
- const GRID_EXPERIMENTAL_ENABLED = experimentalEnabled;
24
+ const GRID_EXPERIMENTAL_ENABLED = false;
36
25
  exports.GRID_EXPERIMENTAL_ENABLED = GRID_EXPERIMENTAL_ENABLED;