import { useMemo } from 'react'; import type { DropdownItemSeparator, DropdownProps } from './Dropdown'; import { Dropdown } from './Dropdown'; import { Icon } from './Icon'; export type RadioDropdownItem = | { type?: 'default'; label: string; shortLabel?: string; value: T; } | DropdownItemSeparator; export interface RadioDropdownProps { value: T; onChange: (value: T) => void; items: RadioDropdownItem[]; extraItems?: DropdownProps['items']; children: DropdownProps['children']; } export function RadioDropdown({ value, items, extraItems, onChange, children, }: RadioDropdownProps) { const dropdownItems = useMemo( () => [ ...items.map((item) => { if (item.type === 'separator') { return item; } else { return { key: item.label, label: item.label, shortLabel: item.shortLabel, onSelect: () => onChange(item.value), leftSlot: , }; } }), ...(extraItems ?? []), ], [items, extraItems, value, onChange], ); return {children}; }