UNPKG

4.04 kBTypeScriptView Raw
1import * as React from "react";
2import { AbstractPureComponent2 } from "../../common";
3import { ActionProps, LinkProps } from "../../common/props";
4import { IPopoverProps } from "../popover/popover";
5import { MenuProps } from "./menu";
6export declare type MenuItemProps = IMenuItemProps;
7/** @deprecated use MenuItemProps */
8export interface IMenuItemProps extends ActionProps, LinkProps {
9 /** Item text, required for usability. */
10 text: React.ReactNode;
11 /**
12 * Whether this item should render with an active appearance. Used to indicate keyboard focus.
13 */
14 active?: boolean;
15 /**
16 * Children of this component will be rendered in a __submenu__ that appears when hovering or
17 * clicking on this menu item.
18 *
19 * Use `text` prop for the content of the menu item itself.
20 */
21 children?: React.ReactNode;
22 /**
23 * Whether this menu item is non-interactive. Enabling this prop will ignore `href`, `tabIndex`,
24 * and mouse event handlers (in particular click, down, enter, leave).
25 */
26 disabled?: boolean;
27 /**
28 * Right-aligned label text content, useful for displaying hotkeys.
29 *
30 * This prop actually supports JSX elements, but TypeScript will throw an error because
31 * `HTMLAttributes` only allows strings. Use `labelElement` to supply a JSX element in TypeScript.
32 */
33 label?: string;
34 /**
35 * A space-delimited list of class names to pass along to the right-aligned label wrapper element.
36 */
37 labelClassName?: string;
38 /**
39 * Right-aligned label content, useful for displaying hotkeys.
40 */
41 labelElement?: React.ReactNode;
42 /**
43 * Changes the ARIA `role` property structure of this MenuItem to accomodate for various
44 * different `role`s of the parent Menu `ul` element.
45 *
46 * If `menuitem`, role structure becomes:
47 *
48 * `<li role="none"`
49 * `<a role="menuitem"`
50 *
51 * which is proper role structure for a `<ul role="menu"` parent (this is the default `role` of a `Menu`).
52 *
53 * If `listoption`, role structure becomes:
54 *
55 * `<li role="option"`
56 * `<a role=undefined`
57 *
58 * which is proper role structure for a `<ul role="listbox"` parent, or a `<select>` parent.
59 *
60 * @default "menuitem"
61 */
62 roleStructure?: "menuitem" | "listoption";
63 /**
64 * Whether the text should be allowed to wrap to multiple lines.
65 * If `false`, text will be truncated with an ellipsis when it reaches `max-width`.
66 *
67 * @default false
68 */
69 multiline?: boolean;
70 /**
71 * Props to spread to `Popover`. Note that `content` and `minimal` cannot be
72 * changed and `usePortal` defaults to `false` so all submenus will live in
73 * the same container.
74 */
75 popoverProps?: Partial<IPopoverProps>;
76 /**
77 * Whether this item is selected. This will set the `aria-selected` attribute.
78 */
79 selected?: boolean;
80 /**
81 * Whether an enabled item without a submenu should automatically close its parent popover when clicked.
82 *
83 * @default true
84 */
85 shouldDismissPopover?: boolean;
86 /**
87 * Props to spread to the child `Menu` component if this item has a submenu.
88 */
89 submenuProps?: Partial<MenuProps>;
90 /**
91 * Name of the HTML tag that wraps the MenuItem.
92 *
93 * @default "a"
94 */
95 tagName?: keyof JSX.IntrinsicElements;
96 /**
97 * A space-delimited list of class names to pass along to the text wrapper element.
98 */
99 textClassName?: string;
100 /**
101 * HTML title to be passed to the <Text> component
102 */
103 htmlTitle?: string;
104}
105/**
106 * Menu item component.
107 *
108 * @see https://blueprintjs.com/docs/#core/components/menu.menu-item
109 */
110export declare class MenuItem extends AbstractPureComponent2<MenuItemProps & React.AnchorHTMLAttributes<HTMLAnchorElement>> {
111 static defaultProps: MenuItemProps;
112 static displayName: string;
113 render(): JSX.Element;
114 private maybeRenderLabel;
115 private maybeRenderPopover;
116}