@mui/x-data-grid 6.3.1 → 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 (349) hide show
  1. package/CHANGELOG.md +113 -0
  2. package/DataGrid/DataGrid.js +20 -1
  3. package/DataGrid/useDataGridComponent.js +2 -2
  4. package/DataGrid/useDataGridProps.js +8 -13
  5. package/colDef/gridBooleanColDef.js +19 -1
  6. package/colDef/gridDateColDef.js +6 -2
  7. package/colDef/gridNumericOperators.js +0 -6
  8. package/colDef/gridSingleSelectColDef.js +21 -1
  9. package/components/base/GridBody.js +2 -1
  10. package/components/cell/GridEditInputCell.js +4 -1
  11. package/components/containers/GridRootStyles.js +1 -0
  12. package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +15 -2
  13. package/components/panel/filterPanel/GridFilterInputBoolean.js +80 -36
  14. package/components/panel/filterPanel/GridFilterInputDate.d.ts +8 -1
  15. package/components/panel/filterPanel/GridFilterInputDate.js +27 -6
  16. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
  17. package/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
  18. package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +8 -1
  19. package/components/panel/filterPanel/GridFilterInputSingleSelect.js +55 -32
  20. package/components/panel/filterPanel/GridFilterInputValue.d.ts +11 -4
  21. package/components/panel/filterPanel/GridFilterInputValue.js +29 -6
  22. package/components/panel/filterPanel/GridFilterPanel.d.ts +2 -1
  23. package/components/panel/filterPanel/GridFilterPanel.js +1 -1
  24. package/components/panel/filterPanel/index.d.ts +3 -1
  25. package/components/panel/filterPanel/index.js +2 -1
  26. package/constants/localeTextConstants.js +26 -0
  27. package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +12 -1
  28. package/hooks/features/clipboard/useGridClipboard.d.ts +2 -1
  29. package/hooks/features/clipboard/useGridClipboard.js +43 -26
  30. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +9 -2
  31. package/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -2
  32. package/hooks/features/dimensions/useGridDimensions.js +4 -6
  33. package/hooks/features/editing/useGridCellEditing.js +7 -3
  34. package/hooks/features/editing/useGridEditing.js +0 -3
  35. package/hooks/features/editing/useGridRowEditing.js +7 -3
  36. package/hooks/features/export/serializers/csvSerializer.d.ts +5 -0
  37. package/hooks/features/export/serializers/csvSerializer.js +46 -6
  38. package/hooks/features/export/useGridCsvExport.d.ts +2 -1
  39. package/hooks/features/export/useGridCsvExport.js +7 -5
  40. package/hooks/features/focus/gridFocusState.d.ts +2 -0
  41. package/hooks/features/focus/gridFocusStateSelector.d.ts +2 -0
  42. package/hooks/features/focus/gridFocusStateSelector.js +6 -0
  43. package/hooks/features/focus/useGridFocus.js +55 -9
  44. package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.d.ts +4 -0
  45. package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +5 -0
  46. package/hooks/features/headerFiltering/index.d.ts +1 -0
  47. package/hooks/features/headerFiltering/index.js +1 -0
  48. package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +6 -0
  49. package/hooks/features/headerFiltering/useGridHeaderFiltering.js +91 -0
  50. package/hooks/features/index.d.ts +1 -0
  51. package/hooks/features/index.js +2 -1
  52. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
  53. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +124 -4
  54. package/hooks/features/rows/useGridRows.js +16 -1
  55. package/index.js +1 -1
  56. package/internals/index.d.ts +9 -3
  57. package/internals/index.js +7 -2
  58. package/internals/utils/index.d.ts +1 -0
  59. package/internals/utils/index.js +2 -1
  60. package/internals/utils/useProps.d.ts +8 -0
  61. package/internals/utils/useProps.js +13 -0
  62. package/joy/icons.d.ts +33 -0
  63. package/joy/icons.js +433 -0
  64. package/joy/joySlots.js +114 -4
  65. package/legacy/DataGrid/DataGrid.js +20 -1
  66. package/legacy/DataGrid/useDataGridComponent.js +2 -2
  67. package/legacy/DataGrid/useDataGridProps.js +11 -9
  68. package/legacy/colDef/gridBooleanColDef.js +21 -1
  69. package/legacy/colDef/gridDateColDef.js +10 -2
  70. package/legacy/colDef/gridNumericOperators.js +0 -6
  71. package/legacy/colDef/gridSingleSelectColDef.js +21 -1
  72. package/legacy/components/base/GridBody.js +2 -1
  73. package/legacy/components/cell/GridEditInputCell.js +4 -1
  74. package/legacy/components/containers/GridRootStyles.js +1 -0
  75. package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +79 -35
  76. package/legacy/components/panel/filterPanel/GridFilterInputDate.js +26 -5
  77. package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
  78. package/legacy/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
  79. package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +54 -31
  80. package/legacy/components/panel/filterPanel/GridFilterInputValue.js +28 -5
  81. package/legacy/components/panel/filterPanel/GridFilterPanel.js +1 -1
  82. package/legacy/components/panel/filterPanel/index.js +2 -1
  83. package/legacy/constants/localeTextConstants.js +26 -0
  84. package/legacy/hooks/features/clipboard/useGridClipboard.js +44 -26
  85. package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +5 -5
  86. package/legacy/hooks/features/dimensions/useGridDimensions.js +4 -6
  87. package/legacy/hooks/features/editing/useGridCellEditing.js +7 -3
  88. package/legacy/hooks/features/editing/useGridEditing.js +0 -3
  89. package/legacy/hooks/features/editing/useGridRowEditing.js +7 -3
  90. package/legacy/hooks/features/export/serializers/csvSerializer.js +43 -6
  91. package/legacy/hooks/features/export/useGridCsvExport.js +8 -5
  92. package/legacy/hooks/features/focus/gridFocusStateSelector.js +10 -0
  93. package/legacy/hooks/features/focus/useGridFocus.js +58 -9
  94. package/legacy/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +11 -0
  95. package/legacy/hooks/features/headerFiltering/index.js +1 -0
  96. package/legacy/hooks/features/headerFiltering/useGridHeaderFiltering.js +93 -0
  97. package/legacy/hooks/features/index.js +2 -1
  98. package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +123 -4
  99. package/legacy/hooks/features/rows/useGridRows.js +16 -1
  100. package/legacy/index.js +1 -1
  101. package/legacy/internals/index.js +7 -2
  102. package/legacy/internals/utils/index.js +2 -1
  103. package/legacy/internals/utils/useProps.js +11 -0
  104. package/legacy/joy/icons.js +432 -0
  105. package/legacy/joy/joySlots.js +118 -4
  106. package/legacy/locales/arSD.js +28 -0
  107. package/legacy/locales/beBY.js +28 -0
  108. package/legacy/locales/bgBG.js +28 -0
  109. package/legacy/locales/csCZ.js +36 -8
  110. package/legacy/locales/daDK.js +28 -0
  111. package/legacy/locales/deDE.js +30 -2
  112. package/legacy/locales/elGR.js +27 -0
  113. package/legacy/locales/esES.js +28 -0
  114. package/legacy/locales/faIR.js +28 -0
  115. package/legacy/locales/fiFI.js +28 -0
  116. package/legacy/locales/frFR.js +34 -6
  117. package/legacy/locales/heIL.js +30 -2
  118. package/legacy/locales/huHU.js +28 -0
  119. package/legacy/locales/itIT.js +28 -0
  120. package/legacy/locales/jaJP.js +28 -0
  121. package/legacy/locales/koKR.js +28 -0
  122. package/legacy/locales/nbNO.js +28 -0
  123. package/legacy/locales/nlNL.js +28 -0
  124. package/legacy/locales/plPL.js +28 -0
  125. package/legacy/locales/ptBR.js +29 -1
  126. package/legacy/locales/roRO.js +28 -0
  127. package/legacy/locales/ruRU.js +28 -0
  128. package/legacy/locales/skSK.js +28 -0
  129. package/legacy/locales/svSE.js +28 -0
  130. package/legacy/locales/trTR.js +28 -0
  131. package/legacy/locales/ukUA.js +36 -9
  132. package/legacy/locales/urPK.js +28 -0
  133. package/legacy/locales/viVN.js +27 -0
  134. package/legacy/locales/zhCN.js +28 -0
  135. package/legacy/locales/zhTW.js +28 -0
  136. package/legacy/material/index.js +5 -1
  137. package/legacy/models/api/index.js +0 -1
  138. package/legacy/models/index.js +0 -1
  139. package/legacy/utils/domUtils.js +14 -1
  140. package/locales/arSD.js +28 -0
  141. package/locales/beBY.js +28 -0
  142. package/locales/bgBG.js +28 -0
  143. package/locales/csCZ.js +36 -8
  144. package/locales/daDK.js +28 -0
  145. package/locales/deDE.js +30 -2
  146. package/locales/elGR.js +27 -0
  147. package/locales/esES.js +28 -0
  148. package/locales/faIR.js +28 -0
  149. package/locales/fiFI.js +28 -0
  150. package/locales/frFR.js +34 -6
  151. package/locales/heIL.js +30 -2
  152. package/locales/huHU.js +28 -0
  153. package/locales/itIT.js +28 -0
  154. package/locales/jaJP.js +28 -0
  155. package/locales/koKR.js +28 -0
  156. package/locales/nbNO.js +28 -0
  157. package/locales/nlNL.js +28 -0
  158. package/locales/plPL.js +28 -0
  159. package/locales/ptBR.js +29 -1
  160. package/locales/roRO.js +28 -0
  161. package/locales/ruRU.js +28 -0
  162. package/locales/skSK.js +28 -0
  163. package/locales/svSE.js +28 -0
  164. package/locales/trTR.js +28 -0
  165. package/locales/ukUA.js +36 -9
  166. package/locales/urPK.js +28 -0
  167. package/locales/viVN.js +27 -0
  168. package/locales/zhCN.js +28 -0
  169. package/locales/zhTW.js +28 -0
  170. package/material/index.d.ts +3 -65
  171. package/material/index.js +5 -1
  172. package/models/api/gridApiCommon.d.ts +3 -3
  173. package/models/api/gridCoreApi.d.ts +8 -0
  174. package/models/api/gridFocusApi.d.ts +6 -0
  175. package/models/api/gridHeaderFilteringApi.d.ts +30 -0
  176. package/models/api/gridLocaleTextApi.d.ts +25 -0
  177. package/models/api/index.d.ts +0 -1
  178. package/models/api/index.js +0 -1
  179. package/models/events/gridEventLookup.d.ts +33 -1
  180. package/models/gridFilterOperator.d.ts +4 -0
  181. package/models/gridHeaderFilteringModel.d.ts +5 -0
  182. package/models/gridHeaderFilteringModel.js +1 -0
  183. package/models/gridSlotsComponent.d.ts +21 -4
  184. package/models/gridSlotsComponentsProps.d.ts +4 -0
  185. package/models/gridStateCommunity.d.ts +2 -0
  186. package/models/index.d.ts +1 -1
  187. package/models/index.js +0 -1
  188. package/models/props/DataGridProps.d.ts +19 -0
  189. package/modern/DataGrid/DataGrid.js +20 -1
  190. package/modern/DataGrid/useDataGridComponent.js +2 -2
  191. package/modern/DataGrid/useDataGridProps.js +8 -13
  192. package/modern/colDef/gridBooleanColDef.js +19 -1
  193. package/modern/colDef/gridDateColDef.js +6 -2
  194. package/modern/colDef/gridNumericOperators.js +0 -6
  195. package/modern/colDef/gridSingleSelectColDef.js +21 -1
  196. package/modern/components/base/GridBody.js +2 -1
  197. package/modern/components/cell/GridEditInputCell.js +4 -1
  198. package/modern/components/containers/GridRootStyles.js +1 -0
  199. package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +80 -36
  200. package/modern/components/panel/filterPanel/GridFilterInputDate.js +27 -6
  201. package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
  202. package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
  203. package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +55 -32
  204. package/modern/components/panel/filterPanel/GridFilterInputValue.js +29 -6
  205. package/modern/components/panel/filterPanel/GridFilterPanel.js +1 -1
  206. package/modern/components/panel/filterPanel/index.js +2 -1
  207. package/modern/constants/localeTextConstants.js +26 -0
  208. package/modern/hooks/features/clipboard/useGridClipboard.js +43 -26
  209. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -2
  210. package/modern/hooks/features/dimensions/useGridDimensions.js +3 -5
  211. package/modern/hooks/features/editing/useGridCellEditing.js +7 -3
  212. package/modern/hooks/features/editing/useGridEditing.js +0 -3
  213. package/modern/hooks/features/editing/useGridRowEditing.js +7 -3
  214. package/modern/hooks/features/export/serializers/csvSerializer.js +44 -6
  215. package/modern/hooks/features/export/useGridCsvExport.js +7 -5
  216. package/modern/hooks/features/focus/gridFocusStateSelector.js +6 -0
  217. package/modern/hooks/features/focus/useGridFocus.js +55 -9
  218. package/modern/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +5 -0
  219. package/modern/hooks/features/headerFiltering/index.js +1 -0
  220. package/modern/hooks/features/headerFiltering/useGridHeaderFiltering.js +90 -0
  221. package/modern/hooks/features/index.js +2 -1
  222. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +124 -4
  223. package/modern/hooks/features/rows/useGridRows.js +16 -1
  224. package/modern/index.js +1 -1
  225. package/modern/internals/index.js +7 -2
  226. package/modern/internals/utils/index.js +2 -1
  227. package/modern/internals/utils/useProps.js +13 -0
  228. package/modern/joy/icons.js +433 -0
  229. package/modern/joy/joySlots.js +110 -4
  230. package/modern/locales/arSD.js +28 -0
  231. package/modern/locales/beBY.js +28 -0
  232. package/modern/locales/bgBG.js +28 -0
  233. package/modern/locales/csCZ.js +36 -8
  234. package/modern/locales/daDK.js +28 -0
  235. package/modern/locales/deDE.js +30 -2
  236. package/modern/locales/elGR.js +27 -0
  237. package/modern/locales/esES.js +28 -0
  238. package/modern/locales/faIR.js +28 -0
  239. package/modern/locales/fiFI.js +28 -0
  240. package/modern/locales/frFR.js +34 -6
  241. package/modern/locales/heIL.js +30 -2
  242. package/modern/locales/huHU.js +28 -0
  243. package/modern/locales/itIT.js +28 -0
  244. package/modern/locales/jaJP.js +28 -0
  245. package/modern/locales/koKR.js +28 -0
  246. package/modern/locales/nbNO.js +28 -0
  247. package/modern/locales/nlNL.js +28 -0
  248. package/modern/locales/plPL.js +28 -0
  249. package/modern/locales/ptBR.js +29 -1
  250. package/modern/locales/roRO.js +28 -0
  251. package/modern/locales/ruRU.js +28 -0
  252. package/modern/locales/skSK.js +28 -0
  253. package/modern/locales/svSE.js +28 -0
  254. package/modern/locales/trTR.js +28 -0
  255. package/modern/locales/ukUA.js +36 -9
  256. package/modern/locales/urPK.js +28 -0
  257. package/modern/locales/viVN.js +27 -0
  258. package/modern/locales/zhCN.js +28 -0
  259. package/modern/locales/zhTW.js +28 -0
  260. package/modern/material/index.js +5 -1
  261. package/modern/models/api/gridHeaderFilteringApi.js +1 -0
  262. package/modern/models/api/index.js +0 -1
  263. package/modern/models/gridHeaderFilteringModel.js +1 -0
  264. package/modern/models/index.js +0 -1
  265. package/modern/utils/domUtils.js +13 -1
  266. package/node/DataGrid/DataGrid.js +20 -1
  267. package/node/DataGrid/useDataGridComponent.js +2 -2
  268. package/node/DataGrid/useDataGridProps.js +7 -12
  269. package/node/colDef/gridBooleanColDef.js +19 -1
  270. package/node/colDef/gridDateColDef.js +6 -2
  271. package/node/colDef/gridNumericOperators.js +0 -6
  272. package/node/colDef/gridSingleSelectColDef.js +21 -1
  273. package/node/components/base/GridBody.js +2 -1
  274. package/node/components/cell/GridEditInputCell.js +4 -1
  275. package/node/components/containers/GridRootStyles.js +1 -0
  276. package/node/components/panel/filterPanel/GridFilterInputBoolean.js +78 -35
  277. package/node/components/panel/filterPanel/GridFilterInputDate.js +27 -6
  278. package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
  279. package/node/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
  280. package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +55 -32
  281. package/node/components/panel/filterPanel/GridFilterInputValue.js +29 -6
  282. package/node/components/panel/filterPanel/GridFilterPanel.js +2 -1
  283. package/node/components/panel/filterPanel/index.js +26 -8
  284. package/node/constants/localeTextConstants.js +26 -0
  285. package/node/hooks/features/clipboard/useGridClipboard.js +42 -25
  286. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -2
  287. package/node/hooks/features/dimensions/useGridDimensions.js +3 -5
  288. package/node/hooks/features/editing/useGridCellEditing.js +7 -3
  289. package/node/hooks/features/editing/useGridEditing.js +0 -3
  290. package/node/hooks/features/editing/useGridRowEditing.js +7 -3
  291. package/node/hooks/features/export/serializers/csvSerializer.js +46 -6
  292. package/node/hooks/features/export/useGridCsvExport.js +6 -3
  293. package/node/hooks/features/focus/gridFocusStateSelector.js +9 -1
  294. package/node/hooks/features/focus/useGridFocus.js +55 -9
  295. package/node/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +15 -0
  296. package/node/hooks/features/headerFiltering/index.js +16 -0
  297. package/node/hooks/features/headerFiltering/useGridHeaderFiltering.js +101 -0
  298. package/node/hooks/features/index.js +11 -0
  299. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +124 -4
  300. package/node/hooks/features/rows/useGridRows.js +16 -1
  301. package/node/index.js +1 -1
  302. package/node/internals/index.js +69 -1
  303. package/node/internals/utils/index.js +11 -0
  304. package/node/internals/utils/useProps.js +22 -0
  305. package/node/joy/icons.js +471 -0
  306. package/node/joy/joySlots.js +110 -3
  307. package/node/locales/arSD.js +28 -0
  308. package/node/locales/beBY.js +28 -0
  309. package/node/locales/bgBG.js +28 -0
  310. package/node/locales/csCZ.js +36 -8
  311. package/node/locales/daDK.js +28 -0
  312. package/node/locales/deDE.js +30 -2
  313. package/node/locales/elGR.js +27 -0
  314. package/node/locales/esES.js +28 -0
  315. package/node/locales/faIR.js +28 -0
  316. package/node/locales/fiFI.js +28 -0
  317. package/node/locales/frFR.js +34 -6
  318. package/node/locales/heIL.js +30 -2
  319. package/node/locales/huHU.js +28 -0
  320. package/node/locales/itIT.js +28 -0
  321. package/node/locales/jaJP.js +28 -0
  322. package/node/locales/koKR.js +28 -0
  323. package/node/locales/nbNO.js +28 -0
  324. package/node/locales/nlNL.js +28 -0
  325. package/node/locales/plPL.js +28 -0
  326. package/node/locales/ptBR.js +29 -1
  327. package/node/locales/roRO.js +28 -0
  328. package/node/locales/ruRU.js +28 -0
  329. package/node/locales/skSK.js +28 -0
  330. package/node/locales/svSE.js +28 -0
  331. package/node/locales/trTR.js +28 -0
  332. package/node/locales/ukUA.js +36 -9
  333. package/node/locales/urPK.js +28 -0
  334. package/node/locales/viVN.js +27 -0
  335. package/node/locales/zhCN.js +28 -0
  336. package/node/locales/zhTW.js +28 -0
  337. package/node/material/index.js +5 -1
  338. package/node/models/api/index.js +0 -11
  339. package/node/models/gridHeaderFilteringModel.js +5 -0
  340. package/node/models/index.js +0 -11
  341. package/node/utils/domUtils.js +15 -1
  342. package/package.json +1 -1
  343. package/utils/domUtils.d.ts +1 -0
  344. package/utils/domUtils.js +13 -1
  345. package/models/api/gridClipboardApi.d.ts +0 -11
  346. /package/legacy/models/api/{gridClipboardApi.js → gridHeaderFilteringApi.js} +0 -0
  347. /package/{models/api/gridClipboardApi.js → legacy/models/gridHeaderFilteringModel.js} +0 -0
  348. /package/{modern/models/api/gridClipboardApi.js → models/api/gridHeaderFilteringApi.js} +0 -0
  349. /package/node/models/api/{gridClipboardApi.js → gridHeaderFilteringApi.js} +0 -0
@@ -29,9 +29,6 @@ export const useGridEditing = (apiRef, props) => {
29
29
  if (isCellEditableProp) {
30
30
  return isCellEditableProp(params);
31
31
  }
32
- if (params.rowNode.type === 'pinnedRow') {
33
- return false;
34
- }
35
32
  return true;
36
33
  }, [isCellEditableProp]);
37
34
  const maybeDebounce = (id, field, debounceMs, callback) => {
@@ -143,10 +143,14 @@ export const useGridRowEditing = (apiRef, props) => {
143
143
  }
144
144
  } else if (params.isEditable) {
145
145
  let reason;
146
- if (event.key === ' ') {
147
- return; // Space scrolls to the last row
146
+ const canStartEditing = apiRef.current.unstable_applyPipeProcessors('canStartEditing', true, {
147
+ event,
148
+ cellParams: params,
149
+ editMode: 'row'
150
+ });
151
+ if (!canStartEditing) {
152
+ return;
148
153
  }
149
-
150
154
  if (isPrintableKey(event)) {
151
155
  reason = GridRowEditStartReasons.printableKeyDown;
152
156
  } else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
@@ -1,6 +1,6 @@
1
1
  import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../../../../colDef';
2
2
  import { buildWarning } from '../../../../utils/warning';
3
- const serializeCellValue = (value, delimiterCharacter) => {
3
+ function sanitizeCellValue(value, delimiterCharacter) {
4
4
  if (typeof value === 'string') {
5
5
  const formattedValue = value.replace(/"/g, '""');
6
6
 
@@ -11,16 +11,47 @@ const serializeCellValue = (value, delimiterCharacter) => {
11
11
  return formattedValue;
12
12
  }
13
13
  return value;
14
+ }
15
+ export const serializeCellValue = (cellParams, options) => {
16
+ const {
17
+ delimiterCharacter,
18
+ ignoreValueFormatter
19
+ } = options;
20
+ let value;
21
+ if (ignoreValueFormatter) {
22
+ const columnType = cellParams.colDef.type;
23
+ if (columnType === 'number') {
24
+ value = String(cellParams.value);
25
+ } else if (columnType === 'date' || columnType === 'dateTime') {
26
+ value = cellParams.value?.toISOString();
27
+ } else if (typeof cellParams.value?.toString === 'function') {
28
+ value = cellParams.value.toString();
29
+ } else {
30
+ value = cellParams.value;
31
+ }
32
+ } else {
33
+ value = cellParams.formattedValue;
34
+ }
35
+ return sanitizeCellValue(value, delimiterCharacter);
14
36
  };
15
37
  const objectFormattedValueWarning = buildWarning(['MUI: When the value of a field is an object or a `renderCell` is provided, the CSV export might not display the value correctly.', 'You can provide a `valueFormatter` with a string representation to be used.']);
16
- const serializeRow = (id, columns, getCellParams, delimiterCharacter) => columns.map(column => {
38
+ const serializeRow = ({
39
+ id,
40
+ columns,
41
+ getCellParams,
42
+ delimiterCharacter,
43
+ ignoreValueFormatter
44
+ }) => columns.map(column => {
17
45
  const cellParams = getCellParams(id, column.field);
18
46
  if (process.env.NODE_ENV !== 'production') {
19
47
  if (String(cellParams.formattedValue) === '[object Object]') {
20
48
  objectFormattedValueWarning();
21
49
  }
22
50
  }
23
- return serializeCellValue(cellParams.formattedValue, delimiterCharacter);
51
+ return serializeCellValue(cellParams, {
52
+ delimiterCharacter,
53
+ ignoreValueFormatter
54
+ });
24
55
  });
25
56
  export function buildCSV(options) {
26
57
  const {
@@ -28,12 +59,19 @@ export function buildCSV(options) {
28
59
  rowIds,
29
60
  getCellParams,
30
61
  delimiterCharacter,
31
- includeHeaders
62
+ includeHeaders,
63
+ ignoreValueFormatter
32
64
  } = options;
33
- const CSVBody = rowIds.reduce((acc, id) => `${acc}${serializeRow(id, columns, getCellParams, delimiterCharacter).join(delimiterCharacter)}\r\n`, '').trim();
65
+ const CSVBody = rowIds.reduce((acc, id) => `${acc}${serializeRow({
66
+ id,
67
+ columns,
68
+ getCellParams,
69
+ delimiterCharacter,
70
+ ignoreValueFormatter
71
+ }).join(delimiterCharacter)}\r\n`, '').trim();
34
72
  if (!includeHeaders) {
35
73
  return CSVBody;
36
74
  }
37
- const CSVHead = `${columns.filter(column => column.field !== GRID_CHECKBOX_SELECTION_COL_DEF.field).map(column => serializeCellValue(column.headerName || column.field, delimiterCharacter)).join(delimiterCharacter)}\r\n`;
75
+ const CSVHead = `${columns.filter(column => column.field !== GRID_CHECKBOX_SELECTION_COL_DEF.field).map(column => sanitizeCellValue(column.headerName || column.field, delimiterCharacter)).join(delimiterCharacter)}\r\n`;
38
76
  return `${CSVHead}${CSVBody}`.trim();
39
77
  }
@@ -6,7 +6,7 @@ import { buildCSV } from './serializers/csvSerializer';
6
6
  import { getColumnsToExport, defaultGetRowsToExport } from './utils';
7
7
  import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
8
8
  import { GridCsvExportMenuItem } from '../../../components/toolbar/GridToolbarExport';
9
-
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
10
  /**
11
11
  * @requires useGridColumns (state)
12
12
  * @requires useGridFilter (state)
@@ -14,9 +14,10 @@ import { GridCsvExportMenuItem } from '../../../components/toolbar/GridToolbarEx
14
14
  * @requires useGridSelection (state)
15
15
  * @requires useGridParamsApi (method)
16
16
  */
17
- import { jsx as _jsx } from "react/jsx-runtime";
18
- export const useGridCsvExport = apiRef => {
17
+ export const useGridCsvExport = (apiRef, props) => {
19
18
  const logger = useGridLogger(apiRef, 'useGridCsvExport');
19
+ const ignoreValueFormatterProp = props.unstable_ignoreValueFormatterDuringExport;
20
+ const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp?.csvExport : ignoreValueFormatterProp) || false;
20
21
  const getDataAsCsv = React.useCallback((options = {}) => {
21
22
  logger.debug(`Get data as CSV`);
22
23
  const exportedColumns = getColumnsToExport({
@@ -32,9 +33,10 @@ export const useGridCsvExport = apiRef => {
32
33
  rowIds: exportedRowIds,
33
34
  getCellParams: apiRef.current.getCellParams,
34
35
  delimiterCharacter: options.delimiter || ',',
35
- includeHeaders: options.includeHeaders ?? true
36
+ includeHeaders: options.includeHeaders ?? true,
37
+ ignoreValueFormatter
36
38
  });
37
- }, [logger, apiRef]);
39
+ }, [logger, apiRef, ignoreValueFormatter]);
38
40
  const exportDataAsCsv = React.useCallback(options => {
39
41
  logger.debug(`Export data as CSV`);
40
42
  const csv = getDataAsCsv(options);
@@ -3,11 +3,17 @@ export const gridFocusStateSelector = state => state.focus;
3
3
  export const gridFocusCellSelector = createSelector(gridFocusStateSelector, focusState => focusState.cell);
4
4
  export const gridFocusColumnHeaderSelector = createSelector(gridFocusStateSelector, focusState => focusState.columnHeader);
5
5
 
6
+ // eslint-disable-next-line @typescript-eslint/naming-convention
7
+ export const unstable_gridFocusColumnHeaderFilterSelector = createSelector(gridFocusStateSelector, focusState => focusState.columnHeaderFilter);
8
+
6
9
  // eslint-disable-next-line @typescript-eslint/naming-convention
7
10
  export const unstable_gridFocusColumnGroupHeaderSelector = createSelector(gridFocusStateSelector, focusState => focusState.columnGroupHeader);
8
11
  export const gridTabIndexStateSelector = state => state.tabIndex;
9
12
  export const gridTabIndexCellSelector = createSelector(gridTabIndexStateSelector, state => state.cell);
10
13
  export const gridTabIndexColumnHeaderSelector = createSelector(gridTabIndexStateSelector, state => state.columnHeader);
11
14
 
15
+ // eslint-disable-next-line @typescript-eslint/naming-convention
16
+ export const unstable_gridTabIndexColumnHeaderFilterSelector = createSelector(gridTabIndexStateSelector, state => state.columnHeaderFilter);
17
+
12
18
  // eslint-disable-next-line @typescript-eslint/naming-convention
13
19
  export const unstable_gridTabIndexColumnGroupHeaderSelector = createSelector(gridTabIndexStateSelector, state => state.columnGroupHeader);
@@ -9,15 +9,18 @@ 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 const focusStateInitializer = state => _extends({}, state, {
13
14
  focus: {
14
15
  cell: null,
15
16
  columnHeader: null,
17
+ columnHeaderFilter: null,
16
18
  columnGroupHeader: null
17
19
  },
18
20
  tabIndex: {
19
21
  cell: null,
20
22
  columnHeader: null,
23
+ columnHeaderFilter: null,
21
24
  columnGroupHeader: null
22
25
  }
23
26
  });
@@ -52,6 +55,7 @@ export const useGridFocus = (apiRef, props) => {
52
55
  field
53
56
  },
54
57
  columnHeader: null,
58
+ columnHeaderFilter: null,
55
59
  columnGroupHeader: null
56
60
  },
57
61
  focus: {
@@ -60,6 +64,7 @@ export const useGridFocus = (apiRef, props) => {
60
64
  field
61
65
  },
62
66
  columnHeader: null,
67
+ columnHeaderFilter: null,
63
68
  columnGroupHeader: null
64
69
  }
65
70
  });
@@ -87,6 +92,7 @@ export const useGridFocus = (apiRef, props) => {
87
92
  columnHeader: {
88
93
  field
89
94
  },
95
+ columnHeaderFilter: null,
90
96
  cell: null,
91
97
  columnGroupHeader: null
92
98
  },
@@ -94,6 +100,33 @@ export const useGridFocus = (apiRef, props) => {
94
100
  columnHeader: {
95
101
  field
96
102
  },
103
+ columnHeaderFilter: null,
104
+ cell: null,
105
+ columnGroupHeader: null
106
+ }
107
+ });
108
+ });
109
+ apiRef.current.forceUpdate();
110
+ }, [apiRef, logger, publishCellFocusOut]);
111
+ const setColumnHeaderFilterFocus = React.useCallback((field, event = {}) => {
112
+ const cell = gridFocusCellSelector(apiRef);
113
+ publishCellFocusOut(cell, event);
114
+ apiRef.current.setState(state => {
115
+ logger.debug(`Focusing on column header filter with colIndex=${field}`);
116
+ return _extends({}, state, {
117
+ tabIndex: {
118
+ columnHeader: null,
119
+ columnHeaderFilter: {
120
+ field
121
+ },
122
+ cell: null,
123
+ columnGroupHeader: null
124
+ },
125
+ focus: {
126
+ columnHeader: null,
127
+ columnHeaderFilter: {
128
+ field
129
+ },
97
130
  cell: null,
98
131
  columnGroupHeader: null
99
132
  }
@@ -114,6 +147,7 @@ export const useGridFocus = (apiRef, props) => {
114
147
  depth
115
148
  },
116
149
  columnHeader: null,
150
+ columnHeaderFilter: null,
117
151
  cell: null
118
152
  },
119
153
  focus: {
@@ -122,6 +156,7 @@ export const useGridFocus = (apiRef, props) => {
122
156
  depth
123
157
  },
124
158
  columnHeader: null,
159
+ columnHeaderFilter: null,
125
160
  cell: null
126
161
  }
127
162
  });
@@ -131,8 +166,16 @@ export const useGridFocus = (apiRef, props) => {
131
166
  const getColumnGroupHeaderFocus = React.useCallback(() => unstable_gridFocusColumnGroupHeaderSelector(apiRef), [apiRef]);
132
167
  const moveFocusToRelativeCell = React.useCallback((id, field, direction) => {
133
168
  let columnIndexToFocus = apiRef.current.getColumnIndex(field);
134
- let rowIndexToFocus = apiRef.current.getRowIndexRelativeToVisibleRows(id);
135
169
  const visibleColumns = gridVisibleColumnDefinitionsSelector(apiRef);
170
+ const currentPage = getVisibleRows(apiRef, {
171
+ pagination: props.pagination,
172
+ paginationMode: props.paginationMode
173
+ });
174
+ const pinnedRows = gridPinnedRowsSelector(apiRef);
175
+
176
+ // Include pinned rows as well
177
+ const currentPageRows = [].concat(pinnedRows.top || [], currentPage.rows, pinnedRows.bottom || []);
178
+ let rowIndexToFocus = currentPageRows.findIndex(row => row.id === id);
136
179
  if (direction === 'right') {
137
180
  columnIndexToFocus += 1;
138
181
  } else if (direction === 'left') {
@@ -140,14 +183,10 @@ export const useGridFocus = (apiRef, props) => {
140
183
  } else {
141
184
  rowIndexToFocus += 1;
142
185
  }
143
- const currentPage = getVisibleRows(apiRef, {
144
- pagination: props.pagination,
145
- paginationMode: props.paginationMode
146
- });
147
186
  if (columnIndexToFocus >= visibleColumns.length) {
148
187
  // Go to next row if we are after the last column
149
188
  rowIndexToFocus += 1;
150
- if (rowIndexToFocus < currentPage.rows.length) {
189
+ if (rowIndexToFocus < currentPageRows.length) {
151
190
  // Go to first column of the next row if there's one more row
152
191
  columnIndexToFocus = 0;
153
192
  }
@@ -159,8 +198,11 @@ export const useGridFocus = (apiRef, props) => {
159
198
  columnIndexToFocus = visibleColumns.length - 1;
160
199
  }
161
200
  }
162
- rowIndexToFocus = clamp(rowIndexToFocus, 0, currentPage.rows.length - 1);
163
- const rowToFocus = currentPage.rows[rowIndexToFocus];
201
+ rowIndexToFocus = clamp(rowIndexToFocus, 0, currentPageRows.length - 1);
202
+ const rowToFocus = currentPageRows[rowIndexToFocus];
203
+ if (!rowToFocus) {
204
+ return;
205
+ }
164
206
  const colSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowToFocus.id, columnIndexToFocus);
165
207
  if (colSpanInfo && colSpanInfo.spannedByColSpan) {
166
208
  if (direction === 'left' || direction === 'below') {
@@ -214,6 +256,7 @@ export const useGridFocus = (apiRef, props) => {
214
256
  focus: {
215
257
  cell: null,
216
258
  columnHeader: null,
259
+ columnHeaderFilter: null,
217
260
  columnGroupHeader: null
218
261
  }
219
262
  }));
@@ -252,6 +295,7 @@ export const useGridFocus = (apiRef, props) => {
252
295
  focus: {
253
296
  cell: null,
254
297
  columnHeader: null,
298
+ columnHeaderFilter: null,
255
299
  columnGroupHeader: null
256
300
  }
257
301
  }));
@@ -280,6 +324,7 @@ export const useGridFocus = (apiRef, props) => {
280
324
  focus: {
281
325
  cell: null,
282
326
  columnHeader: null,
327
+ columnHeaderFilter: null,
283
328
  columnGroupHeader: null
284
329
  }
285
330
  }));
@@ -287,7 +332,8 @@ export const useGridFocus = (apiRef, props) => {
287
332
  }, [apiRef]);
288
333
  const focusApi = {
289
334
  setCellFocus,
290
- setColumnHeaderFocus
335
+ setColumnHeaderFocus,
336
+ setColumnHeaderFilterFocus
291
337
  };
292
338
  const focusPrivateApi = {
293
339
  moveFocusToRelativeCell,
@@ -0,0 +1,5 @@
1
+ /* eslint-disable @typescript-eslint/naming-convention */
2
+ import { createSelector } from '../../../utils/createSelector';
3
+ export const unstable_gridHeaderFilteringStateSelector = state => state.headerFiltering;
4
+ export const unstable_gridHeaderFilteringEditFieldSelector = createSelector(unstable_gridHeaderFilteringStateSelector, headerFilteringState => headerFilteringState.editing);
5
+ export const unstable_gridHeaderFilteringMenuSelector = createSelector(unstable_gridHeaderFilteringStateSelector, headerFilteringState => headerFilteringState.menuOpen);
@@ -0,0 +1 @@
1
+ export * from './gridHeaderFilteringSelectors';
@@ -0,0 +1,90 @@
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 const headerFilteringStateInitializer = state => _extends({}, state, {
7
+ headerFiltering: {
8
+ editing: null,
9
+ menuOpen: null
10
+ }
11
+ });
12
+ export const useGridHeaderFiltering = (apiRef, props) => {
13
+ const logger = useGridLogger(apiRef, 'useGridHeaderFiltering');
14
+ const setHeaderFilterState = React.useCallback(headerFilterState => {
15
+ apiRef.current.setState(state => {
16
+ // Safety check to avoid MIT users from using it
17
+ // This hook should ultimately be moved to the Pro package
18
+ if (props.signature === 'DataGrid') {
19
+ return state;
20
+ }
21
+ return _extends({}, state, {
22
+ headerFiltering: {
23
+ editing: headerFilterState.editing ?? null,
24
+ menuOpen: headerFilterState.menuOpen ?? null
25
+ }
26
+ });
27
+ });
28
+ apiRef.current.forceUpdate();
29
+ }, [apiRef, props.signature]);
30
+ const startHeaderFilterEditMode = React.useCallback(field => {
31
+ logger.debug(`Starting edit mode on header filter for field: ${field}`);
32
+ apiRef.current.setHeaderFilterState({
33
+ editing: field
34
+ });
35
+ }, [apiRef, logger]);
36
+ const stopHeaderFilterEditMode = React.useCallback(() => {
37
+ logger.debug(`Stopping edit mode on header filter`);
38
+ apiRef.current.setHeaderFilterState({
39
+ editing: null
40
+ });
41
+ }, [apiRef, logger]);
42
+ const showHeaderFilterMenu = React.useCallback(field => {
43
+ logger.debug(`Opening header filter menu for field: ${field}`);
44
+ apiRef.current.setHeaderFilterState({
45
+ menuOpen: field
46
+ });
47
+ }, [apiRef, logger]);
48
+ const hideHeaderFilterMenu = React.useCallback(() => {
49
+ logger.debug(`Hiding header filter menu for active field`);
50
+ let fieldToFocus = apiRef.current.state.headerFiltering.menuOpen;
51
+ if (fieldToFocus) {
52
+ const columnLookup = gridColumnLookupSelector(apiRef);
53
+ const columnVisibilityModel = gridColumnVisibilityModelSelector(apiRef);
54
+ const orderedFields = gridColumnFieldsSelector(apiRef);
55
+
56
+ // If the column was removed from the grid, we need to find the closest visible field
57
+ if (!columnLookup[fieldToFocus]) {
58
+ fieldToFocus = orderedFields[0];
59
+ }
60
+
61
+ // If the field to focus is hidden, we need to find the closest visible field
62
+ if (columnVisibilityModel[fieldToFocus] === false) {
63
+ // contains visible column fields + the field that was just hidden
64
+ const visibleOrderedFields = orderedFields.filter(field => {
65
+ if (field === fieldToFocus) {
66
+ return true;
67
+ }
68
+ return columnVisibilityModel[field] !== false;
69
+ });
70
+ const fieldIndex = visibleOrderedFields.indexOf(fieldToFocus);
71
+ fieldToFocus = visibleOrderedFields[fieldIndex + 1] || visibleOrderedFields[fieldIndex - 1];
72
+ }
73
+ apiRef.current.setHeaderFilterState({
74
+ menuOpen: null
75
+ });
76
+ apiRef.current.setColumnHeaderFilterFocus(fieldToFocus);
77
+ }
78
+ }, [apiRef, logger]);
79
+ const headerFilterPrivateApi = {
80
+ setHeaderFilterState
81
+ };
82
+ const headerFilterApi = {
83
+ startHeaderFilterEditMode,
84
+ stopHeaderFilterEditMode,
85
+ showHeaderFilterMenu,
86
+ hideHeaderFilterMenu
87
+ };
88
+ useGridApiMethod(apiRef, headerFilterApi, 'public');
89
+ useGridApiMethod(apiRef, headerFilterPrivateApi, 'private');
90
+ };
@@ -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';
@@ -14,6 +14,8 @@ import { gridPinnedRowsSelector } from '../rows/gridRowsSelector';
14
14
  import { unstable_gridFocusColumnGroupHeaderSelector } from '../focus';
15
15
  import { gridColumnGroupsHeaderMaxDepthSelector } from '../columnGrouping/gridColumnGroupsSelector';
16
16
  import { useGridSelector } from '../../utils/useGridSelector';
17
+ import { unstable_gridHeaderFilteringEditFieldSelector, unstable_gridHeaderFilteringMenuSelector } from '../headerFiltering/gridHeaderFilteringSelectors';
18
+ import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
17
19
  function enrichPageRowsWithPinnedRows(apiRef, rows) {
18
20
  const pinnedRows = gridPinnedRowsSelector(apiRef) || {};
19
21
  return [...(pinnedRows.top || []), ...rows, ...(pinnedRows.bottom || [])];
@@ -67,6 +69,9 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
67
69
  const initialCurrentPageRows = useGridVisibleRows(apiRef, props).rows;
68
70
  const theme = useTheme();
69
71
  const currentPageRows = React.useMemo(() => enrichPageRowsWithPinnedRows(apiRef, initialCurrentPageRows), [apiRef, initialCurrentPageRows]);
72
+ const headerFilteringEnabled =
73
+ // @ts-expect-error // TODO move relevant code to the `DataGridPro`
74
+ props.signature !== 'DataGrid' && props.unstable_headerFilters;
70
75
 
71
76
  /**
72
77
  * @param {number} colIndex Index of the column to focus
@@ -103,6 +108,14 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
103
108
  const field = apiRef.current.getVisibleColumns()[colIndex].field;
104
109
  apiRef.current.setColumnHeaderFocus(field, event);
105
110
  }, [apiRef, logger]);
111
+ const goToHeaderFilter = React.useCallback((colIndex, event) => {
112
+ logger.debug(`Navigating to header filter col ${colIndex}`);
113
+ apiRef.current.scrollToIndexes({
114
+ colIndex
115
+ });
116
+ const field = apiRef.current.getVisibleColumns()[colIndex].field;
117
+ apiRef.current.setColumnHeaderFilterFocus(field, event);
118
+ }, [apiRef, logger]);
106
119
  const goToGroupHeader = React.useCallback((colIndex, depth, event) => {
107
120
  logger.debug(`Navigating to header col ${colIndex}`);
108
121
  apiRef.current.scrollToIndexes({
@@ -114,7 +127,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
114
127
  apiRef.current.setColumnGroupHeaderFocus(field, depth, event);
115
128
  }, [apiRef, logger]);
116
129
  const getRowIdFromIndex = React.useCallback(rowIndex => {
117
- return currentPageRows[rowIndex].id;
130
+ return currentPageRows?.[rowIndex].id;
118
131
  }, [currentPageRows]);
119
132
  const handleColumnHeaderKeyDown = React.useCallback((params, event) => {
120
133
  const headerTitleNode = event.currentTarget.querySelector(`.${gridClasses.columnHeaderTitleContainerContent}`);
@@ -140,7 +153,11 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
140
153
  case 'ArrowDown':
141
154
  {
142
155
  if (firstRowIndexInPage !== null) {
143
- goToCell(colIndexBefore, getRowIdFromIndex(firstRowIndexInPage));
156
+ if (headerFilteringEnabled) {
157
+ goToHeaderFilter(colIndexBefore, event);
158
+ } else {
159
+ goToCell(colIndexBefore, getRowIdFromIndex(firstRowIndexInPage));
160
+ }
144
161
  }
145
162
  break;
146
163
  }
@@ -214,7 +231,97 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
214
231
  if (shouldPreventDefault) {
215
232
  event.preventDefault();
216
233
  }
217
- }, [apiRef, currentPageRows.length, theme.direction, goToCell, getRowIdFromIndex, goToHeader, goToGroupHeader]);
234
+ }, [apiRef, currentPageRows.length, headerFilteringEnabled, goToHeaderFilter, goToCell, getRowIdFromIndex, theme.direction, goToHeader, goToGroupHeader]);
235
+ const handleHeaderFilterKeyDown = React.useCallback((params, event) => {
236
+ const dimensions = apiRef.current.getRootDimensions();
237
+ if (!dimensions) {
238
+ return;
239
+ }
240
+ const isEditing = unstable_gridHeaderFilteringEditFieldSelector(apiRef) === params.field;
241
+ const isHeaderMenuOpen = unstable_gridHeaderFilteringMenuSelector(apiRef) === params.field;
242
+ if (isEditing || isHeaderMenuOpen || !isNavigationKey(event.key)) {
243
+ return;
244
+ }
245
+ const viewportPageSize = apiRef.current.getViewportPageSize();
246
+ const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
247
+ const firstRowIndexInPage = 0;
248
+ const lastRowIndexInPage = currentPageRows.length - 1;
249
+ const firstColIndex = 0;
250
+ const lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
251
+ let shouldPreventDefault = true;
252
+ switch (event.key) {
253
+ case 'ArrowDown':
254
+ {
255
+ const rowId = getRowIdFromIndex(firstRowIndexInPage);
256
+ if (firstRowIndexInPage !== null && rowId != null) {
257
+ goToCell(colIndexBefore, rowId);
258
+ }
259
+ break;
260
+ }
261
+ case 'ArrowRight':
262
+ {
263
+ const rightColIndex = getRightColumnIndex({
264
+ currentColIndex: colIndexBefore,
265
+ firstColIndex,
266
+ lastColIndex,
267
+ direction: theme.direction
268
+ });
269
+ if (rightColIndex !== null) {
270
+ goToHeaderFilter(rightColIndex, event);
271
+ }
272
+ break;
273
+ }
274
+ case 'ArrowLeft':
275
+ {
276
+ const leftColIndex = getLeftColumnIndex({
277
+ currentColIndex: colIndexBefore,
278
+ firstColIndex,
279
+ lastColIndex,
280
+ direction: theme.direction
281
+ });
282
+ if (leftColIndex !== null) {
283
+ goToHeaderFilter(leftColIndex, event);
284
+ } else {
285
+ apiRef.current.setColumnHeaderFilterFocus(params.field, event);
286
+ }
287
+ break;
288
+ }
289
+ case 'ArrowUp':
290
+ {
291
+ goToHeader(colIndexBefore, event);
292
+ break;
293
+ }
294
+ case 'PageDown':
295
+ {
296
+ if (firstRowIndexInPage !== null && lastRowIndexInPage !== null) {
297
+ goToCell(colIndexBefore, getRowIdFromIndex(Math.min(firstRowIndexInPage + viewportPageSize, lastRowIndexInPage)));
298
+ }
299
+ break;
300
+ }
301
+ case 'Home':
302
+ {
303
+ goToHeaderFilter(firstColIndex, event);
304
+ break;
305
+ }
306
+ case 'End':
307
+ {
308
+ goToHeaderFilter(lastColIndex, event);
309
+ break;
310
+ }
311
+ case ' ':
312
+ {
313
+ // prevent Space event from scrolling
314
+ break;
315
+ }
316
+ default:
317
+ {
318
+ shouldPreventDefault = false;
319
+ }
320
+ }
321
+ if (shouldPreventDefault) {
322
+ event.preventDefault();
323
+ }
324
+ }, [apiRef, currentPageRows.length, goToHeaderFilter, theme.direction, goToHeader, goToCell, getRowIdFromIndex]);
218
325
  const focusedColumnGroup = useGridSelector(apiRef, unstable_gridFocusColumnGroupHeaderSelector);
219
326
  const handleColumnGroupHeaderKeyDown = React.useCallback((params, event) => {
220
327
  const dimensions = apiRef.current.getRootDimensions();
@@ -349,6 +456,8 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
349
456
  {
350
457
  if (rowIndexBefore > firstRowIndexInPage) {
351
458
  goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore - 1));
459
+ } else if (headerFilteringEnabled) {
460
+ goToHeaderFilter(colIndexBefore, event);
352
461
  } else {
353
462
  goToHeader(colIndexBefore, event);
354
463
  }
@@ -449,8 +558,19 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
449
558
  if (shouldPreventDefault) {
450
559
  event.preventDefault();
451
560
  }
452
- }, [apiRef, currentPageRows, theme.direction, getRowIdFromIndex, goToCell, goToHeader]);
561
+ }, [apiRef, currentPageRows, theme.direction, goToCell, getRowIdFromIndex, headerFilteringEnabled, goToHeaderFilter, goToHeader]);
562
+ const checkIfCanStartEditing = React.useCallback((initialValue, {
563
+ event
564
+ }) => {
565
+ if (event.key === ' ') {
566
+ // Space scrolls to the last row
567
+ return false;
568
+ }
569
+ return initialValue;
570
+ }, []);
571
+ useGridRegisterPipeProcessor(apiRef, 'canStartEditing', checkIfCanStartEditing);
453
572
  useGridApiEventHandler(apiRef, 'columnHeaderKeyDown', handleColumnHeaderKeyDown);
573
+ useGridApiEventHandler(apiRef, 'headerFilterKeyDown', handleHeaderFilterKeyDown);
454
574
  useGridApiEventHandler(apiRef, 'columnGroupHeaderKeyDown', handleColumnGroupHeaderKeyDown);
455
575
  useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
456
576
  };
@@ -115,8 +115,23 @@ export const useGridRows = (apiRef, props) => {
115
115
  if (props.signature === GridSignature.DataGrid && updates.length > 1) {
116
116
  throw new Error(["MUI: You can't update several rows at once in `apiRef.current.updateRows` on the DataGrid.", 'You need to upgrade to DataGridPro or DataGridPremium component to unlock this feature.'].join('\n'));
117
117
  }
118
+ const nonPinnedRowsUpdates = [];
119
+ updates.forEach(update => {
120
+ const id = getRowIdFromRowModel(update, props.getRowId, 'A row was provided without id when calling updateRows():');
121
+ const rowNode = apiRef.current.getRowNode(id);
122
+ if (rowNode?.type === 'pinnedRow') {
123
+ // @ts-ignore because otherwise `release:build` doesn't work
124
+ const pinnedRowsCache = apiRef.current.caches.pinnedRows;
125
+ const prevModel = pinnedRowsCache.idLookup[id];
126
+ if (prevModel) {
127
+ pinnedRowsCache.idLookup[id] = _extends({}, prevModel, update);
128
+ }
129
+ } else {
130
+ nonPinnedRowsUpdates.push(update);
131
+ }
132
+ });
118
133
  const cache = updateCacheWithNewRows({
119
- updates,
134
+ updates: nonPinnedRowsUpdates,
120
135
  getRowId: props.getRowId,
121
136
  previousCache: apiRef.current.caches.rows
122
137
  });
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.3.1
2
+ * @mui/x-data-grid v6.5.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the