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

react-geosuggest

Package Overview
Dependencies
Maintainers
3
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-geosuggest - npm Package Compare versions

Comparing version 1.24.0 to 1.24.1

.nyc_output/31919.json

8

CHANGELOG.md

@@ -0,1 +1,9 @@

### 1.24.1 (2016-06-21)
#### Bug Fixes
* **Geosuggest:** fix server side rendering ([428dedd8](https://github.com/ubilabs/react-geosuggest/commit/428dedd81687a613085db52e35cae14bf2dd19f4), closes [#172](https://github.com/ubilabs/react-geosuggest/issues/172))
## 1.24.0 (2016-06-21)

@@ -2,0 +10,0 @@

4

dist/react-geosuggest.js

@@ -732,2 +732,6 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Geosuggest = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

value: function componentWillMount() {
if (typeof window === 'undefined') {
return;
}
var googleMaps = this.props.googleMaps || window.google && // eslint-disable-line no-extra-parens

@@ -734,0 +738,0 @@ window.google.maps || this.googleMaps;

2

dist/react-geosuggest.min.js

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

!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Geosuggest=e()}}(function(){var e;return function t(e,n,o){function s(r,a){if(!n[r]){if(!e[r]){var i="function"==typeof require&&require;if(!a&&i)return i(r,!0);if(u)return u(r,!0);var l=new Error("Cannot find module '"+r+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[r]={exports:{}};e[r][0].call(c.exports,function(t){var n=e[r][1][t];return s(n?n:t)},c,c.exports,t,e,n,o)}return n[r].exports}for(var u="function"==typeof require&&require,r=0;r<o.length;r++)s(o[r]);return s}({1:[function(t,n){!function(){"use strict";function t(){for(var e=[],n=0;n<arguments.length;n++){var s=arguments[n];if(s){var u=typeof s;if("string"===u||"number"===u)e.push(s);else if(Array.isArray(s))e.push(t.apply(null,s));else if("object"===u)for(var r in s)o.call(s,r)&&s[r]&&e.push(r)}}return e.join(" ")}var o={}.hasOwnProperty;"undefined"!=typeof n&&n.exports?n.exports=t:"function"==typeof e&&"object"==typeof e.amd&&e.amd?e("classnames",[],function(){return t}):window.classNames=t}()},{}],2:[function(e,t){"use strict";function n(e,t){return e===t?0!==e||1/e===1/t:e!==e&&t!==t}function o(e,t){if(n(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var o=Object.keys(e),u=Object.keys(t);if(o.length!==u.length)return!1;for(var r=0;r<o.length;r++)if(!s.call(t,o[r])||!n(e[o[r]],t[o[r]]))return!1;return!0}var s=Object.prototype.hasOwnProperty;t.exports=o},{}],3:[function(e,t){function n(e,t,n){function o(t){var n=h,o=y;return h=y=void 0,j=t,m=e.apply(o,n)}function u(e){return j=e,b=setTimeout(c,t),T?o(e):m}function r(e){var n=e-P,o=e-j,s=t-n;return _?w(s,v-o):s}function l(e){var n=e-P,o=e-j;return!P||n>=t||0>n||_&&o>=v}function c(){var e=O();return l(e)?p(e):void(b=setTimeout(c,r(e)))}function p(e){return clearTimeout(b),b=void 0,I&&h?o(e):(h=y=void 0,m)}function f(){void 0!==b&&clearTimeout(b),P=j=0,h=y=b=void 0}function g(){return void 0===b?m:p(O())}function d(){var e=O(),n=l(e);if(h=arguments,y=this,P=e,n){if(void 0===b)return u(P);if(_)return clearTimeout(b),b=setTimeout(c,t),o(P)}return void 0===b&&(b=setTimeout(c,t)),m}var h,y,v,m,b,P=0,j=0,T=!1,_=!1,I=!0;if("function"!=typeof e)throw new TypeError(i);return t=a(t)||0,s(n)&&(T=!!n.leading,_="maxWait"in n,v=_?S(a(n.maxWait)||0,t):v,I="trailing"in n?!!n.trailing:I),d.cancel=f,d.flush=g,d}function o(e){var t=s(e)?b.call(e):"";return t==c||t==p}function s(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function u(e){return!!e&&"object"==typeof e}function r(e){return"symbol"==typeof e||u(e)&&b.call(e)==f}function a(e){if("number"==typeof e)return e;if(r(e))return l;if(s(e)){var t=o(e.valueOf)?e.valueOf():e;e=s(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(g,"");var n=h.test(e);return n||y.test(e)?v(e.slice(2),n?2:8):d.test(e)?l:+e}var i="Expected a function",l=0/0,c="[object Function]",p="[object GeneratorFunction]",f="[object Symbol]",g=/^\s+|\s+$/g,d=/^[-+]0x[0-9a-f]+$/i,h=/^0b[01]+$/i,y=/^0o[0-7]+$/i,v=parseInt,m=Object.prototype,b=m.toString,S=Math.max,w=Math.min,O=Date.now;t.exports=n},{}],4:[function(e,t){t.exports=e("react/lib/shallowCompare")},{"react/lib/shallowCompare":5}],5:[function(e,t){"use strict";function n(e,t,n){return!o(e.props,t)||!o(e.state,n)}var o=e("fbjs/lib/shallowEqual");t.exports=n},{"fbjs/lib/shallowEqual":2}],6:[function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(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}function r(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)}function a(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}Object.defineProperty(n,"__esModule",{value:!0});var i=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},l=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}}(),c=window.React,p=o(c),f=e("classnames"),g=o(f),d=e("lodash.debounce"),h=o(d),y=e("./defaults"),v=o(y),m=e("./prop-types"),b=o(m),S=e("./filter-input-attributes"),w=o(S),O=e("./input"),P=o(O),j=e("./suggest-list"),T=o(j),_=function(e){function t(e){s(this,t);var n=u(this,Object.getPrototypeOf(t).call(this,e));return n.onInputChange=function(e){n.setState({userInput:e},n.onAfterInputChange)},n.onAfterInputChange=function(){n.showSuggests(),n.props.onChange(n.state.userInput)},n.onInputFocus=function(){n.props.onFocus(),n.showSuggests()},n.onInputBlur=function(){n.state.ignoreBlur||n.hideSuggests()},n.onNext=function(){return n.activateSuggest("next")},n.onPrev=function(){return n.activateSuggest("prev")},n.onSelect=function(){return n.selectSuggest(n.state.activeSuggest)},n.onSuggestMouseDown=function(){return n.setState({ignoreBlur:!0})},n.onSuggestMouseOut=function(){return n.setState({ignoreBlur:!1})},n.onSuggestNoResults=function(){n.props.onSuggestNoResults(n.state.userInput)},n.hideSuggests=function(){n.props.onBlur(n.state.userInput);var e=setTimeout(function(){n.setState({isSuggestsHidden:!0,activeSuggest:null})},100);n.setState({timer:e})},n.selectSuggest=function(e){return e||(e={label:n.state.userInput}),n.setState({isSuggestsHidden:!0,userInput:e.label}),e.location?(n.setState({ignoreBlur:!1}),void n.props.onSuggestSelect(e)):void n.geocodeSuggest(e)},n.state={isSuggestsHidden:!0,userInput:e.initialValue,activeSuggest:null,suggests:[],timer:null},n.onInputChange=n.onInputChange.bind(n),n.onAfterInputChange=n.onAfterInputChange.bind(n),e.queryDelay&&(n.onAfterInputChange=h["default"](n.onAfterInputChange,e.queryDelay)),n}return r(t,e),l(t,[{key:"componentWillReceiveProps",value:function(e){this.props.initialValue!==e.initialValue&&this.setState({userInput:e.initialValue})}},{key:"componentWillMount",value:function(){var e=this.props.googleMaps||window.google&&window.google.maps||this.googleMaps;e&&(this.googleMaps=e,this.autocompleteService=new e.places.AutocompleteService,this.geocoder=new e.Geocoder)}},{key:"componentWillUnmount",value:function(){clearTimeout(this.state.timer)}},{key:"focus",value:function(){this.refs.input.focus()}},{key:"update",value:function(e){this.setState({userInput:e}),this.props.onChange(e)}},{key:"clear",value:function(){this.setState({userInput:""},this.hideSuggests)}},{key:"searchSuggests",value:function(){var e=this;if(!this.state.userInput)return void this.updateSuggests();var t={input:this.state.userInput};["location","radius","bounds","types"].forEach(function(n){e.props[n]&&(t[n]=e.props[n])}),this.props.country&&(t.componentRestrictions={country:this.props.country}),this.autocompleteService.getPlacePredictions(t,function(t){e.updateSuggests(t||[],function(){e.props.autoActivateFirstSuggest&&!e.state.activeSuggest&&e.activateSuggest("next")})})}},{key:"updateSuggests",value:function(){var e=this,t=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],n=arguments[1],o=[],s=new RegExp(a(this.state.userInput),"gim"),u=this.props.skipSuggest,r=10,i=0,l=null;this.props.fixtures.forEach(function(e){i>=r||!u(e)&&e.label.match(s)&&(i++,e.placeId=e.label,e.isFixture=!0,o.push(e))}),t.forEach(function(t){u(t)||o.push({label:e.props.getSuggestLabel(t),placeId:t.place_id,isFixture:!1})}),l=this.updateActiveSuggest(o),this.setState({suggests:o,activeSuggest:l},n)}},{key:"updateActiveSuggest",value:function(){var e=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],t=this.state.activeSuggest;if(t){var n=e.find(function(e){return t.placeId===e.placeId&&t.isFixture===e.isFixture});t=n||null}return t}},{key:"showSuggests",value:function(){this.searchSuggests(),this.setState({isSuggestsHidden:!1})}},{key:"activateSuggest",value:function(e){if(this.state.isSuggestsHidden)return void this.showSuggests();var t=this.state.suggests.length-1,n="next"===e,o=null,s=0,u=0;for(u;t>=u;u++)this.state.suggests[u]===this.state.activeSuggest&&(s=n?u+1:u-1);this.state.activeSuggest||(s=n?0:t),s>=0&&t>=s&&(o=this.state.suggests[s]),this.props.onActivateSuggest(o),this.setState({activeSuggest:o})}},{key:"geocodeSuggest",value:function(e){var t=this;this.geocoder.geocode(e.placeId&&!e.isFixture?{placeId:e.placeId}:{address:e.label},function(n,o){if(o===t.googleMaps.GeocoderStatus.OK){var s=n[0],u=s.geometry.location;e.gmaps=s,e.location={lat:u.lat(),lng:u.lng()},t.props.onSuggestSelect(e)}})}},{key:"render",value:function(){var e=w["default"](this.props),t=g["default"]("geosuggest",this.props.className),n=p["default"].createElement(P["default"],i({className:this.props.inputClassName,ref:"input",value:this.state.userInput,ignoreTab:this.props.ignoreTab,style:this.props.style.input,onChange:this.onInputChange,onFocus:this.onInputFocus,onBlur:this.onInputBlur,onNext:this.onNext,onPrev:this.onPrev,onSelect:this.onSelect,onEscape:this.hideSuggests},e)),o=p["default"].createElement(T["default"],{isHidden:this.state.isSuggestsHidden,style:this.props.style.suggests,suggestItemStyle:this.props.style.suggestItem,suggests:this.state.suggests,activeSuggest:this.state.activeSuggest,onSuggestNoResults:this.onSuggestNoResults,onSuggestMouseDown:this.onSuggestMouseDown,onSuggestMouseOut:this.onSuggestMouseOut,onSuggestSelect:this.selectSuggest});return p["default"].createElement("div",{className:t},p["default"].createElement("div",{className:"geosuggest__input-wrapper"},n),p["default"].createElement("div",{className:"geosuggest__suggests-wrapper"},o))}}]),t}(p["default"].Component);_.propTypes=b["default"],_.defaultProps=v["default"],n["default"]=_},{"./defaults":7,"./filter-input-attributes":8,"./input":9,"./prop-types":10,"./suggest-list":12,classnames:1,"lodash.debounce":3}],7:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n["default"]={fixtures:[],initialValue:"",placeholder:"Search places",disabled:!1,className:"",inputClassName:"",location:null,radius:null,bounds:null,country:null,types:null,queryDelay:250,googleMaps:null,onActivateSuggest:function(){},onSuggestSelect:function(){},onSuggestNoResults:function(){},onFocus:function(){},onBlur:function(){},onChange:function(){},skipSuggest:function(){},getSuggestLabel:function(e){return e.description},autoActivateFirstSuggest:!1,style:{input:{},suggests:{},suggestItem:{}},ignoreTab:!1}},{}],8:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=function(e){var t={};return o.forEach(function(n){e[n]&&(t[n]=e[n])}),t};var o=["autoFocus","disabled","form","formAction","formEncType","formMethod","formNoValidate","formTarget","height","id","inputMode","maxLength","name","pattern","placeholder","readOnly","required","size","spellCheck","tabIndex"]},{}],9:[function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(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}function r(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)}Object.defineProperty(n,"__esModule",{value:!0});var a=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},i=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}}(),l=window.React,c=o(l),p=e("react-addons-shallow-compare"),f=o(p),g=e("classnames"),d=o(g),h=e("./filter-input-attributes"),y=o(h),v=function(e){function t(){var e,n,o,r;s(this,t);for(var a=arguments.length,i=Array(a),l=0;a>l;l++)i[l]=arguments[l];return n=o=u(this,(e=Object.getPrototypeOf(t)).call.apply(e,[this].concat(i))),o.onChange=function(){o.props.onChange(o.refs.input.value)},o.onFocus=function(){o.props.onFocus()},o.onBlur=function(){o.props.onBlur()},o.onInputKeyDown=function(e){switch(e.which){case 40:e.preventDefault(),o.props.onNext();break;case 38:e.preventDefault(),o.props.onPrev();break;case 13:e.preventDefault(),o.props.onSelect();break;case 9:o.props.ignoreTab||o.props.onSelect();break;case 27:o.props.onEscape()}},r=n,u(o,r)}return r(t,e),i(t,[{key:"shouldComponentUpdate",value:function(e,t){return f["default"](this,e,t)}},{key:"focus",value:function(){this.refs.input.focus()}},{key:"render",value:function(){var e=y["default"](this.props),t=d["default"]("geosuggest__input",this.props.className);return c["default"].createElement("input",a({className:t,ref:"input",type:"text",autoComplete:"off"},e,{value:this.props.value,style:this.props.style,onKeyDown:this.onInputKeyDown,onChange:this.onChange,onFocus:this.onFocus,onBlur:this.onBlur}))}}]),t}(c["default"].Component);v.defaultProps={className:"",value:"",ignoreTab:!1},n["default"]=v},{"./filter-input-attributes":8,classnames:1,"react-addons-shallow-compare":4}],10:[function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var s=window.React,u=o(s);n["default"]={fixtures:u["default"].PropTypes.array,initialValue:u["default"].PropTypes.string,placeholder:u["default"].PropTypes.string,disabled:u["default"].PropTypes.bool,className:u["default"].PropTypes.string,inputClassName:u["default"].PropTypes.string,location:u["default"].PropTypes.object,radius:u["default"].PropTypes.oneOfType([u["default"].PropTypes.string,u["default"].PropTypes.number]),bounds:u["default"].PropTypes.object,country:u["default"].PropTypes.string,types:u["default"].PropTypes.array,queryDelay:u["default"].PropTypes.number,googleMaps:u["default"].PropTypes.object,onSuggestSelect:u["default"].PropTypes.func,onFocus:u["default"].PropTypes.func,onBlur:u["default"].PropTypes.func,onChange:u["default"].PropTypes.func,skipSuggest:u["default"].PropTypes.func,getSuggestLabel:u["default"].PropTypes.func,autoActivateFirstSuggest:u["default"].PropTypes.bool,style:u["default"].PropTypes.shape({input:u["default"].PropTypes.object,suggests:u["default"].PropTypes.object,suggestItem:u["default"].PropTypes.object}),ignoreTab:u["default"].PropTypes.bool}},{}],11:[function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(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}function r(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)}Object.defineProperty(n,"__esModule",{value:!0});var a=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=window.React,l=o(i),c=e("react-addons-shallow-compare"),p=o(c),f=e("classnames"),g=o(f),d=function(e){function t(){var e,n,o,r;s(this,t);for(var a=arguments.length,i=Array(a),l=0;a>l;l++)i[l]=arguments[l];return n=o=u(this,(e=Object.getPrototypeOf(t)).call.apply(e,[this].concat(i))),o.onClick=function(e){e.preventDefault(),o.props.onSelect(o.props.suggest)},r=n,u(o,r)}return r(t,e),a(t,[{key:"shouldComponentUpdate",value:function(e,t){return p["default"](this,e,t)}},{key:"render",value:function(){var e=g["default"]("geosuggest-item",this.props.className,{"geosuggest-item--active":this.props.isActive});return l["default"].createElement("li",{className:e,style:this.props.style,onMouseDown:this.props.onMouseDown,onMouseOut:this.props.onMouseOut,onClick:this.onClick},this.props.suggest.label)}}]),t}(l["default"].Component);n["default"]=d,d.defaultProps={isActive:!1,className:"",suggest:{}}},{classnames:1,"react-addons-shallow-compare":4}],12:[function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(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}function r(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)}Object.defineProperty(n,"__esModule",{value:!0});var a=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=window.React,l=o(i),c=e("react-addons-shallow-compare"),p=o(c),f=e("classnames"),g=o(f),d=e("./suggest-item"),h=o(d),y=function(e){function t(){return s(this,t),u(this,Object.getPrototypeOf(t).apply(this,arguments))}return r(t,e),a(t,[{key:"shouldComponentUpdate",value:function(e,t){return p["default"](this,e,t)}},{key:"isHidden",value:function(){return this.props.isHidden||0===this.props.suggests.length}},{key:"componentWillReceiveProps",value:function(e){e.suggests!==this.props.suggests&&0===e.suggests.length&&this.props.onSuggestNoResults()}},{key:"render",value:function(){var e=this,t=g["default"]("geosuggest__suggests",{"geosuggest__suggests--hidden":this.isHidden()});return l["default"].createElement("ul",{className:t,style:this.props.style},this.props.suggests.map(function(t){var n=e.props.activeSuggest&&t.placeId===e.props.activeSuggest.placeId;return l["default"].createElement(h["default"],{key:t.placeId,className:t.className,suggest:t,style:e.props.suggestItemStyle,isActive:n,onMouseDown:e.props.onSuggestMouseDown,onMouseOut:e.props.onSuggestMouseOut,onSelect:e.props.onSuggestSelect})}))}}]),t}(l["default"].Component);n["default"]=y,y.defaultProps={isHidden:!0,suggests:[]}},{"./suggest-item":11,classnames:1,"react-addons-shallow-compare":4}]},{},[6])(6)});
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Geosuggest=e()}}(function(){var e;return function t(e,n,o){function s(r,a){if(!n[r]){if(!e[r]){var i="function"==typeof require&&require;if(!a&&i)return i(r,!0);if(u)return u(r,!0);var l=new Error("Cannot find module '"+r+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[r]={exports:{}};e[r][0].call(c.exports,function(t){var n=e[r][1][t];return s(n?n:t)},c,c.exports,t,e,n,o)}return n[r].exports}for(var u="function"==typeof require&&require,r=0;r<o.length;r++)s(o[r]);return s}({1:[function(t,n){!function(){"use strict";function t(){for(var e=[],n=0;n<arguments.length;n++){var s=arguments[n];if(s){var u=typeof s;if("string"===u||"number"===u)e.push(s);else if(Array.isArray(s))e.push(t.apply(null,s));else if("object"===u)for(var r in s)o.call(s,r)&&s[r]&&e.push(r)}}return e.join(" ")}var o={}.hasOwnProperty;"undefined"!=typeof n&&n.exports?n.exports=t:"function"==typeof e&&"object"==typeof e.amd&&e.amd?e("classnames",[],function(){return t}):window.classNames=t}()},{}],2:[function(e,t){"use strict";function n(e,t){return e===t?0!==e||1/e===1/t:e!==e&&t!==t}function o(e,t){if(n(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var o=Object.keys(e),u=Object.keys(t);if(o.length!==u.length)return!1;for(var r=0;r<o.length;r++)if(!s.call(t,o[r])||!n(e[o[r]],t[o[r]]))return!1;return!0}var s=Object.prototype.hasOwnProperty;t.exports=o},{}],3:[function(e,t){function n(e,t,n){function o(t){var n=h,o=y;return h=y=void 0,j=t,m=e.apply(o,n)}function u(e){return j=e,b=setTimeout(c,t),T?o(e):m}function r(e){var n=e-P,o=e-j,s=t-n;return _?w(s,v-o):s}function l(e){var n=e-P,o=e-j;return!P||n>=t||0>n||_&&o>=v}function c(){var e=O();return l(e)?p(e):void(b=setTimeout(c,r(e)))}function p(e){return clearTimeout(b),b=void 0,I&&h?o(e):(h=y=void 0,m)}function f(){void 0!==b&&clearTimeout(b),P=j=0,h=y=b=void 0}function g(){return void 0===b?m:p(O())}function d(){var e=O(),n=l(e);if(h=arguments,y=this,P=e,n){if(void 0===b)return u(P);if(_)return clearTimeout(b),b=setTimeout(c,t),o(P)}return void 0===b&&(b=setTimeout(c,t)),m}var h,y,v,m,b,P=0,j=0,T=!1,_=!1,I=!0;if("function"!=typeof e)throw new TypeError(i);return t=a(t)||0,s(n)&&(T=!!n.leading,_="maxWait"in n,v=_?S(a(n.maxWait)||0,t):v,I="trailing"in n?!!n.trailing:I),d.cancel=f,d.flush=g,d}function o(e){var t=s(e)?b.call(e):"";return t==c||t==p}function s(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function u(e){return!!e&&"object"==typeof e}function r(e){return"symbol"==typeof e||u(e)&&b.call(e)==f}function a(e){if("number"==typeof e)return e;if(r(e))return l;if(s(e)){var t=o(e.valueOf)?e.valueOf():e;e=s(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(g,"");var n=h.test(e);return n||y.test(e)?v(e.slice(2),n?2:8):d.test(e)?l:+e}var i="Expected a function",l=0/0,c="[object Function]",p="[object GeneratorFunction]",f="[object Symbol]",g=/^\s+|\s+$/g,d=/^[-+]0x[0-9a-f]+$/i,h=/^0b[01]+$/i,y=/^0o[0-7]+$/i,v=parseInt,m=Object.prototype,b=m.toString,S=Math.max,w=Math.min,O=Date.now;t.exports=n},{}],4:[function(e,t){t.exports=e("react/lib/shallowCompare")},{"react/lib/shallowCompare":5}],5:[function(e,t){"use strict";function n(e,t,n){return!o(e.props,t)||!o(e.state,n)}var o=e("fbjs/lib/shallowEqual");t.exports=n},{"fbjs/lib/shallowEqual":2}],6:[function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(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}function r(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)}function a(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}Object.defineProperty(n,"__esModule",{value:!0});var i=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},l=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}}(),c=window.React,p=o(c),f=e("classnames"),g=o(f),d=e("lodash.debounce"),h=o(d),y=e("./defaults"),v=o(y),m=e("./prop-types"),b=o(m),S=e("./filter-input-attributes"),w=o(S),O=e("./input"),P=o(O),j=e("./suggest-list"),T=o(j),_=function(e){function t(e){s(this,t);var n=u(this,Object.getPrototypeOf(t).call(this,e));return n.onInputChange=function(e){n.setState({userInput:e},n.onAfterInputChange)},n.onAfterInputChange=function(){n.showSuggests(),n.props.onChange(n.state.userInput)},n.onInputFocus=function(){n.props.onFocus(),n.showSuggests()},n.onInputBlur=function(){n.state.ignoreBlur||n.hideSuggests()},n.onNext=function(){return n.activateSuggest("next")},n.onPrev=function(){return n.activateSuggest("prev")},n.onSelect=function(){return n.selectSuggest(n.state.activeSuggest)},n.onSuggestMouseDown=function(){return n.setState({ignoreBlur:!0})},n.onSuggestMouseOut=function(){return n.setState({ignoreBlur:!1})},n.onSuggestNoResults=function(){n.props.onSuggestNoResults(n.state.userInput)},n.hideSuggests=function(){n.props.onBlur(n.state.userInput);var e=setTimeout(function(){n.setState({isSuggestsHidden:!0,activeSuggest:null})},100);n.setState({timer:e})},n.selectSuggest=function(e){return e||(e={label:n.state.userInput}),n.setState({isSuggestsHidden:!0,userInput:e.label}),e.location?(n.setState({ignoreBlur:!1}),void n.props.onSuggestSelect(e)):void n.geocodeSuggest(e)},n.state={isSuggestsHidden:!0,userInput:e.initialValue,activeSuggest:null,suggests:[],timer:null},n.onInputChange=n.onInputChange.bind(n),n.onAfterInputChange=n.onAfterInputChange.bind(n),e.queryDelay&&(n.onAfterInputChange=h["default"](n.onAfterInputChange,e.queryDelay)),n}return r(t,e),l(t,[{key:"componentWillReceiveProps",value:function(e){this.props.initialValue!==e.initialValue&&this.setState({userInput:e.initialValue})}},{key:"componentWillMount",value:function(){if("undefined"!=typeof window){var e=this.props.googleMaps||window.google&&window.google.maps||this.googleMaps;e&&(this.googleMaps=e,this.autocompleteService=new e.places.AutocompleteService,this.geocoder=new e.Geocoder)}}},{key:"componentWillUnmount",value:function(){clearTimeout(this.state.timer)}},{key:"focus",value:function(){this.refs.input.focus()}},{key:"update",value:function(e){this.setState({userInput:e}),this.props.onChange(e)}},{key:"clear",value:function(){this.setState({userInput:""},this.hideSuggests)}},{key:"searchSuggests",value:function(){var e=this;if(!this.state.userInput)return void this.updateSuggests();var t={input:this.state.userInput};["location","radius","bounds","types"].forEach(function(n){e.props[n]&&(t[n]=e.props[n])}),this.props.country&&(t.componentRestrictions={country:this.props.country}),this.autocompleteService.getPlacePredictions(t,function(t){e.updateSuggests(t||[],function(){e.props.autoActivateFirstSuggest&&!e.state.activeSuggest&&e.activateSuggest("next")})})}},{key:"updateSuggests",value:function(){var e=this,t=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],n=arguments[1],o=[],s=new RegExp(a(this.state.userInput),"gim"),u=this.props.skipSuggest,r=10,i=0,l=null;this.props.fixtures.forEach(function(e){i>=r||!u(e)&&e.label.match(s)&&(i++,e.placeId=e.label,e.isFixture=!0,o.push(e))}),t.forEach(function(t){u(t)||o.push({label:e.props.getSuggestLabel(t),placeId:t.place_id,isFixture:!1})}),l=this.updateActiveSuggest(o),this.setState({suggests:o,activeSuggest:l},n)}},{key:"updateActiveSuggest",value:function(){var e=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],t=this.state.activeSuggest;if(t){var n=e.find(function(e){return t.placeId===e.placeId&&t.isFixture===e.isFixture});t=n||null}return t}},{key:"showSuggests",value:function(){this.searchSuggests(),this.setState({isSuggestsHidden:!1})}},{key:"activateSuggest",value:function(e){if(this.state.isSuggestsHidden)return void this.showSuggests();var t=this.state.suggests.length-1,n="next"===e,o=null,s=0,u=0;for(u;t>=u;u++)this.state.suggests[u]===this.state.activeSuggest&&(s=n?u+1:u-1);this.state.activeSuggest||(s=n?0:t),s>=0&&t>=s&&(o=this.state.suggests[s]),this.props.onActivateSuggest(o),this.setState({activeSuggest:o})}},{key:"geocodeSuggest",value:function(e){var t=this;this.geocoder.geocode(e.placeId&&!e.isFixture?{placeId:e.placeId}:{address:e.label},function(n,o){if(o===t.googleMaps.GeocoderStatus.OK){var s=n[0],u=s.geometry.location;e.gmaps=s,e.location={lat:u.lat(),lng:u.lng()},t.props.onSuggestSelect(e)}})}},{key:"render",value:function(){var e=w["default"](this.props),t=g["default"]("geosuggest",this.props.className),n=p["default"].createElement(P["default"],i({className:this.props.inputClassName,ref:"input",value:this.state.userInput,ignoreTab:this.props.ignoreTab,style:this.props.style.input,onChange:this.onInputChange,onFocus:this.onInputFocus,onBlur:this.onInputBlur,onNext:this.onNext,onPrev:this.onPrev,onSelect:this.onSelect,onEscape:this.hideSuggests},e)),o=p["default"].createElement(T["default"],{isHidden:this.state.isSuggestsHidden,style:this.props.style.suggests,suggestItemStyle:this.props.style.suggestItem,suggests:this.state.suggests,activeSuggest:this.state.activeSuggest,onSuggestNoResults:this.onSuggestNoResults,onSuggestMouseDown:this.onSuggestMouseDown,onSuggestMouseOut:this.onSuggestMouseOut,onSuggestSelect:this.selectSuggest});return p["default"].createElement("div",{className:t},p["default"].createElement("div",{className:"geosuggest__input-wrapper"},n),p["default"].createElement("div",{className:"geosuggest__suggests-wrapper"},o))}}]),t}(p["default"].Component);_.propTypes=b["default"],_.defaultProps=v["default"],n["default"]=_},{"./defaults":7,"./filter-input-attributes":8,"./input":9,"./prop-types":10,"./suggest-list":12,classnames:1,"lodash.debounce":3}],7:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n["default"]={fixtures:[],initialValue:"",placeholder:"Search places",disabled:!1,className:"",inputClassName:"",location:null,radius:null,bounds:null,country:null,types:null,queryDelay:250,googleMaps:null,onActivateSuggest:function(){},onSuggestSelect:function(){},onSuggestNoResults:function(){},onFocus:function(){},onBlur:function(){},onChange:function(){},skipSuggest:function(){},getSuggestLabel:function(e){return e.description},autoActivateFirstSuggest:!1,style:{input:{},suggests:{},suggestItem:{}},ignoreTab:!1}},{}],8:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=function(e){var t={};return o.forEach(function(n){e[n]&&(t[n]=e[n])}),t};var o=["autoFocus","disabled","form","formAction","formEncType","formMethod","formNoValidate","formTarget","height","id","inputMode","maxLength","name","pattern","placeholder","readOnly","required","size","spellCheck","tabIndex"]},{}],9:[function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(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}function r(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)}Object.defineProperty(n,"__esModule",{value:!0});var a=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},i=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}}(),l=window.React,c=o(l),p=e("react-addons-shallow-compare"),f=o(p),g=e("classnames"),d=o(g),h=e("./filter-input-attributes"),y=o(h),v=function(e){function t(){var e,n,o,r;s(this,t);for(var a=arguments.length,i=Array(a),l=0;a>l;l++)i[l]=arguments[l];return n=o=u(this,(e=Object.getPrototypeOf(t)).call.apply(e,[this].concat(i))),o.onChange=function(){o.props.onChange(o.refs.input.value)},o.onFocus=function(){o.props.onFocus()},o.onBlur=function(){o.props.onBlur()},o.onInputKeyDown=function(e){switch(e.which){case 40:e.preventDefault(),o.props.onNext();break;case 38:e.preventDefault(),o.props.onPrev();break;case 13:e.preventDefault(),o.props.onSelect();break;case 9:o.props.ignoreTab||o.props.onSelect();break;case 27:o.props.onEscape()}},r=n,u(o,r)}return r(t,e),i(t,[{key:"shouldComponentUpdate",value:function(e,t){return f["default"](this,e,t)}},{key:"focus",value:function(){this.refs.input.focus()}},{key:"render",value:function(){var e=y["default"](this.props),t=d["default"]("geosuggest__input",this.props.className);return c["default"].createElement("input",a({className:t,ref:"input",type:"text",autoComplete:"off"},e,{value:this.props.value,style:this.props.style,onKeyDown:this.onInputKeyDown,onChange:this.onChange,onFocus:this.onFocus,onBlur:this.onBlur}))}}]),t}(c["default"].Component);v.defaultProps={className:"",value:"",ignoreTab:!1},n["default"]=v},{"./filter-input-attributes":8,classnames:1,"react-addons-shallow-compare":4}],10:[function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var s=window.React,u=o(s);n["default"]={fixtures:u["default"].PropTypes.array,initialValue:u["default"].PropTypes.string,placeholder:u["default"].PropTypes.string,disabled:u["default"].PropTypes.bool,className:u["default"].PropTypes.string,inputClassName:u["default"].PropTypes.string,location:u["default"].PropTypes.object,radius:u["default"].PropTypes.oneOfType([u["default"].PropTypes.string,u["default"].PropTypes.number]),bounds:u["default"].PropTypes.object,country:u["default"].PropTypes.string,types:u["default"].PropTypes.array,queryDelay:u["default"].PropTypes.number,googleMaps:u["default"].PropTypes.object,onSuggestSelect:u["default"].PropTypes.func,onFocus:u["default"].PropTypes.func,onBlur:u["default"].PropTypes.func,onChange:u["default"].PropTypes.func,skipSuggest:u["default"].PropTypes.func,getSuggestLabel:u["default"].PropTypes.func,autoActivateFirstSuggest:u["default"].PropTypes.bool,style:u["default"].PropTypes.shape({input:u["default"].PropTypes.object,suggests:u["default"].PropTypes.object,suggestItem:u["default"].PropTypes.object}),ignoreTab:u["default"].PropTypes.bool}},{}],11:[function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(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}function r(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)}Object.defineProperty(n,"__esModule",{value:!0});var a=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=window.React,l=o(i),c=e("react-addons-shallow-compare"),p=o(c),f=e("classnames"),g=o(f),d=function(e){function t(){var e,n,o,r;s(this,t);for(var a=arguments.length,i=Array(a),l=0;a>l;l++)i[l]=arguments[l];return n=o=u(this,(e=Object.getPrototypeOf(t)).call.apply(e,[this].concat(i))),o.onClick=function(e){e.preventDefault(),o.props.onSelect(o.props.suggest)},r=n,u(o,r)}return r(t,e),a(t,[{key:"shouldComponentUpdate",value:function(e,t){return p["default"](this,e,t)}},{key:"render",value:function(){var e=g["default"]("geosuggest-item",this.props.className,{"geosuggest-item--active":this.props.isActive});return l["default"].createElement("li",{className:e,style:this.props.style,onMouseDown:this.props.onMouseDown,onMouseOut:this.props.onMouseOut,onClick:this.onClick},this.props.suggest.label)}}]),t}(l["default"].Component);n["default"]=d,d.defaultProps={isActive:!1,className:"",suggest:{}}},{classnames:1,"react-addons-shallow-compare":4}],12:[function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(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}function r(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)}Object.defineProperty(n,"__esModule",{value:!0});var a=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=window.React,l=o(i),c=e("react-addons-shallow-compare"),p=o(c),f=e("classnames"),g=o(f),d=e("./suggest-item"),h=o(d),y=function(e){function t(){return s(this,t),u(this,Object.getPrototypeOf(t).apply(this,arguments))}return r(t,e),a(t,[{key:"shouldComponentUpdate",value:function(e,t){return p["default"](this,e,t)}},{key:"isHidden",value:function(){return this.props.isHidden||0===this.props.suggests.length}},{key:"componentWillReceiveProps",value:function(e){e.suggests!==this.props.suggests&&0===e.suggests.length&&this.props.onSuggestNoResults()}},{key:"render",value:function(){var e=this,t=g["default"]("geosuggest__suggests",{"geosuggest__suggests--hidden":this.isHidden()});return l["default"].createElement("ul",{className:t,style:this.props.style},this.props.suggests.map(function(t){var n=e.props.activeSuggest&&t.placeId===e.props.activeSuggest.placeId;return l["default"].createElement(h["default"],{key:t.placeId,className:t.className,suggest:t,style:e.props.suggestItemStyle,isActive:n,onMouseDown:e.props.onSuggestMouseDown,onMouseOut:e.props.onSuggestMouseOut,onSelect:e.props.onSuggestSelect})}))}}]),t}(l["default"].Component);n["default"]=y,y.defaultProps={isHidden:!0,suggests:[]}},{"./suggest-item":11,classnames:1,"react-addons-shallow-compare":4}]},{},[6])(6)});

@@ -190,2 +190,6 @@ 'use strict';

value: function componentWillMount() {
if (typeof window === 'undefined') {
return;
}
var googleMaps = this.props.googleMaps || window.google && // eslint-disable-line no-extra-parens

@@ -192,0 +196,0 @@ window.google.maps || this.googleMaps;

{
"name": "react-geosuggest",
"version": "1.24.0",
"version": "1.24.1",
"description": "A React autosuggest for the Google Maps Places API.",

@@ -5,0 +5,0 @@ "main": "module/Geosuggest.js",

Sorry, the diff of this file is not supported yet

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