@mui/x-data-grid 7.16.0 → 7.18.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 (243) hide show
  1. package/CHANGELOG.md +184 -4
  2. package/DataGrid/DataGrid.js +11 -1
  3. package/DataGrid/useDataGridComponent.js +3 -0
  4. package/DataGrid/useDataGridProps.js +2 -1
  5. package/colDef/gridStringOperators.js +49 -33
  6. package/components/GridRow.js +1 -0
  7. package/components/cell/GridCell.js +30 -5
  8. package/components/columnHeaders/GridColumnHeaderItem.d.ts +2 -0
  9. package/components/columnHeaders/GridColumnHeaderItem.js +9 -2
  10. package/components/columnHeaders/GridColumnHeaderTitle.js +3 -1
  11. package/components/columnHeaders/GridGenericColumnHeaderItem.js +1 -2
  12. package/components/containers/GridRootStyles.js +3 -7
  13. package/components/panel/filterPanel/GridFilterForm.js +1 -1
  14. package/constants/gridClasses.d.ts +10 -0
  15. package/constants/gridClasses.js +1 -1
  16. package/constants/localeTextConstants.js +4 -0
  17. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +0 -1
  18. package/hooks/features/columnHeaders/useGridColumnHeaders.js +17 -12
  19. package/hooks/features/columnResize/useGridColumnResize.js +6 -6
  20. package/hooks/features/dimensions/gridDimensionsApi.d.ts +4 -0
  21. package/hooks/features/dimensions/useGridDimensions.d.ts +1 -1
  22. package/hooks/features/dimensions/useGridDimensions.js +4 -1
  23. package/hooks/features/editing/useGridCellEditing.js +3 -19
  24. package/hooks/features/editing/useGridRowEditing.js +7 -2
  25. package/hooks/features/editing/utils.d.ts +2 -0
  26. package/hooks/features/editing/utils.js +15 -0
  27. package/hooks/features/export/serializers/csvSerializer.js +1 -1
  28. package/hooks/features/export/useGridPrintExport.js +2 -1
  29. package/hooks/features/filter/gridFilterUtils.js +1 -1
  30. package/hooks/features/focus/useGridFocus.js +2 -1
  31. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +10 -46
  32. package/hooks/features/keyboardNavigation/utils.d.ts +17 -0
  33. package/hooks/features/keyboardNavigation/utils.js +58 -0
  34. package/hooks/features/rows/gridRowSpanningSelectors.d.ts +4 -0
  35. package/hooks/features/rows/gridRowSpanningSelectors.js +5 -0
  36. package/hooks/features/rows/gridRowSpanningUtils.d.ts +10 -0
  37. package/hooks/features/rows/gridRowSpanningUtils.js +42 -0
  38. package/hooks/features/rows/useGridRowSpanning.d.ts +27 -0
  39. package/hooks/features/rows/useGridRowSpanning.js +257 -0
  40. package/hooks/features/sorting/gridSortingUtils.js +1 -1
  41. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
  42. package/hooks/features/virtualization/useGridVirtualScroller.js +17 -7
  43. package/hooks/utils/useGridApiEventHandler.js +0 -1
  44. package/hooks/utils/useGridSelector.js +1 -1
  45. package/index.js +1 -1
  46. package/internals/index.d.ts +1 -0
  47. package/internals/index.js +1 -0
  48. package/internals/utils/index.d.ts +0 -1
  49. package/internals/utils/index.js +1 -2
  50. package/internals/utils/propValidation.js +1 -1
  51. package/locales/arSD.js +4 -0
  52. package/locales/beBY.js +4 -0
  53. package/locales/bgBG.js +4 -0
  54. package/locales/csCZ.js +4 -0
  55. package/locales/daDK.js +4 -0
  56. package/locales/deDE.js +4 -0
  57. package/locales/elGR.js +4 -0
  58. package/locales/esES.js +4 -0
  59. package/locales/faIR.js +4 -0
  60. package/locales/fiFI.js +4 -0
  61. package/locales/frFR.js +4 -0
  62. package/locales/heIL.js +4 -0
  63. package/locales/hrHR.js +4 -0
  64. package/locales/huHU.js +11 -8
  65. package/locales/isIS.js +4 -0
  66. package/locales/itIT.js +4 -0
  67. package/locales/jaJP.js +4 -0
  68. package/locales/koKR.js +4 -0
  69. package/locales/nbNO.js +4 -0
  70. package/locales/nlNL.js +4 -0
  71. package/locales/nnNO.js +4 -0
  72. package/locales/plPL.js +4 -0
  73. package/locales/ptBR.js +4 -0
  74. package/locales/ptPT.js +4 -0
  75. package/locales/roRO.js +4 -0
  76. package/locales/ruRU.js +4 -0
  77. package/locales/skSK.js +4 -0
  78. package/locales/svSE.js +4 -0
  79. package/locales/trTR.js +4 -0
  80. package/locales/ukUA.js +4 -0
  81. package/locales/urPK.js +4 -0
  82. package/locales/viVN.js +4 -0
  83. package/locales/zhCN.js +4 -0
  84. package/locales/zhHK.js +4 -0
  85. package/locales/zhTW.js +4 -0
  86. package/models/api/gridLocaleTextApi.d.ts +4 -0
  87. package/models/colDef/gridColDef.d.ts +4 -0
  88. package/models/gridStateCommunity.d.ts +2 -0
  89. package/models/props/DataGridProps.d.ts +10 -0
  90. package/modern/DataGrid/DataGrid.js +11 -1
  91. package/modern/DataGrid/useDataGridComponent.js +3 -0
  92. package/modern/DataGrid/useDataGridProps.js +2 -1
  93. package/modern/colDef/gridStringOperators.js +49 -33
  94. package/modern/components/GridRow.js +1 -0
  95. package/modern/components/cell/GridCell.js +30 -5
  96. package/modern/components/columnHeaders/GridColumnHeaderItem.js +9 -2
  97. package/modern/components/columnHeaders/GridColumnHeaderTitle.js +3 -1
  98. package/modern/components/columnHeaders/GridGenericColumnHeaderItem.js +1 -2
  99. package/modern/components/containers/GridRootStyles.js +3 -7
  100. package/modern/components/panel/filterPanel/GridFilterForm.js +1 -1
  101. package/modern/constants/gridClasses.js +1 -1
  102. package/modern/constants/localeTextConstants.js +4 -0
  103. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +17 -12
  104. package/modern/hooks/features/columnResize/useGridColumnResize.js +6 -6
  105. package/modern/hooks/features/dimensions/useGridDimensions.js +4 -1
  106. package/modern/hooks/features/editing/useGridCellEditing.js +3 -19
  107. package/modern/hooks/features/editing/useGridRowEditing.js +7 -2
  108. package/modern/hooks/features/editing/utils.js +15 -0
  109. package/modern/hooks/features/export/serializers/csvSerializer.js +1 -1
  110. package/modern/hooks/features/export/useGridPrintExport.js +2 -1
  111. package/modern/hooks/features/filter/gridFilterUtils.js +1 -1
  112. package/modern/hooks/features/focus/useGridFocus.js +2 -1
  113. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +10 -46
  114. package/modern/hooks/features/keyboardNavigation/utils.js +58 -0
  115. package/modern/hooks/features/rows/gridRowSpanningSelectors.js +5 -0
  116. package/modern/hooks/features/rows/gridRowSpanningUtils.js +42 -0
  117. package/modern/hooks/features/rows/useGridRowSpanning.js +257 -0
  118. package/modern/hooks/features/sorting/gridSortingUtils.js +1 -1
  119. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +17 -7
  120. package/modern/hooks/utils/useGridApiEventHandler.js +0 -1
  121. package/modern/hooks/utils/useGridSelector.js +1 -1
  122. package/modern/index.js +1 -1
  123. package/modern/internals/index.js +1 -0
  124. package/modern/internals/utils/index.js +1 -2
  125. package/modern/internals/utils/propValidation.js +1 -1
  126. package/modern/locales/arSD.js +4 -0
  127. package/modern/locales/beBY.js +4 -0
  128. package/modern/locales/bgBG.js +4 -0
  129. package/modern/locales/csCZ.js +4 -0
  130. package/modern/locales/daDK.js +4 -0
  131. package/modern/locales/deDE.js +4 -0
  132. package/modern/locales/elGR.js +4 -0
  133. package/modern/locales/esES.js +4 -0
  134. package/modern/locales/faIR.js +4 -0
  135. package/modern/locales/fiFI.js +4 -0
  136. package/modern/locales/frFR.js +4 -0
  137. package/modern/locales/heIL.js +4 -0
  138. package/modern/locales/hrHR.js +4 -0
  139. package/modern/locales/huHU.js +11 -8
  140. package/modern/locales/isIS.js +4 -0
  141. package/modern/locales/itIT.js +4 -0
  142. package/modern/locales/jaJP.js +4 -0
  143. package/modern/locales/koKR.js +4 -0
  144. package/modern/locales/nbNO.js +4 -0
  145. package/modern/locales/nlNL.js +4 -0
  146. package/modern/locales/nnNO.js +4 -0
  147. package/modern/locales/plPL.js +4 -0
  148. package/modern/locales/ptBR.js +4 -0
  149. package/modern/locales/ptPT.js +4 -0
  150. package/modern/locales/roRO.js +4 -0
  151. package/modern/locales/ruRU.js +4 -0
  152. package/modern/locales/skSK.js +4 -0
  153. package/modern/locales/svSE.js +4 -0
  154. package/modern/locales/trTR.js +4 -0
  155. package/modern/locales/ukUA.js +4 -0
  156. package/modern/locales/urPK.js +4 -0
  157. package/modern/locales/viVN.js +4 -0
  158. package/modern/locales/zhCN.js +4 -0
  159. package/modern/locales/zhHK.js +4 -0
  160. package/modern/locales/zhTW.js +4 -0
  161. package/modern/utils/createSelector.js +1 -1
  162. package/modern/utils/domUtils.js +12 -12
  163. package/node/DataGrid/DataGrid.js +11 -1
  164. package/node/DataGrid/useDataGridComponent.js +3 -0
  165. package/node/DataGrid/useDataGridProps.js +2 -1
  166. package/node/colDef/gridStringOperators.js +49 -33
  167. package/node/components/GridRow.js +1 -0
  168. package/node/components/cell/GridCell.js +30 -5
  169. package/node/components/columnHeaders/GridColumnHeaderItem.js +9 -2
  170. package/node/components/columnHeaders/GridColumnHeaderTitle.js +3 -1
  171. package/node/components/columnHeaders/GridGenericColumnHeaderItem.js +1 -2
  172. package/node/components/containers/GridRootStyles.js +3 -7
  173. package/node/components/panel/filterPanel/GridFilterForm.js +1 -1
  174. package/node/constants/gridClasses.js +1 -1
  175. package/node/constants/localeTextConstants.js +4 -0
  176. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +17 -12
  177. package/node/hooks/features/columnResize/useGridColumnResize.js +6 -6
  178. package/node/hooks/features/dimensions/useGridDimensions.js +4 -1
  179. package/node/hooks/features/editing/useGridCellEditing.js +3 -19
  180. package/node/hooks/features/editing/useGridRowEditing.js +7 -2
  181. package/node/hooks/features/editing/utils.js +22 -0
  182. package/node/hooks/features/export/serializers/csvSerializer.js +1 -1
  183. package/node/hooks/features/export/useGridPrintExport.js +2 -1
  184. package/node/hooks/features/filter/gridFilterUtils.js +1 -1
  185. package/node/hooks/features/focus/useGridFocus.js +2 -1
  186. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +16 -53
  187. package/node/hooks/features/keyboardNavigation/utils.js +68 -0
  188. package/node/hooks/features/rows/gridRowSpanningSelectors.js +11 -0
  189. package/node/hooks/features/rows/gridRowSpanningUtils.js +52 -0
  190. package/node/hooks/features/rows/useGridRowSpanning.js +267 -0
  191. package/node/hooks/features/sorting/gridSortingUtils.js +1 -1
  192. package/node/hooks/features/virtualization/useGridVirtualScroller.js +17 -7
  193. package/node/hooks/utils/useGridApiEventHandler.js +0 -1
  194. package/node/hooks/utils/useGridSelector.js +1 -1
  195. package/node/index.js +1 -1
  196. package/node/internals/index.js +15 -0
  197. package/node/internals/utils/index.js +0 -11
  198. package/node/internals/utils/propValidation.js +1 -1
  199. package/node/locales/arSD.js +4 -0
  200. package/node/locales/beBY.js +4 -0
  201. package/node/locales/bgBG.js +4 -0
  202. package/node/locales/csCZ.js +4 -0
  203. package/node/locales/daDK.js +4 -0
  204. package/node/locales/deDE.js +4 -0
  205. package/node/locales/elGR.js +4 -0
  206. package/node/locales/esES.js +4 -0
  207. package/node/locales/faIR.js +4 -0
  208. package/node/locales/fiFI.js +4 -0
  209. package/node/locales/frFR.js +4 -0
  210. package/node/locales/heIL.js +4 -0
  211. package/node/locales/hrHR.js +4 -0
  212. package/node/locales/huHU.js +11 -8
  213. package/node/locales/isIS.js +4 -0
  214. package/node/locales/itIT.js +4 -0
  215. package/node/locales/jaJP.js +4 -0
  216. package/node/locales/koKR.js +4 -0
  217. package/node/locales/nbNO.js +4 -0
  218. package/node/locales/nlNL.js +4 -0
  219. package/node/locales/nnNO.js +4 -0
  220. package/node/locales/plPL.js +4 -0
  221. package/node/locales/ptBR.js +4 -0
  222. package/node/locales/ptPT.js +4 -0
  223. package/node/locales/roRO.js +4 -0
  224. package/node/locales/ruRU.js +4 -0
  225. package/node/locales/skSK.js +4 -0
  226. package/node/locales/svSE.js +4 -0
  227. package/node/locales/trTR.js +4 -0
  228. package/node/locales/ukUA.js +4 -0
  229. package/node/locales/urPK.js +4 -0
  230. package/node/locales/viVN.js +4 -0
  231. package/node/locales/zhCN.js +4 -0
  232. package/node/locales/zhHK.js +4 -0
  233. package/node/locales/zhTW.js +4 -0
  234. package/node/utils/createSelector.js +1 -1
  235. package/node/utils/domUtils.js +12 -12
  236. package/package.json +3 -3
  237. package/utils/createSelector.js +1 -1
  238. package/utils/domUtils.d.ts +4 -4
  239. package/utils/domUtils.js +12 -12
  240. package/internals/utils/warning.d.ts +0 -2
  241. package/internals/utils/warning.js +0 -21
  242. package/modern/internals/utils/warning.js +0 -21
  243. package/node/internals/utils/warning.js +0 -28
@@ -45,7 +45,9 @@ export const GRID_DEFAULT_LOCALE_TEXT = {
45
45
  filterPanelInputPlaceholder: 'Filter value',
46
46
  // Filter operators text
47
47
  filterOperatorContains: 'contains',
48
+ filterOperatorDoesNotContain: 'does not contain',
48
49
  filterOperatorEquals: 'equals',
50
+ filterOperatorDoesNotEqual: 'does not equal',
49
51
  filterOperatorStartsWith: 'starts with',
50
52
  filterOperatorEndsWith: 'ends with',
51
53
  filterOperatorIs: 'is',
@@ -65,7 +67,9 @@ export const GRID_DEFAULT_LOCALE_TEXT = {
65
67
  'filterOperator<=': '<=',
66
68
  // Header filter operators text
67
69
  headerFilterOperatorContains: 'Contains',
70
+ headerFilterOperatorDoesNotContain: 'Does not contain',
68
71
  headerFilterOperatorEquals: 'Equals',
72
+ headerFilterOperatorDoesNotEqual: 'Does not equal',
69
73
  headerFilterOperatorStartsWith: 'Starts with',
70
74
  headerFilterOperatorEndsWith: 'Ends with',
71
75
  headerFilterOperatorIs: 'Is',
@@ -25,7 +25,6 @@ export interface UseGridColumnHeadersProps {
25
25
  export interface GetHeadersParams {
26
26
  position?: GridPinnedColumnPosition;
27
27
  renderContext?: GridColumnsRenderContext;
28
- minFirstColumn?: number;
29
28
  maxLastColumn?: number;
30
29
  }
31
30
  type OwnerState = DataGridProcessedProps;
@@ -53,7 +53,7 @@ export const useGridColumnHeaders = props => {
53
53
  const renderContext = useGridSelector(apiRef, gridRenderContextColumnsSelector);
54
54
  const pinnedColumns = useGridSelector(apiRef, gridVisiblePinnedColumnDefinitionsSelector);
55
55
  const columnsLookup = useGridSelector(apiRef, gridColumnLookupSelector);
56
- const offsetLeft = computeOffsetLeft(columnPositions, renderContext, isRtl, pinnedColumns.left.length);
56
+ const offsetLeft = computeOffsetLeft(columnPositions, renderContext, pinnedColumns.left.length);
57
57
  const gridHasFiller = dimensions.columnsTotalWidth < dimensions.viewportOuterSize.width;
58
58
  React.useEffect(() => {
59
59
  apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
@@ -83,7 +83,6 @@ export const useGridColumnHeaders = props => {
83
83
  const getColumnsToRender = params => {
84
84
  const {
85
85
  renderContext: currentContext = renderContext,
86
- // TODO: `minFirstColumn` is not used anymore, could be refactored out.
87
86
  maxLastColumn = visibleColumns.length
88
87
  } = params || {};
89
88
  const firstColumnToRender = currentContext.firstColumnIndex;
@@ -123,16 +122,22 @@ export const useGridColumnHeaders = props => {
123
122
  computedWidth
124
123
  }) => {
125
124
  let style;
126
- if (pinnedPosition === 'left' || pinnedPosition === 'right') {
125
+ const isLeftPinned = pinnedPosition === GridPinnedColumnPosition.LEFT;
126
+ const isRightPinned = pinnedPosition === GridPinnedColumnPosition.RIGHT;
127
+ if (isLeftPinned || isRightPinned) {
127
128
  const pinnedOffset = getPinnedCellOffset(pinnedPosition, computedWidth, columnIndex, columnPositions, dimensions);
129
+ let side = isLeftPinned ? 'left' : 'right';
130
+ if (isRtl) {
131
+ side = isLeftPinned ? 'right' : 'left';
132
+ }
128
133
  if (pinnedPosition === 'left') {
129
134
  style = {
130
- left: pinnedOffset
135
+ [side]: pinnedOffset
131
136
  };
132
137
  }
133
138
  if (pinnedPosition === 'right') {
134
139
  style = {
135
- right: pinnedOffset
140
+ [side]: pinnedOffset
136
141
  };
137
142
  }
138
143
  }
@@ -157,6 +162,9 @@ export const useGridColumnHeaders = props => {
157
162
  columnIndex,
158
163
  computedWidth: colDef.computedWidth
159
164
  });
165
+ const siblingWithBorderingSeparator = pinnedPosition === GridPinnedColumnPosition.RIGHT ? renderedColumns[i - 1] : renderedColumns[i + 1];
166
+ const isSiblingFocused = siblingWithBorderingSeparator ? columnHeaderFocus !== null && columnHeaderFocus.field === siblingWithBorderingSeparator.field : false;
167
+ const isLastUnpinned = columnIndex + 1 === columnPositions.length - pinnedColumns.right.length;
160
168
  columns.push(/*#__PURE__*/_jsx(GridColumnHeaderItem, _extends({}, sortColumnLookup[colDef.field], {
161
169
  columnMenuOpen: open,
162
170
  filterItemsCounter: filterColumnLookup[colDef.field] && filterColumnLookup[colDef.field].length,
@@ -172,7 +180,9 @@ export const useGridColumnHeaders = props => {
172
180
  style: style,
173
181
  indexInSection: i,
174
182
  sectionLength: renderedColumns.length,
175
- gridHasFiller: gridHasFiller
183
+ gridHasFiller: gridHasFiller,
184
+ isLastUnpinned: isLastUnpinned,
185
+ isSiblingFocused: isSiblingFocused
176
186
  }, other), colDef.field));
177
187
  }
178
188
  return getFillers(params, columns, 0);
@@ -186,18 +196,15 @@ export const useGridColumnHeaders = props => {
186
196
  children: [leftRenderContext && getColumnHeaders({
187
197
  position: GridPinnedColumnPosition.LEFT,
188
198
  renderContext: leftRenderContext,
189
- minFirstColumn: leftRenderContext.firstColumnIndex,
190
199
  maxLastColumn: leftRenderContext.lastColumnIndex
191
200
  }, {
192
201
  disableReorder: true
193
202
  }), getColumnHeaders({
194
203
  renderContext,
195
- minFirstColumn: pinnedColumns.left.length,
196
204
  maxLastColumn: visibleColumns.length - pinnedColumns.right.length
197
205
  }), rightRenderContext && getColumnHeaders({
198
206
  position: GridPinnedColumnPosition.RIGHT,
199
207
  renderContext: rightRenderContext,
200
- minFirstColumn: rightRenderContext.firstColumnIndex,
201
208
  maxLastColumn: rightRenderContext.lastColumnIndex
202
209
  }, {
203
210
  disableReorder: true,
@@ -277,7 +284,7 @@ export const useGridColumnHeaders = props => {
277
284
  depth: depth,
278
285
  isLastColumn: headerInfo.colIndex === visibleColumns.length - headerInfo.fields.length,
279
286
  maxDepth: headerGroupingMaxDepth,
280
- height: dimensions.headerHeight,
287
+ height: dimensions.groupHeaderHeight,
281
288
  hasFocus: hasFocus,
282
289
  tabIndex: tabIndex,
283
290
  pinnedPosition: pinnedPosition,
@@ -304,7 +311,6 @@ export const useGridColumnHeaders = props => {
304
311
  params: {
305
312
  position: GridPinnedColumnPosition.LEFT,
306
313
  renderContext: leftRenderContext,
307
- minFirstColumn: leftRenderContext.firstColumnIndex,
308
314
  maxLastColumn: leftRenderContext.lastColumnIndex
309
315
  }
310
316
  }), getColumnGroupHeaders({
@@ -317,7 +323,6 @@ export const useGridColumnHeaders = props => {
317
323
  params: {
318
324
  position: GridPinnedColumnPosition.RIGHT,
319
325
  renderContext: rightRenderContext,
320
- minFirstColumn: rightRenderContext.firstColumnIndex,
321
326
  maxLastColumn: rightRenderContext.lastColumnIndex
322
327
  }
323
328
  })]
@@ -302,13 +302,13 @@ export const useGridColumnResize = (apiRef, props) => {
302
302
  }
303
303
  refs.groupHeaderElements = findGroupHeaderElementsFromField(apiRef.current.columnHeadersContainerRef?.current, colDef.field);
304
304
  refs.cellElements = findGridCellElementsFromCol(refs.columnHeaderElement, apiRef.current);
305
- refs.fillerLeft = findGridElement(apiRef.current, 'filler--pinnedLeft');
306
- refs.fillerRight = findGridElement(apiRef.current, 'filler--pinnedRight');
305
+ refs.fillerLeft = findGridElement(apiRef.current, isRtl ? 'filler--pinnedRight' : 'filler--pinnedLeft');
306
+ refs.fillerRight = findGridElement(apiRef.current, isRtl ? 'filler--pinnedLeft' : 'filler--pinnedRight');
307
307
  const pinnedPosition = apiRef.current.unstable_applyPipeProcessors('isColumnPinned', false, refs.colDef.field);
308
- refs.leftPinnedCellsAfter = pinnedPosition !== GridPinnedColumnPosition.LEFT ? [] : findLeftPinnedCellsAfterCol(apiRef.current, refs.columnHeaderElement);
309
- refs.rightPinnedCellsBefore = pinnedPosition !== GridPinnedColumnPosition.RIGHT ? [] : findRightPinnedCellsBeforeCol(apiRef.current, refs.columnHeaderElement);
310
- refs.leftPinnedHeadersAfter = pinnedPosition !== GridPinnedColumnPosition.LEFT ? [] : findLeftPinnedHeadersAfterCol(apiRef.current, refs.columnHeaderElement);
311
- refs.rightPinnedHeadersBefore = pinnedPosition !== GridPinnedColumnPosition.RIGHT ? [] : findRightPinnedHeadersBeforeCol(apiRef.current, refs.columnHeaderElement);
308
+ refs.leftPinnedCellsAfter = pinnedPosition !== GridPinnedColumnPosition.LEFT ? [] : findLeftPinnedCellsAfterCol(apiRef.current, refs.columnHeaderElement, isRtl);
309
+ refs.rightPinnedCellsBefore = pinnedPosition !== GridPinnedColumnPosition.RIGHT ? [] : findRightPinnedCellsBeforeCol(apiRef.current, refs.columnHeaderElement, isRtl);
310
+ refs.leftPinnedHeadersAfter = pinnedPosition !== GridPinnedColumnPosition.LEFT ? [] : findLeftPinnedHeadersAfterCol(apiRef.current, refs.columnHeaderElement, isRtl);
311
+ refs.rightPinnedHeadersBefore = pinnedPosition !== GridPinnedColumnPosition.RIGHT ? [] : findRightPinnedHeadersBeforeCol(apiRef.current, refs.columnHeaderElement, isRtl);
312
312
  resizeDirection.current = getResizeDirection(separator, isRtl);
313
313
  initialOffsetToSeparator.current = computeOffsetToSeparator(xStart, refs.columnHeaderElement.getBoundingClientRect(), resizeDirection.current);
314
314
  };
@@ -61,6 +61,10 @@ export interface GridDimensions {
61
61
  * Height of one column header.
62
62
  */
63
63
  headerHeight: number;
64
+ /**
65
+ * Height of one column group header.
66
+ */
67
+ groupHeaderHeight: number;
64
68
  /**
65
69
  * Height of header filters.
66
70
  */
@@ -3,7 +3,7 @@ import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
3
3
  import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
4
4
  import { GridDimensions } from './gridDimensionsApi';
5
5
  import { GridStateInitializer } from '../../utils/useGridInitializeState';
6
- type RootProps = Pick<DataGridProcessedProps, 'onResize' | 'scrollbarSize' | 'pagination' | 'paginationMode' | 'autoHeight' | 'getRowHeight' | 'rowHeight' | 'resizeThrottleMs' | 'columnHeaderHeight' | 'headerFilterHeight'>;
6
+ type RootProps = Pick<DataGridProcessedProps, 'onResize' | 'scrollbarSize' | 'pagination' | 'paginationMode' | 'autoHeight' | 'getRowHeight' | 'rowHeight' | 'resizeThrottleMs' | 'columnHeaderHeight' | 'columnGroupHeaderHeight' | 'headerFilterHeight'>;
7
7
  export type GridDimensionsState = GridDimensions;
8
8
  export declare const dimensionsStateInitializer: GridStateInitializer<RootProps>;
9
9
  export declare function useGridDimensions(apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: RootProps): void;
@@ -29,6 +29,7 @@ const EMPTY_DIMENSIONS = {
29
29
  hasScrollY: false,
30
30
  scrollbarSize: 0,
31
31
  headerHeight: 0,
32
+ groupHeaderHeight: 0,
32
33
  headerFilterHeight: 0,
33
34
  rowWidth: 0,
34
35
  rowHeight: 0,
@@ -55,6 +56,7 @@ export function useGridDimensions(apiRef, props) {
55
56
  const densityFactor = useGridSelector(apiRef, gridDensityFactorSelector);
56
57
  const rowHeight = Math.floor(props.rowHeight * densityFactor);
57
58
  const headerHeight = Math.floor(props.columnHeaderHeight * densityFactor);
59
+ const groupHeaderHeight = Math.floor((props.columnGroupHeaderHeight ?? props.columnHeaderHeight) * densityFactor);
58
60
  const headerFilterHeight = Math.floor((props.headerFilterHeight ?? props.columnHeaderHeight) * densityFactor);
59
61
  const columnsTotalWidth = roundToDecimalPlaces(gridColumnsTotalWidthSelector(apiRef), 6);
60
62
  const headersTotalHeight = getTotalHeaderHeight(apiRef, props);
@@ -175,6 +177,7 @@ export function useGridDimensions(apiRef, props) {
175
177
  hasScrollY,
176
178
  scrollbarSize,
177
179
  headerHeight,
180
+ groupHeaderHeight,
178
181
  headerFilterHeight,
179
182
  rowWidth,
180
183
  rowHeight,
@@ -191,7 +194,7 @@ export function useGridDimensions(apiRef, props) {
191
194
  apiRef.current.publishEvent('viewportInnerSizeChange', newDimensions.viewportInnerSize);
192
195
  }
193
196
  apiRef.current.updateRenderContext?.();
194
- }, [apiRef, setDimensions, props.scrollbarSize, props.autoHeight, rowsMeta.currentPageTotalHeight, rowHeight, headerHeight, headerFilterHeight, columnsTotalWidth, headersTotalHeight, leftPinnedWidth, rightPinnedWidth]);
197
+ }, [apiRef, setDimensions, props.scrollbarSize, props.autoHeight, rowsMeta.currentPageTotalHeight, rowHeight, headerHeight, groupHeaderHeight, headerFilterHeight, columnsTotalWidth, headersTotalHeight, leftPinnedWidth, rightPinnedWidth]);
195
198
  const apiPublic = {
196
199
  resize,
197
200
  getRootDimensions
@@ -5,15 +5,16 @@ const _excluded = ["id", "field"],
5
5
  _excluded2 = ["id", "field"];
6
6
  import * as React from 'react';
7
7
  import { unstable_useEventCallback as useEventCallback, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
8
+ import { warnOnce } from '@mui/x-internals/warning';
8
9
  import { useGridApiEventHandler, useGridApiOptionHandler } from "../../utils/useGridApiEventHandler.js";
9
10
  import { GridEditModes, GridCellModes } from "../../../models/gridEditRowModel.js";
10
11
  import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
11
12
  import { gridEditRowsStateSelector } from "./gridEditingSelectors.js";
12
13
  import { isPrintableKey, isPasteShortcut } from "../../../utils/keyboardUtils.js";
13
- import { warnOnce } from "../../../internals/utils/warning.js";
14
14
  import { gridRowsDataRowIdToIdLookupSelector } from "../rows/gridRowsSelector.js";
15
15
  import { deepClone } from "../../../utils/utils.js";
16
16
  import { GridCellEditStartReasons, GridCellEditStopReasons } from "../../../models/params/gridEditCellParams.js";
17
+ import { getDefaultCellValue } from "./utils.js";
17
18
  export const useGridCellEditing = (apiRef, props) => {
18
19
  const [cellModesModel, setCellModesModel] = React.useState({});
19
20
  const cellModesModelRef = React.useRef(cellModesModel);
@@ -249,24 +250,7 @@ export const useGridCellEditing = (apiRef, props) => {
249
250
  } = params;
250
251
  let newValue = apiRef.current.getCellValue(id, field);
251
252
  if (deleteValue) {
252
- const fieldType = apiRef.current.getColumn(field).type;
253
- switch (fieldType) {
254
- case 'boolean':
255
- newValue = false;
256
- break;
257
- case 'date':
258
- case 'dateTime':
259
- case 'number':
260
- newValue = undefined;
261
- break;
262
- case 'singleSelect':
263
- newValue = null;
264
- break;
265
- case 'string':
266
- default:
267
- newValue = '';
268
- break;
269
- }
253
+ newValue = getDefaultCellValue(apiRef.current.getColumn(field));
270
254
  } else if (initialValue) {
271
255
  newValue = initialValue;
272
256
  }
@@ -5,17 +5,18 @@ const _excluded = ["id"],
5
5
  _excluded2 = ["id"];
6
6
  import * as React from 'react';
7
7
  import { unstable_useEventCallback as useEventCallback, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
8
+ import { warnOnce } from '@mui/x-internals/warning';
8
9
  import { useGridApiEventHandler, useGridApiOptionHandler } from "../../utils/useGridApiEventHandler.js";
9
10
  import { GridEditModes, GridRowModes } from "../../../models/gridEditRowModel.js";
10
11
  import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
11
12
  import { gridEditRowsStateSelector } from "./gridEditingSelectors.js";
12
13
  import { isPrintableKey, isPasteShortcut } from "../../../utils/keyboardUtils.js";
13
14
  import { gridColumnFieldsSelector, gridVisibleColumnFieldsSelector } from "../columns/gridColumnsSelector.js";
14
- import { warnOnce } from "../../../internals/utils/warning.js";
15
15
  import { gridRowsDataRowIdToIdLookupSelector } from "../rows/gridRowsSelector.js";
16
16
  import { deepClone } from "../../../utils/utils.js";
17
17
  import { GridRowEditStopReasons, GridRowEditStartReasons } from "../../../models/params/gridRowParams.js";
18
18
  import { GRID_ACTIONS_COLUMN_TYPE } from "../../../colDef/index.js";
19
+ import { getDefaultCellValue } from "./utils.js";
19
20
  export const useGridRowEditing = (apiRef, props) => {
20
21
  const [rowModesModel, setRowModesModel] = React.useState({});
21
22
  const rowModesModelRef = React.useRef(rowModesModel);
@@ -319,7 +320,11 @@ export const useGridRowEditing = (apiRef, props) => {
319
320
  }
320
321
  let newValue = apiRef.current.getCellValue(id, field);
321
322
  if (fieldToFocus === field && (deleteValue || initialValue)) {
322
- newValue = deleteValue ? '' : initialValue;
323
+ if (deleteValue) {
324
+ newValue = getDefaultCellValue(apiRef.current.getColumn(field));
325
+ } else if (initialValue) {
326
+ newValue = initialValue;
327
+ }
323
328
  }
324
329
  acc[field] = {
325
330
  value: newValue,
@@ -0,0 +1,2 @@
1
+ import { GridColDef } from '../../../models/colDef/gridColDef';
2
+ export declare const getDefaultCellValue: (colDef: GridColDef) => false | "" | null | undefined;
@@ -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
+ };
@@ -1,5 +1,5 @@
1
+ import { warnOnce } from '@mui/x-internals/warning';
1
2
  import { GRID_CHECKBOX_SELECTION_COL_DEF } from "../../../../colDef/index.js";
2
- import { warnOnce } from "../../../../internals/utils/warning.js";
3
3
  function sanitizeCellValue(value, csvOptions) {
4
4
  if (value === null || value === undefined) {
5
5
  return '';
@@ -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
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { warnOnce } from '@mui/x-internals/warning';
2
3
  import { GridLogicOperator } from "../../../models/index.js";
3
4
  import { getDefaultGridFilterModel } from "./gridFilterState.js";
4
- import { warnOnce } from "../../../internals/utils/warning.js";
5
5
  import { getPublicApiRef } from "../../../utils/getPublicApiRef.js";
6
6
  import { gridColumnFieldsSelector, gridColumnLookupSelector, gridVisibleColumnFieldsSelector } from "../columns/index.js";
7
7
  let hasEval;
@@ -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,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("../../../models").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
+ }
@@ -0,0 +1,4 @@
1
+ import { GridStateCommunity } from '../../../models/gridStateCommunity';
2
+ export declare const gridRowSpanningHiddenCellsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Record<import("../../..").GridRowId, Record<string, boolean>>>;
3
+ export declare const gridRowSpanningSpannedCellsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Record<import("../../..").GridRowId, Record<string, number>>>;
4
+ export declare const gridRowSpanningHiddenCellsOriginMapSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Record<number, Record<string, number>>>;
@@ -0,0 +1,5 @@
1
+ import { createSelector } from "../../../utils/createSelector.js";
2
+ const gridRowSpanningStateSelector = state => state.rowSpanning;
3
+ export const gridRowSpanningHiddenCellsSelector = createSelector(gridRowSpanningStateSelector, rowSpanning => rowSpanning.hiddenCells);
4
+ export const gridRowSpanningSpannedCellsSelector = createSelector(gridRowSpanningStateSelector, rowSpanning => rowSpanning.spannedCells);
5
+ export const gridRowSpanningHiddenCellsOriginMapSelector = createSelector(gridRowSpanningStateSelector, rowSpanning => rowSpanning.hiddenCellOriginMap);
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import type { GridRenderContext } from '../../../models';
3
+ import type { GridValidRowModel } from '../../../models/gridRows';
4
+ import type { GridColDef } from '../../../models/colDef';
5
+ import type { GridApiCommunity } from '../../../models/api/gridApiCommunity';
6
+ import type { RowRange } from './useGridRowSpanning';
7
+ export declare function getUnprocessedRange(testRange: RowRange, processedRange: RowRange): RowRange | null;
8
+ export declare function isRowContextInitialized(renderContext: GridRenderContext): boolean;
9
+ export declare function isRowRangeUpdated(range1: RowRange, range2: RowRange): boolean;
10
+ export declare const getCellValue: (row: GridValidRowModel, colDef: GridColDef, apiRef: React.MutableRefObject<GridApiCommunity>) => any;
@@ -0,0 +1,42 @@
1
+ export function getUnprocessedRange(testRange, processedRange) {
2
+ if (testRange.firstRowIndex >= processedRange.firstRowIndex && testRange.lastRowIndex <= processedRange.lastRowIndex) {
3
+ return null;
4
+ }
5
+ // Overflowing at the end
6
+ // Example: testRange={ firstRowIndex: 10, lastRowIndex: 20 }, processedRange={ firstRowIndex: 0, lastRowIndex: 15 }
7
+ // Unprocessed Range={ firstRowIndex: 16, lastRowIndex: 20 }
8
+ if (testRange.firstRowIndex >= processedRange.firstRowIndex && testRange.lastRowIndex > processedRange.lastRowIndex) {
9
+ return {
10
+ firstRowIndex: processedRange.lastRowIndex,
11
+ lastRowIndex: testRange.lastRowIndex
12
+ };
13
+ }
14
+ // Overflowing at the beginning
15
+ // Example: testRange={ firstRowIndex: 0, lastRowIndex: 20 }, processedRange={ firstRowIndex: 16, lastRowIndex: 30 }
16
+ // Unprocessed Range={ firstRowIndex: 0, lastRowIndex: 15 }
17
+ if (testRange.firstRowIndex < processedRange.firstRowIndex && testRange.lastRowIndex <= processedRange.lastRowIndex) {
18
+ return {
19
+ firstRowIndex: testRange.firstRowIndex,
20
+ lastRowIndex: processedRange.firstRowIndex - 1
21
+ };
22
+ }
23
+ // TODO: Should return two ranges handle overflowing at both ends ?
24
+ return testRange;
25
+ }
26
+ export function isRowContextInitialized(renderContext) {
27
+ return renderContext.firstRowIndex !== 0 || renderContext.lastRowIndex !== 0;
28
+ }
29
+ export function isRowRangeUpdated(range1, range2) {
30
+ return range1.firstRowIndex !== range2.firstRowIndex || range1.lastRowIndex !== range2.lastRowIndex;
31
+ }
32
+ export const getCellValue = (row, colDef, apiRef) => {
33
+ if (!row) {
34
+ return null;
35
+ }
36
+ let cellValue = row[colDef.field];
37
+ const valueGetter = colDef.rowSpanValueGetter ?? colDef.valueGetter;
38
+ if (valueGetter) {
39
+ cellValue = valueGetter(cellValue, row, colDef, apiRef);
40
+ }
41
+ return cellValue;
42
+ };
@@ -0,0 +1,27 @@
1
+ import * as React from 'react';
2
+ import type { GridColDef } from '../../../models/colDef';
3
+ import type { GridRowId } from '../../../models/gridRows';
4
+ import type { DataGridProcessedProps } from '../../../models/props/DataGridProps';
5
+ import type { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
6
+ import type { GridStateInitializer } from '../../utils/useGridInitializeState';
7
+ export interface GridRowSpanningState {
8
+ spannedCells: Record<GridRowId, Record<GridColDef['field'], number>>;
9
+ hiddenCells: Record<GridRowId, Record<GridColDef['field'], boolean>>;
10
+ /**
11
+ * For each hidden cell, it contains the row index corresponding to the cell that is
12
+ * the origin of the hidden cell. i.e. the cell which is spanned.
13
+ * Used by the virtualization to properly keep the spanned cells in view.
14
+ */
15
+ hiddenCellOriginMap: Record<number, Record<GridColDef['field'], number>>;
16
+ }
17
+ export type RowRange = {
18
+ firstRowIndex: number;
19
+ lastRowIndex: number;
20
+ };
21
+ /**
22
+ * @requires columnsStateInitializer (method) - should be initialized before
23
+ * @requires rowsStateInitializer (method) - should be initialized before
24
+ * @requires filterStateInitializer (method) - should be initialized before
25
+ */
26
+ export declare const rowSpanningStateInitializer: GridStateInitializer;
27
+ export declare const useGridRowSpanning: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "unstable_rowSpanning" | "pagination" | "paginationMode">) => void;