@mui/x-data-grid 5.8.0 → 5.9.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 (242) hide show
  1. package/CHANGELOG.md +141 -63
  2. package/DataGrid/DataGrid.js +1 -1
  3. package/DataGrid/useDataGridComponent.js +3 -1
  4. package/LICENSE +21 -0
  5. package/README.md +1 -1
  6. package/components/GridRow.d.ts +4 -0
  7. package/components/GridRow.js +49 -23
  8. package/components/base/GridOverlays.js +4 -3
  9. package/components/cell/GridActionsCell.d.ts +5 -1
  10. package/components/cell/GridActionsCell.js +170 -21
  11. package/components/cell/GridActionsCellItem.d.ts +66 -4
  12. package/components/cell/GridActionsCellItem.js +7 -5
  13. package/components/cell/GridCell.d.ts +1 -0
  14. package/components/cell/GridCell.js +28 -7
  15. package/components/cell/GridEditInputCell.js +1 -1
  16. package/components/cell/GridEditSingleSelectCell.js +22 -13
  17. package/components/columnHeaders/GridColumnHeaderItem.js +4 -7
  18. package/components/columnHeaders/GridColumnHeaders.d.ts +0 -1
  19. package/components/columnHeaders/GridColumnHeaders.js +1 -1
  20. package/components/columnSelection/GridCellCheckboxRenderer.d.ts +3 -3
  21. package/components/columnSelection/GridCellCheckboxRenderer.js +20 -3
  22. package/components/panel/GridPanel.js +1 -0
  23. package/components/panel/filterPanel/GridFilterForm.js +14 -10
  24. package/components/panel/filterPanel/GridFilterInputBoolean.js +13 -8
  25. package/components/panel/filterPanel/GridFilterInputSingleSelect.js +22 -15
  26. package/components/panel/filterPanel/GridFilterInputValue.js +22 -15
  27. package/components/toolbar/GridToolbarDensitySelector.js +1 -1
  28. package/components/toolbar/GridToolbarFilterButton.d.ts +1 -1
  29. package/components/virtualization/GridVirtualScroller.js +2 -0
  30. package/components/virtualization/GridVirtualScrollerContent.js +1 -3
  31. package/constants/gridDetailPanelToggleField.d.ts +1 -0
  32. package/constants/gridDetailPanelToggleField.js +2 -0
  33. package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +32 -15
  34. package/hooks/core/pipeProcessing/index.d.ts +1 -0
  35. package/hooks/core/pipeProcessing/index.js +2 -1
  36. package/hooks/core/pipeProcessing/useGridPipeProcessing.d.ts +8 -3
  37. package/hooks/core/pipeProcessing/useGridPipeProcessing.js +53 -19
  38. package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +3 -0
  39. package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +27 -0
  40. package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +0 -3
  41. package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +0 -4
  42. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +0 -1
  43. package/hooks/features/columnHeaders/useGridColumnHeaders.js +76 -10
  44. package/hooks/features/columns/gridColumnsInterfaces.d.ts +3 -1
  45. package/hooks/features/columns/gridColumnsUtils.d.ts +19 -1
  46. package/hooks/features/columns/gridColumnsUtils.js +61 -8
  47. package/hooks/features/columns/useGridColumnSpanning.d.ts +7 -0
  48. package/hooks/features/columns/useGridColumnSpanning.js +109 -0
  49. package/hooks/features/columns/useGridColumns.js +24 -18
  50. package/hooks/features/dimensions/useGridDimensions.js +3 -3
  51. package/hooks/features/editRows/useGridCellEditing.new.js +18 -10
  52. package/hooks/features/editRows/useGridEditing.new.js +7 -3
  53. package/hooks/features/editRows/useGridRowEditing.new.js +23 -15
  54. package/hooks/features/filter/useGridFilter.js +14 -9
  55. package/hooks/features/focus/useGridFocus.js +19 -9
  56. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -0
  57. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +39 -7
  58. package/hooks/features/rows/gridRowsSelector.d.ts +1 -0
  59. package/hooks/features/rows/gridRowsSelector.js +1 -0
  60. package/hooks/features/rows/gridRowsState.d.ts +4 -0
  61. package/hooks/features/rows/useGridRows.d.ts +2 -2
  62. package/hooks/features/rows/useGridRows.js +5 -4
  63. package/hooks/features/rows/useGridRowsMeta.js +6 -13
  64. package/hooks/features/scroll/useGridScroll.d.ts +2 -0
  65. package/hooks/features/scroll/useGridScroll.js +25 -3
  66. package/hooks/features/selection/useGridSelection.js +3 -2
  67. package/hooks/features/sorting/useGridSorting.js +10 -10
  68. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +7 -0
  69. package/hooks/features/virtualization/useGridVirtualScroller.js +54 -27
  70. package/index.js +1 -1
  71. package/internals/index.d.ts +1 -0
  72. package/internals/index.js +1 -0
  73. package/legacy/DataGrid/DataGrid.js +1 -1
  74. package/legacy/DataGrid/useDataGridComponent.js +3 -1
  75. package/legacy/components/GridRow.js +47 -23
  76. package/legacy/components/base/GridOverlays.js +4 -3
  77. package/legacy/components/cell/GridActionsCell.js +188 -27
  78. package/legacy/components/cell/GridActionsCellItem.js +7 -5
  79. package/legacy/components/cell/GridCell.js +29 -7
  80. package/legacy/components/cell/GridEditInputCell.js +1 -1
  81. package/legacy/components/cell/GridEditSingleSelectCell.js +33 -24
  82. package/legacy/components/columnHeaders/GridColumnHeaderItem.js +4 -7
  83. package/legacy/components/columnHeaders/GridColumnHeaders.js +2 -3
  84. package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +21 -3
  85. package/legacy/components/panel/GridPanel.js +1 -0
  86. package/legacy/components/panel/filterPanel/GridFilterForm.js +14 -10
  87. package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +13 -8
  88. package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +22 -17
  89. package/legacy/components/panel/filterPanel/GridFilterInputValue.js +22 -17
  90. package/legacy/components/toolbar/GridToolbarDensitySelector.js +1 -1
  91. package/legacy/components/virtualization/GridVirtualScroller.js +2 -0
  92. package/legacy/components/virtualization/GridVirtualScrollerContent.js +1 -3
  93. package/legacy/constants/gridDetailPanelToggleField.js +2 -0
  94. package/legacy/hooks/core/pipeProcessing/index.js +2 -1
  95. package/legacy/hooks/core/pipeProcessing/useGridPipeProcessing.js +60 -24
  96. package/legacy/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +27 -0
  97. package/legacy/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +0 -4
  98. package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +89 -10
  99. package/legacy/hooks/features/columns/gridColumnsUtils.js +79 -22
  100. package/legacy/hooks/features/columns/useGridColumnSpanning.js +107 -0
  101. package/legacy/hooks/features/columns/useGridColumns.js +24 -18
  102. package/legacy/hooks/features/dimensions/useGridDimensions.js +3 -3
  103. package/legacy/hooks/features/editRows/useGridCellEditing.new.js +14 -8
  104. package/legacy/hooks/features/editRows/useGridEditing.new.js +7 -3
  105. package/legacy/hooks/features/editRows/useGridRowEditing.new.js +32 -24
  106. package/legacy/hooks/features/filter/useGridFilter.js +14 -9
  107. package/legacy/hooks/features/focus/useGridFocus.js +19 -9
  108. package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +39 -6
  109. package/legacy/hooks/features/rows/gridRowsSelector.js +3 -0
  110. package/legacy/hooks/features/rows/useGridRows.js +5 -4
  111. package/legacy/hooks/features/rows/useGridRowsMeta.js +6 -13
  112. package/legacy/hooks/features/scroll/useGridScroll.js +25 -3
  113. package/legacy/hooks/features/selection/useGridSelection.js +3 -2
  114. package/legacy/hooks/features/sorting/useGridSorting.js +5 -7
  115. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +65 -37
  116. package/legacy/index.js +1 -1
  117. package/legacy/internals/index.js +1 -0
  118. package/legacy/locales/huHU.js +120 -0
  119. package/legacy/locales/index.js +1 -0
  120. package/legacy/models/api/gridColumnSpanning.js +1 -0
  121. package/legacy/models/events/gridEvents.js +2 -3
  122. package/legacy/models/gridColumnSpanning.js +1 -0
  123. package/locales/huHU.d.ts +2 -0
  124. package/locales/huHU.js +108 -0
  125. package/locales/index.d.ts +1 -0
  126. package/locales/index.js +1 -0
  127. package/models/api/gridApiCommon.d.ts +2 -1
  128. package/models/api/gridColumnSpanning.d.ts +28 -0
  129. package/models/api/gridColumnSpanning.js +1 -0
  130. package/models/api/gridEditingApi.d.ts +49 -3
  131. package/models/colDef/gridColDef.d.ts +5 -0
  132. package/models/events/gridEventLookup.d.ts +3 -8
  133. package/models/events/gridEvents.d.ts +9 -14
  134. package/models/events/gridEvents.js +2 -3
  135. package/models/gridColumnSpanning.d.ts +12 -0
  136. package/models/gridColumnSpanning.js +1 -0
  137. package/models/gridEditRowModel.d.ts +1 -1
  138. package/models/params/gridCellParams.d.ts +12 -2
  139. package/models/params/gridRowParams.d.ts +5 -0
  140. package/models/props/DataGridProps.d.ts +1 -1
  141. package/modern/DataGrid/DataGrid.js +1 -1
  142. package/modern/DataGrid/useDataGridComponent.js +3 -1
  143. package/modern/components/GridRow.js +47 -21
  144. package/modern/components/base/GridOverlays.js +4 -3
  145. package/modern/components/cell/GridActionsCell.js +168 -21
  146. package/modern/components/cell/GridActionsCellItem.js +7 -5
  147. package/modern/components/cell/GridCell.js +28 -7
  148. package/modern/components/cell/GridEditInputCell.js +1 -1
  149. package/modern/components/cell/GridEditSingleSelectCell.js +20 -11
  150. package/modern/components/columnHeaders/GridColumnHeaderItem.js +4 -7
  151. package/modern/components/columnHeaders/GridColumnHeaders.js +1 -1
  152. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +20 -3
  153. package/modern/components/panel/GridPanel.js +1 -0
  154. package/modern/components/panel/filterPanel/GridFilterForm.js +10 -6
  155. package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +11 -6
  156. package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +20 -13
  157. package/modern/components/panel/filterPanel/GridFilterInputValue.js +20 -13
  158. package/modern/components/toolbar/GridToolbarDensitySelector.js +1 -1
  159. package/modern/components/virtualization/GridVirtualScroller.js +2 -0
  160. package/modern/components/virtualization/GridVirtualScrollerContent.js +1 -3
  161. package/modern/constants/gridDetailPanelToggleField.js +2 -0
  162. package/modern/hooks/core/pipeProcessing/index.js +2 -1
  163. package/modern/hooks/core/pipeProcessing/useGridPipeProcessing.js +53 -19
  164. package/modern/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +27 -0
  165. package/modern/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +0 -4
  166. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +76 -10
  167. package/modern/hooks/features/columns/gridColumnsUtils.js +61 -8
  168. package/modern/hooks/features/columns/useGridColumnSpanning.js +107 -0
  169. package/modern/hooks/features/columns/useGridColumns.js +24 -18
  170. package/modern/hooks/features/dimensions/useGridDimensions.js +3 -3
  171. package/modern/hooks/features/editRows/useGridCellEditing.new.js +18 -10
  172. package/modern/hooks/features/editRows/useGridEditing.new.js +7 -3
  173. package/modern/hooks/features/editRows/useGridRowEditing.new.js +23 -15
  174. package/modern/hooks/features/filter/useGridFilter.js +14 -9
  175. package/modern/hooks/features/focus/useGridFocus.js +19 -9
  176. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +37 -7
  177. package/modern/hooks/features/rows/gridRowsSelector.js +1 -0
  178. package/modern/hooks/features/rows/useGridRows.js +5 -4
  179. package/modern/hooks/features/rows/useGridRowsMeta.js +6 -13
  180. package/modern/hooks/features/scroll/useGridScroll.js +23 -3
  181. package/modern/hooks/features/selection/useGridSelection.js +3 -2
  182. package/modern/hooks/features/sorting/useGridSorting.js +10 -10
  183. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +54 -23
  184. package/modern/index.js +1 -1
  185. package/modern/internals/index.js +1 -0
  186. package/modern/locales/huHU.js +108 -0
  187. package/modern/locales/index.js +1 -0
  188. package/modern/models/api/gridColumnSpanning.js +1 -0
  189. package/modern/models/events/gridEvents.js +2 -3
  190. package/modern/models/gridColumnSpanning.js +1 -0
  191. package/node/DataGrid/DataGrid.js +1 -1
  192. package/node/DataGrid/useDataGridComponent.js +4 -1
  193. package/node/components/GridRow.js +50 -23
  194. package/node/components/base/GridOverlays.js +3 -2
  195. package/node/components/cell/GridActionsCell.js +172 -21
  196. package/node/components/cell/GridActionsCellItem.js +7 -4
  197. package/node/components/cell/GridCell.js +28 -7
  198. package/node/components/cell/GridEditInputCell.js +1 -1
  199. package/node/components/cell/GridEditSingleSelectCell.js +23 -13
  200. package/node/components/columnHeaders/GridColumnHeaderItem.js +4 -7
  201. package/node/components/columnHeaders/GridColumnHeaders.js +1 -1
  202. package/node/components/columnSelection/GridCellCheckboxRenderer.js +20 -3
  203. package/node/components/panel/GridPanel.js +1 -0
  204. package/node/components/panel/filterPanel/GridFilterForm.js +15 -10
  205. package/node/components/panel/filterPanel/GridFilterInputBoolean.js +14 -8
  206. package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +23 -15
  207. package/node/components/panel/filterPanel/GridFilterInputValue.js +23 -15
  208. package/node/components/toolbar/GridToolbarDensitySelector.js +1 -1
  209. package/node/components/virtualization/GridVirtualScroller.js +2 -0
  210. package/node/components/virtualization/GridVirtualScrollerContent.js +1 -3
  211. package/node/constants/gridDetailPanelToggleField.js +9 -0
  212. package/node/hooks/core/pipeProcessing/index.js +13 -0
  213. package/node/hooks/core/pipeProcessing/useGridPipeProcessing.js +51 -20
  214. package/node/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +42 -0
  215. package/node/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +0 -3
  216. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +80 -10
  217. package/node/hooks/features/columns/gridColumnsUtils.js +65 -9
  218. package/node/hooks/features/columns/useGridColumnSpanning.js +130 -0
  219. package/node/hooks/features/columns/useGridColumns.js +23 -17
  220. package/node/hooks/features/dimensions/useGridDimensions.js +3 -3
  221. package/node/hooks/features/editRows/useGridCellEditing.new.js +18 -10
  222. package/node/hooks/features/editRows/useGridEditing.new.js +6 -2
  223. package/node/hooks/features/editRows/useGridRowEditing.new.js +21 -14
  224. package/node/hooks/features/filter/useGridFilter.js +14 -9
  225. package/node/hooks/features/focus/useGridFocus.js +19 -9
  226. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +40 -7
  227. package/node/hooks/features/rows/gridRowsSelector.js +3 -1
  228. package/node/hooks/features/rows/useGridRows.js +5 -4
  229. package/node/hooks/features/rows/useGridRowsMeta.js +6 -14
  230. package/node/hooks/features/scroll/useGridScroll.js +26 -2
  231. package/node/hooks/features/selection/useGridSelection.js +4 -2
  232. package/node/hooks/features/sorting/useGridSorting.js +10 -10
  233. package/node/hooks/features/virtualization/useGridVirtualScroller.js +59 -27
  234. package/node/index.js +1 -1
  235. package/node/internals/index.js +8 -0
  236. package/node/locales/huHU.js +118 -0
  237. package/node/locales/index.js +13 -0
  238. package/node/models/api/gridColumnSpanning.js +5 -0
  239. package/node/models/events/gridEvents.js +2 -3
  240. package/node/models/gridColumnSpanning.js +5 -0
  241. package/package.json +4 -4
  242. package/utils/domUtils.d.ts +2 -2
@@ -1,20 +1,12 @@
1
1
  import * as React from 'react';
2
- import { GridCellIndexCoordinates, GridScrollParams } from '../../../models';
2
+ import { GridCellIndexCoordinates, GridScrollParams, GridColDef } from '../../../models';
3
3
  import { GridInitialStateCommunity } from '../../../models/gridStateCommunity';
4
- import { GridColDef } from '../../../models/colDef/gridColDef';
5
4
  import { GridRestoreStatePreProcessingContext, GridRestoreStatePreProcessingValue } from '../../features/statePersistence/gridStatePersistenceInterface';
6
5
  import { GridHydrateColumnsValue } from '../../features/columns/gridColumnsInterfaces';
7
6
  import { GridRowEntry } from '../../../models/gridRows';
8
7
  import { GridPreferencePanelsValue } from '../../features/preferencesPanel';
9
8
  export declare type GridPipeProcessorGroup = keyof GridPipeProcessingLookup;
10
9
  export interface GridPipeProcessingLookup {
11
- hydrateColumns: {
12
- value: GridHydrateColumnsValue;
13
- };
14
- scrollToIndexes: {
15
- value: Partial<GridScrollParams>;
16
- context: Partial<GridCellIndexCoordinates>;
17
- };
18
10
  columnMenu: {
19
11
  value: React.ReactNode[];
20
12
  context: GridColDef;
@@ -22,6 +14,13 @@ export interface GridPipeProcessingLookup {
22
14
  exportState: {
23
15
  value: GridInitialStateCommunity;
24
16
  };
17
+ hydrateColumns: {
18
+ value: GridHydrateColumnsValue;
19
+ };
20
+ preferencePanel: {
21
+ value: React.ReactNode;
22
+ context: GridPreferencePanelsValue;
23
+ };
25
24
  restoreState: {
26
25
  value: GridRestoreStatePreProcessingValue;
27
26
  context: GridRestoreStatePreProcessingContext<GridInitialStateCommunity>;
@@ -30,9 +29,9 @@ export interface GridPipeProcessingLookup {
30
29
  value: Record<string, number>;
31
30
  context: GridRowEntry;
32
31
  };
33
- preferencePanel: {
34
- value: React.ReactNode;
35
- context: GridPreferencePanelsValue;
32
+ scrollToIndexes: {
33
+ value: Partial<GridScrollParams>;
34
+ context: Partial<GridCellIndexCoordinates>;
36
35
  };
37
36
  }
38
37
  export declare type GridPipeProcessor<P extends GridPipeProcessorGroup> = (value: GridPipeProcessingLookup[P]['value'], context: GridPipeProcessingLookup[P] extends {
@@ -46,14 +45,14 @@ declare type GridPipeProcessorsApplierArgs<P extends GridPipeProcessorGroup, T e
46
45
  declare type GridPipeProcessorsApplier = <P extends GridPipeProcessorGroup>(...params: GridPipeProcessorsApplierArgs<P, GridPipeProcessingLookup[P]>) => GridPipeProcessingLookup[P]['value'];
47
46
  export interface GridPipeProcessingApi {
48
47
  /**
49
- * Register a pre-processor and emit an event to notify the agents to re-apply the pre-processors.
48
+ * Register a processor and run all the appliers of the group.
50
49
  * @param {GridPipeProcessorGroup} group The group on which this processor should be applied.
51
- * @param {number} id An unique and static identifier of the processor.
50
+ * @param {string} id An unique and static identifier of the processor.
52
51
  * @param {GridPipeProcessor} processor The processor to register.
53
52
  * @returns {() => void} A function to unregister the processor.
54
53
  * @ignore - do not document.
55
54
  */
56
- unstable_registerPipeProcessor: <G extends GridPipeProcessorGroup>(processorName: GridPipeProcessorGroup, id: string, callback: GridPipeProcessor<G>) => () => void;
55
+ unstable_registerPipeProcessor: <G extends GridPipeProcessorGroup>(group: GridPipeProcessorGroup, id: string, callback: GridPipeProcessor<G>) => () => void;
57
56
  /**
58
57
  * Run all the processors registered for the given group.
59
58
  * @template T
@@ -64,5 +63,23 @@ export interface GridPipeProcessingApi {
64
63
  * @ignore - do not document.
65
64
  */
66
65
  unstable_applyPipeProcessors: GridPipeProcessorsApplier;
66
+ /**
67
+ * Register an applier.
68
+ * @param {GridPipeProcessorGroup} group The group of this applier
69
+ * @param {string} id An unique and static identifier of the applier.
70
+ * @param {() => void} applier The applier to register.
71
+ * @returns {() => void} A function to unregister the applier.
72
+ * @ignore - do not document.
73
+ */
74
+ unstable_registerPipeApplier: (group: GridPipeProcessorGroup, id: string, applier: () => void) => () => void;
75
+ /**
76
+ * Imperatively run all the appliers of a group.
77
+ * Most of the time, the applier should run because a processor is re-registered,
78
+ * but sometimes we want to re-apply the processing even if the processor deps have not changed.
79
+ * This may occur when the change requires a `isDeepEqual` check.
80
+ * @param {GridPipeProcessorGroup} group The group to apply.
81
+ * @ignore - do not document.
82
+ */
83
+ unstable_requestPipeProcessorsApplication: (group: GridPipeProcessorGroup) => void;
67
84
  }
68
85
  export {};
@@ -1,3 +1,4 @@
1
1
  export * from './gridPipeProcessingApi';
2
2
  export * from './useGridPipeProcessing';
3
3
  export * from './useGridRegisterPipeProcessor';
4
+ export * from './useGridRegisterPipeApplier';
@@ -1,3 +1,4 @@
1
1
  export * from './gridPipeProcessingApi';
2
2
  export * from './useGridPipeProcessing';
3
- export * from './useGridRegisterPipeProcessor';
3
+ export * from './useGridRegisterPipeProcessor';
4
+ export * from './useGridRegisterPipeApplier';
@@ -13,7 +13,10 @@ import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
13
13
  * The plugin containing the custom logic must use:
14
14
  *
15
15
  * - `useGridRegisterPipeProcessor` to register their processor.
16
- * When the processor changes, it will fire `GridEvents.pipeProcessorRegister` to re-apply the whole pipe.
16
+ *
17
+ * - `apiRef.current.unstable_requestPipeProcessorsApplication` to imperatively re-apply a group.
18
+ * This method should be used in last resort.
19
+ * Most of the time, the application should be triggered by an update on the deps of the processor.
17
20
  *
18
21
  * =====================================================================================================================
19
22
  *
@@ -21,7 +24,9 @@ import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
21
24
  *
22
25
  * - `apiRef.current.unstable_applyPipeProcessors` to run in chain all the processors of a given group.
23
26
  *
24
- * - `GridEvents.pipeProcessorRegister` to re-apply the whole pipe when a processor of this pipe changes.
25
- *
27
+ * - `useGridRegisterPipeApplier` to re-apply the whole pipe when requested.
28
+ * The applier will be called when:
29
+ * * a processor is registered.
30
+ * * `apiRef.current.unstable_requestPipeProcessorsApplication` is called for the given group.
26
31
  */
27
32
  export declare const useGridPipeProcessing: (apiRef: React.MutableRefObject<GridApiCommunity>) => void;
@@ -1,9 +1,8 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _toPropertyKey from "@babel/runtime/helpers/esm/toPropertyKey";
3
- import _extends from "@babel/runtime/helpers/esm/extends";
4
3
  import * as React from 'react';
5
4
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
6
- import { GridEvents } from '../../../models/events';
5
+
7
6
  /**
8
7
  * Implement the Pipeline Pattern
9
8
  *
@@ -17,7 +16,10 @@ import { GridEvents } from '../../../models/events';
17
16
  * The plugin containing the custom logic must use:
18
17
  *
19
18
  * - `useGridRegisterPipeProcessor` to register their processor.
20
- * When the processor changes, it will fire `GridEvents.pipeProcessorRegister` to re-apply the whole pipe.
19
+ *
20
+ * - `apiRef.current.unstable_requestPipeProcessorsApplication` to imperatively re-apply a group.
21
+ * This method should be used in last resort.
22
+ * Most of the time, the application should be triggered by an update on the deps of the processor.
21
23
  *
22
24
  * =====================================================================================================================
23
25
  *
@@ -25,35 +27,65 @@ import { GridEvents } from '../../../models/events';
25
27
  *
26
28
  * - `apiRef.current.unstable_applyPipeProcessors` to run in chain all the processors of a given group.
27
29
  *
28
- * - `GridEvents.pipeProcessorRegister` to re-apply the whole pipe when a processor of this pipe changes.
29
- *
30
+ * - `useGridRegisterPipeApplier` to re-apply the whole pipe when requested.
31
+ * The applier will be called when:
32
+ * * a processor is registered.
33
+ * * `apiRef.current.unstable_requestPipeProcessorsApplication` is called for the given group.
30
34
  */
31
-
32
35
  export const useGridPipeProcessing = apiRef => {
33
36
  const processorsCache = React.useRef({});
37
+ const runAppliers = React.useCallback(groupCache => {
38
+ if (!groupCache) {
39
+ return;
40
+ }
41
+
42
+ Object.values(groupCache.appliers).forEach(callback => {
43
+ callback();
44
+ });
45
+ }, []);
34
46
  const registerPipeProcessor = React.useCallback((group, id, processor) => {
35
47
  if (!processorsCache.current[group]) {
36
- processorsCache.current[group] = {};
48
+ processorsCache.current[group] = {
49
+ processors: {},
50
+ appliers: {}
51
+ };
37
52
  }
38
53
 
39
- const groupProcessors = processorsCache.current[group];
40
- const oldProcessor = groupProcessors[id];
54
+ const groupCache = processorsCache.current[group];
55
+ const oldProcessor = groupCache.processors[id];
41
56
 
42
57
  if (oldProcessor !== processor) {
43
- processorsCache.current[group] = _extends({}, groupProcessors, {
44
- [id]: processor
45
- });
46
- apiRef.current.publishEvent(GridEvents.pipeProcessorRegister, group);
58
+ groupCache.processors[id] = processor;
59
+ runAppliers(groupCache);
47
60
  }
48
61
 
49
62
  return () => {
50
- const _ref = processorsCache.current[group],
51
- otherProcessors = _objectWithoutPropertiesLoose(_ref, [id].map(_toPropertyKey));
63
+ const _processors = processorsCache.current[group].processors,
64
+ otherProcessors = _objectWithoutPropertiesLoose(_processors, [id].map(_toPropertyKey));
52
65
 
53
- processorsCache.current[group] = otherProcessors;
54
- apiRef.current.publishEvent(GridEvents.pipeProcessorUnregister, group);
66
+ processorsCache.current[group].processors = otherProcessors;
55
67
  };
56
- }, [apiRef]);
68
+ }, [runAppliers]);
69
+ const registerPipeApplier = React.useCallback((group, id, applier) => {
70
+ if (!processorsCache.current[group]) {
71
+ processorsCache.current[group] = {
72
+ processors: {},
73
+ appliers: {}
74
+ };
75
+ }
76
+
77
+ processorsCache.current[group].appliers[id] = applier;
78
+ return () => {
79
+ const _appliers = processorsCache.current[group].appliers,
80
+ otherAppliers = _objectWithoutPropertiesLoose(_appliers, [id].map(_toPropertyKey));
81
+
82
+ processorsCache.current[group].appliers = otherAppliers;
83
+ };
84
+ }, []);
85
+ const requestPipeProcessorsApplication = React.useCallback(group => {
86
+ const groupCache = processorsCache.current[group];
87
+ runAppliers(groupCache);
88
+ }, [runAppliers]);
57
89
  const applyPipeProcessors = React.useCallback((...args) => {
58
90
  const [group, value, context] = args;
59
91
 
@@ -61,13 +93,15 @@ export const useGridPipeProcessing = apiRef => {
61
93
  return value;
62
94
  }
63
95
 
64
- const preProcessors = Object.values(processorsCache.current[group]);
96
+ const preProcessors = Object.values(processorsCache.current[group].processors);
65
97
  return preProcessors.reduce((acc, preProcessor) => {
66
98
  return preProcessor(acc, context);
67
99
  }, value);
68
100
  }, []);
69
101
  const preProcessingApi = {
70
102
  unstable_registerPipeProcessor: registerPipeProcessor,
103
+ unstable_registerPipeApplier: registerPipeApplier,
104
+ unstable_requestPipeProcessorsApplication: requestPipeProcessorsApplication,
71
105
  unstable_applyPipeProcessors: applyPipeProcessors
72
106
  };
73
107
  useGridApiMethod(apiRef, preProcessingApi, 'GridPipeProcessingApi');
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import { GridApiCommon } from '../../../models/api/gridApiCommon';
3
+ export declare const useGridRegisterPipeApplier: <Api extends GridApiCommon, G extends keyof import("./gridPipeProcessingApi").GridPipeProcessingLookup>(apiRef: React.MutableRefObject<Api>, group: G, callback: () => void) => void;
@@ -0,0 +1,27 @@
1
+ import * as React from 'react';
2
+ import { useFirstRender } from '../../utils/useFirstRender';
3
+ export const useGridRegisterPipeApplier = (apiRef, group, callback) => {
4
+ const cleanup = React.useRef();
5
+ const id = React.useRef(`mui-${Math.round(Math.random() * 1e9)}`);
6
+ const registerPreProcessor = React.useCallback(() => {
7
+ cleanup.current = apiRef.current.unstable_registerPipeApplier(group, id.current, callback);
8
+ }, [apiRef, callback, group]);
9
+ useFirstRender(() => {
10
+ registerPreProcessor();
11
+ });
12
+ const isFirstRender = React.useRef(true);
13
+ React.useEffect(() => {
14
+ if (isFirstRender.current) {
15
+ isFirstRender.current = false;
16
+ } else {
17
+ registerPreProcessor();
18
+ }
19
+
20
+ return () => {
21
+ if (cleanup.current) {
22
+ cleanup.current();
23
+ cleanup.current = null;
24
+ }
25
+ };
26
+ }, [registerPreProcessor]);
27
+ };
@@ -1,7 +1,4 @@
1
1
  import * as React from 'react';
2
2
  import { GridApiCommon } from '../../../models/api/gridApiCommon';
3
3
  import { GridPipeProcessor } from './gridPipeProcessingApi';
4
- /**
5
- * TODO: Rename `useGridRegisterPipeProcessor`
6
- */
7
4
  export declare const useGridRegisterPipeProcessor: <Api extends GridApiCommon, G extends keyof import("./gridPipeProcessingApi").GridPipeProcessingLookup>(apiRef: React.MutableRefObject<Api>, group: G, callback: GridPipeProcessor<G>) => void;
@@ -1,9 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { useFirstRender } from '../../utils/useFirstRender';
3
-
4
- /**
5
- * TODO: Rename `useGridRegisterPipeProcessor`
6
- */
7
3
  export const useGridRegisterPipeProcessor = (apiRef, group, callback) => {
8
4
  const cleanup = React.useRef();
9
5
  const id = React.useRef(`mui-${Math.round(Math.random() * 1e9)}`);
@@ -12,7 +12,6 @@ export declare const useGridColumnHeaders: (props: UseGridColumnHeadersProps) =>
12
12
  maxLastColumn?: number | undefined;
13
13
  } | undefined, other?: {}) => JSX.Element[] | null;
14
14
  isDragging: boolean;
15
- updateInnerPosition: (nextRenderContext: GridRenderContext) => void;
16
15
  getRootProps: (other?: {}) => {
17
16
  style: {
18
17
  minHeight: number;
@@ -1,6 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
+ import * as ReactDOM from 'react-dom';
3
4
  import { useForkRef } from '@mui/material/utils';
5
+ import { defaultMemoize } from 'reselect';
4
6
  import { useGridApiContext } from '../../utils/useGridApiContext';
5
7
  import { useGridSelector } from '../../utils/useGridSelector';
6
8
  import { gridVisibleColumnDefinitionsSelector, gridColumnPositionsSelector } from '../columns/gridColumnsSelector';
@@ -13,7 +15,15 @@ import { useGridRootProps } from '../../utils/useGridRootProps';
13
15
  import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
14
16
  import { GridEvents } from '../../../models/events';
15
17
  import { GridColumnHeaderItem } from '../../../components/columnHeaders/GridColumnHeaderItem';
18
+ import { getFirstColumnIndexToRender } from '../columns/gridColumnsUtils';
19
+ import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
20
+ import { getRenderableIndexes } from '../virtualization/useGridVirtualScroller';
16
21
  import { jsx as _jsx } from "react/jsx-runtime";
22
+
23
+ function isUIEvent(event) {
24
+ return !!event.target;
25
+ }
26
+
17
27
  export const useGridColumnHeaders = props => {
18
28
  const {
19
29
  innerRef: innerRefProp,
@@ -37,18 +47,43 @@ export const useGridColumnHeaders = props => {
37
47
  const [renderContext, setRenderContext] = React.useState(null);
38
48
  const prevRenderContext = React.useRef(renderContext);
39
49
  const prevScrollLeft = React.useRef(0);
50
+ const currentPage = useGridVisibleRows(apiRef, rootProps);
40
51
  React.useEffect(() => {
41
52
  apiRef.current.columnHeadersContainerElementRef.current.scrollLeft = 0;
42
- }, [apiRef]);
53
+ }, [apiRef]); // memoize `getFirstColumnIndexToRender`, since it's called on scroll
54
+
55
+ const getFirstColumnIndexToRenderRef = React.useRef(defaultMemoize(getFirstColumnIndexToRender, {
56
+ equalityCheck: (a, b) => ['firstColumnIndex', 'minColumnIndex', 'columnBuffer'].every(key => a[key] === b[key])
57
+ }));
43
58
  const updateInnerPosition = React.useCallback(nextRenderContext => {
44
- const firstColumnToRender = Math.max(nextRenderContext.firstColumnIndex - rootProps.columnBuffer, minColumnIndex);
59
+ const [firstRowToRender, lastRowToRender] = getRenderableIndexes({
60
+ firstIndex: nextRenderContext.firstRowIndex,
61
+ lastIndex: nextRenderContext.lastRowIndex,
62
+ minFirstIndex: 0,
63
+ maxLastIndex: currentPage.rows.length,
64
+ buffer: rootProps.rowBuffer
65
+ });
66
+ const firstColumnToRender = getFirstColumnIndexToRenderRef.current({
67
+ firstColumnIndex: nextRenderContext.firstColumnIndex,
68
+ minColumnIndex,
69
+ columnBuffer: rootProps.columnBuffer,
70
+ firstRowToRender,
71
+ lastRowToRender,
72
+ apiRef,
73
+ visibleRows: currentPage.rows
74
+ });
45
75
  const offset = firstColumnToRender > 0 ? prevScrollLeft.current - columnPositions[firstColumnToRender] : prevScrollLeft.current;
46
76
  innerRef.current.style.transform = `translate3d(${-offset}px, 0px, 0px)`;
47
- }, [columnPositions, minColumnIndex, rootProps.columnBuffer]);
77
+ }, [columnPositions, minColumnIndex, rootProps.columnBuffer, apiRef, currentPage.rows, rootProps.rowBuffer]);
78
+ React.useLayoutEffect(() => {
79
+ if (renderContext) {
80
+ updateInnerPosition(renderContext);
81
+ }
82
+ }, [renderContext, updateInnerPosition]);
48
83
  const handleScroll = React.useCallback(({
49
84
  left,
50
85
  renderContext: nextRenderContext = null
51
- }) => {
86
+ }, event) => {
52
87
  var _prevRenderContext$cu, _prevRenderContext$cu2;
53
88
 
54
89
  if (!innerRef.current) {
@@ -61,15 +96,32 @@ export const useGridColumnHeaders = props => {
61
96
  return;
62
97
  }
63
98
 
64
- prevScrollLeft.current = left;
99
+ prevScrollLeft.current = left; // We can only update the position when we guarantee that the render context has been
100
+ // rendered. This is achieved using ReactDOM.flushSync or when the context doesn't change.
101
+
102
+ let canUpdateInnerPosition = false;
65
103
 
66
104
  if (nextRenderContext !== prevRenderContext.current || !prevRenderContext.current) {
67
- setRenderContext(nextRenderContext);
105
+ // ReactDOM.flushSync cannot be called on `scroll` events fired inside effects
106
+ if (isUIEvent(event)) {
107
+ // To prevent flickering, the inner position can only be updated after the new context has
108
+ // been rendered. ReactDOM.flushSync ensures that the state changes will happen before
109
+ // updating the position.
110
+ ReactDOM.flushSync(() => {
111
+ setRenderContext(nextRenderContext);
112
+ });
113
+ canUpdateInnerPosition = true;
114
+ } else {
115
+ setRenderContext(nextRenderContext);
116
+ }
117
+
68
118
  prevRenderContext.current = nextRenderContext;
119
+ } else {
120
+ canUpdateInnerPosition = true;
69
121
  } // Pass directly the render context to avoid waiting for the next render
70
122
 
71
123
 
72
- if (nextRenderContext) {
124
+ if (nextRenderContext && canUpdateInnerPosition) {
73
125
  updateInnerPosition(nextRenderContext);
74
126
  }
75
127
  }, [updateInnerPosition]);
@@ -95,7 +147,22 @@ export const useGridColumnHeaders = props => {
95
147
  }
96
148
 
97
149
  const columns = [];
98
- const firstColumnToRender = Math.max(nextRenderContext.firstColumnIndex - rootProps.columnBuffer, minFirstColumn);
150
+ const [firstRowToRender, lastRowToRender] = getRenderableIndexes({
151
+ firstIndex: nextRenderContext.firstRowIndex,
152
+ lastIndex: nextRenderContext.lastRowIndex,
153
+ minFirstIndex: 0,
154
+ maxLastIndex: currentPage.rows.length,
155
+ buffer: rootProps.rowBuffer
156
+ });
157
+ const firstColumnToRender = getFirstColumnIndexToRenderRef.current({
158
+ firstColumnIndex: nextRenderContext.firstColumnIndex,
159
+ minColumnIndex: minFirstColumn,
160
+ columnBuffer: rootProps.columnBuffer,
161
+ apiRef,
162
+ firstRowToRender,
163
+ lastRowToRender,
164
+ visibleRows: currentPage.rows
165
+ });
99
166
  const lastColumnToRender = Math.min(nextRenderContext.lastColumnIndex + rootProps.columnBuffer, maxLastColumn);
100
167
  const renderedColumns = visibleColumns.slice(firstColumnToRender, lastColumnToRender);
101
168
 
@@ -119,7 +186,7 @@ export const useGridColumnHeaders = props => {
119
186
  extendRowFullWidth: !rootProps.disableExtendRowFullWidth,
120
187
  hasFocus: hasFocus,
121
188
  tabIndex: tabIndex
122
- }, other), i));
189
+ }, other), column.field));
123
190
  }
124
191
 
125
192
  return columns;
@@ -134,7 +201,6 @@ export const useGridColumnHeaders = props => {
134
201
  renderContext,
135
202
  getColumns,
136
203
  isDragging: !!dragCol,
137
- updateInnerPosition,
138
204
  getRootProps: (other = {}) => _extends({
139
205
  style: rootStyle
140
206
  }, other),
@@ -15,7 +15,9 @@ export interface GridColumnsState {
15
15
  lookup: GridColumnLookup;
16
16
  columnVisibilityModel: GridColumnVisibilityModel;
17
17
  }
18
- export declare type GridColumnDimensions = Pick<GridStateColDef, GridColumnDimensionProperties>;
18
+ export declare type GridColumnDimensions = {
19
+ [key in GridColumnDimensionProperties]?: number;
20
+ };
19
21
  export interface GridColumnsInitialState {
20
22
  columnVisibilityModel?: GridColumnVisibilityModel;
21
23
  orderedFields?: string[];
@@ -4,6 +4,8 @@ import { GridColType, GridColumnTypesRecord } from '../../../models';
4
4
  import { GridStateCommunity } from '../../../models/gridStateCommunity';
5
5
  import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
6
6
  import { GridColDef } from '../../../models/colDef/gridColDef';
7
+ import { GridApiCommon } from '../../../models/api/gridApiCommon';
8
+ import { GridRowEntry } from '../../../models/gridRows';
7
9
  export declare const COLUMNS_DIMENSION_PROPERTIES: readonly ["maxWidth", "minWidth", "width", "flex"];
8
10
  export declare type GridColumnDimensionProperties = typeof COLUMNS_DIMENSION_PROPERTIES[number];
9
11
  export declare const computeColumnTypes: (customColumnTypes?: GridColumnTypesRecord) => GridColumnTypesRecord;
@@ -17,7 +19,7 @@ export declare function computeFlexColumnsWidth({ initialFreeSpace, totalFlexUni
17
19
  totalFlexUnits: number;
18
20
  flexColumns: {
19
21
  field: GridColDef['field'];
20
- flex?: number;
22
+ flex?: number | null;
21
23
  minWidth?: number;
22
24
  maxWidth?: number;
23
25
  }[];
@@ -52,3 +54,19 @@ export declare const createColumnsState: ({ apiRef, columnsToUpsert, initialStat
52
54
  apiRef: React.MutableRefObject<GridApiCommunity>;
53
55
  }) => GridColumnsState;
54
56
  export declare const mergeColumnsState: (columnsState: GridColumnsState) => (state: GridStateCommunity) => GridStateCommunity;
57
+ export declare function getFirstNonSpannedColumnToRender({ firstColumnToRender, apiRef, firstRowToRender, lastRowToRender, visibleRows, }: {
58
+ firstColumnToRender: number;
59
+ apiRef: React.MutableRefObject<GridApiCommon>;
60
+ firstRowToRender: number;
61
+ lastRowToRender: number;
62
+ visibleRows: GridRowEntry[];
63
+ }): number;
64
+ export declare function getFirstColumnIndexToRender({ firstColumnIndex, minColumnIndex, columnBuffer, firstRowToRender, lastRowToRender, apiRef, visibleRows, }: {
65
+ firstColumnIndex: number;
66
+ minColumnIndex: number;
67
+ columnBuffer: number;
68
+ apiRef: React.MutableRefObject<GridApiCommon>;
69
+ firstRowToRender: number;
70
+ lastRowToRender: number;
71
+ visibleRows: GridRowEntry[];
72
+ }): number;
@@ -206,9 +206,15 @@ export const applyInitialState = (columnsState, initialState) => {
206
206
 
207
207
  for (let i = 0; i < columnsWithUpdatedDimensions.length; i += 1) {
208
208
  const field = columnsWithUpdatedDimensions[i];
209
- newColumnLookup[field] = _extends({}, newColumnLookup[field], dimensions[field], {
209
+
210
+ const newColDef = _extends({}, newColumnLookup[field], {
210
211
  hasBeenResized: true
211
212
  });
213
+
214
+ Object.entries(dimensions[field]).forEach(([key, value]) => {
215
+ newColDef[key] = value === -1 ? Infinity : value;
216
+ });
217
+ newColumnLookup[field] = newColDef;
212
218
  }
213
219
 
214
220
  const newColumnsState = {
@@ -296,16 +302,20 @@ export const createColumnsState = ({
296
302
  columnsStateWithoutColumnVisibilityModel.all.push(field);
297
303
  }
298
304
 
299
- let hasValidDimension = false;
300
-
301
- if (!existingState.hasBeenResized) {
302
- hasValidDimension = COLUMNS_DIMENSION_PROPERTIES.some(key => newColumn[key] !== undefined);
303
- }
305
+ let hasBeenResized = existingState.hasBeenResized;
306
+ COLUMNS_DIMENSION_PROPERTIES.forEach(key => {
307
+ if (newColumn[key] !== undefined) {
308
+ hasBeenResized = true;
304
309
 
310
+ if (newColumn[key] === -1) {
311
+ newColumn[key] = Infinity;
312
+ }
313
+ }
314
+ });
305
315
  columnsStateWithoutColumnVisibilityModel.lookup[field] = _extends({}, existingState, {
306
316
  hide: newColumn.hide == null ? false : newColumn.hide
307
317
  }, newColumn, {
308
- hasBeenResized: existingState.hasBeenResized || hasValidDimension
318
+ hasBeenResized
309
319
  });
310
320
  });
311
321
 
@@ -394,4 +404,47 @@ export const createColumnsState = ({
394
404
  };
395
405
  export const mergeColumnsState = columnsState => state => _extends({}, state, {
396
406
  columns: columnsState
397
- });
407
+ });
408
+ export function getFirstNonSpannedColumnToRender({
409
+ firstColumnToRender,
410
+ apiRef,
411
+ firstRowToRender,
412
+ lastRowToRender,
413
+ visibleRows
414
+ }) {
415
+ let firstNonSpannedColumnToRender = firstColumnToRender;
416
+
417
+ for (let i = firstRowToRender; i < lastRowToRender; i += 1) {
418
+ const row = visibleRows[i];
419
+
420
+ if (row) {
421
+ const rowId = visibleRows[i].id;
422
+ const cellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, firstColumnToRender);
423
+
424
+ if (cellColSpanInfo && cellColSpanInfo.spannedByColSpan) {
425
+ firstNonSpannedColumnToRender = cellColSpanInfo.leftVisibleCellIndex;
426
+ }
427
+ }
428
+ }
429
+
430
+ return firstNonSpannedColumnToRender;
431
+ }
432
+ export function getFirstColumnIndexToRender({
433
+ firstColumnIndex,
434
+ minColumnIndex,
435
+ columnBuffer,
436
+ firstRowToRender,
437
+ lastRowToRender,
438
+ apiRef,
439
+ visibleRows
440
+ }) {
441
+ const initialFirstColumnToRender = Math.max(firstColumnIndex - columnBuffer, minColumnIndex);
442
+ const firstColumnToRender = getFirstNonSpannedColumnToRender({
443
+ firstColumnToRender: initialFirstColumnToRender,
444
+ apiRef,
445
+ firstRowToRender,
446
+ lastRowToRender,
447
+ visibleRows
448
+ });
449
+ return firstColumnToRender;
450
+ }
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
3
+ /**
4
+ * @requires useGridColumns (method, event)
5
+ * @requires useGridParamsApi (method)
6
+ */
7
+ export declare const useGridColumnSpanning: (apiRef: React.MutableRefObject<GridApiCommunity>) => void;