@mui/x-data-grid 8.0.0-alpha.10 → 8.0.0-alpha.11
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 +107 -2
- package/DataGrid/useDataGridComponent.js +2 -2
- package/components/GridRow.js +6 -2
- package/components/GridScrollArea.d.ts +5 -2
- package/components/GridScrollArea.js +31 -24
- package/components/GridSkeletonLoadingOverlay.js +2 -1
- package/components/containers/GridRoot.js +11 -9
- package/components/containers/GridRootStyles.js +3 -3
- package/components/menu/columnMenu/GridColumnMenuContainer.js +5 -2
- package/components/virtualization/GridMainContainer.d.ts +2 -2
- package/components/virtualization/GridMainContainer.js +1 -1
- package/components/virtualization/GridVirtualScroller.js +21 -14
- package/constants/index.d.ts +1 -0
- package/constants/index.js +2 -1
- package/constants/signature.d.ts +9 -0
- package/constants/signature.js +10 -0
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +1 -1
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +6 -4
- package/hooks/core/useGridApiInitialization.js +1 -1
- package/hooks/core/useGridStateInitialization.js +3 -2
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -14
- package/hooks/features/columns/gridColumnsSelector.d.ts +0 -5
- package/hooks/features/columns/gridColumnsSelector.js +0 -12
- package/hooks/features/columns/useGridColumns.js +2 -1
- package/hooks/features/dimensions/gridDimensionsSelectors.d.ts +16 -0
- package/hooks/features/dimensions/gridDimensionsSelectors.js +26 -1
- package/hooks/features/dimensions/index.d.ts +1 -1
- package/hooks/features/dimensions/index.js +1 -2
- package/hooks/features/dimensions/useGridDimensions.js +97 -70
- package/hooks/features/editing/gridEditingSelectors.d.ts +5 -1
- package/hooks/features/editing/gridEditingSelectors.js +6 -1
- package/hooks/features/editing/useGridRowEditing.js +4 -4
- package/hooks/features/filter/gridFilterSelector.d.ts +2 -2
- package/hooks/features/filter/gridFilterSelector.js +4 -3
- package/hooks/features/filter/gridFilterState.d.ts +8 -3
- package/hooks/features/filter/gridFilterState.js +5 -0
- package/hooks/features/filter/useGridFilter.js +9 -14
- package/hooks/features/overlays/useGridOverlays.js +1 -1
- package/hooks/features/pagination/gridPaginationUtils.js +1 -1
- package/hooks/features/pagination/useGridPagination.js +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +3 -2
- package/hooks/features/rowSelection/utils.js +2 -2
- package/hooks/features/rows/gridRowsMetaState.d.ts +8 -0
- package/hooks/features/rows/gridRowsUtils.d.ts +0 -4
- package/hooks/features/rows/gridRowsUtils.js +0 -16
- package/hooks/features/rows/useGridRows.js +4 -2
- package/hooks/features/rows/useGridRowsMeta.js +33 -17
- package/hooks/features/sorting/gridSortingSelector.js +10 -9
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +6 -0
- package/hooks/features/virtualization/useGridVirtualScroller.js +43 -27
- package/hooks/utils/index.d.ts +1 -1
- package/hooks/utils/index.js +1 -1
- package/hooks/utils/useGridApiEventHandler.d.ts +7 -17
- package/hooks/utils/useGridApiEventHandler.js +68 -75
- package/hooks/utils/useGridSelector.js +23 -5
- package/hooks/utils/useIsSSR.d.ts +1 -0
- package/hooks/utils/useIsSSR.js +5 -0
- package/index.js +1 -1
- package/internals/index.d.ts +3 -1
- package/internals/index.js +3 -1
- package/internals/utils/propValidation.js +1 -1
- package/models/api/gridStateApi.d.ts +1 -0
- package/models/events/gridEventLookup.d.ts +6 -0
- package/modern/DataGrid/useDataGridComponent.js +2 -2
- package/modern/components/GridRow.js +6 -2
- package/modern/components/GridScrollArea.js +31 -24
- package/modern/components/GridSkeletonLoadingOverlay.js +2 -1
- package/modern/components/containers/GridRoot.js +11 -9
- package/modern/components/containers/GridRootStyles.js +3 -3
- package/modern/components/menu/columnMenu/GridColumnMenuContainer.js +5 -2
- package/modern/components/virtualization/GridMainContainer.js +1 -1
- package/modern/components/virtualization/GridVirtualScroller.js +21 -14
- package/modern/constants/index.js +2 -1
- package/modern/constants/signature.js +10 -0
- package/modern/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +6 -4
- package/modern/hooks/core/useGridApiInitialization.js +1 -1
- package/modern/hooks/core/useGridStateInitialization.js +3 -2
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -14
- package/modern/hooks/features/columns/gridColumnsSelector.js +0 -12
- package/modern/hooks/features/columns/useGridColumns.js +2 -1
- package/modern/hooks/features/dimensions/gridDimensionsSelectors.js +26 -1
- package/modern/hooks/features/dimensions/index.js +1 -2
- package/modern/hooks/features/dimensions/useGridDimensions.js +97 -70
- package/modern/hooks/features/editing/gridEditingSelectors.js +6 -1
- package/modern/hooks/features/editing/useGridRowEditing.js +4 -4
- package/modern/hooks/features/filter/gridFilterSelector.js +4 -3
- package/modern/hooks/features/filter/gridFilterState.js +5 -0
- package/modern/hooks/features/filter/useGridFilter.js +9 -14
- package/modern/hooks/features/overlays/useGridOverlays.js +1 -1
- package/modern/hooks/features/pagination/gridPaginationUtils.js +1 -1
- package/modern/hooks/features/pagination/useGridPagination.js +1 -1
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +3 -2
- package/modern/hooks/features/rowSelection/utils.js +2 -2
- package/modern/hooks/features/rows/gridRowsUtils.js +0 -16
- package/modern/hooks/features/rows/useGridRows.js +4 -2
- package/modern/hooks/features/rows/useGridRowsMeta.js +33 -17
- package/modern/hooks/features/sorting/gridSortingSelector.js +10 -9
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +43 -27
- package/modern/hooks/utils/index.js +1 -1
- package/modern/hooks/utils/useGridApiEventHandler.js +68 -75
- package/modern/hooks/utils/useGridSelector.js +23 -5
- package/modern/hooks/utils/useIsSSR.js +5 -0
- package/modern/index.js +1 -1
- package/modern/internals/index.js +3 -1
- package/modern/internals/utils/propValidation.js +1 -1
- package/node/DataGrid/useDataGridComponent.js +2 -2
- package/node/components/GridRow.js +6 -2
- package/node/components/GridScrollArea.js +31 -24
- package/node/components/GridSkeletonLoadingOverlay.js +2 -1
- package/node/components/containers/GridRoot.js +10 -8
- package/node/components/containers/GridRootStyles.js +3 -3
- package/node/components/menu/columnMenu/GridColumnMenuContainer.js +5 -2
- package/node/components/virtualization/GridMainContainer.js +1 -1
- package/node/components/virtualization/GridVirtualScroller.js +21 -14
- package/node/constants/index.js +11 -0
- package/node/constants/signature.js +16 -0
- package/node/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +6 -4
- package/node/hooks/core/useGridApiInitialization.js +2 -2
- package/node/hooks/core/useGridStateInitialization.js +3 -2
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -14
- package/node/hooks/features/columns/gridColumnsSelector.js +1 -13
- package/node/hooks/features/columns/useGridColumns.js +2 -1
- package/node/hooks/features/dimensions/gridDimensionsSelectors.js +38 -2
- package/node/hooks/features/dimensions/index.js +13 -11
- package/node/hooks/features/dimensions/useGridDimensions.js +94 -67
- package/node/hooks/features/editing/gridEditingSelectors.js +5 -1
- package/node/hooks/features/editing/useGridRowEditing.js +4 -4
- package/node/hooks/features/filter/gridFilterSelector.js +4 -3
- package/node/hooks/features/filter/gridFilterState.js +6 -1
- package/node/hooks/features/filter/useGridFilter.js +8 -13
- package/node/hooks/features/overlays/useGridOverlays.js +1 -1
- package/node/hooks/features/pagination/gridPaginationUtils.js +2 -2
- package/node/hooks/features/pagination/useGridPagination.js +1 -1
- package/node/hooks/features/rowSelection/useGridRowSelection.js +5 -4
- package/node/hooks/features/rowSelection/utils.js +3 -3
- package/node/hooks/features/rows/gridRowsUtils.js +0 -17
- package/node/hooks/features/rows/useGridRows.js +6 -4
- package/node/hooks/features/rows/useGridRowsMeta.js +31 -15
- package/node/hooks/features/sorting/gridSortingSelector.js +10 -9
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +42 -26
- package/node/hooks/utils/index.js +21 -11
- package/node/hooks/utils/useGridApiEventHandler.js +71 -78
- package/node/hooks/utils/useGridSelector.js +23 -5
- package/node/hooks/utils/useIsSSR.js +12 -0
- package/node/index.js +1 -1
- package/node/internals/index.js +32 -7
- package/node/internals/utils/propValidation.js +2 -2
- package/package.json +3 -2
|
@@ -4,7 +4,6 @@ import { useGridApiMethod } from "../utils/index.js";
|
|
|
4
4
|
import { isFunction } from "../../utils/utils.js";
|
|
5
5
|
export const useGridStateInitialization = apiRef => {
|
|
6
6
|
const controlStateMapRef = React.useRef({});
|
|
7
|
-
const [, rawForceUpdate] = React.useState();
|
|
8
7
|
const registerControlState = React.useCallback(controlStateItem => {
|
|
9
8
|
controlStateMapRef.current[controlStateItem.stateId] = controlStateItem;
|
|
10
9
|
}, []);
|
|
@@ -79,7 +78,9 @@ export const useGridStateInitialization = apiRef => {
|
|
|
79
78
|
});
|
|
80
79
|
}, reason);
|
|
81
80
|
}, [apiRef]);
|
|
82
|
-
const forceUpdate = React.useCallback(() =>
|
|
81
|
+
const forceUpdate = React.useCallback(() => {
|
|
82
|
+
// @deprecated - do nothing
|
|
83
|
+
}, []);
|
|
83
84
|
const publicStateApi = {
|
|
84
85
|
setState,
|
|
85
86
|
forceUpdate
|
|
@@ -7,7 +7,7 @@ import { useGridRootProps } from "../../utils/useGridRootProps.js";
|
|
|
7
7
|
import { useGridPrivateApiContext } from "../../utils/useGridPrivateApiContext.js";
|
|
8
8
|
import { useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
|
|
9
9
|
import { GridColumnHeaderItem } from "../../../components/columnHeaders/GridColumnHeaderItem.js";
|
|
10
|
-
import {
|
|
10
|
+
import { gridColumnsTotalWidthSelector, gridGroupHeaderHeightSelector, gridHasFillerSelector, gridHeaderHeightSelector, gridVerticalScrollbarWidthSelector } from "../dimensions/gridDimensionsSelectors.js";
|
|
11
11
|
import { gridRenderContextColumnsSelector } from "../virtualization/index.js";
|
|
12
12
|
import { computeOffsetLeft } from "../virtualization/useGridVirtualScroller.js";
|
|
13
13
|
import { GridColumnGroupHeader } from "../../../components/columnHeaders/GridColumnGroupHeader.js";
|
|
@@ -46,19 +46,17 @@ export const useGridColumnHeaders = props => {
|
|
|
46
46
|
const [resizeCol, setResizeCol] = React.useState('');
|
|
47
47
|
const apiRef = useGridPrivateApiContext();
|
|
48
48
|
const rootProps = useGridRootProps();
|
|
49
|
-
const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
|
|
50
49
|
const columnGroupsModel = useGridSelector(apiRef, gridColumnGroupsUnwrappedModelSelector);
|
|
51
50
|
const columnPositions = useGridSelector(apiRef, gridColumnPositionsSelector);
|
|
52
51
|
const renderContext = useGridSelector(apiRef, gridRenderContextColumnsSelector);
|
|
53
52
|
const pinnedColumns = useGridSelector(apiRef, gridVisiblePinnedColumnDefinitionsSelector);
|
|
54
53
|
const columnsLookup = useGridSelector(apiRef, gridColumnLookupSelector);
|
|
55
54
|
const offsetLeft = computeOffsetLeft(columnPositions, renderContext, pinnedColumns.left.length);
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}, [apiRef]);
|
|
55
|
+
const columnsTotalWidth = useGridSelector(apiRef, gridColumnsTotalWidthSelector);
|
|
56
|
+
const gridHasFiller = useGridSelector(apiRef, gridHasFillerSelector);
|
|
57
|
+
const headerHeight = useGridSelector(apiRef, gridHeaderHeightSelector);
|
|
58
|
+
const groupHeaderHeight = useGridSelector(apiRef, gridGroupHeaderHeightSelector);
|
|
59
|
+
const scrollbarWidth = useGridSelector(apiRef, gridVerticalScrollbarWidthSelector);
|
|
62
60
|
const handleColumnResizeStart = React.useCallback(params => setResizeCol(params.field), []);
|
|
63
61
|
const handleColumnResizeStop = React.useCallback(() => setResizeCol(''), []);
|
|
64
62
|
const handleColumnReorderStart = React.useCallback(params => setDragCol(params.field), []);
|
|
@@ -130,8 +128,7 @@ export const useGridColumnHeaders = props => {
|
|
|
130
128
|
const hasFocus = columnHeaderFocus !== null && columnHeaderFocus.field === colDef.field;
|
|
131
129
|
const open = columnMenuState.open && columnMenuState.field === colDef.field;
|
|
132
130
|
const pinnedPosition = params?.position;
|
|
133
|
-
const
|
|
134
|
-
const pinnedOffset = getPinnedCellOffset(pinnedPosition, colDef.computedWidth, columnIndex, columnPositions, dimensions.columnsTotalWidth, scrollbarWidth);
|
|
131
|
+
const pinnedOffset = getPinnedCellOffset(pinnedPosition, colDef.computedWidth, columnIndex, columnPositions, columnsTotalWidth, scrollbarWidth);
|
|
135
132
|
const siblingWithBorderingSeparator = pinnedPosition === PinnedColumnPosition.RIGHT ? renderedColumns[i - 1] : renderedColumns[i + 1];
|
|
136
133
|
const isSiblingFocused = siblingWithBorderingSeparator ? columnHeaderFocus !== null && columnHeaderFocus.field === siblingWithBorderingSeparator.field : false;
|
|
137
134
|
const isLastUnpinned = columnIndex + 1 === columnPositions.length - pinnedColumns.right.length;
|
|
@@ -142,7 +139,7 @@ export const useGridColumnHeaders = props => {
|
|
|
142
139
|
columns.push(/*#__PURE__*/_jsx(GridColumnHeaderItem, _extends({}, sortColumnLookup[colDef.field], {
|
|
143
140
|
columnMenuOpen: open,
|
|
144
141
|
filterItemsCounter: filterColumnLookup[colDef.field] && filterColumnLookup[colDef.field].length,
|
|
145
|
-
headerHeight:
|
|
142
|
+
headerHeight: headerHeight,
|
|
146
143
|
isDragging: colDef.field === dragCol,
|
|
147
144
|
colDef: colDef,
|
|
148
145
|
colIndex: columnIndex,
|
|
@@ -234,8 +231,7 @@ export const useGridColumnHeaders = props => {
|
|
|
234
231
|
tabIndex
|
|
235
232
|
};
|
|
236
233
|
const pinnedPosition = params.position;
|
|
237
|
-
const
|
|
238
|
-
const pinnedOffset = getPinnedCellOffset(pinnedPosition, headerInfo.width, columnIndex, columnPositions, dimensions.columnsTotalWidth, scrollbarWidth);
|
|
234
|
+
const pinnedOffset = getPinnedCellOffset(pinnedPosition, headerInfo.width, columnIndex, columnPositions, columnsTotalWidth, scrollbarWidth);
|
|
239
235
|
columnIndex += columnFields.length;
|
|
240
236
|
let indexInSection = index;
|
|
241
237
|
if (pinnedPosition === PinnedColumnPosition.LEFT) {
|
|
@@ -250,7 +246,7 @@ export const useGridColumnHeaders = props => {
|
|
|
250
246
|
depth: depth,
|
|
251
247
|
isLastColumn: index === visibleColumnGroupHeader.length - 1,
|
|
252
248
|
maxDepth: headerGroupingMaxDepth,
|
|
253
|
-
height:
|
|
249
|
+
height: groupHeaderHeight,
|
|
254
250
|
hasFocus: hasFocus,
|
|
255
251
|
tabIndex: tabIndex,
|
|
256
252
|
pinnedPosition: pinnedPosition,
|
|
@@ -54,11 +54,6 @@ export declare const gridVisiblePinnedColumnDefinitionsSelector: import("../../.
|
|
|
54
54
|
* @category Visible Columns
|
|
55
55
|
*/
|
|
56
56
|
export declare const gridColumnPositionsSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../../internals").GridStateColDef[], number[]>;
|
|
57
|
-
/**
|
|
58
|
-
* Get the summed width of all the visible columns.
|
|
59
|
-
* @category Visible Columns
|
|
60
|
-
*/
|
|
61
|
-
export declare const gridColumnsTotalWidthSelector: import("../../..").OutputSelector<GridStateCommunity, number[], number>;
|
|
62
57
|
/**
|
|
63
58
|
* Get the filterable columns as an array.
|
|
64
59
|
* @category Columns
|
|
@@ -107,18 +107,6 @@ export const gridColumnPositionsSelector = createSelectorMemoized(gridVisibleCol
|
|
|
107
107
|
return positions;
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
-
/**
|
|
111
|
-
* Get the summed width of all the visible columns.
|
|
112
|
-
* @category Visible Columns
|
|
113
|
-
*/
|
|
114
|
-
export const gridColumnsTotalWidthSelector = createSelector(gridVisibleColumnDefinitionsSelector, gridColumnPositionsSelector, (visibleColumns, positions) => {
|
|
115
|
-
const colCount = visibleColumns.length;
|
|
116
|
-
if (colCount === 0) {
|
|
117
|
-
return 0;
|
|
118
|
-
}
|
|
119
|
-
return positions[colCount - 1] + visibleColumns[colCount - 1].computedWidth;
|
|
120
|
-
});
|
|
121
|
-
|
|
122
110
|
/**
|
|
123
111
|
* Get the filterable columns as an array.
|
|
124
112
|
* @category Columns
|
|
@@ -3,7 +3,8 @@ import * as React from 'react';
|
|
|
3
3
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
|
|
4
4
|
import { useGridLogger } from "../../utils/useGridLogger.js";
|
|
5
5
|
import { gridColumnFieldsSelector, gridColumnDefinitionsSelector, gridColumnLookupSelector, gridColumnsStateSelector, gridColumnVisibilityModelSelector, gridVisibleColumnDefinitionsSelector, gridColumnPositionsSelector } from "./gridColumnsSelector.js";
|
|
6
|
-
import { GridSignature
|
|
6
|
+
import { GridSignature } from "../../../constants/signature.js";
|
|
7
|
+
import { useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
|
|
7
8
|
import { useGridRegisterPipeProcessor, useGridRegisterPipeApplier } from "../../core/pipeProcessing/index.js";
|
|
8
9
|
import { EMPTY_PINNED_COLUMN_FIELDS } from "./gridColumnsInterfaces.js";
|
|
9
10
|
import { hydrateColumnsWidth, createColumnsState, COLUMNS_DIMENSION_PROPERTIES } from "./gridColumnsUtils.js";
|
|
@@ -1,2 +1,18 @@
|
|
|
1
1
|
import { GridStateCommunity } from '../../../models/gridStateCommunity';
|
|
2
2
|
export declare const gridDimensionsSelector: (state: GridStateCommunity) => import("./gridDimensionsApi").GridDimensions;
|
|
3
|
+
/**
|
|
4
|
+
* Get the summed width of all the visible columns.
|
|
5
|
+
* @category Visible Columns
|
|
6
|
+
*/
|
|
7
|
+
export declare const gridColumnsTotalWidthSelector: import("../../..").OutputSelector<GridStateCommunity, import("./gridDimensionsApi").GridDimensions, number>;
|
|
8
|
+
export declare const gridRowHeightSelector: (state: GridStateCommunity) => number;
|
|
9
|
+
export declare const gridContentHeightSelector: (state: GridStateCommunity) => number;
|
|
10
|
+
export declare const gridHasScrollXSelector: (state: GridStateCommunity) => boolean;
|
|
11
|
+
export declare const gridHasScrollYSelector: (state: GridStateCommunity) => boolean;
|
|
12
|
+
export declare const gridHasFillerSelector: (state: GridStateCommunity) => boolean;
|
|
13
|
+
export declare const gridHeaderHeightSelector: (state: GridStateCommunity) => number;
|
|
14
|
+
export declare const gridGroupHeaderHeightSelector: (state: GridStateCommunity) => number;
|
|
15
|
+
export declare const gridHeaderFilterHeightSelector: (state: GridStateCommunity) => number;
|
|
16
|
+
export declare const gridVerticalScrollbarWidthSelector: (state: GridStateCommunity) => number;
|
|
17
|
+
export declare const gridHorizontalScrollbarHeightSelector: (state: GridStateCommunity) => number;
|
|
18
|
+
export declare const gridHasBottomFillerSelector: (state: GridStateCommunity) => boolean;
|
|
@@ -1 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
import { createSelector } from "../../../utils/createSelector.js";
|
|
2
|
+
export const gridDimensionsSelector = state => state.dimensions;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get the summed width of all the visible columns.
|
|
6
|
+
* @category Visible Columns
|
|
7
|
+
*/
|
|
8
|
+
export const gridColumnsTotalWidthSelector = createSelector(gridDimensionsSelector, dimensions => dimensions.columnsTotalWidth);
|
|
9
|
+
export const gridRowHeightSelector = state => state.dimensions.rowHeight;
|
|
10
|
+
export const gridContentHeightSelector = state => state.dimensions.contentSize.height;
|
|
11
|
+
export const gridHasScrollXSelector = state => state.dimensions.hasScrollX;
|
|
12
|
+
export const gridHasScrollYSelector = state => state.dimensions.hasScrollY;
|
|
13
|
+
export const gridHasFillerSelector = state => state.dimensions.columnsTotalWidth < state.dimensions.viewportOuterSize.width;
|
|
14
|
+
export const gridHeaderHeightSelector = state => state.dimensions.headerHeight;
|
|
15
|
+
export const gridGroupHeaderHeightSelector = state => state.dimensions.groupHeaderHeight;
|
|
16
|
+
export const gridHeaderFilterHeightSelector = state => state.dimensions.headerFilterHeight;
|
|
17
|
+
export const gridVerticalScrollbarWidthSelector = state => state.dimensions.hasScrollY ? state.dimensions.scrollbarSize : 0;
|
|
18
|
+
export const gridHorizontalScrollbarHeightSelector = state => state.dimensions.hasScrollX ? state.dimensions.scrollbarSize : 0;
|
|
19
|
+
export const gridHasBottomFillerSelector = state => {
|
|
20
|
+
const height = state.dimensions.hasScrollX ? state.dimensions.scrollbarSize : 0;
|
|
21
|
+
const needsLastRowBorder = state.dimensions.viewportOuterSize.height - state.dimensions.minimumSize.height > 0;
|
|
22
|
+
if (height === 0 && !needsLastRowBorder) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export type { GridDimensionsState } from './useGridDimensions';
|
|
2
|
-
export
|
|
2
|
+
export { gridDimensionsSelector, gridColumnsTotalWidthSelector } from './gridDimensionsSelectors';
|
|
3
3
|
export type { GridDimensions, GridDimensionsApi } from './gridDimensionsApi';
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {};
|
|
1
|
+
export { gridDimensionsSelector, gridColumnsTotalWidthSelector } from "./gridDimensionsSelectors.js";
|
|
@@ -2,21 +2,23 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { unstable_ownerDocument as ownerDocument, unstable_useEnhancedEffect as useEnhancedEffect, unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
4
4
|
import { throttle } from '@mui/x-internals/throttle';
|
|
5
|
-
import {
|
|
5
|
+
import { useGridApiOptionHandler } from "../../utils/useGridApiEventHandler.js";
|
|
6
6
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
|
|
7
|
+
import { createSelector } from "../../../utils/createSelector.js";
|
|
7
8
|
import { useGridLogger } from "../../utils/useGridLogger.js";
|
|
8
|
-
import {
|
|
9
|
+
import { gridColumnPositionsSelector, gridVisibleColumnDefinitionsSelector, gridVisiblePinnedColumnDefinitionsSelector } from "../columns/index.js";
|
|
9
10
|
import { gridDimensionsSelector } from "./gridDimensionsSelectors.js";
|
|
10
11
|
import { gridDensityFactorSelector } from "../density/index.js";
|
|
11
12
|
import { gridRenderContextSelector } from "../virtualization/index.js";
|
|
12
13
|
import { useGridSelector } from "../../utils/index.js";
|
|
13
14
|
import { getVisibleRows } from "../../utils/useGridVisibleRows.js";
|
|
14
15
|
import { gridRowsMetaSelector } from "../rows/gridRowsMetaSelector.js";
|
|
15
|
-
import {
|
|
16
|
+
import { getValidRowHeight, rowHeightWarning } from "../rows/gridRowsUtils.js";
|
|
16
17
|
import { getTotalHeaderHeight } from "../columns/gridColumnsUtils.js";
|
|
17
18
|
import { DATA_GRID_PROPS_DEFAULT_VALUES } from "../../../constants/dataGridPropsDefaultValues.js";
|
|
18
19
|
import { roundToDecimalPlaces } from "../../../utils/roundToDecimalPlaces.js";
|
|
19
20
|
import { isJSDOM } from "../../../utils/isJSDOM.js";
|
|
21
|
+
import { isDeepEqual } from "../../../utils/utils.js";
|
|
20
22
|
const EMPTY_SIZE = {
|
|
21
23
|
width: 0,
|
|
22
24
|
height: 0
|
|
@@ -43,47 +45,52 @@ const EMPTY_DIMENSIONS = {
|
|
|
43
45
|
topContainerHeight: 0,
|
|
44
46
|
bottomContainerHeight: 0
|
|
45
47
|
};
|
|
46
|
-
export const dimensionsStateInitializer = state => {
|
|
48
|
+
export const dimensionsStateInitializer = (state, props, apiRef) => {
|
|
47
49
|
const dimensions = EMPTY_DIMENSIONS;
|
|
50
|
+
const density = gridDensityFactorSelector(apiRef);
|
|
48
51
|
return _extends({}, state, {
|
|
49
|
-
dimensions
|
|
52
|
+
dimensions: _extends({}, dimensions, getStaticDimensions(props, apiRef, density, gridVisiblePinnedColumnDefinitionsSelector(apiRef)))
|
|
50
53
|
});
|
|
51
54
|
};
|
|
55
|
+
const columnsTotalWidthSelector = createSelector(gridVisibleColumnDefinitionsSelector, gridColumnPositionsSelector, (visibleColumns, positions) => {
|
|
56
|
+
const colCount = visibleColumns.length;
|
|
57
|
+
if (colCount === 0) {
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
return roundToDecimalPlaces(positions[colCount - 1] + visibleColumns[colCount - 1].computedWidth, 1);
|
|
61
|
+
});
|
|
52
62
|
export function useGridDimensions(apiRef, props) {
|
|
53
63
|
const logger = useGridLogger(apiRef, 'useResizeContainer');
|
|
54
64
|
const errorShown = React.useRef(false);
|
|
55
65
|
const rootDimensionsRef = React.useRef(EMPTY_SIZE);
|
|
56
|
-
const dimensionsState = useGridSelector(apiRef, gridDimensionsSelector);
|
|
57
|
-
const rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
|
|
58
66
|
const pinnedColumns = useGridSelector(apiRef, gridVisiblePinnedColumnDefinitionsSelector);
|
|
59
67
|
const densityFactor = useGridSelector(apiRef, gridDensityFactorSelector);
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
React.
|
|
72
|
-
const
|
|
73
|
-
const setDimensions = useEventCallback(dimensions => {
|
|
68
|
+
const columnsTotalWidth = useGridSelector(apiRef, columnsTotalWidthSelector);
|
|
69
|
+
const isFirstSizing = React.useRef(true);
|
|
70
|
+
const {
|
|
71
|
+
rowHeight,
|
|
72
|
+
headerHeight,
|
|
73
|
+
groupHeaderHeight,
|
|
74
|
+
headerFilterHeight,
|
|
75
|
+
headersTotalHeight,
|
|
76
|
+
leftPinnedWidth,
|
|
77
|
+
rightPinnedWidth
|
|
78
|
+
} = getStaticDimensions(props, apiRef, densityFactor, pinnedColumns);
|
|
79
|
+
const getRootDimensions = React.useCallback(() => gridDimensionsSelector(apiRef.current.state), [apiRef]);
|
|
80
|
+
const setDimensions = React.useCallback(dimensions => {
|
|
74
81
|
apiRef.current.setState(state => _extends({}, state, {
|
|
75
82
|
dimensions
|
|
76
83
|
}));
|
|
77
|
-
|
|
84
|
+
if (apiRef.current.rootElementRef.current) {
|
|
85
|
+
setCSSVariables(apiRef.current.rootElementRef.current, gridDimensionsSelector(apiRef.current.state));
|
|
86
|
+
}
|
|
87
|
+
}, [apiRef]);
|
|
78
88
|
const getViewportPageSize = React.useCallback(() => {
|
|
79
89
|
const dimensions = gridDimensionsSelector(apiRef.current.state);
|
|
80
90
|
if (!dimensions.isReady) {
|
|
81
91
|
return 0;
|
|
82
92
|
}
|
|
83
|
-
const currentPage = getVisibleRows(apiRef
|
|
84
|
-
pagination: props.pagination,
|
|
85
|
-
paginationMode: props.paginationMode
|
|
86
|
-
});
|
|
93
|
+
const currentPage = getVisibleRows(apiRef);
|
|
87
94
|
|
|
88
95
|
// TODO: Use a combination of scrollTop, dimensions.viewportInnerSize.height and rowsMeta.possitions
|
|
89
96
|
// to find out the maximum number of rows that can fit in the visible part of the grid
|
|
@@ -94,16 +101,19 @@ export function useGridDimensions(apiRef, props) {
|
|
|
94
101
|
}
|
|
95
102
|
const maximumPageSizeWithoutScrollBar = Math.floor(dimensions.viewportInnerSize.height / rowHeight);
|
|
96
103
|
return Math.min(maximumPageSizeWithoutScrollBar, currentPage.rows.length);
|
|
97
|
-
}, [apiRef, props.
|
|
104
|
+
}, [apiRef, props.getRowHeight, rowHeight]);
|
|
98
105
|
const updateDimensions = React.useCallback(() => {
|
|
106
|
+
if (isFirstSizing.current) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
99
109
|
// All the floating point dimensions should be rounded to .1 decimal places to avoid subpixel rendering issues
|
|
100
110
|
// https://github.com/mui/mui-x/issues/9550#issuecomment-1619020477
|
|
101
111
|
// https://github.com/mui/mui-x/issues/15721
|
|
102
112
|
const rootElement = apiRef.current.rootElementRef.current;
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
const topContainerHeight = headersTotalHeight +
|
|
106
|
-
const bottomContainerHeight =
|
|
113
|
+
const scrollbarSize = measureScrollbarSize(rootElement, props.scrollbarSize);
|
|
114
|
+
const rowsMeta = gridRowsMetaSelector(apiRef.current.state);
|
|
115
|
+
const topContainerHeight = headersTotalHeight + rowsMeta.pinnedTopRowsTotalHeight;
|
|
116
|
+
const bottomContainerHeight = rowsMeta.pinnedBottomRowsTotalHeight;
|
|
107
117
|
const contentSize = {
|
|
108
118
|
width: columnsTotalWidth,
|
|
109
119
|
height: roundToDecimalPlaces(rowsMeta.currentPageTotalHeight, 1)
|
|
@@ -180,12 +190,21 @@ export function useGridDimensions(apiRef, props) {
|
|
|
180
190
|
bottomContainerHeight
|
|
181
191
|
};
|
|
182
192
|
const prevDimensions = apiRef.current.state.dimensions;
|
|
193
|
+
if (isDeepEqual(prevDimensions, newDimensions)) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
183
196
|
setDimensions(newDimensions);
|
|
184
197
|
if (!areElementSizesEqual(newDimensions.viewportInnerSize, prevDimensions.viewportInnerSize)) {
|
|
185
198
|
apiRef.current.publishEvent('viewportInnerSizeChange', newDimensions.viewportInnerSize);
|
|
186
199
|
}
|
|
187
200
|
apiRef.current.updateRenderContext?.();
|
|
188
|
-
}, [apiRef, setDimensions, props.scrollbarSize, props.autoHeight,
|
|
201
|
+
}, [apiRef, setDimensions, props.scrollbarSize, props.autoHeight, rowHeight, headerHeight, groupHeaderHeight, headerFilterHeight, columnsTotalWidth, headersTotalHeight, leftPinnedWidth, rightPinnedWidth]);
|
|
202
|
+
const updateDimensionCallback = useEventCallback(updateDimensions);
|
|
203
|
+
const debouncedUpdateDimensions = React.useMemo(() => props.resizeThrottleMs > 0 ? throttle(() => {
|
|
204
|
+
updateDimensionCallback();
|
|
205
|
+
apiRef.current.publishEvent('debouncedResize', rootDimensionsRef.current);
|
|
206
|
+
}, props.resizeThrottleMs) : undefined, [apiRef, props.resizeThrottleMs, updateDimensionCallback]);
|
|
207
|
+
React.useEffect(() => debouncedUpdateDimensions?.clear, [debouncedUpdateDimensions]);
|
|
189
208
|
const apiPublic = {
|
|
190
209
|
getRootDimensions
|
|
191
210
|
};
|
|
@@ -193,35 +212,12 @@ export function useGridDimensions(apiRef, props) {
|
|
|
193
212
|
updateDimensions,
|
|
194
213
|
getViewportPageSize
|
|
195
214
|
};
|
|
215
|
+
useEnhancedEffect(updateDimensions, [updateDimensions]);
|
|
196
216
|
useGridApiMethod(apiRef, apiPublic, 'public');
|
|
197
217
|
useGridApiMethod(apiRef, apiPrivate, 'private');
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
apiRef.current.publishEvent('debouncedResize', rootDimensionsRef.current);
|
|
202
|
-
}
|
|
203
|
-
}, [apiRef, savedSize, updateDimensions]);
|
|
204
|
-
const root = apiRef.current.rootElementRef.current;
|
|
205
|
-
useEnhancedEffect(() => {
|
|
206
|
-
if (!root) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
const set = (k, v) => root.style.setProperty(k, v);
|
|
210
|
-
set('--DataGrid-width', `${dimensionsState.viewportOuterSize.width}px`);
|
|
211
|
-
set('--DataGrid-hasScrollX', `${Number(dimensionsState.hasScrollX)}`);
|
|
212
|
-
set('--DataGrid-hasScrollY', `${Number(dimensionsState.hasScrollY)}`);
|
|
213
|
-
set('--DataGrid-scrollbarSize', `${dimensionsState.scrollbarSize}px`);
|
|
214
|
-
set('--DataGrid-rowWidth', `${dimensionsState.rowWidth}px`);
|
|
215
|
-
set('--DataGrid-columnsTotalWidth', `${dimensionsState.columnsTotalWidth}px`);
|
|
216
|
-
set('--DataGrid-leftPinnedWidth', `${dimensionsState.leftPinnedWidth}px`);
|
|
217
|
-
set('--DataGrid-rightPinnedWidth', `${dimensionsState.rightPinnedWidth}px`);
|
|
218
|
-
set('--DataGrid-headerHeight', `${dimensionsState.headerHeight}px`);
|
|
219
|
-
set('--DataGrid-headersTotalHeight', `${dimensionsState.headersTotalHeight}px`);
|
|
220
|
-
set('--DataGrid-topContainerHeight', `${dimensionsState.topContainerHeight}px`);
|
|
221
|
-
set('--DataGrid-bottomContainerHeight', `${dimensionsState.bottomContainerHeight}px`);
|
|
222
|
-
set('--height', `${dimensionsState.rowHeight}px`);
|
|
223
|
-
}, [root, dimensionsState]);
|
|
224
|
-
const isFirstSizing = React.useRef(true);
|
|
218
|
+
const handleRootMount = React.useCallback(root => {
|
|
219
|
+
setCSSVariables(root, gridDimensionsSelector(apiRef.current.state));
|
|
220
|
+
}, [apiRef]);
|
|
225
221
|
const handleResize = React.useCallback(size => {
|
|
226
222
|
rootDimensionsRef.current = size;
|
|
227
223
|
if (size.height === 0 && !errorShown.current && !props.autoHeight && !isJSDOM) {
|
|
@@ -232,28 +228,58 @@ export function useGridDimensions(apiRef, props) {
|
|
|
232
228
|
logger.error(['The parent DOM element of the Data Grid has an empty width.', 'Please make sure that this element has an intrinsic width.', 'The grid displays with a width of 0px.', '', 'More details: https://mui.com/r/x-data-grid-no-dimensions.'].join('\n'));
|
|
233
229
|
errorShown.current = true;
|
|
234
230
|
}
|
|
235
|
-
if (isFirstSizing.current) {
|
|
231
|
+
if (isFirstSizing.current || !debouncedUpdateDimensions) {
|
|
236
232
|
// We want to initialize the grid dimensions as soon as possible to avoid flickering
|
|
237
|
-
setSavedSize(size);
|
|
238
233
|
isFirstSizing.current = false;
|
|
234
|
+
updateDimensions();
|
|
239
235
|
return;
|
|
240
236
|
}
|
|
241
|
-
|
|
242
|
-
}, [props.autoHeight,
|
|
243
|
-
|
|
244
|
-
useGridApiOptionHandler(apiRef, '
|
|
245
|
-
useGridApiOptionHandler(apiRef, 'paginationModelChange', updateDimensions);
|
|
246
|
-
useGridApiOptionHandler(apiRef, 'columnsChange', updateDimensions);
|
|
247
|
-
useGridApiEventHandler(apiRef, 'resize', handleResize);
|
|
237
|
+
debouncedUpdateDimensions();
|
|
238
|
+
}, [updateDimensions, props.autoHeight, debouncedUpdateDimensions, logger]);
|
|
239
|
+
useGridApiOptionHandler(apiRef, 'rootMount', handleRootMount);
|
|
240
|
+
useGridApiOptionHandler(apiRef, 'resize', handleResize);
|
|
248
241
|
useGridApiOptionHandler(apiRef, 'debouncedResize', props.onResize);
|
|
249
242
|
}
|
|
250
|
-
function
|
|
243
|
+
function setCSSVariables(root, dimensions) {
|
|
244
|
+
const set = (k, v) => root.style.setProperty(k, v);
|
|
245
|
+
set('--DataGrid-hasScrollX', `${Number(dimensions.hasScrollX)}`);
|
|
246
|
+
set('--DataGrid-hasScrollY', `${Number(dimensions.hasScrollY)}`);
|
|
247
|
+
set('--DataGrid-scrollbarSize', `${dimensions.scrollbarSize}px`);
|
|
248
|
+
set('--DataGrid-rowWidth', `${dimensions.rowWidth}px`);
|
|
249
|
+
set('--DataGrid-columnsTotalWidth', `${dimensions.columnsTotalWidth}px`);
|
|
250
|
+
set('--DataGrid-leftPinnedWidth', `${dimensions.leftPinnedWidth}px`);
|
|
251
|
+
set('--DataGrid-rightPinnedWidth', `${dimensions.rightPinnedWidth}px`);
|
|
252
|
+
set('--DataGrid-headerHeight', `${dimensions.headerHeight}px`);
|
|
253
|
+
set('--DataGrid-headersTotalHeight', `${dimensions.headersTotalHeight}px`);
|
|
254
|
+
set('--DataGrid-topContainerHeight', `${dimensions.topContainerHeight}px`);
|
|
255
|
+
set('--DataGrid-bottomContainerHeight', `${dimensions.bottomContainerHeight}px`);
|
|
256
|
+
set('--height', `${dimensions.rowHeight}px`);
|
|
257
|
+
}
|
|
258
|
+
function getStaticDimensions(props, apiRef, density, pinnedColumnns) {
|
|
259
|
+
const validRowHeight = getValidRowHeight(props.rowHeight, DATA_GRID_PROPS_DEFAULT_VALUES.rowHeight, rowHeightWarning);
|
|
260
|
+
return {
|
|
261
|
+
rowHeight: Math.floor(validRowHeight * density),
|
|
262
|
+
headerHeight: Math.floor(props.columnHeaderHeight * density),
|
|
263
|
+
groupHeaderHeight: Math.floor((props.columnGroupHeaderHeight ?? props.columnHeaderHeight) * density),
|
|
264
|
+
headerFilterHeight: Math.floor((props.headerFilterHeight ?? props.columnHeaderHeight) * density),
|
|
265
|
+
columnsTotalWidth: columnsTotalWidthSelector(apiRef),
|
|
266
|
+
headersTotalHeight: getTotalHeaderHeight(apiRef, props),
|
|
267
|
+
leftPinnedWidth: pinnedColumnns.left.reduce((w, col) => w + col.computedWidth, 0),
|
|
268
|
+
rightPinnedWidth: pinnedColumnns.right.reduce((w, col) => w + col.computedWidth, 0)
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
const scrollbarSizeCache = new WeakMap();
|
|
272
|
+
function measureScrollbarSize(rootElement, scrollbarSize) {
|
|
251
273
|
if (scrollbarSize !== undefined) {
|
|
252
274
|
return scrollbarSize;
|
|
253
275
|
}
|
|
254
|
-
if (rootElement === null
|
|
276
|
+
if (rootElement === null) {
|
|
255
277
|
return 0;
|
|
256
278
|
}
|
|
279
|
+
const cachedSize = scrollbarSizeCache.get(rootElement);
|
|
280
|
+
if (cachedSize !== undefined) {
|
|
281
|
+
return cachedSize;
|
|
282
|
+
}
|
|
257
283
|
const doc = ownerDocument(rootElement);
|
|
258
284
|
const scrollDiv = doc.createElement('div');
|
|
259
285
|
scrollDiv.style.width = '99px';
|
|
@@ -264,6 +290,7 @@ function measureScrollbarSize(rootElement, columnsTotalWidth, scrollbarSize) {
|
|
|
264
290
|
rootElement.appendChild(scrollDiv);
|
|
265
291
|
const size = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
|
266
292
|
rootElement.removeChild(scrollDiv);
|
|
293
|
+
scrollbarSizeCache.set(rootElement, size);
|
|
267
294
|
return size;
|
|
268
295
|
}
|
|
269
296
|
function areElementSizesEqual(a, b) {
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { GridStateCommunity } from '../../../models/gridStateCommunity';
|
|
2
2
|
import { GridRowId } from '../../../models/gridRows';
|
|
3
|
+
import { GridEditMode } from '../../../models/gridEditRowModel';
|
|
3
4
|
/**
|
|
4
5
|
* Select the row editing state.
|
|
5
6
|
*/
|
|
6
7
|
export declare const gridEditRowsStateSelector: (state: GridStateCommunity) => import("../../..").GridEditingState;
|
|
7
|
-
export declare const gridRowIsEditingSelector: import("../../..").OutputSelector<GridStateCommunity,
|
|
8
|
+
export declare const gridRowIsEditingSelector: import("../../..").OutputSelector<GridStateCommunity, {
|
|
9
|
+
rowId: GridRowId;
|
|
10
|
+
editMode: GridEditMode;
|
|
11
|
+
}, boolean>;
|
|
8
12
|
export declare const gridEditCellStateSelector: import("../../..").OutputSelector<GridStateCommunity, {
|
|
9
13
|
rowId: GridRowId;
|
|
10
14
|
field: string;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { createSelector } from "../../../utils/createSelector.js";
|
|
2
|
+
import { GridEditModes } from "../../../models/gridEditRowModel.js";
|
|
3
|
+
|
|
2
4
|
/**
|
|
3
5
|
* Select the row editing state.
|
|
4
6
|
*/
|
|
5
7
|
export const gridEditRowsStateSelector = state => state.editRows;
|
|
6
|
-
export const gridRowIsEditingSelector = createSelector(gridEditRowsStateSelector, (editRows,
|
|
8
|
+
export const gridRowIsEditingSelector = createSelector(gridEditRowsStateSelector, (editRows, {
|
|
9
|
+
rowId,
|
|
10
|
+
editMode
|
|
11
|
+
}) => editMode === GridEditModes.Row && Boolean(editRows[rowId]));
|
|
7
12
|
export const gridEditCellStateSelector = createSelector(gridEditRowsStateSelector, (editRows, {
|
|
8
13
|
rowId,
|
|
9
14
|
field
|
|
@@ -232,10 +232,10 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
232
232
|
useGridApiOptionHandler(apiRef, 'rowEditStart', props.onRowEditStart);
|
|
233
233
|
useGridApiOptionHandler(apiRef, 'rowEditStop', props.onRowEditStop);
|
|
234
234
|
const getRowMode = React.useCallback(id => {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
235
|
+
const isEditing = gridRowIsEditingSelector(apiRef.current.state, {
|
|
236
|
+
rowId: id,
|
|
237
|
+
editMode: props.editMode
|
|
238
|
+
});
|
|
239
239
|
return isEditing ? GridRowModes.Edit : GridRowModes.View;
|
|
240
240
|
}, [apiRef, props.editMode]);
|
|
241
241
|
const updateRowModesModel = useEventCallback(newModel => {
|
|
@@ -20,7 +20,7 @@ export declare const gridVisibleRowsLookupSelector: (state: GridStateCommunity)
|
|
|
20
20
|
* @category Filtering
|
|
21
21
|
* @ignore - do not document.
|
|
22
22
|
*/
|
|
23
|
-
export declare const gridFilteredRowsLookupSelector: import("../../..").OutputSelector<GridStateCommunity, import("./gridFilterState").GridFilterState, Record<GridRowId,
|
|
23
|
+
export declare const gridFilteredRowsLookupSelector: import("../../..").OutputSelector<GridStateCommunity, import("./gridFilterState").GridFilterState, Record<GridRowId, false>>;
|
|
24
24
|
/**
|
|
25
25
|
* @category Filtering
|
|
26
26
|
* @ignore - do not document.
|
|
@@ -36,7 +36,7 @@ export declare const gridFilteredDescendantCountLookupSelector: import("../../..
|
|
|
36
36
|
* Does not contain the collapsed children.
|
|
37
37
|
* @category Filtering
|
|
38
38
|
*/
|
|
39
|
-
export declare const gridExpandedSortedRowEntriesSelector: import("../../..").OutputSelector<GridStateCommunity,
|
|
39
|
+
export declare const gridExpandedSortedRowEntriesSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridRowEntry<import("../../..").GridValidRowModel>[], import("../../..").GridRowEntry<import("../../..").GridValidRowModel>[]>;
|
|
40
40
|
/**
|
|
41
41
|
* Get the id of the rows accessible after the filtering process.
|
|
42
42
|
* Does not contain the collapsed children.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isObjectEmpty } from '@mui/x-internals/isObjectEmpty';
|
|
1
2
|
import { createSelector, createSelectorMemoized } from "../../../utils/createSelector.js";
|
|
2
3
|
import { gridSortedRowEntriesSelector } from "../sorting/gridSortingSelector.js";
|
|
3
4
|
import { gridColumnLookupSelector } from "../columns/gridColumnsSelector.js";
|
|
@@ -49,8 +50,8 @@ export const gridFilteredDescendantCountLookupSelector = createSelector(gridFilt
|
|
|
49
50
|
* Does not contain the collapsed children.
|
|
50
51
|
* @category Filtering
|
|
51
52
|
*/
|
|
52
|
-
export const gridExpandedSortedRowEntriesSelector = createSelectorMemoized(gridVisibleRowsLookupSelector, gridSortedRowEntriesSelector,
|
|
53
|
-
if (
|
|
53
|
+
export const gridExpandedSortedRowEntriesSelector = createSelectorMemoized(gridVisibleRowsLookupSelector, gridSortedRowEntriesSelector, (visibleRowsLookup, sortedRows) => {
|
|
54
|
+
if (isObjectEmpty(visibleRowsLookup)) {
|
|
54
55
|
return sortedRows;
|
|
55
56
|
}
|
|
56
57
|
return sortedRows.filter(row => visibleRowsLookup[row.id] !== false);
|
|
@@ -68,7 +69,7 @@ export const gridExpandedSortedRowIdsSelector = createSelectorMemoized(gridExpan
|
|
|
68
69
|
* Contains the collapsed children.
|
|
69
70
|
* @category Filtering
|
|
70
71
|
*/
|
|
71
|
-
export const gridFilteredSortedRowEntriesSelector = createSelectorMemoized(gridFilteredRowsLookupSelector, gridSortedRowEntriesSelector, (filteredRowsLookup, sortedRows) => sortedRows.filter(row => filteredRowsLookup[row.id] !== false));
|
|
72
|
+
export const gridFilteredSortedRowEntriesSelector = createSelectorMemoized(gridFilteredRowsLookupSelector, gridSortedRowEntriesSelector, (filteredRowsLookup, sortedRows) => isObjectEmpty(filteredRowsLookup) ? sortedRows : sortedRows.filter(row => filteredRowsLookup[row.id] !== false));
|
|
72
73
|
|
|
73
74
|
/**
|
|
74
75
|
* Get the id of the rows accessible after the filtering process.
|
|
@@ -7,16 +7,21 @@ export type GridFilterItemResult = {
|
|
|
7
7
|
export type GridQuickFilterValueResult = {
|
|
8
8
|
[key: string]: boolean;
|
|
9
9
|
};
|
|
10
|
+
export declare const defaultGridFilterLookup: {
|
|
11
|
+
filteredRowsLookup: {};
|
|
12
|
+
filteredChildrenCountLookup: {};
|
|
13
|
+
filteredDescendantCountLookup: {};
|
|
14
|
+
};
|
|
10
15
|
export declare const getDefaultGridFilterModel: () => GridFilterModel;
|
|
11
16
|
export interface GridFilterState {
|
|
12
17
|
filterModel: GridFilterModel;
|
|
13
18
|
/**
|
|
14
19
|
* Filtering status for each row.
|
|
15
20
|
* A row is filtered if it is passing the filters, whether its parents are expanded or not.
|
|
16
|
-
*
|
|
21
|
+
* All the rows are filtered except the ones registered in this lookup with `false` values.
|
|
17
22
|
* This is the equivalent of the `visibleRowsLookup` if all the groups were expanded.
|
|
18
23
|
*/
|
|
19
|
-
filteredRowsLookup: Record<GridRowId,
|
|
24
|
+
filteredRowsLookup: Record<GridRowId, false>;
|
|
20
25
|
/**
|
|
21
26
|
* Amount of children that are passing the filters or have children that are passing the filter (does not count grand children).
|
|
22
27
|
* If a row is not registered in this lookup, it is supposed to have no descendant passing the filters.
|
|
@@ -53,4 +58,4 @@ export type GridFilteringMethodValue = Omit<GridFilterState, 'filterModel'>;
|
|
|
53
58
|
* A row is visible if it is passing the filters AND if its parents are expanded.
|
|
54
59
|
* If a row is not registered in this lookup, it is visible.
|
|
55
60
|
*/
|
|
56
|
-
export type GridVisibleRowsLookupState = Record<GridRowId,
|
|
61
|
+
export type GridVisibleRowsLookupState = Record<GridRowId, false>;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { GridLogicOperator } from "../../../models/gridFilterItem.js";
|
|
2
|
+
export const defaultGridFilterLookup = {
|
|
3
|
+
filteredRowsLookup: {},
|
|
4
|
+
filteredChildrenCountLookup: {},
|
|
5
|
+
filteredDescendantCountLookup: {}
|
|
6
|
+
};
|
|
2
7
|
export const getDefaultGridFilterModel = () => ({
|
|
3
8
|
items: [],
|
|
4
9
|
logicOperator: GridLogicOperator.And,
|