"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PopoverMenu = exports.PopoverMenuItem = exports.PopoverMenuMenu = void 0;
const react_1 = __importStar(require("react"));
const react_tiny_popover_1 = __importStar(require("react-tiny-popover"));
const styled_components_1 = __importDefault(require("styled-components"));
exports.PopoverMenuMenu = styled_components_1.default('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;
`;
exports.PopoverMenuItem = styled_components_1.default('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);'}
`;
class PopoverMenu extends react_1.Component {
    constructor() {
        super(...arguments);
        this.state = {
            isPopoverOpen: false,
        };
        this.close = () => {
            this.setState({ isPopoverOpen: false });
        };
        this.renderPopover = ({ position, targetRect, popoverRect, }) => {
            return (react_1.default.createElement(react_tiny_popover_1.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_1.default.createElement(react_tiny_popover_1.default, { isOpen: isPopoverOpen, position: position, align: align, content: this.renderPopover, containerStyle: { overflow: 'visible', zIndex: '4' }, onClickOutside: this.close, transitionDuration: 0 },
            react_1.default.createElement("div", { style: { display: 'inline-flex' }, onClick: () => this.setState({ isPopoverOpen: !isPopoverOpen }) }, children)));
    }
}
exports.PopoverMenu = PopoverMenu;
//# sourceMappingURL=index.js.map