UNPKG

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