@mui/x-data-grid 8.22.1 → 8.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +211 -0
- package/colDef/gridBooleanColDef.js +0 -1
- package/colDef/gridDateOperators.js +6 -6
- package/components/GridPagination.js +3 -1
- package/components/cell/GridBooleanCell.js +9 -1
- package/components/cell/GridEditDateCell.js +3 -1
- package/components/cell/GridFooterCell.d.ts +9 -0
- package/components/cell/GridFooterCell.js +54 -0
- package/components/containers/GridRootStyles.js +8 -0
- package/components/menu/columnMenu/GridColumnMenuContainer.js +3 -1
- package/components/virtualization/GridBottomContainer.js +4 -1
- package/components/virtualization/GridMainContainer.js +4 -1
- package/components/virtualization/GridTopContainer.js +4 -1
- package/components/virtualization/GridVirtualScrollbar.d.ts +1 -1
- package/components/virtualization/GridVirtualScrollbar.js +13 -4
- package/components/virtualization/GridVirtualScrollerFiller.js +18 -5
- package/esm/colDef/gridBooleanColDef.js +0 -1
- package/esm/colDef/gridDateOperators.js +6 -6
- package/esm/components/GridPagination.js +3 -1
- package/esm/components/cell/GridBooleanCell.js +9 -1
- package/esm/components/cell/GridEditDateCell.js +3 -1
- package/esm/components/cell/GridFooterCell.d.ts +9 -0
- package/esm/components/cell/GridFooterCell.js +48 -0
- package/esm/components/containers/GridRootStyles.js +8 -0
- package/esm/components/menu/columnMenu/GridColumnMenuContainer.js +3 -1
- package/esm/components/virtualization/GridBottomContainer.js +4 -1
- package/esm/components/virtualization/GridMainContainer.js +4 -1
- package/esm/components/virtualization/GridTopContainer.js +4 -1
- package/esm/components/virtualization/GridVirtualScrollbar.d.ts +1 -1
- package/esm/components/virtualization/GridVirtualScrollbar.js +13 -4
- package/esm/components/virtualization/GridVirtualScrollerFiller.js +18 -5
- package/esm/hooks/features/columnResize/gridColumnResizeApi.d.ts +7 -0
- package/esm/hooks/features/columnResize/gridColumnResizeApi.js +1 -0
- package/esm/hooks/features/columnResize/useGridColumnResize.js +13 -1
- package/esm/hooks/features/columns/gridColumnsUtils.js +1 -4
- package/esm/hooks/features/dataSource/useGridDataSourceBase.d.ts +3 -3
- package/esm/hooks/features/editing/useGridCellEditing.js +1 -0
- package/esm/hooks/features/pagination/gridPaginationSelector.js +3 -0
- package/esm/hooks/features/rowSelection/useGridRowSelection.js +17 -15
- package/esm/hooks/features/rowSelection/utils.js +2 -2
- package/esm/index.js +1 -1
- package/esm/internals/index.d.ts +2 -0
- package/esm/internals/index.js +1 -0
- package/esm/locales/arSD.js +1 -1
- package/esm/locales/daDK.js +3 -4
- package/esm/locales/faIR.js +1 -1
- package/esm/locales/jaJP.js +33 -38
- package/esm/locales/ptPT.d.ts +2 -1
- package/esm/locales/ptPT.js +114 -125
- package/esm/material/index.js +14 -4
- package/esm/models/gridAggregation.d.ts +18 -0
- package/esm/models/gridAggregation.js +1 -0
- package/esm/utils/domUtils.d.ts +1 -0
- package/esm/utils/domUtils.js +4 -0
- package/esm/utils/utils.d.ts +1 -1
- package/esm/utils/utils.js +2 -2
- package/hooks/features/columnResize/gridColumnResizeApi.d.ts +7 -0
- package/hooks/features/columnResize/gridColumnResizeApi.js +1 -0
- package/hooks/features/columnResize/useGridColumnResize.js +12 -0
- package/hooks/features/columns/gridColumnsUtils.js +1 -4
- package/hooks/features/dataSource/useGridDataSourceBase.d.ts +3 -3
- package/hooks/features/editing/useGridCellEditing.js +1 -0
- package/hooks/features/pagination/gridPaginationSelector.js +3 -0
- package/hooks/features/rowSelection/useGridRowSelection.js +17 -15
- package/hooks/features/rowSelection/utils.js +2 -2
- package/index.js +1 -1
- package/internals/index.d.ts +2 -0
- package/internals/index.js +8 -0
- package/locales/arSD.js +1 -1
- package/locales/daDK.js +3 -4
- package/locales/faIR.js +1 -1
- package/locales/jaJP.js +33 -38
- package/locales/ptPT.d.ts +2 -1
- package/locales/ptPT.js +114 -125
- package/material/index.js +14 -4
- package/models/gridAggregation.d.ts +18 -0
- package/models/gridAggregation.js +5 -0
- package/package.json +3 -3
- package/utils/domUtils.d.ts +1 -0
- package/utils/domUtils.js +5 -0
- package/utils/utils.d.ts +1 -1
- package/utils/utils.js +2 -2
|
@@ -11,6 +11,7 @@ import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
|
11
11
|
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
12
12
|
import { isAutogeneratedRowNode } from "../../hooks/features/rows/gridRowsUtils.js";
|
|
13
13
|
import { GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD } from "../../internals/constants.js";
|
|
14
|
+
import { GridFooterCell } from "./GridFooterCell.js";
|
|
14
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
16
|
const useUtilityClasses = ownerState => {
|
|
16
17
|
const {
|
|
@@ -109,7 +110,14 @@ if (process.env.NODE_ENV !== "production") GridBooleanCell.displayName = "GridBo
|
|
|
109
110
|
export { GridBooleanCell };
|
|
110
111
|
export const renderBooleanCell = params => {
|
|
111
112
|
if (params.field !== GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD && isAutogeneratedRowNode(params.rowNode)) {
|
|
112
|
-
|
|
113
|
+
const aggregationMetaData = params.aggregation;
|
|
114
|
+
if (!aggregationMetaData) {
|
|
115
|
+
return '';
|
|
116
|
+
}
|
|
117
|
+
if (aggregationMetaData.position === 'footer') {
|
|
118
|
+
return /*#__PURE__*/_jsx(GridFooterCell, _extends({}, params));
|
|
119
|
+
}
|
|
120
|
+
return params.formattedValue;
|
|
113
121
|
}
|
|
114
122
|
return /*#__PURE__*/_jsx(GridBooleanCell, _extends({}, params));
|
|
115
123
|
};
|
|
@@ -13,7 +13,9 @@ import { getDataGridUtilityClass } from "../../constants/gridClasses.js";
|
|
|
13
13
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
14
14
|
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
15
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
-
const StyledInputBase = styled(NotRendered
|
|
16
|
+
const StyledInputBase = styled(NotRendered, {
|
|
17
|
+
slot: 'internal'
|
|
18
|
+
})({
|
|
17
19
|
fontSize: 'inherit'
|
|
18
20
|
});
|
|
19
21
|
const useUtilityClasses = ownerState => {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { SxProps, Theme } from '@mui/material/styles';
|
|
3
|
+
import type { GridRenderCellParams } from "../../models/params/gridCellParams.js";
|
|
4
|
+
interface GridFooterCellProps extends GridRenderCellParams {
|
|
5
|
+
sx?: SxProps<Theme>;
|
|
6
|
+
}
|
|
7
|
+
declare function GridFooterCellRaw(props: GridFooterCellProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare const GridFooterCell: React.MemoExoticComponent<typeof GridFooterCellRaw>;
|
|
9
|
+
export { GridFooterCell };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
+
const _excluded = ["formattedValue", "colDef", "cellMode", "row", "api", "id", "value", "rowNode", "field", "hasFocus", "tabIndex", "isEditable"];
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
8
|
+
import { styled } from '@mui/material/styles';
|
|
9
|
+
import { vars } from "../../constants/cssVariables.js";
|
|
10
|
+
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
11
|
+
import { getDataGridUtilityClass } from "../../constants/gridClasses.js";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
const GridFooterCellRoot = styled('div', {
|
|
14
|
+
name: 'MuiDataGrid',
|
|
15
|
+
slot: 'FooterCell'
|
|
16
|
+
})({
|
|
17
|
+
fontWeight: vars.typography.fontWeight.medium,
|
|
18
|
+
color: vars.colors.foreground.accent
|
|
19
|
+
});
|
|
20
|
+
const useUtilityClasses = ownerState => {
|
|
21
|
+
const {
|
|
22
|
+
classes
|
|
23
|
+
} = ownerState;
|
|
24
|
+
const slots = {
|
|
25
|
+
root: ['footerCell']
|
|
26
|
+
};
|
|
27
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
28
|
+
};
|
|
29
|
+
function GridFooterCellRaw(props) {
|
|
30
|
+
const {
|
|
31
|
+
formattedValue
|
|
32
|
+
} = props,
|
|
33
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
34
|
+
const rootProps = useGridRootProps();
|
|
35
|
+
const ownerState = {
|
|
36
|
+
classes: rootProps.classes
|
|
37
|
+
};
|
|
38
|
+
const classes = useUtilityClasses(ownerState);
|
|
39
|
+
return /*#__PURE__*/_jsx(GridFooterCellRoot, _extends({
|
|
40
|
+
ownerState: ownerState,
|
|
41
|
+
className: classes.root
|
|
42
|
+
}, other, {
|
|
43
|
+
children: formattedValue
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
const GridFooterCell = /*#__PURE__*/React.memo(GridFooterCellRaw);
|
|
47
|
+
if (process.env.NODE_ENV !== "production") GridFooterCell.displayName = "GridFooterCell";
|
|
48
|
+
export { GridFooterCell };
|
|
@@ -351,6 +351,10 @@ export const GridRootStyles = styled('div', {
|
|
|
351
351
|
},
|
|
352
352
|
[`& .${c.treeDataGroupingCell}`]: {
|
|
353
353
|
width: 'unset'
|
|
354
|
+
},
|
|
355
|
+
[`& .${c['columnHeader--filter']}`]: {
|
|
356
|
+
flex: 'none !important',
|
|
357
|
+
width: 'unset !important'
|
|
354
358
|
}
|
|
355
359
|
},
|
|
356
360
|
[`&.${c.withSidePanel}`]: {
|
|
@@ -425,6 +429,10 @@ export const GridRootStyles = styled('div', {
|
|
|
425
429
|
minHeight: 'min-content',
|
|
426
430
|
overflow: 'hidden'
|
|
427
431
|
},
|
|
432
|
+
[`&.${c['root--densityCompact']} .${c['columnHeader--filter']}`]: {
|
|
433
|
+
paddingTop: 4,
|
|
434
|
+
paddingBottom: 4
|
|
435
|
+
},
|
|
428
436
|
[`& .${c['virtualScroller--hasScrollX']} .${c['columnHeader--last']}`]: {
|
|
429
437
|
overflow: 'hidden'
|
|
430
438
|
},
|
|
@@ -11,7 +11,9 @@ import { NotRendered } from "../../../utils/assert.js";
|
|
|
11
11
|
import { gridClasses } from "../../../constants/gridClasses.js";
|
|
12
12
|
import { useGridRootProps } from "../../../hooks/utils/useGridRootProps.js";
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
const StyledMenuList = styled(NotRendered
|
|
14
|
+
const StyledMenuList = styled(NotRendered, {
|
|
15
|
+
slot: 'internal'
|
|
16
|
+
})(() => ({
|
|
15
17
|
minWidth: 248
|
|
16
18
|
}));
|
|
17
19
|
function handleMenuScrollCapture(event) {
|
|
@@ -11,7 +11,10 @@ const useUtilityClasses = () => {
|
|
|
11
11
|
};
|
|
12
12
|
return composeClasses(slots, getDataGridUtilityClass, {});
|
|
13
13
|
};
|
|
14
|
-
const Element = styled('div'
|
|
14
|
+
const Element = styled('div', {
|
|
15
|
+
slot: 'internal',
|
|
16
|
+
shouldForwardProp: undefined
|
|
17
|
+
})({
|
|
15
18
|
position: 'sticky',
|
|
16
19
|
zIndex: 40,
|
|
17
20
|
bottom: 'calc(var(--DataGrid-hasScrollX) * var(--DataGrid-scrollbarSize))'
|
|
@@ -5,7 +5,10 @@ import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
|
5
5
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
6
6
|
import { useGridConfiguration } from "../../hooks/utils/useGridConfiguration.js";
|
|
7
7
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
-
const GridPanelAnchor = styled('div'
|
|
8
|
+
const GridPanelAnchor = styled('div', {
|
|
9
|
+
slot: 'internal',
|
|
10
|
+
shouldForwardProp: undefined
|
|
11
|
+
})({
|
|
9
12
|
position: 'absolute',
|
|
10
13
|
top: `var(--DataGrid-headersTotalHeight)`,
|
|
11
14
|
left: 0,
|
|
@@ -11,7 +11,10 @@ const useUtilityClasses = () => {
|
|
|
11
11
|
};
|
|
12
12
|
return composeClasses(slots, getDataGridUtilityClass, {});
|
|
13
13
|
};
|
|
14
|
-
const Element = styled('div'
|
|
14
|
+
const Element = styled('div', {
|
|
15
|
+
slot: 'internal',
|
|
16
|
+
shouldForwardProp: undefined
|
|
17
|
+
})({
|
|
15
18
|
position: 'sticky',
|
|
16
19
|
zIndex: 40,
|
|
17
20
|
top: 0
|
|
@@ -8,6 +8,6 @@ type GridVirtualScrollbarProps = {
|
|
|
8
8
|
}>;
|
|
9
9
|
};
|
|
10
10
|
export declare const scrollbarSizeCssExpression = "calc(max(var(--DataGrid-scrollbarSize), 14px))";
|
|
11
|
-
export declare const ScrollbarCorner: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/system").Theme> & React.ClassAttributes<HTMLDivElement>
|
|
11
|
+
export declare const ScrollbarCorner: import("@emotion/styled").StyledComponent<Pick<import("@mui/system").MUIStyledCommonProps<import("@mui/system").Theme> & Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement> | keyof import("@mui/system").MUIStyledCommonProps<import("@mui/system").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/system").Theme>, {}, {}>;
|
|
12
12
|
declare const GridVirtualScrollbar: React.ForwardRefExoticComponent<GridVirtualScrollbarProps> | React.ForwardRefExoticComponent<GridVirtualScrollbarProps & React.RefAttributes<HTMLDivElement>>;
|
|
13
13
|
export { GridVirtualScrollbar };
|
|
@@ -28,7 +28,10 @@ const useUtilityClasses = (ownerState, position) => {
|
|
|
28
28
|
// to appear and have a real size. We set it to 14px because it seems like an acceptable value and we
|
|
29
29
|
// don't have a method to find the required size for scrollbars on those platforms.
|
|
30
30
|
export const scrollbarSizeCssExpression = 'calc(max(var(--DataGrid-scrollbarSize), 14px))';
|
|
31
|
-
const Scrollbar = styled('div'
|
|
31
|
+
const Scrollbar = styled('div', {
|
|
32
|
+
slot: 'internal',
|
|
33
|
+
shouldForwardProp: undefined
|
|
34
|
+
})({
|
|
32
35
|
position: 'absolute',
|
|
33
36
|
display: 'inline-block',
|
|
34
37
|
zIndex: 60,
|
|
@@ -37,7 +40,9 @@ const Scrollbar = styled('div')({
|
|
|
37
40
|
},
|
|
38
41
|
'--size': scrollbarSizeCssExpression
|
|
39
42
|
});
|
|
40
|
-
const ScrollbarVertical = styled(Scrollbar
|
|
43
|
+
const ScrollbarVertical = styled(Scrollbar, {
|
|
44
|
+
slot: 'internal'
|
|
45
|
+
})({
|
|
41
46
|
width: 'var(--size)',
|
|
42
47
|
height: 'calc(var(--DataGrid-hasScrollY) * (100% - var(--DataGrid-headersTotalHeight) - var(--DataGrid-hasScrollX) * var(--DataGrid-scrollbarSize)))',
|
|
43
48
|
overflowY: 'auto',
|
|
@@ -50,7 +55,9 @@ const ScrollbarVertical = styled(Scrollbar)({
|
|
|
50
55
|
top: 'var(--DataGrid-headersTotalHeight)',
|
|
51
56
|
right: 0
|
|
52
57
|
});
|
|
53
|
-
const ScrollbarHorizontal = styled(Scrollbar
|
|
58
|
+
const ScrollbarHorizontal = styled(Scrollbar, {
|
|
59
|
+
slot: 'internal'
|
|
60
|
+
})({
|
|
54
61
|
width: 'calc(var(--DataGrid-hasScrollX) * (100% - var(--DataGrid-hasScrollY) * var(--DataGrid-scrollbarSize)))',
|
|
55
62
|
height: 'var(--size)',
|
|
56
63
|
overflowY: 'hidden',
|
|
@@ -62,7 +69,9 @@ const ScrollbarHorizontal = styled(Scrollbar)({
|
|
|
62
69
|
},
|
|
63
70
|
bottom: 0
|
|
64
71
|
});
|
|
65
|
-
export const ScrollbarCorner = styled(Scrollbar
|
|
72
|
+
export const ScrollbarCorner = styled(Scrollbar, {
|
|
73
|
+
slot: 'internal'
|
|
74
|
+
})({
|
|
66
75
|
width: 'var(--size)',
|
|
67
76
|
height: 'var(--size)',
|
|
68
77
|
right: 0,
|
|
@@ -7,26 +7,39 @@ import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
|
7
7
|
import { gridDimensionsSelector } from "../../hooks/features/dimensions/index.js";
|
|
8
8
|
import { gridClasses } from "../../constants/index.js";
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
-
const Filler = styled('div'
|
|
10
|
+
const Filler = styled('div', {
|
|
11
|
+
slot: 'internal',
|
|
12
|
+
shouldForwardProp: undefined
|
|
13
|
+
})({
|
|
11
14
|
display: 'flex',
|
|
12
15
|
flexDirection: 'row',
|
|
13
16
|
width: 'var(--DataGrid-rowWidth)',
|
|
14
17
|
boxSizing: 'border-box'
|
|
15
18
|
});
|
|
16
|
-
const Pinned = styled('div'
|
|
19
|
+
const Pinned = styled('div', {
|
|
20
|
+
slot: 'internal',
|
|
21
|
+
shouldForwardProp: undefined
|
|
22
|
+
})({
|
|
17
23
|
position: 'sticky',
|
|
18
24
|
height: '100%',
|
|
19
25
|
boxSizing: 'border-box',
|
|
20
26
|
borderTop: '1px solid var(--rowBorderColor)',
|
|
21
27
|
backgroundColor: vars.cell.background.pinned
|
|
22
28
|
});
|
|
23
|
-
const PinnedLeft = styled(Pinned
|
|
29
|
+
const PinnedLeft = styled(Pinned, {
|
|
30
|
+
slot: 'internal'
|
|
31
|
+
})({
|
|
24
32
|
left: 0
|
|
25
33
|
});
|
|
26
|
-
const PinnedRight = styled(Pinned
|
|
34
|
+
const PinnedRight = styled(Pinned, {
|
|
35
|
+
slot: 'internal'
|
|
36
|
+
})({
|
|
27
37
|
right: 0
|
|
28
38
|
});
|
|
29
|
-
const Main = styled('div'
|
|
39
|
+
const Main = styled('div', {
|
|
40
|
+
slot: 'internal',
|
|
41
|
+
shouldForwardProp: undefined
|
|
42
|
+
})({
|
|
30
43
|
flexGrow: 1,
|
|
31
44
|
borderTop: '1px solid var(--rowBorderColor)'
|
|
32
45
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { GridColDef } from "../../../models/colDef/gridColDef.js";
|
|
2
2
|
export declare const DEFAULT_GRID_AUTOSIZE_OPTIONS: {
|
|
3
3
|
includeHeaders: boolean;
|
|
4
|
+
includeHeaderFilters: boolean;
|
|
4
5
|
includeOutliers: boolean;
|
|
5
6
|
outliersFactor: number;
|
|
6
7
|
expand: boolean;
|
|
@@ -16,6 +17,12 @@ export type GridAutosizeOptions = {
|
|
|
16
17
|
* @default false
|
|
17
18
|
*/
|
|
18
19
|
includeHeaders?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* If true, include header filter widths in the calculation.
|
|
22
|
+
* Only applies when header filters are enabled.
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
includeHeaderFilters?: boolean;
|
|
19
26
|
/**
|
|
20
27
|
* If true, width outliers will be ignored.
|
|
21
28
|
* @default false
|
|
@@ -6,7 +6,7 @@ import useEventCallback from '@mui/utils/useEventCallback';
|
|
|
6
6
|
import ownerDocument from '@mui/utils/ownerDocument';
|
|
7
7
|
import useLazyRef from '@mui/utils/useLazyRef';
|
|
8
8
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
9
|
-
import { findGridCellElementsFromCol, findGridElement, findLeftPinnedCellsAfterCol, findRightPinnedCellsBeforeCol, getFieldFromHeaderElem, findHeaderElementFromField, getFieldsFromGroupHeaderElem, findGroupHeaderElementsFromField, findGridHeader, findGridCells, findParentElementFromClassName, findLeftPinnedHeadersAfterCol, findRightPinnedHeadersBeforeCol, escapeOperandAttributeSelector } from "../../../utils/domUtils.js";
|
|
9
|
+
import { findGridCellElementsFromCol, findGridElement, findLeftPinnedCellsAfterCol, findRightPinnedCellsBeforeCol, getFieldFromHeaderElem, findHeaderElementFromField, getFieldsFromGroupHeaderElem, findGroupHeaderElementsFromField, findGridHeader, findGridHeaderFilter, findGridCells, findParentElementFromClassName, findLeftPinnedHeadersAfterCol, findRightPinnedHeadersBeforeCol, escapeOperandAttributeSelector } from "../../../utils/domUtils.js";
|
|
10
10
|
import { DEFAULT_GRID_AUTOSIZE_OPTIONS } from "./gridColumnResizeApi.js";
|
|
11
11
|
import { gridClasses } from "../../../constants/gridClasses.js";
|
|
12
12
|
import { useGridEvent, useGridApiMethod, useGridEventPriority, useGridLogger, useGridNativeEventListener, useGridSelector, useOnMount } from "../../utils/index.js";
|
|
@@ -17,6 +17,7 @@ import { useTimeout } from "../../utils/useTimeout.js";
|
|
|
17
17
|
import { GridPinnedColumnPosition } from "../columns/gridColumnsInterfaces.js";
|
|
18
18
|
import { gridColumnsStateSelector } from "../columns/index.js";
|
|
19
19
|
import { gridDimensionsSelector } from "../dimensions/index.js";
|
|
20
|
+
import { gridHeaderFilteringEnabledSelector } from "../headerFiltering/index.js";
|
|
20
21
|
import { gridResizingColumnFieldSelector } from "./columnResizeSelector.js";
|
|
21
22
|
function trackFinger(event, currentTouchId) {
|
|
22
23
|
if (currentTouchId !== undefined && event.changedTouches) {
|
|
@@ -134,6 +135,7 @@ function extractColumnWidths(apiRef, options, columns) {
|
|
|
134
135
|
const widthByField = {};
|
|
135
136
|
const root = apiRef.current.rootElementRef.current;
|
|
136
137
|
root.classList.add(gridClasses.autosizing);
|
|
138
|
+
const includeHeaderFilters = options.includeHeaderFilters && gridHeaderFilteringEnabledSelector(apiRef);
|
|
137
139
|
columns.forEach(column => {
|
|
138
140
|
const cells = findGridCells(apiRef.current, column.field);
|
|
139
141
|
const widths = cells.map(cell => {
|
|
@@ -164,6 +166,16 @@ function extractColumnWidths(apiRef, options, columns) {
|
|
|
164
166
|
filteredWidths.push(width);
|
|
165
167
|
}
|
|
166
168
|
}
|
|
169
|
+
if (includeHeaderFilters) {
|
|
170
|
+
const headerFilter = findGridHeaderFilter(apiRef.current, column.field);
|
|
171
|
+
if (headerFilter) {
|
|
172
|
+
const style = window.getComputedStyle(headerFilter, null);
|
|
173
|
+
const paddingWidth = parseInt(style.paddingLeft, 10) + parseInt(style.paddingRight, 10);
|
|
174
|
+
const contentWidth = headerFilter.scrollWidth;
|
|
175
|
+
const width = contentWidth + paddingWidth;
|
|
176
|
+
filteredWidths.push(width);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
167
179
|
const hasColumnMin = column.minWidth !== -Infinity && column.minWidth !== undefined;
|
|
168
180
|
const hasColumnMax = column.maxWidth !== Infinity && column.maxWidth !== undefined;
|
|
169
181
|
const min = hasColumnMin ? column.minWidth : 0;
|
|
@@ -236,8 +236,7 @@ export const createColumnsState = ({
|
|
|
236
236
|
const currentState = gridColumnsStateSelector(apiRef);
|
|
237
237
|
columnsState = {
|
|
238
238
|
orderedFields: keepOnlyColumnsToUpsert ? [] : [...currentState.orderedFields],
|
|
239
|
-
lookup: _extends({}, currentState.lookup),
|
|
240
|
-
// Will be cleaned later if keepOnlyColumnsToUpsert=true
|
|
239
|
+
lookup: keepOnlyColumnsToUpsert ? {} : _extends({}, currentState.lookup),
|
|
241
240
|
columnVisibilityModel,
|
|
242
241
|
initialColumnVisibilityModel: updateInitialVisibilityModel ? columnVisibilityModel : currentState.initialColumnVisibilityModel
|
|
243
242
|
};
|
|
@@ -250,12 +249,10 @@ export const createColumnsState = ({
|
|
|
250
249
|
}
|
|
251
250
|
}
|
|
252
251
|
}
|
|
253
|
-
const columnsToUpsertLookup = {};
|
|
254
252
|
columnsToUpsert.forEach(newColumn => {
|
|
255
253
|
const {
|
|
256
254
|
field
|
|
257
255
|
} = newColumn;
|
|
258
|
-
columnsToUpsertLookup[field] = true;
|
|
259
256
|
columnsToKeep[field] = true;
|
|
260
257
|
let existingState = columnsState.lookup[field];
|
|
261
258
|
if (existingState == null) {
|
|
@@ -21,8 +21,8 @@ export declare const useGridDataSourceBase: <Api extends GridPrivateApiCommunity
|
|
|
21
21
|
cache: GridDataSourceCache;
|
|
22
22
|
events: {
|
|
23
23
|
strategyAvailabilityChange: GridEventListener<"strategyAvailabilityChange">;
|
|
24
|
-
sortModelChange: (params: unknown) => void;
|
|
25
|
-
filterModelChange: (params: unknown) => void;
|
|
26
|
-
paginationModelChange: (params: unknown) => void;
|
|
24
|
+
sortModelChange: (...params: unknown[]) => void;
|
|
25
|
+
filterModelChange: (...params: unknown[]) => void;
|
|
26
|
+
paginationModelChange: (...params: unknown[]) => void;
|
|
27
27
|
};
|
|
28
28
|
};
|
|
@@ -107,6 +107,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
107
107
|
reason = GridCellEditStartReasons.pasteKeyDown;
|
|
108
108
|
} else if (event.key === 'Enter') {
|
|
109
109
|
reason = GridCellEditStartReasons.enterKeyDown;
|
|
110
|
+
event.preventDefault();
|
|
110
111
|
} else if (event.key === 'Backspace' || event.key === 'Delete') {
|
|
111
112
|
reason = GridCellEditStartReasons.deleteKeyDown;
|
|
112
113
|
}
|
|
@@ -60,6 +60,9 @@ export const gridPaginationRowRangeSelector = createSelectorMemoized(gridPaginat
|
|
|
60
60
|
if (!clientSidePaginationEnabled) {
|
|
61
61
|
return null;
|
|
62
62
|
}
|
|
63
|
+
if (!visibleSortedRowEntries || visibleSortedRowEntries.length === 0) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
63
66
|
const visibleTopLevelRowCount = visibleSortedTopLevelRowEntries.length;
|
|
64
67
|
const topLevelFirstRowIndex = Math.min(paginationModel.pageSize * paginationModel.page, visibleTopLevelRowCount - 1);
|
|
65
68
|
const topLevelLastRowIndex = paginationModel.pageSize === ALL_RESULTS_PAGE_VALUE ? visibleTopLevelRowCount - 1 : Math.min(topLevelFirstRowIndex + paginationModel.pageSize - 1, visibleTopLevelRowCount - 1);
|
|
@@ -20,6 +20,7 @@ import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../internals/constants.js"
|
|
|
20
20
|
import { gridClasses } from "../../../constants/gridClasses.js";
|
|
21
21
|
import { isEventTargetInPortal } from "../../../utils/domUtils.js";
|
|
22
22
|
import { isMultipleRowSelectionEnabled, findRowsToSelect, findRowsToDeselect } from "./utils.js";
|
|
23
|
+
import { runIf } from "../../../utils/utils.js";
|
|
23
24
|
import { createRowSelectionManager } from "../../../models/gridRowSelectionManager.js";
|
|
24
25
|
import { gridPaginatedVisibleSortedGridRowIdsSelector } from "../pagination/index.js";
|
|
25
26
|
const emptyModel = {
|
|
@@ -38,11 +39,6 @@ export const rowSelectionStateInitializer = (state, props) => _extends({}, state
|
|
|
38
39
|
*/
|
|
39
40
|
export const useGridRowSelection = (apiRef, props) => {
|
|
40
41
|
const logger = useGridLogger(apiRef, 'useGridSelection');
|
|
41
|
-
const runIfRowSelectionIsEnabled = React.useCallback(callback => (...args) => {
|
|
42
|
-
if (props.rowSelection) {
|
|
43
|
-
callback(...args);
|
|
44
|
-
}
|
|
45
|
-
}, [props.rowSelection]);
|
|
46
42
|
const isNestedData = useGridSelector(apiRef, gridRowMaximumTreeDepthSelector) > 1;
|
|
47
43
|
const applyAutoSelection = props.signature !== GridSignature.DataGrid && (props.rowSelectionPropagation?.parents || props.rowSelectionPropagation?.descendants) && isNestedData;
|
|
48
44
|
const propRowSelectionModel = React.useMemo(() => {
|
|
@@ -121,6 +117,12 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
121
117
|
if (props.rowSelection === false) {
|
|
122
118
|
return false;
|
|
123
119
|
}
|
|
120
|
+
|
|
121
|
+
// If `keepNonExistentRowsSelected` is true, we might run in a case where row selectability is checked for a row that does not exist.
|
|
122
|
+
// Since that row was previously selected (otherwise it would not be checked at this point), we return true.
|
|
123
|
+
if (props.keepNonExistentRowsSelected && !apiRef.current.getRow(id)) {
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
124
126
|
if (propIsRowSelectable && !propIsRowSelectable(apiRef.current.getRowParams(id))) {
|
|
125
127
|
return false;
|
|
126
128
|
}
|
|
@@ -129,7 +131,7 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
129
131
|
return false;
|
|
130
132
|
}
|
|
131
133
|
return true;
|
|
132
|
-
}, [apiRef, props.rowSelection, propIsRowSelectable]);
|
|
134
|
+
}, [apiRef, props.rowSelection, props.keepNonExistentRowsSelected, propIsRowSelectable]);
|
|
133
135
|
const getSelectedRows = React.useCallback(() => gridRowSelectionIdsSelector(apiRef), [apiRef]);
|
|
134
136
|
const selectRow = React.useCallback((id, isSelected = true, resetSelection = false) => {
|
|
135
137
|
if (!apiRef.current.isRowSelectable(id)) {
|
|
@@ -303,7 +305,7 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
303
305
|
* EVENTS
|
|
304
306
|
*/
|
|
305
307
|
const isFirstRender = React.useRef(true);
|
|
306
|
-
const removeOutdatedSelection = React.useCallback((
|
|
308
|
+
const removeOutdatedSelection = React.useCallback(() => {
|
|
307
309
|
if (isFirstRender.current) {
|
|
308
310
|
return;
|
|
309
311
|
}
|
|
@@ -357,7 +359,7 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
357
359
|
const shouldReapplyPropagation = isNestedData && props.rowSelectionPropagation?.parents && (newSelectionModel.ids.size > 0 ||
|
|
358
360
|
// In case of exclude selection, newSelectionModel.ids.size === 0 means all rows are selected
|
|
359
361
|
newSelectionModel.type === 'exclude');
|
|
360
|
-
if (hasChanged || shouldReapplyPropagation
|
|
362
|
+
if (hasChanged || shouldReapplyPropagation) {
|
|
361
363
|
if (shouldReapplyPropagation) {
|
|
362
364
|
if (newSelectionModel.type === 'exclude') {
|
|
363
365
|
const unfilteredSelectedRowIds = getRowsToBeSelected();
|
|
@@ -540,12 +542,12 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
540
542
|
}
|
|
541
543
|
apiRef.current.setRowSelectionModel(propRowSelectionModel);
|
|
542
544
|
});
|
|
543
|
-
useGridEvent(apiRef, 'filteredRowsSet',
|
|
544
|
-
useGridEvent(apiRef, 'rowClick',
|
|
545
|
-
useGridEvent(apiRef, 'rowSelectionCheckboxChange',
|
|
545
|
+
useGridEvent(apiRef, 'filteredRowsSet', runIf(props.rowSelection, removeOutdatedSelection));
|
|
546
|
+
useGridEvent(apiRef, 'rowClick', runIf(props.rowSelection, handleRowClick));
|
|
547
|
+
useGridEvent(apiRef, 'rowSelectionCheckboxChange', runIf(props.rowSelection, handleRowSelectionCheckboxChange));
|
|
546
548
|
useGridEvent(apiRef, 'headerSelectionCheckboxChange', handleHeaderSelectionCheckboxChange);
|
|
547
|
-
useGridEvent(apiRef, 'cellMouseDown',
|
|
548
|
-
useGridEvent(apiRef, 'cellKeyDown',
|
|
549
|
+
useGridEvent(apiRef, 'cellMouseDown', runIf(props.rowSelection, preventSelectionOnShift));
|
|
550
|
+
useGridEvent(apiRef, 'cellKeyDown', runIf(props.rowSelection, handleCellKeyDown));
|
|
549
551
|
|
|
550
552
|
/*
|
|
551
553
|
* EFFECTS
|
|
@@ -588,8 +590,8 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
588
590
|
}
|
|
589
591
|
}, [apiRef, canHaveMultipleSelection, checkboxSelection, isStateControlled, props.rowSelection]);
|
|
590
592
|
React.useEffect(() => {
|
|
591
|
-
|
|
592
|
-
}, [
|
|
593
|
+
runIf(props.rowSelection, removeOutdatedSelection);
|
|
594
|
+
}, [props.rowSelection, removeOutdatedSelection]);
|
|
593
595
|
React.useEffect(() => {
|
|
594
596
|
if (isFirstRender.current) {
|
|
595
597
|
isFirstRender.current = false;
|
|
@@ -40,7 +40,7 @@ export const checkboxPropsSelector = createSelector(gridColumnDefinitionsSelecto
|
|
|
40
40
|
columns
|
|
41
41
|
};
|
|
42
42
|
let isSelectable = true;
|
|
43
|
-
if (typeof isRowSelectable === 'function') {
|
|
43
|
+
if (typeof isRowSelectable === 'function' && rowsLookup[groupId]) {
|
|
44
44
|
isSelectable = isRowSelectable(rowParams);
|
|
45
45
|
}
|
|
46
46
|
if (!groupNode || groupNode.type !== 'group' || rowSelectionManager.has(groupId)) {
|
|
@@ -69,7 +69,7 @@ export const checkboxPropsSelector = createSelector(gridColumnDefinitionsSelecto
|
|
|
69
69
|
row: rowsLookup[itemToTraverseId],
|
|
70
70
|
columns
|
|
71
71
|
};
|
|
72
|
-
const rowIsSelectable = typeof isRowSelectable === 'function' ? isRowSelectable(descendantRowParams) : true;
|
|
72
|
+
const rowIsSelectable = typeof isRowSelectable === 'function' && rowsLookup[itemToTraverseId] ? isRowSelectable(descendantRowParams) : true;
|
|
73
73
|
|
|
74
74
|
// Only consider selectable rows when determining parent selection state
|
|
75
75
|
if (rowIsSelectable) {
|
package/esm/index.js
CHANGED
package/esm/internals/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { GridHeaders } from "../components/GridHeaders.js";
|
|
|
8
8
|
export { GridToolbar, GridToolbarDivider } from "../components/toolbarV8/GridToolbar.js";
|
|
9
9
|
export type { GridToolbarProps } from "../components/toolbarV8/GridToolbar.js";
|
|
10
10
|
export { GridColumnSortButton } from "../components/GridColumnSortButton.js";
|
|
11
|
+
export { GridFooterCell } from "../components/cell/GridFooterCell.js";
|
|
11
12
|
export { GridBaseColumnHeaders } from "../components/columnHeaders/GridBaseColumnHeaders.js";
|
|
12
13
|
export { DATA_GRID_DEFAULT_SLOTS_COMPONENTS } from "../constants/defaultGridSlotsComponents.js";
|
|
13
14
|
export * from "../constants/signature.js";
|
|
@@ -88,6 +89,7 @@ export { useGridInitializeState } from "../hooks/utils/useGridInitializeState.js
|
|
|
88
89
|
export type { GridStateInitializer } from "../hooks/utils/useGridInitializeState.js";
|
|
89
90
|
export type * as BaseSlots from "../models/gridBaseSlots.js";
|
|
90
91
|
export type * from "../models/props/DataGridProps.js";
|
|
92
|
+
export type { GridAggregationPosition, GridAggregationCellMeta } from "../models/gridAggregation.js";
|
|
91
93
|
export type { GridDataSourceApiBase, GridDataSourceApi, GridDataSourceBaseOptions, GridDataSourceFetchRowsParams } from "../hooks/features/dataSource/models.js";
|
|
92
94
|
export { DataSourceRowsUpdateStrategy } from "../hooks/features/dataSource/utils.js";
|
|
93
95
|
export { useGridDataSourceBase } from "../hooks/features/dataSource/useGridDataSourceBase.js";
|
package/esm/internals/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { GridVirtualScrollerRenderZone } from "../components/virtualization/Grid
|
|
|
4
4
|
export { GridHeaders } from "../components/GridHeaders.js";
|
|
5
5
|
export { GridToolbar, GridToolbarDivider } from "../components/toolbarV8/GridToolbar.js";
|
|
6
6
|
export { GridColumnSortButton } from "../components/GridColumnSortButton.js";
|
|
7
|
+
export { GridFooterCell } from "../components/cell/GridFooterCell.js";
|
|
7
8
|
export { GridBaseColumnHeaders } from "../components/columnHeaders/GridBaseColumnHeaders.js";
|
|
8
9
|
export { DATA_GRID_DEFAULT_SLOTS_COMPONENTS } from "../constants/defaultGridSlotsComponents.js";
|
|
9
10
|
export * from "../constants/signature.js";
|
package/esm/locales/arSD.js
CHANGED
|
@@ -23,7 +23,7 @@ const arSDGrid = {
|
|
|
23
23
|
toolbarFiltersTooltipShow: 'اظهر المرشِحات',
|
|
24
24
|
toolbarFiltersTooltipActive: count => count !== 1 ? `${count} من المرشِحات النشطة` : `مرشِح نشط`,
|
|
25
25
|
// Quick filter toolbar field
|
|
26
|
-
toolbarQuickFilterPlaceholder: '
|
|
26
|
+
toolbarQuickFilterPlaceholder: 'بحث…',
|
|
27
27
|
toolbarQuickFilterLabel: 'بحث',
|
|
28
28
|
toolbarQuickFilterDeleteIconLabel: 'أزال',
|
|
29
29
|
// Export selector toolbar button text
|
package/esm/locales/daDK.js
CHANGED
|
@@ -3,8 +3,8 @@ const daDKGrid = {
|
|
|
3
3
|
// Root
|
|
4
4
|
noRowsLabel: 'Ingen rækker',
|
|
5
5
|
noResultsOverlayLabel: 'Ingen resultater',
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
noColumnsOverlayLabel: 'Ingen kolonner',
|
|
7
|
+
noColumnsOverlayManageColumns: 'Administrer kolonner',
|
|
8
8
|
// emptyPivotOverlayLabel: 'Add fields to rows, columns, and values to create a pivot table',
|
|
9
9
|
|
|
10
10
|
// Density selector toolbar button text
|
|
@@ -103,8 +103,7 @@ const daDKGrid = {
|
|
|
103
103
|
'headerFilterOperator>=': 'Større end eller lig med',
|
|
104
104
|
'headerFilterOperator<': 'Mindre end',
|
|
105
105
|
'headerFilterOperator<=': 'Mindre end eller lig med',
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
headerFilterClear: 'Ryd filter',
|
|
108
107
|
// Filter values text
|
|
109
108
|
filterValueAny: 'hvilken som helst',
|
|
110
109
|
filterValueTrue: 'positiv',
|
package/esm/locales/faIR.js
CHANGED
|
@@ -23,7 +23,7 @@ const faIRGrid = {
|
|
|
23
23
|
toolbarFiltersTooltipShow: 'نمایش فیلترها',
|
|
24
24
|
toolbarFiltersTooltipActive: count => count !== 1 ? `${count} فیلترهای فعال` : `${count} فیلتر فعال`,
|
|
25
25
|
// Quick filter toolbar field
|
|
26
|
-
toolbarQuickFilterPlaceholder: '
|
|
26
|
+
toolbarQuickFilterPlaceholder: 'جستجو…',
|
|
27
27
|
toolbarQuickFilterLabel: 'جستجو',
|
|
28
28
|
toolbarQuickFilterDeleteIconLabel: 'حذف',
|
|
29
29
|
// Export selector toolbar button text
|