@mui/x-data-grid 5.11.0 → 5.11.1
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 +101 -16
- package/README.md +1 -2
- package/components/base/GridOverlays.js +1 -1
- package/components/containers/GridRoot.js +25 -5
- package/components/toolbar/GridToolbarFilterButton.d.ts +1 -1
- package/components/toolbar/GridToolbarQuickFilter.js +1 -2
- package/constants/defaultGridSlotsComponents.js +3 -2
- package/constants/gridClasses.d.ts +12 -0
- package/constants/gridClasses.js +1 -1
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +4 -0
- package/hooks/core/pipeProcessing/useGridPipeProcessing.js +10 -9
- package/hooks/features/rows/gridRowsState.d.ts +14 -5
- package/hooks/features/rows/gridRowsUtils.d.ts +13 -1
- package/hooks/features/rows/gridRowsUtils.js +54 -0
- package/hooks/features/rows/useGridRows.js +63 -102
- package/index.js +1 -1
- package/legacy/components/base/GridOverlays.js +1 -1
- package/legacy/components/containers/GridRoot.js +23 -5
- package/legacy/components/toolbar/GridToolbarQuickFilter.js +1 -2
- package/legacy/constants/defaultGridSlotsComponents.js +3 -2
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/hooks/core/pipeProcessing/useGridPipeProcessing.js +10 -10
- package/legacy/hooks/features/rows/gridRowsUtils.js +55 -0
- package/legacy/hooks/features/rows/useGridRows.js +75 -111
- package/legacy/index.js +1 -1
- package/legacy/locales/ruRU.js +3 -3
- package/locales/ruRU.js +3 -3
- package/models/api/gridCoreApi.d.ts +1 -1
- package/models/gridIconSlotsComponent.d.ts +5 -0
- package/modern/components/base/GridOverlays.js +1 -1
- package/modern/components/containers/GridRoot.js +25 -3
- package/modern/components/toolbar/GridToolbarQuickFilter.js +1 -2
- package/modern/constants/defaultGridSlotsComponents.js +3 -2
- package/modern/constants/gridClasses.js +1 -1
- package/modern/hooks/core/pipeProcessing/useGridPipeProcessing.js +10 -9
- package/modern/hooks/features/rows/gridRowsUtils.js +54 -0
- package/modern/hooks/features/rows/useGridRows.js +63 -102
- package/modern/index.js +1 -1
- package/modern/locales/ruRU.js +3 -3
- package/node/components/base/GridOverlays.js +1 -1
- package/node/components/containers/GridRoot.js +24 -3
- package/node/components/toolbar/GridToolbarQuickFilter.js +1 -3
- package/node/constants/defaultGridSlotsComponents.js +2 -1
- package/node/constants/gridClasses.js +1 -1
- package/node/hooks/core/pipeProcessing/useGridPipeProcessing.js +10 -8
- package/node/hooks/features/rows/gridRowsUtils.js +67 -1
- package/node/hooks/features/rows/useGridRows.js +63 -99
- package/node/index.js +1 -1
- package/node/locales/ruRU.js +3 -3
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,21 +3,111 @@
|
|
|
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
|
+
## v5.11.1
|
|
7
|
+
|
|
8
|
+
_May 20, 2022_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 6 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🌍 Support localization on the date and time picker components (#4517) @alexfauquette
|
|
13
|
+
|
|
14
|
+
Texts can be translated in the pickers components, similar to what can be done in the data grid component. Check the [documentation](https://mui.com/x/react-date-pickers/localization/) for more information.
|
|
15
|
+
|
|
16
|
+
- 📃 Add support for column spanning when exporting to Excel (#4830) @cherniavskii
|
|
17
|
+
|
|
18
|
+
<img src="https://user-images.githubusercontent.com/13808724/167691417-bf6baeb9-d409-4134-acb6-aadaf6434de9.png" width="800">
|
|
19
|
+
|
|
20
|
+
- 🐞 Bugs fixes
|
|
21
|
+
|
|
22
|
+
### `@mui/x-data-grid@v5.11.1` / `@mui/x-data-grid-pro@v5.11.1` / `@mui/x-data-grid-premium@v5.11.1`
|
|
23
|
+
|
|
24
|
+
#### Changes
|
|
25
|
+
|
|
26
|
+
- [DataGrid] Add a CSS class corresponding to current density (#4858) @m4theushw
|
|
27
|
+
- [DataGrid] Execute the pipe-processors in their initialization order (#4913) @flaviendelangle
|
|
28
|
+
- [DataGrid] Fix rendering of the no rows overlay when the `loading` prop is changed (#4910) @m4theushw
|
|
29
|
+
- [DataGridPremium] Add `exceljs` to the dependencies (#4939) @alexfauquette
|
|
30
|
+
- [DataGridPremium] Support column spanning in the Excel export (#4830) @cherniavskii
|
|
31
|
+
- [l10n] Improve Russian (ru-RU) locale (#4864) @arvkonstantin
|
|
32
|
+
|
|
33
|
+
### `@mui/x-date-pickers@5.0.0-alpha.4` / `@mui/x-date-pickers-pro@5.0.0-alpha.4`
|
|
34
|
+
|
|
35
|
+
#### Breaking changes
|
|
36
|
+
|
|
37
|
+
- The props related to the action bar buttons have been removed (`clearable`, `showTodayButton`, `cancelText`, `okText`)
|
|
38
|
+
|
|
39
|
+
To decide which button must be displayed and in which order, you can now use the `actions` prop of the `actionBar` component slot props.
|
|
40
|
+
|
|
41
|
+
```jsx
|
|
42
|
+
<DatePicker
|
|
43
|
+
componentsProps={{
|
|
44
|
+
actionBar: {
|
|
45
|
+
// The actions will be the same between desktop and mobile
|
|
46
|
+
actions: ['clear'],
|
|
47
|
+
|
|
48
|
+
// The actions will be different between desktop and mobile
|
|
49
|
+
actions: (variant) => variant === 'desktop' ? [] : ['clear'],
|
|
50
|
+
}
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The build-in `ActionBar` component supports 4 different actions: `'clear'`, `'cancel'`, `'accept'`, and `'today'`.
|
|
56
|
+
By default, the pickers will render the cancel and accept button on mobile and no action on desktop.
|
|
57
|
+
|
|
58
|
+
If you need other actions, you can provide your own component to the `ActionBar` component slot
|
|
59
|
+
|
|
60
|
+
```jsx
|
|
61
|
+
<DatePicker
|
|
62
|
+
components={{ ActionBar: CustomActionBar }}
|
|
63
|
+
/>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### Changes
|
|
67
|
+
|
|
68
|
+
- [DatePicker] Fix keyboard accessibility for first and last year (#4807) @alexfauquette
|
|
69
|
+
- [pickers] Add component slot for action bar (#4778) @alexfauquette
|
|
70
|
+
- [pickers] Add l10n support (#4517) @alexfauquette
|
|
71
|
+
- [pickers] Close Popper when pressing <kbd>Esc</kbd> inside a modal (#4499) @alexfauquette
|
|
72
|
+
- [pickers] Support class slots on toolbar components (#4855) @flaviendelangle
|
|
73
|
+
- [TimePicker] Fix time validation when current date is `null` (#4867) @flaviendelangle
|
|
74
|
+
|
|
75
|
+
### Docs
|
|
76
|
+
|
|
77
|
+
- [docs] Add 301 redirect for columns page (#4940) @alexfauquette
|
|
78
|
+
- [docs] Avoid confusion with license key installation (#4891) @oliviertassinari
|
|
79
|
+
- [docs] Complete the instructions for pickers installation in readme (#4852) @alexfauquette
|
|
80
|
+
- [docs] Disable ads on paid-only pages (#4842) @flaviendelangle
|
|
81
|
+
- [docs] Don't redirect to localized doc on deploy preview (#4818) @m4theushw
|
|
82
|
+
- [docs] Limit `LICENSE` file to 80 char per line (#4873) @oliviertassinari
|
|
83
|
+
- [docs] Typo on OrderId @oliviertassinari
|
|
84
|
+
- [docs] Update feature comparison table (#4918) @cherniavskii
|
|
85
|
+
|
|
86
|
+
### Core
|
|
87
|
+
|
|
88
|
+
- [core] Add new script to generate tree data rows from file tree (#4902) @flaviendelangle
|
|
89
|
+
- [core] Fix code style (#4874) @oliviertassinari
|
|
90
|
+
- [core] Fix React 18 peer dependency (#4908) @oliviertassinari
|
|
91
|
+
- [core] Fix link to the LICENSE file (#4875) @oliviertassinari
|
|
92
|
+
- [core] Fix transitive babel dependency (#4793) @oliviertassinari
|
|
93
|
+
- [core] New pipe processing `rowHydration` (#4896) @flaviendelangle
|
|
94
|
+
- [core] Remove dead code for the docs (#4791) @oliviertassinari
|
|
95
|
+
- [core] Run `yarn prettier` @oliviertassinari
|
|
96
|
+
- [core] Polishes on `CHANGELOG.md` (#4876) @oliviertassinari
|
|
97
|
+
- [core] Simplify rows cache management (#4933) @flaviendelangle
|
|
98
|
+
- [core] Use internal icons for quick filter (#4912) @alexfauquette
|
|
99
|
+
|
|
6
100
|
## v5.11.0
|
|
7
101
|
|
|
8
102
|
_May 13, 2022_
|
|
9
103
|
|
|
10
104
|
We'd like to offer a big thanks to the 15 contributors who made this release possible. Here are some highlights ✨:
|
|
11
105
|
|
|
12
|
-
- 🚀 Premium plan release
|
|
13
|
-
|
|
14
|
-
We’re happy to announce that the Premium plan is [finally out](https://mui.com/blog/premium-plan-release/)!
|
|
15
|
-
With it, MUI X officially steps up to the next level, supporting the most advanced use cases for UI components.
|
|
106
|
+
- 🚀 **Premium plan release**. We're happy to announce that the Premium plan is [finally out](https://mui.com/blog/premium-plan-release/)! With it, MUI X officially steps up to the next level, supporting the most advanced use cases for UI components.
|
|
16
107
|
|
|
17
108
|
This plan is available through the new `@mui/x-data-grid-premium` package, which contains the row grouping and the Excel export features.
|
|
18
109
|
|
|
19
|
-
If you were already using the row grouping feature, you can upgrade by [installing](https://mui.com/x/react-data-grid/getting-started/#installation) `@mui/x-data-grid-premium` and replace `DataGridPro` with `DataGridPremium`, as follows.
|
|
20
|
-
Note that the experimental flag is not required anymore to use the row grouping.
|
|
110
|
+
If you were already using the row grouping feature, you can upgrade by [installing](https://mui.com/x/react-data-grid/getting-started/#installation) `@mui/x-data-grid-premium` and replace `DataGridPro` with `DataGridPremium`, as follows. Note that the experimental flag is not required anymore to use the row grouping.
|
|
21
111
|
|
|
22
112
|
```diff
|
|
23
113
|
-import { DataGridPro } from '@mui/x-data-grid-pro';
|
|
@@ -29,16 +119,11 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos
|
|
|
29
119
|
|
|
30
120
|
For more information about the revised pricing model please have a look at the [blog post](https://mui.com/blog/premium-plan-release/#the-new-licensing-model).
|
|
31
121
|
|
|
32
|
-
- 👔
|
|
33
|
-
|
|
34
|
-
- 🔎 Quick filtering
|
|
35
|
-
|
|
36
|
-
You can now add a quick filtering search bar to your grid.
|
|
37
|
-
To do so, either pass `showQuickFilter` prop to the `<GridToolbar />` or use the `<GridToolbarQuickFilter />` component in your custom toolbar.
|
|
122
|
+
- 👔 **Excel export**. You can find this new Premium feature at: https://mui.com/x/react-data-grid/export/#excel-export.
|
|
38
123
|
|
|
39
|
-
|
|
124
|
+
- 🔎 **Quick filtering**. You can now add a quick filtering search bar to your grid. To do so, either pass `showQuickFilter` prop to the `<GridToolbar />` or use the `<GridToolbarQuickFilter />` component in your custom toolbar. More information about how to customize the filtering logic is in the [documentation]( https://mui.com/x/react-data-grid/filtering/#quick-filter).
|
|
40
125
|
|
|
41
|
-
|
|
126
|
+
<img src="https://user-images.githubusercontent.com/13808724/167700105-5a5acc7c-5463-4871-8514-3d09e2f365ae.png" width="724">
|
|
42
127
|
|
|
43
128
|
- 🐞 Bugs fixes
|
|
44
129
|
|
|
@@ -46,7 +131,7 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos
|
|
|
46
131
|
|
|
47
132
|
#### Breaking changes
|
|
48
133
|
|
|
49
|
-
-
|
|
134
|
+
- Move row grouping to the premium package (#4223) @flaviendelangle
|
|
50
135
|
|
|
51
136
|
The use of `rowGrouping` in the `@mui/x-data-grid-pro` package is deprecated. The experimental flag will be removed in an upcoming release.
|
|
52
137
|
|
|
@@ -76,7 +161,7 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos
|
|
|
76
161
|
|
|
77
162
|
#### Breaking changes
|
|
78
163
|
|
|
79
|
-
- Rework the auto-closing behavior of the pickers
|
|
164
|
+
- Rework the auto-closing behavior of the pickers (#4408) @flaviendelangle
|
|
80
165
|
|
|
81
166
|
The `disableCloseOnSelect` prop has been replaced by a new `closeOnSelect` prop which has the opposite behavior.
|
|
82
167
|
The default behavior remains the same (close after the last step on desktop but not on mobile).
|
package/README.md
CHANGED
|
@@ -21,8 +21,7 @@ This component has the following peer dependencies that you will need to install
|
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@mui/material": "^5.2.8",
|
|
23
23
|
"@mui/system": "^5.2.8",
|
|
24
|
-
"react": "^17.0.2 || ^18.0.0"
|
|
25
|
-
"react-dom": "^17.0.2 || ^18.0.0"
|
|
24
|
+
"react": "^17.0.2 || ^18.0.0"
|
|
26
25
|
},
|
|
27
26
|
```
|
|
28
27
|
|
|
@@ -71,7 +71,7 @@ export function GridOverlays() {
|
|
|
71
71
|
overlay = /*#__PURE__*/_jsx(rootProps.components.NoResultsOverlay, _extends({}, (_rootProps$components2 = rootProps.componentsProps) == null ? void 0 : _rootProps$components2.noResultsOverlay));
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
if (
|
|
74
|
+
if (loading) {
|
|
75
75
|
var _rootProps$components3;
|
|
76
76
|
|
|
77
77
|
overlay = /*#__PURE__*/_jsx(rootProps.components.LoadingOverlay, _extends({}, (_rootProps$components3 = rootProps.componentsProps) == null ? void 0 : _rootProps$components3.loadingOverlay));
|
|
@@ -4,18 +4,31 @@ const _excluded = ["children", "className"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
|
-
import { useForkRef, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/material/utils';
|
|
7
|
+
import { useForkRef, unstable_useEnhancedEffect as useEnhancedEffect, capitalize } from '@mui/material/utils';
|
|
8
|
+
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
8
9
|
import { GridRootStyles } from './GridRootStyles';
|
|
9
10
|
import { gridVisibleColumnDefinitionsSelector } from '../../hooks/features/columns/gridColumnsSelector';
|
|
10
11
|
import { useGridSelector } from '../../hooks/utils/useGridSelector';
|
|
11
12
|
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
12
13
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
13
|
-
import {
|
|
14
|
+
import { getDataGridUtilityClass } from '../../constants/gridClasses';
|
|
14
15
|
import { gridRowCountSelector } from '../../hooks/features/rows/gridRowsSelector';
|
|
16
|
+
import { gridDensityValueSelector } from '../../hooks/features/density/densitySelector';
|
|
15
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
-
const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
|
|
17
|
-
var _rootProps$classes;
|
|
18
18
|
|
|
19
|
+
const useUtilityClasses = ownerState => {
|
|
20
|
+
const {
|
|
21
|
+
autoHeight,
|
|
22
|
+
density,
|
|
23
|
+
classes
|
|
24
|
+
} = ownerState;
|
|
25
|
+
const slots = {
|
|
26
|
+
root: ['root', autoHeight && 'autoHeight', `root--density${capitalize(density)}`]
|
|
27
|
+
};
|
|
28
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
|
|
19
32
|
const rootProps = useGridRootProps();
|
|
20
33
|
|
|
21
34
|
const {
|
|
@@ -27,8 +40,15 @@ const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
|
|
|
27
40
|
const apiRef = useGridApiContext();
|
|
28
41
|
const visibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
|
|
29
42
|
const totalRowCount = useGridSelector(apiRef, gridRowCountSelector);
|
|
43
|
+
const densityValue = useGridSelector(apiRef, gridDensityValueSelector);
|
|
30
44
|
const rootContainerRef = React.useRef(null);
|
|
31
45
|
const handleRef = useForkRef(rootContainerRef, ref);
|
|
46
|
+
const ownerState = {
|
|
47
|
+
density: densityValue,
|
|
48
|
+
classes: rootProps.classes,
|
|
49
|
+
autoHeight: rootProps.autoHeight
|
|
50
|
+
};
|
|
51
|
+
const classes = useUtilityClasses(ownerState);
|
|
32
52
|
apiRef.current.rootElementRef = rootContainerRef; // Our implementation of <NoSsr />
|
|
33
53
|
|
|
34
54
|
const [mountedState, setMountedState] = React.useState(false);
|
|
@@ -47,7 +67,7 @@ const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
|
|
|
47
67
|
|
|
48
68
|
return /*#__PURE__*/_jsx(GridRootStyles, _extends({
|
|
49
69
|
ref: handleRef,
|
|
50
|
-
className: clsx(className,
|
|
70
|
+
className: clsx(className, classes.root),
|
|
51
71
|
role: "grid",
|
|
52
72
|
"aria-colcount": visibleColumns.length,
|
|
53
73
|
"aria-rowcount": totalRowCount,
|
|
@@ -10,5 +10,5 @@ export interface GridToolbarFilterButtonProps extends Omit<TooltipProps, 'title'
|
|
|
10
10
|
button?: ButtonProps;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
declare const GridToolbarFilterButton: React.ForwardRefExoticComponent<Pick<GridToolbarFilterButtonProps, "hidden" | "color" | "style" | "open" | "translate" | "slot" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "
|
|
13
|
+
declare const GridToolbarFilterButton: React.ForwardRefExoticComponent<Pick<GridToolbarFilterButtonProps, "hidden" | "color" | "style" | "open" | "translate" | "slot" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "onClose" | "sx" | "classes" | "componentsProps" | "components" | "TransitionComponent" | "TransitionProps" | "onOpen" | "placement" | "arrow" | "describeChild" | "disableFocusListener" | "disableHoverListener" | "disableInteractive" | "disableTouchListener" | "enterDelay" | "enterNextDelay" | "enterTouchDelay" | "followCursor" | "leaveDelay" | "leaveTouchDelay" | "PopperComponent" | "PopperProps"> & React.RefAttributes<HTMLButtonElement>>;
|
|
14
14
|
export { GridToolbarFilterButton };
|
|
@@ -4,7 +4,6 @@ const _excluded = ["quickFilterParser", "debounceMs"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import TextField from '@mui/material/TextField';
|
|
7
|
-
import SearchIcon from '@mui/icons-material/Search';
|
|
8
7
|
import { styled } from '@mui/material/styles';
|
|
9
8
|
import { debounce } from '@mui/material/utils';
|
|
10
9
|
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
@@ -59,7 +58,7 @@ function GridToolbarQuickFilter(props) {
|
|
|
59
58
|
"aria-label": apiRef.current.getLocaleText('toolbarQuickFilterLabel'),
|
|
60
59
|
type: "search",
|
|
61
60
|
InputProps: {
|
|
62
|
-
startAdornment: /*#__PURE__*/_jsx(
|
|
61
|
+
startAdornment: /*#__PURE__*/_jsx(rootProps.components.QuickFilterIcon, {
|
|
63
62
|
fontSize: "small"
|
|
64
63
|
})
|
|
65
64
|
}
|
|
@@ -7,7 +7,7 @@ import MUISwitch from '@mui/material/Switch';
|
|
|
7
7
|
import MUIButton from '@mui/material/Button';
|
|
8
8
|
import MUITooltip from '@mui/material/Tooltip';
|
|
9
9
|
import MUIPopper from '@mui/material/Popper';
|
|
10
|
-
import { GridArrowDownwardIcon, GridArrowUpwardIcon, GridCell, GridCheckIcon, GridCloseIcon, GridColumnIcon, GridColumnMenu, GridColumnsPanel, GridFilterAltIcon, GridFilterListIcon, GridFilterPanel, GridFooter, GridHeader, GridLoadingOverlay, GridNoRowsOverlay, GridPagination, GridPanel, GridPreferencesPanel, GridRow, GridSaveAltIcon, GridSeparatorIcon, GridTableRowsIcon, GridTripleDotsVerticalIcon, GridViewHeadlineIcon, GridViewStreamIcon, GridMoreVertIcon, GridExpandMoreIcon, GridKeyboardArrowRight, GridAddIcon, GridRemoveIcon, GridDragIcon, GridColumnHeaderFilterIconButton } from '../components';
|
|
10
|
+
import { GridArrowDownwardIcon, GridArrowUpwardIcon, GridCell, GridCheckIcon, GridCloseIcon, GridColumnIcon, GridColumnMenu, GridColumnsPanel, GridFilterAltIcon, GridFilterListIcon, GridFilterPanel, GridFooter, GridHeader, GridLoadingOverlay, GridNoRowsOverlay, GridPagination, GridPanel, GridPreferencesPanel, GridRow, GridSaveAltIcon, GridSeparatorIcon, GridTableRowsIcon, GridTripleDotsVerticalIcon, GridViewHeadlineIcon, GridViewStreamIcon, GridMoreVertIcon, GridExpandMoreIcon, GridKeyboardArrowRight, GridAddIcon, GridRemoveIcon, GridDragIcon, GridColumnHeaderFilterIconButton, GridSearchIcon } from '../components';
|
|
11
11
|
import { GridColumnUnsortedIcon } from '../components/columnHeaders/GridColumnUnsortedIcon';
|
|
12
12
|
import { ErrorOverlay } from '../components/ErrorOverlay';
|
|
13
13
|
import { GridNoResultsOverlay } from '../components/GridNoResultsOverlay';
|
|
@@ -34,7 +34,8 @@ const DEFAULT_GRID_ICON_SLOTS_COMPONENTS = {
|
|
|
34
34
|
GroupingCriteriaExpandIcon: GridKeyboardArrowRight,
|
|
35
35
|
DetailPanelExpandIcon: GridAddIcon,
|
|
36
36
|
DetailPanelCollapseIcon: GridRemoveIcon,
|
|
37
|
-
RowReorderIcon: GridDragIcon
|
|
37
|
+
RowReorderIcon: GridDragIcon,
|
|
38
|
+
QuickFilterIcon: GridSearchIcon
|
|
38
39
|
};
|
|
39
40
|
/**
|
|
40
41
|
* TODO: Differentiate community and pro value and interface
|
|
@@ -319,6 +319,18 @@ export interface GridClasses {
|
|
|
319
319
|
* Styles applied to the root element.
|
|
320
320
|
*/
|
|
321
321
|
root: string;
|
|
322
|
+
/**
|
|
323
|
+
* Styles applied to the root element if density is "standard" (default).
|
|
324
|
+
*/
|
|
325
|
+
'root--densityStandard': string;
|
|
326
|
+
/**
|
|
327
|
+
* Styles applied to the root element if density is "comfortable".
|
|
328
|
+
*/
|
|
329
|
+
'root--densityComfortable': string;
|
|
330
|
+
/**
|
|
331
|
+
* Styles applied to the root element if density is "compact".
|
|
332
|
+
*/
|
|
333
|
+
'root--densityCompact': string;
|
|
322
334
|
/**
|
|
323
335
|
* Styles applied to the row element if the row is editable.
|
|
324
336
|
*/
|
package/constants/gridClasses.js
CHANGED
|
@@ -2,4 +2,4 @@ import { generateUtilityClasses, generateUtilityClass } from '@mui/material';
|
|
|
2
2
|
export function getDataGridUtilityClass(slot) {
|
|
3
3
|
return generateUtilityClass('MuiDataGrid', slot);
|
|
4
4
|
}
|
|
5
|
-
export const gridClasses = generateUtilityClasses('MuiDataGrid', ['actionsCell', 'autoHeight', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--withRenderer', 'cell', 'cellContent', 'cellCheckbox', 'checkboxInput', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderDropZone', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeaders', 'columnHeadersInner', 'columnHeadersInner--scrollable', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsPanel', 'columnsPanelRow', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filterForm', 'filterFormDeleteIcon', 'filterFormLinkOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'iconButtonContainer', 'iconSeparator', 'main', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'root', 'row', 'row--editable', 'row--editing', 'row--lastVisible', 'row--dragging', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'pinnedColumns--left', 'pinnedColumns--right', 'pinnedColumnHeaders', 'pinnedColumnHeaders--left', 'pinnedColumnHeaders--right', 'withBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'groupingCriteriaCell', 'groupingCriteriaCellToggle']);
|
|
5
|
+
export const gridClasses = generateUtilityClasses('MuiDataGrid', ['actionsCell', 'autoHeight', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--withRenderer', 'cell', 'cellContent', 'cellCheckbox', 'checkboxInput', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderDropZone', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeaders', 'columnHeadersInner', 'columnHeadersInner--scrollable', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsPanel', 'columnsPanelRow', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filterForm', 'filterFormDeleteIcon', 'filterFormLinkOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'iconButtonContainer', 'iconSeparator', 'main', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'row', 'row--editable', 'row--editing', 'row--lastVisible', 'row--dragging', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'pinnedColumns--left', 'pinnedColumns--right', 'pinnedColumnHeaders', 'pinnedColumnHeaders--left', 'pinnedColumnHeaders--right', 'withBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'groupingCriteriaCell', 'groupingCriteriaCellToggle']);
|
|
@@ -4,6 +4,7 @@ import { GridInitialStateCommunity } from '../../../models/gridStateCommunity';
|
|
|
4
4
|
import { GridRestoreStatePreProcessingContext, GridRestoreStatePreProcessingValue } from '../../features/statePersistence/gridStatePersistenceInterface';
|
|
5
5
|
import { GridHydrateColumnsValue } from '../../features/columns/gridColumnsInterfaces';
|
|
6
6
|
import { GridRowEntry } from '../../../models/gridRows';
|
|
7
|
+
import { GridHydrateRowsValue } from '../../features/rows/gridRowsState';
|
|
7
8
|
import { GridPreferencePanelsValue } from '../../features/preferencesPanel';
|
|
8
9
|
export declare type GridPipeProcessorGroup = keyof GridPipeProcessingLookup;
|
|
9
10
|
export interface GridPipeProcessingLookup {
|
|
@@ -17,6 +18,9 @@ export interface GridPipeProcessingLookup {
|
|
|
17
18
|
hydrateColumns: {
|
|
18
19
|
value: GridHydrateColumnsValue;
|
|
19
20
|
};
|
|
21
|
+
hydrateRows: {
|
|
22
|
+
value: GridHydrateRowsValue;
|
|
23
|
+
};
|
|
20
24
|
exportMenu: {
|
|
21
25
|
value: {
|
|
22
26
|
component: React.ReactElement;
|
|
@@ -46,30 +46,27 @@ export const useGridPipeProcessing = apiRef => {
|
|
|
46
46
|
const registerPipeProcessor = React.useCallback((group, id, processor) => {
|
|
47
47
|
if (!processorsCache.current[group]) {
|
|
48
48
|
processorsCache.current[group] = {
|
|
49
|
-
processors:
|
|
49
|
+
processors: new Map(),
|
|
50
50
|
appliers: {}
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
const groupCache = processorsCache.current[group];
|
|
55
|
-
const oldProcessor = groupCache.processors
|
|
55
|
+
const oldProcessor = groupCache.processors.get(id);
|
|
56
56
|
|
|
57
57
|
if (oldProcessor !== processor) {
|
|
58
|
-
groupCache.processors
|
|
58
|
+
groupCache.processors.set(id, processor);
|
|
59
59
|
runAppliers(groupCache);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
return () => {
|
|
63
|
-
|
|
64
|
-
otherProcessors = _objectWithoutPropertiesLoose(_processors, [id].map(_toPropertyKey));
|
|
65
|
-
|
|
66
|
-
processorsCache.current[group].processors = otherProcessors;
|
|
63
|
+
processorsCache.current[group].processors.set(id, null);
|
|
67
64
|
};
|
|
68
65
|
}, [runAppliers]);
|
|
69
66
|
const registerPipeApplier = React.useCallback((group, id, applier) => {
|
|
70
67
|
if (!processorsCache.current[group]) {
|
|
71
68
|
processorsCache.current[group] = {
|
|
72
|
-
processors:
|
|
69
|
+
processors: new Map(),
|
|
73
70
|
appliers: {}
|
|
74
71
|
};
|
|
75
72
|
}
|
|
@@ -93,8 +90,12 @@ export const useGridPipeProcessing = apiRef => {
|
|
|
93
90
|
return value;
|
|
94
91
|
}
|
|
95
92
|
|
|
96
|
-
const preProcessors =
|
|
93
|
+
const preProcessors = Array.from(processorsCache.current[group].processors.values());
|
|
97
94
|
return preProcessors.reduce((acc, preProcessor) => {
|
|
95
|
+
if (!preProcessor) {
|
|
96
|
+
return acc;
|
|
97
|
+
}
|
|
98
|
+
|
|
98
99
|
return preProcessor(acc, context);
|
|
99
100
|
}, value);
|
|
100
101
|
}, []);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { GridRowId, GridRowsLookup,
|
|
1
|
+
import { GridRowId, GridRowsLookup, GridRowTreeConfig } from '../../../models/gridRows';
|
|
2
|
+
import type { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
2
3
|
export interface GridRowTreeCreationParams {
|
|
3
4
|
ids: GridRowId[];
|
|
4
5
|
idRowsLookup: GridRowsLookup;
|
|
@@ -17,14 +18,16 @@ export interface GridRowTreeCreationValue {
|
|
|
17
18
|
idRowsLookup: GridRowsLookup;
|
|
18
19
|
idToIdLookup: Record<string, GridRowId>;
|
|
19
20
|
}
|
|
20
|
-
export
|
|
21
|
-
export interface GridRowsInternalCache {
|
|
22
|
-
value: GridRowInternalCacheValue;
|
|
21
|
+
export interface GridRowsInternalCache extends Omit<GridRowTreeCreationParams, 'previousTree'> {
|
|
23
22
|
/**
|
|
24
23
|
* The rows as they were the last time all the rows have been updated at once
|
|
25
24
|
* It is used to avoid processing several time the same set of rows
|
|
26
25
|
*/
|
|
27
|
-
rowsBeforePartialUpdates:
|
|
26
|
+
rowsBeforePartialUpdates: DataGridProcessedProps['rows'];
|
|
27
|
+
/**
|
|
28
|
+
* The value of the `loading` prop since the last time that the rows state was updated.
|
|
29
|
+
*/
|
|
30
|
+
loadingPropBeforePartialUpdates: DataGridProcessedProps['loading'];
|
|
28
31
|
}
|
|
29
32
|
export interface GridRowsState extends GridRowTreeCreationValue {
|
|
30
33
|
/**
|
|
@@ -41,4 +44,10 @@ export interface GridRowsState extends GridRowTreeCreationValue {
|
|
|
41
44
|
* It does not count the expanded children rows.
|
|
42
45
|
*/
|
|
43
46
|
totalTopLevelRowCount: number;
|
|
47
|
+
/**
|
|
48
|
+
* Tree returned by the `rowTreeCreation` strategy processor.
|
|
49
|
+
* It is used to re-apply the `hydrateRows` pipe processor without having to recreate the tree.
|
|
50
|
+
*/
|
|
51
|
+
groupingResponseBeforeRowHydration: GridRowTreeCreationValue;
|
|
44
52
|
}
|
|
53
|
+
export declare type GridHydrateRowsValue = GridRowTreeCreationValue;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GridRowId, GridRowIdGetter, GridRowModel, GridRowTreeConfig } from '../../../models';
|
|
3
|
+
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
|
+
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
5
|
+
import { GridRowsInternalCache, GridRowsState } from './gridRowsState';
|
|
2
6
|
/**
|
|
3
7
|
* A helper function to check if the id provided is valid.
|
|
4
8
|
* @param {GridRowId} id Id as [[GridRowId]].
|
|
@@ -6,4 +10,12 @@ import { GridRowId, GridRowModel, GridRowTreeConfig } from '../../../models';
|
|
|
6
10
|
* @param {string} detailErrorMessage A custom error message to display for invalid IDs
|
|
7
11
|
*/
|
|
8
12
|
export declare function checkGridRowIdIsValid(id: GridRowId, row: GridRowModel | Partial<GridRowModel>, detailErrorMessage?: string): void;
|
|
13
|
+
export declare const getRowIdFromRowModel: (rowModel: GridRowModel, getRowId?: GridRowIdGetter<any> | undefined, detailErrorMessage?: string | undefined) => GridRowId;
|
|
14
|
+
export declare const createRowsInternalCache: ({ rows, getRowId, loading, }: Pick<DataGridProcessedProps, 'rows' | 'getRowId' | 'loading'>) => GridRowsInternalCache;
|
|
15
|
+
export declare const getRowsStateFromCache: ({ apiRef, previousTree, rowCountProp, loadingProp, }: {
|
|
16
|
+
apiRef: React.MutableRefObject<GridApiCommunity>;
|
|
17
|
+
previousTree: GridRowTreeConfig | null;
|
|
18
|
+
rowCountProp: number | undefined;
|
|
19
|
+
loadingProp: boolean | undefined;
|
|
20
|
+
}) => GridRowsState;
|
|
9
21
|
export declare const getTreeNodeDescendants: (tree: GridRowTreeConfig, parentId: GridRowId, skipAutoGeneratedRows: boolean) => GridRowId[];
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["rowsBeforePartialUpdates"];
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* A helper function to check if the id provided is valid.
|
|
3
7
|
* @param {GridRowId} id Id as [[GridRowId]].
|
|
@@ -9,6 +13,56 @@ export function checkGridRowIdIsValid(id, row, detailErrorMessage = 'A row was p
|
|
|
9
13
|
throw new Error(['MUI: The data grid component requires all rows to have a unique `id` property.', 'Alternatively, you can use the `getRowId` prop to specify a custom id for each row.', detailErrorMessage, JSON.stringify(row)].join('\n'));
|
|
10
14
|
}
|
|
11
15
|
}
|
|
16
|
+
export const getRowIdFromRowModel = (rowModel, getRowId, detailErrorMessage) => {
|
|
17
|
+
const id = getRowId ? getRowId(rowModel) : rowModel.id;
|
|
18
|
+
checkGridRowIdIsValid(id, rowModel, detailErrorMessage);
|
|
19
|
+
return id;
|
|
20
|
+
};
|
|
21
|
+
export const createRowsInternalCache = ({
|
|
22
|
+
rows,
|
|
23
|
+
getRowId,
|
|
24
|
+
loading
|
|
25
|
+
}) => {
|
|
26
|
+
const cache = {
|
|
27
|
+
rowsBeforePartialUpdates: rows,
|
|
28
|
+
loadingPropBeforePartialUpdates: loading,
|
|
29
|
+
idRowsLookup: {},
|
|
30
|
+
idToIdLookup: {},
|
|
31
|
+
ids: []
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
for (let i = 0; i < rows.length; i += 1) {
|
|
35
|
+
const row = rows[i];
|
|
36
|
+
const id = getRowIdFromRowModel(row, getRowId);
|
|
37
|
+
cache.idRowsLookup[id] = row;
|
|
38
|
+
cache.idToIdLookup[id] = id;
|
|
39
|
+
cache.ids.push(id);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return cache;
|
|
43
|
+
};
|
|
44
|
+
export const getRowsStateFromCache = ({
|
|
45
|
+
apiRef,
|
|
46
|
+
previousTree,
|
|
47
|
+
rowCountProp,
|
|
48
|
+
loadingProp
|
|
49
|
+
}) => {
|
|
50
|
+
const _apiRef$current$unsta = apiRef.current.unstable_caches.rows,
|
|
51
|
+
cacheForGrouping = _objectWithoutPropertiesLoose(_apiRef$current$unsta, _excluded);
|
|
52
|
+
|
|
53
|
+
const rowCount = rowCountProp != null ? rowCountProp : 0;
|
|
54
|
+
const groupingResponse = apiRef.current.unstable_applyStrategyProcessor('rowTreeCreation', _extends({}, cacheForGrouping, {
|
|
55
|
+
previousTree
|
|
56
|
+
}));
|
|
57
|
+
const processedGroupingResponse = apiRef.current.unstable_applyPipeProcessors('hydrateRows', groupingResponse);
|
|
58
|
+
const dataTopLevelRowCount = processedGroupingResponse.treeDepth === 1 ? processedGroupingResponse.ids.length : Object.values(processedGroupingResponse.tree).filter(node => node.parent == null).length;
|
|
59
|
+
return _extends({}, processedGroupingResponse, {
|
|
60
|
+
groupingResponseBeforeRowHydration: groupingResponse,
|
|
61
|
+
loading: loadingProp,
|
|
62
|
+
totalRowCount: Math.max(rowCount, processedGroupingResponse.ids.length),
|
|
63
|
+
totalTopLevelRowCount: Math.max(rowCount, dataTopLevelRowCount)
|
|
64
|
+
});
|
|
65
|
+
};
|
|
12
66
|
export const getTreeNodeDescendants = (tree, parentId, skipAutoGeneratedRows) => {
|
|
13
67
|
var _tree$parentId;
|
|
14
68
|
|