@mui/x-data-grid-pro 7.7.1 → 7.8.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 +100 -1
- package/DataGridPro/DataGridPro.js +13 -1
- package/DataGridPro/useDataGridProComponent.js +6 -1
- package/DataGridPro/useDataGridProProps.js +10 -3
- package/components/GridDataSourceTreeDataGroupingCell.d.ts +12 -0
- package/components/GridDataSourceTreeDataGroupingCell.js +120 -0
- package/components/GridTreeDataGroupingCell.js +1 -4
- package/esm/DataGridPro/DataGridPro.js +13 -1
- package/esm/DataGridPro/useDataGridProComponent.js +6 -1
- package/esm/DataGridPro/useDataGridProProps.js +9 -3
- package/esm/components/GridDataSourceTreeDataGroupingCell.js +111 -0
- package/esm/components/GridTreeDataGroupingCell.js +1 -4
- package/esm/hooks/features/dataSource/cache.js +36 -0
- package/esm/hooks/features/dataSource/gridDataSourceSelector.js +24 -0
- package/esm/hooks/features/dataSource/useGridDataSource.js +218 -0
- package/esm/hooks/features/dataSource/utils.js +87 -0
- package/esm/hooks/features/index.js +3 -1
- package/esm/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.js +148 -0
- package/esm/hooks/features/serverSideTreeData/utils.js +18 -0
- package/esm/hooks/features/treeData/useGridTreeData.js +6 -2
- package/esm/hooks/features/treeData/useGridTreeDataPreProcessors.js +6 -3
- package/esm/internals/index.js +2 -0
- package/esm/internals/propValidation.js +1 -1
- package/esm/models/index.js +2 -1
- package/esm/utils/releaseInfo.js +1 -1
- package/esm/utils/tree/createRowTree.js +6 -2
- package/esm/utils/tree/insertDataRowInTree.js +34 -10
- package/esm/utils/tree/updateRowTree.js +13 -5
- package/esm/utils/tree/utils.js +5 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
- package/hooks/features/columnPinning/useGridColumnPinning.d.ts +1 -1
- package/hooks/features/columnReorder/useGridColumnReorder.d.ts +1 -1
- package/hooks/features/dataSource/cache.d.ts +18 -0
- package/hooks/features/dataSource/cache.js +43 -0
- package/hooks/features/dataSource/gridDataSourceSelector.d.ts +14 -0
- package/hooks/features/dataSource/gridDataSourceSelector.js +32 -0
- package/hooks/features/dataSource/interfaces.d.ts +50 -0
- package/hooks/features/dataSource/useGridDataSource.d.ts +6 -0
- package/hooks/features/dataSource/useGridDataSource.js +229 -0
- package/hooks/features/dataSource/utils.d.ts +29 -0
- package/hooks/features/dataSource/utils.js +95 -0
- package/hooks/features/detailPanel/gridDetailPanelSelector.d.ts +0 -1
- package/hooks/features/detailPanel/useGridDetailPanel.d.ts +1 -1
- package/hooks/features/index.d.ts +2 -0
- package/hooks/features/index.js +22 -0
- package/hooks/features/infiniteLoader/useGridInfiniteLoader.d.ts +1 -1
- package/hooks/features/lazyLoader/useGridLazyLoader.d.ts +1 -1
- package/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.d.ts +1 -1
- package/hooks/features/rowPinning/useGridRowPinning.d.ts +1 -1
- package/hooks/features/rowPinning/useGridRowPinningPreProcessors.d.ts +2 -2
- package/hooks/features/rowReorder/useGridRowReorder.d.ts +1 -1
- package/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.d.ts +4 -0
- package/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.js +158 -0
- package/hooks/features/serverSideTreeData/utils.d.ts +6 -0
- package/hooks/features/serverSideTreeData/utils.js +25 -0
- package/hooks/features/treeData/gridTreeDataUtils.d.ts +1 -2
- package/hooks/features/treeData/useGridTreeData.d.ts +2 -1
- package/hooks/features/treeData/useGridTreeData.js +6 -2
- package/hooks/features/treeData/useGridTreeDataPreProcessors.d.ts +1 -1
- package/hooks/features/treeData/useGridTreeDataPreProcessors.js +6 -3
- package/hooks/utils/useGridApiContext.d.ts +0 -1
- package/hooks/utils/useGridApiRef.d.ts +0 -1
- package/hooks/utils/useGridPrivateApiContext.d.ts +0 -1
- package/index.js +1 -1
- package/internals/index.d.ts +2 -0
- package/internals/index.js +23 -0
- package/internals/propValidation.js +1 -1
- package/material/index.d.ts +0 -1
- package/models/dataGridProProps.d.ts +17 -11
- package/models/gridApiPro.d.ts +3 -3
- package/models/gridProSlotsComponent.d.ts +0 -1
- package/models/gridStatePro.d.ts +2 -0
- package/models/index.d.ts +1 -0
- package/modern/DataGridPro/DataGridPro.js +13 -1
- package/modern/DataGridPro/useDataGridProComponent.js +6 -1
- package/modern/DataGridPro/useDataGridProProps.js +9 -3
- package/modern/components/GridDataSourceTreeDataGroupingCell.js +111 -0
- package/modern/components/GridTreeDataGroupingCell.js +1 -4
- package/modern/hooks/features/dataSource/cache.js +36 -0
- package/modern/hooks/features/dataSource/gridDataSourceSelector.js +24 -0
- package/modern/hooks/features/dataSource/useGridDataSource.js +218 -0
- package/modern/hooks/features/dataSource/utils.js +87 -0
- package/modern/hooks/features/index.js +3 -1
- package/modern/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.js +148 -0
- package/modern/hooks/features/serverSideTreeData/utils.js +18 -0
- package/modern/hooks/features/treeData/useGridTreeData.js +6 -2
- package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +6 -3
- package/modern/index.js +1 -1
- package/modern/internals/index.js +2 -0
- package/modern/internals/propValidation.js +1 -1
- package/modern/models/index.js +2 -1
- package/modern/utils/releaseInfo.js +1 -1
- package/modern/utils/tree/createRowTree.js +6 -2
- package/modern/utils/tree/insertDataRowInTree.js +34 -10
- package/modern/utils/tree/updateRowTree.js +13 -5
- package/modern/utils/tree/utils.js +5 -1
- package/package.json +3 -3
- package/typeOverloads/modules.d.ts +0 -1
- package/utils/releaseInfo.js +1 -1
- package/utils/tree/createRowTree.js +6 -2
- package/utils/tree/insertDataRowInTree.d.ts +3 -1
- package/utils/tree/insertDataRowInTree.js +33 -9
- package/utils/tree/models.d.ts +1 -0
- package/utils/tree/updateRowTree.d.ts +1 -0
- package/utils/tree/updateRowTree.js +13 -5
- package/utils/tree/utils.d.ts +5 -4
- package/utils/tree/utils.js +7 -2
- package/models/dataSource.d.ts +0 -64
- /package/esm/{models/dataSource.js → hooks/features/dataSource/interfaces.js} +0 -0
- /package/{models/dataSource.js → hooks/features/dataSource/interfaces.js} +0 -0
- /package/modern/{models/dataSource.js → hooks/features/dataSource/interfaces.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,105 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 7.8.0
|
|
7
|
+
|
|
8
|
+
_Jun 28, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 10 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🛰 Introduce server-side data source for improved server integration in the Data Grid.
|
|
13
|
+
|
|
14
|
+
Supports server-side pagination, sorting and filtering on plain and tree data, and automatic caching.
|
|
15
|
+
|
|
16
|
+
To enable, provide a `getRows` function to the `unstable_dataSource` prop on the Data Grid component.
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
const dataSource = {
|
|
20
|
+
getRows: async (params: GridServerGetRowsParams) => {
|
|
21
|
+
const data = await fetch(
|
|
22
|
+
`https://api.example.com/data?${new URLSearchParams({
|
|
23
|
+
page: params.page,
|
|
24
|
+
pageSize: params.pageSize,
|
|
25
|
+
sortModel: JSON.stringify(params.sortModel),
|
|
26
|
+
filterModel: JSON.stringify(params.filterModel),
|
|
27
|
+
}).toString()}`,
|
|
28
|
+
);
|
|
29
|
+
return {
|
|
30
|
+
rows: data.rows,
|
|
31
|
+
totalRows: data.totalRows,
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
<DataGridPro
|
|
36
|
+
unstable_dataSource={dataSource}
|
|
37
|
+
{...otherProps}
|
|
38
|
+
/>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
See [server-side data documentation](https://mui.com/x/react-data-grid/server-side-data/) for more details.
|
|
42
|
+
|
|
43
|
+
- 📈 Support Date data on the BarChart component
|
|
44
|
+
- ↕️ Support custom column sort icons on the Data Grid
|
|
45
|
+
- 🖱️ Support modifying the expansion trigger on the Tree View components
|
|
46
|
+
|
|
47
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
48
|
+
|
|
49
|
+
### Data Grid
|
|
50
|
+
|
|
51
|
+
#### `@mui/x-data-grid@7.8.0`
|
|
52
|
+
|
|
53
|
+
- [DataGrid] Add `columnHeaderSortIcon` slot (#13563) @arminmeh
|
|
54
|
+
- [DataGrid] Fix dimensions lag issue after autosize (#13587) @MBilalShafi
|
|
55
|
+
- [DataGrid] Fix print export failure when `hideFooter` option is set (#13034) @tarunrajput
|
|
56
|
+
|
|
57
|
+
#### `@mui/x-data-grid-pro@7.8.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
58
|
+
|
|
59
|
+
Same changes as in `@mui/x-data-grid@7.8.0`, plus:
|
|
60
|
+
|
|
61
|
+
- [DataGridPro] Fix multi-sorting indicator being cut off (#13625) @KenanYusuf
|
|
62
|
+
- [DataGridPro] Server-side tree data support (#12317) @MBilalShafi
|
|
63
|
+
|
|
64
|
+
#### `@mui/x-data-grid-premium@7.8.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
65
|
+
|
|
66
|
+
Same changes as in `@mui/x-data-grid-pro@7.8.0`.
|
|
67
|
+
|
|
68
|
+
### Date and Time Pickers
|
|
69
|
+
|
|
70
|
+
#### `@mui/x-date-pickers@7.8.0`
|
|
71
|
+
|
|
72
|
+
- [fields] Fix section clearing behavior on Android (#13652) @LukasTy
|
|
73
|
+
|
|
74
|
+
#### `@mui/x-date-pickers-pro@7.8.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
75
|
+
|
|
76
|
+
Same changes as in `@mui/x-date-pickers@7.8.0`.
|
|
77
|
+
|
|
78
|
+
### Charts
|
|
79
|
+
|
|
80
|
+
#### `@mui/x-charts@7.8.0`
|
|
81
|
+
|
|
82
|
+
- [charts] Fix line chart props not passing correct event handlers (#13609) @JCQuintas
|
|
83
|
+
- [charts] Support BarChart with `Date` data (#13471) @alexfauquette
|
|
84
|
+
- [charts] Support RTL for y-axis (#13614) @alexfauquette
|
|
85
|
+
- [charts] Use default values instead of non-null assertion to prevent error being thrown (#13637) @JCQuintas
|
|
86
|
+
|
|
87
|
+
### Tree View
|
|
88
|
+
|
|
89
|
+
#### `@mui/x-tree-view@7.8.0`
|
|
90
|
+
|
|
91
|
+
- [TreeView] Add `expansionTrigger` prop (#13533) @noraleonte
|
|
92
|
+
- [TreeView] Support experimental features from plugin's dependencies (#13632) @flaviendelangle
|
|
93
|
+
|
|
94
|
+
### Docs
|
|
95
|
+
|
|
96
|
+
- [docs] Add callout for `Luxon` `throwOnInvalid` support (#13621) @LukasTy
|
|
97
|
+
- [docs] Add "Overlays" section to the Data Grid documentation (#13624) @KenanYusuf
|
|
98
|
+
|
|
99
|
+
### Core
|
|
100
|
+
|
|
101
|
+
- [core] Add eslint rule to restrict import from `../internals` root (#13633) @JCQuintas
|
|
102
|
+
- [docs-infra] Sync `\_app` folder with monorepo (#13582) @Janpot
|
|
103
|
+
- [license] Allow usage of charts and tree view pro package for old premium licenses (#13619) @flaviendelangle
|
|
104
|
+
|
|
6
105
|
## 7.7.1
|
|
7
106
|
|
|
8
107
|
_Jun 21, 2024_
|
|
@@ -44,7 +143,7 @@ Same changes as in `@mui/x-data-grid-pro@7.7.1`.
|
|
|
44
143
|
- [pickers] Always use the same timezone in the field, the view and the layout components (#13481) @flaviendelangle
|
|
45
144
|
- [pickers] Fix `AdapterDateFnsV3` generated method types (#13464) @alexey-kozlenkov
|
|
46
145
|
- [pickers] Fix controlled `view` behavior (#13552) @LukasTy
|
|
47
|
-
- [TimePicker] Improves RTL verification for the time pickers default views
|
|
146
|
+
- [TimePicker] Improves RTL verification for the time pickers default views (#13447) @arthurbalduini
|
|
48
147
|
|
|
49
148
|
#### `@mui/x-date-pickers-pro@7.7.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
50
149
|
|
|
@@ -906,5 +906,17 @@ DataGridProRaw.propTypes = {
|
|
|
906
906
|
* If `true`, the rows will be gathered in a tree structure according to the `getTreeDataPath` prop.
|
|
907
907
|
* @default false
|
|
908
908
|
*/
|
|
909
|
-
treeData: _propTypes.default.bool
|
|
909
|
+
treeData: _propTypes.default.bool,
|
|
910
|
+
unstable_dataSource: _propTypes.default.shape({
|
|
911
|
+
getChildrenCount: _propTypes.default.func,
|
|
912
|
+
getGroupKey: _propTypes.default.func,
|
|
913
|
+
getRows: _propTypes.default.func.isRequired,
|
|
914
|
+
updateRow: _propTypes.default.func
|
|
915
|
+
}),
|
|
916
|
+
unstable_dataSourceCache: _propTypes.default.shape({
|
|
917
|
+
clear: _propTypes.default.func.isRequired,
|
|
918
|
+
get: _propTypes.default.func.isRequired,
|
|
919
|
+
set: _propTypes.default.func.isRequired
|
|
920
|
+
}),
|
|
921
|
+
unstable_onDataSourceError: _propTypes.default.func
|
|
910
922
|
};
|
|
@@ -9,6 +9,7 @@ var _useGridInfiniteLoader = require("../hooks/features/infiniteLoader/useGridIn
|
|
|
9
9
|
var _useGridColumnReorder = require("../hooks/features/columnReorder/useGridColumnReorder");
|
|
10
10
|
var _useGridTreeData = require("../hooks/features/treeData/useGridTreeData");
|
|
11
11
|
var _useGridTreeDataPreProcessors = require("../hooks/features/treeData/useGridTreeDataPreProcessors");
|
|
12
|
+
var _useGridDataSourceTreeDataPreProcessors = require("../hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors");
|
|
12
13
|
var _useGridColumnPinning = require("../hooks/features/columnPinning/useGridColumnPinning");
|
|
13
14
|
var _useGridColumnPinningPreProcessors = require("../hooks/features/columnPinning/useGridColumnPinningPreProcessors");
|
|
14
15
|
var _useGridDetailPanel = require("../hooks/features/detailPanel/useGridDetailPanel");
|
|
@@ -19,6 +20,7 @@ var _useGridLazyLoader = require("../hooks/features/lazyLoader/useGridLazyLoader
|
|
|
19
20
|
var _useGridLazyLoaderPreProcessors = require("../hooks/features/lazyLoader/useGridLazyLoaderPreProcessors");
|
|
20
21
|
var _useGridRowPinning = require("../hooks/features/rowPinning/useGridRowPinning");
|
|
21
22
|
var _useGridRowPinningPreProcessors = require("../hooks/features/rowPinning/useGridRowPinningPreProcessors");
|
|
23
|
+
var _useGridDataSource = require("../hooks/features/dataSource/useGridDataSource");
|
|
22
24
|
// Pro-only features
|
|
23
25
|
|
|
24
26
|
const useDataGridProComponent = (inputApiRef, props) => {
|
|
@@ -30,6 +32,7 @@ const useDataGridProComponent = (inputApiRef, props) => {
|
|
|
30
32
|
(0, _internals.useGridRowSelectionPreProcessors)(apiRef, props);
|
|
31
33
|
(0, _useGridRowReorderPreProcessors.useGridRowReorderPreProcessors)(apiRef, props);
|
|
32
34
|
(0, _useGridTreeDataPreProcessors.useGridTreeDataPreProcessors)(apiRef, props);
|
|
35
|
+
(0, _useGridDataSourceTreeDataPreProcessors.useGridDataSourceTreeDataPreProcessors)(apiRef, props);
|
|
33
36
|
(0, _useGridLazyLoaderPreProcessors.useGridLazyLoaderPreProcessors)(apiRef, props);
|
|
34
37
|
(0, _useGridRowPinningPreProcessors.useGridRowPinningPreProcessors)(apiRef);
|
|
35
38
|
(0, _useGridDetailPanelPreProcessors.useGridDetailPanelPreProcessors)(apiRef, props);
|
|
@@ -62,8 +65,9 @@ const useDataGridProComponent = (inputApiRef, props) => {
|
|
|
62
65
|
(0, _internals.useGridInitializeState)(_internals.columnMenuStateInitializer, apiRef, props);
|
|
63
66
|
(0, _internals.useGridInitializeState)(_internals.columnGroupsStateInitializer, apiRef, props);
|
|
64
67
|
(0, _internals.useGridInitializeState)(_internals.virtualizationStateInitializer, apiRef, props);
|
|
68
|
+
(0, _internals.useGridInitializeState)(_useGridDataSource.dataSourceStateInitializer, apiRef, props);
|
|
65
69
|
(0, _internals.useGridHeaderFiltering)(apiRef, props);
|
|
66
|
-
(0, _useGridTreeData.useGridTreeData)(apiRef);
|
|
70
|
+
(0, _useGridTreeData.useGridTreeData)(apiRef, props);
|
|
67
71
|
(0, _internals.useGridKeyboardNavigation)(apiRef, props);
|
|
68
72
|
(0, _internals.useGridRowSelection)(apiRef, props);
|
|
69
73
|
(0, _useGridColumnPinning.useGridColumnPinning)(apiRef, props);
|
|
@@ -96,6 +100,7 @@ const useDataGridProComponent = (inputApiRef, props) => {
|
|
|
96
100
|
(0, _internals.useGridEvents)(apiRef, props);
|
|
97
101
|
(0, _internals.useGridStatePersistence)(apiRef);
|
|
98
102
|
(0, _internals.useGridVirtualization)(apiRef, props);
|
|
103
|
+
(0, _useGridDataSource.useGridDataSource)(apiRef, props);
|
|
99
104
|
return apiRef;
|
|
100
105
|
};
|
|
101
106
|
exports.useDataGridProComponent = useDataGridProComponent;
|
|
@@ -13,6 +13,14 @@ var _internals = require("@mui/x-data-grid/internals");
|
|
|
13
13
|
var _dataGridProDefaultSlotsComponents = require("../constants/dataGridProDefaultSlotsComponents");
|
|
14
14
|
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); }
|
|
15
15
|
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 && {}.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; }
|
|
16
|
+
const getDataGridProForcedProps = themedProps => (0, _extends2.default)({
|
|
17
|
+
signature: 'DataGridPro'
|
|
18
|
+
}, themedProps.unstable_dataSource ? {
|
|
19
|
+
filterMode: 'server',
|
|
20
|
+
sortingMode: 'server',
|
|
21
|
+
paginationMode: 'server'
|
|
22
|
+
} : {});
|
|
23
|
+
|
|
16
24
|
/**
|
|
17
25
|
* The default values of `DataGridProPropsWithDefaultValue` to inject in the props of DataGridPro.
|
|
18
26
|
*/
|
|
@@ -46,8 +54,7 @@ const useDataGridProProps = inProps => {
|
|
|
46
54
|
}), [themedProps.slots]);
|
|
47
55
|
return React.useMemo(() => (0, _extends2.default)({}, DATA_GRID_PRO_PROPS_DEFAULT_VALUES, themedProps, {
|
|
48
56
|
localeText,
|
|
49
|
-
slots
|
|
50
|
-
|
|
51
|
-
}), [themedProps, localeText, slots]);
|
|
57
|
+
slots
|
|
58
|
+
}, getDataGridProForcedProps(themedProps)), [themedProps, localeText, slots]);
|
|
52
59
|
};
|
|
53
60
|
exports.useDataGridProProps = useDataGridProProps;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GridRenderCellParams, GridDataSourceGroupNode } from '@mui/x-data-grid';
|
|
3
|
+
interface GridTreeDataGroupingCellProps extends GridRenderCellParams<any, any, any, GridDataSourceGroupNode> {
|
|
4
|
+
hideDescendantCount?: boolean;
|
|
5
|
+
/**
|
|
6
|
+
* The cell offset multiplier used for calculating cell offset (`rowNode.depth * offsetMultiplier` px).
|
|
7
|
+
* @default 2
|
|
8
|
+
*/
|
|
9
|
+
offsetMultiplier?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function GridDataSourceTreeDataGroupingCell(props: GridTreeDataGroupingCellProps): React.JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.GridDataSourceTreeDataGroupingCell = GridDataSourceTreeDataGroupingCell;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _utils = require("@mui/utils");
|
|
11
|
+
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
12
|
+
var _Badge = _interopRequireDefault(require("@mui/material/Badge"));
|
|
13
|
+
var _xDataGrid = require("@mui/x-data-grid");
|
|
14
|
+
var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
|
|
15
|
+
var _useGridRootProps = require("../hooks/utils/useGridRootProps");
|
|
16
|
+
var _useGridPrivateApiContext = require("../hooks/utils/useGridPrivateApiContext");
|
|
17
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
+
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); }
|
|
19
|
+
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 && {}.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; }
|
|
20
|
+
const useUtilityClasses = ownerState => {
|
|
21
|
+
const {
|
|
22
|
+
classes
|
|
23
|
+
} = ownerState;
|
|
24
|
+
const slots = {
|
|
25
|
+
root: ['treeDataGroupingCell'],
|
|
26
|
+
toggle: ['treeDataGroupingCellToggle'],
|
|
27
|
+
loadingContainer: ['treeDataGroupingCellLoadingContainer']
|
|
28
|
+
};
|
|
29
|
+
return (0, _utils.unstable_composeClasses)(slots, _xDataGrid.getDataGridUtilityClass, classes);
|
|
30
|
+
};
|
|
31
|
+
function GridTreeDataGroupingCellIcon(props) {
|
|
32
|
+
const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
|
|
33
|
+
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
34
|
+
const classes = useUtilityClasses(rootProps);
|
|
35
|
+
const {
|
|
36
|
+
rowNode,
|
|
37
|
+
id,
|
|
38
|
+
field,
|
|
39
|
+
descendantCount
|
|
40
|
+
} = props;
|
|
41
|
+
const loadingSelector = state => state.dataSource.loading[id] ?? false;
|
|
42
|
+
const errorSelector = state => state.dataSource.errors[id];
|
|
43
|
+
const isDataLoading = (0, _xDataGrid.useGridSelector)(apiRef, loadingSelector);
|
|
44
|
+
const error = (0, _xDataGrid.useGridSelector)(apiRef, errorSelector);
|
|
45
|
+
const handleClick = event => {
|
|
46
|
+
if (!rowNode.childrenExpanded) {
|
|
47
|
+
// always fetch/get from cache the children when the node is expanded
|
|
48
|
+
apiRef.current.unstable_dataSource.fetchRows(id);
|
|
49
|
+
} else {
|
|
50
|
+
apiRef.current.setRowChildrenExpansion(id, !rowNode.childrenExpanded);
|
|
51
|
+
}
|
|
52
|
+
apiRef.current.setCellFocus(id, field);
|
|
53
|
+
event.stopPropagation(); // TODO remove event.stopPropagation
|
|
54
|
+
};
|
|
55
|
+
const Icon = rowNode.childrenExpanded ? rootProps.slots.treeDataCollapseIcon : rootProps.slots.treeDataExpandIcon;
|
|
56
|
+
if (isDataLoading) {
|
|
57
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
58
|
+
className: classes.loadingContainer,
|
|
59
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
|
|
60
|
+
size: "1rem",
|
|
61
|
+
color: "inherit"
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return descendantCount > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseIconButton, (0, _extends2.default)({
|
|
66
|
+
size: "small",
|
|
67
|
+
onClick: handleClick,
|
|
68
|
+
tabIndex: -1,
|
|
69
|
+
"aria-label": rowNode.childrenExpanded ? apiRef.current.getLocaleText('treeDataCollapse') : apiRef.current.getLocaleText('treeDataExpand')
|
|
70
|
+
}, rootProps?.slotProps?.baseIconButton, {
|
|
71
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseTooltip, {
|
|
72
|
+
title: error?.message ?? null,
|
|
73
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Badge.default, {
|
|
74
|
+
variant: "dot",
|
|
75
|
+
color: "error",
|
|
76
|
+
invisible: !error,
|
|
77
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, {
|
|
78
|
+
fontSize: "inherit"
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
})) : null;
|
|
83
|
+
}
|
|
84
|
+
function GridDataSourceTreeDataGroupingCell(props) {
|
|
85
|
+
const {
|
|
86
|
+
id,
|
|
87
|
+
field,
|
|
88
|
+
formattedValue,
|
|
89
|
+
rowNode,
|
|
90
|
+
hideDescendantCount,
|
|
91
|
+
offsetMultiplier = 2
|
|
92
|
+
} = props;
|
|
93
|
+
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
94
|
+
const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
|
|
95
|
+
const rowSelector = state => state.rows.dataRowIdToModelLookup[id];
|
|
96
|
+
const row = (0, _xDataGrid.useGridSelector)(apiRef, rowSelector);
|
|
97
|
+
const classes = useUtilityClasses(rootProps);
|
|
98
|
+
let descendantCount = 0;
|
|
99
|
+
if (row) {
|
|
100
|
+
descendantCount = Math.max(rootProps.unstable_dataSource?.getChildrenCount?.(row) ?? 0, 0);
|
|
101
|
+
}
|
|
102
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
103
|
+
className: classes.root,
|
|
104
|
+
sx: {
|
|
105
|
+
ml: rowNode.depth * offsetMultiplier
|
|
106
|
+
},
|
|
107
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
108
|
+
className: classes.toggle,
|
|
109
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(GridTreeDataGroupingCellIcon, {
|
|
110
|
+
id: id,
|
|
111
|
+
field: field,
|
|
112
|
+
rowNode: rowNode,
|
|
113
|
+
row: row,
|
|
114
|
+
descendantCount: descendantCount
|
|
115
|
+
})
|
|
116
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
117
|
+
children: [formattedValue === undefined ? rowNode.groupingKey : formattedValue, !hideDescendantCount && descendantCount > 0 ? ` (${descendantCount})` : '']
|
|
118
|
+
})]
|
|
119
|
+
});
|
|
120
|
+
}
|
|
@@ -37,10 +37,7 @@ function GridTreeDataGroupingCell(props) {
|
|
|
37
37
|
} = props;
|
|
38
38
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
39
39
|
const apiRef = (0, _useGridApiContext.useGridApiContext)();
|
|
40
|
-
const
|
|
41
|
-
classes: rootProps.classes
|
|
42
|
-
};
|
|
43
|
-
const classes = useUtilityClasses(ownerState);
|
|
40
|
+
const classes = useUtilityClasses(rootProps);
|
|
44
41
|
const filteredDescendantCountLookup = (0, _xDataGrid.useGridSelector)(apiRef, _xDataGrid.gridFilteredDescendantCountLookupSelector);
|
|
45
42
|
const filteredDescendantCount = filteredDescendantCountLookup[rowNode.id] ?? 0;
|
|
46
43
|
const Icon = rowNode.childrenExpanded ? rootProps.slots.treeDataCollapseIcon : rootProps.slots.treeDataExpandIcon;
|
|
@@ -898,5 +898,17 @@ DataGridProRaw.propTypes = {
|
|
|
898
898
|
* If `true`, the rows will be gathered in a tree structure according to the `getTreeDataPath` prop.
|
|
899
899
|
* @default false
|
|
900
900
|
*/
|
|
901
|
-
treeData: PropTypes.bool
|
|
901
|
+
treeData: PropTypes.bool,
|
|
902
|
+
unstable_dataSource: PropTypes.shape({
|
|
903
|
+
getChildrenCount: PropTypes.func,
|
|
904
|
+
getGroupKey: PropTypes.func,
|
|
905
|
+
getRows: PropTypes.func.isRequired,
|
|
906
|
+
updateRow: PropTypes.func
|
|
907
|
+
}),
|
|
908
|
+
unstable_dataSourceCache: PropTypes.shape({
|
|
909
|
+
clear: PropTypes.func.isRequired,
|
|
910
|
+
get: PropTypes.func.isRequired,
|
|
911
|
+
set: PropTypes.func.isRequired
|
|
912
|
+
}),
|
|
913
|
+
unstable_onDataSourceError: PropTypes.func
|
|
902
914
|
};
|
|
@@ -4,6 +4,7 @@ import { useGridInfiniteLoader } from '../hooks/features/infiniteLoader/useGridI
|
|
|
4
4
|
import { useGridColumnReorder, columnReorderStateInitializer } from '../hooks/features/columnReorder/useGridColumnReorder';
|
|
5
5
|
import { useGridTreeData } from '../hooks/features/treeData/useGridTreeData';
|
|
6
6
|
import { useGridTreeDataPreProcessors } from '../hooks/features/treeData/useGridTreeDataPreProcessors';
|
|
7
|
+
import { useGridDataSourceTreeDataPreProcessors } from '../hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors';
|
|
7
8
|
import { useGridColumnPinning, columnPinningStateInitializer } from '../hooks/features/columnPinning/useGridColumnPinning';
|
|
8
9
|
import { useGridColumnPinningPreProcessors } from '../hooks/features/columnPinning/useGridColumnPinningPreProcessors';
|
|
9
10
|
import { useGridDetailPanel, detailPanelStateInitializer } from '../hooks/features/detailPanel/useGridDetailPanel';
|
|
@@ -14,6 +15,7 @@ import { useGridLazyLoader } from '../hooks/features/lazyLoader/useGridLazyLoade
|
|
|
14
15
|
import { useGridLazyLoaderPreProcessors } from '../hooks/features/lazyLoader/useGridLazyLoaderPreProcessors';
|
|
15
16
|
import { useGridRowPinning, rowPinningStateInitializer } from '../hooks/features/rowPinning/useGridRowPinning';
|
|
16
17
|
import { useGridRowPinningPreProcessors } from '../hooks/features/rowPinning/useGridRowPinningPreProcessors';
|
|
18
|
+
import { useGridDataSource, dataSourceStateInitializer } from '../hooks/features/dataSource/useGridDataSource';
|
|
17
19
|
export const useDataGridProComponent = (inputApiRef, props) => {
|
|
18
20
|
const apiRef = useGridInitialization(inputApiRef, props);
|
|
19
21
|
|
|
@@ -23,6 +25,7 @@ export const useDataGridProComponent = (inputApiRef, props) => {
|
|
|
23
25
|
useGridRowSelectionPreProcessors(apiRef, props);
|
|
24
26
|
useGridRowReorderPreProcessors(apiRef, props);
|
|
25
27
|
useGridTreeDataPreProcessors(apiRef, props);
|
|
28
|
+
useGridDataSourceTreeDataPreProcessors(apiRef, props);
|
|
26
29
|
useGridLazyLoaderPreProcessors(apiRef, props);
|
|
27
30
|
useGridRowPinningPreProcessors(apiRef);
|
|
28
31
|
useGridDetailPanelPreProcessors(apiRef, props);
|
|
@@ -55,8 +58,9 @@ export const useDataGridProComponent = (inputApiRef, props) => {
|
|
|
55
58
|
useGridInitializeState(columnMenuStateInitializer, apiRef, props);
|
|
56
59
|
useGridInitializeState(columnGroupsStateInitializer, apiRef, props);
|
|
57
60
|
useGridInitializeState(virtualizationStateInitializer, apiRef, props);
|
|
61
|
+
useGridInitializeState(dataSourceStateInitializer, apiRef, props);
|
|
58
62
|
useGridHeaderFiltering(apiRef, props);
|
|
59
|
-
useGridTreeData(apiRef);
|
|
63
|
+
useGridTreeData(apiRef, props);
|
|
60
64
|
useGridKeyboardNavigation(apiRef, props);
|
|
61
65
|
useGridRowSelection(apiRef, props);
|
|
62
66
|
useGridColumnPinning(apiRef, props);
|
|
@@ -89,5 +93,6 @@ export const useDataGridProComponent = (inputApiRef, props) => {
|
|
|
89
93
|
useGridEvents(apiRef, props);
|
|
90
94
|
useGridStatePersistence(apiRef);
|
|
91
95
|
useGridVirtualization(apiRef, props);
|
|
96
|
+
useGridDataSource(apiRef, props);
|
|
92
97
|
return apiRef;
|
|
93
98
|
};
|
|
@@ -4,6 +4,13 @@ import { useThemeProps } from '@mui/material/styles';
|
|
|
4
4
|
import { GRID_DEFAULT_LOCALE_TEXT, DATA_GRID_PROPS_DEFAULT_VALUES } from '@mui/x-data-grid';
|
|
5
5
|
import { computeSlots, useProps } from '@mui/x-data-grid/internals';
|
|
6
6
|
import { DATA_GRID_PRO_DEFAULT_SLOTS_COMPONENTS } from '../constants/dataGridProDefaultSlotsComponents';
|
|
7
|
+
const getDataGridProForcedProps = themedProps => _extends({
|
|
8
|
+
signature: 'DataGridPro'
|
|
9
|
+
}, themedProps.unstable_dataSource ? {
|
|
10
|
+
filterMode: 'server',
|
|
11
|
+
sortingMode: 'server',
|
|
12
|
+
paginationMode: 'server'
|
|
13
|
+
} : {});
|
|
7
14
|
|
|
8
15
|
/**
|
|
9
16
|
* The default values of `DataGridProPropsWithDefaultValue` to inject in the props of DataGridPro.
|
|
@@ -38,7 +45,6 @@ export const useDataGridProProps = inProps => {
|
|
|
38
45
|
}), [themedProps.slots]);
|
|
39
46
|
return React.useMemo(() => _extends({}, DATA_GRID_PRO_PROPS_DEFAULT_VALUES, themedProps, {
|
|
40
47
|
localeText,
|
|
41
|
-
slots
|
|
42
|
-
|
|
43
|
-
}), [themedProps, localeText, slots]);
|
|
48
|
+
slots
|
|
49
|
+
}, getDataGridProForcedProps(themedProps)), [themedProps, localeText, slots]);
|
|
44
50
|
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
4
|
+
import Box from '@mui/material/Box';
|
|
5
|
+
import Badge from '@mui/material/Badge';
|
|
6
|
+
import { getDataGridUtilityClass, useGridSelector } from '@mui/x-data-grid';
|
|
7
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
8
|
+
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
9
|
+
import { useGridPrivateApiContext } from '../hooks/utils/useGridPrivateApiContext';
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
const useUtilityClasses = ownerState => {
|
|
12
|
+
const {
|
|
13
|
+
classes
|
|
14
|
+
} = ownerState;
|
|
15
|
+
const slots = {
|
|
16
|
+
root: ['treeDataGroupingCell'],
|
|
17
|
+
toggle: ['treeDataGroupingCellToggle'],
|
|
18
|
+
loadingContainer: ['treeDataGroupingCellLoadingContainer']
|
|
19
|
+
};
|
|
20
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
21
|
+
};
|
|
22
|
+
function GridTreeDataGroupingCellIcon(props) {
|
|
23
|
+
const apiRef = useGridPrivateApiContext();
|
|
24
|
+
const rootProps = useGridRootProps();
|
|
25
|
+
const classes = useUtilityClasses(rootProps);
|
|
26
|
+
const {
|
|
27
|
+
rowNode,
|
|
28
|
+
id,
|
|
29
|
+
field,
|
|
30
|
+
descendantCount
|
|
31
|
+
} = props;
|
|
32
|
+
const loadingSelector = state => state.dataSource.loading[id] ?? false;
|
|
33
|
+
const errorSelector = state => state.dataSource.errors[id];
|
|
34
|
+
const isDataLoading = useGridSelector(apiRef, loadingSelector);
|
|
35
|
+
const error = useGridSelector(apiRef, errorSelector);
|
|
36
|
+
const handleClick = event => {
|
|
37
|
+
if (!rowNode.childrenExpanded) {
|
|
38
|
+
// always fetch/get from cache the children when the node is expanded
|
|
39
|
+
apiRef.current.unstable_dataSource.fetchRows(id);
|
|
40
|
+
} else {
|
|
41
|
+
apiRef.current.setRowChildrenExpansion(id, !rowNode.childrenExpanded);
|
|
42
|
+
}
|
|
43
|
+
apiRef.current.setCellFocus(id, field);
|
|
44
|
+
event.stopPropagation(); // TODO remove event.stopPropagation
|
|
45
|
+
};
|
|
46
|
+
const Icon = rowNode.childrenExpanded ? rootProps.slots.treeDataCollapseIcon : rootProps.slots.treeDataExpandIcon;
|
|
47
|
+
if (isDataLoading) {
|
|
48
|
+
return /*#__PURE__*/_jsx("div", {
|
|
49
|
+
className: classes.loadingContainer,
|
|
50
|
+
children: /*#__PURE__*/_jsx(CircularProgress, {
|
|
51
|
+
size: "1rem",
|
|
52
|
+
color: "inherit"
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return descendantCount > 0 ? /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
|
|
57
|
+
size: "small",
|
|
58
|
+
onClick: handleClick,
|
|
59
|
+
tabIndex: -1,
|
|
60
|
+
"aria-label": rowNode.childrenExpanded ? apiRef.current.getLocaleText('treeDataCollapse') : apiRef.current.getLocaleText('treeDataExpand')
|
|
61
|
+
}, rootProps?.slotProps?.baseIconButton, {
|
|
62
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, {
|
|
63
|
+
title: error?.message ?? null,
|
|
64
|
+
children: /*#__PURE__*/_jsx(Badge, {
|
|
65
|
+
variant: "dot",
|
|
66
|
+
color: "error",
|
|
67
|
+
invisible: !error,
|
|
68
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
69
|
+
fontSize: "inherit"
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
})) : null;
|
|
74
|
+
}
|
|
75
|
+
export function GridDataSourceTreeDataGroupingCell(props) {
|
|
76
|
+
const {
|
|
77
|
+
id,
|
|
78
|
+
field,
|
|
79
|
+
formattedValue,
|
|
80
|
+
rowNode,
|
|
81
|
+
hideDescendantCount,
|
|
82
|
+
offsetMultiplier = 2
|
|
83
|
+
} = props;
|
|
84
|
+
const rootProps = useGridRootProps();
|
|
85
|
+
const apiRef = useGridPrivateApiContext();
|
|
86
|
+
const rowSelector = state => state.rows.dataRowIdToModelLookup[id];
|
|
87
|
+
const row = useGridSelector(apiRef, rowSelector);
|
|
88
|
+
const classes = useUtilityClasses(rootProps);
|
|
89
|
+
let descendantCount = 0;
|
|
90
|
+
if (row) {
|
|
91
|
+
descendantCount = Math.max(rootProps.unstable_dataSource?.getChildrenCount?.(row) ?? 0, 0);
|
|
92
|
+
}
|
|
93
|
+
return /*#__PURE__*/_jsxs(Box, {
|
|
94
|
+
className: classes.root,
|
|
95
|
+
sx: {
|
|
96
|
+
ml: rowNode.depth * offsetMultiplier
|
|
97
|
+
},
|
|
98
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
99
|
+
className: classes.toggle,
|
|
100
|
+
children: /*#__PURE__*/_jsx(GridTreeDataGroupingCellIcon, {
|
|
101
|
+
id: id,
|
|
102
|
+
field: field,
|
|
103
|
+
rowNode: rowNode,
|
|
104
|
+
row: row,
|
|
105
|
+
descendantCount: descendantCount
|
|
106
|
+
})
|
|
107
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
108
|
+
children: [formattedValue === undefined ? rowNode.groupingKey : formattedValue, !hideDescendantCount && descendantCount > 0 ? ` (${descendantCount})` : '']
|
|
109
|
+
})]
|
|
110
|
+
});
|
|
111
|
+
}
|
|
@@ -28,10 +28,7 @@ function GridTreeDataGroupingCell(props) {
|
|
|
28
28
|
} = props;
|
|
29
29
|
const rootProps = useGridRootProps();
|
|
30
30
|
const apiRef = useGridApiContext();
|
|
31
|
-
const
|
|
32
|
-
classes: rootProps.classes
|
|
33
|
-
};
|
|
34
|
-
const classes = useUtilityClasses(ownerState);
|
|
31
|
+
const classes = useUtilityClasses(rootProps);
|
|
35
32
|
const filteredDescendantCountLookup = useGridSelector(apiRef, gridFilteredDescendantCountLookupSelector);
|
|
36
33
|
const filteredDescendantCount = filteredDescendantCountLookup[rowNode.id] ?? 0;
|
|
37
34
|
const Icon = rowNode.childrenExpanded ? rootProps.slots.treeDataCollapseIcon : rootProps.slots.treeDataExpandIcon;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
function getKey(params) {
|
|
2
|
+
return JSON.stringify([params.paginationModel, params.filterModel, params.sortModel, params.groupKeys]);
|
|
3
|
+
}
|
|
4
|
+
export class GridDataSourceCacheDefault {
|
|
5
|
+
constructor({
|
|
6
|
+
ttl = 300000
|
|
7
|
+
}) {
|
|
8
|
+
this.cache = void 0;
|
|
9
|
+
this.ttl = void 0;
|
|
10
|
+
this.cache = {};
|
|
11
|
+
this.ttl = ttl;
|
|
12
|
+
}
|
|
13
|
+
set(key, value) {
|
|
14
|
+
const keyString = getKey(key);
|
|
15
|
+
const expiry = Date.now() + this.ttl;
|
|
16
|
+
this.cache[keyString] = {
|
|
17
|
+
value,
|
|
18
|
+
expiry
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
get(key) {
|
|
22
|
+
const keyString = getKey(key);
|
|
23
|
+
const entry = this.cache[keyString];
|
|
24
|
+
if (!entry) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
if (Date.now() > entry.expiry) {
|
|
28
|
+
delete this.cache[keyString];
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
return entry.value;
|
|
32
|
+
}
|
|
33
|
+
clear() {
|
|
34
|
+
this.cache = {};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { gridFilterModelSelector, gridSortModelSelector, gridPaginationModelSelector } from '@mui/x-data-grid';
|
|
3
|
+
import { createSelector } from '@mui/x-data-grid/internals';
|
|
4
|
+
const computeStartEnd = paginationModel => {
|
|
5
|
+
const start = paginationModel.page * paginationModel.pageSize;
|
|
6
|
+
const end = start + paginationModel.pageSize - 1;
|
|
7
|
+
return {
|
|
8
|
+
start,
|
|
9
|
+
end
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export const gridGetRowsParamsSelector = createSelector(gridFilterModelSelector, gridSortModelSelector, gridPaginationModelSelector, (filterModel, sortModel, paginationModel) => {
|
|
13
|
+
return _extends({
|
|
14
|
+
groupKeys: [],
|
|
15
|
+
// TODO: Implement with `rowGrouping`
|
|
16
|
+
groupFields: [],
|
|
17
|
+
paginationModel,
|
|
18
|
+
sortModel,
|
|
19
|
+
filterModel
|
|
20
|
+
}, computeStartEnd(paginationModel));
|
|
21
|
+
});
|
|
22
|
+
export const gridDataSourceStateSelector = state => state.dataSource;
|
|
23
|
+
export const gridDataSourceLoadingSelector = createSelector(gridDataSourceStateSelector, dataSource => dataSource.loading);
|
|
24
|
+
export const gridDataSourceErrorsSelector = createSelector(gridDataSourceStateSelector, dataSource => dataSource.errors);
|