UNPKG

2.17 kBTypeScriptView Raw
1import * as React from 'react';
2import { Simplify } from '@mui/types';
3import { PolymorphicProps, SlotComponentProps } from '../utils';
4import { UseMenuItemRootSlotProps } from '../useMenuItem';
5export interface MenuItemRootSlotPropsOverrides {
6}
7export type MenuItemOwnerState = Simplify<MenuItemOwnProps & {
8 disabled: boolean;
9 focusVisible: boolean;
10 highlighted: boolean;
11}>;
12export interface MenuItemOwnProps {
13 children?: React.ReactNode;
14 className?: string;
15 onClick?: React.MouseEventHandler<HTMLElement>;
16 /**
17 * If `true`, the menu item will be disabled.
18 * @default false
19 */
20 disabled?: boolean;
21 /**
22 * The components used for each slot inside the MenuItem.
23 * Either a string to use a HTML element or a component.
24 * @default {}
25 */
26 slots?: MenuItemSlots;
27 /**
28 * The props used for each slot inside the MenuItem.
29 * @default {}
30 */
31 slotProps?: {
32 root?: SlotComponentProps<'li', MenuItemRootSlotPropsOverrides, MenuItemOwnerState>;
33 };
34 /**
35 * A text representation of the menu item's content.
36 * Used for keyboard text navigation matching.
37 */
38 label?: string;
39 /**
40 * If `true`, the menu item won't receive focus when the mouse moves over it.
41 *
42 * @default false
43 */
44 disableFocusOnHover?: boolean;
45}
46export interface MenuItemSlots {
47 /**
48 * The component that renders the root.
49 * @default 'li'
50 */
51 root?: React.ElementType;
52}
53export interface MenuItemTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'li'> {
54 props: MenuItemOwnProps & AdditionalProps;
55 defaultComponent: RootComponentType;
56}
57export type MenuItemProps<RootComponentType extends React.ElementType = MenuItemTypeMap['defaultComponent']> = PolymorphicProps<MenuItemTypeMap<{}, RootComponentType>, RootComponentType>;
58export interface MenuItemState {
59 disabled: boolean;
60 highlighted: boolean;
61}
62export type MenuItemRootSlotProps = Simplify<UseMenuItemRootSlotProps & {
63 children?: React.ReactNode;
64 className: string;
65 ref: React.Ref<HTMLElement>;
66 ownerState: MenuItemOwnerState;
67}>;