@mui/x-data-grid 8.0.0-alpha.7 → 8.0.0-alpha.8
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 +115 -0
- package/DataGrid/DataGrid.js +4 -5
- package/DataGrid/useDataGridComponent.js +1 -1
- package/components/GridHeaders.js +2 -2
- package/components/GridRow.d.ts +5 -9
- package/components/GridRow.js +26 -78
- 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/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 +7 -0
- package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +1 -0
- package/components/panel/filterPanel/GridFilterInputBoolean.js +12 -16
- package/components/panel/filterPanel/GridFilterInputDate.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterInputDate.js +32 -29
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -1
- package/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
- package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +1 -0
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +13 -17
- package/components/panel/filterPanel/GridFilterInputValue.d.ts +1 -0
- package/components/panel/filterPanel/GridFilterInputValue.js +34 -28
- package/components/panel/filterPanel/GridFilterInputValueProps.d.ts +1 -1
- package/components/virtualization/GridVirtualScrollbar.js +11 -12
- package/components/virtualization/GridVirtualScroller.js +4 -4
- package/constants/gridClasses.d.ts +12 -0
- package/constants/gridClasses.js +1 -1
- package/constants/localeTextConstants.js +1 -0
- package/context/GridContextProvider.d.ts +1 -1
- package/hooks/features/clipboard/useGridClipboard.d.ts +1 -1
- package/hooks/features/columnGrouping/useGridColumnGrouping.d.ts +1 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +5 -7
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +34 -76
- package/hooks/features/columnMenu/useGridColumnMenu.d.ts +1 -1
- package/hooks/features/columns/gridColumnsUtils.d.ts +3 -3
- package/hooks/features/columns/useGridColumnSpanning.d.ts +1 -1
- package/hooks/features/columns/useGridColumns.d.ts +1 -1
- package/hooks/features/density/useGridDensity.d.ts +1 -1
- package/hooks/features/dimensions/useGridDimensions.d.ts +1 -1
- package/hooks/features/editing/useGridCellEditing.d.ts +1 -1
- package/hooks/features/editing/useGridCellEditing.js +1 -1
- package/hooks/features/editing/useGridEditing.d.ts +1 -1
- package/hooks/features/editing/useGridRowEditing.d.ts +1 -1
- package/hooks/features/editing/useGridRowEditing.js +1 -1
- package/hooks/features/events/useGridEvents.d.ts +1 -1
- package/hooks/features/export/serializers/csvSerializer.d.ts +1 -1
- package/hooks/features/export/useGridCsvExport.d.ts +1 -1
- package/hooks/features/export/useGridPrintExport.d.ts +1 -1
- package/hooks/features/export/utils.d.ts +1 -1
- package/hooks/features/filter/gridFilterSelector.d.ts +1 -1
- package/hooks/features/filter/gridFilterSelector.js +6 -1
- package/hooks/features/filter/gridFilterUtils.d.ts +6 -6
- package/hooks/features/filter/gridFilterUtils.js +3 -3
- package/hooks/features/filter/useGridFilter.d.ts +1 -1
- package/hooks/features/focus/useGridFocus.d.ts +1 -1
- package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +1 -1
- package/hooks/features/keyboardNavigation/utils.d.ts +2 -2
- package/hooks/features/listView/useGridListView.d.ts +1 -1
- package/hooks/features/pagination/gridPaginationInterfaces.d.ts +3 -0
- package/hooks/features/pagination/gridPaginationSelector.d.ts +21 -2
- package/hooks/features/pagination/gridPaginationSelector.js +39 -1
- package/hooks/features/pagination/useGridPagination.d.ts +2 -2
- package/hooks/features/pagination/useGridPagination.js +5 -3
- package/hooks/features/pagination/useGridPaginationMeta.d.ts +1 -1
- package/hooks/features/pagination/useGridPaginationModel.d.ts +1 -1
- package/hooks/features/pagination/useGridPaginationModel.js +23 -1
- package/hooks/features/pagination/useGridRowCount.d.ts +1 -1
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.ts +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.d.ts +1 -1
- package/hooks/features/rowSelection/utils.d.ts +2 -2
- package/hooks/features/rows/gridRowSpanningUtils.d.ts +1 -1
- package/hooks/features/rows/gridRowsSelector.js +1 -1
- package/hooks/features/rows/gridRowsUtils.d.ts +3 -3
- package/hooks/features/rows/useGridParamsApi.d.ts +1 -1
- package/hooks/features/rows/useGridRowSpanning.d.ts +1 -1
- package/hooks/features/rows/useGridRows.d.ts +1 -1
- package/hooks/features/rows/useGridRows.js +2 -2
- package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
- package/hooks/features/scroll/useGridScroll.d.ts +1 -1
- package/hooks/features/sorting/gridSortingUtils.d.ts +2 -2
- package/hooks/features/sorting/gridSortingUtils.js +2 -2
- package/hooks/features/sorting/useGridSorting.d.ts +1 -1
- package/hooks/features/statePersistence/useGridStatePersistence.d.ts +1 -1
- 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 +91 -42
- package/hooks/features/virtualization/useGridVirtualization.d.ts +1 -1
- package/hooks/utils/useGridApiContext.d.ts +1 -1
- package/hooks/utils/useGridApiEventHandler.d.ts +3 -3
- package/hooks/utils/useGridNativeEventListener.d.ts +1 -1
- package/hooks/utils/useGridPrivateApiContext.d.ts +1 -1
- package/hooks/utils/useGridSelector.d.ts +1 -1
- package/hooks/utils/useGridVisibleRows.d.ts +7 -5
- 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/arSD.js +2 -0
- package/locales/beBY.js +1 -0
- package/locales/bgBG.js +2 -0
- package/locales/csCZ.js +2 -0
- package/locales/daDK.js +2 -0
- package/locales/deDE.js +2 -0
- package/locales/elGR.js +2 -0
- package/locales/esES.js +2 -0
- package/locales/faIR.js +2 -0
- package/locales/fiFI.js +2 -0
- package/locales/frFR.js +2 -0
- package/locales/heIL.js +2 -0
- package/locales/hrHR.js +2 -0
- package/locales/huHU.js +2 -0
- package/locales/isIS.js +2 -0
- package/locales/itIT.js +2 -0
- package/locales/jaJP.js +2 -0
- package/locales/koKR.js +2 -0
- package/locales/nbNO.js +2 -0
- package/locales/nlNL.js +2 -0
- package/locales/nnNO.js +2 -0
- package/locales/plPL.js +2 -0
- package/locales/ptBR.js +2 -0
- package/locales/ptPT.js +2 -0
- package/locales/roRO.js +2 -0
- package/locales/ruRU.js +2 -0
- package/locales/skSK.js +2 -0
- package/locales/svSE.js +2 -0
- package/locales/trTR.js +2 -0
- package/locales/ukUA.js +2 -0
- package/locales/urPK.js +2 -0
- package/locales/viVN.js +2 -0
- package/locales/zhCN.js +2 -0
- package/locales/zhHK.js +2 -0
- package/locales/zhTW.js +2 -0
- package/material/index.js +2 -1
- package/models/api/gridLocaleTextApi.d.ts +1 -0
- package/models/colDef/gridColDef.d.ts +8 -8
- package/models/events/gridEventLookup.d.ts +6 -1
- package/models/gridExport.d.ts +1 -1
- package/models/gridFilterOperator.d.ts +1 -1
- package/models/gridIconSlotsComponent.d.ts +5 -0
- package/models/gridStateCommunity.d.ts +4 -0
- 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 +26 -78
- 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/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 +7 -0
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +12 -16
- package/modern/components/panel/filterPanel/GridFilterInputDate.js +32 -29
- package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +13 -17
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +34 -28
- package/modern/components/virtualization/GridVirtualScrollbar.js +11 -12
- package/modern/components/virtualization/GridVirtualScroller.js +4 -4
- package/modern/constants/gridClasses.js +1 -1
- package/modern/constants/localeTextConstants.js +1 -0
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +34 -76
- package/modern/hooks/features/editing/useGridCellEditing.js +1 -1
- package/modern/hooks/features/editing/useGridRowEditing.js +1 -1
- 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/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 +91 -42
- 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/arSD.js +2 -0
- package/modern/locales/beBY.js +1 -0
- package/modern/locales/bgBG.js +2 -0
- package/modern/locales/csCZ.js +2 -0
- package/modern/locales/daDK.js +2 -0
- package/modern/locales/deDE.js +2 -0
- package/modern/locales/elGR.js +2 -0
- package/modern/locales/esES.js +2 -0
- package/modern/locales/faIR.js +2 -0
- package/modern/locales/fiFI.js +2 -0
- package/modern/locales/frFR.js +2 -0
- package/modern/locales/heIL.js +2 -0
- package/modern/locales/hrHR.js +2 -0
- package/modern/locales/huHU.js +2 -0
- package/modern/locales/isIS.js +2 -0
- package/modern/locales/itIT.js +2 -0
- package/modern/locales/jaJP.js +2 -0
- package/modern/locales/koKR.js +2 -0
- package/modern/locales/nbNO.js +2 -0
- package/modern/locales/nlNL.js +2 -0
- package/modern/locales/nnNO.js +2 -0
- package/modern/locales/plPL.js +2 -0
- package/modern/locales/ptBR.js +2 -0
- package/modern/locales/ptPT.js +2 -0
- package/modern/locales/roRO.js +2 -0
- package/modern/locales/ruRU.js +2 -0
- package/modern/locales/skSK.js +2 -0
- package/modern/locales/svSE.js +2 -0
- package/modern/locales/trTR.js +2 -0
- package/modern/locales/ukUA.js +2 -0
- package/modern/locales/urPK.js +2 -0
- package/modern/locales/viVN.js +2 -0
- package/modern/locales/zhCN.js +2 -0
- package/modern/locales/zhHK.js +2 -0
- package/modern/locales/zhTW.js +2 -0
- package/modern/material/index.js +2 -1
- package/modern/utils/cellBorderUtils.js +5 -5
- package/modern/utils/domUtils.js +7 -2
- 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 +25 -77
- 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/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 +7 -0
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +12 -16
- package/node/components/panel/filterPanel/GridFilterInputDate.js +31 -28
- package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +13 -17
- package/node/components/panel/filterPanel/GridFilterInputValue.js +33 -27
- package/node/components/virtualization/GridVirtualScrollbar.js +11 -12
- package/node/components/virtualization/GridVirtualScroller.js +4 -4
- package/node/constants/gridClasses.js +1 -1
- package/node/constants/localeTextConstants.js +1 -0
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +32 -74
- package/node/hooks/features/editing/useGridCellEditing.js +1 -1
- package/node/hooks/features/editing/useGridRowEditing.js +1 -1
- 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/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 +91 -42
- 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/arSD.js +2 -0
- package/node/locales/beBY.js +1 -0
- package/node/locales/bgBG.js +2 -0
- package/node/locales/csCZ.js +2 -0
- package/node/locales/daDK.js +2 -0
- package/node/locales/deDE.js +2 -0
- package/node/locales/elGR.js +2 -0
- package/node/locales/esES.js +2 -0
- package/node/locales/faIR.js +2 -0
- package/node/locales/fiFI.js +2 -0
- package/node/locales/frFR.js +2 -0
- package/node/locales/heIL.js +2 -0
- package/node/locales/hrHR.js +2 -0
- package/node/locales/huHU.js +2 -0
- package/node/locales/isIS.js +2 -0
- package/node/locales/itIT.js +2 -0
- package/node/locales/jaJP.js +2 -0
- package/node/locales/koKR.js +2 -0
- package/node/locales/nbNO.js +2 -0
- package/node/locales/nlNL.js +2 -0
- package/node/locales/nnNO.js +2 -0
- package/node/locales/plPL.js +2 -0
- package/node/locales/ptBR.js +2 -0
- package/node/locales/ptPT.js +2 -0
- package/node/locales/roRO.js +2 -0
- package/node/locales/ruRU.js +2 -0
- package/node/locales/skSK.js +2 -0
- package/node/locales/svSE.js +2 -0
- package/node/locales/trTR.js +2 -0
- package/node/locales/ukUA.js +2 -0
- package/node/locales/urPK.js +2 -0
- package/node/locales/viVN.js +2 -0
- package/node/locales/zhCN.js +2 -0
- package/node/locales/zhHK.js +2 -0
- package/node/locales/zhTW.js +2 -0
- package/node/material/index.js +2 -1
- package/node/utils/cellBorderUtils.js +5 -5
- package/node/utils/domUtils.js +7 -2
- 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 +1 -1
- package/utils/domUtils.js +7 -2
- package/utils/getPublicApiRef.d.ts +1 -1
- package/utils/rtlFlipSide.d.ts +2 -0
- package/utils/rtlFlipSide.js +22 -0
|
@@ -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'
|
|
@@ -338,7 +338,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
338
338
|
if (onProcessRowUpdateError) {
|
|
339
339
|
onProcessRowUpdateError(errorThrown);
|
|
340
340
|
} else if (process.env.NODE_ENV !== 'production') {
|
|
341
|
-
warnOnce(['MUI X: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, for example `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/editing
|
|
341
|
+
warnOnce(['MUI X: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, for example `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/editing/persistence/.'], 'error');
|
|
342
342
|
}
|
|
343
343
|
};
|
|
344
344
|
try {
|
|
@@ -414,7 +414,7 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
414
414
|
if (onProcessRowUpdateError) {
|
|
415
415
|
onProcessRowUpdateError(errorThrown);
|
|
416
416
|
} else if (process.env.NODE_ENV !== 'production') {
|
|
417
|
-
warnOnce(['MUI X: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, for example `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/editing
|
|
417
|
+
warnOnce(['MUI X: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, for example `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/editing/persistence/.'], 'error');
|
|
418
418
|
}
|
|
419
419
|
};
|
|
420
420
|
try {
|
|
@@ -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 {React.
|
|
22
|
+
* @param {React.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 {React.
|
|
136
|
+
* @param {React.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 {React.
|
|
184
|
+
* @param {React.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
|
});
|
|
@@ -9,11 +9,13 @@ export const paginationStateInitializer = (state, props) => {
|
|
|
9
9
|
const rowCount = props.rowCount ?? props.initialState?.pagination?.rowCount;
|
|
10
10
|
const meta = props.paginationMeta ?? props.initialState?.pagination?.meta ?? {};
|
|
11
11
|
return _extends({}, state, {
|
|
12
|
-
pagination: {
|
|
12
|
+
pagination: _extends({}, state.pagination, {
|
|
13
13
|
paginationModel,
|
|
14
14
|
rowCount,
|
|
15
|
-
meta
|
|
16
|
-
|
|
15
|
+
meta,
|
|
16
|
+
enabled: props.pagination === true,
|
|
17
|
+
paginationMode: props.paginationMode
|
|
18
|
+
})
|
|
17
19
|
});
|
|
18
20
|
};
|
|
19
21
|
|
|
@@ -155,12 +155,34 @@ export const useGridPaginationModel = (apiRef, props) => {
|
|
|
155
155
|
/**
|
|
156
156
|
* EFFECTS
|
|
157
157
|
*/
|
|
158
|
+
const isFirstRender = React.useRef(true);
|
|
158
159
|
React.useEffect(() => {
|
|
160
|
+
if (isFirstRender.current) {
|
|
161
|
+
isFirstRender.current = false;
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (!props.pagination) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
159
167
|
apiRef.current.setState(state => _extends({}, state, {
|
|
160
168
|
pagination: _extends({}, state.pagination, {
|
|
161
169
|
paginationModel: getDerivedPaginationModel(state.pagination, props.signature, props.paginationModel)
|
|
162
170
|
})
|
|
163
171
|
}));
|
|
164
|
-
}, [apiRef, props.paginationModel, props.
|
|
172
|
+
}, [apiRef, props.paginationModel, props.signature, props.pagination]);
|
|
173
|
+
React.useEffect(() => {
|
|
174
|
+
apiRef.current.setState(state => {
|
|
175
|
+
const isEnabled = props.pagination === true;
|
|
176
|
+
if (state.pagination.paginationMode === props.paginationMode || state.pagination.enabled === isEnabled) {
|
|
177
|
+
return state;
|
|
178
|
+
}
|
|
179
|
+
return _extends({}, state, {
|
|
180
|
+
pagination: _extends({}, state.pagination, {
|
|
181
|
+
paginationMode: props.paginationMode,
|
|
182
|
+
enabled: props.pagination === true
|
|
183
|
+
})
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
}, [apiRef, props.paginationMode, props.pagination]);
|
|
165
187
|
React.useEffect(handleUpdateAutoPageSize, [handleUpdateAutoPageSize]);
|
|
166
188
|
};
|
|
@@ -15,7 +15,7 @@ export const gridRowMaximumTreeDepthSelector = createSelectorMemoized(gridRowsSt
|
|
|
15
15
|
if (entries.length === 0) {
|
|
16
16
|
return 1;
|
|
17
17
|
}
|
|
18
|
-
return entries.filter(([, nodeCount]) => nodeCount > 0).map(([depth]) => Number(depth)).sort((a, b) => b - a)[0] + 1;
|
|
18
|
+
return (entries.filter(([, nodeCount]) => nodeCount > 0).map(([depth]) => Number(depth)).sort((a, b) => b - a)[0] ?? 0) + 1;
|
|
19
19
|
});
|
|
20
20
|
export const gridDataRowIdsSelector = createSelector(gridRowsStateSelector, rows => rows.dataRowIds);
|
|
21
21
|
|
|
@@ -6,7 +6,7 @@ import { useGridLogger } from "../../utils/useGridLogger.js";
|
|
|
6
6
|
import { gridRowCountSelector, gridRowsLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthsSelector, gridDataRowIdsSelector, gridRowMaximumTreeDepthSelector, gridRowGroupsToFetchSelector } from "./gridRowsSelector.js";
|
|
7
7
|
import { useTimeout } from "../../utils/useTimeout.js";
|
|
8
8
|
import { GridSignature, useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
|
|
9
|
-
import {
|
|
9
|
+
import { getVisibleRows } from "../../utils/useGridVisibleRows.js";
|
|
10
10
|
import { gridSortedRowIdsSelector } from "../sorting/gridSortingSelector.js";
|
|
11
11
|
import { gridFilteredRowsLookupSelector } from "../filter/gridFilterSelector.js";
|
|
12
12
|
import { getTreeNodeDescendants, createRowsInternalCache, getRowsStateFromCache, isAutogeneratedRowNode, GRID_ROOT_GROUP_ID, GRID_ID_AUTOGENERATED, updateCacheWithNewRows, getTopLevelRowCount, getRowIdFromRowModel, computeRowsUpdates } from "./gridRowsUtils.js";
|
|
@@ -40,7 +40,7 @@ export const useGridRows = (apiRef, props) => {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
const logger = useGridLogger(apiRef, 'useGridRows');
|
|
43
|
-
const currentPage =
|
|
43
|
+
const currentPage = getVisibleRows(apiRef);
|
|
44
44
|
const lastUpdateMs = React.useRef(Date.now());
|
|
45
45
|
const lastRowCount = React.useRef(props.rowCount);
|
|
46
46
|
const timeout = useTimeout();
|
|
@@ -19,7 +19,7 @@ const isDesc = direction => direction === 'desc';
|
|
|
19
19
|
/**
|
|
20
20
|
* Transform an item of the sorting model into a method comparing two rows.
|
|
21
21
|
* @param {GridSortItem} sortItem The sort item we want to apply.
|
|
22
|
-
* @param {React.
|
|
22
|
+
* @param {React.RefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
23
23
|
* @returns {GridParsedSortItem | null} The parsed sort item. Returns `null` is the sort item is not valid.
|
|
24
24
|
*/
|
|
25
25
|
const parseSortItem = (sortItem, apiRef) => {
|
|
@@ -72,7 +72,7 @@ const compareRows = (parsedSortItems, row1, row2) => {
|
|
|
72
72
|
/**
|
|
73
73
|
* Generates a method to easily sort a list of rows according to the current sort model.
|
|
74
74
|
* @param {GridSortModel} sortModel The model with which we want to sort the rows.
|
|
75
|
-
* @param {React.
|
|
75
|
+
* @param {React.RefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
76
76
|
* @returns {GridSortingModelApplier | null} A method that generates a list of sorted row ids from a list of rows according to the current sort model. If `null`, we consider that the rows should remain in the order there were provided.
|
|
77
77
|
*/
|
|
78
78
|
export const buildAggregatedSortingApplier = (sortModel, apiRef) => {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { createSelector } from 'reselect';
|
|
3
|
+
import { createSelectorMemoized } from "../../../utils/createSelector.js";
|
|
4
|
+
import { gridVisibleColumnDefinitionsSelector } from "../columns/gridColumnsSelector.js";
|
|
5
|
+
import { gridRenderContextSelector } from "./gridVirtualizationSelectors.js";
|
|
6
|
+
import { gridFocusCellSelector } from "../focus/index.js";
|
|
7
|
+
import { gridVisibleRowsSelector } from "../pagination/index.js";
|
|
8
|
+
import { gridRowsLookupSelector } from "../rows/index.js";
|
|
9
|
+
const gridIsFocusedCellOutOfContex = createSelector(gridFocusCellSelector, gridRenderContextSelector, gridVisibleRowsSelector, gridVisibleColumnDefinitionsSelector, gridRowsLookupSelector, (focusedCell, renderContext, currentPage, visibleColumns, rows) => {
|
|
10
|
+
if (!focusedCell) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const row = rows[focusedCell.id];
|
|
14
|
+
if (!row) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const rowIndex = currentPage.rowToIndexMap.get(row);
|
|
18
|
+
const columnIndex = visibleColumns.slice(renderContext.firstColumnIndex, renderContext.lastColumnIndex).findIndex(column => column.field === focusedCell.field);
|
|
19
|
+
const isInRenderContext = rowIndex !== undefined && columnIndex !== -1 && rowIndex >= renderContext.firstRowIndex && rowIndex <= renderContext.lastRowIndex;
|
|
20
|
+
return !isInRenderContext;
|
|
21
|
+
});
|
|
22
|
+
export const gridFocusedVirtualCellSelector = createSelectorMemoized(gridIsFocusedCellOutOfContex, gridVisibleColumnDefinitionsSelector, gridVisibleRowsSelector, gridRowsLookupSelector, gridFocusCellSelector, (isFocusedCellOutOfRenderContext, visibleColumns, currentPage, rows, focusedCell) => {
|
|
23
|
+
if (!isFocusedCellOutOfRenderContext) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const row = rows[focusedCell.id];
|
|
27
|
+
if (!row) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const rowIndex = currentPage.rowToIndexMap.get(row);
|
|
31
|
+
if (rowIndex === undefined) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const columnIndex = visibleColumns.findIndex(column => column.field === focusedCell.field);
|
|
35
|
+
if (columnIndex === -1) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return _extends({}, focusedCell, {
|
|
39
|
+
rowIndex,
|
|
40
|
+
columnIndex
|
|
41
|
+
});
|
|
42
|
+
});
|