@mui/x-data-grid 6.0.0-alpha.2 → 6.0.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (293) hide show
  1. package/CHANGELOG.md +493 -141
  2. package/DataGrid/DataGrid.js +14 -34
  3. package/DataGrid/useDataGridComponent.js +8 -14
  4. package/DataGrid/useDataGridProps.js +3 -3
  5. package/colDef/gridCheckboxSelectionColDef.js +1 -1
  6. package/colDef/gridNumericOperators.d.ts +1 -1
  7. package/colDef/gridSingleSelectOperators.d.ts +1 -1
  8. package/colDef/gridStringOperators.d.ts +1 -1
  9. package/components/GridFooter.js +1 -1
  10. package/components/GridRow.js +2 -2
  11. package/components/base/GridBody.js +2 -2
  12. package/components/cell/GridEditInputCell.js +3 -8
  13. package/components/cell/GridEditSingleSelectCell.js +6 -38
  14. package/components/columnHeaders/GridColumnGroupHeader.d.ts +2 -0
  15. package/components/columnHeaders/GridColumnGroupHeader.js +32 -5
  16. package/components/columnSelection/GridHeaderCheckbox.js +3 -3
  17. package/components/containers/GridRoot.js +4 -3
  18. package/components/panel/GridColumnsPanel.d.ts +2 -0
  19. package/components/panel/GridColumnsPanel.js +10 -4
  20. package/components/panel/filterPanel/GridFilterForm.d.ts +12 -0
  21. package/components/panel/filterPanel/GridFilterForm.js +29 -7
  22. package/components/panel/filterPanel/GridFilterPanel.d.ts +12 -0
  23. package/components/panel/filterPanel/GridFilterPanel.js +64 -19
  24. package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +1 -1
  25. package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +1 -1
  26. package/hooks/core/strategyProcessing/useGridRegisterStrategyProcessor.d.ts +1 -1
  27. package/hooks/core/useGridInitialization.d.ts +1 -1
  28. package/hooks/core/useGridStateInitialization.d.ts +1 -1
  29. package/hooks/features/columnGrouping/gridColumnGroupsInterfaces.d.ts +10 -1
  30. package/hooks/features/columnGrouping/gridColumnGroupsSelector.d.ts +6 -0
  31. package/hooks/features/columnGrouping/gridColumnGroupsSelector.js +34 -1
  32. package/hooks/features/columnGrouping/gridColumnGroupsUtils.d.ts +15 -0
  33. package/hooks/features/columnGrouping/gridColumnGroupsUtils.js +89 -0
  34. package/hooks/features/columnGrouping/useGridColumnGrouping.d.ts +1 -15
  35. package/hooks/features/columnGrouping/useGridColumnGrouping.js +66 -66
  36. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
  37. package/hooks/features/columnHeaders/useGridColumnHeaders.js +60 -116
  38. package/hooks/features/density/densitySelector.d.ts +0 -2
  39. package/hooks/features/density/densitySelector.js +1 -3
  40. package/hooks/features/density/densityState.d.ts +0 -1
  41. package/hooks/features/density/useGridDensity.d.ts +1 -1
  42. package/hooks/features/density/useGridDensity.js +9 -45
  43. package/hooks/features/dimensions/useGridDimensions.js +3 -2
  44. package/hooks/features/{editRows/gridEditRowsSelector.d.ts → editing/gridEditingSelectors.d.ts} +0 -0
  45. package/hooks/features/{editRows/gridEditRowsSelector.js → editing/gridEditingSelectors.js} +0 -0
  46. package/hooks/features/editing/index.d.ts +1 -0
  47. package/hooks/features/editing/index.js +1 -0
  48. package/hooks/features/{editRows/useGridCellEditing.new.d.ts → editing/useGridCellEditing.d.ts} +0 -0
  49. package/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js} +21 -6
  50. package/hooks/features/{editRows/useGridEditing.new.d.ts → editing/useGridEditing.d.ts} +0 -0
  51. package/hooks/features/{editRows/useGridEditing.new.js → editing/useGridEditing.js} +3 -3
  52. package/hooks/features/{editRows/useGridRowEditing.new.d.ts → editing/useGridRowEditing.d.ts} +0 -0
  53. package/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js} +20 -6
  54. package/hooks/features/export/useGridPrintExport.js +2 -2
  55. package/hooks/features/focus/gridFocusState.d.ts +6 -0
  56. package/hooks/features/focus/gridFocusStateSelector.d.ts +2 -0
  57. package/hooks/features/focus/gridFocusStateSelector.js +6 -2
  58. package/hooks/features/focus/useGridFocus.js +69 -11
  59. package/hooks/features/index.d.ts +2 -2
  60. package/hooks/features/index.js +2 -2
  61. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +135 -1
  62. package/hooks/features/{selection/gridSelectionSelector.d.ts → rowSelection/gridRowSelectionSelector.d.ts} +1 -1
  63. package/hooks/features/rowSelection/gridRowSelectionSelector.js +9 -0
  64. package/hooks/features/rowSelection/index.d.ts +1 -0
  65. package/hooks/features/rowSelection/index.js +1 -0
  66. package/hooks/features/rowSelection/useGridRowSelection.d.ts +12 -0
  67. package/hooks/features/{selection/useGridSelection.js → rowSelection/useGridRowSelection.js} +37 -37
  68. package/hooks/features/{selection/useGridSelectionPreProcessors.d.ts → rowSelection/useGridRowSelectionPreProcessors.d.ts} +1 -1
  69. package/hooks/features/{selection/useGridSelectionPreProcessors.js → rowSelection/useGridRowSelectionPreProcessors.js} +1 -1
  70. package/hooks/features/rows/gridRowsInterfaces.d.ts +4 -0
  71. package/hooks/features/rows/gridRowsUtils.d.ts +1 -1
  72. package/hooks/features/rows/gridRowsUtils.js +5 -2
  73. package/hooks/features/rows/useGridRows.js +23 -7
  74. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
  75. package/hooks/features/virtualization/useGridVirtualScroller.js +2 -2
  76. package/hooks/utils/useGridApi.d.ts +1 -1
  77. package/hooks/utils/useGridApiEventHandler.d.ts +2 -2
  78. package/hooks/utils/useGridApiRef.d.ts +1 -1
  79. package/hooks/utils/useGridInitializeState.d.ts +1 -1
  80. package/hooks/utils/useGridNativeEventListener.d.ts +1 -1
  81. package/hooks/utils/useGridSelector.d.ts +1 -1
  82. package/hooks/utils/useGridState.d.ts +1 -1
  83. package/hooks/utils/useGridVisibleRows.d.ts +2 -2
  84. package/index.js +1 -1
  85. package/internals/index.d.ts +3 -5
  86. package/internals/index.js +3 -5
  87. package/legacy/DataGrid/DataGrid.js +14 -34
  88. package/legacy/DataGrid/useDataGridComponent.js +8 -14
  89. package/legacy/DataGrid/useDataGridProps.js +3 -3
  90. package/legacy/colDef/gridCheckboxSelectionColDef.js +1 -1
  91. package/legacy/components/GridFooter.js +1 -1
  92. package/legacy/components/GridRow.js +2 -2
  93. package/legacy/components/base/GridBody.js +2 -2
  94. package/legacy/components/cell/GridEditInputCell.js +3 -8
  95. package/legacy/components/cell/GridEditSingleSelectCell.js +6 -52
  96. package/legacy/components/columnHeaders/GridColumnGroupHeader.js +46 -13
  97. package/legacy/components/columnSelection/GridHeaderCheckbox.js +3 -3
  98. package/legacy/components/containers/GridRoot.js +4 -3
  99. package/legacy/components/panel/GridColumnsPanel.js +10 -3
  100. package/legacy/components/panel/filterPanel/GridFilterForm.js +31 -7
  101. package/legacy/components/panel/filterPanel/GridFilterPanel.js +67 -18
  102. package/legacy/hooks/features/columnGrouping/gridColumnGroupsSelector.js +33 -1
  103. package/legacy/hooks/features/columnGrouping/gridColumnGroupsUtils.js +96 -0
  104. package/legacy/hooks/features/columnGrouping/useGridColumnGrouping.js +64 -64
  105. package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +70 -122
  106. package/legacy/hooks/features/density/densitySelector.js +0 -6
  107. package/legacy/hooks/features/density/useGridDensity.js +6 -44
  108. package/legacy/hooks/features/dimensions/useGridDimensions.js +3 -2
  109. package/legacy/hooks/features/{editRows/gridEditRowsSelector.js → editing/gridEditingSelectors.js} +0 -0
  110. package/legacy/hooks/features/editing/index.js +1 -0
  111. package/legacy/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js} +21 -6
  112. package/legacy/hooks/features/{editRows/useGridEditing.new.js → editing/useGridEditing.js} +3 -3
  113. package/legacy/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js} +20 -6
  114. package/legacy/hooks/features/export/useGridPrintExport.js +2 -2
  115. package/legacy/hooks/features/focus/gridFocusStateSelector.js +8 -0
  116. package/legacy/hooks/features/focus/useGridFocus.js +72 -11
  117. package/legacy/hooks/features/index.js +2 -2
  118. package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +129 -1
  119. package/legacy/hooks/features/rowSelection/gridRowSelectionSelector.js +19 -0
  120. package/legacy/hooks/features/rowSelection/index.js +1 -0
  121. package/legacy/hooks/features/{selection/useGridSelection.js → rowSelection/useGridRowSelection.js} +37 -37
  122. package/legacy/hooks/features/{selection/useGridSelectionPreProcessors.js → rowSelection/useGridRowSelectionPreProcessors.js} +1 -1
  123. package/legacy/hooks/features/rows/gridRowsUtils.js +5 -2
  124. package/legacy/hooks/features/rows/useGridRows.js +25 -7
  125. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +2 -2
  126. package/legacy/index.js +1 -1
  127. package/legacy/internals/index.js +3 -5
  128. package/legacy/locales/trTR.js +17 -17
  129. package/legacy/models/api/{gridSelectionApi.js → gridRowSelectionApi.js} +0 -0
  130. package/legacy/models/api/index.js +1 -1
  131. package/legacy/models/{gridSelectionModel.js → gridRowSelectionModel.js} +0 -0
  132. package/legacy/models/index.js +1 -1
  133. package/{models/api/gridSelectionApi.js → legacy/models/params/gridColumnGroupHeaderParams.js} +0 -0
  134. package/legacy/models/params/gridEditCellParams.js +0 -4
  135. package/legacy/models/params/index.js +1 -0
  136. package/locales/trTR.js +17 -17
  137. package/models/api/gridApiCommon.d.ts +3 -6
  138. package/models/api/gridApiCommunity.d.ts +1 -7
  139. package/models/api/gridEditingApi.d.ts +36 -121
  140. package/models/api/gridFocusApi.d.ts +13 -0
  141. package/models/api/{gridSelectionApi.d.ts → gridRowSelectionApi.d.ts} +2 -2
  142. package/models/{gridSelectionModel.js → api/gridRowSelectionApi.js} +0 -0
  143. package/models/api/index.d.ts +2 -2
  144. package/models/api/index.js +1 -1
  145. package/models/colDef/gridColDef.d.ts +0 -8
  146. package/models/events/gridEventLookup.d.ts +30 -19
  147. package/models/gridColumnGrouping.d.ts +1 -26
  148. package/models/gridRowSelectionModel.d.ts +3 -0
  149. package/{modern/models/api/gridSelectionApi.js → models/gridRowSelectionModel.js} +0 -0
  150. package/models/gridStateCommunity.d.ts +2 -2
  151. package/models/index.d.ts +1 -1
  152. package/models/index.js +1 -1
  153. package/models/params/gridColumnGroupHeaderParams.d.ts +30 -0
  154. package/{modern/models/gridSelectionModel.js → models/params/gridColumnGroupHeaderParams.js} +0 -0
  155. package/models/params/gridEditCellParams.d.ts +4 -17
  156. package/models/params/gridEditCellParams.js +0 -4
  157. package/models/params/gridRowParams.d.ts +4 -4
  158. package/models/params/index.d.ts +1 -0
  159. package/models/params/index.js +1 -0
  160. package/models/props/DataGridProps.d.ts +8 -32
  161. package/modern/DataGrid/DataGrid.js +14 -34
  162. package/modern/DataGrid/useDataGridComponent.js +8 -12
  163. package/modern/DataGrid/useDataGridProps.js +3 -3
  164. package/modern/colDef/gridCheckboxSelectionColDef.js +1 -1
  165. package/modern/components/GridFooter.js +1 -1
  166. package/modern/components/GridRow.js +2 -2
  167. package/modern/components/base/GridBody.js +2 -2
  168. package/modern/components/cell/GridEditInputCell.js +3 -4
  169. package/modern/components/cell/GridEditSingleSelectCell.js +6 -34
  170. package/modern/components/columnHeaders/GridColumnGroupHeader.js +32 -5
  171. package/modern/components/columnSelection/GridHeaderCheckbox.js +3 -3
  172. package/modern/components/containers/GridRoot.js +4 -3
  173. package/modern/components/panel/GridColumnsPanel.js +10 -4
  174. package/modern/components/panel/filterPanel/GridFilterForm.js +29 -7
  175. package/modern/components/panel/filterPanel/GridFilterPanel.js +62 -17
  176. package/modern/hooks/features/columnGrouping/gridColumnGroupsSelector.js +14 -1
  177. package/modern/hooks/features/columnGrouping/gridColumnGroupsUtils.js +83 -0
  178. package/modern/hooks/features/columnGrouping/useGridColumnGrouping.js +50 -62
  179. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +58 -98
  180. package/modern/hooks/features/density/densitySelector.js +1 -3
  181. package/modern/hooks/features/density/useGridDensity.js +9 -37
  182. package/modern/hooks/features/dimensions/useGridDimensions.js +3 -2
  183. package/modern/hooks/features/{editRows/gridEditRowsSelector.js → editing/gridEditingSelectors.js} +0 -0
  184. package/modern/hooks/features/editing/index.js +1 -0
  185. package/modern/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js} +21 -6
  186. package/modern/hooks/features/{editRows/useGridEditing.new.js → editing/useGridEditing.js} +3 -3
  187. package/modern/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js} +20 -6
  188. package/modern/hooks/features/export/useGridPrintExport.js +2 -2
  189. package/modern/hooks/features/focus/gridFocusStateSelector.js +6 -2
  190. package/modern/hooks/features/focus/useGridFocus.js +69 -11
  191. package/modern/hooks/features/index.js +2 -2
  192. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +135 -1
  193. package/modern/hooks/features/rowSelection/gridRowSelectionSelector.js +9 -0
  194. package/modern/hooks/features/rowSelection/index.js +1 -0
  195. package/modern/hooks/features/{selection/useGridSelection.js → rowSelection/useGridRowSelection.js} +37 -37
  196. package/modern/hooks/features/{selection/useGridSelectionPreProcessors.js → rowSelection/useGridRowSelectionPreProcessors.js} +1 -1
  197. package/modern/hooks/features/rows/gridRowsUtils.js +5 -2
  198. package/modern/hooks/features/rows/useGridRows.js +23 -7
  199. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +2 -2
  200. package/modern/index.js +1 -1
  201. package/modern/internals/index.js +3 -5
  202. package/modern/locales/trTR.js +17 -17
  203. package/modern/models/api/gridRowSelectionApi.js +1 -0
  204. package/modern/models/api/index.js +1 -1
  205. package/modern/models/gridRowSelectionModel.js +1 -0
  206. package/modern/models/index.js +1 -1
  207. package/modern/models/params/gridColumnGroupHeaderParams.js +1 -0
  208. package/modern/models/params/gridEditCellParams.js +0 -4
  209. package/modern/models/params/index.js +1 -0
  210. package/node/DataGrid/DataGrid.js +14 -34
  211. package/node/DataGrid/useDataGridComponent.js +9 -17
  212. package/node/DataGrid/useDataGridProps.js +3 -3
  213. package/node/colDef/gridCheckboxSelectionColDef.js +2 -2
  214. package/node/components/GridFooter.js +2 -2
  215. package/node/components/GridRow.js +2 -2
  216. package/node/components/base/GridBody.js +2 -2
  217. package/node/components/cell/GridEditInputCell.js +3 -9
  218. package/node/components/cell/GridEditSingleSelectCell.js +6 -38
  219. package/node/components/columnHeaders/GridColumnGroupHeader.js +32 -5
  220. package/node/components/columnSelection/GridHeaderCheckbox.js +3 -3
  221. package/node/components/containers/GridRoot.js +4 -2
  222. package/node/components/panel/GridColumnsPanel.js +10 -4
  223. package/node/components/panel/filterPanel/GridFilterForm.js +30 -7
  224. package/node/components/panel/filterPanel/GridFilterPanel.js +63 -19
  225. package/node/hooks/features/columnGrouping/gridColumnGroupsSelector.js +40 -3
  226. package/node/hooks/features/columnGrouping/gridColumnGroupsUtils.js +102 -0
  227. package/node/hooks/features/columnGrouping/useGridColumnGrouping.js +68 -71
  228. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +57 -113
  229. package/node/hooks/features/density/densitySelector.js +2 -6
  230. package/node/hooks/features/density/useGridDensity.js +9 -48
  231. package/node/hooks/features/dimensions/useGridDimensions.js +3 -1
  232. package/node/hooks/features/{editRows/gridEditRowsSelector.js → editing/gridEditingSelectors.js} +0 -0
  233. package/node/hooks/features/{editRows → editing}/index.js +4 -4
  234. package/node/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js} +28 -13
  235. package/node/hooks/features/{editRows/useGridEditing.new.js → editing/useGridEditing.js} +4 -4
  236. package/node/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js} +28 -14
  237. package/node/hooks/features/export/useGridPrintExport.js +2 -2
  238. package/node/hooks/features/focus/gridFocusStateSelector.js +10 -4
  239. package/node/hooks/features/focus/useGridFocus.js +68 -10
  240. package/node/hooks/features/index.js +8 -8
  241. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +138 -1
  242. package/node/hooks/features/{selection/gridSelectionSelector.js → rowSelection/gridRowSelectionSelector.js} +6 -6
  243. package/node/hooks/features/rowSelection/index.js +18 -0
  244. package/node/hooks/features/{selection/useGridSelection.js → rowSelection/useGridRowSelection.js} +43 -43
  245. package/node/hooks/features/{selection/useGridSelectionPreProcessors.js → rowSelection/useGridRowSelectionPreProcessors.js} +3 -3
  246. package/node/hooks/features/rows/gridRowsUtils.js +5 -2
  247. package/node/hooks/features/rows/useGridRows.js +23 -7
  248. package/node/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
  249. package/node/index.js +1 -1
  250. package/node/internals/index.js +23 -45
  251. package/node/locales/trTR.js +17 -17
  252. package/node/models/api/{gridSelectionApi.js → gridRowSelectionApi.js} +0 -0
  253. package/node/models/api/index.js +4 -4
  254. package/node/models/{gridSelectionModel.js → gridRowSelectionModel.js} +0 -0
  255. package/node/models/index.js +4 -4
  256. package/node/models/params/gridColumnGroupHeaderParams.js +5 -0
  257. package/node/models/params/gridEditCellParams.js +0 -3
  258. package/node/models/params/index.js +13 -0
  259. package/package.json +2 -2
  260. package/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.d.ts +0 -4
  261. package/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.js +0 -35
  262. package/hooks/features/editRows/index.d.ts +0 -1
  263. package/hooks/features/editRows/index.js +0 -1
  264. package/hooks/features/editRows/useGridCellEditing.old.d.ts +0 -4
  265. package/hooks/features/editRows/useGridCellEditing.old.js +0 -359
  266. package/hooks/features/editRows/useGridEditing.old.d.ts +0 -11
  267. package/hooks/features/editRows/useGridEditing.old.js +0 -167
  268. package/hooks/features/editRows/useGridRowEditing.old.d.ts +0 -4
  269. package/hooks/features/editRows/useGridRowEditing.old.js +0 -334
  270. package/hooks/features/selection/gridSelectionSelector.js +0 -9
  271. package/hooks/features/selection/index.d.ts +0 -1
  272. package/hooks/features/selection/index.js +0 -1
  273. package/hooks/features/selection/useGridSelection.d.ts +0 -12
  274. package/legacy/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.js +0 -35
  275. package/legacy/hooks/features/editRows/index.js +0 -1
  276. package/legacy/hooks/features/editRows/useGridCellEditing.old.js +0 -411
  277. package/legacy/hooks/features/editRows/useGridEditing.old.js +0 -184
  278. package/legacy/hooks/features/editRows/useGridRowEditing.old.js +0 -505
  279. package/legacy/hooks/features/selection/gridSelectionSelector.js +0 -19
  280. package/legacy/hooks/features/selection/index.js +0 -1
  281. package/models/gridSelectionModel.d.ts +0 -3
  282. package/modern/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.js +0 -29
  283. package/modern/hooks/features/editRows/index.js +0 -1
  284. package/modern/hooks/features/editRows/useGridCellEditing.old.js +0 -355
  285. package/modern/hooks/features/editRows/useGridEditing.old.js +0 -163
  286. package/modern/hooks/features/editRows/useGridRowEditing.old.js +0 -326
  287. package/modern/hooks/features/selection/gridSelectionSelector.js +0 -9
  288. package/modern/hooks/features/selection/index.js +0 -1
  289. package/node/hooks/features/columnGrouping/useGridColumnGroupingPreProcessors.js +0 -55
  290. package/node/hooks/features/editRows/useGridCellEditing.old.js +0 -380
  291. package/node/hooks/features/editRows/useGridEditing.old.js +0 -193
  292. package/node/hooks/features/editRows/useGridRowEditing.old.js +0 -358
  293. package/node/hooks/features/selection/index.js +0 -18
@@ -8,7 +8,7 @@ import { unstable_useEventCallback as useEventCallback } from '@mui/utils';
8
8
  import { useGridApiEventHandler, useGridApiOptionHandler, GridSignature } from '../../utils/useGridApiEventHandler';
9
9
  import { GridEditModes, GridCellModes } from '../../../models/gridEditRowModel';
10
10
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
11
- import { gridEditRowsStateSelector } from './gridEditRowsSelector';
11
+ import { gridEditRowsStateSelector } from './gridEditingSelectors';
12
12
  import { isPrintableKey } from '../../../utils/keyboardUtils';
13
13
  import { buildWarning } from '../../../utils/warning';
14
14
  import { gridRowsDataRowIdToIdLookupSelector } from '../rows/gridRowsSelector';
@@ -121,7 +121,8 @@ export const useGridCellEditing = (apiRef, props) => {
121
121
 
122
122
  if (reason) {
123
123
  const newParams = _extends({}, params, {
124
- reason
124
+ reason,
125
+ key: event.key
125
126
  });
126
127
 
127
128
  apiRef.current.publishEvent('cellEditStart', newParams, event);
@@ -132,14 +133,21 @@ export const useGridCellEditing = (apiRef, props) => {
132
133
  const {
133
134
  id,
134
135
  field,
135
- reason
136
+ reason,
137
+ key
136
138
  } = params;
137
139
  const startCellEditModeParams = {
138
140
  id,
139
141
  field
140
142
  };
141
143
 
142
- if (reason === GridCellEditStartReasons.deleteKeyDown || reason === GridCellEditStartReasons.printableKeyDown) {
144
+ if (reason === GridCellEditStartReasons.printableKeyDown) {
145
+ if (React.version.startsWith('18')) {
146
+ startCellEditModeParams.initialValue = key; // In React 17, cleaning the input is enough
147
+ } else {
148
+ startCellEditModeParams.deleteValue = true;
149
+ }
150
+ } else if (reason === GridCellEditStartReasons.deleteKeyDown) {
143
151
  startCellEditModeParams.deleteValue = true;
144
152
  }
145
153
 
@@ -270,10 +278,17 @@ export const useGridCellEditing = (apiRef, props) => {
270
278
  const {
271
279
  id,
272
280
  field,
273
- deleteValue
281
+ deleteValue,
282
+ initialValue
274
283
  } = params;
284
+ let newValue = apiRef.current.getCellValue(id, field);
285
+
286
+ if (deleteValue || initialValue) {
287
+ newValue = deleteValue ? '' : initialValue;
288
+ }
289
+
275
290
  const newProps = {
276
- value: deleteValue ? '' : apiRef.current.getCellValue(id, field),
291
+ value: newValue,
277
292
  error: false,
278
293
  isProcessingProps: false
279
294
  };
@@ -1,10 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
4
- import { useGridCellEditing } from './useGridCellEditing.new';
4
+ import { useGridCellEditing } from './useGridCellEditing';
5
5
  import { GridCellModes, GridEditModes } from '../../../models/gridEditRowModel';
6
- import { useGridRowEditing } from './useGridRowEditing.new';
7
- import { gridEditRowsStateSelector } from './gridEditRowsSelector';
6
+ import { useGridRowEditing } from './useGridRowEditing';
7
+ import { gridEditRowsStateSelector } from './gridEditingSelectors';
8
8
  import { isAutoGeneratedRow } from '../rows/gridRowsUtils';
9
9
  export const editingStateInitializer = state => _extends({}, state, {
10
10
  editRows: {}
@@ -8,7 +8,7 @@ import { unstable_useEventCallback as useEventCallback } from '@mui/utils';
8
8
  import { useGridApiEventHandler, useGridApiOptionHandler, GridSignature } from '../../utils/useGridApiEventHandler';
9
9
  import { GridEditModes, GridRowModes } from '../../../models/gridEditRowModel';
10
10
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
11
- import { gridEditRowsStateSelector } from './gridEditRowsSelector';
11
+ import { gridEditRowsStateSelector } from './gridEditingSelectors';
12
12
  import { isPrintableKey } from '../../../utils/keyboardUtils';
13
13
  import { gridColumnFieldsSelector } from '../columns/gridColumnsSelector';
14
14
  import { buildWarning } from '../../../utils/warning';
@@ -181,6 +181,7 @@ export const useGridRowEditing = (apiRef, props) => {
181
181
 
182
182
  const newParams = _extends({}, rowParams, {
183
183
  field: params.field,
184
+ key: event.key,
184
185
  reason
185
186
  });
186
187
 
@@ -192,14 +193,21 @@ export const useGridRowEditing = (apiRef, props) => {
192
193
  const {
193
194
  id,
194
195
  field,
195
- reason
196
+ reason,
197
+ key
196
198
  } = params;
197
199
  const startRowEditModeParams = {
198
200
  id,
199
201
  fieldToFocus: field
200
202
  };
201
203
 
202
- if (reason === GridRowEditStartReasons.deleteKeyDown || reason === GridRowEditStartReasons.printableKeyDown) {
204
+ if (reason === GridRowEditStartReasons.printableKeyDown) {
205
+ if (React.version.startsWith('18')) {
206
+ startRowEditModeParams.initialValue = key; // In React 17, cleaning the input is enough
207
+ } else {
208
+ startRowEditModeParams.deleteValue = !!field;
209
+ }
210
+ } else if (reason === GridRowEditStartReasons.deleteKeyDown) {
203
211
  startRowEditModeParams.deleteValue = !!field;
204
212
  }
205
213
 
@@ -339,7 +347,8 @@ export const useGridRowEditing = (apiRef, props) => {
339
347
  const {
340
348
  id,
341
349
  fieldToFocus,
342
- deleteValue
350
+ deleteValue,
351
+ initialValue
343
352
  } = params;
344
353
  const columnFields = gridColumnFieldsSelector(apiRef);
345
354
  const newProps = columnFields.reduce((acc, field) => {
@@ -349,9 +358,14 @@ export const useGridRowEditing = (apiRef, props) => {
349
358
  return acc;
350
359
  }
351
360
 
352
- const shouldDeleteValue = deleteValue && fieldToFocus === field;
361
+ let newValue = apiRef.current.getCellValue(id, field);
362
+
363
+ if (fieldToFocus === field && (deleteValue || initialValue)) {
364
+ newValue = deleteValue ? '' : initialValue;
365
+ }
366
+
353
367
  acc[field] = {
354
- value: shouldDeleteValue ? '' : apiRef.current.getCellValue(id, field),
368
+ value: newValue,
355
369
  error: false,
356
370
  isProcessingProps: false
357
371
  };
@@ -4,7 +4,7 @@ import { ownerDocument } from '@mui/material/utils';
4
4
  import { useGridLogger } from '../../utils/useGridLogger';
5
5
  import { gridVisibleRowCountSelector } from '../filter/gridFilterSelector';
6
6
  import { gridColumnDefinitionsSelector, gridColumnVisibilityModelSelector } from '../columns/gridColumnsSelector';
7
- import { gridDensityTotalHeaderHeightSelector } from '../density/densitySelector';
7
+ import { gridTotalHeaderHeightSelector } from '../columnGrouping/gridColumnGroupsSelector';
8
8
  import { gridClasses } from '../../../constants/gridClasses';
9
9
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
10
10
  import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
@@ -83,7 +83,7 @@ export const useGridPrintExport = (apiRef, props) => {
83
83
  return;
84
84
  }
85
85
 
86
- const totalHeaderHeight = gridDensityTotalHeaderHeightSelector(apiRef);
86
+ const totalHeaderHeight = gridTotalHeaderHeightSelector(apiRef);
87
87
  const rowsMeta = gridRowsMetaSelector(apiRef.current.state);
88
88
  const gridRootElement = apiRef.current.rootElementRef.current;
89
89
  const gridClone = gridRootElement.cloneNode(true);
@@ -6,11 +6,17 @@ export declare type GridCellIdentifier = {
6
6
  export declare type GridColumnIdentifier = {
7
7
  field: string;
8
8
  };
9
+ export declare type GridColumnGroupIdentifier = {
10
+ field: string;
11
+ depth: number;
12
+ };
9
13
  export interface GridFocusState {
10
14
  cell: GridCellIdentifier | null;
11
15
  columnHeader: GridColumnIdentifier | null;
16
+ columnGroupHeader: GridColumnGroupIdentifier | null;
12
17
  }
13
18
  export interface GridTabIndexState {
14
19
  cell: GridCellIdentifier | null;
15
20
  columnHeader: GridColumnIdentifier | null;
21
+ columnGroupHeader: GridColumnGroupIdentifier | null;
16
22
  }
@@ -3,6 +3,8 @@ import { GridFocusState, GridTabIndexState } from './gridFocusState';
3
3
  export declare const gridFocusStateSelector: (state: GridStateCommunity) => GridFocusState;
4
4
  export declare const gridFocusCellSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridCellIdentifier | null>;
5
5
  export declare const gridFocusColumnHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
6
+ export declare const unstable_gridFocusColumnGroupHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnGroupIdentifier | null>;
6
7
  export declare const gridTabIndexStateSelector: (state: GridStateCommunity) => GridTabIndexState;
7
8
  export declare const gridTabIndexCellSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridCellIdentifier | null>;
8
9
  export declare const gridTabIndexColumnHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
10
+ export declare const unstable_gridTabIndexColumnGroupHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnGroupIdentifier | null>;
@@ -1,7 +1,11 @@
1
1
  import { createSelector } from '../../../utils/createSelector';
2
2
  export const gridFocusStateSelector = state => state.focus;
3
3
  export const gridFocusCellSelector = createSelector(gridFocusStateSelector, focusState => focusState.cell);
4
- export const gridFocusColumnHeaderSelector = createSelector(gridFocusStateSelector, focusState => focusState.columnHeader);
4
+ export const gridFocusColumnHeaderSelector = createSelector(gridFocusStateSelector, focusState => focusState.columnHeader); // eslint-disable-next-line @typescript-eslint/naming-convention
5
+
6
+ export const unstable_gridFocusColumnGroupHeaderSelector = createSelector(gridFocusStateSelector, focusState => focusState.columnGroupHeader);
5
7
  export const gridTabIndexStateSelector = state => state.tabIndex;
6
8
  export const gridTabIndexCellSelector = createSelector(gridTabIndexStateSelector, state => state.cell);
7
- export const gridTabIndexColumnHeaderSelector = createSelector(gridTabIndexStateSelector, state => state.columnHeader);
9
+ export const gridTabIndexColumnHeaderSelector = createSelector(gridTabIndexStateSelector, state => state.columnHeader); // eslint-disable-next-line @typescript-eslint/naming-convention
10
+
11
+ export const unstable_gridTabIndexColumnGroupHeaderSelector = createSelector(gridTabIndexStateSelector, state => state.columnGroupHeader);
@@ -5,18 +5,20 @@ import { useGridApiMethod } from '../../utils/useGridApiMethod';
5
5
  import { useGridLogger } from '../../utils/useGridLogger';
6
6
  import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
7
7
  import { isNavigationKey } from '../../../utils/keyboardUtils';
8
- import { gridFocusCellSelector } from './gridFocusStateSelector';
8
+ import { gridFocusCellSelector, unstable_gridFocusColumnGroupHeaderSelector } from './gridFocusStateSelector';
9
9
  import { gridVisibleColumnDefinitionsSelector } from '../columns/gridColumnsSelector';
10
10
  import { getVisibleRows } from '../../utils/useGridVisibleRows';
11
11
  import { clamp } from '../../../utils/utils';
12
12
  export const focusStateInitializer = state => _extends({}, state, {
13
13
  focus: {
14
14
  cell: null,
15
- columnHeader: null
15
+ columnHeader: null,
16
+ columnGroupHeader: null
16
17
  },
17
18
  tabIndex: {
18
19
  cell: null,
19
- columnHeader: null
20
+ columnHeader: null,
21
+ columnGroupHeader: null
20
22
  }
21
23
  });
22
24
  /**
@@ -51,14 +53,16 @@ export const useGridFocus = (apiRef, props) => {
51
53
  id,
52
54
  field
53
55
  },
54
- columnHeader: null
56
+ columnHeader: null,
57
+ columnGroupHeader: null
55
58
  },
56
59
  focus: {
57
60
  cell: {
58
61
  id,
59
62
  field
60
63
  },
61
- columnHeader: null
64
+ columnHeader: null,
65
+ columnGroupHeader: null
62
66
  }
63
67
  });
64
68
  });
@@ -86,18 +90,50 @@ export const useGridFocus = (apiRef, props) => {
86
90
  columnHeader: {
87
91
  field
88
92
  },
89
- cell: null
93
+ cell: null,
94
+ columnGroupHeader: null
90
95
  },
91
96
  focus: {
92
97
  columnHeader: {
93
98
  field
94
99
  },
95
- cell: null
100
+ cell: null,
101
+ columnGroupHeader: null
96
102
  }
97
103
  });
98
104
  });
99
105
  apiRef.current.forceUpdate();
100
106
  }, [apiRef, logger, publishCellFocusOut]);
107
+ const setColumnGroupHeaderFocus = React.useCallback((field, depth, event = {}) => {
108
+ const cell = gridFocusCellSelector(apiRef);
109
+
110
+ if (cell) {
111
+ apiRef.current.publishEvent('cellFocusOut', apiRef.current.getCellParams(cell.id, cell.field), event);
112
+ }
113
+
114
+ apiRef.current.setState(state => {
115
+ return _extends({}, state, {
116
+ tabIndex: {
117
+ columnGroupHeader: {
118
+ field,
119
+ depth
120
+ },
121
+ columnHeader: null,
122
+ cell: null
123
+ },
124
+ focus: {
125
+ columnGroupHeader: {
126
+ field,
127
+ depth
128
+ },
129
+ columnHeader: null,
130
+ cell: null
131
+ }
132
+ });
133
+ });
134
+ apiRef.current.forceUpdate();
135
+ }, [apiRef]);
136
+ const getColumnGroupHeaderFocus = React.useCallback(() => unstable_gridFocusColumnGroupHeaderSelector(apiRef), [apiRef]);
101
137
  const moveFocusToRelativeCell = React.useCallback((id, field, direction) => {
102
138
  let columnIndexToFocus = apiRef.current.getColumnIndex(field);
103
139
  let rowIndexToFocus = apiRef.current.getRowIndexRelativeToVisibleRows(id);
@@ -173,12 +209,29 @@ export const useGridFocus = (apiRef, props) => {
173
209
 
174
210
  apiRef.current.setColumnHeaderFocus(field, event);
175
211
  }, [apiRef]);
212
+ const focussedColumnGroup = unstable_gridFocusColumnGroupHeaderSelector(apiRef);
213
+ const handleColumnGroupHeaderFocus = React.useCallback(({
214
+ fields,
215
+ depth
216
+ }, event) => {
217
+ if (event.target !== event.currentTarget) {
218
+ return;
219
+ }
220
+
221
+ if (focussedColumnGroup !== null && focussedColumnGroup.depth === depth && fields.includes(focussedColumnGroup.field)) {
222
+ // This group cell has already been focused
223
+ return;
224
+ }
225
+
226
+ apiRef.current.unstable_setColumnGroupHeaderFocus(fields[0], depth, event);
227
+ }, [apiRef, focussedColumnGroup]);
176
228
  const handleBlur = React.useCallback(() => {
177
229
  logger.debug(`Clearing focus`);
178
230
  apiRef.current.setState(state => _extends({}, state, {
179
231
  focus: {
180
232
  cell: null,
181
- columnHeader: null
233
+ columnHeader: null,
234
+ columnGroupHeader: null
182
235
  }
183
236
  }));
184
237
  }, [logger, apiRef]);
@@ -214,7 +267,8 @@ export const useGridFocus = (apiRef, props) => {
214
267
  apiRef.current.setState(state => _extends({}, state, {
215
268
  focus: {
216
269
  cell: null,
217
- columnHeader: null
270
+ columnHeader: null,
271
+ columnGroupHeader: null
218
272
  }
219
273
  }));
220
274
  apiRef.current.forceUpdate(); // There's a focused cell but another element (not a cell) was clicked
@@ -241,7 +295,8 @@ export const useGridFocus = (apiRef, props) => {
241
295
  apiRef.current.setState(state => _extends({}, state, {
242
296
  focus: {
243
297
  cell: null,
244
- columnHeader: null
298
+ columnHeader: null,
299
+ columnGroupHeader: null
245
300
  }
246
301
  }));
247
302
  }
@@ -249,7 +304,9 @@ export const useGridFocus = (apiRef, props) => {
249
304
  useGridApiMethod(apiRef, {
250
305
  setCellFocus,
251
306
  setColumnHeaderFocus,
252
- unstable_moveFocusToRelativeCell: moveFocusToRelativeCell
307
+ unstable_moveFocusToRelativeCell: moveFocusToRelativeCell,
308
+ unstable_setColumnGroupHeaderFocus: setColumnGroupHeaderFocus,
309
+ unstable_getColumnGroupHeaderFocus: getColumnGroupHeaderFocus
253
310
  }, 'GridFocusApi');
254
311
  React.useEffect(() => {
255
312
  const doc = ownerDocument(apiRef.current.rootElementRef.current);
@@ -264,5 +321,6 @@ export const useGridFocus = (apiRef, props) => {
264
321
  useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
265
322
  useGridApiEventHandler(apiRef, 'cellModeChange', handleCellModeChange);
266
323
  useGridApiEventHandler(apiRef, 'columnHeaderFocus', handleColumnHeaderFocus);
324
+ useGridApiEventHandler(apiRef, 'columnGroupHeaderFocus', handleColumnGroupHeaderFocus);
267
325
  useGridApiEventHandler(apiRef, 'rowsSet', handleRowSet);
268
326
  };
@@ -2,13 +2,13 @@ export * from './columnMenu';
2
2
  export * from './columns';
3
3
  export * from './columnGrouping';
4
4
  export * from './density';
5
- export * from './editRows';
5
+ export * from './editing';
6
6
  export * from './filter';
7
7
  export * from './focus';
8
8
  export * from './pagination';
9
9
  export * from './preferencesPanel';
10
10
  export * from './rows';
11
- export * from './selection';
11
+ export * from './rowSelection';
12
12
  export * from './sorting';
13
13
  export * from './dimensions';
14
14
  export * from './statePersistence';
@@ -3,13 +3,13 @@ export * from './columnMenu';
3
3
  export * from './columns';
4
4
  export * from './columnGrouping';
5
5
  export * from './density';
6
- export * from './editRows';
6
+ export * from './editing';
7
7
  export * from './filter';
8
8
  export * from './focus';
9
9
  export * from './pagination';
10
10
  export * from './preferencesPanel';
11
11
  export * from './rows';
12
- export * from './selection';
12
+ export * from './rowSelection';
13
13
  export * from './sorting';
14
14
  export * from './dimensions';
15
15
  export * from './statePersistence';
@@ -10,6 +10,9 @@ import { GridCellModes } from '../../../models/gridEditRowModel';
10
10
  import { isNavigationKey } from '../../../utils/keyboardUtils';
11
11
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPanelToggleField';
12
12
  import { gridPinnedRowsSelector } from '../rows/gridRowsSelector';
13
+ import { unstable_gridFocusColumnGroupHeaderSelector } from '../focus';
14
+ import { gridColumnGroupsHeaderMaxDepthSelector } from '../columnGrouping/gridColumnGroupsSelector';
15
+ import { useGridSelector } from '../../utils/useGridSelector';
13
16
 
14
17
  function enrichPageRowsWithPinnedRows(apiRef, rows) {
15
18
  const pinnedRows = gridPinnedRowsSelector(apiRef) || {};
@@ -68,6 +71,16 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
68
71
  const field = apiRef.current.getVisibleColumns()[colIndex].field;
69
72
  apiRef.current.setColumnHeaderFocus(field, event);
70
73
  }, [apiRef, logger]);
74
+ const goToGroupHeader = React.useCallback((colIndex, depth, event) => {
75
+ logger.debug(`Navigating to header col ${colIndex}`);
76
+ apiRef.current.scrollToIndexes({
77
+ colIndex
78
+ });
79
+ const {
80
+ field
81
+ } = apiRef.current.getVisibleColumns()[colIndex];
82
+ apiRef.current.unstable_setColumnGroupHeaderFocus(field, depth, event);
83
+ }, [apiRef, logger]);
71
84
  const getRowIdFromIndex = React.useCallback(rowIndex => {
72
85
  return currentPageRows[rowIndex].id;
73
86
  }, [currentPageRows]);
@@ -239,6 +252,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
239
252
  const lastRowIndexInPage = currentPageRows.length - 1;
240
253
  const firstColIndex = 0;
241
254
  const lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
255
+ const columnGroupMaxDepth = gridColumnGroupsHeaderMaxDepthSelector(apiRef);
242
256
  let shouldPreventDefault = true;
243
257
 
244
258
  switch (event.key) {
@@ -269,6 +283,15 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
269
283
  break;
270
284
  }
271
285
 
286
+ case 'ArrowUp':
287
+ {
288
+ if (columnGroupMaxDepth > 0) {
289
+ goToGroupHeader(colIndexBefore, columnGroupMaxDepth - 1, event);
290
+ }
291
+
292
+ break;
293
+ }
294
+
272
295
  case 'PageDown':
273
296
  {
274
297
  if (firstRowIndexInPage !== null && lastRowIndexInPage !== null) {
@@ -314,7 +337,117 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
314
337
  if (shouldPreventDefault) {
315
338
  event.preventDefault();
316
339
  }
317
- }, [apiRef, currentPageRows, goToCell, goToHeader, getRowIdFromIndex]);
340
+ }, [apiRef, currentPageRows.length, goToCell, getRowIdFromIndex, goToHeader, goToGroupHeader]);
341
+ const focusedColumnGroup = useGridSelector(apiRef, unstable_gridFocusColumnGroupHeaderSelector);
342
+ const handleColumnGroupHeaderKeyDown = React.useCallback((params, event) => {
343
+ const dimensions = apiRef.current.getRootDimensions();
344
+
345
+ if (!dimensions) {
346
+ return;
347
+ }
348
+
349
+ if (focusedColumnGroup === null) {
350
+ return;
351
+ }
352
+
353
+ const {
354
+ field: currentField,
355
+ depth: currentDepth
356
+ } = focusedColumnGroup;
357
+ const {
358
+ fields,
359
+ depth,
360
+ maxDepth
361
+ } = params;
362
+ const viewportPageSize = apiRef.current.unstable_getViewportPageSize();
363
+ const currentColIndex = apiRef.current.getColumnIndex(currentField);
364
+ const colIndexBefore = currentField ? apiRef.current.getColumnIndex(currentField) : 0;
365
+ const firstRowIndexInPage = 0;
366
+ const lastRowIndexInPage = currentPageRows.length - 1;
367
+ const firstColIndex = 0;
368
+ const lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
369
+ let shouldPreventDefault = true;
370
+
371
+ switch (event.key) {
372
+ case 'ArrowDown':
373
+ {
374
+ if (depth === maxDepth - 1) {
375
+ goToHeader(currentColIndex, event);
376
+ } else {
377
+ goToGroupHeader(currentColIndex, currentDepth + 1, event);
378
+ }
379
+
380
+ break;
381
+ }
382
+
383
+ case 'ArrowUp':
384
+ {
385
+ if (depth > 0) {
386
+ goToGroupHeader(currentColIndex, currentDepth - 1, event);
387
+ }
388
+
389
+ break;
390
+ }
391
+
392
+ case 'ArrowRight':
393
+ {
394
+ const remainingRightColumns = fields.length - fields.indexOf(currentField) - 1;
395
+
396
+ if (currentColIndex + remainingRightColumns + 1 <= lastColIndex) {
397
+ goToGroupHeader(currentColIndex + remainingRightColumns + 1, currentDepth, event);
398
+ }
399
+
400
+ break;
401
+ }
402
+
403
+ case 'ArrowLeft':
404
+ {
405
+ const remainingLeftColumns = fields.indexOf(currentField);
406
+
407
+ if (currentColIndex - remainingLeftColumns - 1 >= firstColIndex) {
408
+ goToGroupHeader(currentColIndex - remainingLeftColumns - 1, currentDepth, event);
409
+ }
410
+
411
+ break;
412
+ }
413
+
414
+ case 'PageDown':
415
+ {
416
+ if (firstRowIndexInPage !== null && lastRowIndexInPage !== null) {
417
+ goToCell(colIndexBefore, getRowIdFromIndex(Math.min(firstRowIndexInPage + viewportPageSize, lastRowIndexInPage)));
418
+ }
419
+
420
+ break;
421
+ }
422
+
423
+ case 'Home':
424
+ {
425
+ goToGroupHeader(firstColIndex, currentDepth, event);
426
+ break;
427
+ }
428
+
429
+ case 'End':
430
+ {
431
+ goToGroupHeader(lastColIndex, currentDepth, event);
432
+ break;
433
+ }
434
+
435
+ case ' ':
436
+ {
437
+ // prevent Space event from scrolling
438
+ break;
439
+ }
440
+
441
+ default:
442
+ {
443
+ shouldPreventDefault = false;
444
+ }
445
+ }
446
+
447
+ if (shouldPreventDefault) {
448
+ event.preventDefault();
449
+ }
450
+ }, [apiRef, focusedColumnGroup, currentPageRows.length, goToHeader, goToGroupHeader, goToCell, getRowIdFromIndex]);
318
451
  const handleCellKeyDown = React.useCallback((params, event) => {
319
452
  // Ignore portal
320
453
  if (!event.currentTarget.contains(event.target)) {
@@ -330,5 +463,6 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
330
463
  }, [apiRef]);
331
464
  useGridApiEventHandler(apiRef, 'cellNavigationKeyDown', handleCellNavigationKeyDown);
332
465
  useGridApiEventHandler(apiRef, 'columnHeaderKeyDown', handleColumnHeaderKeyDown);
466
+ useGridApiEventHandler(apiRef, 'columnGroupHeaderKeyDown', handleColumnGroupHeaderKeyDown);
333
467
  useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
334
468
  };
@@ -1,6 +1,6 @@
1
1
  import { GridStateCommunity } from '../../../models/gridStateCommunity';
2
2
  import { GridRowId } from '../../../models/gridRows';
3
- export declare const gridSelectionStateSelector: (state: GridStateCommunity) => import("../../..").GridSelectionModel;
3
+ export declare const gridRowSelectionStateSelector: (state: GridStateCommunity) => import("../../..").GridRowSelectionModel;
4
4
  export declare const selectedGridRowsCountSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
5
5
  export declare const selectedGridRowsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Map<GridRowId, import("../../../models/gridRows").GridValidRowModel>>;
6
6
  export declare const selectedIdsLookupSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Record<GridRowId, GridRowId>>;
@@ -0,0 +1,9 @@
1
+ import { createSelector } from '../../../utils/createSelector';
2
+ import { gridRowsLookupSelector } from '../rows/gridRowsSelector';
3
+ export const gridRowSelectionStateSelector = state => state.rowSelection;
4
+ export const selectedGridRowsCountSelector = createSelector(gridRowSelectionStateSelector, selection => selection.length);
5
+ export const selectedGridRowsSelector = createSelector(gridRowSelectionStateSelector, gridRowsLookupSelector, (selectedRows, rowsLookup) => new Map(selectedRows.map(id => [id, rowsLookup[id]])));
6
+ export const selectedIdsLookupSelector = createSelector(gridRowSelectionStateSelector, selection => selection.reduce((lookup, rowId) => {
7
+ lookup[rowId] = rowId;
8
+ return lookup;
9
+ }, {}));
@@ -0,0 +1 @@
1
+ export * from './gridRowSelectionSelector';
@@ -0,0 +1 @@
1
+ export * from './gridRowSelectionSelector';
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
3
+ import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
4
+ import { GridStateInitializer } from '../../utils/useGridInitializeState';
5
+ export declare const rowSelectionStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'rowSelectionModel'>>;
6
+ /**
7
+ * @requires useGridRows (state, method) - can be after
8
+ * @requires useGridParamsApi (method) - can be after
9
+ * @requires useGridFocus (state) - can be after
10
+ * @requires useGridKeyboardNavigation (`cellKeyDown` event must first be consumed by it)
11
+ */
12
+ export declare const useGridRowSelection: (apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'checkboxSelection' | 'rowSelectionModel' | 'onRowSelectionModelChange' | 'disableMultipleRowSelection' | 'disableRowSelectionOnClick' | 'isRowSelectable' | 'checkboxSelectionVisibleOnly' | 'pagination' | 'paginationMode' | 'classes' | 'keepNonExistentRowsSelected'>) => void;