Socket
Socket
Sign inDemoInstall

react-autosuggest

Package Overview
Dependencies
10
Maintainers
1
Versions
128
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 9.0.0 to 9.0.1

132

dist/Autosuggest.js

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

var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _arrays = require('shallow-equal/arrays');

@@ -78,2 +82,5 @@

document.addEventListener('mousedown', this.onDocumentMouseDown);
this.input = this.autowhatever.input;
this.suggestionsContainer = this.autowhatever.itemsContainer;
}

@@ -107,46 +114,19 @@ }, {

}, {
key: 'inputFocused',
value: function inputFocused(shouldRender) {
this.setState({
isFocused: true,
isCollapsed: !shouldRender
});
}
}, {
key: 'inputBlurred',
value: function inputBlurred(shouldRender) {
this.setState({
isFocused: false,
highlightedSectionIndex: null,
highlightedSuggestionIndex: null,
valueBeforeUpDown: null,
isCollapsed: !shouldRender
});
}
}, {
key: 'inputChanged',
value: function inputChanged(shouldRender) {
this.setState({
highlightedSectionIndex: null,
highlightedSuggestionIndex: null,
valueBeforeUpDown: null,
isCollapsed: !shouldRender
});
}
}, {
key: 'updateHighlightedSuggestion',
value: function updateHighlightedSuggestion(sectionIndex, suggestionIndex, prevValue) {
var valueBeforeUpDown = this.state.valueBeforeUpDown;
this.setState(function (state) {
var valueBeforeUpDown = state.valueBeforeUpDown;
if (suggestionIndex === null) {
valueBeforeUpDown = null;
} else if (valueBeforeUpDown === null && typeof prevValue !== 'undefined') {
valueBeforeUpDown = prevValue;
}
if (suggestionIndex === null) {
valueBeforeUpDown = null;
} else if (valueBeforeUpDown === null && typeof prevValue !== 'undefined') {
valueBeforeUpDown = prevValue;
}
this.setState({
highlightedSectionIndex: sectionIndex,
highlightedSuggestionIndex: suggestionIndex,
valueBeforeUpDown: valueBeforeUpDown
return {
highlightedSectionIndex: sectionIndex,
highlightedSuggestionIndex: suggestionIndex,
valueBeforeUpDown: valueBeforeUpDown
};
});

@@ -158,9 +138,12 @@ }

var shouldResetValueBeforeUpDown = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
var valueBeforeUpDown = this.state.valueBeforeUpDown;
this.setState(function (state) {
var valueBeforeUpDown = state.valueBeforeUpDown;
this.setState({
highlightedSectionIndex: null,
highlightedSuggestionIndex: null,
valueBeforeUpDown: shouldResetValueBeforeUpDown ? null : valueBeforeUpDown
return {
highlightedSectionIndex: null,
highlightedSuggestionIndex: null,
valueBeforeUpDown: shouldResetValueBeforeUpDown ? null : valueBeforeUpDown
};
});

@@ -320,3 +303,7 @@ }

_this2.inputFocused(shouldRender);
_this2.setState({
isFocused: true,
isCollapsed: !shouldRender
});
_onFocus && _onFocus(event);

@@ -348,4 +335,10 @@

_this2.maybeCallOnChange(event, value, 'type');
_this2.inputChanged(shouldRender);
_this2.setState({
highlightedSectionIndex: null,
highlightedSuggestionIndex: null,
valueBeforeUpDown: null,
isCollapsed: !shouldRender
});
if (shouldRender) {

@@ -490,3 +483,3 @@ onSuggestionsFetchRequested({ value: value });

id: id,
ref: this.storeReferences
ref: this.storeAutowhateverRef
});

@@ -500,3 +493,3 @@ }

Autosuggest.propTypes = {
suggestions: _react.PropTypes.array.isRequired,
suggestions: _propTypes2.default.array.isRequired,
onSuggestionsFetchRequested: function onSuggestionsFetchRequested(props, propName) {

@@ -516,7 +509,7 @@ var onSuggestionsFetchRequested = props[propName];

},
onSuggestionSelected: _react.PropTypes.func,
renderInputComponent: _react.PropTypes.func,
renderSuggestionsContainer: _react.PropTypes.func,
getSuggestionValue: _react.PropTypes.func.isRequired,
renderSuggestion: _react.PropTypes.func.isRequired,
onSuggestionSelected: _propTypes2.default.func,
renderInputComponent: _propTypes2.default.func,
renderSuggestionsContainer: _propTypes2.default.func,
getSuggestionValue: _propTypes2.default.func.isRequired,
renderSuggestion: _propTypes2.default.func.isRequired,
inputProps: function inputProps(props, propName) {

@@ -533,5 +526,5 @@ var inputProps = props[propName];

},
shouldRenderSuggestions: _react.PropTypes.func,
alwaysRenderSuggestions: _react.PropTypes.bool,
multiSection: _react.PropTypes.bool,
shouldRenderSuggestions: _propTypes2.default.func,
alwaysRenderSuggestions: _propTypes2.default.bool,
multiSection: _propTypes2.default.bool,
renderSectionTitle: function renderSectionTitle(props, propName) {

@@ -551,6 +544,6 @@ var renderSectionTitle = props[propName];

},
focusInputOnSuggestionClick: _react.PropTypes.bool,
highlightFirstSuggestion: _react.PropTypes.bool,
theme: _react.PropTypes.object,
id: _react.PropTypes.string
focusInputOnSuggestionClick: _propTypes2.default.bool,
highlightFirstSuggestion: _propTypes2.default.bool,
theme: _propTypes2.default.object,
id: _propTypes2.default.string
};

@@ -593,10 +586,5 @@ Autosuggest.defaultProps = {

this.storeReferences = function (autowhatever) {
this.storeAutowhateverRef = function (autowhatever) {
if (autowhatever !== null) {
var input = autowhatever.input,
itemsContainer = autowhatever.itemsContainer;
_this3.input = input;
_this3.suggestionsContainer = itemsContainer;
_this3.autowhatever = autowhatever;
}

@@ -689,4 +677,12 @@ };

var highlightedSuggestion = _this3.getHighlightedSuggestion();
var shouldRender = shouldRenderSuggestions(value);
_this3.inputBlurred(shouldRenderSuggestions(value));
_this3.setState({
isFocused: false,
highlightedSectionIndex: null,
highlightedSuggestionIndex: null,
valueBeforeUpDown: null,
isCollapsed: !shouldRender
});
onBlur && onBlur(_this3.blurEvent, { highlightedSuggestion: highlightedSuggestion });

@@ -693,0 +689,0 @@ };

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React")):"function"==typeof define&&define.amd?define(["React"],t):"object"==typeof exports?exports.Autosuggest=t(require("React")):e.Autosuggest=t(e.React)}(this,function(e){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";e.exports=n(1).default},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},a=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),l=n(2),c=o(l),g=n(3),p=o(g),d=n(4),f=o(d),h=n(13),m=function(){return!0},y=function(e){return e.trim().length>0},v=function(e){var t=e.containerProps,n=e.children;return c.default.createElement("div",t,n)},I=function(e){function t(e){var n=e.alwaysRenderSuggestions;r(this,t);var o=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return S.call(o),o.state={isFocused:!1,isCollapsed:!n,highlightedSectionIndex:null,highlightedSuggestionIndex:null,valueBeforeUpDown:null},o.justPressedUpDown=!1,o}return u(t,e),a(t,[{key:"componentDidMount",value:function(){document.addEventListener("mousedown",this.onDocumentMouseDown)}},{key:"componentWillReceiveProps",value:function(e){(0,p.default)(e.suggestions,this.props.suggestions)?e.highlightFirstSuggestion&&e.suggestions.length>0&&this.justPressedUpDown===!1&&this.highlightFirstSuggestion():this.willRenderSuggestions(e)?(e.highlightFirstSuggestion&&this.highlightFirstSuggestion(),this.state.isCollapsed&&!this.justSelectedSuggestion&&this.revealSuggestions()):this.resetHighlightedSuggestion()}},{key:"componentWillUnmount",value:function(){document.removeEventListener("mousedown",this.onDocumentMouseDown)}},{key:"inputFocused",value:function(e){this.setState({isFocused:!0,isCollapsed:!e})}},{key:"inputBlurred",value:function(e){this.setState({isFocused:!1,highlightedSectionIndex:null,highlightedSuggestionIndex:null,valueBeforeUpDown:null,isCollapsed:!e})}},{key:"inputChanged",value:function(e){this.setState({highlightedSectionIndex:null,highlightedSuggestionIndex:null,valueBeforeUpDown:null,isCollapsed:!e})}},{key:"updateHighlightedSuggestion",value:function(e,t,n){var o=this.state.valueBeforeUpDown;null===t?o=null:null===o&&"undefined"!=typeof n&&(o=n),this.setState({highlightedSectionIndex:e,highlightedSuggestionIndex:t,valueBeforeUpDown:o})}},{key:"resetHighlightedSuggestion",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=this.state.valueBeforeUpDown;this.setState({highlightedSectionIndex:null,highlightedSuggestionIndex:null,valueBeforeUpDown:e?null:t})}},{key:"revealSuggestions",value:function(){this.setState({isCollapsed:!1})}},{key:"closeSuggestions",value:function(){this.setState({highlightedSectionIndex:null,highlightedSuggestionIndex:null,valueBeforeUpDown:null,isCollapsed:!0})}},{key:"getSuggestion",value:function(e,t){var n=this.props,o=n.suggestions,r=n.multiSection,i=n.getSectionSuggestions;return r?i(o[e])[t]:o[t]}},{key:"getHighlightedSuggestion",value:function(){var e=this.state,t=e.highlightedSectionIndex,n=e.highlightedSuggestionIndex;return null===n?null:this.getSuggestion(t,n)}},{key:"getSuggestionValueByIndex",value:function(e,t){var n=this.props.getSuggestionValue;return n(this.getSuggestion(e,t))}},{key:"getSuggestionIndices",value:function(e){var t=e.getAttribute("data-section-index"),n=e.getAttribute("data-suggestion-index");return{sectionIndex:"string"==typeof t?parseInt(t,10):null,suggestionIndex:parseInt(n,10)}}},{key:"findSuggestionElement",value:function(e){var t=e;do{if(null!==t.getAttribute("data-suggestion-index"))return t;t=t.parentNode}while(null!==t);throw console.error("Clicked element:",e),new Error("Couldn't find suggestion element")}},{key:"maybeCallOnChange",value:function(e,t,n){var o=this.props.inputProps,r=o.value,i=o.onChange;t!==r&&i(e,{newValue:t,method:n})}},{key:"willRenderSuggestions",value:function(e){var t=e.suggestions,n=e.inputProps,o=e.shouldRenderSuggestions,r=n.value;return t.length>0&&o(r)}},{key:"getQuery",value:function(){var e=this.props.inputProps,t=e.value,n=this.state.valueBeforeUpDown;return(n||t).trim()}},{key:"render",value:function(){var e=this,t=this.props,n=t.suggestions,o=t.renderInputComponent,r=t.onSuggestionsFetchRequested,i=t.renderSuggestion,u=t.inputProps,a=t.multiSection,l=t.renderSectionTitle,g=t.id,p=t.getSectionSuggestions,d=t.theme,y=t.getSuggestionValue,v=t.alwaysRenderSuggestions,I=this.state,S=I.isFocused,b=I.isCollapsed,w=I.highlightedSectionIndex,P=I.highlightedSuggestionIndex,x=I.valueBeforeUpDown,_=v?m:this.props.shouldRenderSuggestions,C=u.value,O=u.onFocus,T=u.onKeyDown,j=this.willRenderSuggestions(this.props),k=v||S&&!b&&j,R=k?n:[],D=s({},u,{onFocus:function(t){if(!e.justSelectedSuggestion&&!e.justClickedOnSuggestionsContainer){var n=_(C);e.inputFocused(n),O&&O(t),n&&r({value:C})}},onBlur:function(t){return e.justClickedOnSuggestionsContainer?void e.input.focus():(e.blurEvent=t,void(e.justSelectedSuggestion||(e.onBlur(),e.onSuggestionsClearRequested())))},onChange:function(t){var n=t.target.value,o=_(n);e.maybeCallOnChange(t,n,"type"),e.inputChanged(o),o?r({value:n}):e.onSuggestionsClearRequested()},onKeyDown:function(t,o){switch(t.key){case"ArrowDown":case"ArrowUp":if(b)_(C)&&(r({value:C}),e.revealSuggestions());else if(n.length>0){var i=o.newHighlightedSectionIndex,u=o.newHighlightedItemIndex,s=void 0;s=null===u?null===x?C:x:e.getSuggestionValueByIndex(i,u),e.updateHighlightedSuggestion(i,u,C),e.maybeCallOnChange(t,s,"ArrowDown"===t.key?"down":"up")}t.preventDefault(),e.justPressedUpDown=!0,setTimeout(function(){e.justPressedUpDown=!1});break;case"Enter":var a=e.getHighlightedSuggestion();if(k&&!v&&e.closeSuggestions(),null!==a){var l=y(a);e.maybeCallOnChange(t,l,"enter"),e.onSuggestionSelected(t,{suggestion:a,suggestionValue:l,suggestionIndex:P,sectionIndex:w,method:"enter"}),e.justSelectedSuggestion=!0,setTimeout(function(){e.justSelectedSuggestion=!1})}break;case"Escape":k&&t.preventDefault();var c=k&&!v;if(null===x){if(!c){var g="";e.maybeCallOnChange(t,g,"escape"),_(g)?r({value:g}):e.onSuggestionsClearRequested()}}else e.maybeCallOnChange(t,x,"escape");c?(e.onSuggestionsClearRequested(),e.closeSuggestions()):e.resetHighlightedSuggestion()}T&&T(t)}}),E={query:this.getQuery()};return c.default.createElement(f.default,{multiSection:a,items:R,renderInputComponent:o,renderItemsContainer:this.renderSuggestionsContainer,renderItem:i,renderItemData:E,renderSectionTitle:l,getSectionItems:p,highlightedSectionIndex:w,highlightedItemIndex:P,inputProps:D,itemProps:this.itemProps,theme:(0,h.mapToAutowhateverTheme)(d),id:g,ref:this.storeReferences})}}]),t}(l.Component);I.defaultProps={renderSuggestionsContainer:v,shouldRenderSuggestions:y,alwaysRenderSuggestions:!1,multiSection:!1,focusInputOnSuggestionClick:!0,highlightFirstSuggestion:!1,theme:h.defaultTheme,id:"1"};var S=function(){var e=this;this.onDocumentMouseDown=function(t){e.justClickedOnSuggestionsContainer=!1;for(var n=t.detail&&t.detail.target||t.target;null!==n&&n!==document;){if(null!==n.getAttribute("data-suggestion-index"))return;if(n===e.suggestionsContainer)return void(e.justClickedOnSuggestionsContainer=!0);n=n.parentNode}},this.storeReferences=function(t){if(null!==t){var n=t.input,o=t.itemsContainer;e.input=n,e.suggestionsContainer=o}},this.onSuggestionMouseEnter=function(t,n){var o=n.sectionIndex,r=n.itemIndex;e.updateHighlightedSuggestion(o,r)},this.highlightFirstSuggestion=function(){e.updateHighlightedSuggestion(e.props.multiSection?0:null,0)},this.onSuggestionMouseDown=function(){e.justSelectedSuggestion=!0},this.onSuggestionsClearRequested=function(){var t=e.props.onSuggestionsClearRequested;t&&t()},this.onSuggestionSelected=function(t,n){var o=e.props,r=o.alwaysRenderSuggestions,i=o.onSuggestionSelected,u=o.onSuggestionsFetchRequested;i&&i(t,n),r?u({value:n.suggestionValue}):e.onSuggestionsClearRequested(),e.resetHighlightedSuggestion()},this.onSuggestionClick=function(t){var n=e.props,o=n.alwaysRenderSuggestions,r=n.focusInputOnSuggestionClick,i=e.getSuggestionIndices(e.findSuggestionElement(t.target)),u=i.sectionIndex,s=i.suggestionIndex,a=e.getSuggestion(u,s),l=e.props.getSuggestionValue(a);e.maybeCallOnChange(t,l,"click"),e.onSuggestionSelected(t,{suggestion:a,suggestionValue:l,suggestionIndex:s,sectionIndex:u,method:"click"}),o||e.closeSuggestions(),r===!0?e.input.focus():e.onBlur(),setTimeout(function(){e.justSelectedSuggestion=!1})},this.onBlur=function(){var t=e.props,n=t.inputProps,o=t.shouldRenderSuggestions,r=n.value,i=n.onBlur,u=e.getHighlightedSuggestion();e.inputBlurred(o(r)),i&&i(e.blurEvent,{highlightedSuggestion:u})},this.resetHighlightedSuggestionOnMouseLeave=function(){e.resetHighlightedSuggestion(!1)},this.itemProps=function(t){var n=t.sectionIndex,o=t.itemIndex;return{"data-section-index":n,"data-suggestion-index":o,onMouseEnter:e.onSuggestionMouseEnter,onMouseLeave:e.resetHighlightedSuggestionOnMouseLeave,onMouseDown:e.onSuggestionMouseDown,onTouchStart:e.onSuggestionMouseDown,onClick:e.onSuggestionClick}},this.renderSuggestionsContainer=function(t){var n=t.containerProps,o=t.children,r=e.props.renderSuggestionsContainer;return r({containerProps:n,children:o,query:e.getQuery()})}};t.default=I},function(t,n){t.exports=e},function(e,t){e.exports=function(e,t){if(e===t)return!0;var n=e.length;if(t.length!==n)return!1;for(var o=0;o<n;o++)if(e[o]!==t[o])return!1;return!0}},function(e,t,n){"use strict";e.exports=n(5).default},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){var n=[],o=!0,r=!1,i=void 0;try{for(var u,s=e[Symbol.iterator]();!(o=(u=s.next()).done)&&(n.push(u.value),!t||n.length!==t);o=!0);}catch(e){r=!0,i=e}finally{try{!o&&s.return&&s.return()}finally{if(r)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),a=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},c=n(2),g=o(c),p=n(6),d=o(p),f=n(7),h=o(f),m=n(9),y=o(m),v=n(11),I=o(v),S=function(){return!0},b={},w=function(e){return g.default.createElement("input",e)},P=function(e){var t=e.children,n=e.containerProps;return g.default.createElement("div",l({children:t},n))},x={container:"react-autowhatever__container",containerOpen:"react-autowhatever__container--open",input:"react-autowhatever__input",inputOpen:"react-autowhatever__input--open",inputFocused:"react-autowhatever__input--focused",itemsContainer:"react-autowhatever__items-container",itemsContainerOpen:"react-autowhatever__items-container--open",itemsList:"react-autowhatever__items-list",item:"react-autowhatever__item",itemFirst:"react-autowhatever__item--first",itemHighlighted:"react-autowhatever__item--highlighted",sectionContainer:"react-autowhatever__section-container",sectionContainerFirst:"react-autowhatever__section-container--first",sectionTitle:"react-autowhatever__section-title"},_=function(e){function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.storeInputReference=function(e){null!==e&&(n.input=e)},n.storeItemsContainerReference=function(e){null!==e&&(n.itemsContainer=e)},n.onHighlightedItemChange=function(e){n.highlightedItem=e},n.getItemId=function(e,t){if(null===t)return null;var o=n.props.id,r=null===e?"":"section-"+e;return"react-autowhatever-"+o+"-"+r+"-item-"+t},n.onFocus=function(e){var t=n.props.inputProps;n.setState({isInputFocused:!0}),t.onFocus&&t.onFocus(e)},n.onBlur=function(e){var t=n.props.inputProps;n.setState({isInputFocused:!1}),t.onBlur&&t.onBlur(e)},n.onKeyDown=function(e){var t=n.props,o=t.inputProps,r=t.highlightedSectionIndex,i=t.highlightedItemIndex;switch(e.key){case"ArrowDown":case"ArrowUp":var u="ArrowDown"===e.key?"next":"prev",a=n.sectionIterator[u]([r,i]),l=s(a,2),c=l[0],g=l[1];o.onKeyDown(e,{newHighlightedSectionIndex:c,newHighlightedItemIndex:g});break;default:o.onKeyDown(e,{highlightedSectionIndex:r,highlightedItemIndex:i})}},n.highlightedItem=null,n.state={isInputFocused:!1},n.setSectionsItems(e),n.setSectionIterator(e),n.setTheme(e),n}return u(t,e),a(t,[{key:"componentDidMount",value:function(){this.ensureHighlightedItemIsVisible()}},{key:"componentWillReceiveProps",value:function(e){e.items!==this.props.items&&this.setSectionsItems(e),e.items===this.props.items&&e.multiSection===this.props.multiSection||this.setSectionIterator(e),e.theme!==this.props.theme&&this.setTheme(e)}},{key:"componentDidUpdate",value:function(){this.ensureHighlightedItemIsVisible()}},{key:"setSectionsItems",value:function(e){e.multiSection&&(this.sectionsItems=e.items.map(function(t){return e.getSectionItems(t)}),this.sectionsLengths=this.sectionsItems.map(function(e){return e.length}),this.allSectionsAreEmpty=this.sectionsLengths.every(function(e){return 0===e}))}},{key:"setSectionIterator",value:function(e){this.sectionIterator=(0,d.default)({multiSection:e.multiSection,data:e.multiSection?this.sectionsLengths:e.items.length})}},{key:"setTheme",value:function(e){this.theme=(0,h.default)(e.theme)}},{key:"renderSections",value:function(){var e=this;if(this.allSectionsAreEmpty)return null;var t=this.theme,n=this.props,o=n.id,r=n.items,i=n.renderItem,u=n.renderItemData,s=n.shouldRenderSection,a=n.renderSectionTitle,l=n.highlightedSectionIndex,c=n.highlightedItemIndex,p=n.itemProps;return r.map(function(n,r){if(!s(n))return null;var d="react-autowhatever-"+o+"-",f=d+"section-"+r+"-",h=0===r;return g.default.createElement("div",t(f+"container","sectionContainer",h&&"sectionContainerFirst"),g.default.createElement(y.default,{section:n,renderSectionTitle:a,theme:t,sectionKeyPrefix:f}),g.default.createElement(I.default,{items:e.sectionsItems[r],itemProps:p,renderItem:i,renderItemData:u,sectionIndex:r,highlightedItemIndex:l===r?c:null,onHighlightedItemChange:e.onHighlightedItemChange,getItemId:e.getItemId,theme:t,keyPrefix:d,ref:e.storeItemsListReference}))})}},{key:"renderItems",value:function(){var e=this.props.items;if(0===e.length)return null;var t=this.theme,n=this.props,o=n.id,r=n.renderItem,i=n.renderItemData,u=n.highlightedSectionIndex,s=n.highlightedItemIndex,a=n.itemProps;return g.default.createElement(I.default,{items:e,itemProps:a,renderItem:r,renderItemData:i,highlightedItemIndex:null===u?s:null,onHighlightedItemChange:this.onHighlightedItemChange,getItemId:this.getItemId,theme:t,keyPrefix:"react-autowhatever-"+o+"-"})}},{key:"ensureHighlightedItemIsVisible",value:function(){var e=this.highlightedItem;if(e){var t=this.itemsContainer,n=e.offsetParent===t?e.offsetTop:e.offsetTop-t.offsetTop,o=t.scrollTop;n<o?o=n:n+e.offsetHeight>o+t.offsetHeight&&(o=n+e.offsetHeight-t.offsetHeight),o!==t.scrollTop&&(t.scrollTop=o)}}},{key:"render",value:function(){var e=this.theme,t=this.props,n=t.id,o=t.multiSection,r=t.renderInputComponent,i=t.renderItemsContainer,u=t.highlightedSectionIndex,s=t.highlightedItemIndex,a=this.state.isInputFocused,c=o?this.renderSections():this.renderItems(),p=null!==c,d=this.getItemId(u,s),f=e("react-autowhatever-"+n+"-container","container",p&&"containerOpen"),h="react-autowhatever-"+n,m=r(l({type:"text",value:"",autoComplete:"off",role:"combobox","aria-autocomplete":"list","aria-owns":h,"aria-expanded":p,"aria-haspopup":p,"aria-activedescendant":d},e("react-autowhatever-"+n+"-input","input",p&&"inputOpen",a&&"inputFocused"),this.props.inputProps,{onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.props.inputProps.onKeyDown&&this.onKeyDown,ref:this.storeInputReference})),y=i({children:c,containerProps:l({id:h},e("react-autowhatever-"+n+"-items-container","itemsContainer",p&&"itemsContainerOpen"),{ref:this.storeItemsContainerReference})});return g.default.createElement("div",f,m,y)}}]),t}(c.Component);_.propTypes={id:c.PropTypes.string,multiSection:c.PropTypes.bool,renderInputComponent:c.PropTypes.func,renderItemsContainer:c.PropTypes.func,items:c.PropTypes.array.isRequired,renderItem:c.PropTypes.func,renderItemData:c.PropTypes.object,shouldRenderSection:c.PropTypes.func,renderSectionTitle:c.PropTypes.func,getSectionItems:c.PropTypes.func,inputProps:c.PropTypes.object,itemProps:c.PropTypes.oneOfType([c.PropTypes.object,c.PropTypes.func]),highlightedSectionIndex:c.PropTypes.number,highlightedItemIndex:c.PropTypes.number,theme:c.PropTypes.oneOfType([c.PropTypes.object,c.PropTypes.array])},_.defaultProps={id:"1",multiSection:!1,renderInputComponent:w,renderItemsContainer:P,shouldRenderSection:S,renderItem:function(){throw new Error("`renderItem` must be provided")},renderItemData:b,renderSectionTitle:function(){throw new Error("`renderSectionTitle` must be provided")},getSectionItems:function(){throw new Error("`getSectionItems` must be provided")},inputProps:b,itemProps:b,highlightedSectionIndex:null,highlightedItemIndex:null,theme:x},t.default=_},function(e,t){"use strict";var n=function(){function e(e,t){var n=[],o=!0,r=!1,i=void 0;try{for(var u,s=e[Symbol.iterator]();!(o=(u=s.next()).done)&&(n.push(u.value),!t||n.length!==t);o=!0);}catch(e){r=!0,i=e}finally{try{!o&&s.return&&s.return()}finally{if(r)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();e.exports=function(e){function t(e){for(null===e?e=0:e++;e<s.length&&0===s[e];)e++;return e===s.length?null:e}function o(e){for(null===e?e=s.length-1:e--;e>=0&&0===s[e];)e--;return e===-1?null:e}function r(e){var o=n(e,2),r=o[0],i=o[1];return a?null===i||i===s[r]-1?(r=t(r),null===r?[null,null]:[r,0]):[r,i+1]:0===s||i===s-1?[null,null]:null===i?[null,0]:[null,i+1]}function i(e){var t=n(e,2),r=t[0],i=t[1];return a?null===i||0===i?(r=o(r),null===r?[null,null]:[r,s[r]-1]):[r,i-1]:0===s||0===i?[null,null]:null===i?[null,s-1]:[null,i-1]}function u(e){return null===r(e)[1]}var s=e.data,a=e.multiSection;return{next:r,prev:i,isLast:u}}},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){var n=[],o=!0,r=!1,i=void 0;try{for(var u,s=e[Symbol.iterator]();!(o=(u=s.next()).done)&&(n.push(u.value),!t||n.length!==t);o=!0);}catch(e){r=!0,i=e}finally{try{!o&&s.return&&s.return()}finally{if(r)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),u=n(8),s=o(u),a=function(e){return e};t.default=function(e){var t=Array.isArray(e)&&2===e.length?e:[e,null],n=i(t,2),o=n[0],u=n[1];return function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];var l=n.map(function(e){return o[e]}).filter(a);return"string"==typeof l[0]||"function"==typeof u?{key:e,className:u?u.apply(void 0,r(l)):l.join(" ")}:{key:e,style:s.default.apply(void 0,[{}].concat(r(l)))}}},e.exports=t.default},function(e,t){"use strict";function n(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function o(e){var t=Object.getOwnPropertyNames(e);return Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(e))),t.filter(function(t){return r.call(e,t)})}var r=Object.prototype.propertyIsEnumerable;e.exports=Object.assign||function(e,t){for(var r,i,u=n(e),s=1;s<arguments.length;s++){r=arguments[s],i=o(Object(r));for(var a=0;a<i.length;a++)u[i[a]]=r[i[a]]}return u}},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),a=n(2),l=o(a),c=n(10),g=o(c),p=function(e){function t(){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,e),s(t,[{key:"shouldComponentUpdate",value:function(e){return(0,g.default)(e,this.props)}},{key:"render",value:function(){var e=this.props,t=e.section,n=e.renderSectionTitle,o=e.theme,r=e.sectionKeyPrefix,i=n(t);return i?l.default.createElement("div",o(r+"title","sectionTitle"),i):null}}]),t}(a.Component);p.propTypes={section:a.PropTypes.any.isRequired,renderSectionTitle:a.PropTypes.func.isRequired,theme:a.PropTypes.func.isRequired,sectionKeyPrefix:a.PropTypes.string.isRequired},t.default=p},function(e,t){"use strict";function n(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(e===t)return!1;var r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!0;var u={},s=void 0,a=void 0;for(s=0,a=n.length;s<a;s++)u[n[s]]=!0;for(s=0,a=r.length;s<a;s++){var l=r[s],c=e[l],g=t[l];if(c!==g){if(!u[l]||null===c||null===g||"object"!==("undefined"==typeof c?"undefined":o(c))||"object"!==("undefined"==typeof g?"undefined":o(g)))return!0;var p=Object.keys(c),d=Object.keys(g);if(p.length!==d.length)return!0;for(var f=0,h=p.length;f<h;f++){var m=p[f];if(c[m]!==g[m])return!0}}}return!1}Object.defineProperty(t,"__esModule",{value:!0});var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.default=n},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},a=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),l=n(2),c=o(l),g=n(12),p=o(g),d=n(10),f=o(d),h=function(e){function t(){var e,n,o,u;r(this,t);for(var s=arguments.length,a=Array(s),l=0;l<s;l++)a[l]=arguments[l];return n=o=i(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(a))),o.storeHighlightedItemReference=function(e){o.props.onHighlightedItemChange(null===e?null:e.item)},u=n,i(o,u)}return u(t,e),a(t,[{key:"shouldComponentUpdate",value:function(e){return(0,f.default)(e,this.props,["itemProps"])}},{key:"render",value:function(){var e=this,t=this.props,n=t.items,o=t.itemProps,r=t.renderItem,i=t.renderItemData,u=t.sectionIndex,a=t.highlightedItemIndex,l=t.getItemId,g=t.theme,d=t.keyPrefix,f=null===u?d:d+"section-"+u+"-",h="function"==typeof o;return c.default.createElement("ul",s({role:"listbox"},g(f+"items-list","itemsList")),n.map(function(t,n){var d=0===n,m=n===a,y=f+"item-"+n,v=h?o({sectionIndex:u,itemIndex:n}):o,I=s({id:l(u,n)},g(y,"item",d&&"itemFirst",m&&"itemHighlighted"),v);return m&&(I.ref=e.storeHighlightedItemReference),c.default.createElement(p.default,s({},I,{sectionIndex:u,itemIndex:n,item:t,renderItem:r,renderItemData:i}))}))}}]),t}(l.Component);h.propTypes={items:l.PropTypes.array.isRequired,itemProps:l.PropTypes.oneOfType([l.PropTypes.object,l.PropTypes.func]),renderItem:l.PropTypes.func.isRequired,renderItemData:l.PropTypes.object.isRequired,sectionIndex:l.PropTypes.number,highlightedItemIndex:l.PropTypes.number,onHighlightedItemChange:l.PropTypes.func.isRequired,getItemId:l.PropTypes.func.isRequired,theme:l.PropTypes.func.isRequired,keyPrefix:l.PropTypes.string.isRequired},h.defaultProps={sectionIndex:null},t.default=h},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){var n={};for(var o in e)t.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o]);return n}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),c=n(2),g=o(c),p=n(10),d=o(p),f=function(e){function t(){var e,n,o,r;i(this,t);for(var s=arguments.length,a=Array(s),l=0;l<s;l++)a[l]=arguments[l];return n=o=u(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(a))),o.storeItemReference=function(e){null!==e&&(o.item=e)},o.onMouseEnter=function(e){var t=o.props,n=t.sectionIndex,r=t.itemIndex;o.props.onMouseEnter(e,{sectionIndex:n,itemIndex:r})},o.onMouseLeave=function(e){var t=o.props,n=t.sectionIndex,r=t.itemIndex;o.props.onMouseLeave(e,{sectionIndex:n,itemIndex:r})},o.onMouseDown=function(e){var t=o.props,n=t.sectionIndex,r=t.itemIndex;o.props.onMouseDown(e,{sectionIndex:n,itemIndex:r})},o.onClick=function(e){var t=o.props,n=t.sectionIndex,r=t.itemIndex;o.props.onClick(e,{sectionIndex:n,itemIndex:r})},r=n,u(o,r)}return s(t,e),l(t,[{key:"shouldComponentUpdate",value:function(e){return(0,d.default)(e,this.props,["renderItemData"])}},{key:"render",value:function(){var e=this.props,t=e.item,n=e.renderItem,o=e.renderItemData,i=r(e,["item","renderItem","renderItemData"]);return delete i.sectionIndex,delete i.itemIndex,"function"==typeof i.onMouseEnter&&(i.onMouseEnter=this.onMouseEnter),"function"==typeof i.onMouseLeave&&(i.onMouseLeave=this.onMouseLeave),"function"==typeof i.onMouseDown&&(i.onMouseDown=this.onMouseDown),"function"==typeof i.onClick&&(i.onClick=this.onClick),g.default.createElement("li",a({role:"option"},i,{ref:this.storeItemReference}),n(t,o))}}]),t}(c.Component);f.propTypes={sectionIndex:c.PropTypes.number,itemIndex:c.PropTypes.number.isRequired,item:c.PropTypes.any.isRequired,renderItem:c.PropTypes.func.isRequired,renderItemData:c.PropTypes.object.isRequired,onMouseEnter:c.PropTypes.func,onMouseLeave:c.PropTypes.func,onMouseDown:c.PropTypes.func,onClick:c.PropTypes.func},t.default=f},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.defaultTheme={container:"react-autosuggest__container",containerOpen:"react-autosuggest__container--open",input:"react-autosuggest__input",inputOpen:"react-autosuggest__input--open",inputFocused:"react-autosuggest__input--focused",suggestionsContainer:"react-autosuggest__suggestions-container",suggestionsContainerOpen:"react-autosuggest__suggestions-container--open",suggestionsList:"react-autosuggest__suggestions-list",suggestion:"react-autosuggest__suggestion",suggestionFirst:"react-autosuggest__suggestion--first",suggestionHighlighted:"react-autosuggest__suggestion--highlighted",sectionContainer:"react-autosuggest__section-container",sectionContainerFirst:"react-autosuggest__section-container--first",sectionTitle:"react-autosuggest__section-title"},t.mapToAutowhateverTheme=function(e){var t={};for(var n in e)switch(n){case"suggestionsContainer":t.itemsContainer=e[n];break;case"suggestionsContainerOpen":t.itemsContainerOpen=e[n];break;case"suggestion":t.item=e[n];break;case"suggestionFirst":t.itemFirst=e[n];break;case"suggestionHighlighted":t.itemHighlighted=e[n];break;case"suggestionsList":t.itemsList=e[n];break;default:t[n]=e[n]}return t}}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React")):"function"==typeof define&&define.amd?define(["React"],t):"object"==typeof exports?exports.Autosuggest=t(require("React")):e.Autosuggest=t(e.React)}(this,function(e){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";e.exports=n(1).default},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},a=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),l=n(2),c=o(l),g=n(3),f=(o(g),n(7)),d=o(f),h=n(8),p=o(h),m=n(17),v=function(){return!0},y=function(e){return e.trim().length>0},I=function(e){var t=e.containerProps,n=e.children;return c.default.createElement("div",t,n)},S=function(e){function t(e){var n=e.alwaysRenderSuggestions;r(this,t);var o=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return b.call(o),o.state={isFocused:!1,isCollapsed:!n,highlightedSectionIndex:null,highlightedSuggestionIndex:null,valueBeforeUpDown:null},o.justPressedUpDown=!1,o}return u(t,e),a(t,[{key:"componentDidMount",value:function(){document.addEventListener("mousedown",this.onDocumentMouseDown),this.input=this.autowhatever.input,this.suggestionsContainer=this.autowhatever.itemsContainer}},{key:"componentWillReceiveProps",value:function(e){(0,d.default)(e.suggestions,this.props.suggestions)?e.highlightFirstSuggestion&&e.suggestions.length>0&&this.justPressedUpDown===!1&&this.highlightFirstSuggestion():this.willRenderSuggestions(e)?(e.highlightFirstSuggestion&&this.highlightFirstSuggestion(),this.state.isCollapsed&&!this.justSelectedSuggestion&&this.revealSuggestions()):this.resetHighlightedSuggestion()}},{key:"componentWillUnmount",value:function(){document.removeEventListener("mousedown",this.onDocumentMouseDown)}},{key:"updateHighlightedSuggestion",value:function(e,t,n){this.setState(function(o){var r=o.valueBeforeUpDown;return null===t?r=null:null===r&&"undefined"!=typeof n&&(r=n),{highlightedSectionIndex:e,highlightedSuggestionIndex:t,valueBeforeUpDown:r}})}},{key:"resetHighlightedSuggestion",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.setState(function(t){var n=t.valueBeforeUpDown;return{highlightedSectionIndex:null,highlightedSuggestionIndex:null,valueBeforeUpDown:e?null:n}})}},{key:"revealSuggestions",value:function(){this.setState({isCollapsed:!1})}},{key:"closeSuggestions",value:function(){this.setState({highlightedSectionIndex:null,highlightedSuggestionIndex:null,valueBeforeUpDown:null,isCollapsed:!0})}},{key:"getSuggestion",value:function(e,t){var n=this.props,o=n.suggestions,r=n.multiSection,i=n.getSectionSuggestions;return r?i(o[e])[t]:o[t]}},{key:"getHighlightedSuggestion",value:function(){var e=this.state,t=e.highlightedSectionIndex,n=e.highlightedSuggestionIndex;return null===n?null:this.getSuggestion(t,n)}},{key:"getSuggestionValueByIndex",value:function(e,t){var n=this.props.getSuggestionValue;return n(this.getSuggestion(e,t))}},{key:"getSuggestionIndices",value:function(e){var t=e.getAttribute("data-section-index"),n=e.getAttribute("data-suggestion-index");return{sectionIndex:"string"==typeof t?parseInt(t,10):null,suggestionIndex:parseInt(n,10)}}},{key:"findSuggestionElement",value:function(e){var t=e;do{if(null!==t.getAttribute("data-suggestion-index"))return t;t=t.parentNode}while(null!==t);throw console.error("Clicked element:",e),new Error("Couldn't find suggestion element")}},{key:"maybeCallOnChange",value:function(e,t,n){var o=this.props.inputProps,r=o.value,i=o.onChange;t!==r&&i(e,{newValue:t,method:n})}},{key:"willRenderSuggestions",value:function(e){var t=e.suggestions,n=e.inputProps,o=e.shouldRenderSuggestions,r=n.value;return t.length>0&&o(r)}},{key:"getQuery",value:function(){var e=this.props.inputProps,t=e.value,n=this.state.valueBeforeUpDown;return(n||t).trim()}},{key:"render",value:function(){var e=this,t=this.props,n=t.suggestions,o=t.renderInputComponent,r=t.onSuggestionsFetchRequested,i=t.renderSuggestion,u=t.inputProps,a=t.multiSection,l=t.renderSectionTitle,g=t.id,f=t.getSectionSuggestions,d=t.theme,h=t.getSuggestionValue,y=t.alwaysRenderSuggestions,I=this.state,S=I.isFocused,b=I.isCollapsed,w=I.highlightedSectionIndex,x=I.highlightedSuggestionIndex,_=I.valueBeforeUpDown,O=y?v:this.props.shouldRenderSuggestions,C=u.value,j=u.onFocus,P=u.onKeyDown,k=this.willRenderSuggestions(this.props),R=y||S&&!b&&k,D=R?n:[],T=s({},u,{onFocus:function(t){if(!e.justSelectedSuggestion&&!e.justClickedOnSuggestionsContainer){var n=O(C);e.setState({isFocused:!0,isCollapsed:!n}),j&&j(t),n&&r({value:C})}},onBlur:function(t){return e.justClickedOnSuggestionsContainer?void e.input.focus():(e.blurEvent=t,void(e.justSelectedSuggestion||(e.onBlur(),e.onSuggestionsClearRequested())))},onChange:function(t){var n=t.target.value,o=O(n);e.maybeCallOnChange(t,n,"type"),e.setState({highlightedSectionIndex:null,highlightedSuggestionIndex:null,valueBeforeUpDown:null,isCollapsed:!o}),o?r({value:n}):e.onSuggestionsClearRequested()},onKeyDown:function(t,o){switch(t.key){case"ArrowDown":case"ArrowUp":if(b)O(C)&&(r({value:C}),e.revealSuggestions());else if(n.length>0){var i=o.newHighlightedSectionIndex,u=o.newHighlightedItemIndex,s=void 0;s=null===u?null===_?C:_:e.getSuggestionValueByIndex(i,u),e.updateHighlightedSuggestion(i,u,C),e.maybeCallOnChange(t,s,"ArrowDown"===t.key?"down":"up")}t.preventDefault(),e.justPressedUpDown=!0,setTimeout(function(){e.justPressedUpDown=!1});break;case"Enter":var a=e.getHighlightedSuggestion();if(R&&!y&&e.closeSuggestions(),null!==a){var l=h(a);e.maybeCallOnChange(t,l,"enter"),e.onSuggestionSelected(t,{suggestion:a,suggestionValue:l,suggestionIndex:x,sectionIndex:w,method:"enter"}),e.justSelectedSuggestion=!0,setTimeout(function(){e.justSelectedSuggestion=!1})}break;case"Escape":R&&t.preventDefault();var c=R&&!y;if(null===_){if(!c){var g="";e.maybeCallOnChange(t,g,"escape"),O(g)?r({value:g}):e.onSuggestionsClearRequested()}}else e.maybeCallOnChange(t,_,"escape");c?(e.onSuggestionsClearRequested(),e.closeSuggestions()):e.resetHighlightedSuggestion()}P&&P(t)}}),E={query:this.getQuery()};return c.default.createElement(p.default,{multiSection:a,items:D,renderInputComponent:o,renderItemsContainer:this.renderSuggestionsContainer,renderItem:i,renderItemData:E,renderSectionTitle:l,getSectionItems:f,highlightedSectionIndex:w,highlightedItemIndex:x,inputProps:T,itemProps:this.itemProps,theme:(0,m.mapToAutowhateverTheme)(d),id:g,ref:this.storeAutowhateverRef})}}]),t}(l.Component);S.defaultProps={renderSuggestionsContainer:I,shouldRenderSuggestions:y,alwaysRenderSuggestions:!1,multiSection:!1,focusInputOnSuggestionClick:!0,highlightFirstSuggestion:!1,theme:m.defaultTheme,id:"1"};var b=function(){var e=this;this.onDocumentMouseDown=function(t){e.justClickedOnSuggestionsContainer=!1;for(var n=t.detail&&t.detail.target||t.target;null!==n&&n!==document;){if(null!==n.getAttribute("data-suggestion-index"))return;if(n===e.suggestionsContainer)return void(e.justClickedOnSuggestionsContainer=!0);n=n.parentNode}},this.storeAutowhateverRef=function(t){null!==t&&(e.autowhatever=t)},this.onSuggestionMouseEnter=function(t,n){var o=n.sectionIndex,r=n.itemIndex;e.updateHighlightedSuggestion(o,r)},this.highlightFirstSuggestion=function(){e.updateHighlightedSuggestion(e.props.multiSection?0:null,0)},this.onSuggestionMouseDown=function(){e.justSelectedSuggestion=!0},this.onSuggestionsClearRequested=function(){var t=e.props.onSuggestionsClearRequested;t&&t()},this.onSuggestionSelected=function(t,n){var o=e.props,r=o.alwaysRenderSuggestions,i=o.onSuggestionSelected,u=o.onSuggestionsFetchRequested;i&&i(t,n),r?u({value:n.suggestionValue}):e.onSuggestionsClearRequested(),e.resetHighlightedSuggestion()},this.onSuggestionClick=function(t){var n=e.props,o=n.alwaysRenderSuggestions,r=n.focusInputOnSuggestionClick,i=e.getSuggestionIndices(e.findSuggestionElement(t.target)),u=i.sectionIndex,s=i.suggestionIndex,a=e.getSuggestion(u,s),l=e.props.getSuggestionValue(a);e.maybeCallOnChange(t,l,"click"),e.onSuggestionSelected(t,{suggestion:a,suggestionValue:l,suggestionIndex:s,sectionIndex:u,method:"click"}),o||e.closeSuggestions(),r===!0?e.input.focus():e.onBlur(),setTimeout(function(){e.justSelectedSuggestion=!1})},this.onBlur=function(){var t=e.props,n=t.inputProps,o=t.shouldRenderSuggestions,r=n.value,i=n.onBlur,u=e.getHighlightedSuggestion(),s=o(r);e.setState({isFocused:!1,highlightedSectionIndex:null,highlightedSuggestionIndex:null,valueBeforeUpDown:null,isCollapsed:!s}),i&&i(e.blurEvent,{highlightedSuggestion:u})},this.resetHighlightedSuggestionOnMouseLeave=function(){e.resetHighlightedSuggestion(!1)},this.itemProps=function(t){var n=t.sectionIndex,o=t.itemIndex;return{"data-section-index":n,"data-suggestion-index":o,onMouseEnter:e.onSuggestionMouseEnter,onMouseLeave:e.resetHighlightedSuggestionOnMouseLeave,onMouseDown:e.onSuggestionMouseDown,onTouchStart:e.onSuggestionMouseDown,onClick:e.onSuggestionClick}},this.renderSuggestionsContainer=function(t){var n=t.containerProps,o=t.children,r=e.props.renderSuggestionsContainer;return r({containerProps:n,children:o,query:e.getQuery()})}};t.default=S},function(t,n){t.exports=e},function(e,t,n){e.exports=n(4)()},function(e,t,n){"use strict";var o=n(5),r=n(6);e.exports=function(){function e(){r(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t};return n.checkPropTypes=o,n.PropTypes=n,n}},function(e,t){"use strict";function n(e){return function(){return e}}var o=function(){};o.thatReturns=n,o.thatReturnsFalse=n(!1),o.thatReturnsTrue=n(!0),o.thatReturnsNull=n(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e},e.exports=o},function(e,t,n){"use strict";function o(e,t,n,o,i,u,s,a){if(r(t),!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,o,i,u,s,a],g=0;l=new Error(t.replace(/%s/g,function(){return c[g++]})),l.name="Invariant Violation"}throw l.framesToPop=1,l}}var r=function(e){};e.exports=o},function(e,t){e.exports=function(e,t){if(e===t)return!0;var n=e.length;if(t.length!==n)return!1;for(var o=0;o<n;o++)if(e[o]!==t[o])return!1;return!0}},function(e,t,n){"use strict";e.exports=n(9).default},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},a=function(){function e(e,t){var n=[],o=!0,r=!1,i=void 0;try{for(var u,s=e[Symbol.iterator]();!(o=(u=s.next()).done)&&(n.push(u.value),!t||n.length!==t);o=!0);}catch(e){r=!0,i=e}finally{try{!o&&s.return&&s.return()}finally{if(r)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),l=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),c=n(2),g=o(c),f=n(3),d=o(f),h=n(10),p=o(h),m=n(11),v=o(m),y=n(13),I=o(y),S=n(15),b=o(S),w={},x=function(e){return g.default.createElement("input",e)},_=function(e){var t=e.containerProps,n=e.children;return g.default.createElement("div",t,n)},O={container:"react-autowhatever__container",containerOpen:"react-autowhatever__container--open",input:"react-autowhatever__input",inputOpen:"react-autowhatever__input--open",inputFocused:"react-autowhatever__input--focused",itemsContainer:"react-autowhatever__items-container",itemsContainerOpen:"react-autowhatever__items-container--open",itemsList:"react-autowhatever__items-list",item:"react-autowhatever__item",itemFirst:"react-autowhatever__item--first",itemHighlighted:"react-autowhatever__item--highlighted",sectionContainer:"react-autowhatever__section-container",sectionContainerFirst:"react-autowhatever__section-container--first",sectionTitle:"react-autowhatever__section-title"},C=function(e){function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.storeInputReference=function(e){null!==e&&(n.input=e)},n.storeItemsContainerReference=function(e){null!==e&&(n.itemsContainer=e)},n.onHighlightedItemChange=function(e){n.highlightedItem=e},n.getItemId=function(e,t){if(null===t)return null;var o=n.props.id,r=null===e?"":"section-"+e;return"react-autowhatever-"+o+"-"+r+"-item-"+t},n.onFocus=function(e){var t=n.props.inputProps;n.setState({isInputFocused:!0}),t.onFocus&&t.onFocus(e)},n.onBlur=function(e){var t=n.props.inputProps;n.setState({isInputFocused:!1}),t.onBlur&&t.onBlur(e)},n.onKeyDown=function(e){var t=n.props,o=t.inputProps,r=t.highlightedSectionIndex,i=t.highlightedItemIndex;switch(e.key){case"ArrowDown":case"ArrowUp":var u="ArrowDown"===e.key?"next":"prev",s=n.sectionIterator[u]([r,i]),l=a(s,2),c=l[0],g=l[1];o.onKeyDown(e,{newHighlightedSectionIndex:c,newHighlightedItemIndex:g});break;default:o.onKeyDown(e,{highlightedSectionIndex:r,highlightedItemIndex:i})}},n.highlightedItem=null,n.state={isInputFocused:!1},n.setSectionsItems(e),n.setSectionIterator(e),n.setTheme(e),n}return u(t,e),l(t,[{key:"componentDidMount",value:function(){this.ensureHighlightedItemIsVisible()}},{key:"componentWillReceiveProps",value:function(e){e.items!==this.props.items&&this.setSectionsItems(e),e.items===this.props.items&&e.multiSection===this.props.multiSection||this.setSectionIterator(e),e.theme!==this.props.theme&&this.setTheme(e)}},{key:"componentDidUpdate",value:function(){this.ensureHighlightedItemIsVisible()}},{key:"setSectionsItems",value:function(e){e.multiSection&&(this.sectionsItems=e.items.map(function(t){return e.getSectionItems(t)}),this.sectionsLengths=this.sectionsItems.map(function(e){return e.length}),this.allSectionsAreEmpty=this.sectionsLengths.every(function(e){return 0===e}))}},{key:"setSectionIterator",value:function(e){this.sectionIterator=(0,p.default)({multiSection:e.multiSection,data:e.multiSection?this.sectionsLengths:e.items.length})}},{key:"setTheme",value:function(e){this.theme=(0,v.default)(e.theme)}},{key:"renderSections",value:function(){var e=this;if(this.allSectionsAreEmpty)return null;var t=this.theme,n=this.props,o=n.id,r=n.items,i=n.renderItem,u=n.renderItemData,s=n.renderSectionTitle,a=n.highlightedSectionIndex,l=n.highlightedItemIndex,c=n.itemProps;return r.map(function(n,r){var f="react-autowhatever-"+o+"-",d=f+"section-"+r+"-",h=0===r;return g.default.createElement("div",t(d+"container","sectionContainer",h&&"sectionContainerFirst"),g.default.createElement(I.default,{section:n,renderSectionTitle:s,theme:t,sectionKeyPrefix:d}),g.default.createElement(b.default,{items:e.sectionsItems[r],itemProps:c,renderItem:i,renderItemData:u,sectionIndex:r,highlightedItemIndex:a===r?l:null,onHighlightedItemChange:e.onHighlightedItemChange,getItemId:e.getItemId,theme:t,keyPrefix:f,ref:e.storeItemsListReference}))})}},{key:"renderItems",value:function(){var e=this.props.items;if(0===e.length)return null;var t=this.theme,n=this.props,o=n.id,r=n.renderItem,i=n.renderItemData,u=n.highlightedSectionIndex,s=n.highlightedItemIndex,a=n.itemProps;return g.default.createElement(b.default,{items:e,itemProps:a,renderItem:r,renderItemData:i,highlightedItemIndex:null===u?s:null,onHighlightedItemChange:this.onHighlightedItemChange,getItemId:this.getItemId,theme:t,keyPrefix:"react-autowhatever-"+o+"-"})}},{key:"ensureHighlightedItemIsVisible",value:function(){var e=this.highlightedItem;if(e){var t=this.itemsContainer,n=e.offsetParent===t?e.offsetTop:e.offsetTop-t.offsetTop,o=t.scrollTop;n<o?o=n:n+e.offsetHeight>o+t.offsetHeight&&(o=n+e.offsetHeight-t.offsetHeight),o!==t.scrollTop&&(t.scrollTop=o)}}},{key:"render",value:function(){var e=this.theme,t=this.props,n=t.id,o=t.multiSection,r=t.renderInputComponent,i=t.renderItemsContainer,u=t.highlightedSectionIndex,a=t.highlightedItemIndex,l=this.state.isInputFocused,c=o?this.renderSections():this.renderItems(),f=null!==c,d=this.getItemId(u,a),h=e("react-autowhatever-"+n+"-container","container",f&&"containerOpen"),p="react-autowhatever-"+n,m=r(s({type:"text",value:"",autoComplete:"off",role:"combobox","aria-autocomplete":"list","aria-owns":p,"aria-expanded":f,"aria-haspopup":f,"aria-activedescendant":d},e("react-autowhatever-"+n+"-input","input",f&&"inputOpen",l&&"inputFocused"),this.props.inputProps,{onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.props.inputProps.onKeyDown&&this.onKeyDown,ref:this.storeInputReference})),v=i({containerProps:s({id:p},e("react-autowhatever-"+n+"-items-container","itemsContainer",f&&"itemsContainerOpen"),{ref:this.storeItemsContainerReference}),children:c});return g.default.createElement("div",h,m,v)}}]),t}(c.Component);C.propTypes={id:d.default.string,multiSection:d.default.bool,renderInputComponent:d.default.func,renderItemsContainer:d.default.func,items:d.default.array.isRequired,renderItem:d.default.func,renderItemData:d.default.object,renderSectionTitle:d.default.func,getSectionItems:d.default.func,inputProps:d.default.object,itemProps:d.default.oneOfType([d.default.object,d.default.func]),highlightedSectionIndex:d.default.number,highlightedItemIndex:d.default.number,theme:d.default.oneOfType([d.default.object,d.default.array])},C.defaultProps={id:"1",multiSection:!1,renderInputComponent:x,renderItemsContainer:_,renderItem:function(){throw new Error("`renderItem` must be provided")},renderItemData:w,renderSectionTitle:function(){throw new Error("`renderSectionTitle` must be provided")},getSectionItems:function(){throw new Error("`getSectionItems` must be provided")},inputProps:w,itemProps:w,highlightedSectionIndex:null,highlightedItemIndex:null,theme:O},t.default=C},function(e,t){"use strict";var n=function(){function e(e,t){var n=[],o=!0,r=!1,i=void 0;try{for(var u,s=e[Symbol.iterator]();!(o=(u=s.next()).done)&&(n.push(u.value),!t||n.length!==t);o=!0);}catch(e){r=!0,i=e}finally{try{!o&&s.return&&s.return()}finally{if(r)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();e.exports=function(e){function t(e){for(null===e?e=0:e++;e<s.length&&0===s[e];)e++;return e===s.length?null:e}function o(e){for(null===e?e=s.length-1:e--;e>=0&&0===s[e];)e--;return e===-1?null:e}function r(e){var o=n(e,2),r=o[0],i=o[1];return a?null===i||i===s[r]-1?(r=t(r),null===r?[null,null]:[r,0]):[r,i+1]:0===s||i===s-1?[null,null]:null===i?[null,0]:[null,i+1]}function i(e){var t=n(e,2),r=t[0],i=t[1];return a?null===i||0===i?(r=o(r),null===r?[null,null]:[r,s[r]-1]):[r,i-1]:0===s||0===i?[null,null]:null===i?[null,s-1]:[null,i-1]}function u(e){return null===r(e)[1]}var s=e.data,a=e.multiSection;return{next:r,prev:i,isLast:u}}},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){var n=[],o=!0,r=!1,i=void 0;try{for(var u,s=e[Symbol.iterator]();!(o=(u=s.next()).done)&&(n.push(u.value),!t||n.length!==t);o=!0);}catch(e){r=!0,i=e}finally{try{!o&&s.return&&s.return()}finally{if(r)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),u=n(12),s=o(u),a=function(e){return e};t.default=function(e){var t=Array.isArray(e)&&2===e.length?e:[e,null],n=i(t,2),o=n[0],u=n[1];return function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];var l=n.map(function(e){return o[e]}).filter(a);return"string"==typeof l[0]||"function"==typeof u?{key:e,className:u?u.apply(void 0,r(l)):l.join(" ")}:{key:e,style:s.default.apply(void 0,[{}].concat(r(l)))}}},e.exports=t.default},function(e,t){"use strict";function n(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function o(e){var t=Object.getOwnPropertyNames(e);return Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(e))),t.filter(function(t){return r.call(e,t)})}var r=Object.prototype.propertyIsEnumerable;e.exports=Object.assign||function(e,t){for(var r,i,u=n(e),s=1;s<arguments.length;s++){r=arguments[s],i=o(Object(r));for(var a=0;a<i.length;a++)u[i[a]]=r[i[a]]}return u}},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),a=n(2),l=o(a),c=n(3),g=o(c),f=n(14),d=o(f),h=function(e){function t(){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,e),s(t,[{key:"shouldComponentUpdate",value:function(e){return(0,d.default)(e,this.props)}},{key:"render",value:function(){var e=this.props,t=e.section,n=e.renderSectionTitle,o=e.theme,r=e.sectionKeyPrefix,i=n(t);return i?l.default.createElement("div",o(r+"title","sectionTitle"),i):null}}]),t}(a.Component);h.propTypes={section:g.default.any.isRequired,renderSectionTitle:g.default.func.isRequired,theme:g.default.func.isRequired,sectionKeyPrefix:g.default.string.isRequired},t.default=h},function(e,t){"use strict";function n(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(e===t)return!1;var r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!0;var u={},s=void 0,a=void 0;for(s=0,a=n.length;s<a;s++)u[n[s]]=!0;for(s=0,a=r.length;s<a;s++){var l=r[s],c=e[l],g=t[l];if(c!==g){if(!u[l]||null===c||null===g||"object"!==("undefined"==typeof c?"undefined":o(c))||"object"!==("undefined"==typeof g?"undefined":o(g)))return!0;var f=Object.keys(c),d=Object.keys(g);if(f.length!==d.length)return!0;for(var h=0,p=f.length;h<p;h++){var m=f[h];if(c[m]!==g[m])return!0}}}return!1}Object.defineProperty(t,"__esModule",{value:!0});var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.default=n},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},a=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),l=n(2),c=o(l),g=n(3),f=o(g),d=n(16),h=o(d),p=n(14),m=o(p),v=function(e){function t(){var e,n,o,u;r(this,t);for(var s=arguments.length,a=Array(s),l=0;l<s;l++)a[l]=arguments[l];return n=o=i(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(a))),o.storeHighlightedItemReference=function(e){o.props.onHighlightedItemChange(null===e?null:e.item)},u=n,i(o,u)}return u(t,e),a(t,[{key:"shouldComponentUpdate",value:function(e){return(0,m.default)(e,this.props,["itemProps"])}},{key:"render",value:function(){var e=this,t=this.props,n=t.items,o=t.itemProps,r=t.renderItem,i=t.renderItemData,u=t.sectionIndex,a=t.highlightedItemIndex,l=t.getItemId,g=t.theme,f=t.keyPrefix,d=null===u?f:f+"section-"+u+"-",p="function"==typeof o;return c.default.createElement("ul",s({role:"listbox"},g(d+"items-list","itemsList")),n.map(function(t,n){var f=0===n,m=n===a,v=d+"item-"+n,y=p?o({sectionIndex:u,itemIndex:n}):o,I=s({id:l(u,n)},g(v,"item",f&&"itemFirst",m&&"itemHighlighted"),y);return m&&(I.ref=e.storeHighlightedItemReference),c.default.createElement(h.default,s({},I,{sectionIndex:u,itemIndex:n,item:t,renderItem:r,renderItemData:i}))}))}}]),t}(l.Component);v.propTypes={items:f.default.array.isRequired,itemProps:f.default.oneOfType([f.default.object,f.default.func]),renderItem:f.default.func.isRequired,renderItemData:f.default.object.isRequired,sectionIndex:f.default.number,highlightedItemIndex:f.default.number,onHighlightedItemChange:f.default.func.isRequired,getItemId:f.default.func.isRequired,theme:f.default.func.isRequired,keyPrefix:f.default.string.isRequired},v.defaultProps={sectionIndex:null},t.default=v},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){var n={};for(var o in e)t.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o]);return n}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),c=n(2),g=o(c),f=n(3),d=o(f),h=n(14),p=o(h),m=function(e){function t(){var e,n,o,r;i(this,t);for(var s=arguments.length,a=Array(s),l=0;l<s;l++)a[l]=arguments[l];return n=o=u(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(a))),o.storeItemReference=function(e){null!==e&&(o.item=e)},o.onMouseEnter=function(e){var t=o.props,n=t.sectionIndex,r=t.itemIndex;o.props.onMouseEnter(e,{sectionIndex:n,itemIndex:r})},o.onMouseLeave=function(e){var t=o.props,n=t.sectionIndex,r=t.itemIndex;o.props.onMouseLeave(e,{sectionIndex:n,itemIndex:r})},o.onMouseDown=function(e){var t=o.props,n=t.sectionIndex,r=t.itemIndex;o.props.onMouseDown(e,{sectionIndex:n,itemIndex:r})},o.onClick=function(e){var t=o.props,n=t.sectionIndex,r=t.itemIndex;o.props.onClick(e,{sectionIndex:n,itemIndex:r})},r=n,u(o,r)}return s(t,e),l(t,[{key:"shouldComponentUpdate",value:function(e){return(0,p.default)(e,this.props,["renderItemData"])}},{key:"render",value:function(){var e=this.props,t=e.item,n=e.renderItem,o=e.renderItemData,i=r(e,["item","renderItem","renderItemData"]);return delete i.sectionIndex,delete i.itemIndex,"function"==typeof i.onMouseEnter&&(i.onMouseEnter=this.onMouseEnter),"function"==typeof i.onMouseLeave&&(i.onMouseLeave=this.onMouseLeave),"function"==typeof i.onMouseDown&&(i.onMouseDown=this.onMouseDown),"function"==typeof i.onClick&&(i.onClick=this.onClick),g.default.createElement("li",a({role:"option"},i,{ref:this.storeItemReference}),n(t,o))}}]),t}(c.Component);m.propTypes={sectionIndex:d.default.number,itemIndex:d.default.number.isRequired,item:d.default.any.isRequired,renderItem:d.default.func.isRequired,renderItemData:d.default.object.isRequired,onMouseEnter:d.default.func,onMouseLeave:d.default.func,onMouseDown:d.default.func,onClick:d.default.func},t.default=m},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.defaultTheme={container:"react-autosuggest__container",containerOpen:"react-autosuggest__container--open",input:"react-autosuggest__input",inputOpen:"react-autosuggest__input--open",inputFocused:"react-autosuggest__input--focused",suggestionsContainer:"react-autosuggest__suggestions-container",suggestionsContainerOpen:"react-autosuggest__suggestions-container--open",suggestionsList:"react-autosuggest__suggestions-list",suggestion:"react-autosuggest__suggestion",suggestionFirst:"react-autosuggest__suggestion--first",suggestionHighlighted:"react-autosuggest__suggestion--highlighted",sectionContainer:"react-autosuggest__section-container",sectionContainerFirst:"react-autosuggest__section-container--first",sectionTitle:"react-autosuggest__section-title"},t.mapToAutowhateverTheme=function(e){var t={};for(var n in e)switch(n){case"suggestionsContainer":t.itemsContainer=e[n];break;case"suggestionsContainerOpen":t.itemsContainerOpen=e[n];break;case"suggestion":t.item=e[n];break;case"suggestionFirst":
t.itemFirst=e[n];break;case"suggestionHighlighted":t.itemHighlighted=e[n];break;case"suggestionsList":t.itemsList=e[n];break;default:t[n]=e[n]}return t}}])});
{
"name": "react-autosuggest",
"version": "9.0.0",
"version": "9.0.1",
"description": "WAI-ARIA compliant React autosuggest component",

@@ -26,32 +26,33 @@ "main": "dist/index.js",

"dependencies": {
"react-autowhatever": "^9.1.0",
"prop-types": "^15.5.8",
"react-autowhatever": "^10.0.0",
"shallow-equal": "^1.0.0"
},
"peerDependencies": {
"react": ">=0.14.7 || >=16.0.0-alpha.2"
"react": ">=0.14.7"
},
"devDependencies": {
"autoprefixer": "^6.7.5",
"autoprefixer": "^6.7.7",
"autosuggest-highlight": "^3.1.0",
"babel-cli": "^6.23.0",
"babel-core": "^6.23.1",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.3.2",
"babel-cli": "^6.24.1",
"babel-core": "^6.24.1",
"babel-eslint": "^7.2.2",
"babel-loader": "^6.4.1",
"babel-plugin-react-transform": "^2.0.2",
"babel-plugin-transform-react-remove-prop-types": "^0.3.2",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.23.0",
"babel-preset-stage-0": "^6.22.0",
"babel-register": "^6.23.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.24.1",
"chai": "^3.5.0",
"cross-env": "^3.1.4",
"css-loader": "^0.26.2",
"es6-promise": "^4.0.5",
"eslint": "^3.16.1",
"eslint-plugin-react": "6.10.0",
"css-loader": "^0.28.0",
"es6-promise": "^4.1.0",
"eslint": "^3.19.0",
"eslint-plugin-react": "6.10.3",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.10.1",
"ismobilejs": "^0.4.0",
"file-loader": "^0.11.1",
"ismobilejs": "^0.4.1",
"isomorphic-fetch": "^2.2.1",
"jsdom": "^9.11.0",
"jsdom": "^9.12.0",
"less": "^2.7.2",

@@ -62,13 +63,12 @@ "less-loader": "^2.2.3",

"openurl": "^1.1.1",
"postcss-loader": "^1.3.2",
"react": "^16.0.0-alpha.2",
"react-addons-test-utils": "^16.0.0-alpha.2",
"react-dom": "^16.0.0-alpha.2",
"react-modal": "^1.6.5",
"postcss-loader": "^1.3.3",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-modal": "^1.7.7",
"react-transform-hmr": "^1.0.4",
"sinon": "^1.17.7",
"sinon-chai": "^2.8.0",
"style-loader": "^0.13.2",
"sinon-chai": "^2.9.0",
"style-loader": "^0.16.1",
"svgo": "^0.7.2",
"svgo-loader": "^1.1.2",
"svgo-loader": "^1.2.1",
"url-loader": "^0.5.8",

@@ -75,0 +75,0 @@ "webpack": "^1.14.0",

[![Build Status](https://img.shields.io/codeship/41810250-aa07-0132-fbf4-4e62e8945e03/master.svg?style=flat-square)](https://codeship.com/projects/67868)
[![Contributors](https://img.shields.io/github/contributors/moroshko/react-autosuggest.svg?style=flat-square)](https://github.com/moroshko/react-autosuggest/graphs/contributors)
[![Coverage Status](https://img.shields.io/codecov/c/github/moroshko/react-autosuggest/master.svg?style=flat-square)](https://codecov.io/gh/moroshko/react-autosuggest)
[![npms Score](https://badges.npms.io/react.svg?style=flat-square)](https://npms.io/search?q=react-autosuggest)
[![npms Score](https://badges.npms.io/react-autosuggest.svg?style=flat-square)](https://npms.io/search?q=react-autosuggest)
[![npm Downloads](https://img.shields.io/npm/dm/react-autosuggest.svg?style=flat-square)](https://npmjs.org/package/react-autosuggest)
[![npm Version](https://img.shields.io/npm/v/react-autosuggest.svg?style=flat-square)](https://npmjs.org/package/react-autosuggest)
![gzip size](http://img.badgesize.io/https://unpkg.com/react-autosuggest/dist/standalone/autosuggest.min.js?compression=gzip&style=flat-square)

@@ -16,3 +18,3 @@ # React Autosuggest

* [WAI-ARIA compliant](https://www.w3.org/TR/wai-aria-practices/#autocomplete), with support for ARIA attributes and keyboard interactions
* [WAI-ARIA compliant](https://rawgit.com/w3c/aria-practices/master/aria-practices-DeletedSectionsArchive.html#autocomplete), with support for ARIA attributes and keyboard interactions
* Mobile friendly

@@ -42,2 +44,8 @@ * Plugs in nicely to Flux and [Redux](http://redux.js.org) applications

You can also use the standalone UMD build:
```html
<script src="https://unpkg.com/react-autosuggest/dist/standalone/autosuggest.js"></script>
```
## Basic Usage

@@ -256,3 +264,3 @@

When user navigates the suggestions using the <kbd>Up</kbd> and <kbd>Down</kbd> keys, [the input value should be set according to the highlighted suggestion](https://www.w3.org/TR/wai-aria-practices/#autocomplete). You design how suggestion is modelled. Therefore, it's your responsibility to tell Autosuggest how to map suggestions to input values.
When user navigates the suggestions using the <kbd>Up</kbd> and <kbd>Down</kbd> keys, [the input value should be set according to the highlighted suggestion](https://rawgit.com/w3c/aria-practices/master/aria-practices-DeletedSectionsArchive.html#autocomplete). You design how suggestion is modelled. Therefore, it's your responsibility to tell Autosuggest how to map suggestions to input values.

@@ -281,3 +289,3 @@ This function gets the suggestion in question, and it should return a string. For example:

* `suggestion` - The suggestion to render
* `query` - Used to highlight the matching string. As user types in the input element, `query` will be equal to the trimmed value of the input. Then, if user interacts using the <kbd>Up</kbd> or <kbd>Down</kbd> keys, [the input element will get the value of the highlighted suggestion](https://www.w3.org/TR/wai-aria-practices/#autocomplete), but `query` will remain to be equal to the trimmed value of the input element prior to the <kbd>Up</kbd> and <kbd>Down</kbd> interactions.
* `query` - Used to highlight the matching string. As user types in the input element, `query` will be equal to the trimmed value of the input. Then, if user interacts using the <kbd>Up</kbd> or <kbd>Down</kbd> keys, [the input element will get the value of the highlighted suggestion](https://rawgit.com/w3c/aria-practices/master/aria-practices-DeletedSectionsArchive.html#autocomplete), but `query` will remain to be equal to the trimmed value of the input element prior to the <kbd>Up</kbd> and <kbd>Down</kbd> interactions.

@@ -459,3 +467,3 @@ It should return a string or a `ReactElement`. For example:

To keep Autosuggest [accessible](https://www.w3.org/TR/wai-aria-practices/#autocomplete), `renderInputComponent` MUST:
To keep Autosuggest [accessible](https://rawgit.com/w3c/aria-practices/master/aria-practices-DeletedSectionsArchive.html#autocomplete), `renderInputComponent` MUST:

@@ -462,0 +470,0 @@ * render an input element

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc