@mui/x-data-grid 7.24.1 → 7.26.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 +148 -0
- package/DataGrid/DataGrid.js +1 -7
- package/DataGrid/useDataGridComponent.js +2 -2
- package/components/GridRow.d.ts +0 -1
- package/components/GridRow.js +32 -20
- package/components/GridScrollArea.d.ts +5 -2
- package/components/GridScrollArea.js +32 -25
- package/components/GridSkeletonLoadingOverlay.js +2 -1
- package/components/cell/GridCell.d.ts +9 -6
- package/components/cell/GridCell.js +29 -52
- package/components/containers/GridRoot.js +11 -9
- package/components/containers/GridRootStyles.js +138 -40
- package/components/toolbar/GridToolbarColumnsButton.js +5 -4
- package/components/toolbar/GridToolbarDensitySelector.js +2 -2
- package/components/toolbar/GridToolbarExportContainer.js +2 -2
- package/components/toolbar/GridToolbarFilterButton.js +4 -3
- package/components/virtualization/GridMainContainer.d.ts +10 -0
- package/components/virtualization/GridMainContainer.js +10 -2
- package/components/virtualization/GridVirtualScrollbar.d.ts +4 -0
- package/components/virtualization/GridVirtualScrollbar.js +5 -5
- package/components/virtualization/GridVirtualScroller.js +36 -16
- package/components/virtualization/GridVirtualScrollerContent.js +11 -2
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +1 -1
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +6 -4
- package/hooks/core/useGridStateInitialization.js +3 -2
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -14
- package/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/hooks/features/columns/gridColumnsSelector.d.ts +0 -5
- package/hooks/features/columns/gridColumnsSelector.js +0 -12
- package/hooks/features/columns/useGridColumns.js +7 -3
- package/hooks/features/dimensions/gridDimensionsSelectors.d.ts +16 -0
- package/hooks/features/dimensions/gridDimensionsSelectors.js +26 -1
- package/hooks/features/dimensions/index.d.ts +1 -1
- package/hooks/features/dimensions/index.js +1 -2
- package/hooks/features/dimensions/useGridDimensions.js +102 -77
- package/hooks/features/editing/gridEditingSelectors.d.ts +10 -0
- package/hooks/features/editing/gridEditingSelectors.js +12 -1
- package/hooks/features/editing/index.d.ts +1 -1
- package/hooks/features/editing/index.js +1 -1
- package/hooks/features/editing/useGridCellEditing.js +3 -3
- package/hooks/features/editing/useGridRowEditing.js +8 -9
- package/hooks/features/filter/gridFilterState.d.ts +5 -0
- package/hooks/features/filter/gridFilterState.js +5 -0
- package/hooks/features/filter/useGridFilter.js +6 -13
- package/hooks/features/focus/useGridFocus.js +3 -2
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +24 -16
- package/hooks/features/keyboardNavigation/utils.d.ts +1 -2
- package/hooks/features/keyboardNavigation/utils.js +0 -5
- package/hooks/features/listView/useGridListView.js +2 -1
- package/hooks/features/pagination/useGridPagination.js +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +4 -4
- package/hooks/features/rowSelection/utils.js +1 -1
- package/hooks/features/rows/gridRowsMetaState.d.ts +8 -0
- package/hooks/features/rows/gridRowsUtils.d.ts +0 -4
- package/hooks/features/rows/gridRowsUtils.js +0 -16
- package/hooks/features/rows/useGridParamsApi.d.ts +1 -1
- package/hooks/features/rows/useGridParamsApi.js +33 -14
- package/hooks/features/rows/useGridRowSpanning.js +94 -91
- package/hooks/features/rows/useGridRows.js +7 -8
- package/hooks/features/rows/useGridRowsMeta.js +36 -19
- package/hooks/features/sorting/gridSortingSelector.js +10 -9
- package/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +15 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +74 -72
- package/hooks/utils/useGridSelector.d.ts +8 -1
- package/hooks/utils/useGridSelector.js +42 -8
- package/hooks/utils/useIsSSR.d.ts +1 -0
- package/hooks/utils/useIsSSR.js +5 -0
- package/index.js +1 -1
- package/internals/index.d.ts +2 -1
- package/internals/index.js +2 -1
- package/models/api/gridApiCommon.d.ts +2 -2
- package/models/api/gridParamsApi.d.ts +29 -2
- package/models/api/gridStateApi.d.ts +1 -0
- package/models/api/index.d.ts +1 -1
- package/models/api/index.js +0 -1
- package/models/events/gridEventLookup.d.ts +6 -0
- package/modern/DataGrid/DataGrid.js +1 -7
- package/modern/DataGrid/useDataGridComponent.js +2 -2
- package/modern/components/GridRow.js +32 -20
- package/modern/components/GridScrollArea.js +32 -25
- package/modern/components/GridSkeletonLoadingOverlay.js +2 -1
- package/modern/components/cell/GridCell.js +29 -52
- package/modern/components/containers/GridRoot.js +11 -9
- package/modern/components/containers/GridRootStyles.js +138 -40
- package/modern/components/toolbar/GridToolbarColumnsButton.js +5 -4
- package/modern/components/toolbar/GridToolbarDensitySelector.js +2 -2
- package/modern/components/toolbar/GridToolbarExportContainer.js +2 -2
- package/modern/components/toolbar/GridToolbarFilterButton.js +4 -3
- package/modern/components/virtualization/GridMainContainer.js +10 -2
- package/modern/components/virtualization/GridVirtualScrollbar.js +5 -5
- package/modern/components/virtualization/GridVirtualScroller.js +36 -16
- package/modern/components/virtualization/GridVirtualScrollerContent.js +11 -2
- package/modern/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +6 -4
- package/modern/hooks/core/useGridStateInitialization.js +3 -2
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -14
- package/modern/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/modern/hooks/features/columns/gridColumnsSelector.js +0 -12
- package/modern/hooks/features/columns/useGridColumns.js +7 -3
- package/modern/hooks/features/dimensions/gridDimensionsSelectors.js +26 -1
- package/modern/hooks/features/dimensions/index.js +1 -2
- package/modern/hooks/features/dimensions/useGridDimensions.js +102 -77
- package/modern/hooks/features/editing/gridEditingSelectors.js +12 -1
- package/modern/hooks/features/editing/index.js +1 -1
- package/modern/hooks/features/editing/useGridCellEditing.js +3 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +8 -9
- package/modern/hooks/features/filter/gridFilterState.js +5 -0
- package/modern/hooks/features/filter/useGridFilter.js +6 -13
- package/modern/hooks/features/focus/useGridFocus.js +3 -2
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +24 -16
- package/modern/hooks/features/keyboardNavigation/utils.js +0 -5
- package/modern/hooks/features/listView/useGridListView.js +2 -1
- package/modern/hooks/features/pagination/useGridPagination.js +1 -1
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +4 -4
- package/modern/hooks/features/rowSelection/utils.js +1 -1
- package/modern/hooks/features/rows/gridRowsUtils.js +0 -16
- package/modern/hooks/features/rows/useGridParamsApi.js +33 -14
- package/modern/hooks/features/rows/useGridRowSpanning.js +94 -91
- package/modern/hooks/features/rows/useGridRows.js +7 -8
- package/modern/hooks/features/rows/useGridRowsMeta.js +36 -19
- package/modern/hooks/features/sorting/gridSortingSelector.js +10 -9
- package/modern/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +74 -72
- package/modern/hooks/utils/useGridSelector.js +42 -8
- package/modern/hooks/utils/useIsSSR.js +5 -0
- package/modern/index.js +1 -1
- package/modern/internals/index.js +2 -1
- package/modern/models/api/index.js +0 -1
- package/modern/utils/roundToDecimalPlaces.js +3 -0
- package/modern/utils/utils.js +6 -1
- package/node/DataGrid/DataGrid.js +1 -7
- package/node/DataGrid/useDataGridComponent.js +2 -2
- package/node/components/GridRow.js +28 -17
- package/node/components/GridScrollArea.js +31 -24
- package/node/components/GridSkeletonLoadingOverlay.js +2 -1
- package/node/components/cell/GridCell.js +27 -50
- package/node/components/containers/GridRoot.js +10 -8
- package/node/components/containers/GridRootStyles.js +138 -40
- package/node/components/toolbar/GridToolbarColumnsButton.js +5 -4
- package/node/components/toolbar/GridToolbarDensitySelector.js +2 -2
- package/node/components/toolbar/GridToolbarExportContainer.js +2 -2
- package/node/components/toolbar/GridToolbarFilterButton.js +4 -3
- package/node/components/virtualization/GridMainContainer.js +10 -2
- package/node/components/virtualization/GridVirtualScrollbar.js +5 -5
- package/node/components/virtualization/GridVirtualScroller.js +36 -16
- package/node/components/virtualization/GridVirtualScrollerContent.js +11 -2
- package/node/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +6 -4
- package/node/hooks/core/useGridStateInitialization.js +3 -2
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -14
- package/node/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/node/hooks/features/columns/gridColumnsSelector.js +1 -13
- package/node/hooks/features/columns/useGridColumns.js +7 -3
- package/node/hooks/features/dimensions/gridDimensionsSelectors.js +38 -2
- package/node/hooks/features/dimensions/index.js +13 -11
- package/node/hooks/features/dimensions/useGridDimensions.js +99 -74
- package/node/hooks/features/editing/gridEditingSelectors.js +12 -2
- package/node/hooks/features/editing/index.js +7 -11
- package/node/hooks/features/editing/useGridCellEditing.js +2 -2
- package/node/hooks/features/editing/useGridRowEditing.js +6 -7
- package/node/hooks/features/filter/gridFilterState.js +6 -1
- package/node/hooks/features/filter/useGridFilter.js +5 -12
- package/node/hooks/features/focus/useGridFocus.js +3 -2
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +24 -15
- package/node/hooks/features/keyboardNavigation/utils.js +0 -6
- package/node/hooks/features/listView/useGridListView.js +2 -1
- package/node/hooks/features/pagination/useGridPagination.js +1 -1
- package/node/hooks/features/rowSelection/useGridRowSelection.js +3 -3
- package/node/hooks/features/rowSelection/utils.js +1 -1
- package/node/hooks/features/rows/gridRowsUtils.js +0 -17
- package/node/hooks/features/rows/useGridParamsApi.js +33 -14
- package/node/hooks/features/rows/useGridRowSpanning.js +92 -89
- package/node/hooks/features/rows/useGridRows.js +7 -8
- package/node/hooks/features/rows/useGridRowsMeta.js +36 -19
- package/node/hooks/features/sorting/gridSortingSelector.js +10 -9
- package/node/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +73 -71
- package/node/hooks/utils/useGridSelector.js +42 -8
- package/node/hooks/utils/useIsSSR.js +12 -0
- package/node/index.js +1 -1
- package/node/internals/index.js +20 -7
- package/node/models/api/index.js +0 -11
- package/node/utils/roundToDecimalPlaces.js +9 -0
- package/node/utils/utils.js +8 -1
- package/package.json +3 -2
- package/utils/roundToDecimalPlaces.d.ts +1 -0
- package/utils/roundToDecimalPlaces.js +3 -0
- package/utils/utils.d.ts +1 -0
- package/utils/utils.js +6 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["column", "rowId", "
|
|
3
|
+
const _excluded = ["column", "row", "rowId", "rowNode", "align", "children", "colIndex", "width", "className", "style", "colSpan", "disableDragEvents", "isNotVisible", "pinnedOffset", "pinnedPosition", "showRightBorder", "showLeftBorder", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
|
|
4
4
|
_excluded2 = ["changeReason", "unstable_updateValueOnRender"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
@@ -12,13 +12,14 @@ import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
|
12
12
|
import { doesSupportPreventScroll } from "../../utils/doesSupportPreventScroll.js";
|
|
13
13
|
import { getDataGridUtilityClass, gridClasses } from "../../constants/gridClasses.js";
|
|
14
14
|
import { GridCellModes } from "../../models/index.js";
|
|
15
|
-
import { useGridSelector,
|
|
16
|
-
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
15
|
+
import { useGridSelector, useGridSelectorV8 } from "../../hooks/utils/useGridSelector.js";
|
|
17
16
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
18
|
-
import { gridFocusCellSelector } from "../../hooks/features/focus/gridFocusStateSelector.js";
|
|
17
|
+
import { gridFocusCellSelector, gridTabIndexCellSelector } from "../../hooks/features/focus/gridFocusStateSelector.js";
|
|
19
18
|
import { GridPinnedColumnPosition } from "../../hooks/features/columns/gridColumnsInterfaces.js";
|
|
20
19
|
import { PinnedColumnPosition } from "../../internals/constants.js";
|
|
21
20
|
import { gridRowSpanningHiddenCellsSelector, gridRowSpanningSpannedCellsSelector } from "../../hooks/features/rows/gridRowSpanningSelectors.js";
|
|
21
|
+
import { useGridPrivateApiContext } from "../../hooks/utils/useGridPrivateApiContext.js";
|
|
22
|
+
import { gridEditCellStateSelector } from "../../hooks/features/editing/gridEditingSelectors.js";
|
|
22
23
|
import { attachPinnedStyle } from "../../internals/utils/index.js";
|
|
23
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
25
|
export const gridPinnedColumnPositionLookup = {
|
|
@@ -27,30 +28,6 @@ export const gridPinnedColumnPositionLookup = {
|
|
|
27
28
|
[PinnedColumnPosition.NONE]: undefined,
|
|
28
29
|
[PinnedColumnPosition.VIRTUAL]: undefined
|
|
29
30
|
};
|
|
30
|
-
const EMPTY_CELL_PARAMS = {
|
|
31
|
-
id: -1,
|
|
32
|
-
field: '__unset__',
|
|
33
|
-
row: {},
|
|
34
|
-
rowNode: {
|
|
35
|
-
id: -1,
|
|
36
|
-
depth: 0,
|
|
37
|
-
type: 'leaf',
|
|
38
|
-
parent: -1,
|
|
39
|
-
groupingKey: null
|
|
40
|
-
},
|
|
41
|
-
colDef: {
|
|
42
|
-
type: 'string',
|
|
43
|
-
field: '__unset__',
|
|
44
|
-
computedWidth: 0
|
|
45
|
-
},
|
|
46
|
-
cellMode: GridCellModes.View,
|
|
47
|
-
hasFocus: false,
|
|
48
|
-
tabIndex: -1,
|
|
49
|
-
value: null,
|
|
50
|
-
formattedValue: '__unset__',
|
|
51
|
-
isEditable: false,
|
|
52
|
-
api: {}
|
|
53
|
-
};
|
|
54
31
|
const useUtilityClasses = ownerState => {
|
|
55
32
|
const {
|
|
56
33
|
align,
|
|
@@ -74,8 +51,9 @@ let warnedOnce = false;
|
|
|
74
51
|
const GridCell = forwardRef(function GridCell(props, ref) {
|
|
75
52
|
const {
|
|
76
53
|
column,
|
|
54
|
+
row,
|
|
77
55
|
rowId,
|
|
78
|
-
|
|
56
|
+
rowNode,
|
|
79
57
|
align,
|
|
80
58
|
colIndex,
|
|
81
59
|
width,
|
|
@@ -99,22 +77,29 @@ const GridCell = forwardRef(function GridCell(props, ref) {
|
|
|
99
77
|
onDragOver
|
|
100
78
|
} = props,
|
|
101
79
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
102
|
-
const apiRef =
|
|
80
|
+
const apiRef = useGridPrivateApiContext();
|
|
103
81
|
const rootProps = useGridRootProps();
|
|
104
82
|
const isRtl = useRtl();
|
|
105
83
|
const field = column.field;
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
84
|
+
const editCellState = useGridSelectorV8(apiRef, gridEditCellStateSelector, {
|
|
85
|
+
rowId,
|
|
86
|
+
field
|
|
87
|
+
});
|
|
88
|
+
const cellMode = editCellState ? GridCellModes.Edit : GridCellModes.View;
|
|
89
|
+
const cellParams = apiRef.current.getCellParamsForRow(rowId, field, row, {
|
|
90
|
+
colDef: column,
|
|
91
|
+
cellMode,
|
|
92
|
+
rowNode: rowNode,
|
|
93
|
+
tabIndex: useGridSelector(apiRef, () => {
|
|
94
|
+
const cellTabIndex = gridTabIndexCellSelector(apiRef);
|
|
95
|
+
return cellTabIndex && cellTabIndex.field === field && cellTabIndex.id === rowId ? 0 : -1;
|
|
96
|
+
}),
|
|
97
|
+
hasFocus: useGridSelector(apiRef, () => {
|
|
98
|
+
const focus = gridFocusCellSelector(apiRef);
|
|
99
|
+
return focus?.id === rowId && focus.field === field;
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
cellParams.api = apiRef.current;
|
|
118
103
|
const isSelected = useGridSelector(apiRef, () => apiRef.current.unstable_applyPipeProcessors('isCellSelected', false, {
|
|
119
104
|
id: rowId,
|
|
120
105
|
field
|
|
@@ -122,7 +107,6 @@ const GridCell = forwardRef(function GridCell(props, ref) {
|
|
|
122
107
|
const hiddenCells = useGridSelector(apiRef, gridRowSpanningHiddenCellsSelector);
|
|
123
108
|
const spannedCells = useGridSelector(apiRef, gridRowSpanningSpannedCellsSelector);
|
|
124
109
|
const {
|
|
125
|
-
cellMode,
|
|
126
110
|
hasFocus,
|
|
127
111
|
isEditable = false,
|
|
128
112
|
value
|
|
@@ -244,9 +228,6 @@ const GridCell = forwardRef(function GridCell(props, ref) {
|
|
|
244
228
|
}, style)
|
|
245
229
|
});
|
|
246
230
|
}
|
|
247
|
-
if (cellParams === EMPTY_CELL_PARAMS) {
|
|
248
|
-
return null;
|
|
249
|
-
}
|
|
250
231
|
let handleFocus = other.onFocus;
|
|
251
232
|
if (process.env.NODE_ENV === 'test' && rootProps.experimentalFeatures?.warnIfFocusStateIsNotSynced) {
|
|
252
233
|
handleFocus = event => {
|
|
@@ -330,16 +311,12 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
|
|
|
330
311
|
colSpan: PropTypes.number,
|
|
331
312
|
column: PropTypes.object.isRequired,
|
|
332
313
|
disableDragEvents: PropTypes.bool,
|
|
333
|
-
editCellState: PropTypes.shape({
|
|
334
|
-
changeReason: PropTypes.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
|
|
335
|
-
isProcessingProps: PropTypes.bool,
|
|
336
|
-
isValidating: PropTypes.bool,
|
|
337
|
-
value: PropTypes.any
|
|
338
|
-
}),
|
|
339
314
|
isNotVisible: PropTypes.bool.isRequired,
|
|
340
315
|
pinnedOffset: PropTypes.number,
|
|
341
316
|
pinnedPosition: PropTypes.oneOf([0, 1, 2, 3]).isRequired,
|
|
317
|
+
row: PropTypes.object.isRequired,
|
|
342
318
|
rowId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
319
|
+
rowNode: PropTypes.object.isRequired,
|
|
343
320
|
showLeftBorder: PropTypes.bool.isRequired,
|
|
344
321
|
showRightBorder: PropTypes.bool.isRequired,
|
|
345
322
|
width: PropTypes.number.isRequired
|
|
@@ -4,7 +4,7 @@ const _excluded = ["className", "children"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
|
-
import { unstable_useForkRef as useForkRef,
|
|
7
|
+
import { unstable_useForkRef as useForkRef, unstable_capitalize as capitalize, unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
8
8
|
import { fastMemo } from '@mui/x-internals/fastMemo';
|
|
9
9
|
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
10
10
|
import { GridRootStyles } from "./GridRootStyles.js";
|
|
@@ -13,6 +13,7 @@ import { useGridPrivateApiContext } from "../../hooks/utils/useGridPrivateApiCon
|
|
|
13
13
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
14
14
|
import { getDataGridUtilityClass } from "../../constants/gridClasses.js";
|
|
15
15
|
import { gridDensitySelector } from "../../hooks/features/density/densitySelector.js";
|
|
16
|
+
import { useIsSSR } from "../../hooks/utils/useIsSSR.js";
|
|
16
17
|
import { GridHeader } from "../GridHeader.js";
|
|
17
18
|
import { GridBody, GridFooterPlaceholder } from "../base/index.js";
|
|
18
19
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -37,16 +38,17 @@ const GridRoot = forwardRef(function GridRoot(props, ref) {
|
|
|
37
38
|
const apiRef = useGridPrivateApiContext();
|
|
38
39
|
const density = useGridSelector(apiRef, gridDensitySelector);
|
|
39
40
|
const rootElementRef = apiRef.current.rootElementRef;
|
|
40
|
-
const
|
|
41
|
+
const rootMountCallback = React.useCallback(node => {
|
|
42
|
+
if (node === null) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
apiRef.current.publishEvent('rootMount', node);
|
|
46
|
+
}, [apiRef]);
|
|
47
|
+
const handleRef = useForkRef(rootElementRef, ref, rootMountCallback);
|
|
41
48
|
const ownerState = rootProps;
|
|
42
49
|
const classes = useUtilityClasses(ownerState, density);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const [mountedState, setMountedState] = React.useState(false);
|
|
46
|
-
useEnhancedEffect(() => {
|
|
47
|
-
setMountedState(true);
|
|
48
|
-
}, []);
|
|
49
|
-
if (!mountedState) {
|
|
50
|
+
const isSSR = useIsSSR();
|
|
51
|
+
if (isSSR) {
|
|
50
52
|
return null;
|
|
51
53
|
}
|
|
52
54
|
return /*#__PURE__*/_jsxs(GridRootStyles, _extends({
|
|
@@ -3,7 +3,6 @@ import { alpha, styled, darken, lighten, decomposeColor, recomposeColor } from '
|
|
|
3
3
|
import { gridClasses as c } from "../../constants/gridClasses.js";
|
|
4
4
|
import { useGridSelector } from "../../hooks/utils/useGridSelector.js";
|
|
5
5
|
import { useGridPrivateApiContext } from "../../hooks/utils/useGridPrivateApiContext.js";
|
|
6
|
-
import { gridDimensionsSelector } from "../../hooks/features/dimensions/gridDimensionsSelectors.js";
|
|
7
6
|
function getBorderColor(theme) {
|
|
8
7
|
if (theme.vars) {
|
|
9
8
|
return theme.vars.palette.TableCell.border;
|
|
@@ -35,53 +34,80 @@ const separatorIconDragStyles = {
|
|
|
35
34
|
// Emotion thinks it knows better than us which selector we should use.
|
|
36
35
|
// https://github.com/emotion-js/emotion/issues/1105#issuecomment-1722524968
|
|
37
36
|
const ignoreSsrWarning = '/* emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason */';
|
|
37
|
+
const shouldShowBorderTopRightRadiusSelector = state => state.dimensions.hasScrollX && (!state.dimensions.hasScrollY || state.dimensions.scrollbarSize === 0);
|
|
38
38
|
export const GridRootStyles = styled('div', {
|
|
39
39
|
name: 'MuiDataGrid',
|
|
40
40
|
slot: 'Root',
|
|
41
|
-
overridesResolver: (props, styles) => [
|
|
41
|
+
overridesResolver: (props, styles) => [
|
|
42
|
+
// Root overrides
|
|
43
|
+
styles.root, {
|
|
42
44
|
[`&.${c.autoHeight}`]: styles.autoHeight
|
|
43
45
|
}, {
|
|
44
|
-
[`&.${c.
|
|
46
|
+
[`&.${c.autosizing}`]: styles.autosizing
|
|
45
47
|
}, {
|
|
46
|
-
[`&.${c['
|
|
48
|
+
[`&.${c['root--densityStandard']}`]: styles['root--densityStandard']
|
|
47
49
|
}, {
|
|
48
|
-
[`&.${c['
|
|
50
|
+
[`&.${c['root--densityComfortable']}`]: styles['root--densityComfortable']
|
|
49
51
|
}, {
|
|
50
|
-
[`&.${c['
|
|
52
|
+
[`&.${c['root--densityCompact']}`]: styles['root--densityCompact']
|
|
51
53
|
}, {
|
|
52
|
-
[`&.${c
|
|
54
|
+
[`&.${c['root--disableUserSelection']}`]: styles['root--disableUserSelection']
|
|
53
55
|
}, {
|
|
54
|
-
[`&.${c['root--
|
|
56
|
+
[`&.${c['root--noToolbar']}`]: styles['root--noToolbar']
|
|
55
57
|
}, {
|
|
56
|
-
[`&.${c.
|
|
58
|
+
[`&.${c.withVerticalBorder}`]: styles.withVerticalBorder
|
|
59
|
+
},
|
|
60
|
+
// Child element overrides
|
|
61
|
+
// - Only declare overrides here for class names that are not applied to `styled` components.
|
|
62
|
+
// - For `styled` components, declare overrides in the component itself.
|
|
63
|
+
{
|
|
64
|
+
[`& .${c.actionsCell}`]: styles.actionsCell
|
|
57
65
|
}, {
|
|
58
|
-
[`& .${c.
|
|
66
|
+
[`& .${c.booleanCell}`]: styles.booleanCell
|
|
59
67
|
}, {
|
|
60
68
|
[`& .${c.cell}`]: styles.cell
|
|
69
|
+
}, {
|
|
70
|
+
[`& .${c['cell--editable']}`]: styles['cell--editable']
|
|
61
71
|
}, {
|
|
62
72
|
[`& .${c['cell--editing']}`]: styles['cell--editing']
|
|
63
73
|
}, {
|
|
64
|
-
[`& .${c['cell--
|
|
74
|
+
[`& .${c['cell--flex']}`]: styles['cell--flex']
|
|
65
75
|
}, {
|
|
66
|
-
[`& .${c['cell--
|
|
76
|
+
[`& .${c['cell--pinnedLeft']}`]: styles['cell--pinnedLeft']
|
|
67
77
|
}, {
|
|
68
|
-
[`& .${c['cell--
|
|
69
|
-
}, {
|
|
70
|
-
[`& .${c['cell--rangeTop']}`]: styles['cell--rangeTop']
|
|
78
|
+
[`& .${c['cell--pinnedRight']}`]: styles['cell--pinnedRight']
|
|
71
79
|
}, {
|
|
72
80
|
[`& .${c['cell--rangeBottom']}`]: styles['cell--rangeBottom']
|
|
73
81
|
}, {
|
|
74
82
|
[`& .${c['cell--rangeLeft']}`]: styles['cell--rangeLeft']
|
|
75
83
|
}, {
|
|
76
84
|
[`& .${c['cell--rangeRight']}`]: styles['cell--rangeRight']
|
|
85
|
+
}, {
|
|
86
|
+
[`& .${c['cell--rangeTop']}`]: styles['cell--rangeTop']
|
|
87
|
+
}, {
|
|
88
|
+
[`& .${c['cell--selectionMode']}`]: styles['cell--selectionMode']
|
|
89
|
+
}, {
|
|
90
|
+
[`& .${c['cell--textCenter']}`]: styles['cell--textCenter']
|
|
91
|
+
}, {
|
|
92
|
+
[`& .${c['cell--textLeft']}`]: styles['cell--textLeft']
|
|
93
|
+
}, {
|
|
94
|
+
[`& .${c['cell--textRight']}`]: styles['cell--textRight']
|
|
95
|
+
}, {
|
|
96
|
+
[`& .${c['cell--withLeftBorder']}`]: styles['cell--withLeftBorder']
|
|
77
97
|
}, {
|
|
78
98
|
[`& .${c['cell--withRightBorder']}`]: styles['cell--withRightBorder']
|
|
79
99
|
}, {
|
|
80
100
|
[`& .${c.cellCheckbox}`]: styles.cellCheckbox
|
|
101
|
+
}, {
|
|
102
|
+
[`& .${c.cellEmpty}`]: styles.cellEmpty
|
|
103
|
+
}, {
|
|
104
|
+
[`& .${c.cellOffsetLeft}`]: styles.cellOffsetLeft
|
|
81
105
|
}, {
|
|
82
106
|
[`& .${c.cellSkeleton}`]: styles.cellSkeleton
|
|
83
107
|
}, {
|
|
84
108
|
[`& .${c.checkboxInput}`]: styles.checkboxInput
|
|
109
|
+
}, {
|
|
110
|
+
[`& .${c.columnHeader}`]: styles.columnHeader
|
|
85
111
|
}, {
|
|
86
112
|
[`& .${c['columnHeader--alignCenter']}`]: styles['columnHeader--alignCenter']
|
|
87
113
|
}, {
|
|
@@ -90,80 +116,156 @@ export const GridRootStyles = styled('div', {
|
|
|
90
116
|
[`& .${c['columnHeader--alignRight']}`]: styles['columnHeader--alignRight']
|
|
91
117
|
}, {
|
|
92
118
|
[`& .${c['columnHeader--dragging']}`]: styles['columnHeader--dragging']
|
|
119
|
+
}, {
|
|
120
|
+
[`& .${c['columnHeader--emptyGroup']}`]: styles['columnHeader--emptyGroup']
|
|
121
|
+
}, {
|
|
122
|
+
[`& .${c['columnHeader--filledGroup']}`]: styles['columnHeader--filledGroup']
|
|
123
|
+
}, {
|
|
124
|
+
[`& .${c['columnHeader--filtered']}`]: styles['columnHeader--filtered']
|
|
125
|
+
}, {
|
|
126
|
+
[`& .${c['columnHeader--last']}`]: styles['columnHeader--last']
|
|
127
|
+
}, {
|
|
128
|
+
[`& .${c['columnHeader--lastUnpinned']}`]: styles['columnHeader--lastUnpinned']
|
|
93
129
|
}, {
|
|
94
130
|
[`& .${c['columnHeader--moving']}`]: styles['columnHeader--moving']
|
|
95
131
|
}, {
|
|
96
132
|
[`& .${c['columnHeader--numeric']}`]: styles['columnHeader--numeric']
|
|
133
|
+
}, {
|
|
134
|
+
[`& .${c['columnHeader--pinnedLeft']}`]: styles['columnHeader--pinnedLeft']
|
|
135
|
+
}, {
|
|
136
|
+
[`& .${c['columnHeader--pinnedRight']}`]: styles['columnHeader--pinnedRight']
|
|
137
|
+
}, {
|
|
138
|
+
[`& .${c['columnHeader--siblingFocused']}`]: styles['columnHeader--siblingFocused']
|
|
97
139
|
}, {
|
|
98
140
|
[`& .${c['columnHeader--sortable']}`]: styles['columnHeader--sortable']
|
|
99
141
|
}, {
|
|
100
142
|
[`& .${c['columnHeader--sorted']}`]: styles['columnHeader--sorted']
|
|
101
143
|
}, {
|
|
102
|
-
[`& .${c['columnHeader--
|
|
103
|
-
}, {
|
|
104
|
-
[`& .${c.columnHeader}`]: styles.columnHeader
|
|
144
|
+
[`& .${c['columnHeader--withLeftBorder']}`]: styles['columnHeader--withLeftBorder']
|
|
105
145
|
}, {
|
|
106
|
-
[`& .${c
|
|
146
|
+
[`& .${c['columnHeader--withRightBorder']}`]: styles['columnHeader--withRightBorder']
|
|
107
147
|
}, {
|
|
108
148
|
[`& .${c.columnHeaderCheckbox}`]: styles.columnHeaderCheckbox
|
|
109
149
|
}, {
|
|
110
150
|
[`& .${c.columnHeaderDraggableContainer}`]: styles.columnHeaderDraggableContainer
|
|
111
151
|
}, {
|
|
112
152
|
[`& .${c.columnHeaderTitleContainer}`]: styles.columnHeaderTitleContainer
|
|
153
|
+
}, {
|
|
154
|
+
[`& .${c.columnHeaderTitleContainerContent}`]: styles.columnHeaderTitleContainerContent
|
|
155
|
+
}, {
|
|
156
|
+
[`& .${c.columnSeparator}`]: styles.columnSeparator
|
|
113
157
|
}, {
|
|
114
158
|
[`& .${c['columnSeparator--resizable']}`]: styles['columnSeparator--resizable']
|
|
115
159
|
}, {
|
|
116
160
|
[`& .${c['columnSeparator--resizing']}`]: styles['columnSeparator--resizing']
|
|
117
161
|
}, {
|
|
118
|
-
[`& .${c
|
|
162
|
+
[`& .${c['columnSeparator--sideLeft']}`]: styles['columnSeparator--sideLeft']
|
|
163
|
+
}, {
|
|
164
|
+
[`& .${c['columnSeparator--sideRight']}`]: styles['columnSeparator--sideRight']
|
|
165
|
+
}, {
|
|
166
|
+
[`& .${c['container--bottom']}`]: styles['container--bottom']
|
|
167
|
+
}, {
|
|
168
|
+
[`& .${c['container--top']}`]: styles['container--top']
|
|
169
|
+
}, {
|
|
170
|
+
[`& .${c.detailPanelToggleCell}`]: styles.detailPanelToggleCell
|
|
171
|
+
}, {
|
|
172
|
+
[`& .${c['detailPanelToggleCell--expanded']}`]: styles['detailPanelToggleCell--expanded']
|
|
173
|
+
}, {
|
|
174
|
+
[`& .${c.editBooleanCell}`]: styles.editBooleanCell
|
|
119
175
|
}, {
|
|
120
176
|
[`& .${c.filterIcon}`]: styles.filterIcon
|
|
177
|
+
}, {
|
|
178
|
+
[`& .${c['filler--borderBottom']}`]: styles['filler--borderBottom']
|
|
179
|
+
}, {
|
|
180
|
+
[`& .${c['filler--pinnedLeft']}`]: styles['filler--pinnedLeft']
|
|
181
|
+
}, {
|
|
182
|
+
[`& .${c['filler--pinnedRight']}`]: styles['filler--pinnedRight']
|
|
183
|
+
}, {
|
|
184
|
+
[`& .${c.groupingCriteriaCell}`]: styles.groupingCriteriaCell
|
|
185
|
+
}, {
|
|
186
|
+
[`& .${c.groupingCriteriaCellLoadingContainer}`]: styles.groupingCriteriaCellLoadingContainer
|
|
187
|
+
}, {
|
|
188
|
+
[`& .${c.groupingCriteriaCellToggle}`]: styles.groupingCriteriaCellToggle
|
|
189
|
+
}, {
|
|
190
|
+
[`& .${c.headerFilterRow}`]: styles.headerFilterRow
|
|
121
191
|
}, {
|
|
122
192
|
[`& .${c.iconSeparator}`]: styles.iconSeparator
|
|
123
193
|
}, {
|
|
124
194
|
[`& .${c.menuIcon}`]: styles.menuIcon
|
|
125
195
|
}, {
|
|
126
196
|
[`& .${c.menuIconButton}`]: styles.menuIconButton
|
|
197
|
+
}, {
|
|
198
|
+
[`& .${c.menuList}`]: styles.menuList
|
|
127
199
|
}, {
|
|
128
200
|
[`& .${c.menuOpen}`]: styles.menuOpen
|
|
129
201
|
}, {
|
|
130
|
-
[`& .${c.
|
|
202
|
+
[`& .${c.overlayWrapperInner}`]: styles.overlayWrapperInner
|
|
131
203
|
}, {
|
|
132
|
-
[`& .${c
|
|
204
|
+
[`& .${c.pinnedRows}`]: styles.pinnedRows
|
|
133
205
|
}, {
|
|
134
|
-
[`& .${c['
|
|
206
|
+
[`& .${c['pinnedRows--bottom']}`]: styles['pinnedRows--bottom']
|
|
135
207
|
}, {
|
|
136
|
-
[`& .${c['
|
|
208
|
+
[`& .${c['pinnedRows--top']}`]: styles['pinnedRows--top']
|
|
137
209
|
}, {
|
|
138
210
|
[`& .${c.row}`]: styles.row
|
|
139
211
|
}, {
|
|
140
|
-
[`& .${c
|
|
212
|
+
[`& .${c['row--borderBottom']}`]: styles['row--borderBottom']
|
|
213
|
+
}, {
|
|
214
|
+
[`& .${c['row--detailPanelExpanded']}`]: styles['row--detailPanelExpanded']
|
|
215
|
+
}, {
|
|
216
|
+
[`& .${c['row--dragging']}`]: styles['row--dragging']
|
|
217
|
+
}, {
|
|
218
|
+
[`& .${c['row--dynamicHeight']}`]: styles['row--dynamicHeight']
|
|
219
|
+
}, {
|
|
220
|
+
[`& .${c['row--editable']}`]: styles['row--editable']
|
|
221
|
+
}, {
|
|
222
|
+
[`& .${c['row--editing']}`]: styles['row--editing']
|
|
223
|
+
}, {
|
|
224
|
+
[`& .${c['row--firstVisible']}`]: styles['row--firstVisible']
|
|
225
|
+
}, {
|
|
226
|
+
[`& .${c['row--lastVisible']}`]: styles['row--lastVisible']
|
|
141
227
|
}, {
|
|
142
228
|
[`& .${c.rowReorderCell}`]: styles.rowReorderCell
|
|
143
229
|
}, {
|
|
144
230
|
[`& .${c['rowReorderCell--draggable']}`]: styles['rowReorderCell--draggable']
|
|
145
231
|
}, {
|
|
146
|
-
[`& .${c.
|
|
232
|
+
[`& .${c.rowReorderCellContainer}`]: styles.rowReorderCellContainer
|
|
147
233
|
}, {
|
|
148
|
-
[`& .${c.
|
|
234
|
+
[`& .${c.rowReorderCellPlaceholder}`]: styles.rowReorderCellPlaceholder
|
|
149
235
|
}, {
|
|
150
|
-
[`& .${c.
|
|
236
|
+
[`& .${c.rowSkeleton}`]: styles.rowSkeleton
|
|
151
237
|
}, {
|
|
152
|
-
[`& .${c.
|
|
238
|
+
[`& .${c.scrollbar}`]: styles.scrollbar
|
|
153
239
|
}, {
|
|
154
|
-
[`& .${c
|
|
240
|
+
[`& .${c['scrollbar--horizontal']}`]: styles['scrollbar--horizontal']
|
|
155
241
|
}, {
|
|
156
|
-
[`& .${c
|
|
242
|
+
[`& .${c['scrollbar--vertical']}`]: styles['scrollbar--vertical']
|
|
157
243
|
}, {
|
|
158
|
-
[`& .${c.
|
|
244
|
+
[`& .${c.scrollbarFiller}`]: styles.scrollbarFiller
|
|
159
245
|
}, {
|
|
160
|
-
[`& .${c['
|
|
161
|
-
},
|
|
246
|
+
[`& .${c['scrollbarFiller--borderBottom']}`]: styles['scrollbarFiller--borderBottom']
|
|
247
|
+
}, {
|
|
248
|
+
[`& .${c['scrollbarFiller--borderTop']}`]: styles['scrollbarFiller--borderTop']
|
|
249
|
+
}, {
|
|
250
|
+
[`& .${c['scrollbarFiller--header']}`]: styles['scrollbarFiller--header']
|
|
251
|
+
}, {
|
|
252
|
+
[`& .${c['scrollbarFiller--pinnedRight']}`]: styles['scrollbarFiller--pinnedRight']
|
|
253
|
+
}, {
|
|
254
|
+
[`& .${c.sortIcon}`]: styles.sortIcon
|
|
255
|
+
}, {
|
|
256
|
+
[`& .${c.treeDataGroupingCell}`]: styles.treeDataGroupingCell
|
|
257
|
+
}, {
|
|
258
|
+
[`& .${c.treeDataGroupingCellLoadingContainer}`]: styles.treeDataGroupingCellLoadingContainer
|
|
259
|
+
}, {
|
|
260
|
+
[`& .${c.treeDataGroupingCellToggle}`]: styles.treeDataGroupingCellToggle
|
|
261
|
+
}, {
|
|
262
|
+
[`& .${c.withBorderColor}`]: styles.withBorderColor
|
|
263
|
+
}]
|
|
162
264
|
})(({
|
|
163
265
|
theme: t
|
|
164
266
|
}) => {
|
|
165
267
|
const apiRef = useGridPrivateApiContext();
|
|
166
|
-
const
|
|
268
|
+
const shouldShowBorderTopRightRadius = useGridSelector(apiRef, shouldShowBorderTopRightRadiusSelector);
|
|
167
269
|
const borderColor = getBorderColor(t);
|
|
168
270
|
const radius = t.shape.borderRadius;
|
|
169
271
|
const containerBackground = t.vars ? t.vars.palette.background.default : t.mixins.MuiDataGrid?.containerBackground ?? t.palette.background.default;
|
|
@@ -255,10 +357,6 @@ export const GridRootStyles = styled('div', {
|
|
|
255
357
|
overflow: 'visible !important'
|
|
256
358
|
},
|
|
257
359
|
'@media (hover: hover)': {
|
|
258
|
-
[`& .${c.iconButtonContainer}`]: {
|
|
259
|
-
width: '0 !important',
|
|
260
|
-
visibility: 'hidden !important'
|
|
261
|
-
},
|
|
262
360
|
[`& .${c.menuIcon}`]: {
|
|
263
361
|
width: '0 !important',
|
|
264
362
|
visibility: 'hidden !important'
|
|
@@ -319,7 +417,7 @@ export const GridRootStyles = styled('div', {
|
|
|
319
417
|
borderTopLeftRadius: 'calc(var(--unstable_DataGrid-radius) - 1px)'
|
|
320
418
|
},
|
|
321
419
|
[`&.${c['root--noToolbar']} [aria-rowindex="1"] .${c['columnHeader--last']}`]: {
|
|
322
|
-
borderTopRightRadius:
|
|
420
|
+
borderTopRightRadius: shouldShowBorderTopRightRadius ? 'calc(var(--unstable_DataGrid-radius) - 1px)' : undefined
|
|
323
421
|
},
|
|
324
422
|
[`& .${c.columnHeaderCheckbox}, & .${c.cellCheckbox}`]: {
|
|
325
423
|
padding: 0,
|
|
@@ -45,14 +45,15 @@ const GridToolbarColumnsButton = forwardRef(function GridToolbarColumnsButton(pr
|
|
|
45
45
|
"aria-haspopup": "menu",
|
|
46
46
|
"aria-expanded": isOpen,
|
|
47
47
|
"aria-controls": isOpen ? columnPanelId : undefined,
|
|
48
|
-
startIcon: /*#__PURE__*/_jsx(rootProps.slots.columnSelectorIcon, {})
|
|
49
|
-
|
|
48
|
+
startIcon: /*#__PURE__*/_jsx(rootProps.slots.columnSelectorIcon, {})
|
|
49
|
+
}, rootProps.slotProps?.baseButton, buttonProps, {
|
|
50
50
|
onPointerUp: event => {
|
|
51
51
|
if (preferencePanel.open) {
|
|
52
52
|
event.stopPropagation();
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
buttonProps.onPointerUp?.(event);
|
|
55
|
+
},
|
|
56
|
+
onClick: showColumns,
|
|
56
57
|
ref: ref,
|
|
57
58
|
children: apiRef.current.getLocaleText('toolbarColumns')
|
|
58
59
|
}))
|
|
@@ -94,9 +94,9 @@ const GridToolbarDensitySelector = forwardRef(function GridToolbarDensitySelecto
|
|
|
94
94
|
"aria-haspopup": "menu",
|
|
95
95
|
"aria-expanded": open,
|
|
96
96
|
"aria-controls": open ? densityMenuId : undefined,
|
|
97
|
-
id: densityButtonId
|
|
98
|
-
onClick: handleDensitySelectorOpen
|
|
97
|
+
id: densityButtonId
|
|
99
98
|
}, rootProps.slotProps?.baseButton, buttonProps, {
|
|
99
|
+
onClick: handleDensitySelectorOpen,
|
|
100
100
|
ref: handleRef,
|
|
101
101
|
children: apiRef.current.getLocaleText('toolbarDensity')
|
|
102
102
|
}))
|
|
@@ -52,9 +52,9 @@ const GridToolbarExportContainer = forwardRef(function GridToolbarExportContaine
|
|
|
52
52
|
"aria-label": apiRef.current.getLocaleText('toolbarExportLabel'),
|
|
53
53
|
"aria-haspopup": "menu",
|
|
54
54
|
"aria-controls": open ? exportMenuId : undefined,
|
|
55
|
-
id: exportButtonId
|
|
56
|
-
onClick: handleMenuOpen
|
|
55
|
+
id: exportButtonId
|
|
57
56
|
}, rootProps.slotProps?.baseButton, buttonProps, {
|
|
57
|
+
onClick: handleMenuOpen,
|
|
58
58
|
ref: handleRef,
|
|
59
59
|
children: apiRef.current.getLocaleText('toolbarExport')
|
|
60
60
|
}))
|
|
@@ -109,14 +109,15 @@ const GridToolbarFilterButton = forwardRef(function GridToolbarFilterButton(prop
|
|
|
109
109
|
color: "primary"
|
|
110
110
|
}, rootProps.slotProps?.baseBadge, badgeProps, {
|
|
111
111
|
children: /*#__PURE__*/_jsx(rootProps.slots.openFilterButtonIcon, {})
|
|
112
|
-
}))
|
|
112
|
+
}))
|
|
113
|
+
}, rootProps.slotProps?.baseButton, buttonProps, {
|
|
113
114
|
onClick: toggleFilter,
|
|
114
115
|
onPointerUp: event => {
|
|
115
116
|
if (preferencePanel.open) {
|
|
116
117
|
event.stopPropagation();
|
|
117
118
|
}
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
buttonProps.onPointerUp?.(event);
|
|
120
|
+
},
|
|
120
121
|
ref: ref,
|
|
121
122
|
children: apiRef.current.getLocaleText('toolbarFilters')
|
|
122
123
|
}))
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { DataGridProcessedProps } from '../../models/props/DataGridProps';
|
|
3
|
+
import { GridLoadingOverlayVariant } from '../GridLoadingOverlay';
|
|
4
|
+
type OwnerState = Pick<DataGridProcessedProps, 'classes'> & {
|
|
5
|
+
hasScrollX: boolean;
|
|
6
|
+
hasPinnedRight: boolean;
|
|
7
|
+
loadingOverlayVariant: GridLoadingOverlayVariant | null;
|
|
8
|
+
};
|
|
2
9
|
export declare const GridMainContainer: React.ForwardRefExoticComponent<React.PropsWithChildren<{
|
|
3
10
|
className: string;
|
|
11
|
+
ownerState: OwnerState;
|
|
4
12
|
}>> | React.ForwardRefExoticComponent<{
|
|
5
13
|
className: string;
|
|
14
|
+
ownerState: OwnerState;
|
|
6
15
|
} & {
|
|
7
16
|
children?: React.ReactNode | undefined;
|
|
8
17
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
18
|
+
export {};
|
|
@@ -14,7 +14,12 @@ const GridPanelAnchor = styled('div')({
|
|
|
14
14
|
const Element = styled('div', {
|
|
15
15
|
name: 'MuiDataGrid',
|
|
16
16
|
slot: 'Main',
|
|
17
|
-
overridesResolver: (props, styles) =>
|
|
17
|
+
overridesResolver: (props, styles) => {
|
|
18
|
+
const {
|
|
19
|
+
ownerState
|
|
20
|
+
} = props;
|
|
21
|
+
return [styles.main, ownerState.hasPinnedRight && styles['main--hasPinnedRight'], ownerState.loadingOverlayVariant === 'skeleton' && styles['main--hasSkeletonLoadingOverlay']];
|
|
22
|
+
}
|
|
18
23
|
})({
|
|
19
24
|
flexGrow: 1,
|
|
20
25
|
position: 'relative',
|
|
@@ -23,11 +28,14 @@ const Element = styled('div', {
|
|
|
23
28
|
flexDirection: 'column'
|
|
24
29
|
});
|
|
25
30
|
export const GridMainContainer = forwardRef((props, ref) => {
|
|
31
|
+
const {
|
|
32
|
+
ownerState
|
|
33
|
+
} = props;
|
|
26
34
|
const rootProps = useGridRootProps();
|
|
27
35
|
const configuration = useGridConfiguration();
|
|
28
36
|
const ariaAttributes = configuration.hooks.useGridAriaAttributes();
|
|
29
37
|
return /*#__PURE__*/_jsxs(Element, _extends({
|
|
30
|
-
ownerState:
|
|
38
|
+
ownerState: ownerState,
|
|
31
39
|
className: props.className,
|
|
32
40
|
tabIndex: -1
|
|
33
41
|
}, ariaAttributes, rootProps.slotProps?.main, {
|
|
@@ -2,6 +2,10 @@ import * as React from 'react';
|
|
|
2
2
|
type Position = 'vertical' | 'horizontal';
|
|
3
3
|
type GridVirtualScrollbarProps = {
|
|
4
4
|
position: Position;
|
|
5
|
+
scrollPosition: React.RefObject<{
|
|
6
|
+
left: number;
|
|
7
|
+
top: number;
|
|
8
|
+
}>;
|
|
5
9
|
};
|
|
6
10
|
declare const GridVirtualScrollbar: React.ForwardRefExoticComponent<GridVirtualScrollbarProps> | React.ForwardRefExoticComponent<GridVirtualScrollbarProps & React.RefAttributes<HTMLDivElement>>;
|
|
7
11
|
export { GridVirtualScrollbar };
|
|
@@ -67,26 +67,27 @@ const GridVirtualScrollbar = forwardRef(function GridVirtualScrollbar(props, ref
|
|
|
67
67
|
const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
|
|
68
68
|
const propertyDimension = props.position === 'vertical' ? 'height' : 'width';
|
|
69
69
|
const propertyScroll = props.position === 'vertical' ? 'scrollTop' : 'scrollLeft';
|
|
70
|
+
const propertyScrollPosition = props.position === 'vertical' ? 'top' : 'left';
|
|
70
71
|
const hasScroll = props.position === 'vertical' ? dimensions.hasScrollX : dimensions.hasScrollY;
|
|
71
72
|
const contentSize = dimensions.minimumSize[propertyDimension] + (hasScroll ? dimensions.scrollbarSize : 0);
|
|
72
73
|
const scrollbarSize = props.position === 'vertical' ? dimensions.viewportInnerSize.height : dimensions.viewportOuterSize.width;
|
|
73
74
|
const scrollbarInnerSize = scrollbarSize * (contentSize / dimensions.viewportOuterSize[propertyDimension]);
|
|
74
75
|
const onScrollerScroll = useEventCallback(() => {
|
|
75
|
-
const scroller = apiRef.current.virtualScrollerRef.current;
|
|
76
76
|
const scrollbar = scrollbarRef.current;
|
|
77
|
+
const scrollPosition = props.scrollPosition.current;
|
|
77
78
|
if (!scrollbar) {
|
|
78
79
|
return;
|
|
79
80
|
}
|
|
80
|
-
if (
|
|
81
|
+
if (scrollPosition[propertyScrollPosition] === lastPosition.current) {
|
|
81
82
|
return;
|
|
82
83
|
}
|
|
83
|
-
lastPosition.current =
|
|
84
|
+
lastPosition.current = scrollPosition[propertyScrollPosition];
|
|
84
85
|
if (isLocked.current) {
|
|
85
86
|
isLocked.current = false;
|
|
86
87
|
return;
|
|
87
88
|
}
|
|
88
89
|
isLocked.current = true;
|
|
89
|
-
const value =
|
|
90
|
+
const value = scrollPosition[propertyScrollPosition] / contentSize;
|
|
90
91
|
scrollbar[propertyScroll] = value * scrollbarInnerSize;
|
|
91
92
|
});
|
|
92
93
|
const onScrollbarScroll = useEventCallback(() => {
|
|
@@ -107,7 +108,6 @@ const GridVirtualScrollbar = forwardRef(function GridVirtualScrollbar(props, ref
|
|
|
107
108
|
const scroller = apiRef.current.virtualScrollerRef.current;
|
|
108
109
|
const scrollbar = scrollbarRef.current;
|
|
109
110
|
const options = {
|
|
110
|
-
capture: true,
|
|
111
111
|
passive: true
|
|
112
112
|
};
|
|
113
113
|
scroller.addEventListener('scroll', onScrollerScroll, options);
|