@mui/x-data-grid 8.0.0-beta.1 → 8.0.0-beta.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 +94 -0
- package/DataGrid/DataGrid.js +2 -0
- package/components/GridRow.js +3 -8
- package/components/GridShadowScrollArea.js +43 -35
- package/components/cell/GridBooleanCell.d.ts +1 -2
- package/components/cell/GridEditSingleSelectCell.d.ts +4 -4
- package/components/cell/GridEditSingleSelectCell.js +1 -1
- package/components/containers/GridToolbarContainer.js +5 -3
- package/components/quickFilter/QuickFilter.d.ts +26 -3
- package/components/quickFilter/QuickFilter.js +103 -19
- package/components/quickFilter/QuickFilterClear.js +10 -4
- package/components/quickFilter/QuickFilterContext.d.ts +4 -1
- package/components/quickFilter/QuickFilterControl.js +36 -10
- package/components/quickFilter/QuickFilterTrigger.d.ts +28 -0
- package/components/quickFilter/QuickFilterTrigger.js +211 -0
- package/components/quickFilter/index.d.ts +2 -1
- package/components/quickFilter/index.js +11 -0
- package/components/toolbar/GridToolbarColumnsButton.d.ts +3 -4
- package/components/toolbar/GridToolbarDensitySelector.d.ts +3 -4
- package/components/toolbar/GridToolbarExport.d.ts +3 -4
- package/components/toolbar/GridToolbarExportContainer.d.ts +3 -4
- package/components/toolbar/GridToolbarFilterButton.d.ts +4 -6
- package/components/toolbar/GridToolbarFilterButton.js +1 -4
- package/components/toolbar/GridToolbarQuickFilter.js +101 -41
- package/components/toolbarV8/GridToolbar.js +22 -19
- package/components/toolbarV8/Toolbar.d.ts +1 -1
- package/components/toolbarV8/Toolbar.js +76 -23
- package/components/toolbarV8/ToolbarButton.js +34 -14
- package/components/toolbarV8/ToolbarContext.d.ts +4 -2
- package/constants/gridClasses.d.ts +12 -0
- package/constants/gridClasses.js +1 -1
- package/esm/DataGrid/DataGrid.js +2 -0
- package/esm/components/GridRow.js +4 -9
- package/esm/components/GridShadowScrollArea.js +43 -35
- package/esm/components/cell/GridBooleanCell.d.ts +1 -2
- package/esm/components/cell/GridEditSingleSelectCell.d.ts +4 -4
- package/esm/components/cell/GridEditSingleSelectCell.js +1 -1
- package/esm/components/containers/GridToolbarContainer.js +5 -3
- package/esm/components/quickFilter/QuickFilter.d.ts +26 -3
- package/esm/components/quickFilter/QuickFilter.js +101 -17
- package/esm/components/quickFilter/QuickFilterClear.js +10 -4
- package/esm/components/quickFilter/QuickFilterContext.d.ts +4 -1
- package/esm/components/quickFilter/QuickFilterControl.js +36 -10
- package/esm/components/quickFilter/QuickFilterTrigger.d.ts +28 -0
- package/esm/components/quickFilter/QuickFilterTrigger.js +204 -0
- package/esm/components/quickFilter/index.d.ts +2 -1
- package/esm/components/quickFilter/index.js +2 -1
- package/esm/components/toolbar/GridToolbarColumnsButton.d.ts +3 -4
- package/esm/components/toolbar/GridToolbarDensitySelector.d.ts +3 -4
- package/esm/components/toolbar/GridToolbarExport.d.ts +3 -4
- package/esm/components/toolbar/GridToolbarExportContainer.d.ts +3 -4
- package/esm/components/toolbar/GridToolbarFilterButton.d.ts +4 -6
- package/esm/components/toolbar/GridToolbarFilterButton.js +1 -4
- package/esm/components/toolbar/GridToolbarQuickFilter.js +102 -44
- package/esm/components/toolbarV8/GridToolbar.js +22 -19
- package/esm/components/toolbarV8/Toolbar.d.ts +1 -1
- package/esm/components/toolbarV8/Toolbar.js +75 -22
- package/esm/components/toolbarV8/ToolbarButton.js +34 -14
- package/esm/components/toolbarV8/ToolbarContext.d.ts +4 -2
- package/esm/constants/gridClasses.d.ts +12 -0
- package/esm/constants/gridClasses.js +1 -1
- package/esm/hooks/features/columnGrouping/gridColumnGroupsUtils.js +1 -1
- package/esm/hooks/features/columns/useGridColumns.js +0 -1
- package/esm/hooks/features/dimensions/useGridDimensions.js +1 -1
- package/esm/hooks/features/filter/useGridFilter.js +1 -1
- package/esm/hooks/features/pagination/useGridPaginationModel.js +1 -1
- package/esm/hooks/features/virtualization/useGridVirtualScroller.js +12 -1
- package/esm/index.js +1 -1
- package/esm/locales/deDE.js +13 -13
- package/esm/models/props/DataGridProps.d.ts +6 -2
- package/esm/utils/utils.d.ts +0 -27
- package/esm/utils/utils.js +0 -122
- package/hooks/features/columnGrouping/gridColumnGroupsUtils.js +2 -2
- package/hooks/features/columns/useGridColumns.js +0 -1
- package/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/hooks/features/filter/useGridFilter.js +3 -3
- package/hooks/features/pagination/useGridPaginationModel.js +2 -2
- package/hooks/features/virtualization/useGridVirtualScroller.js +11 -0
- package/index.js +1 -1
- package/locales/deDE.js +13 -13
- package/models/props/DataGridProps.d.ts +6 -2
- package/modern/DataGrid/DataGrid.js +2 -0
- package/modern/components/GridRow.js +4 -9
- package/modern/components/GridShadowScrollArea.js +43 -35
- package/modern/components/cell/GridBooleanCell.d.ts +1 -2
- package/modern/components/cell/GridEditSingleSelectCell.d.ts +4 -4
- package/modern/components/cell/GridEditSingleSelectCell.js +1 -1
- package/modern/components/containers/GridToolbarContainer.js +5 -3
- package/modern/components/quickFilter/QuickFilter.d.ts +26 -3
- package/modern/components/quickFilter/QuickFilter.js +101 -17
- package/modern/components/quickFilter/QuickFilterClear.js +10 -4
- package/modern/components/quickFilter/QuickFilterContext.d.ts +4 -1
- package/modern/components/quickFilter/QuickFilterControl.js +36 -10
- package/modern/components/quickFilter/QuickFilterTrigger.d.ts +28 -0
- package/modern/components/quickFilter/QuickFilterTrigger.js +204 -0
- package/modern/components/quickFilter/index.d.ts +2 -1
- package/modern/components/quickFilter/index.js +2 -1
- package/modern/components/toolbar/GridToolbarColumnsButton.d.ts +3 -4
- package/modern/components/toolbar/GridToolbarDensitySelector.d.ts +3 -4
- package/modern/components/toolbar/GridToolbarExport.d.ts +3 -4
- package/modern/components/toolbar/GridToolbarExportContainer.d.ts +3 -4
- package/modern/components/toolbar/GridToolbarFilterButton.d.ts +4 -6
- package/modern/components/toolbar/GridToolbarFilterButton.js +1 -4
- package/modern/components/toolbar/GridToolbarQuickFilter.js +102 -44
- package/modern/components/toolbarV8/GridToolbar.js +22 -19
- package/modern/components/toolbarV8/Toolbar.d.ts +1 -1
- package/modern/components/toolbarV8/Toolbar.js +75 -22
- package/modern/components/toolbarV8/ToolbarButton.js +34 -14
- package/modern/components/toolbarV8/ToolbarContext.d.ts +4 -2
- package/modern/constants/gridClasses.d.ts +12 -0
- package/modern/constants/gridClasses.js +1 -1
- package/modern/hooks/features/columnGrouping/gridColumnGroupsUtils.js +1 -1
- package/modern/hooks/features/columns/useGridColumns.js +0 -1
- package/modern/hooks/features/dimensions/useGridDimensions.js +1 -1
- package/modern/hooks/features/filter/useGridFilter.js +1 -1
- package/modern/hooks/features/pagination/useGridPaginationModel.js +1 -1
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +12 -1
- package/modern/index.js +1 -1
- package/modern/locales/deDE.js +13 -13
- package/modern/models/props/DataGridProps.d.ts +6 -2
- package/modern/utils/utils.d.ts +0 -27
- package/modern/utils/utils.js +0 -122
- package/package.json +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/utils/utils.d.ts +0 -27
- package/utils/utils.js +0 -123
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { TooltipProps } from '@mui/material/Tooltip';
|
|
2
|
+
import type { GridSlotProps } from '../../models/gridSlotsComponentsProps';
|
|
4
3
|
interface GridToolbarColumnsButtonProps {
|
|
5
4
|
/**
|
|
6
5
|
* The props used for each slot inside.
|
|
7
6
|
* @default {}
|
|
8
7
|
*/
|
|
9
8
|
slotProps?: {
|
|
10
|
-
button?: Partial<
|
|
11
|
-
tooltip?: Partial<
|
|
9
|
+
button?: Partial<GridSlotProps['baseButton']>;
|
|
10
|
+
tooltip?: Partial<GridSlotProps['baseTooltip']>;
|
|
12
11
|
};
|
|
13
12
|
}
|
|
14
13
|
declare const GridToolbarColumnsButton: React.ForwardRefExoticComponent<GridToolbarColumnsButtonProps> | React.ForwardRefExoticComponent<GridToolbarColumnsButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { TooltipProps } from '@mui/material/Tooltip';
|
|
2
|
+
import type { GridSlotProps } from '../../models/gridSlotsComponentsProps';
|
|
4
3
|
interface GridToolbarDensitySelectorProps {
|
|
5
4
|
/**
|
|
6
5
|
* The props used for each slot inside.
|
|
7
6
|
* @default {}
|
|
8
7
|
*/
|
|
9
8
|
slotProps?: {
|
|
10
|
-
button?: Partial<
|
|
11
|
-
tooltip?: Partial<
|
|
9
|
+
button?: Partial<GridSlotProps['baseButton']>;
|
|
10
|
+
tooltip?: Partial<GridSlotProps['baseTooltip']>;
|
|
12
11
|
};
|
|
13
12
|
}
|
|
14
13
|
declare const GridToolbarDensitySelector: React.ForwardRefExoticComponent<GridToolbarDensitySelectorProps> | React.ForwardRefExoticComponent<GridToolbarDensitySelectorProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { TooltipProps } from '@mui/material/Tooltip';
|
|
2
|
+
import type { GridSlotProps } from '../../models/gridSlotsComponentsProps';
|
|
4
3
|
import { GridCsvExportOptions, GridPrintExportOptions } from "../../models/gridExport.js";
|
|
5
4
|
export interface GridExportDisplayOptions {
|
|
6
5
|
/**
|
|
@@ -23,8 +22,8 @@ export interface GridToolbarExportProps {
|
|
|
23
22
|
* @default {}
|
|
24
23
|
*/
|
|
25
24
|
slotProps?: {
|
|
26
|
-
button?: Partial<
|
|
27
|
-
tooltip?: Partial<
|
|
25
|
+
button?: Partial<GridSlotProps['baseButton']>;
|
|
26
|
+
tooltip?: Partial<GridSlotProps['baseTooltip']>;
|
|
28
27
|
};
|
|
29
28
|
[x: `data-${string}`]: string;
|
|
30
29
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { TooltipProps } from '@mui/material/Tooltip';
|
|
2
|
+
import type { GridSlotProps } from '../../models/gridSlotsComponentsProps';
|
|
4
3
|
interface GridToolbarExportContainerProps {
|
|
5
4
|
/**
|
|
6
5
|
* The props used for each slot inside.
|
|
7
6
|
* @default {}
|
|
8
7
|
*/
|
|
9
8
|
slotProps?: {
|
|
10
|
-
button?: Partial<
|
|
11
|
-
tooltip?: Partial<
|
|
9
|
+
button?: Partial<GridSlotProps['baseButton']>;
|
|
10
|
+
tooltip?: Partial<GridSlotProps['baseTooltip']>;
|
|
12
11
|
};
|
|
13
12
|
}
|
|
14
13
|
declare const GridToolbarExportContainer: React.ForwardRefExoticComponent<React.PropsWithChildren<GridToolbarExportContainerProps>> | React.ForwardRefExoticComponent<GridToolbarExportContainerProps & {
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { TooltipProps } from '@mui/material/Tooltip';
|
|
4
|
-
import { BadgeProps } from "../../models/gridBaseSlots.js";
|
|
2
|
+
import type { GridSlotProps } from '../../models/gridSlotsComponentsProps';
|
|
5
3
|
export interface GridToolbarFilterButtonProps {
|
|
6
4
|
/**
|
|
7
5
|
* The props used for each slot inside.
|
|
8
6
|
* @default {}
|
|
9
7
|
*/
|
|
10
8
|
slotProps?: {
|
|
11
|
-
button?: Partial<
|
|
12
|
-
tooltip?: Partial<
|
|
13
|
-
badge?: Partial<
|
|
9
|
+
button?: Partial<GridSlotProps['baseButton']>;
|
|
10
|
+
tooltip?: Partial<GridSlotProps['baseTooltip']>;
|
|
11
|
+
badge?: Partial<GridSlotProps['baseBadge']>;
|
|
14
12
|
};
|
|
15
13
|
}
|
|
16
14
|
declare const GridToolbarFilterButton: React.ForwardRefExoticComponent<GridToolbarFilterButtonProps> | React.ForwardRefExoticComponent<GridToolbarFilterButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -3,8 +3,8 @@ import * as React from 'react';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
5
|
import { unstable_composeClasses as composeClasses, unstable_capitalize as capitalize, unstable_useId as useId } from '@mui/utils';
|
|
6
|
-
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
7
6
|
import useForkRef from '@mui/utils/useForkRef';
|
|
7
|
+
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
8
8
|
import { vars } from "../../constants/cssVariables.js";
|
|
9
9
|
import { gridColumnLookupSelector } from "../../hooks/features/columns/gridColumnsSelector.js";
|
|
10
10
|
import { useGridSelector } from "../../hooks/utils/useGridSelector.js";
|
|
@@ -33,9 +33,6 @@ const GridToolbarFilterListRoot = styled('ul', {
|
|
|
33
33
|
margin: vars.spacing(1, 1, 0.5),
|
|
34
34
|
padding: vars.spacing(0, 1)
|
|
35
35
|
});
|
|
36
|
-
|
|
37
|
-
// FIXME(v8:romgrk): override slotProps
|
|
38
|
-
|
|
39
36
|
const GridToolbarFilterButton = forwardRef(function GridToolbarFilterButton(props, ref) {
|
|
40
37
|
const {
|
|
41
38
|
slotProps = {}
|
|
@@ -7,38 +7,71 @@ import PropTypes from 'prop-types';
|
|
|
7
7
|
import composeClasses from '@mui/utils/composeClasses';
|
|
8
8
|
import { styled } from '@mui/system';
|
|
9
9
|
import clsx from 'clsx';
|
|
10
|
-
// import { NotRendered } from '../../utils/assert';
|
|
11
|
-
|
|
12
10
|
import { getDataGridUtilityClass } from "../../constants/index.js";
|
|
13
11
|
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
14
12
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
15
|
-
import { QuickFilter, QuickFilterClear, QuickFilterControl } from "../quickFilter/index.js";
|
|
16
|
-
import {
|
|
13
|
+
import { QuickFilter, QuickFilterClear, QuickFilterControl, QuickFilterTrigger } from "../quickFilter/index.js";
|
|
14
|
+
import { ToolbarButton } from "../toolbarV8/index.js";
|
|
15
|
+
import { vars } from "../../constants/cssVariables.js";
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
17
|
const useUtilityClasses = ownerState => {
|
|
18
18
|
const {
|
|
19
19
|
classes
|
|
20
20
|
} = ownerState;
|
|
21
21
|
const slots = {
|
|
22
|
-
root: ['toolbarQuickFilter']
|
|
22
|
+
root: ['toolbarQuickFilter'],
|
|
23
|
+
trigger: ['toolbarQuickFilterTrigger'],
|
|
24
|
+
control: ['toolbarQuickFilterControl']
|
|
23
25
|
};
|
|
24
26
|
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
25
27
|
};
|
|
28
|
+
const GridQuickFilterRoot = styled('div', {
|
|
29
|
+
name: 'MuiDataGrid',
|
|
30
|
+
slot: 'ToolbarQuickFilter'
|
|
31
|
+
})({
|
|
32
|
+
display: 'grid',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
marginLeft: 'auto'
|
|
35
|
+
});
|
|
36
|
+
const GridQuickFilterTrigger = styled(ToolbarButton, {
|
|
37
|
+
name: 'MuiDataGrid',
|
|
38
|
+
slot: 'ToolbarQuickFilterTrigger'
|
|
39
|
+
})(({
|
|
40
|
+
ownerState
|
|
41
|
+
}) => ({
|
|
42
|
+
gridArea: '1 / 1',
|
|
43
|
+
width: 'min-content',
|
|
44
|
+
height: 'min-content',
|
|
45
|
+
zIndex: 1,
|
|
46
|
+
opacity: ownerState.expanded ? 0 : 1,
|
|
47
|
+
pointerEvents: ownerState.expanded ? 'none' : 'auto',
|
|
48
|
+
transition: vars.transition(['opacity'])
|
|
49
|
+
}));
|
|
26
50
|
|
|
27
51
|
// TODO: Use NotRendered from /utils/assert
|
|
28
52
|
// Currently causes react-docgen to fail
|
|
29
|
-
const
|
|
53
|
+
const GridQuickFilterTextField = styled(_props => {
|
|
30
54
|
throw new Error('Failed assertion: should not be rendered');
|
|
31
55
|
}, {
|
|
32
56
|
name: 'MuiDataGrid',
|
|
33
|
-
slot: '
|
|
34
|
-
})({
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
57
|
+
slot: 'ToolbarQuickFilterControl'
|
|
58
|
+
})(({
|
|
59
|
+
ownerState
|
|
60
|
+
}) => ({
|
|
61
|
+
gridArea: '1 / 1',
|
|
62
|
+
overflowX: 'clip',
|
|
63
|
+
width: ownerState.expanded ? 260 : 'var(--trigger-width)',
|
|
64
|
+
opacity: ownerState.expanded ? 1 : 0,
|
|
65
|
+
transition: vars.transition(['width', 'opacity'])
|
|
66
|
+
}));
|
|
38
67
|
function GridToolbarQuickFilter(props) {
|
|
39
68
|
const apiRef = useGridApiContext();
|
|
40
69
|
const rootProps = useGridRootProps();
|
|
41
|
-
const
|
|
70
|
+
const ownerState = {
|
|
71
|
+
classes: rootProps.classes,
|
|
72
|
+
expanded: false
|
|
73
|
+
};
|
|
74
|
+
const classes = useUtilityClasses(ownerState);
|
|
42
75
|
const {
|
|
43
76
|
quickFilterParser,
|
|
44
77
|
quickFilterFormatter,
|
|
@@ -51,40 +84,65 @@ function GridToolbarQuickFilter(props) {
|
|
|
51
84
|
parser: quickFilterParser,
|
|
52
85
|
formatter: quickFilterFormatter,
|
|
53
86
|
debounceMs: debounceMs,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
87
|
+
render: (quickFilterProps, state) => {
|
|
88
|
+
const currentOwnerState = _extends({}, ownerState, {
|
|
89
|
+
expanded: state.expanded
|
|
90
|
+
});
|
|
91
|
+
return /*#__PURE__*/_jsxs(GridQuickFilterRoot, _extends({}, quickFilterProps, {
|
|
92
|
+
className: clsx(classes.root, className),
|
|
93
|
+
children: [/*#__PURE__*/_jsx(QuickFilterTrigger, {
|
|
94
|
+
render: triggerProps => /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, {
|
|
95
|
+
title: apiRef.current.getLocaleText('toolbarQuickFilterLabel'),
|
|
96
|
+
enterDelay: 0 // Prevents tooltip lagging behind transitioning trigger element
|
|
97
|
+
,
|
|
98
|
+
children: /*#__PURE__*/_jsx(GridQuickFilterTrigger, _extends({
|
|
99
|
+
className: classes.trigger
|
|
100
|
+
}, triggerProps, {
|
|
101
|
+
ownerState: currentOwnerState,
|
|
102
|
+
color: "default",
|
|
103
|
+
"aria-disabled": state.expanded,
|
|
104
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.quickFilterIcon, {
|
|
71
105
|
fontSize: "small"
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
106
|
+
})
|
|
107
|
+
}))
|
|
108
|
+
})
|
|
109
|
+
}), /*#__PURE__*/_jsx(QuickFilterControl, {
|
|
110
|
+
render: _ref => {
|
|
111
|
+
let {
|
|
112
|
+
ref,
|
|
113
|
+
slotProps: controlSlotProps
|
|
114
|
+
} = _ref,
|
|
115
|
+
controlProps = _objectWithoutPropertiesLoose(_ref, _excluded2);
|
|
116
|
+
return /*#__PURE__*/_jsx(GridQuickFilterTextField, _extends({
|
|
117
|
+
as: rootProps.slots.baseTextField,
|
|
118
|
+
className: classes.control,
|
|
119
|
+
ownerState: currentOwnerState,
|
|
120
|
+
inputRef: ref,
|
|
121
|
+
"aria-label": apiRef.current.getLocaleText('toolbarQuickFilterLabel'),
|
|
122
|
+
placeholder: apiRef.current.getLocaleText('toolbarQuickFilterPlaceholder'),
|
|
123
|
+
size: "small",
|
|
124
|
+
slotProps: _extends({
|
|
125
|
+
input: _extends({
|
|
126
|
+
startAdornment: /*#__PURE__*/_jsx(rootProps.slots.quickFilterIcon, {
|
|
79
127
|
fontSize: "small"
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
128
|
+
}),
|
|
129
|
+
endAdornment: controlProps.value ? /*#__PURE__*/_jsx(QuickFilterClear, {
|
|
130
|
+
render: /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, {
|
|
131
|
+
size: "small",
|
|
132
|
+
edge: "end",
|
|
133
|
+
"aria-label": apiRef.current.getLocaleText('toolbarQuickFilterDeleteIconLabel'),
|
|
134
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.quickFilterClearIcon, {
|
|
135
|
+
fontSize: "small"
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
}) : null
|
|
139
|
+
}, controlSlotProps?.input)
|
|
140
|
+
}, controlSlotProps)
|
|
141
|
+
}, rootProps.slotProps?.baseTextField, controlProps, slotProps?.root, other));
|
|
142
|
+
}
|
|
143
|
+
})]
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
88
146
|
});
|
|
89
147
|
}
|
|
90
148
|
process.env.NODE_ENV !== "production" ? GridToolbarQuickFilter.propTypes = {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import Menu from '@mui/material/Menu';
|
|
5
4
|
import useId from '@mui/utils/useId';
|
|
6
5
|
import { styled } from '@mui/system';
|
|
6
|
+
import { GridMenu } from "../menu/GridMenu.js";
|
|
7
7
|
import { Toolbar } from "./Toolbar.js";
|
|
8
8
|
import { ToolbarButton } from "./ToolbarButton.js";
|
|
9
9
|
import { FilterPanelTrigger } from "../filterPanel/index.js";
|
|
@@ -74,30 +74,33 @@ function GridToolbar(props) {
|
|
|
74
74
|
"aria-controls": exportMenuId,
|
|
75
75
|
"aria-haspopup": "true",
|
|
76
76
|
"aria-expanded": exportMenuOpen ? 'true' : undefined,
|
|
77
|
-
onClick: () => setExportMenuOpen(
|
|
77
|
+
onClick: () => setExportMenuOpen(!exportMenuOpen),
|
|
78
78
|
children: /*#__PURE__*/_jsx(rootProps.slots.exportIcon, {
|
|
79
79
|
fontSize: "small"
|
|
80
80
|
})
|
|
81
81
|
})
|
|
82
|
-
}), /*#__PURE__*/
|
|
83
|
-
|
|
84
|
-
anchorEl: exportMenuTriggerRef.current,
|
|
82
|
+
}), /*#__PURE__*/_jsx(GridMenu, {
|
|
83
|
+
target: exportMenuTriggerRef.current,
|
|
85
84
|
open: exportMenuOpen,
|
|
86
85
|
onClose: closeExportMenu,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
86
|
+
position: "bottom-start",
|
|
87
|
+
children: /*#__PURE__*/_jsxs(rootProps.slots.baseMenuList, _extends({
|
|
88
|
+
id: exportMenuId,
|
|
89
|
+
"aria-labelledby": exportMenuTriggerId,
|
|
90
|
+
autoFocusItem: true
|
|
91
|
+
}, rootProps.slotProps?.baseMenuList, {
|
|
92
|
+
children: [!printOptions?.disableToolbarButton && /*#__PURE__*/_jsx(ExportPrint, {
|
|
93
|
+
render: /*#__PURE__*/_jsx(rootProps.slots.baseMenuItem, _extends({}, rootProps.slotProps?.baseMenuItem)),
|
|
94
|
+
options: printOptions,
|
|
95
|
+
onClick: closeExportMenu,
|
|
96
|
+
children: apiRef.current.getLocaleText('toolbarExportPrint')
|
|
97
|
+
}), !csvOptions?.disableToolbarButton && /*#__PURE__*/_jsx(ExportCsv, {
|
|
98
|
+
render: /*#__PURE__*/_jsx(rootProps.slots.baseMenuItem, _extends({}, rootProps.slotProps?.baseMenuItem)),
|
|
99
|
+
options: csvOptions,
|
|
100
|
+
onClick: closeExportMenu,
|
|
101
|
+
children: apiRef.current.getLocaleText('toolbarExportCSV')
|
|
102
|
+
}), additionalExportMenuItems?.(closeExportMenu)]
|
|
103
|
+
}))
|
|
101
104
|
})]
|
|
102
105
|
}), showQuickFilter && /*#__PURE__*/_jsx(GridToolbarQuickFilter, _extends({}, quickFilterProps))]
|
|
103
106
|
});
|
|
@@ -8,7 +8,7 @@ export type ToolbarProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
8
8
|
render?: RenderProp<React.ComponentProps<typeof ToolbarRoot>>;
|
|
9
9
|
};
|
|
10
10
|
type OwnerState = DataGridProcessedProps;
|
|
11
|
-
declare const ToolbarRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/
|
|
11
|
+
declare const ToolbarRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/system").Theme> & {
|
|
12
12
|
ownerState: OwnerState;
|
|
13
13
|
}, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
14
14
|
/**
|
|
@@ -3,7 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
const _excluded = ["render", "className"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import { styled } from '@mui/
|
|
6
|
+
import { styled } from '@mui/system';
|
|
7
7
|
import composeClasses from '@mui/utils/composeClasses';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
@@ -31,6 +31,8 @@ const ToolbarRoot = styled('div', {
|
|
|
31
31
|
alignItems: 'center',
|
|
32
32
|
gap: vars.spacing(0.25),
|
|
33
33
|
padding: vars.spacing(0.75),
|
|
34
|
+
minHeight: 52,
|
|
35
|
+
boxSizing: 'border-box',
|
|
34
36
|
borderBottom: `1px solid ${vars.colors.border.base}`
|
|
35
37
|
});
|
|
36
38
|
|
|
@@ -56,44 +58,95 @@ const Toolbar = forwardRef(function Toolbar(props, ref) {
|
|
|
56
58
|
const classes = useUtilityClasses(rootProps);
|
|
57
59
|
const [focusableItemId, setFocusableItemId] = React.useState(null);
|
|
58
60
|
const [items, setItems] = React.useState([]);
|
|
59
|
-
const registerItem = React.useCallback(
|
|
60
|
-
setItems(prevItems => [...prevItems,
|
|
61
|
+
const registerItem = React.useCallback((id, itemRef) => {
|
|
62
|
+
setItems(prevItems => [...prevItems, {
|
|
63
|
+
id,
|
|
64
|
+
ref: itemRef
|
|
65
|
+
}]);
|
|
61
66
|
}, []);
|
|
62
|
-
const unregisterItem = React.useCallback(
|
|
63
|
-
setItems(prevItems => prevItems.filter(i => i !==
|
|
64
|
-
if (focusableItemId ===
|
|
67
|
+
const unregisterItem = React.useCallback(id => {
|
|
68
|
+
setItems(prevItems => prevItems.filter(i => i.id !== id));
|
|
69
|
+
if (focusableItemId === id) {
|
|
65
70
|
setFocusableItemId(null);
|
|
66
71
|
}
|
|
67
72
|
}, [focusableItemId]);
|
|
73
|
+
const findEnabledItem = React.useCallback((startIndex, step, wrap = true) => {
|
|
74
|
+
let index = startIndex;
|
|
75
|
+
const itemCount = items.length;
|
|
76
|
+
|
|
77
|
+
// Look for enabled items in the specified direction
|
|
78
|
+
for (let i = 0; i < itemCount; i += 1) {
|
|
79
|
+
index += step;
|
|
80
|
+
|
|
81
|
+
// Handle wrapping around the ends
|
|
82
|
+
if (index >= itemCount) {
|
|
83
|
+
if (!wrap) {
|
|
84
|
+
return -1;
|
|
85
|
+
}
|
|
86
|
+
index = 0;
|
|
87
|
+
} else if (index < 0) {
|
|
88
|
+
if (!wrap) {
|
|
89
|
+
return -1;
|
|
90
|
+
}
|
|
91
|
+
index = itemCount - 1;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Return if we found an enabled item
|
|
95
|
+
if (!items[index].ref.current?.disabled && items[index].ref.current?.ariaDisabled !== 'true') {
|
|
96
|
+
return index;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// If we've checked all items and found none enabled
|
|
101
|
+
return -1;
|
|
102
|
+
}, [items]);
|
|
68
103
|
const onItemKeyDown = React.useCallback(event => {
|
|
69
104
|
if (!focusableItemId) {
|
|
70
105
|
return;
|
|
71
106
|
}
|
|
107
|
+
const currentIndex = items.findIndex(item => item.id === focusableItemId);
|
|
108
|
+
let newIndex = -1;
|
|
72
109
|
if (event.key === 'ArrowRight') {
|
|
73
110
|
event.preventDefault();
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
if (event.key === 'ArrowLeft') {
|
|
111
|
+
newIndex = findEnabledItem(currentIndex, 1);
|
|
112
|
+
} else if (event.key === 'ArrowLeft') {
|
|
78
113
|
event.preventDefault();
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
if (event.key === 'Home') {
|
|
114
|
+
newIndex = findEnabledItem(currentIndex, -1);
|
|
115
|
+
} else if (event.key === 'Home') {
|
|
83
116
|
event.preventDefault();
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
if (event.key === 'End') {
|
|
117
|
+
newIndex = findEnabledItem(-1, 1, false);
|
|
118
|
+
} else if (event.key === 'End') {
|
|
87
119
|
event.preventDefault();
|
|
88
|
-
|
|
120
|
+
newIndex = findEnabledItem(items.length, -1, false);
|
|
121
|
+
}
|
|
122
|
+
if (newIndex >= 0 && newIndex < items.length) {
|
|
123
|
+
const item = items[newIndex];
|
|
124
|
+
setFocusableItemId(item.id);
|
|
125
|
+
item.ref.current?.focus();
|
|
126
|
+
}
|
|
127
|
+
}, [items, focusableItemId, findEnabledItem]);
|
|
128
|
+
const onItemFocus = React.useCallback(id => {
|
|
129
|
+
if (focusableItemId !== id) {
|
|
130
|
+
setFocusableItemId(id);
|
|
131
|
+
}
|
|
132
|
+
}, [focusableItemId]);
|
|
133
|
+
const onItemDisabled = React.useCallback(id => {
|
|
134
|
+
const currentIndex = items.findIndex(item => item.id === id);
|
|
135
|
+
const newIndex = findEnabledItem(currentIndex, 1);
|
|
136
|
+
if (newIndex >= 0 && newIndex < items.length) {
|
|
137
|
+
const item = items[newIndex];
|
|
138
|
+
setFocusableItemId(item.id);
|
|
139
|
+
item.ref.current?.focus();
|
|
89
140
|
}
|
|
90
|
-
}, [items,
|
|
141
|
+
}, [items, findEnabledItem]);
|
|
91
142
|
const contextValue = React.useMemo(() => ({
|
|
92
143
|
focusableItemId,
|
|
93
144
|
registerItem,
|
|
94
145
|
unregisterItem,
|
|
95
|
-
onItemKeyDown
|
|
96
|
-
|
|
146
|
+
onItemKeyDown,
|
|
147
|
+
onItemFocus,
|
|
148
|
+
onItemDisabled
|
|
149
|
+
}), [focusableItemId, registerItem, unregisterItem, onItemKeyDown, onItemFocus, onItemDisabled]);
|
|
97
150
|
const element = useGridComponentRenderer(ToolbarRoot, render, _extends({
|
|
98
151
|
role: 'toolbar',
|
|
99
152
|
'aria-orientation': 'horizontal',
|
|
@@ -104,7 +157,7 @@ const Toolbar = forwardRef(function Toolbar(props, ref) {
|
|
|
104
157
|
}));
|
|
105
158
|
React.useEffect(() => {
|
|
106
159
|
if (items.length > 0) {
|
|
107
|
-
setFocusableItemId(items[0]);
|
|
160
|
+
setFocusableItemId(items[0].id);
|
|
108
161
|
}
|
|
109
162
|
}, [items]);
|
|
110
163
|
return /*#__PURE__*/_jsx(ToolbarContext.Provider, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["render"];
|
|
3
|
+
const _excluded = ["render", "onKeyDown", "onFocus", "disabled", "aria-disabled"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { unstable_useForkRef as useForkRef } from '@mui/utils';
|
|
@@ -24,7 +24,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
24
24
|
*/
|
|
25
25
|
const ToolbarButton = forwardRef(function ToolbarButton(props, ref) {
|
|
26
26
|
const {
|
|
27
|
-
render
|
|
27
|
+
render,
|
|
28
|
+
onKeyDown,
|
|
29
|
+
onFocus,
|
|
30
|
+
disabled,
|
|
31
|
+
'aria-disabled': ariaDisabled
|
|
28
32
|
} = props,
|
|
29
33
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
30
34
|
const id = useId();
|
|
@@ -35,28 +39,44 @@ const ToolbarButton = forwardRef(function ToolbarButton(props, ref) {
|
|
|
35
39
|
focusableItemId,
|
|
36
40
|
registerItem,
|
|
37
41
|
unregisterItem,
|
|
38
|
-
onItemKeyDown
|
|
42
|
+
onItemKeyDown,
|
|
43
|
+
onItemFocus,
|
|
44
|
+
onItemDisabled
|
|
39
45
|
} = useToolbarContext();
|
|
46
|
+
const handleKeyDown = event => {
|
|
47
|
+
onItemKeyDown(event);
|
|
48
|
+
onKeyDown?.(event);
|
|
49
|
+
};
|
|
50
|
+
const handleFocus = event => {
|
|
51
|
+
onItemFocus(id);
|
|
52
|
+
onFocus?.(event);
|
|
53
|
+
};
|
|
40
54
|
React.useEffect(() => {
|
|
41
|
-
registerItem(id);
|
|
55
|
+
registerItem(id, buttonRef);
|
|
42
56
|
return () => unregisterItem(id);
|
|
43
57
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
44
58
|
}, []);
|
|
45
|
-
const
|
|
59
|
+
const previousDisabled = React.useRef(disabled);
|
|
46
60
|
React.useEffect(() => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
isInitialFocus.current = false;
|
|
50
|
-
return;
|
|
61
|
+
if (previousDisabled.current !== disabled && disabled === true) {
|
|
62
|
+
onItemDisabled(id, disabled);
|
|
51
63
|
}
|
|
52
|
-
|
|
53
|
-
|
|
64
|
+
previousDisabled.current = disabled;
|
|
65
|
+
}, [disabled, id, onItemDisabled]);
|
|
66
|
+
const previousAriaDisabled = React.useRef(ariaDisabled);
|
|
67
|
+
React.useEffect(() => {
|
|
68
|
+
if (previousAriaDisabled.current !== ariaDisabled && ariaDisabled === true) {
|
|
69
|
+
onItemDisabled(id, true);
|
|
54
70
|
}
|
|
55
|
-
|
|
71
|
+
previousAriaDisabled.current = ariaDisabled;
|
|
72
|
+
}, [ariaDisabled, id, onItemDisabled]);
|
|
56
73
|
const element = useGridComponentRenderer(rootProps.slots.baseIconButton, render, _extends({}, rootProps.slotProps?.baseIconButton, {
|
|
57
|
-
tabIndex: focusableItemId === id ? 0 : -1
|
|
58
|
-
onKeyDown: onItemKeyDown
|
|
74
|
+
tabIndex: focusableItemId === id ? 0 : -1
|
|
59
75
|
}, other, {
|
|
76
|
+
disabled,
|
|
77
|
+
'aria-disabled': ariaDisabled,
|
|
78
|
+
onKeyDown: handleKeyDown,
|
|
79
|
+
onFocus: handleFocus,
|
|
60
80
|
ref: handleRef
|
|
61
81
|
}));
|
|
62
82
|
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export interface ToolbarContextValue {
|
|
3
3
|
focusableItemId: string | null;
|
|
4
|
-
registerItem: (
|
|
5
|
-
unregisterItem: (
|
|
4
|
+
registerItem: (id: string, ref: React.RefObject<HTMLButtonElement | null>) => void;
|
|
5
|
+
unregisterItem: (id: string) => void;
|
|
6
6
|
onItemKeyDown: (event: React.KeyboardEvent<HTMLButtonElement>) => void;
|
|
7
|
+
onItemFocus: (id: string) => void;
|
|
8
|
+
onItemDisabled: (id: string, disabled: boolean) => void;
|
|
7
9
|
}
|
|
8
10
|
export declare const ToolbarContext: React.Context<ToolbarContextValue | undefined>;
|
|
9
11
|
export declare function useToolbarContext(): ToolbarContextValue;
|
|
@@ -631,6 +631,18 @@ export interface GridClasses {
|
|
|
631
631
|
* Styles applied to the toolbar prompt control send button element.
|
|
632
632
|
*/
|
|
633
633
|
toolbarPromptControlSendButton: string;
|
|
634
|
+
/**
|
|
635
|
+
* Styles applied to the toolbar quick filter root element.
|
|
636
|
+
*/
|
|
637
|
+
toolbarQuickFilter: string;
|
|
638
|
+
/**
|
|
639
|
+
* Styles applied to the toolbar quick filter trigger element.
|
|
640
|
+
*/
|
|
641
|
+
toolbarQuickFilterTrigger: string;
|
|
642
|
+
/**
|
|
643
|
+
* Styles applied to the toolbar quick filter control element.
|
|
644
|
+
*/
|
|
645
|
+
toolbarQuickFilterControl: string;
|
|
634
646
|
/**
|
|
635
647
|
* Styles applied the grid if `showColumnVerticalBorder={true}`.
|
|
636
648
|
*/
|