UNPKG

@base-ui-components/react

Version:

Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.

64 lines (63 loc) 2.14 kB
import * as React from 'react'; import type { GenericHTMLProps } from '../../utils/types.js'; import type { SelectRootContext } from '../root/SelectRootContext.js'; import { SelectIndexContext } from '../root/SelectIndexContext.js'; export declare function useSelectItem(params: useSelectItem.Parameters): useSelectItem.ReturnValue; export declare namespace useSelectItem { interface Parameters { /** * Whether the component should ignore user interaction. */ disabled: boolean; /** * Determines if the select item is highlighted. */ highlighted: boolean; /** * Determines if the select item is selected. */ selected: boolean; /** * The ref of the trigger element. */ ref?: React.Ref<Element>; /** * Whether the select menu is currently open. */ open: boolean; /** * The function to set the open state of the select. */ setOpen: SelectRootContext['setOpen']; /** * Determines if the user is currently typing for typeahead matching. */ typingRef: React.MutableRefObject<boolean>; /** * The function to handle the selection of the item. */ handleSelect: () => void; /** * The ref to the selection state of the item. */ selectionRef: React.MutableRefObject<{ allowSelectedMouseUp: boolean; allowUnselectedMouseUp: boolean; allowSelect: boolean; }>; /** * A ref to the index of the selected item. */ selectedIndexRef: React.RefObject<number | null>; /** * A ref to the index of the item. */ indexRef: React.RefObject<number>; setActiveIndex: SelectIndexContext['setActiveIndex']; popupRef: React.RefObject<HTMLDivElement | null>; } interface ReturnValue { getItemProps: (externalProps?: GenericHTMLProps) => GenericHTMLProps; rootRef: React.RefCallback<Element> | null; } }