react-geosuggest
Advanced tools
Comparing version 2.12.1 to 2.13.0
@@ -0,1 +1,15 @@ | ||
## 2.13.0 (2020-05-08) | ||
#### Bug Fixes | ||
* catch changing fixtures (#462) ([3df1f8ee](https://github.com/ubilabs/react-geosuggest/commit/3df1f8ee3fea1a0f1a9e1bbbca0277ac833b0ad7), closes [#457](https://github.com/ubilabs/react-geosuggest/issues/457)) | ||
* stop bundling classnames and lodash.debounce (#458) ([6ffbb4be](https://github.com/ubilabs/react-geosuggest/commit/6ffbb4be9732b4ba7ba69b7beb495659fc6fc737)) | ||
#### Features | ||
* allow any data attributes (#460) ([2d11ab9b](https://github.com/ubilabs/react-geosuggest/commit/2d11ab9be31679556220b2a20516690673340d9f)) | ||
### 2.12.1 (2019-10-30) | ||
@@ -2,0 +16,0 @@ |
@@ -90,3 +90,3 @@ var Geosuggest = (function (React) { | ||
if (module.exports) { | ||
if ( module.exports) { | ||
classNames.default = classNames; | ||
@@ -479,3 +479,3 @@ module.exports = classNames; | ||
/* istanbul ignore next */ | ||
/* tslint:disable:no-empty */ | ||
/* eslint-disable @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-empty-function */ | ||
/** | ||
@@ -488,2 +488,3 @@ * Default values | ||
fixtures: [], | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
getSuggestLabel: function (suggest) { return suggest.description; }, | ||
@@ -578,5 +579,7 @@ highlightMatch: true, | ||
var attributes = {}; | ||
allowedAttributes.forEach(function (allowedAttribute) { | ||
if (props[allowedAttribute]) { | ||
attributes[allowedAttribute] = props[allowedAttribute]; | ||
Object.keys(props).forEach(function (attribute) { | ||
var isDataAttribute = attribute.startsWith('data-'); | ||
var isAllowedAttribute = allowedAttributes.includes(attribute); | ||
if (isAllowedAttribute || isDataAttribute) { | ||
attributes[attribute] = props[attribute]; | ||
} | ||
@@ -590,10 +593,10 @@ }); | ||
*/ | ||
var default_1 = /** @class */ (function (_super) { | ||
__extends(default_1, _super); | ||
var Input = /** @class */ (function (_super) { | ||
__extends(Input, _super); | ||
/** | ||
* The constructor. | ||
*/ | ||
function default_1(props) { | ||
function Input(props) { | ||
var _this = _super.call(this, props) || this; | ||
/* tslint:enable:no-empty */ | ||
/* eslint-enable @typescript-eslint/no-empty-function */ | ||
/** | ||
@@ -610,3 +613,3 @@ * The reference to the input element | ||
*/ | ||
default_1.prototype.onChange = function () { | ||
Input.prototype.onChange = function () { | ||
if (this.input) { | ||
@@ -619,3 +622,4 @@ this.props.onChange(this.input.value); | ||
*/ | ||
default_1.prototype.onInputKeyDown = function (event) { | ||
// eslint-disable-next-line complexity | ||
Input.prototype.onInputKeyDown = function (event) { | ||
// Call props.onKeyDown if defined | ||
@@ -655,5 +659,2 @@ // Gives the developer a little bit more control if needed | ||
break; | ||
/* istanbul ignore next */ | ||
default: | ||
break; | ||
} | ||
@@ -664,3 +665,3 @@ }; | ||
*/ | ||
default_1.prototype.focus = function () { | ||
Input.prototype.focus = function () { | ||
if (this.input) { | ||
@@ -673,3 +674,3 @@ this.input.focus(); | ||
*/ | ||
default_1.prototype.blur = function () { | ||
Input.prototype.blur = function () { | ||
if (this.input) { | ||
@@ -682,15 +683,19 @@ this.input.blur(); | ||
*/ | ||
default_1.prototype.render = function () { | ||
Input.prototype.render = function () { | ||
var _this = this; | ||
var attributes = filterInputAttributes(this.props); | ||
var classes = classnames('geosuggest__input', this.props.className); | ||
if (!attributes.tabIndex) { | ||
attributes.tabIndex = 0; | ||
} | ||
return (React.createElement("input", __assign({ className: classes, ref: function (i) { return (_this.input = i); }, type: "text" }, attributes, { value: this.props.value, style: this.props.style, onKeyDown: this.onInputKeyDown, onChange: this.onChange, onKeyPress: this.props.onKeyPress, onFocus: this.props.onFocus, onBlur: this.props.onBlur, role: "combobox", "aria-expanded": !this.props.isSuggestsHidden, "aria-activedescendant": this.props.activeSuggest | ||
? this.props.activeSuggest.placeId | ||
: undefined, "aria-owns": this.props.listId }))); | ||
: // eslint-disable-next-line no-undefined | ||
undefined, "aria-owns": this.props.listId }))); | ||
}; | ||
/* tslint:disable:no-empty */ | ||
/* eslint-disable @typescript-eslint/no-empty-function */ | ||
/** | ||
* Default values for the properties | ||
*/ | ||
default_1.defaultProps = { | ||
Input.defaultProps = { | ||
activeSuggest: null, | ||
@@ -712,3 +717,3 @@ autoComplete: 'nope', | ||
}; | ||
return default_1; | ||
return Input; | ||
}(React.PureComponent)); | ||
@@ -719,3 +724,3 @@ | ||
*/ | ||
var default_1$1 = /** @class */ (function (_super) { | ||
var default_1 = /** @class */ (function (_super) { | ||
__extends(default_1, _super); | ||
@@ -804,4 +809,4 @@ /** | ||
default_1.prototype.render = function () { | ||
var _a; | ||
var _this = this; | ||
var _a; | ||
var suggest = this.props.suggest; | ||
@@ -828,5 +833,5 @@ var classes = classnames('geosuggest__item', this.props.className, this.props.suggestItemClassName, { 'geosuggest__item--active': this.props.isActive }, (_a = {}, | ||
*/ | ||
var default_1$2 = /** @class */ (function (_super) { | ||
__extends(default_1, _super); | ||
function default_1() { | ||
var default_1$1 = /** @class */ (function (_super) { | ||
__extends(default_1$1, _super); | ||
function default_1$1() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
@@ -837,3 +842,3 @@ } | ||
*/ | ||
default_1.prototype.isHidden = function () { | ||
default_1$1.prototype.isHidden = function () { | ||
return this.props.isHidden || this.props.suggests.length === 0; | ||
@@ -844,3 +849,3 @@ }; | ||
*/ | ||
default_1.prototype.componentDidUpdate = function (prevProps) { | ||
default_1$1.prototype.componentDidUpdate = function (prevProps) { | ||
if (prevProps.suggests !== this.props.suggests) { | ||
@@ -856,5 +861,5 @@ if (this.props.suggests.length === 0) { | ||
*/ | ||
default_1.prototype.render = function () { | ||
default_1$1.prototype.render = function () { | ||
var _a; | ||
var _this = this; | ||
var _a; | ||
var classes = classnames('geosuggest__suggests', this.props.suggestsClassName, { 'geosuggest__suggests--hidden': this.isHidden() }, (_a = {}, | ||
@@ -869,6 +874,6 @@ _a[this.props.hiddenClassName || ''] = this.props.hiddenClassName | ||
false; | ||
return (React.createElement(default_1$1, { key: suggest.placeId, className: suggest.className || '', userInput: _this.props.userInput, isHighlightMatch: _this.props.isHighlightMatch, suggest: suggest, style: _this.props.suggestItemStyle, suggestItemClassName: _this.props.suggestItemClassName, isActive: isActive, activeClassName: _this.props.suggestItemActiveClassName, onMouseDown: _this.props.onSuggestMouseDown, onMouseOut: _this.props.onSuggestMouseOut, onSelect: _this.props.onSuggestSelect, renderSuggestItem: _this.props.renderSuggestItem })); | ||
return (React.createElement(default_1, { key: suggest.placeId, className: suggest.className || '', userInput: _this.props.userInput, isHighlightMatch: _this.props.isHighlightMatch, suggest: suggest, style: _this.props.suggestItemStyle, suggestItemClassName: _this.props.suggestItemClassName, isActive: isActive, activeClassName: _this.props.suggestItemActiveClassName, onMouseDown: _this.props.onSuggestMouseDown, onMouseOut: _this.props.onSuggestMouseOut, onSelect: _this.props.onSuggestSelect, renderSuggestItem: _this.props.renderSuggestItem })); | ||
}))); | ||
}; | ||
return default_1; | ||
return default_1$1; | ||
}(React.PureComponent)); | ||
@@ -884,8 +889,9 @@ | ||
*/ | ||
var default_1$3 = /** @class */ (function (_super) { | ||
__extends(default_1$1, _super); | ||
var default_1$2 = /** @class */ (function (_super) { | ||
__extends(default_1, _super); | ||
/** | ||
* The constructor. Sets the initial state. | ||
*/ | ||
function default_1$1(props) { | ||
// eslint-disable-next-line max-statements | ||
function default_1(props) { | ||
var _this = _super.call(this, props) || this; | ||
@@ -895,2 +901,3 @@ /** | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
_this.googleMaps = null; | ||
@@ -937,5 +944,3 @@ /** | ||
_this.selectSuggest = _this.selectSuggest.bind(_this); | ||
_this.listId = "geosuggest__list_" + Math.random() | ||
.toString(16) | ||
.slice(2); | ||
_this.listId = "geosuggest__list_" + Math.random().toString(16).slice(2); | ||
if (props.queryDelay) { | ||
@@ -949,6 +954,9 @@ _this.onAfterInputChange = lodash_debounce(_this.onAfterInputChange, props.queryDelay); | ||
*/ | ||
default_1$1.prototype.componentDidUpdate = function (prevProps) { | ||
default_1.prototype.componentDidUpdate = function (prevProps) { | ||
if (prevProps.initialValue !== this.props.initialValue) { | ||
this.setState({ userInput: this.props.initialValue || '' }); | ||
} | ||
if (JSON.stringify(prevProps.fixtures) !== JSON.stringify(this.props.fixtures)) { | ||
this.searchSuggests(); | ||
} | ||
}; | ||
@@ -960,3 +968,3 @@ /** | ||
*/ | ||
default_1$1.prototype.componentDidMount = function () { | ||
default_1.prototype.componentDidMount = function () { | ||
if (typeof window === 'undefined') { | ||
@@ -966,2 +974,3 @@ return; | ||
var googleMaps = this.props.googleMaps || | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(window.google && window.google.maps) || | ||
@@ -972,3 +981,3 @@ this.googleMaps; | ||
if (console) { | ||
// tslint:disable-next-line:no-console | ||
// eslint-disable-next-line no-console | ||
console.error('Google maps API was not found in the page.'); | ||
@@ -987,3 +996,3 @@ } | ||
*/ | ||
default_1$1.prototype.componentWillUnmount = function () { | ||
default_1.prototype.componentWillUnmount = function () { | ||
clearTimeout(this.timer); | ||
@@ -994,3 +1003,3 @@ }; | ||
*/ | ||
default_1$1.prototype.onInputChange = function (userInput) { | ||
default_1.prototype.onInputChange = function (userInput) { | ||
if (!userInput) { | ||
@@ -1006,3 +1015,3 @@ if (this.props.onSuggestSelect) { | ||
*/ | ||
default_1$1.prototype.onAfterInputChange = function () { | ||
default_1.prototype.onAfterInputChange = function () { | ||
this.showSuggests(); | ||
@@ -1016,3 +1025,3 @@ if (this.props.onChange) { | ||
*/ | ||
default_1$1.prototype.onInputFocus = function () { | ||
default_1.prototype.onInputFocus = function () { | ||
if (this.props.onFocus) { | ||
@@ -1026,3 +1035,3 @@ this.props.onFocus(); | ||
*/ | ||
default_1$1.prototype.onInputBlur = function () { | ||
default_1.prototype.onInputBlur = function () { | ||
if (!this.state.ignoreBlur) { | ||
@@ -1032,18 +1041,18 @@ this.hideSuggests(); | ||
}; | ||
default_1$1.prototype.onNext = function () { | ||
default_1.prototype.onNext = function () { | ||
this.activateSuggest('next'); | ||
}; | ||
default_1$1.prototype.onPrev = function () { | ||
default_1.prototype.onPrev = function () { | ||
this.activateSuggest('prev'); | ||
}; | ||
default_1$1.prototype.onSelect = function () { | ||
default_1.prototype.onSelect = function () { | ||
this.selectSuggest(this.state.activeSuggest); | ||
}; | ||
default_1$1.prototype.onSuggestMouseDown = function () { | ||
default_1.prototype.onSuggestMouseDown = function () { | ||
this.setState({ ignoreBlur: true }); | ||
}; | ||
default_1$1.prototype.onSuggestMouseOut = function () { | ||
default_1.prototype.onSuggestMouseOut = function () { | ||
this.setState({ ignoreBlur: false }); | ||
}; | ||
default_1$1.prototype.onSuggestNoResults = function () { | ||
default_1.prototype.onSuggestNoResults = function () { | ||
if (this.props.onSuggestNoResults) { | ||
@@ -1056,3 +1065,3 @@ this.props.onSuggestNoResults(this.state.userInput); | ||
*/ | ||
default_1$1.prototype.focus = function () { | ||
default_1.prototype.focus = function () { | ||
if (this.input) { | ||
@@ -1065,3 +1074,3 @@ this.input.focus(); | ||
*/ | ||
default_1$1.prototype.blur = function () { | ||
default_1.prototype.blur = function () { | ||
if (this.input) { | ||
@@ -1074,3 +1083,3 @@ this.input.blur(); | ||
*/ | ||
default_1$1.prototype.update = function (userInput) { | ||
default_1.prototype.update = function (userInput) { | ||
this.setState({ userInput: userInput }); | ||
@@ -1084,3 +1093,3 @@ if (this.props.onChange) { | ||
*/ | ||
default_1$1.prototype.clear = function () { | ||
default_1.prototype.clear = function () { | ||
this.setState({ userInput: '' }, this.hideSuggests); | ||
@@ -1091,3 +1100,4 @@ }; | ||
*/ | ||
default_1$1.prototype.searchSuggests = function () { | ||
// eslint-disable-next-line complexity, max-statements | ||
default_1.prototype.searchSuggests = function () { | ||
var _this = this; | ||
@@ -1105,6 +1115,7 @@ if (!this.state.userInput) { | ||
if (isShorterThanMinLength) { | ||
this.updateSuggests(); | ||
return; | ||
} | ||
var _a = this.props, location = _a.location, radius = _a.radius, bounds = _a.bounds, types = _a.types, country = _a.country; | ||
/* tslint:disable:curly */ | ||
/* eslint-disable curly */ | ||
if (location) | ||
@@ -1120,3 +1131,3 @@ options.location = location; | ||
options.componentRestrictions = { country: country }; | ||
/* tslint:enable:curly */ | ||
/* eslint-enable curly */ | ||
this.setState({ isLoading: true }, function () { | ||
@@ -1142,4 +1153,4 @@ if (!_this.autocompleteService) { | ||
*/ | ||
default_1$1.prototype.updateSuggests = function (suggestsGoogle, | ||
// tslint:disable-next-line:no-empty | ||
default_1.prototype.updateSuggests = function (suggestsGoogle, | ||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-empty-function | ||
callback) { | ||
@@ -1164,3 +1175,3 @@ var _this = this; | ||
fixturesSearched++; | ||
suggests.push(__assign({}, fixture, { isFixture: true, matchedSubstrings: { | ||
suggests.push(__assign(__assign({}, fixture), { isFixture: true, matchedSubstrings: { | ||
length: userInput.length, | ||
@@ -1194,3 +1205,3 @@ offset: fixture.label.indexOf(userInput) | ||
*/ | ||
default_1$1.prototype.updateActiveSuggest = function (suggests) { | ||
default_1.prototype.updateActiveSuggest = function (suggests) { | ||
if (suggests === void 0) { suggests = []; } | ||
@@ -1211,3 +1222,3 @@ var activeSuggest = this.state.activeSuggest; | ||
*/ | ||
default_1$1.prototype.showSuggests = function () { | ||
default_1.prototype.showSuggests = function () { | ||
this.searchSuggests(); | ||
@@ -1219,3 +1230,3 @@ this.setState({ isSuggestsHidden: false }); | ||
*/ | ||
default_1$1.prototype.hideSuggests = function () { | ||
default_1.prototype.hideSuggests = function () { | ||
var _this = this; | ||
@@ -1235,3 +1246,4 @@ if (this.props.onBlur) { | ||
*/ | ||
default_1$1.prototype.activateSuggest = function (direction) { | ||
// eslint-disable-next-line complexity, max-statements | ||
default_1.prototype.activateSuggest = function (direction) { | ||
if (this.state.isSuggestsHidden) { | ||
@@ -1265,3 +1277,4 @@ this.showSuggests(); | ||
*/ | ||
default_1$1.prototype.selectSuggest = function (suggestToSelect) { | ||
// eslint-disable-next-line complexity | ||
default_1.prototype.selectSuggest = function (suggestToSelect) { | ||
var suggest = suggestToSelect || { | ||
@@ -1295,3 +1308,3 @@ isFixture: false, | ||
*/ | ||
default_1$1.prototype.geocodeSuggest = function (suggestToGeocode) { | ||
default_1.prototype.geocodeSuggest = function (suggestToGeocode) { | ||
var _this = this; | ||
@@ -1304,2 +1317,3 @@ if (!this.geocoder) { | ||
this.placesService) { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var options = { | ||
@@ -1310,3 +1324,4 @@ placeId: suggestToGeocode.placeId, | ||
if (this.props.placeDetailFields) { | ||
options.fields = ['geometry'].concat(this.props.placeDetailFields); | ||
options.fields = this.props.placeDetailFields; | ||
options.fields.unshift('geometry'); | ||
} | ||
@@ -1318,3 +1333,3 @@ this.placesService.getDetails(options, function (results, status) { | ||
gmaps.geometry.location); | ||
var suggest = __assign({}, suggestToGeocode, { gmaps: gmaps, location: { | ||
var suggest = __assign(__assign({}, suggestToGeocode), { gmaps: gmaps, location: { | ||
lat: location_1.lat(), | ||
@@ -1336,3 +1351,4 @@ lng: location_1.lng() | ||
? { country: this.props.country } | ||
: undefined, | ||
: // eslint-disable-next-line no-undefined | ||
undefined, | ||
location: this.props.location | ||
@@ -1345,3 +1361,3 @@ }; | ||
gmaps.geometry.location); | ||
var suggest = __assign({}, suggestToGeocode, { gmaps: gmaps, location: { | ||
var suggest = __assign(__assign({}, suggestToGeocode), { gmaps: gmaps, location: { | ||
lat: location_2.lat(), | ||
@@ -1360,3 +1376,3 @@ lng: location_2.lng() | ||
*/ | ||
default_1$1.prototype.render = function () { | ||
default_1.prototype.render = function () { | ||
var _this = this; | ||
@@ -1368,4 +1384,4 @@ var attributes = filterInputAttributes(this.props); | ||
var shouldRenderLabel = this.props.label && attributes.id; | ||
var input = (React.createElement(default_1, __assign({ className: this.props.inputClassName, ref: function (i) { return (_this.input = i); }, value: this.state.userInput, doNotSubmitOnEnter: !this.state.isSuggestsHidden, ignoreTab: this.props.ignoreTab, ignoreEnter: this.props.ignoreEnter, style: this.props.style && this.props.style.input, onChange: this.onInputChange, onFocus: this.onInputFocus, onBlur: this.onInputBlur, onKeyDown: this.props.onKeyDown, onKeyPress: this.props.onKeyPress, onNext: this.onNext, onPrev: this.onPrev, onSelect: this.onSelect, onEscape: this.hideSuggests, isSuggestsHidden: this.state.isSuggestsHidden, activeSuggest: this.state.activeSuggest, listId: this.listId }, attributes))); | ||
var suggestionsList = (React.createElement(default_1$2, { isHidden: this.state.isSuggestsHidden, style: this.props.style && this.props.style.suggests, suggestItemStyle: this.props.style && this.props.style.suggestItem, userInput: this.state.userInput, isHighlightMatch: Boolean(this.props.highlightMatch), suggestsClassName: this.props.suggestsClassName, suggestItemClassName: this.props.suggestItemClassName, suggests: this.state.suggests, hiddenClassName: this.props.suggestsHiddenClassName, suggestItemActiveClassName: this.props.suggestItemActiveClassName, activeSuggest: this.state.activeSuggest, onSuggestNoResults: this.onSuggestNoResults, onSuggestMouseDown: this.onSuggestMouseDown, onSuggestMouseOut: this.onSuggestMouseOut, onSuggestSelect: this.selectSuggest, renderSuggestItem: this.props.renderSuggestItem, listId: this.listId })); | ||
var input = (React.createElement(Input, __assign({ className: this.props.inputClassName, ref: function (i) { return (_this.input = i); }, value: this.state.userInput, doNotSubmitOnEnter: !this.state.isSuggestsHidden, ignoreTab: this.props.ignoreTab, ignoreEnter: this.props.ignoreEnter, style: this.props.style && this.props.style.input, onChange: this.onInputChange, onFocus: this.onInputFocus, onBlur: this.onInputBlur, onKeyDown: this.props.onKeyDown, onKeyPress: this.props.onKeyPress, onNext: this.onNext, onPrev: this.onPrev, onSelect: this.onSelect, onEscape: this.hideSuggests, isSuggestsHidden: this.state.isSuggestsHidden, activeSuggest: this.state.activeSuggest, listId: this.listId }, attributes))); | ||
var suggestionsList = (React.createElement(default_1$1, { isHidden: this.state.isSuggestsHidden, style: this.props.style && this.props.style.suggests, suggestItemStyle: this.props.style && this.props.style.suggestItem, userInput: this.state.userInput, isHighlightMatch: Boolean(this.props.highlightMatch), suggestsClassName: this.props.suggestsClassName, suggestItemClassName: this.props.suggestItemClassName, suggests: this.state.suggests, hiddenClassName: this.props.suggestsHiddenClassName, suggestItemActiveClassName: this.props.suggestItemActiveClassName, activeSuggest: this.state.activeSuggest, onSuggestNoResults: this.onSuggestNoResults, onSuggestMouseDown: this.onSuggestMouseDown, onSuggestMouseOut: this.onSuggestMouseOut, onSuggestSelect: this.selectSuggest, renderSuggestItem: this.props.renderSuggestItem, listId: this.listId })); | ||
return (React.createElement("div", { className: classes }, | ||
@@ -1380,8 +1396,8 @@ React.createElement("div", { className: "geosuggest__input-wrapper" }, | ||
*/ | ||
default_1$1.defaultProps = defaults; | ||
return default_1$1; | ||
default_1.defaultProps = defaults; | ||
return default_1; | ||
}(React.Component)); | ||
return default_1$3; | ||
return default_1$2; | ||
}(React)); |
@@ -1,1 +0,1 @@ | ||
var Geosuggest=function(u){"use strict";var o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s])})(t,e)};function n(t,e){function s(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(s.prototype=e.prototype,new s)}var c=function(){return(c=Object.assign||function(t){for(var e,s=1,o=arguments.length;s<o;s++)for(var n in e=arguments[s])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)},t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var e,r=(function(t){!function(){var r={}.hasOwnProperty;function u(){for(var t=[],e=0;e<arguments.length;e++){var s=arguments[e];if(s){var o=typeof s;if("string"==o||"number"==o)t.push(s);else if(Array.isArray(s)&&s.length){var n=u.apply(null,s);n&&t.push(n)}else if("object"==o)for(var i in s)r.call(s,i)&&s[i]&&t.push(i)}}return t.join(" ")}t.exports?(u.default=u,t.exports=u):window.classNames=u}()}(e={exports:{}},e.exports),e.exports),i=NaN,a="[object Symbol]",p=/^\s+|\s+$/g,g=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,h=/^0o[0-7]+$/i,d=parseInt,s="object"==typeof t&&t&&t.Object===Object&&t,f="object"==typeof self&&self&&self.Object===Object&&self,S=s||f||Function("return this")(),m=Object.prototype.toString,v=Math.max,y=Math.min,b=function(){return S.Date.now()};function I(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function w(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&m.call(t)==a}(t))return i;if(I(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=I(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(p,"");var s=l.test(t);return s||h.test(t)?d(t.slice(2),s?2:8):g.test(t)?i:+t}var C=function(o,s,t){var n,i,r,u,a,p,g=0,l=!1,c=!1,e=!0;if("function"!=typeof o)throw new TypeError("Expected a function");function h(t){var e=n,s=i;return n=i=void 0,g=t,u=o.apply(s,e)}function d(t){var e=t-p;return void 0===p||s<=e||e<0||c&&r<=t-g}function f(){var t=b();if(d(t))return S(t);a=setTimeout(f,function(t){var e=s-(t-p);return c?y(e,r-(t-g)):e}(t))}function S(t){return a=void 0,e&&n?h(t):(n=i=void 0,u)}function m(){var t=b(),e=d(t);if(n=arguments,i=this,p=t,e){if(void 0===a)return function(t){return g=t,a=setTimeout(f,s),l?h(t):u}(p);if(c)return a=setTimeout(f,s),h(p)}return void 0===a&&(a=setTimeout(f,s)),u}return s=w(s)||0,I(t)&&(l=!!t.leading,r=(c="maxWait"in t)?v(w(t.maxWait)||0,s):r,e="trailing"in t?!!t.trailing:e),m.cancel=function(){void 0!==a&&clearTimeout(a),n=p=i=a=void(g=0)},m.flush=function(){return void 0===a?u:S(b())},m},N={autoActivateFirstSuggest:!1,disabled:!1,fixtures:[],getSuggestLabel:function(t){return t.description},highlightMatch:!0,ignoreEnter:!1,ignoreTab:!1,initialValue:"",maxFixtures:10,minLength:1,onKeyDown:function(){},onKeyPress:function(){},placeholder:"Search places",queryDelay:250,skipSuggest:function(){return!1},style:{}},M=["autoCapitalize","autoComplete","autoCorrect","autoFocus","disabled","form","formAction","formEncType","formMethod","formNoValidate","formTarget","height","id","inputMode","maxLength","name","onClick","onContextMenu","onCopy","onCut","onDoubleClick","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp","onPaste","pattern","placeholder","readOnly","required","size","spellCheck","tabIndex","title","aria-atomic","aria-busy","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-dropeffect","aria-errormessage","aria-flowto","aria-grabbed","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-live","aria-owns","aria-relevant","aria-roledescription","aria-activedescendant","aria-autocomplete","aria-multiline","aria-placeholder","aria-readonly","aria-required"];function x(e){var s={};return M.forEach(function(t){e[t]&&(s[t]=e[t])}),s}var D=function(s){function t(t){var e=s.call(this,t)||this;return e.input=null,e.onChange=e.onChange.bind(e),e.onInputKeyDown=e.onInputKeyDown.bind(e),e}return n(t,s),t.prototype.onChange=function(){this.input&&this.props.onChange(this.input.value)},t.prototype.onInputKeyDown=function(t){switch(this.props.onKeyDown&&this.props.onKeyDown(t),t.which){case 40:t.shiftKey||(t.preventDefault(),this.props.onNext());break;case 38:t.shiftKey||(t.preventDefault(),this.props.onPrev());break;case 13:this.props.doNotSubmitOnEnter&&t.preventDefault(),this.props.ignoreEnter||this.props.onSelect();break;case 9:this.props.ignoreTab||this.props.onSelect();break;case 27:this.props.onEscape()}},t.prototype.focus=function(){this.input&&this.input.focus()},t.prototype.blur=function(){this.input&&this.input.blur()},t.prototype.render=function(){var e=this,t=x(this.props),s=r("geosuggest__input",this.props.className);return u.createElement("input",c({className:s,ref:function(t){return e.input=t},type:"text"},t,{value:this.props.value,style:this.props.style,onKeyDown:this.onInputKeyDown,onChange:this.onChange,onKeyPress:this.props.onKeyPress,onFocus:this.props.onFocus,onBlur:this.props.onBlur,role:"combobox","aria-expanded":!this.props.isSuggestsHidden,"aria-activedescendant":this.props.activeSuggest?this.props.activeSuggest.placeId:void 0,"aria-owns":this.props.listId}))},t.defaultProps={activeSuggest:null,autoComplete:"nope",className:"",isSuggestsHidden:!0,listId:"",onBlur:function(){},onChange:function(){},onEscape:function(){},onFocus:function(){},onKeyDown:function(){},onKeyPress:function(){},onNext:function(){},onPrev:function(){},onSelect:function(){},value:""},t}(u.PureComponent),T=function(s){function t(t){var e=s.call(this,t)||this;return e.ref=null,e.onClick=e.onClick.bind(e),e}return n(t,s),t.prototype.makeBold=function(t,e){return u.createElement("b",{className:"geosuggest__item__matched-text",key:e},t)},t.prototype.formatMatchedText=function(t,e){if(!t||!e.matchedSubstrings)return e.label;var s=e.matchedSubstrings.offset,o=s+e.matchedSubstrings.length,n=this.makeBold(e.label.substring(s,o),e.label),i="",r="";return 0<s&&(i=e.label.slice(0,s)),o<e.label.length&&(r=e.label.slice(o)),u.createElement("span",null,i,n,r)},t.prototype.componentDidUpdate=function(t){!t.isActive&&this.props.isActive&&this.scrollIfNeeded()},t.prototype.scrollIfNeeded=function(){var t=this.ref,e=t&&t.parentElement;if(t&&e){var s=t.offsetTop-e.offsetTop<e.scrollTop,o=t.offsetTop-e.offsetTop+t.clientHeight>e.scrollTop+e.clientHeight;(s||o)&&(e.scrollTop=t.offsetTop-e.offsetTop-e.clientHeight/2+t.clientHeight/2)}},t.prototype.onClick=function(t){t.preventDefault(),this.props.onSelect(this.props.suggest)},t.prototype.render=function(){var t,e=this,s=this.props.suggest,o=r("geosuggest__item",this.props.className,this.props.suggestItemClassName,{"geosuggest__item--active":this.props.isActive},((t={})[this.props.activeClassName||""]=this.props.activeClassName?this.props.isActive:null,t)),n=s.label;return this.props.renderSuggestItem?n=this.props.renderSuggestItem(s,this.props.userInput):this.props.isHighlightMatch&&(n=this.formatMatchedText(this.props.userInput,s)),u.createElement("li",{className:o,ref:function(t){return e.ref=t},style:this.props.style,onMouseDown:this.props.onMouseDown,onMouseOut:this.props.onMouseOut,onClick:this.onClick,role:"option","aria-selected":this.props.isActive,id:s.placeId},n)},t}(u.PureComponent),_=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.isHidden=function(){return this.props.isHidden||0===this.props.suggests.length},e.prototype.componentDidUpdate=function(t){t.suggests!==this.props.suggests&&0===this.props.suggests.length&&this.props.onSuggestNoResults()},e.prototype.render=function(){var t,s=this,e=r("geosuggest__suggests",this.props.suggestsClassName,{"geosuggest__suggests--hidden":this.isHidden()},((t={})[this.props.hiddenClassName||""]=this.props.hiddenClassName?this.isHidden():null,t));return u.createElement("ul",{className:e,style:this.props.style,role:"listbox",id:this.props.listId},this.props.suggests.map(function(t){var e=s.props.activeSuggest&&t.placeId===s.props.activeSuggest.placeId||!1;return u.createElement(T,{key:t.placeId,className:t.className||"",userInput:s.props.userInput,isHighlightMatch:s.props.isHighlightMatch,suggest:t,style:s.props.suggestItemStyle,suggestItemClassName:s.props.suggestItemClassName,isActive:e,activeClassName:s.props.suggestItemActiveClassName,onMouseDown:s.props.onSuggestMouseDown,onMouseOut:s.props.onSuggestMouseOut,onSelect:s.props.onSuggestSelect,renderSuggestItem:s.props.renderSuggestItem})}))},e}(u.PureComponent);return function(s){function t(t){var e=s.call(this,t)||this;return e.googleMaps=null,e.autocompleteService=null,e.placesService=null,e.sessionToken=void 0,e.geocoder=null,e.input=null,e.state={activeSuggest:null,ignoreBlur:!1,isLoading:!1,isSuggestsHidden:!0,suggests:[],userInput:t.initialValue||""},e.onInputChange=e.onInputChange.bind(e),e.onAfterInputChange=e.onAfterInputChange.bind(e),e.onInputFocus=e.onInputFocus.bind(e),e.onInputBlur=e.onInputBlur.bind(e),e.onNext=e.onNext.bind(e),e.onPrev=e.onPrev.bind(e),e.onSelect=e.onSelect.bind(e),e.onSuggestMouseDown=e.onSuggestMouseDown.bind(e),e.onSuggestMouseOut=e.onSuggestMouseOut.bind(e),e.onSuggestNoResults=e.onSuggestNoResults.bind(e),e.hideSuggests=e.hideSuggests.bind(e),e.selectSuggest=e.selectSuggest.bind(e),e.listId="geosuggest__list_"+Math.random().toString(16).slice(2),t.queryDelay&&(e.onAfterInputChange=C(e.onAfterInputChange,t.queryDelay)),e}return n(t,s),t.prototype.componentDidUpdate=function(t){t.initialValue!==this.props.initialValue&&this.setState({userInput:this.props.initialValue||""})},t.prototype.componentDidMount=function(){if("undefined"!=typeof window){var t=this.props.googleMaps||window.google&&window.google.maps||this.googleMaps;t?(this.googleMaps=t,this.autocompleteService=new t.places.AutocompleteService,this.placesService=new t.places.PlacesService(document.createElement("div")),this.sessionToken=new t.places.AutocompleteSessionToken,this.geocoder=new t.Geocoder):console&&console.error("Google maps API was not found in the page.")}},t.prototype.componentWillUnmount=function(){clearTimeout(this.timer)},t.prototype.onInputChange=function(t){t||this.props.onSuggestSelect&&this.props.onSuggestSelect(),this.setState({userInput:t},this.onAfterInputChange)},t.prototype.onAfterInputChange=function(){this.showSuggests(),this.props.onChange&&this.props.onChange(this.state.userInput)},t.prototype.onInputFocus=function(){this.props.onFocus&&this.props.onFocus(),this.showSuggests()},t.prototype.onInputBlur=function(){this.state.ignoreBlur||this.hideSuggests()},t.prototype.onNext=function(){this.activateSuggest("next")},t.prototype.onPrev=function(){this.activateSuggest("prev")},t.prototype.onSelect=function(){this.selectSuggest(this.state.activeSuggest)},t.prototype.onSuggestMouseDown=function(){this.setState({ignoreBlur:!0})},t.prototype.onSuggestMouseOut=function(){this.setState({ignoreBlur:!1})},t.prototype.onSuggestNoResults=function(){this.props.onSuggestNoResults&&this.props.onSuggestNoResults(this.state.userInput)},t.prototype.focus=function(){this.input&&this.input.focus()},t.prototype.blur=function(){this.input&&this.input.blur()},t.prototype.update=function(t){this.setState({userInput:t}),this.props.onChange&&this.props.onChange(t)},t.prototype.clear=function(){this.setState({userInput:""},this.hideSuggests)},t.prototype.searchSuggests=function(){var e=this;if(this.state.userInput){var t={input:this.state.userInput,sessionToken:this.sessionToken},s=this.state.userInput.length;if(!(this.props.minLength&&s<this.props.minLength)){var o=this.props,n=o.location,i=o.radius,r=o.bounds,u=o.types,a=o.country;n&&(t.location=n),i&&(t.radius=Number(this.props.radius)),r&&(t.bounds=r),u&&(t.types=u),a&&(t.componentRestrictions={country:a}),this.setState({isLoading:!0},function(){e.autocompleteService?e.autocompleteService.getPlacePredictions(t,function(t){e.setState({isLoading:!1}),e.updateSuggests(t||[],function(){e.props.autoActivateFirstSuggest&&!e.state.activeSuggest&&e.activateSuggest("next")})}):e.setState({isLoading:!1})})}}else this.updateSuggests()},t.prototype.updateSuggests=function(t,e){var s=this;void 0===t&&(t=[]),void 0===e&&(e=function(){});var o,n=[],i=this.state.userInput,r=this.props,u=r.skipSuggest,a=r.maxFixtures,p=r.fixtures,g=new RegExp(function(t){return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}(i),"gim"),l=0;p&&p.forEach(function(t){a&&a<=l||u&&!u(t)&&t.label.match(g)&&(l++,n.push(c({},t,{isFixture:!0,matchedSubstrings:{length:i.length,offset:t.label.indexOf(i)},placeId:t.placeId||t.label})))}),t.forEach(function(t){u&&!u(t)&&n.push({description:t.description,isFixture:!1,label:s.props.getSuggestLabel?s.props.getSuggestLabel(t):"",matchedSubstrings:t.matched_substrings[0],placeId:t.place_id})}),o=this.updateActiveSuggest(n),this.props.onUpdateSuggests&&this.props.onUpdateSuggests(n,o),this.setState({suggests:n,activeSuggest:o},e)},t.prototype.updateActiveSuggest=function(t){void 0===t&&(t=[]);var e=this.state.activeSuggest;if(e){var s=t.filter(function(t){return e&&e.placeId===t.placeId&&e.isFixture===t.isFixture})[0];e=s||null}return e},t.prototype.showSuggests=function(){this.searchSuggests(),this.setState({isSuggestsHidden:!1})},t.prototype.hideSuggests=function(){var t=this;this.props.onBlur&&this.props.onBlur(this.state.userInput),this.timer=window.setTimeout(function(){t.setState({activeSuggest:null,isSuggestsHidden:!0})},100)},t.prototype.activateSuggest=function(t){if(this.state.isSuggestsHidden)this.showSuggests();else{for(var e=this.state.suggests.length-1,s="next"===t,o=null,n=0,i=0;i<=e;i++)this.state.suggests[i]===this.state.activeSuggest&&(n=s?i+1:i-1);this.state.activeSuggest||(n=s?0:e),0<=n&&n<=e&&(o=this.state.suggests[n]),this.props.onActivateSuggest&&this.props.onActivateSuggest(o),this.setState({activeSuggest:o})}},t.prototype.selectSuggest=function(t){var e=t||{isFixture:!1,label:this.state.userInput,placeId:this.state.userInput};if(!t&&this.props.autoActivateFirstSuggest&&0<this.state.suggests.length&&(e=this.state.suggests[0]),this.setState({isSuggestsHidden:!0,userInput:"object"!=typeof e.label?e.label:e.description||""}),e.location)return this.setState({ignoreBlur:!1}),void(this.props.onSuggestSelect&&this.props.onSuggestSelect(e));this.geocodeSuggest(e)},t.prototype.geocodeSuggest=function(i){var r=this;if(this.geocoder)if(i.placeId&&!i.isFixture&&this.placesService){var t={placeId:i.placeId,sessionToken:this.sessionToken};this.props.placeDetailFields&&(t.fields=["geometry"].concat(this.props.placeDetailFields)),this.placesService.getDetails(t,function(t,e){if(e===r.googleMaps.places.PlacesServiceStatus.OK){var s=t,o=s.geometry&&s.geometry.location,n=c({},i,{gmaps:s,location:{lat:o.lat(),lng:o.lng()}});r.sessionToken=new google.maps.places.AutocompleteSessionToken,r.props.onSuggestSelect&&r.props.onSuggestSelect(n)}})}else{t={address:i.label,bounds:this.props.bounds,componentRestrictions:this.props.country?{country:this.props.country}:void 0,location:this.props.location};this.geocoder.geocode(t,function(t,e){if(e===r.googleMaps.GeocoderStatus.OK){var s=t[0],o=s.geometry&&s.geometry.location,n=c({},i,{gmaps:s,location:{lat:o.lat(),lng:o.lng()}});r.props.onSuggestSelect&&r.props.onSuggestSelect(n)}})}},t.prototype.render=function(){var e=this,t=x(this.props),s=r("geosuggest",this.props.className,{"geosuggest--loading":this.state.isLoading}),o=this.props.label&&t.id,n=u.createElement(D,c({className:this.props.inputClassName,ref:function(t){return e.input=t},value:this.state.userInput,doNotSubmitOnEnter:!this.state.isSuggestsHidden,ignoreTab:this.props.ignoreTab,ignoreEnter:this.props.ignoreEnter,style:this.props.style&&this.props.style.input,onChange:this.onInputChange,onFocus:this.onInputFocus,onBlur:this.onInputBlur,onKeyDown:this.props.onKeyDown,onKeyPress:this.props.onKeyPress,onNext:this.onNext,onPrev:this.onPrev,onSelect:this.onSelect,onEscape:this.hideSuggests,isSuggestsHidden:this.state.isSuggestsHidden,activeSuggest:this.state.activeSuggest,listId:this.listId},t)),i=u.createElement(_,{isHidden:this.state.isSuggestsHidden,style:this.props.style&&this.props.style.suggests,suggestItemStyle:this.props.style&&this.props.style.suggestItem,userInput:this.state.userInput,isHighlightMatch:Boolean(this.props.highlightMatch),suggestsClassName:this.props.suggestsClassName,suggestItemClassName:this.props.suggestItemClassName,suggests:this.state.suggests,hiddenClassName:this.props.suggestsHiddenClassName,suggestItemActiveClassName:this.props.suggestItemActiveClassName,activeSuggest:this.state.activeSuggest,onSuggestNoResults:this.onSuggestNoResults,onSuggestMouseDown:this.onSuggestMouseDown,onSuggestMouseOut:this.onSuggestMouseOut,onSuggestSelect:this.selectSuggest,renderSuggestItem:this.props.renderSuggestItem,listId:this.listId});return u.createElement("div",{className:s},u.createElement("div",{className:"geosuggest__input-wrapper"},o&&u.createElement("label",{className:"geosuggest__label",htmlFor:t.id},this.props.label),n),u.createElement("div",{className:"geosuggest__suggests-wrapper"},i))},t.defaultProps=N,t}(u.Component)}(React); | ||
var Geosuggest=function(u){"use strict";var o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s])})(t,e)};function n(t,e){function s(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(s.prototype=e.prototype,new s)}var c=function(){return(c=Object.assign||function(t){for(var e,s=1,o=arguments.length;s<o;s++)for(var n in e=arguments[s])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)},t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var e,r=(function(t){!function(){var r={}.hasOwnProperty;function u(){for(var t=[],e=0;e<arguments.length;e++){var s=arguments[e];if(s){var o=typeof s;if("string"==o||"number"==o)t.push(s);else if(Array.isArray(s)&&s.length){var n=u.apply(null,s);n&&t.push(n)}else if("object"==o)for(var i in s)r.call(s,i)&&s[i]&&t.push(i)}}return t.join(" ")}t.exports?(u.default=u,t.exports=u):window.classNames=u}()}(e={exports:{}},e.exports),e.exports),i=NaN,a="[object Symbol]",p=/^\s+|\s+$/g,g=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,h=/^0o[0-7]+$/i,d=parseInt,s="object"==typeof t&&t&&t.Object===Object&&t,f="object"==typeof self&&self&&self.Object===Object&&self,S=s||f||Function("return this")(),m=Object.prototype.toString,v=Math.max,y=Math.min,b=function(){return S.Date.now()};function I(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function w(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&m.call(t)==a}(t))return i;if(I(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=I(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(p,"");var s=l.test(t);return s||h.test(t)?d(t.slice(2),s?2:8):g.test(t)?i:+t}var C=function(o,s,t){var n,i,r,u,a,p,g=0,l=!1,c=!1,e=!0;if("function"!=typeof o)throw new TypeError("Expected a function");function h(t){var e=n,s=i;return n=i=void 0,g=t,u=o.apply(s,e)}function d(t){var e=t-p;return void 0===p||s<=e||e<0||c&&r<=t-g}function f(){var t=b();if(d(t))return S(t);a=setTimeout(f,function(t){var e=s-(t-p);return c?y(e,r-(t-g)):e}(t))}function S(t){return a=void 0,e&&n?h(t):(n=i=void 0,u)}function m(){var t=b(),e=d(t);if(n=arguments,i=this,p=t,e){if(void 0===a)return function(t){return g=t,a=setTimeout(f,s),l?h(t):u}(p);if(c)return a=setTimeout(f,s),h(p)}return void 0===a&&(a=setTimeout(f,s)),u}return s=w(s)||0,I(t)&&(l=!!t.leading,r=(c="maxWait"in t)?v(w(t.maxWait)||0,s):r,e="trailing"in t?!!t.trailing:e),m.cancel=function(){void 0!==a&&clearTimeout(a),n=p=i=a=void(g=0)},m.flush=function(){return void 0===a?u:S(b())},m},N={autoActivateFirstSuggest:!1,disabled:!1,fixtures:[],getSuggestLabel:function(t){return t.description},highlightMatch:!0,ignoreEnter:!1,ignoreTab:!1,initialValue:"",maxFixtures:10,minLength:1,onKeyDown:function(){},onKeyPress:function(){},placeholder:"Search places",queryDelay:250,skipSuggest:function(){return!1},style:{}},x=["autoCapitalize","autoComplete","autoCorrect","autoFocus","disabled","form","formAction","formEncType","formMethod","formNoValidate","formTarget","height","id","inputMode","maxLength","name","onClick","onContextMenu","onCopy","onCut","onDoubleClick","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp","onPaste","pattern","placeholder","readOnly","required","size","spellCheck","tabIndex","title","aria-atomic","aria-busy","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-dropeffect","aria-errormessage","aria-flowto","aria-grabbed","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-live","aria-owns","aria-relevant","aria-roledescription","aria-activedescendant","aria-autocomplete","aria-multiline","aria-placeholder","aria-readonly","aria-required"];function M(s){var o={};return Object.keys(s).forEach(function(t){var e=t.startsWith("data-");(x.includes(t)||e)&&(o[t]=s[t])}),o}var D=function(s){function t(t){var e=s.call(this,t)||this;return e.input=null,e.onChange=e.onChange.bind(e),e.onInputKeyDown=e.onInputKeyDown.bind(e),e}return n(t,s),t.prototype.onChange=function(){this.input&&this.props.onChange(this.input.value)},t.prototype.onInputKeyDown=function(t){switch(this.props.onKeyDown&&this.props.onKeyDown(t),t.which){case 40:t.shiftKey||(t.preventDefault(),this.props.onNext());break;case 38:t.shiftKey||(t.preventDefault(),this.props.onPrev());break;case 13:this.props.doNotSubmitOnEnter&&t.preventDefault(),this.props.ignoreEnter||this.props.onSelect();break;case 9:this.props.ignoreTab||this.props.onSelect();break;case 27:this.props.onEscape()}},t.prototype.focus=function(){this.input&&this.input.focus()},t.prototype.blur=function(){this.input&&this.input.blur()},t.prototype.render=function(){var e=this,t=M(this.props),s=r("geosuggest__input",this.props.className);return t.tabIndex||(t.tabIndex=0),u.createElement("input",c({className:s,ref:function(t){return e.input=t},type:"text"},t,{value:this.props.value,style:this.props.style,onKeyDown:this.onInputKeyDown,onChange:this.onChange,onKeyPress:this.props.onKeyPress,onFocus:this.props.onFocus,onBlur:this.props.onBlur,role:"combobox","aria-expanded":!this.props.isSuggestsHidden,"aria-activedescendant":this.props.activeSuggest?this.props.activeSuggest.placeId:void 0,"aria-owns":this.props.listId}))},t.defaultProps={activeSuggest:null,autoComplete:"nope",className:"",isSuggestsHidden:!0,listId:"",onBlur:function(){},onChange:function(){},onEscape:function(){},onFocus:function(){},onKeyDown:function(){},onKeyPress:function(){},onNext:function(){},onPrev:function(){},onSelect:function(){},value:""},t}(u.PureComponent),T=function(s){function t(t){var e=s.call(this,t)||this;return e.ref=null,e.onClick=e.onClick.bind(e),e}return n(t,s),t.prototype.makeBold=function(t,e){return u.createElement("b",{className:"geosuggest__item__matched-text",key:e},t)},t.prototype.formatMatchedText=function(t,e){if(!t||!e.matchedSubstrings)return e.label;var s=e.matchedSubstrings.offset,o=s+e.matchedSubstrings.length,n=this.makeBold(e.label.substring(s,o),e.label),i="",r="";return 0<s&&(i=e.label.slice(0,s)),o<e.label.length&&(r=e.label.slice(o)),u.createElement("span",null,i,n,r)},t.prototype.componentDidUpdate=function(t){!t.isActive&&this.props.isActive&&this.scrollIfNeeded()},t.prototype.scrollIfNeeded=function(){var t=this.ref,e=t&&t.parentElement;if(t&&e){var s=t.offsetTop-e.offsetTop<e.scrollTop,o=t.offsetTop-e.offsetTop+t.clientHeight>e.scrollTop+e.clientHeight;(s||o)&&(e.scrollTop=t.offsetTop-e.offsetTop-e.clientHeight/2+t.clientHeight/2)}},t.prototype.onClick=function(t){t.preventDefault(),this.props.onSelect(this.props.suggest)},t.prototype.render=function(){var t,e=this,s=this.props.suggest,o=r("geosuggest__item",this.props.className,this.props.suggestItemClassName,{"geosuggest__item--active":this.props.isActive},((t={})[this.props.activeClassName||""]=this.props.activeClassName?this.props.isActive:null,t)),n=s.label;return this.props.renderSuggestItem?n=this.props.renderSuggestItem(s,this.props.userInput):this.props.isHighlightMatch&&(n=this.formatMatchedText(this.props.userInput,s)),u.createElement("li",{className:o,ref:function(t){return e.ref=t},style:this.props.style,onMouseDown:this.props.onMouseDown,onMouseOut:this.props.onMouseOut,onClick:this.onClick,role:"option","aria-selected":this.props.isActive,id:s.placeId},n)},t}(u.PureComponent),O=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.isHidden=function(){return this.props.isHidden||0===this.props.suggests.length},e.prototype.componentDidUpdate=function(t){t.suggests!==this.props.suggests&&0===this.props.suggests.length&&this.props.onSuggestNoResults()},e.prototype.render=function(){var t,s=this,e=r("geosuggest__suggests",this.props.suggestsClassName,{"geosuggest__suggests--hidden":this.isHidden()},((t={})[this.props.hiddenClassName||""]=this.props.hiddenClassName?this.isHidden():null,t));return u.createElement("ul",{className:e,style:this.props.style,role:"listbox",id:this.props.listId},this.props.suggests.map(function(t){var e=s.props.activeSuggest&&t.placeId===s.props.activeSuggest.placeId||!1;return u.createElement(T,{key:t.placeId,className:t.className||"",userInput:s.props.userInput,isHighlightMatch:s.props.isHighlightMatch,suggest:t,style:s.props.suggestItemStyle,suggestItemClassName:s.props.suggestItemClassName,isActive:e,activeClassName:s.props.suggestItemActiveClassName,onMouseDown:s.props.onSuggestMouseDown,onMouseOut:s.props.onSuggestMouseOut,onSelect:s.props.onSuggestSelect,renderSuggestItem:s.props.renderSuggestItem})}))},e}(u.PureComponent);return function(s){function t(t){var e=s.call(this,t)||this;return e.googleMaps=null,e.autocompleteService=null,e.placesService=null,e.sessionToken=void 0,e.geocoder=null,e.input=null,e.state={activeSuggest:null,ignoreBlur:!1,isLoading:!1,isSuggestsHidden:!0,suggests:[],userInput:t.initialValue||""},e.onInputChange=e.onInputChange.bind(e),e.onAfterInputChange=e.onAfterInputChange.bind(e),e.onInputFocus=e.onInputFocus.bind(e),e.onInputBlur=e.onInputBlur.bind(e),e.onNext=e.onNext.bind(e),e.onPrev=e.onPrev.bind(e),e.onSelect=e.onSelect.bind(e),e.onSuggestMouseDown=e.onSuggestMouseDown.bind(e),e.onSuggestMouseOut=e.onSuggestMouseOut.bind(e),e.onSuggestNoResults=e.onSuggestNoResults.bind(e),e.hideSuggests=e.hideSuggests.bind(e),e.selectSuggest=e.selectSuggest.bind(e),e.listId="geosuggest__list_"+Math.random().toString(16).slice(2),t.queryDelay&&(e.onAfterInputChange=C(e.onAfterInputChange,t.queryDelay)),e}return n(t,s),t.prototype.componentDidUpdate=function(t){t.initialValue!==this.props.initialValue&&this.setState({userInput:this.props.initialValue||""}),JSON.stringify(t.fixtures)!==JSON.stringify(this.props.fixtures)&&this.searchSuggests()},t.prototype.componentDidMount=function(){if("undefined"!=typeof window){var t=this.props.googleMaps||window.google&&window.google.maps||this.googleMaps;t?(this.googleMaps=t,this.autocompleteService=new t.places.AutocompleteService,this.placesService=new t.places.PlacesService(document.createElement("div")),this.sessionToken=new t.places.AutocompleteSessionToken,this.geocoder=new t.Geocoder):console&&console.error("Google maps API was not found in the page.")}},t.prototype.componentWillUnmount=function(){clearTimeout(this.timer)},t.prototype.onInputChange=function(t){t||this.props.onSuggestSelect&&this.props.onSuggestSelect(),this.setState({userInput:t},this.onAfterInputChange)},t.prototype.onAfterInputChange=function(){this.showSuggests(),this.props.onChange&&this.props.onChange(this.state.userInput)},t.prototype.onInputFocus=function(){this.props.onFocus&&this.props.onFocus(),this.showSuggests()},t.prototype.onInputBlur=function(){this.state.ignoreBlur||this.hideSuggests()},t.prototype.onNext=function(){this.activateSuggest("next")},t.prototype.onPrev=function(){this.activateSuggest("prev")},t.prototype.onSelect=function(){this.selectSuggest(this.state.activeSuggest)},t.prototype.onSuggestMouseDown=function(){this.setState({ignoreBlur:!0})},t.prototype.onSuggestMouseOut=function(){this.setState({ignoreBlur:!1})},t.prototype.onSuggestNoResults=function(){this.props.onSuggestNoResults&&this.props.onSuggestNoResults(this.state.userInput)},t.prototype.focus=function(){this.input&&this.input.focus()},t.prototype.blur=function(){this.input&&this.input.blur()},t.prototype.update=function(t){this.setState({userInput:t}),this.props.onChange&&this.props.onChange(t)},t.prototype.clear=function(){this.setState({userInput:""},this.hideSuggests)},t.prototype.searchSuggests=function(){var e=this;if(this.state.userInput){var t={input:this.state.userInput,sessionToken:this.sessionToken},s=this.state.userInput.length;if(this.props.minLength&&s<this.props.minLength)this.updateSuggests();else{var o=this.props,n=o.location,i=o.radius,r=o.bounds,u=o.types,a=o.country;n&&(t.location=n),i&&(t.radius=Number(this.props.radius)),r&&(t.bounds=r),u&&(t.types=u),a&&(t.componentRestrictions={country:a}),this.setState({isLoading:!0},function(){e.autocompleteService?e.autocompleteService.getPlacePredictions(t,function(t){e.setState({isLoading:!1}),e.updateSuggests(t||[],function(){e.props.autoActivateFirstSuggest&&!e.state.activeSuggest&&e.activateSuggest("next")})}):e.setState({isLoading:!1})})}}else this.updateSuggests()},t.prototype.updateSuggests=function(t,e){var s=this;void 0===t&&(t=[]),void 0===e&&(e=function(){});var o,n=[],i=this.state.userInput,r=this.props,u=r.skipSuggest,a=r.maxFixtures,p=r.fixtures,g=new RegExp(function(t){return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}(i),"gim"),l=0;p&&p.forEach(function(t){a&&a<=l||u&&!u(t)&&t.label.match(g)&&(l++,n.push(c(c({},t),{isFixture:!0,matchedSubstrings:{length:i.length,offset:t.label.indexOf(i)},placeId:t.placeId||t.label})))}),t.forEach(function(t){u&&!u(t)&&n.push({description:t.description,isFixture:!1,label:s.props.getSuggestLabel?s.props.getSuggestLabel(t):"",matchedSubstrings:t.matched_substrings[0],placeId:t.place_id})}),o=this.updateActiveSuggest(n),this.props.onUpdateSuggests&&this.props.onUpdateSuggests(n,o),this.setState({suggests:n,activeSuggest:o},e)},t.prototype.updateActiveSuggest=function(t){void 0===t&&(t=[]);var e=this.state.activeSuggest;if(e){var s=t.filter(function(t){return e&&e.placeId===t.placeId&&e.isFixture===t.isFixture})[0];e=s||null}return e},t.prototype.showSuggests=function(){this.searchSuggests(),this.setState({isSuggestsHidden:!1})},t.prototype.hideSuggests=function(){var t=this;this.props.onBlur&&this.props.onBlur(this.state.userInput),this.timer=window.setTimeout(function(){t.setState({activeSuggest:null,isSuggestsHidden:!0})},100)},t.prototype.activateSuggest=function(t){if(this.state.isSuggestsHidden)this.showSuggests();else{for(var e=this.state.suggests.length-1,s="next"===t,o=null,n=0,i=0;i<=e;i++)this.state.suggests[i]===this.state.activeSuggest&&(n=s?i+1:i-1);this.state.activeSuggest||(n=s?0:e),0<=n&&n<=e&&(o=this.state.suggests[n]),this.props.onActivateSuggest&&this.props.onActivateSuggest(o),this.setState({activeSuggest:o})}},t.prototype.selectSuggest=function(t){var e=t||{isFixture:!1,label:this.state.userInput,placeId:this.state.userInput};if(!t&&this.props.autoActivateFirstSuggest&&0<this.state.suggests.length&&(e=this.state.suggests[0]),this.setState({isSuggestsHidden:!0,userInput:"object"!=typeof e.label?e.label:e.description||""}),e.location)return this.setState({ignoreBlur:!1}),void(this.props.onSuggestSelect&&this.props.onSuggestSelect(e));this.geocodeSuggest(e)},t.prototype.geocodeSuggest=function(i){var r=this;if(this.geocoder)if(i.placeId&&!i.isFixture&&this.placesService){var t={placeId:i.placeId,sessionToken:this.sessionToken};this.props.placeDetailFields&&(t.fields=this.props.placeDetailFields,t.fields.unshift("geometry")),this.placesService.getDetails(t,function(t,e){if(e===r.googleMaps.places.PlacesServiceStatus.OK){var s=t,o=s.geometry&&s.geometry.location,n=c(c({},i),{gmaps:s,location:{lat:o.lat(),lng:o.lng()}});r.sessionToken=new google.maps.places.AutocompleteSessionToken,r.props.onSuggestSelect&&r.props.onSuggestSelect(n)}})}else{t={address:i.label,bounds:this.props.bounds,componentRestrictions:this.props.country?{country:this.props.country}:void 0,location:this.props.location};this.geocoder.geocode(t,function(t,e){if(e===r.googleMaps.GeocoderStatus.OK){var s=t[0],o=s.geometry&&s.geometry.location,n=c(c({},i),{gmaps:s,location:{lat:o.lat(),lng:o.lng()}});r.props.onSuggestSelect&&r.props.onSuggestSelect(n)}})}},t.prototype.render=function(){var e=this,t=M(this.props),s=r("geosuggest",this.props.className,{"geosuggest--loading":this.state.isLoading}),o=this.props.label&&t.id,n=u.createElement(D,c({className:this.props.inputClassName,ref:function(t){return e.input=t},value:this.state.userInput,doNotSubmitOnEnter:!this.state.isSuggestsHidden,ignoreTab:this.props.ignoreTab,ignoreEnter:this.props.ignoreEnter,style:this.props.style&&this.props.style.input,onChange:this.onInputChange,onFocus:this.onInputFocus,onBlur:this.onInputBlur,onKeyDown:this.props.onKeyDown,onKeyPress:this.props.onKeyPress,onNext:this.onNext,onPrev:this.onPrev,onSelect:this.onSelect,onEscape:this.hideSuggests,isSuggestsHidden:this.state.isSuggestsHidden,activeSuggest:this.state.activeSuggest,listId:this.listId},t)),i=u.createElement(O,{isHidden:this.state.isSuggestsHidden,style:this.props.style&&this.props.style.suggests,suggestItemStyle:this.props.style&&this.props.style.suggestItem,userInput:this.state.userInput,isHighlightMatch:Boolean(this.props.highlightMatch),suggestsClassName:this.props.suggestsClassName,suggestItemClassName:this.props.suggestItemClassName,suggests:this.state.suggests,hiddenClassName:this.props.suggestsHiddenClassName,suggestItemActiveClassName:this.props.suggestItemActiveClassName,activeSuggest:this.state.activeSuggest,onSuggestNoResults:this.onSuggestNoResults,onSuggestMouseDown:this.onSuggestMouseDown,onSuggestMouseOut:this.onSuggestMouseOut,onSuggestSelect:this.selectSuggest,renderSuggestItem:this.props.renderSuggestItem,listId:this.listId});return u.createElement("div",{className:s},u.createElement("div",{className:"geosuggest__input-wrapper"},o&&u.createElement("label",{className:"geosuggest__label",htmlFor:t.id},this.props.label),n),u.createElement("div",{className:"geosuggest__suggests-wrapper"},i))},t.defaultProps=N,t}(u.Component)}(React); |
import { createElement, PureComponent, Component } from 'react'; | ||
import classnames from 'classnames'; | ||
import debounce from 'lodash.debounce'; | ||
@@ -43,437 +45,4 @@ /*! ***************************************************************************** | ||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
function createCommonjsModule(fn, module) { | ||
return module = { exports: {} }, fn(module, module.exports), module.exports; | ||
} | ||
var classnames = createCommonjsModule(function (module) { | ||
/*! | ||
Copyright (c) 2017 Jed Watson. | ||
Licensed under the MIT License (MIT), see | ||
http://jedwatson.github.io/classnames | ||
*/ | ||
/* global define */ | ||
(function () { | ||
var hasOwn = {}.hasOwnProperty; | ||
function classNames () { | ||
var classes = []; | ||
for (var i = 0; i < arguments.length; i++) { | ||
var arg = arguments[i]; | ||
if (!arg) continue; | ||
var argType = typeof arg; | ||
if (argType === 'string' || argType === 'number') { | ||
classes.push(arg); | ||
} else if (Array.isArray(arg) && arg.length) { | ||
var inner = classNames.apply(null, arg); | ||
if (inner) { | ||
classes.push(inner); | ||
} | ||
} else if (argType === 'object') { | ||
for (var key in arg) { | ||
if (hasOwn.call(arg, key) && arg[key]) { | ||
classes.push(key); | ||
} | ||
} | ||
} | ||
} | ||
return classes.join(' '); | ||
} | ||
if (module.exports) { | ||
classNames.default = classNames; | ||
module.exports = classNames; | ||
} else { | ||
window.classNames = classNames; | ||
} | ||
}()); | ||
}); | ||
/** | ||
* lodash (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
* Copyright jQuery Foundation and other contributors <https://jquery.org/> | ||
* Released under MIT license <https://lodash.com/license> | ||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> | ||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
*/ | ||
/** Used as the `TypeError` message for "Functions" methods. */ | ||
var FUNC_ERROR_TEXT = 'Expected a function'; | ||
/** Used as references for various `Number` constants. */ | ||
var NAN = 0 / 0; | ||
/** `Object#toString` result references. */ | ||
var symbolTag = '[object Symbol]'; | ||
/** Used to match leading and trailing whitespace. */ | ||
var reTrim = /^\s+|\s+$/g; | ||
/** Used to detect bad signed hexadecimal string values. */ | ||
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; | ||
/** Used to detect binary string values. */ | ||
var reIsBinary = /^0b[01]+$/i; | ||
/** Used to detect octal string values. */ | ||
var reIsOctal = /^0o[0-7]+$/i; | ||
/** Built-in method references without a dependency on `root`. */ | ||
var freeParseInt = parseInt; | ||
/** Detect free variable `global` from Node.js. */ | ||
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; | ||
/** Detect free variable `self`. */ | ||
var freeSelf = typeof self == 'object' && self && self.Object === Object && self; | ||
/** Used as a reference to the global object. */ | ||
var root = freeGlobal || freeSelf || Function('return this')(); | ||
/** Used for built-in method references. */ | ||
var objectProto = Object.prototype; | ||
/** | ||
* Used to resolve the | ||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var objectToString = objectProto.toString; | ||
/* Built-in method references for those with the same name as other `lodash` methods. */ | ||
var nativeMax = Math.max, | ||
nativeMin = Math.min; | ||
/** | ||
* Gets the timestamp of the number of milliseconds that have elapsed since | ||
* the Unix epoch (1 January 1970 00:00:00 UTC). | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 2.4.0 | ||
* @category Date | ||
* @returns {number} Returns the timestamp. | ||
* @example | ||
* | ||
* _.defer(function(stamp) { | ||
* console.log(_.now() - stamp); | ||
* }, _.now()); | ||
* // => Logs the number of milliseconds it took for the deferred invocation. | ||
*/ | ||
var now = function() { | ||
return root.Date.now(); | ||
}; | ||
/** | ||
* Creates a debounced function that delays invoking `func` until after `wait` | ||
* milliseconds have elapsed since the last time the debounced function was | ||
* invoked. The debounced function comes with a `cancel` method to cancel | ||
* delayed `func` invocations and a `flush` method to immediately invoke them. | ||
* Provide `options` to indicate whether `func` should be invoked on the | ||
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked | ||
* with the last arguments provided to the debounced function. Subsequent | ||
* calls to the debounced function return the result of the last `func` | ||
* invocation. | ||
* | ||
* **Note:** If `leading` and `trailing` options are `true`, `func` is | ||
* invoked on the trailing edge of the timeout only if the debounced function | ||
* is invoked more than once during the `wait` timeout. | ||
* | ||
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred | ||
* until to the next tick, similar to `setTimeout` with a timeout of `0`. | ||
* | ||
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) | ||
* for details over the differences between `_.debounce` and `_.throttle`. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 0.1.0 | ||
* @category Function | ||
* @param {Function} func The function to debounce. | ||
* @param {number} [wait=0] The number of milliseconds to delay. | ||
* @param {Object} [options={}] The options object. | ||
* @param {boolean} [options.leading=false] | ||
* Specify invoking on the leading edge of the timeout. | ||
* @param {number} [options.maxWait] | ||
* The maximum time `func` is allowed to be delayed before it's invoked. | ||
* @param {boolean} [options.trailing=true] | ||
* Specify invoking on the trailing edge of the timeout. | ||
* @returns {Function} Returns the new debounced function. | ||
* @example | ||
* | ||
* // Avoid costly calculations while the window size is in flux. | ||
* jQuery(window).on('resize', _.debounce(calculateLayout, 150)); | ||
* | ||
* // Invoke `sendMail` when clicked, debouncing subsequent calls. | ||
* jQuery(element).on('click', _.debounce(sendMail, 300, { | ||
* 'leading': true, | ||
* 'trailing': false | ||
* })); | ||
* | ||
* // Ensure `batchLog` is invoked once after 1 second of debounced calls. | ||
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); | ||
* var source = new EventSource('/stream'); | ||
* jQuery(source).on('message', debounced); | ||
* | ||
* // Cancel the trailing debounced invocation. | ||
* jQuery(window).on('popstate', debounced.cancel); | ||
*/ | ||
function debounce(func, wait, options) { | ||
var lastArgs, | ||
lastThis, | ||
maxWait, | ||
result, | ||
timerId, | ||
lastCallTime, | ||
lastInvokeTime = 0, | ||
leading = false, | ||
maxing = false, | ||
trailing = true; | ||
if (typeof func != 'function') { | ||
throw new TypeError(FUNC_ERROR_TEXT); | ||
} | ||
wait = toNumber(wait) || 0; | ||
if (isObject(options)) { | ||
leading = !!options.leading; | ||
maxing = 'maxWait' in options; | ||
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; | ||
trailing = 'trailing' in options ? !!options.trailing : trailing; | ||
} | ||
function invokeFunc(time) { | ||
var args = lastArgs, | ||
thisArg = lastThis; | ||
lastArgs = lastThis = undefined; | ||
lastInvokeTime = time; | ||
result = func.apply(thisArg, args); | ||
return result; | ||
} | ||
function leadingEdge(time) { | ||
// Reset any `maxWait` timer. | ||
lastInvokeTime = time; | ||
// Start the timer for the trailing edge. | ||
timerId = setTimeout(timerExpired, wait); | ||
// Invoke the leading edge. | ||
return leading ? invokeFunc(time) : result; | ||
} | ||
function remainingWait(time) { | ||
var timeSinceLastCall = time - lastCallTime, | ||
timeSinceLastInvoke = time - lastInvokeTime, | ||
result = wait - timeSinceLastCall; | ||
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result; | ||
} | ||
function shouldInvoke(time) { | ||
var timeSinceLastCall = time - lastCallTime, | ||
timeSinceLastInvoke = time - lastInvokeTime; | ||
// Either this is the first call, activity has stopped and we're at the | ||
// trailing edge, the system time has gone backwards and we're treating | ||
// it as the trailing edge, or we've hit the `maxWait` limit. | ||
return (lastCallTime === undefined || (timeSinceLastCall >= wait) || | ||
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); | ||
} | ||
function timerExpired() { | ||
var time = now(); | ||
if (shouldInvoke(time)) { | ||
return trailingEdge(time); | ||
} | ||
// Restart the timer. | ||
timerId = setTimeout(timerExpired, remainingWait(time)); | ||
} | ||
function trailingEdge(time) { | ||
timerId = undefined; | ||
// Only invoke if we have `lastArgs` which means `func` has been | ||
// debounced at least once. | ||
if (trailing && lastArgs) { | ||
return invokeFunc(time); | ||
} | ||
lastArgs = lastThis = undefined; | ||
return result; | ||
} | ||
function cancel() { | ||
if (timerId !== undefined) { | ||
clearTimeout(timerId); | ||
} | ||
lastInvokeTime = 0; | ||
lastArgs = lastCallTime = lastThis = timerId = undefined; | ||
} | ||
function flush() { | ||
return timerId === undefined ? result : trailingEdge(now()); | ||
} | ||
function debounced() { | ||
var time = now(), | ||
isInvoking = shouldInvoke(time); | ||
lastArgs = arguments; | ||
lastThis = this; | ||
lastCallTime = time; | ||
if (isInvoking) { | ||
if (timerId === undefined) { | ||
return leadingEdge(lastCallTime); | ||
} | ||
if (maxing) { | ||
// Handle invocations in a tight loop. | ||
timerId = setTimeout(timerExpired, wait); | ||
return invokeFunc(lastCallTime); | ||
} | ||
} | ||
if (timerId === undefined) { | ||
timerId = setTimeout(timerExpired, wait); | ||
} | ||
return result; | ||
} | ||
debounced.cancel = cancel; | ||
debounced.flush = flush; | ||
return debounced; | ||
} | ||
/** | ||
* Checks if `value` is the | ||
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) | ||
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 0.1.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is an object, else `false`. | ||
* @example | ||
* | ||
* _.isObject({}); | ||
* // => true | ||
* | ||
* _.isObject([1, 2, 3]); | ||
* // => true | ||
* | ||
* _.isObject(_.noop); | ||
* // => true | ||
* | ||
* _.isObject(null); | ||
* // => false | ||
*/ | ||
function isObject(value) { | ||
var type = typeof value; | ||
return !!value && (type == 'object' || type == 'function'); | ||
} | ||
/** | ||
* Checks if `value` is object-like. A value is object-like if it's not `null` | ||
* and has a `typeof` result of "object". | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is object-like, else `false`. | ||
* @example | ||
* | ||
* _.isObjectLike({}); | ||
* // => true | ||
* | ||
* _.isObjectLike([1, 2, 3]); | ||
* // => true | ||
* | ||
* _.isObjectLike(_.noop); | ||
* // => false | ||
* | ||
* _.isObjectLike(null); | ||
* // => false | ||
*/ | ||
function isObjectLike(value) { | ||
return !!value && typeof value == 'object'; | ||
} | ||
/** | ||
* Checks if `value` is classified as a `Symbol` primitive or object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`. | ||
* @example | ||
* | ||
* _.isSymbol(Symbol.iterator); | ||
* // => true | ||
* | ||
* _.isSymbol('abc'); | ||
* // => false | ||
*/ | ||
function isSymbol(value) { | ||
return typeof value == 'symbol' || | ||
(isObjectLike(value) && objectToString.call(value) == symbolTag); | ||
} | ||
/** | ||
* Converts `value` to a number. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to process. | ||
* @returns {number} Returns the number. | ||
* @example | ||
* | ||
* _.toNumber(3.2); | ||
* // => 3.2 | ||
* | ||
* _.toNumber(Number.MIN_VALUE); | ||
* // => 5e-324 | ||
* | ||
* _.toNumber(Infinity); | ||
* // => Infinity | ||
* | ||
* _.toNumber('3.2'); | ||
* // => 3.2 | ||
*/ | ||
function toNumber(value) { | ||
if (typeof value == 'number') { | ||
return value; | ||
} | ||
if (isSymbol(value)) { | ||
return NAN; | ||
} | ||
if (isObject(value)) { | ||
var other = typeof value.valueOf == 'function' ? value.valueOf() : value; | ||
value = isObject(other) ? (other + '') : other; | ||
} | ||
if (typeof value != 'string') { | ||
return value === 0 ? value : +value; | ||
} | ||
value = value.replace(reTrim, ''); | ||
var isBinary = reIsBinary.test(value); | ||
return (isBinary || reIsOctal.test(value)) | ||
? freeParseInt(value.slice(2), isBinary ? 2 : 8) | ||
: (reIsBadHex.test(value) ? NAN : +value); | ||
} | ||
var lodash_debounce = debounce; | ||
/* istanbul ignore next */ | ||
/* tslint:disable:no-empty */ | ||
/* eslint-disable @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-empty-function */ | ||
/** | ||
@@ -486,2 +55,3 @@ * Default values | ||
fixtures: [], | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
getSuggestLabel: function (suggest) { return suggest.description; }, | ||
@@ -576,5 +146,7 @@ highlightMatch: true, | ||
var attributes = {}; | ||
allowedAttributes.forEach(function (allowedAttribute) { | ||
if (props[allowedAttribute]) { | ||
attributes[allowedAttribute] = props[allowedAttribute]; | ||
Object.keys(props).forEach(function (attribute) { | ||
var isDataAttribute = attribute.startsWith('data-'); | ||
var isAllowedAttribute = allowedAttributes.includes(attribute); | ||
if (isAllowedAttribute || isDataAttribute) { | ||
attributes[attribute] = props[attribute]; | ||
} | ||
@@ -588,10 +160,10 @@ }); | ||
*/ | ||
var default_1 = /** @class */ (function (_super) { | ||
__extends(default_1, _super); | ||
var Input = /** @class */ (function (_super) { | ||
__extends(Input, _super); | ||
/** | ||
* The constructor. | ||
*/ | ||
function default_1(props) { | ||
function Input(props) { | ||
var _this = _super.call(this, props) || this; | ||
/* tslint:enable:no-empty */ | ||
/* eslint-enable @typescript-eslint/no-empty-function */ | ||
/** | ||
@@ -608,3 +180,3 @@ * The reference to the input element | ||
*/ | ||
default_1.prototype.onChange = function () { | ||
Input.prototype.onChange = function () { | ||
if (this.input) { | ||
@@ -617,3 +189,4 @@ this.props.onChange(this.input.value); | ||
*/ | ||
default_1.prototype.onInputKeyDown = function (event) { | ||
// eslint-disable-next-line complexity | ||
Input.prototype.onInputKeyDown = function (event) { | ||
// Call props.onKeyDown if defined | ||
@@ -653,5 +226,2 @@ // Gives the developer a little bit more control if needed | ||
break; | ||
/* istanbul ignore next */ | ||
default: | ||
break; | ||
} | ||
@@ -662,3 +232,3 @@ }; | ||
*/ | ||
default_1.prototype.focus = function () { | ||
Input.prototype.focus = function () { | ||
if (this.input) { | ||
@@ -671,3 +241,3 @@ this.input.focus(); | ||
*/ | ||
default_1.prototype.blur = function () { | ||
Input.prototype.blur = function () { | ||
if (this.input) { | ||
@@ -680,15 +250,19 @@ this.input.blur(); | ||
*/ | ||
default_1.prototype.render = function () { | ||
Input.prototype.render = function () { | ||
var _this = this; | ||
var attributes = filterInputAttributes(this.props); | ||
var classes = classnames('geosuggest__input', this.props.className); | ||
if (!attributes.tabIndex) { | ||
attributes.tabIndex = 0; | ||
} | ||
return (createElement("input", __assign({ className: classes, ref: function (i) { return (_this.input = i); }, type: "text" }, attributes, { value: this.props.value, style: this.props.style, onKeyDown: this.onInputKeyDown, onChange: this.onChange, onKeyPress: this.props.onKeyPress, onFocus: this.props.onFocus, onBlur: this.props.onBlur, role: "combobox", "aria-expanded": !this.props.isSuggestsHidden, "aria-activedescendant": this.props.activeSuggest | ||
? this.props.activeSuggest.placeId | ||
: undefined, "aria-owns": this.props.listId }))); | ||
: // eslint-disable-next-line no-undefined | ||
undefined, "aria-owns": this.props.listId }))); | ||
}; | ||
/* tslint:disable:no-empty */ | ||
/* eslint-disable @typescript-eslint/no-empty-function */ | ||
/** | ||
* Default values for the properties | ||
*/ | ||
default_1.defaultProps = { | ||
Input.defaultProps = { | ||
activeSuggest: null, | ||
@@ -710,3 +284,3 @@ autoComplete: 'nope', | ||
}; | ||
return default_1; | ||
return Input; | ||
}(PureComponent)); | ||
@@ -717,3 +291,3 @@ | ||
*/ | ||
var default_1$1 = /** @class */ (function (_super) { | ||
var default_1 = /** @class */ (function (_super) { | ||
__extends(default_1, _super); | ||
@@ -802,4 +376,4 @@ /** | ||
default_1.prototype.render = function () { | ||
var _a; | ||
var _this = this; | ||
var _a; | ||
var suggest = this.props.suggest; | ||
@@ -826,5 +400,5 @@ var classes = classnames('geosuggest__item', this.props.className, this.props.suggestItemClassName, { 'geosuggest__item--active': this.props.isActive }, (_a = {}, | ||
*/ | ||
var default_1$2 = /** @class */ (function (_super) { | ||
__extends(default_1, _super); | ||
function default_1() { | ||
var default_1$1 = /** @class */ (function (_super) { | ||
__extends(default_1$1, _super); | ||
function default_1$1() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
@@ -835,3 +409,3 @@ } | ||
*/ | ||
default_1.prototype.isHidden = function () { | ||
default_1$1.prototype.isHidden = function () { | ||
return this.props.isHidden || this.props.suggests.length === 0; | ||
@@ -842,3 +416,3 @@ }; | ||
*/ | ||
default_1.prototype.componentDidUpdate = function (prevProps) { | ||
default_1$1.prototype.componentDidUpdate = function (prevProps) { | ||
if (prevProps.suggests !== this.props.suggests) { | ||
@@ -854,5 +428,5 @@ if (this.props.suggests.length === 0) { | ||
*/ | ||
default_1.prototype.render = function () { | ||
default_1$1.prototype.render = function () { | ||
var _a; | ||
var _this = this; | ||
var _a; | ||
var classes = classnames('geosuggest__suggests', this.props.suggestsClassName, { 'geosuggest__suggests--hidden': this.isHidden() }, (_a = {}, | ||
@@ -867,6 +441,6 @@ _a[this.props.hiddenClassName || ''] = this.props.hiddenClassName | ||
false; | ||
return (createElement(default_1$1, { key: suggest.placeId, className: suggest.className || '', userInput: _this.props.userInput, isHighlightMatch: _this.props.isHighlightMatch, suggest: suggest, style: _this.props.suggestItemStyle, suggestItemClassName: _this.props.suggestItemClassName, isActive: isActive, activeClassName: _this.props.suggestItemActiveClassName, onMouseDown: _this.props.onSuggestMouseDown, onMouseOut: _this.props.onSuggestMouseOut, onSelect: _this.props.onSuggestSelect, renderSuggestItem: _this.props.renderSuggestItem })); | ||
return (createElement(default_1, { key: suggest.placeId, className: suggest.className || '', userInput: _this.props.userInput, isHighlightMatch: _this.props.isHighlightMatch, suggest: suggest, style: _this.props.suggestItemStyle, suggestItemClassName: _this.props.suggestItemClassName, isActive: isActive, activeClassName: _this.props.suggestItemActiveClassName, onMouseDown: _this.props.onSuggestMouseDown, onMouseOut: _this.props.onSuggestMouseOut, onSelect: _this.props.onSuggestSelect, renderSuggestItem: _this.props.renderSuggestItem })); | ||
}))); | ||
}; | ||
return default_1; | ||
return default_1$1; | ||
}(PureComponent)); | ||
@@ -882,8 +456,9 @@ | ||
*/ | ||
var default_1$3 = /** @class */ (function (_super) { | ||
__extends(default_1$1, _super); | ||
var default_1$2 = /** @class */ (function (_super) { | ||
__extends(default_1, _super); | ||
/** | ||
* The constructor. Sets the initial state. | ||
*/ | ||
function default_1$1(props) { | ||
// eslint-disable-next-line max-statements | ||
function default_1(props) { | ||
var _this = _super.call(this, props) || this; | ||
@@ -893,2 +468,3 @@ /** | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
_this.googleMaps = null; | ||
@@ -935,7 +511,5 @@ /** | ||
_this.selectSuggest = _this.selectSuggest.bind(_this); | ||
_this.listId = "geosuggest__list_" + Math.random() | ||
.toString(16) | ||
.slice(2); | ||
_this.listId = "geosuggest__list_" + Math.random().toString(16).slice(2); | ||
if (props.queryDelay) { | ||
_this.onAfterInputChange = lodash_debounce(_this.onAfterInputChange, props.queryDelay); | ||
_this.onAfterInputChange = debounce(_this.onAfterInputChange, props.queryDelay); | ||
} | ||
@@ -947,6 +521,9 @@ return _this; | ||
*/ | ||
default_1$1.prototype.componentDidUpdate = function (prevProps) { | ||
default_1.prototype.componentDidUpdate = function (prevProps) { | ||
if (prevProps.initialValue !== this.props.initialValue) { | ||
this.setState({ userInput: this.props.initialValue || '' }); | ||
} | ||
if (JSON.stringify(prevProps.fixtures) !== JSON.stringify(this.props.fixtures)) { | ||
this.searchSuggests(); | ||
} | ||
}; | ||
@@ -958,3 +535,3 @@ /** | ||
*/ | ||
default_1$1.prototype.componentDidMount = function () { | ||
default_1.prototype.componentDidMount = function () { | ||
if (typeof window === 'undefined') { | ||
@@ -964,2 +541,3 @@ return; | ||
var googleMaps = this.props.googleMaps || | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(window.google && window.google.maps) || | ||
@@ -970,3 +548,3 @@ this.googleMaps; | ||
if (console) { | ||
// tslint:disable-next-line:no-console | ||
// eslint-disable-next-line no-console | ||
console.error('Google maps API was not found in the page.'); | ||
@@ -985,3 +563,3 @@ } | ||
*/ | ||
default_1$1.prototype.componentWillUnmount = function () { | ||
default_1.prototype.componentWillUnmount = function () { | ||
clearTimeout(this.timer); | ||
@@ -992,3 +570,3 @@ }; | ||
*/ | ||
default_1$1.prototype.onInputChange = function (userInput) { | ||
default_1.prototype.onInputChange = function (userInput) { | ||
if (!userInput) { | ||
@@ -1004,3 +582,3 @@ if (this.props.onSuggestSelect) { | ||
*/ | ||
default_1$1.prototype.onAfterInputChange = function () { | ||
default_1.prototype.onAfterInputChange = function () { | ||
this.showSuggests(); | ||
@@ -1014,3 +592,3 @@ if (this.props.onChange) { | ||
*/ | ||
default_1$1.prototype.onInputFocus = function () { | ||
default_1.prototype.onInputFocus = function () { | ||
if (this.props.onFocus) { | ||
@@ -1024,3 +602,3 @@ this.props.onFocus(); | ||
*/ | ||
default_1$1.prototype.onInputBlur = function () { | ||
default_1.prototype.onInputBlur = function () { | ||
if (!this.state.ignoreBlur) { | ||
@@ -1030,18 +608,18 @@ this.hideSuggests(); | ||
}; | ||
default_1$1.prototype.onNext = function () { | ||
default_1.prototype.onNext = function () { | ||
this.activateSuggest('next'); | ||
}; | ||
default_1$1.prototype.onPrev = function () { | ||
default_1.prototype.onPrev = function () { | ||
this.activateSuggest('prev'); | ||
}; | ||
default_1$1.prototype.onSelect = function () { | ||
default_1.prototype.onSelect = function () { | ||
this.selectSuggest(this.state.activeSuggest); | ||
}; | ||
default_1$1.prototype.onSuggestMouseDown = function () { | ||
default_1.prototype.onSuggestMouseDown = function () { | ||
this.setState({ ignoreBlur: true }); | ||
}; | ||
default_1$1.prototype.onSuggestMouseOut = function () { | ||
default_1.prototype.onSuggestMouseOut = function () { | ||
this.setState({ ignoreBlur: false }); | ||
}; | ||
default_1$1.prototype.onSuggestNoResults = function () { | ||
default_1.prototype.onSuggestNoResults = function () { | ||
if (this.props.onSuggestNoResults) { | ||
@@ -1054,3 +632,3 @@ this.props.onSuggestNoResults(this.state.userInput); | ||
*/ | ||
default_1$1.prototype.focus = function () { | ||
default_1.prototype.focus = function () { | ||
if (this.input) { | ||
@@ -1063,3 +641,3 @@ this.input.focus(); | ||
*/ | ||
default_1$1.prototype.blur = function () { | ||
default_1.prototype.blur = function () { | ||
if (this.input) { | ||
@@ -1072,3 +650,3 @@ this.input.blur(); | ||
*/ | ||
default_1$1.prototype.update = function (userInput) { | ||
default_1.prototype.update = function (userInput) { | ||
this.setState({ userInput: userInput }); | ||
@@ -1082,3 +660,3 @@ if (this.props.onChange) { | ||
*/ | ||
default_1$1.prototype.clear = function () { | ||
default_1.prototype.clear = function () { | ||
this.setState({ userInput: '' }, this.hideSuggests); | ||
@@ -1089,3 +667,4 @@ }; | ||
*/ | ||
default_1$1.prototype.searchSuggests = function () { | ||
// eslint-disable-next-line complexity, max-statements | ||
default_1.prototype.searchSuggests = function () { | ||
var _this = this; | ||
@@ -1103,6 +682,7 @@ if (!this.state.userInput) { | ||
if (isShorterThanMinLength) { | ||
this.updateSuggests(); | ||
return; | ||
} | ||
var _a = this.props, location = _a.location, radius = _a.radius, bounds = _a.bounds, types = _a.types, country = _a.country; | ||
/* tslint:disable:curly */ | ||
/* eslint-disable curly */ | ||
if (location) | ||
@@ -1118,3 +698,3 @@ options.location = location; | ||
options.componentRestrictions = { country: country }; | ||
/* tslint:enable:curly */ | ||
/* eslint-enable curly */ | ||
this.setState({ isLoading: true }, function () { | ||
@@ -1140,4 +720,4 @@ if (!_this.autocompleteService) { | ||
*/ | ||
default_1$1.prototype.updateSuggests = function (suggestsGoogle, | ||
// tslint:disable-next-line:no-empty | ||
default_1.prototype.updateSuggests = function (suggestsGoogle, | ||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-empty-function | ||
callback) { | ||
@@ -1162,3 +742,3 @@ var _this = this; | ||
fixturesSearched++; | ||
suggests.push(__assign({}, fixture, { isFixture: true, matchedSubstrings: { | ||
suggests.push(__assign(__assign({}, fixture), { isFixture: true, matchedSubstrings: { | ||
length: userInput.length, | ||
@@ -1192,3 +772,3 @@ offset: fixture.label.indexOf(userInput) | ||
*/ | ||
default_1$1.prototype.updateActiveSuggest = function (suggests) { | ||
default_1.prototype.updateActiveSuggest = function (suggests) { | ||
if (suggests === void 0) { suggests = []; } | ||
@@ -1209,3 +789,3 @@ var activeSuggest = this.state.activeSuggest; | ||
*/ | ||
default_1$1.prototype.showSuggests = function () { | ||
default_1.prototype.showSuggests = function () { | ||
this.searchSuggests(); | ||
@@ -1217,3 +797,3 @@ this.setState({ isSuggestsHidden: false }); | ||
*/ | ||
default_1$1.prototype.hideSuggests = function () { | ||
default_1.prototype.hideSuggests = function () { | ||
var _this = this; | ||
@@ -1233,3 +813,4 @@ if (this.props.onBlur) { | ||
*/ | ||
default_1$1.prototype.activateSuggest = function (direction) { | ||
// eslint-disable-next-line complexity, max-statements | ||
default_1.prototype.activateSuggest = function (direction) { | ||
if (this.state.isSuggestsHidden) { | ||
@@ -1263,3 +844,4 @@ this.showSuggests(); | ||
*/ | ||
default_1$1.prototype.selectSuggest = function (suggestToSelect) { | ||
// eslint-disable-next-line complexity | ||
default_1.prototype.selectSuggest = function (suggestToSelect) { | ||
var suggest = suggestToSelect || { | ||
@@ -1293,3 +875,3 @@ isFixture: false, | ||
*/ | ||
default_1$1.prototype.geocodeSuggest = function (suggestToGeocode) { | ||
default_1.prototype.geocodeSuggest = function (suggestToGeocode) { | ||
var _this = this; | ||
@@ -1302,2 +884,3 @@ if (!this.geocoder) { | ||
this.placesService) { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var options = { | ||
@@ -1308,3 +891,4 @@ placeId: suggestToGeocode.placeId, | ||
if (this.props.placeDetailFields) { | ||
options.fields = ['geometry'].concat(this.props.placeDetailFields); | ||
options.fields = this.props.placeDetailFields; | ||
options.fields.unshift('geometry'); | ||
} | ||
@@ -1316,3 +900,3 @@ this.placesService.getDetails(options, function (results, status) { | ||
gmaps.geometry.location); | ||
var suggest = __assign({}, suggestToGeocode, { gmaps: gmaps, location: { | ||
var suggest = __assign(__assign({}, suggestToGeocode), { gmaps: gmaps, location: { | ||
lat: location_1.lat(), | ||
@@ -1334,3 +918,4 @@ lng: location_1.lng() | ||
? { country: this.props.country } | ||
: undefined, | ||
: // eslint-disable-next-line no-undefined | ||
undefined, | ||
location: this.props.location | ||
@@ -1343,3 +928,3 @@ }; | ||
gmaps.geometry.location); | ||
var suggest = __assign({}, suggestToGeocode, { gmaps: gmaps, location: { | ||
var suggest = __assign(__assign({}, suggestToGeocode), { gmaps: gmaps, location: { | ||
lat: location_2.lat(), | ||
@@ -1358,3 +943,3 @@ lng: location_2.lng() | ||
*/ | ||
default_1$1.prototype.render = function () { | ||
default_1.prototype.render = function () { | ||
var _this = this; | ||
@@ -1366,4 +951,4 @@ var attributes = filterInputAttributes(this.props); | ||
var shouldRenderLabel = this.props.label && attributes.id; | ||
var input = (createElement(default_1, __assign({ className: this.props.inputClassName, ref: function (i) { return (_this.input = i); }, value: this.state.userInput, doNotSubmitOnEnter: !this.state.isSuggestsHidden, ignoreTab: this.props.ignoreTab, ignoreEnter: this.props.ignoreEnter, style: this.props.style && this.props.style.input, onChange: this.onInputChange, onFocus: this.onInputFocus, onBlur: this.onInputBlur, onKeyDown: this.props.onKeyDown, onKeyPress: this.props.onKeyPress, onNext: this.onNext, onPrev: this.onPrev, onSelect: this.onSelect, onEscape: this.hideSuggests, isSuggestsHidden: this.state.isSuggestsHidden, activeSuggest: this.state.activeSuggest, listId: this.listId }, attributes))); | ||
var suggestionsList = (createElement(default_1$2, { isHidden: this.state.isSuggestsHidden, style: this.props.style && this.props.style.suggests, suggestItemStyle: this.props.style && this.props.style.suggestItem, userInput: this.state.userInput, isHighlightMatch: Boolean(this.props.highlightMatch), suggestsClassName: this.props.suggestsClassName, suggestItemClassName: this.props.suggestItemClassName, suggests: this.state.suggests, hiddenClassName: this.props.suggestsHiddenClassName, suggestItemActiveClassName: this.props.suggestItemActiveClassName, activeSuggest: this.state.activeSuggest, onSuggestNoResults: this.onSuggestNoResults, onSuggestMouseDown: this.onSuggestMouseDown, onSuggestMouseOut: this.onSuggestMouseOut, onSuggestSelect: this.selectSuggest, renderSuggestItem: this.props.renderSuggestItem, listId: this.listId })); | ||
var input = (createElement(Input, __assign({ className: this.props.inputClassName, ref: function (i) { return (_this.input = i); }, value: this.state.userInput, doNotSubmitOnEnter: !this.state.isSuggestsHidden, ignoreTab: this.props.ignoreTab, ignoreEnter: this.props.ignoreEnter, style: this.props.style && this.props.style.input, onChange: this.onInputChange, onFocus: this.onInputFocus, onBlur: this.onInputBlur, onKeyDown: this.props.onKeyDown, onKeyPress: this.props.onKeyPress, onNext: this.onNext, onPrev: this.onPrev, onSelect: this.onSelect, onEscape: this.hideSuggests, isSuggestsHidden: this.state.isSuggestsHidden, activeSuggest: this.state.activeSuggest, listId: this.listId }, attributes))); | ||
var suggestionsList = (createElement(default_1$1, { isHidden: this.state.isSuggestsHidden, style: this.props.style && this.props.style.suggests, suggestItemStyle: this.props.style && this.props.style.suggestItem, userInput: this.state.userInput, isHighlightMatch: Boolean(this.props.highlightMatch), suggestsClassName: this.props.suggestsClassName, suggestItemClassName: this.props.suggestItemClassName, suggests: this.state.suggests, hiddenClassName: this.props.suggestsHiddenClassName, suggestItemActiveClassName: this.props.suggestItemActiveClassName, activeSuggest: this.state.activeSuggest, onSuggestNoResults: this.onSuggestNoResults, onSuggestMouseDown: this.onSuggestMouseDown, onSuggestMouseOut: this.onSuggestMouseOut, onSuggestSelect: this.selectSuggest, renderSuggestItem: this.props.renderSuggestItem, listId: this.listId })); | ||
return (createElement("div", { className: classes }, | ||
@@ -1378,6 +963,6 @@ createElement("div", { className: "geosuggest__input-wrapper" }, | ||
*/ | ||
default_1$1.defaultProps = defaults; | ||
return default_1$1; | ||
default_1.defaultProps = defaults; | ||
return default_1; | ||
}(Component)); | ||
export default default_1$3; | ||
export default default_1$2; |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) : | ||
typeof define === 'function' && define.amd ? define(['react'], factory) : | ||
(global = global || self, global.Geosuggest = factory(global.React)); | ||
}(this, function (React) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react'), require('classnames'), require('lodash.debounce')) : | ||
typeof define === 'function' && define.amd ? define(['react', 'classnames', 'lodash.debounce'], factory) : | ||
(global = global || self, global.Geosuggest = factory(global.React, global.classnames, global.debounce)); | ||
}(this, (function (React, classnames, debounce) { 'use strict'; | ||
classnames = classnames && Object.prototype.hasOwnProperty.call(classnames, 'default') ? classnames['default'] : classnames; | ||
debounce = debounce && Object.prototype.hasOwnProperty.call(debounce, 'default') ? debounce['default'] : debounce; | ||
/*! ***************************************************************************** | ||
@@ -47,437 +50,4 @@ Copyright (c) Microsoft Corporation. All rights reserved. | ||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
function createCommonjsModule(fn, module) { | ||
return module = { exports: {} }, fn(module, module.exports), module.exports; | ||
} | ||
var classnames = createCommonjsModule(function (module) { | ||
/*! | ||
Copyright (c) 2017 Jed Watson. | ||
Licensed under the MIT License (MIT), see | ||
http://jedwatson.github.io/classnames | ||
*/ | ||
/* global define */ | ||
(function () { | ||
var hasOwn = {}.hasOwnProperty; | ||
function classNames () { | ||
var classes = []; | ||
for (var i = 0; i < arguments.length; i++) { | ||
var arg = arguments[i]; | ||
if (!arg) continue; | ||
var argType = typeof arg; | ||
if (argType === 'string' || argType === 'number') { | ||
classes.push(arg); | ||
} else if (Array.isArray(arg) && arg.length) { | ||
var inner = classNames.apply(null, arg); | ||
if (inner) { | ||
classes.push(inner); | ||
} | ||
} else if (argType === 'object') { | ||
for (var key in arg) { | ||
if (hasOwn.call(arg, key) && arg[key]) { | ||
classes.push(key); | ||
} | ||
} | ||
} | ||
} | ||
return classes.join(' '); | ||
} | ||
if (module.exports) { | ||
classNames.default = classNames; | ||
module.exports = classNames; | ||
} else { | ||
window.classNames = classNames; | ||
} | ||
}()); | ||
}); | ||
/** | ||
* lodash (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
* Copyright jQuery Foundation and other contributors <https://jquery.org/> | ||
* Released under MIT license <https://lodash.com/license> | ||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> | ||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
*/ | ||
/** Used as the `TypeError` message for "Functions" methods. */ | ||
var FUNC_ERROR_TEXT = 'Expected a function'; | ||
/** Used as references for various `Number` constants. */ | ||
var NAN = 0 / 0; | ||
/** `Object#toString` result references. */ | ||
var symbolTag = '[object Symbol]'; | ||
/** Used to match leading and trailing whitespace. */ | ||
var reTrim = /^\s+|\s+$/g; | ||
/** Used to detect bad signed hexadecimal string values. */ | ||
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; | ||
/** Used to detect binary string values. */ | ||
var reIsBinary = /^0b[01]+$/i; | ||
/** Used to detect octal string values. */ | ||
var reIsOctal = /^0o[0-7]+$/i; | ||
/** Built-in method references without a dependency on `root`. */ | ||
var freeParseInt = parseInt; | ||
/** Detect free variable `global` from Node.js. */ | ||
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; | ||
/** Detect free variable `self`. */ | ||
var freeSelf = typeof self == 'object' && self && self.Object === Object && self; | ||
/** Used as a reference to the global object. */ | ||
var root = freeGlobal || freeSelf || Function('return this')(); | ||
/** Used for built-in method references. */ | ||
var objectProto = Object.prototype; | ||
/** | ||
* Used to resolve the | ||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var objectToString = objectProto.toString; | ||
/* Built-in method references for those with the same name as other `lodash` methods. */ | ||
var nativeMax = Math.max, | ||
nativeMin = Math.min; | ||
/** | ||
* Gets the timestamp of the number of milliseconds that have elapsed since | ||
* the Unix epoch (1 January 1970 00:00:00 UTC). | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 2.4.0 | ||
* @category Date | ||
* @returns {number} Returns the timestamp. | ||
* @example | ||
* | ||
* _.defer(function(stamp) { | ||
* console.log(_.now() - stamp); | ||
* }, _.now()); | ||
* // => Logs the number of milliseconds it took for the deferred invocation. | ||
*/ | ||
var now = function() { | ||
return root.Date.now(); | ||
}; | ||
/** | ||
* Creates a debounced function that delays invoking `func` until after `wait` | ||
* milliseconds have elapsed since the last time the debounced function was | ||
* invoked. The debounced function comes with a `cancel` method to cancel | ||
* delayed `func` invocations and a `flush` method to immediately invoke them. | ||
* Provide `options` to indicate whether `func` should be invoked on the | ||
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked | ||
* with the last arguments provided to the debounced function. Subsequent | ||
* calls to the debounced function return the result of the last `func` | ||
* invocation. | ||
* | ||
* **Note:** If `leading` and `trailing` options are `true`, `func` is | ||
* invoked on the trailing edge of the timeout only if the debounced function | ||
* is invoked more than once during the `wait` timeout. | ||
* | ||
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred | ||
* until to the next tick, similar to `setTimeout` with a timeout of `0`. | ||
* | ||
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) | ||
* for details over the differences between `_.debounce` and `_.throttle`. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 0.1.0 | ||
* @category Function | ||
* @param {Function} func The function to debounce. | ||
* @param {number} [wait=0] The number of milliseconds to delay. | ||
* @param {Object} [options={}] The options object. | ||
* @param {boolean} [options.leading=false] | ||
* Specify invoking on the leading edge of the timeout. | ||
* @param {number} [options.maxWait] | ||
* The maximum time `func` is allowed to be delayed before it's invoked. | ||
* @param {boolean} [options.trailing=true] | ||
* Specify invoking on the trailing edge of the timeout. | ||
* @returns {Function} Returns the new debounced function. | ||
* @example | ||
* | ||
* // Avoid costly calculations while the window size is in flux. | ||
* jQuery(window).on('resize', _.debounce(calculateLayout, 150)); | ||
* | ||
* // Invoke `sendMail` when clicked, debouncing subsequent calls. | ||
* jQuery(element).on('click', _.debounce(sendMail, 300, { | ||
* 'leading': true, | ||
* 'trailing': false | ||
* })); | ||
* | ||
* // Ensure `batchLog` is invoked once after 1 second of debounced calls. | ||
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); | ||
* var source = new EventSource('/stream'); | ||
* jQuery(source).on('message', debounced); | ||
* | ||
* // Cancel the trailing debounced invocation. | ||
* jQuery(window).on('popstate', debounced.cancel); | ||
*/ | ||
function debounce(func, wait, options) { | ||
var lastArgs, | ||
lastThis, | ||
maxWait, | ||
result, | ||
timerId, | ||
lastCallTime, | ||
lastInvokeTime = 0, | ||
leading = false, | ||
maxing = false, | ||
trailing = true; | ||
if (typeof func != 'function') { | ||
throw new TypeError(FUNC_ERROR_TEXT); | ||
} | ||
wait = toNumber(wait) || 0; | ||
if (isObject(options)) { | ||
leading = !!options.leading; | ||
maxing = 'maxWait' in options; | ||
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; | ||
trailing = 'trailing' in options ? !!options.trailing : trailing; | ||
} | ||
function invokeFunc(time) { | ||
var args = lastArgs, | ||
thisArg = lastThis; | ||
lastArgs = lastThis = undefined; | ||
lastInvokeTime = time; | ||
result = func.apply(thisArg, args); | ||
return result; | ||
} | ||
function leadingEdge(time) { | ||
// Reset any `maxWait` timer. | ||
lastInvokeTime = time; | ||
// Start the timer for the trailing edge. | ||
timerId = setTimeout(timerExpired, wait); | ||
// Invoke the leading edge. | ||
return leading ? invokeFunc(time) : result; | ||
} | ||
function remainingWait(time) { | ||
var timeSinceLastCall = time - lastCallTime, | ||
timeSinceLastInvoke = time - lastInvokeTime, | ||
result = wait - timeSinceLastCall; | ||
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result; | ||
} | ||
function shouldInvoke(time) { | ||
var timeSinceLastCall = time - lastCallTime, | ||
timeSinceLastInvoke = time - lastInvokeTime; | ||
// Either this is the first call, activity has stopped and we're at the | ||
// trailing edge, the system time has gone backwards and we're treating | ||
// it as the trailing edge, or we've hit the `maxWait` limit. | ||
return (lastCallTime === undefined || (timeSinceLastCall >= wait) || | ||
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); | ||
} | ||
function timerExpired() { | ||
var time = now(); | ||
if (shouldInvoke(time)) { | ||
return trailingEdge(time); | ||
} | ||
// Restart the timer. | ||
timerId = setTimeout(timerExpired, remainingWait(time)); | ||
} | ||
function trailingEdge(time) { | ||
timerId = undefined; | ||
// Only invoke if we have `lastArgs` which means `func` has been | ||
// debounced at least once. | ||
if (trailing && lastArgs) { | ||
return invokeFunc(time); | ||
} | ||
lastArgs = lastThis = undefined; | ||
return result; | ||
} | ||
function cancel() { | ||
if (timerId !== undefined) { | ||
clearTimeout(timerId); | ||
} | ||
lastInvokeTime = 0; | ||
lastArgs = lastCallTime = lastThis = timerId = undefined; | ||
} | ||
function flush() { | ||
return timerId === undefined ? result : trailingEdge(now()); | ||
} | ||
function debounced() { | ||
var time = now(), | ||
isInvoking = shouldInvoke(time); | ||
lastArgs = arguments; | ||
lastThis = this; | ||
lastCallTime = time; | ||
if (isInvoking) { | ||
if (timerId === undefined) { | ||
return leadingEdge(lastCallTime); | ||
} | ||
if (maxing) { | ||
// Handle invocations in a tight loop. | ||
timerId = setTimeout(timerExpired, wait); | ||
return invokeFunc(lastCallTime); | ||
} | ||
} | ||
if (timerId === undefined) { | ||
timerId = setTimeout(timerExpired, wait); | ||
} | ||
return result; | ||
} | ||
debounced.cancel = cancel; | ||
debounced.flush = flush; | ||
return debounced; | ||
} | ||
/** | ||
* Checks if `value` is the | ||
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) | ||
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 0.1.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is an object, else `false`. | ||
* @example | ||
* | ||
* _.isObject({}); | ||
* // => true | ||
* | ||
* _.isObject([1, 2, 3]); | ||
* // => true | ||
* | ||
* _.isObject(_.noop); | ||
* // => true | ||
* | ||
* _.isObject(null); | ||
* // => false | ||
*/ | ||
function isObject(value) { | ||
var type = typeof value; | ||
return !!value && (type == 'object' || type == 'function'); | ||
} | ||
/** | ||
* Checks if `value` is object-like. A value is object-like if it's not `null` | ||
* and has a `typeof` result of "object". | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is object-like, else `false`. | ||
* @example | ||
* | ||
* _.isObjectLike({}); | ||
* // => true | ||
* | ||
* _.isObjectLike([1, 2, 3]); | ||
* // => true | ||
* | ||
* _.isObjectLike(_.noop); | ||
* // => false | ||
* | ||
* _.isObjectLike(null); | ||
* // => false | ||
*/ | ||
function isObjectLike(value) { | ||
return !!value && typeof value == 'object'; | ||
} | ||
/** | ||
* Checks if `value` is classified as a `Symbol` primitive or object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`. | ||
* @example | ||
* | ||
* _.isSymbol(Symbol.iterator); | ||
* // => true | ||
* | ||
* _.isSymbol('abc'); | ||
* // => false | ||
*/ | ||
function isSymbol(value) { | ||
return typeof value == 'symbol' || | ||
(isObjectLike(value) && objectToString.call(value) == symbolTag); | ||
} | ||
/** | ||
* Converts `value` to a number. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to process. | ||
* @returns {number} Returns the number. | ||
* @example | ||
* | ||
* _.toNumber(3.2); | ||
* // => 3.2 | ||
* | ||
* _.toNumber(Number.MIN_VALUE); | ||
* // => 5e-324 | ||
* | ||
* _.toNumber(Infinity); | ||
* // => Infinity | ||
* | ||
* _.toNumber('3.2'); | ||
* // => 3.2 | ||
*/ | ||
function toNumber(value) { | ||
if (typeof value == 'number') { | ||
return value; | ||
} | ||
if (isSymbol(value)) { | ||
return NAN; | ||
} | ||
if (isObject(value)) { | ||
var other = typeof value.valueOf == 'function' ? value.valueOf() : value; | ||
value = isObject(other) ? (other + '') : other; | ||
} | ||
if (typeof value != 'string') { | ||
return value === 0 ? value : +value; | ||
} | ||
value = value.replace(reTrim, ''); | ||
var isBinary = reIsBinary.test(value); | ||
return (isBinary || reIsOctal.test(value)) | ||
? freeParseInt(value.slice(2), isBinary ? 2 : 8) | ||
: (reIsBadHex.test(value) ? NAN : +value); | ||
} | ||
var lodash_debounce = debounce; | ||
/* istanbul ignore next */ | ||
/* tslint:disable:no-empty */ | ||
/* eslint-disable @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-empty-function */ | ||
/** | ||
@@ -490,2 +60,3 @@ * Default values | ||
fixtures: [], | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
getSuggestLabel: function (suggest) { return suggest.description; }, | ||
@@ -580,5 +151,7 @@ highlightMatch: true, | ||
var attributes = {}; | ||
allowedAttributes.forEach(function (allowedAttribute) { | ||
if (props[allowedAttribute]) { | ||
attributes[allowedAttribute] = props[allowedAttribute]; | ||
Object.keys(props).forEach(function (attribute) { | ||
var isDataAttribute = attribute.startsWith('data-'); | ||
var isAllowedAttribute = allowedAttributes.includes(attribute); | ||
if (isAllowedAttribute || isDataAttribute) { | ||
attributes[attribute] = props[attribute]; | ||
} | ||
@@ -592,10 +165,10 @@ }); | ||
*/ | ||
var default_1 = /** @class */ (function (_super) { | ||
__extends(default_1, _super); | ||
var Input = /** @class */ (function (_super) { | ||
__extends(Input, _super); | ||
/** | ||
* The constructor. | ||
*/ | ||
function default_1(props) { | ||
function Input(props) { | ||
var _this = _super.call(this, props) || this; | ||
/* tslint:enable:no-empty */ | ||
/* eslint-enable @typescript-eslint/no-empty-function */ | ||
/** | ||
@@ -612,3 +185,3 @@ * The reference to the input element | ||
*/ | ||
default_1.prototype.onChange = function () { | ||
Input.prototype.onChange = function () { | ||
if (this.input) { | ||
@@ -621,3 +194,4 @@ this.props.onChange(this.input.value); | ||
*/ | ||
default_1.prototype.onInputKeyDown = function (event) { | ||
// eslint-disable-next-line complexity | ||
Input.prototype.onInputKeyDown = function (event) { | ||
// Call props.onKeyDown if defined | ||
@@ -657,5 +231,2 @@ // Gives the developer a little bit more control if needed | ||
break; | ||
/* istanbul ignore next */ | ||
default: | ||
break; | ||
} | ||
@@ -666,3 +237,3 @@ }; | ||
*/ | ||
default_1.prototype.focus = function () { | ||
Input.prototype.focus = function () { | ||
if (this.input) { | ||
@@ -675,3 +246,3 @@ this.input.focus(); | ||
*/ | ||
default_1.prototype.blur = function () { | ||
Input.prototype.blur = function () { | ||
if (this.input) { | ||
@@ -684,15 +255,19 @@ this.input.blur(); | ||
*/ | ||
default_1.prototype.render = function () { | ||
Input.prototype.render = function () { | ||
var _this = this; | ||
var attributes = filterInputAttributes(this.props); | ||
var classes = classnames('geosuggest__input', this.props.className); | ||
if (!attributes.tabIndex) { | ||
attributes.tabIndex = 0; | ||
} | ||
return (React.createElement("input", __assign({ className: classes, ref: function (i) { return (_this.input = i); }, type: "text" }, attributes, { value: this.props.value, style: this.props.style, onKeyDown: this.onInputKeyDown, onChange: this.onChange, onKeyPress: this.props.onKeyPress, onFocus: this.props.onFocus, onBlur: this.props.onBlur, role: "combobox", "aria-expanded": !this.props.isSuggestsHidden, "aria-activedescendant": this.props.activeSuggest | ||
? this.props.activeSuggest.placeId | ||
: undefined, "aria-owns": this.props.listId }))); | ||
: // eslint-disable-next-line no-undefined | ||
undefined, "aria-owns": this.props.listId }))); | ||
}; | ||
/* tslint:disable:no-empty */ | ||
/* eslint-disable @typescript-eslint/no-empty-function */ | ||
/** | ||
* Default values for the properties | ||
*/ | ||
default_1.defaultProps = { | ||
Input.defaultProps = { | ||
activeSuggest: null, | ||
@@ -714,3 +289,3 @@ autoComplete: 'nope', | ||
}; | ||
return default_1; | ||
return Input; | ||
}(React.PureComponent)); | ||
@@ -721,3 +296,3 @@ | ||
*/ | ||
var default_1$1 = /** @class */ (function (_super) { | ||
var default_1 = /** @class */ (function (_super) { | ||
__extends(default_1, _super); | ||
@@ -806,4 +381,4 @@ /** | ||
default_1.prototype.render = function () { | ||
var _a; | ||
var _this = this; | ||
var _a; | ||
var suggest = this.props.suggest; | ||
@@ -830,5 +405,5 @@ var classes = classnames('geosuggest__item', this.props.className, this.props.suggestItemClassName, { 'geosuggest__item--active': this.props.isActive }, (_a = {}, | ||
*/ | ||
var default_1$2 = /** @class */ (function (_super) { | ||
__extends(default_1, _super); | ||
function default_1() { | ||
var default_1$1 = /** @class */ (function (_super) { | ||
__extends(default_1$1, _super); | ||
function default_1$1() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
@@ -839,3 +414,3 @@ } | ||
*/ | ||
default_1.prototype.isHidden = function () { | ||
default_1$1.prototype.isHidden = function () { | ||
return this.props.isHidden || this.props.suggests.length === 0; | ||
@@ -846,3 +421,3 @@ }; | ||
*/ | ||
default_1.prototype.componentDidUpdate = function (prevProps) { | ||
default_1$1.prototype.componentDidUpdate = function (prevProps) { | ||
if (prevProps.suggests !== this.props.suggests) { | ||
@@ -858,5 +433,5 @@ if (this.props.suggests.length === 0) { | ||
*/ | ||
default_1.prototype.render = function () { | ||
default_1$1.prototype.render = function () { | ||
var _a; | ||
var _this = this; | ||
var _a; | ||
var classes = classnames('geosuggest__suggests', this.props.suggestsClassName, { 'geosuggest__suggests--hidden': this.isHidden() }, (_a = {}, | ||
@@ -871,6 +446,6 @@ _a[this.props.hiddenClassName || ''] = this.props.hiddenClassName | ||
false; | ||
return (React.createElement(default_1$1, { key: suggest.placeId, className: suggest.className || '', userInput: _this.props.userInput, isHighlightMatch: _this.props.isHighlightMatch, suggest: suggest, style: _this.props.suggestItemStyle, suggestItemClassName: _this.props.suggestItemClassName, isActive: isActive, activeClassName: _this.props.suggestItemActiveClassName, onMouseDown: _this.props.onSuggestMouseDown, onMouseOut: _this.props.onSuggestMouseOut, onSelect: _this.props.onSuggestSelect, renderSuggestItem: _this.props.renderSuggestItem })); | ||
return (React.createElement(default_1, { key: suggest.placeId, className: suggest.className || '', userInput: _this.props.userInput, isHighlightMatch: _this.props.isHighlightMatch, suggest: suggest, style: _this.props.suggestItemStyle, suggestItemClassName: _this.props.suggestItemClassName, isActive: isActive, activeClassName: _this.props.suggestItemActiveClassName, onMouseDown: _this.props.onSuggestMouseDown, onMouseOut: _this.props.onSuggestMouseOut, onSelect: _this.props.onSuggestSelect, renderSuggestItem: _this.props.renderSuggestItem })); | ||
}))); | ||
}; | ||
return default_1; | ||
return default_1$1; | ||
}(React.PureComponent)); | ||
@@ -886,8 +461,9 @@ | ||
*/ | ||
var default_1$3 = /** @class */ (function (_super) { | ||
__extends(default_1$1, _super); | ||
var default_1$2 = /** @class */ (function (_super) { | ||
__extends(default_1, _super); | ||
/** | ||
* The constructor. Sets the initial state. | ||
*/ | ||
function default_1$1(props) { | ||
// eslint-disable-next-line max-statements | ||
function default_1(props) { | ||
var _this = _super.call(this, props) || this; | ||
@@ -897,2 +473,3 @@ /** | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
_this.googleMaps = null; | ||
@@ -939,7 +516,5 @@ /** | ||
_this.selectSuggest = _this.selectSuggest.bind(_this); | ||
_this.listId = "geosuggest__list_" + Math.random() | ||
.toString(16) | ||
.slice(2); | ||
_this.listId = "geosuggest__list_" + Math.random().toString(16).slice(2); | ||
if (props.queryDelay) { | ||
_this.onAfterInputChange = lodash_debounce(_this.onAfterInputChange, props.queryDelay); | ||
_this.onAfterInputChange = debounce(_this.onAfterInputChange, props.queryDelay); | ||
} | ||
@@ -951,6 +526,9 @@ return _this; | ||
*/ | ||
default_1$1.prototype.componentDidUpdate = function (prevProps) { | ||
default_1.prototype.componentDidUpdate = function (prevProps) { | ||
if (prevProps.initialValue !== this.props.initialValue) { | ||
this.setState({ userInput: this.props.initialValue || '' }); | ||
} | ||
if (JSON.stringify(prevProps.fixtures) !== JSON.stringify(this.props.fixtures)) { | ||
this.searchSuggests(); | ||
} | ||
}; | ||
@@ -962,3 +540,3 @@ /** | ||
*/ | ||
default_1$1.prototype.componentDidMount = function () { | ||
default_1.prototype.componentDidMount = function () { | ||
if (typeof window === 'undefined') { | ||
@@ -968,2 +546,3 @@ return; | ||
var googleMaps = this.props.googleMaps || | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(window.google && window.google.maps) || | ||
@@ -974,3 +553,3 @@ this.googleMaps; | ||
if (console) { | ||
// tslint:disable-next-line:no-console | ||
// eslint-disable-next-line no-console | ||
console.error('Google maps API was not found in the page.'); | ||
@@ -989,3 +568,3 @@ } | ||
*/ | ||
default_1$1.prototype.componentWillUnmount = function () { | ||
default_1.prototype.componentWillUnmount = function () { | ||
clearTimeout(this.timer); | ||
@@ -996,3 +575,3 @@ }; | ||
*/ | ||
default_1$1.prototype.onInputChange = function (userInput) { | ||
default_1.prototype.onInputChange = function (userInput) { | ||
if (!userInput) { | ||
@@ -1008,3 +587,3 @@ if (this.props.onSuggestSelect) { | ||
*/ | ||
default_1$1.prototype.onAfterInputChange = function () { | ||
default_1.prototype.onAfterInputChange = function () { | ||
this.showSuggests(); | ||
@@ -1018,3 +597,3 @@ if (this.props.onChange) { | ||
*/ | ||
default_1$1.prototype.onInputFocus = function () { | ||
default_1.prototype.onInputFocus = function () { | ||
if (this.props.onFocus) { | ||
@@ -1028,3 +607,3 @@ this.props.onFocus(); | ||
*/ | ||
default_1$1.prototype.onInputBlur = function () { | ||
default_1.prototype.onInputBlur = function () { | ||
if (!this.state.ignoreBlur) { | ||
@@ -1034,18 +613,18 @@ this.hideSuggests(); | ||
}; | ||
default_1$1.prototype.onNext = function () { | ||
default_1.prototype.onNext = function () { | ||
this.activateSuggest('next'); | ||
}; | ||
default_1$1.prototype.onPrev = function () { | ||
default_1.prototype.onPrev = function () { | ||
this.activateSuggest('prev'); | ||
}; | ||
default_1$1.prototype.onSelect = function () { | ||
default_1.prototype.onSelect = function () { | ||
this.selectSuggest(this.state.activeSuggest); | ||
}; | ||
default_1$1.prototype.onSuggestMouseDown = function () { | ||
default_1.prototype.onSuggestMouseDown = function () { | ||
this.setState({ ignoreBlur: true }); | ||
}; | ||
default_1$1.prototype.onSuggestMouseOut = function () { | ||
default_1.prototype.onSuggestMouseOut = function () { | ||
this.setState({ ignoreBlur: false }); | ||
}; | ||
default_1$1.prototype.onSuggestNoResults = function () { | ||
default_1.prototype.onSuggestNoResults = function () { | ||
if (this.props.onSuggestNoResults) { | ||
@@ -1058,3 +637,3 @@ this.props.onSuggestNoResults(this.state.userInput); | ||
*/ | ||
default_1$1.prototype.focus = function () { | ||
default_1.prototype.focus = function () { | ||
if (this.input) { | ||
@@ -1067,3 +646,3 @@ this.input.focus(); | ||
*/ | ||
default_1$1.prototype.blur = function () { | ||
default_1.prototype.blur = function () { | ||
if (this.input) { | ||
@@ -1076,3 +655,3 @@ this.input.blur(); | ||
*/ | ||
default_1$1.prototype.update = function (userInput) { | ||
default_1.prototype.update = function (userInput) { | ||
this.setState({ userInput: userInput }); | ||
@@ -1086,3 +665,3 @@ if (this.props.onChange) { | ||
*/ | ||
default_1$1.prototype.clear = function () { | ||
default_1.prototype.clear = function () { | ||
this.setState({ userInput: '' }, this.hideSuggests); | ||
@@ -1093,3 +672,4 @@ }; | ||
*/ | ||
default_1$1.prototype.searchSuggests = function () { | ||
// eslint-disable-next-line complexity, max-statements | ||
default_1.prototype.searchSuggests = function () { | ||
var _this = this; | ||
@@ -1107,6 +687,7 @@ if (!this.state.userInput) { | ||
if (isShorterThanMinLength) { | ||
this.updateSuggests(); | ||
return; | ||
} | ||
var _a = this.props, location = _a.location, radius = _a.radius, bounds = _a.bounds, types = _a.types, country = _a.country; | ||
/* tslint:disable:curly */ | ||
/* eslint-disable curly */ | ||
if (location) | ||
@@ -1122,3 +703,3 @@ options.location = location; | ||
options.componentRestrictions = { country: country }; | ||
/* tslint:enable:curly */ | ||
/* eslint-enable curly */ | ||
this.setState({ isLoading: true }, function () { | ||
@@ -1144,4 +725,4 @@ if (!_this.autocompleteService) { | ||
*/ | ||
default_1$1.prototype.updateSuggests = function (suggestsGoogle, | ||
// tslint:disable-next-line:no-empty | ||
default_1.prototype.updateSuggests = function (suggestsGoogle, | ||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-empty-function | ||
callback) { | ||
@@ -1166,3 +747,3 @@ var _this = this; | ||
fixturesSearched++; | ||
suggests.push(__assign({}, fixture, { isFixture: true, matchedSubstrings: { | ||
suggests.push(__assign(__assign({}, fixture), { isFixture: true, matchedSubstrings: { | ||
length: userInput.length, | ||
@@ -1196,3 +777,3 @@ offset: fixture.label.indexOf(userInput) | ||
*/ | ||
default_1$1.prototype.updateActiveSuggest = function (suggests) { | ||
default_1.prototype.updateActiveSuggest = function (suggests) { | ||
if (suggests === void 0) { suggests = []; } | ||
@@ -1213,3 +794,3 @@ var activeSuggest = this.state.activeSuggest; | ||
*/ | ||
default_1$1.prototype.showSuggests = function () { | ||
default_1.prototype.showSuggests = function () { | ||
this.searchSuggests(); | ||
@@ -1221,3 +802,3 @@ this.setState({ isSuggestsHidden: false }); | ||
*/ | ||
default_1$1.prototype.hideSuggests = function () { | ||
default_1.prototype.hideSuggests = function () { | ||
var _this = this; | ||
@@ -1237,3 +818,4 @@ if (this.props.onBlur) { | ||
*/ | ||
default_1$1.prototype.activateSuggest = function (direction) { | ||
// eslint-disable-next-line complexity, max-statements | ||
default_1.prototype.activateSuggest = function (direction) { | ||
if (this.state.isSuggestsHidden) { | ||
@@ -1267,3 +849,4 @@ this.showSuggests(); | ||
*/ | ||
default_1$1.prototype.selectSuggest = function (suggestToSelect) { | ||
// eslint-disable-next-line complexity | ||
default_1.prototype.selectSuggest = function (suggestToSelect) { | ||
var suggest = suggestToSelect || { | ||
@@ -1297,3 +880,3 @@ isFixture: false, | ||
*/ | ||
default_1$1.prototype.geocodeSuggest = function (suggestToGeocode) { | ||
default_1.prototype.geocodeSuggest = function (suggestToGeocode) { | ||
var _this = this; | ||
@@ -1306,2 +889,3 @@ if (!this.geocoder) { | ||
this.placesService) { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var options = { | ||
@@ -1312,3 +896,4 @@ placeId: suggestToGeocode.placeId, | ||
if (this.props.placeDetailFields) { | ||
options.fields = ['geometry'].concat(this.props.placeDetailFields); | ||
options.fields = this.props.placeDetailFields; | ||
options.fields.unshift('geometry'); | ||
} | ||
@@ -1320,3 +905,3 @@ this.placesService.getDetails(options, function (results, status) { | ||
gmaps.geometry.location); | ||
var suggest = __assign({}, suggestToGeocode, { gmaps: gmaps, location: { | ||
var suggest = __assign(__assign({}, suggestToGeocode), { gmaps: gmaps, location: { | ||
lat: location_1.lat(), | ||
@@ -1338,3 +923,4 @@ lng: location_1.lng() | ||
? { country: this.props.country } | ||
: undefined, | ||
: // eslint-disable-next-line no-undefined | ||
undefined, | ||
location: this.props.location | ||
@@ -1347,3 +933,3 @@ }; | ||
gmaps.geometry.location); | ||
var suggest = __assign({}, suggestToGeocode, { gmaps: gmaps, location: { | ||
var suggest = __assign(__assign({}, suggestToGeocode), { gmaps: gmaps, location: { | ||
lat: location_2.lat(), | ||
@@ -1362,3 +948,3 @@ lng: location_2.lng() | ||
*/ | ||
default_1$1.prototype.render = function () { | ||
default_1.prototype.render = function () { | ||
var _this = this; | ||
@@ -1370,4 +956,4 @@ var attributes = filterInputAttributes(this.props); | ||
var shouldRenderLabel = this.props.label && attributes.id; | ||
var input = (React.createElement(default_1, __assign({ className: this.props.inputClassName, ref: function (i) { return (_this.input = i); }, value: this.state.userInput, doNotSubmitOnEnter: !this.state.isSuggestsHidden, ignoreTab: this.props.ignoreTab, ignoreEnter: this.props.ignoreEnter, style: this.props.style && this.props.style.input, onChange: this.onInputChange, onFocus: this.onInputFocus, onBlur: this.onInputBlur, onKeyDown: this.props.onKeyDown, onKeyPress: this.props.onKeyPress, onNext: this.onNext, onPrev: this.onPrev, onSelect: this.onSelect, onEscape: this.hideSuggests, isSuggestsHidden: this.state.isSuggestsHidden, activeSuggest: this.state.activeSuggest, listId: this.listId }, attributes))); | ||
var suggestionsList = (React.createElement(default_1$2, { isHidden: this.state.isSuggestsHidden, style: this.props.style && this.props.style.suggests, suggestItemStyle: this.props.style && this.props.style.suggestItem, userInput: this.state.userInput, isHighlightMatch: Boolean(this.props.highlightMatch), suggestsClassName: this.props.suggestsClassName, suggestItemClassName: this.props.suggestItemClassName, suggests: this.state.suggests, hiddenClassName: this.props.suggestsHiddenClassName, suggestItemActiveClassName: this.props.suggestItemActiveClassName, activeSuggest: this.state.activeSuggest, onSuggestNoResults: this.onSuggestNoResults, onSuggestMouseDown: this.onSuggestMouseDown, onSuggestMouseOut: this.onSuggestMouseOut, onSuggestSelect: this.selectSuggest, renderSuggestItem: this.props.renderSuggestItem, listId: this.listId })); | ||
var input = (React.createElement(Input, __assign({ className: this.props.inputClassName, ref: function (i) { return (_this.input = i); }, value: this.state.userInput, doNotSubmitOnEnter: !this.state.isSuggestsHidden, ignoreTab: this.props.ignoreTab, ignoreEnter: this.props.ignoreEnter, style: this.props.style && this.props.style.input, onChange: this.onInputChange, onFocus: this.onInputFocus, onBlur: this.onInputBlur, onKeyDown: this.props.onKeyDown, onKeyPress: this.props.onKeyPress, onNext: this.onNext, onPrev: this.onPrev, onSelect: this.onSelect, onEscape: this.hideSuggests, isSuggestsHidden: this.state.isSuggestsHidden, activeSuggest: this.state.activeSuggest, listId: this.listId }, attributes))); | ||
var suggestionsList = (React.createElement(default_1$1, { isHidden: this.state.isSuggestsHidden, style: this.props.style && this.props.style.suggests, suggestItemStyle: this.props.style && this.props.style.suggestItem, userInput: this.state.userInput, isHighlightMatch: Boolean(this.props.highlightMatch), suggestsClassName: this.props.suggestsClassName, suggestItemClassName: this.props.suggestItemClassName, suggests: this.state.suggests, hiddenClassName: this.props.suggestsHiddenClassName, suggestItemActiveClassName: this.props.suggestItemActiveClassName, activeSuggest: this.state.activeSuggest, onSuggestNoResults: this.onSuggestNoResults, onSuggestMouseDown: this.onSuggestMouseDown, onSuggestMouseOut: this.onSuggestMouseOut, onSuggestSelect: this.selectSuggest, renderSuggestItem: this.props.renderSuggestItem, listId: this.listId })); | ||
return (React.createElement("div", { className: classes }, | ||
@@ -1382,8 +968,8 @@ React.createElement("div", { className: "geosuggest__input-wrapper" }, | ||
*/ | ||
default_1$1.defaultProps = defaults; | ||
return default_1$1; | ||
default_1.defaultProps = defaults; | ||
return default_1; | ||
}(React.Component)); | ||
return default_1$3; | ||
return default_1$2; | ||
})); | ||
}))); |
{ | ||
"name": "react-geosuggest", | ||
"version": "2.12.1", | ||
"version": "2.13.0", | ||
"description": "A React autosuggest for the Google Maps Places API.", | ||
@@ -26,43 +26,46 @@ "main": "module/Geosuggest.umd.js", | ||
"devDependencies": { | ||
"@types/chai": "^4.1.7", | ||
"@types/classnames": "^2.2.7", | ||
"@types/googlemaps": "^3.30.19", | ||
"@types/jsdom": "^12.2.3", | ||
"@rollup/plugin-commonjs": "^11.0.2", | ||
"@rollup/plugin-node-resolve": "^7.1.1", | ||
"@rollup/plugin-replace": "^2.3.1", | ||
"@types/chai": "^4.2.11", | ||
"@types/classnames": "^2.2.10", | ||
"@types/googlemaps": "^3.39.3", | ||
"@types/jsdom": "^16.2.0", | ||
"@types/lodash.debounce": "^4.0.6", | ||
"@types/mocha": "^5.2.6", | ||
"@types/react": "^16.8.12", | ||
"@types/react-dom": "^16.8.3", | ||
"@types/sinon": "^7.0.11", | ||
"@types/mocha": "^7.0.2", | ||
"@types/react": "^16.9.32", | ||
"@types/react-dom": "^16.9.6", | ||
"@types/sinon": "^9.0.0", | ||
"@typescript-eslint/eslint-plugin": "^2.26.0", | ||
"@typescript-eslint/parser": "^2.26.0", | ||
"chai": "^4.2.0", | ||
"conventional-changelog-generator": "0.0.3", | ||
"copyfiles": "^2.1.0", | ||
"cross-env": "^5.2.0", | ||
"gh-pages": "^2.0.1", | ||
"jsdom": "^14.0.0", | ||
"light-server": "^2.6.2", | ||
"mkdirp": "^0.5.1", | ||
"mocha": "^6.2.1", | ||
"copyfiles": "^2.2.0", | ||
"cross-env": "^7.0.2", | ||
"eslint": "^6.8.0", | ||
"eslint-config-prettier": "^6.10.1", | ||
"eslint-plugin-react": "^7.19.0", | ||
"gh-pages": "^2.2.0", | ||
"jsdom": "^16.2.2", | ||
"light-server": "^2.6.4", | ||
"mkdirp": "^1.0.3", | ||
"mocha": "^7.1.1", | ||
"nodecat": "^2.0.0", | ||
"nyc": "^14.1.1", | ||
"prettier": "^1.16.4", | ||
"nyc": "^15.0.0", | ||
"prettier": "^2.0.2", | ||
"prop-types": "^15.7.2", | ||
"react": "^16.8.6", | ||
"react-dom": "^16.8.6", | ||
"rimraf": "^2.6.3", | ||
"rollup": "^1.9.0", | ||
"rollup-plugin-commonjs": "^9.3.4", | ||
"rollup-plugin-node-resolve": "^4.1.0", | ||
"rollup-plugin-peer-deps-external": "^2.2.0", | ||
"rollup-plugin-replace": "^2.1.1", | ||
"rollup-plugin-typescript2": "^0.20.1", | ||
"rollup-plugin-uglify": "^6.0.2", | ||
"sinon": "^7.3.1", | ||
"ts-node": "^8.0.3", | ||
"tslint": "^5.15.0", | ||
"tslint-config-prettier": "^1.18.0", | ||
"typescript": "^3.4.1" | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.3.2", | ||
"rollup-plugin-peer-deps-external": "^2.2.2", | ||
"rollup-plugin-typescript2": "^0.27.0", | ||
"rollup-plugin-uglify": "^6.0.4", | ||
"sinon": "^9.0.1", | ||
"ts-node": "^8.8.1", | ||
"typescript": "^3.8.3" | ||
}, | ||
"scripts": { | ||
"prepublish": "npm run build:module", | ||
"lint": "tslint -c tslint.json ./src/*.tsx ./src/*.ts ./example/src/*.tsx ./test/*.jsx ./test/*.js ./test/fixtures", | ||
"prepublishOnly": "npm run build:module", | ||
"lint": "eslint ./src/*.tsx ./src/*.ts ./example/src/*.tsx ./test/*.tsx ./test/*.ts ./test/fixtures/*.ts", | ||
"pretest": "npm run js:prettier:ci && npm run lint", | ||
@@ -69,0 +72,0 @@ "test": "nyc --include 'src/*' -e .tsx -s npm run unit-test", |
@@ -313,4 +313,5 @@ # React Geosuggest [![Build Status](https://travis-ci.org/ubilabs/react-geosuggest.svg?branch=master)](https://travis-ci.org/ubilabs/react-geosuggest) | ||
All [allowed attributes for `input[type="text"]`](https://github.com/ubilabs/react-geosuggest/blob/master/src/filter-input-attributes.ts#L4) | ||
All [DOM clipboard events](https://facebook.github.io/react/docs/events.html#clipboard-events). | ||
All [DOM clipboard events](https://facebook.github.io/react/docs/events.html#clipboard-events). | ||
All [DOM mouse events](https://facebook.github.io/react/docs/events.html#mouse-events) except for drag & drop. | ||
All [data attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/data-*). | ||
@@ -339,46 +340,40 @@ | ||
```jsx | ||
import React from 'react'; | ||
import React, {useRef} from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import Geosuggest from 'react-geosuggest'; | ||
class App extends React.Component { | ||
/** | ||
* Render the example app | ||
*/ | ||
render() { | ||
var fixtures = [ | ||
{label: 'Old Elbe Tunnel, Hamburg', location: {lat: 53.5459, lng: 9.966576}}, | ||
{label: 'Reeperbahn, Hamburg', location: {lat: 53.5495629, lng: 9.9625838}}, | ||
{label: 'Alster, Hamburg', location: {lat: 53.5610398, lng: 10.0259135}} | ||
]; | ||
const App = () => { | ||
const geosuggestEl = useRef(null); | ||
return ( | ||
<div> | ||
<Geosuggest | ||
ref={el=>this._geoSuggest=el} | ||
placeholder="Start typing!" | ||
initialValue="Hamburg" | ||
fixtures={fixtures} | ||
onSuggestSelect={this.onSuggestSelect} | ||
location={new google.maps.LatLng(53.558572, 9.9278215)} | ||
radius="20" /> | ||
const fixtures = [ | ||
{label: 'New York', location: {lat: 40.7033127, lng: -73.979681}}, | ||
{label: 'Rio', location: {lat: -22.066452, lng: -42.9232368}}, | ||
{label: 'Tokyo', location: {lat: 35.673343, lng: 139.710388}} | ||
]; | ||
{* Buttons to trigger exposed component functions *} | ||
<button onClick={()=>this._geoSuggest.focus()}>Focus</button> | ||
<button onClick={()=>this._geoSuggest.update('New Zealand')}>Update</button> | ||
<button onClick={()=>this._geoSuggest.clear()}>Clear</button> | ||
<button onClick={()=>this._geoSuggest.selectSuggest()}>Search</button> | ||
</div> | ||
) | ||
} | ||
/** | ||
* When a suggest got selected | ||
* @param {Object} suggest The suggest | ||
*/ | ||
onSuggestSelect(suggest) { | ||
console.log(suggest); | ||
} | ||
}); | ||
const onSuggestSelect = (suggest) => console.log(suggest); | ||
return ( | ||
<div> | ||
<Geosuggest | ||
ref={geosuggestEl} | ||
placeholder="Start typing!" | ||
initialValue="Hamburg" | ||
fixtures={fixtures} | ||
onSuggestSelect={onSuggestSelect} | ||
location={new google.maps.LatLng(53.558572, 9.9278215)} | ||
radius="20" /> | ||
{* Buttons to trigger exposed component functions *} | ||
<button onClick={()=>geosuggestEl.current.focus()}>Focus</button> | ||
<button onClick={()=>geosuggestEl.current.update('New Zealand')}>Update</button> | ||
<button onClick={()=>geosuggestEl.current.clear()}>Clear</button> | ||
<button onClick={()=>geosuggestEl.current.selectSuggest()}>Search</button> | ||
</div> | ||
); | ||
}; | ||
ReactDOM.render(<App />, document.getElementById('app')); | ||
@@ -414,3 +409,3 @@ ``` | ||
Issues and pull requests are welcome! | ||
Issues and pull requests are welcome! | ||
Please read the guidelines in [CONTRIBUTING.md](CONTRIBUTING.md) before starting to work on a PR. | ||
@@ -417,0 +412,0 @@ |
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
1005514
859
0
40
3271
413