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.0.2 to 1.1.0

12

dist/downshift.cjs.js

@@ -563,15 +563,15 @@ 'use strict';

if (hasMoreStateThanType) {
_this3.props.onStateChange(onStateChangeArg, _this3.getState());
_this3.props.onStateChange(onStateChangeArg, _this3.getStateAndHelpers());
}
if (onChangeArg !== undefined) {
_this3.props.onChange(onChangeArg, _this3.getState());
_this3.props.onChange(onChangeArg, _this3.getStateAndHelpers());
}
// this is currently undocumented and therefore subject to change
// We'll try to not break it, but just be warned.
_this3.props.onUserAction(onStateChangeArg, _this3.getState());
_this3.props.onUserAction(onStateChangeArg, _this3.getStateAndHelpers());
});
}
}, {
key: 'getControllerStateAndHelpers',
value: function getControllerStateAndHelpers() {
key: 'getStateAndHelpers',
value: function getStateAndHelpers() {
var _getState = this.getState(),

@@ -725,3 +725,3 @@ highlightedIndex = _getState.highlightedIndex,

this.getInputProps.called = false;
var element = unwrapArray(children(this.getControllerStateAndHelpers()));
var element = unwrapArray(children(this.getStateAndHelpers()));
if (!element) {

@@ -728,0 +728,0 @@ return null;

@@ -558,15 +558,15 @@ import React, { Component } from 'react';

if (hasMoreStateThanType) {
_this3.props.onStateChange(onStateChangeArg, _this3.getState());
_this3.props.onStateChange(onStateChangeArg, _this3.getStateAndHelpers());
}
if (onChangeArg !== undefined) {
_this3.props.onChange(onChangeArg, _this3.getState());
_this3.props.onChange(onChangeArg, _this3.getStateAndHelpers());
}
// this is currently undocumented and therefore subject to change
// We'll try to not break it, but just be warned.
_this3.props.onUserAction(onStateChangeArg, _this3.getState());
_this3.props.onUserAction(onStateChangeArg, _this3.getStateAndHelpers());
});
}
}, {
key: 'getControllerStateAndHelpers',
value: function getControllerStateAndHelpers() {
key: 'getStateAndHelpers',
value: function getStateAndHelpers() {
var _getState = this.getState(),

@@ -720,3 +720,3 @@ highlightedIndex = _getState.highlightedIndex,

this.getInputProps.called = false;
var element = unwrapArray(children(this.getControllerStateAndHelpers()));
var element = unwrapArray(children(this.getStateAndHelpers()));
if (!element) {

@@ -723,0 +723,0 @@ return null;

@@ -562,15 +562,15 @@ 'use strict';

if (hasMoreStateThanType) {
_this3.props.onStateChange(onStateChangeArg, _this3.getState());
_this3.props.onStateChange(onStateChangeArg, _this3.getStateAndHelpers());
}
if (onChangeArg !== undefined) {
_this3.props.onChange(onChangeArg, _this3.getState());
_this3.props.onChange(onChangeArg, _this3.getStateAndHelpers());
}
// this is currently undocumented and therefore subject to change
// We'll try to not break it, but just be warned.
_this3.props.onUserAction(onStateChangeArg, _this3.getState());
_this3.props.onUserAction(onStateChangeArg, _this3.getStateAndHelpers());
});
}
}, {
key: 'getControllerStateAndHelpers',
value: function getControllerStateAndHelpers() {
key: 'getStateAndHelpers',
value: function getStateAndHelpers() {
var _getState = this.getState(),

@@ -724,3 +724,3 @@ highlightedIndex = _getState.highlightedIndex,

this.getInputProps.called = false;
var element = unwrapArray(children(this.getControllerStateAndHelpers()));
var element = unwrapArray(children(this.getStateAndHelpers()));
if (!element) {

@@ -727,0 +727,0 @@ return null;

@@ -557,15 +557,15 @@ import React, { Component } from 'preact';

if (hasMoreStateThanType) {
_this3.props.onStateChange(onStateChangeArg, _this3.getState());
_this3.props.onStateChange(onStateChangeArg, _this3.getStateAndHelpers());
}
if (onChangeArg !== undefined) {
_this3.props.onChange(onChangeArg, _this3.getState());
_this3.props.onChange(onChangeArg, _this3.getStateAndHelpers());
}
// this is currently undocumented and therefore subject to change
// We'll try to not break it, but just be warned.
_this3.props.onUserAction(onStateChangeArg, _this3.getState());
_this3.props.onUserAction(onStateChangeArg, _this3.getStateAndHelpers());
});
}
}, {
key: 'getControllerStateAndHelpers',
value: function getControllerStateAndHelpers() {
key: 'getStateAndHelpers',
value: function getStateAndHelpers() {
var _getState = this.getState(),

@@ -719,3 +719,3 @@ highlightedIndex = _getState.highlightedIndex,

this.getInputProps.called = false;
var element = unwrapArray(children(this.getControllerStateAndHelpers()));
var element = unwrapArray(children(this.getStateAndHelpers()));
if (!element) {

@@ -722,0 +722,0 @@ return null;

@@ -563,15 +563,15 @@ (function (global, factory) {

if (hasMoreStateThanType) {
_this3.props.onStateChange(onStateChangeArg, _this3.getState());
_this3.props.onStateChange(onStateChangeArg, _this3.getStateAndHelpers());
}
if (onChangeArg !== undefined) {
_this3.props.onChange(onChangeArg, _this3.getState());
_this3.props.onChange(onChangeArg, _this3.getStateAndHelpers());
}
// this is currently undocumented and therefore subject to change
// We'll try to not break it, but just be warned.
_this3.props.onUserAction(onStateChangeArg, _this3.getState());
_this3.props.onUserAction(onStateChangeArg, _this3.getStateAndHelpers());
});
}
}, {
key: 'getControllerStateAndHelpers',
value: function getControllerStateAndHelpers() {
key: 'getStateAndHelpers',
value: function getStateAndHelpers() {
var _getState = this.getState(),

@@ -725,3 +725,3 @@ highlightedIndex = _getState.highlightedIndex,

this.getInputProps.called = false;
var element = unwrapArray(children(this.getControllerStateAndHelpers()));
var element = unwrapArray(children(this.getStateAndHelpers()));
if (!element) {

@@ -728,0 +728,0 @@ return null;

@@ -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 l(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),l=i.top+r,s=e.getBoundingClientRect(),a=s.top+n.scrollTop-l;a<n.scrollTop?n.scrollTop=a:a+s.height+r+u>n.scrollTop+i.height&&(n.scrollTop=a+s.height-i.height+r+u)}}function s(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}),T=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)));H.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={},l={};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&&(l[t]=e[t],o.isControlledProp(t)||(i[t]=e[t]))}),i},function(){i(n)(),Object.keys(u).length>1&&o.props.onStateChange(u,o.getState()),void 0!==r&&o.props.onChange(r,o.getState()),o.props.onUserAction(u,o.getState())})}},{key:"getControllerStateAndHelpers",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,l=this.getButtonProps,s=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:l,getLabelProps:s,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.getControllerStateAndHelpers()));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);T.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 l=i!==r;return i?!n||l?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(){}},T.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 H=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(){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,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:T.stateChangeTypes.keyDownArrowDown})},ArrowUp:function(e){e.preventDefault();var t=e.shiftKey?-5:-1;this.moveHighlightedIndex(t,{type:T.stateChangeTypes.keyDownArrowUp})},Enter:function(e){e.preventDefault(),this.getState().isOpen&&this.selectHighlightedItem({type:T.stateChangeTypes.keyDownEnter})},Escape:function(e){e.preventDefault(),this.reset({type:T.stateChangeTypes.keyDownEscape})}},this.buttonKeyDownHandlers=b({},this.keyDownHandlers,{" ":function(e){e.preventDefault(),this.toggleMenu({type:T.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:T.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,l=k(n,["onKeyDown","onBlur","onChange","onInput"]);if(e.getInputProps.called=!0,e.getLabelProps.called&&l.id&&l.id!==e.inputId)throw new Error('downshift: You provided the id of "'+l.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,l.id,p("downshift-input"));var s=e.getState(),h=s.inputValue,c=s.isOpen,g=s.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),l,{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:T.stateChangeTypes.changeInput,isOpen:!0,inputValue:t.target.value})},this.input_handleBlur=function(){e.isMouseDown||e.reset({type:T.stateChangeTypes.blurInput})},this.getItemProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onMouseEnter,o=t.item,i=void 0===o?m("getItemProps","item"):o,r=t.index,u=void 0===r?m("getItemProps","index"):r,l=k(t,["onMouseEnter","item","index"]);return e.items[u]=i,b({id:e.getItemId(u),onMouseEnter:a(n,function(){e.setHighlightedIndex(u,{type:T.stateChangeTypes.itemMouseEnter})})},l)},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=s(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 T.default=T,T});
!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.item,i=void 0===o?m("getItemProps","item"):o,r=t.index,u=void 0===r?m("getItemProps","index"):r,s=k(t,["onMouseEnter","item","index"]);return e.items[u]=i,b({id:e.getItemId(u),onMouseEnter:a(n,function(){e.setHighlightedIndex(u,{type:H.stateChangeTypes.itemMouseEnter})})},s)},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

@@ -564,15 +564,15 @@ (function (global, factory) {

if (hasMoreStateThanType) {
_this3.props.onStateChange(onStateChangeArg, _this3.getState());
_this3.props.onStateChange(onStateChangeArg, _this3.getStateAndHelpers());
}
if (onChangeArg !== undefined) {
_this3.props.onChange(onChangeArg, _this3.getState());
_this3.props.onChange(onChangeArg, _this3.getStateAndHelpers());
}
// this is currently undocumented and therefore subject to change
// We'll try to not break it, but just be warned.
_this3.props.onUserAction(onStateChangeArg, _this3.getState());
_this3.props.onUserAction(onStateChangeArg, _this3.getStateAndHelpers());
});
}
}, {
key: 'getControllerStateAndHelpers',
value: function getControllerStateAndHelpers() {
key: 'getStateAndHelpers',
value: function getStateAndHelpers() {
var _getState = this.getState(),

@@ -726,3 +726,3 @@ highlightedIndex = _getState.highlightedIndex,

this.getInputProps.called = false;
var element = unwrapArray(children(this.getControllerStateAndHelpers()));
var element = unwrapArray(children(this.getStateAndHelpers()));
if (!element) {

@@ -729,0 +729,0 @@ return null;

@@ -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 l(e,t,n){return null!==t&&t!==n.parentNode?e(t)?t:l(e,t.parentNode,n):null}function s(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),l=i.top+r,s=e.getBoundingClientRect(),a=s.top+n.scrollTop-l;a<n.scrollTop?n.scrollTop=a:a+s.height+r+u>n.scrollTop+i.height&&(n.scrollTop=a+s.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=l.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={},l={};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&&(l[t]=e[t],o.isControlledProp(t)||(r[t]=e[t]))}),r},function(){r(n)(),Object.keys(u).length>1&&o.props.onStateChange(u,o.getState()),void 0!==i&&o.props.onChange(i,o.getState()),o.props.onUserAction(u,o.getState())})}},{key:"getControllerStateAndHelpers",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,l=this.getButtonProps,s=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:l,getLabelProps:s,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.getControllerStateAndHelpers()));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 l=i!==r;return i?!n||l?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(){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,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=l(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,l=k(n,["onKeyDown","onBlur","onChange","onInput"]);if(e.getInputProps.called=!0,e.getLabelProps.called&&l.id&&l.id!==e.inputId)throw new Error('downshift: You provided the id of "'+l.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,l.id,d("downshift-input"));var s=e.getState(),a=s.inputValue,c=s.isOpen,g=s.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),l,{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.item,i=void 0===o?y("getItemProps","item"):o,r=t.index,u=void 0===r?y("getItemProps","index"):r,l=k(t,["onMouseEnter","item","index"]);return e.items[u]=i,S({id:e.getItemId(u),onMouseEnter:p(n,function(){e.setHighlightedIndex(u,{type:H.stateChangeTypes.itemMouseEnter})})},l)},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){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.item,i=void 0===o?y("getItemProps","item"):o,r=t.index,u=void 0===r?y("getItemProps","index"):r,s=k(t,["onMouseEnter","item","index"]);return e.items[u]=i,S({id:e.getItemId(u),onMouseEnter:p(n,function(){e.setHighlightedIndex(u,{type:H.stateChangeTypes.itemMouseEnter})})},s)},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.0.2",
"version": "1.1.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",

@@ -195,11 +195,15 @@ <h1 align="center">

> `function(selectedItem: any, allState: object)` | optional, no useful default
> `function(selectedItem: any, stateAndHelpers: object)` | optional, no useful default
Called when the user selects an item. Called with the item that was selected
and the new state of `downshift`. (see `onStateChange` for more info on
`allState`).
`stateAndHelpers`).
- `selectedItem`: The item that was just selected
- `stateAndHelpers`: This is the exact same thing you're `children` prop
function is called with (see [Child Callback Function](#child-callback-function))
### onStateChange
> `function(changes: object, allState: object)` | optional, no useful default
> `function(changes: object, stateAndHelpers: object)` | optional, no useful default

@@ -215,5 +219,5 @@ This function is called anytime the internal state changes. This can be useful

- `changes`: These are the properties that actually have changed since the last
state change
- `allState`: This is the full state object of all the state in your `downshift`
component.
state change.
- `stateAndHelpers`: This is the exact same thing you're `children` prop
function is called with (see [Child Callback Function](#child-callback-function))

@@ -285,4 +289,3 @@ > Tip: This function will be called any time _any_ state is changed. The best

comes in really handy), but you can also control the state from anywhere, be
that state from other components, `redux` (example wanted!), `react-router`
(example wanted!), or anywhere else.
that state from other components, `redux`, `react-router`, or anywhere else.

@@ -432,5 +435,6 @@ > Note: This is very similar to how normal controlled components work elsewhere

- [bare bones autocomplete](https://codesandbox.io/s/6z67jvklw3)
- [multiple selection example](https://codesandbox.io/s/W6gyJ30kn) (uses controlled `selectedItem` API).
- [downshift Apollo example](https://codesandbox.io/s/m5zrvqj85p)
- [Bare bones autocomplete](https://codesandbox.io/s/6z67jvklw3)
- [Multiple selection](https://codesandbox.io/s/W6gyJ30kn) (uses controlled `selectedItem` API).
- [Integration with Apollo](https://codesandbox.io/s/m5zrvqj85p)
- [Integration with Redux](https://codesandbox.io/s/0o0w70lp8p)
- [Integration with `react-instantsearch`](https://codesandbox.io/s/kvn0lpp83) from Algolia

@@ -440,2 +444,3 @@ - [Material UI (1.0.0-beta.4) Combobox Using Downshift](https://codesandbox.io/s/QMGq4kAY)

- [Handling and displaying errors](https://codesandbox.io/s/zKE37vorr)
- [Integration with React Router](https://codesandbox.io/s/ww9lwloy8w)

@@ -442,0 +447,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