import { __assign, __extends } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import { Children } from 'react';
import cx from 'classnames';
import CommonMenu from './CommonMenu';
var PopupMenu = (function (_super) {
    __extends(PopupMenu, _super);
    function PopupMenu() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.handleClick = function (e, specKey) {
            var onClick = _this.props.onClick;
            onClick(e, specKey);
        };
        _this.onSubMenuClick = function () {
            if (_this.props.onSubMenuClick) {
                _this.props.onSubMenuClick(_this.props.specKey);
            }
        };
        _this.renderSubMenuItems = function (component, index) {
            if (!component) {
                return null;
            }
            var specKey = _this.props.specKey;
            return _this.renderCommonMenuItem(component, index, specKey);
        };
        return _this;
    }
    PopupMenu.prototype.render = function () {
        var _a = this.props, children = _a.children, visible = _a.visible, overlayCx = _a.overlayCx;
        if (!visible) {
            return null;
        }
        return (_jsx("ul", __assign({ className: cx('zent-menu', 'zent-submenu-content', overlayCx), onClick: this.onSubMenuClick, "data-zv": 'v10.0.11' }, { children: Children.map(children, this.renderSubMenuItems) }), void 0));
    };
    return PopupMenu;
}(CommonMenu));
export default PopupMenu;
