@primer/react
Version:
An implementation of GitHub's Primer Design System using React
52 lines (51 loc) • 2.16 kB
TypeScript
import { FCWithSlotMarker, SlotMarker, WithSlotMarker } from "../utils/types/Slots.js";
import { ForwardRefComponent } from "../utils/polymorphic.js";
import { ButtonProps } from "../Button/types.js";
import { ActionListDividerProps } from "../ActionList/Divider.js";
import { AnchoredOverlayProps } from "../AnchoredOverlay/AnchoredOverlay.js";
import { OverlayProps } from "../Overlay/Overlay.js";
import React from "react";
import { AnchorPosition } from "@primer/behaviors";
//#region src/ActionMenu/ActionMenu.d.ts
type ActionMenuProps = {
/**
* Recommended: `ActionMenu.Button` or `ActionMenu.Anchor` with `ActionMenu.Overlay`
*/
children: React.ReactElement<any>[] | React.ReactElement<any>;
/**
* 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'>;
type ActionMenuAnchorProps = {
children: React.ReactElement<any>;
id?: string;
} & React.HTMLAttributes<HTMLElement>;
/** this component is syntactical sugar 🍭 */
type ActionMenuButtonProps = ButtonProps;
type MenuOverlayProps = Partial<OverlayProps> & Pick<AnchoredOverlayProps, 'align' | 'side' | 'variant' | 'displayInViewport'> & {
/**
* Recommended: `ActionList`
*/
children: React.ReactNode;
onPositionChange?: ({
position
}: {
position: AnchorPosition;
}) => void;
};
declare const ActionMenu: React.FC<React.PropsWithChildren<ActionMenuProps>> & SlotMarker & {
Button: ForwardRefComponent<"button", ButtonProps>;
Anchor: WithSlotMarker<React.ForwardRefExoticComponent<{
children: React.ReactElement<any>;
id?: string;
} & React.HTMLAttributes<HTMLElement> & React.RefAttributes<HTMLElement>>>;
Overlay: FCWithSlotMarker<React.PropsWithChildren<MenuOverlayProps>>;
Divider: FCWithSlotMarker<React.PropsWithChildren<ActionListDividerProps>>;
};
//#endregion
export { ActionMenu, ActionMenuAnchorProps, ActionMenuButtonProps, ActionMenuProps };