@mui/x-data-grid-pro 8.0.0-beta.3 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/CHANGELOG.md +388 -96
  2. package/DataGridPro/DataGridPro.js +8 -7
  3. package/DataGridPro/useDataGridProComponent.d.ts +2 -2
  4. package/DataGridPro/useDataGridProComponent.js +2 -3
  5. package/components/GridDetailPanel.js +1 -2
  6. package/components/headerFiltering/GridHeaderFilterMenu.js +2 -2
  7. package/esm/DataGridPro/DataGridPro.js +9 -8
  8. package/esm/DataGridPro/useDataGridProComponent.d.ts +2 -2
  9. package/esm/DataGridPro/useDataGridProComponent.js +2 -3
  10. package/esm/components/GridDetailPanel.js +1 -2
  11. package/esm/components/headerFiltering/GridHeaderFilterMenu.js +2 -2
  12. package/esm/hooks/features/dataSource/useGridDataSourceBasePro.d.ts +3 -6
  13. package/esm/hooks/features/dataSource/useGridDataSourceBasePro.js +36 -8
  14. package/esm/hooks/features/dataSource/utils.d.ts +3 -2
  15. package/esm/hooks/features/dataSource/utils.js +13 -1
  16. package/esm/hooks/features/detailPanel/useGridDetailPanel.js +4 -3
  17. package/esm/hooks/features/lazyLoader/useGridLazyLoader.d.ts +1 -1
  18. package/esm/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.d.ts +1 -1
  19. package/esm/hooks/features/rowPinning/useGridRowPinning.d.ts +1 -1
  20. package/esm/hooks/features/serverSideLazyLoader/useGridDataSourceLazyLoader.js +38 -1
  21. package/esm/index.js +1 -1
  22. package/esm/internals/index.d.ts +1 -0
  23. package/esm/internals/index.js +1 -0
  24. package/esm/material/icons.d.ts +3 -6
  25. package/esm/material/icons.js +1 -1
  26. package/esm/material/index.d.ts +2 -2
  27. package/esm/models/dataGridProProps.d.ts +3 -3
  28. package/esm/models/gridProIconSlotsComponent.d.ts +6 -3
  29. package/esm/package.json +1 -1
  30. package/hooks/features/dataSource/useGridDataSourceBasePro.d.ts +3 -6
  31. package/hooks/features/dataSource/useGridDataSourceBasePro.js +34 -6
  32. package/hooks/features/dataSource/utils.d.ts +3 -2
  33. package/hooks/features/dataSource/utils.js +15 -2
  34. package/hooks/features/detailPanel/useGridDetailPanel.js +4 -3
  35. package/hooks/features/lazyLoader/useGridLazyLoader.d.ts +1 -1
  36. package/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.d.ts +1 -1
  37. package/hooks/features/rowPinning/useGridRowPinning.d.ts +1 -1
  38. package/hooks/features/serverSideLazyLoader/useGridDataSourceLazyLoader.js +37 -0
  39. package/index.js +1 -1
  40. package/internals/index.d.ts +1 -0
  41. package/internals/index.js +15 -7
  42. package/material/icons.d.ts +3 -6
  43. package/material/icons.js +3 -3
  44. package/material/index.d.ts +2 -2
  45. package/models/dataGridProProps.d.ts +3 -3
  46. package/models/gridProIconSlotsComponent.d.ts +6 -3
  47. package/package.json +8 -14
  48. package/esm/utils/releaseInfo.d.ts +0 -1
  49. package/esm/utils/releaseInfo.js +0 -13
  50. package/modern/DataGridPro/DataGrid.d.ts +0 -8
  51. package/modern/DataGridPro/DataGrid.js +0 -19
  52. package/modern/DataGridPro/DataGridPro.d.ts +0 -16
  53. package/modern/DataGridPro/DataGridPro.js +0 -1020
  54. package/modern/DataGridPro/index.d.ts +0 -3
  55. package/modern/DataGridPro/index.js +0 -3
  56. package/modern/DataGridPro/useDataGridProComponent.d.ts +0 -4
  57. package/modern/DataGridPro/useDataGridProComponent.js +0 -105
  58. package/modern/DataGridPro/useDataGridProProps.d.ts +0 -7
  59. package/modern/DataGridPro/useDataGridProProps.js +0 -54
  60. package/modern/components/GridColumnHeaders.d.ts +0 -5
  61. package/modern/components/GridColumnHeaders.js +0 -92
  62. package/modern/components/GridColumnMenuPinningItem.d.ts +0 -7
  63. package/modern/components/GridColumnMenuPinningItem.js +0 -77
  64. package/modern/components/GridDataSourceTreeDataGroupingCell.d.ts +0 -12
  65. package/modern/components/GridDataSourceTreeDataGroupingCell.js +0 -107
  66. package/modern/components/GridDetailPanel.d.ts +0 -14
  67. package/modern/components/GridDetailPanel.js +0 -53
  68. package/modern/components/GridDetailPanelToggleCell.d.ts +0 -7
  69. package/modern/components/GridDetailPanelToggleCell.js +0 -121
  70. package/modern/components/GridDetailPanels.d.ts +0 -3
  71. package/modern/components/GridDetailPanels.js +0 -67
  72. package/modern/components/GridPinnedRows.d.ts +0 -6
  73. package/modern/components/GridPinnedRows.js +0 -40
  74. package/modern/components/GridProColumnMenu.d.ts +0 -24
  75. package/modern/components/GridProColumnMenu.js +0 -21
  76. package/modern/components/GridRowReorderCell.d.ts +0 -8
  77. package/modern/components/GridRowReorderCell.js +0 -140
  78. package/modern/components/GridTreeDataGroupingCell.d.ts +0 -15
  79. package/modern/components/GridTreeDataGroupingCell.js +0 -133
  80. package/modern/components/headerFiltering/GridHeaderFilterCell.d.ts +0 -26
  81. package/modern/components/headerFiltering/GridHeaderFilterCell.js +0 -362
  82. package/modern/components/headerFiltering/GridHeaderFilterClearButton.d.ts +0 -6
  83. package/modern/components/headerFiltering/GridHeaderFilterClearButton.js +0 -17
  84. package/modern/components/headerFiltering/GridHeaderFilterMenu.d.ts +0 -30
  85. package/modern/components/headerFiltering/GridHeaderFilterMenu.js +0 -137
  86. package/modern/components/headerFiltering/GridHeaderFilterMenuContainer.d.ts +0 -17
  87. package/modern/components/headerFiltering/GridHeaderFilterMenuContainer.js +0 -138
  88. package/modern/components/headerFiltering/index.d.ts +0 -3
  89. package/modern/components/headerFiltering/index.js +0 -3
  90. package/modern/components/index.d.ts +0 -6
  91. package/modern/components/index.js +0 -7
  92. package/modern/components/reexports.d.ts +0 -1
  93. package/modern/components/reexports.js +0 -1
  94. package/modern/constants/dataGridProDefaultSlotsComponents.d.ts +0 -2
  95. package/modern/constants/dataGridProDefaultSlotsComponents.js +0 -17
  96. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +0 -12
  97. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +0 -143
  98. package/modern/hooks/features/columnPinning/gridColumnPinningInterface.d.ts +0 -40
  99. package/modern/hooks/features/columnPinning/gridColumnPinningInterface.js +0 -1
  100. package/modern/hooks/features/columnPinning/index.d.ts +0 -1
  101. package/modern/hooks/features/columnPinning/index.js +0 -1
  102. package/modern/hooks/features/columnPinning/useGridColumnPinning.d.ts +0 -6
  103. package/modern/hooks/features/columnPinning/useGridColumnPinning.js +0 -228
  104. package/modern/hooks/features/columnPinning/useGridColumnPinningPreProcessors.d.ts +0 -4
  105. package/modern/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +0 -105
  106. package/modern/hooks/features/columnReorder/columnReorderInterfaces.d.ts +0 -6
  107. package/modern/hooks/features/columnReorder/columnReorderInterfaces.js +0 -1
  108. package/modern/hooks/features/columnReorder/columnReorderSelector.d.ts +0 -3
  109. package/modern/hooks/features/columnReorder/columnReorderSelector.js +0 -3
  110. package/modern/hooks/features/columnReorder/index.d.ts +0 -2
  111. package/modern/hooks/features/columnReorder/index.js +0 -2
  112. package/modern/hooks/features/columnReorder/useGridColumnReorder.d.ts +0 -9
  113. package/modern/hooks/features/columnReorder/useGridColumnReorder.js +0 -242
  114. package/modern/hooks/features/dataSource/gridDataSourceSelector.d.ts +0 -7
  115. package/modern/hooks/features/dataSource/gridDataSourceSelector.js +0 -6
  116. package/modern/hooks/features/dataSource/models.d.ts +0 -75
  117. package/modern/hooks/features/dataSource/models.js +0 -1
  118. package/modern/hooks/features/dataSource/useGridDataSourceBasePro.d.ts +0 -33
  119. package/modern/hooks/features/dataSource/useGridDataSourceBasePro.js +0 -179
  120. package/modern/hooks/features/dataSource/useGridDataSourcePro.d.ts +0 -6
  121. package/modern/hooks/features/dataSource/useGridDataSourcePro.js +0 -35
  122. package/modern/hooks/features/dataSource/utils.d.ts +0 -29
  123. package/modern/hooks/features/dataSource/utils.js +0 -82
  124. package/modern/hooks/features/detailPanel/gridDetailPanelInterface.d.ts +0 -41
  125. package/modern/hooks/features/detailPanel/gridDetailPanelInterface.js +0 -1
  126. package/modern/hooks/features/detailPanel/gridDetailPanelSelector.d.ts +0 -14
  127. package/modern/hooks/features/detailPanel/gridDetailPanelSelector.js +0 -5
  128. package/modern/hooks/features/detailPanel/gridDetailPanelToggleColDef.d.ts +0 -4
  129. package/modern/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +0 -34
  130. package/modern/hooks/features/detailPanel/index.d.ts +0 -3
  131. package/modern/hooks/features/detailPanel/index.js +0 -3
  132. package/modern/hooks/features/detailPanel/useGridDetailPanel.d.ts +0 -6
  133. package/modern/hooks/features/detailPanel/useGridDetailPanel.js +0 -191
  134. package/modern/hooks/features/detailPanel/useGridDetailPanelPreProcessors.d.ts +0 -4
  135. package/modern/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +0 -43
  136. package/modern/hooks/features/index.d.ts +0 -7
  137. package/modern/hooks/features/index.js +0 -8
  138. package/modern/hooks/features/infiniteLoader/useGridInfiniteLoader.d.ts +0 -9
  139. package/modern/hooks/features/infiniteLoader/useGridInfiniteLoader.js +0 -104
  140. package/modern/hooks/features/lazyLoader/useGridLazyLoader.d.ts +0 -10
  141. package/modern/hooks/features/lazyLoader/useGridLazyLoader.js +0 -90
  142. package/modern/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.d.ts +0 -5
  143. package/modern/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.js +0 -34
  144. package/modern/hooks/features/lazyLoader/utils.d.ts +0 -18
  145. package/modern/hooks/features/lazyLoader/utils.js +0 -34
  146. package/modern/hooks/features/rowPinning/gridRowPinningInterface.d.ts +0 -17
  147. package/modern/hooks/features/rowPinning/gridRowPinningInterface.js +0 -1
  148. package/modern/hooks/features/rowPinning/gridRowPinningSelector.d.ts +0 -1
  149. package/modern/hooks/features/rowPinning/gridRowPinningSelector.js +0 -1
  150. package/modern/hooks/features/rowPinning/index.d.ts +0 -1
  151. package/modern/hooks/features/rowPinning/index.js +0 -1
  152. package/modern/hooks/features/rowPinning/useGridRowPinning.d.ts +0 -6
  153. package/modern/hooks/features/rowPinning/useGridRowPinning.js +0 -52
  154. package/modern/hooks/features/rowPinning/useGridRowPinningPreProcessors.d.ts +0 -38
  155. package/modern/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +0 -119
  156. package/modern/hooks/features/rowReorder/gridRowReorderColDef.d.ts +0 -2
  157. package/modern/hooks/features/rowReorder/gridRowReorderColDef.js +0 -20
  158. package/modern/hooks/features/rowReorder/index.d.ts +0 -1
  159. package/modern/hooks/features/rowReorder/index.js +0 -1
  160. package/modern/hooks/features/rowReorder/useGridRowReorder.d.ts +0 -8
  161. package/modern/hooks/features/rowReorder/useGridRowReorder.js +0 -141
  162. package/modern/hooks/features/rowReorder/useGridRowReorderPreProcessors.d.ts +0 -4
  163. package/modern/hooks/features/rowReorder/useGridRowReorderPreProcessors.js +0 -46
  164. package/modern/hooks/features/rows/index.d.ts +0 -1
  165. package/modern/hooks/features/rows/index.js +0 -1
  166. package/modern/hooks/features/rows/useGridRowAriaAttributes.d.ts +0 -3
  167. package/modern/hooks/features/rows/useGridRowAriaAttributes.js +0 -37
  168. package/modern/hooks/features/serverSideLazyLoader/useGridDataSourceLazyLoader.d.ts +0 -10
  169. package/modern/hooks/features/serverSideLazyLoader/useGridDataSourceLazyLoader.js +0 -325
  170. package/modern/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.d.ts +0 -4
  171. package/modern/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.js +0 -148
  172. package/modern/hooks/features/serverSideTreeData/utils.d.ts +0 -7
  173. package/modern/hooks/features/serverSideTreeData/utils.js +0 -18
  174. package/modern/hooks/features/treeData/gridTreeDataGroupColDef.d.ts +0 -8
  175. package/modern/hooks/features/treeData/gridTreeDataGroupColDef.js +0 -27
  176. package/modern/hooks/features/treeData/gridTreeDataUtils.d.ts +0 -22
  177. package/modern/hooks/features/treeData/gridTreeDataUtils.js +0 -95
  178. package/modern/hooks/features/treeData/index.d.ts +0 -1
  179. package/modern/hooks/features/treeData/index.js +0 -1
  180. package/modern/hooks/features/treeData/useGridTreeData.d.ts +0 -4
  181. package/modern/hooks/features/treeData/useGridTreeData.js +0 -22
  182. package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.d.ts +0 -4
  183. package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +0 -148
  184. package/modern/hooks/index.d.ts +0 -1
  185. package/modern/hooks/index.js +0 -1
  186. package/modern/hooks/utils/useGridApiContext.d.ts +0 -4
  187. package/modern/hooks/utils/useGridApiContext.js +0 -2
  188. package/modern/hooks/utils/useGridApiRef.d.ts +0 -4
  189. package/modern/hooks/utils/useGridApiRef.js +0 -2
  190. package/modern/hooks/utils/useGridAriaAttributes.d.ts +0 -2
  191. package/modern/hooks/utils/useGridAriaAttributes.js +0 -11
  192. package/modern/hooks/utils/useGridPrivateApiContext.d.ts +0 -2
  193. package/modern/hooks/utils/useGridPrivateApiContext.js +0 -2
  194. package/modern/hooks/utils/useGridRootProps.d.ts +0 -2
  195. package/modern/hooks/utils/useGridRootProps.js +0 -2
  196. package/modern/index.d.ts +0 -22
  197. package/modern/index.js +0 -25
  198. package/modern/internals/index.d.ts +0 -33
  199. package/modern/internals/index.js +0 -38
  200. package/modern/internals/propValidation.d.ts +0 -3
  201. package/modern/internals/propValidation.js +0 -2
  202. package/modern/locales.d.ts +0 -1
  203. package/modern/locales.js +0 -1
  204. package/modern/material/icons.d.ts +0 -6
  205. package/modern/material/icons.js +0 -17
  206. package/modern/material/index.d.ts +0 -5
  207. package/modern/material/index.js +0 -8
  208. package/modern/models/dataGridProProps.d.ts +0 -222
  209. package/modern/models/dataGridProProps.js +0 -1
  210. package/modern/models/gridApiPro.d.ts +0 -11
  211. package/modern/models/gridApiPro.js +0 -1
  212. package/modern/models/gridFetchRowsParams.d.ts +0 -22
  213. package/modern/models/gridFetchRowsParams.js +0 -1
  214. package/modern/models/gridGroupingColDefOverride.d.ts +0 -30
  215. package/modern/models/gridGroupingColDefOverride.js +0 -1
  216. package/modern/models/gridProIconSlotsComponent.d.ts +0 -13
  217. package/modern/models/gridProIconSlotsComponent.js +0 -1
  218. package/modern/models/gridProSlotProps.d.ts +0 -8
  219. package/modern/models/gridProSlotProps.js +0 -1
  220. package/modern/models/gridProSlotsComponent.d.ts +0 -18
  221. package/modern/models/gridProSlotsComponent.js +0 -1
  222. package/modern/models/gridRowOrderChangeParams.d.ts +0 -18
  223. package/modern/models/gridRowOrderChangeParams.js +0 -1
  224. package/modern/models/gridRowScrollEndParams.d.ts +0 -18
  225. package/modern/models/gridRowScrollEndParams.js +0 -1
  226. package/modern/models/gridStatePro.d.ts +0 -19
  227. package/modern/models/gridStatePro.js +0 -1
  228. package/modern/models/index.d.ts +0 -7
  229. package/modern/models/index.js +0 -7
  230. package/modern/package.json +0 -1
  231. package/modern/themeAugmentation/index.d.ts +0 -2
  232. package/modern/themeAugmentation/index.js +0 -4
  233. package/modern/themeAugmentation/overrides.d.ts +0 -7
  234. package/modern/themeAugmentation/overrides.js +0 -1
  235. package/modern/themeAugmentation/props.d.ts +0 -15
  236. package/modern/themeAugmentation/props.js +0 -1
  237. package/modern/typeOverloads/index.d.ts +0 -1
  238. package/modern/typeOverloads/index.js +0 -1
  239. package/modern/typeOverloads/modules.d.ts +0 -70
  240. package/modern/typeOverloads/modules.js +0 -1
  241. package/modern/typeOverloads/reexports.d.ts +0 -17
  242. package/modern/typeOverloads/reexports.js +0 -15
  243. package/modern/utils/index.d.ts +0 -1
  244. package/modern/utils/index.js +0 -1
  245. package/modern/utils/releaseInfo.d.ts +0 -1
  246. package/modern/utils/releaseInfo.js +0 -13
  247. package/modern/utils/tree/createRowTree.d.ts +0 -17
  248. package/modern/utils/tree/createRowTree.js +0 -37
  249. package/modern/utils/tree/index.d.ts +0 -1
  250. package/modern/utils/tree/index.js +0 -1
  251. package/modern/utils/tree/insertDataRowInTree.d.ts +0 -69
  252. package/modern/utils/tree/insertDataRowInTree.js +0 -141
  253. package/modern/utils/tree/models.d.ts +0 -14
  254. package/modern/utils/tree/models.js +0 -1
  255. package/modern/utils/tree/removeDataRowFromTree.d.ts +0 -45
  256. package/modern/utils/tree/removeDataRowFromTree.js +0 -94
  257. package/modern/utils/tree/sortRowTree.d.ts +0 -15
  258. package/modern/utils/tree/sortRowTree.js +0 -114
  259. package/modern/utils/tree/updateRowTree.d.ts +0 -20
  260. package/modern/utils/tree/updateRowTree.js +0 -88
  261. package/modern/utils/tree/utils.d.ts +0 -54
  262. package/modern/utils/tree/utils.js +0 -197
  263. package/tsconfig.build.tsbuildinfo +0 -1
  264. package/utils/releaseInfo.d.ts +0 -1
  265. package/utils/releaseInfo.js +0 -20
  266. /package/esm/{locales.d.ts → locales/index.d.ts} +0 -0
  267. /package/esm/{locales.js → locales/index.js} +0 -0
  268. /package/{locales.d.ts → locales/index.d.ts} +0 -0
  269. /package/{locales.js → locales/index.js} +0 -0
@@ -1,105 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import * as React from 'react';
3
- import { useGridRegisterPipeProcessor, gridVisiblePinnedColumnDefinitionsSelector } from '@mui/x-data-grid/internals';
4
- export const useGridColumnPinningPreProcessors = (apiRef, props) => {
5
- const {
6
- disableColumnPinning
7
- } = props;
8
- const prevAllPinnedColumns = React.useRef([]);
9
- const reorderPinnedColumns = React.useCallback(columnsState => {
10
- if (columnsState.orderedFields.length === 0 || disableColumnPinning) {
11
- return columnsState;
12
- }
13
-
14
- // HACK: This is a hack needed because the pipe processors aren't pure enough. What
15
- // they should be is `gridState -> gridState` transformers, but they only transform a slice
16
- // of the state, not the full state. So if they need access to other parts of the state (like
17
- // the `state.columns.orderedFields` in this case), they might lag behind because the selectors
18
- // are selecting the old state in `apiRef`, not the state being computed in the current pipe processor.
19
- const savedState = apiRef.current.state;
20
- apiRef.current.state = _extends({}, savedState, {
21
- columns: columnsState
22
- });
23
- const visibleColumns = gridVisiblePinnedColumnDefinitionsSelector(apiRef);
24
- apiRef.current.state = savedState;
25
- // HACK: Ends here //
26
-
27
- const leftPinnedColumns = visibleColumns.left.map(c => c.field);
28
- const rightPinnedColumns = visibleColumns.right.map(c => c.field);
29
- let newOrderedFields;
30
- const allPinnedColumns = [...leftPinnedColumns, ...rightPinnedColumns];
31
- const {
32
- orderedFieldsBeforePinningColumns
33
- } = apiRef.current.caches.columnPinning;
34
- if (orderedFieldsBeforePinningColumns) {
35
- newOrderedFields = new Array(columnsState.orderedFields.length).fill(null);
36
- const newOrderedFieldsBeforePinningColumns = [...newOrderedFields];
37
-
38
- // Contains the fields not added to the orderedFields array yet
39
- const remainingFields = [...columnsState.orderedFields];
40
-
41
- // First, we check if the column was unpinned since the last processing.
42
- // If yes and it still exists, we move it back to the same position it was before pinning
43
- prevAllPinnedColumns.current.forEach(field => {
44
- if (!allPinnedColumns.includes(field) && columnsState.lookup[field]) {
45
- // Get the position before pinning
46
- const index = orderedFieldsBeforePinningColumns.indexOf(field);
47
- newOrderedFields[index] = field;
48
- newOrderedFieldsBeforePinningColumns[index] = field;
49
- // This field was already consumed so we prevent from being added again
50
- remainingFields.splice(remainingFields.indexOf(field), 1);
51
- }
52
- });
53
-
54
- // For columns still pinned, we keep stored their original positions
55
- allPinnedColumns.forEach(field => {
56
- let index = orderedFieldsBeforePinningColumns.indexOf(field);
57
- // If index = -1, the pinned field didn't exist in the last processing, it's possibly being added now
58
- // If index >= newOrderedFieldsBeforePinningColumns.length, then one or more columns were removed
59
- // In both cases, use the position from the columns array
60
- // TODO: detect removed columns and decrease the positions after it
61
- if (index === -1 || index >= newOrderedFieldsBeforePinningColumns.length) {
62
- index = columnsState.orderedFields.indexOf(field);
63
- }
64
-
65
- // The fallback above may make the column to be inserted in a position already occupied
66
- // In this case, put it in any empty slot available
67
- if (newOrderedFieldsBeforePinningColumns[index] !== null) {
68
- index = 0;
69
- while (newOrderedFieldsBeforePinningColumns[index] !== null) {
70
- index += 1;
71
- }
72
- }
73
- newOrderedFields[index] = field;
74
- newOrderedFieldsBeforePinningColumns[index] = field;
75
- // This field was already consumed so we prevent from being added again
76
- remainingFields.splice(remainingFields.indexOf(field), 1);
77
- });
78
-
79
- // The fields remaining are those that're neither pinnned nor were unpinned
80
- // For these, we spread them across both arrays making sure to not override existing values
81
- let i = 0;
82
- remainingFields.forEach(field => {
83
- while (newOrderedFieldsBeforePinningColumns[i] !== null) {
84
- i += 1;
85
- }
86
- newOrderedFieldsBeforePinningColumns[i] = field;
87
- newOrderedFields[i] = field;
88
- });
89
- apiRef.current.caches.columnPinning.orderedFieldsBeforePinningColumns = newOrderedFieldsBeforePinningColumns;
90
- } else {
91
- newOrderedFields = [...columnsState.orderedFields];
92
- apiRef.current.caches.columnPinning.orderedFieldsBeforePinningColumns = [...columnsState.orderedFields];
93
- }
94
- prevAllPinnedColumns.current = allPinnedColumns;
95
- const centerColumns = newOrderedFields.filter(field => {
96
- return !leftPinnedColumns.includes(field) && !rightPinnedColumns.includes(field);
97
- });
98
- return _extends({}, columnsState, {
99
- orderedFields: [...leftPinnedColumns, ...centerColumns, ...rightPinnedColumns]
100
- });
101
- }, [apiRef, disableColumnPinning]);
102
- useGridRegisterPipeProcessor(apiRef, 'hydrateColumns', reorderPinnedColumns);
103
- const isColumnPinned = React.useCallback((initialValue, field) => apiRef.current.isColumnPinned(field), [apiRef]);
104
- useGridRegisterPipeProcessor(apiRef, 'isColumnPinned', isColumnPinned);
105
- };
@@ -1,6 +0,0 @@
1
- export interface GridColumnReorderState {
2
- dragCol: string;
3
- }
4
- export interface GridCanBeReorderedPreProcessingContext {
5
- targetIndex: number;
6
- }
@@ -1,3 +0,0 @@
1
- import { GridStatePro } from "../../../models/gridStatePro.js";
2
- export declare const gridColumnReorderSelector: import("@mui/x-data-grid").OutputSelector<GridStatePro, unknown, import("./columnReorderInterfaces").GridColumnReorderState>;
3
- export declare const gridColumnReorderDragColSelector: import("@mui/x-data-grid").OutputSelector<GridStatePro, import("./columnReorderInterfaces").GridColumnReorderState, string>;
@@ -1,3 +0,0 @@
1
- import { createSelector, createRootSelector } from '@mui/x-data-grid/internals';
2
- export const gridColumnReorderSelector = createRootSelector(state => state.columnReorder);
3
- export const gridColumnReorderDragColSelector = createSelector(gridColumnReorderSelector, columnReorder => columnReorder.dragCol);
@@ -1,2 +0,0 @@
1
- export * from "./columnReorderSelector.js";
2
- export type { GridColumnReorderState } from './columnReorderInterfaces';
@@ -1,2 +0,0 @@
1
- export * from "./columnReorderSelector.js";
2
- export {};
@@ -1,9 +0,0 @@
1
- import { RefObject } from '@mui/x-internals/types';
2
- import { GridStateInitializer } from '@mui/x-data-grid/internals';
3
- import { GridPrivateApiPro } from "../../../models/gridApiPro.js";
4
- import { DataGridProProcessedProps } from "../../../models/dataGridProProps.js";
5
- export declare const columnReorderStateInitializer: GridStateInitializer;
6
- /**
7
- * @requires useGridColumns (method)
8
- */
9
- export declare const useGridColumnReorder: (apiRef: RefObject<GridPrivateApiPro>, props: Pick<DataGridProProcessedProps, "disableColumnReorder" | "keepColumnPositionIfDraggedOutside" | "classes" | "onColumnOrderChange">) => void;
@@ -1,242 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import * as React from 'react';
3
- import composeClasses from '@mui/utils/composeClasses';
4
- import { useRtl } from '@mui/system/RtlProvider';
5
- import { useGridEvent, getDataGridUtilityClass, useGridLogger, useGridEventPriority } from '@mui/x-data-grid';
6
- import { gridColumnReorderDragColSelector } from "./columnReorderSelector.js";
7
- const CURSOR_MOVE_DIRECTION_LEFT = 'left';
8
- const CURSOR_MOVE_DIRECTION_RIGHT = 'right';
9
- const getCursorMoveDirectionX = (currentCoordinates, nextCoordinates) => {
10
- return currentCoordinates.x <= nextCoordinates.x ? CURSOR_MOVE_DIRECTION_RIGHT : CURSOR_MOVE_DIRECTION_LEFT;
11
- };
12
- const hasCursorPositionChanged = (currentCoordinates, nextCoordinates) => currentCoordinates.x !== nextCoordinates.x || currentCoordinates.y !== nextCoordinates.y;
13
- const useUtilityClasses = ownerState => {
14
- const {
15
- classes
16
- } = ownerState;
17
- const slots = {
18
- columnHeaderDragging: ['columnHeader--dragging']
19
- };
20
- return composeClasses(slots, getDataGridUtilityClass, classes);
21
- };
22
- export const columnReorderStateInitializer = state => _extends({}, state, {
23
- columnReorder: {
24
- dragCol: ''
25
- }
26
- });
27
-
28
- /**
29
- * @requires useGridColumns (method)
30
- */
31
- export const useGridColumnReorder = (apiRef, props) => {
32
- const logger = useGridLogger(apiRef, 'useGridColumnReorder');
33
- const dragColNode = React.useRef(null);
34
- const cursorPosition = React.useRef({
35
- x: 0,
36
- y: 0
37
- });
38
- const originColumnIndex = React.useRef(null);
39
- const forbiddenIndexes = React.useRef({});
40
- const removeDnDStylesTimeout = React.useRef(undefined);
41
- const ownerState = {
42
- classes: props.classes
43
- };
44
- const classes = useUtilityClasses(ownerState);
45
- const isRtl = useRtl();
46
- React.useEffect(() => {
47
- return () => {
48
- clearTimeout(removeDnDStylesTimeout.current);
49
- };
50
- }, []);
51
- const handleDragStart = React.useCallback((params, event) => {
52
- if (props.disableColumnReorder || params.colDef.disableReorder) {
53
- return;
54
- }
55
- logger.debug(`Start dragging col ${params.field}`);
56
- // Prevent drag events propagation.
57
- // For more information check here https://github.com/mui/mui-x/issues/2680.
58
- event.stopPropagation();
59
- dragColNode.current = event.currentTarget;
60
- dragColNode.current.classList.add(classes.columnHeaderDragging);
61
- if (event.dataTransfer) {
62
- event.dataTransfer.effectAllowed = 'move';
63
- }
64
- apiRef.current.setState(state => _extends({}, state, {
65
- columnReorder: _extends({}, state.columnReorder, {
66
- dragCol: params.field
67
- })
68
- }));
69
- removeDnDStylesTimeout.current = setTimeout(() => {
70
- dragColNode.current.classList.remove(classes.columnHeaderDragging);
71
- });
72
- originColumnIndex.current = apiRef.current.getColumnIndex(params.field, false);
73
- const draggingColumnGroupPath = apiRef.current.getColumnGroupPath(params.field);
74
- const columnIndex = originColumnIndex.current;
75
- const allColumns = apiRef.current.getAllColumns();
76
- const groupsLookup = apiRef.current.getAllGroupDetails();
77
- const getGroupPathFromColumnIndex = colIndex => {
78
- const field = allColumns[colIndex].field;
79
- return apiRef.current.getColumnGroupPath(field);
80
- };
81
-
82
- // The limitingGroupId is the id of the group from which the dragged column should not escape
83
- let limitingGroupId = null;
84
- draggingColumnGroupPath.forEach(groupId => {
85
- if (!groupsLookup[groupId]?.freeReordering) {
86
- // Only consider group that are made of more than one column
87
- if (columnIndex > 0 && getGroupPathFromColumnIndex(columnIndex - 1).includes(groupId)) {
88
- limitingGroupId = groupId;
89
- } else if (columnIndex + 1 < allColumns.length && getGroupPathFromColumnIndex(columnIndex + 1).includes(groupId)) {
90
- limitingGroupId = groupId;
91
- }
92
- }
93
- });
94
- forbiddenIndexes.current = {};
95
- for (let indexToForbid = 0; indexToForbid < allColumns.length; indexToForbid += 1) {
96
- const leftIndex = indexToForbid <= columnIndex ? indexToForbid - 1 : indexToForbid;
97
- const rightIndex = indexToForbid < columnIndex ? indexToForbid : indexToForbid + 1;
98
- if (limitingGroupId !== null) {
99
- // verify this indexToForbid will be linked to the limiting group. Otherwise forbid it
100
- let allowIndex = false;
101
- if (leftIndex >= 0 && getGroupPathFromColumnIndex(leftIndex).includes(limitingGroupId)) {
102
- allowIndex = true;
103
- } else if (rightIndex < allColumns.length && getGroupPathFromColumnIndex(rightIndex).includes(limitingGroupId)) {
104
- allowIndex = true;
105
- }
106
- if (!allowIndex) {
107
- forbiddenIndexes.current[indexToForbid] = true;
108
- }
109
- }
110
-
111
- // Verify we are not splitting another group
112
- if (leftIndex >= 0 && rightIndex < allColumns.length) {
113
- getGroupPathFromColumnIndex(rightIndex).forEach(groupId => {
114
- if (getGroupPathFromColumnIndex(leftIndex).includes(groupId)) {
115
- if (!draggingColumnGroupPath.includes(groupId)) {
116
- // moving here split the group groupId in two distincts chunks
117
- if (!groupsLookup[groupId]?.freeReordering) {
118
- forbiddenIndexes.current[indexToForbid] = true;
119
- }
120
- }
121
- }
122
- });
123
- }
124
- }
125
- }, [props.disableColumnReorder, classes.columnHeaderDragging, logger, apiRef]);
126
- const handleDragEnter = React.useCallback((params, event) => {
127
- event.preventDefault();
128
- // Prevent drag events propagation.
129
- // For more information check here https://github.com/mui/mui-x/issues/2680.
130
- event.stopPropagation();
131
- }, []);
132
- const handleDragOver = React.useCallback((params, event) => {
133
- const dragColField = gridColumnReorderDragColSelector(apiRef);
134
- if (!dragColField) {
135
- return;
136
- }
137
- logger.debug(`Dragging over col ${params.field}`);
138
- event.preventDefault();
139
- // Prevent drag events propagation.
140
- // For more information check here https://github.com/mui/mui-x/issues/2680.
141
- event.stopPropagation();
142
- const coordinates = {
143
- x: event.clientX,
144
- y: event.clientY
145
- };
146
- if (params.field !== dragColField && hasCursorPositionChanged(cursorPosition.current, coordinates)) {
147
- const targetColIndex = apiRef.current.getColumnIndex(params.field, false);
148
- const targetColVisibleIndex = apiRef.current.getColumnIndex(params.field, true);
149
- const targetCol = apiRef.current.getColumn(params.field);
150
- const dragColIndex = apiRef.current.getColumnIndex(dragColField, false);
151
- const visibleColumns = apiRef.current.getVisibleColumns();
152
- const allColumns = apiRef.current.getAllColumns();
153
- const cursorMoveDirectionX = getCursorMoveDirectionX(cursorPosition.current, coordinates);
154
- const hasMovedLeft = cursorMoveDirectionX === CURSOR_MOVE_DIRECTION_LEFT && (isRtl ? dragColIndex < targetColIndex : targetColIndex < dragColIndex);
155
- const hasMovedRight = cursorMoveDirectionX === CURSOR_MOVE_DIRECTION_RIGHT && (isRtl ? targetColIndex < dragColIndex : dragColIndex < targetColIndex);
156
- if (hasMovedLeft || hasMovedRight) {
157
- let canBeReordered;
158
- let indexOffsetInHiddenColumns = 0;
159
- if (!targetCol.disableReorder) {
160
- canBeReordered = true;
161
- } else if (hasMovedLeft) {
162
- canBeReordered = targetColVisibleIndex > 0 && !visibleColumns[targetColVisibleIndex - 1].disableReorder;
163
- } else {
164
- canBeReordered = targetColVisibleIndex < visibleColumns.length - 1 && !visibleColumns[targetColVisibleIndex + 1].disableReorder;
165
- }
166
- if (forbiddenIndexes.current[targetColIndex]) {
167
- let nextVisibleColumnField;
168
- let indexWithOffset = targetColIndex + indexOffsetInHiddenColumns;
169
- if (hasMovedLeft) {
170
- nextVisibleColumnField = targetColVisibleIndex > 0 ? visibleColumns[targetColVisibleIndex - 1].field : null;
171
- while (indexWithOffset > 0 && allColumns[indexWithOffset].field !== nextVisibleColumnField && forbiddenIndexes.current[indexWithOffset]) {
172
- indexOffsetInHiddenColumns -= 1;
173
- indexWithOffset = targetColIndex + indexOffsetInHiddenColumns;
174
- }
175
- } else {
176
- nextVisibleColumnField = targetColVisibleIndex + 1 < visibleColumns.length ? visibleColumns[targetColVisibleIndex + 1].field : null;
177
- while (indexWithOffset < allColumns.length - 1 && allColumns[indexWithOffset].field !== nextVisibleColumnField && forbiddenIndexes.current[indexWithOffset]) {
178
- indexOffsetInHiddenColumns += 1;
179
- indexWithOffset = targetColIndex + indexOffsetInHiddenColumns;
180
- }
181
- }
182
- if (forbiddenIndexes.current[indexWithOffset] || allColumns[indexWithOffset].field === nextVisibleColumnField) {
183
- // If we ended up on a visible column, or a forbidden one, we cannot do the reorder
184
- canBeReordered = false;
185
- }
186
- }
187
- const canBeReorderedProcessed = apiRef.current.unstable_applyPipeProcessors('canBeReordered', canBeReordered, {
188
- targetIndex: targetColVisibleIndex
189
- });
190
- if (canBeReorderedProcessed) {
191
- apiRef.current.setColumnIndex(dragColField, targetColIndex + indexOffsetInHiddenColumns);
192
- }
193
- }
194
- cursorPosition.current = coordinates;
195
- }
196
- }, [apiRef, logger, isRtl]);
197
- const handleDragEnd = React.useCallback((params, event) => {
198
- const dragColField = gridColumnReorderDragColSelector(apiRef);
199
- if (props.disableColumnReorder || !dragColField) {
200
- return;
201
- }
202
- logger.debug('End dragging col');
203
- event.preventDefault();
204
- // Prevent drag events propagation.
205
- // For more information check here https://github.com/mui/mui-x/issues/2680.
206
- event.stopPropagation();
207
- clearTimeout(removeDnDStylesTimeout.current);
208
-
209
- // For more information check here https://github.com/mui/mui-x/issues/14678
210
- if (dragColNode.current.classList.contains(classes.columnHeaderDragging)) {
211
- dragColNode.current.classList.remove(classes.columnHeaderDragging);
212
- }
213
- dragColNode.current = null;
214
-
215
- // Check if the column was dropped outside the grid.
216
- if (event.dataTransfer.dropEffect === 'none' && !props.keepColumnPositionIfDraggedOutside) {
217
- // Accessing params.field may contain the wrong field as header elements are reused
218
- apiRef.current.setColumnIndex(dragColField, originColumnIndex.current);
219
- originColumnIndex.current = null;
220
- } else {
221
- // Emit the columnOrderChange event only once when the reordering stops.
222
- const columnOrderChangeParams = {
223
- column: apiRef.current.getColumn(dragColField),
224
- targetIndex: apiRef.current.getColumnIndexRelativeToVisibleColumns(dragColField),
225
- oldIndex: originColumnIndex.current
226
- };
227
- apiRef.current.publishEvent('columnOrderChange', columnOrderChangeParams);
228
- }
229
- apiRef.current.setState(state => _extends({}, state, {
230
- columnReorder: _extends({}, state.columnReorder, {
231
- dragCol: ''
232
- })
233
- }));
234
- }, [apiRef, props.disableColumnReorder, props.keepColumnPositionIfDraggedOutside, logger, classes.columnHeaderDragging]);
235
- useGridEvent(apiRef, 'columnHeaderDragStart', handleDragStart);
236
- useGridEvent(apiRef, 'columnHeaderDragEnter', handleDragEnter);
237
- useGridEvent(apiRef, 'columnHeaderDragOver', handleDragOver);
238
- useGridEvent(apiRef, 'columnHeaderDragEnd', handleDragEnd);
239
- useGridEvent(apiRef, 'cellDragEnter', handleDragEnter);
240
- useGridEvent(apiRef, 'cellDragOver', handleDragOver);
241
- useGridEventPriority(apiRef, 'columnOrderChange', props.onColumnOrderChange);
242
- };
@@ -1,7 +0,0 @@
1
- import type { GridRowId } from '@mui/x-data-grid';
2
- import { GridStatePro } from "../../../models/gridStatePro.js";
3
- export declare const gridDataSourceStateSelector: import("@mui/x-data-grid").OutputSelector<GridStatePro, unknown, import("./models").GridDataSourceState>;
4
- export declare const gridDataSourceLoadingSelector: import("@mui/x-data-grid").OutputSelector<GridStatePro, import("./models").GridDataSourceState, Record<GridRowId, boolean>>;
5
- export declare const gridDataSourceLoadingIdSelector: import("@mui/x-data-grid").OutputSelector<GridStatePro, GridRowId, boolean>;
6
- export declare const gridDataSourceErrorsSelector: import("@mui/x-data-grid").OutputSelector<GridStatePro, import("./models").GridDataSourceState, Record<GridRowId, any>>;
7
- export declare const gridDataSourceErrorSelector: import("@mui/x-data-grid").OutputSelector<GridStatePro, GridRowId, any>;
@@ -1,6 +0,0 @@
1
- import { createSelector, createRootSelector } from '@mui/x-data-grid/internals';
2
- export const gridDataSourceStateSelector = createRootSelector(state => state.dataSource);
3
- export const gridDataSourceLoadingSelector = createSelector(gridDataSourceStateSelector, dataSource => dataSource.loading);
4
- export const gridDataSourceLoadingIdSelector = createSelector(gridDataSourceStateSelector, (dataSource, id) => dataSource.loading[id] ?? false);
5
- export const gridDataSourceErrorsSelector = createSelector(gridDataSourceStateSelector, dataSource => dataSource.errors);
6
- export const gridDataSourceErrorSelector = createSelector(gridDataSourceStateSelector, (dataSource, id) => dataSource.errors[id]);
@@ -1,75 +0,0 @@
1
- import type { GridValidRowModel, GridRowId, GridGetRowsResponse, GridDataSource, GridGetRowsParams } from '@mui/x-data-grid';
2
- import type { GridDataSourceApiBase } from '@mui/x-data-grid/internals';
3
- export interface GridDataSourceState {
4
- loading: Record<GridRowId, boolean>;
5
- errors: Record<GridRowId, any>;
6
- }
7
- export interface GridGetRowsResponsePro extends GridGetRowsResponse {}
8
- export interface GridGetRowsParamsPro extends GridGetRowsParams {
9
- /**
10
- * Array of keys returned by `getGroupKey` of all the parent rows until the row for which the data is requested
11
- * `getGroupKey` prop must be implemented to use this.
12
- * Useful for `treeData` and `rowGrouping` only.
13
- */
14
- groupKeys?: string[];
15
- }
16
- export interface GridDataSourcePro extends Omit<GridDataSource, 'getRows'> {
17
- /**
18
- * This method will be called when the grid needs to fetch some rows.
19
- * @param {GridGetRowsParamsPro} params The parameters required to fetch the rows.
20
- * @returns {Promise<GridGetRowsResponsePro>} A promise that resolves to the data of type [GridGetRowsResponsePro].
21
- */
22
- getRows(params: GridGetRowsParamsPro): Promise<GridGetRowsResponsePro>;
23
- /**
24
- * Used to group rows by their parent group. Replaces `getTreeDataPath` used in client side tree-data.
25
- * @param {GridRowModel} row The row to get the group key of.
26
- * @returns {string} The group key for the row.
27
- */
28
- getGroupKey?: (row: GridValidRowModel) => string;
29
- /**
30
- * Used to determine the number of children a row has on server.
31
- * @param {GridRowModel} row The row to check the number of children.
32
- * @returns {number} The number of children the row has.
33
- * If the children count is not available for some reason, but there are some children, `getChildrenCount` should return `-1`.
34
- */
35
- getChildrenCount?: (row: GridValidRowModel) => number;
36
- }
37
- export interface GridDataSourceApiBasePro extends Omit<GridDataSourceApiBase, 'fetchRows'> {
38
- /**
39
- * Fetches the rows from the server.
40
- * If no `parentId` option is provided, it fetches the root rows.
41
- * Any missing parameter from `params` will be filled from the state (sorting, filtering, etc.).
42
- * @param {GridRowId} parentId The id of the parent node (default: `GRID_ROOT_GROUP_ID`).
43
- * @param {Partial<GridGetRowsParamsPro>} params Request parameters override.
44
- */
45
- fetchRows: (parentId?: GridRowId, params?: Partial<GridGetRowsParamsPro>) => void;
46
- /**
47
- * Set the loading state of a parent row.
48
- * @param {string} parentId The id of the parent node.
49
- * @param {boolean} loading The loading state to set.
50
- */
51
- setChildrenLoading: (parentId: GridRowId, loading: boolean) => void;
52
- /**
53
- * Set error occured while fetching the children of a row.
54
- * @param {string} parentId The id of the parent node.
55
- * @param {Error} error The error of type `Error` or `null`.
56
- */
57
- setChildrenFetchError: (parentId: GridRowId, error: Error | null) => void;
58
- }
59
- export interface GridDataSourceApiPro {
60
- /**
61
- * The data source API.
62
- */
63
- dataSource: GridDataSourceApiBasePro;
64
- }
65
- export interface GridDataSourcePrivateApiPro {
66
- /**
67
- * Initiates the fetch of the children of a row.
68
- * @param {string} id The id of the group to be fetched.
69
- */
70
- fetchRowChildren: (id: GridRowId) => void;
71
- /**
72
- * Resets the data source state.
73
- */
74
- resetDataSourceState: () => void;
75
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,33 +0,0 @@
1
- import { RefObject } from '@mui/x-internals/types';
2
- import { GridRowId, GridDataSourceCacheDefaultConfig } from '@mui/x-data-grid';
3
- import { CacheChunkManager, DataSourceRowsUpdateStrategy } from '@mui/x-data-grid/internals';
4
- import { GridPrivateApiPro } from "../../../models/gridApiPro.js";
5
- import { DataGridProProcessedProps } from "../../../models/dataGridProProps.js";
6
- import { GridDataSourceApiPro, GridDataSourcePrivateApiPro } from "./models.js";
7
- export declare const INITIAL_STATE: {
8
- loading: {};
9
- errors: {};
10
- };
11
- export declare const useGridDataSourceBasePro: <Api extends GridPrivateApiPro>(apiRef: RefObject<Api>, props: DataGridProProcessedProps, options?: {
12
- cacheOptions?: GridDataSourceCacheDefaultConfig;
13
- fetchRowChildren?: (parentId: GridRowId) => void;
14
- }) => {
15
- api: {
16
- public: GridDataSourceApiPro;
17
- private: GridDataSourcePrivateApiPro;
18
- };
19
- strategyProcessor: {
20
- strategyName: DataSourceRowsUpdateStrategy;
21
- group: "dataSourceRowsUpdate";
22
- processor: import("@mui/x-data-grid/internals").GridStrategyProcessor<"dataSourceRowsUpdate">;
23
- };
24
- events: {
25
- strategyAvailabilityChange: import("@mui/x-data-grid").GridEventListener<"strategyAvailabilityChange">;
26
- sortModelChange: (params: unknown) => void;
27
- filterModelChange: (params: unknown) => void;
28
- paginationModelChange: (params: unknown) => void;
29
- };
30
- setStrategyAvailability: () => void;
31
- cacheChunkManager: CacheChunkManager;
32
- cache: import("@mui/x-data-grid").GridDataSourceCache;
33
- };