UNPKG

1.94 kBTypeScriptView Raw
1/// <reference types="react" />
2import { UseButtonRootSlotProps } from '../useButton';
3import { MuiCancellableEventHandler } from '../utils/MuiCancellableEvent';
4interface UseMenuItemRootSlotOwnProps {
5 id: string | undefined;
6 role: 'menuitem';
7 ref: React.RefCallback<Element> | null;
8}
9export interface MenuItemMetadata {
10 id: string;
11 disabled: boolean;
12 label?: string;
13 ref: React.RefObject<HTMLElement>;
14}
15export type UseMenuItemRootSlotProps<ExternalProps = {}> = ExternalProps & UseMenuItemRootSlotOwnProps & UseButtonRootSlotProps<ExternalProps> & {
16 onClick: MuiCancellableEventHandler<React.MouseEvent>;
17};
18export interface UseMenuItemParameters {
19 disabled?: boolean;
20 id?: string;
21 label?: string;
22 onClick?: React.MouseEventHandler<any>;
23 rootRef: React.Ref<Element>;
24 /**
25 * If `true`, the menu item won't receive focus when the mouse moves over it.
26 *
27 * @default false
28 */
29 disableFocusOnHover?: boolean;
30}
31export interface UseMenuItemReturnValue {
32 /**
33 * Resolver for the root slot's props.
34 * @param externalProps event handlers for the root slot
35 * @returns props that should be spread on the root slot
36 */
37 getRootProps: <ExternalProps extends Record<string, unknown> = {}>(externalProps?: ExternalProps) => UseMenuItemRootSlotProps<ExternalProps>;
38 /**
39 * If `true`, the component is disabled.
40 */
41 disabled: boolean;
42 /**
43 * If `true`, the component is being focused using keyboard.
44 */
45 focusVisible: boolean;
46 /**
47 * If `true`, the component is being highlighted.
48 */
49 highlighted: boolean;
50 /**
51 * 0-based index of the item in the menu.
52 */
53 index: number;
54 /**
55 * The ref to the component's root DOM element.
56 */
57 rootRef: React.RefCallback<Element> | null;
58 /**
59 * Total number of items in the menu.
60 */
61 totalItemCount: number;
62}
63export {};