@mui/x-data-grid 6.7.0 → 6.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 (205) hide show
  1. package/CHANGELOG.md +145 -5541
  2. package/components/GridColumnHeaders.d.ts +2 -2
  3. package/components/GridColumnHeaders.js +3 -1
  4. package/components/GridPagination.d.ts +2 -2
  5. package/components/GridRow.d.ts +2 -2
  6. package/components/GridRow.js +33 -79
  7. package/components/cell/GridCell.d.ts +24 -15
  8. package/components/cell/GridCell.js +422 -45
  9. package/components/cell/GridEditInputCell.js +9 -9
  10. package/components/cell/index.d.ts +2 -1
  11. package/components/cell/index.js +1 -1
  12. package/components/containers/GridRootStyles.js +30 -16
  13. package/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
  14. package/components/panel/GridPanel.d.ts +1 -1
  15. package/components/toolbar/GridToolbar.js +2 -2
  16. package/components/virtualization/GridVirtualScroller.js +4 -9
  17. package/components/virtualization/GridVirtualScrollerContent.js +11 -20
  18. package/constants/defaultGridSlotsComponents.js +6 -2
  19. package/hooks/core/useGridApiInitialization.js +4 -1
  20. package/hooks/core/useGridStateInitialization.js +2 -9
  21. package/hooks/features/clipboard/useGridClipboard.js +1 -4
  22. package/hooks/features/columnGrouping/gridColumnGroupsSelector.js +4 -4
  23. package/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
  24. package/hooks/features/columns/gridColumnsSelector.js +7 -7
  25. package/hooks/features/dimensions/useGridDimensions.js +6 -12
  26. package/hooks/features/editing/useGridCellEditing.js +5 -3
  27. package/hooks/features/editing/useGridRowEditing.js +14 -6
  28. package/hooks/features/filter/gridFilterSelector.js +8 -8
  29. package/hooks/features/filter/gridFilterUtils.d.ts +4 -1
  30. package/hooks/features/filter/gridFilterUtils.js +19 -13
  31. package/hooks/features/filter/useGridFilter.js +2 -1
  32. package/hooks/features/focus/useGridFocus.js +9 -4
  33. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
  34. package/hooks/features/pagination/gridPaginationSelector.js +4 -4
  35. package/hooks/features/rowSelection/gridRowSelectionSelector.js +3 -3
  36. package/hooks/features/rows/gridRowsSelector.js +3 -3
  37. package/hooks/features/rows/useGridParamsApi.d.ts +2 -0
  38. package/hooks/features/rows/useGridParamsApi.js +7 -15
  39. package/hooks/features/sorting/gridSortingSelector.js +3 -3
  40. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +8 -816
  41. package/hooks/features/virtualization/useGridVirtualScroller.js +40 -38
  42. package/hooks/utils/index.d.ts +1 -1
  43. package/hooks/utils/index.js +1 -1
  44. package/hooks/utils/useGridSelector.d.ts +3 -1
  45. package/hooks/utils/useGridSelector.js +37 -6
  46. package/hooks/utils/useLazyRef.d.ts +2 -0
  47. package/hooks/utils/useLazyRef.js +9 -0
  48. package/hooks/utils/useOnMount.d.ts +2 -0
  49. package/hooks/utils/useOnMount.js +7 -0
  50. package/index.js +1 -1
  51. package/internals/index.d.ts +1 -1
  52. package/internals/index.js +1 -1
  53. package/legacy/components/GridColumnHeaders.js +3 -1
  54. package/legacy/components/GridRow.js +35 -79
  55. package/legacy/components/cell/GridCell.js +425 -46
  56. package/legacy/components/cell/GridEditInputCell.js +9 -9
  57. package/legacy/components/cell/index.js +1 -1
  58. package/legacy/components/containers/GridRootStyles.js +20 -17
  59. package/legacy/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
  60. package/legacy/components/toolbar/GridToolbar.js +2 -2
  61. package/legacy/components/virtualization/GridVirtualScroller.js +4 -7
  62. package/legacy/components/virtualization/GridVirtualScrollerContent.js +10 -17
  63. package/legacy/constants/defaultGridSlotsComponents.js +6 -2
  64. package/legacy/hooks/core/useGridApiInitialization.js +4 -1
  65. package/legacy/hooks/core/useGridStateInitialization.js +2 -7
  66. package/legacy/hooks/features/clipboard/useGridClipboard.js +1 -4
  67. package/legacy/hooks/features/columnGrouping/gridColumnGroupsSelector.js +4 -4
  68. package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
  69. package/legacy/hooks/features/columns/gridColumnsSelector.js +7 -7
  70. package/legacy/hooks/features/dimensions/useGridDimensions.js +6 -12
  71. package/legacy/hooks/features/editing/useGridCellEditing.js +5 -3
  72. package/legacy/hooks/features/editing/useGridRowEditing.js +15 -7
  73. package/legacy/hooks/features/filter/gridFilterSelector.js +8 -8
  74. package/legacy/hooks/features/filter/gridFilterUtils.js +23 -19
  75. package/legacy/hooks/features/filter/useGridFilter.js +2 -1
  76. package/legacy/hooks/features/focus/useGridFocus.js +9 -4
  77. package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
  78. package/legacy/hooks/features/pagination/gridPaginationSelector.js +4 -4
  79. package/legacy/hooks/features/rowSelection/gridRowSelectionSelector.js +3 -3
  80. package/legacy/hooks/features/rows/gridRowsSelector.js +3 -3
  81. package/legacy/hooks/features/rows/useGridParamsApi.js +23 -15
  82. package/legacy/hooks/features/sorting/gridSortingSelector.js +3 -3
  83. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +38 -34
  84. package/legacy/hooks/utils/index.js +1 -1
  85. package/legacy/hooks/utils/useGridSelector.js +43 -5
  86. package/legacy/hooks/utils/useLazyRef.js +9 -0
  87. package/legacy/hooks/utils/useOnMount.js +7 -0
  88. package/legacy/index.js +1 -1
  89. package/legacy/internals/index.js +1 -1
  90. package/legacy/locales/elGR.js +70 -79
  91. package/legacy/locales/ptBR.js +12 -13
  92. package/legacy/utils/Store.js +34 -0
  93. package/legacy/utils/createSelector.js +74 -6
  94. package/legacy/utils/doesSupportPreventScroll.js +13 -0
  95. package/legacy/utils/fastMemo.js +5 -0
  96. package/legacy/utils/fastObjectShallowCompare.js +32 -0
  97. package/legacy/utils/keyboardUtils.js +4 -2
  98. package/locales/elGR.js +66 -79
  99. package/locales/ptBR.js +12 -13
  100. package/models/api/gridCoreApi.d.ts +6 -0
  101. package/models/colDef/gridColDef.d.ts +4 -3
  102. package/models/colDef/gridColType.d.ts +3 -1
  103. package/models/events/gridEventLookup.d.ts +3 -3
  104. package/modern/components/GridColumnHeaders.js +3 -1
  105. package/modern/components/GridRow.js +32 -79
  106. package/modern/components/cell/GridCell.js +421 -45
  107. package/modern/components/cell/GridEditInputCell.js +9 -9
  108. package/modern/components/cell/index.js +1 -1
  109. package/modern/components/containers/GridRootStyles.js +30 -16
  110. package/modern/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
  111. package/modern/components/toolbar/GridToolbar.js +2 -2
  112. package/modern/components/virtualization/GridVirtualScroller.js +4 -9
  113. package/modern/components/virtualization/GridVirtualScrollerContent.js +10 -20
  114. package/modern/constants/defaultGridSlotsComponents.js +6 -2
  115. package/modern/hooks/core/useGridApiInitialization.js +4 -1
  116. package/modern/hooks/core/useGridStateInitialization.js +2 -9
  117. package/modern/hooks/features/clipboard/useGridClipboard.js +1 -4
  118. package/modern/hooks/features/columnGrouping/gridColumnGroupsSelector.js +4 -4
  119. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
  120. package/modern/hooks/features/columns/gridColumnsSelector.js +7 -7
  121. package/modern/hooks/features/dimensions/useGridDimensions.js +6 -12
  122. package/modern/hooks/features/editing/useGridCellEditing.js +5 -3
  123. package/modern/hooks/features/editing/useGridRowEditing.js +14 -6
  124. package/modern/hooks/features/filter/gridFilterSelector.js +8 -8
  125. package/modern/hooks/features/filter/gridFilterUtils.js +17 -12
  126. package/modern/hooks/features/filter/useGridFilter.js +2 -1
  127. package/modern/hooks/features/focus/useGridFocus.js +8 -4
  128. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
  129. package/modern/hooks/features/pagination/gridPaginationSelector.js +4 -4
  130. package/modern/hooks/features/rowSelection/gridRowSelectionSelector.js +3 -3
  131. package/modern/hooks/features/rows/gridRowsSelector.js +3 -3
  132. package/modern/hooks/features/rows/useGridParamsApi.js +7 -15
  133. package/modern/hooks/features/sorting/gridSortingSelector.js +3 -3
  134. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +40 -38
  135. package/modern/hooks/utils/index.js +1 -1
  136. package/modern/hooks/utils/useGridSelector.js +37 -6
  137. package/modern/hooks/utils/useLazyRef.js +9 -0
  138. package/modern/hooks/utils/useOnMount.js +7 -0
  139. package/modern/index.js +1 -1
  140. package/modern/internals/index.js +1 -1
  141. package/modern/locales/elGR.js +66 -79
  142. package/modern/locales/ptBR.js +12 -13
  143. package/modern/utils/Store.js +24 -0
  144. package/modern/utils/createSelector.js +74 -6
  145. package/modern/utils/doesSupportPreventScroll.js +13 -0
  146. package/modern/utils/fastMemo.js +5 -0
  147. package/modern/utils/fastObjectShallowCompare.js +32 -0
  148. package/modern/utils/keyboardUtils.js +4 -2
  149. package/node/components/GridColumnHeaders.js +4 -2
  150. package/node/components/GridRow.js +32 -79
  151. package/node/components/cell/GridCell.js +424 -47
  152. package/node/components/cell/GridEditInputCell.js +9 -9
  153. package/node/components/cell/index.js +17 -10
  154. package/node/components/containers/GridRootStyles.js +30 -16
  155. package/node/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
  156. package/node/components/toolbar/GridToolbar.js +2 -2
  157. package/node/components/virtualization/GridVirtualScroller.js +4 -9
  158. package/node/components/virtualization/GridVirtualScrollerContent.js +10 -20
  159. package/node/constants/defaultGridSlotsComponents.js +4 -1
  160. package/node/hooks/core/useGridApiInitialization.js +4 -1
  161. package/node/hooks/core/useGridStateInitialization.js +2 -9
  162. package/node/hooks/features/clipboard/useGridClipboard.js +1 -4
  163. package/node/hooks/features/columnGrouping/gridColumnGroupsSelector.js +3 -3
  164. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +8 -2
  165. package/node/hooks/features/columns/gridColumnsSelector.js +6 -6
  166. package/node/hooks/features/dimensions/useGridDimensions.js +6 -12
  167. package/node/hooks/features/editing/useGridCellEditing.js +5 -3
  168. package/node/hooks/features/editing/useGridRowEditing.js +14 -6
  169. package/node/hooks/features/filter/gridFilterSelector.js +7 -7
  170. package/node/hooks/features/filter/gridFilterUtils.js +17 -12
  171. package/node/hooks/features/filter/useGridFilter.js +2 -1
  172. package/node/hooks/features/focus/useGridFocus.js +8 -4
  173. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
  174. package/node/hooks/features/pagination/gridPaginationSelector.js +3 -3
  175. package/node/hooks/features/rowSelection/gridRowSelectionSelector.js +2 -2
  176. package/node/hooks/features/rows/gridRowsSelector.js +2 -2
  177. package/node/hooks/features/rows/useGridParamsApi.js +9 -15
  178. package/node/hooks/features/sorting/gridSortingSelector.js +2 -2
  179. package/node/hooks/features/virtualization/useGridVirtualScroller.js +40 -36
  180. package/node/hooks/utils/index.js +14 -10
  181. package/node/hooks/utils/useGridSelector.js +41 -7
  182. package/node/hooks/utils/useLazyRef.js +17 -0
  183. package/node/hooks/utils/useOnMount.js +15 -0
  184. package/node/index.js +1 -1
  185. package/node/internals/index.js +7 -0
  186. package/node/locales/elGR.js +66 -79
  187. package/node/locales/ptBR.js +12 -13
  188. package/node/utils/Store.js +31 -0
  189. package/node/utils/createSelector.js +77 -8
  190. package/node/utils/doesSupportPreventScroll.js +19 -0
  191. package/node/utils/fastMemo.js +13 -0
  192. package/node/utils/fastObjectShallowCompare.js +38 -0
  193. package/node/utils/keyboardUtils.js +4 -2
  194. package/package.json +2 -2
  195. package/utils/Store.d.ts +11 -0
  196. package/utils/Store.js +24 -0
  197. package/utils/createSelector.d.ts +1 -0
  198. package/utils/createSelector.js +74 -6
  199. package/utils/doesSupportPreventScroll.d.ts +1 -0
  200. package/utils/doesSupportPreventScroll.js +13 -0
  201. package/utils/fastMemo.d.ts +1 -0
  202. package/utils/fastMemo.js +5 -0
  203. package/utils/fastObjectShallowCompare.d.ts +1 -0
  204. package/utils/fastObjectShallowCompare.js +32 -0
  205. package/utils/keyboardUtils.js +4 -2
@@ -183,22 +183,26 @@ export const buildAggregatedFilterApplier = (filterModel, apiRef) => {
183
183
  passingQuickFilterValues: isRowMatchingQuickFilter && isRowMatchingQuickFilter(rowId, shouldApplyFilter)
184
184
  });
185
185
  };
186
- export const passFilterLogic = (allFilterItemResults, allQuickFilterResults, filterModel, apiRef) => {
187
- var _filterModel$quickFil, _filterModel$logicOpe;
188
- const cleanedFilterItems = filterModel.items.filter(item => getFilterCallbackFromItem(item, apiRef) !== null);
189
- const cleanedAllFilterItemResults = allFilterItemResults.filter(result => result != null);
190
- const cleanedAllQuickFilterResults = allQuickFilterResults.filter(result => result != null);
191
-
192
- // Defaultize operators
193
- const quickFilterLogicOperator = (_filterModel$quickFil = filterModel.quickFilterLogicOperator) != null ? _filterModel$quickFil : getDefaultGridFilterModel().quickFilterLogicOperator;
194
- const logicOperator = (_filterModel$logicOpe = filterModel.logicOperator) != null ? _filterModel$logicOpe : getDefaultGridFilterModel().logicOperator;
186
+ const isNotNull = result => result != null;
187
+ const filterModelItems = (cache, apiRef, items) => {
188
+ if (!cache.cleanedFilterItems) {
189
+ cache.cleanedFilterItems = items.filter(item => getFilterCallbackFromItem(item, apiRef) !== null);
190
+ }
191
+ return cache.cleanedFilterItems;
192
+ };
193
+ export const passFilterLogic = (allFilterItemResults, allQuickFilterResults, filterModel, apiRef, cache) => {
194
+ const cleanedFilterItems = filterModelItems(cache, apiRef, filterModel.items);
195
+ const cleanedFilterItemResults = allFilterItemResults.filter(isNotNull);
196
+ const cleanedQuickFilterResults = allQuickFilterResults.filter(isNotNull);
195
197
 
196
198
  // get result for filter items model
197
- if (cleanedAllFilterItemResults.length > 0) {
199
+ if (cleanedFilterItemResults.length > 0) {
200
+ var _filterModel$logicOpe;
198
201
  // Return true if the item pass with one of the rows
199
202
  const filterItemPredicate = item => {
200
- return cleanedAllFilterItemResults.some(filterItemResult => filterItemResult[item.id]);
203
+ return cleanedFilterItemResults.some(filterItemResult => filterItemResult[item.id]);
201
204
  };
205
+ const logicOperator = (_filterModel$logicOpe = filterModel.logicOperator) != null ? _filterModel$logicOpe : getDefaultGridFilterModel().logicOperator;
202
206
  if (logicOperator === GridLogicOperator.And) {
203
207
  const passesAllFilters = cleanedFilterItems.every(filterItemPredicate);
204
208
  if (!passesAllFilters) {
@@ -213,11 +217,13 @@ export const passFilterLogic = (allFilterItemResults, allQuickFilterResults, fil
213
217
  }
214
218
 
215
219
  // get result for quick filter model
216
- if (cleanedAllQuickFilterResults.length > 0 && filterModel.quickFilterValues != null) {
220
+ if (cleanedQuickFilterResults.length > 0 && filterModel.quickFilterValues != null) {
221
+ var _filterModel$quickFil;
217
222
  // Return true if the item pass with one of the rows
218
223
  const quickFilterValuePredicate = value => {
219
- return cleanedAllQuickFilterResults.some(quickFilterValueResult => quickFilterValueResult[value]);
224
+ return cleanedQuickFilterResults.some(quickFilterValueResult => quickFilterValueResult[value]);
220
225
  };
226
+ const quickFilterLogicOperator = (_filterModel$quickFil = filterModel.quickFilterLogicOperator) != null ? _filterModel$quickFil : getDefaultGridFilterModel().quickFilterLogicOperator;
221
227
  if (quickFilterLogicOperator === GridLogicOperator.And) {
222
228
  const passesAllQuickFilterValues = filterModel.quickFilterValues.every(quickFilterValuePredicate);
223
229
  if (!passesAllQuickFilterValues) {
@@ -261,6 +261,7 @@ export const useGridFilter = (apiRef, props) => {
261
261
  const tree = gridRowTreeSelector(apiRef);
262
262
  const rowIds = tree[GRID_ROOT_GROUP_ID].children;
263
263
  const filteredRowsLookup = {};
264
+ const filterCache = {};
264
265
  for (let i = 0; i < rowIds.length; i += 1) {
265
266
  const rowId = rowIds[i];
266
267
  let isRowPassing;
@@ -271,7 +272,7 @@ export const useGridFilter = (apiRef, props) => {
271
272
  passingFilterItems,
272
273
  passingQuickFilterValues
273
274
  } = params.isRowMatchingFilters(rowId);
274
- isRowPassing = passFilterLogic([passingFilterItems], [passingQuickFilterValues], params.filterModel, apiRef);
275
+ isRowPassing = passFilterLogic([passingFilterItems], [passingQuickFilterValues], params.filterModel, apiRef, filterCache);
275
276
  }
276
277
  filteredRowsLookup[rowId] = isRowPassing;
277
278
  }
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { unstable_ownerDocument as ownerDocument } from '@mui/utils';
4
+ import { gridClasses } from '../../../constants/gridClasses';
4
5
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
5
6
  import { useGridLogger } from '../../utils/useGridLogger';
6
7
  import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
@@ -236,7 +237,6 @@ export const useGridFocus = (apiRef, props) => {
236
237
  }
237
238
  apiRef.current.setColumnHeaderFocus(field, event);
238
239
  }, [apiRef]);
239
- const focussedColumnGroup = unstable_gridFocusColumnGroupHeaderSelector(apiRef);
240
240
  const handleColumnGroupHeaderFocus = React.useCallback(({
241
241
  fields,
242
242
  depth
@@ -244,13 +244,18 @@ export const useGridFocus = (apiRef, props) => {
244
244
  if (event.target !== event.currentTarget) {
245
245
  return;
246
246
  }
247
- if (focussedColumnGroup !== null && focussedColumnGroup.depth === depth && fields.includes(focussedColumnGroup.field)) {
247
+ const focusedColumnGroup = unstable_gridFocusColumnGroupHeaderSelector(apiRef);
248
+ if (focusedColumnGroup !== null && focusedColumnGroup.depth === depth && fields.includes(focusedColumnGroup.field)) {
248
249
  // This group cell has already been focused
249
250
  return;
250
251
  }
251
252
  apiRef.current.setColumnGroupHeaderFocus(fields[0], depth, event);
252
- }, [apiRef, focussedColumnGroup]);
253
- const handleBlur = React.useCallback(() => {
253
+ }, [apiRef]);
254
+ const handleBlur = React.useCallback((_, event) => {
255
+ var _event$relatedTarget;
256
+ if ((_event$relatedTarget = event.relatedTarget) != null && _event$relatedTarget.className.includes(gridClasses.columnHeader)) {
257
+ return;
258
+ }
254
259
  logger.debug(`Clearing focus`);
255
260
  apiRef.current.setState(state => _extends({}, state, {
256
261
  focus: {
@@ -13,7 +13,6 @@ import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPan
13
13
  import { gridPinnedRowsSelector } from '../rows/gridRowsSelector';
14
14
  import { unstable_gridFocusColumnGroupHeaderSelector } from '../focus';
15
15
  import { gridColumnGroupsHeaderMaxDepthSelector } from '../columnGrouping/gridColumnGroupsSelector';
16
- import { useGridSelector } from '../../utils/useGridSelector';
17
16
  import { unstable_gridHeaderFilteringEditFieldSelector, unstable_gridHeaderFilteringMenuSelector } from '../headerFiltering/gridHeaderFilteringSelectors';
18
17
  import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
19
18
  function enrichPageRowsWithPinnedRows(apiRef, rows) {
@@ -322,12 +321,12 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
322
321
  event.preventDefault();
323
322
  }
324
323
  }, [apiRef, currentPageRows.length, goToHeaderFilter, theme.direction, goToHeader, goToCell, getRowIdFromIndex]);
325
- const focusedColumnGroup = useGridSelector(apiRef, unstable_gridFocusColumnGroupHeaderSelector);
326
324
  const handleColumnGroupHeaderKeyDown = React.useCallback((params, event) => {
327
325
  const dimensions = apiRef.current.getRootDimensions();
328
326
  if (!dimensions) {
329
327
  return;
330
328
  }
329
+ const focusedColumnGroup = unstable_gridFocusColumnGroupHeaderSelector(apiRef);
331
330
  if (focusedColumnGroup === null) {
332
331
  return;
333
332
  }
@@ -411,7 +410,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
411
410
  if (shouldPreventDefault) {
412
411
  event.preventDefault();
413
412
  }
414
- }, [apiRef, focusedColumnGroup, currentPageRows.length, goToHeader, goToGroupHeader, goToCell, getRowIdFromIndex]);
413
+ }, [apiRef, currentPageRows.length, goToHeader, goToGroupHeader, goToCell, getRowIdFromIndex]);
415
414
  const handleCellKeyDown = React.useCallback((params, event) => {
416
415
  // Ignore portal
417
416
  if (!event.currentTarget.contains(event.target)) {
@@ -1,4 +1,4 @@
1
- import { createSelector } from '../../../utils/createSelector';
1
+ import { createSelector, createSelectorMemoized } from '../../../utils/createSelector';
2
2
  import { gridFilteredTopLevelRowCountSelector, gridExpandedSortedRowEntriesSelector, gridExpandedSortedRowIdsSelector, gridFilteredSortedTopLevelRowEntriesSelector } from '../filter/gridFilterSelector';
3
3
  import { gridRowMaximumTreeDepthSelector, gridRowTreeSelector } from '../rows/gridRowsSelector';
4
4
  import { getPageCount } from './gridPaginationUtils';
@@ -37,7 +37,7 @@ export const gridPageCountSelector = createSelector(gridPaginationModelSelector,
37
37
  * Get the index of the first and the last row to include in the current page if the pagination is enabled.
38
38
  * @category Pagination
39
39
  */
40
- export const gridPaginationRowRangeSelector = createSelector(gridPaginationModelSelector, gridRowTreeSelector, gridRowMaximumTreeDepthSelector, gridExpandedSortedRowEntriesSelector, gridFilteredSortedTopLevelRowEntriesSelector, (paginationModel, rowTree, rowTreeDepth, visibleSortedRowEntries, visibleSortedTopLevelRowEntries) => {
40
+ export const gridPaginationRowRangeSelector = createSelectorMemoized(gridPaginationModelSelector, gridRowTreeSelector, gridRowMaximumTreeDepthSelector, gridExpandedSortedRowEntriesSelector, gridFilteredSortedTopLevelRowEntriesSelector, (paginationModel, rowTree, rowTreeDepth, visibleSortedRowEntries, visibleSortedTopLevelRowEntries) => {
41
41
  const visibleTopLevelRowCount = visibleSortedTopLevelRowEntries.length;
42
42
  const topLevelFirstRowIndex = Math.min(paginationModel.pageSize * paginationModel.page, visibleTopLevelRowCount - 1);
43
43
  const topLevelLastRowIndex = Math.min(topLevelFirstRowIndex + paginationModel.pageSize - 1, visibleTopLevelRowCount - 1);
@@ -79,7 +79,7 @@ export const gridPaginationRowRangeSelector = createSelector(gridPaginationModel
79
79
  * Get the id and the model of each row to include in the current page if the pagination is enabled.
80
80
  * @category Pagination
81
81
  */
82
- export const gridPaginatedVisibleSortedGridRowEntriesSelector = createSelector(gridExpandedSortedRowEntriesSelector, gridPaginationRowRangeSelector, (visibleSortedRowEntries, paginationRange) => {
82
+ export const gridPaginatedVisibleSortedGridRowEntriesSelector = createSelectorMemoized(gridExpandedSortedRowEntriesSelector, gridPaginationRowRangeSelector, (visibleSortedRowEntries, paginationRange) => {
83
83
  if (!paginationRange) {
84
84
  return [];
85
85
  }
@@ -90,7 +90,7 @@ export const gridPaginatedVisibleSortedGridRowEntriesSelector = createSelector(g
90
90
  * Get the id of each row to include in the current page if the pagination is enabled.
91
91
  * @category Pagination
92
92
  */
93
- export const gridPaginatedVisibleSortedGridRowIdsSelector = createSelector(gridExpandedSortedRowIdsSelector, gridPaginationRowRangeSelector, (visibleSortedRowIds, paginationRange) => {
93
+ export const gridPaginatedVisibleSortedGridRowIdsSelector = createSelectorMemoized(gridExpandedSortedRowIdsSelector, gridPaginationRowRangeSelector, (visibleSortedRowIds, paginationRange) => {
94
94
  if (!paginationRange) {
95
95
  return [];
96
96
  }
@@ -1,9 +1,9 @@
1
- import { createSelector } from '../../../utils/createSelector';
1
+ import { createSelector, createSelectorMemoized } from '../../../utils/createSelector';
2
2
  import { gridRowsLookupSelector } from '../rows/gridRowsSelector';
3
3
  export const gridRowSelectionStateSelector = state => state.rowSelection;
4
4
  export const selectedGridRowsCountSelector = createSelector(gridRowSelectionStateSelector, selection => selection.length);
5
- export const selectedGridRowsSelector = createSelector(gridRowSelectionStateSelector, gridRowsLookupSelector, (selectedRows, rowsLookup) => new Map(selectedRows.map(id => [id, rowsLookup[id]])));
6
- export const selectedIdsLookupSelector = createSelector(gridRowSelectionStateSelector, selection => selection.reduce((lookup, rowId) => {
5
+ export const selectedGridRowsSelector = createSelectorMemoized(gridRowSelectionStateSelector, gridRowsLookupSelector, (selectedRows, rowsLookup) => new Map(selectedRows.map(id => [id, rowsLookup[id]])));
6
+ export const selectedIdsLookupSelector = createSelectorMemoized(gridRowSelectionStateSelector, selection => selection.reduce((lookup, rowId) => {
7
7
  lookup[rowId] = rowId;
8
8
  return lookup;
9
9
  }, {}));
@@ -1,4 +1,4 @@
1
- import { createSelector } from '../../../utils/createSelector';
1
+ import { createSelector, createSelectorMemoized } from '../../../utils/createSelector';
2
2
  const gridRowsStateSelector = state => state.rows;
3
3
  export const gridRowCountSelector = createSelector(gridRowsStateSelector, rows => rows.totalRowCount);
4
4
  export const gridRowsLoadingSelector = createSelector(gridRowsStateSelector, rows => rows.loading);
@@ -10,7 +10,7 @@ export const gridRowsDataRowIdToIdLookupSelector = createSelector(gridRowsStateS
10
10
  export const gridRowTreeSelector = createSelector(gridRowsStateSelector, rows => rows.tree);
11
11
  export const gridRowGroupingNameSelector = createSelector(gridRowsStateSelector, rows => rows.groupingName);
12
12
  export const gridRowTreeDepthsSelector = createSelector(gridRowsStateSelector, rows => rows.treeDepths);
13
- export const gridRowMaximumTreeDepthSelector = createSelector(gridRowsStateSelector, rows => {
13
+ export const gridRowMaximumTreeDepthSelector = createSelectorMemoized(gridRowsStateSelector, rows => {
14
14
  const entries = Object.entries(rows.treeDepths);
15
15
  if (entries.length === 0) {
16
16
  return 1;
@@ -27,7 +27,7 @@ export const gridAdditionalRowGroupsSelector = createSelector(gridRowsStateSelec
27
27
  /**
28
28
  * @ignore - do not document.
29
29
  */
30
- export const gridPinnedRowsSelector = createSelector(gridAdditionalRowGroupsSelector, additionalRowGroups => {
30
+ export const gridPinnedRowsSelector = createSelectorMemoized(gridAdditionalRowGroupsSelector, additionalRowGroups => {
31
31
  var _rawPinnedRows$bottom, _rawPinnedRows$top;
32
32
  const rawPinnedRows = additionalRowGroups == null ? void 0 : additionalRowGroups.pinnedRows;
33
33
  return {
@@ -1,5 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
3
+ export declare class MissingRowIdError extends Error {
4
+ }
3
5
  /**
4
6
  * @requires useGridColumns (method)
5
7
  * @requires useGridRows (method)
@@ -2,11 +2,7 @@ import * as React from 'react';
2
2
  import { getGridCellElement, getGridColumnHeaderElement, getGridRowElement } from '../../../utils/domUtils';
3
3
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
4
4
  import { gridFocusCellSelector, gridTabIndexCellSelector } from '../focus/gridFocusStateSelector';
5
- let warnedOnceMissingColumn = false;
6
- function warnMissingColumn(field) {
7
- console.warn([`MUI: You are calling getValue('${field}') but the column \`${field}\` is not defined.`, `Instead, you can access the data from \`params.row.${field}\`.`].join('\n'));
8
- warnedOnceMissingColumn = true;
9
- }
5
+ export class MissingRowIdError extends Error {}
10
6
 
11
7
  /**
12
8
  * @requires useGridColumns (method)
@@ -24,7 +20,7 @@ export function useGridParamsApi(apiRef) {
24
20
  const getRowParams = React.useCallback(id => {
25
21
  const row = apiRef.current.getRow(id);
26
22
  if (!row) {
27
- throw new Error(`No row with id #${id} found`);
23
+ throw new MissingRowIdError(`No row with id #${id} found`);
28
24
  }
29
25
  const params = {
30
26
  id,
@@ -37,7 +33,7 @@ export function useGridParamsApi(apiRef) {
37
33
  const row = apiRef.current.getRow(id);
38
34
  const rowNode = apiRef.current.getRowNode(id);
39
35
  if (!row || !rowNode) {
40
- throw new Error(`No row with id #${id} found`);
36
+ throw new MissingRowIdError(`No row with id #${id} found`);
41
37
  }
42
38
  const cellFocus = gridFocusCellSelector(apiRef);
43
39
  const cellTabIndex = gridTabIndexCellSelector(apiRef);
@@ -61,7 +57,7 @@ export function useGridParamsApi(apiRef) {
61
57
  const row = apiRef.current.getRow(id);
62
58
  const rowNode = apiRef.current.getRowNode(id);
63
59
  if (!row || !rowNode) {
64
- throw new Error(`No row with id #${id} found`);
60
+ throw new MissingRowIdError(`No row with id #${id} found`);
65
61
  }
66
62
  const cellFocus = gridFocusCellSelector(apiRef);
67
63
  const cellTabIndex = gridTabIndexCellSelector(apiRef);
@@ -75,7 +71,8 @@ export function useGridParamsApi(apiRef) {
75
71
  hasFocus: cellFocus !== null && cellFocus.field === field && cellFocus.id === id,
76
72
  tabIndex: cellTabIndex && cellTabIndex.field === field && cellTabIndex.id === id ? 0 : -1,
77
73
  value,
78
- formattedValue: value
74
+ formattedValue: value,
75
+ isEditable: false
79
76
  };
80
77
  if (colDef && colDef.valueFormatter) {
81
78
  params.formattedValue = colDef.valueFormatter({
@@ -90,15 +87,10 @@ export function useGridParamsApi(apiRef) {
90
87
  }, [apiRef]);
91
88
  const getCellValue = React.useCallback((id, field) => {
92
89
  const colDef = apiRef.current.getColumn(field);
93
- if (process.env.NODE_ENV !== 'production') {
94
- if (!colDef && !warnedOnceMissingColumn) {
95
- warnMissingColumn(field);
96
- }
97
- }
98
90
  if (!colDef || !colDef.valueGetter) {
99
91
  const rowModel = apiRef.current.getRow(id);
100
92
  if (!rowModel) {
101
- throw new Error(`No row with id #${id} found`);
93
+ throw new MissingRowIdError(`No row with id #${id} found`);
102
94
  }
103
95
  return rowModel[field];
104
96
  }
@@ -1,4 +1,4 @@
1
- import { createSelector } from '../../../utils/createSelector';
1
+ import { createSelector, createSelectorMemoized } from '../../../utils/createSelector';
2
2
  import { gridRowsLookupSelector } from '../rows/gridRowsSelector';
3
3
 
4
4
  /**
@@ -17,7 +17,7 @@ export const gridSortedRowIdsSelector = createSelector(gridSortingStateSelector,
17
17
  * Get the id and the model of the rows after the sorting process.
18
18
  * @category Sorting
19
19
  */
20
- export const gridSortedRowEntriesSelector = createSelector(gridSortedRowIdsSelector, gridRowsLookupSelector,
20
+ export const gridSortedRowEntriesSelector = createSelectorMemoized(gridSortedRowIdsSelector, gridRowsLookupSelector,
21
21
  // TODO rows v6: Is this the best approach ?
22
22
  (sortedIds, idRowsLookup) => sortedIds.map(id => {
23
23
  var _idRowsLookup$id;
@@ -36,7 +36,7 @@ export const gridSortModelSelector = createSelector(gridSortingStateSelector, so
36
36
  * @category Sorting
37
37
  * @ignore - do not document.
38
38
  */
39
- export const gridSortColumnLookupSelector = createSelector(gridSortModelSelector, sortModel => {
39
+ export const gridSortColumnLookupSelector = createSelectorMemoized(gridSortModelSelector, sortModel => {
40
40
  const result = sortModel.reduce((res, sortItem, index) => {
41
41
  res[sortItem.field] = {
42
42
  sortDirection: sortItem.sort,