import React from 'react'; import { ToolButtonList, ToolButton, ToolButtonListDefault, ToolButtonListDropDown, ToolButtonListItem, ToolButtonListDivider, } from '@ohif/ui-next'; import { useToolbar } from '@ohif/core/src'; interface ToolButtonListWrapperProps { groupId: string; buttonSection: string; onInteraction?: (details: { groupId: string; itemId: string; commands?: Record; }) => void; } /** * Wraps the ToolButtonList component to handle the OHIF toolbar button structure * @param props - Component props * @returns Component * // test */ export default function ToolButtonListWrapper({ groupId, buttonSection, }: ToolButtonListWrapperProps) { const { onInteraction, toolbarButtons } = useToolbar({ buttonSection, }); if (!toolbarButtons?.length) { return null; } const primary = toolbarButtons.find(button => button.componentProps.isActive)?.componentProps || toolbarButtons[0].componentProps; const items = toolbarButtons.map(button => button.componentProps); return (
onInteraction?.({ groupId, itemId, commands: primary.commands }) } className={primary.className} />
{items.map(item => { return ( onInteraction?.({ groupId, itemId: item.id, commands: item.commands }) } > {item.label || item.tooltip || item.id} ); })}
); }