@mui/x-data-grid 8.8.0 → 8.9.2
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 +225 -24
- package/DataGrid/DataGrid.js +5 -0
- package/DataGrid/index.d.ts +0 -1
- package/DataGrid/useDataGridComponent.js +10 -0
- package/colDef/gridCheckboxSelectionColDef.js +1 -0
- package/components/GridDetailPanels.d.ts +2 -2
- package/components/GridPinnedRows.d.ts +2 -2
- package/components/GridRow.js +5 -0
- package/components/GridScrollArea.js +1 -1
- package/components/cell/GridCell.js +7 -5
- package/components/cell/GridEditSingleSelectCell.js +1 -1
- package/components/columnsManagement/GridColumnsManagement.d.ts +6 -0
- package/components/columnsManagement/GridColumnsManagement.js +17 -5
- package/components/containers/GridRootStyles.d.ts +1 -1
- package/components/containers/GridRootStyles.js +39 -0
- package/components/toolbarV8/Toolbar.d.ts +1 -1
- package/components/virtualization/GridVirtualScroller.js +5 -5
- package/constants/dataGridPropsDefaultValues.js +1 -0
- package/constants/gridClasses.d.ts +12 -0
- package/constants/gridClasses.js +3 -1
- package/esm/DataGrid/DataGrid.js +5 -0
- package/esm/DataGrid/index.d.ts +0 -1
- package/esm/DataGrid/useDataGridComponent.js +10 -0
- package/esm/colDef/gridCheckboxSelectionColDef.js +1 -0
- package/esm/components/GridDetailPanels.d.ts +2 -2
- package/esm/components/GridPinnedRows.d.ts +2 -2
- package/esm/components/GridRow.js +5 -0
- package/esm/components/GridScrollArea.js +1 -1
- package/esm/components/cell/GridCell.js +7 -5
- package/esm/components/cell/GridEditSingleSelectCell.js +1 -1
- package/esm/components/columnsManagement/GridColumnsManagement.d.ts +6 -0
- package/esm/components/columnsManagement/GridColumnsManagement.js +17 -5
- package/esm/components/containers/GridRootStyles.d.ts +1 -1
- package/esm/components/containers/GridRootStyles.js +39 -0
- package/esm/components/toolbarV8/Toolbar.d.ts +1 -1
- package/esm/components/virtualization/GridVirtualScroller.js +5 -5
- package/esm/constants/dataGridPropsDefaultValues.js +1 -0
- package/esm/constants/gridClasses.d.ts +12 -0
- package/esm/constants/gridClasses.js +3 -1
- package/esm/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +5 -0
- package/esm/hooks/core/pipeProcessing/useGridPipeProcessing.js +20 -5
- package/esm/hooks/core/useGridProps.d.ts +2 -2
- package/esm/hooks/core/useGridProps.js +3 -1
- package/esm/hooks/core/useGridVirtualizer.d.ts +9 -0
- package/esm/hooks/core/useGridVirtualizer.js +223 -0
- package/esm/hooks/features/columnGrouping/gridColumnGroupsInterfaces.d.ts +4 -1
- package/esm/hooks/features/columnGrouping/gridColumnGroupsUtils.js +35 -32
- package/esm/hooks/features/columnGrouping/useGridColumnGrouping.js +18 -13
- package/esm/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
- package/esm/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -2
- package/esm/hooks/features/columns/gridColumnsInterfaces.d.ts +3 -3
- package/esm/hooks/features/columns/gridColumnsSelector.js +6 -2
- package/esm/hooks/features/columns/gridColumnsUtils.js +6 -4
- package/esm/hooks/features/columns/useGridColumnSpanning.js +5 -90
- package/esm/hooks/features/columns/useGridColumns.js +8 -10
- package/esm/hooks/features/dimensions/useGridDimensions.js +18 -188
- package/esm/hooks/features/export/utils.js +1 -1
- package/esm/hooks/features/filter/useGridFilter.js +3 -3
- package/esm/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
- package/esm/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +6 -10
- package/esm/hooks/features/keyboardNavigation/utils.d.ts +3 -3
- package/esm/hooks/features/keyboardNavigation/utils.js +5 -5
- package/esm/hooks/features/listView/gridListViewSelectors.d.ts +8 -1
- package/esm/hooks/features/listView/gridListViewSelectors.js +7 -0
- package/esm/hooks/features/pivoting/gridPivotingInterfaces.d.ts +0 -1
- package/esm/hooks/features/pivoting/gridPivotingSelectors.d.ts +1 -4
- package/esm/hooks/features/pivoting/gridPivotingSelectors.js +1 -2
- package/esm/hooks/features/rowSelection/useGridRowSelection.js +5 -4
- package/esm/hooks/features/rows/gridRowsMetaInterfaces.d.ts +2 -8
- package/esm/hooks/features/rows/gridRowsMetaState.d.ts +2 -18
- package/esm/hooks/features/rows/gridRowsUtils.d.ts +1 -1
- package/esm/hooks/features/rows/gridRowsUtils.js +5 -2
- package/esm/hooks/features/rows/useGridRowAriaAttributes.js +3 -1
- package/esm/hooks/features/rows/useGridRowSpanning.d.ts +2 -12
- package/esm/hooks/features/rows/useGridRowSpanning.js +54 -85
- package/esm/hooks/features/rows/useGridRows.js +4 -3
- package/esm/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
- package/esm/hooks/features/rows/useGridRowsMeta.js +17 -187
- package/esm/hooks/features/scroll/useGridScroll.d.ts +1 -1
- package/esm/hooks/features/scroll/useGridScroll.js +2 -3
- package/esm/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +1 -1
- package/esm/hooks/features/virtualization/index.d.ts +1 -0
- package/esm/hooks/features/virtualization/index.js +1 -0
- package/esm/hooks/features/virtualization/useGridVirtualization.d.ts +5 -16
- package/esm/hooks/features/virtualization/useGridVirtualization.js +41 -22
- package/esm/hooks/utils/index.d.ts +2 -1
- package/esm/hooks/utils/index.js +2 -1
- package/esm/hooks/utils/useFirstRender.d.ts +1 -1
- package/esm/hooks/utils/useFirstRender.js +1 -8
- package/esm/hooks/utils/useGridInitializeState.d.ts +1 -1
- package/esm/hooks/utils/useGridInitializeState.js +6 -1
- package/esm/hooks/utils/useRunOncePerLoop.d.ts +1 -0
- package/esm/hooks/utils/useRunOncePerLoop.js +26 -0
- package/esm/index.js +1 -1
- package/esm/internals/index.d.ts +1 -1
- package/esm/internals/index.js +1 -1
- package/esm/internals/utils/getPinnedCellOffset.js +5 -0
- package/esm/locales/frFR.js +18 -21
- package/esm/locales/heIL.js +12 -12
- package/esm/locales/plPL.js +22 -24
- package/esm/models/api/gridApiCommon.d.ts +4 -1
- package/esm/models/api/gridColumnSpanning.d.ts +5 -11
- package/esm/models/api/gridRowApi.d.ts +5 -0
- package/esm/models/events/gridEventLookup.d.ts +2 -1
- package/esm/models/gridApiCaches.d.ts +8 -2
- package/esm/models/gridStateCommunity.d.ts +2 -2
- package/esm/models/props/DataGridProps.d.ts +5 -0
- package/esm/utils/roundToDecimalPlaces.d.ts +1 -1
- package/esm/utils/roundToDecimalPlaces.js +1 -3
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +5 -0
- package/hooks/core/pipeProcessing/useGridPipeProcessing.js +20 -5
- package/hooks/core/useGridProps.d.ts +2 -2
- package/hooks/core/useGridProps.js +3 -1
- package/hooks/core/useGridVirtualizer.d.ts +9 -0
- package/hooks/core/useGridVirtualizer.js +231 -0
- package/hooks/features/columnGrouping/gridColumnGroupsInterfaces.d.ts +4 -1
- package/hooks/features/columnGrouping/gridColumnGroupsUtils.js +35 -32
- package/hooks/features/columnGrouping/useGridColumnGrouping.js +18 -13
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -3
- package/hooks/features/columns/gridColumnsInterfaces.d.ts +3 -3
- package/hooks/features/columns/gridColumnsSelector.js +6 -2
- package/hooks/features/columns/gridColumnsUtils.js +6 -4
- package/hooks/features/columns/useGridColumnSpanning.js +5 -91
- package/hooks/features/columns/useGridColumns.js +8 -10
- package/hooks/features/dimensions/useGridDimensions.js +18 -188
- package/hooks/features/export/utils.js +1 -1
- package/hooks/features/filter/useGridFilter.js +3 -3
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +6 -10
- package/hooks/features/keyboardNavigation/utils.d.ts +3 -3
- package/hooks/features/keyboardNavigation/utils.js +5 -5
- package/hooks/features/listView/gridListViewSelectors.d.ts +8 -1
- package/hooks/features/listView/gridListViewSelectors.js +8 -1
- package/hooks/features/pivoting/gridPivotingInterfaces.d.ts +0 -1
- package/hooks/features/pivoting/gridPivotingSelectors.d.ts +1 -4
- package/hooks/features/pivoting/gridPivotingSelectors.js +2 -3
- package/hooks/features/rowSelection/useGridRowSelection.js +5 -4
- package/hooks/features/rows/gridRowsMetaInterfaces.d.ts +2 -8
- package/hooks/features/rows/gridRowsMetaState.d.ts +2 -18
- package/hooks/features/rows/gridRowsUtils.d.ts +1 -1
- package/hooks/features/rows/gridRowsUtils.js +5 -2
- package/hooks/features/rows/useGridRowAriaAttributes.js +3 -1
- package/hooks/features/rows/useGridRowSpanning.d.ts +2 -12
- package/hooks/features/rows/useGridRowSpanning.js +54 -85
- package/hooks/features/rows/useGridRows.js +4 -3
- package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
- package/hooks/features/rows/useGridRowsMeta.js +15 -186
- package/hooks/features/scroll/useGridScroll.d.ts +1 -1
- package/hooks/features/scroll/useGridScroll.js +2 -3
- package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +1 -1
- package/hooks/features/virtualization/index.d.ts +1 -0
- package/hooks/features/virtualization/index.js +12 -0
- package/hooks/features/virtualization/useGridVirtualization.d.ts +5 -16
- package/hooks/features/virtualization/useGridVirtualization.js +42 -24
- package/hooks/utils/index.d.ts +2 -1
- package/hooks/utils/index.js +16 -4
- package/hooks/utils/useFirstRender.d.ts +1 -1
- package/hooks/utils/useFirstRender.js +11 -11
- package/hooks/utils/useGridInitializeState.d.ts +1 -1
- package/hooks/utils/useGridInitializeState.js +6 -1
- package/hooks/utils/useRunOncePerLoop.d.ts +1 -0
- package/hooks/utils/useRunOncePerLoop.js +33 -0
- package/index.js +1 -1
- package/internals/index.d.ts +1 -1
- package/internals/index.js +4 -11
- package/internals/utils/getPinnedCellOffset.js +5 -0
- package/locales/frFR.js +18 -21
- package/locales/heIL.js +12 -12
- package/locales/plPL.js +22 -24
- package/models/api/gridApiCommon.d.ts +4 -1
- package/models/api/gridColumnSpanning.d.ts +5 -11
- package/models/api/gridRowApi.d.ts +5 -0
- package/models/events/gridEventLookup.d.ts +2 -1
- package/models/gridApiCaches.d.ts +8 -2
- package/models/gridStateCommunity.d.ts +2 -2
- package/models/props/DataGridProps.d.ts +5 -0
- package/package.json +5 -5
- package/utils/roundToDecimalPlaces.d.ts +1 -1
- package/utils/roundToDecimalPlaces.js +7 -4
- package/esm/hooks/features/rows/gridRowSpanningSelectors.d.ts +0 -10
- package/esm/hooks/features/rows/gridRowSpanningSelectors.js +0 -5
- package/esm/hooks/features/virtualization/useGridVirtualScroller.d.ts +0 -56
- package/esm/hooks/features/virtualization/useGridVirtualScroller.js +0 -846
- package/esm/hooks/utils/useRunOnce.d.ts +0 -5
- package/esm/hooks/utils/useRunOnce.js +0 -18
- package/esm/utils/platform.d.ts +0 -1
- package/esm/utils/platform.js +0 -2
- package/hooks/features/rows/gridRowSpanningSelectors.d.ts +0 -10
- package/hooks/features/rows/gridRowSpanningSelectors.js +0 -11
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +0 -56
- package/hooks/features/virtualization/useGridVirtualScroller.js +0 -857
- package/hooks/utils/useRunOnce.d.ts +0 -5
- package/hooks/utils/useRunOnce.js +0 -27
- package/utils/platform.d.ts +0 -1
- package/utils/platform.js +0 -8
|
@@ -57,7 +57,8 @@ const useGridPipeProcessing = apiRef => {
|
|
|
57
57
|
cache.current[group] = {
|
|
58
58
|
processors: new Map(),
|
|
59
59
|
processorsAsArray: [],
|
|
60
|
-
appliers: {}
|
|
60
|
+
appliers: {},
|
|
61
|
+
processorsUpdated: false
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
64
|
const groupCache = cache.current[group];
|
|
@@ -65,19 +66,20 @@ const useGridPipeProcessing = apiRef => {
|
|
|
65
66
|
if (oldProcessor !== processor) {
|
|
66
67
|
groupCache.processors.set(id, processor);
|
|
67
68
|
groupCache.processorsAsArray = Array.from(cache.current[group].processors.values()).filter(processorValue => processorValue !== null);
|
|
68
|
-
|
|
69
|
+
groupCache.processorsUpdated = true;
|
|
69
70
|
}
|
|
70
71
|
return () => {
|
|
71
72
|
cache.current[group].processors.set(id, null);
|
|
72
73
|
cache.current[group].processorsAsArray = Array.from(cache.current[group].processors.values()).filter(processorValue => processorValue !== null);
|
|
73
74
|
};
|
|
74
|
-
}, [
|
|
75
|
+
}, []);
|
|
75
76
|
const registerPipeApplier = React.useCallback((group, id, applier) => {
|
|
76
77
|
if (!cache.current[group]) {
|
|
77
78
|
cache.current[group] = {
|
|
78
79
|
processors: new Map(),
|
|
79
80
|
processorsAsArray: [],
|
|
80
|
-
appliers: {}
|
|
81
|
+
appliers: {},
|
|
82
|
+
processorsUpdated: false
|
|
81
83
|
};
|
|
82
84
|
}
|
|
83
85
|
cache.current[group].appliers[id] = applier;
|
|
@@ -90,6 +92,18 @@ const useGridPipeProcessing = apiRef => {
|
|
|
90
92
|
const requestPipeProcessorsApplication = React.useCallback(group => {
|
|
91
93
|
runAppliers(cache.current[group]);
|
|
92
94
|
}, [runAppliers]);
|
|
95
|
+
const runAppliersForPendingProcessors = React.useCallback(() => {
|
|
96
|
+
for (const group in cache.current) {
|
|
97
|
+
if (!Object.prototype.hasOwnProperty.call(cache.current, group)) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const groupCache = cache.current[group];
|
|
101
|
+
if (groupCache.processorsUpdated) {
|
|
102
|
+
groupCache.processorsUpdated = false;
|
|
103
|
+
runAppliers(groupCache);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}, [runAppliers]);
|
|
93
107
|
const applyPipeProcessors = React.useCallback((...args) => {
|
|
94
108
|
const [group, value, context] = args;
|
|
95
109
|
if (!cache.current[group]) {
|
|
@@ -105,7 +119,8 @@ const useGridPipeProcessing = apiRef => {
|
|
|
105
119
|
const preProcessingPrivateApi = {
|
|
106
120
|
registerPipeProcessor,
|
|
107
121
|
registerPipeApplier,
|
|
108
|
-
requestPipeProcessorsApplication
|
|
122
|
+
requestPipeProcessorsApplication,
|
|
123
|
+
runAppliersForPendingProcessors
|
|
109
124
|
};
|
|
110
125
|
const preProcessingPublicApi = {
|
|
111
126
|
unstable_applyPipeProcessors: applyPipeProcessors
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { RefObject } from '@mui/x-internals/types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { DataGridProcessedProps } from "../../models/props/DataGridProps.js";
|
|
3
3
|
import type { GridPrivateApiCommon } from "../../models/api/gridApiCommon.js";
|
|
4
4
|
import type { GridStateInitializer } from "../utils/useGridInitializeState.js";
|
|
5
|
-
type Props = Pick<
|
|
5
|
+
type Props = Pick<DataGridProcessedProps, 'getRowId' | 'listView'>;
|
|
6
6
|
export declare const propsStateInitializer: GridStateInitializer<Props>;
|
|
7
7
|
export declare const useGridProps: <PrivateApi extends GridPrivateApiCommon>(apiRef: RefObject<PrivateApi>, props: Props) => void;
|
|
8
8
|
export {};
|
|
@@ -12,6 +12,7 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
12
12
|
const propsStateInitializer = (state, props) => {
|
|
13
13
|
return (0, _extends2.default)({}, state, {
|
|
14
14
|
props: {
|
|
15
|
+
listView: props.listView,
|
|
15
16
|
getRowId: props.getRowId
|
|
16
17
|
}
|
|
17
18
|
});
|
|
@@ -21,9 +22,10 @@ const useGridProps = (apiRef, props) => {
|
|
|
21
22
|
React.useEffect(() => {
|
|
22
23
|
apiRef.current.setState(state => (0, _extends2.default)({}, state, {
|
|
23
24
|
props: {
|
|
25
|
+
listView: props.listView,
|
|
24
26
|
getRowId: props.getRowId
|
|
25
27
|
}
|
|
26
28
|
}));
|
|
27
|
-
}, [apiRef, props.getRowId]);
|
|
29
|
+
}, [apiRef, props.listView, props.getRowId]);
|
|
28
30
|
};
|
|
29
31
|
exports.useGridProps = useGridProps;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
+
import { GridPrivateApiCommunity } from "../../models/api/gridApiCommunity.js";
|
|
3
|
+
import { DataGridProcessedProps } from "../../models/props/DataGridProps.js";
|
|
4
|
+
type RootProps = DataGridProcessedProps;
|
|
5
|
+
/**
|
|
6
|
+
* Virtualizer setup
|
|
7
|
+
*/
|
|
8
|
+
export declare function useGridVirtualizer(apiRef: RefObject<GridPrivateApiCommunity>, rootProps: RootProps): void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useGridVirtualizer = useGridVirtualizer;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
12
|
+
var _RtlProvider = require("@mui/system/RtlProvider");
|
|
13
|
+
var _math = require("@mui/x-internals/math");
|
|
14
|
+
var _store = require("@mui/x-internals/store");
|
|
15
|
+
var _xVirtualizer = require("@mui/x-virtualizer");
|
|
16
|
+
var _useFirstRender = require("../utils/useFirstRender");
|
|
17
|
+
var _createSelector = require("../../utils/createSelector");
|
|
18
|
+
var _useGridSelector = require("../utils/useGridSelector");
|
|
19
|
+
var _gridDimensionsSelectors = require("../features/dimensions/gridDimensionsSelectors");
|
|
20
|
+
var _density = require("../features/density");
|
|
21
|
+
var _gridColumnsSelector = require("../features/columns/gridColumnsSelector");
|
|
22
|
+
var _gridRowsSelector = require("../features/rows/gridRowsSelector");
|
|
23
|
+
var _useGridVisibleRows = require("../utils/useGridVisibleRows");
|
|
24
|
+
var _pagination = require("../features/pagination");
|
|
25
|
+
var _gridFocusedVirtualCellSelector = require("../features/virtualization/gridFocusedVirtualCellSelector");
|
|
26
|
+
var _rowSelection = require("../features/rowSelection");
|
|
27
|
+
var _dataGridPropsDefaultValues = require("../../constants/dataGridPropsDefaultValues");
|
|
28
|
+
var _gridRowsUtils = require("../features/rows/gridRowsUtils");
|
|
29
|
+
var _gridColumnsUtils = require("../features/columns/gridColumnsUtils");
|
|
30
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
31
|
+
function identity(x) {
|
|
32
|
+
return x;
|
|
33
|
+
}
|
|
34
|
+
const columnsTotalWidthSelector = (0, _createSelector.createSelector)(_gridColumnsSelector.gridVisibleColumnDefinitionsSelector, _gridColumnsSelector.gridColumnPositionsSelector, (visibleColumns, positions) => {
|
|
35
|
+
const colCount = visibleColumns.length;
|
|
36
|
+
if (colCount === 0) {
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
return (0, _math.roundToDecimalPlaces)(positions[colCount - 1] + visibleColumns[colCount - 1].computedWidth, 1);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Virtualizer setup
|
|
44
|
+
*/
|
|
45
|
+
function useGridVirtualizer(apiRef, rootProps) {
|
|
46
|
+
const isRtl = (0, _RtlProvider.useRtl)();
|
|
47
|
+
const {
|
|
48
|
+
listView
|
|
49
|
+
} = rootProps;
|
|
50
|
+
const visibleColumns = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector);
|
|
51
|
+
const pinnedRows = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridPinnedRowsSelector);
|
|
52
|
+
const pinnedColumns = (0, _gridColumnsSelector.gridVisiblePinnedColumnDefinitionsSelector)(apiRef);
|
|
53
|
+
const rowSelectionManager = (0, _useGridSelector.useGridSelector)(apiRef, _rowSelection.gridRowSelectionManagerSelector);
|
|
54
|
+
const isRowSelected = id => rowSelectionManager.has(id) && apiRef.current.isRowSelectable(id);
|
|
55
|
+
const currentPage = (0, _useGridVisibleRows.useGridVisibleRows)(apiRef);
|
|
56
|
+
const hasColSpan = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridHasColSpanSelector);
|
|
57
|
+
|
|
58
|
+
/* TODO: extract dimensions code */
|
|
59
|
+
const contentHeight = (0, _useGridSelector.useGridSelector)(apiRef, _gridDimensionsSelectors.gridContentHeightSelector);
|
|
60
|
+
const verticalScrollbarWidth = (0, _useGridSelector.useGridSelector)(apiRef, _gridDimensionsSelectors.gridVerticalScrollbarWidthSelector);
|
|
61
|
+
const hasFiller = (0, _useGridSelector.useGridSelector)(apiRef, _gridDimensionsSelectors.gridHasFillerSelector);
|
|
62
|
+
const {
|
|
63
|
+
autoHeight
|
|
64
|
+
} = rootProps;
|
|
65
|
+
const scrollReset = listView;
|
|
66
|
+
|
|
67
|
+
// <DIMENSIONS>
|
|
68
|
+
const density = (0, _useGridSelector.useGridSelector)(apiRef, _density.gridDensityFactorSelector);
|
|
69
|
+
const baseRowHeight = (0, _gridRowsUtils.getValidRowHeight)(rootProps.rowHeight, _dataGridPropsDefaultValues.DATA_GRID_PROPS_DEFAULT_VALUES.rowHeight, _gridRowsUtils.rowHeightWarning);
|
|
70
|
+
const rowHeight = Math.floor(baseRowHeight * density);
|
|
71
|
+
const headerHeight = Math.floor(rootProps.columnHeaderHeight * density);
|
|
72
|
+
const groupHeaderHeight = Math.floor((rootProps.columnGroupHeaderHeight ?? rootProps.columnHeaderHeight) * density);
|
|
73
|
+
const headerFilterHeight = Math.floor((rootProps.headerFilterHeight ?? rootProps.columnHeaderHeight) * density);
|
|
74
|
+
const columnsTotalWidth = (0, _useGridSelector.useGridSelector)(apiRef, columnsTotalWidthSelector);
|
|
75
|
+
const headersTotalHeight = (0, _gridColumnsUtils.getTotalHeaderHeight)(apiRef, rootProps);
|
|
76
|
+
const leftPinnedWidth = pinnedColumns.left.reduce((w, col) => w + col.computedWidth, 0);
|
|
77
|
+
const rightPinnedWidth = pinnedColumns.right.reduce((w, col) => w + col.computedWidth, 0);
|
|
78
|
+
const dimensions = {
|
|
79
|
+
rowHeight,
|
|
80
|
+
headerHeight,
|
|
81
|
+
groupHeaderHeight,
|
|
82
|
+
headerFilterHeight,
|
|
83
|
+
columnsTotalWidth,
|
|
84
|
+
headersTotalHeight,
|
|
85
|
+
leftPinnedWidth,
|
|
86
|
+
rightPinnedWidth
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// </DIMENSIONS>
|
|
90
|
+
|
|
91
|
+
// <ROWS_META>
|
|
92
|
+
const dataRowCount = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridRowCountSelector);
|
|
93
|
+
const pagination = (0, _useGridSelector.useGridSelector)(apiRef, _pagination.gridPaginationSelector);
|
|
94
|
+
const rowCount = Math.min(pagination.enabled ? pagination.paginationModel.pageSize : dataRowCount, dataRowCount);
|
|
95
|
+
const {
|
|
96
|
+
getRowHeight,
|
|
97
|
+
getEstimatedRowHeight,
|
|
98
|
+
getRowSpacing
|
|
99
|
+
} = rootProps;
|
|
100
|
+
// </ROWS_META>
|
|
101
|
+
|
|
102
|
+
const focusedVirtualCell = (0, _useGridSelector.useGridSelector)(apiRef, _gridFocusedVirtualCellSelector.gridFocusedVirtualCellSelector);
|
|
103
|
+
const virtualizer = (0, _xVirtualizer.useVirtualizer)({
|
|
104
|
+
scrollbarSize: rootProps.scrollbarSize,
|
|
105
|
+
dimensions,
|
|
106
|
+
initialState: {
|
|
107
|
+
scroll: rootProps.initialState?.scroll,
|
|
108
|
+
dimensions: apiRef.current.state.dimensions,
|
|
109
|
+
rowSpanning: apiRef.current.state.rowSpanning,
|
|
110
|
+
virtualization: apiRef.current.state.virtualization
|
|
111
|
+
},
|
|
112
|
+
isRtl,
|
|
113
|
+
rows: currentPage.rows,
|
|
114
|
+
range: currentPage.range,
|
|
115
|
+
rowIdToIndexMap: currentPage.rowIdToIndexMap,
|
|
116
|
+
rowCount,
|
|
117
|
+
columns: visibleColumns,
|
|
118
|
+
pinnedRows,
|
|
119
|
+
pinnedColumns,
|
|
120
|
+
refs: {
|
|
121
|
+
container: apiRef.current.mainElementRef,
|
|
122
|
+
scroller: apiRef.current.virtualScrollerRef,
|
|
123
|
+
scrollbarVertical: apiRef.current.virtualScrollbarVerticalRef,
|
|
124
|
+
scrollbarHorizontal: apiRef.current.virtualScrollbarHorizontalRef
|
|
125
|
+
},
|
|
126
|
+
hasColSpan,
|
|
127
|
+
contentHeight,
|
|
128
|
+
minimalContentHeight: _gridRowsUtils.minimalContentHeight,
|
|
129
|
+
autoHeight,
|
|
130
|
+
getRowHeight: React.useMemo(() => {
|
|
131
|
+
if (!getRowHeight) {
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
return rowEntry => getRowHeight((0, _extends2.default)({}, rowEntry, {
|
|
135
|
+
densityFactor: density
|
|
136
|
+
}));
|
|
137
|
+
}, [getRowHeight, density]),
|
|
138
|
+
getEstimatedRowHeight: React.useMemo(() => getEstimatedRowHeight ? rowEntry => getEstimatedRowHeight((0, _extends2.default)({}, rowEntry, {
|
|
139
|
+
densityFactor: density
|
|
140
|
+
})) : undefined, [getEstimatedRowHeight, density]),
|
|
141
|
+
getRowSpacing: React.useMemo(() => getRowSpacing ? (rowEntry, visibility) => getRowSpacing((0, _extends2.default)({}, rowEntry, visibility, {
|
|
142
|
+
indexRelativeToCurrentPage: apiRef.current.getRowIndexRelativeToVisibleRows(rowEntry.id)
|
|
143
|
+
})) : undefined, [apiRef, getRowSpacing]),
|
|
144
|
+
applyRowHeight: (0, _useEventCallback.default)((entry, row) => apiRef.current.unstable_applyPipeProcessors('rowHeight', entry, row)),
|
|
145
|
+
virtualizeColumnsWithAutoRowHeight: rootProps.virtualizeColumnsWithAutoRowHeight,
|
|
146
|
+
focusedVirtualCell: (0, _useEventCallback.default)(() => focusedVirtualCell),
|
|
147
|
+
rowBufferPx: rootProps.rowBufferPx,
|
|
148
|
+
columnBufferPx: rootProps.columnBufferPx,
|
|
149
|
+
resizeThrottleMs: rootProps.resizeThrottleMs,
|
|
150
|
+
onResize: (0, _useEventCallback.default)(size => apiRef.current.publishEvent('resize', size)),
|
|
151
|
+
onWheel: (0, _useEventCallback.default)(event => {
|
|
152
|
+
apiRef.current.publishEvent('virtualScrollerWheel', {}, event);
|
|
153
|
+
}),
|
|
154
|
+
onTouchMove: (0, _useEventCallback.default)(event => {
|
|
155
|
+
apiRef.current.publishEvent('virtualScrollerTouchMove', {}, event);
|
|
156
|
+
}),
|
|
157
|
+
onRenderContextChange: (0, _useEventCallback.default)(nextRenderContext => {
|
|
158
|
+
apiRef.current.publishEvent('renderedRowsIntervalChange', nextRenderContext);
|
|
159
|
+
}),
|
|
160
|
+
onScrollChange: (scrollPosition, nextRenderContext) => {
|
|
161
|
+
apiRef.current.publishEvent('scrollPositionChange', {
|
|
162
|
+
top: scrollPosition.top,
|
|
163
|
+
left: scrollPosition.left,
|
|
164
|
+
renderContext: nextRenderContext
|
|
165
|
+
});
|
|
166
|
+
},
|
|
167
|
+
scrollReset,
|
|
168
|
+
getColspan: (rowId, column) => {
|
|
169
|
+
if (typeof column.colSpan === 'function') {
|
|
170
|
+
const row = apiRef.current.getRow(rowId);
|
|
171
|
+
const value = apiRef.current.getRowValue(row, column);
|
|
172
|
+
return column.colSpan(value, row, column, apiRef) ?? 0;
|
|
173
|
+
}
|
|
174
|
+
return column.colSpan ?? 0;
|
|
175
|
+
},
|
|
176
|
+
renderRow: params => /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.row, (0, _extends2.default)({
|
|
177
|
+
row: params.model,
|
|
178
|
+
rowId: params.id,
|
|
179
|
+
index: params.rowIndex,
|
|
180
|
+
selected: isRowSelected(params.id),
|
|
181
|
+
offsetLeft: params.offsetLeft,
|
|
182
|
+
columnsTotalWidth: columnsTotalWidth,
|
|
183
|
+
rowHeight: params.baseRowHeight,
|
|
184
|
+
pinnedColumns: pinnedColumns,
|
|
185
|
+
visibleColumns: params.columns,
|
|
186
|
+
firstColumnIndex: params.firstColumnIndex,
|
|
187
|
+
lastColumnIndex: params.lastColumnIndex,
|
|
188
|
+
focusedColumnIndex: params.focusedColumnIndex,
|
|
189
|
+
isFirstVisible: params.isFirstVisible,
|
|
190
|
+
isLastVisible: params.isLastVisible,
|
|
191
|
+
isNotVisible: params.isVirtualFocusRow,
|
|
192
|
+
showBottomBorder: params.showBottomBorder,
|
|
193
|
+
scrollbarWidth: verticalScrollbarWidth,
|
|
194
|
+
gridHasFiller: hasFiller
|
|
195
|
+
}, rootProps.slotProps?.row), params.id),
|
|
196
|
+
renderInfiniteLoadingTrigger: id => apiRef.current.getInfiniteLoadingTriggerElement?.({
|
|
197
|
+
lastRowId: id
|
|
198
|
+
})
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// HACK: Keep the grid's store in sync with the virtualizer store. We set up the
|
|
202
|
+
// subscription in the render phase rather than in an effect because other grid
|
|
203
|
+
// initialization code runs between those two moments.
|
|
204
|
+
//
|
|
205
|
+
// TODO(v9): Remove this
|
|
206
|
+
(0, _useFirstRender.useFirstRender)(() => {
|
|
207
|
+
apiRef.current.store.state.dimensions = virtualizer.store.state.dimensions;
|
|
208
|
+
apiRef.current.store.state.rowsMeta = virtualizer.store.state.rowsMeta;
|
|
209
|
+
apiRef.current.store.state.virtualization = virtualizer.store.state.virtualization;
|
|
210
|
+
});
|
|
211
|
+
(0, _store.useStoreEffect)(virtualizer.store, identity, (_, state) => {
|
|
212
|
+
if (state.dimensions !== apiRef.current.state.dimensions) {
|
|
213
|
+
apiRef.current.setState(gridState => (0, _extends2.default)({}, gridState, {
|
|
214
|
+
dimensions: state.dimensions
|
|
215
|
+
}));
|
|
216
|
+
}
|
|
217
|
+
if (state.rowsMeta !== apiRef.current.state.rowsMeta) {
|
|
218
|
+
apiRef.current.setState(gridState => (0, _extends2.default)({}, gridState, {
|
|
219
|
+
rowsMeta: state.rowsMeta
|
|
220
|
+
}));
|
|
221
|
+
}
|
|
222
|
+
if (state.virtualization !== apiRef.current.state.virtualization) {
|
|
223
|
+
apiRef.current.setState(gridState => (0, _extends2.default)({}, gridState, {
|
|
224
|
+
virtualization: state.virtualization
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
apiRef.current.register('private', {
|
|
229
|
+
virtualizer
|
|
230
|
+
});
|
|
231
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GridColumnGroup } from "../../../models/gridColumnGrouping.js";
|
|
1
|
+
import { GridColumnGroup, GridColumnGroupingModel } from "../../../models/gridColumnGrouping.js";
|
|
2
2
|
export type GridColumnGroupLookup = {
|
|
3
3
|
[groupId: string]: Omit<GridColumnGroup, 'children'>;
|
|
4
4
|
};
|
|
@@ -13,4 +13,7 @@ export interface GridColumnsGroupingState {
|
|
|
13
13
|
[columnField: string]: GridColumnGroup['groupId'][];
|
|
14
14
|
};
|
|
15
15
|
maxDepth: number;
|
|
16
|
+
}
|
|
17
|
+
export interface GridColumnGroupingInternalCache {
|
|
18
|
+
lastColumnGroupingModel?: GridColumnGroupingModel;
|
|
16
19
|
}
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.unwrapGroupingColumnModel = exports.getColumnGroupsHeaderStructure = void 0;
|
|
7
|
-
var _isDeepEqual = require("@mui/x-internals/isDeepEqual");
|
|
8
7
|
var _gridColumnGrouping = require("../../../models/gridColumnGrouping");
|
|
9
8
|
// This is the recurrence function that help writing `unwrapGroupingColumnModel()`
|
|
10
9
|
const recurrentUnwrapGroupingColumnModel = (columnGroupNode, parents, unwrappedGroupingModelToComplete) => {
|
|
@@ -44,45 +43,49 @@ exports.unwrapGroupingColumnModel = unwrapGroupingColumnModel;
|
|
|
44
43
|
const getColumnGroupsHeaderStructure = (orderedColumns, unwrappedGroupingModel, pinnedFields) => {
|
|
45
44
|
const getParents = field => unwrappedGroupingModel[field] ?? [];
|
|
46
45
|
const groupingHeaderStructure = [];
|
|
47
|
-
const maxDepth = Math.max(...orderedColumns.map(field => getParents(field).length));
|
|
48
|
-
const haveSameParents = (field1, field2, depth) =>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
const maxDepth = Math.max(0, ...orderedColumns.map(field => getParents(field).length));
|
|
47
|
+
const haveSameParents = (field1, field2, depth) => {
|
|
48
|
+
const a = getParents(field1);
|
|
49
|
+
const b = getParents(field2);
|
|
50
|
+
for (let i = 0; i <= depth; i += 1) {
|
|
51
|
+
if (a[i] !== b[i]) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
55
54
|
}
|
|
56
|
-
return
|
|
55
|
+
return true;
|
|
56
|
+
};
|
|
57
|
+
const haveDifferentContainers = (field1, field2) => {
|
|
58
|
+
const left = pinnedFields?.left;
|
|
59
|
+
const right = pinnedFields?.right;
|
|
60
|
+
const inLeft1 = !!left?.includes(field1);
|
|
61
|
+
const inLeft2 = !!left?.includes(field2);
|
|
62
|
+
const inRight1 = !!right?.includes(field1);
|
|
63
|
+
const inRight2 = !!right?.includes(field2);
|
|
64
|
+
return inLeft1 !== inLeft2 || inRight1 !== inRight2;
|
|
57
65
|
};
|
|
58
66
|
for (let depth = 0; depth < maxDepth; depth += 1) {
|
|
59
|
-
const depthStructure =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
const depthStructure = [];
|
|
68
|
+
for (let i = 0; i < orderedColumns.length; i += 1) {
|
|
69
|
+
const field = orderedColumns[i];
|
|
70
|
+
const groupId = getParents(field)[depth] ?? null;
|
|
71
|
+
if (depthStructure.length === 0) {
|
|
72
|
+
depthStructure.push({
|
|
73
|
+
columnFields: [field],
|
|
64
74
|
groupId
|
|
65
|
-
}
|
|
75
|
+
});
|
|
76
|
+
continue;
|
|
66
77
|
}
|
|
67
|
-
const lastGroup =
|
|
78
|
+
const lastGroup = depthStructure[depthStructure.length - 1];
|
|
68
79
|
const prevField = lastGroup.columnFields[lastGroup.columnFields.length - 1];
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
haveDifferentContainers(prevField, newField)) {
|
|
73
|
-
// It's a new group
|
|
74
|
-
return [...structure, {
|
|
75
|
-
columnFields: [newField],
|
|
80
|
+
if (lastGroup.groupId !== groupId || !haveSameParents(prevField, field, depth) || haveDifferentContainers(prevField, field)) {
|
|
81
|
+
depthStructure.push({
|
|
82
|
+
columnFields: [field],
|
|
76
83
|
groupId
|
|
77
|
-
}
|
|
84
|
+
});
|
|
85
|
+
} else {
|
|
86
|
+
lastGroup.columnFields.push(field);
|
|
78
87
|
}
|
|
79
|
-
|
|
80
|
-
// It extends the previous group
|
|
81
|
-
return [...structure.slice(0, structure.length - 1), {
|
|
82
|
-
columnFields: [...lastGroup.columnFields, newField],
|
|
83
|
-
groupId
|
|
84
|
-
}];
|
|
85
|
-
}, []);
|
|
88
|
+
}
|
|
86
89
|
groupingHeaderStructure.push(depthStructure);
|
|
87
90
|
}
|
|
88
91
|
return groupingHeaderStructure;
|
|
@@ -18,10 +18,11 @@ var _useGridEvent = require("../../utils/useGridEvent");
|
|
|
18
18
|
var _columns = require("../columns");
|
|
19
19
|
const _excluded = ["groupId", "children"];
|
|
20
20
|
const createGroupLookup = columnGroupingModel => {
|
|
21
|
-
|
|
22
|
-
columnGroupingModel.
|
|
21
|
+
const groupLookup = {};
|
|
22
|
+
for (let i = 0; i < columnGroupingModel.length; i += 1) {
|
|
23
|
+
const node = columnGroupingModel[i];
|
|
23
24
|
if ((0, _gridColumnGrouping.isLeaf)(node)) {
|
|
24
|
-
|
|
25
|
+
continue;
|
|
25
26
|
}
|
|
26
27
|
const {
|
|
27
28
|
groupId,
|
|
@@ -31,10 +32,8 @@ const createGroupLookup = columnGroupingModel => {
|
|
|
31
32
|
if (!groupId) {
|
|
32
33
|
throw new Error('MUI X: An element of the columnGroupingModel does not have either `field` or `groupId`.');
|
|
33
34
|
}
|
|
34
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
35
|
-
|
|
36
|
-
console.warn(`MUI X: group groupId=${groupId} has no children.`);
|
|
37
|
-
}
|
|
35
|
+
if (process.env.NODE_ENV !== 'production' && !children) {
|
|
36
|
+
console.warn(`MUI X: group groupId=${groupId} has no children.`);
|
|
38
37
|
}
|
|
39
38
|
const groupParam = (0, _extends2.default)({}, other, {
|
|
40
39
|
groupId
|
|
@@ -43,13 +42,15 @@ const createGroupLookup = columnGroupingModel => {
|
|
|
43
42
|
if (subTreeLookup[groupId] !== undefined || groupLookup[groupId] !== undefined) {
|
|
44
43
|
throw new Error(`MUI X: The groupId ${groupId} is used multiple times in the columnGroupingModel.`);
|
|
45
44
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return (0, _extends2.default)({}, groupLookup);
|
|
45
|
+
Object.assign(groupLookup, subTreeLookup);
|
|
46
|
+
groupLookup[groupId] = groupParam;
|
|
47
|
+
}
|
|
48
|
+
return groupLookup;
|
|
51
49
|
};
|
|
52
50
|
const columnGroupsStateInitializer = (state, props, apiRef) => {
|
|
51
|
+
apiRef.current.caches.columnGrouping = {
|
|
52
|
+
lastColumnGroupingModel: props.columnGroupingModel
|
|
53
|
+
};
|
|
53
54
|
if (!props.columnGroupingModel) {
|
|
54
55
|
return state;
|
|
55
56
|
}
|
|
@@ -105,6 +106,7 @@ const useGridColumnGrouping = (apiRef, props) => {
|
|
|
105
106
|
});
|
|
106
107
|
}, [apiRef, props.columnGroupingModel]);
|
|
107
108
|
const updateColumnGroupingState = React.useCallback(columnGroupingModel => {
|
|
109
|
+
apiRef.current.caches.columnGrouping.lastColumnGroupingModel = columnGroupingModel;
|
|
108
110
|
// @ts-expect-error Move this logic to `Pro` package
|
|
109
111
|
const pinnedColumns = apiRef.current.getPinnedColumns?.() ?? {};
|
|
110
112
|
const columnFields = (0, _columns.gridColumnFieldsSelector)(apiRef);
|
|
@@ -136,7 +138,10 @@ const useGridColumnGrouping = (apiRef, props) => {
|
|
|
136
138
|
* EFFECTS
|
|
137
139
|
*/
|
|
138
140
|
React.useEffect(() => {
|
|
141
|
+
if (props.columnGroupingModel === apiRef.current.caches.columnGrouping.lastColumnGroupingModel) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
139
144
|
updateColumnGroupingState(props.columnGroupingModel);
|
|
140
|
-
}, [updateColumnGroupingState, props.columnGroupingModel]);
|
|
145
|
+
}, [apiRef, updateColumnGroupingState, props.columnGroupingModel]);
|
|
141
146
|
};
|
|
142
147
|
exports.useGridColumnGrouping = useGridColumnGrouping;
|
|
@@ -31,7 +31,7 @@ export interface GetHeadersParams {
|
|
|
31
31
|
type OwnerState = DataGridProcessedProps;
|
|
32
32
|
export declare const GridColumnHeaderRow: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
33
33
|
ownerState: OwnerState;
|
|
34
|
-
}, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.
|
|
34
|
+
}, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
35
35
|
export declare const useGridColumnHeaders: (props: UseGridColumnHeadersProps) => {
|
|
36
36
|
renderContext: GridColumnsRenderContext;
|
|
37
37
|
leftRenderContext: {
|
|
@@ -11,6 +11,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
13
13
|
var _styles = require("@mui/material/styles");
|
|
14
|
+
var _xVirtualizer = require("@mui/x-virtualizer");
|
|
14
15
|
var _utils = require("../../utils");
|
|
15
16
|
var _useGridRootProps = require("../../utils/useGridRootProps");
|
|
16
17
|
var _useGridPrivateApiContext = require("../../utils/useGridPrivateApiContext");
|
|
@@ -18,7 +19,6 @@ var _useGridEvent = require("../../utils/useGridEvent");
|
|
|
18
19
|
var _GridColumnHeaderItem = require("../../../components/columnHeaders/GridColumnHeaderItem");
|
|
19
20
|
var _gridDimensionsSelectors = require("../dimensions/gridDimensionsSelectors");
|
|
20
21
|
var _virtualization = require("../virtualization");
|
|
21
|
-
var _useGridVirtualScroller = require("../virtualization/useGridVirtualScroller");
|
|
22
22
|
var _GridColumnGroupHeader = require("../../../components/columnHeaders/GridColumnGroupHeader");
|
|
23
23
|
var _columns = require("../columns");
|
|
24
24
|
var _gridColumnGroupsSelector = require("../columnGrouping/gridColumnGroupsSelector");
|
|
@@ -59,7 +59,7 @@ const useGridColumnHeaders = props => {
|
|
|
59
59
|
const renderContext = (0, _utils.useGridSelector)(apiRef, _virtualization.gridRenderContextColumnsSelector);
|
|
60
60
|
const pinnedColumns = (0, _utils.useGridSelector)(apiRef, _columns.gridVisiblePinnedColumnDefinitionsSelector);
|
|
61
61
|
const columnsLookup = (0, _utils.useGridSelector)(apiRef, _columns.gridColumnLookupSelector);
|
|
62
|
-
const offsetLeft = (0,
|
|
62
|
+
const offsetLeft = (0, _xVirtualizer.computeOffsetLeft)(columnPositions, renderContext, pinnedColumns.left.length);
|
|
63
63
|
const columnsTotalWidth = (0, _utils.useGridSelector)(apiRef, _gridDimensionsSelectors.gridColumnsTotalWidthSelector);
|
|
64
64
|
const gridHasFiller = (0, _utils.useGridSelector)(apiRef, _gridDimensionsSelectors.gridHasFillerSelector);
|
|
65
65
|
const headerHeight = (0, _utils.useGridSelector)(apiRef, _gridDimensionsSelectors.gridHeaderHeightSelector);
|
|
@@ -92,7 +92,8 @@ const useGridColumnHeaders = props => {
|
|
|
92
92
|
renderContext: currentContext = renderContext
|
|
93
93
|
} = params || {};
|
|
94
94
|
const firstColumnToRender = currentContext.firstColumnIndex;
|
|
95
|
-
|
|
95
|
+
// HACK: renderContext ins't always synchronized, this should be handled properly.
|
|
96
|
+
const lastColumnToRender = Math.min(currentContext.lastColumnIndex, visibleColumns.length);
|
|
96
97
|
const renderedColumns = visibleColumns.slice(firstColumnToRender, lastColumnToRender);
|
|
97
98
|
return {
|
|
98
99
|
renderedColumns,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GridColDef, GridStateColDef } from "../../../models/colDef/gridColDef.js";
|
|
1
|
+
import type { GridColDef, GridStateColDef } from "../../../models/colDef/gridColDef.js";
|
|
2
2
|
import type { GridColumnDimensionProperties } from "./gridColumnsUtils.js";
|
|
3
3
|
export declare enum GridPinnedColumnPosition {
|
|
4
4
|
LEFT = "left",
|
|
@@ -21,8 +21,8 @@ export interface GridPinnedColumnFields {
|
|
|
21
21
|
right?: string[];
|
|
22
22
|
}
|
|
23
23
|
export declare const EMPTY_PINNED_COLUMN_FIELDS: {
|
|
24
|
-
left:
|
|
25
|
-
right:
|
|
24
|
+
left: never[];
|
|
25
|
+
right: never[];
|
|
26
26
|
};
|
|
27
27
|
export interface GridPinnedColumns {
|
|
28
28
|
left: GridStateColDef[];
|
|
@@ -7,6 +7,7 @@ exports.gridVisiblePinnedColumnDefinitionsSelector = exports.gridVisibleColumnFi
|
|
|
7
7
|
var _createSelector = require("../../../utils/createSelector");
|
|
8
8
|
var _gridColumnsInterfaces = require("./gridColumnsInterfaces");
|
|
9
9
|
var _gridCoreSelector = require("../../core/gridCoreSelector");
|
|
10
|
+
var _listView = require("../listView");
|
|
10
11
|
/**
|
|
11
12
|
* Get the columns state
|
|
12
13
|
* @category Columns
|
|
@@ -50,7 +51,7 @@ const gridInitialColumnVisibilityModelSelector = exports.gridInitialColumnVisibi
|
|
|
50
51
|
* Get the visible columns as a lookup (an object containing the field for keys and the definition for values).
|
|
51
52
|
* @category Visible Columns
|
|
52
53
|
*/
|
|
53
|
-
const gridVisibleColumnDefinitionsSelector = exports.gridVisibleColumnDefinitionsSelector = (0, _createSelector.createSelectorMemoized)(gridColumnDefinitionsSelector, gridColumnVisibilityModelSelector, (columns, columnVisibilityModel) => columns.filter(column => columnVisibilityModel[column.field] !== false));
|
|
54
|
+
const gridVisibleColumnDefinitionsSelector = exports.gridVisibleColumnDefinitionsSelector = (0, _createSelector.createSelectorMemoized)(gridColumnDefinitionsSelector, gridColumnVisibilityModelSelector, _listView.gridListViewSelector, _listView.gridListColumnSelector, (columns, columnVisibilityModel, listView, listColumn) => listView && listColumn ? [listColumn] : columns.filter(column => columnVisibilityModel[column.field] !== false));
|
|
54
55
|
|
|
55
56
|
/**
|
|
56
57
|
* Get the field of each visible column.
|
|
@@ -75,7 +76,10 @@ const gridExistingPinnedColumnSelector = exports.gridExistingPinnedColumnSelecto
|
|
|
75
76
|
* Get the visible pinned columns.
|
|
76
77
|
* @category Visible Columns
|
|
77
78
|
*/
|
|
78
|
-
const gridVisiblePinnedColumnDefinitionsSelector = exports.gridVisiblePinnedColumnDefinitionsSelector = (0, _createSelector.createSelectorMemoized)(gridColumnsStateSelector, gridPinnedColumnsSelector, gridVisibleColumnFieldsSelector, _gridCoreSelector.gridIsRtlSelector, (columnsState, model, visibleColumnFields, isRtl) => {
|
|
79
|
+
const gridVisiblePinnedColumnDefinitionsSelector = exports.gridVisiblePinnedColumnDefinitionsSelector = (0, _createSelector.createSelectorMemoized)(gridColumnsStateSelector, gridPinnedColumnsSelector, gridVisibleColumnFieldsSelector, _gridCoreSelector.gridIsRtlSelector, _listView.gridListViewSelector, (columnsState, model, visibleColumnFields, isRtl, listView) => {
|
|
80
|
+
if (listView) {
|
|
81
|
+
return _gridColumnsInterfaces.EMPTY_PINNED_COLUMN_FIELDS;
|
|
82
|
+
}
|
|
79
83
|
const visiblePinnedFields = filterMissingColumns(model, visibleColumnFields, isRtl);
|
|
80
84
|
const visiblePinnedColumns = {
|
|
81
85
|
left: visiblePinnedFields.left.map(field => columnsState.lookup[field]),
|
|
@@ -257,11 +257,13 @@ const createColumnsState = ({
|
|
|
257
257
|
initialColumnVisibilityModel: updateInitialVisibilityModel ? columnVisibilityModel : currentState.initialColumnVisibilityModel
|
|
258
258
|
};
|
|
259
259
|
}
|
|
260
|
-
|
|
260
|
+
const columnsToKeep = {};
|
|
261
261
|
if (keepOnlyColumnsToUpsert && !isInsideStateInitializer) {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
262
|
+
for (const key in columnsState.lookup) {
|
|
263
|
+
if (Object.prototype.hasOwnProperty.call(columnsState.lookup, key)) {
|
|
264
|
+
columnsToKeep[key] = false;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
265
267
|
}
|
|
266
268
|
const columnsToUpsertLookup = {};
|
|
267
269
|
columnsToUpsert.forEach(newColumn => {
|