@mui/x-data-grid 7.1.1 → 7.3.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 (145) hide show
  1. package/CHANGELOG.md +211 -0
  2. package/DataGrid/DataGrid.js +19 -0
  3. package/components/GridPagination.d.ts +4 -1
  4. package/components/GridPagination.js +60 -9
  5. package/components/GridRow.js +4 -1
  6. package/components/GridScrollArea.js +1 -1
  7. package/components/cell/GridCell.d.ts +1 -0
  8. package/components/cell/GridCell.js +4 -2
  9. package/components/columnHeaders/GridColumnGroupHeader.d.ts +1 -0
  10. package/components/columnHeaders/GridColumnGroupHeader.js +3 -2
  11. package/components/columnHeaders/GridColumnHeaderItem.d.ts +2 -0
  12. package/components/columnHeaders/GridColumnHeaderItem.js +9 -4
  13. package/components/containers/GridRootStyles.js +8 -4
  14. package/components/index.d.ts +1 -1
  15. package/components/index.js +1 -1
  16. package/components/panel/GridPanel.js +3 -1
  17. package/components/panel/filterPanel/GridFilterInputDate.js +5 -1
  18. package/constants/gridClasses.d.ts +11 -2
  19. package/constants/gridClasses.js +1 -1
  20. package/hooks/core/useGridInitialization.js +1 -1
  21. package/hooks/core/useGridStateInitialization.d.ts +1 -2
  22. package/hooks/core/useGridStateInitialization.js +6 -10
  23. package/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -5
  24. package/hooks/features/columnResize/useGridColumnResize.js +75 -61
  25. package/hooks/features/columns/gridColumnsUtils.d.ts +2 -1
  26. package/hooks/features/columns/gridColumnsUtils.js +4 -3
  27. package/hooks/features/density/useGridDensity.d.ts +1 -1
  28. package/hooks/features/density/useGridDensity.js +30 -4
  29. package/hooks/features/dimensions/gridDimensionsApi.d.ts +5 -1
  30. package/hooks/features/dimensions/useGridDimensions.d.ts +1 -1
  31. package/hooks/features/dimensions/useGridDimensions.js +5 -2
  32. package/hooks/features/editing/useGridCellEditing.js +17 -2
  33. package/hooks/features/editing/useGridRowEditing.js +3 -1
  34. package/hooks/features/export/serializers/csvSerializer.js +6 -5
  35. package/hooks/features/export/useGridPrintExport.d.ts +1 -1
  36. package/hooks/features/export/useGridPrintExport.js +2 -2
  37. package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +2 -2
  38. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +2 -2
  39. package/hooks/features/pagination/gridPaginationInterfaces.d.ts +14 -2
  40. package/hooks/features/pagination/gridPaginationSelector.d.ts +5 -0
  41. package/hooks/features/pagination/gridPaginationSelector.js +7 -1
  42. package/hooks/features/pagination/gridPaginationUtils.d.ts +1 -2
  43. package/hooks/features/pagination/gridPaginationUtils.js +5 -3
  44. package/hooks/features/pagination/useGridPagination.d.ts +1 -1
  45. package/hooks/features/pagination/useGridPagination.js +5 -1
  46. package/hooks/features/pagination/useGridPaginationMeta.d.ts +4 -0
  47. package/hooks/features/pagination/useGridPaginationMeta.js +77 -0
  48. package/hooks/features/pagination/useGridPaginationModel.js +2 -1
  49. package/hooks/features/pagination/useGridRowCount.d.ts +0 -4
  50. package/hooks/features/pagination/useGridRowCount.js +32 -18
  51. package/hooks/utils/useGridSelector.d.ts +1 -1
  52. package/index.js +1 -1
  53. package/internals/index.d.ts +1 -1
  54. package/internals/utils/propValidation.js +1 -1
  55. package/locales/daDK.js +3 -4
  56. package/locales/deDE.js +3 -4
  57. package/locales/frFR.js +5 -6
  58. package/locales/svSE.js +3 -4
  59. package/models/api/gridApiCommon.d.ts +1 -1
  60. package/models/api/gridCallbackDetails.d.ts +5 -0
  61. package/models/api/gridLocaleTextApi.d.ts +7 -3
  62. package/models/api/index.d.ts +1 -1
  63. package/models/api/index.js +0 -1
  64. package/models/events/gridEventLookup.d.ts +7 -1
  65. package/models/gridPaginationProps.d.ts +3 -0
  66. package/models/props/DataGridProps.d.ts +26 -8
  67. package/modern/DataGrid/DataGrid.js +19 -0
  68. package/modern/components/GridPagination.js +60 -9
  69. package/modern/components/GridRow.js +4 -1
  70. package/modern/components/GridScrollArea.js +1 -1
  71. package/modern/components/cell/GridCell.js +4 -2
  72. package/modern/components/columnHeaders/GridColumnGroupHeader.js +3 -2
  73. package/modern/components/columnHeaders/GridColumnHeaderItem.js +9 -4
  74. package/modern/components/containers/GridRootStyles.js +8 -4
  75. package/modern/components/index.js +1 -1
  76. package/modern/components/panel/GridPanel.js +3 -1
  77. package/modern/components/panel/filterPanel/GridFilterInputDate.js +5 -1
  78. package/modern/constants/gridClasses.js +1 -1
  79. package/modern/hooks/core/useGridInitialization.js +1 -1
  80. package/modern/hooks/core/useGridStateInitialization.js +6 -10
  81. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -5
  82. package/modern/hooks/features/columnResize/useGridColumnResize.js +75 -61
  83. package/modern/hooks/features/columns/gridColumnsUtils.js +4 -3
  84. package/modern/hooks/features/density/useGridDensity.js +30 -4
  85. package/modern/hooks/features/dimensions/useGridDimensions.js +5 -2
  86. package/modern/hooks/features/editing/useGridCellEditing.js +17 -2
  87. package/modern/hooks/features/editing/useGridRowEditing.js +3 -1
  88. package/modern/hooks/features/export/serializers/csvSerializer.js +6 -5
  89. package/modern/hooks/features/export/useGridPrintExport.js +2 -2
  90. package/modern/hooks/features/pagination/gridPaginationSelector.js +7 -1
  91. package/modern/hooks/features/pagination/gridPaginationUtils.js +5 -3
  92. package/modern/hooks/features/pagination/useGridPagination.js +5 -1
  93. package/modern/hooks/features/pagination/useGridPaginationMeta.js +77 -0
  94. package/modern/hooks/features/pagination/useGridPaginationModel.js +2 -1
  95. package/modern/hooks/features/pagination/useGridRowCount.js +32 -18
  96. package/modern/index.js +1 -1
  97. package/modern/internals/utils/propValidation.js +1 -1
  98. package/modern/locales/daDK.js +3 -4
  99. package/modern/locales/deDE.js +3 -4
  100. package/modern/locales/frFR.js +5 -6
  101. package/modern/locales/svSE.js +3 -4
  102. package/modern/models/api/index.js +0 -1
  103. package/modern/utils/cellBorderUtils.js +15 -2
  104. package/node/DataGrid/DataGrid.js +19 -0
  105. package/node/components/GridPagination.js +59 -8
  106. package/node/components/GridRow.js +4 -1
  107. package/node/components/GridScrollArea.js +1 -1
  108. package/node/components/cell/GridCell.js +4 -2
  109. package/node/components/columnHeaders/GridColumnGroupHeader.js +3 -2
  110. package/node/components/columnHeaders/GridColumnHeaderItem.js +8 -3
  111. package/node/components/containers/GridRootStyles.js +8 -4
  112. package/node/components/index.js +27 -10
  113. package/node/components/panel/GridPanel.js +3 -1
  114. package/node/components/panel/filterPanel/GridFilterInputDate.js +5 -1
  115. package/node/constants/gridClasses.js +1 -1
  116. package/node/hooks/core/useGridInitialization.js +1 -1
  117. package/node/hooks/core/useGridStateInitialization.js +6 -10
  118. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -5
  119. package/node/hooks/features/columnResize/useGridColumnResize.js +76 -62
  120. package/node/hooks/features/columns/gridColumnsUtils.js +4 -3
  121. package/node/hooks/features/density/useGridDensity.js +30 -4
  122. package/node/hooks/features/dimensions/useGridDimensions.js +5 -2
  123. package/node/hooks/features/editing/useGridCellEditing.js +17 -2
  124. package/node/hooks/features/editing/useGridRowEditing.js +3 -1
  125. package/node/hooks/features/export/serializers/csvSerializer.js +6 -5
  126. package/node/hooks/features/export/useGridPrintExport.js +2 -2
  127. package/node/hooks/features/pagination/gridPaginationSelector.js +8 -2
  128. package/node/hooks/features/pagination/gridPaginationUtils.js +6 -4
  129. package/node/hooks/features/pagination/useGridPagination.js +5 -1
  130. package/node/hooks/features/pagination/useGridPaginationMeta.js +87 -0
  131. package/node/hooks/features/pagination/useGridPaginationModel.js +2 -1
  132. package/node/hooks/features/pagination/useGridRowCount.js +30 -15
  133. package/node/index.js +1 -1
  134. package/node/internals/utils/propValidation.js +1 -1
  135. package/node/locales/daDK.js +3 -4
  136. package/node/locales/deDE.js +3 -4
  137. package/node/locales/frFR.js +5 -6
  138. package/node/locales/svSE.js +3 -4
  139. package/node/models/api/index.js +0 -11
  140. package/node/utils/cellBorderUtils.js +15 -2
  141. package/package.json +1 -1
  142. package/themeAugmentation/overrides.d.ts +6 -0
  143. package/utils/cellBorderUtils.d.ts +1 -1
  144. package/utils/cellBorderUtils.js +15 -2
  145. package/utils/getGridLocalization.d.ts +1 -1
@@ -1,19 +1,17 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
+ import useLazyRef from '@mui/utils/useLazyRef';
3
4
  import { gridFilteredTopLevelRowCountSelector } from '../filter';
4
- import { useGridLogger, useGridSelector, useGridApiMethod } from '../../utils';
5
+ import { useGridLogger, useGridSelector, useGridApiMethod, useGridApiEventHandler } from '../../utils';
5
6
  import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
6
- import { gridPaginationRowCountSelector } from './gridPaginationSelector';
7
- import { noRowCountInServerMode } from './gridPaginationUtils';
8
-
9
- /**
10
- * @requires useGridFilter (state)
11
- * @requires useGridDimensions (event) - can be after
12
- */
7
+ import { gridPaginationRowCountSelector, gridPaginationMetaSelector, gridPaginationModelSelector } from './gridPaginationSelector';
13
8
  export const useGridRowCount = (apiRef, props) => {
14
9
  const logger = useGridLogger(apiRef, 'useGridRowCount');
15
10
  const visibleTopLevelRowCount = useGridSelector(apiRef, gridFilteredTopLevelRowCountSelector);
16
- const rowCount = useGridSelector(apiRef, gridPaginationRowCountSelector);
11
+ const rowCountState = useGridSelector(apiRef, gridPaginationRowCountSelector);
12
+ const paginationMeta = useGridSelector(apiRef, gridPaginationMetaSelector);
13
+ const paginationModel = useGridSelector(apiRef, gridPaginationModelSelector);
14
+ const previousPageSize = useLazyRef(() => gridPaginationModelSelector(apiRef).pageSize);
17
15
  apiRef.current.registerControlState({
18
16
  stateId: 'paginationRowCount',
19
17
  propModel: props.rowCount,
@@ -26,7 +24,7 @@ export const useGridRowCount = (apiRef, props) => {
26
24
  * API METHODS
27
25
  */
28
26
  const setRowCount = React.useCallback(newRowCount => {
29
- if (rowCount === newRowCount) {
27
+ if (rowCountState === newRowCount) {
30
28
  return;
31
29
  }
32
30
  logger.debug("Setting 'rowCount' to", newRowCount);
@@ -35,7 +33,7 @@ export const useGridRowCount = (apiRef, props) => {
35
33
  rowCount: newRowCount
36
34
  })
37
35
  }));
38
- }, [apiRef, logger, rowCount]);
36
+ }, [apiRef, logger, rowCountState]);
39
37
  const paginationRowCountApi = {
40
38
  setRowCount
41
39
  };
@@ -75,20 +73,36 @@ export const useGridRowCount = (apiRef, props) => {
75
73
  useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
76
74
 
77
75
  /**
78
- * EFFECTS
76
+ * EVENTS
79
77
  */
80
- React.useEffect(() => {
81
- if (process.env.NODE_ENV !== 'production') {
82
- if (props.paginationMode === 'server' && props.rowCount == null) {
83
- noRowCountInServerMode();
78
+ const handlePaginationModelChange = React.useCallback(model => {
79
+ if (props.paginationMode === 'client' || !previousPageSize.current) {
80
+ return;
81
+ }
82
+ if (model.pageSize !== previousPageSize.current) {
83
+ previousPageSize.current = model.pageSize;
84
+ if (rowCountState === -1) {
85
+ // Row count unknown and page size changed, reset the page
86
+ apiRef.current.setPage(0);
84
87
  }
85
88
  }
86
- }, [props.rowCount, props.paginationMode]);
89
+ }, [props.paginationMode, previousPageSize, rowCountState, apiRef]);
90
+ useGridApiEventHandler(apiRef, 'paginationModelChange', handlePaginationModelChange);
91
+
92
+ /**
93
+ * EFFECTS
94
+ */
87
95
  React.useEffect(() => {
88
96
  if (props.paginationMode === 'client') {
89
97
  apiRef.current.setRowCount(visibleTopLevelRowCount);
90
98
  } else if (props.rowCount != null) {
91
99
  apiRef.current.setRowCount(props.rowCount);
92
100
  }
93
- }, [apiRef, visibleTopLevelRowCount, props.paginationMode, props.rowCount]);
101
+ }, [apiRef, props.paginationMode, visibleTopLevelRowCount, props.rowCount]);
102
+ const isLastPage = paginationMeta.hasNextPage === false;
103
+ React.useEffect(() => {
104
+ if (isLastPage && rowCountState === -1) {
105
+ apiRef.current.setRowCount(paginationModel.pageSize * paginationModel.page + visibleTopLevelRowCount);
106
+ }
107
+ }, [apiRef, visibleTopLevelRowCount, isLastPage, rowCountState, paginationModel]);
94
108
  };
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.1.1
2
+ * @mui/x-data-grid v7.3.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,6 +1,6 @@
1
1
  import { isNumber } from '../../utils/utils';
2
2
  import { GridSignature } from '../../hooks/utils/useGridApiEventHandler';
3
- export const propValidatorsDataGrid = [props => props.autoPageSize && props.autoHeight && ['MUI X: `<DataGrid autoPageSize={true} autoHeight={true} />` are not valid props.', 'You cannot use both the `autoPageSize` and `autoHeight` props at the same time because `autoHeight` scales the height of the Data Grid according to the `pageSize`.', '', 'Please remove one of these two props.'].join('\n') || undefined, props => props.signature === GridSignature.DataGrid && props.paginationMode === 'client' && isNumber(props.rowCount) && 'MUI X: Usage of the `rowCount` prop with client side pagination (`paginationMode="client"`) has no effect. `rowCount` is only meant to be used with `paginationMode="server"`.' || undefined];
3
+ export const propValidatorsDataGrid = [props => props.autoPageSize && props.autoHeight && ['MUI X: `<DataGrid autoPageSize={true} autoHeight={true} />` are not valid props.', 'You cannot use both the `autoPageSize` and `autoHeight` props at the same time because `autoHeight` scales the height of the Data Grid according to the `pageSize`.', '', 'Please remove one of these two props.'].join('\n') || undefined, props => props.paginationMode === 'client' && props.paginationMeta != null && ['MUI X: Usage of the `paginationMeta` prop with client-side pagination (`paginationMode="client"`) has no effect.', '`paginationMeta` is only meant to be used with `paginationMode="server"`.'].join('\n') || undefined, props => props.signature === GridSignature.DataGrid && props.paginationMode === 'client' && isNumber(props.rowCount) && ['MUI X: Usage of the `rowCount` prop with client side pagination (`paginationMode="client"`) has no effect.', '`rowCount` is only meant to be used with `paginationMode="server"`.'].join('\n') || undefined, props => props.paginationMode === 'server' && props.rowCount == null && ["MUI X: The `rowCount` prop must be passed using `paginationMode='server'`", 'For more detail, see http://mui.com/components/data-grid/pagination/#index-based-pagination'].join('\n') || undefined];
4
4
  const warnedOnceCache = new Set();
5
5
  const warnOnce = message => {
6
6
  if (!warnedOnceCache.has(message)) {
@@ -30,10 +30,9 @@ const daDKGrid = {
30
30
  toolbarExportPrint: 'Print',
31
31
  toolbarExportExcel: 'Download som Excel',
32
32
  // Columns management text
33
- // columnsManagementSearchTitle: 'Search',
34
- // columnsManagementNoColumns: 'No columns',
35
- // columnsManagementShowHideAllText: 'Show/Hide All',
36
-
33
+ columnsManagementSearchTitle: 'Søg',
34
+ columnsManagementNoColumns: 'Ingen søjler',
35
+ columnsManagementShowHideAllText: 'Vis/Shjul Alle',
37
36
  // Filter panel text
38
37
  filterPanelAddFilter: 'Tilføj filter',
39
38
  filterPanelRemoveAll: 'Fjern alle',
@@ -30,10 +30,9 @@ const deDEGrid = {
30
30
  toolbarExportPrint: 'Drucken',
31
31
  toolbarExportExcel: 'Download als Excel',
32
32
  // Columns management text
33
- // columnsManagementSearchTitle: 'Search',
34
- // columnsManagementNoColumns: 'No columns',
35
- // columnsManagementShowHideAllText: 'Show/Hide All',
36
-
33
+ columnsManagementSearchTitle: 'Suche',
34
+ columnsManagementNoColumns: 'Keine Spalten',
35
+ columnsManagementShowHideAllText: 'Alle anzeigen/verbergen',
37
36
  // Filter panel text
38
37
  filterPanelAddFilter: 'Filter hinzufügen',
39
38
  filterPanelRemoveAll: 'Alle entfernen',
@@ -16,7 +16,7 @@ const frFRGrid = {
16
16
  // Filters toolbar button text
17
17
  toolbarFilters: 'Filtres',
18
18
  toolbarFiltersLabel: 'Afficher les filtres',
19
- toolbarFiltersTooltipHide: 'Cacher les filtres',
19
+ toolbarFiltersTooltipHide: 'Masquer les filtres',
20
20
  toolbarFiltersTooltipShow: 'Afficher les filtres',
21
21
  toolbarFiltersTooltipActive: count => count > 1 ? `${count} filtres actifs` : `${count} filtre actif`,
22
22
  // Quick filter toolbar field
@@ -30,10 +30,9 @@ const frFRGrid = {
30
30
  toolbarExportPrint: 'Imprimer',
31
31
  toolbarExportExcel: 'Télécharger pour Excel',
32
32
  // Columns management text
33
- // columnsManagementSearchTitle: 'Search',
34
- // columnsManagementNoColumns: 'No columns',
35
- // columnsManagementShowHideAllText: 'Show/Hide All',
36
-
33
+ columnsManagementSearchTitle: 'Rechercher',
34
+ columnsManagementNoColumns: 'Pas de colonnes',
35
+ columnsManagementShowHideAllText: 'Afficher/masquer toutes',
37
36
  // Filter panel text
38
37
  filterPanelAddFilter: 'Ajouter un filtre',
39
38
  filterPanelRemoveAll: 'Tout supprimer',
@@ -94,7 +93,7 @@ const frFRGrid = {
94
93
  columnMenuShowColumns: 'Afficher les colonnes',
95
94
  columnMenuManageColumns: 'Gérer les colonnes',
96
95
  columnMenuFilter: 'Filtrer',
97
- columnMenuHideColumn: 'Cacher',
96
+ columnMenuHideColumn: 'Masquer',
98
97
  columnMenuUnsort: 'Annuler le tri',
99
98
  columnMenuSortAsc: 'Tri ascendant',
100
99
  columnMenuSortDesc: 'Tri descendant',
@@ -30,10 +30,9 @@ const svSEGrid = {
30
30
  toolbarExportPrint: 'Skriv ut',
31
31
  toolbarExportExcel: 'Ladda ner som Excel',
32
32
  // Columns management text
33
- // columnsManagementSearchTitle: 'Search',
34
- // columnsManagementNoColumns: 'No columns',
35
- // columnsManagementShowHideAllText: 'Show/Hide All',
36
-
33
+ columnsManagementSearchTitle: 'Sök',
34
+ columnsManagementNoColumns: 'Inga kolumner',
35
+ columnsManagementShowHideAllText: 'Visa/Dölj alla',
37
36
  // Filter panel text
38
37
  filterPanelAddFilter: 'Lägg till filter',
39
38
  filterPanelRemoveAll: 'Ta bort alla',
@@ -4,7 +4,6 @@ export * from './gridDensityApi';
4
4
  export * from './gridRowApi';
5
5
  export * from './gridRowSelectionApi';
6
6
  export * from './gridSortApi';
7
- export * from './gridLocaleTextApi';
8
7
  export * from './gridCsvExportApi';
9
8
  export * from './gridFilterApi';
10
9
  export * from './gridColumnMenuApi';
@@ -1,7 +1,20 @@
1
1
  import { GridPinnedColumnPosition } from '../hooks/features/columns/gridColumnsInterfaces';
2
- export const shouldCellShowRightBorder = (pinnedPosition, indexInSection, sectionLength, showCellVerticalBorderRootProp) => {
2
+ export const shouldCellShowRightBorder = (pinnedPosition, indexInSection, sectionLength, showCellVerticalBorderRootProp, gridHasFiller) => {
3
3
  const isSectionLastCell = indexInSection === sectionLength - 1;
4
- return showCellVerticalBorderRootProp && (pinnedPosition !== GridPinnedColumnPosition.LEFT ? !isSectionLastCell : true) || pinnedPosition === GridPinnedColumnPosition.LEFT && isSectionLastCell;
4
+ if (pinnedPosition === GridPinnedColumnPosition.LEFT && isSectionLastCell) {
5
+ return true;
6
+ }
7
+ if (showCellVerticalBorderRootProp) {
8
+ if (pinnedPosition === GridPinnedColumnPosition.LEFT) {
9
+ return true;
10
+ }
11
+ if (pinnedPosition === GridPinnedColumnPosition.RIGHT) {
12
+ return !isSectionLastCell;
13
+ }
14
+ // pinnedPosition === undefined, middle section
15
+ return !isSectionLastCell || gridHasFiller;
16
+ }
17
+ return false;
5
18
  };
6
19
  export const shouldCellShowLeftBorder = (pinnedPosition, indexInSection) => {
7
20
  return pinnedPosition === GridPinnedColumnPosition.RIGHT && indexInSection === 0;
@@ -193,6 +193,12 @@ DataGridRaw.propTypes = {
193
193
  * @default "cell"
194
194
  */
195
195
  editMode: _propTypes.default.oneOf(['cell', 'row']),
196
+ /**
197
+ * Use if the actual rowCount is not known upfront, but an estimation is available.
198
+ * If some rows have children (for instance in the tree data), this number represents the amount of top level rows.
199
+ * Applicable only with `paginationMode="server"` and when `rowCount="-1"`
200
+ */
201
+ estimatedRowCount: _propTypes.default.number,
196
202
  /**
197
203
  * Unstable features, breaking changes might be introduced.
198
204
  * For each feature, if the flag is not explicitly set to `true`, the feature will be fully disabled and any property / method call will not have any effect.
@@ -494,6 +500,11 @@ DataGridRaw.propTypes = {
494
500
  * @param {GridCallbackDetails} details Additional details for this callback.
495
501
  */
496
502
  onMenuOpen: _propTypes.default.func,
503
+ /**
504
+ * Callback fired when the pagination meta has changed.
505
+ * @param {GridPaginationMeta} paginationMeta Updated pagination meta.
506
+ */
507
+ onPaginationMetaChange: _propTypes.default.func,
497
508
  /**
498
509
  * Callback fired when the pagination model has changed.
499
510
  * @param {GridPaginationModel} model Updated pagination model.
@@ -593,6 +604,13 @@ DataGridRaw.propTypes = {
593
604
  value: _propTypes.default.number.isRequired
594
605
  })]).isRequired),
595
606
  pagination: _propTypes.default.oneOf([true]),
607
+ /**
608
+ * The extra information about the pagination state of the Data Grid.
609
+ * Only applicable with `paginationMode="server"`.
610
+ */
611
+ paginationMeta: _propTypes.default.shape({
612
+ hasNextPage: _propTypes.default.bool
613
+ }),
596
614
  /**
597
615
  * Pagination can be processed on the server or client-side.
598
616
  * Set it to 'client' if you would like to handle the pagination on the client-side.
@@ -628,6 +646,7 @@ DataGridRaw.propTypes = {
628
646
  /**
629
647
  * Set the total number of rows, if it is different from the length of the value `rows` prop.
630
648
  * If some rows have children (for instance in the tree data), this number represents the amount of top level rows.
649
+ * Only works with `paginationMode="server"`, ignored when `paginationMode="client"`.
631
650
  */
632
651
  rowCount: _propTypes.default.number,
633
652
  /**
@@ -7,9 +7,9 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.GridPagination = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var React = _interopRequireWildcard(require("react"));
10
+ var _styles = require("@mui/material/styles");
10
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
12
  var _TablePagination = _interopRequireWildcard(require("@mui/material/TablePagination"));
12
- var _styles = require("@mui/material/styles");
13
13
  var _useGridSelector = require("../hooks/utils/useGridSelector");
14
14
  var _useGridApiContext = require("../hooks/utils/useGridApiContext");
15
15
  var _useGridRootProps = require("../hooks/utils/useGridRootProps");
@@ -33,6 +33,31 @@ const GridPaginationRoot = (0, _styles.styled)(_TablePagination.default)(({
33
33
  }
34
34
  }
35
35
  }));
36
+ const wrapLabelDisplayedRows = (labelDisplayedRows, estimated) => {
37
+ return ({
38
+ from,
39
+ to,
40
+ count,
41
+ page
42
+ }) => labelDisplayedRows({
43
+ from,
44
+ to,
45
+ count,
46
+ page,
47
+ estimated
48
+ });
49
+ };
50
+ const defaultLabelDisplayedRows = ({
51
+ from,
52
+ to,
53
+ count,
54
+ estimated
55
+ }) => {
56
+ if (!estimated) {
57
+ return `${from}–${to} of ${count !== -1 ? count : `more than ${to}`}`;
58
+ }
59
+ return `${from}–${to} of ${count !== -1 ? count : `more than ${estimated > to ? estimated : to}`}`;
60
+ };
36
61
 
37
62
  // A mutable version of a readonly array.
38
63
 
@@ -41,10 +66,32 @@ const GridPagination = exports.GridPagination = /*#__PURE__*/React.forwardRef(fu
41
66
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
42
67
  const paginationModel = (0, _useGridSelector.useGridSelector)(apiRef, _gridPaginationSelector.gridPaginationModelSelector);
43
68
  const rowCount = (0, _useGridSelector.useGridSelector)(apiRef, _gridPaginationSelector.gridPaginationRowCountSelector);
44
- const lastPage = React.useMemo(() => {
45
- const calculatedValue = Math.ceil(rowCount / (paginationModel.pageSize || 1)) - 1;
46
- return Math.max(0, calculatedValue);
47
- }, [rowCount, paginationModel.pageSize]);
69
+ const pageCount = (0, _useGridSelector.useGridSelector)(apiRef, _gridPaginationSelector.gridPageCountSelector);
70
+ const {
71
+ paginationMode,
72
+ loading,
73
+ estimatedRowCount
74
+ } = rootProps;
75
+ const computedProps = React.useMemo(() => {
76
+ if (rowCount === -1 && paginationMode === 'server' && loading) {
77
+ return {
78
+ backIconButtonProps: {
79
+ disabled: true
80
+ },
81
+ nextIconButtonProps: {
82
+ disabled: true
83
+ }
84
+ };
85
+ }
86
+ return {};
87
+ }, [loading, paginationMode, rowCount]);
88
+ const lastPage = React.useMemo(() => Math.max(0, pageCount - 1), [pageCount]);
89
+ const computedPage = React.useMemo(() => {
90
+ if (rowCount === -1) {
91
+ return paginationModel.page;
92
+ }
93
+ return paginationModel.page <= lastPage ? paginationModel.page : lastPage;
94
+ }, [lastPage, paginationModel.page, rowCount]);
48
95
  const handlePageSizeChange = React.useCallback(event => {
49
96
  const pageSize = Number(event.target.value);
50
97
  apiRef.current.setPageSize(pageSize);
@@ -70,16 +117,18 @@ const GridPagination = exports.GridPagination = /*#__PURE__*/React.forwardRef(fu
70
117
  const warnedOnceMissingInPageSizeOptions = React.useRef(false);
71
118
  const pageSize = rootProps.paginationModel?.pageSize ?? paginationModel.pageSize;
72
119
  if (!warnedOnceMissingInPageSizeOptions.current && !rootProps.autoPageSize && !isPageSizeIncludedInPageSizeOptions(pageSize)) {
73
- console.warn([`MUI X: The page size \`${paginationModel.pageSize}\` is not preset in the \`pageSizeOptions\`.`, `Add it to show the pagination select.`].join('\n'));
120
+ console.warn([`MUI X: The page size \`${paginationModel.pageSize}\` is not present in the \`pageSizeOptions\`.`, `Add it to show the pagination select.`].join('\n'));
74
121
  warnedOnceMissingInPageSizeOptions.current = true;
75
122
  }
76
123
  }
77
124
  const pageSizeOptions = isPageSizeIncludedInPageSizeOptions(paginationModel.pageSize) ? rootProps.pageSizeOptions : [];
125
+ const locales = apiRef.current.getLocaleText('MuiTablePagination');
126
+ const wrappedLabelDisplayedRows = wrapLabelDisplayedRows(locales.labelDisplayedRows || defaultLabelDisplayedRows, estimatedRowCount);
78
127
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridPaginationRoot, (0, _extends2.default)({
79
128
  ref: ref,
80
129
  component: "div",
81
130
  count: rowCount,
82
- page: paginationModel.page <= lastPage ? paginationModel.page : lastPage
131
+ page: computedPage
83
132
  // TODO: Remove the cast once the type is fixed in Material UI and that the min Material UI version
84
133
  // for x-data-grid is past the fix.
85
134
  // Note that Material UI will not mutate the array, so this is safe.
@@ -88,7 +137,9 @@ const GridPagination = exports.GridPagination = /*#__PURE__*/React.forwardRef(fu
88
137
  rowsPerPage: paginationModel.pageSize,
89
138
  onPageChange: handlePageChange,
90
139
  onRowsPerPageChange: handlePageSizeChange
91
- }, apiRef.current.getLocaleText('MuiTablePagination'), props));
140
+ }, computedProps, locales, {
141
+ labelDisplayedRows: wrappedLabelDisplayedRows
142
+ }, props));
92
143
  });
93
144
  process.env.NODE_ENV !== "production" ? GridPagination.propTypes = {
94
145
  // ----------------------------- Warning --------------------------------
@@ -101,6 +101,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
101
101
  const handleRef = (0, _utils.unstable_useForkRef)(ref, refProp);
102
102
  const rowNode = apiRef.current.getRowNode(rowId);
103
103
  const scrollbarWidth = dimensions.hasScrollY ? dimensions.scrollbarSize : 0;
104
+ const gridHasFiller = dimensions.columnsTotalWidth < dimensions.viewportOuterSize.width;
104
105
  const hasFocusCell = focusedColumnIndex !== undefined;
105
106
  const hasVirtualFocusCellLeft = hasFocusCell && focusedColumnIndex >= pinnedColumns.left.length && focusedColumnIndex < renderContext.firstColumnIndex;
106
107
  const hasVirtualFocusCellRight = hasFocusCell && focusedColumnIndex < visibleColumns.length - pinnedColumns.right.length && focusedColumnIndex >= renderContext.lastColumnIndex;
@@ -292,7 +293,8 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
292
293
  pinnedOffset: pinnedOffset,
293
294
  pinnedPosition: pinnedPosition,
294
295
  sectionIndex: indexInSection,
295
- sectionLength: sectionLength
296
+ sectionLength: sectionLength,
297
+ gridHasFiller: gridHasFiller
296
298
  }, slotProps?.cell), column.field);
297
299
  };
298
300
 
@@ -372,6 +374,7 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
372
374
  }).isRequired,
373
375
  hasScrollX: _propTypes.default.bool.isRequired,
374
376
  hasScrollY: _propTypes.default.bool.isRequired,
377
+ headerFilterHeight: _propTypes.default.number.isRequired,
375
378
  headerHeight: _propTypes.default.number.isRequired,
376
379
  headersTotalHeight: _propTypes.default.number.isRequired,
377
380
  isReady: _propTypes.default.bool.isRequired,
@@ -91,7 +91,7 @@ function GridScrollAreaRaw(props) {
91
91
  scrollDirection
92
92
  });
93
93
  const classes = useUtilityClasses(ownerState);
94
- const totalHeaderHeight = (0, _gridColumnsUtils.getTotalHeaderHeight)(apiRef, rootProps.columnHeaderHeight);
94
+ const totalHeaderHeight = (0, _gridColumnsUtils.getTotalHeaderHeight)(apiRef, rootProps);
95
95
  const headerHeight = Math.floor(rootProps.columnHeaderHeight * densityFactor);
96
96
  const style = {
97
97
  height: headerHeight,
@@ -23,7 +23,7 @@ var _useGridParamsApi = require("../../hooks/features/rows/useGridParamsApi");
23
23
  var _cellBorderUtils = require("../../utils/cellBorderUtils");
24
24
  var _gridColumnsInterfaces = require("../../hooks/features/columns/gridColumnsInterfaces");
25
25
  var _jsxRuntime = require("react/jsx-runtime");
26
- const _excluded = ["column", "rowId", "editCellState", "align", "children", "colIndex", "width", "className", "style", "gridHasScrollX", "colSpan", "disableDragEvents", "isNotVisible", "pinnedOffset", "pinnedPosition", "sectionIndex", "sectionLength", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
26
+ const _excluded = ["column", "rowId", "editCellState", "align", "children", "colIndex", "width", "className", "style", "gridHasScrollX", "colSpan", "disableDragEvents", "isNotVisible", "pinnedOffset", "pinnedPosition", "sectionIndex", "sectionLength", "gridHasFiller", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
27
27
  _excluded2 = ["changeReason", "unstable_updateValueOnRender"];
28
28
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
29
29
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -101,6 +101,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
101
101
  pinnedPosition,
102
102
  sectionIndex,
103
103
  sectionLength,
104
+ gridHasFiller,
104
105
  onClick,
105
106
  onDoubleClick,
106
107
  onMouseDown,
@@ -171,7 +172,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
171
172
  const isSelectionMode = rootProps.cellSelection ?? false;
172
173
  const position = gridPinnedColumnPositionLookup[pinnedPosition];
173
174
  const showLeftBorder = (0, _cellBorderUtils.shouldCellShowLeftBorder)(position, sectionIndex);
174
- const showRightBorder = (0, _cellBorderUtils.shouldCellShowRightBorder)(position, sectionIndex, sectionLength, rootProps.showCellVerticalBorder);
175
+ const showRightBorder = (0, _cellBorderUtils.shouldCellShowRightBorder)(position, sectionIndex, sectionLength, rootProps.showCellVerticalBorder, gridHasFiller);
175
176
  const ownerState = {
176
177
  align,
177
178
  showLeftBorder,
@@ -337,6 +338,7 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
337
338
  isValidating: _propTypes.default.bool,
338
339
  value: _propTypes.default.any
339
340
  }),
341
+ gridHasFiller: _propTypes.default.bool.isRequired,
340
342
  isNotVisible: _propTypes.default.bool.isRequired,
341
343
  onClick: _propTypes.default.func,
342
344
  onDoubleClick: _propTypes.default.func,
@@ -52,7 +52,8 @@ function GridColumnGroupHeader(props) {
52
52
  pinnedPosition,
53
53
  style,
54
54
  indexInSection,
55
- sectionLength
55
+ sectionLength,
56
+ gridHasFiller
56
57
  } = props;
57
58
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
58
59
  const headerCellRef = React.useRef(null);
@@ -80,7 +81,7 @@ function GridColumnGroupHeader(props) {
80
81
  headerComponent = render(renderParams);
81
82
  }
82
83
  const showLeftBorder = (0, _cellBorderUtils.shouldCellShowLeftBorder)(pinnedPosition, indexInSection);
83
- const showRightBorder = (0, _cellBorderUtils.shouldCellShowRightBorder)(pinnedPosition, indexInSection, sectionLength, rootProps.showCellVerticalBorder);
84
+ const showRightBorder = (0, _cellBorderUtils.shouldCellShowRightBorder)(pinnedPosition, indexInSection, sectionLength, rootProps.showCellVerticalBorder, gridHasFiller);
84
85
  const ownerState = (0, _extends2.default)({}, props, {
85
86
  classes: rootProps.classes,
86
87
  showLeftBorder,
@@ -8,6 +8,7 @@ exports.GridColumnHeaderItem = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var React = _interopRequireWildcard(require("react"));
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
+ var _clsx = _interopRequireDefault(require("clsx"));
11
12
  var _utils = require("@mui/utils");
12
13
  var _fastMemo = require("../../utils/fastMemo");
13
14
  var _useGridPrivateApiContext = require("../../hooks/utils/useGridPrivateApiContext");
@@ -52,6 +53,7 @@ function GridColumnHeaderItem(props) {
52
53
  colIndex,
53
54
  headerHeight,
54
55
  isResizing,
56
+ isLast,
55
57
  sortDirection,
56
58
  sortIndex,
57
59
  filterItemsCounter,
@@ -62,7 +64,8 @@ function GridColumnHeaderItem(props) {
62
64
  style,
63
65
  pinnedPosition,
64
66
  indexInSection,
65
- sectionLength
67
+ sectionLength,
68
+ gridHasFiller
66
69
  } = props;
67
70
  const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
68
71
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
@@ -77,7 +80,7 @@ function GridColumnHeaderItem(props) {
77
80
  headerComponent = colDef.renderHeader(apiRef.current.getColumnHeaderParams(colDef.field));
78
81
  }
79
82
  const showLeftBorder = (0, _cellBorderUtils.shouldCellShowLeftBorder)(pinnedPosition, indexInSection);
80
- const showRightBorder = (0, _cellBorderUtils.shouldCellShowRightBorder)(pinnedPosition, indexInSection, sectionLength, rootProps.showCellVerticalBorder);
83
+ const showRightBorder = (0, _cellBorderUtils.shouldCellShowRightBorder)(pinnedPosition, indexInSection, sectionLength, rootProps.showCellVerticalBorder, gridHasFiller);
81
84
  const ownerState = (0, _extends2.default)({}, props, {
82
85
  classes: rootProps.classes,
83
86
  showRightBorder,
@@ -189,7 +192,7 @@ function GridColumnHeaderItem(props) {
189
192
  width: colDef.computedWidth,
190
193
  columnMenuIconButton: columnMenuIconButton,
191
194
  columnTitleIconButtons: columnTitleIconButtons,
192
- headerClassName: headerClassName,
195
+ headerClassName: (0, _clsx.default)(headerClassName, isLast && _gridClasses.gridClasses['columnHeader--last']),
193
196
  label: label,
194
197
  resizable: !rootProps.disableColumnResize && !!colDef.resizable,
195
198
  "data-field": colDef.field,
@@ -209,10 +212,12 @@ process.env.NODE_ENV !== "production" ? GridColumnHeaderItem.propTypes = {
209
212
  columnMenuOpen: _propTypes.default.bool.isRequired,
210
213
  disableReorder: _propTypes.default.bool,
211
214
  filterItemsCounter: _propTypes.default.number,
215
+ gridHasFiller: _propTypes.default.bool.isRequired,
212
216
  hasFocus: _propTypes.default.bool,
213
217
  headerHeight: _propTypes.default.number.isRequired,
214
218
  indexInSection: _propTypes.default.number.isRequired,
215
219
  isDragging: _propTypes.default.bool.isRequired,
220
+ isLast: _propTypes.default.bool.isRequired,
216
221
  isResizing: _propTypes.default.bool.isRequired,
217
222
  pinnedPosition: _propTypes.default.oneOf(['left', 'right']),
218
223
  sectionLength: _propTypes.default.number.isRequired,
@@ -158,8 +158,8 @@ const GridRootStyles = exports.GridRootStyles = (0, _styles.styled)('div', {
158
158
  }) => {
159
159
  const borderColor = getBorderColor(t);
160
160
  const radius = t.shape.borderRadius;
161
- const containerBackground = t.vars ? t.vars.palette.background.default : t.palette.background.default;
162
- const pinnedBackground = containerBackground;
161
+ const containerBackground = t.vars ? t.vars.palette.background.default : t.mixins.MuiDataGrid?.containerBackground ?? t.palette.background.default;
162
+ const pinnedBackground = t.mixins.MuiDataGrid?.pinnedBackground ?? containerBackground;
163
163
  const overlayBackground = t.vars ? `rgba(${t.vars.palette.background.defaultChannel} / ${t.vars.palette.action.disabledOpacity})` : (0, _styles.alpha)(t.palette.background.default, t.palette.action.disabledOpacity);
164
164
  const hoverOpacity = (t.vars || t).palette.action.hoverOpacity;
165
165
  const hoverColor = (t.vars || t).palette.action.hover;
@@ -281,7 +281,9 @@ const GridRootStyles = exports.GridRootStyles = (0, _styles.styled)('div', {
281
281
  [`& .${_gridClasses.gridClasses.columnHeader}`]: {
282
282
  position: 'relative',
283
283
  display: 'flex',
284
- alignItems: 'center',
284
+ alignItems: 'center'
285
+ },
286
+ [`& .${_gridClasses.gridClasses['columnHeader--last']}`]: {
285
287
  overflow: 'hidden'
286
288
  },
287
289
  [`& .${_gridClasses.gridClasses['columnHeader--sorted']} .${_gridClasses.gridClasses.iconButtonContainer}, & .${_gridClasses.gridClasses['columnHeader--filtered']} .${_gridClasses.gridClasses.iconButtonContainer}`]: {
@@ -457,7 +459,6 @@ const GridRootStyles = exports.GridRootStyles = (0, _styles.styled)('div', {
457
459
  userSelect: 'none'
458
460
  },
459
461
  [`& .${_gridClasses.gridClasses['row--dynamicHeight']} > .${_gridClasses.gridClasses.cell}`]: {
460
- overflow: 'initial',
461
462
  whiteSpace: 'initial',
462
463
  lineHeight: 'inherit'
463
464
  },
@@ -639,6 +640,9 @@ const GridRootStyles = exports.GridRootStyles = (0, _styles.styled)('div', {
639
640
  },
640
641
  [`& .${_gridClasses.gridClasses.filler}`]: {
641
642
  flex: 1
643
+ },
644
+ [`& .${_gridClasses.gridClasses['filler--borderTop']}`]: {
645
+ borderTop: '1px solid var(--DataGrid-rowBorderColor)'
642
646
  }
643
647
  });
644
648
  return gridStyle;