import { ComputedRef, MaybeRefOrGetter, Ref } from '../../node_modules/vue'; type Item = any; /** * Reactive inputs driving the selectable dropdown state. */ export interface UseSelectableDropdownOptions { /** * Two-way model of the currently active item(s). Owned by the component * (a `v-model`) and mutated by the selection actions. */ activeItems: Ref; /** * Two-way model of the canonical selection: a single item, or an array of * items when `multiple` is set. */ modelValue: Ref; /** * The items rendered by the list, carrying their scroller ids. Used to * resolve indexes for keyboard navigation and range selection. */ items: MaybeRefOrGetter; /** * Whether several items can be selected at once. */ multiple: MaybeRefOrGetter; /** * Equality predicate used to compare two items. */ eq: MaybeRefOrGetter<(a: Item, b: Item) => boolean>; } /** * Reactive API returned by {@link useSelectableDropdown}. */ export interface UseSelectableDropdown { /** * Index of the first active item within the items list, or `-1` when none is * active. */ firstActiveItemIndex: ComputedRef; /** * Whether the given item is currently active. */ itemActivated: (item: Item) => boolean; /** * Whether the item at the given items-list index is currently active. * Unlike {@link itemActivated}, resolves each active item to a single * distinct index, so duplicate-valued items aren't all marked active. */ itemActivatedAtIndex: (index: number) => boolean; /** * Selects a single item, toggling it off when it is the only active one. */ selectItem: (item: Item) => void; /** * Adds the item to the active set, or removes it when already active. */ addItem: (item: Item) => void; /** * Extends the active selection as a contiguous range up to the given item. */ selectRangeToItem: (item: Item) => void; /** * Resets the active set from the canonical model value (or the given value). */ activateItemOrItems: (itemOrItems?: Item) => void; /** * Moves the active item to the previous one in the list. */ activatePreviousItem: () => void; /** * Moves the active item to the next one in the list. */ activateNextItem: () => void; /** * Clears the active set. */ clearActiveItems: () => void; } /** * Owns the selection state machine of the selectable dropdown: which items are * active, how single/multiple/range selection mutate that set, keyboard * navigation between items, and the two-way synchronization between the active * set and the canonical `modelValue`. DOM concerns (keyboard binding, scroller * ids) and event emission stay in the component. * * This composable is internal to the library and not exported from the public * entry point; consume it from a relative path. * * @param options - Reactive dropdown inputs (see {@link UseSelectableDropdownOptions}). * @returns The {@link UseSelectableDropdown} selection API. * @example * import { useSelectableDropdown } from '@/composables/useSelectableDropdown' * * const { itemActivated, selectItem } = useSelectableDropdown({ * activeItems, * modelValue, * items: () => items_.value, * multiple: () => props.multiple, * eq: () => props.eq * }) */ export declare function useSelectableDropdown(options: UseSelectableDropdownOptions): UseSelectableDropdown; export default useSelectableDropdown;