/
index.d.ts
90 lines (81 loc) · 2.69 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// 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;
selectSuggest(value?: Suggest): void;
}
// Replace with Exclude once on 2.8+
export type Diff<T extends string, U extends string> = (
& { [P in T]: P }
& { [P in U]: never }
& { [x: string]: never }
)[T];
export type Omit<T, K extends keyof T> = Pick<T, Diff<keyof T, K>>;
export interface GeosuggestProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'style'> {
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;
suggestItemClassName?: string;
suggestItemActiveClassName?: 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;
}