New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-google-places-autocomplete

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-google-places-autocomplete - npm Package Compare versions

Comparing version 1.5.1 to 1.5.2

2

dist/GooglePlacesAutocomplete/index.js

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

if (renderSuggestions) {
return renderSuggestions(activeSuggestion, suggestions, this.onSuggestionsSelect);
return renderSuggestions(activeSuggestion, suggestions, this.onSuggestionSelect);
}

@@ -221,0 +221,0 @@

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ReactGooglePlacesAutocomplete=t():e.ReactGooglePlacesAutocomplete=t()}(window,function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,n){e.exports=n(6)()},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getLatLng=t.geocodeByPlaceId=t.geocodeByAddress=void 0;var o,r=n(2),i=(o=r)&&o.__esModule?o:{default:o},u=n(16);t.geocodeByAddress=u.geocodeByAddress,t.geocodeByPlaceId=u.geocodeByPlaceId,t.getLatLng=u.getLatLng,t.default=i.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},r=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=n(3),u=f(i),a=f(n(0)),s=f(n(8)),l=f(n(9)),c=n(10);function f(e){return e&&e.__esModule?e:{default:e}}n(11);var p=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.fetchSuggestions=(0,l.default)(function(e){var t=n.props.autocompletionRequest;n.setState({loading:!0}),n.placesService.getPlacePredictions(o({},(0,s.default)(t),{input:e}),n.fetchSuggestionsCallback)},n.props.debounce),n.state={activeSuggestion:null,loading:!1,placesServiceStatus:null,suggestions:[],value:e.initialValue},n.changeActiveSuggestion=n.changeActiveSuggestion.bind(n),n.changeValue=n.changeValue.bind(n),n.clearSuggestions=n.clearSuggestions.bind(n),n.fetchSuggestionsCallback=n.fetchSuggestionsCallback.bind(n),n.handleClick=n.handleClick.bind(n),n.handleKeyDown=n.handleKeyDown.bind(n),n.initalizeService=n.initializeService.bind(n),n.onSuggestionSelect=n.onSuggestionSelect.bind(n),n.renderInput=n.renderInput.bind(n),n.renderSuggestions=n.renderSuggestions.bind(n),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.Component),r(t,[{key:"componentDidMount",value:function(){this.initalizeService(),document.addEventListener("click",this.handleClick)}},{key:"componentWillUnmount",value:function(){document.removeEventListener("click",this.handleClick)}},{key:"componentWillReceiveProps",value:function(e){e.initialValue&&this.setState({value:e.initialValue})}},{key:"handleClick",value:function(e){e.target.id.includes("google-places-autocomplete")||this.clearSuggestions()}},{key:"changeValue",value:function(e){this.setState({value:e}),e.length>0?this.fetchSuggestions(e):this.setState({suggestions:[]})}},{key:"initializeService",value:function(){var e=this;return window.google?window.google.maps?window.google.maps.places?(this.placesService=new window.google.maps.places.AutocompleteService,void this.setState({placesServiceStatus:window.google.maps.places.PlacesServiceStatus.OK})):(console.error("[react-google-places-autocomplete]: Google maps places script not loaded"),void setTimeout(function(){e.initializeService()},1e3)):(console.error("[react-google-places-autocomplete]: Google maps script not loaded"),void setTimeout(function(){e.initalizeService()},1e3)):(console.error("[react-google-places-autocomplete]: Google script not loaded"),void setTimeout(function(){e.initalizeService()},1e3))}},{key:"renderInput",value:function(){var e=this,t=this.state.value,n=this.props,o=n.inputClassName,r=n.inputStyle,i=n.placeholder,a=n.renderInput,s=n.required;return a?a({autoComplete:"off",id:"google-places-autocomplete-input",value:t,onChange:function(t){var n=t.target;return e.changeValue(n.value)},onKeyDown:this.handleKeyDown,type:"text",placeholder:i,required:s}):u.default.createElement("input",{autoComplete:"off",className:o||"google-places-autocomplete__input",id:"google-places-autocomplete-input",onChange:function(t){var n=t.target;return e.changeValue(n.value)},onKeyDown:this.handleKeyDown,placeholder:i,style:r,type:"text",value:t})}},{key:"renderSuggestions",value:function(){var e=this,t=this.state,n=t.activeSuggestion,o=t.suggestions,r=this.props,i=r.renderSuggestions,a=r.suggestionsClassNames,s=r.suggestionsStyles;return 0===o.length?null:i?i(n,o,this.onSuggestionsSelect):u.default.createElement("div",{id:"google-places-suggestions-container",className:a.container||"google-places-autocomplete__suggestions-container",style:s.container},o.map(function(t,o){return u.default.createElement("div",{id:"google-places-autocomplete-suggestion--"+o,key:t.id,className:(a.suggestion||"google-places-autocomplete__suggestion")+" "+(n===o?a.suggestionActive||"google-places-autocomplete__suggestion--active":""),style:s.suggestion,onClick:function(n){return e.onSuggestionSelect(t,n)},role:"presentation"},t.description)}))}},{key:"renderLoader",value:function(){var e=this.props.loader;return e||u.default.createElement("div",{className:"google-places-autocomplete__suggestions-container"},u.default.createElement("div",{className:"google-places-autcomplete__suggestions"},"Loading..."))}},{key:"onSuggestionSelect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;t&&t.stopPropagation();var n=this.props.onSelect;this.setState({activeSuggestion:null,suggestions:[],value:e.description}),n(e)}},{key:"fetchSuggestionsCallback",value:function(e,t){this.state.placesServiceStatus;this.setState({loading:!1,suggestions:e||[]})}},{key:"handleKeyDown",value:function(e){var t=this.state,n=t.activeSuggestion,o=t.suggestions;switch(e.key){case"Enter":e.preventDefault(),null!==n&&this.onSuggestionSelect(o[n]);break;case"ArrowDown":this.changeActiveSuggestion(1);break;case"ArrowUp":this.changeActiveSuggestion(-1);break;case"Escape":this.clearSuggestions()}}},{key:"clearSuggestions",value:function(){this.setState({activeSuggestion:null,suggestions:[]})}},{key:"changeActiveSuggestion",value:function(e){if(0!==this.state.suggestions.length)switch(e){case 1:this.setState(function(e){var t=e.activeSuggestion,n=e.suggestions;return null===t||t===n.length-1?{activeSuggestion:0}:{activeSuggestion:t+1}});break;case-1:this.setState(function(e){var t=e.activeSuggestion,n=e.suggestions;return t?{activeSuggestion:t-1}:{activeSuggestion:n.length-1}})}}},{key:"render",value:function(){var e=this.state.loading;return u.default.createElement("div",{className:"google-places-autocomplete"},this.renderInput(),e?this.renderLoader():this.renderSuggestions())}}]),t}();p.propTypes={autocompletionRequest:c.autocompletionRequestType,debounce:a.default.number,initialValue:a.default.string,inputClassName:a.default.string,inputStyle:a.default.object,loader:a.default.node,onSelect:a.default.func,placeholder:a.default.string,renderInput:a.default.func,renderSuggestions:a.default.func,suggestionsClassNames:c.suggestionClassNamesType,suggestionsStyles:c.suggestionStylesType,required:a.default.bool},p.defaultProps={autocompletionRequest:{},debounce:300,initialValue:"",inputClassName:"",inputStyle:{},loader:null,onSelect:function(){},placeholder:"Address",renderInput:void 0,renderSuggestions:void 0,suggestionsClassNames:{container:"",suggestion:"",suggestionActive:""},suggestionsStyles:{container:{},suggestion:{}},required:!1},t.default=p},function(e,t,n){"use strict";e.exports=n(4)},function(e,t,n){"use strict";
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ReactGooglePlacesAutocomplete=t():e.ReactGooglePlacesAutocomplete=t()}(window,function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,n){e.exports=n(6)()},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getLatLng=t.geocodeByPlaceId=t.geocodeByAddress=void 0;var o,r=n(2),i=(o=r)&&o.__esModule?o:{default:o},u=n(16);t.geocodeByAddress=u.geocodeByAddress,t.geocodeByPlaceId=u.geocodeByPlaceId,t.getLatLng=u.getLatLng,t.default=i.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},r=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=n(3),u=f(i),a=f(n(0)),s=f(n(8)),l=f(n(9)),c=n(10);function f(e){return e&&e.__esModule?e:{default:e}}n(11);var p=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.fetchSuggestions=(0,l.default)(function(e){var t=n.props.autocompletionRequest;n.setState({loading:!0}),n.placesService.getPlacePredictions(o({},(0,s.default)(t),{input:e}),n.fetchSuggestionsCallback)},n.props.debounce),n.state={activeSuggestion:null,loading:!1,placesServiceStatus:null,suggestions:[],value:e.initialValue},n.changeActiveSuggestion=n.changeActiveSuggestion.bind(n),n.changeValue=n.changeValue.bind(n),n.clearSuggestions=n.clearSuggestions.bind(n),n.fetchSuggestionsCallback=n.fetchSuggestionsCallback.bind(n),n.handleClick=n.handleClick.bind(n),n.handleKeyDown=n.handleKeyDown.bind(n),n.initalizeService=n.initializeService.bind(n),n.onSuggestionSelect=n.onSuggestionSelect.bind(n),n.renderInput=n.renderInput.bind(n),n.renderSuggestions=n.renderSuggestions.bind(n),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.Component),r(t,[{key:"componentDidMount",value:function(){this.initalizeService(),document.addEventListener("click",this.handleClick)}},{key:"componentWillUnmount",value:function(){document.removeEventListener("click",this.handleClick)}},{key:"componentWillReceiveProps",value:function(e){e.initialValue&&this.setState({value:e.initialValue})}},{key:"handleClick",value:function(e){e.target.id.includes("google-places-autocomplete")||this.clearSuggestions()}},{key:"changeValue",value:function(e){this.setState({value:e}),e.length>0?this.fetchSuggestions(e):this.setState({suggestions:[]})}},{key:"initializeService",value:function(){var e=this;return window.google?window.google.maps?window.google.maps.places?(this.placesService=new window.google.maps.places.AutocompleteService,void this.setState({placesServiceStatus:window.google.maps.places.PlacesServiceStatus.OK})):(console.error("[react-google-places-autocomplete]: Google maps places script not loaded"),void setTimeout(function(){e.initializeService()},1e3)):(console.error("[react-google-places-autocomplete]: Google maps script not loaded"),void setTimeout(function(){e.initalizeService()},1e3)):(console.error("[react-google-places-autocomplete]: Google script not loaded"),void setTimeout(function(){e.initalizeService()},1e3))}},{key:"renderInput",value:function(){var e=this,t=this.state.value,n=this.props,o=n.inputClassName,r=n.inputStyle,i=n.placeholder,a=n.renderInput,s=n.required;return a?a({autoComplete:"off",id:"google-places-autocomplete-input",value:t,onChange:function(t){var n=t.target;return e.changeValue(n.value)},onKeyDown:this.handleKeyDown,type:"text",placeholder:i,required:s}):u.default.createElement("input",{autoComplete:"off",className:o||"google-places-autocomplete__input",id:"google-places-autocomplete-input",onChange:function(t){var n=t.target;return e.changeValue(n.value)},onKeyDown:this.handleKeyDown,placeholder:i,style:r,type:"text",value:t})}},{key:"renderSuggestions",value:function(){var e=this,t=this.state,n=t.activeSuggestion,o=t.suggestions,r=this.props,i=r.renderSuggestions,a=r.suggestionsClassNames,s=r.suggestionsStyles;return 0===o.length?null:i?i(n,o,this.onSuggestionSelect):u.default.createElement("div",{id:"google-places-suggestions-container",className:a.container||"google-places-autocomplete__suggestions-container",style:s.container},o.map(function(t,o){return u.default.createElement("div",{id:"google-places-autocomplete-suggestion--"+o,key:t.id,className:(a.suggestion||"google-places-autocomplete__suggestion")+" "+(n===o?a.suggestionActive||"google-places-autocomplete__suggestion--active":""),style:s.suggestion,onClick:function(n){return e.onSuggestionSelect(t,n)},role:"presentation"},t.description)}))}},{key:"renderLoader",value:function(){var e=this.props.loader;return e||u.default.createElement("div",{className:"google-places-autocomplete__suggestions-container"},u.default.createElement("div",{className:"google-places-autcomplete__suggestions"},"Loading..."))}},{key:"onSuggestionSelect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;t&&t.stopPropagation();var n=this.props.onSelect;this.setState({activeSuggestion:null,suggestions:[],value:e.description}),n(e)}},{key:"fetchSuggestionsCallback",value:function(e,t){this.state.placesServiceStatus;this.setState({loading:!1,suggestions:e||[]})}},{key:"handleKeyDown",value:function(e){var t=this.state,n=t.activeSuggestion,o=t.suggestions;switch(e.key){case"Enter":e.preventDefault(),null!==n&&this.onSuggestionSelect(o[n]);break;case"ArrowDown":this.changeActiveSuggestion(1);break;case"ArrowUp":this.changeActiveSuggestion(-1);break;case"Escape":this.clearSuggestions()}}},{key:"clearSuggestions",value:function(){this.setState({activeSuggestion:null,suggestions:[]})}},{key:"changeActiveSuggestion",value:function(e){if(0!==this.state.suggestions.length)switch(e){case 1:this.setState(function(e){var t=e.activeSuggestion,n=e.suggestions;return null===t||t===n.length-1?{activeSuggestion:0}:{activeSuggestion:t+1}});break;case-1:this.setState(function(e){var t=e.activeSuggestion,n=e.suggestions;return t?{activeSuggestion:t-1}:{activeSuggestion:n.length-1}})}}},{key:"render",value:function(){var e=this.state.loading;return u.default.createElement("div",{className:"google-places-autocomplete"},this.renderInput(),e?this.renderLoader():this.renderSuggestions())}}]),t}();p.propTypes={autocompletionRequest:c.autocompletionRequestType,debounce:a.default.number,initialValue:a.default.string,inputClassName:a.default.string,inputStyle:a.default.object,loader:a.default.node,onSelect:a.default.func,placeholder:a.default.string,renderInput:a.default.func,renderSuggestions:a.default.func,suggestionsClassNames:c.suggestionClassNamesType,suggestionsStyles:c.suggestionStylesType,required:a.default.bool},p.defaultProps={autocompletionRequest:{},debounce:300,initialValue:"",inputClassName:"",inputStyle:{},loader:null,onSelect:function(){},placeholder:"Address",renderInput:void 0,renderSuggestions:void 0,suggestionsClassNames:{container:"",suggestion:"",suggestionActive:""},suggestionsStyles:{container:{},suggestion:{}},required:!1},t.default=p},function(e,t,n){"use strict";e.exports=n(4)},function(e,t,n){"use strict";
/** @license React v16.8.6

@@ -3,0 +3,0 @@ * react.production.min.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ReactGooglePlacesAutocomplete=t():e.ReactGooglePlacesAutocomplete=t()}(window,function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,n){e.exports=n(6)()},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getLatLng=t.geocodeByPlaceId=t.geocodeByAddress=void 0;var o,r=n(2),i=(o=r)&&o.__esModule?o:{default:o},u=n(16);t.geocodeByAddress=u.geocodeByAddress,t.geocodeByPlaceId=u.geocodeByPlaceId,t.getLatLng=u.getLatLng,t.default=i.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},r=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=n(3),u=f(i),a=f(n(0)),s=f(n(8)),l=f(n(9)),c=n(10);function f(e){return e&&e.__esModule?e:{default:e}}n(11);var p=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.fetchSuggestions=(0,l.default)(function(e){var t=n.props.autocompletionRequest;n.setState({loading:!0}),n.placesService.getPlacePredictions(o({},(0,s.default)(t),{input:e}),n.fetchSuggestionsCallback)},n.props.debounce),n.state={activeSuggestion:null,loading:!1,placesServiceStatus:null,suggestions:[],value:e.initialValue},n.changeActiveSuggestion=n.changeActiveSuggestion.bind(n),n.changeValue=n.changeValue.bind(n),n.clearSuggestions=n.clearSuggestions.bind(n),n.fetchSuggestionsCallback=n.fetchSuggestionsCallback.bind(n),n.handleClick=n.handleClick.bind(n),n.handleKeyDown=n.handleKeyDown.bind(n),n.initalizeService=n.initializeService.bind(n),n.onSuggestionSelect=n.onSuggestionSelect.bind(n),n.renderInput=n.renderInput.bind(n),n.renderSuggestions=n.renderSuggestions.bind(n),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.Component),r(t,[{key:"componentDidMount",value:function(){this.initalizeService(),document.addEventListener("click",this.handleClick)}},{key:"componentWillUnmount",value:function(){document.removeEventListener("click",this.handleClick)}},{key:"componentWillReceiveProps",value:function(e){e.initialValue&&this.setState({value:e.initialValue})}},{key:"handleClick",value:function(e){e.target.id.includes("google-places-autocomplete")||this.clearSuggestions()}},{key:"changeValue",value:function(e){this.setState({value:e}),e.length>0?this.fetchSuggestions(e):this.setState({suggestions:[]})}},{key:"initializeService",value:function(){var e=this;return window.google?window.google.maps?window.google.maps.places?(this.placesService=new window.google.maps.places.AutocompleteService,void this.setState({placesServiceStatus:window.google.maps.places.PlacesServiceStatus.OK})):(console.error("[react-google-places-autocomplete]: Google maps places script not loaded"),void setTimeout(function(){e.initializeService()},1e3)):(console.error("[react-google-places-autocomplete]: Google maps script not loaded"),void setTimeout(function(){e.initalizeService()},1e3)):(console.error("[react-google-places-autocomplete]: Google script not loaded"),void setTimeout(function(){e.initalizeService()},1e3))}},{key:"renderInput",value:function(){var e=this,t=this.state.value,n=this.props,o=n.inputClassName,r=n.inputStyle,i=n.placeholder,a=n.renderInput,s=n.required;return a?a({autoComplete:"off",id:"google-places-autocomplete-input",value:t,onChange:function(t){var n=t.target;return e.changeValue(n.value)},onKeyDown:this.handleKeyDown,type:"text",placeholder:i,required:s}):u.default.createElement("input",{autoComplete:"off",className:o||"google-places-autocomplete__input",id:"google-places-autocomplete-input",onChange:function(t){var n=t.target;return e.changeValue(n.value)},onKeyDown:this.handleKeyDown,placeholder:i,style:r,type:"text",value:t})}},{key:"renderSuggestions",value:function(){var e=this,t=this.state,n=t.activeSuggestion,o=t.suggestions,r=this.props,i=r.renderSuggestions,a=r.suggestionsClassNames,s=r.suggestionsStyles;return 0===o.length?null:i?i(n,o,this.onSuggestionsSelect):u.default.createElement("div",{id:"google-places-suggestions-container",className:a.container||"google-places-autocomplete__suggestions-container",style:s.container},o.map(function(t,o){return u.default.createElement("div",{id:"google-places-autocomplete-suggestion--"+o,key:t.id,className:(a.suggestion||"google-places-autocomplete__suggestion")+" "+(n===o?a.suggestionActive||"google-places-autocomplete__suggestion--active":""),style:s.suggestion,onClick:function(n){return e.onSuggestionSelect(t,n)},role:"presentation"},t.description)}))}},{key:"renderLoader",value:function(){var e=this.props.loader;return e||u.default.createElement("div",{className:"google-places-autocomplete__suggestions-container"},u.default.createElement("div",{className:"google-places-autcomplete__suggestions"},"Loading..."))}},{key:"onSuggestionSelect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;t&&t.stopPropagation();var n=this.props.onSelect;this.setState({activeSuggestion:null,suggestions:[],value:e.description}),n(e)}},{key:"fetchSuggestionsCallback",value:function(e,t){this.state.placesServiceStatus;this.setState({loading:!1,suggestions:e||[]})}},{key:"handleKeyDown",value:function(e){var t=this.state,n=t.activeSuggestion,o=t.suggestions;switch(e.key){case"Enter":e.preventDefault(),null!==n&&this.onSuggestionSelect(o[n]);break;case"ArrowDown":this.changeActiveSuggestion(1);break;case"ArrowUp":this.changeActiveSuggestion(-1);break;case"Escape":this.clearSuggestions()}}},{key:"clearSuggestions",value:function(){this.setState({activeSuggestion:null,suggestions:[]})}},{key:"changeActiveSuggestion",value:function(e){if(0!==this.state.suggestions.length)switch(e){case 1:this.setState(function(e){var t=e.activeSuggestion,n=e.suggestions;return null===t||t===n.length-1?{activeSuggestion:0}:{activeSuggestion:t+1}});break;case-1:this.setState(function(e){var t=e.activeSuggestion,n=e.suggestions;return t?{activeSuggestion:t-1}:{activeSuggestion:n.length-1}})}}},{key:"render",value:function(){var e=this.state.loading;return u.default.createElement("div",{className:"google-places-autocomplete"},this.renderInput(),e?this.renderLoader():this.renderSuggestions())}}]),t}();p.propTypes={autocompletionRequest:c.autocompletionRequestType,debounce:a.default.number,initialValue:a.default.string,inputClassName:a.default.string,inputStyle:a.default.object,loader:a.default.node,onSelect:a.default.func,placeholder:a.default.string,renderInput:a.default.func,renderSuggestions:a.default.func,suggestionsClassNames:c.suggestionClassNamesType,suggestionsStyles:c.suggestionStylesType,required:a.default.bool},p.defaultProps={autocompletionRequest:{},debounce:300,initialValue:"",inputClassName:"",inputStyle:{},loader:null,onSelect:function(){},placeholder:"Address",renderInput:void 0,renderSuggestions:void 0,suggestionsClassNames:{container:"",suggestion:"",suggestionActive:""},suggestionsStyles:{container:{},suggestion:{}},required:!1},t.default=p},function(e,t,n){"use strict";e.exports=n(4)},function(e,t,n){"use strict";
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ReactGooglePlacesAutocomplete=t():e.ReactGooglePlacesAutocomplete=t()}(window,function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,n){e.exports=n(6)()},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getLatLng=t.geocodeByPlaceId=t.geocodeByAddress=void 0;var o,r=n(2),i=(o=r)&&o.__esModule?o:{default:o},u=n(16);t.geocodeByAddress=u.geocodeByAddress,t.geocodeByPlaceId=u.geocodeByPlaceId,t.getLatLng=u.getLatLng,t.default=i.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},r=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=n(3),u=f(i),a=f(n(0)),s=f(n(8)),l=f(n(9)),c=n(10);function f(e){return e&&e.__esModule?e:{default:e}}n(11);var p=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.fetchSuggestions=(0,l.default)(function(e){var t=n.props.autocompletionRequest;n.setState({loading:!0}),n.placesService.getPlacePredictions(o({},(0,s.default)(t),{input:e}),n.fetchSuggestionsCallback)},n.props.debounce),n.state={activeSuggestion:null,loading:!1,placesServiceStatus:null,suggestions:[],value:e.initialValue},n.changeActiveSuggestion=n.changeActiveSuggestion.bind(n),n.changeValue=n.changeValue.bind(n),n.clearSuggestions=n.clearSuggestions.bind(n),n.fetchSuggestionsCallback=n.fetchSuggestionsCallback.bind(n),n.handleClick=n.handleClick.bind(n),n.handleKeyDown=n.handleKeyDown.bind(n),n.initalizeService=n.initializeService.bind(n),n.onSuggestionSelect=n.onSuggestionSelect.bind(n),n.renderInput=n.renderInput.bind(n),n.renderSuggestions=n.renderSuggestions.bind(n),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.Component),r(t,[{key:"componentDidMount",value:function(){this.initalizeService(),document.addEventListener("click",this.handleClick)}},{key:"componentWillUnmount",value:function(){document.removeEventListener("click",this.handleClick)}},{key:"componentWillReceiveProps",value:function(e){e.initialValue&&this.setState({value:e.initialValue})}},{key:"handleClick",value:function(e){e.target.id.includes("google-places-autocomplete")||this.clearSuggestions()}},{key:"changeValue",value:function(e){this.setState({value:e}),e.length>0?this.fetchSuggestions(e):this.setState({suggestions:[]})}},{key:"initializeService",value:function(){var e=this;return window.google?window.google.maps?window.google.maps.places?(this.placesService=new window.google.maps.places.AutocompleteService,void this.setState({placesServiceStatus:window.google.maps.places.PlacesServiceStatus.OK})):(console.error("[react-google-places-autocomplete]: Google maps places script not loaded"),void setTimeout(function(){e.initializeService()},1e3)):(console.error("[react-google-places-autocomplete]: Google maps script not loaded"),void setTimeout(function(){e.initalizeService()},1e3)):(console.error("[react-google-places-autocomplete]: Google script not loaded"),void setTimeout(function(){e.initalizeService()},1e3))}},{key:"renderInput",value:function(){var e=this,t=this.state.value,n=this.props,o=n.inputClassName,r=n.inputStyle,i=n.placeholder,a=n.renderInput,s=n.required;return a?a({autoComplete:"off",id:"google-places-autocomplete-input",value:t,onChange:function(t){var n=t.target;return e.changeValue(n.value)},onKeyDown:this.handleKeyDown,type:"text",placeholder:i,required:s}):u.default.createElement("input",{autoComplete:"off",className:o||"google-places-autocomplete__input",id:"google-places-autocomplete-input",onChange:function(t){var n=t.target;return e.changeValue(n.value)},onKeyDown:this.handleKeyDown,placeholder:i,style:r,type:"text",value:t})}},{key:"renderSuggestions",value:function(){var e=this,t=this.state,n=t.activeSuggestion,o=t.suggestions,r=this.props,i=r.renderSuggestions,a=r.suggestionsClassNames,s=r.suggestionsStyles;return 0===o.length?null:i?i(n,o,this.onSuggestionSelect):u.default.createElement("div",{id:"google-places-suggestions-container",className:a.container||"google-places-autocomplete__suggestions-container",style:s.container},o.map(function(t,o){return u.default.createElement("div",{id:"google-places-autocomplete-suggestion--"+o,key:t.id,className:(a.suggestion||"google-places-autocomplete__suggestion")+" "+(n===o?a.suggestionActive||"google-places-autocomplete__suggestion--active":""),style:s.suggestion,onClick:function(n){return e.onSuggestionSelect(t,n)},role:"presentation"},t.description)}))}},{key:"renderLoader",value:function(){var e=this.props.loader;return e||u.default.createElement("div",{className:"google-places-autocomplete__suggestions-container"},u.default.createElement("div",{className:"google-places-autcomplete__suggestions"},"Loading..."))}},{key:"onSuggestionSelect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;t&&t.stopPropagation();var n=this.props.onSelect;this.setState({activeSuggestion:null,suggestions:[],value:e.description}),n(e)}},{key:"fetchSuggestionsCallback",value:function(e,t){this.state.placesServiceStatus;this.setState({loading:!1,suggestions:e||[]})}},{key:"handleKeyDown",value:function(e){var t=this.state,n=t.activeSuggestion,o=t.suggestions;switch(e.key){case"Enter":e.preventDefault(),null!==n&&this.onSuggestionSelect(o[n]);break;case"ArrowDown":this.changeActiveSuggestion(1);break;case"ArrowUp":this.changeActiveSuggestion(-1);break;case"Escape":this.clearSuggestions()}}},{key:"clearSuggestions",value:function(){this.setState({activeSuggestion:null,suggestions:[]})}},{key:"changeActiveSuggestion",value:function(e){if(0!==this.state.suggestions.length)switch(e){case 1:this.setState(function(e){var t=e.activeSuggestion,n=e.suggestions;return null===t||t===n.length-1?{activeSuggestion:0}:{activeSuggestion:t+1}});break;case-1:this.setState(function(e){var t=e.activeSuggestion,n=e.suggestions;return t?{activeSuggestion:t-1}:{activeSuggestion:n.length-1}})}}},{key:"render",value:function(){var e=this.state.loading;return u.default.createElement("div",{className:"google-places-autocomplete"},this.renderInput(),e?this.renderLoader():this.renderSuggestions())}}]),t}();p.propTypes={autocompletionRequest:c.autocompletionRequestType,debounce:a.default.number,initialValue:a.default.string,inputClassName:a.default.string,inputStyle:a.default.object,loader:a.default.node,onSelect:a.default.func,placeholder:a.default.string,renderInput:a.default.func,renderSuggestions:a.default.func,suggestionsClassNames:c.suggestionClassNamesType,suggestionsStyles:c.suggestionStylesType,required:a.default.bool},p.defaultProps={autocompletionRequest:{},debounce:300,initialValue:"",inputClassName:"",inputStyle:{},loader:null,onSelect:function(){},placeholder:"Address",renderInput:void 0,renderSuggestions:void 0,suggestionsClassNames:{container:"",suggestion:"",suggestionActive:""},suggestionsStyles:{container:{},suggestion:{}},required:!1},t.default=p},function(e,t,n){"use strict";e.exports=n(4)},function(e,t,n){"use strict";
/** @license React v16.8.6

@@ -3,0 +3,0 @@ * react.production.min.js

{
"name": "react-google-places-autocomplete",
"version": "1.5.1",
"version": "1.5.2",
"description": "Google places autocomplete input for ReactJS.",

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

@@ -171,3 +171,3 @@ import React, { Component } from 'react';

suggestions,
this.onSuggestionsSelect,
this.onSuggestionSelect,
);

@@ -174,0 +174,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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