react-geosuggest
Advanced tools
Comparing version 1.13.0 to 1.14.0
@@ -0,1 +1,13 @@ | ||
## 1.14.0 (2016-01-04) | ||
#### Bug Fixes | ||
* check whether component is still mounted after timeout ([67972d08](https://github.com/ubilabs/react-geosuggest/commit/67972d08ee24e77605ead13d23025854683454ef), closes [#71](https://github.com/ubilabs/react-geosuggest/issues/71)) | ||
* "use strict"; no longer throws errors if google cannot be loaded ([d8c97c0](https://github.com/ubilabs/react-geosuggest/commit/d8c97c0e1d023a31c4545fff24ff0a1e7b18c2b6)) | ||
#### Features | ||
* Add property for input class name. ([c43b91a](https://github.com/ubilabs/react-geosuggest/commit/c43b91aa597d7d9685be994a431e54529464cabe)) | ||
## 1.13.0 (2015-10-29) | ||
@@ -2,0 +14,0 @@ |
@@ -1,2 +0,2 @@ | ||
/* global google */ | ||
/* global window */ | ||
@@ -31,2 +31,3 @@ 'use strict'; | ||
className: '', | ||
inputClassName: '', | ||
location: null, | ||
@@ -56,2 +57,3 @@ radius: null, | ||
return { | ||
isMounted: false, | ||
isSuggestsHidden: true, | ||
@@ -82,15 +84,26 @@ userInput: this.props.initialValue, | ||
var googleMaps = this.props.googleMaps || google && google.maps || this.googleMaps; | ||
var googleMaps = this.props.googleMaps || window.google && // eslint-disable-line no-extra-parens | ||
window.google.maps || this.googleMaps; | ||
if (!googleMaps) { | ||
console.error('Google map api was not found in the page.'); | ||
} else { | ||
this.googleMaps = googleMaps; | ||
console.error( // eslint-disable-line no-console | ||
'Google map api was not found in the page.'); | ||
return; | ||
} | ||
this.googleMaps = googleMaps; | ||
this.autocompleteService = new googleMaps.places.AutocompleteService(); | ||
this.geocoder = new googleMaps.Geocoder(); | ||
this.setState({ isMounted: true }); | ||
}, | ||
/** | ||
* When the component will unmount | ||
*/ | ||
componentWillUnmount: function componentWillUnmount() { | ||
this.setState({ isMounted: false }); | ||
}, | ||
/** | ||
* Method used for setting initial value. | ||
@@ -100,5 +113,3 @@ * @param {string} value to set in input | ||
setInputValue: function setInputValue(value) { | ||
this.setState({ | ||
userInput: value | ||
}); | ||
this.setState({ userInput: value }); | ||
}, | ||
@@ -110,8 +121,10 @@ | ||
onInputChange: function onInputChange() { | ||
var _this = this; | ||
var userInput = this.refs.geosuggestInput.value; | ||
this.setState({ userInput: userInput }, (function () { | ||
this.showSuggests(); | ||
this.props.onChange(userInput); | ||
}).bind(this)); | ||
this.setState({ userInput: userInput }, function () { | ||
_this.showSuggests(); | ||
_this.props.onChange(userInput); | ||
}); | ||
}, | ||
@@ -140,5 +153,7 @@ | ||
clear: function clear() { | ||
this.setState({ userInput: '' }, (function () { | ||
this.hideSuggests(); | ||
}).bind(this)); | ||
var _this2 = this; | ||
this.setState({ userInput: '' }, function () { | ||
return _this2.hideSuggests(); | ||
}); | ||
}, | ||
@@ -150,2 +165,4 @@ | ||
searchSuggests: function searchSuggests() { | ||
var _this3 = this; | ||
if (!this.state.userInput) { | ||
@@ -182,9 +199,9 @@ this.updateSuggests(); | ||
this.autocompleteService.getPlacePredictions(options, (function (suggestsGoogle) { | ||
this.updateSuggests(suggestsGoogle); | ||
this.autocompleteService.getPlacePredictions(options, function (suggestsGoogle) { | ||
_this3.updateSuggests(suggestsGoogle); | ||
if (this.props.autoActivateFirstSuggest) { | ||
this.activateSuggest('next'); | ||
if (_this3.props.autoActivateFirstSuggest) { | ||
_this3.activateSuggest('next'); | ||
} | ||
}).bind(this)); | ||
}); | ||
}, | ||
@@ -197,3 +214,3 @@ | ||
updateSuggests: function updateSuggests(suggestsGoogle) { | ||
var _this = this; | ||
var _this4 = this; | ||
@@ -218,3 +235,3 @@ if (!suggestsGoogle) { | ||
suggests.push({ | ||
label: _this.props.getSuggestLabel(suggest), | ||
label: _this4.props.getSuggestLabel(suggest), | ||
placeId: suggest.place_id | ||
@@ -240,6 +257,10 @@ }); | ||
hideSuggests: function hideSuggests() { | ||
var _this5 = this; | ||
this.props.onBlur(); | ||
setTimeout((function () { | ||
this.setState({ isSuggestsHidden: true }); | ||
}).bind(this), 100); | ||
setTimeout(function () { | ||
if (_this5.state && _this5.state.isMounted) { | ||
_this5.setState({ isSuggestsHidden: true }); | ||
} | ||
}, 100); | ||
}, | ||
@@ -286,2 +307,3 @@ | ||
activateSuggest: function activateSuggest(direction) { | ||
// eslint-disable-line complexity | ||
if (this.state.isSuggestsHidden) { | ||
@@ -344,4 +366,6 @@ this.showSuggests(); | ||
geocodeSuggest: function geocodeSuggest(suggest) { | ||
this.geocoder.geocode({ address: suggest.label }, (function (results, status) { | ||
if (status !== this.googleMaps.GeocoderStatus.OK) { | ||
var _this6 = this; | ||
this.geocoder.geocode({ address: suggest.label }, function (results, status) { | ||
if (status !== _this6.googleMaps.GeocoderStatus.OK) { | ||
return; | ||
@@ -359,4 +383,4 @@ } | ||
this.props.onSuggestSelect(suggest); | ||
}).bind(this)); | ||
_this6.props.onSuggestSelect(suggest); | ||
}); | ||
}, | ||
@@ -375,3 +399,3 @@ | ||
_react2['default'].createElement('input', { | ||
className: 'geosuggest__input', | ||
className: 'geosuggest__input ' + this.props.inputClassName, | ||
ref: 'geosuggestInput', | ||
@@ -378,0 +402,0 @@ type: 'text', |
{ | ||
"name": "react-geosuggest", | ||
"version": "1.13.0", | ||
"version": "1.14.0", | ||
"description": "A React autosuggest for the Google Maps Places API.", | ||
@@ -5,0 +5,0 @@ "main": "module/Geosuggest.js", |
@@ -68,2 +68,8 @@ # React Geosuggest [![Build Status](https://travis-ci.org/ubilabs/react-geosuggest.svg?branch=master)](https://travis-ci.org/ubilabs/react-geosuggest) | ||
#### inputClassName | ||
Type: `String` | ||
Default: `''` | ||
Add an additional class to the input. | ||
#### disabled | ||
@@ -70,0 +76,0 @@ Type: `Boolean` |
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
36553
487
270