downshift 9.1.0-alpha.0 → 9.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/downshift.d.ts +282 -0
- package/dist/index.d.ts +3 -0
- package/dist/stateChangeTypes.d.ts +17 -0
- package/package.json +1 -1
- package/typings/index.d.ts +2 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
export default Downshift;
|
|
2
|
+
declare class Downshift extends Component<any, any, any> {
|
|
3
|
+
static propTypes: {
|
|
4
|
+
children: PropTypes.Requireable<(...args: any[]) => any>;
|
|
5
|
+
defaultHighlightedIndex: PropTypes.Requireable<number>;
|
|
6
|
+
defaultIsOpen: PropTypes.Requireable<boolean>;
|
|
7
|
+
initialHighlightedIndex: PropTypes.Requireable<number>;
|
|
8
|
+
initialSelectedItem: PropTypes.Requireable<any>;
|
|
9
|
+
initialInputValue: PropTypes.Requireable<string>;
|
|
10
|
+
initialIsOpen: PropTypes.Requireable<boolean>;
|
|
11
|
+
getA11yStatusMessage: PropTypes.Requireable<(...args: any[]) => any>;
|
|
12
|
+
itemToString: PropTypes.Requireable<(...args: any[]) => any>;
|
|
13
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
14
|
+
onSelect: PropTypes.Requireable<(...args: any[]) => any>;
|
|
15
|
+
onStateChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
16
|
+
onInputValueChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
17
|
+
onUserAction: PropTypes.Requireable<(...args: any[]) => any>;
|
|
18
|
+
onOuterClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
19
|
+
selectedItemChanged: PropTypes.Requireable<(...args: any[]) => any>;
|
|
20
|
+
stateReducer: PropTypes.Requireable<(...args: any[]) => any>;
|
|
21
|
+
itemCount: PropTypes.Requireable<number>;
|
|
22
|
+
id: PropTypes.Requireable<string>;
|
|
23
|
+
environment: PropTypes.Requireable<PropTypes.InferProps<{
|
|
24
|
+
addEventListener: PropTypes.Validator<(...args: any[]) => any>;
|
|
25
|
+
removeEventListener: PropTypes.Validator<(...args: any[]) => any>;
|
|
26
|
+
document: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
27
|
+
createElement: PropTypes.Validator<(...args: any[]) => any>;
|
|
28
|
+
getElementById: PropTypes.Validator<(...args: any[]) => any>;
|
|
29
|
+
activeElement: PropTypes.Validator<any>;
|
|
30
|
+
body: PropTypes.Validator<any>;
|
|
31
|
+
}>>>;
|
|
32
|
+
Node: PropTypes.Validator<(...args: any[]) => any>;
|
|
33
|
+
}>>;
|
|
34
|
+
suppressRefError: PropTypes.Requireable<boolean>;
|
|
35
|
+
scrollIntoView: PropTypes.Requireable<(...args: any[]) => any>;
|
|
36
|
+
selectedItem: PropTypes.Requireable<any>;
|
|
37
|
+
isOpen: PropTypes.Requireable<boolean>;
|
|
38
|
+
inputValue: PropTypes.Requireable<string>;
|
|
39
|
+
highlightedIndex: PropTypes.Requireable<number>;
|
|
40
|
+
labelId: PropTypes.Requireable<string>;
|
|
41
|
+
inputId: PropTypes.Requireable<string>;
|
|
42
|
+
menuId: PropTypes.Requireable<string>;
|
|
43
|
+
getItemId: PropTypes.Requireable<(...args: any[]) => any>;
|
|
44
|
+
};
|
|
45
|
+
static defaultProps: {
|
|
46
|
+
defaultHighlightedIndex: null;
|
|
47
|
+
defaultIsOpen: boolean;
|
|
48
|
+
getA11yStatusMessage: typeof getA11yStatusMessage;
|
|
49
|
+
itemToString: (i: any) => string;
|
|
50
|
+
onStateChange: typeof noop;
|
|
51
|
+
onInputValueChange: typeof noop;
|
|
52
|
+
onUserAction: typeof noop;
|
|
53
|
+
onChange: typeof noop;
|
|
54
|
+
onSelect: typeof noop;
|
|
55
|
+
onOuterClick: typeof noop;
|
|
56
|
+
selectedItemChanged: (prevItem: any, item: any) => boolean;
|
|
57
|
+
environment: (Window & typeof globalThis) | undefined;
|
|
58
|
+
stateReducer: (state: any, stateToSet: any) => any;
|
|
59
|
+
suppressRefError: boolean;
|
|
60
|
+
scrollIntoView: typeof scrollIntoView;
|
|
61
|
+
};
|
|
62
|
+
static stateChangeTypes: typeof stateChangeTypes;
|
|
63
|
+
constructor(props: any);
|
|
64
|
+
state: Object;
|
|
65
|
+
id: any;
|
|
66
|
+
menuId: any;
|
|
67
|
+
labelId: any;
|
|
68
|
+
inputId: any;
|
|
69
|
+
getItemId: any;
|
|
70
|
+
items: any[];
|
|
71
|
+
itemCount: null;
|
|
72
|
+
previousResultCount: number;
|
|
73
|
+
timeoutIds: any[];
|
|
74
|
+
/**
|
|
75
|
+
* @param {Function} fn the function to call after the time
|
|
76
|
+
* @param {Number} time the time to wait
|
|
77
|
+
*/
|
|
78
|
+
internalSetTimeout: (fn: Function, time: number) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Clear all running timeouts
|
|
81
|
+
*/
|
|
82
|
+
internalClearTimeouts(): void;
|
|
83
|
+
/**
|
|
84
|
+
* Gets the state based on internal state or props
|
|
85
|
+
* If a state value is passed via props, then that
|
|
86
|
+
* is the value given, otherwise it's retrieved from
|
|
87
|
+
* stateToMerge
|
|
88
|
+
*
|
|
89
|
+
* @param {Object} stateToMerge defaults to this.state
|
|
90
|
+
* @return {Object} the state
|
|
91
|
+
*/
|
|
92
|
+
getState(stateToMerge?: Object): Object;
|
|
93
|
+
getItemCount(): number;
|
|
94
|
+
setItemCount: (count: any) => void;
|
|
95
|
+
unsetItemCount: () => void;
|
|
96
|
+
getItemNodeFromIndex(index: any): any;
|
|
97
|
+
isItemDisabled: (_item: any, index: any) => any;
|
|
98
|
+
setHighlightedIndex: (highlightedIndex?: any, otherStateToSet?: {}) => void;
|
|
99
|
+
scrollHighlightedItemIntoView(): void;
|
|
100
|
+
moveHighlightedIndex(amount: any, otherStateToSet: any): void;
|
|
101
|
+
clearSelection: (cb: any) => void;
|
|
102
|
+
selectItem: (item: any, otherStateToSet: any, cb: any) => void;
|
|
103
|
+
selectItemAtIndex: (itemIndex: any, otherStateToSet: any, cb: any) => void;
|
|
104
|
+
selectHighlightedItem: (otherStateToSet: any, cb: any) => void;
|
|
105
|
+
internalSetState: (stateToSet: any, cb: any) => void;
|
|
106
|
+
getStateAndHelpers(): {
|
|
107
|
+
getRootProps: ({ refKey, ref, ...rest }?: {
|
|
108
|
+
refKey?: string | undefined;
|
|
109
|
+
}, { suppressRefError }?: {
|
|
110
|
+
suppressRefError?: boolean | undefined;
|
|
111
|
+
}) => {
|
|
112
|
+
role: string;
|
|
113
|
+
'aria-expanded': any;
|
|
114
|
+
'aria-haspopup': string;
|
|
115
|
+
'aria-owns': any;
|
|
116
|
+
'aria-labelledby': any;
|
|
117
|
+
};
|
|
118
|
+
getToggleButtonProps: ({ onClick, onPress, onKeyDown, onKeyUp, onBlur, ...rest }?: {}) => {
|
|
119
|
+
type: string;
|
|
120
|
+
role: string;
|
|
121
|
+
'aria-label': string;
|
|
122
|
+
'aria-haspopup': boolean;
|
|
123
|
+
'data-toggle': boolean;
|
|
124
|
+
};
|
|
125
|
+
getLabelProps: (props: any) => any;
|
|
126
|
+
getMenuProps: ({ refKey, ref, ...props }?: {
|
|
127
|
+
refKey?: string | undefined;
|
|
128
|
+
}, { suppressRefError }?: {
|
|
129
|
+
suppressRefError?: boolean | undefined;
|
|
130
|
+
}) => {
|
|
131
|
+
role: string;
|
|
132
|
+
'aria-labelledby': any;
|
|
133
|
+
id: any;
|
|
134
|
+
};
|
|
135
|
+
getInputProps: ({ onKeyDown, onBlur, onChange, onInput, onChangeText, ...rest }?: {}) => {
|
|
136
|
+
'aria-autocomplete': string;
|
|
137
|
+
'aria-activedescendant': any;
|
|
138
|
+
'aria-controls': any;
|
|
139
|
+
'aria-labelledby': any;
|
|
140
|
+
autoComplete: string;
|
|
141
|
+
value: any;
|
|
142
|
+
id: any;
|
|
143
|
+
};
|
|
144
|
+
getItemProps: ({ onMouseMove, onMouseDown, onClick, onPress, index, item, ...rest }?: {
|
|
145
|
+
item?: void | undefined;
|
|
146
|
+
}) => {
|
|
147
|
+
onMouseMove: Function;
|
|
148
|
+
onMouseDown: Function;
|
|
149
|
+
id: any;
|
|
150
|
+
role: string;
|
|
151
|
+
'aria-selected': boolean;
|
|
152
|
+
} | {
|
|
153
|
+
onMouseDown: Function;
|
|
154
|
+
id: any;
|
|
155
|
+
role: string;
|
|
156
|
+
'aria-selected': boolean;
|
|
157
|
+
};
|
|
158
|
+
reset: (otherStateToSet: {} | undefined, cb: any) => void;
|
|
159
|
+
openMenu: (cb: any) => void;
|
|
160
|
+
closeMenu: (cb: any) => void;
|
|
161
|
+
toggleMenu: (otherStateToSet: {} | undefined, cb: any) => void;
|
|
162
|
+
selectItem: (item: any, otherStateToSet: any, cb: any) => void;
|
|
163
|
+
selectItemAtIndex: (itemIndex: any, otherStateToSet: any, cb: any) => void;
|
|
164
|
+
selectHighlightedItem: (otherStateToSet: any, cb: any) => void;
|
|
165
|
+
setHighlightedIndex: (highlightedIndex?: any, otherStateToSet?: {}) => void;
|
|
166
|
+
clearSelection: (cb: any) => void;
|
|
167
|
+
clearItems: () => void;
|
|
168
|
+
setItemCount: (count: any) => void;
|
|
169
|
+
unsetItemCount: () => void;
|
|
170
|
+
setState: (stateToSet: any, cb: any) => void;
|
|
171
|
+
itemToString: any;
|
|
172
|
+
id: any;
|
|
173
|
+
highlightedIndex: any;
|
|
174
|
+
inputValue: any;
|
|
175
|
+
isOpen: any;
|
|
176
|
+
selectedItem: any;
|
|
177
|
+
};
|
|
178
|
+
rootRef: (node: any) => any;
|
|
179
|
+
_rootNode: any;
|
|
180
|
+
getRootProps: ({ refKey, ref, ...rest }?: {
|
|
181
|
+
refKey?: string | undefined;
|
|
182
|
+
}, { suppressRefError }?: {
|
|
183
|
+
suppressRefError?: boolean | undefined;
|
|
184
|
+
}) => {
|
|
185
|
+
role: string;
|
|
186
|
+
'aria-expanded': any;
|
|
187
|
+
'aria-haspopup': string;
|
|
188
|
+
'aria-owns': any;
|
|
189
|
+
'aria-labelledby': any;
|
|
190
|
+
};
|
|
191
|
+
keyDownHandlers: {
|
|
192
|
+
ArrowDown(event: any): void;
|
|
193
|
+
ArrowUp(event: any): void;
|
|
194
|
+
Enter(event: any): void;
|
|
195
|
+
Escape(event: any): void;
|
|
196
|
+
};
|
|
197
|
+
buttonKeyDownHandlers: {
|
|
198
|
+
' '(event: any): void;
|
|
199
|
+
ArrowDown(event: any): void;
|
|
200
|
+
ArrowUp(event: any): void;
|
|
201
|
+
Enter(event: any): void;
|
|
202
|
+
Escape(event: any): void;
|
|
203
|
+
};
|
|
204
|
+
inputKeyDownHandlers: {
|
|
205
|
+
Home(event: any): void;
|
|
206
|
+
End(event: any): void;
|
|
207
|
+
ArrowDown(event: any): void;
|
|
208
|
+
ArrowUp(event: any): void;
|
|
209
|
+
Enter(event: any): void;
|
|
210
|
+
Escape(event: any): void;
|
|
211
|
+
};
|
|
212
|
+
getToggleButtonProps: ({ onClick, onPress, onKeyDown, onKeyUp, onBlur, ...rest }?: {}) => {
|
|
213
|
+
type: string;
|
|
214
|
+
role: string;
|
|
215
|
+
'aria-label': string;
|
|
216
|
+
'aria-haspopup': boolean;
|
|
217
|
+
'data-toggle': boolean;
|
|
218
|
+
};
|
|
219
|
+
buttonHandleKeyUp: (event: any) => void;
|
|
220
|
+
buttonHandleKeyDown: (event: any) => void;
|
|
221
|
+
buttonHandleClick: (event: any) => void;
|
|
222
|
+
buttonHandleBlur: (event: any) => void;
|
|
223
|
+
getLabelProps: (props: any) => any;
|
|
224
|
+
getInputProps: ({ onKeyDown, onBlur, onChange, onInput, onChangeText, ...rest }?: {}) => {
|
|
225
|
+
'aria-autocomplete': string;
|
|
226
|
+
'aria-activedescendant': any;
|
|
227
|
+
'aria-controls': any;
|
|
228
|
+
'aria-labelledby': any;
|
|
229
|
+
autoComplete: string;
|
|
230
|
+
value: any;
|
|
231
|
+
id: any;
|
|
232
|
+
};
|
|
233
|
+
inputHandleKeyDown: (event: any) => void;
|
|
234
|
+
inputHandleChange: (event: any) => void;
|
|
235
|
+
inputHandleBlur: () => void;
|
|
236
|
+
menuRef: (node: any) => void;
|
|
237
|
+
_menuNode: any;
|
|
238
|
+
getMenuProps: ({ refKey, ref, ...props }?: {
|
|
239
|
+
refKey?: string | undefined;
|
|
240
|
+
}, { suppressRefError }?: {
|
|
241
|
+
suppressRefError?: boolean | undefined;
|
|
242
|
+
}) => {
|
|
243
|
+
role: string;
|
|
244
|
+
'aria-labelledby': any;
|
|
245
|
+
id: any;
|
|
246
|
+
};
|
|
247
|
+
getItemProps: ({ onMouseMove, onMouseDown, onClick, onPress, index, item, ...rest }?: {
|
|
248
|
+
item?: void | undefined;
|
|
249
|
+
}) => {
|
|
250
|
+
onMouseMove: Function;
|
|
251
|
+
onMouseDown: Function;
|
|
252
|
+
id: any;
|
|
253
|
+
role: string;
|
|
254
|
+
'aria-selected': boolean;
|
|
255
|
+
} | {
|
|
256
|
+
onMouseDown: Function;
|
|
257
|
+
id: any;
|
|
258
|
+
role: string;
|
|
259
|
+
'aria-selected': boolean;
|
|
260
|
+
};
|
|
261
|
+
avoidScrolling: boolean | undefined;
|
|
262
|
+
clearItems: () => void;
|
|
263
|
+
reset: (otherStateToSet: {} | undefined, cb: any) => void;
|
|
264
|
+
toggleMenu: (otherStateToSet: {} | undefined, cb: any) => void;
|
|
265
|
+
openMenu: (cb: any) => void;
|
|
266
|
+
closeMenu: (cb: any) => void;
|
|
267
|
+
updateStatus: Function;
|
|
268
|
+
componentDidMount(): void;
|
|
269
|
+
cleanup: (() => void) | (() => void) | undefined;
|
|
270
|
+
isMouseDown: boolean | undefined;
|
|
271
|
+
isTouchMove: boolean | undefined;
|
|
272
|
+
shouldScroll(prevState: any, prevProps: any): any;
|
|
273
|
+
componentDidUpdate(prevProps: any, prevState: any): void;
|
|
274
|
+
componentWillUnmount(): void;
|
|
275
|
+
render(): any;
|
|
276
|
+
}
|
|
277
|
+
import { Component } from 'react';
|
|
278
|
+
import PropTypes from 'prop-types';
|
|
279
|
+
import { getA11yStatusMessage } from './utils';
|
|
280
|
+
import { noop } from './utils-ts';
|
|
281
|
+
import { scrollIntoView } from './utils-ts';
|
|
282
|
+
import * as stateChangeTypes from './stateChangeTypes';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const unknown: "__autocomplete_unknown__";
|
|
2
|
+
export const mouseUp: "__autocomplete_mouseup__";
|
|
3
|
+
export const itemMouseEnter: "__autocomplete_item_mouseenter__";
|
|
4
|
+
export const keyDownArrowUp: "__autocomplete_keydown_arrow_up__";
|
|
5
|
+
export const keyDownArrowDown: "__autocomplete_keydown_arrow_down__";
|
|
6
|
+
export const keyDownEscape: "__autocomplete_keydown_escape__";
|
|
7
|
+
export const keyDownEnter: "__autocomplete_keydown_enter__";
|
|
8
|
+
export const keyDownHome: "__autocomplete_keydown_home__";
|
|
9
|
+
export const keyDownEnd: "__autocomplete_keydown_end__";
|
|
10
|
+
export const clickItem: "__autocomplete_click_item__";
|
|
11
|
+
export const blurInput: "__autocomplete_blur_input__";
|
|
12
|
+
export const changeInput: "__autocomplete_change_input__";
|
|
13
|
+
export const keyDownSpaceButton: "__autocomplete_keydown_space_button__";
|
|
14
|
+
export const clickButton: "__autocomplete_click_button__";
|
|
15
|
+
export const blurButton: "__autocomplete_blur_button__";
|
|
16
|
+
export const controlledPropUpdatedSelectedItem: "__autocomplete_controlled_prop_updated_selected_item__";
|
|
17
|
+
export const touchEnd: "__autocomplete_touchend__";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "downshift",
|
|
3
|
-
"version": "9.1.0-alpha.
|
|
3
|
+
"version": "9.1.0-alpha.2",
|
|
4
4
|
"description": "🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.",
|
|
5
5
|
"main": "dist/downshift.cjs.js",
|
|
6
6
|
"react-native": "dist/downshift.native.cjs.js",
|