@mui/x-data-grid 7.23.6 → 7.24.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 +150 -0
- package/DataGrid/DataGrid.js +4 -5
- package/DataGrid/useDataGridComponent.d.ts +2 -1
- package/DataGrid/useDataGridComponent.js +1 -1
- package/components/GridHeaders.js +2 -2
- package/components/GridRow.d.ts +5 -9
- package/components/GridRow.js +28 -105
- package/components/GridSkeletonLoadingOverlay.js +18 -18
- package/components/cell/GridCell.d.ts +9 -16
- package/components/cell/GridCell.js +17 -35
- package/components/columnHeaders/GridColumnGroupHeader.d.ts +5 -5
- package/components/columnHeaders/GridColumnGroupHeader.js +7 -10
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.d.ts +3 -3
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.js +21 -7
- package/components/columnHeaders/GridColumnHeaderItem.d.ts +5 -5
- package/components/columnHeaders/GridColumnHeaderItem.js +13 -12
- package/components/columnSelection/GridCellCheckboxRenderer.js +2 -2
- package/components/containers/GridRoot.d.ts +2 -2
- package/components/containers/GridRoot.js +14 -6
- package/components/containers/GridRootStyles.js +1 -0
- package/components/panel/GridPanel.js +2 -1
- package/components/panel/filterPanel/GridFilterInputValueProps.d.ts +2 -1
- package/components/toolbar/GridToolbarColumnsButton.js +6 -1
- package/components/toolbar/GridToolbarFilterButton.js +6 -1
- package/components/virtualization/GridVirtualScrollbar.js +11 -12
- package/components/virtualization/GridVirtualScroller.js +4 -4
- package/context/GridContextProvider.d.ts +2 -1
- package/hooks/core/pipeProcessing/useGridPipeProcessing.d.ts +2 -2
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +2 -2
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +2 -2
- package/hooks/core/strategyProcessing/useGridRegisterStrategyProcessor.d.ts +2 -2
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.d.ts +2 -2
- package/hooks/core/useGridApiInitialization.d.ts +2 -2
- package/hooks/core/useGridInitialization.d.ts +2 -2
- package/hooks/core/useGridIsRtl.d.ts +2 -2
- package/hooks/core/useGridLocaleText.d.ts +2 -2
- package/hooks/core/useGridLoggerFactory.d.ts +2 -2
- package/hooks/core/useGridRefs.d.ts +2 -2
- package/hooks/core/useGridStateInitialization.d.ts +2 -2
- package/hooks/features/clipboard/useGridClipboard.d.ts +2 -2
- package/hooks/features/columnGrouping/useGridColumnGrouping.d.ts +2 -2
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +5 -7
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +34 -76
- package/hooks/features/columnMenu/useGridColumnMenu.d.ts +2 -2
- package/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
- package/hooks/features/columnResize/useGridColumnResize.d.ts +2 -2
- package/hooks/features/columnResize/useGridColumnResize.js +4 -2
- package/hooks/features/columns/gridColumnsUtils.d.ts +4 -4
- package/hooks/features/columns/useGridColumnSpanning.d.ts +2 -2
- package/hooks/features/columns/useGridColumns.d.ts +2 -2
- package/hooks/features/density/useGridDensity.d.ts +2 -2
- package/hooks/features/dimensions/useGridDimensions.d.ts +2 -2
- package/hooks/features/dimensions/useGridDimensions.js +1 -3
- package/hooks/features/editing/useGridCellEditing.d.ts +2 -2
- package/hooks/features/editing/useGridEditing.d.ts +2 -2
- package/hooks/features/editing/useGridRowEditing.d.ts +2 -2
- package/hooks/features/events/useGridEvents.d.ts +2 -2
- package/hooks/features/export/serializers/csvSerializer.d.ts +2 -1
- package/hooks/features/export/useGridCsvExport.d.ts +2 -2
- package/hooks/features/export/useGridPrintExport.d.ts +2 -2
- package/hooks/features/export/utils.d.ts +2 -2
- package/hooks/features/filter/gridFilterSelector.js +6 -1
- package/hooks/features/filter/gridFilterUtils.d.ts +7 -7
- package/hooks/features/filter/gridFilterUtils.js +3 -3
- package/hooks/features/filter/useGridFilter.d.ts +2 -2
- package/hooks/features/focus/useGridFocus.d.ts +2 -2
- package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +2 -2
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +2 -2
- package/hooks/features/keyboardNavigation/utils.d.ts +3 -3
- package/hooks/features/listView/useGridListView.d.ts +2 -2
- package/hooks/features/pagination/gridPaginationInterfaces.d.ts +3 -0
- package/hooks/features/pagination/gridPaginationSelector.d.ts +20 -1
- package/hooks/features/pagination/gridPaginationSelector.js +39 -1
- package/hooks/features/pagination/useGridPagination.d.ts +3 -3
- package/hooks/features/pagination/useGridPagination.js +5 -3
- package/hooks/features/pagination/useGridPaginationMeta.d.ts +2 -2
- package/hooks/features/pagination/useGridPaginationModel.d.ts +2 -2
- package/hooks/features/pagination/useGridPaginationModel.js +23 -1
- package/hooks/features/pagination/useGridRowCount.d.ts +2 -2
- package/hooks/features/preferencesPanel/gridPreferencePanelSelector.d.ts +1 -0
- package/hooks/features/preferencesPanel/gridPreferencePanelSelector.js +8 -1
- package/hooks/features/preferencesPanel/index.d.ts +1 -1
- package/hooks/features/preferencesPanel/index.js +1 -1
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.ts +2 -2
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
- package/hooks/features/rowSelection/useGridRowSelection.d.ts +2 -2
- package/hooks/features/rowSelection/useGridRowSelectionPreProcessors.d.ts +2 -2
- package/hooks/features/rowSelection/utils.d.ts +3 -2
- package/hooks/features/rows/gridRowSpanningUtils.d.ts +2 -2
- package/hooks/features/rows/gridRowsSelector.js +1 -1
- package/hooks/features/rows/gridRowsUtils.d.ts +4 -4
- package/hooks/features/rows/useGridParamsApi.d.ts +2 -2
- package/hooks/features/rows/useGridRowSpanning.d.ts +2 -2
- package/hooks/features/rows/useGridRows.d.ts +2 -2
- package/hooks/features/rows/useGridRows.js +2 -2
- package/hooks/features/rows/useGridRowsMeta.d.ts +2 -2
- package/hooks/features/rows/useGridRowsPreProcessors.d.ts +2 -2
- package/hooks/features/scroll/useGridScroll.d.ts +2 -2
- package/hooks/features/sorting/gridSortingUtils.d.ts +3 -3
- package/hooks/features/sorting/gridSortingUtils.js +2 -2
- package/hooks/features/sorting/useGridSorting.d.ts +2 -2
- package/hooks/features/statePersistence/useGridStatePersistence.d.ts +2 -2
- package/hooks/features/virtualization/gridFocusedVirtualCellSelector.d.ts +6 -0
- package/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +42 -0
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +2 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +92 -50
- package/hooks/features/virtualization/useGridVirtualization.d.ts +2 -2
- package/hooks/utils/useGridApiContext.d.ts +2 -2
- package/hooks/utils/useGridApiEventHandler.d.ts +4 -4
- package/hooks/utils/useGridApiMethod.d.ts +2 -2
- package/hooks/utils/useGridApiRef.d.ts +2 -2
- package/hooks/utils/useGridApiRef.js +3 -1
- package/hooks/utils/useGridInitializeState.d.ts +3 -3
- package/hooks/utils/useGridLogger.d.ts +2 -2
- package/hooks/utils/useGridNativeEventListener.d.ts +2 -1
- package/hooks/utils/useGridPrivateApiContext.d.ts +2 -1
- package/hooks/utils/useGridSelector.d.ts +3 -3
- package/hooks/utils/useGridVisibleRows.d.ts +8 -6
- package/hooks/utils/useGridVisibleRows.js +5 -28
- package/index.js +1 -1
- package/internals/constants.d.ts +6 -0
- package/internals/constants.js +8 -1
- package/internals/index.d.ts +1 -0
- package/internals/index.js +1 -0
- package/internals/utils/attachPinnedStyle.d.ts +2 -0
- package/internals/utils/attachPinnedStyle.js +9 -0
- package/internals/utils/getPinnedCellOffset.d.ts +3 -3
- package/internals/utils/getPinnedCellOffset.js +6 -7
- package/internals/utils/index.d.ts +1 -0
- package/internals/utils/index.js +2 -1
- package/locales/faIR.js +5 -6
- package/locales/urPK.js +9 -10
- package/models/colDef/gridColDef.d.ts +9 -8
- package/models/events/gridEventLookup.d.ts +6 -1
- package/models/gridExport.d.ts +2 -2
- package/models/gridFilterOperator.d.ts +2 -1
- package/models/gridStateCommunity.d.ts +4 -0
- package/models/props/DataGridProps.d.ts +2 -1
- package/modern/DataGrid/DataGrid.js +4 -5
- package/modern/DataGrid/useDataGridComponent.js +1 -1
- package/modern/components/GridHeaders.js +2 -2
- package/modern/components/GridRow.js +28 -105
- package/modern/components/GridSkeletonLoadingOverlay.js +18 -18
- package/modern/components/cell/GridCell.js +17 -35
- package/modern/components/columnHeaders/GridColumnGroupHeader.js +7 -10
- package/modern/components/columnHeaders/GridColumnHeaderFilterIconButton.js +21 -7
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +13 -12
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +2 -2
- package/modern/components/containers/GridRoot.js +14 -6
- package/modern/components/containers/GridRootStyles.js +1 -0
- package/modern/components/panel/GridPanel.js +2 -1
- package/modern/components/toolbar/GridToolbarColumnsButton.js +6 -1
- package/modern/components/toolbar/GridToolbarFilterButton.js +6 -1
- package/modern/components/virtualization/GridVirtualScrollbar.js +11 -12
- package/modern/components/virtualization/GridVirtualScroller.js +4 -4
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +34 -76
- package/modern/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
- package/modern/hooks/features/columnResize/useGridColumnResize.js +4 -2
- package/modern/hooks/features/dimensions/useGridDimensions.js +1 -3
- package/modern/hooks/features/filter/gridFilterSelector.js +6 -1
- package/modern/hooks/features/filter/gridFilterUtils.js +3 -3
- package/modern/hooks/features/pagination/gridPaginationSelector.js +39 -1
- package/modern/hooks/features/pagination/useGridPagination.js +5 -3
- package/modern/hooks/features/pagination/useGridPaginationModel.js +23 -1
- package/modern/hooks/features/preferencesPanel/gridPreferencePanelSelector.js +8 -1
- package/modern/hooks/features/preferencesPanel/index.js +1 -1
- package/modern/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
- package/modern/hooks/features/rows/gridRowsSelector.js +1 -1
- package/modern/hooks/features/rows/useGridRows.js +2 -2
- package/modern/hooks/features/sorting/gridSortingUtils.js +2 -2
- package/modern/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +42 -0
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +92 -50
- package/modern/hooks/utils/useGridApiRef.js +3 -1
- package/modern/hooks/utils/useGridVisibleRows.js +5 -28
- package/modern/index.js +1 -1
- package/modern/internals/constants.js +8 -1
- package/modern/internals/index.js +1 -0
- package/modern/internals/utils/attachPinnedStyle.js +9 -0
- package/modern/internals/utils/getPinnedCellOffset.js +6 -7
- package/modern/internals/utils/index.js +2 -1
- package/modern/locales/faIR.js +5 -6
- package/modern/locales/urPK.js +9 -10
- package/modern/utils/cellBorderUtils.js +5 -5
- package/modern/utils/domUtils.js +7 -2
- package/modern/utils/isJSDOM.js +1 -0
- package/modern/utils/rtlFlipSide.js +22 -0
- package/node/DataGrid/DataGrid.js +2 -3
- package/node/DataGrid/useDataGridComponent.js +1 -1
- package/node/components/GridHeaders.js +2 -2
- package/node/components/GridRow.js +27 -104
- package/node/components/GridSkeletonLoadingOverlay.js +17 -17
- package/node/components/cell/GridCell.js +18 -36
- package/node/components/columnHeaders/GridColumnGroupHeader.js +7 -10
- package/node/components/columnHeaders/GridColumnHeaderFilterIconButton.js +20 -6
- package/node/components/columnHeaders/GridColumnHeaderItem.js +13 -12
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
- package/node/components/containers/GridRoot.js +14 -6
- package/node/components/containers/GridRootStyles.js +1 -0
- package/node/components/panel/GridPanel.js +2 -1
- package/node/components/toolbar/GridToolbarColumnsButton.js +6 -1
- package/node/components/toolbar/GridToolbarFilterButton.js +6 -1
- package/node/components/virtualization/GridVirtualScrollbar.js +11 -12
- package/node/components/virtualization/GridVirtualScroller.js +4 -4
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +32 -74
- package/node/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
- package/node/hooks/features/columnResize/useGridColumnResize.js +4 -2
- package/node/hooks/features/dimensions/useGridDimensions.js +3 -5
- package/node/hooks/features/filter/gridFilterSelector.js +6 -1
- package/node/hooks/features/filter/gridFilterUtils.js +3 -3
- package/node/hooks/features/pagination/gridPaginationSelector.js +41 -3
- package/node/hooks/features/pagination/useGridPagination.js +5 -3
- package/node/hooks/features/pagination/useGridPaginationModel.js +23 -1
- package/node/hooks/features/preferencesPanel/gridPreferencePanelSelector.js +9 -2
- package/node/hooks/features/preferencesPanel/index.js +11 -10
- package/node/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
- package/node/hooks/features/rows/gridRowsSelector.js +1 -1
- package/node/hooks/features/rows/useGridRows.js +1 -1
- package/node/hooks/features/sorting/gridSortingUtils.js +2 -2
- package/node/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +49 -0
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +94 -52
- package/node/hooks/utils/useGridApiRef.js +3 -1
- package/node/hooks/utils/useGridVisibleRows.js +3 -28
- package/node/index.js +1 -1
- package/node/internals/constants.js +9 -2
- package/node/internals/index.js +12 -0
- package/node/internals/utils/attachPinnedStyle.js +15 -0
- package/node/internals/utils/getPinnedCellOffset.js +6 -7
- package/node/internals/utils/index.js +11 -0
- package/node/locales/faIR.js +5 -6
- package/node/locales/urPK.js +9 -10
- package/node/utils/cellBorderUtils.js +5 -5
- package/node/utils/domUtils.js +7 -2
- package/node/utils/isJSDOM.js +7 -0
- package/node/utils/rtlFlipSide.js +29 -0
- package/package.json +2 -2
- package/utils/cellBorderUtils.d.ts +3 -3
- package/utils/cellBorderUtils.js +5 -5
- package/utils/createSelector.d.ts +3 -3
- package/utils/domUtils.js +7 -2
- package/utils/getPublicApiRef.d.ts +2 -1
- package/utils/isJSDOM.d.ts +1 -0
- package/utils/isJSDOM.js +1 -0
- package/utils/rtlFlipSide.d.ts +2 -0
- package/utils/rtlFlipSide.js +22 -0
|
@@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { unstable_composeClasses as composeClasses, unstable_useId as useId } from '@mui/utils';
|
|
6
6
|
import { fastMemo } from '@mui/x-internals/fastMemo';
|
|
7
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
7
8
|
import { useGridPrivateApiContext } from "../../hooks/utils/useGridPrivateApiContext.js";
|
|
8
9
|
import { ColumnHeaderMenuIcon } from "./ColumnHeaderMenuIcon.js";
|
|
9
10
|
import { GridColumnHeaderMenu } from "../menu/columnMenu/GridColumnHeaderMenu.js";
|
|
@@ -11,7 +12,8 @@ import { gridClasses, getDataGridUtilityClass } from "../../constants/gridClasse
|
|
|
11
12
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
12
13
|
import { GridGenericColumnHeaderItem } from "./GridGenericColumnHeaderItem.js";
|
|
13
14
|
import { isEventTargetInPortal } from "../../utils/domUtils.js";
|
|
14
|
-
import {
|
|
15
|
+
import { PinnedColumnPosition } from "../../internals/constants.js";
|
|
16
|
+
import { attachPinnedStyle } from "../../internals/utils/index.js";
|
|
15
17
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
18
|
const useUtilityClasses = ownerState => {
|
|
17
19
|
const {
|
|
@@ -31,7 +33,7 @@ const useUtilityClasses = ownerState => {
|
|
|
31
33
|
// todo refactor to a prop on col isNumeric or ?? ie: coltype===price wont work
|
|
32
34
|
const isColumnNumeric = colDef.type === 'number';
|
|
33
35
|
const slots = {
|
|
34
|
-
root: ['columnHeader', colDef.headerAlign === 'left' && 'columnHeader--alignLeft', colDef.headerAlign === 'center' && 'columnHeader--alignCenter', colDef.headerAlign === 'right' && 'columnHeader--alignRight', colDef.sortable && 'columnHeader--sortable', isDragging && 'columnHeader--moving', isColumnSorted && 'columnHeader--sorted', isColumnFiltered && 'columnHeader--filtered', isColumnNumeric && 'columnHeader--numeric', 'withBorderColor', showRightBorder && 'columnHeader--withRightBorder', showLeftBorder && 'columnHeader--withLeftBorder', pinnedPosition ===
|
|
36
|
+
root: ['columnHeader', colDef.headerAlign === 'left' && 'columnHeader--alignLeft', colDef.headerAlign === 'center' && 'columnHeader--alignCenter', colDef.headerAlign === 'right' && 'columnHeader--alignRight', colDef.sortable && 'columnHeader--sortable', isDragging && 'columnHeader--moving', isColumnSorted && 'columnHeader--sorted', isColumnFiltered && 'columnHeader--filtered', isColumnNumeric && 'columnHeader--numeric', 'withBorderColor', showRightBorder && 'columnHeader--withRightBorder', showLeftBorder && 'columnHeader--withLeftBorder', pinnedPosition === PinnedColumnPosition.LEFT && 'columnHeader--pinnedLeft', pinnedPosition === PinnedColumnPosition.RIGHT && 'columnHeader--pinnedRight',
|
|
35
37
|
// TODO: Remove classes below and restore `:has` selectors when they are supported in jsdom
|
|
36
38
|
// See https://github.com/mui/mui-x/pull/14559
|
|
37
39
|
isLastUnpinned && 'columnHeader--lastUnpinned', isSiblingFocused && 'columnHeader--siblingFocused'],
|
|
@@ -56,14 +58,14 @@ function GridColumnHeaderItem(props) {
|
|
|
56
58
|
tabIndex,
|
|
57
59
|
disableReorder,
|
|
58
60
|
separatorSide,
|
|
59
|
-
|
|
61
|
+
showLeftBorder,
|
|
62
|
+
showRightBorder,
|
|
60
63
|
pinnedPosition,
|
|
61
|
-
|
|
62
|
-
sectionLength,
|
|
63
|
-
gridHasFiller
|
|
64
|
+
pinnedOffset
|
|
64
65
|
} = props;
|
|
65
66
|
const apiRef = useGridPrivateApiContext();
|
|
66
67
|
const rootProps = useGridRootProps();
|
|
68
|
+
const isRtl = useRtl();
|
|
67
69
|
const headerCellRef = React.useRef(null);
|
|
68
70
|
const columnMenuId = useId();
|
|
69
71
|
const columnMenuButtonId = useId();
|
|
@@ -74,8 +76,6 @@ function GridColumnHeaderItem(props) {
|
|
|
74
76
|
if (colDef.renderHeader) {
|
|
75
77
|
headerComponent = colDef.renderHeader(apiRef.current.getColumnHeaderParams(colDef.field));
|
|
76
78
|
}
|
|
77
|
-
const showLeftBorder = shouldCellShowLeftBorder(pinnedPosition, indexInSection);
|
|
78
|
-
const showRightBorder = shouldCellShowRightBorder(pinnedPosition, indexInSection, sectionLength, rootProps.showColumnVerticalBorder, gridHasFiller);
|
|
79
79
|
const ownerState = _extends({}, props, {
|
|
80
80
|
classes: rootProps.classes,
|
|
81
81
|
showRightBorder,
|
|
@@ -171,6 +171,7 @@ function GridColumnHeaderItem(props) {
|
|
|
171
171
|
colDef
|
|
172
172
|
}) : colDef.headerClassName;
|
|
173
173
|
const label = colDef.headerName ?? colDef.field;
|
|
174
|
+
const style = React.useMemo(() => attachPinnedStyle(_extends({}, props.style), isRtl, pinnedPosition, pinnedOffset), [pinnedPosition, pinnedOffset, props.style, isRtl]);
|
|
174
175
|
return /*#__PURE__*/_jsx(GridGenericColumnHeaderItem, _extends({
|
|
175
176
|
ref: headerCellRef,
|
|
176
177
|
classes: classes,
|
|
@@ -209,18 +210,18 @@ process.env.NODE_ENV !== "production" ? GridColumnHeaderItem.propTypes = {
|
|
|
209
210
|
columnMenuOpen: PropTypes.bool.isRequired,
|
|
210
211
|
disableReorder: PropTypes.bool,
|
|
211
212
|
filterItemsCounter: PropTypes.number,
|
|
212
|
-
gridHasFiller: PropTypes.bool.isRequired,
|
|
213
213
|
hasFocus: PropTypes.bool,
|
|
214
214
|
headerHeight: PropTypes.number.isRequired,
|
|
215
|
-
indexInSection: PropTypes.number.isRequired,
|
|
216
215
|
isDragging: PropTypes.bool.isRequired,
|
|
217
216
|
isLast: PropTypes.bool.isRequired,
|
|
218
217
|
isLastUnpinned: PropTypes.bool.isRequired,
|
|
219
218
|
isResizing: PropTypes.bool.isRequired,
|
|
220
219
|
isSiblingFocused: PropTypes.bool.isRequired,
|
|
221
|
-
|
|
222
|
-
|
|
220
|
+
pinnedOffset: PropTypes.number,
|
|
221
|
+
pinnedPosition: PropTypes.oneOf([0, 1, 2, 3]),
|
|
223
222
|
separatorSide: PropTypes.oneOf(['left', 'right']),
|
|
223
|
+
showLeftBorder: PropTypes.bool.isRequired,
|
|
224
|
+
showRightBorder: PropTypes.bool.isRequired,
|
|
224
225
|
sortDirection: PropTypes.oneOf(['asc', 'desc']),
|
|
225
226
|
sortIndex: PropTypes.number,
|
|
226
227
|
style: PropTypes.object,
|
|
@@ -8,7 +8,7 @@ import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
|
8
8
|
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
9
9
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
10
10
|
import { getDataGridUtilityClass } from "../../constants/gridClasses.js";
|
|
11
|
-
import { useGridSelector } from "../../hooks/utils/useGridSelector.js";
|
|
11
|
+
import { objectShallowCompare, useGridSelector } from "../../hooks/utils/useGridSelector.js";
|
|
12
12
|
import { getCheckboxPropsSelector } from "../../hooks/features/rowSelection/utils.js";
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
const useUtilityClasses = ownerState => {
|
|
@@ -76,7 +76,7 @@ const GridCellCheckboxForwardRef = forwardRef(function GridCellCheckboxRenderer(
|
|
|
76
76
|
const {
|
|
77
77
|
isIndeterminate,
|
|
78
78
|
isChecked
|
|
79
|
-
} = useGridSelector(apiRef, checkboxPropsSelector);
|
|
79
|
+
} = useGridSelector(apiRef, checkboxPropsSelector, objectShallowCompare);
|
|
80
80
|
if (rowNode.type === 'footer' || rowNode.type === 'pinnedRow') {
|
|
81
81
|
return null;
|
|
82
82
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["className"];
|
|
3
|
+
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
7
|
import { unstable_useForkRef as useForkRef, unstable_useEnhancedEffect as useEnhancedEffect, unstable_capitalize as capitalize, unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
8
|
+
import { fastMemo } from '@mui/x-internals/fastMemo';
|
|
8
9
|
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
9
10
|
import { GridRootStyles } from "./GridRootStyles.js";
|
|
10
11
|
import { useGridSelector } from "../../hooks/utils/useGridSelector.js";
|
|
@@ -12,7 +13,9 @@ import { useGridPrivateApiContext } from "../../hooks/utils/useGridPrivateApiCon
|
|
|
12
13
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
13
14
|
import { getDataGridUtilityClass } from "../../constants/gridClasses.js";
|
|
14
15
|
import { gridDensitySelector } from "../../hooks/features/density/densitySelector.js";
|
|
15
|
-
import {
|
|
16
|
+
import { GridHeader } from "../GridHeader.js";
|
|
17
|
+
import { GridBody, GridFooterPlaceholder } from "../base/index.js";
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
19
|
const useUtilityClasses = (ownerState, density) => {
|
|
17
20
|
const {
|
|
18
21
|
autoHeight,
|
|
@@ -27,7 +30,8 @@ const useUtilityClasses = (ownerState, density) => {
|
|
|
27
30
|
const GridRoot = forwardRef(function GridRoot(props, ref) {
|
|
28
31
|
const rootProps = useGridRootProps();
|
|
29
32
|
const {
|
|
30
|
-
className
|
|
33
|
+
className,
|
|
34
|
+
children
|
|
31
35
|
} = props,
|
|
32
36
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
33
37
|
const apiRef = useGridPrivateApiContext();
|
|
@@ -45,11 +49,14 @@ const GridRoot = forwardRef(function GridRoot(props, ref) {
|
|
|
45
49
|
if (!mountedState) {
|
|
46
50
|
return null;
|
|
47
51
|
}
|
|
48
|
-
return /*#__PURE__*/
|
|
52
|
+
return /*#__PURE__*/_jsxs(GridRootStyles, _extends({
|
|
49
53
|
className: clsx(classes.root, className),
|
|
50
54
|
ownerState: ownerState
|
|
51
55
|
}, other, {
|
|
52
|
-
ref: handleRef
|
|
56
|
+
ref: handleRef,
|
|
57
|
+
children: [/*#__PURE__*/_jsx(GridHeader, {}), /*#__PURE__*/_jsx(GridBody, {
|
|
58
|
+
children: children
|
|
59
|
+
}), /*#__PURE__*/_jsx(GridFooterPlaceholder, {})]
|
|
53
60
|
}));
|
|
54
61
|
});
|
|
55
62
|
process.env.NODE_ENV !== "production" ? GridRoot.propTypes = {
|
|
@@ -62,4 +69,5 @@ process.env.NODE_ENV !== "production" ? GridRoot.propTypes = {
|
|
|
62
69
|
*/
|
|
63
70
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
64
71
|
} : void 0;
|
|
65
|
-
|
|
72
|
+
const MemoizedGridRoot = fastMemo(GridRoot);
|
|
73
|
+
export { MemoizedGridRoot as GridRoot };
|
|
@@ -91,7 +91,8 @@ const GridPanel = forwardRef((props, ref) => {
|
|
|
91
91
|
}, other, {
|
|
92
92
|
ref: ref,
|
|
93
93
|
children: /*#__PURE__*/_jsx(ClickAwayListener, {
|
|
94
|
-
mouseEvent: "
|
|
94
|
+
mouseEvent: "onPointerUp",
|
|
95
|
+
touchEvent: false,
|
|
95
96
|
onClickAway: handleClickAway,
|
|
96
97
|
children: /*#__PURE__*/_jsx(GridPaperRoot, {
|
|
97
98
|
className: classes.paper,
|
|
@@ -46,7 +46,12 @@ const GridToolbarColumnsButton = forwardRef(function GridToolbarColumnsButton(pr
|
|
|
46
46
|
"aria-expanded": isOpen,
|
|
47
47
|
"aria-controls": isOpen ? columnPanelId : undefined,
|
|
48
48
|
startIcon: /*#__PURE__*/_jsx(rootProps.slots.columnSelectorIcon, {}),
|
|
49
|
-
onClick: showColumns
|
|
49
|
+
onClick: showColumns,
|
|
50
|
+
onPointerUp: event => {
|
|
51
|
+
if (preferencePanel.open) {
|
|
52
|
+
event.stopPropagation();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
50
55
|
}, rootProps.slotProps?.baseButton, buttonProps, {
|
|
51
56
|
ref: ref,
|
|
52
57
|
children: apiRef.current.getLocaleText('toolbarColumns')
|
|
@@ -110,7 +110,12 @@ const GridToolbarFilterButton = forwardRef(function GridToolbarFilterButton(prop
|
|
|
110
110
|
}, rootProps.slotProps?.baseBadge, badgeProps, {
|
|
111
111
|
children: /*#__PURE__*/_jsx(rootProps.slots.openFilterButtonIcon, {})
|
|
112
112
|
})),
|
|
113
|
-
onClick: toggleFilter
|
|
113
|
+
onClick: toggleFilter,
|
|
114
|
+
onPointerUp: event => {
|
|
115
|
+
if (preferencePanel.open) {
|
|
116
|
+
event.stopPropagation();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
114
119
|
}, rootProps.slotProps?.baseButton, buttonProps, {
|
|
115
120
|
ref: ref,
|
|
116
121
|
children: apiRef.current.getLocaleText('toolbarFilters')
|
|
@@ -22,6 +22,9 @@ const Scrollbar = styled('div')({
|
|
|
22
22
|
position: 'absolute',
|
|
23
23
|
display: 'inline-block',
|
|
24
24
|
zIndex: 6,
|
|
25
|
+
'&:hover': {
|
|
26
|
+
zIndex: 7
|
|
27
|
+
},
|
|
25
28
|
// In macOS Safari and Gnome Web, scrollbars are overlaid and don't affect the layout. So we consider
|
|
26
29
|
// their size to be 0px throughout all the calculations, but the floating scrollbar container does need
|
|
27
30
|
// to appear and have a real size. We set it to 14px because it seems like an acceptable value and we
|
|
@@ -103,19 +106,15 @@ const GridVirtualScrollbar = forwardRef(function GridVirtualScrollbar(props, ref
|
|
|
103
106
|
useOnMount(() => {
|
|
104
107
|
const scroller = apiRef.current.virtualScrollerRef.current;
|
|
105
108
|
const scrollbar = scrollbarRef.current;
|
|
106
|
-
|
|
107
|
-
capture: true
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
const options = {
|
|
110
|
+
capture: true,
|
|
111
|
+
passive: true
|
|
112
|
+
};
|
|
113
|
+
scroller.addEventListener('scroll', onScrollerScroll, options);
|
|
114
|
+
scrollbar.addEventListener('scroll', onScrollbarScroll, options);
|
|
112
115
|
return () => {
|
|
113
|
-
scroller.removeEventListener('scroll', onScrollerScroll,
|
|
114
|
-
|
|
115
|
-
});
|
|
116
|
-
scrollbar.removeEventListener('scroll', onScrollbarScroll, {
|
|
117
|
-
capture: true
|
|
118
|
-
});
|
|
116
|
+
scroller.removeEventListener('scroll', onScrollerScroll, options);
|
|
117
|
+
scrollbar.removeEventListener('scroll', onScrollbarScroll, options);
|
|
119
118
|
};
|
|
120
119
|
});
|
|
121
120
|
React.useEffect(() => {
|
|
@@ -98,11 +98,11 @@ function GridVirtualScroller(props) {
|
|
|
98
98
|
virtualScroller: virtualScroller
|
|
99
99
|
})
|
|
100
100
|
})]
|
|
101
|
-
})), dimensions.
|
|
102
|
-
position: "vertical"
|
|
103
|
-
}, getScrollbarVerticalProps())), dimensions.hasScrollX && !rootProps.unstable_listView && /*#__PURE__*/_jsx(Scrollbar, _extends({
|
|
101
|
+
})), dimensions.hasScrollX && !rootProps.unstable_listView && /*#__PURE__*/_jsx(Scrollbar, _extends({
|
|
104
102
|
position: "horizontal"
|
|
105
|
-
}, getScrollbarHorizontalProps())),
|
|
103
|
+
}, getScrollbarHorizontalProps())), dimensions.hasScrollY && /*#__PURE__*/_jsx(Scrollbar, _extends({
|
|
104
|
+
position: "vertical"
|
|
105
|
+
}, getScrollbarVerticalProps())), props.children]
|
|
106
106
|
}));
|
|
107
107
|
}
|
|
108
108
|
export { GridVirtualScroller };
|
|
@@ -2,22 +2,23 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
|
-
import { useRtl } from '@mui/system/RtlProvider';
|
|
6
5
|
import { useGridSelector } from "../../utils/index.js";
|
|
7
6
|
import { useGridRootProps } from "../../utils/useGridRootProps.js";
|
|
8
7
|
import { useGridPrivateApiContext } from "../../utils/useGridPrivateApiContext.js";
|
|
9
8
|
import { useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
|
|
10
9
|
import { GridColumnHeaderItem } from "../../../components/columnHeaders/GridColumnHeaderItem.js";
|
|
11
10
|
import { gridDimensionsSelector } from "../dimensions/index.js";
|
|
12
|
-
import { gridRenderContextColumnsSelector
|
|
11
|
+
import { gridRenderContextColumnsSelector } from "../virtualization/index.js";
|
|
13
12
|
import { computeOffsetLeft } from "../virtualization/useGridVirtualScroller.js";
|
|
14
13
|
import { GridColumnGroupHeader } from "../../../components/columnHeaders/GridColumnGroupHeader.js";
|
|
15
|
-
import {
|
|
14
|
+
import { gridColumnPositionsSelector, gridVisiblePinnedColumnDefinitionsSelector, gridColumnLookupSelector } from "../columns/index.js";
|
|
16
15
|
import { gridColumnGroupsUnwrappedModelSelector } from "../columnGrouping/gridColumnGroupsSelector.js";
|
|
17
16
|
import { GridScrollbarFillerCell as ScrollbarFiller } from "../../../components/GridScrollbarFillerCell.js";
|
|
18
17
|
import { getPinnedCellOffset } from "../../../internals/utils/getPinnedCellOffset.js";
|
|
19
18
|
import { GridColumnHeaderSeparatorSides } from "../../../components/columnHeaders/GridColumnHeaderSeparator.js";
|
|
20
19
|
import { gridClasses } from "../../../constants/gridClasses.js";
|
|
20
|
+
import { shouldCellShowLeftBorder, shouldCellShowRightBorder } from "../../../utils/cellBorderUtils.js";
|
|
21
|
+
import { PinnedColumnPosition } from "../../../internals/constants.js";
|
|
21
22
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
23
|
export const GridColumnHeaderRow = styled('div', {
|
|
23
24
|
name: 'MuiDataGrid',
|
|
@@ -44,10 +45,8 @@ export const useGridColumnHeaders = props => {
|
|
|
44
45
|
const [dragCol, setDragCol] = React.useState('');
|
|
45
46
|
const [resizeCol, setResizeCol] = React.useState('');
|
|
46
47
|
const apiRef = useGridPrivateApiContext();
|
|
47
|
-
const isRtl = useRtl();
|
|
48
48
|
const rootProps = useGridRootProps();
|
|
49
49
|
const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
|
|
50
|
-
const hasColumnVirtualization = useGridSelector(apiRef, gridVirtualizationColumnEnabledSelector);
|
|
51
50
|
const columnGroupsModel = useGridSelector(apiRef, gridColumnGroupsUnwrappedModelSelector);
|
|
52
51
|
const columnPositions = useGridSelector(apiRef, gridColumnPositionsSelector);
|
|
53
52
|
const renderContext = useGridSelector(apiRef, gridRenderContextColumnsSelector);
|
|
@@ -84,18 +83,10 @@ export const useGridColumnHeaders = props => {
|
|
|
84
83
|
// Helper for computation common between getColumnHeaders and getColumnGroupHeaders
|
|
85
84
|
const getColumnsToRender = params => {
|
|
86
85
|
const {
|
|
87
|
-
renderContext: currentContext = renderContext
|
|
88
|
-
maxLastColumn = visibleColumns.length
|
|
86
|
+
renderContext: currentContext = renderContext
|
|
89
87
|
} = params || {};
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (!rootProps.disableVirtualization && !hasColumnVirtualization) {
|
|
93
|
-
firstColumnToRender = 0;
|
|
94
|
-
lastColumnToRender = maxLastColumn;
|
|
95
|
-
} else {
|
|
96
|
-
firstColumnToRender = currentContext.firstColumnIndex;
|
|
97
|
-
lastColumnToRender = currentContext.lastColumnIndex;
|
|
98
|
-
}
|
|
88
|
+
const firstColumnToRender = currentContext.firstColumnIndex;
|
|
89
|
+
const lastColumnToRender = currentContext.lastColumnIndex;
|
|
99
90
|
const renderedColumns = visibleColumns.slice(firstColumnToRender, lastColumnToRender);
|
|
100
91
|
return {
|
|
101
92
|
renderedColumns,
|
|
@@ -104,7 +95,7 @@ export const useGridColumnHeaders = props => {
|
|
|
104
95
|
};
|
|
105
96
|
};
|
|
106
97
|
const getFillers = (params, children, leftOverflow, borderBottom = false) => {
|
|
107
|
-
const isPinnedRight = params?.position ===
|
|
98
|
+
const isPinnedRight = params?.position === PinnedColumnPosition.RIGHT;
|
|
108
99
|
const isNotPinned = params?.position === undefined;
|
|
109
100
|
const hasScrollbarFiller = pinnedColumns.right.length > 0 && isPinnedRight || pinnedColumns.right.length === 0 && isNotPinned;
|
|
110
101
|
const leftOffsetWidth = offsetLeft - leftOverflow;
|
|
@@ -125,33 +116,6 @@ export const useGridColumnHeaders = props => {
|
|
|
125
116
|
})]
|
|
126
117
|
});
|
|
127
118
|
};
|
|
128
|
-
const getCellOffsetStyle = ({
|
|
129
|
-
pinnedPosition,
|
|
130
|
-
columnIndex,
|
|
131
|
-
computedWidth
|
|
132
|
-
}) => {
|
|
133
|
-
let style;
|
|
134
|
-
const isLeftPinned = pinnedPosition === GridPinnedColumnPosition.LEFT;
|
|
135
|
-
const isRightPinned = pinnedPosition === GridPinnedColumnPosition.RIGHT;
|
|
136
|
-
if (isLeftPinned || isRightPinned) {
|
|
137
|
-
const pinnedOffset = getPinnedCellOffset(pinnedPosition, computedWidth, columnIndex, columnPositions, dimensions);
|
|
138
|
-
let side = isLeftPinned ? 'left' : 'right';
|
|
139
|
-
if (isRtl) {
|
|
140
|
-
side = isLeftPinned ? 'right' : 'left';
|
|
141
|
-
}
|
|
142
|
-
if (pinnedPosition === 'left') {
|
|
143
|
-
style = {
|
|
144
|
-
[side]: pinnedOffset
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
if (pinnedPosition === 'right') {
|
|
148
|
-
style = {
|
|
149
|
-
[side]: pinnedOffset
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return style;
|
|
154
|
-
};
|
|
155
119
|
const getColumnHeaders = (params, other = {}) => {
|
|
156
120
|
const {
|
|
157
121
|
renderedColumns,
|
|
@@ -166,14 +130,15 @@ export const useGridColumnHeaders = props => {
|
|
|
166
130
|
const hasFocus = columnHeaderFocus !== null && columnHeaderFocus.field === colDef.field;
|
|
167
131
|
const open = columnMenuState.open && columnMenuState.field === colDef.field;
|
|
168
132
|
const pinnedPosition = params?.position;
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
computedWidth: colDef.computedWidth
|
|
173
|
-
});
|
|
174
|
-
const siblingWithBorderingSeparator = pinnedPosition === GridPinnedColumnPosition.RIGHT ? renderedColumns[i - 1] : renderedColumns[i + 1];
|
|
133
|
+
const scrollbarWidth = dimensions.hasScrollY ? dimensions.scrollbarSize : 0;
|
|
134
|
+
const pinnedOffset = getPinnedCellOffset(pinnedPosition, colDef.computedWidth, columnIndex, columnPositions, dimensions.columnsTotalWidth, scrollbarWidth);
|
|
135
|
+
const siblingWithBorderingSeparator = pinnedPosition === PinnedColumnPosition.RIGHT ? renderedColumns[i - 1] : renderedColumns[i + 1];
|
|
175
136
|
const isSiblingFocused = siblingWithBorderingSeparator ? columnHeaderFocus !== null && columnHeaderFocus.field === siblingWithBorderingSeparator.field : false;
|
|
176
137
|
const isLastUnpinned = columnIndex + 1 === columnPositions.length - pinnedColumns.right.length;
|
|
138
|
+
const indexInSection = i;
|
|
139
|
+
const sectionLength = renderedColumns.length;
|
|
140
|
+
const showLeftBorder = shouldCellShowLeftBorder(pinnedPosition, indexInSection);
|
|
141
|
+
const showRightBorder = shouldCellShowRightBorder(pinnedPosition, indexInSection, sectionLength, rootProps.showCellVerticalBorder, gridHasFiller);
|
|
177
142
|
columns.push(/*#__PURE__*/_jsx(GridColumnHeaderItem, _extends({}, sortColumnLookup[colDef.field], {
|
|
178
143
|
columnMenuOpen: open,
|
|
179
144
|
filterItemsCounter: filterColumnLookup[colDef.field] && filterColumnLookup[colDef.field].length,
|
|
@@ -186,12 +151,11 @@ export const useGridColumnHeaders = props => {
|
|
|
186
151
|
hasFocus: hasFocus,
|
|
187
152
|
tabIndex: tabIndex,
|
|
188
153
|
pinnedPosition: pinnedPosition,
|
|
189
|
-
|
|
190
|
-
indexInSection: i,
|
|
191
|
-
sectionLength: renderedColumns.length,
|
|
192
|
-
gridHasFiller: gridHasFiller,
|
|
154
|
+
pinnedOffset: pinnedOffset,
|
|
193
155
|
isLastUnpinned: isLastUnpinned,
|
|
194
|
-
isSiblingFocused: isSiblingFocused
|
|
156
|
+
isSiblingFocused: isSiblingFocused,
|
|
157
|
+
showLeftBorder: showLeftBorder,
|
|
158
|
+
showRightBorder: showRightBorder
|
|
195
159
|
}, other), colDef.field));
|
|
196
160
|
}
|
|
197
161
|
return getFillers(params, columns, 0);
|
|
@@ -203,18 +167,15 @@ export const useGridColumnHeaders = props => {
|
|
|
203
167
|
ownerState: rootProps,
|
|
204
168
|
className: gridClasses['row--borderBottom'],
|
|
205
169
|
children: [leftRenderContext && getColumnHeaders({
|
|
206
|
-
position:
|
|
207
|
-
renderContext: leftRenderContext
|
|
208
|
-
maxLastColumn: leftRenderContext.lastColumnIndex
|
|
170
|
+
position: PinnedColumnPosition.LEFT,
|
|
171
|
+
renderContext: leftRenderContext
|
|
209
172
|
}, {
|
|
210
173
|
disableReorder: true
|
|
211
174
|
}), getColumnHeaders({
|
|
212
|
-
renderContext
|
|
213
|
-
maxLastColumn: visibleColumns.length - pinnedColumns.right.length
|
|
175
|
+
renderContext
|
|
214
176
|
}), rightRenderContext && getColumnHeaders({
|
|
215
|
-
position:
|
|
216
|
-
renderContext: rightRenderContext
|
|
217
|
-
maxLastColumn: rightRenderContext.lastColumnIndex
|
|
177
|
+
position: PinnedColumnPosition.RIGHT,
|
|
178
|
+
renderContext: rightRenderContext
|
|
218
179
|
}, {
|
|
219
180
|
disableReorder: true,
|
|
220
181
|
separatorSide: GridColumnHeaderSeparatorSides.Left
|
|
@@ -273,14 +234,11 @@ export const useGridColumnHeaders = props => {
|
|
|
273
234
|
tabIndex
|
|
274
235
|
};
|
|
275
236
|
const pinnedPosition = params.position;
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
columnIndex,
|
|
279
|
-
computedWidth: headerInfo.width
|
|
280
|
-
});
|
|
237
|
+
const scrollbarWidth = dimensions.hasScrollY ? dimensions.scrollbarSize : 0;
|
|
238
|
+
const pinnedOffset = getPinnedCellOffset(pinnedPosition, headerInfo.width, columnIndex, columnPositions, dimensions.columnsTotalWidth, scrollbarWidth);
|
|
281
239
|
columnIndex += columnFields.length;
|
|
282
240
|
let indexInSection = index;
|
|
283
|
-
if (pinnedPosition ===
|
|
241
|
+
if (pinnedPosition === PinnedColumnPosition.LEFT) {
|
|
284
242
|
// Group headers can expand to multiple columns, we need to adjust the index
|
|
285
243
|
indexInSection = columnIndex - 1;
|
|
286
244
|
}
|
|
@@ -296,10 +254,9 @@ export const useGridColumnHeaders = props => {
|
|
|
296
254
|
hasFocus: hasFocus,
|
|
297
255
|
tabIndex: tabIndex,
|
|
298
256
|
pinnedPosition: pinnedPosition,
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
gridHasFiller: gridHasFiller
|
|
257
|
+
pinnedOffset: pinnedOffset,
|
|
258
|
+
showLeftBorder: shouldCellShowLeftBorder(pinnedPosition, indexInSection),
|
|
259
|
+
showRightBorder: shouldCellShowRightBorder(pinnedPosition, indexInSection, visibleColumnGroupHeader.length, rootProps.showCellVerticalBorder, gridHasFiller)
|
|
303
260
|
}, index);
|
|
304
261
|
});
|
|
305
262
|
return getFillers(params, children, leftOverflow);
|
|
@@ -317,7 +274,7 @@ export const useGridColumnHeaders = props => {
|
|
|
317
274
|
children: [leftRenderContext && getColumnGroupHeaders({
|
|
318
275
|
depth,
|
|
319
276
|
params: {
|
|
320
|
-
position:
|
|
277
|
+
position: PinnedColumnPosition.LEFT,
|
|
321
278
|
renderContext: leftRenderContext,
|
|
322
279
|
maxLastColumn: leftRenderContext.lastColumnIndex
|
|
323
280
|
}
|
|
@@ -329,7 +286,7 @@ export const useGridColumnHeaders = props => {
|
|
|
329
286
|
}), rightRenderContext && getColumnGroupHeaders({
|
|
330
287
|
depth,
|
|
331
288
|
params: {
|
|
332
|
-
position:
|
|
289
|
+
position: PinnedColumnPosition.RIGHT,
|
|
333
290
|
renderContext: rightRenderContext,
|
|
334
291
|
maxLastColumn: rightRenderContext.lastColumnIndex
|
|
335
292
|
}
|
|
@@ -344,11 +301,12 @@ export const useGridColumnHeaders = props => {
|
|
|
344
301
|
rightRenderContext,
|
|
345
302
|
pinnedColumns,
|
|
346
303
|
visibleColumns,
|
|
347
|
-
|
|
304
|
+
columnPositions,
|
|
348
305
|
getFillers,
|
|
349
306
|
getColumnHeadersRow,
|
|
350
307
|
getColumnsToRender,
|
|
351
308
|
getColumnGroupHeadersRows,
|
|
309
|
+
getPinnedCellOffset,
|
|
352
310
|
isDragging: !!dragCol,
|
|
353
311
|
getInnerProps: () => ({
|
|
354
312
|
role: 'rowgroup'
|
|
@@ -40,7 +40,6 @@ export const useGridColumnMenu = apiRef => {
|
|
|
40
40
|
});
|
|
41
41
|
});
|
|
42
42
|
apiRef.current.hidePreferences();
|
|
43
|
-
apiRef.current.forceUpdate();
|
|
44
43
|
}
|
|
45
44
|
}, [apiRef, logger]);
|
|
46
45
|
const hideColumnMenu = React.useCallback(() => {
|
|
@@ -82,7 +81,6 @@ export const useGridColumnMenu = apiRef => {
|
|
|
82
81
|
columnMenu: newState
|
|
83
82
|
});
|
|
84
83
|
});
|
|
85
|
-
apiRef.current.forceUpdate();
|
|
86
84
|
}
|
|
87
85
|
}, [apiRef, logger]);
|
|
88
86
|
const toggleColumnMenu = React.useCallback(field => {
|
|
@@ -193,8 +193,10 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
193
193
|
const prevWidth = refs.columnHeaderElement.offsetWidth;
|
|
194
194
|
const widthDiff = newWidth - prevWidth;
|
|
195
195
|
const columnWidthDiff = newWidth - refs.initialColWidth;
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
if (columnWidthDiff > 0) {
|
|
197
|
+
const newTotalWidth = refs.initialTotalWidth + columnWidthDiff;
|
|
198
|
+
apiRef.current.rootElementRef?.current?.style.setProperty('--DataGrid-rowWidth', `${newTotalWidth}px`);
|
|
199
|
+
}
|
|
198
200
|
refs.colDef.computedWidth = newWidth;
|
|
199
201
|
refs.colDef.width = newWidth;
|
|
200
202
|
refs.colDef.flex = 0;
|
|
@@ -15,6 +15,7 @@ import { gridRowsMetaSelector } from "../rows/gridRowsMetaSelector.js";
|
|
|
15
15
|
import { calculatePinnedRowsHeight, getValidRowHeight, rowHeightWarning } from "../rows/gridRowsUtils.js";
|
|
16
16
|
import { getTotalHeaderHeight } from "../columns/gridColumnsUtils.js";
|
|
17
17
|
import { DATA_GRID_PROPS_DEFAULT_VALUES } from "../../../constants/dataGridPropsDefaultValues.js";
|
|
18
|
+
import { isJSDOM } from "../../../utils/isJSDOM.js";
|
|
18
19
|
const EMPTY_SIZE = {
|
|
19
20
|
width: 0,
|
|
20
21
|
height: 0
|
|
@@ -237,9 +238,6 @@ export function useGridDimensions(apiRef, props) {
|
|
|
237
238
|
const isFirstSizing = React.useRef(true);
|
|
238
239
|
const handleResize = React.useCallback(size => {
|
|
239
240
|
rootDimensionsRef.current = size;
|
|
240
|
-
|
|
241
|
-
// jsdom has no layout capabilities
|
|
242
|
-
const isJSDOM = /jsdom|HappyDOM/.test(window.navigator.userAgent);
|
|
243
241
|
if (size.height === 0 && !errorShown.current && !props.autoHeight && !isJSDOM) {
|
|
244
242
|
logger.error(['The parent DOM element of the Data Grid has an empty height.', 'Please make sure that this element has an intrinsic height.', 'The grid displays with a height of 0px.', '', 'More details: https://mui.com/r/x-data-grid-no-dimensions.'].join('\n'));
|
|
245
243
|
errorShown.current = true;
|
|
@@ -49,7 +49,12 @@ export const gridFilteredDescendantCountLookupSelector = createSelector(gridFilt
|
|
|
49
49
|
* Does not contain the collapsed children.
|
|
50
50
|
* @category Filtering
|
|
51
51
|
*/
|
|
52
|
-
export const gridExpandedSortedRowEntriesSelector = createSelectorMemoized(gridVisibleRowsLookupSelector, gridSortedRowEntriesSelector, (visibleRowsLookup, sortedRows
|
|
52
|
+
export const gridExpandedSortedRowEntriesSelector = createSelectorMemoized(gridVisibleRowsLookupSelector, gridSortedRowEntriesSelector, gridRowMaximumTreeDepthSelector, gridFilterModelSelector, gridQuickFilterValuesSelector, (visibleRowsLookup, sortedRows, maxDepth, filterModel, quickFilterValues) => {
|
|
53
|
+
if (maxDepth < 2 && !filterModel.items.length && !quickFilterValues?.length) {
|
|
54
|
+
return sortedRows;
|
|
55
|
+
}
|
|
56
|
+
return sortedRows.filter(row => visibleRowsLookup[row.id] !== false);
|
|
57
|
+
});
|
|
53
58
|
|
|
54
59
|
/**
|
|
55
60
|
* Get the id of the rows accessible after the filtering process.
|
|
@@ -19,7 +19,7 @@ function getHasEval() {
|
|
|
19
19
|
/**
|
|
20
20
|
* Adds default values to the optional fields of a filter items.
|
|
21
21
|
* @param {GridFilterItem} item The raw filter item.
|
|
22
|
-
* @param {
|
|
22
|
+
* @param {RefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
|
|
23
23
|
* @return {GridFilterItem} The clean filter item with an uniq ID and an always-defined operator.
|
|
24
24
|
* TODO: Make the typing reflect the different between GridFilterInputItem and GridFilterItem.
|
|
25
25
|
*/
|
|
@@ -133,7 +133,7 @@ let filterItemsApplierId = 1;
|
|
|
133
133
|
/**
|
|
134
134
|
* Generates a method to easily check if a row is matching the current filter model.
|
|
135
135
|
* @param {GridFilterModel} filterModel The model with which we want to filter the rows.
|
|
136
|
-
* @param {
|
|
136
|
+
* @param {RefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
|
|
137
137
|
* @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
|
|
138
138
|
*/
|
|
139
139
|
const buildAggregatedFilterItemsApplier = (filterModel, apiRef, disableEval) => {
|
|
@@ -181,7 +181,7 @@ export const shouldQuickFilterExcludeHiddenColumns = filterModel => {
|
|
|
181
181
|
/**
|
|
182
182
|
* Generates a method to easily check if a row is matching the current quick filter.
|
|
183
183
|
* @param {any[]} filterModel The model with which we want to filter the rows.
|
|
184
|
-
* @param {
|
|
184
|
+
* @param {RefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
|
|
185
185
|
* @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
|
|
186
186
|
*/
|
|
187
187
|
const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
|
|
@@ -10,6 +10,12 @@ const ALL_RESULTS_PAGE_VALUE = -1;
|
|
|
10
10
|
*/
|
|
11
11
|
export const gridPaginationSelector = state => state.pagination;
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* @category Pagination
|
|
15
|
+
* @ignore - do not document.
|
|
16
|
+
*/
|
|
17
|
+
export const gridPaginationEnabledClientSideSelector = createSelector(gridPaginationSelector, pagination => pagination.enabled && pagination.paginationMode === 'client');
|
|
18
|
+
|
|
13
19
|
/**
|
|
14
20
|
* Get the pagination model
|
|
15
21
|
* @category Pagination
|
|
@@ -50,7 +56,10 @@ export const gridPageCountSelector = createSelector(gridPaginationModelSelector,
|
|
|
50
56
|
* Get the index of the first and the last row to include in the current page if the pagination is enabled.
|
|
51
57
|
* @category Pagination
|
|
52
58
|
*/
|
|
53
|
-
export const gridPaginationRowRangeSelector = createSelectorMemoized(gridPaginationModelSelector, gridRowTreeSelector, gridRowMaximumTreeDepthSelector, gridExpandedSortedRowEntriesSelector, gridFilteredSortedTopLevelRowEntriesSelector, (paginationModel, rowTree, rowTreeDepth, visibleSortedRowEntries, visibleSortedTopLevelRowEntries) => {
|
|
59
|
+
export const gridPaginationRowRangeSelector = createSelectorMemoized(gridPaginationEnabledClientSideSelector, gridPaginationModelSelector, gridRowTreeSelector, gridRowMaximumTreeDepthSelector, gridExpandedSortedRowEntriesSelector, gridFilteredSortedTopLevelRowEntriesSelector, (clientSidePaginationEnabled, paginationModel, rowTree, rowTreeDepth, visibleSortedRowEntries, visibleSortedTopLevelRowEntries) => {
|
|
60
|
+
if (!clientSidePaginationEnabled) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
54
63
|
const visibleTopLevelRowCount = visibleSortedTopLevelRowEntries.length;
|
|
55
64
|
const topLevelFirstRowIndex = Math.min(paginationModel.pageSize * paginationModel.page, visibleTopLevelRowCount - 1);
|
|
56
65
|
const topLevelLastRowIndex = paginationModel.pageSize === ALL_RESULTS_PAGE_VALUE ? visibleTopLevelRowCount - 1 : Math.min(topLevelFirstRowIndex + paginationModel.pageSize - 1, visibleTopLevelRowCount - 1);
|
|
@@ -112,4 +121,33 @@ export const gridPaginatedVisibleSortedGridRowIdsSelector = createSelectorMemoiz
|
|
|
112
121
|
return [];
|
|
113
122
|
}
|
|
114
123
|
return visibleSortedRowIds.slice(paginationRange.firstRowIndex, paginationRange.lastRowIndex + 1);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Get the rows, range and rowIndex lookup map after filtering and sorting.
|
|
128
|
+
* Does not contain the collapsed children.
|
|
129
|
+
* @category Pagination
|
|
130
|
+
*/
|
|
131
|
+
export const gridVisibleRowsSelector = createSelectorMemoized(gridPaginationEnabledClientSideSelector, gridPaginationRowRangeSelector, gridPaginatedVisibleSortedGridRowEntriesSelector, gridExpandedSortedRowEntriesSelector, (clientPaginationEnabled, paginationRowRange, paginationRows, expandedSortedRowEntries) => {
|
|
132
|
+
if (clientPaginationEnabled) {
|
|
133
|
+
return {
|
|
134
|
+
rows: paginationRows,
|
|
135
|
+
range: paginationRowRange,
|
|
136
|
+
rowToIndexMap: paginationRows.reduce((lookup, row, index) => {
|
|
137
|
+
lookup.set(row.model, index);
|
|
138
|
+
return lookup;
|
|
139
|
+
}, new Map())
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
rows: expandedSortedRowEntries,
|
|
144
|
+
range: expandedSortedRowEntries.length === 0 ? null : {
|
|
145
|
+
firstRowIndex: 0,
|
|
146
|
+
lastRowIndex: expandedSortedRowEntries.length - 1
|
|
147
|
+
},
|
|
148
|
+
rowToIndexMap: expandedSortedRowEntries.reduce((lookup, row, index) => {
|
|
149
|
+
lookup.set(row.model, index);
|
|
150
|
+
return lookup;
|
|
151
|
+
}, new Map())
|
|
152
|
+
};
|
|
115
153
|
});
|