@mui/x-data-grid 7.8.0 → 7.10.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 +140 -0
- package/DataGrid/DataGrid.js +1 -0
- package/DataGrid/useDataGridProps.js +30 -22
- package/components/GridLoadingOverlay.d.ts +15 -3
- package/components/GridLoadingOverlay.js +48 -4
- package/components/GridRow.js +2 -1
- package/components/GridSkeletonLoadingOverlay.d.ts +3 -0
- package/components/GridSkeletonLoadingOverlay.js +181 -0
- package/components/base/GridOverlays.d.ts +11 -1
- package/components/base/GridOverlays.js +26 -40
- package/components/cell/GridSkeletonCell.d.ts +13 -6
- package/components/cell/GridSkeletonCell.js +61 -19
- package/components/containers/GridRoot.js +4 -16
- package/components/containers/GridRootStyles.js +11 -2
- package/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
- package/components/virtualization/GridMainContainer.js +11 -3
- package/components/virtualization/GridVirtualScroller.js +10 -6
- package/components/virtualization/GridVirtualScrollerFiller.d.ts +5 -1
- package/components/virtualization/GridVirtualScrollerFiller.js +9 -6
- package/constants/gridClasses.d.ts +9 -0
- package/constants/gridClasses.js +1 -1
- package/hooks/features/filter/gridFilterSelector.d.ts +11 -0
- package/hooks/features/filter/gridFilterSelector.js +13 -0
- package/hooks/features/overlays/useGridOverlays.d.ts +11 -0
- package/hooks/features/overlays/useGridOverlays.js +35 -0
- package/hooks/features/virtualization/useGridVirtualScroller.js +4 -12
- package/hooks/utils/index.d.ts +0 -1
- package/hooks/utils/index.js +0 -1
- package/index.js +1 -1
- package/locales/esES.js +1 -2
- package/models/api/gridRowSelectionApi.d.ts +2 -2
- package/models/colDef/gridColDef.d.ts +4 -4
- package/models/gridRowSelectionModel.d.ts +2 -2
- package/models/gridSlotsComponentsProps.d.ts +2 -1
- package/models/props/DataGridProps.d.ts +5 -4
- package/modern/DataGrid/DataGrid.js +1 -0
- package/modern/DataGrid/useDataGridProps.js +30 -22
- package/modern/components/GridLoadingOverlay.js +48 -4
- package/modern/components/GridRow.js +2 -1
- package/modern/components/GridSkeletonLoadingOverlay.js +181 -0
- package/modern/components/base/GridOverlays.js +26 -40
- package/modern/components/cell/GridSkeletonCell.js +61 -19
- package/modern/components/containers/GridRoot.js +4 -16
- package/modern/components/containers/GridRootStyles.js +11 -2
- package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
- package/modern/components/virtualization/GridMainContainer.js +11 -3
- package/modern/components/virtualization/GridVirtualScroller.js +10 -6
- package/modern/components/virtualization/GridVirtualScrollerFiller.js +9 -6
- package/modern/constants/gridClasses.js +1 -1
- package/modern/hooks/features/filter/gridFilterSelector.js +13 -0
- package/modern/hooks/features/overlays/useGridOverlays.js +35 -0
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +4 -12
- package/modern/hooks/utils/index.js +0 -1
- package/modern/index.js +1 -1
- package/modern/locales/esES.js +1 -2
- package/modern/utils/utils.js +10 -2
- package/node/DataGrid/DataGrid.js +1 -0
- package/node/DataGrid/useDataGridProps.js +30 -22
- package/node/components/GridLoadingOverlay.js +48 -4
- package/node/components/GridRow.js +2 -1
- package/node/components/GridSkeletonLoadingOverlay.js +189 -0
- package/node/components/base/GridOverlays.js +26 -40
- package/node/components/cell/GridSkeletonCell.js +60 -18
- package/node/components/containers/GridRoot.js +3 -15
- package/node/components/containers/GridRootStyles.js +11 -2
- package/node/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
- package/node/components/virtualization/GridMainContainer.js +10 -2
- package/node/components/virtualization/GridVirtualScroller.js +9 -5
- package/node/components/virtualization/GridVirtualScrollerFiller.js +9 -6
- package/node/constants/gridClasses.js +1 -1
- package/node/hooks/features/filter/gridFilterSelector.js +14 -1
- package/node/hooks/features/overlays/useGridOverlays.js +42 -0
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +4 -12
- package/node/hooks/utils/index.js +0 -12
- package/node/index.js +1 -1
- package/node/locales/esES.js +1 -2
- package/node/utils/utils.js +11 -3
- package/package.json +5 -4
- package/utils/utils.d.ts +8 -1
- package/utils/utils.js +10 -2
- package/hooks/utils/useResizeObserver.d.ts +0 -2
- package/hooks/utils/useResizeObserver.js +0 -36
- package/modern/hooks/utils/useResizeObserver.js +0 -36
- package/node/hooks/utils/useResizeObserver.js +0 -44
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,146 @@
|
|
|
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.10.0
|
|
7
|
+
|
|
8
|
+
_Jul 11, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 12 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🎁 Add selectors to support showing child row count in footer in the Data Grid
|
|
13
|
+
- ✨ New APIs for retrieving current item tree and item's children IDs in the Tree View
|
|
14
|
+
- 🌍 Improve Spanish (es-ES) locale on the Data Grid
|
|
15
|
+
- 🐞 Bugfixes
|
|
16
|
+
- 📚 Documentation improvements
|
|
17
|
+
|
|
18
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
19
|
+
|
|
20
|
+
### Data Grid
|
|
21
|
+
|
|
22
|
+
#### `@mui/x-data-grid@7.10.0`
|
|
23
|
+
|
|
24
|
+
- [DataGrid] Add selectors to support showing child row count in footer (#13725) @KenanYusuf
|
|
25
|
+
- [DataGrid] Fix incorrect panels position when using a toolbar (#13474) @oukunan
|
|
26
|
+
- [DataGrid] Set default variant to `'standard'` in `GridFilterInputMultipleValue` (#13129) @tarunrajput
|
|
27
|
+
- [DataGrid] Use `readonly` on more array props (#13331) @pcorpet
|
|
28
|
+
- [l10n] Improve Spanish (es-ES) locale (#13772) @joserealdev
|
|
29
|
+
|
|
30
|
+
#### `@mui/x-data-grid-pro@7.10.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
31
|
+
|
|
32
|
+
Same changes as in `@mui/x-data-grid@7.10.0`, plus:
|
|
33
|
+
|
|
34
|
+
- [DataGridPro] Keep bottom pinned row at the bottom (#13313) @romgrk
|
|
35
|
+
|
|
36
|
+
#### `@mui/x-data-grid-premium@7.10.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
37
|
+
|
|
38
|
+
Same changes as in `@mui/x-data-grid-pro@7.10.0`.
|
|
39
|
+
|
|
40
|
+
### Date and Time Pickers
|
|
41
|
+
|
|
42
|
+
#### `@mui/x-date-pickers@7.10.0`
|
|
43
|
+
|
|
44
|
+
- [fields] Prevent infinite recursion when ensuring selection (#13779) @LukasTy
|
|
45
|
+
- [fields] Unify fields behavior regardless of the `readOnly` flag (#13688) @LukasTy
|
|
46
|
+
|
|
47
|
+
#### `@mui/x-date-pickers-pro@7.10.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
48
|
+
|
|
49
|
+
Same changes as in `@mui/x-date-pickers@7.10.0`, plus:
|
|
50
|
+
|
|
51
|
+
- [DateRangePicker] Fix `calendarHeader` slot props propagation (#13780) @LukasTy
|
|
52
|
+
- [DateTimeRangePicker] Resolve `format` from given `views` (#13743) @LukasTy
|
|
53
|
+
|
|
54
|
+
### Charts
|
|
55
|
+
|
|
56
|
+
#### `@mui/x-charts@7.10.0`
|
|
57
|
+
|
|
58
|
+
- [charts] Fix displaying area of a `LineChart` when using the `log` scale (#13791) @alexfauquette
|
|
59
|
+
- [charts] Use correct click handler prop on pie chart `OnSeriesItemClick` documentation (#13761) @tonyhallett
|
|
60
|
+
|
|
61
|
+
### Tree View
|
|
62
|
+
|
|
63
|
+
#### `@mui/x-tree-view@7.10.0`
|
|
64
|
+
|
|
65
|
+
- [TreeView] Add `getItemTree` and `getItemOrderedChildrenIds` methods to the public API (#13804) @flaviendelangle
|
|
66
|
+
- [TreeView] Add utility function to check if an optional plugin is present (#13788) @flaviendelangle
|
|
67
|
+
|
|
68
|
+
### Docs
|
|
69
|
+
|
|
70
|
+
- [docs] Add missing default `loading` prop value (#13604) @oliviertassinari
|
|
71
|
+
- [docs] Add the `DateTimeRangePicker` to the "Commonly used components" demo (#13775) @flaviendelangle
|
|
72
|
+
- [docs] Fix Pickers customization playground overflow (#13742) @LukasTy
|
|
73
|
+
- [docs] Move Pickers dialog guidelines to accessibility page (#13778) @arthurbalduini
|
|
74
|
+
|
|
75
|
+
### Core
|
|
76
|
+
|
|
77
|
+
- [core] Sort `DATA_GRID_PROPS_DEFAULT_VALUES` alphabetically (#13783) @oliviertassinari
|
|
78
|
+
- [test] Fix split infinitive use in tests @oliviertassinari
|
|
79
|
+
|
|
80
|
+
## 7.9.0
|
|
81
|
+
|
|
82
|
+
_Jul 5, 2024_
|
|
83
|
+
|
|
84
|
+
We'd like to offer a big thanks to the 7 contributors who made this release possible. Here are some highlights ✨:
|
|
85
|
+
|
|
86
|
+
- 🔄 Add loading overlay variants, including a skeleton loader option to the Data Grid component. See [Loading overlay docs](https://mui.com/x/react-data-grid/overlays/#loading-overlay) for more details.
|
|
87
|
+
- 🌳 Add `selectItem` and `getItemDOMElement` methods to the TreeView component public API
|
|
88
|
+
- ⛏️ Make the `usePickersTranslations` hook public in the pickers component
|
|
89
|
+
- 🐞 Bugfixes
|
|
90
|
+
|
|
91
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
92
|
+
|
|
93
|
+
### Data Grid
|
|
94
|
+
|
|
95
|
+
#### `@mui/x-data-grid@7.9.0`
|
|
96
|
+
|
|
97
|
+
- [DataGrid] Add skeleton loading overlay support (#13293) @KenanYusuf
|
|
98
|
+
- [DataGrid] Fix pagination when `pagination={undefined}` (#13349) @sai6855
|
|
99
|
+
|
|
100
|
+
#### `@mui/x-data-grid-pro@7.9.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
101
|
+
|
|
102
|
+
Same changes as in `@mui/x-data-grid@7.9.0`.
|
|
103
|
+
|
|
104
|
+
#### `@mui/x-data-grid-premium@7.9.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
105
|
+
|
|
106
|
+
Same changes as in `@mui/x-data-grid-pro@7.9.0`.
|
|
107
|
+
|
|
108
|
+
### Date and Time Pickers
|
|
109
|
+
|
|
110
|
+
#### `@mui/x-date-pickers@7.9.0`
|
|
111
|
+
|
|
112
|
+
- [pickers] Make the `usePickersTranslations` hook public (#13657) @flaviendelangle
|
|
113
|
+
|
|
114
|
+
#### `@mui/x-date-pickers-pro@7.9.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
115
|
+
|
|
116
|
+
Same changes as in `@mui/x-date-pickers@7.9.0`.
|
|
117
|
+
|
|
118
|
+
### Charts
|
|
119
|
+
|
|
120
|
+
#### `@mui/x-charts@7.9.0`
|
|
121
|
+
|
|
122
|
+
- [charts] Add Heatmap (unreleased) (#13209) @alexfauquette
|
|
123
|
+
- [charts] Add initial `Zoom&Pan` to the Pro charts (unreleased) (#13405) @JCQuintas
|
|
124
|
+
- [charts] Fix Axis Highlight on horizontal bar charts regression (#13717) @JCQuintas
|
|
125
|
+
- [charts] Improve charts interaction for mobile users (#13692) @JCQuintas
|
|
126
|
+
- [charts] Add documentation on how to disable the tooltip on charts (#13724) @JCQuintas
|
|
127
|
+
|
|
128
|
+
### Tree View
|
|
129
|
+
|
|
130
|
+
#### `@mui/x-tree-view@7.9.0`
|
|
131
|
+
|
|
132
|
+
- [TreeView] Add `selectItem` and `getItemDOMElement` methods to the public API (#13485) @flaviendelangle
|
|
133
|
+
|
|
134
|
+
### Docs
|
|
135
|
+
|
|
136
|
+
- [docs] Fix custom "no results overlay" demo in dark mode (#13715) @KenanYusuf
|
|
137
|
+
|
|
138
|
+
### Core
|
|
139
|
+
|
|
140
|
+
- [core] Add `react_next` workflow in CircleCI (#13360) @cherniavskii
|
|
141
|
+
- [core] Create a new package to share utils across X packages (#13528) @flaviendelangle
|
|
142
|
+
- [core] Fix dependency setup (#13684) @LukasTy
|
|
143
|
+
- [core] Remove `jscodeshift-add-imports` package (#13720) @LukasTy
|
|
144
|
+
- [code-infra] Cleanup monorepo and `@mui/docs` usage (#13713) @LukasTy
|
|
145
|
+
|
|
6
146
|
## 7.8.0
|
|
7
147
|
|
|
8
148
|
_Jun 28, 2024_
|
package/DataGrid/DataGrid.js
CHANGED
|
@@ -23,54 +23,55 @@ const DATA_GRID_FORCED_PROPS = {
|
|
|
23
23
|
export const DATA_GRID_PROPS_DEFAULT_VALUES = {
|
|
24
24
|
autoHeight: false,
|
|
25
25
|
autoPageSize: false,
|
|
26
|
+
autosizeOnMount: false,
|
|
26
27
|
checkboxSelection: false,
|
|
27
28
|
checkboxSelectionVisibleOnly: false,
|
|
29
|
+
clipboardCopyCellDelimiter: '\t',
|
|
28
30
|
columnBufferPx: 150,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
rowSelection: true,
|
|
31
|
+
columnHeaderHeight: 56,
|
|
32
|
+
disableAutosize: false,
|
|
32
33
|
disableColumnFilter: false,
|
|
33
34
|
disableColumnMenu: false,
|
|
35
|
+
disableColumnReorder: false,
|
|
36
|
+
disableColumnResize: false,
|
|
34
37
|
disableColumnSelector: false,
|
|
38
|
+
disableColumnSorting: false,
|
|
35
39
|
disableDensitySelector: false,
|
|
36
40
|
disableEval: false,
|
|
37
41
|
disableMultipleColumnsFiltering: false,
|
|
38
|
-
disableMultipleRowSelection: false,
|
|
39
|
-
disableColumnSorting: false,
|
|
40
42
|
disableMultipleColumnsSorting: false,
|
|
43
|
+
disableMultipleRowSelection: false,
|
|
41
44
|
disableRowSelectionOnClick: false,
|
|
42
45
|
disableVirtualization: false,
|
|
43
46
|
editMode: GridEditModes.Cell,
|
|
44
|
-
filterMode: 'client',
|
|
45
47
|
filterDebounceMs: 150,
|
|
46
|
-
|
|
48
|
+
filterMode: 'client',
|
|
47
49
|
hideFooter: false,
|
|
48
50
|
hideFooterPagination: false,
|
|
49
51
|
hideFooterRowCount: false,
|
|
50
52
|
hideFooterSelectedRowCount: false,
|
|
51
53
|
ignoreDiacritics: false,
|
|
54
|
+
ignoreValueFormatterDuringExport: false,
|
|
55
|
+
keepColumnPositionIfDraggedOutside: false,
|
|
56
|
+
keepNonExistentRowsSelected: false,
|
|
57
|
+
loading: false,
|
|
52
58
|
logger: console,
|
|
53
59
|
logLevel: process.env.NODE_ENV === 'production' ? 'error' : 'warn',
|
|
60
|
+
pageSizeOptions: [25, 50, 100],
|
|
54
61
|
pagination: false,
|
|
55
62
|
paginationMode: 'client',
|
|
56
|
-
rowHeight: 52,
|
|
57
63
|
resizeThrottleMs: 60,
|
|
58
|
-
|
|
64
|
+
rowBufferPx: 150,
|
|
65
|
+
rowHeight: 52,
|
|
66
|
+
rowPositionsDebounceMs: 166,
|
|
67
|
+
rows: [],
|
|
68
|
+
rowSelection: true,
|
|
59
69
|
rowSpacingType: 'margin',
|
|
60
70
|
showCellVerticalBorder: false,
|
|
61
71
|
showColumnVerticalBorder: false,
|
|
62
|
-
sortingOrder: ['asc', 'desc', null],
|
|
63
72
|
sortingMode: 'client',
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
disableColumnResize: false,
|
|
67
|
-
keepNonExistentRowsSelected: false,
|
|
68
|
-
keepColumnPositionIfDraggedOutside: false,
|
|
69
|
-
ignoreValueFormatterDuringExport: false,
|
|
70
|
-
clipboardCopyCellDelimiter: '\t',
|
|
71
|
-
rowPositionsDebounceMs: 166,
|
|
72
|
-
autosizeOnMount: false,
|
|
73
|
-
disableAutosize: false
|
|
73
|
+
sortingOrder: ['asc', 'desc', null],
|
|
74
|
+
throttleRowsMs: 0
|
|
74
75
|
};
|
|
75
76
|
const defaultSlots = DATA_GRID_DEFAULT_SLOTS_COMPONENTS;
|
|
76
77
|
export const useDataGridProps = inProps => {
|
|
@@ -85,8 +86,15 @@ export const useDataGridProps = inProps => {
|
|
|
85
86
|
defaultSlots,
|
|
86
87
|
slots: themedProps.slots
|
|
87
88
|
}), [themedProps.slots]);
|
|
88
|
-
|
|
89
|
+
const injectDefaultProps = React.useMemo(() => {
|
|
90
|
+
return Object.keys(DATA_GRID_PROPS_DEFAULT_VALUES).reduce((acc, key) => {
|
|
91
|
+
// @ts-ignore
|
|
92
|
+
acc[key] = themedProps[key] ?? DATA_GRID_PROPS_DEFAULT_VALUES[key];
|
|
93
|
+
return acc;
|
|
94
|
+
}, {});
|
|
95
|
+
}, [themedProps]);
|
|
96
|
+
return React.useMemo(() => _extends({}, themedProps, injectDefaultProps, {
|
|
89
97
|
localeText,
|
|
90
98
|
slots
|
|
91
|
-
}, DATA_GRID_FORCED_PROPS), [themedProps, localeText, slots]);
|
|
99
|
+
}, DATA_GRID_FORCED_PROPS), [themedProps, localeText, slots, injectDefaultProps]);
|
|
92
100
|
};
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { GridOverlayProps } from './containers/GridOverlay';
|
|
3
|
+
export type GridLoadingOverlayVariant = 'circular-progress' | 'linear-progress' | 'skeleton';
|
|
4
|
+
export interface GridLoadingOverlayProps extends GridOverlayProps {
|
|
5
|
+
/**
|
|
6
|
+
* The variant of the overlay.
|
|
7
|
+
* @default 'circular-progress'
|
|
8
|
+
*/
|
|
9
|
+
variant?: GridLoadingOverlayVariant;
|
|
10
|
+
/**
|
|
11
|
+
* The variant of the overlay when no rows are displayed.
|
|
12
|
+
* @default 'circular-progress'
|
|
13
|
+
*/
|
|
14
|
+
noRowsVariant?: GridLoadingOverlayVariant;
|
|
15
|
+
}
|
|
16
|
+
declare const GridLoadingOverlay: React.ForwardRefExoticComponent<GridLoadingOverlayProps & React.RefAttributes<HTMLDivElement>>;
|
|
5
17
|
export { GridLoadingOverlay };
|
|
@@ -1,14 +1,48 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["variant", "noRowsVariant", "style"];
|
|
2
4
|
import * as React from 'react';
|
|
3
5
|
import PropTypes from 'prop-types';
|
|
6
|
+
import LinearProgress from '@mui/material/LinearProgress';
|
|
4
7
|
import CircularProgress from '@mui/material/CircularProgress';
|
|
5
8
|
import { GridOverlay } from './containers/GridOverlay';
|
|
9
|
+
import { GridSkeletonLoadingOverlay } from './GridSkeletonLoadingOverlay';
|
|
10
|
+
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
11
|
+
import { gridRowCountSelector, useGridSelector } from '../hooks';
|
|
6
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
const LOADING_VARIANTS = {
|
|
14
|
+
'circular-progress': {
|
|
15
|
+
component: CircularProgress,
|
|
16
|
+
style: {}
|
|
17
|
+
},
|
|
18
|
+
'linear-progress': {
|
|
19
|
+
component: LinearProgress,
|
|
20
|
+
style: {
|
|
21
|
+
display: 'block'
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
skeleton: {
|
|
25
|
+
component: GridSkeletonLoadingOverlay,
|
|
26
|
+
style: {
|
|
27
|
+
display: 'block'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
7
31
|
const GridLoadingOverlay = /*#__PURE__*/React.forwardRef(function GridLoadingOverlay(props, ref) {
|
|
32
|
+
const {
|
|
33
|
+
variant = 'circular-progress',
|
|
34
|
+
noRowsVariant = 'circular-progress',
|
|
35
|
+
style
|
|
36
|
+
} = props,
|
|
37
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
38
|
+
const apiRef = useGridApiContext();
|
|
39
|
+
const rowsCount = useGridSelector(apiRef, gridRowCountSelector);
|
|
40
|
+
const activeVariant = LOADING_VARIANTS[rowsCount === 0 ? noRowsVariant : variant];
|
|
8
41
|
return /*#__PURE__*/_jsx(GridOverlay, _extends({
|
|
9
|
-
ref: ref
|
|
10
|
-
|
|
11
|
-
|
|
42
|
+
ref: ref,
|
|
43
|
+
style: _extends({}, activeVariant.style, style)
|
|
44
|
+
}, other, {
|
|
45
|
+
children: /*#__PURE__*/_jsx(activeVariant.component, {})
|
|
12
46
|
}));
|
|
13
47
|
});
|
|
14
48
|
process.env.NODE_ENV !== "production" ? GridLoadingOverlay.propTypes = {
|
|
@@ -16,6 +50,16 @@ process.env.NODE_ENV !== "production" ? GridLoadingOverlay.propTypes = {
|
|
|
16
50
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
17
51
|
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
18
52
|
// ----------------------------------------------------------------------
|
|
19
|
-
|
|
53
|
+
/**
|
|
54
|
+
* The variant of the overlay when no rows are displayed.
|
|
55
|
+
* @default 'circular-progress'
|
|
56
|
+
*/
|
|
57
|
+
noRowsVariant: PropTypes.oneOf(['circular-progress', 'linear-progress', 'skeleton']),
|
|
58
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
59
|
+
/**
|
|
60
|
+
* The variant of the overlay.
|
|
61
|
+
* @default 'circular-progress'
|
|
62
|
+
*/
|
|
63
|
+
variant: PropTypes.oneOf(['circular-progress', 'linear-progress', 'skeleton'])
|
|
20
64
|
} : void 0;
|
|
21
65
|
export { GridLoadingOverlay };
|
package/components/GridRow.js
CHANGED
|
@@ -249,10 +249,11 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
249
249
|
const pinnedOffset = getPinnedCellOffset(gridPinnedColumnPositionLookup[pinnedPosition], column.computedWidth, indexRelativeToAllColumns, columnPositions, dimensions);
|
|
250
250
|
if (rowNode?.type === 'skeletonRow') {
|
|
251
251
|
return /*#__PURE__*/_jsx(slots.skeletonCell, {
|
|
252
|
+
type: column.type,
|
|
252
253
|
width: width,
|
|
253
254
|
height: rowHeight,
|
|
254
255
|
field: column.field,
|
|
255
|
-
align: column.align
|
|
256
|
+
align: column.align
|
|
256
257
|
}, column.field);
|
|
257
258
|
}
|
|
258
259
|
const editCellState = editRowsState[rowId]?.[column.field] ?? null;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { styled } from '@mui/system';
|
|
5
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
6
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
7
|
+
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
8
|
+
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
9
|
+
import { GridPinnedColumnPosition, gridColumnPositionsSelector, gridColumnsTotalWidthSelector, gridDimensionsSelector, gridVisibleColumnDefinitionsSelector, gridVisiblePinnedColumnDefinitionsSelector, useGridApiEventHandler, useGridSelector } from '../hooks';
|
|
10
|
+
import { getDataGridUtilityClass, gridClasses } from '../constants/gridClasses';
|
|
11
|
+
import { getPinnedCellOffset } from '../internals/utils/getPinnedCellOffset';
|
|
12
|
+
import { shouldCellShowLeftBorder, shouldCellShowRightBorder } from '../utils/cellBorderUtils';
|
|
13
|
+
import { escapeOperandAttributeSelector } from '../utils/domUtils';
|
|
14
|
+
import { GridScrollbarFillerCell } from './GridScrollbarFillerCell';
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
const SkeletonOverlay = styled('div', {
|
|
17
|
+
name: 'MuiDataGrid',
|
|
18
|
+
slot: 'SkeletonLoadingOverlay',
|
|
19
|
+
overridesResolver: (props, styles) => styles.skeletonLoadingOverlay
|
|
20
|
+
})({
|
|
21
|
+
minWidth: '100%',
|
|
22
|
+
width: 'max-content',
|
|
23
|
+
// prevents overflow: clip; cutting off the x axis
|
|
24
|
+
height: '100%',
|
|
25
|
+
overflow: 'clip' // y axis is hidden while the x axis is allowed to overflow
|
|
26
|
+
});
|
|
27
|
+
const useUtilityClasses = ownerState => {
|
|
28
|
+
const {
|
|
29
|
+
classes
|
|
30
|
+
} = ownerState;
|
|
31
|
+
const slots = {
|
|
32
|
+
root: ['skeletonLoadingOverlay']
|
|
33
|
+
};
|
|
34
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
35
|
+
};
|
|
36
|
+
const getColIndex = el => parseInt(el.getAttribute('data-colindex'), 10);
|
|
37
|
+
const GridSkeletonLoadingOverlay = /*#__PURE__*/React.forwardRef(function GridSkeletonLoadingOverlay(props, forwardedRef) {
|
|
38
|
+
const rootProps = useGridRootProps();
|
|
39
|
+
const {
|
|
40
|
+
slots
|
|
41
|
+
} = rootProps;
|
|
42
|
+
const classes = useUtilityClasses({
|
|
43
|
+
classes: rootProps.classes
|
|
44
|
+
});
|
|
45
|
+
const ref = React.useRef(null);
|
|
46
|
+
const handleRef = useForkRef(ref, forwardedRef);
|
|
47
|
+
const apiRef = useGridApiContext();
|
|
48
|
+
const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
|
|
49
|
+
const viewportHeight = dimensions?.viewportInnerSize.height ?? 0;
|
|
50
|
+
const skeletonRowsCount = Math.ceil(viewportHeight / dimensions.rowHeight);
|
|
51
|
+
const totalWidth = useGridSelector(apiRef, gridColumnsTotalWidthSelector);
|
|
52
|
+
const positions = useGridSelector(apiRef, gridColumnPositionsSelector);
|
|
53
|
+
const inViewportCount = React.useMemo(() => positions.filter(value => value <= totalWidth).length, [totalWidth, positions]);
|
|
54
|
+
const allVisibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
|
|
55
|
+
const columns = React.useMemo(() => allVisibleColumns.slice(0, inViewportCount), [allVisibleColumns, inViewportCount]);
|
|
56
|
+
const pinnedColumns = useGridSelector(apiRef, gridVisiblePinnedColumnDefinitionsSelector);
|
|
57
|
+
const getPinnedStyle = React.useCallback((computedWidth, index, position) => {
|
|
58
|
+
const pinnedOffset = getPinnedCellOffset(position, computedWidth, index, positions, dimensions);
|
|
59
|
+
return {
|
|
60
|
+
[position]: pinnedOffset
|
|
61
|
+
};
|
|
62
|
+
}, [dimensions, positions]);
|
|
63
|
+
const getPinnedPosition = React.useCallback(field => {
|
|
64
|
+
if (pinnedColumns.left.findIndex(col => col.field === field) !== -1) {
|
|
65
|
+
return GridPinnedColumnPosition.LEFT;
|
|
66
|
+
}
|
|
67
|
+
if (pinnedColumns.right.findIndex(col => col.field === field) !== -1) {
|
|
68
|
+
return GridPinnedColumnPosition.RIGHT;
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
}, [pinnedColumns.left, pinnedColumns.right]);
|
|
72
|
+
const children = React.useMemo(() => {
|
|
73
|
+
const array = [];
|
|
74
|
+
for (let i = 0; i < skeletonRowsCount; i += 1) {
|
|
75
|
+
const rowCells = [];
|
|
76
|
+
for (let colIndex = 0; colIndex < columns.length; colIndex += 1) {
|
|
77
|
+
const column = columns[colIndex];
|
|
78
|
+
const pinnedPosition = getPinnedPosition(column.field);
|
|
79
|
+
const isPinnedLeft = pinnedPosition === GridPinnedColumnPosition.LEFT;
|
|
80
|
+
const isPinnedRight = pinnedPosition === GridPinnedColumnPosition.RIGHT;
|
|
81
|
+
const sectionLength = pinnedPosition ? pinnedColumns[pinnedPosition].length // pinned section
|
|
82
|
+
: columns.length - pinnedColumns.left.length - pinnedColumns.right.length; // middle section
|
|
83
|
+
const sectionIndex = pinnedPosition ? pinnedColumns[pinnedPosition].findIndex(col => col.field === column.field) // pinned section
|
|
84
|
+
: colIndex - pinnedColumns.left.length; // middle section
|
|
85
|
+
const pinnedStyle = pinnedPosition && getPinnedStyle(column.computedWidth, colIndex, pinnedPosition);
|
|
86
|
+
const gridHasFiller = dimensions.columnsTotalWidth < dimensions.viewportOuterSize.width;
|
|
87
|
+
const showRightBorder = shouldCellShowRightBorder(pinnedPosition, sectionIndex, sectionLength, rootProps.showCellVerticalBorder, gridHasFiller);
|
|
88
|
+
const showLeftBorder = shouldCellShowLeftBorder(pinnedPosition, sectionIndex);
|
|
89
|
+
const isLastColumn = colIndex === columns.length - 1;
|
|
90
|
+
const isFirstPinnedRight = isPinnedRight && sectionIndex === 0;
|
|
91
|
+
const hasFillerBefore = isFirstPinnedRight && gridHasFiller;
|
|
92
|
+
const hasFillerAfter = isLastColumn && !isFirstPinnedRight && gridHasFiller;
|
|
93
|
+
const expandedWidth = dimensions.viewportOuterSize.width - dimensions.columnsTotalWidth;
|
|
94
|
+
const emptyCellWidth = Math.max(0, expandedWidth);
|
|
95
|
+
const emptyCell = /*#__PURE__*/_jsx(slots.skeletonCell, {
|
|
96
|
+
width: emptyCellWidth,
|
|
97
|
+
empty: true
|
|
98
|
+
}, `skeleton-filler-column-${i}`);
|
|
99
|
+
const scrollbarWidth = dimensions.hasScrollY ? dimensions.scrollbarSize : 0;
|
|
100
|
+
const hasScrollbarFiller = isLastColumn && scrollbarWidth !== 0;
|
|
101
|
+
if (hasFillerBefore) {
|
|
102
|
+
rowCells.push(emptyCell);
|
|
103
|
+
}
|
|
104
|
+
rowCells.push( /*#__PURE__*/_jsx(slots.skeletonCell, {
|
|
105
|
+
field: column.field,
|
|
106
|
+
type: column.type,
|
|
107
|
+
align: column.align,
|
|
108
|
+
width: "var(--width)",
|
|
109
|
+
height: dimensions.rowHeight,
|
|
110
|
+
"data-colindex": colIndex,
|
|
111
|
+
className: clsx(isPinnedLeft && gridClasses['cell--pinnedLeft'], isPinnedRight && gridClasses['cell--pinnedRight'], showRightBorder && gridClasses['cell--withRightBorder'], showLeftBorder && gridClasses['cell--withLeftBorder']),
|
|
112
|
+
style: _extends({
|
|
113
|
+
'--width': `${column.computedWidth}px`
|
|
114
|
+
}, pinnedStyle)
|
|
115
|
+
}, `skeleton-column-${i}-${column.field}`));
|
|
116
|
+
if (hasFillerAfter) {
|
|
117
|
+
rowCells.push(emptyCell);
|
|
118
|
+
}
|
|
119
|
+
if (hasScrollbarFiller) {
|
|
120
|
+
rowCells.push( /*#__PURE__*/_jsx(GridScrollbarFillerCell, {
|
|
121
|
+
pinnedRight: pinnedColumns.right.length > 0
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
array.push( /*#__PURE__*/_jsx("div", {
|
|
126
|
+
className: clsx(gridClasses.row, gridClasses.rowSkeleton, i === 0 && gridClasses['row--firstVisible']),
|
|
127
|
+
children: rowCells
|
|
128
|
+
}, `skeleton-row-${i}`));
|
|
129
|
+
}
|
|
130
|
+
return array;
|
|
131
|
+
}, [slots, columns, pinnedColumns, skeletonRowsCount, rootProps.showCellVerticalBorder, dimensions.columnsTotalWidth, dimensions.viewportOuterSize.width, dimensions.rowHeight, dimensions.hasScrollY, dimensions.scrollbarSize, getPinnedPosition, getPinnedStyle]);
|
|
132
|
+
|
|
133
|
+
// Sync the column resize of the overlay columns with the grid
|
|
134
|
+
const handleColumnResize = params => {
|
|
135
|
+
const {
|
|
136
|
+
colDef,
|
|
137
|
+
width
|
|
138
|
+
} = params;
|
|
139
|
+
const cells = ref.current?.querySelectorAll(`[data-field="${escapeOperandAttributeSelector(colDef.field)}"]`);
|
|
140
|
+
if (!cells) {
|
|
141
|
+
throw new Error('MUI X: Expected skeleton cells to be defined with `data-field` attribute.');
|
|
142
|
+
}
|
|
143
|
+
const resizedColIndex = columns.findIndex(col => col.field === colDef.field);
|
|
144
|
+
const pinnedPosition = getPinnedPosition(colDef.field);
|
|
145
|
+
const isPinnedLeft = pinnedPosition === GridPinnedColumnPosition.LEFT;
|
|
146
|
+
const isPinnedRight = pinnedPosition === GridPinnedColumnPosition.RIGHT;
|
|
147
|
+
const currentWidth = getComputedStyle(cells[0]).getPropertyValue('--width');
|
|
148
|
+
const delta = parseInt(currentWidth, 10) - width;
|
|
149
|
+
if (cells) {
|
|
150
|
+
cells.forEach(element => {
|
|
151
|
+
element.style.setProperty('--width', `${width}px`);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
if (isPinnedLeft) {
|
|
155
|
+
const pinnedCells = ref.current?.querySelectorAll(`.${gridClasses['cell--pinnedLeft']}`);
|
|
156
|
+
pinnedCells?.forEach(element => {
|
|
157
|
+
const colIndex = getColIndex(element);
|
|
158
|
+
if (colIndex > resizedColIndex) {
|
|
159
|
+
element.style.left = `${parseInt(getComputedStyle(element).left, 10) - delta}px`;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (isPinnedRight) {
|
|
164
|
+
const pinnedCells = ref.current?.querySelectorAll(`.${gridClasses['cell--pinnedRight']}`);
|
|
165
|
+
pinnedCells?.forEach(element => {
|
|
166
|
+
const colIndex = getColIndex(element);
|
|
167
|
+
if (colIndex < resizedColIndex) {
|
|
168
|
+
element.style.right = `${parseInt(getComputedStyle(element).right, 10) + delta}px`;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
useGridApiEventHandler(apiRef, 'columnResize', handleColumnResize);
|
|
174
|
+
return /*#__PURE__*/_jsx(SkeletonOverlay, _extends({
|
|
175
|
+
className: classes.root,
|
|
176
|
+
ref: handleRef
|
|
177
|
+
}, props, {
|
|
178
|
+
children: children
|
|
179
|
+
}));
|
|
180
|
+
});
|
|
181
|
+
export { GridSkeletonLoadingOverlay };
|
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
2
|
+
import { GridOverlayType } from '../../hooks/features/overlays/useGridOverlays';
|
|
3
|
+
import { GridLoadingOverlayVariant } from '../GridLoadingOverlay';
|
|
4
|
+
interface GridOverlaysProps {
|
|
5
|
+
overlayType: GridOverlayType;
|
|
6
|
+
loadingOverlayVariant: GridLoadingOverlayVariant | null;
|
|
7
|
+
}
|
|
8
|
+
export declare function GridOverlays(props: GridOverlaysProps): React.JSX.Element | null;
|
|
9
|
+
export declare namespace GridOverlays {
|
|
10
|
+
var propTypes: any;
|
|
11
|
+
}
|
|
12
|
+
export {};
|