@mui/x-data-grid 6.0.3 → 6.1.0

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 (162) hide show
  1. package/CHANGELOG.md +119 -0
  2. package/components/GridAutoSizer.js +3 -0
  3. package/components/GridPagination.d.ts +6 -6
  4. package/components/GridRow.js +4 -2
  5. package/components/cell/GridActionsCellItem.d.ts +2 -2
  6. package/components/cell/GridEditDateCell.js +37 -16
  7. package/components/columnHeaders/ColumnHeaderMenuIcon.js +20 -16
  8. package/components/columnHeaders/GridColumnHeaderTitle.js +5 -5
  9. package/components/menu/columnMenu/GridColumnHeaderMenu.js +4 -2
  10. package/components/menu/columnMenu/GridColumnMenu.d.ts +5 -5
  11. package/components/menu/columnMenu/GridColumnMenu.js +30 -30
  12. package/components/menu/columnMenu/GridColumnMenuProps.d.ts +1 -1
  13. package/components/panel/GridColumnsPanel.d.ts +8 -0
  14. package/components/panel/GridColumnsPanel.js +18 -6
  15. package/components/panel/GridPanel.d.ts +1 -1
  16. package/components/panel/filterPanel/GridFilterPanel.js +1 -1
  17. package/components/reexportable.d.ts +1 -1
  18. package/components/reexportable.js +1 -1
  19. package/components/toolbar/GridToolbarColumnsButton.d.ts +1 -1
  20. package/components/toolbar/GridToolbarDensitySelector.d.ts +1 -1
  21. package/components/toolbar/GridToolbarExportContainer.d.ts +1 -1
  22. package/hooks/core/useGridApiInitialization.js +3 -3
  23. package/hooks/features/columnMenu/columnMenuInterfaces.d.ts +11 -11
  24. package/hooks/features/columnMenu/{useGridColumnMenuComponents.d.ts → useGridColumnMenuSlots.d.ts} +4 -4
  25. package/hooks/features/columnMenu/{useGridColumnMenuComponents.js → useGridColumnMenuSlots.js} +21 -26
  26. package/hooks/features/columns/gridColumnsSelector.d.ts +3 -3
  27. package/hooks/features/columns/useGridColumns.js +1 -1
  28. package/hooks/features/editing/useGridCellEditing.js +5 -1
  29. package/hooks/features/editing/useGridEditing.js +1 -3
  30. package/hooks/features/editing/useGridRowEditing.js +5 -1
  31. package/hooks/features/filter/gridFilterState.js +6 -1
  32. package/hooks/features/filter/useGridFilter.js +6 -1
  33. package/hooks/features/sorting/useGridSorting.js +1 -1
  34. package/hooks/features/virtualization/useGridVirtualScroller.js +1 -1
  35. package/index.d.ts +1 -1
  36. package/index.js +10 -2
  37. package/legacy/components/GridAutoSizer.js +3 -0
  38. package/legacy/components/GridRow.js +5 -2
  39. package/legacy/components/cell/GridEditBooleanCell.js +19 -21
  40. package/legacy/components/cell/GridEditDateCell.js +69 -39
  41. package/legacy/components/cell/GridEditInputCell.js +25 -27
  42. package/legacy/components/cell/GridEditSingleSelectCell.js +26 -28
  43. package/legacy/components/columnHeaders/ColumnHeaderMenuIcon.js +20 -16
  44. package/legacy/components/columnHeaders/GridColumnHeaderTitle.js +5 -5
  45. package/legacy/components/menu/columnMenu/GridColumnHeaderMenu.js +4 -2
  46. package/legacy/components/menu/columnMenu/GridColumnMenu.js +32 -32
  47. package/legacy/components/panel/GridColumnsPanel.js +19 -6
  48. package/legacy/components/panel/filterPanel/GridFilterPanel.js +1 -1
  49. package/legacy/components/reexportable.js +1 -1
  50. package/legacy/hooks/core/useGridApiInitialization.js +3 -3
  51. package/legacy/hooks/features/columnMenu/{useGridColumnMenuComponents.js → useGridColumnMenuSlots.js} +25 -30
  52. package/legacy/hooks/features/columns/gridColumnsUtils.js +2 -2
  53. package/legacy/hooks/features/columns/useGridColumns.js +1 -1
  54. package/legacy/hooks/features/editing/useGridCellEditing.js +120 -120
  55. package/legacy/hooks/features/editing/useGridEditing.js +17 -21
  56. package/legacy/hooks/features/editing/useGridRowEditing.js +5 -1
  57. package/legacy/hooks/features/export/useGridPrintExport.js +45 -47
  58. package/legacy/hooks/features/filter/gridFilterState.js +6 -1
  59. package/legacy/hooks/features/filter/useGridFilter.js +6 -1
  60. package/legacy/hooks/features/rows/gridRowsUtils.js +2 -2
  61. package/legacy/hooks/features/sorting/useGridSorting.js +1 -1
  62. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +7 -7
  63. package/legacy/index.js +10 -2
  64. package/legacy/locales/coreLocales.js +0 -1
  65. package/legacy/locales/daDK.js +16 -21
  66. package/legacy/locales/esES.js +1 -1
  67. package/legacy/locales/huHU.js +15 -20
  68. package/legacy/locales/jaJP.js +1 -1
  69. package/legacy/locales/nbNO.js +10 -12
  70. package/legacy/locales/nlNL.js +3 -3
  71. package/legacy/locales/ptBR.js +7 -9
  72. package/legacy/locales/ruRU.js +1 -1
  73. package/legacy/locales/svSE.js +2 -2
  74. package/legacy/models/gridColumnGrouping.js +4 -0
  75. package/legacy/models/params/gridRowParams.js +8 -0
  76. package/legacy/utils/createSelector.js +14 -22
  77. package/locales/coreLocales.js +0 -1
  78. package/locales/daDK.js +16 -21
  79. package/locales/esES.js +1 -1
  80. package/locales/huHU.js +15 -20
  81. package/locales/jaJP.js +1 -1
  82. package/locales/nbNO.js +10 -12
  83. package/locales/nlNL.js +3 -3
  84. package/locales/ptBR.js +7 -9
  85. package/locales/ruRU.js +1 -1
  86. package/locales/svSE.js +2 -2
  87. package/models/api/gridCoreApi.d.ts +3 -1
  88. package/models/api/gridEditingApi.d.ts +4 -0
  89. package/models/gridColumnGrouping.js +4 -0
  90. package/models/params/gridRowParams.js +8 -0
  91. package/modern/components/GridAutoSizer.js +3 -0
  92. package/modern/components/GridRow.js +4 -2
  93. package/modern/components/cell/GridEditDateCell.js +37 -16
  94. package/modern/components/columnHeaders/ColumnHeaderMenuIcon.js +19 -15
  95. package/modern/components/columnHeaders/GridColumnHeaderTitle.js +5 -5
  96. package/modern/components/menu/columnMenu/GridColumnHeaderMenu.js +4 -2
  97. package/modern/components/menu/columnMenu/GridColumnMenu.js +30 -30
  98. package/modern/components/panel/GridColumnsPanel.js +18 -6
  99. package/modern/components/panel/filterPanel/GridFilterPanel.js +1 -1
  100. package/modern/components/reexportable.js +1 -1
  101. package/modern/hooks/core/useGridApiInitialization.js +3 -3
  102. package/modern/hooks/features/columnMenu/{useGridColumnMenuComponents.js → useGridColumnMenuSlots.js} +21 -26
  103. package/modern/hooks/features/columns/useGridColumns.js +1 -1
  104. package/modern/hooks/features/editing/useGridCellEditing.js +5 -1
  105. package/modern/hooks/features/editing/useGridEditing.js +1 -3
  106. package/modern/hooks/features/editing/useGridRowEditing.js +5 -1
  107. package/modern/hooks/features/filter/gridFilterState.js +6 -1
  108. package/modern/hooks/features/filter/useGridFilter.js +6 -1
  109. package/modern/hooks/features/sorting/useGridSorting.js +1 -1
  110. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +1 -1
  111. package/modern/index.js +10 -2
  112. package/modern/locales/coreLocales.js +0 -1
  113. package/modern/locales/daDK.js +16 -21
  114. package/modern/locales/esES.js +1 -1
  115. package/modern/locales/huHU.js +15 -20
  116. package/modern/locales/jaJP.js +1 -1
  117. package/modern/locales/nbNO.js +10 -12
  118. package/modern/locales/nlNL.js +3 -3
  119. package/modern/locales/ptBR.js +7 -9
  120. package/modern/locales/ruRU.js +1 -1
  121. package/modern/locales/svSE.js +2 -2
  122. package/modern/models/gridColumnGrouping.js +4 -0
  123. package/modern/models/params/gridRowParams.js +8 -0
  124. package/modern/utils/createSelector.js +12 -22
  125. package/node/components/GridAutoSizer.js +3 -1
  126. package/node/components/GridRow.js +4 -2
  127. package/node/components/cell/GridCell.js +1 -0
  128. package/node/components/cell/GridEditDateCell.js +37 -16
  129. package/node/components/columnHeaders/ColumnHeaderMenuIcon.js +19 -15
  130. package/node/components/columnHeaders/GridColumnHeaderTitle.js +5 -5
  131. package/node/components/menu/columnMenu/GridColumnHeaderMenu.js +4 -2
  132. package/node/components/menu/columnMenu/GridColumnMenu.js +33 -33
  133. package/node/components/panel/GridColumnsPanel.js +18 -6
  134. package/node/components/panel/filterPanel/GridFilterPanel.js +1 -1
  135. package/node/components/reexportable.js +4 -4
  136. package/node/hooks/core/useGridApiInitialization.js +3 -3
  137. package/node/hooks/features/columnMenu/{useGridColumnMenuComponents.js → useGridColumnMenuSlots.js} +22 -27
  138. package/node/hooks/features/columns/useGridColumns.js +1 -1
  139. package/node/hooks/features/editing/useGridCellEditing.js +5 -1
  140. package/node/hooks/features/editing/useGridEditing.js +1 -3
  141. package/node/hooks/features/editing/useGridRowEditing.js +5 -1
  142. package/node/hooks/features/filter/gridFilterState.js +5 -0
  143. package/node/hooks/features/filter/useGridFilter.js +6 -1
  144. package/node/hooks/features/sorting/useGridSorting.js +1 -1
  145. package/node/hooks/features/virtualization/useGridVirtualScroller.js +1 -1
  146. package/node/index.js +7 -7
  147. package/node/locales/daDK.js +16 -21
  148. package/node/locales/esES.js +1 -1
  149. package/node/locales/huHU.js +15 -20
  150. package/node/locales/jaJP.js +1 -1
  151. package/node/locales/nbNO.js +10 -12
  152. package/node/locales/nlNL.js +3 -3
  153. package/node/locales/ptBR.js +7 -9
  154. package/node/locales/ruRU.js +1 -1
  155. package/node/locales/svSE.js +2 -2
  156. package/node/models/gridColumnGrouping.js +4 -0
  157. package/node/models/params/gridEditCellParams.js +1 -0
  158. package/node/models/params/gridRowParams.js +9 -0
  159. package/node/utils/createSelector.js +12 -22
  160. package/package.json +1 -1
  161. package/utils/createSelector.d.ts +4 -4
  162. package/utils/createSelector.js +14 -22
@@ -74,54 +74,66 @@ function GridEditDateCell(props) {
74
74
  classes: rootProps.classes
75
75
  };
76
76
  var classes = useUtilityClasses(ownerState);
77
+ var hasUpdatedEditValueOnMount = React.useRef(false);
78
+ var parseValueToDate = React.useCallback(function (value) {
79
+ if (value === '') {
80
+ return null;
81
+ }
82
+ var _value$split = value.split('T'),
83
+ _value$split2 = _slicedToArray(_value$split, 2),
84
+ date = _value$split2[0],
85
+ time = _value$split2[1];
86
+ var _date$split = date.split('-'),
87
+ _date$split2 = _slicedToArray(_date$split, 3),
88
+ year = _date$split2[0],
89
+ month = _date$split2[1],
90
+ day = _date$split2[2];
91
+ var parsedDate = new Date();
92
+ parsedDate.setFullYear(Number(year), Number(month) - 1, Number(day));
93
+ parsedDate.setHours(0, 0, 0, 0);
94
+ if (time) {
95
+ var _time$split = time.split(':'),
96
+ _time$split2 = _slicedToArray(_time$split, 2),
97
+ hours = _time$split2[0],
98
+ minutes = _time$split2[1];
99
+ parsedDate.setHours(Number(hours), Number(minutes), 0, 0);
100
+ }
101
+ return parsedDate;
102
+ }, []);
77
103
  var handleChange = React.useCallback( /*#__PURE__*/function () {
78
104
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event) {
79
- var newFormattedDate, newParsedDate, _newFormattedDate$spl, _newFormattedDate$spl2, date, time, _date$split, _date$split2, year, month, day, _time$split, _time$split2, hours, minutes;
105
+ var newFormattedDate, newParsedDate;
80
106
  return _regeneratorRuntime.wrap(function _callee$(_context) {
81
- while (1) {
82
- switch (_context.prev = _context.next) {
83
- case 0:
84
- newFormattedDate = event.target.value;
85
- if (newFormattedDate === '') {
86
- newParsedDate = null;
87
- } else {
88
- _newFormattedDate$spl = newFormattedDate.split('T'), _newFormattedDate$spl2 = _slicedToArray(_newFormattedDate$spl, 2), date = _newFormattedDate$spl2[0], time = _newFormattedDate$spl2[1];
89
- _date$split = date.split('-'), _date$split2 = _slicedToArray(_date$split, 3), year = _date$split2[0], month = _date$split2[1], day = _date$split2[2];
90
- newParsedDate = new Date();
91
- newParsedDate.setFullYear(Number(year), Number(month) - 1, Number(day));
92
- newParsedDate.setHours(0, 0, 0, 0);
93
- if (time) {
94
- _time$split = time.split(':'), _time$split2 = _slicedToArray(_time$split, 2), hours = _time$split2[0], minutes = _time$split2[1];
95
- newParsedDate.setHours(Number(hours), Number(minutes), 0, 0);
96
- }
97
- }
98
- if (!onValueChange) {
99
- _context.next = 5;
100
- break;
101
- }
107
+ while (1) switch (_context.prev = _context.next) {
108
+ case 0:
109
+ newFormattedDate = event.target.value;
110
+ newParsedDate = parseValueToDate(newFormattedDate);
111
+ if (!onValueChange) {
102
112
  _context.next = 5;
103
- return onValueChange(event, newParsedDate);
104
- case 5:
105
- setValueState({
106
- parsed: newParsedDate,
107
- formatted: newFormattedDate
108
- });
109
- apiRef.current.setEditCellValue({
110
- id: id,
111
- field: field,
112
- value: newParsedDate
113
- }, event);
114
- case 7:
115
- case "end":
116
- return _context.stop();
117
- }
113
+ break;
114
+ }
115
+ _context.next = 5;
116
+ return onValueChange(event, newParsedDate);
117
+ case 5:
118
+ setValueState({
119
+ parsed: newParsedDate,
120
+ formatted: newFormattedDate
121
+ });
122
+ apiRef.current.setEditCellValue({
123
+ id: id,
124
+ field: field,
125
+ value: newParsedDate
126
+ }, event);
127
+ case 7:
128
+ case "end":
129
+ return _context.stop();
118
130
  }
119
131
  }, _callee);
120
132
  }));
121
133
  return function (_x) {
122
134
  return _ref.apply(this, arguments);
123
135
  };
124
- }(), [apiRef, field, id, onValueChange]);
136
+ }(), [apiRef, field, id, onValueChange, parseValueToDate]);
125
137
  React.useEffect(function () {
126
138
  setValueState(function (state) {
127
139
  var _valueTransformed$par, _state$parsed;
@@ -136,8 +148,26 @@ function GridEditDateCell(props) {
136
148
  inputRef.current.focus();
137
149
  }
138
150
  }, [hasFocus]);
151
+ var meta = apiRef.current.unstable_getEditCellMeta(id, field);
152
+ var handleInputRef = function handleInputRef(el) {
153
+ inputRef.current = el;
154
+ if (meta.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
155
+ var inputValue = inputRef.current.value;
156
+ var parsedDate = parseValueToDate(inputValue);
157
+ setValueState({
158
+ parsed: parsedDate,
159
+ formatted: inputValue
160
+ });
161
+ apiRef.current.setEditCellValue({
162
+ id: id,
163
+ field: field,
164
+ value: parsedDate
165
+ });
166
+ hasUpdatedEditValueOnMount.current = true;
167
+ }
168
+ };
139
169
  return /*#__PURE__*/_jsx(StyledInputBase, _extends({
140
- inputRef: inputRef,
170
+ inputRef: handleInputRef,
141
171
  fullWidth: true,
142
172
  className: classes.root,
143
173
  type: isDateTime ? 'datetime-local' : 'date',
@@ -67,34 +67,32 @@ var GridEditInputCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
67
67
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event) {
68
68
  var newValue, column, parsedValue;
69
69
  return _regeneratorRuntime.wrap(function _callee$(_context) {
70
- while (1) {
71
- switch (_context.prev = _context.next) {
72
- case 0:
73
- newValue = event.target.value;
74
- if (!onValueChange) {
75
- _context.next = 4;
76
- break;
77
- }
70
+ while (1) switch (_context.prev = _context.next) {
71
+ case 0:
72
+ newValue = event.target.value;
73
+ if (!onValueChange) {
78
74
  _context.next = 4;
79
- return onValueChange(event, newValue);
80
- case 4:
81
- column = apiRef.current.getColumn(field);
82
- parsedValue = newValue;
83
- if (column.valueParser) {
84
- parsedValue = column.valueParser(newValue, apiRef.current.getCellParams(id, field));
85
- }
86
- setValueState(parsedValue);
87
- apiRef.current.setEditCellValue({
88
- id: id,
89
- field: field,
90
- value: parsedValue,
91
- debounceMs: debounceMs,
92
- unstable_skipValueParser: true
93
- }, event);
94
- case 9:
95
- case "end":
96
- return _context.stop();
97
- }
75
+ break;
76
+ }
77
+ _context.next = 4;
78
+ return onValueChange(event, newValue);
79
+ case 4:
80
+ column = apiRef.current.getColumn(field);
81
+ parsedValue = newValue;
82
+ if (column.valueParser) {
83
+ parsedValue = column.valueParser(newValue, apiRef.current.getCellParams(id, field));
84
+ }
85
+ setValueState(parsedValue);
86
+ apiRef.current.setEditCellValue({
87
+ id: id,
88
+ field: field,
89
+ value: parsedValue,
90
+ debounceMs: debounceMs,
91
+ unstable_skipValueParser: true
92
+ }, event);
93
+ case 9:
94
+ case "end":
95
+ return _context.stop();
98
96
  }
99
97
  }, _callee);
100
98
  }));
@@ -83,35 +83,33 @@ function GridEditSingleSelectCell(props) {
83
83
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event) {
84
84
  var target, formattedTargetValue;
85
85
  return _regeneratorRuntime.wrap(function _callee$(_context) {
86
- while (1) {
87
- switch (_context.prev = _context.next) {
88
- case 0:
89
- if (!(!isSingleSelectColDef(colDef) || !valueOptions)) {
90
- _context.next = 2;
91
- break;
92
- }
93
- return _context.abrupt("return");
94
- case 2:
95
- setOpen(false);
96
- target = event.target; // NativeSelect casts the value to a string.
97
- formattedTargetValue = getValueFromValueOptions(target.value, valueOptions, getOptionValue);
98
- if (!onValueChange) {
99
- _context.next = 8;
100
- break;
101
- }
86
+ while (1) switch (_context.prev = _context.next) {
87
+ case 0:
88
+ if (!(!isSingleSelectColDef(colDef) || !valueOptions)) {
89
+ _context.next = 2;
90
+ break;
91
+ }
92
+ return _context.abrupt("return");
93
+ case 2:
94
+ setOpen(false);
95
+ target = event.target; // NativeSelect casts the value to a string.
96
+ formattedTargetValue = getValueFromValueOptions(target.value, valueOptions, getOptionValue);
97
+ if (!onValueChange) {
102
98
  _context.next = 8;
103
- return onValueChange(event, formattedTargetValue);
104
- case 8:
105
- _context.next = 10;
106
- return apiRef.current.setEditCellValue({
107
- id: id,
108
- field: field,
109
- value: formattedTargetValue
110
- }, event);
111
- case 10:
112
- case "end":
113
- return _context.stop();
114
- }
99
+ break;
100
+ }
101
+ _context.next = 8;
102
+ return onValueChange(event, formattedTargetValue);
103
+ case 8:
104
+ _context.next = 10;
105
+ return apiRef.current.setEditCellValue({
106
+ id: id,
107
+ field: field,
108
+ value: formattedTargetValue
109
+ }, event);
110
+ case 10:
111
+ case "end":
112
+ return _context.stop();
115
113
  }
116
114
  }, _callee);
117
115
  }));
@@ -15,7 +15,7 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
15
15
  return composeClasses(slots, getDataGridUtilityClass, classes);
16
16
  };
17
17
  export var ColumnHeaderMenuIcon = /*#__PURE__*/React.memo(function (props) {
18
- var _rootProps$slotProps;
18
+ var _rootProps$slotProps, _rootProps$slotProps2;
19
19
  var colDef = props.colDef,
20
20
  open = props.open,
21
21
  columnMenuId = props.columnMenuId,
@@ -34,22 +34,26 @@ export var ColumnHeaderMenuIcon = /*#__PURE__*/React.memo(function (props) {
34
34
  }, [apiRef, colDef.field]);
35
35
  return /*#__PURE__*/_jsx("div", {
36
36
  className: classes.root,
37
- children: /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
38
- ref: iconButtonRef,
39
- tabIndex: -1,
40
- className: classes.button,
41
- "aria-label": apiRef.current.getLocaleText('columnMenuLabel'),
37
+ children: /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, _extends({
42
38
  title: apiRef.current.getLocaleText('columnMenuLabel'),
43
- size: "small",
44
- onClick: handleMenuIconClick,
45
- "aria-expanded": open ? 'true' : undefined,
46
- "aria-haspopup": "true",
47
- "aria-controls": columnMenuId,
48
- id: columnMenuButtonId
49
- }, (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.baseIconButton, {
50
- children: /*#__PURE__*/_jsx(rootProps.slots.columnMenuIcon, {
51
- fontSize: "small"
52
- })
39
+ enterDelay: 1000
40
+ }, (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.baseTooltip, {
41
+ children: /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
42
+ ref: iconButtonRef,
43
+ tabIndex: -1,
44
+ className: classes.button,
45
+ "aria-label": apiRef.current.getLocaleText('columnMenuLabel'),
46
+ size: "small",
47
+ onClick: handleMenuIconClick,
48
+ "aria-expanded": open ? 'true' : undefined,
49
+ "aria-haspopup": "true",
50
+ "aria-controls": columnMenuId,
51
+ id: columnMenuButtonId
52
+ }, (_rootProps$slotProps2 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps2.baseIconButton, {
53
+ children: /*#__PURE__*/_jsx(rootProps.slots.columnMenuIcon, {
54
+ fontSize: "small"
55
+ })
56
+ }))
53
57
  }))
54
58
  });
55
59
  });
@@ -45,16 +45,15 @@ var ColumnHeaderInnerTitle = /*#__PURE__*/React.forwardRef(function ColumnHeader
45
45
  function GridColumnHeaderTitle(props) {
46
46
  var _rootProps$slotProps;
47
47
  var label = props.label,
48
- description = props.description,
49
- columnWidth = props.columnWidth;
48
+ description = props.description;
50
49
  var rootProps = useGridRootProps();
51
50
  var titleRef = React.useRef(null);
52
51
  var _React$useState = React.useState(''),
53
52
  _React$useState2 = _slicedToArray(_React$useState, 2),
54
53
  tooltip = _React$useState2[0],
55
54
  setTooltip = _React$useState2[1];
56
- React.useEffect(function () {
57
- if (!description && titleRef && titleRef.current) {
55
+ var handleMouseOver = React.useCallback(function () {
56
+ if (!description && titleRef != null && titleRef.current) {
58
57
  var isOver = isOverflown(titleRef.current);
59
58
  if (isOver) {
60
59
  setTooltip(label);
@@ -62,11 +61,12 @@ function GridColumnHeaderTitle(props) {
62
61
  setTooltip('');
63
62
  }
64
63
  }
65
- }, [titleRef, columnWidth, description, label]);
64
+ }, [description, label]);
66
65
  return /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, _extends({
67
66
  title: description || tooltip
68
67
  }, (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.baseTooltip, {
69
68
  children: /*#__PURE__*/_jsx(ColumnHeaderInnerTitle, {
69
+ onMouseOver: handleMouseOver,
70
70
  ref: titleRef,
71
71
  children: label
72
72
  })
@@ -19,8 +19,10 @@ function GridColumnHeaderMenu(_ref) {
19
19
  var hideMenu = React.useCallback(function (event) {
20
20
  // Prevent triggering the sorting
21
21
  event.stopPropagation();
22
- apiRef.current.hideColumnMenu();
23
- }, [apiRef]);
22
+ if (!(target != null && target.contains(event.target))) {
23
+ apiRef.current.hideColumnMenu();
24
+ }
25
+ }, [apiRef, target]);
24
26
  if (!target) {
25
27
  return null;
26
28
  }
@@ -1,21 +1,21 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- var _excluded = ["defaultComponents", "defaultComponentsProps", "components", "componentsProps"];
4
+ var _excluded = ["defaultSlots", "defaultSlotProps", "slots", "slotProps"];
5
5
  import * as React from 'react';
6
6
  import PropTypes from 'prop-types';
7
- import { useGridColumnMenuComponents } from '../../../hooks/features/columnMenu/useGridColumnMenuComponents';
7
+ import { useGridColumnMenuSlots } from '../../../hooks/features/columnMenu/useGridColumnMenuSlots';
8
8
  import { GridColumnMenuContainer } from './GridColumnMenuContainer';
9
9
  import { GridColumnMenuColumnsItem } from './menuItems/GridColumnMenuColumnsItem';
10
10
  import { GridColumnMenuFilterItem } from './menuItems/GridColumnMenuFilterItem';
11
11
  import { GridColumnMenuSortItem } from './menuItems/GridColumnMenuSortItem';
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
- export var GRID_COLUMN_MENU_COMPONENTS = {
14
- ColumnMenuSortItem: GridColumnMenuSortItem,
15
- ColumnMenuFilterItem: GridColumnMenuFilterItem,
16
- ColumnMenuColumnsItem: GridColumnMenuColumnsItem
13
+ export var GRID_COLUMN_MENU_SLOTS = {
14
+ columnMenuSortItem: GridColumnMenuSortItem,
15
+ columnMenuFilterItem: GridColumnMenuFilterItem,
16
+ columnMenuColumnsItem: GridColumnMenuColumnsItem
17
17
  };
18
- export var GRID_COLUMN_MENU_COMPONENTS_PROPS = {
18
+ export var GRID_COLUMN_MENU_SLOT_PROPS = {
19
19
  columnMenuSortItem: {
20
20
  displayOrder: 10
21
21
  },
@@ -27,33 +27,33 @@ export var GRID_COLUMN_MENU_COMPONENTS_PROPS = {
27
27
  }
28
28
  };
29
29
  var GridGenericColumnMenu = /*#__PURE__*/React.forwardRef(function GridGenericColumnMenu(props, ref) {
30
- var defaultComponents = props.defaultComponents,
31
- defaultComponentsProps = props.defaultComponentsProps,
32
- components = props.components,
33
- componentsProps = props.componentsProps,
30
+ var defaultSlots = props.defaultSlots,
31
+ defaultSlotProps = props.defaultSlotProps,
32
+ slots = props.slots,
33
+ slotProps = props.slotProps,
34
34
  other = _objectWithoutProperties(props, _excluded);
35
- var orderedComponents = useGridColumnMenuComponents(_extends({}, other, {
36
- defaultComponents: defaultComponents,
37
- defaultComponentsProps: defaultComponentsProps,
38
- components: components,
39
- componentsProps: componentsProps
35
+ var orderedSlots = useGridColumnMenuSlots(_extends({}, other, {
36
+ defaultSlots: defaultSlots,
37
+ defaultSlotProps: defaultSlotProps,
38
+ slots: slots,
39
+ slotProps: slotProps
40
40
  }));
41
41
  return /*#__PURE__*/_jsx(GridColumnMenuContainer, _extends({
42
42
  ref: ref
43
43
  }, other, {
44
- children: orderedComponents.map(function (_ref, index) {
44
+ children: orderedSlots.map(function (_ref, index) {
45
45
  var _ref2 = _slicedToArray(_ref, 2),
46
46
  Component = _ref2[0],
47
- componentProps = _ref2[1];
48
- return /*#__PURE__*/_jsx(Component, _extends({}, componentProps), index);
47
+ otherProps = _ref2[1];
48
+ return /*#__PURE__*/_jsx(Component, _extends({}, otherProps), index);
49
49
  })
50
50
  }));
51
51
  });
52
52
  var GridColumnMenu = /*#__PURE__*/React.forwardRef(function GridColumnMenu(props, ref) {
53
53
  return /*#__PURE__*/_jsx(GridGenericColumnMenu, _extends({}, props, {
54
54
  ref: ref,
55
- defaultComponents: GRID_COLUMN_MENU_COMPONENTS,
56
- defaultComponentsProps: GRID_COLUMN_MENU_COMPONENTS_PROPS
55
+ defaultSlots: GRID_COLUMN_MENU_SLOTS,
56
+ defaultSlotProps: GRID_COLUMN_MENU_SLOT_PROPS
57
57
  }));
58
58
  });
59
59
  process.env.NODE_ENV !== "production" ? GridColumnMenu.propTypes = {
@@ -62,20 +62,20 @@ process.env.NODE_ENV !== "production" ? GridColumnMenu.propTypes = {
62
62
  // | To update them edit the TypeScript types and run "yarn proptypes" |
63
63
  // ----------------------------------------------------------------------
64
64
  colDef: PropTypes.object.isRequired,
65
- /**
66
- * `components` could be used to add new and (or) override default column menu items
67
- * If you register a nee component you must pass it's `displayOrder` in `componentsProps`
68
- * or it will be placed in the end of the list
69
- */
70
- components: PropTypes.object,
65
+ hideMenu: PropTypes.func.isRequired,
66
+ id: PropTypes.string,
67
+ labelledby: PropTypes.string,
68
+ open: PropTypes.bool.isRequired,
71
69
  /**
72
70
  * Could be used to pass new props or override props specific to a column menu component
73
71
  * e.g. `displayOrder`
74
72
  */
75
- componentsProps: PropTypes.object,
76
- hideMenu: PropTypes.func.isRequired,
77
- id: PropTypes.string,
78
- labelledby: PropTypes.string,
79
- open: PropTypes.bool.isRequired
73
+ slotProps: PropTypes.object,
74
+ /**
75
+ * `slots` could be used to add new and (or) override default column menu items
76
+ * If you register a nee component you must pass it's `displayOrder` in `slotProps`
77
+ * or it will be placed in the end of the list
78
+ */
79
+ slots: PropTypes.object
80
80
  } : void 0;
81
81
  export { GridColumnMenu, GridGenericColumnMenu };
@@ -3,7 +3,7 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
4
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
5
5
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
6
- var _excluded = ["sort", "searchPredicate", "autoFocusSearchField", "disableHideAllButton", "disableShowAllButton"];
6
+ var _excluded = ["sort", "searchPredicate", "autoFocusSearchField", "disableHideAllButton", "disableShowAllButton", "getTogglableColumns"];
7
7
  import * as React from 'react';
8
8
  import PropTypes from 'prop-types';
9
9
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
@@ -84,6 +84,7 @@ function GridColumnsPanel(props) {
84
84
  disableHideAllButton = _props$disableHideAll === void 0 ? false : _props$disableHideAll,
85
85
  _props$disableShowAll = props.disableShowAllButton,
86
86
  disableShowAllButton = _props$disableShowAll === void 0 ? false : _props$disableShowAll,
87
+ getTogglableColumns = props.getTogglableColumns,
87
88
  other = _objectWithoutProperties(props, _excluded);
88
89
  var sortedColumns = React.useMemo(function () {
89
90
  switch (sort) {
@@ -123,14 +124,18 @@ function GridColumnsPanel(props) {
123
124
  setSearchValue(event.target.value);
124
125
  }, []);
125
126
  var currentColumns = React.useMemo(function () {
127
+ var togglableColumns = getTogglableColumns ? getTogglableColumns(sortedColumns) : null;
128
+ var togglableSortedColumns = togglableColumns ? sortedColumns.filter(function (_ref4) {
129
+ var field = _ref4.field;
130
+ return togglableColumns.includes(field);
131
+ }) : sortedColumns;
126
132
  if (!searchValue) {
127
- return sortedColumns;
133
+ return togglableSortedColumns;
128
134
  }
129
- var searchValueToCheck = searchValue.toLowerCase();
130
- return sortedColumns.filter(function (column) {
131
- return searchPredicate(column, searchValueToCheck);
135
+ return togglableSortedColumns.filter(function (column) {
136
+ return searchPredicate(column, searchValue.toLowerCase());
132
137
  });
133
- }, [sortedColumns, searchValue, searchPredicate]);
138
+ }, [sortedColumns, searchValue, searchPredicate, getTogglableColumns]);
134
139
  var firstSwitchRef = React.useRef(null);
135
140
  React.useEffect(function () {
136
141
  if (autoFocusSearchField) {
@@ -215,6 +220,14 @@ process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
215
220
  autoFocusSearchField: PropTypes.bool,
216
221
  disableHideAllButton: PropTypes.bool,
217
222
  disableShowAllButton: PropTypes.bool,
223
+ /**
224
+ * Returns the list of togglable columns.
225
+ * If used, only those columns will be displayed in the panel
226
+ * which are passed as the return value of the function.
227
+ * @param {GridColDef[]} columns The `ColDef` list of all columns.
228
+ * @returns {GridColDef['field'][]} The list of togglable columns' field names.
229
+ */
230
+ getTogglableColumns: PropTypes.func,
218
231
  searchPredicate: PropTypes.func,
219
232
  slotProps: PropTypes.object,
220
233
  sort: PropTypes.oneOf(['asc', 'desc'])
@@ -156,7 +156,7 @@ var GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(pro
156
156
  columnsSort: columnsSort
157
157
  }, filterFormProps), item.id == null ? index : item.id);
158
158
  })
159
- }), !rootProps.disableMultipleColumnsFiltering && !disableAddFilterButton && !disableRemoveAllButton ? /*#__PURE__*/_jsxs(GridPanelFooter, {
159
+ }), !rootProps.disableMultipleColumnsFiltering && !(disableAddFilterButton && disableRemoveAllButton) ? /*#__PURE__*/_jsxs(GridPanelFooter, {
160
160
  children: [!disableAddFilterButton ? /*#__PURE__*/_jsx(rootProps.slots.baseButton, _extends({
161
161
  onClick: addNewFilter,
162
162
  startIcon: /*#__PURE__*/_jsx(rootProps.slots.filterPanelAddIcon, {})
@@ -1 +1 @@
1
- export { GridColumnMenu, GRID_COLUMN_MENU_COMPONENTS, GRID_COLUMN_MENU_COMPONENTS_PROPS } from './menu/columnMenu/GridColumnMenu';
1
+ export { GridColumnMenu, GRID_COLUMN_MENU_SLOTS, GRID_COLUMN_MENU_SLOT_PROPS } from './menu/columnMenu/GridColumnMenu';
@@ -2,7 +2,6 @@ import * as React from 'react';
2
2
  import { useGridApiMethod } from '../utils/useGridApiMethod';
3
3
  import { GridSignature } from '../utils/useGridApiEventHandler';
4
4
  import { EventManager } from '../../utils/EventManager';
5
- import { unstable_resetCreateSelectorCache } from '../../utils/createSelector';
6
5
  var isSyntheticEvent = function isSyntheticEvent(event) {
7
6
  return event.isPropagationStopped !== undefined;
8
7
  };
@@ -40,7 +39,9 @@ export function useGridApiInitialization(inputApiRef, props) {
40
39
  if (!publicApiRef.current) {
41
40
  publicApiRef.current = {
42
41
  state: {},
43
- instanceId: globalId
42
+ instanceId: {
43
+ id: globalId
44
+ }
44
45
  };
45
46
  globalId += 1;
46
47
  }
@@ -86,7 +87,6 @@ export function useGridApiInitialization(inputApiRef, props) {
86
87
  React.useEffect(function () {
87
88
  var api = privateApiRef.current;
88
89
  return function () {
89
- unstable_resetCreateSelectorCache(api.instanceId);
90
90
  api.publishEvent('unmount');
91
91
  };
92
92
  }, [privateApiRef]);