UNPKG

2.88 kBTypeScriptView Raw
1import * as React from "react";
2import { AbstractPureComponent2 } from "../../common";
3import { ActionProps, LinkProps } from "../../common/props";
4import { IPopoverProps } from "../popover/popover";
5export declare type MenuItemProps = IMenuItemProps;
6/** @deprecated use MenuItemProps */
7export interface IMenuItemProps extends ActionProps, LinkProps {
8 /** Item text, required for usability. */
9 text: React.ReactNode;
10 /** Whether this menu item should appear with an active state. */
11 active?: boolean;
12 /**
13 * Children of this component will be rendered in a __submenu__ that appears when hovering or
14 * clicking on this menu item.
15 *
16 * Use `text` prop for the content of the menu item itself.
17 */
18 children?: React.ReactNode;
19 /**
20 * Whether this menu item is non-interactive. Enabling this prop will ignore `href`, `tabIndex`,
21 * and mouse event handlers (in particular click, down, enter, leave).
22 */
23 disabled?: boolean;
24 /**
25 * Right-aligned label text content, useful for displaying hotkeys.
26 *
27 * This prop actually supports JSX elements, but TypeScript will throw an error because
28 * `HTMLAttributes` only allows strings. Use `labelElement` to supply a JSX element in TypeScript.
29 */
30 label?: string;
31 /**
32 * A space-delimited list of class names to pass along to the right-aligned label wrapper element.
33 */
34 labelClassName?: string;
35 /**
36 * Right-aligned label content, useful for displaying hotkeys.
37 */
38 labelElement?: React.ReactNode;
39 /**
40 * Whether the text should be allowed to wrap to multiple lines.
41 * If `false`, text will be truncated with an ellipsis when it reaches `max-width`.
42 *
43 * @default false
44 */
45 multiline?: boolean;
46 /**
47 * Props to spread to `Popover`. Note that `content` and `minimal` cannot be
48 * changed and `usePortal` defaults to `false` so all submenus will live in
49 * the same container.
50 */
51 popoverProps?: Partial<IPopoverProps>;
52 /**
53 * Whether an enabled item without a submenu should automatically close its parent popover when clicked.
54 *
55 * @default true
56 */
57 shouldDismissPopover?: boolean;
58 /**
59 * Name of the HTML tag that wraps the MenuItem.
60 *
61 * @default "a"
62 */
63 tagName?: keyof JSX.IntrinsicElements;
64 /**
65 * A space-delimited list of class names to pass along to the text wrapper element.
66 */
67 textClassName?: string;
68 /**
69 * HTML title to be passed to the <Text> component
70 */
71 htmlTitle?: string;
72}
73export declare class MenuItem extends AbstractPureComponent2<MenuItemProps & React.AnchorHTMLAttributes<HTMLAnchorElement>> {
74 static defaultProps: MenuItemProps;
75 static displayName: string;
76 render(): JSX.Element;
77 private maybeRenderLabel;
78 private maybeRenderPopover;
79}