UNPKG

1.27 kBTypeScriptView Raw
1/// <reference types="react" />
2import { UseListItemRootSlotProps } from '../useList';
3export interface SelectOption<Value> {
4 value: Value;
5 label: React.ReactNode;
6 disabled?: boolean;
7 ref: React.RefObject<HTMLElement>;
8 id?: string;
9}
10export interface UseOptionParameters<Value> {
11 disabled: boolean;
12 id?: string;
13 label: string | React.ReactNode;
14 rootRef?: React.Ref<Element>;
15 value: Value;
16}
17export interface UseOptionReturnValue {
18 /**
19 * If `true`, the option is selected.
20 */
21 selected: boolean;
22 /**
23 * If `true`, the option is highlighted.
24 */
25 highlighted: boolean;
26 index: number;
27 /**
28 * Resolver for the root slot's props.
29 * @param externalProps props for the root slot
30 * @returns props that should be spread on the root slot
31 */
32 getRootProps: <ExternalProps extends Record<string, unknown>>(externalProps?: ExternalProps) => UseOptionRootSlotProps<ExternalProps>;
33 /**
34 * Ref to the root slot DOM node.
35 */
36 rootRef: React.RefCallback<Element> | null;
37}
38export type UseOptionRootSlotProps<ExternalProps extends Record<string, unknown> = {}> = UseListItemRootSlotProps<ExternalProps> & {
39 ref?: React.RefCallback<Element> | null;
40} & ExternalProps;