import { MoreOutlined } from '@ant-design/icons'; import { useIntl } from '@umijs/max'; import { Button, Dropdown, Tooltip, type MenuProps } from 'antd'; import classNames from 'classnames'; import _ from 'lodash'; import { memo } from 'react'; import './index.less'; interface DropdownButtonsProps { items: MenuProps['items']; size?: 'small' | 'middle' | 'large'; onSelect: (val: any, item?: any) => void; } const DropdownButtons: React.FC = ({ items, size = 'middle', onSelect }) => { const intl = useIntl(); const handleMenuClick = (item: any) => { console.log('menu click', item.key); const selectItem = _.find(items, { key: item.key }); onSelect(item.key, selectItem); }; const handleButtonClick = (e: any) => { const headItem = _.head(items); onSelect(headItem.key, headItem); }; if (!items?.length) { return ; } return ( <> {items?.length === 1 ? ( ) : ( { return (
{_.map(_.tail(items), (item: any) => { return ( ); })}
); }} buttonsRender={([leftButton, rightButton]) => [ , ]} >
)} ); }; export default memo(DropdownButtons);