import React, { Component } from 'react';
import Popover, { ArrowContainer } from 'react-tiny-popover';
import styled from 'styled-components/macro';
export const PopoverMenuMenu = styled('div') `
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
  background: #fff;
  border-radius: 3px;
  padding: 5px 0;
  max-height: 500px;
  overflow: scroll;
`;
export const PopoverMenuItem = styled('div') `
  padding: 15px;
  border-bottom: 1px solid #f0f0f0;
  :last-child {
    border-bottom: none;
  }
  :hover {
    background: var(--light-color);
  }
  ${(p) => p.active && 'background: var(--light-color);'}
`;
export class PopoverMenu extends Component {
    constructor() {
        super(...arguments);
        this.state = {
            isPopoverOpen: false,
        };
        this.close = () => {
            this.setState({ isPopoverOpen: false });
        };
        this.renderPopover = ({ position, targetRect, popoverRect, }) => {
            return (React.createElement(ArrowContainer, { position: position, targetRect: targetRect, popoverRect: popoverRect, arrowColor: '#fff', arrowSize: 5 }, this.props.renderMenu(this.close)));
        };
    }
    render() {
        const { position = 'bottom', align = 'start', children } = this.props;
        const { isPopoverOpen } = this.state;
        return (React.createElement(Popover, { isOpen: isPopoverOpen, position: position, align: align, content: this.renderPopover, containerStyle: { overflow: 'visible', zIndex: '4' }, onClickOutside: this.close, transitionDuration: 0 },
            React.createElement("div", { style: { display: 'inline-flex' }, onClick: () => this.setState({ isPopoverOpen: !isPopoverOpen }) }, children)));
    }
}
//# sourceMappingURL=index.js.map