1 | /// <reference types="react" />
|
2 | import { EventHandlers } from '../utils';
|
3 | export interface UseListItemParameters<ItemValue> {
|
4 | /**
|
5 | * If `true`, the list item will dispatch the `itemHover` action on pointer over.
|
6 | * Since the use cases for it are rare, it's disabled by default.
|
7 | * It could be used to mimic the native `select` behavior, which highlights the hovered item.
|
8 | *
|
9 | * @default false
|
10 | */
|
11 | handlePointerOverEvents?: boolean;
|
12 | /**
|
13 | * The list item.
|
14 | */
|
15 | item: ItemValue;
|
16 | /**
|
17 | * A ref to the list item's DOM element.
|
18 | */
|
19 | rootRef?: React.Ref<Element>;
|
20 | }
|
21 | interface UseListItemRootSlotOwnProps {
|
22 | id?: string;
|
23 | onClick: React.MouseEventHandler;
|
24 | onPointerOver: React.PointerEventHandler | undefined;
|
25 | ref: React.RefCallback<Element> | null;
|
26 | tabIndex?: number;
|
27 | }
|
28 | export type UseListItemRootSlotProps<TOther = {}> = Omit<TOther, keyof UseListItemRootSlotOwnProps> & UseListItemRootSlotOwnProps;
|
29 | export interface UseListItemReturnValue {
|
30 | /**
|
31 | * Resolver for the root slot's props.
|
32 | * @param otherHandlers event handlers for the root slot
|
33 | * @returns props that should be spread on the root slot
|
34 | */
|
35 | getRootProps: <TOther extends EventHandlers = {}>(otherHandlers?: TOther) => UseListItemRootSlotProps<TOther>;
|
36 | /**
|
37 | * If `true`, the current item is highlighted.
|
38 | */
|
39 | highlighted: boolean;
|
40 | /**
|
41 | * If `true`, the current item is selected.
|
42 | */
|
43 | selected: boolean;
|
44 | /**
|
45 | * The ref to the root element.
|
46 | */
|
47 | rootRef: React.RefCallback<Element> | null;
|
48 | }
|
49 | export {};
|