UNPKG

1.52 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[];
23export default function listReducer<ItemValue, State extends ListState<ItemValue>>(state: State, action: ListReducerAction<ItemValue> & {
24 context: ListActionContext<ItemValue>;
25}): State;