Created
August 27, 2017 07:12
-
-
Save nitin42/bcbd15c852912d4736a3472ccdd9cbe5 to your computer and use it in GitHub Desktop.
Flow typed definitions for downshift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
type A11yOptionsStatusMessageOptions = { | |
highlightedIndex: number, | |
highlightedValue: any, | |
inputValue: string, | |
isOpen: boolean, | |
itemToString: (item: any) => string, | |
previousResultCount: number, | |
resultCount: number, | |
selectedItem: any, | |
} | |
type ChangeOptions = { | |
selectedItem: any, | |
previousItem: any, | |
} | |
type StateChangeOptions = { | |
highlightedIndex: number, | |
inputValue: string, | |
isOpen: boolean, | |
selectedItem: any, | |
} | |
type GetRootPropsOptions = { | |
refKey: string, | |
} | |
type GetItemPropsOptions = { | |
index: number, | |
item: any, | |
} | |
type ControllerStateAndHelpers = { | |
getRootProps: (options: GetRootPropsOptions) => any, | |
getButtonProps: (options: GetButtonPropsOptions) => any, | |
getLabelProps: (options: GetLabelPropsOptions) => any, | |
getInputProps: (options: GetInputPropsOptions) => any, | |
getItemProps: (options: GetItemPropsOptions) => any, | |
openMenu: () => void, | |
closeMenu: () => void, | |
toggleMenu: () => void, | |
selectItem: (item: any) => void, | |
selectItemAtIndex: (index: number) => void, | |
selectHighlightedItem: (index: number) => void, | |
setHighlightedItem: (index: number) => void, | |
clearSelection: () => void, | |
highlightedIndex: number, | |
inputValue: string, | |
isOpen: boolean, | |
selectedItem: any, | |
} | |
class GetInputPropsOptions extends React$Element<*> {} | |
class GetLabelPropsOptions extends React$Element<*> {} | |
class GetButtonPropsOptions extends React$Element<*> { | |
clearSelection: () => void | |
closeMenu: () => void | |
openMenu: () => void | |
selectHighlightedItem: () => void | |
selectItem: (item: any) => void | |
selectItemAtIndex: (index: number) => void | |
setHighlightedIndex: (index: number) => void | |
toggleMenu: (state: boolean) => void | |
highlightedIndex: number | |
inputValue: string | |
isOpen: boolean | |
selectedItem: any | |
} | |
type ChildrenFunction = (options: ControllerStateAndHelpers) => React$Node<*> | |
type downshiftProps = { | |
children: ChildrenFunction, | |
defaultHighlightedIndex?: number, | |
defaultSelectedItem?: any, | |
defaultInputValue?: string, | |
defaultIsOpen?: boolean, | |
getA11yStatusMessage?: (options: A11yOptionsStatusMessageOptions) => any, | |
itemToString?: (item: any) => any, | |
onChange?: (options: ChangeOptions) => void, | |
onStateChange?: (options: StateChangeOptions) => void, | |
onClick?: Function, | |
selectedItem?: any, | |
isOpen?: boolean, | |
inputValue?: string, | |
highlightedIndex?: number, | |
} | |
class Downshift extends React$Component { | |
props: downshiftProps | |
} | |
declare module 'downshift' { | |
declare export default Downshift | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh! I'll update it. Thanks 😄