@mui/x-data-grid 7.2.0 → 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 (109) hide show
  1. package/CHANGELOG.md +125 -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 +1 -0
  6. package/components/GridScrollArea.js +1 -1
  7. package/components/columnHeaders/GridColumnHeaderItem.d.ts +1 -0
  8. package/components/columnHeaders/GridColumnHeaderItem.js +5 -2
  9. package/components/columnHeaders/GridColumnHeaderSeparator.js +1 -1
  10. package/components/containers/GridRootStyles.js +3 -1
  11. package/components/index.d.ts +1 -1
  12. package/components/index.js +1 -1
  13. package/components/panel/GridPanel.js +3 -1
  14. package/constants/gridClasses.d.ts +6 -2
  15. package/constants/gridClasses.js +1 -1
  16. package/hooks/features/columnHeaders/useGridColumnHeaders.js +2 -2
  17. package/hooks/features/columnResize/useGridColumnResize.js +75 -61
  18. package/hooks/features/columns/gridColumnsUtils.d.ts +2 -1
  19. package/hooks/features/columns/gridColumnsUtils.js +4 -3
  20. package/hooks/features/density/useGridDensity.d.ts +1 -1
  21. package/hooks/features/density/useGridDensity.js +30 -4
  22. package/hooks/features/dimensions/gridDimensionsApi.d.ts +5 -1
  23. package/hooks/features/dimensions/useGridDimensions.d.ts +1 -1
  24. package/hooks/features/dimensions/useGridDimensions.js +5 -2
  25. package/hooks/features/editing/useGridCellEditing.js +14 -1
  26. package/hooks/features/export/useGridPrintExport.d.ts +1 -1
  27. package/hooks/features/export/useGridPrintExport.js +2 -2
  28. package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +2 -2
  29. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +2 -2
  30. package/hooks/features/pagination/gridPaginationInterfaces.d.ts +14 -2
  31. package/hooks/features/pagination/gridPaginationSelector.d.ts +5 -0
  32. package/hooks/features/pagination/gridPaginationSelector.js +7 -1
  33. package/hooks/features/pagination/gridPaginationUtils.d.ts +1 -2
  34. package/hooks/features/pagination/gridPaginationUtils.js +5 -3
  35. package/hooks/features/pagination/useGridPagination.d.ts +1 -1
  36. package/hooks/features/pagination/useGridPagination.js +5 -1
  37. package/hooks/features/pagination/useGridPaginationMeta.d.ts +4 -0
  38. package/hooks/features/pagination/useGridPaginationMeta.js +77 -0
  39. package/hooks/features/pagination/useGridPaginationModel.js +2 -1
  40. package/hooks/features/pagination/useGridRowCount.d.ts +0 -4
  41. package/hooks/features/pagination/useGridRowCount.js +32 -18
  42. package/hooks/utils/useGridSelector.d.ts +1 -1
  43. package/index.js +1 -1
  44. package/internals/index.d.ts +1 -1
  45. package/internals/utils/propValidation.js +1 -1
  46. package/locales/daDK.js +3 -4
  47. package/models/api/gridApiCommon.d.ts +1 -1
  48. package/models/api/gridLocaleTextApi.d.ts +7 -3
  49. package/models/api/index.d.ts +1 -1
  50. package/models/api/index.js +0 -1
  51. package/models/events/gridEventLookup.d.ts +7 -1
  52. package/models/gridPaginationProps.d.ts +3 -0
  53. package/models/props/DataGridProps.d.ts +26 -8
  54. package/modern/DataGrid/DataGrid.js +19 -0
  55. package/modern/components/GridPagination.js +60 -9
  56. package/modern/components/GridRow.js +1 -0
  57. package/modern/components/GridScrollArea.js +1 -1
  58. package/modern/components/columnHeaders/GridColumnHeaderItem.js +5 -2
  59. package/modern/components/columnHeaders/GridColumnHeaderSeparator.js +1 -1
  60. package/modern/components/containers/GridRootStyles.js +3 -1
  61. package/modern/components/index.js +1 -1
  62. package/modern/components/panel/GridPanel.js +3 -1
  63. package/modern/constants/gridClasses.js +1 -1
  64. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +2 -2
  65. package/modern/hooks/features/columnResize/useGridColumnResize.js +75 -61
  66. package/modern/hooks/features/columns/gridColumnsUtils.js +4 -3
  67. package/modern/hooks/features/density/useGridDensity.js +30 -4
  68. package/modern/hooks/features/dimensions/useGridDimensions.js +5 -2
  69. package/modern/hooks/features/editing/useGridCellEditing.js +14 -1
  70. package/modern/hooks/features/export/useGridPrintExport.js +2 -2
  71. package/modern/hooks/features/pagination/gridPaginationSelector.js +7 -1
  72. package/modern/hooks/features/pagination/gridPaginationUtils.js +5 -3
  73. package/modern/hooks/features/pagination/useGridPagination.js +5 -1
  74. package/modern/hooks/features/pagination/useGridPaginationMeta.js +77 -0
  75. package/modern/hooks/features/pagination/useGridPaginationModel.js +2 -1
  76. package/modern/hooks/features/pagination/useGridRowCount.js +32 -18
  77. package/modern/index.js +1 -1
  78. package/modern/internals/utils/propValidation.js +1 -1
  79. package/modern/locales/daDK.js +3 -4
  80. package/modern/models/api/index.js +0 -1
  81. package/node/DataGrid/DataGrid.js +19 -0
  82. package/node/components/GridPagination.js +59 -8
  83. package/node/components/GridRow.js +1 -0
  84. package/node/components/GridScrollArea.js +1 -1
  85. package/node/components/columnHeaders/GridColumnHeaderItem.js +4 -1
  86. package/node/components/columnHeaders/GridColumnHeaderSeparator.js +1 -1
  87. package/node/components/containers/GridRootStyles.js +3 -1
  88. package/node/components/index.js +27 -10
  89. package/node/components/panel/GridPanel.js +3 -1
  90. package/node/constants/gridClasses.js +1 -1
  91. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +2 -2
  92. package/node/hooks/features/columnResize/useGridColumnResize.js +76 -62
  93. package/node/hooks/features/columns/gridColumnsUtils.js +4 -3
  94. package/node/hooks/features/density/useGridDensity.js +30 -4
  95. package/node/hooks/features/dimensions/useGridDimensions.js +5 -2
  96. package/node/hooks/features/editing/useGridCellEditing.js +14 -1
  97. package/node/hooks/features/export/useGridPrintExport.js +2 -2
  98. package/node/hooks/features/pagination/gridPaginationSelector.js +8 -2
  99. package/node/hooks/features/pagination/gridPaginationUtils.js +6 -4
  100. package/node/hooks/features/pagination/useGridPagination.js +5 -1
  101. package/node/hooks/features/pagination/useGridPaginationMeta.js +87 -0
  102. package/node/hooks/features/pagination/useGridPaginationModel.js +2 -1
  103. package/node/hooks/features/pagination/useGridRowCount.js +30 -15
  104. package/node/index.js +1 -1
  105. package/node/internals/utils/propValidation.js +1 -1
  106. package/node/locales/daDK.js +3 -4
  107. package/node/models/api/index.js +0 -11
  108. package/package.json +1 -1
  109. package/utils/getGridLocalization.d.ts +1 -1
@@ -0,0 +1,77 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import { useGridLogger, useGridSelector, useGridApiMethod } from '../../utils';
4
+ import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
5
+ import { gridPaginationMetaSelector } from './gridPaginationSelector';
6
+ export const useGridPaginationMeta = (apiRef, props) => {
7
+ const logger = useGridLogger(apiRef, 'useGridPaginationMeta');
8
+ const paginationMeta = useGridSelector(apiRef, gridPaginationMetaSelector);
9
+ apiRef.current.registerControlState({
10
+ stateId: 'paginationMeta',
11
+ propModel: props.paginationMeta,
12
+ propOnChange: props.onPaginationMetaChange,
13
+ stateSelector: gridPaginationMetaSelector,
14
+ changeEvent: 'paginationMetaChange'
15
+ });
16
+
17
+ /**
18
+ * API METHODS
19
+ */
20
+ const setPaginationMeta = React.useCallback(newPaginationMeta => {
21
+ if (paginationMeta === newPaginationMeta) {
22
+ return;
23
+ }
24
+ logger.debug("Setting 'paginationMeta' to", newPaginationMeta);
25
+ apiRef.current.setState(state => _extends({}, state, {
26
+ pagination: _extends({}, state.pagination, {
27
+ meta: newPaginationMeta
28
+ })
29
+ }));
30
+ }, [apiRef, logger, paginationMeta]);
31
+ const paginationMetaApi = {
32
+ setPaginationMeta
33
+ };
34
+ useGridApiMethod(apiRef, paginationMetaApi, 'public');
35
+
36
+ /**
37
+ * PRE-PROCESSING
38
+ */
39
+ const stateExportPreProcessing = React.useCallback((prevState, context) => {
40
+ const exportedPaginationMeta = gridPaginationMetaSelector(apiRef);
41
+ const shouldExportRowCount =
42
+ // Always export if the `exportOnlyDirtyModels` property is not activated
43
+ !context.exportOnlyDirtyModels ||
44
+ // Always export if the `paginationMeta` is controlled
45
+ props.paginationMeta != null ||
46
+ // Always export if the `paginationMeta` has been initialized
47
+ props.initialState?.pagination?.meta != null;
48
+ if (!shouldExportRowCount) {
49
+ return prevState;
50
+ }
51
+ return _extends({}, prevState, {
52
+ pagination: _extends({}, prevState.pagination, {
53
+ meta: exportedPaginationMeta
54
+ })
55
+ });
56
+ }, [apiRef, props.paginationMeta, props.initialState?.pagination?.meta]);
57
+ const stateRestorePreProcessing = React.useCallback((params, context) => {
58
+ const restoredPaginationMeta = context.stateToRestore.pagination?.meta ? context.stateToRestore.pagination.meta : gridPaginationMetaSelector(apiRef);
59
+ apiRef.current.setState(state => _extends({}, state, {
60
+ pagination: _extends({}, state.pagination, {
61
+ meta: restoredPaginationMeta
62
+ })
63
+ }));
64
+ return params;
65
+ }, [apiRef]);
66
+ useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
67
+ useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
68
+
69
+ /**
70
+ * EFFECTS
71
+ */
72
+ React.useEffect(() => {
73
+ if (props.paginationMeta) {
74
+ apiRef.current.setPaginationMeta(props.paginationMeta);
75
+ }
76
+ }, [apiRef, props.paginationMeta]);
77
+ };
@@ -9,7 +9,8 @@ export const getDerivedPaginationModel = (paginationState, signature, pagination
9
9
  let paginationModel = paginationState.paginationModel;
10
10
  const rowCount = paginationState.rowCount;
11
11
  const pageSize = paginationModelProp?.pageSize ?? paginationModel.pageSize;
12
- const pageCount = getPageCount(rowCount, pageSize);
12
+ const page = paginationModelProp?.page ?? paginationModel.page;
13
+ const pageCount = getPageCount(rowCount, pageSize, page);
13
14
  if (paginationModelProp && (paginationModelProp?.page !== paginationModel.page || paginationModelProp?.pageSize !== paginationModel.pageSize)) {
14
15
  paginationModel = paginationModelProp;
15
16
  }
@@ -1,8 +1,4 @@
1
1
  import * as React from 'react';
2
2
  import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
3
3
  import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
4
- /**
5
- * @requires useGridFilter (state)
6
- * @requires useGridDimensions (event) - can be after
7
- */
8
4
  export declare const useGridRowCount: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'rowCount' | 'initialState' | 'paginationMode' | 'onRowCountChange'>) => void;
@@ -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
  };
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { GridApiCommon } from '../../models/api/gridApiCommon';
2
+ import type { GridApiCommon } from '../../models/api/gridApiCommon';
3
3
  import { OutputSelector } from '../../utils/createSelector';
4
4
  import { fastObjectShallowCompare } from '../../utils/fastObjectShallowCompare';
5
5
  export declare const objectShallowCompare: typeof fastObjectShallowCompare;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.2.0
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
@@ -65,7 +65,7 @@ export { useTimeout } from '../hooks/utils/useTimeout';
65
65
  export { useGridVisibleRows, getVisibleRows } from '../hooks/utils/useGridVisibleRows';
66
66
  export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
67
67
  export type { GridStateInitializer } from '../hooks/utils/useGridInitializeState';
68
- export type { DataGridProSharedPropsWithDefaultValue, DataGridPremiumSharedPropsWithDefaultValue, GridExperimentalFeatures, DataGridPropsWithoutDefaultValue, DataGridPropsWithDefaultValues, DataGridPropsWithComplexDefaultValueAfterProcessing, DataGridPropsWithComplexDefaultValueBeforeProcessing, } from '../models/props/DataGridProps';
68
+ export type * from '../models/props/DataGridProps';
69
69
  export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
70
70
  export * from '../utils/createControllablePromise';
71
71
  export { createSelector, createSelectorMemoized } from '../utils/createSelector';
@@ -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)) {
package/locales/daDK.js CHANGED
@@ -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',
@@ -6,7 +6,7 @@ import { GridDensityApi } from './gridDensityApi';
6
6
  import { GridEditingApi, GridEditingPrivateApi } from './gridEditingApi';
7
7
  import type { GridFilterApi } from './gridFilterApi';
8
8
  import { GridFocusApi, GridFocusPrivateApi } from './gridFocusApi';
9
- import { GridLocaleTextApi } from './gridLocaleTextApi';
9
+ import type { GridLocaleTextApi } from './gridLocaleTextApi';
10
10
  import type { GridParamsApi } from './gridParamsApi';
11
11
  import { GridPreferencesPanelApi } from './gridPreferencesPanelApi';
12
12
  import { GridPrintExportApi } from './gridPrintExportApi';
@@ -1,6 +1,10 @@
1
1
  import * as React from 'react';
2
- import { ComponentsPropsList } from '@mui/material/styles';
3
- import { GridColDef } from '../colDef';
2
+ import type { ComponentsPropsList } from '@mui/material/styles';
3
+ import type { WrappedLabelDisplayedRows } from '../../components/GridPagination';
4
+ import type { GridColDef } from '../colDef';
5
+ export type MuiTablePaginationLocalizedProps = Omit<ComponentsPropsList['MuiTablePagination'], 'page' | 'count' | 'onChangePage' | 'rowsPerPage' | 'onPageChange' | 'labelDisplayedRows'> & {
6
+ labelDisplayedRows?: WrappedLabelDisplayedRows;
7
+ };
4
8
  /**
5
9
  * Set the types of the texts in the grid.
6
10
  */
@@ -122,7 +126,7 @@ export interface GridLocaleText {
122
126
  aggregationFunctionLabelMin: string;
123
127
  aggregationFunctionLabelMax: string;
124
128
  aggregationFunctionLabelSize: string;
125
- MuiTablePagination: Omit<ComponentsPropsList['MuiTablePagination'], 'page' | 'count' | 'onChangePage' | 'rowsPerPage' | 'onPageChange'>;
129
+ MuiTablePagination: MuiTablePaginationLocalizedProps;
126
130
  }
127
131
  export type GridTranslationKeys = keyof GridLocaleText;
128
132
  /**
@@ -8,7 +8,7 @@ export type { GridRowsMetaApi } from './gridRowsMetaApi';
8
8
  export * from './gridRowSelectionApi';
9
9
  export * from './gridSortApi';
10
10
  export type { GridStateApi } from './gridStateApi';
11
- export * from './gridLocaleTextApi';
11
+ export type { GridLocaleText, GridLocaleTextApi, GridTranslationKeys } from './gridLocaleTextApi';
12
12
  export * from './gridCsvExportApi';
13
13
  export type { GridFocusApi } from './gridFocusApi';
14
14
  export * from './gridFilterApi';
@@ -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';
@@ -12,7 +12,7 @@ import type { GridColumnVisibilityModel } from '../../hooks/features/columns';
12
12
  import type { GridStrategyProcessorName } from '../../hooks/core/strategyProcessing';
13
13
  import { GridRowEditStartParams, GridRowEditStopParams } from '../params/gridRowParams';
14
14
  import { GridCellModesModel, GridRowModesModel } from '../api/gridEditingApi';
15
- import { GridPaginationModel } from '../gridPaginationProps';
15
+ import { GridPaginationMeta, GridPaginationModel } from '../gridPaginationProps';
16
16
  import { GridDensity } from '../gridDensity';
17
17
  export interface GridRowEventLookup {
18
18
  /**
@@ -382,6 +382,12 @@ export interface GridControlledStateEventLookup {
382
382
  densityChange: {
383
383
  params: GridDensity;
384
384
  };
385
+ /**
386
+ * Fired when the pagination meta change.
387
+ */
388
+ paginationMetaChange: {
389
+ params: GridPaginationMeta;
390
+ };
385
391
  }
386
392
  export interface GridControlledStateReasonLookup {
387
393
  filter: 'upsertFilterItem' | 'upsertFilterItems' | 'deleteFilterItem' | 'changeLogicOperator' | 'restoreState' | 'removeAllFilterItems';
@@ -11,3 +11,6 @@ export interface GridPaginationModel {
11
11
  */
12
12
  page: number;
13
13
  }
14
+ export interface GridPaginationMeta {
15
+ hasNextPage?: boolean;
16
+ }
@@ -23,7 +23,7 @@ import { GridSlotsComponentsProps } from '../gridSlotsComponentsProps';
23
23
  import { GridColumnVisibilityModel } from '../../hooks/features/columns/gridColumnsInterfaces';
24
24
  import { GridCellModesModel, GridRowModesModel } from '../api/gridEditingApi';
25
25
  import { GridColumnGroupingModel } from '../gridColumnGrouping';
26
- import { GridPaginationModel } from '../gridPaginationProps';
26
+ import { GridPaginationMeta, GridPaginationModel } from '../gridPaginationProps';
27
27
  import type { GridAutosizeOptions } from '../../hooks/features/columnResize';
28
28
  export interface GridExperimentalFeatures {
29
29
  /**
@@ -38,11 +38,6 @@ export interface GridExperimentalFeatures {
38
38
  export type DataGridProps<R extends GridValidRowModel = any> = Omit<Partial<DataGridPropsWithDefaultValues<R>> & DataGridPropsWithComplexDefaultValueBeforeProcessing & DataGridPropsWithoutDefaultValue<R>, DataGridForcedPropsKey> & {
39
39
  pagination?: true;
40
40
  };
41
- /**
42
- * The props of the `DataGrid` component after the pre-processing phase.
43
- */
44
- export interface DataGridProcessedProps<R extends GridValidRowModel = any> extends DataGridPropsWithDefaultValues, DataGridPropsWithComplexDefaultValueAfterProcessing, DataGridPropsWithoutDefaultValue<R> {
45
- }
46
41
  /**
47
42
  * The props of the `DataGrid` component after the pre-processing phase that the user should not be able to override.
48
43
  * Those are usually used in feature-hook for which the pro-plan has more advanced features (eg: multi-sorting, multi-filtering, ...).
@@ -380,8 +375,15 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
380
375
  /**
381
376
  * Set the total number of rows, if it is different from the length of the value `rows` prop.
382
377
  * If some rows have children (for instance in the tree data), this number represents the amount of top level rows.
378
+ * Only works with `paginationMode="server"`, ignored when `paginationMode="client"`.
383
379
  */
384
380
  rowCount?: number;
381
+ /**
382
+ * Use if the actual rowCount is not known upfront, but an estimation is available.
383
+ * If some rows have children (for instance in the tree data), this number represents the amount of top level rows.
384
+ * Applicable only with `paginationMode="server"` and when `rowCount="-1"`
385
+ */
386
+ estimatedRowCount?: number;
385
387
  /**
386
388
  * Override the height/width of the Data Grid inner scrollbar.
387
389
  */
@@ -569,6 +571,11 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
569
571
  * The pagination model of type [[GridPaginationModel]] which refers to current `page` and `pageSize`.
570
572
  */
571
573
  paginationModel?: GridPaginationModel;
574
+ /**
575
+ * The extra information about the pagination state of the Data Grid.
576
+ * Only applicable with `paginationMode="server"`.
577
+ */
578
+ paginationMeta?: GridPaginationMeta;
572
579
  /**
573
580
  * Callback fired when the pagination model has changed.
574
581
  * @param {GridPaginationModel} model Updated pagination model.
@@ -580,6 +587,11 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
580
587
  * @param {number} count Updated row count.
581
588
  */
582
589
  onRowCountChange?: (count: number) => void;
590
+ /**
591
+ * Callback fired when the pagination meta has changed.
592
+ * @param {GridPaginationMeta} paginationMeta Updated pagination meta.
593
+ */
594
+ onPaginationMetaChange?: (paginationMeta: GridPaginationMeta) => void;
583
595
  /**
584
596
  * Callback fired when the preferences panel is closed.
585
597
  * @param {GridPreferencePanelParams} params With all properties from [[GridPreferencePanelParams]].
@@ -757,6 +769,12 @@ export interface DataGridProSharedPropsWithDefaultValue {
757
769
  */
758
770
  headerFilters: boolean;
759
771
  }
772
+ export interface DataGridProSharedPropsWithoutDefaultValue {
773
+ /**
774
+ * Override the height of the header filters.
775
+ */
776
+ headerFilterHeight?: number;
777
+ }
760
778
  export interface DataGridPremiumSharedPropsWithDefaultValue {
761
779
  /**
762
780
  * If `true`, the cell selection mode is enabled.
@@ -765,7 +783,7 @@ export interface DataGridPremiumSharedPropsWithDefaultValue {
765
783
  cellSelection: boolean;
766
784
  }
767
785
  /**
768
- * Contains the commercial packages' props shared in the MIT version.
786
+ * The props of the `DataGrid` component after the pre-processing phase.
769
787
  */
770
- export interface DataGridProcessedPropsWithShared extends DataGridProcessedProps, Partial<DataGridProSharedPropsWithDefaultValue>, Partial<DataGridPremiumSharedPropsWithDefaultValue> {
788
+ export interface DataGridProcessedProps<R extends GridValidRowModel = any> extends DataGridPropsWithDefaultValues, DataGridPropsWithComplexDefaultValueAfterProcessing, DataGridPropsWithoutDefaultValue<R>, DataGridProSharedPropsWithoutDefaultValue, Partial<DataGridProSharedPropsWithDefaultValue>, Partial<DataGridPremiumSharedPropsWithDefaultValue> {
771
789
  }
@@ -186,6 +186,12 @@ DataGridRaw.propTypes = {
186
186
  * @default "cell"
187
187
  */
188
188
  editMode: PropTypes.oneOf(['cell', 'row']),
189
+ /**
190
+ * Use if the actual rowCount is not known upfront, but an estimation is available.
191
+ * If some rows have children (for instance in the tree data), this number represents the amount of top level rows.
192
+ * Applicable only with `paginationMode="server"` and when `rowCount="-1"`
193
+ */
194
+ estimatedRowCount: PropTypes.number,
189
195
  /**
190
196
  * Unstable features, breaking changes might be introduced.
191
197
  * 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.
@@ -487,6 +493,11 @@ DataGridRaw.propTypes = {
487
493
  * @param {GridCallbackDetails} details Additional details for this callback.
488
494
  */
489
495
  onMenuOpen: PropTypes.func,
496
+ /**
497
+ * Callback fired when the pagination meta has changed.
498
+ * @param {GridPaginationMeta} paginationMeta Updated pagination meta.
499
+ */
500
+ onPaginationMetaChange: PropTypes.func,
490
501
  /**
491
502
  * Callback fired when the pagination model has changed.
492
503
  * @param {GridPaginationModel} model Updated pagination model.
@@ -586,6 +597,13 @@ DataGridRaw.propTypes = {
586
597
  value: PropTypes.number.isRequired
587
598
  })]).isRequired),
588
599
  pagination: PropTypes.oneOf([true]),
600
+ /**
601
+ * The extra information about the pagination state of the Data Grid.
602
+ * Only applicable with `paginationMode="server"`.
603
+ */
604
+ paginationMeta: PropTypes.shape({
605
+ hasNextPage: PropTypes.bool
606
+ }),
589
607
  /**
590
608
  * Pagination can be processed on the server or client-side.
591
609
  * Set it to 'client' if you would like to handle the pagination on the client-side.
@@ -621,6 +639,7 @@ DataGridRaw.propTypes = {
621
639
  /**
622
640
  * Set the total number of rows, if it is different from the length of the value `rows` prop.
623
641
  * If some rows have children (for instance in the tree data), this number represents the amount of top level rows.
642
+ * Only works with `paginationMode="server"`, ignored when `paginationMode="client"`.
624
643
  */
625
644
  rowCount: PropTypes.number,
626
645
  /**
@@ -1,12 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
+ import { styled } from '@mui/material/styles';
3
4
  import PropTypes from 'prop-types';
4
5
  import TablePagination, { tablePaginationClasses } from '@mui/material/TablePagination';
5
- import { styled } from '@mui/material/styles';
6
6
  import { useGridSelector } from '../hooks/utils/useGridSelector';
7
7
  import { useGridApiContext } from '../hooks/utils/useGridApiContext';
8
8
  import { useGridRootProps } from '../hooks/utils/useGridRootProps';
9
- import { gridPaginationModelSelector, gridPaginationRowCountSelector } from '../hooks/features/pagination/gridPaginationSelector';
9
+ import { gridPaginationModelSelector, gridPaginationRowCountSelector, gridPageCountSelector } from '../hooks/features/pagination/gridPaginationSelector';
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  const GridPaginationRoot = styled(TablePagination)(({
12
12
  theme
@@ -24,6 +24,31 @@ const GridPaginationRoot = styled(TablePagination)(({
24
24
  }
25
25
  }
26
26
  }));
27
+ const wrapLabelDisplayedRows = (labelDisplayedRows, estimated) => {
28
+ return ({
29
+ from,
30
+ to,
31
+ count,
32
+ page
33
+ }) => labelDisplayedRows({
34
+ from,
35
+ to,
36
+ count,
37
+ page,
38
+ estimated
39
+ });
40
+ };
41
+ const defaultLabelDisplayedRows = ({
42
+ from,
43
+ to,
44
+ count,
45
+ estimated
46
+ }) => {
47
+ if (!estimated) {
48
+ return `${from}–${to} of ${count !== -1 ? count : `more than ${to}`}`;
49
+ }
50
+ return `${from}–${to} of ${count !== -1 ? count : `more than ${estimated > to ? estimated : to}`}`;
51
+ };
27
52
 
28
53
  // A mutable version of a readonly array.
29
54
 
@@ -32,10 +57,32 @@ const GridPagination = /*#__PURE__*/React.forwardRef(function GridPagination(pro
32
57
  const rootProps = useGridRootProps();
33
58
  const paginationModel = useGridSelector(apiRef, gridPaginationModelSelector);
34
59
  const rowCount = useGridSelector(apiRef, gridPaginationRowCountSelector);
35
- const lastPage = React.useMemo(() => {
36
- const calculatedValue = Math.ceil(rowCount / (paginationModel.pageSize || 1)) - 1;
37
- return Math.max(0, calculatedValue);
38
- }, [rowCount, paginationModel.pageSize]);
60
+ const pageCount = useGridSelector(apiRef, gridPageCountSelector);
61
+ const {
62
+ paginationMode,
63
+ loading,
64
+ estimatedRowCount
65
+ } = rootProps;
66
+ const computedProps = React.useMemo(() => {
67
+ if (rowCount === -1 && paginationMode === 'server' && loading) {
68
+ return {
69
+ backIconButtonProps: {
70
+ disabled: true
71
+ },
72
+ nextIconButtonProps: {
73
+ disabled: true
74
+ }
75
+ };
76
+ }
77
+ return {};
78
+ }, [loading, paginationMode, rowCount]);
79
+ const lastPage = React.useMemo(() => Math.max(0, pageCount - 1), [pageCount]);
80
+ const computedPage = React.useMemo(() => {
81
+ if (rowCount === -1) {
82
+ return paginationModel.page;
83
+ }
84
+ return paginationModel.page <= lastPage ? paginationModel.page : lastPage;
85
+ }, [lastPage, paginationModel.page, rowCount]);
39
86
  const handlePageSizeChange = React.useCallback(event => {
40
87
  const pageSize = Number(event.target.value);
41
88
  apiRef.current.setPageSize(pageSize);
@@ -61,16 +108,18 @@ const GridPagination = /*#__PURE__*/React.forwardRef(function GridPagination(pro
61
108
  const warnedOnceMissingInPageSizeOptions = React.useRef(false);
62
109
  const pageSize = rootProps.paginationModel?.pageSize ?? paginationModel.pageSize;
63
110
  if (!warnedOnceMissingInPageSizeOptions.current && !rootProps.autoPageSize && !isPageSizeIncludedInPageSizeOptions(pageSize)) {
64
- console.warn([`MUI X: The page size \`${paginationModel.pageSize}\` is not preset in the \`pageSizeOptions\`.`, `Add it to show the pagination select.`].join('\n'));
111
+ console.warn([`MUI X: The page size \`${paginationModel.pageSize}\` is not present in the \`pageSizeOptions\`.`, `Add it to show the pagination select.`].join('\n'));
65
112
  warnedOnceMissingInPageSizeOptions.current = true;
66
113
  }
67
114
  }
68
115
  const pageSizeOptions = isPageSizeIncludedInPageSizeOptions(paginationModel.pageSize) ? rootProps.pageSizeOptions : [];
116
+ const locales = apiRef.current.getLocaleText('MuiTablePagination');
117
+ const wrappedLabelDisplayedRows = wrapLabelDisplayedRows(locales.labelDisplayedRows || defaultLabelDisplayedRows, estimatedRowCount);
69
118
  return /*#__PURE__*/_jsx(GridPaginationRoot, _extends({
70
119
  ref: ref,
71
120
  component: "div",
72
121
  count: rowCount,
73
- page: paginationModel.page <= lastPage ? paginationModel.page : lastPage
122
+ page: computedPage
74
123
  // TODO: Remove the cast once the type is fixed in Material UI and that the min Material UI version
75
124
  // for x-data-grid is past the fix.
76
125
  // Note that Material UI will not mutate the array, so this is safe.
@@ -79,7 +128,9 @@ const GridPagination = /*#__PURE__*/React.forwardRef(function GridPagination(pro
79
128
  rowsPerPage: paginationModel.pageSize,
80
129
  onPageChange: handlePageChange,
81
130
  onRowsPerPageChange: handlePageSizeChange
82
- }, apiRef.current.getLocaleText('MuiTablePagination'), props));
131
+ }, computedProps, locales, {
132
+ labelDisplayedRows: wrappedLabelDisplayedRows
133
+ }, props));
83
134
  });
84
135
  process.env.NODE_ENV !== "production" ? GridPagination.propTypes = {
85
136
  // ----------------------------- Warning --------------------------------
@@ -366,6 +366,7 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
366
366
  }).isRequired,
367
367
  hasScrollX: PropTypes.bool.isRequired,
368
368
  hasScrollY: PropTypes.bool.isRequired,
369
+ headerFilterHeight: PropTypes.number.isRequired,
369
370
  headerHeight: PropTypes.number.isRequired,
370
371
  headersTotalHeight: PropTypes.number.isRequired,
371
372
  isReady: PropTypes.bool.isRequired,
@@ -82,7 +82,7 @@ function GridScrollAreaRaw(props) {
82
82
  scrollDirection
83
83
  });
84
84
  const classes = useUtilityClasses(ownerState);
85
- const totalHeaderHeight = getTotalHeaderHeight(apiRef, rootProps.columnHeaderHeight);
85
+ const totalHeaderHeight = getTotalHeaderHeight(apiRef, rootProps);
86
86
  const headerHeight = Math.floor(rootProps.columnHeaderHeight * densityFactor);
87
87
  const style = {
88
88
  height: headerHeight,
@@ -1,13 +1,14 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import PropTypes from 'prop-types';
4
+ import clsx from 'clsx';
4
5
  import { unstable_composeClasses as composeClasses, unstable_useId as useId } from '@mui/utils';
5
6
  import { fastMemo } from '../../utils/fastMemo';
6
7
  import { useGridPrivateApiContext } from '../../hooks/utils/useGridPrivateApiContext';
7
8
  import { GridColumnHeaderSortIcon } from './GridColumnHeaderSortIcon';
8
9
  import { ColumnHeaderMenuIcon } from './ColumnHeaderMenuIcon';
9
10
  import { GridColumnHeaderMenu } from '../menu/columnMenu/GridColumnHeaderMenu';
10
- import { getDataGridUtilityClass } from '../../constants/gridClasses';
11
+ import { gridClasses, getDataGridUtilityClass } from '../../constants/gridClasses';
11
12
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
12
13
  import { GridGenericColumnHeaderItem } from './GridGenericColumnHeaderItem';
13
14
  import { isEventTargetInPortal } from '../../utils/domUtils';
@@ -44,6 +45,7 @@ function GridColumnHeaderItem(props) {
44
45
  colIndex,
45
46
  headerHeight,
46
47
  isResizing,
48
+ isLast,
47
49
  sortDirection,
48
50
  sortIndex,
49
51
  filterItemsCounter,
@@ -182,7 +184,7 @@ function GridColumnHeaderItem(props) {
182
184
  width: colDef.computedWidth,
183
185
  columnMenuIconButton: columnMenuIconButton,
184
186
  columnTitleIconButtons: columnTitleIconButtons,
185
- headerClassName: headerClassName,
187
+ headerClassName: clsx(headerClassName, isLast && gridClasses['columnHeader--last']),
186
188
  label: label,
187
189
  resizable: !rootProps.disableColumnResize && !!colDef.resizable,
188
190
  "data-field": colDef.field,
@@ -207,6 +209,7 @@ process.env.NODE_ENV !== "production" ? GridColumnHeaderItem.propTypes = {
207
209
  headerHeight: PropTypes.number.isRequired,
208
210
  indexInSection: PropTypes.number.isRequired,
209
211
  isDragging: PropTypes.bool.isRequired,
212
+ isLast: PropTypes.bool.isRequired,
210
213
  isResizing: PropTypes.bool.isRequired,
211
214
  pinnedPosition: PropTypes.oneOf(['left', 'right']),
212
215
  sectionLength: PropTypes.number.isRequired,
@@ -48,7 +48,7 @@ function GridColumnHeaderSeparatorRaw(props) {
48
48
  className: classes.root,
49
49
  style: {
50
50
  minHeight: height,
51
- opacity: rootProps.showColumnVerticalBorder ? 1 : 0
51
+ opacity: rootProps.showColumnVerticalBorder ? 0 : 1
52
52
  }
53
53
  }, other, {
54
54
  onClick: stopClick,