@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
@@ -218,7 +218,8 @@ export const createColumnsState = ({
218
218
  columnsToUpsert,
219
219
  initialState,
220
220
  columnVisibilityModel = gridColumnVisibilityModelSelector(apiRef),
221
- keepOnlyColumnsToUpsert = false
221
+ keepOnlyColumnsToUpsert = false,
222
+ updateInitialVisibilityModel = false
222
223
  }) => {
223
224
  const isInsideStateInitializer = !apiRef.current.state.columns;
224
225
  let columnsState;
@@ -226,7 +227,8 @@ export const createColumnsState = ({
226
227
  columnsState = {
227
228
  orderedFields: [],
228
229
  lookup: {},
229
- columnVisibilityModel
230
+ columnVisibilityModel,
231
+ initialColumnVisibilityModel: columnVisibilityModel
230
232
  };
231
233
  } else {
232
234
  const currentState = gridColumnsStateSelector(apiRef);
@@ -234,7 +236,8 @@ export const createColumnsState = ({
234
236
  orderedFields: keepOnlyColumnsToUpsert ? [] : [...currentState.orderedFields],
235
237
  lookup: _extends({}, currentState.lookup),
236
238
  // Will be cleaned later if keepOnlyColumnsToUpsert=true
237
- columnVisibilityModel
239
+ columnVisibilityModel,
240
+ initialColumnVisibilityModel: updateInitialVisibilityModel ? columnVisibilityModel : currentState.initialColumnVisibilityModel
238
241
  };
239
242
  }
240
243
  let columnsToKeep = {};
@@ -1,2 +1,2 @@
1
- export * from "./gridColumnsSelector.js";
1
+ export { gridColumnsStateSelector, gridColumnFieldsSelector, gridColumnLookupSelector, gridColumnVisibilityModelSelector, gridColumnDefinitionsSelector, gridVisibleColumnDefinitionsSelector, gridVisibleColumnFieldsSelector, gridPinnedColumnsSelector, gridVisiblePinnedColumnDefinitionsSelector, gridColumnPositionsSelector, gridFilterableColumnDefinitionsSelector, gridFilterableColumnLookupSelector, gridHasColSpanSelector } from "./gridColumnsSelector.js";
2
2
  export * from "./gridColumnsInterfaces.js";
@@ -1,2 +1,2 @@
1
- export * from "./gridColumnsSelector.js";
1
+ export { gridColumnsStateSelector, gridColumnFieldsSelector, gridColumnLookupSelector, gridColumnVisibilityModelSelector, gridColumnDefinitionsSelector, gridVisibleColumnDefinitionsSelector, gridVisibleColumnFieldsSelector, gridPinnedColumnsSelector, gridVisiblePinnedColumnDefinitionsSelector, gridColumnPositionsSelector, gridFilterableColumnDefinitionsSelector, gridFilterableColumnLookupSelector, gridHasColSpanSelector } from "./gridColumnsSelector.js";
2
2
  export * from "./gridColumnsInterfaces.js";
@@ -82,7 +82,8 @@ export function useGridColumns(apiRef, props) {
82
82
  apiRef,
83
83
  columnsToUpsert: columns,
84
84
  initialState: undefined,
85
- keepOnlyColumnsToUpsert: false
85
+ keepOnlyColumnsToUpsert: false,
86
+ updateInitialVisibilityModel: true
86
87
  });
87
88
  setGridColumnsState(columnsState);
88
89
  }, [apiRef, setGridColumnsState]);
@@ -288,7 +289,8 @@ export function useGridColumns(apiRef, props) {
288
289
  initialState: undefined,
289
290
  // If the user provides a model, we don't want to set it in the state here because it has it's dedicated `useEffect` which calls `setColumnVisibilityModel`
290
291
  columnsToUpsert: props.columns,
291
- keepOnlyColumnsToUpsert: true
292
+ keepOnlyColumnsToUpsert: true,
293
+ updateInitialVisibilityModel: true
292
294
  });
293
295
  previousColumnsProp.current = props.columns;
294
296
  setGridColumnsState(columnsState);
@@ -0,0 +1,31 @@
1
+ import type { GridGetRowsParams, GridUpdateRowParams } from '../../../models/gridDataSource';
2
+ export declare class GridGetRowsError<T extends GridGetRowsParams = GridGetRowsParams> extends Error {
3
+ /**
4
+ * The parameters used in the failed request
5
+ */
6
+ readonly params: T;
7
+ /**
8
+ * The original error that caused this error
9
+ */
10
+ readonly cause?: Error;
11
+ constructor(options: {
12
+ message: string;
13
+ params: T;
14
+ cause?: Error;
15
+ });
16
+ }
17
+ export declare class GridUpdateRowError extends Error {
18
+ /**
19
+ * The parameters used in the failed request
20
+ */
21
+ readonly params: GridUpdateRowParams;
22
+ /**
23
+ * The original error that caused this error
24
+ */
25
+ readonly cause?: Error;
26
+ constructor(options: {
27
+ message: string;
28
+ params: GridUpdateRowParams;
29
+ cause?: Error;
30
+ });
31
+ }
@@ -0,0 +1,32 @@
1
+ export class GridGetRowsError extends Error {
2
+ constructor(options) {
3
+ super(options.message);
4
+ /**
5
+ * The parameters used in the failed request
6
+ */
7
+ this.params = void 0;
8
+ /**
9
+ * The original error that caused this error
10
+ */
11
+ this.cause = void 0;
12
+ this.name = 'GridGetRowsError';
13
+ this.params = options.params;
14
+ this.cause = options.cause;
15
+ }
16
+ }
17
+ export class GridUpdateRowError extends Error {
18
+ constructor(options) {
19
+ super(options.message);
20
+ /**
21
+ * The parameters used in the failed request
22
+ */
23
+ this.params = void 0;
24
+ /**
25
+ * The original error that caused this error
26
+ */
27
+ this.cause = void 0;
28
+ this.name = 'GridUpdateRowError';
29
+ this.params = options.params;
30
+ this.cause = options.cause;
31
+ }
32
+ }
@@ -0,0 +1,2 @@
1
+ export { GridDataSourceCacheDefault, type GridDataSourceCacheDefaultConfig } from "./cache.js";
2
+ export { GridGetRowsError, GridUpdateRowError } from "./gridDataSourceError.js";
@@ -0,0 +1,2 @@
1
+ export { GridDataSourceCacheDefault } from "./cache.js";
2
+ export { GridGetRowsError, GridUpdateRowError } from "./gridDataSourceError.js";
@@ -18,5 +18,5 @@ export interface GridDataSourceApi {
18
18
  /**
19
19
  * The data source API.
20
20
  */
21
- unstable_dataSource: GridDataSourceApiBase;
21
+ dataSource: GridDataSourceApiBase;
22
22
  }
@@ -8,7 +8,7 @@ import type { DataGridProcessedProps } from '../../../models/props/DataGridProps
8
8
  import type { GridStrategyProcessor } from '../../core/strategyProcessing';
9
9
  import type { GridEventListener } from '../../../models/events';
10
10
  import type { GridRowId } from '../../../models';
11
- export declare const useGridDataSourceBase: <Api extends GridPrivateApiCommunity>(apiRef: RefObject<Api>, props: Pick<DataGridProcessedProps, "unstable_dataSource" | "unstable_dataSourceCache" | "unstable_onDataSourceError" | "pageSizeOptions" | "signature">, options?: {
11
+ export declare const useGridDataSourceBase: <Api extends GridPrivateApiCommunity>(apiRef: RefObject<Api>, props: Pick<DataGridProcessedProps, "dataSource" | "dataSourceCache" | "onDataSourceError" | "pageSizeOptions" | "signature">, options?: {
12
12
  cacheOptions?: GridDataSourceCacheDefaultConfig;
13
13
  fetchRowChildren?: (parents: GridRowId[]) => void;
14
14
  clearDataSourceState?: () => void;
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import useLazyRef from '@mui/utils/useLazyRef';
4
4
  import { unstable_debounce as debounce } from '@mui/utils';
5
+ import { warnOnce } from '@mui/x-internals/warning';
5
6
  import { GRID_ROOT_GROUP_ID } from "../rows/gridRowsUtils.js";
6
7
  import { runIf } from "../../../utils/utils.js";
7
8
  import { GridStrategyGroup } from "../../core/strategyProcessing/index.js";
@@ -10,6 +11,7 @@ import { gridPaginationModelSelector } from "../pagination/gridPaginationSelecto
10
11
  import { gridGetRowsParamsSelector } from "./gridDataSourceSelector.js";
11
12
  import { CacheChunkManager, DataSourceRowsUpdateStrategy } from "./utils.js";
12
13
  import { GridDataSourceCacheDefault } from "./cache.js";
14
+ import { GridGetRowsError } from "./gridDataSourceError.js";
13
15
  const noopCache = {
14
16
  clear: () => {},
15
17
  get: () => undefined,
@@ -23,20 +25,20 @@ function getCache(cacheProp, options = {}) {
23
25
  }
24
26
  export const useGridDataSourceBase = (apiRef, props, options = {}) => {
25
27
  const setStrategyAvailability = React.useCallback(() => {
26
- apiRef.current.setStrategyAvailability(GridStrategyGroup.DataSource, DataSourceRowsUpdateStrategy.Default, props.unstable_dataSource ? () => true : () => false);
27
- }, [apiRef, props.unstable_dataSource]);
28
+ apiRef.current.setStrategyAvailability(GridStrategyGroup.DataSource, DataSourceRowsUpdateStrategy.Default, props.dataSource ? () => true : () => false);
29
+ }, [apiRef, props.dataSource]);
28
30
  const [defaultRowsUpdateStrategyActive, setDefaultRowsUpdateStrategyActive] = React.useState(false);
29
31
  const paginationModel = useGridSelector(apiRef, gridPaginationModelSelector);
30
32
  const lastRequestId = React.useRef(0);
31
- const onError = props.unstable_onDataSourceError;
33
+ const onDataSourceErrorProp = props.onDataSourceError;
32
34
  const cacheChunkManager = useLazyRef(() => {
33
35
  const sortedPageSizeOptions = props.pageSizeOptions.map(option => typeof option === 'number' ? option : option.value).sort((a, b) => a - b);
34
36
  const cacheChunkSize = Math.min(paginationModel.pageSize, sortedPageSizeOptions[0]);
35
37
  return new CacheChunkManager(cacheChunkSize);
36
38
  }).current;
37
- const [cache, setCache] = React.useState(() => getCache(props.unstable_dataSourceCache, options.cacheOptions));
39
+ const [cache, setCache] = React.useState(() => getCache(props.dataSourceCache, options.cacheOptions));
38
40
  const fetchRows = React.useCallback(async (parentId, params) => {
39
- const getRows = props.unstable_dataSource?.getRows;
41
+ const getRows = props.dataSource?.getRows;
40
42
  if (!getRows) {
41
43
  return;
42
44
  }
@@ -74,20 +76,28 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
74
76
  fetchParams
75
77
  });
76
78
  }
77
- } catch (error) {
79
+ } catch (originalError) {
78
80
  if (lastRequestId.current === requestId) {
79
81
  apiRef.current.applyStrategyProcessor('dataSourceRowsUpdate', {
80
- error: error,
82
+ error: originalError,
81
83
  fetchParams
82
84
  });
83
- onError?.(error, fetchParams);
85
+ if (typeof onDataSourceErrorProp === 'function') {
86
+ onDataSourceErrorProp(new GridGetRowsError({
87
+ message: originalError?.message,
88
+ params: fetchParams,
89
+ cause: originalError
90
+ }));
91
+ } else if (process.env.NODE_ENV !== 'production') {
92
+ warnOnce(['MUI X: A call to `dataSource.getRows()` threw an error which was not handled because `unstable_onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid unstable_onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'], 'error');
93
+ }
84
94
  }
85
95
  } finally {
86
96
  if (defaultRowsUpdateStrategyActive && lastRequestId.current === requestId) {
87
97
  apiRef.current.setLoading(false);
88
98
  }
89
99
  }
90
- }, [cacheChunkManager, cache, apiRef, defaultRowsUpdateStrategyActive, props.unstable_dataSource?.getRows, onError, options, props.signature]);
100
+ }, [cacheChunkManager, cache, apiRef, defaultRowsUpdateStrategyActive, props.dataSource?.getRows, onDataSourceErrorProp, options, props.signature]);
91
101
  const handleStrategyActivityChange = React.useCallback(() => {
92
102
  setDefaultRowsUpdateStrategyActive(apiRef.current.getActiveStrategy(GridStrategyGroup.DataSource) === DataSourceRowsUpdateStrategy.Default);
93
103
  }, [apiRef]);
@@ -109,7 +119,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
109
119
  }, true);
110
120
  }, [apiRef]);
111
121
  const dataSourceApi = {
112
- unstable_dataSource: {
122
+ dataSource: {
113
123
  fetchRows,
114
124
  cache
115
125
  }
@@ -121,18 +131,18 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
121
131
  isFirstRender.current = false;
122
132
  return;
123
133
  }
124
- if (props.unstable_dataSourceCache === undefined) {
134
+ if (props.dataSourceCache === undefined) {
125
135
  return;
126
136
  }
127
- const newCache = getCache(props.unstable_dataSourceCache, options.cacheOptions);
137
+ const newCache = getCache(props.dataSourceCache, options.cacheOptions);
128
138
  setCache(prevCache => prevCache !== newCache ? newCache : prevCache);
129
- }, [props.unstable_dataSourceCache, options.cacheOptions]);
139
+ }, [props.dataSourceCache, options.cacheOptions]);
130
140
  React.useEffect(() => {
131
- if (props.unstable_dataSource) {
132
- apiRef.current.unstable_dataSource.cache.clear();
133
- apiRef.current.unstable_dataSource.fetchRows();
141
+ if (props.dataSource) {
142
+ apiRef.current.dataSource.cache.clear();
143
+ apiRef.current.dataSource.fetchRows();
134
144
  }
135
- }, [apiRef, props.unstable_dataSource]);
145
+ }, [apiRef, props.dataSource]);
136
146
  return {
137
147
  api: {
138
148
  public: dataSourceApi
@@ -1,6 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import { unstable_ownerDocument as ownerDocument, unstable_useEnhancedEffect as useEnhancedEffect, unstable_useEventCallback as useEventCallback } from '@mui/utils';
3
+ import useEventCallback from '@mui/utils/useEventCallback';
4
+ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
5
+ import ownerDocument from '@mui/utils/ownerDocument';
4
6
  import { throttle } from '@mui/x-internals/throttle';
5
7
  import { useGridApiOptionHandler } from "../../utils/useGridApiEventHandler.js";
6
8
  import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
@@ -109,8 +111,7 @@ export function useGridDimensions(apiRef, props) {
109
111
  // All the floating point dimensions should be rounded to .1 decimal places to avoid subpixel rendering issues
110
112
  // https://github.com/mui/mui-x/issues/9550#issuecomment-1619020477
111
113
  // https://github.com/mui/mui-x/issues/15721
112
- const rootElement = apiRef.current.rootElementRef.current;
113
- const scrollbarSize = measureScrollbarSize(rootElement, props.scrollbarSize);
114
+ const scrollbarSize = measureScrollbarSize(apiRef.current.mainElementRef.current, props.scrollbarSize);
114
115
  const rowsMeta = gridRowsMetaSelector(apiRef);
115
116
  const topContainerHeight = headersTotalHeight + rowsMeta.pinnedTopRowsTotalHeight;
116
117
  const bottomContainerHeight = rowsMeta.pinnedBottomRowsTotalHeight;
@@ -269,28 +270,28 @@ function getStaticDimensions(props, apiRef, density, pinnedColumnns) {
269
270
  };
270
271
  }
271
272
  const scrollbarSizeCache = new WeakMap();
272
- function measureScrollbarSize(rootElement, scrollbarSize) {
273
+ function measureScrollbarSize(element, scrollbarSize) {
273
274
  if (scrollbarSize !== undefined) {
274
275
  return scrollbarSize;
275
276
  }
276
- if (rootElement === null) {
277
+ if (element === null) {
277
278
  return 0;
278
279
  }
279
- const cachedSize = scrollbarSizeCache.get(rootElement);
280
+ const cachedSize = scrollbarSizeCache.get(element);
280
281
  if (cachedSize !== undefined) {
281
282
  return cachedSize;
282
283
  }
283
- const doc = ownerDocument(rootElement);
284
+ const doc = ownerDocument(element);
284
285
  const scrollDiv = doc.createElement('div');
285
286
  scrollDiv.style.width = '99px';
286
287
  scrollDiv.style.height = '99px';
287
288
  scrollDiv.style.position = 'absolute';
288
289
  scrollDiv.style.overflow = 'scroll';
289
290
  scrollDiv.className = 'scrollDiv';
290
- rootElement.appendChild(scrollDiv);
291
+ element.appendChild(scrollDiv);
291
292
  const size = scrollDiv.offsetWidth - scrollDiv.clientWidth;
292
- rootElement.removeChild(scrollDiv);
293
- scrollbarSizeCache.set(rootElement, size);
293
+ element.removeChild(scrollDiv);
294
+ scrollbarSizeCache.set(element, size);
294
295
  return size;
295
296
  }
296
297
  function areElementSizesEqual(a, b) {
@@ -4,7 +4,8 @@ import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  const _excluded = ["id", "field"],
5
5
  _excluded2 = ["id", "field"];
6
6
  import * as React from 'react';
7
- import { unstable_useEventCallback as useEventCallback, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
7
+ import useEventCallback from '@mui/utils/useEventCallback';
8
+ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
8
9
  import { warnOnce } from '@mui/x-internals/warning';
9
10
  import { useGridApiEventHandler, useGridApiOptionHandler } from "../../utils/useGridApiEventHandler.js";
10
11
  import { GridEditModes, GridCellModes } from "../../../models/gridEditRowModel.js";
@@ -4,7 +4,8 @@ import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  const _excluded = ["id"],
5
5
  _excluded2 = ["id"];
6
6
  import * as React from 'react';
7
- import { unstable_useEventCallback as useEventCallback, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
7
+ import useEventCallback from '@mui/utils/useEventCallback';
8
+ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
8
9
  import { warnOnce } from '@mui/x-internals/warning';
9
10
  import { useGridApiEventHandler, useGridApiOptionHandler } from "../../utils/useGridApiEventHandler.js";
10
11
  import { GridEditModes, GridRowModes } from "../../../models/gridEditRowModel.js";
@@ -1,6 +1,7 @@
1
1
  import { gridColumnDefinitionsSelector, gridVisibleColumnDefinitionsSelector } from "../columns/index.js";
2
2
  import { gridFilteredSortedRowIdsSelector } from "../filter/index.js";
3
3
  import { gridPinnedRowsSelector, gridRowTreeSelector } from "../rows/gridRowsSelector.js";
4
+ import { gridRowSelectionCountSelector, gridRowSelectionIdsSelector } from "../rowSelection/gridRowSelectionSelector.js";
4
5
  export const getColumnsToExport = ({
5
6
  apiRef,
6
7
  options
@@ -23,14 +24,15 @@ export const defaultGetRowsToExport = ({
23
24
  }) => {
24
25
  const filteredSortedRowIds = gridFilteredSortedRowIdsSelector(apiRef);
25
26
  const rowTree = gridRowTreeSelector(apiRef);
26
- const selectedRows = apiRef.current.getSelectedRows();
27
+ const selectedRowsCount = gridRowSelectionCountSelector(apiRef);
27
28
  const bodyRows = filteredSortedRowIds.filter(id => rowTree[id].type !== 'footer');
28
29
  const pinnedRows = gridPinnedRowsSelector(apiRef);
29
30
  const topPinnedRowsIds = pinnedRows?.top?.map(row => row.id) || [];
30
31
  const bottomPinnedRowsIds = pinnedRows?.bottom?.map(row => row.id) || [];
31
32
  bodyRows.unshift(...topPinnedRowsIds);
32
33
  bodyRows.push(...bottomPinnedRowsIds);
33
- if (selectedRows.size > 0) {
34
+ if (selectedRowsCount > 0) {
35
+ const selectedRows = gridRowSelectionIdsSelector(apiRef);
34
36
  return bodyRows.filter(id => selectedRows.has(id));
35
37
  }
36
38
  return bodyRows;
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import { unstable_ownerDocument as ownerDocument, unstable_useEventCallback as useEventcallback } from '@mui/utils';
3
+ import useEventCallback from '@mui/utils/useEventCallback';
4
+ import ownerDocument from '@mui/utils/ownerDocument';
4
5
  import { gridClasses } from "../../../constants/gridClasses.js";
5
6
  import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
6
7
  import { useGridLogger } from "../../utils/useGridLogger.js";
@@ -346,7 +347,7 @@ export const useGridFocus = (apiRef, props) => {
346
347
  }));
347
348
  }
348
349
  }, [apiRef, props.pagination, props.paginationMode]);
349
- const handlePaginationModelChange = useEventcallback(() => {
350
+ const handlePaginationModelChange = useEventCallback(() => {
350
351
  const currentFocusedCell = gridFocusCellSelector(apiRef);
351
352
  if (!currentFocusedCell) {
352
353
  return;
@@ -16,4 +16,4 @@ export * from "./dimensions/index.js";
16
16
  export * from "./statePersistence/index.js";
17
17
  export * from "./headerFiltering/index.js";
18
18
  export * from "./virtualization/index.js";
19
- export { GridDataSourceCacheDefault, type GridDataSourceCacheDefaultConfig } from "./dataSource/cache.js";
19
+ export * from "./dataSource/index.js";
@@ -17,4 +17,4 @@ export * from "./dimensions/index.js";
17
17
  export * from "./statePersistence/index.js";
18
18
  export * from "./headerFiltering/index.js";
19
19
  export * from "./virtualization/index.js";
20
- export { GridDataSourceCacheDefault } from "./dataSource/cache.js";
20
+ export * from "./dataSource/index.js";
@@ -1,6 +1,6 @@
1
1
  import { GridStateCommunity } from "../../../models/gridStateCommunity.js";
2
2
  import { GridRowId } from "../../../models/gridRows.js";
3
3
  export declare const gridRowSelectionStateSelector: import("../../..").OutputSelector<GridStateCommunity, unknown, import("../../..").GridRowSelectionModel>;
4
- export declare const selectedGridRowsCountSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridRowSelectionModel, number>;
5
- export declare const selectedGridRowsSelector: import("../../..").OutputSelector<GridStateCommunity, import("..").GridRowIdToModelLookup<import("../../..").GridValidRowModel>, Map<GridRowId, import("../../..").GridValidRowModel>>;
6
- export declare const selectedIdsLookupSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridRowSelectionModel, Record<GridRowId, GridRowId>>;
4
+ export declare const gridRowSelectionManagerSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridRowSelectionModel, import("../../../models/gridRowSelectionManager").RowSelectionManager>;
5
+ export declare const gridRowSelectionCountSelector: import("../../..").OutputSelector<GridStateCommunity, number, number>;
6
+ export declare const gridRowSelectionIdsSelector: import("../../..").OutputSelector<GridStateCommunity, GridRowId[], Map<GridRowId, import("../../..").GridValidRowModel>>;
@@ -1,9 +1,29 @@
1
1
  import { createSelector, createRootSelector, createSelectorMemoized } from "../../../utils/createSelector.js";
2
- import { gridRowsLookupSelector } from "../rows/gridRowsSelector.js";
2
+ import { gridDataRowIdsSelector, gridRowsLookupSelector } from "../rows/gridRowsSelector.js";
3
+ import { gridFilteredRowCountSelector } from "../filter/gridFilterSelector.js";
4
+ import { createRowSelectionManager } from "../../../models/gridRowSelectionManager.js";
3
5
  export const gridRowSelectionStateSelector = createRootSelector(state => state.rowSelection);
4
- export const selectedGridRowsCountSelector = createSelector(gridRowSelectionStateSelector, selection => selection.length);
5
- export const selectedGridRowsSelector = createSelectorMemoized(gridRowSelectionStateSelector, gridRowsLookupSelector, (selectedRows, rowsLookup) => new Map(selectedRows.map(id => [id, rowsLookup[id]])));
6
- export const selectedIdsLookupSelector = createSelectorMemoized(gridRowSelectionStateSelector, selection => selection.reduce((lookup, rowId) => {
7
- lookup[rowId] = rowId;
8
- return lookup;
9
- }, {}));
6
+ export const gridRowSelectionManagerSelector = createSelectorMemoized(gridRowSelectionStateSelector, createRowSelectionManager);
7
+ export const gridRowSelectionCountSelector = createSelector(gridRowSelectionStateSelector, gridFilteredRowCountSelector, (selection, filteredRowCount) => {
8
+ if (selection.type === 'include') {
9
+ return selection.ids.size;
10
+ }
11
+ // In exclude selection, all rows are selectable.
12
+ return filteredRowCount - selection.ids.size;
13
+ });
14
+ export const gridRowSelectionIdsSelector = createSelectorMemoized(gridRowSelectionStateSelector, gridRowsLookupSelector, gridDataRowIdsSelector, (selectionModel, rowsLookup, rowIds) => {
15
+ const map = new Map();
16
+ if (selectionModel.type === 'include') {
17
+ for (const id of selectionModel.ids) {
18
+ map.set(id, rowsLookup[id]);
19
+ }
20
+ } else {
21
+ for (let i = 0; i < rowIds.length; i += 1) {
22
+ const id = rowIds[i];
23
+ if (!selectionModel.ids.has(id)) {
24
+ map.set(id, rowsLookup[id]);
25
+ }
26
+ }
27
+ }
28
+ return map;
29
+ });