use-places-autocomplete
Advanced tools
Comparing version 1.6.1 to 1.7.0
declare module "use-places-autocomplete" { | ||
/* Types from @types/googlemaps */ | ||
// Hook | ||
class LatLng { | ||
constructor(lat: number, lng: number, noWrap?: boolean); | ||
constructor(literal: LatLngLiteral, noWrap?: boolean); | ||
equals(other: LatLng): boolean; | ||
lat(): number; | ||
lng(): number; | ||
toString(): string; | ||
toUrlValue(precision?: number): string; | ||
toJSON(): LatLngLiteral; | ||
} | ||
class LatLngBounds { | ||
constructor(sw?: LatLng | LatLngLiteral, ne?: LatLng | LatLngLiteral); | ||
contains(latLng: LatLng | LatLngLiteral): boolean; | ||
equals(other: LatLngBounds | LatLngBoundsLiteral): boolean; | ||
extend(point: LatLng | LatLngLiteral): LatLngBounds; | ||
getCenter(): LatLng; | ||
getNorthEast(): LatLng; | ||
getSouthWest(): LatLng; | ||
intersects(other: LatLngBounds | LatLngBoundsLiteral): boolean; | ||
isEmpty(): boolean; | ||
toJSON(): LatLngBoundsLiteral; | ||
toSpan(): LatLng; | ||
toString(): string; | ||
toUrlValue(precision?: number): string; | ||
union(other: LatLngBounds | LatLngBoundsLiteral): LatLngBounds; | ||
} | ||
class AutocompleteSessionToken {} | ||
interface LatLngLiteral { | ||
lat: number; | ||
lng: number; | ||
} | ||
interface LatLngBoundsLiteral { | ||
east: number; | ||
north: number; | ||
south: number; | ||
west: number; | ||
} | ||
interface ComponentRestrictions { | ||
country: string | string[]; | ||
} | ||
interface AutocompletionRequest { | ||
bounds?: LatLngBounds | LatLngBoundsLiteral; | ||
componentRestrictions?: ComponentRestrictions; | ||
location?: LatLng; | ||
offset?: number; | ||
origin?: LatLng | LatLngLiteral; | ||
radius?: number; | ||
sessionToken?: AutocompleteSessionToken; | ||
types?: string[]; | ||
} | ||
interface PredictionSubstring { | ||
length: number; | ||
offset: number; | ||
} | ||
interface AutocompleteStructuredFormatting { | ||
main_text: string; | ||
main_text_matched_substrings: PredictionSubstring[]; | ||
secondary_text: string; | ||
secondary_text_matched_substrings?: PredictionSubstring[]; | ||
} | ||
interface PredictionTerm { | ||
offset: number; | ||
value: string; | ||
} | ||
interface AutocompletePrediction { | ||
description: string; | ||
distance_meters?: number; | ||
id?: string; | ||
matched_substrings: PredictionSubstring[]; | ||
place_id: string; | ||
reference: string; | ||
structured_formatting: AutocompleteStructuredFormatting; | ||
terms: PredictionTerm[]; | ||
types: string[]; | ||
} | ||
// Geocoding | ||
interface GeocoderComponentRestrictions { | ||
administrativeArea?: string; | ||
country?: string | string[]; | ||
locality?: string; | ||
postalCode?: string; | ||
route?: string; | ||
} | ||
interface GeocoderRequest { | ||
address?: string; | ||
bounds?: LatLngBounds | LatLngBoundsLiteral; | ||
componentRestrictions?: GeocoderComponentRestrictions; | ||
location?: LatLng | LatLngLiteral; | ||
placeId?: string; | ||
region?: string; | ||
} | ||
interface GeocoderAddressComponent { | ||
long_name: string; | ||
short_name: string; | ||
types: string[]; | ||
} | ||
enum GeocoderLocationType { | ||
APPROXIMATE = "APPROXIMATE", | ||
GEOMETRIC_CENTER = "GEOMETRIC_CENTER", | ||
RANGE_INTERPOLATED = "RANGE_INTERPOLATED", | ||
ROOFTOP = "ROOFTOP", | ||
} | ||
interface GeocoderGeometry { | ||
bounds: LatLngBounds; | ||
location: LatLng; | ||
location_type: GeocoderLocationType; | ||
viewport: LatLngBounds; | ||
} | ||
interface GeocoderResult { | ||
address_components: GeocoderAddressComponent[]; | ||
formatted_address: string; | ||
geometry: GeocoderGeometry; | ||
partial_match: boolean; | ||
place_id: string; | ||
postcode_localities: string[]; | ||
types: string[]; | ||
} | ||
// getDetails | ||
interface PlaceDetailsRequest { | ||
placeId: string; | ||
fields?: string[]; | ||
sessionToken?: AutocompleteSessionToken; | ||
} | ||
interface PlaceResult { | ||
address_components?: GeocoderAddressComponent[]; | ||
adr_address?: string; | ||
aspects?: PlaceAspectRating[]; | ||
formatted_address?: string; | ||
formatted_phone_number?: string; | ||
geometry?: PlaceGeometry; | ||
html_attributions?: string[]; | ||
icon?: string; | ||
id?: string; | ||
international_phone_number?: string; | ||
name: string; | ||
opening_hours?: OpeningHours; | ||
permanently_closed?: boolean; | ||
photos?: PlacePhoto[]; | ||
place_id?: string; | ||
plus_code?: PlacePlusCode; | ||
price_level?: number; | ||
rating?: number; | ||
reviews?: PlaceReview[]; | ||
types?: string[]; | ||
url?: string; | ||
user_ratings_total?: number; | ||
utc_offset?: number; | ||
utc_offset_minutes?: number; | ||
vicinity?: string; | ||
website?: string; | ||
} | ||
interface PlaceAspectRating { | ||
rating: number; | ||
type: string; | ||
} | ||
interface PlaceGeometry { | ||
location: LatLng; | ||
viewport: LatLngBounds; | ||
} | ||
interface OpeningHours { | ||
open_now: boolean; | ||
periods: OpeningPeriod[]; | ||
weekday_text: string[]; | ||
isOpen(date?: Date): boolean; | ||
} | ||
interface OpeningPeriod { | ||
open: OpeningHoursTime; | ||
close?: OpeningHoursTime; | ||
} | ||
interface OpeningHoursTime { | ||
day: number; | ||
hours: number; | ||
minutes: number; | ||
nextDate: number; | ||
time: string; | ||
} | ||
interface PlacePhoto { | ||
height: number; | ||
html_attributions: string[]; | ||
width: number; | ||
getUrl(opts: PhotoOptions): string; | ||
} | ||
interface PhotoOptions { | ||
maxHeight?: number; | ||
maxWidth?: number; | ||
} | ||
interface PlacePlusCode { | ||
compound_code?: string; | ||
global_code: string; | ||
} | ||
interface PlaceReview { | ||
aspects: PlaceAspectRating[]; | ||
author_name: string; | ||
author_url?: string; | ||
language: string; | ||
profile_photo_url: string; | ||
rating: number; | ||
relative_time_description: string; | ||
text: string; | ||
time: number; | ||
} | ||
/* Package types */ | ||
// Hook | ||
export type RequestOptions = AutocompletionRequest; | ||
@@ -236,0 +4,0 @@ |
{ | ||
"name": "use-places-autocomplete", | ||
"version": "1.6.1", | ||
"version": "1.7.0", | ||
"description": "React hook for Google Maps Places Autocomplete.", | ||
@@ -77,11 +77,11 @@ "license": "MIT", | ||
"@babel/core": "^7.12.10", | ||
"@babel/preset-env": "^7.12.10", | ||
"@babel/preset-env": "^7.12.11", | ||
"@babel/preset-react": "^7.12.10", | ||
"@babel/preset-typescript": "^7.12.7", | ||
"@emotion/babel-plugin": "^11.1.2", | ||
"@emotion/react": "^11.1.2", | ||
"@emotion/react": "^11.1.4", | ||
"@rollup/plugin-babel": "^5.2.2", | ||
"@rollup/plugin-commonjs": "^17.0.0", | ||
"@rollup/plugin-html": "^0.2.0", | ||
"@rollup/plugin-node-resolve": "^10.0.0", | ||
"@rollup/plugin-node-resolve": "^11.0.1", | ||
"@rollup/plugin-replace": "^2.3.4", | ||
@@ -91,4 +91,4 @@ "@rollup/plugin-url": "^6.0.0", | ||
"@testing-library/react-hooks": "^3.7.0", | ||
"@types/googlemaps": "^3.40.4", | ||
"@types/jest": "^26.0.18", | ||
"@types/googlemaps": "^3.43.0", | ||
"@types/jest": "^26.0.19", | ||
"@types/lodash.debounce": "^4.0.6", | ||
@@ -98,4 +98,4 @@ "@types/react": "^17.0.0", | ||
"eslint": "^7.2.0", | ||
"eslint-config-welly": "^1.8.6", | ||
"husky": "^4.3.5", | ||
"eslint-config-welly": "^1.8.7", | ||
"husky": "^4.3.6", | ||
"jest": "^26.6.3", | ||
@@ -112,3 +112,3 @@ "lint-staged": "^10.5.3", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.34.2", | ||
"rollup": "^2.35.1", | ||
"rollup-plugin-copy": "^3.3.0", | ||
@@ -124,3 +124,3 @@ "rollup-plugin-livereload": "^2.0.0", | ||
"ts-jest": "^26.4.4", | ||
"typescript": "^4.1.2" | ||
"typescript": "^4.1.3" | ||
}, | ||
@@ -127,0 +127,0 @@ "peerDependencies": { |
@@ -32,4 +32,4 @@ # <em><b>USE-PLACES-AUTOCOMPLETE</b></em> | ||
- π Supports [TypeScript](https://www.typescriptlang.org) type definition. | ||
- β¨οΈ Builds an UX rich component (e.g. [WAI-ARIA compliant](https://rawgit.com/w3c/aria-practices/master/aria-practices-DeletedSectionsArchive.html#autocomplete) and keyword support) via comprehensive [demo code](https://github.com/wellyshen/use-places-autocomplete/blob/master/demo/App/index.tsx). | ||
- π¦ Tiny size ([~ 1.3KB gzipped](https://bundlephobia.com/result?p=use-places-autocomplete)). No external dependencies, aside for the `react`. | ||
- β¨οΈ Builds a UX-rich component (e.g. [WAI-ARIA compliant](https://rawgit.com/w3c/aria-practices/master/aria-practices-DeletedSectionsArchive.html#autocomplete) and keyword support) via comprehensive [demo code](https://github.com/wellyshen/use-places-autocomplete/blob/master/demo/App/index.tsx). | ||
- π¦ Tiny size ([~ 1.3KB gzipped](https://bundlephobia.com/result?p=use-places-autocomplete)). No external dependencies, aside for the `react`. | ||
@@ -50,2 +50,10 @@ ## Requirement | ||
When working with TypeScript you need to install the [@types/googlemaps](https://www.npmjs.com/package/@types/googlemaps) as a `devDependencies`. | ||
```sh | ||
$ yarn add --dev @types/googlemaps | ||
# or | ||
$ npm install --save-dev @types/googlemaps | ||
``` | ||
## Getting Started | ||
@@ -492,6 +500,8 @@ | ||
- `parameter: object` - [the request](https://developers.google.com/maps/documentation/javascript/places#place_details_requests) of the PlacesService's `getDetails()` method. You must supply the `placeId` that you would like details about. | ||
- `parameter: object` - [the request](https://developers.google.com/maps/documentation/javascript/places#place_details_requests) of the PlacesService's `getDetails()` method. You must supply the `placeId` that you would like details about. If you do not specify any fields or omit the fields parameter you will get every field available. | ||
- `placeResult: object | null` - [the details](https://developers.google.com/maps/documentation/javascript/reference/places-service#PlaceResult) about the specific place your queried. | ||
- `error: any` - an exception. | ||
> β οΈ warning, you are billed based on how much information you retrieve, So it is advised that you retrieve just what you. | ||
## Contributors β¨ | ||
@@ -498,0 +508,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
528
40893
249