UNPKG

2.27 kBTypeScriptView Raw
1import * as React from 'react';
2import { ExtendList, ExtendListTypeMap } from '../List';
3import { OverrideProps } from '../OverridableComponent';
4
5export interface MenuListOwnProps {
6 /**
7 * If `true`, will focus the `[role="menu"]` container and move into tab order.
8 * @default false
9 */
10 autoFocus?: boolean;
11 /**
12 * If `true`, will focus the first menuitem if `variant="menu"` or selected item
13 * if `variant="selectedMenu"`.
14 * @default false
15 */
16 autoFocusItem?: boolean;
17 /**
18 * MenuList contents, normally `MenuItem`s.
19 */
20 children?: React.ReactNode;
21 /**
22 * If `true`, will allow focus on disabled items.
23 * @default false
24 */
25 disabledItemsFocusable?: boolean;
26 /**
27 * If `true`, the menu items will not wrap focus.
28 * @default false
29 */
30 disableListWrap?: boolean;
31 /**
32 * The variant to use. Use `menu` to prevent selected items from impacting the initial focus
33 * and the vertical alignment relative to the anchor element.
34 * @default 'selectedMenu'
35 */
36 variant?: 'menu' | 'selectedMenu';
37}
38
39export type MenuListTypeMap<
40 AdditionalProps = {},
41 RootComponent extends React.ElementType = 'ul',
42> = ExtendListTypeMap<{
43 props: AdditionalProps & MenuListOwnProps;
44 defaultComponent: RootComponent;
45}>;
46
47export type MenuListClassKey = keyof NonNullable<MenuListTypeMap['props']['classes']>;
48
49/**
50 * A permanently displayed menu following https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/.
51 * It's exposed to help customization of the [`Menu`](https://mui.com/material-ui/api/menu/) component if you
52 * use it separately you need to move focus into the component manually. Once
53 * the focus is placed inside the component it is fully keyboard accessible.
54 *
55 * Demos:
56 *
57 * - [Menu](https://mui.com/material-ui/react-menu/)
58 *
59 * API:
60 *
61 * - [MenuList API](https://mui.com/material-ui/api/menu-list/)
62 * - inherits [List API](https://mui.com/material-ui/api/list/)
63 */
64declare const MenuList: ExtendList<MenuListTypeMap>;
65
66export type MenuListProps<
67 RootComponent extends React.ElementType = MenuListTypeMap['defaultComponent'],
68 AdditionalProps = {},
69> = OverrideProps<MenuListTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
70 component?: React.ElementType;
71};
72
73export default MenuList;