import React from 'react';
import { Menu } from 'antd';
import Dropdown from "../dropdown";
import classNames from 'classnames';
import "./index.less";
var PisellDropdown = function PisellDropdown(_ref) {
  var trigger = _ref.trigger,
    _ref$items = _ref.items,
    items = _ref$items === void 0 ? [] : _ref$items,
    _ref$showShortcut = _ref.showShortcut,
    showShortcut = _ref$showShortcut === void 0 ? true : _ref$showShortcut,
    _ref$triggerType = _ref.triggerType,
    triggerType = _ref$triggerType === void 0 ? ['click'] : _ref$triggerType,
    className = _ref.className,
    style = _ref.style,
    onSelect = _ref.onSelect;
  var renderMenuItem = function renderMenuItem(item) {
    var menuItem = /*#__PURE__*/React.createElement("div", {
      className: "pisell-dropdown-item"
    }, /*#__PURE__*/React.createElement("div", {
      className: "pisell-dropdown-item-content"
    }, item.icon && /*#__PURE__*/React.createElement("span", {
      className: "pisell-dropdown-item-icon"
    }, item.icon), /*#__PURE__*/React.createElement("span", {
      className: "pisell-dropdown-item-label"
    }, item.label)), showShortcut && item.shortcut && /*#__PURE__*/React.createElement("span", {
      className: "pisell-dropdown-item-shortcut"
    }, item.shortcut));
    return item.divider ? /*#__PURE__*/React.createElement(React.Fragment, {
      key: item.key
    }, /*#__PURE__*/React.createElement(Menu.Item, {
      key: item.key
    }, menuItem), /*#__PURE__*/React.createElement(Menu.Divider, null)) : /*#__PURE__*/React.createElement(Menu.Item, {
      key: item.key
    }, menuItem);
  };
  var menu = /*#__PURE__*/React.createElement(Menu, {
    onClick: function onClick(_ref2) {
      var key = _ref2.key;
      return onSelect === null || onSelect === void 0 ? void 0 : onSelect(key);
    },
    className: "pisell-dropdown-menu"
  }, items.map(renderMenuItem));
  return /*#__PURE__*/React.createElement(Dropdown, {
    overlay: menu,
    trigger: triggerType,
    className: classNames('pisell-dropdown', className),
    style: style
  }, trigger || /*#__PURE__*/React.createElement("span", null, "Account"));
};
export default PisellDropdown;