@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.
- package/CHANGELOG.md +125 -0
- package/DataGrid/DataGrid.js +19 -0
- package/components/GridPagination.d.ts +4 -1
- package/components/GridPagination.js +60 -9
- package/components/GridRow.js +1 -0
- package/components/GridScrollArea.js +1 -1
- package/components/columnHeaders/GridColumnHeaderItem.d.ts +1 -0
- package/components/columnHeaders/GridColumnHeaderItem.js +5 -2
- package/components/columnHeaders/GridColumnHeaderSeparator.js +1 -1
- package/components/containers/GridRootStyles.js +3 -1
- package/components/index.d.ts +1 -1
- package/components/index.js +1 -1
- package/components/panel/GridPanel.js +3 -1
- package/constants/gridClasses.d.ts +6 -2
- package/constants/gridClasses.js +1 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +2 -2
- package/hooks/features/columnResize/useGridColumnResize.js +75 -61
- package/hooks/features/columns/gridColumnsUtils.d.ts +2 -1
- package/hooks/features/columns/gridColumnsUtils.js +4 -3
- package/hooks/features/density/useGridDensity.d.ts +1 -1
- package/hooks/features/density/useGridDensity.js +30 -4
- package/hooks/features/dimensions/gridDimensionsApi.d.ts +5 -1
- package/hooks/features/dimensions/useGridDimensions.d.ts +1 -1
- package/hooks/features/dimensions/useGridDimensions.js +5 -2
- package/hooks/features/editing/useGridCellEditing.js +14 -1
- package/hooks/features/export/useGridPrintExport.d.ts +1 -1
- package/hooks/features/export/useGridPrintExport.js +2 -2
- package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +2 -2
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +2 -2
- package/hooks/features/pagination/gridPaginationInterfaces.d.ts +14 -2
- package/hooks/features/pagination/gridPaginationSelector.d.ts +5 -0
- package/hooks/features/pagination/gridPaginationSelector.js +7 -1
- package/hooks/features/pagination/gridPaginationUtils.d.ts +1 -2
- package/hooks/features/pagination/gridPaginationUtils.js +5 -3
- package/hooks/features/pagination/useGridPagination.d.ts +1 -1
- package/hooks/features/pagination/useGridPagination.js +5 -1
- package/hooks/features/pagination/useGridPaginationMeta.d.ts +4 -0
- package/hooks/features/pagination/useGridPaginationMeta.js +77 -0
- package/hooks/features/pagination/useGridPaginationModel.js +2 -1
- package/hooks/features/pagination/useGridRowCount.d.ts +0 -4
- package/hooks/features/pagination/useGridRowCount.js +32 -18
- package/hooks/utils/useGridSelector.d.ts +1 -1
- package/index.js +1 -1
- package/internals/index.d.ts +1 -1
- package/internals/utils/propValidation.js +1 -1
- package/locales/daDK.js +3 -4
- package/models/api/gridApiCommon.d.ts +1 -1
- package/models/api/gridLocaleTextApi.d.ts +7 -3
- package/models/api/index.d.ts +1 -1
- package/models/api/index.js +0 -1
- package/models/events/gridEventLookup.d.ts +7 -1
- package/models/gridPaginationProps.d.ts +3 -0
- package/models/props/DataGridProps.d.ts +26 -8
- package/modern/DataGrid/DataGrid.js +19 -0
- package/modern/components/GridPagination.js +60 -9
- package/modern/components/GridRow.js +1 -0
- package/modern/components/GridScrollArea.js +1 -1
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +5 -2
- package/modern/components/columnHeaders/GridColumnHeaderSeparator.js +1 -1
- package/modern/components/containers/GridRootStyles.js +3 -1
- package/modern/components/index.js +1 -1
- package/modern/components/panel/GridPanel.js +3 -1
- package/modern/constants/gridClasses.js +1 -1
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +2 -2
- package/modern/hooks/features/columnResize/useGridColumnResize.js +75 -61
- package/modern/hooks/features/columns/gridColumnsUtils.js +4 -3
- package/modern/hooks/features/density/useGridDensity.js +30 -4
- package/modern/hooks/features/dimensions/useGridDimensions.js +5 -2
- package/modern/hooks/features/editing/useGridCellEditing.js +14 -1
- package/modern/hooks/features/export/useGridPrintExport.js +2 -2
- package/modern/hooks/features/pagination/gridPaginationSelector.js +7 -1
- package/modern/hooks/features/pagination/gridPaginationUtils.js +5 -3
- package/modern/hooks/features/pagination/useGridPagination.js +5 -1
- package/modern/hooks/features/pagination/useGridPaginationMeta.js +77 -0
- package/modern/hooks/features/pagination/useGridPaginationModel.js +2 -1
- package/modern/hooks/features/pagination/useGridRowCount.js +32 -18
- package/modern/index.js +1 -1
- package/modern/internals/utils/propValidation.js +1 -1
- package/modern/locales/daDK.js +3 -4
- package/modern/models/api/index.js +0 -1
- package/node/DataGrid/DataGrid.js +19 -0
- package/node/components/GridPagination.js +59 -8
- package/node/components/GridRow.js +1 -0
- package/node/components/GridScrollArea.js +1 -1
- package/node/components/columnHeaders/GridColumnHeaderItem.js +4 -1
- package/node/components/columnHeaders/GridColumnHeaderSeparator.js +1 -1
- package/node/components/containers/GridRootStyles.js +3 -1
- package/node/components/index.js +27 -10
- package/node/components/panel/GridPanel.js +3 -1
- package/node/constants/gridClasses.js +1 -1
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +2 -2
- package/node/hooks/features/columnResize/useGridColumnResize.js +76 -62
- package/node/hooks/features/columns/gridColumnsUtils.js +4 -3
- package/node/hooks/features/density/useGridDensity.js +30 -4
- package/node/hooks/features/dimensions/useGridDimensions.js +5 -2
- package/node/hooks/features/editing/useGridCellEditing.js +14 -1
- package/node/hooks/features/export/useGridPrintExport.js +2 -2
- package/node/hooks/features/pagination/gridPaginationSelector.js +8 -2
- package/node/hooks/features/pagination/gridPaginationUtils.js +6 -4
- package/node/hooks/features/pagination/useGridPagination.js +5 -1
- package/node/hooks/features/pagination/useGridPaginationMeta.js +87 -0
- package/node/hooks/features/pagination/useGridPaginationModel.js +2 -1
- package/node/hooks/features/pagination/useGridRowCount.js +30 -15
- package/node/index.js +1 -1
- package/node/internals/utils/propValidation.js +1 -1
- package/node/locales/daDK.js +3 -4
- package/node/models/api/index.js +0 -11
- package/package.json +1 -1
- package/utils/getGridLocalization.d.ts +1 -1
|
@@ -7,21 +7,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.useGridRowCount = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _useLazyRef = _interopRequireDefault(require("@mui/utils/useLazyRef"));
|
|
10
11
|
var _filter = require("../filter");
|
|
11
12
|
var _utils = require("../../utils");
|
|
12
13
|
var _pipeProcessing = require("../../core/pipeProcessing");
|
|
13
14
|
var _gridPaginationSelector = require("./gridPaginationSelector");
|
|
14
|
-
var _gridPaginationUtils = require("./gridPaginationUtils");
|
|
15
15
|
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); }
|
|
16
16
|
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; }
|
|
17
|
-
/**
|
|
18
|
-
* @requires useGridFilter (state)
|
|
19
|
-
* @requires useGridDimensions (event) - can be after
|
|
20
|
-
*/
|
|
21
17
|
const useGridRowCount = (apiRef, props) => {
|
|
22
18
|
const logger = (0, _utils.useGridLogger)(apiRef, 'useGridRowCount');
|
|
23
19
|
const visibleTopLevelRowCount = (0, _utils.useGridSelector)(apiRef, _filter.gridFilteredTopLevelRowCountSelector);
|
|
24
|
-
const
|
|
20
|
+
const rowCountState = (0, _utils.useGridSelector)(apiRef, _gridPaginationSelector.gridPaginationRowCountSelector);
|
|
21
|
+
const paginationMeta = (0, _utils.useGridSelector)(apiRef, _gridPaginationSelector.gridPaginationMetaSelector);
|
|
22
|
+
const paginationModel = (0, _utils.useGridSelector)(apiRef, _gridPaginationSelector.gridPaginationModelSelector);
|
|
23
|
+
const previousPageSize = (0, _useLazyRef.default)(() => (0, _gridPaginationSelector.gridPaginationModelSelector)(apiRef).pageSize);
|
|
25
24
|
apiRef.current.registerControlState({
|
|
26
25
|
stateId: 'paginationRowCount',
|
|
27
26
|
propModel: props.rowCount,
|
|
@@ -34,7 +33,7 @@ const useGridRowCount = (apiRef, props) => {
|
|
|
34
33
|
* API METHODS
|
|
35
34
|
*/
|
|
36
35
|
const setRowCount = React.useCallback(newRowCount => {
|
|
37
|
-
if (
|
|
36
|
+
if (rowCountState === newRowCount) {
|
|
38
37
|
return;
|
|
39
38
|
}
|
|
40
39
|
logger.debug("Setting 'rowCount' to", newRowCount);
|
|
@@ -43,7 +42,7 @@ const useGridRowCount = (apiRef, props) => {
|
|
|
43
42
|
rowCount: newRowCount
|
|
44
43
|
})
|
|
45
44
|
}));
|
|
46
|
-
}, [apiRef, logger,
|
|
45
|
+
}, [apiRef, logger, rowCountState]);
|
|
47
46
|
const paginationRowCountApi = {
|
|
48
47
|
setRowCount
|
|
49
48
|
};
|
|
@@ -83,21 +82,37 @@ const useGridRowCount = (apiRef, props) => {
|
|
|
83
82
|
(0, _pipeProcessing.useGridRegisterPipeProcessor)(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
84
83
|
|
|
85
84
|
/**
|
|
86
|
-
*
|
|
85
|
+
* EVENTS
|
|
87
86
|
*/
|
|
88
|
-
React.
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
const handlePaginationModelChange = React.useCallback(model => {
|
|
88
|
+
if (props.paginationMode === 'client' || !previousPageSize.current) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (model.pageSize !== previousPageSize.current) {
|
|
92
|
+
previousPageSize.current = model.pageSize;
|
|
93
|
+
if (rowCountState === -1) {
|
|
94
|
+
// Row count unknown and page size changed, reset the page
|
|
95
|
+
apiRef.current.setPage(0);
|
|
92
96
|
}
|
|
93
97
|
}
|
|
94
|
-
}, [props.
|
|
98
|
+
}, [props.paginationMode, previousPageSize, rowCountState, apiRef]);
|
|
99
|
+
(0, _utils.useGridApiEventHandler)(apiRef, 'paginationModelChange', handlePaginationModelChange);
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* EFFECTS
|
|
103
|
+
*/
|
|
95
104
|
React.useEffect(() => {
|
|
96
105
|
if (props.paginationMode === 'client') {
|
|
97
106
|
apiRef.current.setRowCount(visibleTopLevelRowCount);
|
|
98
107
|
} else if (props.rowCount != null) {
|
|
99
108
|
apiRef.current.setRowCount(props.rowCount);
|
|
100
109
|
}
|
|
101
|
-
}, [apiRef,
|
|
110
|
+
}, [apiRef, props.paginationMode, visibleTopLevelRowCount, props.rowCount]);
|
|
111
|
+
const isLastPage = paginationMeta.hasNextPage === false;
|
|
112
|
+
React.useEffect(() => {
|
|
113
|
+
if (isLastPage && rowCountState === -1) {
|
|
114
|
+
apiRef.current.setRowCount(paginationModel.pageSize * paginationModel.page + visibleTopLevelRowCount);
|
|
115
|
+
}
|
|
116
|
+
}, [apiRef, visibleTopLevelRowCount, isLastPage, rowCountState, paginationModel]);
|
|
102
117
|
};
|
|
103
118
|
exports.useGridRowCount = useGridRowCount;
|
package/node/index.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.validateProps = exports.propValidatorsDataGrid = exports.clearWarningsCache = void 0;
|
|
7
7
|
var _utils = require("../../utils/utils");
|
|
8
8
|
var _useGridApiEventHandler = require("../../hooks/utils/useGridApiEventHandler");
|
|
9
|
-
const propValidatorsDataGrid = exports.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 === _useGridApiEventHandler.GridSignature.DataGrid && props.paginationMode === 'client' && (0, _utils.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];
|
|
9
|
+
const propValidatorsDataGrid = exports.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 === _useGridApiEventHandler.GridSignature.DataGrid && props.paginationMode === 'client' && (0, _utils.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];
|
|
10
10
|
const warnedOnceCache = new Set();
|
|
11
11
|
const warnOnce = message => {
|
|
12
12
|
if (!warnedOnceCache.has(message)) {
|
package/node/locales/daDK.js
CHANGED
|
@@ -36,10 +36,9 @@ const daDKGrid = {
|
|
|
36
36
|
toolbarExportPrint: 'Print',
|
|
37
37
|
toolbarExportExcel: 'Download som Excel',
|
|
38
38
|
// Columns management text
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
columnsManagementSearchTitle: 'Søg',
|
|
40
|
+
columnsManagementNoColumns: 'Ingen søjler',
|
|
41
|
+
columnsManagementShowHideAllText: 'Vis/Shjul Alle',
|
|
43
42
|
// Filter panel text
|
|
44
43
|
filterPanelAddFilter: 'Tilføj filter',
|
|
45
44
|
filterPanelRemoveAll: 'Fjern alle',
|
package/node/models/api/index.js
CHANGED
|
@@ -69,17 +69,6 @@ Object.keys(_gridSortApi).forEach(function (key) {
|
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
|
-
var _gridLocaleTextApi = require("./gridLocaleTextApi");
|
|
73
|
-
Object.keys(_gridLocaleTextApi).forEach(function (key) {
|
|
74
|
-
if (key === "default" || key === "__esModule") return;
|
|
75
|
-
if (key in exports && exports[key] === _gridLocaleTextApi[key]) return;
|
|
76
|
-
Object.defineProperty(exports, key, {
|
|
77
|
-
enumerable: true,
|
|
78
|
-
get: function () {
|
|
79
|
-
return _gridLocaleTextApi[key];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
72
|
var _gridCsvExportApi = require("./gridCsvExportApi");
|
|
84
73
|
Object.keys(_gridCsvExportApi).forEach(function (key) {
|
|
85
74
|
if (key === "default" || key === "__esModule") return;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Localization as CoreLocalization } from '@mui/material/locale';
|
|
2
|
-
import { GridLocaleText } from '../models/api/gridLocaleTextApi';
|
|
2
|
+
import type { GridLocaleText } from '../models/api/gridLocaleTextApi';
|
|
3
3
|
export interface Localization {
|
|
4
4
|
components: {
|
|
5
5
|
MuiDataGrid: {
|