diff --git a/.all-contributorsrc b/.all-contributorsrc
index 3cd448ab8..dcc0f91ed 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -243,6 +243,15 @@
"doc",
"ideas"
]
+ },
+ {
+ "login": "tansongyang",
+ "name": "Frank Tan",
+ "avatar_url": "https://avatars3.githubusercontent.com/u/9488719?v=4",
+ "profile": "https://github.com/tansongyang",
+ "contributions": [
+ "code"
+ ]
}
]
}
diff --git a/README.md b/README.md
index aaca1271f..23483d8ee 100644
--- a/README.md
+++ b/README.md
@@ -554,7 +554,7 @@ Thanks goes to these people ([emoji key][emojis]):
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| [
monssef](https://github.com/rezof)
[💡](#example-rezof "Examples") | [
Federico Zivolo](https://fezvrasta.github.io)
[📖](https://github.com/paypal/downshift/commits?author=FezVrasta "Documentation") | [
Divyendu Singh](https://divyendusingh.com)
[💡](#example-divyenduz "Examples") | [
Muhammad Salman](https://github.com/salmanmanekia)
[💻](https://github.com/paypal/downshift/commits?author=salmanmanekia "Code") | [
João Alberto](https://twitter.com/psicotropidev)
[💻](https://github.com/paypal/downshift/commits?author=psicotropicos "Code") | [
Bernard Lin](https://github.com/bernard-lin)
[💻](https://github.com/paypal/downshift/commits?author=bernard-lin "Code") [📖](https://github.com/paypal/downshift/commits?author=bernard-lin "Documentation") | [
Geoff Davis](https://geoffdavis.info)
[💡](#example-geoffdavis92 "Examples") |
| [
Anup](https://github.com/reznord)
[📖](https://github.com/paypal/downshift/commits?author=reznord "Documentation") | [
Ferdinand Salis](http://ferdinandsalis.com)
[🐛](https://github.com/paypal/downshift/issues?q=author%3Aferdinandsalis "Bug reports") [💻](https://github.com/paypal/downshift/commits?author=ferdinandsalis "Code") | [
Kye Hohenberger](https://github.com/tkh44)
[🐛](https://github.com/paypal/downshift/issues?q=author%3Atkh44 "Bug reports") | [
Julien Goux](https://github.com/jgoux)
[🐛](https://github.com/paypal/downshift/issues?q=author%3Ajgoux "Bug reports") [💻](https://github.com/paypal/downshift/commits?author=jgoux "Code") [⚠️](https://github.com/paypal/downshift/commits?author=jgoux "Tests") | [
Joachim Seminck](https://github.com/jseminck)
[💻](https://github.com/paypal/downshift/commits?author=jseminck "Code") | [
Jesse Harlin](http://jesseharlin.net/)
[🐛](https://github.com/paypal/downshift/issues?q=author%3Athe-simian "Bug reports") [💡](#example-the-simian "Examples") | [
Matt Parrish](https://github.com/pbomb)
[🔧](#tool-pbomb "Tools") |
-| [
thom](http://thom.kr)
[💻](https://github.com/paypal/downshift/commits?author=thomhos "Code") | [
Vu Tran](http://twitter.com/tranvu)
[💻](https://github.com/paypal/downshift/commits?author=vutran "Code") | [
Codie Mullins](https://github.com/codiemullins)
[💻](https://github.com/paypal/downshift/commits?author=codiemullins "Code") [💡](#example-codiemullins "Examples") | [
Mohammad Rajabifard](https://morajabi.me)
[📖](https://github.com/paypal/downshift/commits?author=morajabi "Documentation") [🤔](#ideas-morajabi "Ideas, Planning, & Feedback") |
+| [
thom](http://thom.kr)
[💻](https://github.com/paypal/downshift/commits?author=thomhos "Code") | [
Vu Tran](http://twitter.com/tranvu)
[💻](https://github.com/paypal/downshift/commits?author=vutran "Code") | [
Codie Mullins](https://github.com/codiemullins)
[💻](https://github.com/paypal/downshift/commits?author=codiemullins "Code") [💡](#example-codiemullins "Examples") | [
Mohammad Rajabifard](https://morajabi.me)
[📖](https://github.com/paypal/downshift/commits?author=morajabi "Documentation") [🤔](#ideas-morajabi "Ideas, Planning, & Feedback") | [
Frank Tan](https://github.com/tansongyang)
[💻](https://github.com/paypal/downshift/commits?author=tansongyang "Code") |
This project follows the [all-contributors][all-contributors] specification.
diff --git a/typings/index.d.ts b/typings/index.d.ts
index d1fed24bc..181845ef8 100644
--- a/typings/index.d.ts
+++ b/typings/index.d.ts
@@ -2,24 +2,24 @@ import * as React from 'react';
export interface DownshiftProps {
children: ChildrenFunction;
- defaultHighlightedIndex?: number;
+ defaultHighlightedIndex?: number | null;
defaultSelectedItem?: any;
defaultInputValue?: string;
defaultIsOpen?: boolean;
- getA11yStatusMessage?: (options: A11StatusMessageOptions) => any;
+ getA11yStatusMessage?: (options: A11yStatusMessageOptions) => any;
itemToString?: (item: any) => string;
onChange?: (selectedItem: any, stateAndHelpers: ControllerStateAndHelpers) => void;
onStateChange?: (options: StateChangeOptions, stateAndHelpers: ControllerStateAndHelpers) => void;
onUserAction?: (options: StateChangeOptions, stateAndHelpers: ControllerStateAndHelpers) => void;
- onClick?: Function;
+ itemCount?: number;
selectedItem?: any;
isOpen?: boolean;
inputValue?: string;
highlightedIndex?: number;
}
-export interface A11StatusMessageOptions {
- highlightedIndex: number;
+export interface A11yStatusMessageOptions {
+ highlightedIndex: number | null;
highlightedValue: any;
inputValue: string;
isOpen: boolean;
@@ -29,11 +29,6 @@ export interface A11StatusMessageOptions {
selectedItem: any;
}
-export interface ChangeOptions {
- selectedItem: any;
- previousItem: any;
-}
-
export interface StateChangeOptions {
highlightedIndex: number;
inputValue: string;
@@ -49,30 +44,14 @@ export interface GetInputPropsOptions extends React.HTMLProps
export interface GetLabelPropsOptions extends React.HTMLProps { }
-export interface GetButtonPropsOptions extends React.HTMLProps {
- // actions
- clearSelection: () => void;
- closeMenu: () => void;
- openMenu: () => void;
- selectHighlightedItem: () => void;
- selectItem: (item: any) => void;
- selectItemAtIndex: (index: number) => void;
- setHighlightedIndex: (index: number) => void;
- toggleMenu: (state: boolean) => void;
-
- // state
- highlightedIndex: number;
- inputValue: string;
- isOpen: boolean;
- selectedItem: any;
-}
+export interface GetButtonPropsOptions extends React.HTMLProps { }
interface OptionalExtraGetItemPropsOptions {
[key: string]: any;
}
export interface GetItemPropsOptions extends OptionalExtraGetItemPropsOptions {
- index: number;
+ index?: number;
item: any;
}
@@ -85,18 +64,20 @@ export interface ControllerStateAndHelpers {
getItemProps: (options: GetItemPropsOptions) => any;
// actions
- openMenu: () => void;
- closeMenu: () => void;
- toggleMenu: () => void;
- selectItem: (item: any) => void;
- selectItemAtIndex: (index: number) => void;
- selectHighlightedItem: (index: number) => void;
- setHighlightedItem: (index: number) => void;
- clearSelection: () => void;
+ openMenu: (cb?: Function) => void;
+ closeMenu: (cb?: Function) => void;
+ toggleMenu: (cb?: Function) => void;
+ selectItem: (item: any, otherStateToSet?: object, cb?: Function) => void;
+ selectItemAtIndex: (index: number, otherStateToSet?: object, cb?: Function) => void;
+ selectHighlightedItem: (otherStateToSet?: object, cb?: Function) => void;
+ setHighlightedIndex: (index: number, otherStateToSet?: object, cb?: Function) => void;
+ clearSelection: (cb?: Function) => void;
+ reset: (otherStateToSet?: object, cb?: Function) => void;
+ itemToString: (item: any) => void;
// state
- highlightedIndex: number;
- inputValue: string;
+ highlightedIndex: number | null;
+ inputValue: string | null;
isOpen: boolean;
selectedItem: any;
}