import React, { useState, useMemo } from 'react' import { Icon } from '../../atoms/icon/index.js' import { DropDownMenu, DropDownItem, } from '../../molecules/drop-down/index.js' import { StyledDropDownItemAction } from './button-group.styled.jsx' import { ButtonInGroupProps } from './button-group.types.js' export const DropDownItemWithButtons: React.FC = (props) => { const { variant, onClick, href, icon, label, buttons, source, ...rest } = props const [loading, setLoading] = useState(false) const onClickHandler = onClick ? async (event) => { setLoading(true) await onClick(event, source) setLoading(false) } : undefined const iconName = useMemo(() => (loading ? 'Loader' : icon), [loading]) return ( {buttons && buttons.length ? ( ) : ''} {!loading && !icon ? '' : } {label} {buttons && buttons.length ? ( {buttons.map((button) => ( ))} ) : ''} ) } DropDownItemWithButtons.displayName = 'DropDownItemWithButtons' export default DropDownItemWithButtons