UNPKG

@primer/react

Version:

An implementation of GitHub's Primer Design System using React

51 lines 2.28 kB
import React from 'react'; import type { AnchoredOverlayProps } from '../AnchoredOverlay'; import type { OverlayProps } from '../Overlay'; import type { ButtonProps } from '../Button'; import type { AnchorPosition } from '@primer/behaviors'; import type { ForwardRefComponent as PolymorphicForwardRefComponent } from '../utils/polymorphic'; export type MenuCloseHandler = (gesture: 'anchor-click' | 'click-outside' | 'escape' | 'tab' | 'item-select' | 'arrow-left' | 'close') => void; export type MenuContextProps = Pick<AnchoredOverlayProps, 'anchorRef' | 'renderAnchor' | 'open' | 'onOpen' | 'anchorId'> & { onClose?: MenuCloseHandler; isSubmenu?: boolean; }; export type ActionMenuProps = { /** * Recommended: `ActionMenu.Button` or `ActionMenu.Anchor` with `ActionMenu.Overlay` */ children: React.ReactElement[] | React.ReactElement; /** * If defined, will control the open/closed state of the overlay. Must be used in conjunction with `onOpenChange`. */ open?: boolean; /** * If defined, will control the open/closed state of the overlay. Must be used in conjunction with `open`. */ onOpenChange?: (s: boolean) => void; } & Pick<AnchoredOverlayProps, 'anchorRef'>; export type ActionMenuAnchorProps = { children: React.ReactElement; id?: string; } & React.HTMLAttributes<HTMLElement>; /** this component is syntactical sugar 🍭 */ export type ActionMenuButtonProps = ButtonProps; type MenuOverlayProps = Partial<OverlayProps> & Pick<AnchoredOverlayProps, 'align' | 'side' | 'variant'> & { /** * Recommended: `ActionList` */ children: React.ReactNode; onPositionChange?: ({ position }: { position: AnchorPosition; }) => void; }; export declare const ActionMenu: React.FC<React.PropsWithChildren<ActionMenuProps>> & { Button: PolymorphicForwardRefComponent<"button", ButtonProps>; Anchor: React.ForwardRefExoticComponent<{ children: React.ReactElement; id?: string; } & React.HTMLAttributes<HTMLElement> & React.RefAttributes<HTMLElement>>; Overlay: React.FC<React.PropsWithChildren<MenuOverlayProps>>; Divider: React.FC<React.PropsWithChildren<import("..").ActionListDividerProps>>; }; export {}; //# sourceMappingURL=ActionMenu.d.ts.map