@mui/x-data-grid 8.0.0-alpha.12 → 8.0.0-alpha.13

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 (348) hide show
  1. package/CHANGELOG.md +299 -0
  2. package/DataGrid/DataGrid.js +31 -22
  3. package/DataGrid/useDataGridProps.js +1 -1
  4. package/colDef/gridCheckboxSelectionColDef.js +1 -3
  5. package/components/GridFooter.js +1 -1
  6. package/components/GridHeader.js +1 -1
  7. package/components/GridPagination.js +5 -6
  8. package/components/GridRowCount.js +4 -5
  9. package/components/GridScrollArea.js +4 -3
  10. package/components/GridSelectedRowCount.js +5 -6
  11. package/components/GridShadowScrollArea.d.ts +8 -0
  12. package/components/GridShadowScrollArea.js +82 -0
  13. package/components/cell/GridEditInputCell.js +2 -3
  14. package/components/columnSelection/GridHeaderCheckbox.js +51 -17
  15. package/components/columnsManagement/GridColumnsManagement.js +59 -61
  16. package/components/containers/GridOverlay.js +6 -8
  17. package/components/containers/GridRoot.js +4 -2
  18. package/components/containers/GridRootStyles.d.ts +1 -2
  19. package/components/containers/GridRootStyles.js +77 -100
  20. package/components/containers/GridToolbarContainer.js +5 -6
  21. package/components/menu/GridMenu.js +7 -6
  22. package/components/menu/columnMenu/GridColumnHeaderMenu.js +4 -3
  23. package/components/panel/GridPanel.js +18 -20
  24. package/components/panel/GridPanelContent.js +6 -8
  25. package/components/panel/GridPanelFooter.js +5 -6
  26. package/components/panel/GridPanelHeader.js +4 -5
  27. package/components/panel/filterPanel/GridFilterForm.js +13 -20
  28. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.ts +2 -2
  29. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +10 -39
  30. package/components/panel/filterPanel/GridFilterInputMultipleValue.d.ts +2 -2
  31. package/components/panel/filterPanel/GridFilterInputMultipleValue.js +20 -45
  32. package/components/panel/filterPanel/GridFilterInputValue.js +3 -6
  33. package/components/toolbar/GridToolbarFilterButton.js +5 -6
  34. package/components/toolbar/GridToolbarQuickFilter.js +23 -30
  35. package/components/virtualization/GridVirtualScrollbar.js +8 -5
  36. package/components/virtualization/GridVirtualScrollerFiller.js +2 -1
  37. package/constants/cssVariables.d.ts +294 -0
  38. package/constants/cssVariables.js +168 -0
  39. package/constants/dataGridPropsDefaultValues.js +1 -0
  40. package/constants/defaultGridSlotsComponents.js +1 -1
  41. package/constants/gridClasses.d.ts +13 -0
  42. package/constants/gridClasses.js +1 -1
  43. package/context/GridContextProvider.js +4 -1
  44. package/esm/DataGrid/DataGrid.js +31 -22
  45. package/esm/DataGrid/useDataGridProps.js +1 -1
  46. package/esm/colDef/gridCheckboxSelectionColDef.js +1 -3
  47. package/esm/components/GridFooter.js +2 -2
  48. package/esm/components/GridHeader.js +1 -1
  49. package/esm/components/GridPagination.js +5 -6
  50. package/esm/components/GridRowCount.js +4 -5
  51. package/esm/components/GridScrollArea.js +2 -1
  52. package/esm/components/GridSelectedRowCount.js +5 -6
  53. package/esm/components/GridShadowScrollArea.d.ts +8 -0
  54. package/esm/components/GridShadowScrollArea.js +74 -0
  55. package/esm/components/cell/GridEditInputCell.js +2 -3
  56. package/esm/components/columnSelection/GridHeaderCheckbox.js +51 -17
  57. package/esm/components/columnsManagement/GridColumnsManagement.js +60 -62
  58. package/esm/components/containers/GridOverlay.js +6 -8
  59. package/esm/components/containers/GridRoot.js +4 -2
  60. package/esm/components/containers/GridRootStyles.d.ts +1 -2
  61. package/esm/components/containers/GridRootStyles.js +78 -101
  62. package/esm/components/containers/GridToolbarContainer.js +5 -6
  63. package/esm/components/menu/GridMenu.js +7 -6
  64. package/esm/components/menu/columnMenu/GridColumnHeaderMenu.js +2 -1
  65. package/esm/components/panel/GridPanel.js +18 -20
  66. package/esm/components/panel/GridPanelContent.js +6 -8
  67. package/esm/components/panel/GridPanelFooter.js +5 -6
  68. package/esm/components/panel/GridPanelHeader.js +4 -5
  69. package/esm/components/panel/filterPanel/GridFilterForm.js +13 -20
  70. package/esm/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.ts +2 -2
  71. package/esm/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +10 -39
  72. package/esm/components/panel/filterPanel/GridFilterInputMultipleValue.d.ts +2 -2
  73. package/esm/components/panel/filterPanel/GridFilterInputMultipleValue.js +19 -44
  74. package/esm/components/panel/filterPanel/GridFilterInputValue.js +3 -6
  75. package/esm/components/toolbar/GridToolbarFilterButton.js +5 -6
  76. package/esm/components/toolbar/GridToolbarQuickFilter.js +23 -30
  77. package/esm/components/virtualization/GridVirtualScrollbar.js +3 -1
  78. package/esm/components/virtualization/GridVirtualScrollerFiller.js +2 -1
  79. package/esm/constants/cssVariables.d.ts +294 -0
  80. package/esm/constants/cssVariables.js +161 -0
  81. package/esm/constants/dataGridPropsDefaultValues.js +1 -0
  82. package/esm/constants/defaultGridSlotsComponents.js +2 -2
  83. package/esm/constants/gridClasses.d.ts +13 -0
  84. package/esm/constants/gridClasses.js +1 -1
  85. package/esm/context/GridContextProvider.js +4 -1
  86. package/esm/hooks/features/clipboard/useGridClipboard.js +3 -2
  87. package/esm/hooks/features/columnHeaders/useGridColumnHeaders.js +2 -2
  88. package/esm/hooks/features/columnResize/useGridColumnResize.js +2 -1
  89. package/esm/hooks/features/columns/gridColumnsInterfaces.d.ts +1 -0
  90. package/esm/hooks/features/columns/gridColumnsSelector.d.ts +7 -0
  91. package/esm/hooks/features/columns/gridColumnsSelector.js +8 -0
  92. package/esm/hooks/features/columns/gridColumnsUtils.d.ts +3 -1
  93. package/esm/hooks/features/columns/gridColumnsUtils.js +6 -3
  94. package/esm/hooks/features/columns/index.d.ts +1 -1
  95. package/esm/hooks/features/columns/index.js +1 -1
  96. package/esm/hooks/features/columns/useGridColumns.js +4 -2
  97. package/esm/hooks/features/dataSource/gridDataSourceError.d.ts +31 -0
  98. package/esm/hooks/features/dataSource/gridDataSourceError.js +32 -0
  99. package/esm/hooks/features/dataSource/index.d.ts +2 -0
  100. package/esm/hooks/features/dataSource/index.js +2 -0
  101. package/esm/hooks/features/dataSource/models.d.ts +1 -1
  102. package/esm/hooks/features/dataSource/useGridDataSourceBase.d.ts +1 -1
  103. package/esm/hooks/features/dataSource/useGridDataSourceBase.js +27 -17
  104. package/esm/hooks/features/dimensions/useGridDimensions.js +11 -10
  105. package/esm/hooks/features/editing/useGridCellEditing.js +2 -1
  106. package/esm/hooks/features/editing/useGridRowEditing.js +2 -1
  107. package/esm/hooks/features/export/utils.js +4 -2
  108. package/esm/hooks/features/focus/useGridFocus.js +3 -2
  109. package/esm/hooks/features/index.d.ts +1 -1
  110. package/esm/hooks/features/index.js +1 -1
  111. package/esm/hooks/features/rowSelection/gridRowSelectionSelector.d.ts +3 -3
  112. package/esm/hooks/features/rowSelection/gridRowSelectionSelector.js +27 -7
  113. package/esm/hooks/features/rowSelection/useGridRowSelection.js +148 -81
  114. package/esm/hooks/features/rowSelection/utils.d.ts +2 -2
  115. package/esm/hooks/features/rowSelection/utils.js +11 -11
  116. package/esm/hooks/features/rows/gridRowsInterfaces.d.ts +1 -1
  117. package/esm/hooks/features/rows/gridRowsUtils.d.ts +2 -1
  118. package/esm/hooks/features/rows/gridRowsUtils.js +8 -0
  119. package/esm/hooks/features/rows/useGridParamsApi.js +2 -8
  120. package/esm/hooks/features/rows/useGridRowAriaAttributes.js +2 -4
  121. package/esm/hooks/features/rows/useGridRows.d.ts +2 -2
  122. package/esm/hooks/features/rows/useGridRows.js +7 -7
  123. package/esm/hooks/features/virtualization/useGridVirtualScroller.js +5 -9
  124. package/esm/hooks/utils/useGridSelector.js +4 -1
  125. package/esm/hooks/utils/useIsSSR.js +4 -1
  126. package/esm/index.js +1 -1
  127. package/esm/internals/index.d.ts +2 -1
  128. package/esm/internals/index.js +2 -1
  129. package/esm/internals/utils/propValidation.js +1 -1
  130. package/esm/locales/bnBD.d.ts +2 -0
  131. package/esm/locales/bnBD.js +167 -0
  132. package/esm/locales/deDE.js +3 -5
  133. package/esm/locales/huHU.js +10 -13
  134. package/esm/locales/index.d.ts +1 -0
  135. package/esm/locales/index.js +1 -0
  136. package/esm/locales/ruRU.js +17 -21
  137. package/esm/material/index.d.ts +1 -0
  138. package/esm/material/index.js +164 -49
  139. package/esm/material/variables.d.ts +5 -0
  140. package/esm/material/variables.js +89 -0
  141. package/esm/models/api/gridRowSelectionApi.d.ts +4 -2
  142. package/esm/models/api/gridSortApi.d.ts +1 -1
  143. package/esm/models/configuration/gridConfiguration.d.ts +7 -1
  144. package/esm/models/gridBaseSlots.d.ts +56 -6
  145. package/esm/models/gridDataSource.d.ts +9 -4
  146. package/esm/models/gridRowSelectionManager.d.ts +9 -0
  147. package/esm/models/gridRowSelectionManager.js +36 -0
  148. package/esm/models/gridRowSelectionModel.d.ts +4 -2
  149. package/esm/models/gridSlotsComponent.d.ts +7 -27
  150. package/esm/models/gridSlotsComponentsProps.d.ts +3 -11
  151. package/esm/models/gridSortModel.d.ts +1 -1
  152. package/esm/models/index.d.ts +2 -1
  153. package/esm/models/index.js +2 -3
  154. package/esm/models/props/DataGridProps.d.ts +22 -17
  155. package/esm/utils/css/context.d.ts +14 -0
  156. package/esm/utils/css/context.js +54 -0
  157. package/esm/utils/index.d.ts +2 -1
  158. package/esm/utils/index.js +1 -1
  159. package/hooks/features/clipboard/useGridClipboard.js +3 -2
  160. package/hooks/features/columnHeaders/useGridColumnHeaders.js +2 -2
  161. package/hooks/features/columnResize/useGridColumnResize.js +28 -27
  162. package/hooks/features/columns/gridColumnsInterfaces.d.ts +1 -0
  163. package/hooks/features/columns/gridColumnsSelector.d.ts +7 -0
  164. package/hooks/features/columns/gridColumnsSelector.js +9 -1
  165. package/hooks/features/columns/gridColumnsUtils.d.ts +3 -1
  166. package/hooks/features/columns/gridColumnsUtils.js +6 -3
  167. package/hooks/features/columns/index.d.ts +1 -1
  168. package/hooks/features/columns/index.js +94 -10
  169. package/hooks/features/columns/useGridColumns.js +4 -2
  170. package/hooks/features/dataSource/gridDataSourceError.d.ts +31 -0
  171. package/hooks/features/dataSource/gridDataSourceError.js +40 -0
  172. package/hooks/features/dataSource/index.d.ts +2 -0
  173. package/hooks/features/dataSource/index.js +25 -0
  174. package/hooks/features/dataSource/models.d.ts +1 -1
  175. package/hooks/features/dataSource/useGridDataSourceBase.d.ts +1 -1
  176. package/hooks/features/dataSource/useGridDataSourceBase.js +27 -17
  177. package/hooks/features/dimensions/useGridDimensions.js +19 -18
  178. package/hooks/features/editing/useGridCellEditing.js +10 -9
  179. package/hooks/features/editing/useGridRowEditing.js +11 -10
  180. package/hooks/features/export/utils.js +4 -2
  181. package/hooks/features/focus/useGridFocus.js +8 -7
  182. package/hooks/features/index.d.ts +1 -1
  183. package/hooks/features/index.js +11 -28
  184. package/hooks/features/rowSelection/gridRowSelectionSelector.d.ts +3 -3
  185. package/hooks/features/rowSelection/gridRowSelectionSelector.js +27 -7
  186. package/hooks/features/rowSelection/useGridRowSelection.js +146 -79
  187. package/hooks/features/rowSelection/utils.d.ts +2 -2
  188. package/hooks/features/rowSelection/utils.js +10 -10
  189. package/hooks/features/rows/gridRowsInterfaces.d.ts +1 -1
  190. package/hooks/features/rows/gridRowsUtils.d.ts +2 -1
  191. package/hooks/features/rows/gridRowsUtils.js +10 -1
  192. package/hooks/features/rows/useGridParamsApi.js +2 -8
  193. package/hooks/features/rows/useGridRowAriaAttributes.js +2 -4
  194. package/hooks/features/rows/useGridRows.d.ts +2 -2
  195. package/hooks/features/rows/useGridRows.js +7 -7
  196. package/hooks/features/virtualization/useGridVirtualScroller.js +21 -25
  197. package/hooks/utils/useGridSelector.js +6 -2
  198. package/hooks/utils/useIsSSR.js +6 -2
  199. package/index.js +1 -1
  200. package/internals/index.d.ts +2 -1
  201. package/internals/index.js +15 -0
  202. package/internals/utils/propValidation.js +1 -1
  203. package/locales/bnBD.d.ts +2 -0
  204. package/locales/bnBD.js +173 -0
  205. package/locales/deDE.js +3 -5
  206. package/locales/huHU.js +10 -13
  207. package/locales/index.d.ts +1 -0
  208. package/locales/index.js +11 -0
  209. package/locales/ruRU.js +17 -21
  210. package/material/index.d.ts +1 -0
  211. package/material/index.js +170 -49
  212. package/material/variables.d.ts +5 -0
  213. package/material/variables.js +95 -0
  214. package/models/api/gridRowSelectionApi.d.ts +4 -2
  215. package/models/api/gridSortApi.d.ts +1 -1
  216. package/models/configuration/gridConfiguration.d.ts +7 -1
  217. package/models/gridBaseSlots.d.ts +56 -6
  218. package/models/gridDataSource.d.ts +9 -4
  219. package/models/gridRowSelectionManager.d.ts +9 -0
  220. package/models/gridRowSelectionManager.js +43 -0
  221. package/models/gridRowSelectionModel.d.ts +4 -2
  222. package/models/gridSlotsComponent.d.ts +7 -27
  223. package/models/gridSlotsComponentsProps.d.ts +3 -11
  224. package/models/gridSortModel.d.ts +1 -1
  225. package/models/index.d.ts +2 -1
  226. package/models/index.js +34 -11
  227. package/models/props/DataGridProps.d.ts +22 -17
  228. package/modern/DataGrid/DataGrid.js +31 -22
  229. package/modern/DataGrid/useDataGridProps.js +1 -1
  230. package/modern/colDef/gridCheckboxSelectionColDef.js +1 -3
  231. package/modern/components/GridFooter.js +2 -2
  232. package/modern/components/GridHeader.js +1 -1
  233. package/modern/components/GridPagination.js +5 -6
  234. package/modern/components/GridRowCount.js +4 -5
  235. package/modern/components/GridScrollArea.js +2 -1
  236. package/modern/components/GridSelectedRowCount.js +5 -6
  237. package/modern/components/GridShadowScrollArea.d.ts +8 -0
  238. package/modern/components/GridShadowScrollArea.js +74 -0
  239. package/modern/components/cell/GridEditInputCell.js +2 -3
  240. package/modern/components/columnSelection/GridHeaderCheckbox.js +51 -17
  241. package/modern/components/columnsManagement/GridColumnsManagement.js +60 -62
  242. package/modern/components/containers/GridOverlay.js +6 -8
  243. package/modern/components/containers/GridRoot.js +4 -2
  244. package/modern/components/containers/GridRootStyles.d.ts +1 -2
  245. package/modern/components/containers/GridRootStyles.js +78 -101
  246. package/modern/components/containers/GridToolbarContainer.js +5 -6
  247. package/modern/components/menu/GridMenu.js +7 -6
  248. package/modern/components/menu/columnMenu/GridColumnHeaderMenu.js +2 -1
  249. package/modern/components/panel/GridPanel.js +18 -20
  250. package/modern/components/panel/GridPanelContent.js +6 -8
  251. package/modern/components/panel/GridPanelFooter.js +5 -6
  252. package/modern/components/panel/GridPanelHeader.js +4 -5
  253. package/modern/components/panel/filterPanel/GridFilterForm.js +13 -20
  254. package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.ts +2 -2
  255. package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +10 -39
  256. package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.d.ts +2 -2
  257. package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.js +19 -44
  258. package/modern/components/panel/filterPanel/GridFilterInputValue.js +3 -6
  259. package/modern/components/toolbar/GridToolbarFilterButton.js +5 -6
  260. package/modern/components/toolbar/GridToolbarQuickFilter.js +23 -30
  261. package/modern/components/virtualization/GridVirtualScrollbar.js +3 -1
  262. package/modern/components/virtualization/GridVirtualScrollerFiller.js +2 -1
  263. package/modern/constants/cssVariables.d.ts +294 -0
  264. package/modern/constants/cssVariables.js +161 -0
  265. package/modern/constants/dataGridPropsDefaultValues.js +1 -0
  266. package/modern/constants/defaultGridSlotsComponents.js +2 -2
  267. package/modern/constants/gridClasses.d.ts +13 -0
  268. package/modern/constants/gridClasses.js +1 -1
  269. package/modern/context/GridContextProvider.js +4 -1
  270. package/modern/hooks/features/clipboard/useGridClipboard.js +3 -2
  271. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +2 -2
  272. package/modern/hooks/features/columnResize/useGridColumnResize.js +2 -1
  273. package/modern/hooks/features/columns/gridColumnsInterfaces.d.ts +1 -0
  274. package/modern/hooks/features/columns/gridColumnsSelector.d.ts +7 -0
  275. package/modern/hooks/features/columns/gridColumnsSelector.js +8 -0
  276. package/modern/hooks/features/columns/gridColumnsUtils.d.ts +3 -1
  277. package/modern/hooks/features/columns/gridColumnsUtils.js +6 -3
  278. package/modern/hooks/features/columns/index.d.ts +1 -1
  279. package/modern/hooks/features/columns/index.js +1 -1
  280. package/modern/hooks/features/columns/useGridColumns.js +4 -2
  281. package/modern/hooks/features/dataSource/gridDataSourceError.d.ts +31 -0
  282. package/modern/hooks/features/dataSource/gridDataSourceError.js +32 -0
  283. package/modern/hooks/features/dataSource/index.d.ts +2 -0
  284. package/modern/hooks/features/dataSource/index.js +2 -0
  285. package/modern/hooks/features/dataSource/models.d.ts +1 -1
  286. package/modern/hooks/features/dataSource/useGridDataSourceBase.d.ts +1 -1
  287. package/modern/hooks/features/dataSource/useGridDataSourceBase.js +27 -17
  288. package/modern/hooks/features/dimensions/useGridDimensions.js +11 -10
  289. package/modern/hooks/features/editing/useGridCellEditing.js +2 -1
  290. package/modern/hooks/features/editing/useGridRowEditing.js +2 -1
  291. package/modern/hooks/features/export/utils.js +4 -2
  292. package/modern/hooks/features/focus/useGridFocus.js +3 -2
  293. package/modern/hooks/features/index.d.ts +1 -1
  294. package/modern/hooks/features/index.js +1 -1
  295. package/modern/hooks/features/rowSelection/gridRowSelectionSelector.d.ts +3 -3
  296. package/modern/hooks/features/rowSelection/gridRowSelectionSelector.js +27 -7
  297. package/modern/hooks/features/rowSelection/useGridRowSelection.js +148 -81
  298. package/modern/hooks/features/rowSelection/utils.d.ts +2 -2
  299. package/modern/hooks/features/rowSelection/utils.js +11 -11
  300. package/modern/hooks/features/rows/gridRowsInterfaces.d.ts +1 -1
  301. package/modern/hooks/features/rows/gridRowsUtils.d.ts +2 -1
  302. package/modern/hooks/features/rows/gridRowsUtils.js +8 -0
  303. package/modern/hooks/features/rows/useGridParamsApi.js +2 -8
  304. package/modern/hooks/features/rows/useGridRowAriaAttributes.js +2 -4
  305. package/modern/hooks/features/rows/useGridRows.d.ts +2 -2
  306. package/modern/hooks/features/rows/useGridRows.js +7 -7
  307. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +5 -9
  308. package/modern/hooks/utils/useGridSelector.js +4 -1
  309. package/modern/hooks/utils/useIsSSR.js +4 -1
  310. package/modern/index.js +1 -1
  311. package/modern/internals/index.d.ts +2 -1
  312. package/modern/internals/index.js +2 -1
  313. package/modern/internals/utils/propValidation.js +1 -1
  314. package/modern/locales/bnBD.d.ts +2 -0
  315. package/modern/locales/bnBD.js +167 -0
  316. package/modern/locales/deDE.js +3 -5
  317. package/modern/locales/huHU.js +10 -13
  318. package/modern/locales/index.d.ts +1 -0
  319. package/modern/locales/index.js +1 -0
  320. package/modern/locales/ruRU.js +17 -21
  321. package/modern/material/index.d.ts +1 -0
  322. package/modern/material/index.js +164 -49
  323. package/modern/material/variables.d.ts +5 -0
  324. package/modern/material/variables.js +89 -0
  325. package/modern/models/api/gridRowSelectionApi.d.ts +4 -2
  326. package/modern/models/api/gridSortApi.d.ts +1 -1
  327. package/modern/models/configuration/gridConfiguration.d.ts +7 -1
  328. package/modern/models/gridBaseSlots.d.ts +56 -6
  329. package/modern/models/gridDataSource.d.ts +9 -4
  330. package/modern/models/gridRowSelectionManager.d.ts +9 -0
  331. package/modern/models/gridRowSelectionManager.js +36 -0
  332. package/modern/models/gridRowSelectionModel.d.ts +4 -2
  333. package/modern/models/gridSlotsComponent.d.ts +7 -27
  334. package/modern/models/gridSlotsComponentsProps.d.ts +3 -11
  335. package/modern/models/gridSortModel.d.ts +1 -1
  336. package/modern/models/index.d.ts +2 -1
  337. package/modern/models/index.js +2 -3
  338. package/modern/models/props/DataGridProps.d.ts +22 -17
  339. package/modern/utils/css/context.d.ts +14 -0
  340. package/modern/utils/css/context.js +54 -0
  341. package/modern/utils/index.d.ts +2 -1
  342. package/modern/utils/index.js +1 -1
  343. package/package.json +2 -2
  344. package/tsconfig.build.tsbuildinfo +1 -1
  345. package/utils/css/context.d.ts +14 -0
  346. package/utils/css/context.js +64 -0
  347. package/utils/index.d.ts +2 -1
  348. package/utils/index.js +8 -1
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.useGridRowSelection = exports.rowSelectionStateInitializer = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var React = _interopRequireWildcard(require("react"));
11
+ var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
11
12
  var _signature = require("../../../constants/signature");
12
13
  var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
13
14
  var _useGridApiMethod = require("../../utils/useGridApiMethod");
@@ -15,7 +16,6 @@ var _useGridLogger = require("../../utils/useGridLogger");
15
16
  var _useGridSelector = require("../../utils/useGridSelector");
16
17
  var _gridRowsSelector = require("../rows/gridRowsSelector");
17
18
  var _gridRowSelectionSelector = require("./gridRowSelectionSelector");
18
- var _pagination = require("../pagination");
19
19
  var _gridFocusStateSelector = require("../focus/gridFocusStateSelector");
20
20
  var _gridFilterSelector = require("../filter/gridFilterSelector");
21
21
  var _colDef = require("../../../colDef");
@@ -26,20 +26,14 @@ var _constants = require("../../../internals/constants");
26
26
  var _gridClasses = require("../../../constants/gridClasses");
27
27
  var _domUtils = require("../../../utils/domUtils");
28
28
  var _utils = require("./utils");
29
- const getSelectionModelPropValue = (selectionModelProp, prevSelectionModel) => {
30
- if (selectionModelProp == null) {
31
- return selectionModelProp;
32
- }
33
- if (Array.isArray(selectionModelProp)) {
34
- return selectionModelProp;
35
- }
36
- if (prevSelectionModel && prevSelectionModel[0] === selectionModelProp) {
37
- return prevSelectionModel;
38
- }
39
- return [selectionModelProp];
29
+ var _gridRowSelectionManager = require("../../../models/gridRowSelectionManager");
30
+ var _pagination = require("../pagination");
31
+ const emptyModel = {
32
+ type: 'include',
33
+ ids: new Set()
40
34
  };
41
35
  const rowSelectionStateInitializer = (state, props) => (0, _extends2.default)({}, state, {
42
- rowSelection: props.rowSelection ? getSelectionModelPropValue(props.rowSelectionModel) ?? [] : []
36
+ rowSelection: props.rowSelection ? props.rowSelectionModel ?? emptyModel : emptyModel
43
37
  });
44
38
 
45
39
  /**
@@ -58,8 +52,8 @@ const useGridRowSelection = (apiRef, props) => {
58
52
  }, [props.rowSelection]);
59
53
  const applyAutoSelection = props.signature !== _signature.GridSignature.DataGrid && (props.rowSelectionPropagation?.parents || props.rowSelectionPropagation?.descendants);
60
54
  const propRowSelectionModel = React.useMemo(() => {
61
- return getSelectionModelPropValue(props.rowSelectionModel, (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef));
62
- }, [apiRef, props.rowSelectionModel]);
55
+ return props.rowSelectionModel;
56
+ }, [props.rowSelectionModel]);
63
57
  const lastRowToggled = React.useRef(null);
64
58
  apiRef.current.registerControlState({
65
59
  stateId: 'rowSelection',
@@ -99,23 +93,30 @@ const useGridRowSelection = (apiRef, props) => {
99
93
  endId
100
94
  }, !isSelected);
101
95
  }, [apiRef]);
96
+ const getRowsToBeSelected = (0, _useEventCallback.default)(() => {
97
+ const rowsToBeSelected = props.pagination && props.checkboxSelectionVisibleOnly && props.paginationMode === 'client' ? (0, _pagination.gridPaginatedVisibleSortedGridRowIdsSelector)(apiRef) : (0, _gridFilterSelector.gridExpandedSortedRowIdsSelector)(apiRef);
98
+ return rowsToBeSelected;
99
+ });
102
100
 
103
101
  /*
104
102
  * API METHODS
105
103
  */
106
104
  const setRowSelectionModel = React.useCallback(model => {
107
- if (props.signature === _signature.GridSignature.DataGrid && !canHaveMultipleSelection && Array.isArray(model) && model.length > 1) {
105
+ if (props.signature === _signature.GridSignature.DataGrid && !canHaveMultipleSelection && (model.type !== 'include' || model.ids.size > 1)) {
108
106
  throw new Error(['MUI X: `rowSelectionModel` can only contain 1 item in DataGrid.', 'You need to upgrade to DataGridPro or DataGridPremium component to unlock multiple selection.'].join('\n'));
109
107
  }
110
108
  const currentModel = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef);
111
109
  if (currentModel !== model) {
112
110
  logger.debug(`Setting selection model`);
113
111
  apiRef.current.setState(state => (0, _extends2.default)({}, state, {
114
- rowSelection: props.rowSelection ? model : []
112
+ rowSelection: props.rowSelection ? model : emptyModel
115
113
  }));
116
114
  }
117
115
  }, [apiRef, logger, props.rowSelection, props.signature, canHaveMultipleSelection]);
118
- const isRowSelected = React.useCallback(id => (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef).includes(id), [apiRef]);
116
+ const isRowSelected = React.useCallback(id => {
117
+ const selectionManager = (0, _gridRowSelectionSelector.gridRowSelectionManagerSelector)(apiRef);
118
+ return selectionManager.has(id);
119
+ }, [apiRef]);
119
120
  const isRowSelectable = React.useCallback(id => {
120
121
  if (props.rowSelection === false) {
121
122
  return false;
@@ -129,7 +130,7 @@ const useGridRowSelection = (apiRef, props) => {
129
130
  }
130
131
  return true;
131
132
  }, [apiRef, props.rowSelection, propIsRowSelectable]);
132
- const getSelectedRows = React.useCallback(() => (0, _gridRowSelectionSelector.selectedGridRowsSelector)(apiRef), [apiRef]);
133
+ const getSelectedRows = React.useCallback(() => (0, _gridRowSelectionSelector.gridRowSelectionIdsSelector)(apiRef), [apiRef]);
133
134
  const selectRow = React.useCallback((id, isSelected = true, resetSelection = false) => {
134
135
  if (!apiRef.current.isRowSelectable(id)) {
135
136
  return;
@@ -137,9 +138,12 @@ const useGridRowSelection = (apiRef, props) => {
137
138
  lastRowToggled.current = id;
138
139
  if (resetSelection) {
139
140
  logger.debug(`Setting selection for row ${id}`);
140
- const newSelection = [];
141
+ const newSelectionModel = {
142
+ type: 'include',
143
+ ids: new Set()
144
+ };
141
145
  const addRow = rowId => {
142
- newSelection.push(rowId);
146
+ newSelectionModel.ids.add(rowId);
143
147
  };
144
148
  if (isSelected) {
145
149
  addRow(id);
@@ -147,17 +151,21 @@ const useGridRowSelection = (apiRef, props) => {
147
151
  (0, _utils.findRowsToSelect)(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, addRow);
148
152
  }
149
153
  }
150
- apiRef.current.setRowSelectionModel(newSelection);
154
+ apiRef.current.setRowSelectionModel(newSelectionModel);
151
155
  } else {
152
156
  logger.debug(`Toggling selection for row ${id}`);
153
- const selection = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef);
154
- const newSelection = new Set(selection);
155
- newSelection.delete(id);
157
+ const selectionModel = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef);
158
+ const newSelectionModel = {
159
+ type: selectionModel.type,
160
+ ids: new Set(selectionModel.ids)
161
+ };
162
+ const selectionManager = (0, _gridRowSelectionManager.createRowSelectionManager)(newSelectionModel);
163
+ selectionManager.unselect(id);
156
164
  const addRow = rowId => {
157
- newSelection.add(rowId);
165
+ selectionManager.select(rowId);
158
166
  };
159
167
  const removeRow = rowId => {
160
- newSelection.delete(rowId);
168
+ selectionManager.unselect(rowId);
161
169
  };
162
170
  if (isSelected) {
163
171
  addRow(id);
@@ -167,45 +175,62 @@ const useGridRowSelection = (apiRef, props) => {
167
175
  } else if (applyAutoSelection) {
168
176
  (0, _utils.findRowsToDeselect)(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, removeRow);
169
177
  }
170
- const isSelectionValid = newSelection.size < 2 || canHaveMultipleSelection;
178
+ const isSelectionValid = newSelectionModel.type === 'include' && newSelectionModel.ids.size < 2 || canHaveMultipleSelection;
171
179
  if (isSelectionValid) {
172
- apiRef.current.setRowSelectionModel(Array.from(newSelection));
180
+ apiRef.current.setRowSelectionModel(newSelectionModel);
173
181
  }
174
182
  }
175
183
  }, [apiRef, logger, applyAutoSelection, tree, props.rowSelectionPropagation?.descendants, props.rowSelectionPropagation?.parents, canHaveMultipleSelection]);
176
184
  const selectRows = React.useCallback((ids, isSelected = true, resetSelection = false) => {
177
185
  logger.debug(`Setting selection for several rows`);
178
- const selectableIds = ids.filter(id => apiRef.current.isRowSelectable(id));
179
- let newSelection;
186
+ if (props.rowSelection === false) {
187
+ return;
188
+ }
189
+ const selectableIds = new Set();
190
+ for (let i = 0; i < ids.length; i += 1) {
191
+ const id = ids[i];
192
+ if (apiRef.current.isRowSelectable(id)) {
193
+ selectableIds.add(id);
194
+ }
195
+ }
196
+ const currentSelectionModel = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef);
197
+ let newSelectionModel;
180
198
  if (resetSelection) {
199
+ newSelectionModel = {
200
+ type: 'include',
201
+ ids: selectableIds
202
+ };
181
203
  if (isSelected) {
182
- newSelection = new Set(selectableIds);
204
+ const selectionManager = (0, _gridRowSelectionManager.createRowSelectionManager)(newSelectionModel);
183
205
  if (applyAutoSelection) {
184
206
  const addRow = rowId => {
185
- newSelection.add(rowId);
207
+ selectionManager.select(rowId);
186
208
  };
187
- selectableIds.forEach(id => {
209
+ for (const id of selectableIds) {
188
210
  (0, _utils.findRowsToSelect)(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, addRow);
189
- });
211
+ }
190
212
  }
191
213
  } else {
192
- newSelection = new Set();
214
+ newSelectionModel.ids = new Set();
193
215
  }
194
- const currentLookup = (0, _gridRowSelectionSelector.selectedIdsLookupSelector)(apiRef);
195
- if (newSelection.size === Object.keys(currentLookup).length && Array.from(newSelection).every(id => currentLookup[id] === id)) {
216
+ if (currentSelectionModel.type === newSelectionModel.type && newSelectionModel.ids.size === currentSelectionModel.ids.size && Array.from(newSelectionModel.ids).every(id => currentSelectionModel.ids.has(id))) {
196
217
  return;
197
218
  }
198
219
  } else {
199
- newSelection = new Set(Object.values((0, _gridRowSelectionSelector.selectedIdsLookupSelector)(apiRef)));
220
+ newSelectionModel = {
221
+ type: currentSelectionModel.type,
222
+ ids: new Set(currentSelectionModel.ids)
223
+ };
224
+ const selectionManager = (0, _gridRowSelectionManager.createRowSelectionManager)(newSelectionModel);
200
225
  const addRow = rowId => {
201
- newSelection.add(rowId);
226
+ selectionManager.select(rowId);
202
227
  };
203
228
  const removeRow = rowId => {
204
- newSelection.delete(rowId);
229
+ selectionManager.unselect(rowId);
205
230
  };
206
- selectableIds.forEach(id => {
231
+ for (const id of selectableIds) {
207
232
  if (isSelected) {
208
- newSelection.add(id);
233
+ selectionManager.select(id);
209
234
  if (applyAutoSelection) {
210
235
  (0, _utils.findRowsToSelect)(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, addRow);
211
236
  }
@@ -215,13 +240,13 @@ const useGridRowSelection = (apiRef, props) => {
215
240
  (0, _utils.findRowsToDeselect)(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, removeRow);
216
241
  }
217
242
  }
218
- });
243
+ }
219
244
  }
220
- const isSelectionValid = newSelection.size < 2 || canHaveMultipleSelection;
245
+ const isSelectionValid = newSelectionModel.type === 'include' && newSelectionModel.ids.size < 2 || canHaveMultipleSelection;
221
246
  if (isSelectionValid) {
222
- apiRef.current.setRowSelectionModel(Array.from(newSelection));
247
+ apiRef.current.setRowSelectionModel(newSelectionModel);
223
248
  }
224
- }, [logger, applyAutoSelection, canHaveMultipleSelection, apiRef, tree, props.rowSelectionPropagation?.descendants, props.rowSelectionPropagation?.parents]);
249
+ }, [logger, applyAutoSelection, canHaveMultipleSelection, apiRef, tree, props.rowSelectionPropagation?.descendants, props.rowSelectionPropagation?.parents, props.rowSelection]);
225
250
  const selectRowRange = React.useCallback(({
226
251
  startId,
227
252
  endId
@@ -260,57 +285,72 @@ const useGridRowSelection = (apiRef, props) => {
260
285
  const currentSelection = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef);
261
286
  const rowsLookup = (0, _gridRowsSelector.gridRowsLookupSelector)(apiRef);
262
287
  const filteredRowsLookup = (0, _gridFilterSelector.gridFilteredRowsLookupSelector)(apiRef);
263
-
264
- // We clone the existing object to avoid mutating the same object returned by the selector to others part of the project
265
- const selectionLookup = (0, _extends2.default)({}, (0, _gridRowSelectionSelector.selectedIdsLookupSelector)(apiRef));
266
288
  const isNonExistent = id => {
267
289
  if (props.filterMode === 'server') {
268
290
  return !rowsLookup[id];
269
291
  }
270
292
  return !rowsLookup[id] || filteredRowsLookup[id] === false;
271
293
  };
294
+ const newSelectionModel = {
295
+ type: currentSelection.type,
296
+ ids: new Set(currentSelection.ids)
297
+ };
298
+ const selectionManager = (0, _gridRowSelectionManager.createRowSelectionManager)(newSelectionModel);
272
299
  let hasChanged = false;
273
- currentSelection.forEach(id => {
300
+ for (const id of currentSelection.ids) {
274
301
  if (isNonExistent(id)) {
275
302
  if (props.keepNonExistentRowsSelected) {
276
- return;
303
+ continue;
277
304
  }
278
- delete selectionLookup[id];
305
+ selectionManager.unselect(id);
279
306
  hasChanged = true;
280
- return;
307
+ continue;
281
308
  }
282
309
  if (!props.rowSelectionPropagation?.parents) {
283
- return;
310
+ continue;
284
311
  }
285
312
  const node = tree[id];
286
- if (node.type === 'group') {
313
+ if (node?.type === 'group') {
287
314
  const isAutoGenerated = node.isAutoGenerated;
288
315
  if (isAutoGenerated) {
289
- delete selectionLookup[id];
316
+ selectionManager.unselect(id);
290
317
  hasChanged = true;
291
- return;
318
+ continue;
292
319
  }
293
320
  // Keep previously selected tree data parents selected if all their children are filtered out
294
321
  if (!node.children.every(childId => filteredRowsLookup[childId] === false)) {
295
- delete selectionLookup[id];
322
+ selectionManager.unselect(id);
296
323
  hasChanged = true;
297
324
  }
298
325
  }
299
- });
326
+ }
300
327
 
301
328
  // For nested data, on row tree updation (filtering, adding rows, etc.) when the selection is
302
329
  // not empty, we need to re-run scanning of the tree to propagate the selection changes
303
330
  // Example: A parent whose de-selected children are filtered out should now be selected
304
- const shouldReapplyPropagation = isNestedData && props.rowSelectionPropagation?.parents && Object.keys(selectionLookup).length > 0;
331
+ const shouldReapplyPropagation = isNestedData && props.rowSelectionPropagation?.parents && (newSelectionModel.ids.size > 0 ||
332
+ // In case of exclude selection, newSelectionModel.ids.size === 0 means all rows are selected
333
+ newSelectionModel.type === 'exclude');
305
334
  if (hasChanged || shouldReapplyPropagation && !sortModelUpdated) {
306
- const newSelection = Object.values(selectionLookup);
307
335
  if (shouldReapplyPropagation) {
308
- apiRef.current.selectRows(newSelection, true, true);
336
+ if (newSelectionModel.type === 'exclude') {
337
+ const unfilteredSelectedRowIds = getRowsToBeSelected();
338
+ const selectedRowIds = [];
339
+ for (let i = 0; i < unfilteredSelectedRowIds.length; i += 1) {
340
+ const rowId = unfilteredSelectedRowIds[i];
341
+ if ((props.keepNonExistentRowsSelected || !isNonExistent(rowId)) && selectionManager.has(rowId)) {
342
+ selectedRowIds.push(rowId);
343
+ }
344
+ }
345
+ apiRef.current.selectRows(selectedRowIds, true, true);
346
+ } else {
347
+ apiRef.current.selectRows(Array.from(newSelectionModel.ids), true, true);
348
+ }
309
349
  } else {
310
- apiRef.current.setRowSelectionModel(newSelection);
350
+ apiRef.current.setRowSelectionModel(newSelectionModel);
311
351
  }
312
352
  }
313
- }, [apiRef, isNestedData, props.rowSelectionPropagation?.parents, props.keepNonExistentRowsSelected, props.filterMode, tree]);
353
+ }, [apiRef, isNestedData, props.rowSelectionPropagation?.parents, props.keepNonExistentRowsSelected, props.filterMode, tree, getRowsToBeSelected]);
314
354
  const handleSingleRowSelection = React.useCallback((id, event) => {
315
355
  const hasCtrlKey = event.metaKey || event.ctrlKey;
316
356
 
@@ -321,7 +361,7 @@ const useGridRowSelection = (apiRef, props) => {
321
361
 
322
362
  const isMultipleSelectionDisabled = !checkboxSelection && !hasCtrlKey && !(0, _keyboardUtils.isKeyboardEvent)(event);
323
363
  const resetSelection = !canHaveMultipleSelection || isMultipleSelectionDisabled;
324
- const selectedRowsCount = apiRef.current.getSelectedRows().size;
364
+ const selectedRowsCount = (0, _gridRowSelectionSelector.gridRowSelectionCountSelector)(apiRef);
325
365
  if (canHaveMultipleSelection && selectedRowsCount > 1 && !hasCtrlKey) {
326
366
  apiRef.current.selectRow(id, true, resetSelection);
327
367
  } else {
@@ -370,10 +410,22 @@ const useGridRowSelection = (apiRef, props) => {
370
410
  apiRef.current.selectRow(params.id, params.value, !canHaveMultipleSelection);
371
411
  }
372
412
  }, [apiRef, expandMouseRowRangeSelection, canHaveMultipleSelection]);
413
+ const toggleAllRows = React.useCallback(value => {
414
+ const filterModel = (0, _gridFilterSelector.gridFilterModelSelector)(apiRef);
415
+ const quickFilterModel = (0, _gridFilterSelector.gridQuickFilterValuesSelector)(apiRef);
416
+ const hasFilters = filterModel.items.length > 0 || (quickFilterModel?.length || 0) > 0;
417
+ if (!props.isRowSelectable && !props.checkboxSelectionVisibleOnly && applyAutoSelection && !hasFilters) {
418
+ apiRef.current.setRowSelectionModel({
419
+ type: value ? 'exclude' : 'include',
420
+ ids: new Set()
421
+ });
422
+ } else {
423
+ apiRef.current.selectRows(getRowsToBeSelected(), value);
424
+ }
425
+ }, [apiRef, applyAutoSelection, getRowsToBeSelected, props.checkboxSelectionVisibleOnly, props.isRowSelectable]);
373
426
  const handleHeaderSelectionCheckboxChange = React.useCallback(params => {
374
- const rowsToBeSelected = props.pagination && props.checkboxSelectionVisibleOnly && props.paginationMode === 'client' ? (0, _pagination.gridPaginatedVisibleSortedGridRowIdsSelector)(apiRef) : (0, _gridFilterSelector.gridExpandedSortedRowIdsSelector)(apiRef);
375
- apiRef.current.selectRows(rowsToBeSelected, params.value);
376
- }, [apiRef, props.checkboxSelectionVisibleOnly, props.pagination, props.paginationMode]);
427
+ toggleAllRows(params.value);
428
+ }, [toggleAllRows]);
377
429
  const handleCellKeyDown = React.useCallback((params, event) => {
378
430
  // Get the most recent cell mode because it may have been changed by another listener
379
431
  if (apiRef.current.getCellMode(params.id, params.field) === _gridEditRowModel.GridCellModes.Edit) {
@@ -422,7 +474,10 @@ const useGridRowSelection = (apiRef, props) => {
422
474
  }
423
475
  }
424
476
  const visibleRows = (0, _useGridVisibleRows.getVisibleRows)(apiRef);
425
- const rowsBetweenStartAndEnd = visibleRows.rows.slice(start, end + 1).map(row => row.id);
477
+ const rowsBetweenStartAndEnd = [];
478
+ for (let i = start; i <= end; i += 1) {
479
+ rowsBetweenStartAndEnd.push(visibleRows.rows[i].id);
480
+ }
426
481
  apiRef.current.selectRows(rowsBetweenStartAndEnd, !isNextRowSelected);
427
482
  return;
428
483
  }
@@ -434,9 +489,9 @@ const useGridRowSelection = (apiRef, props) => {
434
489
  }
435
490
  if (String.fromCharCode(event.keyCode) === 'A' && (event.ctrlKey || event.metaKey)) {
436
491
  event.preventDefault();
437
- selectRows(apiRef.current.getAllRowIds(), true);
492
+ toggleAllRows(true);
438
493
  }
439
- }, [apiRef, handleSingleRowSelection, selectRows, canHaveMultipleSelection]);
494
+ }, [apiRef, canHaveMultipleSelection, handleSingleRowSelection, toggleAllRows]);
440
495
  (0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'sortedRowsSet', runIfRowSelectionIsEnabled(() => removeOutdatedSelection(true)));
441
496
  (0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'filteredRowsSet', runIfRowSelectionIsEnabled(removeOutdatedSelection));
442
497
  (0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'rowClick', runIfRowSelectionIsEnabled(handleRowClick));
@@ -455,7 +510,7 @@ const useGridRowSelection = (apiRef, props) => {
455
510
  }, [apiRef, propRowSelectionModel, props.rowSelection]);
456
511
  React.useEffect(() => {
457
512
  if (!props.rowSelection) {
458
- apiRef.current.setRowSelectionModel([]);
513
+ apiRef.current.setRowSelectionModel(emptyModel);
459
514
  }
460
515
  }, [apiRef, props.rowSelection]);
461
516
  const isStateControlled = propRowSelectionModel != null;
@@ -466,10 +521,22 @@ const useGridRowSelection = (apiRef, props) => {
466
521
 
467
522
  // props.isRowSelectable changed
468
523
  const currentSelection = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef);
469
- if (isRowSelectable) {
470
- const newSelection = currentSelection.filter(id => isRowSelectable(id));
471
- if (newSelection.length < currentSelection.length) {
472
- apiRef.current.setRowSelectionModel(newSelection);
524
+ if (typeof isRowSelectable === 'function') {
525
+ let selectableIds = new Set();
526
+ if (currentSelection.type === 'include') {
527
+ for (const id of currentSelection.ids) {
528
+ if (isRowSelectable(id)) {
529
+ selectableIds.add(id);
530
+ }
531
+ }
532
+ } else {
533
+ selectableIds = new Set(currentSelection.ids);
534
+ }
535
+ if (currentSelection.type === 'include' && selectableIds.size < currentSelection.ids.size) {
536
+ apiRef.current.setRowSelectionModel({
537
+ type: currentSelection.type,
538
+ ids: selectableIds
539
+ });
473
540
  }
474
541
  }
475
542
  }, [apiRef, isRowSelectable, isStateControlled, props.rowSelection]);
@@ -478,9 +545,9 @@ const useGridRowSelection = (apiRef, props) => {
478
545
  return;
479
546
  }
480
547
  const currentSelection = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef);
481
- if (!canHaveMultipleSelection && currentSelection.length > 1) {
548
+ if (!canHaveMultipleSelection && (currentSelection.type === 'include' && currentSelection.ids.size > 1 || currentSelection.type === 'exclude')) {
482
549
  // See https://github.com/mui/mui-x/issues/8455
483
- apiRef.current.setRowSelectionModel([]);
550
+ apiRef.current.setRowSelectionModel(emptyModel);
484
551
  }
485
552
  }, [apiRef, canHaveMultipleSelection, checkboxSelection, isStateControlled, props.rowSelection]);
486
553
  React.useEffect(() => {
@@ -2,9 +2,9 @@ import { RefObject } from '@mui/x-internals/types';
2
2
  import type { GridRowId, GridRowTreeConfig } from '../../../models/gridRows';
3
3
  import type { DataGridProcessedProps } from '../../../models/props/DataGridProps';
4
4
  import type { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
5
- import type { GridRowSelectionPropagation } from '../../../models/gridRowSelectionModel';
5
+ import { type GridRowSelectionPropagation } from "../../../models/gridRowSelectionModel.js";
6
6
  export declare const ROW_SELECTION_PROPAGATION_DEFAULT: GridRowSelectionPropagation;
7
- export declare function getCheckboxPropsSelector(groupId: GridRowId, autoSelectParents: boolean): import("../../..").OutputSelector<import("../../../models/gridStateCommunity").GridStateCommunity, Record<GridRowId, GridRowId>, {
7
+ export declare function getCheckboxPropsSelector(groupId: GridRowId, autoSelectParents: boolean): import("../../..").OutputSelector<import("../../../models/gridStateCommunity").GridStateCommunity, import("../../../models/gridRowSelectionManager").RowSelectionManager, {
8
8
  isIndeterminate: boolean;
9
9
  isChecked: boolean;
10
10
  }>;
@@ -38,15 +38,15 @@ function getGridRowGroupSelectableDescendants(apiRef, groupId) {
38
38
 
39
39
  // TODO v8: Use `createSelectorV8`
40
40
  function getCheckboxPropsSelector(groupId, autoSelectParents) {
41
- return (0, _createSelector.createSelector)(_gridRowsSelector.gridRowTreeSelector, _gridSortingSelector.gridSortedRowIdsSelector, _gridFilterSelector.gridFilteredRowsLookupSelector, _gridRowSelectionSelector.selectedIdsLookupSelector, (rowTree, sortedRowIds, filteredRowsLookup, rowSelectionLookup) => {
41
+ return (0, _createSelector.createSelector)(_gridRowsSelector.gridRowTreeSelector, _gridSortingSelector.gridSortedRowIdsSelector, _gridFilterSelector.gridFilteredRowsLookupSelector, _gridRowSelectionSelector.gridRowSelectionManagerSelector, (rowTree, sortedRowIds, filteredRowsLookup, rowSelectionManager) => {
42
42
  const groupNode = rowTree[groupId];
43
43
  if (!groupNode || groupNode.type !== 'group') {
44
44
  return {
45
45
  isIndeterminate: false,
46
- isChecked: rowSelectionLookup[groupId] === groupId
46
+ isChecked: rowSelectionManager.has(groupId)
47
47
  };
48
48
  }
49
- if (rowSelectionLookup[groupId] === groupId) {
49
+ if (rowSelectionManager.has(groupId)) {
50
50
  return {
51
51
  isIndeterminate: false,
52
52
  isChecked: true
@@ -59,14 +59,14 @@ function getCheckboxPropsSelector(groupId, autoSelectParents) {
59
59
  const id = sortedRowIds[index];
60
60
  if (filteredRowsLookup[id] !== false) {
61
61
  selectableDescendantsCount += 1;
62
- if (rowSelectionLookup[id] !== undefined) {
62
+ if (rowSelectionManager.has(id)) {
63
63
  selectedDescendantsCount += 1;
64
64
  }
65
65
  }
66
66
  }
67
67
  return {
68
- isIndeterminate: selectedDescendantsCount > 0 && (selectedDescendantsCount < selectableDescendantsCount || rowSelectionLookup[groupId] === undefined),
69
- isChecked: autoSelectParents ? selectedDescendantsCount > 0 : rowSelectionLookup[groupId] === groupId
68
+ isIndeterminate: selectedDescendantsCount > 0 && (selectedDescendantsCount < selectableDescendantsCount || !rowSelectionManager.has(groupId)),
69
+ isChecked: autoSelectParents ? selectedDescendantsCount > 0 : rowSelectionManager.has(groupId)
70
70
  };
71
71
  });
72
72
  }
@@ -104,7 +104,7 @@ const getFilteredRowNodeSiblings = (tree, filteredRows, id) => {
104
104
  };
105
105
  const findRowsToSelect = (apiRef, tree, selectedRow, autoSelectDescendants, autoSelectParents, addRow) => {
106
106
  const filteredRows = (0, _gridFilterSelector.gridFilteredRowsLookupSelector)(apiRef);
107
- const selectedIdsLookup = (0, _gridRowSelectionSelector.selectedIdsLookupSelector)(apiRef);
107
+ const rowSelectionManager = (0, _gridRowSelectionSelector.gridRowSelectionManagerSelector)(apiRef);
108
108
  const selectedDescendants = new Set([]);
109
109
  if (!autoSelectDescendants && !autoSelectParents) {
110
110
  return;
@@ -121,7 +121,7 @@ const findRowsToSelect = (apiRef, tree, selectedRow, autoSelectDescendants, auto
121
121
  }
122
122
  if (autoSelectParents) {
123
123
  const checkAllDescendantsSelected = rowId => {
124
- if (selectedIdsLookup[rowId] !== rowId && !selectedDescendants.has(rowId)) {
124
+ if (!rowSelectionManager.has(rowId) && !selectedDescendants.has(rowId)) {
125
125
  return false;
126
126
  }
127
127
  const node = tree[rowId];
@@ -147,14 +147,14 @@ const findRowsToSelect = (apiRef, tree, selectedRow, autoSelectDescendants, auto
147
147
  };
148
148
  exports.findRowsToSelect = findRowsToSelect;
149
149
  const findRowsToDeselect = (apiRef, tree, deselectedRow, autoSelectDescendants, autoSelectParents, removeRow) => {
150
- const selectedIdsLookup = (0, _gridRowSelectionSelector.selectedIdsLookupSelector)(apiRef);
150
+ const rowSelectionManager = (0, _gridRowSelectionSelector.gridRowSelectionManagerSelector)(apiRef);
151
151
  if (!autoSelectParents && !autoSelectDescendants) {
152
152
  return;
153
153
  }
154
154
  if (autoSelectParents) {
155
155
  const allParents = getRowNodeParents(tree, deselectedRow);
156
156
  allParents.forEach(parent => {
157
- const isSelected = selectedIdsLookup[parent] === parent;
157
+ const isSelected = rowSelectionManager.has(parent);
158
158
  if (isSelected) {
159
159
  removeRow(parent);
160
160
  }
@@ -61,7 +61,7 @@ export interface GridRowsState {
61
61
  /**
62
62
  * Contains some values of type `GridRowId` that have been requested to be fetched
63
63
  * either by `defaultGroupingExpansionDepth` or `isGroupExpandedByDefault` props.
64
- * Applicable with server-side grouped data and `unstable_dataSource` only.
64
+ * Applicable with server-side grouped data and `dataSource` only.
65
65
  */
66
66
  groupsToFetch?: GridRowId[];
67
67
  }
@@ -1,5 +1,5 @@
1
1
  import { RefObject } from '@mui/x-internals/types';
2
- import { GridAutoGeneratedGroupNode, GridAutoGeneratedPinnedRowNode, GridFooterNode, GridGroupNode, GridRowId, GridRowIdGetter, GridRowModel, GridRowModelUpdate, GridRowTreeConfig, GridSkeletonRowNode, GridTreeNode } from "../../../models/index.js";
2
+ import { GridAutoGeneratedGroupNode, GridAutoGeneratedPinnedRowNode, GridColDef, GridFooterNode, GridGroupNode, GridRowId, GridRowIdGetter, GridRowModel, GridRowModelUpdate, GridRowTreeConfig, GridSkeletonRowNode, GridTreeNode, GridValidRowModel } from "../../../models/index.js";
3
3
  import { DataGridProcessedProps } from "../../../models/props/DataGridProps.js";
4
4
  import { GridApiCommunity, GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
5
5
  import { GridRowsInternalCache, GridRowsState, GridRowTreeCreationParams } from "./gridRowsInterfaces.js";
@@ -14,6 +14,7 @@ export declare const buildRootGroup: () => GridGroupNode;
14
14
  */
15
15
  export declare function checkGridRowIdIsValid(id: GridRowId, row: GridRowModel | Partial<GridRowModel>, detailErrorMessage?: string): void;
16
16
  export declare const getRowIdFromRowModel: (rowModel: GridRowModel, getRowId?: GridRowIdGetter, detailErrorMessage?: string) => GridRowId;
17
+ export declare const getRowValue: (row: GridValidRowModel, colDef: GridColDef, apiRef: RefObject<GridApiCommunity>) => any;
17
18
  export declare const createRowsInternalCache: ({
18
19
  rows,
19
20
  getRowId,
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.buildRootGroup = exports.GRID_ROOT_GROUP_ID = exports.GRID_ID_AUTOGENERATED = void 0;
8
8
  exports.checkGridRowIdIsValid = checkGridRowIdIsValid;
9
9
  exports.computeRowsUpdates = computeRowsUpdates;
10
- exports.updateCacheWithNewRows = exports.rowHeightWarning = exports.minimalContentHeight = exports.isAutogeneratedRowNode = exports.isAutogeneratedRow = exports.getValidRowHeight = exports.getTreeNodeDescendants = exports.getTopLevelRowCount = exports.getRowsStateFromCache = exports.getRowIdFromRowModel = exports.getRowHeightWarning = exports.createRowsInternalCache = void 0;
10
+ exports.updateCacheWithNewRows = exports.rowHeightWarning = exports.minimalContentHeight = exports.isAutogeneratedRowNode = exports.isAutogeneratedRow = exports.getValidRowHeight = exports.getTreeNodeDescendants = exports.getTopLevelRowCount = exports.getRowsStateFromCache = exports.getRowValue = exports.getRowIdFromRowModel = exports.getRowHeightWarning = exports.createRowsInternalCache = void 0;
11
11
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
12
12
  var _gridRowsSelector = require("./gridRowsSelector");
13
13
  const GRID_ROOT_GROUP_ID = exports.GRID_ROOT_GROUP_ID = `auto-generated-group-node-root`;
@@ -43,6 +43,15 @@ const getRowIdFromRowModel = (rowModel, getRowId, detailErrorMessage) => {
43
43
  return id;
44
44
  };
45
45
  exports.getRowIdFromRowModel = getRowIdFromRowModel;
46
+ const getRowValue = (row, colDef, apiRef) => {
47
+ const field = colDef.field;
48
+ if (!colDef || !colDef.valueGetter) {
49
+ return row[field];
50
+ }
51
+ const value = row[colDef.field];
52
+ return colDef.valueGetter(value, row, colDef, apiRef);
53
+ };
54
+ exports.getRowValue = getRowValue;
46
55
  const createRowsInternalCache = ({
47
56
  rows,
48
57
  getRowId,
@@ -12,6 +12,7 @@ var _useGridApiMethod = require("../../utils/useGridApiMethod");
12
12
  var _gridFocusStateSelector = require("../focus/gridFocusStateSelector");
13
13
  var _gridListViewSelectors = require("../listView/gridListViewSelectors");
14
14
  var _gridRowsSelector = require("./gridRowsSelector");
15
+ var _gridRowsUtils = require("./gridRowsUtils");
15
16
  class MissingRowIdError extends Error {}
16
17
 
17
18
  /**
@@ -97,14 +98,7 @@ function useGridParamsApi(apiRef, props) {
97
98
  }
98
99
  return colDef.valueGetter(row[colDef.field], row, colDef, apiRef);
99
100
  }, [apiRef]);
100
- const getRowValue = React.useCallback((row, colDef) => {
101
- const field = colDef.field;
102
- if (!colDef || !colDef.valueGetter) {
103
- return row[field];
104
- }
105
- const value = row[colDef.field];
106
- return colDef.valueGetter(value, row, colDef, apiRef);
107
- }, [apiRef]);
101
+ const getRowValue = React.useCallback((row, colDef) => (0, _gridRowsUtils.getRowValue)(row, colDef, apiRef), [apiRef]);
108
102
  const getRowFormattedValue = React.useCallback((row, colDef) => {
109
103
  const value = getRowValue(row, colDef);
110
104
  if (!colDef || !colDef.valueFormatter) {
@@ -6,22 +6,20 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.useGridRowAriaAttributes = void 0;
8
8
  var React = _interopRequireWildcard(require("react"));
9
- var _rowSelection = require("../rowSelection");
10
9
  var _useGridSelector = require("../../utils/useGridSelector");
11
10
  var _gridColumnGroupsSelector = require("../columnGrouping/gridColumnGroupsSelector");
12
11
  var _useGridPrivateApiContext = require("../../utils/useGridPrivateApiContext");
13
12
  const useGridRowAriaAttributes = () => {
14
13
  const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
15
- const selectedIdsLookup = (0, _useGridSelector.useGridSelector)(apiRef, _rowSelection.selectedIdsLookupSelector);
16
14
  const headerGroupingMaxDepth = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnGroupsSelector.gridColumnGroupsHeaderMaxDepthSelector);
17
15
  return React.useCallback((rowNode, index) => {
18
16
  const ariaAttributes = {};
19
17
  const ariaRowIndex = index + headerGroupingMaxDepth + 2; // 1 for the header row and 1 as it's 1-based
20
18
  ariaAttributes['aria-rowindex'] = ariaRowIndex;
21
19
  if (apiRef.current.isRowSelectable(rowNode.id)) {
22
- ariaAttributes['aria-selected'] = selectedIdsLookup[rowNode.id] !== undefined;
20
+ ariaAttributes['aria-selected'] = apiRef.current.isRowSelected(rowNode.id);
23
21
  }
24
22
  return ariaAttributes;
25
- }, [apiRef, selectedIdsLookup, headerGroupingMaxDepth]);
23
+ }, [apiRef, headerGroupingMaxDepth]);
26
24
  };
27
25
  exports.useGridRowAriaAttributes = useGridRowAriaAttributes;
@@ -2,5 +2,5 @@ import { RefObject } from '@mui/x-internals/types';
2
2
  import { DataGridProcessedProps } from "../../../models/props/DataGridProps.js";
3
3
  import { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
4
4
  import { GridStateInitializer } from "../../utils/useGridInitializeState.js";
5
- export declare const rowsStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'unstable_dataSource' | 'rows' | 'rowCount' | 'getRowId' | 'loading'>>;
6
- export declare const useGridRows: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "rows" | "getRowId" | "rowCount" | "throttleRowsMs" | "signature" | "pagination" | "paginationMode" | "loading" | "unstable_dataSource">) => void;
5
+ export declare const rowsStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'dataSource' | 'rows' | 'rowCount' | 'getRowId' | 'loading'>>;
6
+ export declare const useGridRows: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "rows" | "getRowId" | "rowCount" | "throttleRowsMs" | "signature" | "pagination" | "paginationMode" | "loading" | "dataSource">) => void;