@mui/x-data-grid 8.0.0-alpha.13 → 8.0.0-alpha.14
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 +131 -0
- package/colDef/gridActionsColDef.js +1 -1
- package/colDef/gridBooleanColDef.js +1 -1
- package/colDef/gridCheckboxSelectionColDef.js +1 -1
- package/components/columnsManagement/GridColumnsManagement.js +1 -0
- package/components/columnsPanel/ColumnsPanelTrigger.d.ts +33 -0
- package/components/columnsPanel/ColumnsPanelTrigger.js +209 -0
- package/components/columnsPanel/index.d.ts +1 -0
- package/components/columnsPanel/index.js +16 -0
- package/components/export/ExportCsv.d.ts +30 -0
- package/components/export/ExportCsv.js +196 -0
- package/components/export/ExportPrint.d.ts +30 -0
- package/components/export/ExportPrint.js +196 -0
- package/components/export/index.d.ts +2 -0
- package/components/export/index.js +27 -0
- package/components/filterPanel/FilterPanelTrigger.d.ts +37 -0
- package/components/filterPanel/FilterPanelTrigger.js +212 -0
- package/components/filterPanel/index.d.ts +1 -0
- package/components/filterPanel/index.js +16 -0
- package/components/index.d.ts +6 -1
- package/components/index.js +60 -0
- package/components/quickFilter/QuickFilter.d.ts +41 -0
- package/components/quickFilter/QuickFilter.js +110 -0
- package/components/quickFilter/QuickFilterClear.d.ts +28 -0
- package/components/quickFilter/QuickFilterClear.js +161 -0
- package/components/quickFilter/QuickFilterContext.d.ts +13 -0
- package/components/quickFilter/QuickFilterContext.js +17 -0
- package/components/quickFilter/QuickFilterControl.d.ts +28 -0
- package/components/quickFilter/QuickFilterControl.js +104 -0
- package/components/quickFilter/index.d.ts +3 -0
- package/components/quickFilter/index.js +38 -0
- package/components/toolbar/GridToolbar.d.ts +1 -1
- package/components/toolbar/GridToolbar.js +2 -2
- package/components/toolbar/GridToolbarQuickFilter.js +54 -87
- package/components/toolbarV8/GridToolbar.d.ts +11 -0
- package/components/toolbarV8/GridToolbar.js +142 -0
- package/components/toolbarV8/Toolbar.d.ts +32 -0
- package/components/toolbarV8/Toolbar.js +132 -0
- package/components/toolbarV8/ToolbarButton.d.ts +23 -0
- package/components/toolbarV8/ToolbarButton.js +179 -0
- package/components/toolbarV8/ToolbarContext.d.ts +9 -0
- package/components/toolbarV8/ToolbarContext.js +17 -0
- package/components/toolbarV8/index.d.ts +2 -0
- package/components/toolbarV8/index.js +27 -0
- package/components/virtualization/GridVirtualScrollbar.js +7 -1
- package/constants/defaultGridSlotsComponents.js +2 -1
- package/constants/gridClasses.d.ts +4 -0
- package/esm/colDef/gridActionsColDef.js +1 -1
- package/esm/colDef/gridBooleanColDef.js +1 -1
- package/esm/colDef/gridCheckboxSelectionColDef.js +1 -1
- package/esm/components/columnsManagement/GridColumnsManagement.js +1 -0
- package/esm/components/columnsPanel/ColumnsPanelTrigger.d.ts +33 -0
- package/esm/components/columnsPanel/ColumnsPanelTrigger.js +202 -0
- package/esm/components/columnsPanel/index.d.ts +1 -0
- package/esm/components/columnsPanel/index.js +1 -0
- package/esm/components/export/ExportCsv.d.ts +30 -0
- package/esm/components/export/ExportCsv.js +189 -0
- package/esm/components/export/ExportPrint.d.ts +30 -0
- package/esm/components/export/ExportPrint.js +189 -0
- package/esm/components/export/index.d.ts +2 -0
- package/esm/components/export/index.js +2 -0
- package/esm/components/filterPanel/FilterPanelTrigger.d.ts +37 -0
- package/esm/components/filterPanel/FilterPanelTrigger.js +205 -0
- package/esm/components/filterPanel/index.d.ts +1 -0
- package/esm/components/filterPanel/index.js +1 -0
- package/esm/components/index.d.ts +6 -1
- package/esm/components/index.js +6 -1
- package/esm/components/quickFilter/QuickFilter.d.ts +41 -0
- package/esm/components/quickFilter/QuickFilter.js +103 -0
- package/esm/components/quickFilter/QuickFilterClear.d.ts +28 -0
- package/esm/components/quickFilter/QuickFilterClear.js +154 -0
- package/esm/components/quickFilter/QuickFilterContext.d.ts +13 -0
- package/esm/components/quickFilter/QuickFilterContext.js +9 -0
- package/esm/components/quickFilter/QuickFilterControl.d.ts +28 -0
- package/esm/components/quickFilter/QuickFilterControl.js +97 -0
- package/esm/components/quickFilter/index.d.ts +3 -0
- package/esm/components/quickFilter/index.js +3 -0
- package/esm/components/toolbar/GridToolbar.d.ts +1 -1
- package/esm/components/toolbar/GridToolbar.js +2 -2
- package/esm/components/toolbar/GridToolbarQuickFilter.js +56 -87
- package/esm/components/toolbarV8/GridToolbar.d.ts +11 -0
- package/esm/components/toolbarV8/GridToolbar.js +135 -0
- package/esm/components/toolbarV8/Toolbar.d.ts +32 -0
- package/esm/components/toolbarV8/Toolbar.js +125 -0
- package/esm/components/toolbarV8/ToolbarButton.d.ts +23 -0
- package/esm/components/toolbarV8/ToolbarButton.js +172 -0
- package/esm/components/toolbarV8/ToolbarContext.d.ts +9 -0
- package/esm/components/toolbarV8/ToolbarContext.js +9 -0
- package/esm/components/toolbarV8/index.d.ts +2 -0
- package/esm/components/toolbarV8/index.js +2 -0
- package/esm/components/virtualization/GridVirtualScrollbar.js +7 -1
- package/esm/constants/defaultGridSlotsComponents.js +2 -1
- package/esm/constants/gridClasses.d.ts +4 -0
- package/esm/hooks/features/rows/useGridRowsMeta.js +8 -0
- package/esm/hooks/features/virtualization/useGridVirtualScroller.d.ts +0 -2
- package/esm/hooks/features/virtualization/useGridVirtualScroller.js +0 -2
- package/esm/hooks/utils/index.d.ts +2 -1
- package/esm/hooks/utils/useGridComponentRenderer.d.ts +12 -0
- package/esm/hooks/utils/useGridComponentRenderer.js +36 -0
- package/esm/index.js +1 -1
- package/esm/internals/demo/TailwindDemoContainer.d.ts +11 -0
- package/esm/internals/demo/TailwindDemoContainer.js +55 -0
- package/esm/internals/demo/index.d.ts +1 -0
- package/esm/internals/demo/index.js +1 -0
- package/esm/internals/index.d.ts +4 -0
- package/esm/internals/index.js +3 -0
- package/esm/material/icons/index.d.ts +3 -3
- package/esm/material/icons/index.js +6 -6
- package/esm/material/index.js +3 -3
- package/esm/models/gridBaseSlots.d.ts +5 -1
- package/esm/models/gridIconSlotsComponent.d.ts +1 -1
- package/esm/models/gridSlotsComponent.d.ts +1 -2
- package/hooks/features/rows/useGridRowsMeta.js +8 -0
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +0 -2
- package/hooks/features/virtualization/useGridVirtualScroller.js +0 -2
- package/hooks/utils/index.d.ts +2 -1
- package/hooks/utils/useGridComponentRenderer.d.ts +12 -0
- package/hooks/utils/useGridComponentRenderer.js +44 -0
- package/index.js +1 -1
- package/internals/demo/TailwindDemoContainer.d.ts +11 -0
- package/internals/demo/TailwindDemoContainer.js +63 -0
- package/internals/demo/index.d.ts +1 -0
- package/internals/demo/index.js +12 -0
- package/internals/index.d.ts +4 -0
- package/internals/index.js +28 -0
- package/material/icons/index.d.ts +3 -3
- package/material/icons/index.js +7 -7
- package/material/index.js +2 -2
- package/models/gridBaseSlots.d.ts +5 -1
- package/models/gridIconSlotsComponent.d.ts +1 -1
- package/models/gridSlotsComponent.d.ts +1 -2
- package/modern/colDef/gridActionsColDef.js +1 -1
- package/modern/colDef/gridBooleanColDef.js +1 -1
- package/modern/colDef/gridCheckboxSelectionColDef.js +1 -1
- package/modern/components/columnsManagement/GridColumnsManagement.js +1 -0
- package/modern/components/columnsPanel/ColumnsPanelTrigger.d.ts +33 -0
- package/modern/components/columnsPanel/ColumnsPanelTrigger.js +202 -0
- package/modern/components/columnsPanel/index.d.ts +1 -0
- package/modern/components/columnsPanel/index.js +1 -0
- package/modern/components/export/ExportCsv.d.ts +30 -0
- package/modern/components/export/ExportCsv.js +189 -0
- package/modern/components/export/ExportPrint.d.ts +30 -0
- package/modern/components/export/ExportPrint.js +189 -0
- package/modern/components/export/index.d.ts +2 -0
- package/modern/components/export/index.js +2 -0
- package/modern/components/filterPanel/FilterPanelTrigger.d.ts +37 -0
- package/modern/components/filterPanel/FilterPanelTrigger.js +205 -0
- package/modern/components/filterPanel/index.d.ts +1 -0
- package/modern/components/filterPanel/index.js +1 -0
- package/modern/components/index.d.ts +6 -1
- package/modern/components/index.js +6 -1
- package/modern/components/quickFilter/QuickFilter.d.ts +41 -0
- package/modern/components/quickFilter/QuickFilter.js +103 -0
- package/modern/components/quickFilter/QuickFilterClear.d.ts +28 -0
- package/modern/components/quickFilter/QuickFilterClear.js +154 -0
- package/modern/components/quickFilter/QuickFilterContext.d.ts +13 -0
- package/modern/components/quickFilter/QuickFilterContext.js +9 -0
- package/modern/components/quickFilter/QuickFilterControl.d.ts +28 -0
- package/modern/components/quickFilter/QuickFilterControl.js +97 -0
- package/modern/components/quickFilter/index.d.ts +3 -0
- package/modern/components/quickFilter/index.js +3 -0
- package/modern/components/toolbar/GridToolbar.d.ts +1 -1
- package/modern/components/toolbar/GridToolbar.js +2 -2
- package/modern/components/toolbar/GridToolbarQuickFilter.js +56 -87
- package/modern/components/toolbarV8/GridToolbar.d.ts +11 -0
- package/modern/components/toolbarV8/GridToolbar.js +135 -0
- package/modern/components/toolbarV8/Toolbar.d.ts +32 -0
- package/modern/components/toolbarV8/Toolbar.js +125 -0
- package/modern/components/toolbarV8/ToolbarButton.d.ts +23 -0
- package/modern/components/toolbarV8/ToolbarButton.js +172 -0
- package/modern/components/toolbarV8/ToolbarContext.d.ts +9 -0
- package/modern/components/toolbarV8/ToolbarContext.js +9 -0
- package/modern/components/toolbarV8/index.d.ts +2 -0
- package/modern/components/toolbarV8/index.js +2 -0
- package/modern/components/virtualization/GridVirtualScrollbar.js +7 -1
- package/modern/constants/defaultGridSlotsComponents.js +2 -1
- package/modern/constants/gridClasses.d.ts +4 -0
- package/modern/hooks/features/rows/useGridRowsMeta.js +8 -0
- package/modern/hooks/features/virtualization/useGridVirtualScroller.d.ts +0 -2
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +0 -2
- package/modern/hooks/utils/index.d.ts +2 -1
- package/modern/hooks/utils/useGridComponentRenderer.d.ts +12 -0
- package/modern/hooks/utils/useGridComponentRenderer.js +36 -0
- package/modern/index.js +1 -1
- package/modern/internals/demo/TailwindDemoContainer.d.ts +11 -0
- package/modern/internals/demo/TailwindDemoContainer.js +55 -0
- package/modern/internals/demo/index.d.ts +1 -0
- package/modern/internals/demo/index.js +1 -0
- package/modern/internals/index.d.ts +4 -0
- package/modern/internals/index.js +3 -0
- package/modern/material/icons/index.d.ts +3 -3
- package/modern/material/icons/index.js +6 -6
- package/modern/material/index.js +3 -3
- package/modern/models/gridBaseSlots.d.ts +5 -1
- package/modern/models/gridIconSlotsComponent.d.ts +1 -1
- package/modern/models/gridSlotsComponent.d.ts +1 -2
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["quickFilterParser", "quickFilterFormatter", "debounceMs", "className", "slotProps"]
|
|
3
|
+
const _excluded = ["quickFilterParser", "quickFilterFormatter", "debounceMs", "className", "slotProps"],
|
|
4
|
+
_excluded2 = ["ref", "slotProps"];
|
|
4
5
|
import * as React from 'react';
|
|
5
|
-
import clsx from 'clsx';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
|
-
import { styled } from '@mui/material/styles';
|
|
8
|
-
import { unstable_debounce as debounce } from '@mui/utils';
|
|
9
7
|
import composeClasses from '@mui/utils/composeClasses';
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
8
|
+
import { styled } from '@mui/system';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
// import { NotRendered } from '../../utils/assert';
|
|
11
|
+
|
|
12
12
|
import { getDataGridUtilityClass } from "../../constants/index.js";
|
|
13
13
|
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
14
14
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
15
|
-
import {
|
|
16
|
-
import { gridQuickFilterValuesSelector } from "../../hooks/features/filter/index.js";
|
|
17
|
-
import { isDeepEqual } from "../../utils/utils.js";
|
|
15
|
+
import { QuickFilter, QuickFilterClear, QuickFilterControl } from "../quickFilter/index.js";
|
|
18
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
17
|
const useUtilityClasses = ownerState => {
|
|
20
18
|
const {
|
|
@@ -25,98 +23,69 @@ const useUtilityClasses = ownerState => {
|
|
|
25
23
|
};
|
|
26
24
|
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
27
25
|
};
|
|
28
|
-
|
|
26
|
+
|
|
27
|
+
// TODO: Use NotRendered from /utils/assert
|
|
28
|
+
// Currently causes react-docgen to fail
|
|
29
|
+
const GridToolbarQuickFilterRoot = styled(_props => {
|
|
30
|
+
throw new Error('Failed assertion: should not be rendered');
|
|
31
|
+
}, {
|
|
29
32
|
name: 'MuiDataGrid',
|
|
30
|
-
slot: 'ToolbarQuickFilter'
|
|
31
|
-
overridesResolver: (props, styles) => styles.toolbarQuickFilter
|
|
33
|
+
slot: 'ToolbarQuickFilter'
|
|
32
34
|
})({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
[`& input[type="search"]::-webkit-search-decoration,
|
|
37
|
-
& input[type="search"]::-webkit-search-cancel-button,
|
|
38
|
-
& input[type="search"]::-webkit-search-results-button,
|
|
39
|
-
& input[type="search"]::-webkit-search-results-decoration`]: {
|
|
40
|
-
/* clears the 'X' icon from Chrome */
|
|
41
|
-
display: 'none'
|
|
42
|
-
}
|
|
35
|
+
width: 260,
|
|
36
|
+
marginLeft: 'auto'
|
|
43
37
|
});
|
|
44
|
-
const defaultSearchValueParser = searchText => searchText.split(' ').filter(word => word !== '');
|
|
45
|
-
const defaultSearchValueFormatter = values => values.join(' ');
|
|
46
38
|
function GridToolbarQuickFilter(props) {
|
|
47
39
|
const apiRef = useGridApiContext();
|
|
48
40
|
const rootProps = useGridRootProps();
|
|
49
41
|
const classes = useUtilityClasses(rootProps);
|
|
50
|
-
const quickFilterValues = useGridSelector(apiRef, gridQuickFilterValuesSelector);
|
|
51
42
|
const {
|
|
52
|
-
quickFilterParser
|
|
53
|
-
quickFilterFormatter
|
|
54
|
-
debounceMs
|
|
43
|
+
quickFilterParser,
|
|
44
|
+
quickFilterFormatter,
|
|
45
|
+
debounceMs,
|
|
55
46
|
className,
|
|
56
47
|
slotProps
|
|
57
48
|
} = props,
|
|
58
49
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
React.useEffect(() => debouncedUpdateSearchValue.clear, [debouncedUpdateSearchValue]);
|
|
77
|
-
const handleSearchValueChange = React.useCallback(event => {
|
|
78
|
-
const newSearchValue = event.target.value;
|
|
79
|
-
setSearchValue(newSearchValue);
|
|
80
|
-
debouncedUpdateSearchValue(newSearchValue);
|
|
81
|
-
}, [debouncedUpdateSearchValue]);
|
|
82
|
-
const handleSearchReset = React.useCallback(() => {
|
|
83
|
-
setSearchValue('');
|
|
84
|
-
updateSearchValue('');
|
|
85
|
-
}, [updateSearchValue]);
|
|
86
|
-
return /*#__PURE__*/_jsx(GridToolbarQuickFilterRoot, _extends({
|
|
87
|
-
as: rootProps.slots.baseTextField,
|
|
88
|
-
ownerState: rootProps,
|
|
89
|
-
size: "small",
|
|
90
|
-
value: searchValue,
|
|
91
|
-
onChange: handleSearchValueChange,
|
|
92
|
-
className: clsx(classes.root, className),
|
|
93
|
-
placeholder: apiRef.current.getLocaleText('toolbarQuickFilterPlaceholder'),
|
|
94
|
-
"aria-label": apiRef.current.getLocaleText('toolbarQuickFilterLabel'),
|
|
95
|
-
type: "search"
|
|
96
|
-
}, other, {
|
|
97
|
-
slotProps: _extends({}, slotProps?.root.slotProps, {
|
|
98
|
-
input: _extends({
|
|
99
|
-
startAdornment: /*#__PURE__*/_jsx(rootProps.slots.quickFilterIcon, {
|
|
100
|
-
fontSize: "small"
|
|
101
|
-
}),
|
|
102
|
-
endAdornment: /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
|
|
103
|
-
"aria-label": apiRef.current.getLocaleText('toolbarQuickFilterDeleteIconLabel'),
|
|
50
|
+
return /*#__PURE__*/_jsx(QuickFilter, {
|
|
51
|
+
parser: quickFilterParser,
|
|
52
|
+
formatter: quickFilterFormatter,
|
|
53
|
+
debounceMs: debounceMs,
|
|
54
|
+
children: /*#__PURE__*/_jsx(QuickFilterControl, {
|
|
55
|
+
render: _ref => {
|
|
56
|
+
let {
|
|
57
|
+
ref,
|
|
58
|
+
slotProps: controlSlotProps
|
|
59
|
+
} = _ref,
|
|
60
|
+
controlProps = _objectWithoutPropertiesLoose(_ref, _excluded2);
|
|
61
|
+
return /*#__PURE__*/_jsx(GridToolbarQuickFilterRoot, _extends({
|
|
62
|
+
as: rootProps.slots.baseTextField,
|
|
63
|
+
className: clsx(classes.root, className),
|
|
64
|
+
inputRef: ref,
|
|
65
|
+
"aria-label": apiRef.current.getLocaleText('toolbarQuickFilterLabel'),
|
|
66
|
+
placeholder: apiRef.current.getLocaleText('toolbarQuickFilterPlaceholder'),
|
|
104
67
|
size: "small",
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
68
|
+
slotProps: _extends({
|
|
69
|
+
input: _extends({
|
|
70
|
+
startAdornment: /*#__PURE__*/_jsx(rootProps.slots.quickFilterIcon, {
|
|
71
|
+
fontSize: "small"
|
|
72
|
+
}),
|
|
73
|
+
endAdornment: controlProps.value ? /*#__PURE__*/_jsx(QuickFilterClear, {
|
|
74
|
+
render: /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, {
|
|
75
|
+
size: "small",
|
|
76
|
+
edge: "end",
|
|
77
|
+
"aria-label": apiRef.current.getLocaleText('toolbarQuickFilterDeleteIconLabel'),
|
|
78
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.quickFilterClearIcon, {
|
|
79
|
+
fontSize: "small"
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
}) : null
|
|
83
|
+
}, controlSlotProps?.input)
|
|
84
|
+
}, controlSlotProps)
|
|
85
|
+
}, rootProps.slotProps?.baseTextField, controlProps, slotProps?.root, other));
|
|
86
|
+
}
|
|
118
87
|
})
|
|
119
|
-
}
|
|
88
|
+
});
|
|
120
89
|
}
|
|
121
90
|
process.env.NODE_ENV !== "production" ? GridToolbarQuickFilter.propTypes = {
|
|
122
91
|
// ----------------------------- Warning --------------------------------
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GridSlotProps } from "../../models/gridSlotsComponentsProps.js";
|
|
3
|
+
interface GridToolbarInternalProps {
|
|
4
|
+
additionalExportMenuItems?: (onMenuItemClick: () => void) => React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export type GridToolbarProps = GridSlotProps['toolbar'] & GridToolbarInternalProps;
|
|
7
|
+
declare function GridToolbar(props: GridToolbarProps): React.JSX.Element;
|
|
8
|
+
declare namespace GridToolbar {
|
|
9
|
+
var propTypes: any;
|
|
10
|
+
}
|
|
11
|
+
export { GridToolbar };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import Menu from '@mui/material/Menu';
|
|
5
|
+
import useId from '@mui/utils/useId';
|
|
6
|
+
import { styled } from '@mui/system';
|
|
7
|
+
import { Toolbar } from "./Toolbar.js";
|
|
8
|
+
import { ToolbarButton } from "./ToolbarButton.js";
|
|
9
|
+
import { FilterPanelTrigger } from "../filterPanel/index.js";
|
|
10
|
+
import { ColumnsPanelTrigger } from "../columnsPanel/index.js";
|
|
11
|
+
import { ExportCsv, ExportPrint } from "../export/index.js";
|
|
12
|
+
import { GridToolbarQuickFilter } from "../toolbar/GridToolbarQuickFilter.js";
|
|
13
|
+
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
14
|
+
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
15
|
+
import { NotRendered } from "../../utils/assert.js";
|
|
16
|
+
import { vars } from "../../constants/cssVariables.js";
|
|
17
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
+
const Divider = styled(NotRendered, {
|
|
19
|
+
name: 'MuiDataGrid',
|
|
20
|
+
slot: 'ToolbarDivider'
|
|
21
|
+
})({
|
|
22
|
+
height: '50%',
|
|
23
|
+
margin: vars.spacing(0, 0.5)
|
|
24
|
+
});
|
|
25
|
+
function GridToolbar(props) {
|
|
26
|
+
const {
|
|
27
|
+
showQuickFilter = true,
|
|
28
|
+
quickFilterProps,
|
|
29
|
+
csvOptions,
|
|
30
|
+
printOptions,
|
|
31
|
+
additionalExportMenuItems
|
|
32
|
+
} = props;
|
|
33
|
+
const apiRef = useGridApiContext();
|
|
34
|
+
const rootProps = useGridRootProps();
|
|
35
|
+
const [exportMenuOpen, setExportMenuOpen] = React.useState(false);
|
|
36
|
+
const exportMenuTriggerRef = React.useRef(null);
|
|
37
|
+
const exportMenuId = useId();
|
|
38
|
+
const exportMenuTriggerId = useId();
|
|
39
|
+
const showExportMenu = !csvOptions?.disableToolbarButton || !printOptions?.disableToolbarButton || additionalExportMenuItems;
|
|
40
|
+
const closeExportMenu = () => setExportMenuOpen(false);
|
|
41
|
+
return /*#__PURE__*/_jsxs(Toolbar, {
|
|
42
|
+
children: [!rootProps.disableColumnSelector && /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, {
|
|
43
|
+
title: apiRef.current.getLocaleText('toolbarColumns'),
|
|
44
|
+
children: /*#__PURE__*/_jsx(ColumnsPanelTrigger, {
|
|
45
|
+
render: /*#__PURE__*/_jsx(ToolbarButton, {}),
|
|
46
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.columnSelectorIcon, {
|
|
47
|
+
fontSize: "small"
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
}), !rootProps.disableColumnFilter && /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, {
|
|
51
|
+
title: apiRef.current.getLocaleText('toolbarFilters'),
|
|
52
|
+
children: /*#__PURE__*/_jsx(FilterPanelTrigger, {
|
|
53
|
+
render: (triggerProps, state) => /*#__PURE__*/_jsx(ToolbarButton, _extends({}, triggerProps, {
|
|
54
|
+
color: "default",
|
|
55
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.baseBadge, {
|
|
56
|
+
badgeContent: state.filterCount,
|
|
57
|
+
color: "primary",
|
|
58
|
+
variant: "dot",
|
|
59
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.openFilterButtonIcon, {
|
|
60
|
+
fontSize: "small"
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
}))
|
|
64
|
+
})
|
|
65
|
+
}), showExportMenu && (!rootProps.disableColumnFilter || !rootProps.disableColumnSelector) && /*#__PURE__*/_jsx(Divider, {
|
|
66
|
+
as: rootProps.slots.baseDivider,
|
|
67
|
+
orientation: "vertical"
|
|
68
|
+
}), showExportMenu && /*#__PURE__*/_jsxs(React.Fragment, {
|
|
69
|
+
children: [/*#__PURE__*/_jsx(rootProps.slots.baseTooltip, {
|
|
70
|
+
title: apiRef.current.getLocaleText('toolbarExport'),
|
|
71
|
+
children: /*#__PURE__*/_jsx(ToolbarButton, {
|
|
72
|
+
ref: exportMenuTriggerRef,
|
|
73
|
+
id: exportMenuTriggerId,
|
|
74
|
+
"aria-controls": exportMenuId,
|
|
75
|
+
"aria-haspopup": "true",
|
|
76
|
+
"aria-expanded": exportMenuOpen ? 'true' : undefined,
|
|
77
|
+
onClick: () => setExportMenuOpen(true),
|
|
78
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.exportIcon, {
|
|
79
|
+
fontSize: "small"
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
}), /*#__PURE__*/_jsxs(Menu, {
|
|
83
|
+
id: exportMenuId,
|
|
84
|
+
anchorEl: exportMenuTriggerRef.current,
|
|
85
|
+
open: exportMenuOpen,
|
|
86
|
+
onClose: closeExportMenu,
|
|
87
|
+
MenuListProps: {
|
|
88
|
+
'aria-labelledby': exportMenuTriggerId
|
|
89
|
+
},
|
|
90
|
+
children: [!printOptions?.disableToolbarButton && /*#__PURE__*/_jsx(ExportPrint, {
|
|
91
|
+
render: /*#__PURE__*/_jsx(rootProps.slots.baseMenuItem, _extends({}, rootProps.slotProps?.baseMenuItem)),
|
|
92
|
+
options: printOptions,
|
|
93
|
+
onClick: closeExportMenu,
|
|
94
|
+
children: apiRef.current.getLocaleText('toolbarExportPrint')
|
|
95
|
+
}), !csvOptions?.disableToolbarButton && /*#__PURE__*/_jsx(ExportCsv, {
|
|
96
|
+
render: /*#__PURE__*/_jsx(rootProps.slots.baseMenuItem, _extends({}, rootProps.slotProps?.baseMenuItem)),
|
|
97
|
+
options: csvOptions,
|
|
98
|
+
onClick: closeExportMenu,
|
|
99
|
+
children: apiRef.current.getLocaleText('toolbarExportCSV')
|
|
100
|
+
}), additionalExportMenuItems?.(closeExportMenu)]
|
|
101
|
+
})]
|
|
102
|
+
}), showQuickFilter && /*#__PURE__*/_jsx(GridToolbarQuickFilter, _extends({}, quickFilterProps))]
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
process.env.NODE_ENV !== "production" ? GridToolbar.propTypes = {
|
|
106
|
+
// ----------------------------- Warning --------------------------------
|
|
107
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
108
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
109
|
+
// ----------------------------------------------------------------------
|
|
110
|
+
additionalExportMenuItems: PropTypes.func,
|
|
111
|
+
csvOptions: PropTypes.object,
|
|
112
|
+
printOptions: PropTypes.object,
|
|
113
|
+
/**
|
|
114
|
+
* Props passed to the quick filter component.
|
|
115
|
+
*/
|
|
116
|
+
quickFilterProps: PropTypes.shape({
|
|
117
|
+
className: PropTypes.string,
|
|
118
|
+
debounceMs: PropTypes.number,
|
|
119
|
+
quickFilterFormatter: PropTypes.func,
|
|
120
|
+
quickFilterParser: PropTypes.func,
|
|
121
|
+
slotProps: PropTypes.object
|
|
122
|
+
}),
|
|
123
|
+
/**
|
|
124
|
+
* Show the quick filter component.
|
|
125
|
+
* @default true
|
|
126
|
+
*/
|
|
127
|
+
showQuickFilter: PropTypes.bool,
|
|
128
|
+
/**
|
|
129
|
+
* The props used for each slot inside.
|
|
130
|
+
* @default {}
|
|
131
|
+
*/
|
|
132
|
+
slotProps: PropTypes.object,
|
|
133
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
134
|
+
} : void 0;
|
|
135
|
+
export { GridToolbar };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { RenderProp } from "../../hooks/utils/useGridComponentRenderer.js";
|
|
3
|
+
import type { DataGridProcessedProps } from '../../models/props/DataGridProps';
|
|
4
|
+
export type ToolbarProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
5
|
+
/**
|
|
6
|
+
* A function to customize rendering of the component.
|
|
7
|
+
*/
|
|
8
|
+
render?: RenderProp<React.ComponentProps<typeof ToolbarRoot>>;
|
|
9
|
+
};
|
|
10
|
+
type OwnerState = DataGridProcessedProps;
|
|
11
|
+
declare const ToolbarRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
12
|
+
ownerState: OwnerState;
|
|
13
|
+
}, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
14
|
+
/**
|
|
15
|
+
* The top level Toolbar component that provides context to child components.
|
|
16
|
+
* It renders a styled `<div />` element.
|
|
17
|
+
*
|
|
18
|
+
* Demos:
|
|
19
|
+
*
|
|
20
|
+
* - [Toolbar](https://mui.com/x/react-data-grid/components/toolbar/)
|
|
21
|
+
*
|
|
22
|
+
* API:
|
|
23
|
+
*
|
|
24
|
+
* - [Toolbar API](https://mui.com/x/api/data-grid/toolbar/)
|
|
25
|
+
*/
|
|
26
|
+
declare const Toolbar: React.ForwardRefExoticComponent<ToolbarProps> | React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
27
|
+
/**
|
|
28
|
+
* A function to customize rendering of the component.
|
|
29
|
+
*/
|
|
30
|
+
render?: RenderProp<React.ComponentProps<typeof ToolbarRoot>>;
|
|
31
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
32
|
+
export { Toolbar };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["render", "className"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { styled } from '@mui/material/styles';
|
|
7
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
8
|
+
import clsx from 'clsx';
|
|
9
|
+
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
10
|
+
import { vars } from "../../constants/cssVariables.js";
|
|
11
|
+
import { getDataGridUtilityClass } from "../../constants/gridClasses.js";
|
|
12
|
+
import { useGridComponentRenderer } from "../../hooks/utils/useGridComponentRenderer.js";
|
|
13
|
+
import { ToolbarContext } from "./ToolbarContext.js";
|
|
14
|
+
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
const useUtilityClasses = ownerState => {
|
|
17
|
+
const {
|
|
18
|
+
classes
|
|
19
|
+
} = ownerState;
|
|
20
|
+
const slots = {
|
|
21
|
+
root: ['toolbar']
|
|
22
|
+
};
|
|
23
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
24
|
+
};
|
|
25
|
+
const ToolbarRoot = styled('div', {
|
|
26
|
+
name: 'MuiDataGrid',
|
|
27
|
+
slot: 'Toolbar'
|
|
28
|
+
})({
|
|
29
|
+
flex: 0,
|
|
30
|
+
display: 'flex',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
gap: vars.spacing(0.25),
|
|
33
|
+
padding: vars.spacing(0.75),
|
|
34
|
+
borderBottom: `1px solid ${vars.colors.border.base}`
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The top level Toolbar component that provides context to child components.
|
|
39
|
+
* It renders a styled `<div />` element.
|
|
40
|
+
*
|
|
41
|
+
* Demos:
|
|
42
|
+
*
|
|
43
|
+
* - [Toolbar](https://mui.com/x/react-data-grid/components/toolbar/)
|
|
44
|
+
*
|
|
45
|
+
* API:
|
|
46
|
+
*
|
|
47
|
+
* - [Toolbar API](https://mui.com/x/api/data-grid/toolbar/)
|
|
48
|
+
*/
|
|
49
|
+
const Toolbar = forwardRef(function Toolbar(props, ref) {
|
|
50
|
+
const {
|
|
51
|
+
render,
|
|
52
|
+
className
|
|
53
|
+
} = props,
|
|
54
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
55
|
+
const rootProps = useGridRootProps();
|
|
56
|
+
const classes = useUtilityClasses(rootProps);
|
|
57
|
+
const [focusableItemId, setFocusableItemId] = React.useState(null);
|
|
58
|
+
const [items, setItems] = React.useState([]);
|
|
59
|
+
const registerItem = React.useCallback(item => {
|
|
60
|
+
setItems(prevItems => [...prevItems, item]);
|
|
61
|
+
}, []);
|
|
62
|
+
const unregisterItem = React.useCallback(item => {
|
|
63
|
+
setItems(prevItems => prevItems.filter(i => i !== item));
|
|
64
|
+
if (focusableItemId === item) {
|
|
65
|
+
setFocusableItemId(null);
|
|
66
|
+
}
|
|
67
|
+
}, [focusableItemId]);
|
|
68
|
+
const onItemKeyDown = React.useCallback(event => {
|
|
69
|
+
if (!focusableItemId) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (event.key === 'ArrowRight') {
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
const nextIndex = items.indexOf(focusableItemId) + 1;
|
|
75
|
+
setFocusableItemId(items[nextIndex < items.length ? nextIndex : 0]);
|
|
76
|
+
}
|
|
77
|
+
if (event.key === 'ArrowLeft') {
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
const prevIndex = items.indexOf(focusableItemId) - 1;
|
|
80
|
+
setFocusableItemId(items[prevIndex < 0 ? items.length - 1 : prevIndex]);
|
|
81
|
+
}
|
|
82
|
+
if (event.key === 'Home') {
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
setFocusableItemId(items[0]);
|
|
85
|
+
}
|
|
86
|
+
if (event.key === 'End') {
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
setFocusableItemId(items[items.length - 1]);
|
|
89
|
+
}
|
|
90
|
+
}, [items, focusableItemId]);
|
|
91
|
+
const contextValue = React.useMemo(() => ({
|
|
92
|
+
focusableItemId,
|
|
93
|
+
registerItem,
|
|
94
|
+
unregisterItem,
|
|
95
|
+
onItemKeyDown
|
|
96
|
+
}), [registerItem, unregisterItem, focusableItemId, onItemKeyDown]);
|
|
97
|
+
const element = useGridComponentRenderer(ToolbarRoot, render, _extends({
|
|
98
|
+
role: 'toolbar',
|
|
99
|
+
'aria-orientation': 'horizontal',
|
|
100
|
+
className: clsx(classes.root, className),
|
|
101
|
+
ownerState: rootProps
|
|
102
|
+
}, other, {
|
|
103
|
+
ref
|
|
104
|
+
}));
|
|
105
|
+
React.useEffect(() => {
|
|
106
|
+
if (items.length > 0) {
|
|
107
|
+
setFocusableItemId(items[0]);
|
|
108
|
+
}
|
|
109
|
+
}, [items]);
|
|
110
|
+
return /*#__PURE__*/_jsx(ToolbarContext.Provider, {
|
|
111
|
+
value: contextValue,
|
|
112
|
+
children: element
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
process.env.NODE_ENV !== "production" ? Toolbar.propTypes = {
|
|
116
|
+
// ----------------------------- Warning --------------------------------
|
|
117
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
118
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
119
|
+
// ----------------------------------------------------------------------
|
|
120
|
+
/**
|
|
121
|
+
* A function to customize rendering of the component.
|
|
122
|
+
*/
|
|
123
|
+
render: PropTypes.oneOfType([PropTypes.element, PropTypes.func])
|
|
124
|
+
} : void 0;
|
|
125
|
+
export { Toolbar };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { RenderProp } from "../../hooks/utils/useGridComponentRenderer.js";
|
|
3
|
+
import type { GridSlotProps } from '../../models';
|
|
4
|
+
export type ToolbarButtonProps = GridSlotProps['baseIconButton'] & {
|
|
5
|
+
/**
|
|
6
|
+
* A function to customize rendering of the component.
|
|
7
|
+
*/
|
|
8
|
+
render?: RenderProp<GridSlotProps['baseIconButton']>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A button for performing actions from the toolbar.
|
|
12
|
+
* It renders the `baseIconButton` slot.
|
|
13
|
+
*
|
|
14
|
+
* Demos:
|
|
15
|
+
*
|
|
16
|
+
* - [Toolbar](https://mui.com/x/react-data-grid/components/toolbar/)
|
|
17
|
+
*
|
|
18
|
+
* API:
|
|
19
|
+
*
|
|
20
|
+
* - [ToolbarButton API](https://mui.com/x/api/data-grid/toolbar-button/)
|
|
21
|
+
*/
|
|
22
|
+
declare const ToolbarButton: React.ForwardRefExoticComponent<ToolbarButtonProps> | React.ForwardRefExoticComponent<Omit<ToolbarButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
23
|
+
export { ToolbarButton };
|