@mui/x-data-grid 6.20.1 → 6.20.4

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 (45) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/DataGrid/DataGrid.js +5 -0
  3. package/components/GridPagination.js +2 -7
  4. package/components/panel/GridPanel.js +4 -1
  5. package/hooks/features/export/useGridPrintExport.js +8 -4
  6. package/hooks/features/pagination/gridPaginationInterfaces.d.ts +19 -2
  7. package/hooks/features/pagination/gridPaginationSelector.d.ts +5 -0
  8. package/hooks/features/pagination/gridPaginationSelector.js +8 -2
  9. package/hooks/features/pagination/useGridPagination.d.ts +1 -6
  10. package/hooks/features/pagination/useGridPagination.js +9 -159
  11. package/hooks/features/pagination/useGridPaginationModel.d.ts +11 -0
  12. package/hooks/features/pagination/useGridPaginationModel.js +176 -0
  13. package/hooks/features/pagination/useGridRowCount.d.ts +8 -0
  14. package/hooks/features/pagination/useGridRowCount.js +97 -0
  15. package/index.js +1 -1
  16. package/legacy/DataGrid/DataGrid.js +5 -0
  17. package/legacy/components/GridPagination.js +2 -7
  18. package/legacy/components/panel/GridPanel.js +4 -1
  19. package/legacy/hooks/features/export/useGridPrintExport.js +10 -4
  20. package/legacy/hooks/features/pagination/gridPaginationSelector.js +11 -3
  21. package/legacy/hooks/features/pagination/useGridPagination.js +9 -161
  22. package/legacy/hooks/features/pagination/useGridPaginationModel.js +182 -0
  23. package/legacy/hooks/features/pagination/useGridRowCount.js +101 -0
  24. package/legacy/index.js +1 -1
  25. package/models/events/gridEventLookup.d.ts +6 -0
  26. package/models/props/DataGridProps.d.ts +5 -0
  27. package/modern/DataGrid/DataGrid.js +5 -0
  28. package/modern/components/GridPagination.js +2 -4
  29. package/modern/components/panel/GridPanel.js +4 -1
  30. package/modern/hooks/features/export/useGridPrintExport.js +8 -4
  31. package/modern/hooks/features/pagination/gridPaginationSelector.js +8 -2
  32. package/modern/hooks/features/pagination/useGridPagination.js +8 -151
  33. package/modern/hooks/features/pagination/useGridPaginationModel.js +171 -0
  34. package/modern/hooks/features/pagination/useGridRowCount.js +94 -0
  35. package/modern/index.js +1 -1
  36. package/node/DataGrid/DataGrid.js +5 -0
  37. package/node/components/GridPagination.js +1 -3
  38. package/node/components/panel/GridPanel.js +4 -1
  39. package/node/hooks/features/export/useGridPrintExport.js +8 -4
  40. package/node/hooks/features/pagination/gridPaginationSelector.js +8 -2
  41. package/node/hooks/features/pagination/useGridPagination.js +9 -155
  42. package/node/hooks/features/pagination/useGridPaginationModel.js +182 -0
  43. package/node/hooks/features/pagination/useGridRowCount.js +103 -0
  44. package/node/index.js +1 -1
  45. package/package.json +1 -1
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useGridRowCount = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _filter = require("../filter");
11
+ var _utils = require("../../utils");
12
+ var _pipeProcessing = require("../../core/pipeProcessing");
13
+ var _gridPaginationSelector = require("./gridPaginationSelector");
14
+ var _gridPaginationUtils = require("./gridPaginationUtils");
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
+ 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
+ const useGridRowCount = (apiRef, props) => {
22
+ const logger = (0, _utils.useGridLogger)(apiRef, 'useGridRowCount');
23
+ const visibleTopLevelRowCount = (0, _utils.useGridSelector)(apiRef, _filter.gridFilteredTopLevelRowCountSelector);
24
+ const rowCount = (0, _utils.useGridSelector)(apiRef, _gridPaginationSelector.gridPaginationRowCountSelector);
25
+ apiRef.current.registerControlState({
26
+ stateId: 'paginationRowCount',
27
+ propModel: props.rowCount,
28
+ propOnChange: props.onRowCountChange,
29
+ stateSelector: _gridPaginationSelector.gridPaginationRowCountSelector,
30
+ changeEvent: 'rowCountChange'
31
+ });
32
+
33
+ /**
34
+ * API METHODS
35
+ */
36
+ const setRowCount = React.useCallback(newRowCount => {
37
+ if (rowCount === newRowCount) {
38
+ return;
39
+ }
40
+ logger.debug("Setting 'rowCount' to", newRowCount);
41
+ apiRef.current.setState(state => (0, _extends2.default)({}, state, {
42
+ pagination: (0, _extends2.default)({}, state.pagination, {
43
+ rowCount: newRowCount
44
+ })
45
+ }));
46
+ }, [apiRef, logger, rowCount]);
47
+ const paginationRowCountApi = {
48
+ setRowCount
49
+ };
50
+ (0, _utils.useGridApiMethod)(apiRef, paginationRowCountApi, 'public');
51
+
52
+ /**
53
+ * PRE-PROCESSING
54
+ */
55
+ const stateExportPreProcessing = React.useCallback((prevState, context) => {
56
+ const exportedRowCount = (0, _gridPaginationSelector.gridPaginationRowCountSelector)(apiRef);
57
+ const shouldExportRowCount =
58
+ // Always export if the `exportOnlyDirtyModels` property is not activated
59
+ !context.exportOnlyDirtyModels ||
60
+ // Always export if the `rowCount` is controlled
61
+ props.rowCount != null ||
62
+ // Always export if the `rowCount` has been initialized
63
+ props.initialState?.pagination?.rowCount != null;
64
+ if (!shouldExportRowCount) {
65
+ return prevState;
66
+ }
67
+ return (0, _extends2.default)({}, prevState, {
68
+ pagination: (0, _extends2.default)({}, prevState.pagination, {
69
+ rowCount: exportedRowCount
70
+ })
71
+ });
72
+ }, [apiRef, props.rowCount, props.initialState?.pagination?.rowCount]);
73
+ const stateRestorePreProcessing = React.useCallback((params, context) => {
74
+ const restoredRowCount = context.stateToRestore.pagination?.rowCount ? context.stateToRestore.pagination.rowCount : (0, _gridPaginationSelector.gridPaginationRowCountSelector)(apiRef);
75
+ apiRef.current.setState(state => (0, _extends2.default)({}, state, {
76
+ pagination: (0, _extends2.default)({}, state.pagination, {
77
+ rowCount: restoredRowCount
78
+ })
79
+ }));
80
+ return params;
81
+ }, [apiRef]);
82
+ (0, _pipeProcessing.useGridRegisterPipeProcessor)(apiRef, 'exportState', stateExportPreProcessing);
83
+ (0, _pipeProcessing.useGridRegisterPipeProcessor)(apiRef, 'restoreState', stateRestorePreProcessing);
84
+
85
+ /**
86
+ * EFFECTS
87
+ */
88
+ React.useEffect(() => {
89
+ if (process.env.NODE_ENV !== 'production') {
90
+ if (props.paginationMode === 'server' && props.rowCount == null) {
91
+ (0, _gridPaginationUtils.noRowCountInServerMode)();
92
+ }
93
+ }
94
+ }, [props.rowCount, props.paginationMode]);
95
+ React.useEffect(() => {
96
+ if (props.paginationMode === 'client') {
97
+ apiRef.current.setRowCount(visibleTopLevelRowCount);
98
+ } else if (props.rowCount != null) {
99
+ apiRef.current.setRowCount(props.rowCount);
100
+ }
101
+ }, [apiRef, visibleTopLevelRowCount, props.paginationMode, props.rowCount]);
102
+ };
103
+ exports.useGridRowCount = useGridRowCount;
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.20.1
2
+ * @mui/x-data-grid v6.20.4
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "6.20.1",
3
+ "version": "6.20.4",
4
4
  "description": "The community edition of the data grid component (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",