import React, { useContext } from 'react';
import classnames from 'classnames';
import { DownOutlined, EllipsisOutlined } from '@wii/icons';
import Dropdown from '../dropdown';
import Menu from '../menu';
import Button from '../button';
import ConfigProvider from '../config-provider';
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
/**
 * 一个简单的下拉菜单
 *
 * @param param0
 */
const DropdownButton = ({
  children,
  menus,
  onSelect,
  className,
  style
}) => {
  const {
    getPrefixCls
  } = useContext(ConfigProvider.ConfigContext);
  const tempClassName = getPrefixCls('pro-table-dropdown');
  return /*#__PURE__*/_jsx(Dropdown, {
    menu: {
      items: menus === null || menus === void 0 ? void 0 : menus.map(item => ({
        label: item.name,
        key: item.key
      })),
      onClick: params => onSelect && onSelect(params.key)
    },
    className: classnames(tempClassName, className),
    children: /*#__PURE__*/_jsxs(Button, {
      style: style,
      children: [children, " ", /*#__PURE__*/_jsx(DownOutlined, {})]
    })
  });
};
const TableDropdown = ({
  className: propsClassName,
  style,
  onSelect,
  menus = []
}) => {
  const {
    getPrefixCls
  } = useContext(ConfigProvider.ConfigContext);
  const className = getPrefixCls('pro-table-dropdown');
  const menu = /*#__PURE__*/_jsx(Menu, {
    onClick: params => onSelect && onSelect(params.key),
    items: menus.map(item => ({
      label: item.name,
      key: item.key
    }))
  });
  return /*#__PURE__*/_jsx(Dropdown, {
    overlay: menu,
    className: classnames(className, propsClassName),
    children: /*#__PURE__*/_jsx("a", {
      style: style,
      children: /*#__PURE__*/_jsx(EllipsisOutlined, {})
    })
  });
};
TableDropdown.Button = DropdownButton;
export default TableDropdown;