Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-google-autocomplete

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-google-autocomplete - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

8

lib/index.js

@@ -52,3 +52,3 @@ 'use strict';

_props$fields = _props.fields,
fields = _props$fields === undefined ? ["address_components", "geometry.location", "place_id", "formatted_address"] : _props$fields;
fields = _props$fields === undefined ? ['address_components', 'geometry.location', 'place_id', 'formatted_address'] : _props$fields;

@@ -99,3 +99,3 @@ var config = {

if (this.props.onPlaceSelected) {
this.props.onPlaceSelected(this.autocomplete.getPlace());
this.props.onPlaceSelected(this.autocomplete.getPlace(), this.refs.input);
}

@@ -113,5 +113,3 @@ }

return _react2.default.createElement('input', _extends({
ref: 'input'
}, rest));
return _react2.default.createElement('input', _extends({ ref: 'input' }, rest));
}

@@ -118,0 +116,0 @@ }]);

{
"name": "react-google-autocomplete",
"version": "1.1.0",
"version": "1.1.1",
"description": "React component for google autocomplete.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -10,4 +10,4 @@ import React from 'react';

bounds: PropTypes.object,
fields: PropTypes.array,
}
fields: PropTypes.array
};

@@ -22,6 +22,11 @@ constructor(props) {

const {
types=['(cities)'],
types = ['(cities)'],
componentRestrictions,
bounds,
fields = ["address_components", "geometry.location", "place_id", "formatted_address"]
fields = [
'address_components',
'geometry.location',
'place_id',
'formatted_address'
]
} = this.props;

@@ -31,3 +36,3 @@ const config = {

bounds,
fields,
fields
};

@@ -41,5 +46,11 @@

this.autocomplete = new google.maps.places.Autocomplete(this.refs.input, config);
this.autocomplete = new google.maps.places.Autocomplete(
this.refs.input,
config
);
this.event = this.autocomplete.addListener('place_changed', this.onSelected.bind(this));
this.event = this.autocomplete.addListener(
'place_changed',
this.onSelected.bind(this)
);
}

@@ -58,3 +69,3 @@

attributes: true,
attributeFilter: ['autocomplete'],
attributeFilter: ['autocomplete']
});

@@ -70,3 +81,3 @@ }

if (this.props.onPlaceSelected) {
this.props.onPlaceSelected(this.autocomplete.getPlace());
this.props.onPlaceSelected(this.autocomplete.getPlace(), this.refs.input);
}

@@ -76,10 +87,11 @@ }

render() {
const {onPlaceSelected, types, componentRestrictions, bounds, ...rest} = this.props;
const {
onPlaceSelected,
types,
componentRestrictions,
bounds,
...rest
} = this.props;
return (
<input
ref="input"
{...rest}
/>
);
return <input ref="input" {...rest} />;
}

@@ -92,4 +104,4 @@ }

onOpen: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
}
onClose: PropTypes.func.isRequired
};

@@ -102,13 +114,16 @@ constructor(props) {

onChange(e) {
const { types=['(cities)'] } = this.props;
const { types = ['(cities)'] } = this.props;
if(e.target.value) {
this.service.getPlacePredictions({input: e.target.value, types}, (predictions, status) => {
if (status === 'OK' && predictions && predictions.length > 0) {
this.props.onOpen(predictions);
if (e.target.value) {
this.service.getPlacePredictions(
{ input: e.target.value, types },
(predictions, status) => {
if (status === 'OK' && predictions && predictions.length > 0) {
this.props.onOpen(predictions);
console.log(predictions);
} else {
this.props.onClose();
} else {
this.props.onClose();
}
}
});
);
} else {

@@ -119,10 +134,13 @@ this.props.onClose();

componentDidMount() {
componentDidMount() {
if (this.props.input.value) {
this.placeService = new google.maps.places.PlacesService(this.refs.div);
this.placeService.getDetails({placeId: this.props.input.value}, (e, status) => {
if(status === 'OK') {
this.refs.input.value = e.formatted_address;
this.placeService.getDetails(
{ placeId: this.props.input.value },
(e, status) => {
if (status === 'OK') {
this.refs.input.value = e.formatted_address;
}
}
});
);
}

@@ -134,12 +152,10 @@ }

<div>
{React.cloneElement(this.props.input,
{
...this.props,
ref: 'input',
onChange: (e) => {
this.onChange(e);
},
{React.cloneElement(this.props.input, {
...this.props,
ref: 'input',
onChange: e => {
this.onChange(e);
}
)}
<div ref="div"></div>
})}
<div ref="div" />
</div>

@@ -146,0 +162,0 @@ );

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc