DefinitelyTyped/types/react-geosuggest/index.d.ts
Daniel Rosenwasser 8656af6859
Merge pull request #23386 from brmenchl/master
[react-geosuggest] Add argument types to onFocus component prop
2018-02-13 16:30:12 -08:00

82 lines
2.4 KiB
TypeScript

// Type definitions for react-geosuggest 2.7
// Project: https://github.com/ubilabs/react-geosuggest
// Definitions by: Brad Menchl <https://github.com/brmenchl>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
/// <reference types="googlemaps" />
import { Component, InputHTMLAttributes } from "react";
export default class Geosuggest extends Component<GeosuggestProps> {
focus(): void;
blur(): void;
update(value: string): void;
clear(): void;
}
export interface GeosuggestProps extends InputHTMLAttributes<HTMLInputElement> {
placeholder?: string;
initialValue?: string;
className?: string;
style?: Styles;
inputClassName?: string;
disabled?: boolean;
location?: google.maps.LatLng;
radius?: number;
bounds?: google.maps.LatLngBounds;
country?: string | string[];
types?: QueryType[];
fixtures?: Fixture[];
maxFixtures?: number;
googleMaps?: typeof google.maps;
ignoreTab?: boolean;
queryDelay?: number;
minLength?: number;
highlightMatch?: boolean;
onFocus?(value: any): void;
onBlur?(value: any): void;
onChange?(value: any): void;
onKeyDown?(event: any): void;
onKeyPress?(event: any): void;
onSuggestSelect?(suggest: Suggest): void;
onUpdateSuggests?(suggests: any, activeSuggest: any): void;
onActivateSuggest?(suggest: Suggest): void;
onSuggestNoResults?(userInput: string): void;
getSuggestLabel?(googleSuggest: google.maps.places.AutocompletePrediction): string;
renderSuggestItem?(googleSuggest: google.maps.places.AutocompletePrediction): any;
skipSuggest?(googleSuggest: google.maps.places.AutocompletePrediction): boolean;
autoActivateFirstSuggest?: boolean;
label?: string;
suggestsClassName?: string;
suggestsHiddenClassName?: string;
suggestsItemClassName?: string;
suggestsItemActiveClassName?: string;
autoComplete?: string;
}
export interface Styles {
input?: Record<string, any>;
suggestItem?: Record<string, any>;
suggests?: Record<string, any>;
}
export type QueryType
= 'establishment'
| 'geocode'
| '(cities)'
| '(regions)';
export interface Fixture {
className?: string;
label: string;
location?: google.maps.LatLng;
}
export interface Suggest {
gmaps?: google.maps.GeocoderResult;
label: string;
location: {lat: string, lng: string};
placeId: string;
}