@mui/x-data-grid 7.17.0 → 7.19.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 (203) hide show
  1. package/CHANGELOG.md +208 -5
  2. package/DataGrid/DataGrid.js +16 -1
  3. package/DataGrid/useDataGridComponent.js +3 -0
  4. package/DataGrid/useDataGridProps.js +2 -1
  5. package/components/GridRow.js +1 -0
  6. package/components/cell/GridCell.js +33 -9
  7. package/components/columnHeaders/GridBaseColumnHeaders.js +1 -1
  8. package/components/columnSelection/GridCellCheckboxRenderer.js +12 -4
  9. package/components/columnSelection/GridHeaderCheckbox.d.ts +1 -1
  10. package/components/containers/GridRoot.js +1 -1
  11. package/components/containers/GridRootStyles.js +32 -23
  12. package/components/containers/GridToolbarContainer.js +1 -1
  13. package/components/menu/GridMenu.js +1 -1
  14. package/components/panel/GridPanel.d.ts +1 -1
  15. package/components/panel/GridPanel.js +1 -1
  16. package/components/panel/GridPanelContent.js +1 -1
  17. package/components/panel/GridPanelFooter.js +1 -1
  18. package/components/panel/GridPanelHeader.js +1 -1
  19. package/components/panel/GridPanelWrapper.js +1 -1
  20. package/components/panel/filterPanel/filterPanelUtils.d.ts +1 -1
  21. package/components/toolbar/GridToolbarQuickFilter.js +1 -1
  22. package/components/virtualization/GridBottomContainer.d.ts +1 -1
  23. package/components/virtualization/GridBottomContainer.js +18 -1
  24. package/components/virtualization/GridMainContainer.js +3 -1
  25. package/components/virtualization/GridTopContainer.d.ts +1 -1
  26. package/components/virtualization/GridTopContainer.js +1 -1
  27. package/components/virtualization/GridVirtualScrollbar.js +1 -7
  28. package/components/virtualization/GridVirtualScroller.js +1 -0
  29. package/components/virtualization/GridVirtualScrollerFiller.js +3 -4
  30. package/hooks/features/columnGrouping/gridColumnGroupsSelector.d.ts +4 -4
  31. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -2
  32. package/hooks/features/columnHeaders/useGridColumnHeaders.js +11 -11
  33. package/hooks/features/columnResize/columnResizeSelector.d.ts +1 -1
  34. package/hooks/features/columnResize/useGridColumnResize.js +6 -6
  35. package/hooks/features/columns/gridColumnsSelector.d.ts +12 -12
  36. package/hooks/features/columns/gridColumnsUtils.js +3 -2
  37. package/hooks/features/density/densitySelector.d.ts +1 -1
  38. package/hooks/features/dimensions/gridDimensionsApi.d.ts +4 -0
  39. package/hooks/features/dimensions/useGridDimensions.d.ts +1 -1
  40. package/hooks/features/dimensions/useGridDimensions.js +4 -1
  41. package/hooks/features/editing/useGridCellEditing.js +3 -19
  42. package/hooks/features/editing/useGridRowEditing.js +7 -2
  43. package/hooks/features/editing/utils.d.ts +2 -0
  44. package/hooks/features/editing/utils.js +15 -0
  45. package/hooks/features/export/useGridPrintExport.js +2 -1
  46. package/hooks/features/filter/gridFilterSelector.d.ts +17 -17
  47. package/hooks/features/focus/gridFocusStateSelector.d.ts +8 -8
  48. package/hooks/features/focus/useGridFocus.js +2 -1
  49. package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.d.ts +3 -3
  50. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +10 -46
  51. package/hooks/features/keyboardNavigation/utils.d.ts +17 -0
  52. package/hooks/features/keyboardNavigation/utils.js +58 -0
  53. package/hooks/features/pagination/gridPaginationSelector.d.ts +9 -9
  54. package/hooks/features/rowSelection/gridRowSelectionSelector.d.ts +3 -3
  55. package/hooks/features/rowSelection/useGridRowSelection.d.ts +1 -1
  56. package/hooks/features/rowSelection/useGridRowSelection.js +105 -29
  57. package/hooks/features/rowSelection/utils.d.ts +10 -0
  58. package/hooks/features/rowSelection/utils.js +156 -1
  59. package/hooks/features/rows/gridRowSpanningSelectors.d.ts +4 -0
  60. package/hooks/features/rows/gridRowSpanningSelectors.js +5 -0
  61. package/hooks/features/rows/gridRowSpanningUtils.d.ts +10 -0
  62. package/hooks/features/rows/gridRowSpanningUtils.js +42 -0
  63. package/hooks/features/rows/gridRowsSelector.d.ts +14 -14
  64. package/hooks/features/rows/useGridRowSpanning.d.ts +27 -0
  65. package/hooks/features/rows/useGridRowSpanning.js +257 -0
  66. package/hooks/features/rows/useGridRows.d.ts +1 -1
  67. package/hooks/features/rows/useGridRows.js +7 -1
  68. package/hooks/features/scroll/useGridScroll.js +19 -19
  69. package/hooks/features/sorting/gridSortingSelector.d.ts +4 -4
  70. package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +5 -5
  71. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
  72. package/hooks/features/virtualization/useGridVirtualScroller.js +17 -7
  73. package/hooks/utils/useGridApiEventHandler.js +0 -1
  74. package/hooks/utils/useGridVisibleRows.d.ts +2 -2
  75. package/index.js +1 -1
  76. package/internals/index.d.ts +2 -0
  77. package/internals/index.js +2 -0
  78. package/locales/bgBG.js +8 -9
  79. package/locales/deDE.js +4 -4
  80. package/locales/frFR.js +4 -4
  81. package/locales/hrHR.d.ts +1 -1
  82. package/locales/hrHR.js +69 -46
  83. package/locales/jaJP.js +1 -2
  84. package/locales/ptPT.d.ts +1 -1
  85. package/locales/ptPT.js +4 -4
  86. package/locales/viVN.js +20 -20
  87. package/locales/zhHK.d.ts +1 -1
  88. package/models/colDef/gridColDef.d.ts +4 -0
  89. package/models/gridRowSelectionModel.d.ts +4 -0
  90. package/models/gridStateCommunity.d.ts +2 -0
  91. package/models/props/DataGridProps.d.ts +30 -1
  92. package/modern/DataGrid/DataGrid.js +16 -1
  93. package/modern/DataGrid/useDataGridComponent.js +3 -0
  94. package/modern/DataGrid/useDataGridProps.js +2 -1
  95. package/modern/components/GridRow.js +1 -0
  96. package/modern/components/cell/GridCell.js +33 -9
  97. package/modern/components/columnHeaders/GridBaseColumnHeaders.js +1 -1
  98. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +12 -4
  99. package/modern/components/containers/GridRoot.js +1 -1
  100. package/modern/components/containers/GridRootStyles.js +32 -23
  101. package/modern/components/containers/GridToolbarContainer.js +1 -1
  102. package/modern/components/menu/GridMenu.js +1 -1
  103. package/modern/components/panel/GridPanel.js +1 -1
  104. package/modern/components/panel/GridPanelContent.js +1 -1
  105. package/modern/components/panel/GridPanelFooter.js +1 -1
  106. package/modern/components/panel/GridPanelHeader.js +1 -1
  107. package/modern/components/panel/GridPanelWrapper.js +1 -1
  108. package/modern/components/toolbar/GridToolbarQuickFilter.js +1 -1
  109. package/modern/components/virtualization/GridBottomContainer.js +18 -1
  110. package/modern/components/virtualization/GridMainContainer.js +3 -1
  111. package/modern/components/virtualization/GridTopContainer.js +1 -1
  112. package/modern/components/virtualization/GridVirtualScrollbar.js +1 -7
  113. package/modern/components/virtualization/GridVirtualScroller.js +1 -0
  114. package/modern/components/virtualization/GridVirtualScrollerFiller.js +3 -4
  115. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +11 -11
  116. package/modern/hooks/features/columnResize/useGridColumnResize.js +6 -6
  117. package/modern/hooks/features/columns/gridColumnsUtils.js +3 -2
  118. package/modern/hooks/features/dimensions/useGridDimensions.js +4 -1
  119. package/modern/hooks/features/editing/useGridCellEditing.js +3 -19
  120. package/modern/hooks/features/editing/useGridRowEditing.js +7 -2
  121. package/modern/hooks/features/editing/utils.js +15 -0
  122. package/modern/hooks/features/export/useGridPrintExport.js +2 -1
  123. package/modern/hooks/features/focus/useGridFocus.js +2 -1
  124. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +10 -46
  125. package/modern/hooks/features/keyboardNavigation/utils.js +58 -0
  126. package/modern/hooks/features/rowSelection/useGridRowSelection.js +105 -29
  127. package/modern/hooks/features/rowSelection/utils.js +156 -1
  128. package/modern/hooks/features/rows/gridRowSpanningSelectors.js +5 -0
  129. package/modern/hooks/features/rows/gridRowSpanningUtils.js +42 -0
  130. package/modern/hooks/features/rows/useGridRowSpanning.js +257 -0
  131. package/modern/hooks/features/rows/useGridRows.js +7 -1
  132. package/modern/hooks/features/scroll/useGridScroll.js +19 -19
  133. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +17 -7
  134. package/modern/hooks/utils/useGridApiEventHandler.js +0 -1
  135. package/modern/index.js +1 -1
  136. package/modern/internals/index.js +2 -0
  137. package/modern/locales/bgBG.js +8 -9
  138. package/modern/locales/deDE.js +4 -4
  139. package/modern/locales/frFR.js +4 -4
  140. package/modern/locales/hrHR.js +69 -46
  141. package/modern/locales/jaJP.js +1 -2
  142. package/modern/locales/ptPT.js +4 -4
  143. package/modern/locales/viVN.js +20 -20
  144. package/modern/utils/createSelector.js +6 -0
  145. package/modern/utils/domUtils.js +12 -12
  146. package/node/DataGrid/DataGrid.js +16 -1
  147. package/node/DataGrid/useDataGridComponent.js +3 -0
  148. package/node/DataGrid/useDataGridProps.js +2 -1
  149. package/node/components/GridRow.js +1 -0
  150. package/node/components/cell/GridCell.js +33 -9
  151. package/node/components/columnHeaders/GridBaseColumnHeaders.js +1 -1
  152. package/node/components/columnSelection/GridCellCheckboxRenderer.js +12 -4
  153. package/node/components/containers/GridRoot.js +1 -1
  154. package/node/components/containers/GridRootStyles.js +32 -23
  155. package/node/components/containers/GridToolbarContainer.js +1 -1
  156. package/node/components/menu/GridMenu.js +1 -1
  157. package/node/components/panel/GridPanel.js +1 -1
  158. package/node/components/panel/GridPanelContent.js +1 -1
  159. package/node/components/panel/GridPanelFooter.js +1 -1
  160. package/node/components/panel/GridPanelHeader.js +1 -1
  161. package/node/components/panel/GridPanelWrapper.js +1 -1
  162. package/node/components/toolbar/GridToolbarQuickFilter.js +1 -1
  163. package/node/components/virtualization/GridBottomContainer.js +18 -1
  164. package/node/components/virtualization/GridMainContainer.js +3 -1
  165. package/node/components/virtualization/GridTopContainer.js +1 -1
  166. package/node/components/virtualization/GridVirtualScrollbar.js +1 -7
  167. package/node/components/virtualization/GridVirtualScroller.js +1 -0
  168. package/node/components/virtualization/GridVirtualScrollerFiller.js +3 -4
  169. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +11 -11
  170. package/node/hooks/features/columnResize/useGridColumnResize.js +6 -6
  171. package/node/hooks/features/columns/gridColumnsUtils.js +3 -2
  172. package/node/hooks/features/dimensions/useGridDimensions.js +4 -1
  173. package/node/hooks/features/editing/useGridCellEditing.js +3 -19
  174. package/node/hooks/features/editing/useGridRowEditing.js +7 -2
  175. package/node/hooks/features/editing/utils.js +22 -0
  176. package/node/hooks/features/export/useGridPrintExport.js +2 -1
  177. package/node/hooks/features/focus/useGridFocus.js +2 -1
  178. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +16 -53
  179. package/node/hooks/features/keyboardNavigation/utils.js +68 -0
  180. package/node/hooks/features/rowSelection/useGridRowSelection.js +102 -26
  181. package/node/hooks/features/rowSelection/utils.js +160 -1
  182. package/node/hooks/features/rows/gridRowSpanningSelectors.js +11 -0
  183. package/node/hooks/features/rows/gridRowSpanningUtils.js +52 -0
  184. package/node/hooks/features/rows/useGridRowSpanning.js +267 -0
  185. package/node/hooks/features/rows/useGridRows.js +7 -1
  186. package/node/hooks/features/scroll/useGridScroll.js +19 -19
  187. package/node/hooks/features/virtualization/useGridVirtualScroller.js +17 -7
  188. package/node/hooks/utils/useGridApiEventHandler.js +0 -1
  189. package/node/index.js +1 -1
  190. package/node/internals/index.js +38 -15
  191. package/node/locales/bgBG.js +8 -9
  192. package/node/locales/deDE.js +4 -4
  193. package/node/locales/frFR.js +4 -4
  194. package/node/locales/hrHR.js +69 -46
  195. package/node/locales/jaJP.js +1 -2
  196. package/node/locales/ptPT.js +4 -4
  197. package/node/locales/viVN.js +20 -20
  198. package/node/utils/createSelector.js +6 -0
  199. package/node/utils/domUtils.js +12 -12
  200. package/package.json +3 -3
  201. package/utils/createSelector.js +6 -0
  202. package/utils/domUtils.d.ts +4 -4
  203. package/utils/domUtils.js +12 -12
@@ -0,0 +1,15 @@
1
+ export const getDefaultCellValue = colDef => {
2
+ switch (colDef.type) {
3
+ case 'boolean':
4
+ return false;
5
+ case 'date':
6
+ case 'dateTime':
7
+ case 'number':
8
+ return undefined;
9
+ case 'singleSelect':
10
+ return null;
11
+ case 'string':
12
+ default:
13
+ return '';
14
+ }
15
+ };
@@ -38,6 +38,7 @@ function buildPrintWindow(title) {
38
38
  * @requires useGridParamsApi (method)
39
39
  */
40
40
  export const useGridPrintExport = (apiRef, props) => {
41
+ const hasRootReference = apiRef.current.rootElementRef.current !== null;
41
42
  const logger = useGridLogger(apiRef, 'useGridPrintExport');
42
43
  const doc = React.useRef(null);
43
44
  const previousGridState = React.useRef(null);
@@ -46,7 +47,7 @@ export const useGridPrintExport = (apiRef, props) => {
46
47
  const previousVirtualizationState = React.useRef();
47
48
  React.useEffect(() => {
48
49
  doc.current = ownerDocument(apiRef.current.rootElementRef.current);
49
- }, [apiRef]);
50
+ }, [apiRef, hasRootReference]);
50
51
 
51
52
  // Returns a promise because updateColumns triggers state update and
52
53
  // the new state needs to be in place before the grid can be sized correctly
@@ -5,12 +5,12 @@ import { GridStateCommunity } from '../../../models/gridStateCommunity';
5
5
  * Get the current filter model.
6
6
  * @category Filtering
7
7
  */
8
- export declare const gridFilterModelSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridFilterModel>;
8
+ export declare const gridFilterModelSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridFilterModel>;
9
9
  /**
10
10
  * Get the current quick filter values.
11
11
  * @category Filtering
12
12
  */
13
- export declare const gridQuickFilterValuesSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, any[] | undefined>;
13
+ export declare const gridQuickFilterValuesSelector: import("../../..").OutputSelector<GridStateCommunity, any[] | undefined>;
14
14
  /**
15
15
  * @category Visible rows
16
16
  * @ignore - do not document.
@@ -20,79 +20,79 @@ export declare const gridVisibleRowsLookupSelector: (state: GridStateCommunity)
20
20
  * @category Filtering
21
21
  * @ignore - do not document.
22
22
  */
23
- export declare const gridFilteredRowsLookupSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Record<GridRowId, boolean>>;
23
+ export declare const gridFilteredRowsLookupSelector: import("../../..").OutputSelector<GridStateCommunity, Record<GridRowId, boolean>>;
24
24
  /**
25
25
  * @category Filtering
26
26
  * @ignore - do not document.
27
27
  */
28
- export declare const gridFilteredChildrenCountLookupSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Record<GridRowId, number>>;
28
+ export declare const gridFilteredChildrenCountLookupSelector: import("../../..").OutputSelector<GridStateCommunity, Record<GridRowId, number>>;
29
29
  /**
30
30
  * @category Filtering
31
31
  * @ignore - do not document.
32
32
  */
33
- export declare const gridFilteredDescendantCountLookupSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Record<GridRowId, number>>;
33
+ export declare const gridFilteredDescendantCountLookupSelector: import("../../..").OutputSelector<GridStateCommunity, Record<GridRowId, number>>;
34
34
  /**
35
35
  * Get the id and the model of the rows accessible after the filtering process.
36
36
  * Does not contain the collapsed children.
37
37
  * @category Filtering
38
38
  */
39
- export declare const gridExpandedSortedRowEntriesSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../../models/gridRows").GridRowEntry<import("../../../models/gridRows").GridValidRowModel>[]>;
39
+ export declare const gridExpandedSortedRowEntriesSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridRowEntry<import("../../..").GridValidRowModel>[]>;
40
40
  /**
41
41
  * Get the id of the rows accessible after the filtering process.
42
42
  * Does not contain the collapsed children.
43
43
  * @category Filtering
44
44
  */
45
- export declare const gridExpandedSortedRowIdsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, GridRowId[]>;
45
+ export declare const gridExpandedSortedRowIdsSelector: import("../../..").OutputSelector<GridStateCommunity, GridRowId[]>;
46
46
  /**
47
47
  * Get the id and the model of the rows accessible after the filtering process.
48
48
  * Contains the collapsed children.
49
49
  * @category Filtering
50
50
  */
51
- export declare const gridFilteredSortedRowEntriesSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../../models/gridRows").GridRowEntry<import("../../../models/gridRows").GridValidRowModel>[]>;
51
+ export declare const gridFilteredSortedRowEntriesSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridRowEntry<import("../../..").GridValidRowModel>[]>;
52
52
  /**
53
53
  * Get the id of the rows accessible after the filtering process.
54
54
  * Contains the collapsed children.
55
55
  * @category Filtering
56
56
  */
57
- export declare const gridFilteredSortedRowIdsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, GridRowId[]>;
57
+ export declare const gridFilteredSortedRowIdsSelector: import("../../..").OutputSelector<GridStateCommunity, GridRowId[]>;
58
58
  /**
59
59
  * Get the ids to position in the current tree level lookup of the rows accessible after the filtering process.
60
60
  * Does not contain the collapsed children.
61
61
  * @category Filtering
62
62
  * @ignore - do not document.
63
63
  */
64
- export declare const gridExpandedSortedRowTreeLevelPositionLookupSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Record<GridRowId, number>>;
64
+ export declare const gridExpandedSortedRowTreeLevelPositionLookupSelector: import("../../..").OutputSelector<GridStateCommunity, Record<GridRowId, number>>;
65
65
  /**
66
66
  * Get the id and the model of the top level rows accessible after the filtering process.
67
67
  * @category Filtering
68
68
  */
69
- export declare const gridFilteredSortedTopLevelRowEntriesSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../../models/gridRows").GridRowEntry<import("../../../models/gridRows").GridValidRowModel>[]>;
69
+ export declare const gridFilteredSortedTopLevelRowEntriesSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridRowEntry<import("../../..").GridValidRowModel>[]>;
70
70
  /**
71
71
  * Get the amount of rows accessible after the filtering process.
72
72
  * @category Filtering
73
73
  */
74
- export declare const gridExpandedRowCountSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
74
+ export declare const gridExpandedRowCountSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
75
75
  /**
76
76
  * Get the amount of top level rows accessible after the filtering process.
77
77
  * @category Filtering
78
78
  */
79
- export declare const gridFilteredTopLevelRowCountSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
79
+ export declare const gridFilteredTopLevelRowCountSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
80
80
  /**
81
81
  * Get the amount of rows accessible after the filtering process.
82
82
  * Includes top level and descendant rows.
83
83
  * @category Filtering
84
84
  */
85
- export declare const gridFilteredRowCountSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
85
+ export declare const gridFilteredRowCountSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
86
86
  /**
87
87
  * Get the amount of descendant rows accessible after the filtering process.
88
88
  * @category Filtering
89
89
  */
90
- export declare const gridFilteredDescendantRowCountSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
90
+ export declare const gridFilteredDescendantRowCountSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
91
91
  /**
92
92
  * @category Filtering
93
93
  * @ignore - do not document.
94
94
  */
95
- export declare const gridFilterActiveItemsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, GridFilterItem[]>;
95
+ export declare const gridFilterActiveItemsSelector: import("../../..").OutputSelector<GridStateCommunity, GridFilterItem[]>;
96
96
  export type GridFilterActiveItemsLookup = {
97
97
  [field: string]: GridFilterItem[];
98
98
  };
@@ -100,4 +100,4 @@ export type GridFilterActiveItemsLookup = {
100
100
  * @category Filtering
101
101
  * @ignore - do not document.
102
102
  */
103
- export declare const gridFilterActiveItemsLookupSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, GridFilterActiveItemsLookup>;
103
+ export declare const gridFilterActiveItemsLookupSelector: import("../../..").OutputSelector<GridStateCommunity, GridFilterActiveItemsLookup>;
@@ -1,12 +1,12 @@
1
1
  import { GridStateCommunity } from '../../../models/gridStateCommunity';
2
2
  import { GridFocusState, GridTabIndexState } from './gridFocusState';
3
3
  export declare const gridFocusStateSelector: (state: GridStateCommunity) => GridFocusState;
4
- export declare const gridFocusCellSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridCellCoordinates | null>;
5
- export declare const gridFocusColumnHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
6
- export declare const gridFocusColumnHeaderFilterSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
7
- export declare const gridFocusColumnGroupHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnGroupIdentifier | null>;
4
+ export declare const gridFocusCellSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridCellCoordinates | null>;
5
+ export declare const gridFocusColumnHeaderSelector: import("../../..").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
6
+ export declare const gridFocusColumnHeaderFilterSelector: import("../../..").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
7
+ export declare const gridFocusColumnGroupHeaderSelector: import("../../..").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnGroupIdentifier | null>;
8
8
  export declare const gridTabIndexStateSelector: (state: GridStateCommunity) => GridTabIndexState;
9
- export declare const gridTabIndexCellSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridCellCoordinates | null>;
10
- export declare const gridTabIndexColumnHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
11
- export declare const gridTabIndexColumnHeaderFilterSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
12
- export declare const gridTabIndexColumnGroupHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnGroupIdentifier | null>;
9
+ export declare const gridTabIndexCellSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridCellCoordinates | null>;
10
+ export declare const gridTabIndexColumnHeaderSelector: import("../../..").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
11
+ export declare const gridTabIndexColumnHeaderFilterSelector: import("../../..").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
12
+ export declare const gridTabIndexColumnGroupHeaderSelector: import("../../..").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnGroupIdentifier | null>;
@@ -34,6 +34,7 @@ export const focusStateInitializer = state => _extends({}, state, {
34
34
  export const useGridFocus = (apiRef, props) => {
35
35
  const logger = useGridLogger(apiRef, 'useGridFocus');
36
36
  const lastClickedCell = React.useRef(null);
37
+ const hasRootReference = apiRef.current.rootElementRef.current !== null;
37
38
  const publishCellFocusOut = React.useCallback((cell, event) => {
38
39
  if (cell) {
39
40
  // The row might have been deleted
@@ -380,7 +381,7 @@ export const useGridFocus = (apiRef, props) => {
380
381
  return () => {
381
382
  doc.removeEventListener('mouseup', handleDocumentClick);
382
383
  };
383
- }, [apiRef, handleDocumentClick]);
384
+ }, [apiRef, hasRootReference, handleDocumentClick]);
384
385
  useGridApiEventHandler(apiRef, 'columnHeaderBlur', handleBlur);
385
386
  useGridApiEventHandler(apiRef, 'cellDoubleClick', handleCellDoubleClick);
386
387
  useGridApiEventHandler(apiRef, 'cellMouseDown', handleCellMouseDown);
@@ -1,5 +1,5 @@
1
1
  import { GridStateCommunity } from '../../../models/gridStateCommunity';
2
2
  export declare const gridHeaderFilteringStateSelector: (state: GridStateCommunity) => import("../../../models/gridHeaderFilteringModel").GridHeaderFilteringState;
3
- export declare const gridHeaderFilteringEnabledSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, boolean>;
4
- export declare const gridHeaderFilteringEditFieldSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, string | null>;
5
- export declare const gridHeaderFilteringMenuSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, string | null>;
3
+ export declare const gridHeaderFilteringEnabledSelector: import("../../..").OutputSelector<GridStateCommunity, boolean>;
4
+ export declare const gridHeaderFilteringEditFieldSelector: import("../../..").OutputSelector<GridStateCommunity, string | null>;
5
+ export declare const gridHeaderFilteringMenuSelector: import("../../..").OutputSelector<GridStateCommunity, string | null>;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { useRtl } from '@mui/system/RtlProvider';
3
- import { gridVisibleColumnDefinitionsSelector } from "../columns/gridColumnsSelector.js";
3
+ import { gridVisibleColumnDefinitionsSelector, gridVisibleColumnFieldsSelector } from "../columns/gridColumnsSelector.js";
4
4
  import { useGridLogger } from "../../utils/useGridLogger.js";
5
5
  import { useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
6
6
  import { gridExpandedSortedRowEntriesSelector } from "../filter/gridFilterSelector.js";
@@ -10,50 +10,12 @@ import { gridClasses } from "../../../constants/gridClasses.js";
10
10
  import { GridCellModes } from "../../../models/gridEditRowModel.js";
11
11
  import { isNavigationKey } from "../../../utils/keyboardUtils.js";
12
12
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../constants/gridDetailPanelToggleField.js";
13
- import { gridPinnedRowsSelector } from "../rows/gridRowsSelector.js";
14
13
  import { gridFocusColumnGroupHeaderSelector } from "../focus/index.js";
15
14
  import { gridColumnGroupsHeaderMaxDepthSelector } from "../columnGrouping/gridColumnGroupsSelector.js";
16
15
  import { gridHeaderFilteringEditFieldSelector, gridHeaderFilteringMenuSelector } from "../headerFiltering/gridHeaderFilteringSelectors.js";
17
16
  import { useGridRegisterPipeProcessor } from "../../core/pipeProcessing/index.js";
18
17
  import { isEventTargetInPortal } from "../../../utils/domUtils.js";
19
- function enrichPageRowsWithPinnedRows(apiRef, rows) {
20
- const pinnedRows = gridPinnedRowsSelector(apiRef) || {};
21
- return [...(pinnedRows.top || []), ...rows, ...(pinnedRows.bottom || [])];
22
- }
23
- const getLeftColumnIndex = ({
24
- currentColIndex,
25
- firstColIndex,
26
- lastColIndex,
27
- isRtl
28
- }) => {
29
- if (isRtl) {
30
- if (currentColIndex < lastColIndex) {
31
- return currentColIndex + 1;
32
- }
33
- } else if (!isRtl) {
34
- if (currentColIndex > firstColIndex) {
35
- return currentColIndex - 1;
36
- }
37
- }
38
- return null;
39
- };
40
- const getRightColumnIndex = ({
41
- currentColIndex,
42
- firstColIndex,
43
- lastColIndex,
44
- isRtl
45
- }) => {
46
- if (isRtl) {
47
- if (currentColIndex > firstColIndex) {
48
- return currentColIndex - 1;
49
- }
50
- } else if (!isRtl) {
51
- if (currentColIndex < lastColIndex) {
52
- return currentColIndex + 1;
53
- }
54
- }
55
- return null;
56
- };
18
+ import { enrichPageRowsWithPinnedRows, getLeftColumnIndex, getRightColumnIndex, findNonRowSpannedCell } from "./utils.js";
57
19
 
58
20
  /**
59
21
  * @requires useGridSorting (method) - can be after
@@ -73,11 +35,12 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
73
35
 
74
36
  /**
75
37
  * @param {number} colIndex Index of the column to focus
76
- * @param {number} rowIndex index of the row to focus
38
+ * @param {GridRowId} rowId index of the row to focus
77
39
  * @param {string} closestColumnToUse Which closest column cell to use when the cell is spanned by `colSpan`.
40
+ * @param {string} rowSpanScanDirection Which direction to search to find the next cell not hidden by `rowSpan`.
78
41
  * TODO replace with apiRef.current.moveFocusToRelativeCell()
79
42
  */
80
- const goToCell = React.useCallback((colIndex, rowId, closestColumnToUse = 'left') => {
43
+ const goToCell = React.useCallback((colIndex, rowId, closestColumnToUse = 'left', rowSpanScanDirection = 'up') => {
81
44
  const visibleSortedRows = gridExpandedSortedRowEntriesSelector(apiRef);
82
45
  const nextCellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, colIndex);
83
46
  if (nextCellColSpanInfo && nextCellColSpanInfo.spannedByColSpan) {
@@ -87,16 +50,17 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
87
50
  colIndex = nextCellColSpanInfo.rightVisibleCellIndex;
88
51
  }
89
52
  }
53
+ const field = gridVisibleColumnFieldsSelector(apiRef)[colIndex];
54
+ const nonRowSpannedRowId = findNonRowSpannedCell(apiRef, rowId, field, rowSpanScanDirection);
90
55
  // `scrollToIndexes` requires a rowIndex relative to all visible rows.
91
56
  // Those rows do not include pinned rows, but pinned rows do not need scroll anyway.
92
- const rowIndexRelativeToAllRows = visibleSortedRows.findIndex(row => row.id === rowId);
57
+ const rowIndexRelativeToAllRows = visibleSortedRows.findIndex(row => row.id === nonRowSpannedRowId);
93
58
  logger.debug(`Navigating to cell row ${rowIndexRelativeToAllRows}, col ${colIndex}`);
94
59
  apiRef.current.scrollToIndexes({
95
60
  colIndex,
96
61
  rowIndex: rowIndexRelativeToAllRows
97
62
  });
98
- const field = apiRef.current.getVisibleColumns()[colIndex].field;
99
- apiRef.current.setCellFocus(rowId, field);
63
+ apiRef.current.setCellFocus(nonRowSpannedRowId, field);
100
64
  }, [apiRef, logger]);
101
65
  const goToHeader = React.useCallback((colIndex, event) => {
102
66
  logger.debug(`Navigating to header col ${colIndex}`);
@@ -432,7 +396,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
432
396
  {
433
397
  // "Enter" is only triggered by the row / cell editing feature
434
398
  if (rowIndexBefore < lastRowIndexInPage) {
435
- goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore + 1));
399
+ goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore + 1), isRtl ? 'right' : 'left', 'down');
436
400
  }
437
401
  break;
438
402
  }
@@ -0,0 +1,17 @@
1
+ import * as React from 'react';
2
+ import { GridColDef, GridRowEntry, GridRowId } from '../../../models';
3
+ import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
4
+ export declare function enrichPageRowsWithPinnedRows(apiRef: React.MutableRefObject<GridApiCommunity>, rows: GridRowEntry[]): GridRowEntry<import("../../..").GridValidRowModel>[];
5
+ export declare const getLeftColumnIndex: ({ currentColIndex, firstColIndex, lastColIndex, isRtl, }: {
6
+ currentColIndex: number;
7
+ firstColIndex: number;
8
+ lastColIndex: number;
9
+ isRtl: boolean;
10
+ }) => number | null;
11
+ export declare const getRightColumnIndex: ({ currentColIndex, firstColIndex, lastColIndex, isRtl, }: {
12
+ currentColIndex: number;
13
+ firstColIndex: number;
14
+ lastColIndex: number;
15
+ isRtl: boolean;
16
+ }) => number | null;
17
+ export declare function findNonRowSpannedCell(apiRef: React.MutableRefObject<GridApiCommunity>, rowId: GridRowId, field: GridColDef['field'], rowSpanScanDirection: 'up' | 'down'): GridRowId;
@@ -0,0 +1,58 @@
1
+ import { gridFilteredSortedRowIdsSelector } from "../filter/gridFilterSelector.js";
2
+ import { gridRowSpanningHiddenCellsSelector } from "../rows/gridRowSpanningSelectors.js";
3
+ import { gridPinnedRowsSelector } from "../rows/gridRowsSelector.js";
4
+ export function enrichPageRowsWithPinnedRows(apiRef, rows) {
5
+ const pinnedRows = gridPinnedRowsSelector(apiRef) || {};
6
+ return [...(pinnedRows.top || []), ...rows, ...(pinnedRows.bottom || [])];
7
+ }
8
+ export const getLeftColumnIndex = ({
9
+ currentColIndex,
10
+ firstColIndex,
11
+ lastColIndex,
12
+ isRtl
13
+ }) => {
14
+ if (isRtl) {
15
+ if (currentColIndex < lastColIndex) {
16
+ return currentColIndex + 1;
17
+ }
18
+ } else if (!isRtl) {
19
+ if (currentColIndex > firstColIndex) {
20
+ return currentColIndex - 1;
21
+ }
22
+ }
23
+ return null;
24
+ };
25
+ export const getRightColumnIndex = ({
26
+ currentColIndex,
27
+ firstColIndex,
28
+ lastColIndex,
29
+ isRtl
30
+ }) => {
31
+ if (isRtl) {
32
+ if (currentColIndex > firstColIndex) {
33
+ return currentColIndex - 1;
34
+ }
35
+ } else if (!isRtl) {
36
+ if (currentColIndex < lastColIndex) {
37
+ return currentColIndex + 1;
38
+ }
39
+ }
40
+ return null;
41
+ };
42
+ export function findNonRowSpannedCell(apiRef, rowId, field, rowSpanScanDirection) {
43
+ const rowSpanHiddenCells = gridRowSpanningHiddenCellsSelector(apiRef);
44
+ if (!rowSpanHiddenCells[rowId]?.[field]) {
45
+ return rowId;
46
+ }
47
+ const filteredSortedRowIds = gridFilteredSortedRowIdsSelector(apiRef);
48
+ // find closest non row spanned cell in the given `rowSpanScanDirection`
49
+ let nextRowIndex = filteredSortedRowIds.indexOf(rowId) + (rowSpanScanDirection === 'down' ? 1 : -1);
50
+ while (nextRowIndex >= 0 && nextRowIndex < filteredSortedRowIds.length) {
51
+ const nextRowId = filteredSortedRowIds[nextRowIndex];
52
+ if (!rowSpanHiddenCells[nextRowId]?.[field]) {
53
+ return nextRowId;
54
+ }
55
+ nextRowIndex += rowSpanScanDirection === 'down' ? 1 : -1;
56
+ }
57
+ return rowId;
58
+ }
@@ -8,37 +8,37 @@ export declare const gridPaginationSelector: (state: GridStateCommunity) => impo
8
8
  * Get the pagination model
9
9
  * @category Pagination
10
10
  */
11
- export declare const gridPaginationModelSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridPaginationModel>;
11
+ export declare const gridPaginationModelSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridPaginationModel>;
12
12
  /**
13
13
  * Get the row count
14
14
  * @category Pagination
15
15
  */
16
- export declare const gridPaginationRowCountSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
16
+ export declare const gridPaginationRowCountSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
17
17
  /**
18
18
  * Get the pagination meta
19
19
  * @category Pagination
20
20
  */
21
- export declare const gridPaginationMetaSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridPaginationMeta>;
21
+ export declare const gridPaginationMetaSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridPaginationMeta>;
22
22
  /**
23
23
  * Get the index of the page to render if the pagination is enabled
24
24
  * @category Pagination
25
25
  */
26
- export declare const gridPageSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
26
+ export declare const gridPageSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
27
27
  /**
28
28
  * Get the maximum amount of rows to display on a single page if the pagination is enabled
29
29
  * @category Pagination
30
30
  */
31
- export declare const gridPageSizeSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
31
+ export declare const gridPageSizeSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
32
32
  /**
33
33
  * Get the amount of pages needed to display all the rows if the pagination is enabled
34
34
  * @category Pagination
35
35
  */
36
- export declare const gridPageCountSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
36
+ export declare const gridPageCountSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
37
37
  /**
38
38
  * Get the index of the first and the last row to include in the current page if the pagination is enabled.
39
39
  * @category Pagination
40
40
  */
41
- export declare const gridPaginationRowRangeSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, {
41
+ export declare const gridPaginationRowRangeSelector: import("../../..").OutputSelector<GridStateCommunity, {
42
42
  firstRowIndex: number;
43
43
  lastRowIndex: number;
44
44
  } | null>;
@@ -46,9 +46,9 @@ export declare const gridPaginationRowRangeSelector: import("../../../utils/crea
46
46
  * Get the id and the model of each row to include in the current page if the pagination is enabled.
47
47
  * @category Pagination
48
48
  */
49
- export declare const gridPaginatedVisibleSortedGridRowEntriesSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridRowEntry<import("../../..").GridValidRowModel>[]>;
49
+ export declare const gridPaginatedVisibleSortedGridRowEntriesSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridRowEntry<import("../../..").GridValidRowModel>[]>;
50
50
  /**
51
51
  * Get the id of each row to include in the current page if the pagination is enabled.
52
52
  * @category Pagination
53
53
  */
54
- export declare const gridPaginatedVisibleSortedGridRowIdsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridRowId[]>;
54
+ export declare const gridPaginatedVisibleSortedGridRowIdsSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridRowId[]>;
@@ -1,6 +1,6 @@
1
1
  import { GridStateCommunity } from '../../../models/gridStateCommunity';
2
2
  import { GridRowId } from '../../../models/gridRows';
3
3
  export declare const gridRowSelectionStateSelector: (state: GridStateCommunity) => import("../../..").GridRowSelectionModel;
4
- export declare const selectedGridRowsCountSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
5
- export declare const selectedGridRowsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Map<GridRowId, import("../../../models/gridRows").GridValidRowModel>>;
6
- export declare const selectedIdsLookupSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Record<GridRowId, GridRowId>>;
4
+ export declare const selectedGridRowsCountSelector: import("../../..").OutputSelector<GridStateCommunity, number>;
5
+ export declare const selectedGridRowsSelector: import("../../..").OutputSelector<GridStateCommunity, Map<GridRowId, import("../../..").GridValidRowModel>>;
6
+ export declare const selectedIdsLookupSelector: import("../../..").OutputSelector<GridStateCommunity, Record<GridRowId, GridRowId>>;
@@ -9,4 +9,4 @@ export declare const rowSelectionStateInitializer: GridStateInitializer<Pick<Dat
9
9
  * @requires useGridFocus (state) - can be after
10
10
  * @requires useGridKeyboardNavigation (`cellKeyDown` event must first be consumed by it)
11
11
  */
12
- export declare const useGridRowSelection: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "checkboxSelection" | "rowSelectionModel" | "onRowSelectionModelChange" | "disableMultipleRowSelection" | "disableRowSelectionOnClick" | "isRowSelectable" | "checkboxSelectionVisibleOnly" | "pagination" | "paginationMode" | "classes" | "keepNonExistentRowsSelected" | "rowSelection" | "signature">) => void;
12
+ export declare const useGridRowSelection: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "checkboxSelection" | "rowSelectionModel" | "onRowSelectionModelChange" | "disableMultipleRowSelection" | "disableRowSelectionOnClick" | "isRowSelectable" | "checkboxSelectionVisibleOnly" | "pagination" | "paginationMode" | "classes" | "keepNonExistentRowsSelected" | "rowSelection" | "rowSelectionPropagation" | "signature">) => void;