73 lines
2.8 KiB
JavaScript
73 lines
2.8 KiB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
var _excluded = ["label", "icon", "showInMenu", "onClick"],
|
|
_excluded2 = ["label", "icon", "showInMenu", "onClick", "closeMenuOnClick", "closeMenu"];
|
|
import * as React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import MenuItem from '@mui/material/MenuItem';
|
|
import ListItemIcon from '@mui/material/ListItemIcon';
|
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
var GridActionsCellItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
var rootProps = useGridRootProps();
|
|
if (!props.showInMenu) {
|
|
var _rootProps$slotProps;
|
|
var _label = props.label,
|
|
_icon = props.icon,
|
|
_showInMenu = props.showInMenu,
|
|
_onClick = props.onClick,
|
|
_other = _objectWithoutProperties(props, _excluded);
|
|
var _handleClick = function _handleClick(event) {
|
|
_onClick == null || _onClick(event);
|
|
};
|
|
return /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
|
|
ref: ref,
|
|
size: "small",
|
|
role: "menuitem",
|
|
"aria-label": _label
|
|
}, _other, {
|
|
onClick: _handleClick
|
|
}, (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.baseIconButton, {
|
|
children: /*#__PURE__*/React.cloneElement(_icon, {
|
|
fontSize: 'small'
|
|
})
|
|
}));
|
|
}
|
|
var label = props.label,
|
|
icon = props.icon,
|
|
showInMenu = props.showInMenu,
|
|
onClick = props.onClick,
|
|
_props$closeMenuOnCli = props.closeMenuOnClick,
|
|
closeMenuOnClick = _props$closeMenuOnCli === void 0 ? true : _props$closeMenuOnCli,
|
|
closeMenu = props.closeMenu,
|
|
other = _objectWithoutProperties(props, _excluded2);
|
|
var handleClick = function handleClick(event) {
|
|
onClick == null || onClick(event);
|
|
if (closeMenuOnClick) {
|
|
closeMenu == null || closeMenu();
|
|
}
|
|
};
|
|
return /*#__PURE__*/_jsxs(MenuItem, _extends({
|
|
ref: ref
|
|
}, other, {
|
|
onClick: handleClick,
|
|
children: [icon && /*#__PURE__*/_jsx(ListItemIcon, {
|
|
children: icon
|
|
}), label]
|
|
}));
|
|
});
|
|
process.env.NODE_ENV !== "production" ? GridActionsCellItem.propTypes = {
|
|
// ----------------------------- Warning --------------------------------
|
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
// ----------------------------------------------------------------------
|
|
/**
|
|
* from https://mui.com/material-ui/api/button-base/#ButtonBase-prop-component
|
|
*/
|
|
component: PropTypes.elementType,
|
|
icon: PropTypes.element,
|
|
label: PropTypes.string.isRequired,
|
|
showInMenu: PropTypes.bool
|
|
} : void 0;
|
|
export { GridActionsCellItem }; |