react-google-places-autocomplete
Advanced tools
Comparing version 1.6.1 to 1.6.2
@@ -91,4 +91,5 @@ 'use strict'; | ||
}, { | ||
key: 'componentWillReceiveProps', | ||
value: function componentWillReceiveProps(nextProps) { | ||
key: 'UNSAFE_componentWillReceiveProps', | ||
value: function UNSAFE_componentWillReceiveProps(nextProps) { | ||
// eslint-disable-line | ||
if (nextProps.initialValue) { | ||
@@ -269,3 +270,3 @@ this.setState({ value: nextProps.initialValue }); | ||
'div', | ||
{ className: 'google-places-autcomplete__suggestions' }, | ||
{ className: 'google-places-autocomplete__suggestions' }, | ||
'Loading...' | ||
@@ -272,0 +273,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),u=(o=r)&&o.__esModule?o:{default:o},i=n(11);t.geocodeByAddress=i.geocodeByAddress,t.geocodeByPlaceId=i.geocodeByPlaceId,t.getLatLng=i.getLatLng,t.default=u.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}}(),u=n(3),i=f(u),a=f(n(0)),l=f(n(8)),s=f(n(9)),c=n(10);function f(e){return e&&e.__esModule?e:{default:e}}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,s.default)(function(e){var t=n.props.autocompletionRequest;n.setState({loading:!0}),n.placesService.getPlacePredictions(o({},(0,l.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,u.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){var t=this.props.idPrefix;e.target.id.includes(t+"-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.idPrefix,r=n.inputClassName,u=n.inputStyle,a=n.placeholder,l=n.renderInput,s=n.required,c=n.disabled;return l?l({autoComplete:"off",id:o+"-google-places-autocomplete-input",value:t,onChange:function(t){var n=t.target;return e.changeValue(n.value)},onKeyDown:this.handleKeyDown,type:"text",placeholder:a,required:s,disabled:c}):i.default.createElement("input",{autoComplete:"off",className:r||"google-places-autocomplete__input",id:o+"-google-places-autocomplete-input",onChange:function(t){var n=t.target;return e.changeValue(n.value)},onKeyDown:this.handleKeyDown,placeholder:a,style:u,type:"text",value:t,required:s,disabled:c})}},{key:"renderSuggestions",value:function(){var e=this,t=this.state,n=t.activeSuggestion,o=t.suggestions,r=this.props,u=r.idPrefix,a=r.renderSuggestions,l=r.suggestionsClassNames,s=r.suggestionsStyles;return 0===o.length?null:a?a(n,o,this.onSuggestionSelect):i.default.createElement("div",{id:u+"-google-places-suggestions-container",className:l.container||"google-places-autocomplete__suggestions-container",style:s.container},o.map(function(t,o){return i.default.createElement("div",{id:u+"-google-places-autocomplete-suggestion--"+o,key:t.id,className:(l.suggestion||"google-places-autocomplete__suggestion")+" "+(n===o?l.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||i.default.createElement("div",{className:"google-places-autocomplete__suggestions-container"},i.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 i.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,disabled:a.default.bool,idPrefix:a.default.string},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,disabled:!1,idPrefix:""},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),u=(o=r)&&o.__esModule?o:{default:o},i=n(11);t.geocodeByAddress=i.geocodeByAddress,t.geocodeByPlaceId=i.geocodeByPlaceId,t.getLatLng=i.getLatLng,t.default=u.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}}(),u=n(3),i=f(u),a=f(n(0)),l=f(n(8)),s=f(n(9)),c=n(10);function f(e){return e&&e.__esModule?e:{default:e}}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,s.default)(function(e){var t=n.props.autocompletionRequest;n.setState({loading:!0}),n.placesService.getPlacePredictions(o({},(0,l.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,u.Component),r(t,[{key:"componentDidMount",value:function(){this.initalizeService(),document.addEventListener("click",this.handleClick)}},{key:"componentWillUnmount",value:function(){document.removeEventListener("click",this.handleClick)}},{key:"UNSAFE_componentWillReceiveProps",value:function(e){e.initialValue&&this.setState({value:e.initialValue})}},{key:"handleClick",value:function(e){var t=this.props.idPrefix;e.target.id.includes(t+"-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.idPrefix,r=n.inputClassName,u=n.inputStyle,a=n.placeholder,l=n.renderInput,s=n.required,c=n.disabled;return l?l({autoComplete:"off",id:o+"-google-places-autocomplete-input",value:t,onChange:function(t){var n=t.target;return e.changeValue(n.value)},onKeyDown:this.handleKeyDown,type:"text",placeholder:a,required:s,disabled:c}):i.default.createElement("input",{autoComplete:"off",className:r||"google-places-autocomplete__input",id:o+"-google-places-autocomplete-input",onChange:function(t){var n=t.target;return e.changeValue(n.value)},onKeyDown:this.handleKeyDown,placeholder:a,style:u,type:"text",value:t,required:s,disabled:c})}},{key:"renderSuggestions",value:function(){var e=this,t=this.state,n=t.activeSuggestion,o=t.suggestions,r=this.props,u=r.idPrefix,a=r.renderSuggestions,l=r.suggestionsClassNames,s=r.suggestionsStyles;return 0===o.length?null:a?a(n,o,this.onSuggestionSelect):i.default.createElement("div",{id:u+"-google-places-suggestions-container",className:l.container||"google-places-autocomplete__suggestions-container",style:s.container},o.map(function(t,o){return i.default.createElement("div",{id:u+"-google-places-autocomplete-suggestion--"+o,key:t.id,className:(l.suggestion||"google-places-autocomplete__suggestion")+" "+(n===o?l.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||i.default.createElement("div",{className:"google-places-autocomplete__suggestions-container"},i.default.createElement("div",{className:"google-places-autocomplete__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 i.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,disabled:a.default.bool,idPrefix:a.default.string},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,disabled:!1,idPrefix:""},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),u=(o=r)&&o.__esModule?o:{default:o},i=n(11);t.geocodeByAddress=i.geocodeByAddress,t.geocodeByPlaceId=i.geocodeByPlaceId,t.getLatLng=i.getLatLng,t.default=u.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}}(),u=n(3),i=f(u),a=f(n(0)),l=f(n(8)),s=f(n(9)),c=n(10);function f(e){return e&&e.__esModule?e:{default:e}}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,s.default)(function(e){var t=n.props.autocompletionRequest;n.setState({loading:!0}),n.placesService.getPlacePredictions(o({},(0,l.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,u.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){var t=this.props.idPrefix;e.target.id.includes(t+"-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.idPrefix,r=n.inputClassName,u=n.inputStyle,a=n.placeholder,l=n.renderInput,s=n.required,c=n.disabled;return l?l({autoComplete:"off",id:o+"-google-places-autocomplete-input",value:t,onChange:function(t){var n=t.target;return e.changeValue(n.value)},onKeyDown:this.handleKeyDown,type:"text",placeholder:a,required:s,disabled:c}):i.default.createElement("input",{autoComplete:"off",className:r||"google-places-autocomplete__input",id:o+"-google-places-autocomplete-input",onChange:function(t){var n=t.target;return e.changeValue(n.value)},onKeyDown:this.handleKeyDown,placeholder:a,style:u,type:"text",value:t,required:s,disabled:c})}},{key:"renderSuggestions",value:function(){var e=this,t=this.state,n=t.activeSuggestion,o=t.suggestions,r=this.props,u=r.idPrefix,a=r.renderSuggestions,l=r.suggestionsClassNames,s=r.suggestionsStyles;return 0===o.length?null:a?a(n,o,this.onSuggestionSelect):i.default.createElement("div",{id:u+"-google-places-suggestions-container",className:l.container||"google-places-autocomplete__suggestions-container",style:s.container},o.map(function(t,o){return i.default.createElement("div",{id:u+"-google-places-autocomplete-suggestion--"+o,key:t.id,className:(l.suggestion||"google-places-autocomplete__suggestion")+" "+(n===o?l.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||i.default.createElement("div",{className:"google-places-autocomplete__suggestions-container"},i.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 i.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,disabled:a.default.bool,idPrefix:a.default.string},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,disabled:!1,idPrefix:""},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),u=(o=r)&&o.__esModule?o:{default:o},i=n(11);t.geocodeByAddress=i.geocodeByAddress,t.geocodeByPlaceId=i.geocodeByPlaceId,t.getLatLng=i.getLatLng,t.default=u.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}}(),u=n(3),i=f(u),a=f(n(0)),l=f(n(8)),s=f(n(9)),c=n(10);function f(e){return e&&e.__esModule?e:{default:e}}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,s.default)(function(e){var t=n.props.autocompletionRequest;n.setState({loading:!0}),n.placesService.getPlacePredictions(o({},(0,l.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,u.Component),r(t,[{key:"componentDidMount",value:function(){this.initalizeService(),document.addEventListener("click",this.handleClick)}},{key:"componentWillUnmount",value:function(){document.removeEventListener("click",this.handleClick)}},{key:"UNSAFE_componentWillReceiveProps",value:function(e){e.initialValue&&this.setState({value:e.initialValue})}},{key:"handleClick",value:function(e){var t=this.props.idPrefix;e.target.id.includes(t+"-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.idPrefix,r=n.inputClassName,u=n.inputStyle,a=n.placeholder,l=n.renderInput,s=n.required,c=n.disabled;return l?l({autoComplete:"off",id:o+"-google-places-autocomplete-input",value:t,onChange:function(t){var n=t.target;return e.changeValue(n.value)},onKeyDown:this.handleKeyDown,type:"text",placeholder:a,required:s,disabled:c}):i.default.createElement("input",{autoComplete:"off",className:r||"google-places-autocomplete__input",id:o+"-google-places-autocomplete-input",onChange:function(t){var n=t.target;return e.changeValue(n.value)},onKeyDown:this.handleKeyDown,placeholder:a,style:u,type:"text",value:t,required:s,disabled:c})}},{key:"renderSuggestions",value:function(){var e=this,t=this.state,n=t.activeSuggestion,o=t.suggestions,r=this.props,u=r.idPrefix,a=r.renderSuggestions,l=r.suggestionsClassNames,s=r.suggestionsStyles;return 0===o.length?null:a?a(n,o,this.onSuggestionSelect):i.default.createElement("div",{id:u+"-google-places-suggestions-container",className:l.container||"google-places-autocomplete__suggestions-container",style:s.container},o.map(function(t,o){return i.default.createElement("div",{id:u+"-google-places-autocomplete-suggestion--"+o,key:t.id,className:(l.suggestion||"google-places-autocomplete__suggestion")+" "+(n===o?l.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||i.default.createElement("div",{className:"google-places-autocomplete__suggestions-container"},i.default.createElement("div",{className:"google-places-autocomplete__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 i.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,disabled:a.default.bool,idPrefix:a.default.string},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,disabled:!1,idPrefix:""},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.6.1", | ||
"version": "1.6.2", | ||
"description": "Google places autocomplete input for ReactJS.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -57,3 +57,3 @@ import React, { Component } from 'react'; | ||
componentWillReceiveProps(nextProps) { | ||
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line | ||
if (nextProps.initialValue) { | ||
@@ -218,3 +218,3 @@ this.setState({ value: nextProps.initialValue }); | ||
<div className="google-places-autocomplete__suggestions-container"> | ||
<div className="google-places-autcomplete__suggestions"> | ||
<div className="google-places-autocomplete__suggestions"> | ||
Loading... | ||
@@ -221,0 +221,0 @@ </div> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
418009
1208