Socket
Socket
Sign inDemoInstall

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.9 to 1.0.0-rc.10

83

dist/downshift.cjs.js

@@ -356,19 +356,41 @@ 'use strict';

/**
* preact treats all children as arrays and React doesn't
* this is for compatibility. Children could also be undefined/null
* @param {*} children the children prop
* @return {Function} a function which should be called to get what to render
* Takes an argument and if it's an array, returns the first item in the array
* otherwise returns the argument
* @param {*} arg the maybe-array
* @param {*} defaultValue the value if arg is falsey not defined
* @return {*} the arg or it's first item
*/
function getChildrenFn(children) {
if (!children) {
return noop;
} else if (typeof children === 'function') {
return children;
} else if (typeof children[0] === 'function') {
return children[0];
function unwrapArray(arg, defaultValue) {
arg = Array.isArray(arg) ? /* istanbul ignore next (preact) */arg[0] : arg;
if (!arg && defaultValue) {
return defaultValue;
} else {
return noop;
return arg;
}
}
/**
* @param {Object} element (P)react element
* @return {Boolean} whether it's a DOM element
*/
function isDOMElement(element) {
/* istanbul ignore if */
if (element.nodeName) {
// then this is preact
return typeof element.nodeName === 'string';
} else {
// then we assume this is react
return typeof element.type === 'string';
}
}
/**
* @param {Object} element (P)react element
* @return {Object} the props
*/
function getElementProps(element) {
// props for react, attributes for preact
return element.props || /* istanbul ignore next (preact) */element.attributes;
}
/* eslint camelcase:0 */

@@ -664,3 +686,3 @@

value: function render() {
var children = getChildrenFn(this.props.children);
var children = unwrapArray(this.props.children, noop);
// because the items are rerendered every time we call the children

@@ -679,15 +701,13 @@ // we clear this out each render and

this.getInputProps.called = false;
var uiDescriptor = children(this.getControllerStateAndHelpers());
if (!uiDescriptor) {
var element = unwrapArray(children(this.getControllerStateAndHelpers()));
if (!element) {
return null;
}
// doing React.Children.only for Preact support ⚛️
var element = React__default.Children.only(uiDescriptor);
if (this.getRootProps.called) {
validateGetRootPropsCalledCorrectly(element, this.getRootProps);
return element;
} else if (typeof element.type === 'string') {
} else if (isDOMElement(element)) {
// they didn't apply the root props, but we can clone
// this and apply the props ourselves
return React__default.cloneElement(element, this.getRootProps(element.props));
return React__default.cloneElement(element, this.getRootProps(getElementProps(element)));
} else {

@@ -934,8 +954,11 @@ // they didn't apply the root props, but they need to

this.getInputProps = function () {
var _babelHelpers$extends2;
var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var onChange = _ref5.onChange,
onKeyDown = _ref5.onKeyDown,
var onKeyDown = _ref5.onKeyDown,
onBlur = _ref5.onBlur,
rest = objectWithoutProperties(_ref5, ['onChange', 'onKeyDown', 'onBlur']);
onChange = _ref5.onChange,
onInput = _ref5.onInput,
rest = objectWithoutProperties(_ref5, ['onKeyDown', 'onBlur', 'onChange', 'onInput']);

@@ -947,2 +970,3 @@ _this5.getInputProps.called = true;

_this5.inputId = firstDefined(_this5.inputId, rest.id, generateId('downshift-input'));
var onChangeKey = 'onChange';

@@ -954,3 +978,3 @@ var _getState4 = _this5.getState(),

return _extends({
return _extends((_babelHelpers$extends2 = {
role: 'combobox',

@@ -961,7 +985,4 @@ 'aria-autocomplete': 'list',

autoComplete: 'off',
value: inputValue,
onChange: composeEventHandlers(onChange, _this5.input_handleChange),
onKeyDown: composeEventHandlers(onKeyDown, _this5.input_handleKeyDown),
onBlur: composeEventHandlers(onBlur, _this5.input_handleBlur)
}, rest, {
value: inputValue
}, defineProperty(_babelHelpers$extends2, onChangeKey, composeEventHandlers(onChange, onInput, _this5.input_handleChange)), defineProperty(_babelHelpers$extends2, 'onKeyDown', composeEventHandlers(onKeyDown, _this5.input_handleKeyDown)), defineProperty(_babelHelpers$extends2, 'onBlur', composeEventHandlers(onBlur, _this5.input_handleBlur)), _babelHelpers$extends2), rest, {
id: _this5.inputId

@@ -1066,3 +1087,3 @@ });

var refKeySpecified = refKey !== 'ref';
var isComposite = typeof element.type !== 'string';
var isComposite = !isDOMElement(element);
if (isComposite && !refKeySpecified) {

@@ -1073,6 +1094,6 @@ throw new Error('downshift: You returned a non-DOM element. You must specify a refKey in getRootProps');

}
if (!element.props.hasOwnProperty(refKey)) {
if (!getElementProps(element).hasOwnProperty(refKey)) {
throw new Error('downshift: You must apply the ref prop "' + refKey + '" from getRootProps onto your root element.');
}
if (!element.props.hasOwnProperty('onClick')) {
if (!getElementProps(element).hasOwnProperty('onClick')) {
throw new Error('downshift: You must apply the "onClick" prop from getRootProps onto your root element.');

@@ -1079,0 +1100,0 @@ }

@@ -351,19 +351,41 @@ import React, { Component } from 'react';

/**
* preact treats all children as arrays and React doesn't
* this is for compatibility. Children could also be undefined/null
* @param {*} children the children prop
* @return {Function} a function which should be called to get what to render
* Takes an argument and if it's an array, returns the first item in the array
* otherwise returns the argument
* @param {*} arg the maybe-array
* @param {*} defaultValue the value if arg is falsey not defined
* @return {*} the arg or it's first item
*/
function getChildrenFn(children) {
if (!children) {
return noop;
} else if (typeof children === 'function') {
return children;
} else if (typeof children[0] === 'function') {
return children[0];
function unwrapArray(arg, defaultValue) {
arg = Array.isArray(arg) ? /* istanbul ignore next (preact) */arg[0] : arg;
if (!arg && defaultValue) {
return defaultValue;
} else {
return noop;
return arg;
}
}
/**
* @param {Object} element (P)react element
* @return {Boolean} whether it's a DOM element
*/
function isDOMElement(element) {
/* istanbul ignore if */
if (element.nodeName) {
// then this is preact
return typeof element.nodeName === 'string';
} else {
// then we assume this is react
return typeof element.type === 'string';
}
}
/**
* @param {Object} element (P)react element
* @return {Object} the props
*/
function getElementProps(element) {
// props for react, attributes for preact
return element.props || /* istanbul ignore next (preact) */element.attributes;
}
/* eslint camelcase:0 */

@@ -659,3 +681,3 @@

value: function render() {
var children = getChildrenFn(this.props.children);
var children = unwrapArray(this.props.children, noop);
// because the items are rerendered every time we call the children

@@ -674,15 +696,13 @@ // we clear this out each render and

this.getInputProps.called = false;
var uiDescriptor = children(this.getControllerStateAndHelpers());
if (!uiDescriptor) {
var element = unwrapArray(children(this.getControllerStateAndHelpers()));
if (!element) {
return null;
}
// doing React.Children.only for Preact support ⚛️
var element = React.Children.only(uiDescriptor);
if (this.getRootProps.called) {
validateGetRootPropsCalledCorrectly(element, this.getRootProps);
return element;
} else if (typeof element.type === 'string') {
} else if (isDOMElement(element)) {
// they didn't apply the root props, but we can clone
// this and apply the props ourselves
return React.cloneElement(element, this.getRootProps(element.props));
return React.cloneElement(element, this.getRootProps(getElementProps(element)));
} else {

@@ -929,8 +949,11 @@ // they didn't apply the root props, but they need to

this.getInputProps = function () {
var _babelHelpers$extends2;
var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var onChange = _ref5.onChange,
onKeyDown = _ref5.onKeyDown,
var onKeyDown = _ref5.onKeyDown,
onBlur = _ref5.onBlur,
rest = objectWithoutProperties(_ref5, ['onChange', 'onKeyDown', 'onBlur']);
onChange = _ref5.onChange,
onInput = _ref5.onInput,
rest = objectWithoutProperties(_ref5, ['onKeyDown', 'onBlur', 'onChange', 'onInput']);

@@ -942,2 +965,3 @@ _this5.getInputProps.called = true;

_this5.inputId = firstDefined(_this5.inputId, rest.id, generateId('downshift-input'));
var onChangeKey = 'onChange';

@@ -949,3 +973,3 @@ var _getState4 = _this5.getState(),

return _extends({
return _extends((_babelHelpers$extends2 = {
role: 'combobox',

@@ -956,7 +980,4 @@ 'aria-autocomplete': 'list',

autoComplete: 'off',
value: inputValue,
onChange: composeEventHandlers(onChange, _this5.input_handleChange),
onKeyDown: composeEventHandlers(onKeyDown, _this5.input_handleKeyDown),
onBlur: composeEventHandlers(onBlur, _this5.input_handleBlur)
}, rest, {
value: inputValue
}, defineProperty(_babelHelpers$extends2, onChangeKey, composeEventHandlers(onChange, onInput, _this5.input_handleChange)), defineProperty(_babelHelpers$extends2, 'onKeyDown', composeEventHandlers(onKeyDown, _this5.input_handleKeyDown)), defineProperty(_babelHelpers$extends2, 'onBlur', composeEventHandlers(onBlur, _this5.input_handleBlur)), _babelHelpers$extends2), rest, {
id: _this5.inputId

@@ -1061,3 +1082,3 @@ });

var refKeySpecified = refKey !== 'ref';
var isComposite = typeof element.type !== 'string';
var isComposite = !isDOMElement(element);
if (isComposite && !refKeySpecified) {

@@ -1068,6 +1089,6 @@ throw new Error('downshift: You returned a non-DOM element. You must specify a refKey in getRootProps');

}
if (!element.props.hasOwnProperty(refKey)) {
if (!getElementProps(element).hasOwnProperty(refKey)) {
throw new Error('downshift: You must apply the ref prop "' + refKey + '" from getRootProps onto your root element.');
}
if (!element.props.hasOwnProperty('onClick')) {
if (!getElementProps(element).hasOwnProperty('onClick')) {
throw new Error('downshift: You must apply the "onClick" prop from getRootProps onto your root element.');

@@ -1074,0 +1095,0 @@ }

'use strict';
var preact = require('preact');
var preact__default = preact['default'];
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
/*
* This file is here to make downshift compatible with
* preact without requiring you to include all of preact-compat
*/
preact__default.Children = {
only: function only(children) {
return children && children[0];
}
};
var React = require('preact');
var React__default = _interopDefault(React);
/*
* This file is here for preact compatibility
* so you don't have to ship prop types to preact.
* This makes the assumption that you are trading
* off a little nicer developer experience in favor
* of a smaller build.
*/
function proptype() {}
proptype.isRequired = proptype;
var PropTypes = {
element: proptype,
func: proptype,
number: proptype,
any: proptype,
bool: proptype,
string: proptype
};
var classCallCheck = function (instance, Constructor) {

@@ -382,19 +355,41 @@ if (!(instance instanceof Constructor)) {

/**
* preact treats all children as arrays and React doesn't
* this is for compatibility. Children could also be undefined/null
* @param {*} children the children prop
* @return {Function} a function which should be called to get what to render
* Takes an argument and if it's an array, returns the first item in the array
* otherwise returns the argument
* @param {*} arg the maybe-array
* @param {*} defaultValue the value if arg is falsey not defined
* @return {*} the arg or it's first item
*/
function getChildrenFn(children) {
if (!children) {
return noop;
} else if (typeof children === 'function') {
return children;
} else if (typeof children[0] === 'function') {
return children[0];
function unwrapArray(arg, defaultValue) {
arg = Array.isArray(arg) ? /* istanbul ignore next (preact) */arg[0] : arg;
if (!arg && defaultValue) {
return defaultValue;
} else {
return noop;
return arg;
}
}
/**
* @param {Object} element (P)react element
* @return {Boolean} whether it's a DOM element
*/
function isDOMElement(element) {
/* istanbul ignore if */
if (element.nodeName) {
// then this is preact
return typeof element.nodeName === 'string';
} else {
// then we assume this is react
return typeof element.type === 'string';
}
}
/**
* @param {Object} element (P)react element
* @return {Object} the props
*/
function getElementProps(element) {
// props for react, attributes for preact
return element.props || /* istanbul ignore next (preact) */element.attributes;
}
/* eslint camelcase:0 */

@@ -690,3 +685,3 @@

value: function render() {
var children = getChildrenFn(this.props.children);
var children = unwrapArray(this.props.children, noop);
// because the items are rerendered every time we call the children

@@ -705,15 +700,13 @@ // we clear this out each render and

this.getInputProps.called = false;
var uiDescriptor = children(this.getControllerStateAndHelpers());
if (!uiDescriptor) {
var element = unwrapArray(children(this.getControllerStateAndHelpers()));
if (!element) {
return null;
}
// doing React.Children.only for Preact support ⚛️
var element = preact__default.Children.only(uiDescriptor);
if (this.getRootProps.called) {
validateGetRootPropsCalledCorrectly(element, this.getRootProps);
return element;
} else if (typeof element.type === 'string') {
} else if (isDOMElement(element)) {
// they didn't apply the root props, but we can clone
// this and apply the props ourselves
return preact__default.cloneElement(element, this.getRootProps(element.props));
return React__default.cloneElement(element, this.getRootProps(getElementProps(element)));
} else {

@@ -727,25 +720,4 @@ // they didn't apply the root props, but they need to

return Downshift;
}(preact.Component);
}(React.Component);
Downshift$1.propTypes = {
children: PropTypes.func,
defaultHighlightedIndex: PropTypes.number,
defaultSelectedItem: PropTypes.any,
defaultInputValue: PropTypes.string,
defaultIsOpen: PropTypes.bool,
getA11yStatusMessage: PropTypes.func,
itemToString: PropTypes.func,
onChange: PropTypes.func,
onStateChange: PropTypes.func,
onClick: PropTypes.func,
itemCount: PropTypes.number,
// things we keep in state for uncontrolled components
// but can accept as props for controlled components
/* eslint-disable react/no-unused-prop-types */
selectedItem: PropTypes.any,
isOpen: PropTypes.bool,
inputValue: PropTypes.string,
highlightedIndex: PropTypes.number
/* eslint-enable */
};
Downshift$1.defaultProps = {

@@ -961,8 +933,11 @@ defaultHighlightedIndex: null,

this.getInputProps = function () {
var _babelHelpers$extends2;
var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var onChange = _ref5.onChange,
onKeyDown = _ref5.onKeyDown,
var onKeyDown = _ref5.onKeyDown,
onBlur = _ref5.onBlur,
rest = objectWithoutProperties(_ref5, ['onChange', 'onKeyDown', 'onBlur']);
onChange = _ref5.onChange,
onInput = _ref5.onInput,
rest = objectWithoutProperties(_ref5, ['onKeyDown', 'onBlur', 'onChange', 'onInput']);

@@ -974,2 +949,3 @@ _this5.getInputProps.called = true;

_this5.inputId = firstDefined(_this5.inputId, rest.id, generateId('downshift-input'));
var onChangeKey = 'onInput';

@@ -981,3 +957,3 @@ var _getState4 = _this5.getState(),

return _extends({
return _extends((_babelHelpers$extends2 = {
role: 'combobox',

@@ -988,7 +964,4 @@ 'aria-autocomplete': 'list',

autoComplete: 'off',
value: inputValue,
onChange: composeEventHandlers(onChange, _this5.input_handleChange),
onKeyDown: composeEventHandlers(onKeyDown, _this5.input_handleKeyDown),
onBlur: composeEventHandlers(onBlur, _this5.input_handleBlur)
}, rest, {
value: inputValue
}, defineProperty(_babelHelpers$extends2, onChangeKey, composeEventHandlers(onChange, onInput, _this5.input_handleChange)), defineProperty(_babelHelpers$extends2, 'onKeyDown', composeEventHandlers(onKeyDown, _this5.input_handleKeyDown)), defineProperty(_babelHelpers$extends2, 'onBlur', composeEventHandlers(onBlur, _this5.input_handleBlur)), _babelHelpers$extends2), rest, {
id: _this5.inputId

@@ -1093,3 +1066,3 @@ });

var refKeySpecified = refKey !== 'ref';
var isComposite = typeof element.type !== 'string';
var isComposite = !isDOMElement(element);
if (isComposite && !refKeySpecified) {

@@ -1100,6 +1073,6 @@ throw new Error('downshift: You returned a non-DOM element. You must specify a refKey in getRootProps');

}
if (!element.props.hasOwnProperty(refKey)) {
if (!getElementProps(element).hasOwnProperty(refKey)) {
throw new Error('downshift: You must apply the ref prop "' + refKey + '" from getRootProps onto your root element.');
}
if (!element.props.hasOwnProperty('onClick')) {
if (!getElementProps(element).hasOwnProperty('onClick')) {
throw new Error('downshift: You must apply the "onClick" prop from getRootProps onto your root element.');

@@ -1106,0 +1079,0 @@ }

@@ -1,34 +0,3 @@

import { Component } from 'preact';
import preact__default from 'preact';
import * as preact from 'preact';
import React, { Component } from 'preact';
/*
* This file is here to make downshift compatible with
* preact without requiring you to include all of preact-compat
*/
preact__default.Children = {
only: function only(children) {
return children && children[0];
}
};
/*
* This file is here for preact compatibility
* so you don't have to ship prop types to preact.
* This makes the assumption that you are trading
* off a little nicer developer experience in favor
* of a smaller build.
*/
function proptype() {}
proptype.isRequired = proptype;
var PropTypes = {
element: proptype,
func: proptype,
number: proptype,
any: proptype,
bool: proptype,
string: proptype
};
var classCallCheck = function (instance, Constructor) {

@@ -381,19 +350,41 @@ if (!(instance instanceof Constructor)) {

/**
* preact treats all children as arrays and React doesn't
* this is for compatibility. Children could also be undefined/null
* @param {*} children the children prop
* @return {Function} a function which should be called to get what to render
* Takes an argument and if it's an array, returns the first item in the array
* otherwise returns the argument
* @param {*} arg the maybe-array
* @param {*} defaultValue the value if arg is falsey not defined
* @return {*} the arg or it's first item
*/
function getChildrenFn(children) {
if (!children) {
return noop;
} else if (typeof children === 'function') {
return children;
} else if (typeof children[0] === 'function') {
return children[0];
function unwrapArray(arg, defaultValue) {
arg = Array.isArray(arg) ? /* istanbul ignore next (preact) */arg[0] : arg;
if (!arg && defaultValue) {
return defaultValue;
} else {
return noop;
return arg;
}
}
/**
* @param {Object} element (P)react element
* @return {Boolean} whether it's a DOM element
*/
function isDOMElement(element) {
/* istanbul ignore if */
if (element.nodeName) {
// then this is preact
return typeof element.nodeName === 'string';
} else {
// then we assume this is react
return typeof element.type === 'string';
}
}
/**
* @param {Object} element (P)react element
* @return {Object} the props
*/
function getElementProps(element) {
// props for react, attributes for preact
return element.props || /* istanbul ignore next (preact) */element.attributes;
}
/* eslint camelcase:0 */

@@ -689,3 +680,3 @@

value: function render() {
var children = getChildrenFn(this.props.children);
var children = unwrapArray(this.props.children, noop);
// because the items are rerendered every time we call the children

@@ -704,15 +695,13 @@ // we clear this out each render and

this.getInputProps.called = false;
var uiDescriptor = children(this.getControllerStateAndHelpers());
if (!uiDescriptor) {
var element = unwrapArray(children(this.getControllerStateAndHelpers()));
if (!element) {
return null;
}
// doing React.Children.only for Preact support ⚛️
var element = preact__default.Children.only(uiDescriptor);
if (this.getRootProps.called) {
validateGetRootPropsCalledCorrectly(element, this.getRootProps);
return element;
} else if (typeof element.type === 'string') {
} else if (isDOMElement(element)) {
// they didn't apply the root props, but we can clone
// this and apply the props ourselves
return preact__default.cloneElement(element, this.getRootProps(element.props));
return React.cloneElement(element, this.getRootProps(getElementProps(element)));
} else {

@@ -728,23 +717,2 @@ // they didn't apply the root props, but they need to

Downshift$1.propTypes = {
children: PropTypes.func,
defaultHighlightedIndex: PropTypes.number,
defaultSelectedItem: PropTypes.any,
defaultInputValue: PropTypes.string,
defaultIsOpen: PropTypes.bool,
getA11yStatusMessage: PropTypes.func,
itemToString: PropTypes.func,
onChange: PropTypes.func,
onStateChange: PropTypes.func,
onClick: PropTypes.func,
itemCount: PropTypes.number,
// things we keep in state for uncontrolled components
// but can accept as props for controlled components
/* eslint-disable react/no-unused-prop-types */
selectedItem: PropTypes.any,
isOpen: PropTypes.bool,
inputValue: PropTypes.string,
highlightedIndex: PropTypes.number
/* eslint-enable */
};
Downshift$1.defaultProps = {

@@ -960,8 +928,11 @@ defaultHighlightedIndex: null,

this.getInputProps = function () {
var _babelHelpers$extends2;
var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var onChange = _ref5.onChange,
onKeyDown = _ref5.onKeyDown,
var onKeyDown = _ref5.onKeyDown,
onBlur = _ref5.onBlur,
rest = objectWithoutProperties(_ref5, ['onChange', 'onKeyDown', 'onBlur']);
onChange = _ref5.onChange,
onInput = _ref5.onInput,
rest = objectWithoutProperties(_ref5, ['onKeyDown', 'onBlur', 'onChange', 'onInput']);

@@ -973,2 +944,3 @@ _this5.getInputProps.called = true;

_this5.inputId = firstDefined(_this5.inputId, rest.id, generateId('downshift-input'));
var onChangeKey = 'onInput';

@@ -980,3 +952,3 @@ var _getState4 = _this5.getState(),

return _extends({
return _extends((_babelHelpers$extends2 = {
role: 'combobox',

@@ -987,7 +959,4 @@ 'aria-autocomplete': 'list',

autoComplete: 'off',
value: inputValue,
onChange: composeEventHandlers(onChange, _this5.input_handleChange),
onKeyDown: composeEventHandlers(onKeyDown, _this5.input_handleKeyDown),
onBlur: composeEventHandlers(onBlur, _this5.input_handleBlur)
}, rest, {
value: inputValue
}, defineProperty(_babelHelpers$extends2, onChangeKey, composeEventHandlers(onChange, onInput, _this5.input_handleChange)), defineProperty(_babelHelpers$extends2, 'onKeyDown', composeEventHandlers(onKeyDown, _this5.input_handleKeyDown)), defineProperty(_babelHelpers$extends2, 'onBlur', composeEventHandlers(onBlur, _this5.input_handleBlur)), _babelHelpers$extends2), rest, {
id: _this5.inputId

@@ -1092,3 +1061,3 @@ });

var refKeySpecified = refKey !== 'ref';
var isComposite = typeof element.type !== 'string';
var isComposite = !isDOMElement(element);
if (isComposite && !refKeySpecified) {

@@ -1099,6 +1068,6 @@ throw new Error('downshift: You returned a non-DOM element. You must specify a refKey in getRootProps');

}
if (!element.props.hasOwnProperty(refKey)) {
if (!getElementProps(element).hasOwnProperty(refKey)) {
throw new Error('downshift: You must apply the ref prop "' + refKey + '" from getRootProps onto your root element.');
}
if (!element.props.hasOwnProperty('onClick')) {
if (!getElementProps(element).hasOwnProperty('onClick')) {
throw new Error('downshift: You must apply the "onClick" prop from getRootProps onto your root element.');

@@ -1105,0 +1074,0 @@ }

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
typeof define === 'function' && define.amd ? define(['preact'], factory) :
(global.Downshift = factory(global.preact));
}(this, (function (preact) { 'use strict';
(global.Downshift = factory(global.React));
}(this, (function (React) { 'use strict';
var preact__default = preact['default'];
var React__default = 'default' in React ? React['default'] : React;
/*
* This file is here to make downshift compatible with
* preact without requiring you to include all of preact-compat
*/
preact__default.Children = {
only: function only(children) {
return children && children[0];
}
};
/*
* This file is here for preact compatibility
* so you don't have to ship prop types to preact.
* This makes the assumption that you are trading
* off a little nicer developer experience in favor
* of a smaller build.
*/
function proptype() {}
proptype.isRequired = proptype;
var PropTypes = {
element: proptype,
func: proptype,
number: proptype,
any: proptype,
bool: proptype,
string: proptype
};
var classCallCheck = function (instance, Constructor) {

@@ -385,19 +356,41 @@ if (!(instance instanceof Constructor)) {

/**
* preact treats all children as arrays and React doesn't
* this is for compatibility. Children could also be undefined/null
* @param {*} children the children prop
* @return {Function} a function which should be called to get what to render
* Takes an argument and if it's an array, returns the first item in the array
* otherwise returns the argument
* @param {*} arg the maybe-array
* @param {*} defaultValue the value if arg is falsey not defined
* @return {*} the arg or it's first item
*/
function getChildrenFn(children) {
if (!children) {
return noop;
} else if (typeof children === 'function') {
return children;
} else if (typeof children[0] === 'function') {
return children[0];
function unwrapArray(arg, defaultValue) {
arg = Array.isArray(arg) ? /* istanbul ignore next (preact) */arg[0] : arg;
if (!arg && defaultValue) {
return defaultValue;
} else {
return noop;
return arg;
}
}
/**
* @param {Object} element (P)react element
* @return {Boolean} whether it's a DOM element
*/
function isDOMElement(element) {
/* istanbul ignore if */
if (element.nodeName) {
// then this is preact
return typeof element.nodeName === 'string';
} else {
// then we assume this is react
return typeof element.type === 'string';
}
}
/**
* @param {Object} element (P)react element
* @return {Object} the props
*/
function getElementProps(element) {
// props for react, attributes for preact
return element.props || /* istanbul ignore next (preact) */element.attributes;
}
/* eslint camelcase:0 */

@@ -693,3 +686,3 @@

value: function render() {
var children = getChildrenFn(this.props.children);
var children = unwrapArray(this.props.children, noop);
// because the items are rerendered every time we call the children

@@ -708,15 +701,13 @@ // we clear this out each render and

this.getInputProps.called = false;
var uiDescriptor = children(this.getControllerStateAndHelpers());
if (!uiDescriptor) {
var element = unwrapArray(children(this.getControllerStateAndHelpers()));
if (!element) {
return null;
}
// doing React.Children.only for Preact support ⚛️
var element = preact__default.Children.only(uiDescriptor);
if (this.getRootProps.called) {
validateGetRootPropsCalledCorrectly(element, this.getRootProps);
return element;
} else if (typeof element.type === 'string') {
} else if (isDOMElement(element)) {
// they didn't apply the root props, but we can clone
// this and apply the props ourselves
return preact__default.cloneElement(element, this.getRootProps(element.props));
return React__default.cloneElement(element, this.getRootProps(getElementProps(element)));
} else {

@@ -730,25 +721,4 @@ // they didn't apply the root props, but they need to

return Downshift;
}(preact.Component);
}(React.Component);
Downshift$1.propTypes = {
children: PropTypes.func,
defaultHighlightedIndex: PropTypes.number,
defaultSelectedItem: PropTypes.any,
defaultInputValue: PropTypes.string,
defaultIsOpen: PropTypes.bool,
getA11yStatusMessage: PropTypes.func,
itemToString: PropTypes.func,
onChange: PropTypes.func,
onStateChange: PropTypes.func,
onClick: PropTypes.func,
itemCount: PropTypes.number,
// things we keep in state for uncontrolled components
// but can accept as props for controlled components
/* eslint-disable react/no-unused-prop-types */
selectedItem: PropTypes.any,
isOpen: PropTypes.bool,
inputValue: PropTypes.string,
highlightedIndex: PropTypes.number
/* eslint-enable */
};
Downshift$1.defaultProps = {

@@ -964,8 +934,11 @@ defaultHighlightedIndex: null,

this.getInputProps = function () {
var _babelHelpers$extends2;
var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var onChange = _ref5.onChange,
onKeyDown = _ref5.onKeyDown,
var onKeyDown = _ref5.onKeyDown,
onBlur = _ref5.onBlur,
rest = objectWithoutProperties(_ref5, ['onChange', 'onKeyDown', 'onBlur']);
onChange = _ref5.onChange,
onInput = _ref5.onInput,
rest = objectWithoutProperties(_ref5, ['onKeyDown', 'onBlur', 'onChange', 'onInput']);

@@ -977,2 +950,3 @@ _this5.getInputProps.called = true;

_this5.inputId = firstDefined(_this5.inputId, rest.id, generateId('downshift-input'));
var onChangeKey = 'onInput';

@@ -984,3 +958,3 @@ var _getState4 = _this5.getState(),

return _extends({
return _extends((_babelHelpers$extends2 = {
role: 'combobox',

@@ -991,7 +965,4 @@ 'aria-autocomplete': 'list',

autoComplete: 'off',
value: inputValue,
onChange: composeEventHandlers(onChange, _this5.input_handleChange),
onKeyDown: composeEventHandlers(onKeyDown, _this5.input_handleKeyDown),
onBlur: composeEventHandlers(onBlur, _this5.input_handleBlur)
}, rest, {
value: inputValue
}, defineProperty(_babelHelpers$extends2, onChangeKey, composeEventHandlers(onChange, onInput, _this5.input_handleChange)), defineProperty(_babelHelpers$extends2, 'onKeyDown', composeEventHandlers(onKeyDown, _this5.input_handleKeyDown)), defineProperty(_babelHelpers$extends2, 'onBlur', composeEventHandlers(onBlur, _this5.input_handleBlur)), _babelHelpers$extends2), rest, {
id: _this5.inputId

@@ -1096,3 +1067,3 @@ });

var refKeySpecified = refKey !== 'ref';
var isComposite = typeof element.type !== 'string';
var isComposite = !isDOMElement(element);
if (isComposite && !refKeySpecified) {

@@ -1103,6 +1074,6 @@ throw new Error('downshift: You returned a non-DOM element. You must specify a refKey in getRootProps');

}
if (!element.props.hasOwnProperty(refKey)) {
if (!getElementProps(element).hasOwnProperty(refKey)) {
throw new Error('downshift: You must apply the ref prop "' + refKey + '" from getRootProps onto your root element.');
}
if (!element.props.hasOwnProperty('onClick')) {
if (!getElementProps(element).hasOwnProperty('onClick')) {
throw new Error('downshift: You must apply the "onClick" prop from getRootProps onto your root element.');

@@ -1109,0 +1080,0 @@ }

@@ -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],i().innerHTML=""+k.filter(Boolean).map(o).join("")}function o(e,t){return'<div style="display:'+(t===k.length-1?"block":"none")+';">'+e+"</div>"}function i(){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 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=D(e,t);if(null!==n){var o=getComputedStyle(n),i=n.getBoundingClientRect(),r=parseInt(o.borderTopWidth,10),u=i.top+r,l=e.getBoundingClientRect(),s=l.top+n.scrollTop-u;s<n.scrollTop?n.scrollTop=s:s+l.height>n.scrollTop+i.height&&(n.scrollTop=s+l.height-i.height)}}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 h(){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+"-"+_++}function p(){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){return e?"function"==typeof e?e:"function"==typeof e[0]?e[0]:u:u}function g(e,t){var n=t.refKey,o="ref"!==n,i="string"!=typeof e.type;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(!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},v=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}}(),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)},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,D=l.bind(null,function(e){return e.scrollHeight>e.clientHeight}),H=function(e){function t(){var e;v(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)));M.call(r),r.id=d("downshift");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.root_handleClick=h(r.props.onClick,r.root_handleClick),r}return S(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(n,o){return n[o]=e.isStateProp(o)?e.props[o]:t[o],n},{})}},{key:"isStateProp",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,t){var n=this,o=void 0,i={};return this.setState(function(t){t=n.getState(t);var r={},u={};return(e="function"==typeof e?e(t):e).hasOwnProperty("selectedItem")&&(o=e.selectedItem),Object.keys(e).forEach(function(o){"type"!==o&&(t[o]!==e[o]&&(i[o]=e[o]),u[o]=e[o],n.isStateProp(o)||(r[o]=e[o]))}),r},function(){r(t)(),Object.keys(i).length&&n.props.onStateChange(i,n.getState()),void 0!==o&&n.props.onChange(o,n.getState())})}},{key:"getControllerStateAndHelpers",value:function(){var e=this.getState(),t=e.highlightedIndex,n=e.inputValue,o=e.selectedItem,i=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: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(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=f(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(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);H.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,itemCount:y.number,selectedItem:y.any,isOpen:y.bool,inputValue:y.string,highlightedIndex:y.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(){},onChange:function(){}},H.stateChangeTypes={mouseUp:"__autocomplete_mouseup__"};var M=function(){var e=this;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;e.internalSetState({highlightedIndex:t},function(){s(e.getItemNodeFromIndex(e.getState().highlightedIndex),e._rootNode)})},this.highlightIndex=function(t){e.openMenu(function(){e.setHighlightedIndex(t)})},this.moveHighlightedIndex=function(t){e.getState().isOpen?e.changeHighlighedIndex(t):e.highlightIndex()},this.changeHighlighedIndex=function(t){var n=e.getItemCount()-1;if(!(n<0)){var o=e.getState().highlightedIndex;null===o&&(o=t>0?-1:n+1);var i=o+t;i<0?i=n:i>n&&(i=0),e.setHighlightedIndex(i)}},this.clearSelection=function(){e.internalSetState({selectedItem:null,inputValue:"",isOpen:!1},function(){var t=e._rootNode.querySelector("#"+e.inputId);t&&t.focus&&t.focus()})},this.selectItem=function(t){e.internalSetState({isOpen:!1,highlightedIndex:null,selectedItem:t,inputValue:e.props.itemToString(t)})},this.selectItemAtIndex=function(t){var n=e.items[t];n&&e.selectItem(n)},this.selectHighlightedItem=function(){return e.selectItemAtIndex(e.getState().highlightedIndex)},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=x(n,["refKey","onClick"]);return e.getRootProps.called=!0,e.getRootProps.refKey=i,b((t={},w(t,i,e.rootRef),w(t,"onClick",h(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)},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()}},this.buttonKeyDownHandlers=b({},this.keyDownHandlers,{" ":function(e){e.preventDefault(),this.toggleMenu()}}),this.getButtonProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onClick,o=t.onKeyDown,i=x(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:h(n,e.button_handleClick),onKeyDown:h(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()},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=p(e.inputId,t.htmlFor,d("downshift-input")),b({},t,{htmlFor:e.inputId})},this.getInputProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onChange,o=t.onKeyDown,i=t.onBlur,r=x(t,["onChange","onKeyDown","onBlur"]);if(e.getInputProps.called=!0,e.getLabelProps.called&&r.id&&r.id!==e.inputId)throw new Error('downshift: You provided the id of "'+r.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=p(e.inputId,r.id,d("downshift-input"));var u=e.getState(),l=u.inputValue,s=u.isOpen,a=u.highlightedIndex;return b({role:"combobox","aria-autocomplete":"list","aria-expanded":s,"aria-activedescendant":"number"==typeof a&&a>=0?e.getItemId(a):null,autoComplete:"off",value:l,onChange:h(n,e.input_handleChange),onKeyDown:h(o,e.input_handleKeyDown),onBlur:h(i,e.input_handleBlur)},r,{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({isOpen:!0,inputValue:t.target.value})},this.input_handleBlur=function(){e.isMouseDown||e.reset()},this.getItemProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onMouseEnter,o=t.item,i=t.index,r=x(t,["onMouseEnter","item","index"]);return e.items[i]=o,b({id:e.getItemId(i),onMouseEnter:h(n,function(){e.setHighlightedIndex(i)})},r)},this.reset=function(t){e.internalSetState(function(n){var o=n.selectedItem;return{type:t,isOpen:!1,highlightedIndex:null,inputValue:e.props.itemToString(o)}})},this.toggleMenu=function(t,n){e.internalSetState(function(e){var n=!e.isOpen;return"boolean"==typeof t&&(n=t),{isOpen:n}},function(){e.getState().isOpen&&e.setHighlightedIndex(),r(n)()})},this.openMenu=function(t){e.toggleMenu(!0,t)},this.closeMenu=function(t){e.toggleMenu(!1,t)},this.updateStatus=a(function(){if(e._isMounted){var t=e.getState(),o=e.items[t.highlightedIndex]||{},i=e.getItemCount(),r=e.props.getA11yStatusMessage(b({itemToString:e.props.itemToString,previousResultCount:e.previousResultCount,resultCount:i,highlightedItem:o},t));e.previousResultCount=i,n(r)}},200)};return H});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("preact")):"function"==typeof define&&define.amd?define(["preact"],t):e.Downshift=t(e.React)}(this,function(e){"use strict";function t(e){var t=k[k.length-1]===e;k=t?[].concat(C(k),[e]):[e],o().innerHTML=""+k.filter(Boolean).map(n).join("")}function n(e,t){return'<div style="display:'+(t===k.length-1?"block":"none")+';">'+e+"</div>"}function o(){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: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=D(e,t);if(null!==n){var o=getComputedStyle(n),i=n.getBoundingClientRect(),r=parseInt(o.borderTopWidth,10),u=i.top+r,l=e.getBoundingClientRect(),s=l.top+n.scrollTop-u;s<n.scrollTop?n.scrollTop=s:s+l.height>n.scrollTop+i.height&&(n.scrollTop=s+l.height-i.height)}}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 h(e){return e+"-"+_++}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 p(e){return e===e&&"number"==typeof e}function c(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 g(e){return e.props||e.attributes}function m(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(!g(e).hasOwnProperty(n))throw new Error('downshift: You must apply the ref prop "'+n+'" from getRootProps onto your root element.');if(!g(e).hasOwnProperty("onClick"))throw new Error('downshift: You must apply the "onClick" prop from getRootProps onto your root element.')}var y="default"in e?e.default:e,v=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}}(),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)},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,D=u.bind(null,function(e){return e.scrollHeight>e.clientHeight}),H=function(e){function t(){var e;v(this,t);for(var n=arguments.length,o=Array(n),i=0;i<n;i++)o[i]=arguments[i];var r=P(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(o)));M.call(r),r.id=h("downshift");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.root_handleClick=a(r.props.onClick,r.root_handleClick),r}return S(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(n,o){return n[o]=e.isStateProp(o)?e.props[o]:t[o],n},{})}},{key:"isStateProp",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,t){var n=this,o=void 0,r={};return this.setState(function(t){t=n.getState(t);var i={},u={};return(e="function"==typeof e?e(t):e).hasOwnProperty("selectedItem")&&(o=e.selectedItem),Object.keys(e).forEach(function(o){"type"!==o&&(t[o]!==e[o]&&(r[o]=e[o]),u[o]=e[o],n.isStateProp(o)||(i[o]=e[o]))}),i},function(){i(t)(),Object.keys(r).length&&n.props.onStateChange(r,n.getState()),void 0!==o&&n.props.onChange(o,n.getState())})}},{key:"getControllerStateAndHelpers",value:function(){var e=this.getState(),t=e.highlightedIndex,n=e.inputValue,o=e.selectedItem,i=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: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(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=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 m(t,this.getRootProps),t;if(f(t))return y.cloneElement(t,this.getRootProps(g(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 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(){},onChange:function(){}},H.stateChangeTypes={mouseUp:"__autocomplete_mouseup__"};var M=function(){var e=this;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;e.internalSetState({highlightedIndex:t},function(){l(e.getItemNodeFromIndex(e.getState().highlightedIndex),e._rootNode)})},this.highlightIndex=function(t){e.openMenu(function(){e.setHighlightedIndex(t)})},this.moveHighlightedIndex=function(t){e.getState().isOpen?e.changeHighlighedIndex(t):e.highlightIndex()},this.changeHighlighedIndex=function(t){var n=e.getItemCount()-1;if(!(n<0)){var o=e.getState().highlightedIndex;null===o&&(o=t>0?-1:n+1);var i=o+t;i<0?i=n:i>n&&(i=0),e.setHighlightedIndex(i)}},this.clearSelection=function(){e.internalSetState({selectedItem:null,inputValue:"",isOpen:!1},function(){var t=e._rootNode.querySelector("#"+e.inputId);t&&t.focus&&t.focus()})},this.selectItem=function(t){e.internalSetState({isOpen:!1,highlightedIndex:null,selectedItem:t,inputValue:e.props.itemToString(t)})},this.selectItemAtIndex=function(t){var n=e.items[t];n&&e.selectItem(n)},this.selectHighlightedItem=function(){return e.selectItemAtIndex(e.getState().highlightedIndex)},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=x(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 p(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)},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()}},this.buttonKeyDownHandlers=b({},this.keyDownHandlers,{" ":function(e){e.preventDefault(),this.toggleMenu()}}),this.getButtonProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onClick,o=t.onKeyDown,i=x(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()},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,h("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=x(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,h("downshift-input"));var s=e.getState(),p=s.inputValue,c=s.isOpen,f=s.highlightedIndex;return b((t={role:"combobox","aria-autocomplete":"list","aria-expanded":c,"aria-activedescendant":"number"==typeof f&&f>=0?e.getItemId(f):null,autoComplete:"off",value:p},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({isOpen:!0,inputValue:t.target.value})},this.input_handleBlur=function(){e.isMouseDown||e.reset()},this.getItemProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onMouseEnter,o=t.item,i=t.index,r=x(t,["onMouseEnter","item","index"]);return e.items[i]=o,b({id:e.getItemId(i),onMouseEnter:a(n,function(){e.setHighlightedIndex(i)})},r)},this.reset=function(t){e.internalSetState(function(n){var o=n.selectedItem;return{type:t,isOpen:!1,highlightedIndex:null,inputValue:e.props.itemToString(o)}})},this.toggleMenu=function(t,n){e.internalSetState(function(e){var n=!e.isOpen;return"boolean"==typeof t&&(n=t),{isOpen:n}},function(){e.getState().isOpen&&e.setHighlightedIndex(),i(n)()})},this.openMenu=function(t){e.toggleMenu(!0,t)},this.closeMenu=function(t){e.toggleMenu(!1,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 H});
//# sourceMappingURL=downshift.preact.umd.min.js.map

@@ -357,19 +357,41 @@ (function (global, factory) {

/**
* preact treats all children as arrays and React doesn't
* this is for compatibility. Children could also be undefined/null
* @param {*} children the children prop
* @return {Function} a function which should be called to get what to render
* Takes an argument and if it's an array, returns the first item in the array
* otherwise returns the argument
* @param {*} arg the maybe-array
* @param {*} defaultValue the value if arg is falsey not defined
* @return {*} the arg or it's first item
*/
function getChildrenFn(children) {
if (!children) {
return noop;
} else if (typeof children === 'function') {
return children;
} else if (typeof children[0] === 'function') {
return children[0];
function unwrapArray(arg, defaultValue) {
arg = Array.isArray(arg) ? /* istanbul ignore next (preact) */arg[0] : arg;
if (!arg && defaultValue) {
return defaultValue;
} else {
return noop;
return arg;
}
}
/**
* @param {Object} element (P)react element
* @return {Boolean} whether it's a DOM element
*/
function isDOMElement(element) {
/* istanbul ignore if */
if (element.nodeName) {
// then this is preact
return typeof element.nodeName === 'string';
} else {
// then we assume this is react
return typeof element.type === 'string';
}
}
/**
* @param {Object} element (P)react element
* @return {Object} the props
*/
function getElementProps(element) {
// props for react, attributes for preact
return element.props || /* istanbul ignore next (preact) */element.attributes;
}
/* eslint camelcase:0 */

@@ -665,3 +687,3 @@

value: function render() {
var children = getChildrenFn(this.props.children);
var children = unwrapArray(this.props.children, noop);
// because the items are rerendered every time we call the children

@@ -680,15 +702,13 @@ // we clear this out each render and

this.getInputProps.called = false;
var uiDescriptor = children(this.getControllerStateAndHelpers());
if (!uiDescriptor) {
var element = unwrapArray(children(this.getControllerStateAndHelpers()));
if (!element) {
return null;
}
// doing React.Children.only for Preact support ⚛️
var element = React__default.Children.only(uiDescriptor);
if (this.getRootProps.called) {
validateGetRootPropsCalledCorrectly(element, this.getRootProps);
return element;
} else if (typeof element.type === 'string') {
} else if (isDOMElement(element)) {
// they didn't apply the root props, but we can clone
// this and apply the props ourselves
return React__default.cloneElement(element, this.getRootProps(element.props));
return React__default.cloneElement(element, this.getRootProps(getElementProps(element)));
} else {

@@ -935,8 +955,11 @@ // they didn't apply the root props, but they need to

this.getInputProps = function () {
var _babelHelpers$extends2;
var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var onChange = _ref5.onChange,
onKeyDown = _ref5.onKeyDown,
var onKeyDown = _ref5.onKeyDown,
onBlur = _ref5.onBlur,
rest = objectWithoutProperties(_ref5, ['onChange', 'onKeyDown', 'onBlur']);
onChange = _ref5.onChange,
onInput = _ref5.onInput,
rest = objectWithoutProperties(_ref5, ['onKeyDown', 'onBlur', 'onChange', 'onInput']);

@@ -948,2 +971,3 @@ _this5.getInputProps.called = true;

_this5.inputId = firstDefined(_this5.inputId, rest.id, generateId('downshift-input'));
var onChangeKey = 'onChange';

@@ -955,3 +979,3 @@ var _getState4 = _this5.getState(),

return _extends({
return _extends((_babelHelpers$extends2 = {
role: 'combobox',

@@ -962,7 +986,4 @@ 'aria-autocomplete': 'list',

autoComplete: 'off',
value: inputValue,
onChange: composeEventHandlers(onChange, _this5.input_handleChange),
onKeyDown: composeEventHandlers(onKeyDown, _this5.input_handleKeyDown),
onBlur: composeEventHandlers(onBlur, _this5.input_handleBlur)
}, rest, {
value: inputValue
}, defineProperty(_babelHelpers$extends2, onChangeKey, composeEventHandlers(onChange, onInput, _this5.input_handleChange)), defineProperty(_babelHelpers$extends2, 'onKeyDown', composeEventHandlers(onKeyDown, _this5.input_handleKeyDown)), defineProperty(_babelHelpers$extends2, 'onBlur', composeEventHandlers(onBlur, _this5.input_handleBlur)), _babelHelpers$extends2), rest, {
id: _this5.inputId

@@ -1067,3 +1088,3 @@ });

var refKeySpecified = refKey !== 'ref';
var isComposite = typeof element.type !== 'string';
var isComposite = !isDOMElement(element);
if (isComposite && !refKeySpecified) {

@@ -1074,6 +1095,6 @@ throw new Error('downshift: You returned a non-DOM element. You must specify a refKey in getRootProps');

}
if (!element.props.hasOwnProperty(refKey)) {
if (!getElementProps(element).hasOwnProperty(refKey)) {
throw new Error('downshift: You must apply the ref prop "' + refKey + '" from getRootProps onto your root element.');
}
if (!element.props.hasOwnProperty('onClick')) {
if (!getElementProps(element).hasOwnProperty('onClick')) {
throw new Error('downshift: You must apply the "onClick" prop from getRootProps onto your root element.');

@@ -1080,0 +1101,0 @@ }

@@ -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(C(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 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 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=_(e,t);if(null!==n){var o=getComputedStyle(n),i=n.getBoundingClientRect(),r=parseInt(o.borderTopWidth,10),u=i.top+r,l=e.getBoundingClientRect(),s=l.top+n.scrollTop-u;s<n.scrollTop?n.scrollTop=s:s+l.height>n.scrollTop+i.height&&(n.scrollTop=s+l.height-i.height)}}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 h(){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+"-"+k++}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 c(e){return e===e&&"number"==typeof e}function f(e){return e?"function"==typeof e?e:"function"==typeof e[0]?e[0]:u:u}function g(e,t){var n=t.refKey,o="ref"!==n,i="string"!=typeof e.type;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(!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")},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}}(),I=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},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)},P="undefined"==typeof document?null:document.getElementById("a11y-status-message"),O=[],k=1,_=l.bind(null,function(e){return e.scrollHeight>e.clientHeight}),D=function(e){function t(){var e;y(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)));H.call(r),r.id=p("downshift");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.root_handleClick=h(r.props.onClick,r.root_handleClick),r}return b(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(n,o){return n[o]=e.isStateProp(o)?e.props[o]:t[o],n},{})}},{key:"isStateProp",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,t){var n=this,o=void 0,i={};return this.setState(function(t){t=n.getState(t);var r={},u={};return(e="function"==typeof e?e(t):e).hasOwnProperty("selectedItem")&&(o=e.selectedItem),Object.keys(e).forEach(function(o){"type"!==o&&(t[o]!==e[o]&&(i[o]=e[o]),u[o]=e[o],n.isStateProp(o)||(r[o]=e[o]))}),r},function(){r(t)(),Object.keys(i).length&&n.props.onStateChange(i,n.getState()),void 0!==o&&n.props.onChange(o,n.getState())})}},{key:"getControllerStateAndHelpers",value:function(){var e=this.getState(),t=e.highlightedIndex,n=e.inputValue,o=e.selectedItem,i=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: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(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=f(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(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);D.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,itemCount:t.number,selectedItem:t.any,isOpen:t.bool,inputValue:t.string,highlightedIndex:t.number},D.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(){},onChange:function(){}},D.stateChangeTypes={mouseUp:"__autocomplete_mouseup__"};var H=function(){var e=this;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;e.internalSetState({highlightedIndex:t},function(){s(e.getItemNodeFromIndex(e.getState().highlightedIndex),e._rootNode)})},this.highlightIndex=function(t){e.openMenu(function(){e.setHighlightedIndex(t)})},this.moveHighlightedIndex=function(t){e.getState().isOpen?e.changeHighlighedIndex(t):e.highlightIndex()},this.changeHighlighedIndex=function(t){var n=e.getItemCount()-1;if(!(n<0)){var o=e.getState().highlightedIndex;null===o&&(o=t>0?-1:n+1);var i=o+t;i<0?i=n:i>n&&(i=0),e.setHighlightedIndex(i)}},this.clearSelection=function(){e.internalSetState({selectedItem:null,inputValue:"",isOpen:!1},function(){var t=e._rootNode.querySelector("#"+e.inputId);t&&t.focus&&t.focus()})},this.selectItem=function(t){e.internalSetState({isOpen:!1,highlightedIndex:null,selectedItem:t,inputValue:e.props.itemToString(t)})},this.selectItemAtIndex=function(t){var n=e.items[t];n&&e.selectItem(n)},this.selectHighlightedItem=function(){return e.selectItemAtIndex(e.getState().highlightedIndex)},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=S(n,["refKey","onClick"]);return e.getRootProps.called=!0,e.getRootProps.refKey=i,w((t={},I(t,i,e.rootRef),I(t,"onClick",h(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)},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()}},this.buttonKeyDownHandlers=w({},this.keyDownHandlers,{" ":function(e){e.preventDefault(),this.toggleMenu()}}),this.getButtonProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onClick,o=t.onKeyDown,i=S(t,["onClick","onKeyDown"]),r=e.getState().isOpen;return w({role:"button","aria-label":r?"close menu":"open menu","aria-expanded":r,"aria-haspopup":!0,onClick:h(n,e.button_handleClick),onKeyDown:h(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()},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")),w({},t,{htmlFor:e.inputId})},this.getInputProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onChange,o=t.onKeyDown,i=t.onBlur,r=S(t,["onChange","onKeyDown","onBlur"]);if(e.getInputProps.called=!0,e.getLabelProps.called&&r.id&&r.id!==e.inputId)throw new Error('downshift: You provided the id of "'+r.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,r.id,p("downshift-input"));var u=e.getState(),l=u.inputValue,s=u.isOpen,a=u.highlightedIndex;return w({role:"combobox","aria-autocomplete":"list","aria-expanded":s,"aria-activedescendant":"number"==typeof a&&a>=0?e.getItemId(a):null,autoComplete:"off",value:l,onChange:h(n,e.input_handleChange),onKeyDown:h(o,e.input_handleKeyDown),onBlur:h(i,e.input_handleBlur)},r,{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({isOpen:!0,inputValue:t.target.value})},this.input_handleBlur=function(){e.isMouseDown||e.reset()},this.getItemProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onMouseEnter,o=t.item,i=t.index,r=S(t,["onMouseEnter","item","index"]);return e.items[i]=o,w({id:e.getItemId(i),onMouseEnter:h(n,function(){e.setHighlightedIndex(i)})},r)},this.reset=function(t){e.internalSetState(function(n){var o=n.selectedItem;return{type:t,isOpen:!1,highlightedIndex:null,inputValue:e.props.itemToString(o)}})},this.toggleMenu=function(t,n){e.internalSetState(function(e){var n=!e.isOpen;return"boolean"==typeof t&&(n=t),{isOpen:n}},function(){e.getState().isOpen&&e.setHighlightedIndex(),r(n)()})},this.openMenu=function(t){e.toggleMenu(!0,t)},this.closeMenu=function(t){e.toggleMenu(!1,t)},this.updateStatus=a(function(){if(e._isMounted){var t=e.getState(),o=e.items[t.highlightedIndex]||{},i=e.getItemCount(),r=e.props.getA11yStatusMessage(w({itemToString:e.props.itemToString,previousResultCount:e.previousResultCount,resultCount:i,highlightedItem:o},t));e.previousResultCount=i,n(r)}},200)};return D});
!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=_[_.length-1]===e;_=t?[].concat(O(_),[e]):[e],i().innerHTML=""+_.filter(Boolean).map(o).join("")}function o(e,t){return'<div style="display:'+(t===_.length-1?"block":"none")+';">'+e+"</div>"}function i(){return k||((k=document.createElement("div")).setAttribute("id","a11y-status-message"),k.setAttribute("role","status"),k.setAttribute("aria-live","assertive"),k.setAttribute("aria-relevant","additions text"),Object.assign(k.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),document.body.appendChild(k),k)}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=H(e,t);if(null!==n){var o=getComputedStyle(n),i=n.getBoundingClientRect(),r=parseInt(o.borderTopWidth,10),u=i.top+r,l=e.getBoundingClientRect(),s=l.top+n.scrollTop-u;s<n.scrollTop?n.scrollTop=s:s+l.height>n.scrollTop+i.height&&(n.scrollTop=s+l.height-i.height)}}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 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),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 h(e){return e+"-"+D++}function p(){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!(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 m(e){return e.props||e.attributes}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(!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 I="default"in e?e.default:e;t=t&&t.hasOwnProperty("default")?t.default:t;var v=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},x=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)},C=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},O=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)},k="undefined"==typeof document?null:document.getElementById("a11y-status-message"),_=[],D=1,H=l.bind(null,function(e){return e.scrollHeight>e.clientHeight}),M=function(e){function t(){var e;v(this,t);for(var n=arguments.length,o=Array(n),i=0;i<n;i++)o[i]=arguments[i];var r=P(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(o)));A.call(r),r.id=h("downshift");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.root_handleClick=d(r.props.onClick,r.root_handleClick),r}return x(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.isStateProp(o)?e.props[o]:t[o],n},{})}},{key:"isStateProp",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,t){var n=this,o=void 0,i={};return this.setState(function(t){t=n.getState(t);var r={},u={};return(e="function"==typeof e?e(t):e).hasOwnProperty("selectedItem")&&(o=e.selectedItem),Object.keys(e).forEach(function(o){"type"!==o&&(t[o]!==e[o]&&(i[o]=e[o]),u[o]=e[o],n.isStateProp(o)||(r[o]=e[o]))}),r},function(){r(t)(),Object.keys(i).length&&n.props.onStateChange(i,n.getState()),void 0!==o&&n.props.onChange(o,n.getState())})}},{key:"getControllerStateAndHelpers",value:function(){var e=this.getState(),t=e.highlightedIndex,n=e.inputValue,o=e.selectedItem,i=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: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(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=f(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=f(e(this.getControllerStateAndHelpers()));if(!t)return null;if(this.getRootProps.called)return y(t,this.getRootProps),t;if(g(t))return I.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);M.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,itemCount:t.number,selectedItem:t.any,isOpen:t.bool,inputValue:t.string,highlightedIndex:t.number},M.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(){},onChange:function(){}},M.stateChangeTypes={mouseUp:"__autocomplete_mouseup__"};var A=function(){var e=this;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;e.internalSetState({highlightedIndex:t},function(){s(e.getItemNodeFromIndex(e.getState().highlightedIndex),e._rootNode)})},this.highlightIndex=function(t){e.openMenu(function(){e.setHighlightedIndex(t)})},this.moveHighlightedIndex=function(t){e.getState().isOpen?e.changeHighlighedIndex(t):e.highlightIndex()},this.changeHighlighedIndex=function(t){var n=e.getItemCount()-1;if(!(n<0)){var o=e.getState().highlightedIndex;null===o&&(o=t>0?-1:n+1);var i=o+t;i<0?i=n:i>n&&(i=0),e.setHighlightedIndex(i)}},this.clearSelection=function(){e.internalSetState({selectedItem:null,inputValue:"",isOpen:!1},function(){var t=e._rootNode.querySelector("#"+e.inputId);t&&t.focus&&t.focus()})},this.selectItem=function(t){e.internalSetState({isOpen:!1,highlightedIndex:null,selectedItem:t,inputValue:e.props.itemToString(t)})},this.selectItemAtIndex=function(t){var n=e.items[t];n&&e.selectItem(n)},this.selectHighlightedItem=function(){return e.selectItemAtIndex(e.getState().highlightedIndex)},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=C(n,["refKey","onClick"]);return e.getRootProps.called=!0,e.getRootProps.refKey=i,S((t={},b(t,i,e.rootRef),b(t,"onClick",d(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)},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()}},this.buttonKeyDownHandlers=S({},this.keyDownHandlers,{" ":function(e){e.preventDefault(),this.toggleMenu()}}),this.getButtonProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onClick,o=t.onKeyDown,i=C(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:d(n,e.button_handleClick),onKeyDown:d(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()},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=p(e.inputId,t.htmlFor,h("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=C(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=p(e.inputId,l.id,h("downshift-input"));var s=e.getState(),a=s.inputValue,c=s.isOpen,f=s.highlightedIndex;return S((t={role:"combobox","aria-autocomplete":"list","aria-expanded":c,"aria-activedescendant":"number"==typeof f&&f>=0?e.getItemId(f):null,autoComplete:"off",value:a},b(t,"onChange",d(r,u,e.input_handleChange)),b(t,"onKeyDown",d(o,e.input_handleKeyDown)),b(t,"onBlur",d(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({isOpen:!0,inputValue:t.target.value})},this.input_handleBlur=function(){e.isMouseDown||e.reset()},this.getItemProps=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onMouseEnter,o=t.item,i=t.index,r=C(t,["onMouseEnter","item","index"]);return e.items[i]=o,S({id:e.getItemId(i),onMouseEnter:d(n,function(){e.setHighlightedIndex(i)})},r)},this.reset=function(t){e.internalSetState(function(n){var o=n.selectedItem;return{type:t,isOpen:!1,highlightedIndex:null,inputValue:e.props.itemToString(o)}})},this.toggleMenu=function(t,n){e.internalSetState(function(e){var n=!e.isOpen;return"boolean"==typeof t&&(n=t),{isOpen:n}},function(){e.getState().isOpen&&e.setHighlightedIndex(),r(n)()})},this.openMenu=function(t){e.toggleMenu(!0,t)},this.closeMenu=function(t){e.toggleMenu(!1,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 M});
//# sourceMappingURL=downshift.umd.min.js.map
{
"name": "downshift",
"version": "1.0.0-rc.9",
"version": "1.0.0-rc.10",
"description": "A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete components",

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

},
"files": ["dist"],
"files": [
"dist"
],
"keywords": [],

@@ -34,2 +36,3 @@ "author": "Kent C. Dodds <kent@doddsfamily.us> (http://kentcdodds.com/)",

"babel-plugin-transform-react-jsx": "^6.24.1",
"babel-plugin-transform-react-remove-prop-types": "^0.4.8",
"babel-preset-env": "^1.6.0",

@@ -49,2 +52,3 @@ "babel-preset-react": "^6.24.1",

"preact": "^8.2.1",
"preact-render-to-string": "^3.6.3",
"prettier-eslint-cli": "^4.1.1",

@@ -61,3 +65,4 @@ "prop-types": "^15.5.10",

"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-uglify": "^2.0.1"
"rollup-plugin-uglify": "^2.0.1",
"rollup-watch": "^4.3.1"
},

@@ -77,3 +82,4 @@ "lint-staged": {

},
"homepage": "https://github.com/paypal/downshift#readme"
"homepage": "https://github.com/paypal/downshift#readme",
"dependencies": {}
}

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