UNPKG

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