@styleless-ui/react
Version:
Completely unstyled, headless and accessible React UI components.
60 lines (59 loc) • 1.9 kB
TypeScript
import * as React from "react";
import { type PopperProps as PopperProps } from "../Popper";
import type { VirtualElement } from "../Popper/helpers";
import type { MergeElementProps } from "../typings";
interface OwnProps {
/**
* The content of the component.
*/
children?: React.ReactNode | ((ctx: {
open: boolean;
}) => React.ReactNode);
/**
* The className applied to the component.
*/
className?: string | ((ctx: {
open: boolean;
}) => string);
/**
* The anchor element for the menu.
*/
anchorElement?: React.RefObject<HTMLElement> | HTMLElement | VirtualElement | string;
/**
* The menu positioning alignment.
* @default "start"
*/
alignment?: PopperProps["alignment"];
/**
* If `true`, the menu will be open.
*/
open?: boolean;
/**
* Callback fired when a click interaction happens outside the component.
*/
onOutsideClick?: (event: MouseEvent) => void;
/**
* Callback fired when the `Escape` key is released.
*/
onEscapeKeyUp?: (event: KeyboardEvent) => void;
/**
* Used to prevent/allow keyboard navigation when more control is needed.
* @default true
*/
shouldActivateKeyboardNavigation?: boolean;
/**
* Used to keep mounting when more control is needed.\
* Useful when controlling animation with React animation libraries.\
* It will be inherited by any descendant submenus respectively.
* @default false
*/
keepMounted?: boolean;
/**
* Used to prevent/allow item selection with typed character.
* @default false
*/
disabledKeySearch?: boolean;
}
export type Props = Omit<MergeElementProps<"div", OwnProps>, "defaultValue" | "defaultChecked">;
declare const Menu: (props: Props, ref: React.Ref<HTMLDivElement>) => JSX.Element | null;
export default Menu;