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.0-rc.1 to 1.0.0-rc.2

31

dist/downshift.cjs.js

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

var Downshift$1 = function (_Component) {
inherits(Downshift, _Component);
var Downshift$1 = function (_PureComponent) {
inherits(Downshift, _PureComponent);

@@ -750,7 +750,21 @@ function Downshift() {

return Object.keys(stateToMerge).reduce(function (state, key) {
state[key] = _this2.props[key] === undefined ? _this2.state[key] : _this2.props[key];
state[key] = _this2.isStateProp(key) ? _this2.props[key] : _this2.state[key];
return state;
}, {});
}
/**
* This determines whether a prop is a "state prop" meaning it is
* state which is controlled by the outside of this component rather
* than within this component.
* @param {String} key the key to check
* @return {Boolean} whether it is a controlled state prop
*/
}, {
key: 'isStateProp',
value: function isStateProp(key) {
return this.props[key] !== undefined;
}
}, {
key: 'maybeScrollToHighlightedElement',

@@ -810,3 +824,3 @@ value: function maybeScrollToHighlightedElement(highlightedIndex) {

// if it's coming from props, then we don't want to set it internally
if (!_this3.props.hasOwnProperty(key)) {
if (!_this3.isStateProp(key)) {
nextState[key] = onStateChangeArg[key];

@@ -950,3 +964,8 @@ }

key: 'componentDidUpdate',
value: function componentDidUpdate() {
value: function componentDidUpdate(prevProps) {
if (this.isStateProp('selectedItem') && this.props.selectedItem !== prevProps.selectedItem) {
this.internalSetState({
inputValue: this.props.itemToString(this.props.selectedItem)
});
}
this.updateStatus();

@@ -998,3 +1017,3 @@ }

return Downshift;
}(React.Component);
}(React.PureComponent);

@@ -1001,0 +1020,0 @@ Downshift$1.propTypes = {

33

dist/downshift.es.js

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

import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';

@@ -367,4 +367,4 @@

var Downshift$1 = function (_Component) {
inherits(Downshift, _Component);
var Downshift$1 = function (_PureComponent) {
inherits(Downshift, _PureComponent);

@@ -745,7 +745,21 @@ function Downshift() {

return Object.keys(stateToMerge).reduce(function (state, key) {
state[key] = _this2.props[key] === undefined ? _this2.state[key] : _this2.props[key];
state[key] = _this2.isStateProp(key) ? _this2.props[key] : _this2.state[key];
return state;
}, {});
}
/**
* This determines whether a prop is a "state prop" meaning it is
* state which is controlled by the outside of this component rather
* than within this component.
* @param {String} key the key to check
* @return {Boolean} whether it is a controlled state prop
*/
}, {
key: 'isStateProp',
value: function isStateProp(key) {
return this.props[key] !== undefined;
}
}, {
key: 'maybeScrollToHighlightedElement',

@@ -805,3 +819,3 @@ value: function maybeScrollToHighlightedElement(highlightedIndex) {

// if it's coming from props, then we don't want to set it internally
if (!_this3.props.hasOwnProperty(key)) {
if (!_this3.isStateProp(key)) {
nextState[key] = onStateChangeArg[key];

@@ -945,3 +959,8 @@ }

key: 'componentDidUpdate',
value: function componentDidUpdate() {
value: function componentDidUpdate(prevProps) {
if (this.isStateProp('selectedItem') && this.props.selectedItem !== prevProps.selectedItem) {
this.internalSetState({
inputValue: this.props.itemToString(this.props.selectedItem)
});
}
this.updateStatus();

@@ -993,3 +1012,3 @@ }

return Downshift;
}(Component);
}(PureComponent);

@@ -996,0 +1015,0 @@ Downshift$1.propTypes = {

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

var Downshift$1 = function (_Component) {
inherits(Downshift, _Component);
var Downshift$1 = function (_PureComponent) {
inherits(Downshift, _PureComponent);

@@ -776,7 +776,21 @@ function Downshift() {

return Object.keys(stateToMerge).reduce(function (state, key) {
state[key] = _this2.props[key] === undefined ? _this2.state[key] : _this2.props[key];
state[key] = _this2.isStateProp(key) ? _this2.props[key] : _this2.state[key];
return state;
}, {});
}
/**
* This determines whether a prop is a "state prop" meaning it is
* state which is controlled by the outside of this component rather
* than within this component.
* @param {String} key the key to check
* @return {Boolean} whether it is a controlled state prop
*/
}, {
key: 'isStateProp',
value: function isStateProp(key) {
return this.props[key] !== undefined;
}
}, {
key: 'maybeScrollToHighlightedElement',

@@ -836,3 +850,3 @@ value: function maybeScrollToHighlightedElement(highlightedIndex) {

// if it's coming from props, then we don't want to set it internally
if (!_this3.props.hasOwnProperty(key)) {
if (!_this3.isStateProp(key)) {
nextState[key] = onStateChangeArg[key];

@@ -976,3 +990,8 @@ }

key: 'componentDidUpdate',
value: function componentDidUpdate() {
value: function componentDidUpdate(prevProps) {
if (this.isStateProp('selectedItem') && this.props.selectedItem !== prevProps.selectedItem) {
this.internalSetState({
inputValue: this.props.itemToString(this.props.selectedItem)
});
}
this.updateStatus();

@@ -1024,3 +1043,3 @@ }

return Downshift;
}(preact.Component);
}(preact.PureComponent);

@@ -1027,0 +1046,0 @@ Downshift$1.propTypes = {

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

import { Component } from 'preact';
import { PureComponent } from 'preact';
import preact__default from 'preact';

@@ -397,4 +397,4 @@ import * as preact from 'preact';

var Downshift$1 = function (_Component) {
inherits(Downshift, _Component);
var Downshift$1 = function (_PureComponent) {
inherits(Downshift, _PureComponent);

@@ -775,7 +775,21 @@ function Downshift() {

return Object.keys(stateToMerge).reduce(function (state, key) {
state[key] = _this2.props[key] === undefined ? _this2.state[key] : _this2.props[key];
state[key] = _this2.isStateProp(key) ? _this2.props[key] : _this2.state[key];
return state;
}, {});
}
/**
* This determines whether a prop is a "state prop" meaning it is
* state which is controlled by the outside of this component rather
* than within this component.
* @param {String} key the key to check
* @return {Boolean} whether it is a controlled state prop
*/
}, {
key: 'isStateProp',
value: function isStateProp(key) {
return this.props[key] !== undefined;
}
}, {
key: 'maybeScrollToHighlightedElement',

@@ -835,3 +849,3 @@ value: function maybeScrollToHighlightedElement(highlightedIndex) {

// if it's coming from props, then we don't want to set it internally
if (!_this3.props.hasOwnProperty(key)) {
if (!_this3.isStateProp(key)) {
nextState[key] = onStateChangeArg[key];

@@ -975,3 +989,8 @@ }

key: 'componentDidUpdate',
value: function componentDidUpdate() {
value: function componentDidUpdate(prevProps) {
if (this.isStateProp('selectedItem') && this.props.selectedItem !== prevProps.selectedItem) {
this.internalSetState({
inputValue: this.props.itemToString(this.props.selectedItem)
});
}
this.updateStatus();

@@ -1023,3 +1042,3 @@ }

return Downshift;
}(Component);
}(PureComponent);

@@ -1026,0 +1045,0 @@ Downshift$1.propTypes = {

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

var Downshift$1 = function (_Component) {
inherits(Downshift, _Component);
var Downshift$1 = function (_PureComponent) {
inherits(Downshift, _PureComponent);

@@ -779,7 +779,21 @@ function Downshift() {

return Object.keys(stateToMerge).reduce(function (state, key) {
state[key] = _this2.props[key] === undefined ? _this2.state[key] : _this2.props[key];
state[key] = _this2.isStateProp(key) ? _this2.props[key] : _this2.state[key];
return state;
}, {});
}
/**
* This determines whether a prop is a "state prop" meaning it is
* state which is controlled by the outside of this component rather
* than within this component.
* @param {String} key the key to check
* @return {Boolean} whether it is a controlled state prop
*/
}, {
key: 'isStateProp',
value: function isStateProp(key) {
return this.props[key] !== undefined;
}
}, {
key: 'maybeScrollToHighlightedElement',

@@ -839,3 +853,3 @@ value: function maybeScrollToHighlightedElement(highlightedIndex) {

// if it's coming from props, then we don't want to set it internally
if (!_this3.props.hasOwnProperty(key)) {
if (!_this3.isStateProp(key)) {
nextState[key] = onStateChangeArg[key];

@@ -979,3 +993,8 @@ }

key: 'componentDidUpdate',
value: function componentDidUpdate() {
value: function componentDidUpdate(prevProps) {
if (this.isStateProp('selectedItem') && this.props.selectedItem !== prevProps.selectedItem) {
this.internalSetState({
inputValue: this.props.itemToString(this.props.selectedItem)
});
}
this.updateStatus();

@@ -1027,3 +1046,3 @@ }

return Downshift;
}(preact.Component);
}(preact.PureComponent);

@@ -1030,0 +1049,0 @@ Downshift$1.propTypes = {

@@ -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.preact)}(this,function(e){"use strict";function t(){}function n(e){var t=k[k.length-1]===e;k=t?[].concat(P(k),[e]):[e],r().innerHTML=""+k.filter(Boolean).map(o).join("")}function o(e,t){return'<div style="display:'+(t===k.length-1?"block":"none")+';">'+e+"</div>"}function r(){return O||((O=document.createElement("div")).setAttribute("id","a11y-status-message"),O.setAttribute("role","status"),O.setAttribute("aria-live","assertive"),O.setAttribute("aria-relevant","additions text"),Object.assign(O.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),document.body.appendChild(O),O)}function i(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=H(e,t);if(null!==n){var o=getComputedStyle(n),r=n.getBoundingClientRect(),i=parseInt(o.borderTopWidth,10),u=r.top+i,l=e.getBoundingClientRect(),s=l.top+n.scrollTop-u;s<n.scrollTop?n.scrollTop=s:s+l.height>n.scrollTop+r.height&&(n.scrollTop=s+l.height-r.height)}}function a(e,t){var n=void 0;return function(){for(var o=arguments.length,r=Array(o),i=0;i<o;i++)r[i]=arguments[i];n&&clearTimeout(n),n=setTimeout(function(){n=null,e.apply(void 0,r)},t)}}function d(){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),r=1;r<n;r++)o[r-1]=arguments[r];return t.some(function(t){return t&&t.apply(void 0,[e].concat(o)),e.defaultPrevented})}}function p(e){return e+"-"+_++}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 f(e,t){return Object.keys(t).every(function(n){return e[n]===t[n]})}function g(e,t){var n=t.refKey,o="ref"!==n,r="string"!=typeof e.type;if(r&&!o)throw new Error("downshift: You returned a non-DOM element. You must specify a refKey in getRootProps");if(!r&&o)throw new Error('downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified "'+n+'"');if(!e.props.hasOwnProperty(n))throw new Error('downshift: You must apply the ref prop "'+n+'" from getRootProps onto your root element.');if(!e.props.hasOwnProperty("onClick"))throw new Error('downshift: You must apply the "onClick" prop from getRootProps onto your root element.')}var m=e.default;m.Children={only:function(e){return e&&e[0]}},t.isRequired=t;var y={element:t,func:t,number:t,any:t,bool:t,string:t},I=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},v=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},w=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)},x=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},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)},O="undefined"==typeof document?null:document.getElementById("a11y-status-message"),k=[],_=1,H=l.bind(null,function(e){return e.scrollHeight>e.clientHeight}),D=function(e){function t(){var e;I(this,t);for(var o=arguments.length,r=Array(o),u=0;u<o;u++)r[u]=arguments[u];var s=C(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(r)));return s.input=null,s.items=[],s.previousResultCount=0,s.getItemFromIndex=function(e){return s.items&&s.items[0]?s.items[e]:null},s.getItemNodeFromIndex=function(e){return document.getElementById(s.getItemId(e))},s.setHighlightedIndex=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:s.props.defaultHighlightedIndex;s.internalSetState({highlightedIndex:e},function(){s.maybeScrollToHighlightedElement(e)})},s.highlightIndex=function(e){s.openMenu(function(){s.setHighlightedIndex(e)})},s.moveHighlightedIndex=function(e){s.getState().isOpen?s.changeHighlighedIndex(e):s.highlightIndex()},s.changeHighlighedIndex=function(e){var t=s.items.length-1;if(!(t<0)){var n=s.getState().highlightedIndex;null===n&&(n=e>0?-1:t+1);var o=n+e;o<0?o=t:o>t&&(o=0),s.setHighlightedIndex(o)}},s.clearSelection=function(){s.internalSetState({selectedItem:null,inputValue:"",isOpen:!1},function(){var e=s._rootNode.querySelector("#"+s.inputId);e&&e.focus&&e.focus()})},s.selectItem=function(e){s.reset(),s.internalSetState({selectedItem:e,inputValue:s.props.itemToString(e)})},s.selectItemAtIndex=function(e){if(null!==e){var t=s.getItemFromIndex(e);t&&s.selectItem(t)}},s.selectHighlightedItem=function(){return s.selectItemAtIndex(s.getState().highlightedIndex)},s.rootRef=function(e){return s._rootNode=e},s.getRootProps=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.refKey,o=void 0===n?"ref":n,r=t.onClick,i=x(t,["refKey","onClick"]);return s.getRootProps.called=!0,s.getRootProps.refKey=o,w((e={},b(e,o,s.rootRef),b(e,"onClick",d(r,s.root_handleClick)),e),i)},s.root_handleClick=function(e){e.preventDefault();var t=l(function(e){return c(s.getItemIndexFromId(e.getAttribute("id")))},e.target,s._rootNode);t&&s.selectItemAtIndex(s.getItemIndexFromId(t.getAttribute("id")))},s.keyDownHandlers={ArrowDown:function(e){e.preventDefault();var t=e.shiftKey?5:1;this.moveHighlightedIndex(t)},ArrowUp:function(e){e.preventDefault();var t=e.shiftKey?-5:-1;this.moveHighlightedIndex(t)},Enter:function(e){e.preventDefault(),this.getState().isOpen&&this.selectHighlightedItem()},Escape:function(e){e.preventDefault(),this.reset()}},s.buttonKeyDownHandlers=w({},s.keyDownHandlers,{" ":function(e){e.preventDefault(),this.toggleMenu()}}),s.getButtonProps=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.onClick,n=e.onKeyDown,o=x(e,["onClick","onKeyDown"]),r=s.getState().isOpen;return w({role:"button","aria-label":r?"close menu":"open menu","aria-expanded":r,"aria-haspopup":!0,onClick:d(t,s.button_handleClick),onKeyDown:d(n,s.button_handleKeyDown)},o)},s.button_handleKeyDown=function(e){s.buttonKeyDownHandlers[e.key]&&s.buttonKeyDownHandlers[e.key].call(s,e)},s.button_handleClick=function(e){e.preventDefault(),s.toggleMenu()},s.getLabelProps=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(s.getLabelProps.called=!0,s.getInputProps.called&&e.htmlFor&&e.htmlFor!==s.inputId)throw new Error('downshift: You provided the htmlFor of "'+e.htmlFor+'" for your label, but the id of your input is "'+s.inputId+'". You must either remove the id from your input or set the htmlFor of the label equal to the input id.');return s.inputId=h(s.inputId,e.htmlFor,p("downshift-input")),w({},e,{htmlFor:s.inputId})},s.getInputProps=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.onChange,n=e.onKeyDown,o=e.onBlur,r=x(e,["onChange","onKeyDown","onBlur"]);if(s.getInputProps.called=!0,s.getLabelProps.called&&r.id&&r.id!==s.inputId)throw new Error('downshift: You provided the id of "'+r.id+'" for your input, but the htmlFor of your label is "'+s.inputId+'". You must either remove the id from your input or set the htmlFor of the label equal to the input id.');s.inputId=h(s.inputId,r.id,p("downshift-input"));var i=s.getState(),u=i.inputValue,l=i.isOpen,a=i.highlightedIndex;return w({role:"combobox","aria-autocomplete":"list","aria-expanded":l,"aria-activedescendant":"number"==typeof a&&a>=0?s.getItemId(a):null,autoComplete:"off",value:u,onChange:d(t,s.input_handleChange),onKeyDown:d(n,s.input_handleKeyDown),onBlur:d(o,s.input_handleBlur)},r,{id:s.inputId})},s.input_handleKeyDown=function(e){e.key&&s.keyDownHandlers[e.key]&&s.keyDownHandlers[e.key].call(s,e)},s.input_handleChange=function(e){s.internalSetState({isOpen:!0,inputValue:e.target.value})},s.input_handleBlur=function(){s.isMouseDown||s.reset()},s.getItemProps=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.onMouseEnter,n=e.item,o=e.index,r=x(e,["onMouseEnter","item","index"]);return s.items[o]=n,w({id:s.getItemId(o),onMouseEnter:d(t,function(){s.setHighlightedIndex(o)})},r)},s.reset=function(e){s.internalSetState(function(t){var n=t.selectedItem;return{type:e,isOpen:!1,highlightedIndex:null,inputValue:s.props.itemToString(n)}})},s.toggleMenu=function(e,t){s.internalSetState(function(t){var n=!t.isOpen;return"boolean"==typeof e&&(n=e),{isOpen:n}},function(){s.getState().isOpen&&s.setHighlightedIndex(),i(t)()})},s.openMenu=function(e){s.toggleMenu(!0,e)},s.closeMenu=function(e){s.toggleMenu(!1,e)},s.updateStatus=a(function(){if(s._isMounted){var e=s.getState(),t=s.getItemFromIndex(e.highlightedIndex)||{},o=s.items.length,r=s.props.getA11yStatusMessage(w({itemToString:s.props.itemToString,previousResultCount:s.previousResultCount,resultCount:o,highlightedItem:t},e));s.previousResultCount=o,n(r)}},200),s.id=p("downshift"),s.state={highlightedIndex:s.props.defaultHighlightedIndex,inputValue:s.props.defaultInputValue,isOpen:s.props.defaultIsOpen,selectedItem:s.props.defaultSelectedItem},s.root_handleClick=d(s.props.onClick,s.root_handleClick),s}return S(t,e),v(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(t,n){return t[n]=void 0===e.props[n]?e.state[n]:e.props[n],t},{})}},{key:"maybeScrollToHighlightedElement",value:function(e){s(this.getItemNodeFromIndex(e),this._rootNode)}},{key:"internalSetState",value:function(e,t){var n=this,o={},r=void 0,u=void 0;return this.setState(function(t){t=n.getState(t);var i={},l={};return(r="function"==typeof e?e(t):e).hasOwnProperty("selectedItem")&&(o.selectedItem=r.selectedItem,o.previousItem=t.selectedItem),Object.keys(r).forEach(function(e){"type"!==e&&(l[e]=r[e],n.props.hasOwnProperty(e)||(i[e]=r[e]))}),u=!f(t,l),i},function(){i(t)(),u&&n.props.onStateChange(r),Object.keys(o).length&&n.props.onChange(o)})}},{key:"getControllerStateAndHelpers",value:function(){var e=this.getState(),t=e.highlightedIndex,n=e.inputValue,o=e.selectedItem,r=e.isOpen;return{getRootProps:this.getRootProps,getButtonProps:this.getButtonProps,getLabelProps:this.getLabelProps,getInputProps:this.getInputProps,getItemProps:this.getItemProps,openMenu:this.openMenu,closeMenu:this.closeMenu,toggleMenu:this.toggleMenu,selectItem:this.selectItem,selectItemAtIndex:this.selectItemAtIndex,selectHighlightedItem:this.selectHighlightedItem,setHighlightedIndex:this.setHighlightedIndex,clearSelection:this.clearSelection,highlightedIndex:t,inputValue:n,isOpen:r,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.reset(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(){this.updateStatus()}},{key:"componentWillUnmount",value:function(){this.cleanup()}},{key:"render",value:function(){var e=this.props.children;this.items=[],this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;var t=e&&e(this.getControllerStateAndHelpers());if(!t)return null;var n=m.Children.only(t);if(this.getRootProps.called)return g(n,this.getRootProps),n;if("string"==typeof n.type)return m.cloneElement(n,this.getRootProps(n.props));throw new Error("downshift: If you return a non-DOM element, you must use apply the getRootProps function")}}]),t}(e.Component);return D.propTypes={children:y.func,defaultHighlightedIndex:y.number,defaultSelectedItem:y.any,defaultInputValue:y.string,defaultIsOpen:y.bool,getA11yStatusMessage:y.func,itemToString:y.func,onChange:y.func,onStateChange:y.func,onClick:y.func,selectedItem:y.any,isOpen:y.bool,inputValue:y.string,highlightedIndex:y.number},D.defaultProps={defaultHighlightedIndex:null,defaultSelectedItem:null,defaultInputValue:"",defaultIsOpen:!1,getA11yStatusMessage:function(e){var t=e.isOpen,n=e.highlightedItem,o=e.selectedItem,r=e.resultCount,i=e.previousResultCount,u=e.itemToString;if(!t)return o?u(o):"";var l=r!==i;return r?!n||l?r+" "+(1===r?"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(){},onChange:function(){}},D.stateChangeTypes={mouseUp:"__autocomplete_mouseup__"},D});
!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.preact)}(this,function(e){"use strict";function t(){}function n(e){var t=k[k.length-1]===e;k=t?[].concat(C(k),[e]):[e],r().innerHTML=""+k.filter(Boolean).map(o).join("")}function o(e,t){return'<div style="display:'+(t===k.length-1?"block":"none")+';">'+e+"</div>"}function r(){return O||((O=document.createElement("div")).setAttribute("id","a11y-status-message"),O.setAttribute("role","status"),O.setAttribute("aria-live","assertive"),O.setAttribute("aria-relevant","additions text"),Object.assign(O.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),document.body.appendChild(O),O)}function i(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=H(e,t);if(null!==n){var o=getComputedStyle(n),r=n.getBoundingClientRect(),i=parseInt(o.borderTopWidth,10),u=r.top+i,l=e.getBoundingClientRect(),s=l.top+n.scrollTop-u;s<n.scrollTop?n.scrollTop=s:s+l.height>n.scrollTop+r.height&&(n.scrollTop=s+l.height-r.height)}}function a(e,t){var n=void 0;return function(){for(var o=arguments.length,r=Array(o),i=0;i<o;i++)r[i]=arguments[i];n&&clearTimeout(n),n=setTimeout(function(){n=null,e.apply(void 0,r)},t)}}function d(){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),r=1;r<n;r++)o[r-1]=arguments[r];return t.some(function(t){return t&&t.apply(void 0,[e].concat(o)),e.defaultPrevented})}}function p(e){return e+"-"+_++}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 f(e,t){return Object.keys(t).every(function(n){return e[n]===t[n]})}function g(e,t){var n=t.refKey,o="ref"!==n,r="string"!=typeof e.type;if(r&&!o)throw new Error("downshift: You returned a non-DOM element. You must specify a refKey in getRootProps");if(!r&&o)throw new Error('downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified "'+n+'"');if(!e.props.hasOwnProperty(n))throw new Error('downshift: You must apply the ref prop "'+n+'" from getRootProps onto your root element.');if(!e.props.hasOwnProperty("onClick"))throw new Error('downshift: You must apply the "onClick" prop from getRootProps onto your root element.')}var m=e.default;m.Children={only:function(e){return e&&e[0]}},t.isRequired=t;var y={element:t,func:t,number:t,any:t,bool:t,string:t},I=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},v=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},w=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)},x=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},P=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},C=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)},O="undefined"==typeof document?null:document.getElementById("a11y-status-message"),k=[],_=1,H=l.bind(null,function(e){return e.scrollHeight>e.clientHeight}),D=function(e){function t(){var e;I(this,t);for(var o=arguments.length,r=Array(o),u=0;u<o;u++)r[u]=arguments[u];var s=P(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(r)));return s.input=null,s.items=[],s.previousResultCount=0,s.getItemFromIndex=function(e){return s.items&&s.items[0]?s.items[e]:null},s.getItemNodeFromIndex=function(e){return document.getElementById(s.getItemId(e))},s.setHighlightedIndex=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:s.props.defaultHighlightedIndex;s.internalSetState({highlightedIndex:e},function(){s.maybeScrollToHighlightedElement(e)})},s.highlightIndex=function(e){s.openMenu(function(){s.setHighlightedIndex(e)})},s.moveHighlightedIndex=function(e){s.getState().isOpen?s.changeHighlighedIndex(e):s.highlightIndex()},s.changeHighlighedIndex=function(e){var t=s.items.length-1;if(!(t<0)){var n=s.getState().highlightedIndex;null===n&&(n=e>0?-1:t+1);var o=n+e;o<0?o=t:o>t&&(o=0),s.setHighlightedIndex(o)}},s.clearSelection=function(){s.internalSetState({selectedItem:null,inputValue:"",isOpen:!1},function(){var e=s._rootNode.querySelector("#"+s.inputId);e&&e.focus&&e.focus()})},s.selectItem=function(e){s.reset(),s.internalSetState({selectedItem:e,inputValue:s.props.itemToString(e)})},s.selectItemAtIndex=function(e){if(null!==e){var t=s.getItemFromIndex(e);t&&s.selectItem(t)}},s.selectHighlightedItem=function(){return s.selectItemAtIndex(s.getState().highlightedIndex)},s.rootRef=function(e){return s._rootNode=e},s.getRootProps=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.refKey,o=void 0===n?"ref":n,r=t.onClick,i=x(t,["refKey","onClick"]);return s.getRootProps.called=!0,s.getRootProps.refKey=o,w((e={},b(e,o,s.rootRef),b(e,"onClick",d(r,s.root_handleClick)),e),i)},s.root_handleClick=function(e){e.preventDefault();var t=l(function(e){return c(s.getItemIndexFromId(e.getAttribute("id")))},e.target,s._rootNode);t&&s.selectItemAtIndex(s.getItemIndexFromId(t.getAttribute("id")))},s.keyDownHandlers={ArrowDown:function(e){e.preventDefault();var t=e.shiftKey?5:1;this.moveHighlightedIndex(t)},ArrowUp:function(e){e.preventDefault();var t=e.shiftKey?-5:-1;this.moveHighlightedIndex(t)},Enter:function(e){e.preventDefault(),this.getState().isOpen&&this.selectHighlightedItem()},Escape:function(e){e.preventDefault(),this.reset()}},s.buttonKeyDownHandlers=w({},s.keyDownHandlers,{" ":function(e){e.preventDefault(),this.toggleMenu()}}),s.getButtonProps=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.onClick,n=e.onKeyDown,o=x(e,["onClick","onKeyDown"]),r=s.getState().isOpen;return w({role:"button","aria-label":r?"close menu":"open menu","aria-expanded":r,"aria-haspopup":!0,onClick:d(t,s.button_handleClick),onKeyDown:d(n,s.button_handleKeyDown)},o)},s.button_handleKeyDown=function(e){s.buttonKeyDownHandlers[e.key]&&s.buttonKeyDownHandlers[e.key].call(s,e)},s.button_handleClick=function(e){e.preventDefault(),s.toggleMenu()},s.getLabelProps=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(s.getLabelProps.called=!0,s.getInputProps.called&&e.htmlFor&&e.htmlFor!==s.inputId)throw new Error('downshift: You provided the htmlFor of "'+e.htmlFor+'" for your label, but the id of your input is "'+s.inputId+'". You must either remove the id from your input or set the htmlFor of the label equal to the input id.');return s.inputId=h(s.inputId,e.htmlFor,p("downshift-input")),w({},e,{htmlFor:s.inputId})},s.getInputProps=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.onChange,n=e.onKeyDown,o=e.onBlur,r=x(e,["onChange","onKeyDown","onBlur"]);if(s.getInputProps.called=!0,s.getLabelProps.called&&r.id&&r.id!==s.inputId)throw new Error('downshift: You provided the id of "'+r.id+'" for your input, but the htmlFor of your label is "'+s.inputId+'". You must either remove the id from your input or set the htmlFor of the label equal to the input id.');s.inputId=h(s.inputId,r.id,p("downshift-input"));var i=s.getState(),u=i.inputValue,l=i.isOpen,a=i.highlightedIndex;return w({role:"combobox","aria-autocomplete":"list","aria-expanded":l,"aria-activedescendant":"number"==typeof a&&a>=0?s.getItemId(a):null,autoComplete:"off",value:u,onChange:d(t,s.input_handleChange),onKeyDown:d(n,s.input_handleKeyDown),onBlur:d(o,s.input_handleBlur)},r,{id:s.inputId})},s.input_handleKeyDown=function(e){e.key&&s.keyDownHandlers[e.key]&&s.keyDownHandlers[e.key].call(s,e)},s.input_handleChange=function(e){s.internalSetState({isOpen:!0,inputValue:e.target.value})},s.input_handleBlur=function(){s.isMouseDown||s.reset()},s.getItemProps=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.onMouseEnter,n=e.item,o=e.index,r=x(e,["onMouseEnter","item","index"]);return s.items[o]=n,w({id:s.getItemId(o),onMouseEnter:d(t,function(){s.setHighlightedIndex(o)})},r)},s.reset=function(e){s.internalSetState(function(t){var n=t.selectedItem;return{type:e,isOpen:!1,highlightedIndex:null,inputValue:s.props.itemToString(n)}})},s.toggleMenu=function(e,t){s.internalSetState(function(t){var n=!t.isOpen;return"boolean"==typeof e&&(n=e),{isOpen:n}},function(){s.getState().isOpen&&s.setHighlightedIndex(),i(t)()})},s.openMenu=function(e){s.toggleMenu(!0,e)},s.closeMenu=function(e){s.toggleMenu(!1,e)},s.updateStatus=a(function(){if(s._isMounted){var e=s.getState(),t=s.getItemFromIndex(e.highlightedIndex)||{},o=s.items.length,r=s.props.getA11yStatusMessage(w({itemToString:s.props.itemToString,previousResultCount:s.previousResultCount,resultCount:o,highlightedItem:t},e));s.previousResultCount=o,n(r)}},200),s.id=p("downshift"),s.state={highlightedIndex:s.props.defaultHighlightedIndex,inputValue:s.props.defaultInputValue,isOpen:s.props.defaultIsOpen,selectedItem:s.props.defaultSelectedItem},s.root_handleClick=d(s.props.onClick,s.root_handleClick),s}return S(t,e),v(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(t,n){return t[n]=e.isStateProp(n)?e.props[n]:e.state[n],t},{})}},{key:"isStateProp",value:function(e){return void 0!==this.props[e]}},{key:"maybeScrollToHighlightedElement",value:function(e){s(this.getItemNodeFromIndex(e),this._rootNode)}},{key:"internalSetState",value:function(e,t){var n=this,o={},r=void 0,u=void 0;return this.setState(function(t){t=n.getState(t);var i={},l={};return(r="function"==typeof e?e(t):e).hasOwnProperty("selectedItem")&&(o.selectedItem=r.selectedItem,o.previousItem=t.selectedItem),Object.keys(r).forEach(function(e){"type"!==e&&(l[e]=r[e],n.isStateProp(e)||(i[e]=r[e]))}),u=!f(t,l),i},function(){i(t)(),u&&n.props.onStateChange(r),Object.keys(o).length&&n.props.onChange(o)})}},{key:"getControllerStateAndHelpers",value:function(){var e=this.getState(),t=e.highlightedIndex,n=e.inputValue,o=e.selectedItem,r=e.isOpen;return{getRootProps:this.getRootProps,getButtonProps:this.getButtonProps,getLabelProps:this.getLabelProps,getInputProps:this.getInputProps,getItemProps:this.getItemProps,openMenu:this.openMenu,closeMenu:this.closeMenu,toggleMenu:this.toggleMenu,selectItem:this.selectItem,selectItemAtIndex:this.selectItemAtIndex,selectHighlightedItem:this.selectHighlightedItem,setHighlightedIndex:this.setHighlightedIndex,clearSelection:this.clearSelection,highlightedIndex:t,inputValue:n,isOpen:r,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.reset(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.isStateProp("selectedItem")&&this.props.selectedItem!==e.selectedItem&&this.internalSetState({inputValue:this.props.itemToString(this.props.selectedItem)}),this.updateStatus()}},{key:"componentWillUnmount",value:function(){this.cleanup()}},{key:"render",value:function(){var e=this.props.children;this.items=[],this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;var t=e&&e(this.getControllerStateAndHelpers());if(!t)return null;var n=m.Children.only(t);if(this.getRootProps.called)return g(n,this.getRootProps),n;if("string"==typeof n.type)return m.cloneElement(n,this.getRootProps(n.props));throw new Error("downshift: If you return a non-DOM element, you must use apply the getRootProps function")}}]),t}(e.PureComponent);return D.propTypes={children:y.func,defaultHighlightedIndex:y.number,defaultSelectedItem:y.any,defaultInputValue:y.string,defaultIsOpen:y.bool,getA11yStatusMessage:y.func,itemToString:y.func,onChange:y.func,onStateChange:y.func,onClick:y.func,selectedItem:y.any,isOpen:y.bool,inputValue:y.string,highlightedIndex:y.number},D.defaultProps={defaultHighlightedIndex:null,defaultSelectedItem:null,defaultInputValue:"",defaultIsOpen:!1,getA11yStatusMessage:function(e){var t=e.isOpen,n=e.highlightedItem,o=e.selectedItem,r=e.resultCount,i=e.previousResultCount,u=e.itemToString;if(!t)return o?u(o):"";var l=r!==i;return r?!n||l?r+" "+(1===r?"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(){},onChange:function(){}},D.stateChangeTypes={mouseUp:"__autocomplete_mouseup__"},D});
//# sourceMappingURL=downshift.preact.umd.min.js.map

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

var Downshift$1 = function (_Component) {
inherits(Downshift, _Component);
var Downshift$1 = function (_PureComponent) {
inherits(Downshift, _PureComponent);

@@ -751,7 +751,21 @@ function Downshift() {

return Object.keys(stateToMerge).reduce(function (state, key) {
state[key] = _this2.props[key] === undefined ? _this2.state[key] : _this2.props[key];
state[key] = _this2.isStateProp(key) ? _this2.props[key] : _this2.state[key];
return state;
}, {});
}
/**
* This determines whether a prop is a "state prop" meaning it is
* state which is controlled by the outside of this component rather
* than within this component.
* @param {String} key the key to check
* @return {Boolean} whether it is a controlled state prop
*/
}, {
key: 'isStateProp',
value: function isStateProp(key) {
return this.props[key] !== undefined;
}
}, {
key: 'maybeScrollToHighlightedElement',

@@ -811,3 +825,3 @@ value: function maybeScrollToHighlightedElement(highlightedIndex) {

// if it's coming from props, then we don't want to set it internally
if (!_this3.props.hasOwnProperty(key)) {
if (!_this3.isStateProp(key)) {
nextState[key] = onStateChangeArg[key];

@@ -951,3 +965,8 @@ }

key: 'componentDidUpdate',
value: function componentDidUpdate() {
value: function componentDidUpdate(prevProps) {
if (this.isStateProp('selectedItem') && this.props.selectedItem !== prevProps.selectedItem) {
this.internalSetState({
inputValue: this.props.itemToString(this.props.selectedItem)
});
}
this.updateStatus();

@@ -999,3 +1018,3 @@ }

return Downshift;
}(React.Component);
}(React.PureComponent);

@@ -1002,0 +1021,0 @@ Downshift$1.propTypes = {

@@ -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],r().innerHTML=""+O.filter(Boolean).map(o).join("")}function o(e,t){return'<div style="display:'+(t===O.length-1?"block":"none")+';">'+e+"</div>"}function r(){return C||((C=document.createElement("div")).setAttribute("id","a11y-status-message"),C.setAttribute("role","status"),C.setAttribute("aria-live","assertive"),C.setAttribute("aria-relevant","additions text"),Object.assign(C.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),document.body.appendChild(C),C)}function i(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=_(e,t);if(null!==n){var o=getComputedStyle(n),r=n.getBoundingClientRect(),i=parseInt(o.borderTopWidth,10),u=r.top+i,l=e.getBoundingClientRect(),s=l.top+n.scrollTop-u;s<n.scrollTop?n.scrollTop=s:s+l.height>n.scrollTop+r.height&&(n.scrollTop=s+l.height-r.height)}}function a(e,t){var n=void 0;return function(){for(var o=arguments.length,r=Array(o),i=0;i<o;i++)r[i]=arguments[i];n&&clearTimeout(n),n=setTimeout(function(){n=null,e.apply(void 0,r)},t)}}function d(){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),r=1;r<n;r++)o[r-1]=arguments[r];return t.some(function(t){return t&&t.apply(void 0,[e].concat(o)),e.defaultPrevented})}}function p(e){return e+"-"+k++}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 f(e,t){return Object.keys(t).every(function(n){return e[n]===t[n]})}function g(e,t){var n=t.refKey,o="ref"!==n,r="string"!=typeof e.type;if(r&&!o)throw new Error("downshift: You returned a non-DOM element. You must specify a refKey in getRootProps");if(!r&&o)throw new Error('downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified "'+n+'"');if(!e.props.hasOwnProperty(n))throw new Error('downshift: You must apply the ref prop "'+n+'" from getRootProps onto your root element.');if(!e.props.hasOwnProperty("onClick"))throw new Error('downshift: You must apply the "onClick" prop from getRootProps onto your root element.')}var m="default"in e?e.default:e;t=t&&t.hasOwnProperty("default")?t.default:t;var y=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},I=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}}(),v=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},w=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},b=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)},S=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)},C="undefined"==typeof document?null:document.getElementById("a11y-status-message"),O=[],k=1,_=l.bind(null,function(e){return e.scrollHeight>e.clientHeight}),H=function(e){function t(){var e;y(this,t);for(var o=arguments.length,r=Array(o),u=0;u<o;u++)r[u]=arguments[u];var s=x(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(r)));return s.input=null,s.items=[],s.previousResultCount=0,s.getItemFromIndex=function(e){return s.items&&s.items[0]?s.items[e]:null},s.getItemNodeFromIndex=function(e){return document.getElementById(s.getItemId(e))},s.setHighlightedIndex=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:s.props.defaultHighlightedIndex;s.internalSetState({highlightedIndex:e},function(){s.maybeScrollToHighlightedElement(e)})},s.highlightIndex=function(e){s.openMenu(function(){s.setHighlightedIndex(e)})},s.moveHighlightedIndex=function(e){s.getState().isOpen?s.changeHighlighedIndex(e):s.highlightIndex()},s.changeHighlighedIndex=function(e){var t=s.items.length-1;if(!(t<0)){var n=s.getState().highlightedIndex;null===n&&(n=e>0?-1:t+1);var o=n+e;o<0?o=t:o>t&&(o=0),s.setHighlightedIndex(o)}},s.clearSelection=function(){s.internalSetState({selectedItem:null,inputValue:"",isOpen:!1},function(){var e=s._rootNode.querySelector("#"+s.inputId);e&&e.focus&&e.focus()})},s.selectItem=function(e){s.reset(),s.internalSetState({selectedItem:e,inputValue:s.props.itemToString(e)})},s.selectItemAtIndex=function(e){if(null!==e){var t=s.getItemFromIndex(e);t&&s.selectItem(t)}},s.selectHighlightedItem=function(){return s.selectItemAtIndex(s.getState().highlightedIndex)},s.rootRef=function(e){return s._rootNode=e},s.getRootProps=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.refKey,o=void 0===n?"ref":n,r=t.onClick,i=S(t,["refKey","onClick"]);return s.getRootProps.called=!0,s.getRootProps.refKey=o,w((e={},v(e,o,s.rootRef),v(e,"onClick",d(r,s.root_handleClick)),e),i)},s.root_handleClick=function(e){e.preventDefault();var t=l(function(e){return c(s.getItemIndexFromId(e.getAttribute("id")))},e.target,s._rootNode);t&&s.selectItemAtIndex(s.getItemIndexFromId(t.getAttribute("id")))},s.keyDownHandlers={ArrowDown:function(e){e.preventDefault();var t=e.shiftKey?5:1;this.moveHighlightedIndex(t)},ArrowUp:function(e){e.preventDefault();var t=e.shiftKey?-5:-1;this.moveHighlightedIndex(t)},Enter:function(e){e.preventDefault(),this.getState().isOpen&&this.selectHighlightedItem()},Escape:function(e){e.preventDefault(),this.reset()}},s.buttonKeyDownHandlers=w({},s.keyDownHandlers,{" ":function(e){e.preventDefault(),this.toggleMenu()}}),s.getButtonProps=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.onClick,n=e.onKeyDown,o=S(e,["onClick","onKeyDown"]),r=s.getState().isOpen;return w({role:"button","aria-label":r?"close menu":"open menu","aria-expanded":r,"aria-haspopup":!0,onClick:d(t,s.button_handleClick),onKeyDown:d(n,s.button_handleKeyDown)},o)},s.button_handleKeyDown=function(e){s.buttonKeyDownHandlers[e.key]&&s.buttonKeyDownHandlers[e.key].call(s,e)},s.button_handleClick=function(e){e.preventDefault(),s.toggleMenu()},s.getLabelProps=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(s.getLabelProps.called=!0,s.getInputProps.called&&e.htmlFor&&e.htmlFor!==s.inputId)throw new Error('downshift: You provided the htmlFor of "'+e.htmlFor+'" for your label, but the id of your input is "'+s.inputId+'". You must either remove the id from your input or set the htmlFor of the label equal to the input id.');return s.inputId=h(s.inputId,e.htmlFor,p("downshift-input")),w({},e,{htmlFor:s.inputId})},s.getInputProps=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.onChange,n=e.onKeyDown,o=e.onBlur,r=S(e,["onChange","onKeyDown","onBlur"]);if(s.getInputProps.called=!0,s.getLabelProps.called&&r.id&&r.id!==s.inputId)throw new Error('downshift: You provided the id of "'+r.id+'" for your input, but the htmlFor of your label is "'+s.inputId+'". You must either remove the id from your input or set the htmlFor of the label equal to the input id.');s.inputId=h(s.inputId,r.id,p("downshift-input"));var i=s.getState(),u=i.inputValue,l=i.isOpen,a=i.highlightedIndex;return w({role:"combobox","aria-autocomplete":"list","aria-expanded":l,"aria-activedescendant":"number"==typeof a&&a>=0?s.getItemId(a):null,autoComplete:"off",value:u,onChange:d(t,s.input_handleChange),onKeyDown:d(n,s.input_handleKeyDown),onBlur:d(o,s.input_handleBlur)},r,{id:s.inputId})},s.input_handleKeyDown=function(e){e.key&&s.keyDownHandlers[e.key]&&s.keyDownHandlers[e.key].call(s,e)},s.input_handleChange=function(e){s.internalSetState({isOpen:!0,inputValue:e.target.value})},s.input_handleBlur=function(){s.isMouseDown||s.reset()},s.getItemProps=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.onMouseEnter,n=e.item,o=e.index,r=S(e,["onMouseEnter","item","index"]);return s.items[o]=n,w({id:s.getItemId(o),onMouseEnter:d(t,function(){s.setHighlightedIndex(o)})},r)},s.reset=function(e){s.internalSetState(function(t){var n=t.selectedItem;return{type:e,isOpen:!1,highlightedIndex:null,inputValue:s.props.itemToString(n)}})},s.toggleMenu=function(e,t){s.internalSetState(function(t){var n=!t.isOpen;return"boolean"==typeof e&&(n=e),{isOpen:n}},function(){s.getState().isOpen&&s.setHighlightedIndex(),i(t)()})},s.openMenu=function(e){s.toggleMenu(!0,e)},s.closeMenu=function(e){s.toggleMenu(!1,e)},s.updateStatus=a(function(){if(s._isMounted){var e=s.getState(),t=s.getItemFromIndex(e.highlightedIndex)||{},o=s.items.length,r=s.props.getA11yStatusMessage(w({itemToString:s.props.itemToString,previousResultCount:s.previousResultCount,resultCount:o,highlightedItem:t},e));s.previousResultCount=o,n(r)}},200),s.id=p("downshift"),s.state={highlightedIndex:s.props.defaultHighlightedIndex,inputValue:s.props.defaultInputValue,isOpen:s.props.defaultIsOpen,selectedItem:s.props.defaultSelectedItem},s.root_handleClick=d(s.props.onClick,s.root_handleClick),s}return b(t,e),I(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(t,n){return t[n]=void 0===e.props[n]?e.state[n]:e.props[n],t},{})}},{key:"maybeScrollToHighlightedElement",value:function(e){s(this.getItemNodeFromIndex(e),this._rootNode)}},{key:"internalSetState",value:function(e,t){var n=this,o={},r=void 0,u=void 0;return this.setState(function(t){t=n.getState(t);var i={},l={};return(r="function"==typeof e?e(t):e).hasOwnProperty("selectedItem")&&(o.selectedItem=r.selectedItem,o.previousItem=t.selectedItem),Object.keys(r).forEach(function(e){"type"!==e&&(l[e]=r[e],n.props.hasOwnProperty(e)||(i[e]=r[e]))}),u=!f(t,l),i},function(){i(t)(),u&&n.props.onStateChange(r),Object.keys(o).length&&n.props.onChange(o)})}},{key:"getControllerStateAndHelpers",value:function(){var e=this.getState(),t=e.highlightedIndex,n=e.inputValue,o=e.selectedItem,r=e.isOpen;return{getRootProps:this.getRootProps,getButtonProps:this.getButtonProps,getLabelProps:this.getLabelProps,getInputProps:this.getInputProps,getItemProps:this.getItemProps,openMenu:this.openMenu,closeMenu:this.closeMenu,toggleMenu:this.toggleMenu,selectItem:this.selectItem,selectItemAtIndex:this.selectItemAtIndex,selectHighlightedItem:this.selectHighlightedItem,setHighlightedIndex:this.setHighlightedIndex,clearSelection:this.clearSelection,highlightedIndex:t,inputValue:n,isOpen:r,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.reset(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(){this.updateStatus()}},{key:"componentWillUnmount",value:function(){this.cleanup()}},{key:"render",value:function(){var e=this.props.children;this.items=[],this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;var t=e&&e(this.getControllerStateAndHelpers());if(!t)return null;var n=m.Children.only(t);if(this.getRootProps.called)return g(n,this.getRootProps),n;if("string"==typeof n.type)return m.cloneElement(n,this.getRootProps(n.props));throw new Error("downshift: If you return a non-DOM element, you must use apply the getRootProps function")}}]),t}(e.Component);return 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,onClick:t.func,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,r=e.resultCount,i=e.previousResultCount,u=e.itemToString;if(!t)return o?u(o):"";var l=r!==i;return r?!n||l?r+" "+(1===r?"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(){},onChange:function(){}},H.stateChangeTypes={mouseUp:"__autocomplete_mouseup__"},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],r().innerHTML=""+O.filter(Boolean).map(o).join("")}function o(e,t){return'<div style="display:'+(t===O.length-1?"block":"none")+';">'+e+"</div>"}function r(){return C||((C=document.createElement("div")).setAttribute("id","a11y-status-message"),C.setAttribute("role","status"),C.setAttribute("aria-live","assertive"),C.setAttribute("aria-relevant","additions text"),Object.assign(C.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),document.body.appendChild(C),C)}function i(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=_(e,t);if(null!==n){var o=getComputedStyle(n),r=n.getBoundingClientRect(),i=parseInt(o.borderTopWidth,10),u=r.top+i,l=e.getBoundingClientRect(),s=l.top+n.scrollTop-u;s<n.scrollTop?n.scrollTop=s:s+l.height>n.scrollTop+r.height&&(n.scrollTop=s+l.height-r.height)}}function a(e,t){var n=void 0;return function(){for(var o=arguments.length,r=Array(o),i=0;i<o;i++)r[i]=arguments[i];n&&clearTimeout(n),n=setTimeout(function(){n=null,e.apply(void 0,r)},t)}}function d(){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),r=1;r<n;r++)o[r-1]=arguments[r];return t.some(function(t){return t&&t.apply(void 0,[e].concat(o)),e.defaultPrevented})}}function p(e){return e+"-"+k++}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 f(e,t){return Object.keys(t).every(function(n){return e[n]===t[n]})}function g(e,t){var n=t.refKey,o="ref"!==n,r="string"!=typeof e.type;if(r&&!o)throw new Error("downshift: You returned a non-DOM element. You must specify a refKey in getRootProps");if(!r&&o)throw new Error('downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified "'+n+'"');if(!e.props.hasOwnProperty(n))throw new Error('downshift: You must apply the ref prop "'+n+'" from getRootProps onto your root element.');if(!e.props.hasOwnProperty("onClick"))throw new Error('downshift: You must apply the "onClick" prop from getRootProps onto your root element.')}var m="default"in e?e.default:e;t=t&&t.hasOwnProperty("default")?t.default:t;var y=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},I=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}}(),v=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},w=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},b=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)},S=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)},C="undefined"==typeof document?null:document.getElementById("a11y-status-message"),O=[],k=1,_=l.bind(null,function(e){return e.scrollHeight>e.clientHeight}),H=function(e){function t(){var e;y(this,t);for(var o=arguments.length,r=Array(o),u=0;u<o;u++)r[u]=arguments[u];var s=x(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(r)));return s.input=null,s.items=[],s.previousResultCount=0,s.getItemFromIndex=function(e){return s.items&&s.items[0]?s.items[e]:null},s.getItemNodeFromIndex=function(e){return document.getElementById(s.getItemId(e))},s.setHighlightedIndex=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:s.props.defaultHighlightedIndex;s.internalSetState({highlightedIndex:e},function(){s.maybeScrollToHighlightedElement(e)})},s.highlightIndex=function(e){s.openMenu(function(){s.setHighlightedIndex(e)})},s.moveHighlightedIndex=function(e){s.getState().isOpen?s.changeHighlighedIndex(e):s.highlightIndex()},s.changeHighlighedIndex=function(e){var t=s.items.length-1;if(!(t<0)){var n=s.getState().highlightedIndex;null===n&&(n=e>0?-1:t+1);var o=n+e;o<0?o=t:o>t&&(o=0),s.setHighlightedIndex(o)}},s.clearSelection=function(){s.internalSetState({selectedItem:null,inputValue:"",isOpen:!1},function(){var e=s._rootNode.querySelector("#"+s.inputId);e&&e.focus&&e.focus()})},s.selectItem=function(e){s.reset(),s.internalSetState({selectedItem:e,inputValue:s.props.itemToString(e)})},s.selectItemAtIndex=function(e){if(null!==e){var t=s.getItemFromIndex(e);t&&s.selectItem(t)}},s.selectHighlightedItem=function(){return s.selectItemAtIndex(s.getState().highlightedIndex)},s.rootRef=function(e){return s._rootNode=e},s.getRootProps=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.refKey,o=void 0===n?"ref":n,r=t.onClick,i=S(t,["refKey","onClick"]);return s.getRootProps.called=!0,s.getRootProps.refKey=o,w((e={},v(e,o,s.rootRef),v(e,"onClick",d(r,s.root_handleClick)),e),i)},s.root_handleClick=function(e){e.preventDefault();var t=l(function(e){return c(s.getItemIndexFromId(e.getAttribute("id")))},e.target,s._rootNode);t&&s.selectItemAtIndex(s.getItemIndexFromId(t.getAttribute("id")))},s.keyDownHandlers={ArrowDown:function(e){e.preventDefault();var t=e.shiftKey?5:1;this.moveHighlightedIndex(t)},ArrowUp:function(e){e.preventDefault();var t=e.shiftKey?-5:-1;this.moveHighlightedIndex(t)},Enter:function(e){e.preventDefault(),this.getState().isOpen&&this.selectHighlightedItem()},Escape:function(e){e.preventDefault(),this.reset()}},s.buttonKeyDownHandlers=w({},s.keyDownHandlers,{" ":function(e){e.preventDefault(),this.toggleMenu()}}),s.getButtonProps=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.onClick,n=e.onKeyDown,o=S(e,["onClick","onKeyDown"]),r=s.getState().isOpen;return w({role:"button","aria-label":r?"close menu":"open menu","aria-expanded":r,"aria-haspopup":!0,onClick:d(t,s.button_handleClick),onKeyDown:d(n,s.button_handleKeyDown)},o)},s.button_handleKeyDown=function(e){s.buttonKeyDownHandlers[e.key]&&s.buttonKeyDownHandlers[e.key].call(s,e)},s.button_handleClick=function(e){e.preventDefault(),s.toggleMenu()},s.getLabelProps=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(s.getLabelProps.called=!0,s.getInputProps.called&&e.htmlFor&&e.htmlFor!==s.inputId)throw new Error('downshift: You provided the htmlFor of "'+e.htmlFor+'" for your label, but the id of your input is "'+s.inputId+'". You must either remove the id from your input or set the htmlFor of the label equal to the input id.');return s.inputId=h(s.inputId,e.htmlFor,p("downshift-input")),w({},e,{htmlFor:s.inputId})},s.getInputProps=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.onChange,n=e.onKeyDown,o=e.onBlur,r=S(e,["onChange","onKeyDown","onBlur"]);if(s.getInputProps.called=!0,s.getLabelProps.called&&r.id&&r.id!==s.inputId)throw new Error('downshift: You provided the id of "'+r.id+'" for your input, but the htmlFor of your label is "'+s.inputId+'". You must either remove the id from your input or set the htmlFor of the label equal to the input id.');s.inputId=h(s.inputId,r.id,p("downshift-input"));var i=s.getState(),u=i.inputValue,l=i.isOpen,a=i.highlightedIndex;return w({role:"combobox","aria-autocomplete":"list","aria-expanded":l,"aria-activedescendant":"number"==typeof a&&a>=0?s.getItemId(a):null,autoComplete:"off",value:u,onChange:d(t,s.input_handleChange),onKeyDown:d(n,s.input_handleKeyDown),onBlur:d(o,s.input_handleBlur)},r,{id:s.inputId})},s.input_handleKeyDown=function(e){e.key&&s.keyDownHandlers[e.key]&&s.keyDownHandlers[e.key].call(s,e)},s.input_handleChange=function(e){s.internalSetState({isOpen:!0,inputValue:e.target.value})},s.input_handleBlur=function(){s.isMouseDown||s.reset()},s.getItemProps=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.onMouseEnter,n=e.item,o=e.index,r=S(e,["onMouseEnter","item","index"]);return s.items[o]=n,w({id:s.getItemId(o),onMouseEnter:d(t,function(){s.setHighlightedIndex(o)})},r)},s.reset=function(e){s.internalSetState(function(t){var n=t.selectedItem;return{type:e,isOpen:!1,highlightedIndex:null,inputValue:s.props.itemToString(n)}})},s.toggleMenu=function(e,t){s.internalSetState(function(t){var n=!t.isOpen;return"boolean"==typeof e&&(n=e),{isOpen:n}},function(){s.getState().isOpen&&s.setHighlightedIndex(),i(t)()})},s.openMenu=function(e){s.toggleMenu(!0,e)},s.closeMenu=function(e){s.toggleMenu(!1,e)},s.updateStatus=a(function(){if(s._isMounted){var e=s.getState(),t=s.getItemFromIndex(e.highlightedIndex)||{},o=s.items.length,r=s.props.getA11yStatusMessage(w({itemToString:s.props.itemToString,previousResultCount:s.previousResultCount,resultCount:o,highlightedItem:t},e));s.previousResultCount=o,n(r)}},200),s.id=p("downshift"),s.state={highlightedIndex:s.props.defaultHighlightedIndex,inputValue:s.props.defaultInputValue,isOpen:s.props.defaultIsOpen,selectedItem:s.props.defaultSelectedItem},s.root_handleClick=d(s.props.onClick,s.root_handleClick),s}return b(t,e),I(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(t,n){return t[n]=e.isStateProp(n)?e.props[n]:e.state[n],t},{})}},{key:"isStateProp",value:function(e){return void 0!==this.props[e]}},{key:"maybeScrollToHighlightedElement",value:function(e){s(this.getItemNodeFromIndex(e),this._rootNode)}},{key:"internalSetState",value:function(e,t){var n=this,o={},r=void 0,u=void 0;return this.setState(function(t){t=n.getState(t);var i={},l={};return(r="function"==typeof e?e(t):e).hasOwnProperty("selectedItem")&&(o.selectedItem=r.selectedItem,o.previousItem=t.selectedItem),Object.keys(r).forEach(function(e){"type"!==e&&(l[e]=r[e],n.isStateProp(e)||(i[e]=r[e]))}),u=!f(t,l),i},function(){i(t)(),u&&n.props.onStateChange(r),Object.keys(o).length&&n.props.onChange(o)})}},{key:"getControllerStateAndHelpers",value:function(){var e=this.getState(),t=e.highlightedIndex,n=e.inputValue,o=e.selectedItem,r=e.isOpen;return{getRootProps:this.getRootProps,getButtonProps:this.getButtonProps,getLabelProps:this.getLabelProps,getInputProps:this.getInputProps,getItemProps:this.getItemProps,openMenu:this.openMenu,closeMenu:this.closeMenu,toggleMenu:this.toggleMenu,selectItem:this.selectItem,selectItemAtIndex:this.selectItemAtIndex,selectHighlightedItem:this.selectHighlightedItem,setHighlightedIndex:this.setHighlightedIndex,clearSelection:this.clearSelection,highlightedIndex:t,inputValue:n,isOpen:r,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.reset(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.isStateProp("selectedItem")&&this.props.selectedItem!==e.selectedItem&&this.internalSetState({inputValue:this.props.itemToString(this.props.selectedItem)}),this.updateStatus()}},{key:"componentWillUnmount",value:function(){this.cleanup()}},{key:"render",value:function(){var e=this.props.children;this.items=[],this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;var t=e&&e(this.getControllerStateAndHelpers());if(!t)return null;var n=m.Children.only(t);if(this.getRootProps.called)return g(n,this.getRootProps),n;if("string"==typeof n.type)return m.cloneElement(n,this.getRootProps(n.props));throw new Error("downshift: If you return a non-DOM element, you must use apply the getRootProps function")}}]),t}(e.PureComponent);return 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,onClick:t.func,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,r=e.resultCount,i=e.previousResultCount,u=e.itemToString;if(!t)return o?u(o):"";var l=r!==i;return r?!n||l?r+" "+(1===r?"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(){},onChange:function(){}},H.stateChangeTypes={mouseUp:"__autocomplete_mouseup__"},H});
//# sourceMappingURL=downshift.umd.min.js.map
{
"name": "downshift",
"version": "1.0.0-rc.1",
"version": "1.0.0-rc.2",
"description": "A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete components",

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

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