2024-02-23 06:23:32 -05:00
|
|
|
import classNames from 'classnames'
|
|
|
|
import Button from './button'
|
|
|
|
import {
|
|
|
|
Dropdown,
|
|
|
|
DropdownItem,
|
|
|
|
DropdownMenu,
|
|
|
|
DropdownToggle,
|
|
|
|
} from './dropdown-menu'
|
|
|
|
import MaterialIcon from '@/shared/components/material-icon'
|
|
|
|
import type { SplitButtonProps } from '@/features/ui/components/types/split-button-props'
|
|
|
|
|
|
|
|
export function SplitButton({
|
2024-03-27 06:53:54 -04:00
|
|
|
accessibilityLabel,
|
2024-02-23 06:23:32 -05:00
|
|
|
align,
|
|
|
|
id,
|
|
|
|
items,
|
|
|
|
text,
|
|
|
|
variant,
|
|
|
|
...props
|
|
|
|
}: SplitButtonProps) {
|
|
|
|
const buttonClassName = classNames('split-button')
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Dropdown align={align}>
|
|
|
|
<Button className={buttonClassName} variant={variant} {...props}>
|
|
|
|
<span className="split-button-content">{text}</span>
|
|
|
|
</Button>
|
|
|
|
<DropdownToggle
|
|
|
|
bsPrefix="dropdown-button-toggle"
|
|
|
|
id={id}
|
|
|
|
variant={variant}
|
|
|
|
{...props}
|
|
|
|
>
|
2024-03-27 06:53:54 -04:00
|
|
|
<MaterialIcon
|
|
|
|
className="split-button-caret"
|
|
|
|
type="expand_more"
|
|
|
|
accessibilityLabel={accessibilityLabel}
|
|
|
|
/>
|
2024-02-23 06:23:32 -05:00
|
|
|
</DropdownToggle>
|
|
|
|
<DropdownMenu>
|
|
|
|
{items.map((item, index) => (
|
|
|
|
<DropdownItem key={index} eventKey={item.eventKey}>
|
|
|
|
{item.label}
|
|
|
|
</DropdownItem>
|
|
|
|
))}
|
|
|
|
</DropdownMenu>
|
|
|
|
</Dropdown>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|