UNPKG

2 kBTypeScriptView Raw
1import { ListState, ListReducerAction, ListActionContext, SelectionMode } from './useList.types';
2/**
3 * Gets the next item to highlight based on the current highlighted item and the search direction.
4 *
5 * @param previouslyHighlightedValue The item from which to start the search for the next candidate.
6 * @param offset The offset from the previously highlighted item to search for the next candidate or a special named value ('reset', 'start', 'end').
7 * @param context The list action context.
8 *
9 * @returns The next item to highlight or null if no item is valid.
10 */
11export declare function moveHighlight<ItemValue>(previouslyHighlightedValue: ItemValue | null, offset: number | 'reset' | 'start' | 'end', context: ListActionContext<ItemValue>): NonNullable<ItemValue> | (ItemValue & undefined) | null;
12/**
13 * Toggles the selection of an item.
14 *
15 * @param item Item to toggle.
16 * @param selectedValues Already selected items.
17 * @param selectionMode The number of items that can be simultanously selected.
18 * @param itemComparer A custom item comparer function.
19 *
20 * @returns The new array of selected items.
21 */
22export declare function toggleSelection<ItemValue>(item: ItemValue, selectedValues: ItemValue[], selectionMode: SelectionMode, itemComparer: (item1: ItemValue, item2: ItemValue) => boolean): ItemValue[];
23/**
24 * Handles item selection in a list.
25 *
26 * @param item - The item to be selected.
27 * @param state - The current state of the list.
28 * @param context - The context of the list action.
29 * @returns The new state of the list after the item has been selected, or the original state if the item is disabled.
30 */
31export declare function handleItemSelection<ItemValue, State extends ListState<ItemValue>>(item: ItemValue, state: State, context: ListActionContext<ItemValue>): State;
32export declare function listReducer<ItemValue, State extends ListState<ItemValue>>(state: State, action: ListReducerAction<ItemValue> & {
33 context: ListActionContext<ItemValue>;
34}): State;