import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu' import type React from 'react' import { SvgTaillessLineArrowRight1 } from '@chainlink/blocks-icons' import { getIconUrl } from '../../utils' import { cn } from '../../utils/cn' import { Tag } from '../Tag' import type { TagProps } from '../Tag/Tag' import { typographyVariants } from '../Typography' /** Root state container for the dropdown. Manages open/closed state. Compose with DropdownMenuTrigger and DropdownMenuContent. */ const DropdownMenu = DropdownMenuPrimitive.Root /** Element that opens the dropdown on click. Use `asChild` to make any element (e.g. a Button) the trigger. */ const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger /** Groups related DropdownMenuItems under an optional DropdownMenuLabel. */ const DropdownMenuGroup = DropdownMenuPrimitive.Group /** Portal that renders DropdownMenuContent outside the DOM tree. Used internally by DropdownMenuContent. */ const DropdownMenuPortal = DropdownMenuPrimitive.Portal /** Container for a nested submenu. Compose with DropdownMenuSubTrigger and DropdownMenuSubContent. */ const DropdownMenuSub = DropdownMenuPrimitive.Sub /** Groups radio-style items where only one can be selected at a time. */ const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup DropdownMenuSub.displayName = 'DropdownMenuSub' type DropdownMenuSubTriggerProps = React.ComponentPropsWithoutRef< typeof DropdownMenuPrimitive.SubTrigger > & { /** When true, adds left padding to align with items that have an icon in the leading slot. */ inset?: boolean ref?: React.Ref> } /** Item inside DropdownMenuSub that opens the nested submenu on hover or click. Shows a trailing arrow icon. */ const DropdownMenuSubTrigger = ({ className, inset, children, ref, ...props }: DropdownMenuSubTriggerProps) => ( <> {children} ) DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName type DropdownMenuSubContentProps = React.ComponentPropsWithoutRef< typeof DropdownMenuPrimitive.SubContent > & { ref?: React.Ref> } const DropdownMenuSubContent = ({ className, ref, ...props }: DropdownMenuSubContentProps) => ( ) DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName type DropdownMenuContentProps = React.ComponentPropsWithoutRef< typeof DropdownMenuPrimitive.Content > & { ref?: React.Ref> } /** * Floating panel that contains the dropdown items. Renders inside a portal. * Accepts `side` and `align` props for positioning relative to the trigger. */ const DropdownMenuContent = ({ className, children, sideOffset = 4, ref, ...props }: DropdownMenuContentProps) => ( {children} ) DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName type DropdownMenuItemProps = React.ComponentPropsWithoutRef< typeof DropdownMenuPrimitive.Item > & { /** When true, adds left padding to align with items that have an icon in the leading slot. */ inset?: boolean ref?: React.Ref> } /** A single clickable action in the dropdown. Use `disabled` to prevent interaction. */ const DropdownMenuItem = ({ className, inset, ref, ...props }: DropdownMenuItemProps) => ( ) DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName type DropdownMenuCheckboxItemProps = React.ComponentPropsWithoutRef< typeof DropdownMenuPrimitive.CheckboxItem > & { ref?: React.Ref> } /** A menu item with a checkbox indicator. Use `checked` and `onCheckedChange` to control its state. */ const DropdownMenuCheckboxItem = ({ className, children, checked, ref, ...props }: DropdownMenuCheckboxItemProps) => ( {children} ) DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName const Circle = (props: React.SVGProps) => ( ) type DropdownMenuRadioItemProps = React.ComponentPropsWithoutRef< typeof DropdownMenuPrimitive.RadioItem > & { ref?: React.Ref> } /** A menu item inside DropdownMenuRadioGroup. Only one radio item per group can be selected at a time. */ const DropdownMenuRadioItem = ({ className, children, ref, ...props }: DropdownMenuRadioItemProps) => ( {children} ) DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName type DropdownMenuLabelProps = React.ComponentPropsWithoutRef< typeof DropdownMenuPrimitive.Label > & { /** When true, adds left padding to align with items that have an icon in the leading slot. */ inset?: boolean ref?: React.Ref> } /** Non-interactive section label inside a DropdownMenuGroup. */ const DropdownMenuLabel = ({ className, inset, ref, ...props }: DropdownMenuLabelProps) => ( ) DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName type DropdownMenuSeparatorProps = React.ComponentPropsWithoutRef< typeof DropdownMenuPrimitive.Separator > & { ref?: React.Ref> } /** Horizontal rule that visually separates groups of items. */ const DropdownMenuSeparator = ({ className, ref, ...props }: DropdownMenuSeparatorProps) => ( ) DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName /** Right-aligned keyboard shortcut hint rendered inside a DropdownMenuItem. */ const DropdownMenuShortcut = ({ className, ...props }: React.HTMLAttributes) => { return ( ) } DropdownMenuShortcut.displayName = 'DropdownMenuShortcut' /** Right-aligned Tag badge rendered inside a DropdownMenuItem. Useful for labels like "New" or "Beta". */ const DropdownMenuTag = ({ className, size = 'sm', hideIcon = true, ...props }: TagProps) => { return (
) } DropdownMenuTag.displayName = 'DropdownMenuTag' export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTag, DropdownMenuTrigger, }