@mui/x-data-grid
Version:
The Community plan edition of the Data Grid components (MUI X).
42 lines • 1.83 kB
JavaScript
import * as React from 'react';
import PropTypes from 'prop-types';
import MenuItem from '@mui/material/MenuItem';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import { GridPreferencePanelsValue } from '../../../../hooks/features/preferencesPanel/gridPreferencePanelsValue';
import { useGridApiContext } from '../../../../hooks/utils/useGridApiContext';
import { useGridRootProps } from '../../../../hooks/utils/useGridRootProps';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
function GridColumnMenuManageItem(props) {
const {
onClick
} = props;
const apiRef = useGridApiContext();
const rootProps = useGridRootProps();
const showColumns = React.useCallback(event => {
onClick(event); // hide column menu
apiRef.current.showPreferences(GridPreferencePanelsValue.columns);
}, [apiRef, onClick]);
if (rootProps.disableColumnSelector) {
return null;
}
return /*#__PURE__*/_jsxs(MenuItem, {
onClick: showColumns,
children: [/*#__PURE__*/_jsx(ListItemIcon, {
children: /*#__PURE__*/_jsx(rootProps.slots.columnMenuManageColumnsIcon, {
fontSize: "small"
})
}), /*#__PURE__*/_jsx(ListItemText, {
children: apiRef.current.getLocaleText('columnMenuManageColumns')
})]
});
}
process.env.NODE_ENV !== "production" ? GridColumnMenuManageItem.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
colDef: PropTypes.object.isRequired,
onClick: PropTypes.func.isRequired
} : void 0;
export { GridColumnMenuManageItem };