1 | import * as React from 'react';
|
2 | import { PopoverProps } from '../Popover';
|
3 | import { MenuListProps } from '../MenuList';
|
4 | import { PaperProps } from '../Paper';
|
5 | import { StandardProps } from '..';
|
6 | import { TransitionHandlerProps, TransitionProps } from '../transitions/transition';
|
7 |
|
8 | export interface MenuProps
|
9 | extends StandardProps<PopoverProps & Partial<TransitionHandlerProps>, MenuClassKey> {
|
10 | /**
|
11 | * A HTML element, or a function that returns it.
|
12 | * It's used to set the position of the menu.
|
13 | * @document
|
14 | */
|
15 | anchorEl?: PopoverProps['anchorEl'];
|
16 | /**
|
17 | * If `true` (Default) will focus the `[role="menu"]` if no focusable child is found. Disabled
|
18 | * children are not focusable. If you set this prop to `false` focus will be placed
|
19 | * on the parent modal container. This has severe accessibility implications
|
20 | * and should only be considered if you manage focus otherwise.
|
21 | */
|
22 | autoFocus?: boolean;
|
23 | /**
|
24 | * Menu contents, normally `MenuItem`s.
|
25 | */
|
26 | children?: React.ReactNode;
|
27 | /**
|
28 | * When opening the menu will not focus the active item but the `[role="menu"]`
|
29 | * unless `autoFocus` is also set to `false`. Not using the default means not
|
30 | * following WAI-ARIA authoring practices. Please be considerate about possible
|
31 | * accessibility implications.
|
32 | */
|
33 | disableAutoFocusItem?: boolean;
|
34 | /**
|
35 | * Props applied to the [`MenuList`](/api/menu-list/) element.
|
36 | */
|
37 | MenuListProps?: Partial<MenuListProps>;
|
38 | /**
|
39 | * Callback fired when the component requests to be closed.
|
40 | *
|
41 | * @param {object} event The event source of the callback.
|
42 | * @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`, `"tabKeyDown"`.
|
43 | */
|
44 | onClose?: PopoverProps['onClose'];
|
45 | /**
|
46 | * Callback fired before the Menu enters.
|
47 | * @deprecated Use the `TransitionProps` prop instead.
|
48 | * @document
|
49 | */
|
50 | onEnter?: PopoverProps['onEnter'];
|
51 | /**
|
52 | * Callback fired when the Menu has entered.
|
53 | * @deprecated Use the `TransitionProps` prop instead.
|
54 | * @document
|
55 | */
|
56 | onEntered?: PopoverProps['onEntered'];
|
57 | /**
|
58 | * Callback fired when the Menu is entering.
|
59 | * @deprecated Use the `TransitionProps` prop instead.
|
60 | * @document
|
61 | */
|
62 | onEntering?: PopoverProps['onEntering'];
|
63 | /**
|
64 | * Callback fired before the Menu exits.
|
65 | * @deprecated Use the `TransitionProps` prop instead.
|
66 | * @document
|
67 | */
|
68 | onExit?: PopoverProps['onExit'];
|
69 | /**
|
70 | * Callback fired when the Menu has exited.
|
71 | * @deprecated Use the `TransitionProps` prop instead.
|
72 | * @document
|
73 | */
|
74 | onExited?: PopoverProps['onExited'];
|
75 | /**
|
76 | * Callback fired when the Menu is exiting.
|
77 | * @deprecated Use the `TransitionProps` prop instead.
|
78 | * @document
|
79 | */
|
80 | onExiting?: PopoverProps['onExiting'];
|
81 | /**
|
82 | * If `true`, the menu is visible.
|
83 | */
|
84 | open: boolean;
|
85 | /**
|
86 | * `classes` prop applied to the [`Popover`](/api/popover/) element.
|
87 | */
|
88 | PopoverClasses?: PopoverProps['classes'];
|
89 | /**
|
90 | * The length of the transition in `ms`, or 'auto'
|
91 | */
|
92 | transitionDuration?: TransitionProps['timeout'] | 'auto';
|
93 | /**
|
94 | * Props applied to the transition element.
|
95 | * By default, the element is based on this [`Transition`](http://reactcommunity.org/react-transition-group/transition) component.
|
96 | */
|
97 | TransitionProps?: TransitionProps;
|
98 | /**
|
99 | * The variant to use. Use `menu` to prevent selected items from impacting the initial focus
|
100 | * and the vertical alignment relative to the anchor element.
|
101 | */
|
102 | variant?: 'menu' | 'selectedMenu';
|
103 | }
|
104 |
|
105 | export type MenuClassKey = 'paper' | 'list';
|
106 |
|
107 | /**
|
108 | *
|
109 | * Demos:
|
110 | *
|
111 | * - [App Bar](https://mui.com/components/app-bar/)
|
112 | * - [Menus](https://mui.com/components/menus/)
|
113 | *
|
114 | * API:
|
115 | *
|
116 | * - [Menu API](https://mui.com/api/menu/)
|
117 | * - inherits [Popover API](https://mui.com/api/popover/)
|
118 | */
|
119 | export default function Menu(props: MenuProps): JSX.Element;
|