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