import React, { PropsWithChildren, ReactElement } from 'react'; import { ButtonProps } from '../Button'; import { type IconButtonProps } from '../IconButton'; import { type ActionMenuButtonModes as ActionMenuButtonMode, type ActionMenuSizes as ActionMenuSize } from './ActionMenuContext'; import { type Icon } from '@primer/octicons-react'; import { type PositionSettings } from '@primer/behaviors'; import type { BaseProps } from '../component-helpers'; /** * Design tokens */ import '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/action-menu/colors-with-modes.css'; export declare const actionMenuOverlaySides: PositionSettings["side"][]; export { ActionMenuButtonModes, ActionMenuProvider, ActionMenuSizes, useActionMenuContext } from './ActionMenuContext'; export type ActionMenuProps = { /** * The content of the ActionMenu. Must include an ActionMenu.Button or ActionMenu.IconButton and an ActionMenu.Overlay */ children: ReactElement | ReactElement | ReactElement | Array | ReactElement | ReactElement>; /** * Determines whether the ActionMenu is disabled */ disabled?: boolean; /** * Determines whether the ActionMenu is open by default */ open?: boolean; /** * Callback that is called when an item is selected. * The value of the selected item is passed as an argument. */ onSelect?: (newValue: string) => void; /** * The selection variant of the ActionMenu. * - `single`: Only one item can be selected at a time. Menu items as a menuitemradio. * - `none`: No items can be selected. Menu items as a menuitem. */ selectionVariant?: 'single' | 'none'; /** * Test id for the ActionMenu */ 'data-testid'?: string; /** * Horizontal alignment of the menu relative to the bottom of the button */ menuAlignment?: 'start' | 'end'; /** * Size configuratin of the ActionMenu */ size?: ActionMenuSize; menuSide?: PositionSettings['side']; /** * Alternative behavior for the button and menu items * - `default`: The button and menu items behave as a standard button and menu item. * - `split-button`: The button behaves as a split button, and the menu items behave as links. */ mode?: ActionMenuButtonMode; } & BaseProps; type ActionMenuButtonProps = PropsWithChildren & Pick, 'id' | 'disabled' | 'onClick'>> & { as?: ButtonProps<'a'>['as']; href?: ButtonProps<'a'>['href']; menuOpen?: boolean; 'data-testid'?: string; size?: ActionMenuSize; variant?: ButtonProps<'a'>['variant']; leadingVisual?: ButtonProps<'a'>['leadingVisual']; }; export type ActionMenuIconButtonProps = Omit, 'size'> & { 'data-testid'?: string; }; type ActionMenuIconButtonComponent = (props: ActionMenuIconButtonProps & React.RefAttributes) => React.ReactElement | null; type ActionMenuItemBaseProps = { handler?: (newValue: string) => void; type?: 'none' | 'single' | 'link'; disabled?: boolean; size?: ActionMenuSize; leadingVisual?: React.ReactElement | React.ReactNode | Icon; } & PropsWithChildren>; type ActionMenuItemAnchorProps = ActionMenuItemBaseProps & { as: 'a'; } & Omit, keyof ActionMenuItemBaseProps | 'as'>; type ActionMenuItemDefaultProps = ActionMenuItemBaseProps & { as?: string; value?: string; selected?: boolean; } & Omit, keyof ActionMenuItemBaseProps | 'as'>; type ActionMenuOverlayProps = PropsWithChildren & React.HTMLAttributes> & { 'aria-label': string; id?: string; 'data-testid'?: string; menuOpen?: boolean; style?: React.CSSProperties; }; /** * Use ActionMenu to display a list of actions or selections that expand through a trigger button. * @see https://primer.style/brand/components/ActionMenu */ export declare const ActionMenu: React.NamedExoticComponent<{ /** * The content of the ActionMenu. Must include an ActionMenu.Button or ActionMenu.IconButton and an ActionMenu.Overlay */ children: ReactElement | ReactElement | ReactElement | Array | ReactElement | ReactElement>; /** * Determines whether the ActionMenu is disabled */ disabled?: boolean; /** * Determines whether the ActionMenu is open by default */ open?: boolean; /** * Callback that is called when an item is selected. * The value of the selected item is passed as an argument. */ onSelect?: (newValue: string) => void; /** * The selection variant of the ActionMenu. * - `single`: Only one item can be selected at a time. Menu items as a menuitemradio. * - `none`: No items can be selected. Menu items as a menuitem. */ selectionVariant?: "single" | "none"; /** * Test id for the ActionMenu */ 'data-testid'?: string; /** * Horizontal alignment of the menu relative to the bottom of the button */ menuAlignment?: "start" | "end"; /** * Size configuratin of the ActionMenu */ size?: ActionMenuSize; menuSide?: PositionSettings["side"]; /** * Alternative behavior for the button and menu items * - `default`: The button and menu items behave as a standard button and menu item. * - `split-button`: The button behaves as a split button, and the menu items behave as links. */ mode?: ActionMenuButtonMode; } & BaseProps> & { readonly type: ({ id, children, "data-testid": testId, disabled, open, selectionVariant, menuAlignment, size, menuSide, onSelect, mode, }: ActionMenuProps) => React.JSX.Element; } & { Button: React.ForwardRefExoticComponent & React.RefAttributes>; IconButton: ActionMenuIconButtonComponent; Item: ({ as, children, className, disabled, handler, selected, type, value, onClick, onKeyDown, leadingVisual: LeadingVisual, ...props }: ActionMenuItemAnchorProps | ActionMenuItemDefaultProps) => React.JSX.Element; Overlay: React.ForwardRefExoticComponent & React.RefAttributes>; testIds: { root: string; readonly button: string; readonly overlay: string; readonly list: string; readonly item: string; }; };