1 | import * as React from 'react';
|
2 | import { ListAction, ListState, UseListRootSlotProps } from '../useList';
|
3 | import { MenuItemMetadata } from '../useMenuItem';
|
4 | import { EventHandlers } from '../utils/types';
|
5 | import { MenuProviderValue } from './MenuProvider';
|
6 | export interface UseMenuParameters {
|
7 | |
8 |
|
9 |
|
10 |
|
11 | defaultOpen?: boolean;
|
12 | |
13 |
|
14 |
|
15 |
|
16 | open?: boolean;
|
17 | |
18 |
|
19 |
|
20 | onOpenChange?: (open: boolean) => void;
|
21 | |
22 |
|
23 |
|
24 | listboxId?: string;
|
25 | |
26 |
|
27 |
|
28 | listboxRef?: React.Ref<Element>;
|
29 | }
|
30 | export interface UseMenuReturnValue {
|
31 | |
32 |
|
33 |
|
34 | contextValue: MenuProviderValue;
|
35 | |
36 |
|
37 |
|
38 |
|
39 | dispatch: (action: ListAction<string>) => void;
|
40 | |
41 |
|
42 |
|
43 |
|
44 |
|
45 | getListboxProps: <TOther extends EventHandlers>(otherHandlers?: TOther) => UseMenuListboxSlotProps;
|
46 | |
47 |
|
48 |
|
49 | highlightedValue: string | null;
|
50 | |
51 |
|
52 |
|
53 | listboxRef: React.RefCallback<Element> | null;
|
54 | |
55 |
|
56 |
|
57 | menuItems: Map<string, MenuItemMetadata>;
|
58 | |
59 |
|
60 |
|
61 | open: boolean;
|
62 | }
|
63 | interface UseMenuListboxSlotEventHandlers {
|
64 | onBlur: React.FocusEventHandler;
|
65 | onKeyDown: React.KeyboardEventHandler;
|
66 | }
|
67 | export type UseMenuListboxSlotProps<TOther = {}> = UseListRootSlotProps<Omit<TOther, keyof UseMenuListboxSlotEventHandlers> & UseMenuListboxSlotEventHandlers> & {
|
68 | ref: React.RefCallback<Element> | null;
|
69 | role: React.AriaRole;
|
70 | };
|
71 | export interface MenuInternalState extends ListState<string> {
|
72 | |
73 |
|
74 |
|
75 | open: boolean;
|
76 | }
|
77 | export {};
|