-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy pathAutocompletePropGetters.ts
More file actions
123 lines (114 loc) · 3.11 KB
/
AutocompletePropGetters.ts
File metadata and controls
123 lines (114 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import { BaseItem } from './AutocompleteApi';
import { AutocompleteEnterKeyHint } from './AutocompleteOptions';
import { InternalAutocompleteSource } from './AutocompleteSource';
export interface AutocompletePropGetters<
TItem extends BaseItem,
TEvent = Event,
TMouseEvent = MouseEvent,
TKeyboardEvent = KeyboardEvent
> {
getEnvironmentProps: GetEnvironmentProps;
getRootProps: GetRootProps;
getFormProps: GetFormProps<TEvent>;
getLabelProps: GetLabelProps;
getInputProps: GetInputProps<TEvent, TMouseEvent, TKeyboardEvent>;
getPanelProps: GetPanelProps<TMouseEvent>;
getListProps: GetListProps;
getItemProps: GetItemProps<TItem, TMouseEvent>;
}
export type GetEnvironmentProps = (props: {
[key: string]: unknown;
formElement: HTMLElement;
inputElement: HTMLInputElement;
panelElement: HTMLElement;
}) => {
onTouchStart(event: TouchEvent): void;
onTouchMove(event: TouchEvent): void;
onMouseDown(event: MouseEvent): void;
};
export type GetRootProps = (props?: { [key: string]: unknown }) => {
role: 'combobox';
'aria-expanded': boolean;
'aria-haspopup':
| boolean
| 'dialog'
| 'menu'
| 'true'
| 'false'
| 'grid'
| 'listbox'
| 'tree'
| undefined;
'aria-controls': string | undefined;
'aria-labelledby': string;
};
export type GetFormProps<TEvent = Event> = (props: {
[key: string]: unknown;
inputElement: HTMLInputElement | null;
}) => {
action: '';
noValidate: true;
role: 'search';
onSubmit(event: TEvent): void;
onReset(event: TEvent): void;
};
export type GetLabelProps = (props?: { [key: string]: unknown }) => {
htmlFor: string;
id: string;
};
export type GetInputProps<TEvent, TMouseEvent, TKeyboardEvent> = (props: {
[key: string]: unknown;
inputElement: HTMLInputElement | null;
maxLength?: number;
}) => {
id: string;
value: string;
autoFocus: boolean;
placeholder: string;
autoComplete: 'on' | 'off';
autoCorrect: 'on' | 'off';
autoCapitalize: 'on' | 'off';
enterKeyHint: AutocompleteEnterKeyHint;
spellCheck: 'false';
maxLength: number;
type: 'search';
'aria-autocomplete': 'none' | 'inline' | 'list' | 'both';
'aria-activedescendant': string | undefined;
'aria-controls': string | undefined;
'aria-labelledby': string;
onChange(event: TEvent): void;
onCompositionEnd(event: TEvent): void;
onKeyDown(event: TKeyboardEvent): void;
onFocus(event: TEvent): void;
onBlur(): void;
onClick(event: TMouseEvent): void;
};
export type GetPanelProps<TMouseEvent> = (props?: {
[key: string]: unknown;
}) => {
onMouseDown(event: TMouseEvent): void;
onMouseLeave(): void;
};
export type GetListProps = (props?: {
[key: string]: unknown;
source: InternalAutocompleteSource<any>;
}) => {
role: 'listbox';
'aria-labelledby': string;
id: string;
};
export type GetItemProps<
TItem extends BaseItem,
TMouseEvent = MouseEvent
> = (props: {
[key: string]: unknown;
item: TItem;
source: InternalAutocompleteSource<TItem>;
}) => {
id: string;
role: 'option';
'aria-selected': boolean;
onMouseMove(event: TMouseEvent): void;
onMouseDown(event: TMouseEvent): void;
onClick(event: TMouseEvent): void;
};