@mui/x-data-grid 6.4.0 → 6.5.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 (267) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/DataGrid/useDataGridProps.js +5 -12
  3. package/colDef/gridNumericOperators.js +0 -6
  4. package/components/cell/GridEditInputCell.js +4 -1
  5. package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +15 -2
  6. package/components/panel/filterPanel/GridFilterInputBoolean.js +80 -36
  7. package/components/panel/filterPanel/GridFilterInputDate.d.ts +8 -1
  8. package/components/panel/filterPanel/GridFilterInputDate.js +27 -6
  9. package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +8 -1
  10. package/components/panel/filterPanel/GridFilterInputSingleSelect.js +55 -32
  11. package/components/panel/filterPanel/GridFilterInputValue.d.ts +11 -4
  12. package/components/panel/filterPanel/GridFilterInputValue.js +29 -6
  13. package/components/panel/filterPanel/GridFilterPanel.d.ts +2 -1
  14. package/components/panel/filterPanel/GridFilterPanel.js +1 -1
  15. package/components/panel/filterPanel/index.d.ts +3 -1
  16. package/components/panel/filterPanel/index.js +2 -1
  17. package/constants/localeTextConstants.js +26 -0
  18. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +9 -2
  19. package/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -2
  20. package/hooks/features/dimensions/useGridDimensions.js +2 -2
  21. package/hooks/features/editing/useGridEditing.js +0 -3
  22. package/hooks/features/focus/gridFocusState.d.ts +2 -0
  23. package/hooks/features/focus/gridFocusStateSelector.d.ts +2 -0
  24. package/hooks/features/focus/gridFocusStateSelector.js +6 -0
  25. package/hooks/features/focus/useGridFocus.js +55 -9
  26. package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.d.ts +4 -0
  27. package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +5 -0
  28. package/hooks/features/headerFiltering/index.d.ts +1 -0
  29. package/hooks/features/headerFiltering/index.js +1 -0
  30. package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +6 -0
  31. package/hooks/features/headerFiltering/useGridHeaderFiltering.js +91 -0
  32. package/hooks/features/index.d.ts +1 -0
  33. package/hooks/features/index.js +2 -1
  34. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
  35. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +113 -4
  36. package/hooks/features/rows/useGridRows.js +16 -1
  37. package/index.js +1 -1
  38. package/internals/index.d.ts +6 -1
  39. package/internals/index.js +4 -0
  40. package/internals/utils/index.d.ts +1 -0
  41. package/internals/utils/index.js +2 -1
  42. package/internals/utils/useProps.d.ts +8 -0
  43. package/internals/utils/useProps.js +13 -0
  44. package/legacy/DataGrid/useDataGridProps.js +8 -8
  45. package/legacy/colDef/gridNumericOperators.js +0 -6
  46. package/legacy/components/cell/GridEditInputCell.js +4 -1
  47. package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +79 -35
  48. package/legacy/components/panel/filterPanel/GridFilterInputDate.js +26 -5
  49. package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +54 -31
  50. package/legacy/components/panel/filterPanel/GridFilterInputValue.js +28 -5
  51. package/legacy/components/panel/filterPanel/GridFilterPanel.js +1 -1
  52. package/legacy/components/panel/filterPanel/index.js +2 -1
  53. package/legacy/constants/localeTextConstants.js +26 -0
  54. package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +5 -5
  55. package/legacy/hooks/features/dimensions/useGridDimensions.js +2 -2
  56. package/legacy/hooks/features/editing/useGridEditing.js +0 -3
  57. package/legacy/hooks/features/focus/gridFocusStateSelector.js +10 -0
  58. package/legacy/hooks/features/focus/useGridFocus.js +58 -9
  59. package/legacy/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +11 -0
  60. package/legacy/hooks/features/headerFiltering/index.js +1 -0
  61. package/legacy/hooks/features/headerFiltering/useGridHeaderFiltering.js +93 -0
  62. package/legacy/hooks/features/index.js +2 -1
  63. package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +113 -4
  64. package/legacy/hooks/features/rows/useGridRows.js +16 -1
  65. package/legacy/index.js +1 -1
  66. package/legacy/internals/index.js +4 -0
  67. package/legacy/internals/utils/index.js +2 -1
  68. package/legacy/internals/utils/useProps.js +11 -0
  69. package/legacy/locales/arSD.js +28 -0
  70. package/legacy/locales/beBY.js +28 -0
  71. package/legacy/locales/bgBG.js +28 -0
  72. package/legacy/locales/csCZ.js +36 -8
  73. package/legacy/locales/daDK.js +28 -0
  74. package/legacy/locales/deDE.js +28 -0
  75. package/legacy/locales/elGR.js +27 -0
  76. package/legacy/locales/esES.js +28 -0
  77. package/legacy/locales/faIR.js +28 -0
  78. package/legacy/locales/fiFI.js +28 -0
  79. package/legacy/locales/frFR.js +28 -0
  80. package/legacy/locales/heIL.js +30 -2
  81. package/legacy/locales/huHU.js +28 -0
  82. package/legacy/locales/itIT.js +28 -0
  83. package/legacy/locales/jaJP.js +28 -0
  84. package/legacy/locales/koKR.js +28 -0
  85. package/legacy/locales/nbNO.js +28 -0
  86. package/legacy/locales/nlNL.js +28 -0
  87. package/legacy/locales/plPL.js +28 -0
  88. package/legacy/locales/ptBR.js +28 -0
  89. package/legacy/locales/roRO.js +28 -0
  90. package/legacy/locales/ruRU.js +28 -0
  91. package/legacy/locales/skSK.js +28 -0
  92. package/legacy/locales/svSE.js +28 -0
  93. package/legacy/locales/trTR.js +28 -0
  94. package/legacy/locales/ukUA.js +28 -0
  95. package/legacy/locales/urPK.js +28 -0
  96. package/legacy/locales/viVN.js +27 -0
  97. package/legacy/locales/zhCN.js +28 -0
  98. package/legacy/locales/zhTW.js +28 -0
  99. package/legacy/material/index.js +2 -0
  100. package/legacy/models/api/gridHeaderFilteringApi.js +1 -0
  101. package/legacy/models/gridHeaderFilteringModel.js +1 -0
  102. package/legacy/models/index.js +0 -1
  103. package/locales/arSD.js +28 -0
  104. package/locales/beBY.js +28 -0
  105. package/locales/bgBG.js +28 -0
  106. package/locales/csCZ.js +36 -8
  107. package/locales/daDK.js +28 -0
  108. package/locales/deDE.js +28 -0
  109. package/locales/elGR.js +27 -0
  110. package/locales/esES.js +28 -0
  111. package/locales/faIR.js +28 -0
  112. package/locales/fiFI.js +28 -0
  113. package/locales/frFR.js +28 -0
  114. package/locales/heIL.js +30 -2
  115. package/locales/huHU.js +28 -0
  116. package/locales/itIT.js +28 -0
  117. package/locales/jaJP.js +28 -0
  118. package/locales/koKR.js +28 -0
  119. package/locales/nbNO.js +28 -0
  120. package/locales/nlNL.js +28 -0
  121. package/locales/plPL.js +28 -0
  122. package/locales/ptBR.js +28 -0
  123. package/locales/roRO.js +28 -0
  124. package/locales/ruRU.js +28 -0
  125. package/locales/skSK.js +28 -0
  126. package/locales/svSE.js +28 -0
  127. package/locales/trTR.js +28 -0
  128. package/locales/ukUA.js +28 -0
  129. package/locales/urPK.js +28 -0
  130. package/locales/viVN.js +27 -0
  131. package/locales/zhCN.js +28 -0
  132. package/locales/zhTW.js +28 -0
  133. package/material/index.d.ts +3 -66
  134. package/material/index.js +2 -0
  135. package/models/api/gridApiCommon.d.ts +3 -2
  136. package/models/api/gridCoreApi.d.ts +4 -0
  137. package/models/api/gridFocusApi.d.ts +6 -0
  138. package/models/api/gridHeaderFilteringApi.d.ts +30 -0
  139. package/models/api/gridHeaderFilteringApi.js +1 -0
  140. package/models/api/gridLocaleTextApi.d.ts +25 -0
  141. package/models/events/gridEventLookup.d.ts +27 -1
  142. package/models/gridFilterOperator.d.ts +4 -0
  143. package/models/gridHeaderFilteringModel.d.ts +5 -0
  144. package/models/gridHeaderFilteringModel.js +1 -0
  145. package/models/gridSlotsComponent.d.ts +16 -4
  146. package/models/gridStateCommunity.d.ts +2 -0
  147. package/models/index.d.ts +1 -1
  148. package/models/index.js +0 -1
  149. package/modern/DataGrid/useDataGridProps.js +5 -12
  150. package/modern/colDef/gridNumericOperators.js +0 -6
  151. package/modern/components/cell/GridEditInputCell.js +4 -1
  152. package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +80 -36
  153. package/modern/components/panel/filterPanel/GridFilterInputDate.js +27 -6
  154. package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +55 -32
  155. package/modern/components/panel/filterPanel/GridFilterInputValue.js +29 -6
  156. package/modern/components/panel/filterPanel/GridFilterPanel.js +1 -1
  157. package/modern/components/panel/filterPanel/index.js +2 -1
  158. package/modern/constants/localeTextConstants.js +26 -0
  159. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -2
  160. package/modern/hooks/features/dimensions/useGridDimensions.js +2 -2
  161. package/modern/hooks/features/editing/useGridEditing.js +0 -3
  162. package/modern/hooks/features/focus/gridFocusStateSelector.js +6 -0
  163. package/modern/hooks/features/focus/useGridFocus.js +55 -9
  164. package/modern/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +5 -0
  165. package/modern/hooks/features/headerFiltering/index.js +1 -0
  166. package/modern/hooks/features/headerFiltering/useGridHeaderFiltering.js +90 -0
  167. package/modern/hooks/features/index.js +2 -1
  168. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +113 -4
  169. package/modern/hooks/features/rows/useGridRows.js +16 -1
  170. package/modern/index.js +1 -1
  171. package/modern/internals/index.js +4 -0
  172. package/modern/internals/utils/index.js +2 -1
  173. package/modern/internals/utils/useProps.js +13 -0
  174. package/modern/locales/arSD.js +28 -0
  175. package/modern/locales/beBY.js +28 -0
  176. package/modern/locales/bgBG.js +28 -0
  177. package/modern/locales/csCZ.js +36 -8
  178. package/modern/locales/daDK.js +28 -0
  179. package/modern/locales/deDE.js +28 -0
  180. package/modern/locales/elGR.js +27 -0
  181. package/modern/locales/esES.js +28 -0
  182. package/modern/locales/faIR.js +28 -0
  183. package/modern/locales/fiFI.js +28 -0
  184. package/modern/locales/frFR.js +28 -0
  185. package/modern/locales/heIL.js +30 -2
  186. package/modern/locales/huHU.js +28 -0
  187. package/modern/locales/itIT.js +28 -0
  188. package/modern/locales/jaJP.js +28 -0
  189. package/modern/locales/koKR.js +28 -0
  190. package/modern/locales/nbNO.js +28 -0
  191. package/modern/locales/nlNL.js +28 -0
  192. package/modern/locales/plPL.js +28 -0
  193. package/modern/locales/ptBR.js +28 -0
  194. package/modern/locales/roRO.js +28 -0
  195. package/modern/locales/ruRU.js +28 -0
  196. package/modern/locales/skSK.js +28 -0
  197. package/modern/locales/svSE.js +28 -0
  198. package/modern/locales/trTR.js +28 -0
  199. package/modern/locales/ukUA.js +28 -0
  200. package/modern/locales/urPK.js +28 -0
  201. package/modern/locales/viVN.js +27 -0
  202. package/modern/locales/zhCN.js +28 -0
  203. package/modern/locales/zhTW.js +28 -0
  204. package/modern/material/index.js +2 -0
  205. package/modern/models/api/gridHeaderFilteringApi.js +1 -0
  206. package/modern/models/gridHeaderFilteringModel.js +1 -0
  207. package/modern/models/index.js +0 -1
  208. package/node/DataGrid/useDataGridProps.js +4 -11
  209. package/node/colDef/gridNumericOperators.js +0 -6
  210. package/node/components/cell/GridEditInputCell.js +4 -1
  211. package/node/components/panel/filterPanel/GridFilterInputBoolean.js +78 -35
  212. package/node/components/panel/filterPanel/GridFilterInputDate.js +27 -6
  213. package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +55 -32
  214. package/node/components/panel/filterPanel/GridFilterInputValue.js +29 -6
  215. package/node/components/panel/filterPanel/GridFilterPanel.js +2 -1
  216. package/node/components/panel/filterPanel/index.js +26 -8
  217. package/node/constants/localeTextConstants.js +26 -0
  218. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -2
  219. package/node/hooks/features/dimensions/useGridDimensions.js +2 -2
  220. package/node/hooks/features/editing/useGridEditing.js +0 -3
  221. package/node/hooks/features/focus/gridFocusStateSelector.js +9 -1
  222. package/node/hooks/features/focus/useGridFocus.js +55 -9
  223. package/node/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +15 -0
  224. package/node/hooks/features/headerFiltering/index.js +16 -0
  225. package/node/hooks/features/headerFiltering/useGridHeaderFiltering.js +101 -0
  226. package/node/hooks/features/index.js +11 -0
  227. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +113 -4
  228. package/node/hooks/features/rows/useGridRows.js +16 -1
  229. package/node/index.js +1 -1
  230. package/node/internals/index.js +46 -0
  231. package/node/internals/utils/index.js +11 -0
  232. package/node/internals/utils/useProps.js +22 -0
  233. package/node/locales/arSD.js +28 -0
  234. package/node/locales/beBY.js +28 -0
  235. package/node/locales/bgBG.js +28 -0
  236. package/node/locales/csCZ.js +36 -8
  237. package/node/locales/daDK.js +28 -0
  238. package/node/locales/deDE.js +28 -0
  239. package/node/locales/elGR.js +27 -0
  240. package/node/locales/esES.js +28 -0
  241. package/node/locales/faIR.js +28 -0
  242. package/node/locales/fiFI.js +28 -0
  243. package/node/locales/frFR.js +28 -0
  244. package/node/locales/heIL.js +30 -2
  245. package/node/locales/huHU.js +28 -0
  246. package/node/locales/itIT.js +28 -0
  247. package/node/locales/jaJP.js +28 -0
  248. package/node/locales/koKR.js +28 -0
  249. package/node/locales/nbNO.js +28 -0
  250. package/node/locales/nlNL.js +28 -0
  251. package/node/locales/plPL.js +28 -0
  252. package/node/locales/ptBR.js +28 -0
  253. package/node/locales/roRO.js +28 -0
  254. package/node/locales/ruRU.js +28 -0
  255. package/node/locales/skSK.js +28 -0
  256. package/node/locales/svSE.js +28 -0
  257. package/node/locales/trTR.js +28 -0
  258. package/node/locales/ukUA.js +28 -0
  259. package/node/locales/urPK.js +28 -0
  260. package/node/locales/viVN.js +27 -0
  261. package/node/locales/zhCN.js +28 -0
  262. package/node/locales/zhTW.js +28 -0
  263. package/node/material/index.js +2 -0
  264. package/node/models/api/gridHeaderFilteringApi.js +5 -0
  265. package/node/models/gridHeaderFilteringModel.js +5 -0
  266. package/node/models/index.js +0 -11
  267. package/package.json +1 -1
@@ -2,10 +2,11 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
5
- var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "getOptionLabel", "getOptionValue"];
5
+ var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "getOptionLabel", "getOptionValue", "placeholder", "tabIndex", "label", "headerFilterMenu", "isFilterActive", "clearButton"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import { unstable_useId as useId } from '@mui/utils';
9
+ import { styled } from '@mui/material/styles';
9
10
  import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
10
11
  import { getValueFromValueOptions, isSingleSelectColDef } from './filterPanelUtils';
11
12
  import { createElement as _createElement } from "react";
@@ -33,6 +34,11 @@ var renderSingleSelectOptions = function renderSingleSelectOptions(_ref) {
33
34
  }), label);
34
35
  });
35
36
  };
37
+ var SingleSelectOperatorContainer = styled('div')({
38
+ display: 'flex',
39
+ alignItems: 'flex-end',
40
+ width: '100%'
41
+ });
36
42
  function GridFilterInputSingleSelect(props) {
37
43
  var _item$value, _rootProps$slotProps$, _rootProps$slotProps, _rootProps$slotProps$2, _resolvedColumn, _resolvedColumn2, _rootProps$slotProps2, _rootProps$slotProps3, _rootProps$slotProps4;
38
44
  var item = props.item,
@@ -42,6 +48,12 @@ function GridFilterInputSingleSelect(props) {
42
48
  focusElementRef = props.focusElementRef,
43
49
  getOptionLabelProp = props.getOptionLabel,
44
50
  getOptionValueProp = props.getOptionValue,
51
+ placeholder = props.placeholder,
52
+ tabIndex = props.tabIndex,
53
+ labelProp = props.label,
54
+ headerFilterMenu = props.headerFilterMenu,
55
+ isFilterActive = props.isFilterActive,
56
+ clearButton = props.clearButton,
45
57
  others = _objectWithoutProperties(props, _excluded);
46
58
  var _React$useState = React.useState((_item$value = item.value) != null ? _item$value : ''),
47
59
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -102,36 +114,40 @@ function GridFilterInputSingleSelect(props) {
102
114
  if (!isSingleSelectColDef(resolvedColumn)) {
103
115
  return null;
104
116
  }
105
- var label = apiRef.current.getLocaleText('filterPanelInputLabel');
106
- return /*#__PURE__*/_jsxs(React.Fragment, {
107
- children: [/*#__PURE__*/_jsx(rootProps.slots.baseInputLabel, _extends({}, (_rootProps$slotProps2 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps2.baseInputLabel, {
108
- id: labelId,
109
- shrink: true,
110
- variant: "standard",
111
- children: label
112
- })), /*#__PURE__*/_jsx(rootProps.slots.baseSelect, _extends({
113
- id: id,
114
- label: label,
115
- labelId: labelId,
116
- value: filterValueState,
117
- onChange: onFilterChange,
118
- variant: "standard",
119
- type: type || 'text',
120
- inputProps: {
121
- ref: focusElementRef,
122
- placeholder: apiRef.current.getLocaleText('filterPanelInputPlaceholder')
123
- },
124
- native: isSelectNative
125
- }, others, (_rootProps$slotProps3 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps3.baseSelect, {
126
- children: renderSingleSelectOptions({
127
- column: resolvedColumn,
128
- OptionComponent: rootProps.slots.baseSelectOption,
129
- getOptionLabel: getOptionLabel,
130
- getOptionValue: getOptionValue,
131
- isSelectNative: isSelectNative,
132
- baseSelectOptionProps: (_rootProps$slotProps4 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps4.baseSelectOption
133
- })
134
- }))]
117
+ var label = labelProp != null ? labelProp : apiRef.current.getLocaleText('filterPanelInputLabel');
118
+ return /*#__PURE__*/_jsxs(SingleSelectOperatorContainer, {
119
+ children: [/*#__PURE__*/_jsxs(rootProps.slots.baseFormControl, {
120
+ children: [/*#__PURE__*/_jsx(rootProps.slots.baseInputLabel, _extends({}, (_rootProps$slotProps2 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps2.baseInputLabel, {
121
+ id: labelId,
122
+ shrink: true,
123
+ variant: "standard",
124
+ children: label
125
+ })), /*#__PURE__*/_jsx(rootProps.slots.baseSelect, _extends({
126
+ id: id,
127
+ label: label,
128
+ labelId: labelId,
129
+ value: filterValueState,
130
+ onChange: onFilterChange,
131
+ startAdornment: isFilterActive ? headerFilterMenu : null,
132
+ variant: "standard",
133
+ type: type || 'text',
134
+ inputProps: {
135
+ tabIndex: tabIndex,
136
+ ref: focusElementRef,
137
+ placeholder: placeholder != null ? placeholder : apiRef.current.getLocaleText('filterPanelInputPlaceholder')
138
+ },
139
+ native: isSelectNative
140
+ }, others, (_rootProps$slotProps3 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps3.baseSelect, {
141
+ children: renderSingleSelectOptions({
142
+ column: resolvedColumn,
143
+ OptionComponent: rootProps.slots.baseSelectOption,
144
+ getOptionLabel: getOptionLabel,
145
+ getOptionValue: getOptionValue,
146
+ isSelectNative: isSelectNative,
147
+ baseSelectOptionProps: (_rootProps$slotProps4 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps4.baseSelectOption
148
+ })
149
+ }))]
150
+ }), clearButton]
135
151
  });
136
152
  }
137
153
  process.env.NODE_ENV !== "production" ? GridFilterInputSingleSelect.propTypes = {
@@ -143,6 +159,7 @@ process.env.NODE_ENV !== "production" ? GridFilterInputSingleSelect.propTypes =
143
159
  current: PropTypes.object.isRequired
144
160
  }).isRequired,
145
161
  applyValue: PropTypes.func.isRequired,
162
+ clearButton: PropTypes.node,
146
163
  focusElementRef: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.func, PropTypes.object]),
147
164
  /**
148
165
  * Used to determine the label displayed for a given value option.
@@ -156,6 +173,12 @@ process.env.NODE_ENV !== "production" ? GridFilterInputSingleSelect.propTypes =
156
173
  * @returns {string} The value to be used.
157
174
  */
158
175
  getOptionValue: PropTypes.func,
176
+ headerFilterMenu: PropTypes.node,
177
+ /**
178
+ * It is `true` if the filter either has a value or an operator with no value
179
+ * required is selected (e.g. `isEmpty`)
180
+ */
181
+ isFilterActive: PropTypes.bool,
159
182
  item: PropTypes.shape({
160
183
  field: PropTypes.string.isRequired,
161
184
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef"];
4
+ var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "tabIndex", "disabled", "headerFilterMenu", "isFilterActive", "clearButton", "InputProps"];
5
5
  import * as React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import { unstable_useId as useId } from '@mui/utils';
@@ -15,6 +15,12 @@ function GridFilterInputValue(props) {
15
15
  type = props.type,
16
16
  apiRef = props.apiRef,
17
17
  focusElementRef = props.focusElementRef,
18
+ tabIndex = props.tabIndex,
19
+ disabled = props.disabled,
20
+ headerFilterMenu = props.headerFilterMenu,
21
+ isFilterActive = props.isFilterActive,
22
+ clearButton = props.clearButton,
23
+ InputProps = props.InputProps,
18
24
  others = _objectWithoutProperties(props, _excluded);
19
25
  var filterTimeout = React.useRef();
20
26
  var _React$useState = React.useState((_item$value = item.value) != null ? _item$value : ''),
@@ -49,9 +55,6 @@ function GridFilterInputValue(props) {
49
55
  var itemValue = (_item$value2 = item.value) != null ? _item$value2 : '';
50
56
  setFilterValueState(String(itemValue));
51
57
  }, [item.value]);
52
- var InputProps = applying ? {
53
- endAdornment: /*#__PURE__*/_jsx(rootProps.slots.loadIcon, {})
54
- } : others.InputProps;
55
58
  return /*#__PURE__*/_jsx(rootProps.slots.baseTextField, _extends({
56
59
  id: id,
57
60
  label: apiRef.current.getLocaleText('filterPanelInputLabel'),
@@ -60,7 +63,20 @@ function GridFilterInputValue(props) {
60
63
  onChange: onFilterChange,
61
64
  variant: "standard",
62
65
  type: type || 'text',
63
- InputProps: InputProps,
66
+ InputProps: _extends({}, applying || clearButton ? {
67
+ endAdornment: applying ? /*#__PURE__*/_jsx(rootProps.slots.loadIcon, {
68
+ fontSize: "small",
69
+ color: "action"
70
+ }) : clearButton
71
+ } : {}, headerFilterMenu && isFilterActive ? {
72
+ startAdornment: headerFilterMenu
73
+ } : {}, {
74
+ disabled: disabled
75
+ }, InputProps, {
76
+ inputProps: _extends({
77
+ tabIndex: tabIndex
78
+ }, InputProps == null ? void 0 : InputProps.inputProps)
79
+ }),
64
80
  InputLabelProps: {
65
81
  shrink: true
66
82
  },
@@ -76,7 +92,14 @@ process.env.NODE_ENV !== "production" ? GridFilterInputValue.propTypes = {
76
92
  current: PropTypes.object.isRequired
77
93
  }).isRequired,
78
94
  applyValue: PropTypes.func.isRequired,
95
+ clearButton: PropTypes.node,
79
96
  focusElementRef: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.func, PropTypes.object]),
97
+ headerFilterMenu: PropTypes.node,
98
+ /**
99
+ * It is `true` if the filter either has a value or an operator with no value
100
+ * required is selected (e.g. `isEmpty`)
101
+ */
102
+ isFilterActive: PropTypes.bool,
80
103
  item: PropTypes.shape({
81
104
  field: PropTypes.string.isRequired,
82
105
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -218,4 +218,4 @@ process.env.NODE_ENV !== "production" ? GridFilterPanel.propTypes = {
218
218
  */
219
219
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
220
220
  } : void 0;
221
- export { GridFilterPanel };
221
+ export { GridFilterPanel, getGridFilter };
@@ -2,7 +2,8 @@ export * from './GridFilterForm';
2
2
  export * from './GridFilterInputValue';
3
3
  export * from './GridFilterInputDate';
4
4
  export * from './GridFilterInputSingleSelect';
5
+ export * from './GridFilterInputBoolean';
5
6
  export * from './GridFilterInputValueProps';
6
- export * from './GridFilterPanel';
7
+ export { GridFilterPanel } from './GridFilterPanel';
7
8
  export * from './GridFilterInputMultipleValue';
8
9
  export * from './GridFilterInputMultipleSingleSelect';
@@ -60,6 +60,32 @@ export var GRID_DEFAULT_LOCALE_TEXT = {
60
60
  filterOperatorIsEmpty: 'is empty',
61
61
  filterOperatorIsNotEmpty: 'is not empty',
62
62
  filterOperatorIsAnyOf: 'is any of',
63
+ 'filterOperator=': '=',
64
+ 'filterOperator!=': '!=',
65
+ 'filterOperator>': '>',
66
+ 'filterOperator>=': '>=',
67
+ 'filterOperator<': '<',
68
+ 'filterOperator<=': '<=',
69
+ // Header filter operators text
70
+ headerFilterOperatorContains: 'Contains',
71
+ headerFilterOperatorEquals: 'Equals',
72
+ headerFilterOperatorStartsWith: 'Starts with',
73
+ headerFilterOperatorEndsWith: 'Ends with',
74
+ headerFilterOperatorIs: 'Is',
75
+ headerFilterOperatorNot: 'Is not',
76
+ headerFilterOperatorAfter: 'Is after',
77
+ headerFilterOperatorOnOrAfter: 'Is on or after',
78
+ headerFilterOperatorBefore: 'Is before',
79
+ headerFilterOperatorOnOrBefore: 'Is on or before',
80
+ headerFilterOperatorIsEmpty: 'Is empty',
81
+ headerFilterOperatorIsNotEmpty: 'Is not empty',
82
+ headerFilterOperatorIsAnyOf: 'Is any of',
83
+ 'headerFilterOperator=': 'Equals',
84
+ 'headerFilterOperator!=': 'Not equals',
85
+ 'headerFilterOperator>': 'Is greater than',
86
+ 'headerFilterOperator>=': 'Is greater than or equal to',
87
+ 'headerFilterOperator<': 'Is less than',
88
+ 'headerFilterOperator<=': 'Is less than or equal to',
63
89
  // Filter values text
64
90
  filterValueAny: 'any',
65
91
  filterValueTrue: 'true',
@@ -298,10 +298,8 @@ export var useGridColumnHeaders = function useGridColumnHeaders(props) {
298
298
  var tabIndex = columnGroupHeaderTabIndexState !== null && columnGroupHeaderTabIndexState.depth === depth && columnFields.includes(columnGroupHeaderTabIndexState.field) ? 0 : -1;
299
299
  var headerInfo = {
300
300
  groupId: groupId,
301
- width: columnFields.map(function (field) {
302
- return apiRef.current.getColumn(field).computedWidth;
303
- }).reduce(function (acc, val) {
304
- return acc + val;
301
+ width: columnFields.reduce(function (acc, field) {
302
+ return acc + apiRef.current.getColumn(field).computedWidth;
305
303
  }, 0),
306
304
  fields: columnFields,
307
305
  colIndex: columnIndex,
@@ -360,6 +358,7 @@ export var useGridColumnHeaders = function useGridColumnHeaders(props) {
360
358
  return {
361
359
  renderContext: renderContext,
362
360
  getColumnHeaders: getColumnHeaders,
361
+ getColumnsToRender: getColumnsToRender,
363
362
  getColumnGroupHeaders: getColumnGroupHeaders,
364
363
  isDragging: !!dragCol,
365
364
  getRootProps: function getRootProps() {
@@ -373,6 +372,7 @@ export var useGridColumnHeaders = function useGridColumnHeaders(props) {
373
372
  ref: handleInnerRef,
374
373
  role: 'rowgroup'
375
374
  };
376
- }
375
+ },
376
+ headerHeight: headerHeight
377
377
  };
378
378
  };
@@ -162,8 +162,8 @@ export function useGridDimensions(apiRef, props) {
162
162
  if (!mainEl) {
163
163
  return;
164
164
  }
165
- var height = mainEl.offsetHeight || 0;
166
- var width = mainEl.offsetWidth || 0;
165
+ var height = mainEl.clientHeight || 0;
166
+ var width = mainEl.clientWidth || 0;
167
167
  var win = ownerWindow(mainEl);
168
168
  var computedStyle = win.getComputedStyle(mainEl);
169
169
  var paddingLeft = parseInt(computedStyle.paddingLeft, 10) || 0;
@@ -32,9 +32,6 @@ export var useGridEditing = function useGridEditing(apiRef, props) {
32
32
  if (isCellEditableProp) {
33
33
  return isCellEditableProp(params);
34
34
  }
35
- if (params.rowNode.type === 'pinnedRow') {
36
- return false;
37
- }
38
35
  return true;
39
36
  }, [isCellEditableProp]);
40
37
  var maybeDebounce = function maybeDebounce(id, field, debounceMs, callback) {
@@ -9,6 +9,11 @@ export var gridFocusColumnHeaderSelector = createSelector(gridFocusStateSelector
9
9
  return focusState.columnHeader;
10
10
  });
11
11
 
12
+ // eslint-disable-next-line @typescript-eslint/naming-convention
13
+ export var unstable_gridFocusColumnHeaderFilterSelector = createSelector(gridFocusStateSelector, function (focusState) {
14
+ return focusState.columnHeaderFilter;
15
+ });
16
+
12
17
  // eslint-disable-next-line @typescript-eslint/naming-convention
13
18
  export var unstable_gridFocusColumnGroupHeaderSelector = createSelector(gridFocusStateSelector, function (focusState) {
14
19
  return focusState.columnGroupHeader;
@@ -23,6 +28,11 @@ export var gridTabIndexColumnHeaderSelector = createSelector(gridTabIndexStateSe
23
28
  return state.columnHeader;
24
29
  });
25
30
 
31
+ // eslint-disable-next-line @typescript-eslint/naming-convention
32
+ export var unstable_gridTabIndexColumnHeaderFilterSelector = createSelector(gridTabIndexStateSelector, function (state) {
33
+ return state.columnHeaderFilter;
34
+ });
35
+
26
36
  // eslint-disable-next-line @typescript-eslint/naming-convention
27
37
  export var unstable_gridTabIndexColumnGroupHeaderSelector = createSelector(gridTabIndexStateSelector, function (state) {
28
38
  return state.columnGroupHeader;
@@ -9,16 +9,19 @@ import { gridFocusCellSelector, unstable_gridFocusColumnGroupHeaderSelector } fr
9
9
  import { gridVisibleColumnDefinitionsSelector } from '../columns/gridColumnsSelector';
10
10
  import { getVisibleRows } from '../../utils/useGridVisibleRows';
11
11
  import { clamp } from '../../../utils/utils';
12
+ import { gridPinnedRowsSelector } from '../rows/gridRowsSelector';
12
13
  export var focusStateInitializer = function focusStateInitializer(state) {
13
14
  return _extends({}, state, {
14
15
  focus: {
15
16
  cell: null,
16
17
  columnHeader: null,
18
+ columnHeaderFilter: null,
17
19
  columnGroupHeader: null
18
20
  },
19
21
  tabIndex: {
20
22
  cell: null,
21
23
  columnHeader: null,
24
+ columnHeaderFilter: null,
22
25
  columnGroupHeader: null
23
26
  }
24
27
  });
@@ -54,6 +57,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
54
57
  field: field
55
58
  },
56
59
  columnHeader: null,
60
+ columnHeaderFilter: null,
57
61
  columnGroupHeader: null
58
62
  },
59
63
  focus: {
@@ -62,6 +66,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
62
66
  field: field
63
67
  },
64
68
  columnHeader: null,
69
+ columnHeaderFilter: null,
65
70
  columnGroupHeader: null
66
71
  }
67
72
  });
@@ -90,6 +95,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
90
95
  columnHeader: {
91
96
  field: field
92
97
  },
98
+ columnHeaderFilter: null,
93
99
  cell: null,
94
100
  columnGroupHeader: null
95
101
  },
@@ -97,6 +103,34 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
97
103
  columnHeader: {
98
104
  field: field
99
105
  },
106
+ columnHeaderFilter: null,
107
+ cell: null,
108
+ columnGroupHeader: null
109
+ }
110
+ });
111
+ });
112
+ apiRef.current.forceUpdate();
113
+ }, [apiRef, logger, publishCellFocusOut]);
114
+ var setColumnHeaderFilterFocus = React.useCallback(function (field) {
115
+ var event = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
116
+ var cell = gridFocusCellSelector(apiRef);
117
+ publishCellFocusOut(cell, event);
118
+ apiRef.current.setState(function (state) {
119
+ logger.debug("Focusing on column header filter with colIndex=".concat(field));
120
+ return _extends({}, state, {
121
+ tabIndex: {
122
+ columnHeader: null,
123
+ columnHeaderFilter: {
124
+ field: field
125
+ },
126
+ cell: null,
127
+ columnGroupHeader: null
128
+ },
129
+ focus: {
130
+ columnHeader: null,
131
+ columnHeaderFilter: {
132
+ field: field
133
+ },
100
134
  cell: null,
101
135
  columnGroupHeader: null
102
136
  }
@@ -118,6 +152,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
118
152
  depth: depth
119
153
  },
120
154
  columnHeader: null,
155
+ columnHeaderFilter: null,
121
156
  cell: null
122
157
  },
123
158
  focus: {
@@ -126,6 +161,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
126
161
  depth: depth
127
162
  },
128
163
  columnHeader: null,
164
+ columnHeaderFilter: null,
129
165
  cell: null
130
166
  }
131
167
  });
@@ -137,8 +173,18 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
137
173
  }, [apiRef]);
138
174
  var moveFocusToRelativeCell = React.useCallback(function (id, field, direction) {
139
175
  var columnIndexToFocus = apiRef.current.getColumnIndex(field);
140
- var rowIndexToFocus = apiRef.current.getRowIndexRelativeToVisibleRows(id);
141
176
  var visibleColumns = gridVisibleColumnDefinitionsSelector(apiRef);
177
+ var currentPage = getVisibleRows(apiRef, {
178
+ pagination: props.pagination,
179
+ paginationMode: props.paginationMode
180
+ });
181
+ var pinnedRows = gridPinnedRowsSelector(apiRef);
182
+
183
+ // Include pinned rows as well
184
+ var currentPageRows = [].concat(pinnedRows.top || [], currentPage.rows, pinnedRows.bottom || []);
185
+ var rowIndexToFocus = currentPageRows.findIndex(function (row) {
186
+ return row.id === id;
187
+ });
142
188
  if (direction === 'right') {
143
189
  columnIndexToFocus += 1;
144
190
  } else if (direction === 'left') {
@@ -146,14 +192,10 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
146
192
  } else {
147
193
  rowIndexToFocus += 1;
148
194
  }
149
- var currentPage = getVisibleRows(apiRef, {
150
- pagination: props.pagination,
151
- paginationMode: props.paginationMode
152
- });
153
195
  if (columnIndexToFocus >= visibleColumns.length) {
154
196
  // Go to next row if we are after the last column
155
197
  rowIndexToFocus += 1;
156
- if (rowIndexToFocus < currentPage.rows.length) {
198
+ if (rowIndexToFocus < currentPageRows.length) {
157
199
  // Go to first column of the next row if there's one more row
158
200
  columnIndexToFocus = 0;
159
201
  }
@@ -165,8 +207,11 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
165
207
  columnIndexToFocus = visibleColumns.length - 1;
166
208
  }
167
209
  }
168
- rowIndexToFocus = clamp(rowIndexToFocus, 0, currentPage.rows.length - 1);
169
- var rowToFocus = currentPage.rows[rowIndexToFocus];
210
+ rowIndexToFocus = clamp(rowIndexToFocus, 0, currentPageRows.length - 1);
211
+ var rowToFocus = currentPageRows[rowIndexToFocus];
212
+ if (!rowToFocus) {
213
+ return;
214
+ }
170
215
  var colSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowToFocus.id, columnIndexToFocus);
171
216
  if (colSpanInfo && colSpanInfo.spannedByColSpan) {
172
217
  if (direction === 'left' || direction === 'below') {
@@ -218,6 +263,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
218
263
  focus: {
219
264
  cell: null,
220
265
  columnHeader: null,
266
+ columnHeaderFilter: null,
221
267
  columnGroupHeader: null
222
268
  }
223
269
  });
@@ -258,6 +304,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
258
304
  focus: {
259
305
  cell: null,
260
306
  columnHeader: null,
307
+ columnHeaderFilter: null,
261
308
  columnGroupHeader: null
262
309
  }
263
310
  });
@@ -288,6 +335,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
288
335
  focus: {
289
336
  cell: null,
290
337
  columnHeader: null,
338
+ columnHeaderFilter: null,
291
339
  columnGroupHeader: null
292
340
  }
293
341
  });
@@ -296,7 +344,8 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
296
344
  }, [apiRef]);
297
345
  var focusApi = {
298
346
  setCellFocus: setCellFocus,
299
- setColumnHeaderFocus: setColumnHeaderFocus
347
+ setColumnHeaderFocus: setColumnHeaderFocus,
348
+ setColumnHeaderFilterFocus: setColumnHeaderFilterFocus
300
349
  };
301
350
  var focusPrivateApi = {
302
351
  moveFocusToRelativeCell: moveFocusToRelativeCell,
@@ -0,0 +1,11 @@
1
+ /* eslint-disable @typescript-eslint/naming-convention */
2
+ import { createSelector } from '../../../utils/createSelector';
3
+ export var unstable_gridHeaderFilteringStateSelector = function unstable_gridHeaderFilteringStateSelector(state) {
4
+ return state.headerFiltering;
5
+ };
6
+ export var unstable_gridHeaderFilteringEditFieldSelector = createSelector(unstable_gridHeaderFilteringStateSelector, function (headerFilteringState) {
7
+ return headerFilteringState.editing;
8
+ });
9
+ export var unstable_gridHeaderFilteringMenuSelector = createSelector(unstable_gridHeaderFilteringStateSelector, function (headerFilteringState) {
10
+ return headerFilteringState.menuOpen;
11
+ });
@@ -0,0 +1 @@
1
+ export * from './gridHeaderFilteringSelectors';
@@ -0,0 +1,93 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import { useGridApiMethod } from '../../utils/useGridApiMethod';
4
+ import { useGridLogger } from '../../utils';
5
+ import { gridColumnLookupSelector, gridColumnVisibilityModelSelector, gridColumnFieldsSelector } from '../columns/gridColumnsSelector';
6
+ export var headerFilteringStateInitializer = function headerFilteringStateInitializer(state) {
7
+ return _extends({}, state, {
8
+ headerFiltering: {
9
+ editing: null,
10
+ menuOpen: null
11
+ }
12
+ });
13
+ };
14
+ export var useGridHeaderFiltering = function useGridHeaderFiltering(apiRef, props) {
15
+ var logger = useGridLogger(apiRef, 'useGridHeaderFiltering');
16
+ var setHeaderFilterState = React.useCallback(function (headerFilterState) {
17
+ apiRef.current.setState(function (state) {
18
+ var _headerFilterState$ed, _headerFilterState$me;
19
+ // Safety check to avoid MIT users from using it
20
+ // This hook should ultimately be moved to the Pro package
21
+ if (props.signature === 'DataGrid') {
22
+ return state;
23
+ }
24
+ return _extends({}, state, {
25
+ headerFiltering: {
26
+ editing: (_headerFilterState$ed = headerFilterState.editing) != null ? _headerFilterState$ed : null,
27
+ menuOpen: (_headerFilterState$me = headerFilterState.menuOpen) != null ? _headerFilterState$me : null
28
+ }
29
+ });
30
+ });
31
+ apiRef.current.forceUpdate();
32
+ }, [apiRef, props.signature]);
33
+ var startHeaderFilterEditMode = React.useCallback(function (field) {
34
+ logger.debug("Starting edit mode on header filter for field: ".concat(field));
35
+ apiRef.current.setHeaderFilterState({
36
+ editing: field
37
+ });
38
+ }, [apiRef, logger]);
39
+ var stopHeaderFilterEditMode = React.useCallback(function () {
40
+ logger.debug("Stopping edit mode on header filter");
41
+ apiRef.current.setHeaderFilterState({
42
+ editing: null
43
+ });
44
+ }, [apiRef, logger]);
45
+ var showHeaderFilterMenu = React.useCallback(function (field) {
46
+ logger.debug("Opening header filter menu for field: ".concat(field));
47
+ apiRef.current.setHeaderFilterState({
48
+ menuOpen: field
49
+ });
50
+ }, [apiRef, logger]);
51
+ var hideHeaderFilterMenu = React.useCallback(function () {
52
+ logger.debug("Hiding header filter menu for active field");
53
+ var fieldToFocus = apiRef.current.state.headerFiltering.menuOpen;
54
+ if (fieldToFocus) {
55
+ var columnLookup = gridColumnLookupSelector(apiRef);
56
+ var columnVisibilityModel = gridColumnVisibilityModelSelector(apiRef);
57
+ var orderedFields = gridColumnFieldsSelector(apiRef);
58
+
59
+ // If the column was removed from the grid, we need to find the closest visible field
60
+ if (!columnLookup[fieldToFocus]) {
61
+ fieldToFocus = orderedFields[0];
62
+ }
63
+
64
+ // If the field to focus is hidden, we need to find the closest visible field
65
+ if (columnVisibilityModel[fieldToFocus] === false) {
66
+ // contains visible column fields + the field that was just hidden
67
+ var visibleOrderedFields = orderedFields.filter(function (field) {
68
+ if (field === fieldToFocus) {
69
+ return true;
70
+ }
71
+ return columnVisibilityModel[field] !== false;
72
+ });
73
+ var fieldIndex = visibleOrderedFields.indexOf(fieldToFocus);
74
+ fieldToFocus = visibleOrderedFields[fieldIndex + 1] || visibleOrderedFields[fieldIndex - 1];
75
+ }
76
+ apiRef.current.setHeaderFilterState({
77
+ menuOpen: null
78
+ });
79
+ apiRef.current.setColumnHeaderFilterFocus(fieldToFocus);
80
+ }
81
+ }, [apiRef, logger]);
82
+ var headerFilterPrivateApi = {
83
+ setHeaderFilterState: setHeaderFilterState
84
+ };
85
+ var headerFilterApi = {
86
+ startHeaderFilterEditMode: startHeaderFilterEditMode,
87
+ stopHeaderFilterEditMode: stopHeaderFilterEditMode,
88
+ showHeaderFilterMenu: showHeaderFilterMenu,
89
+ hideHeaderFilterMenu: hideHeaderFilterMenu
90
+ };
91
+ useGridApiMethod(apiRef, headerFilterApi, 'public');
92
+ useGridApiMethod(apiRef, headerFilterPrivateApi, 'private');
93
+ };
@@ -11,4 +11,5 @@ export * from './rows';
11
11
  export * from './rowSelection';
12
12
  export * from './sorting';
13
13
  export * from './dimensions';
14
- export * from './statePersistence';
14
+ export * from './statePersistence';
15
+ export * from './headerFiltering';