UNPKG

2.08 kBTypeScriptView Raw
1/// <reference types="react" />
2export declare const ListActionTypes: {
3 readonly blur: "list:blur";
4 readonly focus: "list:focus";
5 readonly itemClick: "list:itemClick";
6 readonly itemHover: "list:itemHover";
7 readonly itemsChange: "list:itemsChange";
8 readonly keyDown: "list:keyDown";
9 readonly resetHighlight: "list:resetHighlight";
10 readonly highlightLast: "list:highlightLast";
11 readonly textNavigation: "list:textNavigation";
12 readonly clearSelection: "list:clearSelection";
13};
14interface ItemClickAction<ItemValue> {
15 type: typeof ListActionTypes.itemClick;
16 item: ItemValue;
17 event: React.MouseEvent;
18}
19interface ItemHoverAction<ItemValue> {
20 type: typeof ListActionTypes.itemHover;
21 item: ItemValue;
22 event: React.MouseEvent;
23}
24interface FocusAction {
25 type: typeof ListActionTypes.focus;
26 event: React.FocusEvent;
27}
28interface BlurAction {
29 type: typeof ListActionTypes.blur;
30 event: React.FocusEvent;
31}
32interface KeyDownAction {
33 type: typeof ListActionTypes.keyDown;
34 key: string;
35 event: React.KeyboardEvent;
36}
37interface TextNavigationAction {
38 type: typeof ListActionTypes.textNavigation;
39 event: React.KeyboardEvent;
40 searchString: string;
41}
42interface ItemsChangeAction<ItemValue> {
43 type: typeof ListActionTypes.itemsChange;
44 event: null;
45 items: ItemValue[];
46 previousItems: ItemValue[];
47}
48interface ResetHighlightAction {
49 type: typeof ListActionTypes.resetHighlight;
50 event: React.SyntheticEvent | null;
51}
52interface HighlightLastAction {
53 type: typeof ListActionTypes.highlightLast;
54 event: React.SyntheticEvent | null;
55}
56interface ClearSelectionAction {
57 type: typeof ListActionTypes.clearSelection;
58}
59/**
60 * A union of all standard actions that can be dispatched to the list reducer.
61 */
62export type ListAction<ItemValue> = BlurAction | FocusAction | ItemClickAction<ItemValue> | ItemHoverAction<ItemValue> | ItemsChangeAction<ItemValue> | KeyDownAction | ResetHighlightAction | HighlightLastAction | TextNavigationAction | ClearSelectionAction;
63export {};