suggestion-react-input-search
Version:
Suggestion search input based on searches entered for React
1 lines • 27.3 kB
JavaScript
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=5)}([function(e,t,n){"use strict";e.exports=n(6)},function(e,t,n){"use strict";function r(e){return function(){return e}}var o=function(){};o.thatReturns=r,o.thatReturnsFalse=r(!1),o.thatReturnsTrue=r(!0),o.thatReturnsNull=r(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e},e.exports=o},function(e,t){e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var n=function(e,t){var n,r=e[1]||"",o=e[3];if(!o)return r;if(t&&"function"==typeof btoa){var i=(n=o,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(n))))+" */"),s=o.sources.map(function(e){return"/*# sourceURL="+o.sourceRoot+e+" */"});return[r].concat(s).concat([i]).join("\n")}return[r].join("\n")}(t,e);return t[2]?"@media "+t[2]+"{"+n+"}":n}).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var r={},o=0;o<this.length;o++){var i=this[o][0];"number"==typeof i&&(r[i]=!0)}for(o=0;o<e.length;o++){var s=e[o];"number"==typeof s[0]&&r[s[0]]||(n&&!s[2]?s[2]=n:n&&(s[2]="("+s[2]+") and ("+n+")"),t.push(s))}},t}},function(e,t,n){var r,o,i={},s=(r=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===o&&(o=r.apply(this,arguments)),o}),a=function(e){var t={};return function(e){if("function"==typeof e)return e();if(void 0===t[e]){var n=function(e){return document.querySelector(e)}.call(this,e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}}(),u=null,c=0,l=[],f=n(16);function p(e,t){for(var n=0;n<e.length;n++){var r=e[n],o=i[r.id];if(o){o.refs++;for(var s=0;s<o.parts.length;s++)o.parts[s](r.parts[s]);for(;s<r.parts.length;s++)o.parts.push(b(r.parts[s],t))}else{var a=[];for(s=0;s<r.parts.length;s++)a.push(b(r.parts[s],t));i[r.id]={id:r.id,refs:1,parts:a}}}}function d(e,t){for(var n=[],r={},o=0;o<e.length;o++){var i=e[o],s=t.base?i[0]+t.base:i[0],a={css:i[1],media:i[2],sourceMap:i[3]};r[s]?r[s].parts.push(a):n.push(r[s]={id:s,parts:[a]})}return n}function h(e,t){var n=a(e.insertInto);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var r=l[l.length-1];if("top"===e.insertAt)r?r.nextSibling?n.insertBefore(t,r.nextSibling):n.appendChild(t):n.insertBefore(t,n.firstChild),l.push(t);else if("bottom"===e.insertAt)n.appendChild(t);else{if("object"!=typeof e.insertAt||!e.insertAt.before)throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");var o=a(e.insertInto+" "+e.insertAt.before);n.insertBefore(t,o)}}function g(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e);var t=l.indexOf(e);t>=0&&l.splice(t,1)}function y(e){var t=document.createElement("style");return e.attrs.type="text/css",m(t,e.attrs),h(e,t),t}function m(e,t){Object.keys(t).forEach(function(n){e.setAttribute(n,t[n])})}function b(e,t){var n,r,o,i;if(t.transform&&e.css){if(!(i=t.transform(e.css)))return function(){};e.css=i}if(t.singleton){var s=c++;n=u||(u=y(t)),r=S.bind(null,n,s,!1),o=S.bind(null,n,s,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(e){var t=document.createElement("link");return e.attrs.type="text/css",e.attrs.rel="stylesheet",m(t,e.attrs),h(e,t),t}(t),r=function(e,t,n){var r=n.css,o=n.sourceMap,i=void 0===t.convertToAbsoluteUrls&&o;(t.convertToAbsoluteUrls||i)&&(r=f(r)),o&&(r+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */");var s=new Blob([r],{type:"text/css"}),a=e.href;e.href=URL.createObjectURL(s),a&&URL.revokeObjectURL(a)}.bind(null,n,t),o=function(){g(n),n.href&&URL.revokeObjectURL(n.href)}):(n=y(t),r=function(e,t){var n=t.css,r=t.media;if(r&&e.setAttribute("media",r),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}.bind(null,n),o=function(){g(n)});return r(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;r(e=t)}else o()}}e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||"boolean"==typeof t.singleton||(t.singleton=s()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var n=d(e,t);return p(n,t),function(e){for(var r=[],o=0;o<n.length;o++){var s=n[o];(a=i[s.id]).refs--,r.push(a)}for(e&&p(d(e,t),t),o=0;o<r.length;o++){var a;if(0===(a=r[o]).refs){for(var u=0;u<a.parts.length;u++)a.parts[u]();delete i[a.id]}}}};var v,O=(v=[],function(e,t){return v[e]=t,v.filter(Boolean).join("\n")});function S(e,t,n,r){var o=n?"":r.css;if(e.styleSheet)e.styleSheet.cssText=O(t,o);else{var i=document.createTextNode(o),s=e.childNodes;s[t]&&e.removeChild(s[t]),s.length?e.insertBefore(i,s[t]):e.appendChild(i)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ENTER_KEY_CODE=13,t.DOWN_ARROW_KEY_CODE=40,t.UP_ARROW_KEY_CODE=38,t.ESCAPE_KEY_CODE=27,t.CLICK_EVENT="click",t.TAB_KEY_CODE=9},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=c(n(0)),i=(c(n(9)),c(n(13))),s=c(n(18)),a=n(19),u=n(4);function c(e){return e&&e.__esModule?e:{default:e}}n(21);var l="",f=-1,p=/[\u0300-\u036f]/g,d=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e)),r=(e.inputClass,e.suggestionListClass,e.inputPosition,e.persistent?(0,a.loadSearches)():n.props.recentSearches);return n.state={showSuggestions:!1,suggestions:[],recentSearches:r,term:l,selectedItemIndex:f,inputClicked:!1},n.handleOnClickOnItem=n.handleOnClickOnItem.bind(n),n.handleOnSearch=n.handleOnSearch.bind(n),n.handleOnKeyPress=n.handleOnKeyPress.bind(n),n.handleClickOutside=n.handleClickOutside.bind(n),n.handleOnSelectedItemIndex=n.handleOnSelectedItemIndex.bind(n),n.inputRef=null,n.setInputRef=function(e){n.inputRef=e},n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,o.default.Component),r(t,[{key:"componentDidMount",value:function(){document.addEventListener(u.CLICK_EVENT,this.handleClickOutside)}},{key:"componentWillUnmount",value:function(){document.removeEventListener(u.CLICK_EVENT,this.handleClickOutside)}},{key:"componentDidUpdate",value:function(e,t){var n=this.state.recentSearches,r=this.props.persistent;n!==t.recentSearches&&r&&(0,a.saveSearches)(n)}},{key:"getSuggestionsFor",value:function(e){var t=this.props,n=t.minLength,r=(t.maxSuggestions,this.state.recentSearches),o=function(e){return e.toLowerCase().trim().normalize("NFD").replace(p,"")};return n>e.length?[]:r.filter(function(t){return function(e,t){return o(e).includes(o(t))}(t,e)})}},{key:"handleOnKeyPress",value:function(e){var t=e.keyCode,n=this.state,r=n.suggestions,o=n.selectedItemIndex,i=this.props.maxSuggestions,s=o>f?r[o]:e.target.value;if(t===u.ESCAPE_KEY_CODE&&this.setState(a.resetAndHideSuggestions),t===u.ENTER_KEY_CODE&&""!==s&&this.submitSearch(s),t===u.DOWN_ARROW_KEY_CODE||t===u.UP_ARROW_KEY_CODE){var c=this.selectItem(r.length,t),l=document.querySelector(".suggestions-container");this.setState((0,a.selectItemIndex)(c)),l&&(0===a.selectItemIndex?l.scrollTop=0:l.scrollTop=41.59*(c+1-i)),e.preventDefault()}if(t===u.TAB_KEY_CODE&&1===r.length){e.preventDefault();var p=r[0];this.submitSearch(p)}}},{key:"handleOnSearch",value:function(e){var t=e.target.value,n=this.getSuggestionsFor(t);this.props.autocompleteOnMatch&&1===n.length&&n[0]===t?this.submitSearch(t):this.setState((0,a.establishSuggestionsForTerm)(n,t))}},{key:"handleOnClickOnItem",value:function(e){var t=e.target.innerText;this.submitSearch(t)}},{key:"handleClickOutside",value:function(e){this.inputRef.contains(e.target)||this.setState(a.hideSuggestions)}},{key:"handleOnSelectedItemIndex",value:function(e){this.setState((0,a.selectItemIndex)(e))}},{key:"handleOnClickInputContainer",value:function(){this.setState({inputClicked:!0})}},{key:"selectItem",value:function(e,t){var n=this.state.selectedItemIndex,r=t===u.DOWN_ARROW_KEY_CODE?n+1:n-1;return r>=e?0:r<0?e-1:r}},{key:"submitSearch",value:function(e){var t=this.props.onSubmitFunction;this.setState((0,a.addNewSearch)(e)),t?t(e):console.error("Submit function must be provided")}},{key:"render",value:function(){var e=this,t=this.state,n=t.suggestions,r=t.showSuggestions,a=t.selectedItemIndex,u=t.inputClicked,c=t.term,f=this.props,p=f.placeholder,d=f.inputClass,h=f.inputPosition,g=f.suggestionListClass,y=f.floatingLabel,m="search-input-container "+h,b=""+d,v=g+" "+h,O={maxHeight:41.59*f.maxSuggestions};return o.default.createElement("div",{className:m},o.default.createElement("div",{className:"search-input-container__inner",onClick:function(){return e.handleOnClickInputContainer()}},o.default.createElement(s.default,{floatingLabel:y,placeholder:p,isInputEmpty:c===l,inputRef:this.inputRef,inputContainerClicked:u}),o.default.createElement("input",{type:"text",name:"search",value:c,placeholder:y?"":p,onChange:this.handleOnSearch,onClick:this.handleOnSearch,onKeyDown:this.handleOnKeyPress,ref:this.setInputRef,className:b,autoComplete:"off"}),o.default.createElement(i.default,{show:r,suggestions:n,onClickItem:this.handleOnClickOnItem,onSelectedItemIndex:this.handleOnSelectedItemIndex,selectedItemIndex:a,suggestionListClass:v,suggestionHeightStyle:O})))}}]),t}();d.defaultProps={inputClass:"suggestion-input",inputPosition:"start",suggestionListClass:"suggestions-container",placeholder:"Search...",recentSearches:[],minLength:1,persistent:!1,floatingLabel:!1,autocompleteOnMatch:!1,maxSuggestions:5},t.default=d},function(e,t,n){"use strict";var r=n(7),o=n(8),i=n(1),s="function"==typeof Symbol&&Symbol.for,a=s?Symbol.for("react.element"):60103,u=s?Symbol.for("react.call"):60104,c=s?Symbol.for("react.return"):60105,l=s?Symbol.for("react.portal"):60106,f=s?Symbol.for("react.fragment"):60107,p="function"==typeof Symbol&&Symbol.iterator;function d(e){for(var t=arguments.length-1,n="Minified React error #"+e+"; visit http://facebook.github.io/react/docs/error-decoder.html?invariant="+e,r=0;r<t;r++)n+="&args[]="+encodeURIComponent(arguments[r+1]);throw(t=Error(n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.")).name="Invariant Violation",t.framesToPop=1,t}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}};function g(e,t,n){this.props=e,this.context=t,this.refs=o,this.updater=n||h}function y(e,t,n){this.props=e,this.context=t,this.refs=o,this.updater=n||h}function m(){}g.prototype.isReactComponent={},g.prototype.setState=function(e,t){"object"!=typeof e&&"function"!=typeof e&&null!=e&&d("85"),this.updater.enqueueSetState(this,e,t,"setState")},g.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},m.prototype=g.prototype;var b=y.prototype=new m;function v(e,t,n){this.props=e,this.context=t,this.refs=o,this.updater=n||h}b.constructor=y,r(b,g.prototype),b.isPureReactComponent=!0;var O=v.prototype=new m;O.constructor=v,r(O,g.prototype),O.unstable_isAsyncReactComponent=!0,O.render=function(){return this.props.children};var S={current:null},_=Object.prototype.hasOwnProperty,x={key:!0,ref:!0,__self:!0,__source:!0};function w(e,t,n){var r,o={},i=null,s=null;if(null!=t)for(r in void 0!==t.ref&&(s=t.ref),void 0!==t.key&&(i=""+t.key),t)_.call(t,r)&&!x.hasOwnProperty(r)&&(o[r]=t[r]);var u=arguments.length-2;if(1===u)o.children=n;else if(1<u){for(var c=Array(u),l=0;l<u;l++)c[l]=arguments[l+2];o.children=c}if(e&&e.defaultProps)for(r in u=e.defaultProps)void 0===o[r]&&(o[r]=u[r]);return{$$typeof:a,type:e,key:i,ref:s,props:o,_owner:S.current}}function E(e){return"object"==typeof e&&null!==e&&e.$$typeof===a}var C=/\/+/g,k=[];function I(e,t,n,r){if(k.length){var o=k.pop();return o.result=e,o.keyPrefix=t,o.func=n,o.context=r,o.count=0,o}return{result:e,keyPrefix:t,func:n,context:r,count:0}}function j(e){e.result=null,e.keyPrefix=null,e.func=null,e.context=null,e.count=0,10>k.length&&k.push(e)}function R(e,t,n,r){var o=typeof e;"undefined"!==o&&"boolean"!==o||(e=null);var i=!1;if(null===e)i=!0;else switch(o){case"string":case"number":i=!0;break;case"object":switch(e.$$typeof){case a:case u:case c:case l:i=!0}}if(i)return n(r,e,""===t?"."+P(e,0):t),1;if(i=0,t=""===t?".":t+":",Array.isArray(e))for(var s=0;s<e.length;s++){var f=t+P(o=e[s],s);i+=R(o,f,n,r)}else if("function"==typeof(f=null==e?null:"function"==typeof(f=p&&e[p]||e["@@iterator"])?f:null))for(e=f.call(e),s=0;!(o=e.next()).done;)i+=R(o=o.value,f=t+P(o,s++),n,r);else"object"===o&&d("31","[object Object]"==(n=""+e)?"object with keys {"+Object.keys(e).join(", ")+"}":n,"");return i}function P(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+(""+e).replace(/[=:]/g,function(e){return t[e]})}(e.key):t.toString(36)}function L(e,t){e.func.call(e.context,t,e.count++)}function T(e,t,n){var r=e.result,o=e.keyPrefix;e=e.func.call(e.context,t,e.count++),Array.isArray(e)?A(e,r,n,i.thatReturnsArgument):null!=e&&(E(e)&&(t=o+(!e.key||t&&t.key===e.key?"":(""+e.key).replace(C,"$&/")+"/")+n,e={$$typeof:a,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}),r.push(e))}function A(e,t,n,r,o){var i="";null!=n&&(i=(""+n).replace(C,"$&/")+"/"),t=I(t,i,r,o),null==e||R(e,"",T,t),j(t)}var N={Children:{map:function(e,t,n){if(null==e)return e;var r=[];return A(e,r,null,t,n),r},forEach:function(e,t,n){if(null==e)return e;t=I(null,null,t,n),null==e||R(e,"",L,t),j(t)},count:function(e){return null==e?0:R(e,"",i.thatReturnsNull,null)},toArray:function(e){var t=[];return A(e,t,null,i.thatReturnsArgument),t},only:function(e){return E(e)||d("143"),e}},Component:g,PureComponent:y,unstable_AsyncComponent:v,Fragment:f,createElement:w,cloneElement:function(e,t,n){var o=r({},e.props),i=e.key,s=e.ref,u=e._owner;if(null!=t){if(void 0!==t.ref&&(s=t.ref,u=S.current),void 0!==t.key&&(i=""+t.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(l in t)_.call(t,l)&&!x.hasOwnProperty(l)&&(o[l]=void 0===t[l]&&void 0!==c?c[l]:t[l])}var l=arguments.length-2;if(1===l)o.children=n;else if(1<l){c=Array(l);for(var f=0;f<l;f++)c[f]=arguments[f+2];o.children=c}return{$$typeof:a,type:e.type,key:i,ref:s,props:o,_owner:u}},createFactory:function(e){var t=w.bind(null,e);return t.type=e,t},isValidElement:E,version:"16.2.0",__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:{ReactCurrentOwner:S,assign:r}},M=Object.freeze({default:N}),U=M&&N||M;e.exports=U.default?U.default:U},function(e,t,n){"use strict";var r=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,s,a=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),u=1;u<arguments.length;u++){for(var c in n=Object(arguments[u]))o.call(n,c)&&(a[c]=n[c]);if(r){s=r(n);for(var l=0;l<s.length;l++)i.call(n,s[l])&&(a[s[l]]=n[s[l]])}}return a}},function(e,t,n){"use strict";e.exports={}},function(e,t,n){e.exports=n(10)()},function(e,t,n){"use strict";var r=n(1),o=n(11),i=n(12);e.exports=function(){function e(e,t,n,r,s,a){a!==i&&o(!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,exact:t};return n.checkPropTypes=r,n.PropTypes=n,n}},function(e,t,n){"use strict";e.exports=function(e,t,n,r,o,i,s,a){if(!e){var u;if(void 0===t)u=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,o,i,s,a],l=0;(u=new Error(t.replace(/%s/g,function(){return c[l++]}))).name="Invariant Violation"}throw u.framesToPop=1,u}}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=s(n(0));n(14);var i=s(n(17));function s(e){return e&&e.__esModule?e:{default:e}}var a=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.suggestionListRef=null,n.setSuggestionListRef=function(e){n.suggestionListRef=e},n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,o.default.Component),r(t,[{key:"onMouseOver",value:function(e){for(var t=this.suggestionListRef.children,n=e.target,r=n.parentElement,o=0;o<t.length;o++){var i=t[o];i.className="",this.setItemAsSelected(n,r,i,o)}}},{key:"setItemAsSelected",value:function(e,t,n,r){var o=this.props.onSelectedItemIndex;e!==n&&t!==n||(n.className="selected",o(r))}},{key:"render",value:function(){var e=this,t=this.props,n=t.show,r=t.suggestions,s=t.suggestionListClass,a=t.onClickItem,u=t.selectedItemIndex,c=t.suggestionHeightStyle;if(n){var l=r.map(function(t,n){return o.default.createElement(i.default,{key:n,index:n,selectedItemIndex:u,item:t,onClick:function(e){return a(e)},onMouseOver:function(t){return e.onMouseOver(t)}})});return o.default.createElement("div",{className:s,style:c},o.default.createElement("ul",{ref:this.setSuggestionListRef},l))}return null}}]),t}();t.default=a},function(e,t,n){var r=n(15);"string"==typeof r&&(r=[[e.i,r,""]]);n(3)(r,{hmr:!0,transform:void 0,insertInto:void 0}),r.locals&&(e.exports=r.locals)},function(e,t,n){(e.exports=n(2)(!1)).push([e.i,".suggestions-container{width:400px;webkit-box-shadow:0 4px 10px rgba(53,60,72,.1);box-shadow:0 4px 10px rgba(53,60,72,.1);border-radius:4px;z-index:1;background-color:#fff;margin-top:.5rem;position:absolute;overflow:scroll}.suggestions-container ul{padding:0;margin:0;list-style:none;font-size:.9rem;display:flex;flex-direction:column;text-align:start}.suggestions-container ul li{cursor:pointer}.suggestions-container ul li span{padding:.8rem;letter-spacing:.2px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-transform:lowercase;display:block}.suggestions-container ul li.selected{background-color:rgba(53,60,72,.1);padding-left:5px}.suggestions-container ul li.selected:first-child{border-top-left-radius:4px;border-top-right-radius:4px}",""])},function(e,t){e.exports=function(e){var t="undefined"!=typeof window&&window.location;if(!t)throw new Error("fixUrls requires window.location");if(!e||"string"!=typeof e)return e;var n=t.protocol+"//"+t.host,r=n+t.pathname.replace(/\/[^\/]*$/,"/");return e.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,function(e,t){var o,i=t.trim().replace(/^"(.*)"$/,function(e,t){return t}).replace(/^'(.*)'$/,function(e,t){return t});return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(i)?e:(o=0===i.indexOf("//")?i:0===i.indexOf("/")?n+i:r+i.replace(/^\.\//,""),"url("+JSON.stringify(o)+")")})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,o=(r=n(0))&&r.__esModule?r:{default:r};t.default=function(e){var t=e.index,n=e.selectedItemIndex,r=e.item,i=e.onClick,s=e.onMouseOver,a=t===n?"selected":"";return o.default.createElement("li",{className:a,onClick:function(e){return i(e)},onMouseOver:function(e){return s(e)}},o.default.createElement("span",null,r))}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=(r=n(0))&&r.__esModule?r:{default:r};n(4);var s=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.floatingLabelRef=null,n.setFloatingLabelRef=function(e){n.floatingLabelRef=e},n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.default.Component),o(t,[{key:"componentDidUpdate",value:function(){this.props.inputContainerClicked?this.focusElement():this.removeFocus()}},{key:"removeFocus",value:function(){var e=this.props,t=e.isInputEmpty,n=e.floatingLabel,r=e.inputContainerClicked;t&&n&&!r&&this.floatingLabelRef.classList.remove("focus"),n&&this.floatingLabelRef.classList.remove("focus-color")}},{key:"focusElement",value:function(){this.props.floatingLabel&&this.floatingLabelRef.classList.add("focus","focus-color")}},{key:"render",value:function(){var e=this.props,t=e.floatingLabel,n=e.placeholder;return t?i.default.createElement("span",{className:"search-input-container__title",ref:this.setFloatingLabelRef},i.default.createElement("label",null,n)):null}}]),t}();t.default=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.saveSearches=t.loadSearches=t.establishSuggestionsForTerm=t.selectItemIndex=t.hideSuggestions=t.resetAndHideSuggestions=t.addNewSearch=void 0;var r=n(20);t.addNewSearch=function(e){return function(t){var n=t.recentSearches;return{showSuggestions:!1,suggestions:[],recentSearches:n.includes(e)?n:[].concat(function(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)}(n),[e]),term:e,selectedItemIndex:-1}}},t.resetAndHideSuggestions=function(e){return{showSuggestions:!1,suggestions:[],selectedItemIndex:-1}},t.hideSuggestions=function(e){return{showSuggestions:!1,selectedItemIndex:-1,inputClicked:!1}},t.selectItemIndex=function(e){return function(t){return{selectedItemIndex:e}}},t.establishSuggestionsForTerm=function(e,t){return function(n){return e.length>0?{showSuggestions:!0,suggestions:e,term:t}:{showSuggestions:!1,term:t,selectedItemIndex:-1}}},t.loadSearches=r.loadSearches,t.saveSearches=r.saveSearches},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.saveSearches=function(e){try{var t=JSON.stringify(e);localStorage.setItem("searches",t)}catch(e){console.error("There was an error while persisting data to local storage")}},t.loadSearches=function(){try{var e=localStorage.getItem("searches");return null===e?[]:JSON.parse(e)}catch(e){console.error("There was an error while retrieving data from local storage")}}},function(e,t,n){var r=n(22);"string"==typeof r&&(r=[[e.i,r,""]]);n(3)(r,{hmr:!0,transform:void 0,insertInto:void 0}),r.locals&&(e.exports=r.locals)},function(e,t,n){(e.exports=n(2)(!1)).push([e.i,".search-input-container{display:flex;flex-direction:column}.search-input-container .search-input-container__inner{width:400px;position:absolute}.search-input-container .search-input-container__inner .search-input-container__title{position:absolute;pointer-events:none;transition:.4s cubic-bezier(.25,.8,.25,1),color .4s cubic-bezier(.25,.8,.25,1),width .4s cubic-bezier(.25,.8,.25,1);left:0}.search-input-container .search-input-container__inner .focus{transform:translateY(-1.28125em) scale(.75) perspective(100px) translateZ(.001px);transform-origin:0}.search-input-container .search-input-container__inner .focus-color{color:#008cba}.search-input-container .suggestion-input{border-top:none;border-left:none;border-right:none;border-bottom:1px solid #cacaca;outline:none;width:400px;font-size:.8rem;font-family:Open Sans,sans-serif;line-height:1.2}.search-input-container .suggestion-input:focus{border-bottom:2px solid #008cba}.end{align-items:flex-end}.start{align-items:flex-start}.center{align-items:center}",""])}]);