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

downshift

Package Overview
Dependencies
Maintainers
1
Versions
354
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

downshift - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

2

dist/downshift.cjs.js

@@ -941,4 +941,4 @@ 'use strict';

Enter: function Enter(event) {
event.preventDefault();
if (this.getState().isOpen) {
event.preventDefault();
this.selectHighlightedItem({

@@ -945,0 +945,0 @@ type: Downshift$1.stateChangeTypes.keyDownEnter

@@ -936,4 +936,4 @@ import React, { Component } from 'react';

Enter: function Enter(event) {
event.preventDefault();
if (this.getState().isOpen) {
event.preventDefault();
this.selectHighlightedItem({

@@ -940,0 +940,0 @@ type: Downshift$1.stateChangeTypes.keyDownEnter

@@ -918,4 +918,4 @@ 'use strict';

Enter: function Enter(event) {
event.preventDefault();
if (this.getState().isOpen) {
event.preventDefault();
this.selectHighlightedItem({

@@ -922,0 +922,0 @@ type: Downshift$1.stateChangeTypes.keyDownEnter

@@ -913,4 +913,4 @@ import React, { Component } from 'preact';

Enter: function Enter(event) {
event.preventDefault();
if (this.getState().isOpen) {
event.preventDefault();
this.selectHighlightedItem({

@@ -917,0 +917,0 @@ type: Downshift$1.stateChangeTypes.keyDownEnter

@@ -919,4 +919,4 @@ (function (global, factory) {

Enter: function Enter(event) {
event.preventDefault();
if (this.getState().isOpen) {
event.preventDefault();
this.selectHighlightedItem({

@@ -923,0 +923,0 @@ type: Downshift$1.stateChangeTypes.keyDownEnter

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("preact")):"function"==typeof define&&define.amd?define(["preact"],t):e.Downshift=t(e.React)}(this,function(e){"use strict";function t(e){var t=D[D.length-1]===e;D=t?[].concat(x(D),[e]):[e],o().innerHTML=""+D.filter(Boolean).map(n).join("")}function n(e,t){return'<div style="display:'+(t===D.length-1?"block":"none")+';">'+e+"</div>"}function o(){return P||((P=document.createElement("div")).setAttribute("id","a11y-status-message"),P.setAttribute("role","status"),P.setAttribute("aria-live","assertive"),P.setAttribute("aria-relevant","additions text"),Object.assign(P.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),document.body.appendChild(P),P)}function i(e){return"function"==typeof e?e:r}function r(){}function u(e,t,n){return null!==t&&t!==n.parentNode?e(t)?t:u(e,t.parentNode,n):null}function s(e,t){var n=A(e,t);if(null!==n){var o=getComputedStyle(n),i=n.getBoundingClientRect(),r=parseInt(o.borderTopWidth,10),u=parseInt(o.borderBottomWidth,10),s=i.top+r,l=e.getBoundingClientRect(),a=l.top+n.scrollTop-s;a<n.scrollTop?n.scrollTop=a:a+l.height+r+u>n.scrollTop+i.height&&(n.scrollTop=a+l.height-i.height+r+u)}}function l(e,t){var n=void 0;return function(){for(var o=arguments.length,i=Array(o),r=0;r<o;r++)i[r]=arguments[r];n&&clearTimeout(n),n=setTimeout(function(){n=null,e.apply(void 0,i)},t)}}function a(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=arguments.length,o=Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return t.some(function(t){return t&&t.apply(void 0,[e].concat(o)),e.defaultPrevented})}}function p(e){return e+"-"+O++}function d(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.find(function(e){return void 0!==e})}function h(e){return e===e&&"number"==typeof e}function c(e,t){return!(e=Array.isArray(e)?e[0]:e)&&t?t:e}function g(e){return e.nodeName?"string"==typeof e.nodeName:"string"==typeof e.type}function f(e){return e.props||e.attributes}function m(e,t){throw new Error('The property "'+t+'" is required in "'+e+'"')}function y(e,t){var n=t.refKey,o="ref"!==n,i=!g(e);if(i&&!o)throw new Error("downshift: You returned a non-DOM element. You must specify a refKey in getRootProps");if(!i&&o)throw new Error('downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified "'+n+'"');if(!f(e).hasOwnProperty(n))throw new Error('downshift: You must apply the ref prop "'+n+'" from getRootProps onto your root element.');if(!f(e).hasOwnProperty("onClick"))throw new Error('downshift: You must apply the "onClick" prop from getRootProps onto your root element.')}var v="default"in e?e.default:e,I=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},_=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}}(),w=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},b=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},S=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)},k=function(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},C=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},x=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)},P="undefined"==typeof document?null:document.getElementById("a11y-status-message"),D=[],O=1,A=u.bind(null,function(e){return e.scrollHeight>e.clientHeight}),H=function(e){function t(){var e;I(this,t);for(var n=arguments.length,o=Array(n),i=0;i<n;i++)o[i]=arguments[i];var r=C(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(o)));T.call(r);var u=r.getState({highlightedIndex:r.props.defaultHighlightedIndex,isOpen:r.props.defaultIsOpen,inputValue:r.props.defaultInputValue,selectedItem:r.props.defaultSelectedItem});return u.selectedItem&&(u.inputValue=r.props.itemToString(u.selectedItem)),r.state=u,r}return S(t,e),_(t,[{key:"getState",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state;return Object.keys(t).reduce(function(n,o){return n[o]=e.isControlledProp(o)?e.props[o]:t[o],n},{})}},{key:"isControlledProp",value:function(e){return void 0!==this.props[e]}},{key:"getItemCount",value:function(){return void 0===this.props.itemCount?this.items.length:this.props.itemCount}},{key:"internalSetState",value:function(e,n){var o=this,r=void 0,u={};return this.setState(function(n){n=o.getState(n);var i={},s={};return(e="function"==typeof e?e(n):e).hasOwnProperty("selectedItem")&&e.selectedItem!==n.selectedItem&&(r=e.selectedItem),e.type=e.type||t.stateChangeTypes.unknown,Object.keys(e).forEach(function(t){n[t]!==e[t]&&(u[t]=e[t]),"type"!==t&&(s[t]=e[t],o.isControlledProp(t)||(i[t]=e[t]))}),i},function(){i(n)(),Object.keys(u).length>1&&o.props.onStateChange(u,o.getStateAndHelpers()),void 0!==r&&o.props.onChange(r,o.getStateAndHelpers()),o.props.onUserAction(u,o.getStateAndHelpers())})}},{key:"getStateAndHelpers",value:function(){var e=this.getState(),t=e.highlightedIndex,n=e.inputValue,o=e.selectedItem,i=e.isOpen,r=this.props.itemToString,u=this.getRootProps,s=this.getButtonProps,l=this.getLabelProps,a=this.getInputProps,p=this.getItemProps,d=this.openMenu,h=this.closeMenu,c=this.toggleMenu,g=this.selectItem,f=this.selectItemAtIndex,m=this.selectHighlightedItem,y=this.setHighlightedIndex,v=this.clearSelection;return{getRootProps:u,getButtonProps:s,getLabelProps:l,getInputProps:a,getItemProps:p,reset:this.reset,openMenu:d,closeMenu:h,toggleMenu:c,selectItem:g,selectItemAtIndex:f,selectHighlightedItem:m,setHighlightedIndex:y,clearSelection:v,itemToString:r,highlightedIndex:t,inputValue:n,isOpen:i,selectedItem:o}}},{key:"getItemId",value:function(e){return this.id+"-item-"+e}},{key:"getItemIndexFromId",value:function(e){return e?Number(e.split(this.id+"-item-")[1]):null}},{key:"componentDidMount",value:function(){var e=this;this._isMounted=!0;var n=function(){e.isMouseDown=!0},o=function(n){e.isMouseDown=!1,n.target!==e._rootNode&&e._rootNode.contains(n.target)||!e.getState().isOpen||e.reset({type:t.stateChangeTypes.mouseUp})};window.addEventListener("mousedown",n),window.addEventListener("mouseup",o),this.cleanup=function(){e._isMounted=!1,window.removeEventListener("mousedown",n),window.removeEventListener("mouseup",o)}}},{key:"componentDidUpdate",value:function(e){this.isControlledProp("selectedItem")&&this.props.selectedItem!==e.selectedItem&&this.internalSetState({type:t.stateChangeTypes.controlledPropUpdatedSelectedItem,inputValue:this.props.itemToString(this.props.selectedItem)}),this.updateStatus()}},{key:"componentWillUnmount",value:function(){this.cleanup()}},{key:"render",value:function(){var e=c(this.props.children,r);this.items=[],this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;var t=c(e(this.getStateAndHelpers()));if(!t)return null;if(this.getRootProps.called)return y(t,this.getRootProps),t;if(g(t))return v.cloneElement(t,this.getRootProps(f(t)));throw new Error("downshift: If you return a non-DOM element, you must use apply the getRootProps function")}}]),t}(e.Component);H.defaultProps={defaultHighlightedIndex:null,defaultSelectedItem:null,defaultInputValue:"",defaultIsOpen:!1,getA11yStatusMessage:function(e){var t=e.isOpen,n=e.highlightedItem,o=e.selectedItem,i=e.resultCount,r=e.previousResultCount,u=e.itemToString;if(!t)return o?u(o):"";var s=i!==r;return i?!n||s?i+" "+(1===i?"result is":"results are")+" available, use up and down arrow keys to navigate.":u(n):"No results."},itemToString:function(e){return null==e?"":String(e)},onStateChange:function(){},onUserAction:function(){},onChange:function(){}},H.stateChangeTypes={unknown:"__autocomplete_unknown__",mouseUp:"__autocomplete_mouseup__",itemMouseEnter:"__autocomplete_item_mouseenter__",keyDownArrowUp:"__autocomplete_keydown_arrow_up__",keyDownArrowDown:"__autocomplete_keydown_arrow_down__",keyDownEscape:"__autocomplete_keydown_escape__",keyDownEnter:"__autocomplete_keydown_enter__",blurInput:"__autocomplete_blur_input__",changeInput:"__autocomplete_change_input__",keyDownSpaceButton:"__autocomplete_keydown_space_button__",clickButton:"__autocomplete_click_button__",controlledPropUpdatedSelectedItem:"__autocomplete_controlled_prop_updated_selected_item__"};var T=function(){var e=this;this.id=p("downshift"),this.root_handleClick=a(this.props.onClick,this.root_handleClick),this.input=null,this.items=[],this.previousResultCount=0,this.getItemNodeFromIndex=function(t){return document.getElementById(e.getItemId(t))},this.setHighlightedIndex=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.props.defaultHighlightedIndex,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.internalSetState(b({highlightedIndex:t},n),function(){s(e.getItemNodeFromIndex(e.getState().highlightedIndex),e._rootNode)})},this.openAndHighlightDefaultIndex=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.setHighlightedIndex(void 0,b({isOpen:!0},t))},this.highlightDefaultIndex=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.setHighlightedIndex(void 0,t)},this.moveHighlightedIndex=function(t,n){e.getState().isOpen?e.changeHighlightedIndex(t,n):e.openAndHighlightDefaultIndex(n)},this.changeHighlightedIndex=function(t,n){var o=e.getItemCount()-1;if(!(o<0)){var i=e.getState().highlightedIndex;null===i&&(i=t>0?-1:o+1);var r=i+t;r<0?r=o:r>o&&(r=0),e.setHighlightedIndex(r,n)}},this.clearSelection=function(t){e.internalSetState({selectedItem:null,inputValue:"",isOpen:!1},function(){var n=e._rootNode.querySelector("#"+e.inputId);n&&n.focus&&n.focus(),i(t)()})},this.selectItem=function(t,n,o){e.internalSetState(b({isOpen:!1,highlightedIndex:null,selectedItem:t,inputValue:e.props.itemToString(t)},n),i(o))},this.selectItemAtIndex=function(t,n,o){var i=e.items[t];i&&e.selectItem(i,n,o)},this.selectHighlightedItem=function(t,n){return e.selectItemAtIndex(e.getState().highlightedIndex,t,n)},this.rootRef=function(t){return e._rootNode=t},this.getRootProps=function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=n.refKey,i=void 0===o?"ref":o,r=n.onClick,u=k(n,["refKey","onClick"]);return e.getRootProps.called=!0,e.getRootProps.refKey=i,b((t={},w(t,i,e.rootRef),w(t,"onClick",a(r,e.root_handleClick)),t),u)},this.root_handleClick=function(t){t.preventDefault();var n=u(function(t){return h(e.getItemIndexFromId(t.getAttribute("id")))},t.target,e._rootNode);n&&e.selectItemAtIndex(e.getItemIndexFromId(n.getAttribute("id")))},this.keyDownHandlers={ArrowDown:function(e){e.preventDefault();var t=e.shiftKey?5:1;this.moveHighlightedIndex(t,{type:H.stateChangeTypes.keyDownArrowDown})},ArrowUp:function(e){e.preventDefault();var t=e.shiftKey?-5:-1;this.moveHighlightedIndex(t,{type:H.stateChangeTypes.keyDownArrowUp})},Enter:function(e){e.preventDefault(),this.getState().isOpen&&this.selectHighlightedItem({type:H.stateChangeTypes.keyDownEnter})},Escape:function(e){e.preventDefault(),this.reset({type:H.stateChangeTypes.keyDownEscape})}},this.buttonKeyDownHandlers=b({},this.keyDownHandlers,{" ":function(e){e.preventDefault(),this.toggleMenu({type:H.stateChangeTypes.keyDownSpaceButton})}}),this.getButtonProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onClick,o=t.onKeyDown,i=k(t,["onClick","onKeyDown"]),r=e.getState().isOpen;return b({role:"button","aria-label":r?"close menu":"open menu","aria-expanded":r,"aria-haspopup":!0,onClick:a(n,e.button_handleClick),onKeyDown:a(o,e.button_handleKeyDown)},i)},this.button_handleKeyDown=function(t){e.buttonKeyDownHandlers[t.key]&&e.buttonKeyDownHandlers[t.key].call(e,t)},this.button_handleClick=function(t){t.preventDefault(),e.toggleMenu({type:H.stateChangeTypes.clickButton})},this.getLabelProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(e.getLabelProps.called=!0,e.getInputProps.called&&t.htmlFor&&t.htmlFor!==e.inputId)throw new Error('downshift: You provided the htmlFor of "'+t.htmlFor+'" for your label, but the id of your input is "'+e.inputId+'". You must either remove the id from your input or set the htmlFor of the label equal to the input id.');return e.inputId=d(e.inputId,t.htmlFor,p("downshift-input")),b({},t,{htmlFor:e.inputId})},this.getInputProps=function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=n.onKeyDown,i=n.onBlur,r=n.onChange,u=n.onInput,s=k(n,["onKeyDown","onBlur","onChange","onInput"]);if(e.getInputProps.called=!0,e.getLabelProps.called&&s.id&&s.id!==e.inputId)throw new Error('downshift: You provided the id of "'+s.id+'" for your input, but the htmlFor of your label is "'+e.inputId+'". You must either remove the id from your input or set the htmlFor of the label equal to the input id.');e.inputId=d(e.inputId,s.id,p("downshift-input"));var l=e.getState(),h=l.inputValue,c=l.isOpen,g=l.highlightedIndex;return b((t={role:"combobox","aria-autocomplete":"list","aria-expanded":c,"aria-activedescendant":"number"==typeof g&&g>=0?e.getItemId(g):null,autoComplete:"off",value:h},w(t,"onInput",a(r,u,e.input_handleChange)),w(t,"onKeyDown",a(o,e.input_handleKeyDown)),w(t,"onBlur",a(i,e.input_handleBlur)),t),s,{id:e.inputId})},this.input_handleKeyDown=function(t){t.key&&e.keyDownHandlers[t.key]&&e.keyDownHandlers[t.key].call(e,t)},this.input_handleChange=function(t){e.internalSetState({type:H.stateChangeTypes.changeInput,isOpen:!0,inputValue:t.target.value})},this.input_handleBlur=function(){e.isMouseDown||e.reset({type:H.stateChangeTypes.blurInput})},this.getItemProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onMouseEnter,o=t.index,i=t.item,r=void 0===i?m("getItemProps","item"):i,u=k(t,["onMouseEnter","index","item"]);return void 0===o?(e.items.push(r),o=e.items.indexOf(r)):e.items[o]=r,b({id:e.getItemId(o),onMouseEnter:a(n,function(){e.setHighlightedIndex(o,{type:H.stateChangeTypes.itemMouseEnter})})},u)},this.reset=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];e.internalSetState(function(n){var o=n.selectedItem;return b({isOpen:!1,highlightedIndex:null,inputValue:e.props.itemToString(o)},t)},i(n))},this.toggleMenu=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];e.internalSetState(function(e){var n=e.isOpen;return b({isOpen:!n},t)},function(){e.getState().isOpen&&e.highlightDefaultIndex(),i(n)()})},this.openMenu=function(t){e.internalSetState({isOpen:!0},i(t))},this.closeMenu=function(t){e.internalSetState({isOpen:!1},i(t))},this.updateStatus=l(function(){if(e._isMounted){var n=e.getState(),o=e.items[n.highlightedIndex]||{},i=e.getItemCount(),r=e.props.getA11yStatusMessage(b({itemToString:e.props.itemToString,previousResultCount:e.previousResultCount,resultCount:i,highlightedItem:o},n));e.previousResultCount=i,t(r)}},200)};return H.default=H,H});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("preact")):"function"==typeof define&&define.amd?define(["preact"],t):e.Downshift=t(e.React)}(this,function(e){"use strict";function t(e){var t=D[D.length-1]===e;D=t?[].concat(x(D),[e]):[e],o().innerHTML=""+D.filter(Boolean).map(n).join("")}function n(e,t){return'<div style="display:'+(t===D.length-1?"block":"none")+';">'+e+"</div>"}function o(){return P||((P=document.createElement("div")).setAttribute("id","a11y-status-message"),P.setAttribute("role","status"),P.setAttribute("aria-live","assertive"),P.setAttribute("aria-relevant","additions text"),Object.assign(P.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),document.body.appendChild(P),P)}function i(e){return"function"==typeof e?e:r}function r(){}function u(e,t,n){return null!==t&&t!==n.parentNode?e(t)?t:u(e,t.parentNode,n):null}function s(e,t){var n=A(e,t);if(null!==n){var o=getComputedStyle(n),i=n.getBoundingClientRect(),r=parseInt(o.borderTopWidth,10),u=parseInt(o.borderBottomWidth,10),s=i.top+r,l=e.getBoundingClientRect(),a=l.top+n.scrollTop-s;a<n.scrollTop?n.scrollTop=a:a+l.height+r+u>n.scrollTop+i.height&&(n.scrollTop=a+l.height-i.height+r+u)}}function l(e,t){var n=void 0;return function(){for(var o=arguments.length,i=Array(o),r=0;r<o;r++)i[r]=arguments[r];n&&clearTimeout(n),n=setTimeout(function(){n=null,e.apply(void 0,i)},t)}}function a(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=arguments.length,o=Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return t.some(function(t){return t&&t.apply(void 0,[e].concat(o)),e.defaultPrevented})}}function p(e){return e+"-"+O++}function d(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.find(function(e){return void 0!==e})}function h(e){return e===e&&"number"==typeof e}function c(e,t){return!(e=Array.isArray(e)?e[0]:e)&&t?t:e}function g(e){return e.nodeName?"string"==typeof e.nodeName:"string"==typeof e.type}function f(e){return e.props||e.attributes}function m(e,t){throw new Error('The property "'+t+'" is required in "'+e+'"')}function y(e,t){var n=t.refKey,o="ref"!==n,i=!g(e);if(i&&!o)throw new Error("downshift: You returned a non-DOM element. You must specify a refKey in getRootProps");if(!i&&o)throw new Error('downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified "'+n+'"');if(!f(e).hasOwnProperty(n))throw new Error('downshift: You must apply the ref prop "'+n+'" from getRootProps onto your root element.');if(!f(e).hasOwnProperty("onClick"))throw new Error('downshift: You must apply the "onClick" prop from getRootProps onto your root element.')}var v="default"in e?e.default:e,I=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},_=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}}(),w=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},b=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},S=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)},k=function(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},C=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},x=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)},P="undefined"==typeof document?null:document.getElementById("a11y-status-message"),D=[],O=1,A=u.bind(null,function(e){return e.scrollHeight>e.clientHeight}),H=function(e){function t(){var e;I(this,t);for(var n=arguments.length,o=Array(n),i=0;i<n;i++)o[i]=arguments[i];var r=C(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(o)));T.call(r);var u=r.getState({highlightedIndex:r.props.defaultHighlightedIndex,isOpen:r.props.defaultIsOpen,inputValue:r.props.defaultInputValue,selectedItem:r.props.defaultSelectedItem});return u.selectedItem&&(u.inputValue=r.props.itemToString(u.selectedItem)),r.state=u,r}return S(t,e),_(t,[{key:"getState",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state;return Object.keys(t).reduce(function(n,o){return n[o]=e.isControlledProp(o)?e.props[o]:t[o],n},{})}},{key:"isControlledProp",value:function(e){return void 0!==this.props[e]}},{key:"getItemCount",value:function(){return void 0===this.props.itemCount?this.items.length:this.props.itemCount}},{key:"internalSetState",value:function(e,n){var o=this,r=void 0,u={};return this.setState(function(n){n=o.getState(n);var i={},s={};return(e="function"==typeof e?e(n):e).hasOwnProperty("selectedItem")&&e.selectedItem!==n.selectedItem&&(r=e.selectedItem),e.type=e.type||t.stateChangeTypes.unknown,Object.keys(e).forEach(function(t){n[t]!==e[t]&&(u[t]=e[t]),"type"!==t&&(s[t]=e[t],o.isControlledProp(t)||(i[t]=e[t]))}),i},function(){i(n)(),Object.keys(u).length>1&&o.props.onStateChange(u,o.getStateAndHelpers()),void 0!==r&&o.props.onChange(r,o.getStateAndHelpers()),o.props.onUserAction(u,o.getStateAndHelpers())})}},{key:"getStateAndHelpers",value:function(){var e=this.getState(),t=e.highlightedIndex,n=e.inputValue,o=e.selectedItem,i=e.isOpen,r=this.props.itemToString,u=this.getRootProps,s=this.getButtonProps,l=this.getLabelProps,a=this.getInputProps,p=this.getItemProps,d=this.openMenu,h=this.closeMenu,c=this.toggleMenu,g=this.selectItem,f=this.selectItemAtIndex,m=this.selectHighlightedItem,y=this.setHighlightedIndex,v=this.clearSelection;return{getRootProps:u,getButtonProps:s,getLabelProps:l,getInputProps:a,getItemProps:p,reset:this.reset,openMenu:d,closeMenu:h,toggleMenu:c,selectItem:g,selectItemAtIndex:f,selectHighlightedItem:m,setHighlightedIndex:y,clearSelection:v,itemToString:r,highlightedIndex:t,inputValue:n,isOpen:i,selectedItem:o}}},{key:"getItemId",value:function(e){return this.id+"-item-"+e}},{key:"getItemIndexFromId",value:function(e){return e?Number(e.split(this.id+"-item-")[1]):null}},{key:"componentDidMount",value:function(){var e=this;this._isMounted=!0;var n=function(){e.isMouseDown=!0},o=function(n){e.isMouseDown=!1,n.target!==e._rootNode&&e._rootNode.contains(n.target)||!e.getState().isOpen||e.reset({type:t.stateChangeTypes.mouseUp})};window.addEventListener("mousedown",n),window.addEventListener("mouseup",o),this.cleanup=function(){e._isMounted=!1,window.removeEventListener("mousedown",n),window.removeEventListener("mouseup",o)}}},{key:"componentDidUpdate",value:function(e){this.isControlledProp("selectedItem")&&this.props.selectedItem!==e.selectedItem&&this.internalSetState({type:t.stateChangeTypes.controlledPropUpdatedSelectedItem,inputValue:this.props.itemToString(this.props.selectedItem)}),this.updateStatus()}},{key:"componentWillUnmount",value:function(){this.cleanup()}},{key:"render",value:function(){var e=c(this.props.children,r);this.items=[],this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;var t=c(e(this.getStateAndHelpers()));if(!t)return null;if(this.getRootProps.called)return y(t,this.getRootProps),t;if(g(t))return v.cloneElement(t,this.getRootProps(f(t)));throw new Error("downshift: If you return a non-DOM element, you must use apply the getRootProps function")}}]),t}(e.Component);H.defaultProps={defaultHighlightedIndex:null,defaultSelectedItem:null,defaultInputValue:"",defaultIsOpen:!1,getA11yStatusMessage:function(e){var t=e.isOpen,n=e.highlightedItem,o=e.selectedItem,i=e.resultCount,r=e.previousResultCount,u=e.itemToString;if(!t)return o?u(o):"";var s=i!==r;return i?!n||s?i+" "+(1===i?"result is":"results are")+" available, use up and down arrow keys to navigate.":u(n):"No results."},itemToString:function(e){return null==e?"":String(e)},onStateChange:function(){},onUserAction:function(){},onChange:function(){}},H.stateChangeTypes={unknown:"__autocomplete_unknown__",mouseUp:"__autocomplete_mouseup__",itemMouseEnter:"__autocomplete_item_mouseenter__",keyDownArrowUp:"__autocomplete_keydown_arrow_up__",keyDownArrowDown:"__autocomplete_keydown_arrow_down__",keyDownEscape:"__autocomplete_keydown_escape__",keyDownEnter:"__autocomplete_keydown_enter__",blurInput:"__autocomplete_blur_input__",changeInput:"__autocomplete_change_input__",keyDownSpaceButton:"__autocomplete_keydown_space_button__",clickButton:"__autocomplete_click_button__",controlledPropUpdatedSelectedItem:"__autocomplete_controlled_prop_updated_selected_item__"};var T=function(){var e=this;this.id=p("downshift"),this.root_handleClick=a(this.props.onClick,this.root_handleClick),this.input=null,this.items=[],this.previousResultCount=0,this.getItemNodeFromIndex=function(t){return document.getElementById(e.getItemId(t))},this.setHighlightedIndex=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.props.defaultHighlightedIndex,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.internalSetState(b({highlightedIndex:t},n),function(){s(e.getItemNodeFromIndex(e.getState().highlightedIndex),e._rootNode)})},this.openAndHighlightDefaultIndex=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.setHighlightedIndex(void 0,b({isOpen:!0},t))},this.highlightDefaultIndex=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.setHighlightedIndex(void 0,t)},this.moveHighlightedIndex=function(t,n){e.getState().isOpen?e.changeHighlightedIndex(t,n):e.openAndHighlightDefaultIndex(n)},this.changeHighlightedIndex=function(t,n){var o=e.getItemCount()-1;if(!(o<0)){var i=e.getState().highlightedIndex;null===i&&(i=t>0?-1:o+1);var r=i+t;r<0?r=o:r>o&&(r=0),e.setHighlightedIndex(r,n)}},this.clearSelection=function(t){e.internalSetState({selectedItem:null,inputValue:"",isOpen:!1},function(){var n=e._rootNode.querySelector("#"+e.inputId);n&&n.focus&&n.focus(),i(t)()})},this.selectItem=function(t,n,o){e.internalSetState(b({isOpen:!1,highlightedIndex:null,selectedItem:t,inputValue:e.props.itemToString(t)},n),i(o))},this.selectItemAtIndex=function(t,n,o){var i=e.items[t];i&&e.selectItem(i,n,o)},this.selectHighlightedItem=function(t,n){return e.selectItemAtIndex(e.getState().highlightedIndex,t,n)},this.rootRef=function(t){return e._rootNode=t},this.getRootProps=function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=n.refKey,i=void 0===o?"ref":o,r=n.onClick,u=k(n,["refKey","onClick"]);return e.getRootProps.called=!0,e.getRootProps.refKey=i,b((t={},w(t,i,e.rootRef),w(t,"onClick",a(r,e.root_handleClick)),t),u)},this.root_handleClick=function(t){t.preventDefault();var n=u(function(t){return h(e.getItemIndexFromId(t.getAttribute("id")))},t.target,e._rootNode);n&&e.selectItemAtIndex(e.getItemIndexFromId(n.getAttribute("id")))},this.keyDownHandlers={ArrowDown:function(e){e.preventDefault();var t=e.shiftKey?5:1;this.moveHighlightedIndex(t,{type:H.stateChangeTypes.keyDownArrowDown})},ArrowUp:function(e){e.preventDefault();var t=e.shiftKey?-5:-1;this.moveHighlightedIndex(t,{type:H.stateChangeTypes.keyDownArrowUp})},Enter:function(e){this.getState().isOpen&&(e.preventDefault(),this.selectHighlightedItem({type:H.stateChangeTypes.keyDownEnter}))},Escape:function(e){e.preventDefault(),this.reset({type:H.stateChangeTypes.keyDownEscape})}},this.buttonKeyDownHandlers=b({},this.keyDownHandlers,{" ":function(e){e.preventDefault(),this.toggleMenu({type:H.stateChangeTypes.keyDownSpaceButton})}}),this.getButtonProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onClick,o=t.onKeyDown,i=k(t,["onClick","onKeyDown"]),r=e.getState().isOpen;return b({role:"button","aria-label":r?"close menu":"open menu","aria-expanded":r,"aria-haspopup":!0,onClick:a(n,e.button_handleClick),onKeyDown:a(o,e.button_handleKeyDown)},i)},this.button_handleKeyDown=function(t){e.buttonKeyDownHandlers[t.key]&&e.buttonKeyDownHandlers[t.key].call(e,t)},this.button_handleClick=function(t){t.preventDefault(),e.toggleMenu({type:H.stateChangeTypes.clickButton})},this.getLabelProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(e.getLabelProps.called=!0,e.getInputProps.called&&t.htmlFor&&t.htmlFor!==e.inputId)throw new Error('downshift: You provided the htmlFor of "'+t.htmlFor+'" for your label, but the id of your input is "'+e.inputId+'". You must either remove the id from your input or set the htmlFor of the label equal to the input id.');return e.inputId=d(e.inputId,t.htmlFor,p("downshift-input")),b({},t,{htmlFor:e.inputId})},this.getInputProps=function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=n.onKeyDown,i=n.onBlur,r=n.onChange,u=n.onInput,s=k(n,["onKeyDown","onBlur","onChange","onInput"]);if(e.getInputProps.called=!0,e.getLabelProps.called&&s.id&&s.id!==e.inputId)throw new Error('downshift: You provided the id of "'+s.id+'" for your input, but the htmlFor of your label is "'+e.inputId+'". You must either remove the id from your input or set the htmlFor of the label equal to the input id.');e.inputId=d(e.inputId,s.id,p("downshift-input"));var l=e.getState(),h=l.inputValue,c=l.isOpen,g=l.highlightedIndex;return b((t={role:"combobox","aria-autocomplete":"list","aria-expanded":c,"aria-activedescendant":"number"==typeof g&&g>=0?e.getItemId(g):null,autoComplete:"off",value:h},w(t,"onInput",a(r,u,e.input_handleChange)),w(t,"onKeyDown",a(o,e.input_handleKeyDown)),w(t,"onBlur",a(i,e.input_handleBlur)),t),s,{id:e.inputId})},this.input_handleKeyDown=function(t){t.key&&e.keyDownHandlers[t.key]&&e.keyDownHandlers[t.key].call(e,t)},this.input_handleChange=function(t){e.internalSetState({type:H.stateChangeTypes.changeInput,isOpen:!0,inputValue:t.target.value})},this.input_handleBlur=function(){e.isMouseDown||e.reset({type:H.stateChangeTypes.blurInput})},this.getItemProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onMouseEnter,o=t.index,i=t.item,r=void 0===i?m("getItemProps","item"):i,u=k(t,["onMouseEnter","index","item"]);return void 0===o?(e.items.push(r),o=e.items.indexOf(r)):e.items[o]=r,b({id:e.getItemId(o),onMouseEnter:a(n,function(){e.setHighlightedIndex(o,{type:H.stateChangeTypes.itemMouseEnter})})},u)},this.reset=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];e.internalSetState(function(n){var o=n.selectedItem;return b({isOpen:!1,highlightedIndex:null,inputValue:e.props.itemToString(o)},t)},i(n))},this.toggleMenu=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];e.internalSetState(function(e){var n=e.isOpen;return b({isOpen:!n},t)},function(){e.getState().isOpen&&e.highlightDefaultIndex(),i(n)()})},this.openMenu=function(t){e.internalSetState({isOpen:!0},i(t))},this.closeMenu=function(t){e.internalSetState({isOpen:!1},i(t))},this.updateStatus=l(function(){if(e._isMounted){var n=e.getState(),o=e.items[n.highlightedIndex]||{},i=e.getItemCount(),r=e.props.getA11yStatusMessage(b({itemToString:e.props.itemToString,previousResultCount:e.previousResultCount,resultCount:i,highlightedItem:o},n));e.previousResultCount=i,t(r)}},200)};return H.default=H,H});
//# sourceMappingURL=downshift.preact.umd.min.js.map

@@ -942,4 +942,4 @@ (function (global, factory) {

Enter: function Enter(event) {
event.preventDefault();
if (this.getState().isOpen) {
event.preventDefault();
this.selectHighlightedItem({

@@ -946,0 +946,0 @@ type: Downshift$1.stateChangeTypes.keyDownEnter

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],t):e.Downshift=t(e.React,e.PropTypes)}(this,function(e,t){"use strict";function n(e){var t=O[O.length-1]===e;O=t?[].concat(P(O),[e]):[e],i().innerHTML=""+O.filter(Boolean).map(o).join("")}function o(e,t){return'<div style="display:'+(t===O.length-1?"block":"none")+';">'+e+"</div>"}function i(){return D||((D=document.createElement("div")).setAttribute("id","a11y-status-message"),D.setAttribute("role","status"),D.setAttribute("aria-live","assertive"),D.setAttribute("aria-relevant","additions text"),Object.assign(D.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),document.body.appendChild(D),D)}function r(e){return"function"==typeof e?e:u}function u(){}function s(e,t,n){return null!==t&&t!==n.parentNode?e(t)?t:s(e,t.parentNode,n):null}function l(e,t){var n=T(e,t);if(null!==n){var o=getComputedStyle(n),i=n.getBoundingClientRect(),r=parseInt(o.borderTopWidth,10),u=parseInt(o.borderBottomWidth,10),s=i.top+r,l=e.getBoundingClientRect(),a=l.top+n.scrollTop-s;a<n.scrollTop?n.scrollTop=a:a+l.height+r+u>n.scrollTop+i.height&&(n.scrollTop=a+l.height-i.height+r+u)}}function a(e,t){var n=void 0;return function(){for(var o=arguments.length,i=Array(o),r=0;r<o;r++)i[r]=arguments[r];n&&clearTimeout(n),n=setTimeout(function(){n=null,e.apply(void 0,i)},t)}}function p(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=arguments.length,o=Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return t.some(function(t){return t&&t.apply(void 0,[e].concat(o)),e.defaultPrevented})}}function d(e){return e+"-"+A++}function h(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.find(function(e){return void 0!==e})}function c(e){return e===e&&"number"==typeof e}function g(e,t){return!(e=Array.isArray(e)?e[0]:e)&&t?t:e}function f(e){return e.nodeName?"string"==typeof e.nodeName:"string"==typeof e.type}function m(e){return e.props||e.attributes}function y(e,t){throw new Error('The property "'+t+'" is required in "'+e+'"')}function I(e,t){var n=t.refKey,o="ref"!==n,i=!f(e);if(i&&!o)throw new Error("downshift: You returned a non-DOM element. You must specify a refKey in getRootProps");if(!i&&o)throw new Error('downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified "'+n+'"');if(!m(e).hasOwnProperty(n))throw new Error('downshift: You must apply the ref prop "'+n+'" from getRootProps onto your root element.');if(!m(e).hasOwnProperty("onClick"))throw new Error('downshift: You must apply the "onClick" prop from getRootProps onto your root element.')}var v="default"in e?e.default:e;t=t&&t.hasOwnProperty("default")?t.default:t;var _=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},w=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}}(),b=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},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},C=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)},k=function(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},x=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},P=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)},D="undefined"==typeof document?null:document.getElementById("a11y-status-message"),O=[],A=1,T=s.bind(null,function(e){return e.scrollHeight>e.clientHeight}),H=function(e){function t(){var e;_(this,t);for(var n=arguments.length,o=Array(n),i=0;i<n;i++)o[i]=arguments[i];var r=x(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(o)));E.call(r);var u=r.getState({highlightedIndex:r.props.defaultHighlightedIndex,isOpen:r.props.defaultIsOpen,inputValue:r.props.defaultInputValue,selectedItem:r.props.defaultSelectedItem});return u.selectedItem&&(u.inputValue=r.props.itemToString(u.selectedItem)),r.state=u,r}return C(t,e),w(t,[{key:"getState",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state;return Object.keys(t).reduce(function(n,o){return n[o]=e.isControlledProp(o)?e.props[o]:t[o],n},{})}},{key:"isControlledProp",value:function(e){return void 0!==this.props[e]}},{key:"getItemCount",value:function(){return void 0===this.props.itemCount?this.items.length:this.props.itemCount}},{key:"internalSetState",value:function(e,n){var o=this,i=void 0,u={};return this.setState(function(n){n=o.getState(n);var r={},s={};return(e="function"==typeof e?e(n):e).hasOwnProperty("selectedItem")&&e.selectedItem!==n.selectedItem&&(i=e.selectedItem),e.type=e.type||t.stateChangeTypes.unknown,Object.keys(e).forEach(function(t){n[t]!==e[t]&&(u[t]=e[t]),"type"!==t&&(s[t]=e[t],o.isControlledProp(t)||(r[t]=e[t]))}),r},function(){r(n)(),Object.keys(u).length>1&&o.props.onStateChange(u,o.getStateAndHelpers()),void 0!==i&&o.props.onChange(i,o.getStateAndHelpers()),o.props.onUserAction(u,o.getStateAndHelpers())})}},{key:"getStateAndHelpers",value:function(){var e=this.getState(),t=e.highlightedIndex,n=e.inputValue,o=e.selectedItem,i=e.isOpen,r=this.props.itemToString,u=this.getRootProps,s=this.getButtonProps,l=this.getLabelProps,a=this.getInputProps,p=this.getItemProps,d=this.openMenu,h=this.closeMenu,c=this.toggleMenu,g=this.selectItem,f=this.selectItemAtIndex,m=this.selectHighlightedItem,y=this.setHighlightedIndex,I=this.clearSelection;return{getRootProps:u,getButtonProps:s,getLabelProps:l,getInputProps:a,getItemProps:p,reset:this.reset,openMenu:d,closeMenu:h,toggleMenu:c,selectItem:g,selectItemAtIndex:f,selectHighlightedItem:m,setHighlightedIndex:y,clearSelection:I,itemToString:r,highlightedIndex:t,inputValue:n,isOpen:i,selectedItem:o}}},{key:"getItemId",value:function(e){return this.id+"-item-"+e}},{key:"getItemIndexFromId",value:function(e){return e?Number(e.split(this.id+"-item-")[1]):null}},{key:"componentDidMount",value:function(){var e=this;this._isMounted=!0;var n=function(){e.isMouseDown=!0},o=function(n){e.isMouseDown=!1,n.target!==e._rootNode&&e._rootNode.contains(n.target)||!e.getState().isOpen||e.reset({type:t.stateChangeTypes.mouseUp})};window.addEventListener("mousedown",n),window.addEventListener("mouseup",o),this.cleanup=function(){e._isMounted=!1,window.removeEventListener("mousedown",n),window.removeEventListener("mouseup",o)}}},{key:"componentDidUpdate",value:function(e){this.isControlledProp("selectedItem")&&this.props.selectedItem!==e.selectedItem&&this.internalSetState({type:t.stateChangeTypes.controlledPropUpdatedSelectedItem,inputValue:this.props.itemToString(this.props.selectedItem)}),this.updateStatus()}},{key:"componentWillUnmount",value:function(){this.cleanup()}},{key:"render",value:function(){var e=g(this.props.children,u);this.items=[],this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;var t=g(e(this.getStateAndHelpers()));if(!t)return null;if(this.getRootProps.called)return I(t,this.getRootProps),t;if(f(t))return v.cloneElement(t,this.getRootProps(m(t)));throw new Error("downshift: If you return a non-DOM element, you must use apply the getRootProps function")}}]),t}(e.Component);H.propTypes={children:t.func,defaultHighlightedIndex:t.number,defaultSelectedItem:t.any,defaultInputValue:t.string,defaultIsOpen:t.bool,getA11yStatusMessage:t.func,itemToString:t.func,onChange:t.func,onStateChange:t.func,onUserAction:t.func,onClick:t.func,itemCount:t.number,selectedItem:t.any,isOpen:t.bool,inputValue:t.string,highlightedIndex:t.number},H.defaultProps={defaultHighlightedIndex:null,defaultSelectedItem:null,defaultInputValue:"",defaultIsOpen:!1,getA11yStatusMessage:function(e){var t=e.isOpen,n=e.highlightedItem,o=e.selectedItem,i=e.resultCount,r=e.previousResultCount,u=e.itemToString;if(!t)return o?u(o):"";var s=i!==r;return i?!n||s?i+" "+(1===i?"result is":"results are")+" available, use up and down arrow keys to navigate.":u(n):"No results."},itemToString:function(e){return null==e?"":String(e)},onStateChange:function(){},onUserAction:function(){},onChange:function(){}},H.stateChangeTypes={unknown:"__autocomplete_unknown__",mouseUp:"__autocomplete_mouseup__",itemMouseEnter:"__autocomplete_item_mouseenter__",keyDownArrowUp:"__autocomplete_keydown_arrow_up__",keyDownArrowDown:"__autocomplete_keydown_arrow_down__",keyDownEscape:"__autocomplete_keydown_escape__",keyDownEnter:"__autocomplete_keydown_enter__",blurInput:"__autocomplete_blur_input__",changeInput:"__autocomplete_change_input__",keyDownSpaceButton:"__autocomplete_keydown_space_button__",clickButton:"__autocomplete_click_button__",controlledPropUpdatedSelectedItem:"__autocomplete_controlled_prop_updated_selected_item__"};var E=function(){var e=this;this.id=d("downshift"),this.root_handleClick=p(this.props.onClick,this.root_handleClick),this.input=null,this.items=[],this.previousResultCount=0,this.getItemNodeFromIndex=function(t){return document.getElementById(e.getItemId(t))},this.setHighlightedIndex=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.props.defaultHighlightedIndex,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.internalSetState(S({highlightedIndex:t},n),function(){l(e.getItemNodeFromIndex(e.getState().highlightedIndex),e._rootNode)})},this.openAndHighlightDefaultIndex=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.setHighlightedIndex(void 0,S({isOpen:!0},t))},this.highlightDefaultIndex=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.setHighlightedIndex(void 0,t)},this.moveHighlightedIndex=function(t,n){e.getState().isOpen?e.changeHighlightedIndex(t,n):e.openAndHighlightDefaultIndex(n)},this.changeHighlightedIndex=function(t,n){var o=e.getItemCount()-1;if(!(o<0)){var i=e.getState().highlightedIndex;null===i&&(i=t>0?-1:o+1);var r=i+t;r<0?r=o:r>o&&(r=0),e.setHighlightedIndex(r,n)}},this.clearSelection=function(t){e.internalSetState({selectedItem:null,inputValue:"",isOpen:!1},function(){var n=e._rootNode.querySelector("#"+e.inputId);n&&n.focus&&n.focus(),r(t)()})},this.selectItem=function(t,n,o){e.internalSetState(S({isOpen:!1,highlightedIndex:null,selectedItem:t,inputValue:e.props.itemToString(t)},n),r(o))},this.selectItemAtIndex=function(t,n,o){var i=e.items[t];i&&e.selectItem(i,n,o)},this.selectHighlightedItem=function(t,n){return e.selectItemAtIndex(e.getState().highlightedIndex,t,n)},this.rootRef=function(t){return e._rootNode=t},this.getRootProps=function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=n.refKey,i=void 0===o?"ref":o,r=n.onClick,u=k(n,["refKey","onClick"]);return e.getRootProps.called=!0,e.getRootProps.refKey=i,S((t={},b(t,i,e.rootRef),b(t,"onClick",p(r,e.root_handleClick)),t),u)},this.root_handleClick=function(t){t.preventDefault();var n=s(function(t){return c(e.getItemIndexFromId(t.getAttribute("id")))},t.target,e._rootNode);n&&e.selectItemAtIndex(e.getItemIndexFromId(n.getAttribute("id")))},this.keyDownHandlers={ArrowDown:function(e){e.preventDefault();var t=e.shiftKey?5:1;this.moveHighlightedIndex(t,{type:H.stateChangeTypes.keyDownArrowDown})},ArrowUp:function(e){e.preventDefault();var t=e.shiftKey?-5:-1;this.moveHighlightedIndex(t,{type:H.stateChangeTypes.keyDownArrowUp})},Enter:function(e){e.preventDefault(),this.getState().isOpen&&this.selectHighlightedItem({type:H.stateChangeTypes.keyDownEnter})},Escape:function(e){e.preventDefault(),this.reset({type:H.stateChangeTypes.keyDownEscape})}},this.buttonKeyDownHandlers=S({},this.keyDownHandlers,{" ":function(e){e.preventDefault(),this.toggleMenu({type:H.stateChangeTypes.keyDownSpaceButton})}}),this.getButtonProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onClick,o=t.onKeyDown,i=k(t,["onClick","onKeyDown"]),r=e.getState().isOpen;return S({role:"button","aria-label":r?"close menu":"open menu","aria-expanded":r,"aria-haspopup":!0,onClick:p(n,e.button_handleClick),onKeyDown:p(o,e.button_handleKeyDown)},i)},this.button_handleKeyDown=function(t){e.buttonKeyDownHandlers[t.key]&&e.buttonKeyDownHandlers[t.key].call(e,t)},this.button_handleClick=function(t){t.preventDefault(),e.toggleMenu({type:H.stateChangeTypes.clickButton})},this.getLabelProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(e.getLabelProps.called=!0,e.getInputProps.called&&t.htmlFor&&t.htmlFor!==e.inputId)throw new Error('downshift: You provided the htmlFor of "'+t.htmlFor+'" for your label, but the id of your input is "'+e.inputId+'". You must either remove the id from your input or set the htmlFor of the label equal to the input id.');return e.inputId=h(e.inputId,t.htmlFor,d("downshift-input")),S({},t,{htmlFor:e.inputId})},this.getInputProps=function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=n.onKeyDown,i=n.onBlur,r=n.onChange,u=n.onInput,s=k(n,["onKeyDown","onBlur","onChange","onInput"]);if(e.getInputProps.called=!0,e.getLabelProps.called&&s.id&&s.id!==e.inputId)throw new Error('downshift: You provided the id of "'+s.id+'" for your input, but the htmlFor of your label is "'+e.inputId+'". You must either remove the id from your input or set the htmlFor of the label equal to the input id.');e.inputId=h(e.inputId,s.id,d("downshift-input"));var l=e.getState(),a=l.inputValue,c=l.isOpen,g=l.highlightedIndex;return S((t={role:"combobox","aria-autocomplete":"list","aria-expanded":c,"aria-activedescendant":"number"==typeof g&&g>=0?e.getItemId(g):null,autoComplete:"off",value:a},b(t,"onChange",p(r,u,e.input_handleChange)),b(t,"onKeyDown",p(o,e.input_handleKeyDown)),b(t,"onBlur",p(i,e.input_handleBlur)),t),s,{id:e.inputId})},this.input_handleKeyDown=function(t){t.key&&e.keyDownHandlers[t.key]&&e.keyDownHandlers[t.key].call(e,t)},this.input_handleChange=function(t){e.internalSetState({type:H.stateChangeTypes.changeInput,isOpen:!0,inputValue:t.target.value})},this.input_handleBlur=function(){e.isMouseDown||e.reset({type:H.stateChangeTypes.blurInput})},this.getItemProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onMouseEnter,o=t.index,i=t.item,r=void 0===i?y("getItemProps","item"):i,u=k(t,["onMouseEnter","index","item"]);return void 0===o?(e.items.push(r),o=e.items.indexOf(r)):e.items[o]=r,S({id:e.getItemId(o),onMouseEnter:p(n,function(){e.setHighlightedIndex(o,{type:H.stateChangeTypes.itemMouseEnter})})},u)},this.reset=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];e.internalSetState(function(n){var o=n.selectedItem;return S({isOpen:!1,highlightedIndex:null,inputValue:e.props.itemToString(o)},t)},r(n))},this.toggleMenu=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];e.internalSetState(function(e){var n=e.isOpen;return S({isOpen:!n},t)},function(){e.getState().isOpen&&e.highlightDefaultIndex(),r(n)()})},this.openMenu=function(t){e.internalSetState({isOpen:!0},r(t))},this.closeMenu=function(t){e.internalSetState({isOpen:!1},r(t))},this.updateStatus=a(function(){if(e._isMounted){var t=e.getState(),o=e.items[t.highlightedIndex]||{},i=e.getItemCount(),r=e.props.getA11yStatusMessage(S({itemToString:e.props.itemToString,previousResultCount:e.previousResultCount,resultCount:i,highlightedItem:o},t));e.previousResultCount=i,n(r)}},200)};return H.default=H,H});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],t):e.Downshift=t(e.React,e.PropTypes)}(this,function(e,t){"use strict";function n(e){var t=O[O.length-1]===e;O=t?[].concat(P(O),[e]):[e],i().innerHTML=""+O.filter(Boolean).map(o).join("")}function o(e,t){return'<div style="display:'+(t===O.length-1?"block":"none")+';">'+e+"</div>"}function i(){return D||((D=document.createElement("div")).setAttribute("id","a11y-status-message"),D.setAttribute("role","status"),D.setAttribute("aria-live","assertive"),D.setAttribute("aria-relevant","additions text"),Object.assign(D.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),document.body.appendChild(D),D)}function r(e){return"function"==typeof e?e:u}function u(){}function s(e,t,n){return null!==t&&t!==n.parentNode?e(t)?t:s(e,t.parentNode,n):null}function l(e,t){var n=T(e,t);if(null!==n){var o=getComputedStyle(n),i=n.getBoundingClientRect(),r=parseInt(o.borderTopWidth,10),u=parseInt(o.borderBottomWidth,10),s=i.top+r,l=e.getBoundingClientRect(),a=l.top+n.scrollTop-s;a<n.scrollTop?n.scrollTop=a:a+l.height+r+u>n.scrollTop+i.height&&(n.scrollTop=a+l.height-i.height+r+u)}}function a(e,t){var n=void 0;return function(){for(var o=arguments.length,i=Array(o),r=0;r<o;r++)i[r]=arguments[r];n&&clearTimeout(n),n=setTimeout(function(){n=null,e.apply(void 0,i)},t)}}function p(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=arguments.length,o=Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return t.some(function(t){return t&&t.apply(void 0,[e].concat(o)),e.defaultPrevented})}}function d(e){return e+"-"+A++}function h(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.find(function(e){return void 0!==e})}function c(e){return e===e&&"number"==typeof e}function g(e,t){return!(e=Array.isArray(e)?e[0]:e)&&t?t:e}function f(e){return e.nodeName?"string"==typeof e.nodeName:"string"==typeof e.type}function m(e){return e.props||e.attributes}function y(e,t){throw new Error('The property "'+t+'" is required in "'+e+'"')}function I(e,t){var n=t.refKey,o="ref"!==n,i=!f(e);if(i&&!o)throw new Error("downshift: You returned a non-DOM element. You must specify a refKey in getRootProps");if(!i&&o)throw new Error('downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified "'+n+'"');if(!m(e).hasOwnProperty(n))throw new Error('downshift: You must apply the ref prop "'+n+'" from getRootProps onto your root element.');if(!m(e).hasOwnProperty("onClick"))throw new Error('downshift: You must apply the "onClick" prop from getRootProps onto your root element.')}var v="default"in e?e.default:e;t=t&&t.hasOwnProperty("default")?t.default:t;var _=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},w=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}}(),b=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},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},C=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)},k=function(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},x=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},P=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)},D="undefined"==typeof document?null:document.getElementById("a11y-status-message"),O=[],A=1,T=s.bind(null,function(e){return e.scrollHeight>e.clientHeight}),H=function(e){function t(){var e;_(this,t);for(var n=arguments.length,o=Array(n),i=0;i<n;i++)o[i]=arguments[i];var r=x(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(o)));E.call(r);var u=r.getState({highlightedIndex:r.props.defaultHighlightedIndex,isOpen:r.props.defaultIsOpen,inputValue:r.props.defaultInputValue,selectedItem:r.props.defaultSelectedItem});return u.selectedItem&&(u.inputValue=r.props.itemToString(u.selectedItem)),r.state=u,r}return C(t,e),w(t,[{key:"getState",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state;return Object.keys(t).reduce(function(n,o){return n[o]=e.isControlledProp(o)?e.props[o]:t[o],n},{})}},{key:"isControlledProp",value:function(e){return void 0!==this.props[e]}},{key:"getItemCount",value:function(){return void 0===this.props.itemCount?this.items.length:this.props.itemCount}},{key:"internalSetState",value:function(e,n){var o=this,i=void 0,u={};return this.setState(function(n){n=o.getState(n);var r={},s={};return(e="function"==typeof e?e(n):e).hasOwnProperty("selectedItem")&&e.selectedItem!==n.selectedItem&&(i=e.selectedItem),e.type=e.type||t.stateChangeTypes.unknown,Object.keys(e).forEach(function(t){n[t]!==e[t]&&(u[t]=e[t]),"type"!==t&&(s[t]=e[t],o.isControlledProp(t)||(r[t]=e[t]))}),r},function(){r(n)(),Object.keys(u).length>1&&o.props.onStateChange(u,o.getStateAndHelpers()),void 0!==i&&o.props.onChange(i,o.getStateAndHelpers()),o.props.onUserAction(u,o.getStateAndHelpers())})}},{key:"getStateAndHelpers",value:function(){var e=this.getState(),t=e.highlightedIndex,n=e.inputValue,o=e.selectedItem,i=e.isOpen,r=this.props.itemToString,u=this.getRootProps,s=this.getButtonProps,l=this.getLabelProps,a=this.getInputProps,p=this.getItemProps,d=this.openMenu,h=this.closeMenu,c=this.toggleMenu,g=this.selectItem,f=this.selectItemAtIndex,m=this.selectHighlightedItem,y=this.setHighlightedIndex,I=this.clearSelection;return{getRootProps:u,getButtonProps:s,getLabelProps:l,getInputProps:a,getItemProps:p,reset:this.reset,openMenu:d,closeMenu:h,toggleMenu:c,selectItem:g,selectItemAtIndex:f,selectHighlightedItem:m,setHighlightedIndex:y,clearSelection:I,itemToString:r,highlightedIndex:t,inputValue:n,isOpen:i,selectedItem:o}}},{key:"getItemId",value:function(e){return this.id+"-item-"+e}},{key:"getItemIndexFromId",value:function(e){return e?Number(e.split(this.id+"-item-")[1]):null}},{key:"componentDidMount",value:function(){var e=this;this._isMounted=!0;var n=function(){e.isMouseDown=!0},o=function(n){e.isMouseDown=!1,n.target!==e._rootNode&&e._rootNode.contains(n.target)||!e.getState().isOpen||e.reset({type:t.stateChangeTypes.mouseUp})};window.addEventListener("mousedown",n),window.addEventListener("mouseup",o),this.cleanup=function(){e._isMounted=!1,window.removeEventListener("mousedown",n),window.removeEventListener("mouseup",o)}}},{key:"componentDidUpdate",value:function(e){this.isControlledProp("selectedItem")&&this.props.selectedItem!==e.selectedItem&&this.internalSetState({type:t.stateChangeTypes.controlledPropUpdatedSelectedItem,inputValue:this.props.itemToString(this.props.selectedItem)}),this.updateStatus()}},{key:"componentWillUnmount",value:function(){this.cleanup()}},{key:"render",value:function(){var e=g(this.props.children,u);this.items=[],this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;var t=g(e(this.getStateAndHelpers()));if(!t)return null;if(this.getRootProps.called)return I(t,this.getRootProps),t;if(f(t))return v.cloneElement(t,this.getRootProps(m(t)));throw new Error("downshift: If you return a non-DOM element, you must use apply the getRootProps function")}}]),t}(e.Component);H.propTypes={children:t.func,defaultHighlightedIndex:t.number,defaultSelectedItem:t.any,defaultInputValue:t.string,defaultIsOpen:t.bool,getA11yStatusMessage:t.func,itemToString:t.func,onChange:t.func,onStateChange:t.func,onUserAction:t.func,onClick:t.func,itemCount:t.number,selectedItem:t.any,isOpen:t.bool,inputValue:t.string,highlightedIndex:t.number},H.defaultProps={defaultHighlightedIndex:null,defaultSelectedItem:null,defaultInputValue:"",defaultIsOpen:!1,getA11yStatusMessage:function(e){var t=e.isOpen,n=e.highlightedItem,o=e.selectedItem,i=e.resultCount,r=e.previousResultCount,u=e.itemToString;if(!t)return o?u(o):"";var s=i!==r;return i?!n||s?i+" "+(1===i?"result is":"results are")+" available, use up and down arrow keys to navigate.":u(n):"No results."},itemToString:function(e){return null==e?"":String(e)},onStateChange:function(){},onUserAction:function(){},onChange:function(){}},H.stateChangeTypes={unknown:"__autocomplete_unknown__",mouseUp:"__autocomplete_mouseup__",itemMouseEnter:"__autocomplete_item_mouseenter__",keyDownArrowUp:"__autocomplete_keydown_arrow_up__",keyDownArrowDown:"__autocomplete_keydown_arrow_down__",keyDownEscape:"__autocomplete_keydown_escape__",keyDownEnter:"__autocomplete_keydown_enter__",blurInput:"__autocomplete_blur_input__",changeInput:"__autocomplete_change_input__",keyDownSpaceButton:"__autocomplete_keydown_space_button__",clickButton:"__autocomplete_click_button__",controlledPropUpdatedSelectedItem:"__autocomplete_controlled_prop_updated_selected_item__"};var E=function(){var e=this;this.id=d("downshift"),this.root_handleClick=p(this.props.onClick,this.root_handleClick),this.input=null,this.items=[],this.previousResultCount=0,this.getItemNodeFromIndex=function(t){return document.getElementById(e.getItemId(t))},this.setHighlightedIndex=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.props.defaultHighlightedIndex,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.internalSetState(S({highlightedIndex:t},n),function(){l(e.getItemNodeFromIndex(e.getState().highlightedIndex),e._rootNode)})},this.openAndHighlightDefaultIndex=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.setHighlightedIndex(void 0,S({isOpen:!0},t))},this.highlightDefaultIndex=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.setHighlightedIndex(void 0,t)},this.moveHighlightedIndex=function(t,n){e.getState().isOpen?e.changeHighlightedIndex(t,n):e.openAndHighlightDefaultIndex(n)},this.changeHighlightedIndex=function(t,n){var o=e.getItemCount()-1;if(!(o<0)){var i=e.getState().highlightedIndex;null===i&&(i=t>0?-1:o+1);var r=i+t;r<0?r=o:r>o&&(r=0),e.setHighlightedIndex(r,n)}},this.clearSelection=function(t){e.internalSetState({selectedItem:null,inputValue:"",isOpen:!1},function(){var n=e._rootNode.querySelector("#"+e.inputId);n&&n.focus&&n.focus(),r(t)()})},this.selectItem=function(t,n,o){e.internalSetState(S({isOpen:!1,highlightedIndex:null,selectedItem:t,inputValue:e.props.itemToString(t)},n),r(o))},this.selectItemAtIndex=function(t,n,o){var i=e.items[t];i&&e.selectItem(i,n,o)},this.selectHighlightedItem=function(t,n){return e.selectItemAtIndex(e.getState().highlightedIndex,t,n)},this.rootRef=function(t){return e._rootNode=t},this.getRootProps=function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=n.refKey,i=void 0===o?"ref":o,r=n.onClick,u=k(n,["refKey","onClick"]);return e.getRootProps.called=!0,e.getRootProps.refKey=i,S((t={},b(t,i,e.rootRef),b(t,"onClick",p(r,e.root_handleClick)),t),u)},this.root_handleClick=function(t){t.preventDefault();var n=s(function(t){return c(e.getItemIndexFromId(t.getAttribute("id")))},t.target,e._rootNode);n&&e.selectItemAtIndex(e.getItemIndexFromId(n.getAttribute("id")))},this.keyDownHandlers={ArrowDown:function(e){e.preventDefault();var t=e.shiftKey?5:1;this.moveHighlightedIndex(t,{type:H.stateChangeTypes.keyDownArrowDown})},ArrowUp:function(e){e.preventDefault();var t=e.shiftKey?-5:-1;this.moveHighlightedIndex(t,{type:H.stateChangeTypes.keyDownArrowUp})},Enter:function(e){this.getState().isOpen&&(e.preventDefault(),this.selectHighlightedItem({type:H.stateChangeTypes.keyDownEnter}))},Escape:function(e){e.preventDefault(),this.reset({type:H.stateChangeTypes.keyDownEscape})}},this.buttonKeyDownHandlers=S({},this.keyDownHandlers,{" ":function(e){e.preventDefault(),this.toggleMenu({type:H.stateChangeTypes.keyDownSpaceButton})}}),this.getButtonProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onClick,o=t.onKeyDown,i=k(t,["onClick","onKeyDown"]),r=e.getState().isOpen;return S({role:"button","aria-label":r?"close menu":"open menu","aria-expanded":r,"aria-haspopup":!0,onClick:p(n,e.button_handleClick),onKeyDown:p(o,e.button_handleKeyDown)},i)},this.button_handleKeyDown=function(t){e.buttonKeyDownHandlers[t.key]&&e.buttonKeyDownHandlers[t.key].call(e,t)},this.button_handleClick=function(t){t.preventDefault(),e.toggleMenu({type:H.stateChangeTypes.clickButton})},this.getLabelProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(e.getLabelProps.called=!0,e.getInputProps.called&&t.htmlFor&&t.htmlFor!==e.inputId)throw new Error('downshift: You provided the htmlFor of "'+t.htmlFor+'" for your label, but the id of your input is "'+e.inputId+'". You must either remove the id from your input or set the htmlFor of the label equal to the input id.');return e.inputId=h(e.inputId,t.htmlFor,d("downshift-input")),S({},t,{htmlFor:e.inputId})},this.getInputProps=function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=n.onKeyDown,i=n.onBlur,r=n.onChange,u=n.onInput,s=k(n,["onKeyDown","onBlur","onChange","onInput"]);if(e.getInputProps.called=!0,e.getLabelProps.called&&s.id&&s.id!==e.inputId)throw new Error('downshift: You provided the id of "'+s.id+'" for your input, but the htmlFor of your label is "'+e.inputId+'". You must either remove the id from your input or set the htmlFor of the label equal to the input id.');e.inputId=h(e.inputId,s.id,d("downshift-input"));var l=e.getState(),a=l.inputValue,c=l.isOpen,g=l.highlightedIndex;return S((t={role:"combobox","aria-autocomplete":"list","aria-expanded":c,"aria-activedescendant":"number"==typeof g&&g>=0?e.getItemId(g):null,autoComplete:"off",value:a},b(t,"onChange",p(r,u,e.input_handleChange)),b(t,"onKeyDown",p(o,e.input_handleKeyDown)),b(t,"onBlur",p(i,e.input_handleBlur)),t),s,{id:e.inputId})},this.input_handleKeyDown=function(t){t.key&&e.keyDownHandlers[t.key]&&e.keyDownHandlers[t.key].call(e,t)},this.input_handleChange=function(t){e.internalSetState({type:H.stateChangeTypes.changeInput,isOpen:!0,inputValue:t.target.value})},this.input_handleBlur=function(){e.isMouseDown||e.reset({type:H.stateChangeTypes.blurInput})},this.getItemProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onMouseEnter,o=t.index,i=t.item,r=void 0===i?y("getItemProps","item"):i,u=k(t,["onMouseEnter","index","item"]);return void 0===o?(e.items.push(r),o=e.items.indexOf(r)):e.items[o]=r,S({id:e.getItemId(o),onMouseEnter:p(n,function(){e.setHighlightedIndex(o,{type:H.stateChangeTypes.itemMouseEnter})})},u)},this.reset=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];e.internalSetState(function(n){var o=n.selectedItem;return S({isOpen:!1,highlightedIndex:null,inputValue:e.props.itemToString(o)},t)},r(n))},this.toggleMenu=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];e.internalSetState(function(e){var n=e.isOpen;return S({isOpen:!n},t)},function(){e.getState().isOpen&&e.highlightDefaultIndex(),r(n)()})},this.openMenu=function(t){e.internalSetState({isOpen:!0},r(t))},this.closeMenu=function(t){e.internalSetState({isOpen:!1},r(t))},this.updateStatus=a(function(){if(e._isMounted){var t=e.getState(),o=e.items[t.highlightedIndex]||{},i=e.getItemCount(),r=e.props.getA11yStatusMessage(S({itemToString:e.props.itemToString,previousResultCount:e.previousResultCount,resultCount:i,highlightedItem:o},t));e.previousResultCount=i,n(r)}},200)};return H.default=H,H});
//# sourceMappingURL=downshift.umd.min.js.map
{
"name": "downshift",
"version": "1.2.0",
"version": "1.3.0",
"description": "A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete components",

@@ -5,0 +5,0 @@ "main": "dist/downshift.cjs.js",

@@ -18,3 +18,3 @@ <h1 align="center">

[![All Contributors](https://img.shields.io/badge/all_contributors-23-orange.svg?style=flat-square)](#contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-24-orange.svg?style=flat-square)](#contributors)
[![PRs Welcome][prs-badge]][prs]

@@ -369,5 +369,33 @@ [![Chat][chat-badge]][chat]

The props returned from calling this function should be applied to any menu
items you render. **This is an impure function**, so it should only be called
when you will actually be applying the props to an item.
items you render.
**This is an impure function**, so it should only be called when you will
actually be applying the props to an item.
<details>
<summary>What do you mean by impure function?</summary>
Basically just don't do this:
```jsx
items.map(item => {
const props = getItemProps({item}) // we're calling it here
if (!shouldRenderItem(item)) {
return null // but we're not using props, and downshift things we are...
}
return <div {...props} />
})
```
Instead, you could do this:
```jsx
items
.filter(shouldRenderItem)
.map(item => <div {...getItemProps({item})} />)
```
</details>
Required properties:

@@ -510,3 +538,3 @@

| [<img src="https://avatars0.githubusercontent.com/u/3415488?v=4" width="100px;"/><br /><sub>Anup</sub>](https://github.com/reznord)<br />[📖](https://github.com/paypal/downshift/commits?author=reznord "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/340520?v=4" width="100px;"/><br /><sub>Ferdinand Salis</sub>](http://ferdinandsalis.com)<br />[🐛](https://github.com/paypal/downshift/issues?q=author%3Aferdinandsalis "Bug reports") [💻](https://github.com/paypal/downshift/commits?author=ferdinandsalis "Code") | [<img src="https://avatars2.githubusercontent.com/u/662750?v=4" width="100px;"/><br /><sub>Kye Hohenberger</sub>](https://github.com/tkh44)<br />[🐛](https://github.com/paypal/downshift/issues?q=author%3Atkh44 "Bug reports") | [<img src="https://avatars0.githubusercontent.com/u/1443499?v=4" width="100px;"/><br /><sub>Julien Goux</sub>](https://github.com/jgoux)<br />[🐛](https://github.com/paypal/downshift/issues?q=author%3Ajgoux "Bug reports") [💻](https://github.com/paypal/downshift/commits?author=jgoux "Code") [⚠️](https://github.com/paypal/downshift/commits?author=jgoux "Tests") | [<img src="https://avatars2.githubusercontent.com/u/9586897?v=4" width="100px;"/><br /><sub>Joachim Seminck</sub>](https://github.com/jseminck)<br />[💻](https://github.com/paypal/downshift/commits?author=jseminck "Code") | [<img src="https://avatars3.githubusercontent.com/u/954596?v=4" width="100px;"/><br /><sub>Jesse Harlin</sub>](http://jesseharlin.net/)<br />[🐛](https://github.com/paypal/downshift/issues?q=author%3Athe-simian "Bug reports") [💡](#example-the-simian "Examples") | [<img src="https://avatars0.githubusercontent.com/u/1402095?v=4" width="100px;"/><br /><sub>Matt Parrish</sub>](https://github.com/pbomb)<br />[🔧](#tool-pbomb "Tools") |
| [<img src="https://avatars1.githubusercontent.com/u/11661846?v=4" width="100px;"/><br /><sub>thom</sub>](http://thom.kr)<br /> | [<img src="https://avatars2.githubusercontent.com/u/1088312?v=4" width="100px;"/><br /><sub>Vu Tran</sub>](http://twitter.com/tranvu)<br /> |
| [<img src="https://avatars1.githubusercontent.com/u/11661846?v=4" width="100px;"/><br /><sub>thom</sub>](http://thom.kr)<br />[💻](https://github.com/paypal/downshift/commits?author=thomhos "Code") | [<img src="https://avatars2.githubusercontent.com/u/1088312?v=4" width="100px;"/><br /><sub>Vu Tran</sub>](http://twitter.com/tranvu)<br />[💻](https://github.com/paypal/downshift/commits?author=vutran "Code") | [<img src="https://avatars1.githubusercontent.com/u/74193?v=4" width="100px;"/><br /><sub>Codie Mullins</sub>](https://github.com/codiemullins)<br />[💻](https://github.com/paypal/downshift/commits?author=codiemullins "Code") |
<!-- ALL-CONTRIBUTORS-LIST:END -->

@@ -513,0 +541,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc