diff --git a/types/react-places-autocomplete/index.d.ts b/types/react-places-autocomplete/index.d.ts index dffcbf29f8..bf11a9fa30 100644 --- a/types/react-places-autocomplete/index.d.ts +++ b/types/react-places-autocomplete/index.d.ts @@ -53,24 +53,24 @@ export interface PropTypes { role: 'combobox'; 'aria-autocomplete': 'list'; 'aria-expanded': boolean; - 'aria-activedescendant': string | null; + 'aria-activedescendant': string | undefined; disabled: boolean; onKeyDown: React.KeyboardEventHandler; - onBlur: () => void; + onBlur: React.FocusEventHandler; value: string | undefined; onChange: (ev: { target: { value: string }}) => void; } & InputProps; getSuggestionItemProps: (suggestion: Suggestion, options?: SuggestionProps) => { key: number; - id: string | null; + id: string | undefined; role: 'option'; - onMouseEnter: () => void; - onMouseLeave: () => void; + onMouseEnter: React.MouseEventHandler; + onMouseLeave: React.MouseEventHandler; onMouseDown: React.MouseEventHandler; - onMouseUp: () => void; - onTouchStart: () => void; - onTouchEnd: () => void; - onClick: (event?: Event) => void; + onMouseUp: React.MouseEventHandler; + onTouchStart: React.TouchEventHandler; + onTouchEnd: React.TouchEventHandler; + onClick: React.MouseEventHandler; } & SuggestionProps; }>) => React.ReactNode; } diff --git a/types/react-places-autocomplete/react-places-autocomplete-tests.tsx b/types/react-places-autocomplete/react-places-autocomplete-tests.tsx index 7d72ac4397..3da7a4e81c 100644 --- a/types/react-places-autocomplete/react-places-autocomplete-tests.tsx +++ b/types/react-places-autocomplete/react-places-autocomplete-tests.tsx @@ -31,18 +31,30 @@ class Test extends React.Component { return (
- {({getInputProps, getSuggestionItemProps, suggestions}) => ( - <> - -
- {suggestions.map(suggestion => ( -
- {suggestion.description} -
- ))} -
- - )} + {({getInputProps, suggestions, getSuggestionItemProps, loading}) => { + const inputProps = getInputProps({ + required: true, + className: loading ? 'is-pending' : '' + }); + return ( + <> + +
+ {suggestions.map(suggestion => { + const divProps = getSuggestionItemProps(suggestion, { + className: suggestion.active ? 'active' : '' + }); + return ( +
+ {suggestion.description} +
+ ); + })} +
+ + ); + } + }
);