import type { ReactNode } from 'react'
import { useLegendConfig } from '../../provider'
import { LegendOverflowMenu } from '../legend-overflow-menu/legend-overflow-menu'

export interface LegendPanelMenuProps {
  /** Menu items; async items use `stopPropagation` + `runAsyncMenuAction`. */
  children?: ReactNode
}

/**
 * Overflow (⋮) menu for the panel header (no row/group context).
 *
 * @experimental This API is new and may change in a future release.
 */
export function LegendPanelMenu({ children }: LegendPanelMenuProps) {
  const { labels } = useLegendConfig()

  return (
    <LegendOverflowMenu ariaLabel={labels.panelOptions}>
      {children}
    </LegendOverflowMenu>
  )
}
