import React from "react";
import PropTypes from "prop-types";
import { defineMessages, injectIntl } from "react-intl";
import Menu from "@material-ui/core/Menu";
import { Divider } from "@material-ui/core";
import Icon from "/imports/ui/components/common/icon/component";
import { SMALL_VIEWPORT_BREAKPOINT } from '/imports/ui/components/layout/enums';
import { ENTER } from "/imports/utils/keyCodes";
import Styled from './styles';
const intlMessages = defineMessages({
close: {
id: 'app.dropdown.close',
description: 'Close button label',
},
});
class BBBMenu extends React.Component {
constructor(props) {
super(props);
this.state = {
anchorEl: null,
};
this.optsToMerge = {};
this.autoFocus = false;
this.handleClick = this.handleClick.bind(this);
this.handleClose = this.handleClose.bind(this);
}
componentDidUpdate() {
const { anchorEl } = this.state;
if (this.props.open === false && anchorEl) {
this.setState({ anchorEl: null });
} else if (this.props.open === true && !anchorEl) {
this.setState({ anchorEl: this.anchorElRef });
}
}
handleClick(event) {
this.setState({ anchorEl: event.currentTarget });
};
handleClose(event) {
const { onCloseCallback } = this.props;
this.setState({ anchorEl: null }, onCloseCallback());
if (event) {
event.persist();
if (event.type === 'click') {
setTimeout(() => {
document.activeElement.blur();
}, 0);
}
}
};
makeMenuItems() {
const { actions, selectedEmoji } = this.props;
return actions?.map(a => {
const { dataTest, label, onClick, key, disabled, description, selected } = a;
const emojiSelected = key?.toLowerCase()?.includes(selectedEmoji?.toLowerCase());
let customStyles = {
paddingLeft: '16px',
paddingRight: '16px',
paddingTop: '12px',
paddingBottom: '12px',
marginLeft: '0px',
marginRight: '0px',
};
if (a.customStyles) {
customStyles = { ...customStyles, ...a.customStyles };
}
return [
a.dividerTop &&